Extended Attributes

From
Dmitry Babayev (2:5022/75)
To
All
Date
2001-05-17T17:48:48Z
Area
SU.WINDOWS.NT.PROG
Hello everybody.

Что делаю не так ?

#include <windows.h>
#include <stdio.h>

void main() {
  HANDLE hFileSource;
  WIN32_STREAM_ID *StreamId;
  DWORD dwBytesWritten;
  LPVOID lpContext;
  WCHAR EAName[] = L"MyAttribute";
  BYTE EAData[] = "My Extended Attributes";
  DWORD StreamHeaderSize;
  BOOL bSuccess;
  BYTE *Header;
  StreamHeaderSize = sizeof(WIN32_STREAM_ID) + wcslen(EAName) * sizeof(WCHAR);
  Header = (BYTE *)malloc(StreamHeaderSize);
  StreamId = (WIN32_STREAM_ID *)Header;
  hFileSource = CreateFile("EAtest", FILE_WRITE_EA,
                         FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
                         NULL, CREATE_ALWAYS, 0, NULL);
  if (hFileSource == INVALID_HANDLE_VALUE) {
    printf("CreateFile (source) error! (rc=%lu)\n", GetLastError());
    return;
  }
  lpContext = NULL;
  StreamId->dwStreamId = BACKUP_EA_DATA;
  StreamId->dwStreamAttributes = 0;
  StreamId->Size.QuadPart = sizeof(EAData);
  StreamId->dwStreamNameSize = wcslen(EAName) + 1;
  memmove(Header + sizeof(WIN32_STREAM_ID) - ANYSIZE_ARRAY * sizeof(WCHAR),
          EAName, (wcslen(EAName) + 1) * sizeof(WCHAR));
  bSuccess = BackupWrite(hFileSource, (LPBYTE)StreamId,
                         StreamHeaderSize, &dwBytesWritten, FALSE, FALSE,
                         &lpContext);
  if (bSuccess) {
    bSuccess = BackupWrite(hFileSource, EAData, sizeof(EAData), &dwBytesWritten,
                           FALSE, FALSE, &lpContext);
    if (!bSuccess) {
      printf("BackupWrite error! (rc=%i)\n", (int)(GetLastError()));
    }
    BackupWrite(hFileSource, NULL, 0, &dwBytesWritten, TRUE, FALSE, &lpContext);
  }
  CloseHandle(hFileSource);
}

Получаю GetLastError():

255 The extended attributes are inconsistent.  ERROR_EA_LIST_INCONSISTENT

Dmitry

---
 * Origin:  (2:5022/75)