Archive: Problem with executing CeCreateFile


Problem with executing CeCreateFile
I am using the system.dll plugin to execute RAPI commands for a remote installation.

I am able to create directories, but I am not able to open or create files.

System::Call "rapi::CeCreateDirectory(w 'application\ctgtalk', i 0) i .r4"

System::Call "rapi::CeFileCreate(w 'application\ctgtalk\somefile.txt', i 3, i 0, i 0, i 1, i 128, i 0) p .r4"


The create directory function works file returns 1 indicating success and directory is created.

The CeFileCreate function is supposed to return a file handle if it succeeds and an invalid handle if it fails. It is returning 0 with is not a valid file handle and the file is not created.

dwDesiredAccess is set to 3 which is GENERIC_READ | GENERIC_WRITE.
dwCreationDisposition is set to 1 which is CREATE_NEW.
dwFlagsAndAttributes is set to 128 which is FILE_ATTRIBUTE_NORMAL.

Does anyone have a clue as to why this is not working?

Chris Lustig





The parameter set to 1 sets to CREATE_NEW and the parameter set to 128 sets to FILE_ATTRIBUTES_NORMAL.


p is not a valid type in 2.46, use i for now


Originally posted by Anders
p is not a valid type in 2.46, use i for now
Doesn't work when I use i either. I am still clueless.

Chris

Would help if you used CeCreateFile instead of CeFileCreate ;)

Edit: And System should have put "error" on the stack.

Stu


That's Embarrasing
Oops I am a little dislexic. Thanks. At least I am now getting error codes back and can move forward.

Thanks,

Chris


From bogus errors to real errors CeCreateFile

Originally posted by Afrow UK
Would help if you used CeCreateFile instead of CeFileCreate ;)

Edit: And System should have put "error" on the stack.

Stu
That is in fact what was happening.

Now that the function call name is correct I am getting an invalid parameter error.

this is the System::Call

System::Call "rapi::CeCreateFile(w 'application\\ctgtalk\\somefile.txt', i 3, i 0, i 0, i 1, i 128, i 0) i .r4"

which should be equivalent to

CeCreateFile( L "\\application\\ctgTalk\\somefile.txt",GENERIC_WRITE | GENERIC_READ,0,0,CREATE_NEW,FILE_ATTRIBUTES_NORMAL,0)


Note: When calling fuctions through the System::Call forward slashes in front of the path don't work. I was able to get the CeCreateDirectory function to work when I removed the forward slashes.

If anyone has a clue for this one, it would be greatly appriciated.

Chris

You should use !defines for all the constants. For masks System allows | (bitwise or). That should help a bit. As for double backstrokes that is purely because in C/C++ (and others) a single backstroke is an escape character (i.e. "\"hello\""). You don't need to use two here.

Stu