Move testsets from reactos to rostests (into a "win32" directory for now). 2/2
authorAleksey Bragin <aleksey@reactos.org>
Tue, 6 Mar 2007 11:34:03 +0000 (11:34 +0000)
committerAleksey Bragin <aleksey@reactos.org>
Tue, 6 Mar 2007 11:34:03 +0000 (11:34 +0000)
svn path=/trunk/; revision=26012

38 files changed:
rostests/directory.rbuild
rostests/win32/loadlib/loadlib.c [new file with mode: 0644]
rostests/win32/loadlib/loadlib.h [new file with mode: 0644]
rostests/win32/msvcrt/fileio/_tfileio.c [new file with mode: 0644]
rostests/win32/msvcrt/fileio/fileio.c [new file with mode: 0644]
rostests/win32/msvcrt/fileio/main.c [new file with mode: 0644]
rostests/win32/msvcrt/fileio/main.h [new file with mode: 0644]
rostests/win32/msvcrt/fileio/wfileio.c [new file with mode: 0644]
rostests/win32/rpcrt4/context_handles/client.c [new file with mode: 0644]
rostests/win32/rpcrt4/context_handles/ctx.acf [new file with mode: 0644]
rostests/win32/rpcrt4/context_handles/ctx.h [new file with mode: 0644]
rostests/win32/rpcrt4/context_handles/ctx.idl [new file with mode: 0644]
rostests/win32/rpcrt4/context_handles/ctx_c.c [new file with mode: 0644]
rostests/win32/rpcrt4/context_handles/ctx_s.c [new file with mode: 0644]
rostests/win32/rpcrt4/context_handles/server.c [new file with mode: 0644]
rostests/win32/smss/movefile/movefile.cpp [new file with mode: 0644]
rostests/win32/smss/movefile/movefile.rbuild [new file with mode: 0644]
rostests/win32/smss/movefile/movefile.rc [new file with mode: 0644]
rostests/win32/smss/smss.rbuild [new file with mode: 0644]
rostests/win32/testsets.rbuild [new file with mode: 0644]
rostests/win32/user32/drawcaption/capicon.c [new file with mode: 0644]
rostests/win32/user32/drawcaption/capicon.rc [new file with mode: 0644]
rostests/win32/user32/drawcaption/drawcap.c [new file with mode: 0644]
rostests/win32/user32/drawcaption/drawcap.rc [new file with mode: 0644]
rostests/win32/user32/drawcaption/drawcaption.rbuild [new file with mode: 0644]
rostests/win32/user32/drawcaption/res/icon1big.ico [new file with mode: 0644]
rostests/win32/user32/drawcaption/res/icon1sm.ico [new file with mode: 0644]
rostests/win32/user32/drawcaption/res/icon2big.ico [new file with mode: 0644]
rostests/win32/user32/drawcaption/res/icon2sm.ico [new file with mode: 0644]
rostests/win32/user32/drawcaption/resource.h [new file with mode: 0644]
rostests/win32/user32/kbdlayout/kbdlayout.c [new file with mode: 0644]
rostests/win32/user32/kbdlayout/kbdlayout.dsp [new file with mode: 0644]
rostests/win32/user32/kbdlayout/kbdlayout.rbuild [new file with mode: 0644]
rostests/win32/user32/kbdlayout/kbdlayout.rc [new file with mode: 0644]
rostests/win32/user32/kbdlayout/resource.h [new file with mode: 0644]
rostests/win32/user32/sysicon/sysicon.c [new file with mode: 0644]
rostests/win32/user32/sysicon/sysicon.rbuild [new file with mode: 0644]
rostests/win32/user32/user32.rbuild [new file with mode: 0644]

index 2cf2d77..961c833 100644 (file)
@@ -4,3 +4,6 @@
 <directory name="tests">\r
        <xi:include href="tests/directory.rbuild" />\r
 </directory>\r
