[SHELL32_APITEST] -Add some tests for SHParseDisplayName for CORE-12882.
[reactos.git] / rostests / apitests / apphelp / data.c
index 7e19c51..6752caa 100644 (file)
@@ -65,9 +65,7 @@ static IMAGE_NT_HEADERS32 nt_header =
         0, /* SizeOfUninitializedData */
         0x1000, /* AddressOfEntryPoint */
         0x1000, /* BaseOfCode */
-#ifndef _WIN64
         0, /* BaseOfData */
-#endif
         0x400000, /* ImageBase */
         0x1000, /* SectionAlignment */
         0x200, /* FileAlignment */
@@ -571,6 +569,9 @@ void test_create_file_imp(const char* name, const char* contents, size_t len)
     }
 }
 
+static unsigned char win10Header[8] = {
+    0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+};
 static unsigned char rawData[2356] = {
     0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x73, 0x64, 0x62, 0x66,
     0x02, 0x78, 0x3E, 0x01, 0x00, 0x00, 0x03, 0x78, 0x44, 0x00, 0x00, 0x00,
@@ -771,14 +772,24 @@ static unsigned char rawData[2356] = {
     0x21, 0x00, 0x00, 0x00
 };
 
-void test_create_db_imp(const char* name)
+DWORD test_get_db_size()
+{
+    return sizeof(rawData);
+}
+
+void test_create_db_imp(const char* name, int win10)
 {
     HANDLE file = CreateFileA(name, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
-    ok(file != INVALID_HANDLE_VALUE, "can't create file\n");
-    if(file != INVALID_HANDLE_VALUE)
+    winetest_ok(file != INVALID_HANDLE_VALUE, "can't create file '%s'\n", name);
+    if (file != INVALID_HANDLE_VALUE)
     {
         DWORD size;
         WriteFile(file, rawData, sizeof(rawData), &size, NULL);
+        if (win10)
+        {
+            SetFilePointer(file, 0, NULL, FILE_BEGIN);
+            WriteFile(file, win10Header, sizeof(win10Header), &size, NULL);
+        }
         CloseHandle(file);
     }
 }
@@ -799,3 +810,41 @@ DWORD get_host_winver(void)
     return g_WinVersion;
 }
 
+DWORD get_module_version(HMODULE mod)
+{
+    DWORD dwVersion = 0;
+    HRSRC hResInfo = FindResource(mod, MAKEINTRESOURCE(VS_VERSION_INFO), RT_VERSION);
+    DWORD dwSize = SizeofResource(mod, hResInfo);
+    if (hResInfo && dwSize)
+    {
+        VS_FIXEDFILEINFO *lpFfi;
+        UINT uLen;
+
+        HGLOBAL hResData = LoadResource(mod, hResInfo);
+        LPVOID pRes = LockResource(hResData);
+        HLOCAL pResCopy = LocalAlloc(LMEM_FIXED, dwSize);
+
+        CopyMemory(pResCopy, pRes, dwSize);
+        FreeResource(hResData);
+
+        if (VerQueryValueW(pResCopy, L"\\", (LPVOID*)&lpFfi, &uLen))
+        {
+            dwVersion = (HIWORD(lpFfi->dwProductVersionMS) << 8) | LOWORD(lpFfi->dwProductVersionMS);
+            if (!dwVersion)
+                dwVersion = (HIWORD(lpFfi->dwFileVersionMS) << 8) | LOWORD(lpFfi->dwFileVersionMS);
+        }
+
+        LocalFree(pResCopy);
+    }
+
+    return dwVersion;
+}
+
+void silence_debug_output(void)
+{
+    if (GetEnvironmentVariableA("SHIM_DEBUG_LEVEL", NULL, 0) == ERROR_ENVVAR_NOT_FOUND)
+        SetEnvironmentVariableA("SHIM_DEBUG_LEVEL", "0");
+    if (GetEnvironmentVariableA("SHIMENG_DEBUG_LEVEL", NULL, 0) == ERROR_ENVVAR_NOT_FOUND)
+        SetEnvironmentVariableA("SHIMENG_DEBUG_LEVEL", "0");
+}
+