Okay. I'm trying to figure out something using SwiftForth, and I know it
is very dependant on that, so if anyone knows, much help appreciated!
Short background: what I want to do is for copy protection purposes, so
please, no comments on "why?" or "that's silly" :)
I need to know _exactly_ where in my compiled EXE the data for a CONSTANT
is placed. For example:
0 CONSTANT code-gen
: CHECK ( -- b )
code-gen 0<> ;
PROGRAM foo.exe
Now, I have a website setup that will let the end-user download a copy of
the program, but right before the download occurs, the 4-byte value that
"code-gen" loads is overwritten with a valid value. This value is unique
to the end-user and the program will cease to function if wrong. I
certainly hope this makes sense.
I've though about possibly looking at foo.exe with a hex editor,
searching for "code-gen" the word and then looking for the 4-bytes around
it that are 0, but if there were a more "definitive" way of doing this
would be great, as in the future the position of the CONSTANT may change.
--
Best regards,
Jeff Massung jma[at]mfire.com
http://www.jm-basic.com
|
|
0
|
|
|
|
Reply
|
Jeff
|
12/2/2003 3:05:16 AM |
|
"Jeff Massung" <jma[at]nospam.mfire.com> a �crit dans le message de
news:Xns9444CC5919804jeffmapeoplepccom@216.168.3.50...
> Okay. I'm trying to figure out something using SwiftForth, and I know it
> is very dependant on that, so if anyone knows, much help appreciated!
>
> Short background: what I want to do is for copy protection purposes, so
> please, no comments on "why?" or "that's silly" :)
>
> I need to know _exactly_ where in my compiled EXE the data for a CONSTANT
> is placed. For example:
>
> 0 CONSTANT code-gen
>
> : CHECK ( -- b )
> code-gen 0<> ;
>
> PROGRAM foo.exe
>
> Now, I have a website setup that will let the end-user download a copy of
> the program, but right before the download occurs, the 4-byte value that
> "code-gen" loads is overwritten with a valid value. This value is unique
> to the end-user and the program will cease to function if wrong. I
> certainly hope this makes sense.
>
> I've though about possibly looking at foo.exe with a hex editor,
> searching for "code-gen" the word and then looking for the 4-bytes around
> it that are 0, but if there were a more "definitive" way of doing this
> would be great, as in the future the position of the CONSTANT may change.
You may search for the name field in the exe file, then compute
the offset to the pfa:
' code-gen >name count type \ code-gen ok
' code-gen dup >name swap >body - . \ -15 ok
Charles
>
> --
> Best regards,
> Jeff Massung jma[at]mfire.com
>
> http://www.jm-basic.com
|
|
0
|
|
|
|
Reply
|
mail3749 (34)
|
12/2/2003 1:09:27 PM
|
|
Op Tue, 02 Dec 2003 03:05:16 -0000 schreef Jeff Massung
<jma[at]nospam.mfire.com>:
>Okay. I'm trying to figure out something using SwiftForth, and I know it
>is very dependant on that, so if anyone knows, much help appreciated!
>
>Short background: what I want to do is for copy protection purposes, so
>please, no comments on "why?" or "that's silly" :)
>
>I need to know _exactly_ where in my compiled EXE the data for a CONSTANT
>is placed. For example:
>
>0 CONSTANT code-gen
>
>: CHECK ( -- b )
> code-gen 0<> ;
>
>PROGRAM foo.exe
>
>Now, I have a website setup that will let the end-user download a copy of
>the program, but right before the download occurs, the 4-byte value that
>"code-gen" loads is overwritten with a valid value. This value is unique
>to the end-user and the program will cease to function if wrong. I
>certainly hope this makes sense.
>
>I've though about possibly looking at foo.exe with a hex editor,
>searching for "code-gen" the word and then looking for the 4-bytes around
>it that are 0, but if there were a more "definitive" way of doing this
>would be great, as in the future the position of the CONSTANT may change.
Why would you change a constant, its instances could be compiled
as literals in the code, so changing it later on would not have
effect.
Like the ALTER statement in COBOL: very bad sort of programming!
This is where VALUEs are for.
Coos
|
|
0
|
|
|
|
Reply
|
j.j.haREMOVEak (5)
|
12/2/2003 4:33:34 PM
|
|
Coos Haak <j.j.haREMOVEak@hccTHISnet.nl> wrote in
news:difpsvojral3ls64klng9av9lojr9vmssj@4ax.com:
> Op Tue, 02 Dec 2003 03:05:16 -0000 schreef Jeff Massung
> <jma[at]nospam.mfire.com>:
>
>>I need to know _exactly_ where in my compiled EXE the data for a
>>CONSTANT is placed. For example:
>>
>>0 CONSTANT code-gen
>>
>>
>>I've though about possibly looking at foo.exe with a hex editor,
>>searching for "code-gen" the word and then looking for the 4-bytes
>>around it that are 0, but if there were a more "definitive" way of
>>doing this would be great, as in the future the position of the
>>CONSTANT may change.
>
> Why would you change a constant, its instances could be compiled
> as literals in the code, so changing it later on would not have
> effect.
> Like the ALTER statement in COBOL: very bad sort of programming!
> This is where VALUEs are for.
>
Coos,
Your right. Thanks. I just changed it to CREATE code-gen 0 , instead.
Fixed :)
--
Best regards,
Jeff mailto:jma@mfire.com
http://www.simforth.com
|
|
0
|
|
|
|
Reply
|
jma (133)
|
12/2/2003 6:14:38 PM
|
|
Jeff Massung wrote:
>
> Okay. I'm trying to figure out something using SwiftForth, and I know it
> is very dependant on that, so if anyone knows, much help appreciated!
>
> Short background: what I want to do is for copy protection purposes, so
> please, no comments on "why?" or "that's silly" :)
>
> I need to know _exactly_ where in my compiled EXE the data for a CONSTANT
> is placed. For example:
>
> 0 CONSTANT code-gen
>
> : CHECK ( -- b )
> code-gen 0<> ;
>
> PROGRAM foo.exe
>
> Now, I have a website setup that will let the end-user download a copy of
> the program, but right before the download occurs, the 4-byte value that
> "code-gen" loads is overwritten with a valid value. This value is unique
> to the end-user and the program will cease to function if wrong. I
> certainly hope this makes sense.
>
> I've though about possibly looking at foo.exe with a hex editor,
> searching for "code-gen" the word and then looking for the 4-bytes around
> it that are 0, but if there were a more "definitive" way of doing this
> would be great, as in the future the position of the CONSTANT may change.
>
> --
> Best regards,
> Jeff Massung jma[at]mfire.com
>
> http://www.jm-basic.com
In ANS Forth the location of the data in a CONSTANT is not specified because
CONSTANTs are not to be varied. But you can define a defining word
: "CONSTANT" CREATE , DOES> @ ;
and know that anything defined with "CONSTANT" has its data stored in a
location accessible with >BODY. As in
37 "CONSTANT" x ok
' x >body @ . 37 ok
In Win32Forth or GForth this also works with a regular CONSTANT, as in
-49 constant y ok
' y >body @ . -49 ok
15 ' y >body ! ok
y . 15 ok
But in general that need not work.
--
Julian V. Noble
Professor Emeritus of Physics
jvn@lessspamformother.virginia.edu
^^^^^^^^^^^^^^^^^^
http://galileo.phys.virginia.edu/~jvn/
"God is not willing to do everything, and thereby take away that
share of glory that rightfully belongs to ourselves."
-- N. Machiavelli, "The Prince".
|
|
0
|
|
|
|
Reply
|
jvn1 (150)
|
12/2/2003 9:26:33 PM
|
|
|
4 Replies
43 Views
(page loaded in 0.454 seconds)
|