ReactOS 0.4.15-dev-7918-g2a2556c
mainwnd.c File Reference
#include <precomp.h>
#include <io.h>
Include dependency graph for mainwnd.c:

Go to the source code of this file.

Macros

#define BUFSIZE   4096
 

Typedefs

typedef int(_cdecl * RUNTEST) (char **)
 

Functions

DWORD WINAPI PipeReadThread (LPVOID lpParam)
 
DWORD WINAPI CreateClientProcess (PMAIN_WND_INFO pInfo)
 
static BOOL OnInitMainDialog (HWND hDlg, LPARAM lParam)
 
static VOID RunSelectedTest (PMAIN_WND_INFO pInfo)
 
static VOID AddTestToCombo (PMAIN_WND_INFO pInfo)
 
static VOID FreeTestCmdStrings (PMAIN_WND_INFO pInfo)
 
static BOOL CALLBACK MainDlgProc (HWND hDlg, UINT Message, WPARAM wParam, LPARAM lParam)
 
INT WINAPI wWinMain (HINSTANCE hInst, HINSTANCE hPrev, LPWSTR Cmd, int iCmd)
 

Variables

HINSTANCE hInstance
 
WCHAR szPipeName [] = L"\\\\.\\pipe\\winetest_pipe"
 

Macro Definition Documentation

◆ BUFSIZE

#define BUFSIZE   4096

Definition at line 13 of file mainwnd.c.

Typedef Documentation

◆ RUNTEST

typedef int(_cdecl * RUNTEST) (char **)

Definition at line 19 of file mainwnd.c.

Function Documentation

◆ AddTestToCombo()

static VOID AddTestToCombo ( PMAIN_WND_INFO  pInfo)
static

Definition at line 231 of file mainwnd.c.

232{
233 HWND hRunCmd;
234 LPWSTR lpExePath;
235 INT len;
236
237 hRunCmd = GetDlgItem(pInfo->hMainWnd, IDC_TESTSELECTION);
238 if (hRunCmd)
239 {
240 SendMessageW(hRunCmd,
242 0,
243 (LPARAM)pInfo->SelectedTest.szName);
244
245 len = (wcslen(pInfo->SelectedTest.szRunCmd) + 1) * sizeof(WCHAR);
246 lpExePath = HeapAlloc(GetProcessHeap(), 0, len);
247 if (lpExePath)
248 {
249 wcsncpy(lpExePath,
250 pInfo->SelectedTest.szRunCmd,
251 len / sizeof(WCHAR));
252 }
253
254 SendMessageW(hRunCmd,
256 0,
257 (LPARAM)lpExePath);
258 SendMessageW(hRunCmd,
260 0,
261 0);
262 }
263}
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
GLenum GLsizei len
Definition: glext.h:6722
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define IDC_TESTSELECTION
Definition: resource.h:12
_CRTIMP wchar_t *__cdecl wcsncpy(wchar_t *_Dest, const wchar_t *_Source, size_t _Count)
HWND hMainWnd
Definition: precomp.h:51
TEST_ITEM SelectedTest
Definition: precomp.h:40
WCHAR szRunCmd[MAX_RUN_CMD]
Definition: precomp.h:18
WCHAR szName[MAX_NAME]
Definition: precomp.h:17
int32_t INT
Definition: typedefs.h:58
LONG_PTR LPARAM
Definition: windef.h:208
#define CB_SETITEMDATA
Definition: winuser.h:1966
#define CB_SETCURSEL
Definition: winuser.h:1961
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define CB_INSERTSTRING
Definition: winuser.h:1957
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by MainDlgProc().

◆ CreateClientProcess()

DWORD WINAPI CreateClientProcess ( PMAIN_WND_INFO  pInfo)

Definition at line 67 of file mainwnd.c.

