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
Solved

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

Posted on 2001-08-01
3
159 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
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 100 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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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 is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
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.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

829 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