Bazaar/Protect : fixed to allow functions returning values and variable declarations inside function body

git-svn-id: svn://ultimatepp.org/upp/trunk@2712 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
micio 2010-09-20 12:01:04 +00:00
parent 68fb777258
commit 978e71164a
2 changed files with 53 additions and 47 deletions

View file

@ -36,15 +36,18 @@ using namespace Upp;
"\t.ascii \""PROTECT_START_MARKER"\"\n" \
"1:\n" \
); \
__start:
__start: \
{ \
#define PROTECT_END_FUNC \
return; \
} \
__end: \
asm volatile ( \
"\tjmp 2f\n" \
"\t.ascii \""PROTECT_END_MARKER"\"\n" \
)
"2:\n" \
);
#else
#define _PROTECT_START_MARKER __asm _emit 0xba __asm _emit 0xad __asm _emit 0xde __asm _emit 0xad __asm _emit 0xfa __asm _emit 0xce

View file

@ -1,43 +1,46 @@
#include <CtrlLib/CtrlLib.h>
#include <Protect/Protect.h>
using namespace Upp;
String GetKey(void)
{
return "\xAA\xBB\xCC\xDD\xEE\xFF";
}
bool Decrypt(byte *start, size_t len)
{
return PROTECT_DECRYPT ( start, len, GetKey() );
}
void testfn1(void)
{
PROTECT_START_FUNC(Decrypt);
PromptOK("testfn1 DECRYPTED SUCCESFULLY!!!");
return;
PROTECT_END_FUNC;
}
void testfn2(void)
{
PROTECT_START_FUNC(Decrypt);
PromptOK("testfn2 DECRYPTED SUCCESFULLY!!!");
return;
PROTECT_END_FUNC;
}
GUI_APP_MAIN
{
testfn1();
testfn2();
}
#include <CtrlLib/CtrlLib.h>
#include <Protect/Protect.h>
using namespace Upp;
String GetKey(void)
{
return "\xAA\xBB\xCC\xDD\xEE\xFF";
}
bool Decrypt(byte *start, size_t len)
{
return PROTECT_DECRYPT ( start, len, GetKey() );
}
double testfn1(double d, double e)
{
PROTECT_START_FUNC(Decrypt);
double f;
f = d * e;
PromptOK("testfn1 DECRYPTED SUCCESFULLY!!!");
return 2 * f + e;
PROTECT_END_FUNC;
}
void testfn2(void)
{
PROTECT_START_FUNC(Decrypt);
PromptOK("testfn2 DECRYPTED SUCCESFULLY!!!");
return;
PROTECT_END_FUNC;
}
GUI_APP_MAIN
{
double d = testfn1(3, 4);
testfn2();
}