Convert string to hex and write file

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Tim

    Convert string to hex and write file

    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.F ileName = "mstsc.exe" ; //remote desktop
    rdp.StartInfo.W orkingDirectory = WorkingDirector y; //dir of rdp file
    rdp.StartInfo.A rguments = 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(Work ingDirectory + "\\" + Arguments,
    System.IO.FileM ode.Create);
    StreamWriter sw = new StreamWriter(fi le);
    to write the file. Can I use the same thing to write HEX?

    Thanks

    Tim


  • The Other Nice Man

    #2
    Re: Convert string to hex and write file

    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.

    Comment

    Working...