ReactOS 0.4.15-dev-7931-gfd331f1
IDataObject.cpp File Reference
#include "precomp.h"
Include dependency graph for IDataObject.cpp:

Go to the source code of this file.

Macros

#define FILE_ATTRIBUTE_VIRTUAL   0x10000
 
#define GetFirstDataObject(spFolder, grfFlags, spData)   GetFirstDataObject_(__FILE__, __LINE__, spFolder, grfFlags, spData)
 

Functions

 DEFINE_GUID (CLSID_ZipFolderContextMenu, 0xb8cdcb65, 0xb1bf, 0x4b42, 0x94, 0x28, 0x1d, 0xfd, 0xb7, 0xee, 0x92, 0xaf)
 
static BOOL write_raw_file (const WCHAR *FileName, const void *Data, DWORD Size)
 
BOOL extract_resource (WCHAR *Filename, LPCWSTR ResourceName, WCHAR *ParentFolder)
 
bool InitializeShellFolder_ (const char *file, int line, const WCHAR *Filename, CComPtr< IShellFolder > &spFolder)
 
static bool GetFirstDataObject_ (const char *file, int line, IShellFolder *spFolder, SHCONTF grfFlags, CComPtr< IDataObject > &spData)
 
bool IsFormatAdvertised_ (const char *file, int line, IDataObject *pDataObj, CLIPFORMAT cfFormat, TYMED tymed)
 
static void test_FileDescriptor (FILEGROUPDESCRIPTORW *Descriptor)
 
static void test_FileDescriptor_Folder (FILEGROUPDESCRIPTORW *Descriptor)
 
static void test_FileContents1 (IStream *Stream)
 
static void test_FileContents2 (IStream *Stream)
 
static void test_DataObject_FirstFile (IShellFolder *pFolder)
 
static void test_DataObject_FirstFolder (IShellFolder *pFolder)
 
static void test_DataObject (const WCHAR *Filename)
 
 START_TEST (IDataObject)
 

Variables

static bool g_bOldZipfldr
 
const char test_file_1_contents [] = "Some generic text in the root file.\r\nMore text on a new line."
 
const char test_file_2_contents [] = "Some generic text in the file in folder_1.\r\nMore text on a new line."
 
static GUID GUID_NULL_
 
static CLIPFORMAT cfHIDA = RegisterClipboardFormatA(CFSTR_SHELLIDLISTA)
 
static CLIPFORMAT cfFileDescriptor = RegisterClipboardFormatW(CFSTR_FILEDESCRIPTORW)
 
static CLIPFORMAT cfFileContents = RegisterClipboardFormatW(CFSTR_FILECONTENTSW)
 

Macro Definition Documentation

◆ FILE_ATTRIBUTE_VIRTUAL

#define FILE_ATTRIBUTE_VIRTUAL   0x10000

Definition at line 11 of file IDataObject.cpp.

◆ GetFirstDataObject

#define GetFirstDataObject (   spFolder,
  grfFlags,
  spData 
)    GetFirstDataObject_(__FILE__, __LINE__, spFolder, grfFlags, spData)

Definition at line 93 of file IDataObject.cpp.

Function Documentation

◆ DEFINE_GUID()

DEFINE_GUID ( CLSID_ZipFolderContextMenu  ,
0xb8cdcb65  ,
0xb1bf  ,
0x4b42  ,
0x94  ,
0x28  ,
0x1d  ,
0xfd  ,
0xb7  ,
0xee  ,
0x92  ,
0xaf   
)

◆ extract_resource()

BOOL extract_resource ( WCHAR Filename,
LPCWSTR  ResourceName,
WCHAR ParentFolder 
)

Definition at line 39 of file IDataObject.cpp.

