-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 Am 2015-10-04 um 19:52 schrieb Andrew D'Addesio:
+ /* Write ddHwDesc */ + desc_ptr = (BYTE*)&fdr->ddHwDesc; + memcpy(desc_ptr, &desc1, desc_size); + ((D3DDEVICEDESC*)desc_ptr)->dwSize = desc_size; + + /* Write ddSwDesc */ + desc_ptr += desc_size; + memcpy(desc_ptr, &desc1, desc_size); + ((D3DDEVICEDESC*)desc_ptr)->dwSize = desc_size; Is there a nicer way? I can't think of one to be honest, but this code feels somewhat unsatisfying.
Also I guess we're lucky that all versions of D3DDEVICEDESC have a DWORD-aligned size, so we don't have to worry about padding between them. Native ddraw doesn't support d3d in 64 bit. Ours does though, mostly out of laziness. Did you run the test in a 64 bit build? It might fail due to different struct alignment.
+ /* Invalid D3DDEVICEDESC sizes should fail */ + search.dwSize = sizeof(search); + search.dwFlags = 0; + clear_device_result(&result, (D3D1_DESC_SIZE-4), (D3D1_DESC_SIZE-4)); hr = IDirect3D_FindDevice(Direct3D1, &search, &result); - ok(hr == D3D_OK, - "Expected IDirect3D1::FindDevice to return D3D_OK, got 0x%08x\n", hr); + ok(hr == DDERR_INVALIDPARAMS, + "Expected IDirect3D1::FindDevice to return DDERR_INVALIDPARAMS, got 0x%08x\n", hr); What happens when you use something between D3D1_DESC_SIZE and D3D2_DESC_SIZE, or e.g. the largest size + 4?
I recommend to put the valid and invalid tests in a table together with an expect HRESULT. That way you don't have to duplicate the structure assignment code + FindDevice call and can just iterate over the table. -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAEBCAAGBQJWEiUOAAoJEN0/YqbEcdMwTCgP/AqlzZ9yyJktv2U+OTgxVGTU 9tj/ZbsKIVk7S0FQFDvyUaKCmP7CcYH+ARoJapn7it6peMdNKHB7zbAgsR7koWph hKECmx+xJ4w4Fjvkj159XYL28DokEHqDmZeaeghwldPbCcXTMO5BulJrooO5F1MI Q2/lwhr+pOO3EDOlLvvLntrOszuYJdy0CbWB34ORlV0PQfk/7Wwm+9rkDzVTDS4r xnpNAzEPaFHNrlhmXlaoFa6arsKTILcwhpmt6wzXTMhcyGs8NRcHA1F5lgIbnH3X m6q84FI5Law/epfKwJSyXTI1eDdWB0PKGqw+xEUv4T79q8oRVRe+W/Sjvq9bluEa fDYshHOP2uVRQ0kcObqSTx9iOWW9RtCdTdHxhloHDOOPIAJyxyoENOkYV/5V+QBT P3pKUG9qjNFODFxQvHb6rvbUisVUXGPihC1fbdAkoNYD4Mf2V5rZ+K88RgXQmofS +zbxziLAr6ItmeCw4/nAvt3/8HoQAtWkF7Bb6ZxhtViOzRraNkLvjqPtJ1HAmz8F TueLADA2bRXpGmkW+9bjLbQ0Z6aK2fqQHYy4Rmkt1LJwGSqrMz5ctq63XChZgA+G +c2OXfvcC+zJsVfLxFHmPjPv1eQ0CQ3gyssjRVGPXq9JAQNHqJxm4ldK5e/dJcTS VBxzcIjMMFVLld6a+dS5 =TBrC -----END PGP SIGNATURE-----