diff --git a/rostests/directory.rbuild b/rostests/directory.rbuild index 2cf2d77b7d6..961c8331993 100644 --- a/rostests/directory.rbuild +++ b/rostests/directory.rbuild @@ -4,3 +4,6 @@ + + + diff --git a/rostests/win32/loadlib/loadlib.c b/rostests/win32/loadlib/loadlib.c new file mode 100644 index 00000000000..1c0bec94758 --- /dev/null +++ b/rostests/win32/loadlib/loadlib.c @@ -0,0 +1,223 @@ +/* + * ReactOS test program - + * + * loadlib.c + * + * Copyright (C) 2002 Robert Dickenson + * + * 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 +#include "loadlib.h" +#include +#include +#include + +#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 index 00000000000..51210d4722e --- /dev/null +++ b/rostests/win32/loadlib/loadlib.h @@ -0,0 +1,45 @@ +/* + * ReactOS test program - + * + * loadlib.h + * + * Copyright (C) 2002 Robert Dickenson + * + * 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 index 00000000000..84d0e1a6633 --- /dev/null +++ b/rostests/win32/msvcrt/fileio/_tfileio.c @@ -0,0 +1,421 @@ +/* + * ReactOS test program - + * + * _tfileio.c + * + * Copyright (C) 2002 Robert Dickenson + * + * 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 +#include +#include +#include + + +#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 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 index 00000000000..ab29300e05e --- /dev/null +++ b/rostests/win32/msvcrt/fileio/fileio.c @@ -0,0 +1,31 @@ +/* + * ReactOS test program - + * + * _fileio.c + * + * Copyright (C) 2002 Robert Dickenson + * + * 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 index 00000000000..64f5476d859 --- /dev/null +++ b/rostests/win32/msvcrt/fileio/main.c @@ -0,0 +1,124 @@ +/* + * ReactOS test program - + * + * main.c + * + * Copyright (C) 2002 Robert Dickenson + * + * 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 +#include +#include +#include +#include + +#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 index 00000000000..ee20fbe151d --- /dev/null +++ b/rostests/win32/msvcrt/fileio/main.h @@ -0,0 +1,42 @@ +/* + * ReactOS test program - + * + * main.h + * + * Copyright (C) 2002 Robert Dickenson + * + * 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 index 00000000000..5985a8aa238 --- /dev/null +++ b/rostests/win32/msvcrt/fileio/wfileio.c @@ -0,0 +1,31 @@ +/* + * ReactOS test program - + * + * wfileio.c + * + * Copyright (C) 2002 Robert Dickenson + * + * 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 index 00000000000..8cfb261fe6a --- /dev/null +++ b/rostests/win32/rpcrt4/context_handles/client.c @@ -0,0 +1,457 @@ +#include +#include +#include +#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_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 index 00000000000..c02c5d1a213 --- /dev/null +++ b/rostests/win32/rpcrt4/context_handles/ctx.acf @@ -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 index 00000000000..f92edbe6c31 --- /dev/null +++ b/rostests/win32/rpcrt4/context_handles/ctx.h @@ -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 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 index 00000000000..e3226dde75e --- /dev/null +++ b/rostests/win32/rpcrt4/context_handles/ctx.idl @@ -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 index 00000000000..69a8bd3204e --- /dev/null +++ b/rostests/win32/rpcrt4/context_handles/ctx_c.c @@ -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 +#if defined( _ALPHA_ ) +#include +#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 index 00000000000..81e610c986e --- /dev/null +++ b/rostests/win32/rpcrt4/context_handles/ctx_s.c @@ -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 +#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 index 00000000000..66f048f1124 --- /dev/null +++ b/rostests/win32/rpcrt4/context_handles/server.c @@ -0,0 +1,78 @@ +#include +#include +#include +#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 index 00000000000..447c389df93 --- /dev/null +++ b/rostests/win32/smss/movefile/movefile.cpp @@ -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 +#include +#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 + . + + 0x0500 + 0x0600 + 0x0600 + kernel32 + advapi32 + user32 + movefile.cpp + movefile.rc + \ 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 index 00000000000..77fc4abedb0 --- /dev/null +++ b/rostests/win32/smss/movefile/movefile.rc @@ -0,0 +1,9 @@ +#include +#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 + + diff --git a/rostests/win32/smss/smss.rbuild b/rostests/win32/smss/smss.rbuild new file mode 100644 index 00000000000..20ff30e2965 --- /dev/null +++ b/rostests/win32/smss/smss.rbuild @@ -0,0 +1,7 @@ + + + + + + + diff --git a/rostests/win32/testsets.rbuild b/rostests/win32/testsets.rbuild new file mode 100644 index 00000000000..745c4b5c25b --- /dev/null +++ b/rostests/win32/testsets.rbuild @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/rostests/win32/user32/drawcaption/capicon.c b/rostests/win32/user32/drawcaption/capicon.c new file mode 100644 index 00000000000..31bec73f870 --- /dev/null +++ b/rostests/win32/user32/drawcaption/capicon.c @@ -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 \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 index 00000000000..0cb31e4e0be --- /dev/null +++ b/rostests/win32/user32/drawcaption/capicon.rc @@ -0,0 +1,13 @@ +#include +#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 + +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 index 00000000000..b6036d8a41b --- /dev/null +++ b/rostests/win32/user32/drawcaption/drawcap.c @@ -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 [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 index 00000000000..c7f3270e80a --- /dev/null +++ b/rostests/win32/user32/drawcaption/drawcap.rc @@ -0,0 +1,11 @@ +#include +#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 + +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 index 00000000000..9593d201568 --- /dev/null +++ b/rostests/win32/user32/drawcaption/drawcaption.rbuild @@ -0,0 +1,29 @@ + + . + + + + 0x0500 + 0x0600 + 0x0600 + kernel32 + user32 + gdi32 + drawcap.c + drawcap.rc + + + + . + + + + 0x0500 + 0x0600 + 0x0600 + kernel32 + user32 + gdi32 + capicon.c + capicon.rc + diff --git a/rostests/win32/user32/drawcaption/res/icon1big.ico b/rostests/win32/user32/drawcaption/res/icon1big.ico new file mode 100644 index 00000000000..2f4358ac9f8 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 index 00000000000..523c7fc57f3 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 index 00000000000..909dbd0621b 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 index 00000000000..eeba9f57c65 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 index 00000000000..ce5b98a9f4d --- /dev/null +++ b/rostests/win32/user32/drawcaption/resource.h @@ -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 index 00000000000..f142303726d --- /dev/null +++ b/rostests/win32/user32/kbdlayout/kbdlayout.c @@ -0,0 +1,387 @@ +/* + * PROJECT: ReactOS + * LICENSE: GPL - See COPYING in the top level directory + * FILE: base/applications/testset/user32/kbdlayout/kbdlayout.c + * PURPOSE: Keyboard layout testapp + * COPYRIGHT: Copyright 2007 Saveliy Tretiakov + */ + +#define UNICODE +#include +#include +#include "resource.h" + + + +LRESULT MainDialogProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lParam); + + +HINSTANCE hInst; +HWND hMainDlg; + + +typedef struct { + WNDPROC OrigProc; + WCHAR WndName[25]; +} WND_DATA; + +DWORD WINAPI ThreadProc(LPVOID lpParam) +{ + + DialogBoxParam(hInst, + MAKEINTRESOURCE(IDD_MAINDIALOG), + NULL, + (DLGPROC)MainDialogProc, + (LPARAM)NULL); + + return 0; +} + +INT WINAPI WinMain(HINSTANCE hInstance, + HINSTANCE hPrevInstance, + LPSTR lpCmdLine, + int nCmdShow) +{ + + + hInst = hInstance; + + ThreadProc(0); + + return 0; +} + + +int GetKlList(HKL **list) +{ + HKL *ret; + int n; + + n = GetKeyboardLayoutList(0, NULL); + ret = HeapAlloc(GetProcessHeap(), 0, sizeof(HKL)*n); + GetKeyboardLayoutList(n, ret); + *list = ret; + return n; +} + +void FreeKlList(HKL *list) +{ + HeapFree(GetProcessHeap(), 0, list); +} + + +void UpdateData(HWND hDlg) +{ + WCHAR buf[KL_NAMELENGTH]; + WCHAR buf2[512]; + + HWND hList; + HKL *klList, hKl; + int n, i,j; + + GetKeyboardLayoutName(buf); + swprintf(buf2, L"Active: %s (%x)", buf, GetKeyboardLayout(0)); + SetWindowText(GetDlgItem(hDlg, IDC_ACTIVE), buf2); + + hList = GetDlgItem(hDlg, IDC_LIST); + SendMessage(hList, LB_RESETCONTENT, 0, 0); + + n = GetKlList(&klList); + hKl = GetKeyboardLayout(0); + for(i = 0; i < n; i++) + { + swprintf(buf, L"%x", klList[i] ); + j = SendMessage(hList, LB_ADDSTRING, 0, (LPARAM) buf); + SendMessage(hList, LB_SETITEMDATA, j, (LPARAM) klList[i]); + if(klList[i] == hKl) SendMessage(hList, LB_SETCURSEL, j, 0); + } + + FreeKlList(klList); +} + +void FormatMsg(WCHAR *format, ...) +{ + WCHAR buf[255]; + va_list argptr; + va_start(argptr, format); + _vsnwprintf(buf, sizeof(buf)-1, format, argptr); + MessageBox(0, buf, L"msg", 0); + va_end(argptr); +} + +void FormatBox(HWND hWnd, DWORD Flags, WCHAR *Caption, WCHAR *Format, ...) +{ + WCHAR buf[255]; + va_list argptr; + va_start(argptr, Format); + _vsnwprintf(buf, sizeof(buf)-1, Format, argptr); + MessageBox(hWnd, buf, Caption, Flags); + va_end(argptr); +} + + +LRESULT CALLBACK WndSubclassProc( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) +{ + WND_DATA *data = (WND_DATA*)GetWindowLong(hwnd, GWL_USERDATA); + + if(uMsg == WM_INPUTLANGCHANGE) + { + FormatMsg(L"%s: WM_INPUTLANGCHANGE lParam=%x wParam=%x\n", data->WndName, lParam, wParam); + UpdateData(hMainDlg); + //Pass message to defwindowproc + } + else if(uMsg == WM_INPUTLANGCHANGEREQUEST) + { + FormatMsg(L"%s: WM_INPUTLANGCHANGEREQUEST lParam=%x wParam=%x\n", data->WndName, lParam, wParam); + UpdateData(hMainDlg); + //Pass message to defwindowproc + } + + return ( CallWindowProc( data->OrigProc, hwnd, uMsg, wParam, lParam) ); +} + +void SubclassWnd(HWND hWnd, WCHAR* Name) +{ + WND_DATA *data = HeapAlloc(GetProcessHeap(), 0, sizeof(WND_DATA)); + data->OrigProc = (WNDPROC)SetWindowLong( hWnd, GWL_WNDPROC, (LONG)WndSubclassProc); + wcsncpy(data->WndName, Name, 25); + SetWindowLong(hWnd, GWL_USERDATA, (LONG)data); + return; +} + +DWORD GetActivateFlags(HWND hDlg) +{ + DWORD ret = 0; + + if(IsDlgButtonChecked(hDlg, IDC_KLF_REORDER)) + ret |= KLF_REORDER; + + if(IsDlgButtonChecked(hDlg, IDC_KLF_RESET)) + ret |= KLF_RESET; + + if(IsDlgButtonChecked(hDlg, IDC_KLF_SHIFTLOCK)) + ret |= KLF_SHIFTLOCK; + + if(IsDlgButtonChecked(hDlg, IDC_KLF_SETFORPROCESS)) + ret |= KLF_SETFORPROCESS; + + return ret; + +} + +DWORD GetLoadFlags(HWND hDlg) +{ + DWORD ret = 0; + + if(IsDlgButtonChecked(hDlg, IDL_KLF_ACTIVATE)) + ret |= KLF_ACTIVATE; + + if(IsDlgButtonChecked(hDlg, IDL_KLF_NOTELLSHELL)) + ret |= KLF_NOTELLSHELL; + + if(IsDlgButtonChecked(hDlg, IDL_KLF_REORDER)) + ret |= KLF_REORDER; + + if(IsDlgButtonChecked(hDlg, IDL_KLF_REPLACELANG)) + ret |= KLF_REPLACELANG; + + if(IsDlgButtonChecked(hDlg, IDL_KLF_SUBSTITUTE_OK)) + ret |= KLF_SUBSTITUTE_OK; + + if(IsDlgButtonChecked(hDlg, IDL_KLF_SETFORPROCESS)) + ret |= KLF_SETFORPROCESS; + + return ret; +} + +UINT GetDelayMilliseconds(HWND hDlg) +{ + WCHAR Buf[255]; + UINT ret; + + GetWindowText(GetDlgItem(hDlg, IDC_DELAY), Buf, sizeof(Buf)); + + swscanf(Buf, L"%d", &ret); + + return ret*1000; +} + +HKL GetSelectedLayout(HWND hDlg) +{ + int n; + HWND hList; + hList = GetDlgItem(hDlg, IDC_LIST); + if((n = SendMessage(hList, LB_GETCURSEL, 0, 0)) != LB_ERR) + return (HKL) SendMessage(hList, LB_GETITEMDATA, n, 0); + else return INVALID_HANDLE_VALUE; +} + +HKL GetActivateHandle(HWND hDlg) +{ + + if(IsDlgButtonChecked(hDlg, IDC_FROMLIST)) + return GetSelectedLayout(hDlg); + else if(IsDlgButtonChecked(hDlg, IDC_HKL_NEXT)) + return (HKL)HKL_NEXT; + + return (HKL)HKL_PREV; + +} + + +/*************************************************** + * MainDialogProc * + ***************************************************/ + +LRESULT MainDialogProc(HWND hDlg, + UINT Msg, + WPARAM wParam, + LPARAM lParam) +{ + HKL hKl; + + switch (Msg) + { + case WM_INITDIALOG: + { + WCHAR Buf[255]; + UpdateData(hDlg); + hMainDlg = hDlg; + + SubclassWnd(GetDlgItem(hDlg, IDC_LIST), L"List"); + SubclassWnd(GetDlgItem(hDlg, IDC_EDIT1), L"Edit1"); + SubclassWnd(GetDlgItem(hDlg, IDC_KLID), L"Klid"); + SubclassWnd(GetDlgItem(hDlg, ID_CANCEL), L"CancelB"); + SubclassWnd(GetDlgItem(hDlg, IDC_ACTIVATE), L"ActivateB"); + SubclassWnd(GetDlgItem(hDlg, IDC_REFRESH), L"RefreshB"); + SubclassWnd(GetDlgItem(hDlg, IDC_UNLOAD), L"UnloadB"); + SubclassWnd(GetDlgItem(hDlg, IDC_LOAD), L"LoadB"); + + CheckRadioButton(hDlg, IDC_FROMLIST, IDC_FROMEDIT, IDC_FROMLIST); + SetWindowText(GetDlgItem(hDlg, IDC_KLID), L"00000419"); + + swprintf(Buf, L"Current thread id: %d", GetCurrentThreadId()); + SetWindowText(GetDlgItem(hDlg, IDC_CURTHREAD), Buf); + + SetWindowText(GetDlgItem(hDlg, IDC_DELAY), L"0"); + + return 0; + } /* WM_INITDIALOG */ + + case WM_COMMAND: + { + switch(LOWORD(wParam)) + { + case ID_CANCEL: + { + EndDialog(hDlg, ERROR_CANCELLED); + break; + } + + case IDC_ACTIVATE: + { + if((hKl = GetActivateHandle(hDlg)) != INVALID_HANDLE_VALUE) + { + Sleep(GetDelayMilliseconds(hDlg)); + if(!(hKl = ActivateKeyboardLayout(hKl, GetActivateFlags(hDlg)))) + FormatBox(hDlg, MB_ICONERROR, L"Error", + L"ActivateKeyboardLayout() failed. %d", GetLastError()); + else UpdateData(hDlg); + //FormatBox(hDlg, 0, L"Activated", L"Prev - %x, err - %d.", hKl, + // GetLastError()); + } + else MessageBox(hDlg, L"No item selected", L"Error", MB_ICONERROR); + break; + } + + case IDC_UNLOAD: + { + if((hKl = GetSelectedLayout(hDlg)) != INVALID_HANDLE_VALUE) + { + Sleep(GetDelayMilliseconds(hDlg)); + if(!UnloadKeyboardLayout(hKl)) + FormatBox(hDlg, MB_ICONERROR, L"Error", + L"UnloadKeyboardLayout() failed. %d", + GetLastError()); + else UpdateData(hDlg); + } + else MessageBox(hDlg, L"No item selected", L"Error", MB_ICONERROR); + break; + } + + case IDC_LOAD: + { + WCHAR buf[255]; + GetWindowText(GetDlgItem(hDlg, IDC_KLID), buf, sizeof(buf)); + Sleep(GetDelayMilliseconds(hDlg)); + if(!LoadKeyboardLayout(buf, GetLoadFlags(hDlg))) + FormatBox(hDlg, MB_ICONERROR, L"Error", + L"LoadKeyboardLayout() failed. %d", + GetLastError()); + else UpdateData(hDlg); + break; + } + + case IDC_REFRESH: + { + UpdateData(hDlg); + break; + } + + case IDC_NEWTHREAD: + { + if(!CreateThread(NULL, 0, ThreadProc, NULL, 0, NULL)) + { + FormatBox(hDlg, MB_ICONERROR, L"Error!", + L"Can not create thread (%d).", GetLastError()); + } + } + + case IDC_LIST: + { + if(HIWORD(wParam) == LBN_SELCHANGE) + { + WCHAR buf[25]; + if((hKl = GetSelectedLayout(hDlg)) != NULL) + { + swprintf(buf, L"%x", hKl); + SetWindowText(GetDlgItem(hDlg, IDC_HANDLE), buf); + } + } + break; + } + + } + + return TRUE; + } /* WM_COMMAND */ + + + case WM_INPUTLANGCHANGE: + { + FormatMsg(L"dlg WM_INPUTLANGCHANGE lParam=%x wParam=%x\n", lParam, wParam); + return FALSE; + } + + case WM_INPUTLANGCHANGEREQUEST: + { + FormatMsg(L"dlg WM_INPUTLANGCHANGEREQUEST lParam=%x wParam=%x\n", lParam, wParam); + UpdateData(hDlg); + return FALSE; + } + + case WM_CLOSE: + { + EndDialog(hDlg, ERROR_CANCELLED); + return TRUE; + } /* WM_CLOSE */ + + default: + return FALSE; + } + +} + + + + diff --git a/rostests/win32/user32/kbdlayout/kbdlayout.dsp b/rostests/win32/user32/kbdlayout/kbdlayout.dsp new file mode 100644 index 00000000000..e2d2d804e6d --- /dev/null +++ b/rostests/win32/user32/kbdlayout/kbdlayout.dsp @@ -0,0 +1,98 @@ +# Microsoft Developer Studio Project File - Name="kbdlayout" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Console Application" 0x0103 + +CFG=kbdlayout - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "kbdlayout.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "kbdlayout.mak" CFG="kbdlayout - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "kbdlayout - Win32 Release" (based on "Win32 (x86) Console Application") +!MESSAGE "kbdlayout - Win32 Debug" (based on "Win32 (x86) Console Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "kbdlayout - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD BASE RSC /l 0x419 /d "NDEBUG" +# ADD RSC /l 0x419 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# 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 +# 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 + +!ELSEIF "$(CFG)" == "kbdlayout - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD BASE RSC /l 0x419 /d "_DEBUG" +# ADD RSC /l 0x419 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# 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 +# 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 +# SUBTRACT LINK32 /pdb:none + +!ENDIF + +# Begin Target + +# Name "kbdlayout - Win32 Release" +# Name "kbdlayout - Win32 Debug" +# Begin Source File + +SOURCE=.\kbdlayout.c +# End Source File +# Begin Source File + +SOURCE=.\kbdlayout.rc +# End Source File +# Begin Source File + +SOURCE=.\resource.h +# End Source File +# End Target +# End Project diff --git a/rostests/win32/user32/kbdlayout/kbdlayout.rbuild b/rostests/win32/user32/kbdlayout/kbdlayout.rbuild new file mode 100644 index 00000000000..1f954ab0875 --- /dev/null +++ b/rostests/win32/user32/kbdlayout/kbdlayout.rbuild @@ -0,0 +1,13 @@ + + . + + + 0x0500 + 0x0600 + 0x0600 + kernel32 + user32 + gdi32 + kbdlayout.c + kbdlayout.rc + diff --git a/rostests/win32/user32/kbdlayout/kbdlayout.rc b/rostests/win32/user32/kbdlayout/kbdlayout.rc new file mode 100644 index 00000000000..5226952dc70 --- /dev/null +++ b/rostests/win32/user32/kbdlayout/kbdlayout.rc @@ -0,0 +1,142 @@ +//Microsoft Developer Studio generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "afxres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// Russian resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_RUS) +#ifdef _WIN32 +LANGUAGE LANG_RUSSIAN, SUBLANG_DEFAULT +#pragma code_page(1251) +#endif //_WIN32 + +///////////////////////////////////////////////////////////////////////////// +// +// Dialog +// + +IDD_MAINDIALOG DIALOG DISCARDABLE 0, 0, 327, 194 +STYLE DS_MODALFRAME | DS_CENTER | WS_CAPTION | WS_SYSMENU +CAPTION "Keyboard layout test" +FONT 8, "MS Sans Serif" +BEGIN + PUSHBUTTON "Close",ID_CANCEL,215,172,105,14 + EDITTEXT IDC_EDIT1,7,140,199,47,ES_MULTILINE | ES_AUTOHSCROLL + LISTBOX IDC_LIST,124,60,84,46,LBS_NOINTEGRALHEIGHT | WS_VSCROLL | + WS_TABSTOP + LTEXT "Loaded layouts",IDC_STATIC,124,50,49,8 + LTEXT "Active:",IDC_ACTIVE,7,127,114,10,SS_SUNKEN + PUSHBUTTON "Unload",IDC_UNLOAD,124,109,41,14 + PUSHBUTTON "Activate",IDC_ACTIVATE,166,109,41,14 + GROUPBOX "Activate Flags",IDC_STATIC,215,7,103,67 + CONTROL "KLF_REORDER",IDC_KLF_REORDER,"Button",BS_AUTOCHECKBOX | + WS_TABSTOP,221,22,69,10 + CONTROL "KLF_RESET",IDC_KLF_RESET,"Button",BS_AUTOCHECKBOX | + WS_TABSTOP,221,34,66,12 + CONTROL "KLF_SETFORPROCESS",IDC_KLF_SETFORPROCESS,"Button", + BS_AUTOCHECKBOX | WS_TABSTOP,221,48,95,10 + CONTROL "KLF_SHIFTLOCK",IDC_KLF_SHIFTLOCK,"Button", + BS_AUTOCHECKBOX | WS_TABSTOP,221,60,72,10 + GROUPBOX "Activate layout",IDC_STATIC,216,77,103,50 + CONTROL "From list",IDC_FROMLIST,"Button",BS_AUTORADIOBUTTON | + WS_GROUP,220,90,41,10 + CONTROL "HKL_NEXT",IDC_HKL_NEXT,"Button",BS_AUTORADIOBUTTON,220, + 101,53,10 + CONTROL "HKL_PREV",IDC_HKL_PREV,"Button",BS_AUTORADIOBUTTON,220, + 112,53,10 + GROUPBOX "Load layout",IDC_STATIC,7,7,113,118 + CONTROL "KLF_ACTIVATE",IDL_KLF_ACTIVATE,"Button",BS_AUTOCHECKBOX | + WS_TABSTOP,14,44,67,10 + CONTROL "KLF_NOTELLSHELL",IDL_KLF_NOTELLSHELL,"Button", + BS_AUTOCHECKBOX | WS_TABSTOP,14,57,83,10 + LTEXT "pwszKLID:",IDC_STATIC,14,17,35,8 + EDITTEXT IDC_KLID,14,27,54,14,ES_AUTOHSCROLL + CONTROL "KLF_REORDER",IDL_KLF_REORDER,"Button",BS_AUTOCHECKBOX | + WS_TABSTOP,14,71,69,10 + CONTROL "KLF_REPLACELANG",IDL_KLF_REPLACELANG,"Button", + BS_AUTOCHECKBOX | WS_TABSTOP,14,84,85,10 + CONTROL "KLF_SUBSTITUTE_OK",IDL_KLF_SUBSTITUTE_OK,"Button", + BS_AUTOCHECKBOX | WS_TABSTOP,14,97,92,10 + CONTROL "KLF_SETFORPROCESS",IDL_KLF_SETFORPROCESS,"Button", + BS_AUTOCHECKBOX | WS_TABSTOP,14,110,95,10 + PUSHBUTTON "Load",IDC_LOAD,71,27,46,14 + PUSHBUTTON "Refresh",IDC_REFRESH,124,124,83,12 + GROUPBOX "Multithreading",IDC_STATIC,216,130,104,39 + LTEXT "Current thread ID:",IDC_CURTHREAD,219,141,93,8 + PUSHBUTTON "Create new thread",IDC_NEWTHREAD,234,152,71,12 + GROUPBOX "Load\\Activate delay",IDC_STATIC,124,7,85,40 + LTEXT "Delay (seconds):",IDC_STATIC,130,17,75,8 + EDITTEXT IDC_DELAY,128,29,59,14,ES_AUTOHSCROLL +END + + +///////////////////////////////////////////////////////////////////////////// +// +// DESIGNINFO +// + +#ifdef APSTUDIO_INVOKED +GUIDELINES DESIGNINFO DISCARDABLE +BEGIN + IDD_MAINDIALOG, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 320 + TOPMARGIN, 7 + BOTTOMMARGIN, 187 + END +END +#endif // APSTUDIO_INVOKED + + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE DISCARDABLE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE DISCARDABLE +BEGIN + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE DISCARDABLE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + +#endif // Russian resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/rostests/win32/user32/kbdlayout/resource.h b/rostests/win32/user32/kbdlayout/resource.h new file mode 100644 index 00000000000..38b5f849f1c --- /dev/null +++ b/rostests/win32/user32/kbdlayout/resource.h @@ -0,0 +1,46 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Developer Studio generated include file. +// Used by kbdlayout.rc +// +#define IDD_MAINDIALOG 101 +#define ID_CANCEL 1000 +#define IDC_EDIT1 1021 +#define IDC_LIST 1022 +#define IDC_ACTIVE 1023 +#define IDC_EDIT2 1024 +#define IDC_DELAY 1024 +#define IDC_UNLOAD 1025 +#define IDC_ACTIVATE 1026 +#define IDC_KLF_REORDER 1027 +#define IDC_KLF_RESET 1028 +#define IDC_KLF_SETFORPROCESS 1029 +#define IDC_KLF_SHIFTLOCK 1030 +#define IDC_FROMLIST 1032 +#define IDC_HKL_NEXT 1033 +#define IDC_HKL_PREV 1034 +#define IDL_KLF_ACTIVATE 1035 +#define IDL_KLF_NOTELLSHELL 1036 +#define IDC_KLID 1037 +#define IDL_KLF_REORDER 1038 +#define IDL_KLF_REPLACELANG 1039 +#define IDL_KLF_SUBSTITUTE_OK 1040 +#define IDL_KLF_SETFORPROCESS 1041 +#define IDC_HKL_PREV2 1042 +#define IDC_FROMEDIT 1042 +#define IDC_LOAD 1043 +#define IDC_REFRESH 1044 +#define IDC_HANDLE 1046 +#define IDC_CURTHREAD 1049 +#define IDC_NEWTHREAD 1050 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NO_MFC 1 +#define _APS_NEXT_RESOURCE_VALUE 105 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1051 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/rostests/win32/user32/sysicon/sysicon.c b/rostests/win32/user32/sysicon/sysicon.c new file mode 100644 index 00000000000..054f422516a --- /dev/null +++ b/rostests/win32/user32/sysicon/sysicon.c @@ -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 index 00000000000..cc617fee768 --- /dev/null +++ b/rostests/win32/user32/sysicon/sysicon.rbuild @@ -0,0 +1,13 @@ + + . + + + + 0x0500 + 0x0600 + 0x0600 + kernel32 + user32 + gdi32 + sysicon.c + diff --git a/rostests/win32/user32/user32.rbuild b/rostests/win32/user32/user32.rbuild new file mode 100644 index 00000000000..b2097ac0df8 --- /dev/null +++ b/rostests/win32/user32/user32.rbuild @@ -0,0 +1,13 @@ + + + + + + + + + + + + +