40{
42 UINT TickMask = 0xffff;
43 if (!ParentFolder)
44 {
46 ParentFolder = workdir;
47 }
48 else
49 {
50 // Fixed filename
51 TickMask = 0;
52 }
53 StringCchPrintfW(Filename, MAX_PATH, L"%sTMP%u.zip", ParentFolder, GetTickCount() & TickMask);
54
56 HRSRC hRsrc = FindResourceW(hMod, ResourceName, MAKEINTRESOURCEW(RT_RCDATA));
57 ok(!!hRsrc, "Unable to find %s\n", wine_dbgstr_w(ResourceName));
58 if (!hRsrc)
59 return FALSE;
60
61 HGLOBAL hGlobal = LoadResource(hMod, hRsrc);
62 DWORD Size = SizeofResource(hMod, hRsrc);
63 LPVOID pData = LockResource(hGlobal);
64
65 ok(Size && !!pData, "Unable to load %s\n", wine_dbgstr_w(ResourceName));
66 if (!Size || !pData)
67 return FALSE;
68
71 return Written;
72}
static BOOL write_raw_file(const WCHAR *FileName, const void *Data, DWORD Size)
Definition: IDataObject.cpp:21
#define ok(value,...)
Definition: atltest.h:57
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
#define MAX_PATH
Definition: compat.h:34
HMODULE WINAPI GetModuleHandleW(LPCWSTR lpModuleName)
Definition: loader.c:838
DWORD WINAPI GetTempPathW(IN DWORD count, OUT LPWSTR path)
Definition: path.c:2080
DWORD WINAPI GetTickCount(VOID)
Definition: time.c:455
HRSRC WINAPI FindResourceW(HINSTANCE hModule, LPCWSTR name, LPCWSTR type)
Definition: res.c:176
DWORD WINAPI SizeofResource(HINSTANCE hModule, HRSRC hRsrc)
Definition: res.c:568
LPVOID WINAPI LockResource(HGLOBAL handle)
Definition: res.c:550
HGLOBAL WINAPI LoadResource(HINSTANCE hModule, HRSRC hRsrc)
Definition: res.c:532
IN PVCB IN PBCB OUT PDIRENT IN USHORT IN POEM_STRING Filename
Definition: fatprocs.h:939
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
#define wine_dbgstr_w
Definition: kernel32.h:34
static char workdir[MAX_PATH]
Definition: batch.c:26
unsigned int UINT
Definition: ndis.h:50
#define L(x)
Definition: ntvdm.h:50
#define RT_RCDATA
Definition: pedump.c:372
#define _countof(array)
Definition: sndvol32.h:68
STRSAFEAPI StringCchPrintfW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszFormat,...)
Definition: strsafe.h:530
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1830
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4533
#define UnlockResource(handle)
Definition: winbase.h:3372
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by START_TEST().

◆ GetFirstDataObject_()

static bool GetFirstDataObject_ ( const char file,
int  line,
IShellFolder spFolder,
SHCONTF  grfFlags,
CComPtr< IDataObject > &  spData 
)
static

Definition at line 94 of file IDataObject.cpp.

95{
96 CComPtr<IEnumIDList> spEnum;
97 HRESULT hr;
98 ok_hr_(file, line, (hr = spFolder->EnumObjects(NULL, grfFlags, &spEnum)), S_OK);
99 if (!SUCCEEDED(hr))
100 return false;
101
102 CComHeapPtr<ITEMID_CHILD> child;
103 ULONG celtFetched = 0;
104 ok_hr_(file, line, (hr = spEnum->Next(1, &child, &celtFetched)), S_OK);
105 ok_int_(file, line, celtFetched, 1);
106 if (!SUCCEEDED(hr))
107 return false;
108
109 // This call fails without the extension being '.zip'
110 ok_hr_(file, line, (hr = spFolder->GetUIObjectOf(NULL, 1, &child, IID_IDataObject, NULL, reinterpret_cast<LPVOID*>(&spData))), S_OK);
111 return SUCCEEDED(hr);
112}
#define ok_hr_(file, line, status, expected)
Definition: apitest.h:55
HRESULT GetUIObjectOf([in] HWND hwndOwner, [in] UINT cidl, [in, size_is(cidl)] PCUITEMID_CHILD_ARRAY apidl, [in] REFIID riid, [in, out, unique] UINT *prgfInOut, [out, iid_is(riid)] void **ppvOut)
HRESULT EnumObjects([in] HWND hwndOwner, [in] SHCONTF grfFlags, [out] IEnumIDList **ppenumIDList)
#define S_OK
Definition: intsafe.h:52
#define SUCCEEDED(hr)
Definition: intsafe.h:50
static HWND child
Definition: cursoricon.c:298
const GUID IID_IDataObject
#define ok_int_(file, line, expression, result)
Definition: test.h:992
HRESULT hr
Definition: shlfolder.c:183
Definition: fci.c:127
Definition: parser.c:49
uint32_t ULONG
Definition: typedefs.h:59

◆ InitializeShellFolder_()

bool InitializeShellFolder_ ( const char file,
int  line,
const WCHAR Filename,
CComPtr< IShellFolder > &  spFolder 
)

Definition at line 74 of file IDataObject.cpp.

75{
76 CComHeapPtr<ITEMIDLIST_ABSOLUTE> pidl;
77 HRESULT hr;
79 if (!SUCCEEDED(hr))
80 return false;
81
82 CComPtr<IShellFolder> spParent;
83 PCUIDLIST_RELATIVE pidlLast;
84 ok_hr_(file, line, (hr = SHBindToParent(pidl, IID_PPV_ARG(IShellFolder, &spParent), &pidlLast)), S_OK);
85 if (!SUCCEEDED(hr))
86 return false;
87
88 ok_hr_(file, line, (hr = spParent->BindToObject(pidlLast, 0, IID_PPV_ARG(IShellFolder, &spFolder))), S_OK);
89
90 return SUCCEEDED(hr);
91}
HRESULT WINAPI SHParseDisplayName(LPCWSTR pszName, IBindCtx *pbc, LPITEMIDLIST *ppidl, SFGAOF sfgaoIn, SFGAOF *psfgaoOut)
Definition: pidl.c:1405
HRESULT WINAPI SHBindToParent(LPCITEMIDLIST pidl, REFIID riid, LPVOID *ppv, LPCITEMIDLIST *ppidlLast)
Definition: pidl.c:1361
const ITEMIDLIST_RELATIVE UNALIGNED * PCUIDLIST_RELATIVE
Definition: shtypes.idl:57
#define IID_PPV_ARG(Itype, ppType)