68{
70 STARTUPINFO si;
73
74 //
75 // Set up the security attributes
76 //
77 sa.nLength= sizeof(SECURITY_ATTRIBUTES);
78 sa.lpSecurityDescriptor = NULL;
79 sa.bInheritHandle = TRUE;
80
81 //
82 // Create a pipe for the child process's STDOUT
83 //
84 if (!CreatePipe(&pInfo->hStdOutRd,
85 &pInfo->hStdOutWr,
86 &sa,
87 0))
88 {
89 return FALSE;
90 }
91
92 //
93 // Ensure the read handle to the pipe for STDOUT is not inherited
94 //
97 0))
98 {
99 return FALSE;
100 }
101
102 ZeroMemory(&si, sizeof(STARTUPINFO));
103 si.cb = sizeof(STARTUPINFO);
104 si.hStdError = pInfo->hStdOutWr;
105 si.hStdOutput = pInfo->hStdOutWr;
108
110
112 NULL,
113 NULL,
114 NULL,
115 TRUE,
116 0,//CREATE_SUSPENDED,
117 NULL,
118 NULL,
119 &si,
120 &pi);
121 if (bSuccess)
122 {
123 //
124 // Create thread to handle pipe input from child processes
125 //
127 0,
129 pInfo,
130 0,
131 NULL);
132
134
135 CloseHandle(pi.hProcess);
136 CloseHandle(pi.hThread);
137 }
138
139 return bSuccess;
140}
static struct sockaddr_in sa
Definition: adnsresfilter.c:69
HANDLE WINAPI GetStdHandle(IN DWORD nStdHandle)
Definition: console.c:203
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define CloseHandle
Definition: compat.h:739
struct _SECURITY_ATTRIBUTES SECURITY_ATTRIBUTES
BOOL WINAPI SetHandleInformation(IN HANDLE hObject, IN DWORD dwMask, IN DWORD dwFlags)
Definition: handle.c:78
BOOL WINAPI DECLSPEC_HOTPATCH CreateProcessW(LPCWSTR lpApplicationName, LPWSTR lpCommandLine, LPSECURITY_ATTRIBUTES lpProcessAttributes, LPSECURITY_ATTRIBUTES lpThreadAttributes, BOOL bInheritHandles, DWORD dwCreationFlags, LPVOID lpEnvironment, LPCWSTR lpCurrentDirectory, LPSTARTUPINFOW lpStartupInfo, LPPROCESS_INFORMATION lpProcessInformation)
Definition: proc.c:4592
HANDLE WINAPI DECLSPEC_HOTPATCH CreateThread(IN LPSECURITY_ATTRIBUTES lpThreadAttributes, IN DWORD dwStackSize, IN LPTHREAD_START_ROUTINE lpStartAddress, IN LPVOID lpParameter, IN DWORD dwCreationFlags, OUT LPDWORD lpThreadId)
Definition: thread.c:137
static BOOLEAN bSuccess
Definition: drive.cpp:433
#define INFINITE
Definition: serial.h:102
unsigned int BOOL
Definition: ntddk_ex.h:94
DWORD WINAPI PipeReadThread(LPVOID lpParam)
Definition: mainwnd.c:22
static refpint_t pi[]
Definition: server.c:96
BOOL WINAPI CreatePipe(PHANDLE hReadPipe, PHANDLE hWritePipe, LPSECURITY_ATTRIBUTES lpPipeAttributes, DWORD nSize)
Definition: npipe.c:117
HANDLE hStdOutRd
Definition: precomp.h:29
HANDLE hStdOutWr
Definition: precomp.h:30
HANDLE hPipeThread
Definition: precomp.h:28
LPWSTR lpCmdLine
Definition: precomp.h:31
HANDLE hStdOutput
Definition: winbase.h:847
HANDLE hStdError
Definition: winbase.h:848
DWORD dwFlags
Definition: winbase.h:842
DWORD cb
Definition: winbase.h:831
HANDLE hStdInput
Definition: winbase.h:846
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
#define ZeroMemory
Definition: winbase.h:1712
#define STD_INPUT_HANDLE
Definition: winbase.h:267
STARTUPINFOA STARTUPINFO
Definition: winbase.h:3719
#define HANDLE_FLAG_INHERIT
Definition: winbase.h:264
#define STARTF_USESTDHANDLES
Definition: winbase.h:499

Referenced by RunSelectedTest().

◆ FreeTestCmdStrings()

