Module: wine
Branch: master
Commit: 41da56a05f0c7eb362b0d99041ac23f4d5ed5f91
URL: http://source.winehq.org/git/wine.git/?a=commit;h=41da56a05f0c7eb362b0d9904…
Author: Roy Shea <royshea(a)gmail.com>
Date: Fri Aug 1 17:13:38 2008 -0700
mstask/test: NewWorkItem conformance test.
---
dlls/mstask/tests/Makefile.in | 13 ++++++
dlls/mstask/tests/task_scheduler.c | 82 ++++++++++++++++++++++++++++++++++++
2 files changed, 95 insertions(+), 0 deletions(-)
diff --git a/dlls/mstask/tests/Makefile.in b/dlls/mstask/tests/Makefile.in
new file mode 100644
index 0000000..9a261e7
--- /dev/null
+++ b/dlls/mstask/tests/Makefile.in
@@ -0,0 +1,13 @@
+TOPSRCDIR = @top_srcdir@
+TOPOBJDIR = ../../..
+SRCDIR = @srcdir@
+VPATH = @srcdir@
+TESTDLL = mstask.dll
+IMPORTS = ole32 kernel32
+
+CTESTS = \
+ task_scheduler.c
+
+@MAKE_TEST_RULES@
+
+@DEPENDENCIES@ # everything below this line is overwritten by make depend
diff --git a/dlls/mstask/tests/task_scheduler.c b/dlls/mstask/tests/task_scheduler.c
new file mode 100644
index 0000000..94614dc
--- /dev/null
+++ b/dlls/mstask/tests/task_scheduler.c
@@ -0,0 +1,82 @@
+/*
+ * Test suite for TaskScheduler interface
+ *
+ * Copyright (C) 2008 Google (Roy Shea)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#define COBJMACROS
+
+#include "initguid.h"
+#include "mstask.h"
+#include "wine/test.h"
+
+static ITaskScheduler *test_task_scheduler;
+
+static void test_NewWorkItem(void)
+{
+ HRESULT hres;
+ ITask *task;
+ const WCHAR task_name[] = {'T', 'e', 's', 't', 'i', 'n', 'g', 0};
+ GUID GUID_BAD;
+
+ /* Initialize a GUID that will not be a recognized CLSID or a IID */
+ CoCreateGuid(&GUID_BAD);
+
+ /* Create TaskScheduler */
+ hres = CoCreateInstance(&CLSID_CTaskScheduler, NULL, CLSCTX_INPROC_SERVER,
+ &IID_ITaskScheduler, (void **) &test_task_scheduler);
+ ok(hres == S_OK, "CTaskScheduler CoCreateInstance failed: %08x\n", hres);
+ if (hres != S_OK)
+ {
+ skip("Failed to create task scheduler. Skipping tests.\n");
+ return;
+ }
+
+ /* Test basic task creation */
+ hres = ITaskScheduler_NewWorkItem(test_task_scheduler, task_name,
+ &CLSID_CTask, &IID_ITask, (IUnknown**)&task);
+ todo_wine ok(hres == S_OK, "NewNetworkItem failed: %08x\n", hres);
+ if (hres == S_OK)
+ ITask_Release(task);
+
+ /* Task creation attempt using invalid work item class ID */
+ hres = ITaskScheduler_NewWorkItem(test_task_scheduler, task_name,
+ &GUID_BAD, &IID_ITask, (IUnknown**)&task);
+ todo_wine ok(hres == CLASS_E_CLASSNOTAVAILABLE,
+ "Expected CLASS_E_CLASSNOTAVAILABLE: %08x\n", hres);
+
+ /* Task creation attempt using invalid interface ID */
+ hres = ITaskScheduler_NewWorkItem(test_task_scheduler, task_name,
+ &CLSID_CTask, &GUID_BAD, (IUnknown**)&task);
+ todo_wine ok(hres == E_NOINTERFACE, "Expected E_NOINTERFACE: %08x\n", hres);
+
+ /* Task creation attempt using invalid work item class and interface ID */
+ hres = ITaskScheduler_NewWorkItem(test_task_scheduler, task_name,
+ &GUID_BAD, &GUID_BAD, (IUnknown**)&task);
+ todo_wine ok(hres == CLASS_E_CLASSNOTAVAILABLE,
+ "Expected CLASS_E_CLASSNOTAVAILABLE: %08x\n", hres);
+
+ ITaskScheduler_Release(test_task_scheduler);
+ return;
+}
+
+START_TEST(task_scheduler)
+{
+ CoInitialize(NULL);
+ test_NewWorkItem();
+ CoUninitialize();
+}
Module: wine
Branch: master
Commit: 3f563c3d9bdf8f31615382fff6b9d44c4cb49fdb
URL: http://source.winehq.org/git/wine.git/?a=commit;h=3f563c3d9bdf8f31615382fff…
Author: Juan Lang <juan.lang(a)gmail.com>
Date: Fri Aug 1 10:18:36 2008 -0700
crypt32: Use ReadFile rather than a memory-mapped file to check the type of a file.
---
dlls/crypt32/sip.c | 53 +++++++++++++++++++++++----------------------------
1 files changed, 24 insertions(+), 29 deletions(-)
diff --git a/dlls/crypt32/sip.c b/dlls/crypt32/sip.c
index 171165a..8668f5b 100644
--- a/dlls/crypt32/sip.c
+++ b/dlls/crypt32/sip.c
@@ -1,6 +1,6 @@
/*
* Copyright 2002 Mike McCormack for CodeWeavers
- * Copyright 2005 Juan Lang
+ * Copyright 2005-2008 Juan Lang
* Copyright 2006 Paul Vriens
*
* This library is free software; you can redistribute it and/or
@@ -276,15 +276,15 @@ BOOL WINAPI CryptSIPRetrieveSubjectGuid
(LPCWSTR FileName, HANDLE hFileIn, GUID *pgSubject)
{
HANDLE hFile;
- HANDLE hFilemapped;
- LPVOID pMapped;
BOOL bRet = FALSE;
- DWORD fileSize;
- IMAGE_DOS_HEADER *dos;
+ DWORD count;
+ LARGE_INTEGER zero, oldPos;
/* FIXME, find out if there is a name for this GUID */
static const GUID unknown = { 0xC689AAB8, 0x8E78, 0x11D0, { 0x8C,0x47,0x00,0xC0,0x4F,0xC2,0x95,0xEE }};
static const GUID cabGUID = { 0xc689aaba, 0x8e78, 0x11d0, {0x8c,0x47,0x00,0xc0,0x4f,0xc2,0x95,0xee }};
+ static const WORD dosHdr = IMAGE_DOS_SIGNATURE;
static const BYTE cabHdr[] = { 'M','S','C','F' };
+ BYTE hdr[SIP_MAX_MAGIC_NUMBER];
TRACE("(%s %p %p)\n", wine_dbgstr_w(FileName), hFileIn, pgSubject);
@@ -307,38 +307,33 @@ BOOL WINAPI CryptSIPRetrieveSubjectGuid
if (hFile == INVALID_HANDLE_VALUE) return FALSE;
}
- hFilemapped = CreateFileMappingA(hFile, NULL, PAGE_READONLY, 0, 0, NULL);
- /* Last error is set by CreateFileMapping */
- if (!hFilemapped) goto cleanup3;
+ zero.QuadPart = 0;
+ SetFilePointerEx(hFile, zero, &oldPos, FILE_CURRENT);
+ SetFilePointer(hFile, 0, NULL, FILE_BEGIN);
+ if (!ReadFile(hFile, hdr, sizeof(hdr), &count, NULL))
+ goto cleanup;
- pMapped = MapViewOfFile(hFilemapped, FILE_MAP_READ, 0, 0, 0);
- /* Last error is set by MapViewOfFile */
- if (!pMapped) goto cleanup2;
-
- /* Native checks it right here */
- fileSize = GetFileSize(hFile, NULL);
- if (fileSize < 4)
+ if (count < SIP_MAX_MAGIC_NUMBER)
{
SetLastError(ERROR_INVALID_PARAMETER);
- goto cleanup1;
+ goto cleanup;
}
/* As everything is in place now we start looking at the file header */
- dos = (IMAGE_DOS_HEADER *)pMapped;
- if (dos->e_magic == IMAGE_DOS_SIGNATURE)
+ if (!memcmp(hdr, &dosHdr, sizeof(dosHdr)))
{
*pgSubject = unknown;
SetLastError(S_OK);
bRet = TRUE;
- goto cleanup1;
+ goto cleanup;
}
/* Quick-n-dirty check for a cab file. */
- if (!memcmp(pMapped, cabHdr, sizeof(cabHdr)))
+ if (!memcmp(hdr, cabHdr, sizeof(cabHdr)))
{
*pgSubject = cabGUID;
SetLastError(S_OK);
bRet = TRUE;
- goto cleanup1;
+ goto cleanup;
}
/* FIXME
@@ -352,14 +347,14 @@ BOOL WINAPI CryptSIPRetrieveSubjectGuid
/* Let's set the most common error for now */
SetLastError(TRUST_E_SUBJECT_FORM_UNKNOWN);
- /* The 3 different cleanups are here because we shouldn't overwrite the last error */
-cleanup1:
- UnmapViewOfFile(pMapped);
-cleanup2:
- CloseHandle(hFilemapped);
-cleanup3:
- /* If we didn't open this one we shouldn't close it (hFile is a copy) */
- if (!hFileIn) CloseHandle(hFile);
+cleanup:
+ /* If we didn't open this one we shouldn't close it (hFile is a copy),
+ * but we should reset the file pointer to its original position.
+ */
+ if (!hFileIn)
+ CloseHandle(hFile);
+ else
+ SetFilePointerEx(hFile, oldPos, NULL, FILE_BEGIN);
return bRet;
}