◆ IsFormatAdvertised_()

bool IsFormatAdvertised_ ( const char file,
int  line,
IDataObject pDataObj,
CLIPFORMAT  cfFormat,
TYMED  tymed 
)

Definition at line 114 of file IDataObject.cpp.

115{
116 CComPtr<IEnumFORMATETC> pEnumFmt;
117 HRESULT hr = pDataObj->EnumFormatEtc(DATADIR_GET, &pEnumFmt);
118
119 ok_hex_(file, line, hr, S_OK);
120 if (!SUCCEEDED(hr))
121 return false;
122
123 FORMATETC fmt;
124 while (S_OK == (hr = pEnumFmt->Next(1, &fmt, NULL)))
125 {
126 if (fmt.cfFormat == cfFormat)
127 {
128 ok_hex_(file, line, fmt.lindex, -1);
129 if (tymed)
130 ok_hex_(file, line, fmt.tymed, tymed);
131 return true;
132 }
133 }
135 return false;
136}
#define ok_hex_(expression, result)
HRESULT EnumFormatEtc([in] DWORD dwDirection, [out] IEnumFORMATETC **ppenumFormatEtc)
static DWORD tymed
Definition: url.c:174
Definition: dsound.c:943
#define S_FALSE
Definition: winerror.h:2357

◆ START_TEST()

START_TEST ( IDataObject  )

Definition at line 565 of file IDataObject.cpp.

566{
567 skip("Code in zipfldr not implemented yet\n");
568 return;
569
571
572 ok_hr(hr, S_OK);
573 if (!SUCCEEDED(hr))
574 return;
575
576 WCHAR ZipTestFile[MAX_PATH];
578 return;
579 test_DataObject(ZipTestFile);
580 DeleteFileW(ZipTestFile);
582}
#define ok_hr(status, expected)
Definition: ACListISF.cpp:31
BOOL extract_resource(WCHAR *Filename, LPCWSTR ResourceName, WCHAR *ParentFolder)
Definition: IDataObject.cpp:39
#define skip(...)
Definition: atltest.h:64
BOOL WINAPI DeleteFileW(IN LPCWSTR lpFileName)
Definition: delete.c:39
HRESULT WINAPI CoInitialize(LPVOID lpReserved)
Definition: compobj.c:1964
void WINAPI DECLSPEC_HOTPATCH CoUninitialize(void)
Definition: compobj.c:2067
#define IDR_ZIP_TEST_FILE
Definition: resource.h:2
static void test_DataObject(void)
Definition: shlfolder.c:5102

◆ test_DataObject()

static void test_DataObject ( const WCHAR Filename)
static

Definition at line 554 of file IDataObject.cpp.

555{
556 CComPtr<IShellFolder> spFolder;
557 if (!InitializeShellFolder(Filename, spFolder))
558 return;
559
562}
static void test_DataObject_FirstFolder(IShellFolder *pFolder)
static void test_DataObject_FirstFile(IShellFolder *pFolder)
#define InitializeShellFolder(Filename, pFolder)
Definition: precomp.h:25

◆ test_DataObject_FirstFile()

static void test_DataObject_FirstFile ( IShellFolder pFolder)
static

Definition at line 409 of file IDataObject.cpp.

