Merge pull request #3529 from akallabeth/warning_fixes

Variadic macro warning fixes
This commit is contained in:
Martin Fleisz 2016-10-10 12:23:57 +02:00 committed by GitHub
commit 38f9d0f675
43 changed files with 1416 additions and 1109 deletions

View File

@ -33,9 +33,9 @@
#define TAG CHANNELS_TAG("audin.client")
#ifdef WITH_DEBUG_DVC
#define DEBUG_DVC(fmt, ...) WLog_DBG(TAG, fmt, ## __VA_ARGS__)
#define DEBUG_DVC(...) WLog_DBG(TAG, __VA_ARGS__)
#else
#define DEBUG_DVC(fmt, ...) do { } while (0)
#define DEBUG_DVC(...) do { } while (0)
#endif
#endif /* FREERDP_AUDIN_CLIENT_MAIN_H */

View File

@ -55,9 +55,9 @@ typedef struct cliprdr_plugin cliprdrPlugin;
CliprdrClientContext* cliprdr_get_client_interface(cliprdrPlugin* cliprdr);
#ifdef WITH_DEBUG_CLIPRDR
#define DEBUG_CLIPRDR(fmt, ...) WLog_DBG(TAG, fmt, ## __VA_ARGS__)
#define DEBUG_CLIPRDR(...) WLog_DBG(TAG, __VA_ARGS__)
#else
#define DEBUG_CLIPRDR(fmt, ...) do { } while (0)
#define DEBUG_CLIPRDR(...) do { } while (0)
#endif
#endif /* __CLIPRDR_MAIN_H */

View File

@ -31,9 +31,9 @@
#define DVC_TAG CHANNELS_TAG("echo.client")
#ifdef WITH_DEBUG_DVC
#define DEBUG_DVC(fmt, ...) WLog_DBG(DVC_TAG, fmt, ## __VA_ARGS__)
#define DEBUG_DVC(...) WLog_DBG(DVC_TAG, __VA_ARGS__)
#else
#define DEBUG_DVC(fmt, ...) do { } while (0)
#define DEBUG_DVC(...) do { } while (0)
#endif
#endif /* __ECHO_MAIN_H */

View File

@ -26,9 +26,9 @@ rdpPrinterDriver* printer_win_get_driver(void);
#define PRINTER_TAG CHANNELS_TAG("printer.client")
#ifdef WITH_DEBUG_WINPR
#define DEBUG_WINPR(fmt, ...) WLog_DBG(PRINTER_TAG, fmt, ## __VA_ARGS__)
#define DEBUG_WINPR(...) WLog_DBG(PRINTER_TAG, __VA_ARGS__)
#else
#define DEBUG_WINPR(fmt, ...) do { } while (0)
#define DEBUG_WINPR(...) do { } while (0)
#endif
#endif

View File

@ -82,9 +82,9 @@ struct _RDPINPUT_CONTACT_POINT
typedef struct _RDPINPUT_CONTACT_POINT RDPINPUT_CONTACT_POINT;
#ifdef WITH_DEBUG_DVC
#define DEBUG_DVC(fmt, ...) WLog_DBG(TAG, fmt, ## __VA_ARGS__)
#define DEBUG_DVC(...) WLog_DBG(TAG, __VA_ARGS__)
#else
#define DEBUG_DVC(fmt, ...) do { } while (0)
#define DEBUG_DVC(...) do { } while (0)
#endif
#endif /* FREERDP_CHANNEL_RDPEI_CLIENT_MAIN_H */

View File

@ -30,9 +30,9 @@
#define TAG CHANNELS_TAG("rdpsnd.client")
#if defined(WITH_DEBUG_SND)
#define DEBUG_SND(fmt, ...) WLog_DBG(TAG, fmt, ## __VA_ARGS__)
#define DEBUG_SND(...) WLog_DBG(TAG, __VA_ARGS__)
#else
#define DEBUG_SND(fmt, ...) do { } while (0)
#define DEBUG_SND(...) do { } while (0)
#endif
UINT rdpsnd_virtual_channel_write(rdpsndPlugin* rdpsnd, wStream* s);

View File

@ -31,9 +31,9 @@
#define TAG CHANNELS_TAG("tsmf.client")
#ifdef WITH_DEBUG_TSMF
#define DEBUG_TSMF(fmt, ...) WLog_DBG(TAG, fmt, ## __VA_ARGS__)
#define DEBUG_TSMF(...) WLog_DBG(TAG, __VA_ARGS__)
#else
#define DEBUG_TSMF(fmt, ...) do { } while (0)
#define DEBUG_TSMF(...) do { } while (0)
#endif
typedef struct _TS_AM_MEDIA_TYPE
@ -53,7 +53,7 @@ typedef struct _TS_AM_MEDIA_TYPE
UINT32 Channels;
UINT32 BitsPerSample;
UINT32 BlockAlign;
const BYTE *ExtraData;
const BYTE* ExtraData;
UINT32 ExtraDataSize;
} TS_AM_MEDIA_TYPE;

View File

@ -38,9 +38,9 @@
#define TAG CHANNELS_TAG("urbdrc.client")
#ifdef WITH_DEBUG_DVC
#define DEBUG_DVC(fmt, ...) WLog_DBG(TAG, fmt, ## __VA_ARGS__)
#define DEBUG_DVC(...) WLog_DBG(TAG, __VA_ARGS__)
#else
#define DEBUG_DVC(fmt, ...) do { } while (0)
#define DEBUG_DVC(...) do { } while (0)
#endif
#define CAPABILITIES_NEGOTIATOR 0x00000000
@ -109,25 +109,25 @@
enum device_text_type
{
DeviceTextDescription = 0,
DeviceTextDescription = 0,
DeviceTextLocationInformation = 1,
};
enum device_descriptor_table
{
B_LENGTH = 0,
B_DESCRIPTOR_TYPE = 1,
BCD_USB = 2,
B_LENGTH = 0,
B_DESCRIPTOR_TYPE = 1,
BCD_USB = 2,
B_DEVICE_CLASS = 4,
B_DEVICE_SUBCLASS = 5,
B_DEVICE_SUBCLASS = 5,
B_DEVICE_PROTOCOL = 6,
B_MAX_PACKET_SIZE0 = 7,
ID_VENDOR = 8,
B_MAX_PACKET_SIZE0 = 7,
ID_VENDOR = 8,
ID_PRODUCT = 10,
BCD_DEVICE = 12,
BCD_DEVICE = 12,
I_MANUFACTURER = 14,
I_PRODUCT = 15,
I_SERIAL_NUMBER = 16,
I_PRODUCT = 15,
I_SERIAL_NUMBER = 16,
B_NUM_CONFIGURATIONS = 17
};
@ -259,11 +259,11 @@ enum device_descriptor_table
#define USBD_TRANSFER_DIRECTION_IN 1
#define VALID_TRANSFER_FLAGS_MASK USBD_SHORT_TRANSFER_OK | \
USBD_TRANSFER_DIRECTION | \
USBD_START_ISO_TRANSFER_ASAP | \
USBD_DEFAULT_PIPE_TRANSFER)
#define ENDPOINT_HALT 0x00
USBD_TRANSFER_DIRECTION | \
USBD_START_ISO_TRANSFER_ASAP | \
USBD_DEFAULT_PIPE_TRANSFER)
#define ENDPOINT_HALT 0x00
#define DEVICE_REMOTE_WAKEUP 0x01
/* transfer type */
@ -318,16 +318,16 @@ enum device_descriptor_table
#define LOG_LEVEL 1
#define dummy_wait_obj(void) do{ sleep(5); } while(0)
#define dummy_wait_s_obj(_s) do{ sleep(_s); } while(0)
#define dummy_wait_obj(void) do{ sleep(5); } while(0)
#define dummy_wait_s_obj(_s) do{ sleep(_s); } while(0)
#define ISOCH_FIFO 1
#define WAIT_COMPLETE_SLEEP 10000 /* for cpu high loading */
#define urbdrc_get_mstime(_t) do { \
struct timeval _tp; \
gettimeofday(&_tp, 0); \
_t = (_tp.tv_sec * 1000) + (_tp.tv_usec / 1000); \
} while (0)
struct timeval _tp; \
gettimeofday(&_tp, 0); \
_t = (_tp.tv_sec * 1000) + (_tp.tv_usec / 1000); \
} while (0)
#endif /* __URBDRC_TYPES_H */

View File

@ -48,9 +48,9 @@
#define TAG CLIENT_TAG("windows")
#ifdef WITH_DEBUG_CLIPRDR
#define DEBUG_CLIPRDR(fmt, ...) WLog_DBG(TAG, fmt, ## __VA_ARGS__)
#define DEBUG_CLIPRDR(...) WLog_DBG(TAG, __VA_ARGS__)
#else
#define DEBUG_CLIPRDR(fmt, ...) do { } while (0)
#define DEBUG_CLIPRDR(...) do { } while (0)
#endif
typedef BOOL (WINAPI* fnAddClipboardFormatListener)(HWND hwnd);

View File

@ -33,9 +33,9 @@ void wf_event_focus_in(wfContext* wfc);
#define KBD_TAG CLIENT_TAG("windows")
#ifdef WITH_DEBUG_KBD
#define DEBUG_KBD(fmt, ...) WLog_DBG(KBD_TAG, fmt, ## __VA_ARGS__)
#define DEBUG_KBD(...) WLog_DBG(KBD_TAG, __VA_ARGS__)
#else
#define DEBUG_KBD(fmt, ...) do { } while (0)
#define DEBUG_KBD(...) do { } while (0)
#endif
#endif /* __WF_EVENT_H */

View File

@ -1383,7 +1383,6 @@ static BOOL xf_auto_reconnect(freerdp* instance)
{
UINT32 maxRetries;
UINT32 numRetries = 0;
xfContext* xfc = (xfContext*) instance->context;
rdpSettings* settings = instance->settings;
maxRetries = settings->AutoReconnectMaxRetries;

View File

@ -80,9 +80,9 @@ const char* const X11_EVENT_STRINGS[] =
};
#ifdef WITH_DEBUG_X11
#define DEBUG_X11(fmt, ...) WLog_DBG(TAG, fmt, ## __VA_ARGS__)
#define DEBUG_X11(...) WLog_DBG(TAG, __VA_ARGS__)
#else
#define DEBUG_X11(fmt, ...) do { } while (0)
#define DEBUG_X11(...) do { } while (0)
#endif
BOOL xf_event_action_script_init(xfContext* xfc)

View File

@ -58,9 +58,9 @@
#define TAG CLIENT_TAG("x11")
#ifdef WITH_DEBUG_X11
#define DEBUG_X11(fmt, ...) WLog_DBG(TAG, fmt, ## __VA_ARGS__)
#define DEBUG_X11(...) WLog_DBG(TAG, __VA_ARGS__)
#else
#define DEBUG_X11(fmt, ...) do { } while (0)
#define DEBUG_X11(...) do { } while (0)
#endif
#include "FreeRDP_Icon_256px.h"

View File

