FreeRDP
TestClientRdpFile.c
1 #include <freerdp/config.h>
2 
3 #include <stdio.h>
4 #include <winpr/crt.h>
5 #include <winpr/windows.h>
6 #include <winpr/path.h>
7 #include <winpr/crypto.h>
8 
9 #include <freerdp/client/file.h>
10 #include <freerdp/channels/rdpecam.h>
11 
12 static const BYTE testRdpFileUTF16[] = {
13  0xff, 0xfe, 0x73, 0x00, 0x63, 0x00, 0x72, 0x00, 0x65, 0x00, 0x65, 0x00, 0x6e, 0x00, 0x20, 0x00,
14  0x6d, 0x00, 0x6f, 0x00, 0x64, 0x00, 0x65, 0x00, 0x20, 0x00, 0x69, 0x00, 0x64, 0x00, 0x3a, 0x00,
15  0x69, 0x00, 0x3a, 0x00, 0x32, 0x00, 0x0d, 0x00, 0x0a, 0x00, 0x75, 0x00, 0x73, 0x00, 0x65, 0x00,
16  0x20, 0x00, 0x6d, 0x00, 0x75, 0x00, 0x6c, 0x00, 0x74, 0x00, 0x69, 0x00, 0x6d, 0x00, 0x6f, 0x00,
17  0x6e, 0x00, 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00, 0x30, 0x00, 0x0d, 0x00, 0x0a, 0x00, 0x64, 0x00,
18  0x65, 0x00, 0x73, 0x00, 0x6b, 0x00, 0x74, 0x00, 0x6f, 0x00, 0x70, 0x00, 0x77, 0x00, 0x69, 0x00,
19  0x64, 0x00, 0x74, 0x00, 0x68, 0x00, 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00, 0x31, 0x00, 0x39, 0x00,
20  0x32, 0x00, 0x30, 0x00, 0x0d, 0x00, 0x0a, 0x00, 0x64, 0x00, 0x65, 0x00, 0x73, 0x00, 0x6b, 0x00,
21  0x74, 0x00, 0x6f, 0x00, 0x70, 0x00, 0x68, 0x00, 0x65, 0x00, 0x69, 0x00, 0x67, 0x00, 0x68, 0x00,
22  0x74, 0x00, 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00, 0x31, 0x00, 0x30, 0x00, 0x38, 0x00, 0x30, 0x00,
23  0x0d, 0x00, 0x0a, 0x00, 0x73, 0x00, 0x65, 0x00, 0x73, 0x00, 0x73, 0x00, 0x69, 0x00, 0x6f, 0x00,
24  0x6e, 0x00, 0x20, 0x00, 0x62, 0x00, 0x70, 0x00, 0x70, 0x00, 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00,
25  0x33, 0x00, 0x32, 0x00, 0x0d, 0x00, 0x0a, 0x00, 0x77, 0x00, 0x69, 0x00, 0x6e, 0x00, 0x70, 0x00,
26  0x6f, 0x00, 0x73, 0x00, 0x73, 0x00, 0x74, 0x00, 0x72, 0x00, 0x3a, 0x00, 0x73, 0x00, 0x3a, 0x00,
27  0x30, 0x00, 0x2c, 0x00, 0x31, 0x00, 0x2c, 0x00, 0x35, 0x00, 0x35, 0x00, 0x33, 0x00, 0x2c, 0x00,
28  0x32, 0x00, 0x31, 0x00, 0x31, 0x00, 0x2c, 0x00, 0x31, 0x00, 0x33, 0x00, 0x35, 0x00, 0x33, 0x00,
29  0x2c, 0x00, 0x38, 0x00, 0x31, 0x00, 0x31, 0x00, 0x0d, 0x00, 0x0a, 0x00, 0x63, 0x00, 0x6f, 0x00,
30  0x6d, 0x00, 0x70, 0x00, 0x72, 0x00, 0x65, 0x00, 0x73, 0x00, 0x73, 0x00, 0x69, 0x00, 0x6f, 0x00,
31  0x6e, 0x00, 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00, 0x31, 0x00, 0x0d, 0x00, 0x0a, 0x00, 0x6b, 0x00,
32  0x65, 0x00, 0x79, 0x00, 0x62, 0x00, 0x6f, 0x00, 0x61, 0x00, 0x72, 0x00, 0x64, 0x00, 0x68, 0x00,
33  0x6f, 0x00, 0x6f, 0x00, 0x6b, 0x00, 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00, 0x32, 0x00, 0x0d, 0x00,
34  0x0a, 0x00, 0x61, 0x00, 0x75, 0x00, 0x64, 0x00, 0x69, 0x00, 0x6f, 0x00, 0x63, 0x00, 0x61, 0x00,
35  0x70, 0x00, 0x74, 0x00, 0x75, 0x00, 0x72, 0x00, 0x65, 0x00, 0x6d, 0x00, 0x6f, 0x00, 0x64, 0x00,
36  0x65, 0x00, 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00, 0x30, 0x00, 0x0d, 0x00, 0x0a, 0x00, 0x76, 0x00,
37  0x69, 0x00, 0x64, 0x00, 0x65, 0x00, 0x6f, 0x00, 0x70, 0x00, 0x6c, 0x00, 0x61, 0x00, 0x79, 0x00,
38  0x62, 0x00, 0x61, 0x00, 0x63, 0x00, 0x6b, 0x00, 0x6d, 0x00, 0x6f, 0x00, 0x64, 0x00, 0x65, 0x00,
39  0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00, 0x31, 0x00, 0x0d, 0x00, 0x0a, 0x00, 0x63, 0x00, 0x6f, 0x00,
40  0x6e, 0x00, 0x6e, 0x00, 0x65, 0x00, 0x63, 0x00, 0x74, 0x00, 0x69, 0x00, 0x6f, 0x00, 0x6e, 0x00,
41  0x20, 0x00, 0x74, 0x00, 0x79, 0x00, 0x70, 0x00, 0x65, 0x00, 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00,
42  0x37, 0x00, 0x0d, 0x00, 0x0a, 0x00, 0x6e, 0x00, 0x65, 0x00, 0x74, 0x00, 0x77, 0x00, 0x6f, 0x00,
43  0x72, 0x00, 0x6b, 0x00, 0x61, 0x00, 0x75, 0x00, 0x74, 0x00, 0x6f, 0x00, 0x64, 0x00, 0x65, 0x00,
44  0x74, 0x00, 0x65, 0x00, 0x63, 0x00, 0x74, 0x00, 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00, 0x31, 0x00,
45  0x0d, 0x00, 0x0a, 0x00, 0x62, 0x00, 0x61, 0x00, 0x6e, 0x00, 0x64, 0x00, 0x77, 0x00, 0x69, 0x00,
46  0x64, 0x00, 0x74, 0x00, 0x68, 0x00, 0x61, 0x00, 0x75, 0x00, 0x74, 0x00, 0x6f, 0x00, 0x64, 0x00,
47  0x65, 0x00, 0x74, 0x00, 0x65, 0x00, 0x63, 0x00, 0x74, 0x00, 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00,
48  0x31, 0x00, 0x0d, 0x00, 0x0a, 0x00, 0x64, 0x00, 0x69, 0x00, 0x73, 0x00, 0x70, 0x00, 0x6c, 0x00,
49  0x61, 0x00, 0x79, 0x00, 0x63, 0x00, 0x6f, 0x00, 0x6e, 0x00, 0x6e, 0x00, 0x65, 0x00, 0x63, 0x00,
50  0x74, 0x00, 0x69, 0x00, 0x6f, 0x00, 0x6e, 0x00, 0x62, 0x00, 0x61, 0x00, 0x72, 0x00, 0x3a, 0x00,
51  0x69, 0x00, 0x3a, 0x00, 0x31, 0x00, 0x0d, 0x00, 0x0a, 0x00, 0x65, 0x00, 0x6e, 0x00, 0x61, 0x00,
52  0x62, 0x00, 0x6c, 0x00, 0x65, 0x00, 0x77, 0x00, 0x6f, 0x00, 0x72, 0x00, 0x6b, 0x00, 0x73, 0x00,
53  0x70, 0x00, 0x61, 0x00, 0x63, 0x00, 0x65, 0x00, 0x72, 0x00, 0x65, 0x00, 0x63, 0x00, 0x6f, 0x00,
54  0x6e, 0x00, 0x6e, 0x00, 0x65, 0x00, 0x63, 0x00, 0x74, 0x00, 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00,
55  0x30, 0x00, 0x0d, 0x00, 0x0a, 0x00, 0x64, 0x00, 0x69, 0x00, 0x73, 0x00, 0x61, 0x00, 0x62, 0x00,
56  0x6c, 0x00, 0x65, 0x00, 0x20, 0x00, 0x77, 0x00, 0x61, 0x00, 0x6c, 0x00, 0x6c, 0x00, 0x70, 0x00,
57  0x61, 0x00, 0x70, 0x00, 0x65, 0x00, 0x72, 0x00, 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00, 0x30, 0x00,
58  0x0d, 0x00, 0x0a, 0x00, 0x61, 0x00, 0x6c, 0x00, 0x6c, 0x00, 0x6f, 0x00, 0x77, 0x00, 0x20, 0x00,
59  0x66, 0x00, 0x6f, 0x00, 0x6e, 0x00, 0x74, 0x00, 0x20, 0x00, 0x73, 0x00, 0x6d, 0x00, 0x6f, 0x00,
60  0x6f, 0x00, 0x74, 0x00, 0x68, 0x00, 0x69, 0x00, 0x6e, 0x00, 0x67, 0x00, 0x3a, 0x00, 0x69, 0x00,
61  0x3a, 0x00, 0x30, 0x00, 0x0d, 0x00, 0x0a, 0x00, 0x61, 0x00, 0x6c, 0x00, 0x6c, 0x00, 0x6f, 0x00,
62  0x77, 0x00, 0x20, 0x00, 0x64, 0x00, 0x65, 0x00, 0x73, 0x00, 0x6b, 0x00, 0x74, 0x00, 0x6f, 0x00,
63  0x70, 0x00, 0x20, 0x00, 0x63, 0x00, 0x6f, 0x00, 0x6d, 0x00, 0x70, 0x00, 0x6f, 0x00, 0x73, 0x00,
64  0x69, 0x00, 0x74, 0x00, 0x69, 0x00, 0x6f, 0x00, 0x6e, 0x00, 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00,
65  0x30, 0x00, 0x0d, 0x00, 0x0a, 0x00, 0x64, 0x00, 0x69, 0x00, 0x73, 0x00, 0x61, 0x00, 0x62, 0x00,
66  0x6c, 0x00, 0x65, 0x00, 0x20, 0x00, 0x66, 0x00, 0x75, 0x00, 0x6c, 0x00, 0x6c, 0x00, 0x20, 0x00,
67  0x77, 0x00, 0x69, 0x00, 0x6e, 0x00, 0x64, 0x00, 0x6f, 0x00, 0x77, 0x00, 0x20, 0x00, 0x64, 0x00,
68  0x72, 0x00, 0x61, 0x00, 0x67, 0x00, 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00, 0x31, 0x00, 0x0d, 0x00,
69  0x0a, 0x00, 0x64, 0x00, 0x69, 0x00, 0x73, 0x00, 0x61, 0x00, 0x62, 0x00, 0x6c, 0x00, 0x65, 0x00,
70  0x20, 0x00, 0x6d, 0x00, 0x65, 0x00, 0x6e, 0x00, 0x75, 0x00, 0x20, 0x00, 0x61, 0x00, 0x6e, 0x00,
71  0x69, 0x00, 0x6d, 0x00, 0x73, 0x00, 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00, 0x31, 0x00, 0x0d, 0x00,
72  0x0a, 0x00, 0x64, 0x00, 0x69, 0x00, 0x73, 0x00, 0x61, 0x00, 0x62, 0x00, 0x6c, 0x00, 0x65, 0x00,
73  0x20, 0x00, 0x74, 0x00, 0x68, 0x00, 0x65, 0x00, 0x6d, 0x00, 0x65, 0x00, 0x73, 0x00, 0x3a, 0x00,
74  0x69, 0x00, 0x3a, 0x00, 0x30, 0x00, 0x0d, 0x00, 0x0a, 0x00, 0x64, 0x00, 0x69, 0x00, 0x73, 0x00,
75  0x61, 0x00, 0x62, 0x00, 0x6c, 0x00, 0x65, 0x00, 0x20, 0x00, 0x63, 0x00, 0x75, 0x00, 0x72, 0x00,
76  0x73, 0x00, 0x6f, 0x00, 0x72, 0x00, 0x20, 0x00, 0x73, 0x00, 0x65, 0x00, 0x74, 0x00, 0x74, 0x00,
77  0x69, 0x00, 0x6e, 0x00, 0x67, 0x00, 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00, 0x30, 0x00, 0x0d, 0x00,
78  0x0a, 0x00, 0x62, 0x00, 0x69, 0x00, 0x74, 0x00, 0x6d, 0x00, 0x61, 0x00, 0x70, 0x00, 0x63, 0x00,
79  0x61, 0x00, 0x63, 0x00, 0x68, 0x00, 0x65, 0x00, 0x70, 0x00, 0x65, 0x00, 0x72, 0x00, 0x73, 0x00,
80  0x69, 0x00, 0x73, 0x00, 0x74, 0x00, 0x65, 0x00, 0x6e, 0x00, 0x61, 0x00, 0x62, 0x00, 0x6c, 0x00,
81  0x65, 0x00, 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00, 0x31, 0x00, 0x0d, 0x00, 0x0a, 0x00, 0x66, 0x00,
82  0x75, 0x00, 0x6c, 0x00, 0x6c, 0x00, 0x20, 0x00, 0x61, 0x00, 0x64, 0x00, 0x64, 0x00, 0x72, 0x00,
83  0x65, 0x00, 0x73, 0x00, 0x73, 0x00, 0x3a, 0x00, 0x73, 0x00, 0x3a, 0x00, 0x4c, 0x00, 0x41, 0x00,
84  0x42, 0x00, 0x31, 0x00, 0x2d, 0x00, 0x57, 0x00, 0x37, 0x00, 0x2d, 0x00, 0x44, 0x00, 0x4d, 0x00,
85  0x2d, 0x00, 0x30, 0x00, 0x31, 0x00, 0x2e, 0x00, 0x6c, 0x00, 0x61, 0x00, 0x62, 0x00, 0x31, 0x00,
86  0x2e, 0x00, 0x61, 0x00, 0x77, 0x00, 0x61, 0x00, 0x6b, 0x00, 0x65, 0x00, 0x2e, 0x00, 0x6c, 0x00,
87  0x6f, 0x00, 0x63, 0x00, 0x61, 0x00, 0x6c, 0x00, 0x0d, 0x00, 0x0a, 0x00, 0x61, 0x00, 0x75, 0x00,
88  0x64, 0x00, 0x69, 0x00, 0x6f, 0x00, 0x6d, 0x00, 0x6f, 0x00, 0x64, 0x00, 0x65, 0x00, 0x3a, 0x00,
89  0x69, 0x00, 0x3a, 0x00, 0x30, 0x00, 0x0d, 0x00, 0x0a, 0x00, 0x72, 0x00, 0x65, 0x00, 0x64, 0x00,
90  0x69, 0x00, 0x72, 0x00, 0x65, 0x00, 0x63, 0x00, 0x74, 0x00, 0x70, 0x00, 0x72, 0x00, 0x69, 0x00,
91  0x6e, 0x00, 0x74, 0x00, 0x65, 0x00, 0x72, 0x00, 0x73, 0x00, 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00,
92  0x31, 0x00, 0x0d, 0x00, 0x0a, 0x00, 0x72, 0x00, 0x65, 0x00, 0x64, 0x00, 0x69, 0x00, 0x72, 0x00,
93  0x65, 0x00, 0x63, 0x00, 0x74, 0x00, 0x63, 0x00, 0x6f, 0x00, 0x6d, 0x00, 0x70, 0x00, 0x6f, 0x00,
94  0x72, 0x00, 0x74, 0x00, 0x73, 0x00, 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00, 0x30, 0x00, 0x0d, 0x00,
95  0x0a, 0x00, 0x72, 0x00, 0x65, 0x00, 0x64, 0x00, 0x69, 0x00, 0x72, 0x00, 0x65, 0x00, 0x63, 0x00,
96  0x74, 0x00, 0x73, 0x00, 0x6d, 0x00, 0x61, 0x00, 0x72, 0x00, 0x74, 0x00, 0x63, 0x00, 0x61, 0x00,
97  0x72, 0x00, 0x64, 0x00, 0x73, 0x00, 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00, 0x31, 0x00, 0x0d, 0x00,
98  0x0a, 0x00, 0x72, 0x00, 0x65, 0x00, 0x64, 0x00, 0x69, 0x00, 0x72, 0x00, 0x65, 0x00, 0x63, 0x00,
99  0x74, 0x00, 0x63, 0x00, 0x6c, 0x00, 0x69, 0x00, 0x70, 0x00, 0x62, 0x00, 0x6f, 0x00, 0x61, 0x00,
100  0x72, 0x00, 0x64, 0x00, 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00, 0x31, 0x00, 0x0d, 0x00, 0x0a, 0x00,
101  0x72, 0x00, 0x65, 0x00, 0x64, 0x00, 0x69, 0x00, 0x72, 0x00, 0x65, 0x00, 0x63, 0x00, 0x74, 0x00,
102  0x70, 0x00, 0x6f, 0x00, 0x73, 0x00, 0x64, 0x00, 0x65, 0x00, 0x76, 0x00, 0x69, 0x00, 0x63, 0x00,
103  0x65, 0x00, 0x73, 0x00, 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00, 0x30, 0x00, 0x0d, 0x00, 0x0a, 0x00,
104  0x61, 0x00, 0x75, 0x00, 0x74, 0x00, 0x6f, 0x00, 0x72, 0x00, 0x65, 0x00, 0x63, 0x00, 0x6f, 0x00,
105  0x6e, 0x00, 0x6e, 0x00, 0x65, 0x00, 0x63, 0x00, 0x74, 0x00, 0x69, 0x00, 0x6f, 0x00, 0x6e, 0x00,
106  0x20, 0x00, 0x65, 0x00, 0x6e, 0x00, 0x61, 0x00, 0x62, 0x00, 0x6c, 0x00, 0x65, 0x00, 0x64, 0x00,
107  0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00, 0x31, 0x00, 0x0d, 0x00, 0x0a, 0x00, 0x61, 0x00, 0x75, 0x00,
108  0x74, 0x00, 0x68, 0x00, 0x65, 0x00, 0x6e, 0x00, 0x74, 0x00, 0x69, 0x00, 0x63, 0x00, 0x61, 0x00,
109  0x74, 0x00, 0x69, 0x00, 0x6f, 0x00, 0x6e, 0x00, 0x20, 0x00, 0x6c, 0x00, 0x65, 0x00, 0x76, 0x00,
110  0x65, 0x00, 0x6c, 0x00, 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00, 0x32, 0x00, 0x0d, 0x00, 0x0a, 0x00,
111  0x70, 0x00, 0x72, 0x00, 0x6f, 0x00, 0x6d, 0x00, 0x70, 0x00, 0x74, 0x00, 0x20, 0x00, 0x66, 0x00,
112  0x6f, 0x00, 0x72, 0x00, 0x20, 0x00, 0x63, 0x00, 0x72, 0x00, 0x65, 0x00, 0x64, 0x00, 0x65, 0x00,
113  0x6e, 0x00, 0x74, 0x00, 0x69, 0x00, 0x61, 0x00, 0x6c, 0x00, 0x73, 0x00, 0x3a, 0x00, 0x69, 0x00,
114  0x3a, 0x00, 0x30, 0x00, 0x0d, 0x00, 0x0a, 0x00, 0x6e, 0x00, 0x65, 0x00, 0x67, 0x00, 0x6f, 0x00,
115  0x74, 0x00, 0x69, 0x00, 0x61, 0x00, 0x74, 0x00, 0x65, 0x00, 0x20, 0x00, 0x73, 0x00, 0x65, 0x00,
116  0x63, 0x00, 0x75, 0x00, 0x72, 0x00, 0x69, 0x00, 0x74, 0x00, 0x79, 0x00, 0x20, 0x00, 0x6c, 0x00,
117  0x61, 0x00, 0x79, 0x00, 0x65, 0x00, 0x72, 0x00, 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00, 0x31, 0x00,
118  0x0d, 0x00, 0x0a, 0x00, 0x72, 0x00, 0x65, 0x00, 0x6d, 0x00, 0x6f, 0x00, 0x74, 0x00, 0x65, 0x00,
119  0x61, 0x00, 0x70, 0x00, 0x70, 0x00, 0x6c, 0x00, 0x69, 0x00, 0x63, 0x00, 0x61, 0x00, 0x74, 0x00,
120  0x69, 0x00, 0x6f, 0x00, 0x6e, 0x00, 0x6d, 0x00, 0x6f, 0x00, 0x64, 0x00, 0x65, 0x00, 0x3a, 0x00,
121  0x69, 0x00, 0x3a, 0x00, 0x30, 0x00, 0x0d, 0x00, 0x0a, 0x00, 0x61, 0x00, 0x6c, 0x00, 0x74, 0x00,
122  0x65, 0x00, 0x72, 0x00, 0x6e, 0x00, 0x61, 0x00, 0x74, 0x00, 0x65, 0x00, 0x20, 0x00, 0x73, 0x00,
123  0x68, 0x00, 0x65, 0x00, 0x6c, 0x00, 0x6c, 0x00, 0x3a, 0x00, 0x73, 0x00, 0x3a, 0x00, 0x0d, 0x00,
124  0x0a, 0x00, 0x73, 0x00, 0x68, 0x00, 0x65, 0x00, 0x6c, 0x00, 0x6c, 0x00, 0x20, 0x00, 0x77, 0x00,
125  0x6f, 0x00, 0x72, 0x00, 0x6b, 0x00, 0x69, 0x00, 0x6e, 0x00, 0x67, 0x00, 0x20, 0x00, 0x64, 0x00,
126  0x69, 0x00, 0x72, 0x00, 0x65, 0x00, 0x63, 0x00, 0x74, 0x00, 0x6f, 0x00, 0x72, 0x00, 0x79, 0x00,
127  0x3a, 0x00, 0x73, 0x00, 0x3a, 0x00, 0x0d, 0x00, 0x0a, 0x00, 0x67, 0x00, 0x61, 0x00, 0x74, 0x00,
128  0x65, 0x00, 0x77, 0x00, 0x61, 0x00, 0x79, 0x00, 0x68, 0x00, 0x6f, 0x00, 0x73, 0x00, 0x74, 0x00,
129  0x6e, 0x00, 0x61, 0x00, 0x6d, 0x00, 0x65, 0x00, 0x3a, 0x00, 0x73, 0x00, 0x3a, 0x00, 0x4c, 0x00,
130  0x41, 0x00, 0x42, 0x00, 0x31, 0x00, 0x2d, 0x00, 0x57, 0x00, 0x32, 0x00, 0x4b, 0x00, 0x38, 0x00,
131  0x52, 0x00, 0x32, 0x00, 0x2d, 0x00, 0x47, 0x00, 0x57, 0x00, 0x2e, 0x00, 0x6c, 0x00, 0x61, 0x00,
132  0x62, 0x00, 0x31, 0x00, 0x2e, 0x00, 0x61, 0x00, 0x77, 0x00, 0x61, 0x00, 0x6b, 0x00, 0x65, 0x00,
133  0x2e, 0x00, 0x6c, 0x00, 0x6f, 0x00, 0x63, 0x00, 0x61, 0x00, 0x6c, 0x00, 0x0d, 0x00, 0x0a, 0x00,
134  0x67, 0x00, 0x61, 0x00, 0x74, 0x00, 0x65, 0x00, 0x77, 0x00, 0x61, 0x00, 0x79, 0x00, 0x75, 0x00,
135  0x73, 0x00, 0x61, 0x00, 0x67, 0x00, 0x65, 0x00, 0x6d, 0x00, 0x65, 0x00, 0x74, 0x00, 0x68, 0x00,
136  0x6f, 0x00, 0x64, 0x00, 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00, 0x31, 0x00, 0x0d, 0x00, 0x0a, 0x00,
137  0x67, 0x00, 0x61, 0x00, 0x74, 0x00, 0x65, 0x00, 0x77, 0x00, 0x61, 0x00, 0x79, 0x00, 0x63, 0x00,
138  0x72, 0x00, 0x65, 0x00, 0x64, 0x00, 0x65, 0x00, 0x6e, 0x00, 0x74, 0x00, 0x69, 0x00, 0x61, 0x00,
139  0x6c, 0x00, 0x73, 0x00, 0x73, 0x00, 0x6f, 0x00, 0x75, 0x00, 0x72, 0x00, 0x63, 0x00, 0x65, 0x00,
140  0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00, 0x30, 0x00, 0x0d, 0x00, 0x0a, 0x00, 0x67, 0x00, 0x61, 0x00,
141  0x74, 0x00, 0x65, 0x00, 0x77, 0x00, 0x61, 0x00, 0x79, 0x00, 0x70, 0x00, 0x72, 0x00, 0x6f, 0x00,
142  0x66, 0x00, 0x69, 0x00, 0x6c, 0x00, 0x65, 0x00, 0x75, 0x00, 0x73, 0x00, 0x61, 0x00, 0x67, 0x00,
143  0x65, 0x00, 0x6d, 0x00, 0x65, 0x00, 0x74, 0x00, 0x68, 0x00, 0x6f, 0x00, 0x64, 0x00, 0x3a, 0x00,
144  0x69, 0x00, 0x3a, 0x00, 0x31, 0x00, 0x0d, 0x00, 0x0a, 0x00, 0x70, 0x00, 0x72, 0x00, 0x6f, 0x00,
145  0x6d, 0x00, 0x70, 0x00, 0x74, 0x00, 0x63, 0x00, 0x72, 0x00, 0x65, 0x00, 0x64, 0x00, 0x65, 0x00,
146  0x6e, 0x00, 0x74, 0x00, 0x69, 0x00, 0x61, 0x00, 0x6c, 0x00, 0x6f, 0x00, 0x6e, 0x00, 0x63, 0x00,
147  0x65, 0x00, 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00, 0x31, 0x00, 0x0d, 0x00, 0x0a, 0x00, 0x75, 0x00,
148  0x73, 0x00, 0x65, 0x00, 0x20, 0x00, 0x72, 0x00, 0x65, 0x00, 0x64, 0x00, 0x69, 0x00, 0x72, 0x00,
149  0x65, 0x00, 0x63, 0x00, 0x74, 0x00, 0x69, 0x00, 0x6f, 0x00, 0x6e, 0x00, 0x20, 0x00, 0x73, 0x00,
150  0x65, 0x00, 0x72, 0x00, 0x76, 0x00, 0x65, 0x00, 0x72, 0x00, 0x20, 0x00, 0x6e, 0x00, 0x61, 0x00,
151  0x6d, 0x00, 0x65, 0x00, 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00, 0x30, 0x00, 0x0d, 0x00, 0x0a, 0x00,
152  0x72, 0x00, 0x64, 0x00, 0x67, 0x00, 0x69, 0x00, 0x73, 0x00, 0x6b, 0x00, 0x64, 0x00, 0x63, 0x00,
153  0x70, 0x00, 0x72, 0x00, 0x6f, 0x00, 0x78, 0x00, 0x79, 0x00, 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00,
154  0x30, 0x00, 0x0d, 0x00, 0x0a, 0x00, 0x6b, 0x00, 0x64, 0x00, 0x63, 0x00, 0x70, 0x00, 0x72, 0x00,
155  0x6f, 0x00, 0x78, 0x00, 0x79, 0x00, 0x6e, 0x00, 0x61, 0x00, 0x6d, 0x00, 0x65, 0x00, 0x3a, 0x00,
156  0x73, 0x00, 0x3a, 0x00, 0x0d, 0x00, 0x0a, 0x00, 0x64, 0x00, 0x72, 0x00, 0x69, 0x00, 0x76, 0x00,
157  0x65, 0x00, 0x73, 0x00, 0x74, 0x00, 0x6f, 0x00, 0x72, 0x00, 0x65, 0x00, 0x64, 0x00, 0x69, 0x00,
158  0x72, 0x00, 0x65, 0x00, 0x63, 0x00, 0x74, 0x00, 0x3a, 0x00, 0x73, 0x00, 0x3a, 0x00, 0x2a, 0x00,
159  0x0d, 0x00, 0x0a, 0x00, 0x75, 0x00, 0x73, 0x00, 0x65, 0x00, 0x72, 0x00, 0x6e, 0x00, 0x61, 0x00,
160  0x6d, 0x00, 0x65, 0x00, 0x3a, 0x00, 0x73, 0x00, 0x3a, 0x00, 0x4c, 0x00, 0x41, 0x00, 0x42, 0x00,
161  0x31, 0x00, 0x5c, 0x00, 0x4a, 0x00, 0x6f, 0x00, 0x68, 0x00, 0x6e, 0x00, 0x44, 0x00, 0x6f, 0x00,
162  0x65, 0x00, 0x0d, 0x00, 0x0a, 0x00
163 };
164 
165 #if defined(CHANNEL_RDPECAM_CLIENT)
166 static const char* camera_args[] = { RDPECAM_DVC_CHANNEL_NAME,
167  "device:*",
168  "device:\\?\\usb#vid_0bda&pid_58b0&mi",
169  "device:-\\?\\usb#vid_0bdc&pid_58b1&mi",
170  "encode:1",
171  "quality:2" };
172 #endif
173 
174 #if defined(CHANNEL_URBDRC_CLIENT)
175 static const char* urbdrc_args[] = { "urbdrc", "device:*", "device:USBInstanceID:someid",
176  "device:{72631e54-78a4-11d0-bcf7-00aa00b7b32a}" };
177 #endif
178 
179 static char testRdpFileUTF8[] =
180  "screen mode id:i:2\n"
181  "use multimon:i:0\n"
182  "desktopwidth:i:1920\n"
183  "desktopheight:i:1080\n"
184  "dynamic resolution:i:1080\n"
185  "desktopscalefactor:i:1080\n"
186  "redirected video capture encoding quality:i:2\n"
187  "encode redirected video capture:i:1\n"
188  "camerastoredirect:s:*,\\?\\usb#vid_0bda&pid_58b0&mi,-\\?\\usb#vid_0bdc&pid_58b1&mi\n"
189  "usbdevicestoredirect:s:*,USBInstanceID:someid,{72631e54-78a4-11d0-bcf7-00aa00b7b32a}\n"
190  "selectedmonitors:s:3,2,42,23"
191  "session bpp:i:32\n"
192  "winposstr:s:0,1,553,211,1353,811\n"
193  "compression:i:1\n"
194  "keyboardhook:i:2\n"
195  "audiocapturemode:i:0\n"
196  "videoplaybackmode:i:2\n"
197  "connection type:i:7\n"
198  "networkautodetect:i:1\n"
199  "bandwidthautodetect:i:1\n"
200  "displayconnectionbar:i:1\n"
201  "enableworkspacereconnect:i:0\n"
202  "disable wallpaper:i:0\n"
203  "allow font smoothing:i:0\n"
204  "allow desktop composition:i:0\n"
205  "disable full window drag:i:1\n"
206  "disable menu anims:i:1\n"
207  "disable themes:i:0\n"
208  "disable cursor setting:i:0\n"
209  "bitmapcachepersistenable:i:1\n"
210  "full address:s:LAB1-W7-DM-01.lab1.awake.local\n"
211  "alternate full address:s:LAB1-W7-DM-01.lab1.awake.global\n"
212  "audiomode:i:0\n"
213  "redirectprinters:i:1\n"
214  "redirectcomports:i:0\n"
215  "redirectsmartcards:i:1\n"
216  "redirectclipboard:i:1\n"
217  "redirectposdevices:i:0\n"
218  "autoreconnection enabled:i:1\n"
219  "authentication level:i:2\n"
220  "prompt for credentials:i:0\n"
221  "negotiate security layer:i:1\n"
222  "remoteapplicationmode:i:0\n"
223  "alternate shell:s:\n"
224  "shell working directory:s:\n"
225  "gatewayhostname:s:LAB1-W2K8R2-GW.lab1.awake.local\n"
226  "gatewayusagemethod:i:1\n"
227  "gatewaycredentialssource:i:0\n"
228  "gatewayprofileusagemethod:i:1\n"
229  "promptcredentialonce:i:1\n"
230  "use redirection server name:i:0\n"
231  "rdgiskdcproxy:i:0\n"
232  "kdcproxyname:s:\n"
233  "drivestoredirect:s:*\n"
234  "username:s:LAB1\\JohnDoe\n"
235  "vendor integer:i:123\n"
236  "vendor string:s:microsoft\n";
237 
238 static char* append(const char* fmt, ...)
239 {
240  int rc = 0;
241  char* dst = NULL;
242  va_list ap = { 0 };
243 
244  va_start(ap, fmt);
245  rc = vsnprintf(NULL, 0, fmt, ap);
246  va_end(ap);
247  if (rc < 0)
248  return NULL;
249  dst = malloc((size_t)rc + 1);
250  if (!dst)
251  return NULL;
252 
253  va_start(ap, fmt);
254  rc = vsnprintf(dst, (size_t)rc + 1, fmt, ap);
255  va_end(ap);
256  if (rc < 0)
257  {
258  free(dst);
259  return NULL;
260  }
261  return dst;
262 }
263 
264 int TestClientRdpFile(int argc, char* argv[])
265 {
266  int rc = -1;
267  int iValue = 0;
268  UINT32 uValue = 0;
269  const UINT32* puValue = NULL;
270  const char* sValue = NULL;
271  char* utfname = NULL;
272  char* uniname = NULL;
273  char* base = NULL;
274  char* tmp = NULL;
275  UINT64 id = 0;
276  rdpFile* file = NULL;
277  rdpSettings* settings = NULL;
278 
279  WINPR_UNUSED(argc);
280  WINPR_UNUSED(argv);
281  winpr_RAND(&id, sizeof(id));
282 
283  /* Unicode */
284  file = freerdp_client_rdp_file_new();
285  settings = freerdp_settings_new(0);
286 
287  if (!file || !settings)
288  {
289  printf("rdp_file_new failed\n");
290  goto fail;
291  }
292 
293  if (!freerdp_client_parse_rdp_file_buffer(file, testRdpFileUTF16, sizeof(testRdpFileUTF16)))
294  goto fail;
295 
296  if (!freerdp_client_populate_settings_from_rdp_file(file, settings))
297  goto fail;
298 
299  if (freerdp_settings_get_bool(settings, FreeRDP_UseMultimon))
300  {
301  printf("UseMultiMon mismatch: Actual: %" PRIu32 ", Expected: 0\n",
302  freerdp_settings_get_bool(settings, FreeRDP_UseMultimon));
303  goto fail;
304  }
305 
306  if (!freerdp_settings_get_bool(settings, FreeRDP_Fullscreen))
307  {
308  printf("ScreenModeId mismatch: Actual: %" PRIu32 ", Expected: TRUE\n",
309  freerdp_settings_get_bool(settings, FreeRDP_Fullscreen));
310  goto fail;
311  }
312 
313 #if 0 /* TODO: Currently unused */
314  if (freerdp_settings_get_uint32(settings, FreeRDP_GatewayProfileUsageMethod) != 1)
315  {
316  printf("GatewayProfileUsageMethod mismatch: Actual: %"PRIu32", Expected: 1\n",
317  freerdp_settings_get_uint32(settings, FreeRDP_GatewayProfileUsageMethod));
318  goto fail;
319  }
320 #endif
321 
322  if (strcmp(freerdp_settings_get_string(settings, FreeRDP_GatewayHostname),
323  "LAB1-W2K8R2-GW.lab1.awake.local") != 0)
324  {
325  printf("GatewayHostname mismatch: Actual: %s, Expected: %s\n",
326  freerdp_settings_get_string(settings, FreeRDP_GatewayHostname),
327  "LAB1-W2K8R2-GW.lab1.awake.local");
328  goto fail;
329  }
330 
331  if (strcmp(freerdp_settings_get_string(settings, FreeRDP_ServerHostname),
332  "LAB1-W7-DM-01.lab1.awake.local") != 0)
333  {
334  printf("ServerHostname mismatch: Actual: %s, Expected: %s\n",
335  freerdp_settings_get_string(settings, FreeRDP_ServerHostname),
336  "LAB1-W7-DM-01.lab1.awake.local");
337  goto fail;
338  }
339 
340  freerdp_client_rdp_file_free(file);
341  freerdp_settings_free(settings);
342  /* Ascii */
343  file = freerdp_client_rdp_file_new();
344  settings = freerdp_settings_new(0);
345  if (!file || !settings)
346  {
347  printf("rdp_file_new failed\n");
348  goto fail;
349  }
350 
351  if (!freerdp_client_parse_rdp_file_buffer(file, (BYTE*)testRdpFileUTF8,
352  sizeof(testRdpFileUTF8)))
353  goto fail;
354 
355  if (!freerdp_client_populate_settings_from_rdp_file(file, settings))
356  goto fail;
357 
358  if (freerdp_settings_get_bool(settings, FreeRDP_UseMultimon))
359  {
360  printf("UseMultiMon mismatch: Actual: %" PRIu32 ", Expected: 0\n",
361  freerdp_settings_get_bool(settings, FreeRDP_UseMultimon));
362  return -1;
363  }
364 
365  if (!freerdp_settings_get_bool(settings, FreeRDP_Fullscreen))
366  {
367  printf("ScreenModeId mismatch: Actual: %" PRIu32 ", Expected: TRUE\n",
368  freerdp_settings_get_bool(settings, FreeRDP_Fullscreen));
369  return -1;
370  }
371 
372 #if 0 /* TODO: Currently unused */
373  if (freerdp_settings_get_uint32(settings, FreeRDP_GatewayProfileUsageMethod) != 1)
374  {
375  printf("GatewayProfileUsageMethod mismatch: Actual: %"PRIu32", Expected: 1\n",
376  freerdp_settings_get_uint32(settings, FreeRDP_GatewayProfileUsageMethod));
377  goto fail;
378  }
379 #endif
380 
381  if (strcmp(freerdp_settings_get_string(settings, FreeRDP_ServerHostname),
382  "LAB1-W7-DM-01.lab1.awake.global") != 0)
383  {
384  printf("ServerHostname mismatch: Actual: %s, Expected: %s\n",
385  freerdp_settings_get_string(settings, FreeRDP_ServerHostname),
386  "LAB1-W7-DM-01.lab1.awake.global");
387  goto fail;
388  }
389 
390  if (strcmp(freerdp_settings_get_string(settings, FreeRDP_GatewayHostname),
391  "LAB1-W2K8R2-GW.lab1.awake.local") != 0)
392  {
393  printf("GatewayHostname mismatch: Actual: %s, Expected: %s\n",
394  freerdp_settings_get_string(settings, FreeRDP_GatewayHostname),
395  "LAB1-W2K8R2-GW.lab1.awake.local");
396  goto fail;
397  }
398 
399  iValue = freerdp_client_rdp_file_get_integer_option(file, "dynamic resolution");
400  if (iValue != 1080)
401  {
402  printf("dynamic resolution uses invalid default value %d", iValue);
403  goto fail;
404  }
405  if (!freerdp_settings_get_bool(settings, FreeRDP_DynamicResolutionUpdate))
406  {
407  printf("FreeRDP_DynamicResolutionUpdate has invalid value");
408  goto fail;
409  }
410  iValue = freerdp_client_rdp_file_get_integer_option(file, "desktopscalefactor");
411  if (iValue != 1080)
412  {
413  printf("desktopscalefactor uses invalid default value %d", iValue);
414  goto fail;
415  }
416  if ((INT64)freerdp_settings_get_uint32(settings, FreeRDP_DesktopScaleFactor) != iValue)
417  {
418  printf("FreeRDP_DesktopScaleFactor has invalid value");
419  goto fail;
420  }
421 
422  /* Check [MS-RDPECAM] related options */
423 #if defined(CHANNEL_RDPECAM_CLIENT)
424  {
425  ADDIN_ARGV* args = NULL;
426  iValue =
427  freerdp_client_rdp_file_get_integer_option(file, "encode redirected video capture");
428  if (iValue != 1)
429  {
430  printf("encode redirected video capture uses invalid default value %d", iValue);
431  goto fail;
432  }
433  iValue = freerdp_client_rdp_file_get_integer_option(
434  file, "redirected video capture encoding quality");
435  if (iValue != 2)
436  {
437  printf("redirected video capture encoding quality uses invalid default value %d",
438  iValue);
439  goto fail;
440  }
441  args = freerdp_dynamic_channel_collection_find(settings, RDPECAM_DVC_CHANNEL_NAME);
442  if (!args)
443  {
444  printf("rdpecam channel was not loaded");
445  goto fail;
446  }
447  if (args->argc != 6)
448  {
449  printf("rdpecam channel was not loaded");
450  goto fail;
451  }
452 
453  for (int x = 0; x < args->argc; x++)
454  {
455  if (strcmp(args->argv[x], camera_args[x]) != 0)
456  {
457  printf("rdpecam invalid argument argv[%d]: %s", x, args->argv[x]);
458  goto fail;
459  }
460  }
461  }
462 #endif
463 
464  /* Check [URBDRC] related options */
465 #if defined(CHANNEL_URBDRC_CLIENT)
466  {
467  ADDIN_ARGV* args = freerdp_dynamic_channel_collection_find(settings, "urbdrc");
468  if (!args)
469  {
470  printf("urbdrc channel was not loaded");
471  goto fail;
472  }
473  if (args->argc != 4)
474  {
475  printf("urbdrc channel was not loaded");
476  goto fail;
477  }
478 
479  for (int x = 0; x < args->argc; x++)
480  {
481  if (strcmp(args->argv[x], urbdrc_args[x]) != 0)
482  {
483  printf("urbdrc invalid argument argv[%d]: %s", x, args->argv[x]);
484  goto fail;
485  }
486  }
487  }
488 #endif
489 
490  /* Validate selectedmonitors:s:3,2,42,23 */
491  uValue = freerdp_settings_get_uint32(settings, FreeRDP_NumMonitorIds);
492  if (uValue != 4)
493  {
494  printf("FreeRDP_NumMonitorIds has invalid value %" PRIu32, uValue);
495  goto fail;
496  }
497  puValue = (const UINT32*)freerdp_settings_get_pointer_array(settings, FreeRDP_MonitorIds, 0);
498  if (!puValue)
499  {
500  printf("FreeRDP_MonitorIds has invalid value %p", (const void*)puValue);
501  goto fail;
502  }
503  if ((puValue[0] != 3) || (puValue[1] != 2) || (puValue[2] != 42) || (puValue[3] != 23))
504  {
505  printf("FreeRDP_MonitorIds has invalid values: [%" PRIu32 ",%" PRIu32 ",%" PRIu32
506  ",%" PRIu32 "]",
507  puValue[0], puValue[1], puValue[2], puValue[3]);
508  goto fail;
509  }
510 
511  iValue = freerdp_client_rdp_file_get_integer_option(file, "videoplaybackmode");
512  if (iValue != 2)
513  {
514  printf("videoplaybackmode uses invalid default value %d", iValue);
515  goto fail;
516  }
517  if (!freerdp_settings_get_bool(settings, FreeRDP_SupportVideoOptimized))
518  {
519  printf("FreeRDP_SupportVideoOptimized has invalid value");
520  goto fail;
521  }
522  if (!freerdp_settings_get_bool(settings, FreeRDP_SupportGeometryTracking))
523  {
524  printf("FreeRDP_SupportGeometryTracking has invalid value");
525  goto fail;
526  }
527 
528  iValue = freerdp_client_rdp_file_get_integer_option(file, "vendor integer");
529  if (iValue != 123)
530  goto fail;
531 
532  if (freerdp_client_rdp_file_set_integer_option(file, "vendor integer", 456) == -1)
533  {
534  printf("failed to set integer: vendor integer");
535  goto fail;
536  }
537 
538  iValue = freerdp_client_rdp_file_get_integer_option(file, "vendor integer");
539  if (iValue != 456)
540  return -1;
541 
542  const char microsoft[] = "microsoft";
543  sValue = freerdp_client_rdp_file_get_string_option(file, "vendor string");
544  if (strncmp(sValue, microsoft, sizeof(microsoft)) != 0)
545  goto fail;
546 
547  const char apple[] = "apple";
548  freerdp_client_rdp_file_set_string_option(file, "vendor string", "apple");
549  sValue = freerdp_client_rdp_file_get_string_option(file, "vendor string");
550  if (strncmp(sValue, apple, sizeof(apple)) != 0)
551  goto fail;
552 
553  freerdp_client_rdp_file_set_string_option(file, "fruits", "banana,oranges");
554 
555  if (freerdp_client_rdp_file_set_integer_option(file, "numbers", 123456789) == -1)
556  {
557  printf("failed to set integer: numbers");
558  return -1;
559  }
560 
561  freerdp_client_rdp_file_free(file);
562 
563  tmp = GetKnownPath(KNOWN_PATH_TEMP);
564  if (!tmp)
565  goto fail;
566 
567  base = append("%s/rdp-file-test-%" PRIx64, tmp, id);
568  if (!base)
569  goto fail;
570  if (!CreateDirectoryA(base, NULL))
571  goto fail;
572  utfname = append("%s/utfname", base);
573  uniname = append("%s/uniname", base);
574  file = freerdp_client_rdp_file_new();
575  if (!file || !utfname || !uniname)
576  goto fail;
577 
578  if (!freerdp_client_populate_rdp_file_from_settings(file, settings))
579  goto fail;
580 
581  if (!freerdp_client_write_rdp_file(file, utfname, FALSE))
582  goto fail;
583 
584  if (!freerdp_client_write_rdp_file(file, uniname, TRUE))
585  goto fail;
586 
587  rc = 0;
588 fail:
589  if (utfname)
590  winpr_DeleteFile(utfname);
591  if (uniname)
592  winpr_DeleteFile(uniname);
593  if (base)
594  winpr_RemoveDirectory(base);
595  free(utfname);
596  free(uniname);
597  free(base);
598  free(tmp);
599  freerdp_client_rdp_file_free(file);
600  freerdp_settings_free(settings);
601  return rc;
602 }
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 const char * freerdp_settings_get_string(const rdpSettings *settings, FreeRDP_Settings_Keys_String id)
Returns a immutable string settings value.
FREERDP_API void freerdp_settings_free(rdpSettings *settings)
Free a settings struct with all data in it.