410{
411 CComPtr<IDataObject> spDataObj;
412 if (!GetFirstDataObject(pFolder, SHCONTF_NONFOLDERS, spDataObj))
413 return;
414
415 if (!IsFormatAdvertised(spDataObj, cfHIDA, TYMED_HGLOBAL))
416 {
417 trace("Pre-Vista zipfldr\n");
418 // No seconds in filetimes, less functional IStream* implementation
419 g_bOldZipfldr = true;
420 }
421
422 ok(!IsFormatAdvertised(spDataObj, CF_HDROP, TYMED_NULL), "Expected CF_HDROP to be absent\n");
423 ok(IsFormatAdvertised(spDataObj, cfFileDescriptor, TYMED_HGLOBAL), "Expected FileDescriptorW to be supported\n");
424 ok(IsFormatAdvertised(spDataObj, cfFileContents, TYMED_ISTREAM), "Expected FileContents to be supported\n");
425
426 STGMEDIUM medium = {0};
427 FORMATETC etc = { cfFileDescriptor, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL };
428 HRESULT hr = spDataObj->GetData(&etc, &medium);
429 ok_hex(hr, S_OK);
430 if (!SUCCEEDED(hr))
431 return;
432
433 ok_hex(medium.tymed, TYMED_HGLOBAL);
434 PVOID pData = GlobalLock(medium.hGlobal);
436 GlobalUnlock(medium.hGlobal);
437 ReleaseStgMedium(&medium);
438
439 // Invalid index
440 etc.cfFormat = cfFileContents;
441 etc.ptd = NULL;
442 etc.dwAspect = DVASPECT_CONTENT;
443 etc.lindex = -1;
444 etc.tymed = TYMED_ISTREAM;
445 memset(&medium, 0xcc, sizeof(medium));
446 hr = spDataObj->GetData(&etc, &medium);
448 ok_hex(medium.tymed, TYMED_NULL);
449 ok_ptr(medium.hGlobal, NULL);
450 ok_ptr(medium.pUnkForRelease, NULL);
451 if (SUCCEEDED(hr))
452 ReleaseStgMedium(&medium);
453
454 // Correct index
455 etc.cfFormat = cfFileContents;
456 etc.ptd = NULL;
457 etc.dwAspect = DVASPECT_CONTENT;
458 etc.lindex = 0;
459 etc.tymed = TYMED_ISTREAM;
460 memset(&medium, 0xcc, sizeof(medium));
461 // During this call a temp file is created: %TMP%\Temp%u_%s\test_file_for_zip.txt
462 // Or for the 2k3 version: %TMP%\Temporary Directory %u for %s\test_file_for_zip.txt
463 hr = spDataObj->GetData(&etc, &medium);
464 ok_hex(hr, S_OK);
465 ok_hex(medium.tymed, TYMED_ISTREAM);
466 if (SUCCEEDED(hr))
467 {
468 test_FileContents1(medium.pstm);
469 ReleaseStgMedium(&medium);
470 }
471
472 //if (winetest_get_failures())
473 // DumpDataObjectFormats(spDataObj);
474}
static CLIPFORMAT cfFileDescriptor
static void test_FileDescriptor(FILEGROUPDESCRIPTORW *Descriptor)
static CLIPFORMAT cfFileContents
static bool g_bOldZipfldr
Definition: IDataObject.cpp:17
static void test_FileContents1(IStream *Stream)
#define GetFirstDataObject(spFolder, grfFlags, spData)
Definition: IDataObject.cpp:93
static CLIPFORMAT cfHIDA
#define ok_hex(expression, result)
Definition: atltest.h:94
#define trace
Definition: atltest.h:70
#define ok_ptr(expression, result)
Definition: atltest.h:108
#define CF_HDROP
Definition: constants.h:410
#define E_INVALIDARG
Definition: ddrawi.h:101
void WINAPI ReleaseStgMedium(STGMEDIUM *pmedium)
Definition: ole2.c:2033
LPVOID NTAPI GlobalLock(HGLOBAL hMem)
Definition: heapmem.c:755
BOOL NTAPI GlobalUnlock(HGLOBAL hMem)
Definition: heapmem.c:1190
#define IsFormatAdvertised(pDataObj, cfFormat, tymed)
Definition: precomp.h:28
#define memset(x, y, z)
Definition: compat.h:39

Referenced by test_DataObject().

◆ test_DataObject_FirstFolder()

static void test_DataObject_FirstFolder ( IShellFolder pFolder)
static

Definition at line 476 of file IDataObject.cpp.

477{
478 CComPtr<IDataObject> spDataObj;
479 if (!GetFirstDataObject(pFolder, SHCONTF_FOLDERS, spDataObj))
480 return;
481
482 ok(!IsFormatAdvertised(spDataObj, CF_HDROP, TYMED_NULL), "Expected CF_HDROP to be absent\n");
483 ok(IsFormatAdvertised(spDataObj, cfFileDescriptor, TYMED_HGLOBAL), "Expected FileDescriptorW to be supported\n");
484 ok(IsFormatAdvertised(spDataObj, cfFileContents, TYMED_ISTREAM), "Expected FileContents to be supported\n");
485 // 7+
486 ok(!!IsFormatAdvertised(spDataObj, cfHIDA, TYMED_HGLOBAL) != g_bOldZipfldr, "Expected HIDA to be %s\n", g_bOldZipfldr ? "absent" : "supported");
487
488 STGMEDIUM medium = {0};
489 FORMATETC etc = { cfFileDescriptor, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL };
490 HRESULT hr = spDataObj->GetData(&etc, &medium);
491 ok_hex(hr, S_OK);
492 if (!SUCCEEDED(hr))
493 return;
494
495 ok_hex(medium.tymed, TYMED_HGLOBAL);
496 PVOID pData = GlobalLock(medium.hGlobal);
498 GlobalUnlock(medium.hGlobal);
499 ReleaseStgMedium(&medium);
500
501 // Invalid index
502 etc.cfFormat = cfFileContents;
503 etc.ptd = NULL;
504 etc.dwAspect = DVASPECT_CONTENT;
505 etc.lindex = -1;
506 etc.tymed = TYMED_ISTREAM;
507 memset(&medium, 0xcc, sizeof(medium));
508 hr = spDataObj->GetData(&etc, &medium);
510 ok_hex(medium.tymed, TYMED_NULL);
511 ok_ptr(medium.hGlobal, NULL);
512 ok_ptr(medium.pUnkForRelease, NULL);
513 if (SUCCEEDED(hr))
514 ReleaseStgMedium(&medium);
515
516 // Not a file (first index is the folder)
517 etc.cfFormat = cfFileContents;
518 etc.ptd = NULL;
519 etc.dwAspect = DVASPECT_CONTENT;
520 etc.lindex = 0;
521 etc.tymed = TYMED_ISTREAM;
522 memset(&medium, 0xcc, sizeof(medium));
523 hr = spDataObj->GetData(&etc, &medium);
524 ok_hex(hr, E_FAIL);
525 ok_hex(medium.tymed, TYMED_NULL);
526 ok_ptr(medium.hGlobal, NULL);
527 ok_ptr(medium.pUnkForRelease, NULL);
528 if (SUCCEEDED(hr))
529 ReleaseStgMedium(&medium);
530
531 // The file (content of the folder)
532 etc.cfFormat = cfFileContents;
533 etc.ptd = NULL;
534 etc.dwAspect = DVASPECT_CONTENT;
535 etc.lindex = 1;
536 etc.tymed = TYMED_ISTREAM;
537 memset(&medium, 0xcc, sizeof(medium));
538 // During this call a temp file is created: %TMP%\Temp%u_%s\folder1\test_file_for_zip.txt
539 // Or for the 2k3 version: %TMP%\Temporary Directory %u for %s\folder1\test_file_for_zip.txt
540 hr = spDataObj->GetData(&etc, &medium);
541 ok_hex(hr, S_OK);
542 ok_hex(medium.tymed, TYMED_ISTREAM);
543 if (SUCCEEDED(hr))
544 {
545 test_FileContents2(medium.pstm);
546 ReleaseStgMedium(&medium);
547 }
548
549 //if (winetest_get_failures())
550 // DumpDataObjectFormats(spDataObj);
551}
static void test_FileContents2(IStream *Stream)
static void test_FileDescriptor_Folder(FILEGROUPDESCRIPTORW *Descriptor)
#define E_FAIL
Definition: ddrawi.h:102

