Author Topic: gbal conversion hint  (Read 6248 times)

Offline 9940

  • Mr. Drawsprite
  • **
  • Posts: 53
    • View Profile
gbal conversion hint
« on: 2009-Jul-06 »
Quote
Please, 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

Example
with ALWAYSONTOP(TRUE) (by unknown)

Take the cleary parts of the gbal
Code: GLBasic [Select]
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\)
Code: GLBasic [Select]
#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
Code: GLBasic [Select]
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
 
« Last Edit: 2009-Jul-21 by 9940 »

Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 10656
  • here on my island the sea says 'hello'
    • View Profile
    • http://www.glbasic.com
Re: gbal conversion hint
« Reply #1 on: 2009-Jul-06 »
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.

Offline 9940

  • Mr. Drawsprite
  • **
  • Posts: 53
    • View Profile
Re: gbal conversion hint
« Reply #2 on: 2009-Jul-06 »
Think about the c\c++, you've never seen one obfuscated c++ file?

Except these
Code: GLBasic [Select]
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.
« Last Edit: 2009-Jul-06 by 9940 »

Offline Hemlos

  • To boldy go where no pixel has gone before!
  • Global Moderator
  • Prof. Inline
  • *******
  • Posts: 1578
  • Particle Hawk
    • View Profile
Re: gbal conversion hint
« Reply #3 on: 2009-Aug-11 »
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 ?
Volume_of_Earth(km^3) = 4/3*3.14*POW(6371.392896,3)

Offline Schranz0r

  • Premium User :)
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 4963
  • O Rly?
    • View Profile
Re: gbal conversion hint
« Reply #4 on: 2009-Aug-11 »
With the magic line: EXPORT functionname
An compile on GLBasic to DLL ;)
I <3 DGArray's :D

PC:
AMD RYzen 7 1700 @3.9Ghz, 16GB HyperX Fury 2666Mhz Ram, ASUS ROG GTX 1060 STRIX 6GB, Windows 10 Pro 64Bit, MSi Tomahawk B350 Mainboard

Offline Hemlos

  • To boldy go where no pixel has gone before!
  • Global Moderator
  • Prof. Inline
  • *******
  • Posts: 1578
  • Particle Hawk
    • View Profile
Re: gbal conversion hint
« Reply #5 on: 2009-Aug-13 »
With the magic line: EXPORT functionname
An compile on GLBasic to DLL ;)

That would be special requests for another thread ;{
Volume_of_Earth(km^3) = 4/3*3.14*POW(6371.392896,3)

Offline Schranz0r

  • Premium User :)
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 4963
  • O Rly?
    • View Profile
Re: gbal conversion hint
« Reply #6 on: 2009-Aug-13 »
hehe
I <3 DGArray's :D

PC:
AMD RYzen 7 1700 @3.9Ghz, 16GB HyperX Fury 2666Mhz Ram, ASUS ROG GTX 1060 STRIX 6GB, Windows 10 Pro 64Bit, MSi Tomahawk B350 Mainboard

Offline Hemlos

  • To boldy go where no pixel has gone before!
  • Global Moderator
  • Prof. Inline
  • *******
  • Posts: 1578
  • Particle Hawk
    • View Profile
Re: gbal conversion hint
« Reply #7 on: 2009-Aug-14 »
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
Volume_of_Earth(km^3) = 4/3*3.14*POW(6371.392896,3)

Offline Schranz0r

  • Premium User :)
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 4963
  • O Rly?
    • View Profile
Re: gbal conversion hint
« Reply #8 on: 2009-Aug-14 »
GBAS:

Code: GLBasic [Select]

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 ;)
I <3 DGArray's :D

PC:
AMD RYzen 7 1700 @3.9Ghz, 16GB HyperX Fury 2666Mhz Ram, ASUS ROG GTX 1060 STRIX 6GB, Windows 10 Pro 64Bit, MSi Tomahawk B350 Mainboard

Offline Hemlos

  • To boldy go where no pixel has gone before!
  • Global Moderator
  • Prof. Inline
  • *******
  • Posts: 1578
  • Particle Hawk
    • View Profile
Re: gbal conversion hint
« Reply #9 on: 2009-Aug-14 »

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
Volume_of_Earth(km^3) = 4/3*3.14*POW(6371.392896,3)

Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 10656
  • here on my island the sea says 'hello'
    • View Profile
    • http://www.glbasic.com
Re: gbal conversion hint
« Reply #10 on: 2009-Aug-14 »
Oh dear. On my Todo now...

Offline Schranz0r

  • Premium User :)
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 4963
  • O Rly?
    • View Profile
Re: gbal conversion hint
« Reply #11 on: 2009-Aug-14 »
xD
I <3 DGArray's :D

PC:
AMD RYzen 7 1700 @3.9Ghz, 16GB HyperX Fury 2666Mhz Ram, ASUS ROG GTX 1060 STRIX 6GB, Windows 10 Pro 64Bit, MSi Tomahawk B350 Mainboard