1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
use ms_dtyp::{FILETIME, WCHAR};
#[derive(Clone, Debug, PartialEq)]
pub struct PAC_CLIENT_INFO {
pub ClientId: FILETIME,
pub Name: Vec<WCHAR>,
}
impl PAC_CLIENT_INFO {
pub fn new(ClientId: FILETIME, Name: &str) -> Self {
return Self {
ClientId,
Name: Name.encode_utf16().collect(),
};
}
pub fn build(&self) -> Vec<u8> {
let mut data = Vec::new();
data.append(&mut self.ClientId.to_le_bytes().to_vec());
data.append(&mut ((self.Name.len()*2) as u16).to_le_bytes().to_vec());
for c in self.Name.iter() {
data.append(&mut c.to_le_bytes().to_vec());
}
return data;
}
}
#[cfg(test)]
mod test {
use super::*;
#[test]
fn test_build_pac_client_info() {
let client =
PAC_CLIENT_INFO::new(0x1d633f10ea77a00.into(), "stegosaurus");
assert_eq!(
vec![
0x00, 0x7A, 0xA7, 0x0E, 0xF1, 0x33, 0xD6, 0x01, 0x16, 0x00,
0x73, 0x00, 0x74, 0x00, 0x65, 0x00, 0x67, 0x00, 0x6F, 0x00,
0x73, 0x00, 0x61, 0x00, 0x75, 0x00, 0x72, 0x00, 0x75, 0x00,
0x73, 0x00
],
client.build()
);
}
}