Referenced by test_DataObject().

◆ test_FileContents1()

static void test_FileContents1 ( IStream Stream)
static

Definition at line 223 of file IDataObject.cpp.

224{
225 STATSTG statstg = {0};
226 HRESULT hr = Stream->Stat(&statstg, STATFLAG_DEFAULT);
228 if (SUCCEEDED(hr))
229 {
230 FILETIME LocalFileTime, FileTime;
231 WORD Mask = g_bOldZipfldr ? 0xffe0 : (0xffff); // bits 0-4 are the seconds
232 DosDateTimeToFileTime(0x5024, (0xa5f2 & Mask), &LocalFileTime);
233 LocalFileTimeToFileTime(&LocalFileTime, &FileTime);
234
235 ok_wstr(statstg.pwcsName, L"test_file_for_zip.txt");
236 ok_hex(statstg.type, STGTY_STREAM);
237 ok_int(statstg.cbSize.LowPart, strlen(test_file_1_contents));
238 ok_hex(statstg.cbSize.HighPart, 0);
239 ok_hex(statstg.mtime.dwHighDateTime, FileTime.dwHighDateTime);
240 ok_hex(statstg.mtime.dwLowDateTime, FileTime.dwLowDateTime);
241 ok_hex(statstg.ctime.dwHighDateTime, FileTime.dwHighDateTime);
242 ok_hex(statstg.ctime.dwLowDateTime, FileTime.dwLowDateTime);
243 ok_hex(statstg.atime.dwHighDateTime, FileTime.dwHighDateTime);
244 ok_hex(statstg.atime.dwLowDateTime, FileTime.dwLowDateTime);
245 ok_hex(statstg.grfMode, STGM_SHARE_DENY_WRITE);
246 ok_hex(statstg.grfLocksSupported, 0);
247 ok(!memcmp(&statstg.clsid, &GUID_NULL_, sizeof(GUID_NULL_)), "Expected GUID_NULL, got %s\n", wine_dbgstr_guid(&statstg.clsid));
248 ok_hex(statstg.grfStateBits, 0);
249 CoTaskMemFree(statstg.pwcsName);
250 }
251
252 LARGE_INTEGER Offset = { {0} };
253 ULARGE_INTEGER NewPosition = { {0} };
254 hr = Stream->Seek(Offset, STREAM_SEEK_CUR, &NewPosition);
256 ok_int(NewPosition.HighPart, 0);
257 ok_int(NewPosition.LowPart, 0);
258
259 char buf[100] = { 0 };
260 ULONG cbRead;
261 hr = Stream->Read(buf, sizeof(buf)-1, &cbRead);
262 ok_hex(hr, S_FALSE);
265
266 hr = Stream->Seek(Offset, STREAM_SEEK_CUR, &NewPosition);
268 ok_int(NewPosition.HighPart, 0);
269 if (SUCCEEDED(hr))
271
272 ULONG cbWritten;
273 hr = Stream->Write("DUMMY", 5, &cbWritten);
274 if (!g_bOldZipfldr)
275 {
277 }
278 else
279 {
280 // Write succeeds, but is not reflected in the file on disk
281 ok_hex(hr, S_OK);
282 }
283
284 // Can increase the size...
285 NewPosition.LowPart = statstg.cbSize.LowPart + 1;
286 hr = Stream->SetSize(NewPosition);
288
289 // But is not reflected in the Stat result
290 hr = Stream->Stat(&statstg, STATFLAG_DEFAULT);
292 if (SUCCEEDED(hr))
293 {
294 ok_int(statstg.cbSize.LowPart, strlen(test_file_1_contents));
295 CoTaskMemFree(statstg.pwcsName);
296 }
297
298 // Old zipfldr does not support seek, so we can not read it again
299 if (!g_bOldZipfldr)
300 {
301 Offset.QuadPart = 0;
302 hr = Stream->Seek(Offset, STREAM_SEEK_SET, &NewPosition);
303 ok_hex(hr, S_OK);
304
305 memset(buf, 0, sizeof(buf));
306 hr = Stream->Read(buf, sizeof(buf)-1, &cbRead);
307 ok_hex(hr, S_FALSE);
309 }
310}
const char test_file_1_contents[]
Definition: IDataObject.cpp:18
static GUID GUID_NULL_
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define ok_str(x, y)
Definition: atltest.h:127
#define ok_wstr(x, y)
Definition: atltest.h:130
#define ok_int(expression, result)
Definition: atltest.h:134
#define E_NOTIMPL
Definition: ddrawi.h:99
BOOL WINAPI DosDateTimeToFileTime(IN WORD wFatDate, IN WORD wFatTime, OUT LPFILETIME lpFileTime)
Definition: time.c:75
BOOL WINAPI LocalFileTimeToFileTime(IN CONST FILETIME *lpLocalFileTime, OUT LPFILETIME lpFileTime)
Definition: time.c:253
unsigned short WORD
Definition: ntddk_ex.h:93
unsigned int Mask
Definition: fpcontrol.c:82
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
VOID WINAPI CoTaskMemFree(LPVOID ptr)
Definition: ifs.c:442
HRESULT Write([in, size_is(cb)] const void *pv, [in] ULONG cb, [out] ULONG *pcbWritten)
HRESULT Read([out, size_is(cb), length_is(*pcbRead)] void *pv, [in] ULONG cb, [out] ULONG *pcbRead)
HRESULT SetSize([in] ULARGE_INTEGER libNewSize)
HRESULT Stat([out] STATSTG *pstatstg, [in] DWORD grfStatFlag)
HRESULT Seek([in] LARGE_INTEGER dlibMove, [in] DWORD dwOrigin, [out] ULARGE_INTEGER *plibNewPosition)
static IStream Stream
Definition: htmldoc.c:1115
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
#define STGM_SHARE_DENY_WRITE
Definition: objbase.h:922
static __inline const char * wine_dbgstr_guid(const GUID *id)
Definition: debug.h:197
DWORD dwHighDateTime
Definition: mapidefs.h:66
DWORD dwLowDateTime
Definition: mapidefs.h:65
$ULONG LowPart
Definition: ntbasedef.h:569
$ULONG HighPart
Definition: ntbasedef.h:570
#define STG_E_ACCESSDENIED
Definition: winerror.h:2568

