ReactOS 0.4.17-dev-966-gf06eace
mciwnd.c File Reference
#include <windows.h>
#include <vfw.h>
#include "wine/test.h"
Include dependency graph for mciwnd.c:

Go to the source code of this file.

Macros

#define WIN32_LEAN_AND_MEAN
 

Functions

static BOOL create_avi_file (char *fname)
 
static LRESULT WINAPI proxy_MCIWndProc (HWND hWnd, UINT wMsg, WPARAM wParam, LPARAM lParam)
 
static LRESULT CALLBACK hook_proc (int code, WPARAM wp, LPARAM lp)
 
static void test_window_create (unsigned line, const char *fname, HWND parent, BOOL with_mci, BOOL call_ansi, unsigned match)
 
static void test_MCIWndCreate (void)
 
 START_TEST (mciwnd)
 

Variables

static const DWORD file_header []
 
static const MainAVIHeader main_avi_header
 
static const DWORD stream_list []
 
static const AVIStreamHeader avi_stream_header
 
static const DWORD video_stream_format []
 
static const DWORD padding []
 
static const DWORD data []
 
struct {
enum  {
  NO_MATCH , PTR_ANSI_MATCH , PTR_UNICODE_MATCH , ANSI_MATCH ,
  UNICODE_MATCH
}
 
   const char *   expectedA
 
   const WCHAR *   expectedW
 
   unsigned   open_msg
 
   enum { ... }    match
 
} wnd_creation
 
static WNDPROC old_MCIWndProc
 

Macro Definition Documentation

◆ WIN32_LEAN_AND_MEAN

#define WIN32_LEAN_AND_MEAN

Definition at line 21 of file mciwnd.c.

Function Documentation

◆ create_avi_file()

static BOOL create_avi_file ( char *  fname)
static

Definition at line 111 of file mciwnd.c.

