EldoS | Feel safer!

Software components for data protection, secure storage and transfer

Mapper sample application doesn't work well under xp sp3

Also by EldoS: SecureBlackbox
200+ components and classes for digital security, signing, encryption and secure networking.
#17783
Posted: 10/08/2011 09:46:22
by xu zhi lian (Basic support level)
Joined: 09/27/2011
Posts: 17

I copied a file(such as test.zip) to vDisk(Z:) occur error, that means: Can't copy, the filename directory name or volume label syntax is incorrect.
but not always appear this error when Copy all the files,Just copy some files to appear this error.
I debuged the program and found, After CbFsWriteFile write all data, CbFsCreateFile fired FileName parameter is "\test.zip:Zone.Identifier"
Code
FileName   0x00f60260 "\test.zip:Zone.Identifier"   const wchar_t *


Then call CreateFile return INVALID_HANDLE_VALUE

Code
Ctx->hFile = (PVOID)CreateFile(
            FName,   //"\test.zip:Zone.Identifier"
            GENERIC_READ | FILE_WRITE_ATTRIBUTES,
            FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
            NULL,
            OPEN_EXISTING,
            FILE_FLAG_BACKUP_SEMANTICS,
            0);

if(INVALID_HANDLE_VALUE == Ctx->hFile)
        {
            *FileHandleContext = NULL;
            free(Ctx);
            free(FName);
            FName = NULL;
            throw ECBFSError(GetLastError());   //report error
        }


Why changed the filename from "test.zip" to "\test.zip:Zone.Identifier"?

I attached error picture.

I've send test.zip to sales@eldos.com.

Can you help me.
Thanks and Regards.
Xu


#17784
Posted: 10/08/2011 10:17:38
by Eugene Mayevski (EldoS Corp.)

:Zone.Identifier is the name of the alternate stream (semocolon is a separator between file name and stream name). Looks like mapper doesn't handle alternate streams correctly for whatever reason.
What exactly build of CBFS are you using?


Sincerely yours
Eugene Mayevski
#17785
Posted: 10/08/2011 10:23:44
by xu zhi lian (Basic support level)
Joined: 09/27/2011
Posts: 17

I found that if you copy the file to normal, After CbFsWriteFile write all data, CbFsCreateFile will not be fired.
#17786
Posted: 10/08/2011 10:26:15
by xu zhi lian (Basic support level)
Joined: 09/27/2011
Posts: 17

I am using 3.2.98 version of CBFS.
#17787
Posted: 10/08/2011 10:28:50
by Eugene Mayevski (EldoS Corp.)

Quote
xu zhi lian wrote:
I found that if you copy the file to normal, After CbFsWriteFile write all data, CbFsCreateFile will not be fired.


That is a workaround but not a solution. We'll check Mapper sample probably on Monday.


Sincerely yours
Eugene Mayevski
#17788
Posted: 10/08/2011 10:30:28
by xu zhi lian (Basic support level)
Joined: 09/27/2011
Posts: 17

this your your company provide an example of Mapper