Referenced by test_DataObject_FirstFile().

◆ test_FileContents2()

static void test_FileContents2 ( IStream Stream)
static

Definition at line 313 of file IDataObject.cpp.

314{
315 STATSTG statstg = {0};
316 HRESULT hr = Stream->Stat(&statstg, STATFLAG_DEFAULT);
318 if (SUCCEEDED(hr))
319 {
320 FILETIME LocalFileTime, FileTime;
321 WORD Mask = g_bOldZipfldr ? 0xffe0 : (0xffff); // bits 0-4 are the seconds
322 DosDateTimeToFileTime(0x5024, (0xa60d & Mask), &LocalFileTime);
323 LocalFileTimeToFileTime(&LocalFileTime, &FileTime);
324
325 ok_wstr(statstg.pwcsName, L"test_file_for_zip.txt");
326 ok_hex(statstg.type, STGTY_STREAM);
327 ok_int(statstg.cbSize.LowPart, strlen(test_file_2_contents));
328 ok_hex(statstg.cbSize.HighPart, 0);
329 ok_hex(statstg.mtime.dwHighDateTime, FileTime.dwHighDateTime);
330 ok_hex(statstg.mtime.dwLowDateTime, FileTime.dwLowDateTime);
331 ok_hex(statstg.ctime.dwHighDateTime, FileTime.dwHighDateTime);
332 ok_hex(statstg.ctime.dwLowDateTime, FileTime.dwLowDateTime);
333 ok_hex(statstg.atime.dwHighDateTime, FileTime.dwHighDateTime);
334 ok_hex(statstg.atime.dwLowDateTime, FileTime.dwLowDateTime);
335 ok_hex(statstg.grfMode, STGM_SHARE_DENY_WRITE);
336 ok_hex(statstg.grfLocksSupported, 0);
337 ok(!memcmp(&statstg.clsid, &GUID_NULL_, sizeof(GUID_NULL_)), "Expected GUID_NULL, got %s\n", wine_dbgstr_guid(&statstg.clsid));
338 ok_hex(statstg.grfStateBits, 0);
339 CoTaskMemFree(statstg.pwcsName);
340 }
341
342 LARGE_INTEGER Offset = { {0} };
343 ULARGE_INTEGER NewPosition = { {0} };
344 hr = Stream->Seek(Offset, STREAM_SEEK_CUR, &NewPosition);
346 ok_int(NewPosition.HighPart, 0);
347 ok_int(NewPosition.LowPart, 0);
348
349 char buf[100] = { 0 };
350 ULONG cbRead;
351 hr = Stream->Read(buf, sizeof(buf)-1, &cbRead);
352 ok_hex(hr, S_FALSE);
355
356 hr = Stream->Seek(Offset, STREAM_SEEK_CUR, &NewPosition);
358 ok_int(NewPosition.HighPart, 0);
359 if (SUCCEEDED(hr))
361
362 ULONG cbWritten;
363 hr = Stream->Write("DUMMY", 5, &cbWritten);
364 if (!g_bOldZipfldr)
365 {
367 }
368 else
369 {
370 // Write succeeds, but is not reflected in the file on disk
371 ok_hex(hr, S_OK);
372 }
373
374 // Can increase the size...
375 NewPosition.LowPart = statstg.cbSize.LowPart + 1;
376 hr = Stream->SetSize(NewPosition);
378
379 // But is not reflected in the Stat result
380 hr = Stream->Stat(&statstg, STATFLAG_DEFAULT);
382 if (SUCCEEDED(hr))
383 {
384 ok_int(statstg.cbSize.LowPart, strlen(test_file_2_contents));
385 CoTaskMemFree(statstg.pwcsName);
386 }
387
388 // Old zipfldr does not support seek, so we can not read it again
389 if (!g_bOldZipfldr)
390 {
391 Offset.QuadPart = 0;
392 hr = Stream->Seek(Offset, STREAM_SEEK_SET, &NewPosition);
393 ok_hex(hr, S_OK);
394
395 memset(buf, 0, sizeof(buf));
396 hr = Stream->Read(buf, sizeof(buf)-1, &cbRead);
397 ok_hex(hr, S_FALSE);
400 }
401}
const char test_file_2_contents[]
Definition: IDataObject.cpp:19