static VOID FreeTestCmdStrings ( PMAIN_WND_INFO  pInfo)
static

Definition at line 266 of file mainwnd.c.

267{
268 HWND hRunCmd;
269 LPWSTR lpExePath;
270 INT cnt, i;
271
272 hRunCmd = GetDlgItem(pInfo->hMainWnd, IDC_TESTSELECTION);
273
274 cnt = SendMessageW(hRunCmd,
276 0,
277 0);
278 if (cnt != CB_ERR)
279 {
280 for (i = 0; i < cnt; i++)
281 {
282 lpExePath = (LPWSTR)SendMessage(hRunCmd,
284 i,
285 0);
286 if (lpExePath)
287 {
288 HeapFree(GetProcessHeap(), 0, lpExePath);
289 }
290 }
291 }
292}
#define HeapFree(x, y, z)
Definition: compat.h:735
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define CB_ERR
Definition: winuser.h:2435
#define CB_GETCOUNT
Definition: winuser.h:1942
#define CB_GETITEMDATA
Definition: winuser.h:1950
#define SendMessage
Definition: winuser.h:5843

Referenced by MainDlgProc().

◆ MainDlgProc()

static BOOL CALLBACK MainDlgProc ( HWND  hDlg,
UINT  Message,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 295 of file mainwnd.c.

299{
300 PMAIN_WND_INFO pInfo;
301
302 /* Get the window context */
303 pInfo = (PMAIN_WND_INFO)GetWindowLongPtr(hDlg,
305 if (pInfo == NULL && Message != WM_INITDIALOG)
306 {
307 goto HandleDefaultMessage;
308 }
309
310 switch(Message)
311 {
312 case WM_INITDIALOG:
313 return OnInitMainDialog(hDlg, lParam);
314
315 case WM_COMMAND:
316 {
317 switch(LOWORD(wParam))
318 {
319 case IDC_BROWSE:
320 {
321 INT_PTR ret;
322
325 hDlg,
327 (LPARAM)pInfo);
328 if (ret == IDOK)
329 {
330 AddTestToCombo(pInfo);
331 }
332
333 break;
334 }
335 case IDC_OPTIONS:
338 hDlg,
340 (LPARAM)pInfo);
341 break;
342
343 case IDC_RUN:
344 RunSelectedTest(pInfo);
345 break;
346
347 case IDOK:
348 EndDialog(hDlg, 0);
349 break;
350 }
351 }
352 break;
353
354 case WM_CLOSE:
355 EndDialog(hDlg, 0);
356 break;
357
358 case WM_DESTROY:
359 if (pInfo->hSmIcon)
360 DestroyIcon(pInfo->hSmIcon);
361 if (pInfo->hBgIcon)
362 DestroyIcon(pInfo->hBgIcon);
363
364 FreeTestCmdStrings(pInfo);
365
366 break;
367
368HandleDefaultMessage:
369 default:
370 return FALSE;
371 }
372
373 return FALSE;
374}
#define IDC_OPTIONS
#define IDD_OPTIONS
Definition: resource.h:19
struct _MAIN_WND_INFO * PMAIN_WND_INFO
#define IDC_RUN
Definition: resource.h:21
#define IDC_BROWSE
Definition: resource.h:21
BOOL CALLBACK BrowseDlgProc(HWND hDlg, UINT Message, WPARAM wParam, LPARAM lParam)
Definition: browsewnd.c:332
HINSTANCE hInstance
Definition: charmap.c:19
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
#define DLGPROC
Definition: maze.c:62
static const WCHAR Message[]
Definition: register.c:74
static BOOL OnInitMainDialog(HWND hDlg, LPARAM lParam)
Definition: mainwnd.c:144
static VOID AddTestToCombo(PMAIN_WND_INFO pInfo)
Definition: mainwnd.c:231
static VOID RunSelectedTest(PMAIN_WND_INFO pInfo)
Definition: mainwnd.c:190
static VOID FreeTestCmdStrings(PMAIN_WND_INFO pInfo)
Definition: mainwnd.c:266
#define IDD_TESTBROWSER
Definition: resource.h:2
#define LOWORD(l)
Definition: pedump.c:82
INT_PTR CALLBACK OptionsDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: solitaire.cpp:289
HICON hBgIcon
Definition: precomp.h:35
HICON hSmIcon
Definition: precomp.h:34
#define GetWindowLongPtr
Definition: treelist.c:73
#define GWLP_USERDATA
Definition: treelist.c:63
int32_t INT_PTR
Definition: typedefs.h:64
int ret
#define WM_CLOSE
Definition: winuser.h:1621
#define WM_COMMAND
Definition: winuser.h:1740
#define WM_INITDIALOG
Definition: winuser.h:1739
#define IDOK
Definition: winuser.h:830
#define WM_DESTROY
Definition: winuser.h:1609
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
INT_PTR WINAPI DialogBoxParamW(_In_opt_ HINSTANCE, _In_ LPCWSTR, _In_opt_ HWND, _In_opt_ DLGPROC, _In_ LPARAM)
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)
BOOL WINAPI DestroyIcon(_In_ HICON)
Definition: cursoricon.c:2053