112{
114 DWORD written;
115 char temp_path[MAX_PATH];
116 BOOL ret;
117 BYTE *buffer;
118 ULONG buffer_length;
119
121 ok(ret, "Failed to get a temp path, err %ld\n", GetLastError());
122 if (!ret)
123 return FALSE;
124
125 ret = GetTempFileNameA(temp_path, "mci", 0, fname);
126 ok(ret, "Failed to get a temp name, err %ld\n", GetLastError());
127 if (!ret)
128 return FALSE;
129 DeleteFileA(fname);
130
131 lstrcatA(fname, ".avi");
132
134 ok(hFile != INVALID_HANDLE_VALUE, "Failed to create a file, err %ld\n", GetLastError());
135 if (hFile == INVALID_HANDLE_VALUE) return FALSE;
136
137 buffer_length = padding[1];
138 buffer = calloc(1, buffer_length);
139
140 WriteFile(hFile, file_header, sizeof(file_header), &written, NULL);
141 WriteFile(hFile, &main_avi_header, sizeof(MainAVIHeader), &written, NULL);
142 WriteFile(hFile, stream_list, sizeof(stream_list), &written, NULL);
145 WriteFile(hFile, padding, sizeof(padding), &written, NULL);
146 WriteFile(hFile, buffer, buffer_length, &written, NULL);
147 WriteFile(hFile, data, sizeof(data), &written, NULL);
148
149 free(buffer);
150
152 return ret;
153}
#define ok(value,...)
Definition: atltest.h:57
#define free
Definition: debug_ros.c:5
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
#define CloseHandle
Definition: compat.h:739
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define CreateFileA(a, b, c, d, e, f, g)
Definition: compat.h:740
#define MAX_PATH
Definition: compat.h:34
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:137
BOOL WINAPI DeleteFileA(IN LPCSTR lpFileName)
Definition: delete.c:24
BOOL WINAPI WriteFile(_In_ HANDLE hFile, _In_reads_bytes_opt_(nNumberOfBytesToWrite) LPCVOID lpBuffer, _In_ DWORD nNumberOfBytesToWrite, _Out_opt_ LPDWORD lpNumberOfBytesWritten, _Inout_opt_ LPOVERLAPPED lpOverlapped)
Definition: rw.c:25
DWORD WINAPI GetTempPathA(IN DWORD nBufferLength, OUT LPSTR lpBuffer)
Definition: path.c:2072
return ret
Definition: mutex.c:147
UINT WINAPI GetTempFileNameA(IN LPCSTR lpPathName, IN LPCSTR lpPrefixString, IN UINT uUnique, OUT LPSTR lpTempFileName)
Definition: filename.c:26
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLuint buffer
Definition: glext.h:5915
LPSTR WINAPI lstrcatA(LPSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:123
#define CREATE_ALWAYS
Definition: disk.h:72
static const DWORD stream_list[]
Definition: mciwnd.c:51
static const DWORD video_stream_format[]
Definition: mciwnd.c:75
static const DWORD padding[]
Definition: mciwnd.c:88
static const AVIStreamHeader avi_stream_header
Definition: mciwnd.c:57
static const MainAVIHeader main_avi_header
Definition: mciwnd.c:36
static const DWORD file_header[]
Definition: mciwnd.c:28
char temp_path[MAX_PATH]
Definition: mspatcha.c:123
_In_ HANDLE hFile
Definition: mswsock.h:90
#define GENERIC_WRITE
Definition: nt_native.h:90
#define calloc
Definition: rosglue.h:14
uint32_t ULONG
Definition: typedefs.h:59
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
unsigned char BYTE
Definition: xxhash.c:193

Referenced by test_MCIWndCreate().

◆ hook_proc()

static LRESULT CALLBACK hook_proc ( int  code,
WPARAM  wp,
LPARAM  lp 
)
static

Definition at line 196 of file mciwnd.c.

197{
198 if (code == HCBT_CREATEWND && lp)
199 {
200 CREATESTRUCTW* cs = ((CBT_CREATEWNDW *)lp)->lpcs;
201 if (cs && ((ULONG_PTR)cs->lpszClass >> 16) && !wcsicmp(cs->lpszClass, L"MCIWndClass"))
202 {
204 ok(old_MCIWndProc != NULL, "No wnd proc\n");
205 }
206 }
207
208 return CallNextHookEx( NULL, code, wp, lp );
209}
#define wcsicmp
Definition: compat.h:15
#define L(x)
Definition: resources.c:13
#define cs
Definition: i386-dis.c:442
LONG_PTR LPARAM
Definition: minwindef.h:175
static WNDPROC old_MCIWndProc
Definition: mciwnd.c:165
static LRESULT WINAPI proxy_MCIWndProc(HWND hWnd, UINT wMsg, WPARAM wParam, LPARAM lParam)
Definition: mciwnd.c:166
#define HCBT_CREATEWND
Definition: winuser.h:58
LRESULT WINAPI CallNextHookEx(_In_opt_ HHOOK, _In_ int, _In_ WPARAM, _In_ LPARAM)
LRESULT(CALLBACK * WNDPROC)(HWND, UINT, WPARAM, LPARAM)
Definition: winuser.h:3014
#define SetWindowLongPtrW
Definition: winuser.h:5512
Definition: inflate.c:139
#define GWLP_WNDPROC
Definition: treelist.c:66
uint32_t ULONG_PTR
Definition: typedefs.h:65

Referenced by test_MCIWndCreate().

◆ proxy_MCIWndProc()

static LRESULT WINAPI proxy_MCIWndProc ( HWND  hWnd,
UINT  wMsg,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 166 of file mciwnd.c.

167{
168 switch (wMsg)
169 {
170 case WM_CREATE:
171 {
173 if (cs->lpCreateParams)
174 {
175 if (cs->lpCreateParams == wnd_creation.expectedA)
176 wnd_creation.match = PTR_ANSI_MATCH;
177 else if (cs->lpCreateParams == wnd_creation.expectedW)
178 wnd_creation.match = PTR_UNICODE_MATCH;
179 else if (!strcmp(cs->lpCreateParams, wnd_creation.expectedA))
180 wnd_creation.match = ANSI_MATCH;
181 else if (!wcscmp(cs->lpCreateParams, wnd_creation.expectedW))
182 wnd_creation.match = UNICODE_MATCH;
183 }
184 }
185 break;
186 case MCIWNDM_OPENA:
187 case MCIWNDM_OPENW:
188 wnd_creation.open_msg = wMsg;
189 break;
190 default:
191 break;
192 }
193 return old_MCIWndProc(hWnd, wMsg, wParam, lParam);
194}
HWND hWnd
Definition: settings.c:17
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
_ACRTIMP int __cdecl wcscmp(const wchar_t *, const wchar_t *)
Definition: wcs.c:1977
_ACRTIMP int __cdecl strcmp(const char *, const char *)
Definition: string.c:3324
if(dx< 0)
Definition: linetemp.h:194
static struct @1952 wnd_creation
#define WM_CREATE
Definition: winuser.h:1636
#define MCIWNDM_OPENW
Definition: vfw.h:1979
#define MCIWNDM_OPENA
Definition: vfw.h:1967

Referenced by hook_proc().

◆ START_TEST()

START_TEST ( mciwnd  )

Definition at line 319 of file mciwnd.c.

320{
322}
static void test_MCIWndCreate(void)
Definition: mciwnd.c:261

◆ test_MCIWndCreate()

static void test_MCIWndCreate ( void  )
static

Definition at line 261 of file mciwnd.c.

262{
265 char fname[MAX_PATH];
266 char invalid_fname[] = "invalid.avi";
267 char error[200];
268 HHOOK hook;
269 LRESULT ret;
270
271 create_avi_file(fname);
272
274
275 test_window_create( __LINE__, fname, NULL, TRUE, TRUE, UNICODE_MATCH );
276 test_window_create( __LINE__, fname, NULL, TRUE, FALSE, PTR_UNICODE_MATCH );
277 test_window_create( __LINE__, fname, NULL, FALSE, TRUE, PTR_ANSI_MATCH );
278 test_window_create( __LINE__, fname, NULL, FALSE, FALSE, PTR_ANSI_MATCH );
279
280 parent = CreateWindowExA(0, "static", "msvfw32 test",
281 WS_POPUP, 0, 0, 100, 100,
282 0, 0, 0, NULL);
283 ok(parent != NULL, "Failed to create a window\n");
284 ok(!IsWindowUnicode(parent), "Expecting ansi parent window\n");
285
286 test_window_create( __LINE__, fname, parent, TRUE, TRUE, UNICODE_MATCH );
287 test_window_create( __LINE__, fname, parent, TRUE, FALSE, PTR_UNICODE_MATCH );
288 test_window_create( __LINE__, fname, parent, FALSE, TRUE, PTR_ANSI_MATCH );
289 test_window_create( __LINE__, fname, parent, FALSE, FALSE, PTR_ANSI_MATCH );
290
292
293 parent = CreateWindowExW(0, L"static", L"msvfw32 test",
294 WS_POPUP, 0, 0, 100, 100,
295 0, 0, 0, NULL);
296 ok(parent != NULL, "Failed to create a window\n");
297 ok(IsWindowUnicode(parent), "Expecting unicode parent window\n");
298
299 test_window_create( __LINE__, fname, parent, TRUE, TRUE, UNICODE_MATCH );
300 test_window_create( __LINE__, fname, parent, TRUE, FALSE, PTR_UNICODE_MATCH );
301 test_window_create( __LINE__, fname, parent, FALSE, TRUE, PTR_UNICODE_MATCH );
302 test_window_create( __LINE__, fname, parent, FALSE, FALSE, PTR_UNICODE_MATCH );
303
305
307
309 ok(window != NULL, "Failed to create an MCIWnd window\n");
310
312 todo_wine ok(ret == MCIERR_FILE_NOT_FOUND, "Unexpected error %Id\n", ret);
313
315
316 DeleteFileA(fname);
317}
@ hook
Definition: SystemMenu.c:35
#define TRUE
Definition: types.h:120
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:812
HWND VFWAPIV MCIWndCreateA(HWND hwndParent, HINSTANCE hInstance, DWORD dwStyle, LPCSTR szFile)
Definition: mciwnd.c:128
r parent
Definition: btrfs.c:3010
#define todo_wine
Definition: minitest.h:80
LONG_PTR LRESULT
Definition: minwindef.h:176
#define error(str)
Definition: mkdosfs.c:1605
#define MCIERR_FILE_NOT_FOUND
Definition: mmsystem.h:585
static HINSTANCE hinst
Definition: edit.c:551
static IHTMLWindow2 * window
Definition: events.c:77
static LRESULT CALLBACK hook_proc(int code, WPARAM wp, LPARAM lp)
Definition: mciwnd.c:196
static BOOL create_avi_file(char *fname)
Definition: mciwnd.c:111
static void test_window_create(unsigned line, const char *fname, HWND parent, BOOL with_mci, BOOL call_ansi, unsigned match)
Definition: mciwnd.c:211
#define WS_POPUP
Definition: pedump.c:616
HWND WINAPI CreateWindowExA(_In_ DWORD dwExStyle, _In_opt_ LPCSTR lpClassName, _In_opt_ LPCSTR lpWindowName, _In_ DWORD dwStyle, _In_ int X, _In_ int Y, _In_ int nWidth, _In_ int nHeight, _In_opt_ HWND hWndParent, _In_opt_ HMENU hMenu, _In_opt_ HINSTANCE hInstance, _In_opt_ LPVOID lpParam)
HHOOK WINAPI SetWindowsHookExW(_In_ int, _In_ HOOKPROC, _In_opt_ HINSTANCE, _In_ DWORD)
LRESULT WINAPI SendMessageA(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define WH_CBT
Definition: winuser.h:35
BOOL WINAPI IsWindowUnicode(_In_ HWND)
BOOL WINAPI UnhookWindowsHookEx(_In_ HHOOK)
HWND WINAPI CreateWindowExW(_In_ DWORD dwExStyle, _In_opt_ LPCWSTR lpClassName, _In_opt_ LPCWSTR lpWindowName, _In_ DWORD dwStyle, _In_ int X, _In_ int Y, _In_ int nWidth, _In_ int nHeight, _In_opt_ HWND hWndParent, _In_opt_ HMENU hMenu, _In_opt_ HINSTANCE hInstance, _In_opt_ LPVOID lpParam)
BOOL WINAPI DestroyWindow(_In_ HWND)
#define MCIWNDM_GETERRORA
Definition: vfw.h:1964
#define MCIWNDF_NOERRORDLG
Definition: vfw.h:1807
DWORD WINAPI GetCurrentThreadId(void)
Definition: thread.c:459

Referenced by START_TEST().

◆ test_window_create()

static void test_window_create ( unsigned  line,
const char *  fname,
HWND  parent,
BOOL  with_mci,
BOOL  call_ansi,
unsigned  match 
)
static

Definition at line 211 of file mciwnd.c.

213{
215 WCHAR fnameW[MAX_PATH];
216 HWND window;
217 char error[200];
218 LRESULT ret;
219 BOOL expect_ansi = match == PTR_ANSI_MATCH || match == ANSI_MATCH;
220
221 MultiByteToWideChar(CP_ACP, 0, fname, -1, fnameW, ARRAY_SIZE(fnameW));
222
223 wnd_creation.expectedA = fname;
224 wnd_creation.expectedW = fnameW;
225 wnd_creation.open_msg = 0;
226 wnd_creation.match = NO_MATCH;
227
228 if (call_ansi)
229 {
230 if (with_mci)
232 else
233 window = CreateWindowExA(0, "MCIWndClass", NULL,
235 0, 0, 300, 0,
236 parent, 0, hinst, expect_ansi ? (LPVOID)fname : (LPVOID)fnameW);
237 }
238 else
239 {
240 if (with_mci)
242 else
243 window = CreateWindowExW(0, L"MCIWndClass", NULL,
245 0, 0, 300, 0,
246 parent, 0, hinst, expect_ansi ? (LPVOID)fname : (LPVOID)fnameW);
247 }
248 ok_(__FILE__, line)(window != NULL, "Failed to create an MCIWnd window\n");
249 ok_(__FILE__, line)(wnd_creation.match == match, "unexpected match %u\n", wnd_creation.match);
250 ok_(__FILE__, line)((expect_ansi && wnd_creation.open_msg == MCIWNDM_OPENA) ||
251 (!expect_ansi && wnd_creation.open_msg == MCIWNDM_OPENW),
252 "bad open message %u %s%u\n", match,
253 wnd_creation.open_msg >= WM_USER ? "WM_USER+" : "",
254 wnd_creation.open_msg >= WM_USER ? wnd_creation.open_msg - WM_USER : wnd_creation.open_msg);
256 ok_(__FILE__, line)(!ret || broken(ret == ERROR_INVALID_HANDLE) /* w2003std, w2008s64 */,
257 "Unexpected error %Id\n", ret);
259}
#define broken(x)
Definition: atltest.h:178
#define ok_(x1, x2)
Definition: atltest.h:61
#define ARRAY_SIZE(A)
Definition: main.h:20
#define CP_ACP
Definition: compat.h:109
#define ERROR_INVALID_HANDLE
Definition: compat.h:98
#define MultiByteToWideChar
Definition: compat.h:110
HWND VFWAPIV MCIWndCreateW(HWND hwndParent, HINSTANCE hInstance, DWORD dwStyle, LPCWSTR szFile)
Definition: mciwnd.c:104
enum @1952::@1953 match
short WCHAR
Definition: pedump.c:58
#define WS_CLIPSIBLINGS
Definition: pedump.c:618
#define WS_CLIPCHILDREN
Definition: pedump.c:619
#define WM_USER
Definition: winuser.h:1923
Definition: parser.c:49
Definition: match.c:28

Referenced by test_MCIWndCreate().

Variable Documentation

◆ avi_stream_header

const AVIStreamHeader avi_stream_header
static
Initial value:
=
{
0,
0,
0,
0,
0,
1,
0xf,
0,
2,
0x48,
0,
0,
{ 0, 0, 0, 0 }
}
#define streamtypeVIDEO
Definition: aviriff.h:92

Definition at line 57 of file mciwnd.c.

Referenced by create_avi_file().

◆ data

const DWORD data[]
static
Initial value:
=
{
mmioFOURCC('0', '0', 'd', 'b'), 0x48, 0x48000000, 0x08000800,
0x00100100, 0x00003e00, 0x08000000, 0x00200800,
0x00001600, 0x00000000, 0x00003a00, 0x22e306f9,
0xfc120000, 0x0a000022, 0x00000000, 0x00300000,
0x00c01200, 0x00000000, 0x02010000, 0x00000000,
mmioFOURCC('0', '0', 'd', 'b'), 0x48, 0x48000000, 0x08000800,
0x00100100, 0x00003e00, 0x08000000, 0x00200800,
0x00001600, 0x00000000, 0x00003a00, 0x22e306f9,
0xfc120000, 0x0a000022, 0x00000000, 0x00300000,
0x00c01200, 0x00000000, 0x02010000, 0x00000000,
mmioFOURCC('i', 'd', 'x', '1'), 0x20, mmioFOURCC('0', '0', 'd', 'b'), 0x10,
0x04, 0x48, mmioFOURCC('0', '0', 'd', 'b'), 0x10,
0x54, 0x48,
}
#define FOURCC_LIST
Definition: mmsystem.h:565
#define mmioFOURCC(c0, c1, c2, c3)
Definition: mmsystem.h:38
#define listtypeAVIMOVIE
Definition: vfw.h:898

Definition at line 93 of file mciwnd.c.

◆ expectedA

const char* expectedA

Definition at line 158 of file mciwnd.c.

Referenced by test_DoEnvironmentSubst(), and test_mxwriter_encoding().

◆ expectedW

◆ file_header

const DWORD file_header[]
static
Initial value:
=
{
FOURCC_RIFF, 0x8c0 ,
FOURCC_LIST, 0xc0 ,
}
#define FOURCC_RIFF
Definition: mmsystem.h:564
struct _MainAVIHeader MainAVIHeader
#define listtypeAVIHEADER
Definition: vfw.h:890
#define ckidAVIMAINHDR
Definition: vfw.h:891
#define formtypeAVI
Definition: vfw.h:889

Definition at line 28 of file mciwnd.c.

Referenced by create_avi_file(), and create_bitmap().

◆ main_avi_header

const MainAVIHeader main_avi_header
static
Initial value:
=
{
0x0001046b,
0x00000000,
0x00000000,
0x00000810,
2,
0,
1,
0x48,
5,
5,
{ 0, 0, 0, 0 }
}

Definition at line 36 of file mciwnd.c.

Referenced by create_avi_file().

◆ 

enum { ... } match

Referenced by test_window_create().

◆ old_MCIWndProc

WNDPROC old_MCIWndProc
static

Definition at line 165 of file mciwnd.c.

Referenced by hook_proc(), and proxy_MCIWndProc().

◆ open_msg

unsigned open_msg

Definition at line 161 of file mciwnd.c.

◆ padding

◆ stream_list

const DWORD stream_list[]
static
Initial value:
=
{
FOURCC_LIST, 0x74 ,
}
#define ckidSTREAMHEADER
Definition: aviriff.h:88
#define listtypeSTREAMHEADER
Definition: vfw.h:892

Definition at line 51 of file mciwnd.c.

Referenced by create_avi_file().

◆ video_stream_format

const DWORD video_stream_format[]
static
Initial value:
=
{
0x28 ,
0x28 ,
5 ,
5 ,
0x00180001 ,
mmioFOURCC('c', 'v', 'i', 'd'),
0x245a,
0, 0, 0, 0,
}
#define ckidSTREAMFORMAT
Definition: aviriff.h:125

Definition at line 75 of file mciwnd.c.

Referenced by create_avi_file().

◆ 

struct { ... } wnd_creation