Referenced by test_DataObject_FirstFolder().

◆ test_FileDescriptor()

static void test_FileDescriptor ( FILEGROUPDESCRIPTORW Descriptor)
static

Definition at line 163 of file IDataObject.cpp.

164{
165 ok_int(Descriptor->cItems, 1u);
166 if (Descriptor->cItems > 0)
167 {
168 FILETIME LocalFileTime, FileTime;
169 WORD Mask = g_bOldZipfldr ? 0xffe0 : (0xffff); // bits 0-4 are the seconds
170 DosDateTimeToFileTime(0x5024, (0xa5f2 & Mask), &LocalFileTime);
171 LocalFileTimeToFileTime(&LocalFileTime, &FileTime);
172
173 FILEDESCRIPTORW* FileDescriptor = Descriptor->fgd;
176 ok_hex(FileDescriptor->ftLastWriteTime.dwHighDateTime, FileTime.dwHighDateTime);
177 ok_hex(FileDescriptor->ftLastWriteTime.dwLowDateTime, FileTime.dwLowDateTime);
178 ok_hex(FileDescriptor->nFileSizeHigh, 0);
180 ok_wstr(FileDescriptor->cFileName, L"test_file_for_zip.txt");
181 }
182}
#define FILE_ATTRIBUTE_VIRTUAL
Definition: IDataObject.cpp:11
#define FILE_ATTRIBUTE_ARCHIVE
Definition: nt_native.h:706
#define FD_WRITESTIME
Definition: shlobj.h:2307
#define FD_FILESIZE
Definition: shlobj.h:2308
#define FD_PROGRESSUI
Definition: shlobj.h:2309
#define FD_ATTRIBUTES
Definition: shlobj.h:2304
FILETIME ftLastWriteTime
Definition: shlobj.h:2340
DWORD dwFileAttributes
Definition: shlobj.h:2337
WCHAR cFileName[MAX_PATH]
Definition: shlobj.h:2343
DWORD nFileSizeLow
Definition: shlobj.h:2342
DWORD nFileSizeHigh
Definition: shlobj.h:2341
_Must_inspect_result_ _In_ WDFIORESLIST _In_ PIO_RESOURCE_DESCRIPTOR Descriptor
Definition: wdfresource.h:342

Referenced by test_DataObject_FirstFile().

◆ test_FileDescriptor_Folder()

static void test_FileDescriptor_Folder ( FILEGROUPDESCRIPTORW Descriptor)
static

Definition at line 184 of file IDataObject.cpp.

