Results 1 to 12 of 12
  1. #1
    Bombsaway707's Avatar
    Join Date
    Jun 2009
    Gender
    male
    Location
    Gym
    Posts
    8,799
    Reputation
    791
    Thanks
    4,004
    My Mood
    Amused

    Inputting A String Into A Program Permanently

    Hello All, i was looking for a way to put a string into a program permanently. Im making a portable emailer that you could put on a flash drive. I was wondering how i would go about setting or putting in the persons email and making it stay as a string without using a text file on the flash drive. What i mean is i want the user to set an email and for the email to remain in the program, the only way i know to do this is through the text file. Setting a string within the program doesnt work because the program loses the string when it switches computers.
    Cheers!

  2. #2
    Hassan's Avatar
    Join Date
    May 2010
    Gender
    male
    Location
    System.Threading.Tasks
    Posts
    4,764
    Reputation
    495
    Thanks
    2,133
    My Mood
    Dead
    The only way that I can see it happening is recompiling the application itself by passing the .resources [.resx] file you create at runtime and then pass this file to the EmbeddedResource parameter of your CodeDomProvider instance. To do this, you'll need to:

    1: Create a new instance of CodeDomProvider (C# Code Provider).
    2: Create a new instance of ResourceWriter which is a part of System.Resources namespace. You will need to give it a filename so it knows where to store the resource.
    3: Write your new resource by using the AddResource method of the ResourceWriter instance. E.g: ResourceWriter.AddResource("Password","MyPassword" )
    4: Add the newly generated resource file to the Embedded Resources of CodeDomProvider by using: CodeDomProvider.EmbeddedParameters.Add("PathToNewR esourceFile")
    5: Compile the code to generate a new assembly. (To get rid of the current assembly, you might want to add some code to CodeDomProvider's entry point to delete the current assembly).

    I know this is pretty complex but you can't modify existing embedded resource file when the executable is open. I think that there might be some other way to store the data but I can't think of any of it right now.

  3. The Following User Says Thank You to Hassan For This Useful Post:

    Bombsaway707 (07-12-2012)

  4. #3
    Jason's Avatar
    Join Date
    Apr 2010
    Gender
    male
    Location
    /dev/null
    Posts
    5,704
    Reputation
    918
    Thanks
    7,676
    My Mood
    Mellow
    Quote Originally Posted by Hassan View Post
    The only way that I can see it happening is recompiling the application itself by passing the .resources [.resx] file you create at runtime and then pass this file to the EmbeddedResource parameter of your CodeDomProvider instance. To do this, you'll need to:

    1: Create a new instance of CodeDomProvider (C# Code Provider).
    2: Create a new instance of ResourceWriter which is a part of System.Resources namespace. You will need to give it a filename so it knows where to store the resource.
    3: Write your new resource by using the AddResource method of the ResourceWriter instance. E.g: ResourceWriter.AddResource("Password","MyPassword" )
    4: Add the newly generated resource file to the Embedded Resources of CodeDomProvider by using: CodeDomProvider.EmbeddedParameters.Add("PathToNewR esourceFile")
    5: Compile the code to generate a new assembly. (To get rid of the current assembly, you might want to add some code to CodeDomProvider's entry point to delete the current assembly).

    I know this is pretty complex but you can't modify existing embedded resource file when the executable is open. I think that there might be some other way to store the data but I can't think of any of it right now.
    Or, use My.Settings and set it to application scope? Derp.

    Quote Originally Posted by Jeremy S. Anderson
    There are only two things to come out of Berkley, Unix and LSD,
    and I don’t think this is a coincidence
    You can win the rat race,
    But you're still nothing but a fucking RAT.


    ++Latest Projects++
    [Open Source] Injection Library
    Simple PE Cipher
    FilthyHooker - Simple Hooking Class
    CLR Injector - Inject .NET dlls with ease
    Simple Injection - An in-depth look
    MPGH's .NET SDK
    eJect - Simple Injector
    Basic PE Explorer (BETA)

  5. #4
    Hassan's Avatar
    Join Date
    May 2010
    Gender
    male
    Location
    System.Threading.Tasks
    Posts
    4,764
    Reputation
    495
    Thanks
    2,133
    My Mood
    Dead
    Quote Originally Posted by Jason View Post


    Or, use My.Settings and set it to application scope? Derp.
    Aren't application scope settings read only ?

  6. #5
    Jason's Avatar
    Join Date
    Apr 2010
    Gender
    male
    Location
    /dev/null
    Posts
    5,704
    Reputation
    918
    Thanks
    7,676
    My Mood
    Mellow
    Quote Originally Posted by Hassan View Post


    Aren't application scope settings read only ?
    Yeah, but so are resources :/. Also, you can user scope them if you need, but seeing as he wanted the string to be "permanent", why would he modify it?

    Quote Originally Posted by Jeremy S. Anderson
    There are only two things to come out of Berkley, Unix and LSD,
    and I don’t think this is a coincidence
    You can win the rat race,
    But you're still nothing but a fucking RAT.


    ++Latest Projects++
    [Open Source] Injection Library
    Simple PE Cipher
    FilthyHooker - Simple Hooking Class
    CLR Injector - Inject .NET dlls with ease
    Simple Injection - An in-depth look
    MPGH's .NET SDK
    eJect - Simple Injector
    Basic PE Explorer (BETA)

  7. #6
    Hassan's Avatar
    Join Date
    May 2010
    Gender
    male
    Location
    System.Threading.Tasks
    Posts
    4,764
    Reputation
    495
    Thanks
    2,133
    My Mood
    Dead
    Quote Originally Posted by Jason View Post


    Yeah, but so are resources :/. Also, you can user scope them if you need, but seeing as he wanted the string to be "permanent", why would he modify it?
    He wants the user to input the email. So that won't work with the application scope. And if he is going to use user scope, the app will lose its settings when the application is moved to another computer. So, once he enters the email, it needs to be entered to the resource file.
    Last edited by Hassan; 07-12-2012 at 10:29 AM.

  8. #7
    Jason's Avatar
    Join Date
    Apr 2010
    Gender
    male
    Location
    /dev/null
    Posts
    5,704
    Reputation
    918
    Thanks
    7,676
    My Mood
    Mellow
    Quote Originally Posted by Hassan View Post


    He wants the user to input the email. So that won't work with the application scope. And if he is going to use user scope, the app will lose its settings when the application is moved to another computer. So, once he enters the email, it needs to be entered to the resource file.
    No, My.Settings stores internally, even via the User scope. If he moves the same .exe to another computer, the settings will be the same. Try it and see

    Quote Originally Posted by Jeremy S. Anderson
    There are only two things to come out of Berkley, Unix and LSD,
    and I don’t think this is a coincidence
    You can win the rat race,
    But you're still nothing but a fucking RAT.


    ++Latest Projects++
    [Open Source] Injection Library
    Simple PE Cipher
    FilthyHooker - Simple Hooking Class
    CLR Injector - Inject .NET dlls with ease
    Simple Injection - An in-depth look
    MPGH's .NET SDK
    eJect - Simple Injector
    Basic PE Explorer (BETA)

  9. #8
    Hassan's Avatar
    Join Date
    May 2010
    Gender
    male
    Location
    System.Threading.Tasks
    Posts
    4,764
    Reputation
    495
    Thanks
    2,133
    My Mood
    Dead
    Quote Originally Posted by Jason View Post


    No, My.Settings stores internally, even via the User scope. If he moves the same .exe to another computer, the settings will be the same. Try it and see
    What ? No, it doesn't. It even loses the settings if I move the app from one location to another with in the same computer. The settings are stored in local filesystem under Application Data folder.

  10. #9
    Jason's Avatar
    Join Date
    Apr 2010
    Gender
    male
    Location
    /dev/null
    Posts
    5,704
    Reputation
    918
    Thanks
    7,676
    My Mood
    Mellow
    Quote Originally Posted by Hassan View Post


    What ? No, it doesn't. It even loses the settings if I move the app from one location to another with in the same computer. The settings are stored in local filesystem under Application Data folder.
    What ze fuck? Worked for me fine in the past going from PC to PC. Odd.

    Quote Originally Posted by Jeremy S. Anderson
    There are only two things to come out of Berkley, Unix and LSD,
    and I don’t think this is a coincidence
    You can win the rat race,
    But you're still nothing but a fucking RAT.


    ++Latest Projects++
    [Open Source] Injection Library
    Simple PE Cipher
    FilthyHooker - Simple Hooking Class
    CLR Injector - Inject .NET dlls with ease
    Simple Injection - An in-depth look
    MPGH's .NET SDK
    eJect - Simple Injector
    Basic PE Explorer (BETA)

  11. #10
    Hassan's Avatar
    Join Date
    May 2010
    Gender
    male
    Location
    System.Threading.Tasks
    Posts
    4,764
    Reputation
    495
    Thanks
    2,133
    My Mood
    Dead
    Quote Originally Posted by Jason View Post


    What ze fuck? Worked for me fine in the past going from PC to PC. Odd.
    Hmm, funny how I never experienced that.

  12. #11
    Bombsaway707's Avatar
    Join Date
    Jun 2009
    Gender
    male
    Location
    Gym
    Posts
    8,799
    Reputation
    791
    Thanks
    4,004
    My Mood
    Amused
    Quote Originally Posted by Hassan View Post
    The only way that I can see it happening is recompiling the application itself by passing the .resources [.resx] file you create at runtime and then pass this file to the EmbeddedResource parameter of your CodeDomProvider instance. To do this, you'll need to:

    1: Create a new instance of CodeDomProvider (C# Code Provider).
    2: Create a new instance of ResourceWriter which is a part of System.Resources namespace. You will need to give it a filename so it knows where to store the resource.
    3: Write your new resource by using the AddResource method of the ResourceWriter instance. E.g: ResourceWriter.AddResource("Password","MyPassword" )
    4: Add the newly generated resource file to the Embedded Resources of CodeDomProvider by using: CodeDomProvider.EmbeddedParameters.Add("PathToNewR esourceFile")
    5: Compile the code to generate a new assembly. (To get rid of the current assembly, you might want to add some code to CodeDomProvider's entry point to delete the current assembly).

    I know this is pretty complex but you can't modify existing embedded resource file when the executable is open. I think that there might be some other way to store the data but I can't think of any of it right now.
    Thank you! Ill be trying that tonight and letting you know how it went, ive always wondered how to do this

  13. #12
    DawgiiStylz's Avatar
    Join Date
    Aug 2009
    Gender
    male
    Location
    Dawg House
    Posts
    7,811
    Reputation
    219
    Thanks
    2,896
    My Mood
    Tired
    Hmm.. I always thought it was saved in the program. Guess that makes sense
    Quote Originally Posted by Hassan View Post


    What ? No, it doesn't. It even loses the settings if I move the app from one location to another with in the same computer. The settings are stored in local filesystem under Application Data folder.

Similar Threads

  1. Getting into Computer Programming
    By Elegant Elephant in forum Coders Lounge
    Replies: 19
    Last Post: 02-18-2012, 07:02 AM
  2. [Tut]Merging .dlls into your program
    By Blubb1337 in forum Visual Basic Programming
    Replies: 12
    Last Post: 10-28-2010, 09:27 AM
  3. [Tutorial] Inputting Addies into your Hacks (Including Teleport Hack)
    By ppl2pass in forum Combat Arms Hack Coding / Programming / Source Code
    Replies: 6
    Last Post: 09-24-2010, 11:39 AM
  4. Merging Files into VB Program
    By ppl2pass in forum Visual Basic Programming
    Replies: 0
    Last Post: 02-18-2010, 10:51 PM
  5. How to make your program minimize into the task bar?
    By deathninjak0 in forum Visual Basic Programming
    Replies: 8
    Last Post: 11-29-2009, 05:01 AM