Convert string to hex and write file

T

Tim

Hi,

What I am trying to accomplish is to initiate remote desktop session from
within my C# application to XP Pro machine NOT terminal services to a
server.

I have not found any way to do this with code (if you know of a way then I
would love to hear about it). What I have created so far is;

1. Write RDP file to the HD from the code
2. Start process with file as argument

Process rdp = new Process();
rdp.StartInfo.FileName = "mstsc.exe"; //remote desktop
rdp.StartInfo.WorkingDirectory = WorkingDirectory; //dir of rdp file
rdp.StartInfo.Arguments = Arguments; //rdp file
rdp.Start();

This works however I want to save the username and password so that it just
logs the user in automatically.
If you look at an RDP file in notepad you will see that it is all text. If
right click and choose edit you can input a password and click save
password. If you save your changes you get a long binary hash password.

If you open it in notepad and copy everything and paste it into an empty
text file and rename it RDP, you would think you have the same thing. Not
so. Original is 5k, copied version is 3k. There is in fact a whole bunch of
hidden characters. If you open the original in a hex editor then you will
see that the whole file is prepended by ff fe and there is 00 in between
every character.

This is what makes up the extra 2k.So my question is; how do I parse each
line of text (comes from DB), convert it to HEX, insert the 00 value
(whatever that is) and then write it out as a file with a .rdp extension?

I would appreciate any help. Right now I am using
FileStream file = new FileStream(WorkingDirectory + "\\" + Arguments,
System.IO.FileMode.Create);
StreamWriter sw = new StreamWriter(file);
to write the file. Can I use the same thing to write HEX?

Thanks

Tim
 
T

The Other Nice Man

IIRC the 00 between each character in the hex view shows that the
orginal file is Unicode. When you save the file in notepad it defaults
to ANSI.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top