185{
186 ok_int(Descriptor->cItems, 2u);
187 if (Descriptor->cItems > 0)
188 {
189 FILETIME LocalFileTime, FileTime;
190 WORD Mask = g_bOldZipfldr ? 0xffe0 : (0xffff); // bits 0-4 are the seconds
191 DosDateTimeToFileTime(0x5024, (0xa5fc & Mask), &LocalFileTime);
192 LocalFileTimeToFileTime(&LocalFileTime, &FileTime);
193
194 FILEDESCRIPTORW* FileDescriptor = Descriptor->fgd;
196 ok(FileDescriptor->dwFileAttributes == FILE_ATTRIBUTE_DIRECTORY ||
197 FileDescriptor->dwFileAttributes == (FILE_ATTRIBUTE_DIRECTORY | FILE_ATTRIBUTE_VIRTUAL), "Got attr: 0x%lx\n", FileDescriptor->dwFileAttributes);
198 //ok_hex(FileDescriptor->dwFileAttributes, FILE_ATTRIBUTE_DIRECTORY);
199 ok_hex(FileDescriptor->ftLastWriteTime.dwHighDateTime, FileTime.dwHighDateTime);
200 ok_hex(FileDescriptor->ftLastWriteTime.dwLowDateTime, FileTime.dwLowDateTime);
201 ok_hex(FileDescriptor->nFileSizeHigh, 0);
202 ok_hex(FileDescriptor->nFileSizeLow, 0);
203 ok_wstr(FileDescriptor->cFileName, L"folder_1");
204
205 if (Descriptor->cItems > 1)
206 {
207 DosDateTimeToFileTime(0x5024, (0xa60d & Mask), &LocalFileTime);
208 LocalFileTimeToFileTime(&LocalFileTime, &FileTime);
209
210 FileDescriptor = Descriptor->fgd + 1;
213 ok_hex(FileDescriptor->ftLastWriteTime.dwHighDateTime, FileTime.dwHighDateTime);
214 ok_hex(FileDescriptor->ftLastWriteTime.dwLowDateTime, FileTime.dwLowDateTime);
215 ok_hex(FileDescriptor->nFileSizeHigh, 0);
217 ok_wstr(FileDescriptor->cFileName, L"folder_1\\test_file_for_zip.txt");
218 }
219 }
220}
#define FILE_ATTRIBUTE_DIRECTORY
Definition: nt_native.h:705

Referenced by test_DataObject_FirstFolder().

◆ write_raw_file()

static BOOL write_raw_file ( const WCHAR FileName,
const void Data,
DWORD  Size 
)
static

Definition at line 21 of file IDataObject.cpp.

22{
24 DWORD dwWritten;
26
28 {
29 skip("Failed to create temp file %ls, error %lu\n", FileName, GetLastError());
30 return FALSE;
31 }
32 Success = WriteFile(Handle, Data, Size, &dwWritten, NULL);
33 ok(Success == TRUE, "WriteFile failed with %lu\n", GetLastError());
34 ok(dwWritten == Size, "WriteFile wrote %lu bytes instead of %lu\n", dwWritten, Size);
36 return Success && (dwWritten == Size);
37}
#define TRUE
Definition: types.h:120
#define CloseHandle
Definition: compat.h:739
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define CreateFileW
Definition: compat.h:741
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:137
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:24
@ Success
Definition: eventcreate.c:712
ULONG Handle
Definition: gdb_input.c:15
#define CREATE_ALWAYS
Definition: disk.h:72
#define GENERIC_WRITE
Definition: nt_native.h:90
DWORD WINAPI GetLastError(void)
Definition: except.c:1042

Referenced by extract_resource().

Variable Documentation

◆ cfFileContents

CLIPFORMAT cfFileContents = RegisterClipboardFormatW(CFSTR_FILECONTENTSW)
static

Definition at line 407 of file IDataObject.cpp.

Referenced by test_DataObject_FirstFile(), and test_DataObject_FirstFolder().

◆ cfFileDescriptor

CLIPFORMAT cfFileDescriptor = RegisterClipboardFormatW(CFSTR_FILEDESCRIPTORW)
static

Definition at line 406 of file IDataObject.cpp.

Referenced by test_DataObject_FirstFile(), and test_DataObject_FirstFolder().

◆ cfHIDA

CLIPFORMAT cfHIDA = RegisterClipboardFormatA(CFSTR_SHELLIDLISTA)
static

Definition at line 405 of file IDataObject.cpp.

Referenced by test_DataObject_FirstFile(), and test_DataObject_FirstFolder().

◆ g_bOldZipfldr

◆ GUID_NULL_

GUID GUID_NULL_
static

Definition at line 222 of file IDataObject.cpp.

Referenced by test_FileContents1(), and test_FileContents2().

◆ test_file_1_contents

const char test_file_1_contents[] = "Some generic text in the root file.\r\nMore text on a new line."

Definition at line 18 of file IDataObject.cpp.

Referenced by test_FileContents1(), and test_FileDescriptor().

◆ test_file_2_contents

const char test_file_2_contents[] = "Some generic text in the file in folder_1.\r\nMore text on a new line."

Definition at line 19 of file IDataObject.cpp.

Referenced by test_FileContents2(), and test_FileDescriptor_Folder().