@ -750,7 +750,7 @@ static char** freerdp_command_line_parse_comma_separated_values_offset(
p = t;
if (count > 0)
if (count)
MoveMemory(&p[1], p, sizeof(char*)** count);
(*count)++;
@ -2506,7 +2506,7 @@ int freerdp_client_settings_parse_command_line_arguments(rdpSettings* settings,
static BOOL freerdp_client_load_static_channel_addin(rdpChannels* channels,
rdpSettings* settings, char* name, void* data)
{
void* entry;
PVIRTUALCHANNELENTRY entry;
entry = freerdp_load_channel_addin_entry(name, NULL, NULL,
FREERDP_ADDIN_CHANNEL_STATIC);

View File

@ -46,7 +46,8 @@ struct _FREERDP_ADDIN
};
typedef struct _FREERDP_ADDIN FREERDP_ADDIN;
typedef void* (*FREERDP_LOAD_CHANNEL_ADDIN_ENTRY_FN)(LPCSTR pszName, LPSTR pszSubsystem, LPSTR pszType, DWORD dwFlags);
typedef PVIRTUALCHANNELENTRY(*FREERDP_LOAD_CHANNEL_ADDIN_ENTRY_FN)(
LPCSTR pszName, LPSTR pszSubsystem, LPSTR pszType, DWORD dwFlags);
#ifdef __cplusplus
extern "C" {
@ -55,11 +56,15 @@ extern "C" {
FREERDP_API LPSTR freerdp_get_library_install_path(void);
FREERDP_API LPSTR freerdp_get_dynamic_addin_install_path(void);
FREERDP_API int freerdp_register_addin_provider(FREERDP_LOAD_CHANNEL_ADDIN_ENTRY_FN provider, DWORD dwFlags);
FREERDP_API int freerdp_register_addin_provider(
FREERDP_LOAD_CHANNEL_ADDIN_ENTRY_FN provider, DWORD dwFlags);
FREERDP_API void* freerdp_load_dynamic_addin(LPCSTR pszFileName, LPCSTR pszPath, LPCSTR pszEntryName);
FREERDP_API void* freerdp_load_dynamic_channel_addin_entry(LPCSTR pszName, LPSTR pszSubsystem, LPSTR pszType, DWORD dwFlags);
FREERDP_API void* freerdp_load_channel_addin_entry(LPCSTR pszName, LPSTR pszSubsystem, LPSTR pszType, DWORD dwFlags);
FREERDP_API PVIRTUALCHANNELENTRY freerdp_load_dynamic_addin(LPCSTR pszFileName,
LPCSTR pszPath, LPCSTR pszEntryName);
FREERDP_API PVIRTUALCHANNELENTRY freerdp_load_dynamic_channel_addin_entry(
LPCSTR pszName, LPSTR pszSubsystem, LPSTR pszType, DWORD dwFlags);
FREERDP_API PVIRTUALCHANNELENTRY freerdp_load_channel_addin_entry(
LPCSTR pszName, LPSTR pszSubsystem, LPSTR pszType, DWORD dwFlags);
#ifdef __cplusplus
}

View File

@ -34,9 +34,9 @@
#define RFX_TAG FREERDP_TAG("codec.rfx")
#ifdef WITH_DEBUG_RFX
#define DEBUG_RFX(fmt, ...) WLog_DBG(RFX_TAG, fmt, ## __VA_ARGS__)
#define DEBUG_RFX(...) WLog_DBG(RFX_TAG, __VA_ARGS__)
#else
#define DEBUG_RFX(fmt, ...) do { } while (0)
#define DEBUG_RFX(...) do { } while (0)
#endif
typedef struct _RFX_TILE_COMPOSE_WORK_PARAM RFX_TILE_COMPOSE_WORK_PARAM;
@ -55,7 +55,7 @@ struct _RFX_CONTEXT_PRIV
PTP_POOL ThreadPool;
TP_CALLBACK_ENVIRON ThreadPoolEnv;
wBufferPool* BufferPool;
/* profilers */

View File

@ -33,7 +33,7 @@
#include <freerdp/build-config.h>
LPSTR freerdp_get_library_install_path()
LPSTR freerdp_get_library_install_path(void)
{
LPSTR pszPath;
size_t cchPath;
@ -41,12 +41,11 @@ LPSTR freerdp_get_library_install_path()
size_t cchInstallPrefix;
LPCSTR pszLibraryPath = FREERDP_LIBRARY_PATH;
LPCSTR pszInstallPrefix = FREERDP_INSTALL_PREFIX;
cchLibraryPath = strlen(pszLibraryPath);
cchInstallPrefix = strlen(pszInstallPrefix);
cchPath = cchInstallPrefix + cchLibraryPath + 2;
pszPath = (LPSTR) malloc(cchPath + 1);
if (!pszPath)
return NULL;
@ -62,7 +61,7 @@ LPSTR freerdp_get_library_install_path()
return pszPath;
}
LPSTR freerdp_get_dynamic_addin_install_path()
LPSTR freerdp_get_dynamic_addin_install_path(void)
{
LPSTR pszPath;
size_t cchPath;
@ -70,12 +69,11 @@ LPSTR freerdp_get_dynamic_addin_install_path()
size_t cchInstallPrefix;
LPCSTR pszAddinPath = FREERDP_ADDIN_PATH;
LPCSTR pszInstallPrefix = FREERDP_INSTALL_PREFIX;
cchAddinPath = strlen(pszAddinPath);
cchInstallPrefix = strlen(pszInstallPrefix);
cchPath = cchInstallPrefix + cchAddinPath + 2;
pszPath = (LPSTR) malloc(cchPath + 1);
if (!pszPath)
return NULL;
@ -91,9 +89,10 @@ LPSTR freerdp_get_dynamic_addin_install_path()
return pszPath;
}
void* freerdp_load_dynamic_addin(LPCSTR pszFileName, LPCSTR pszPath, LPCSTR pszEntryName)
PVIRTUALCHANNELENTRY freerdp_load_dynamic_addin(LPCSTR pszFileName,
LPCSTR pszPath, LPCSTR pszEntryName)
{
void* entry;
PVIRTUALCHANNELENTRY entry;
BOOL bHasExt;
PCSTR pszExt;
size_t cchExt;
@ -105,7 +104,6 @@ void* freerdp_load_dynamic_addin(LPCSTR pszFileName, LPCSTR pszPath, LPCSTR pszE
size_t cchAddinFile;
LPSTR pszAddinInstallPath;
size_t cchAddinInstallPath;
entry = NULL;
cchExt = 0;
bHasExt = TRUE;
@ -119,12 +117,14 @@ void* freerdp_load_dynamic_addin(LPCSTR pszFileName, LPCSTR pszPath, LPCSTR pszE
}
pszAddinInstallPath = freerdp_get_dynamic_addin_install_path();
if (!pszAddinInstallPath)
return NULL;
cchAddinInstallPath = strlen(pszAddinInstallPath);
cchAddinInstallPath = strlen(pszAddinInstallPath);
cchFilePath = cchAddinInstallPath + cchFileName + 32;
pszFilePath = (LPSTR) malloc(cchFilePath + 1);
if (!pszFilePath)
{
free(pszAddinInstallPath);
@ -134,35 +134,37 @@ void* freerdp_load_dynamic_addin(LPCSTR pszFileName, LPCSTR pszPath, LPCSTR pszE
if (bHasExt)
{
pszAddinFile = _strdup(pszFileName);
if (!pszAddinFile)
{
free(pszAddinInstallPath);
free(pszFilePath);
return NULL;
}
cchAddinFile = strlen(pszAddinFile);
}
else
{
cchAddinFile = cchFileName + cchExt + 2 + sizeof(FREERDP_SHARED_LIBRARY_PREFIX);
pszAddinFile = (LPSTR) malloc(cchAddinFile + 1);
if (!pszAddinFile)
{
free(pszAddinInstallPath);
free(pszFilePath);
return NULL;
}
sprintf_s(pszAddinFile, cchAddinFile, FREERDP_SHARED_LIBRARY_PREFIX"%s%s", pszFileName, pszExt);
sprintf_s(pszAddinFile, cchAddinFile, FREERDP_SHARED_LIBRARY_PREFIX"%s%s",
pszFileName, pszExt);
cchAddinFile = strlen(pszAddinFile);
}
CopyMemory(pszFilePath, pszAddinInstallPath, cchAddinInstallPath);
pszFilePath[cchAddinInstallPath] = '\0';
NativePathCchAppendA((LPSTR) pszFilePath, cchFilePath + 1, pszAddinFile);
library = LoadLibraryA(pszFilePath);
free(pszAddinInstallPath);
free(pszAddinFile);
free(pszFilePath);
@ -170,7 +172,7 @@ void* freerdp_load_dynamic_addin(LPCSTR pszFileName, LPCSTR pszPath, LPCSTR pszE
if (!library)
return NULL;
entry = GetProcAddress(library, pszEntryName);
entry = (PVIRTUALCHANNELENTRY)GetProcAddress(library, pszEntryName);
if (entry)
return entry;
@ -179,43 +181,51 @@ void* freerdp_load_dynamic_addin(LPCSTR pszFileName, LPCSTR pszPath, LPCSTR pszE
return entry;
}
void* freerdp_load_dynamic_channel_addin_entry(LPCSTR pszName, LPSTR pszSubsystem, LPSTR pszType, DWORD dwFlags)
PVIRTUALCHANNELENTRY freerdp_load_dynamic_channel_addin_entry(LPCSTR pszName,
LPSTR pszSubsystem, LPSTR pszType, DWORD dwFlags)
{
void* entry;
PVIRTUALCHANNELENTRY entry;
LPSTR pszFileName;
size_t cchFileName = sizeof(FREERDP_SHARED_LIBRARY_PREFIX) + 32;
LPCSTR pszExtension;
LPCSTR pszPrefix = FREERDP_SHARED_LIBRARY_PREFIX;
pszExtension = PathGetSharedLibraryExtensionA(0);
if (pszName && pszSubsystem && pszType)
{
cchFileName += strlen(pszName) + strlen(pszSubsystem) + strlen(pszType) + strlen(pszExtension);
cchFileName += strlen(pszName) + strlen(pszSubsystem) + strlen(
pszType) + strlen(pszExtension);
pszFileName = (LPSTR) malloc(cchFileName);
if (!pszFileName)
return NULL;
sprintf_s(pszFileName, cchFileName, "%s%s-client-%s-%s.%s", pszPrefix, pszName, pszSubsystem, pszType, pszExtension);
sprintf_s(pszFileName, cchFileName, "%s%s-client-%s-%s.%s", pszPrefix, pszName,
pszSubsystem, pszType, pszExtension);
cchFileName = strlen(pszFileName);
}
else if (pszName && pszSubsystem)
{
cchFileName += strlen(pszName) + strlen(pszSubsystem) + strlen(pszExtension);
pszFileName = (LPSTR) malloc(cchFileName);
if (!pszFileName)
return NULL;
sprintf_s(pszFileName, cchFileName, "%s%s-client-%s.%s", pszPrefix, pszName, pszSubsystem, pszExtension);
sprintf_s(pszFileName, cchFileName, "%s%s-client-%s.%s", pszPrefix, pszName,
pszSubsystem, pszExtension);
cchFileName = strlen(pszFileName);
}
else if (pszName)
{
cchFileName += strlen(pszName) + strlen(pszExtension);
pszFileName = (LPSTR) malloc(cchFileName);
if (!pszFileName)
return NULL;
sprintf_s(pszFileName, cchFileName, "%s%s-client.%s", pszPrefix, pszName, pszExtension);
sprintf_s(pszFileName, cchFileName, "%s%s-client.%s", pszPrefix, pszName,
pszExtension);
cchFileName = strlen(pszFileName);
}
else
@ -227,23 +237,21 @@ void* freerdp_load_dynamic_channel_addin_entry(LPCSTR pszName, LPSTR pszSubsyste
{
LPSTR pszEntryName;
size_t cchEntryName;
/* subsystem add-in */
cchEntryName = 64 + strlen(pszName);
pszEntryName = (LPSTR) malloc(cchEntryName + 1);
if (!pszEntryName)
{
free(pszFileName);
return NULL;
}
sprintf_s(pszEntryName, cchEntryName + 1, "freerdp_%s_client_subsystem_entry", pszName);
sprintf_s(pszEntryName, cchEntryName + 1, "freerdp_%s_client_subsystem_entry",
pszName);
entry = freerdp_load_dynamic_addin(pszFileName, NULL, pszEntryName);
free(pszEntryName);
free(pszFileName);
return entry;
}
@ -262,23 +270,28 @@ void* freerdp_load_dynamic_channel_addin_entry(LPCSTR pszName, LPSTR pszSubsyste
return entry;
}
static FREERDP_LOAD_CHANNEL_ADDIN_ENTRY_FN freerdp_load_static_channel_addin_entry = NULL;
static FREERDP_LOAD_CHANNEL_ADDIN_ENTRY_FN
freerdp_load_static_channel_addin_entry = NULL;
int freerdp_register_addin_provider(FREERDP_LOAD_CHANNEL_ADDIN_ENTRY_FN provider, DWORD dwFlags)
int freerdp_register_addin_provider(FREERDP_LOAD_CHANNEL_ADDIN_ENTRY_FN
provider, DWORD dwFlags)
{
freerdp_load_static_channel_addin_entry = provider;
return 0;
}
void* freerdp_load_channel_addin_entry(LPCSTR pszName, LPSTR pszSubsystem, LPSTR pszType, DWORD dwFlags)
PVIRTUALCHANNELENTRY freerdp_load_channel_addin_entry(LPCSTR pszName,
LPSTR pszSubsystem, LPSTR pszType, DWORD dwFlags)
{
void* entry = NULL;
PVIRTUALCHANNELENTRY entry = NULL;
if (freerdp_load_static_channel_addin_entry)
entry = freerdp_load_static_channel_addin_entry(pszName, pszSubsystem, pszType, dwFlags);
entry = freerdp_load_static_channel_addin_entry(pszName, pszSubsystem, pszType,
dwFlags);
if (!entry)
entry = freerdp_load_dynamic_channel_addin_entry(pszName, pszSubsystem, pszType, dwFlags);
entry = freerdp_load_dynamic_channel_addin_entry(pszName, pszSubsystem, pszType,
dwFlags);
return entry;
}

View File

@ -72,9 +72,9 @@ FREERDP_LOCAL void key_free(rdpRsaKey* key);
#define CERTIFICATE_TAG FREERDP_TAG("core.certificate")
#ifdef WITH_DEBUG_CERTIFICATE
#define DEBUG_CERTIFICATE(fmt, ...) WLog_DBG(CERTIFICATE_TAG, fmt, ## __VA_ARGS__)
#define DEBUG_CERTIFICATE(...) WLog_DBG(CERTIFICATE_TAG, __VA_ARGS__)
#else
#define DEBUG_CERTIFICATE(fmt, ...) do { } while (0)
#define DEBUG_CERTIFICATE(...) do { } while (0)
#endif
#endif /* __CERTIFICATE_H */

View File

@ -770,8 +770,8 @@ int freerdp_channels_client_load(rdpChannels* channels, rdpSettings* settings,
int freerdp_channels_load_plugin(rdpChannels* channels, rdpSettings* settings,
const char* name, void* data)
{
void* entry;
entry = (PVIRTUALCHANNELENTRY) freerdp_load_channel_addin_entry(name, NULL,
PVIRTUALCHANNELENTRY entry;
entry = freerdp_load_channel_addin_entry(name, NULL,
NULL, FREERDP_ADDIN_CHANNEL_STATIC);
if (!entry)

View File

@ -252,9 +252,9 @@ FREERDP_LOCAL void license_free(rdpLicense* license);
#define LICENSE_TAG FREERDP_TAG("core.license")
#ifdef WITH_DEBUG_LICENSE
#define DEBUG_LICENSE(fmt, ...) WLog_DBG(LICENSE_TAG, fmt, ## __VA_ARGS__)
#define DEBUG_LICENSE(...) WLog_DBG(LICENSE_TAG, __VA_ARGS__)
#else
#define DEBUG_LICENSE(fmt, ...) do { } while (0)
#define DEBUG_LICENSE(...) do { } while (0)
#endif
#endif /* __LICENSE_H */

View File

@ -147,26 +147,26 @@ FREERDP_LOCAL void nego_free(rdpNego* nego);
FREERDP_LOCAL void nego_init(rdpNego* nego);
FREERDP_LOCAL void nego_set_target(rdpNego* nego, char* hostname, int port);
FREERDP_LOCAL void nego_set_negotiation_enabled(rdpNego* nego,
BOOL NegotiateSecurityLayer);
BOOL NegotiateSecurityLayer);
FREERDP_LOCAL void nego_set_restricted_admin_mode_required(rdpNego* nego,
BOOL RestrictedAdminModeRequired);
BOOL RestrictedAdminModeRequired);
FREERDP_LOCAL void nego_set_gateway_enabled(rdpNego* nego, BOOL GatewayEnabled);
FREERDP_LOCAL void nego_set_gateway_bypass_local(rdpNego* nego,
BOOL GatewayBypassLocal);
BOOL GatewayBypassLocal);
FREERDP_LOCAL void nego_enable_rdp(rdpNego* nego, BOOL enable_rdp);
FREERDP_LOCAL void nego_enable_tls(rdpNego* nego, BOOL enable_tls);
FREERDP_LOCAL void nego_enable_nla(rdpNego* nego, BOOL enable_nla);
FREERDP_LOCAL void nego_enable_ext(rdpNego* nego, BOOL enable_ext);
FREERDP_LOCAL BOOL nego_set_routing_token(rdpNego* nego, BYTE* RoutingToken,
DWORD RoutingTokenLength);
DWORD RoutingTokenLength);
FREERDP_LOCAL BOOL nego_set_cookie(rdpNego* nego, char* cookie);
FREERDP_LOCAL void nego_set_cookie_max_length(rdpNego* nego,
UINT32 CookieMaxLength);
UINT32 CookieMaxLength);
FREERDP_LOCAL void nego_set_send_preconnection_pdu(rdpNego* nego,
BOOL SendPreconnectionPdu);
BOOL SendPreconnectionPdu);
FREERDP_LOCAL void nego_set_preconnection_id(rdpNego* nego,
UINT32 PreconnectionId);
UINT32 PreconnectionId);
FREERDP_LOCAL void nego_set_preconnection_blob(rdpNego* nego,
char* PreconnectionBlob);
char* PreconnectionBlob);
#endif /* __NEGO_H */

View File

@ -241,9 +241,9 @@ FREERDP_LOCAL void rdp_free(rdpRdp* rdp);
#define RDP_TAG FREERDP_TAG("core.rdp")
#ifdef WITH_DEBUG_RDP
#define DEBUG_RDP(fmt, ...) WLog_DBG(RDP_TAG, fmt, ## __VA_ARGS__)
#define DEBUG_RDP(...) WLog_DBG(RDP_TAG, __VA_ARGS__)
#else
#define DEBUG_RDP(fmt, ...) do { } while (0)
#define DEBUG_RDP(...) do { } while (0)
#endif
BOOL rdp_decrypt(rdpRdp* rdp, wStream* s, int length, UINT16 securityFlags);

View File

@ -60,9 +60,9 @@ FREERDP_LOCAL void redirection_free(rdpRedirection* redirection);
#define REDIR_TAG FREERDP_TAG("core.redirection")
#ifdef WITH_DEBUG_REDIR
#define DEBUG_REDIR(fmt, ...) WLog_DBG(REDIR_TAG, fmt, ## __VA_ARGS__)
#define DEBUG_REDIR(...) WLog_DBG(REDIR_TAG, __VA_ARGS__)
#else
#define DEBUG_REDIR(fmt, ...) do { } while (0)
#define DEBUG_REDIR(...) do { } while (0)
#endif
#endif /* __REDIRECTION_H */

File diff suppressed because it is too large Load Diff

View File

@ -38,9 +38,9 @@ FREERDP_LOCAL BOOL rdp_write_client_time_zone(wStream* s,
#define TIMEZONE_TAG FREERDP_TAG("core.timezone")
#ifdef WITH_DEBUG_TIMEZONE
#define DEBUG_TIMEZONE(fmt, ...) WLog_DBG(TIMEZONE_TAG, fmt, ## __VA_ARGS__)
#define DEBUG_TIMEZONE(...) WLog_DBG(TIMEZONE_TAG, __VA_ARGS__)
#else
#define DEBUG_TIMEZONE(fmt, ...) do { } while (0)
#define DEBUG_TIMEZONE(...) do { } while (0)
#endif
#endif /* __TIMEZONE_H */

View File

@ -382,26 +382,23 @@ static void transport_bio_error_log(LPCSTR tag, LPCSTR biofunc, BIO* bio,
wLog* log;
wLogMessage log_message;
int saveerrno;
DWORD level;
saveerrno = errno;
log = WLog_Get(tag);
if (!log)
return;
log_message.Level = WLOG_ERROR;
level = WLOG_ERROR;
if (log_message.Level < WLog_GetLogLevel(log))
if (level < WLog_GetLogLevel(log))
return;
log_message.Type = WLOG_MESSAGE_TEXT;
log_message.LineNumber = line;
log_message.FileName = file;
log_message.FunctionName = func;
if (ERR_peek_error() == 0)
{
log_message.FormatString = "%s returned a system error %d: %s";
WLog_PrintMessage(log, &log_message, biofunc, saveerrno, strerror(saveerrno));
const char* fmt = "%s returned a system error %d: %s";
WLog_PrintMessage(log, WLOG_MESSAGE_TEXT, level, line, file, func, fmt, biofunc,
saveerrno, strerror(saveerrno));
return;
}
@ -409,11 +406,13 @@ static void transport_bio_error_log(LPCSTR tag, LPCSTR biofunc, BIO* bio,
if (buf)
{
const char* fmt = "%s returned an error: %s";
while ((sslerr = ERR_get_error()))
{
ERR_error_string_n(sslerr, buf, 120);
log_message.FormatString = "%s returned an error: %s";
WLog_PrintMessage(log, &log_message, biofunc, buf);
WLog_PrintMessage(log, WLOG_MESSAGE_TEXT, level, line, file, func, fmt, biofunc,
buf);
}
free(buf);

View File

@ -32,9 +32,9 @@ FREERDP_LOCAL BOOL update_recv_altsec_window_order(rdpUpdate* update,
#define WND_TAG FREERDP_TAG("core.wnd")
#ifdef WITH_DEBUG_WND
#define DEBUG_WND(fmt, ...) WLog_DBG(WND_TAG, fmt, ## __VA_ARGS__)
#define DEBUG_WND(...) WLog_DBG(WND_TAG, __VA_ARGS__)
#else
#define DEBUG_WND(fmt, ...) do { } while (0)
#define DEBUG_WND(...) do { } while (0)
#endif
#endif /* __WINDOW_H */

View File

@ -28,16 +28,16 @@
#define KBD_TAG FREERDP_TAG("locale")
#ifdef WITH_DEBUG_KBD
#define DEBUG_KBD(fmt, ...) WLog_DBG(KBD_TAG, fmt, ## __VA_ARGS__)
#define DEBUG_KBD(...) WLog_DBG(KBD_TAG, __VA_ARGS__)
#else
#define DEBUG_KBD(fmt, ...) do { } while (0)
#define DEBUG_KBD(...) do { } while (0)
#endif
#define TIMEZONE_TAG FREERDP_TAG("timezone")
#ifdef WITH_DEBUG_TIMEZONE
#define DEBUG_TIMEZONE(fmt, ...) WLog_DBG(TIMEZONE_TAG, fmt, ## __VA_ARGS__)
#define DEBUG_TIMEZONE(...) WLog_DBG(TIMEZONE_TAG, __VA_ARGS__)
#else
#define DEBUG_TIMEZONE(fmt, ...) do { } while (0)
#define DEBUG_TIMEZONE(...) do { } while (0)
#endif
#endif /* __LIBLOCALE_H */

View File

@ -28,9 +28,9 @@
#define TAG FREERDP_TAG("utils")
#ifdef WITH_DEBUG_MSUSB
#define DEBUG_MSUSB(fmt, ...) WLog_DBG(TAG, fmt, ## __VA_ARGS__)
#define DEBUG_MSUSB(...) WLog_DBG(TAG, __VA_ARGS__)
#else
#define DEBUG_MSUSB(fmt, ...) do { } while (0)
#define DEBUG_MSUSB(...) do { } while (0)
#endif
@ -39,7 +39,8 @@ static MSUSB_PIPE_DESCRIPTOR* msusb_mspipe_new()
return (MSUSB_PIPE_DESCRIPTOR*) calloc(1, sizeof(MSUSB_PIPE_DESCRIPTOR));
}
static void msusb_mspipes_free(MSUSB_PIPE_DESCRIPTOR** MsPipes, UINT32 NumberOfPipes)
static void msusb_mspipes_free(MSUSB_PIPE_DESCRIPTOR** MsPipes,
UINT32 NumberOfPipes)
{
int pnum = 0;
@ -47,13 +48,15 @@ static void msusb_mspipes_free(MSUSB_PIPE_DESCRIPTOR** MsPipes, UINT32 NumberOfP
{
for (pnum = 0; pnum < NumberOfPipes && MsPipes[pnum]; pnum++)
{
zfree(MsPipes[pnum]);
zfree(MsPipes[pnum]);
}
zfree(MsPipes);
}
}
void msusb_mspipes_replace(MSUSB_INTERFACE_DESCRIPTOR* MsInterface, MSUSB_PIPE_DESCRIPTOR** NewMsPipes, UINT32 NewNumberOfPipes)
void msusb_mspipes_replace(MSUSB_INTERFACE_DESCRIPTOR* MsInterface,
MSUSB_PIPE_DESCRIPTOR** NewMsPipes, UINT32 NewNumberOfPipes)
{
/* free orignal MsPipes */
msusb_mspipes_free(MsInterface->MsPipes, MsInterface->NumberOfPipes);
@ -62,51 +65,55 @@ void msusb_mspipes_replace(MSUSB_INTERFACE_DESCRIPTOR* MsInterface, MSUSB_PIPE_D
MsInterface->NumberOfPipes = NewNumberOfPipes;
}
static MSUSB_PIPE_DESCRIPTOR** msusb_mspipes_read(BYTE* data, UINT32 data_size, UINT32 NumberOfPipes, int* offset)
static MSUSB_PIPE_DESCRIPTOR** msusb_mspipes_read(BYTE* data, UINT32 data_size,
UINT32 NumberOfPipes, int* offset)
{
int pnum, move = 0;
MSUSB_PIPE_DESCRIPTOR** MsPipes;
MsPipes = (MSUSB_PIPE_DESCRIPTOR**) calloc(NumberOfPipes, sizeof(MSUSB_PIPE_DESCRIPTOR*));
MsPipes = (MSUSB_PIPE_DESCRIPTOR**) calloc(NumberOfPipes,
sizeof(MSUSB_PIPE_DESCRIPTOR*));
if (!MsPipes)
return NULL;
for (pnum = 0; pnum < NumberOfPipes; pnum++)
{
MSUSB_PIPE_DESCRIPTOR *MsPipe = msusb_mspipe_new();
MSUSB_PIPE_DESCRIPTOR* MsPipe = msusb_mspipe_new();
if (!MsPipe)
goto out_error;
data_read_UINT16(data + move, MsPipe->MaximumPacketSize);
data_read_UINT32(data + move + 4, MsPipe->MaximumTransferSize);
data_read_UINT32(data + move + 8, MsPipe->PipeFlags);
move += 12;
/* Already set to zero by memset
MsPipe->PipeHandle = 0;
MsPipe->bEndpointAddress = 0;
MsPipe->bInterval = 0;
MsPipe->PipeType = 0;
MsPipe->InitCompleted = 0;
*/
/* Already set to zero by memset
MsPipe->PipeHandle = 0;
MsPipe->bEndpointAddress = 0;
MsPipe->bInterval = 0;
MsPipe->PipeType = 0;
MsPipe->InitCompleted = 0;
*/
MsPipes[pnum] = MsPipe;
}
*offset += move;
return MsPipes;
}
*offset += move;
return MsPipes;
out_error:
for (pnum = 0; pnum < NumberOfPipes; pnum++)
{
free(MsPipes[pnum]);
}
free(MsPipes);
return NULL;
}
static MSUSB_INTERFACE_DESCRIPTOR* msusb_msinterface_new()
{
return (MSUSB_INTERFACE_DESCRIPTOR*) calloc(1, sizeof(MSUSB_INTERFACE_DESCRIPTOR));
return (MSUSB_INTERFACE_DESCRIPTOR*) calloc(1,
sizeof(MSUSB_INTERFACE_DESCRIPTOR));
}
static void msusb_msinterface_free(MSUSB_INTERFACE_DESCRIPTOR* MsInterface)
@ -119,7 +126,8 @@ static void msusb_msinterface_free(MSUSB_INTERFACE_DESCRIPTOR* MsInterface)
}
}
static void msusb_msinterface_free_list(MSUSB_INTERFACE_DESCRIPTOR** MsInterfaces, UINT32 NumInterfaces)
static void msusb_msinterface_free_list(MSUSB_INTERFACE_DESCRIPTOR**
MsInterfaces, UINT32 NumInterfaces)
{
int inum = 0;
@ -134,68 +142,70 @@ static void msusb_msinterface_free_list(MSUSB_INTERFACE_DESCRIPTOR** MsInterface
}
}
void msusb_msinterface_replace(MSUSB_CONFIG_DESCRIPTOR* MsConfig, BYTE InterfaceNumber, MSUSB_INTERFACE_DESCRIPTOR* NewMsInterface)
void msusb_msinterface_replace(MSUSB_CONFIG_DESCRIPTOR* MsConfig,
BYTE InterfaceNumber, MSUSB_INTERFACE_DESCRIPTOR* NewMsInterface)
{
msusb_msinterface_free(MsConfig->MsInterfaces[InterfaceNumber]);
MsConfig->MsInterfaces[InterfaceNumber] = NewMsInterface;
MsConfig->MsInterfaces[InterfaceNumber] = NewMsInterface;
}
MSUSB_INTERFACE_DESCRIPTOR* msusb_msinterface_read(BYTE* data, UINT32 data_size, int* offset)
MSUSB_INTERFACE_DESCRIPTOR* msusb_msinterface_read(BYTE* data, UINT32 data_size,
int* offset)
{
MSUSB_INTERFACE_DESCRIPTOR* MsInterface;
MsInterface = msusb_msinterface_new();
if (!MsInterface)
return NULL;
data_read_UINT16(data, MsInterface->Length);
data_read_UINT16(data + 2, MsInterface->NumberOfPipesExpected);
data_read_BYTE(data + 4, MsInterface->InterfaceNumber);
data_read_BYTE(data + 5, MsInterface->AlternateSetting);
data_read_UINT32(data + 8, MsInterface->NumberOfPipes);
*offset += 12;
MsInterface->InterfaceHandle = 0;
MsInterface->bInterfaceClass = 0;
MsInterface->bInterfaceSubClass = 0;
MsInterface->bInterfaceProtocol = 0;
MsInterface->InitCompleted = 0;
MsInterface->MsPipes = NULL;
if (MsInterface->NumberOfPipes > 0)
{
MsInterface->MsPipes =
msusb_mspipes_read(data+(*offset), data_size-(*offset), MsInterface->NumberOfPipes, offset);
MsInterface->MsPipes =
msusb_mspipes_read(data + (*offset), data_size - (*offset),
MsInterface->NumberOfPipes, offset);
if (!MsInterface->MsPipes)
goto out_error;
}
return MsInterface;
return MsInterface;
out_error:
msusb_msinterface_free(MsInterface);
return NULL;
}
int msusb_msinterface_write(MSUSB_INTERFACE_DESCRIPTOR* MsInterface, BYTE* data, int* offset)
int msusb_msinterface_write(MSUSB_INTERFACE_DESCRIPTOR* MsInterface, BYTE* data,
int* offset)
{
MSUSB_PIPE_DESCRIPTOR ** MsPipes;
MSUSB_PIPE_DESCRIPTOR * MsPipe;
MSUSB_PIPE_DESCRIPTOR** MsPipes;
MSUSB_PIPE_DESCRIPTOR* MsPipe;
int pnum = 0, move = 0;
/* Length */
data_write_UINT16(data, MsInterface->Length);
data_write_UINT16(data, MsInterface->Length);
/* InterfaceNumber */
data_write_BYTE(data + 2, MsInterface->InterfaceNumber);
data_write_BYTE(data + 2, MsInterface->InterfaceNumber);
/* AlternateSetting */
data_write_BYTE(data + 3, MsInterface->AlternateSetting);
data_write_BYTE(data + 3, MsInterface->AlternateSetting);
/* bInterfaceClass */
data_write_BYTE(data + 4, MsInterface->bInterfaceClass);
data_write_BYTE(data + 4, MsInterface->bInterfaceClass);
/* bInterfaceSubClass */
data_write_BYTE(data + 5, MsInterface->bInterfaceSubClass);
data_write_BYTE(data + 5, MsInterface->bInterfaceSubClass);
/* bInterfaceProtocol */
data_write_BYTE(data + 6, MsInterface->bInterfaceProtocol);
/* Padding */
/* Padding */
data_write_BYTE(data + 7, 0);
/* InterfaceHandle */
data_write_UINT32(data + 8, MsInterface->InterfaceHandle);
@ -204,7 +214,8 @@ int msusb_msinterface_write(MSUSB_INTERFACE_DESCRIPTOR* MsInterface, BYTE* data,
move += 16;
/* Pipes */
MsPipes = MsInterface->MsPipes;
for(pnum = 0; pnum < MsInterface->NumberOfPipes; pnum++)
for (pnum = 0; pnum < MsInterface->NumberOfPipes; pnum++)
{
MsPipe = MsPipes[pnum];
/* MaximumPacketSize */
@ -221,55 +232,53 @@ int msusb_msinterface_write(MSUSB_INTERFACE_DESCRIPTOR* MsInterface, BYTE* data,
data_write_UINT32(data + move + 12, MsPipe->MaximumTransferSize);
/* PipeFlags */
data_write_UINT32(data + move + 16, MsPipe->PipeFlags);
move += 20;
}
*offset += move;
return 0;
}
static MSUSB_INTERFACE_DESCRIPTOR** msusb_msinterface_read_list(BYTE * data, UINT32 data_size, UINT32 NumInterfaces)
static MSUSB_INTERFACE_DESCRIPTOR** msusb_msinterface_read_list(BYTE* data,
UINT32 data_size, UINT32 NumInterfaces)
{
int inum, offset = 0;
MSUSB_INTERFACE_DESCRIPTOR** MsInterfaces;
MsInterfaces = (MSUSB_INTERFACE_DESCRIPTOR**) calloc(NumInterfaces, sizeof(MSUSB_INTERFACE_DESCRIPTOR*));
MsInterfaces = (MSUSB_INTERFACE_DESCRIPTOR**) calloc(NumInterfaces,
sizeof(MSUSB_INTERFACE_DESCRIPTOR*));
if (!MsInterfaces)
return NULL;
for (inum = 0; inum < NumInterfaces; inum++)
{
MsInterfaces[inum] = msusb_msinterface_read(data + offset, data_size - offset, &offset);
}
MsInterfaces[inum] = msusb_msinterface_read(data + offset, data_size - offset,
&offset);
}
return MsInterfaces;
}
int msusb_msconfig_write(MSUSB_CONFIG_DESCRIPTOR* MsConfg, BYTE* data, int* offset)
int msusb_msconfig_write(MSUSB_CONFIG_DESCRIPTOR* MsConfg, BYTE* data,
int* offset)
{
int inum = 0;
MSUSB_INTERFACE_DESCRIPTOR** MsInterfaces;
MSUSB_INTERFACE_DESCRIPTOR* MsInterface;
/* ConfigurationHandle*/
data_write_UINT32(data + *offset, MsConfg->ConfigurationHandle);
/* NumInterfaces*/
data_write_UINT32(data + *offset + 4, MsConfg->NumInterfaces);
data_write_UINT32(data + *offset + 4, MsConfg->NumInterfaces);
*offset += 8;
/* Interfaces */
MsInterfaces = MsConfg->MsInterfaces;
for(inum = 0; inum < MsConfg->NumInterfaces; inum++)
for (inum = 0; inum < MsConfg->NumInterfaces; inum++)
{
MsInterface = MsInterfaces[inum];
msusb_msinterface_write(MsInterface, data + (*offset), offset);
}
return 0;
}
@ -288,16 +297,16 @@ void msusb_msconfig_free(MSUSB_CONFIG_DESCRIPTOR* MsConfig)
}
}
MSUSB_CONFIG_DESCRIPTOR* msusb_msconfig_read(BYTE* data, UINT32 data_size, UINT32 NumInterfaces)
MSUSB_CONFIG_DESCRIPTOR* msusb_msconfig_read(BYTE* data, UINT32 data_size,
UINT32 NumInterfaces)
{
int i, offset = 0;
UINT16 lenInterface;
MSUSB_CONFIG_DESCRIPTOR* MsConfig;
BYTE lenConfiguration, typeConfiguration;
MsConfig = msusb_msconfig_new();
for(i = 0; i < NumInterfaces; i++)
for (i = 0; i < NumInterfaces; i++)
{
data_read_UINT16(data + offset, lenInterface);
offset += lenInterface;
@ -309,33 +318,33 @@ MSUSB_CONFIG_DESCRIPTOR* msusb_msconfig_read(BYTE* data, UINT32 data_size, UINT3
if (lenConfiguration != 0x9 || typeConfiguration != 0x2)
{
DEBUG_MSUSB("%s: len and type must be 0x9 and 0x2 , but it is 0x%x and 0x%x",
lenConfiguration, typeConfiguration);
lenConfiguration, typeConfiguration);
}
data_read_UINT16(data + offset + 2, MsConfig->wTotalLength);
data_read_BYTE(data + offset + 5, MsConfig->bConfigurationValue);
MsConfig->NumInterfaces = NumInterfaces;
MsConfig->ConfigurationHandle = 0;
MsConfig->InitCompleted = 0;
MsConfig->MsOutSize = 0;
MsConfig->MsInterfaces = NULL;
offset = 0;
if (NumInterfaces > 0)
{
MsConfig->MsInterfaces = msusb_msinterface_read_list(data, data_size, NumInterfaces);
MsConfig->MsInterfaces = msusb_msinterface_read_list(data, data_size,
NumInterfaces);
}
return MsConfig;
}
void msusb_msconfig_dump(MSUSB_CONFIG_DESCRIPTOR* MsConfig)
{
MSUSB_INTERFACE_DESCRIPTOR ** MsInterfaces;
MSUSB_INTERFACE_DESCRIPTOR * MsInterface;
MSUSB_PIPE_DESCRIPTOR ** MsPipes;
MSUSB_PIPE_DESCRIPTOR * MsPipe;
MSUSB_INTERFACE_DESCRIPTOR** MsInterfaces;
MSUSB_INTERFACE_DESCRIPTOR* MsInterface;
MSUSB_PIPE_DESCRIPTOR** MsPipes;
MSUSB_PIPE_DESCRIPTOR* MsPipe;
int inum = 0, pnum = 0;
WLog_INFO(TAG, "=================MsConfig:========================");
WLog_INFO(TAG, "wTotalLength:%d", MsConfig->wTotalLength);
@ -345,12 +354,14 @@ void msusb_msconfig_dump(MSUSB_CONFIG_DESCRIPTOR* MsConfig)
WLog_INFO(TAG, "MsOutSize:%d", MsConfig->MsOutSize);
WLog_INFO(TAG, "NumInterfaces:%d", MsConfig->NumInterfaces);
MsInterfaces = MsConfig->MsInterfaces;
for(inum = 0; inum < MsConfig->NumInterfaces; inum++)
for (inum = 0; inum < MsConfig->NumInterfaces; inum++)
{
MsInterface = MsInterfaces[inum];
WLog_INFO(TAG, " Interfase: %d", MsInterface->InterfaceNumber);
WLog_INFO(TAG, " Length: %d", MsInterface->Length);
WLog_INFO(TAG, " NumberOfPipesExpected: %d", MsInterface->NumberOfPipesExpected);
WLog_INFO(TAG, " NumberOfPipesExpected: %d",
MsInterface->NumberOfPipesExpected);
WLog_INFO(TAG, " AlternateSetting: %d", MsInterface->AlternateSetting);
WLog_INFO(TAG, " NumberOfPipes: %d", MsInterface->NumberOfPipes);
WLog_INFO(TAG, " InterfaceHandle: 0x%x", MsInterface->InterfaceHandle);
@ -359,6 +370,7 @@ void msusb_msconfig_dump(MSUSB_CONFIG_DESCRIPTOR* MsConfig)
WLog_INFO(TAG, " bInterfaceProtocol: 0x%x", MsInterface->bInterfaceProtocol);
WLog_INFO(TAG, " InitCompleted: %d", MsInterface->InitCompleted);
MsPipes = MsInterface->MsPipes;
for (pnum = 0; pnum < MsInterface->NumberOfPipes; pnum++)
{
MsPipe = MsPipes[pnum];
@ -373,5 +385,6 @@ void msusb_msconfig_dump(MSUSB_CONFIG_DESCRIPTOR* MsConfig)
WLog_INFO(TAG, " InitCompleted: %d", MsPipe->InitCompleted);
}
}
WLog_INFO(TAG, "==================================================");
}

View File

@ -33,23 +33,21 @@
#define TAG FREERDP_TAG("utils.ringbuffer")
#ifdef WITH_DEBUG_RINGBUFFER
#define DEBUG_RINGBUFFER(fmt, ...) WLog_DBG(TAG, fmt, ## __VA_ARGS__)
#define DEBUG_RINGBUFFER(...) WLog_DBG(TAG, __VA_ARGS__)
#else
#define DEBUG_RINGBUFFER(fmt, ...) do { } while (0)
#define DEBUG_RINGBUFFER(...) do { } while (0)
#endif
BOOL ringbuffer_init(RingBuffer* rb, size_t initialSize)
{
rb->buffer = malloc(initialSize);
if (!rb->buffer)
return FALSE;
rb->readPtr = rb->writePtr = 0;
rb->initialSize = rb->size = rb->freeSize = initialSize;
DEBUG_RINGBUFFER("ringbuffer_init(%p)", rb);
return TRUE;
}
@ -66,7 +64,6 @@ size_t ringbuffer_capacity(const RingBuffer* rb)
void ringbuffer_destroy(RingBuffer* rb)
{
DEBUG_RINGBUFFER("ringbuffer_destroy(%p)", rb);
free(rb->buffer);
rb->buffer = NULL;
}
@ -74,7 +71,6 @@ void ringbuffer_destroy(RingBuffer* rb)
static BOOL ringbuffer_realloc(RingBuffer* rb, size_t targetSize)
{
BYTE* newData;
DEBUG_RINGBUFFER("ringbuffer_realloc(%p): targetSize: %d", rb, targetSize);
if (rb->writePtr == rb->readPtr)
@ -83,10 +79,10 @@ static BOOL ringbuffer_realloc(RingBuffer* rb, size_t targetSize)
* beginning of the buffer
*/
newData = (BYTE*) realloc(rb->buffer, targetSize);
if (!newData)
return FALSE;
rb->readPtr = rb->writePtr = 0;
rb->buffer = newData;
}
@ -101,7 +97,7 @@ static BOOL ringbuffer_realloc(RingBuffer* rb, size_t targetSize)
* [............|XXXXXXXXXXXXXX|..........]
*/
newData = (BYTE*) realloc(rb->buffer, targetSize);
if (!newData)
return FALSE;
@ -113,10 +109,10 @@ static BOOL ringbuffer_realloc(RingBuffer* rb, size_t targetSize)
* and the write head is set accordingly
*/
newData = (BYTE*) malloc(targetSize);
if (!newData)
return FALSE;
if (rb->readPtr < rb->writePtr)
{
/* readPtr writePtr
@ -134,14 +130,13 @@ static BOOL ringbuffer_realloc(RingBuffer* rb, size_t targetSize)
* [XXXXXXXXXXXX|..............|XXXXXXXXXX]
*/
BYTE* dst = newData;
memcpy(dst, rb->buffer + rb->readPtr, rb->size - rb->readPtr);
dst += (rb->size - rb->readPtr);
if (rb->writePtr)
memcpy(dst, rb->buffer, rb->writePtr);
}
rb->writePtr = rb->size - rb->freeSize;
rb->readPtr = 0;
free(rb->buffer);
@ -150,7 +145,6 @@ static BOOL ringbuffer_realloc(RingBuffer* rb, size_t targetSize)
rb->freeSize += (targetSize - rb->size);
rb->size = targetSize;
return TRUE;
}
@ -165,9 +159,8 @@ BOOL ringbuffer_write(RingBuffer* rb, const BYTE* ptr, size_t sz)
{
size_t toWrite;
size_t remaining;
DEBUG_RINGBUFFER("ringbuffer_write(%p): sz: %d", rb, sz);
if ((rb->freeSize <= sz) && !ringbuffer_realloc(rb, rb->size + sz))
return FALSE;
@ -179,7 +172,7 @@ BOOL ringbuffer_write(RingBuffer* rb, const BYTE* ptr, size_t sz)
*/
toWrite = sz;
remaining = sz;
if (rb->size - rb->writePtr < sz)
toWrite = rb->size - rb->writePtr;
@ -194,7 +187,6 @@ BOOL ringbuffer_write(RingBuffer* rb, const BYTE* ptr, size_t sz)
memcpy(rb->buffer, ptr, remaining);
rb->writePtr = (rb->writePtr + sz) % rb->size;
rb->freeSize -= sz;
return TRUE;
}
@ -233,16 +225,15 @@ BYTE* ringbuffer_ensure_linear_write(RingBuffer* rb, size_t sz)
BOOL ringbuffer_commit_written_bytes(RingBuffer* rb, size_t sz)
{
DEBUG_RINGBUFFER("ringbuffer_commit_written_bytes(%p): sz: %d", rb, sz);
if (sz < 1)
return TRUE;
if (rb->writePtr + sz > rb->size)
return FALSE;
rb->writePtr = (rb->writePtr + sz) % rb->size;
rb->freeSize -= sz;
return TRUE;
}
@ -252,12 +243,11 @@ int ringbuffer_peek(const RingBuffer* rb, DataChunk chunks[2], size_t sz)
size_t toRead;
int chunkIndex = 0;
int status = 0;
DEBUG_RINGBUFFER("ringbuffer_peek(%p): sz: %d", rb, sz);
if (sz < 1)
return 0;
if ((rb->size - rb->freeSize) < sz)
remaining = rb->size - rb->freeSize;
@ -281,23 +271,23 @@ int ringbuffer_peek(const RingBuffer* rb, DataChunk chunks[2], size_t sz)
chunks[chunkIndex].size = remaining;
status++;
}
return status;
}
void ringbuffer_commit_read_bytes(RingBuffer* rb, size_t sz)
{
DEBUG_RINGBUFFER("ringbuffer_commit_read_bytes(%p): sz: %d", rb, sz);
if (sz < 1)
return;
assert(rb->size - rb->freeSize >= sz);
assert(rb->size - rb->freeSize >= sz);
rb->readPtr = (rb->readPtr + sz) % rb->size;
rb->freeSize += sz;
/* when we reach a reasonable free size, we can go back to the original size */
if ((rb->size != rb->initialSize) && (ringbuffer_used(rb) < rb->initialSize / 2))
if ((rb->size != rb->initialSize)
&& (ringbuffer_used(rb) < rb->initialSize / 2))
ringbuffer_realloc(rb, rb->initialSize);
}

View File

@ -58,15 +58,15 @@ typedef enum _SECURITY_IMPERSONATION_LEVEL
#define TOKEN_ADJUST_SESSIONID (0x0100)
#define TOKEN_ALL_ACCESS_P (STANDARD_RIGHTS_REQUIRED | TOKEN_ASSIGN_PRIMARY | TOKEN_DUPLICATE | \
TOKEN_IMPERSONATE | TOKEN_QUERY | TOKEN_QUERY_SOURCE | \
TOKEN_ADJUST_PRIVILEGES | TOKEN_ADJUST_GROUPS | TOKEN_ADJUST_DEFAULT)
TOKEN_IMPERSONATE | TOKEN_QUERY | TOKEN_QUERY_SOURCE | \
TOKEN_ADJUST_PRIVILEGES | TOKEN_ADJUST_GROUPS | TOKEN_ADJUST_DEFAULT)
#define TOKEN_ALL_ACCESS (TOKEN_ALL_ACCESS_P | TOKEN_ADJUST_SESSIONID)
#define TOKEN_READ (STANDARD_RIGHTS_READ | TOKEN_QUERY)
#define TOKEN_WRITE (STANDARD_RIGHTS_WRITE | \
TOKEN_ADJUST_PRIVILEGES | TOKEN_ADJUST_GROUPS | TOKEN_ADJUST_DEFAULT)
TOKEN_ADJUST_PRIVILEGES | TOKEN_ADJUST_GROUPS | TOKEN_ADJUST_DEFAULT)
#define TOKEN_EXECUTE (STANDARD_RIGHTS_EXECUTE)
@ -75,7 +75,7 @@ typedef enum _SECURITY_IMPERSONATION_LEVEL
#define TOKEN_MANDATORY_POLICY_NEW_PROCESS_MIN 0x2
#define TOKEN_MANDATORY_POLICY_VALID_MASK (TOKEN_MANDATORY_POLICY_NO_WRITE_UP | \
TOKEN_MANDATORY_POLICY_NEW_PROCESS_MIN)
TOKEN_MANDATORY_POLICY_NEW_PROCESS_MIN)
#define POLICY_AUDIT_SUBCATEGORY_COUNT (56)
@ -120,7 +120,7 @@ typedef struct _LUID_AND_ATTRIBUTES
DWORD Attributes;
} LUID_AND_ATTRIBUTES, *PLUID_AND_ATTRIBUTES;
typedef LUID_AND_ATTRIBUTES LUID_AND_ATTRIBUTES_ARRAY[ANYSIZE_ARRAY];
typedef LUID_AND_ATTRIBUTES_ARRAY *PLUID_AND_ATTRIBUTES_ARRAY;
typedef LUID_AND_ATTRIBUTES_ARRAY* PLUID_AND_ATTRIBUTES_ARRAY;
typedef struct _SID_IDENTIFIER_AUTHORITY
{
@ -156,7 +156,7 @@ typedef struct _SID_AND_ATTRIBUTES
} SID_AND_ATTRIBUTES, * PSID_AND_ATTRIBUTES;
typedef SID_AND_ATTRIBUTES SID_AND_ATTRIBUTES_ARRAY[ANYSIZE_ARRAY];
typedef SID_AND_ATTRIBUTES_ARRAY *PSID_AND_ATTRIBUTES_ARRAY;
typedef SID_AND_ATTRIBUTES_ARRAY* PSID_AND_ATTRIBUTES_ARRAY;
typedef ULONG_PTR SID_HASH_ENTRY, *PSID_HASH_ENTRY;
@ -172,13 +172,13 @@ typedef enum _TOKEN_TYPE
TokenPrimary = 1,
TokenImpersonation
} TOKEN_TYPE;
typedef TOKEN_TYPE *PTOKEN_TYPE;
typedef TOKEN_TYPE* PTOKEN_TYPE;
typedef enum _TOKEN_ELEVATION_TYPE
{
TokenElevationTypeDefault = 1,
TokenElevationTypeFull,
TokenElevationTypeLimited,
TokenElevationTypeLimited
} TOKEN_ELEVATION_TYPE, *PTOKEN_ELEVATION_TYPE;
typedef enum _TOKEN_INFORMATION_CLASS
@ -375,29 +375,47 @@ typedef struct _TOKEN_APPCONTAINER_INFORMATION
extern "C" {
#endif
WINPR_API BOOL InitializeSecurityDescriptor(PSECURITY_DESCRIPTOR pSecurityDescriptor, DWORD dwRevision);
WINPR_API DWORD GetSecurityDescriptorLength(PSECURITY_DESCRIPTOR pSecurityDescriptor);
WINPR_API BOOL IsValidSecurityDescriptor(PSECURITY_DESCRIPTOR pSecurityDescriptor);
WINPR_API BOOL InitializeSecurityDescriptor(PSECURITY_DESCRIPTOR
pSecurityDescriptor, DWORD dwRevision);
WINPR_API DWORD GetSecurityDescriptorLength(PSECURITY_DESCRIPTOR
pSecurityDescriptor);
WINPR_API BOOL IsValidSecurityDescriptor(PSECURITY_DESCRIPTOR
pSecurityDescriptor);
WINPR_API BOOL GetSecurityDescriptorControl(PSECURITY_DESCRIPTOR pSecurityDescriptor,
PSECURITY_DESCRIPTOR_CONTROL pControl, LPDWORD lpdwRevision);
WINPR_API BOOL SetSecurityDescriptorControl(PSECURITY_DESCRIPTOR pSecurityDescriptor,
SECURITY_DESCRIPTOR_CONTROL ControlBitsOfInterest, SECURITY_DESCRIPTOR_CONTROL ControlBitsToSet);
WINPR_API BOOL GetSecurityDescriptorControl(PSECURITY_DESCRIPTOR
pSecurityDescriptor,
PSECURITY_DESCRIPTOR_CONTROL pControl, LPDWORD lpdwRevision);
WINPR_API BOOL SetSecurityDescriptorControl(PSECURITY_DESCRIPTOR
pSecurityDescriptor,
SECURITY_DESCRIPTOR_CONTROL ControlBitsOfInterest,
SECURITY_DESCRIPTOR_CONTROL ControlBitsToSet);
WINPR_API BOOL GetSecurityDescriptorDacl(PSECURITY_DESCRIPTOR pSecurityDescriptor, LPBOOL lpbDaclPresent, PACL* pDacl, LPBOOL lpbDaclDefaulted);
WINPR_API BOOL SetSecurityDescriptorDacl(PSECURITY_DESCRIPTOR pSecurityDescriptor, BOOL bDaclPresent, PACL pDacl, BOOL bDaclDefaulted);
WINPR_API BOOL GetSecurityDescriptorDacl(PSECURITY_DESCRIPTOR
pSecurityDescriptor, LPBOOL lpbDaclPresent, PACL* pDacl,
LPBOOL lpbDaclDefaulted);
WINPR_API BOOL SetSecurityDescriptorDacl(PSECURITY_DESCRIPTOR
pSecurityDescriptor, BOOL bDaclPresent, PACL pDacl, BOOL bDaclDefaulted);
WINPR_API BOOL GetSecurityDescriptorGroup(PSECURITY_DESCRIPTOR pSecurityDescriptor, PSID* pGroup, LPBOOL lpbGroupDefaulted);
WINPR_API BOOL SetSecurityDescriptorGroup(PSECURITY_DESCRIPTOR pSecurityDescriptor, PSID pGroup, BOOL bGroupDefaulted);
WINPR_API BOOL GetSecurityDescriptorGroup(PSECURITY_DESCRIPTOR
pSecurityDescriptor, PSID* pGroup, LPBOOL lpbGroupDefaulted);
WINPR_API BOOL SetSecurityDescriptorGroup(PSECURITY_DESCRIPTOR
pSecurityDescriptor, PSID pGroup, BOOL bGroupDefaulted);
WINPR_API BOOL GetSecurityDescriptorOwner(PSECURITY_DESCRIPTOR pSecurityDescriptor, PSID* pOwner, LPBOOL lpbOwnerDefaulted);
WINPR_API BOOL SetSecurityDescriptorOwner(PSECURITY_DESCRIPTOR pSecurityDescriptor, PSID pOwner, BOOL bOwnerDefaulted);
WINPR_API BOOL GetSecurityDescriptorOwner(PSECURITY_DESCRIPTOR
pSecurityDescriptor, PSID* pOwner, LPBOOL lpbOwnerDefaulted);
WINPR_API BOOL SetSecurityDescriptorOwner(PSECURITY_DESCRIPTOR
pSecurityDescriptor, PSID pOwner, BOOL bOwnerDefaulted);
WINPR_API DWORD GetSecurityDescriptorRMControl(PSECURITY_DESCRIPTOR SecurityDescriptor, PUCHAR RMControl);
WINPR_API DWORD SetSecurityDescriptorRMControl(PSECURITY_DESCRIPTOR SecurityDescriptor, PUCHAR RMControl);
WINPR_API DWORD GetSecurityDescriptorRMControl(PSECURITY_DESCRIPTOR
SecurityDescriptor, PUCHAR RMControl);
WINPR_API DWORD SetSecurityDescriptorRMControl(PSECURITY_DESCRIPTOR
SecurityDescriptor, PUCHAR RMControl);
WINPR_API BOOL GetSecurityDescriptorSacl(PSECURITY_DESCRIPTOR pSecurityDescriptor, LPBOOL lpbSaclPresent, PACL* pSacl, LPBOOL lpbSaclDefaulted);
WINPR_API BOOL SetSecurityDescriptorSacl(PSECURITY_DESCRIPTOR pSecurityDescriptor, BOOL bSaclPresent, PACL pSacl, BOOL bSaclDefaulted);
WINPR_API BOOL GetSecurityDescriptorSacl(PSECURITY_DESCRIPTOR
pSecurityDescriptor, LPBOOL lpbSaclPresent, PACL* pSacl,
LPBOOL lpbSaclDefaulted);
WINPR_API BOOL SetSecurityDescriptorSacl(PSECURITY_DESCRIPTOR
pSecurityDescriptor, BOOL bSaclPresent, PACL pSacl, BOOL bSaclDefaulted);
#ifdef __cplusplus
}

