[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Anton

2/13/2011 12:40:00 AM

My adjunct question got buried in the last post.
What is the best way to embed a string into the compiled code after
compilation?
I would like to put in a serial number of sorts.
All I can think of is to put in a known string in the source, then
search the EXE with a different program I write to find that string and
substitute my unique string. Is there a better way to do this?
I would have to make multiple copies of my EXE then process all of them
to embed the replacement. It is all doable but ...
Is the Resource portion easy to find and modify within the EXE?


7 Answers

mm

2/13/2011 1:32:00 AM

0

El 12/02/11 09:39 p.m., BeeJ escribió:
> My adjunct question got buried in the last post.
> What is the best way to embed a string into the compiled code after
> compilation?
> I would like to put in a serial number of sorts.
> All I can think of is to put in a known string in the source, then
> search the EXE with a different program I write to find that string and
> substitute my unique string. Is there a better way to do this?
> I would have to make multiple copies of my EXE then process all of them
> to embed the replacement. It is all doable but ...
> Is the Resource portion easy to find and modify within the EXE?

May be something like this.

Start a new project and copy this code:

********************************************************
Option Explicit

Private Sub Form_Load()
Dim a As String * 50

a = "EMPTY_STRING______________________________________"

MsgBox "Program compiled with " & a
End Sub
********************************************************

Compile to D:\Project1.exe (or whatever)

Start another project and copy this code:

********************************************************
Option Explicit

Private Sub Form_Load()
Text1.MaxLength = 50
Text1.Text = "Enter the new String here and press enter"
End Sub

Private Sub Text1_KeyPress(KeyAscii As Integer)
Dim iBytes() As Byte
Dim iLen As Long
Dim iStr As String
Dim iPos As Long
Dim iStr50a As String * 50
Dim iStr50b As String * 50
Dim iFilePath As String

If KeyAscii = 13 Then
iFilePath = "d:\project1.exe"
Open iFilePath For Binary Lock Read As #1
iLen = FileLen(iFilePath)
ReDim iBytes(iLen - 1)
Get #1, , iBytes
Close #1

iStr50a = Text1.Text
iStr50b = "EMPTY_STRING______________________________________"

iStr = iBytes
iPos = InStr(iStr, iStr50b)
iStr = Left(iStr, iPos - 1) & iStr50a & Right(iStr, _
Len(iStr) - iPos - 50 + 1)
iBytes = iStr

Open iFilePath & "_customized.exe" For Binary Access Write As #1
Put #1, , iBytes
Close #1
End If
End Sub
********************************************************

Enter something and press Enter. Then run d:\project1.exe_customized.exe

Anton

2/13/2011 2:13:00 AM

0

I'll give it a try tomorrow.
Thanks!


(nobody)

2/13/2011 3:08:00 AM

0

Check UpdateResource() API function.


BeeJ

2/13/2011 3:32:00 PM

0

Nobody was thinking very hard :
> Check UpdateResource() API function.

Other than resource types, what is the advantage of using this?
I could find no VB examples. Some posts aggravated over not being able
to make it work.
The MS C++ Examples are very good but I am weak in translating C++ to
VB. If pressed I might manage it with a little help but is it worth
the effort?
In my case (for now at least) search and replace on a string would be
adequate. Are there any pitfalls using that? i.e. make sure string
length is maintained.


Mayayana

2/13/2011 4:12:00 PM

0

| My adjunct question got buried in the last post.

No it didn't. I answered it: You can edit each
full version binary, but it's much easier to just
include confirmation code that confims a valid
activation code by some formula. I do it by generating
a key from the email address. The full version
EXE can then compare the email string with
the activation code. You could also use a standalone
formula. For instance, the ansi value of the 3rd
character has to be the value of the 1st character
plus 4. Etc. Then your code in the EXE can check for
a valid activation code string *pattern* without needing
to embed the string. (This assumes you only build
the check into your full version, since that approach
is easy to crack.)

I think MS probably uses something like that
method for their Windows keys. Their installer
can recognize a valid product key -- and confirm that
it's valid for the particular version of Windows --
before going online or dealing with product activation.
Presumably that must involve pattern matching.

I guess it depends on what you're selling. If it's
$1,000 and you sell 1 per month then you can
afford to spend time customizing each installer.
If it's $20 and you might sell 10 in 1 day, you'll
have to build 10 custom installers in 1 day. You
might then regret your embedded string design.


| What is the best way to embed a string into the compiled code after
| compilation?
| I would like to put in a serial number of sorts.


(nobody)

2/13/2011 5:18:00 PM

0

"BeeJ" <nospam@live.com> wrote in message
news:ij8ti2$bgs$1@speranza.aioe.org...
> Nobody was thinking very hard :
>> Check UpdateResource() API function.
>
> Other than resource types, what is the advantage of using this?
> I could find no VB examples. Some posts aggravated over not being able to
> make it work.
> The MS C++ Examples are very good but I am weak in translating C++ to VB.
> If pressed I might manage it with a little help but is it worth the
> effort?
> In my case (for now at least) search and replace on a string would be
> adequate. Are there any pitfalls using that? i.e. make sure string
> length is maintained.

I will try to post a VB sample in a separate thread today...


BeeJ

2/13/2011 7:43:00 PM

0

Buried in the sense that others may have missed it.