FreeRDP
Loading...
Searching...
No Matches
TestClientRdpFile.c
1#include <freerdp/config.h>
2
3#include <stdio.h>
4#include <errno.h>
5
6#include <winpr/crt.h>
7#include <winpr/windows.h>
8#include <winpr/path.h>
9#include <winpr/crypto.h>
10
11#include <freerdp/client/file.h>
12#include <freerdp/channels/rdpecam.h>
13
14static const BYTE testRdpFileUTF16[] = {
15 0xff, 0xfe, 0x73, 0x00, 0x63, 0x00, 0x72, 0x00, 0x65, 0x00, 0x65, 0x00, 0x6e, 0x00, 0x20, 0x00,
16 0x6d, 0x00, 0x6f, 0x00, 0x64, 0x00, 0x65, 0x00, 0x20, 0x00, 0x69, 0x00, 0x64, 0x00, 0x3a, 0x00,
17 0x69, 0x00, 0x3a, 0x00, 0x32, 0x00, 0x0d, 0x00, 0x0a, 0x00, 0x75, 0x00, 0x73, 0x00, 0x65, 0x00,
18 0x20, 0x00, 0x6d, 0x00, 0x75, 0x00, 0x6c, 0x00, 0x74, 0x00, 0x69, 0x00, 0x6d, 0x00, 0x6f, 0x00,
19 0x6e, 0x00, 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00, 0x30, 0x00, 0x0d, 0x00, 0x0a, 0x00, 0x64, 0x00,
20 0x65, 0x00, 0x73, 0x00, 0x6b, 0x00, 0x74, 0x00, 0x6f, 0x00, 0x70, 0x00, 0x77, 0x00, 0x69, 0x00,
21 0x64, 0x00, 0x74, 0x00, 0x68, 0x00, 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00, 0x31, 0x00, 0x39, 0x00,
22 0x32, 0x00, 0x30, 0x00, 0x0d, 0x00, 0x0a, 0x00, 0x64, 0x00, 0x65, 0x00, 0x73, 0x00, 0x6b, 0x00,
23 0x74, 0x00, 0x6f, 0x00, 0x70, 0x00, 0x68, 0x00, 0x65, 0x00, 0x69, 0x00, 0x67, 0x00, 0x68, 0x00,
24 0x74, 0x00, 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00, 0x31, 0x00, 0x30, 0x00, 0x38, 0x00, 0x30, 0x00,
25 0x0d, 0x00, 0x0a, 0x00, 0x73, 0x00, 0x65, 0x00, 0x73, 0x00, 0x73, 0x00, 0x69, 0x00, 0x6f, 0x00,
26 0x6e, 0x00, 0x20, 0x00, 0x62, 0x00, 0x70, 0x00, 0x70, 0x00, 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00,
27 0x33, 0x00, 0x32, 0x00, 0x0d, 0x00, 0x0a, 0x00, 0x77, 0x00, 0x69, 0x00, 0x6e, 0x00, 0x70, 0x00,
28 0x6f, 0x00, 0x73, 0x00, 0x73, 0x00, 0x74, 0x00, 0x72, 0x00, 0x3a, 0x00, 0x73, 0x00, 0x3a, 0x00,
29 0x30, 0x00, 0x2c, 0x00, 0x31, 0x00, 0x2c, 0x00, 0x35, 0x00, 0x35, 0x00, 0x33, 0x00, 0x2c, 0x00,
30 0x32, 0x00, 0x31, 0x00, 0x31, 0x00, 0x2c, 0x00, 0x31, 0x00, 0x33, 0x00, 0x35, 0x00, 0x33, 0x00,
31 0x2c, 0x00, 0x38, 0x00, 0x31, 0x00, 0x31, 0x00, 0x0d, 0x00, 0x0a, 0x00, 0x63, 0x00, 0x6f, 0x00,
32 0x6d, 0x00, 0x70, 0x00, 0x72, 0x00, 0x65, 0x00, 0x73, 0x00, 0x73, 0x00, 0x69, 0x00, 0x6f, 0x00,
33 0x6e, 0x00, 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00, 0x31, 0x00, 0x0d, 0x00, 0x0a, 0x00, 0x6b, 0x00,
34 0x65, 0x00, 0x79, 0x00, 0x62, 0x00, 0x6f, 0x00, 0x61, 0x00, 0x72, 0x00, 0x64, 0x00, 0x68, 0x00,
35 0x6f, 0x00, 0x6f, 0x00, 0x6b, 0x00, 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00, 0x32, 0x00, 0x0d, 0x00,
36 0x0a, 0x00, 0x61, 0x00, 0x75, 0x00, 0x64, 0x00, 0x69, 0x00, 0x6f, 0x00, 0x63, 0x00, 0x61, 0x00,
37 0x70, 0x00, 0x74, 0x00, 0x75, 0x00, 0x72, 0x00, 0x65, 0x00, 0x6d, 0x00, 0x6f, 0x00, 0x64, 0x00,
38 0x65, 0x00, 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00, 0x30, 0x00, 0x0d, 0x00, 0x0a, 0x00, 0x76, 0x00,
39 0x69, 0x00, 0x64, 0x00, 0x65, 0x00, 0x6f, 0x00, 0x70, 0x00, 0x6c, 0x00, 0x61, 0x00, 0x79, 0x00,
40 0x62, 0x00, 0x61, 0x00, 0x63, 0x00, 0x6b, 0x00, 0x6d, 0x00, 0x6f, 0x00, 0x64, 0x00, 0x65, 0x00,
41 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00, 0x31, 0x00, 0x0d, 0x00, 0x0a, 0x00, 0x63, 0x00, 0x6f, 0x00,
42 0x6e, 0x00, 0x6e, 0x00, 0x65, 0x00, 0x63, 0x00, 0x74, 0x00, 0x69, 0x00, 0x6f, 0x00, 0x6e, 0x00,
43 0x20, 0x00, 0x74, 0x00, 0x79, 0x00, 0x70, 0x00, 0x65, 0x00, 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00,
44 0x37, 0x00, 0x0d, 0x00, 0x0a, 0x00, 0x6e, 0x00, 0x65, 0x00, 0x74, 0x00, 0x77, 0x00, 0x6f, 0x00,
45 0x72, 0x00, 0x6b, 0x00, 0x61, 0x00, 0x75, 0x00, 0x74, 0x00, 0x6f, 0x00, 0x64, 0x00, 0x65, 0x00,
46 0x74, 0x00, 0x65, 0x00, 0x63, 0x00, 0x74, 0x00, 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00, 0x31, 0x00,
47 0x0d, 0x00, 0x0a, 0x00, 0x62, 0x00, 0x61, 0x00, 0x6e, 0x00, 0x64, 0x00, 0x77, 0x00, 0x69, 0x00,
48 0x64, 0x00, 0x74, 0x00, 0x68, 0x00, 0x61, 0x00, 0x75, 0x00, 0x74, 0x00, 0x6f, 0x00, 0x64, 0x00,
49 0x65, 0x00, 0x74, 0x00, 0x65, 0x00, 0x63, 0x00, 0x74, 0x00, 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00,
50 0x31, 0x00, 0x0d, 0x00, 0x0a, 0x00, 0x64, 0x00, 0x69, 0x00, 0x73, 0x00, 0x70, 0x00, 0x6c, 0x00,
51 0x61, 0x00, 0x79, 0x00, 0x63, 0x00, 0x6f, 0x00, 0x6e, 0x00, 0x6e, 0x00, 0x65, 0x00, 0x63, 0x00,
52 0x74, 0x00, 0x69, 0x00, 0x6f, 0x00, 0x6e, 0x00, 0x62, 0x00, 0x61, 0x00, 0x72, 0x00, 0x3a, 0x00,
53 0x69, 0x00, 0x3a, 0x00, 0x31, 0x00, 0x0d, 0x00, 0x0a, 0x00, 0x65, 0x00, 0x6e, 0x00, 0x61, 0x00,
54 0x62, 0x00, 0x6c, 0x00, 0x65, 0x00, 0x77, 0x00, 0x6f, 0x00, 0x72, 0x00, 0x6b, 0x00, 0x73, 0x00,
55 0x70, 0x00, 0x61, 0x00, 0x63, 0x00, 0x65, 0x00, 0x72, 0x00, 0x65, 0x00, 0x63, 0x00, 0x6f, 0x00,
56 0x6e, 0x00, 0x6e, 0x00, 0x65, 0x00, 0x63, 0x00, 0x74, 0x00, 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00,
57 0x30, 0x00, 0x0d, 0x00, 0x0a, 0x00, 0x64, 0x00, 0x69, 0x00, 0x73, 0x00, 0x61, 0x00, 0x62, 0x00,
58 0x6c, 0x00, 0x65, 0x00, 0x20, 0x00, 0x77, 0x00, 0x61, 0x00, 0x6c, 0x00, 0x6c, 0x00, 0x70, 0x00,
59 0x61, 0x00, 0x70, 0x00, 0x65, 0x00, 0x72, 0x00, 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00, 0x30, 0x00,
60 0x0d, 0x00, 0x0a, 0x00, 0x61, 0x00, 0x6c, 0x00, 0x6c, 0x00, 0x6f, 0x00, 0x77, 0x00, 0x20, 0x00,
61 0x66, 0x00, 0x6f, 0x00, 0x6e, 0x00, 0x74, 0x00, 0x20, 0x00, 0x73, 0x00, 0x6d, 0x00, 0x6f, 0x00,
62 0x6f, 0x00, 0x74, 0x00, 0x68, 0x00, 0x69, 0x00, 0x6e, 0x00, 0x67, 0x00, 0x3a, 0x00, 0x69, 0x00,
63 0x3a, 0x00, 0x30, 0x00, 0x0d, 0x00, 0x0a, 0x00, 0x61, 0x00, 0x6c, 0x00, 0x6c, 0x00, 0x6f, 0x00,
64 0x77, 0x00, 0x20, 0x00, 0x64, 0x00, 0x65, 0x00, 0x73, 0x00, 0x6b, 0x00, 0x74, 0x00, 0x6f, 0x00,
65 0x70, 0x00, 0x20, 0x00, 0x63, 0x00, 0x6f, 0x00, 0x6d, 0x00, 0x70, 0x00, 0x6f, 0x00, 0x73, 0x00,
66 0x69, 0x00, 0x74, 0x00, 0x69, 0x00, 0x6f, 0x00, 0x6e, 0x00, 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00,
67 0x30, 0x00, 0x0d, 0x00, 0x0a, 0x00, 0x64, 0x00, 0x69, 0x00, 0x73, 0x00, 0x61, 0x00, 0x62, 0x00,
68 0x6c, 0x00, 0x65, 0x00, 0x20, 0x00, 0x66, 0x00, 0x75, 0x00, 0x6c, 0x00, 0x6c, 0x00, 0x20, 0x00,
69 0x77, 0x00, 0x69, 0x00, 0x6e, 0x00, 0x64, 0x00, 0x6f, 0x00, 0x77, 0x00, 0x20, 0x00, 0x64, 0x00,
70 0x72, 0x00, 0x61, 0x00, 0x67, 0x00, 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00, 0x31, 0x00, 0x0d, 0x00,
71 0x0a, 0x00, 0x64, 0x00, 0x69, 0x00, 0x73, 0x00, 0x61, 0x00, 0x62, 0x00, 0x6c, 0x00, 0x65, 0x00,
72 0x20, 0x00, 0x6d, 0x00, 0x65, 0x00, 0x6e, 0x00, 0x75, 0x00, 0x20, 0x00, 0x61, 0x00, 0x6e, 0x00,
73 0x69, 0x00, 0x6d, 0x00, 0x73, 0x00, 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00, 0x31, 0x00, 0x0d, 0x00,
74 0x0a, 0x00, 0x64, 0x00, 0x69, 0x00, 0x73, 0x00, 0x61, 0x00, 0x62, 0x00, 0x6c, 0x00, 0x65, 0x00,
75 0x20, 0x00, 0x74, 0x00, 0x68, 0x00, 0x65, 0x00, 0x6d, 0x00, 0x65, 0x00, 0x73, 0x00, 0x3a, 0x00,
76 0x69, 0x00, 0x3a, 0x00, 0x30, 0x00, 0x0d, 0x00, 0x0a, 0x00, 0x64, 0x00, 0x69, 0x00, 0x73, 0x00,
77 0x61, 0x00, 0x62, 0x00, 0x6c, 0x00, 0x65, 0x00, 0x20, 0x00, 0x63, 0x00, 0x75, 0x00, 0x72, 0x00,
78 0x73, 0x00, 0x6f, 0x00, 0x72, 0x00, 0x20, 0x00, 0x73, 0x00, 0x65, 0x00, 0x74, 0x00, 0x74, 0x00,
79 0x69, 0x00, 0x6e, 0x00, 0x67, 0x00, 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00, 0x30, 0x00, 0x0d, 0x00,
80 0x0a, 0x00, 0x62, 0x00, 0x69, 0x00, 0x74, 0x00, 0x6d, 0x00, 0x61, 0x00, 0x70, 0x00, 0x63, 0x00,
81 0x61, 0x00, 0x63, 0x00, 0x68, 0x00, 0x65, 0x00, 0x70, 0x00, 0x65, 0x00, 0x72, 0x00, 0x73, 0x00,
82 0x69, 0x00, 0x73, 0x00, 0x74, 0x00, 0x65, 0x00, 0x6e, 0x00, 0x61, 0x00, 0x62, 0x00, 0x6c, 0x00,
83 0x65, 0x00, 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00, 0x31, 0x00, 0x0d, 0x00, 0x0a, 0x00, 0x66, 0x00,
84 0x75, 0x00, 0x6c, 0x00, 0x6c, 0x00, 0x20, 0x00, 0x61, 0x00, 0x64, 0x00, 0x64, 0x00, 0x72, 0x00,
85 0x65, 0x00, 0x73, 0x00, 0x73, 0x00, 0x3a, 0x00, 0x73, 0x00, 0x3a, 0x00, 0x4c, 0x00, 0x41, 0x00,
86 0x42, 0x00, 0x31, 0x00, 0x2d, 0x00, 0x57, 0x00, 0x37, 0x00, 0x2d, 0x00, 0x44, 0x00, 0x4d, 0x00,
87 0x2d, 0x00, 0x30, 0x00, 0x31, 0x00, 0x2e, 0x00, 0x6c, 0x00, 0x61, 0x00, 0x62, 0x00, 0x31, 0x00,
88 0x2e, 0x00, 0x61, 0x00, 0x77, 0x00, 0x61, 0x00, 0x6b, 0x00, 0x65, 0x00, 0x2e, 0x00, 0x6c, 0x00,
89 0x6f, 0x00, 0x63, 0x00, 0x61, 0x00, 0x6c, 0x00, 0x0d, 0x00, 0x0a, 0x00, 0x61, 0x00, 0x75, 0x00,
90 0x64, 0x00, 0x69, 0x00, 0x6f, 0x00, 0x6d, 0x00, 0x6f, 0x00, 0x64, 0x00, 0x65, 0x00, 0x3a, 0x00,
91 0x69, 0x00, 0x3a, 0x00, 0x30, 0x00, 0x0d, 0x00, 0x0a, 0x00, 0x72, 0x00, 0x65, 0x00, 0x64, 0x00,
92 0x69, 0x00, 0x72, 0x00, 0x65, 0x00, 0x63, 0x00, 0x74, 0x00, 0x70, 0x00, 0x72, 0x00, 0x69, 0x00,
93 0x6e, 0x00, 0x74, 0x00, 0x65, 0x00, 0x72, 0x00, 0x73, 0x00, 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00,
94 0x31, 0x00, 0x0d, 0x00, 0x0a, 0x00, 0x72, 0x00, 0x65, 0x00, 0x64, 0x00, 0x69, 0x00, 0x72, 0x00,
95 0x65, 0x00, 0x63, 0x00, 0x74, 0x00, 0x63, 0x00, 0x6f, 0x00, 0x6d, 0x00, 0x70, 0x00, 0x6f, 0x00,
96 0x72, 0x00, 0x74, 0x00, 0x73, 0x00, 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00, 0x30, 0x00, 0x0d, 0x00,
97 0x0a, 0x00, 0x72, 0x00, 0x65, 0x00, 0x64, 0x00, 0x69, 0x00, 0x72, 0x00, 0x65, 0x00, 0x63, 0x00,
98 0x74, 0x00, 0x73, 0x00, 0x6d, 0x00, 0x61, 0x00, 0x72, 0x00, 0x74, 0x00, 0x63, 0x00, 0x61, 0x00,
99 0x72, 0x00, 0x64, 0x00, 0x73, 0x00, 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00, 0x31, 0x00, 0x0d, 0x00,
100 0x0a, 0x00, 0x72, 0x00, 0x65, 0x00, 0x64, 0x00, 0x69, 0x00, 0x72, 0x00, 0x65, 0x00, 0x63, 0x00,
101 0x74, 0x00, 0x63, 0x00, 0x6c, 0x00, 0x69, 0x00, 0x70, 0x00, 0x62, 0x00, 0x6f, 0x00, 0x61, 0x00,
102 0x72, 0x00, 0x64, 0x00, 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00, 0x31, 0x00, 0x0d, 0x00, 0x0a, 0x00,
103 0x72, 0x00, 0x65, 0x00, 0x64, 0x00, 0x69, 0x00, 0x72, 0x00, 0x65, 0x00, 0x63, 0x00, 0x74, 0x00,
104 0x70, 0x00, 0x6f, 0x00, 0x73, 0x00, 0x64, 0x00, 0x65, 0x00, 0x76, 0x00, 0x69, 0x00, 0x63, 0x00,
105 0x65, 0x00, 0x73, 0x00, 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00, 0x30, 0x00, 0x0d, 0x00, 0x0a, 0x00,
106 0x61, 0x00, 0x75, 0x00, 0x74, 0x00, 0x6f, 0x00, 0x72, 0x00, 0x65, 0x00, 0x63, 0x00, 0x6f, 0x00,
107 0x6e, 0x00, 0x6e, 0x00, 0x65, 0x00, 0x63, 0x00, 0x74, 0x00, 0x69, 0x00, 0x6f, 0x00, 0x6e, 0x00,
108 0x20, 0x00, 0x65, 0x00, 0x6e, 0x00, 0x61, 0x00, 0x62, 0x00, 0x6c, 0x00, 0x65, 0x00, 0x64, 0x00,
109 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00, 0x31, 0x00, 0x0d, 0x00, 0x0a, 0x00, 0x61, 0x00, 0x75, 0x00,
110 0x74, 0x00, 0x68, 0x00, 0x65, 0x00, 0x6e, 0x00, 0x74, 0x00, 0x69, 0x00, 0x63, 0x00, 0x61, 0x00,
111 0x74, 0x00, 0x69, 0x00, 0x6f, 0x00, 0x6e, 0x00, 0x20, 0x00, 0x6c, 0x00, 0x65, 0x00, 0x76, 0x00,
112 0x65, 0x00, 0x6c, 0x00, 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00, 0x32, 0x00, 0x0d, 0x00, 0x0a, 0x00,
113 0x70, 0x00, 0x72, 0x00, 0x6f, 0x00, 0x6d, 0x00, 0x70, 0x00, 0x74, 0x00, 0x20, 0x00, 0x66, 0x00,
114 0x6f, 0x00, 0x72, 0x00, 0x20, 0x00, 0x63, 0x00, 0x72, 0x00, 0x65, 0x00, 0x64, 0x00, 0x65, 0x00,
115 0x6e, 0x00, 0x74, 0x00, 0x69, 0x00, 0x61, 0x00, 0x6c, 0x00, 0x73, 0x00, 0x3a, 0x00, 0x69, 0x00,
116 0x3a, 0x00, 0x30, 0x00, 0x0d, 0x00, 0x0a, 0x00, 0x6e, 0x00, 0x65, 0x00, 0x67, 0x00, 0x6f, 0x00,
117 0x74, 0x00, 0x69, 0x00, 0x61, 0x00, 0x74, 0x00, 0x65, 0x00, 0x20, 0x00, 0x73, 0x00, 0x65, 0x00,
118 0x63, 0x00, 0x75, 0x00, 0x72, 0x00, 0x69, 0x00, 0x74, 0x00, 0x79, 0x00, 0x20, 0x00, 0x6c, 0x00,
119 0x61, 0x00, 0x79, 0x00, 0x65, 0x00, 0x72, 0x00, 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00, 0x31, 0x00,
120 0x0d, 0x00, 0x0a, 0x00, 0x72, 0x00, 0x65, 0x00, 0x6d, 0x00, 0x6f, 0x00, 0x74, 0x00, 0x65, 0x00,
121 0x61, 0x00, 0x70, 0x00, 0x70, 0x00, 0x6c, 0x00, 0x69, 0x00, 0x63, 0x00, 0x61, 0x00, 0x74, 0x00,
122 0x69, 0x00, 0x6f, 0x00, 0x6e, 0x00, 0x6d, 0x00, 0x6f, 0x00, 0x64, 0x00, 0x65, 0x00, 0x3a, 0x00,
123 0x69, 0x00, 0x3a, 0x00, 0x30, 0x00, 0x0d, 0x00, 0x0a, 0x00, 0x61, 0x00, 0x6c, 0x00, 0x74, 0x00,
124 0x65, 0x00, 0x72, 0x00, 0x6e, 0x00, 0x61, 0x00, 0x74, 0x00, 0x65, 0x00, 0x20, 0x00, 0x73, 0x00,
125 0x68, 0x00, 0x65, 0x00, 0x6c, 0x00, 0x6c, 0x00, 0x3a, 0x00, 0x73, 0x00, 0x3a, 0x00, 0x0d, 0x00,
126 0x0a, 0x00, 0x73, 0x00, 0x68, 0x00, 0x65, 0x00, 0x6c, 0x00, 0x6c, 0x00, 0x20, 0x00, 0x77, 0x00,
127 0x6f, 0x00, 0x72, 0x00, 0x6b, 0x00, 0x69, 0x00, 0x6e, 0x00, 0x67, 0x00, 0x20, 0x00, 0x64, 0x00,
128 0x69, 0x00, 0x72, 0x00, 0x65, 0x00, 0x63, 0x00, 0x74, 0x00, 0x6f, 0x00, 0x72, 0x00, 0x79, 0x00,
129 0x3a, 0x00, 0x73, 0x00, 0x3a, 0x00, 0x0d, 0x00, 0x0a, 0x00, 0x67, 0x00, 0x61, 0x00, 0x74, 0x00,
130 0x65, 0x00, 0x77, 0x00, 0x61, 0x00, 0x79, 0x00, 0x68, 0x00, 0x6f, 0x00, 0x73, 0x00, 0x74, 0x00,
131 0x6e, 0x00, 0x61, 0x00, 0x6d, 0x00, 0x65, 0x00, 0x3a, 0x00, 0x73, 0x00, 0x3a, 0x00, 0x4c, 0x00,
132 0x41, 0x00, 0x42, 0x00, 0x31, 0x00, 0x2d, 0x00, 0x57, 0x00, 0x32, 0x00, 0x4b, 0x00, 0x38, 0x00,
133 0x52, 0x00, 0x32, 0x00, 0x2d, 0x00, 0x47, 0x00, 0x57, 0x00, 0x2e, 0x00, 0x6c, 0x00, 0x61, 0x00,
134 0x62, 0x00, 0x31, 0x00, 0x2e, 0x00, 0x61, 0x00, 0x77, 0x00, 0x61, 0x00, 0x6b, 0x00, 0x65, 0x00,
135 0x2e, 0x00, 0x6c, 0x00, 0x6f, 0x00, 0x63, 0x00, 0x61, 0x00, 0x6c, 0x00, 0x0d, 0x00, 0x0a, 0x00,
136 0x67, 0x00, 0x61, 0x00, 0x74, 0x00, 0x65, 0x00, 0x77, 0x00, 0x61, 0x00, 0x79, 0x00, 0x75, 0x00,
137 0x73, 0x00, 0x61, 0x00, 0x67, 0x00, 0x65, 0x00, 0x6d, 0x00, 0x65, 0x00, 0x74, 0x00, 0x68, 0x00,
138 0x6f, 0x00, 0x64, 0x00, 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00, 0x31, 0x00, 0x0d, 0x00, 0x0a, 0x00,
139 0x67, 0x00, 0x61, 0x00, 0x74, 0x00, 0x65, 0x00, 0x77, 0x00, 0x61, 0x00, 0x79, 0x00, 0x63, 0x00,
140 0x72, 0x00, 0x65, 0x00, 0x64, 0x00, 0x65, 0x00, 0x6e, 0x00, 0x74, 0x00, 0x69, 0x00, 0x61, 0x00,
141 0x6c, 0x00, 0x73, 0x00, 0x73, 0x00, 0x6f, 0x00, 0x75, 0x00, 0x72, 0x00, 0x63, 0x00, 0x65, 0x00,
142 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00, 0x30, 0x00, 0x0d, 0x00, 0x0a, 0x00, 0x67, 0x00, 0x61, 0x00,
143 0x74, 0x00, 0x65, 0x00, 0x77, 0x00, 0x61, 0x00, 0x79, 0x00, 0x70, 0x00, 0x72, 0x00, 0x6f, 0x00,
144 0x66, 0x00, 0x69, 0x00, 0x6c, 0x00, 0x65, 0x00, 0x75, 0x00, 0x73, 0x00, 0x61, 0x00, 0x67, 0x00,
145 0x65, 0x00, 0x6d, 0x00, 0x65, 0x00, 0x74, 0x00, 0x68, 0x00, 0x6f, 0x00, 0x64, 0x00, 0x3a, 0x00,
146 0x69, 0x00, 0x3a, 0x00, 0x31, 0x00, 0x0d, 0x00, 0x0a, 0x00, 0x70, 0x00, 0x72, 0x00, 0x6f, 0x00,
147 0x6d, 0x00, 0x70, 0x00, 0x74, 0x00, 0x63, 0x00, 0x72, 0x00, 0x65, 0x00, 0x64, 0x00, 0x65, 0x00,
148 0x6e, 0x00, 0x74, 0x00, 0x69, 0x00, 0x61, 0x00, 0x6c, 0x00, 0x6f, 0x00, 0x6e, 0x00, 0x63, 0x00,
149 0x65, 0x00, 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00, 0x31, 0x00, 0x0d, 0x00, 0x0a, 0x00, 0x75, 0x00,
150 0x73, 0x00, 0x65, 0x00, 0x20, 0x00, 0x72, 0x00, 0x65, 0x00, 0x64, 0x00, 0x69, 0x00, 0x72, 0x00,
151 0x65, 0x00, 0x63, 0x00, 0x74, 0x00, 0x69, 0x00, 0x6f, 0x00, 0x6e, 0x00, 0x20, 0x00, 0x73, 0x00,
152 0x65, 0x00, 0x72, 0x00, 0x76, 0x00, 0x65, 0x00, 0x72, 0x00, 0x20, 0x00, 0x6e, 0x00, 0x61, 0x00,
153 0x6d, 0x00, 0x65, 0x00, 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00, 0x30, 0x00, 0x0d, 0x00, 0x0a, 0x00,
154 0x72, 0x00, 0x64, 0x00, 0x67, 0x00, 0x69, 0x00, 0x73, 0x00, 0x6b, 0x00, 0x64, 0x00, 0x63, 0x00,
155 0x70, 0x00, 0x72, 0x00, 0x6f, 0x00, 0x78, 0x00, 0x79, 0x00, 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00,
156 0x30, 0x00, 0x0d, 0x00, 0x0a, 0x00, 0x6b, 0x00, 0x64, 0x00, 0x63, 0x00, 0x70, 0x00, 0x72, 0x00,
157 0x6f, 0x00, 0x78, 0x00, 0x79, 0x00, 0x6e, 0x00, 0x61, 0x00, 0x6d, 0x00, 0x65, 0x00, 0x3a, 0x00,
158 0x73, 0x00, 0x3a, 0x00, 0x0d, 0x00, 0x0a, 0x00, 0x64, 0x00, 0x72, 0x00, 0x69, 0x00, 0x76, 0x00,
159 0x65, 0x00, 0x73, 0x00, 0x74, 0x00, 0x6f, 0x00, 0x72, 0x00, 0x65, 0x00, 0x64, 0x00, 0x69, 0x00,
160 0x72, 0x00, 0x65, 0x00, 0x63, 0x00, 0x74, 0x00, 0x3a, 0x00, 0x73, 0x00, 0x3a, 0x00, 0x2a, 0x00,
161 0x0d, 0x00, 0x0a, 0x00, 0x75, 0x00, 0x73, 0x00, 0x65, 0x00, 0x72, 0x00, 0x6e, 0x00, 0x61, 0x00,
162 0x6d, 0x00, 0x65, 0x00, 0x3a, 0x00, 0x73, 0x00, 0x3a, 0x00, 0x4c, 0x00, 0x41, 0x00, 0x42, 0x00,
163 0x31, 0x00, 0x5c, 0x00, 0x4a, 0x00, 0x6f, 0x00, 0x68, 0x00, 0x6e, 0x00, 0x44, 0x00, 0x6f, 0x00,
164 0x65, 0x00, 0x0d, 0x00, 0x0a, 0x00
165};
166
167#if defined(CHANNEL_RDPECAM_CLIENT)
168static const char* camera_args[] = { RDPECAM_DVC_CHANNEL_NAME,
169 "device:*",
170 "device:\\?\\usb#vid_0bda&pid_58b0&mi",
171 "device:-\\?\\usb#vid_0bdc&pid_58b1&mi",
172 "encode:1",
173 "quality:2" };
174#endif
175
176#if defined(CHANNEL_URBDRC_CLIENT)
177static const char* urbdrc_args[] = { "urbdrc", "device:*", "device:USBInstanceID:someid",
178 "device:{72631e54-78a4-11d0-bcf7-00aa00b7b32a}" };
179#endif
180
181static char testRdpFileUTF8[] =
182 "screen mode id:i:2\n"
183 "use multimon:i:0\n"
184 "desktopwidth:i:1920\n"
185 "desktopheight:i:1080\n"
186 "dynamic resolution:i:1080\n"
187 "desktopscalefactor:i:1080\n"
188 "redirected video capture encoding quality:i:2\n"
189 "encode redirected video capture:i:1\n"
190 "camerastoredirect:s:*,\\?\\usb#vid_0bda&pid_58b0&mi,-\\?\\usb#vid_0bdc&pid_58b1&mi\n"
191 "usbdevicestoredirect:s:*,USBInstanceID:someid,{72631e54-78a4-11d0-bcf7-00aa00b7b32a}\n"
192 "selectedmonitors:s:3,2,42,23"
193 "session bpp:i:32\n"
194 "winposstr:s:0,1,553,211,1353,811\n"
195 "compression:i:1\n"
196 "keyboardhook:i:2\n"
197 "audiocapturemode:i:0\n"
198 "videoplaybackmode:i:2\n"
199 "connection type:i:7\n"
200 "networkautodetect:i:1\n"
201 "bandwidthautodetect:i:1\n"
202 "displayconnectionbar:i:1\n"
203 "enableworkspacereconnect:i:0\n"
204 "disable wallpaper:i:0\n"
205 "allow font smoothing:i:0\n"
206 "allow desktop composition:i:0\n"
207 "disable full window drag:i:1\n"
208 "disable menu anims:i:1\n"
209 "disable themes:i:0\n"
210 "disable cursor setting:i:0\n"
211 "bitmapcachepersistenable:i:1\n"
212 "full address:s:LAB1-W7-DM-01.lab1.awake.local\n"
213 "alternate full address:s:LAB1-W7-DM-01.lab1.awake.global\n"
214 "audiomode:i:0\n"
215 "redirectprinters:i:1\n"
216 "redirectcomports:i:0\n"
217 "redirectsmartcards:i:1\n"
218 "redirectclipboard:i:1\n"
219 "redirectposdevices:i:0\n"
220 "autoreconnection enabled:i:1\n"
221 "authentication level:i:2\n"
222 "prompt for credentials:i:0\n"
223 "negotiate security layer:i:1\n"
224 "remoteapplicationmode:i:0\n"
225 "alternate shell:s:\n"
226 "shell working directory:s:\n"
227 "gatewayhostname:s:LAB1-W2K8R2-GW.lab1.awake.local\n"
228 "gatewayusagemethod:i:1\n"
229 "gatewaycredentialssource:i:0\n"
230 "gatewayprofileusagemethod:i:1\n"
231 "promptcredentialonce:i:1\n"
232 "use redirection server name:i:0\n"
233 "rdgiskdcproxy:i:0\n"
234 "kdcproxyname:s:\n"
235 "drivestoredirect:s:*\n"
236 "username:s:LAB1\\JohnDoe\n"
237 "vendor integer:i:123\n"
238 "vendor string:s:microsoft\n";
239
240static char* append(const char* fmt, ...)
241{
242 int rc = 0;
243 char* dst = nullptr;
244 va_list ap = WINPR_C_ARRAY_INIT;
245
246 va_start(ap, fmt);
247 rc = vsnprintf(nullptr, 0, fmt, ap);
248 va_end(ap);
249 if (rc < 0)
250 return nullptr;
251 dst = malloc((size_t)rc + 1);
252 if (!dst)
253 return nullptr;
254
255 va_start(ap, fmt);
256 rc = vsnprintf(dst, (size_t)rc + 1, fmt, ap);
257 va_end(ap);
258 if (rc < 0)
259 {
260 free(dst);
261 return nullptr;
262 }
263 return dst;
264}
265
266static FILE* test_fopen(const char* name, const char* mode)
267{
268#ifndef TEST_SOURCE_DIR
269#error "TEST_SOURCE_DIR must be defined to the test source directory"
270#endif
271
272 char* path = GetCombinedPath(TEST_SOURCE_DIR, name);
273 FILE* fp = winpr_fopen(path, mode);
274 free(path);
275 return fp;
276}
277
278static void* read_rdp_data(const char* name, size_t* plen)
279{
280 BOOL success = FALSE;
281 char* json = nullptr;
282 FILE* fp = test_fopen(name, "r");
283 if (!fp)
284 goto fail;
285
286 if (fseek(fp, 0, SEEK_END) != 0)
287 goto fail;
288
289 const INT64 pos = _ftelli64(fp);
290 if (pos < 0)
291 goto fail;
292
293 if (fseek(fp, 0, SEEK_SET) != 0)
294 goto fail;
295
296 const size_t upos = WINPR_CXX_COMPAT_CAST(size_t, pos);
297 json = calloc(1ULL + upos, sizeof(char));
298 if (!json)
299 goto fail;
300 if (fread(json, 1, pos, fp) != pos)
301 goto fail;
302
303 *plen = upos;
304 success = TRUE;
305fail:
306 if (!success)
307 {
308 char buffer[128] = WINPR_C_ARRAY_INIT;
309 WLog_ERR(__func__, "failed to read data from '%s': %s", name,
310 winpr_strerror(errno, buffer, sizeof(buffer)));
311 free(json);
312 json = nullptr;
313 }
314
315 if (fp)
316 (void)fclose(fp);
317 return json;
318}
319
320static bool save_settings(const rdpSettings* settings, const char* name)
321{
322 bool rc = false;
323 size_t datalen = 0;
324 char* data = freerdp_settings_serialize(settings, TRUE, &datalen);
325 if (!data)
326 return false;
327
328 FILE* fp = test_fopen(name, "w");
329 if (fp)
330 {
331 const size_t res = fwrite(data, 1, datalen, fp);
332 (void)fclose(fp);
333 rc = res == datalen;
334 }
335
336 free(data);
337 return rc;
338}
339
340static char* get_json_name(const char* base, bool unchecked)
341{
342 size_t namelen = 0;
343 char* name = nullptr;
344 winpr_asprintf(&name, &namelen, "%s%s.json", base, unchecked ? ".unchecked" : "");
345 return name;
346}
347
348static rdpSettings* read_json(const char* name)
349{
350 size_t datalen = 0;
351 void* data = read_rdp_data(name, &datalen);
352 rdpSettings* settings = freerdp_settings_deserialize(data, datalen);
353fail:
354 free(data);
355 return settings;
356}
357
358static rdpSettings* load_from(const void* data, size_t len, bool unchecked)
359{
360 BOOL rc = false;
361 rdpFile* file = freerdp_client_rdp_file_new();
362 rdpSettings* settings = read_json("default-settings.json");
363 if (!settings)
364 {
365 settings = freerdp_settings_new(0);
366 if (settings)
367 {
368 save_settings(settings, "default-settings.json");
369 }
370 }
371 if (!file || !settings)
372 goto fail;
373
374 if (!freerdp_client_parse_rdp_file_buffer(file, data, len))
375 goto fail;
376
377 if (unchecked)
378 {
379 if (!freerdp_client_populate_settings_from_rdp_file_unchecked(file, settings))
380 goto fail;
381 }
382 else
383 {
384 if (!freerdp_client_populate_settings_from_rdp_file(file, settings))
385 goto fail;
386 }
387
388 rc = true;
389fail:
390 freerdp_client_rdp_file_free(file);
391 if (!rc)
392 {
393 freerdp_settings_free(settings);
394 return nullptr;
395 }
396 return settings;
397}
398
399static rdpSettings* load_from_file(const char* name, bool unchecked)
400{
401 size_t datalen = 0;
402 void* data = read_rdp_data(name, &datalen);
403 if (!data)
404 return nullptr;
405 rdpSettings* settings = load_from(data, datalen, unchecked);
406 free(data);
407 return settings;
408}
409
410static bool test_data(const char* json, const void* data, size_t len, bool unchecked)
411{
412 bool rc = false;
413
414 rdpSettings* settings = load_from(data, len, unchecked);
415 rdpSettings* expect = read_json(json);
416 if (!settings || !expect)
417 goto fail;
418
419#ifndef WITH_GFX_H264
420 if (!freerdp_settings_set_bool(expect, FreeRDP_GfxH264, FALSE) ||
421 !freerdp_settings_set_bool(expect, FreeRDP_GfxAVC444, FALSE) ||
422 !freerdp_settings_set_bool(expect, FreeRDP_GfxAVC444v2, FALSE))
423 goto fail;
424#endif
425 wLog* log = WLog_Get(__func__);
426 WLog_Print(log, WLOG_INFO, "Test cast '%s'", json);
427 if (freerdp_settings_print_diff(log, WLOG_ERROR, expect, settings))
428 goto fail;
429 rc = true;
430fail:
431 freerdp_settings_free(settings);
432 freerdp_settings_free(expect);
433 return rc;
434}
435
436static HANDLE FindFirstFileUTF8(LPCSTR pszSearchPath, WIN32_FIND_DATAW* FindData)
437{
438 HANDLE hdl = INVALID_HANDLE_VALUE;
439 if (!pszSearchPath)
440 return hdl;
441 WCHAR* wpath = ConvertUtf8ToWCharAlloc(pszSearchPath, nullptr);
442 if (!wpath)
443 return hdl;
444
445 hdl = FindFirstFileW(wpath, FindData);
446 free(wpath);
447
448 return hdl;
449}
450
451static bool test_rdp_file(const char* base, bool allowCreate, bool unchecked)
452{
453 bool rc = false;
454
455 size_t rdplen = 0;
456 char* rdp = nullptr;
457 winpr_asprintf(&rdp, &rdplen, "%s.rdp", base);
458 char* json = get_json_name(base, unchecked);
459 size_t datalen = 0;
460 void* data = read_rdp_data(rdp, &datalen);
461
462 if (!data)
463 goto fail;
464
465 rc = test_data(json, data, datalen, unchecked);
466 if (!rc && allowCreate)
467 {
468 rdpSettings* expect = read_json(json);
469 if (expect)
470 {
471 freerdp_settings_free(expect);
472 goto fail;
473 }
474
475 rdpSettings* settings = load_from_file(rdp, unchecked);
476 if (!settings)
477 goto fail;
478
479 rc = save_settings(settings, json);
480 }
481fail:
482 free(data);
483 free(json);
484 free(rdp);
485 return rc;
486}
487
488static bool test_rdp_files(bool allowCreate)
489{
490 bool rc = false;
491 /* Load RDP files from directory, compare to JSON in same directory.
492 * If JSON does not exist, create it.
493 */
494#ifndef TEST_SOURCE_DIR
495#error "TEST_SOURCE_DIR must be defined to the test source directory"
496#endif
497
498 HANDLE hdl = INVALID_HANDLE_VALUE;
499 char* path = GetCombinedPath(TEST_SOURCE_DIR, "rdp-testcases/*.rdp");
500 if (!path)
501 goto fail;
502
503 WIN32_FIND_DATAW FindData = WINPR_C_ARRAY_INIT;
504 hdl = FindFirstFileUTF8(path, &FindData);
505
506 if (hdl == INVALID_HANDLE_VALUE)
507 {
508 WLog_INFO(
509 __func__,
510 "no RDP files found in %s. Add RDP files to generate settings JSON for comparison.",
511 path);
512 rc = true;
513 goto fail;
514 }
515
516 do
517 {
518 if ((FindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0)
519 {
520 char cFileName[6 * MAX_PATH] = WINPR_C_ARRAY_INIT;
521 char rdp[6 * MAX_PATH] = WINPR_C_ARRAY_INIT;
522 ConvertWCharToUtf8(FindData.cFileName, cFileName, sizeof(cFileName));
523 const size_t len = strnlen(cFileName, sizeof(cFileName));
524 if (len < 4)
525 continue;
526 strcpy(rdp, "rdp-testcases/");
527 strncpy(&rdp[14], cFileName, len - 4);
528
529 if (!test_rdp_file(rdp, allowCreate, false))
530 goto fail;
531 if (!test_rdp_file(rdp, allowCreate, true))
532 goto fail;
533 }
534 } while (FindNextFileW(hdl, &FindData));
535
536 rc = true;
537
538fail:
539 FindClose(hdl);
540 free(path);
541 return rc;
542}
543
544int TestClientRdpFile(int argc, char* argv[])
545{
546 int rc = -1;
547 int iValue = 0;
548 UINT32 uValue = 0;
549 const UINT32* puValue = nullptr;
550 const char* sValue = nullptr;
551 char* utfname = nullptr;
552 char* uniname = nullptr;
553 char* base = nullptr;
554 char* tmp = nullptr;
555 UINT64 id = 0;
556 rdpFile* file = nullptr;
557 rdpSettings* settings = nullptr;
558
559 WINPR_UNUSED(argc);
560 WINPR_UNUSED(argv);
561 if (winpr_RAND(&id, sizeof(id)) < 0)
562 return -1;
563
564 /* UTF8 */
565#if defined(CHANNEL_URBDRC_CLIENT) && defined(CHANNEL_RDPECAM_CLIENT)
566 if (!test_data("testRdpFileUTF8.json", testRdpFileUTF8, sizeof(testRdpFileUTF8), false))
567 return -1;
568 if (!test_data("testRdpFileUTF8.unchecked.json", testRdpFileUTF8, sizeof(testRdpFileUTF8),
569 true))
570 return -1;
571#endif
572
573 /* Unicode */
574#if defined(CHANNEL_URBDRC_CLIENT)
575 if (!test_data("testRdpFileUTF16.json", testRdpFileUTF16, sizeof(testRdpFileUTF16), false))
576 return -1;
577 if (!test_data("testRdpFileUTF16.unchecked.json", testRdpFileUTF16, sizeof(testRdpFileUTF16),
578 true))
579 return -1;
580#endif
581
582#if defined(CHANNEL_URBDRC_CLIENT) && defined(CHANNEL_RDPECAM_CLIENT)
583 if (!test_rdp_files(argc > 1))
584 return -1;
585#endif
586
587 /* Ascii */
588 file = freerdp_client_rdp_file_new();
589 settings = freerdp_settings_new(0);
590 if (!file || !settings)
591 {
592 printf("rdp_file_new failed\n");
593 goto fail;
594 }
595
596 if (!freerdp_client_parse_rdp_file_buffer(file, (BYTE*)testRdpFileUTF8,
597 sizeof(testRdpFileUTF8)))
598 goto fail;
599
600 if (!freerdp_client_populate_settings_from_rdp_file(file, settings))
601 goto fail;
602
603 if (freerdp_settings_get_bool(settings, FreeRDP_UseMultimon))
604 {
605 printf("UseMultiMon mismatch: Actual: %" PRIu32 ", Expected: 0\n",
606 freerdp_settings_get_bool(settings, FreeRDP_UseMultimon));
607 return -1;
608 }
609
610 if (!freerdp_settings_get_bool(settings, FreeRDP_Fullscreen))
611 {
612 printf("ScreenModeId mismatch: Actual: %" PRIu32 ", Expected: TRUE\n",
613 freerdp_settings_get_bool(settings, FreeRDP_Fullscreen));
614 return -1;
615 }
616
617 if (strcmp(freerdp_settings_get_string(settings, FreeRDP_ServerHostname),
618 "LAB1-W7-DM-01.lab1.awake.global") != 0)
619 {
620 printf("ServerHostname mismatch: Actual: %s, Expected: %s\n",
621 freerdp_settings_get_string(settings, FreeRDP_ServerHostname),
622 "LAB1-W7-DM-01.lab1.awake.global");
623 goto fail;
624 }
625
626 if (strcmp(freerdp_settings_get_string(settings, FreeRDP_GatewayHostname),
627 "LAB1-W2K8R2-GW.lab1.awake.local") != 0)
628 {
629 printf("GatewayHostname mismatch: Actual: %s, Expected: %s\n",
630 freerdp_settings_get_string(settings, FreeRDP_GatewayHostname),
631 "LAB1-W2K8R2-GW.lab1.awake.local");
632 goto fail;
633 }
634
635 iValue = freerdp_client_rdp_file_get_integer_option(file, "dynamic resolution");
636 if (iValue != 1080)
637 {
638 printf("dynamic resolution uses invalid default value %d", iValue);
639 goto fail;
640 }
641 if (!freerdp_settings_get_bool(settings, FreeRDP_DynamicResolutionUpdate))
642 {
643 printf("FreeRDP_DynamicResolutionUpdate has invalid value");
644 goto fail;
645 }
646 iValue = freerdp_client_rdp_file_get_integer_option(file, "desktopscalefactor");
647 if (iValue != 1080)
648 {
649 printf("desktopscalefactor uses invalid default value %d", iValue);
650 goto fail;
651 }
652 if ((INT64)freerdp_settings_get_uint32(settings, FreeRDP_DesktopScaleFactor) != iValue)
653 {
654 printf("FreeRDP_DesktopScaleFactor has invalid value");
655 goto fail;
656 }
657
658 /* Check [MS-RDPECAM] related options */
659#if defined(CHANNEL_RDPECAM_CLIENT)
660 {
661 ADDIN_ARGV* args = nullptr;
662 iValue =
663 freerdp_client_rdp_file_get_integer_option(file, "encode redirected video capture");
664 if (iValue != 1)
665 {
666 printf("encode redirected video capture uses invalid default value %d", iValue);
667 goto fail;
668 }
669 iValue = freerdp_client_rdp_file_get_integer_option(
670 file, "redirected video capture encoding quality");
671 if (iValue != 2)
672 {
673 printf("redirected video capture encoding quality uses invalid default value %d",
674 iValue);
675 goto fail;
676 }
677 args = freerdp_dynamic_channel_collection_find(settings, RDPECAM_DVC_CHANNEL_NAME);
678 if (!args)
679 {
680 printf("rdpecam channel was not loaded");
681 goto fail;
682 }
683 if (args->argc != 6)
684 {
685 printf("rdpecam channel was not loaded");
686 goto fail;
687 }
688
689 for (int x = 0; x < args->argc; x++)
690 {
691 if (strcmp(args->argv[x], camera_args[x]) != 0)
692 {
693 printf("rdpecam invalid argument argv[%d]: %s", x, args->argv[x]);
694 goto fail;
695 }
696 }
697 }
698#endif
699
700 /* Check [URBDRC] related options */
701#if defined(CHANNEL_URBDRC_CLIENT)
702 {
703 ADDIN_ARGV* args = freerdp_dynamic_channel_collection_find(settings, "urbdrc");
704 if (!args)
705 {
706 printf("urbdrc channel was not loaded");
707 goto fail;
708 }
709 if (args->argc != 4)
710 {
711 printf("urbdrc channel was not loaded");
712 goto fail;
713 }
714
715 for (int x = 0; x < args->argc; x++)
716 {
717 if (strcmp(args->argv[x], urbdrc_args[x]) != 0)
718 {
719 printf("urbdrc invalid argument argv[%d]: %s", x, args->argv[x]);
720 goto fail;
721 }
722 }
723 }
724#endif
725
726 /* Validate selectedmonitors:s:3,2,42,23 */
727 uValue = freerdp_settings_get_uint32(settings, FreeRDP_NumMonitorIds);
728 if (uValue != 4)
729 {
730 printf("FreeRDP_NumMonitorIds has invalid value %" PRIu32, uValue);
731 goto fail;
732 }
733 puValue = (const UINT32*)freerdp_settings_get_pointer_array(settings, FreeRDP_MonitorIds, 0);
734 if (!puValue)
735 {
736 printf("FreeRDP_MonitorIds has invalid value %p", (const void*)puValue);
737 goto fail;
738 }
739 if ((puValue[0] != 3) || (puValue[1] != 2) || (puValue[2] != 42) || (puValue[3] != 23))
740 {
741 printf("FreeRDP_MonitorIds has invalid values: [%" PRIu32 ",%" PRIu32 ",%" PRIu32
742 ",%" PRIu32 "]",
743 puValue[0], puValue[1], puValue[2], puValue[3]);
744 goto fail;
745 }
746
747 iValue = freerdp_client_rdp_file_get_integer_option(file, "videoplaybackmode");
748 if (iValue != 2)
749 {
750 printf("videoplaybackmode uses invalid default value %d", iValue);
751 goto fail;
752 }
753 if (!freerdp_settings_get_bool(settings, FreeRDP_SupportVideoOptimized))
754 {
755 printf("FreeRDP_SupportVideoOptimized has invalid value");
756 goto fail;
757 }
758 if (!freerdp_settings_get_bool(settings, FreeRDP_SupportGeometryTracking))
759 {
760 printf("FreeRDP_SupportGeometryTracking has invalid value");
761 goto fail;
762 }
763
764 iValue = freerdp_client_rdp_file_get_integer_option(file, "vendor integer");
765 if (iValue != 123)
766 goto fail;
767
768 if (freerdp_client_rdp_file_set_integer_option(file, "vendor integer", 456) == -1)
769 {
770 printf("failed to set integer: vendor integer");
771 goto fail;
772 }
773
774 iValue = freerdp_client_rdp_file_get_integer_option(file, "vendor integer");
775 if (iValue != 456)
776 return -1;
777
778 const char microsoft[] = "microsoft";
779 sValue = freerdp_client_rdp_file_get_string_option(file, "vendor string");
780 if (strncmp(sValue, microsoft, sizeof(microsoft)) != 0)
781 goto fail;
782
783 const char apple[] = "apple";
784 freerdp_client_rdp_file_set_string_option(file, "vendor string", "apple");
785 sValue = freerdp_client_rdp_file_get_string_option(file, "vendor string");
786 if (strncmp(sValue, apple, sizeof(apple)) != 0)
787 goto fail;
788
789 freerdp_client_rdp_file_set_string_option(file, "fruits", "banana,oranges");
790
791 if (freerdp_client_rdp_file_set_integer_option(file, "numbers", 123456789) == -1)
792 {
793 printf("failed to set integer: numbers");
794 return -1;
795 }
796
797 freerdp_client_rdp_file_free(file);
798
799 tmp = GetKnownPath(KNOWN_PATH_TEMP);
800 if (!tmp)
801 goto fail;
802
803 base = append("%s/rdp-file-test-%" PRIx64, tmp, id);
804 if (!base)
805 goto fail;
806 if (!CreateDirectoryA(base, nullptr))
807 goto fail;
808 utfname = append("%s/utfname", base);
809 uniname = append("%s/uniname", base);
810 file = freerdp_client_rdp_file_new();
811 if (!file || !utfname || !uniname)
812 goto fail;
813
814 if (!freerdp_client_populate_rdp_file_from_settings(file, settings))
815 goto fail;
816
817 if (!freerdp_client_write_rdp_file(file, utfname, FALSE))
818 goto fail;
819
820 if (!freerdp_client_write_rdp_file(file, uniname, TRUE))
821 goto fail;
822
823 rc = 0;
824fail:
825 if (utfname)
826 winpr_DeleteFile(utfname);
827 if (uniname)
828 winpr_DeleteFile(uniname);
829 if (base)
830 winpr_RemoveDirectory(base);
831 free(utfname);
832 free(uniname);
833 free(base);
834 free(tmp);
835 freerdp_client_rdp_file_free(file);
836 freerdp_settings_free(settings);
837 return rc;
838}
FREERDP_API BOOL freerdp_settings_set_bool(rdpSettings *settings, FreeRDP_Settings_Keys_Bool id, BOOL val)
Sets a BOOL settings value.
WINPR_ATTR_NODISCARD FREERDP_API const char * freerdp_settings_get_string(const rdpSettings *settings, FreeRDP_Settings_Keys_String id)
Returns a immutable string settings value.
WINPR_ATTR_NODISCARD FREERDP_API rdpSettings * freerdp_settings_deserialize(const char *jstr, size_t length)
A function that converts a JSON string to a rdpSettings struct.
FREERDP_API void freerdp_settings_free(rdpSettings *settings)
Free a settings struct with all data in it.
WINPR_ATTR_NODISCARD FREERDP_API rdpSettings * freerdp_settings_new(DWORD flags)
creates a new setting struct
WINPR_ATTR_NODISCARD FREERDP_API UINT32 freerdp_settings_get_uint32(const rdpSettings *settings, FreeRDP_Settings_Keys_UInt32 id)
Returns a UINT32 settings value.
WINPR_ATTR_NODISCARD FREERDP_API char * freerdp_settings_serialize(const rdpSettings *settings, BOOL pretty, size_t *plength)
A function that converts a rdpSettings struct to a JSON serialized string.
WINPR_ATTR_NODISCARD FREERDP_API BOOL freerdp_settings_get_bool(const rdpSettings *settings, FreeRDP_Settings_Keys_Bool id)
Returns a boolean settings value.
WINPR_ATTR_NODISCARD FREERDP_API BOOL freerdp_settings_print_diff(wLog *log, DWORD level, const rdpSettings *settings, const rdpSettings *other)
Dumps the difference between two settings structs to a WLog.