Hi all..
Probem to use the C#, to create a Terminal Service hs occered me.
1 byte is plus arbitrarily at the end when converting to Unicode byte if the length of the Loadbalance is odd.
Because they become the type string.
It is thought string type is due to be allocated in 2bytes unit in c#, but hous shoud I resolve?
Below is the code I wrote..
string lb = rdpInfo.LoadbalanceInfo;
if (lb.Length % 2 == 1) lb += " ";
else lb += "\r\n";
byte[] b = Encoding.UTF8.GetBytes(lb);
string final = Encoding.Unicode.GetString(b);
sessionView.AdvancedSettings2.LoadBalanceInfo = final;
The length of the stirng is to odd a blank when an odd number as shown in the code, yhou can transform it into a byte,
but it is recognized as a wrong address for 20 hexadecimal, which means blank, connection has not been..
Format of the stirng is presumed to be because the length of the packet byte of conversion is increased by one when the length of the string is odd because it dealt with in 2bytes one character.
AdvancedSettings2.LoadbalanceInfo hs become to a string, but how can how to send a decent packet if the length of the input string is an odd number? Normal Loadbalaninfo packet length is 46. But my Loadbalanceinfo packet is 47.
46 41 E0 00 00 00 00
00 74 73 76 3A 2F 2F 4D 53 20 54 65 72 6D 69 6E
61 6C 20 53 65 72 76 69 63 65 73 20 50 6C 75 67
69 6E 2E 31 2E 43 4F 4C 4C 45 43 54 49 4F 4E 5F
53 48 0D 0A 01 00 08 00 0B 00 00 00 (Packet of a normal connection)
47 42 e0 00 00 00 00
00 74 73 76 3a 2f 2f 4d 53 20 54 65 72 6d 69 6e
61 6c 20 53 65 72 76 69 63 65 73 20 50 6c 75 67
69 6e 2e 31 2e 43 4f 4c 4c 45 43 54 49 4f 4e 5f
53 48 20 0d 0a 01 00 08 00 0b 00 00 00 (Invalid Packet)