Register | Login
Forum Index > Bugs and Fixes > access violation in FileEntry
Author Message
Pages: 1 2 3 4 5 6 7
Emil_halim
Ziron Beta Tester

avatar

(send private message)

Posts: 639
Topics: 104

Location:
Alex, Egypt
[846] - posted: 2011-11-26 18:58:09
oh , i have an other problem.

i have add this code to allow new keyword
Code:
function event_While() {
  uses edi esi ecx ebx;
  boolean Flg = true;  
  
  if(Flg) {
        
        return true;
  } else {   
        return false;                           // let Ziron handle the line  
  }  
}

procedure FileEntry(DWord handle; char* strCode) {
  
     uses edi;
     eax = strOffset(strCode, '.DATA');
     while (char[eax] <> 0) {
            char[eax] = "_";
            eax = strOffset(eax, '.DATA');
     }
     
     eax = strOffset(strCode, '.CODE');
     while (char[eax] <> 0) {
            char[eax] = "_";
            eax = strOffset(eax, '.CODE');
     }
     
     eax = strOffset(strCode, '.WHILE');
     while (char[eax] <> 0) {
            char[eax] = "_";
            eax = strOffset(eax, '.WHILE');
     }

/*     
    char tmp[1024];     
    edi = strGetLine(strCode, @tmp);
    while(edi > 0) {    
          Ziron_ShowMessage(@tmp);
          
          
          edi = strGetLine(edi, @tmp);
     }
*/  
}

function InitPlugin(pointer pGetF) {
  Ziron_LoadAll(pGetF); //use framework utility function to load all

  //register our keyword
  Ziron_RegisterKeyword('_Data', @event_Data);
  
  Ziron_RegisterKeyword('_While', @event_While);
  
  return strLoaded;
}


but it seems that ziron did not like this line
Code:
Ziron_RegisterKeyword('_While', @event_While);


when i comment it ziron loaded masm plugin and work , when i did not comment it
ziron gave that
Code:
PlugSys: Emit plugin has loaded!
PlugSys: masm.dll skipped - not a valid plugin
[5,3]: Unknown Identifier "." in [testprg.zir]
Code: 
  .DATA


http://www.freewebs.com/ogremagic/index.htm
Admin
Site Admin

avatar

(send private message)

Posts: 933
Topics: 55

Location:
OverHertz Studio
[847] - posted: 2011-11-26 20:12:37
ok first check the log you posted

Code:
PlugSys: masm.dll skipped - not a valid plugin


it does not replace the . because it does not load the plugin, maybe you have forgot something such as exporting a function.

as for the strGetLine it seems i had re-added some test code and made small mistake ... [esi+1].. here is the fixed and working tested version:

Code:
function strGetLine(pointer strOff; pointer dest) { 
  uses esi edi;

  esi = strOff;
  if (char[esi] == 0) {
    return 0;
  }  
  edi = dest;
  
  lodsb
  repeat {
    if (al == 0) {
      esi--;
      break;
    } elseif (al == 13 and char[esi] == 10) {
      esi += 2;
      break;
    }
  
    char[edi] = al;  
    edi++;
    lodsb
  };
  char[edi] = 0; 

  return esi;
}


Download Ziron
Get free hosting for Ziron related fan-sites and Ziron projects, contact me in private message.
Emil_halim
Ziron Beta Tester

avatar

(send private message)

Posts: 639
Topics: 104

Location:
Alex, Egypt
[848] - posted: 2011-11-26 20:19:10

it does not replace the . because it does not load the plugin, maybe you have forgot something such as exporting a function.


no i have just add that code to my masm plugin , but found that when putting only one Ziron_RegisterKeyword function ziron accepts it and when putting 2 functions ziron refused
to load it

http://www.freewebs.com/ogremagic/index.htm
Emil_halim
Ziron Beta Tester

avatar

(send private message)

Posts: 639
Topics: 104

Location:
Alex, Egypt
[849] - posted: 2011-11-26 20:29:08
also i have tested your latest strGetLine function.

it prints the main program and a lot of include files then crashed. BTW i include only console.zir header file.

so if there is a way to use the handle parameter of FileEntry function to limit that.

http://www.freewebs.com/ogremagic/index.htm
Admin
Site Admin

avatar

(send private message)

Posts: 933
Topics: 55

Location:
OverHertz Studio
[850] - posted: 2011-11-26 20:33:49
i tested strGetLine with this code:

Code:
plugins off;

program WIN32DLL 'Masm PLUGIN';

#include 'zirplug/framework.zir';
#include 'zirutils.zir';
#include 'strings.zir';

const strLoaded = 'Masm plugin version 0.01 has loaded! ';



