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
A community discussion post from the original code:zIRON forum.
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
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
no ziron does not process before plugin preprocess, so that is a good option.
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.
if so, why Ziron will detect '.' and fire error befor plugin's FileEntry manipulate the file ?
http://www.freewebs.com/ogremagic/index.htm
It works fine...
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:
program WIN32CUI 'test';
#include 'ch.zir';
.DATA
wait_key(nil);
ExitProcess(0);
maybe you forgot to export the FileEntry procedure?
oh , may be something in my code , any i will post it when back to home.
http://www.freewebs.com/ogremagic/index.htm
here is the plugin 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
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