diff --git a/channels/server/channels.c b/channels/server/channels.c index c83ed7cd1..231826866 100644 --- a/channels/server/channels.c +++ b/channels/server/channels.c @@ -635,7 +635,7 @@ BOOL WTSVirtualChannelQuery( int fds_count = 0; BOOL result = FALSE; rdpPeerChannel* channel = (rdpPeerChannel*) hChannelHandle; - + ZeroMemory(fds, sizeof(fds)); switch (WtsVirtualClass) { case WTSVirtualFileHandle: diff --git a/client/Android/FreeRDPCore/src/com/freerdp/freerdpcore/utils/KeyboardMapper.java b/client/Android/FreeRDPCore/src/com/freerdp/freerdpcore/utils/KeyboardMapper.java index e9bbb2cd6..437075ca8 100644 --- a/client/Android/FreeRDPCore/src/com/freerdp/freerdpcore/utils/KeyboardMapper.java +++ b/client/Android/FreeRDPCore/src/com/freerdp/freerdpcore/utils/KeyboardMapper.java @@ -216,6 +216,7 @@ public class KeyboardMapper final static int VK_PA1 = 0xFD; final static int VK_OEM_CLEAR = 0xFE; final static int VK_UNICODE = 0x80000000; + final static int VK_EXT_KEY = 0x00000100; // key codes to switch between custom keyboard private final static int EXTKEY_KBFUNCTIONKEYS = 0x1100; @@ -337,12 +338,12 @@ public class KeyboardMapper keymapExt[context.getResources().getInteger(R.integer.keycode_F12)] = VK_F12; keymapExt[context.getResources().getInteger(R.integer.keycode_tab)] = VK_TAB; keymapExt[context.getResources().getInteger(R.integer.keycode_print)] = VK_PRINT; - keymapExt[context.getResources().getInteger(R.integer.keycode_insert)] = VK_INSERT; - keymapExt[context.getResources().getInteger(R.integer.keycode_delete)] = VK_DELETE; - keymapExt[context.getResources().getInteger(R.integer.keycode_home)] = VK_HOME; - keymapExt[context.getResources().getInteger(R.integer.keycode_end)] = VK_END; - keymapExt[context.getResources().getInteger(R.integer.keycode_pgup)] = VK_PRIOR; - keymapExt[context.getResources().getInteger(R.integer.keycode_pgdn)] = VK_NEXT; + keymapExt[context.getResources().getInteger(R.integer.keycode_insert)] = VK_INSERT | VK_EXT_KEY; + keymapExt[context.getResources().getInteger(R.integer.keycode_delete)] = VK_DELETE | VK_EXT_KEY; + keymapExt[context.getResources().getInteger(R.integer.keycode_home)] = VK_HOME | VK_EXT_KEY; + keymapExt[context.getResources().getInteger(R.integer.keycode_end)] = VK_END | VK_EXT_KEY; + keymapExt[context.getResources().getInteger(R.integer.keycode_pgup)] = VK_PRIOR | VK_EXT_KEY; + keymapExt[context.getResources().getInteger(R.integer.keycode_pgdn)] = VK_NEXT | VK_EXT_KEY; // numpad mapping keymapExt[context.getResources().getInteger(R.integer.keycode_numpad_0)] = VK_NUMPAD0; @@ -358,8 +359,8 @@ public class KeyboardMapper keymapExt[context.getResources().getInteger(R.integer.keycode_numpad_numlock)] = VK_NUMLOCK; keymapExt[context.getResources().getInteger(R.integer.keycode_numpad_add)] = VK_ADD; keymapExt[context.getResources().getInteger(R.integer.keycode_numpad_comma)] = VK_DECIMAL; - keymapExt[context.getResources().getInteger(R.integer.keycode_numpad_divide)] = VK_DIVIDE; - keymapExt[context.getResources().getInteger(R.integer.keycode_numpad_enter)] = VK_RETURN; + keymapExt[context.getResources().getInteger(R.integer.keycode_numpad_divide)] = VK_DIVIDE | VK_EXT_KEY; + keymapExt[context.getResources().getInteger(R.integer.keycode_numpad_enter)] = VK_RETURN | VK_EXT_KEY; keymapExt[context.getResources().getInteger(R.integer.keycode_numpad_multiply)] = VK_MULTIPLY; keymapExt[context.getResources().getInteger(R.integer.keycode_numpad_subtract)] = VK_SUBTRACT; keymapExt[context.getResources().getInteger(R.integer.keycode_numpad_equals)] = (KEY_FLAG_UNICODE | 61); @@ -367,16 +368,16 @@ public class KeyboardMapper keymapExt[context.getResources().getInteger(R.integer.keycode_numpad_right_paren)] = (KEY_FLAG_UNICODE | 41); // cursor key codes - keymapExt[context.getResources().getInteger(R.integer.keycode_up)] = VK_UP; - keymapExt[context.getResources().getInteger(R.integer.keycode_down)] = VK_DOWN; - keymapExt[context.getResources().getInteger(R.integer.keycode_left)] = VK_LEFT; - keymapExt[context.getResources().getInteger(R.integer.keycode_right)] = VK_RIGHT; - keymapExt[context.getResources().getInteger(R.integer.keycode_enter)] = VK_RETURN; + keymapExt[context.getResources().getInteger(R.integer.keycode_up)] = VK_UP | VK_EXT_KEY; + keymapExt[context.getResources().getInteger(R.integer.keycode_down)] = VK_DOWN | VK_EXT_KEY; + keymapExt[context.getResources().getInteger(R.integer.keycode_left)] = VK_LEFT | VK_EXT_KEY; + keymapExt[context.getResources().getInteger(R.integer.keycode_right)] = VK_RIGHT | VK_EXT_KEY; + keymapExt[context.getResources().getInteger(R.integer.keycode_enter)] = VK_RETURN | VK_EXT_KEY; keymapExt[context.getResources().getInteger(R.integer.keycode_backspace)] = VK_BACK; // shared keys - keymapExt[context.getResources().getInteger(R.integer.keycode_win)] = VK_LWIN; - keymapExt[context.getResources().getInteger(R.integer.keycode_menu)] = VK_APPS; + keymapExt[context.getResources().getInteger(R.integer.keycode_win)] = VK_LWIN | VK_EXT_KEY; + keymapExt[context.getResources().getInteger(R.integer.keycode_menu)] = VK_APPS | VK_EXT_KEY; keymapExt[context.getResources().getInteger(R.integer.keycode_esc)] = VK_ESCAPE; /* keymapExt[context.getResources().getInteger(R.integer.keycode_modifier_ctrl)] = VK_LCONTROL; @@ -591,11 +592,11 @@ public class KeyboardMapper } case VK_LWIN: { - if(!checkToggleModifierLock(VK_LMENU)) + if(!checkToggleModifierLock(VK_LWIN)) { isWinLocked = false; winPressed = !winPressed; - listener.processVirtualKey(VK_LWIN, winPressed); + listener.processVirtualKey(VK_LWIN | VK_EXT_KEY, winPressed); } else isWinLocked = true; @@ -628,7 +629,7 @@ public class KeyboardMapper } if(winPressed && (!isWinLocked || force)) { - listener.processVirtualKey(VK_LWIN, false); + listener.processVirtualKey(VK_LWIN | VK_EXT_KEY, false); winPressed = false; } diff --git a/client/Mac/MRDPRailView.m b/client/Mac/MRDPRailView.m index 7c9220dfb..d5ed2e66d 100644 --- a/client/Mac/MRDPRailView.m +++ b/client/Mac/MRDPRailView.m @@ -545,7 +545,7 @@ MRDPRailView* g_mrdpRailView; - (void) keyDown:(NSEvent *) event { int key; - BOOL extended; + USHORT extended; DWORD vkcode; DWORD scancode; @@ -565,7 +565,7 @@ MRDPRailView* g_mrdpRailView; - (void) keyUp:(NSEvent *) event { int key; - BOOL extended; + USHORT extended; DWORD vkcode; DWORD scancode; @@ -573,7 +573,7 @@ MRDPRailView* g_mrdpRailView; vkcode = GetVirtualKeyCodeFromKeycode(key, KEYCODE_TYPE_APPLE); scancode = GetVirtualScanCodeFromVirtualKeyCode(vkcode, 4); - extended = (scancode & KBDEXT) ? KBDEXT : 0; + extended = (scancode & KBDEXT) ? TRUE : FALSE; rdp_instance->input->KeyboardEvent(rdp_instance->input, extended | KBD_FLAGS_RELEASE, scancode & 0xFF); } diff --git a/client/Mac/MRDPView.m b/client/Mac/MRDPView.m index 66df776a6..f7b428601 100644 --- a/client/Mac/MRDPView.m +++ b/client/Mac/MRDPView.m @@ -370,7 +370,7 @@ const char* error_code_names[] = - (void) keyDown:(NSEvent *) event { int key; - BOOL extended; + USHORT extended; DWORD vkcode; DWORD scancode; @@ -393,7 +393,7 @@ const char* error_code_names[] = - (void) keyUp:(NSEvent *) event { int key; - BOOL extended; + USHORT extended; DWORD vkcode; DWORD scancode; @@ -595,7 +595,7 @@ const char* error_code_names[] = * save state info for use by other methods later on ***********************************************************************/ -- (void) saveStateInfo:(freerdp *) instance:(rdpContext *) context +- (void) saveStateInfo:(freerdp *) instance :(rdpContext *) context { rdp_instance = instance; rdp_context = context; diff --git a/client/X11/xfreerdp.c b/client/X11/xfreerdp.c index 6ebfbc0ab..05520d2dd 100644 --- a/client/X11/xfreerdp.c +++ b/client/X11/xfreerdp.c @@ -64,6 +64,7 @@ #include #include +#include #include "xf_gdi.h" #include "xf_rail.h" @@ -1204,7 +1205,7 @@ int xfreerdp_run(freerdp* instance) fd_set rfds_set; fd_set wfds_set; int fd_input_event; - HANDLE input_event; + HANDLE input_event = INVALID_HANDLE_VALUE; int select_status; BOOL async_update; BOOL async_input; diff --git a/client/common/cmdline.c b/client/common/cmdline.c index db2a25ae5..28ab422aa 100644 --- a/client/common/cmdline.c +++ b/client/common/cmdline.c @@ -963,19 +963,19 @@ int freerdp_client_parse_command_line_arguments(int argc, char** argv, rdpSettin layouts = freerdp_keyboard_get_layouts(RDP_KEYBOARD_LAYOUT_TYPE_STANDARD); printf("\nKeyboard Layouts\n"); for (i = 0; layouts[i].code; i++) - printf("0x%08X\t%s\n", layouts[i].code, layouts[i].name); + printf("0x%08lX\t%s\n", layouts[i].code, layouts[i].name); free(layouts); layouts = freerdp_keyboard_get_layouts(RDP_KEYBOARD_LAYOUT_TYPE_VARIANT); printf("\nKeyboard Layout Variants\n"); for (i = 0; layouts[i].code; i++) - printf("0x%08X\t%s\n", layouts[i].code, layouts[i].name); + printf("0x%08lX\t%s\n", layouts[i].code, layouts[i].name); free(layouts); layouts = freerdp_keyboard_get_layouts(RDP_KEYBOARD_LAYOUT_TYPE_IME); printf("\nKeyboard Input Method Editors (IMEs)\n"); for (i = 0; layouts[i].code; i++) - printf("0x%08X\t%s\n", layouts[i].code, layouts[i].name); + printf("0x%08lX\t%s\n", layouts[i].code, layouts[i].name); free(layouts); printf("\n"); @@ -986,7 +986,7 @@ int freerdp_client_parse_command_line_arguments(int argc, char** argv, rdpSettin arg = CommandLineFindArgumentA(args, "v"); - if (!(arg->Flags & COMMAND_LINE_VALUE_PRESENT)) + if (!settings->ConnectionFile && !(arg->Flags & COMMAND_LINE_VALUE_PRESENT)) { printf("error: server hostname was not specified with /v:[:port]\n"); return COMMAND_LINE_ERROR_MISSING_ARGUMENT; diff --git a/client/common/compatibility.c b/client/common/compatibility.c index 3faf68aa6..f3dc49df3 100644 --- a/client/common/compatibility.c +++ b/client/common/compatibility.c @@ -186,7 +186,10 @@ int freerdp_client_old_command_line_pre_filter(void* context, int index, int arg { return -1; } - + if (_stricmp(&(argv[index])[strlen(argv[index])- 4], ".rdp") == 0) + { + return -1; + } freerdp_client_old_parse_hostname((char*) argv[index], &settings->ServerHostname, &settings->ServerPort); } else diff --git a/client/common/test/TestClientRdpFile.c b/client/common/test/TestClientRdpFile.c index 7381903b1..2f391630a 100644 --- a/client/common/test/TestClientRdpFile.c +++ b/client/common/test/TestClientRdpFile.c @@ -269,19 +269,19 @@ int TestClientRdpFile(int argc, char* argv[]) if (file->UseMultiMon != 0) { - printf("UseMultiMon mismatch: Actual: %d, Expected: %d\n", file->UseMultiMon, 0); + printf("UseMultiMon mismatch: Actual: %ld, Expected: %d\n", file->UseMultiMon, 0); return -1; } if (file->ScreenModeId != 2) { - printf("ScreenModeId mismatch: Actual: %d, Expected: %d\n", file->ScreenModeId, 2); + printf("ScreenModeId mismatch: Actual: %ld, Expected: %d\n", file->ScreenModeId, 2); return -1; } if (file->GatewayProfileUsageMethod != 1) { - printf("GatewayProfileUsageMethod mismatch: Actual: %d, Expected: %d\n", file->GatewayProfileUsageMethod, 1); + printf("GatewayProfileUsageMethod mismatch: Actual: %ld, Expected: %d\n", file->GatewayProfileUsageMethod, 1); return -1; } @@ -301,19 +301,19 @@ int TestClientRdpFile(int argc, char* argv[]) if (file->UseMultiMon != 0) { - printf("UseMultiMon mismatch: Actual: %d, Expected: %d\n", file->UseMultiMon, 0); + printf("UseMultiMon mismatch: Actual: %ld, Expected: %d\n", file->UseMultiMon, 0); return -1; } if (file->ScreenModeId != 2) { - printf("ScreenModeId mismatch: Actual: %d, Expected: %d\n", file->ScreenModeId, 2); + printf("ScreenModeId mismatch: Actual: %ld, Expected: %d\n", file->ScreenModeId, 2); return -1; } if (file->GatewayProfileUsageMethod != 1) { - printf("GatewayProfileUsageMethod mismatch: Actual: %d, Expected: %d\n", file->GatewayProfileUsageMethod, 1); + printf("GatewayProfileUsageMethod mismatch: Actual: %ld, Expected: %d\n", file->GatewayProfileUsageMethod, 1); return -1; } diff --git a/client/iOS/Misc/Utils.m b/client/iOS/Misc/Utils.m index e627ad389..58572cd76 100644 --- a/client/iOS/Misc/Utils.m +++ b/client/iOS/Misc/Utils.m @@ -223,8 +223,7 @@ NSMutableArray* FilterHistory(NSArray* history, NSString* filterStr) #pragma mark Version Info NSString* TSXAppFullVersion() { - NSDictionary* info_dict = [[NSBundle mainBundle] infoDictionary]; - return [NSString stringWithFormat:@"%@.%@ (%@)", [info_dict objectForKey:@"CFBundleShortVersionString"], [info_dict objectForKey:@"CFBundleVersion"], [NSString stringWithUTF8String:GIT_REVISION]]; + return [NSString stringWithUTF8String:GIT_REVISION]; } #pragma mark iPad/iPhone detection diff --git a/client/iOS/Models/RDPKeyboard.m b/client/iOS/Models/RDPKeyboard.m index b896596e0..17aa66543 100644 --- a/client/iOS/Models/RDPKeyboard.m +++ b/client/iOS/Models/RDPKeyboard.m @@ -204,7 +204,7 @@ // toggle windows key, returns true if pressed, otherwise false - (void)toggleWinKey { - [self sendVirtualKey:VK_LWIN up:_win_pressed]; + [self sendVirtualKey:(VK_LWIN | KBDEXT) up:_win_pressed]; _win_pressed = !_win_pressed; [self notifyDelegateModifiersChanged]; } @@ -213,7 +213,7 @@ - (void)sendEnterKeyStroke { - [self sendVirtualKeyCode:VK_RETURN]; + [self sendVirtualKeyCode:(VK_RETURN | KBDEXT)]; } - (void)sendEscapeKeyStroke diff --git a/client/iOS/Views/AdvancedKeyboardView.m b/client/iOS/Views/AdvancedKeyboardView.m index cadaf639e..f135ce9ec 100644 --- a/client/iOS/Views/AdvancedKeyboardView.m +++ b/client/iOS/Views/AdvancedKeyboardView.m @@ -52,17 +52,17 @@ struct ButtonItem functionKeysItems[24] = { @"img:icon_key_arrows", KEY_SHOW_CURSORVIEW }, { @"Tab", VK_TAB }, - { @"Ins", VK_INSERT }, - { @"Home", VK_HOME }, - { @"PgUp", VK_PRIOR }, - { @"img:icon_key_win", VK_LWIN }, + { @"Ins", VK_INSERT | KBDEXT }, + { @"Home", VK_HOME | KBDEXT }, + { @"PgUp", VK_PRIOR | KBDEXT }, + { @"img:icon_key_win", VK_LWIN | KBDEXT }, { @"123", KEY_SHOW_NUMPADVIEW }, { @"Print", VK_PRINT }, - { @"Del", VK_DELETE }, - { @"End", VK_END }, - { @"PgDn", VK_NEXT }, - { @"img:icon_key_menu", VK_APPS } + { @"Del", VK_DELETE | KBDEXT }, + { @"End", VK_END | KBDEXT }, + { @"PgDn", VK_NEXT | KBDEXT }, + { @"img:icon_key_menu", VK_APPS | KBDEXT } }; @@ -75,7 +75,7 @@ struct ButtonItem numPadKeysItems[24] = { @"9", VK_NUMPAD9 }, { @"-", VK_SUBTRACT }, - { @"/", VK_DIVIDE }, + { @"/", VK_DIVIDE | KBDEXT }, { @"*", VK_MULTIPLY }, { @"4", VK_NUMPAD4 }, { @"5", VK_NUMPAD5 }, @@ -94,7 +94,7 @@ struct ButtonItem numPadKeysItems[24] = { @"", KEY_MERGE_COLUMN }, { @"0", VK_NUMPAD0 }, { @".", VK_DECIMAL }, - { @"img:icon_key_return", VK_RETURN } + { @"img:icon_key_return", VK_RETURN | KBDEXT } }; @@ -110,23 +110,23 @@ struct ButtonItem cursorKeysItems[24] = { @"", KEY_SKIP }, { @"", KEY_SKIP }, { @"", KEY_SKIP }, - { @"img:icon_key_arrow_up", VK_UP }, + { @"img:icon_key_arrow_up", VK_UP | KBDEXT }, { @"", KEY_SKIP }, { @"", KEY_SKIP }, { @"Fn", KEY_SHOW_FUNCVIEW }, { @"", KEY_SKIP }, - { @"img:icon_key_arrow_left", VK_LEFT }, + { @"img:icon_key_arrow_left", VK_LEFT | KBDEXT }, { @"", KEY_SKIP }, - { @"img:icon_key_arrow_right", VK_RIGHT }, + { @"img:icon_key_arrow_right", VK_RIGHT | KBDEXT }, { @"img:icon_key_backspace", VK_BACK }, { @"123", KEY_SHOW_NUMPADVIEW }, { @"", KEY_SKIP }, { @"", KEY_SKIP }, - { @"img:icon_key_arrow_down", VK_DOWN }, + { @"img:icon_key_arrow_down", VK_DOWN | KBDEXT }, { @"", KEY_SKIP }, - { @"img:icon_key_return", VK_RETURN } + { @"img:icon_key_return", VK_RETURN | KBDEXT } }; diff --git a/client/iOS/iFreeRDP.plist b/client/iOS/iFreeRDP.plist index a60778e01..8727f716b 100644 --- a/client/iOS/iFreeRDP.plist +++ b/client/iOS/iFreeRDP.plist @@ -24,7 +24,7 @@ CFBundlePackageType APPL CFBundleShortVersionString - 1.0 + 1.0.0 CFBundleSignature ???? CFBundleVersion diff --git a/libfreerdp/codec/rfx_sse2.c b/libfreerdp/codec/rfx_sse2.c index 232fc522c..1737442ca 100644 --- a/libfreerdp/codec/rfx_sse2.c +++ b/libfreerdp/codec/rfx_sse2.c @@ -39,10 +39,16 @@ #define CACHE_LINE_BYTES 64 +#ifndef __clang__ +#define ATTRIBUTES __gnu_inline__, __always_inline__, __artificial__ +#else +#define ATTRIBUTES __gnu_inline__, __always_inline__ +#endif + #define _mm_between_epi16(_val, _min, _max) \ do { _val = _mm_min_epi16(_max, _mm_max_epi16(_val, _min)); } while (0) -static __inline void __attribute__((__gnu_inline__, __always_inline__, __artificial__)) +static __inline void __attribute__((ATTRIBUTES)) _mm_prefetch_buffer(char * buffer, int num_bytes) { __m128i * buf = (__m128i*) buffer; @@ -56,7 +62,7 @@ _mm_prefetch_buffer(char * buffer, int num_bytes) /* rfx_decode_ycbcr_to_rgb_sse2 code now resides in the primitives library. */ /* rfx_encode_rgb_to_ycbcr_sse2 code now resides in the primitives library. */ -static __inline void __attribute__((__gnu_inline__, __always_inline__, __artificial__)) +static __inline void __attribute__((ATTRIBUTES)) rfx_quantization_decode_block_sse2(INT16* buffer, const int buffer_size, const UINT32 factor) { __m128i a; @@ -94,7 +100,7 @@ static void rfx_quantization_decode_sse2(INT16* buffer, const UINT32* quantizati rfx_quantization_decode_block_sse2(buffer + 4032, 64, quantization_values[0] - 6); /* LL3 */ } -static __inline void __attribute__((__gnu_inline__, __always_inline__, __artificial__)) +static __inline void __attribute__((ATTRIBUTES)) rfx_quantization_encode_block_sse2(INT16* buffer, const int buffer_size, const UINT32 factor) { __m128i a; @@ -135,7 +141,7 @@ static void rfx_quantization_encode_sse2(INT16* buffer, const UINT32* quantizati rfx_quantization_encode_block_sse2(buffer, 4096, 5); } -static __inline void __attribute__((__gnu_inline__, __always_inline__, __artificial__)) +static __inline void __attribute__((ATTRIBUTES)) rfx_dwt_2d_decode_block_horiz_sse2(INT16* l, INT16* h, INT16* dst, int subband_width) { int y, n; @@ -222,7 +228,7 @@ rfx_dwt_2d_decode_block_horiz_sse2(INT16* l, INT16* h, INT16* dst, int subband_w } } -static __inline void __attribute__((__gnu_inline__, __always_inline__, __artificial__)) +static __inline void __attribute__((ATTRIBUTES)) rfx_dwt_2d_decode_block_vert_sse2(INT16* l, INT16* h, INT16* dst, int subband_width) { int x, n; @@ -303,7 +309,7 @@ rfx_dwt_2d_decode_block_vert_sse2(INT16* l, INT16* h, INT16* dst, int subband_wi } } -static __inline void __attribute__((__gnu_inline__, __always_inline__, __artificial__)) +static __inline void __attribute__((ATTRIBUTES)) rfx_dwt_2d_decode_block_sse2(INT16* buffer, INT16* idwt, int subband_width) { INT16 *hl, *lh, *hh, *ll; @@ -341,7 +347,7 @@ static void rfx_dwt_2d_decode_sse2(INT16* buffer, INT16* dwt_buffer) rfx_dwt_2d_decode_block_sse2(buffer, dwt_buffer, 32); } -static __inline void __attribute__((__gnu_inline__, __always_inline__, __artificial__)) +static __inline void __attribute__((ATTRIBUTES)) rfx_dwt_2d_encode_block_vert_sse2(INT16* src, INT16* l, INT16* h, int subband_width) { int total_width; @@ -397,7 +403,7 @@ rfx_dwt_2d_encode_block_vert_sse2(INT16* src, INT16* l, INT16* h, int subband_wi } } -static __inline void __attribute__((__gnu_inline__, __always_inline__, __artificial__)) +static __inline void __attribute__((ATTRIBUTES)) rfx_dwt_2d_encode_block_horiz_sse2(INT16* src, INT16* l, INT16* h, int subband_width) { int y; @@ -451,7 +457,7 @@ rfx_dwt_2d_encode_block_horiz_sse2(INT16* src, INT16* l, INT16* h, int subband_w } } -static __inline void __attribute__((__gnu_inline__, __always_inline__, __artificial__)) +static __inline void __attribute__((ATTRIBUTES)) rfx_dwt_2d_encode_block_sse2(INT16* buffer, INT16* dwt, int subband_width) { INT16 *hl, *lh, *hh, *ll; diff --git a/libfreerdp/gdi/test/TestGdiRop3.c b/libfreerdp/gdi/test/TestGdiRop3.c index 242f64597..5dec672a7 100644 --- a/libfreerdp/gdi/test/TestGdiRop3.c +++ b/libfreerdp/gdi/test/TestGdiRop3.c @@ -105,6 +105,7 @@ char* gdi_convert_postfix_to_infix(char* postfix) wStack* stack; int al, bl, cl, dl; char *a, *b, *c, *d; + al = bl = cl = dl =0; stack = Stack_New(FALSE); @@ -153,7 +154,7 @@ char* gdi_convert_postfix_to_infix(char* postfix) } else { - printf("invalid operator: %s\n", c[0]); + printf("invalid operator: %c\n", c[0]); } //printf("Operator: %s\n", c); diff --git a/scripts/.gitignore b/scripts/.gitignore index 6af50295b..840af4a06 100644 --- a/scripts/.gitignore +++ b/scripts/.gitignore @@ -1 +1,2 @@ !*.sh +regenerate_jni_headers.sh diff --git a/server/Sample/sfreerdp.c b/server/Sample/sfreerdp.c index 087d444cf..8331b8bd6 100644 --- a/server/Sample/sfreerdp.c +++ b/server/Sample/sfreerdp.c @@ -44,12 +44,6 @@ static char* test_pcap_file = NULL; static BOOL test_dump_rfx_realtime = TRUE; -/* HL1, LH1, HH1, HL2, LH2, HH2, HL3, LH3, HH3, LL3 */ -static const unsigned int test_quantization_values[] = -{ - 6, 6, 6, 6, 7, 7, 8, 8, 8, 9 -}; - void test_peer_context_new(freerdp_peer* client, testPeerContext* context) { context->rfx_context = rfx_context_new(); diff --git a/server/Windows/wf_directsound.c b/server/Windows/wf_directsound.c index f80d8066c..cc0518073 100644 --- a/server/Windows/wf_directsound.c +++ b/server/Windows/wf_directsound.c @@ -29,10 +29,11 @@ int wf_rdpsnd_set_latest_peer(wfPeerContext* peer) int wf_directsound_activate(rdpsnd_server_context* context) { HRESULT hr; + wfInfo* wfi; LPDIRECTSOUNDCAPTUREBUFFER pDSCB; - WAVEFORMATEX wfx = {WAVE_FORMAT_PCM, 2, 44100, 176400, 4, 16, 0}; + wfi = wf_info_get_instance(); printf("RDPSND (direct sound) Activated\n"); @@ -47,9 +48,9 @@ int wf_directsound_activate(rdpsnd_server_context* context) dscbd.dwSize = sizeof(DSCBUFFERDESC); dscbd.dwFlags = 0; - dscbd.dwBufferBytes = 176400; + dscbd.dwBufferBytes = wfi->agreed_format->nAvgBytesPerSec; dscbd.dwReserved = 0; - dscbd.lpwfxFormat = &wfx; + dscbd.lpwfxFormat = wfi->agreed_format; dscbd.dwFXCount = 0; dscbd.lpDSCFXDesc = NULL; @@ -69,8 +70,6 @@ int wf_directsound_activate(rdpsnd_server_context* context) _tprintf(_T("Created IDirectSoundCaptureBuffer8\n")); pDSCB->lpVtbl->Release(pDSCB); - context->SelectFormat(context, 4); - context->SetVolume(context, 0x7FFF, 0x7FFF); lastPos = 0; CreateThread(NULL, 0, wf_rdpsnd_directsound_thread, latestPeer, 0, NULL); diff --git a/server/Windows/wf_info.c b/server/Windows/wf_info.c index b9f268d27..57c03e8bf 100644 --- a/server/Windows/wf_info.c +++ b/server/Windows/wf_info.c @@ -225,7 +225,12 @@ void wf_info_peer_register(wfInfo* wfi, wfPeerContext* context) if (wfi->peerCount == 0) wf_dxgi_init(wfi); #else - wf_mirror_driver_activate(wfi); + if (wf_mirror_driver_activate(wfi) == FALSE) + { + context->socketClose = TRUE; + wf_info_unlock(wfi); + return; + } #endif //look trhough the array of peers until an empty slot for(i=0; i + * Copyright 2012-2013 Corey Clayton * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -49,7 +50,7 @@ BOOL wf_mirror_driver_find_display_device(wfInfo* wfi) deviceKeyPrefixLength = _tcslen(DEVICE_KEY_PREFIX); - if (_tcsncmp(deviceInfo.DeviceKey, DEVICE_KEY_PREFIX, deviceKeyPrefixLength) == 0) + if (_tcsnicmp(deviceInfo.DeviceKey, DEVICE_KEY_PREFIX, deviceKeyPrefixLength) == 0) { deviceKeyLength = _tcslen(deviceInfo.DeviceKey) - deviceKeyPrefixLength; wfi->deviceKey = (LPTSTR) malloc((deviceKeyLength + 1) * sizeof(TCHAR)); @@ -87,7 +88,7 @@ BOOL wf_mirror_driver_display_device_attach(wfInfo* wfi, DWORD mode) DWORD dwValue; status = RegOpenKeyEx(HKEY_LOCAL_MACHINE, wfi->deviceKey, - 0, KEY_READ | KEY_WOW64_64KEY, &hKey); + 0, KEY_ALL_ACCESS | KEY_WOW64_64KEY, &hKey); if (status != ERROR_SUCCESS) return FALSE; @@ -99,16 +100,22 @@ BOOL wf_mirror_driver_display_device_attach(wfInfo* wfi, DWORD mode) if (status != ERROR_SUCCESS) return FALSE; - if (dwValue == 1) + if (dwValue ^ mode) //only if we want to change modes { dwValue = mode; dwSize = sizeof(DWORD); - status = RegSetValueEx(HKEY_LOCAL_MACHINE, _T("Attach.ToDesktop"), + status = RegSetValueEx(hKey, _T("Attach.ToDesktop"), 0, REG_DWORD, (BYTE*) &dwValue, dwSize); if (status != ERROR_SUCCESS) + { + printf("Error writing registry key: %d ", status); + if (status == ERROR_ACCESS_DENIED) + printf("access denied. Do you have admin privleges?"); + printf("\n"); return FALSE; + } } return TRUE; @@ -167,10 +174,10 @@ void wf_mirror_driver_print_display_change_status(LONG status) * This function will attempt to apply the currently configured display settings * in the registry to the display driver. It will return TRUE if successful * otherwise it returns FALSE. - * If unload is nonzero then the the driver will be asked to remove itself. + * If mode is MIRROR_UNLOAD then the the driver will be asked to remove itself. */ -BOOL wf_mirror_driver_update(wfInfo* wfi, int unload) +BOOL wf_mirror_driver_update(wfInfo* wfi, int mode) { HDC dc; BOOL status; @@ -180,7 +187,7 @@ BOOL wf_mirror_driver_update(wfInfo* wfi, int unload) LONG disp_change_status; DWORD dmf_devmodewext_magic_sig = 0xDF20C0DE; - if (!unload) + if (mode == MIRROR_LOAD) { //first let's get the virtual screen dimentions wfi->virtscreen_width = GetSystemMetrics(SM_CXVIRTUALSCREEN); @@ -196,12 +203,17 @@ BOOL wf_mirror_driver_update(wfInfo* wfi, int unload) ReleaseDC(NULL, dc);*/ } - else + else if (mode == MIRROR_UNLOAD) { wfi->servscreen_width = 0; wfi->servscreen_height = 0; wfi->bitsPerPixel = 0; } + else + { + printf("Invalid mirror mode!\n"); + return FALSE; + } deviceMode = (DEVMODE*) malloc(sizeof(DEVMODE) + EXT_DEVMODE_SIZE_MAX); deviceMode->dmDriverExtra = 2 * sizeof(DWORD); @@ -238,13 +250,12 @@ BOOL wf_mirror_driver_update(wfInfo* wfi, int unload) BOOL wf_mirror_driver_map_memory(wfInfo* wfi) { int status; - GETCHANGESBUF* b; wfi->driverDC = CreateDC(wfi->deviceName, NULL, NULL, NULL); if (wfi->driverDC == NULL) { - _tprintf(_T("Could not create device driver wfi!\n")); + _tprintf(_T("Could not create device driver context!\n")); return FALSE; } @@ -256,10 +267,9 @@ BOOL wf_mirror_driver_map_memory(wfInfo* wfi) if (status <= 0) { _tprintf(_T("Failed to map shared memory from the driver! code %d\n"), status); + return FALSE; } - b = (GETCHANGESBUF*) wfi->changeBuffer; - return TRUE; } @@ -291,18 +301,39 @@ BOOL wf_mirror_driver_cleanup(wfInfo* wfi) return TRUE; } -void wf_mirror_driver_activate(wfInfo* wfi) +BOOL wf_mirror_driver_activate(wfInfo* wfi) { if (!wfi->mirrorDriverActive) { printf("Activating Mirror Driver\n"); - wf_mirror_driver_find_display_device(wfi); - wf_mirror_driver_display_device_attach(wfi, 1); - wf_mirror_driver_update(wfi, FALSE); - wf_mirror_driver_map_memory(wfi); + if (wf_mirror_driver_find_display_device(wfi) == FALSE) + { + printf("Could not find dfmirage mirror driver! Is it installed?\n"); + return FALSE; + } + + if (wf_mirror_driver_display_device_attach(wfi, 1) == FALSE) + { + printf("Could not attach display device!\n"); + return FALSE; + } + + if (wf_mirror_driver_update(wfi, MIRROR_LOAD) == FALSE) + { + printf("could not update system with new display settings!\n"); + return FALSE; + } + + if (wf_mirror_driver_map_memory(wfi) == FALSE) + { + printf("Unable to map memory for mirror driver!\n"); + return FALSE; + } wfi->mirrorDriverActive = TRUE; } + + return TRUE; } void wf_mirror_driver_deactivate(wfInfo* wfi) @@ -313,7 +344,7 @@ void wf_mirror_driver_deactivate(wfInfo* wfi) wf_mirror_driver_cleanup(wfi); wf_mirror_driver_display_device_attach(wfi, 0); - wf_mirror_driver_update(wfi, 1); + wf_mirror_driver_update(wfi, MIRROR_UNLOAD); wfi->mirrorDriverActive = FALSE; } } \ No newline at end of file diff --git a/server/Windows/wf_mirage.h b/server/Windows/wf_mirage.h index af52ab61c..9ddfb8096 100644 --- a/server/Windows/wf_mirage.h +++ b/server/Windows/wf_mirage.h @@ -3,6 +3,7 @@ * FreeRDP Windows Server * * Copyright 2012 Marc-Andre Moreau + * Copyright 2012-2013 Corey Clayton * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,6 +23,14 @@ #include "wf_interface.h" +enum +{ + MIRROR_LOAD = 0, + MIRROR_UNLOAD = 1 +}; + + + enum { DMF_ESCAPE_BASE_1_VB = 1030, @@ -202,11 +211,11 @@ typedef struct BOOL wf_mirror_driver_find_display_device(wfInfo* wfi); BOOL wf_mirror_driver_display_device_attach(wfInfo* wfi, DWORD mode); -BOOL wf_mirror_driver_update(wfInfo* wfi, int unload); +BOOL wf_mirror_driver_update(wfInfo* wfi, int mode); BOOL wf_mirror_driver_map_memory(wfInfo* wfi); BOOL wf_mirror_driver_cleanup(wfInfo* wfi); -void wf_mirror_driver_activate(wfInfo* wfi); +BOOL wf_mirror_driver_activate(wfInfo* wfi); void wf_mirror_driver_deactivate(wfInfo* wfi); #endif /* WF_MIRAGE_H */ diff --git a/server/Windows/wf_peer.c b/server/Windows/wf_peer.c index 8bca9086d..42b6f2c20 100644 --- a/server/Windows/wf_peer.c +++ b/server/Windows/wf_peer.c @@ -51,7 +51,6 @@ void wf_peer_context_free(freerdp_peer* client, wfPeerContext* context) if (context->rdpsnd) { - printf("snd_free\n"); wf_rdpsnd_lock(); context->info->snd_stop = TRUE; rdpsnd_server_context_free(context->rdpsnd); @@ -80,8 +79,7 @@ BOOL wf_peer_post_connect(freerdp_peer* client) wfi = context->info; settings = client->settings; - if ( - (get_screen_info(wfi->screenID, NULL, &wfi->servscreen_width, &wfi->servscreen_height, &wfi->bitsPerPixel) == 0) || + if ( (get_screen_info(wfi->screenID, NULL, &wfi->servscreen_width, &wfi->servscreen_height, &wfi->bitsPerPixel) == 0) || (wfi->servscreen_width == 0) || (wfi->servscreen_height == 0) || (wfi->bitsPerPixel == 0) ) @@ -92,8 +90,10 @@ BOOL wf_peer_post_connect(freerdp_peer* client) if ((settings->DesktopWidth != wfi->servscreen_width) || (settings->DesktopHeight != wfi->servscreen_height)) { + /* printf("Client requested resolution %dx%d, but will resize to %dx%d\n", settings->DesktopWidth, settings->DesktopHeight, wfi->servscreen_width, wfi->servscreen_height); + */ settings->DesktopWidth = wfi->servscreen_width; settings->DesktopHeight = wfi->servscreen_height; @@ -121,8 +121,6 @@ BOOL wf_peer_activate(freerdp_peer* client) wfInfo* wfi; wfPeerContext* context = (wfPeerContext*) client->context; - printf("PeerActivate\n"); - wfi = context->info; client->activated = TRUE; wf_update_peer_activate(wfi, context); @@ -134,14 +132,13 @@ BOOL wf_peer_activate(freerdp_peer* client) BOOL wf_peer_logon(freerdp_peer* client, SEC_WINNT_AUTH_IDENTITY* identity, BOOL automatic) { - printf("PeerLogon\n"); - + /* if (automatic) { _tprintf(_T("Logon: User:%s Domain:%s Password:%s\n"), identity->User, identity->Domain, identity->Password); } - + */ wfreerdp_server_peer_callback_event(((rdpContext*) client->context)->peer->pId, WF_SRV_CALLBACK_EVENT_AUTH); return TRUE; @@ -170,15 +167,13 @@ DWORD WINAPI wf_peer_socket_listener(LPVOID lpParam) ZeroMemory(rfds, sizeof(rfds)); context = (wfPeerContext*) client->context; - printf("PeerSocketListener\n"); - while (1) { rcount = 0; if (client->GetFileDescriptor(client, rfds, &rcount) != TRUE) { - printf("Failed to get peer file descriptor\n"); + //printf("Failed to get peer file descriptor\n"); break; } @@ -207,8 +202,6 @@ DWORD WINAPI wf_peer_socket_listener(LPVOID lpParam) break; } - printf("Exiting Peer Socket Listener Thread\n"); - return 0; } @@ -268,15 +261,12 @@ DWORD WINAPI wf_peer_main_loop(LPVOID lpParam) } context->socketEvent = CreateEvent(NULL, TRUE, FALSE, NULL); - printf("socketEvent created\n"); - + context->socketSemaphore = CreateSemaphore(NULL, 0, 1, NULL); context->socketThread = CreateThread(NULL, 0, wf_peer_socket_listener, client, 0, NULL); printf("We've got a client %s\n", client->local ? "(local)" : client->hostname); - printf("Setting Handles\n"); - nCount = 0; handles[nCount++] = context->updateEvent; handles[nCount++] = context->socketEvent; @@ -304,7 +294,7 @@ DWORD WINAPI wf_peer_main_loop(LPVOID lpParam) { if (client->CheckFileDescriptor(client) != TRUE) { - printf("Failed to check peer file descriptor\n"); + //printf("Failed to check peer file descriptor\n"); context->socketClose = TRUE; } @@ -342,7 +332,5 @@ DWORD WINAPI wf_peer_main_loop(LPVOID lpParam) freerdp_peer_context_free(client); freerdp_peer_free(client); - printf("Exiting Peer Main Loop Thread\n"); - return 0; } diff --git a/server/Windows/wf_rdpsnd.c b/server/Windows/wf_rdpsnd.c index cb24b95d1..d9b4d742c 100644 --- a/server/Windows/wf_rdpsnd.c +++ b/server/Windows/wf_rdpsnd.c @@ -40,22 +40,49 @@ #endif -static const AUDIO_FORMAT test_audio_formats[] = -{ - { WAVE_FORMAT_DVI_ADPCM, 2, 22050, 0, 1024, 4, 0, NULL }, /* IMA ADPCM, 22050 Hz, 2 channels */ - { WAVE_FORMAT_DVI_ADPCM, 1, 22050, 0, 512, 4, 0, NULL }, /* IMA ADPCM, 22050 Hz, 1 channels */ - { WAVE_FORMAT_PCM, 2, 22050, 0, 4, 16, 0, NULL }, /* PCM, 22050 Hz, 2 channels, 16 bits */ - { WAVE_FORMAT_PCM, 1, 22050, 0, 2, 16, 0, NULL }, /* PCM, 22050 Hz, 1 channels, 16 bits */ - { WAVE_FORMAT_PCM, 2, 44100, 0, 4, 16, 0, NULL }, /* PCM, 44100 Hz, 2 channels, 16 bits */ - { WAVE_FORMAT_PCM, 1, 44100, 0, 2, 16, 0, NULL }, /* PCM, 44100 Hz, 1 channels, 16 bits */ - { WAVE_FORMAT_PCM, 2, 11025, 0, 4, 16, 0, NULL }, /* PCM, 11025 Hz, 2 channels, 16 bits */ - { WAVE_FORMAT_PCM, 1, 11025, 0, 2, 16, 0, NULL }, /* PCM, 11025 Hz, 1 channels, 16 bits */ - { WAVE_FORMAT_PCM, 2, 8000, 0, 4, 16, 0, NULL }, /* PCM, 8000 Hz, 2 channels, 16 bits */ - { WAVE_FORMAT_PCM, 1, 8000, 0, 2, 16, 0, NULL } /* PCM, 8000 Hz, 1 channels, 16 bits */ +static const AUDIO_FORMAT audio_formats[] = +{ + { WAVE_FORMAT_PCM, 2, 44100, 176400, 4, 16, NULL }, + { WAVE_FORMAT_ALAW, 2, 22050, 44100, 2, 8, NULL } }; static void wf_peer_rdpsnd_activated(rdpsnd_server_context* context) { + wfInfo* wfi; + int i, j; + + wfi = wf_info_get_instance(); + + wfi->agreed_format = NULL; + printf("Client supports the following %d formats: \n", context->num_client_formats); + for(i = 0; i < context->num_client_formats; i++) + { + //TODO: improve the way we agree on a format + for (j = 0; j < context->num_server_formats; j++) + { + if ((context->client_formats[i].wFormatTag == context->server_formats[j].wFormatTag) && + (context->client_formats[i].nChannels == context->server_formats[j].nChannels) && + (context->client_formats[i].nSamplesPerSec == context->server_formats[j].nSamplesPerSec)) + { + printf("agreed on format!\n"); + wfi->agreed_format = (AUDIO_FORMAT*)&context->server_formats[j]; + break; + } + } + if (wfi->agreed_format != NULL) + break; + + } + + if (wfi->agreed_format == NULL) + { + printf("Could not agree on a audio format with the server\n"); + return; + } + + context->SelectFormat(context, i); + context->SetVolume(context, 0x7FFF, 0x7FFF); + #ifdef WITH_RDPSND_DSOUND wf_directsound_activate(context); @@ -122,9 +149,9 @@ BOOL wf_peer_rdpsnd_init(wfPeerContext* context) context->rdpsnd = rdpsnd_server_context_new(context->vcm); context->rdpsnd->data = context; - context->rdpsnd->server_formats = test_audio_formats; + context->rdpsnd->server_formats = audio_formats; context->rdpsnd->num_server_formats = - sizeof(test_audio_formats) / sizeof(test_audio_formats[0]); + sizeof(audio_formats) / sizeof(audio_formats[0]); context->rdpsnd->src_format.wFormatTag = 1; context->rdpsnd->src_format.nChannels = 2; diff --git a/server/Windows/wf_wasapi.c b/server/Windows/wf_wasapi.c index 8725d1b44..c24d495ea 100644 --- a/server/Windows/wf_wasapi.c +++ b/server/Windows/wf_wasapi.c @@ -48,9 +48,6 @@ int wf_wasapi_activate(rdpsnd_server_context* context) printf("RDPSND (WASAPI) Activated\n"); - context->SelectFormat(context, 4); - context->SetVolume(context, 0x7FFF, 0x7FFF); - CreateThread(NULL, 0, wf_rdpsnd_wasapi_thread, latestPeer, 0, NULL); return 0; @@ -213,15 +210,14 @@ DWORD WINAPI wf_rdpsnd_wasapi_thread(LPVOID lpParam) exit(1); } - //screw it, use our own format - //WAVEFORMATEX wfx = {WAVE_FORMAT_PCM, 2, 44100, 176400, 4, 16, 0}; - pwfx->wFormatTag = WAVE_FORMAT_PCM; - pwfx->nChannels = 2; - pwfx->nSamplesPerSec = 44100; - pwfx->nAvgBytesPerSec = 176400; - pwfx->nBlockAlign = 4; - pwfx->wBitsPerSample = 16; - pwfx->cbSize = 0; + + pwfx->wFormatTag = wfi->agreed_format->wFormatTag; + pwfx->nChannels = wfi->agreed_format->nChannels; + pwfx->nSamplesPerSec = wfi->agreed_format->nSamplesPerSec; + pwfx->nAvgBytesPerSec = wfi->agreed_format->nAvgBytesPerSec; + pwfx->nBlockAlign = wfi->agreed_format->nBlockAlign; + pwfx->wBitsPerSample = wfi->agreed_format->wBitsPerSample; + pwfx->cbSize = wfi->agreed_format->cbSize; hr = pAudioClient->lpVtbl->Initialize( pAudioClient, diff --git a/winpr/CMakeLists.txt b/winpr/CMakeLists.txt index 8ad2a6001..226291f57 100644 --- a/winpr/CMakeLists.txt +++ b/winpr/CMakeLists.txt @@ -73,4 +73,6 @@ add_subdirectory(include) add_subdirectory(libwinpr) -add_subdirectory(tools) +if(NOT ANDROID AND NOT IOS) + add_subdirectory(tools) +endif() diff --git a/winpr/include/winpr/sysinfo.h b/winpr/include/winpr/sysinfo.h index 679294b6a..0a6ad2e42 100644 --- a/winpr/include/winpr/sysinfo.h +++ b/winpr/include/winpr/sysinfo.h @@ -301,6 +301,7 @@ WINPR_API BOOL IsProcessorFeaturePresentEx(DWORD ProcessorFeature); #define PF_EX_ARM_VFP4 11 #define PF_EX_ARM_IDIVA 12 #define PF_EX_ARM_IDIVT 13 +#define PF_EX_AVX_PCLMULQDQ 14 /* * some "aliases" for the standard defines diff --git a/winpr/libwinpr/credui/test/TestCredUICmdLinePromptForCredentials.c b/winpr/libwinpr/credui/test/TestCredUICmdLinePromptForCredentials.c index 478498888..124d4bd63 100644 --- a/winpr/libwinpr/credui/test/TestCredUICmdLinePromptForCredentials.c +++ b/winpr/libwinpr/credui/test/TestCredUICmdLinePromptForCredentials.c @@ -26,7 +26,7 @@ int TestCredUICmdLinePromptForCredentials(int argc, char* argv[]) if (status != NO_ERROR) { - printf("CredUIPromptForCredentials unexpected status: 0x%08X\n", status); + printf("CredUIPromptForCredentials unexpected status: 0x%08lX\n", status); return -1; } diff --git a/winpr/libwinpr/credui/test/TestCredUIParseUserName.c b/winpr/libwinpr/credui/test/TestCredUIParseUserName.c index 27073d3fd..e7f7f39ba 100644 --- a/winpr/libwinpr/credui/test/TestCredUIParseUserName.c +++ b/winpr/libwinpr/credui/test/TestCredUIParseUserName.c @@ -22,7 +22,7 @@ int TestCredUIParseUserName(int argc, char* argv[]) status = CredUIParseUserName(testUserName1, User, sizeof(User) / sizeof(TCHAR), Domain, sizeof(Domain) / sizeof(TCHAR)); - printf("CredUIParseUserName status: 0x%08X\n", status); + printf("CredUIParseUserName status: 0x%08lX\n", status); _tprintf(_T("UserName: %s -> Domain: %s User: %s\n"), testUserName1, Domain, User); @@ -34,7 +34,7 @@ int TestCredUIParseUserName(int argc, char* argv[]) status = CredUIParseUserName(testUserName2, User, sizeof(User) / sizeof(TCHAR), Domain, sizeof(Domain) / sizeof(TCHAR)); - printf("CredUIParseUserName status: 0x%08X\n", status); + printf("CredUIParseUserName status: 0x%08lX\n", status); _tprintf(_T("UserName: %s -> Domain: %s User: %s\n"), testUserName2, Domain, User); diff --git a/winpr/libwinpr/credui/test/TestCredUIPromptForCredentials.c b/winpr/libwinpr/credui/test/TestCredUIPromptForCredentials.c index aa79dc662..85e142802 100644 --- a/winpr/libwinpr/credui/test/TestCredUIPromptForCredentials.c +++ b/winpr/libwinpr/credui/test/TestCredUIPromptForCredentials.c @@ -35,7 +35,7 @@ int TestCredUIPromptForCredentials(int argc, char* argv[]) if (status != NO_ERROR) { - printf("CredUIPromptForCredentials unexpected status: 0x%08X\n", status); + printf("CredUIPromptForCredentials unexpected status: 0x%08lX\n", status); return -1; } diff --git a/winpr/libwinpr/crt/string.c b/winpr/libwinpr/crt/string.c index 4015108f5..2717ac06d 100644 --- a/winpr/libwinpr/crt/string.c +++ b/winpr/libwinpr/crt/string.c @@ -98,6 +98,9 @@ size_t _wcslen(const WCHAR* str) { WCHAR* p = (WCHAR*) str; + if (!p) + return 0; + while (*p) p++; diff --git a/winpr/libwinpr/crt/test/TestAlignment.c b/winpr/libwinpr/crt/test/TestAlignment.c index 817d29b84..d520bfad6 100644 --- a/winpr/libwinpr/crt/test/TestAlignment.c +++ b/winpr/libwinpr/crt/test/TestAlignment.c @@ -26,7 +26,7 @@ int TestAlignment(int argc, char* argv[]) if (((size_t) ptr % alignment) != 0) { - printf("This pointer, %d, is not aligned on %d\n", ptr, alignment); + printf("This pointer, %p, is not aligned on %lu\n", ptr, (unsigned long)alignment); return -1; } @@ -36,7 +36,7 @@ int TestAlignment(int argc, char* argv[]) if (((size_t) ptr % alignment) != 0) { - printf("This pointer, %d, is not aligned on %d\n", ptr, alignment); + printf("This pointer, %p, is not aligned on %lu\n", ptr, (unsigned long)alignment); return -1; } @@ -54,7 +54,8 @@ int TestAlignment(int argc, char* argv[]) if (((((size_t) ptr) + offset) % alignment) != 0) { - printf("This pointer, %d, does not satisfy offset %d and alignment %d\n", ptr, offset, alignment); + printf("This pointer, %p, does not satisfy offset %lu and alignment %lu\n", ptr, (unsigned + long)offset, (unsigned long)alignment); return -1; } @@ -70,7 +71,8 @@ int TestAlignment(int argc, char* argv[]) if (((((size_t) ptr) + offset) % alignment) != 0) { - printf("This pointer, %d, does not satisfy offset %d and alignment %d\n", ptr, offset, alignment); + printf("This pointer, %p, does not satisfy offset %lu and alignment %lu\n", ptr, (unsigned + long)offset, (unsigned long)alignment); return -1; } diff --git a/winpr/libwinpr/crt/test/TestString.c b/winpr/libwinpr/crt/test/TestString.c index c19ef5e98..663e35757 100644 --- a/winpr/libwinpr/crt/test/TestString.c +++ b/winpr/libwinpr/crt/test/TestString.c @@ -38,7 +38,8 @@ int TestString(int argc, char* argv[]) if (length != testStringW_Length) { - printf("_wcslen error: length mismatch: Actual: %d, Expected: %d\n", length, testStringW_Length); + printf("_wcslen error: length mismatch: Actual: %lu, Expected: %lu\n", (unsigned long) length, + (unsigned long) testStringW_Length); return -1; } @@ -49,7 +50,8 @@ int TestString(int argc, char* argv[]) if (pos != 11) { - printf("_wcschr error: position mismatch: Actual: %d, Expected: %d\n", pos, 11); + printf("_wcschr error: position mismatch: Actual: %lu, Expected: %u\n", (unsigned long)pos, + 11); return -1; } @@ -58,7 +60,7 @@ int TestString(int argc, char* argv[]) if (pos != 29) { - printf("_wcschr error: position mismatch: Actual: %d, Expected: %d\n", pos, 29); + printf("_wcschr error: position mismatch: Actual: %lu, Expected: %u\n", (unsigned long)pos, 29); return -1; } @@ -66,7 +68,8 @@ int TestString(int argc, char* argv[]) if (p != NULL) { - printf("_wcschr error: return value mismatch: Actual: 0x%08X, Expected: 0x%08X\n", (size_t) p, (size_t) NULL); + printf("_wcschr error: return value mismatch: Actual: 0x%08lX, Expected: 0x%08lX\n", (unsigned + long) p, (unsigned long) NULL); return -1; } diff --git a/winpr/libwinpr/crt/test/TestUnicodeConversion.c b/winpr/libwinpr/crt/test/TestUnicodeConversion.c index c494be3a1..67f05e535 100644 --- a/winpr/libwinpr/crt/test/TestUnicodeConversion.c +++ b/winpr/libwinpr/crt/test/TestUnicodeConversion.c @@ -139,7 +139,7 @@ int convert_utf8_to_utf16(BYTE* lpMultiByteStr, BYTE* expected_lpWideCharStr, in if (!length) { DWORD error = GetLastError(); - printf("MultiByteToWideChar error: 0x%08X\n", error); + printf("MultiByteToWideChar error: 0x%08lX\n", error); return -1; } @@ -206,7 +206,7 @@ int convert_utf16_to_utf8(BYTE* lpWideCharStr, BYTE* expected_lpMultiByteStr, in if (!length) { DWORD error = GetLastError(); - printf("WideCharToMultiByte error: 0x%08X\n", error); + printf("WideCharToMultiByte error: 0x%08lX\n", error); return -1; } diff --git a/winpr/libwinpr/dsparse/test/.gitignore b/winpr/libwinpr/dsparse/test/.gitignore index 38ad7151f..76c112aa9 100644 --- a/winpr/libwinpr/dsparse/test/.gitignore +++ b/winpr/libwinpr/dsparse/test/.gitignore @@ -1,2 +1,4 @@ TestDs TestDs.c +TestDsParse +TestDsParse.c diff --git a/winpr/libwinpr/dsparse/test/TestDsMakeSpn.c b/winpr/libwinpr/dsparse/test/TestDsMakeSpn.c index 80e4f6a32..e01371904 100644 --- a/winpr/libwinpr/dsparse/test/TestDsMakeSpn.c +++ b/winpr/libwinpr/dsparse/test/TestDsMakeSpn.c @@ -35,7 +35,7 @@ int TestDsMakeSpn(int argc, char* argv[]) if (SpnLength != 37) { - _tprintf(_T("DsMakeSpn: SpnLength mismatch: Actual: %d, Expected: %d\n"), SpnLength, 37); + _tprintf(_T("DsMakeSpn: SpnLength mismatch: Actual: %ld, Expected: %d\n"), SpnLength, 37); return -1; } diff --git a/winpr/libwinpr/dsparse/test/TestDsParse.c b/winpr/libwinpr/dsparse/test/TestDsParse.c deleted file mode 100644 index 98a7e63f5..000000000 --- a/winpr/libwinpr/dsparse/test/TestDsParse.c +++ /dev/null @@ -1,165 +0,0 @@ -#include -#include -#include -#include - - - - -/* Forward declare test functions. */ -int TestDsMakeSpn(int, char*[]); -int TestDsCrackNames(int, char*[]); - - -/* Create map. */ - -typedef int (*MainFuncPointer)(int , char*[]); -typedef struct -{ - const char* name; - MainFuncPointer func; -} functionMapEntry; - -functionMapEntry cmakeGeneratedFunctionMapEntries[] = { - { - "TestDsMakeSpn", - TestDsMakeSpn - }, - { - "TestDsCrackNames", - TestDsCrackNames - }, - - {0,0} -}; - -/* Allocate and create a lowercased copy of string - (note that it has to be free'd manually) */ - -char* lowercase(const char *string) -{ - char *new_string, *p; - -#ifdef __cplusplus - new_string = static_cast(malloc(sizeof(char) * - static_cast(strlen(string) + 1))); -#else - new_string = (char *)(malloc(sizeof(char) * (size_t)(strlen(string) + 1))); -#endif - - if (!new_string) - { - return 0; - } - strcpy(new_string, string); - p = new_string; - while (*p != 0) - { -#ifdef __cplusplus - *p = static_cast(tolower(*p)); -#else - *p = (char)(tolower(*p)); -#endif - - ++p; - } - return new_string; -} - -int main(int ac, char *av[]) -{ - int i, NumTests, testNum, partial_match; - char *arg, *test_name; - int count; - int testToRun = -1; - - - - for(count =0; cmakeGeneratedFunctionMapEntries[count].name != 0; count++) - { - } - NumTests = count; - /* If no test name was given */ - /* process command line with user function. */ - if (ac < 2) - { - /* Ask for a test. */ - printf("Available tests:\n"); - for (i =0; i < NumTests; ++i) - { - printf("%3d. %s\n", i, cmakeGeneratedFunctionMapEntries[i].name); - } - printf("To run a test, enter the test number: "); - fflush(stdout); - testNum = 0; - if( scanf("%d", &testNum) != 1 ) - { - printf("Couldn't parse that input as a number\n"); - return -1; - } - if (testNum >= NumTests) - { - printf("%3d is an invalid test number.\n", testNum); - return -1; - } - testToRun = testNum; - ac--; - av++; - } - partial_match = 0; - arg = 0; - /* If partial match is requested. */ - if(testToRun == -1 && ac > 1) - { - partial_match = (strcmp(av[1], "-R") == 0) ? 1 : 0; - } - if (partial_match && ac < 3) - { - printf("-R needs an additional parameter.\n"); - return -1; - } - if(testToRun == -1) - { - arg = lowercase(av[1 + partial_match]); - } - for (i =0; i < NumTests && testToRun == -1; ++i) - { - test_name = lowercase(cmakeGeneratedFunctionMapEntries[i].name); - if (partial_match && strstr(test_name, arg) != NULL) - { - testToRun = i; - ac -=2; - av += 2; - } - else if (!partial_match && strcmp(test_name, arg) == 0) - { - testToRun = i; - ac--; - av++; - } - free(test_name); - } - if(arg) - { - free(arg); - } - if(testToRun != -1) - { - int result; - - result = (*cmakeGeneratedFunctionMapEntries[testToRun].func)(ac, av); - - return result; - } - - - /* Nothing was run, display the test names. */ - printf("Available tests:\n"); - for (i =0; i < NumTests; ++i) - { - printf("%3d. %s\n", i, cmakeGeneratedFunctionMapEntries[i].name); - } - printf("Failed: %s is an invalid test name.\n", av[1]); - - return -1; -} diff --git a/winpr/libwinpr/file/test/TestFileFindFirstFile.c b/winpr/libwinpr/file/test/TestFileFindFirstFile.c index d6f027a02..dab2c51f9 100644 --- a/winpr/libwinpr/file/test/TestFileFindFirstFile.c +++ b/winpr/libwinpr/file/test/TestFileFindFirstFile.c @@ -41,7 +41,7 @@ int TestFileFindFirstFile(int argc, char* argv[]) if (hFind == INVALID_HANDLE_VALUE) { - _tprintf(_T("FindFirstFile failure: %s (%d)\n"), FilePath, hFind); + _tprintf(_T("FindFirstFile failure: %s (INVALID_HANDLE_VALUE -1)\n"), FilePath); return -1; } @@ -49,7 +49,7 @@ int TestFileFindFirstFile(int argc, char* argv[]) if (_tcscmp(FindData.cFileName, testFile1) != 0) { - _tprintf(_T("FindFirstFile failure: Expected: %d, Actual: %s\n"), + _tprintf(_T("FindFirstFile failure: Expected: %s, Actual: %s\n"), testFile1, FindData.cFileName); return -1; } diff --git a/winpr/libwinpr/file/test/TestFileFindNextFile.c b/winpr/libwinpr/file/test/TestFileFindNextFile.c index 052fc7b8f..390d3a9d7 100644 --- a/winpr/libwinpr/file/test/TestFileFindNextFile.c +++ b/winpr/libwinpr/file/test/TestFileFindNextFile.c @@ -73,7 +73,7 @@ int TestFileFindNextFile(int argc, char* argv[]) if ((_tcscmp(FindData.cFileName, testDirectory2File1) != 0) && (_tcscmp(FindData.cFileName, testDirectory2File2) != 0)) { - _tprintf(_T("FindNextFile failure: Expected: %d, Actual: %s\n"), + _tprintf(_T("FindNextFile failure: Expected: %s, Actual: %s\n"), testDirectory2File2, FindData.cFileName); return -1; } diff --git a/winpr/libwinpr/path/test/TestPathAllocCombine.c b/winpr/libwinpr/path/test/TestPathAllocCombine.c index dcddb2dc9..f40547e41 100644 --- a/winpr/libwinpr/path/test/TestPathAllocCombine.c +++ b/winpr/libwinpr/path/test/TestPathAllocCombine.c @@ -23,7 +23,7 @@ int TestPathAllocCombine(int argc, char* argv[]) if (status != S_OK) { - _tprintf(_T("PathAllocCombine status: 0x%08X\n"), status); + _tprintf(_T("PathAllocCombine status: 0x%08lX\n"), status); return -1; } @@ -41,7 +41,7 @@ int TestPathAllocCombine(int argc, char* argv[]) if (status != S_OK) { - _tprintf(_T("PathAllocCombine status: 0x%08X\n"), status); + _tprintf(_T("PathAllocCombine status: 0x%08lX\n"), status); return -1; } @@ -59,7 +59,7 @@ int TestPathAllocCombine(int argc, char* argv[]) if (status != S_OK) { - _tprintf(_T("PathAllocCombine status: 0x%08X\n"), status); + _tprintf(_T("PathAllocCombine status: 0x%08lX\n"), status); return -1; } @@ -77,7 +77,7 @@ int TestPathAllocCombine(int argc, char* argv[]) if (status != S_OK) { - _tprintf(_T("PathAllocCombine status: 0x%08X\n"), status); + _tprintf(_T("PathAllocCombine status: 0x%08lX\n"), status); return -1; } diff --git a/winpr/libwinpr/path/test/TestPathCchAddBackslashEx.c b/winpr/libwinpr/path/test/TestPathCchAddBackslashEx.c index 9fe39be84..9513a3101 100644 --- a/winpr/libwinpr/path/test/TestPathCchAddBackslashEx.c +++ b/winpr/libwinpr/path/test/TestPathCchAddBackslashEx.c @@ -23,7 +23,7 @@ int TestPathCchAddBackslashEx(int argc, char* argv[]) if (status != S_OK) { - _tprintf(_T("PathCchAddBackslash status: 0x%08X\n"), status); + _tprintf(_T("PathCchAddBackslash status: 0x%08lX\n"), status); return -1; } @@ -41,7 +41,7 @@ int TestPathCchAddBackslashEx(int argc, char* argv[]) if (status != S_FALSE) { - _tprintf(_T("PathCchAddBackslash status: 0x%08X\n"), status); + _tprintf(_T("PathCchAddBackslash status: 0x%08lX\n"), status); return -1; } diff --git a/winpr/libwinpr/path/test/TestPathCchAddExtension.c b/winpr/libwinpr/path/test/TestPathCchAddExtension.c index ef766cffa..028ed84fb 100644 --- a/winpr/libwinpr/path/test/TestPathCchAddExtension.c +++ b/winpr/libwinpr/path/test/TestPathCchAddExtension.c @@ -23,7 +23,7 @@ int TestPathCchAddExtension(int argc, char* argv[]) if (status != S_OK) { - _tprintf(_T("PathCchAddExtension status: 0x%08X\n"), status); + _tprintf(_T("PathCchAddExtension status: 0x%08lX\n"), status); return -1; } @@ -41,7 +41,7 @@ int TestPathCchAddExtension(int argc, char* argv[]) if (status != S_OK) { - _tprintf(_T("PathCchAddExtension status: 0x%08X\n"), status); + _tprintf(_T("PathCchAddExtension status: 0x%08lX\n"), status); return -1; } @@ -59,7 +59,7 @@ int TestPathCchAddExtension(int argc, char* argv[]) if (status != S_FALSE) { - _tprintf(_T("PathCchAddExtension status: 0x%08X\n"), status); + _tprintf(_T("PathCchAddExtension status: 0x%08lX\n"), status); return -1; } @@ -77,7 +77,7 @@ int TestPathCchAddExtension(int argc, char* argv[]) if (status != S_FALSE) { - _tprintf(_T("PathCchAddExtension status: 0x%08X\n"), status); + _tprintf(_T("PathCchAddExtension status: 0x%08lX\n"), status); return -1; } diff --git a/winpr/libwinpr/path/test/TestPathCchAppend.c b/winpr/libwinpr/path/test/TestPathCchAppend.c index 76053c38a..6827a636e 100644 --- a/winpr/libwinpr/path/test/TestPathCchAppend.c +++ b/winpr/libwinpr/path/test/TestPathCchAppend.c @@ -24,7 +24,7 @@ int TestPathCchAppend(int argc, char* argv[]) if (status != S_OK) { - _tprintf(_T("PathCchAppend status: 0x%08X\n"), status); + _tprintf(_T("PathCchAppend status: 0x%08lX\n"), status); return -1; } @@ -42,7 +42,7 @@ int TestPathCchAppend(int argc, char* argv[]) if (status != S_OK) { - _tprintf(_T("PathCchAppend status: 0x%08X\n"), status); + _tprintf(_T("PathCchAppend status: 0x%08lX\n"), status); return -1; } @@ -60,7 +60,7 @@ int TestPathCchAppend(int argc, char* argv[]) if (status != S_OK) { - _tprintf(_T("PathCchAppend status: 0x%08X\n"), status); + _tprintf(_T("PathCchAppend status: 0x%08lX\n"), status); return -1; } @@ -78,7 +78,7 @@ int TestPathCchAppend(int argc, char* argv[]) if (status != S_OK) { - _tprintf(_T("PathCchAppend status: 0x%08X\n"), status); + _tprintf(_T("PathCchAppend status: 0x%08lX\n"), status); return -1; } diff --git a/winpr/libwinpr/path/test/TestPathCchStripPrefix.c b/winpr/libwinpr/path/test/TestPathCchStripPrefix.c index 7163c1346..ec081eb3e 100644 --- a/winpr/libwinpr/path/test/TestPathCchStripPrefix.c +++ b/winpr/libwinpr/path/test/TestPathCchStripPrefix.c @@ -28,7 +28,7 @@ int TestPathCchStripPrefix(int argc, char* argv[]) if (status != S_OK) { - _tprintf(_T("PathCchStripPrefix status: 0x%08X\n"), status); + _tprintf(_T("PathCchStripPrefix status: 0x%08lX\n"), status); return -1; } @@ -46,7 +46,7 @@ int TestPathCchStripPrefix(int argc, char* argv[]) if (status != S_FALSE) { - _tprintf(_T("PathCchStripPrefix status: 0x%08X\n"), status); + _tprintf(_T("PathCchStripPrefix status: 0x%08lX\n"), status); return -1; } diff --git a/winpr/libwinpr/pipe/test/TestPipeCreatePipe.c b/winpr/libwinpr/pipe/test/TestPipeCreatePipe.c index ecf9b36fb..902c914cd 100644 --- a/winpr/libwinpr/pipe/test/TestPipeCreatePipe.c +++ b/winpr/libwinpr/pipe/test/TestPipeCreatePipe.c @@ -36,8 +36,8 @@ int TestPipeCreatePipe(int argc, char* argv[]) if (dwWrite != sizeof(writeBuffer)) { - _tprintf(_T("WriteFile: unexpected number of bytes written: Actual: %d, Expected: %d\n"), - dwWrite, sizeof(writeBuffer)); + _tprintf(_T("WriteFile: unexpected number of bytes written: Actual: %ld, Expected: %ld\n"), + dwWrite, (long int)sizeof(writeBuffer)); return -1; } @@ -52,8 +52,8 @@ int TestPipeCreatePipe(int argc, char* argv[]) if (dwRead != sizeof(readBuffer)) { - _tprintf(_T("ReadFile: unexpected number of bytes read: Actual: %d, Expected: %d\n"), - dwWrite, sizeof(readBuffer)); + _tprintf(_T("ReadFile: unexpected number of bytes read: Actual: %ld, Expected: %ld\n"), + dwWrite, (long int)sizeof(readBuffer)); return -1; } diff --git a/winpr/libwinpr/pool/test/TestPoolWork.c b/winpr/libwinpr/pool/test/TestPoolWork.c index 72bc228ff..b830f77c3 100644 --- a/winpr/libwinpr/pool/test/TestPoolWork.c +++ b/winpr/libwinpr/pool/test/TestPoolWork.c @@ -12,7 +12,7 @@ void CALLBACK test_WorkCallback(PTP_CALLBACK_INSTANCE instance, void* context, P BYTE b[1024]; BYTE c[1024]; - printf("Hello %s: %d (thread: %d)\n", context, + printf("Hello %s: %ld (thread: %lu)\n", (char *)context, InterlockedIncrement(&count), GetCurrentThreadId()); for (index = 0; index < 100; index++) diff --git a/winpr/libwinpr/rpc/rpc.c b/winpr/libwinpr/rpc/rpc.c index 13d9862c8..07dcd3ed8 100644 --- a/winpr/libwinpr/rpc/rpc.c +++ b/winpr/libwinpr/rpc/rpc.c @@ -582,7 +582,7 @@ RPC_STATUS UuidToStringA(UUID* Uuid, RPC_CSTR* StringUuid) * xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx */ - sprintf_s((char*) *StringUuid, 36 + 1, "%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x", + sprintf_s((char*) *StringUuid, 36 + 1, "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x", Uuid->Data1, Uuid->Data2, Uuid->Data3, Uuid->Data4[0], Uuid->Data4[1], Uuid->Data4[2], Uuid->Data4[3], Uuid->Data4[4], diff --git a/winpr/libwinpr/sspi/NTLM/ntlm.c b/winpr/libwinpr/sspi/NTLM/ntlm.c index 11258adf7..adc0d0d79 100644 --- a/winpr/libwinpr/sspi/NTLM/ntlm.c +++ b/winpr/libwinpr/sspi/NTLM/ntlm.c @@ -63,6 +63,11 @@ void ntlm_SetContextWorkstation(NTLM_CONTEXT* context, char* Workstation) void ntlm_SetContextServicePrincipalNameW(NTLM_CONTEXT* context, LPWSTR ServicePrincipalName) { context->ServicePrincipalName.Length = _wcslen(ServicePrincipalName) * 2; + if (!ServicePrincipalName) + { + context->ServicePrincipalName.Buffer = NULL; + return; + } context->ServicePrincipalName.Buffer = (PWSTR) malloc(context->ServicePrincipalName.Length + 2); CopyMemory(context->ServicePrincipalName.Buffer, ServicePrincipalName, context->ServicePrincipalName.Length + 2); } diff --git a/winpr/libwinpr/sspi/test/CMakeLists.txt b/winpr/libwinpr/sspi/test/CMakeLists.txt index 694ae997f..43d133943 100644 --- a/winpr/libwinpr/sspi/test/CMakeLists.txt +++ b/winpr/libwinpr/sspi/test/CMakeLists.txt @@ -9,7 +9,6 @@ set(${MODULE_PREFIX}_TESTS TestEnumerateSecurityPackages.c TestInitializeSecurityContext.c TestAcquireCredentialsHandle.c - TestSchannel.c TestNTLM.c) create_test_sourcelist(${MODULE_PREFIX}_SRCS diff --git a/winpr/libwinpr/sspi/test/TestSchannel.c b/winpr/libwinpr/sspi/test/TestSchannel.c index 740ad5c4f..a4ef21b28 100644 --- a/winpr/libwinpr/sspi/test/TestSchannel.c +++ b/winpr/libwinpr/sspi/test/TestSchannel.c @@ -81,7 +81,7 @@ int schannel_send(PSecurityFunctionTable table, HANDLE hPipe, PCtxtHandle phCont printf("EncryptMessage status: 0x%08X\n", status); - printf("EncryptMessage output: cBuffers: %d [0]: %d / %d [1]: %d / %d [2]: %d / %d [3]: %d / %d\n", Message.cBuffers, + printf("EncryptMessage output: cBuffers: %ld [0]: %lu / %lu [1]: %lu / %lu [2]: %lu / %lu [3]: %lu / %lu\n", Message.cBuffers, Message.pBuffers[0].cbBuffer, Message.pBuffers[0].BufferType, Message.pBuffers[1].cbBuffer, Message.pBuffers[1].BufferType, Message.pBuffers[2].cbBuffer, Message.pBuffers[2].BufferType, @@ -150,7 +150,7 @@ int schannel_recv(PSecurityFunctionTable table, HANDLE hPipe, PCtxtHandle phCont printf("DecryptMessage status: 0x%08X\n", status); - printf("DecryptMessage output: cBuffers: %d [0]: %d / %d [1]: %d / %d [2]: %d / %d [3]: %d / %d\n", Message.cBuffers, + printf("DecryptMessage output: cBuffers: %ld [0]: %lu / %lu [1]: %lu / %lu [2]: %lu / %lu [3]: %lu / %lu\n", Message.cBuffers, Message.pBuffers[0].cbBuffer, Message.pBuffers[0].BufferType, Message.pBuffers[1].cbBuffer, Message.pBuffers[1].BufferType, Message.pBuffers[2].cbBuffer, Message.pBuffers[2].BufferType, @@ -159,7 +159,7 @@ int schannel_recv(PSecurityFunctionTable table, HANDLE hPipe, PCtxtHandle phCont if (status != SEC_E_OK) return -1; - printf("Decrypted Message (%d)\n", Message.pBuffers[1].cbBuffer); + printf("Decrypted Message (%ld)\n", Message.pBuffers[1].cbBuffer); winpr_HexDump((BYTE*) Message.pBuffers[1].pvBuffer, Message.pBuffers[1].cbBuffer); if (memcmp(Message.pBuffers[1].pvBuffer, test_LastDummyMessage, sizeof(test_LastDummyMessage)) == 0) @@ -330,9 +330,9 @@ static void* schannel_test_server_thread(void* arg) else if (status == SEC_E_INCOMPLETE_MESSAGE) printf("AcceptSecurityContext status: SEC_E_INCOMPLETE_MESSAGE\n"); - printf("Server cBuffers: %d pBuffers[0]: %d type: %d\n", + printf("Server cBuffers: %lu pBuffers[0]: %lu type: %lu\n", SecBufferDesc_out.cBuffers, SecBufferDesc_out.pBuffers[0].cbBuffer, SecBufferDesc_out.pBuffers[0].BufferType); - printf("Server Input cBuffers: %d pBuffers[0]: %d type: %d pBuffers[1]: %d type: %d\n", SecBufferDesc_in.cBuffers, + printf("Server Input cBuffers: %ld pBuffers[0]: %lu type: %lu pBuffers[1]: %lu type: %lu\n", SecBufferDesc_in.cBuffers, SecBufferDesc_in.pBuffers[0].cbBuffer, SecBufferDesc_in.pBuffers[0].BufferType, SecBufferDesc_in.pBuffers[1].cbBuffer, SecBufferDesc_in.pBuffers[1].BufferType); @@ -351,7 +351,7 @@ static void* schannel_test_server_thread(void* arg) if (pSecBuffer->cbBuffer > 0) { - printf("Server > Client (%d)\n", pSecBuffer->cbBuffer); + printf("Server > Client (%ld)\n", pSecBuffer->cbBuffer); winpr_HexDump((BYTE*) pSecBuffer->pvBuffer, pSecBuffer->cbBuffer); if (!WriteFile(g_ClientWritePipe, pSecBuffer->pvBuffer, pSecBuffer->cbBuffer, &NumberOfBytesWritten, NULL)) @@ -479,7 +479,7 @@ int TestSchannel(int argc, char* argv[]) * 0x800C 0x800D 0x800E 0x2400 0xAA02 0xAE06 0x2200 0x2203 */ - printf("SupportedAlgs: %d\n", SupportedAlgs.cSupportedAlgs); + printf("SupportedAlgs: %ld\n", SupportedAlgs.cSupportedAlgs); for (index = 0; index < SupportedAlgs.cSupportedAlgs; index++) { @@ -500,7 +500,7 @@ int TestSchannel(int argc, char* argv[]) /* CipherStrengths: Minimum: 40 Maximum: 256 */ - printf("CipherStrengths: Minimum: %d Maximum: %d\n", + printf("CipherStrengths: Minimum: %ld Maximum: %ld\n", CipherStrengths.dwMinimumCipherStrength, CipherStrengths.dwMaximumCipherStrength); ZeroMemory(&SupportedProtocols, sizeof(SecPkgCred_SupportedProtocols)); @@ -514,7 +514,7 @@ int TestSchannel(int argc, char* argv[]) /* SupportedProtocols: 0x208A0 */ - printf("SupportedProtocols: 0x%04X\n", SupportedProtocols.grbitProtocol); + printf("SupportedProtocols: 0x%04lX\n", SupportedProtocols.grbitProtocol); fContextReq = ISC_REQ_STREAM | ISC_REQ_SEQUENCE_DETECT | ISC_REQ_REPLAY_DETECT | @@ -547,7 +547,7 @@ int TestSchannel(int argc, char* argv[]) } g_ClientWait = TRUE; - printf("NumberOfBytesRead: %d\n", NumberOfBytesRead); + printf("NumberOfBytesRead: %ld\n", NumberOfBytesRead); SecBuffer_in[0].BufferType = SECBUFFER_TOKEN; SecBuffer_in[0].pvBuffer = lpTokenIn; @@ -587,9 +587,9 @@ int TestSchannel(int argc, char* argv[]) else if (status == SEC_E_INCOMPLETE_MESSAGE) printf("InitializeSecurityContext status: SEC_E_INCOMPLETE_MESSAGE\n"); - printf("Client Output cBuffers: %d pBuffers[0]: %d type: %d\n", + printf("Client Output cBuffers: %ld pBuffers[0]: %ld type: %ld\n", SecBufferDesc_out.cBuffers, SecBufferDesc_out.pBuffers[0].cbBuffer, SecBufferDesc_out.pBuffers[0].BufferType); - printf("Client Input cBuffers: %d pBuffers[0]: %d type: %d pBuffers[1]: %d type: %d\n", SecBufferDesc_in.cBuffers, + printf("Client Input cBuffers: %ld pBuffers[0]: %ld type: %ld pBuffers[1]: %ld type: %ld\n", SecBufferDesc_in.cBuffers, SecBufferDesc_in.pBuffers[0].cbBuffer, SecBufferDesc_in.pBuffers[0].BufferType, SecBufferDesc_in.pBuffers[1].cbBuffer, SecBufferDesc_in.pBuffers[1].BufferType); @@ -599,7 +599,7 @@ int TestSchannel(int argc, char* argv[]) if (pSecBuffer->cbBuffer > 0) { - printf("Client > Server (%d)\n", pSecBuffer->cbBuffer); + printf("Client > Server (%ld)\n", pSecBuffer->cbBuffer); winpr_HexDump((BYTE*) pSecBuffer->pvBuffer, pSecBuffer->cbBuffer); if (!WriteFile(g_ServerWritePipe, pSecBuffer->pvBuffer, pSecBuffer->cbBuffer, &NumberOfBytesWritten, NULL)) diff --git a/winpr/libwinpr/synch/wait.c b/winpr/libwinpr/synch/wait.c index 94387e506..50fcca363 100644 --- a/winpr/libwinpr/synch/wait.c +++ b/winpr/libwinpr/synch/wait.c @@ -148,7 +148,7 @@ DWORD WaitForSingleObject(HANDLE hHandle, DWORD dwMilliseconds) } else { - printf("WaitForSingleObject: unknown handle type %d\n", Type); + printf("WaitForSingleObject: unknown handle type %lu\n", Type); } return WAIT_OBJECT_0; diff --git a/winpr/libwinpr/sysinfo/sysinfo.c b/winpr/libwinpr/sysinfo/sysinfo.c index 947dc2490..7b6d86df7 100644 --- a/winpr/libwinpr/sysinfo/sysinfo.c +++ b/winpr/libwinpr/sysinfo/sysinfo.c @@ -389,18 +389,20 @@ ULONGLONG GetTickCount64(void) #define D_BIT_SSE2 (1<<26) #define D_BIT_3DN (1<<30) #define C_BIT_SSE3 (1<<0) +#define C_BIT_PCLMULQDQ (1<<1) +#define C_BIT_3DNP (1<<8) #define C_BIT_3DNP (1<<8) #define C_BIT_SSSE3 (1<<9) #define C_BIT_SSE41 (1<<19) #define C_BIT_SSE42 (1<<20) -#define C_BIT_XGETBV (1<<27) +#define C_BIT_FMA (1<<12) +#define C_BIT_AES (1<<25) +#define C_BIT_XGETBV (1<<27) #define C_BIT_AVX (1<<28) #define C_BITS_AVX (C_BIT_XGETBV|C_BIT_AVX) #define E_BIT_XMM (1<<1) #define E_BIT_YMM (1<<2) #define E_BITS_AVX (E_BIT_XMM|E_BIT_YMM) -#define C_BIT_FMA (1<<11) -#define C_BIT_AVX_AES (1<<24) static void cpuid( unsigned info, @@ -660,34 +662,38 @@ BOOL IsProcessorFeaturePresentEx(DWORD ProcessorFeature) case PF_EX_AVX: case PF_EX_FMA: case PF_EX_AVX_AES: + case PF_EX_AVX_PCLMULQDQ: { + /* Check for general AVX support */ if ((c & C_BITS_AVX) != C_BITS_AVX) - ret = FALSE; + break; - int e, f; - xgetbv(0, e, f); + int e, f; + xgetbv(0, e, f); - if ((e & E_BITS_AVX) == E_BITS_AVX) + /* XGETBV enabled for applications and XMM/YMM states enabled */ + if ((e & E_BITS_AVX) == E_BITS_AVX) + { + switch (ProcessorFeature) { - switch (ProcessorFeature) - { - case: PF_EX_AVX: - ret = TRUE; - break; - case: PF_EX_FMA: - if (c & C_BIT_FMA) - ret = TRUE; - break; - case: PF_EX_AVX_AES: - if (c & C_BIT_AVX_AES) - ret = TRUE; - break; - { + case PF_EX_AVX: ret = TRUE; break; - } - } - } + case PF_EX_FMA: + if (c & C_BIT_FMA) + ret = TRUE; + break; + case PF_EX_AVX_AES: + if (c & C_BIT_AES) + ret = TRUE; + break; + case PF_EX_AVX_PCLMULQDQ: + if (c & C_BIT_PCLMULQDQ) + ret = TRUE; + break; + } + } + } break; #endif //__AVX__ default: diff --git a/winpr/libwinpr/sysinfo/test/TestCPUFeatures.c b/winpr/libwinpr/sysinfo/test/TestCPUFeatures.c index e7c7e83ea..5f90a63f6 100644 --- a/winpr/libwinpr/sysinfo/test/TestCPUFeatures.c +++ b/winpr/libwinpr/sysinfo/test/TestCPUFeatures.c @@ -3,42 +3,45 @@ #include #include +#define TEST_FEATURE(feature) printf("\t" #feature ": %s\n", IsProcessorFeaturePresent(feature) ? "yes" : "no") +#define TEST_FEATURE_EX(feature) printf("\t" #feature ": %s\n", IsProcessorFeaturePresentEx(feature) ? "yes" : "no") int TestCPUFeatures(int argc, char* argv[]) { printf("Base CPU Flags:\n"); #ifdef _M_IX86_AMD64 - printf("\tPF_MMX_INSTRUCTIONS_AVAILABLE: %s\n", IsProcessorFeaturePresent(PF_MMX_INSTRUCTIONS_AVAILABLE) ? "yes" : "no"); - printf("\tPF_XMMI_INSTRUCTIONS_AVAILABLE: %s\n", IsProcessorFeaturePresent(PF_XMMI_INSTRUCTIONS_AVAILABLE) ? "yes" : "no"); - printf("\tPF_XMMI64_INSTRUCTIONS_AVAILABLE: %s\n", IsProcessorFeaturePresent(PF_XMMI64_INSTRUCTIONS_AVAILABLE) ? "yes" : "no"); - printf("\tPF_3DNOW_INSTRUCTIONS_AVAILABLE: %s\n", IsProcessorFeaturePresent(PF_3DNOW_INSTRUCTIONS_AVAILABLE) ? "yes" : "no"); - printf("\tPF_SSE3_INSTRUCTIONS_AVAILABLE: %s\n", IsProcessorFeaturePresent(PF_SSE3_INSTRUCTIONS_AVAILABLE) ? "yes" : "no"); + TEST_FEATURE(PF_MMX_INSTRUCTIONS_AVAILABLE); + TEST_FEATURE(PF_XMMI_INSTRUCTIONS_AVAILABLE); + TEST_FEATURE(PF_XMMI64_INSTRUCTIONS_AVAILABLE); + TEST_FEATURE(PF_3DNOW_INSTRUCTIONS_AVAILABLE); + TEST_FEATURE(PF_SSE3_INSTRUCTIONS_AVAILABLE); printf("\n"); printf("Extended CPU Flags (not found in windows API):\n"); - printf("\tPF_EX_3DNOW_PREFETCH: %s\n", IsProcessorFeaturePresentEx(PF_EX_3DNOW_PREFETCH) ? "yes" : "no"); - printf("\tPF_EX_SSSE3: %s\n", IsProcessorFeaturePresentEx(PF_EX_SSSE3) ? "yes" : "no"); - printf("\tPF_EX_SSE41: %s\n", IsProcessorFeaturePresentEx(PF_EX_SSE41) ? "yes" : "no"); - printf("\tPF_EX_SSE42: %s\n", IsProcessorFeaturePresentEx(PF_EX_SSE42) ? "yes" : "no"); - printf("\tPF_EX_AVX: %s\n", IsProcessorFeaturePresentEx(PF_EX_AVX) ? "yes" : "no"); - printf("\tPF_EX_FMA: %s\n", IsProcessorFeaturePresentEx(PF_EX_FMA) ? "yes" : "no"); - printf("\tPF_EX_AVX_AES: %s\n", IsProcessorFeaturePresentEx(PF_EX_AVX_AES) ? "yes" : "no"); + TEST_FEATURE_EX(PF_EX_3DNOW_PREFETCH); + TEST_FEATURE_EX(PF_EX_SSSE3); + TEST_FEATURE_EX(PF_EX_SSE41); + TEST_FEATURE_EX(PF_EX_SSE42); + TEST_FEATURE_EX(PF_EX_AVX); + TEST_FEATURE_EX(PF_EX_FMA); + TEST_FEATURE_EX(PF_EX_AVX_AES); + TEST_FEATURE_EX(PF_EX_AVX_PCLMULQDQ); #elif defined(_M_ARM) - printf("\tPF_ARM_NEON_INSTRUCTIONS_AVAILABLE: %s\n", IsProcessorFeaturePresent(PF_ARM_NEON_INSTRUCTIONS_AVAILABLE) ? "yes" : "no"); - printf("\tPF_ARM_THUMB: %s\n", IsProcessorFeaturePresent(PF_ARM_THUMB) ? "yes" : "no"); - printf("\tPF_ARM_VFP_32_REGISTERS_AVAILABLE: %s\n", IsProcessorFeaturePresent(PF_ARM_VFP_32_REGISTERS_AVAILABLE) ? "yes" : "no"); - printf("\tPF_ARM_DIVIDE_INSTRUCTION_AVAILABLE: %s\n", IsProcessorFeaturePresent(PF_ARM_DIVIDE_INSTRUCTION_AVAILABLE) ? "yes" : "no"); - printf("\tPF_ARM_VFP3: %s\n", IsProcessorFeaturePresent(PF_ARM_VFP3) ? "yes" : "no"); - printf("\tPF_ARM_THUMB: %s\n", IsProcessorFeaturePresent(PF_ARM_THUMB) ? "yes" : "no"); - printf("\tPF_ARM_JAZELLE: %s\n", IsProcessorFeaturePresent(PF_ARM_JAZELLE) ? "yes" : "no"); - printf("\tPF_ARM_DSP: %s\n", IsProcessorFeaturePresent(PF_ARM_DSP) ? "yes" : "no"); - printf("\tPF_ARM_THUMB2: %s\n", IsProcessorFeaturePresent(PF_ARM_THUMB2) ? "yes" : "no"); - printf("\tPF_ARM_T2EE: %s\n", IsProcessorFeaturePresent(PF_ARM_T2EE) ? "yes" : "no"); - printf("\tPF_ARM_INTEL_WMMX: %s\n", IsProcessorFeaturePresent(PF_ARM_INTEL_WMMX) ? "yes" : "no"); + TEST_FEATURE(PF_ARM_NEON_INSTRUCTIONS_AVAILABLE); + TEST_FEATURE(PF_ARM_THUMB); + TEST_FEATURE(PF_ARM_VFP_32_REGISTERS_AVAILABLE); + TEST_FEATURE(PF_ARM_DIVIDE_INSTRUCTION_AVAILABLE); + TEST_FEATURE(PF_ARM_VFP3); + TEST_FEATURE(PF_ARM_THUMB); + TEST_FEATURE(PF_ARM_JAZELLE); + TEST_FEATURE(PF_ARM_DSP); + TEST_FEATURE(PF_ARM_THUMB2); + TEST_FEATURE(PF_ARM_T2EE); + TEST_FEATURE(PF_ARM_INTEL_WMMX); printf("Extended CPU Flags (not found in windows API):\n"); - printf("\tPF_EX_ARM_VFP1: %s\n", IsProcessorFeaturePresentEx(PF_EX_ARM_VFP1) ? "yes" : "no"); - printf("\tPF_EX_ARM_VFP3D16: %s\n", IsProcessorFeaturePresentEx(PF_EX_ARM_VFP3D16) ? "yes" : "no"); - printf("\tPF_EX_ARM_VFP4: %s\n", IsProcessorFeaturePresentEx(PF_EX_ARM_VFP4) ? "yes" : "no"); - printf("\tPF_EX_ARM_IDIVA: %s\n", IsProcessorFeaturePresentEx(PF_EX_ARM_IDIVA) ? "yes" : "no"); - printf("\tPF_EX_ARM_IDIVT: %s\n", IsProcessorFeaturePresentEx(PF_EX_ARM_IDIVT) ? "yes" : "no"); + TEST_FEATURE_EX(PF_EX_ARM_VFP1); + TEST_FEATURE_EX(PF_EX_ARM_VFP3D16); + TEST_FEATURE_EX(PF_EX_ARM_VFP4); + TEST_FEATURE_EX(PF_EX_ARM_IDIVA); + TEST_FEATURE_EX(PF_EX_ARM_IDIVT); #endif printf("\n"); return 0; diff --git a/winpr/libwinpr/sysinfo/test/TestGetNativeSystemInfo.c b/winpr/libwinpr/sysinfo/test/TestGetNativeSystemInfo.c index 861809aa4..82ae5d652 100644 --- a/winpr/libwinpr/sysinfo/test/TestGetNativeSystemInfo.c +++ b/winpr/libwinpr/sysinfo/test/TestGetNativeSystemInfo.c @@ -11,13 +11,13 @@ int TestGetNativeSystemInfo(int argc, char* argv[]) printf("SystemInfo:\n"); printf("\twProcessorArchitecture: %d\n", sysinfo.wProcessorArchitecture); printf("\twReserved: %d\n", sysinfo.wReserved); - printf("\tdwPageSize: 0x%08X\n", sysinfo.dwPageSize); + printf("\tdwPageSize: 0x%08lX\n", sysinfo.dwPageSize); printf("\tlpMinimumApplicationAddress: %p\n", sysinfo.lpMinimumApplicationAddress); printf("\tlpMaximumApplicationAddress: %p\n", sysinfo.lpMaximumApplicationAddress); - printf("\tdwActiveProcessorMask: 0x%08X\n", sysinfo.dwActiveProcessorMask); - printf("\tdwNumberOfProcessors: %d\n", sysinfo.dwNumberOfProcessors); - printf("\tdwProcessorType: %d\n", sysinfo.dwProcessorType); - printf("\tdwAllocationGranularity: %d\n", sysinfo.dwAllocationGranularity); + printf("\tdwActiveProcessorMask: 0x%08llX\n", (unsigned long long)sysinfo.dwActiveProcessorMask); + printf("\tdwNumberOfProcessors: %ld\n", sysinfo.dwNumberOfProcessors); + printf("\tdwProcessorType: %ld\n", sysinfo.dwProcessorType); + printf("\tdwAllocationGranularity: %ld\n", sysinfo.dwAllocationGranularity); printf("\twProcessorLevel: %d\n", sysinfo.wProcessorLevel); printf("\twProcessorRevision: %d\n", sysinfo.wProcessorRevision); printf("\n"); diff --git a/winpr/libwinpr/utils/test/TestArrayList.c b/winpr/libwinpr/utils/test/TestArrayList.c index db0d41ec7..ef3709593 100644 --- a/winpr/libwinpr/utils/test/TestArrayList.c +++ b/winpr/libwinpr/utils/test/TestArrayList.c @@ -50,7 +50,7 @@ int TestArrayList(int argc, char* argv[]) ArrayList_RemoveAt(arrayList, 0); if (val != index) { - printf("ArrayList: shifted %d entries, expected value %d, got %d\n", index, index, val); + printf("ArrayList: shifted %d entries, expected value %d, got %ld\n", index, index, (long int)val); return -1; } } diff --git a/winpr/libwinpr/utils/test/TestCmdLine.c b/winpr/libwinpr/utils/test/TestCmdLine.c index b048de495..4302bd355 100644 --- a/winpr/libwinpr/utils/test/TestCmdLine.c +++ b/winpr/libwinpr/utils/test/TestCmdLine.c @@ -60,7 +60,8 @@ int TestCmdLine(int argc, char* argv[]) { int status; DWORD flags; - int width, height; + int width = 0; + int height = 0; COMMAND_LINE_ARGUMENT_A* arg; flags = COMMAND_LINE_SIGIL_SLASH | COMMAND_LINE_SEPARATOR_COLON | COMMAND_LINE_SIGIL_PLUS_MINUS;