procedure FileEntry(DWord handle; char* strCode) {
     uses edi;
     
    char tmp[4096];
     
    edi = strGetLine(strCode, @tmp);
    while(edi <> 0) {    
          Ziron_ShowMessage(@tmp);
                   
          edi = strGetLine(edi, @tmp);
     }
  
}

function InitPlugin(pointer pGetF) {
  Ziron_LoadAll(pGetF); //use framework utility function to load all

  //register our keyword
  //Ziron_RegisterKeyword('_Data', @event_Data);
  
  return strLoaded;
}

entry function DLLMain(DWord iDLL; DWord iReason; Pointer iResult) {
  if (iReason == DLL_PROCESS_ATTACH) {
    return true;
  }

  return false;
}

exports InitPlugin, FileEntry;


and it works, so maybe the crash is somewhere else, and regarding the include files, console.zir also includes several include files, and there is 1 system include file.

Download Ziron
Get free hosting for Ziron related fan-sites and Ziron projects, contact me in private message.
Emil_halim
Ziron Beta Tester

avatar

(send private message)

Posts: 639
Topics: 104

Location:
Alex, Egypt
[851] - posted: 2011-11-26 20:41:01

ok try to test the 'test program' in post #[845].

http://www.freewebs.com/ogremagic/index.htm
Admin
Site Admin

avatar

(send private message)

Posts: 933
Topics: 55

Location:
OverHertz Studio
[852] - posted: 2011-11-26 20:56:46
i just tested and it worked perfectly....



Download Ziron
Get free hosting for Ziron related fan-sites and Ziron projects, contact me in private message.
Emil_halim
Ziron Beta Tester

avatar

(send private message)

Posts: 639
Topics: 104

Location:
Alex, Egypt
[853] - posted: 2011-11-26 21:01:24
ok , here is my entire code again
Code:
plugins off;
plugins emit; 

program WIN32DLL 'Masm PLUGIN';

#include 'zirplug/framework.zir';
#include 'zirutils.zir';
#include 'strings.zir';

//////////////////////////////

const strLoaded = 'Masm plugin version 0.01 has loaded! ';

function H_strlen(char* str) {
  Eax = str;
  while(char[eax] != 0) {
    Eax++;
  }
  sub eax, str
}

function  H_strcpy(Dword dst,src)
{ 
  uses edx ebx;
  
  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) 
{ 
  uses edx ebx;

  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;
} 

inline procedure  H_strjoin(;)
{
  $temp = 1;
  $to = $argc - 1;  
  $repeat $to:  
     H_strcat($arg[0],$arg[$temp]);  
  $temp++;
  $end
}

function H_Trim(char* str;int32* len)
{  
  uses Esi Edi Ecx;
  Esi = str;
  al = char[Esi];
@Rept:     
 if(al==32 or al==9 or al==10 or al==11 or al==13)
  { 
    Esi++;
    al = char[Esi];
    goto @Rept;
  }       
 Ecx = Esi;
 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,Esi 
 if(len != nil )
  {
    //*len = Ecx;
    Eax = len;
    Dword[Eax] = Ecx;  
  } 
 push Ecx
 Edi = str;
 rep movsb
 pop ecx 
 Eax = str;
 char[Eax+Ecx]=0;
}

inline procedure GotoLineEnd()
{
  eax = Ziron_IsNextLineBreak();
  while(!eax)
   {
       Ziron_GetNextToken(); // remove every things after ';'
       eax = Ziron_IsNextLineBreak();    
   }
}

inline procedure SkipSemiToLineEnd()
{
   eax = Ziron_PeekNextToken();
   if (eax == zirSemi_Colon) 
    {
       Ziron_GetNextToken(); // remove ';'
       GotoLineEnd();
    }        
}
//////////////////////////////
function event_While() {
  uses edi esi ecx ebx;
  boolean Flg = true;  
  
  if(Flg) {
        
        return true;
  } else {   
        return false;                           // let Ziron handle the line  
  }  
}