View File

@ -59,8 +59,10 @@ WINPR_API int _wcscmp(const WCHAR* string1, const WCHAR* string2);
WINPR_API size_t _wcslen(const WCHAR* str);
WINPR_API WCHAR* _wcschr(const WCHAR* str, WCHAR c);
WINPR_API char* strtok_s(char* strToken, const char* strDelimit, char** context);
WINPR_API WCHAR* wcstok_s(WCHAR* strToken, const WCHAR* strDelimit, WCHAR** context);
WINPR_API char* strtok_s(char* strToken, const char* strDelimit,
char** context);
WINPR_API WCHAR* wcstok_s(WCHAR* strToken, const WCHAR* strDelimit,
WCHAR** context);
#else
@ -168,27 +170,33 @@ WINPR_API int lstrcmpW(LPCWSTR lpString1, LPCWSTR lpString2);
#define sprintf_s snprintf
#define _snprintf snprintf
#define _scprintf(_fmt, ...) snprintf(NULL, 0, _fmt, ## __VA_ARGS__)
#define _scprintf(...) snprintf(NULL, 0, __VA_ARGS__)
#define _scprintf(_fmt, ...) snprintf(NULL, 0, _fmt, ## __VA_ARGS__)
#define _scprintf(...) snprintf(NULL, 0, __VA_ARGS__)
/* Unicode Conversion */
WINPR_API int MultiByteToWideChar(UINT CodePage, DWORD dwFlags, LPCSTR lpMultiByteStr,
int cbMultiByte, LPWSTR lpWideCharStr, int cchWideChar);
WINPR_API int MultiByteToWideChar(UINT CodePage, DWORD dwFlags,
LPCSTR lpMultiByteStr,
int cbMultiByte, LPWSTR lpWideCharStr, int cchWideChar);
WINPR_API int WideCharToMultiByte(UINT CodePage, DWORD dwFlags, LPCWSTR lpWideCharStr, int cchWideChar,
LPSTR lpMultiByteStr, int cbMultiByte, LPCSTR lpDefaultChar, LPBOOL lpUsedDefaultChar);
WINPR_API int WideCharToMultiByte(UINT CodePage, DWORD dwFlags,
LPCWSTR lpWideCharStr, int cchWideChar,
LPSTR lpMultiByteStr, int cbMultiByte, LPCSTR lpDefaultChar,
LPBOOL lpUsedDefaultChar);
#endif
/* Extended API */
WINPR_API int ConvertToUnicode(UINT CodePage, DWORD dwFlags, LPCSTR lpMultiByteStr,
int cbMultiByte, LPWSTR* lpWideCharStr, int cchWideChar);
WINPR_API int ConvertToUnicode(UINT CodePage, DWORD dwFlags,
LPCSTR lpMultiByteStr,
int cbMultiByte, LPWSTR* lpWideCharStr, int cchWideChar);
WINPR_API int ConvertFromUnicode(UINT CodePage, DWORD dwFlags, LPCWSTR lpWideCharStr, int cchWideChar,
LPSTR* lpMultiByteStr, int cbMultiByte, LPCSTR lpDefaultChar, LPBOOL lpUsedDefaultChar);
WINPR_API int ConvertFromUnicode(UINT CodePage, DWORD dwFlags,
LPCWSTR lpWideCharStr, int cchWideChar,
LPSTR* lpMultiByteStr, int cbMultiByte, LPCSTR lpDefaultChar,
LPBOOL lpUsedDefaultChar);
WINPR_API void ByteSwapUnicode(WCHAR* wstr, int length);

View File

