Skip to content
Low-level programming · Higher-level thinking
Login Register
Forum / Source Help

fastcall question

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

Replies

Emil_halim member
Posts
639
Threads
104
Location
Alex, Egypt

ok , the same error is take place but this time in the plugin module itself.

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

Emil_halim member
Posts
639
Threads
104
Location
Alex, Egypt

here is the plugin code

program WIN32DLL 'Test PLUGIN';

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

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

const strLoaded = 'Test plugin has loaded!';

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

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


//
// 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;
    strcpy(@buf,'mov eax, 5000');
    Len = 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 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;

and here is the program

program WIN32CUI 'test';

#include 'console.zir';

eax = 1;
print('eax = ', eax:int, '\r\n');

KeyTest;

print('eax = ', eax:int, '\r\n');

wait_key(nil);
ExitProcess(0);

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

Colin admin
Posts
928
Threads
49
Location
Bulgaria

i have found the problem, it is a problem with local variables when pushing onto the stack from a function call, in this case

eax = Ziron_Execute(@buf, Len);

Len is the problem, i am going to fix this bug then will re-post with updated version hopefully.

Emil_halim member
Posts
639
Threads
104
Location
Alex, Egypt

everything is okay , but the fastcall has the same error when calling this

    char  buf[5000];
    DWord Len;
    strcpy(@buf,'mov eax, 5000');

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

Colin admin
Posts
928
Threads
49
Location
Bulgaria

yes, these problems are not fixed yet, they will take a little longer, since the type of mov is very different, i will have these fixed as soon as i get time :)