function event_Data() {
  uses edi esi ecx ebx;
  char buf[2048];
  char var[255];
  char right[5100];
  char tmp[255];
  char dtype[32];
  char extn[32];
  dword indx,ndx;
  const stp = 16;
  boolean Flg = true;  
  
  if(Flg) {
    // always start with  '{' 
    eax = Ziron_ExpectNextToken(zirBraceOpen);    
    if (eax == -1) {
      Ziron_FatalError('Expected { symbol');
      return true;
    }
          
    repeat {
      // found '}' so let's finished
      eax = Ziron_PeekNextToken(); 
      if (eax == zirBraceClose) {
        Ziron_GetNextToken(); 
        break;
      } 
              
      buf=0; 
      right=0;
      indx = 0;         
      // get the variable name and hold it in Var
     /*   
      DWord dt = Ziron_ExpectNextToken(zirIdent); 
      if (dt == -1) {
        Ziron_FatalError('Expected Variable Name');
        return true;
      }
     */
      DWord dt = Ziron_GetNextToken();  
      char tVar[512];
      char* strTemp;
      H_strcpy(@tvar, Ziron_GetStringValue());
      strLower(@tVar);
      H_Trim(@tVar,nil);
      eax = @tVar;
      if( word[eax] == "db" or word[eax] == "dw" or word[eax] == "dd" or word[eax] == "dq" or dt == zirData_Type) 
       {
          strTemp = eax;  
          ndx++;
         // Ziron_ShowMessage(@tVar);
          IntToStr(ndx, @tmp);
          var=0;    
          H_strjoin(@var ,@extn,  '_' , @tmp, '_temp');
          goto @forwerd;
       }
      else
       {
          ndx=0; 
          extn=0;   
          H_strcpy(@var, Ziron_GetStringValue()); 
          H_strcpy(@extn, Ziron_GetStringValue());     
       }       
      // get DB or DW or DD or DQ or (data type)
      dt = Ziron_GetNextToken(); 
      boolean  _db, _dw, _dd, _dq;        
      strTemp = strLower(Ziron_GetStringValue());
      @forwerd:
      _db = strCmp('db',strTemp);
      if (_db)
       {
            H_strcpy(@dtype,'byte ');     // found DB
       } 
      else
       {
           _dw = strCmp('dw',strTemp); //  
            if (_dw) 
             {
                  H_strcpy(@dtype,'word '); // found DW
             }
            else 
             {
                  _dd = strCmp('dd', strTemp);     
                  if (_dd) 
                   {
                        H_strcpy(@dtype,'DWord '); // found DD
                   } 
                  else 
                   {
                        _dq = strCmp('dq', strTemp);    
                        if (_dq) 
                         {
                              H_strcpy(@dtype,'qword '); // found DQ
                         }
                        else
                         {
                           if(dt == zirData_Type)  // found data type
                             {
                                H_strcpy(@dtype,Ziron_GetStringValue()); 
                                H_strcat(@dtype,' '); 
                             }
                            else
                             {          
                               // there is no DB or DW or DD or DQ or (data type) so fire error 
                               Ziron_FatalError('Expected DB or DW or DD or DQ symple');
                               return true;
                             }
                         }
                  }
            }
      }
              
      @digit:
        
      // get whatever after DB 
      eax = Ziron_GetNextToken();
      //  var  DB ?  
      if (eax == zirQuestionSym) {
        H_strjoin(@buf, @dtype , @var, ' = ' , '0;' ); 
        Ziron_Exec(@buf);
        continue;
      }
          
      case (eax) {
        // var DB 0x0f 
        state zirHEXADECIMAL:
          edx = indx; imul edx, stp; eax = @right; edx += eax;
          H_strcpy(edx,'0x');            
          H_strcat(edx,Ziron_GetStringValue());
          break; 
        // var Db 1  
        state zirNUMBER:
          edx = indx; imul edx, stp; eax = @right; edx += eax;            
          H_strcpy(edx,Ziron_GetStringValue());                 
          break;   
        // str  DB 'hello',0  
        state zirConstString:
              char str1[2048];
              H_strcpy(@str1,Ziron_GetStringValue());
              ecx = H_strlen(@str1);
              while(ecx > 0)
               {      
                 esi = @str1;
                 edx = indx; bl = [esi+edx]; imul edx, stp; eax = @right; edx += eax; 
                 char[edx] = ord('"');
                 char[edx+1] = bl;
                 char[edx+2] = ord('"');
                 char[edx+3] = 0;
                 indx++;
                 ecx--; 
               } 
               indx--;  
          break;
          state zirFLOAT:
              edx = indx; imul edx, stp; eax = @right; edx += eax;            
              H_strcpy(edx,Ziron_GetStringValue());         
              //Ziron_ShowMessage(Ziron_GetStringValue());
          break;     
        default:
          Ziron_FatalError('Expected number');
          return true;
      }
        
        
      eax = Ziron_PeekNextToken();
      // check for ','
      // var db 0 , 0 , 0 , 1
      if (eax == zirCOMMA) {
        Ziron_GetNextToken(); // remove ','
        indx++;        
        goto @digit;
      } 
      // check for ';'
      // var DB 0x0f  ; Declare a byte
      SkipSemiToLineEnd();
        
      // bytes DB 10 DUP(0)
      eax = strCmp('dup',strLower(Ziron_GetStringValue()));
      if (eax) 
       { 
         Ziron_GetNextToken(); // remove 'DUP'
         Ziron_GetNextToken(); // remove '('
         Ziron_GetNextToken(); // remove '0'
         char  v[10];
         H_strcpy(@v,Ziron_GetStringValue());
         Ziron_GetNextToken(); // remove ')'           
         ecx = strVal(@right);
         while(ecx > 0)
          {
             edx = indx; imul edx, stp; eax = @right; edx += eax; 
             H_strcpy(edx,@v);   
             indx++;
             ecx--; 
          } 
         indx--;   
         // check for ';'
         SkipSemiToLineEnd();
       }  
      
      
      
       
      // 
      buf = 0;
      if (indx == 0) { 
        H_strjoin(@buf, @dtype , @var, ' = ' , @right , ';' ); 
        Ziron_ShowMessage(@buf);
        Ziron_Exec(@buf); 
      }
      else
      {
          H_strcat(@buf, @dtype );            
          edi = xor;        
          while (edi <= indx)
           {       
              IntToStr(edi, @tmp);           
              edx = edi; imul edx, stp; eax = @right; edx += eax; 
              H_strjoin(@buf, @var,  '[' , @tmp ,']=' , edx , '; ' ); 
              edi++; 
           }   
          Ziron_ShowMessage(@buf);
          Ziron_Exec(@buf);  
      } 

      
    };            
    return true;
  } else {   
    return false;                           // let Ziron handle the line  
  }  
}