Referenced by wWinMain().

◆ OnInitMainDialog()

static BOOL OnInitMainDialog ( HWND  hDlg,
LPARAM  lParam 
)
static

Definition at line 144 of file mainwnd.c.

146{
147 PMAIN_WND_INFO pInfo;
148
149 pInfo = (PMAIN_WND_INFO)lParam;
150
151 /* Initialize the main window context */
152 pInfo->hMainWnd = hDlg;
153
154 SetWindowLongPtr(hDlg,
156 (LONG_PTR)pInfo);
157
161 16,
162 16,
163 0);
164 if (pInfo->hSmIcon)
165 {
166 SendMessageW(hDlg,
167 WM_SETICON,
169 (LPARAM)pInfo->hSmIcon);
170 }
171
175 32,
176 32,
177 0);
178 if (pInfo->hBgIcon)
179 {
180 SendMessageW(hDlg,
181 WM_SETICON,
182 ICON_BIG,
183 (LPARAM)pInfo->hBgIcon);
184 }
185
186 return TRUE;
187}
#define IDI_ICON
Definition: resource.h:5
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
#define ICON_BIG
Definition: tnclass.cpp:51
#define ICON_SMALL
Definition: tnclass.cpp:48
#define SetWindowLongPtr
Definition: treelist.c:70
#define IMAGE_ICON
Definition: winuser.h:212
HANDLE WINAPI LoadImageW(_In_opt_ HINSTANCE hInst, _In_ LPCWSTR name, _In_ UINT type, _In_ int cx, _In_ int cy, _In_ UINT fuLoad)
Definition: cursoricon.c:2203

Referenced by MainDlgProc().

◆ PipeReadThread()

DWORD WINAPI PipeReadThread ( LPVOID  lpParam)

Definition at line 22 of file mainwnd.c.