@ -104,109 +104,80 @@ typedef struct _wLog wLog;
#define WLOG_PACKET_INBOUND 1
#define WLOG_PACKET_OUTBOUND 2
WINPR_API BOOL WLog_PrintMessage(wLog* log, wLogMessage* message, ...);
WINPR_API BOOL WLog_PrintMessageVA(wLog* log, wLogMessage* message, va_list args);
WINPR_API BOOL WLog_PrintMessage(wLog* log, DWORD type, DWORD level, DWORD line,
const char* file, const char* function, ...);
WINPR_API BOOL WLog_PrintMessageVA(wLog* log, DWORD type, DWORD level,
DWORD line,
const char* file, const char* function, va_list args);
#define WLog_Print(_log, _log_level, _fmt, ...) \
#define WLog_Print(_log, _log_level, ...) \
do { \
if (_log && _log_level >= WLog_GetLogLevel(_log)) { \
wLogMessage _log_message; \
memset(&_log_message, 0, sizeof(_log_message)); \
_log_message.Type = WLOG_MESSAGE_TEXT; \
_log_message.Level = _log_level; \
_log_message.FormatString = _fmt; \
_log_message.LineNumber = __LINE__; \
_log_message.FileName = __FILE__; \
_log_message.FunctionName = __FUNCTION__; \
WLog_PrintMessage(_log, &(_log_message), ## __VA_ARGS__ ); \
WLog_PrintMessage(_log, WLOG_MESSAGE_TEXT, _log_level, \
__LINE__, __FILE__, __FUNCTION__, __VA_ARGS__ ); \
} \
} while (0)
#define WLog_PrintVA(_log, _log_level, _fmt, _args) \
#define WLog_PrintVA(_log, _log_level, _args) \
do { \
if (_log && _log_level >= WLog_GetLogLevel(_log)) { \
wLogMessage _log_message; \
memset(&_log_message, 0, sizeof(_log_message)); \
_log_message.Type = WLOG_MESSAGE_TEXT; \
_log_message.Level = _log_level; \
_log_message.FormatString = _fmt; \
_log_message.LineNumber = __LINE__; \
_log_message.FileName = __FILE__; \
_log_message.FunctionName = __FUNCTION__; \
WLog_PrintMessageVA(_log, &(_log_message), _args); \
WLog_PrintMessageVA(_log, WLOG_MESSAGE_TEXT, _log_level, \
__LINE__, __FILE__, __FUNCTION__, _args ); \
} \
} while (0)
#define WLog_Data(_log, _log_level, ...) \
do { \
if (_log && _log_level >= WLog_GetLogLevel(_log)) { \
wLogMessage _log_message; \
memset(&_log_message, 0, sizeof(_log_message)); \
_log_message.Type = WLOG_MESSAGE_DATA; \
_log_message.Level = _log_level; \
_log_message.FormatString = NULL; \
_log_message.LineNumber = __LINE__; \
_log_message.FileName = __FILE__; \
_log_message.FunctionName = __FUNCTION__; \
WLog_PrintMessage(_log, &(_log_message), ## __VA_ARGS__ ); \
WLog_PrintMessage(_log, WLOG_MESSAGE_DATA, _log_level, \
__LINE__, __FILE__, __FUNCTION__, __VA_ARGS__ ); \
} \
} while (0)
#define WLog_Image(_log, _log_level, ...) \
do { \
if (_log && _log_level >= WLog_GetLogLevel(_log)) { \
wLogMessage _log_message; \
memset(&_log_message, 0, sizeof(_log_message)); \
_log_message.Type = WLOG_MESSAGE_IMAGE; \
_log_message.Level = _log_level; \
_log_message.FormatString = NULL; \
_log_message.LineNumber = __LINE__; \
_log_message.FileName = __FILE__; \
_log_message.FunctionName = __FUNCTION__; \
WLog_PrintMessage(_log, &(_log_message), ## __VA_ARGS__ ); \
WLog_PrintMessage(_log, WLOG_MESSAGE_DATA, _log_level, \
__LINE__, __FILE__, __FUNCTION__, __VA_ARGS__ ); \
} \
} while (0)
#define WLog_Packet(_log, _log_level, ...) \
do { \
if (_log && _log_level >= WLog_GetLogLevel(_log)) { \
wLogMessage _log_message; \
memset(&_log_message, 0, sizeof(_log_message)); \
_log_message.Type = WLOG_MESSAGE_PACKET; \
_log_message.Level = _log_level; \
_log_message.FormatString = NULL; \
_log_message.LineNumber = __LINE__; \
_log_message.FileName = __FILE__; \
_log_message.FunctionName = __FUNCTION__; \
WLog_PrintMessage(_log, &(_log_message), ## __VA_ARGS__ ); \
WLog_PrintMessage(_log, WLOG_MESSAGE_PACKET, _log_level, \
__LINE__, __FILE__, __FUNCTION__, __VA_ARGS__ ); \
} \
} while (0)
#define WLog_IsLevelActive(_log, _log_level) \
(_log ? _log_level >= WLog_GetLogLevel(_log) : FALSE)
#define WLog_LVL(tag, lvl, fmt, ...) WLog_Print(WLog_Get(tag), lvl, fmt, ## __VA_ARGS__)
#define WLog_VRB(tag, fmt, ...) WLog_Print(WLog_Get(tag), WLOG_TRACE, fmt, ## __VA_ARGS__)
#define WLog_DBG(tag, fmt, ...) WLog_Print(WLog_Get(tag), WLOG_DEBUG, fmt, ## __VA_ARGS__)
#define WLog_INFO(tag, fmt, ...) WLog_Print(WLog_Get(tag), WLOG_INFO, fmt, ## __VA_ARGS__)
#define WLog_WARN(tag, fmt, ...) WLog_Print(WLog_Get(tag), WLOG_WARN, fmt, ## __VA_ARGS__)
#define WLog_ERR(tag, fmt, ...) WLog_Print(WLog_Get(tag), WLOG_ERROR, fmt, ## __VA_ARGS__)
#define WLog_FATAL(tag, fmt, ...) WLog_Print(WLog_Get(tag), WLOG_FATAL, fmt, ## __VA_ARGS__)
#define WLog_LVL(tag, lvl, ...) WLog_Print(WLog_Get(tag), lvl, __VA_ARGS__)
#define WLog_VRB(tag, ...) WLog_Print(WLog_Get(tag), WLOG_TRACE, __VA_ARGS__)
#define WLog_DBG(tag, ...) WLog_Print(WLog_Get(tag), WLOG_DEBUG, __VA_ARGS__)
#define WLog_INFO(tag, ...) WLog_Print(WLog_Get(tag), WLOG_INFO, __VA_ARGS__)
#define WLog_WARN(tag, ...) WLog_Print(WLog_Get(tag), WLOG_WARN, __VA_ARGS__)
#define WLog_ERR(tag, ...) WLog_Print(WLog_Get(tag), WLOG_ERROR, __VA_ARGS__)
#define WLog_FATAL(tag, ...) WLog_Print(WLog_Get(tag), WLOG_FATAL, __VA_ARGS__)
WINPR_API DWORD WLog_GetLogLevel(wLog* log);
WINPR_API BOOL WLog_SetLogLevel(wLog* log, DWORD logLevel);
WINPR_API BOOL WLog_SetStringLogLevel(wLog* log, LPCSTR level);
WINPR_API BOOL WLog_AddStringLogFilters(LPCSTR filter);
static INLINE BOOL WLog_IsLevelActive(wLog* _log, DWORD _log_level)
{
return _log ? _log_level >= WLog_GetLogLevel(_log) : FALSE;
}
WINPR_API BOOL WLog_SetLogAppenderType(wLog* log, DWORD logAppenderType);
WINPR_API wLogAppender* WLog_GetLogAppender(wLog* log);
WINPR_API BOOL WLog_OpenAppender(wLog* log);
WINPR_API BOOL WLog_CloseAppender(wLog* log);
WINPR_API BOOL WLog_ConfigureAppender(wLogAppender *appender, const char *setting, void *value);
WINPR_API BOOL WLog_ConfigureAppender(wLogAppender* appender,
const char* setting, void* value);
WINPR_API wLogLayout* WLog_GetLogLayout(wLog* log);
WINPR_API BOOL WLog_Layout_SetPrefixFormat(wLog* log, wLogLayout* layout, const char* format);
WINPR_API BOOL WLog_Layout_SetPrefixFormat(wLog* log, wLogLayout* layout,
const char* format);
WINPR_API wLog* WLog_GetRoot(void);
WINPR_API wLog* WLog_Get(LPCSTR name);
@ -214,12 +185,13 @@ WINPR_API wLog* WLog_Get(LPCSTR name);
WINPR_API BOOL WLog_Init(void);
WINPR_API BOOL WLog_Uninit(void);
typedef BOOL (*wLogCallbackMessage_t)(const wLogMessage *msg);
typedef BOOL (*wLogCallbackData_t)(const wLogMessage *msg);
typedef BOOL (*wLogCallbackImage_t)(const wLogMessage *msg);
typedef BOOL (*wLogCallbackPackage_t)(const wLogMessage *msg);
typedef BOOL (*wLogCallbackMessage_t)(const wLogMessage* msg);
typedef BOOL (*wLogCallbackData_t)(const wLogMessage* msg);
typedef BOOL (*wLogCallbackImage_t)(const wLogMessage* msg);
typedef BOOL (*wLogCallbackPackage_t)(const wLogMessage* msg);
struct _wLogCallbacks {
struct _wLogCallbacks
{
wLogCallbackData_t data;
wLogCallbackImage_t image;
wLogCallbackMessage_t message;

View File

@ -74,8 +74,8 @@ typedef struct tagCHANNEL_DEF
char name[CHANNEL_NAME_LEN + 1];
ULONG options;
} CHANNEL_DEF;
typedef CHANNEL_DEF *PCHANNEL_DEF;
typedef PCHANNEL_DEF *PPCHANNEL_DEF;
typedef CHANNEL_DEF* PCHANNEL_DEF;
typedef PCHANNEL_DEF* PPCHANNEL_DEF;
typedef struct tagCHANNEL_PDU_HEADER
{
@ -117,14 +117,14 @@ typedef struct tagCHANNEL_PDU_HEADER
#endif
typedef VOID VCAPITYPE CHANNEL_INIT_EVENT_FN(LPVOID pInitHandle,
UINT event, LPVOID pData, UINT dataLength);
UINT event, LPVOID pData, UINT dataLength);
typedef CHANNEL_INIT_EVENT_FN *PCHANNEL_INIT_EVENT_FN;
typedef CHANNEL_INIT_EVENT_FN* PCHANNEL_INIT_EVENT_FN;
typedef VOID VCAPITYPE CHANNEL_INIT_EVENT_EX_FN(LPVOID lpUserParam,
LPVOID pInitHandle, UINT event, LPVOID pData, UINT dataLength);
LPVOID pInitHandle, UINT event, LPVOID pData, UINT dataLength);
typedef CHANNEL_INIT_EVENT_EX_FN *PCHANNEL_INIT_EVENT_EX_FN;
typedef CHANNEL_INIT_EVENT_EX_FN* PCHANNEL_INIT_EVENT_EX_FN;
#define CHANNEL_EVENT_INITIALIZED 0
#define CHANNEL_EVENT_CONNECTED 1
@ -138,14 +138,15 @@ typedef CHANNEL_INIT_EVENT_EX_FN *PCHANNEL_INIT_EVENT_EX_FN;
#define CHANNEL_EVENT_WRITE_CANCELLED 12
typedef VOID VCAPITYPE CHANNEL_OPEN_EVENT_FN(DWORD openHandle, UINT event,
LPVOID pData, UINT32 dataLength, UINT32 totalLength, UINT32 dataFlags);
LPVOID pData, UINT32 dataLength, UINT32 totalLength, UINT32 dataFlags);
typedef CHANNEL_OPEN_EVENT_FN *PCHANNEL_OPEN_EVENT_FN;
typedef CHANNEL_OPEN_EVENT_FN* PCHANNEL_OPEN_EVENT_FN;
typedef VOID VCAPITYPE CHANNEL_OPEN_EVENT_EX_FN(LPVOID lpUserParam, DWORD openHandle, UINT event,
LPVOID pData, UINT32 dataLength, UINT32 totalLength, UINT32 dataFlags);
typedef VOID VCAPITYPE CHANNEL_OPEN_EVENT_EX_FN(LPVOID lpUserParam,
DWORD openHandle, UINT event,
LPVOID pData, UINT32 dataLength, UINT32 totalLength, UINT32 dataFlags);
typedef CHANNEL_OPEN_EVENT_EX_FN *PCHANNEL_OPEN_EVENT_EX_FN;
typedef CHANNEL_OPEN_EVENT_EX_FN* PCHANNEL_OPEN_EVENT_EX_FN;
#define CHANNEL_RC_OK 0
#define CHANNEL_RC_ALREADY_INITIALIZED 1
@ -171,43 +172,51 @@ typedef CHANNEL_OPEN_EVENT_EX_FN *PCHANNEL_OPEN_EVENT_EX_FN;
#define VIRTUAL_CHANNEL_VERSION_WIN2000 1
typedef UINT VCAPITYPE VIRTUALCHANNELINIT(LPVOID* ppInitHandle, PCHANNEL_DEF pChannel,
INT channelCount, ULONG versionRequested, PCHANNEL_INIT_EVENT_FN pChannelInitEventProc);
typedef UINT VCAPITYPE VIRTUALCHANNELINIT(LPVOID* ppInitHandle,
PCHANNEL_DEF pChannel,
INT channelCount, ULONG versionRequested,
PCHANNEL_INIT_EVENT_FN pChannelInitEventProc);
typedef VIRTUALCHANNELINIT *PVIRTUALCHANNELINIT;
typedef VIRTUALCHANNELINIT* PVIRTUALCHANNELINIT;
typedef UINT VCAPITYPE VIRTUALCHANNELINITEX(LPVOID lpUserParam, LPVOID pInitHandle, PCHANNEL_DEF pChannel,
INT channelCount, ULONG versionRequested, PCHANNEL_INIT_EVENT_EX_FN pChannelInitEventProcEx);
typedef UINT VCAPITYPE VIRTUALCHANNELINITEX(LPVOID lpUserParam,
LPVOID pInitHandle, PCHANNEL_DEF pChannel,
INT channelCount, ULONG versionRequested,
PCHANNEL_INIT_EVENT_EX_FN pChannelInitEventProcEx);
typedef VIRTUALCHANNELINITEX *PVIRTUALCHANNELINITEX;
typedef VIRTUALCHANNELINITEX* PVIRTUALCHANNELINITEX;
typedef UINT VCAPITYPE VIRTUALCHANNELOPEN(LPVOID pInitHandle, LPDWORD pOpenHandle,
PCHAR pChannelName, PCHANNEL_OPEN_EVENT_FN pChannelOpenEventProc);
typedef UINT VCAPITYPE VIRTUALCHANNELOPEN(LPVOID pInitHandle,
LPDWORD pOpenHandle,
PCHAR pChannelName, PCHANNEL_OPEN_EVENT_FN pChannelOpenEventProc);
typedef VIRTUALCHANNELOPEN *PVIRTUALCHANNELOPEN;
typedef VIRTUALCHANNELOPEN* PVIRTUALCHANNELOPEN;
typedef UINT VCAPITYPE VIRTUALCHANNELOPENEX(LPVOID pInitHandle, LPDWORD pOpenHandle,
PCHAR pChannelName, PCHANNEL_OPEN_EVENT_EX_FN pChannelOpenEventProcEx);
typedef UINT VCAPITYPE VIRTUALCHANNELOPENEX(LPVOID pInitHandle,
LPDWORD pOpenHandle,
PCHAR pChannelName, PCHANNEL_OPEN_EVENT_EX_FN pChannelOpenEventProcEx);
typedef VIRTUALCHANNELOPENEX *PVIRTUALCHANNELOPENEX;
typedef VIRTUALCHANNELOPENEX* PVIRTUALCHANNELOPENEX;
typedef UINT VCAPITYPE VIRTUALCHANNELCLOSE(DWORD openHandle);
typedef VIRTUALCHANNELCLOSE *PVIRTUALCHANNELCLOSE;
typedef VIRTUALCHANNELCLOSE* PVIRTUALCHANNELCLOSE;
typedef UINT VCAPITYPE VIRTUALCHANNELCLOSEEX(LPVOID pInitHandle, DWORD openHandle);
typedef UINT VCAPITYPE VIRTUALCHANNELCLOSEEX(LPVOID pInitHandle,
DWORD openHandle);
typedef VIRTUALCHANNELCLOSEEX *PVIRTUALCHANNELCLOSEEX;
typedef VIRTUALCHANNELCLOSEEX* PVIRTUALCHANNELCLOSEEX;
typedef UINT VCAPITYPE VIRTUALCHANNELWRITE(DWORD openHandle,
LPVOID pData, ULONG dataLength, LPVOID pUserData);
LPVOID pData, ULONG dataLength, LPVOID pUserData);
typedef VIRTUALCHANNELWRITE *PVIRTUALCHANNELWRITE;
typedef VIRTUALCHANNELWRITE* PVIRTUALCHANNELWRITE;
typedef UINT VCAPITYPE VIRTUALCHANNELWRITEEX(LPVOID pInitHandle, DWORD openHandle,
LPVOID pData, ULONG dataLength, LPVOID pUserData);
typedef UINT VCAPITYPE VIRTUALCHANNELWRITEEX(LPVOID pInitHandle,
DWORD openHandle,
LPVOID pData, ULONG dataLength, LPVOID pUserData);
typedef VIRTUALCHANNELWRITEEX *PVIRTUALCHANNELWRITEEX;
typedef VIRTUALCHANNELWRITEEX* PVIRTUALCHANNELWRITEEX;
typedef struct tagCHANNEL_ENTRY_POINTS
{
@ -231,13 +240,15 @@ typedef struct tagCHANNEL_ENTRY_POINTS_EX
typedef BOOL VCAPITYPE VIRTUALCHANNELENTRY(PCHANNEL_ENTRY_POINTS pEntryPoints);
typedef VIRTUALCHANNELENTRY *PVIRTUALCHANNELENTRY;
typedef VIRTUALCHANNELENTRY* PVIRTUALCHANNELENTRY;
typedef BOOL VCAPITYPE VIRTUALCHANNELENTRYEX(PCHANNEL_ENTRY_POINTS_EX pEntryPointsEx, PVOID pInitHandle);
typedef BOOL VCAPITYPE VIRTUALCHANNELENTRYEX(PCHANNEL_ENTRY_POINTS_EX
pEntryPointsEx, PVOID pInitHandle);
typedef VIRTUALCHANNELENTRYEX *PVIRTUALCHANNELENTRYEX;
typedef VIRTUALCHANNELENTRYEX* PVIRTUALCHANNELENTRYEX;
typedef HRESULT (VCAPITYPE *PFNVCAPIGETINSTANCE)(REFIID refiid, PULONG pNumObjs, PVOID* ppObjArray);
typedef HRESULT(VCAPITYPE* PFNVCAPIGETINSTANCE)(REFIID refiid, PULONG pNumObjs,
PVOID* ppObjArray);
#endif
@ -298,14 +309,14 @@ typedef HRESULT (VCAPITYPE *PFNVCAPIGETINSTANCE)(REFIID refiid, PULONG pNumObjs,
#define WTS_SECURITY_USER_ACCESS (WTS_SECURITY_CURRENT_GUEST_ACCESS | WTS_SECURITY_QUERY_INFORMATION | WTS_SECURITY_CONNECT)
#define WTS_SECURITY_CURRENT_USER_ACCESS (WTS_SECURITY_SET_INFORMATION | WTS_SECURITY_RESET \
WTS_SECURITY_VIRTUAL_CHANNELS | WTS_SECURITY_LOGOFF \
WTS_SECURITY_DISCONNECT)
WTS_SECURITY_VIRTUAL_CHANNELS | WTS_SECURITY_LOGOFF \
WTS_SECURITY_DISCONNECT)
#define WTS_SECURITY_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | WTS_SECURITY_QUERY_INFORMATION | \
WTS_SECURITY_SET_INFORMATION | WTS_SECURITY_RESET | \
WTS_SECURITY_VIRTUAL_CHANNELS | WTS_SECURITY_REMOTE_CONTROL | \
WTS_SECURITY_LOGON | WTS_SECURITY_MESSAGE | \
WTS_SECURITY_CONNECT | WTS_SECURITY_DISCONNECT)
WTS_SECURITY_SET_INFORMATION | WTS_SECURITY_RESET | \
WTS_SECURITY_VIRTUAL_CHANNELS | WTS_SECURITY_REMOTE_CONTROL | \
WTS_SECURITY_LOGON | WTS_SECURITY_MESSAGE | \
WTS_SECURITY_CONNECT | WTS_SECURITY_DISCONNECT)
typedef enum _WTS_CONNECTSTATE_CLASS
{
@ -318,7 +329,7 @@ typedef enum _WTS_CONNECTSTATE_CLASS
WTSListen,
WTSReset,
WTSDown,
WTSInit,
WTSInit
} WTS_CONNECTSTATE_CLASS;
typedef struct _WTS_SERVER_INFOW
@ -485,7 +496,7 @@ typedef struct _WTSINFOA
DWORD OutgoingCompressedBy;
CHAR WinStationName[WINSTATIONNAME_LENGTH];
CHAR Domain[DOMAIN_LENGTH];
CHAR UserName[USERNAME_LENGTH+1];
CHAR UserName[USERNAME_LENGTH + 1];
LARGE_INTEGER ConnectTime;
LARGE_INTEGER DisconnectTime;
LARGE_INTEGER LastInputTime;
@ -677,7 +688,7 @@ typedef enum _WTS_CONFIG_CLASS
WTSUserConfigTerminalServerHomeDir,
WTSUserConfigTerminalServerHomeDirDrive,
WTSUserConfigfTerminalServerRemoteHomeDir,
WTSUserConfigUser,
WTSUserConfigUser
} WTS_CONFIG_CLASS;
typedef enum _WTS_CONFIG_SOURCE
@ -809,13 +820,13 @@ typedef enum _WTS_TYPE_CLASS
{
WTSTypeProcessInfoLevel0,
WTSTypeProcessInfoLevel1,
WTSTypeSessionInfoLevel1,
WTSTypeSessionInfoLevel1
} WTS_TYPE_CLASS;
typedef WCHAR WTSLISTENERNAMEW[WTS_LISTENER_NAME_LENGTH + 1];
typedef WTSLISTENERNAMEW *PWTSLISTENERNAMEW;
typedef WTSLISTENERNAMEW* PWTSLISTENERNAMEW;
typedef CHAR WTSLISTENERNAMEA[WTS_LISTENER_NAME_LENGTH + 1];
typedef WTSLISTENERNAMEA *PWTSLISTENERNAMEA;
typedef WTSLISTENERNAMEA* PWTSLISTENERNAMEA;
typedef struct _WTSLISTENERCONFIGW
{
@ -963,17 +974,25 @@ extern "C" {
WINPR_API BOOL WINAPI WTSStopRemoteControlSession(ULONG LogonId);
WINPR_API BOOL WINAPI WTSStartRemoteControlSessionW(LPWSTR pTargetServerName, ULONG TargetLogonId, BYTE HotkeyVk, USHORT HotkeyModifiers);
WINPR_API BOOL WINAPI WTSStartRemoteControlSessionA(LPSTR pTargetServerName, ULONG TargetLogonId, BYTE HotkeyVk, USHORT HotkeyModifiers);
WINPR_API BOOL WINAPI WTSStartRemoteControlSessionW(LPWSTR pTargetServerName,
ULONG TargetLogonId, BYTE HotkeyVk, USHORT HotkeyModifiers);
WINPR_API BOOL WINAPI WTSStartRemoteControlSessionA(LPSTR pTargetServerName,
ULONG TargetLogonId, BYTE HotkeyVk, USHORT HotkeyModifiers);
WINPR_API BOOL WINAPI WTSStartRemoteControlSessionExW(LPWSTR pTargetServerName, ULONG TargetLogonId, BYTE HotkeyVk, USHORT HotkeyModifiers, DWORD flags);
WINPR_API BOOL WINAPI WTSStartRemoteControlSessionExA(LPSTR pTargetServerName, ULONG TargetLogonId, BYTE HotkeyVk, USHORT HotkeyModifiers, DWORD flags);
WINPR_API BOOL WINAPI WTSStartRemoteControlSessionExW(LPWSTR pTargetServerName,
ULONG TargetLogonId, BYTE HotkeyVk, USHORT HotkeyModifiers, DWORD flags);
WINPR_API BOOL WINAPI WTSStartRemoteControlSessionExA(LPSTR pTargetServerName,
ULONG TargetLogonId, BYTE HotkeyVk, USHORT HotkeyModifiers, DWORD flags);
WINPR_API BOOL WINAPI WTSConnectSessionW(ULONG LogonId, ULONG TargetLogonId, PWSTR pPassword, BOOL bWait);
WINPR_API BOOL WINAPI WTSConnectSessionA(ULONG LogonId, ULONG TargetLogonId, PSTR pPassword, BOOL bWait);
WINPR_API BOOL WINAPI WTSConnectSessionW(ULONG LogonId, ULONG TargetLogonId,
PWSTR pPassword, BOOL bWait);
WINPR_API BOOL WINAPI WTSConnectSessionA(ULONG LogonId, ULONG TargetLogonId,
PSTR pPassword, BOOL bWait);
WINPR_API BOOL WINAPI WTSEnumerateServersW(LPWSTR pDomainName, DWORD Reserved, DWORD Version, PWTS_SERVER_INFOW* ppServerInfo, DWORD* pCount);
WINPR_API BOOL WINAPI WTSEnumerateServersA(LPSTR pDomainName, DWORD Reserved, DWORD Version, PWTS_SERVER_INFOA* ppServerInfo, DWORD* pCount);
WINPR_API BOOL WINAPI WTSEnumerateServersW(LPWSTR pDomainName, DWORD Reserved,
DWORD Version, PWTS_SERVER_INFOW* ppServerInfo, DWORD* pCount);
WINPR_API BOOL WINAPI WTSEnumerateServersA(LPSTR pDomainName, DWORD Reserved,
DWORD Version, PWTS_SERVER_INFOA* ppServerInfo, DWORD* pCount);
WINPR_API HANDLE WINAPI WTSOpenServerW(LPWSTR pServerName);
WINPR_API HANDLE WINAPI WTSOpenServerA(LPSTR pServerName);
@ -983,54 +1002,81 @@ WINPR_API HANDLE WINAPI WTSOpenServerExA(LPSTR pServerName);
WINPR_API VOID WINAPI WTSCloseServer(HANDLE hServer);
WINPR_API BOOL WINAPI WTSEnumerateSessionsW(HANDLE hServer, DWORD Reserved, DWORD Version, PWTS_SESSION_INFOW* ppSessionInfo, DWORD* pCount);
WINPR_API BOOL WINAPI WTSEnumerateSessionsA(HANDLE hServer, DWORD Reserved, DWORD Version, PWTS_SESSION_INFOA* ppSessionInfo, DWORD* pCount);
WINPR_API BOOL WINAPI WTSEnumerateSessionsW(HANDLE hServer, DWORD Reserved,
DWORD Version, PWTS_SESSION_INFOW* ppSessionInfo, DWORD* pCount);
WINPR_API BOOL WINAPI WTSEnumerateSessionsA(HANDLE hServer, DWORD Reserved,
DWORD Version, PWTS_SESSION_INFOA* ppSessionInfo, DWORD* pCount);
WINPR_API BOOL WINAPI WTSEnumerateSessionsExW(HANDLE hServer, DWORD* pLevel, DWORD Filter, PWTS_SESSION_INFO_1W* ppSessionInfo, DWORD* pCount);
WINPR_API BOOL WINAPI WTSEnumerateSessionsExA(HANDLE hServer, DWORD* pLevel, DWORD Filter, PWTS_SESSION_INFO_1A* ppSessionInfo, DWORD* pCount);
WINPR_API BOOL WINAPI WTSEnumerateSessionsExW(HANDLE hServer, DWORD* pLevel,
DWORD Filter, PWTS_SESSION_INFO_1W* ppSessionInfo, DWORD* pCount);
WINPR_API BOOL WINAPI WTSEnumerateSessionsExA(HANDLE hServer, DWORD* pLevel,
DWORD Filter, PWTS_SESSION_INFO_1A* ppSessionInfo, DWORD* pCount);
WINPR_API BOOL WINAPI WTSEnumerateProcessesW(HANDLE hServer, DWORD Reserved, DWORD Version, PWTS_PROCESS_INFOW* ppProcessInfo, DWORD* pCount);
WINPR_API BOOL WINAPI WTSEnumerateProcessesA(HANDLE hServer, DWORD Reserved, DWORD Version, PWTS_PROCESS_INFOA* ppProcessInfo, DWORD* pCount);
WINPR_API BOOL WINAPI WTSEnumerateProcessesW(HANDLE hServer, DWORD Reserved,
DWORD Version, PWTS_PROCESS_INFOW* ppProcessInfo, DWORD* pCount);
WINPR_API BOOL WINAPI WTSEnumerateProcessesA(HANDLE hServer, DWORD Reserved,
DWORD Version, PWTS_PROCESS_INFOA* ppProcessInfo, DWORD* pCount);
WINPR_API BOOL WINAPI WTSTerminateProcess(HANDLE hServer, DWORD ProcessId, DWORD ExitCode);
WINPR_API BOOL WINAPI WTSTerminateProcess(HANDLE hServer, DWORD ProcessId,
DWORD ExitCode);
WINPR_API BOOL WINAPI WTSQuerySessionInformationW(HANDLE hServer, DWORD SessionId, WTS_INFO_CLASS WTSInfoClass, LPWSTR* ppBuffer, DWORD* pBytesReturned);
WINPR_API BOOL WINAPI WTSQuerySessionInformationA(HANDLE hServer, DWORD SessionId, WTS_INFO_CLASS WTSInfoClass, LPSTR* ppBuffer, DWORD* pBytesReturned);
WINPR_API BOOL WINAPI WTSQuerySessionInformationW(HANDLE hServer,
DWORD SessionId, WTS_INFO_CLASS WTSInfoClass, LPWSTR* ppBuffer,
DWORD* pBytesReturned);
WINPR_API BOOL WINAPI WTSQuerySessionInformationA(HANDLE hServer,
DWORD SessionId, WTS_INFO_CLASS WTSInfoClass, LPSTR* ppBuffer,
DWORD* pBytesReturned);
WINPR_API BOOL WINAPI WTSQueryUserConfigW(LPWSTR pServerName, LPWSTR pUserName, WTS_CONFIG_CLASS WTSConfigClass, LPWSTR* ppBuffer, DWORD* pBytesReturned);
WINPR_API BOOL WINAPI WTSQueryUserConfigA(LPSTR pServerName, LPSTR pUserName, WTS_CONFIG_CLASS WTSConfigClass, LPSTR* ppBuffer, DWORD* pBytesReturned);
WINPR_API BOOL WINAPI WTSQueryUserConfigW(LPWSTR pServerName, LPWSTR pUserName,
WTS_CONFIG_CLASS WTSConfigClass, LPWSTR* ppBuffer, DWORD* pBytesReturned);
WINPR_API BOOL WINAPI WTSQueryUserConfigA(LPSTR pServerName, LPSTR pUserName,
WTS_CONFIG_CLASS WTSConfigClass, LPSTR* ppBuffer, DWORD* pBytesReturned);
WINPR_API BOOL WINAPI WTSSetUserConfigW(LPWSTR pServerName, LPWSTR pUserName, WTS_CONFIG_CLASS WTSConfigClass, LPWSTR pBuffer, DWORD DataLength);
WINPR_API BOOL WINAPI WTSSetUserConfigA(LPSTR pServerName, LPSTR pUserName, WTS_CONFIG_CLASS WTSConfigClass, LPSTR pBuffer, DWORD DataLength);
WINPR_API BOOL WINAPI WTSSetUserConfigW(LPWSTR pServerName, LPWSTR pUserName,
WTS_CONFIG_CLASS WTSConfigClass, LPWSTR pBuffer, DWORD DataLength);
WINPR_API BOOL WINAPI WTSSetUserConfigA(LPSTR pServerName, LPSTR pUserName,
WTS_CONFIG_CLASS WTSConfigClass, LPSTR pBuffer, DWORD DataLength);
WINPR_API BOOL WINAPI WTSSendMessageW(HANDLE hServer, DWORD SessionId, LPWSTR pTitle, DWORD TitleLength,
LPWSTR pMessage, DWORD MessageLength, DWORD Style, DWORD Timeout, DWORD* pResponse, BOOL bWait);
WINPR_API BOOL WINAPI WTSSendMessageA(HANDLE hServer, DWORD SessionId, LPSTR pTitle, DWORD TitleLength,
LPSTR pMessage, DWORD MessageLength, DWORD Style, DWORD Timeout, DWORD* pResponse, BOOL bWait);
WINPR_API BOOL WINAPI WTSSendMessageW(HANDLE hServer, DWORD SessionId,
LPWSTR pTitle, DWORD TitleLength,
LPWSTR pMessage, DWORD MessageLength, DWORD Style, DWORD Timeout,
DWORD* pResponse, BOOL bWait);
WINPR_API BOOL WINAPI WTSSendMessageA(HANDLE hServer, DWORD SessionId,
LPSTR pTitle, DWORD TitleLength,
LPSTR pMessage, DWORD MessageLength, DWORD Style, DWORD Timeout,
DWORD* pResponse, BOOL bWait);
WINPR_API BOOL WINAPI WTSDisconnectSession(HANDLE hServer, DWORD SessionId, BOOL bWait);
WINPR_API BOOL WINAPI WTSDisconnectSession(HANDLE hServer, DWORD SessionId,
BOOL bWait);
WINPR_API BOOL WINAPI WTSLogoffSession(HANDLE hServer, DWORD SessionId, BOOL bWait);
WINPR_API BOOL WINAPI WTSLogoffSession(HANDLE hServer, DWORD SessionId,
BOOL bWait);
WINPR_API BOOL WINAPI WTSShutdownSystem(HANDLE hServer, DWORD ShutdownFlag);
WINPR_API BOOL WINAPI WTSWaitSystemEvent(HANDLE hServer, DWORD EventMask, DWORD* pEventFlags);
WINPR_API BOOL WINAPI WTSWaitSystemEvent(HANDLE hServer, DWORD EventMask,
DWORD* pEventFlags);
WINPR_API HANDLE WINAPI WTSVirtualChannelOpen(HANDLE hServer, DWORD SessionId, LPSTR pVirtualName);
WINPR_API HANDLE WINAPI WTSVirtualChannelOpen(HANDLE hServer, DWORD SessionId,
LPSTR pVirtualName);
WINPR_API HANDLE WINAPI WTSVirtualChannelOpenEx(DWORD SessionId, LPSTR pVirtualName, DWORD flags);
WINPR_API HANDLE WINAPI WTSVirtualChannelOpenEx(DWORD SessionId,
LPSTR pVirtualName, DWORD flags);
WINPR_API BOOL WINAPI WTSVirtualChannelClose(HANDLE hChannelHandle);
WINPR_API BOOL WINAPI WTSVirtualChannelRead(HANDLE hChannelHandle, ULONG TimeOut, PCHAR Buffer, ULONG BufferSize, PULONG pBytesRead);
WINPR_API BOOL WINAPI WTSVirtualChannelRead(HANDLE hChannelHandle,
ULONG TimeOut, PCHAR Buffer, ULONG BufferSize, PULONG pBytesRead);
WINPR_API BOOL WINAPI WTSVirtualChannelWrite(HANDLE hChannelHandle, PCHAR Buffer, ULONG Length, PULONG pBytesWritten);
WINPR_API BOOL WINAPI WTSVirtualChannelWrite(HANDLE hChannelHandle,
PCHAR Buffer, ULONG Length, PULONG pBytesWritten);
WINPR_API BOOL WINAPI WTSVirtualChannelPurgeInput(HANDLE hChannelHandle);
WINPR_API BOOL WINAPI WTSVirtualChannelPurgeOutput(HANDLE hChannelHandle);
WINPR_API BOOL WINAPI WTSVirtualChannelQuery(HANDLE hChannelHandle, WTS_VIRTUAL_CLASS WtsVirtualClass, PVOID* ppBuffer, DWORD* pBytesReturned);
WINPR_API BOOL WINAPI WTSVirtualChannelQuery(HANDLE hChannelHandle,
WTS_VIRTUAL_CLASS WtsVirtualClass, PVOID* ppBuffer, DWORD* pBytesReturned);
WINPR_API VOID WINAPI WTSFreeMemory(PVOID pMemory);
@ -1038,42 +1084,60 @@ WINPR_API BOOL WINAPI WTSRegisterSessionNotification(HWND hWnd, DWORD dwFlags);
WINPR_API BOOL WINAPI WTSUnRegisterSessionNotification(HWND hWnd);
WINPR_API BOOL WINAPI WTSRegisterSessionNotificationEx(HANDLE hServer, HWND hWnd, DWORD dwFlags);
WINPR_API BOOL WINAPI WTSRegisterSessionNotificationEx(HANDLE hServer,
HWND hWnd, DWORD dwFlags);
WINPR_API BOOL WINAPI WTSUnRegisterSessionNotificationEx(HANDLE hServer, HWND hWnd);
WINPR_API BOOL WINAPI WTSUnRegisterSessionNotificationEx(HANDLE hServer,
HWND hWnd);
WINPR_API BOOL WINAPI WTSQueryUserToken(ULONG SessionId, PHANDLE phToken);
WINPR_API BOOL WINAPI WTSFreeMemoryExW(WTS_TYPE_CLASS WTSTypeClass, PVOID pMemory, ULONG NumberOfEntries);
WINPR_API BOOL WINAPI WTSFreeMemoryExA(WTS_TYPE_CLASS WTSTypeClass, PVOID pMemory, ULONG NumberOfEntries);
WINPR_API BOOL WINAPI WTSFreeMemoryExW(WTS_TYPE_CLASS WTSTypeClass,
PVOID pMemory, ULONG NumberOfEntries);
WINPR_API BOOL WINAPI WTSFreeMemoryExA(WTS_TYPE_CLASS WTSTypeClass,
PVOID pMemory, ULONG NumberOfEntries);
WINPR_API BOOL WINAPI WTSEnumerateProcessesExW(HANDLE hServer, DWORD* pLevel, DWORD SessionId, LPWSTR* ppProcessInfo, DWORD* pCount);
WINPR_API BOOL WINAPI WTSEnumerateProcessesExA(HANDLE hServer, DWORD* pLevel, DWORD SessionId, LPSTR* ppProcessInfo, DWORD* pCount);
WINPR_API BOOL WINAPI WTSEnumerateProcessesExW(HANDLE hServer, DWORD* pLevel,
DWORD SessionId, LPWSTR* ppProcessInfo, DWORD* pCount);
WINPR_API BOOL WINAPI WTSEnumerateProcessesExA(HANDLE hServer, DWORD* pLevel,
DWORD SessionId, LPSTR* ppProcessInfo, DWORD* pCount);
WINPR_API BOOL WINAPI WTSEnumerateListenersW(HANDLE hServer, PVOID pReserved, DWORD Reserved, PWTSLISTENERNAMEW pListeners, DWORD* pCount);
WINPR_API BOOL WINAPI WTSEnumerateListenersA(HANDLE hServer, PVOID pReserved, DWORD Reserved, PWTSLISTENERNAMEA pListeners, DWORD* pCount);
WINPR_API BOOL WINAPI WTSEnumerateListenersW(HANDLE hServer, PVOID pReserved,
DWORD Reserved, PWTSLISTENERNAMEW pListeners, DWORD* pCount);
WINPR_API BOOL WINAPI WTSEnumerateListenersA(HANDLE hServer, PVOID pReserved,
DWORD Reserved, PWTSLISTENERNAMEA pListeners, DWORD* pCount);
WINPR_API BOOL WINAPI WTSQueryListenerConfigW(HANDLE hServer, PVOID pReserved, DWORD Reserved, LPWSTR pListenerName, PWTSLISTENERCONFIGW pBuffer);
WINPR_API BOOL WINAPI WTSQueryListenerConfigA(HANDLE hServer, PVOID pReserved, DWORD Reserved, LPSTR pListenerName, PWTSLISTENERCONFIGA pBuffer);
WINPR_API BOOL WINAPI WTSQueryListenerConfigW(HANDLE hServer, PVOID pReserved,
DWORD Reserved, LPWSTR pListenerName, PWTSLISTENERCONFIGW pBuffer);
WINPR_API BOOL WINAPI WTSQueryListenerConfigA(HANDLE hServer, PVOID pReserved,
DWORD Reserved, LPSTR pListenerName, PWTSLISTENERCONFIGA pBuffer);
WINPR_API BOOL WINAPI WTSCreateListenerW(HANDLE hServer, PVOID pReserved, DWORD Reserved,
LPWSTR pListenerName, PWTSLISTENERCONFIGW pBuffer, DWORD flag);
WINPR_API BOOL WINAPI WTSCreateListenerA(HANDLE hServer, PVOID pReserved, DWORD Reserved,
LPSTR pListenerName, PWTSLISTENERCONFIGA pBuffer, DWORD flag);
WINPR_API BOOL WINAPI WTSCreateListenerW(HANDLE hServer, PVOID pReserved,
DWORD Reserved,
LPWSTR pListenerName, PWTSLISTENERCONFIGW pBuffer, DWORD flag);
WINPR_API BOOL WINAPI WTSCreateListenerA(HANDLE hServer, PVOID pReserved,
DWORD Reserved,
LPSTR pListenerName, PWTSLISTENERCONFIGA pBuffer, DWORD flag);
WINPR_API BOOL WINAPI WTSSetListenerSecurityW(HANDLE hServer, PVOID pReserved, DWORD Reserved,
LPWSTR pListenerName, SECURITY_INFORMATION SecurityInformation,
PSECURITY_DESCRIPTOR pSecurityDescriptor);
WINPR_API BOOL WINAPI WTSSetListenerSecurityA(HANDLE hServer, PVOID pReserved, DWORD Reserved,
LPSTR pListenerName, SECURITY_INFORMATION SecurityInformation,
PSECURITY_DESCRIPTOR pSecurityDescriptor);
WINPR_API BOOL WINAPI WTSSetListenerSecurityW(HANDLE hServer, PVOID pReserved,
DWORD Reserved,
LPWSTR pListenerName, SECURITY_INFORMATION SecurityInformation,
PSECURITY_DESCRIPTOR pSecurityDescriptor);
WINPR_API BOOL WINAPI WTSSetListenerSecurityA(HANDLE hServer, PVOID pReserved,
DWORD Reserved,
LPSTR pListenerName, SECURITY_INFORMATION SecurityInformation,
PSECURITY_DESCRIPTOR pSecurityDescriptor);
WINPR_API BOOL WINAPI WTSGetListenerSecurityW(HANDLE hServer, PVOID pReserved, DWORD Reserved,
LPWSTR pListenerName, SECURITY_INFORMATION SecurityInformation,
PSECURITY_DESCRIPTOR pSecurityDescriptor, DWORD nLength, LPDWORD lpnLengthNeeded);
WINPR_API BOOL WINAPI WTSGetListenerSecurityA(HANDLE hServer, PVOID pReserved, DWORD Reserved,
LPSTR pListenerName, SECURITY_INFORMATION SecurityInformation,
PSECURITY_DESCRIPTOR pSecurityDescriptor, DWORD nLength, LPDWORD lpnLengthNeeded);
WINPR_API BOOL WINAPI WTSGetListenerSecurityW(HANDLE hServer, PVOID pReserved,
DWORD Reserved,
LPWSTR pListenerName, SECURITY_INFORMATION SecurityInformation,
PSECURITY_DESCRIPTOR pSecurityDescriptor, DWORD nLength,
LPDWORD lpnLengthNeeded);
WINPR_API BOOL WINAPI WTSGetListenerSecurityA(HANDLE hServer, PVOID pReserved,
DWORD Reserved,
LPSTR pListenerName, SECURITY_INFORMATION SecurityInformation,
PSECURITY_DESCRIPTOR pSecurityDescriptor, DWORD nLength,
LPDWORD lpnLengthNeeded);
/**
* WTSEnableChildSessions, WTSIsChildSessionsEnabled and WTSGetChildSessionId
@ -1088,7 +1152,7 @@ WINPR_API BOOL CDECL WTSIsChildSessionsEnabled(PBOOL pbEnabled);
WINPR_API BOOL CDECL WTSGetChildSessionId(PULONG pSessionId);
WINPR_API BOOL CDECL WTSLogonUser(HANDLE hServer, LPCSTR username,
LPCSTR password, LPCSTR domain);
LPCSTR password, LPCSTR domain);
WINPR_API BOOL CDECL WTSLogoffUser(HANDLE hServer);
@ -1154,156 +1218,206 @@ WINPR_API DWORD WINAPI WTSGetActiveConsoleSessionId(void);
#endif
typedef BOOL (WINAPI * WTS_STOP_REMOTE_CONTROL_SESSION_FN)(ULONG LogonId);
typedef BOOL (WINAPI* WTS_STOP_REMOTE_CONTROL_SESSION_FN)(ULONG LogonId);
typedef BOOL (WINAPI * WTS_START_REMOTE_CONTROL_SESSION_FN_W)(LPWSTR pTargetServerName,
ULONG TargetLogonId, BYTE HotkeyVk, USHORT HotkeyModifiers);
typedef BOOL (WINAPI * WTS_START_REMOTE_CONTROL_SESSION_FN_A)(LPSTR pTargetServerName,
ULONG TargetLogonId, BYTE HotkeyVk, USHORT HotkeyModifiers);
typedef BOOL (WINAPI* WTS_START_REMOTE_CONTROL_SESSION_FN_W)(
LPWSTR pTargetServerName,
ULONG TargetLogonId, BYTE HotkeyVk, USHORT HotkeyModifiers);
typedef BOOL (WINAPI* WTS_START_REMOTE_CONTROL_SESSION_FN_A)(
LPSTR pTargetServerName,
ULONG TargetLogonId, BYTE HotkeyVk, USHORT HotkeyModifiers);
typedef BOOL (WINAPI * WTS_START_REMOTE_CONTROL_SESSION_EX_FN_W)(LPWSTR pTargetServerName,
ULONG TargetLogonId, BYTE HotkeyVk, USHORT HotkeyModifiers, DWORD flags);
typedef BOOL (WINAPI * WTS_START_REMOTE_CONTROL_SESSION_EX_FN_A)(LPSTR pTargetServerName,
ULONG TargetLogonId, BYTE HotkeyVk, USHORT HotkeyModifiers, DWORD flags);
typedef BOOL (WINAPI* WTS_START_REMOTE_CONTROL_SESSION_EX_FN_W)(
LPWSTR pTargetServerName,
ULONG TargetLogonId, BYTE HotkeyVk, USHORT HotkeyModifiers, DWORD flags);
typedef BOOL (WINAPI* WTS_START_REMOTE_CONTROL_SESSION_EX_FN_A)(
LPSTR pTargetServerName,
ULONG TargetLogonId, BYTE HotkeyVk, USHORT HotkeyModifiers, DWORD flags);
typedef BOOL (WINAPI * WTS_CONNECT_SESSION_FN_W)(ULONG LogonId, ULONG TargetLogonId, PWSTR pPassword, BOOL bWait);
typedef BOOL (WINAPI * WTS_CONNECT_SESSION_FN_A)(ULONG LogonId, ULONG TargetLogonId, PSTR pPassword, BOOL bWait);
typedef BOOL (WINAPI* WTS_CONNECT_SESSION_FN_W)(ULONG LogonId,
ULONG TargetLogonId, PWSTR pPassword, BOOL bWait);
typedef BOOL (WINAPI* WTS_CONNECT_SESSION_FN_A)(ULONG LogonId,
ULONG TargetLogonId, PSTR pPassword, BOOL bWait);
typedef BOOL (WINAPI * WTS_ENUMERATE_SERVERS_FN_W)(LPWSTR pDomainName,
DWORD Reserved, DWORD Version, PWTS_SERVER_INFOW* ppServerInfo, DWORD* pCount);
typedef BOOL (WINAPI * WTS_ENUMERATE_SERVERS_FN_A)(LPSTR pDomainName,
DWORD Reserved, DWORD Version, PWTS_SERVER_INFOA* ppServerInfo, DWORD* pCount);
typedef BOOL (WINAPI* WTS_ENUMERATE_SERVERS_FN_W)(LPWSTR pDomainName,
DWORD Reserved, DWORD Version, PWTS_SERVER_INFOW* ppServerInfo, DWORD* pCount);
typedef BOOL (WINAPI* WTS_ENUMERATE_SERVERS_FN_A)(LPSTR pDomainName,
DWORD Reserved, DWORD Version, PWTS_SERVER_INFOA* ppServerInfo, DWORD* pCount);
typedef HANDLE (WINAPI * WTS_OPEN_SERVER_FN_W)(LPWSTR pServerName);
typedef HANDLE (WINAPI * WTS_OPEN_SERVER_FN_A)(LPSTR pServerName);
typedef HANDLE(WINAPI* WTS_OPEN_SERVER_FN_W)(LPWSTR pServerName);
typedef HANDLE(WINAPI* WTS_OPEN_SERVER_FN_A)(LPSTR pServerName);
typedef HANDLE (WINAPI * WTS_OPEN_SERVER_EX_FN_W)(LPWSTR pServerName);
typedef HANDLE (WINAPI * WTS_OPEN_SERVER_EX_FN_A)(LPSTR pServerName);
typedef HANDLE(WINAPI* WTS_OPEN_SERVER_EX_FN_W)(LPWSTR pServerName);
typedef HANDLE(WINAPI* WTS_OPEN_SERVER_EX_FN_A)(LPSTR pServerName);
typedef VOID (WINAPI * WTS_CLOSE_SERVER_FN)(HANDLE hServer);
typedef VOID (WINAPI* WTS_CLOSE_SERVER_FN)(HANDLE hServer);
typedef BOOL (WINAPI * WTS_ENUMERATE_SESSIONS_FN_W)(HANDLE hServer,
DWORD Reserved, DWORD Version, PWTS_SESSION_INFOW* ppSessionInfo, DWORD* pCount);
typedef BOOL (WINAPI * WTS_ENUMERATE_SESSIONS_FN_A)(HANDLE hServer,
DWORD Reserved, DWORD Version, PWTS_SESSION_INFOA* ppSessionInfo, DWORD* pCount);
typedef BOOL (WINAPI* WTS_ENUMERATE_SESSIONS_FN_W)(HANDLE hServer,
DWORD Reserved, DWORD Version, PWTS_SESSION_INFOW* ppSessionInfo,
DWORD* pCount);
typedef BOOL (WINAPI* WTS_ENUMERATE_SESSIONS_FN_A)(HANDLE hServer,
DWORD Reserved, DWORD Version, PWTS_SESSION_INFOA* ppSessionInfo,
DWORD* pCount);
typedef BOOL (WINAPI * WTS_ENUMERATE_SESSIONS_EX_FN_W)(HANDLE hServer,
DWORD* pLevel, DWORD Filter, PWTS_SESSION_INFO_1W* ppSessionInfo, DWORD* pCount);
typedef BOOL (WINAPI * WTS_ENUMERATE_SESSIONS_EX_FN_A)(HANDLE hServer,
DWORD* pLevel, DWORD Filter, PWTS_SESSION_INFO_1A* ppSessionInfo, DWORD* pCount);
typedef BOOL (WINAPI* WTS_ENUMERATE_SESSIONS_EX_FN_W)(HANDLE hServer,
DWORD* pLevel, DWORD Filter, PWTS_SESSION_INFO_1W* ppSessionInfo,
DWORD* pCount);
typedef BOOL (WINAPI* WTS_ENUMERATE_SESSIONS_EX_FN_A)(HANDLE hServer,
DWORD* pLevel, DWORD Filter, PWTS_SESSION_INFO_1A* ppSessionInfo,
DWORD* pCount);
typedef BOOL (WINAPI * WTS_ENUMERATE_PROCESSES_FN_W)(HANDLE hServer,
DWORD Reserved, DWORD Version, PWTS_PROCESS_INFOW* ppProcessInfo, DWORD* pCount);
typedef BOOL (WINAPI * WTS_ENUMERATE_PROCESSES_FN_A)(HANDLE hServer,
DWORD Reserved, DWORD Version, PWTS_PROCESS_INFOA* ppProcessInfo, DWORD* pCount);
typedef BOOL (WINAPI* WTS_ENUMERATE_PROCESSES_FN_W)(HANDLE hServer,
DWORD Reserved, DWORD Version, PWTS_PROCESS_INFOW* ppProcessInfo,
DWORD* pCount);
typedef BOOL (WINAPI* WTS_ENUMERATE_PROCESSES_FN_A)(HANDLE hServer,
DWORD Reserved, DWORD Version, PWTS_PROCESS_INFOA* ppProcessInfo,
DWORD* pCount);
typedef BOOL (WINAPI * WTS_TERMINATE_PROCESS_FN)(HANDLE hServer, DWORD ProcessId, DWORD ExitCode);
typedef BOOL (WINAPI* WTS_TERMINATE_PROCESS_FN)(HANDLE hServer, DWORD ProcessId,
DWORD ExitCode);
typedef BOOL (WINAPI * WTS_QUERY_SESSION_INFORMATION_FN_W)(HANDLE hServer,
DWORD SessionId, WTS_INFO_CLASS WTSInfoClass, LPWSTR* ppBuffer, DWORD* pBytesReturned);
typedef BOOL (WINAPI * WTS_QUERY_SESSION_INFORMATION_FN_A)(HANDLE hServer,
DWORD SessionId, WTS_INFO_CLASS WTSInfoClass, LPSTR* ppBuffer, DWORD* pBytesReturned);
typedef BOOL (WINAPI* WTS_QUERY_SESSION_INFORMATION_FN_W)(HANDLE hServer,
DWORD SessionId, WTS_INFO_CLASS WTSInfoClass, LPWSTR* ppBuffer,
DWORD* pBytesReturned);
typedef BOOL (WINAPI* WTS_QUERY_SESSION_INFORMATION_FN_A)(HANDLE hServer,
DWORD SessionId, WTS_INFO_CLASS WTSInfoClass, LPSTR* ppBuffer,
DWORD* pBytesReturned);
typedef BOOL (WINAPI * WTS_QUERY_USER_CONFIG_FN_W)(LPWSTR pServerName,
LPWSTR pUserName, WTS_CONFIG_CLASS WTSConfigClass, LPWSTR* ppBuffer, DWORD* pBytesReturned);
typedef BOOL (WINAPI * WTS_QUERY_USER_CONFIG_FN_A)(LPSTR pServerName,
LPSTR pUserName, WTS_CONFIG_CLASS WTSConfigClass, LPSTR* ppBuffer, DWORD* pBytesReturned);
typedef BOOL (WINAPI* WTS_QUERY_USER_CONFIG_FN_W)(LPWSTR pServerName,
LPWSTR pUserName, WTS_CONFIG_CLASS WTSConfigClass, LPWSTR* ppBuffer,
DWORD* pBytesReturned);
typedef BOOL (WINAPI* WTS_QUERY_USER_CONFIG_FN_A)(LPSTR pServerName,
LPSTR pUserName, WTS_CONFIG_CLASS WTSConfigClass, LPSTR* ppBuffer,
DWORD* pBytesReturned);
typedef BOOL (WINAPI * WTS_SET_USER_CONFIG_FN_W)(LPWSTR pServerName,
LPWSTR pUserName, WTS_CONFIG_CLASS WTSConfigClass, LPWSTR pBuffer, DWORD DataLength);
typedef BOOL (WINAPI * WTS_SET_USER_CONFIG_FN_A)(LPSTR pServerName,
LPSTR pUserName, WTS_CONFIG_CLASS WTSConfigClass, LPSTR pBuffer, DWORD DataLength);
typedef BOOL (WINAPI* WTS_SET_USER_CONFIG_FN_W)(LPWSTR pServerName,
LPWSTR pUserName, WTS_CONFIG_CLASS WTSConfigClass, LPWSTR pBuffer,
DWORD DataLength);
typedef BOOL (WINAPI* WTS_SET_USER_CONFIG_FN_A)(LPSTR pServerName,
LPSTR pUserName, WTS_CONFIG_CLASS WTSConfigClass, LPSTR pBuffer,
DWORD DataLength);
typedef BOOL (WINAPI * WTS_SEND_MESSAGE_FN_W)(HANDLE hServer, DWORD SessionId, LPWSTR pTitle, DWORD TitleLength,
LPWSTR pMessage, DWORD MessageLength, DWORD Style, DWORD Timeout, DWORD* pResponse, BOOL bWait);
typedef BOOL (WINAPI * WTS_SEND_MESSAGE_FN_A)(HANDLE hServer, DWORD SessionId, LPSTR pTitle, DWORD TitleLength,
LPSTR pMessage, DWORD MessageLength, DWORD Style, DWORD Timeout, DWORD* pResponse, BOOL bWait);
typedef BOOL (WINAPI* WTS_SEND_MESSAGE_FN_W)(HANDLE hServer, DWORD SessionId,
LPWSTR pTitle, DWORD TitleLength,
LPWSTR pMessage, DWORD MessageLength, DWORD Style, DWORD Timeout,
DWORD* pResponse, BOOL bWait);
typedef BOOL (WINAPI* WTS_SEND_MESSAGE_FN_A)(HANDLE hServer, DWORD SessionId,
LPSTR pTitle, DWORD TitleLength,
LPSTR pMessage, DWORD MessageLength, DWORD Style, DWORD Timeout,
DWORD* pResponse, BOOL bWait);
typedef BOOL (WINAPI * WTS_DISCONNECT_SESSION_FN)(HANDLE hServer, DWORD SessionId, BOOL bWait);
typedef BOOL (WINAPI* WTS_DISCONNECT_SESSION_FN)(HANDLE hServer,
DWORD SessionId, BOOL bWait);
typedef BOOL (WINAPI * WTS_LOGOFF_SESSION_FN)(HANDLE hServer, DWORD SessionId, BOOL bWait);
typedef BOOL (WINAPI* WTS_LOGOFF_SESSION_FN)(HANDLE hServer, DWORD SessionId,
BOOL bWait);
typedef BOOL (WINAPI * WTS_SHUTDOWN_SYSTEM_FN)(HANDLE hServer, DWORD ShutdownFlag);
typedef BOOL (WINAPI* WTS_SHUTDOWN_SYSTEM_FN)(HANDLE hServer,
DWORD ShutdownFlag);
typedef BOOL (WINAPI * WTS_WAIT_SYSTEM_EVENT_FN)(HANDLE hServer, DWORD EventMask, DWORD* pEventFlags);
typedef BOOL (WINAPI* WTS_WAIT_SYSTEM_EVENT_FN)(HANDLE hServer, DWORD EventMask,
DWORD* pEventFlags);
typedef HANDLE (WINAPI * WTS_VIRTUAL_CHANNEL_OPEN_FN)(HANDLE hServer, DWORD SessionId, LPSTR pVirtualName);
typedef HANDLE(WINAPI* WTS_VIRTUAL_CHANNEL_OPEN_FN)(HANDLE hServer,
DWORD SessionId, LPSTR pVirtualName);
typedef HANDLE (WINAPI * WTS_VIRTUAL_CHANNEL_OPEN_EX_FN)(DWORD SessionId, LPSTR pVirtualName, DWORD flags);
typedef HANDLE(WINAPI* WTS_VIRTUAL_CHANNEL_OPEN_EX_FN)(DWORD SessionId,
LPSTR pVirtualName, DWORD flags);
typedef BOOL (WINAPI * WTS_VIRTUAL_CHANNEL_CLOSE_FN)(HANDLE hChannelHandle);
typedef BOOL (WINAPI* WTS_VIRTUAL_CHANNEL_CLOSE_FN)(HANDLE hChannelHandle);
typedef BOOL (WINAPI * WTS_VIRTUAL_CHANNEL_READ_FN)(HANDLE hChannelHandle, ULONG TimeOut, PCHAR Buffer, ULONG BufferSize, PULONG pBytesRead);
typedef BOOL (WINAPI* WTS_VIRTUAL_CHANNEL_READ_FN)(HANDLE hChannelHandle,
ULONG TimeOut, PCHAR Buffer, ULONG BufferSize, PULONG pBytesRead);
typedef BOOL (WINAPI * WTS_VIRTUAL_CHANNEL_WRITE_FN)(HANDLE hChannelHandle, PCHAR Buffer, ULONG Length, PULONG pBytesWritten);
typedef BOOL (WINAPI* WTS_VIRTUAL_CHANNEL_WRITE_FN)(HANDLE hChannelHandle,
PCHAR Buffer, ULONG Length, PULONG pBytesWritten);
typedef BOOL (WINAPI * WTS_VIRTUAL_CHANNEL_PURGE_INPUT_FN)(HANDLE hChannelHandle);
typedef BOOL (WINAPI* WTS_VIRTUAL_CHANNEL_PURGE_INPUT_FN)(
HANDLE hChannelHandle);
typedef BOOL (WINAPI * WTS_VIRTUAL_CHANNEL_PURGE_OUTPUT_FN)(HANDLE hChannelHandle);
typedef BOOL (WINAPI* WTS_VIRTUAL_CHANNEL_PURGE_OUTPUT_FN)(
HANDLE hChannelHandle);
typedef BOOL (WINAPI * WTS_VIRTUAL_CHANNEL_QUERY_FN)(HANDLE hChannelHandle, WTS_VIRTUAL_CLASS WtsVirtualClass, PVOID* ppBuffer, DWORD* pBytesReturned);
typedef BOOL (WINAPI* WTS_VIRTUAL_CHANNEL_QUERY_FN)(HANDLE hChannelHandle,
WTS_VIRTUAL_CLASS WtsVirtualClass, PVOID* ppBuffer, DWORD* pBytesReturned);
typedef VOID (WINAPI * WTS_FREE_MEMORY_FN)(PVOID pMemory);
typedef VOID (WINAPI* WTS_FREE_MEMORY_FN)(PVOID pMemory);
typedef BOOL (WINAPI * WTS_REGISTER_SESSION_NOTIFICATION_FN)(HWND hWnd, DWORD dwFlags);
typedef BOOL (WINAPI* WTS_REGISTER_SESSION_NOTIFICATION_FN)(HWND hWnd,
DWORD dwFlags);
typedef BOOL (WINAPI * WTS_UNREGISTER_SESSION_NOTIFICATION_FN)(HWND hWnd);
typedef BOOL (WINAPI* WTS_UNREGISTER_SESSION_NOTIFICATION_FN)(HWND hWnd);
typedef BOOL (WINAPI * WTS_REGISTER_SESSION_NOTIFICATION_EX_FN)(HANDLE hServer, HWND hWnd, DWORD dwFlags);
typedef BOOL (WINAPI* WTS_REGISTER_SESSION_NOTIFICATION_EX_FN)(HANDLE hServer,
HWND hWnd, DWORD dwFlags);
typedef BOOL (WINAPI * WTS_UNREGISTER_SESSION_NOTIFICATION_EX_FN)(HANDLE hServer, HWND hWnd);
typedef BOOL (WINAPI* WTS_UNREGISTER_SESSION_NOTIFICATION_EX_FN)(HANDLE hServer,
HWND hWnd);
typedef BOOL (WINAPI * WTS_QUERY_USER_TOKEN_FN)(ULONG SessionId, PHANDLE phToken);
typedef BOOL (WINAPI* WTS_QUERY_USER_TOKEN_FN)(ULONG SessionId,
PHANDLE phToken);
typedef BOOL (WINAPI * WTS_FREE_MEMORY_EX_FN_W)(WTS_TYPE_CLASS WTSTypeClass, PVOID pMemory, ULONG NumberOfEntries);
typedef BOOL (WINAPI * WTS_FREE_MEMORY_EX_FN_A)(WTS_TYPE_CLASS WTSTypeClass, PVOID pMemory, ULONG NumberOfEntries);
typedef BOOL (WINAPI* WTS_FREE_MEMORY_EX_FN_W)(WTS_TYPE_CLASS WTSTypeClass,
PVOID pMemory, ULONG NumberOfEntries);
typedef BOOL (WINAPI* WTS_FREE_MEMORY_EX_FN_A)(WTS_TYPE_CLASS WTSTypeClass,
PVOID pMemory, ULONG NumberOfEntries);
typedef BOOL (WINAPI * WTS_ENUMERATE_PROCESSES_EX_FN_W)(HANDLE hServer,
DWORD* pLevel, DWORD SessionId, LPWSTR* ppProcessInfo, DWORD* pCount);
typedef BOOL (WINAPI * WTS_ENUMERATE_PROCESSES_EX_FN_A)(HANDLE hServer,
DWORD* pLevel, DWORD SessionId, LPSTR* ppProcessInfo, DWORD* pCount);
typedef BOOL (WINAPI* WTS_ENUMERATE_PROCESSES_EX_FN_W)(HANDLE hServer,
DWORD* pLevel, DWORD SessionId, LPWSTR* ppProcessInfo, DWORD* pCount);
typedef BOOL (WINAPI* WTS_ENUMERATE_PROCESSES_EX_FN_A)(HANDLE hServer,
DWORD* pLevel, DWORD SessionId, LPSTR* ppProcessInfo, DWORD* pCount);
typedef BOOL (WINAPI * WTS_ENUMERATE_LISTENERS_FN_W)(HANDLE hServer,
PVOID pReserved, DWORD Reserved, PWTSLISTENERNAMEW pListeners, DWORD* pCount);
typedef BOOL (WINAPI * WTS_ENUMERATE_LISTENERS_FN_A)(HANDLE hServer,
PVOID pReserved, DWORD Reserved, PWTSLISTENERNAMEA pListeners, DWORD* pCount);
typedef BOOL (WINAPI* WTS_ENUMERATE_LISTENERS_FN_W)(HANDLE hServer,
PVOID pReserved, DWORD Reserved, PWTSLISTENERNAMEW pListeners, DWORD* pCount);
typedef BOOL (WINAPI* WTS_ENUMERATE_LISTENERS_FN_A)(HANDLE hServer,
PVOID pReserved, DWORD Reserved, PWTSLISTENERNAMEA pListeners, DWORD* pCount);
typedef BOOL (WINAPI * WTS_QUERY_LISTENER_CONFIG_FN_W)(HANDLE hServer,
PVOID pReserved, DWORD Reserved, LPWSTR pListenerName, PWTSLISTENERCONFIGW pBuffer);
typedef BOOL (WINAPI * WTS_QUERY_LISTENER_CONFIG_FN_A)(HANDLE hServer,
PVOID pReserved, DWORD Reserved, LPSTR pListenerName, PWTSLISTENERCONFIGA pBuffer);
typedef BOOL (WINAPI* WTS_QUERY_LISTENER_CONFIG_FN_W)(HANDLE hServer,
PVOID pReserved, DWORD Reserved, LPWSTR pListenerName,
PWTSLISTENERCONFIGW pBuffer);
typedef BOOL (WINAPI* WTS_QUERY_LISTENER_CONFIG_FN_A)(HANDLE hServer,
PVOID pReserved, DWORD Reserved, LPSTR pListenerName,
PWTSLISTENERCONFIGA pBuffer);
typedef BOOL (WINAPI * WTS_CREATE_LISTENER_FN_W)(HANDLE hServer, PVOID pReserved, DWORD Reserved,
LPWSTR pListenerName, PWTSLISTENERCONFIGW pBuffer, DWORD flag);
typedef BOOL (WINAPI * WTS_CREATE_LISTENER_FN_A)(HANDLE hServer, PVOID pReserved, DWORD Reserved,
LPSTR pListenerName, PWTSLISTENERCONFIGA pBuffer, DWORD flag);
typedef BOOL (WINAPI* WTS_CREATE_LISTENER_FN_W)(HANDLE hServer, PVOID pReserved,
DWORD Reserved,
LPWSTR pListenerName, PWTSLISTENERCONFIGW pBuffer, DWORD flag);
typedef BOOL (WINAPI* WTS_CREATE_LISTENER_FN_A)(HANDLE hServer, PVOID pReserved,
DWORD Reserved,
LPSTR pListenerName, PWTSLISTENERCONFIGA pBuffer, DWORD flag);
typedef BOOL (WINAPI * WTS_SET_LISTENER_SECURITY_FN_W)(HANDLE hServer, PVOID pReserved, DWORD Reserved,
LPWSTR pListenerName, SECURITY_INFORMATION SecurityInformation,
PSECURITY_DESCRIPTOR pSecurityDescriptor);
typedef BOOL (WINAPI * WTS_SET_LISTENER_SECURITY_FN_A)(HANDLE hServer, PVOID pReserved, DWORD Reserved,
LPSTR pListenerName, SECURITY_INFORMATION SecurityInformation,
PSECURITY_DESCRIPTOR pSecurityDescriptor);
typedef BOOL (WINAPI* WTS_SET_LISTENER_SECURITY_FN_W)(HANDLE hServer,
PVOID pReserved, DWORD Reserved,
LPWSTR pListenerName, SECURITY_INFORMATION SecurityInformation,
PSECURITY_DESCRIPTOR pSecurityDescriptor);
typedef BOOL (WINAPI* WTS_SET_LISTENER_SECURITY_FN_A)(HANDLE hServer,
PVOID pReserved, DWORD Reserved,
LPSTR pListenerName, SECURITY_INFORMATION SecurityInformation,
PSECURITY_DESCRIPTOR pSecurityDescriptor);
typedef BOOL (WINAPI * WTS_GET_LISTENER_SECURITY_FN_W)(HANDLE hServer, PVOID pReserved, DWORD Reserved,
LPWSTR pListenerName, SECURITY_INFORMATION SecurityInformation,
PSECURITY_DESCRIPTOR pSecurityDescriptor, DWORD nLength, LPDWORD lpnLengthNeeded);
typedef BOOL (WINAPI * WTS_GET_LISTENER_SECURITY_FN_A)(HANDLE hServer, PVOID pReserved, DWORD Reserved,
LPSTR pListenerName, SECURITY_INFORMATION SecurityInformation,
PSECURITY_DESCRIPTOR pSecurityDescriptor, DWORD nLength, LPDWORD lpnLengthNeeded);
typedef BOOL (WINAPI* WTS_GET_LISTENER_SECURITY_FN_W)(HANDLE hServer,
PVOID pReserved, DWORD Reserved,
LPWSTR pListenerName, SECURITY_INFORMATION SecurityInformation,
PSECURITY_DESCRIPTOR pSecurityDescriptor, DWORD nLength,
LPDWORD lpnLengthNeeded);
typedef BOOL (WINAPI* WTS_GET_LISTENER_SECURITY_FN_A)(HANDLE hServer,
PVOID pReserved, DWORD Reserved,
LPSTR pListenerName, SECURITY_INFORMATION SecurityInformation,
PSECURITY_DESCRIPTOR pSecurityDescriptor, DWORD nLength,
LPDWORD lpnLengthNeeded);
typedef BOOL (CDECL * WTS_ENABLE_CHILD_SESSIONS_FN)(BOOL bEnable);
typedef BOOL (CDECL* WTS_ENABLE_CHILD_SESSIONS_FN)(BOOL bEnable);
typedef BOOL (CDECL * WTS_IS_CHILD_SESSIONS_ENABLED_FN)(PBOOL pbEnabled);
typedef BOOL (CDECL* WTS_IS_CHILD_SESSIONS_ENABLED_FN)(PBOOL pbEnabled);
typedef BOOL (CDECL * WTS_GET_CHILD_SESSION_ID_FN)(PULONG pSessionId);
typedef BOOL (CDECL* WTS_GET_CHILD_SESSION_ID_FN)(PULONG pSessionId);
typedef DWORD (WINAPI * WTS_GET_ACTIVE_CONSOLE_SESSION_ID_FN)(void);
typedef DWORD (WINAPI* WTS_GET_ACTIVE_CONSOLE_SESSION_ID_FN)(void);
typedef BOOL (WINAPI * WTS_LOGON_USER_FN)(HANDLE hServer, LPCSTR username,
LPCSTR password, LPCSTR domain);
typedef BOOL (WINAPI* WTS_LOGON_USER_FN)(HANDLE hServer, LPCSTR username,
LPCSTR password, LPCSTR domain);
typedef BOOL (WINAPI * WTS_LOGOFF_USER_FN)(HANDLE hServer);
typedef BOOL (WINAPI* WTS_LOGOFF_USER_FN)(HANDLE hServer);
struct _WtsApiFunctionTable
{
@ -1381,7 +1495,7 @@ struct _WtsApiFunctionTable
typedef struct _WtsApiFunctionTable WtsApiFunctionTable;
typedef WtsApiFunctionTable* PWtsApiFunctionTable;
typedef PWtsApiFunctionTable (CDECL * INIT_WTSAPI_FN)(void);
typedef PWtsApiFunctionTable(CDECL* INIT_WTSAPI_FN)(void);
#ifdef __cplusplus
extern "C" {

View File

@ -56,7 +56,7 @@ struct _wClipboard
/* clipboard data */
UINT32 size;
const void* data;
void* data;
UINT32 formatId;
UINT32 sequenceNumber;

View File

@ -54,7 +54,7 @@
#include "comm.h"
static wLog *_Log = NULL;
static wLog* _Log = NULL;
struct comm_device
{
@ -68,7 +68,7 @@ typedef struct comm_device COMM_DEVICE;
/* FIXME: get a clever data structure, see also io.h functions */
/* _CommDevices is a NULL-terminated array with a maximun of COMM_DEVICE_MAX COMM_DEVICE */
#define COMM_DEVICE_MAX 128
static COMM_DEVICE **_CommDevices = NULL;
static COMM_DEVICE** _CommDevices = NULL;
static CRITICAL_SECTION _CommDevicesLock;
static HANDLE_CREATOR _CommHandleCreator;
@ -77,7 +77,7 @@ static pthread_once_t _CommInitialized = PTHREAD_ONCE_INIT;
static int CommGetFd(HANDLE handle)
{
WINPR_COMM *comm = (WINPR_COMM *)handle;
WINPR_COMM* comm = (WINPR_COMM*)handle;
if (!CommIsHandled(handle))
return -1;
@ -85,7 +85,7 @@ static int CommGetFd(HANDLE handle)
return comm->fd;
}
HANDLE_CREATOR *GetCommHandleCreator(void)
HANDLE_CREATOR* GetCommHandleCreator(void)
{
_CommHandleCreator.IsHandled = IsCommDevice;
_CommHandleCreator.CreateFileA = CommCreateFileA;
@ -95,11 +95,10 @@ HANDLE_CREATOR *GetCommHandleCreator(void)
static void _CommInit(void)
{
/* NB: error management to be done outside of this function */
assert(_Log == NULL);
assert(_CommDevices == NULL);
_CommDevices = (COMM_DEVICE**)calloc(COMM_DEVICE_MAX + 1, sizeof(COMM_DEVICE*));
_CommDevices = (COMM_DEVICE**)calloc(COMM_DEVICE_MAX+1, sizeof(COMM_DEVICE*));
if (!_CommDevices)
return;
@ -130,14 +129,14 @@ static BOOL CommInitialized()
}
void CommLog_Print(int level, char *fmt, ...)
void CommLog_Print(int level, ...)
{
if (!CommInitialized())
return;
va_list ap;
va_start(ap, fmt);
WLog_PrintVA(_Log, level, fmt, ap);
va_start(ap, level);
WLog_PrintVA(_Log, level, ap);
va_end(ap);
}
@ -148,7 +147,6 @@ BOOL BuildCommDCBA(LPCSTR lpDef, LPDCB lpDCB)
return FALSE;
/* TODO: not implemented */
CommLog_Print(WLOG_ERROR, "%s: Not implemented", __FUNCTION__);
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
return FALSE;
@ -160,31 +158,30 @@ BOOL BuildCommDCBW(LPCWSTR lpDef, LPDCB lpDCB)
return FALSE;
/* TODO: not implemented */
CommLog_Print(WLOG_ERROR, "%s: Not implemented", __FUNCTION__);
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
return FALSE;
}
BOOL BuildCommDCBAndTimeoutsA(LPCSTR lpDef, LPDCB lpDCB, LPCOMMTIMEOUTS lpCommTimeouts)
BOOL BuildCommDCBAndTimeoutsA(LPCSTR lpDef, LPDCB lpDCB,
LPCOMMTIMEOUTS lpCommTimeouts)
{
if (!CommInitialized())
return FALSE;
/* TODO: not implemented */
CommLog_Print(WLOG_ERROR, "%s: Not implemented", __FUNCTION__);
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
return FALSE;
}
BOOL BuildCommDCBAndTimeoutsW(LPCWSTR lpDef, LPDCB lpDCB, LPCOMMTIMEOUTS lpCommTimeouts)
BOOL BuildCommDCBAndTimeoutsW(LPCWSTR lpDef, LPDCB lpDCB,
LPCOMMTIMEOUTS lpCommTimeouts)
{
if (!CommInitialized())
return FALSE;
/* TODO: not implemented */
CommLog_Print(WLOG_ERROR, "%s: Not implemented", __FUNCTION__);
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
return FALSE;
@ -196,7 +193,6 @@ BOOL CommConfigDialogA(LPCSTR lpszName, HWND hWnd, LPCOMMCONFIG lpCC)
return FALSE;
/* TODO: not implemented */
CommLog_Print(WLOG_ERROR, "%s: Not implemented", __FUNCTION__);
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
return FALSE;
@ -208,7 +204,6 @@ BOOL CommConfigDialogW(LPCWSTR lpszName, HWND hWnd, LPCOMMCONFIG lpCC)
return FALSE;
/* TODO: not implemented */
CommLog_Print(WLOG_ERROR, "%s: Not implemented", __FUNCTION__);
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
return FALSE;
@ -312,13 +307,14 @@ BOOL GetCommProperties(HANDLE hFile, LPCOMMPROP lpCommProp)
if (!CommInitialized())
return FALSE;
if (!pComm || pComm->Type != HANDLE_TYPE_COMM || !pComm->fd )
if (!pComm || pComm->Type != HANDLE_TYPE_COMM || !pComm->fd)
{
SetLastError(ERROR_INVALID_HANDLE);
return FALSE;
}
if (!CommDeviceIoControl(pComm, IOCTL_SERIAL_GET_PROPERTIES, NULL, 0, lpCommProp, sizeof(COMMPROP), &bytesReturned, NULL))
if (!CommDeviceIoControl(pComm, IOCTL_SERIAL_GET_PROPERTIES, NULL, 0,
lpCommProp, sizeof(COMMPROP), &bytesReturned, NULL))
{
CommLog_Print(WLOG_WARN, "GetCommProperties failure.");
return FALSE;
@ -340,7 +336,7 @@ BOOL GetCommProperties(HANDLE hFile, LPCOMMPROP lpCommProp)
*/
BOOL GetCommState(HANDLE hFile, LPDCB lpDCB)
{
DCB *lpLocalDcb;
DCB* lpLocalDcb;
struct termios currentState;
WINPR_COMM* pComm = (WINPR_COMM*) hFile;
DWORD bytesReturned;
@ -348,7 +344,7 @@ BOOL GetCommState(HANDLE hFile, LPDCB lpDCB)
if (!CommInitialized())
return FALSE;
if (!pComm || pComm->Type != HANDLE_TYPE_COMM || !pComm->fd )
if (!pComm || pComm->Type != HANDLE_TYPE_COMM || !pComm->fd)
{
SetLastError(ERROR_INVALID_HANDLE);
return FALSE;
@ -373,6 +369,7 @@ BOOL GetCommState(HANDLE hFile, LPDCB lpDCB)
}
lpLocalDcb = (DCB*)calloc(1, lpDCB->DCBlength);
if (lpLocalDcb == NULL)
{
SetLastError(ERROR_OUTOFMEMORY);
@ -380,35 +377,40 @@ BOOL GetCommState(HANDLE hFile, LPDCB lpDCB)
}
/* error_handle */
lpLocalDcb->DCBlength = lpDCB->DCBlength;
SERIAL_BAUD_RATE baudRate;
if (!CommDeviceIoControl(pComm, IOCTL_SERIAL_GET_BAUD_RATE, NULL, 0, &baudRate, sizeof(SERIAL_BAUD_RATE), &bytesReturned, NULL))
if (!CommDeviceIoControl(pComm, IOCTL_SERIAL_GET_BAUD_RATE, NULL, 0, &baudRate,
sizeof(SERIAL_BAUD_RATE), &bytesReturned, NULL))
{
CommLog_Print(WLOG_WARN, "GetCommState failure: could not get the baud rate.");
goto error_handle;
}
lpLocalDcb->BaudRate = baudRate.BaudRate;
lpLocalDcb->BaudRate = baudRate.BaudRate;
lpLocalDcb->fBinary = (currentState.c_cflag & ICANON) == 0;
if (!lpLocalDcb->fBinary)
{
CommLog_Print(WLOG_WARN, "Unexpected nonbinary mode, consider to unset the ICANON flag.");
CommLog_Print(WLOG_WARN,
"Unexpected nonbinary mode, consider to unset the ICANON flag.");
}
lpLocalDcb->fParity = (currentState.c_iflag & INPCK) != 0;
lpLocalDcb->fParity = (currentState.c_iflag & INPCK) != 0;
SERIAL_HANDFLOW handflow;
if (!CommDeviceIoControl(pComm, IOCTL_SERIAL_GET_HANDFLOW, NULL, 0, &handflow, sizeof(SERIAL_HANDFLOW), &bytesReturned, NULL))
if (!CommDeviceIoControl(pComm, IOCTL_SERIAL_GET_HANDFLOW, NULL, 0, &handflow,
sizeof(SERIAL_HANDFLOW), &bytesReturned, NULL))
{
CommLog_Print(WLOG_WARN, "GetCommState failure: could not get the handflow settings.");
CommLog_Print(WLOG_WARN,
"GetCommState failure: could not get the handflow settings.");
goto error_handle;
}
lpLocalDcb->fOutxCtsFlow = (handflow.ControlHandShake & SERIAL_CTS_HANDSHAKE) != 0;
lpLocalDcb->fOutxDsrFlow = (handflow.ControlHandShake & SERIAL_DSR_HANDSHAKE) != 0;
lpLocalDcb->fOutxCtsFlow = (handflow.ControlHandShake & SERIAL_CTS_HANDSHAKE) !=
0;
lpLocalDcb->fOutxDsrFlow = (handflow.ControlHandShake & SERIAL_DSR_HANDSHAKE) !=
0;
if (handflow.ControlHandShake & SERIAL_DTR_HANDSHAKE)
{
@ -423,16 +425,13 @@ BOOL GetCommState(HANDLE hFile, LPDCB lpDCB)
lpLocalDcb->fDtrControl = DTR_CONTROL_DISABLE;
}
lpLocalDcb->fDsrSensitivity = (handflow.ControlHandShake & SERIAL_DSR_SENSITIVITY) != 0;
lpLocalDcb->fTXContinueOnXoff = (handflow.FlowReplace & SERIAL_XOFF_CONTINUE) != 0;
lpLocalDcb->fDsrSensitivity = (handflow.ControlHandShake &
SERIAL_DSR_SENSITIVITY) != 0;
lpLocalDcb->fTXContinueOnXoff = (handflow.FlowReplace & SERIAL_XOFF_CONTINUE) !=
0;
lpLocalDcb->fOutX = (handflow.FlowReplace & SERIAL_AUTO_TRANSMIT) != 0;
lpLocalDcb->fInX = (handflow.FlowReplace & SERIAL_AUTO_RECEIVE) != 0;
lpLocalDcb->fErrorChar = (handflow.FlowReplace & SERIAL_ERROR_CHAR) != 0;
lpLocalDcb->fNull = (handflow.FlowReplace & SERIAL_NULL_STRIPPING) != 0;
if (handflow.FlowReplace & SERIAL_RTS_HANDSHAKE)
@ -449,57 +448,45 @@ BOOL GetCommState(HANDLE hFile, LPDCB lpDCB)
}
// FIXME: how to get the RTS_CONTROL_TOGGLE state? Does it match the UART 16750's Autoflow Control Enabled bit in its Modem Control Register (MCR)
lpLocalDcb->fAbortOnError = (handflow.ControlHandShake & SERIAL_ERROR_ABORT) != 0;
lpLocalDcb->fAbortOnError = (handflow.ControlHandShake & SERIAL_ERROR_ABORT) !=
0;
/* lpLocalDcb->fDummy2 not used */
lpLocalDcb->wReserved = 0; /* must be zero */
lpLocalDcb->XonLim = handflow.XonLimit;
lpLocalDcb->XoffLim = handflow.XoffLimit;
SERIAL_LINE_CONTROL lineControl;
if (!CommDeviceIoControl(pComm, IOCTL_SERIAL_GET_LINE_CONTROL, NULL, 0, &lineControl, sizeof(SERIAL_LINE_CONTROL), &bytesReturned, NULL))
if (!CommDeviceIoControl(pComm, IOCTL_SERIAL_GET_LINE_CONTROL, NULL, 0,
&lineControl, sizeof(SERIAL_LINE_CONTROL), &bytesReturned, NULL))
{
CommLog_Print(WLOG_WARN, "GetCommState failure: could not get the control settings.");
CommLog_Print(WLOG_WARN,
"GetCommState failure: could not get the control settings.");
goto error_handle;
}
lpLocalDcb->ByteSize = lineControl.WordLength;
lpLocalDcb->Parity = lineControl.Parity;
lpLocalDcb->StopBits = lineControl.StopBits;
SERIAL_CHARS serialChars;
if (!CommDeviceIoControl(pComm, IOCTL_SERIAL_GET_CHARS, NULL, 0, &serialChars, sizeof(SERIAL_CHARS), &bytesReturned, NULL))
if (!CommDeviceIoControl(pComm, IOCTL_SERIAL_GET_CHARS, NULL, 0, &serialChars,
sizeof(SERIAL_CHARS), &bytesReturned, NULL))
{
CommLog_Print(WLOG_WARN, "GetCommState failure: could not get the serial chars.");
CommLog_Print(WLOG_WARN,
"GetCommState failure: could not get the serial chars.");
goto error_handle;
}
lpLocalDcb->XonChar = serialChars.XonChar;
lpLocalDcb->XoffChar = serialChars.XoffChar;
lpLocalDcb->ErrorChar = serialChars.ErrorChar;
lpLocalDcb->EofChar = serialChars.EofChar;
lpLocalDcb->EvtChar = serialChars.EventChar;
memcpy(lpDCB, lpLocalDcb, lpDCB->DCBlength);
free(lpLocalDcb);
return TRUE;
error_handle:
free(lpLocalDcb);
return FALSE;
}
@ -526,7 +513,7 @@ BOOL SetCommState(HANDLE hFile, LPDCB lpDCB)
if (!CommInitialized())
return FALSE;
if (!pComm || pComm->Type != HANDLE_TYPE_COMM || !pComm->fd )
if (!pComm || pComm->Type != HANDLE_TYPE_COMM || !pComm->fd)
{
SetLastError(ERROR_INVALID_HANDLE);
return FALSE;
@ -540,31 +527,39 @@ BOOL SetCommState(HANDLE hFile, LPDCB lpDCB)
/* NB: did the choice to call ioctls first when available and
then to setup upcomingTermios. Don't mix both stages. */
/** ioctl calls stage **/
SERIAL_BAUD_RATE baudRate;
baudRate.BaudRate = lpDCB->BaudRate;
if (!CommDeviceIoControl(pComm, IOCTL_SERIAL_SET_BAUD_RATE, &baudRate, sizeof(SERIAL_BAUD_RATE), NULL, 0, &bytesReturned, NULL))
if (!CommDeviceIoControl(pComm, IOCTL_SERIAL_SET_BAUD_RATE, &baudRate,
sizeof(SERIAL_BAUD_RATE), NULL, 0, &bytesReturned, NULL))
{
CommLog_Print(WLOG_WARN, "SetCommState failure: could not set the baud rate.");
return FALSE;
}
SERIAL_CHARS serialChars;
if (!CommDeviceIoControl(pComm, IOCTL_SERIAL_GET_CHARS, NULL, 0, &serialChars, sizeof(SERIAL_CHARS), &bytesReturned, NULL)) /* as of today, required for BreakChar */
if (!CommDeviceIoControl(pComm, IOCTL_SERIAL_GET_CHARS, NULL, 0, &serialChars,
sizeof(SERIAL_CHARS), &bytesReturned,
NULL)) /* as of today, required for BreakChar */
{
CommLog_Print(WLOG_WARN, "SetCommState failure: could not get the initial serial chars.");
CommLog_Print(WLOG_WARN,
"SetCommState failure: could not get the initial serial chars.");
return FALSE;
}
serialChars.XonChar = lpDCB->XonChar;
serialChars.XoffChar = lpDCB->XoffChar;
serialChars.ErrorChar = lpDCB->ErrorChar;
serialChars.EofChar = lpDCB->EofChar;
serialChars.EventChar = lpDCB->EvtChar;
if (!CommDeviceIoControl(pComm, IOCTL_SERIAL_SET_CHARS, &serialChars, sizeof(SERIAL_CHARS), NULL, 0, &bytesReturned, NULL))
if (!CommDeviceIoControl(pComm, IOCTL_SERIAL_SET_CHARS, &serialChars,
sizeof(SERIAL_CHARS), NULL, 0, &bytesReturned, NULL))
{
CommLog_Print(WLOG_WARN, "SetCommState failure: could not set the serial chars.");
CommLog_Print(WLOG_WARN,
"SetCommState failure: could not set the serial chars.");
return FALSE;
}
@ -572,13 +567,15 @@ BOOL SetCommState(HANDLE hFile, LPDCB lpDCB)
lineControl.StopBits = lpDCB->StopBits;
lineControl.Parity = lpDCB->Parity;
lineControl.WordLength = lpDCB->ByteSize;
if (!CommDeviceIoControl(pComm, IOCTL_SERIAL_SET_LINE_CONTROL, &lineControl, sizeof(SERIAL_LINE_CONTROL), NULL, 0, &bytesReturned, NULL))
if (!CommDeviceIoControl(pComm, IOCTL_SERIAL_SET_LINE_CONTROL, &lineControl,
sizeof(SERIAL_LINE_CONTROL), NULL, 0, &bytesReturned, NULL))
{
CommLog_Print(WLOG_WARN, "SetCommState failure: could not set the control settings.");
CommLog_Print(WLOG_WARN,
"SetCommState failure: could not set the control settings.");
return FALSE;
}
SERIAL_HANDFLOW handflow;
ZeroMemory(&handflow, sizeof(SERIAL_HANDFLOW));
@ -587,7 +584,6 @@ BOOL SetCommState(HANDLE hFile, LPDCB lpDCB)
handflow.ControlHandShake |= SERIAL_CTS_HANDSHAKE;
}
if (lpDCB->fOutxDsrFlow)
{
handflow.ControlHandShake |= SERIAL_DSR_HANDSHAKE;
@ -608,7 +604,8 @@ BOOL SetCommState(HANDLE hFile, LPDCB lpDCB)
break;
default:
CommLog_Print(WLOG_WARN, "Unexpected fDtrControl value: %d\n", lpDCB->fDtrControl);
CommLog_Print(WLOG_WARN, "Unexpected fDtrControl value: %d\n",
lpDCB->fDtrControl);
return FALSE;
}
@ -662,7 +659,8 @@ BOOL SetCommState(HANDLE hFile, LPDCB lpDCB)
break;
default:
CommLog_Print(WLOG_WARN, "Unexpected fRtsControl value: %d\n", lpDCB->fRtsControl);
CommLog_Print(WLOG_WARN, "Unexpected fRtsControl value: %d\n",
lpDCB->fRtsControl);
return FALSE;
}
@ -672,25 +670,24 @@ BOOL SetCommState(HANDLE hFile, LPDCB lpDCB)
}
/* lpDCB->fDummy2 not used */
/* lpLocalDcb->wReserved ignored */
handflow.XonLimit = lpDCB->XonLim;
handflow.XoffLimit = lpDCB->XoffLim;
if (!CommDeviceIoControl(pComm, IOCTL_SERIAL_SET_HANDFLOW, &handflow, sizeof(SERIAL_HANDFLOW), NULL, 0, &bytesReturned, NULL))
if (!CommDeviceIoControl(pComm, IOCTL_SERIAL_SET_HANDFLOW, &handflow,
sizeof(SERIAL_HANDFLOW), NULL, 0, &bytesReturned, NULL))
{
CommLog_Print(WLOG_WARN, "SetCommState failure: could not set the handflow settings.");
CommLog_Print(WLOG_WARN,
"SetCommState failure: could not set the handflow settings.");
return FALSE;
}
/** upcomingTermios stage **/
ZeroMemory(&upcomingTermios, sizeof(struct termios));
if (tcgetattr(pComm->fd, &upcomingTermios) < 0) /* NB: preserves current settings not directly handled by the Communication Functions */
if (tcgetattr(pComm->fd,
&upcomingTermios) <
0) /* NB: preserves current settings not directly handled by the Communication Functions */
{
SetLastError(ERROR_IO_DEVICE);
return FALSE;
@ -703,7 +700,8 @@ BOOL SetCommState(HANDLE hFile, LPDCB lpDCB)
else
{
upcomingTermios.c_lflag |= ICANON;
CommLog_Print(WLOG_WARN, "Unexpected nonbinary mode, consider to unset the ICANON flag.");
CommLog_Print(WLOG_WARN,
"Unexpected nonbinary mode, consider to unset the ICANON flag.");
}
if (lpDCB->fParity)
@ -715,7 +713,6 @@ BOOL SetCommState(HANDLE hFile, LPDCB lpDCB)
upcomingTermios.c_iflag &= ~INPCK;
}
/* http://msdn.microsoft.com/en-us/library/windows/desktop/aa363423%28v=vs.85%29.aspx
*
* The SetCommState function reconfigures the communications
@ -733,7 +730,6 @@ BOOL SetCommState(HANDLE hFile, LPDCB lpDCB)
return FALSE;
}
return TRUE;
}
@ -749,7 +745,7 @@ BOOL GetCommTimeouts(HANDLE hFile, LPCOMMTIMEOUTS lpCommTimeouts)
if (!CommInitialized())
return FALSE;
if (!pComm || pComm->Type != HANDLE_TYPE_COMM || !pComm->fd )
if (!pComm || pComm->Type != HANDLE_TYPE_COMM || !pComm->fd)
{
SetLastError(ERROR_INVALID_HANDLE);
return FALSE;
@ -757,7 +753,8 @@ BOOL GetCommTimeouts(HANDLE hFile, LPCOMMTIMEOUTS lpCommTimeouts)
/* as of today, SERIAL_TIMEOUTS and COMMTIMEOUTS structures are identical */
if (!CommDeviceIoControl(pComm, IOCTL_SERIAL_GET_TIMEOUTS, NULL, 0, lpCommTimeouts, sizeof(COMMTIMEOUTS), &bytesReturned, NULL))
if (!CommDeviceIoControl(pComm, IOCTL_SERIAL_GET_TIMEOUTS, NULL, 0,
lpCommTimeouts, sizeof(COMMTIMEOUTS), &bytesReturned, NULL))
{
CommLog_Print(WLOG_WARN, "GetCommTimeouts failure.");
return FALSE;
@ -779,7 +776,7 @@ BOOL SetCommTimeouts(HANDLE hFile, LPCOMMTIMEOUTS lpCommTimeouts)
if (!CommInitialized())
return FALSE;
if (!pComm || pComm->Type != HANDLE_TYPE_COMM || !pComm->fd )
if (!pComm || pComm->Type != HANDLE_TYPE_COMM || !pComm->fd)
{
SetLastError(ERROR_INVALID_HANDLE);
return FALSE;
@ -787,7 +784,8 @@ BOOL SetCommTimeouts(HANDLE hFile, LPCOMMTIMEOUTS lpCommTimeouts)
/* as of today, SERIAL_TIMEOUTS and COMMTIMEOUTS structures are identical */
if (!CommDeviceIoControl(pComm, IOCTL_SERIAL_SET_TIMEOUTS, lpCommTimeouts, sizeof(COMMTIMEOUTS), NULL, 0, &bytesReturned, NULL))
if (!CommDeviceIoControl(pComm, IOCTL_SERIAL_SET_TIMEOUTS, lpCommTimeouts,
sizeof(COMMTIMEOUTS), NULL, 0, &bytesReturned, NULL))
{
CommLog_Print(WLOG_WARN, "SetCommTimeouts failure.");
return FALSE;
@ -802,19 +800,18 @@ BOOL GetDefaultCommConfigA(LPCSTR lpszName, LPCOMMCONFIG lpCC, LPDWORD lpdwSize)
return FALSE;
/* TODO: not implemented */
CommLog_Print(WLOG_ERROR, "%s: Not implemented", __FUNCTION__);
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
return FALSE;
}
BOOL GetDefaultCommConfigW(LPCWSTR lpszName, LPCOMMCONFIG lpCC, LPDWORD lpdwSize)
BOOL GetDefaultCommConfigW(LPCWSTR lpszName, LPCOMMCONFIG lpCC,
LPDWORD lpdwSize)
{
if (!CommInitialized())
return FALSE;
/* TODO: not implemented */
CommLog_Print(WLOG_ERROR, "%s: Not implemented", __FUNCTION__);
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
return FALSE;
@ -826,7 +823,6 @@ BOOL SetDefaultCommConfigA(LPCSTR lpszName, LPCOMMCONFIG lpCC, DWORD dwSize)
return FALSE;
/* TODO: not implemented */
CommLog_Print(WLOG_ERROR, "%s: Not implemented", __FUNCTION__);
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
return FALSE;
@ -838,7 +834,6 @@ BOOL SetDefaultCommConfigW(LPCWSTR lpszName, LPCOMMCONFIG lpCC, DWORD dwSize)
return FALSE;
/* TODO: not implemented */
CommLog_Print(WLOG_ERROR, "%s: Not implemented", __FUNCTION__);
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
return FALSE;
@ -904,13 +899,14 @@ BOOL PurgeComm(HANDLE hFile, DWORD dwFlags)
if (!CommInitialized())
return FALSE;
if (!pComm || pComm->Type != HANDLE_TYPE_COMM || !pComm->fd )
if (!pComm || pComm->Type != HANDLE_TYPE_COMM || !pComm->fd)
{
SetLastError(ERROR_INVALID_HANDLE);
return FALSE;
}
if (!CommDeviceIoControl(pComm, IOCTL_SERIAL_PURGE, &dwFlags, sizeof(DWORD), NULL, 0, &bytesReturned, NULL))
if (!CommDeviceIoControl(pComm, IOCTL_SERIAL_PURGE, &dwFlags, sizeof(DWORD),
NULL, 0, &bytesReturned, NULL))
{
CommLog_Print(WLOG_WARN, "PurgeComm failure.");
return FALSE;
@ -929,7 +925,7 @@ BOOL SetupComm(HANDLE hFile, DWORD dwInQueue, DWORD dwOutQueue)
if (!CommInitialized())
return FALSE;
if (!pComm || pComm->Type != HANDLE_TYPE_COMM || !pComm->fd )
if (!pComm || pComm->Type != HANDLE_TYPE_COMM || !pComm->fd)
{
SetLastError(ERROR_INVALID_HANDLE);
return FALSE;
@ -938,7 +934,8 @@ BOOL SetupComm(HANDLE hFile, DWORD dwInQueue, DWORD dwOutQueue)
queueSize.InSize = dwInQueue;
queueSize.OutSize = dwOutQueue;
if (!CommDeviceIoControl(pComm, IOCTL_SERIAL_SET_QUEUE_SIZE, &queueSize, sizeof(SERIAL_QUEUE_SIZE), NULL, 0, &bytesReturned, NULL))
if (!CommDeviceIoControl(pComm, IOCTL_SERIAL_SET_QUEUE_SIZE, &queueSize,
sizeof(SERIAL_QUEUE_SIZE), NULL, 0, &bytesReturned, NULL))
{
CommLog_Print(WLOG_WARN, "SetCommTimeouts failure.");
return FALSE;
@ -1009,9 +1006,10 @@ static BOOL _IsReservedCommDeviceName(LPCTSTR lpName)
return FALSE;
/* Serial ports, COM1-9 */
for (i=1; i<10; i++)
for (i = 1; i < 10; i++)
{
TCHAR genericName[5];
if (_stprintf_s(genericName, 5, _T("COM%d"), i) < 0)
{
return FALSE;
@ -1022,9 +1020,10 @@ static BOOL _IsReservedCommDeviceName(LPCTSTR lpName)
}
/* Parallel ports, LPT1-9 */
for (i=1; i<10; i++)
for (i = 1; i < 10; i++)
{
TCHAR genericName[5];
if (_stprintf_s(genericName, 5, _T("LPT%d"), i) < 0)
{
return FALSE;
@ -1035,7 +1034,6 @@ static BOOL _IsReservedCommDeviceName(LPCTSTR lpName)
}
/* FIXME: what about PRN ? */
return FALSE;
}
@ -1049,7 +1047,8 @@ static BOOL _IsReservedCommDeviceName(LPCTSTR lpName)
* ERROR_OUTOFMEMORY was not possible to get mappings.
* ERROR_INVALID_DATA was not possible to add the device.
*/
BOOL DefineCommDevice(/* DWORD dwFlags,*/ LPCTSTR lpDeviceName, LPCTSTR lpTargetPath)
BOOL DefineCommDevice(/* DWORD dwFlags,*/ LPCTSTR lpDeviceName,
LPCTSTR lpTargetPath)
{
int i = 0;
LPTSTR storedDeviceName = NULL;
@ -1076,6 +1075,7 @@ BOOL DefineCommDevice(/* DWORD dwFlags,*/ LPCTSTR lpDeviceName, LPCTSTR lpTarget
}
storedDeviceName = _tcsdup(lpDeviceName);
if (storedDeviceName == NULL)
{
SetLastError(ERROR_OUTOFMEMORY);
@ -1083,13 +1083,14 @@ BOOL DefineCommDevice(/* DWORD dwFlags,*/ LPCTSTR lpDeviceName, LPCTSTR lpTarget
}
storedTargetPath = _tcsdup(lpTargetPath);
if (storedTargetPath == NULL)
{
SetLastError(ERROR_OUTOFMEMORY);
goto error_handle;
}
for (i=0; i<COMM_DEVICE_MAX; i++)
for (i = 0; i < COMM_DEVICE_MAX; i++)
{
if (_CommDevices[i] != NULL)
{
@ -1100,7 +1101,6 @@ BOOL DefineCommDevice(/* DWORD dwFlags,*/ LPCTSTR lpDeviceName, LPCTSTR lpTarget
free(_CommDevices[i]->path);
_CommDevices[i]->name = storedDeviceName;
_CommDevices[i]->path = storedTargetPath;
break;
}
}
@ -1108,6 +1108,7 @@ BOOL DefineCommDevice(/* DWORD dwFlags,*/ LPCTSTR lpDeviceName, LPCTSTR lpTarget
{
/* new emplacement */
_CommDevices[i] = (COMM_DEVICE*)calloc(1, sizeof(COMM_DEVICE));
if (_CommDevices[i] == NULL)
{
SetLastError(ERROR_OUTOFMEMORY);
@ -1128,12 +1129,9 @@ BOOL DefineCommDevice(/* DWORD dwFlags,*/ LPCTSTR lpDeviceName, LPCTSTR lpTarget
LeaveCriticalSection(&_CommDevicesLock);
return TRUE;
error_handle:
free(storedDeviceName);
free(storedTargetPath);
LeaveCriticalSection(&_CommDevicesLock);
return FALSE;
}
@ -1159,7 +1157,6 @@ DWORD QueryCommDevice(LPCTSTR lpDeviceName, LPTSTR lpTargetPath, DWORD ucchMax)
{
int i;
LPTSTR storedTargetPath;
SetLastError(ERROR_SUCCESS);
if (!CommInitialized())
@ -1178,9 +1175,9 @@ DWORD QueryCommDevice(LPCTSTR lpDeviceName, LPTSTR lpTargetPath, DWORD ucchMax)
}
EnterCriticalSection(&_CommDevicesLock);
storedTargetPath = NULL;
for (i=0; i<COMM_DEVICE_MAX; i++)
for (i = 0; i < COMM_DEVICE_MAX; i++)
{
if (_CommDevices[i] != NULL)
{
@ -1212,7 +1209,6 @@ DWORD QueryCommDevice(LPCTSTR lpDeviceName, LPTSTR lpTargetPath, DWORD ucchMax)
_tcscpy(lpTargetPath, storedTargetPath);
lpTargetPath[_tcslen(storedTargetPath) + 1] = '\0'; /* 2nd final '\0' */
return _tcslen(lpTargetPath) + 2;
}
@ -1257,11 +1253,12 @@ void _comm_setServerSerialDriver(HANDLE hComm, SERIAL_DRIVER_ID driverId)
pComm->serverSerialDriverId = driverId;
}
static HANDLE_OPS ops = {
CommIsHandled,
CommCloseHandle,
CommGetFd,
NULL /* CleanupHandle */
static HANDLE_OPS ops =
{
CommIsHandled,
CommCloseHandle,
CommGetFd,
NULL /* CleanupHandle */
};
@ -1290,8 +1287,9 @@ static HANDLE_OPS ops = {
*
* @return INVALID_HANDLE_VALUE on error.
*/
HANDLE CommCreateFileA(LPCSTR lpDeviceName, DWORD dwDesiredAccess, DWORD dwShareMode, LPSECURITY_ATTRIBUTES lpSecurityAttributes,
DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, HANDLE hTemplateFile)
HANDLE CommCreateFileA(LPCSTR lpDeviceName, DWORD dwDesiredAccess,
DWORD dwShareMode, LPSECURITY_ATTRIBUTES lpSecurityAttributes,
DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, HANDLE hTemplateFile)
{
CHAR devicePath[MAX_PATH];
struct stat deviceStat;
@ -1300,10 +1298,11 @@ HANDLE CommCreateFileA(LPCSTR lpDeviceName, DWORD dwDesiredAccess, DWORD dwShare
if (!CommInitialized())
return INVALID_HANDLE_VALUE;
if (dwDesiredAccess != (GENERIC_READ | GENERIC_WRITE))
{
CommLog_Print(WLOG_WARN, "unexpected access to the device: 0x%lX", dwDesiredAccess);
CommLog_Print(WLOG_WARN, "unexpected access to the device: 0x%lX",
dwDesiredAccess);
}
if (dwShareMode != 0)
@ -1313,11 +1312,12 @@ HANDLE CommCreateFileA(LPCSTR lpDeviceName, DWORD dwDesiredAccess, DWORD dwShare
}
/* TODO: Prevents other processes from opening a file or
* device if they request delete, read, or write access. */
* device if they request delete, read, or write access. */
if (lpSecurityAttributes != NULL)
{
CommLog_Print(WLOG_WARN, "unexpected security attributes, nLength=%lu", lpSecurityAttributes->nLength);
CommLog_Print(WLOG_WARN, "unexpected security attributes, nLength=%lu",
lpSecurityAttributes->nLength);
}
if (dwCreationDisposition != OPEN_EXISTING)
@ -1348,7 +1348,8 @@ HANDLE CommCreateFileA(LPCSTR lpDeviceName, DWORD dwDesiredAccess, DWORD dwShare
if (dwFlagsAndAttributes != 0)
{
CommLog_Print(WLOG_WARN, "unexpected flags and attributes: 0x%lX", dwFlagsAndAttributes);
CommLog_Print(WLOG_WARN, "unexpected flags and attributes: 0x%lX",
dwFlagsAndAttributes);
}
if (hTemplateFile != NULL)
@ -1358,6 +1359,7 @@ HANDLE CommCreateFileA(LPCSTR lpDeviceName, DWORD dwDesiredAccess, DWORD dwShare
}
pComm = (WINPR_COMM*) calloc(1, sizeof(WINPR_COMM));
if (pComm == NULL)
{
SetLastError(ERROR_OUTOFMEMORY);
@ -1365,12 +1367,10 @@ HANDLE CommCreateFileA(LPCSTR lpDeviceName, DWORD dwDesiredAccess, DWORD dwShare
}
WINPR_HANDLE_SET_TYPE_AND_MODE(pComm, HANDLE_TYPE_COMM, WINPR_FD_READ);
pComm->ops = &ops;
/* error_handle */
pComm->fd = open(devicePath, O_RDWR | O_NOCTTY | O_NONBLOCK);
if (pComm->fd < 0)
{
CommLog_Print(WLOG_WARN, "failed to open device %s", devicePath);
@ -1379,6 +1379,7 @@ HANDLE CommCreateFileA(LPCSTR lpDeviceName, DWORD dwDesiredAccess, DWORD dwShare
}
pComm->fd_read = open(devicePath, O_RDONLY | O_NOCTTY | O_NONBLOCK);
if (pComm->fd_read < 0)
{
CommLog_Print(WLOG_WARN, "failed to open fd_read, device: %s", devicePath);
@ -1386,17 +1387,20 @@ HANDLE CommCreateFileA(LPCSTR lpDeviceName, DWORD dwDesiredAccess, DWORD dwShare
goto error_handle;
}
pComm->fd_read_event = eventfd(0, EFD_NONBLOCK); /* EFD_NONBLOCK required because a read() is not always expected */
pComm->fd_read_event = eventfd(0,
EFD_NONBLOCK); /* EFD_NONBLOCK required because a read() is not always expected */
if (pComm->fd_read_event < 0)
{
CommLog_Print(WLOG_WARN, "failed to open fd_read_event, device: %s", devicePath);
CommLog_Print(WLOG_WARN, "failed to open fd_read_event, device: %s",
devicePath);
SetLastError(ERROR_BAD_DEVICE);
goto error_handle;
}
InitializeCriticalSection(&pComm->ReadLock);
pComm->fd_write = open(devicePath, O_WRONLY | O_NOCTTY | O_NONBLOCK);
if (pComm->fd_write < 0)
{
CommLog_Print(WLOG_WARN, "failed to open fd_write, device: %s", devicePath);
@ -1404,60 +1408,59 @@ HANDLE CommCreateFileA(LPCSTR lpDeviceName, DWORD dwDesiredAccess, DWORD dwShare
goto error_handle;
}
pComm->fd_write_event = eventfd(0, EFD_NONBLOCK); /* EFD_NONBLOCK required because a read() is not always expected */
pComm->fd_write_event = eventfd(0,
EFD_NONBLOCK); /* EFD_NONBLOCK required because a read() is not always expected */
if (pComm->fd_write_event < 0)
{
CommLog_Print(WLOG_WARN, "failed to open fd_write_event, device: %s", devicePath);
CommLog_Print(WLOG_WARN, "failed to open fd_write_event, device: %s",
devicePath);
SetLastError(ERROR_BAD_DEVICE);
goto error_handle;
}
InitializeCriticalSection(&pComm->WriteLock);
/* can also be setup later on with _comm_setServerSerialDriver() */
pComm->serverSerialDriverId = SerialDriverUnknown;
InitializeCriticalSection(&pComm->EventsLock);
if (ioctl(pComm->fd, TIOCGICOUNT, &(pComm->counters)) < 0)
{
CommLog_Print(WLOG_WARN, "TIOCGICOUNT ioctl failed, errno=[%d] %s.", errno, strerror(errno));
CommLog_Print(WLOG_WARN, "TIOCGICOUNT ioctl failed, errno=[%d] %s.", errno,
strerror(errno));
CommLog_Print(WLOG_WARN, "could not read counters.");
/* could not initialize counters but keep on.
/* could not initialize counters but keep on.
*
* Not all drivers, especially for USB to serial
* adapters (e.g. those based on pl2303), does support
* this call.
*/
ZeroMemory(&(pComm->counters), sizeof(struct serial_icounter_struct));
}
/* The binary/raw mode is required for the redirection but
* only flags that are not handle somewhere-else, except
* ICANON, are forced here. */
ZeroMemory(&upcomingTermios, sizeof(struct termios));
if (tcgetattr(pComm->fd, &upcomingTermios) < 0)
{
SetLastError(ERROR_IO_DEVICE);
goto error_handle;
}
upcomingTermios.c_iflag &= ~(/*IGNBRK |*/ BRKINT | PARMRK | ISTRIP | INLCR | IGNCR | ICRNL /*| IXON*/);
upcomingTermios.c_iflag &= ~(/*IGNBRK |*/ BRKINT | PARMRK | ISTRIP | INLCR |
IGNCR | ICRNL /*| IXON*/);
upcomingTermios.c_oflag = 0; /* <=> &= ~OPOST */
upcomingTermios.c_lflag = 0; /* <=> &= ~(ECHO | ECHONL | ICANON | ISIG | IEXTEN); */
upcomingTermios.c_lflag =
0; /* <=> &= ~(ECHO | ECHONL | ICANON | ISIG | IEXTEN); */
/* upcomingTermios.c_cflag &= ~(CSIZE | PARENB); */
/* upcomingTermios.c_cflag |= CS8; */
/* About missing flags recommended by termios(3):
*
* IGNBRK and IXON, see: IOCTL_SERIAL_SET_HANDFLOW
* CSIZE, PARENB and CS8, see: IOCTL_SERIAL_SET_LINE_CONTROL
*/
/* a few more settings required for the redirection */
upcomingTermios.c_cflag |= CLOCAL | CREAD;
@ -1468,29 +1471,28 @@ HANDLE CommCreateFileA(LPCSTR lpDeviceName, DWORD dwDesiredAccess, DWORD dwShare
}
return (HANDLE)pComm;
error_handle:
error_handle:
if (pComm != NULL)
{
CloseHandle(pComm);
}
return INVALID_HANDLE_VALUE;
}
BOOL CommIsHandled(HANDLE handle)
{
WINPR_COMM *pComm;
WINPR_COMM* pComm;
if (!CommInitialized())
return FALSE;
pComm = (WINPR_COMM*)handle;
if (!pComm || (pComm->Type != HANDLE_TYPE_COMM) || (pComm == INVALID_HANDLE_VALUE))
if (!pComm || (pComm->Type != HANDLE_TYPE_COMM)
|| (pComm == INVALID_HANDLE_VALUE))
{
SetLastError(ERROR_INVALID_HANDLE);
return FALSE;
@ -1501,7 +1503,7 @@ BOOL CommIsHandled(HANDLE handle)
BOOL CommCloseHandle(HANDLE handle)
{
WINPR_COMM *pComm;
WINPR_COMM* pComm;
if (!CommInitialized())
return FALSE;
@ -1520,7 +1522,8 @@ BOOL CommCloseHandle(HANDLE handle)
DWORD BytesReturned = 0;
/* ensures to gracefully stop the WAIT_ON_MASK's loop */
if (!CommDeviceIoControl(handle, IOCTL_SERIAL_SET_WAIT_MASK, &WaitMask, sizeof(ULONG), NULL, 0, &BytesReturned, NULL))
if (!CommDeviceIoControl(handle, IOCTL_SERIAL_SET_WAIT_MASK, &WaitMask,
sizeof(ULONG), NULL, 0, &BytesReturned, NULL))
{
CommLog_Print(WLOG_WARN, "failure to WAIT_ON_MASK's loop!");
}
@ -1546,7 +1549,6 @@ BOOL CommCloseHandle(HANDLE handle)
close(pComm->fd_read_event);
free(pComm);
return TRUE;
}

View File

@ -63,7 +63,8 @@ struct winpr_comm
COMMTIMEOUTS timeouts;
CRITICAL_SECTION EventsLock; /* protects counters, WaitEventMask and PendingEvents */
CRITICAL_SECTION
EventsLock; /* protects counters, WaitEventMask and PendingEvents */
struct serial_icounter_struct counters;
ULONG WaitEventMask;
ULONG PendingEvents;
@ -93,7 +94,7 @@ typedef struct winpr_comm WINPR_COMM;
#define FREERDP_PURGE_RXABORT 0x00000002 /* abort pending reception */
void CommLog_Print(int wlog_level, char *fmt, ...);
void CommLog_Print(int wlog_level, ...);
BOOL CommIsHandled(HANDLE handle);
BOOL CommCloseHandle(HANDLE handle);

View File

@ -41,8 +41,8 @@ BOOL _comm_set_permissive(HANDLE hDevice, BOOL permissive)
if (hDevice == INVALID_HANDLE_VALUE)
{
SetLastError(ERROR_INVALID_HANDLE);
return FALSE;
}
return FALSE;
}
if (!pComm || pComm->Type != HANDLE_TYPE_COMM)
{
@ -67,7 +67,7 @@ static UCHAR _vtime(ULONG Ti)
else if (Ti > 25500)
return 255; /* 0xFF */
else
return Ti/100;
return Ti / 100;
}
@ -81,26 +81,25 @@ static UCHAR _vtime(ULONG Ti)
* ERROR_BAD_DEVICE
*/
BOOL CommReadFile(HANDLE hDevice, LPVOID lpBuffer, DWORD nNumberOfBytesToRead,
LPDWORD lpNumberOfBytesRead, LPOVERLAPPED lpOverlapped)
LPDWORD lpNumberOfBytesRead, LPOVERLAPPED lpOverlapped)
{
WINPR_COMM* pComm = (WINPR_COMM*) hDevice;
int biggestFd = -1;
fd_set read_set;
int nbFds;
COMMTIMEOUTS *pTimeouts;
COMMTIMEOUTS* pTimeouts;
UCHAR vmin = 0;
UCHAR vtime = 0;
ULONGLONG Tmax = 0;
struct timeval tmaxTimeout, *pTmaxTimeout;
struct termios currentTermios;
EnterCriticalSection(&pComm->ReadLock); /* KISSer by the function's beginning */
if (hDevice == INVALID_HANDLE_VALUE)
{
SetLastError(ERROR_INVALID_HANDLE);
goto return_false;
}
goto return_false;
}
if (!pComm || pComm->Type != HANDLE_TYPE_COMM)
{
@ -116,7 +115,8 @@ BOOL CommReadFile(HANDLE hDevice, LPVOID lpBuffer, DWORD nNumberOfBytesToRead,
if (lpNumberOfBytesRead == NULL)
{
SetLastError(ERROR_INVALID_PARAMETER); /* since we doesn't suppport lpOverlapped != NULL */
SetLastError(
ERROR_INVALID_PARAMETER); /* since we doesn't suppport lpOverlapped != NULL */
goto return_false;
}
@ -135,7 +135,8 @@ BOOL CommReadFile(HANDLE hDevice, LPVOID lpBuffer, DWORD nNumberOfBytesToRead,
if (currentTermios.c_lflag & ICANON)
{
CommLog_Print(WLOG_WARN, "Canonical mode not supported"); /* the timeout could not be set */
CommLog_Print(WLOG_WARN,
"Canonical mode not supported"); /* the timeout could not be set */
SetLastError(ERROR_NOT_SUPPORTED);
goto return_false;
}
@ -145,30 +146,31 @@ BOOL CommReadFile(HANDLE hDevice, LPVOID lpBuffer, DWORD nNumberOfBytesToRead,
*
* ReadIntervalTimeout | ReadTotalTimeoutMultiplier | ReadTotalTimeoutConstant | VMIN | VTIME | TMAX |
* 0 | 0 | 0 | N | 0 | INDEF | Blocks for N bytes available.
* 0< Ti <MAXULONG | 0 | 0 | N | Ti | INDEF | Blocks on first byte, then use Ti between bytes.
* 0< Ti <MAXULONG | 0 | 0 | N | Ti | INDEF | Blocks on first byte, then use Ti between bytes.
* MAXULONG | 0 | 0 | 0 | 0 | 0 | Returns immediately with bytes available (don't block)
* MAXULONG | MAXULONG | 0< Tc <MAXULONG | N | 0 | Tc | Blocks on first byte during Tc or returns immediately whith bytes available
* MAXULONG | m | MAXULONG | | Invalid
* 0 | m | 0< Tc <MAXULONG | N | 0 | Tmax | Blocks on first byte during Tmax or returns immediately whith bytes available
* 0< Ti <MAXULONG | m | 0< Tc <MAXULONG | N | Ti | Tmax | Blocks on first byte, then use Ti between bytes. Tmax is used for the whole system call.
*/
/* NB: timeouts are in milliseconds, VTIME are in deciseconds and is an unsigned char */
/* FIXME: double check whether open(pComm->fd_read_event, O_NONBLOCK) doesn't conflict with above use cases */
pTimeouts = &(pComm->timeouts);
if ((pTimeouts->ReadIntervalTimeout == MAXULONG) && (pTimeouts->ReadTotalTimeoutConstant == MAXULONG))
if ((pTimeouts->ReadIntervalTimeout == MAXULONG)
&& (pTimeouts->ReadTotalTimeoutConstant == MAXULONG))
{
CommLog_Print(WLOG_WARN, "ReadIntervalTimeout and ReadTotalTimeoutConstant cannot be both set to MAXULONG");
CommLog_Print(WLOG_WARN,
"ReadIntervalTimeout and ReadTotalTimeoutConstant cannot be both set to MAXULONG");
SetLastError(ERROR_INVALID_PARAMETER);
goto return_false;
}
/* VMIN */
if ((pTimeouts->ReadIntervalTimeout == MAXULONG) && (pTimeouts->ReadTotalTimeoutMultiplier == 0) && (pTimeouts->ReadTotalTimeoutConstant == 0))
if ((pTimeouts->ReadIntervalTimeout == MAXULONG)
&& (pTimeouts->ReadTotalTimeoutMultiplier == 0)
&& (pTimeouts->ReadTotalTimeoutConstant == 0))
{
vmin = 0;
}
@ -176,28 +178,26 @@ BOOL CommReadFile(HANDLE hDevice, LPVOID lpBuffer, DWORD nNumberOfBytesToRead,
{
/* N */
/* vmin = nNumberOfBytesToRead < 256 ? nNumberOfBytesToRead : 255;*/ /* 0xFF */
/* NB: we might wait endlessly with vmin=N, prefer to
* force vmin=1 and return with bytes
* available. FIXME: is a feature disarded here? */
vmin = 1;
}
/* VTIME */
if ((pTimeouts->ReadIntervalTimeout > 0) && (pTimeouts->ReadIntervalTimeout < MAXULONG))
if ((pTimeouts->ReadIntervalTimeout > 0)
&& (pTimeouts->ReadIntervalTimeout < MAXULONG))
{
/* Ti */
vtime = _vtime(pTimeouts->ReadIntervalTimeout);
}
/* TMAX */
pTmaxTimeout = &tmaxTimeout;
pTmaxTimeout = &tmaxTimeout;
if ((pTimeouts->ReadIntervalTimeout == MAXULONG) && (pTimeouts->ReadTotalTimeoutMultiplier == MAXULONG))
if ((pTimeouts->ReadIntervalTimeout == MAXULONG)
&& (pTimeouts->ReadTotalTimeoutMultiplier == MAXULONG))
{
/* Tc */
Tmax = pTimeouts->ReadTotalTimeoutConstant;
@ -205,60 +205,64 @@ BOOL CommReadFile(HANDLE hDevice, LPVOID lpBuffer, DWORD nNumberOfBytesToRead,
else
{
/* Tmax */
Tmax = nNumberOfBytesToRead * pTimeouts->ReadTotalTimeoutMultiplier + pTimeouts->ReadTotalTimeoutConstant;
Tmax = nNumberOfBytesToRead * pTimeouts->ReadTotalTimeoutMultiplier +
pTimeouts->ReadTotalTimeoutConstant;
/* INDEFinitely */
if((Tmax == 0) && (pTimeouts->ReadIntervalTimeout < MAXULONG) && (pTimeouts->ReadTotalTimeoutMultiplier == 0))
if ((Tmax == 0) && (pTimeouts->ReadIntervalTimeout < MAXULONG)
&& (pTimeouts->ReadTotalTimeoutMultiplier == 0))
pTmaxTimeout = NULL;
}
if ((currentTermios.c_cc[VMIN] != vmin) || (currentTermios.c_cc[VTIME] != vtime))
if ((currentTermios.c_cc[VMIN] != vmin)
|| (currentTermios.c_cc[VTIME] != vtime))
{
currentTermios.c_cc[VMIN] = vmin;
currentTermios.c_cc[VTIME] = vtime;
if (tcsetattr(pComm->fd, TCSANOW, &currentTermios) < 0)
{
CommLog_Print(WLOG_WARN, "CommReadFile failure, could not apply new timeout values: VMIN=%u, VTIME=%u", vmin, vtime);
CommLog_Print(WLOG_WARN,
"CommReadFile failure, could not apply new timeout values: VMIN=%u, VTIME=%u",
vmin, vtime);
SetLastError(ERROR_IO_DEVICE);
goto return_false;
}
}
/* wait indefinitely if pTmaxTimeout is NULL */
/* wait indefinitely if pTmaxTimeout is NULL */
if(pTmaxTimeout != NULL)
if (pTmaxTimeout != NULL)
{
ZeroMemory(pTmaxTimeout, sizeof(struct timeval));
if (Tmax > 0) /* return immdiately if Tmax == 0 */
{
pTmaxTimeout->tv_sec = Tmax / 1000; /* s */
pTmaxTimeout->tv_usec = (Tmax % 1000) * 1000; /* us */
}
}
ZeroMemory(pTmaxTimeout, sizeof(struct timeval));
if (Tmax > 0) /* return immdiately if Tmax == 0 */
{
pTmaxTimeout->tv_sec = Tmax / 1000; /* s */
pTmaxTimeout->tv_usec = (Tmax % 1000) * 1000; /* us */
}
}
/* FIXME: had expected eventfd_write() to return EAGAIN when
* there is no eventfd_read() but this not the case. */
/* discard a possible and no more relevant event */
eventfd_read(pComm->fd_read_event, NULL);
biggestFd = pComm->fd_read;
if (pComm->fd_read_event > biggestFd)
biggestFd = pComm->fd_read_event;
FD_ZERO(&read_set);
assert(pComm->fd_read_event < FD_SETSIZE);
assert(pComm->fd_read < FD_SETSIZE);
FD_SET(pComm->fd_read_event, &read_set);
FD_SET(pComm->fd_read, &read_set);
nbFds = select(biggestFd + 1, &read_set, NULL, NULL, pTmaxTimeout);
nbFds = select(biggestFd+1, &read_set, NULL, NULL, pTmaxTimeout);
if (nbFds < 0)
{
CommLog_Print(WLOG_WARN, "select() failure, errno=[%d] %s\n", errno, strerror(errno));
CommLog_Print(WLOG_WARN, "select() failure, errno=[%d] %s\n", errno,
strerror(errno));
SetLastError(ERROR_IO_DEVICE);
goto return_false;
}
@ -266,12 +270,10 @@ BOOL CommReadFile(HANDLE hDevice, LPVOID lpBuffer, DWORD nNumberOfBytesToRead,
if (nbFds == 0)
{
/* timeout */
SetLastError(ERROR_TIMEOUT);
goto return_false;
}
/* read_set */
if (FD_ISSET(pComm->fd_read_event, &read_set))
@ -287,7 +289,9 @@ BOOL CommReadFile(HANDLE hDevice, LPVOID lpBuffer, DWORD nNumberOfBytesToRead,
}
else
{
CommLog_Print(WLOG_WARN, "unexpected error on reading fd_read_event, errno=[%d] %s\n", errno, strerror(errno));
CommLog_Print(WLOG_WARN,
"unexpected error on reading fd_read_event, errno=[%d] %s\n", errno,
strerror(errno));
/* FIXME: goto return_false ? */
}
@ -303,18 +307,21 @@ BOOL CommReadFile(HANDLE hDevice, LPVOID lpBuffer, DWORD nNumberOfBytesToRead,
assert(event == FREERDP_PURGE_RXABORT); /* no other expected event so far */
}
if (FD_ISSET(pComm->fd_read, &read_set))
{
ssize_t nbRead = 0;
nbRead = read(pComm->fd_read, lpBuffer, nNumberOfBytesToRead);
if (nbRead < 0)
{
CommLog_Print(WLOG_WARN, "CommReadFile failed, ReadIntervalTimeout=%lu, ReadTotalTimeoutMultiplier=%lu, ReadTotalTimeoutConstant=%lu VMIN=%u, VTIME=%u",
pTimeouts->ReadIntervalTimeout, pTimeouts->ReadTotalTimeoutMultiplier, pTimeouts->ReadTotalTimeoutConstant,
currentTermios.c_cc[VMIN], currentTermios.c_cc[VTIME]);
CommLog_Print(WLOG_WARN, "CommReadFile failed, nNumberOfBytesToRead=%lu, errno=[%d] %s", nNumberOfBytesToRead, errno, strerror(errno));
CommLog_Print(WLOG_WARN,
"CommReadFile failed, ReadIntervalTimeout=%lu, ReadTotalTimeoutMultiplier=%lu, ReadTotalTimeoutConstant=%lu VMIN=%u, VTIME=%u",
pTimeouts->ReadIntervalTimeout, pTimeouts->ReadTotalTimeoutMultiplier,
pTimeouts->ReadTotalTimeoutConstant,
currentTermios.c_cc[VMIN], currentTermios.c_cc[VTIME]);
CommLog_Print(WLOG_WARN,
"CommReadFile failed, nNumberOfBytesToRead=%lu, errno=[%d] %s",
nNumberOfBytesToRead, errno, strerror(errno));
if (errno == EAGAIN)
{
@ -347,12 +354,10 @@ BOOL CommReadFile(HANDLE hDevice, LPVOID lpBuffer, DWORD nNumberOfBytesToRead,
assert(FALSE);
*lpNumberOfBytesRead = 0;
return_false:
return_false:
LeaveCriticalSection(&pComm->ReadLock);
return FALSE;
return_true:
return_true:
LeaveCriticalSection(&pComm->ReadLock);
return TRUE;
}
@ -365,19 +370,20 @@ BOOL CommReadFile(HANDLE hDevice, LPVOID lpBuffer, DWORD nNumberOfBytesToRead,
* ERROR_INVALID_PARAMETER
* ERROR_BAD_DEVICE
*/
BOOL CommWriteFile(HANDLE hDevice, LPCVOID lpBuffer, DWORD nNumberOfBytesToWrite,
LPDWORD lpNumberOfBytesWritten, LPOVERLAPPED lpOverlapped)
BOOL CommWriteFile(HANDLE hDevice, LPCVOID lpBuffer,
DWORD nNumberOfBytesToWrite,
LPDWORD lpNumberOfBytesWritten, LPOVERLAPPED lpOverlapped)
{
WINPR_COMM* pComm = (WINPR_COMM*) hDevice;
struct timeval tmaxTimeout, *pTmaxTimeout;
EnterCriticalSection(&pComm->WriteLock); /* KISSer by the function's beginning */
EnterCriticalSection(
&pComm->WriteLock); /* KISSer by the function's beginning */
if (hDevice == INVALID_HANDLE_VALUE)
{
SetLastError(ERROR_INVALID_HANDLE);
goto return_false;
}
goto return_false;
}
if (!pComm || pComm->Type != HANDLE_TYPE_COMM)
{
@ -393,7 +399,8 @@ BOOL CommWriteFile(HANDLE hDevice, LPCVOID lpBuffer, DWORD nNumberOfBytesToWrite
if (lpNumberOfBytesWritten == NULL)
{
SetLastError(ERROR_INVALID_PARAMETER); /* since we doesn't suppport lpOverlapped != NULL */
SetLastError(
ERROR_INVALID_PARAMETER); /* since we doesn't suppport lpOverlapped != NULL */
goto return_false;
}
@ -408,26 +415,27 @@ BOOL CommWriteFile(HANDLE hDevice, LPCVOID lpBuffer, DWORD nNumberOfBytesToWrite
* there is no eventfd_read() but this not the case. */
/* discard a possible and no more relevant event */
eventfd_read(pComm->fd_write_event, NULL);
/* ms */
ULONGLONG Tmax = nNumberOfBytesToWrite * pComm->timeouts.WriteTotalTimeoutMultiplier + pComm->timeouts.WriteTotalTimeoutConstant;
ULONGLONG Tmax = nNumberOfBytesToWrite *
pComm->timeouts.WriteTotalTimeoutMultiplier +
pComm->timeouts.WriteTotalTimeoutConstant;
/* NB: select() may update the timeout argument to indicate
* how much time was left. Keep the timeout variable out of
* the while() */
pTmaxTimeout = &tmaxTimeout;
pTmaxTimeout = &tmaxTimeout;
ZeroMemory(pTmaxTimeout, sizeof(struct timeval));
if (Tmax > 0)
if (Tmax > 0)
{
pTmaxTimeout->tv_sec = Tmax / 1000; /* s */
pTmaxTimeout->tv_usec = (Tmax % 1000) * 1000; /* us */
}
else if ((pComm->timeouts.WriteTotalTimeoutMultiplier == 0) && (pComm->timeouts.WriteTotalTimeoutConstant == 0))
else if ((pComm->timeouts.WriteTotalTimeoutMultiplier == 0)
&& (pComm->timeouts.WriteTotalTimeoutConstant == 0))
{
pTmaxTimeout = NULL;
}
/* else return immdiately */
while (*lpNumberOfBytesWritten < nNumberOfBytesToWrite)
@ -435,24 +443,23 @@ BOOL CommWriteFile(HANDLE hDevice, LPCVOID lpBuffer, DWORD nNumberOfBytesToWrite
int biggestFd = -1;
fd_set event_set, write_set;
int nbFds;
biggestFd = pComm->fd_write;
if (pComm->fd_write_event > biggestFd)
biggestFd = pComm->fd_write_event;
FD_ZERO(&event_set);
FD_ZERO(&write_set);
assert(pComm->fd_write_event < FD_SETSIZE);
assert(pComm->fd_write < FD_SETSIZE);
FD_SET(pComm->fd_write_event, &event_set);
FD_SET(pComm->fd_write, &write_set);
nbFds = select(biggestFd + 1, &event_set, &write_set, NULL, pTmaxTimeout);
nbFds = select(biggestFd+1, &event_set, &write_set, NULL, pTmaxTimeout);
if (nbFds < 0)
{
CommLog_Print(WLOG_WARN, "select() failure, errno=[%d] %s\n", errno, strerror(errno));
CommLog_Print(WLOG_WARN, "select() failure, errno=[%d] %s\n", errno,
strerror(errno));
SetLastError(ERROR_IO_DEVICE);
goto return_false;
}
@ -460,12 +467,10 @@ BOOL CommWriteFile(HANDLE hDevice, LPCVOID lpBuffer, DWORD nNumberOfBytesToWrite
if (nbFds == 0)
{
/* timeout */
SetLastError(ERROR_TIMEOUT);
goto return_false;
}
/* event_set */
if (FD_ISSET(pComm->fd_write_event, &event_set))
@ -481,7 +486,9 @@ BOOL CommWriteFile(HANDLE hDevice, LPCVOID lpBuffer, DWORD nNumberOfBytesToWrite
}
else
{
CommLog_Print(WLOG_WARN, "unexpected error on reading fd_write_event, errno=[%d] %s\n", errno, strerror(errno));
CommLog_Print(WLOG_WARN,
"unexpected error on reading fd_write_event, errno=[%d] %s\n", errno,
strerror(errno));
/* FIXME: goto return_false ? */
}
@ -497,20 +504,20 @@ BOOL CommWriteFile(HANDLE hDevice, LPCVOID lpBuffer, DWORD nNumberOfBytesToWrite
assert(event == FREERDP_PURGE_TXABORT); /* no other expected event so far */
}
/* write_set */
if (FD_ISSET(pComm->fd_write, &write_set))
{
ssize_t nbWritten;
nbWritten = write(pComm->fd_write,
lpBuffer + (*lpNumberOfBytesWritten),
nNumberOfBytesToWrite - (*lpNumberOfBytesWritten));
((BYTE*)lpBuffer) + (*lpNumberOfBytesWritten),
nNumberOfBytesToWrite - (*lpNumberOfBytesWritten));
if (nbWritten < 0)
{
CommLog_Print(WLOG_WARN, "CommWriteFile failed after %lu bytes written, errno=[%d] %s\n", *lpNumberOfBytesWritten, errno, strerror(errno));
CommLog_Print(WLOG_WARN,
"CommWriteFile failed after %lu bytes written, errno=[%d] %s\n",
*lpNumberOfBytesWritten, errno, strerror(errno));
if (errno == EAGAIN)
{
@ -532,10 +539,8 @@ BOOL CommWriteFile(HANDLE hDevice, LPCVOID lpBuffer, DWORD nNumberOfBytesToWrite
*lpNumberOfBytesWritten += nbWritten;
}
} /* while */
/* FIXME: this call to tcdrain() doesn't look correct and
* might hide a bug but was required while testing a serial
* printer. Its driver was expecting the modem line status
@ -545,13 +550,10 @@ BOOL CommWriteFile(HANDLE hDevice, LPCVOID lpBuffer, DWORD nNumberOfBytesToWrite
* DesiredAccess=0x0012019F. The printer worked fine with
* mstsc. */
tcdrain(pComm->fd_write);
return_true:
return_true:
LeaveCriticalSection(&pComm->WriteLock);
return TRUE;
return_false:
return_false:
LeaveCriticalSection(&pComm->WriteLock);
return FALSE;
}

View File

@ -35,11 +35,11 @@ extern const NDR_TYPE_MARSHALL_ROUTINE pfnMarshallRoutines[];
extern const NDR_TYPE_UNMARSHALL_ROUTINE pfnUnmarshallRoutines[];
extern const NDR_TYPE_FREE_ROUTINE pfnFreeRoutines[];
extern const char SimpleTypeAlignment[];
extern const char SimpleTypeBufferSize[];
extern const char SimpleTypeMemorySize[];
extern const unsigned char SimpleTypeAlignment[];
extern const unsigned char SimpleTypeBufferSize[];
extern const unsigned char SimpleTypeMemorySize[];
extern const char NdrTypeFlags[];
extern const unsigned char NdrTypeFlags[];
extern const char* FC_TYPE_STRINGS[];
#include "ndr_correlation.h"

View File

@ -31,7 +31,7 @@
#include "ndr_simple.h"
#include "ndr_private.h"
const char SimpleTypeAlignment[] =
const unsigned char SimpleTypeAlignment[] =
{
0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x03, 0x03, 0x03, 0x07, 0x07, 0x01, 0x03, 0x03,
0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
@ -51,7 +51,7 @@ const char SimpleTypeAlignment[] =
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
const char SimpleTypeBufferSize[] =
const unsigned char SimpleTypeBufferSize[] =
{
0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x04, 0x04, 0x04, 0x08, 0x08, 0x02, 0x04, 0x04,
0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
@ -71,7 +71,7 @@ const char SimpleTypeBufferSize[] =
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
const char SimpleTypeMemorySize[] =
const unsigned char SimpleTypeMemorySize[] =
{
0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x04, 0x04, 0x04, 0x08, 0x08, 0x04, 0x04, 0x04,
0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
@ -91,7 +91,7 @@ const char SimpleTypeMemorySize[] =
0x92, 0x9D, 0x3A, 0x75, 0x92, 0x9D, 0x3A, 0x75, 0x92, 0x9D, 0x3A, 0x75, 0x92, 0x9D, 0x3A, 0x75,
};
const char NdrTypeFlags[] =
const unsigned char NdrTypeFlags[] =
{
0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x02, 0x02, 0x02, 0x02, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x08, 0x08, 0x08, 0x08, 0x08,
@ -111,17 +111,17 @@ const char NdrTypeFlags[] =
0xAD, 0xAD, 0x9B, 0xBA, 0x9B, 0x9B, 0x0D, 0xB9, 0xAD, 0x19, 0x19, 0xBA, 0xDB, 0x09, 0x86, 0xB1,
};
char NdrGetSimpleTypeBufferAlignment(unsigned char FormatChar)
unsigned char NdrGetSimpleTypeBufferAlignment(unsigned char FormatChar)
{
return SimpleTypeAlignment[FormatChar];
}
char NdrGetSimpleTypeBufferSize(unsigned char FormatChar)
unsigned char NdrGetSimpleTypeBufferSize(unsigned char FormatChar)
{
return SimpleTypeAlignment[FormatChar];
}
char NdrGetSimpleTypeMemorySize(unsigned char FormatChar)
unsigned char NdrGetSimpleTypeMemorySize(unsigned char FormatChar)
{
return SimpleTypeMemorySize[FormatChar];
}
@ -131,7 +131,8 @@ int NdrGetTypeFlags(unsigned char FormatChar)
return NdrTypeFlags[FormatChar];
}
void NdrSimpleTypeBufferSize(PMIDL_STUB_MESSAGE pStubMsg, unsigned char* pMemory, PFORMAT_STRING pFormat)
void NdrSimpleTypeBufferSize(PMIDL_STUB_MESSAGE pStubMsg,
unsigned char* pMemory, PFORMAT_STRING pFormat)
{
switch (*pFormat)
{
@ -184,19 +185,19 @@ void NdrSimpleTypeBufferSize(PMIDL_STUB_MESSAGE pStubMsg, unsigned char* pMemory
}
}
void NdrSimpleTypeMarshall(PMIDL_STUB_MESSAGE pStubMsg, unsigned char* pMemory, unsigned char FormatChar)
void NdrSimpleTypeMarshall(PMIDL_STUB_MESSAGE pStubMsg, unsigned char* pMemory,
unsigned char FormatChar)
{
}
void NdrSimpleTypeUnmarshall(PMIDL_STUB_MESSAGE pStubMsg, unsigned char* pMemory, unsigned char FormatChar)
void NdrSimpleTypeUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
unsigned char* pMemory, unsigned char FormatChar)
{
}
void NdrSimpleTypeFree(PMIDL_STUB_MESSAGE pStubMsg, unsigned char* pMemory, PFORMAT_STRING pFormat)
void NdrSimpleTypeFree(PMIDL_STUB_MESSAGE pStubMsg, unsigned char* pMemory,
PFORMAT_STRING pFormat)
{
}
#endif

View File

@ -24,14 +24,18 @@
#ifndef _WIN32
void NdrSimpleTypeBufferSize(PMIDL_STUB_MESSAGE pStubMsg, unsigned char* pMemory, PFORMAT_STRING pFormat);
void NdrSimpleTypeMarshall(PMIDL_STUB_MESSAGE pStubMsg, unsigned char* pMemory, unsigned char FormatChar);
void NdrSimpleTypeUnmarshall(PMIDL_STUB_MESSAGE pStubMsg, unsigned char* pMemory, unsigned char FormatChar);
void NdrSimpleTypeFree(PMIDL_STUB_MESSAGE pStubMsg, unsigned char* pMemory, PFORMAT_STRING pFormat);
void NdrSimpleTypeBufferSize(PMIDL_STUB_MESSAGE pStubMsg,
unsigned char* pMemory, PFORMAT_STRING pFormat);
void NdrSimpleTypeMarshall(PMIDL_STUB_MESSAGE pStubMsg, unsigned char* pMemory,
unsigned char FormatChar);
void NdrSimpleTypeUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
unsigned char* pMemory, unsigned char FormatChar);
void NdrSimpleTypeFree(PMIDL_STUB_MESSAGE pStubMsg, unsigned char* pMemory,
PFORMAT_STRING pFormat);
char NdrGetSimpleTypeBufferAlignment(unsigned char FormatChar);
char NdrGetSimpleTypeBufferSize(unsigned char FormatChar);
char NdrGetSimpleTypeMemorySize(unsigned char FormatChar);
unsigned char NdrGetSimpleTypeBufferAlignment(unsigned char FormatChar);
unsigned char NdrGetSimpleTypeBufferSize(unsigned char FormatChar);
unsigned char NdrGetSimpleTypeMemorySize(unsigned char FormatChar);
int NdrGetTypeFlags(unsigned char FormatChar);
#endif

View File

@ -140,7 +140,7 @@ static DWORD ThreadCleanupHandle(HANDLE handle)
if (status != 0)
{
WLog_ERR(TAG, "pthread_join failure: [%d] %s",
status, strerror(status));
status, strerror(status));
pthread_mutex_unlock(&thread->mutex);
return WAIT_FAILED;
}
@ -154,11 +154,12 @@ static DWORD ThreadCleanupHandle(HANDLE handle)
return WAIT_OBJECT_0;
}
static HANDLE_OPS ops = {
ThreadIsHandled,
ThreadCloseHandle,
ThreadGetFd,
ThreadCleanupHandle
static HANDLE_OPS ops =
{
ThreadIsHandled,
ThreadCloseHandle,
ThreadGetFd,
ThreadCleanupHandle
};
@ -202,6 +203,7 @@ static void dump_thread(WINPR_THREAD* thread)
free(msg);
}
#endif
}
@ -209,7 +211,7 @@ static void dump_thread(WINPR_THREAD* thread)
* TODO: implement thread suspend/resume using pthreads
* http://stackoverflow.com/questions/3140867/suspend-pthreads-without-using-condition
*/
static BOOL set_event(WINPR_THREAD *thread)
static BOOL set_event(WINPR_THREAD* thread)
{
int length;
BOOL status = FALSE;
@ -224,6 +226,7 @@ static BOOL set_event(WINPR_THREAD *thread)
status = (length == 0) ? TRUE : FALSE;
#else
if (WaitForSingleObject(thread, 0) != WAIT_OBJECT_0)
{
length = write(thread->pipe_fd[1], "-", 1);
@ -235,11 +238,12 @@ static BOOL set_event(WINPR_THREAD *thread)
{
status = TRUE;
}
#endif
return status;
}
static BOOL reset_event(WINPR_THREAD *thread)
static BOOL reset_event(WINPR_THREAD* thread)
{
int length;
BOOL status = FALSE;
@ -278,10 +282,11 @@ static BOOL thread_compare(void* a, void* b)
* in thread function. */
static void* thread_launcher(void* arg)
{
DWORD res = -1;
DWORD res = 1;
void* rc = NULL;
WINPR_THREAD* thread = (WINPR_THREAD*) arg;
void *(*fkt)(void*);
typedef void* (*fkt_t)(void*);
fkt_t fkt;
if (!thread)
{
@ -289,7 +294,7 @@ static void* thread_launcher(void* arg)
goto exit;
}
if (!(fkt = (void*) thread->lpStartAddress))
if (!(fkt = (fkt_t)thread->lpStartAddress))
{
WLog_ERR(TAG, "Thread function argument is %p", fkt);
goto exit;
@ -307,13 +312,12 @@ static void* thread_launcher(void* arg)
goto exit;
}
}
if (pthread_mutex_unlock(&thread->threadIsReadyMutex))
goto exit;
assert(ListDictionary_Contains(thread_list, &thread->thread));
rc = fkt(thread->lpParameter);
exit:
if (thread)
@ -322,15 +326,16 @@ exit:
thread->dwExitCode = (DWORD)(size_t)rc;
set_event(thread);
res = thread->dwExitCode;
if (thread->detached || !thread->started)
cleanup_handle(thread);
}
return rc;
}
static BOOL winpr_StartThread(WINPR_THREAD *thread)
static BOOL winpr_StartThread(WINPR_THREAD* thread)
{
pthread_attr_t attr;
pthread_attr_init(&attr);
@ -345,7 +350,6 @@ static BOOL winpr_StartThread(WINPR_THREAD *thread)
if (pthread_create(&thread->thread, &attr, thread_launcher, thread))
goto error;
if (pthread_mutex_lock(&thread->threadIsReadyMutex))
goto error;
@ -355,30 +359,32 @@ static BOOL winpr_StartThread(WINPR_THREAD *thread)
pthread_mutex_unlock(&thread->threadIsReadyMutex);
goto error;
}
if (pthread_cond_signal(&thread->threadIsReady) != 0)
{
WLog_ERR(TAG, "failed to signal the thread was ready");
pthread_mutex_unlock(&thread->threadIsReadyMutex);
goto error;
}
if (pthread_mutex_unlock(&thread->threadIsReadyMutex))
goto error;
pthread_attr_destroy(&attr);
dump_thread(thread);
return TRUE;
error:
pthread_attr_destroy(&attr);
return FALSE;
}
HANDLE CreateThread(LPSECURITY_ATTRIBUTES lpThreadAttributes, SIZE_T dwStackSize,
LPTHREAD_START_ROUTINE lpStartAddress, LPVOID lpParameter, DWORD dwCreationFlags, LPDWORD lpThreadId)
HANDLE CreateThread(LPSECURITY_ATTRIBUTES lpThreadAttributes,
SIZE_T dwStackSize,
LPTHREAD_START_ROUTINE lpStartAddress, LPVOID lpParameter,
DWORD dwCreationFlags, LPDWORD lpThreadId)
{
HANDLE handle;
WINPR_THREAD* thread;
thread = (WINPR_THREAD*) calloc(1, sizeof(WINPR_THREAD));
if (!thread)
@ -389,14 +395,12 @@ HANDLE CreateThread(LPSECURITY_ATTRIBUTES lpThreadAttributes, SIZE_T dwStackSize
thread->lpStartAddress = lpStartAddress;
thread->lpThreadAttributes = lpThreadAttributes;
thread->ops = &ops;
#if defined(WITH_DEBUG_THREADS)
thread->create_stack = winpr_backtrace(20);
dump_thread(thread);
#endif
thread->pipe_fd[0] = -1;
thread->pipe_fd[1] = -1;
#ifdef HAVE_EVENTFD_H
thread->pipe_fd[0] = eventfd(0, EFD_NONBLOCK);
@ -405,20 +409,23 @@ HANDLE CreateThread(LPSECURITY_ATTRIBUTES lpThreadAttributes, SIZE_T dwStackSize
WLog_ERR(TAG, "failed to create thread pipe fd 0");
goto error_pipefd0;
}
#else
if (pipe(thread->pipe_fd) < 0)
{
WLog_ERR(TAG, "failed to create thread pipe");
goto error_pipefd0;
}
{
int flags = fcntl(thread->pipe_fd[0], F_GETFL);
fcntl(thread->pipe_fd[0], F_SETFL, flags | O_NONBLOCK);
}
#endif
if(pthread_mutex_init(&thread->mutex, 0) != 0)
if (pthread_mutex_init(&thread->mutex, 0) != 0)
{
WLog_ERR(TAG, "failed to initialize thread mutex");
goto error_mutex;
@ -442,11 +449,13 @@ HANDLE CreateThread(LPSECURITY_ATTRIBUTES lpThreadAttributes, SIZE_T dwStackSize
if (!thread_list)
{
thread_list = ListDictionary_New(TRUE);
if (!thread_list)
{
WLog_ERR(TAG, "Couldn't create global thread list");
goto error_thread_list;
}
thread_list->objectKey.fnObjectEquals = thread_compare;
}
@ -462,7 +471,6 @@ HANDLE CreateThread(LPSECURITY_ATTRIBUTES lpThreadAttributes, SIZE_T dwStackSize
}
return handle;
error_thread_list:
pthread_cond_destroy(&thread->threadIsReady);
error_thread_ready:
@ -470,35 +478,39 @@ error_thread_ready:
error_thread_ready_mutex:
pthread_mutex_destroy(&thread->mutex);
error_mutex:
if (thread->pipe_fd[1] >= 0)
close(thread->pipe_fd[1]);
if (thread->pipe_fd[0] >= 0)
close(thread->pipe_fd[0]);
error_pipefd0:
free(thread);
return NULL;
}
void cleanup_handle(void *obj)
void cleanup_handle(void* obj)
{
int rc;
WINPR_THREAD* thread = (WINPR_THREAD*) obj;
rc = pthread_cond_destroy(&thread->threadIsReady);
if (rc)
WLog_ERR(TAG, "failed to destroy a condition variable [%d] %s (%d)",
rc, strerror(errno), errno);
rc, strerror(errno), errno);
rc = pthread_mutex_destroy(&thread->threadIsReadyMutex);
if (rc)
WLog_ERR(TAG, "failed to destroy a condition variable mutex [%d] %s (%d)",
rc, strerror(errno), errno);
rc, strerror(errno), errno);
rc = pthread_mutex_destroy(&thread->mutex);
if (rc)
WLog_ERR(TAG, "failed to destroy mutex [%d] %s (%d)",
rc, strerror(errno), errno);
rc, strerror(errno), errno);
if (thread->pipe_fd[0] >= 0)
close(thread->pipe_fd[0]);
@ -563,8 +575,10 @@ BOOL ThreadCloseHandle(HANDLE handle)
return TRUE;
}
HANDLE CreateRemoteThread(HANDLE hProcess, LPSECURITY_ATTRIBUTES lpThreadAttributes, SIZE_T dwStackSize,
LPTHREAD_START_ROUTINE lpStartAddress, LPVOID lpParameter, DWORD dwCreationFlags, LPDWORD lpThreadId)
HANDLE CreateRemoteThread(HANDLE hProcess,
LPSECURITY_ATTRIBUTES lpThreadAttributes, SIZE_T dwStackSize,
LPTHREAD_START_ROUTINE lpStartAddress, LPVOID lpParameter,
DWORD dwCreationFlags, LPDWORD lpThreadId)
{
WLog_ERR(TAG, "%s: not implemented", __FUNCTION__);
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
@ -595,10 +609,8 @@ VOID ExitThread(DWORD dwExitCode)
else
{
WINPR_THREAD* thread;
ListDictionary_Lock(thread_list);
thread = ListDictionary_GetItemValue(thread_list, &tid);
assert(thread);
thread->exited = TRUE;
thread->dwExitCode = dwExitCode;
@ -607,12 +619,12 @@ VOID ExitThread(DWORD dwExitCode)
#endif
ListDictionary_Unlock(thread_list);
set_event(thread);
rc = thread->dwExitCode;
if (thread->detached || !thread->started)
cleanup_handle(thread);
pthread_exit((void*) (size_t) rc);
pthread_exit((void*)(size_t) rc);
}
}
@ -661,7 +673,6 @@ DWORD GetCurrentThreadId(VOID)
{
pthread_t tid;
tid = pthread_self();
/* Since pthread_t can be 64-bits on some systems, take just the */
/* lower 32-bits of it for the thread ID returned by this function. */
return (DWORD)tid & 0xffffffffUL;
@ -674,25 +685,26 @@ DWORD ResumeThread(HANDLE hThread)
WINPR_THREAD* thread;
if (!winpr_Handle_GetInfo(hThread, &Type, &Object))
return (DWORD)-1;
return (DWORD) - 1;
thread = (WINPR_THREAD*) Object;
if (pthread_mutex_lock(&thread->mutex))
return (DWORD)-1;
return (DWORD) - 1;
if (!thread->started)
{
if (!winpr_StartThread(thread))
{
pthread_mutex_unlock(&thread->mutex);
return (DWORD)-1;
return (DWORD) - 1;
}
}
else
WLog_WARN(TAG, "Thread already started!");
if (pthread_mutex_unlock(&thread->mutex))
return (DWORD)-1;
return (DWORD) - 1;
return 0;
}
@ -701,7 +713,7 @@ DWORD SuspendThread(HANDLE hThread)
{
WLog_ERR(TAG, "%s: not implemented", __FUNCTION__);
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
return (DWORD)-1;
return (DWORD) - 1;
}
BOOL SwitchToThread(VOID)
@ -728,6 +740,7 @@ BOOL TerminateThread(HANDLE hThread, DWORD dwExitCode)
thread = (WINPR_THREAD*) Object;
thread->exited = TRUE;
thread->dwExitCode = dwExitCode;
if (pthread_mutex_lock(&thread->mutex))
return FALSE;
@ -736,6 +749,7 @@ BOOL TerminateThread(HANDLE hThread, DWORD dwExitCode)
#else
WLog_ERR(TAG, "Function not supported on this platform!");
#endif
if (pthread_mutex_unlock(&thread->mutex))
return FALSE;
@ -767,14 +781,15 @@ VOID DumpThreadHandles(void)
}
else
{
ULONG_PTR *keys = NULL;
ULONG_PTR* keys = NULL;
ListDictionary_Lock(thread_list);
int x, count = ListDictionary_GetKeys(thread_list, &keys);
WLog_DBG(TAG, "Dumping %d elements", count);
for (x = 0; x < count; x++)
{
WINPR_THREAD* thread = ListDictionary_GetItemValue(thread_list, (void*) keys[x]);
WINPR_THREAD* thread = ListDictionary_GetItemValue(thread_list,
(void*) keys[x]);
WLog_DBG(TAG, "Thread [%d] handle created still not closed!", x);
msg = winpr_backtrace_symbols(thread->create_stack, &used);
@ -794,7 +809,7 @@ VOID DumpThreadHandles(void)
WLog_DBG(TAG, "Thread [%d] exited at:", x);
msg = winpr_backtrace_symbols(thread->exit_stack, &used);
for (i=0; i<used; i++)
for (i = 0; i < used; i++)
WLog_DBG(TAG, "[%d]: %s", i, msg[i]);
free(msg);
@ -802,7 +817,6 @@ VOID DumpThreadHandles(void)
}
free(keys);
ListDictionary_Unlock(thread_list);
}

View File

@ -84,33 +84,39 @@ static BOOL log_recursion(LPCSTR file, LPCSTR fkt, int line)
if (!bt)
return FALSE;
msg = winpr_backtrace_symbols(bt, &used);
if (!msg)
return FALSE;
#if defined(ANDROID)
if (__android_log_print(ANDROID_LOG_FATAL, tag, "Recursion detected!!!") < 0)
return FALSE;
if (__android_log_print(ANDROID_LOG_FATAL, tag, "Check %s [%s:%d]", fkt, file, line) < 0)
if (__android_log_print(ANDROID_LOG_FATAL, tag, "Check %s [%s:%d]", fkt, file,
line) < 0)
return FALSE;
for (i=0; i<used; i++)
for (i = 0; i < used; i++)
if (__android_log_print(ANDROID_LOG_FATAL, tag, "%d: %s", i, msg[i]) < 0)
return FALSE;
#else
if (fprintf(stderr, "[%s]: Recursion detected!\n", fkt) < 0)
return FALSE;
if (fprintf(stderr, "[%s]: Check %s:%d\n", fkt, file, line) < 0)
return FALSE;
for (i=0; i<used; i++)
for (i = 0; i < used; i++)
if (fprintf(stderr, "%s: %lu: %s\n", fkt, (unsigned long)i, msg[i]) < 0)
return FALSE;
#endif
free(msg);
winpr_backtrace_free(bt);
return TRUE;
}
@ -134,7 +140,8 @@ BOOL WLog_Write(wLog* log, wLogMessage* message)
EnterCriticalSection(&appender->lock);
if (appender->recursive)
status = log_recursion(message->FileName, message->FunctionName, message->LineNumber);
status = log_recursion(message->FileName, message->FunctionName,
message->LineNumber);
else
{
appender->recursive = TRUE;
@ -165,7 +172,8 @@ BOOL WLog_WriteData(wLog* log, wLogMessage* message)
EnterCriticalSection(&appender->lock);
if (appender->recursive)
status = log_recursion(message->FileName, message->FunctionName, message->LineNumber);
status = log_recursion(message->FileName, message->FunctionName,
message->LineNumber);
else
{
appender->recursive = TRUE;
@ -196,7 +204,8 @@ BOOL WLog_WriteImage(wLog* log, wLogMessage* message)
EnterCriticalSection(&appender->lock);
if (appender->recursive)
status = log_recursion(message->FileName, message->FunctionName, message->LineNumber);
status = log_recursion(message->FileName, message->FunctionName,
message->LineNumber);
else
{
appender->recursive = TRUE;
@ -227,7 +236,8 @@ BOOL WLog_WritePacket(wLog* log, wLogMessage* message)
EnterCriticalSection(&appender->lock);
if (appender->recursive)
status = log_recursion(message->FileName, message->FunctionName, message->LineNumber);
status = log_recursion(message->FileName, message->FunctionName,
message->LineNumber);
else
{
appender->recursive = TRUE;
@ -239,57 +249,75 @@ BOOL WLog_WritePacket(wLog* log, wLogMessage* message)
return status;
}
BOOL WLog_PrintMessageVA(wLog* log, wLogMessage* message, va_list args)
BOOL WLog_PrintMessageVA(wLog* log, DWORD type, DWORD level, DWORD line,
const char* file, const char* function, va_list args)
{
BOOL status = FALSE;
wLogMessage message = { 0 };
message.Level = level;
message.LineNumber = line;
message.FileName = file;
message.FunctionName = function;
if (message->Type == WLOG_MESSAGE_TEXT)
switch (type)
{
if (!strchr(message->FormatString, '%'))
{
message->TextString = (LPSTR) message->FormatString;
status = WLog_Write(log, message);
}
else
{
char formattedLogMessage[WLOG_MAX_STRING_SIZE];
if (wvsnprintfx(formattedLogMessage, WLOG_MAX_STRING_SIZE - 1, message->FormatString, args) < 0)
return FALSE;
message->TextString = formattedLogMessage;
status = WLog_Write(log, message);
}
}
else if (message->Type == WLOG_MESSAGE_DATA)
{
message->Data = va_arg(args, void*);
message->Length = va_arg(args, int);
status = WLog_WriteData(log, message);
}
else if (message->Type == WLOG_MESSAGE_IMAGE)
{
message->ImageData = va_arg(args, void*);
message->ImageWidth = va_arg(args, int);
message->ImageHeight = va_arg(args, int);
message->ImageBpp = va_arg(args, int);
status = WLog_WriteImage(log, message);
}
else if (message->Type == WLOG_MESSAGE_PACKET)
{
message->PacketData = va_arg(args, void*);
message->PacketLength = va_arg(args, int);
message->PacketFlags = va_arg(args, int);
status = WLog_WritePacket(log, message);
case WLOG_MESSAGE_TEXT:
message.FormatString = va_arg(args, const char*);
if (!strchr(message.FormatString, '%'))
{
message.TextString = (LPSTR) message.FormatString;
status = WLog_Write(log, &message);
}
else
{
char formattedLogMessage[WLOG_MAX_STRING_SIZE];
if (wvsnprintfx(formattedLogMessage, WLOG_MAX_STRING_SIZE - 1,
message.FormatString, args) < 0)
return FALSE;
message.TextString = formattedLogMessage;
status = WLog_Write(log, &message);
}
break;
case WLOG_MESSAGE_DATA:
message.Data = va_arg(args, void*);
message.Length = va_arg(args, int);
status = WLog_WriteData(log, &message);
break;
case WLOG_MESSAGE_IMAGE:
message.ImageData = va_arg(args, void*);
message.ImageWidth = va_arg(args, int);
message.ImageHeight = va_arg(args, int);
message.ImageBpp = va_arg(args, int);
status = WLog_WriteImage(log, &message);
break;
case WLOG_MESSAGE_PACKET:
message.PacketData = va_arg(args, void*);
message.PacketLength = va_arg(args, int);
message.PacketFlags = va_arg(args, int);
status = WLog_WritePacket(log, &message);
break;
default:
break;
}
return status;
}
BOOL WLog_PrintMessage(wLog* log, wLogMessage* message, ...)
BOOL WLog_PrintMessage(wLog* log, DWORD type, DWORD level, DWORD line,
const char* file, const char* function, ...)
{
BOOL status;
va_list args;
va_start(args, message);
status = WLog_PrintMessageVA(log, message, args);
va_start(args, function);
status = WLog_PrintMessageVA(log, type, level, line, file, function, args);
va_end(args);
return status;
}
@ -303,16 +331,19 @@ DWORD WLog_GetLogLevel(wLog* log)
return log->FilterLevel;
else if (log->Level == WLOG_LEVEL_INHERIT)
log->Level = WLog_GetLogLevel(log->Parent);
return log->Level;
}
BOOL WLog_SetStringLogLevel(wLog* log, LPCSTR level)
{
int lvl;
if (!log || !level)
return FALSE;
lvl = WLog_ParseLogLevel(level);
if (lvl < 0)
return FALSE;
@ -349,8 +380,8 @@ BOOL WLog_AddStringLogFilters(LPCSTR filter)
return FALSE;
g_Filters = tmp;
cp = (LPSTR)_strdup(filter);
if (!cp)
return FALSE;
@ -360,6 +391,7 @@ BOOL WLog_AddStringLogFilters(LPCSTR filter)
do
{
p = strchr(p, ',');
if (p)
*p = '\0';
@ -367,7 +399,7 @@ BOOL WLog_AddStringLogFilters(LPCSTR filter)
{
if (!WLog_ParseFilter(&g_Filters[pos++], filterStr))
{
free (cp);
free(cp);
return FALSE;
}
}
@ -383,8 +415,7 @@ BOOL WLog_AddStringLogFilters(LPCSTR filter)
while (p != NULL);
g_FilterCount = size;
free (cp);
free(cp);
return TRUE;
}
@ -434,7 +465,7 @@ BOOL WLog_ParseFilter(wLogFilter* filter, LPCSTR name)
int iLevel;
count = 1;
if(!name)
if (!name)
return FALSE;
p = (char*) name;
@ -449,16 +480,20 @@ BOOL WLog_ParseFilter(wLogFilter* filter, LPCSTR name)
}
names = _strdup(name);
if (!names)
return FALSE;
filter->NameCount = count;
filter->Names = (LPSTR*) calloc((count + 1UL), sizeof(LPSTR));
if(!filter->Names)
if (!filter->Names)
{
free(names);
filter->NameCount = 0;
return FALSE;
}
filter->Names[count] = NULL;
count = 0;
p = (char*) names;
@ -493,6 +528,7 @@ BOOL WLog_ParseFilter(wLogFilter* filter, LPCSTR name)
{
if (count < (int) filter->NameCount)
filter->Names[count++] = p + 1;
*p = '\0';
p++;
}
@ -505,10 +541,8 @@ BOOL WLog_ParseFilters(void)
BOOL res;
char* env;
DWORD nSize;
g_Filters = NULL;
g_FilterCount = 0;
nSize = GetEnvironmentVariableA("WLOG_FILTER", NULL, 0);
if (nSize < 1)
@ -523,9 +557,7 @@ BOOL WLog_ParseFilters(void)
return FALSE;
res = WLog_AddStringLogFilters(env);
free(env);
return res;
}
@ -587,15 +619,19 @@ BOOL WLog_ParseName(wLog* log, LPCSTR name)
}
names = _strdup(name);
if (!names)
return FALSE;
log->NameCount = count;
log->Names = (LPSTR*) calloc((count + 1UL), sizeof(LPSTR));
if(!log->Names)
if (!log->Names)
{
free(names);
return FALSE;
}
log->Names[count] = NULL;
count = 0;
p = (char*) names;
@ -605,6 +641,7 @@ BOOL WLog_ParseName(wLog* log, LPCSTR name)
{
if (count < (int) log->NameCount)
log->Names[count++] = p + 1;
*p = '\0';
p++;
}
@ -618,8 +655,8 @@ wLog* WLog_New(LPCSTR name, wLog* rootLogger)
char* env = NULL;
DWORD nSize;
int iLevel;
log = (wLog*) calloc(1, sizeof(wLog));
if (!log)
return NULL;
@ -653,6 +690,7 @@ wLog* WLog_New(LPCSTR name, wLog* rootLogger)
if (nSize)
{
env = (LPSTR) malloc(nSize);
if (!env)
goto out_fail;
@ -677,11 +715,10 @@ wLog* WLog_New(LPCSTR name, wLog* rootLogger)
log->Level = (DWORD) iLevel;
return log;
out_fail:
free (log->Children);
free (log->Name);
free (log);
free(log->Children);
free(log->Name);
free(log);
return NULL;
}
@ -724,6 +761,7 @@ wLog* WLog_GetRoot(void)
if (nSize)
{
env = (LPSTR) malloc(nSize);
if (!env)
goto fail;
@ -740,13 +778,16 @@ wLog* WLog_GetRoot(void)
logAppenderType = WLOG_APPENDER_FILE;
else if (_stricmp(env, "BINARY") == 0)
logAppenderType = WLOG_APPENDER_BINARY;
#ifdef HAVE_SYSLOG_H
else if (_stricmp(env, "SYSLOG") == 0)
logAppenderType = WLOG_APPENDER_SYSLOG;
#endif /* HAVE_SYSLOG_H */
#ifdef HAVE_JOURNALD_H
else if (_stricmp(env, "JOURNALD") == 0)
logAppenderType = WLOG_APPENDER_JOURNALD;
#endif
else if (_stricmp(env, "UDP") == 0)
logAppenderType = WLOG_APPENDER_UDP;
@ -759,7 +800,6 @@ wLog* WLog_GetRoot(void)
}
return g_RootLog;
fail:
free(g_RootLog);
g_RootLog = NULL;
@ -770,24 +810,29 @@ BOOL WLog_AddChild(wLog* parent, wLog* child)
{
if (parent->ChildrenCount >= parent->ChildrenSize)
{
wLog **tmp;
wLog** tmp;
parent->ChildrenSize *= 2;
if (!parent->ChildrenSize)
{
if (parent->Children)
free (parent->Children);
free(parent->Children);
parent->Children = NULL;
}
else
{
tmp = (wLog**) realloc(parent->Children, sizeof(wLog*) * parent->ChildrenSize);
if (!tmp)
{
if (parent->Children)
free (parent->Children);
free(parent->Children);
parent->Children = NULL;
return FALSE;
}
parent->Children = tmp;
}
}
@ -828,28 +873,33 @@ wLog* WLog_FindChild(LPCSTR name)
wLog* WLog_Get(LPCSTR name)
{
wLog* log;
if (!(log = WLog_FindChild(name)))
{
wLog* root = WLog_GetRoot();
if (!root)
return NULL;
if (!(log = WLog_New(name, root)))
return NULL;
if (!WLog_AddChild(root, log))
{
WLog_Free(log);
return NULL;
}
}
return log;
}
BOOL WLog_Init()
BOOL WLog_Init(void)
{
return WLog_GetRoot() != NULL;
}
BOOL WLog_Uninit()
BOOL WLog_Uninit(void)
{
DWORD index;
wLog* child = NULL;