Thread: Re: [Dev-C++] Split code in public/private parts - Help please
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Ferdinando F. <s2...@st...> - 2004-01-10 18:57:35
|
> How can I compile "part two" (which has no "main" function), > so that the source code cannot be seen anymore ? You can put "part two" in a separate file, and compile it singularly, then distribute the output file (with .o extension). > Then, how can I compile "part one" source code (which has > the "main" function) with "part two" compiled version? You have to include in your project the .o file selecting "include in link" and deselecting "include in compilation", or equivalently build a library from it (a .a file), call it e.g. libp2.a, and specify "-lp2" in linker options. > How can I make sure it is not possible > to call directly another function of "part two" ? _Really_ you can't, but only who knows the implementation (or is a good and patient reverse engineer) know what's inside an object file. You should put declarations for all functions you would like a programmer to call in a header (.h) and distribute it with your .o or .a file. Bye, Ferdinando. |
|
From: Haakon M. E. <ha...@nh...> - 2004-01-11 12:51:04
|
I think Jean-Marc is asking about something else - code obfuscation. There are several references about wanting to hide what the source code does. Why do you want this, Jean-Marc? Yours sincerely, Haakon Meland Eriksen |
|
From: Jean-Marc G. <go...@sk...> - 2004-01-11 14:29:11
|
I thank you all for your advice/comments.
You are right about my intents, Haakon. I am marketing a kinda complex
"mathematical" algorithm for planning trips/tours. Since this algorithm has
to be interfaced by customers, once compiled, I want the source code of the
algorithm to be "hidden" (as far as the customers don't try to do
decompilation or reverse engineering). I definitely do not want customers to
see what the algorithm does but also not the names of "private"
functions/variables, except for the main function (called "algorithm()") and
its parameters, of course.
Any additional advice/reference on this topic ? Also, if you have
ideas/references about how I can make decompilation and reverse engineering
more difficult, I would be very pleased to know them.
Again and by advance, thank you.
Best regards,
Jean-Marc
----- Original Message -----
From: "Haakon M. Eriksen" <ha...@nh...>
To: "Per Westermark" <pw...@ia...>; "Jean-Marc Godart"
<go...@sk...>
Cc: <dev...@li...>; "Ferdinando Formica"
<s2...@st...>
Sent: Sunday, January 11, 2004 1:50 PM
Subject: RE: [Dev-C++] Split code in public/private parts - Help please
> I think Jean-Marc is asking about something else - code obfuscation.
> There are several references about wanting to hide what the source code
> does. Why do you want this, Jean-Marc?
>
>
> Yours sincerely,
>
>
>
> Haakon Meland Eriksen
>
>
>
> -------------------------------------------------------
> This SF.net email is sponsored by: Perforce Software.
> Perforce is the Fast Software Configuration Management System offering
> advanced branching capabilities and atomic changes on 50+ platforms.
> Free Eval! http://www.perforce.com/perforce/loadprog.html
> _______________________________________________
> Dev-cpp-users mailing list
> Dev...@li...
> TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm
> https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
>
>
>
|
|
From: <or...@vp...> - 2004-01-11 14:41:10
|
Jean-Marc Godart wrote: > I thank you all for your advice/comments. > > You are right about my intents, Haakon. I am marketing a kinda complex > "mathematical" algorithm for planning trips/tours. Since this algorithm has > to be interfaced by customers, once compiled, I want the source code of the > algorithm to be "hidden" (as far as the customers don't try to do > decompilation or reverse engineering). I definitely do not want customers to > see what the algorithm does but also not the names of "private" > functions/variables, except for the main function (called "algorithm()") and > its parameters, of course. > > Any additional advice/reference on this topic ? Also, if you have > ideas/references about how I can make decompilation and reverse engineering > more difficult, I would be very pleased to know them. Well, this is theoretically impossible. Nearly everything can be cracked/reverse engineered nowadays. However, you may try writing a small program that scans all of your source code, and then renames everything inside: variable, function names, except what you specify not to rename. Then you compile that. That way, you won't get lost in your sources, as you develop the "readable" version, but compile the "renamed" one. That may help some, though you will have to write a new program, the code parser/renamer. -- Greetings, Balázs |
|
From: Per W. <pw...@ia...> - 2004-01-11 14:56:42
|
If the program will only export a single algorithm() function, there are no need to bother with changing names of all internal variables and functions. It is - as I said in an earlier mail - enought to declare them static. These symbols will then be hidden from the linker - no symbol names to be found in the object - or library - file. It is enough to make sure the object file is built without debugging information and that it is stripped. Anyway - are you sure that your algorithm are really so revolutionary that you need to take the time to protect it? There are really a huge set of available algorithms for performing routing, flow optimizations etc. The biggest trick is to decide which algorithm to use. Then a large set of these algorithms are available with free source code. What I'm trying to say is that in most cases, it costs more to try and protect code than what is to be gained. Unless really drastic measures are taken, a competent hacker will most probably walk through your algorithm in a very limited time. The question is: does he/she have a reason to? /Per W On Sun, 11 Jan 2004, OROSZI Bal=E1zs wrote: > Jean-Marc Godart wrote: > > I thank you all for your advice/comments. > > > > You are right about my intents, Haakon. I am marketing a kinda complex > > "mathematical" algorithm for planning trips/tours. Since this algorithm= has > > to be interfaced by customers, once compiled, I want the source code of= the > > algorithm to be "hidden" (as far as the customers don't try to do > > decompilation or reverse engineering). I definitely do not want custome= rs to > > see what the algorithm does but also not the names of "private" > > functions/variables, except for the main function (called "algorithm()"= ) and > > its parameters, of course. > > > > Any additional advice/reference on this topic ? Also, if you have > > ideas/references about how I can make decompilation and reverse enginee= ring > > more difficult, I would be very pleased to know them. > > Well, this is theoretically impossible. Nearly everything can be > cracked/reverse engineered nowadays. > > However, you may try writing a small program that scans all of your > source code, and then renames everything inside: variable, function > names, except what you specify not to rename. Then you compile that. > That way, you won't get lost in your sources, as you develop the > "readable" version, but compile the "renamed" one. > That may help some, though you will have to write a new program, the > code parser/renamer. > > -- > Greetings, > Bal=E1zs > > > > > ------------------------------------------------------- > This SF.net email is sponsored by: Perforce Software. > Perforce is the Fast Software Configuration Management System offering > advanced branching capabilities and atomic changes on 50+ platforms. > Free Eval! http://www.perforce.com/perforce/loadprog.html > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > |
|
From: Jean-Marc G. <go...@sk...> - 2004-01-11 11:07:18
|
Thanks a lot for your very adequate answer, Ferdinando.
I have two extra questions, based on your answer ... Sorry it is a little
off-topic now since it is more like a general C question.
(1) What is the difference between a ".o" file and a ".lib" file (library)
and how can I convert one in the other ?
(2) I understand it is not possible to prevent someone from calling all of
the functions in the ".o" file. Yet, I just noticed the names of all my
variables and functions appear "in clear" in the code of the ".o" file (when
opening it with a text processor). Is there a way to avoid this (as the
names are explicit and give hints about the way the program works) ? Of
course, I can just give names as "a", "b", "c"... but then I get lost in my
source code. I tried to use "static" but it does not change a thing ...
Any help is welcome !
Thanks again,
Jean-Marc
----- Original Message -----
From: "Ferdinando Formica" <s2...@st...>
To: <go...@sk...>
Cc: "Dev-C++ Mailing List" <dev...@li...>
Sent: Saturday, January 10, 2004 7:51 PM
Subject: Re: [Dev-C++] Split code in public/private parts - Help please
>
> > How can I compile "part two" (which has no "main" function),
> > so that the source code cannot be seen anymore ?
>
> You can put "part two" in a separate file, and compile it singularly, then
> distribute the output file (with .o extension).
>
> > Then, how can I compile "part one" source code (which has
> > the "main" function) with "part two" compiled version?
>
> You have to include in your project the .o file selecting "include in
> link" and deselecting "include in compilation", or equivalently build a
> library from it (a .a file), call it e.g. libp2.a, and specify "-lp2" in
> linker options.
>
> > How can I make sure it is not possible
> > to call directly another function of "part two" ?
>
> _Really_ you can't, but only who knows the implementation (or is a good
> and patient reverse engineer) know what's inside an object file. You
> should put declarations for all functions you would like a programmer to
> call in a header (.h) and distribute it with your .o or .a file.
>
> Bye, Ferdinando.
>
>
>
|
|
From: Per W. <pw...@ia...> - 2004-01-11 11:41:12
|
A library is a collection of multiple object files. There are a lot of
good references out there.
If any other object file must call your functions, you might do
/* private_include_file.h */
#define eval_area get_lost_1
#define solve_root get_lost_2
...
and then your code will be
#include "private_include_file.h"
void my_callable_function(void) {
...
if (eval_area(1,2,3) > 0) {
solve_root(4,5,6);
}
}
If your variables and functions doesn't need to be accessed from the
outside, it is enough to declare them static, i.e.:
/* my_private_file.c */
static int private_variable_1;
static float private_variable_2;
char public_version[] = "My callable module version 1.02.01";
static int eval_area(int a,int b,int c) {
....
return a+b+c;
}
void my_callable_function(void) {
...
if (eval-area(1,2,3) > 0) {
solve_root(4,5,6);
}
}
/Per W
On Sun, 11 Jan 2004, Jean-Marc Godart wrote:
> Thanks a lot for your very adequate answer, Ferdinando.
>
> I have two extra questions, based on your answer ... Sorry it is a little
> off-topic now since it is more like a general C question.
>
> (1) What is the difference between a ".o" file and a ".lib" file (library)
> and how can I convert one in the other ?
>
> (2) I understand it is not possible to prevent someone from calling all of
> the functions in the ".o" file. Yet, I just noticed the names of all my
> variables and functions appear "in clear" in the code of the ".o" file (when
> opening it with a text processor). Is there a way to avoid this (as the
> names are explicit and give hints about the way the program works) ? Of
> course, I can just give names as "a", "b", "c"... but then I get lost in my
> source code. I tried to use "static" but it does not change a thing ...
>
> Any help is welcome !
>
> Thanks again,
>
> Jean-Marc
>
> ----- Original Message -----
> From: "Ferdinando Formica" <s2...@st...>
> To: <go...@sk...>
> Cc: "Dev-C++ Mailing List" <dev...@li...>
> Sent: Saturday, January 10, 2004 7:51 PM
> Subject: Re: [Dev-C++] Split code in public/private parts - Help please
>
>
> >
> > > How can I compile "part two" (which has no "main" function),
> > > so that the source code cannot be seen anymore ?
> >
> > You can put "part two" in a separate file, and compile it singularly, then
> > distribute the output file (with .o extension).
> >
> > > Then, how can I compile "part one" source code (which has
> > > the "main" function) with "part two" compiled version?
> >
> > You have to include in your project the .o file selecting "include in
> > link" and deselecting "include in compilation", or equivalently build a
> > library from it (a .a file), call it e.g. libp2.a, and specify "-lp2" in
> > linker options.
> >
> > > How can I make sure it is not possible
> > > to call directly another function of "part two" ?
> >
> > _Really_ you can't, but only who knows the implementation (or is a good
> > and patient reverse engineer) know what's inside an object file. You
> > should put declarations for all functions you would like a programmer to
> > call in a header (.h) and distribute it with your .o or .a file.
> >
> > Bye, Ferdinando.
> >
> >
> >
>
>
>
>
> -------------------------------------------------------
> This SF.net email is sponsored by: Perforce Software.
> Perforce is the Fast Software Configuration Management System offering
> advanced branching capabilities and atomic changes on 50+ platforms.
> Free Eval! http://www.perforce.com/perforce/loadprog.html
> _______________________________________________
> Dev-cpp-users mailing list
> Dev...@li...
> TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm
> https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
>
|