assignment detecting
A community discussion post from the original code:zIRON forum.
Replies
edi = Ziron_ExtractLine(....
//move through tokens etc
anyways i would suggest for what you are trying to do then use FileEntry instead since it is better suited for such things.
still did not know how to use Ziron_ExtractLin inside ProgramEntry handler?
FileEntry did not allow use of excution.
http://www.freewebs.com/ogremagic/index.htm
With FileEntry, you would not use Ziron_Execute, instead you would use Ziron_SetFileBuffer
Hi Mr Colin,
as i mentioned before , FileEntry is not my point here and i am not willing use it in this
case because i want to Ziron execute something from plugin.
so is programEntry will help here or not and if so , please give me an example of using it.
thanks.
http://www.freewebs.com/ogremagic/index.htm
as i've said, what you are trying to do is not possible, simply because Ziron does not compile line by line, it is char to char.
take these 2 examples
mov
eax,
ecx
MyFunc(
a, b, c
d, e, f
);
now what you are wanting to do is get a line and then execute it.. so lets take a look
first line
mov
execute -> syntax error.
2nd line
eax,
execute -> syntax error.
and so on...., like i've said, FileEntry would be your only option, using SetFileBuffer, you can go through line by line, changing anything you need to change, and then let Ziron process the whole new buffer.
If you give me an exact description of what you actually want to do (if it is not just exec each line) then please give me a deep explanation and maybe i can implement some new pf functions to help in some better way.
as for ProgramEntry, this would not be suitable.
ok,
what i want to do is , make a trick , because of Ziron is an assembler and not a compiler.
i was thinking to get around this problem by the next consept
plugin will take the control from the beginning , of course that will be after program statement , as you have said using event handler for 'program' term will be impossible.
plugin will parse the source code here , by this sequence
1- get the line , if it has a ';' then we have a valid line that ziron can execute it,
else still get the next line and keep searching for ';' trem.
2- start parse this line and see if we need to modify it then go ahead else pass it
without changed to Ziron ,EG executes it.
3- if we get the needed line we can modify it as desired and parse it then we can
make new line and execute it.
4- loop this procedure until we found end of code
hope you get my point.
thanks.
http://www.freewebs.com/ogremagic/index.htm
ok then i would still suggest to use FileEntry, i've wrote some code for you to help understand the usage, i have not tested it and it is not fully correct, will need a little work, but should give you a good idea how to do what you want to do :)
int bufSize;
char* strSource;
procedure emitLine(char* line) {
if (strAppend(strSource, line, bufSize) = false) {
//we need to re-alloc strSource and extend buffer size
edx = strSource;
add bufSize, 2048
strSource = new bufSize;
strlcpy(strSource, edx, 2048);
delete edx; //delete old mem
//now append it, maybe should check line is not 2048 bytes long :-p
strAppend(strSource, line, bufSize);
}
}
function InitPlugin(pointer pGetF) {
Ziron_LoadAll(pGetF); //use framework utility function to load all
//init strSource here
bufSize = 2048;
strSource = new 2048;
return strLoaded;
}
function UnloadPlugin() {
//free strSource here
delete strSource;
}
function FileEntry(DWord handle; char* code) {
uses edi;
m_strFill(strSource, 1, 0); //set first character as null so we can re-use for strAppend
//your usual code here
char tmp[2048];
edi = strGetLine(code, @tmp);
while(edi <> 0) {
Ziron_ShowMessage(@tmp);
emitLine(@tmp);
edi = strGetLine(edi, @tmp);
}
Ziron_SetFileBuffer(handle, strSource, strLen(strSource));
}
entry function DLLMain(DWord iDLL; DWord iReason; Pointer iResult) {
if (iReason == DLL_PROCESS_ATTACH) {
return true;
}
return false;
}
exports InitPlugin, UnloadPlugin, FileEntry;