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

Problem with macro fileread

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

Molotov member
Posts
49
Threads
21
Location
Behind Keyboard

Problem with macro fileread

PlugSys: Emit plugin has loaded!
PlugSys: zirdebug.dll skipped - plugin does not have entry function "InitPlugin"
--------------------------------------------


[15,50]: Expected ( but found , in [macro fileread]
Code: 
	ReadFile($handle, $fbuffer, $maxlen, $fileread, $overlapped);

Press the [enter] key to exit.

when using

	pointer zFile;
	zFile = filecreate(settingsfile);
	fileread(zFile,settings,512,null);
	fileclose(zFile);

"Lerning new things is what life is all about, if you are always doing the same old things day in and day out you might aswell just kill yourself." - ME d^_^b

Replies

Colin admin
Posts
928
Threads
49
Location
Bulgaria

decided to take a look at this before i go out to club :) anyways i've fixed a bug with mov instruction but for now i've applied a fix

edit the fileio.zir file and replace fileread with

inline function fileread(handle, fbuffer, maxlen, overlapped) {
	push 0
	ReadFile($handle, $fbuffer, $maxlen, esp, $overlapped);
	emit byte 0x8B, 0x04, 0x24;     //fix for "eax = [esp];"
	esp += 4;
	$return eax;
}

sample:

program WIN32CUI 'Test';

#include 'ch.zir';
#include 'fileio.zir';

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

const SettingsFile = '.\\Settings.dat';

char settings[1024];
pointer hFile;

hFile = fileopen(SettingsFile, OPEN_EXISTING);

fileread(hFile, @settings, 512, nil);

fileclose(hFile);

print('Settings = ', @settings, '\r\n');


wait_key(nil);
ExitProcess(0);

it should be noted that i plan to replace the fileio file with another in one of the upcoming releases, which will change all macro names.

e.g.

fileread will become File_Read(..., fileopen - File_Open(...

anyways for now this will solve your problem :)

Molotov member
Posts
49
Threads
21
Location
Behind Keyboard

fileread keeps crashing the application, commenting out it and it works..

Exception code: c0000005

Exception shift: 0000314c

program WIN32CUI 'Test';

#include 'ch.zir';
#include 'fileio.zir';
#include 'strings.zir';
////////////////////

const serverfile = '.\\servers.dat';
const settingsfile = '.\\settings.dat';


function test_fileread() {
	uses edi esi ecx;

	char servers[512];
	
	pointer zFile;
	zFile = fileopen(serverfile,OPEN_EXISTING);
	if(zFile == null) {
		print('Couldn´t open file \r\n');
		return false;
	} else {
		print('File open\r\n');
	}
	fileread(zFile,@servers,512,null);
	fileclose(zFile);
	
}

test_fileread();

wait_key(nil);
ExitProcess(0);

"Lerning new things is what life is all about, if you are always doing the same old things day in and day out you might aswell just kill yourself." - ME d^_^b

Colin admin
Posts
928
Threads
49
Location
Bulgaria

will look into it, did id only happen with latest release? what is "Exception shift" ?

Molotov member
Posts
49
Threads
21
Location
Behind Keyboard

beats me what it is i have a swedish win7 and it was saying "Undantags förskjutning" Undantag = eception, förskjutning = shift, google translate says: excluding shift..

Yeah was with latest release.. Haven´t tested with an older version..

"Lerning new things is what life is all about, if you are always doing the same old things day in and day out you might aswell just kill yourself." - ME d^_^b

Colin admin
Posts
928
Threads
49
Location
Bulgaria

ok this is fixed in the latest beta