Code
void CbFsEnumerateNamedStreams(
    CallbackFileSystem* Sender,
   CbFsFileInfo* FileInfo,
   PVOID* NamedStreamContext,
    PWSTR StreamName,
    PDWORD StreamNameLength,
    __int64* StreamSize,
    __int64* StreamAllocationSize,
    LPBOOL NamedStreamFound
    )
{
    WIN32_STREAM_ID sid;
    DWORD dw1,dw2,nRead;
    PWSTR FullName = NULL;
    PNAMED_STREAM_CONTEXT nsc = NULL;
    

    *NamedStreamFound = FALSE;

    if(*NamedStreamContext == NULL)  
    {
        FullName = (PWSTR)malloc((FileInfo->get_FileName(NULL) + _tcslen(g_RootPath) + 1) * sizeof(WCHAR));

        ASSERT(FullName);

        _tcscpy(FullName, g_RootPath);

        FileInfo->get_FileName(&FullName[_tcslen(g_RootPath)]);

        nsc = (PNAMED_STREAM_CONTEXT)malloc(sizeof(NAMED_STREAM_CONTEXT));
        
        ASSERT(nsc);

        ZeroMemory(nsc, sizeof(NAMED_STREAM_CONTEXT));

        nsc->Header.NodeTypeCode = CBFS_NTC_NAMED_STREAMS_ENUM;

        nsc->hFile = CreateFile(FullName,
            READ_CONTROL,
            0,
            NULL,
            OPEN_EXISTING,
            FILE_FLAG_BACKUP_SEMANTICS,
            NULL
            );
        *NamedStreamContext = nsc;
    }
    else
    {
        nsc = (PNAMED_STREAM_CONTEXT)*NamedStreamContext;
        ASSERT(nsc);
        ASSERT(nsc->hFile != INVALID_HANDLE_VALUE);
    }
    if(FullName) free(FullName);

    if (nsc->hFile == INVALID_HANDLE_VALUE)
    {
        free(nsc);
        DWORD error = GetLastError();
        throw ECBFSError(error);
    }

    ZeroMemory(&sid, sizeof(WIN32_STREAM_ID));

    DWORD StreamHeaderSize = (LPBYTE)&sid.cStreamName - (LPBYTE)&sid;
    
    while (*NamedStreamFound == FALSE)
    {
        BackupRead(nsc->hFile, (LPBYTE)&sid, StreamHeaderSize, &nRead, FALSE, TRUE, &nsc->EnumCtx);

        if(sid.dwStreamId == BACKUP_ALTERNATE_DATA)
        {
            *NamedStreamFound = TRUE;
            *StreamNameLength = sid.dwStreamNameSize;
            *StreamSize = sid.Size.QuadPart;
            *StreamAllocationSize = sid.Size.QuadPart;
            
            
            BackupRead(nsc->hFile, (LPBYTE) StreamName, sid.dwStreamNameSize,
                &nRead, FALSE, FALSE, &nsc->EnumCtx);

        }
        if(!BackupSeek(nsc->hFile, sid.Size.LowPart, sid.Size.HighPart, &dw1, &dw2, &nsc->EnumCtx))//search next stream
        {
            BackupRead(nsc->hFile, NULL, NULL, &nRead, TRUE, FALSE, &nsc->EnumCtx); // abort enumeration
            break;
        }
        ZeroMemory(&sid, sizeof(WIN32_STREAM_ID));
    }
    if(*NamedStreamFound == FALSE)
    {
        CloseHandle(nsc->hFile);    
        free(nsc);
        *NamedStreamContext = NULL;
    }
}
#17789
Posted: 10/08/2011 10:32:03
by xu zhi lian (Basic support level)
Joined: 09/27/2011
Posts: 17

Quote
Eugene Mayevski wrote:
Quote
xu zhi lian wrote:
I found that if you copy the file to normal, After CbFsWriteFile write all data, CbFsCreateFile will not be fired.


That is a workaround but not a solution. We'll check Mapper sample probably on Monday.


Thanks Mayevski
#17798
Posted: 10/10/2011 05:52:38
by Eugene Mayevski (EldoS Corp.)

There's a problem in interpretation of documentations in some applications. Documentation states "If this buffer is not large enough to hold a FILE_STREAM_INFORMATION structure for each file stream, FltQueryInformationFile or ZwQueryInformationFile returns STATUS_BUFFER_OVERFLOW or STATUS_BUFFER_TOO_SMALL."

In fact applications expect STATUS_BUFFER_OVERFLOW as returned by NTFS and don't check STATUS_BUFFER_TOO_SMALL (which is more logical and which was returned by CBFS). CBFS will return STATUS_BUFFER_OVERFLOW in the next build (in about a week).


Sincerely yours
Eugene Mayevski
#17802
Posted: 10/10/2011 09:40:18
by xu zhi lian (Basic support level)
Joined: 09/27/2011
Posts: 17

mapper sample application work fine under win7 in the current version.
mapper sample application work fine under xp sp3 in the next build too?
#17804
Posted: 10/10/2011 10:12:06
by Eugene Mayevski (EldoS Corp.)

It is expected to work (i.e. after fixes we couldn't reproduce the issue anymore). You would need to test your specific code with the next build when it's released.


Sincerely yours
Eugene Mayevski
Also by EldoS: SecureBlackbox
200+ components and classes for digital security, signing, encryption and secure networking.

Reply

Statistics

Topic viewed 2891 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!