Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 527513
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T08:53:27+00:00 2026-05-13T08:53:27+00:00

I looking for example of program, that modifies a string inside its exe. I

  • 0

I looking for example of program, that modifies a string inside its exe.

I work with C++, Visual Studio under Windows.

I searched working examples in Windows, but I can’t find any working code.

I need simple code, that will ask user for string:

string strTest = "";
(if strTest != "")
{
   cout << "Modified: " << strTest << endl;
}
cin >> strText;

And code should rewrite:

string strTest = "";

To string that typed user:

string strTest = "SomeStringFromUser"; 

How, in C++, do you modify a string (from string strTest = “”), to string, what a user typed? (for example to strTest = “foo”)?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T08:53:28+00:00Added an answer on May 13, 2026 at 8:53 am

    When an EXE is running on a Windows machine, the exe file is held open as a CreateFileMapping object with pages marked either as READONLY or COPY_ON_WRITE.

    So when the exe writes to itself, the file is not modified. It just creates a new page backed by the swap file. But since the file is kept open, no-one else can open the EXE file and write to it either.

    Other than hacking the page protection to turn off COPY_ON_WRITE – Which I’m not sure is even possible. The only way I can think to do this would be to write a little program that runs after your exe finishes and opens the .exe file and writes to it.

    I’ve gotta believe that whatever you are trying to do, there is a better way to go about it.

    — Later —-

    Ok, I get it now. you are looking to watermark your exe. Here’s the thing, this is pretty easy to do in your installer before the exe starts. But once the .exe is running it’s MUCH harder to do.

    Here’s what I would do.

    • declare a global string variable of the necessary size, say const char g_szWatermark[100] = "";
    • Build my exe, then look in the map file to find the address of the variable within its segment (remember about C++ name decoration)
    • parse the EXE header to find the where the segment begins in the exe.
    • add these two numbers to get the location of the string within the exe file, give this number to my installer
    • have the installer run a little program that asks the user for information and then writes it into the .exe. Note: you have do do this before the exe runs or it won’t work!
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 369k
  • Answers 369k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Using * as a selector is a pretty bad idea.… May 14, 2026 at 6:23 pm
  • Editorial Team
    Editorial Team added an answer Could you do something like... data: {target: event.target, info: $("#pnl_info").val()} May 14, 2026 at 6:23 pm
  • Editorial Team
    Editorial Team added an answer No, a List<Dog> is not a List<Animal>. Consider what you… May 14, 2026 at 6:23 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.