• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 199
  • Last Modified:

How to change an ID number in an exe file without recompiling it

Hi,

it was not easy to find an appropriate title for my question. I'll try to explain my problem as clear as possible.
I have to write a small application, which does set a special bit in the memory of a hardware device. I already have the application which sets the bit, BUT this bit may not be set in every device. Only devices with a special hardware ID may have set this bit.
The problem is, that the hardware IDs which may have set this bit are not known at compliling time. The valid hardware ID has to be set in the application later.
This bit is for some kind of security reason. Therefore it is important that the hardware ID can not be chosen by anyone, so that the bit can not be set in any device (no *.ini file).
This change in the application must be possible on every computer, even if there is no compiler installed.

Is there some possibility of having a small standalone compiler or something like this? Any other ideas?

I hope I made myself clear enough... Otherwise just ask.

Thank you very much
0
Bohne
Asked:
Bohne
  • 3
  • 3
1 Solution
 
Jaime OlivaresCommented:
I think best approach is to save ID as a resource (like a bitmap or icon inside your app), so you can change it without recompiling.
Is your app a Windows GUI application?
0
 
BohneAuthor Commented:
yes it's a MFC GUI application in Visual Studio C++. How do I get this resource into my application? And is it secure, can nobody else change this resource?
0
 
Jaime OlivaresCommented:
>>And is it secure, can nobody else change this resource?
There doesn't exist a secure method by itself, anybody can change your app and you can't avoid it in any way, but you can encrypt your data so if other user try to change it, you can detect it with some kind of CRC or hash algorithm.
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
BohneAuthor Commented:
So how do I change this resource? Can I write a small second application which changes the resource?
0
 
BohneAuthor Commented:
I have now stored the ID in the String Table resource of my application. So I can change this string (e.g. with Resource Hacker) and everything works. But how do I change this string with a self programmed tool (which should be much more simple than Resource Hacker)? Are there any examples on changing a resource of an exe file in Visual Studio C++?
0
 
Jaime OlivaresCommented:
It is something like this (not tested):

BOOL UpdateTextRes(LPCTSTR filename, LPCTSTR resname, LPCTSTR str)   // Tip: use upercase for all strings
{
      HANDLE hRes = ::BeginUpdateResource(filename, FALSE);
      if (!hRes) {
          ::AfxMessageBox("Error opening file");
      } else {
          BOOL result = ::UpdateResource(hRes, RT_RCDATA, resname, 0, str, strlen(str));  // notice resource type: RCDATA
          ::EndUpdateResource(hRes, !result);
      }
      return result;   // returns true if sucessfully updated
}

more information at:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/resources/introductiontoresources/addingdeletingandreplacingresources.asp
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now