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 = NULL;
244 va_list ap = { 0 };
245
246 va_start(ap, fmt);
247 rc = vsnprintf(NULL, 0, fmt, ap);
248 va_end(ap);
249 if (rc < 0)
250 return NULL;
251 dst = malloc((size_t)rc + 1);
252 if (!dst)
253 return NULL;
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 NULL;
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 = NULL;
282 FILE* fp = test_fopen(name, "r");
283 if (!fp)
284 goto fail;
285 if (fseek(fp, 0, SEEK_END) != 0)
286 goto fail;
287 const size_t pos = WINPR_ASSERTING_INT_CAST(size_t, _ftelli64(fp));
288 if (fseek(fp, 0, SEEK_SET) != 0)
289 goto fail;
290
291 json = calloc(1ULL + pos, sizeof(char));
292 if (!json)
293 goto fail;
294 if (fread(json, 1, pos, fp) != pos)
295 goto fail;
296
297 *plen = pos;
298 success = TRUE;
299fail:
300 if (!success)
301 {
302 char buffer[128] = { 0 };
303 WLog_ERR(__func__, "failed to read data from '%s': %s", name,
304 winpr_strerror(errno, buffer, sizeof(buffer)));
305 free(json);
306 json = NULL;
307 }
308
309 if (fp)
310 (void)fclose(fp);
311 return json;
312}
313
314static bool save_settings(const rdpSettings* settings, const char* name)
315{
316 bool rc = false;
317 size_t datalen = 0;
318 char* data = freerdp_settings_serialize(settings, TRUE, &datalen);
319 if (!data)
320 return false;
321
322 FILE* fp = test_fopen(name, "w");
323 if (fp)
324 {
325 const size_t res = fwrite(data, 1, datalen, fp);
326 (void)fclose(fp);
327 rc = res == datalen;
328 }
329
330 free(data);
331 return rc;
332}
333
334static char* get_json_name(const char* base, bool unchecked)
335{
336 size_t namelen = 0;
337 char* name = NULL;
338 winpr_asprintf(&name, &namelen, "%s%s.json", base, unchecked ? ".unchecked" : "");
339 return name;
340}
341
342static rdpSettings* read_json(const char* name)
343{
344 size_t datalen = 0;
345 void* data = read_rdp_data(name, &datalen);
346 rdpSettings* settings = freerdp_settings_deserialize(data, datalen);
347fail:
348 free(data);
349 return settings;
350}
351
352static rdpSettings* load_from(const void* data, size_t len, bool unchecked)
353{
354 BOOL rc = false;
355 rdpFile* file = freerdp_client_rdp_file_new();
356 rdpSettings* settings = read_json("default-settings.json");
357 if (!settings)
358 {
359 settings = freerdp_settings_new(0);
360 if (settings)
361 {
362 save_settings(settings, "default-settings.json");
363 }
364 }
365 if (!file || !settings)
366 goto fail;
367
368 if (!freerdp_client_parse_rdp_file_buffer(file, data, len))
369 goto fail;
370
371 if (unchecked)
372 {
373 if (!freerdp_client_populate_settings_from_rdp_file_unchecked(file, settings))
374 goto fail;
375 }
376 else
377 {
378 if (!freerdp_client_populate_settings_from_rdp_file(file, settings))
379 goto fail;
380 }
381
382 rc = true;
383fail:
384 freerdp_client_rdp_file_free(file);
385 if (!rc)
386 {
387 freerdp_settings_free(settings);
388 return NULL;
389 }
390 return settings;
391}
392
393static rdpSettings* load_from_file(const char* name, bool unchecked)
394{
395 size_t datalen = 0;
396 void* data = read_rdp_data(name, &datalen);
397 if (!data)
398 return NULL;
399 rdpSettings* settings = load_from(data, datalen, unchecked);
400 free(data);
401 return settings;
402}
403
404static bool test_data(const char* json, const void* data, size_t len, bool unchecked)
405{
406 bool rc = false;
407
408 rdpSettings* settings = load_from(data, len, unchecked);
409 rdpSettings* expect = read_json(json);
410 if (!settings || !expect)
411 goto fail;
412
413 wLog* log = WLog_Get(__func__);
414 WLog_Print(log, WLOG_INFO, "Test cast '%s'", json);
415 if (freerdp_settings_print_diff(log, WLOG_ERROR, expect, settings))
416 goto fail;
417 rc = true;
418fail:
419 freerdp_settings_free(settings);
420 freerdp_settings_free(expect);
421 return rc;
422}
423
424static HANDLE FindFirstFileUTF8(LPCSTR pszSearchPath, WIN32_FIND_DATAW* FindData)
425{
426 HANDLE hdl = INVALID_HANDLE_VALUE;
427 if (!pszSearchPath)
428 return hdl;
429 WCHAR* wpath = ConvertUtf8ToWCharAlloc(pszSearchPath, NULL);
430 if (!wpath)
431 return hdl;
432
433 hdl = FindFirstFileW(wpath, FindData);
434 free(wpath);
435
436 return hdl;
437}
438
439static bool test_rdp_file(const char* base, bool allowCreate, bool unchecked)
440{
441 bool rc = false;
442
443 size_t rdplen = 0;
444 char* rdp = NULL;
445 winpr_asprintf(&rdp, &rdplen, "%s.rdp", base);
446 char* json = get_json_name(base, unchecked);
447 size_t datalen = 0;
448 void* data = read_rdp_data(rdp, &datalen);
449
450 if (!data)
451 goto fail;
452
453 rc = test_data(json, data, datalen, unchecked);
454 if (!rc && allowCreate)
455 {
456 rdpSettings* expect = read_json(json);
457 if (expect)
458 {
459 freerdp_settings_free(expect);
460 goto fail;
461 }
462
463 rdpSettings* settings = load_from_file(rdp, unchecked);
464 if (!settings)
465 goto fail;
466
467 rc = save_settings(settings, json);
468 }
469fail:
470 free(data);
471 free(json);
472 free(rdp);
473 return rc;
474}
475
476static bool test_rdp_files(bool allowCreate)
477{
478 bool rc = false;
479 /* Load RDP files from directory, compare to JSON in same directory.
480 * If JSON does not exist, create it.
481 */
482#ifndef TEST_SOURCE_DIR
483#error "TEST_SOURCE_DIR must be defined to the test source directory"
484#endif
485
486 HANDLE hdl = INVALID_HANDLE_VALUE;
487 char* path = GetCombinedPath(TEST_SOURCE_DIR, "rdp-testcases/*.rdp");
488 if (!path)
489 goto fail;
490
491 WIN32_FIND_DATAW FindData = { 0 };
492 hdl = FindFirstFileUTF8(path, &FindData);
493
494 if (hdl == INVALID_HANDLE_VALUE)
495 {
496 WLog_INFO(
497 __func__,
498 "no RDP files found in %s. Add RDP files to generate settings JSON for comparison.",
499 path);
500 rc = true;
501 goto fail;
502 }
503
504 do
505 {
506 if ((FindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0)
507 {
508 char cFileName[6 * MAX_PATH] = { 0 };
509 char rdp[6 * MAX_PATH] = { 0 };
510 ConvertWCharToUtf8(FindData.cFileName, cFileName, sizeof(cFileName));
511 const size_t len = strnlen(cFileName, sizeof(cFileName));
512 if (len < 4)
513 continue;
514 strcpy(rdp, "rdp-testcases/");
515 strncpy(&rdp[14], cFileName, len - 4);
516
517 if (!test_rdp_file(rdp, allowCreate, false))
518 goto fail;
519 if (!test_rdp_file(rdp, allowCreate, true))
520 goto fail;
521 }
522 } while (FindNextFileW(hdl, &FindData));
523
524 rc = true;
525
526fail:
527 FindClose(hdl);
528 free(path);
529 return rc;
530}
531
532int TestClientRdpFile(int argc, char* argv[])
533{
534 int rc = -1;
535 int iValue = 0;
536 UINT32 uValue = 0;
537 const UINT32* puValue = NULL;
538 const char* sValue = NULL;
539 char* utfname = NULL;
540 char* uniname = NULL;
541 char* base = NULL;
542 char* tmp = NULL;
543 UINT64 id = 0;
544 rdpFile* file = NULL;
545 rdpSettings* settings = NULL;
546
547 WINPR_UNUSED(argc);
548 WINPR_UNUSED(argv);
549 winpr_RAND(&id, sizeof(id));
550
551 /* UTF8 */
552#if defined(CHANNEL_URBDRC_CLIENT) && defined(CHANNEL_RDPECAM_CLIENT)
553 if (!test_data("testRdpFileUTF8.json", testRdpFileUTF8, sizeof(testRdpFileUTF8), false))
554 return -1;
555 if (!test_data("testRdpFileUTF8.unchecked.json", testRdpFileUTF8, sizeof(testRdpFileUTF8),
556 true))
557 return -1;
558#endif
559
560 /* Unicode */
561#if defined(CHANNEL_URBDRC_CLIENT)
562 if (!test_data("testRdpFileUTF16.json", testRdpFileUTF16, sizeof(testRdpFileUTF16), false))
563 return -1;
564 if (!test_data("testRdpFileUTF16.unchecked.json", testRdpFileUTF16, sizeof(testRdpFileUTF16),
565 true))
566 return -1;
567#endif
568
569#if defined(CHANNEL_URBDRC_CLIENT) && defined(CHANNEL_RDPECAM_CLIENT)
570 if (!test_rdp_files(argc > 1))
571 return -1;
572#endif
573
574 /* Ascii */
575 file = freerdp_client_rdp_file_new();
576 settings = freerdp_settings_new(0);
577 if (!file || !settings)
578 {
579 printf("rdp_file_new failed\n");
580 goto fail;
581 }
582
583 if (!freerdp_client_parse_rdp_file_buffer(file, (BYTE*)testRdpFileUTF8,
584 sizeof(testRdpFileUTF8)))
585 goto fail;
586
587 if (!freerdp_client_populate_settings_from_rdp_file(file, settings))
588 goto fail;
589
590 if (freerdp_settings_get_bool(settings, FreeRDP_UseMultimon))
591 {
592 printf("UseMultiMon mismatch: Actual: %" PRIu32 ", Expected: 0\n",
593 freerdp_settings_get_bool(settings, FreeRDP_UseMultimon));
594 return -1;
595 }
596
597 if (!freerdp_settings_get_bool(settings, FreeRDP_Fullscreen))
598 {
599 printf("ScreenModeId mismatch: Actual: %" PRIu32 ", Expected: TRUE\n",
600 freerdp_settings_get_bool(settings, FreeRDP_Fullscreen));
601 return -1;
602 }
603
604 if (strcmp(freerdp_settings_get_string(settings, FreeRDP_ServerHostname),
605 "LAB1-W7-DM-01.lab1.awake.global") != 0)
606 {
607 printf("ServerHostname mismatch: Actual: %s, Expected: %s\n",
608 freerdp_settings_get_string(settings, FreeRDP_ServerHostname),
609 "LAB1-W7-DM-01.lab1.awake.global");
610 goto fail;
611 }
612
613 if (strcmp(freerdp_settings_get_string(settings, FreeRDP_GatewayHostname),
614 "LAB1-W2K8R2-GW.lab1.awake.local") != 0)
615 {
616 printf("GatewayHostname mismatch: Actual: %s, Expected: %s\n",
617 freerdp_settings_get_string(settings, FreeRDP_GatewayHostname),
618 "LAB1-W2K8R2-GW.lab1.awake.local");
619 goto fail;
620 }
621
622 iValue = freerdp_client_rdp_file_get_integer_option(file, "dynamic resolution");
623 if (iValue != 1080)
624 {
625 printf("dynamic resolution uses invalid default value %d", iValue);
626 goto fail;
627 }
628 if (!freerdp_settings_get_bool(settings, FreeRDP_DynamicResolutionUpdate))
629 {
630 printf("FreeRDP_DynamicResolutionUpdate has invalid value");
631 goto fail;
632 }
633 iValue = freerdp_client_rdp_file_get_integer_option(file, "desktopscalefactor");
634 if (iValue != 1080)
635 {
636 printf("desktopscalefactor uses invalid default value %d", iValue);
637 goto fail;
638 }
639 if ((INT64)freerdp_settings_get_uint32(settings, FreeRDP_DesktopScaleFactor) != iValue)
640 {
641 printf("FreeRDP_DesktopScaleFactor has invalid value");
642 goto fail;
643 }
644
645 /* Check [MS-RDPECAM] related options */
646#if defined(CHANNEL_RDPECAM_CLIENT)
647 {
648 ADDIN_ARGV* args = NULL;
649 iValue =
650 freerdp_client_rdp_file_get_integer_option(file, "encode redirected video capture");
651 if (iValue != 1)
652 {
653 printf("encode redirected video capture uses invalid default value %d", iValue);
654 goto fail;
655 }
656 iValue = freerdp_client_rdp_file_get_integer_option(
657 file, "redirected video capture encoding quality");
658 if (iValue != 2)
659 {
660 printf("redirected video capture encoding quality uses invalid default value %d",
661 iValue);
662 goto fail;
663 }
664 args = freerdp_dynamic_channel_collection_find(settings, RDPECAM_DVC_CHANNEL_NAME);
665 if (!args)
666 {
667 printf("rdpecam channel was not loaded");
668 goto fail;
669 }
670 if (args->argc != 6)
671 {
672 printf("rdpecam channel was not loaded");
673 goto fail;
674 }
675
676 for (int x = 0; x < args->argc; x++)
677 {
678 if (strcmp(args->argv[x], camera_args[x]) != 0)
679 {
680 printf("rdpecam invalid argument argv[%d]: %s", x, args->argv[x]);
681 goto fail;
682 }
683 }
684 }
685#endif
686
687 /* Check [URBDRC] related options */
688#if defined(CHANNEL_URBDRC_CLIENT)
689 {
690 ADDIN_ARGV* args = freerdp_dynamic_channel_collection_find(settings, "urbdrc");
691 if (!args)
692 {
693 printf("urbdrc channel was not loaded");
694 goto fail;
695 }
696 if (args->argc != 4)
697 {
698 printf("urbdrc channel was not loaded");
699 goto fail;
700 }
701
702 for (int x = 0; x < args->argc; x++)
703 {
704 if (strcmp(args->argv[x], urbdrc_args[x]) != 0)
705 {
706 printf("urbdrc invalid argument argv[%d]: %s", x, args->argv[x]);
707 goto fail;
708 }
709 }
710 }
711#endif
712
713 /* Validate selectedmonitors:s:3,2,42,23 */
714 uValue = freerdp_settings_get_uint32(settings, FreeRDP_NumMonitorIds);
715 if (uValue != 4)
716 {
717 printf("FreeRDP_NumMonitorIds has invalid value %" PRIu32, uValue);
718 goto fail;
719 }
720 puValue = (const UINT32*)freerdp_settings_get_pointer_array(settings, FreeRDP_MonitorIds, 0);
721 if (!puValue)
722 {
723 printf("FreeRDP_MonitorIds has invalid value %p", (const void*)puValue);
724 goto fail;
725 }
726 if ((puValue[0] != 3) || (puValue[1] != 2) || (puValue[2] != 42) || (puValue[3] != 23))
727 {
728 printf("FreeRDP_MonitorIds has invalid values: [%" PRIu32 ",%" PRIu32 ",%" PRIu32
729 ",%" PRIu32 "]",
730 puValue[0], puValue[1], puValue[2], puValue[3]);
731 goto fail;
732 }
733
734 iValue = freerdp_client_rdp_file_get_integer_option(file, "videoplaybackmode");
735 if (iValue != 2)
736 {
737 printf("videoplaybackmode uses invalid default value %d", iValue);
738 goto fail;
739 }
740 if (!freerdp_settings_get_bool(settings, FreeRDP_SupportVideoOptimized))
741 {
742 printf("FreeRDP_SupportVideoOptimized has invalid value");
743 goto fail;
744 }
745 if (!freerdp_settings_get_bool(settings, FreeRDP_SupportGeometryTracking))
746 {
747 printf("FreeRDP_SupportGeometryTracking has invalid value");
748 goto fail;
749 }
750
751 iValue = freerdp_client_rdp_file_get_integer_option(file, "vendor integer");
752 if (iValue != 123)
753 goto fail;
754
755 if (freerdp_client_rdp_file_set_integer_option(file, "vendor integer", 456) == -1)
756 {
757 printf("failed to set integer: vendor integer");
758 goto fail;
759 }
760
761 iValue = freerdp_client_rdp_file_get_integer_option(file, "vendor integer");
762 if (iValue != 456)
763 return -1;
764
765 const char microsoft[] = "microsoft";
766 sValue = freerdp_client_rdp_file_get_string_option(file, "vendor string");
767 if (strncmp(sValue, microsoft, sizeof(microsoft)) != 0)
768 goto fail;
769
770 const char apple[] = "apple";
771 freerdp_client_rdp_file_set_string_option(file, "vendor string", "apple");
772 sValue = freerdp_client_rdp_file_get_string_option(file, "vendor string");
773 if (strncmp(sValue, apple, sizeof(apple)) != 0)
774 goto fail;
775
776 freerdp_client_rdp_file_set_string_option(file, "fruits", "banana,oranges");
777
778 if (freerdp_client_rdp_file_set_integer_option(file, "numbers", 123456789) == -1)
779 {
780 printf("failed to set integer: numbers");
781 return -1;
782 }
783
784 freerdp_client_rdp_file_free(file);
785
786 tmp = GetKnownPath(KNOWN_PATH_TEMP);
787 if (!tmp)
788 goto fail;
789
790 base = append("%s/rdp-file-test-%" PRIx64, tmp, id);
791 if (!base)
792 goto fail;
793 if (!CreateDirectoryA(base, NULL))
794 goto fail;
795 utfname = append("%s/utfname", base);
796 uniname = append("%s/uniname", base);
797 file = freerdp_client_rdp_file_new();
798 if (!file || !utfname || !uniname)
799 goto fail;
800
801 if (!freerdp_client_populate_rdp_file_from_settings(file, settings))
802 goto fail;
803
804 if (!freerdp_client_write_rdp_file(file, utfname, FALSE))
805 goto fail;
806
807 if (!freerdp_client_write_rdp_file(file, uniname, TRUE))
808 goto fail;
809
810 rc = 0;
811fail:
812 if (utfname)
813 winpr_DeleteFile(utfname);
814 if (uniname)
815 winpr_DeleteFile(uniname);
816 if (base)
817 winpr_RemoveDirectory(base);
818 free(utfname);
819 free(uniname);
820 free(base);
821 free(tmp);
822 freerdp_client_rdp_file_free(file);
823 freerdp_settings_free(settings);
824 return rc;
825}
FREERDP_API UINT32 freerdp_settings_get_uint32(const rdpSettings *settings, FreeRDP_Settings_Keys_UInt32 id)
Returns a UINT32 settings value.
FREERDP_API BOOL freerdp_settings_get_bool(const rdpSettings *settings, FreeRDP_Settings_Keys_Bool id)
Returns a boolean settings value.
FREERDP_API rdpSettings * freerdp_settings_new(DWORD flags)
creates a new setting struct
FREERDP_API BOOL freerdp_settings_print_diff(wLog *log, DWORD level, const rdpSettings *src, const rdpSettings *other)
Dumps the difference between two settings structs to a WLog.
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.
FREERDP_API void freerdp_settings_free(rdpSettings *settings)
Free a settings struct with all data in it.
FREERDP_API const char * freerdp_settings_get_string(const rdpSettings *settings, FreeRDP_Settings_Keys_String id)
Returns a immutable string settings value.
FREERDP_API rdpSettings * freerdp_settings_deserialize(const char *json, size_t length)
A function that converts a JSON string to a rdpSettings struct.