+<directory name="win32">\r
+       <xi:include href="win32/testsets.rbuild" />\r
+</directory>\r
diff --git a/rostests/win32/loadlib/loadlib.c b/rostests/win32/loadlib/loadlib.c
new file mode 100644 (file)
index 0000000..1c0bec9
--- /dev/null
@@ -0,0 +1,223 @@
+/*
+ *  ReactOS test program - 
+ *
+ *  loadlib.c
+ *
+ *  Copyright (C) 2002  Robert Dickenson <robd@reactos.org>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program 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 General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <windows.h>
+#include "loadlib.h"
+#include <string.h>
+#include <stdlib.h>
+#include <wchar.h>
+
+#define APP_VERSION 1
+#define MAX_LIBS    25
+
+#ifdef UNICODE
+#define TARGET  "UNICODE"
+BOOL bUseAnsi = FALSE;
+#else
+#define TARGET  "MBCS"
+BOOL bUseAnsi = TRUE;
+#endif
+BOOL verbose_flagged = FALSE;
+BOOL debug_flagged = FALSE;
+BOOL loop_flagged = FALSE;
+BOOL recursive_flagged = FALSE;
+
+HANDLE OutputHandle;
+HANDLE InputHandle;
+
+
+void dprintf(char* fmt, ...)
+{
+   va_list args;
+   char buffer[255];
+
+   va_start(args, fmt);
+   wvsprintfA(buffer, fmt, args);
+   WriteConsoleA(OutputHandle, buffer, lstrlenA(buffer), NULL, NULL);
+   va_end(args);
+}
+
+long getinput(char* buf, int buflen)
+{
+    DWORD result;
+
+    ReadConsoleA(InputHandle, buf, buflen, &result, NULL);
+    return (long)result;
+}
+
+DWORD ReportLastError(void)
+{
+    DWORD dwError = GetLastError();
+    if (dwError != ERROR_SUCCESS) {
+        PSTR msg = NULL;
+        if (FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM,
+            0, dwError, MAKELANGID(LANG_NEUTRAL,SUBLANG_DEFAULT), (PSTR)&msg, 0, NULL)) {
+            if (msg != NULL) {
+                dprintf("ReportLastError() %d - %s\n", dwError, msg);
+            } else {
+                dprintf("ERROR: ReportLastError() %d - returned TRUE but with no msg string!\n", dwError);
+            }
+        } else {
+            dprintf("ReportLastError() %d - unknown error\n", dwError);
+        }
+        if (msg != NULL) {
+            LocalFree(msg);
+        }
+    }
+    return dwError;
+}
+
+const char* appName(const char* argv0)
+{
+    const char* name;
+
+    name = (const char*)strrchr(argv0, '\\');
+    if (name != NULL) 
+        return name + 1;
+    return argv0;
+}
+
+int usage(const char* appName)
+{
+    dprintf("USAGE: %s libname [libname ...] [unicode]|[ansi] [loop][recurse]\n", appName);
+    dprintf("\tWhere libname(s) is one or more libraries to load.\n");
+    dprintf("\t[unicode] - perform tests using UNICODE api calls\n");
+    dprintf("\t[ansi] - perform tests using ANSI api calls\n");
+    dprintf("\t    default is %s\n", TARGET);
+    dprintf("\t[loop] - run test process in continuous loop\n");
+    dprintf("\t[recurse] - load libraries recursively rather than sequentually\n");
+    dprintf("\t[debug] - enable debug mode (unused)\n");
+    dprintf("\t[verbose] - enable verbose output (unused)\n");
+    return 0;
+}
+
+DWORD LoadLibraryList(char** libnames, int counter, BOOL bUseAnsi)
+{
+    HMODULE hModule;
+
+    dprintf("Attempting to LoadLibrary");
+    if (bUseAnsi) {
+        dprintf("A(%s) - ", *libnames);
+        hModule = LoadLibraryA(*libnames);
+    } else {
+        int len;
+        wchar_t libnameW[500];
+        len = mbstowcs(libnameW, *libnames, strlen(*libnames));
+        if (len) {
+            libnameW[len] = L'\0';
+            dprintf("W(%S) - ", libnameW);
+            hModule = LoadLibraryW(libnameW);
+        } else {
+            return ERROR_INVALID_PARAMETER;
+        }
+    }
+    if (hModule == NULL) {
+        dprintf("\nERROR: failed to obtain handle to module %s - %x\n", *libnames, hModule);
+        return ReportLastError();
+    }
+    dprintf("%x\n", hModule);
+
+    if (counter--) {
+        LoadLibraryList(++libnames, counter, bUseAnsi);
+    }
+
+    if (!FreeLibrary(hModule)) {
+        dprintf("ERROR: failed to free module %s - %x\n", *libnames, hModule);
+        return ReportLastError();
+    } else {
+        dprintf("FreeLibrary(%x) - successfull.\n", hModule);
+    }
+    return 0L;
+}
+
+int __cdecl main(int argc, char* argv[])
+{
+    char* libs[MAX_LIBS];
+    int lib_count = 0;
+    int result = 0;
+    int i = 0;
+
+    AllocConsole();
+    InputHandle = GetStdHandle(STD_INPUT_HANDLE);
+    OutputHandle =  GetStdHandle(STD_OUTPUT_HANDLE);
+
+    dprintf("%s application - build %03d (default: %s)\n", appName(argv[0]), APP_VERSION, TARGET);
+    if (argc < 2) {
+        /*return */usage(appName(argv[0]));
+    }
+    memset(libs, 0, sizeof(libs));
+    for (i = 1; i < argc; i++) {
+        if (lstrcmpiA(argv[i], "ansi") == 0) {
+            bUseAnsi = TRUE;
+        } else if (lstrcmpiA(argv[i], "unicode") == 0) {
+            bUseAnsi = FALSE;
+        } else if (lstrcmpiA(argv[i], "loop") == 0) {
+            loop_flagged = 1;
+        } else if (lstrcmpiA(argv[i], "recurse") == 0) {
+            recursive_flagged = 1;
+        } else if (lstrcmpiA(argv[i], "verbose") == 0) {
+            verbose_flagged = 1;
+        } else if (lstrcmpiA(argv[i], "debug") == 0) {
+            debug_flagged = 1;
+        } else {
+            if (lib_count < MAX_LIBS) {
+                libs[lib_count] = argv[i];
+                ++lib_count;
+            }
+        }
+    }
+    if (lib_count) {
+        do {
+            if (recursive_flagged) {
+                result = LoadLibraryList(libs, lib_count - 1, bUseAnsi);
+            } else {
+                for (i = 0; i < lib_count; i++) {
+                    result = LoadLibraryList(&libs[i], 0, bUseAnsi);
+                    //if (result != 0) break;
+                }
+            }
+        } while (loop_flagged);
+    } else {
+        int len;
+        char buffer[500];
+        do {
+            dprintf("\nEnter library name to attempt loading: ");
+            len = getinput(buffer, sizeof(buffer) - 1);
+            if (len > 2) {
+                char* buf = buffer;
+                buffer[len-2] = '\0';
+                result = LoadLibraryList(&buf, 0, bUseAnsi);
+            } else break;
+        } while (!result && len);
+    }
+    dprintf("finished\n");
+    return result;
+}
+
+
+#ifdef _NOCRT
+char* args[] = { "loadlib.exe", "advapi32.dll", "user32.dll", "recurse"};
+int __cdecl mainCRTStartup(void)
+{
+    return main(3, args);
+}
+#endif /*__GNUC__*/
diff --git a/rostests/win32/loadlib/loadlib.h b/rostests/win32/loadlib/loadlib.h
new file mode 100644 (file)
index 0000000..51210d4
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ *  ReactOS test program - 
+ *
+ *  loadlib.h
+ *
+ *  Copyright (C) 2002  Robert Dickenson <robd@reactos.org>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program 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 General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#ifndef __LOADLIB_H__
+#define __LOADLIB_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+extern BOOL verbose_flagged;
+extern BOOL debug_flagged;
+extern BOOL loop_flagged;
+extern BOOL recursive_flagged;
+
+DWORD ReportLastError(void);
+long getinput(char* Buffer, int buflen);
+void dprintf(char* fmt, ...);
+
+
+#ifdef __cplusplus
+};
+#endif
+
+#endif // __LOADLIB_H__
diff --git a/rostests/win32/msvcrt/fileio/_tfileio.c b/rostests/win32/msvcrt/fileio/_tfileio.c
new file mode 100644 (file)
index 0000000..84d0e1a
--- /dev/null
@@ -0,0 +1,421 @@
+/*
+ *  ReactOS test program - 
+ *
+ *  _tfileio.c
+ *
+ *  Copyright (C) 2002  Robert Dickenson <robd@reactos.org>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program 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 General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+#include <tchar.h>
+#include <wchar.h>
+#include <stdio.h>
+
+
+#ifdef UNICODE
+#define _tfopen      _wfopen
+#define _tunlink     _wunlink
+#define _TEOF        WEOF
+#define _gettchar    getwchar 
+#define _puttchar    putwchar  
+#define _THEX_FORMAT _T("0x%04x ")
+#else /*UNICODE*/
+#define _tfopen      fopen
+#define _tunlink     _unlink
+#define _TEOF        EOF
+#define _gettchar    getchar
+#define _puttchar    putchar
+#define _THEX_FORMAT "0x%02x "
+#endif /*UNICODE*/
+
+
+#define TEST_BUFFER_SIZE 200
+#define TEST_FILE_LINES  4
+
+extern BOOL verbose_flagged;
+extern BOOL status_flagged;
+
+static TCHAR test_buffer[TEST_BUFFER_SIZE];
+
+static TCHAR dos_data[] = _T("line1: this is a bunch of readable text.\r\n")\
+                   _T("line2: some more printable text and punctuation !@#$%^&*()\r\n")\
+                   _T("line3: followed up with some numerals 1234567890\r\n")\
+                   _T("line4: done.\r\n");
+
+static TCHAR nix_data[] = _T("line1: this is a bunch of readable text.\n")\
+                   _T("line2: some more printable text and punctuation !@#$%^&*()\n")\
+                   _T("line3: followed up with some numerals 1234567890\n")\
+                   _T("line4: done.\n");
+
+#ifdef UNICODE
+#define TEST_B1_FILE_SIZE ((((sizeof(dos_data)/2)-1)+TEST_FILE_LINES)/2) // (166+4)/2=85
+#define TEST_B2_FILE_SIZE (((sizeof(dos_data)/2)-1)*2)                   // (166*2)  =332
+#define TEST_B3_FILE_SIZE ((((sizeof(nix_data)/2)-1)+TEST_FILE_LINES)/2) // (162+4)/2=83
+#define TEST_B4_FILE_SIZE (((sizeof(nix_data)/2)-1)*2)                   // (162*2)  =324
+#else /*UNICODE*/
+#define TEST_B1_FILE_SIZE (sizeof(dos_data)-1+TEST_FILE_LINES) // (166+4)=170
+#define TEST_B2_FILE_SIZE (sizeof(dos_data)-1-TEST_FILE_LINES) // (166-4)=162
+#define TEST_B3_FILE_SIZE (sizeof(nix_data)-1+TEST_FILE_LINES) // (162+4)=166
+#define TEST_B4_FILE_SIZE (sizeof(nix_data)-1)                 // (162)  =162
+#endif /*UNICODE*/
+
+
+//    result = create_test_file(file_name, _T("wb"), _T("rb"), file_data);
+
+static BOOL test_file_truncate(TCHAR* file_name)
+{
+    BOOL result = FALSE;
+    int count = -1;
+    int error_code;
+    TCHAR ch;
+    TCHAR* file_data = _T("this file should have been truncated to zero bytes...");
+    FILE *file = _tfopen(file_name, _T("wb"));
+
+    if (verbose_flagged) {
+        _tprintf(_T("test_file_truncate(\"%s\")\n"), file_name);
+    }
+
+    if (file != NULL) {
+        if (_fputts(file_data, file) != _TEOF) {
+        } else {
+            _tprintf(_T("ERROR: failed to write data to file \"%s\"\n"), file_name);
+            _tprintf(_T("ERROR: ferror returned %d\n"), ferror(file));
+        }
+        fclose(file);
+    } else {
+        _tprintf(_T("ERROR: failed to open/create file \"%s\" for output\n"), file_name);
+        _tprintf(_T("ERROR: ferror returned %d\n"), ferror(file));
+    }
+
+    file = _tfopen(file_name, _T("wb"));
+    if (file != NULL) {
+        error_code = ferror(file);
+        if (error_code) {
+             _tprintf(_T("ERROR: (%s) ferror returned %d\n"), file_name, error_code);
+        }
+        fclose(file);
+    } else {
+        _tprintf(_T("ERROR: (%s) failed to open file for truncating\n"), file_name);
+    }
+
+    file = _tfopen(file_name, _T("rb"));
+    if (file != NULL) {
+        count = 0;
+        while ((ch = _fgettc(file)) != _TEOF) {
+            if (verbose_flagged) {
+                _tprintf(_THEX_FORMAT, ch);
+            }
+            ++count;
+        }
+        error_code = ferror(file);
+        if (error_code) {
+             _tprintf(_T("ERROR: (%s) ferror returned %d after reading\n"), file_name, error_code);
+             perror("Read error");
+        }
+        fclose(file);
+    } else {
+        _tprintf(_T("ERROR: (%s) failed to open file for reading\n"), file_name);
+    }
+    if (count) {
+        result = TRUE;
+    }
+    return result;
+}
+
+static BOOL create_output_file(TCHAR* file_name, TCHAR* file_mode, TCHAR* file_data)
+{
+    BOOL result = FALSE;
+    FILE *file = _tfopen(file_name, file_mode);
+    if (file != NULL) {
+        if (_fputts(file_data, file) != _TEOF) {
+            result = TRUE;
+        } else {
+            _tprintf(_T("ERROR: failed to write data to file \"%s\"\n"), file_name);
+            _tprintf(_T("ERROR: ferror returned %d\n"), ferror(file));
+        }
+        fclose(file);
+    } else {
+        _tprintf(_T("ERROR: failed to open/create file \"%s\" for output\n"), file_name);
+        _tprintf(_T("ERROR: ferror returned %d\n"), ferror(file));
+    }
+    return result;
+}
+
+static BOOL verify_output_file(TCHAR* file_name, TCHAR* file_mode, TCHAR* file_data)
+{
+    int error_code;
+    int offset = 0;
+    int line_num = 0;
+    BOOL result = FALSE;
+    BOOL error_flagged = FALSE;
+    FILE* file = _tfopen(file_name, file_mode);
+    if (file == NULL) {
+        _tprintf(_T("ERROR: (%s) Can't open file for reading\n"), file_name);
+        _tprintf(_T("ERROR: ferror returned %d\n"), ferror(file));
+        return FALSE;
+    } else if (status_flagged) {
+        _tprintf(_T("STATUS: (%s) opened file for reading\n"), file_name);
+    }
+    while (_fgetts(test_buffer, TEST_BUFFER_SIZE, file)) {
+        int length = _tcslen(test_buffer);
+        int req_len = _tcschr(file_data+offset, _T('\n')) - (file_data+offset) + 1;
+
+        ++line_num;
+        if (length > req_len) {
+            _tprintf(_T("ERROR: read excess bytes from line %d, length %d, but expected %d\n"), line_num, length, req_len);
+            error_flagged = TRUE;
+            break;
+        }
+        if (length < req_len) {
+            _tprintf(_T("ERROR: read to few bytes from line %d, length %d, but expected %d\n"), line_num, length, req_len);
+            error_flagged = TRUE;
+            break;
+        }
+        if (status_flagged) {
+            _tprintf(_T("STATUS: Verifying %d bytes read from line %d\n"), length, line_num);
+        }
+        if (_tcsncmp(test_buffer, file_data+offset, length - 1) == 0) {
+            result = TRUE;
+        } else {
+            if (status_flagged) {
+                int i;
+                _tprintf(_T("WARNING: (%s) failed to verify file\n"), file_name);
+                for (i = 0; i < length; i++) {
+                    if (file_data[offset+i] != test_buffer[i]) {
+                        _tprintf(_T("line %d, offset %d expected: 0x%04x found: 0x%04x\n"), line_num, i, (int)file_data[offset+i], (int)test_buffer[i]);
+                    }
+                }
+                _tprintf(_T("\n"));
+            } else {
+                error_flagged = TRUE;
+            }
+        }
+        offset += length;
+    }
+    error_code = ferror(file);
+    if (error_code) {
+         _tprintf(_T("ERROR: (%s) ferror returned %d after reading\n"), file_name, error_code);
+         perror("Read error");
+    }
+    if (!line_num) {
+        _tprintf(_T("ERROR: (%s) failed to read from file\n"), file_name);
+    }
+    if (error_flagged == TRUE) {
+        _tprintf(_T("ERROR: (%s) failed to verify file\n"), file_name);
+        result = FALSE;
+    }
+    fclose(file);
+    return result;
+}
+
+static int create_test_file(TCHAR* file_name, TCHAR* write_mode, TCHAR* read_mode, TCHAR* file_data)
+{
+    if (status_flagged) {
+        _tprintf(_T("STATUS: Attempting to create output file %s\n"), file_name);
+    }
+    if (create_output_file(file_name, write_mode, file_data)) {
+        if (status_flagged) {
+            _tprintf(_T("STATUS: Attempting to verify output file %s\n"), file_name);
+        }
+        if (verify_output_file(file_name, read_mode, file_data)) {
+            if (status_flagged) {
+                _tprintf(_T("SUCCESS: %s verified ok\n"), file_name);
+            }
+        } else {
+            //_tprintf(_T("ERROR: failed to verify file %s\n"), file_name);
+            return 2;
+        }
+    } else {
+        _tprintf(_T("ERROR: failed to create file %s\n"), file_name);
+        return 1;
+    }
+    return 0;
+}
+
+static int check_file_size(TCHAR* file_name, TCHAR* file_mode, int expected)
+{
+    int count = 0;
+    FILE* file;
+    TCHAR ch;
+    int error_code;
+
+    if (status_flagged) {
+        //_tprintf(_T("STATUS: (%s) checking for %d bytes in %s mode\n"), file_name, expected, _tcschr(file_mode, _T('b')) ? _T("binary") : _T("text"));
+        _tprintf(_T("STATUS: (%s) checking for %d bytes with mode %s\n"), file_name, expected, file_mode);
+    }
+    file = _tfopen(file_name, file_mode);
+    if (file == NULL) {
+        _tprintf(_T("ERROR: (%s) failed to open file for reading\n"), file_name);
+        return 1;
+    }
+    while ((ch = _fgettc(file)) != _TEOF) {
+        if (verbose_flagged) {
+            _tprintf(_THEX_FORMAT, ch);
+        }
+        ++count;
+    }
+    error_code = ferror(file);
+    if (error_code) {
+         _tprintf(_T("ERROR: (%s) ferror returned %d after reading\n"), file_name, error_code);
+         perror("Read error");
+    }
+
+    if (verbose_flagged) {
+//        _puttc(_T('\n'), stdout);
+    }
+    fclose(file);
+    if (count == expected) {
+        if (status_flagged) {
+            _tprintf(_T("PASSED: (%s) read %d bytes\n"), file_name, count);
+        }
+    } else {
+        _tprintf(_T("FAILED: (%s) read %d bytes but expected %d using mode \"%s\"\n"), file_name, count, expected, file_mode);
+    }
+    return (count == expected) ? 0 : -1;
+}
+
+static int test_console_io(void)
+{
+    TCHAR buffer[81];
+    TCHAR ch;
+    int i, j;
+
+    _tprintf(_T("Enter a line for echoing:\n"));
+
+    //for (i = 0; (i < 80) && ((ch = _gettchar()) != _TEOF) && (ch != _T('\n')); i++) {
+    for (i = 0; (i < 80) && ((ch = _gettc(stdin)) != _TEOF) && (ch != _T('\n')); i++) {
+        buffer[i] = (TCHAR)ch;
+    }
+    buffer[i] = _T('\0');
+    for (j = 0; j < i; j++) {
+        _puttc(buffer[j], stdout);
+    }
+    _puttc(_T('\n'), stdout);
+    _tprintf(_T("%s\n"), buffer);
+    return 0;
+}
+
+static int test_console_getchar(void)
+{
+    int result = 0;
+    TCHAR ch;
+
+    _tprintf(_T("Enter lines for dumping or <ctrl-z><nl> to finish:\n"));
+
+    //while ((ch = _gettchar()) != _TEOF) {
+    while ((ch = _gettc(stdin)) != _TEOF) {
+        _tprintf(_THEX_FORMAT, ch);
+        //printf("0x%04x ", ch);
+    }
+    return result;
+}
+
+static int test_console_putch(void)
+{
+    int result = 0;
+
+    _putch('1');
+    _putch('@');
+    _putch('3');
+    _putch(':');
+    _putch('\n');
+    _putch('a');
+    _putch('B');
+    _putch('c');
+    _putch(':');
+    _putch('\n');
+    return result;
+}
+
+static int test_unlink_files(void)
+{
+    int result = 0;
+
+    //printf("sizeof dos_data: %d\n", sizeof(dos_data));
+    //printf("sizeof nix_data: %d\n", sizeof(nix_data));
+
+    result |= _tunlink(_T("binary.dos"));
+    result |= _tunlink(_T("binary.nix"));
+    result |= _tunlink(_T("text.dos"));
+    result |= _tunlink(_T("text.nix"));
+    return result;
+}
+
+static int test_text_fileio(TCHAR* file_name, TCHAR* file_data, int tsize, int bsize)
+{
+    int result = 0;
+
+    result = create_test_file(file_name, _T("w"), _T("r"), file_data);
+    result = check_file_size(file_name, _T("r"), tsize);
+    result = check_file_size(file_name, _T("rb"), bsize);
+    return result;
+}
+
+static int test_binary_fileio(TCHAR* file_name, TCHAR* file_data, int tsize, int bsize)
+{
+    int result = 0;
+
+    result = create_test_file(file_name, _T("wb"), _T("rb"), file_data);
+    result = check_file_size(file_name, _T("r"), tsize);
+    result = check_file_size(file_name, _T("rb"), bsize);
+    return result;
+}
+
+static int test_files(int test_num, char* type)
+{
+    int result = 0;
+
+    printf("performing test: %d (%s)\n", test_num, type);
+
+
+    if (test_file_truncate(_T("zerosize.foo"))) {
+        printf("System unable to truncate files yet, unlinking:\n");
+        test_unlink_files();
+    }
+
+    switch (test_num) {
+    case 1:
+        result = test_text_fileio(_T("text.dos"), dos_data, 166, TEST_B1_FILE_SIZE);
+        break;
+    case 2:
+        result = test_binary_fileio(_T("binary.dos"), dos_data, TEST_B2_FILE_SIZE, 166);
+        break;
+    case 3:
+        result = test_text_fileio(_T("text.nix"), nix_data, 162, TEST_B3_FILE_SIZE);
+        break;
+    case 4:
+        result = test_binary_fileio(_T("binary.nix"), nix_data, TEST_B4_FILE_SIZE, 162);
+        break;
+    case 5:
+        result = test_console_io();
+        break;
+    case 6:
+        result = test_console_getchar();
+        break;
+    case 7:
+        result = test_console_putch();
+        break;
+    case -1:
+        result = test_unlink_files();
+        break;
+    default:
+        _tprintf(_T("no test number selected\n"));
+        break;
+    }
+    return result;
+}
diff --git a/rostests/win32/msvcrt/fileio/fileio.c b/rostests/win32/msvcrt/fileio/fileio.c
new file mode 100644 (file)
index 0000000..ab29300
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ *  ReactOS test program - 
+ *
+ *  _fileio.c
+ *
+ *  Copyright (C) 2002  Robert Dickenson <robd@reactos.org>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program 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 General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#undef UNICODE
+#undef _UNICODE
+#include "_tfileio.c"
+
+
+int run_ansi_tests(int test_num)
+{
+    return test_files(test_num, "ANSI");
+}
diff --git a/rostests/win32/msvcrt/fileio/main.c b/rostests/win32/msvcrt/fileio/main.c
new file mode 100644 (file)
index 0000000..64f5476
--- /dev/null
@@ -0,0 +1,124 @@
+/*
+ *  ReactOS test program - 
+ *
+ *  main.c
+ *
+ *  Copyright (C) 2002  Robert Dickenson <robd@reactos.org>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program 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 General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+#include <tchar.h>
+#include <wchar.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "main.h"
+
+
+#define VERSION 1
+
+#ifdef UNICODE
+#define TARGET  "UNICODE"
+#else
+#define TARGET  "MBCS"
+#endif
+
+BOOL verbose_flagged = 0;
+BOOL status_flagged = 0;
+
+int usage(char* argv0)
+{
+    printf("USAGE: %s test_id [unicode]|[ansi] [clean]|[status][verbose]\n", argv0);
+    printf("\tWhere test_id is one of:\n");
+    printf("\t0 - (default) regression mode, run tests 1-4 displaying failures only\n");
+    printf("\t1 - Write DOS style eol data to file in text mode (text.dos)\n");
+    printf("\t2 - Write NIX style eol data to file in binary mode (binary.dos)\n");
+    printf("\t3 - Write DOS style eol data to file in text mode (text.nix)\n");
+    printf("\t4 - Write NIX style eol data to file in binary mode (binary.nix)\n");
+    printf("\t5 - Echo console line input\n");
+    printf("\t6 - Dump console line input in hex format\n");
+    printf("\t7 - The source code is your friend\n");
+    printf("\t[unicode] - perform tests using UNICODE versions of library functions\n");
+    printf("\t[ansi] - perform tests using ANSI versions of library functions\n");
+    printf("\t    If neither unicode or ansi is specified build default is used\n");
+    printf("\t[clean] - delete all temporary test output files\n");
+    printf("\t[status] - enable extra status display while running\n");
+    printf("\t[verbose] - enable verbose output when running\n");
+    return 0;
+}
+
+int __cdecl main(int argc, char* argv[])
+{
+    int test_num = 0;
+    int version = 0;
+    int result = 0;
+    int i = 0;
+
+    printf("%s test application - build %03d (default: %s)\n", argv[0], VERSION, TARGET);
+    if (argc < 2) {
+        return usage(argv[0]);
+    }
+    for (i = 1; i < argc; i++) {
+        if (strstr(argv[i], "ansi") || strstr(argv[i], "ANSI")) {
+            version = 1;
+        } else if (strstr(argv[i], "unicode") || strstr(argv[i], "UNICODE")) {
+            version = 2;
+        } else if (strstr(argv[i], "clean") || strstr(argv[i], "CLEAN")) {
+            test_num = -1;
+        } else if (strstr(argv[i], "verbose") || strstr(argv[i], "VERBOSE")) {
+            verbose_flagged = 1;
+        } else if (strstr(argv[i], "status") || strstr(argv[i], "STATUS")) {
+            status_flagged = 1;
+        } else {
+            test_num = atoi(argv[1]);
+            //if (test_num < 0
+        }
+    }
+    for (i = test_num; i <= test_num; i++) {
+        if (!test_num) {
+            test_num = 4;
+            i = 1;
+        }
+        switch (version) {
+        case 1:
+            result = run_ansi_tests(i);
+            break;
+        case 2:
+            result = run_unicode_tests(i);
+            break;
+        default:
+            result = run_ansi_tests(i);
+            result = run_unicode_tests(i);
+            break;
+        }
+    }
+    printf("finished\n");
+    return result;
+}
+
+#ifndef __GNUC__
+
+char* args[] = { "fileio.exe", "0", "unicode", "verbose"};
+
+int __cdecl mainCRTStartup(void)
+{
+    main(2, args);
+    return 0;
+}
+
+#endif /*__GNUC__*/
diff --git a/rostests/win32/msvcrt/fileio/main.h b/rostests/win32/msvcrt/fileio/main.h
new file mode 100644 (file)
index 0000000..ee20fbe
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ *  ReactOS test program - 
+ *
+ *  main.h
+ *
+ *  Copyright (C) 2002  Robert Dickenson <robd@reactos.org>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program 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 General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#ifndef __MAIN_H__
+#define __MAIN_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+int app_main(int argc, char* argv[]);
+DWORD GetInput(char* Buffer, int buflen);
+
+int test_ansi_files(int test_num);
+int test_unicode_files(int test_num);
+
+
+#ifdef __cplusplus
+};
+#endif
+
+#endif // __MAIN_H__
diff --git a/rostests/win32/msvcrt/fileio/wfileio.c b/rostests/win32/msvcrt/fileio/wfileio.c
new file mode 100644 (file)
index 0000000..5985a8a
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ *  ReactOS test program - 
+ *
+ *  wfileio.c
+ *
+ *  Copyright (C) 2002  Robert Dickenson <robd@reactos.org>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program 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 General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#define UNICODE
+#define _UNICODE
+#include "_tfileio.c"
+
+
+int run_unicode_tests(int test_num)
+{
+    return test_files(test_num, "UNICODE");
+}
diff --git a/rostests/win32/rpcrt4/context_handles/client.c b/rostests/win32/rpcrt4/context_handles/client.c
new file mode 100644 (file)
index 0000000..8cfb261
--- /dev/null
@@ -0,0 +1,457 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <ctype.h>
+#include "ctx.h" 
+#define TYPE_FORMAT_STRING_SIZE   23                                
+#define PROC_FORMAT_STRING_SIZE   21                                
+#define TRANSMIT_AS_TABLE_SIZE    0            
+#define WIRE_MARSHAL_TABLE_SIZE   0   
+
+typedef struct _MIDL_TYPE_FORMAT_STRING
+    {
+    short          Pad;
+    unsigned char  Format[ TYPE_FORMAT_STRING_SIZE ];
+    } MIDL_TYPE_FORMAT_STRING;
+
+typedef struct _MIDL_PROC_FORMAT_STRING
+    {
+    short          Pad;
+    unsigned char  Format[ PROC_FORMAT_STRING_SIZE ];
+} MIDL_PROC_FORMAT_STRING;
+
+extern const MIDL_STUB_DESC hello_StubDesc;
+extern const MIDL_PROC_FORMAT_STRING __MIDL_ProcFormatString;
+//extern const MIDL_TYPE_FORMAT_STRING __MIDL_TypeFormatString;*/
+
+/*****************************************************************
+ * Modified from midl-generated stubs                            *
+ *****************************************************************/
+
+
+void m_CtxOpen( 
+    /* [out] */ PCTXTYPE __RPC_FAR *pphContext,
+    /* [in] */ long Value)
+{
+    RPC_BINDING_HANDLE _Handle =       0;
+    
+    RPC_MESSAGE _RpcMessage;
+    
+    MIDL_STUB_MESSAGE _StubMsg;
+
+       char *ctx, *buf;
+       int i;
+       
+       printf("\n*******************************************************************\n");
+       printf("**** CtxOpen()                                                  ***\n");
+       printf("*******************************************************************\n\n");
+    
+    if(!pphContext)
+        {
+        RpcRaiseException(RPC_X_NULL_REF_POINTER);
+        }
+    RpcTryFinally
+        {
+        NdrClientInitializeNew(
+                          ( PRPC_MESSAGE  )&_RpcMessage,
+                          ( PMIDL_STUB_MESSAGE  )&_StubMsg,
+                          ( PMIDL_STUB_DESC  )&hello_StubDesc,
+                          0);
+        
+        
+        _Handle = hBinding;
+        
+        
+        _StubMsg.BufferLength = 4U;
+        NdrGetBuffer( (PMIDL_STUB_MESSAGE) &_StubMsg, _StubMsg.BufferLength, _Handle );
+        
+        *(( long __RPC_FAR * )_StubMsg.Buffer)++ = Value;
+        
+        NdrSendReceive( (PMIDL_STUB_MESSAGE) &_StubMsg, (unsigned char __RPC_FAR *) _StubMsg.Buffer );
+        
+        if ( (_RpcMessage.DataRepresentation & 0X0000FFFFUL) != NDR_LOCAL_DATA_REPRESENTATION )
+            NdrConvert( (PMIDL_STUB_MESSAGE) &_StubMsg, (PFORMAT_STRING) &__MIDL_ProcFormatString.Format[0] );
+
+
+        printf("Before NdrClientContextUnmarshall: Buflen=%d\nBuffer: ",  _StubMsg.RpcMsg->BufferLength);
+        for(buf = _StubMsg.Buffer, i = 0; i < _StubMsg.RpcMsg->BufferLength; i++)
+               printf("0x%x, ", buf[i] & 0x0FF);
+        printf("\n\n");
+        
+        *pphContext = (void *)0;
+        NdrClientContextUnmarshall(
+                              ( PMIDL_STUB_MESSAGE  )&_StubMsg,
+                              ( NDR_CCONTEXT __RPC_FAR * )pphContext,
+                              _Handle);
+        
+        ctx = (char*)*pphContext;
+        printf("\nNdrClientContextUnmarshall returned: handle=0x%p\n", ctx);
+        printf("00: 0x%x <- obviously pointer to binding handle copyed from _Handle\n", *((int*)ctx));
+        ctx+=4;
+        printf("04: 0x%x <- unknown field\n", *((int*)ctx));
+        printf("08: ");
+        
+        for(ctx+=4, i = 0; i < 20; i++)
+               printf("0x%x,", *(ctx+i) & 0x0FF); printf(" <- ndr 20 bytes\n\n");
+               
+        printf("Buflen=%d, Buffer: ", _StubMsg.BufferLength);
+        for(buf = _StubMsg.BufferStart; buf < _StubMsg.BufferEnd; buf++)
+               printf("0x%x,", *buf & 0x0FF);
+        printf("\n");
+        
+        
+        }
+    RpcFinally
+        {
+        NdrFreeBuffer( (PMIDL_STUB_MESSAGE) &_StubMsg );
+        
+        }
+    RpcEndFinally
+    
+}
+
+void m_CtxOpen2( 
+    /* [out] */ PCTXTYPE __RPC_FAR *pphContext,
+    /* [in] */ long Value)
+{
+
+    RPC_BINDING_HANDLE _Handle =       0;
+    
+    RPC_MESSAGE _RpcMessage;
+    
+    MIDL_STUB_MESSAGE _StubMsg;
+    
+    char buf[255];
+    
+        NdrClientInitializeNew(
+                          ( PRPC_MESSAGE  )&_RpcMessage,
+                          ( PMIDL_STUB_MESSAGE  )&_StubMsg,
+                          ( PMIDL_STUB_DESC  )&hello_StubDesc,
+                          0);
+        
+        
+        _Handle = hBinding;
+        
+        
+        _StubMsg.BufferLength = 4U;
+        NdrGetBuffer( (PMIDL_STUB_MESSAGE) &_StubMsg, _StubMsg.BufferLength, _Handle );
+        
+        *(( long __RPC_FAR * )_StubMsg.Buffer)++ = Value;
+        
+        NdrSendReceive( (PMIDL_STUB_MESSAGE) &_StubMsg, (unsigned char __RPC_FAR *) _StubMsg.Buffer );
+        
+        if ( (_RpcMessage.DataRepresentation & 0X0000FFFFUL) != NDR_LOCAL_DATA_REPRESENTATION )
+            NdrConvert( (PMIDL_STUB_MESSAGE) &_StubMsg, (PFORMAT_STRING) &__MIDL_ProcFormatString.Format[0] );
+        
+        *pphContext = (void *)0;
+        
+        RpcTryExcept
+        {
+        NdrClientContextUnmarshall(
+                              ( PMIDL_STUB_MESSAGE  )&_StubMsg,
+                              NULL,
+                              _Handle);
+        }
+        RpcExcept(1)
+        {
+               printf("NdrClientContextUnmarshall reported exception = %d\n", RpcExceptionCode());
+        }
+        RpcEndExcept
+        
+        
+        
+        RpcTryExcept
+        {
+        NdrClientContextUnmarshall(
+                              ( PMIDL_STUB_MESSAGE  )&_StubMsg,
+                              (NDR_CCONTEXT __RPC_FAR * )pphContext,
+                              NULL);
+        }
+        RpcExcept(1)
+        {
+               printf("NdrClientContextUnmarshall reported exception = %d\n", RpcExceptionCode());
+        }
+        RpcEndExcept
+        
+                            
+        RpcTryExcept
+        {
+        NdrClientContextMarshall(
+                            ( PMIDL_STUB_MESSAGE  )&_StubMsg,
+                            NULL,
+                            1);
+        }
+        RpcExcept(1)
+        {
+               printf("NdrClientContextMarshall reported exception = %d\n", RpcExceptionCode());
+        }
+        RpcEndExcept
+        
+        RpcTryExcept
+        {
+               NDRCContextUnmarshall( NULL, _Handle, buf, _RpcMessage.DataRepresentation  );
+        }
+        RpcExcept(1)
+        {
+               printf("NDRCContextUnmarshall reported exception = %d\n", RpcExceptionCode());
+        }
+        RpcEndExcept
+
+        
+        NdrFreeBuffer( (PMIDL_STUB_MESSAGE) &_StubMsg );
+        
+    
+}
+
+void m_CtxHello( 
+    /* [in] */ PCTXTYPE phContext)
+{
+
+    RPC_BINDING_HANDLE _Handle =       0;
+    
+    RPC_MESSAGE _RpcMessage;
+    
+    MIDL_STUB_MESSAGE _StubMsg;
+    
+    char *buf;
+    int i;
+    
+       printf("\n*******************************************************************\n");
+       printf("**** CtxHello()                                                 ***\n");
+       printf("*******************************************************************\n\n");
+    
+    RpcTryFinally
+        {
+        NdrClientInitializeNew(
+                          ( PRPC_MESSAGE  )&_RpcMessage,
+                          ( PMIDL_STUB_MESSAGE  )&_StubMsg,
+                          ( PMIDL_STUB_DESC  )&hello_StubDesc,
+                          1);
+        
+        
+        if(phContext != 0)
+            {
+            _Handle = NDRCContextBinding(( NDR_CCONTEXT  )phContext);;
+            
+            }
+        else
+            {
+            RpcRaiseException(RPC_X_SS_IN_NULL_CONTEXT);
+            }
+        
+        _StubMsg.BufferLength = 20U;
+        NdrGetBuffer( (PMIDL_STUB_MESSAGE) &_StubMsg, _StubMsg.BufferLength, _Handle );
+        
+        NdrClientContextMarshall(
+                            ( PMIDL_STUB_MESSAGE  )&_StubMsg,
+                            ( NDR_CCONTEXT  )phContext,
+                            1);
+        printf("After NdrClientContextMarshall: Buflen=%d\nBuffer: ", _StubMsg.BufferLength );
+        for(buf = _StubMsg.Buffer, i = 0; i < _StubMsg.BufferLength; i++)
+               printf("0x%x, ", buf[i] & 0x0FF);
+        printf("\n\n");
+        
+        NdrSendReceive( (PMIDL_STUB_MESSAGE) &_StubMsg, (unsigned char __RPC_FAR *) _StubMsg.Buffer );
+        
+        }
+    RpcFinally
+        {
+        NdrFreeBuffer( (PMIDL_STUB_MESSAGE) &_StubMsg );
+        
+        }
+    RpcEndFinally
+    
+}
+
+
+void m_CtxClose( 
+    /* [out][in] */ PCTXTYPE __RPC_FAR *pphContext)
+{
+
+    RPC_BINDING_HANDLE _Handle =       0;
+    
+    RPC_MESSAGE _RpcMessage;
+    
+    MIDL_STUB_MESSAGE _StubMsg;
+    char *buf;
+    int i;
+       
+       printf("\n*******************************************************************\n");
+       printf("**** CtxClose()                                                 ***\n");
+       printf("*******************************************************************\n\n");
+       
+    if(!pphContext)
+        {
+        RpcRaiseException(RPC_X_NULL_REF_POINTER);
+        }
+    RpcTryFinally
+        {
+        NdrClientInitializeNew(
+                          ( PRPC_MESSAGE  )&_RpcMessage,
+                          ( PMIDL_STUB_MESSAGE  )&_StubMsg,
+                          ( PMIDL_STUB_DESC  )&hello_StubDesc,
+                          2);
+        
+        
+        if(*pphContext != 0)
+            {
+            _Handle = NDRCContextBinding(( NDR_CCONTEXT  )*pphContext);;
+            
+            }
+        
+        _StubMsg.BufferLength = 20U;
+        NdrGetBuffer( (PMIDL_STUB_MESSAGE) &_StubMsg, _StubMsg.BufferLength, _Handle );
+        
+        NdrClientContextMarshall(
+                            ( PMIDL_STUB_MESSAGE  )&_StubMsg,
+                            ( NDR_CCONTEXT  )*pphContext,
+                            0);
+        
+        NdrSendReceive( (PMIDL_STUB_MESSAGE) &_StubMsg, (unsigned char __RPC_FAR *) _StubMsg.Buffer );
+        
+        if ( (_RpcMessage.DataRepresentation & 0X0000FFFFUL) != NDR_LOCAL_DATA_REPRESENTATION )
+            NdrConvert( (PMIDL_STUB_MESSAGE) &_StubMsg, (PFORMAT_STRING) &__MIDL_ProcFormatString.Format[14] );
+        
+        
+      printf("Before NdrClientContextUnmarshall: Buflen=%d\nBuffer: ",  _StubMsg.BufferLength );
+        for(buf = _StubMsg.Buffer, i = 0; i < _StubMsg.BufferLength; i++)
+               printf("0x%x, ", buf[i] & 0x0FF);
+        printf("\n\n");
+        
+        NdrClientContextUnmarshall(
+                              ( PMIDL_STUB_MESSAGE  )&_StubMsg,
+                              ( NDR_CCONTEXT __RPC_FAR * )pphContext,
+                              _Handle);
+                            
+               printf("\nNdrClientContextUnmarshall returned: handle=0x%p\n", *pphContext);
+               
+        
+        }
+    RpcFinally
+        {
+        NdrFreeBuffer( (PMIDL_STUB_MESSAGE) &_StubMsg );
+        
+        }
+    RpcEndFinally
+    
+}
+
+int interactive = 0;
+void interact()
+{
+       if(interactive)
+       {
+               printf("\nPress any key to continue...");
+               getch();
+               printf("\n\n");
+       }
+}
+
+void main(int argc, char **argv)
+{
+       RPC_STATUS status;
+       unsigned long ulCode;
+       PCTXTYPE hContext;
+       char *pszStringBinding = NULL;
+       RPC_BINDING_HANDLE Handle =     0;
+       char buffer[255];
+       
+       int test_num = 0;
+       int test_value = 31337;
+       
+       if(argc<2)
+       {
+               printf("USAGE: client.exe <test_number> [test_value] [interactive]\n"
+                       "Available tests:\n"
+                       "0. General test\n"
+                       "1. NULL pointer test\n"
+                       "2. Context rundown routine");
+               return;
+       }
+       
+       test_num = atoi(argv[1]);
+       if(argc>2) test_value = atoi(argv[2]);
+       if(argc>3) interactive = 1;
+
+       status = RpcStringBindingCompose(NULL, 
+               "ncacn_np", 
+               NULL, 
+               "\\pipe\\hello", 
+               NULL, 
+               &pszStringBinding);
+
+       if (status) 
+       {
+               printf("RpcStringBindingCompose %x\n", status);
+               exit(status);
+       }
+       
+       status = RpcBindingFromStringBinding(pszStringBinding, &hBinding);
+
+       if (status)
+       {
+               printf("RpcBindingFromStringBinding %x\n", status);
+               exit(status);
+       }
+
+       RpcStringFree(&pszStringBinding); 
+       
+       switch(test_num)
+       {
+       case 0:
+               m_CtxOpen(&hContext, test_value);
+               RpcBindingFree(&hBinding);
+               m_CtxHello(hContext);
+               interact();
+               m_CtxClose(&hContext);
+               break;
+       case 1:
+               /////////////////////////////////////////////////////////////////////////////////////////
+               RpcTryExcept
+               {
+                       Handle = NDRCContextBinding(NULL);
+                       printf("NDRCContextBinding(NULL) returned %p\n", Handle);
+               }
+               RpcExcept(1)
+               {
+                        printf("NDRCContextBinding(NULL) reported exception = %d\n", RpcExceptionCode());
+               }
+               RpcEndExcept    
+               
+               m_CtxOpen2(&hContext, test_value);
+               
+               /////////////////////////////////////////////////////////////////////////////////////////
+               RpcTryExcept
+               {
+                       NDRCContextMarshall(NULL, &buffer);
+                       printf("NDRCContextMarshall(NULL) returned %p\n", Handle);
+               }
+               RpcExcept(1)
+               {
+                        printf("NDRCContextMarshall(NULL) reported exception = %d\n", RpcExceptionCode());
+               }
+               RpcEndExcept    
+               /////////////////////////////////////////////////////////////////////////////////////////
+               break;
+       case 2:
+               CtxOpen(&hContext, test_value);
+               interact();
+               ExitProcess(0);
+               break;
+       default:
+               printf("Unknown test %d\n", test_num);
+       }
+
+}
+
+
+void __RPC_FAR * __RPC_USER midl_user_allocate(size_t len)
+{
+       return(malloc(len));
+}
+void __RPC_USER midl_user_free(void __RPC_FAR * ptr)
+{
+       free(ptr);
+}
diff --git a/rostests/win32/rpcrt4/context_handles/ctx.acf b/rostests/win32/rpcrt4/context_handles/ctx.acf
new file mode 100644 (file)
index 0000000..c02c5d1
--- /dev/null
@@ -0,0 +1,8 @@
+//file hello.idl
+[
+    implicit_handle(handle_t hBinding)
+]
+interface hello
+{
+
+}
\ No newline at end of file
diff --git a/rostests/win32/rpcrt4/context_handles/ctx.h b/rostests/win32/rpcrt4/context_handles/ctx.h
new file mode 100644 (file)
index 0000000..f92edbe
--- /dev/null
@@ -0,0 +1,80 @@
+
+#pragma warning( disable: 4049 )  /* more than 64k source lines */
+
+/* this ALWAYS GENERATED file contains the definitions for the interfaces */
+
+
+ /* File created by MIDL compiler version 5.03.0280 */
+/* at Fri Mar 24 18:32:16 2006
+ */
+/* Compiler settings for ctx.idl:
+    Os (OptLev=s), W1, Zp8, env=Win32 (32b run), ms_ext, c_ext
+    error checks: allocation ref bounds_check enum stub_data 
+    VC __declspec() decoration level: 
+         __declspec(uuid()), __declspec(selectany), __declspec(novtable)
+         DECLSPEC_UUID(), MIDL_INTERFACE()
+*/
+//@@MIDL_FILE_HEADING(  )
+
+
+/* verify that the <rpcndr.h> version is high enough to compile this file*/
+#ifndef __REQUIRED_RPCNDR_H_VERSION__
+#define __REQUIRED_RPCNDR_H_VERSION__ 440
+#endif
+
+#include "rpc.h"
+#include "rpcndr.h"
+
+#ifndef __ctx_h__
+#define __ctx_h__
+
+/* Forward Declarations */ 
+
+#ifdef __cplusplus
+extern "C"{
+#endif 
+
+void __RPC_FAR * __RPC_USER MIDL_user_allocate(size_t);
+void __RPC_USER MIDL_user_free( void __RPC_FAR * ); 
+
+#ifndef __hello_INTERFACE_DEFINED__
+#define __hello_INTERFACE_DEFINED__
+
+/* interface hello */
+/* [implicit_handle][version][uuid] */ 
+
+typedef long CTXTYPE;
+
+typedef /* [context_handle] */ CTXTYPE __RPC_FAR *PCTXTYPE;
+
+void CtxOpen( 
+    /* [out] */ PCTXTYPE __RPC_FAR *pphContext,
+    /* [in] */ long Value);
+
+void CtxHello( 
+    /* [in] */ PCTXTYPE phContext);
+
+void CtxClose( 
+    /* [out][in] */ PCTXTYPE __RPC_FAR *pphContext);
+
+
+extern handle_t hBinding;
+
+
+extern RPC_IF_HANDLE hello_v1_0_c_ifspec;
+extern RPC_IF_HANDLE hello_v1_0_s_ifspec;
+#endif /* __hello_INTERFACE_DEFINED__ */
+
+/* Additional Prototypes for ALL interfaces */
+
+void __RPC_USER PCTXTYPE_rundown( PCTXTYPE );
+
+/* end of Additional Prototypes */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
+
diff --git a/rostests/win32/rpcrt4/context_handles/ctx.idl b/rostests/win32/rpcrt4/context_handles/ctx.idl
new file mode 100644 (file)
index 0000000..e3226dd
--- /dev/null
@@ -0,0 +1,19 @@
+//file hello.idl
+[
+       uuid(7a98c250-6808-11cf-b73b-00aa00b677a7),
+       version(1.0)
+]
+interface hello
+{
+
+typedef long CTXTYPE;
+typedef [context_handle] CTXTYPE *PCTXTYPE;
+
+void CtxOpen( [out] PCTXTYPE *pphContext,
+                               [in] long Value);
+
+void CtxHello( [in]  PCTXTYPE phContext );
+
+void CtxClose( [in, out] PCTXTYPE *pphContext );
+
+}
\ No newline at end of file
diff --git a/rostests/win32/rpcrt4/context_handles/ctx_c.c b/rostests/win32/rpcrt4/context_handles/ctx_c.c
new file mode 100644 (file)
index 0000000..69a8bd3
--- /dev/null
@@ -0,0 +1,335 @@
+
+#pragma warning( disable: 4049 )  /* more than 64k source lines */
+
+/* this ALWAYS GENERATED file contains the RPC client stubs */
+
+
+ /* File created by MIDL compiler version 5.03.0280 */
+/* at Fri Mar 24 18:32:16 2006
+ */
+/* Compiler settings for ctx.idl:
+    Os (OptLev=s), W1, Zp8, env=Win32 (32b run), ms_ext, c_ext
+    error checks: allocation ref bounds_check enum stub_data 
+    VC __declspec() decoration level: 
+         __declspec(uuid()), __declspec(selectany), __declspec(novtable)
+         DECLSPEC_UUID(), MIDL_INTERFACE()
+*/
+//@@MIDL_FILE_HEADING(  )
+
+#if !defined(_M_IA64) && !defined(_M_AXP64)
+#include <string.h>
+#if defined( _ALPHA_ )
+#include <stdarg.h>
+#endif
+
+#include "ctx.h"
+
+#define TYPE_FORMAT_STRING_SIZE   23                                
+#define PROC_FORMAT_STRING_SIZE   21                                
+#define TRANSMIT_AS_TABLE_SIZE    0            
+#define WIRE_MARSHAL_TABLE_SIZE   0            
+
+typedef struct _MIDL_TYPE_FORMAT_STRING
+    {
+    short          Pad;
+    unsigned char  Format[ TYPE_FORMAT_STRING_SIZE ];
+    } MIDL_TYPE_FORMAT_STRING;
+
+typedef struct _MIDL_PROC_FORMAT_STRING
+    {
+    short          Pad;
+    unsigned char  Format[ PROC_FORMAT_STRING_SIZE ];
+    } MIDL_PROC_FORMAT_STRING;
+
+
+extern const MIDL_TYPE_FORMAT_STRING __MIDL_TypeFormatString;
+extern const MIDL_PROC_FORMAT_STRING __MIDL_ProcFormatString;
+
+#define GENERIC_BINDING_TABLE_SIZE   0            
+
+
+/* Standard interface: hello, ver. 1.0,
+   GUID={0x7a98c250,0x6808,0x11cf,{0xb7,0x3b,0x00,0xaa,0x00,0xb6,0x77,0xa7}} */
+
+handle_t hBinding;
+
+
+static const RPC_CLIENT_INTERFACE hello___RpcClientInterface =
+    {
+    sizeof(RPC_CLIENT_INTERFACE),
+    {{0x7a98c250,0x6808,0x11cf,{0xb7,0x3b,0x00,0xaa,0x00,0xb6,0x77,0xa7}},{1,0}},
+    {{0x8A885D04,0x1CEB,0x11C9,{0x9F,0xE8,0x08,0x00,0x2B,0x10,0x48,0x60}},{2,0}},
+    0,
+    0,
+    0,
+    0,
+    0,
+    0
+    };
+RPC_IF_HANDLE hello_v1_0_c_ifspec = (RPC_IF_HANDLE)& hello___RpcClientInterface;
+
+extern const MIDL_STUB_DESC hello_StubDesc;
+
+RPC_BINDING_HANDLE hello__MIDL_AutoBindHandle;
+
+
+void CtxOpen( 
+    /* [out] */ PCTXTYPE __RPC_FAR *pphContext,
+    /* [in] */ long Value)
+{
+
+    RPC_BINDING_HANDLE _Handle =       0;
+    
+    RPC_MESSAGE _RpcMessage;
+    
+    MIDL_STUB_MESSAGE _StubMsg;
+    
+    if(!pphContext)
+        {
+        RpcRaiseException(RPC_X_NULL_REF_POINTER);
+        }
+    RpcTryFinally
+        {
+        NdrClientInitializeNew(
+                          ( PRPC_MESSAGE  )&_RpcMessage,
+                          ( PMIDL_STUB_MESSAGE  )&_StubMsg,
+                          ( PMIDL_STUB_DESC  )&hello_StubDesc,
+                          0);
+        
+        
+        _Handle = hBinding;
+        
+        
+        _StubMsg.BufferLength = 4U;
+        NdrGetBuffer( (PMIDL_STUB_MESSAGE) &_StubMsg, _StubMsg.BufferLength, _Handle );
+        
+        *(( long __RPC_FAR * )_StubMsg.Buffer)++ = Value;
+        
+        NdrSendReceive( (PMIDL_STUB_MESSAGE) &_StubMsg, (unsigned char __RPC_FAR *) _StubMsg.Buffer );
+        
+        if ( (_RpcMessage.DataRepresentation & 0X0000FFFFUL) != NDR_LOCAL_DATA_REPRESENTATION )
+            NdrConvert( (PMIDL_STUB_MESSAGE) &_StubMsg, (PFORMAT_STRING) &__MIDL_ProcFormatString.Format[0] );
+        
+        *pphContext = (void *)0;
+        NdrClientContextUnmarshall(
+                              ( PMIDL_STUB_MESSAGE  )&_StubMsg,
+                              ( NDR_CCONTEXT __RPC_FAR * )pphContext,
+                              _Handle);
+        
+        }
+    RpcFinally
+        {
+        NdrFreeBuffer( (PMIDL_STUB_MESSAGE) &_StubMsg );
+        
+        }
+    RpcEndFinally
+    
+}
+
+
+void CtxHello( 
+    /* [in] */ PCTXTYPE phContext)
+{
+
+    RPC_BINDING_HANDLE _Handle =       0;
+    
+    RPC_MESSAGE _RpcMessage;
+    
+    MIDL_STUB_MESSAGE _StubMsg;
+    
+    RpcTryFinally
+        {
+        NdrClientInitializeNew(
+                          ( PRPC_MESSAGE  )&_RpcMessage,
+                          ( PMIDL_STUB_MESSAGE  )&_StubMsg,
+                          ( PMIDL_STUB_DESC  )&hello_StubDesc,
+                          1);
+        
+        
+        if(phContext != 0)
+            {
+            _Handle = NDRCContextBinding(( NDR_CCONTEXT  )phContext);;
+            
+            }
+        else
+            {
+            RpcRaiseException(RPC_X_SS_IN_NULL_CONTEXT);
+            }
+        
+        _StubMsg.BufferLength = 20U;
+        NdrGetBuffer( (PMIDL_STUB_MESSAGE) &_StubMsg, _StubMsg.BufferLength, _Handle );
+        
+        NdrClientContextMarshall(
+                            ( PMIDL_STUB_MESSAGE  )&_StubMsg,
+                            ( NDR_CCONTEXT  )phContext,
+                            1);
+        NdrSendReceive( (PMIDL_STUB_MESSAGE) &_StubMsg, (unsigned char __RPC_FAR *) _StubMsg.Buffer );
+        
+        }
+    RpcFinally
+        {
+        NdrFreeBuffer( (PMIDL_STUB_MESSAGE) &_StubMsg );
+        
+        }
+    RpcEndFinally
+    
+}
+
+
+void CtxClose( 
+    /* [out][in] */ PCTXTYPE __RPC_FAR *pphContext)
+{
+
+    RPC_BINDING_HANDLE _Handle =       0;
+    
+    RPC_MESSAGE _RpcMessage;
+    
+    MIDL_STUB_MESSAGE _StubMsg;
+    
+    if(!pphContext)
+        {
+        RpcRaiseException(RPC_X_NULL_REF_POINTER);
+        }
+    RpcTryFinally
+        {
+        NdrClientInitializeNew(
+                          ( PRPC_MESSAGE  )&_RpcMessage,
+                          ( PMIDL_STUB_MESSAGE  )&_StubMsg,
+                          ( PMIDL_STUB_DESC  )&hello_StubDesc,
+                          2);
+        
+        
+        if(*pphContext != 0)
+            {
+            _Handle = NDRCContextBinding(( NDR_CCONTEXT  )*pphContext);;
+            
+            }
+        
+        _StubMsg.BufferLength = 20U;
+        NdrGetBuffer( (PMIDL_STUB_MESSAGE) &_StubMsg, _StubMsg.BufferLength, _Handle );
+        
+        NdrClientContextMarshall(
+                            ( PMIDL_STUB_MESSAGE  )&_StubMsg,
+                            ( NDR_CCONTEXT  )*pphContext,
+                            0);
+        NdrSendReceive( (PMIDL_STUB_MESSAGE) &_StubMsg, (unsigned char __RPC_FAR *) _StubMsg.Buffer );
+        
+        if ( (_RpcMessage.DataRepresentation & 0X0000FFFFUL) != NDR_LOCAL_DATA_REPRESENTATION )
+            NdrConvert( (PMIDL_STUB_MESSAGE) &_StubMsg, (PFORMAT_STRING) &__MIDL_ProcFormatString.Format[14] );
+        
+        NdrClientContextUnmarshall(
+                              ( PMIDL_STUB_MESSAGE  )&_StubMsg,
+                              ( NDR_CCONTEXT __RPC_FAR * )pphContext,
+                              _Handle);
+        
+        }
+    RpcFinally
+        {
+        NdrFreeBuffer( (PMIDL_STUB_MESSAGE) &_StubMsg );
+        
+        }
+    RpcEndFinally
+    
+}
+
+
+const MIDL_STUB_DESC hello_StubDesc = 
+    {
+    (void __RPC_FAR *)& hello___RpcClientInterface,
+    MIDL_user_allocate,
+    MIDL_user_free,
+    &hBinding,
+    0,
+    0,
+    0,
+    0,
+    __MIDL_TypeFormatString.Format,
+    1, /* -error bounds_check flag */
+    0x10001, /* Ndr library version */
+    0,
+    0x5030118, /* MIDL Version 5.3.280 */
+    0,
+    0,
+    0,  /* notify & notify_flag routine table */
+    0x1, /* MIDL flag */
+    0,  /* Reserved3 */
+    0,  /* Reserved4 */
+    0   /* Reserved5 */
+    };
+
+#if !defined(__RPC_WIN32__)
+#error  Invalid build platform for this stub.
+#endif
+
+const MIDL_PROC_FORMAT_STRING __MIDL_ProcFormatString =
+    {
+        0,
+        {
+                       
+                       0x51,           /* FC_OUT_PARAM */
+#ifndef _ALPHA_
+                       0x1,            /* x86, MIPS & PPC stack size = 1 */
+#else
+                       0x2,            /* Alpha stack size = 2 */
+#endif
+/*  2 */       NdrFcShort( 0x2 ),      /* Type Offset=2 */
+/*  4 */       0x4e,           /* FC_IN_PARAM_BASETYPE */
+                       0x8,            /* FC_LONG */
+/*  6 */       0x5b,           /* FC_END */
+                       0x5c,           /* FC_PAD */
+/*  8 */       
+                       0x4d,           /* FC_IN_PARAM */
+#ifndef _ALPHA_
+                       0x1,            /* x86, MIPS & PPC stack size = 1 */
+#else
+                       0x2,            /* Alpha stack size = 2 */
+#endif
+/* 10 */       NdrFcShort( 0xa ),      /* Type Offset=10 */
+/* 12 */       0x5b,           /* FC_END */
+                       0x5c,           /* FC_PAD */
+/* 14 */       
+                       0x50,           /* FC_IN_OUT_PARAM */
+#ifndef _ALPHA_
+                       0x1,            /* x86, MIPS & PPC stack size = 1 */
+#else
+                       0x2,            /* Alpha stack size = 2 */
+#endif
+/* 16 */       NdrFcShort( 0xe ),      /* Type Offset=14 */
+/* 18 */       0x5b,           /* FC_END */
+                       0x5c,           /* FC_PAD */
+
+                       0x0
+        }
+    };
+
+const MIDL_TYPE_FORMAT_STRING __MIDL_TypeFormatString =
+    {
+        0,
+        {
+                       NdrFcShort( 0x0 ),      /* 0 */
+/*  2 */       
+                       0x11, 0x0,      /* FC_RP */
+/*  4 */       NdrFcShort( 0x2 ),      /* Offset= 2 (6) */
+/*  6 */       0x30,           /* FC_BIND_CONTEXT */
+                       0xa0,           /* Ctxt flags:  via ptr, out, */
+/*  8 */       0x0,            /* 0 */
+                       0x0,            /* 0 */
+/* 10 */       0x30,           /* FC_BIND_CONTEXT */
+                       0x41,           /* Ctxt flags:  in, can't be null */
+/* 12 */       0x0,            /* 0 */
+                       0x0,            /* 0 */
+/* 14 */       
+                       0x11, 0x0,      /* FC_RP */
+/* 16 */       NdrFcShort( 0x2 ),      /* Offset= 2 (18) */
+/* 18 */       0x30,           /* FC_BIND_CONTEXT */
+                       0xe1,           /* Ctxt flags:  via ptr, in, out, can't be null */
+/* 20 */       0x0,            /* 0 */
+                       0x0,            /* 0 */
+
+                       0x0
+        }
+    };
+
+
+#endif /* !defined(_M_IA64) && !defined(_M_AXP64)*/
+
diff --git a/rostests/win32/rpcrt4/context_handles/ctx_s.c b/rostests/win32/rpcrt4/context_handles/ctx_s.c
new file mode 100644 (file)
index 0000000..81e610c
--- /dev/null
@@ -0,0 +1,349 @@
+
+#pragma warning( disable: 4049 )  /* more than 64k source lines */
+
+/* this ALWAYS GENERATED file contains the RPC server stubs */
+
+
+ /* File created by MIDL compiler version 5.03.0280 */
+/* at Fri Mar 24 18:32:16 2006
+ */
+/* Compiler settings for ctx.idl:
+    Os (OptLev=s), W1, Zp8, env=Win32 (32b run), ms_ext, c_ext
+    error checks: allocation ref bounds_check enum stub_data 
+    VC __declspec() decoration level: 
+         __declspec(uuid()), __declspec(selectany), __declspec(novtable)
+         DECLSPEC_UUID(), MIDL_INTERFACE()
+*/
+//@@MIDL_FILE_HEADING(  )
+
+#if !defined(_M_IA64) && !defined(_M_AXP64)
+#include <string.h>
+#include "ctx.h"
+
+#define TYPE_FORMAT_STRING_SIZE   23                                
+#define PROC_FORMAT_STRING_SIZE   21                                
+#define TRANSMIT_AS_TABLE_SIZE    0            
+#define WIRE_MARSHAL_TABLE_SIZE   0            
+
+typedef struct _MIDL_TYPE_FORMAT_STRING
+    {
+    short          Pad;
+    unsigned char  Format[ TYPE_FORMAT_STRING_SIZE ];
+    } MIDL_TYPE_FORMAT_STRING;
+
+typedef struct _MIDL_PROC_FORMAT_STRING
+    {
+    short          Pad;
+    unsigned char  Format[ PROC_FORMAT_STRING_SIZE ];
+    } MIDL_PROC_FORMAT_STRING;
+
+extern const MIDL_TYPE_FORMAT_STRING __MIDL_TypeFormatString;
+extern const MIDL_PROC_FORMAT_STRING __MIDL_ProcFormatString;
+
+/* Standard interface: hello, ver. 1.0,
+   GUID={0x7a98c250,0x6808,0x11cf,{0xb7,0x3b,0x00,0xaa,0x00,0xb6,0x77,0xa7}} */
+
+
+extern RPC_DISPATCH_TABLE hello_v1_0_DispatchTable;
+
+static const RPC_SERVER_INTERFACE hello___RpcServerInterface =
+    {
+    sizeof(RPC_SERVER_INTERFACE),
+    {{0x7a98c250,0x6808,0x11cf,{0xb7,0x3b,0x00,0xaa,0x00,0xb6,0x77,0xa7}},{1,0}},
+    {{0x8A885D04,0x1CEB,0x11C9,{0x9F,0xE8,0x08,0x00,0x2B,0x10,0x48,0x60}},{2,0}},
+    &hello_v1_0_DispatchTable,
+    0,
+    0,
+    0,
+    0,
+    0
+    };
+RPC_IF_HANDLE hello_v1_0_s_ifspec = (RPC_IF_HANDLE)& hello___RpcServerInterface;
+
+extern const MIDL_STUB_DESC hello_StubDesc;
+
+void __RPC_STUB
+hello_CtxOpen(
+    PRPC_MESSAGE _pRpcMessage )
+{
+    long Value;
+    MIDL_STUB_MESSAGE _StubMsg;
+    NDR_SCONTEXT pphContext;
+    RPC_STATUS _Status;
+    
+    ((void)(_Status));
+    NdrServerInitializeNew(
+                          _pRpcMessage,
+                          &_StubMsg,
+                          &hello_StubDesc);
+    
+    ( PCTXTYPE __RPC_FAR * )pphContext = 0;
+    RpcTryFinally
+        {
+        RpcTryExcept
+            {
+            if ( (_pRpcMessage->DataRepresentation & 0X0000FFFFUL) != NDR_LOCAL_DATA_REPRESENTATION )
+                NdrConvert( (PMIDL_STUB_MESSAGE) &_StubMsg, (PFORMAT_STRING) &__MIDL_ProcFormatString.Format[0] );
+            
+            Value = *(( long __RPC_FAR * )_StubMsg.Buffer)++;
+            
+            if(_StubMsg.Buffer > _StubMsg.BufferEnd)
+                {
+                RpcRaiseException(RPC_X_BAD_STUB_DATA);
+                }
+            }
+        RpcExcept( RPC_BAD_STUB_DATA_EXCEPTION_FILTER )
+            {
+            RpcRaiseException(RPC_X_BAD_STUB_DATA);
+            }
+        RpcEndExcept
+        pphContext = NDRSContextUnmarshall( (char *)0, _pRpcMessage->DataRepresentation ); 
+        
+        
+        CtxOpen(( PCTXTYPE __RPC_FAR * )NDRSContextValue(pphContext),Value);
+        
+        _StubMsg.BufferLength = 20U;
+        _pRpcMessage->BufferLength = _StubMsg.BufferLength;
+        
+        _Status = I_RpcGetBuffer( _pRpcMessage ); 
+        if ( _Status )
+            RpcRaiseException( _Status );
+        
+        _StubMsg.Buffer = (unsigned char __RPC_FAR *) _pRpcMessage->Buffer;
+        
+        NdrServerContextMarshall(
+                            ( PMIDL_STUB_MESSAGE  )&_StubMsg,
+                            ( NDR_SCONTEXT  )pphContext,
+                            ( NDR_RUNDOWN  )PCTXTYPE_rundown);
+        
+        }
+    RpcFinally
+        {
+        }
+    RpcEndFinally
+    _pRpcMessage->BufferLength = 
+        (unsigned int)(_StubMsg.Buffer - (unsigned char __RPC_FAR *)_pRpcMessage->Buffer);
+    
+}
+
+void __RPC_STUB
+hello_CtxHello(
+    PRPC_MESSAGE _pRpcMessage )
+{
+    MIDL_STUB_MESSAGE _StubMsg;
+    NDR_SCONTEXT phContext;
+    RPC_STATUS _Status;
+    
+    ((void)(_Status));
+    NdrServerInitializeNew(
+                          _pRpcMessage,
+                          &_StubMsg,
+                          &hello_StubDesc);
+    
+    RpcTryFinally
+        {
+        RpcTryExcept
+            {
+            if ( (_pRpcMessage->DataRepresentation & 0X0000FFFFUL) != NDR_LOCAL_DATA_REPRESENTATION )
+                NdrConvert( (PMIDL_STUB_MESSAGE) &_StubMsg, (PFORMAT_STRING) &__MIDL_ProcFormatString.Format[8] );
+            
+            phContext = NdrServerContextUnmarshall(( PMIDL_STUB_MESSAGE  )&_StubMsg);
+            
+            if(_StubMsg.Buffer > _StubMsg.BufferEnd)
+                {
+                RpcRaiseException(RPC_X_BAD_STUB_DATA);
+                }
+            }
+        RpcExcept( RPC_BAD_STUB_DATA_EXCEPTION_FILTER )
+            {
+            RpcRaiseException(RPC_X_BAD_STUB_DATA);
+            }
+        RpcEndExcept
+        
+        CtxHello(( PCTXTYPE  )*NDRSContextValue(phContext));
+        
+        }
+    RpcFinally
+        {
+        }
+    RpcEndFinally
+    _pRpcMessage->BufferLength = 
+        (unsigned int)(_StubMsg.Buffer - (unsigned char __RPC_FAR *)_pRpcMessage->Buffer);
+    
+}
+
+void __RPC_STUB
+hello_CtxClose(
+    PRPC_MESSAGE _pRpcMessage )
+{
+    MIDL_STUB_MESSAGE _StubMsg;
+    NDR_SCONTEXT pphContext;
+    RPC_STATUS _Status;
+    
+    ((void)(_Status));
+    NdrServerInitializeNew(
+                          _pRpcMessage,
+                          &_StubMsg,
+                          &hello_StubDesc);
+    
+    ( PCTXTYPE __RPC_FAR * )pphContext = 0;
+    RpcTryFinally
+        {
+        RpcTryExcept
+            {
+            if ( (_pRpcMessage->DataRepresentation & 0X0000FFFFUL) != NDR_LOCAL_DATA_REPRESENTATION )
+                NdrConvert( (PMIDL_STUB_MESSAGE) &_StubMsg, (PFORMAT_STRING) &__MIDL_ProcFormatString.Format[14] );
+            
+            pphContext = NdrServerContextUnmarshall(( PMIDL_STUB_MESSAGE  )&_StubMsg);
+            
+            if(_StubMsg.Buffer > _StubMsg.BufferEnd)
+                {
+                RpcRaiseException(RPC_X_BAD_STUB_DATA);
+                }
+            }
+        RpcExcept( RPC_BAD_STUB_DATA_EXCEPTION_FILTER )
+            {
+            RpcRaiseException(RPC_X_BAD_STUB_DATA);
+            }
+        RpcEndExcept
+        
+        CtxClose(( PCTXTYPE __RPC_FAR * )NDRSContextValue(pphContext));
+        
+        _StubMsg.BufferLength = 20U;
+        _pRpcMessage->BufferLength = _StubMsg.BufferLength;
+        
+        _Status = I_RpcGetBuffer( _pRpcMessage ); 
+        if ( _Status )
+            RpcRaiseException( _Status );
+        
+        _StubMsg.Buffer = (unsigned char __RPC_FAR *) _pRpcMessage->Buffer;
+        
+        NdrServerContextMarshall(
+                            ( PMIDL_STUB_MESSAGE  )&_StubMsg,
+                            ( NDR_SCONTEXT  )pphContext,
+                            ( NDR_RUNDOWN  )PCTXTYPE_rundown);
+        
+        }
+    RpcFinally
+        {
+        }
+    RpcEndFinally
+    _pRpcMessage->BufferLength = 
+        (unsigned int)(_StubMsg.Buffer - (unsigned char __RPC_FAR *)_pRpcMessage->Buffer);
+    
+}
+
+
+static const MIDL_STUB_DESC hello_StubDesc = 
+    {
+    (void __RPC_FAR *)& hello___RpcServerInterface,
+    MIDL_user_allocate,
+    MIDL_user_free,
+    0,
+    0,
+    0,
+    0,
+    0,
+    __MIDL_TypeFormatString.Format,
+    1, /* -error bounds_check flag */
+    0x10001, /* Ndr library version */
+    0,
+    0x5030118, /* MIDL Version 5.3.280 */
+    0,
+    0,
+    0,  /* notify & notify_flag routine table */
+    0x1, /* MIDL flag */
+    0,  /* Reserved3 */
+    0,  /* Reserved4 */
+    0   /* Reserved5 */
+    };
+
+static RPC_DISPATCH_FUNCTION hello_table[] =
+    {
+    hello_CtxOpen,
+    hello_CtxHello,
+    hello_CtxClose,
+    0
+    };
+RPC_DISPATCH_TABLE hello_v1_0_DispatchTable = 
+    {
+    3,
+    hello_table
+    };
+
+#if !defined(__RPC_WIN32__)
+#error  Invalid build platform for this stub.
+#endif
+
+static const MIDL_PROC_FORMAT_STRING __MIDL_ProcFormatString =
+    {
+        0,
+        {
+                       
+                       0x51,           /* FC_OUT_PARAM */
+#ifndef _ALPHA_
+                       0x1,            /* x86, MIPS & PPC stack size = 1 */
+#else
+                       0x2,            /* Alpha stack size = 2 */
+#endif
+/*  2 */       NdrFcShort( 0x2 ),      /* Type Offset=2 */
+/*  4 */       0x4e,           /* FC_IN_PARAM_BASETYPE */
+                       0x8,            /* FC_LONG */
+/*  6 */       0x5b,           /* FC_END */
+                       0x5c,           /* FC_PAD */
+/*  8 */       
+                       0x4d,           /* FC_IN_PARAM */
+#ifndef _ALPHA_
+                       0x1,            /* x86, MIPS & PPC stack size = 1 */
+#else
+                       0x2,            /* Alpha stack size = 2 */
+#endif
+/* 10 */       NdrFcShort( 0xa ),      /* Type Offset=10 */
+/* 12 */       0x5b,           /* FC_END */
+                       0x5c,           /* FC_PAD */
+/* 14 */       
+                       0x50,           /* FC_IN_OUT_PARAM */
+#ifndef _ALPHA_
+                       0x1,            /* x86, MIPS & PPC stack size = 1 */
+#else
+                       0x2,            /* Alpha stack size = 2 */
+#endif
+/* 16 */       NdrFcShort( 0xe ),      /* Type Offset=14 */
+/* 18 */       0x5b,           /* FC_END */
+                       0x5c,           /* FC_PAD */
+
+                       0x0
+        }
+    };
+
+static const MIDL_TYPE_FORMAT_STRING __MIDL_TypeFormatString =
+    {
+        0,
+        {
+                       NdrFcShort( 0x0 ),      /* 0 */
+/*  2 */       
+                       0x11, 0x0,      /* FC_RP */
+/*  4 */       NdrFcShort( 0x2 ),      /* Offset= 2 (6) */
+/*  6 */       0x30,           /* FC_BIND_CONTEXT */
+                       0xa0,           /* Ctxt flags:  via ptr, out, */
+/*  8 */       0x0,            /* 0 */
+                       0x0,            /* 0 */
+/* 10 */       0x30,           /* FC_BIND_CONTEXT */
+                       0x41,           /* Ctxt flags:  in, can't be null */
+/* 12 */       0x0,            /* 0 */
+                       0x0,            /* 0 */
+/* 14 */       
+                       0x11, 0x0,      /* FC_RP */
+/* 16 */       NdrFcShort( 0x2 ),      /* Offset= 2 (18) */
+/* 18 */       0x30,           /* FC_BIND_CONTEXT */
+                       0xe1,           /* Ctxt flags:  via ptr, in, out, can't be null */
+/* 20 */       0x0,            /* 0 */
+                       0x0,            /* 0 */
+
+                       0x0
+        }
+    };
+
+
+#endif /* !defined(_M_IA64) && !defined(_M_AXP64)*/
+
diff --git a/rostests/win32/rpcrt4/context_handles/server.c b/rostests/win32/rpcrt4/context_handles/server.c
new file mode 100644 (file)
index 0000000..66f048f
--- /dev/null
@@ -0,0 +1,78 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <ctype.h>
+#include "ctx.h"
+
+void CtxOpen( PCTXTYPE *pphContext,
+        long Value)
+{
+       printf("CtxOpen(): Value=%d\n",Value);
+       *pphContext = (PCTXTYPE)midl_user_allocate( sizeof(CTXTYPE) );
+       **pphContext = Value;
+}
+
+void CtxHello( PCTXTYPE phContext )
+{
+       printf("CtxHello(): Hello, World! Context value: %d\n", *phContext);
+}
+
+void CtxClose(PCTXTYPE *pphContext )
+{
+       printf("CtxClose(): %d\n", **pphContext);
+       midl_user_free(*pphContext);
+       *pphContext = NULL;
+}
+
+
+void main()
+{
+       RPC_STATUS status;
+       unsigned int    cMinCalls      = 1;
+       unsigned int    cMaxCalls      = 20;
+       int i;
+
+       status = RpcServerUseProtseqEp("ncacn_np", 20, "\\pipe\\hello", NULL);
+
+       if (status) 
+       {
+               printf("RpcServerUseProtseqEp %x\n", status);
+               exit(status);
+       }
+
+       status = RpcServerRegisterIf(hello_v1_0_s_ifspec, NULL, NULL);
+
+       if (status) 
+       {
+               printf("RpcServerRegisterIf %x\n", status);
+       exit(status);
+       }
+
+       status = RpcServerListen(1, 20, FALSE);
+
+       if (status) 
+       {
+               printf("RpcServerListen %x", status);
+               exit(status);
+       }
+
+       scanf("%d", &i);
+}
+
+
+void __RPC_USER PCTXTYPE_rundown(
+    PCTXTYPE hContext)
+{
+       PCTXTYPE pCtx = (PCTXTYPE)hContext;
+    printf("Context rundown: Value=%d \n", *pCtx);
+    midl_user_free(hContext);
+}
+
+void __RPC_FAR * __RPC_USER midl_user_allocate(size_t len)
+{
+       return(malloc(len));
+}
+void __RPC_USER midl_user_free(void __RPC_FAR * ptr)
+{
+       free(ptr);
+}
diff --git a/rostests/win32/smss/movefile/movefile.cpp b/rostests/win32/smss/movefile/movefile.cpp
new file mode 100644 (file)
index 0000000..447c389
--- /dev/null
@@ -0,0 +1,235 @@
+/*
+ * PROJECT:         ReactOS Test applications
+ * LICENSE:         GPL - See COPYING in the top level directory
+ * FILE:            base/applications/testsets/smss/movefile.cpp
+ * PURPOSE:         Provides testing for the "move file after reboot"
+ *                  function of smss.exe/kernel32.dll
+ * PROGRAMMERS:     Dmitriy Philippov (shedon@mail.ru)
+ */
+
+
+#define WIN32_LEAN_AND_MEAN            // Exclude rarely-used stuff from Windows headers
+#include "windows.h"
+#include <stdio.h>
+#include <tchar.h>
+#include "stdlib.h"
+#include "string.h"
+
+
+void Usage()
+{
+       printf(" Usage: smssTest.exe -g|c|s|d \n \
+                       g - generate test files \n \
+                       c - check files after reboot \n \
+                       s - show registry entry \n \
+                       d - delete registry value \n");
+}
+
+int ShowRegValue()
+{
+       BYTE lpBuff[255];
+       memset(lpBuff, 0, sizeof(lpBuff));
+
+       DWORD lSize = sizeof(lpBuff);
+       HKEY hKey;
+       LONG retValue;
+       // test registry entry
+       retValue = RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Control\\Session Manager", 0, KEY_QUERY_VALUE, &hKey);
+       if( ERROR_SUCCESS != retValue ) {
+               printf("RegOpenKeyEx err=%ld \n", retValue);
+               return 1;
+       }
+
+       retValue = RegQueryValueEx(hKey, "PendingFileRenameOperations", NULL, NULL, lpBuff, &lSize);
+       if( ERROR_SUCCESS != retValue ) {
+               printf("RegQueryValueEx err=%ld \n", retValue);
+               lSize = 0;
+       }
+
+       printf("reg data: \n");
+       for(UINT i=0; i<lSize; i++) {
+               printf("%c", lpBuff[i]);
+       }
+       printf("\n");
+
+       RegCloseKey(hKey);
+
+       return 0;
+}
+
+int DeleteValue()
+{
+       HKEY hKey;
+       LONG retValue;
+       // test registry entry
+       retValue = RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Control\\Session Manager", 0, KEY_SET_VALUE, &hKey);
+       if( ERROR_SUCCESS != retValue ) {
+               printf("RegOpenKeyEx err=%ld \n", retValue);
+               return 1;
+       }
+
+       retValue = RegDeleteValue(hKey, "PendingFileRenameOperations");
+       if( ERROR_SUCCESS != retValue ) {
+               printf("RegDeleteValue err=%ld \n", retValue);
+       }
+
+       RegCloseKey(hKey);
+
+       return 0;
+}
+
+int Generate()
+{
+       char sBuf[255];
+       DWORD dwSize;
+       HANDLE hFile = NULL;
+       BOOL fReturnValue;
+
+       const char szxReplacedFile[] = "c:\\testFileIsReplaced";
+       const char szxMovedFileWithRepl[] = "c:\\testFileShouldBeMovedW";
+       const char szxMovedFile[] = "c:\\testFileShouldBeMoved";
+       const char szxNewMovedFile[] = "c:\\testFileIsMoved";
+       const char szxDeletedFile[] = "c:\\testFileShouldBeDeleted";
+
+       memset(sBuf, 0xaa, sizeof(sBuf));
+
+       // create the first file for moving
+       hFile = CreateFile(
+               szxMovedFile,
+               FILE_ALL_ACCESS,
+               0,
+               NULL,
+               CREATE_ALWAYS,
+               FILE_ATTRIBUTE_NORMAL,
+               NULL);
+       if(NULL == hFile) {
+               printf("Can't create the %s file, err=%ld \n", szxMovedFile, GetLastError());
+               return 1;
+       }
+       WriteFile(hFile, sBuf, sizeof(sBuf), &dwSize, NULL);
+       CloseHandle(hFile);
+
+       // create the second file for removing
+       hFile = CreateFile(
+               szxDeletedFile,
+               FILE_ALL_ACCESS,
+               0,
+               NULL,
+               CREATE_ALWAYS,
+               FILE_ATTRIBUTE_NORMAL,
+               NULL);
+       if(NULL == hFile) {
+               printf("Can't create the %s file, err=%ld \n", szxDeletedFile, GetLastError());
+               return 1;
+       }
+       WriteFile(hFile, sBuf, sizeof(sBuf), &dwSize, NULL);
+       CloseHandle(hFile);
+
+       hFile = CreateFile(
+               szxReplacedFile,
+               FILE_ALL_ACCESS,
+               0,
+               NULL,
+               CREATE_ALWAYS,
+               FILE_ATTRIBUTE_NORMAL,
+               NULL);
+       if(NULL == hFile) {
+               printf("Can't create the %s file, err=%ld \n", szxReplacedFile, GetLastError());
+               return 1;
+       }
+       WriteFile(hFile, sBuf, sizeof(sBuf), &dwSize, NULL);
+       CloseHandle(hFile);
+
+       
+       hFile = CreateFile(
+               szxMovedFileWithRepl,
+               FILE_ALL_ACCESS,
+               0,
+               NULL,
+               CREATE_ALWAYS,
+               FILE_ATTRIBUTE_NORMAL,
+               NULL);
+       if(NULL == hFile) {
+               printf("Can't create the %s file, err=%ld \n", szxMovedFileWithRepl, GetLastError());
+               return 1;
+       }
+       WriteFile(hFile, sBuf, sizeof(sBuf), &dwSize, NULL);
+       CloseHandle(hFile);
+
+
+       fReturnValue = MoveFileEx(
+               szxDeletedFile,
+               NULL,
+               MOVEFILE_DELAY_UNTIL_REBOOT);
+       if( !fReturnValue ) {
+               printf("Can't move the %s file, err=%ld \n", szxDeletedFile, GetLastError());
+               return 1;
+       }
+
+       ShowRegValue();
+
+       fReturnValue = MoveFileEx(
+               szxMovedFile,
+               szxNewMovedFile,
+               MOVEFILE_DELAY_UNTIL_REBOOT);
+       if( !fReturnValue ) {
+               printf("Can't move the %s file, err=%ld \n", szxMovedFile, GetLastError());
+               return 1;
+       }
+
+       ShowRegValue();
+
+       fReturnValue = MoveFileEx(
+               szxMovedFileWithRepl,
+               szxReplacedFile,
+               MOVEFILE_DELAY_UNTIL_REBOOT|MOVEFILE_REPLACE_EXISTING);
+       if( !fReturnValue ) {
+               printf("Can't move the %s file, err=%ld \n", szxMovedFileWithRepl, GetLastError());
+               return 1;
+       }
+
+       ShowRegValue();
+
+       return 0;
+}
+
+int Check()
+{
+       return 0;
+}
+
+int _tmain(int argc, _TCHAR* argv[])
+{
+       if( argc<2 ) {
+               Usage();
+               return 1;
+       }
+
+       if( 0 == strncmp(argv[1], "-g", 2)  )
+       {
+               // generate test files and registry values
+               return Generate();
+       }
+       else if( 0 == strncmp(argv[1], "-c", 2) )
+       {
+               // check generated files
+               return Check();
+       }
+       else if( 0 == strncmp(argv[1], "-s", 2) )
+       {
+               // 
+               return ShowRegValue();
+       }
+       else if( 0 == strncmp(argv[1], "-d", 2) )
+       {
+               return DeleteValue();
+       }
+       else
+       {
+               Usage();
+               return 1;
+       }
+
+       return 0;
+}
+
diff --git a/rostests/win32/smss/movefile/movefile.rbuild b/rostests/win32/smss/movefile/movefile.rbuild
new file mode 100644 (file)
index 0000000..84c400f
--- /dev/null
@@ -0,0 +1,12 @@
+<module name="movefile" type="win32cui" installbase="system32" installname="movefiletest.exe">
+       <include base="movefile">.</include>
+       <define name="__USE_W32API" />
+       <define name="_WIN32_IE">0x0500</define>
+       <define name="_WIN32_WINNT">0x0600</define>
+       <define name="WINVER">0x0600</define>
+       <library>kernel32</library>
+       <library>advapi32</library>
+       <library>user32</library>
+       <file>movefile.cpp</file>
+       <file>movefile.rc</file>
+</module>
\ No newline at end of file
diff --git a/rostests/win32/smss/movefile/movefile.rc b/rostests/win32/smss/movefile/movefile.rc
new file mode 100644 (file)
index 0000000..77fc4ab
--- /dev/null
@@ -0,0 +1,9 @@
+#include <windows.h>
+#include "resource.h"
+
+#define REACTOS_STR_FILE_DESCRIPTION   "ReactOS Move File after reboot test\0"
+#define REACTOS_STR_INTERNAL_NAME      "movefiletest\0"
+#define REACTOS_STR_ORIGINAL_FILENAME  "movefiletest.exe\0"
+#include <reactos/version.rc>
+
+
diff --git a/rostests/win32/smss/smss.rbuild b/rostests/win32/smss/smss.rbuild
new file mode 100644 (file)
index 0000000..20ff30e
--- /dev/null
@@ -0,0 +1,7 @@
+<?xml version="1.0"?>
+<!DOCTYPE project SYSTEM "tools/rbuild/project.dtd">
+<group>
+<directory name="movefile">
+       <xi:include href="movefile/movefile.rbuild" />
+</directory>
+</group>
diff --git a/rostests/win32/testsets.rbuild b/rostests/win32/testsets.rbuild
new file mode 100644 (file)
index 0000000..745c4b5
--- /dev/null
@@ -0,0 +1,10 @@
+<?xml version="1.0"?>
+<!DOCTYPE project SYSTEM "tools/rbuild/project.dtd">
+<group>
+<directory name="smss">
+       <xi:include href="smss/smss.rbuild" />
+</directory>
+<directory name="user32">
+       <xi:include href="user32/user32.rbuild" />
+</directory>
+</group>
diff --git a/rostests/win32/user32/drawcaption/capicon.c b/rostests/win32/user32/drawcaption/capicon.c
new file mode 100644 (file)
index 0000000..31bec73
--- /dev/null
@@ -0,0 +1,145 @@
+/* 
+ *  Copyright 2006 Saveliy Tretiakov
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program 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 General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include "windows.h"
+#include "stdio.h"
+#include "resource.h"
+
+WCHAR WndClass[] = L"capicon_class";
+
+HINSTANCE hInst;
+INT testnum = 0;
+
+
+LRESULT CALLBACK WndProc(HWND hWnd, 
+                                                        UINT msg, 
+                                                        WPARAM wParam, 
+                                                        LPARAM lParam)
+{      
+   HICON hIcon;
+       
+       switch (msg)
+       {
+          case WM_GETICON:
+             if(testnum>2)
+             {
+                if(wParam == ICON_SMALL)
+                   hIcon = LoadIcon(hInst, MAKEINTRESOURCE(ID_ICON2SM));
+                else if(wParam == ICON_BIG)
+                   hIcon = LoadIcon(hInst, MAKEINTRESOURCE(ID_ICON2BIG));
+                else hIcon = (HICON)1;
+             
+                if(!hIcon)
+                {
+                   printf("LoadIcon() failed: %d\n", (INT)GetLastError());
+                   break;
+                }
+             
+                return (LRESULT)hIcon;
+             }
+             break;
+       
+       case WM_DESTROY:
+                       PostQuitMessage(0);
+                       return 0;
+       }
+
+       return DefWindowProc(hWnd, msg, wParam, lParam);
+}
+
+
+INT main(INT argc, CHAR **argv)
+{
+       HWND hWnd;
+       MSG msg;
+       WNDCLASSEX wcx;
+       UINT result;
+
+       if(argc<2)
+       {
+               printf("DrawCaption icon test.\n");
+               printf("USAGE: drawcap.exe <testnumber>\n\n");
+               printf("Available tests:\n"
+                       "1. Class small icon\n"
+                       "2. Class big icon\n"
+                       "3. Class small icon + WM_GETICON\n"
+                       "4. Class big icon + WM_GETICON\n"
+                       "5. WM_GETICON only\n\n");
+               return 0;
+       }
+       
+       testnum = atoi(argv[1]);
+       if(testnum < 1 || testnum > 5)
+       {
+               printf("Unknown test %d\n", testnum);
+               return 1;
+       }
+       
+       hInst = GetModuleHandle(NULL);
+       
+       memset(&wcx, 0, sizeof(wcx));
+       wcx.cbSize = sizeof(wcx);
+       wcx.style = CS_HREDRAW | CS_VREDRAW;
+       wcx.lpfnWndProc = (WNDPROC) WndProc;
+       wcx.hInstance = hInst;
+       wcx.hbrBackground = (HBRUSH)COLOR_WINDOW;
+       wcx.lpszClassName = WndClass;
+       if(testnum<5)wcx.hIcon = LoadIcon(hInst, MAKEINTRESOURCE(ID_ICON1BIG));
+       if(testnum == 1 || testnum == 3)
+          wcx.hIconSm = LoadIcon(hInst, MAKEINTRESOURCE(ID_ICON1SM));
+       
+       if(!(result = RegisterClassEx(&wcx)))
+       {
+               printf("Shit! RegisterClassEx failed: %d\n", 
+                       (int)GetLastError());
+               return 1;
+       }
+       
+       hWnd = CreateWindowEx(0, 
+                               WndClass, 
+                               L"DrawCaption icon test",
+                               WS_OVERLAPPED|WS_THICKFRAME|WS_SYSMENU,
+                               CW_USEDEFAULT,
+                               CW_USEDEFAULT,
+                               250,
+                               100,
+                               NULL,
+                               0,
+                               hInst,
+                               NULL);
+       
+       if(!hWnd)
+       {
+               printf("Shit! Can't create wnd!\n");
+               UnregisterClass(WndClass, hInst);
+               return 1;
+       }
+       
+       
+       ShowWindow(hWnd, SW_SHOW); 
+       UpdateWindow(hWnd);  
+
+       while(GetMessage(&msg, NULL, 0, 0 ))
+       {
+               TranslateMessage(&msg); 
+               DispatchMessage(&msg); 
+       } 
+
+       UnregisterClass(WndClass, hInst);
+       return 0;
+}
diff --git a/rostests/win32/user32/drawcaption/capicon.rc b/rostests/win32/user32/drawcaption/capicon.rc
new file mode 100644 (file)
index 0000000..0cb31e4
--- /dev/null
@@ -0,0 +1,13 @@
+#include <windows.h>
+#include "resource.h"
+
+#define REACTOS_STR_FILE_DESCRIPTION   "ReactOS DrawCaption icon test\0"
+#define REACTOS_STR_INTERNAL_NAME      "capicon\0"
+#define REACTOS_STR_ORIGINAL_FILENAME  "capicon.exe\0"
+#include <reactos/version.rc>
+
+ID_ICON1BIG ICON res\icon1big.ico
+ID_ICON1SM  ICON res\icon1sm.ico
+ID_ICON2BIG ICON res\icon2big.ico
+ID_ICON2SM  ICON res\icon2sm.ico
+
diff --git a/rostests/win32/user32/drawcaption/drawcap.c b/rostests/win32/user32/drawcaption/drawcap.c
new file mode 100644 (file)
index 0000000..b6036d8
--- /dev/null
@@ -0,0 +1,289 @@
+/* 
+ *  Copyright 2006 Saveliy Tretiakov
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program 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 General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include "windows.h"
+#include "resource.h"
+#include "stdio.h"
+
+WCHAR CaptWndClass[] = L"captwnd_class";
+
+HINSTANCE hInst;
+INT testnum = 0;
+
+//BOOL STDCALL (*DrawCaptionTemp) (
+//              HWND        hwnd,
+//              HDC         hdc,
+//              const RECT *rect,
+//              HFONT       hFont,
+//              HICON       hIcon,
+//              LPCWSTR     str,
+//              UINT        uFlags);
+
+VOID CapTest(HWND hWnd, 
+       HDC hDc, 
+       LPRECT pR, 
+       WCHAR *Text, 
+       DWORD Flags,
+       WCHAR *AddonStr,
+       DWORD Addon)
+{
+       WCHAR Buf[512];
+       
+       lstrcpy(Buf, AddonStr);
+       if(lstrlen(Buf))lstrcat(Buf, L" | ");
+       lstrcat(Buf, Text);
+       
+       DrawText( hDc, Buf, lstrlen(Buf), pR, DT_LEFT );  
+       
+       pR->top+=20;
+       pR->bottom+=20; 
+               
+       if(!DrawCaption(hWnd, hDc, pR, Flags | Addon))
+       {
+               printf("PAINT: DrawCaption failed: %d\n", (int)GetLastError());
+       }
+
+       pR->top+=30;
+       pR->bottom+=30; 
+}
+
+VOID DrawCaptionTest(HWND hWnd, HDC hDc, WCHAR *AddonStr, DWORD Addon)
+{
+       RECT Rect;
+       GetClientRect(hWnd, &Rect);
+       Rect.bottom = 30;
+       Rect.left = 10;
+       Rect.right-=10;
+       Rect.top = 10;
+
+       CapTest(hWnd, hDc, &Rect, L"DC_TEXT:", DC_TEXT, AddonStr, Addon); 
+       
+       CapTest(hWnd, hDc, &Rect, 
+               L"DC_TEXT | DC_ACTIVE:", 
+               DC_TEXT | DC_ACTIVE, 
+               AddonStr, Addon); 
+       
+       CapTest(hWnd, hDc, &Rect, 
+               L"DC_TEXT | DC_ICON:" , 
+               DC_TEXT | DC_ICON, 
+               AddonStr, Addon);
+        
+       CapTest(hWnd, hDc, &Rect, 
+               L"DC_TEXT | DC_ACTIVE | DC_ICON:" , 
+               DC_TEXT | DC_ACTIVE | DC_ICON, 
+               AddonStr, Addon); 
+
+       CapTest(hWnd, hDc, &Rect, 
+               L"DC_TEXT | DC_INBUTTON:" , 
+               DC_TEXT | DC_INBUTTON, 
+               AddonStr, Addon);
+        
+       CapTest(hWnd, hDc, &Rect, 
+               L"DC_TEXT | DC_ACTIVE | DC_INBUTTON:" , 
+               DC_TEXT | DC_ACTIVE | DC_INBUTTON, 
+               AddonStr, Addon); 
+                               
+       CapTest(hWnd, hDc, &Rect, 
+               L"DC_TEXT | DC_ICON | DC_INBUTTON:" , 
+               DC_TEXT | DC_ICON | DC_INBUTTON, 
+               AddonStr, Addon);
+        
+       CapTest(hWnd, hDc, &Rect, 
+               L"DC_TEXT | DC_ACTIVE | DC_ICON | DC_INBUTTON:" ,
+               DC_TEXT | DC_ACTIVE | DC_ICON | DC_INBUTTON, 
+               AddonStr, Addon);                       
+
+}
+
+LRESULT CALLBACK CaptWndProc(HWND hWnd, 
+                                                        UINT msg, 
+                                                        WPARAM wParam, 
+                                                        LPARAM lParam)
+{      
+
+       
+       switch (msg)
+       {
+
+               case WM_PAINT:
+               {
+                       HDC hDc;
+                       PAINTSTRUCT Ps;
+                       
+                       hDc = BeginPaint(hWnd, &Ps);
+                       SetBkMode( hDc, TRANSPARENT );
+                       
+                       switch(testnum)
+                       {
+                       case 1:
+                               DrawCaptionTest(hWnd, hDc, L"", 0);
+                               break;
+                       case 2:
+                               DrawCaptionTest(hWnd, hDc, L"DC_GRADIENT", DC_GRADIENT);
+                               break;
+                       case 3:
+                               DrawCaptionTest(hWnd, hDc, L"DC_SMALLCAP", DC_SMALLCAP);
+                               break;
+                       case 4:
+                               DrawCaptionTest(hWnd, hDc, L"DC_BUTTONS", DC_BUTTONS);
+                               break;
+                       case 5:
+                               DrawCaptionTest(hWnd, hDc, 
+                                       L"DC_GRADIENT | DC_SMALLCAP", 
+                                       DC_GRADIENT | DC_SMALLCAP);
+                               break;
+                       case 6:
+                               DrawCaptionTest(hWnd, hDc, 
+                                       L"DC_GRADIENT | DC_BUTTONS", 
+                                       DC_GRADIENT | DC_BUTTONS);
+                               break;
+                       case 7: 
+                               DrawCaptionTest(hWnd, hDc, 
+                                       L"DC_BUTTONS | DC_SMALLCAP", 
+                                       DC_BUTTONS | DC_SMALLCAP);
+                               break;
+                       case 8:
+                               DrawCaptionTest(hWnd, hDc, 
+                                       L"DC_BUTTONS | DC_SMALLCAP | DC_GRADIENT", 
+                                       DC_BUTTONS | DC_SMALLCAP | DC_GRADIENT);
+                               break;
+                       }
+                       
+                       EndPaint(hWnd, &Ps);
+               
+                       return 0;
+               }
+
+               case WM_DESTROY:
+               {
+                       PostQuitMessage(0);
+                       return 0;
+               }
+       }
+
+       return DefWindowProc(hWnd, msg, wParam, lParam);
+}
+
+
+INT main(INT argc, CHAR **argv)
+{
+       HWND hWnd;
+       MSG msg;
+       WNDCLASSEX wcx;
+       UINT result;
+       HBRUSH hBr;
+       //HMODULE hLib;
+       
+       if(argc<2)
+       {
+               printf("DrawCaption testcode.\n");
+               printf("USAGE: drawcap.exe <testnumber> [useicon]\n\n");
+               printf("Available tests:\n"
+                       "1. DrawCaption test\n"
+                       "2. DrawCaption test + DC_GRADIENT\n"
+                       "3. DrawCaption test + DC_SMALLCAP\n"
+                       "4. DrawCaption test + DC_BUTTONS\n"
+                       "5. DrawCaption test + DC_GRADIENT | DC_SMALLCAP\n"
+                       "6. DrawCaption test + DC_GRADIENT | DC_BUTTONS\n"
+                       "7. DrawCaption test + DC_BUTTONS | DC_SMALLCAP\n"
+                       "8. DrawCaption test + DC_BUTTONS | DC_SMALLCAP | DC_GRADIENT\n\n");
+               return 0;
+       }
+       
+       testnum = atoi(argv[1]);
+       if(testnum < 1 || testnum > 8)
+       {
+               printf("Unknown test %d\n", testnum);
+               return 1;
+       }
+               
+       hInst = GetModuleHandle(NULL);
+       
+       //hLib = LoadLibrary(L"user32");
+       //if(!hLib)
+       //{
+       //      printf("Shit! Can't load user32.dll\n");
+       //      return 1;
+       //}
+       
+       //DrawCaptionTemp = GetProcAddress(hLib, "DrawCaptionTempW");
+       //if(!DrawCaptionTemp)
+       //{
+       //      printf("Shit! Can't get DrawCaptionTemp address\n");
+       //      return 1;
+       //}
+       
+       hBr = CreateSolidBrush(RGB(255, 255, 255));
+       if(!hBr)
+       {
+               printf("Shit! Can't create brush.");
+               return 1;
+       }
+       
+       memset(&wcx, 0, sizeof(wcx));
+       wcx.cbSize = sizeof(wcx);
+       wcx.style = CS_HREDRAW | CS_VREDRAW;
+       wcx.lpfnWndProc = (WNDPROC) CaptWndProc;
+       wcx.hInstance = hInst;
+       wcx.hbrBackground = hBr;
+       wcx.lpszClassName = CaptWndClass;
+       if(argc > 2) wcx.hIconSm = LoadIcon(hInst, MAKEINTRESOURCE(ID_ICON1SM));
+       
+       if(!(result = RegisterClassEx(&wcx)))
+       {
+               printf("Shit! RegisterClassEx failed: %d\n", 
+                       (int)GetLastError());
+               DeleteObject(hBr);
+               return 1;
+       }
+       
+       hWnd = CreateWindowEx(0, 
+                               CaptWndClass, 
+                               L"DrawCaption test",
+                               WS_OVERLAPPED|WS_THICKFRAME|WS_SYSMENU,
+                               CW_USEDEFAULT,
+                               CW_USEDEFAULT,
+                               600,
+                               470,
+                               NULL,
+                               0,
+                               hInst,
+                               NULL);
+       
+       if(!hWnd)
+       {
+               printf("Shit! Can't create wnd!\n");
+               UnregisterClass(CaptWndClass, hInst);
+               DeleteObject(hBr);
+               return 1;
+       }
+       
+       
+       ShowWindow(hWnd, SW_SHOW); 
+       UpdateWindow(hWnd);  
+
+       while(GetMessage(&msg, NULL, 0, 0 ))
+       {
+               TranslateMessage(&msg); 
+               DispatchMessage(&msg); 
+       } 
+
+       DeleteObject(hBr);
+       UnregisterClass(CaptWndClass, hInst);
+       return 0;
+}
diff --git a/rostests/win32/user32/drawcaption/drawcap.rc b/rostests/win32/user32/drawcaption/drawcap.rc
new file mode 100644 (file)
index 0000000..c7f3270
--- /dev/null
@@ -0,0 +1,11 @@
+#include <windows.h>
+#include "resource.h"
+
+#define REACTOS_STR_FILE_DESCRIPTION   "ReactOS DrawCaption test\0"
+#define REACTOS_STR_INTERNAL_NAME      "drawcap\0"
+#define REACTOS_STR_ORIGINAL_FILENAME  "drawcap.exe\0"
+#include <reactos/version.rc>
+
+ID_ICON1SM  ICON res\icon1sm.ico
+
+
diff --git a/rostests/win32/user32/drawcaption/drawcaption.rbuild b/rostests/win32/user32/drawcaption/drawcaption.rbuild
new file mode 100644 (file)
index 0000000..9593d20
--- /dev/null
@@ -0,0 +1,29 @@
+<module name="drawcap" type="win32cui" installbase="system32" installname="drawcap.exe">
+       <include base="drawcap">.</include>
+       <define name="__USE_W32API" />
+       <define name="UNICODE" />
+       <define name="_UNICODE" />
+       <define name="_WIN32_IE">0x0500</define>
+       <define name="_WIN32_WINNT">0x0600</define>
+       <define name="WINVER">0x0600</define>
+       <library>kernel32</library>
+       <library>user32</library>
+       <library>gdi32</library>
+       <file>drawcap.c</file>
+       <file>drawcap.rc</file>
+</module>
+
+<module name="capicon" type="win32cui" installbase="system32" installname="capicon.exe">
+       <include base="capicon">.</include>
+       <define name="__USE_W32API" />
+       <define name="UNICODE" />
+       <define name="_UNICODE" />
+       <define name="_WIN32_IE">0x0500</define>
+       <define name="_WIN32_WINNT">0x0600</define>
+       <define name="WINVER">0x0600</define>
+       <library>kernel32</library>
+       <library>user32</library>
+       <library>gdi32</library>
+       <file>capicon.c</file>
+       <file>capicon.rc</file>
+</module>
diff --git a/rostests/win32/user32/drawcaption/res/icon1big.ico b/rostests/win32/user32/drawcaption/res/icon1big.ico
new file mode 100644 (file)
index 0000000..2f4358a
Binary files /dev/null and b/rostests/win32/user32/drawcaption/res/icon1big.ico differ
diff --git a/rostests/win32/user32/drawcaption/res/icon1sm.ico b/rostests/win32/user32/drawcaption/res/icon1sm.ico
new file mode 100644 (file)
index 0000000..523c7fc
Binary files /dev/null and b/rostests/win32/user32/drawcaption/res/icon1sm.ico differ
diff --git a/rostests/win32/user32/drawcaption/res/icon2big.ico b/rostests/win32/user32/drawcaption/res/icon2big.ico
new file mode 100644 (file)
index 0000000..909dbd0
Binary files /dev/null and b/rostests/win32/user32/drawcaption/res/icon2big.ico differ
diff --git a/rostests/win32/user32/drawcaption/res/icon2sm.ico b/rostests/win32/user32/drawcaption/res/icon2sm.ico
new file mode 100644 (file)
index 0000000..eeba9f5
Binary files /dev/null and b/rostests/win32/user32/drawcaption/res/icon2sm.ico differ
diff --git a/rostests/win32/user32/drawcaption/resource.h b/rostests/win32/user32/drawcaption/resource.h
new file mode 100644 (file)
index 0000000..ce5b98a
--- /dev/null
@@ -0,0 +1,10 @@
+#ifndef _CAPICON_RESOURCE_H
+#define _CAPICON_RESOURCE_H
+
+#define ID_ICON1BIG    101
+#define ID_ICON1SM    102
+#define ID_ICON2BIG    103
+#define ID_ICON2SM    104
+
+
+#endif /* _CAPICON_RESOURCE_H */
diff --git a/rostests/win32/user32/kbdlayout/kbdlayout.c b/rostests/win32/user32/kbdlayout/kbdlayout.c
new file mode 100644 (file)
index 0000000..f142303
--- /dev/null
@@ -0,0 +1,387 @@
+/*\r
+ * PROJECT:         ReactOS \r
+ * LICENSE:         GPL - See COPYING in the top level directory\r
+ * FILE:            base/applications/testset/user32/kbdlayout/kbdlayout.c\r
+ * PURPOSE:         Keyboard layout testapp\r
+ * COPYRIGHT:       Copyright 2007 Saveliy Tretiakov\r
+ */\r
+\r
+#define UNICODE\r
+#include<wchar.h>\r
+#include <windows.h>\r
+#include "resource.h"\r
+\r
+\r
+\r
+LRESULT MainDialogProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lParam);\r
+\r
+\r
+HINSTANCE hInst;\r
+HWND hMainDlg;\r
+\r
+\r
+typedef struct {\r
+       WNDPROC OrigProc;\r
+       WCHAR WndName[25];\r
+} WND_DATA;\r
+\r
+DWORD WINAPI ThreadProc(LPVOID lpParam)\r
+{\r
+\r
+       DialogBoxParam(hInst, \r
+               MAKEINTRESOURCE(IDD_MAINDIALOG),\r
+               NULL, \r
+               (DLGPROC)MainDialogProc, \r
+               (LPARAM)NULL);\r
+\r
+       return 0;\r
+}\r
+\r
+INT WINAPI WinMain(HINSTANCE hInstance,\r
+    HINSTANCE hPrevInstance,\r
+    LPSTR lpCmdLine,\r
+    int nCmdShow)\r
+{\r
+\r
+\r
+       hInst = hInstance;\r
+\r
+       ThreadProc(0);\r
+\r
+       return 0;\r
+}\r
+\r
+\r
+int GetKlList(HKL **list)\r
+{\r
+       HKL *ret;\r
+       int n;\r
+\r
+       n = GetKeyboardLayoutList(0, NULL);\r
+       ret = HeapAlloc(GetProcessHeap(), 0, sizeof(HKL)*n);\r
+       GetKeyboardLayoutList(n, ret);\r
+       *list = ret;\r
+       return n;\r
+}\r
+\r
+void FreeKlList(HKL *list)\r
+{\r
+       HeapFree(GetProcessHeap(), 0, list);\r
+}\r
+\r
+\r
+void UpdateData(HWND hDlg)\r
+{\r
+       WCHAR buf[KL_NAMELENGTH];\r
+       WCHAR buf2[512];\r
+\r
+       HWND hList;\r
+       HKL *klList, hKl;\r
+       int n, i,j;\r
+\r
+       GetKeyboardLayoutName(buf);\r
+       swprintf(buf2, L"Active: %s (%x)", buf, GetKeyboardLayout(0));\r
+       SetWindowText(GetDlgItem(hDlg, IDC_ACTIVE), buf2);\r
+\r
+       hList = GetDlgItem(hDlg, IDC_LIST);\r
+       SendMessage(hList, LB_RESETCONTENT, 0, 0);\r
+\r
+       n = GetKlList(&klList);\r
+       hKl = GetKeyboardLayout(0);\r
+       for(i = 0; i < n; i++)\r
+       {\r
+               swprintf(buf, L"%x", klList[i] );\r
+               j = SendMessage(hList, LB_ADDSTRING, 0, (LPARAM) buf); \r
+               SendMessage(hList, LB_SETITEMDATA, j, (LPARAM) klList[i]); \r
+               if(klList[i] == hKl) SendMessage(hList, LB_SETCURSEL, j, 0);\r
+       }\r
+\r
+       FreeKlList(klList);\r
+}\r
+\r
+void FormatMsg(WCHAR *format, ...)\r
+{\r
+       WCHAR buf[255];\r
+       va_list argptr;\r
+       va_start(argptr, format);\r
+       _vsnwprintf(buf, sizeof(buf)-1, format, argptr);\r
+       MessageBox(0, buf, L"msg", 0);\r
+       va_end(argptr);\r
+}\r
+\r
+void FormatBox(HWND hWnd, DWORD Flags, WCHAR *Caption, WCHAR *Format, ...)\r
+{\r
+       WCHAR buf[255];\r
+       va_list argptr;\r
+       va_start(argptr, Format);\r
+       _vsnwprintf(buf, sizeof(buf)-1, Format, argptr);\r
+       MessageBox(hWnd, buf, Caption, Flags);\r
+       va_end(argptr);\r
+}\r
+\r
+\r
+LRESULT CALLBACK WndSubclassProc( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)\r
+{\r
+       WND_DATA *data = (WND_DATA*)GetWindowLong(hwnd, GWL_USERDATA);\r
+\r
+       if(uMsg == WM_INPUTLANGCHANGE)\r
+       {\r
+               FormatMsg(L"%s: WM_INPUTLANGCHANGE lParam=%x wParam=%x\n", data->WndName, lParam, wParam);\r
+               UpdateData(hMainDlg);\r
+               //Pass message to defwindowproc\r
+       } \r
+       else if(uMsg == WM_INPUTLANGCHANGEREQUEST)\r
+       {\r
+               FormatMsg(L"%s: WM_INPUTLANGCHANGEREQUEST lParam=%x wParam=%x\n", data->WndName, lParam, wParam);\r
+               UpdateData(hMainDlg);\r
+               //Pass message to defwindowproc\r
+       }\r
+       \r
+       return ( CallWindowProc( data->OrigProc, hwnd, uMsg, wParam, lParam) ); \r
+}\r
+\r
+void SubclassWnd(HWND hWnd, WCHAR* Name)\r
+{\r
+       WND_DATA *data = HeapAlloc(GetProcessHeap(), 0, sizeof(WND_DATA));\r
+       data->OrigProc = (WNDPROC)SetWindowLong( hWnd, GWL_WNDPROC, (LONG)WndSubclassProc);\r
+       wcsncpy(data->WndName, Name, 25);\r
+       SetWindowLong(hWnd, GWL_USERDATA, (LONG)data);\r
+       return;\r
+}\r
+\r
+DWORD GetActivateFlags(HWND hDlg)\r
+{\r
+       DWORD ret = 0;\r
+\r
+       if(IsDlgButtonChecked(hDlg, IDC_KLF_REORDER))\r
+               ret |= KLF_REORDER;\r
+\r
+       if(IsDlgButtonChecked(hDlg, IDC_KLF_RESET))\r
+               ret |= KLF_RESET;\r
+\r
+       if(IsDlgButtonChecked(hDlg, IDC_KLF_SHIFTLOCK))\r
+               ret |= KLF_SHIFTLOCK;\r
+\r
+       if(IsDlgButtonChecked(hDlg, IDC_KLF_SETFORPROCESS))\r
+               ret |= KLF_SETFORPROCESS;\r
+\r
+       return ret;\r
+\r
+}\r
+\r
+DWORD GetLoadFlags(HWND hDlg)\r
+{\r
+       DWORD ret = 0;\r
+\r
+       if(IsDlgButtonChecked(hDlg, IDL_KLF_ACTIVATE))\r
+               ret |= KLF_ACTIVATE;\r
+\r
+       if(IsDlgButtonChecked(hDlg, IDL_KLF_NOTELLSHELL))\r
+               ret |= KLF_NOTELLSHELL;\r
+\r
+       if(IsDlgButtonChecked(hDlg, IDL_KLF_REORDER))\r
+               ret |= KLF_REORDER;\r
+\r
+       if(IsDlgButtonChecked(hDlg, IDL_KLF_REPLACELANG))\r
+               ret |= KLF_REPLACELANG;\r
+\r
+       if(IsDlgButtonChecked(hDlg, IDL_KLF_SUBSTITUTE_OK))\r
+               ret |= KLF_SUBSTITUTE_OK;\r
+\r
+       if(IsDlgButtonChecked(hDlg, IDL_KLF_SETFORPROCESS))\r
+               ret |= KLF_SETFORPROCESS;\r
+\r
+       return ret;\r
+}\r
+\r
+UINT GetDelayMilliseconds(HWND hDlg)\r
+{\r
+       WCHAR Buf[255];\r
+       UINT ret;\r
+\r
+       GetWindowText(GetDlgItem(hDlg, IDC_DELAY), Buf, sizeof(Buf));\r
+\r
+       swscanf(Buf, L"%d", &ret);\r
+\r
+       return ret*1000;\r
+}\r
+\r
+HKL GetSelectedLayout(HWND hDlg)\r
+{\r
+       int n;\r
+       HWND hList;\r
+       hList = GetDlgItem(hDlg, IDC_LIST);\r
+       if((n = SendMessage(hList, LB_GETCURSEL, 0, 0)) != LB_ERR)\r
+               return (HKL) SendMessage(hList, LB_GETITEMDATA, n, 0);\r
+       else return INVALID_HANDLE_VALUE;\r
+}\r
+\r
+HKL GetActivateHandle(HWND hDlg)\r
+{\r
+\r
+       if(IsDlgButtonChecked(hDlg, IDC_FROMLIST))\r
+               return GetSelectedLayout(hDlg);\r
+       else if(IsDlgButtonChecked(hDlg, IDC_HKL_NEXT)) \r
+               return (HKL)HKL_NEXT;\r
+\r
+       return (HKL)HKL_PREV;\r
+\r
+}\r
+\r
+\r
+/***************************************************\r
+ * MainDialogProc                                  *\r
+ ***************************************************/\r
+\r
+LRESULT MainDialogProc(HWND hDlg,\r
+       UINT Msg,\r
+       WPARAM wParam,\r
+       LPARAM lParam)\r
+{\r
+       HKL hKl;\r
+\r
+       switch (Msg)\r
+       {\r
+               case WM_INITDIALOG:\r
+               {\r
+                       WCHAR Buf[255];\r
+                       UpdateData(hDlg);\r
+                       hMainDlg = hDlg;\r
+\r
+                       SubclassWnd(GetDlgItem(hDlg, IDC_LIST), L"List");\r
+                       SubclassWnd(GetDlgItem(hDlg, IDC_EDIT1), L"Edit1");\r
+                       SubclassWnd(GetDlgItem(hDlg, IDC_KLID), L"Klid");\r
+                       SubclassWnd(GetDlgItem(hDlg, ID_CANCEL), L"CancelB");\r
+                       SubclassWnd(GetDlgItem(hDlg, IDC_ACTIVATE), L"ActivateB");\r
+                       SubclassWnd(GetDlgItem(hDlg, IDC_REFRESH), L"RefreshB");\r
+                       SubclassWnd(GetDlgItem(hDlg, IDC_UNLOAD), L"UnloadB");\r
+                       SubclassWnd(GetDlgItem(hDlg, IDC_LOAD), L"LoadB");\r
+\r
+                       CheckRadioButton(hDlg, IDC_FROMLIST, IDC_FROMEDIT, IDC_FROMLIST);\r
+                       SetWindowText(GetDlgItem(hDlg, IDC_KLID), L"00000419");\r
+\r
+                       swprintf(Buf, L"Current thread id: %d", GetCurrentThreadId());\r
+                       SetWindowText(GetDlgItem(hDlg, IDC_CURTHREAD), Buf);\r
+\r
+                       SetWindowText(GetDlgItem(hDlg, IDC_DELAY), L"0");\r
+\r
+                       return 0;\r
+               } /* WM_INITDIALOG */\r
+\r
+               case WM_COMMAND:\r
+               {\r
+                       switch(LOWORD(wParam))\r
+                       {\r
+                               case ID_CANCEL:\r
+                               {\r
+                                       EndDialog(hDlg, ERROR_CANCELLED);\r
+                                       break;\r
+                               }\r
+\r
+                               case IDC_ACTIVATE:\r
+                               {\r
+                                       if((hKl = GetActivateHandle(hDlg)) != INVALID_HANDLE_VALUE)\r
+                                       {\r
+                                               Sleep(GetDelayMilliseconds(hDlg));\r
+                                               if(!(hKl = ActivateKeyboardLayout(hKl, GetActivateFlags(hDlg))))\r
+                                                       FormatBox(hDlg, MB_ICONERROR, L"Error", \r
+                                                               L"ActivateKeyboardLayout() failed. %d", GetLastError());\r
+                                               else UpdateData(hDlg);\r
+                                               //FormatBox(hDlg, 0, L"Activated", L"Prev - %x, err - %d.", hKl, \r
+                                               // GetLastError());\r
+                                       }\r
+                                       else MessageBox(hDlg, L"No item selected", L"Error", MB_ICONERROR);\r
+                                       break;\r
+                               }\r
+\r
+                               case IDC_UNLOAD:\r
+                               {\r
+                                       if((hKl = GetSelectedLayout(hDlg)) != INVALID_HANDLE_VALUE)\r
+                                       {\r
+                                               Sleep(GetDelayMilliseconds(hDlg));\r
+                                               if(!UnloadKeyboardLayout(hKl))\r
+                                                       FormatBox(hDlg, MB_ICONERROR, L"Error", \r
+                                                               L"UnloadKeyboardLayout() failed. %d", \r
+                                                               GetLastError());\r
+                                               else UpdateData(hDlg);\r
+                                       }                       \r
+                                       else MessageBox(hDlg,  L"No item selected", L"Error", MB_ICONERROR);\r
+                                       break;\r
+                               }\r
+\r
+                               case IDC_LOAD:\r
+                               {\r
+                                       WCHAR buf[255];\r
+                                       GetWindowText(GetDlgItem(hDlg, IDC_KLID), buf, sizeof(buf));\r
+                                       Sleep(GetDelayMilliseconds(hDlg));\r
+                                       if(!LoadKeyboardLayout(buf, GetLoadFlags(hDlg)))\r
+                                               FormatBox(hDlg, MB_ICONERROR, L"Error", \r
+                                                       L"LoadKeyboardLayout() failed. %d",\r
+                                                       GetLastError());\r
+                                       else UpdateData(hDlg);\r
+                                       break;\r
+                               }\r
+\r
+                               case IDC_REFRESH:\r
+                               {\r
+                                       UpdateData(hDlg);\r
+                                       break;\r
+                               }\r
+\r
+                               case IDC_NEWTHREAD:\r
+                               {\r
+                                       if(!CreateThread(NULL, 0, ThreadProc, NULL, 0, NULL))\r
+                                       {\r
+                                               FormatBox(hDlg, MB_ICONERROR, L"Error!", \r
+                                                       L"Can not create thread (%d).", GetLastError());\r
+                                       }\r
+                               }\r
+\r
+                               case IDC_LIST:\r
+                               {\r
+                                       if(HIWORD(wParam) == LBN_SELCHANGE)\r
+                                       {\r
+                                               WCHAR buf[25];\r
+                                               if((hKl = GetSelectedLayout(hDlg)) != NULL)\r
+                                               {\r
+                                                       swprintf(buf, L"%x", hKl);\r
+                                                       SetWindowText(GetDlgItem(hDlg, IDC_HANDLE), buf);\r
+                                               }\r
+                                       }\r
+                                       break;\r
+                               }\r
+\r
+                       }\r
+\r
+                       return TRUE;\r
+               } /* WM_COMMAND */\r
+\r
+\r
+               case WM_INPUTLANGCHANGE:\r
+               {\r
+                       FormatMsg(L"dlg WM_INPUTLANGCHANGE lParam=%x wParam=%x\n", lParam, wParam);\r
+                       return FALSE;\r
+               }\r
+\r
+               case WM_INPUTLANGCHANGEREQUEST:\r
+               {\r
+                       FormatMsg(L"dlg WM_INPUTLANGCHANGEREQUEST lParam=%x wParam=%x\n", lParam, wParam);\r
+                       UpdateData(hDlg);\r
+                       return FALSE;\r
+               }\r
+\r
+               case WM_CLOSE:\r
+               {\r
+                       EndDialog(hDlg, ERROR_CANCELLED);\r
+                       return TRUE;\r
+               } /* WM_CLOSE */\r
+\r
+               default:\r
+                       return FALSE;\r
+       }\r
+\r
+}\r
+\r
+\r
+\r
+\r
diff --git a/rostests/win32/user32/kbdlayout/kbdlayout.dsp b/rostests/win32/user32/kbdlayout/kbdlayout.dsp
new file mode 100644 (file)
index 0000000..e2d2d80
--- /dev/null
@@ -0,0 +1,98 @@
+# Microsoft Developer Studio Project File - Name="kbdlayout" - Package Owner=<4>\r
+# Microsoft Developer Studio Generated Build File, Format Version 6.00\r
+# ** DO NOT EDIT **\r
+\r
+# TARGTYPE "Win32 (x86) Console Application" 0x0103\r
+\r
+CFG=kbdlayout - Win32 Debug\r
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,\r
+!MESSAGE use the Export Makefile command and run\r
+!MESSAGE \r
+!MESSAGE NMAKE /f "kbdlayout.mak".\r
+!MESSAGE \r
+!MESSAGE You can specify a configuration when running NMAKE\r
+!MESSAGE by defining the macro CFG on the command line. For example:\r
+!MESSAGE \r
+!MESSAGE NMAKE /f "kbdlayout.mak" CFG="kbdlayout - Win32 Debug"\r
+!MESSAGE \r
+!MESSAGE Possible choices for configuration are:\r
+!MESSAGE \r
+!MESSAGE "kbdlayout - Win32 Release" (based on "Win32 (x86) Console Application")\r
+!MESSAGE "kbdlayout - Win32 Debug" (based on "Win32 (x86) Console Application")\r
+!MESSAGE \r
+\r
+# Begin Project\r
+# PROP AllowPerConfigDependencies 0\r
+# PROP Scc_ProjName ""\r
+# PROP Scc_LocalPath ""\r
+CPP=cl.exe\r
+RSC=rc.exe\r
+\r
+!IF  "$(CFG)" == "kbdlayout - Win32 Release"\r
+\r
+# PROP BASE Use_MFC 0\r
+# PROP BASE Use_Debug_Libraries 0\r
+# PROP BASE Output_Dir "Release"\r
+# PROP BASE Intermediate_Dir "Release"\r
+# PROP BASE Target_Dir ""\r
+# PROP Use_MFC 0\r
+# PROP Use_Debug_Libraries 0\r
+# PROP Output_Dir "Release"\r
+# PROP Intermediate_Dir "Release"\r
+# PROP Target_Dir ""\r
+# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c\r
+# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c\r
+# ADD BASE RSC /l 0x419 /d "NDEBUG"\r
+# ADD RSC /l 0x419 /d "NDEBUG"\r
+BSC32=bscmake.exe\r
+# ADD BASE BSC32 /nologo\r
+# ADD BSC32 /nologo\r
+LINK32=link.exe\r
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386\r
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386\r
+\r
+!ELSEIF  "$(CFG)" == "kbdlayout - Win32 Debug"\r
+\r
+# PROP BASE Use_MFC 0\r
+# PROP BASE Use_Debug_Libraries 1\r
+# PROP BASE Output_Dir "Debug"\r
+# PROP BASE Intermediate_Dir "Debug"\r
+# PROP BASE Target_Dir ""\r
+# PROP Use_MFC 0\r
+# PROP Use_Debug_Libraries 1\r
+# PROP Output_Dir "Debug"\r
+# PROP Intermediate_Dir "Debug"\r
+# PROP Ignore_Export_Lib 0\r
+# PROP Target_Dir ""\r
+# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c\r
+# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c\r
+# ADD BASE RSC /l 0x419 /d "_DEBUG"\r
+# ADD RSC /l 0x419 /d "_DEBUG"\r
+BSC32=bscmake.exe\r
+# ADD BASE BSC32 /nologo\r
+# ADD BSC32 /nologo\r
+LINK32=link.exe\r
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept\r
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept\r
+# SUBTRACT LINK32 /pdb:none\r
+\r
+!ENDIF \r
+\r
+# Begin Target\r
+\r
+# Name "kbdlayout - Win32 Release"\r
+# Name "kbdlayout - Win32 Debug"\r
+# Begin Source File\r
+\r
+SOURCE=.\kbdlayout.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=.\kbdlayout.rc\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=.\resource.h\r
+# End Source File\r
+# End Target\r
+# End Project\r
diff --git a/rostests/win32/user32/kbdlayout/kbdlayout.rbuild b/rostests/win32/user32/kbdlayout/kbdlayout.rbuild
new file mode 100644 (file)
index 0000000..1f954ab
--- /dev/null
@@ -0,0 +1,13 @@
+<module name="kbdlayout" type="win32gui" installbase="system32" installname="kbdlayout.exe">\r
+       <include base="kbdlayout">.</include>\r
+       <define name="__USE_W32API" />\r
+       <define name="_UNICODE" />\r
+       <define name="_WIN32_IE">0x0500</define>\r
+       <define name="_WIN32_WINNT">0x0600</define>\r
+       <define name="WINVER">0x0600</define>\r
+       <library>kernel32</library>\r
+       <library>user32</library>\r
+       <library>gdi32</library>\r
+       <file>kbdlayout.c</file>\r
+       <file>kbdlayout.rc</file>\r
+</module>\r
diff --git a/rostests/win32/user32/kbdlayout/kbdlayout.rc b/rostests/win32/user32/kbdlayout/kbdlayout.rc
new file mode 100644 (file)
index 0000000..5226952
--- /dev/null
@@ -0,0 +1,142 @@
+//Microsoft Developer Studio generated resource script.\r
+//\r
+#include "resource.h"\r
+\r
+#define APSTUDIO_READONLY_SYMBOLS\r
+/////////////////////////////////////////////////////////////////////////////\r
+//\r
+// Generated from the TEXTINCLUDE 2 resource.\r
+//\r
+#include "afxres.h"\r
+\r
+/////////////////////////////////////////////////////////////////////////////\r
+#undef APSTUDIO_READONLY_SYMBOLS\r
+\r
+/////////////////////////////////////////////////////////////////////////////\r
+// Russian resources\r
+\r
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_RUS)\r
+#ifdef _WIN32\r
+LANGUAGE LANG_RUSSIAN, SUBLANG_DEFAULT\r
+#pragma code_page(1251)\r
+#endif //_WIN32\r
+\r
+/////////////////////////////////////////////////////////////////////////////\r
+//\r
+// Dialog\r
+//\r
+\r
+IDD_MAINDIALOG DIALOG DISCARDABLE  0, 0, 327, 194\r
+STYLE DS_MODALFRAME | DS_CENTER | WS_CAPTION | WS_SYSMENU\r
+CAPTION "Keyboard layout test"\r
+FONT 8, "MS Sans Serif"\r
+BEGIN\r
+    PUSHBUTTON      "Close",ID_CANCEL,215,172,105,14\r
+    EDITTEXT        IDC_EDIT1,7,140,199,47,ES_MULTILINE | ES_AUTOHSCROLL\r
+    LISTBOX         IDC_LIST,124,60,84,46,LBS_NOINTEGRALHEIGHT | WS_VSCROLL | \r
+                    WS_TABSTOP\r
+    LTEXT           "Loaded layouts",IDC_STATIC,124,50,49,8\r
+    LTEXT           "Active:",IDC_ACTIVE,7,127,114,10,SS_SUNKEN\r
+    PUSHBUTTON      "Unload",IDC_UNLOAD,124,109,41,14\r
+    PUSHBUTTON      "Activate",IDC_ACTIVATE,166,109,41,14\r
+    GROUPBOX        "Activate Flags",IDC_STATIC,215,7,103,67\r
+    CONTROL         "KLF_REORDER",IDC_KLF_REORDER,"Button",BS_AUTOCHECKBOX | \r
+                    WS_TABSTOP,221,22,69,10\r
+    CONTROL         "KLF_RESET",IDC_KLF_RESET,"Button",BS_AUTOCHECKBOX | \r
+                    WS_TABSTOP,221,34,66,12\r
+    CONTROL         "KLF_SETFORPROCESS",IDC_KLF_SETFORPROCESS,"Button",\r
+                    BS_AUTOCHECKBOX | WS_TABSTOP,221,48,95,10\r
+    CONTROL         "KLF_SHIFTLOCK",IDC_KLF_SHIFTLOCK,"Button",\r
+                    BS_AUTOCHECKBOX | WS_TABSTOP,221,60,72,10\r
+    GROUPBOX        "Activate layout",IDC_STATIC,216,77,103,50\r
+    CONTROL         "From list",IDC_FROMLIST,"Button",BS_AUTORADIOBUTTON | \r
+                    WS_GROUP,220,90,41,10\r
+    CONTROL         "HKL_NEXT",IDC_HKL_NEXT,"Button",BS_AUTORADIOBUTTON,220,\r
+                    101,53,10\r
+    CONTROL         "HKL_PREV",IDC_HKL_PREV,"Button",BS_AUTORADIOBUTTON,220,\r
+                    112,53,10\r
+    GROUPBOX        "Load layout",IDC_STATIC,7,7,113,118\r
+    CONTROL         "KLF_ACTIVATE",IDL_KLF_ACTIVATE,"Button",BS_AUTOCHECKBOX | \r
+                    WS_TABSTOP,14,44,67,10\r
+    CONTROL         "KLF_NOTELLSHELL",IDL_KLF_NOTELLSHELL,"Button",\r
+                    BS_AUTOCHECKBOX | WS_TABSTOP,14,57,83,10\r
+    LTEXT           "pwszKLID:",IDC_STATIC,14,17,35,8\r
+    EDITTEXT        IDC_KLID,14,27,54,14,ES_AUTOHSCROLL\r
+    CONTROL         "KLF_REORDER",IDL_KLF_REORDER,"Button",BS_AUTOCHECKBOX | \r
+                    WS_TABSTOP,14,71,69,10\r
+    CONTROL         "KLF_REPLACELANG",IDL_KLF_REPLACELANG,"Button",\r
+                    BS_AUTOCHECKBOX | WS_TABSTOP,14,84,85,10\r
+    CONTROL         "KLF_SUBSTITUTE_OK",IDL_KLF_SUBSTITUTE_OK,"Button",\r
+                    BS_AUTOCHECKBOX | WS_TABSTOP,14,97,92,10\r
+    CONTROL         "KLF_SETFORPROCESS",IDL_KLF_SETFORPROCESS,"Button",\r
+                    BS_AUTOCHECKBOX | WS_TABSTOP,14,110,95,10\r
+    PUSHBUTTON      "Load",IDC_LOAD,71,27,46,14\r
+    PUSHBUTTON      "Refresh",IDC_REFRESH,124,124,83,12\r
+    GROUPBOX        "Multithreading",IDC_STATIC,216,130,104,39\r
+    LTEXT           "Current thread ID:",IDC_CURTHREAD,219,141,93,8\r
+    PUSHBUTTON      "Create new thread",IDC_NEWTHREAD,234,152,71,12\r
+    GROUPBOX        "Load\\Activate delay",IDC_STATIC,124,7,85,40\r
+    LTEXT           "Delay (seconds):",IDC_STATIC,130,17,75,8\r
+    EDITTEXT        IDC_DELAY,128,29,59,14,ES_AUTOHSCROLL\r
+END\r
+\r
+\r
+/////////////////////////////////////////////////////////////////////////////\r
+//\r
+// DESIGNINFO\r
+//\r
+\r
+#ifdef APSTUDIO_INVOKED\r
+GUIDELINES DESIGNINFO DISCARDABLE \r
+BEGIN\r
+    IDD_MAINDIALOG, DIALOG\r
+    BEGIN\r
+        LEFTMARGIN, 7\r
+        RIGHTMARGIN, 320\r
+        TOPMARGIN, 7\r
+        BOTTOMMARGIN, 187\r
+    END\r
+END\r
+#endif    // APSTUDIO_INVOKED\r
+\r
+\r
+#ifdef APSTUDIO_INVOKED\r
+/////////////////////////////////////////////////////////////////////////////\r
+//\r
+// TEXTINCLUDE\r
+//\r
+\r
+1 TEXTINCLUDE DISCARDABLE \r
+BEGIN\r
+    "resource.h\0"\r
+END\r
+\r
+2 TEXTINCLUDE DISCARDABLE \r
+BEGIN\r
+    "#include ""afxres.h""\r\n"\r
+    "\0"\r
+END\r
+\r
+3 TEXTINCLUDE DISCARDABLE \r
+BEGIN\r
+    "\r\n"\r
+    "\0"\r
+END\r
+\r
+#endif    // APSTUDIO_INVOKED\r
+\r
+#endif    // Russian resources\r
+/////////////////////////////////////////////////////////////////////////////\r
+\r
+\r
+\r
+#ifndef APSTUDIO_INVOKED\r
+/////////////////////////////////////////////////////////////////////////////\r
+//\r
+// Generated from the TEXTINCLUDE 3 resource.\r
+//\r
+\r
+\r
+/////////////////////////////////////////////////////////////////////////////\r
+#endif    // not APSTUDIO_INVOKED\r
+\r
diff --git a/rostests/win32/user32/kbdlayout/resource.h b/rostests/win32/user32/kbdlayout/resource.h
new file mode 100644 (file)
index 0000000..38b5f84
--- /dev/null
@@ -0,0 +1,46 @@
+//{{NO_DEPENDENCIES}}\r
+// Microsoft Developer Studio generated include file.\r
+// Used by kbdlayout.rc\r
+//\r
+#define IDD_MAINDIALOG                  101\r
+#define ID_CANCEL                       1000\r
+#define IDC_EDIT1                       1021\r
+#define IDC_LIST                        1022\r
+#define IDC_ACTIVE                      1023\r
+#define IDC_EDIT2                       1024\r
+#define IDC_DELAY                       1024\r
+#define IDC_UNLOAD                      1025\r
+#define IDC_ACTIVATE                    1026\r
+#define IDC_KLF_REORDER                 1027\r
+#define IDC_KLF_RESET                   1028\r
+#define IDC_KLF_SETFORPROCESS           1029\r
+#define IDC_KLF_SHIFTLOCK               1030\r
+#define IDC_FROMLIST                    1032\r
+#define IDC_HKL_NEXT                    1033\r
+#define IDC_HKL_PREV                    1034\r
+#define IDL_KLF_ACTIVATE                1035\r
+#define IDL_KLF_NOTELLSHELL             1036\r
+#define IDC_KLID                        1037\r
+#define IDL_KLF_REORDER                 1038\r
+#define IDL_KLF_REPLACELANG             1039\r
+#define IDL_KLF_SUBSTITUTE_OK           1040\r
+#define IDL_KLF_SETFORPROCESS           1041\r
+#define IDC_HKL_PREV2                   1042\r
+#define IDC_FROMEDIT                    1042\r
+#define IDC_LOAD                        1043\r
+#define IDC_REFRESH                     1044\r
+#define IDC_HANDLE                      1046\r
+#define IDC_CURTHREAD                   1049\r
+#define IDC_NEWTHREAD                   1050\r
+\r
+// Next default values for new objects\r
+// \r
+#ifdef APSTUDIO_INVOKED\r
+#ifndef APSTUDIO_READONLY_SYMBOLS\r
+#define _APS_NO_MFC                     1\r
+#define _APS_NEXT_RESOURCE_VALUE        105\r
+#define _APS_NEXT_COMMAND_VALUE         40001\r
+#define _APS_NEXT_CONTROL_VALUE         1051\r
+#define _APS_NEXT_SYMED_VALUE           101\r
+#endif\r
+#endif\r
diff --git a/rostests/win32/user32/sysicon/sysicon.c b/rostests/win32/user32/sysicon/sysicon.c
new file mode 100644 (file)
index 0000000..054f422
--- /dev/null
@@ -0,0 +1,163 @@
+/* 
+ *  Copyright 2006 Saveliy Tretiakov
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program 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 General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+ /* This testapp demonstrates WS_SYSMENU + WS_EX_DLGMODALFRAME 
+  * behavior and shows that DrawCaption does care 
+  * about WS_EX_DLGMODALFRAME and WS_EX_TOOLWINDOW 
+  */
+
+#include "windows.h"
+#include "stdio.h"
+#include "resource.h"
+
+WCHAR WndClass[] = L"sysicon_class";
+
+LRESULT CALLBACK WndProc(HWND hWnd, 
+                                                        UINT msg, 
+                                                        WPARAM wParam, 
+                                                        LPARAM lParam)
+{      
+       
+       switch (msg)
+       {
+  
+    case WM_PAINT:
+    {
+                       HDC hDc;
+                       PAINTSTRUCT Ps;
+           RECT Rect;
+           GetClientRect(hWnd, &Rect);
+           
+           Rect.left = 10;
+           Rect.top = 10;
+           Rect.right-=10;
+           Rect.bottom = 25;
+           
+                       hDc = BeginPaint(hWnd, &Ps);
+                       SetBkMode( hDc, TRANSPARENT );
+                       
+           DrawCaption(hWnd, hDc, &Rect, DC_GRADIENT | DC_ACTIVE | DC_TEXT | DC_ICON);
+       
+                       EndPaint(hWnd, &Ps);
+               
+                       return 0;
+               }
+                       
+   case WM_DESTROY:
+                       PostQuitMessage(0);
+                       return 0;
+       }
+
+       return DefWindowProc(hWnd, msg, wParam, lParam);
+}
+
+int APIENTRY WinMain(HINSTANCE hInst,
+    HINSTANCE hPrevInstance,
+    LPSTR lpCmdLine,
+    int nCmdShow)
+{
+       HWND hWnd1, hWnd2, hWnd3;
+       MSG msg;
+       WNDCLASSEX wcx;
+       UINT result;
+       
+       memset(&wcx, 0, sizeof(wcx));
+       wcx.cbSize = sizeof(wcx);
+       wcx.lpfnWndProc = (WNDPROC) WndProc;
+       wcx.hInstance = hInst;
+       wcx.hbrBackground = (HBRUSH)COLOR_WINDOW;
+       wcx.lpszClassName = WndClass;
+       
+       if(!(result = RegisterClassEx(&wcx)))
+       {
+               return 1;
+       }
+       
+       /* WS_EX_DLGMODALFRAME */
+       hWnd1 = CreateWindowEx(WS_EX_DLGMODALFRAME, 
+                               WndClass, 
+                               L"WS_SYSMENU | WS_EX_DLGMODALFRAME",
+                               WS_CAPTION | WS_SYSMENU ,
+                               CW_USEDEFAULT,
+                               CW_USEDEFAULT,
+                               400,
+                               100,
+                               NULL,
+                               0,
+                               hInst,
+                               NULL);
+       
+       if(!hWnd1)
+       {
+               return 1;
+       }
+       
+       ShowWindow(hWnd1, SW_SHOW); 
+       UpdateWindow(hWnd1);  
+
+       hWnd2 = CreateWindowEx(WS_EX_TOOLWINDOW,
+                               WndClass, 
+                               L"WS_SYSMENU | WS_EX_TOOLWINDOW",
+                               WS_CAPTION | WS_SYSMENU ,
+                               CW_USEDEFAULT,
+                               CW_USEDEFAULT,
+                               400,
+                               100,
+                               NULL,
+                               0,
+                               hInst,
+                               NULL);
+       
+       if(!hWnd2)
+       {
+               return 1;
+       }
+       
+       ShowWindow(hWnd2, SW_SHOW); 
+       UpdateWindow(hWnd2);  
+
+       hWnd3 = CreateWindowEx(0,
+                               WndClass, 
+                               L"WS_SYSMENU ",
+                               WS_CAPTION | WS_SYSMENU ,
+                               CW_USEDEFAULT,
+                               CW_USEDEFAULT,
+                               400,
+                               100,
+                               NULL,
+                               0,
+                               hInst,
+                               NULL);
+       
+       if(!hWnd3)
+       {
+               return 1;
+       }
+       
+       ShowWindow(hWnd3, SW_SHOW); 
+       UpdateWindow(hWnd3);  
+       
+       while(GetMessage(&msg, NULL, 0, 0 ))
+       {
+               TranslateMessage(&msg); 
+               DispatchMessage(&msg); 
+       } 
+
+       UnregisterClass(WndClass, hInst);
+       return 0;
+}
diff --git a/rostests/win32/user32/sysicon/sysicon.rbuild b/rostests/win32/user32/sysicon/sysicon.rbuild
new file mode 100644 (file)
index 0000000..cc617fe
--- /dev/null
@@ -0,0 +1,13 @@
+<module name="sysicon" type="win32gui" installbase="system32" installname="sysicon.exe">
+       <include base="capicon">.</include>
+       <define name="__USE_W32API" />
+       <define name="UNICODE" />
+       <define name="_UNICODE" />
+       <define name="_WIN32_IE">0x0500</define>
+       <define name="_WIN32_WINNT">0x0600</define>
+       <define name="WINVER">0x0600</define>
+       <library>kernel32</library>
+       <library>user32</library>
+       <library>gdi32</library>
+       <file>sysicon.c</file>
+</module>
diff --git a/rostests/win32/user32/user32.rbuild b/rostests/win32/user32/user32.rbuild
new file mode 100644 (file)
index 0000000..b2097ac
--- /dev/null
@@ -0,0 +1,13 @@
+<?xml version="1.0"?>
+<!DOCTYPE project SYSTEM "tools/rbuild/project.dtd">
+<group>
+<directory name="drawcaption">
+       <xi:include href="drawcaption/drawcaption.rbuild" />
+</directory>
+<directory name="sysicon">
+       <xi:include href="sysicon/sysicon.rbuild" />
+</directory>
+<directory name="kbdlayout">
+       <xi:include href="kbdlayout/kbdlayout.rbuild" />
+</directory>
+</group>