From: Jerry West on
I have a old VB6 exe that is important to a client for continued use. The
source code is not available. A hard coded string within the source code
needs to be changed, otherwise the exe is no longer of use to them. Is it
possible to use a HexEditor to open the exe and change the string and resave
the exe? Would this idea be a viable solution? The string is not a constant.
It is a hard coded string in the source. I did try opening the file in a Hex
editor but only found it showed the strings that were declared as
constants --I could not see any strings that were actually in the code
itself.

Can anybody shed some light on this?

Thanks!

JW

From: Karl E. Peterson on
Jerry West wrote:
> I have a old VB6 exe that is important to a client for continued use. The
> source code is not available. A hard coded string within the source code
> needs to be changed, otherwise the exe is no longer of use to them. Is it
> possible to use a HexEditor to open the exe and change the string and resave
> the exe?

As long as you just overwrite it. I imagine it could get very dicey if
you tried changing the length of it. Especially if you tried to
lengthen it. You could fairly easily shorten it, for most purposes, by
filling the end of it with null chars.

> Would this idea be a viable solution?

I can't see why not.

> The string is not a constant.
> It is a hard coded string in the source. I did try opening the file in a Hex
> editor but only found it showed the strings that were declared as constants
> --I could not see any strings that were actually in the code itself.

Maybe I don't understand your "in the code" comment, then? Something
like this?

Private Sub Timer1_Timer()
Label1.Caption = Format$(Now, "long time")
End Sub

I just compiled that, opened the EXE in a hex editor (Cygnus), and had
no problem finding the "long time" string. Are you doing a Unicode
search?

--
..NET: It's About Trust!
http://vfred.mvps.org


From: Karl E. Peterson on
Karl E. Peterson wrote:
> Jerry West wrote:
>> I have a old VB6 exe that is important to a client for continued use. The
>> source code is not available. A hard coded string within the source code
>> needs to be changed, otherwise the exe is no longer of use to them. Is it
>> possible to use a HexEditor to open the exe and change the string and
>> resave the exe?
>
> As long as you just overwrite it. I imagine it could get very dicey if you
> tried changing the length of it. Especially if you tried to lengthen it.
> You could fairly easily shorten it, for most purposes, by filling the end of
> it with null chars.

Just confirmed this. I changed the text in a MsgBox string, and it
worked just fine. I even truncated it by padding it out with 00's.

But, when I inserted new bytes, to try extending it, the program blew
chunks when starting.

So, there ya go.

--
..NET: It's About Trust!
http://vfred.mvps.org


From: dpb on
Jerry West wrote:
> I have a old VB6 exe that is important to a client for continued use.
> The source code is not available. A hard coded string within the source
> code needs to be changed, otherwise the exe is no longer of use to them.
> Is it possible to use a HexEditor to open the exe and change the string
> and resave the exe? Would this idea be a viable solution? The string is
> not a constant. It is a hard coded string in the source. I did try
> opening the file in a Hex editor but only found it showed the strings
> that were declared as constants --I could not see any strings that were
> actually in the code itself.
>
> Can anybody shed some light on this?

The string is embedded in the executable if it is a constant string. It
will be unicode though, so a simple ASCII search won't find it easily.

But, if you can change it to a usable string in the same length
constraints, sure, you can hack on the executable. In olden days, much
code was maintained this way for lack of easier tools and/or the high
cost of rebuilding that is a way long forgotten (thankfully)...

Just be careful to have backups before you start.

--
From: DanS on
"Jerry West" <jw(a)comcast.net> wrote in
news:_cWdne91_6KZQ-PWnZ2dnUVZ_h2dnZ2d(a)giganews.com:

> I have a old VB6 exe that is important to a client for continued use.
> The source code is not available. A hard coded string within the
> source code needs to be changed, otherwise the exe is no longer of use
> to them. Is it possible to use a HexEditor to open the exe and change
> the string and resave the exe? Would this idea be a viable solution?
> The string is not a constant. It is a hard coded string in the source.
> I did try opening the file in a Hex editor but only found it showed
> the strings that were declared as constants --I could not see any
> strings that were actually in the code itself.

I've not had to do any replacements like this on a VB6 app.

Caveat.....the new string needs to be the same length as the original
string. If it's shorter, you can pad it with spaces at the end (if that's
not going to affect 'something'). But you can;t put a longer string in
there.

Are strings stored in Unicode in a VB app ? I think so, so search for the
strings characters with zero's too......

"test" = &h74 &h65 &h73 &h74

Unicode "test" = &h74 &h0 &h65 &h0 &h73 &h0 &h74 &h0

I don't think VB is big-endian (but I may be corrected).