EldoS | Feel safer!

Software components for data protection, secure storage and transfer

How to increase file size ?

Also by EldoS: Callback File System
Create virtual file systems and disks, expose and manage remote data as if they were files on the local disk.
#23027
Posted: 01/02/2013 07:29:14
by Mia Pak (Priority Standard support level)
Joined: 11/19/2012
Posts: 16

I have question for increase file size.
For add encryption information about the encrypted file, I increased the size to 512 bytes for the header block.
So I used callback function in the following ways.

1 WriteFile: Move start position to 512 and write buffer.
2 ReadFile: Move start position to 512 and read buffer.
3 SetEndOfFile: Increase end position to 512.
4 GetFilesize: Return original file size (except for the size of the header)

Usually. By way of the above, file header block is created well. and It's no problem.

However, In the specific program(like powerpoint), WriteFile being called to a larger size than the size of the SetEndofFile.
In this case, file handle size is less than buffer size because of header block and failed to save buffer.
So I use CallbackFiter :SetEndofFile to increase handle size in the WriteFile Callback. but It's occured system hang.

Check SetAllocationSize / EnumurateDirectory Callback but did not know the information about the increased size.

Do you have a advice if there is a way to solve my problem?

thank you.
#23029
Posted: 01/02/2013 09:00:02
by Vladimir Cherniga (EldoS Corp.)

Increasing file size possible without explicit SetEndOfFile event. It can be made by extending write request from the user mode. In this case just save a new file size in associated context.
#23035
Posted: 01/02/2013 12:39:31
by Mia Pak (Priority Standard support level)
Joined: 11/19/2012
Posts: 16

Could you explain in detail or simple example?
#23036
Posted: 01/02/2013 12:52:43
by Vladimir Cherniga (EldoS Corp.)

Quote
Could you explain in detail or simple example?

You may refer to the Encrypt sample, look at the EncryptContext::Write() procedure for details.
#23042
Posted: 01/04/2013 03:47:49
by Mia Pak (Priority Standard support level)
Joined: 11/19/2012
Posts: 16

I can't find increasing size in encrypt sample.

As I said above question, It's possible to change size at setendoffile callback and I increase size in this callback for my header.
But sometimes in WriteFile Callback, File size is changed writing none cached buffer after writing cache buffer . So I use "callbackfilter::setendoffile" to increase size for my header info size. but in this time SetEndofFile be caused desktop hang.

Is there any solution about my problem?
#23043
Posted: 01/04/2013 04:22:37
by Eugene Mayevski (EldoS Corp.)

We are sorry for misleading you, indeed our samples don't shift file data as you do.

As mentioned in the neigbour post, to forge file size you need to handle:
a) GetFileSize (OnPostGetFileSizesC)
b) EnumerateDirectory (OnEnumerateDirectoryC)
c) file alteration operations (OnSetAllocationSizeC, OnSetEndOfFileC, OnWriteFileC)

Note, that besides obvious events there's also OnWriteFileC event which can alter file size.

We do have plans to extend our sample to hold encryption key and IV in the beginning of the file, but such modification of the sample would take some time as our developers have a development plan filled for a couple of months.


Sincerely yours
Eugene Mayevski
#23044
Posted: 01/04/2013 04:26:00
by Vladimir Cherniga (EldoS Corp.)

What happened if you write beyond end of file in write callback, without changing EOF value ? Write callback may be originated from the cache or memory manager and in this case exclusive locks are granted to the file. This cause a system lock in callback handler, if you try to perform an operations that requires file system resources be acquired. It does mean that you cannot request file system to change file size in read or write callbacks.
#23047
Posted: 01/04/2013 10:09:16
by Mia Pak (Priority Standard support level)
Joined: 11/19/2012
Posts: 16

<--header block-->|<--- encrypted block (same size to original file) ---->

Above feature is what I want to make file structure.
For making this, I resized file size by CallbackFilter::SetEndOfFile in SetEndofFile Callback.(It's only one what I know.)
But cached writing alters the size of the file without firing any CallbackEvent(SetEndOfFile, EnumDiretory, SetAllocationSize). So If I can not resize the file in read/write callback like you said, Is there point to do this?
And Eugene said that altering is possible in write callback, then what is the way?

thank you. :)
#23048
Posted: 01/04/2013 10:24:29
by Vladimir Cherniga (EldoS Corp.)

You should try to report fake file size in GetFileSize and EnumerateDirectory callback. Also you may try to patch offsets for non-cached read/write requests in the corresponding callbacks in order to prevent header block reading into the system cache.
#23049
Posted: 01/04/2013 10:49:02
by Mia Pak (Priority Standard support level)
Joined: 11/19/2012
Posts: 16

Yes. I did it.
Problem is increasing the size of the file as header block after cached write.
Also by EldoS: MsgConnect
Cross-platform protocol-independent communication framework for building peer-to-peer and client-server applications and middleware components.

Reply

Statistics

Topic viewed 8457 times

Number of guests: 1, registered members: 0, in total hidden: 0




|

Back to top

As of July 15, 2016 EldoS Corporation will operate as a division of /n software inc. For more information, please read the announcement.

Got it!