procedure FileEntry(DWord handle; char* strCode) {
  
     uses edi;
     eax = strOffset(strCode, '.DATA');
     while (char[eax] <> 0) {
            char[eax] = "_";
            eax = strOffset(eax, '.DATA');
     }
     
     eax = strOffset(strCode, '.CODE');
     while (char[eax] <> 0) {
            char[eax] = "_";
            eax = strOffset(eax, '.CODE');
     }
     
     eax = strOffset(strCode, '.WHILE');
     while (char[eax] <> 0) {
            char[eax] = "_";
            eax = strOffset(eax, '.WHILE');
     }

     
    char tmp[1024];     
    edi = strGetLine(strCode, @tmp);
    while(edi > 0) {    
          Ziron_ShowMessage(@tmp);
                    
          edi = strGetLine(edi, @tmp);
     }
  
}

function InitPlugin(pointer pGetF) {
  Ziron_LoadAll(pGetF); //use framework utility function to load all

  //register our keyword
  Ziron_RegisterKeyword('_Data', @event_Data);
  
 // Ziron_RegisterKeyword('_While', @event_While); 
  
  return strLoaded;
}

entry function DLLMain(DWord iDLL; DWord iReason; Pointer iResult) {
  if (iReason == DLL_PROCESS_ATTACH) {
    return true;
  }

  return false;
}

exports InitPlugin, FileEntry;


and here is the test code
Code:
program WIN32CUI 'Masm Syntax test';

#include 'console.zir';

.DATA 
{

var      DB 0x0f  ; Declare a byte, referred to as location var, containing the value 0x0f.
vv       Db 1      
ar1      DB ?  
ar2      DB 0 

ml       db 0 , 0 , 0 , 1
         db 5 , 6          // multi lines declration
         db ?              // an other line
         db 0xfc           //one more line

bytes    DB 10 DUP(0)   ; Declare 10 bytes starting at location bytes.

str1     DB 'hello',0

Wvar     dw 10

Dvar     dd 20

//Qvar     dq 30  // will be allowed later

varname   dword  1342 , 10 
          dword  13 , 100   // multi lines declration
          
vwrd      word   7
vbyte     byte   0x40

vchar     char   'welcome',10,13,0

CrLf      db   10,13

//svar      single 1.5 , 5.0 

//dblvar   double 10.0

//exvar   extended 100.0    

}


/*
.CODE
{
PUBLIC _myFunc
_myFunc PROC
  ; Subroutine Prologue
  
  mov eax,5
  ret
_myFunc ENDP
}
*/

/*
eax = 0;
al = vv ;
print('var = ', Eax); 

eax = @var;
eax = [eax]
print('var = ', Eax); 

*/
eax = @ml;
Ecx = [eax]
print('var = ', Ecx); 

//print(@str1);

.WHILE()
{
  
}

wait_key(nil);
ExitProcess(0);


so try it and see what happens. also check the error of 2 functions in InitPlugin

http://www.freewebs.com/ogremagic/index.htm
Pages: 1 2 3 4 5 6 7
create new reply


Quick reply:

Message:



Currently Active Users:
There are currently 7 user(s) online. 0 member(s) and 7 guest(s)
Most users ever online was 1046, January 28, 2022, 2:08 pm.


Statistics:
Threads: 225 | Posts: 1848 | Members: 51 | Active Members: 51
Welcome to our newest member, yecate
const Copyright = '2011-2024 © OverHertz Ltd. All rights reserved.';
Web development by OverHertz Ltd