23{
24 PMAIN_WND_INFO pInfo;
26 DWORD dwRead;
27 CHAR chBuf[BUFSIZE];
30 INT count;
31
32 pInfo = (PMAIN_WND_INFO)lpParam;
33
36
37 ZeroMemory(&item, sizeof(LVITEMA));
38 item.mask = LVIF_TEXT;
39
40 while (TRUE)
41 {
42 dwRead = 0;
44 chBuf,
45 BUFSIZE,
46 &dwRead,
47 NULL);
48 if(!bSuccess || dwRead == 0)
49 break;
50
51 chBuf[dwRead] = 0;
52
56
57 //item.iItem = ListView_GetItemCount(hList);
58 //item.pszText = chBuf;
59 //SendMessage(hEdit, LVM_INSERTITEMA, 0, (LPARAM)&item);
60 }
61
62 return 0;
63}
#define ReadFile(a, b, c, d, e)
Definition: compat.h:742
unsigned long DWORD
Definition: ntddk_ex.h:95
GLuint GLuint GLsizei count
Definition: gl.h:1545
HWND hList
Definition: livecd.c:10
#define IDC_LIST
Definition: resource.h:93
#define BUFSIZE
Definition: mainwnd.c:13
#define IDC_OUTPUT
Definition: resource.h:11
static ATOM item
Definition: dde.c:856
#define LVIF_TEXT
Definition: commctrl.h:2309
static HWND hEdit
Definition: autocomplete.c:34
UINT_PTR WPARAM
Definition: windef.h:207
#define EM_REPLACESEL
Definition: winuser.h:2006
int WINAPI GetWindowTextLengthA(_In_ HWND)
LRESULT WINAPI SendMessageA(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define EM_SETSEL
Definition: winuser.h:2018
char CHAR
Definition: xmlstorage.h:175

Referenced by CreateClientProcess().

◆ RunSelectedTest()

static VOID RunSelectedTest ( PMAIN_WND_INFO  pInfo)
static

Definition at line 190 of file mainwnd.c.

191{
192 HWND hRunCmd;
193 WCHAR szTextCmd[MAX_RUN_CMD];
194 INT sel;
195
196 hRunCmd = GetDlgItem(pInfo->hMainWnd, IDC_TESTSELECTION);
197
198 sel = SendMessageW(hRunCmd,
200 0,
201 0);
202 if (sel != CB_ERR)
203 {
204 if (SendMessageW(hRunCmd,
206 sel,
207 (LPARAM)szTextCmd) != CB_ERR)
208 {
209 pInfo->lpCmdLine = (LPWSTR)SendMessage(hRunCmd,
211 0,
212 0);
213 if (pInfo->lpCmdLine)
214 {
215 //
216 // Create a new thread to create the client process
217 // and receive any ouput via stdout
218 //
220 0,
222 pInfo,
223 0,
224 NULL);
225 }
226 }
227 }
228}
DWORD WINAPI CreateClientProcess(PMAIN_WND_INFO pInfo)
Definition: mainwnd.c:67
#define MAX_RUN_CMD
Definition: precomp.h:13
#define CB_GETLBTEXT
Definition: winuser.h:1952
#define CB_GETCURSEL
Definition: winuser.h:1943

Referenced by MainDlgProc().

◆ wWinMain()

INT WINAPI wWinMain ( HINSTANCE  hInstance,
HINSTANCE  hPrevInstance,
LPWSTR  lpCmdLine,
int  nShowCmd 
)

This file has no copyright assigned and is placed in the Public Domain. This file is part of the w64 mingw-runtime package. No warranty is given; refer to the file DISCLAIMER.PD within this package.

Definition at line 378 of file mainwnd.c.

382{
384 PMAIN_WND_INFO pInfo;
385 INT Ret = -1;
386
390
392
393 ZeroMemory(&iccx, sizeof(INITCOMMONCONTROLSEX));
394 iccx.dwSize = sizeof(INITCOMMONCONTROLSEX);
395 iccx.dwICC = ICC_TAB_CLASSES;
397
398 pInfo = HeapAlloc(GetProcessHeap(),
399 0,
400 sizeof(MAIN_WND_INFO));
401 if (pInfo)
402 {
405 NULL,
407 (LPARAM)pInfo) == IDOK);
408
410 0,
411 pInfo);
412 }
413
414 return Ret;
415}
BOOL WINAPI InitCommonControlsEx(const INITCOMMONCONTROLSEX *lpInitCtrls)
Definition: commctrl.c:893
HINSTANCE hInst
Definition: dxdiag.c:13
static BOOL CALLBACK MainDlgProc(HWND hDlg, UINT Message, WPARAM wParam, LPARAM lParam)
Definition: mainwnd.c:295
#define IDD_WINETESTGUI
Definition: resource.h:1
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
struct tagINITCOMMONCONTROLSEX INITCOMMONCONTROLSEX
#define ICC_TAB_CLASSES
Definition: commctrl.h:61
@ Cmd
Definition: sacdrv.h:278

Referenced by wmain().

Variable Documentation

◆ hInstance

HINSTANCE hInstance

Definition at line 15 of file mainwnd.c.

◆ szPipeName

WCHAR szPipeName[] = L"\\\\.\\pipe\\winetest_pipe"

Definition at line 17 of file mainwnd.c.