Skip to content
Low-level programming · Higher-level thinking
Login Register
Forum / Bugs and Fixes

access violation in FileEntry

A community discussion post from the original code:zIRON forum.

Emil_halim member
Posts
639
Threads
104
Location
Alex, Egypt

access violation in FileEntry

hi

when trying to get each line from code buffer in FileEntry function i got access violation.

here is the FileEntry code

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

procedure FileEntry(DWord handle; char* strCode) {
  
     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');
     }
     
     char* tmp[1024];
     push edi
     edi = H_GetNextLine(strCode,tmp);
     while(edi > 0) 
      {
      
      
         edi = H_GetNextLine(strCode,tmp);
      } 
     pop edi
}

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

Replies

Colin admin
Posts
928
Threads
49
Location
Bulgaria

Hi Emil

     char* tmp[1024]; //it should be noted this will equal 4096 bytes of stack space
     push edi
     edi = H_GetNextLine(strCode,@tmp);
     while(edi > 0) 
      {
      
      
         edi = H_GetNextLine(strCode,@tmp);
      } 
     pop edi
Emil_halim member
Posts
639
Threads
104
Location
Alex, Egypt

after changing it to this

char tmp[1024];

ziron stop working and gave that

Ziron Compiler 1.1.27.6
Copyright (C) 2011. OverHertz Ltd. All rights reserved.
--------------------------------------------
11/23/2011 9:36:05 PM
--------------------------------------------

PlugSys: Emit plugin has loaded!
PlugSys: Masm plugin version 0.01 has loaded! 

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

Colin admin
Posts
928
Threads
49
Location
Bulgaria

looks like your plugin is stuck in a loop in FileEntry...

Emil_halim member
Posts
639
Threads
104
Location
Alex, Egypt

i have modified it be like that

procedure FileEntry(DWord handle; char* strCode) {
  
     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');
     }
     
     char tmp[1024];
     push edi
     edi = strCode
     if([edi] == "prog" and [edi+4] == "ram ") // is it the main code
     {
        edi = H_GetNextLine(strCode,tmp);
        while(edi > 0) 
         {
           // Ziron_ShowMessage(@tmp);
            edi = H_GetNextLine(strCode,tmp);
         }
     } 
     pop edi
     
}

but it crashing , what is the way to navigate throw the code in your opinion ?

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

Colin admin
Posts
928
Threads
49
Location
Bulgaria

It is probably crashing when strCode is below 8 bytes.. as for how i'd need to have a think about it, depends really what you need to do. Why do you need to know if it is the main file?

If someone includes some of their own files, they would not be processed ?

Emil_halim member
Posts
639
Threads
104
Location
Alex, Egypt

no i did not want to process the main file only , but i have used that to prevent the crashing only.

i need to navigate in all text code ' the main and including file as well'

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

Colin admin
Posts
928
Threads
49
Location
Bulgaria

in your getnextline function probably you need to check for null byte before adding your incr..

here:

  esi = strbuf;  
  add esi, ecx