Register | Login
Forum Index > Requests and Feedback > data section.
Author Message
Pages: 1 2 3 4 5 6 7 8 9 10 11
Emil_halim
Ziron Beta Tester

avatar

(send private message)

Posts: 639
Topics: 104

Location:
Alex, Egypt
[597] - posted: 2011-11-11 16:09:55

i have a solution

first Masm plugin in preprocessor mode i can search for '.Data' then change it to '_Data'
and register '_Data' as a function to parse what after it.


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

avatar

(send private message)

Posts: 639
Topics: 104

Location:
Alex, Egypt
[598] - posted: 2011-11-11 16:47:34

oh , it seems that Ziron will process the file before plugin make the preprocess on that file

so please can you allow plugin manipulate the file first?

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

avatar

(send private message)

Posts: 933
Topics: 55

Location:
OverHertz Studio
[599] - posted: 2011-11-11 16:59:51
no ziron does not process before plugin preprocess, so that is a good option.

Download Ziron
Get free hosting for Ziron related fan-sites and Ziron projects, contact me in private message.
Admin
Site Admin

avatar

(send private message)

Posts: 933
Topics: 55

Location:
OverHertz Studio
[602] - posted: 2011-11-11 18:42:45
FileEntry plugin event is called before any processing is done from ziron, but of course you will need to use the Ziron_SetFileBuffer function to update the file before returning from the FileEntry function.

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
[604] - posted: 2011-11-11 18:59:22

if so, why Ziron will detect '.' and fire error befor plugin's FileEntry manipulate the file ?

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

avatar

(send private message)

Posts: 933
Topics: 55

Location:
OverHertz Studio
[607] - posted: 2011-11-11 19:14:56
It works fine...

Code:
program WIN32DLL 'test PLUGIN';

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


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

const strLoaded = 'test plugin has loaded!';

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


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

  return strLoaded;
}

procedure FileEntry(DWord handle; char* strCode) {
  Ziron_ShowMessage('-------------- before the error');
}

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

  return false;
}

exports InitPlugin, FileEntry;



test code:
Code:
program WIN32CUI 'test';

#include 'ch.zir'; 

.DATA

wait_key(nil);
ExitProcess(0);




maybe you forgot to export the FileEntry procedure?

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
[608] - posted: 2011-11-11 19:19:55

oh , may be something in my code , any i will post it when back to home.

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

avatar

(send private message)

Posts: 639
Topics: 104

Location:
Alex, Egypt
[610] - posted: 2011-11-11 20:12:40
here is the plugin code
Code:
//******************************************************//
//                                                      //
//                                                      //
//                 Masm plugin                          //
//               By  Emil Halim                         //
//                 11/11/2011                           //
//                                                      //
//******************************************************//

plugins off;

program WIN32DLL 'Masm PLUGIN';

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

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

const strLoaded = 'Masm plugin has loaded!';

procedure H_memcpy(Dword dst,src,len)
{
  uses Esi Edi;
  Edi = dst;
  Esi = src;
  Ecx = len;
  rep movsb
}

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

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);
   char[Eax] = 0;
}

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

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


//
// event_Data()
// return false to allow the assembler to process this keyword internally.
// return true to tell the assembler this keyword has been processed.
//
function event_Data() {
  uses edi;
  char buf[2048];
  char var[255];
  char str1[255];
  boolean Flg = true;  
  
  if(Flg)
   {
      eax = Ziron_IsNextLineBreak();
      while(eax)
      {
        Ziron_GetNextToken();
        eax = Ziron_IsNextLineBreak();
      } 
      
      return true;
   }
  else
   {   
      return false;                           // let Ziron handle the line  
   }  
}

function FileEntry(DWord handle; char* strCode)
{
   const maxLen = 1024;
   char myBuffer[maxLen];
   char outbuf[102400];
   pointer Tstr;
   
   //preprocess the main file
   if (handle == 0)
    {
       outbuf = 0;
       push edi
       edi = H_GetNextLine(strCode,@myBuffer);
       while(edi > 0){
         Ziron_ShowMessage(@myBuffer);
         Tstr = H_Trim(@myBuffer,nil);
         Eax = Tstr
         if(char[Eax] == ".")
          {
             char[Eax] = "_"
          }
         H_strcat( @outbuf , eax);
       }
       pop edi
       //set the buffer
      DWord Len;
      Len = H_strlen(@outbuf);
      Ziron_ShowMessage(@outbuf);
      Ziron_SetFileBuffer(handle, @outbuf, Len);  
    }
}

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;


test program
Code:
program WIN32CUI 'Masm Syntax test';

#include 'console.zir';


.DATA  var      DB 64     //; Declare a byte, referred to as location var, containing the value 64.

wait_key(nil);
ExitProcess(0);


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


Quick reply:

Message:



Currently Active Users:
There are currently 2 user(s) online. 0 member(s) and 2 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