Author |
Message
|
Admin Site Admin
(send private message)
Posts: 933 Topics: 55
Location: OverHertz Studio | [303] - posted: 2011-11-03 23:58:04 ok it is fixed - check the fastcall thread for the link to the fixed file
thanks for the reports.
Download Ziron
Get free hosting for Ziron related fan-sites and Ziron projects, contact me in private message. |
Emil_halim Ziron Beta Tester
(send private message)
Posts: 639 Topics: 104
Location: Alex, Egypt | [305] - posted: 2011-11-04 14:47:09 i afraid , this code when compiling and put it in Plugin Folder gives access violation.
Code:function FileEntry(DWord handle; char* strCode)
{
const maxLen = 512;
char* bufCode;
pointer str;
//create a buffer
char myBuffer[maxLen];
//preprocess the main file
if (handle == 0)
{
bufCode = GetTmpStr(102400);
push edi
edi = GetNextLine(strCode,@myBuffer);
while(edi > 0)
{
//Ziron_ShowMessage(@myBuffer);
//strcpy(bufCode,@myBuffer);
str = Trim(@myBuffer,nil);
strcat(bufCode,str);
strcat(bufCode,\'\\r\\n\');
edi = GetNextLine(strCode,@myBuffer);
}
pop edi
//set the buffer
DWord Len;
Len = strlen(bufCode);
Ziron_ShowMessage(bufCode);
Ziron_SetFileBuffer(handle, bufCode, Len);
}
}
http://www.freewebs.com/ogremagic/index.htm |
Emil_halim Ziron Beta Tester
(send private message)
Posts: 639 Topics: 104
Location: Alex, Egypt | [306] - posted: 2011-11-04 15:11:50
i have found that the error came from Trim function.
here is the trim function
Code:function H_GetTmpStr(DWord sizeInByte)
{
uses Ebx Ecx;
global int32 StrCnt;
global char* StrFunc[2048];
Eax = StrCnt;
Eax++;
and Eax,2047
StrCnt = Eax;
Ebx = @StrFunc;
lea Ebx,[Ebx+Eax]
Eax=DWord[Ebx];
if( Eax> 0)
{
freemem( Eax);
}
[Ebx]= malloc(sizeInByte);
}
function Trim(char* str;int32* len)
{
uses Ebx Ecx;
Ebx = str;
al = char[Ebx];
@Rept:
if(al==32 or al==9 or al==10 or al==11 or al==13)
{
Ebx++;
al = char[Ebx];
goto @Rept;
}
Ecx = Ebx;
while(char[Ecx] != 0)
{
Ecx++;
}
al = char[Ecx-1];
@Rept1:
if(al==32 or al==9 or al==10 or al==11 or al==13)
{
Ecx--;
al = char[Ecx-1];
goto @Rept1;
}
sub Ecx,Ebx
if(len != nil )
{
//*len = Ecx;
Eax = len;
Dword[Eax] = Ecx;
}
Eax = GetTmpStr(Ecx);
push Eax
strlcpy(Eax,Ebx,Ecx);
pop Eax
char[Eax+Ecx]=0;
}
http://www.freewebs.com/ogremagic/index.htm |
Emil_halim Ziron Beta Tester
(send private message)
Posts: 639 Topics: 104
Location: Alex, Egypt | [308] - posted: 2011-11-04 16:03:39
i have used yor StrTrim Function like this
Code:
still have the same error"!!!!!
http://www.freewebs.com/ogremagic/index.htm |
Admin Site Admin
(send private message)
Posts: 933 Topics: 55
Location: OverHertz Studio | [309] - posted: 2011-11-04 16:41:08 can you show the code you are calling Trim from?
is strbuf a pointer?
Code:char* strbuf;
strbuf = malloc(...
or
Code:
if the latter then you will need
Code:
Download Ziron
Get free hosting for Ziron related fan-sites and Ziron projects, contact me in private message. |
Emil_halim Ziron Beta Tester
(send private message)
Posts: 639 Topics: 104
Location: Alex, Egypt | [310] - posted: 2011-11-04 17:00:14 ok here is the full code
Helper.zir file
Code://*********************
// helper functions
// By Emil Halim
//*********************
#include \'smm32.zir\';
procedure H_memcpy(Dword dst,src,len)
{
uses Esi Edi Ecx;
Edi = dst;
Esi = src;
Ecx = len;
rep movsb
}
function H_strlen(char* str)
{
Eax = nil;
Ebx = str;
while(char[Ebx] != 0)
{
Ebx++;
Eax++;
}
}
function H_strcpy(Dword dst,src)
{
Eax = dst;
Edx = src;
push Eax;
BL = [Edx];
while ( BL != 0)
{
[Eax] = BL;
Eax++; Edx++;
BL = [Edx];
}
[Eax] = 0;
pop Eax;
}
function H_strcat(Dword dst,src)
{
Eax = dst;
Edx = src;
push Eax;
while (byte [Eax] != 0) { Eax++; }
while (byte [Edx] != 0)
{
BL = [Edx];
[Eax] = BL;
Edx++; Eax++;
}
[Eax] = 0;
pop Eax;
}
function H_GetNextLine(char* strbuf; pointer dest)
{
global int32 incr;
uses esi edi;
eax = xor;
ecx = incr;
esi = strbuf;
add esi, ecx
edi = dest;
while(char[esi] != 0)
{
if (word[esi] == \"\\r\\n\")
{
eax += 2;
break;
}
bl = char[Esi];
char[edi] = bl;
eax++;
esi++;
edi++;
}
char[edi] = 0;
add ecx, eax
incr = ecx;
}
function H_GetTmpStr(DWord sizeInByte)
{
uses Ebx Ecx;
global int32 StrCnt;
global char* StrFunc[2048];
Eax = StrCnt;
Eax++;
and Eax,2047
StrCnt = Eax;
Ebx = @StrFunc;
lea Ebx,[Ebx+Eax]
Eax=DWord[Ebx];
if( Eax> 0)
{
freemem( Eax);
}
[Ebx]= malloc(sizeInByte);
}
function H_Trim(char* str;int32* len)
{
uses Ebx Ecx;
Ebx = str;
al = char[Ebx];
@Rept:
if(al==32 or al==9 or al==10 or al==11 or al==13)
{
Ebx++;
al = char[Ebx];
goto @Rept;
}
Ecx = Ebx;
while(char[Ecx] != 0)
{
Ecx++;
}
al = char[Ecx-1];
@Rept1:
if(al==32 or al==9 or al==10 or al==11 or al==13)
{
Ecx--;
al = char[Ecx-1];
goto @Rept1;
}
sub Ecx,Ebx
if(len != nil )
{
//*len = Ecx;
Eax = len;
Dword[Eax] = Ecx;
}
Eax = H_GetTmpStr(Ecx);
char[Eax+Ecx]=0;
H_memcpy(Eax,Ebx,Ecx);
}
function H_LTrim (char* str)
{
uses Ebx Ecx;
Ebx = str;
al = char[Ebx];
@Rept:
if(al==32 or al==9 or al==10 or al==11 or al==13)
{
Ebx++;
al = char[Ebx];
goto @Rept;
}
Ecx = Ebx;
while(char[Ecx] != 0)
{
Ecx++;
}
sub Ecx,Ebx
Eax = H_GetTmpStr(Ecx);
push Eax
strlcpy(Eax,Ebx,Ecx);
pop Eax
}
function H_Left(char* str; int32 length)
{
uses Esi Edi Ecx;
Esi = str;
Ecx = Esi;
while(char[Ecx] != 0)
{
Ecx++;
}
sub Ecx,Esi
if(length < Ecx)
{
Ecx = length;
}
Edi = H_GetTmpStr(Ecx);
char[Edi+Ecx]=0;
push Edi
rep movsb
pop Eax
}
http://www.freewebs.com/ogremagic/index.htm |
Emil_halim Ziron Beta Tester
(send private message)
Posts: 639 Topics: 104
Location: Alex, Egypt | [311] - posted: 2011-11-04 17:00:31 test.zir
Code://******************************************************//
// test plugin system //
//******************************************************//
program WIN32DLL \'Test PLUGIN\';
#include \'zirplug/framework.zir\';
#include \'zirutils.zir\'
#include \'smm32.zir\';
#include \'Helper.zir\';
//////////////////////////////////////////////////////////////
const strLoaded = \'Test plugin has loaded!\';
///////////////////////////////////////////////////////////////////////
//
// event_Emit()
// return false to allow the assembler to process this keyword internally.
// return true to tell the assembler this keyword has been processed.
//
function event_Test() {
uses edi;
char buf[5000];
DWord Len;
H_strcpy(@buf,\'mov eax, 5000\');
Len = H_strlen(@buf);
Ziron_ShowMessage(@buf);
eax = Ziron_Execute(@buf,Len);
if (eax == false) {
Ziron_FatalError(\'myCMD plugin is not compatible with this version of Ziron\');
}
eax = true;
}
function FileEntry(DWord handle; char* strCode)
{
const maxLen = 512;
char* bufCode;
pointer strbuf;
//create a buffer
char myBuffer[maxLen];
//preprocess the main file
if (handle == 0)
{
bufCode = H_GetTmpStr(102400);
push edi
edi = H_GetNextLine(strCode,@myBuffer);
while(edi > 0)
{
//Ziron_ShowMessage(@myBuffer);
//H_strcpy(bufCode,@myBuffer);
strbuf = H_Trim(@myBuffer,nil);
H_strcat(bufCode,strbuf);
H_strcat(bufCode,\'\\r\\n\');
edi = H_GetNextLine(strCode,@myBuffer);
}
pop edi
//set the buffer
DWord Len;
Len = H_strlen(bufCode);
Ziron_ShowMessage(bufCode);
Ziron_SetFileBuffer(handle, bufCode, Len);
}
}
function InitPlugin(pointer pGetF) {
Ziron_LoadAll(pGetF); //use framework utility function to load all
//register our keyword
Ziron_RegisterKeyword(\'KeyTest\', @event_Test);
return strLoaded;
}
entry function DLLMain(DWord iDLL,iReason; Pointer iResult) {
if (iReason == DLL_PROCESS_ATTACH) {
return true;
}
return false;
}
exports InitPlugin, FileEntry;
http://www.freewebs.com/ogremagic/index.htm |
Emil_halim Ziron Beta Tester
(send private message)
Posts: 639 Topics: 104
Location: Alex, Egypt | [312] - posted: 2011-11-04 17:05:01
i did not put the \' in the code.
http://www.freewebs.com/ogremagic/index.htm |