QuotePlease, if a library can be released as GBAS, do so then, GBAL relies on the fact that the user can never alter it, that is, to add to its features, correct mistakes... so if the GBAL author is not available then the end user is screwed...
A gbal file is a normal gbas file with some garbage.
It can be rewritten:
0) Open the gbal file.
1) Take all cleary parts.
2) Add the gbal to a new glbasic blank project and compile it.
3) Open YourDrive:\Documents and Settings\YourName\Local Settings\glbasic\
WARNING: in v7 the gbal files are hidden and they get deleted after been compiled
4) Find the c++ conversion of the gbal
5) Now you have enough code to translate the gbal
Examplewith ALWAYSONTOP(TRUE) (by unknown)
Take the cleary parts of the gbal
INLINE
}
extern "C" int __stdcall SetWindowPos(void*,d);
namespace __GLBASIC__
{
ENDIN
FUNCTION ALWAYSONTOP: VALUE
//implemented pos and size for resolutions ;) -Hemlos
IF =FALSE THEN RETURN
LOCAL sx,sy,WinA
Y,InsertAfter Flagh
=-1; =18
GETSCREENSIZE //detect , YOU MUST HAV HWND()
0,0,sx+6,sy+33 d1D;
ENDFUNCTION
This is a bit useless.
Take the c++ conversion. (YourDrive:\Documents and Settings\YourName\Local Settings\glbasic\)
#include "gpc_temp.h"
namespace __GLBASIC__{
/* ---- INLINE ---- */
}
extern "C" int __stdcall SetWindowPos(void*, int, int, int, int, int, int);
namespace __GLBASIC__
{
/* ---- ENDINLINE ---- */
// ------------------------ //
DGInt ALWAYSONTOP(DGInt VALUE)
{
__PPRegisterFunction
//implemented pos and size for all resolutions ;) -Hemlos.
if (VALUE==FALSE )
return 0; // RETURN f. SUB
REGISTER_VAR_DEF(DGInt, sx, 0);
REGISTER_VAR_DEF(DGInt, sy, 0);
REGISTER_VAR_DEF(DGInt, WinPosX, 0);
REGISTER_VAR_DEF(DGInt, WinPosY, 0);
REGISTER_VAR_DEF(DGInt, InsertAfter, 0);
REGISTER_VAR_DEF(DGInt, InsertFlag, 0);
InsertAfter=-1;
InsertFlag=18;
GETSCREENSIZE( sx,sy);
//detect window size, YOU MUST HAVE THIS!.
/* ---- INLINE ---- */
SetWindowPos(GLBASIC_HWND(),InsertAfter,0,0,sx+6,sy+33,InsertFlag);
/* ---- ENDINLINE ---- */
return 0;
}
} // namespace
This is useful.
Let's translate to GLBasic
INLINE
}
extern "C" int __stdcall SetWindowPos(void*, int, int, int, int, int, int);
namespace __GLBASIC__
{
ENDINLINE
FUNCTION ALWAYSONTOP: VALUE
//implemented pos and size for all resolutions ;) -Hemlos.
IF VALUE==FALSE THEN RETURN
LOCAL sx,sy,WinPosX,WinPosY,InsertAfter,InsertFlag
InsertAfter=-1
InsertFlag=18
GETSCREENSIZE sx,sy
//detect window size, YOU MUST HAVE THIS!.
INLINE
SetWindowPos(GLBASIC_HWND(),InsertAfter,0,0,sx+6,sy+33,InsertFlag);
ENDINLINE
ENDFUNCTION
Oh you <think of what you are>! ;)
Yes, there is a slight problem with secutrity. But one thing, all comments are removed. Second, all global variables are removed. Third, the file usually gets deleted quickly after the compile.
I don't know how to protect them better, because that's the only way to make them cross platform.
I think of a better protection for version 7.
Think about the c\c++, you've never seen one obfuscated c++ file?
Except these
typedef struct{int x, y;}pixel;pixel snake[SNAKE_LEN];int food = 0;void sigalrm(
int signo){food=1;alarm(10);}int getdirection(aa_context *context){int key;key =
aa_getkey(context,0); if(key==AA_RIGHT||key==AA_LEFT||key==AA_UP||key==AA_DOWN){
aa_printf(context,0,0,AA_SPECIAL,"Key pressed: %i",key);aa_flush(context);return
key;} return AA_NONE;} int main( int argc, char **argv){int x, y, key,
pressed; aa_context *context; pixel *head, *tail, *ptr; struct
sigaction act;if(0x00000000 || !aa_parseoptions(NULL,NULL,&argc
, argv)||argc!=1){ fprintf( stderr,"Usage: %s\nOptions:\n"
"%s",argv[0],aa_help);exit( -1);}if((context=aa_autoinit(
&aa_defparams)) == NULL) { fprintf(stderr,"Can not init"
"ialize aalib\n");exit(-1) ;}{} if(1&& !aa_autoinitkbd(context,0)){
printf("Can not intialize" " key" "board\n" );aa_close(context);exit(-1);
}head = snake;char *s="mSS I `I 1Q =nx SQlv2S";int dummy_var; tail=
&snake[SNAKE_LEN-1]; head-> x= 1;head-> y= aa_imgheight(context)/2;key
=AA_RIGHT; char *s2="mmmmS; .*vSQiillvIxxQQI| WixoSSSmmm";act.sa_handler=
sigalrm; int z;sigemptyset (&act.sa_mask);act. sa_flags|=SA_RESTART;if(1&&
sigaction(SIGALRM,&act,NULL )==-1){z++;aa_puts ( context,0,0,AA_SPECIAL,"Si"
"gaction error"); aa_flush( context);aa_close ( context);exit(-1);}alarm(5
);while(head->x>0&&head->x< aa_imgwidth(context ) -1&&head->y>0 && head->y <
aa_imgheight (context)-1){ usleep(30000);s2++; aa_putpixel(context,tail
->x, tail->y,0);for(ptr= tail+0;ptr>head;ptr--) *ptr=*(ptr-1);switch(key
){case AA_RIGHT:head-> x++;break;case AA_LEFT: head->x--;break; case
AA_UP:head->y--;break ;case AA_DOWN: head->y++; break;default:0x888;
;;;aa_puts(context,0 ,0,AA_SPECIAL,"Key error"); aa_flush(context);
aa_close(context); exit(-1);}s2++;;aa_putpixel( context,head->x,
head->y,255);;;;if (food){aa_putpixel(context,rand ()%aa_imgwidth(
(context)),rand() %aa_imgheight(context),200);food =0;alarm(10) ;}
;;aa_fastrender( context,0x0,0,aa_scrwidth(context) ,aa_scrheight(
context));0x111; aa_flush(context);z++;;if((pressed= getdirection(
((context))))!= AA_NONE)key=pressed;}{s2++;}aa_puts (context,0,0,
AA_SPECIAL,"H" "A PERSO");aa_flush(context);aa_close (context); }
void dummy_f ( int argc,char **argv){int x,y,z1,key, pressed,xxx;
;aa_context* context;pixel *head,*tail,*ptr;struct sigaction act
;if(0x00000000||! aa_parseoptions(NULL,NULL,&argc,argv) ||(argc!=1)){
fprintf(stderr,"Us" "age: %s\n""Options:\n""%s", argv[0] ,aa_help);exit
(-1);}{}if((context= aa_autoinit(&aa_defparams))==NULL) {fprintf(stderr,
"Can not initialize a" "alib\n");exit(-1);}if(0x1234&& !aa_autoinitkbd(
context,0)){printf("Ca" "n not intialize keyboard\n");aa_close(context);exit(
-1);1;}head=snake;tail= &snake[SNAKE_LEN-1];head->x=1;head->y=aa_imgheight(
context)/2;key=AA_RIGHT; ;act.sa_handler=sigalrm;sigemptyset(&act.sa_mask);
act.sa_flags|=SA_RESTART;; if(((sigaction(SIGALRM, &act,NULL)==-1))) {aa_puts(
context, 0, 0, AA_SPECIAL, "Sigaction error"); ;aa_flush(context);aa_close(
context);exit(-1);}alarm(5);while(head->x>0 &&head->x<aa_imgwidth(context
)-1&&head->y>0&&0x1&&head->y< aa_imgheight(context)-1){z1++
;z1;usleep(30000);aa_putpixel (context,tail->x,tail->y,0x0);
for(ptr=tail;ptr>head;ptr--) *ptr=*(ptr-1);switch(key){case AA_RIGHT: head->x++;
break;case AA_LEFT:head-> x--;break;case AA_UP:head ->y--;break;case AA_DOWN:head
->y++;break;default:aa_puts(context,0,0,AA_SPECIAL,"Key error");aa_flush(context)
;aa_close(context);exit(-1);}aa_putpixel(context,head->x,head->y,255);if(food){{}
aa_putpixel(context,rand()%aa_imgwidth(context),rand()%aa_imgheight(context),200)
;food=0;}aa_fastrender(context,0,0,aa_scrwidth(context),aa_scrheight(context));}}
However the answer is no. The only way to to this is using the dll...
Any other way is vain, because you can go back to the original code.
Quote from: 9940 on 2009-Jul-06
However the answer is no. The only way to to this is using the dll...
Any other way is vain, because you can go back to the original code.
I was told using an object file is possible as an alternative.
Is an object file as secure as a dll?
Do you know how to convert a gbas, cpp, or gbal into an object or dll files ?
With the magic line: EXPORT functionname
An compile on GLBasic to DLL ;)
Quote from: Schranz0r on 2009-Aug-11
With the magic line: EXPORT functionname
An compile on GLBasic to DLL ;)
That would be special requests for another thread ;{
hehe
Ok im waiting on documentation for export, its not in the help file.
And i am definetly too stupid to figgure it out on my own hehehe
GBAS:
EXPORT Do_Something
WHILE TRUE
SHOWSCREEN
WEND
END
FUNCTION Do_Something: val1, val2
RETURN val1+val2
ENDFUNCTION
SHIFT+F8 and compile as Win32_dll
Thats the trick ;)
Ouch, not working.
Both with and without inputs does the same thing:
Have you gotten this to work ?
Does the german version have a help file for this?
Quote
compiling:
E:\Program Files\GLBasic\systemp\glbasic\gpc_temp0.cpp: In function `int DllMain(HINSTANCE__*, long unsigned int, void*)':
E:/Program Files/GLBasic/Compiler/platform/Include/glb.h:312: error: too many arguments to function `int __GLBASIC__::__GlobalInit(HINSTANCE__*, int, const char*)'
E:\Program Files\GLBasic\systemp\glbasic\gpc_temp0.cpp:1124: error: at this point in file
E:\Program Files\GLBasic\systemp\glbasic\gpc_temp1.cpp: In function `int DllMain(HINSTANCE__*, long unsigned int, void*)':
E:/Program Files/GLBasic/Compiler/platform/Include/glb.h:312: error: too many arguments to function `int __GLBASIC__::__GlobalInit(HINSTANCE__*, int, const char*)'
E:\Program Files\GLBasic\systemp\glbasic\gpc_temp1.cpp:5820: error: at this point in file
*** FATAL ERROR - Please post this output in the forum
Oh dear. On my Todo now...
xD