?
Solved

How do I allow my exe to modify it's own resource?

Posted on 2001-08-01
3
Medium Priority
?
174 Views
Last Modified: 2013-11-20
I basically want to be able to modify a resource in my executable as a way of copy-protecting my programs. When the program first runs, I want it to modify a resource, giving it the serial number of the user's C: drive.

Is this possible? I know how to retrieve serial number - I only want to know how to modify "self".

0
Comment
Question by:jhattingh
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 86

Expert Comment

by:jkr
ID: 6340166
>>I want it to modify a resource

This is possible using e.g. 'UpdateReposurce()' (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/hh/winui/resource_2crp.asp) - see also http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/hh/winui/resource_05yr.asp ('Adding, Deleting, and Replacing Resources'). However, there are some restrictions:

  Windows NT/2000 or later: Requires Windows NT 3.1 or later.
  Windows 95/98/Me: Unsupported.
0
 
LVL 12

Expert Comment

by:migel
ID: 6340571
Hi!
Why resource ???
you can write serial id indirect into the EXE file just make sure where serial located in the exe and write nwe value to the founded offset
0
 
LVL 49

Accepted Solution

by:
DanRollins earned 400 total points
ID: 6341211
Easier than migel's suggestion...
Write say, four bytes to the end of the EXE program:

1) at runtime, open the EXE file.  
2) Seek to the end less 4 bytes.
3) Read the next 4 bytes.
4a) If the first two are some special codes (e.g. "jH') then the signature-stamping has already been done.  So verify that the next two bytes match the signature of the executing computer.
4b) If the first two bytes are *NOT* 'jH', calculate the signature stamp and write 'jHxx' to the end of the file -- where xx is your signature stamp.

Note that this will trigger most virus protection software to complain.  One way around that is to rename the EXE to Myprog.Tmp before doing this, then name it back later.  If this is not possible from the EXE, then do it in an installation/setup program.  

Also, the best way *IS* to write to a resource -- but so many users continue to use Win98 that it is not possible to use that as a sole method -- unless you restrict users to Win2K

-- Dan
0

Featured Post

Get proactive database performance tuning online

At Percona’s web store you can order full Percona Database Performance Audit in minutes. Find out the health of your database, and how to improve it. Pay online with a credit card. Improve your database performance now!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question