From ff164c8fa4f5c46870d17588cca6eb40b2b5b29a Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Sat, 27 Nov 2010 19:02:37 +0000 Subject: [PATCH 001/181] [XML] Silence a warning on MSVC svn path=/trunk/; revision=49824 --- reactos/tools/xml.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/reactos/tools/xml.cpp b/reactos/tools/xml.cpp index 8400ce131ed..50125e129d6 100644 --- a/reactos/tools/xml.cpp +++ b/reactos/tools/xml.cpp @@ -18,6 +18,7 @@ #ifdef _MSC_VER #pragma warning ( disable : 4786 ) +#pragma warning ( disable : 4996 ) #endif//_MSC_VER #ifdef WIN32 @@ -41,7 +42,6 @@ #include #include #include "xml.h" -#include "ssprintf.h" #ifndef MAX_PATH #define MAX_PATH _MAX_PATH @@ -100,7 +100,9 @@ XMLException::XMLException ( void XMLException::SetExceptionV ( const std::string& location, const char* format, va_list args ) { - _e = location + ": " + ssvprintf(format,args); + char buffer[1024]; + _vsnprintf(buffer, sizeof(buffer)-1, format, args); + _e = location + ": " + buffer; } void XMLException::SetException ( const std::string& location, const char* format, ... ) @@ -424,13 +426,14 @@ string XMLFile::Location() const { int line = 1; + char line_str[10]; const char* p = strchr ( _buf.c_str(), '\n' ); while ( p && p < _p ) { ++line; p = strchr ( p+1, '\n' ); } - return ssprintf ( "%s(%i)",_filename.c_str(), line ); + return _filename + "(" + itoa(line, line_str, 10) + ")"; } XMLAttribute::XMLAttribute() From 9ce593995947c6815715a297d4df0a8feed59d6d Mon Sep 17 00:00:00 2001 From: Aleksey Bragin Date: Sat, 27 Nov 2010 21:38:11 +0000 Subject: [PATCH 002/181] [MPRAPI] - Sync to Wine-1.3.8 See issue #5718 for more details. svn path=/trunk/; revision=49825 --- reactos/dll/win32/mprapi/mprapi.c | 26 ++++++++++++++++++++++++++ reactos/dll/win32/mprapi/mprapi.spec | 2 +- reactos/media/doc/README.WINE | 1 + 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/reactos/dll/win32/mprapi/mprapi.c b/reactos/dll/win32/mprapi/mprapi.c index 90f47ae0c6b..715f1b8cada 100644 --- a/reactos/dll/win32/mprapi/mprapi.c +++ b/reactos/dll/win32/mprapi/mprapi.c @@ -44,6 +44,32 @@ BOOL WINAPI DllMain(HINSTANCE hinst, DWORD reason, LPVOID reserved) return TRUE; } +/*********************************************************************** + * MprAdminGetErrorString (MPRAPI.@) + * + * Return a unicode string for the given mpr errorcode + * + * PARAMS + * mprerror [i] errorcode, for which a description is requested + * localstr [o] pointer, where a buffer with the error description is returned + * + * RETURNS + * Failure: ERROR_MR_MID_NOT_FOUND, when mprerror is not known + * Success: ERROR_SUCCESS, and in localstr a pointer to a buffer from LocalAlloc, + * which contains the error description. + * + * NOTES + * The caller must free the returned buffer with LocalFree + * + */ +DWORD APIENTRY MprAdminGetErrorString(DWORD mprerror, LPWSTR *localstr) +{ + FIXME("(0x%x/%u, %p): stub!\n", mprerror, mprerror, localstr); + + *localstr = NULL; + return ERROR_MR_MID_NOT_FOUND; +} + /*********************************************************************** * MprAdminIsServiceRunning (MPRAPI.@) */ diff --git a/reactos/dll/win32/mprapi/mprapi.spec b/reactos/dll/win32/mprapi/mprapi.spec index 6fb84393f2d..4b5937b8806 100644 --- a/reactos/dll/win32/mprapi/mprapi.spec +++ b/reactos/dll/win32/mprapi/mprapi.spec @@ -6,7 +6,7 @@ @ stub MprAdminDeregisterConnectionNotification @ stub MprAdminDeviceEnum @ stub MprAdminEstablishDomainRasServer -@ stub MprAdminGetErrorString +@ stdcall MprAdminGetErrorString(long ptr) @ stub MprAdminGetPDCServer @ stub MprAdminInterfaceConnect @ stub MprAdminInterfaceCreate diff --git a/reactos/media/doc/README.WINE b/reactos/media/doc/README.WINE index 0937d63e64b..adaff2f0e71 100644 --- a/reactos/media/doc/README.WINE +++ b/reactos/media/doc/README.WINE @@ -90,6 +90,7 @@ reactos/dll/win32/mciseq # Autosync reactos/dll/win32/mciwave # Autosync reactos/dll/win32/mlang # Autosync reactos/dll/win32/mpr # Autosync +reactos/dll/win32/mprapi # Autosync reactos/dll/win32/msacm32 # Autosync reactos/dll/win32/msadp32.acm # Autosync reactos/dll/win32/mscat32 # Autosync From 1d70b8136abd6c1805bffa90cd182ec57e7a0fa2 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Sat, 27 Nov 2010 22:12:15 +0000 Subject: [PATCH 003/181] [ASM] Merge asm related changes from cmake branch. svn path=/trunk/; revision=49826 --- .../boot/freeldr/freeldr/arch/amd64/arch.S | 9 +- .../boot/freeldr/freeldr/arch/amd64/boot.S | 10 +- .../boot/freeldr/freeldr/arch/amd64/i386pnp.S | 4 + .../boot/freeldr/freeldr/arch/amd64/int386.S | 5 + reactos/boot/freeldr/freeldr/arch/amd64/mb.S | 5 + reactos/boot/freeldr/freeldr/arch/i386/arch.S | 370 +++---- reactos/dll/ntdll/dispatch/i386/dispatch.S | 70 +- .../dll/win32/kernel32/thread/amd64/fiber.S | 8 +- .../dll/win32/kernel32/thread/amd64/thread.S | 9 +- .../dll/win32/kernel32/thread/i386/fiber.S | 16 +- .../dll/win32/kernel32/thread/i386/thread.S | 13 +- reactos/hal/halx86/amd64/mps.S | 7 +- reactos/hal/halx86/amd64/systimer.S | 6 +- reactos/hal/halx86/generic/i386/systimer.S | 224 +++-- reactos/hal/halx86/generic/i386/trap.S | 10 +- reactos/include/reactos/asm.inc | 262 +++++ reactos/include/reactos/ks386.inc | 946 ++++++++++++++++++ reactos/lib/rtl/amd64/debug_asm.S | 2 +- reactos/lib/rtl/amd64/except_asm.S | 4 +- reactos/lib/rtl/amd64/rtlmem.S | 3 +- reactos/lib/rtl/amd64/slist.S | 4 +- reactos/lib/rtl/i386/debug_asm.S | 36 +- reactos/lib/rtl/i386/except_asm.s | 90 +- reactos/lib/rtl/i386/interlck.S | 37 +- reactos/lib/rtl/i386/res_asm.s | 19 +- reactos/lib/rtl/i386/rtlmem.s | 47 +- reactos/lib/sdk/crt/except/amd64/chkstk_asm.s | 6 +- reactos/lib/sdk/crt/except/amd64/seh.s | 6 +- reactos/lib/sdk/crt/except/i386/chkstk_asm.s | 99 +- reactos/lib/sdk/crt/except/i386/prolog.s | 27 +- reactos/lib/sdk/crt/except/i386/seh.s | 41 +- reactos/lib/sdk/crt/float/i386/logb.c | 2 +- reactos/lib/sdk/crt/math/amd64/alldiv.S | 3 +- reactos/lib/sdk/crt/math/amd64/atan.S | 4 +- reactos/lib/sdk/crt/math/amd64/atan2.S | 4 +- reactos/lib/sdk/crt/math/amd64/ceil.S | 4 +- reactos/lib/sdk/crt/math/amd64/ceilf.S | 32 +- reactos/lib/sdk/crt/math/amd64/exp.S | 5 +- reactos/lib/sdk/crt/math/amd64/fabs.S | 3 +- reactos/lib/sdk/crt/math/amd64/floor.S | 6 +- reactos/lib/sdk/crt/math/amd64/floorf.S | 25 +- reactos/lib/sdk/crt/math/amd64/fmod.S | 5 +- reactos/lib/sdk/crt/math/amd64/fmodf.S | 5 +- reactos/lib/sdk/crt/math/amd64/ldexp.S | 5 +- reactos/lib/sdk/crt/math/amd64/log.S | 3 +- reactos/lib/sdk/crt/math/amd64/log10.S | 3 +- reactos/lib/sdk/crt/math/amd64/pow.S | 4 +- reactos/lib/sdk/crt/math/amd64/sqrt.S | 6 +- reactos/lib/sdk/crt/math/amd64/sqrtf.S | 6 +- reactos/lib/sdk/crt/math/amd64/tan.S | 6 +- reactos/lib/sdk/crt/math/i386/alldiv_asm.s | 18 +- reactos/lib/sdk/crt/math/i386/alldvrm_asm.s | 51 +- reactos/lib/sdk/crt/math/i386/allmul_asm.s | 8 +- reactos/lib/sdk/crt/math/i386/allrem_asm.s | 11 +- reactos/lib/sdk/crt/math/i386/allshl_asm.s | 9 +- reactos/lib/sdk/crt/math/i386/allshr_asm.s | 11 +- reactos/lib/sdk/crt/math/i386/atan2_asm.s | 18 + reactos/lib/sdk/crt/math/i386/atan_asm.s | 11 +- reactos/lib/sdk/crt/math/i386/aulldiv_asm.s | 33 +- reactos/lib/sdk/crt/math/i386/aulldvrm_asm.s | 35 +- reactos/lib/sdk/crt/math/i386/aullrem_asm.s | 35 +- reactos/lib/sdk/crt/math/i386/aullshr_asm.s | 19 +- reactos/lib/sdk/crt/math/i386/ceil_asm.s | 11 +- reactos/lib/sdk/crt/math/i386/ceilf.S | 53 +- reactos/lib/sdk/crt/math/i386/cos_asm.s | 9 +- reactos/lib/sdk/crt/math/i386/exp_asm.s | 29 + reactos/lib/sdk/crt/math/i386/fabs_asm.s | 11 +- reactos/lib/sdk/crt/math/i386/floor_asm.s | 13 +- reactos/lib/sdk/crt/math/i386/floorf.S | 57 +- reactos/lib/sdk/crt/math/i386/fmod_asm.s | 26 + reactos/lib/sdk/crt/math/i386/fmodf_asm.s | 26 + reactos/lib/sdk/crt/math/i386/ftol2_asm.s | 28 + reactos/lib/sdk/crt/math/i386/ftol_asm.s | 13 +- reactos/lib/sdk/crt/math/i386/log10_asm.s | 8 +- reactos/lib/sdk/crt/math/i386/log_asm.s | 11 +- reactos/lib/sdk/crt/math/i386/pow_asm.s | 373 +++---- reactos/lib/sdk/crt/math/i386/sin_asm.s | 9 +- reactos/lib/sdk/crt/math/i386/sqrt_asm.s | 11 +- reactos/lib/sdk/crt/math/i386/tan_asm.s | 11 +- reactos/lib/sdk/crt/mem/i386/memchr_asm.s | 34 +- reactos/lib/sdk/crt/mem/i386/memcpy_asm.s | 114 --- reactos/lib/sdk/crt/mem/i386/memmove_asm.s | 158 +-- reactos/lib/sdk/crt/mem/i386/memset_asm.s | 65 +- reactos/lib/sdk/crt/setjmp/amd64/setjmp.s | 6 +- reactos/lib/sdk/crt/setjmp/i386/setjmp.s | 71 +- reactos/lib/sdk/crt/string/i386/strcat_asm.s | 2 +- reactos/lib/sdk/crt/string/i386/strchr_asm.s | 2 +- reactos/lib/sdk/crt/string/i386/strcmp_asm.s | 2 +- reactos/lib/sdk/crt/string/i386/strcpy_asm.s | 2 +- reactos/lib/sdk/crt/string/i386/strlen_asm.s | 2 +- reactos/lib/sdk/crt/string/i386/strncat_asm.s | 2 +- reactos/lib/sdk/crt/string/i386/strncmp_asm.s | 2 +- reactos/lib/sdk/crt/string/i386/strncpy_asm.s | 2 +- reactos/lib/sdk/crt/string/i386/strnlen_asm.s | 2 +- reactos/lib/sdk/crt/string/i386/strrchr_asm.s | 2 +- reactos/lib/sdk/crt/string/i386/tchar.h | 8 +- reactos/lib/sdk/crt/string/i386/tcscat.h | 32 - reactos/lib/sdk/crt/string/i386/tcscat.inc | 35 + reactos/lib/sdk/crt/string/i386/tcschr.h | 30 - reactos/lib/sdk/crt/string/i386/tcschr.inc | 32 + reactos/lib/sdk/crt/string/i386/tcscmp.h | 34 - reactos/lib/sdk/crt/string/i386/tcscmp.inc | 37 + reactos/lib/sdk/crt/string/i386/tcscpy.h | 27 - reactos/lib/sdk/crt/string/i386/tcscpy.inc | 30 + reactos/lib/sdk/crt/string/i386/tcslen.h | 29 - reactos/lib/sdk/crt/string/i386/tcslen.inc | 32 + reactos/lib/sdk/crt/string/i386/tcsncat.h | 42 - reactos/lib/sdk/crt/string/i386/tcsncat.inc | 45 + reactos/lib/sdk/crt/string/i386/tcsncmp.h | 40 - reactos/lib/sdk/crt/string/i386/tcsncmp.inc | 43 + reactos/lib/sdk/crt/string/i386/tcsncpy.h | 34 - reactos/lib/sdk/crt/string/i386/tcsncpy.inc | 37 + reactos/lib/sdk/crt/string/i386/tcsnlen.h | 30 - reactos/lib/sdk/crt/string/i386/tcsnlen.inc | 33 + reactos/lib/sdk/crt/string/i386/tcsrchr.h | 31 - reactos/lib/sdk/crt/string/i386/tcsrchr.inc | 34 + reactos/lib/sdk/crt/string/i386/wcscat_asm.s | 2 +- reactos/lib/sdk/crt/string/i386/wcschr_asm.s | 2 +- reactos/lib/sdk/crt/string/i386/wcscmp_asm.s | 2 +- reactos/lib/sdk/crt/string/i386/wcscpy_asm.s | 2 +- reactos/lib/sdk/crt/string/i386/wcslen_asm.s | 2 +- reactos/lib/sdk/crt/string/i386/wcsncat_asm.s | 2 +- reactos/lib/sdk/crt/string/i386/wcsncmp_asm.s | 2 +- reactos/lib/sdk/crt/string/i386/wcsncpy_asm.s | 2 +- reactos/lib/sdk/crt/string/i386/wcsnlen_asm.s | 2 +- reactos/lib/sdk/crt/string/i386/wcsrchr_asm.s | 2 +- reactos/ntoskrnl/ex/i386/fastinterlck_asm.S | 104 +- reactos/ntoskrnl/ex/i386/interlck_asm.S | 54 +- reactos/ntoskrnl/ex/i386/ioport.S | 66 +- .../ntoskrnl/include/internal/i386/asmmacro.S | 14 +- reactos/ntoskrnl/kdbg/amd64/kdb_help.S | 12 +- reactos/ntoskrnl/kdbg/i386/kdb_help.S | 187 ++-- reactos/ntoskrnl/ke/amd64/boot.S | 8 +- reactos/ntoskrnl/ke/amd64/ctxswitch.S | 5 +- reactos/ntoskrnl/ke/amd64/trap.S | 5 +- reactos/ntoskrnl/ke/i386/ctxswitch.S | 39 +- reactos/ntoskrnl/ke/i386/trap.s | 30 +- reactos/ntoskrnl/ke/i386/usercall_asm.S | 38 +- reactos/ntoskrnl/rtl/i386/stack.S | 11 +- .../win32/win32k/dib/i386/dib24bpp_hline.s | 13 +- .../win32k/dib/i386/dib32bpp_colorfill.s | 17 +- .../win32/win32k/dib/i386/dib32bpp_hline.s | 11 +- .../win32/win32k/eng/i386/floatobj.S | 72 +- .../win32/win32k/misc/i386/atan2_asm.s | 10 +- .../win32/win32k/misc/i386/ceil_asm.s | 10 +- .../win32/win32k/misc/i386/cos_asm.s | 8 +- .../win32/win32k/misc/i386/floor_asm.s | 12 +- .../win32/win32k/misc/i386/sin_asm.s | 8 +- reactos/tools/nci/ncitool.c | 102 +- 149 files changed, 3474 insertions(+), 2029 deletions(-) create mode 100644 reactos/include/reactos/asm.inc create mode 100644 reactos/include/reactos/ks386.inc create mode 100644 reactos/lib/sdk/crt/math/i386/atan2_asm.s create mode 100644 reactos/lib/sdk/crt/math/i386/exp_asm.s create mode 100644 reactos/lib/sdk/crt/math/i386/fmod_asm.s create mode 100644 reactos/lib/sdk/crt/math/i386/fmodf_asm.s create mode 100644 reactos/lib/sdk/crt/math/i386/ftol2_asm.s delete mode 100644 reactos/lib/sdk/crt/string/i386/tcscat.h create mode 100644 reactos/lib/sdk/crt/string/i386/tcscat.inc delete mode 100644 reactos/lib/sdk/crt/string/i386/tcschr.h create mode 100644 reactos/lib/sdk/crt/string/i386/tcschr.inc delete mode 100644 reactos/lib/sdk/crt/string/i386/tcscmp.h create mode 100644 reactos/lib/sdk/crt/string/i386/tcscmp.inc delete mode 100644 reactos/lib/sdk/crt/string/i386/tcscpy.h create mode 100644 reactos/lib/sdk/crt/string/i386/tcscpy.inc delete mode 100644 reactos/lib/sdk/crt/string/i386/tcslen.h create mode 100644 reactos/lib/sdk/crt/string/i386/tcslen.inc delete mode 100644 reactos/lib/sdk/crt/string/i386/tcsncat.h create mode 100644 reactos/lib/sdk/crt/string/i386/tcsncat.inc delete mode 100644 reactos/lib/sdk/crt/string/i386/tcsncmp.h create mode 100644 reactos/lib/sdk/crt/string/i386/tcsncmp.inc delete mode 100644 reactos/lib/sdk/crt/string/i386/tcsncpy.h create mode 100644 reactos/lib/sdk/crt/string/i386/tcsncpy.inc delete mode 100644 reactos/lib/sdk/crt/string/i386/tcsnlen.h create mode 100644 reactos/lib/sdk/crt/string/i386/tcsnlen.inc delete mode 100644 reactos/lib/sdk/crt/string/i386/tcsrchr.h create mode 100644 reactos/lib/sdk/crt/string/i386/tcsrchr.inc diff --git a/reactos/boot/freeldr/freeldr/arch/amd64/arch.S b/reactos/boot/freeldr/freeldr/arch/amd64/arch.S index 9def109221c..236a0be4b69 100644 --- a/reactos/boot/freeldr/freeldr/arch/amd64/arch.S +++ b/reactos/boot/freeldr/freeldr/arch/amd64/arch.S @@ -1,10 +1,13 @@ -.intel_syntax noprefix -.text -.code16 #define ASM + +#include + #include +.text +.code16 + //.org 0x8000 .global RealEntryPoint diff --git a/reactos/boot/freeldr/freeldr/arch/amd64/boot.S b/reactos/boot/freeldr/freeldr/arch/amd64/boot.S index eb3ba3c3c64..bc2e43e9e8b 100644 --- a/reactos/boot/freeldr/freeldr/arch/amd64/boot.S +++ b/reactos/boot/freeldr/freeldr/arch/amd64/boot.S @@ -17,14 +17,17 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +#include + + .text .code16 #define ASM #include - -EXTERN(ChainLoadBiosBootSectorCode) +PUBLIC ChainLoadBiosBootSectorCode +ChainLoadBiosBootSectorCode: .code64 call x86_64_SwitchToReal @@ -46,7 +49,8 @@ EXTERN(ChainLoadBiosBootSectorCode) // ljmpl $0x0000,$0x7C00 jmp 0x7c00:0x0000 -EXTERN(SoftReboot) +PUBLIC SoftReboot +SoftReboot: .code64 call x86_64_SwitchToReal diff --git a/reactos/boot/freeldr/freeldr/arch/amd64/i386pnp.S b/reactos/boot/freeldr/freeldr/arch/amd64/i386pnp.S index 19589275bac..c74fb97d64d 100644 --- a/reactos/boot/freeldr/freeldr/arch/amd64/i386pnp.S +++ b/reactos/boot/freeldr/freeldr/arch/amd64/i386pnp.S @@ -17,6 +17,9 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +#include + + .text .code16 @@ -255,4 +258,5 @@ EXTERN(PnpBiosGetDeviceNode) ret +END /* EOF */ diff --git a/reactos/boot/freeldr/freeldr/arch/amd64/int386.S b/reactos/boot/freeldr/freeldr/arch/amd64/int386.S index a22e409c61c..6881173910d 100644 --- a/reactos/boot/freeldr/freeldr/arch/amd64/int386.S +++ b/reactos/boot/freeldr/freeldr/arch/amd64/int386.S @@ -17,6 +17,9 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +#include + + .intel_syntax noprefix .text .code16 @@ -168,3 +171,5 @@ Int386_vector_opcode: mov eax, Int386_eax ret + +END diff --git a/reactos/boot/freeldr/freeldr/arch/amd64/mb.S b/reactos/boot/freeldr/freeldr/arch/amd64/mb.S index 2d515e90053..51b06bc1e01 100644 --- a/reactos/boot/freeldr/freeldr/arch/amd64/mb.S +++ b/reactos/boot/freeldr/freeldr/arch/amd64/mb.S @@ -17,6 +17,9 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +#include + + .text .code16 @@ -61,3 +64,5 @@ pd_startup: .fill 4096, 1, 0 PageDirectoryEnd: + +END diff --git a/reactos/boot/freeldr/freeldr/arch/i386/arch.S b/reactos/boot/freeldr/freeldr/arch/i386/arch.S index 9e9475eecda..225dc4be3f9 100644 --- a/reactos/boot/freeldr/freeldr/arch/i386/arch.S +++ b/reactos/boot/freeldr/freeldr/arch/i386/arch.S @@ -17,27 +17,29 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ - .text - .code16 +.intel_syntax noprefix +#define HEX(y) 0x##y #define ASM #include #include + .code16 EXTERN(RealEntryPoint) cli /* Setup segment registers */ - xorw %ax,%ax - movw %ax,%ds - movw %ax,%es - movw %ax,%fs - movw %ax,%gs - movw %ax,%ss + xor ax, ax + mov ds, ax + mov es, ax + mov fs, ax + mov gs, ax + mov ss, ax + /* Setup a stack */ - movw stack16,%sp + mov sp, word ptr ds:stack16 sti @@ -47,24 +49,24 @@ EXTERN(RealEntryPoint) .code32 /* Zero BootDrive and BootPartition */ - xorl %eax,%eax - movl %eax,(_BootDrive) - movl %eax,(_BootPartition) + xor eax, eax + mov dword ptr [_BootDrive], eax + mov dword ptr [_BootPartition], eax /* Store the boot drive */ - movb %dl,(_BootDrive) + mov byte ptr [_BootDrive], dl /* Store the boot partition */ - movb %dh,(_BootPartition) + mov byte ptr [_BootPartition], dh /* GO! */ - pushl %eax + push eax call _BootMain call switch_to_real .code16 - int $0x19 + int HEX(19) /* We should never get here */ stop: @@ -78,7 +80,7 @@ stop: */ EXTERN(switch_to_prot) - .code16 +.code16 cli /* None of these */ @@ -88,18 +90,18 @@ EXTERN(switch_to_prot) /* Of course CS has to already be valid. */ /* We are currently in real-mode so we */ /* need real-mode segment values. */ - xorw %ax,%ax - movw %ax,%ds - movw %ax,%es - movw %ax,%fs - movw %ax,%gs - movw %ax,%ss + xor ax, ax + mov ds, ax + mov es, ax + mov fs, ax + mov gs, ax + mov ss, ax /* Get the return address off the stack */ - popw (code32ret) + pop word ptr ds:[code32ret] /* Save 16-bit stack pointer */ - movw %sp,stack16 + mov word ptr ds:[stack16], sp /* Load the GDT */ lgdt gdtptr @@ -107,28 +109,28 @@ EXTERN(switch_to_prot) lidt i386idtptr /* Enable Protected Mode */ - mov %cr0,%eax - orl $CR0_PE_SET,%eax - mov %eax,%cr0 + mov eax, cr0 + or eax, CR0_PE_SET + mov cr0, eax /* Clear prefetch queue & correct CS */ - ljmp $PMODE_CS, $inpmode + //ljmp PMODE_CS, inpmode + jmp far ptr PMODE_CS:inpmode - - .code32 +.code32 inpmode: /* Setup segment selectors */ - movw $PMODE_DS,%ax - movw %ax,%ds - movw %ax,%es - movw %ax,%fs - movw %ax,%gs - movw %ax,%ss - movl stack32,%esp + mov ax, PMODE_DS + mov ds, ax + mov es, ax + mov fs, ax + mov gs, ax + mov ss, ax + mov esp, dword ptr [stack32] /* Put the return address back onto the stack */ - pushl (code32ret) + push dword ptr [code32ret] /* Now return in p-mode! */ ret @@ -139,7 +141,7 @@ inpmode: */ EXTERN(switch_to_real) - .code32 +.code32 /* We don't know what values are currently */ /* in the segment registers. So we are */ @@ -147,48 +149,49 @@ EXTERN(switch_to_real) /* Of course CS has to already be valid. */ /* We are currently in protected-mode so we */ /* need protected-mode segment values. */ - movw $PMODE_DS,%ax - movw %ax,%ds - movw %ax,%es - movw %ax,%fs - movw %ax,%gs - movw %ax,%ss + mov ax, PMODE_DS + mov ds, ax + mov es, ax + mov fs, ax + mov gs, ax + mov ss, ax /* Get the return address off the stack */ - popl (code16ret) + pop dword ptr [code16ret] /* Save 32-bit stack pointer */ - movl %esp,stack32 + mov dword ptr [stack32], esp /* jmp to 16-bit segment to set the limit correctly */ - ljmp $RMODE_CS, $switch_to_real16 + ljmp RMODE_CS, switch_to_real16 switch_to_real16: - .code16 +.code16 /* Restore segment registers to correct limit */ - movw $RMODE_DS,%ax - movw %ax,%ds - movw %ax,%es - movw %ax,%fs - movw %ax,%gs - movw %ax,%ss + mov ax, RMODE_DS + mov ds, ax + mov es, ax + mov fs, ax + mov gs, ax + mov ss, ax /* Disable Protected Mode */ - mov %cr0,%eax - andl $CR0_PE_CLR,%eax - mov %eax,%cr0 + mov eax, cr0 + and eax, CR0_PE_CLR + mov cr0, eax /* Clear prefetch queue & correct CS */ - ljmp $0, $inrmode + //ljmp $0, $inrmode + jmp far ptr 0:inrmode inrmode: - movw %cs,%ax - movw %ax,%ds - movw %ax,%es - movw %ax,%fs - movw %ax,%gs - movw %ax,%ss + mov ax, cs + mov ds, ax + mov es, ax + mov fs, ax + mov gs, ax + mov ss, ax /* Clear out the high 16-bits of ESP */ /* This is needed because I have one */ @@ -196,12 +199,12 @@ inrmode: /* anything other than 0x0000 is in the high */ /* 16-bits of ESP. Even though real-mode */ /* code should only use SP and not ESP. */ - xorl %esp,%esp + xor esp, esp - movw stack16,%sp + mov sp, word ptr ds:[stack16] /* Put the return address back onto the stack */ - pushw (code16ret) + push word ptr ds:[code16ret] /* Load IDTR with real mode value */ lidt rmode_idtptr @@ -215,14 +218,14 @@ inrmode: /* * Needed for enabling the a20 address line */ - .code16 +.code16 empty_8042: .word 0x00eb,0x00eb // jmp $+2, jmp $+2 - inb $0x64,%al - cmp $0xff, %al // legacy-free machine without keyboard - jz empty_8042_ret // controllers on Intel Macs read back 0xFF - testb $0x02,%al - jnz empty_8042 + in al, HEX(64) + cmp al, HEX(ff) // legacy-free machine without keyboard + jz empty_8042_ret // controllers on Intel Macs read back 0xFF + test al, 2 + jnz empty_8042 empty_8042_ret: ret @@ -230,24 +233,24 @@ empty_8042_ret: * Enable the A20 address line (to allow access to over 1mb) */ EXTERN(_EnableA20) +.code32 + + pusha + + call switch_to_real +.code16 + + call empty_8042 + mov al, HEX(D1) // command write + out HEX(64), al + call empty_8042 + mov al, HEX(DF) // A20 on + out HEX(60), al + call empty_8042 + call switch_to_prot .code32 - pushal - - call switch_to_real - .code16 - - call empty_8042 - movb $0xD1,%al // command write - outb %al,$0x64 - call empty_8042 - mov $0xDF,%al // A20 on - out %al,$0x60 - call empty_8042 - call switch_to_prot - .code32 - - popal + popa ret @@ -255,24 +258,24 @@ EXTERN(_EnableA20) * Disable the A20 address line */ EXTERN(_DisableA20) - .code32 +.code32 - pushal + pusha - call switch_to_real + call switch_to_real .code16 call empty_8042 - movb $0xD1,%al // command write - outb %al,$0x64 - call empty_8042 - mov $0xDD,%al // A20 off - out %al,$0x60 + mov al, HEX(D1) // command write + out HEX(64), al + call empty_8042 + mov al, HEX(DD) // A20 off + out HEX(60), al call empty_8042 call switch_to_prot .code32 - popal + popa ret @@ -294,11 +297,11 @@ EXTERN(_DisableA20) * above 1MB. So we let Grub load us there and then relocate * ourself to 0x8000 */ -#define FREELDR_BASE 0x8000 -#define INITIAL_BASE 0x200000 +#define FREELDR_BASE HEX(8000) +#define INITIAL_BASE HEX(200000) /* Align 32 bits boundary */ - .align 4 +.align 4 /* Multiboot header */ MultibootHeader: @@ -330,44 +333,45 @@ MultibootEntry: * our own */ lgdt gdtptrhigh + INITIAL_BASE - FREELDR_BASE /* Reload segment selectors */ - ljmp $PMODE_CS, $(mb1 + INITIAL_BASE - FREELDR_BASE) + //ljmp $PMODE_CS, $(mb1 + INITIAL_BASE - FREELDR_BASE) + jmp far ptr PMODE_CS: (mb1 + INITIAL_BASE - FREELDR_BASE) mb1: - movw $PMODE_DS,%dx - movw %dx,%ds - movw %dx,%es + mov dx, PMODE_DS + mov ds, dx + mov es, dx /* Check for valid multiboot signature */ - cmpl $MULTIBOOT_BOOTLOADER_MAGIC,%eax - jne mbfail + cmp eax, MULTIBOOT_BOOTLOADER_MAGIC + jne mbfail /* Store multiboot info in a safe place */ - movl %ebx,%esi - movl $(mb_info + INITIAL_BASE - FREELDR_BASE),%edi - movl $MB_INFO_SIZE,%ecx + mov esi, ebx + mov edi, offset mb_info + INITIAL_BASE - FREELDR_BASE + mov ecx, MB_INFO_SIZE rep movsb /* Save commandline */ - movl MB_INFO_FLAGS_OFFSET(%ebx),%edx - testl $MB_INFO_FLAG_COMMAND_LINE,MB_INFO_FLAGS_OFFSET(%ebx) - jz mb3 - movl MB_INFO_COMMAND_LINE_OFFSET(%ebx),%esi - movl $(cmdline + INITIAL_BASE - FREELDR_BASE),%edi - movl $CMDLINE_SIZE,%ecx + mov edx, [ebx + MB_INFO_FLAGS_OFFSET] + test dword ptr [ebx + MB_INFO_FLAGS_OFFSET], MB_INFO_FLAG_COMMAND_LINE + jz mb3 + mov esi, [ebx + MB_INFO_COMMAND_LINE_OFFSET] + mov edi, offset cmdline + INITIAL_BASE - FREELDR_BASE + mov ecx, CMDLINE_SIZE mb2: lodsb stosb - testb %al,%al - jz mb3 - dec %ecx - jnz mb2 + test al, al + jz mb3 + dec ecx + jnz mb2 mb3: /* Copy to low mem */ - movl $INITIAL_BASE,%esi - movl $FREELDR_BASE,%edi - movl $(__bss_end__ - FREELDR_BASE),%ecx - addl $3,%ecx - shrl $2,%ecx - rep movsl + mov esi, INITIAL_BASE + mov edi, FREELDR_BASE + mov ecx, (offset __bss_end__ - FREELDR_BASE) + add ecx, 3 + shr ecx, 2 + rep movsd /* Load the GDT and IDT */ lgdt gdtptr @@ -375,47 +379,49 @@ mb3: /* Clear prefetch queue & correct CS, * jump to low mem */ - ljmp $PMODE_CS, $mb4 + //ljmp $PMODE_CS, $mb4 + jmp far ptr PMODE_CS:mb4 mb4: /* Reload segment selectors */ - movw $PMODE_DS,%dx - movw %dx,%ds - movw %dx,%es - movw %dx,%fs - movw %dx,%gs - movw %dx,%ss - movl $STACK32ADDR,%esp + mov dx, PMODE_DS + mov ds, dx + mov es, dx + mov fs, dx + mov gs, dx + mov ss, dx + mov esp, STACK32ADDR - movl $mb_info,%ebx + mov ebx, offset mb_info /* See if the boot device was passed in */ - movl MB_INFO_FLAGS_OFFSET(%ebx),%edx - testl $MB_INFO_FLAG_BOOT_DEVICE,%edx - jz mb5 + mov edx, [ebx + MB_INFO_FLAGS_OFFSET] + test edx, MB_INFO_FLAG_BOOT_DEVICE + jz mb5 /* Retrieve boot device info */ - movl MB_INFO_BOOT_DEVICE_OFFSET(%ebx),%eax - shrl $16,%eax - incb %al - movb %al,_BootPartition - movb %ah,_BootDrive - jmp mb6 + mov eax, [ebx + MB_INFO_BOOT_DEVICE_OFFSET] + shr eax, 16 + inc al + mov byte ptr _BootPartition, al + mov byte ptr _BootDrive, ah + jmp mb6 mb5: /* No boot device known, assume first partition of first harddisk */ - movb $0x80,_BootDrive - movb $1,_BootPartition + mov byte ptr _BootDrive, HEX(80) + mov byte ptr _BootPartition, 1 mb6: /* Check for command line */ - mov $cmdline,%eax - testl $MB_INFO_FLAG_COMMAND_LINE,MB_INFO_FLAGS_OFFSET(%ebx) - jnz mb7 - xorl %eax,%eax + mov eax, offset cmdline + test dword ptr [ebx + MB_INFO_FLAGS_OFFSET], MB_INFO_FLAG_COMMAND_LINE + jnz mb7 + xor eax, eax mb7: /* GO! */ - pushl %eax + push eax call _BootMain -mbfail: call switch_to_real +mbfail: + call switch_to_real .code16 - int $0x19 + int 0x19 mbstop: jmp mbstop /* We should never get here */ .code32 @@ -437,52 +443,52 @@ code32ret: .long 0 - .p2align 2 /* force 4-byte alignment */ + .align 4 /* force 4-byte alignment */ gdt: /* NULL Descriptor */ - .word 0x0000 - .word 0x0000 - .word 0x0000 - .word 0x0000 + .word HEX(0000) + .word HEX(0000) + .word HEX(0000) + .word HEX(0000) /* 32-bit flat CS */ - .word 0xFFFF - .word 0x0000 - .word 0x9A00 - .word 0x00CF + .word HEX(FFFF) + .word HEX(0000) + .word HEX(9A00) + .word HEX(00CF) /* 32-bit flat DS */ - .word 0xFFFF - .word 0x0000 - .word 0x9200 - .word 0x00CF + .word HEX(FFFF) + .word HEX(0000) + .word HEX(9200) + .word HEX(00CF) /* 16-bit real mode CS */ - .word 0xFFFF - .word 0x0000 - .word 0x9E00 - .word 0x0000 + .word HEX(FFFF) + .word HEX(0000) + .word HEX(9E00) + .word HEX(0000) /* 16-bit real mode DS */ - .word 0xFFFF - .word 0x0000 - .word 0x9200 - .word 0x0000 + .word HEX(FFFF) + .word HEX(0000) + .word HEX(9200) + .word HEX(0000) /* GDT table pointer */ gdtptr: - .word 0x27 /* Limit */ - .long gdt /* Base Address */ + .word HEX(27) /* Limit */ + .long gdt /* Base Address */ /* Initial GDT table pointer for multiboot */ gdtptrhigh: - .word 0x27 /* Limit */ - .long gdt + INITIAL_BASE - FREELDR_BASE /* Base Address */ + .word HEX(27) /* Limit */ + .long gdt + INITIAL_BASE - FREELDR_BASE /* Base Address */ /* Real-mode IDT pointer */ rmode_idtptr: - .word 0x3ff /* Limit */ - .long 0 /* Base Address */ + .word HEX(3ff) /* Limit */ + .long 0 /* Base Address */ mb_info: .fill MB_INFO_SIZE, 1, 0 diff --git a/reactos/dll/ntdll/dispatch/i386/dispatch.S b/reactos/dll/ntdll/dispatch/i386/dispatch.S index c17374e9ed1..25f7c34bcee 100644 --- a/reactos/dll/ntdll/dispatch/i386/dispatch.S +++ b/reactos/dll/ntdll/dispatch/i386/dispatch.S @@ -8,13 +8,22 @@ /* INCLUDES ******************************************************************/ -#include -.intel_syntax noprefix +#include +#include + +EXTERN _LdrpInit@12:PROC +EXTERN _NtTestAlert@0:PROC +EXTERN _RtlDispatchException@8:PROC +EXTERN _RtlRaiseException@4:PROC +EXTERN _RtlRaiseStatus@4:PROC +EXTERN _ZwCallbackReturn@12:PROC +EXTERN _ZwContinue@8:PROC +EXTERN _ZwRaiseException@12:PROC /* FUNCTIONS ****************************************************************/ +.code -.func LdrInitializeThunk@16 -.globl _LdrInitializeThunk@16 +PUBLIC _LdrInitializeThunk@16 _LdrInitializeThunk@16: /* Get the APC Context */ @@ -28,9 +37,8 @@ _LdrInitializeThunk@16: /* Jump into the C initialization routine */ jmp _LdrpInit@12 -.endfunc -.func KiUserApcExceptionHandler + _KiUserApcExceptionHandler: /* Put the exception record in ECX and check the Flags */ @@ -45,10 +53,9 @@ _KiUserApcExceptionHandler: /* We'll execute handler */ mov eax, EXCEPTION_EXECUTE_HANDLER ret 16 -.endfunc -.func KiUserApcDispatcher@16 -.globl _KiUserApcDispatcher@16 + +PUBLIC _KiUserApcDispatcher@16 _KiUserApcDispatcher@16: /* Setup SEH stack */ @@ -86,9 +93,8 @@ StatusRaiseApc: call _RtlRaiseStatus@4 jmp StatusRaiseApc ret 16 -.endfunc -.func KiUserCallbackExceptionHandler + _KiUserCallbackExceptionHandler: /* Put the exception record in ECX and check the Flags */ @@ -106,10 +112,9 @@ return: /* We'll execute the handler */ mov eax, EXCEPTION_EXECUTE_HANDLER ret 16 -.endfunc -.func KiUserCallbackDispatcher@12 -.globl _KiUserCallbackDispatcher@12 + +PUBLIC _KiUserCallbackDispatcher@12 _KiUserCallbackDispatcher@12: /* Setup SEH stack */ @@ -131,7 +136,7 @@ _KiUserCallbackDispatcher@12: mov eax, [eax+PEB_KERNEL_CALLBACK_TABLE] /* Call the routine */ - call [eax+edx*4] + call dword ptr [eax+edx*4] /* Return from callback */ push eax @@ -148,10 +153,9 @@ StatusRaise: call _RtlRaiseStatus@4 jmp StatusRaise ret 12 -.endfunc -.func KiRaiseUserExceptionDispatcher@0 -.globl _KiRaiseUserExceptionDispatcher@0 + +PUBLIC _KiRaiseUserExceptionDispatcher@0 _KiRaiseUserExceptionDispatcher@0: /* Setup stack for EXCEPTION_RECORD */ @@ -177,10 +181,9 @@ _KiRaiseUserExceptionDispatcher@0: mov esp, ebp pop ebp ret -.endfunc -.func KiUserExceptionDispatcher@8 -.globl _KiUserExceptionDispatcher@8 + +PUBLIC _KiUserExceptionDispatcher@8 _KiUserExceptionDispatcher@8: /* Clear direction flag */ @@ -236,39 +239,35 @@ Exit: push esp call _RtlRaiseException@4 ret 8 -.endfunc -.func KiIntSystemCall@0 -.globl _KiIntSystemCall@0 + +PUBLIC _KiIntSystemCall@0 _KiIntSystemCall@0: /* Set stack in EDX and do the interrupt */ lea edx, [esp+8] - int 0x2E + int HEX(2E) /* Return to caller */ ret -.endfunc -.func KiFastSystemCall@0 -.globl _KiFastSystemCall@0 + +PUBLIC _KiFastSystemCall@0 _KiFastSystemCall@0: /* Put ESP in EDX and do the SYSENTER */ mov edx, esp sysenter -.endfunc -.func KiFastSystemCallRet@0 -.globl _KiFastSystemCallRet@0 + +PUBLIC _KiFastSystemCallRet@0 _KiFastSystemCallRet@0: /* Just return to caller */ ret -.endfunc -.func RtlpGetStackLimits@8 -.globl _RtlpGetStackLimits@8 + +PUBLIC _RtlpGetStackLimits@8 _RtlpGetStackLimits@8: /* Get the stack limits */ @@ -283,4 +282,5 @@ _RtlpGetStackLimits@8: /* return */ ret 8 -.endfunc + +END diff --git a/reactos/dll/win32/kernel32/thread/amd64/fiber.S b/reactos/dll/win32/kernel32/thread/amd64/fiber.S index 984447abe11..09ea635d23c 100644 --- a/reactos/dll/win32/kernel32/thread/amd64/fiber.S +++ b/reactos/dll/win32/kernel32/thread/amd64/fiber.S @@ -7,11 +7,13 @@ * KJK::Hyperion */ -#include +#include -.globl SwitchToFiber -.intel_syntax noprefix + +PUBLIC SwitchToFiber SwitchToFiber: /* FIXME: TODO */ ret 4 + +END diff --git a/reactos/dll/win32/kernel32/thread/amd64/thread.S b/reactos/dll/win32/kernel32/thread/amd64/thread.S index 2c0c2260cb8..71ed562f816 100644 --- a/reactos/dll/win32/kernel32/thread/amd64/thread.S +++ b/reactos/dll/win32/kernel32/thread/amd64/thread.S @@ -6,9 +6,11 @@ * PROGRAMMER: Alex Ionescu (alex@relsoft.net) */ -.globl BaseThreadStartupThunk -.globl BaseProcessStartThunk -.intel_syntax noprefix +#include + + +PUBLIC BaseThreadStartupThunk +PUBLIC BaseProcessStartThunk BaseThreadStartupThunk: @@ -29,4 +31,5 @@ BaseProcessStartThunk: push 0 /* Return RIP */ jmp BaseProcessStartup +END /* EOF */ diff --git a/reactos/dll/win32/kernel32/thread/i386/fiber.S b/reactos/dll/win32/kernel32/thread/i386/fiber.S index 57358ffeed4..bf88c468487 100644 --- a/reactos/dll/win32/kernel32/thread/i386/fiber.S +++ b/reactos/dll/win32/kernel32/thread/i386/fiber.S @@ -7,11 +7,12 @@ * KJK::Hyperion */ -#include +#include +#include -.globl _SwitchToFiber@4 -.intel_syntax noprefix +.code +PUBLIC _SwitchToFiber@4 _SwitchToFiber@4: /* Get the TEB */ mov edx, fs:[TEB_SELF] @@ -30,7 +31,7 @@ _SwitchToFiber@4: mov [eax+FIBER_CONTEXT_EIP], ebx /* Check if we're to save FPU State */ - cmp dword ptr [eax+FIBER_CONTEXT_FLAGS], CONTEXT_FULL | CONTEXT_FLOATING_POINT + cmp dword ptr [eax+FIBER_CONTEXT_FLAGS], CONTEXT_FULL OR CONTEXT_FLOATING_POINT jnz NoFpuStateSave /* Save the FPU State (Status and Control)*/ @@ -80,7 +81,7 @@ NoFpuStateSave: mov [edx+TEB_ACTIVATION_CONTEXT_STACK_POINTER], esi /* Restore FPU State */ - cmp dword ptr [eax+FIBER_CONTEXT_FLAGS], CONTEXT_FULL | CONTEXT_FLOATING_POINT + cmp dword ptr [eax+FIBER_CONTEXT_FLAGS], CONTEXT_FULL OR CONTEXT_FLOATING_POINT jnz NoFpuStateRestore /* Check if the Status Word Changed */ @@ -96,7 +97,7 @@ NoFpuStateSave: StatusWordChanged: /* Load the new one */ - mov word ptr [ecx+FIBER_CONTEXT_FLOAT_SAVE_TAG_WORD], 0xFFFF + mov word ptr [ecx+FIBER_CONTEXT_FLOAT_SAVE_TAG_WORD], HEX(0FFFF) fldenv [ecx+FIBER_CONTEXT_FLOAT_SAVE_CONTROL_WORD] ControlWordEqual: @@ -120,6 +121,7 @@ NoFpuStateRestore: mov [edx+TEB_FLS_DATA], eax /* Jump to new fiber */ - jmp [ecx+FIBER_CONTEXT_EIP] + jmp dword ptr [ecx+FIBER_CONTEXT_EIP] +END /* EOF */ diff --git a/reactos/dll/win32/kernel32/thread/i386/thread.S b/reactos/dll/win32/kernel32/thread/i386/thread.S index 5dea1ee7400..a07bcb2e60e 100644 --- a/reactos/dll/win32/kernel32/thread/i386/thread.S +++ b/reactos/dll/win32/kernel32/thread/i386/thread.S @@ -6,9 +6,15 @@ * PROGRAMMER: Alex Ionescu (alex@relsoft.net) */ -.globl _BaseThreadStartupThunk@0 -.globl _BaseProcessStartThunk@0 -.intel_syntax noprefix +#include + +.code + +EXTERN _BaseThreadStartup@8:PROC +EXTERN _BaseProcessStartup@4:PROC + +PUBLIC _BaseThreadStartupThunk@0 +PUBLIC _BaseProcessStartThunk@0 _BaseThreadStartupThunk@0: @@ -29,4 +35,5 @@ _BaseProcessStartThunk@0: push 0 /* Return EIP */ jmp _BaseProcessStartup@4 +END /* EOF */ diff --git a/reactos/hal/halx86/amd64/mps.S b/reactos/hal/halx86/amd64/mps.S index 35436520ae6..7a3b8c55aa6 100644 --- a/reactos/hal/halx86/amd64/mps.S +++ b/reactos/hal/halx86/amd64/mps.S @@ -8,8 +8,9 @@ /* INCLUDES ******************************************************************/ -#include -#include +#include + +#include /* FUNCTIONS *****************************************************************/ @@ -92,5 +93,5 @@ MpsTimerInterrupt: AFTER iret - +END /* EOF */ diff --git a/reactos/hal/halx86/amd64/systimer.S b/reactos/hal/halx86/amd64/systimer.S index 1cb3b6e02a3..47d2a844b23 100644 --- a/reactos/hal/halx86/amd64/systimer.S +++ b/reactos/hal/halx86/amd64/systimer.S @@ -7,8 +7,9 @@ /* INCLUDES ******************************************************************/ -#include -#include +#include + +#include /* GLOBALS *******************************************************************/ @@ -90,3 +91,4 @@ HalpClockInterrupt: UNIMPLEMENTED _HalpClockInterrupt iret +END diff --git a/reactos/hal/halx86/generic/i386/systimer.S b/reactos/hal/halx86/generic/i386/systimer.S index 1a5bb45a1b8..8534f88a204 100644 --- a/reactos/hal/halx86/generic/i386/systimer.S +++ b/reactos/hal/halx86/generic/i386/systimer.S @@ -7,12 +7,42 @@ /* INCLUDES ******************************************************************/ -#include -.intel_syntax noprefix +#include + +#include + +EXTERN _HalpAcquireSystemHardwareSpinLock@0:PROC +EXTERN _HalpReleaseCmosSpinLock@0:PROC +EXTERN _DbgBreakPoint@0:PROC +EXTERN _HalpCurrentRollOver:DWORD +EXTERN _HalpPerfCounterCutoff:DWORD + +#define PIC1_BASE HEX(20) /* IO base address for master PIC */ +#define PIC2_BASE HEX(A0) /* IO base address for slave PIC */ +#define PIC1_COMMAND PIC1_BASE +#define PIC1_DATA (PIC1_BASE+1) +#define PIC2_COMMAND PIC2_BASE +#define PIC2_DATA (PIC2_BASE+1) +#define PIC_EOI HEX(20) +#define PIC_SPECIFIC_EOI2 HEX(62) + +#define CMOS_ADDR HEX(70) +#define CMOS_DATA HEX(71) +#define CMOS_REGISTER_A HEX(0A) +#define CMOS_REGISTER_B HEX(0B) +#define CMOS_REGISTER_C HEX(0C) +#define CMOS_REGISTER_D HEX(0D) + +#define PIT_CH0 HEX(40) +#define PIT_MODE HEX(43) +#define SYSTEM_CTRL_PORT_A HEX(92) /* GLOBALS *******************************************************************/ -.globl _HalpPerfCounter +.data +ASSUME CS:NOTHING, DS:NOTHING, ES:NOTHING, FS:NOTHING, GS:NOTHING + +PUBLIC _HalpPerfCounter _HalpLastPerfCounterLow: .long 0 _HalpLastPerfCounterHigh: .long 0 _HalpPerfCounter: @@ -22,8 +52,8 @@ _HalpSystemHardwareFlags: .long 0 /* FUNCTIONS *****************************************************************/ -.global _HalpCalibrateStallExecution@0 -.func HalpCalibrateStallExecution@0 +.code +PUBLIC _HalpCalibrateStallExecution@0 _HalpCalibrateStallExecution@0: /* Setup the stack frame */ @@ -37,27 +67,27 @@ _HalpCalibrateStallExecution@0: /* Get the current interrupt mask on the PICs */ xor eax, eax - in al, 0xA1 + in al, PIC2_DATA shl eax, 8 - in al, 0x21 + in al, PIC1_DATA /* Save it */ push eax /* Now mask everything except the RTC and PIC 2 chain-interrupt */ - mov eax, ~((1 << 2) | (1 << 8)) + mov eax, NOT (HEX(04) OR HEX(100)) /* Program the PICs */ - out 0x21, al + out PIC1_DATA, al shr eax, 8 - out 0xA1, al + out PIC2_DATA, al /* Now get the IDT */ sidt [ebp-8] mov ecx, [ebp-6] /* Get the IDT entry for the RTC */ - mov eax, 0x38 + mov eax, HEX(38) shl eax, 3 add ecx, eax @@ -70,7 +100,7 @@ _HalpCalibrateStallExecution@0: mov eax, offset OnlyOnePersonCanWriteHalCode mov [ecx], ax mov word ptr [ecx+2], KGDT_R0_CODE - mov word ptr [ecx+4], 0x8E00 + mov word ptr [ecx+4], HEX(08E00) shr eax, 16 mov [ecx+6], ax @@ -81,18 +111,18 @@ _HalpCalibrateStallExecution@0: call _HalpAcquireSystemHardwareSpinLock@0 /* Now initialize register A on the CMOS */ - mov ax, (0x2D << 8) | 0xA - out 0x70, al + mov ax, HEX(2D00) OR CMOS_REGISTER_A + out CMOS_ADDR, al jmp $+2 mov al, ah - out 0x71, al + out CMOS_DATA, al jmp $+2 /* Read register B */ - mov ax, 0xB - out 0x70, al + mov ax, CMOS_REGISTER_B + out CMOS_ADDR, al jmp $+2 - in al, 0x71 + in al, CMOS_DATA jmp $+2 /* Don't touch the LastKnownGoodConfig hack */ @@ -100,28 +130,28 @@ _HalpCalibrateStallExecution@0: mov ah, al /* Enable the interrupt */ - or ah, 0x42 + or ah, HEX(42) /* Now write the register B */ - mov al, 0xB - out 0x70, al + mov al, CMOS_REGISTER_B + out CMOS_ADDR, al jmp $+2 mov al, ah - out 0x71, al + out CMOS_DATA, al jmp $+2 /* Read register C */ - mov al, 0xC - out 0x70, al + mov al, CMOS_REGISTER_C + out CMOS_ADDR, al jmp $+2 - in al, 0x71 + in al, CMOS_DATA jmp $+2 /* Read register D */ - mov al, 0xD - out 0x70, al + mov al, CMOS_REGISTER_D + out CMOS_ADDR, al jmp $+2 - in al, 0x71 + in al, CMOS_DATA jmp $+2 /* Release CMOS lock */ @@ -169,18 +199,18 @@ OnlyOnePersonCanWriteHalCode: call _HalpAcquireSystemHardwareSpinLock@0 /* Now initialize register A on the CMOS */ - mov ax, (0x2D << 8) | 0xA - out 0x70, al + mov ax, HEX(2D00) OR CMOS_REGISTER_A + out CMOS_ADDR, al jmp $+2 mov al, ah - out 0x71, al + out CMOS_DATA, al jmp $+2 /* Read register B */ - mov ax, 0xB - out 0x70, al + mov ax, CMOS_REGISTER_B + out CMOS_ADDR, al jmp $+2 - in al, 0x71 + in al, CMOS_DATA jmp $+2 /* Don't touch the LastKnownGoodConfig hack */ @@ -188,38 +218,38 @@ OnlyOnePersonCanWriteHalCode: mov ah, al /* Enable the interrupt */ - or ah, 0x42 + or ah, HEX(42) /* Now write the register B */ - mov al, 0xB - out 0x70, al + mov al, CMOS_REGISTER_B + out CMOS_ADDR, al jmp $+2 mov al, ah - out 0x71, al + out CMOS_DATA, al jmp $+2 /* Read register C */ - mov al, 0xC - out 0x70, al + mov al, CMOS_REGISTER_C + out CMOS_ADDR, al jmp $+2 - in al, 0x71 + in al, CMOS_DATA jmp $+2 /* Read register D */ - mov al, 0xD - out 0x70, al + mov al, CMOS_REGISTER_D + out CMOS_ADDR, al jmp $+2 - in al, 0x71 + in al, CMOS_DATA jmp $+2 /* Release CMOS lock */ call _HalpReleaseCmosSpinLock@0 /* Dismiss the interrupt */ - mov al, 0x20 - out 0xA0, al - mov al, 0x62 - out 0x20, al + mov al, PIC_EOI + out PIC2_COMMAND, al + mov al, PIC_SPECIFIC_EOI2 + out PIC1_COMMAND, al /* Reset the counter and return back to the looper */ xor eax, eax @@ -248,24 +278,24 @@ FoundFactor: /* Prepare for interrupt return */ pop eax push offset AndItsNotYou - mov eax, 0x13 + mov eax, HEX(13) /* Acquire CMOS lock */ call _HalpAcquireSystemHardwareSpinLock@0 /* Now initialize register A on the CMOS */ - mov ax, (0x2D << 8) | 0xA - out 0x70, al + mov ax, HEX(2D00) OR CMOS_REGISTER_A + out CMOS_ADDR, al jmp $+2 mov al, ah - out 0x71, al + out CMOS_DATA, al jmp $+2 /* Read register B */ - mov ax, 0xB - out 0x70, al + mov ax, CMOS_REGISTER_B + out CMOS_ADDR, al jmp $+2 - in al, 0x71 + in al, CMOS_DATA jmp $+2 /* Don't touch the LastKnownGoodConfig hack */ @@ -273,34 +303,34 @@ FoundFactor: mov ah, al /* Disable the interrupt */ - or ah, 0x2 + or ah, 2 /* Now write the register B */ - mov al, 0xB - out 0x70, al + mov al, CMOS_REGISTER_B + out CMOS_ADDR, al jmp $+2 mov al, ah - out 0x71, al + out CMOS_DATA, al jmp $+2 /* Read register C */ - mov al, 0xC - out 0x70, al + mov al, CMOS_REGISTER_C + out CMOS_ADDR, al jmp $+2 - in al, 0x71 + in al, CMOS_DATA jmp $+2 /* Release CMOS lock */ call _HalpReleaseCmosSpinLock@0 /* Dismiss the interrupt */ - mov al, 0x20 - out 0xA0, al - mov al, 0x62 - out 0x20, al + mov al, PIC_EOI + out PIC2_COMMAND, al + mov al, PIC_SPECIFIC_EOI2 + out PIC1_COMMAND, al /* Disable interrupts on return */ - and word ptr [esp+8], ~EFLAGS_INTERRUPT_MASK + and word ptr [esp+8], NOT EFLAGS_INTERRUPT_MASK iretd /************************* WE ARE BACK FROM RTC ***************************/ @@ -313,9 +343,9 @@ AndItsNotYou: /* Restore the mask */ pop eax - out 0x21, al + out PIC1_DATA, al shr eax, 8 - out 0xA1, al + out PIC2_DATA, al /* Restore EFLAGS */ popf @@ -324,11 +354,10 @@ AndItsNotYou: mov esp, ebp pop ebp ret -.endfunc + #ifndef _MINIHAL_ -.globl _KeStallExecutionProcessor@4 -.func KeStallExecutionProcessor@4 +PUBLIC _KeStallExecutionProcessor@4 _KeStallExecutionProcessor@4: /* Get the number of microseconds required */ @@ -356,11 +385,9 @@ SubtractLoop: Done: /* Return */ ret 4 -.endfunc #endif -.global _KeQueryPerformanceCounter@4 -.func KeQueryPerformanceCounter@4 +PUBLIC _KeQueryPerformanceCounter@4 _KeQueryPerformanceCounter@4: /* Check if we were called too early */ @@ -380,20 +407,20 @@ LoopPreInt: LoopPostInt: /* Get the current value */ - mov ebx, _HalpPerfCounterLow - mov esi, _HalpPerfCounterHigh + mov ebx, dword ptr _HalpPerfCounterLow + mov esi, dword ptr _HalpPerfCounterHigh /* Read 8254 timer */ - mov al, 0 - out 0x43, al - in al, 0x92 - or al, _HalpPerfCounterCutoff - out 0x92, al + mov al, 0 /* Interrupt on terminal count */ + out PIT_MODE, al + in al, SYSTEM_CTRL_PORT_A + or al, byte ptr _HalpPerfCounterCutoff + out SYSTEM_CTRL_PORT_A, al jmp $+2 - in al, 0x40 + in al, PIT_CH0 jmp $+2 movzx ecx, al - in al, 0x40 + in al, PIT_CH0 mov ch, al /* Enable interrupts and do a short wait */ @@ -406,8 +433,8 @@ LoopPostInt: cli /* Get the counter value again */ - mov eax, _HalpPerfCounterLow - mov edx, _HalpPerfCounterHigh + mov eax, dword ptr _HalpPerfCounterLow + mov edx, dword ptr _HalpPerfCounterHigh /* Check if someone updated the counter */ cmp eax, ebx @@ -417,7 +444,7 @@ LoopPostInt: /* Check if the current 8254 value causes rollover */ neg ecx - add ecx, _HalpCurrentRollOver + add ecx, dword ptr _HalpCurrentRollOver jnb DoRollOver SetSum: @@ -427,19 +454,19 @@ SetSum: adc edx, 0 /* Check if we're above or below the last high value */ - cmp edx, _HalpLastPerfCounterHigh + cmp edx, dword ptr _HalpLastPerfCounterHigh jb short BelowHigh jnz short BelowLow /* Check if we're above or below the last low value */ - cmp eax, _HalpLastPerfCounterLow + cmp eax, dword ptr _HalpLastPerfCounterLow jb BelowHigh BelowLow: /* Update the last value and bring back interrupts */ - mov _HalpLastPerfCounterLow, eax - mov _HalpLastPerfCounterHigh, edx + mov dword ptr _HalpLastPerfCounterLow, eax + mov dword ptr _HalpLastPerfCounterHigh, edx popf /* Check if caller wants frequency */ @@ -469,7 +496,7 @@ DoRollOver: /* We might have an incoming interrupt, save EFLAGS and reset rollover */ mov esi, [esp] - mov ecx, _HalpCurrentRollOver + mov ecx, dword ptr _HalpCurrentRollOver popf /* Check if interrupts were enabled and try again */ @@ -483,8 +510,8 @@ DoRollOver: BelowHigh: /* Get the last counter values */ - mov ebx, _HalpLastPerfCounterLow - mov esi, _HalpLastPerfCounterHigh + mov ebx, dword ptr _HalpLastPerfCounterLow + mov esi, dword ptr _HalpLastPerfCounterHigh /* Check if the previous value was 0 and go back if yes */ mov ecx, ebx @@ -495,7 +522,7 @@ BelowHigh: sub ebx, eax sbb esi, edx jnz InvalidCount - cmp ebx, _HalpCurrentRollOver + cmp ebx, dword ptr _HalpCurrentRollOver jg InvalidCount /* Fixup the count with the last known value */ @@ -517,7 +544,8 @@ BelowHigh: InvalidCount: popf xor eax, eax - mov _HalpLastPerfCounterLow, eax - mov _HalpLastPerfCounterHigh, eax + mov dword ptr _HalpLastPerfCounterLow, eax + mov dword ptr _HalpLastPerfCounterHigh, eax jmp LoopPreInt -.endfunc + +END diff --git a/reactos/hal/halx86/generic/i386/trap.S b/reactos/hal/halx86/generic/i386/trap.S index 2ad319bfb6e..8a4f4538144 100644 --- a/reactos/hal/halx86/generic/i386/trap.S +++ b/reactos/hal/halx86/generic/i386/trap.S @@ -8,12 +8,12 @@ /* INCLUDES ******************************************************************/ -#include -#include +#include + +#include #include -.code32 -.text +.code TRAP_ENTRY HalpTrap0D, 0 TRAP_ENTRY HalpApcInterrupt, KI_SOFTWARE_TRAP @@ -42,4 +42,6 @@ _HalpRealModeStart: .space 2048 _HalpRealModeEnd: PUBLIC _HalpRealModeEnd +.endcode16 +END diff --git a/reactos/include/reactos/asm.inc b/reactos/include/reactos/asm.inc new file mode 100644 index 00000000000..4274221fc19 --- /dev/null +++ b/reactos/include/reactos/asm.inc @@ -0,0 +1,262 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS Kernel + * FILE: ntoskrnl/include/amd64/asmmacro.S + * PURPOSE: ASM macros for for GAS and MASM/ML64 + * PROGRAMMERS: Timo Kreuzer (timo.kreuzer@reactos.org) + */ + +#ifdef _USE_ML + +/* Allow ".name" identifiers */ +OPTION DOTNAME + +.686P +.XMM +.MODEL FLAT +ASSUME CS:NOTHING, DS:NOTHING, ES:NOTHING, FS:NOTHING, GS:NOTHING + +/* Hex numbers need to be in 01ABh format */ +#define HEX(x) 0##x##h + +/* Macro values need to be marked */ +#define VAL(x) x + +/* MASM/ML doesn't want explicit [rip] addressing */ +rip = 0 + +/* Due to MASM's reverse syntax, we are forced to use a precompiler macro */ +#define MACRO(name, ...) name MACRO __VA_ARGS__ + +/* To avoid reverse syntax we provide a new macro .PROC, replacing PROC... */ +.PROC MACRO name + name PROC FRAME + _name: +ENDM + +/* ... and .ENDP, replacing ENDP */ +.ENDP MACRO name + name ENDP +ENDM + +/* MASM doesn't have an ASCII macro */ +.ASCII MACRO text + DB text +ENDM + +/* MASM doesn't have an ASCIZ macro */ +.ASCIZ MACRO text + DB text, 0 +ENDM + +#define lgdt lgdt fword ptr ds: + +#define lidt lidt fword ptr ds: + +ljmp MACRO segment, offset + DB 0 +ENDM + +.code64 MACRO + .code +ENDM + +.code32 MACRO + .code + .586P +ENDM + +.code16 MACRO + ASSUME nothing + .text SEGMENT use16 +ENDM + +.endcode16 MACRO + .text ENDS +ENDM + +.bss MACRO + .DATA? + ASSUME nothing +ENDM + +//.text MACRO +//ENDM + +.align MACRO alignment + ALIGN alignment +ENDM + +.byte MACRO args:VARARG + db args +ENDM + +.short MACRO args:VARARG + dw args +ENDM + +.word MACRO args:VARARG + dw args +ENDM + +.long MACRO args:VARARG + dd args +ENDM + +.double MACRO args:VARARG + dq args +ENDM + +.org MACRO value + ORG value +ENDM + +.fill MACRO repeat, size, value +// FIXME +ENDM + +ljmp MACRO segment, offset +// FIXME +ENDM + +UNIMPLEMENTED MACRO name +ENDM + +/* We need this to distinguish repeat from macros */ +#define ENDR ENDM + +#else /***********************************************************************/ + +/* Force intel syntax */ +.intel_syntax noprefix + +.altmacro + +/* Hex numbers need to be in 0x1AB format */ +#define HEX(y) 0x##y + +/* Macro values need to be marked */ +#define VAL(x) \x + +/* Due to MASM's reverse syntax, we are forced to use a precompiler macro */ +#define MACRO(...) .macro __VA_ARGS__ +#define ENDM .endm + +/* To avoid reverse syntax we provide a new macro .PROC, replacing PROC... */ +.macro .PROC name + .func \name + \name: + .cfi_startproc + .equ cfa_current_offset, -8 +.endm + +/* ... and .ENDP, replacing ENDP */ +.macro .ENDP name + .cfi_endproc + .endfunc +.endm + +/* MASM compatible PUBLIC */ +.macro PUBLIC symbol + .global \symbol +.endm + +/* Dummy ASSUME */ +.macro ASSUME p1 p2 p3 p4 p5 p6 p7 p8 +.endm + +/* MASM needs an end tag for segments */ +.macro .endcode16 +.endm + +/* MASM compatible ALIGN */ +#define ALIGN .align + +/* MASM compatible REPEAT, additional ENDR */ +#define REPEAT .rept +#define ENDR .endr + +.macro ljmp segment, offset + jmp far ptr \segment:\offset +.endm + +/* MASM compatible EXTERN */ +.macro EXTERN name +.endm + +/* MASM needs an END tag */ +#define END + +.macro .MODEL model +.endm + +.macro .code + .text +.endm + +/* Macros for x64 stack unwind OPs */ + +.macro .allocstack size + .cfi_adjust_cfa_offset \size + .set cfa_current_offset, cfa_current_offset - \size +.endm + +code = 1 +.macro .pushframe param=0 + .if (\param) + .cfi_adjust_cfa_offset 0x30 + .set cfa_current_offset, cfa_current_offset - 0x30 + .else + .cfi_adjust_cfa_offset 0x28 + .set cfa_current_offset, cfa_current_offset - 0x28 + .endif +.endm + +.macro .pushreg reg + .cfi_adjust_cfa_offset 8 + .equ cfa_current_offset, cfa_current_offset - 8 + .cfi_offset \reg, cfa_current_offset +.endm + +.macro .savereg reg, offset + // checkme!!! + .cfi_offset \reg, \offset +.endm + +.macro .savexmm128 reg, offset + // checkme!!! + .cfi_offset \reg, \offset +.endm + +.macro .setframe reg, offset + .cfi_def_cfa reg, \offset + .equ cfa_current_offset, \offset +.endm + +.macro .endprolog +.endm + +.macro UNIMPLEMENTED2 file, line, func + + jmp 3f +1: .asciz "\func" +2: .asciz \file +3: + sub rsp, 0x20 + lea rcx, MsgUnimplemented[rip] + lea rdx, 1b[rip] + lea r8, 2b[rip] + mov r9, \line + call DbgPrint + add rsp, 0x20 +.endm +#define UNIMPLEMENTED UNIMPLEMENTED2 __FILE__, __LINE__, + +/* MASM/ML uses ".if" for runtime conditionals, and "if" for compile time + conditionals. We therefore use "if", too. .if shouldn't be used at all */ +#define if .if +#define endif .endif +#define else .else +#define elseif .elseif + +#endif diff --git a/reactos/include/reactos/ks386.inc b/reactos/include/reactos/ks386.inc new file mode 100644 index 00000000000..a4272847a9f --- /dev/null +++ b/reactos/include/reactos/ks386.inc @@ -0,0 +1,946 @@ + +/* Pointer size */ +SizeofPointer = 0x4 + +/* Breakpoints */ +BREAKPOINT_BREAK = 0x0 +BREAKPOINT_PRINT = 0x1 +BREAKPOINT_PROMPT = 0x2 +BREAKPOINT_LOAD_SYMBOLS = 0x3 +BREAKPOINT_UNLOAD_SYMBOLS = 0x4 +BREAKPOINT_COMMAND_STRING = 0x5 + +/* Context Frame Flags */ +CONTEXT_FULL = 0x10007 +CONTEXT_CONTROL = 0x10001 +CONTEXT_INTEGER = 0x10002 +CONTEXT_SEGMENTS = 0x10004 +CONTEXT_FLOATING_POINT = 0x10008 +CONTEXT_DEBUG_REGISTERS = 0x10010 + +/* Exception flags */ +EXCEPTION_NONCONTINUABLE = 0x1 +EXCEPTION_UNWINDING = 0x2 +EXCEPTION_EXIT_UNWIND = 0x4 +EXCEPTION_STACK_INVALID = 0x8 +EXCEPTION_NESTED_CALL = 0x10 +EXCEPTION_TARGET_UNWIND = 0x20 +EXCEPTION_COLLIDED_UNWIND = 0x20 +EXCEPTION_UNWIND = 0x6 +EXCEPTION_EXECUTE_HANDLER = 0x1 +EXCEPTION_CONTINUE_SEARCH = 0x0 +EXCEPTION_CONTINUE_EXECUTION = 0xffffffff +EXCEPTION_CHAIN_END = 0xffffffff + +/* Exception types */ +ExceptionContinueExecution = 0x0 +ExceptionContinueSearch = 0x1 +ExceptionNestedException = 0x2 +ExceptionCollidedUnwind = 0x3 + +/* Lock Queue */ +LOCK_QUEUE_WAIT = 0x1 +LOCK_QUEUE_OWNER = 0x2 +LockQueueDispatcherLock = 0x0 + +/* Process states */ +ProcessInMemory = 0x0 +ProcessOutOfMemory = 0x1 +ProcessInTransition = 0x2 + +/* Processor mode */ +KernelMode = 0x0 +UserMode = 0x1 + +/* Status codes */ +STATUS_ACCESS_VIOLATION = 0xc0000005 +STATUS_ASSERTION_FAILURE = 0xc0000420 +STATUS_ARRAY_BOUNDS_EXCEEDED = 0xc000008c +STATUS_BAD_COMPRESSION_BUFFER = 0xc0000242 +STATUS_BREAKPOINT = 0x80000003 +STATUS_CALLBACK_POP_STACK = 0xc0000423 +STATUS_DATATYPE_MISALIGNMENT = 0x80000002 +STATUS_FLOAT_DENORMAL_OPERAND = 0xc000008d +STATUS_FLOAT_DIVIDE_BY_ZERO = 0xc000008e +STATUS_FLOAT_INEXACT_RESULT = 0xc000008f +STATUS_FLOAT_INVALID_OPERATION = 0xc0000090 +STATUS_FLOAT_OVERFLOW = 0xc0000091 +STATUS_FLOAT_STACK_CHECK = 0xc0000092 +STATUS_FLOAT_UNDERFLOW = 0xc0000093 +STATUS_FLOAT_MULTIPLE_FAULTS = 0xc00002b4 +STATUS_FLOAT_MULTIPLE_TRAPS = 0xc00002b5 +STATUS_GUARD_PAGE_VIOLATION = 0x80000001 +STATUS_ILLEGAL_FLOAT_CONTEXT = 0xc000014a +STATUS_ILLEGAL_INSTRUCTION = 0xc000001d +STATUS_INSTRUCTION_MISALIGNMENT = 0xc00000aa +STATUS_INVALID_HANDLE = 0xc0000008 +STATUS_INVALID_LOCK_SEQUENCE = 0xc000001e +STATUS_INVALID_OWNER = 0xc000005a +STATUS_INVALID_PARAMETER = 0xc000000d +STATUS_INVALID_PARAMETER_1 = 0xc00000ef +STATUS_INVALID_SYSTEM_SERVICE = 0xc000001c +STATUS_INTEGER_DIVIDE_BY_ZERO = 0xc0000094 +STATUS_INTEGER_OVERFLOW = 0xc0000095 +STATUS_IN_PAGE_ERROR = 0xc0000006 +STATUS_KERNEL_APC = 0x100 +STATUS_LONGJUMP = 0x80000026 +STATUS_NO_CALLBACK_ACTIVE = 0xc0000258 +STATUS_NO_EVENT_PAIR = 0xc000014e +STATUS_PRIVILEGED_INSTRUCTION = 0xc0000096 +STATUS_SINGLE_STEP = 0x80000004 +STATUS_STACK_BUFFER_OVERRUN = 0xc0000409 +STATUS_STACK_OVERFLOW = 0xc00000fd +STATUS_SUCCESS = 0x0 +STATUS_THREAD_IS_TERMINATING = 0xc000004b +STATUS_TIMEOUT = 0x102 +STATUS_UNWIND = 0xc0000027 +STATUS_UNWIND_CONSOLIDATE = 0x80000029 +STATUS_USER_APC = 0xc0 +STATUS_WAKE_SYSTEM_DEBUGGER = 0x80000007 + +/* TLS defines */ +TLS_MINIMUM_AVAILABLE = 0x40 +TLS_EXPANSION_SLOTS = 0x400 + +/* Thread states */ +Initialized = 0x0 +Ready = 0x1 +Running = 0x2 +Standby = 0x3 +Terminated = 0x4 +Waiting = 0x5 + +/* Wait type / reason */ +WrExecutive = 0x7 +WrMutex = 0x1d +WrDispatchInt = 0x1f +WrQuantumEnd = 0x1e +WrEventPair = 0xe +WaitAny = 0x1 +WaitAll = 0x0 + +/* Interrupt object types */ +InLevelSensitive = 0x0 +InLatched = 0x1 + +/* Bug Check Codes */ +APC_INDEX_MISMATCH = 0x1 +INVALID_AFFINITY_SET = 0x3 +INVALID_DATA_ACCESS_TRAP = 0x4 +IRQL_NOT_GREATER_OR_EQUAL = 0x9 +IRQL_NOT_LESS_OR_EQUAL = 0xa +NO_USER_MODE_CONTEXT = 0xe +SPIN_LOCK_ALREADY_OWNED = 0xf +SPIN_LOCK_NOT_OWNED = 0x10 +THREAD_NOT_MUTEX_OWNER = 0x11 +TRAP_CAUSE_UNKNOWN = 0x12 +KMODE_EXCEPTION_NOT_HANDLED = 0x1e +KERNEL_APC_PENDING_DURING_EXIT = 0x20 +PANIC_STACK_SWITCH = 0x2b +DATA_BUS_ERROR = 0x2e +INSTRUCTION_BUS_ERROR = 0x2f +SYSTEM_EXIT_OWNED_MUTEX = 0x39 +PAGE_FAULT_WITH_INTERRUPTS_OFF = 0x49 +IRQL_GT_ZERO_AT_SYSTEM_SERVICE = 0x4a +DATA_COHERENCY_EXCEPTION = 0x55 +INSTRUCTION_COHERENCY_EXCEPTION = 0x56 +HAL1_INITIALIZATION_FAILED = 0x61 +UNEXPECTED_KERNEL_MODE_TRAP = 0x7f +NMI_HARDWARE_FAILURE = 0x80 +SPIN_LOCK_INIT_FAILURE = 0x81 +ATTEMPTED_SWITCH_FROM_DPC = 0xb8 + +/* IRQL */ +PASSIVE_LEVEL = 0x0 +APC_LEVEL = 0x1 +DISPATCH_LEVEL = 0x2 +CLOCK1_LEVEL = 0x1c +CLOCK2_LEVEL = 0x1c +IPI_LEVEL = 0x1d +POWER_LEVEL = 0x1e +PROFILE_LEVEL = 0x1b +HIGH_LEVEL = 0x1f +#ifdef NT_UP +SYNCH_LEVEL = 0x2 +#else +SYNCH_LEVEL = 0x1b +#endif + +/* Stack sizes */ +KERNEL_STACK_SIZE = 0x3000 +KERNEL_LARGE_STACK_SIZE = 0xf000 +KERNEL_LARGE_STACK_COMMIT = 0x3000 + +/* Miscellaneous Definitions */ +LOW_REALTIME_PRIORITY = 0x10 +CLOCK_QUANTUM_DECREMENT = 0x3 +WAIT_QUANTUM_DECREMENT = 0x1 +MAXIMUM_PROCESSORS = 0x20 +INITIAL_STALL_COUNT = 0x64 +KI_EXCEPTION_ACCESS_VIOLATION = 0x10000004 +Executive = 0x0 +FALSE = 0x0 +TRUE = 0x1 +DBG_STATUS_CONTROL_C = 0x1 +USER_SHARED_DATA = 0x7ffe0000 +PAGE_SIZE = 0x1000 +MAXIMUM_IDTVECTOR = 0xff +PRIMARY_VECTOR_BASE = 0x30 +RPL_MASK = 0x3 +MODE_MASK = 0x1 +NUMBER_SERVICE_TABLES = 0x2 +SERVICE_NUMBER_MASK = 0xfff +SERVICE_TABLE_SHIFT = 0x8 +SERVICE_TABLE_MASK = 0x10 +SERVICE_TABLE_TEST = 0x10 + +/* KAPC */ +ApType = 0x0 +ApSize = 0x2 +ApThread = 0x8 +ApApcListEntry = 0xc +ApKernelRoutine = 0x14 +ApRundownRoutine = 0x18 +ApNormalRoutine = 0x1c +ApNormalContext = 0x20 +ApSystemArgument1 = 0x24 +ApSystemArgument2 = 0x28 +ApApcStateIndex = 0x2c +ApApcMode = 0x2d +ApInserted = 0x2e +ApcObjectLength = 0x30 + +/* KAPC_STATE */ +AsApcListHead = 0x0 +AsProcess = 0x10 +AsKernelApcInProgress = 0x14 +AsKernelApcPending = 0x15 +AsUserApcPending = 0x16 + +/* CLIENT_ID */ +CidUniqueProcess = 0x0 +CidUniqueThread = 0x4 + +/* RTL_CRITICAL_SECTION */ +CsDebugInfo = 0x0 +CsLockCount = 0x4 +CsRecursionCount = 0x8 +CsOwningThread = 0xc +CsLockSemaphore = 0x10 +CsSpinCount = 0x14 + +/* RTL_CRITICAL_SECTION_DEBUG */ +CsType = 0x0 +CsCreatorBackTraceIndex = 0x2 +CsCriticalSection = 0x4 +CsProcessLocksList = 0x8 +CsEntryCount = 0x10 +CsContentionCount = 0x14 + +/* KDEVICE_QUEUE_ENTRY */ +DeDeviceListEntry = 0x0 +DeSortKey = 0x8 +DeInserted = 0xc +DeviceQueueEntryLength = 0x10 + +/* KDPC */ +DpType = 0x0 +DpImportance = 0x1 +DpNumber = 0x2 +DpDpcListEntry = 0x4 +DpDeferredRoutine = 0xc +DpDeferredContext = 0x10 +DpSystemArgument1 = 0x14 +DpSystemArgument2 = 0x18 +DpDpcData = 0x1c +DpcObjectLength = 0x20 + +/* KDEVICE_QUEUE */ +DvType = 0x0 +DvSize = 0x2 +DvDeviceListHead = 0x4 +DvSpinLock = 0xc +DvBusy = 0x10 +DeviceQueueObjectLength = 0x14 + +/* EXCEPTION_RECORD */ +ErExceptionCode = 0x0 +ErExceptionFlags = 0x4 +ErExceptionRecord = 0x8 +ErExceptionAddress = 0xc +ErNumberParameters = 0x10 +ErExceptionInformation = 0x14 +ExceptionRecordLength = 0x50 +EXCEPTION_RECORD_LENGTH = 0x50 + +/* EPROCESS */ +EpDebugPort = 0xcc +EpVdmObjects = 0x144 +ExecutiveProcessObjectLength = 0x278 + +/* KEVENT */ +EvType = 0x0 +EvSize = 0x2 +EvSignalState = 0x4 +EvWaitListHead = 0x8 +EventObjectLength = 0x10 + +/* FAST_MUTEX */ +FmCount = 0x0 +FmOwner = 0x4 +FmContention = 0x8 +FmOldIrql = 0x1c + +/* KINTERRUPT */ +InType = 0x0 +InSize = 0x2 +InInterruptListEntry = 0x4 +InServiceRoutine = 0xc +InServiceContext = 0x10 +InSpinLock = 0x14 +InTickCount = 0x18 +InActualLock = 0x1c +InDispatchAddress = 0x20 +InVector = 0x24 +InIrql = 0x28 +InSynchronizeIrql = 0x29 +InFloatingSave = 0x2a +InConnected = 0x2b +InNumber = 0x2c +InShareVector = 0x2d +InMode = 0x30 +InServiceCount = 0x34 +InDispatchCount = 0x38 +InDispatchCode = 0x3c +InterruptObjectLength = 0x1e4 + +/* IO_STATUS_BLOCK */ +IoStatus = 0x0 +IoPointer = 0x0 +IoInformation = 0x4 + +/* KNODE */ +KnPfnDereferenceSListHead = 0x8 +KnProcessorMask = 0x10 +KnColor = 0x14 +KnSeed = 0x18 +KnNodeNumber = 0x19 +KnFlags = 0x1a +knMmShiftedColor = 0x1e +KnFreeCount = 0x22 +KnPfnDeferredList = 0x2a +KNODE_SIZE = 0x2e + +/* KSPIN_LOCK_QUEUE */ +LqNext = 0x0 +LqLock = 0x4 + +/* KLOCK_QUEUE_HANDLE */ +LqhNext = 0x0 +LqhLock = 0x4 +LqhOldIrql = 0x8 +LOCK_QUEUE_HEADER_SIZE = 0xc + +/* LARGE_INTEGER */ +LiLowPart = 0x0 +LiHighPart = 0x4 + +/* LIST_ENTRY */ +LsFlink = 0x0 +LsBlink = 0x4 + +/* PEB */ +PeKernelCallbackTable = 0x2c +ProcessEnvironmentBlockLength = 0x230 + +/* KPROFILE */ +PfType = 0x0 +PfSize = 0x2 +PfProfileListEntry = 0x4 +PfProcess = 0xc +PfRangeBase = 0x10 +PfRangeLimit = 0x14 +PfBucketShift = 0x18 +PfBuffer = 0x1c +PfSegment = 0x20 +PfAffinity = 0x24 +PfSource = 0x28 +PfStarted = 0x2c +ProfileObjectLength = 0x30 + +/* PORT_MESSAGE */ +PmLength = 0x0 +PmZeroInit = 0x4 +PmClientId = 0x8 +PmProcess = 0x8 +PmThread = 0xc +PmMessageId = 0x10 +PmClientViewSize = 0x14 +PortMessageLength = 0x18 + +/* KPROCESS */ +PrType = 0x0 +PrSize = 0x2 +PrSignalState = 0x4 +PrProfileListHead = 0x10 +PrDirectoryTableBase = 0x18 +PrLdtDescriptor = 0x20 +PrIopmOffset = 0x30 +PrInt21Descriptor = 0x28 +PrVdmTrapcHandler = 0x4c +PrFlags = 0x6b +PrActiveProcessors = 0x34 +PrKernelTime = 0x38 +PrUserTime = 0x3c +PrReadyListHead = 0x40 +PrSwapListEntry = 0x48 +PrThreadListHead = 0x50 +PrProcessLock = 0x58 +PrAffinity = 0x5c +PrProcessFlags = 0x60 +PrBasePriority = 0x64 +PrQuantumReset = 0x65 +PrState = 0x66 +PrStackCount = 0x6c +KernelProcessObjectLength = 0x78 + +/* KQUEUE */ +QuType = 0x0 +QuSize = 0x2 +QuSignalState = 0x4 +QuEntryListHead = 0x10 +QuCurrentCount = 0x18 +QuMaximumCount = 0x1c +QuThreadListHead = 0x20 +QueueObjectLength = 0x28 + +/* STRING */ +StrLength = 0x0 +StrMaximumLength = 0x2 +StrBuffer = 0x4 + +/* TEB */ +TeCmTeb = 0x0 +TeExceptionList = 0x0 +TeStackBase = 0x4 +TeStackLimit = 0x8 +TeFiberData = 0x10 +TeSelf = 0x18 +TeEnvironmentPointer = 0x1c +TeClientId = 0x20 +TeActiveRpcHandle = 0x28 +TeThreadLocalStoragePointer = 0x2c +TeCountOfOwnedCriticalSections = 0x38 +TePeb = 0x30 +TeCsrClientThread = 0x3c +TeWOW32Reserved = 0xc0 +TeExceptionCode = 0x1a4 +TeActivationContextStackPointer = 0x1a8 +TeGdiClientPID = 0x6c0 +TeGdiClientTID = 0x6c4 +TeGdiThreadLocalInfo = 0x6c8 +TeglDispatchTable = 0x7c4 +TeglReserved1 = 0xb68 +TeglReserved2 = 0xbdc +TeglSectionInfo = 0xbe0 +TeglSection = 0xbe4 +TeglTable = 0xbe8 +TeglCurrentRC = 0xbec +TeglContext = 0xbf0 +TeDeallocationStack = 0xe0c +TeTlsSlots = 0xe10 +TeTlsExpansionSlots = 0xf94 +TeLastErrorValue = 0x34 +TeVdm = 0xf18 +TeInstrumentation = 0xf2c +TeGdiBatchCount = 0xf70 +TeGuaranteedStackBytes = 0xf78 +TeFlsData = 0xfb4 +ThreadEnvironmentBlockLength = 0xfbc + +/* TIME_FIELDS */ +TfSecond = 0xa +TfMinute = 0x8 +TfHour = 0x6 +TfWeekday = 0xe +TfDay = 0x4 +TfMonth = 0x2 +TfYear = 0x0 +TfMilliseconds = 0xc + +/* KTHREAD */ +ThType = 0x0 +ThSize = 0x2 +ThLock = 0x0 +ThDebugActive = 0x3 +ThSignalState = 0x4 +ThInitialStack = 0x18 +ThStackLimit = 0x1c +ThKernelStack = 0x20 +ThThreadLock = 0x24 +ThAlerted = 0x5e +ThApcState = 0x28 +ThPriority = 0x5b +ThSwapBusy = 0x5d +ThNextProcessor = 0x40 +ThDeferredProcessor = 0x41 +ThApcQueueLock = 0x44 +ThContextSwitches = 0x48 +ThState = 0x4c +ThNpxState = 0x4d +ThWaitIrql = 0x4e +ThWaitMode = 0x4f +ThWaitStatus = 0x50 +ThWaitBlockList = 0x54 +ThGateObject = 0x54 +ThWaitListEntry = 0x60 +ThSwapListEntry = 0x60 +ThQueue = 0x68 +ThWaitTime = 0x6c +ThCombinedApcDisable = 0x70 +ThKernelApcDisable = 0x70 +ThSpecialApcDisable = 0x72 +ThTeb = 0x74 +ThTimer = 0x78 +ThThreadFlags = 0xa0 +ThServiceTable = 0x118 +ThWaitBlock = 0xa8 +ThResourceIndex = 0xef +ThQueueListEntry = 0x108 +ThTrapFrame = 0x110 +ThCallbackStack = 0x114 +ThApcStateIndex = 0x11c +ThIdealProcessor = 0x11d +ThBasePriority = 0x121 +ThPriorityDecrement = 0x122 +ThAdjustReason = 0x42 +ThAdjustIncrement = 0x43 +ThPreviousMode = 0xd7 +ThSaturation = 0x123 +ThFreezeCount = 0x14f +ThUserAffinity = 0x124 +ThProcess = 0x128 +ThAffinity = 0x12c +ThUserIdealProcessor = 0x151 +ThApcStatePointer = 0x130 +ThSavedApcState = 0x138 +ThWaitReason = 0x5a +ThSuspendCount = 0x150 +ThWin32Thread = 0x154 +ThStackBase = 0x158 +ThSuspendApc = 0x15c +ThPowerState = 0x18b +ThKernelTime = 0x160 +ThLegoData = 0x184 +ThLargeStack = 0x107 +ThUserTime = 0x18c +ThSuspendSemaphore = 0x190 +ThSListFaultCount = 0x1a4 +ThThreadListEntry = 0x1a8 +ThMutantListHead = 0x10 +ThSListFaultAddress = 0x1b0 +KernelThreadObjectLength = 0x1b8 +ExecutiveThreadObjectLength = 0x250 + +/* KTIMER */ +TiType = 0x0 +TiSize = 0x2 +TiInserted = 0x3 +TiSignalState = 0x4 +TiDueTime = 0x10 +TiTimerListEntry = 0x18 +TiDpc = 0x20 +TiPeriod = 0x24 +TimerObjectLength = 0x28 + +/* TIME */ + +/* KUSER_SHARED_DATA */ +UsTickCountMultiplier = 0x4 +UsInterruptTime = 0x8 +UsSystemTime = 0x14 +UsTimeZoneBias = 0x20 +UsImageNumberLow = 0x2c +UsImageNumberHigh = 0x2e +UsNtSystemRoot = 0x30 +UsMaxStackTraceDepth = 0x238 +UsCryptoExponent = 0x23c +UsTimeZoneId = 0x240 +UsLargePageMinimum = 0x244 +UsReserved2 = 0x248 +UsNtProductType = 0x264 +UsProductTypeIsValid = 0x268 +UsNtMajorVersion = 0x26c +UsNtMinorVersion = 0x270 +UsProcessorFeatures = 0x274 +UsReserved1 = 0x2b4 +UsReserved3 = 0x2b8 +UsTimeSlip = 0x2bc +UsAlternativeArchitecture = 0x2c0 +UsSystemExpirationDate = 0x2c8 +UsSuiteMask = 0x2d0 +UsKdDebuggerEnabled = 0x2d4 +UsActiveConsoleId = 0x2d8 +UsDismountCount = 0x2dc +UsComPlusPackage = 0x2e0 +UsLastSystemRITEventTickCount = 0x2e4 +UsNumberOfPhysicalPages = 0x2e8 +UsSafeBootMode = 0x2ec +UsTestRetInstruction = 0x2f8 +UsSystemCall = 0x300 +UsSystemCallReturn = 0x304 +UsSystemCallPad = 0x308 +UsTickCount = 0x320 +UsTickCountQuad = 0x320 +UsWow64SharedInformation = 0x340 + +/* KWAIT_BLOCK */ +WbWaitListEntry = 0x0 +WbThread = 0x8 +WbObject = 0xc +WbNextWaitBlock = 0x10 +WbWaitKey = 0x14 +WbWaitType = 0x16 + +/* CR0 flags */ +CR0_PE = 0x1 +CR0_MP = 0x2 +CR0_EM = 0x4 +CR0_TS = 0x8 +CR0_ET = 0x10 +CR0_NE = 0x20 +CR0_WP = 0x10000 +CR0_AM = 0x40000 +CR0_NW = 0x20000000 +CR0_CD = 0x40000000 +CR0_PG = 0x80000000 + +/* CR4 flags */ +CR4_VME = 0x1 +CR4_PVI = 0x2 +CR4_TSD = 0x4 +CR4_DE = 0x8 +CR4_PSE = 0x10 +CR4_PAE = 0x20 +CR4_MCE = 0x40 +CR4_PGE = 0x80 +CR4_FXSR = 0x200 +CR4_XMMEXCPT = 0x400 + +/* KeFeatureBits flags */ +KF_RDTSC = 0x2 +KF_CR4 = 0x4 +KF_GLOBAL_PAGE = 0x10 +KF_LARGE_PAGE = 0x20 +KF_CMPXCHG8B = 0x80 +KF_FAST_SYSCALL = 0x1000 +KF_V86_VIS = 0x1 + +/* Machine type definitions */ +MACHINE_TYPE_ISA = 0x0 +MACHINE_TYPE_EISA = 0x1 +MACHINE_TYPE_MCA = 0x2 + +/* EFLAGS */ +EFLAGS_TF = 0x100 +EFLAGS_INTERRUPT_MASK = 0x200 +EFLAGS_V86_MASK = 0x20000 +EFLAGS_ALIGN_CHECK = 0x40000 +EFLAGS_VIF = 0x80000 +EFLAGS_VIP = 0x100000 +EFLAGS_USER_SANITIZE = 0x3f4dd7 + +/* KDGT selectors */ +KGDT_R3_DATA = 0x20 +KGDT_R3_CODE = 0x18 +KGDT_R0_CODE = 0x8 +KGDT_R0_DATA = 0x10 +KGDT_R0_PCR = 0x30 +KGDT_TSS = 0x28 +KGDT_R3_TEB = 0x38 +KGDT_DF_TSS = 0x50 +KGDT_NMI_TSS = 0x58 +KGDT_LDT = 0x48 +NPX_STATE_NOT_LOADED = 0xa +NPX_STATE_LOADED = 0x0 +PF_XMMI_INSTRUCTIONS_AVAILABLE = 0x6 +EFLAG_SELECT = 0xc000 + +/* CONTEXT */ +CsContextFlags = 0x0 +CsDr0 = 0x4 +CsDr1 = 0x8 +CsDr2 = 0xc +CsDr3 = 0x10 +CsDr6 = 0x14 +CsDr7 = 0x18 +CsFloatSave = 0x1c +CsSegGs = 0x8c +CsSegFs = 0x90 +CsSegEs = 0x94 +CsSegDs = 0x98 +CsEdi = 0x9c +CsEsi = 0xa0 +CsEbx = 0xa4 +CsEdx = 0xa8 +CsEcx = 0xac +CsEax = 0xb0 +CsEbp = 0xb4 +CsEip = 0xb8 +CsSegCs = 0xbc +CsEflags = 0xc0 +CsEsp = 0xc4 +CsSegSs = 0xc8 +CsExtendedRegisters = 0xcc +ContextFrameLength = 0x2cc +CONTEXT_LENGTH = 0x2cc + +/* KGDTENTRY */ +KgdtBaseLow = 0x2 +KgdtBaseMid = 0x4 +KgdtBaseHi = 0x7 +KgdtLimitHi = 0x6 +KgdtLimitLow = 0x0 + +/* KTRAP_FRAME */ +TsExceptionList = 0x4c +TsPreviousPreviousMode = 0x48 +TsSegGs = 0x30 +TsSegFs = 0x50 +TsSegEs = 0x34 +TsSegDs = 0x38 +TsEdi = 0x54 +TsEsi = 0x58 +TsEbp = 0x60 +TsEbx = 0x5c +TsEdx = 0x3c +TsEcx = 0x40 +TsEax = 0x44 +TsErrCode = 0x64 +TsEip = 0x68 +TsSegCs = 0x6c +TsEflags = 0x70 +TsHardwareEsp = 0x74 +TsHardwareSegSs = 0x78 +TsTempSegCs = 0x10 +TsTempEsp = 0x14 +TsDbgEbp = 0x0 +TsDbgEip = 0x4 +TsDbgArgMark = 0x8 +TsDbgArgPointer = 0xc +TsDr0 = 0x18 +TsDr1 = 0x1c +TsDr2 = 0x20 +TsDr3 = 0x24 +TsDr6 = 0x28 +TsDr7 = 0x2c +TsV86Es = 0x7c +TsV86Ds = 0x80 +TsV86Fs = 0x84 +TsV86Gs = 0x88 +KTRAP_FRAME_LENGTH = 0x8c +KTRAP_FRAME_ALIGN = 0x4 +FRAME_EDITED = 0xfff8 + +/* KTSS */ +TssEsp0 = 0x4 +TssCR3 = 0x1c +TssEip = 0x20 +TssEFlags = 0x24 +TssEax = 0x28 +TssEbx = 0x34 +TssEcx = 0x2c +TssEdx = 0x30 +TssEsp = 0x38 +TssEbp = 0x3c +TssEsi = 0x40 +TssEdi = 0x44 +TssEs = 0x48 +TssCs = 0x4c +TssSs = 0x50 +TssDs = 0x54 +TssFs = 0x58 +TssGs = 0x5c +TssLDT = 0x60 +TssIoMapBase = 0x66 +TssIoMaps = 0x68 +TssLength = 0x20ac + +/* KPCR */ +KPCR_EXCEPTION_LIST = 0x0 +KPCR_PERF_GLOBAL_GROUP_MASK = 0x8 +KPCR_CONTEXT_SWITCHES = 0x10 +KPCR_TEB = 0x18 +KPCR_SELF = 0x1c +KPCR_PRCB = 0x20 +KPCR_IDT = 0x38 +KPCR_GDT = 0x3c +KPCR_TSS = 0x40 +KPCR_STALL_SCALE_FACTOR = 0x4c +KPCR_PRCB_DATA = 0x120 +KPCR_CURRENT_THREAD = 0x124 +KPCR_PRCB_NEXT_THREAD = 0x128 +KPCR_PRCB_DPC_QUEUE_DEPTH = 0xa4c +KPCR_PRCB_DPC_STACK = 0xa68 +KPCR_PRCB_MAXIMUM_DPC_QUEUE_DEPTH = 0xa6c +KPCR_PRCB_DPC_ROUTINE_ACTIVE = 0xa7a +KPCR_PRCB_TIMER_REQUEST = 0xa88 +KPCR_PRCB_QUANTUM_END = 0xaa1 +KPCR_PRCB_DEFERRED_READY_LIST_HEAD = 0xc10 +KPCR_PRCB_POWER_STATE_IDLE_FUNCTION = 0xec0 + +/* KTRAP_FRAME */ +KTRAP_FRAME_DEBUGEBP = 0x0 +KTRAP_FRAME_DEBUGEIP = 0x4 +KTRAP_FRAME_TEMPESP = 0x14 +KTRAP_FRAME_DR0 = 0x18 +KTRAP_FRAME_DR1 = 0x1c +KTRAP_FRAME_DR2 = 0x20 +KTRAP_FRAME_DR3 = 0x24 +KTRAP_FRAME_DR6 = 0x28 +KTRAP_FRAME_DR7 = 0x2c +KTRAP_FRAME_GS = 0x30 +KTRAP_FRAME_ES = 0x34 +KTRAP_FRAME_DS = 0x38 +KTRAP_FRAME_EDX = 0x3c +KTRAP_FRAME_ECX = 0x40 +KTRAP_FRAME_EAX = 0x44 +KTRAP_FRAME_PREVIOUS_MODE = 0x48 +KTRAP_FRAME_EXCEPTION_LIST = 0x4c +KTRAP_FRAME_FS = 0x50 +KTRAP_FRAME_EDI = 0x54 +KTRAP_FRAME_ESI = 0x58 +KTRAP_FRAME_EBX = 0x5c +KTRAP_FRAME_EBP = 0x60 +KTRAP_FRAME_ERROR_CODE = 0x64 +KTRAP_FRAME_EIP = 0x68 +KTRAP_FRAME_EFLAGS = 0x70 +KTRAP_FRAME_ESP = 0x74 +KTRAP_FRAME_SS = 0x78 +KTRAP_FRAME_V86_ES = 0x7c +KTRAP_FRAME_V86_DS = 0x80 +KTRAP_FRAME_V86_FS = 0x84 +KTRAP_FRAME_V86_GS = 0x88 +KTRAP_FRAME_SIZE = 0x8c +FRAME_EDITED = 0xfff8 + +/* CONTEXT */ +CONTEXT_FLAGS = 0x0 +CONTEXT_SEGGS = 0x8c +CONTEXT_SEGFS = 0x90 +CONTEXT_SEGES = 0x94 +CONTEXT_SEGDS = 0x98 +CONTEXT_EDI = 0x9c +CONTEXT_ESI = 0xa0 +CONTEXT_EBX = 0xa4 +CONTEXT_EDX = 0xa8 +CONTEXT_ECX = 0xac +CONTEXT_EAX = 0xb0 +CONTEXT_EBP = 0xb4 +CONTEXT_EIP = 0xb8 +CONTEXT_SEGCS = 0xbc +CONTEXT_EFLAGS = 0xc0 +CONTEXT_ESP = 0xc4 +CONTEXT_SEGSS = 0xc8 +CONTEXT_FRAME_LENGTH = 0x2cc + +/* FIBER */ +FIBER_PARAMETER = 0x0 +FIBER_EXCEPTION_LIST = 0x4 +FIBER_STACK_BASE = 0x8 +FIBER_STACK_LIMIT = 0xc +FIBER_DEALLOCATION_STACK = 0x10 +FIBER_CONTEXT = 0x14 +FIBER_CONTEXT_FLAGS = 0x14 +FIBER_CONTEXT_EAX = 0xc4 +FIBER_CONTEXT_EBX = 0xb8 +FIBER_CONTEXT_ECX = 0xc0 +FIBER_CONTEXT_EDX = 0xbc +FIBER_CONTEXT_ESI = 0xb4 +FIBER_CONTEXT_EDI = 0xb0 +FIBER_CONTEXT_EBP = 0xc8 +FIBER_CONTEXT_EIP = 0xcc +FIBER_CONTEXT_ESP = 0xd8 +FIBER_CONTEXT_DR6 = 0x28 +FIBER_CONTEXT_FLOAT_SAVE_CONTROL_WORD = 0x30 +FIBER_CONTEXT_FLOAT_SAVE_STATUS_WORD = 0x34 +FIBER_CONTEXT_FLOAT_SAVE_TAG_WORD = 0x38 +FIBER_GUARANTEED_STACK_BYTES = 0x2e0 +FIBER_FLS_DATA = 0x2e4 +FIBER_ACTIVATION_CONTEXT_STACK = 0x2e8 + +/* KTSS */ +KTSS_IOMAPBASE = 0x66 +KTSS_ESP0 = 0x4 + +/* EXCEPTION_RECORD */ +EXCEPTION_RECORD_EXCEPTION_CODE = 0x0 +EXCEPTION_RECORD_EXCEPTION_FLAGS = 0x4 +EXCEPTION_RECORD_EXCEPTION_RECORD = 0x8 +EXCEPTION_RECORD_EXCEPTION_ADDRESS = 0xc +EXCEPTION_RECORD_NUMBER_PARAMETERS = 0x10 +EXCEPTION_RECORD_EXCEPTION_ADDRESS = 0xc +SIZEOF_EXCEPTION_RECORD = 0x50 +EXCEPTION_RECORD_LENGTH = 0x50 + +/* KTHREAD */ +KTHREAD_DEBUG_ACTIVE = 0x3 +KTHREAD_INITIAL_STACK = 0x18 +KTHREAD_STACK_LIMIT = 0x1c +KTHREAD_TEB = 0x74 +KTHREAD_KERNEL_STACK = 0x20 +KTHREAD_APCSTATE_PROCESS = 0x38 +KTHREAD_PENDING_KERNEL_APC = 0x3d +KTHREAD_CONTEXT_SWITCHES = 0x48 +KTHREAD_STATE_ = 0x4c +KTHREAD_NPX_STATE = 0x4d +KTHREAD_WAIT_IRQL = 0x4e +KTHREAD_WAIT_REASON = 0x5a +KTHREAD_COMBINED_APC_DISABLE = 0x70 +KTHREAD_SPECIAL_APC_DISABLE = 0x72 +KTHREAD_LARGE_STACK = 0x107 +KTHREAD_TRAP_FRAME = 0x110 +KTHREAD_CALLBACK_STACK = 0x114 +KTHREAD_APC_STATE_INDEX = 0x11c +KTHREAD_STACK_BASE = 0x158 + +/* KPROCESS */ +KPROCESS_DIRECTORY_TABLE_BASE = 0x18 +KPROCESS_LDT_DESCRIPTOR0 = 0x20 +KPROCESS_LDT_DESCRIPTOR1 = 0x24 +KPROCESS_INT21_DESCRIPTOR0 = 0x28 +KPROCESS_INT21_DESCRIPTOR1 = 0x2c +KPROCESS_IOPM_OFFSET = 0x30 + +/* Teb */ +TEB_EXCEPTION_LIST = 0x0 +TEB_STACK_LIMIT = 0x8 +TEB_STACK_BASE = 0x4 +TEB_SELF = 0x18 +TEB_FIBER_DATA = 0x10 +TEB_PEB = 0x30 +TEB_EXCEPTION_CODE = 0x1a4 +PEB_KERNEL_CALLBACK_TABLE = 0x2c +TEB_FLS_DATA = 0xfb4 +TEB_ACTIVATION_CONTEXT_STACK_POINTER = 0x1a8 +TEB_GUARANTEED_STACK_BYTES = 0xf78 +TEB_DEALLOCATION_STACK = 0xe0c + +/* Misc */ +NPX_FRAME_LENGTH = 0x210 +FN_CR0_NPX_STATE = 0x20c +DR7_RESERVED_MASK = 0xdc00 +FP_CONTROL_WORD = 0x0 +FP_STATUS_WORD = 0x4 +FP_TAG_WORD = 0x8 +FP_DATA_SELECTOR = 0x18 +CBSTACK_RESULT = 0x20 +CBSTACK_RESULT_LENGTH = 0x24 +CBSTACK_TRAP_FRAME = 0x4 +CBSTACK_CALLBACK_STACK = 0x8 +SIZEOF_FX_SAVE_AREA = 0x210 +KUSER_SHARED_SYSCALL = 0x7ffe0300 +EXCEPTION_EXECUTE_HANDLER = 0x1 +STATUS_CALLBACK_POP_STACK = 0xc0000423 +CONTEXT_ALIGNED_SIZE = 0x2cc +PROCESSOR_FEATURE_FXSR = 0x7ffe0278 diff --git a/reactos/lib/rtl/amd64/debug_asm.S b/reactos/lib/rtl/amd64/debug_asm.S index c115feb12fc..ca09236c566 100644 --- a/reactos/lib/rtl/amd64/debug_asm.S +++ b/reactos/lib/rtl/amd64/debug_asm.S @@ -6,7 +6,7 @@ * PROGRAMER: Timo Kreuzer (timo.kreuzer@reactos.org) */ -#include +#include /* GLOBALS ****************************************************************/ diff --git a/reactos/lib/rtl/amd64/except_asm.S b/reactos/lib/rtl/amd64/except_asm.S index a4b35079fcd..54f44ce445a 100644 --- a/reactos/lib/rtl/amd64/except_asm.S +++ b/reactos/lib/rtl/amd64/except_asm.S @@ -8,8 +8,8 @@ /* INCLUDES ******************************************************************/ -#include -#include +#include +#include /* FUNCTIONS *****************************************************************/ diff --git a/reactos/lib/rtl/amd64/rtlmem.S b/reactos/lib/rtl/amd64/rtlmem.S index d0a82068251..e75161061ee 100644 --- a/reactos/lib/rtl/amd64/rtlmem.S +++ b/reactos/lib/rtl/amd64/rtlmem.S @@ -8,8 +8,7 @@ /* INCLUDES ******************************************************************/ -#include -#include +#include /* FUNCTIONS *****************************************************************/ diff --git a/reactos/lib/rtl/amd64/slist.S b/reactos/lib/rtl/amd64/slist.S index ca1ed3905d5..efdada51999 100644 --- a/reactos/lib/rtl/amd64/slist.S +++ b/reactos/lib/rtl/amd64/slist.S @@ -6,8 +6,8 @@ * PROGRAMMERS: Timo Kreuzer */ -#include -#include +#include +#include #define SLIST8A_DEPTH_MASK HEX(000000000000FFFF) #define SLIST8A_DEPTH_INC HEX(0000000000000001) diff --git a/reactos/lib/rtl/i386/debug_asm.S b/reactos/lib/rtl/i386/debug_asm.S index c79545f53c0..39b6fa84236 100644 --- a/reactos/lib/rtl/i386/debug_asm.S +++ b/reactos/lib/rtl/i386/debug_asm.S @@ -6,43 +6,39 @@ * PROGRAMER: Alex Ionescu (alex@relsoft.net) */ -.intel_syntax noprefix +#include /* GLOBALS ****************************************************************/ -.globl _DbgBreakPoint@0 -.globl _DbgBreakPointWithStatus@4 -.globl _DbgUserBreakPoint@0 -.globl _DebugService@20 -.globl _DebugService2@12 -.globl _DbgBreakPointNoBugCheck@0 -.globl _RtlpBreakWithStatusInstruction@0 +PUBLIC _DbgBreakPoint@0 +PUBLIC _DbgBreakPointWithStatus@4 +PUBLIC _DbgUserBreakPoint@0 +PUBLIC _DebugService@20 +PUBLIC _DebugService2@12 +PUBLIC _DbgBreakPointNoBugCheck@0 +PUBLIC _RtlpBreakWithStatusInstruction@0 /* FUNCTIONS ***************************************************************/ -.func DbgBreakPointNoBugCheck@0 +.code + _DbgBreakPointNoBugCheck@0: int 3 ret -.endfunc -.func DbgBreakPoint@0 _DbgBreakPoint@0: _DbgUserBreakPoint@0: int 3 ret -.endfunc -.func DbgBreakPointWithStatus@4 _DbgBreakPointWithStatus@4: mov eax, [esp+4] _RtlpBreakWithStatusInstruction@0: int 3 ret 4 -.endfunc -.func DebugService2@12 + _DebugService2@12: /* Setup the stack */ @@ -53,15 +49,14 @@ _DebugService2@12: mov eax, [ebp+16] mov ecx, [ebp+8] mov edx, [ebp+12] - int 0x2D + int HEX(2D) int 3 /* Restore stack */ pop ebp ret 12 -.endfunc -.func DebugService@20 + _DebugService@20: /* Setup the stack */ @@ -78,7 +73,7 @@ _DebugService@20: mov edx, [ebp+16] mov ebx, [ebp+20] mov edi, [ebp+24] - int 0x2D + int HEX(2D) int 3 /* Restore registers */ @@ -88,4 +83,5 @@ _DebugService@20: /* Return */ pop ebp ret 20 -.endfunc + +END diff --git a/reactos/lib/rtl/i386/except_asm.s b/reactos/lib/rtl/i386/except_asm.s index 9b2f856c724..53b07c69711 100644 --- a/reactos/lib/rtl/i386/except_asm.s +++ b/reactos/lib/rtl/i386/except_asm.s @@ -9,8 +9,13 @@ /* INCLUDES ******************************************************************/ -#include -.intel_syntax noprefix +#include +#include + +EXTERN _RtlpCheckForActiveDebugger@0:PROC +EXTERN _RtlDispatchException@8:PROC +EXTERN _ZwContinue@8:PROC +EXTERN _ZwRaiseException@12:PROC #define ExceptionContinueSearch 1 #define ExceptionNestedException 2 @@ -18,17 +23,17 @@ /* FUNCTIONS *****************************************************************/ -.func RtlpGetExceptionList@0 -.globl _RtlpGetExceptionList@0 +.code + +PUBLIC _RtlpGetExceptionList@0 _RtlpGetExceptionList@0: /* Return the exception list */ mov eax, fs:[TEB_EXCEPTION_LIST] ret -.endfunc -.func RtlpSetExceptionList@4 -.globl _RtlpSetExceptionList@4 + +PUBLIC _RtlpSetExceptionList@4 _RtlpSetExceptionList@4: /* Get the new list */ @@ -40,10 +45,9 @@ _RtlpSetExceptionList@4: /* Return */ ret 4 -.endfunc -.func RtlCaptureContext@4 -.globl _RtlCaptureContext@4 + +PUBLIC _RtlCaptureContext@4 _RtlCaptureContext@4: /* Preserve EBX and put the context in it */ @@ -61,10 +65,9 @@ _RtlCaptureContext@4: /* Capture the other regs */ jmp CaptureRest -.endfunc -.func RtlpCaptureContext@4 -.globl _RtlpCaptureContext@4 + +PUBLIC _RtlpCaptureContext@4 _RtlpCaptureContext@4: /* Preserve EBX and put the context in it */ @@ -107,10 +110,9 @@ CaptureRest: /* Return to the caller */ pop ebx ret 4 -.endfunc -.func RtlpExecuteHandlerForException@20 -.globl _RtlpExecuteHandlerForException@20 + +PUBLIC _RtlpExecuteHandlerForException@20 _RtlpExecuteHandlerForException@20: /* Copy the routine in EDX */ @@ -118,16 +120,14 @@ _RtlpExecuteHandlerForException@20: /* Jump to common routine */ jmp _RtlpExecuteHandler@20 -.endfunc -.func RtlpExecuteHandlerForUnwind@20 -.globl _RtlpExecuteHandlerForUnwind@20 + +PUBLIC _RtlpExecuteHandlerForUnwind@20 _RtlpExecuteHandlerForUnwind@20: /* Copy the routine in EDX */ mov edx, offset _RtlpUnwindProtector -.endfunc -.func RtlpExecuteHandler@20 + _RtlpExecuteHandler@20: /* Save non-volatile */ @@ -142,22 +142,21 @@ _RtlpExecuteHandler@20: xor edi, edi /* Call the 2nd-stage executer */ - push [esp+0x20] - push [esp+0x20] - push [esp+0x20] - push [esp+0x20] - push [esp+0x20] + push [esp+32] + push [esp+32] + push [esp+32] + push [esp+32] + push [esp+32] call _RtlpExecuteHandler2@20 /* Restore non-volatile */ pop edi pop esi pop ebx - ret 0x14 -.endfunc + ret 20 -.func RtlpExecuteHandler2@20 -.globl _RtlpExecuteHandler2@20 + +PUBLIC _RtlpExecuteHandler2@20 _RtlpExecuteHandler2@20: /* Set up stack frame */ @@ -165,7 +164,7 @@ _RtlpExecuteHandler2@20: mov ebp, esp /* Save the Frame */ - push [ebp+0xC] + push [ebp+12] /* Push handler address */ push edx @@ -177,11 +176,11 @@ _RtlpExecuteHandler2@20: mov [fs:TEB_EXCEPTION_LIST], esp /* Call the handler */ - push [ebp+0x14] - push [ebp+0x10] - push [ebp+0xC] + push [ebp+20] + push [ebp+16] + push [ebp+12] push [ebp+8] - mov ecx, [ebp+0x18] + mov ecx, [ebp+24] call ecx /* Unlink us */ @@ -193,10 +192,9 @@ _RtlpExecuteHandler2@20: /* Undo stack frame and return */ mov esp, ebp pop ebp - ret 0x14 -.endfunc + ret 20 + -.func RtlpExceptionProtector _RtlpExceptionProtector: /* Assume we'll continue */ @@ -222,9 +220,8 @@ _RtlpExceptionProtector: return: ret 16 -.endfunc -.func RtlpUnwindProtector + _RtlpUnwindProtector: /* Assume we'll continue */ @@ -250,10 +247,9 @@ _RtlpUnwindProtector: .return: ret 16 -.endfunc -.func RtlRaiseException@4 -.globl _RtlRaiseException@4 + +PUBLIC _RtlRaiseException@4 _RtlRaiseException@4: /* Set up stack frame */ @@ -325,10 +321,9 @@ RaiseStatus1: /* If we returned, raise a status */ push eax call _RtlRaiseStatus@4 -.endfunc -.func RtlRaiseStatus@4 -.globl _RtlRaiseStatus@4 + +PUBLIC _RtlRaiseStatus@4 _RtlRaiseStatus@4: /* Set up stack frame */ @@ -398,4 +393,5 @@ RaiseStatus2: /* If we returned, raise a status */ push eax call _RtlRaiseStatus@4 -.endfunc + +END diff --git a/reactos/lib/rtl/i386/interlck.S b/reactos/lib/rtl/i386/interlck.S index 5b95e4c5429..7ad7a085216 100644 --- a/reactos/lib/rtl/i386/interlck.S +++ b/reactos/lib/rtl/i386/interlck.S @@ -6,20 +6,20 @@ * PROGRAMMERS: Timo Kreuzer */ -.intel_syntax noprefix +#include /* FUNCTIONS ****************************************************************/ - +.code /* PSLIST_ENTRY * NTAPI * RtlInterlockedPopEntrySList( * IN PSLIST_HEADER ListHead); */ -.global _ExpInterlockedPopEntrySListResume@0 -.global _ExpInterlockedPopEntrySListEnd@0 -.global _ExpInterlockedPopEntrySListFault@0 -.global _RtlInterlockedPopEntrySList@4 +PUBLIC _ExpInterlockedPopEntrySListResume@0 +PUBLIC _ExpInterlockedPopEntrySListEnd@0 +PUBLIC _ExpInterlockedPopEntrySListFault@0 +PUBLIC _RtlInterlockedPopEntrySList@4 _RtlInterlockedPopEntrySList@4: /* Save registers */ @@ -35,10 +35,9 @@ _ExpInterlockedPopEntrySListResume@0: /* Load ListHead->Depth and ListHead->Sequence into edx */ mov edx, [ebp + 4] -1: /* Check if ListHead->Next is NULL */ or eax, eax - jz 2f + jz _ExpInterlockedPopEntrySList2 /* Copy Depth and Sequence number and adjust Depth */ lea ecx, [edx - 1] @@ -54,7 +53,7 @@ _ExpInterlockedPopEntrySListEnd@0: jnz _ExpInterlockedPopEntrySListResume@0 /* Restore registers and return */ -2: +_ExpInterlockedPopEntrySList2: pop ebp pop ebx ret 4 @@ -66,7 +65,7 @@ _ExpInterlockedPopEntrySListEnd@0: * IN PSLIST_HEADER ListHead, * IN PSLIST_ENTRY ListEntry); */ -.global _RtlInterlockedPushEntrySList@8 +PUBLIC _RtlInterlockedPushEntrySList@8 _RtlInterlockedPushEntrySList@8: /* Save registers */ @@ -85,18 +84,18 @@ _RtlInterlockedPushEntrySList@8: /* Load ListHead->Depth and ListHead->Sequence into edx */ mov edx, [ebp + 4] -1: +_RtlpInterlockedPushEntrySListResume: /* Set ListEntry->Next to ListHead->Next */ mov [ebx], eax /* Copy ListHead->Depth and ListHead->Sequence and adjust them */ - lea ecx, [edx + 0x10001] + lea ecx, [edx + HEX(10001)] /* If [ebp] equals edx:eax, exchange it with ecx:ebx */ LOCK cmpxchg8b qword ptr [ebp] /* If not equal, retry with edx:eax, being the content of [ebp] now */ - jnz 1b + jnz _RtlpInterlockedPushEntrySListResume /* Restore registers and return */ pop ebp @@ -109,7 +108,7 @@ _RtlInterlockedPushEntrySList@8: * RtlInterlockedFlushSList( * IN PSINGLE_LIST_ENTRY ListHead); */ -.global _RtlInterlockedFlushSList@4 +PUBLIC _RtlInterlockedFlushSList@4 _RtlInterlockedFlushSList@4: /* Save registers */ @@ -128,10 +127,10 @@ _RtlInterlockedFlushSList@4: /* Load ListHead->Depth and ListHead->Sequence into edx */ mov edx, [ebp + 4] -1: +_RtlpInterlockedFlushSListResume: /* Check if ListHead->Next is NULL */ or eax, eax - jz 2f + jz _RtlpInterlockedFlushSListEnd /* Copy Depth and Sequence number to ecx */ mov ecx, edx @@ -143,10 +142,12 @@ _RtlInterlockedFlushSList@4: LOCK cmpxchg8b qword ptr [ebp] /* If not equal, retry with edx:eax, being the content of [ebp] now */ - jnz 1b + jnz _RtlpInterlockedFlushSListResume /* Restore registers and return */ -2: +_RtlpInterlockedFlushSListEnd: pop ebp pop ebx ret 4 + +END diff --git a/reactos/lib/rtl/i386/res_asm.s b/reactos/lib/rtl/i386/res_asm.s index 46c61e08d42..5af744c2308 100644 --- a/reactos/lib/rtl/i386/res_asm.s +++ b/reactos/lib/rtl/i386/res_asm.s @@ -1,11 +1,22 @@ -#include -.intel_syntax noprefix +/* + * COPYRIGHT: GNU GPL - See COPYING in the top level directory + * PROJECT: ReactOS Run-Time Library + * PURPOSE: + * FILE: lib/rtl/i386/res_asm.S + * PROGRAMER: + */ + +#include +#include + +EXTERN _LdrpAccessResource@16:PROC /* * On x86, Shrinker, an executable compressor, depends on the * "call access_resource" instruction being there. */ -.globl _LdrAccessResource@16 +.code +PUBLIC _LdrAccessResource@16 _LdrAccessResource@16: push ebp mov ebp, esp @@ -18,3 +29,5 @@ _LdrAccessResource@16: call _LdrpAccessResource@16 leave ret 16 + +END diff --git a/reactos/lib/rtl/i386/rtlmem.s b/reactos/lib/rtl/i386/rtlmem.s index dea3b6d920d..d26f5b4ec52 100644 --- a/reactos/lib/rtl/i386/rtlmem.s +++ b/reactos/lib/rtl/i386/rtlmem.s @@ -1,26 +1,26 @@ /* - * COPYRIGHT: See COPYING in the top level directory + * COPYRIGHT: GNU GPL - See COPYING in the top level directory * PROJECT: ReactOS Run-Time Library * PURPOSE: Memory functions * FILE: lib/rtl/i386/rtlswap.S * PROGRAMER: Alex Ionescu (alex.ionescu@reactos.org) */ -.intel_syntax noprefix +#include /* GLOBALS *******************************************************************/ -.globl _RtlCompareMemory@12 -.globl _RtlCompareMemoryUlong@12 -.globl _RtlFillMemory@12 -.globl _RtlFillMemoryUlong@12 -.globl _RtlMoveMemory@12 -.globl _RtlZeroMemory@8 -.globl @RtlPrefetchMemoryNonTemporal@8 +PUBLIC _RtlCompareMemory@12 +PUBLIC _RtlCompareMemoryUlong@12 +PUBLIC _RtlFillMemory@12 +PUBLIC _RtlFillMemoryUlong@12 +PUBLIC _RtlMoveMemory@12 +PUBLIC _RtlZeroMemory@8 +PUBLIC @RtlPrefetchMemoryNonTemporal@8 /* FUNCTIONS *****************************************************************/ +.code -.func RtlCompareMemory@12 _RtlCompareMemory@12: /* Save volatiles */ @@ -74,9 +74,8 @@ NotEqual2: pop edi pop esi ret 12 -.endfunc -.func RtlCompareMemoryUlong@12 + _RtlCompareMemoryUlong@12: /* Get pointers and size in ULONGs */ @@ -97,9 +96,8 @@ Done: mov eax, edi pop edi ret 12 -.endfunc -.func RtlFillMemory@12 + _RtlFillMemory@12: /* Get pointers and size */ @@ -134,9 +132,8 @@ ByteFill: rep stosb pop edi ret 12 -.endfunc -.func RtlFillMemoryUlong@12 + _RtlFillMemoryUlong@12: /* Get pointer, size and pattern */ @@ -150,9 +147,8 @@ _RtlFillMemoryUlong@12: rep stosd pop edi ret 12 -.endfunc -.func RtlFillMemoryUlonglong@16 + _RtlFillMemoryUlonglong@16: /* Save volatiles */ @@ -179,9 +175,8 @@ _RtlFillMemoryUlonglong@16: pop esi pop edi ret 16 -.endfunc -.func RtlZeroMemory@8 + _RtlZeroMemory@8: /* Get pointers and size */ @@ -212,9 +207,8 @@ ByteZero: rep stosb pop edi ret 8 -.endfunc -.func RtlMoveMemory@12 + _RtlMoveMemory@12: /* Save volatiles */ @@ -280,9 +274,8 @@ Overlap: rep movsb cld jmp DoneMove -.endfunc -.func @RtlPrefetchMemoryNonTemporal@8, @RtlPrefetchMemoryNonTemporal@8 + @RtlPrefetchMemoryNonTemporal@8: /* @@ -306,8 +299,10 @@ FetchLine: /* Keep looping for the next line, or return if done */ ja FetchLine ret -.endfunc + /* FIXME: HACK */ _Ke386CacheAlignment: - .long 0x40 + .long 64 + +END diff --git a/reactos/lib/sdk/crt/except/amd64/chkstk_asm.s b/reactos/lib/sdk/crt/except/amd64/chkstk_asm.s index 4008d4f5eab..b1486dea898 100644 --- a/reactos/lib/sdk/crt/except/amd64/chkstk_asm.s +++ b/reactos/lib/sdk/crt/except/amd64/chkstk_asm.s @@ -8,11 +8,10 @@ /* INCLUDES ******************************************************************/ -#include +#include -.intel_syntax noprefix -.global MsgUnimplemented +PUBLIC MsgUnimplemented MsgUnimplemented: .asciz "WARNING: %s at %s:%d is UNIMPLEMENTED!\n" @@ -27,4 +26,5 @@ MsgUnimplemented: ret .endp +END /* EOF */ diff --git a/reactos/lib/sdk/crt/except/amd64/seh.s b/reactos/lib/sdk/crt/except/amd64/seh.s index e784457e9f8..9d44d3ffd4d 100644 --- a/reactos/lib/sdk/crt/except/amd64/seh.s +++ b/reactos/lib/sdk/crt/except/amd64/seh.s @@ -8,8 +8,8 @@ /* INCLUDES ******************************************************************/ -#include -.intel_syntax noprefix +#include +#include #define DISPOSITION_DISMISS 0 #define DISPOSITION_CONTINUE_SEARCH 1 @@ -54,3 +54,5 @@ _except_handler2: _except_handler3: ret .endfunc + +END diff --git a/reactos/lib/sdk/crt/except/i386/chkstk_asm.s b/reactos/lib/sdk/crt/except/i386/chkstk_asm.s index 5104a35b1c4..58879f18d0f 100644 --- a/reactos/lib/sdk/crt/except/i386/chkstk_asm.s +++ b/reactos/lib/sdk/crt/except/i386/chkstk_asm.s @@ -7,8 +7,43 @@ * PROGRAMER: KJK::Hyperion */ -.globl __chkstk -.globl __alloca_probe +#include +#include + +#define PAGE_SIZE 4096 + +PUBLIC __chkstk +PUBLIC __alloca_probe +PUBLIC __alloca_probe_16 +.code + + /* 16 byte aligned alloca probe + * EAX = size to be allocated */ +__alloca_probe_16: + /* save the ECX register */ + push ecx + + /* ecx = top of the previous stack frame */ + lea ecx, [esp + 8] + + /* Calculate end of allocation */ + sub ecx, eax + + /* Get the misalignment */ + and ecx, 15 + + /* Add the misalignment to the original alloc size */ + add eax, ecx + + /* Check for overflow */ + jnc l1 + + /* Set maximum value */ + mov eax, HEX(0ffffffff) +l1: + /* Restore ecx */ + pop ecx + /* Fall through to __chkstk */ /* _chkstk() is called by all stack allocations of more than 4 KB. It grows the @@ -18,49 +53,49 @@ __chkstk: __alloca_probe: -/* EAX = size to be allocated */ -/* save the ECX register */ - pushl %ecx + /* EAX = size to be allocated */ + /* save the ECX register */ + push ecx -/* ECX = top of the previous stack frame */ - leal 8(%esp), %ecx + /* ECX = top of the previous stack frame */ + lea ecx, [esp + 8] -/* probe the desired memory, page by page */ - cmpl $0x1000, %eax - jge .l_MoreThanAPage - jmp .l_LessThanAPage + /* probe the desired memory, page by page */ + cmp eax, PAGE_SIZE + jl .l_LessThanAPage .l_MoreThanAPage: -/* raise the top of the stack by a page and probe */ - subl $0x1000, %ecx - testl %eax, 0(%ecx) + /* raise the top of the stack by a page and probe */ + sub ecx, PAGE_SIZE + test [ecx], eax -/* loop if still more than a page must be probed */ - subl $0x1000, %eax - cmpl $0x1000, %eax - jge .l_MoreThanAPage + /* loop if still more than a page must be probed */ + sub eax, PAGE_SIZE + cmp eax, PAGE_SIZE + jge .l_MoreThanAPage .l_LessThanAPage: -/* raise the top of the stack by EAX bytes (size % 4096) and probe */ - subl %eax, %ecx - testl %eax, 0(%ecx) + /* raise the top of the stack by EAX bytes (size % 4096) and probe */ + sub ecx, eax + test [ecx], eax -/* EAX = top of the stack */ - movl %esp, %eax + /* EAX = top of the stack */ + mov eax, esp -/* allocate the memory */ - movl %ecx, %esp + /* allocate the memory */ + mov esp, ecx -/* restore ECX */ - movl 0(%eax), %ecx + /* restore ECX */ + mov ecx, [eax] -/* restore the return address */ - movl 4(%eax), %eax - pushl %eax + /* restore the return address */ + mov eax, [eax + 4] + push eax -/* return */ - ret + /* return */ + ret /* EOF */ +END diff --git a/reactos/lib/sdk/crt/except/i386/prolog.s b/reactos/lib/sdk/crt/except/i386/prolog.s index 5ff588d6746..ebbf4ee412d 100644 --- a/reactos/lib/sdk/crt/except/i386/prolog.s +++ b/reactos/lib/sdk/crt/except/i386/prolog.s @@ -8,20 +8,23 @@ /* INCLUDES ******************************************************************/ -#include +#include +#include -/* GLOBALS *******************************************************************/ - -.globl __EH_prolog +/* FUNCTIONS *****************************************************************/ +.code +PUBLIC __EH_prolog // Copied from Wine. __EH_prolog: - pushl $-1 - pushl %eax - pushl %fs:0 - movl %esp, %fs:0 - movl 12(%esp), %eax - movl %ebp, 12(%esp) - leal 12(%esp), %ebp - pushl %eax + push -1 + push eax + push fs:0 + mov fs:0, esp + mov eax, [esp + 12] + mov [esp + 12], ebp + lea ebp, [esp + 12] + push eax ret + +END diff --git a/reactos/lib/sdk/crt/except/i386/seh.s b/reactos/lib/sdk/crt/except/i386/seh.s index 15a8cc5777a..6fde1e181f7 100644 --- a/reactos/lib/sdk/crt/except/i386/seh.s +++ b/reactos/lib/sdk/crt/except/i386/seh.s @@ -8,24 +8,29 @@ /* INCLUDES ******************************************************************/ -#include -.intel_syntax noprefix +#include #define DISPOSITION_DISMISS 0 #define DISPOSITION_CONTINUE_SEARCH 1 #define DISPOSITION_COLLIDED_UNWIND 3 +#define EXCEPTION_EXIT_UNWIND 4 +#define EXCEPTION_UNWINDING 2 + + +EXTERN _RtlUnwind@16:PROC + /* GLOBALS *******************************************************************/ -.globl __global_unwind2 -.globl __local_unwind2 -.globl __abnormal_termination -.globl __except_handler2 -.globl __except_handler3 +PUBLIC __global_unwind2 +PUBLIC __local_unwind2 +PUBLIC __abnormal_termination +PUBLIC __except_handler2 +PUBLIC __except_handler3 /* FUNCTIONS *****************************************************************/ -.func unwind_handler +.code _unwind_handler: /* Check if we were unwinding and continue search if not */ @@ -56,9 +61,8 @@ _unwind_handler: unwind_handler_return: ret -.endfunc -.func _global_unwind2 + __global_unwind2: /* Create stack and save all registers */ @@ -85,9 +89,8 @@ glu_return: mov esp, ebp pop ebp ret -.endfunc -.func _abnormal_termination + __abnormal_termination: /* Assume false */ @@ -112,9 +115,8 @@ __abnormal_termination: /* Return */ ab_return: ret -.endfunc -.func _local_unwind2 + __local_unwind2: /* Save volatiles */ @@ -175,9 +177,8 @@ unwind_return: pop esi pop ebx ret -.endfunc -.func _except_handler2 + __except_handler2: /* Setup stack and save volatiles */ @@ -256,7 +257,7 @@ except_loop2: mov [ebx+12], eax /* Call except handler */ - call [edi+ecx*4+8] + call dword ptr [edi+ecx*4+8] except_continue2: /* Reload try level and except again */ @@ -297,9 +298,8 @@ except_return2: mov esp, ebp pop ebp ret -.endfunc -.func _except_handler3 + __except_handler3: /* Setup stack and save volatiles */ @@ -437,4 +437,5 @@ except_return3: mov esp, ebp pop ebp ret -.endfunc + +END diff --git a/reactos/lib/sdk/crt/float/i386/logb.c b/reactos/lib/sdk/crt/float/i386/logb.c index 0c02c0e0f11..e4b61949fc4 100644 --- a/reactos/lib/sdk/crt/float/i386/logb.c +++ b/reactos/lib/sdk/crt/float/i386/logb.c @@ -30,7 +30,7 @@ double _logb (double __x) ("fxtract\n\t" : "=t" (__junk), "=u" (__val) : "0" (__x)); #else -#error REVIEW ME +#pragma message ("REVIEW ME") __asm fld [__x]; __asm fxtract; __asm fstp st(0); diff --git a/reactos/lib/sdk/crt/math/amd64/alldiv.S b/reactos/lib/sdk/crt/math/amd64/alldiv.S index 831ef50981b..b4018cc4739 100644 --- a/reactos/lib/sdk/crt/math/amd64/alldiv.S +++ b/reactos/lib/sdk/crt/math/amd64/alldiv.S @@ -8,8 +8,7 @@ /* INCLUDES ******************************************************************/ -#include -#include +#include /* DATA *********************************************************************/ diff --git a/reactos/lib/sdk/crt/math/amd64/atan.S b/reactos/lib/sdk/crt/math/amd64/atan.S index 3ba194931f4..889f10e2825 100644 --- a/reactos/lib/sdk/crt/math/amd64/atan.S +++ b/reactos/lib/sdk/crt/math/amd64/atan.S @@ -8,8 +8,8 @@ /* INCLUDES ******************************************************************/ -#include -#include +#include +#include /* FUNCTIONS ****************************************************************/ diff --git a/reactos/lib/sdk/crt/math/amd64/atan2.S b/reactos/lib/sdk/crt/math/amd64/atan2.S index 7cd29b93269..fd611101f0a 100644 --- a/reactos/lib/sdk/crt/math/amd64/atan2.S +++ b/reactos/lib/sdk/crt/math/amd64/atan2.S @@ -8,8 +8,8 @@ /* INCLUDES ******************************************************************/ -#include -#include +#include +#include /* FUNCTIONS ****************************************************************/ diff --git a/reactos/lib/sdk/crt/math/amd64/ceil.S b/reactos/lib/sdk/crt/math/amd64/ceil.S index dbee413f491..17ae0150717 100644 --- a/reactos/lib/sdk/crt/math/amd64/ceil.S +++ b/reactos/lib/sdk/crt/math/amd64/ceil.S @@ -8,8 +8,8 @@ /* INCLUDES ******************************************************************/ -#include -#include +#include +#include /* FUNCTIONS ****************************************************************/ diff --git a/reactos/lib/sdk/crt/math/amd64/ceilf.S b/reactos/lib/sdk/crt/math/amd64/ceilf.S index e3a948fff8a..2b2d14b03f0 100644 --- a/reactos/lib/sdk/crt/math/amd64/ceilf.S +++ b/reactos/lib/sdk/crt/math/amd64/ceilf.S @@ -8,8 +8,8 @@ /* INCLUDES ******************************************************************/ -#include -#include +#include +#include /* FUNCTIONS ****************************************************************/ @@ -17,24 +17,30 @@ PUBLIC ceilf ceilf: + sub rsp, 16 + /* Put parameter on the stack */ - movss [rsp - 0x10], xmm0 - fld dword ptr [rsp] + movss [rsp], xmm0 + fld dword ptr [rsp] /* Change fpu control word to round up */ - fstcw [rsp - 0x10] - mov eax, [rsp - 0x10] - or eax, 0x00800 - and eax, 0x0fbff - mov [rsp - 0x08], eax - fldcw [rsp - 0x08] + fstcw [rsp + 8] + mov eax, [rsp + 8] + or eax, HEX(00800) + and eax, HEX(0fbff) + mov [rsp + 12], eax + fldcw [rsp + 12] /* Round to integer */ frndint /* Restore fpu control word */ - fldcw [rsp - 0x10] + fldcw [rsp + 8] - fstp dword ptr [rsp - 0x10] - movss xmm0, [rsp - 0x10] + fstp dword ptr [rsp] + movss xmm0, [rsp] + + add rsp, 16 ret + +END diff --git a/reactos/lib/sdk/crt/math/amd64/exp.S b/reactos/lib/sdk/crt/math/amd64/exp.S index ca3dc993182..44b324e4267 100644 --- a/reactos/lib/sdk/crt/math/amd64/exp.S +++ b/reactos/lib/sdk/crt/math/amd64/exp.S @@ -8,8 +8,8 @@ /* INCLUDES ******************************************************************/ -#include -#include +#include +#include /* FUNCTIONS ****************************************************************/ @@ -20,3 +20,4 @@ exp: UNIMPLEMENTED exp ret +END diff --git a/reactos/lib/sdk/crt/math/amd64/fabs.S b/reactos/lib/sdk/crt/math/amd64/fabs.S index e58b960ecab..3c1e8f2dcf1 100644 --- a/reactos/lib/sdk/crt/math/amd64/fabs.S +++ b/reactos/lib/sdk/crt/math/amd64/fabs.S @@ -8,8 +8,7 @@ /* INCLUDES ******************************************************************/ -#include -#include +#include /* FUNCTIONS ****************************************************************/ diff --git a/reactos/lib/sdk/crt/math/amd64/floor.S b/reactos/lib/sdk/crt/math/amd64/floor.S index f1c3b9305af..c0fba3dd066 100644 --- a/reactos/lib/sdk/crt/math/amd64/floor.S +++ b/reactos/lib/sdk/crt/math/amd64/floor.S @@ -8,8 +8,8 @@ /* INCLUDES ******************************************************************/ -#include -#include +#include +#include /* FUNCTIONS ****************************************************************/ @@ -19,3 +19,5 @@ PUBLIC floor floor: UNIMPLEMENTED floor ret + +END diff --git a/reactos/lib/sdk/crt/math/amd64/floorf.S b/reactos/lib/sdk/crt/math/amd64/floorf.S index e2d02202df7..0ac9098b9a3 100644 --- a/reactos/lib/sdk/crt/math/amd64/floorf.S +++ b/reactos/lib/sdk/crt/math/amd64/floorf.S @@ -8,8 +8,8 @@ /* INCLUDES ******************************************************************/ -#include -#include +#include +#include /* FUNCTIONS ****************************************************************/ @@ -17,24 +17,29 @@ PUBLIC floorf floorf: + sub rsp, 16 + /* Put parameter on the stack */ - movss [rsp - 0x10], xmm0 + movss [rsp], xmm0 fld dword ptr [rsp] /* Change fpu control word to round down */ - fstcw [rsp - 0x10] - mov eax, [rsp - 0x10] + fstcw [rsp] + mov eax, [rsp] or eax, 0x00400 and eax, 0x0f7ff - mov [rsp - 0x08], eax - fldcw [rsp - 0x08] + mov [rsp + 8], eax + fldcw [rsp + 8] /* Round to integer */ frndint /* Restore fpu control word */ - fldcw [rsp - 0x10] + fldcw [rsp] - fstp dword ptr [rsp - 0x10] - movss xmm0, [rsp - 0x10] + fstp dword ptr [rsp] + movss xmm0, [rsp] + add rsp, 16 ret + +END diff --git a/reactos/lib/sdk/crt/math/amd64/fmod.S b/reactos/lib/sdk/crt/math/amd64/fmod.S index 4ca67f55bfb..697257ab368 100644 --- a/reactos/lib/sdk/crt/math/amd64/fmod.S +++ b/reactos/lib/sdk/crt/math/amd64/fmod.S @@ -8,8 +8,7 @@ /* INCLUDES ******************************************************************/ -#include -#include +#include /* DATA *********************************************************************/ @@ -17,3 +16,5 @@ PUBLIC fmod fmod: UNIMPLEMENTED fmod ret + +END diff --git a/reactos/lib/sdk/crt/math/amd64/fmodf.S b/reactos/lib/sdk/crt/math/amd64/fmodf.S index e109c387cc8..d0e24ef9529 100644 --- a/reactos/lib/sdk/crt/math/amd64/fmodf.S +++ b/reactos/lib/sdk/crt/math/amd64/fmodf.S @@ -8,8 +8,7 @@ /* INCLUDES ******************************************************************/ -#include -#include +#include /* DATA *********************************************************************/ @@ -17,3 +16,5 @@ PUBLIC fmodf fmodf: UNIMPLEMENTED fmodf ret + +END diff --git a/reactos/lib/sdk/crt/math/amd64/ldexp.S b/reactos/lib/sdk/crt/math/amd64/ldexp.S index d0265629bf6..a83660ae7a3 100644 --- a/reactos/lib/sdk/crt/math/amd64/ldexp.S +++ b/reactos/lib/sdk/crt/math/amd64/ldexp.S @@ -8,8 +8,7 @@ /* INCLUDES ******************************************************************/ -#include -#include +#include /* DATA *********************************************************************/ @@ -17,3 +16,5 @@ PUBLIC ldexp ldexp: UNIMPLEMENTED ldexp ret + +END diff --git a/reactos/lib/sdk/crt/math/amd64/log.S b/reactos/lib/sdk/crt/math/amd64/log.S index 9fa02763b9e..1289a745cba 100644 --- a/reactos/lib/sdk/crt/math/amd64/log.S +++ b/reactos/lib/sdk/crt/math/amd64/log.S @@ -8,8 +8,7 @@ /* INCLUDES ******************************************************************/ -#include -#include +#include /* DATA *********************************************************************/ diff --git a/reactos/lib/sdk/crt/math/amd64/log10.S b/reactos/lib/sdk/crt/math/amd64/log10.S index 007f0d80e98..f8014aa5bc6 100644 --- a/reactos/lib/sdk/crt/math/amd64/log10.S +++ b/reactos/lib/sdk/crt/math/amd64/log10.S @@ -8,8 +8,7 @@ /* INCLUDES ******************************************************************/ -#include -#include +#include /* DATA *********************************************************************/ diff --git a/reactos/lib/sdk/crt/math/amd64/pow.S b/reactos/lib/sdk/crt/math/amd64/pow.S index 37988801b11..48adf3961f3 100644 --- a/reactos/lib/sdk/crt/math/amd64/pow.S +++ b/reactos/lib/sdk/crt/math/amd64/pow.S @@ -8,8 +8,8 @@ /* INCLUDES ******************************************************************/ -#include -#include +#include +#include /* DATA *********************************************************************/ diff --git a/reactos/lib/sdk/crt/math/amd64/sqrt.S b/reactos/lib/sdk/crt/math/amd64/sqrt.S index 758d8768d4f..282419e78a5 100644 --- a/reactos/lib/sdk/crt/math/amd64/sqrt.S +++ b/reactos/lib/sdk/crt/math/amd64/sqrt.S @@ -8,8 +8,8 @@ /* INCLUDES ******************************************************************/ -#include -#include +#include +#include /* DATA *********************************************************************/ @@ -17,3 +17,5 @@ PUBLIC sqrt sqrt: UNIMPLEMENTED sqrt ret + +END diff --git a/reactos/lib/sdk/crt/math/amd64/sqrtf.S b/reactos/lib/sdk/crt/math/amd64/sqrtf.S index a4ee3fa6cc5..da75fcf42f5 100644 --- a/reactos/lib/sdk/crt/math/amd64/sqrtf.S +++ b/reactos/lib/sdk/crt/math/amd64/sqrtf.S @@ -8,8 +8,8 @@ /* INCLUDES ******************************************************************/ -#include -#include +#include +#include /* DATA *********************************************************************/ @@ -17,3 +17,5 @@ PUBLIC sqrtf sqrtf: sqrtss xmm0, xmm0 ret + +END diff --git a/reactos/lib/sdk/crt/math/amd64/tan.S b/reactos/lib/sdk/crt/math/amd64/tan.S index a7c66d0ccd7..93e5d01d762 100644 --- a/reactos/lib/sdk/crt/math/amd64/tan.S +++ b/reactos/lib/sdk/crt/math/amd64/tan.S @@ -8,8 +8,8 @@ /* INCLUDES ******************************************************************/ -#include -#include +#include +#include /* DATA *********************************************************************/ @@ -17,3 +17,5 @@ PUBLIC tan tan: UNIMPLEMENTED tan ret + +END diff --git a/reactos/lib/sdk/crt/math/i386/alldiv_asm.s b/reactos/lib/sdk/crt/math/i386/alldiv_asm.s index 043a8af95c3..5061fb7c21f 100644 --- a/reactos/lib/sdk/crt/math/i386/alldiv_asm.s +++ b/reactos/lib/sdk/crt/math/i386/alldiv_asm.s @@ -33,18 +33,22 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ - - .globl __alldiv - .globl __fltused - + +#include + +PUBLIC __alldiv +PUBLIC __fltused + /* DATA ********************************************************************/ +.data +ASSUME CS:NOTHING, DS:NOTHING, ES:NOTHING, FS:NOTHING, GS:NOTHING __fltused: - .long 0x9875 + .long HEX(9875) -.intel_syntax noprefix /* FUNCTIONS ***************************************************************/ +.code // // lldiv - signed long divide @@ -222,3 +226,5 @@ L8: pop edi ret 16 + +END diff --git a/reactos/lib/sdk/crt/math/i386/alldvrm_asm.s b/reactos/lib/sdk/crt/math/i386/alldvrm_asm.s index 8f775d6dac3..a055d55d62e 100644 --- a/reactos/lib/sdk/crt/math/i386/alldvrm_asm.s +++ b/reactos/lib/sdk/crt/math/i386/alldvrm_asm.s @@ -33,12 +33,13 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ - -.globl __alldvrm - -.intel_syntax noprefix +#include + +PUBLIC __alldvrm + /* FUNCTIONS ***************************************************************/ +.code __alldvrm: push edi @@ -88,7 +89,7 @@ __alldvrm: mov eax,DVNDHI // hi word of a or eax,eax // test to see if signed - jge short ....L1 // skip rest if a is already positive + jge short .L1 // skip rest if a is already positive inc edi // complement result sign flag inc ebp // complement result sign flag mov edx,DVNDLO // lo word of a @@ -97,10 +98,10 @@ __alldvrm: sbb eax,0 mov DVNDHI,eax // save positive value mov DVNDLO,edx -....L1: +.L1: mov eax,DVSRHI // hi word of b or eax,eax // test to see if signed - jge short ....L2 // skip rest if b is already positive + jge short .L2 // skip rest if b is already positive inc edi // complement the result sign flag mov edx,DVSRLO // lo word of a neg eax // make b positive @@ -108,7 +109,7 @@ __alldvrm: sbb eax,0 mov DVSRHI,eax // save positive value mov DVSRLO,edx -....L2: +.L2: // // Now do the divide. First look to see if the divisor is less than 4194304K. @@ -119,7 +120,7 @@ __alldvrm: // or eax,eax // check to see if divisor < 4194304K - jnz short ....L3 // nope, gotta do this the hard way + jnz short .L3 // nope, gotta do this the hard way mov ecx,DVSRLO // load divisor mov eax,DVNDHI // load high word of dividend xor edx,edx @@ -137,24 +138,24 @@ __alldvrm: mov eax,esi // set up low word of quotient mul dword ptr DVSRLO // LOWORD(QUOT) * DVSR add edx,ecx // EDX:EAX = QUOT * DVSR - jmp short ....L4 // complete remainder calculation + jmp short .L4 // complete remainder calculation // // Here we do it the hard way. Remember, eax contains the high word of DVSR // -....L3: +.L3: mov ebx,eax // ebx:ecx <- divisor mov ecx,DVSRLO mov edx,DVNDHI // edx:eax <- dividend mov eax,DVNDLO -....L5: +.L5: shr ebx,1 // shift divisor right one bit rcr ecx,1 shr edx,1 // shift dividend right one bit rcr eax,1 or ebx,ebx - jnz short ....L5 // loop until divisor < 4194304K + jnz short .L5 // loop until divisor < 4194304K div ecx // now divide, ignore remainder mov esi,eax // save quotient @@ -170,7 +171,7 @@ __alldvrm: mov eax,DVSRLO mul esi // QUOT * DVSRLO add edx,ecx // EDX:EAX = QUOT * DVSR - jc short ....L6 // carry means Quotient is off by 1 + jc short .L6 // carry means Quotient is off by 1 // // do long compare here between original dividend and the result of the @@ -179,18 +180,18 @@ __alldvrm: // cmp edx,DVNDHI // compare hi words of result and original - ja short ....L6 // if result > original, do subtract - jb short ....L7 // if result < original, we are ok + ja short .L6 // if result > original, do subtract + jb short .L7 // if result < original, we are ok cmp eax,DVNDLO // hi words are equal, compare lo words - jbe short ....L7 // if less or equal we are ok, else subtract -....L6: + jbe short .L7 // if less or equal we are ok, else subtract +.L6: dec esi // subtract 1 from quotient sub eax,DVSRLO // subtract divisor from result sbb edx,DVSRHI -....L7: +.L7: xor ebx,ebx // ebx:esi <- quotient -....L4: +.L4: // // Calculate remainder by subtracting the result from the original dividend. // Since the result is already in a register, we will do the subtract in the @@ -208,7 +209,7 @@ __alldvrm: // dec ebp // check result sign flag - jns short ....L9 // result is ok, set up the quotient + jns short .L9 // result is ok, set up the quotient neg edx // otherwise, negate the result neg eax sbb edx,0 @@ -216,7 +217,7 @@ __alldvrm: // // Now we need to get the quotient into edx:eax and the remainder into ebx:ecx. // -....L9: +.L9: mov ecx,edx mov edx,ebx mov ebx,ecx @@ -229,7 +230,7 @@ __alldvrm: // dec edi // check to see if result is negative - jnz short ....L8 // if EDI == 0, result should be negative + jnz short .L8 // if EDI == 0, result should be negative neg edx // otherwise, negate the result neg eax sbb edx,0 @@ -238,9 +239,11 @@ __alldvrm: // Restore the saved registers and return. // -....L8: +.L8: pop ebp pop esi pop edi ret 16 + +END diff --git a/reactos/lib/sdk/crt/math/i386/allmul_asm.s b/reactos/lib/sdk/crt/math/i386/allmul_asm.s index ddfa7cf7b46..b9a47baafcc 100644 --- a/reactos/lib/sdk/crt/math/i386/allmul_asm.s +++ b/reactos/lib/sdk/crt/math/i386/allmul_asm.s @@ -33,12 +33,13 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ - -.globl __allmul -.intel_syntax noprefix +#include + +PUBLIC __allmul /* FUNCTIONS ***************************************************************/ +.code // // llmul - long multiply routine @@ -113,3 +114,4 @@ hard: ret 16 // callee restores the stack +END diff --git a/reactos/lib/sdk/crt/math/i386/allrem_asm.s b/reactos/lib/sdk/crt/math/i386/allrem_asm.s index a8e222e25bf..2c3e68c5578 100644 --- a/reactos/lib/sdk/crt/math/i386/allrem_asm.s +++ b/reactos/lib/sdk/crt/math/i386/allrem_asm.s @@ -33,12 +33,13 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ - -.globl __allrem - -.intel_syntax noprefix +#include + +PUBLIC __allrem + /* FUNCTIONS ***************************************************************/ +.code // // llrem - signed long remainder @@ -227,3 +228,5 @@ __allrem : pop ebx ret 16 + +END diff --git a/reactos/lib/sdk/crt/math/i386/allshl_asm.s b/reactos/lib/sdk/crt/math/i386/allshl_asm.s index b5d574aff01..48d06b7dd5a 100644 --- a/reactos/lib/sdk/crt/math/i386/allshl_asm.s +++ b/reactos/lib/sdk/crt/math/i386/allshl_asm.s @@ -33,12 +33,13 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ - -.globl __allshl -.intel_syntax noprefix +#include + +PUBLIC __allshl /* FUNCTIONS ***************************************************************/ +.code // // llshl - long shift left @@ -92,3 +93,5 @@ RETZERO: xor eax,eax xor edx,edx ret + +END diff --git a/reactos/lib/sdk/crt/math/i386/allshr_asm.s b/reactos/lib/sdk/crt/math/i386/allshr_asm.s index 575fc92db9a..e2b60bd97aa 100644 --- a/reactos/lib/sdk/crt/math/i386/allshr_asm.s +++ b/reactos/lib/sdk/crt/math/i386/allshr_asm.s @@ -33,12 +33,13 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ - -.globl __allshr - -.intel_syntax noprefix +#include + +PUBLIC __allshr + /* FUNCTIONS ***************************************************************/ +.code // // llshr - long shift right @@ -93,3 +94,5 @@ __allshr: sar edx,31 mov eax,edx ret + +END diff --git a/reactos/lib/sdk/crt/math/i386/atan2_asm.s b/reactos/lib/sdk/crt/math/i386/atan2_asm.s new file mode 100644 index 00000000000..699b02d3530 --- /dev/null +++ b/reactos/lib/sdk/crt/math/i386/atan2_asm.s @@ -0,0 +1,18 @@ + +#include + +PUBLIC _atan2 + +.code +_atan2: + push ebp + mov ebp, esp + + fld qword ptr [ebp + 8] + fld qword ptr [ebp + 16] + fpatan + + pop ebp + ret + +END diff --git a/reactos/lib/sdk/crt/math/i386/atan_asm.s b/reactos/lib/sdk/crt/math/i386/atan_asm.s index 37554c940ae..9cd08752369 100644 --- a/reactos/lib/sdk/crt/math/i386/atan_asm.s +++ b/reactos/lib/sdk/crt/math/i386/atan_asm.s @@ -33,12 +33,13 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ - -.globl _atan - -.intel_syntax noprefix +#include + +PUBLIC _atan + /* FUNCTIONS ***************************************************************/ +.code _atan: push ebp @@ -48,3 +49,5 @@ _atan: fpatan // Take the arctangent pop ebp ret + +END diff --git a/reactos/lib/sdk/crt/math/i386/aulldiv_asm.s b/reactos/lib/sdk/crt/math/i386/aulldiv_asm.s index 565914eb87b..b3a08787c1c 100644 --- a/reactos/lib/sdk/crt/math/i386/aulldiv_asm.s +++ b/reactos/lib/sdk/crt/math/i386/aulldiv_asm.s @@ -33,12 +33,13 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ - - .globl __aulldiv -.intel_syntax noprefix +#include + +PUBLIC __aulldiv /* FUNCTIONS ***************************************************************/ +.code // // ulldiv - unsigned long divide @@ -105,7 +106,7 @@ __aulldiv: mov eax,DVSRHI // check to see if divisor < 4194304K or eax,eax - jnz short ..L1 // nope, gotta do this the hard way + jnz short .L1 // nope, gotta do this the hard way mov ecx,DVSRLO // load divisor mov eax,DVNDHI // load high word of dividend xor edx,edx @@ -114,24 +115,24 @@ __aulldiv: mov eax,DVNDLO // edx:eax <- remainder:lo word of dividend div ecx // get low order bits of quotient mov edx,ebx // edx:eax <- quotient hi:quotient lo - jmp short ..L2 // restore stack and return + jmp short .L2 // restore stack and return // // Here we do it the hard way. Remember, eax contains DVSRHI // -..L1: +.L1: mov ecx,eax // ecx:ebx <- divisor mov ebx,DVSRLO mov edx,DVNDHI // edx:eax <- dividend mov eax,DVNDLO -..L3: +.L3: shr ecx,1 // shift divisor right one bit// hi bit <- 0 rcr ebx,1 shr edx,1 // shift dividend right one bit// hi bit <- 0 rcr eax,1 or ecx,ecx - jnz short ..L3 // loop until divisor < 4194304K + jnz short .L3 // loop until divisor < 4194304K div ebx // now divide, ignore remainder mov esi,eax // save quotient @@ -147,7 +148,7 @@ __aulldiv: mov eax,DVSRLO mul esi // QUOT * DVSRLO add edx,ecx // EDX:EAX = QUOT * DVSR - jc short ..L4 // carry means Quotient is off by 1 + jc short .L4 // carry means Quotient is off by 1 // // do long compare here between original dividend and the result of the @@ -156,13 +157,13 @@ __aulldiv: // cmp edx,DVNDHI // compare hi words of result and original - ja short ..L4 // if result > original, do subtract - jb short ..L5 // if result < original, we are ok + ja short .L4 // if result > original, do subtract + jb short .L5 // if result < original, we are ok cmp eax,DVNDLO // hi words are equal, compare lo words - jbe short ..L5 // if less or equal we are ok, else subtract -..L4: + jbe short .L5 // if less or equal we are ok, else subtract +.L4: dec esi // subtract 1 from quotient -..L5: +.L5: xor edx,edx // edx:eax <- quotient mov eax,esi @@ -171,9 +172,11 @@ __aulldiv: // Restore the saved registers and return. // -..L2: +.L2: pop esi pop ebx ret 16 + +END diff --git a/reactos/lib/sdk/crt/math/i386/aulldvrm_asm.s b/reactos/lib/sdk/crt/math/i386/aulldvrm_asm.s index 6f7de08f2b2..ed1d4a10832 100644 --- a/reactos/lib/sdk/crt/math/i386/aulldvrm_asm.s +++ b/reactos/lib/sdk/crt/math/i386/aulldvrm_asm.s @@ -33,12 +33,13 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ - -.globl __aulldvrm - -.intel_syntax noprefix +#include + +PUBLIC __aulldvrm + /* FUNCTIONS ***************************************************************/ +.code __aulldvrm: @@ -101,7 +102,7 @@ __aulldvrm: mov eax,DVSRHI // check to see if divisor < 4194304K or eax,eax - jnz short .....L1 // nope, gotta do this the hard way + jnz short .L1 // nope, gotta do this the hard way mov ecx,DVSRLO // load divisor mov eax,DVNDHI // load high word of dividend xor edx,edx @@ -120,24 +121,24 @@ __aulldvrm: mov eax,esi // set up low word of quotient mul dword ptr DVSRLO // LOWORD(QUOT) * DVSR add edx,ecx // EDX:EAX = QUOT * DVSR - jmp short .....L2 // complete remainder calculation + jmp short .L2 // complete remainder calculation // // Here we do it the hard way. Remember, eax contains DVSRHI // -.....L1: +.L1: mov ecx,eax // ecx:ebx <- divisor mov ebx,DVSRLO mov edx,DVNDHI // edx:eax <- dividend mov eax,DVNDLO -.....L3: +.L3: shr ecx,1 // shift divisor right one bit// hi bit <- 0 rcr ebx,1 shr edx,1 // shift dividend right one bit// hi bit <- 0 rcr eax,1 or ecx,ecx - jnz short .....L3 // loop until divisor < 4194304K + jnz short .L3 // loop until divisor < 4194304K div ebx // now divide, ignore remainder mov esi,eax // save quotient @@ -153,7 +154,7 @@ __aulldvrm: mov eax,DVSRLO mul esi // QUOT * DVSRLO add edx,ecx // EDX:EAX = QUOT * DVSR - jc short .....L4 // carry means Quotient is off by 1 + jc short .L4 // carry means Quotient is off by 1 // // do long compare here between original dividend and the result of the @@ -162,18 +163,18 @@ __aulldvrm: // cmp edx,DVNDHI // compare hi words of result and original - ja short .....L4 // if result > original, do subtract - jb short .....L5 // if result < original, we are ok + ja short .L4 // if result > original, do subtract + jb short .L5 // if result < original, we are ok cmp eax,DVNDLO // hi words are equal, compare lo words - jbe short .....L5 // if less or equal we are ok, else subtract -.....L4: + jbe short .L5 // if less or equal we are ok, else subtract +.L4: dec esi // subtract 1 from quotient sub eax,DVSRLO // subtract divisor from result sbb edx,DVSRHI -.....L5: +.L5: xor ebx,ebx // ebx:esi <- quotient -.....L2: +.L2: // // Calculate remainder by subtracting the result from the original dividend. // Since the result is already in a register, we will do the subtract in the @@ -202,3 +203,5 @@ __aulldvrm: pop esi ret 16 + +END diff --git a/reactos/lib/sdk/crt/math/i386/aullrem_asm.s b/reactos/lib/sdk/crt/math/i386/aullrem_asm.s index bfcb0efb2a0..4fde84a01ba 100644 --- a/reactos/lib/sdk/crt/math/i386/aullrem_asm.s +++ b/reactos/lib/sdk/crt/math/i386/aullrem_asm.s @@ -33,12 +33,13 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ - -.globl __aullrem - -.intel_syntax noprefix +#include + +PUBLIC __aullrem + /* FUNCTIONS ***************************************************************/ +.code // // ullrem - unsigned long remainder @@ -101,7 +102,7 @@ __aullrem: mov eax,DVSRHI // check to see if divisor < 4194304K or eax,eax - jnz short ...L1 // nope, gotta do this the hard way + jnz short .L1 // nope, gotta do this the hard way mov ecx,DVSRLO // load divisor mov eax,DVNDHI // load high word of dividend xor edx,edx @@ -110,24 +111,24 @@ __aullrem: div ecx // edx <- final remainder mov eax,edx // edx:eax <- remainder xor edx,edx - jmp short ...L2 // restore stack and return + jmp short .L2 // restore stack and return // // Here we do it the hard way. Remember, eax contains DVSRHI // -...L1: +.L1: mov ecx,eax // ecx:ebx <- divisor mov ebx,DVSRLO mov edx,DVNDHI // edx:eax <- dividend mov eax,DVNDLO -...L3: +.L3: shr ecx,1 // shift divisor right one bit// hi bit <- 0 rcr ebx,1 shr edx,1 // shift dividend right one bit// hi bit <- 0 rcr eax,1 or ecx,ecx - jnz short ...L3 // loop until divisor < 4194304K + jnz short .L3 // loop until divisor < 4194304K div ebx // now divide, ignore remainder // @@ -142,7 +143,7 @@ __aullrem: xchg ecx,eax // put partial product in ECX, get quotient in EAX mul dword ptr DVSRLO add edx,ecx // EDX:EAX = QUOT * DVSR - jc short ...L4 // carry means Quotient is off by 1 + jc short .L4 // carry means Quotient is off by 1 // // do long compare here between original dividend and the result of the @@ -151,14 +152,14 @@ __aullrem: // cmp edx,DVNDHI // compare hi words of result and original - ja short ...L4 // if result > original, do subtract - jb short ...L5 // if result < original, we're ok + ja short .L4 // if result > original, do subtract + jb short .L5 // if result < original, we're ok cmp eax,DVNDLO // hi words are equal, compare lo words - jbe short ...L5 // if less or equal we're ok, else subtract -...L4: + jbe short .L5 // if less or equal we're ok, else subtract +.L4: sub eax,DVSRLO // subtract divisor from result sbb edx,DVSRHI -...L5: +.L5: // // Calculate remainder by subtracting the result from the original dividend. @@ -177,8 +178,10 @@ __aullrem: // Restore the saved registers and return. // -...L2: +.L2: pop ebx ret 16 + +END diff --git a/reactos/lib/sdk/crt/math/i386/aullshr_asm.s b/reactos/lib/sdk/crt/math/i386/aullshr_asm.s index 1b9f2af9f2e..5d65f4b2eea 100644 --- a/reactos/lib/sdk/crt/math/i386/aullshr_asm.s +++ b/reactos/lib/sdk/crt/math/i386/aullshr_asm.s @@ -33,12 +33,13 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ - -.globl __aullshr - -.intel_syntax noprefix +#include + +PUBLIC __aullshr + /* FUNCTIONS ***************************************************************/ +.code // // ullshr - long shift right @@ -65,13 +66,13 @@ __aullshr: // depends only on the high order bit of edx). // cmp cl,64 - jae short ..RETZERO + jae short .RETZERO // // Handle shifts of between 0 and 31 bits // cmp cl, 32 - jae short ..MORE32 + jae short .MORE32 shrd eax,edx,cl shr edx,cl ret @@ -79,7 +80,7 @@ __aullshr: // // Handle shifts of between 32 and 63 bits // -..MORE32: +.MORE32: mov eax,edx xor edx,edx and cl,31 @@ -89,7 +90,9 @@ __aullshr: // // return 0 in edx:eax // -..RETZERO: +.RETZERO: xor eax,eax xor edx,edx ret + +END diff --git a/reactos/lib/sdk/crt/math/i386/ceil_asm.s b/reactos/lib/sdk/crt/math/i386/ceil_asm.s index aad69114f5a..0b6d2ffb7b3 100644 --- a/reactos/lib/sdk/crt/math/i386/ceil_asm.s +++ b/reactos/lib/sdk/crt/math/i386/ceil_asm.s @@ -33,12 +33,13 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ - -.globl _ceil -.intel_syntax noprefix +#include + +PUBLIC _ceil /* FUNCTIONS ***************************************************************/ +.code _ceil: push ebp @@ -47,7 +48,7 @@ _ceil: fld qword ptr [ebp+8] // Load real from stack fstcw [ebp-2] // Save control word fclex // Clear exceptions - mov word ptr [ebp-4],0xb63 // Rounding control word + mov word ptr [ebp-4], HEX(0b63) // Rounding control word fldcw [ebp-4] // Set new rounding control frndint // Round to integer fclex // Clear exceptions @@ -55,3 +56,5 @@ _ceil: mov esp,ebp // Deallocate temporary space pop ebp ret + +END diff --git a/reactos/lib/sdk/crt/math/i386/ceilf.S b/reactos/lib/sdk/crt/math/i386/ceilf.S index 9eee272ecb3..79d66ce1cf2 100644 --- a/reactos/lib/sdk/crt/math/i386/ceilf.S +++ b/reactos/lib/sdk/crt/math/i386/ceilf.S @@ -3,53 +3,34 @@ * This file is part of the w64 mingw-runtime package. * No warranty is given; refer to the file DISCLAIMER.PD within this package. */ -#include <_mingw_mac.h> - .file "ceilf.S" - .text - .align 4 -.globl __MINGW_USYMBOL(ceilf) - .def __MINGW_USYMBOL(ceilf); .scl 2; .type 32; .endef -__MINGW_USYMBOL(ceilf): -#ifdef _WIN64 - subq $24,%rsp - movss %xmm0,8(%rsp) - flds 8(%rsp) +#include - fstcw 4(%rsp) /* store fpu control word */ +.code +.align 4 - movl $0x0800,%edx /* round towards +oo */ - orl 4(%rsp),%edx - andl $0xfbff,%edx - movl %edx,(%rsp) - fldcw (%rsp) /* load modified control word */ +PUBLIC _ceilf +_ceilf: - frndint /* round */ + fld dword ptr [esp + 4] + sub esp, 8 - fldcw 4(%rsp) /* restore original control word */ - fstps 8(%rsp) - movss 8(%rsp),%xmm0 - addq $24,%rsp - ret -#else - flds 4(%esp) - subl $8,%esp - - fstcw 4(%esp) /* store fpu control word */ + fstcw [esp + 4] /* store fpu control word */ /* We use here %edx although only the low 1 bits are defined. But none of the operations should care and they are faster than the 16 bit operations. */ - movl $0x0800,%edx /* round towards +oo */ - orl 4(%esp),%edx - andl $0xfbff,%edx - movl %edx,(%esp) - fldcw (%esp) /* load modified control word */ + mov edx, [esp + 4] + or edx, HEX(0800) /* round towards +oo */ + and edx, HEX(fbff) + mov [esp], edx + fldcw [esp] /* load modified control word */ frndint /* round */ - fldcw 4(%esp) /* restore original control word */ + fldcw [esp + 4] /* restore original control word */ - addl $8,%esp + add esp, 8 ret -#endif + +END diff --git a/reactos/lib/sdk/crt/math/i386/cos_asm.s b/reactos/lib/sdk/crt/math/i386/cos_asm.s index b1c6ada49b2..7732fe78734 100644 --- a/reactos/lib/sdk/crt/math/i386/cos_asm.s +++ b/reactos/lib/sdk/crt/math/i386/cos_asm.s @@ -33,12 +33,13 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ - -.globl _cos -.intel_syntax noprefix +#include + +PUBLIC _cos /* FUNCTIONS ***************************************************************/ +.code _cos: push ebp @@ -47,3 +48,5 @@ _cos: fcos // Take the cosine pop ebp ret + +END diff --git a/reactos/lib/sdk/crt/math/i386/exp_asm.s b/reactos/lib/sdk/crt/math/i386/exp_asm.s new file mode 100644 index 00000000000..3dd5be060b9 --- /dev/null +++ b/reactos/lib/sdk/crt/math/i386/exp_asm.s @@ -0,0 +1,29 @@ + +#include + +PUBLIC _exp + +/* FUNCTIONS ***************************************************************/ +.code + +_exp: + push ebp + mov ebp, esp + + fld qword ptr [ebp + 8] + fldl2e + fmul st, st(1) + fst st(1) + frndint + fxch st(1) + fsub st, st(1) + f2xm1 + fld1 + faddp st(1), st + fscale + fstp st(1) + + pop ebp + ret + +END diff --git a/reactos/lib/sdk/crt/math/i386/fabs_asm.s b/reactos/lib/sdk/crt/math/i386/fabs_asm.s index 5c6ce9214ef..c121f5205db 100644 --- a/reactos/lib/sdk/crt/math/i386/fabs_asm.s +++ b/reactos/lib/sdk/crt/math/i386/fabs_asm.s @@ -33,12 +33,13 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ - -.globl _fabs - -.intel_syntax noprefix +#include + +PUBLIC _fabs + /* FUNCTIONS ***************************************************************/ +.code _fabs: push ebp @@ -47,3 +48,5 @@ _fabs: fabs // Take the absolute value pop ebp ret + +END diff --git a/reactos/lib/sdk/crt/math/i386/floor_asm.s b/reactos/lib/sdk/crt/math/i386/floor_asm.s index f03c85cb4e8..7a2ed174eb3 100644 --- a/reactos/lib/sdk/crt/math/i386/floor_asm.s +++ b/reactos/lib/sdk/crt/math/i386/floor_asm.s @@ -33,12 +33,13 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ - -.globl _floor - -.intel_syntax noprefix +#include + +PUBLIC _floor + /* FUNCTIONS ***************************************************************/ +.code _floor: push ebp @@ -47,7 +48,7 @@ _floor: fld qword ptr [ebp+8] // Load real from stack fstcw [ebp-2] // Save control word fclex // Clear exceptions - mov word ptr [ebp-4],0x763 // Rounding control word + mov word ptr [ebp-4], HEX(0763) // Rounding control word fldcw [ebp-4] // Set new rounding control frndint // Round to integer fclex // Clear exceptions @@ -55,3 +56,5 @@ _floor: mov esp,ebp pop ebp ret + +END diff --git a/reactos/lib/sdk/crt/math/i386/floorf.S b/reactos/lib/sdk/crt/math/i386/floorf.S index eec073b2376..99ef5522038 100644 --- a/reactos/lib/sdk/crt/math/i386/floorf.S +++ b/reactos/lib/sdk/crt/math/i386/floorf.S @@ -7,57 +7,34 @@ * Removed header file dependency for use in libmingwex.a by * Danny Smith */ -#include <_mingw_mac.h> - .file "floorf.S" - .text -#ifdef _WIN64 - .align 8 -#else - .align 4 -#endif -.globl __MINGW_USYMBOL(floorf) - .def __MINGW_USYMBOL(floorf); .scl 2; .type 32; .endef -__MINGW_USYMBOL(floorf): -#ifdef _WIN64 - subq $24,%rsp - movss %xmm0,8(%rsp) - flds 8(%rsp) +#include - fstcw 4(%rsp) /* store fpu control word */ - movl $0x400,%edx /* round towards -oo */ - orl 4(%rsp),%edx - andl $0xf7ff,%edx - movl %edx,(%rsp) - fldcw (%rsp) /* load modified control word */ +.code +.align 4 - frndint /* round */ +PUBLIC _floorf +_floorf: - fldcw 4(%rsp) /* restore original control word */ + fld dword ptr [esp + 4] + sub esp, 8 - fstps 8(%rsp) - movss 8(%rsp),%xmm0 - addq $24,%rsp - ret -#else - flds 4(%esp) - subl $8,%esp - - fstcw 4(%esp) /* store fpu control word */ + fstcw [esp + 4] /* store fpu control word */ /* We use here %edx although only the low 1 bits are defined. But none of the operations should care and they are faster than the 16 bit operations. */ - movl $0x400,%edx /* round towards -oo */ - orl 4(%esp),%edx - andl $0xf7ff,%edx - movl %edx,(%esp) - fldcw (%esp) /* load modified control word */ + mov edx, [esp + 4] + or edx, HEX(0400) /* round towards -oo */ + and edx, HEX(0f7ff) + mov [esp], edx + fldcw [esp] /* load modified control word */ frndint /* round */ - fldcw 4(%esp) /* restore original control word */ + fldcw [esp + 4] /* restore original control word */ - addl $8,%esp + add esp, 8 ret -#endif + +END diff --git a/reactos/lib/sdk/crt/math/i386/fmod_asm.s b/reactos/lib/sdk/crt/math/i386/fmod_asm.s new file mode 100644 index 00000000000..44be4c0b24a --- /dev/null +++ b/reactos/lib/sdk/crt/math/i386/fmod_asm.s @@ -0,0 +1,26 @@ + +#include + +PUBLIC _fmod + +/* FUNCTIONS ***************************************************************/ +.code + +_fmod: + push ebp + mov ebp, esp + + fld qword ptr [ebp + 8] + fld qword ptr [ebp + 16] + fxch st(1) +l1: + fprem + fstsw ax + sahf + jp l1 + fstp st(1) + + pop ebp + ret + +END diff --git a/reactos/lib/sdk/crt/math/i386/fmodf_asm.s b/reactos/lib/sdk/crt/math/i386/fmodf_asm.s new file mode 100644 index 00000000000..1a06ef98671 --- /dev/null +++ b/reactos/lib/sdk/crt/math/i386/fmodf_asm.s @@ -0,0 +1,26 @@ + +#include + +PUBLIC _fmodf + +/* FUNCTIONS ***************************************************************/ +.code + +_fmodf: + push ebp + mov ebp, esp + + fld dword ptr [esp + 4] + fld dword ptr [esp + 8] + fxch st(1) +l1: + fprem + fstsw ax + sahf + jp l1 + fstp st(1) + + pop ebp + ret + +END diff --git a/reactos/lib/sdk/crt/math/i386/ftol2_asm.s b/reactos/lib/sdk/crt/math/i386/ftol2_asm.s new file mode 100644 index 00000000000..12f55010312 --- /dev/null +++ b/reactos/lib/sdk/crt/math/i386/ftol2_asm.s @@ -0,0 +1,28 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS kernel + * PURPOSE: Run-Time Library + * FILE: lib/rtl/i386/ftol2.S + * PROGRAMER: + * + */ + +#include + +EXTERN __ftol:PROC +PUBLIC __ftol2 +PUBLIC __ftol2_sse + +/* FUNCTIONS ***************************************************************/ +.code + +/* + * This routine is called by MSVC-generated code to convert from floating point + * to integer representation. The floating point number to be converted is + * on the top of the floating point stack. + */ +__ftol2: +__ftol2_sse: + jmp __ftol + +END diff --git a/reactos/lib/sdk/crt/math/i386/ftol_asm.s b/reactos/lib/sdk/crt/math/i386/ftol_asm.s index 4e1445a9988..9942f389f88 100644 --- a/reactos/lib/sdk/crt/math/i386/ftol_asm.s +++ b/reactos/lib/sdk/crt/math/i386/ftol_asm.s @@ -33,12 +33,13 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ - -.globl __ftol - -.intel_syntax noprefix +#include + +PUBLIC __ftol + /* FUNCTIONS ***************************************************************/ +.code /* * This routine is called by MSVC-generated code to convert from floating point @@ -54,7 +55,7 @@ __ftol: fstcw [ebp-2] wait mov ax, [ebp-2] - or ah, 0xC + or ah, 12 mov [ebp-4], ax fldcw [ebp-4] @@ -71,3 +72,5 @@ __ftol: /* Remove stack frame and return*/ leave ret + +END diff --git a/reactos/lib/sdk/crt/math/i386/log10_asm.s b/reactos/lib/sdk/crt/math/i386/log10_asm.s index 71731816429..a627ace1090 100644 --- a/reactos/lib/sdk/crt/math/i386/log10_asm.s +++ b/reactos/lib/sdk/crt/math/i386/log10_asm.s @@ -7,12 +7,13 @@ * PROGRAMER: Magnus Olsen (magnus@greatlord.com) * */ - -.globl _log10 -.intel_syntax noprefix +#include + +PUBLIC _log10 /* FUNCTIONS ***************************************************************/ +.code _log10: @@ -25,3 +26,4 @@ _log10: pop ebp ret +END diff --git a/reactos/lib/sdk/crt/math/i386/log_asm.s b/reactos/lib/sdk/crt/math/i386/log_asm.s index 0d98279ed41..472202fee92 100644 --- a/reactos/lib/sdk/crt/math/i386/log_asm.s +++ b/reactos/lib/sdk/crt/math/i386/log_asm.s @@ -33,12 +33,13 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ - -.globl _log - -.intel_syntax noprefix +#include + +PUBLIC _log + /* FUNCTIONS ***************************************************************/ +.code _log: push ebp @@ -49,3 +50,5 @@ _log: fyl2x // Compute the natural log(x) pop ebp ret + +END diff --git a/reactos/lib/sdk/crt/math/i386/pow_asm.s b/reactos/lib/sdk/crt/math/i386/pow_asm.s index 0b79aa5883e..f418cd38c6e 100644 --- a/reactos/lib/sdk/crt/math/i386/pow_asm.s +++ b/reactos/lib/sdk/crt/math/i386/pow_asm.s @@ -19,41 +19,53 @@ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -/* Reacros modifications */ +/* Reactos modifications */ +#include + #define ALIGNARG(log2) log2 #define ASM_TYPE_DIRECTIVE(name,typearg) #define ASM_SIZE_DIRECTIVE(name) #define cfi_adjust_cfa_offset(x) -#define ENTRY(x) -#define END(x) -.global _pow - .text +PUBLIC _pow + +.data +ASSUME nothing .align ALIGNARG(4) ASM_TYPE_DIRECTIVE(infinity,@object) + inf_zero: infinity: - .byte 0, 0, 0, 0, 0, 0, 0xf0, 0x7f + .byte 0, 0, 0, 0, 0, 0, HEX(f0), HEX(7f) ASM_SIZE_DIRECTIVE(infinity) ASM_TYPE_DIRECTIVE(zero,@object) -zero: .double 0.0 +zero: + .double 0.0 ASM_SIZE_DIRECTIVE(zero) ASM_TYPE_DIRECTIVE(minf_mzero,@object) + minf_mzero: minfinity: - .byte 0, 0, 0, 0, 0, 0, 0xf0, 0xff + .byte 0, 0, 0, 0, 0, 0, HEX(f0), HEX(ff) + mzero: - .byte 0, 0, 0, 0, 0, 0, 0, 0x80 + .byte 0, 0, 0, 0, 0, 0, 0, HEX(80) ASM_SIZE_DIRECTIVE(minf_mzero) ASM_TYPE_DIRECTIVE(one,@object) -one: .double 1.0 + +one: + .double 1.0 ASM_SIZE_DIRECTIVE(one) ASM_TYPE_DIRECTIVE(limit,@object) -limit: .double 0.29 + +limit: + .double 0.29 ASM_SIZE_DIRECTIVE(limit) ASM_TYPE_DIRECTIVE(p63,@object) -p63: .byte 0, 0, 0, 0, 0, 0, 0xe0, 0x43 + +p63: + .byte 0, 0, 0, 0, 0, 0, HEX(e0), HEX(43) ASM_SIZE_DIRECTIVE(p63) #ifdef PIC @@ -61,308 +73,309 @@ p63: .byte 0, 0, 0, 0, 0, 0, 0xe0, 0x43 #define MOX(op,x,f) op##@GOTOFF(%ecx,x,f) #else #define MO(op) op -#define MOX(op,x,f) op(,x,f) +#define MOX(op,x,f) op[x*f] #endif - .text +.code _pow: -ENTRY(__ieee754_pow) - fldl 12(%esp) // y + fld qword ptr [esp + 12] // y fxam #ifdef PIC LOAD_PIC_REG (cx) #endif - fnstsw - movb %ah, %dl - andb $0x45, %ah - cmpb $0x40, %ah // is y == 0 ? - je 11f + fnstsw ax + mov dl, ah + and ah, HEX(045) + cmp ah, HEX(040) // is y == 0 ? + je L11 - cmpb $0x05, %ah // is y == ±inf ? - je 12f + cmp ah, 5 // is y == ±inf ? + je L12 - cmpb $0x01, %ah // is y == NaN ? - je 30f + cmp ah, 1 // is y == NaN ? + je L30 - fldl 4(%esp) // x : y + fld qword ptr [esp + 4] // x : y - subl $8,%esp + sub esp, 8 cfi_adjust_cfa_offset (8) fxam - fnstsw - movb %ah, %dh - andb $0x45, %ah - cmpb $0x40, %ah - je 20f // x is ±0 + fnstsw ax + mov dh, ah + and ah, HEX(45) + cmp ah, HEX(040) + je L20 // x is ±0 - cmpb $0x05, %ah - je 15f // x is ±inf + cmp ah, 5 + je L15 // x is ±inf - fxch // y : x + fxch st(1) // y : x /* fistpll raises invalid exception for |y| >= 1L<<63. */ - fld %st // y : y : x + fld st // y : y : x fabs // |y| : y : x - fcompl MO(p63) // y : x - fnstsw + fcomp qword ptr MO(p63) // y : x + fnstsw ax sahf - jnc 2f + jnc L2 /* First see whether `y' is a natural number. In this case we can use a more precise algorithm. */ - fld %st // y : y : x - fistpll (%esp) // y : x - fildll (%esp) // int(y) : y : x - fucomp %st(1) // y : x - fnstsw + fld st // y : y : x + fistp qword ptr [esp] // y : x + fild qword ptr [esp] // int(y) : y : x + fucomp st(1) // y : x + fnstsw ax sahf - jne 2f + jne L2 /* OK, we have an integer value for y. */ - popl %eax + pop eax cfi_adjust_cfa_offset (-4) - popl %edx + pop edx cfi_adjust_cfa_offset (-4) - orl $0, %edx - fstp %st(0) // x - jns 4f // y >= 0, jump - fdivrl MO(one) // 1/x (now referred to as x) - negl %eax - adcl $0, %edx - negl %edx -4: fldl MO(one) // 1 : x - fxch + or edx, 0 + fstp st // x + jns L4 // y >= 0, jump + fdivr qword ptr MO(one) // 1/x (now referred to as x) + neg eax + adc edx, 0 + neg edx +L4: fld qword ptr MO(one) // 1 : x + fxch st(1) -6: shrdl $1, %edx, %eax - jnc 5f - fxch - fmul %st(1) // x : ST*x - fxch -5: fmul %st(0), %st // x*x : ST*x - shrl $1, %edx - movl %eax, %ecx - orl %edx, %ecx - jnz 6b - fstp %st(0) // ST*x +L6: shrd eax, edx, 1 + jnc L5 + fxch st(1) + fmul st, st(1) // x : ST*x + fxch st(1) +L5: fmul st, st // x*x : ST*x + shr edx, 1 + mov ecx, eax + or ecx, edx + jnz L6 + fstp st // ST*x ret /* y is ±NAN */ -30: fldl 4(%esp) // x : y - fldl MO(one) // 1.0 : x : y - fucomp %st(1) // x : y - fnstsw +L30: + fld qword ptr [esp + 4] // x : y + fld qword ptr MO(one) // 1.0 : x : y + fucomp st(1) // x : y + fnstsw ax sahf - je 31f - fxch // y : x -31: fstp %st(1) + je L31 + fxch st(1) // y : x +L31:fstp st(1) ret cfi_adjust_cfa_offset (8) .align ALIGNARG(4) -2: /* y is a real number. */ - fxch // x : y - fldl MO(one) // 1.0 : x : y - fldl MO(limit) // 0.29 : 1.0 : x : y - fld %st(2) // x : 0.29 : 1.0 : x : y - fsub %st(2) // x-1 : 0.29 : 1.0 : x : y +L2: /* y is a real number. */ + fxch st(1) // x : y + fld qword ptr MO(one) // 1.0 : x : y + fld qword ptr MO(limit) // 0.29 : 1.0 : x : y + fld st(2) // x : 0.29 : 1.0 : x : y + fsub st, st(2) // x-1 : 0.29 : 1.0 : x : y fabs // |x-1| : 0.29 : 1.0 : x : y fucompp // 1.0 : x : y - fnstsw - fxch // x : 1.0 : y + fnstsw ax + fxch st(1) // x : 1.0 : y sahf - ja 7f - fsub %st(1) // x-1 : 1.0 : y + ja L7 + fsub st, st(1) // x-1 : 1.0 : y fyl2xp1 // log2(x) : y - jmp 8f + jmp L8 -7: fyl2x // log2(x) : y -8: fmul %st(1) // y*log2(x) : y - fst %st(1) // y*log2(x) : y*log2(x) +L7: fyl2x // log2(x) : y +L8: fmul st, st(1) // y*log2(x) : y + fst st(1) // y*log2(x) : y*log2(x) frndint // int(y*log2(x)) : y*log2(x) - fsubr %st, %st(1) // int(y*log2(x)) : fract(y*log2(x)) + fsubr st(1), st // int(y*log2(x)) : fract(y*log2(x)) fxch // fract(y*log2(x)) : int(y*log2(x)) f2xm1 // 2^fract(y*log2(x))-1 : int(y*log2(x)) - faddl MO(one) // 2^fract(y*log2(x)) : int(y*log2(x)) + fadd qword ptr MO(one) // 2^fract(y*log2(x)) : int(y*log2(x)) fscale // 2^fract(y*log2(x))*2^int(y*log2(x)) : int(y*log2(x)) - addl $8, %esp + add esp, 8 cfi_adjust_cfa_offset (-8) - fstp %st(1) // 2^fract(y*log2(x))*2^int(y*log2(x)) + fstp st(1) // 2^fract(y*log2(x))*2^int(y*log2(x)) ret // pow(x,±0) = 1 .align ALIGNARG(4) -11: fstp %st(0) // pop y - fldl MO(one) +L11:fstp st(0) // pop y + fld qword ptr MO(one) ret // y == ±inf .align ALIGNARG(4) -12: fstp %st(0) // pop y - fldl MO(one) // 1 - fldl 4(%esp) // x : 1 +L12: fstp st(0) // pop y + fld qword ptr MO(one) // 1 + fld qword ptr [esp + 4] // x : 1 fabs // abs(x) : 1 fucompp // < 1, == 1, or > 1 - fnstsw - andb $0x45, %ah - cmpb $0x45, %ah - je 13f // jump if x is NaN + fnstsw ax + and ah, HEX(45) + cmp ah, HEX(45) + je L13 // jump if x is NaN - cmpb $0x40, %ah - je 14f // jump if |x| == 1 + cmp ah, HEX(40) + je L14 // jump if |x| == 1 - shlb $1, %ah - xorb %ah, %dl - andl $2, %edx - fldl MOX(inf_zero, %edx, 4) + shl ah, 1 + xor dl, ah + and edx, 2 + fld qword ptr MOX(inf_zero, edx, 4) ret .align ALIGNARG(4) -14: fldl MO(one) +L14:fld qword ptr MO(one) ret .align ALIGNARG(4) -13: fldl 4(%esp) // load x == NaN +L13:fld qword ptr [esp + 4] // load x == NaN ret cfi_adjust_cfa_offset (8) .align ALIGNARG(4) // x is ±inf -15: fstp %st(0) // y - testb $2, %dh - jz 16f // jump if x == +inf +L15: fstp st(0) // y + test dh, 2 + jz L16 // jump if x == +inf // We must find out whether y is an odd integer. - fld %st // y : y - fistpll (%esp) // y - fildll (%esp) // int(y) : y + fld st // y : y + fistp qword ptr [esp] // y + fild qword ptr [esp] // int(y) : y fucompp // - fnstsw + fnstsw ax sahf - jne 17f + jne L17 // OK, the value is an integer, but is the number of bits small // enough so that all are coming from the mantissa? - popl %eax + pop eax cfi_adjust_cfa_offset (-4) - popl %edx + pop edx cfi_adjust_cfa_offset (-4) - andb $1, %al - jz 18f // jump if not odd - movl %edx, %eax - orl %edx, %edx - jns 155f - negl %eax -155: cmpl $0x00200000, %eax - ja 18f // does not fit in mantissa bits + and al, 1 + jz L18 // jump if not odd + mov eax, edx + or edx, edx + jns L155 + neg eax +L155: + cmp eax, HEX(000200000) + ja L18 // does not fit in mantissa bits // It's an odd integer. - shrl $31, %edx - fldl MOX(minf_mzero, %edx, 8) + shr edx, 31 + fld qword ptr MOX(minf_mzero, edx, 8) ret cfi_adjust_cfa_offset (8) .align ALIGNARG(4) -16: fcompl MO(zero) - addl $8, %esp +L16:fcomp qword ptr MO(zero) + add esp, 8 cfi_adjust_cfa_offset (-8) - fnstsw - shrl $5, %eax - andl $8, %eax - fldl MOX(inf_zero, %eax, 1) + fnstsw ax + shr eax, 5 + and eax, 8 + fld qword ptr MOX(inf_zero, eax, 1) ret cfi_adjust_cfa_offset (8) .align ALIGNARG(4) -17: shll $30, %edx // sign bit for y in right position - addl $8, %esp +L17: shl ecx, 30 // sign bit for y in right position + add esp, 8 cfi_adjust_cfa_offset (-8) -18: shrl $31, %edx - fldl MOX(inf_zero, %edx, 8) +L18: shr edx, 31 + fld qword ptr MOX(inf_zero, edx, 8) ret cfi_adjust_cfa_offset (8) .align ALIGNARG(4) // x is ±0 -20: fstp %st(0) // y - testb $2, %dl - jz 21f // y > 0 +L20: fstp st(0) // y + test dl, 2 + jz L21 // y > 0 // x is ±0 and y is < 0. We must find out whether y is an odd integer. - testb $2, %dh - jz 25f + test dh, 2 + jz L25 - fld %st // y : y - fistpll (%esp) // y - fildll (%esp) // int(y) : y + fld st // y : y + fistp qword ptr [esp] // y + fild qword ptr [esp] // int(y) : y fucompp // - fnstsw + fnstsw ax sahf - jne 26f + jne L26 // OK, the value is an integer, but is the number of bits small // enough so that all are coming from the mantissa? - popl %eax + pop eax cfi_adjust_cfa_offset (-4) - popl %edx + pop edx cfi_adjust_cfa_offset (-4) - andb $1, %al - jz 27f // jump if not odd - cmpl $0xffe00000, %edx - jbe 27f // does not fit in mantissa bits + and al, 1 + jz L27 // jump if not odd + cmp edx, HEX(0ffe00000) + jbe L27 // does not fit in mantissa bits // It's an odd integer. // Raise divide-by-zero exception and get minus infinity value. - fldl MO(one) - fdivl MO(zero) + fld qword ptr MO(one) + fdiv qword ptr MO(zero) fchs ret cfi_adjust_cfa_offset (8) -25: fstp %st(0) -26: addl $8, %esp +L25: fstp st(0) +L26: add esp, 8 cfi_adjust_cfa_offset (-8) -27: // Raise divide-by-zero exception and get infinity value. - fldl MO(one) - fdivl MO(zero) +L27: // Raise divide-by-zero exception and get infinity value. + fld qword ptr MO(one) + fdiv qword ptr MO(zero) ret cfi_adjust_cfa_offset (8) .align ALIGNARG(4) // x is ±0 and y is > 0. We must find out whether y is an odd integer. -21: testb $2, %dh - jz 22f +L21:test dh, 2 + jz L22 - fld %st // y : y - fistpll (%esp) // y - fildll (%esp) // int(y) : y + fld st // y : y + fistp qword ptr [esp] // y + fild qword ptr [esp] // int(y) : y fucompp // - fnstsw + fnstsw ax sahf - jne 23f + jne L23 // OK, the value is an integer, but is the number of bits small // enough so that all are coming from the mantissa? - popl %eax + pop eax cfi_adjust_cfa_offset (-4) - popl %edx + pop edx cfi_adjust_cfa_offset (-4) - andb $1, %al - jz 24f // jump if not odd - cmpl $0xffe00000, %edx - jae 24f // does not fit in mantissa bits + and al, 1 + jz L24 // jump if not odd + cmp edx, HEX(0ffe00000) + jae L24 // does not fit in mantissa bits // It's an odd integer. - fldl MO(mzero) + fld qword ptr MO(mzero) ret cfi_adjust_cfa_offset (8) -22: fstp %st(0) -23: addl $8, %esp // Don't use 2 x pop +L22: fstp st(0) +L23: add esp, 8 // Don't use 2 x pop cfi_adjust_cfa_offset (-8) -24: fldl MO(zero) +L24: fld qword ptr MO(zero) ret -END(__ieee754_pow) +END diff --git a/reactos/lib/sdk/crt/math/i386/sin_asm.s b/reactos/lib/sdk/crt/math/i386/sin_asm.s index 39791a3e989..4a27af804b2 100644 --- a/reactos/lib/sdk/crt/math/i386/sin_asm.s +++ b/reactos/lib/sdk/crt/math/i386/sin_asm.s @@ -33,12 +33,13 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ - -.globl _sin -.intel_syntax noprefix +#include + +PUBLIC _sin /* FUNCTIONS ***************************************************************/ +.code _sin: push ebp // Save register bp @@ -47,3 +48,5 @@ _sin: fsin // Take the sine pop ebp // Restore register bp ret + +END diff --git a/reactos/lib/sdk/crt/math/i386/sqrt_asm.s b/reactos/lib/sdk/crt/math/i386/sqrt_asm.s index c953a0350e9..3385204d572 100644 --- a/reactos/lib/sdk/crt/math/i386/sqrt_asm.s +++ b/reactos/lib/sdk/crt/math/i386/sqrt_asm.s @@ -33,12 +33,13 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ - -.globl _sqrt - -.intel_syntax noprefix +#include + +PUBLIC _sqrt + /* FUNCTIONS ***************************************************************/ +.code _sqrt: push ebp @@ -47,3 +48,5 @@ _sqrt: fsqrt // Take the square root pop ebp ret + +END diff --git a/reactos/lib/sdk/crt/math/i386/tan_asm.s b/reactos/lib/sdk/crt/math/i386/tan_asm.s index 34af2614f89..3b64b360f17 100644 --- a/reactos/lib/sdk/crt/math/i386/tan_asm.s +++ b/reactos/lib/sdk/crt/math/i386/tan_asm.s @@ -33,12 +33,13 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ - -.globl _tan - -.intel_syntax noprefix +#include + +PUBLIC _tan + /* FUNCTIONS ***************************************************************/ +.code _tan: push ebp @@ -50,3 +51,5 @@ _tan: mov esp,ebp // Deallocate temporary space pop ebp ret + +END diff --git a/reactos/lib/sdk/crt/mem/i386/memchr_asm.s b/reactos/lib/sdk/crt/mem/i386/memchr_asm.s index f6e8037fc31..40cd3dc8cef 100644 --- a/reactos/lib/sdk/crt/mem/i386/memchr_asm.s +++ b/reactos/lib/sdk/crt/mem/i386/memchr_asm.s @@ -5,28 +5,34 @@ * FILE: lib/sdk/crt/mem/i386/memchr.s */ +#include +#include + /* * void* memchr(const void* s, int c, size_t n) */ -.globl _memchr +PUBLIC _memchr +.code _memchr: - push %ebp - mov %esp,%ebp - push %edi - mov 0x8(%ebp),%edi - mov 0xc(%ebp),%eax - mov 0x10(%ebp),%ecx + push ebp + mov ebp, esp + push edi + mov edi, [ebp + 8] + mov eax, [ebp + 12] + mov ecx, [ebp + 16] cld - jecxz .Lnotfound - repne scasb - je .Lfound + jecxz .Lnotfound + repne scasb + je .Lfound .Lnotfound: - mov $1,%edi + mov edi, 1 .Lfound: - mov %edi,%eax - dec %eax - pop %edi + mov eax, edi + dec eax + pop edi leave ret + +END diff --git a/reactos/lib/sdk/crt/mem/i386/memcpy_asm.s b/reactos/lib/sdk/crt/mem/i386/memcpy_asm.s index 36a1a079513..e69de29bb2d 100644 --- a/reactos/lib/sdk/crt/mem/i386/memcpy_asm.s +++ b/reactos/lib/sdk/crt/mem/i386/memcpy_asm.s @@ -1,114 +0,0 @@ -/* - * void *memcpy (void *to, const void *from, size_t count) - * - * NOTE: This code is a duplicate of memmove function from memmove_asm.s - */ - -.globl _memcpy - -_memcpy: - push %ebp - mov %esp,%ebp - - push %esi - push %edi - - mov 8(%ebp),%edi - mov 12(%ebp),%esi - mov 16(%ebp),%ecx - - cmp %esi,%edi - jbe .CopyUp - mov %ecx,%eax - add %esi,%eax - cmp %eax,%edi - jb .CopyDown - -.CopyUp: - cld - - cmp $16,%ecx - jb .L1 - mov %ecx,%edx - test $3,%edi - je .L2 -/* - * Make the destination dword aligned - */ - mov %edi,%ecx - and $3,%ecx - sub $5,%ecx - not %ecx - sub %ecx,%edx - rep movsb - mov %edx,%ecx -.L2: - shr $2,%ecx - rep movsl - mov %edx,%ecx - and $3,%ecx -.L1: - test %ecx,%ecx - je .L3 - rep movsb -.L3: - mov 8(%ebp),%eax - pop %edi - pop %esi - leave - ret - -.CopyDown: - std - - add %ecx,%edi - add %ecx,%esi - - cmp $16,%ecx - jb .L4 - mov %ecx,%edx - test $3,%edi - je .L5 - -/* - * Make the destination dword aligned - */ - mov %edi,%ecx - and $3,%ecx - sub %ecx,%edx - dec %esi - dec %edi - rep movsb - mov %edx,%ecx - - sub $3,%esi - sub $3,%edi -.L6: - shr $2,%ecx - rep movsl - mov %edx,%ecx - and $3,%ecx - je .L7 - add $3,%esi - add $3,%edi -.L8: - rep movsb -.L7: - cld - mov 8(%ebp),%eax - pop %edi - pop %esi - leave - ret -.L5: - sub $4,%edi - sub $4,%esi - jmp .L6 - -.L4: - test %ecx,%ecx - je .L7 - dec %esi - dec %edi - jmp .L8 - diff --git a/reactos/lib/sdk/crt/mem/i386/memmove_asm.s b/reactos/lib/sdk/crt/mem/i386/memmove_asm.s index e27006e3bed..476f843befe 100644 --- a/reactos/lib/sdk/crt/mem/i386/memmove_asm.s +++ b/reactos/lib/sdk/crt/mem/i386/memmove_asm.s @@ -1,114 +1,120 @@ /* - * void *memmove (void *to, const void *from, size_t count) + * void *memcpy (void *to, const void *from, size_t count) * - * NOTE: This code is duplicated in memcpy_asm.s */ -.globl _memmove +#include +#include +PUBLIC _memcpy +PUBLIC _memmove +.code + +_memcpy: _memmove: - push %ebp - mov %esp,%ebp + push ebp + mov ebp, esp - push %esi - push %edi + push esi + push edi - mov 8(%ebp),%edi - mov 12(%ebp),%esi - mov 16(%ebp),%ecx + mov edi, [ebp + 8] + mov esi, [ebp + 12] + mov ecx, [ebp + 16] - cmp %esi,%edi + cmp edi, esi jbe .CopyUp - mov %ecx,%eax - add %esi,%eax - cmp %eax,%edi - jb .CopyDown - + mov eax, ecx + add eax, esi + cmp edi, eax + jb .CopyDown + .CopyUp: cld - cmp $16,%ecx - jb .L1 - mov %ecx,%edx - test $3,%edi - je .L2 + cmp ecx, 16 + jb .L1 + mov edx, ecx + test edi, 3 + je .L2 /* * Make the destination dword aligned */ - mov %edi,%ecx - and $3,%ecx - sub $5,%ecx - not %ecx - sub %ecx,%edx - rep movsb - mov %edx,%ecx + mov ecx, edi + and ecx, 3 + sub ecx, 5 + not ecx + sub edx, ecx + rep movsb + mov ecx, edx .L2: - shr $2,%ecx - rep movsl - mov %edx,%ecx - and $3,%ecx + shr ecx, 2 + rep movsd + mov ecx, edx + and ecx, 3 .L1: - test %ecx,%ecx - je .L3 - rep movsb + test ecx, ecx + je .L3 + rep movsb .L3: - mov 8(%ebp),%eax - pop %edi - pop %esi + mov eax, [ebp + 8] + pop edi + pop esi leave ret .CopyDown: - std + std - add %ecx,%edi - add %ecx,%esi + add edi, ecx + add esi, ecx - cmp $16,%ecx - jb .L4 - mov %ecx,%edx - test $3,%edi - je .L5 + cmp ecx, 16 + jb .L4 + mov edx, ecx + test edi, 3 + je .L5 /* * Make the destination dword aligned */ - mov %edi,%ecx - and $3,%ecx - sub %ecx,%edx - dec %esi - dec %edi - rep movsb - mov %edx,%ecx + mov ecx, edi + and ecx, 3 + sub edx, ecx + dec esi + dec edi + rep movsb + mov ecx, edx - sub $3,%esi - sub $3,%edi + sub esi, 3 + sub edi, 3 .L6: - shr $2,%ecx - rep movsl - mov %edx,%ecx - and $3,%ecx - je .L7 - add $3,%esi - add $3,%edi + shr ecx, 2 + rep movsd + mov ecx, edx + and ecx, 3 + je .L7 + add esi, 3 + add edi, 3 .L8: - rep movsb + rep movsb .L7: cld - mov 8(%ebp),%eax - pop %edi - pop %esi + mov eax, [ebp + 8] + pop edi + pop esi leave ret .L5: - sub $4,%edi - sub $4,%esi - jmp .L6 - -.L4: - test %ecx,%ecx - je .L7 - dec %esi - dec %edi - jmp .L8 + sub edi, 4 + sub esi, 4 + jmp .L6 +.L4: + test ecx, ecx + je .L7 + dec esi + dec edi + jmp .L8 + +END diff --git a/reactos/lib/sdk/crt/mem/i386/memset_asm.s b/reactos/lib/sdk/crt/mem/i386/memset_asm.s index 4f7c9436e71..81430472f4a 100644 --- a/reactos/lib/sdk/crt/mem/i386/memset_asm.s +++ b/reactos/lib/sdk/crt/mem/i386/memset_asm.s @@ -2,46 +2,51 @@ * $Id$ */ +#include +#include + /* * void *memset (void *src, int val, size_t count) */ -.globl _memset +PUBLIC _memset +.code _memset: - push %ebp - mov %esp,%ebp - push %edi - mov 0x8(%ebp),%edi - movzb 0xc(%ebp),%eax - mov 0x10(%ebp),%ecx + push ebp + mov ebp, esp + push edi + mov edi, [ebp + 8] + movzx eax, byte ptr [ebp + 12] + mov ecx, [ebp + 16] cld - cmp $16,%ecx - jb .L1 - mov $0x01010101,%edx - mul %edx - mov %ecx,%edx - test $3,%edi - je .L2 - mov %edi,%ecx - and $3,%ecx - sub $5,%ecx - not %ecx - sub %ecx,%edx - rep stosb - mov %edx,%ecx + cmp ecx, 16 + jb .L1 + mov edx, HEX(01010101) + mul edx + mov edx, ecx + test edi, 3 + je .L2 + mov ecx, edi + and ecx, 3 + sub ecx, 5 + not ecx + sub edx, ecx + rep stosb + mov ecx, edx .L2: - shr $2,%ecx - rep stosl - mov %edx,%ecx - and $3,%ecx + shr ecx, 2 + rep stosd + mov ecx, edx + and ecx, 3 .L1: - test %ecx,%ecx - je .L3 - rep stosb + test ecx, ecx + je .L3 + rep stosb .L3: - pop %edi - mov 0x8(%ebp),%eax + pop edi + mov eax, [ebp + 8] leave ret +END diff --git a/reactos/lib/sdk/crt/setjmp/amd64/setjmp.s b/reactos/lib/sdk/crt/setjmp/amd64/setjmp.s index 56459ae7665..a969bc43db5 100644 --- a/reactos/lib/sdk/crt/setjmp/amd64/setjmp.s +++ b/reactos/lib/sdk/crt/setjmp/amd64/setjmp.s @@ -8,8 +8,8 @@ /* INCLUDES ******************************************************************/ -#include -#include +#include +#include #define JUMP_BUFFER_Frame 0x00 #define JUMP_BUFFER_Rbx 0x08 @@ -156,3 +156,5 @@ PUBLIC longjmp inc rax 2: jmp r8 .endp longjmp + +END diff --git a/reactos/lib/sdk/crt/setjmp/i386/setjmp.s b/reactos/lib/sdk/crt/setjmp/i386/setjmp.s index 7cf257cca24..dc0e9656b3a 100644 --- a/reactos/lib/sdk/crt/setjmp/i386/setjmp.s +++ b/reactos/lib/sdk/crt/setjmp/i386/setjmp.s @@ -9,6 +9,8 @@ * complete implementation */ +#include + #define JB_BP 0 #define JB_BX 1 #define JB_DI 2 @@ -20,6 +22,7 @@ #define JMPBUF 4 +.code /* * int * _setjmp(jmp_buf env); @@ -33,20 +36,20 @@ * Notes: * Sets up the jmp_buf */ -.globl __setjmp +PUBLIC __setjmp __setjmp: - xorl %eax, %eax - movl JMPBUF(%esp), %edx + xor eax, eax + mov edx, JMPBUF[esp] /* Save registers. */ - movl %ebp, (JB_BP*4)(%edx) /* Save caller's frame pointer. */ - movl %ebx, (JB_BX*4)(%edx) - movl %edi, (JB_DI*4)(%edx) - movl %esi, (JB_SI*4)(%edx) - leal JMPBUF(%esp), %ecx /* Save SP as it will be after we return. */ - movl %ecx, (JB_SP*4)(%edx) - movl PCOFF(%esp), %ecx /* Save PC we are returning to now. */ - movl %ecx, (JB_IP*4)(%edx) + mov [edx + JB_BP*4], ebp /* Save caller's frame pointer. */ + mov [edx + JB_BX*4], ebx + mov [edx + JB_DI*4], edi + mov [edx + JB_SI*4], esi + lea ecx, JMPBUF[esp] /* Save SP as it will be after we return. */ + mov [edx + JB_SP*4], ecx + mov ecx, PCOFF[esp] /* Save PC we are returning to now. */ + mov [edx + JB_IP*4], ecx ret /* @@ -62,24 +65,22 @@ __setjmp: * Notes: * Sets up the jmp_buf */ -.globl __setjmp3 +PUBLIC __setjmp3 __setjmp3: - xorl %eax, %eax - movl JMPBUF(%esp), %edx + xor eax, eax + mov edx, JMPBUF[esp] /* Save registers. */ - movl %ebp, (JB_BP*4)(%edx) /* Save caller's frame pointer. */ - movl %ebx, (JB_BX*4)(%edx) - movl %edi, (JB_DI*4)(%edx) - movl %esi, (JB_SI*4)(%edx) - leal JMPBUF(%esp), %ecx /* Save SP as it will be after we return. */ - movl %ecx, (JB_SP*4)(%edx) - movl PCOFF(%esp), %ecx /* Save PC we are returning to now. */ - movl %ecx, (JB_IP*4)(%edx) + mov [edx + JB_BP*4], ebp /* Save caller's frame pointer. */ + mov [edx + JB_BX*4], ebx + mov [edx + JB_DI*4], edi + mov [edx + JB_SI*4], esi + lea ecx, JMPBUF[esp] /* Save SP as it will be after we return. */ + mov [edx + JB_SP*4], ecx + mov ecx, PCOFF[esp] /* Save PC we are returning to now. */ + mov [edx + JB_IP*4], ecx ret -#define VAL 8 - /* * void * longjmp(jmp_buf env, int value); @@ -94,18 +95,20 @@ __setjmp3: * Notes: * Non-local goto */ -.globl _longjmp +PUBLIC _longjmp _longjmp: - movl JMPBUF(%esp), %ecx /* User's jmp_buf in %ecx. */ + mov ecx, JMPBUF[esp] /* User's jmp_buf in %ecx. */ - movl VAL(%esp), %eax /* Second argument is return value. */ + mov eax, [esp + 8] /* Second argument is return value. */ /* Save the return address now. */ - movl (JB_IP*4)(%ecx), %edx + mov edx, [edx + JB_IP*4] /* Restore registers. */ - movl (JB_BP*4)(%ecx), %ebp - movl (JB_BX*4)(%ecx), %ebx - movl (JB_DI*4)(%ecx), %edi - movl (JB_SI*4)(%ecx), %esi - movl (JB_SP*4)(%ecx), %esp + mov ebp, [edx + JB_BP*4] + mov ebx, [edx + JB_BX*4] + mov edi, [edx + JB_DI*4] + mov esi, [edx + JB_SI*4] + mov esp, [edx + JB_SP*4] /* Jump to saved PC. */ - jmp *%edx + jmp dword ptr [edx] + +END diff --git a/reactos/lib/sdk/crt/string/i386/strcat_asm.s b/reactos/lib/sdk/crt/string/i386/strcat_asm.s index 1241e78f7bb..6f7b8052d23 100644 --- a/reactos/lib/sdk/crt/string/i386/strcat_asm.s +++ b/reactos/lib/sdk/crt/string/i386/strcat_asm.s @@ -1,6 +1,6 @@ /* $Id$ */ -#include "tcscat.h" +#include "tcscat.inc" /* EOF */ diff --git a/reactos/lib/sdk/crt/string/i386/strchr_asm.s b/reactos/lib/sdk/crt/string/i386/strchr_asm.s index b90e86d3303..f8085f25485 100644 --- a/reactos/lib/sdk/crt/string/i386/strchr_asm.s +++ b/reactos/lib/sdk/crt/string/i386/strchr_asm.s @@ -1,6 +1,6 @@ /* $Id$ */ -#include "tcschr.h" +#include "tcschr.inc" /* EOF */ diff --git a/reactos/lib/sdk/crt/string/i386/strcmp_asm.s b/reactos/lib/sdk/crt/string/i386/strcmp_asm.s index 3ee6573f700..8618f17c076 100644 --- a/reactos/lib/sdk/crt/string/i386/strcmp_asm.s +++ b/reactos/lib/sdk/crt/string/i386/strcmp_asm.s @@ -1,6 +1,6 @@ /* $Id$ */ -#include "tcscmp.h" +#include "tcscmp.inc" /* EOF */ diff --git a/reactos/lib/sdk/crt/string/i386/strcpy_asm.s b/reactos/lib/sdk/crt/string/i386/strcpy_asm.s index 1b77403847c..168d2921ba8 100644 --- a/reactos/lib/sdk/crt/string/i386/strcpy_asm.s +++ b/reactos/lib/sdk/crt/string/i386/strcpy_asm.s @@ -1,6 +1,6 @@ /* $Id$ */ -#include "tcscpy.h" +#include "tcscpy.inc" /* EOF */ diff --git a/reactos/lib/sdk/crt/string/i386/strlen_asm.s b/reactos/lib/sdk/crt/string/i386/strlen_asm.s index 9bb10b6d91b..66a8ba27299 100644 --- a/reactos/lib/sdk/crt/string/i386/strlen_asm.s +++ b/reactos/lib/sdk/crt/string/i386/strlen_asm.s @@ -1,6 +1,6 @@ /* $Id$ */ -#include "tcslen.h" +#include "tcslen.inc" /* EOF */ diff --git a/reactos/lib/sdk/crt/string/i386/strncat_asm.s b/reactos/lib/sdk/crt/string/i386/strncat_asm.s index 52b20671625..d7fefe417a7 100644 --- a/reactos/lib/sdk/crt/string/i386/strncat_asm.s +++ b/reactos/lib/sdk/crt/string/i386/strncat_asm.s @@ -1,6 +1,6 @@ /* $Id$ */ -#include "tcsncat.h" +#include "tcsncat.inc" /* EOF */ diff --git a/reactos/lib/sdk/crt/string/i386/strncmp_asm.s b/reactos/lib/sdk/crt/string/i386/strncmp_asm.s index 30c64e6b664..d4db767c207 100644 --- a/reactos/lib/sdk/crt/string/i386/strncmp_asm.s +++ b/reactos/lib/sdk/crt/string/i386/strncmp_asm.s @@ -1,6 +1,6 @@ /* $Id$ */ -#include "tcsncmp.h" +#include "tcsncmp.inc" /* EOF */ diff --git a/reactos/lib/sdk/crt/string/i386/strncpy_asm.s b/reactos/lib/sdk/crt/string/i386/strncpy_asm.s index 7409b4ed6c7..584dbb8cce5 100644 --- a/reactos/lib/sdk/crt/string/i386/strncpy_asm.s +++ b/reactos/lib/sdk/crt/string/i386/strncpy_asm.s @@ -1,6 +1,6 @@ /* $Id$ */ -#include "tcsncpy.h" +#include "tcsncpy.inc" /* EOF */ diff --git a/reactos/lib/sdk/crt/string/i386/strnlen_asm.s b/reactos/lib/sdk/crt/string/i386/strnlen_asm.s index be35b3ca2c2..5c1f8dfccf7 100644 --- a/reactos/lib/sdk/crt/string/i386/strnlen_asm.s +++ b/reactos/lib/sdk/crt/string/i386/strnlen_asm.s @@ -1,6 +1,6 @@ /* $Id$ */ -#include "tcsnlen.h" +#include "tcsnlen.inc" /* EOF */ diff --git a/reactos/lib/sdk/crt/string/i386/strrchr_asm.s b/reactos/lib/sdk/crt/string/i386/strrchr_asm.s index a8a9d5e79ac..c94f29ec0d7 100644 --- a/reactos/lib/sdk/crt/string/i386/strrchr_asm.s +++ b/reactos/lib/sdk/crt/string/i386/strrchr_asm.s @@ -1,6 +1,6 @@ /* $Id$ */ -#include "tcsrchr.h" +#include "tcsrchr.inc" /* EOF */ diff --git a/reactos/lib/sdk/crt/string/i386/tchar.h b/reactos/lib/sdk/crt/string/i386/tchar.h index ce2f1b9666d..a313e86111e 100644 --- a/reactos/lib/sdk/crt/string/i386/tchar.h +++ b/reactos/lib/sdk/crt/string/i386/tchar.h @@ -21,12 +21,12 @@ #define _tlods lodsw #define _tstos stosw -#define _tsize $2 +#define _tsize 2 #define _treg(_O_) _O_ ## x -#define _tdec(_O_) sub $2, _O_ -#define _tinc(_O_) add $2, _O_ +#define _tdec(_O_) sub _O_, 2 +#define _tinc(_O_) add _O_, 2 #else @@ -45,7 +45,7 @@ #define _tlods lodsb #define _tstos stosb -#define _tsize $1 +#define _tsize 1 #define _treg(_O_) _O_ ## l diff --git a/reactos/lib/sdk/crt/string/i386/tcscat.h b/reactos/lib/sdk/crt/string/i386/tcscat.h deleted file mode 100644 index e50676528d8..00000000000 --- a/reactos/lib/sdk/crt/string/i386/tcscat.h +++ /dev/null @@ -1,32 +0,0 @@ -/* $Id$ - */ - -#include "tchar.h" - -.globl _tcscat - -_tcscat: - push %esi - push %edi - mov 0x0C(%esp), %edi - mov 0x10(%esp), %esi - - xor %eax, %eax - mov $-1, %ecx - cld - - repne _tscas - _tdec(%edi) - -.L1: - _tlods - _tstos - test %_treg(a), %_treg(a) - jnz .L1 - - mov 0x0C(%esp), %eax - pop %edi - pop %esi - ret - -/* EOF */ diff --git a/reactos/lib/sdk/crt/string/i386/tcscat.inc b/reactos/lib/sdk/crt/string/i386/tcscat.inc new file mode 100644 index 00000000000..d587128f447 --- /dev/null +++ b/reactos/lib/sdk/crt/string/i386/tcscat.inc @@ -0,0 +1,35 @@ +/* $Id: tcscat.inc 49591 2010-11-15 01:29:12Z tkreuzer $ + */ + +#include "tchar.h" +#include + +PUBLIC _tcscat +.code + +_tcscat: + push esi + push edi + mov edi, [esp + 12] + mov esi, [esp + 16] + + xor eax, eax + mov ecx, -1 + cld + + repne _tscas + _tdec(edi) + +.L1: + _tlods + _tstos + test _treg(a), _treg(a) + jnz .L1 + + mov eax, [esp + 12] + pop edi + pop esi + ret + +END +/* EOF */ diff --git a/reactos/lib/sdk/crt/string/i386/tcschr.h b/reactos/lib/sdk/crt/string/i386/tcschr.h deleted file mode 100644 index ea08bb8d22e..00000000000 --- a/reactos/lib/sdk/crt/string/i386/tcschr.h +++ /dev/null @@ -1,30 +0,0 @@ -/* $Id$ - */ - -#include "tchar.h" - -.globl _tcschr - -_tcschr: - push %esi - mov 0x8(%esp), %esi - mov 0xC(%esp), %edx - - cld - -.L1: - _tlods - cmp %_treg(a), %_treg(d) - je .L2 - test %_treg(a), %_treg(a) - jnz .L1 - mov _tsize, %esi - -.L2: - mov %esi, %eax - _tdec(%eax) - - pop %esi - ret - -/* EOF */ diff --git a/reactos/lib/sdk/crt/string/i386/tcschr.inc b/reactos/lib/sdk/crt/string/i386/tcschr.inc new file mode 100644 index 00000000000..9554ac3cbcd --- /dev/null +++ b/reactos/lib/sdk/crt/string/i386/tcschr.inc @@ -0,0 +1,32 @@ +/* $Id: tcschr.inc 49591 2010-11-15 01:29:12Z tkreuzer $ + */ + +#include "tchar.h" +#include + +PUBLIC _tcschr +.code + +_tcschr: + push esi + mov esi, [esp + 8] + mov edx, [esp + 12] + cld + +.L1: + _tlods + cmp _treg(d), _treg(a) + je .L2 + test _treg(a), _treg(a) + jnz .L1 + mov esi, _tsize + +.L2: + mov eax, esi + _tdec(eax) + + pop esi + ret + +END +/* EOF */ diff --git a/reactos/lib/sdk/crt/string/i386/tcscmp.h b/reactos/lib/sdk/crt/string/i386/tcscmp.h deleted file mode 100644 index 6830a0ba0dc..00000000000 --- a/reactos/lib/sdk/crt/string/i386/tcscmp.h +++ /dev/null @@ -1,34 +0,0 @@ -/* $Id$ - */ - -#include "tchar.h" - -.globl _tcscmp - -_tcscmp: - push %esi - push %edi - mov 0x0C(%esp), %esi - mov 0x10(%esp), %edi - xor %eax, %eax - cld - -.L1: - _tlods - _tscas - jne .L2 - test %eax, %eax - jne .L1 - xor %eax, %eax - jmp .L3 - -.L2: - sbb %eax, %eax - or $1, %al - -.L3: - pop %edi - pop %esi - ret - -/* EOF */ diff --git a/reactos/lib/sdk/crt/string/i386/tcscmp.inc b/reactos/lib/sdk/crt/string/i386/tcscmp.inc new file mode 100644 index 00000000000..3bcf453e7b7 --- /dev/null +++ b/reactos/lib/sdk/crt/string/i386/tcscmp.inc @@ -0,0 +1,37 @@ +/* $Id: tcscmp.inc 49591 2010-11-15 01:29:12Z tkreuzer $ + */ + +#include "tchar.h" +#include + +PUBLIC _tcscmp +.code + +_tcscmp: + push esi + push edi + mov esi, [esp + 12] + mov edi, [esp + 16] + xor eax, eax + cld + +.L1: + _tlods + _tscas + jne .L2 + test eax, eax + jne .L1 + xor eax, eax + jmp .L3 + +.L2: + sbb eax, eax + or al, 1 + +.L3: + pop edi + pop esi + ret + +END +/* EOF */ diff --git a/reactos/lib/sdk/crt/string/i386/tcscpy.h b/reactos/lib/sdk/crt/string/i386/tcscpy.h deleted file mode 100644 index cb89a43a4a8..00000000000 --- a/reactos/lib/sdk/crt/string/i386/tcscpy.h +++ /dev/null @@ -1,27 +0,0 @@ -/* $Id$ - */ - -#include "tchar.h" - -.globl _tcscpy - -_tcscpy: - push %esi - push %edi - mov 0x0C(%esp), %edi - mov 0x10(%esp), %esi - cld - -.L1: - _tlods - _tstos - test %_treg(a), %_treg(a) - jnz .L1 - - mov 0x0C(%esp), %eax - - pop %edi - pop %esi - ret - -/* EOF */ diff --git a/reactos/lib/sdk/crt/string/i386/tcscpy.inc b/reactos/lib/sdk/crt/string/i386/tcscpy.inc new file mode 100644 index 00000000000..b16b4ccea32 --- /dev/null +++ b/reactos/lib/sdk/crt/string/i386/tcscpy.inc @@ -0,0 +1,30 @@ +/* $Id: tcscpy.inc 49591 2010-11-15 01:29:12Z tkreuzer $ + */ + +#include "tchar.h" +#include + +PUBLIC _tcscpy +.code + +_tcscpy: + push esi + push edi + mov edi, [esp + 12] + mov esi, [esp + 16] + cld + +.L1: + _tlods + _tstos + test _treg(a), _treg(a) + jnz .L1 + + mov eax, [esp + 12] + + pop edi + pop esi + ret + +END +/* EOF */ diff --git a/reactos/lib/sdk/crt/string/i386/tcslen.h b/reactos/lib/sdk/crt/string/i386/tcslen.h deleted file mode 100644 index 8c9586da70d..00000000000 --- a/reactos/lib/sdk/crt/string/i386/tcslen.h +++ /dev/null @@ -1,29 +0,0 @@ -/* $Id$ -*/ - -#include "tchar.h" - -.globl _tcslen - -_tcslen: - push %edi - mov 0x8(%esp), %edi - xor %eax, %eax - test %edi,%edi - jz _tcslen_end - - mov $-1, %ecx - cld - - repne _tscas - - not %ecx - dec %ecx - - mov %ecx, %eax - -_tcslen_end: - pop %edi - ret - -/* EOF */ diff --git a/reactos/lib/sdk/crt/string/i386/tcslen.inc b/reactos/lib/sdk/crt/string/i386/tcslen.inc new file mode 100644 index 00000000000..f749b9d88c4 --- /dev/null +++ b/reactos/lib/sdk/crt/string/i386/tcslen.inc @@ -0,0 +1,32 @@ +/* $Id: tcslen.inc 49591 2010-11-15 01:29:12Z tkreuzer $ +*/ + +#include "tchar.h" +#include + +PUBLIC _tcslen +.code + +_tcslen: + push edi + mov edi, [esp + 8] + xor eax, eax + test edi, edi + jz _tcslen_end + + mov ecx, -1 + cld + + repne _tscas + + not ecx + dec ecx + + mov eax, ecx + +_tcslen_end: + pop edi + ret + +END +/* EOF */ diff --git a/reactos/lib/sdk/crt/string/i386/tcsncat.h b/reactos/lib/sdk/crt/string/i386/tcsncat.h deleted file mode 100644 index f7a3b616396..00000000000 --- a/reactos/lib/sdk/crt/string/i386/tcsncat.h +++ /dev/null @@ -1,42 +0,0 @@ -/* $Id$ - */ - -#include "tchar.h" - -.globl _tcsncat - -_tcsncat: - push %esi - push %edi - mov 0x0C(%esp), %edi - mov 0x10(%esp), %esi - cld - - xor %eax, %eax - mov $-1, %ecx - repne _tscas - _tdec(%edi) - - mov 0x14(%esp),%ecx - -.L1: - dec %ecx - js .L2 - _tlods - _tstos - test %_treg(a), %_treg(a) - jne .L1 - jmp .L3 - -.L2: - xor %eax, %eax - _tstos - -.L3: - mov 0x0C(%esp), %eax - pop %edi - pop %esi - - ret - -/* EOF */ diff --git a/reactos/lib/sdk/crt/string/i386/tcsncat.inc b/reactos/lib/sdk/crt/string/i386/tcsncat.inc new file mode 100644 index 00000000000..b03bb87785f --- /dev/null +++ b/reactos/lib/sdk/crt/string/i386/tcsncat.inc @@ -0,0 +1,45 @@ +/* $Id: tcsncat.inc 49591 2010-11-15 01:29:12Z tkreuzer $ + */ + +#include "tchar.h" +#include + +PUBLIC _tcsncat +.code + +_tcsncat: + push esi + push edi + mov edi, [esp + 12] + mov esi, [esp + 16] + cld + + xor eax, eax + mov ecx, -1 + repne _tscas + _tdec(edi) + + mov ecx, [esp + 20] + +.L1: + dec ecx + js .L2 + _tlods + _tstos + test _treg(a), _treg(a) + jne .L1 + jmp .L3 + +.L2: + xor eax, eax + _tstos + +.L3: + mov eax, [esp + 12] + pop edi + pop esi + + ret + +END +/* EOF */ diff --git a/reactos/lib/sdk/crt/string/i386/tcsncmp.h b/reactos/lib/sdk/crt/string/i386/tcsncmp.h deleted file mode 100644 index 58a30859e73..00000000000 --- a/reactos/lib/sdk/crt/string/i386/tcsncmp.h +++ /dev/null @@ -1,40 +0,0 @@ -/* $Id$ - */ - -#include "tchar.h" - -.globl _tcsncmp - -_tcsncmp: - push %esi - push %edi - mov 0x0C(%esp), %esi /* s1 */ - mov 0x10(%esp), %edi /* s2 */ - mov 0x14(%esp), %ecx /* n */ - - xor %eax,%eax - cld - -.L1: - dec %ecx - js .L2 - _tlods - _tscas - jne .L3 - test %eax, %eax - jne .L1 - -.L2: - xor %eax, %eax - jmp .L4 - -.L3: - sbb %eax, %eax - or $1, %al - -.L4: - pop %edi - pop %esi - ret - -/* EOF */ diff --git a/reactos/lib/sdk/crt/string/i386/tcsncmp.inc b/reactos/lib/sdk/crt/string/i386/tcsncmp.inc new file mode 100644 index 00000000000..9545e583bec --- /dev/null +++ b/reactos/lib/sdk/crt/string/i386/tcsncmp.inc @@ -0,0 +1,43 @@ +/* $Id: tcsncmp.inc 49591 2010-11-15 01:29:12Z tkreuzer $ + */ + +#include "tchar.h" +#include + +PUBLIC _tcsncmp +.code + +_tcsncmp: + push esi + push edi + mov esi, [esp + 12] /* s1 */ + mov edi, [esp + 16] /* s2 */ + mov ecx, [esp + 20] /* n */ + + xor eax, eax + cld + +.L1: + dec ecx + js .L2 + _tlods + _tscas + jne .L3 + test eax, eax + jne .L1 + +.L2: + xor eax, eax + jmp .L4 + +.L3: + sbb eax, eax + or al, 1 + +.L4: + pop edi + pop esi + ret + +END +/* EOF */ diff --git a/reactos/lib/sdk/crt/string/i386/tcsncpy.h b/reactos/lib/sdk/crt/string/i386/tcsncpy.h deleted file mode 100644 index ed15334d036..00000000000 --- a/reactos/lib/sdk/crt/string/i386/tcsncpy.h +++ /dev/null @@ -1,34 +0,0 @@ -/* $Id$ - */ - -#include "tchar.h" - -.globl _tcsncpy - -_tcsncpy: - push %esi - push %edi - mov 0x0C(%esp), %edi /* s1 */ - mov 0x10(%esp), %esi /* s2 */ - mov 0x14(%esp), %ecx /* n */ - - xor %eax, %eax - cld - -.L1: - dec %ecx - js .L2 - _tlods - _tstos - test %_treg(a), %_treg(a) - jnz .L1 - rep _tstos - -.L2: - mov 0x0C(%esp), %eax - - pop %edi - pop %esi - ret - -/* EOF */ diff --git a/reactos/lib/sdk/crt/string/i386/tcsncpy.inc b/reactos/lib/sdk/crt/string/i386/tcsncpy.inc new file mode 100644 index 00000000000..248c5ce9a20 --- /dev/null +++ b/reactos/lib/sdk/crt/string/i386/tcsncpy.inc @@ -0,0 +1,37 @@ +/* $Id: tcsncpy.inc 49591 2010-11-15 01:29:12Z tkreuzer $ + */ + +#include "tchar.h" +#include + +PUBLIC _tcsncpy +.code + +_tcsncpy: + push esi + push edi + mov edi, [esp + 12] /* s1 */ + mov esi, [esp + 16] /* s2 */ + mov ecx, [esp + 20] /* n */ + + xor eax, eax + cld + +.L1: + dec ecx + js .L2 + _tlods + _tstos + test _treg(a), _treg(a) + jnz .L1 + rep _tstos + +.L2: + mov eax, [esp + 12] + + pop edi + pop esi + ret + +END +/* EOF */ diff --git a/reactos/lib/sdk/crt/string/i386/tcsnlen.h b/reactos/lib/sdk/crt/string/i386/tcsnlen.h deleted file mode 100644 index 90a4ec6c88c..00000000000 --- a/reactos/lib/sdk/crt/string/i386/tcsnlen.h +++ /dev/null @@ -1,30 +0,0 @@ -/* $Id$ -*/ - -#include "tchar.h" - -.globl _tcsnlen - -_tcsnlen: - push %edi - mov 0x8(%esp), %edi - mov 0xC(%esp), %ecx - xor %eax, %eax - test %ecx, %ecx - jz .L1 - mov %ecx, %edx - - cld - - repne _tscas - - sete %al - sub %ecx, %edx - sub %eax, %edx - mov %edx, %eax - -.L1: - pop %edi - ret - -/* EOF */ diff --git a/reactos/lib/sdk/crt/string/i386/tcsnlen.inc b/reactos/lib/sdk/crt/string/i386/tcsnlen.inc new file mode 100644 index 00000000000..fc72607adb2 --- /dev/null +++ b/reactos/lib/sdk/crt/string/i386/tcsnlen.inc @@ -0,0 +1,33 @@ +/* $Id: tcsnlen.inc 49591 2010-11-15 01:29:12Z tkreuzer $ +*/ + +#include "tchar.h" +#include + +PUBLIC _tcsnlen +.code + +_tcsnlen: + push edi + mov edi, [esp + 8] + mov ecx, [esp + 12] + xor eax, eax + test ecx, ecx + jz .L1 + mov edx, ecx + + cld + + repne _tscas + + sete al + sub edx, ecx + sub edx, eax + mov eax, edx + +.L1: + pop edi + ret + +END +/* EOF */ diff --git a/reactos/lib/sdk/crt/string/i386/tcsrchr.h b/reactos/lib/sdk/crt/string/i386/tcsrchr.h deleted file mode 100644 index 61d3a4dd863..00000000000 --- a/reactos/lib/sdk/crt/string/i386/tcsrchr.h +++ /dev/null @@ -1,31 +0,0 @@ -/* $Id$ - */ - -#include "tchar.h" - -.globl _tcsrchr - -_tcsrchr: - push %esi - mov 0x8(%esp), %esi - mov 0xC(%esp), %edx - - cld - mov _tsize, %ecx - -.L1: - _tlods - cmp %_treg(a), %_treg(d) - jne .L2 - mov %esi, %ecx - -.L2: - test %_treg(a), %_treg(a) - jnz .L1 - - mov %ecx, %eax - _tdec(%eax) - pop %esi - ret - -/* EOF */ diff --git a/reactos/lib/sdk/crt/string/i386/tcsrchr.inc b/reactos/lib/sdk/crt/string/i386/tcsrchr.inc new file mode 100644 index 00000000000..9527853122a --- /dev/null +++ b/reactos/lib/sdk/crt/string/i386/tcsrchr.inc @@ -0,0 +1,34 @@ +/* $Id: tcsrchr.inc 49591 2010-11-15 01:29:12Z tkreuzer $ + */ + +#include "tchar.h" +#include + +PUBLIC _tcsrchr +.code + +_tcsrchr: + push esi + mov esi, [esp + 8] + mov edx, [esp + 12] + + cld + mov ecx, _tsize + +.L1: + _tlods + cmp _treg(d), _treg(a) + jne .L2 + mov ecx, esi + +.L2: + test _treg(a), _treg(a) + jnz .L1 + + mov eax, ecx + _tdec(eax) + pop esi + ret + +END +/* EOF */ diff --git a/reactos/lib/sdk/crt/string/i386/wcscat_asm.s b/reactos/lib/sdk/crt/string/i386/wcscat_asm.s index 56beb026aa3..b833d0ddab3 100644 --- a/reactos/lib/sdk/crt/string/i386/wcscat_asm.s +++ b/reactos/lib/sdk/crt/string/i386/wcscat_asm.s @@ -2,6 +2,6 @@ */ #define _UNICODE -#include "tcscat.h" +#include "tcscat.inc" /* EOF */ diff --git a/reactos/lib/sdk/crt/string/i386/wcschr_asm.s b/reactos/lib/sdk/crt/string/i386/wcschr_asm.s index a493a48d237..8fc6c360baf 100644 --- a/reactos/lib/sdk/crt/string/i386/wcschr_asm.s +++ b/reactos/lib/sdk/crt/string/i386/wcschr_asm.s @@ -2,6 +2,6 @@ */ #define _UNICODE -#include "tcschr.h" +#include "tcschr.inc" /* EOF */ diff --git a/reactos/lib/sdk/crt/string/i386/wcscmp_asm.s b/reactos/lib/sdk/crt/string/i386/wcscmp_asm.s index 2377a026b78..b4f5425beba 100644 --- a/reactos/lib/sdk/crt/string/i386/wcscmp_asm.s +++ b/reactos/lib/sdk/crt/string/i386/wcscmp_asm.s @@ -2,6 +2,6 @@ */ #define _UNICODE -#include "tcscmp.h" +#include "tcscmp.inc" /* EOF */ diff --git a/reactos/lib/sdk/crt/string/i386/wcscpy_asm.s b/reactos/lib/sdk/crt/string/i386/wcscpy_asm.s index 7e76864972d..78b6fe2a6d2 100644 --- a/reactos/lib/sdk/crt/string/i386/wcscpy_asm.s +++ b/reactos/lib/sdk/crt/string/i386/wcscpy_asm.s @@ -2,6 +2,6 @@ */ #define _UNICODE -#include "tcscpy.h" +#include "tcscpy.inc" /* EOF */ diff --git a/reactos/lib/sdk/crt/string/i386/wcslen_asm.s b/reactos/lib/sdk/crt/string/i386/wcslen_asm.s index f70390048ad..5d4bfe054aa 100644 --- a/reactos/lib/sdk/crt/string/i386/wcslen_asm.s +++ b/reactos/lib/sdk/crt/string/i386/wcslen_asm.s @@ -2,6 +2,6 @@ */ #define _UNICODE -#include "tcslen.h" +#include "tcslen.inc" /* EOF */ diff --git a/reactos/lib/sdk/crt/string/i386/wcsncat_asm.s b/reactos/lib/sdk/crt/string/i386/wcsncat_asm.s index 36e2cf15dc6..d28bbc3e3a4 100644 --- a/reactos/lib/sdk/crt/string/i386/wcsncat_asm.s +++ b/reactos/lib/sdk/crt/string/i386/wcsncat_asm.s @@ -2,6 +2,6 @@ */ #define _UNICODE -#include "tcsncat.h" +#include "tcsncat.inc" /* EOF */ diff --git a/reactos/lib/sdk/crt/string/i386/wcsncmp_asm.s b/reactos/lib/sdk/crt/string/i386/wcsncmp_asm.s index 594e2c49340..5ae53efa7c9 100644 --- a/reactos/lib/sdk/crt/string/i386/wcsncmp_asm.s +++ b/reactos/lib/sdk/crt/string/i386/wcsncmp_asm.s @@ -2,6 +2,6 @@ */ #define _UNICODE -#include "tcsncmp.h" +#include "tcsncmp.inc" /* EOF */ diff --git a/reactos/lib/sdk/crt/string/i386/wcsncpy_asm.s b/reactos/lib/sdk/crt/string/i386/wcsncpy_asm.s index 601e70cdafe..b4591cfdb10 100644 --- a/reactos/lib/sdk/crt/string/i386/wcsncpy_asm.s +++ b/reactos/lib/sdk/crt/string/i386/wcsncpy_asm.s @@ -2,6 +2,6 @@ */ #define _UNICODE -#include "tcsncpy.h" +#include "tcsncpy.inc" /* EOF */ diff --git a/reactos/lib/sdk/crt/string/i386/wcsnlen_asm.s b/reactos/lib/sdk/crt/string/i386/wcsnlen_asm.s index 65bd605231c..39349927757 100644 --- a/reactos/lib/sdk/crt/string/i386/wcsnlen_asm.s +++ b/reactos/lib/sdk/crt/string/i386/wcsnlen_asm.s @@ -2,6 +2,6 @@ */ #define _UNICODE -#include "tcsnlen.h" +#include "tcsnlen.inc" /* EOF */ diff --git a/reactos/lib/sdk/crt/string/i386/wcsrchr_asm.s b/reactos/lib/sdk/crt/string/i386/wcsrchr_asm.s index 872403a8956..a845ee53203 100644 --- a/reactos/lib/sdk/crt/string/i386/wcsrchr_asm.s +++ b/reactos/lib/sdk/crt/string/i386/wcsrchr_asm.s @@ -2,6 +2,6 @@ */ #define _UNICODE -#include "tcsrchr.h" +#include "tcsrchr.inc" /* EOF */ diff --git a/reactos/ntoskrnl/ex/i386/fastinterlck_asm.S b/reactos/ntoskrnl/ex/i386/fastinterlck_asm.S index f09edfd3b9c..566f37f5a0c 100644 --- a/reactos/ntoskrnl/ex/i386/fastinterlck_asm.S +++ b/reactos/ntoskrnl/ex/i386/fastinterlck_asm.S @@ -8,14 +8,13 @@ /* INCLUDES ******************************************************************/ -#include -#include +#include +#include #include /* FUNCTIONS ****************************************************************/ .code32 -.text /* * NOTE: These functions must obey the following rules: @@ -30,7 +29,7 @@ *ExInterlockedAddLargeStatistic(IN PLARGE_INTEGER Addend, * IN ULONG Increment) */ -.global @ExInterlockedAddLargeStatistic@8 +PUBLIC @ExInterlockedAddLargeStatistic@8 @ExInterlockedAddLargeStatistic@8: #ifdef CONFIG_SMP @@ -38,10 +37,10 @@ lock add [ecx], edx /* Check for carry bit and return */ - jb 1f + jb .l1 ret -1: +.l1: /* Add carry */ lock adc dword ptr [ecx+4], 0 #else @@ -58,7 +57,7 @@ * IN ULONG Increment, * IN PKSPIN_LOCK Lock) */ -.global @ExfInterlockedAddUlong@12 +PUBLIC @ExfInterlockedAddUlong@12 @ExfInterlockedAddUlong@12: /* Save flags */ @@ -103,7 +102,7 @@ * IN PLIST_ENTRY ListEntry, * IN PKSPIN_LOCK Lock) */ -.global @ExfInterlockedInsertHeadList@12 +PUBLIC @ExfInterlockedInsertHeadList@12 @ExfInterlockedInsertHeadList@12: #ifdef CONFIG_SMP @@ -139,11 +138,11 @@ /* Check if list was empty */ xor eax, ecx - jz 2f + jz .l2 /* Return list pointer */ xor eax, ecx -2: +.l2: ret 4 #ifdef CONFIG_SMP @@ -159,7 +158,7 @@ * IN PLIST_ENTRY ListEntry, * IN PKSPIN_LOCK Lock) */ -.global @ExfInterlockedInsertTailList@12 +PUBLIC @ExfInterlockedInsertTailList@12 @ExfInterlockedInsertTailList@12: #ifdef CONFIG_SMP @@ -195,11 +194,11 @@ /* Check if list was empty */ xor eax, ecx - jz 2f + jz .l3 /* Return list pointer */ xor eax, ecx -2: +.l3: ret 4 #ifdef CONFIG_SMP @@ -214,7 +213,7 @@ *ExfInterlockedRemoveHeadList(IN PLIST_ENTRY ListHead, * IN PKSPIN_LOCK Lock) */ -.global @ExfInterlockedRemoveHeadList@8 +PUBLIC @ExfInterlockedRemoveHeadList@8 @ExfInterlockedRemoveHeadList@8: /* Save flags and disable interrupts */ @@ -228,7 +227,7 @@ /* Check if it's empty */ cmp eax, ecx - je 2f + je .l4 /* Get the next entry and do the deletion */ #ifdef CONFIG_SMP @@ -254,7 +253,7 @@ /* Return */ ret -2: +.l4: /* Release lock */ RELEASE_SPINLOCK(edx) @@ -276,7 +275,7 @@ *ExfInterlockedPopEntryList(IN PSINGLE_LIST_ENTRY ListHead, * IN PKSPIN_LOCK Lock) */ -.global @ExfInterlockedPopEntryList@8 +PUBLIC @ExfInterlockedPopEntryList@8 @ExfInterlockedPopEntryList@8: /* Save flags and disable interrupts */ @@ -290,7 +289,7 @@ /* Check if it's empty */ or eax, eax - je 3f + je .l6 /* Get next entry and do deletion */ #ifdef CONFIG_SMP @@ -302,7 +301,7 @@ pop edx #endif -2: +.l5: /* Release lock */ RELEASE_SPINLOCK(edx) @@ -312,10 +311,10 @@ /* Return */ ret -3: +.l6: /* Return empty list */ xor eax, eax - jmp 2b + jmp .l5 #ifdef CONFIG_SMP .spin5: @@ -329,7 +328,7 @@ * IN PSINGLE_LIST_ENTRY ListEntry, * IN PKSPIN_LOCK Lock) */ -.global @ExfInterlockedPushEntryList@12 +PUBLIC @ExfInterlockedPushEntryList@12 @ExfInterlockedPushEntryList@12: /* Save flags */ @@ -383,11 +382,11 @@ *ExInterlockedPopEntrySList(IN PSINGLE_LIST_ENTRY ListHead, * IN PKSPIN_LOCK Lock) */ -.global @ExInterlockedPopEntrySList@8 -.global @InterlockedPopEntrySList@4 -.global _ExpInterlockedPopEntrySListResume@0 -.global _ExpInterlockedPopEntrySListFault@0 -.global _ExpInterlockedPopEntrySListEnd@0 +PUBLIC @ExInterlockedPopEntrySList@8 +PUBLIC @InterlockedPopEntrySList@4 +PUBLIC _ExpInterlockedPopEntrySListResume@0 +PUBLIC _ExpInterlockedPopEntrySListFault@0 +PUBLIC _ExpInterlockedPopEntrySListEnd@0 @ExInterlockedPopEntrySList@8: @InterlockedPopEntrySList@4: @@ -405,7 +404,7 @@ _ExpInterlockedPopEntrySListResume@0: /* Check if the list is empty */ or eax, eax - jz 2f + jz .l7 /* Copy sequence number and adjust it */ lea ecx, [edx-1] @@ -418,7 +417,7 @@ _ExpInterlockedPopEntrySListEnd@0: jnz _ExpInterlockedPopEntrySListResume@0 /* Restore registers and return */ -2: +.l7: pop ebp pop ebx ret @@ -429,13 +428,13 @@ _ExpInterlockedPopEntrySListEnd@0: * IN PSINGLE_LIST_ENTRY ListEntry, * IN PKSPIN_LOCK Lock) */ -.global @ExInterlockedPushEntrySList@12 +PUBLIC @ExInterlockedPushEntrySList@12 @ExInterlockedPushEntrySList@12: /* So we can fall through below */ pop [esp] -.global @InterlockedPushEntrySList@8 +PUBLIC @InterlockedPushEntrySList@8 @InterlockedPushEntrySList@8: /* Save registers */ @@ -450,19 +449,18 @@ _ExpInterlockedPopEntrySListEnd@0: mov edx, [ebp+4] mov eax, [ebp] -1: +.l8: /* Set link pointer */ mov [ebx], eax /* Copy sequence number and adjust it */ - lea ecx, [edx+0x10001] + lea ecx, [edx + HEX(10001)] /* Do the exchange */ LOCK cmpxchg8b qword ptr [ebp] - jnz 1b + jnz .l8 /* Restore registers and return */ -2: pop ebp pop ebx ret @@ -471,7 +469,7 @@ _ExpInterlockedPopEntrySListEnd@0: *FASTCALL *ExInterlockedFlushSList(IN PSINGLE_LIST_ENTRY ListHead) */ -.global @ExInterlockedFlushSList@4 +PUBLIC @ExInterlockedFlushSList@4 @ExInterlockedFlushSList@4: /* Save registers */ @@ -488,10 +486,10 @@ _ExpInterlockedPopEntrySListEnd@0: mov edx, [ebp+4] mov eax, [ebp] -1: +.l9: /* Check if the list is empty */ or eax, eax - jz 2f + jz .l10 /* Clear sequence and pointer */ mov ecx, edx @@ -499,10 +497,10 @@ _ExpInterlockedPopEntrySListEnd@0: /* Do the exchange */ LOCK cmpxchg8b qword ptr [ebp] - jnz 1b + jnz .l9 /* Restore registers and return */ -2: +.l10: pop ebp pop ebx ret @@ -511,7 +509,7 @@ _ExpInterlockedPopEntrySListEnd@0: *FASTCALL *Exfi386InterlockedIncrementLong(IN PLONG Addend) */ -.global @Exfi386InterlockedIncrementLong@4 +PUBLIC @Exfi386InterlockedIncrementLong@4 @Exfi386InterlockedIncrementLong@4: /* Do the op */ @@ -526,7 +524,7 @@ _ExpInterlockedPopEntrySListEnd@0: *FASTCALL *Exfi386InterlockedDecrementLong(IN PLONG Addend) */ -.global @Exfi386InterlockedDecrementLong@4 +PUBLIC @Exfi386InterlockedDecrementLong@4 @Exfi386InterlockedDecrementLong@4: /* Do the op */ @@ -542,7 +540,7 @@ _ExpInterlockedPopEntrySListEnd@0: *Exfi386InterlockedExchangeUlong(IN PULONG Taget, * IN ULONG Value) */ -.global @Exfi386InterlockedExchangeUlong@8 +PUBLIC @Exfi386InterlockedExchangeUlong@8 @Exfi386InterlockedExchangeUlong@8: #ifdef CONFIG_SMP @@ -552,9 +550,9 @@ _ExpInterlockedPopEntrySListEnd@0: #else /* On UP, use cmpxchg */ mov eax, [ecx] -1: +.l11: cmpxchg [ecx], edx - jnz 1b + jnz .l11 #endif /* Return */ @@ -566,7 +564,7 @@ _ExpInterlockedPopEntrySListEnd@0: * IN PLONGLONG Exchange, * IN PLONGLONG Comperand) */ -.global @ExfInterlockedCompareExchange64@12 +PUBLIC @ExfInterlockedCompareExchange64@12 @ExfInterlockedCompareExchange64@12: /* Save registers */ @@ -598,7 +596,7 @@ _ExpInterlockedPopEntrySListEnd@0: * IN PLONGLONG Comperand, * IN PKSPIN_LOCK Lock) */ -.global @ExInterlockedCompareExchange64@16 +PUBLIC @ExInterlockedCompareExchange64@16 @ExInterlockedCompareExchange64@16: /* Save registers */ @@ -630,7 +628,7 @@ _ExpInterlockedPopEntrySListEnd@0: *ExfInterlockedPopEntrySList(IN PSINGLE_LIST_ENTRY ListHead, * IN PKSPIN_LOCK Lock) */ -.global @ExfInterlockedPopEntrySList@8 +PUBLIC @ExfInterlockedPopEntrySList@8 @ExfInterlockedPopEntrySList@8: /* Save flags */ @@ -646,7 +644,7 @@ _ExpInterlockedPopEntrySListEnd@0: /* Get the next link and check if it's empty */ mov eax, [ecx] or eax, eax - jz 1f + jz .l12 /* Get address of the next link and store it */ push [eax] @@ -655,7 +653,7 @@ _ExpInterlockedPopEntrySListEnd@0: /* Decrement list depth */ dec dword ptr [ecx+4] -1: +.l12: #ifdef CONFIG_SMP /* Release spinlock */ RELEASE_SPINLOCK(edx) @@ -678,7 +676,7 @@ _ExpInterlockedPopEntrySListEnd@0: * IN PSINGLE_LIST_ENTRY ListEntry, * IN PKSPIN_LOCK Lock) */ -.global @ExfInterlockedPushEntrySList@12 +PUBLIC @ExfInterlockedPushEntrySList@12 @ExfInterlockedPushEntrySList@12: /* Save flags */ @@ -727,7 +725,7 @@ _ExpInterlockedPopEntrySListEnd@0: * IN PLONGLONG Comperand, * IN PKSPIN_LOCK Lock) */ -.global @ExpInterlockedCompareExchange64@16 +PUBLIC @ExpInterlockedCompareExchange64@16 @ExpInterlockedCompareExchange64@16: /* Save registers */ @@ -802,4 +800,6 @@ NoMatch: pushfd SPIN_ON_LOCK(esi, .startc) #endif + +END /* EOF */ diff --git a/reactos/ntoskrnl/ex/i386/interlck_asm.S b/reactos/ntoskrnl/ex/i386/interlck_asm.S index 954091cee85..755813e80d8 100644 --- a/reactos/ntoskrnl/ex/i386/interlck_asm.S +++ b/reactos/ntoskrnl/ex/i386/interlck_asm.S @@ -8,14 +8,13 @@ /* INCLUDES ******************************************************************/ -#include -#include +#include +#include #include /* FUNCTIONS ****************************************************************/ .code32 -.text /* * NOTE: These functions must obey the following rules: @@ -31,7 +30,7 @@ * IN PLIST_ENTRY ListEntry, * IN PKSPIN_LOCK Lock) */ -.global _ExInterlockedAddLargeInteger@16 +PUBLIC _ExInterlockedAddLargeInteger@16 _ExInterlockedAddLargeInteger@16: /* Prepare stack frame */ @@ -97,7 +96,7 @@ _ExInterlockedAddLargeInteger@16: * IN PLIST_ENTRY ListEntry, * IN PKSPIN_LOCK Lock) */ -.global _ExInterlockedAddUlong@12 +PUBLIC _ExInterlockedAddUlong@12 _ExInterlockedAddUlong@12: /* Save flags and disable interrupts */ @@ -153,7 +152,7 @@ _ExInterlockedAddUlong@12: * IN PLIST_ENTRY ListEntry, * IN PKSPIN_LOCK Lock) */ -.global _ExInterlockedInsertHeadList@12 +PUBLIC _ExInterlockedInsertHeadList@12 _ExInterlockedInsertHeadList@12: /* Save lock pointer */ @@ -189,12 +188,12 @@ _ExInterlockedInsertHeadList@12: /* check if the list was empty and return NULL */ xor eax, edx - jz 2f + jz .l2 /* Return pointer */ mov eax, edx -2: +.l2: ret 12 #ifdef CONFIG_SMP @@ -209,7 +208,7 @@ _ExInterlockedInsertHeadList@12: * IN PLIST_ENTRY ListEntry, * IN PKSPIN_LOCK Lock) */ -.global _ExInterlockedInsertTailList@12 +PUBLIC _ExInterlockedInsertTailList@12 _ExInterlockedInsertTailList@12: /* Save lock pointer */ @@ -245,12 +244,12 @@ _ExInterlockedInsertTailList@12: /* Check if the list was empty and return NULL */ xor eax, edx - jz 2f + jz .l3 /* Return pointer */ mov eax, edx -2: +.l3: ret 12 #ifdef CONFIG_SMP @@ -264,7 +263,7 @@ _ExInterlockedInsertTailList@12: *ExInterlockedRemoveHeadList(IN PLIST_ENTRY ListHead, * IN PKSPIN_LOCK Lock) */ -.global _ExInterlockedRemoveHeadList@8 +PUBLIC _ExInterlockedRemoveHeadList@8 _ExInterlockedRemoveHeadList@8: /* Save lock pointer */ @@ -284,7 +283,7 @@ _ExInterlockedRemoveHeadList@8: /* Check if it's empty */ cmp eax, edx - je 2f + je .l4 /* Get next entry and do deletion */ mov ecx, [eax] @@ -303,7 +302,7 @@ _ExInterlockedRemoveHeadList@8: /* Return */ ret 8 -2: +.l4: /* Release lock */ #ifdef CONFIG_SMP mov edx, [esp+12] @@ -328,7 +327,7 @@ _ExInterlockedRemoveHeadList@8: *ExInterlockedPopEntryList(IN PSINGLE_LIST_ENTRY ListHead, * IN PKSPIN_LOCK Lock) */ -.global _ExInterlockedPopEntryList@8 +PUBLIC _ExInterlockedPopEntryList@8 _ExInterlockedPopEntryList@8: /* Save lock pointer */ @@ -348,13 +347,13 @@ _ExInterlockedPopEntryList@8: /* Check if it's empty */ or eax, eax - je 3f + je .l6 /* Get next entry and do deletion */ mov edx, [eax] mov [ecx], edx -2: +.l5: /* Release lock */ #ifdef CONFIG_SMP mov ecx, [esp+12] @@ -367,10 +366,10 @@ _ExInterlockedPopEntryList@8: /* Return */ ret 8 -3: +.l6: /* Return empty list */ xor eax, eax - jmp 2b + jmp .l5 #ifdef CONFIG_SMP .spin6: @@ -384,7 +383,7 @@ _ExInterlockedPopEntryList@8: * IN PSINGLE_LIST_ENTRY ListEntry, * IN PKSPIN_LOCK Lock) */ -.global _ExInterlockedPushEntryList@12 +PUBLIC _ExInterlockedPushEntryList@12 _ExInterlockedPushEntryList@12: /* Save lock pointer */ @@ -430,7 +429,7 @@ _ExInterlockedPushEntryList@12: *ExInterlockedIncrementLong(IN PLONG Addend, * IN PKSPIN_LOCK Lock) */ -.global _ExInterlockedIncrementLong@8 +PUBLIC _ExInterlockedIncrementLong@8 _ExInterlockedIncrementLong@8: /* Get addend */ @@ -449,7 +448,7 @@ _ExInterlockedIncrementLong@8: *ExInterlockedDecrementLong(IN PLONG Addend, * IN PKSPIN_LOCK Lock) */ -.global _ExInterlockedDecrementLong@8 +PUBLIC _ExInterlockedDecrementLong@8 _ExInterlockedDecrementLong@8: /* Get addend */ @@ -469,7 +468,7 @@ _ExInterlockedDecrementLong@8: * IN ULONG Value, * IN PKSPIN_LOCK Lock) */ -.global _ExInterlockedExchangeUlong@12 +PUBLIC _ExInterlockedExchangeUlong@12 _ExInterlockedExchangeUlong@12: /* Get pointers */ @@ -498,7 +497,7 @@ _ExInterlockedExchangeUlong@12: *Exi386InterlockedIncrementLong(IN PLONG Addend, * IN PKSPIN_LOCK Lock) */ -.global _Exi386InterlockedIncrementLong@4 +PUBLIC _Exi386InterlockedIncrementLong@4 _Exi386InterlockedIncrementLong@4: /* Get addend */ @@ -517,7 +516,7 @@ _Exi386InterlockedIncrementLong@4: *Exi386InterlockedDecrementLong(IN PLONG Addend, * IN PKSPIN_LOCK Lock) */ -.global _Exi386InterlockedDecrementLong@4 +PUBLIC _Exi386InterlockedDecrementLong@4 _Exi386InterlockedDecrementLong@4: /* Get addend */ @@ -537,7 +536,7 @@ _Exi386InterlockedDecrementLong@4: * IN ULONG Value, * IN PKSPIN_LOCK Lock) */ -.global _Exi386InterlockedExchangeUlong@12 +PUBLIC _Exi386InterlockedExchangeUlong@12 _Exi386InterlockedExchangeUlong@12: /* Get pointers */ @@ -560,5 +559,6 @@ _Exi386InterlockedExchangeUlong@12: /* Return */ ret 8 - + +END /* EOF */ diff --git a/reactos/ntoskrnl/ex/i386/ioport.S b/reactos/ntoskrnl/ex/i386/ioport.S index c9c55a160f4..ba456c799f8 100644 --- a/reactos/ntoskrnl/ex/i386/ioport.S +++ b/reactos/ntoskrnl/ex/i386/ioport.S @@ -8,54 +8,52 @@ /* INCLUDES ******************************************************************/ -#include -.intel_syntax noprefix +#include +#include /* GLOBALS *******************************************************************/ -.globl _READ_REGISTER_UCHAR@4 -.globl _READ_REGISTER_USHORT@4 -.globl _READ_REGISTER_ULONG@4 -.globl _READ_REGISTER_BUFFER_UCHAR@12 -.globl _READ_REGISTER_BUFFER_USHORT@12 -.globl _READ_REGISTER_BUFFER_ULONG@12 -.globl _WRITE_REGISTER_UCHAR@8 -.globl _WRITE_REGISTER_USHORT@8 -.globl _WRITE_REGISTER_ULONG@8 -.globl _WRITE_REGISTER_BUFFER_UCHAR@12 -.globl _WRITE_REGISTER_BUFFER_USHORT@12 -.globl _WRITE_REGISTER_BUFFER_ULONG@12 +PUBLIC _READ_REGISTER_UCHAR@4 +PUBLIC _READ_REGISTER_USHORT@4 +PUBLIC _READ_REGISTER_ULONG@4 +PUBLIC _READ_REGISTER_BUFFER_UCHAR@12 +PUBLIC _READ_REGISTER_BUFFER_USHORT@12 +PUBLIC _READ_REGISTER_BUFFER_ULONG@12 +PUBLIC _WRITE_REGISTER_UCHAR@8 +PUBLIC _WRITE_REGISTER_USHORT@8 +PUBLIC _WRITE_REGISTER_ULONG@8 +PUBLIC _WRITE_REGISTER_BUFFER_UCHAR@12 +PUBLIC _WRITE_REGISTER_BUFFER_USHORT@12 +PUBLIC _WRITE_REGISTER_BUFFER_ULONG@12 /* FUNCTIONS *****************************************************************/ -.func READ_REGISTER_UCHAR@4 +.code + _READ_REGISTER_UCHAR@4: /* Return the requested memory location */ mov edx, [esp+4] mov al, [edx] ret 4 -.endfunc -.func READ_REGISTER_USHORT@4 + _READ_REGISTER_USHORT@4: /* Return the requested memory location */ mov edx, [esp+4] mov ax, [edx] ret 4 -.endfunc -.func READ_REGISTER_ULONG@4 + _READ_REGISTER_ULONG@4: /* Return the requested memory location */ mov edx, [esp+4] mov eax, [edx] ret 4 -.endfunc -.func READ_REGISTER_BUFFER_UCHAR@12 + _READ_REGISTER_BUFFER_UCHAR@12: /* Save volatiles */ @@ -72,9 +70,8 @@ _READ_REGISTER_BUFFER_UCHAR@12: mov edi, edx mov esi, eax ret 12 -.endfunc -.func READ_REGISTER_BUFFER_USHORT@12 + _READ_REGISTER_BUFFER_USHORT@12: /* Save volatiles */ @@ -91,9 +88,8 @@ _READ_REGISTER_BUFFER_USHORT@12: mov edi, edx mov esi, eax ret 12 -.endfunc -.func READ_REGISTER_BUFFER_ULONG@12 + _READ_REGISTER_BUFFER_ULONG@12: /* Save volatiles */ @@ -110,9 +106,8 @@ _READ_REGISTER_BUFFER_ULONG@12: mov edi, edx mov esi, eax ret 12 -.endfunc -.func WRITE_REGISTER_UCHAR@8 + _WRITE_REGISTER_UCHAR@8: /* Write to memory */ @@ -123,9 +118,8 @@ _WRITE_REGISTER_UCHAR@8: /* Flush posted write buffers and return */ lock or [esp+4], edx ret 8 -.endfunc -.func WRITE_REGISTER_USHORT@8 + _WRITE_REGISTER_USHORT@8: /* Write to memory */ @@ -136,9 +130,8 @@ _WRITE_REGISTER_USHORT@8: /* Flush posted write buffers and return */ lock or [esp+4], edx ret 8 -.endfunc -.func WRITE_REGISTER_ULONG@8 + _WRITE_REGISTER_ULONG@8: /* Write to memory */ @@ -149,9 +142,8 @@ _WRITE_REGISTER_ULONG@8: /* Flush posted write buffers and return */ lock or [esp+4], edx ret 8 -.endfunc -.func WRITE_REGISTER_BUFFER_UCHAR@12 + _WRITE_REGISTER_BUFFER_UCHAR@12: /* Save volatiles */ @@ -171,9 +163,8 @@ _WRITE_REGISTER_BUFFER_UCHAR@12: mov edi, edx mov esi, eax ret 12 -.endfunc -.func WRITE_REGISTER_BUFFER_USHORT@12 + _WRITE_REGISTER_BUFFER_USHORT@12: /* Save volatiles */ @@ -193,9 +184,8 @@ _WRITE_REGISTER_BUFFER_USHORT@12: mov edi, edx mov esi, eax ret 12 -.endfunc -.func WRITE_REGISTER_BUFFER_ULONG@12 + _WRITE_REGISTER_BUFFER_ULONG@12: /* Save volatiles */ @@ -215,6 +205,6 @@ _WRITE_REGISTER_BUFFER_ULONG@12: mov edi, edx mov esi, eax ret 12 -.endfunc +END /* EOF */ diff --git a/reactos/ntoskrnl/include/internal/i386/asmmacro.S b/reactos/ntoskrnl/include/internal/i386/asmmacro.S index 6ddb9d015ad..2a64a938320 100644 --- a/reactos/ntoskrnl/include/internal/i386/asmmacro.S +++ b/reactos/ntoskrnl/include/internal/i386/asmmacro.S @@ -60,8 +60,8 @@ // @remark None. // MACRO(idt, Handler, Bits) - .long \Handler - .short \Bits + .long VAL(Handler) + .short VAL(Bits) .short KGDT_R0_CODE ENDM @@ -128,17 +128,17 @@ MACRO(KiEnterTrap, Flags) mov [esp + KTRAP_FRAME_EAX], eax /* Does the caller want nonvolatiles only? */ - if ((Flags AND KI_NONVOLATILES_ONLY) == 0) + if (NOT (Flags AND KI_NONVOLATILES_ONLY)) /* Otherwise, save the volatiles as well */ mov [esp + KTRAP_FRAME_ECX], ecx mov [esp + KTRAP_FRAME_EDX], edx endif /* Save segment registers? */ - if ((Flags AND KI_DONT_SAVE_SEGS) == 0) + if (NOT (Flags AND KI_DONT_SAVE_SEGS)) /* Check for V86 mode */ - test byte ptr [esp + KTRAP_FRAME_EFLAGS + 2], (EFLAGS_V86_MASK >> 16) + test byte ptr [esp + KTRAP_FRAME_EFLAGS + 2], (EFLAGS_V86_MASK / HEX(10000)) jz not_v86_trap /* Restore V8086 segments into Protected Mode segments */ @@ -173,7 +173,7 @@ set_sane_segs: mov es, ax /* Fast system calls have fs already fixed */ - if ((Flags AND KI_FAST_SYSTEM_CALL) == 0) + if (NOT (Flags AND KI_FAST_SYSTEM_CALL)) /* Otherwise fix fs now */ mov ax, KGDT_R0_PCR mov fs, ax @@ -296,7 +296,7 @@ PUBLIC @&Name&@4 mov ecx, [esp - OffsetEsp + KTRAP_FRAME_ESP] /* Keep interrupts disabled until the sti / sysexit */ - and byte ptr [esp - OffsetEsp + KTRAP_FRAME_EFLAGS + 1], ~(EFLAGS_INTERRUPT_MASK >> 8) + and byte ptr [esp - OffsetEsp + KTRAP_FRAME_EFLAGS + 1], NOT (EFLAGS_INTERRUPT_MASK / HEX(100)) endif diff --git a/reactos/ntoskrnl/kdbg/amd64/kdb_help.S b/reactos/ntoskrnl/kdbg/amd64/kdb_help.S index eb777010513..eca6dcfbdac 100644 --- a/reactos/ntoskrnl/kdbg/amd64/kdb_help.S +++ b/reactos/ntoskrnl/kdbg/amd64/kdb_help.S @@ -1,7 +1,9 @@ -#include -#include -.globl KdbEnter +#include + +#include + +PUBLIC KdbEnter KdbEnter: /* save flags */ @@ -149,4 +151,6 @@ KdbpStackSwitchAndCall: mov rsp, rax /* Return */ - ret \ No newline at end of file + ret + +END \ No newline at end of file diff --git a/reactos/ntoskrnl/kdbg/i386/kdb_help.S b/reactos/ntoskrnl/kdbg/i386/kdb_help.S index 00cb522c17c..e586f14c5e7 100644 --- a/reactos/ntoskrnl/kdbg/i386/kdb_help.S +++ b/reactos/ntoskrnl/kdbg/i386/kdb_help.S @@ -1,68 +1,72 @@ -#include -.text +#include +#include -.globl _KdbEnter +EXTERN _KdbEnterDebuggerException:PROC + +.code + +PUBLIC _KdbEnter _KdbEnter: /* * Set up a trap frame */ - pushfl /* Eflags */ - pushl %cs /* Cs */ - pushl $0 /* ErrorCode */ - pushl %ebp /* Ebp */ - pushl %ebx /* Ebx */ - movl 20(%esp), %ebp /* Eip */ - movl 16(%esp), %ebx /* Eflags */ - movl %ebx, 20(%esp) - movl 12(%esp), %ebx /* Cs */ - movl %ebx, 16(%esp) - movl %ebp, 12(%esp) - pushl %esi /* Esi */ - pushl %edi /* Edi */ - pushl %fs /* Fs */ - pushl $0 /* ExceptionList */ - pushl $0 /* PreviousMode */ - pushl %eax /* Eax */ - pushl %ecx /* Ecx */ - pushl %edx /* Edx */ - pushl %ds /* Ds */ - pushl %es /* Es */ - pushl %gs /* Gs */ - movl %dr7, %eax - pushl %eax /* Dr7 */ + pushf /* Eflags */ + push cs /* Cs */ + push 0 /* ErrorCode */ + push ebp /* Ebp */ + push ebx /* Ebx */ + mov ebp, [esp + 20] /* Eip */ + mov ebx, [esp + 16] /* Eflags */ + mov [esp + 20], ebx + mov ebx, [esp + 12] /* Cs */ + mov [esp + 16], ebx + mov [esp + 12], ebp + push esi /* Esi */ + push edi /* Edi */ + push fs /* Fs */ + push 0 /* ExceptionList */ + push 0 /* PreviousMode */ + push eax /* Eax */ + push ecx /* Ecx */ + push edx /* Edx */ + push ds /* Ds */ + push es /* Es */ + push gs /* Gs */ + mov eax, dr7 + push eax /* Dr7 */ /* Clear all breakpoint enables in dr7. */ - andl $0xFFFF0000, %eax - movl %eax, %dr7 - movl %dr6, %eax - pushl %eax /* Dr6 */ - movl %dr3, %eax - pushl %eax /* Dr3 */ - movl %dr2, %eax - pushl %eax /* Dr2 */ - movl %dr1, %eax - pushl %eax /* Dr1 */ - movl %dr0, %eax - pushl %eax /* Dr0 */ - leal 0x58(%esp), %eax - pushl %eax /* TempEsp */ - pushl %ss /* TempSegSs */ - pushl $0 /* DebugPointer */ - pushl $3 /* DebugArgMark (Exception number) */ - pushl 0x60(%esp) /* DebugEip */ - pushl %ebp /* DebugEbp */ + and eax, HEX(0FFFF0000) + mov dr7, eax + mov eax, dr6 + push eax /* Dr6 */ + mov eax, dr3 + push eax /* Dr3 */ + mov eax, dr2 + push eax /* Dr2 */ + mov eax, dr1 + push eax /* Dr1 */ + mov eax, dr0 + push eax /* Dr0 */ + lea eax, [esp + HEX(58)] + push eax /* TempEsp */ + push ss /* TempSegSs */ + push 0 /* DebugPointer */ + push 3 /* DebugArgMark (Exception number) */ + push [esp + HEX(60)] /* DebugEip */ + push ebp /* DebugEbp */ /* * Call KDB */ - movl %esp, %eax - pushl $1 /* FirstChance */ - pushl %eax /* Push a pointer to the trap frame */ - pushl $0 /* Context */ - pushl $0 /* PreviousMode (KernelMode) */ - pushl $0 /* ExceptionRecord */ - call _KdbEnterDebuggerException + mov eax, esp + push 1 /* FirstChance */ + push eax /* Push a pointer to the trap frame */ + push 0 /* Context */ + push 0 /* PreviousMode (KernelMode) */ + push 0 /* ExceptionRecord */ + call _KdbEnterDebuggerException /* * Pop the arguments and unused portions of the trap frame: @@ -73,41 +77,41 @@ _KdbEnter: * TempSegSs * TempEsp */ - addl $(11*4), %esp + add esp, 11*4 /* * Restore/update debugging registers. */ - popl %eax /* Dr0 */ - movl %eax, %dr0 - popl %eax /* Dr1 */ - movl %eax, %dr1 - popl %eax /* Dr2 */ - movl %eax, %dr2 - popl %eax /* Dr3 */ - movl %eax, %dr3 - popl %eax /* Dr6 */ - movl %eax, %dr6 - popl %eax /* Dr7 */ - movl %eax, %dr7 + pop eax /* Dr0 */ + mov dr0, eax + pop eax /* Dr1 */ + mov dr1, eax + pop eax /* Dr2 */ + mov dr2, eax + pop eax /* Dr3 */ + mov dr3, eax + pop eax /* Dr6 */ + mov dr6, eax + pop eax /* Dr7 */ + mov dr7, eax /* * Restore registers including any that might have been changed * inside the debugger. */ - popl %gs /* Gs */ - popl %es /* Es */ - popl %ds /* Ds */ - popl %edx /* Edx */ - popl %ecx /* Ecx */ - popl %eax /* Eax */ - addl $8, %esp /* PreviousMode, ExceptionList */ - popl %fs /* Fs */ - popl %edi /* Edi */ - popl %esi /* Esi */ - popl %ebx /* Ebx */ - popl %ebp /* Ebp */ - addl $4, %esp /* ErrorCode */ + pop gs /* Gs */ + pop es /* Es */ + pop ds /* Ds */ + pop edx /* Edx */ + pop ecx /* Ecx */ + pop eax /* Eax */ + add esp, 8 /* PreviousMode, ExceptionList */ + pop fs /* Fs */ + pop edi /* Edi */ + pop esi /* Esi */ + pop ebx /* Ebx */ + pop ebp /* Ebp */ + add esp, 4 /* ErrorCode */ /* * Return to the caller. @@ -115,26 +119,27 @@ _KdbEnter: iret -.globl _KdbpStackSwitchAndCall@8 +PUBLIC _KdbpStackSwitchAndCall@8 _KdbpStackSwitchAndCall@8: - pushl %ebp - movl %esp, %ebp + push ebp + mov ebp, esp - movl 0x8(%esp), %eax /* New stack */ - movl 0xC(%esp), %ecx /* Function to call */ - movl %esp, %edx /* Old stack */ + mov eax, [esp + 8] /* New stack */ + mov ecx, [esp + 12] /* Function to call */ + mov edx, esp /* Old stack */ /* Switch stack */ - movl %eax, %esp - pushl %edx + mov esp, eax + push edx /* Call function */ - call *%ecx + call ecx /* Switch back to old stack */ - popl %esp + pop esp /* Return */ - popl %ebp - ret $8 + pop ebp + ret 8 +END diff --git a/reactos/ntoskrnl/ke/amd64/boot.S b/reactos/ntoskrnl/ke/amd64/boot.S index f1715c6663e..4efbef3f94a 100644 --- a/reactos/ntoskrnl/ke/amd64/boot.S +++ b/reactos/ntoskrnl/ke/amd64/boot.S @@ -2,14 +2,14 @@ * FILE: ntoskrnl/ke/i386/boot.S * COPYRIGHT: See COPYING in the top level directory * PURPOSE: FreeLDR Wrapper Bootstrap Code and Bootstrap Trampoline - * PROGRAMMERs: Alex Ionescu (alex@relsoft.net) - * Thomas Weidenmueller + * PROGRAMMER: Timo Kreuzer (timo.kreuzer@reactos.org) */ /* INCLUDES ******************************************************************/ -#include -#include +#include + +#include EXTERN KiInitializeKernelAndGotoIdleLoop:PROC diff --git a/reactos/ntoskrnl/ke/amd64/ctxswitch.S b/reactos/ntoskrnl/ke/amd64/ctxswitch.S index 61ce1473e53..1c9b13e5737 100644 --- a/reactos/ntoskrnl/ke/amd64/ctxswitch.S +++ b/reactos/ntoskrnl/ke/amd64/ctxswitch.S @@ -9,8 +9,9 @@ /* INCLUDES ******************************************************************/ -#include -#include +#include + +#include /* FUNCTIONS ****************************************************************/ diff --git a/reactos/ntoskrnl/ke/amd64/trap.S b/reactos/ntoskrnl/ke/amd64/trap.S index 532f6bbdb91..2b95b42894d 100644 --- a/reactos/ntoskrnl/ke/amd64/trap.S +++ b/reactos/ntoskrnl/ke/amd64/trap.S @@ -7,8 +7,9 @@ /* INCLUDES ******************************************************************/ -#include -#include +#include + +#include EXTERN KiDispatchException:PROC EXTERN FrLdrDbgPrint:DWORD diff --git a/reactos/ntoskrnl/ke/i386/ctxswitch.S b/reactos/ntoskrnl/ke/i386/ctxswitch.S index 9a9c95f4db1..8fba093426f 100644 --- a/reactos/ntoskrnl/ke/i386/ctxswitch.S +++ b/reactos/ntoskrnl/ke/i386/ctxswitch.S @@ -10,22 +10,27 @@ /* INCLUDES ******************************************************************/ -#include -.intel_syntax noprefix +#include +#include + +EXTERN @KiSwapContextEntry@8:PROC +EXTERN @KiSwapContextExit@8:PROC +EXTERN @KiRetireDpcList@4:PROC +EXTERN @KiEnterV86Mode@4:PROC +EXTERN @KiExitV86Mode@4:PROC /* FUNCTIONS ****************************************************************/ +.code -.globl @KiSwapContextInternal@0 -.func @KiSwapContextInternal@0, @KiSwapContextInternal@0 +PUBLIC @KiSwapContextInternal@0 @KiSwapContextInternal@0: /* Build switch frame */ sub esp, 2 * 4 mov ecx, esp jmp @KiSwapContextEntry@8 -.endfunc -.globl @KiSwapContext@8 -.func @KiSwapContext@8, @KiSwapContext@8 + +PUBLIC @KiSwapContext@8 @KiSwapContext@8: /* Save 4 registers */ sub esp, 4 * 4 @@ -51,10 +56,9 @@ /* Clean stack */ add esp, 4 * 4 ret -.endfunc -.globl @KiSwitchThreads@8 -.func @KiSwitchThreads@8, @KiSwitchThreads@8 + +PUBLIC @KiSwitchThreads@8 @KiSwitchThreads@8: /* Load the new kernel stack and switch OS to new thread */ mov esp, edx @@ -63,10 +67,9 @@ /* Now we're on the new thread. Return to the caller to restore registers */ add esp, 2 * 4 ret -.endfunc -.globl @KiRetireDpcListInDpcStack@8 -.func @KiRetireDpcListInDpcStack@8, @KiRetireDpcListInDpcStack@8 + +PUBLIC @KiRetireDpcListInDpcStack@8 @KiRetireDpcListInDpcStack@8: /* Switch stacks and retire DPCs */ mov eax, esp @@ -77,11 +80,10 @@ /* Return on original stack */ pop esp ret -.endfunc + /* FIXFIX: Move to C code ****/ -.globl _Ki386SetupAndExitToV86Mode@4 -.func Ki386SetupAndExitToV86Mode@4 +PUBLIC _Ki386SetupAndExitToV86Mode@4 _Ki386SetupAndExitToV86Mode@4: /* Enter V8086 mode */ @@ -90,9 +92,9 @@ _Ki386SetupAndExitToV86Mode@4: mov ecx, esp call @KiEnterV86Mode@4 jmp $ -.endfunc -.globl @Ki386BiosCallReturnAddress@4 + +PUBLIC @Ki386BiosCallReturnAddress@4 @Ki386BiosCallReturnAddress@4: /* Exit V8086 mode */ @@ -102,3 +104,4 @@ _Ki386SetupAndExitToV86Mode@4: popad ret 4 +END diff --git a/reactos/ntoskrnl/ke/i386/trap.s b/reactos/ntoskrnl/ke/i386/trap.s index adfcd322dd9..f3c99c48c77 100644 --- a/reactos/ntoskrnl/ke/i386/trap.s +++ b/reactos/ntoskrnl/ke/i386/trap.s @@ -9,8 +9,8 @@ /* INCLUDES ******************************************************************/ -#include -#include +#include +#include #include MACRO(GENERATE_IDT_STUB, Number) @@ -18,16 +18,19 @@ idt _KiUnexpectedInterrupt&Number, INT_32_DPL0 ENDM MACRO(GENERATE_INT_HANDLER, Number) -.func KiUnexpectedInterrupt&Number +//.func KiUnexpectedInterrupt&Number _KiUnexpectedInterrupt&Number: push PRIMARY_VECTOR_BASE + Number jmp _KiEndUnexpectedRange@0 -.endfunc +//.endfunc ENDM +EXTERN _KiTrap02:PROC + /* GLOBALS *******************************************************************/ .data +ASSUME nothing PUBLIC _KiIdt _KiIdt: @@ -52,9 +55,9 @@ idt _KiTrap10, INT_32_DPL0 /* INT 10: x87 FPU Error (#MF) */ idt _KiTrap11, INT_32_DPL0 /* INT 11: Align Check Exception (#AC) */ idt _KiTrap0F, INT_32_DPL0 /* INT 12: Machine Check Exception (#MC)*/ idt _KiTrap0F, INT_32_DPL0 /* INT 13: SIMD FPU Exception (#XF) */ -.rept 22 +REPEAT 22 idt _KiTrap0F, INT_32_DPL0 /* INT 14-29: UNDEFINED INTERRUPTS */ -.endr +ENDR idt _KiGetTickCount, INT_32_DPL3 /* INT 2A: Get Tick Count Handler */ idt _KiCallbackReturn, INT_32_DPL3 /* INT 2B: User-Mode Callback Return */ idt _KiRaiseAssertion, INT_32_DPL3 /* INT 2C: Debug Assertion Handler */ @@ -62,15 +65,15 @@ idt _KiDebugService, INT_32_DPL3 /* INT 2D: Debug Service Handler */ idt _KiSystemService, INT_32_DPL3 /* INT 2E: System Call Service Handler */ idt _KiTrap0F, INT_32_DPL0 /* INT 2F: RESERVED */ i = 0 -.rept 208 +REPEAT 208 GENERATE_IDT_STUB %i i = i + 1 -.endr +ENDR PUBLIC _KiIdtDescriptor _KiIdtDescriptor: .short 0 - .short 0x7FF + .short HEX(7FF) .long _KiIdt PUBLIC _KiUnexpectedEntrySize @@ -78,8 +81,7 @@ _KiUnexpectedEntrySize: .long _KiUnexpectedInterrupt1 - _KiUnexpectedInterrupt0 /******************************************************************************/ -.code32 -.text +.code TRAP_ENTRY KiTrap00, KI_PUSH_FAKE_ERROR_CODE TRAP_ENTRY KiTrap01, KI_PUSH_FAKE_ERROR_CODE @@ -106,7 +108,7 @@ TRAP_ENTRY KiDebugService, KI_PUSH_FAKE_ERROR_CODE TRAP_ENTRY KiUnexpectedInterruptTail, 0 ALIGN 4 -EXTERN @KiInterruptTemplateHandler@8 +EXTERN @KiInterruptTemplateHandler@8:PROC PUBLIC _KiInterruptTemplate _KiInterruptTemplate: KiEnterTrap KI_PUSH_FAKE_ERROR_CODE @@ -135,10 +137,10 @@ _KiFastCallEntry: PUBLIC _KiStartUnexpectedRange@0 _KiStartUnexpectedRange@0: i = 0 -.rept 208 +REPEAT 208 GENERATE_INT_HANDLER %i i = i + 1 -.endr +ENDR PUBLIC _KiEndUnexpectedRange@0 _KiEndUnexpectedRange@0: jmp _KiUnexpectedInterruptTail diff --git a/reactos/ntoskrnl/ke/i386/usercall_asm.S b/reactos/ntoskrnl/ke/i386/usercall_asm.S index 2da726882eb..dcdc7ba9e88 100644 --- a/reactos/ntoskrnl/ke/i386/usercall_asm.S +++ b/reactos/ntoskrnl/ke/i386/usercall_asm.S @@ -8,17 +8,18 @@ /* INCLUDES ******************************************************************/ -#include -#include +#include +#include #include +EXTERN _MmGrowKernelStack@4:PROC +EXTERN _KeUserCallbackDispatcher:PROC +EXTERN @KiServiceExit@8:PROC + /* FUNCTIONS ****************************************************************/ +.code -.code32 -.text - -.globl _KiGetUserModeStackAddress@0 -.func KiGetUserModeStackAddress@0 +PUBLIC _KiGetUserModeStackAddress@0 _KiGetUserModeStackAddress@0: /* Get the current thread's trapframe and return the esp */ @@ -27,7 +28,6 @@ _KiGetUserModeStackAddress@0: lea eax, [eax+KTRAP_FRAME_ESP] ret -.endfunc /*++ * @name KiCallUserMode @@ -53,8 +53,7 @@ _KiGetUserModeStackAddress@0: * This call MUST be paired by interrupt 0x2B or NtCallbackReturn. * *--*/ -.globl _KiCallUserMode@8 -.func KiCallUserMode@8 +PUBLIC _KiCallUserMode@8 _KiCallUserMode@8: /* Save volatile registers */ @@ -102,7 +101,7 @@ ApcsEnabled: #endif /* Get the lowest stack limit and check if we can handle it */ - lea eax, [esp-0x3000] + lea eax, [esp-HEX(3000)] cmp eax, [ebx+KTHREAD_STACK_LIMIT] jnb StackOk @@ -130,7 +129,7 @@ StackOk: mov [ebx+KTHREAD_CALLBACK_STACK], esp /* Align stack on 16-byte boundary */ - and esp, ~15 + and esp, NOT 15 mov edi, esp /* Set destination and origin NPX Areas */ @@ -181,7 +180,7 @@ DontBias: /* Copy DR7 */ mov edi, [edx+KTRAP_FRAME_DR7] - test edi, ~DR7_RESERVED_MASK + test edi, NOT DR7_RESERVED_MASK mov [esp+KTRAP_FRAME_DR7], edi /* Check if we need to save debug registers */ @@ -226,7 +225,6 @@ GrowFailed: /* Return */ ret 8 -.endfunc /*++ * @name NtCallbackReturn @@ -251,8 +249,7 @@ GrowFailed: * @remark This call MUST be paired with KeUserModeCallback. * *--*/ -.globl _NtCallbackReturn@12 -.func NtCallbackReturn@12 +PUBLIC _NtCallbackReturn@12 _NtCallbackReturn@12: /* Get the current thread and make sure we have a callback stack */ @@ -316,7 +313,7 @@ CheckDebug: and dword ptr [edi+KTRAP_FRAME_DR7], 0 /* Check if debugging was active */ - test byte ptr [eax+KTHREAD_DEBUG_ACTIVE], 0xFF + test byte ptr [eax+KTHREAD_DEBUG_ACTIVE], HEX(0FF) jnz RestoreDebug RestoreStack: @@ -407,7 +404,6 @@ NoStack: /* Return failure */ mov eax, STATUS_NO_CALLBACK_ACTIVE ret 12 -.endfunc /*++ * @name KeSwitchKernelStack @@ -429,8 +425,7 @@ NoStack: * this routine. * *--*/ -.globl _KeSwitchKernelStack@8 -.func KeSwitchKernelStack@8 +PUBLIC _KeSwitchKernelStack@8 _KeSwitchKernelStack@8: /* Save volatiles */ @@ -515,4 +510,5 @@ V86Switch: pop edi pop esi ret 8 -.endfunc + +END diff --git a/reactos/ntoskrnl/rtl/i386/stack.S b/reactos/ntoskrnl/rtl/i386/stack.S index d71cc4f0c3e..7fbb6e0106a 100644 --- a/reactos/ntoskrnl/rtl/i386/stack.S +++ b/reactos/ntoskrnl/rtl/i386/stack.S @@ -8,13 +8,13 @@ /* INCLUDES ******************************************************************/ -#include -.intel_syntax noprefix +#include +#include /* FUNCTIONS *****************************************************************/ +.code -.func RtlpGetStackLimits@8 -.globl _RtlpGetStackLimits@8 +PUBLIC _RtlpGetStackLimits@8 _RtlpGetStackLimits@8: /* Get the current thread */ @@ -34,4 +34,5 @@ _RtlpGetStackLimits@8: /* return */ ret 8 -.endfunc + +END diff --git a/reactos/subsystems/win32/win32k/dib/i386/dib24bpp_hline.s b/reactos/subsystems/win32/win32k/dib/i386/dib24bpp_hline.s index 24451140f7c..1d36aa4bb9c 100644 --- a/reactos/subsystems/win32/win32k/dib/i386/dib24bpp_hline.s +++ b/reactos/subsystems/win32/win32k/dib/i386/dib24bpp_hline.s @@ -6,13 +6,12 @@ * PROGRAMMERS: Magnus Olsen */ -.globl _DIB_24BPP_HLine -.intel_syntax noprefix +#include + +.code + +PUBLIC _DIB_24BPP_HLine -.def _DIB_24BPP_HLine; -.scl 2; -.type 32; -.endef _DIB_24BPP_HLine: push edi push esi @@ -151,3 +150,5 @@ pop esi pop edi ret + +END diff --git a/reactos/subsystems/win32/win32k/dib/i386/dib32bpp_colorfill.s b/reactos/subsystems/win32/win32k/dib/i386/dib32bpp_colorfill.s index fce9f7f84c0..00a83804a73 100644 --- a/reactos/subsystems/win32/win32k/dib/i386/dib32bpp_colorfill.s +++ b/reactos/subsystems/win32/win32k/dib/i386/dib32bpp_colorfill.s @@ -7,15 +7,16 @@ * Timo Kreuzer (timo.kreuzer@reactos.org) */ -.intel_syntax noprefix +#include +.code /* * BOOLEAN * _cdecl * DIB_32BPP_ColorFill(SURFOBJ* pso, RECTL* prcl, ULONG iColor); */ -.globl _DIB_32BPP_ColorFill +PUBLIC _DIB_32BPP_ColorFill _DIB_32BPP_ColorFill: push ebp mov ebp, esp @@ -27,22 +28,22 @@ _DIB_32BPP_ColorFill: mov edx, [ebp+12] /* edx = prcl */ mov ecx, [ebp+8] /* ecx = pso */ - mov ebx, [ecx+0x24] /* ebx = pso->lDelta; */ + mov ebx, [ecx+36] /* ebx = pso->lDelta; */ mov [esp], ebx /* lDelta = pso->lDelta; */ mov edi, [edx+4] /* edi = prcl->top; */ mov eax, edi /* eax = prcl->top; */ imul eax, ebx /* eax = prcl->top * pso->lDelta; */ - add eax, [ecx+0x20] /* eax += pso->pvScan0; */ + add eax, [ecx+32] /* eax += pso->pvScan0; */ mov ebx, [edx] /* ebx = prcl->left; */ lea esi, [eax+ebx*4] /* esi = pvLine0 = eax + 4 * prcl->left; */ mov ebx, [edx+8] /* ebx = prcl->right; */ sub ebx, [edx] /* ebx = prcl->right - prcl->left; */ - jbe end /* if (ebx <= 0) goto end; */ + jbe .end /* if (ebx <= 0) goto end; */ mov edx, [edx+12] /* edx = prcl->bottom; */ sub edx, edi /* edx -= prcl->top; */ - jbe end /* if (eax <= 0) goto end; */ + jbe .end /* if (eax <= 0) goto end; */ mov eax, [ebp+16] /* eax = iColor; */ cld @@ -55,7 +56,7 @@ for_loop: /* do { */ dec edx /* cy--; */ jnz for_loop /* } while (cy > 0); */ -end: +.end: mov eax, 1 add esp, 4 pop edi @@ -63,3 +64,5 @@ end: pop ebx pop ebp ret + +END diff --git a/reactos/subsystems/win32/win32k/dib/i386/dib32bpp_hline.s b/reactos/subsystems/win32/win32k/dib/i386/dib32bpp_hline.s index f976b8741bf..c60d43d6343 100644 --- a/reactos/subsystems/win32/win32k/dib/i386/dib32bpp_hline.s +++ b/reactos/subsystems/win32/win32k/dib/i386/dib32bpp_hline.s @@ -6,13 +6,11 @@ * PROGRAMMERS: Magnus Olsen */ -.globl _DIB_32BPP_HLine -.intel_syntax noprefix +#include -.def _DIB_32BPP_HLine; -.scl 2; -.type 32; -.endef +.code + +PUBLIC _DIB_32BPP_HLine _DIB_32BPP_HLine: sub esp, 12 // rember the base is not hex it is dec @@ -55,3 +53,4 @@ _save_rest: add esp, 12 ret +END diff --git a/reactos/subsystems/win32/win32k/eng/i386/floatobj.S b/reactos/subsystems/win32/win32k/eng/i386/floatobj.S index 6a9a3324729..c046bcfbeec 100644 --- a/reactos/subsystems/win32/win32k/eng/i386/floatobj.S +++ b/reactos/subsystems/win32/win32k/eng/i386/floatobj.S @@ -6,6 +6,9 @@ * PROGRAMMER: Timo Kreuzer */ +#include + +.code /******************************************************************************* * IEEE 754-1985 single precision floating point @@ -72,9 +75,6 @@ * FLOATOBJ_SubLong - wrapper */ -.intel_syntax noprefix -.text - #define lMant 0 #define lExp 4 @@ -87,24 +87,24 @@ * FLOATOBJ_SetFloat(IN OUT PFLOATOBJ pf, IN FLOATL f); */ _FLOATOBJ_SetFloat@8: -.global _FLOATOBJ_SetFloat@8 +PUBLIC _FLOATOBJ_SetFloat@8 push ebp mov ebp, esp mov ecx, [esp + PARAM2] /* Load the float into ecx */ mov eax, ecx /* Copy float to eax for later */ - test ecx, 0x7f800000 /* Check for zero exponent - 0 or denormal */ + test ecx, HEX(7f800000) /* Check for zero exponent - 0 or denormal */ jz SetFloat0 /* If it's all zero, ... */ shl ecx, 7 /* Put the bits for the mantissa in place */ cdq /* Fill edx with the sign from the FLOATL in eax */ - and ecx, 0x7fffffff /* Mask out invalid field in the mantissa */ + and ecx, HEX(7fffffff) /* Mask out invalid field in the mantissa */ shr eax, 23 /* Shift the exponent in eax in place */ - or ecx, 0x40000000 /* Set bit for 1 in the mantissa */ - and eax, 0xff /* Mask out invalid fields in the exponent in eax */ + or ecx, HEX(40000000) /* Set bit for 1 in the mantissa */ + and eax, HEX(0ff) /* Mask out invalid fields in the exponent in eax */ xor ecx, edx /* Make use of the sign bit expanded to full edx */ @@ -136,7 +136,7 @@ SetFloat0: * */ _FLOATOBJ_GetFloat@4: -.global _FLOATOBJ_GetFloat@4 +PUBLIC _FLOATOBJ_GetFloat@4 push ebp mov ebp, esp @@ -152,13 +152,13 @@ _FLOATOBJ_GetFloat@4: sub eax, edx jz GetFloatRet - and ecx, 0xff /* Mask out invalid fields in the exponent */ - and eax, 0x3fffffff /* Mask out invalid fields in mantissa */ + and ecx, HEX(0ff) /* Mask out invalid fields in the exponent */ + and eax, HEX(3fffffff) /* Mask out invalid fields in mantissa */ shl ecx, 23 /* Shift exponent in place */ shr eax, 7 /* Shift mantissa in place */ - and edx, 0x80000000 /* Reduce edx to sign bit only */ + and edx, HEX(80000000) /* Reduce edx to sign bit only */ or eax, ecx /* Set exponent in result */ or eax, edx /* Set sign bit in result */ @@ -178,7 +178,7 @@ GetFloatRet: * Instead of using abs(l), which is 3 + 2 instructions, use a branch. */ _FLOATOBJ_SetLong@8: -.global _FLOATOBJ_SetLong@8 +PUBLIC _FLOATOBJ_SetLong@8 push ebp mov ebp, esp @@ -236,7 +236,7 @@ SetLong0: * */ _FLOATOBJ_GetLong@4: -.global _FLOATOBJ_GetLong@4 +PUBLIC _FLOATOBJ_GetLong@4 push ebp mov ebp, esp @@ -263,7 +263,7 @@ GetLong2: * FLOATOBJ_Equal(IN PFLOATOBJ pf1, IN PFLOATOBJ pf2); */ _FLOATOBJ_Equal@8: -.global _FLOATOBJ_Equal@8 +PUBLIC _FLOATOBJ_Equal@8 push ebp mov ebp, esp @@ -291,7 +291,7 @@ _FLOATOBJ_Equal@8: * FLOATOBJ_EqualLong(IN PFLOATOBJ pf, IN LONG l); */ _FLOATOBJ_EqualLong@8: -.global _FLOATOBJ_EqualLong@8 +PUBLIC _FLOATOBJ_EqualLong@8 push ebp mov ebp, esp @@ -325,7 +325,7 @@ EqualLongFalse: * */ _FLOATOBJ_GreaterThan@8: -.global _FLOATOBJ_GreaterThan@8 +PUBLIC _FLOATOBJ_GreaterThan@8 push ebp mov ebp, esp @@ -415,7 +415,7 @@ GreaterThan_neg2: * LOATOBJ_GreaterThan */ _FLOATOBJ_GreaterThanLong@8: -.global _FLOATOBJ_GreaterThanLong@8 +PUBLIC _FLOATOBJ_GreaterThanLong@8 push ebp mov ebp, esp @@ -445,7 +445,7 @@ _FLOATOBJ_GreaterThanLong@8: * */ _FLOATOBJ_LessThan@8: -.global _FLOATOBJ_LessThan@8 +PUBLIC _FLOATOBJ_LessThan@8 push ebp mov ebp, esp @@ -536,7 +536,7 @@ LessThan_neg2: * Currently implemented as a wrapper around FLOATOBJ_SetLong and FLOATOBJ_LessThan */ _FLOATOBJ_LessThanLong@8: -.global _FLOATOBJ_LessThanLong@8 +PUBLIC _FLOATOBJ_LessThanLong@8 push ebp mov ebp, esp @@ -569,7 +569,7 @@ _FLOATOBJ_LessThanLong@8: * No special handling for 0, where mantissa is 0 */ _FLOATOBJ_Mul@8: -.global _FLOATOBJ_Mul@8 +PUBLIC _FLOATOBJ_Mul@8 push ebp mov ebp, esp @@ -620,7 +620,7 @@ MulNeg: lea edx, [edx + ecx -2] /* Normalize exponent in edx */ - or eax, 0x80000000 /* Set sign bit */ + or eax, HEX(80000000) /* Set sign bit */ mov ecx, [esp + PARAM1] /* Load pf1 into ecx */ mov [ecx + lMant], eax /* Save back mantissa */ @@ -646,7 +646,7 @@ Mul0: * Currently implemented as a wrapper around FLOATOBJ_SetFloat and FLOATOBJ_Mul */ _FLOATOBJ_MulFloat@8: -.global _FLOATOBJ_MulFloat@8 +PUBLIC _FLOATOBJ_MulFloat@8 push ebp mov ebp, esp @@ -675,7 +675,7 @@ _FLOATOBJ_MulFloat@8: * Currently implemented as a wrapper around FLOATOBJ_SetLong and FLOATOBJ_Mul */ _FLOATOBJ_MulLong@8: -.global _FLOATOBJ_MulLong@8 +PUBLIC _FLOATOBJ_MulLong@8 push ebp mov ebp, esp @@ -703,7 +703,7 @@ _FLOATOBJ_MulLong@8: * */ _FLOATOBJ_Div@8: -.global _FLOATOBJ_Div@8 +PUBLIC _FLOATOBJ_Div@8 push ebp mov ebp, esp push ebx @@ -736,7 +736,7 @@ _FLOATOBJ_Div@8: div ecx /* Do an unsigned divide */ xor ecx, ecx /* Adjust result */ - test eax, 0x80000000 + test eax, HEX(80000000) setnz cl shr eax, cl @@ -773,7 +773,7 @@ Div0: * Currently implemented as a wrapper around FLOATOBJ_SetFloat and FLOATOBJ_Div */ _FLOATOBJ_DivFloat@8: -.global _FLOATOBJ_DivFloat@8 +PUBLIC _FLOATOBJ_DivFloat@8 push ebp mov ebp, esp sub esp, 8 /* Make room for a FLOATOBJ on the stack */ @@ -802,7 +802,7 @@ _FLOATOBJ_DivFloat@8: * Currently implemented as a wrapper around FLOATOBJ_SetLong and FLOATOBJ_Div */ _FLOATOBJ_DivLong@8: -.global _FLOATOBJ_DivLong@8 +PUBLIC _FLOATOBJ_DivLong@8 push ebp mov ebp, esp sub esp, 8 /* Make room for a FLOATOBJ on the stack */ @@ -829,7 +829,7 @@ _FLOATOBJ_DivLong@8: * */ _FLOATOBJ_Add@8: -.global _FLOATOBJ_Add@8 +PUBLIC _FLOATOBJ_Add@8 push ebp mov ebp, esp push ebx @@ -928,7 +928,7 @@ AddIs0: * Currently implemented as a wrapper around FLOATOBJ_SetFloat and FLOATOBJ_Add */ _FLOATOBJ_AddFloat@8: -.global _FLOATOBJ_AddFloat@8 +PUBLIC _FLOATOBJ_AddFloat@8 push ebp mov ebp, esp sub esp, 8 /* Make room for a FLOATOBJ on the stack */ @@ -957,7 +957,7 @@ _FLOATOBJ_AddFloat@8: * Currently implemented as a wrapper around FLOATOBJ_SetLong and FLOATOBJ_Add */ _FLOATOBJ_AddLong@8: -.global _FLOATOBJ_AddLong@8 +PUBLIC _FLOATOBJ_AddLong@8 push ebp mov ebp, esp sub esp, 8 /* Make room for a FLOATOBJ on the stack */ @@ -985,7 +985,7 @@ _FLOATOBJ_AddLong@8: * */ _FLOATOBJ_Sub@8: -.global _FLOATOBJ_Sub@8 +PUBLIC _FLOATOBJ_Sub@8 push ebp mov ebp, esp push ebx @@ -1083,7 +1083,7 @@ SubIs0: * Currently implemented as a wrapper around FLOATOBJ_SetFloat and FLOATOBJ_Sub */ _FLOATOBJ_SubFloat@8: -.global _FLOATOBJ_SubFloat@8 +PUBLIC _FLOATOBJ_SubFloat@8 push ebp mov ebp, esp sub esp, 8 /* Make room for a FLOATOBJ on the stack */ @@ -1112,7 +1112,7 @@ _FLOATOBJ_SubFloat@8: * Currently implemented as a wrapper around FLOATOBJ_SetLong and FLOATOBJ_Sub */ _FLOATOBJ_SubLong@8: -.global _FLOATOBJ_SubLong@8 +PUBLIC _FLOATOBJ_SubLong@8 push ebp mov ebp, esp sub esp, 8 /* Make room for a FLOATOBJ on the stack */ @@ -1140,7 +1140,7 @@ _FLOATOBJ_SubLong@8: * */ _FLOATOBJ_Neg@4: -.global _FLOATOBJ_Neg@4 +PUBLIC _FLOATOBJ_Neg@4 push ebp mov ebp, esp @@ -1150,5 +1150,5 @@ _FLOATOBJ_Neg@4: pop ebp /* Return */ ret 4 - +END /* EOF */ diff --git a/reactos/subsystems/win32/win32k/misc/i386/atan2_asm.s b/reactos/subsystems/win32/win32k/misc/i386/atan2_asm.s index 1ce05320559..75aca5f7b30 100644 --- a/reactos/subsystems/win32/win32k/misc/i386/atan2_asm.s +++ b/reactos/subsystems/win32/win32k/misc/i386/atan2_asm.s @@ -33,13 +33,13 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ - -.globl _atan2 - -.intel_syntax noprefix +#include + /* FUNCTIONS ***************************************************************/ +.code +PUBLIC _atan2 _atan2: push ebp mov ebp,esp @@ -49,3 +49,5 @@ _atan2: mov esp,ebp pop ebp ret + +END diff --git a/reactos/subsystems/win32/win32k/misc/i386/ceil_asm.s b/reactos/subsystems/win32/win32k/misc/i386/ceil_asm.s index aad69114f5a..1256fa1cf00 100644 --- a/reactos/subsystems/win32/win32k/misc/i386/ceil_asm.s +++ b/reactos/subsystems/win32/win32k/misc/i386/ceil_asm.s @@ -33,13 +33,13 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ - -.globl _ceil -.intel_syntax noprefix +#include /* FUNCTIONS ***************************************************************/ +.code +PUBLIC _ceil _ceil: push ebp mov ebp,esp @@ -47,7 +47,7 @@ _ceil: fld qword ptr [ebp+8] // Load real from stack fstcw [ebp-2] // Save control word fclex // Clear exceptions - mov word ptr [ebp-4],0xb63 // Rounding control word + mov word ptr [ebp-4],HEX(b63) // Rounding control word fldcw [ebp-4] // Set new rounding control frndint // Round to integer fclex // Clear exceptions @@ -55,3 +55,5 @@ _ceil: mov esp,ebp // Deallocate temporary space pop ebp ret + +END diff --git a/reactos/subsystems/win32/win32k/misc/i386/cos_asm.s b/reactos/subsystems/win32/win32k/misc/i386/cos_asm.s index b1c6ada49b2..8b525755b17 100644 --- a/reactos/subsystems/win32/win32k/misc/i386/cos_asm.s +++ b/reactos/subsystems/win32/win32k/misc/i386/cos_asm.s @@ -33,13 +33,13 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ - -.globl _cos -.intel_syntax noprefix +#include /* FUNCTIONS ***************************************************************/ +.code +PUBLIC _cos _cos: push ebp mov ebp,esp // Point to the stack frame @@ -47,3 +47,5 @@ _cos: fcos // Take the cosine pop ebp ret + +END diff --git a/reactos/subsystems/win32/win32k/misc/i386/floor_asm.s b/reactos/subsystems/win32/win32k/misc/i386/floor_asm.s index f03c85cb4e8..1f5f2b107df 100644 --- a/reactos/subsystems/win32/win32k/misc/i386/floor_asm.s +++ b/reactos/subsystems/win32/win32k/misc/i386/floor_asm.s @@ -33,13 +33,13 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ - -.globl _floor - -.intel_syntax noprefix + +#include /* FUNCTIONS ***************************************************************/ +.code +PUBLIC _floor _floor: push ebp mov ebp,esp @@ -47,7 +47,7 @@ _floor: fld qword ptr [ebp+8] // Load real from stack fstcw [ebp-2] // Save control word fclex // Clear exceptions - mov word ptr [ebp-4],0x763 // Rounding control word + mov word ptr [ebp-4],HEX(763) // Rounding control word fldcw [ebp-4] // Set new rounding control frndint // Round to integer fclex // Clear exceptions @@ -55,3 +55,5 @@ _floor: mov esp,ebp pop ebp ret + +END diff --git a/reactos/subsystems/win32/win32k/misc/i386/sin_asm.s b/reactos/subsystems/win32/win32k/misc/i386/sin_asm.s index 39791a3e989..7ec0fa69c23 100644 --- a/reactos/subsystems/win32/win32k/misc/i386/sin_asm.s +++ b/reactos/subsystems/win32/win32k/misc/i386/sin_asm.s @@ -33,13 +33,13 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ - -.globl _sin -.intel_syntax noprefix +#include /* FUNCTIONS ***************************************************************/ +.code +PUBLIC _sin _sin: push ebp // Save register bp mov ebp,esp // Point to the stack frame @@ -47,3 +47,5 @@ _sin: fsin // Take the sine pop ebp // Restore register bp ret + +END diff --git a/reactos/tools/nci/ncitool.c b/reactos/tools/nci/ncitool.c index 07838af1efa..ca10a815a5b 100644 --- a/reactos/tools/nci/ncitool.c +++ b/reactos/tools/nci/ncitool.c @@ -50,16 +50,15 @@ * This stubs calls into KUSER_SHARED_DATA where either a * sysenter or interrupt is performed, depending on CPU support. */ -#if defined(__GNUC__) -#define UserModeStub_x86 " movl $0x%x, %%eax\n" \ - " movl $KUSER_SHARED_SYSCALL, %%ecx\n" \ - " call *(%%ecx)\n" \ - " ret $0x%x\n\n" +#define UserModeStub_x86 " mov eax, %d\n" \ + " mov ecx, KUSER_SHARED_SYSCALL\n" \ + " call dword ptr [ecx]\n" \ + " ret %d\n\n" -#define UserModeStub_amd64 " movl $0x%x, %%eax\n" \ - " movq %%rcx, %%r10\n" \ +#define UserModeStub_amd64 " mov eax, %d\n" \ + " mov r10, rcx\n" \ " syscall\n" \ - " ret $0x%x\n\n" + " ret %d\n\n" #define UserModeStub_ppc " stwu 1,-16(1)\n" \ " mflr 0\n\t" \ @@ -79,32 +78,21 @@ #define UserModeStub_arm " swi #0x%x\n" \ " bx lr\n\n" -#elif defined(_MSC_VER) -#define UserModeStub_x86 " asm { \n" \ - " mov eax, %xh\n" \ - " mov ecx, KUSER_SHARED_SYSCALL\n" \ - " call [ecx]\n" \ - " ret %xh\n" \ - " }\n" -#else -#error Unknown compiler for inline assembler -#endif /* * This stub calls KiSystemService directly with a fake INT2E stack. * Because EIP is pushed during the call, the handler will return here. */ -#if defined(__GNUC__) -#define KernelModeStub_x86 " movl $0x%x, %%eax\n" \ - " leal 4(%%esp), %%edx\n" \ - " pushfl\n" \ - " pushl $KGDT_R0_CODE\n" \ +#define KernelModeStub_x86 " mov eax, %d\n" \ + " lea edx, [esp + 4]\n" \ + " pushf\n" \ + " push KGDT_R0_CODE\n" \ " call _KiSystemService\n" \ - " ret $0x%x\n\n" + " ret %d\n\n" -#define KernelModeStub_amd64 " movl $0x%x, %%eax\n" \ +#define KernelModeStub_amd64 " mov eax, %d\n" \ " call KiSystemService\n" \ - " ret $0x%x\n\n" + " ret %d\n\n" /* For now, use the usermode stub. We'll optimize later */ #define KernelModeStub_ppc UserModeStub_ppc @@ -116,19 +104,6 @@ " swi #0x%x\n" \ " bx ip\n\n" -#elif defined(_MSC_VER) -#define KernelModeStub_x86 " asm { \n" \ - " mov eax, %xh\n" \ - " lea edx, [esp+4]\n" \ - " pushf\n" \ - " push KGDT_R0_CODE\n" \ - " call _KiSystemService\n" \ - " ret %xh\n" \ - " }\n" -#else -#error Unknown compiler for inline assembler -#endif - /***** Arch Dependent Stuff ******/ struct ncitool_data_t { const char *arch; @@ -141,9 +116,9 @@ struct ncitool_data_t { struct ncitool_data_t ncitool_data[] = { { "i386", 4, KernelModeStub_x86, UserModeStub_x86, - ".global _%s@%d\n", "_%s@%d:\n" }, + "PUBLIC _%s@%d\n", "_%s@%d:\n" }, { "amd64", 4, KernelModeStub_amd64, UserModeStub_amd64, - ".global %s\n", "%s:\n" }, + "PUBLIC %s\n", "%s:\n" }, { "powerpc", 4, KernelModeStub_ppc, UserModeStub_ppc, "\t.globl %s\n", "%s:\n" }, { "mips", 4, KernelModeStub_mips, UserModeStub_mips, @@ -192,14 +167,14 @@ WriteFileHeader(FILE * StubFile, " * PURPOSE: %s\n" " * PROGRAMMER: Computer Generated File. See tools/nci/ncitool.c\n" " * REMARK: DO NOT EDIT OR COMMIT MODIFICATIONS TO THIS FILE\n" - " */\n\n\n" - "#include \n\n", + " */\n\n\n", + FileDescription, FileLocation); } /*++ - * WriteFileHeader + * WriteStubHeader * * Prints out the File Header for a Stub File. * @@ -393,6 +368,7 @@ CreateStubs(FILE * SyscallDb, char *SyscallArguments; int SyscallId; unsigned StackBytes; + unsigned int i; /* We loop, incrementing the System Call Index, until the end of the file */ for (SyscallId = 0; ((!feof(SyscallDb)) && (fgets(Line, sizeof(Line), SyscallDb) != NULL));) { @@ -408,26 +384,23 @@ CreateStubs(FILE * SyscallDb, if (NtSyscallName) { /* Create Usermode Stubs for Nt/Zw syscalls in each Usermode file */ - int i; for (i= 0; i < UserFiles; i++) { - /* Write the Nt Version */ - WriteUserModeStub(UserModeFiles[i], - NtSyscallName, - StackBytes, - SyscallId | Index); + /* Write the Stub Header and export the Function */ + WriteStubHeader(UserModeFiles[i], NtSyscallName, StackBytes); /* If a Zw Version is needed (was specified), write it too */ if (NeedsZw) { NtSyscallName[0] = 'Z'; NtSyscallName[1] = 'w'; - WriteUserModeStub(UserModeFiles[i], - NtSyscallName, - StackBytes, - SyscallId | Index); + + /* Write the Stub Header and export the Function */ + WriteStubHeader(UserModeFiles[i], NtSyscallName, StackBytes); } + /* Write the Stub Code */ + fprintf(UserModeFiles[i], UserModeStub, SyscallId | Index, StackBytes); } /* Create the Kernel coutnerparts (only Zw*, Nt* are the real functions!) */ @@ -445,6 +418,11 @@ CreateStubs(FILE * SyscallDb, SyscallId++; } } + +#if defined(_MSC_VER) + for (i= 0; i < UserFiles; i++) fprintf(UserModeFiles[i], "END\n"); + fprintf(KernelModeFile, "END\n"); +#endif } /*++ @@ -627,7 +605,7 @@ CreateSpec(FILE * SyscallDb, /* Make sure we really extracted something */ if (NtSyscallName) { - int i; + unsigned int i; for (i= 0; i < CountFiles; i++) { if (!UseZw) { @@ -670,7 +648,7 @@ void usage(char * argv0) int main(int argc, char* argv[]) { - FILE * Files[Arguments] = { }; + FILE * Files[Arguments] = {0}; int FileNumber, ArgOffset = 1; char * OpenType = "r"; @@ -710,15 +688,24 @@ int main(int argc, char* argv[]) WriteFileHeader(Files[NtosUserStubs], "System Call Stubs for Native API", argv[NtosUserStubs + ArgOffset]); + fputs("#include \n" + "#include \n" + ".code\n\n", Files[NtosUserStubs]); WriteFileHeader(Files[NtosKernelStubs], "System Call Stubs for Native API", argv[NtosKernelStubs + ArgOffset]); - fputs("#include \n\n", Files[NtosKernelStubs]); + fputs("#include \n" + "#include \n" + ".code\n" + "EXTERN _KiSystemService:PROC\n\n", Files[NtosKernelStubs]); WriteFileHeader(Files[Win32kStubs], "System Call Stubs for Native API", argv[Win32kStubs + ArgOffset]); + fputs("#include \n" + "#include \n" + ".code\n\n", Files[Win32kStubs]); /* Create the System Stubs */ CreateStubs(Files[NativeSystemDb], @@ -772,3 +759,4 @@ int main(int argc, char* argv[]) return(0); } + From 250e056ecef8d214b6cdee9c37a8db8dcc2d6362 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Sat, 27 Nov 2010 22:24:15 +0000 Subject: [PATCH 004/181] revert r49824 svn path=/trunk/; revision=49827 --- reactos/tools/xml.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/reactos/tools/xml.cpp b/reactos/tools/xml.cpp index 50125e129d6..8400ce131ed 100644 --- a/reactos/tools/xml.cpp +++ b/reactos/tools/xml.cpp @@ -18,7 +18,6 @@ #ifdef _MSC_VER #pragma warning ( disable : 4786 ) -#pragma warning ( disable : 4996 ) #endif//_MSC_VER #ifdef WIN32 @@ -42,6 +41,7 @@ #include #include #include "xml.h" +#include "ssprintf.h" #ifndef MAX_PATH #define MAX_PATH _MAX_PATH @@ -100,9 +100,7 @@ XMLException::XMLException ( void XMLException::SetExceptionV ( const std::string& location, const char* format, va_list args ) { - char buffer[1024]; - _vsnprintf(buffer, sizeof(buffer)-1, format, args); - _e = location + ": " + buffer; + _e = location + ": " + ssvprintf(format,args); } void XMLException::SetException ( const std::string& location, const char* format, ... ) @@ -426,14 +424,13 @@ string XMLFile::Location() const { int line = 1; - char line_str[10]; const char* p = strchr ( _buf.c_str(), '\n' ); while ( p && p < _p ) { ++line; p = strchr ( p+1, '\n' ); } - return _filename + "(" + itoa(line, line_str, 10) + ")"; + return ssprintf ( "%s(%i)",_filename.c_str(), line ); } XMLAttribute::XMLAttribute() From af040adf503922bcd242fc22b6ae3c98795f2a3b Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Sun, 28 Nov 2010 00:10:02 +0000 Subject: [PATCH 005/181] [CRT] Fix typos svn path=/trunk/; revision=49830 --- reactos/lib/sdk/crt/setjmp/i386/setjmp.s | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/reactos/lib/sdk/crt/setjmp/i386/setjmp.s b/reactos/lib/sdk/crt/setjmp/i386/setjmp.s index dc0e9656b3a..68916996a4f 100644 --- a/reactos/lib/sdk/crt/setjmp/i386/setjmp.s +++ b/reactos/lib/sdk/crt/setjmp/i386/setjmp.s @@ -101,13 +101,13 @@ _longjmp: mov eax, [esp + 8] /* Second argument is return value. */ /* Save the return address now. */ - mov edx, [edx + JB_IP*4] + mov edx, [ecx + JB_IP*4] /* Restore registers. */ - mov ebp, [edx + JB_BP*4] - mov ebx, [edx + JB_BX*4] - mov edi, [edx + JB_DI*4] - mov esi, [edx + JB_SI*4] - mov esp, [edx + JB_SP*4] + mov ebp, [ecx + JB_BP*4] + mov ebx, [ecx + JB_BX*4] + mov edi, [ecx + JB_DI*4] + mov esi, [ecx + JB_SI*4] + mov esp, [ecx + JB_SP*4] /* Jump to saved PC. */ jmp dword ptr [edx] From 52a1227b430fb2a392d52fe166bd4d04b690b0a5 Mon Sep 17 00:00:00 2001 From: James Tabor Date: Sun, 28 Nov 2010 01:37:16 +0000 Subject: [PATCH 006/181] [User32] - Sync up with wine 1.2 rc6 menu so it will pass the tests from rev 47939. svn path=/trunk/; revision=49834 --- reactos/dll/win32/user32/windows/menu.c | 31 +++++++++++++++---------- 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/reactos/dll/win32/user32/windows/menu.c b/reactos/dll/win32/user32/windows/menu.c index c9e87de47de..8f8610d64b1 100644 --- a/reactos/dll/win32/user32/windows/menu.c +++ b/reactos/dll/win32/user32/windows/menu.c @@ -3487,14 +3487,23 @@ static BOOL FASTCALL MenuInitTracking(HWND hWnd, HMENU hMenu, BOOL bPopup, UINT HideCaret(0); + MenuGetRosMenuInfo(&MenuInfo, hMenu); + /* This makes the menus of applications built with Delphi work. + * It also enables menus to be displayed in more than one window, + * but there are some bugs left that need to be fixed in this case. + */ + if(MenuInfo.Self == hMenu) + { + MenuInfo.Wnd = hWnd; + MenuSetRosMenuInfo(&MenuInfo); + } + /* Send WM_ENTERMENULOOP and WM_INITMENU message only if TPM_NONOTIFY flag is not specified */ if (!(wFlags & TPM_NONOTIFY)) SendMessageW( hWnd, WM_ENTERMENULOOP, bPopup, 0 ); SendMessageW( hWnd, WM_SETCURSOR, (WPARAM)hWnd, HTCAPTION ); - MenuGetRosMenuInfo(&MenuInfo, hMenu); - if (!(wFlags & TPM_NONOTIFY)) { SendMessageW( hWnd, WM_INITMENU, (WPARAM)hMenu, 0 ); @@ -3512,16 +3521,6 @@ static BOOL FASTCALL MenuInitTracking(HWND hWnd, HMENU hMenu, BOOL bPopup, UINT } } - /* This makes the menus of applications built with Delphi work. - * It also enables menus to be displayed in more than one window, - * but there are some bugs left that need to be fixed in this case. - */ - if(MenuInfo.Self == hMenu) - { - MenuInfo.Wnd = hWnd; - MenuSetRosMenuInfo(&MenuInfo); - } - IntNotifyWinEvent( EVENT_SYSTEM_MENUSTART, hWnd, MenuInfo.Flags & MF_SYSMENU ? OBJID_SYSMENU : OBJID_MENU, @@ -3652,6 +3651,7 @@ BOOL WINAPI TrackPopupMenuEx( HMENU Menu, UINT Flags, int x, int y, HWND Wnd, LPTPMPARAMS Tpm) { BOOL ret = FALSE; + ROSMENUINFO MenuInfo; if (!IsMenu(Menu)) { @@ -3659,6 +3659,13 @@ BOOL WINAPI TrackPopupMenuEx( HMENU Menu, UINT Flags, int x, int y, return FALSE; } + MenuGetRosMenuInfo(&MenuInfo, Menu); + if (IsWindow(MenuInfo.Wnd)) + { + SetLastError( ERROR_POPUP_ALREADY_ACTIVE ); + return FALSE; + } + MenuInitTracking(Wnd, Menu, TRUE, Flags); /* Send WM_INITMENUPOPUP message only if TPM_NONOTIFY flag is not specified */ From 205fe71c5df45b5fdee7aa0297a4e68f11d6430f Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Sun, 28 Nov 2010 09:53:22 +0000 Subject: [PATCH 007/181] [CRT] Fix another typo svn path=/trunk/; revision=49836 --- reactos/lib/sdk/crt/setjmp/i386/setjmp.s | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reactos/lib/sdk/crt/setjmp/i386/setjmp.s b/reactos/lib/sdk/crt/setjmp/i386/setjmp.s index 68916996a4f..95c4aac27a3 100644 --- a/reactos/lib/sdk/crt/setjmp/i386/setjmp.s +++ b/reactos/lib/sdk/crt/setjmp/i386/setjmp.s @@ -109,6 +109,6 @@ _longjmp: mov esi, [ecx + JB_SI*4] mov esp, [ecx + JB_SP*4] /* Jump to saved PC. */ - jmp dword ptr [edx] + jmp edx END From 5afe6c4f39b672bcb50fd28b7d155b584ede190f Mon Sep 17 00:00:00 2001 From: Aleksey Bragin Date: Sun, 28 Nov 2010 12:10:59 +0000 Subject: [PATCH 008/181] [ATL] - Ettl Martin: Make CComCriticalSection destructor virtual. See issue #4975 for more details. svn path=/trunk/; revision=49840 --- reactos/lib/atl/atlcore.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reactos/lib/atl/atlcore.h b/reactos/lib/atl/atlcore.h index c2f22eacfdf..08e19d41382 100644 --- a/reactos/lib/atl/atlcore.h +++ b/reactos/lib/atl/atlcore.h @@ -43,7 +43,7 @@ public: memset(&m_sec, 0, sizeof(CRITICAL_SECTION)); } - ~CComCriticalSection() + virtual ~CComCriticalSection() { } From b0fb94b1f3ddcde521a000ed5cf993215d5f2a23 Mon Sep 17 00:00:00 2001 From: Pierre Schweitzer Date: Sun, 28 Nov 2010 16:33:56 +0000 Subject: [PATCH 009/181] [NTOSKRNL] Never read code & commit while being tired... svn path=/trunk/; revision=49848 --- reactos/ntoskrnl/fsrtl/dbcsname.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/reactos/ntoskrnl/fsrtl/dbcsname.c b/reactos/ntoskrnl/fsrtl/dbcsname.c index da0fd71cb47..903da2eeab3 100644 --- a/reactos/ntoskrnl/fsrtl/dbcsname.c +++ b/reactos/ntoskrnl/fsrtl/dbcsname.c @@ -140,7 +140,7 @@ FsRtlDoesDbcsContainWildCards(IN PANSI_STRING Name) /*++ * @name FsRtlIsDbcsInExpression - * @halfplemented + * @implemented * * Check if the Name string is in the Expression string. * @@ -152,7 +152,7 @@ FsRtlDoesDbcsContainWildCards(IN PANSI_STRING Name) * * @return TRUE if Name is found in Expression, FALSE otherwise * - * @remarks Implementation should be fixed to handle wildcards + * @remarks * *--*/ BOOLEAN From 14dc931ab1c3bb6d02c73a058ac0aa4dda829664 Mon Sep 17 00:00:00 2001 From: Amine Khaldi Date: Sun, 28 Nov 2010 16:38:51 +0000 Subject: [PATCH 010/181] [NTOSKRNL/MM] - Fix the use of an uninitialized variable. svn path=/trunk/; revision=49850 --- reactos/ntoskrnl/mm/ARM3/expool.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reactos/ntoskrnl/mm/ARM3/expool.c b/reactos/ntoskrnl/mm/ARM3/expool.c index 79e5ef95dc7..120050e6aca 100644 --- a/reactos/ntoskrnl/mm/ARM3/expool.c +++ b/reactos/ntoskrnl/mm/ARM3/expool.c @@ -248,7 +248,7 @@ VOID NTAPI ExpCheckPoolBlocks(IN PVOID Block) { - BOOLEAN FoundBlock; + BOOLEAN FoundBlock = FALSE; SIZE_T Size = 0; PPOOL_HEADER Entry; From e8615c4221d19591595660bd3e7c602d003dc859 Mon Sep 17 00:00:00 2001 From: Pierre Schweitzer Date: Sun, 28 Nov 2010 16:43:40 +0000 Subject: [PATCH 011/181] [DDK] FsRtlRemoveBaseMcbEntry() return is VOID svn path=/trunk/; revision=49851 --- reactos/include/ddk/ntifs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reactos/include/ddk/ntifs.h b/reactos/include/ddk/ntifs.h index 8c4f1a1bbad..a82cd79053a 100644 --- a/reactos/include/ddk/ntifs.h +++ b/reactos/include/ddk/ntifs.h @@ -7344,7 +7344,7 @@ FsRtlAddBaseMcbEntry( IN LONGLONG SectorCount); NTKERNELAPI -BOOLEAN +VOID NTAPI FsRtlRemoveBaseMcbEntry( IN PBASE_MCB Mcb, From 6a6c5e47e60bb42383ddb7049097b4e3ae66f805 Mon Sep 17 00:00:00 2001 From: Pierre Schweitzer Date: Sun, 28 Nov 2010 22:33:19 +0000 Subject: [PATCH 012/181] [NTOSKRNL/NEWCC] Init Dummy var even if just used for debug to suppress warning svn path=/trunk/; revision=49858 --- reactos/ntoskrnl/po/power.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/reactos/ntoskrnl/po/power.c b/reactos/ntoskrnl/po/power.c index 42a0bb854db..a4f45c0f38c 100644 --- a/reactos/ntoskrnl/po/power.c +++ b/reactos/ntoskrnl/po/power.c @@ -750,6 +750,8 @@ NtSetSystemPowerState(IN POWER_ACTION SystemAction, #ifndef NEWCC /* Flush dirty cache pages */ CcRosFlushDirtyPages(-1, &Dummy); +#else + Dummy = 0; #endif /* Flush all volumes and the registry */ From 081b22869e390014a774a64d0ac33dfdcfc1078c Mon Sep 17 00:00:00 2001 From: James Tabor Date: Mon, 29 Nov 2010 16:48:27 +0000 Subject: [PATCH 013/181] [User32] - Fixed export for PrintWindow see bug 5466 and 5609. svn path=/trunk/; revision=49861 --- reactos/dll/win32/user32/misc/stubs.c | 21 ++++----------------- reactos/dll/win32/user32/user32.pspec | 2 +- 2 files changed, 5 insertions(+), 18 deletions(-) diff --git a/reactos/dll/win32/user32/misc/stubs.c b/reactos/dll/win32/user32/misc/stubs.c index 354b5d3f31c..229c0a9bc7d 100644 --- a/reactos/dll/win32/user32/misc/stubs.c +++ b/reactos/dll/win32/user32/misc/stubs.c @@ -311,7 +311,7 @@ AlignRects(LPRECT rect, DWORD b, DWORD c, DWORD d) } /* - * @unimplemented + * @implemented */ LRESULT WINAPI @@ -320,8 +320,9 @@ DefRawInputProc( INT nInput, UINT cbSizeHeader) { - UNIMPLEMENTED; - return 0; + if (cbSizeHeader == sizeof(RAWINPUTHEADER)) + return S_OK; + return 1; } /* @@ -386,20 +387,6 @@ GetRegisteredRawInputDevices( return 0; } -/* - * @unimplemented - */ -BOOL -WINAPI -PrintWindow( - HWND hwnd, - HDC hdcBlt, - UINT nFlags) -{ - UNIMPLEMENTED; - return FALSE; -} - /* * @unimplemented */ diff --git a/reactos/dll/win32/user32/user32.pspec b/reactos/dll/win32/user32/user32.pspec index 603a025bf0d..3913a9a92df 100644 --- a/reactos/dll/win32/user32/user32.pspec +++ b/reactos/dll/win32/user32/user32.pspec @@ -526,7 +526,7 @@ @ stdcall PostQuitMessage(long) @ stdcall PostThreadMessageA(long long long long) @ stdcall PostThreadMessageW(long long long long) -; @ stub PrintWindow +@ stdcall PrintWindow(ptr ptr long) NtUserPrintWindow @ stdcall PrivateExtractIconExA(str long ptr ptr long) @ stdcall PrivateExtractIconExW(wstr long ptr ptr long) @ stdcall PrivateExtractIconsA(str long long long ptr ptr long long) From 76b3ad6788bb5bda66f138f4bc8016642734e1f8 Mon Sep 17 00:00:00 2001 From: Aleksey Bragin Date: Tue, 30 Nov 2010 16:29:49 +0000 Subject: [PATCH 014/181] [DDRAW] - Jerome Gardou: Almost all of the ddraw->refcount winetests pass. One remains, due to the fact that IdirectDrawSurface::SetPalette is unimplemented. IDirectDraw::Createpalette is implemented too, but needs testing. There are no parameter checks. - Comments from me: The patch is not build-tested, however I did my best to merge it to existing ddraw and I prefer the actual code to be in the repository rather than hanging in bugzilla for years (last comment to the patch is dated 29.10.2009). See issue #4909 for more details. svn path=/trunk/; revision=49872 --- .../directx/ddraw/Ddraw/callbacks_dd_hel.c | 41 ++++- reactos/dll/directx/ddraw/Ddraw/ddraw_main.c | 30 +++- reactos/dll/directx/ddraw/Ddraw/ddraw_stubs.c | 7 - .../dll/directx/ddraw/Palette/createpalette.c | 135 +++++++++++++++ reactos/dll/directx/ddraw/Palette/palette.c | 157 ++++++++++++++++++ .../dll/directx/ddraw/Surface/createsurface.c | 1 - .../dll/directx/ddraw/Surface/surface_main.c | 20 ++- .../ddraw/Vtable/DirectDrawSurface4_Vtable.c | 4 +- .../ddraw/Vtable/DirectDrawSurface7_Vtable.c | 4 +- reactos/dll/directx/ddraw/ddraw.rbuild | 5 +- reactos/dll/directx/ddraw/rosdraw.h | 6 +- reactos/dll/directx/ddraw/startup.c | 21 ++- 12 files changed, 406 insertions(+), 25 deletions(-) create mode 100644 reactos/dll/directx/ddraw/Palette/createpalette.c create mode 100644 reactos/dll/directx/ddraw/Palette/palette.c diff --git a/reactos/dll/directx/ddraw/Ddraw/callbacks_dd_hel.c b/reactos/dll/directx/ddraw/Ddraw/callbacks_dd_hel.c index 8592543152c..57c30e346d8 100644 --- a/reactos/dll/directx/ddraw/Ddraw/callbacks_dd_hel.c +++ b/reactos/dll/directx/ddraw/Ddraw/callbacks_dd_hel.c @@ -75,9 +75,46 @@ DWORD CALLBACK HelDdCanCreateSurface(LPDDHAL_CANCREATESURFACEDATA lpCanCreateSu DX_STUB; } -DWORD CALLBACK HelDdCreatePalette(LPDDHAL_CREATEPALETTEDATA lpCreatePalette) +DWORD CALLBACK HelDdCreatePalette(LPDDHAL_CREATEPALETTEDATA lpCreatePalette) { - DX_STUB; + DDRAWI_DDRAWPALETTE_GBL* ddPalGbl = lpCreatePalette->lpDDPalette; + LOGPALETTE* logPal ; + WORD size=1; + + if(ddPalGbl->dwFlags & DDRAWIPAL_2) + size = 2; + else if(ddPalGbl->dwFlags & DDRAWIPAL_4) + size = 4; + else if(ddPalGbl->dwFlags & DDRAWIPAL_16) + size = 16; + else if(ddPalGbl->dwFlags & DDRAWIPAL_256) + size = 256; + + DxHeapMemAlloc(logPal, sizeof(LOGPALETTE) + size*sizeof(PALETTEENTRY)); + if(logPal == NULL) + { + lpCreatePalette->ddRVal = DDERR_OUTOFMEMORY; + return DDHAL_DRIVER_HANDLED; + } + + logPal->palVersion = 0x300; + logPal->palNumEntries = size; + CopyMemory(&logPal->palPalEntry[0], lpCreatePalette->lpColorTable, size*sizeof(PALETTEENTRY)); + + ddPalGbl->hHELGDIPalette = CreatePalette(logPal); + + if (ddPalGbl->hHELGDIPalette == NULL) + { + DxHeapMemFree(logPal); + lpCreatePalette->ddRVal = DDERR_INVALIDOBJECT; + return DDHAL_DRIVER_HANDLED; + } + + DxHeapMemFree(logPal); + ddPalGbl->lpColorTable = lpCreatePalette->lpColorTable; + ddPalGbl->dwFlags |= DDRAWIPAL_INHEL | DDRAWIPAL_GDI ; + lpCreatePalette->ddRVal = DD_OK; + return DDHAL_DRIVER_HANDLED; } DWORD CALLBACK HelDdGetScanLine(LPDDHAL_GETSCANLINEDATA lpGetScanLine) diff --git a/reactos/dll/directx/ddraw/Ddraw/ddraw_main.c b/reactos/dll/directx/ddraw/Ddraw/ddraw_main.c index a3b307c8a04..fe02d0a0d76 100644 --- a/reactos/dll/directx/ddraw/Ddraw/ddraw_main.c +++ b/reactos/dll/directx/ddraw/Ddraw/ddraw_main.c @@ -533,6 +533,9 @@ Main_DirectDraw_CreateSurface4(LPDDRAWI_DIRECTDRAW_INT This, LPDDSURFACEDESC2 pD } _SEH2_END; + if(*ppSurf != NULL) + Main_DirectDraw_AddRef(This); + LeaveCriticalSection(&ddcs); return ret; } @@ -540,7 +543,32 @@ Main_DirectDraw_CreateSurface4(LPDDRAWI_DIRECTDRAW_INT This, LPDDSURFACEDESC2 pD /* 5 of 31 DirectDraw7_Vtable api are working simluare to windows */ /* 8 of 31 DirectDraw7_Vtable api are under devloping / testing */ - +HRESULT WINAPI Main_DirectDraw_CreatePalette(LPDDRAWI_DIRECTDRAW_INT This, DWORD dwFlags, + LPPALETTEENTRY palent, LPDIRECTDRAWPALETTE* ppPalette, LPUNKNOWN pUnkOuter) +{ + HRESULT ret = DD_OK; + DX_WINDBG_trace(); + + EnterCriticalSection(&ddcs); + *ppPalette = NULL; + + _SEH2_TRY + { + ret = Internal_CreatePalette(This, dwFlags, palent, ppPalette, pUnkOuter); + } + _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) + { + ret = DDERR_INVALIDPARAMS; + } + _SEH2_END; + + //Versions 7 and 4 are addref'ed + if((This->lpVtbl == &DirectDraw7_Vtable || This->lpVtbl == &DirectDraw4_Vtable) && *ppPalette != NULL) + Main_DirectDraw_AddRef(This) ; + + LeaveCriticalSection(&ddcs); + return ret; +} diff --git a/reactos/dll/directx/ddraw/Ddraw/ddraw_stubs.c b/reactos/dll/directx/ddraw/Ddraw/ddraw_stubs.c index a2c60e74b33..4f11676ea86 100644 --- a/reactos/dll/directx/ddraw/Ddraw/ddraw_stubs.c +++ b/reactos/dll/directx/ddraw/Ddraw/ddraw_stubs.c @@ -24,13 +24,6 @@ Main_DirectDraw_CreateClipper(LPDDRAWI_DIRECTDRAW_INT This, DX_STUB; } -HRESULT WINAPI Main_DirectDraw_CreatePalette(LPDDRAWI_DIRECTDRAW_INT This, DWORD dwFlags, - LPPALETTEENTRY palent, LPDIRECTDRAWPALETTE* ppPalette, LPUNKNOWN pUnkOuter) -{ - DX_WINDBG_trace(); - DX_STUB; -} - HRESULT WINAPI Main_DirectDraw_DuplicateSurface(LPDDRAWI_DIRECTDRAW_INT This, LPDIRECTDRAWSURFACE7 src, LPDIRECTDRAWSURFACE7* dst) { diff --git a/reactos/dll/directx/ddraw/Palette/createpalette.c b/reactos/dll/directx/ddraw/Palette/createpalette.c new file mode 100644 index 00000000000..87bb0a9f141 --- /dev/null +++ b/reactos/dll/directx/ddraw/Palette/createpalette.c @@ -0,0 +1,135 @@ +/* $Id$ + * + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS DirectX + * FILE: ddraw/surface/createsurface.c + * PURPOSE: IDirectDrawPalette Creation + * PROGRAMMER: Jérôme Gardou + * + */ +#include "rosdraw.h" + +DWORD ConvertPCapsFlags(DWORD dwFlags) +{ + DWORD ret = 0; + if(dwFlags & DDPCAPS_4BIT) + ret|=DDRAWIPAL_16; + if(dwFlags & DDPCAPS_8BIT) + ret|=DDRAWIPAL_256; + if(dwFlags & DDPCAPS_8BITENTRIES) + ret|=DDRAWIPAL_STORED_8INDEX; + if(dwFlags & DDPCAPS_ALLOW256) + ret|=DDRAWIPAL_ALLOW256; + if(dwFlags & DDPCAPS_ALPHA) + ret|=DDRAWIPAL_ALPHA; + if(dwFlags & DDPCAPS_1BIT) + ret|=DDRAWIPAL_2; + if(dwFlags & DDPCAPS_2BIT) + ret|=DDRAWIPAL_4; + + return ret; +} + +HRESULT +Internal_CreatePalette( LPDDRAWI_DIRECTDRAW_INT pDDraw, DWORD dwFlags, + LPPALETTEENTRY palent, LPDIRECTDRAWPALETTE* ppPalette, LPUNKNOWN pUnkOuter) +{ + DDHAL_CREATEPALETTEDATA mDdCreatePalette = { 0 }; + + LPDDRAWI_DDRAWPALETTE_INT ThisPalInt = NULL; + LPDDRAWI_DDRAWPALETTE_LCL ThisPalLcl = NULL; + LPDDRAWI_DDRAWPALETTE_GBL ThisPalGbl = NULL; + + HRESULT ret; + + if(pUnkOuter) + { + return CLASS_E_NOAGGREGATION; + } + + if(!(pDDraw->lpLcl->dwLocalFlags & DDRAWILCL_SETCOOPCALLED)) + { + return DDERR_NOCOOPERATIVELEVELSET; + } + + + if (pDDraw->lpLcl->dwProcessId != GetCurrentProcessId() ) + { + return DDERR_INVALIDOBJECT; + } + + /* Allocate the palette interface and needed members */ + DxHeapMemAlloc(ThisPalInt, sizeof( DDRAWI_DDRAWPALETTE_INT ) ); + if( ThisPalInt == NULL ) + { + ret = DDERR_OUTOFMEMORY; + goto cleanup; + } + + DxHeapMemAlloc(ThisPalLcl, sizeof( DDRAWI_DDRAWPALETTE_LCL ) ); + if( ThisPalLcl == NULL ) + { + ret = DDERR_OUTOFMEMORY; + goto cleanup; + } + + DxHeapMemAlloc(ThisPalGbl, sizeof( DDRAWI_DDRAWPALETTE_GBL ) ); + if( ThisPalGbl == NULL ) + { + ret = DDERR_OUTOFMEMORY; + goto cleanup; + } + + /*Some initial setup*/ + + ThisPalInt->lpLcl = ThisPalLcl; + ThisPalLcl->lpGbl = ThisPalGbl; + + ThisPalLcl->lpDD_lcl = ThisPalGbl->lpDD_lcl = pDDraw->lpLcl; + ThisPalGbl->dwFlags = ConvertPCapsFlags(dwFlags); + + ThisPalInt->lpVtbl = (PVOID)&DirectDrawPalette_Vtable; + ThisPalGbl->dwProcessId = GetCurrentProcessId(); + + mDdCreatePalette.lpDD = pDDraw->lpLcl->lpGbl; + mDdCreatePalette.lpDDPalette = ThisPalGbl; + if(pDDraw->lpLcl->lpGbl->lpDDCBtmp->HALDD.dwFlags & DDHAL_CB32_CREATEPALETTE) { + mDdCreatePalette.CreatePalette = pDDraw->lpLcl->lpGbl->lpDDCBtmp->HALDD.CreatePalette; + DX_STUB_str("Using HAL CreatePalette\n"); + } + else { + mDdCreatePalette.CreatePalette = pDDraw->lpLcl->lpGbl->lpDDCBtmp->HELDD.CreatePalette; + DX_STUB_str("Using HEL CreatePalette\n"); + } + mDdCreatePalette.ddRVal = DDERR_GENERIC; + mDdCreatePalette.lpColorTable = palent; + + if (mDdCreatePalette.CreatePalette(&mDdCreatePalette) == DDHAL_DRIVER_NOTHANDLED) + { + DX_STUB_str("mDdCreateSurface failed with DDHAL_DRIVER_NOTHANDLED."); + ret = DDERR_NOTINITIALIZED; + goto cleanup; + } + + if (mDdCreatePalette.ddRVal != DD_OK) + { + DX_STUB_str("mDdCreateSurface failed."); + ret = mDdCreatePalette.ddRVal; + goto cleanup; + } + + *ppPalette = (LPDIRECTDRAWPALETTE)ThisPalInt; + ThisPalInt->lpLink = pDDraw->lpLcl->lpGbl->palList; + pDDraw->lpLcl->lpGbl->palList = ThisPalInt; + ThisPalInt->lpLcl->dwReserved1 = (ULONG_PTR)pDDraw; + IDirectDrawPalette_AddRef(*ppPalette); + + return DD_OK; + +cleanup: + if(ThisPalInt) DxHeapMemFree(ThisPalInt); + if(ThisPalLcl) DxHeapMemFree(ThisPalLcl); + if(ThisPalGbl) DxHeapMemFree(ThisPalGbl); + + return ret; +} diff --git a/reactos/dll/directx/ddraw/Palette/palette.c b/reactos/dll/directx/ddraw/Palette/palette.c new file mode 100644 index 00000000000..c366be9206c --- /dev/null +++ b/reactos/dll/directx/ddraw/Palette/palette.c @@ -0,0 +1,157 @@ +/* $Id: palette.c $ + * + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS DirectX + * FILE: ddraw/Palette/palette.c + * PURPOSE: IDirectDrawPalette Implementation + * PROGRAMMER: Jérôme Gardou + * + */ + +#include "rosdraw.h" + +/***************************************************************************** + * IDirectDrawPalette::QueryInterface + * + * A usual QueryInterface implementation. Can only Query IUnknown and + * IDirectDrawPalette + * + * Params: + * refiid: The interface id queried for + * obj: Address to return the interface pointer at + * + * Returns: + * S_OK on success + * E_NOINTERFACE if the requested interface wasn't found + *****************************************************************************/ +static HRESULT WINAPI +DirectDrawPalette_QueryInterface(IDirectDrawPalette *iface, + REFIID refiid, + void **obj) +{ + if (IsEqualGUID(refiid, &IID_IUnknown) + || IsEqualGUID(refiid, &IID_IDirectDrawPalette)) + { + *obj = iface; + IDirectDrawPalette_AddRef(iface); + return S_OK; + } + else + { + *obj = NULL; + return E_NOINTERFACE; + } +} + +/***************************************************************************** + * IDirectDrawPaletteImpl::AddRef + * + * Increases the refcount. + * + * Returns: + * The new refcount + * + *****************************************************************************/ +static ULONG WINAPI +DirectDrawPalette_AddRef(IDirectDrawPalette *iface) +{ + LPDDRAWI_DDRAWPALETTE_INT This = (LPDDRAWI_DDRAWPALETTE_INT)iface; + ULONG ref = 0; + + _SEH2_TRY + { + ref = ++This->dwIntRefCnt; + } + _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) + { + } + _SEH2_END + + return ref; +} + +/***************************************************************************** + * IDirectDrawPaletteImpl::Release + * + * Reduces the refcount. If the refcount falls to 0, the object is destroyed + * + * Returns: + * The new refcount + * + *****************************************************************************/ +static ULONG WINAPI +DirectDrawPalette_Release(IDirectDrawPalette *iface) +{ + LPDDRAWI_DDRAWPALETTE_INT This = (LPDDRAWI_DDRAWPALETTE_INT)iface; + ULONG ref = 0; + + _SEH2_TRY + { + ref = --This->dwIntRefCnt; + if(ref == 0) + { + AcquireDDThreadLock(); + if(((LPDDRAWI_DIRECTDRAW_INT)This->lpLcl->dwReserved1)->lpVtbl == &DirectDraw7_Vtable + || ((LPDDRAWI_DIRECTDRAW_INT)This->lpLcl->dwReserved1)->lpVtbl == &DirectDraw4_Vtable) + Main_DirectDraw_Release((LPDDRAWI_DIRECTDRAW_INT)This->lpLcl->dwReserved1) ; + DxHeapMemFree(This); //HUGE FIXME!!! + ReleaseDDThreadLock(); + } + } + _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) + { + } + _SEH2_END + + return ref; +} + +static HRESULT WINAPI +DirectDrawPalette_Initialize( LPDIRECTDRAWPALETTE iface, + LPDIRECTDRAW ddraw, + DWORD dwFlags, + LPPALETTEENTRY palent) +{ + DX_WINDBG_trace(); + DX_STUB; +} + +static HRESULT WINAPI +DirectDrawPalette_GetEntries( LPDIRECTDRAWPALETTE iface, + DWORD dwFlags, + DWORD dwStart, DWORD dwCount, + LPPALETTEENTRY palent) +{ + DX_WINDBG_trace(); + DX_STUB; +} + +static HRESULT WINAPI +DirectDrawPalette_SetEntries( LPDIRECTDRAWPALETTE iface, + DWORD dwFlags, + DWORD dwStart, + DWORD dwCount, + LPPALETTEENTRY palent) +{ + DX_WINDBG_trace(); + DX_STUB; +} + +static HRESULT WINAPI +DirectDrawPalette_GetCaps( LPDIRECTDRAWPALETTE iface, + LPDWORD lpdwCaps) +{ + DX_WINDBG_trace(); + DX_STUB; +} + +const IDirectDrawPaletteVtbl DirectDrawPalette_Vtable = +{ + DirectDrawPalette_QueryInterface, + DirectDrawPalette_AddRef, + DirectDrawPalette_Release, + DirectDrawPalette_GetCaps, + DirectDrawPalette_GetEntries, + DirectDrawPalette_Initialize, + DirectDrawPalette_SetEntries +}; diff --git a/reactos/dll/directx/ddraw/Surface/createsurface.c b/reactos/dll/directx/ddraw/Surface/createsurface.c index c34396f309d..d6d95579a3d 100644 --- a/reactos/dll/directx/ddraw/Surface/createsurface.c +++ b/reactos/dll/directx/ddraw/Surface/createsurface.c @@ -182,7 +182,6 @@ Internal_CreateSurface( LPDDRAWI_DIRECTDRAW_INT pDDraw, LPDDSURFACEDESC2 pDDSD, /* FIXME ThisSurfaceMore->dmiDDrawReserved7.wMonitorsAttachedToDesktop */ ThisSurfMore->dmiDDrawReserved7.wMonitorsAttachedToDesktop = 1; pDDraw->lpLcl->lpPrimary = ThisSurfInt; - Main_DirectDraw_AddRef(pDDraw); } else { diff --git a/reactos/dll/directx/ddraw/Surface/surface_main.c b/reactos/dll/directx/ddraw/Surface/surface_main.c index 28bc2c34bb1..81abdf8f88d 100644 --- a/reactos/dll/directx/ddraw/Surface/surface_main.c +++ b/reactos/dll/directx/ddraw/Surface/surface_main.c @@ -264,14 +264,28 @@ Main_DDrawSurface_QueryInterface(LPDDRAWI_DDRAWSURFACE_INT This, REFIID riid, LP ULONG WINAPI Main_DDrawSurface_Release(LPDDRAWI_DDRAWSURFACE_INT This) { - /* FIXME This is not right exiame how it should be done */ - DX_STUB_str("FIXME This is not right exiame how it should be done\n"); - return This->dwIntRefCnt; + ULONG ret = --This->dwIntRefCnt; + if(!ret) + { + DX_STUB_str("Release is a bit simplistic right now\n"); + AcquireDDThreadLock(); + DxHeapMemFree(This); + ReleaseDDThreadLock(); + } + return ret; } +ULONG WINAPI Main_DDrawSurface_Release4(LPDDRAWI_DDRAWSURFACE_INT This) +{ + ULONG ref = Main_DDrawSurface_Release(This) ; + + if(ref == 0) Main_DirectDraw_Release(This->lpLcl->lpSurfMore->lpDD_int); + + return ref; +} HRESULT WINAPI Main_DDrawSurface_Blt(LPDDRAWI_DDRAWSURFACE_INT ThisDest, LPRECT rdst, LPDDRAWI_DDRAWSURFACE_INT ThisSrc, LPRECT rsrc, DWORD dwFlags, LPDDBLTFX lpbltfx) diff --git a/reactos/dll/directx/ddraw/Vtable/DirectDrawSurface4_Vtable.c b/reactos/dll/directx/ddraw/Vtable/DirectDrawSurface4_Vtable.c index 3041906f21c..57fd0a4e3c5 100644 --- a/reactos/dll/directx/ddraw/Vtable/DirectDrawSurface4_Vtable.c +++ b/reactos/dll/directx/ddraw/Vtable/DirectDrawSurface4_Vtable.c @@ -16,7 +16,7 @@ #endif ULONG WINAPI Main_DDrawSurface_AddRef(LPDIRECTDRAWSURFACE4); -ULONG WINAPI Main_DDrawSurface_Release(LPDIRECTDRAWSURFACE4); +ULONG WINAPI Main_DDrawSurface_Release4(LPDIRECTDRAWSURFACE4); HRESULT WINAPI Main_DDrawSurface_QueryInterface(LPDIRECTDRAWSURFACE4, REFIID, LPVOID*); HRESULT WINAPI Main_DDrawSurface_ReleaseDC(LPDIRECTDRAWSURFACE4, HDC); HRESULT WINAPI Main_DDrawSurface_Blt(LPDIRECTDRAWSURFACE4, LPRECT, LPDIRECTDRAWSURFACE4, LPRECT, DWORD, LPDDBLTFX); @@ -68,7 +68,7 @@ IDirectDrawSurface4Vtbl DirectDrawSurface4_Vtable = { Main_DDrawSurface_QueryInterface, Main_DDrawSurface_AddRef, /* (Compact done) */ - Main_DDrawSurface_Release, + Main_DDrawSurface_Release4, Main_DDrawSurface_AddAttachedSurface, Main_DDrawSurface_AddOverlayDirtyRect, Main_DDrawSurface_Blt, diff --git a/reactos/dll/directx/ddraw/Vtable/DirectDrawSurface7_Vtable.c b/reactos/dll/directx/ddraw/Vtable/DirectDrawSurface7_Vtable.c index 97e92008ae9..07037c0ddb6 100644 --- a/reactos/dll/directx/ddraw/Vtable/DirectDrawSurface7_Vtable.c +++ b/reactos/dll/directx/ddraw/Vtable/DirectDrawSurface7_Vtable.c @@ -16,7 +16,7 @@ #endif ULONG WINAPI Main_DDrawSurface_AddRef(LPDIRECTDRAWSURFACE7); -ULONG WINAPI Main_DDrawSurface_Release(LPDIRECTDRAWSURFACE7); +ULONG WINAPI Main_DDrawSurface_Release4(LPDIRECTDRAWSURFACE7); HRESULT WINAPI Main_DDrawSurface_QueryInterface(LPDIRECTDRAWSURFACE7, REFIID, LPVOID*); HRESULT WINAPI Main_DDrawSurface_ReleaseDC(LPDIRECTDRAWSURFACE7, HDC); HRESULT WINAPI Main_DDrawSurface_Blt(LPDIRECTDRAWSURFACE7, LPRECT, LPDIRECTDRAWSURFACE7, LPRECT, DWORD, LPDDBLTFX); @@ -72,7 +72,7 @@ IDirectDrawSurface7Vtbl DirectDrawSurface7_Vtable = { Main_DDrawSurface_QueryInterface, Main_DDrawSurface_AddRef, /* (Compact done) */ - Main_DDrawSurface_Release, + Main_DDrawSurface_Release4, Main_DDrawSurface_AddAttachedSurface, Main_DDrawSurface_AddOverlayDirtyRect, Main_DDrawSurface_Blt, diff --git a/reactos/dll/directx/ddraw/ddraw.rbuild b/reactos/dll/directx/ddraw/ddraw.rbuild index a678e62164e..016afa6090a 100644 --- a/reactos/dll/directx/ddraw/ddraw.rbuild +++ b/reactos/dll/directx/ddraw/ddraw.rbuild @@ -8,7 +8,7 @@ d3d8thk dxguid ole32 - user32 + uuid advapi32 pseh @@ -49,7 +49,8 @@ kernel_stubs.c - palette_stubs.c + palette.c + createpalette.c videoport_stubs.c diff --git a/reactos/dll/directx/ddraw/rosdraw.h b/reactos/dll/directx/ddraw/rosdraw.h index 6cb0f2088c8..9b50c1c7eda 100644 --- a/reactos/dll/directx/ddraw/rosdraw.h +++ b/reactos/dll/directx/ddraw/rosdraw.h @@ -34,7 +34,7 @@ extern IDirectDrawSurface4Vtbl DirectDrawSurface4_Vtable; extern IDirectDrawSurface3Vtbl DirectDrawSurface3_Vtable; extern IDirectDrawSurface2Vtbl DirectDrawSurface2_Vtable; extern IDirectDrawSurfaceVtbl DirectDrawSurface_Vtable; -extern IDirectDrawPaletteVtbl DirectDrawPalette_Vtable; +extern const IDirectDrawPaletteVtbl DirectDrawPalette_Vtable; extern IDirectDrawClipperVtbl DirectDrawClipper_Vtable; extern IDirectDrawColorControlVtbl DirectDrawColorControl_Vtable; extern IDirectDrawGammaControlVtbl DirectDrawGammaControl_Vtable; @@ -93,6 +93,10 @@ Internal_CreateSurface( LPDDRAWI_DDRAWSURFACE_INT *ppSurf, IUnknown *pUnkOuter); +HRESULT +Internal_CreatePalette( LPDDRAWI_DIRECTDRAW_INT pDDraw, DWORD dwFlags, + LPPALETTEENTRY palent, LPDIRECTDRAWPALETTE* ppPalette, LPUNKNOWN pUnkOuter); + /* convert DDSURFACEDESC to DDSURFACEDESC2 */ void CopyDDSurfDescToDDSurfDesc2(LPDDSURFACEDESC2 dst_pDesc, LPDDSURFACEDESC src_pDesc); diff --git a/reactos/dll/directx/ddraw/startup.c b/reactos/dll/directx/ddraw/startup.c index e1158af974a..6a5c6ba9d33 100644 --- a/reactos/dll/directx/ddraw/startup.c +++ b/reactos/dll/directx/ddraw/startup.c @@ -24,17 +24,29 @@ Create_DirectDraw (LPGUID pGUID, LPDIRECTDRAW* pIface, LPDDRAWI_DIRECTDRAW_INT This; DX_WINDBG_trace(); + BOOL linking = FALSE; - if ((IsBadReadPtr(pIface,sizeof(LPDIRECTDRAW))) || - (IsBadWritePtr(pIface,sizeof(LPDIRECTDRAW)))) + if (pIface == NULL) { return DDERR_INVALIDPARAMS; } This = (LPDDRAWI_DIRECTDRAW_INT)*pIface; - if ( (IsBadWritePtr(This,sizeof(LPDDRAWI_DIRECTDRAW_INT)) != 0) || - (IsBadWritePtr(This->lpLcl,sizeof(LPDDRAWI_DIRECTDRAW_LCL)) != 0) ) + DX_STUB_str("Linking?\n") + + _SEH2_TRY + { + linking = This->lpLcl ? TRUE:FALSE; + } + _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) + { + linking = FALSE; + } + _SEH2_END; + + /* fixme linking too second link when we shall not doing it */ + if (!linking) { /* We do not have a DirectDraw interface, we need alloc it*/ LPDDRAWI_DIRECTDRAW_INT memThis; @@ -310,6 +322,7 @@ StartDirectDraw(LPDIRECTDRAW iface, LPGUID lpGuid, BOOL reenable) return DDERR_NODIRECTDRAWSUPPORT; } dwFlags |= DDRAWI_NOHARDWARE; + DX_STUB_str("No hardware support\n"); } if (hel_ret!=DD_OK) From 7ca7ff0cbd21af0e5963d96697bd510247452ed7 Mon Sep 17 00:00:00 2001 From: Aleksey Bragin Date: Tue, 30 Nov 2010 16:38:53 +0000 Subject: [PATCH 015/181] [CMD] - Carlo Bramix: MultiByteToWideChar() has just 6 and not 8 parameters, probably it's a forgetten copy/past from WideCharToMultiByte(). - Carlo Bramix: ConvertULargeInteger() should have its parameter 'Len' declared as UINT rather than 'INT'. This fixes a signed/unsigned mismatch warning. See issue #5678 for more details. svn path=/trunk/; revision=49873 --- reactos/base/shell/cmd/cmd.c | 2 +- reactos/base/shell/cmd/cmd.h | 2 +- reactos/base/shell/cmd/console.c | 2 +- reactos/base/shell/cmd/precomp.h | 1 + 4 files changed, 4 insertions(+), 3 deletions(-) diff --git a/reactos/base/shell/cmd/cmd.c b/reactos/base/shell/cmd/cmd.c index 09f362d73af..1c63be6e5e1 100644 --- a/reactos/base/shell/cmd/cmd.c +++ b/reactos/base/shell/cmd/cmd.c @@ -180,7 +180,7 @@ WORD wDefColor; /* default color */ * insert commas into a number */ INT -ConvertULargeInteger(ULONGLONG num, LPTSTR des, INT len, BOOL bPutSeperator) +ConvertULargeInteger(ULONGLONG num, LPTSTR des, UINT len, BOOL bPutSeperator) { TCHAR temp[39]; /* maximum length with nNumberGroups == 1 */ UINT n, iTarget; diff --git a/reactos/base/shell/cmd/cmd.h b/reactos/base/shell/cmd/cmd.h index c6605de480f..9344ac9372f 100644 --- a/reactos/base/shell/cmd/cmd.h +++ b/reactos/base/shell/cmd/cmd.h @@ -99,7 +99,7 @@ INT cmd_cls (LPTSTR); /* Prototypes for CMD.C */ -INT ConvertULargeInteger(ULONGLONG num, LPTSTR des, INT len, BOOL bPutSeperator); +INT ConvertULargeInteger(ULONGLONG num, LPTSTR des, UINT len, BOOL bPutSeperator); HANDLE RunFile(DWORD, LPTSTR, LPTSTR, LPTSTR, INT); INT ParseCommandLine(LPTSTR); struct _PARSED_COMMAND; diff --git a/reactos/base/shell/cmd/console.c b/reactos/base/shell/cmd/console.c index 8184af747ea..e5830586305 100644 --- a/reactos/base/shell/cmd/console.c +++ b/reactos/base/shell/cmd/console.c @@ -131,7 +131,7 @@ static VOID ConWrite(TCHAR *str, DWORD len, DWORD nStdHandle) error_out_of_memory(); return; } - len = MultiByteToWideChar(OutputCodePage, 0, str, len, buffer, len, NULL, NULL); + len = MultiByteToWideChar(OutputCodePage, 0, str, len, buffer, len); str = (PVOID)buffer; #endif WriteFile(hOutput, str, len * sizeof(WCHAR), &dwWritten, NULL); diff --git a/reactos/base/shell/cmd/precomp.h b/reactos/base/shell/cmd/precomp.h index 915246cceb8..3eb404b69c4 100644 --- a/reactos/base/shell/cmd/precomp.h +++ b/reactos/base/shell/cmd/precomp.h @@ -23,6 +23,7 @@ #include #include #include +#include #define NTOS_MODE_USER #include From ed5da47acdff9e0b20ea47414d97e5d6f7dd8bd6 Mon Sep 17 00:00:00 2001 From: Aleksey Bragin Date: Tue, 30 Nov 2010 19:14:41 +0000 Subject: [PATCH 016/181] [FINDSTR] - Port findstr (incomplete, as author of this patch states, it may satisfy RosBE, .c .h and .rc files) from FreeDOS project. Needed for RosBE-on-ReactOS support. See issue #5724 for more details. svn path=/trunk/; revision=49875 --- reactos/base/applications/applications.rbuild | 3 + reactos/base/applications/findstr/findstr.c | 295 ++++++++++++++++++ .../base/applications/findstr/findstr.rbuild | 8 + reactos/base/applications/findstr/findstr.rc | 6 + .../base/applications/findstr/lang/bg-BG.rc | 17 + .../base/applications/findstr/lang/ca-ES.rc | 17 + .../base/applications/findstr/lang/cs-CZ.rc | 23 ++ .../base/applications/findstr/lang/de-DE.rc | 17 + .../base/applications/findstr/lang/el-GR.rc | 17 + .../base/applications/findstr/lang/en-US.rc | 17 + .../base/applications/findstr/lang/es-ES.rc | 17 + .../base/applications/findstr/lang/fr-FR.rc | 17 + .../base/applications/findstr/lang/it-IT.rc | 17 + .../base/applications/findstr/lang/lt-LT.rc | 26 ++ .../base/applications/findstr/lang/no-NO.rc | 17 + .../base/applications/findstr/lang/pl-PL.rc | 24 ++ .../base/applications/findstr/lang/pt-BR.rc | 17 + .../base/applications/findstr/lang/ru-RU.rc | 17 + .../base/applications/findstr/lang/sk-SK.rc | 21 ++ .../base/applications/findstr/lang/sv-SE.rc | 17 + .../base/applications/findstr/lang/uk-UA.rc | 25 ++ reactos/base/applications/findstr/resource.h | 3 + reactos/base/applications/findstr/rsrc.rc | 20 ++ reactos/boot/bootdata/packages/reactos.dff | 1 + 24 files changed, 659 insertions(+) create mode 100644 reactos/base/applications/findstr/findstr.c create mode 100644 reactos/base/applications/findstr/findstr.rbuild create mode 100644 reactos/base/applications/findstr/findstr.rc create mode 100644 reactos/base/applications/findstr/lang/bg-BG.rc create mode 100644 reactos/base/applications/findstr/lang/ca-ES.rc create mode 100644 reactos/base/applications/findstr/lang/cs-CZ.rc create mode 100644 reactos/base/applications/findstr/lang/de-DE.rc create mode 100644 reactos/base/applications/findstr/lang/el-GR.rc create mode 100644 reactos/base/applications/findstr/lang/en-US.rc create mode 100644 reactos/base/applications/findstr/lang/es-ES.rc create mode 100644 reactos/base/applications/findstr/lang/fr-FR.rc create mode 100644 reactos/base/applications/findstr/lang/it-IT.rc create mode 100644 reactos/base/applications/findstr/lang/lt-LT.rc create mode 100644 reactos/base/applications/findstr/lang/no-NO.rc create mode 100644 reactos/base/applications/findstr/lang/pl-PL.rc create mode 100644 reactos/base/applications/findstr/lang/pt-BR.rc create mode 100644 reactos/base/applications/findstr/lang/ru-RU.rc create mode 100644 reactos/base/applications/findstr/lang/sk-SK.rc create mode 100644 reactos/base/applications/findstr/lang/sv-SE.rc create mode 100644 reactos/base/applications/findstr/lang/uk-UA.rc create mode 100644 reactos/base/applications/findstr/resource.h create mode 100644 reactos/base/applications/findstr/rsrc.rc diff --git a/reactos/base/applications/applications.rbuild b/reactos/base/applications/applications.rbuild index 232b44c0868..0a1265ce571 100644 --- a/reactos/base/applications/applications.rbuild +++ b/reactos/base/applications/applications.rbuild @@ -22,6 +22,9 @@ + + + diff --git a/reactos/base/applications/findstr/findstr.c b/reactos/base/applications/findstr/findstr.c new file mode 100644 index 00000000000..681bff7ee53 --- /dev/null +++ b/reactos/base/applications/findstr/findstr.c @@ -0,0 +1,295 @@ +/* findstr.c */ + +/* Copyright (C) 1994-2002, Jim Hall */ + +/* Adapted for ReactOS -Edited for Findstr.exe K'Williams */ + +/* + 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., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ + + +/* This program locates a string in a text file and prints those lines + * that contain the string. Multiple files are clearly separated. + */ + +#include +#include +#include +#include +#include + +#include +#include + +#include "resource.h" + + +/* Symbol definition */ +#define MAX_STR 1024 + + +/* This function prints out all lines containing a substring. There are some + * conditions that may be passed to the function. + * + * RETURN: If the string was found at least once, returns 1. + * If the string was not found at all, returns 0. + */ +int +find_str (char *sz, FILE *p, int invert_search, + int count_lines, int number_output, int ignore_case, int at_start, int literal_search, + int at_end, int reg_express, int exact_match, int sub_dirs, int only_fname) +{ + int i, length; + long line_number = 0, total_lines = 0; + char *c, temp_str[MAX_STR], this_line[MAX_STR]; + + /* Convert to upper if needed */ + if (ignore_case) + { + length = strlen (sz); + for (i = 0; i < length; i++) + sz[i] = toupper (sz[i]); + } + + /* Scan the file until EOF */ + while (fgets (temp_str, MAX_STR, p) != NULL) + { + /* Remove the trailing newline */ + length = strlen (temp_str); + if (temp_str[length-1] == '\n') + { + temp_str[length-1] = '\0'; + } + + /* Increment number of lines */ + line_number++; + strcpy (this_line, temp_str); + + /* Convert to upper if needed */ + if (ignore_case) + { + for (i = 0; i < length; i++) + { + temp_str[i] = toupper (temp_str[i]); + } + } + + /* Locate the substring */ + + /* strstr() returns a pointer to the first occurrence in the + string of the substring */ + c = strstr (temp_str, sz); + + if ( ((invert_search) ? (c == NULL) : (c != NULL)) ) + { + if (!count_lines) + { + if (number_output) + printf ("%ld:", line_number); + + /* Print the line of text */ + puts (this_line); + } + + total_lines++; + } /* long if */ + } /* while fgets */ + + if (count_lines) + { + /* Just show num. lines that contain the string */ + printf ("%ld\n", total_lines); + } + + + /* RETURN: If the string was found at least once, returns 1. + * If the string was not found at all, returns 0. + */ + return (total_lines > 0 ? 1 : 0); +} + +/* Show usage */ +void +usage (void) +{ + TCHAR lpUsage[4096]; + + LoadString( GetModuleHandle(NULL), IDS_USAGE, (LPTSTR)lpUsage, 4096); + CharToOem(lpUsage, lpUsage); + printf( lpUsage ); +} + + +/* Main program */ +int +main (int argc, char **argv) +{ + char *opt, *needle = NULL; + int ret = 0; + TCHAR lpMessage[4096]; + + int invert_search = 0; /* flag to invert the search */ + int count_lines = 0; /* flag to whether/not count lines */ + int number_output = 0; /* flag to print line numbers */ + int ignore_case = 0; /* flag to be case insensitive */ + int at_start = 0; /* flag to Match if at the beginning of a line. */ + int at_end = 0; /* flag to Match if at the beginning of a line. */ + int reg_express = 0; /* flag to use/not use regular expressions */ + int exact_match = 0; /* flag to be exact match */ + int sub_dirs= 0; /* this and all subdirectories */ + int only_fname= 0; /* print only the name of the file*/ + int literal_search=0; + + FILE *pfile; /* file pointer */ + int hfind; /* search handle */ + struct _finddata_t finddata; /* _findfirst, filenext block */ + + /* Scan the command line */ + while ((--argc) && (needle == NULL)) + { + if (*(opt = *++argv) == '/') + { + switch (opt[1]) + { + case 'b': + case 'B': /* Matches pattern if at the beginning of a line */ + at_start = 1; + break; + + //case 'c': + //case 'C': /* Literal? */ + // literal_search = 1; + // break; + + case 'e': + case 'E': /* matches pattern if at end of line */ + at_end = 1; + break; + + case 'i': + case 'I': /* Ignore */ + ignore_case = 1; + break; + + case 'm': + case 'M': /* only filename */ + only_fname = 1; + break; + + case 'n': + case 'N': /* Number */ + number_output = 1; + break; + + case 'r': + case 'R': /* search strings as regular expressions */ + reg_express = 1; + break; + + case 's': + case 'S': /* search files in child directory too*/ + sub_dirs = 1; + break; + + case 'v': + case 'V': /* Not with */ + invert_search = 1; + break; + + case 'x': + case 'X': /* exact match */ + exact_match = 1; + break; + + default: + usage (); + exit (2); /* syntax error .. return error 2 */ + break; + } + } + else + { + /* Get the string */ + if (needle == NULL) + { + /* Assign the string to find */ + needle = *argv; + } + } + } + + /* Check for search string */ + if (needle == NULL) + { + /* No string? */ + usage (); + exit (1); + } + + /* Scan the files for the string */ + if (argc == 0) + { + ret = find_str (needle, stdin, invert_search, count_lines, + number_output, ignore_case, at_start, literal_search, at_end, reg_express, exact_match, + sub_dirs, only_fname); + } + + while (--argc >= 0) + { + hfind = _findfirst (*++argv, &finddata); + if (hfind < 0) + { + /* We were not able to find a file. Display a message and + set the exit status. */ + LoadString( GetModuleHandle(NULL), IDS_NO_SUCH_FILE, (LPTSTR)lpMessage, 4096); + CharToOem(lpMessage, lpMessage); + fprintf (stderr, lpMessage, *argv);// + } + else + { + /* repeat find next file to match the filemask */ + do + { + /* We have found a file, so try to open it */ + if ((pfile = fopen (finddata.name, "r")) != NULL) + { + printf ("---------------- %s\n", finddata.name); + ret = find_str (needle, pfile, invert_search, count_lines, + number_output, ignore_case, at_start, literal_search, at_end, reg_express, exact_match, + sub_dirs, only_fname); + fclose (pfile); + } + else + { + LoadString(GetModuleHandle(NULL), IDS_CANNOT_OPEN, (LPTSTR)lpMessage, 4096); + CharToOem(lpMessage, lpMessage); + fprintf (stderr, lpMessage, + finddata.name); + } + } + while (_findnext(hfind, &finddata) > 0); + } + _findclose(hfind); + } /* for each argv */ + + /* RETURN: If the string was found at least once, returns 0. + * If the string was not found at all, returns 1. + * (Note that find_str.c returns the exact opposite values.) + */ + exit ( (ret ? 0 : 1) ); +} + + diff --git a/reactos/base/applications/findstr/findstr.rbuild b/reactos/base/applications/findstr/findstr.rbuild new file mode 100644 index 00000000000..64306e39df8 --- /dev/null +++ b/reactos/base/applications/findstr/findstr.rbuild @@ -0,0 +1,8 @@ + + + + user32 + findstr.c + findstr.rc + rsrc.rc + diff --git a/reactos/base/applications/findstr/findstr.rc b/reactos/base/applications/findstr/findstr.rc new file mode 100644 index 00000000000..8d50fbaa345 --- /dev/null +++ b/reactos/base/applications/findstr/findstr.rc @@ -0,0 +1,6 @@ +#define REACTOS_STR_FILE_DESCRIPTION "W32 findstr command\0" +#define REACTOS_STR_INTERNAL_NAME "findstr\0" +#define REACTOS_STR_ORIGINAL_FILENAME "findstr.exe\0" +#include + +#include "rsrc.rc" diff --git a/reactos/base/applications/findstr/lang/bg-BG.rc b/reactos/base/applications/findstr/lang/bg-BG.rc new file mode 100644 index 00000000000..3f7cd7fde86 --- /dev/null +++ b/reactos/base/applications/findstr/lang/bg-BG.rc @@ -0,0 +1,17 @@ +LANGUAGE LANG_BULGARIAN, SUBLANG_DEFAULT + +STRINGTABLE DISCARDABLE +BEGIN + +IDS_USAGE, "FIND: Èçâåæäà âñè÷êè ðåäîâå âúâ ôàéëà, êîèòî ñúäúðæàò óêàçàíèÿ íèç..\n\n\ + FIND [ /C ] [ /I ] [ /N ] [ /V ] \"íèç\" [ ôàéë... ]\n\ + /C Áðîè êîëêî ðåäà ñúäúðæàò íèçà\n\ + /I Ïðåíåáðåãâà ÃëÀâÍÎñÒòà\n\ + /N Áðîé ïîêàçàíè ðåäîâå, êàòî ñå çàïî÷âà îò 1\n\ + /V Èçâåæäàíå íà ðåäîâåòå, ÍÅñúäúðæàùè íèçà." + +IDS_NO_SUCH_FILE, "FIND: %s: Íÿìà òàêúâ ôàéë\n" + +IDS_CANNOT_OPEN, "FIND: %s: Îòâàðÿíåòî íà ôàéëà å íåâúçìîæíî\n" + +END diff --git a/reactos/base/applications/findstr/lang/ca-ES.rc b/reactos/base/applications/findstr/lang/ca-ES.rc new file mode 100644 index 00000000000..932d4bc06bc --- /dev/null +++ b/reactos/base/applications/findstr/lang/ca-ES.rc @@ -0,0 +1,17 @@ +LANGUAGE LANG_CATALAN, SUBLANG_DEFAULT + +STRINGTABLE DISCARDABLE +BEGIN + +IDS_USAGE, "FIND: Mostra totes les linies que continguin una determinada cadena de caràcters.\n\n\ + FIND [ /C ] [ /I ] [ /N ] [ /V ] \"Cadena de caràcters\" [ file... ]\n\ + /C Conta el numero de linies que contenen la cadena de caràcters\n\ + /I Ignora majúscules i minúscules\n\ + /N Numero de linies mostrades, començant per la primera\n\ + /V Mostra les linies que no contenen la cadena de caràcters" + +IDS_NO_SUCH_FILE, "FIND: %s: No he trobat el fitxer\n" + +IDS_CANNOT_OPEN, "FIND: %s: No puc obrir el fitxer\n" + +END diff --git a/reactos/base/applications/findstr/lang/cs-CZ.rc b/reactos/base/applications/findstr/lang/cs-CZ.rc new file mode 100644 index 00000000000..8a41024c73b --- /dev/null +++ b/reactos/base/applications/findstr/lang/cs-CZ.rc @@ -0,0 +1,23 @@ +/* FILE: applications/cmdutils/find/lang/cs-CZ.rc + * TRANSLATOR: Radek Liska aka Black_Fox (radekliska at gmail dot com) + * THANKS TO: Mario Kacmar aka Kario (kario@szm.sk) + * UPDATED: 2008-02-29 + */ + +LANGUAGE LANG_CZECH, SUBLANG_DEFAULT + +STRINGTABLE DISCARDABLE +BEGIN + +IDS_USAGE, "FIND: Zobrazí všechny øádky souboru obsahující hledaný øetìzec.\n\n\ + FIND [ /C ] [ /I ] [ /N ] [ /V ] \"øetìzec\" [ soubor... ]\n\ + /C Zobrazí poèet øádkù obsahující øetìzec.\n\ + /I Ignoruje velikost písmen.\n\ + /N Èísluje zobrazené øádky, zaèíná od 1.\n\ + /V Zobrazí všechny øádky, které NEobsahují zadaný øetìžec." + +IDS_NO_SUCH_FILE, "FIND: Soubor %s nebyl nalezen.\n" + +IDS_CANNOT_OPEN, "FIND: Soubor %s nelze otevøít!\n" + +END diff --git a/reactos/base/applications/findstr/lang/de-DE.rc b/reactos/base/applications/findstr/lang/de-DE.rc new file mode 100644 index 00000000000..1663cc7aff7 --- /dev/null +++ b/reactos/base/applications/findstr/lang/de-DE.rc @@ -0,0 +1,17 @@ +LANGUAGE LANG_GERMAN, SUBLANG_NEUTRAL + +STRINGTABLE DISCARDABLE +BEGIN + +IDS_USAGE, "Sucht in einer Datei nach einer Zeichenfolge.\n\n\ + FIND [ /C ] [ /I ] [ /N ] [ /V ] \"string\" [ file... ]\n\ + /C Zeigt nur die Anzahl der die Zeichenfolge enthaltenen Zeilen an.\n\ + /I Ignoriert Groß-/Kleinbuchstaben bei der Suche.\n\ + /N Zeigt die Zeilen mit ihren Zeilennummern an.\n\ + /V Zeigt alle Zeilen an, die die Zeichenfolge NICHT enhalten." + +IDS_NO_SUCH_FILE, "Datei %s nicht gefunden\n" + +IDS_CANNOT_OPEN, "Datei %s kann nicht geöffnet werden.\n" + +END diff --git a/reactos/base/applications/findstr/lang/el-GR.rc b/reactos/base/applications/findstr/lang/el-GR.rc new file mode 100644 index 00000000000..19e993dda46 --- /dev/null +++ b/reactos/base/applications/findstr/lang/el-GR.rc @@ -0,0 +1,17 @@ +LANGUAGE LANG_GREEK, SUBLANG_DEFAULT + +STRINGTABLE DISCARDABLE +BEGIN + +IDS_USAGE, "FIND: Åêôõðþíåé üëåò ôéò ãñáììÝò åíüò áñ÷åßïõ ðïõ ðåñéÝ÷ïõí Ýíá áëöáñéèìçôéêü.\n\n\ + FIND [ /C ] [ /I ] [ /N ] [ /V ] \"áëöáñéèìçôéêü\" [ áñ÷åßï... ]\n\ + /C ÌÝôñçóç ãñáììþí ðïõ ðåñéÝ÷ïõí ôï áëöáñéèìçôéêü\n\ + /I Áãíüçóç êåöáëáßùí\n\ + /N ÅìöÜíéóç áñéèìþí óôéò åìöáíéæüìåíåò ãñáììÝò, îåêéíþíôáò áðü ôï 1\n\ + /V Åêôýðùóç ãñáììþí ðïõ äåí ðåñéÝ÷ïõí ôï áëöáñéèìçôéêü" + +IDS_NO_SUCH_FILE, "FIND: %s: Äåí õðÜñ÷åé áõôü ôï áñ÷åßï\n" + +IDS_CANNOT_OPEN, "FIND: %s: Äåí Þôáí äõíáôü ôï Üíïéãìá ôïõ áñ÷åßïõ\n" + +END diff --git a/reactos/base/applications/findstr/lang/en-US.rc b/reactos/base/applications/findstr/lang/en-US.rc new file mode 100644 index 00000000000..d4ebfe38d53 --- /dev/null +++ b/reactos/base/applications/findstr/lang/en-US.rc @@ -0,0 +1,17 @@ +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US + +STRINGTABLE DISCARDABLE +BEGIN + +IDS_USAGE, "FINDSTR: Prints all lines of a file that contain a string.\n\n\ + FIND [ /C ] [ /I ] [ /N ] [ /V ] \"string\" [ file... ]\n\ + /C Count the number of lines that contain string\n\ + /I Ignore case\n\ + /N Number the displayed lines, starting at 1\n\ + /V Print lines that do not contain the string" + +IDS_NO_SUCH_FILE, "FINDSTR: %s: No such file\n" + +IDS_CANNOT_OPEN, "FINDSTR: %s: Cannot open file\n" + +END diff --git a/reactos/base/applications/findstr/lang/es-ES.rc b/reactos/base/applications/findstr/lang/es-ES.rc new file mode 100644 index 00000000000..f2fee3f0a4b --- /dev/null +++ b/reactos/base/applications/findstr/lang/es-ES.rc @@ -0,0 +1,17 @@ +LANGUAGE LANG_SPANISH, SUBLANG_NEUTRAL + +STRINGTABLE DISCARDABLE +BEGIN + +IDS_USAGE, "FIND: Imprime todas las líneas de un fichero que contiene una cadena.\n\n\ + FIND [ /C ] [ /I ] [ /N ] [ /V ] \"cadena\" [ fichero... ]\n\ + /C Cuenta el número de líneas que contienen la cadena de caracteres\n\ + /I Ignora mayúsculas y minúsculas\n\ + /N Numero de líneas a mostrar en pantalla, a partir de la primera\n\ + /V Muestra las líneas que no contienen la cadena de caracteres." + +IDS_NO_SUCH_FILE, "FIND: %s: No se encontró el fichero\n" + +IDS_CANNOT_OPEN, "FIND: %s: No se pudo abrir el fichero\n" + +END diff --git a/reactos/base/applications/findstr/lang/fr-FR.rc b/reactos/base/applications/findstr/lang/fr-FR.rc new file mode 100644 index 00000000000..076f0930177 --- /dev/null +++ b/reactos/base/applications/findstr/lang/fr-FR.rc @@ -0,0 +1,17 @@ +LANGUAGE LANG_FRENCH, SUBLANG_NEUTRAL + +STRINGTABLE DISCARDABLE +BEGIN + +IDS_USAGE, "FIND: Affiche toutes les lignes d'un fichier qui contiennent un morceau de texte.\n\n\ + FIND [ /C ] [ /I ] [ /N ] [ /V ] \"texte\" [ fichier... ]\n\ + /C Compte le nombre de lignes qui contiennent le texte\n\ + /I Insensible à la casse\n\ + /N Numérote les lignes affichées en commençant à 1\n\ + /V Affiche les lignes qui ne contiennent pas le texte" + +IDS_NO_SUCH_FILE, "FIND: %s : fichier inexistant\n" + +IDS_CANNOT_OPEN, "FIND: %s : impossible d'ouvrir le fichier\n" + +END diff --git a/reactos/base/applications/findstr/lang/it-IT.rc b/reactos/base/applications/findstr/lang/it-IT.rc new file mode 100644 index 00000000000..d0dabd405f2 --- /dev/null +++ b/reactos/base/applications/findstr/lang/it-IT.rc @@ -0,0 +1,17 @@ +LANGUAGE LANG_ITALIAN, SUBLANG_NEUTRAL + +STRINGTABLE DISCARDABLE +BEGIN + +IDS_USAGE, "FIND: Visualizza le linee di un file che contengono un stringa.\n\n\ + FIND [ /C ] [ /I ] [ /N ] [ /V ] \"stringa\" [ file... ]\n\ + /C Conta il numero di linee che contengono la stringa\n\ + /I Ignora maiuscole/minuscole\n\ + /N Numera le linee visualizzate a partire da 1\n\ + /V Visualizza le linee che non contengono la stringa" + +IDS_NO_SUCH_FILE, "FIND: %s: File non trovato\n" + +IDS_CANNOT_OPEN, "FIND: %s: Impossibile aprire il file\n" + +END diff --git a/reactos/base/applications/findstr/lang/lt-LT.rc b/reactos/base/applications/findstr/lang/lt-LT.rc new file mode 100644 index 00000000000..ce5b86af08a --- /dev/null +++ b/reactos/base/applications/findstr/lang/lt-LT.rc @@ -0,0 +1,26 @@ +/* + * PROJECT: ReactOS find command + * LICENSE: GPL - See COPYING in the top level directory + * FILE: base/applications/cmdutils/find/lang/lt-LT.rc + * PURPOSE: Lithuanian Language File + * TRANSLATOR: Vytis "CMan" Girdþijauskas (cman@cman.us) + * DATE: 2007-09-23 + */ + +LANGUAGE LANG_LITHUANIAN, SUBLANG_DEFAULT + +STRINGTABLE DISCARDABLE +BEGIN + +IDS_USAGE, "FIND: Spausdina visas bylos eilutes, kuriose yra ieðkomas tekstas.\n\n\ + FIND [ /C ] [ /I ] [ /N ] [ /V ] \"tekstas\" [ byla... ]\n\ + /C Skaièiuoti eilutes, kuriose yra ieðkomas tekstas\n\ + /I Ignoruoti raidþiø dydá\n\ + /N Numeruoti vaizduojamas eilutes, pradedant nuo 1\n\ + /V Spausdinti eilutes, kuriose nëra ieðkomo teksto" + +IDS_NO_SUCH_FILE, "FIND: %s: Tokios bylos nëra\n" + +IDS_CANNOT_OPEN, "FIND: %s: Nepavyko atverti bylos\n" + +END diff --git a/reactos/base/applications/findstr/lang/no-NO.rc b/reactos/base/applications/findstr/lang/no-NO.rc new file mode 100644 index 00000000000..d564684f86f --- /dev/null +++ b/reactos/base/applications/findstr/lang/no-NO.rc @@ -0,0 +1,17 @@ +LANGUAGE LANG_NORWEGIAN, SUBLANG_NEUTRAL + +STRINGTABLE DISCARDABLE +BEGIN + +IDS_USAGE, "FINN: Skriv alle linjene for filen som inneholder en streng.\n\n\ + FIND [ /C ] [ /I ] [ /N ] [ /V ] \"streng\" [ fil... ]\n\ + /C Teller nummer av linjer som inneholder strenger\n\ + /I Ignorere sak\n\ + /N Nummer viste linjer, start med 1\n\ + /V Skriv linjer som ikke inneholder en streng" + +IDS_NO_SUCH_FILE, "FINN: %s: Ingen filer\n" + +IDS_CANNOT_OPEN, "FINN: %s: Kan ikke åpne filen\n" + +END diff --git a/reactos/base/applications/findstr/lang/pl-PL.rc b/reactos/base/applications/findstr/lang/pl-PL.rc new file mode 100644 index 00000000000..744623e2aa4 --- /dev/null +++ b/reactos/base/applications/findstr/lang/pl-PL.rc @@ -0,0 +1,24 @@ +/* + * translated by Caemyr - Olaf Siejka (Dec,2007) + * Use ReactOS forum PM or IRC to contact me + * http://www.reactos.org + * IRC: irc.freenode.net #reactos-pl + */ + +LANGUAGE LANG_POLISH, SUBLANG_DEFAULT + +STRINGTABLE DISCARDABLE +BEGIN + +IDS_USAGE, "FIND: Wyœwietla wszystkie linie danego pliku, zawieraj¹ce szukany ci¹g znaków.\n\n\ + FIND [ /C ] [ /I ] [ /N ] [ /V ] \"ci¹g znaków\" [ plik... ]\n\ + /C Oblicza w ilu liniach pojawi³ siê szukany ci¹g znaków\n\ + /I Ignoruje wielkoœæ liter\n\ + /N Numeruje wyœwietlane linie, zaczynaj¹c od 1\n\ + /V Wyœwietla te linie które nie zawieraj¹ szukanego ci¹gu znaków" + +IDS_NO_SUCH_FILE, "FIND: %s: Plik nie zosta³ znaleziony\n" + +IDS_CANNOT_OPEN, "FIND: %s: Nie mo¿na otworzyæ pliku\n" + +END diff --git a/reactos/base/applications/findstr/lang/pt-BR.rc b/reactos/base/applications/findstr/lang/pt-BR.rc new file mode 100644 index 00000000000..de6342b71b3 --- /dev/null +++ b/reactos/base/applications/findstr/lang/pt-BR.rc @@ -0,0 +1,17 @@ +LANGUAGE LANG_PORTUGUESE, SUBLANG_NEUTRAL + +STRINGTABLE DISCARDABLE +BEGIN + +IDS_USAGE, "FIND: Localiza uma seqüência de texto em um ou mais arquivos.\n\n\ + FIND [ /C ] [ /I ] [ /N ] [ /V ] \"seqüência\" [ arquivo... ]\n\ + /C Exibe apenas o número de linhas que contêm a seqüência.\n\ + /I Ignora maiúsculas/minúsculas ao localizar uma seqüência.\n\ + /N Exibe o número de cada linha, iniciando no 1.\n\ + /V Exibe todas as linhas que NÃO contêm a seqüência especificada." + +IDS_NO_SUCH_FILE, "FIND: %s: Arquivo não encontrado\n" + +IDS_CANNOT_OPEN, "FIND: %s: Não foi possível abrir o arquivo\n" + +END diff --git a/reactos/base/applications/findstr/lang/ru-RU.rc b/reactos/base/applications/findstr/lang/ru-RU.rc new file mode 100644 index 00000000000..94594f56770 --- /dev/null +++ b/reactos/base/applications/findstr/lang/ru-RU.rc @@ -0,0 +1,17 @@ +LANGUAGE LANG_RUSSIAN, SUBLANG_DEFAULT + +STRINGTABLE DISCARDABLE +BEGIN + +IDS_USAGE, "FIND: Ïîèñê òåêñòîâîé ñòðîêè â îäíîì èëè íåñêîëüêèõ ôàéëàõ.\n\n\ + FIND [ /C ] [ /I ] [ /N ] [ /V ] \"ñòðîêà\" [ ôàéë... ]\n\ + /C Âûâîä òîëüêî îáùåãî ÷èñëà ñòðîê, ñîäåðæàùèõ çàäàííóþ ñòðîêó.\n\ + /I Ïîèñê áåç ó÷åòà ðåãèñòðà ñèìâîëîâ.\n\ + /N Âûâîä íîìåðîâ îòîáðàæàåìûõ ñòðîê (íà÷èíàÿ ñ 1).\n\ + /V Âûâîä âñåõ ñòðîê, ÍÅ ñîäåðæàùèõ çàäàííóþ ñòðîêó." + +IDS_NO_SUCH_FILE, "FIND: %s: Ôàéë íå ñóùåñòâóåò.\n" + +IDS_CANNOT_OPEN, "FIND: %s: Íåâîçìîæíî îòêðûòü ôàéë.\n" + +END diff --git a/reactos/base/applications/findstr/lang/sk-SK.rc b/reactos/base/applications/findstr/lang/sk-SK.rc new file mode 100644 index 00000000000..93037288a93 --- /dev/null +++ b/reactos/base/applications/findstr/lang/sk-SK.rc @@ -0,0 +1,21 @@ +/* TRANSLATOR: M rio KaŸm r /Mario Kacmar/ aka Kario (kario@szm.sk) + * DATE OF TR: 12-02-2008 + */ + +LANGUAGE LANG_SLOVAK, SUBLANG_DEFAULT + +STRINGTABLE DISCARDABLE +BEGIN + +IDS_USAGE, "FIND: Zobraz¡ vçetky riadky s£boru obsahuj£ce h–adanì reœazec.\n\n\ + FIND [ /C ] [ /I ] [ /N ] [ /V ] \"reœazec\" [ s£bor... ]\n\ + /C Zobraz¡ poŸet riadkov, ktor‚ obsahuj£ reœazec.\n\ + /I Ignoruje ve–kosœ p¡smen.\n\ + /N ¬¡sluje zobrazen‚ riadky, zaŸ¡na od 1.\n\ + /V Zobraz¡ vçetky riadky, ktor‚ neobsahuj£ h–adanì reœazec." + +IDS_NO_SUCH_FILE, "FIND: S£bor %s sa nenaçiel.\n" + +IDS_CANNOT_OPEN, "FIND: S£bor %s sa ned  otvoriœ.\n" + +END diff --git a/reactos/base/applications/findstr/lang/sv-SE.rc b/reactos/base/applications/findstr/lang/sv-SE.rc new file mode 100644 index 00000000000..e8d0d6eefdc --- /dev/null +++ b/reactos/base/applications/findstr/lang/sv-SE.rc @@ -0,0 +1,17 @@ +LANGUAGE LANG_SWEDISH, SUBLANG_NEUTRAL + +STRINGTABLE DISCARDABLE +BEGIN + +IDS_USAGE, "FIND: Skriver ut alla rader i en fil som innehåller en sträng.\n\n\ + FIND [ /C ] [ /I ] [ /N ] [ /V ] \"sträng\" [ fil... ]\n\ + /C Räkna nummren av linjer som innehåller en strängen\n\ + /I Ignorera skiftläge\n\ + /N Antal visade rader, börjar på 1\n\ + /V Skriver ut rader som inte innehåller strängen" + +IDS_NO_SUCH_FILE, "FIND: %s: Ingen sorts fil\n" + +IDS_CANNOT_OPEN, "FIND: %s: Kan inte öppna filen\n" + +END diff --git a/reactos/base/applications/findstr/lang/uk-UA.rc b/reactos/base/applications/findstr/lang/uk-UA.rc new file mode 100644 index 00000000000..b7df8b4e635 --- /dev/null +++ b/reactos/base/applications/findstr/lang/uk-UA.rc @@ -0,0 +1,25 @@ +/* + * PROJECT: Find + * LICENSE: GPL - See COPYING in the top level directory + * FILE: base/applications/cmdutils/find/lang/uk-UA.rc + * PURPOSE: Ukraianian Language File for find + * TRANSLATOR: Artem Reznikov + */ + +LANGUAGE LANG_UKRAINIAN, SUBLANG_DEFAULT + +STRINGTABLE DISCARDABLE +BEGIN + +IDS_USAGE, "FIND: Âèâåäåííÿ âñ³õ ðÿäê³â ôàéëó, ÿê³ ì³ñòÿòü ðÿäîê.\n\n\ + FIND [ /C ] [ /I ] [ /N ] [ /V ] \"ðÿäîê\" [ ôàéë... ]\n\ + /C Ïîðàõóâàòè ê³ëüê³ñòü ðÿäê³â, ÿê³ ì³ñòÿòü ðÿäîê\n\ + /I Íå âðàõîâóâàòè ðåã³ñòð ñèìâîë³â\n\ + /N Íóìåðóâàòè ðÿäêè, ÿê³ â³äîáðàæàþòüñÿ (ïî÷èíàþ÷è ç 1)\n\ + /V Âèâåäåííÿ ðÿäê³â, ÿê³ íå ì³ñòÿòü çàäàíèé ðÿäîê" + +IDS_NO_SUCH_FILE, "FIND: %s: Ôàéë íå ³ñíóº\n" + +IDS_CANNOT_OPEN, "FIND: %s: Íåìîæëèâî â³äêðèòè ôàéë\n" + +END diff --git a/reactos/base/applications/findstr/resource.h b/reactos/base/applications/findstr/resource.h new file mode 100644 index 00000000000..444cd8cc457 --- /dev/null +++ b/reactos/base/applications/findstr/resource.h @@ -0,0 +1,3 @@ +#define IDS_USAGE 1000 +#define IDS_NO_SUCH_FILE 1001 +#define IDS_CANNOT_OPEN 1002 diff --git a/reactos/base/applications/findstr/rsrc.rc b/reactos/base/applications/findstr/rsrc.rc new file mode 100644 index 00000000000..99baec73cbe --- /dev/null +++ b/reactos/base/applications/findstr/rsrc.rc @@ -0,0 +1,20 @@ +#include +#include "resource.h" + +#include "lang/bg-BG.rc" +#include "lang/ca-ES.rc" +#include "lang/cs-CZ.rc" +#include "lang/de-DE.rc" +#include "lang/el-GR.rc" +#include "lang/en-US.rc" +#include "lang/es-ES.rc" +#include "lang/fr-FR.rc" +#include "lang/it-IT.rc" +#include "lang/lt-LT.rc" +#include "lang/no-NO.rc" +#include "lang/pl-PL.rc" +#include "lang/pt-BR.rc" +#include "lang/ru-RU.rc" +#include "lang/sk-SK.rc" +#include "lang/sv-SE.rc" +#include "lang/uk-UA.rc" diff --git a/reactos/boot/bootdata/packages/reactos.dff b/reactos/boot/bootdata/packages/reactos.dff index f08fb2489c0..778dac88b98 100644 --- a/reactos/boot/bootdata/packages/reactos.dff +++ b/reactos/boot/bootdata/packages/reactos.dff @@ -45,6 +45,7 @@ base\applications\cmdutils\xcopy\xcopy.exe 1 base\applications\control\control.exe 1 base\applications\dxdiag\dxdiag.exe 1 base\applications\extrac32\extrac32.exe 1 +base\applications\findstr\findstr.exe 1 base\applications\fontview\fontview.exe 1 base\applications\games\solitaire\sol.exe 1 base\applications\games\spider\spider.exe 1 From 1a20b0bd9c66342cc8135a22b186556f17d4e77c Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Thu, 2 Dec 2010 14:37:16 +0000 Subject: [PATCH 017/181] [NTOSKRNL] patch by Samuel Serapion: Implement MemorySectionName case for NtQueryVirtualMemory. Protect buffer access with SEH. See issue #5753 for more details. svn path=/trunk/; revision=49898 --- reactos/ntoskrnl/mm/ARM3/virtual.c | 250 +++++++++++++++++++++++++---- 1 file changed, 215 insertions(+), 35 deletions(-) diff --git a/reactos/ntoskrnl/mm/ARM3/virtual.c b/reactos/ntoskrnl/mm/ARM3/virtual.c index 4e69411f864..508db86b1e2 100644 --- a/reactos/ntoskrnl/mm/ARM3/virtual.c +++ b/reactos/ntoskrnl/mm/ARM3/virtual.c @@ -2339,35 +2339,21 @@ NtResetWriteWatch(IN HANDLE ProcessHandle, NTSTATUS NTAPI -NtQueryVirtualMemory(IN HANDLE ProcessHandle, - IN PVOID BaseAddress, - IN MEMORY_INFORMATION_CLASS MemoryInformationClass, - OUT PVOID MemoryInformation, - IN SIZE_T MemoryInformationLength, - OUT PSIZE_T ReturnLength) +MiQueryMemoryBasicInformation(IN HANDLE ProcessHandle, + IN PVOID BaseAddress, + OUT PVOID MemoryInformation, + IN SIZE_T MemoryInformationLength, + OUT PSIZE_T ReturnLength) { PEPROCESS TargetProcess; - NTSTATUS Status; + NTSTATUS Status = STATUS_SUCCESS; PMMVAD Vad = NULL; PVOID Address, NextAddress; BOOLEAN Found = FALSE; ULONG NewProtect, NewState, BaseVpn; MEMORY_BASIC_INFORMATION MemoryInfo; KAPC_STATE ApcState; - DPRINT("Querying class %d about address: %p\n", MemoryInformationClass, BaseAddress); - - /* Only this class is supported for now */ - ASSERT(MemoryInformationClass == MemoryBasicInformation); - - /* Validate the size information of the class */ - if (MemoryInformationLength < sizeof(MEMORY_BASIC_INFORMATION)) - { - /* The size is invalid */ - return STATUS_INFO_LENGTH_MISMATCH; - } - - /* Bail out if the address is invalid */ - if (BaseAddress > MM_HIGHEST_USER_ADDRESS) return STATUS_INVALID_PARAMETER; + KPROCESSOR_MODE PreviousMode = ExGetPreviousMode(); /* Check for illegal addresses in user-space, or the shared memory area */ if ((BaseAddress > MM_HIGHEST_VAD_ADDRESS) || @@ -2396,11 +2382,27 @@ NtQueryVirtualMemory(IN HANDLE ProcessHandle, MemoryInfo.RegionSize = (ULONG_PTR)MemoryInfo.AllocationBase - (ULONG_PTR)Address; } - /* Return the data (FIXME: Use SEH) */ - *(PMEMORY_BASIC_INFORMATION)MemoryInformation = MemoryInfo; - if (ReturnLength) *ReturnLength = sizeof(MEMORY_BASIC_INFORMATION); + /* Return the data, NtQueryInformation already probed it*/ + if (PreviousMode != KernelMode) + { + _SEH2_TRY + { + *(PMEMORY_BASIC_INFORMATION)MemoryInformation = MemoryInfo; + if (ReturnLength) *ReturnLength = sizeof(MEMORY_BASIC_INFORMATION); + } + _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) + { + Status = _SEH2_GetExceptionCode(); + } + _SEH2_END; + } + else + { + *(PMEMORY_BASIC_INFORMATION)MemoryInformation = MemoryInfo; + if (ReturnLength) *ReturnLength = sizeof(MEMORY_BASIC_INFORMATION); + } - return STATUS_SUCCESS; + return Status; } /* Check if this is for a local or remote process */ @@ -2507,11 +2509,27 @@ NtQueryVirtualMemory(IN HANDLE ProcessHandle, MemoryInfo.Protect = PAGE_NOACCESS; MemoryInfo.Type = 0; - /* Return the data (FIXME: Use SEH) */ - *(PMEMORY_BASIC_INFORMATION)MemoryInformation = MemoryInfo; - if (ReturnLength) *ReturnLength = sizeof(MEMORY_BASIC_INFORMATION); + /* Return the data, NtQueryInformation already probed it*/ + if (PreviousMode != KernelMode) + { + _SEH2_TRY + { + *(PMEMORY_BASIC_INFORMATION)MemoryInformation = MemoryInfo; + if (ReturnLength) *ReturnLength = sizeof(MEMORY_BASIC_INFORMATION); + } + _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) + { + Status = _SEH2_GetExceptionCode(); + } + _SEH2_END; + } + else + { + *(PMEMORY_BASIC_INFORMATION)MemoryInformation = MemoryInfo; + if (ReturnLength) *ReturnLength = sizeof(MEMORY_BASIC_INFORMATION); + } - return STATUS_SUCCESS; + return Status; } /* This must be a VM VAD */ @@ -2539,7 +2557,7 @@ NtQueryVirtualMemory(IN HANDLE ProcessHandle, Address = NextAddress; } - /* Now that we know the last VA address, calculate hte region size */ + /* Now that we know the last VA address, calculate the region size */ MemoryInfo.RegionSize = ((ULONG_PTR)Address - (ULONG_PTR)MemoryInfo.BaseAddress); /* Check if we were attached */ @@ -2550,17 +2568,179 @@ NtQueryVirtualMemory(IN HANDLE ProcessHandle, ObDereferenceObject(TargetProcess); } - /* Return the data (FIXME: Use SEH) */ - *(PMEMORY_BASIC_INFORMATION)MemoryInformation = MemoryInfo; - if (ReturnLength) *ReturnLength = sizeof(MEMORY_BASIC_INFORMATION); - + /* Return the data, NtQueryInformation already probed it*/ + if (PreviousMode != KernelMode) + { + _SEH2_TRY + { + *(PMEMORY_BASIC_INFORMATION)MemoryInformation = MemoryInfo; + if (ReturnLength) *ReturnLength = sizeof(MEMORY_BASIC_INFORMATION); + } + _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) + { + Status = _SEH2_GetExceptionCode(); + } + _SEH2_END; + } + else + { + *(PMEMORY_BASIC_INFORMATION)MemoryInformation = MemoryInfo; + if (ReturnLength) *ReturnLength = sizeof(MEMORY_BASIC_INFORMATION); + } + /* All went well */ DPRINT("Base: %p AllocBase: %p Protect: %lx AllocProtect: %lx " "State: %lx Type: %lx Size: %lx\n", MemoryInfo.BaseAddress, MemoryInfo.AllocationBase, MemoryInfo.AllocationProtect, MemoryInfo.Protect, MemoryInfo.State, MemoryInfo.Type, MemoryInfo.RegionSize); - return STATUS_SUCCESS; + + return Status; +} + +NTSTATUS +NTAPI +MiQueryMemorySectionName(IN HANDLE ProcessHandle, + IN PVOID BaseAddress, + OUT PVOID MemoryInformation, + IN SIZE_T MemoryInformationLength, + OUT PSIZE_T ReturnLength) +{ + PEPROCESS Process; + NTSTATUS Status; + WCHAR ModuleFileNameBuffer[MAX_PATH] = {0}; + UNICODE_STRING ModuleFileName; + PMEMORY_SECTION_NAME SectionName = NULL; + KPROCESSOR_MODE PreviousMode = ExGetPreviousMode(); + + Status = ObReferenceObjectByHandle(ProcessHandle, + PROCESS_QUERY_INFORMATION, + NULL, + PreviousMode, + (PVOID*)(&Process), + NULL); + + if (!NT_SUCCESS(Status)) + { + DPRINT("MiQueryMemorySectionName: ObReferenceObjectByHandle returned %x\n",Status); + return Status; + } + + RtlInitEmptyUnicodeString(&ModuleFileName, ModuleFileNameBuffer, sizeof(ModuleFileNameBuffer)); + Status = MmGetFileNameForAddress(BaseAddress, &ModuleFileName); + + if (NT_SUCCESS(Status)) + { + SectionName = MemoryInformation; + if (PreviousMode != KernelMode) + { + _SEH2_TRY + { + RtlInitUnicodeString(&SectionName->SectionFileName, SectionName->NameBuffer); + SectionName->SectionFileName.MaximumLength = MemoryInformationLength; + RtlCopyUnicodeString(&SectionName->SectionFileName, &ModuleFileName); + + if (ReturnLength) *ReturnLength = ModuleFileName.Length; + + } + _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) + { + Status = _SEH2_GetExceptionCode(); + } + _SEH2_END; + } + else + { + RtlInitUnicodeString(&SectionName->SectionFileName, SectionName->NameBuffer); + SectionName->SectionFileName.MaximumLength = MemoryInformationLength; + RtlCopyUnicodeString(&SectionName->SectionFileName, &ModuleFileName); + + if (ReturnLength) *ReturnLength = ModuleFileName.Length; + + } + } + ObDereferenceObject(Process); + return Status; +} + +NTSTATUS +NTAPI +NtQueryVirtualMemory(IN HANDLE ProcessHandle, + IN PVOID BaseAddress, + IN MEMORY_INFORMATION_CLASS MemoryInformationClass, + OUT PVOID MemoryInformation, + IN SIZE_T MemoryInformationLength, + OUT PSIZE_T ReturnLength) +{ + NTSTATUS Status = STATUS_SUCCESS; + KPROCESSOR_MODE PreviousMode; + + DPRINT("Querying class %d about address: %p\n", MemoryInformationClass, BaseAddress); + + /* Bail out if the address is invalid */ + if (BaseAddress > MM_HIGHEST_USER_ADDRESS) return STATUS_INVALID_PARAMETER; + + /* Probe return buffer */ + PreviousMode = ExGetPreviousMode(); + if (PreviousMode != KernelMode) + { + _SEH2_TRY + { + ProbeForWrite(MemoryInformation, + MemoryInformationLength, + sizeof(ULONG_PTR)); + + if (ReturnLength) ProbeForWriteSize_t(ReturnLength); + } + _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) + { + Status = _SEH2_GetExceptionCode(); + } + _SEH2_END; + + if (!NT_SUCCESS(Status)) + { + return Status; + } + } + + switch(MemoryInformationClass) + { + case MemoryBasicInformation: + /* Validate the size information of the class */ + if (MemoryInformationLength < sizeof(MEMORY_BASIC_INFORMATION)) + { + /* The size is invalid */ + return STATUS_INFO_LENGTH_MISMATCH; + } + Status = MiQueryMemoryBasicInformation(ProcessHandle, + BaseAddress, + MemoryInformation, + MemoryInformationLength, + ReturnLength); + break; + + case MemorySectionName: + /* Validate the size information of the class */ + if (MemoryInformationLength < sizeof(MEMORY_SECTION_NAME)) + { + /* The size is invalid */ + return STATUS_INFO_LENGTH_MISMATCH; + } + Status = MiQueryMemorySectionName(ProcessHandle, + BaseAddress, + MemoryInformation, + MemoryInformationLength, + ReturnLength); + break; + case MemoryWorkingSetList: + case MemoryBasicVlmInformation: + default: + DPRINT1("Unhandled memory information class %d\n", MemoryInformationClass); + break; + } + + return Status; } /* EOF */ From 3972c628bb90583f935f91518127b89a02bc43df Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Fri, 3 Dec 2010 11:46:52 +0000 Subject: [PATCH 018/181] revert accidental change from r49499 svn path=/trunk/; revision=49918 --- reactos/modules/directory.rbuild | 7 ------- 1 file changed, 7 deletions(-) diff --git a/reactos/modules/directory.rbuild b/reactos/modules/directory.rbuild index a4424fd98e1..7c33c54cb7c 100644 --- a/reactos/modules/directory.rbuild +++ b/reactos/modules/directory.rbuild @@ -22,11 +22,4 @@ - From 7d1736a1a2a39ab506a3fe94fdd0e27aef1d9c46 Mon Sep 17 00:00:00 2001 From: James Tabor Date: Fri, 3 Dec 2010 15:34:06 +0000 Subject: [PATCH 019/181] [Win32k|User32] - Fixed SendNotifyMessage, thanks to Michael Martin callback changes. Fixed DispatchMessage when dealing with thread errors. Fixed all but one of the Get/PeekMessage wine tests. Fixed attaching threads to process information. Plus other fixes. - Implemented support for QS bits, ReplyMessage (not fully correct), and others. - Tested everything here, please post regressions so I can add more applications to the test list. This patch is synced with 49720 and 49772. After that there are graphic issues. - Credits goes to wine for helping with diagnosing issues in the ReactOS message system. svn path=/trunk/; revision=49929 --- reactos/dll/win32/user32/windows/menu.c | 7 +- reactos/dll/win32/user32/windows/message.c | 97 ++++- reactos/include/reactos/win32k/ntuser.h | 3 +- .../win32/win32k/include/msgqueue.h | 44 +- .../subsystems/win32/win32k/include/win32.h | 1 + .../subsystems/win32/win32k/main/dllmain.c | 30 +- .../subsystems/win32/win32k/ntuser/desktop.c | 4 +- .../subsystems/win32/win32k/ntuser/input.c | 14 +- .../subsystems/win32/win32k/ntuser/message.c | 275 ++++++++---- reactos/subsystems/win32/win32k/ntuser/misc.c | 40 +- .../subsystems/win32/win32k/ntuser/msgqueue.c | 407 ++++++++++++------ .../subsystems/win32/win32k/ntuser/painting.c | 10 +- .../win32/win32k/ntuser/simplecall.c | 2 + .../subsystems/win32/win32k/ntuser/timer.c | 2 +- 14 files changed, 657 insertions(+), 279 deletions(-) diff --git a/reactos/dll/win32/user32/windows/menu.c b/reactos/dll/win32/user32/windows/menu.c index 8f8610d64b1..32b00314769 100644 --- a/reactos/dll/win32/user32/windows/menu.c +++ b/reactos/dll/win32/user32/windows/menu.c @@ -3182,7 +3182,7 @@ static INT FASTCALL MenuTrackMenu(HMENU hmenu, UINT wFlags, INT x, INT y, SetCapture(mt.OwnerWnd); (void)NtUserSetGUIThreadHandle(MSQ_STATE_MENUOWNER, mt.OwnerWnd); - ERR("MenuTrackMenu 1\n"); + FIXME("MenuTrackMenu 1\n"); while (! fEndMenu) { PVOID menu = ValidateHandle(mt.CurrentMenu, VALIDATE_TYPE_MENU); @@ -3210,6 +3210,7 @@ static INT FASTCALL MenuTrackMenu(HMENU hmenu, UINT wFlags, INT x, INT y, } WaitMessage(); } + //FIXME("MenuTrackMenu loop 1\n"); } /* check if EndMenu() tried to cancel us, by posting this message */ @@ -3417,6 +3418,7 @@ static INT FASTCALL MenuTrackMenu(HMENU hmenu, UINT wFlags, INT x, INT y, { PeekMessageW( &msg, 0, msg.message, msg.message, PM_REMOVE ); DispatchMessageW( &msg ); + //FIXME("MenuTrackMenu loop 2\n"); continue; } @@ -3427,8 +3429,9 @@ static INT FASTCALL MenuTrackMenu(HMENU hmenu, UINT wFlags, INT x, INT y, if (fRemove && !(mt.TrackFlags & TF_SKIPREMOVE) ) PeekMessageW( &msg, 0, msg.message, msg.message, PM_REMOVE ); else mt.TrackFlags &= ~TF_SKIPREMOVE; + //FIXME("MenuTrackMenu loop 3\n"); } - ERR("MenuTrackMenu 2\n"); + FIXME("MenuTrackMenu 2\n"); (void)NtUserSetGUIThreadHandle(MSQ_STATE_MENUOWNER, NULL); SetCapture(NULL); /* release the capture */ diff --git a/reactos/dll/win32/user32/windows/message.c b/reactos/dll/win32/user32/windows/message.c index 300bfc796cf..93bb170214c 100644 --- a/reactos/dll/win32/user32/windows/message.c +++ b/reactos/dll/win32/user32/windows/message.c @@ -1097,7 +1097,6 @@ WINAPI InSendMessage(VOID) { PCLIENTTHREADINFO pcti = GetWin32ClientInfo()->pClientThreadInfo; -// FIXME("ISM %x\n",pcti); if ( pcti ) { if (pcti->CTI_flags & CTI_INSENDMESSAGE) @@ -1118,7 +1117,6 @@ InSendMessageEx( LPVOID lpReserved) { PCLIENTTHREADINFO pcti = GetWin32ClientInfo()->pClientThreadInfo; -// FIXME("ISMEX %x\n",pcti); if (pcti && !(pcti->CTI_flags & CTI_INSENDMESSAGE)) return ISMEX_NOSEND; else @@ -1442,6 +1440,12 @@ IntCallMessageProc(IN PWND Wnd, IN HWND hWnd, IN UINT Msg, IN WPARAM wParam, IN Class = DesktopPtrToUser(Wnd->pcls); WndProc = NULL; + + if ( Wnd->head.pti != GetW32ThreadInfo()) + { // Must be inside the same thread! + SetLastError( ERROR_MESSAGE_SYNC_ONLY ); + return 0; + } /* This is the message exchange for user32. If there's a need to monitor messages, do it here! @@ -1586,11 +1590,16 @@ DispatchMessageA(CONST MSG *lpmsg) MSG UnicodeMsg; PWND Wnd; + if ( lpmsg->message & ~WM_MAXIMUM ) + { + SetLastError( ERROR_INVALID_PARAMETER ); + return 0; + } + if (lpmsg->hwnd != NULL) { Wnd = ValidateHwnd(lpmsg->hwnd); - if (!Wnd || Wnd->head.pti != GetW32ThreadInfo()) - return 0; + if (!Wnd) return 0; } else Wnd = NULL; @@ -1602,7 +1611,7 @@ DispatchMessageA(CONST MSG *lpmsg) if ( lpmsg->message == WM_SYSTIMER ) return NtUserDispatchMessage( (PMSG)lpmsg ); - _SEH2_TRY // wine does this. + _SEH2_TRY // wine does this. Hint: Prevents call to another thread.... { Ret = WndProc(lpmsg->hwnd, lpmsg->message, @@ -1613,7 +1622,6 @@ DispatchMessageA(CONST MSG *lpmsg) { } _SEH2_END; - } else if (Wnd != NULL) { @@ -1654,11 +1662,16 @@ DispatchMessageW(CONST MSG *lpmsg) LRESULT Ret = 0; PWND Wnd; + if ( lpmsg->message & ~WM_MAXIMUM ) + { + SetLastError( ERROR_INVALID_PARAMETER ); + return 0; + } + if (lpmsg->hwnd != NULL) { Wnd = ValidateHwnd(lpmsg->hwnd); - if (!Wnd || Wnd->head.pti != GetW32ThreadInfo()) - return 0; + if (!Wnd) return 0; } else Wnd = NULL; @@ -1795,6 +1808,42 @@ GetMessageW(LPMSG lpMsg, return Res; } +BOOL WINAPI +PeekMessageWorker(PNTUSERGETMESSAGEINFO pInfo, + HWND hWnd, + UINT wMsgFilterMin, + UINT wMsgFilterMax, + UINT wRemoveMsg) +{ + PCLIENTINFO pci; + PCLIENTTHREADINFO pcti; + pci = GetWin32ClientInfo(); + pcti = pci->pClientThreadInfo; + + if (!hWnd && pci && pcti) + { + pci->cSpins++; + + if ((pci->cSpins >= 100) && (pci->dwTIFlags & TIF_SPINNING)) + { // Yield after 100 spin cycles and ready to swap vinyl. + if (!(pci->dwTIFlags & TIF_WAITFORINPUTIDLE)) + { // Not waiting for idle event. + if (!pcti->fsChangeBits && !pcti->fsWakeBits) + { // No messages are available. + if ((GetTickCount() - pcti->tickLastMsgChecked) > 1000) + { // Up the msg read count if over 1 sec. + NtUserGetThreadState(THREADSTATE_UPTIMELASTREAD); + } + pci->cSpins = 0; + ZwYieldExecution(); + FIXME("seeSpins!\n"); + return FALSE; + } + } + } + } + return NtUserPeekMessage(pInfo, hWnd, wMsgFilterMin, wMsgFilterMax, wRemoveMsg); +} /* * @implemented @@ -1812,7 +1861,7 @@ PeekMessageA(LPMSG lpMsg, PUSER32_THREAD_DATA ThreadData = User32GetThreadData(); MsgConversionCleanup(lpMsg, TRUE, FALSE, NULL); - Res = NtUserPeekMessage(&Info, hWnd, wMsgFilterMin, wMsgFilterMax, wRemoveMsg); + Res = PeekMessageWorker(&Info, hWnd, wMsgFilterMin, wMsgFilterMax, wRemoveMsg); if (-1 == (int) Res || !Res) { return FALSE; @@ -1865,7 +1914,7 @@ PeekMessageW( PUSER32_THREAD_DATA ThreadData = User32GetThreadData(); MsgConversionCleanup(lpMsg, FALSE, FALSE, NULL); - Res = NtUserPeekMessage(&Info, hWnd, wMsgFilterMin, wMsgFilterMax, wRemoveMsg); + Res = PeekMessageWorker(&Info, hWnd, wMsgFilterMin, wMsgFilterMax, wRemoveMsg); if (-1 == (int) Res || !Res) { return FALSE; @@ -2567,7 +2616,8 @@ DWORD WINAPI RealGetQueueStatus(UINT flags) { - if (flags & ~(QS_SMRESULT|QS_ALLPOSTMESSAGE|QS_ALLINPUT)) + #define QS_TEMPALLINPUT 255 // ATM, do not support QS_RAWINPUT + if (flags & ~(QS_SMRESULT|QS_ALLPOSTMESSAGE|QS_TEMPALLINPUT)) { SetLastError( ERROR_INVALID_FLAGS ); return 0; @@ -2802,6 +2852,8 @@ RealMsgWaitForMultipleObjectsEx( LPHANDLE RealHandles; HANDLE MessageQueueHandle; DWORD Result; + PCLIENTINFO pci; + PCLIENTTHREADINFO pcti; if (dwFlags & ~(MWMO_WAITALL | MWMO_ALERTABLE | MWMO_INPUTAVAILABLE)) { @@ -2809,14 +2861,21 @@ RealMsgWaitForMultipleObjectsEx( return WAIT_FAILED; } -/* - if (dwFlags & MWMO_INPUTAVAILABLE) - { - RealGetQueueStatus(dwWakeMask); - } - */ + pci = GetWin32ClientInfo(); + if (!pci) return WAIT_FAILED; - MessageQueueHandle = NtUserMsqSetWakeMask(dwWakeMask); + pcti = pci->pClientThreadInfo; + if (pcti && ( !nCount || !(dwFlags & MWMO_WAITALL) )) + { + if ( (pcti->fsChangeBits & LOWORD(dwWakeMask)) || + ( (dwFlags & MWMO_INPUTAVAILABLE) && (pcti->fsWakeBits & LOWORD(dwWakeMask)) ) ) + { + //FIXME("Chg 0x%x Wake 0x%x Mask 0x%x nCnt %d\n",pcti->fsChangeBits, pcti->fsWakeBits, dwWakeMask, nCount); + return nCount; + } + } + + MessageQueueHandle = NtUserMsqSetWakeMask(MAKELONG(dwWakeMask, dwFlags)); if (MessageQueueHandle == NULL) { SetLastError(0); /* ? */ @@ -2840,7 +2899,7 @@ RealMsgWaitForMultipleObjectsEx( HeapFree(GetProcessHeap(), 0, RealHandles); NtUserMsqClearWakeMask(); - + //FIXME("Result 0X%x\n",Result); return Result; } diff --git a/reactos/include/reactos/win32k/ntuser.h b/reactos/include/reactos/win32k/ntuser.h index 5c4a335ec9f..e6745d9f7fc 100644 --- a/reactos/include/reactos/win32k/ntuser.h +++ b/reactos/include/reactos/win32k/ntuser.h @@ -2104,7 +2104,8 @@ enum ThreadStateRoutines THREADSTATE_PROGMANWINDOW, THREADSTATE_TASKMANWINDOW, THREADSTATE_GETMESSAGETIME, - THREADSTATE_GETINPUTSTATE + THREADSTATE_GETINPUTSTATE, + THREADSTATE_UPTIMELASTREAD }; DWORD_PTR diff --git a/reactos/subsystems/win32/win32k/include/msgqueue.h b/reactos/subsystems/win32/win32k/include/msgqueue.h index 8a8bac87a24..00ea6e131d1 100644 --- a/reactos/subsystems/win32/win32k/include/msgqueue.h +++ b/reactos/subsystems/win32/win32k/include/msgqueue.h @@ -8,10 +8,23 @@ #define MSQ_ISEVENT 2 #define MSQ_SENTNOWAIT 0x80000000 +#define QSIDCOUNTS 6 + +typedef enum _QS_ROS_TYPES +{ + QSRosKey = 0, + QSRosMouseMove, + QSRosMouseButton, + QSRosPostMessage, + QSRosSendMessage, + QSRosHotKey, +}QS_ROS_TYPES,*PQS_ROS_TYPES; + typedef struct _USER_MESSAGE { LIST_ENTRY ListEntry; MSG Msg; + DWORD QS_Flags; } USER_MESSAGE, *PUSER_MESSAGE; struct _USER_MESSAGE_QUEUE; @@ -20,8 +33,10 @@ typedef struct _USER_SENT_MESSAGE { LIST_ENTRY ListEntry; MSG Msg; + DWORD QS_Flags; // Original QS bits used to create this message. PKEVENT CompletionEvent; LRESULT* Result; + LRESULT lResult; struct _USER_MESSAGE_QUEUE* SenderQueue; SENDASYNCPROC CompletionCallback; ULONG_PTR CompletionCallbackContext; @@ -31,16 +46,6 @@ typedef struct _USER_SENT_MESSAGE BOOL HasPackedLParam; } USER_SENT_MESSAGE, *PUSER_SENT_MESSAGE; -typedef struct _USER_SENT_MESSAGE_NOTIFY -{ - SENDASYNCPROC CompletionCallback; - ULONG_PTR CompletionCallbackContext; - LRESULT Result; - HWND hWnd; - UINT Msg; - LIST_ENTRY ListEntry; -} USER_SENT_MESSAGE_NOTIFY, *PUSER_SENT_MESSAGE_NOTIFY; - typedef struct _USER_MESSAGE_QUEUE { /* Reference counter, only access this variable with interlocked functions! */ @@ -52,8 +57,6 @@ typedef struct _USER_MESSAGE_QUEUE LIST_ENTRY SentMessagesListHead; /* Queue of messages posted to the queue. */ LIST_ENTRY PostedMessagesListHead; - /* Queue of sent-message notifies for the queue. */ - LIST_ENTRY NotifyMessagesListHead; /* Queue for hardware messages for the queue. */ LIST_ENTRY HardwareMessagesListHead; /* Lock for the hardware message list. */ @@ -76,8 +79,6 @@ typedef struct _USER_MESSAGE_QUEUE ULONG LastMsgRead; /* Current window with focus (ie. receives keyboard input) for this queue. */ HWND FocusWindow; - /* Count of paints pending. */ - ULONG PaintCount; /* Current active window for this queue. */ HWND ActiveWindow; /* Current capture window for this queue. */ @@ -92,9 +93,11 @@ typedef struct _USER_MESSAGE_QUEUE PTHRDCARETINFO CaretInfo; /* queue state tracking */ - WORD WakeMask; - WORD QueueBits; - WORD ChangedBits; + // Send list QS_SENDMESSAGE + // Post list QS_POSTMESSAGE|QS_HOTKEY|QS_PAINT|QS_TIMER|QS_KEY + // Hard list QS_MOUSE|QS_KEY only + // Accounting of queue bit sets, the rest are flags. QS_TIMER QS_PAINT counts are handled in thread information. + DWORD nCntsQBits[QSIDCOUNTS]; // QS_KEY QS_MOUSEMOVE QS_MOUSEBUTTON QS_POSTMESSAGE QS_SENDMESSAGE QS_HOTKEY /* extra message information */ LPARAM ExtraInfo; @@ -130,6 +133,7 @@ MsqPeekMessage(IN PUSER_MESSAGE_QUEUE MessageQueue, IN PWND Window, IN UINT MsgFilterLow, IN UINT MsgFilterHigh, + IN UINT QSflags, OUT PMSG Message); BOOL APIENTRY co_MsqPeekHardwareMessage(IN PUSER_MESSAGE_QUEUE MessageQueue, @@ -137,6 +141,7 @@ co_MsqPeekHardwareMessage(IN PUSER_MESSAGE_QUEUE MessageQueue, IN PWND Window, IN UINT MsgFilterLow, IN UINT MsgFilterHigh, + IN UINT QSflags, OUT MSG* pMsg); BOOL APIENTRY co_MsqPeekMouseMove(IN PUSER_MESSAGE_QUEUE MessageQueue, @@ -220,7 +225,6 @@ MsqSetStateWindow(PUSER_MESSAGE_QUEUE MessageQueue, ULONG Type, HWND hWnd); __inline BOOL MsqIsSignaled( PUSER_MESSAGE_QUEUE queue ); __inline VOID MsqSetQueueBits( PUSER_MESSAGE_QUEUE queue, WORD bits ); -__inline VOID MsqClearQueueBits( PUSER_MESSAGE_QUEUE queue, WORD bits ); BOOL APIENTRY IntInitMessagePumpHook(); BOOL APIENTRY IntUninitMessagePumpHook(); #define MAKE_LONG(x, y) ((((y) & 0xFFFF) << 16) | ((x) & 0xFFFF)) @@ -285,5 +289,9 @@ MsqCalculateMessageTime(IN PLARGE_INTEGER TickCount) VOID FASTCALL IdlePing(VOID); VOID FASTCALL IdlePong(VOID); +BOOL FASTCALL co_MsqReplyMessage(LRESULT); +UINT FASTCALL GetWakeMask(UINT, UINT); +VOID FASTCALL MsqWakeQueue(PUSER_MESSAGE_QUEUE,DWORD,BOOL); +VOID FASTCALL ClearMsgBitsMask(PUSER_MESSAGE_QUEUE,UINT); /* EOF */ diff --git a/reactos/subsystems/win32/win32k/include/win32.h b/reactos/subsystems/win32/win32k/include/win32.h index ed1e645a0a6..68a52a8e6e6 100644 --- a/reactos/subsystems/win32/win32k/include/win32.h +++ b/reactos/subsystems/win32/win32k/include/win32.h @@ -161,6 +161,7 @@ typedef struct _PROCESSINFO struct _DESKTOP* rpdeskStartup; PCLS pclsPrivateList; PCLS pclsPublicList; + INT cThreads; DWORD dwhmodLibLoadedMask; HANDLE ahmodLibLoaded[CLIBS]; struct _WINSTATION_OBJECT *prpwinsta; diff --git a/reactos/subsystems/win32/win32k/main/dllmain.c b/reactos/subsystems/win32/win32k/main/dllmain.c index d0bbae1b025..c8cf433ce04 100644 --- a/reactos/subsystems/win32/win32k/main/dllmain.c +++ b/reactos/subsystems/win32/win32k/main/dllmain.c @@ -268,6 +268,9 @@ Win32kThreadCallback(struct _ETHREAD *Thread, Win32Thread->TIF_flags &= ~TIF_INCLEANUP; co_IntDestroyCaret(Win32Thread); Win32Thread->ppi = PsGetCurrentProcessWin32Process(); + Win32Thread->ptiSibling = Win32Thread->ppi->ptiList; + Win32Thread->ppi->ptiList = Win32Thread; + Win32Thread->ppi->cThreads++; if (Win32Thread->rpdesk && !Win32Thread->pDeskInfo) { Win32Thread->pDeskInfo = Win32Thread->rpdesk->pDeskInfo; @@ -298,16 +301,39 @@ Win32kThreadCallback(struct _ETHREAD *Thread, else { DPRINT1("No TEB for this Thread!\n"); + // System thread running! Now SendMessage should be okay. + Win32Thread->pcti = &Win32Thread->cti; } Win32Thread->pEThread = Thread; } else { + PTHREADINFO pti; PSINGLE_LIST_ENTRY e; DPRINT("Destroying W32 thread TID:%d at IRQ level: %lu\n", Thread->Cid.UniqueThread, KeGetCurrentIrql()); Win32Thread->TIF_flags |= TIF_INCLEANUP; + pti = Win32Thread->ppi->ptiList; + if (pti == Win32Thread) + { + Win32Thread->ppi->ptiList = Win32Thread->ptiSibling; + Win32Thread->ppi->cThreads--; + } + else + { + do + { + if (pti->ptiSibling == Win32Thread) + { + pti->ptiSibling = Win32Thread->ptiSibling; + Win32Thread->ppi->cThreads--; + break; + } + pti = pti->ptiSibling; + } + while (pti); + } DceFreeThreadDCE(Win32Thread); HOOK_DestroyThreadHooks(Thread); EVENT_DestroyThreadEvents(Thread); @@ -332,9 +358,7 @@ Win32kThreadCallback(struct _ETHREAD *Thread, e = PopEntryList(&Win32Thread->ReferencesList); } - IntSetThreadDesktop(NULL, - TRUE); - + IntSetThreadDesktop(NULL, TRUE); PsSetThreadWin32Thread(Thread, NULL); } diff --git a/reactos/subsystems/win32/win32k/ntuser/desktop.c b/reactos/subsystems/win32/win32k/ntuser/desktop.c index c4af4525c8c..8e97e1b7b7a 100644 --- a/reactos/subsystems/win32/win32k/ntuser/desktop.c +++ b/reactos/subsystems/win32/win32k/ntuser/desktop.c @@ -1926,7 +1926,7 @@ IntSetThreadDesktop(IN PDESKTOP DesktopObject, RtlZeroMemory(&ctiSave, sizeof(CLIENTTHREADINFO)); - if (W32Thread->pcti && OldDesktop) + if (W32Thread->pcti && OldDesktop && NtCurrentTeb()) { RtlCopyMemory(&ctiSave, W32Thread->pcti, sizeof(CLIENTTHREADINFO)); DPRINT("Free ClientThreadInfo\n"); @@ -1934,7 +1934,7 @@ IntSetThreadDesktop(IN PDESKTOP DesktopObject, W32Thread->pcti = NULL; } - if (!W32Thread->pcti && DesktopObject) + if (!W32Thread->pcti && DesktopObject && NtCurrentTeb()) { DPRINT("Allocate ClientThreadInfo\n"); W32Thread->pcti = DesktopHeapAlloc( DesktopObject, diff --git a/reactos/subsystems/win32/win32k/ntuser/input.c b/reactos/subsystems/win32/win32k/ntuser/input.c index 717e8c4be1c..a8d6d83bb76 100644 --- a/reactos/subsystems/win32/win32k/ntuser/input.c +++ b/reactos/subsystems/win32/win32k/ntuser/input.c @@ -2,7 +2,7 @@ * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel * PURPOSE: Window classes - * FILE: subsys/win32k/ntuser/class.c + * FILE: subsystems/win32/win32k/ntuser/input.c * PROGRAMER: Casper S. Hornstrup (chorns@users.sourceforge.net) * REVISION HISTORY: * 06-06-2001 CSH Created @@ -206,13 +206,6 @@ MouseThreadMain(PVOID StartContext) NTSTATUS Status; MOUSE_ATTRIBUTES MouseAttr; - Status = Win32kInitWin32Thread(PsGetCurrentThread()); - if (!NT_SUCCESS(Status)) - { - DPRINT1("Win32K: Failed making keyboard thread a win32 thread.\n"); - return; //(Status); - } - KeSetPriorityThread(&PsGetCurrentThread()->Tcb, LOW_REALTIME_PRIORITY + 3); @@ -1399,8 +1392,9 @@ IntKeyboardInput(KEYBDINPUT *ki) FocusMessageQueue->Desktop->pDeskInfo->LastInputWasKbd = TRUE; Msg.pt = gpsi->ptCursor; - - MsqPostMessage(FocusMessageQueue, &Msg, FALSE, QS_KEY); + // Post to hardware queue, based on the first part of wine "some GetMessage tests" + // in test_PeekMessage() + MsqPostMessage(FocusMessageQueue, &Msg, TRUE, QS_KEY); } else { diff --git a/reactos/subsystems/win32/win32k/ntuser/message.c b/reactos/subsystems/win32/win32k/ntuser/message.c index 01dcb73a982..70f1678b622 100644 --- a/reactos/subsystems/win32/win32k/ntuser/message.c +++ b/reactos/subsystems/win32/win32k/ntuser/message.c @@ -2,7 +2,7 @@ * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel * PURPOSE: Messages -* FILE: subsys/win32k/ntuser/message.c +* FILE: subsystems/win32/win32k/ntuser/message.c * PROGRAMER: Casper S. Hornstrup (chorns@users.sourceforge.net) * REVISION HISTORY: * 06-06-2001 CSH Created @@ -342,12 +342,17 @@ IdlePing(VOID) pti = PsGetCurrentThreadWin32Thread(); - if ( pti && pti->pDeskInfo && pti == ptiForeground ) + if ( pti ) { - if ( pti->fsHooks & HOOKID_TO_FLAG(WH_FOREGROUNDIDLE) || - pti->pDeskInfo->fsHooks & HOOKID_TO_FLAG(WH_FOREGROUNDIDLE) ) + pti->pClientInfo->cSpins = 0; // Reset spins. + + if ( pti->pDeskInfo && pti == ptiForeground ) { - co_HOOK_CallHooks(WH_FOREGROUNDIDLE,HC_ACTION,0,0); + if ( pti->fsHooks & HOOKID_TO_FLAG(WH_FOREGROUNDIDLE) || + pti->pDeskInfo->fsHooks & HOOKID_TO_FLAG(WH_FOREGROUNDIDLE) ) + { + co_HOOK_CallHooks(WH_FOREGROUNDIDLE,HC_ACTION,0,0); + } } } @@ -371,6 +376,25 @@ IdlePong(VOID) } } +UINT FASTCALL +GetWakeMask(UINT first, UINT last ) +{ + UINT mask = QS_POSTMESSAGE | QS_SENDMESSAGE; /* Always selected */ + + if (first || last) + { + if ((first <= WM_KEYLAST) && (last >= WM_KEYFIRST)) mask |= QS_KEY; + if ( ((first <= WM_MOUSELAST) && (last >= WM_MOUSEFIRST)) || + ((first <= WM_NCMOUSELAST) && (last >= WM_NCMOUSEFIRST)) ) mask |= QS_MOUSE; + if ((first <= WM_TIMER) && (last >= WM_TIMER)) mask |= QS_TIMER; + if ((first <= WM_SYSTIMER) && (last >= WM_SYSTIMER)) mask |= QS_TIMER; + if ((first <= WM_PAINT) && (last >= WM_PAINT)) mask |= QS_PAINT; + } + else mask = QS_ALLINPUT; + + return mask; +} + static VOID FASTCALL IntCallWndProc( PWND Window, HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam) { @@ -424,6 +448,12 @@ IntDispatchMessage(PMSG pMsg) pti = PsGetCurrentThreadWin32Thread(); + if ( Window->head.pti != pti) + { + SetLastWin32Error( ERROR_MESSAGE_SYNC_ONLY ); + return 0; + } + if (((pMsg->message == WM_SYSTIMER) || (pMsg->message == WM_TIMER)) && (pMsg->lParam) ) @@ -503,24 +533,34 @@ IntDispatchMessage(PMSG pMsg) } /* -* Internal version of PeekMessage() doing all the work -*/ + * Internal version of PeekMessage() doing all the work + */ BOOL FASTCALL co_IntPeekMessage( PMSG Msg, PWND Window, UINT MsgFilterMin, UINT MsgFilterMax, - UINT RemoveMsg ) + UINT RemoveMsg, + BOOL bGMSG ) { PTHREADINFO pti; + PCLIENTINFO pci; LARGE_INTEGER LargeTickCount; PUSER_MESSAGE_QUEUE ThreadQueue; BOOL RemoveMessages; + UINT ProcessMask; + BOOL Hit = FALSE; pti = PsGetCurrentThreadWin32Thread(); ThreadQueue = pti->MessageQueue; + pci = pti->pClientInfo; RemoveMessages = RemoveMsg & PM_REMOVE; + ProcessMask = HIWORD(RemoveMsg); + + /* Hint, "If wMsgFilterMin and wMsgFilterMax are both zero, PeekMessage returns + all available messages (that is, no range filtering is performed)". */ + if (!ProcessMask) ProcessMask = (QS_ALLPOSTMESSAGE|QS_ALLINPUT); IdlePong(); @@ -528,16 +568,49 @@ co_IntPeekMessage( PMSG Msg, { KeQueryTickCount(&LargeTickCount); ThreadQueue->LastMsgRead = LargeTickCount.u.LowPart; + pti->pcti->tickLastMsgChecked = LargeTickCount.u.LowPart; /* Dispatch sent messages here. */ - while (co_MsqDispatchOneSentMessage(ThreadQueue)) ; + while ( co_MsqDispatchOneSentMessage(ThreadQueue) ) + { + /* if some PM_QS* flags were specified, only handle sent messages from now on */ + if (HIWORD(RemoveMsg) && !bGMSG) Hit = TRUE; // wine does this; ProcessMask = QS_SENDMESSAGE; + } + if (Hit) return FALSE; + + /* Clear changed bits so we can wait on them if we don't find a message */ + if (ProcessMask & QS_POSTMESSAGE) + { + pti->pcti->fsChangeBits &= ~(QS_POSTMESSAGE | QS_HOTKEY | QS_TIMER); + if (MsgFilterMin == 0 && MsgFilterMax == 0) // wine hack does this; ~0U) + { + pti->pcti->fsChangeBits &= ~QS_ALLPOSTMESSAGE; + } + } + + if (ProcessMask & QS_INPUT) + { + pti->pcti->fsChangeBits &= ~QS_INPUT; + } + + /* Now check for normal messages. */ + if ((ProcessMask & QS_POSTMESSAGE) && + MsqPeekMessage( ThreadQueue, + RemoveMessages, + Window, + MsgFilterMin, + MsgFilterMax, + ProcessMask, + Msg )) + { + return TRUE; + } /* Now look for a quit message. */ - if (ThreadQueue->QuitPosted) { /* According to the PSDK, WM_QUIT messages are always returned, regardless - of the filter specified */ + of the filter specified */ Msg->hwnd = NULL; Msg->message = WM_QUIT; Msg->wParam = ThreadQueue->QuitExitCode; @@ -545,49 +618,48 @@ co_IntPeekMessage( PMSG Msg, if (RemoveMessages) { ThreadQueue->QuitPosted = FALSE; + ClearMsgBitsMask(ThreadQueue, QS_POSTMESSAGE); + pti->pcti->fsWakeBits &= ~QS_ALLPOSTMESSAGE; + pti->pcti->fsChangeBits &= ~QS_ALLPOSTMESSAGE; } - - return TRUE; - } - - /* Now check for normal messages. */ - if (MsqPeekMessage( ThreadQueue, - RemoveMessages, - Window, - MsgFilterMin, - MsgFilterMax, - Msg )) - { return TRUE; } /* Check for hardware events. */ - if(co_MsqPeekMouseMove(ThreadQueue, - RemoveMessages, - Window, - MsgFilterMin, - MsgFilterMax, - Msg )) + if ((ProcessMask & QS_MOUSE) && + co_MsqPeekMouseMove( ThreadQueue, + RemoveMessages, + Window, + MsgFilterMin, + MsgFilterMax, + Msg )) { return TRUE; } - if(co_MsqPeekHardwareMessage(ThreadQueue, - RemoveMessages, - Window, - MsgFilterMin, - MsgFilterMax, - Msg)) + if ((ProcessMask & QS_INPUT) && + co_MsqPeekHardwareMessage( ThreadQueue, + RemoveMessages, + Window, + MsgFilterMin, + MsgFilterMax, + ProcessMask, + Msg)) { return TRUE; } /* Check for sent messages again. */ - while (co_MsqDispatchOneSentMessage(ThreadQueue)) - ; + while ( co_MsqDispatchOneSentMessage(ThreadQueue) ) + { + if (HIWORD(RemoveMsg) && !bGMSG) Hit = TRUE; + } + if (Hit) return FALSE; /* Check for paint messages. */ - if( IntGetPaintMessage( Window, + if ((ProcessMask & QS_PAINT) && + pti->cPaintsReady && + IntGetPaintMessage( Window, MsgFilterMin, MsgFilterMax, pti, @@ -597,7 +669,11 @@ co_IntPeekMessage( PMSG Msg, return TRUE; } - if (PostTimerMessages(Window)) + /* This is correct, check for the current threads timers waiting to be + posted to this threads message queue. If any we loop again. + */ + if ((ProcessMask & QS_TIMER) && + PostTimerMessages(Window)) { continue; } @@ -718,11 +794,12 @@ co_IntWaitMessage( PWND Window, do { - if ( co_IntPeekMessage( &Msg, - Window, - MsgFilterMin, - MsgFilterMax, - PM_NOREMOVE)) + if ( co_IntPeekMessage( &Msg, // Dont reenter! + Window, + MsgFilterMin, + MsgFilterMax, + MAKELONG( PM_NOREMOVE, GetWakeMask( MsgFilterMin, MsgFilterMax)), + TRUE ) ) // act like GetMessage. { return TRUE; } @@ -754,6 +831,7 @@ co_IntGetPeekMessage( PMSG pMsg, BOOL bGMSG ) { PWND Window; + PTHREADINFO pti; BOOL Present = FALSE; if ( hWnd == HWND_TOPMOST || hWnd == HWND_BROADCAST ) @@ -781,13 +859,19 @@ co_IntGetPeekMessage( PMSG pMsg, MsgFilterMax = 0; } + if (bGMSG) + { + RemoveMsg |= ((GetWakeMask( MsgFilterMin, MsgFilterMax ))<< 16); + } + do { Present = co_IntPeekMessage( pMsg, Window, MsgFilterMin, MsgFilterMax, - RemoveMsg ); + RemoveMsg, + bGMSG ); if (Present) { // The WH_GETMESSAGE hook enables an application to monitor messages about to @@ -796,13 +880,19 @@ co_IntGetPeekMessage( PMSG pMsg, co_HOOK_CallHooks( WH_GETMESSAGE, HC_ACTION, RemoveMsg & PM_REMOVE, (LPARAM)pMsg); if ( bGMSG ) - return (WM_QUIT != pMsg->message); + { + Present = (WM_QUIT != pMsg->message); + break; + } } if ( bGMSG ) { if ( !co_IntWaitMessage(Window, MsgFilterMin, MsgFilterMax) ) - return -1; + { + Present = -1; + break; + } } else { @@ -821,6 +911,14 @@ co_IntGetPeekMessage( PMSG pMsg, } while( bGMSG && !Present ); + pti = PsGetCurrentThreadWin32Thread(); + // Been spinning, time to swap vinyl... + if (pti->pClientInfo->cSpins >= 100) + { + // Clear the spin cycle to fix the mix. + pti->pClientInfo->cSpins = 0; + //if (!(pti->TIF_flags & TIF_SPINNING)) FIXME need to swap vinyl.. + } return Present; } @@ -947,7 +1045,7 @@ UserPostMessage( HWND Wnd, MsqPostQuitMessage(Window->head.pti->MessageQueue, wParam); } else - { + { Message.hwnd = Wnd; Message.message = Msg; Message.wParam = wParam; @@ -1283,7 +1381,9 @@ co_IntSendMessageWithCallBack( HWND hWnd, Message->Msg.lParam = lParamPacked; Message->CompletionEvent = NULL; Message->Result = 0; - Message->SenderQueue = NULL; //Win32Thread->MessageQueue; + Message->lResult = 0; + Message->QS_Flags = 0; + Message->SenderQueue = NULL; // mjmartin, you are right! This is null. Win32Thread->MessageQueue; IntReferenceMessageQueue(Window->head.pti->MessageQueue); Message->CompletionCallback = CompletionCallback; @@ -1291,6 +1391,9 @@ co_IntSendMessageWithCallBack( HWND hWnd, Message->HookMessage = MSQ_NORMAL | MSQ_SENTNOWAIT; Message->HasPackedLParam = (lParamBufferSize > 0); + Message->QS_Flags = QS_SENDMESSAGE; + MsqWakeQueue(Window->head.pti->MessageQueue, QS_SENDMESSAGE, FALSE); + InsertTailList(&Window->head.pti->MessageQueue->SentMessagesListHead, &Message->ListEntry); IntDereferenceMessageQueue(Window->head.pti->MessageQueue); @@ -1468,7 +1571,7 @@ UserSendNotifyMessage( HWND hWnd, WPARAM wParam, LPARAM lParam ) { - BOOL Result = TRUE; + BOOL Ret = TRUE; if (FindMsgMemory(Msg) != 0) { @@ -1491,37 +1594,28 @@ UserSendNotifyMessage( HWND hWnd, UserSendNotifyMessage(DesktopWindow->head.h, Msg, wParam, lParam); for (i = 0; List[i]; i++) { - UserSendNotifyMessage(List[i], Msg, wParam, lParam); + Ret = UserSendNotifyMessage(List[i], Msg, wParam, lParam); + if (!Ret) + { + DPRINT1("SendNotifyMessage: Failed in Broadcast!\n"); + break; + } } ExFreePool(List); } } else { - ULONG_PTR PResult; - PTHREADINFO pti; - PWND Window; - - if ( !(Window = UserGetWindowObject(hWnd)) ) return FALSE; - - pti = PsGetCurrentThreadWin32Thread(); - - if (Window->head.pti->MessageQueue != pti->MessageQueue) - { // Send message w/o waiting for it. - Result = UserPostMessage(hWnd, Msg, wParam, lParam); - } - else - { // Handle message and callback. - Result = co_IntSendMessageTimeoutSingle( hWnd, - Msg, - wParam, - lParam, - SMTO_NORMAL, - 0, - &PResult ); - } + ULONG_PTR lResult = 0; + Ret = co_IntSendMessageWithCallBack( hWnd, + Msg, + wParam, + lParam, + NULL, + 0, + &lResult); } - return Result; + return Ret; } @@ -1537,15 +1631,13 @@ IntGetQueueStatus(DWORD Changes) // wine: Changes &= (QS_ALLINPUT|QS_ALLPOSTMESSAGE|QS_SMRESULT); - Result = MAKELONG(Queue->ChangedBits & Changes, Queue->QueueBits & Changes); + /* High word, types of messages currently in the queue. + Low word, types of messages that have been added to the queue and that + are still in the queue + */ + Result = MAKELONG(pti->pcti->fsChangeBits & Changes, pti->pcti->fsWakeBits & Changes); - if (pti->pcti) - { - pti->pcti->fsChangeBits = Queue->ChangedBits; - pti->pcti->fsChangeBits &= ~Changes; - } - - Queue->ChangedBits &= ~Changes; + pti->pcti->fsChangeBits &= ~Changes; return Result; } @@ -1684,9 +1776,9 @@ NtUserWaitMessage(VOID) BOOL ret; UserEnterExclusive(); - + DPRINT("NtUserWaitMessage Enter\n"); ret = co_IntWaitMessage(NULL, 0, 0); - + DPRINT("NtUserWaitMessage Leave\n"); UserLeave(); return ret; @@ -2338,6 +2430,13 @@ NtUserWaitForInputIdle( IN HANDLE hProcess, if (dwMilliseconds != INFINITE) Timeout.QuadPart = (LONGLONG) dwMilliseconds * (LONGLONG) -10000; + W32Process->W32PF_flags |= W32PF_WAITFORINPUTIDLE; + for (pti = W32Process->ptiList; pti; pti = pti->ptiSibling) + { + pti->TIF_flags |= TIF_WAITFORINPUTIDLE; + pti->pClientInfo->dwTIFlags = pti->TIF_flags; + } + DPRINT("WFII: ppi 0x%x\n",W32Process); DPRINT("WFII: waiting for %p\n", Handles[1] ); do @@ -2368,7 +2467,7 @@ NtUserWaitForInputIdle( IN HANDLE hProcess, case STATUS_WAIT_2: { MSG Msg; - co_IntPeekMessage( &Msg, 0, 0, 0, PM_REMOVE | PM_QS_SENDMESSAGE ); + co_IntGetPeekMessage( &Msg, 0, 0, 0, PM_REMOVE | PM_QS_SENDMESSAGE, FALSE); DPRINT1("WFII: WAIT 2\n"); } break; @@ -2387,6 +2486,12 @@ NtUserWaitForInputIdle( IN HANDLE hProcess, while (TRUE); WaitExit: + for (pti = W32Process->ptiList; pti; pti = pti->ptiSibling) + { + pti->TIF_flags &= ~TIF_WAITFORINPUTIDLE; + pti->pClientInfo->dwTIFlags = pti->TIF_flags; + } + W32Process->W32PF_flags &= ~W32PF_WAITFORINPUTIDLE; ObDereferenceObject(Process); UserLeave(); return Status; diff --git a/reactos/subsystems/win32/win32k/ntuser/misc.c b/reactos/subsystems/win32/win32k/ntuser/misc.c index d884d0c145f..c2c240d033e 100644 --- a/reactos/subsystems/win32/win32k/ntuser/misc.c +++ b/reactos/subsystems/win32/win32k/ntuser/misc.c @@ -2,7 +2,7 @@ * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel * PURPOSE: Misc User funcs - * FILE: subsystem/win32/win32k/ntuser/misc.c + * FILE: subsystems/win32/win32k/ntuser/misc.c * PROGRAMER: Ge van Geldorp (ge@gse.nl) * REVISION HISTORY: * 2003/05/22 Created @@ -102,6 +102,8 @@ NtUserGetThreadState( break; case THREADSTATE_INSENDMESSAGE: { + PUSER_SENT_MESSAGE Message; + PLIST_ENTRY Entry; PUSER_MESSAGE_QUEUE MessageQueue = ((PTHREADINFO)PsGetCurrentThreadWin32Thread())->MessageQueue; DPRINT1("THREADSTATE_INSENDMESSAGE\n"); @@ -109,21 +111,39 @@ NtUserGetThreadState( ret = ISMEX_NOSEND; if (!IsListEmpty(&MessageQueue->SentMessagesListHead)) { - ret = ISMEX_SEND; + Entry = MessageQueue->SentMessagesListHead.Flink; + Message = CONTAINING_RECORD(Entry, USER_SENT_MESSAGE, ListEntry); + + if (Message->SenderQueue) + ret = ISMEX_SEND; + else + { + if (Message->CompletionCallback) + ret = ISMEX_CALLBACK; + else + ret = ISMEX_NOTIFY; + } + /* if ReplyMessage */ + if (Message->QS_Flags & QS_SMRESULT) ret |= ISMEX_REPLIED; } - else if (!IsListEmpty(&MessageQueue->NotifyMessagesListHead)) - { - /* FIXME Need to set message flag when in callback mode with notify */ - ret = ISMEX_NOTIFY; - } - /* FIXME Need to set message flag if replied to or ReplyMessage */ + break; } - case THREADSTATE_GETMESSAGETIME: - /* FIXME Needs more work! */ + case THREADSTATE_GETMESSAGETIME: ret = ((PTHREADINFO)PsGetCurrentThreadWin32Thread())->timeLast; break; + case THREADSTATE_UPTIMELASTREAD: + { + PTHREADINFO pti; + LARGE_INTEGER LargeTickCount; + pti = PsGetCurrentThreadWin32Thread(); + KeQueryTickCount(&LargeTickCount); + pti->MessageQueue->LastMsgRead = LargeTickCount.u.LowPart; + pti->pcti->tickLastMsgChecked = LargeTickCount.u.LowPart; + } + break; + case THREADSTATE_GETINPUTSTATE: ret = LOWORD(IntGetQueueStatus(QS_POSTMESSAGE|QS_TIMER|QS_PAINT|QS_SENDMESSAGE|QS_INPUT)) & (QS_KEY | QS_MOUSEBUTTON); break; diff --git a/reactos/subsystems/win32/win32k/ntuser/msgqueue.c b/reactos/subsystems/win32/win32k/ntuser/msgqueue.c index b03ba84365b..9b5ac9cd269 100644 --- a/reactos/subsystems/win32/win32k/ntuser/msgqueue.c +++ b/reactos/subsystems/win32/win32k/ntuser/msgqueue.c @@ -1,21 +1,3 @@ -/* - * ReactOS W32 Subsystem - * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 ReactOS Team - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ /* * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -41,74 +23,6 @@ static PAGED_LOOKASIDE_LIST MessageLookasideList; /* FUNCTIONS *****************************************************************/ -HANDLE FASTCALL -IntMsqSetWakeMask(DWORD WakeMask) -{ - PTHREADINFO Win32Thread; - PUSER_MESSAGE_QUEUE MessageQueue; - HANDLE MessageEventHandle; - - Win32Thread = PsGetCurrentThreadWin32Thread(); - if (Win32Thread == NULL || Win32Thread->MessageQueue == NULL) - return 0; - - MessageQueue = Win32Thread->MessageQueue; - MessageQueue->WakeMask = WakeMask; - MessageEventHandle = MessageQueue->NewMessagesHandle; - - if (Win32Thread->pcti) - Win32Thread->pcti->fsWakeMask = WakeMask; - - IdlePing(); - - return MessageEventHandle; -} - -BOOL FASTCALL -IntMsqClearWakeMask(VOID) -{ - PTHREADINFO Win32Thread; - PUSER_MESSAGE_QUEUE MessageQueue; - - Win32Thread = PsGetCurrentThreadWin32Thread(); - if (Win32Thread == NULL || Win32Thread->MessageQueue == NULL) - return FALSE; - - MessageQueue = Win32Thread->MessageQueue; -// HACK!!!!!!! Newbies that wrote this should hold your head down in shame! (jt) - MessageQueue->WakeMask = ~0; - - if (Win32Thread->pcti) - Win32Thread->pcti->fsWakeMask = 0; - - IdlePong(); - - return TRUE; -} - -VOID FASTCALL -MsqWakeQueue(PUSER_MESSAGE_QUEUE Queue, DWORD MessageBits) -{ - Queue->QueueBits |= MessageBits; - Queue->ChangedBits |= MessageBits; - if (Queue->WakeMask & MessageBits) - KeSetEvent(Queue->NewMessages, IO_NO_INCREMENT, FALSE); -} - -VOID FASTCALL -MsqIncPaintCountQueue(PUSER_MESSAGE_QUEUE Queue) -{ - Queue->PaintCount++; - MsqWakeQueue(Queue, QS_PAINT); -} - -VOID FASTCALL -MsqDecPaintCountQueue(PUSER_MESSAGE_QUEUE Queue) -{ - Queue->PaintCount--; -} - - INIT_FUNCTION NTSTATUS NTAPI @@ -125,12 +39,153 @@ MsqInitializeImpl(VOID) return(STATUS_SUCCESS); } +HANDLE FASTCALL +IntMsqSetWakeMask(DWORD WakeMask) +{ + PTHREADINFO Win32Thread; + PUSER_MESSAGE_QUEUE MessageQueue; + HANDLE MessageEventHandle; + DWORD dwFlags = HIWORD(WakeMask); + + Win32Thread = PsGetCurrentThreadWin32Thread(); + if (Win32Thread == NULL || Win32Thread->MessageQueue == NULL) + return 0; + + MessageQueue = Win32Thread->MessageQueue; +// Win32Thread->pEventQueueServer; IntMsqSetWakeMask returns Win32Thread->hEventQueueClient + MessageEventHandle = MessageQueue->NewMessagesHandle; + + if (Win32Thread->pcti) + { + if ( (Win32Thread->pcti->fsChangeBits & LOWORD(WakeMask)) || + ( (dwFlags & MWMO_INPUTAVAILABLE) && (Win32Thread->pcti->fsWakeBits & LOWORD(WakeMask)) ) ) + { + DPRINT1("Chg 0x%x Wake 0x%x Mask 0x%x\n",Win32Thread->pcti->fsChangeBits, Win32Thread->pcti->fsWakeBits, WakeMask); + KeSetEvent(MessageQueue->NewMessages, IO_NO_INCREMENT, FALSE); // Wake it up! + return MessageEventHandle; + } + } + + IdlePing(); + + return MessageEventHandle; +} + +BOOL FASTCALL +IntMsqClearWakeMask(VOID) +{ + PTHREADINFO Win32Thread; + + Win32Thread = PsGetCurrentThreadWin32Thread(); + if (Win32Thread == NULL || Win32Thread->MessageQueue == NULL) + return FALSE; + // Very hacky, but that is what they do. + Win32Thread->pcti->fsWakeBits = 0; + + IdlePong(); + + return TRUE; +} + +/* + Due to the uncertainty of knowing what was set in our multilevel message queue, + and even if the bits are all cleared. The same as cTimers/cPaintsReady. + I think this is the best solution... (jt) */ +VOID FASTCALL +MsqWakeQueue(PUSER_MESSAGE_QUEUE Queue, DWORD MessageBits, BOOL KeyEvent) +{ + PTHREADINFO pti; + + pti = Queue->Thread->Tcb.Win32Thread; + pti->pcti->fsWakeBits |= MessageBits; + pti->pcti->fsChangeBits |= MessageBits; + + // Start bit accounting to help clear the main set of bits. + if (MessageBits & QS_KEY) Queue->nCntsQBits[QSRosKey]++; + if (MessageBits & QS_MOUSEMOVE) Queue->nCntsQBits[QSRosMouseMove]++; + if (MessageBits & QS_MOUSEBUTTON) Queue->nCntsQBits[QSRosMouseButton]++; + if (MessageBits & QS_POSTMESSAGE) Queue->nCntsQBits[QSRosPostMessage]++; + if (MessageBits & QS_SENDMESSAGE) Queue->nCntsQBits[QSRosSendMessage]++; + if (MessageBits & QS_HOTKEY) Queue->nCntsQBits[QSRosHotKey]++; + + if (KeyEvent) + KeSetEvent(Queue->NewMessages, IO_NO_INCREMENT, FALSE); +} + +VOID FASTCALL +ClearMsgBitsMask(PUSER_MESSAGE_QUEUE Queue, UINT MessageBits) +{ + PTHREADINFO pti; + UINT ClrMask = 0; + + pti = Queue->Thread->Tcb.Win32Thread; + + if (MessageBits & QS_KEY) + { + if (--Queue->nCntsQBits[QSRosKey] == 0) ClrMask |= QS_KEY; + } + if (MessageBits & QS_MOUSEMOVE) // ReactOS hard coded. + { // Account for tracking mouse moves.. + if (--Queue->nCntsQBits[QSRosMouseMove] == 0) ClrMask |= QS_MOUSEMOVE; + // Handle mouse move bits here. + if (Queue->MouseMoved) ClrMask |= QS_MOUSEMOVE; + } + if (MessageBits & QS_MOUSEBUTTON) + { + if (--Queue->nCntsQBits[QSRosMouseButton] == 0) ClrMask |= QS_MOUSEBUTTON; + } + if (MessageBits & QS_POSTMESSAGE) + { + if (--Queue->nCntsQBits[QSRosPostMessage] == 0) ClrMask |= QS_POSTMESSAGE; + } + if (MessageBits & QS_TIMER) // ReactOS hard coded. + { // Handle timer bits here. + if ( pti->cTimersReady ) + { + if (--pti->cTimersReady == 0) ClrMask |= QS_TIMER; + } + } + if (MessageBits & QS_PAINT) // ReactOS hard coded. + { // Handle paint bits here. + if ( pti->cPaintsReady ) + { + if (--pti->cPaintsReady == 0) ClrMask |= QS_PAINT; + } + } + if (MessageBits & QS_SENDMESSAGE) + { + if (--Queue->nCntsQBits[QSRosSendMessage] == 0) ClrMask |= QS_SENDMESSAGE; + } + if (MessageBits & QS_HOTKEY) + { + if (--Queue->nCntsQBits[QSRosHotKey] == 0) ClrMask |= QS_HOTKEY; + } + + pti->pcti->fsWakeBits &= ~ClrMask; + pti->pcti->fsChangeBits &= ~ClrMask; +} + +VOID FASTCALL +MsqIncPaintCountQueue(PUSER_MESSAGE_QUEUE Queue) +{ + PTHREADINFO pti; + pti = Queue->Thread->Tcb.Win32Thread; + pti->cPaintsReady++; + MsqWakeQueue(Queue, QS_PAINT, TRUE); +} + +VOID FASTCALL +MsqDecPaintCountQueue(PUSER_MESSAGE_QUEUE Queue) +{ + ClearMsgBitsMask(Queue, QS_PAINT); +} + VOID FASTCALL MsqPostMouseMove(PUSER_MESSAGE_QUEUE MessageQueue, MSG* Msg) { MessageQueue->MouseMoveMsg = *Msg; MessageQueue->MouseMoved = TRUE; - MsqWakeQueue(MessageQueue, QS_MOUSEMOVE); + MsqWakeQueue(MessageQueue, QS_MOUSEMOVE, TRUE); } VOID FASTCALL @@ -366,6 +421,7 @@ co_MsqDispatchOneSentMessage(PUSER_MESSAGE_QUEUE MessageQueue) PUSER_SENT_MESSAGE Message; PLIST_ENTRY Entry; LRESULT Result; + PTHREADINFO pti; if (IsListEmpty(&MessageQueue->SentMessagesListHead)) { @@ -376,11 +432,20 @@ co_MsqDispatchOneSentMessage(PUSER_MESSAGE_QUEUE MessageQueue) Entry = RemoveHeadList(&MessageQueue->SentMessagesListHead); Message = CONTAINING_RECORD(Entry, USER_SENT_MESSAGE, ListEntry); + pti = MessageQueue->Thread->Tcb.Win32Thread; + // Processing a message sent to it from another thread. + if ( MessageQueue != Message->SenderQueue ) // most likely, but, to be sure. + { + pti->pcti->CTI_flags |= CTI_INSENDMESSAGE; // Let the user know... + } + /* insert it to the list of messages that are currently dispatched by this message queue */ InsertTailList(&MessageQueue->LocalDispatchingMessagesHead, &Message->ListEntry); + ClearMsgBitsMask(MessageQueue, Message->QS_Flags); + if (Message->HookMessage == MSQ_ISHOOK) { // Direct Hook Call processor Result = co_CallHook( Message->Msg.message, // HookId @@ -419,6 +484,11 @@ co_MsqDispatchOneSentMessage(PUSER_MESSAGE_QUEUE MessageQueue) /* still keep the sender's message queue locked, so the sender can't exit the MsqSendMessage() function (if timed out) */ + if (Message->QS_Flags & QS_SMRESULT) + { + Result = Message->lResult; + } + /* Let the sender know the result. */ if (Message->Result != NULL) { @@ -456,6 +526,9 @@ co_MsqDispatchOneSentMessage(PUSER_MESSAGE_QUEUE MessageQueue) /* free the message */ ExFreePoolWithTag(Message, TAG_USRMSG); + + pti->pcti->CTI_flags &= ~CTI_INSENDMESSAGE; + return(TRUE); } @@ -483,6 +556,7 @@ MsqRemoveWindowMessagesFromQueue(PVOID pWindow) if (PostedMessage->Msg.hwnd == Window->head.h) { RemoveEntryList(&PostedMessage->ListEntry); + ClearMsgBitsMask(MessageQueue, PostedMessage->QS_Flags); MsqDestroyMessage(PostedMessage); CurrentEntry = MessageQueue->PostedMessagesListHead.Flink; } @@ -504,6 +578,7 @@ MsqRemoveWindowMessagesFromQueue(PVOID pWindow) DPRINT("Notify the sender and remove a message from the queue that had not been dispatched\n"); RemoveEntryList(&SentMessage->ListEntry); + ClearMsgBitsMask(MessageQueue, SentMessage->QS_Flags); /* remove the message from the dispatching list if neede */ if ((!(SentMessage->HookMessage & MSQ_SENTNOWAIT)) @@ -581,6 +656,8 @@ co_MsqSendMessage(PUSER_MESSAGE_QUEUE MessageQueue, Message->Msg.lParam = lParam; Message->CompletionEvent = &CompletionEvent; Message->Result = &Result; + Message->lResult = 0; + Message->QS_Flags = 0; Message->SenderQueue = ThreadQueue; IntReferenceMessageQueue(ThreadQueue); Message->CompletionCallback = NULL; @@ -596,7 +673,8 @@ co_MsqSendMessage(PUSER_MESSAGE_QUEUE MessageQueue, /* queue it in the destination's message queue */ InsertTailList(&MessageQueue->SentMessagesListHead, &Message->ListEntry); - MsqWakeQueue(MessageQueue, QS_SENDMESSAGE); + Message->QS_Flags = QS_SENDMESSAGE; + MsqWakeQueue(MessageQueue, QS_SENDMESSAGE, TRUE); /* we can't access the Message anymore since it could have already been deleted! */ @@ -746,7 +824,9 @@ MsqPostMessage(PUSER_MESSAGE_QUEUE MessageQueue, MSG* Msg, BOOLEAN HardwareMessa InsertTailList(&MessageQueue->HardwareMessagesListHead, &Message->ListEntry); } - MsqWakeQueue(MessageQueue, MessageBits); + + Message->QS_Flags = MessageBits; + MsqWakeQueue(MessageQueue, MessageBits, (MessageBits & QS_TIMER ? FALSE : TRUE)); } VOID FASTCALL @@ -754,7 +834,7 @@ MsqPostQuitMessage(PUSER_MESSAGE_QUEUE MessageQueue, ULONG ExitCode) { MessageQueue->QuitPosted = TRUE; MessageQueue->QuitExitCode = ExitCode; - MsqWakeQueue(MessageQueue, QS_POSTMESSAGE); + MsqWakeQueue(MessageQueue, QS_POSTMESSAGE|QS_ALLPOSTMESSAGE, TRUE); } /*********************************************************************** @@ -1122,17 +1202,38 @@ co_MsqPeekMouseMove(IN PUSER_MESSAGE_QUEUE MessageQueue, *pMsg = msg; if(Remove) + { + ClearMsgBitsMask(MessageQueue, QS_MOUSEMOVE); MessageQueue->MouseMoved = FALSE; + } return AcceptMessage; } +/* check whether a message filter contains at least one potential hardware message */ +static INT FASTCALL +filter_contains_hw_range( UINT first, UINT last ) +{ + /* hardware message ranges are (in numerical order): + * WM_NCMOUSEFIRST .. WM_NCMOUSELAST + * WM_KEYFIRST .. WM_KEYLAST + * WM_MOUSEFIRST .. WM_MOUSELAST + */ + if (!last) --last; + if (last < WM_NCMOUSEFIRST) return 0; + if (first > WM_NCMOUSELAST && last < WM_KEYFIRST) return 0; + if (first > WM_KEYLAST && last < WM_MOUSEFIRST) return 0; + if (first > WM_MOUSELAST) return 0; + return 1; +} + BOOL APIENTRY co_MsqPeekHardwareMessage(IN PUSER_MESSAGE_QUEUE MessageQueue, IN BOOL Remove, IN PWND Window, IN UINT MsgFilterLow, IN UINT MsgFilterHigh, + IN UINT QSflags, OUT MSG* pMsg) { @@ -1141,33 +1242,45 @@ co_MsqPeekHardwareMessage(IN PUSER_MESSAGE_QUEUE MessageQueue, PLIST_ENTRY ListHead, CurrentEntry = NULL; MSG msg; + if (!filter_contains_hw_range( MsgFilterLow, MsgFilterHigh )) return FALSE; + ListHead = &MessageQueue->HardwareMessagesListHead; CurrentEntry = ListHead->Flink; - while(CurrentEntry != ListHead) - { - CurrentMessage = CONTAINING_RECORD(CurrentEntry, USER_MESSAGE, + if (IsListEmpty(CurrentEntry)) return FALSE; + + CurrentMessage = CONTAINING_RECORD(CurrentEntry, USER_MESSAGE, ListEntry); - - msg = CurrentMessage->Msg; - - AcceptMessage = co_IntProcessHardwareMessage(&msg, &Remove, MsgFilterLow, MsgFilterHigh); - + do + { + if (IsListEmpty(CurrentEntry)) break; + if (!CurrentMessage) break; CurrentEntry = CurrentMessage->ListEntry.Flink; - if (Remove) + if ( (( MsgFilterLow == 0 && MsgFilterHigh == 0 ) && (CurrentMessage->QS_Flags & QSflags)) || + ( MsgFilterLow <= CurrentMessage->Msg.message && MsgFilterHigh >= CurrentMessage->Msg.message ) ) { - RemoveEntryList(&CurrentMessage->ListEntry); - MsqDestroyMessage(CurrentMessage); - } + msg = CurrentMessage->Msg; - if(AcceptMessage) - { - *pMsg = msg; - return TRUE; - } + AcceptMessage = co_IntProcessHardwareMessage(&msg, &Remove, MsgFilterLow, MsgFilterHigh); + if (Remove) + { + RemoveEntryList(&CurrentMessage->ListEntry); + ClearMsgBitsMask(MessageQueue, CurrentMessage->QS_Flags); + MsqDestroyMessage(CurrentMessage); + } + + if (AcceptMessage) + { + *pMsg = msg; + return TRUE; + } + } + CurrentMessage = CONTAINING_RECORD(CurrentEntry, USER_MESSAGE, + ListEntry); } + while(CurrentEntry != ListHead); return FALSE; } @@ -1178,6 +1291,7 @@ MsqPeekMessage(IN PUSER_MESSAGE_QUEUE MessageQueue, IN PWND Window, IN UINT MsgFilterLow, IN UINT MsgFilterHigh, + IN UINT QSflags, OUT PMSG Message) { PLIST_ENTRY CurrentEntry; @@ -1186,29 +1300,35 @@ MsqPeekMessage(IN PUSER_MESSAGE_QUEUE MessageQueue, CurrentEntry = MessageQueue->PostedMessagesListHead.Flink; ListHead = &MessageQueue->PostedMessagesListHead; - while (CurrentEntry != ListHead) - { - CurrentMessage = CONTAINING_RECORD(CurrentEntry, USER_MESSAGE, + + if (IsListEmpty(CurrentEntry)) return FALSE; + + CurrentMessage = CONTAINING_RECORD(CurrentEntry, USER_MESSAGE, ListEntry); - if ( ( !Window || - PtrToInt(Window) == 1 || - Window->head.h == CurrentMessage->Msg.hwnd ) && - ( (MsgFilterLow == 0 && MsgFilterHigh == 0) || - ( MsgFilterLow <= CurrentMessage->Msg.message && - MsgFilterHigh >= CurrentMessage->Msg.message ) ) ) + do + { + if (IsListEmpty(CurrentEntry)) break; + if (!CurrentMessage) break; + CurrentEntry = CurrentEntry->Flink; + + if ( ( !Window || Window == HWND_BOTTOM || Window->head.h == CurrentMessage->Msg.hwnd ) && + ( ( ( MsgFilterLow == 0 && MsgFilterHigh == 0 ) && CurrentMessage->QS_Flags & QSflags ) || + ( MsgFilterLow <= CurrentMessage->Msg.message && MsgFilterHigh >= CurrentMessage->Msg.message ) ) ) { - *Message= CurrentMessage->Msg; + *Message = CurrentMessage->Msg; if (Remove) { RemoveEntryList(&CurrentMessage->ListEntry); + ClearMsgBitsMask(MessageQueue, CurrentMessage->QS_Flags); MsqDestroyMessage(CurrentMessage); } - return(TRUE); } - CurrentEntry = CurrentEntry->Flink; + CurrentMessage = CONTAINING_RECORD(CurrentEntry, USER_MESSAGE, + ListEntry); } + while (CurrentEntry != ListHead); return(FALSE); } @@ -1257,9 +1377,6 @@ MsqInitializeMessageQueue(struct _ETHREAD *Thread, PUSER_MESSAGE_QUEUE MessageQu KeQueryTickCount(&LargeTickCount); MessageQueue->LastMsgRead = LargeTickCount.u.LowPart; MessageQueue->FocusWindow = NULL; - MessageQueue->PaintCount = 0; -// HACK!!!!!!! Newbies that wrote this should hold your head down in shame! (jt) - MessageQueue->WakeMask = ~0; MessageQueue->NewMessagesHandle = NULL; Status = ZwCreateEvent(&MessageQueue->NewMessagesHandle, EVENT_ALL_ACCESS, @@ -1288,6 +1405,10 @@ MsqCleanupMessageQueue(PUSER_MESSAGE_QUEUE MessageQueue) PLIST_ENTRY CurrentEntry; PUSER_MESSAGE CurrentMessage; PUSER_SENT_MESSAGE CurrentSentMessage; + PTHREADINFO pti; + + pti = MessageQueue->Thread->Tcb.Win32Thread; + /* cleanup posted messages */ while (!IsListEmpty(&MessageQueue->PostedMessagesListHead)) @@ -1391,6 +1512,16 @@ MsqCleanupMessageQueue(PUSER_MESSAGE_QUEUE MessageQueue) locked later */ } + // Clear it all out. + pti->pcti->fsWakeBits = 0; + pti->pcti->fsChangeBits = 0; + + MessageQueue->nCntsQBits[QSRosKey] = 0; + MessageQueue->nCntsQBits[QSRosMouseMove] = 0; + MessageQueue->nCntsQBits[QSRosMouseButton] = 0; + MessageQueue->nCntsQBits[QSRosPostMessage] = 0; + MessageQueue->nCntsQBits[QSRosSendMessage] = 0; + MessageQueue->nCntsQBits[QSRosHotKey] = 0; } PUSER_MESSAGE_QUEUE FASTCALL @@ -1475,6 +1606,38 @@ MsqGetMessageExtraInfo(VOID) return MessageQueue->ExtraInfo; } +BOOL FASTCALL +co_MsqReplyMessage( LRESULT lResult ) +{ + PUSER_SENT_MESSAGE Message; + PLIST_ENTRY Entry; + PTHREADINFO pti; + PUSER_MESSAGE_QUEUE MessageQueue; + + pti = PsGetCurrentThreadWin32Thread(); + MessageQueue = pti->MessageQueue; + + if(!MessageQueue) return FALSE; + + if (IsListEmpty(&MessageQueue->SentMessagesListHead)) + { + return(FALSE); + } + // Do we loop through all msgs or just set the first one? + Entry = MessageQueue->SentMessagesListHead.Flink; + Message = CONTAINING_RECORD(Entry, USER_SENT_MESSAGE, ListEntry); + + if (Message->QS_Flags & QS_SMRESULT) return FALSE; + + if (Message->SenderQueue || Message->CompletionCallback) + { + Message->lResult = lResult; + Message->QS_Flags |= QS_SMRESULT; + MsqWakeQueue(MessageQueue, 0, TRUE); // Wake it up!? Bits? + } + return TRUE; +} + HWND FASTCALL MsqSetStateWindow(PUSER_MESSAGE_QUEUE MessageQueue, ULONG Type, HWND hWnd) { diff --git a/reactos/subsystems/win32/win32k/ntuser/painting.c b/reactos/subsystems/win32/win32k/ntuser/painting.c index 6eca443034a..6cc9b5a15bd 100644 --- a/reactos/subsystems/win32/win32k/ntuser/painting.c +++ b/reactos/subsystems/win32/win32k/ntuser/painting.c @@ -2,7 +2,7 @@ * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel * PURPOSE: Window painting function - * FILE: subsys/win32k/ntuser/painting.c + * FILE: subsystems/win32/win32k/ntuser/painting.c * PROGRAMER: Filip Navara (xnavara@volny.cz) * REVISION HISTORY: * 06/06/2001 Created (?) @@ -660,9 +660,7 @@ IntGetPaintMessage( MSG *Message, BOOL Remove) { - PUSER_MESSAGE_QUEUE MessageQueue = (PUSER_MESSAGE_QUEUE)Thread->MessageQueue; - - if (!MessageQueue->PaintCount) + if (!Thread->cPaintsReady) return FALSE; if ((MsgFilterMin != 0 || MsgFilterMax != 0) && @@ -673,9 +671,9 @@ IntGetPaintMessage( if (Message->hwnd == NULL) { - DPRINT1("PAINTING BUG: Thread marked as containing dirty windows, but no dirty windows found!\n"); + DPRINT1("PAINTING BUG: Thread marked as containing dirty windows, but no dirty windows found! Counts %d\n",Thread->cPaintsReady); /* Hack to stop spamming the debuglog ! */ - MessageQueue->PaintCount = 0; + Thread->cPaintsReady = 0; return FALSE; } diff --git a/reactos/subsystems/win32/win32k/ntuser/simplecall.c b/reactos/subsystems/win32/win32k/ntuser/simplecall.c index 953f936574a..df2f1e4b00a 100644 --- a/reactos/subsystems/win32/win32k/ntuser/simplecall.c +++ b/reactos/subsystems/win32/win32k/ntuser/simplecall.c @@ -333,6 +333,8 @@ NtUserCallOneParam( _SEH2_END; RETURN(Ret); } + case ONEPARAM_ROUTINE_REPLYMESSAGE: + RETURN (co_MsqReplyMessage((LRESULT) Param)); } DPRINT1("Calling invalid routine number 0x%x in NtUserCallOneParam(), Param=0x%x\n", Routine, Param); diff --git a/reactos/subsystems/win32/win32k/ntuser/timer.c b/reactos/subsystems/win32/win32k/ntuser/timer.c index b3a7fbde3bc..ee316aab8c2 100644 --- a/reactos/subsystems/win32/win32k/ntuser/timer.c +++ b/reactos/subsystems/win32/win32k/ntuser/timer.c @@ -361,7 +361,7 @@ PostTimerMessages(PWND Window) MsqPostMessage(ThreadQueue, &Msg, FALSE, QS_TIMER); pTmr->flags &= ~TMRF_READY; - ThreadQueue->WakeMask = ~QS_TIMER; + pti->cTimersReady++; Hit = TRUE; break; } From 6e80bd7c43719c637a6085bc64f4117729e0a6fb Mon Sep 17 00:00:00 2001 From: James Tabor Date: Fri, 3 Dec 2010 18:02:02 +0000 Subject: [PATCH 020/181] [Win32k] - More fixes to In Send and Reply message support. svn path=/trunk/; revision=49935 --- .../win32/win32k/include/msgqueue.h | 1 + .../subsystems/win32/win32k/include/win32.h | 1 + .../subsystems/win32/win32k/ntuser/message.c | 3 +- reactos/subsystems/win32/win32k/ntuser/misc.c | 11 ++----- .../subsystems/win32/win32k/ntuser/msgqueue.c | 31 +++++++++---------- 5 files changed, 22 insertions(+), 25 deletions(-) diff --git a/reactos/subsystems/win32/win32k/include/msgqueue.h b/reactos/subsystems/win32/win32k/include/msgqueue.h index 00ea6e131d1..7c84ed0d4ae 100644 --- a/reactos/subsystems/win32/win32k/include/msgqueue.h +++ b/reactos/subsystems/win32/win32k/include/msgqueue.h @@ -38,6 +38,7 @@ typedef struct _USER_SENT_MESSAGE LRESULT* Result; LRESULT lResult; struct _USER_MESSAGE_QUEUE* SenderQueue; + struct _USER_MESSAGE_QUEUE* CallBackSenderQueue; SENDASYNCPROC CompletionCallback; ULONG_PTR CompletionCallbackContext; /* entry in the dispatching list of the sender's message queue */ diff --git a/reactos/subsystems/win32/win32k/include/win32.h b/reactos/subsystems/win32/win32k/include/win32.h index 68a52a8e6e6..56bfd56856a 100644 --- a/reactos/subsystems/win32/win32k/include/win32.h +++ b/reactos/subsystems/win32/win32k/include/win32.h @@ -75,6 +75,7 @@ typedef struct _THREADINFO PCLIENTINFO pClientInfo; FLONG TIF_flags; PUNICODE_STRING pstrAppName; + struct _USER_SENT_MESSAGE *pusmCurrent; LONG timeLast; ULONG_PTR idLast; INT exitCode; diff --git a/reactos/subsystems/win32/win32k/ntuser/message.c b/reactos/subsystems/win32/win32k/ntuser/message.c index 70f1678b622..7c339b8dee7 100644 --- a/reactos/subsystems/win32/win32k/ntuser/message.c +++ b/reactos/subsystems/win32/win32k/ntuser/message.c @@ -1383,7 +1383,8 @@ co_IntSendMessageWithCallBack( HWND hWnd, Message->Result = 0; Message->lResult = 0; Message->QS_Flags = 0; - Message->SenderQueue = NULL; // mjmartin, you are right! This is null. Win32Thread->MessageQueue; + Message->SenderQueue = NULL; // mjmartin, you are right! This is null. + Message->CallBackSenderQueue = Win32Thread->MessageQueue; IntReferenceMessageQueue(Window->head.pti->MessageQueue); Message->CompletionCallback = CompletionCallback; diff --git a/reactos/subsystems/win32/win32k/ntuser/misc.c b/reactos/subsystems/win32/win32k/ntuser/misc.c index c2c240d033e..eb6a066bd55 100644 --- a/reactos/subsystems/win32/win32k/ntuser/misc.c +++ b/reactos/subsystems/win32/win32k/ntuser/misc.c @@ -102,18 +102,13 @@ NtUserGetThreadState( break; case THREADSTATE_INSENDMESSAGE: { - PUSER_SENT_MESSAGE Message; - PLIST_ENTRY Entry; - PUSER_MESSAGE_QUEUE MessageQueue = - ((PTHREADINFO)PsGetCurrentThreadWin32Thread())->MessageQueue; + PUSER_SENT_MESSAGE Message = + ((PTHREADINFO)PsGetCurrentThreadWin32Thread())->pusmCurrent; DPRINT1("THREADSTATE_INSENDMESSAGE\n"); ret = ISMEX_NOSEND; - if (!IsListEmpty(&MessageQueue->SentMessagesListHead)) + if (Message) { - Entry = MessageQueue->SentMessagesListHead.Flink; - Message = CONTAINING_RECORD(Entry, USER_SENT_MESSAGE, ListEntry); - if (Message->SenderQueue) ret = ISMEX_SEND; else diff --git a/reactos/subsystems/win32/win32k/ntuser/msgqueue.c b/reactos/subsystems/win32/win32k/ntuser/msgqueue.c index 9b5ac9cd269..b4569eeebc6 100644 --- a/reactos/subsystems/win32/win32k/ntuser/msgqueue.c +++ b/reactos/subsystems/win32/win32k/ntuser/msgqueue.c @@ -418,7 +418,7 @@ MsqDestroyMessage(PUSER_MESSAGE Message) BOOLEAN FASTCALL co_MsqDispatchOneSentMessage(PUSER_MESSAGE_QUEUE MessageQueue) { - PUSER_SENT_MESSAGE Message; + PUSER_SENT_MESSAGE SaveMsg, Message; PLIST_ENTRY Entry; LRESULT Result; PTHREADINFO pti; @@ -433,9 +433,14 @@ co_MsqDispatchOneSentMessage(PUSER_MESSAGE_QUEUE MessageQueue) Message = CONTAINING_RECORD(Entry, USER_SENT_MESSAGE, ListEntry); pti = MessageQueue->Thread->Tcb.Win32Thread; + + SaveMsg = pti->pusmCurrent; + pti->pusmCurrent = Message; + // Processing a message sent to it from another thread. - if ( MessageQueue != Message->SenderQueue ) // most likely, but, to be sure. - { + if ( ( Message->SenderQueue && MessageQueue != Message->SenderQueue) || + ( Message->CallBackSenderQueue && MessageQueue != Message->CallBackSenderQueue )) + { // most likely, but, to be sure. pti->pcti->CTI_flags |= CTI_INSENDMESSAGE; // Let the user know... } @@ -528,6 +533,7 @@ co_MsqDispatchOneSentMessage(PUSER_MESSAGE_QUEUE MessageQueue) ExFreePoolWithTag(Message, TAG_USRMSG); pti->pcti->CTI_flags &= ~CTI_INSENDMESSAGE; + pti->pusmCurrent = SaveMsg; return(TRUE); } @@ -659,6 +665,7 @@ co_MsqSendMessage(PUSER_MESSAGE_QUEUE MessageQueue, Message->lResult = 0; Message->QS_Flags = 0; Message->SenderQueue = ThreadQueue; + Message->CallBackSenderQueue = NULL; IntReferenceMessageQueue(ThreadQueue); Message->CompletionCallback = NULL; Message->CompletionCallbackContext = 0; @@ -1606,34 +1613,26 @@ MsqGetMessageExtraInfo(VOID) return MessageQueue->ExtraInfo; } +// ReplyMessage is called by the thread receiving the window message. BOOL FASTCALL co_MsqReplyMessage( LRESULT lResult ) { PUSER_SENT_MESSAGE Message; - PLIST_ENTRY Entry; PTHREADINFO pti; - PUSER_MESSAGE_QUEUE MessageQueue; pti = PsGetCurrentThreadWin32Thread(); - MessageQueue = pti->MessageQueue; + Message = pti->pusmCurrent; - if(!MessageQueue) return FALSE; - - if (IsListEmpty(&MessageQueue->SentMessagesListHead)) - { - return(FALSE); - } - // Do we loop through all msgs or just set the first one? - Entry = MessageQueue->SentMessagesListHead.Flink; - Message = CONTAINING_RECORD(Entry, USER_SENT_MESSAGE, ListEntry); + if(!Message) return FALSE; if (Message->QS_Flags & QS_SMRESULT) return FALSE; + // SendMessageXxx || Callback msg and not a notify msg if (Message->SenderQueue || Message->CompletionCallback) { Message->lResult = lResult; Message->QS_Flags |= QS_SMRESULT; - MsqWakeQueue(MessageQueue, 0, TRUE); // Wake it up!? Bits? + // See co_MsqDispatchOneSentMessage, change bits already accounted for and cleared and this msg is going away.. } return TRUE; } From a3bba1d54ae135f32620825ac0cbaf3433544546 Mon Sep 17 00:00:00 2001 From: James Tabor Date: Fri, 3 Dec 2010 18:13:28 +0000 Subject: [PATCH 021/181] [Win32k] - More fixes to In Send message support. One more case fixed in looping back. svn path=/trunk/; revision=49936 --- reactos/subsystems/win32/win32k/ntuser/msgqueue.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/reactos/subsystems/win32/win32k/ntuser/msgqueue.c b/reactos/subsystems/win32/win32k/ntuser/msgqueue.c index b4569eeebc6..027489dc122 100644 --- a/reactos/subsystems/win32/win32k/ntuser/msgqueue.c +++ b/reactos/subsystems/win32/win32k/ntuser/msgqueue.c @@ -532,7 +532,8 @@ co_MsqDispatchOneSentMessage(PUSER_MESSAGE_QUEUE MessageQueue) /* free the message */ ExFreePoolWithTag(Message, TAG_USRMSG); - pti->pcti->CTI_flags &= ~CTI_INSENDMESSAGE; + /* do not hangup on the user if this is reentering */ + if (!SaveMsg) pti->pcti->CTI_flags &= ~CTI_INSENDMESSAGE; pti->pusmCurrent = SaveMsg; return(TRUE); From fe0eda52aa0b5688007153501fe2975c624ce5c3 Mon Sep 17 00:00:00 2001 From: Eric Kohl Date: Sat, 4 Dec 2010 08:54:16 +0000 Subject: [PATCH 022/181] [NPFS] Read and write IRPs must fail if the caller is not a pipe but a directory or a device. svn path=/trunk/; revision=49945 --- reactos/drivers/filesystems/npfs/rw.c | 31 +++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/reactos/drivers/filesystems/npfs/rw.c b/reactos/drivers/filesystems/npfs/rw.c index 3c54bd7df47..ea3449adb70 100644 --- a/reactos/drivers/filesystems/npfs/rw.c +++ b/reactos/drivers/filesystems/npfs/rw.c @@ -307,6 +307,20 @@ NpfsRead(IN PDEVICE_OBJECT DeviceObject, DPRINT("NpfsRead(DeviceObject %p, Irp %p)\n", DeviceObject, Irp); + FileObject = IoGetCurrentIrpStackLocation(Irp)->FileObject; + DPRINT("FileObject %p\n", FileObject); + DPRINT("Pipe name %wZ\n", &FileObject->FileName); + Ccb = FileObject->FsContext2; + + /* Fail, if the CCB is not a pipe CCB */ + if (Ccb->Type != CCB_PIPE) + { + DPRINT("Not a pipe!\n"); + Status = STATUS_INVALID_PARAMETER; + Irp->IoStatus.Information = 0; + goto done; + } + if (Irp->MdlAddress == NULL) { DPRINT("Irp->MdlAddress == NULL\n"); @@ -315,10 +329,6 @@ NpfsRead(IN PDEVICE_OBJECT DeviceObject, goto done; } - FileObject = IoGetCurrentIrpStackLocation(Irp)->FileObject; - DPRINT("FileObject %p\n", FileObject); - DPRINT("Pipe name %wZ\n", &FileObject->FileName); - Ccb = FileObject->FsContext2; Context = (PNPFS_CONTEXT)&Irp->Tail.Overlay.DriverContext; if ((Ccb->OtherSide) && (Ccb->OtherSide->PipeState == FILE_PIPE_DISCONNECTED_STATE) && (Ccb->PipeState == FILE_PIPE_DISCONNECTED_STATE)) @@ -736,7 +746,7 @@ NpfsWrite(PDEVICE_OBJECT DeviceObject, NTSTATUS Status = STATUS_SUCCESS; ULONG Length; ULONG Offset; - ULONG Information; + ULONG Information = 0; ULONG CopyLength; ULONG TempLength; @@ -748,12 +758,21 @@ NpfsWrite(PDEVICE_OBJECT DeviceObject, DPRINT("Pipe name %wZ\n", &FileObject->FileName); Ccb = FileObject->FsContext2; + + /* Fail, if the CCB is not a pipe CCB */ + if (Ccb->Type != CCB_PIPE) + { + DPRINT("Not a pipe!\n"); + Status = STATUS_INVALID_PARAMETER; + Length = 0; + goto done; + } + ReaderCcb = Ccb->OtherSide; Fcb = Ccb->Fcb; Length = IoStack->Parameters.Write.Length; Offset = IoStack->Parameters.Write.ByteOffset.u.LowPart; - Information = 0; if (Irp->MdlAddress == NULL) { From 95aa3be8eb2cfa3a42814596565a46039e204c30 Mon Sep 17 00:00:00 2001 From: Eric Kohl Date: Sat, 4 Dec 2010 15:25:27 +0000 Subject: [PATCH 023/181] [NPFS] - Fail attempts to connect or disconnect a directory or device. - Fail attempts to connect or disconnect a pipe by the client. svn path=/trunk/; revision=49948 --- reactos/drivers/filesystems/npfs/fsctrl.c | 28 +++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/reactos/drivers/filesystems/npfs/fsctrl.c b/reactos/drivers/filesystems/npfs/fsctrl.c index 9055bb1f902..decae593b86 100644 --- a/reactos/drivers/filesystems/npfs/fsctrl.c +++ b/reactos/drivers/filesystems/npfs/fsctrl.c @@ -95,6 +95,20 @@ NpfsConnectPipe(PIRP Irp, DPRINT("NpfsConnectPipe()\n"); + /* Fail, if the CCB is not a pipe CCB */ + if (Ccb->Type != CCB_PIPE) + { + DPRINT1("Not a pipe\n"); + return STATUS_ILLEGAL_FUNCTION; + } + + /* Fail, if the CCB is not a server end CCB */ + if (Ccb->PipeEnd != FILE_PIPE_SERVER_END) + { + DPRINT1("Not the server end\n"); + return STATUS_ILLEGAL_FUNCTION; + } + if (Ccb->PipeState == FILE_PIPE_CONNECTED_STATE) { KeResetEvent(&Ccb->ConnectEvent); @@ -192,6 +206,20 @@ NpfsDisconnectPipe(PNPFS_CCB Ccb) DPRINT("NpfsDisconnectPipe()\n"); + /* Fail, if the CCB is not a pipe CCB */ + if (Ccb->Type != CCB_PIPE) + { + DPRINT1("Not a pipe\n"); + return STATUS_ILLEGAL_FUNCTION; + } + + /* Fail, if the CCB is not a server end CCB */ + if (Ccb->PipeEnd != FILE_PIPE_SERVER_END) + { + DPRINT1("Not the server end\n"); + return STATUS_ILLEGAL_FUNCTION; + } + Fcb = Ccb->Fcb; KeLockMutex(&Fcb->CcbListLock); From e781fb11a4e840b62cc7d690262bf2cf6c1d1f20 Mon Sep 17 00:00:00 2001 From: James Tabor Date: Sat, 4 Dec 2010 17:51:17 +0000 Subject: [PATCH 024/181] [Win32k|User32] - Remove the old send message API and use NtUserMessageCall. - Send messages do not pass the Ansi bit. This was evident during the hook changes. User32 knows the caller is Ansi and with a Unicode window user32 can make the apropate switch. Win32k on the other hand, assumes, based on the Unicode window the caller is Unicode. Hook tests enabled in send message, forces the call to win32k, and the Ansi product is Unicode data. Using NtUserMessageCall this bit can be passed forward to allow win32k to make the correct switch going to callback. svn path=/trunk/; revision=49950 --- reactos/dll/win32/user32/windows/message.c | 260 +++++++---------- reactos/include/reactos/win32k/ntuser.h | 36 +-- .../subsystems/win32/win32k/ntuser/message.c | 272 +++++++----------- .../win32/win32k/ntuser/simplecall.c | 6 + reactos/subsystems/win32/win32k/w32ksvc.db | 2 - 5 files changed, 224 insertions(+), 352 deletions(-) diff --git a/reactos/dll/win32/user32/windows/message.c b/reactos/dll/win32/user32/windows/message.c index 93bb170214c..c0b2813d8f5 100644 --- a/reactos/dll/win32/user32/windows/message.c +++ b/reactos/dll/win32/user32/windows/message.c @@ -266,14 +266,6 @@ MsgiUMToKMCleanup(PMSG UMMsg, PMSG KMMsg) return; } -static BOOL FASTCALL -MsgiUMToKMReply(PMSG UMMsg, PMSG KMMsg, LRESULT *Result) -{ - MsgiUMToKMCleanup(UMMsg, KMMsg); - - return TRUE; -} - static BOOL FASTCALL MsgiKMToUMMessage(PMSG KMMsg, PMSG UMMsg) { @@ -1074,6 +1066,7 @@ GetMessagePos(VOID) { PUSER32_THREAD_DATA ThreadData = User32GetThreadData(); return(MAKELONG(ThreadData->LastMessage.pt.x, ThreadData->LastMessage.pt.y)); + //return NtUserCallNoParam(NOPARAM_ROUTINE_GETMSESSAGEPOS); } @@ -2103,7 +2096,6 @@ SendMessageW(HWND Wnd, LPARAM lParam) { MSG UMMsg, KMMsg; - NTUSERSENDMESSAGEINFO Info; LRESULT Result; PWND Window; PTHREADINFO ti = GetW32ThreadInfo(); @@ -2137,32 +2129,21 @@ SendMessageW(HWND Wnd, UMMsg.message = Msg; UMMsg.wParam = wParam; UMMsg.lParam = lParam; + if (! MsgiUMToKMMessage(&UMMsg, &KMMsg, FALSE)) { return FALSE; } - Info.Ansi = FALSE; - Result = NtUserSendMessage( KMMsg.hwnd, - KMMsg.message, + + Result = NtUserMessageCall( KMMsg.hwnd, + KMMsg.message, KMMsg.wParam, KMMsg.lParam, - &Info); - if (! Info.HandledByKernel) - { - MsgiUMToKMCleanup(&UMMsg, &KMMsg); - /* We need to send the message ourselves */ - Result = IntCallWindowProcW( Info.Ansi, - Info.Proc, - Window, - UMMsg.hwnd, - UMMsg.message, - UMMsg.wParam, - UMMsg.lParam); - } - else if (! MsgiUMToKMReply(&UMMsg, &KMMsg, &Result)) - { - return FALSE; - } + (ULONG_PTR)&Result, + FNID_SENDMESSAGE, + FALSE); + + MsgiUMToKMCleanup(&UMMsg, &KMMsg); return Result; } @@ -2174,10 +2155,8 @@ SendMessageW(HWND Wnd, LRESULT WINAPI SendMessageA(HWND Wnd, UINT Msg, WPARAM wParam, LPARAM lParam) { - MSG AnsiMsg, UcMsg; - MSG KMMsg; + MSG AnsiMsg, UcMsg, KMMsg; LRESULT Result; - NTUSERSENDMESSAGEINFO Info; PWND Window; PTHREADINFO ti = GetW32ThreadInfo(); @@ -2210,57 +2189,28 @@ SendMessageA(HWND Wnd, UINT Msg, WPARAM wParam, LPARAM lParam) AnsiMsg.message = Msg; AnsiMsg.wParam = wParam; AnsiMsg.lParam = lParam; - if (! MsgiAnsiToUnicodeMessage(&UcMsg, &AnsiMsg)) - { - return FALSE; - } - if (! MsgiUMToKMMessage(&UcMsg, &KMMsg, FALSE)) - { + if (!MsgiAnsiToUnicodeMessage(&UcMsg, &AnsiMsg)) + { + return FALSE; + } + + if (!MsgiUMToKMMessage(&UcMsg, &KMMsg, FALSE)) + { MsgiAnsiToUnicodeCleanup(&UcMsg, &AnsiMsg); return FALSE; - } - Info.Ansi = TRUE; - Result = NtUserSendMessage( KMMsg.hwnd, - KMMsg.message, + } + + Result = NtUserMessageCall( KMMsg.hwnd, + KMMsg.message, KMMsg.wParam, KMMsg.lParam, - &Info); - if (! Info.HandledByKernel) - { - /* We need to send the message ourselves */ - if (Info.Ansi) - { - /* Ansi message and Ansi window proc, that's easy. Clean up - the Unicode message though */ - MsgiUMToKMCleanup(&UcMsg, &KMMsg); - MsgiAnsiToUnicodeCleanup(&UcMsg, &AnsiMsg); - Result = IntCallWindowProcA(Info.Ansi, Info.Proc, Window, Wnd, Msg, wParam, lParam); - } - else - { - /* Unicode winproc. Although we started out with an Ansi message we - already converted it to Unicode for the kernel call. Reuse that - message to avoid another conversion */ - Result = IntCallWindowProcW( Info.Ansi, - Info.Proc, - Window, - UcMsg.hwnd, - UcMsg.message, - UcMsg.wParam, - UcMsg.lParam); - if (! MsgiAnsiToUnicodeReply(&UcMsg, &AnsiMsg, &Result)) - { - return FALSE; - } - } - } - /* Message sent by kernel. Convert back to Ansi */ - else if (! MsgiUMToKMReply(&UcMsg, &KMMsg, &Result) || - ! MsgiAnsiToUnicodeReply(&UcMsg, &AnsiMsg, &Result)) - { - return FALSE; - } + (ULONG_PTR)&Result, + FNID_SENDMESSAGE, + TRUE); + + MsgiUMToKMCleanup(&UcMsg, &KMMsg); + MsgiAnsiToUnicodeReply(&UcMsg, &AnsiMsg, &Result); return Result; } @@ -2278,18 +2228,34 @@ SendMessageCallbackA( SENDASYNCPROC lpCallBack, ULONG_PTR dwData) { + BOOL Result; + MSG AnsiMsg, UcMsg; CALL_BACK_INFO CallBackInfo; CallBackInfo.CallBack = lpCallBack; CallBackInfo.Context = dwData; - return NtUserMessageCall(hWnd, - Msg, - wParam, - lParam, - (ULONG_PTR)&CallBackInfo, - FNID_SENDMESSAGECALLBACK, - TRUE); + AnsiMsg.hwnd = hWnd; + AnsiMsg.message = Msg; + AnsiMsg.wParam = wParam; + AnsiMsg.lParam = lParam; + + if (!MsgiAnsiToUnicodeMessage(&UcMsg, &AnsiMsg)) + { + return FALSE; + } + + Result = NtUserMessageCall( UcMsg.hwnd, + UcMsg.message, + UcMsg.wParam, + UcMsg.lParam, + (ULONG_PTR)&CallBackInfo, + FNID_SENDMESSAGECALLBACK, + TRUE); + + MsgiAnsiToUnicodeCleanup(&UcMsg, &AnsiMsg); + + return Result; } /* @@ -2305,7 +2271,6 @@ SendMessageCallbackW( SENDASYNCPROC lpCallBack, ULONG_PTR dwData) { - CALL_BACK_INFO CallBackInfo; CallBackInfo.CallBack = lpCallBack; @@ -2334,76 +2299,47 @@ SendMessageTimeoutA( UINT uTimeout, PDWORD_PTR lpdwResult) { - MSG AnsiMsg; - MSG UcMsg; + MSG AnsiMsg, UcMsg; LRESULT Result; - NTUSERSENDMESSAGEINFO Info; + DOSENDMESSAGE dsm; + + SPY_EnterMessage(SPY_SENDMESSAGE, hWnd, Msg, wParam, lParam); + + if ( Msg & ~WM_MAXIMUM || fuFlags & ~(SMTO_NOTIMEOUTIFNOTHUNG|SMTO_ABORTIFHUNG|SMTO_BLOCK)) + { + SetLastError( ERROR_INVALID_PARAMETER ); + return 0; + } + + if (lpdwResult) *lpdwResult = 0; + + dsm.uFlags = fuFlags; + dsm.uTimeout = uTimeout; AnsiMsg.hwnd = hWnd; AnsiMsg.message = Msg; AnsiMsg.wParam = wParam; AnsiMsg.lParam = lParam; + if (! MsgiAnsiToUnicodeMessage(&UcMsg, &AnsiMsg)) - { - return FALSE; - } - - SPY_EnterMessage(SPY_SENDMESSAGE, hWnd, Msg, wParam, lParam); - - Info.Ansi = TRUE; - Result = NtUserSendMessageTimeout(UcMsg.hwnd, UcMsg.message, - UcMsg.wParam, UcMsg.lParam, - fuFlags, uTimeout, (ULONG_PTR*)lpdwResult, &Info); - if(!Result) { - SPY_ExitMessage(SPY_RESULT_OK, hWnd, Msg, Result, wParam, lParam); return FALSE; } - if (! Info.HandledByKernel) - { - PWND pWnd; - pWnd = ValidateHwnd(hWnd); - /* We need to send the message ourselves */ - if (Info.Ansi) - { - /* Ansi message and Ansi window proc, that's easy. Clean up - the Unicode message though */ - MsgiAnsiToUnicodeCleanup(&UcMsg, &AnsiMsg); - Result = IntCallWindowProcA(Info.Ansi, Info.Proc, pWnd, hWnd, Msg, wParam, lParam); - } - else - { - /* Unicode winproc. Although we started out with an Ansi message we - already converted it to Unicode for the kernel call. Reuse that - message to avoid another conversion */ - Result = IntCallWindowProcW( Info.Ansi, - Info.Proc, - pWnd, - UcMsg.hwnd, - UcMsg.message, - UcMsg.wParam, - UcMsg.lParam); - if (! MsgiAnsiToUnicodeReply(&UcMsg, &AnsiMsg, &Result)) - { - SPY_ExitMessage(SPY_RESULT_OK, hWnd, Msg, Result, wParam, lParam); - return FALSE; - } - } - if(lpdwResult) - *lpdwResult = Result; - Result = TRUE; - } - else - { - /* Message sent by kernel. Convert back to Ansi */ - if (! MsgiAnsiToUnicodeReply(&UcMsg, &AnsiMsg, &Result)) - { - SPY_ExitMessage(SPY_RESULT_OK, hWnd, Msg, Result, wParam, lParam); - return FALSE; - } - } + + Result = NtUserMessageCall( UcMsg.hwnd, + UcMsg.message, + UcMsg.wParam, + UcMsg.lParam, + (ULONG_PTR)&dsm, + FNID_SENDMESSAGETIMEOUT, + TRUE); + + MsgiAnsiToUnicodeReply(&UcMsg, &AnsiMsg, &Result); + + if (lpdwResult) *lpdwResult = dsm.Result; SPY_ExitMessage(SPY_RESULT_OK, hWnd, Msg, Result, wParam, lParam); + return Result; } @@ -2422,28 +2358,34 @@ SendMessageTimeoutW( UINT uTimeout, PDWORD_PTR lpdwResult) { - NTUSERSENDMESSAGEINFO Info; LRESULT Result; + DOSENDMESSAGE dsm; SPY_EnterMessage(SPY_SENDMESSAGE, hWnd, Msg, wParam, lParam); - Info.Ansi = FALSE; - Result = NtUserSendMessageTimeout(hWnd, Msg, wParam, lParam, fuFlags, uTimeout, - lpdwResult, &Info); - if (! Info.HandledByKernel) - { - PWND pWnd; - pWnd = ValidateHwnd(hWnd); - /* We need to send the message ourselves */ - Result = IntCallWindowProcW(Info.Ansi, Info.Proc, pWnd, hWnd, Msg, wParam, lParam); - if(lpdwResult) - *lpdwResult = Result; + if ( Msg & ~WM_MAXIMUM || fuFlags & ~(SMTO_NOTIMEOUTIFNOTHUNG|SMTO_ABORTIFHUNG|SMTO_BLOCK)) + { + SetLastError( ERROR_INVALID_PARAMETER ); + return 0; + } + + if (lpdwResult) *lpdwResult = 0; - SPY_ExitMessage(SPY_RESULT_OK, hWnd, Msg, Result, wParam, lParam); - return TRUE; - } + dsm.uFlags = fuFlags; + dsm.uTimeout = uTimeout; + + Result = NtUserMessageCall( hWnd, + Msg, + wParam, + lParam, + (ULONG_PTR)&dsm, + FNID_SENDMESSAGETIMEOUT, + FALSE); + + if (lpdwResult) *lpdwResult = dsm.Result; SPY_ExitMessage(SPY_RESULT_OK, hWnd, Msg, Result, wParam, lParam); + return Result; } diff --git a/reactos/include/reactos/win32k/ntuser.h b/reactos/include/reactos/win32k/ntuser.h index e6745d9f7fc..936b4f87f58 100644 --- a/reactos/include/reactos/win32k/ntuser.h +++ b/reactos/include/reactos/win32k/ntuser.h @@ -2255,6 +2255,15 @@ NtUserMapVirtualKeyEx( UINT keyCode, UINT transType, DWORD keyboardId, HKL dwhkl ); + +typedef struct tagDOSENDMESSAGE +{ + UINT uFlags; + UINT uTimeout; + ULONG_PTR Result; +} +DOSENDMESSAGE, *PDOSENDMESSAGE; + BOOL NTAPI NtUserMessageCall( @@ -3302,33 +3311,6 @@ NtUserMonitorFromWindow( IN HWND hWnd, IN DWORD dwFlags); - -typedef struct tagNTUSERSENDMESSAGEINFO -{ - BOOL HandledByKernel; - BOOL Ansi; - WNDPROC Proc; -} NTUSERSENDMESSAGEINFO, *PNTUSERSENDMESSAGEINFO; - -/* use NtUserMessageCall */ -LRESULT NTAPI -NtUserSendMessage(HWND hWnd, - UINT Msg, - WPARAM wParam, - LPARAM lParam, - PNTUSERSENDMESSAGEINFO Info); - -/* use NtUserMessageCall */ -LRESULT NTAPI -NtUserSendMessageTimeout(HWND hWnd, - UINT Msg, - WPARAM wParam, - LPARAM lParam, - UINT uFlags, - UINT uTimeout, - ULONG_PTR *uResult, - PNTUSERSENDMESSAGEINFO Info); - typedef struct _SETSCROLLBARINFO { int nTrackPos; diff --git a/reactos/subsystems/win32/win32k/ntuser/message.c b/reactos/subsystems/win32/win32k/ntuser/message.c index 7c339b8dee7..426c0b3ddaf 100644 --- a/reactos/subsystems/win32/win32k/ntuser/message.c +++ b/reactos/subsystems/win32/win32k/ntuser/message.c @@ -19,14 +19,6 @@ BOOLEAN NTAPI PsGetProcessExitProcessCalled(PEPROCESS Process); #define PM_BADMSGFLAGS ~((QS_RAWINPUT << 16)|PM_QS_SENDMESSAGE|PM_QS_PAINT|PM_QS_POSTMESSAGE|PM_QS_INPUT|PM_NOYIELD|PM_REMOVE) -typedef struct -{ - UINT uFlags; - UINT uTimeout; - ULONG_PTR Result; -} -DOSENDMESSAGE, *PDOSENDMESSAGE; - /* FUNCTIONS *****************************************************************/ NTSTATUS FASTCALL @@ -864,6 +856,8 @@ co_IntGetPeekMessage( PMSG pMsg, RemoveMsg |= ((GetWakeMask( MsgFilterMin, MsgFilterMax ))<< 16); } + pti = PsGetCurrentThreadWin32Thread(); + do { Present = co_IntPeekMessage( pMsg, @@ -874,6 +868,9 @@ co_IntGetPeekMessage( PMSG pMsg, bGMSG ); if (Present) { + pti->timeLast = pMsg->time; + pti->ptLast = pMsg->pt; + // The WH_GETMESSAGE hook enables an application to monitor messages about to // be returned by the GetMessage or PeekMessage function. @@ -911,7 +908,6 @@ co_IntGetPeekMessage( PMSG pMsg, } while( bGMSG && !Present ); - pti = PsGetCurrentThreadWin32Thread(); // Been spinning, time to swap vinyl... if (pti->pClientInfo->cSpins >= 100) { @@ -962,7 +958,7 @@ UserPostThreadMessage( DWORD idThread, Message.pt = gpsi->ptCursor; KeQueryTickCount(&LargeTickCount); - pThread->timeLast = Message.time = MsqCalculateMessageTime(&LargeTickCount); + Message.time = MsqCalculateMessageTime(&LargeTickCount); MsqPostMessage(pThread->MessageQueue, &Message, FALSE, QS_POSTMESSAGE); ObDereferenceObject( peThread ); return TRUE; @@ -1052,7 +1048,7 @@ UserPostMessage( HWND Wnd, Message.lParam = lParam; Message.pt = gpsi->ptCursor; KeQueryTickCount(&LargeTickCount); - pti->timeLast = Message.time = MsqCalculateMessageTime(&LargeTickCount); + Message.time = MsqCalculateMessageTime(&LargeTickCount); MsqPostMessage(Window->head.pti->MessageQueue, &Message, FALSE, QS_POSTMESSAGE); } } @@ -1451,29 +1447,21 @@ co_IntDoSendMessage( HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam, - PDOSENDMESSAGE dsm, - PNTUSERSENDMESSAGEINFO UnsafeInfo ) + PDOSENDMESSAGE dsm) { PTHREADINFO pti; LRESULT Result = TRUE; NTSTATUS Status; PWND Window = NULL; - NTUSERSENDMESSAGEINFO Info; MSG UserModeMsg; MSG KernelModeMsg; PMSGMEMORY MsgMemoryEntry; - RtlZeroMemory(&Info, sizeof(NTUSERSENDMESSAGEINFO)); - - /* FIXME: Call hooks. */ if (HWND_BROADCAST != hWnd) { Window = UserGetWindowObject(hWnd); if ( !Window ) { - /* Tell usermode to not touch this one */ - Info.HandledByKernel = TRUE; - MmCopyToCaller(UnsafeInfo, &Info, sizeof(NTUSERSENDMESSAGEINFO)); return 0; } } @@ -1487,85 +1475,47 @@ co_IntDoSendMessage( HWND hWnd, /* See if the current thread can handle the message */ pti = PsGetCurrentThreadWin32Thread(); - // This is checked in user mode!!!!!!! - if ( HWND_BROADCAST != hWnd && - NULL != pti && - Window->head.pti->MessageQueue == pti->MessageQueue && - !ISITHOOKED(WH_CALLWNDPROC) && - !ISITHOOKED(WH_CALLWNDPROCRET) && - ( Msg < WM_DDE_FIRST || Msg > WM_DDE_LAST ) ) + UserModeMsg.hwnd = hWnd; + UserModeMsg.message = Msg; + UserModeMsg.wParam = wParam; + UserModeMsg.lParam = lParam; + MsgMemoryEntry = FindMsgMemory(UserModeMsg.message); + + Status = CopyMsgToKernelMem(&KernelModeMsg, &UserModeMsg, MsgMemoryEntry); + if (! NT_SUCCESS(Status)) { - /* Gather the information usermode needs to call the window proc directly */ - Info.HandledByKernel = FALSE; + SetLastWin32Error(ERROR_INVALID_PARAMETER); + return (dsm ? 0 : -1); + } - Status = MmCopyFromCaller(&(Info.Ansi), &(UnsafeInfo->Ansi), sizeof(BOOL)); - if (! NT_SUCCESS(Status)) - { - Info.Ansi = ! Window->Unicode; - } - - Info.Ansi = !Window->Unicode; - Info.Proc = Window->lpfnWndProc; + if (!dsm) + { + Result = co_IntSendMessage( KernelModeMsg.hwnd, + KernelModeMsg.message, + KernelModeMsg.wParam, + KernelModeMsg.lParam ); } else { - /* Must be handled by other thread */ - // if (HWND_BROADCAST != hWnd) - // { - // UserDereferenceObject(Window); - // } - Info.HandledByKernel = TRUE; - UserModeMsg.hwnd = hWnd; - UserModeMsg.message = Msg; - UserModeMsg.wParam = wParam; - UserModeMsg.lParam = lParam; - MsgMemoryEntry = FindMsgMemory(UserModeMsg.message); - - Status = CopyMsgToKernelMem(&KernelModeMsg, &UserModeMsg, MsgMemoryEntry); - if (! NT_SUCCESS(Status)) - { - MmCopyToCaller(UnsafeInfo, &Info, sizeof(NTUSERSENDMESSAGEINFO)); - SetLastWin32Error(ERROR_INVALID_PARAMETER); - return (dsm ? 0 : -1); - } - - if(!dsm) - { - Result = co_IntSendMessage( KernelModeMsg.hwnd, - KernelModeMsg.message, - KernelModeMsg.wParam, - KernelModeMsg.lParam ); - } - else - { - Result = co_IntSendMessageTimeout( KernelModeMsg.hwnd, - KernelModeMsg.message, - KernelModeMsg.wParam, - KernelModeMsg.lParam, - dsm->uFlags, - dsm->uTimeout, - &dsm->Result ); - } - - Status = CopyMsgToUserMem(&UserModeMsg, &KernelModeMsg); - if (! NT_SUCCESS(Status)) - { - MmCopyToCaller(UnsafeInfo, &Info, sizeof(NTUSERSENDMESSAGEINFO)); - SetLastWin32Error(ERROR_INVALID_PARAMETER); - return(dsm ? 0 : -1); - } + Result = co_IntSendMessageTimeout( KernelModeMsg.hwnd, + KernelModeMsg.message, + KernelModeMsg.wParam, + KernelModeMsg.lParam, + dsm->uFlags, + dsm->uTimeout, + &dsm->Result ); } - Status = MmCopyToCaller(UnsafeInfo, &Info, sizeof(NTUSERSENDMESSAGEINFO)); + Status = CopyMsgToUserMem(&UserModeMsg, &KernelModeMsg); if (! NT_SUCCESS(Status)) { - SetLastWin32Error(ERROR_INVALID_PARAMETER); + SetLastWin32Error(ERROR_INVALID_PARAMETER); + return(dsm ? 0 : -1); } return (LRESULT)Result; } - BOOL FASTCALL UserSendNotifyMessage( HWND hWnd, UINT Msg, @@ -1709,68 +1659,6 @@ NtUserPostThreadMessage(DWORD idThread, return ret; } -////////// API on the way out! -LRESULT APIENTRY -NtUserSendMessageTimeout( HWND hWnd, - UINT Msg, - WPARAM wParam, - LPARAM lParam, - UINT uFlags, - UINT uTimeout, - ULONG_PTR *uResult, - PNTUSERSENDMESSAGEINFO UnsafeInfo ) -{ - DOSENDMESSAGE dsm; - LRESULT Result; - - DPRINT("Enter NtUserSendMessageTimeout\n"); - - dsm.uFlags = uFlags; - dsm.uTimeout = uTimeout; - - UserEnterExclusive(); - - Result = co_IntDoSendMessage(hWnd, Msg, wParam, lParam, &dsm, UnsafeInfo); - - UserLeave(); - - if(uResult != NULL && Result != 0) - { - _SEH2_TRY - { - ProbeForWrite(uResult, sizeof(ULONG_PTR), 1); - RtlCopyMemory(uResult, &dsm.Result, sizeof(ULONG_PTR)); - } - _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) - { - SetLastWin32Error(ERROR_INVALID_PARAMETER);; - Result = FALSE; - } - _SEH2_END; - } - - return Result; -} - -LRESULT APIENTRY -NtUserSendMessage( HWND Wnd, - UINT Msg, - WPARAM wParam, - LPARAM lParam, - PNTUSERSENDMESSAGEINFO UnsafeInfo ) -{ - BOOL ret; - - UserEnterExclusive(); - - ret = co_IntDoSendMessage(Wnd, Msg, wParam, lParam, NULL, UnsafeInfo); - - UserLeave(); - - return ret; -} -////////// - BOOL APIENTRY NtUserWaitMessage(VOID) { @@ -2220,32 +2108,32 @@ NtUserMessageCall( HWND hWnd, if (parm.flags & BSF_FORCEIFHUNG || parm.flags & BSF_NOHANG) { co_IntSendMessageTimeout( HWND_BROADCAST, - Msg, - wParam, - lParam, - SMTO_ABORTIFHUNG, - 2000, - &RetVal); + Msg, + wParam, + lParam, + SMTO_ABORTIFHUNG, + 2000, + &RetVal); } else if (parm.flags & BSF_NOTIMEOUTIFNOTHUNG) { co_IntSendMessageTimeout( HWND_BROADCAST, - Msg, + Msg, wParam, - lParam, - SMTO_NOTIMEOUTIFNOTHUNG, - 2000, - &RetVal); + lParam, + SMTO_NOTIMEOUTIFNOTHUNG, + 2000, + &RetVal); } else { co_IntSendMessageTimeout( HWND_BROADCAST, - Msg, - wParam, - lParam, - SMTO_NORMAL, - 2000, - &RetVal); + Msg, + wParam, + lParam, + SMTO_NORMAL, + 2000, + &RetVal); } Ret = RetVal; } @@ -2275,6 +2163,62 @@ NtUserMessageCall( HWND hWnd, } } break; + case FNID_SENDMESSAGE: + { + Ret = co_IntDoSendMessage(hWnd, Msg, wParam, lParam, 0); + + if (ResultInfo) + { + _SEH2_TRY + { + ProbeForWrite((PVOID)ResultInfo, sizeof(ULONG_PTR), 1); + RtlCopyMemory((PVOID)ResultInfo, &Ret, sizeof(ULONG_PTR)); + } + _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) + { + Ret = FALSE; + _SEH2_YIELD(break); + } + _SEH2_END; + } + break; + } + case FNID_SENDMESSAGETIMEOUT: + { + DOSENDMESSAGE dsm, *pdsm = (PDOSENDMESSAGE)ResultInfo; + if (ResultInfo) + { + _SEH2_TRY + { + ProbeForRead(pdsm, sizeof(DOSENDMESSAGE), 1); + RtlCopyMemory(&dsm, pdsm, sizeof(DOSENDMESSAGE)); + } + _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) + { + Ret = FALSE; + _SEH2_YIELD(break); + } + _SEH2_END; + } + + Ret = co_IntDoSendMessage( hWnd, Msg, wParam, lParam, &dsm ); + + if (pdsm) + { + _SEH2_TRY + { + ProbeForWrite(pdsm, sizeof(DOSENDMESSAGE), 1); + RtlCopyMemory(pdsm, &dsm, sizeof(DOSENDMESSAGE)); + } + _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) + { + Ret = FALSE; + _SEH2_YIELD(break); + } + _SEH2_END; + } + break; + } // CallNextHook bypass. case FNID_CALLWNDPROC: case FNID_CALLWNDPROCRET: diff --git a/reactos/subsystems/win32/win32k/ntuser/simplecall.c b/reactos/subsystems/win32/win32k/ntuser/simplecall.c index df2f1e4b00a..d1c5e0bec90 100644 --- a/reactos/subsystems/win32/win32k/ntuser/simplecall.c +++ b/reactos/subsystems/win32/win32k/ntuser/simplecall.c @@ -113,6 +113,12 @@ NtUserCallNoParam(DWORD Routine) case NOPARAM_ROUTINE_MSQCLEARWAKEMASK: RETURN( (DWORD_PTR)IntMsqClearWakeMask()); + case NOPARAM_ROUTINE_GETMSESSAGEPOS: + { + PTHREADINFO pti = PsGetCurrentThreadWin32Thread(); + RETURN( (DWORD_PTR)MAKELONG(pti->ptLast.x, pti->ptLast.y)); + } + default: DPRINT1("Calling invalid routine number 0x%x in NtUserCallNoParam\n", Routine); SetLastWin32Error(ERROR_INVALID_PARAMETER); diff --git a/reactos/subsystems/win32/win32k/w32ksvc.db b/reactos/subsystems/win32/win32k/w32ksvc.db index 00701aa1f28..0ff90f786d8 100644 --- a/reactos/subsystems/win32/win32k/w32ksvc.db +++ b/reactos/subsystems/win32/win32k/w32ksvc.db @@ -692,6 +692,4 @@ NtUserMenuItemInfo 5 NtUserMonitorFromPoint 3 NtUserMonitorFromRect 2 NtUserMonitorFromWindow 2 -NtUserSendMessage 5 -NtUserSendMessageTimeout 8 NtUserSetScrollBarInfo 3 From ca9bd801825fa527d74b38ca1a419d867323e0d4 Mon Sep 17 00:00:00 2001 From: Aleksey Bragin Date: Sun, 5 Dec 2010 10:27:45 +0000 Subject: [PATCH 025/181] [TASKMGR] - Rafal Harabien: Add support for DELETE key to processes and applications list in taskmgr. See issue #5646 for more details. svn path=/trunk/; revision=49954 --- reactos/base/applications/taskmgr/applpage.c | 13 +++++++++++++ reactos/base/applications/taskmgr/procpage.c | 11 +++++++++++ 2 files changed, 24 insertions(+) diff --git a/reactos/base/applications/taskmgr/applpage.c b/reactos/base/applications/taskmgr/applpage.c index 88c52070fa9..673cdad0a83 100644 --- a/reactos/base/applications/taskmgr/applpage.c +++ b/reactos/base/applications/taskmgr/applpage.c @@ -210,6 +210,11 @@ ApplicationPageWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) ApplicationPageOnNotify(wParam, lParam); break; + case WM_KEYDOWN: + if (wParam == VK_DELETE) + ProcessPage_OnEndProcess(); + break; + } return 0; @@ -584,6 +589,14 @@ void ApplicationPageOnNotify(WPARAM wParam, LPARAM lParam) ApplicationPage_OnSwitchTo(); break; + + case LVN_KEYDOWN: + + if (((LPNMLVKEYDOWN)lParam)->wVKey == VK_DELETE) + ApplicationPage_OnEndTask(); + + break; + } } else if (pnmh->hwndFrom == ListView_GetHeader(hApplicationPageListCtrl)) diff --git a/reactos/base/applications/taskmgr/procpage.c b/reactos/base/applications/taskmgr/procpage.c index acaa159bd04..6b7ae3519fe 100644 --- a/reactos/base/applications/taskmgr/procpage.c +++ b/reactos/base/applications/taskmgr/procpage.c @@ -201,6 +201,11 @@ ProcessPageWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) case WM_NOTIFY: ProcessPageOnNotify(wParam, lParam); break; + + case WM_KEYDOWN: + if (wParam == VK_DELETE) + ProcessPage_OnEndProcess(); + break; } return 0; @@ -251,6 +256,12 @@ void ProcessPageOnNotify(WPARAM wParam, LPARAM lParam) ProcessPageShowContextMenu(GetSelectedProcessId()); break; + case LVN_KEYDOWN: + + if (((LPNMLVKEYDOWN)lParam)->wVKey == VK_DELETE) + ProcessPage_OnEndProcess(); + break; + } } else if (pnmh->hwndFrom == hProcessPageHeaderCtrl) From 5f879a12458c24e73be30bacc26d141876424ee5 Mon Sep 17 00:00:00 2001 From: Giannis Adamopoulos Date: Sun, 5 Dec 2010 23:10:03 +0000 Subject: [PATCH 026/181] [win32k] -Amend to r41772. Allow PostMessage to handle DDE messages svn path=/trunk/; revision=49957 --- .../subsystems/win32/win32k/ntuser/message.c | 45 ++++++++++++++----- 1 file changed, 35 insertions(+), 10 deletions(-) diff --git a/reactos/subsystems/win32/win32k/ntuser/message.c b/reactos/subsystems/win32/win32k/ntuser/message.c index 426c0b3ddaf..fb798ed85ce 100644 --- a/reactos/subsystems/win32/win32k/ntuser/message.c +++ b/reactos/subsystems/win32/win32k/ntuser/message.c @@ -977,10 +977,42 @@ UserPostMessage( HWND Wnd, LPARAM lParam ) { PTHREADINFO pti; - MSG Message; + MSG Message, KernelModeMsg; LARGE_INTEGER LargeTickCount; + PMSGMEMORY MsgMemoryEntry; - if (FindMsgMemory(Msg) != 0) + Message.hwnd = Wnd; + Message.message = Msg; + Message.wParam = wParam; + Message.lParam = lParam; + Message.pt = gpsi->ptCursor; + KeQueryTickCount(&LargeTickCount); + Message.time = MsqCalculateMessageTime(&LargeTickCount); + + MsgMemoryEntry = FindMsgMemory(Message.message); + + if( Msg >= WM_DDE_FIRST && Msg <= WM_DDE_LAST ) + { + NTSTATUS Status; + + Status = CopyMsgToKernelMem(&KernelModeMsg, &Message, MsgMemoryEntry); + if (! NT_SUCCESS(Status)) + { + SetLastWin32Error(ERROR_INVALID_PARAMETER); + return FALSE; + } + co_IntSendMessageNoWait(KernelModeMsg.hwnd, + KernelModeMsg.message, + KernelModeMsg.wParam, + KernelModeMsg.lParam); + + if(MsgMemoryEntry) + ExFreePool((PVOID) KernelModeMsg.lParam); + + return TRUE; + } + + if (MsgMemoryEntry) { SetLastWin32Error(ERROR_MESSAGE_SYNC_ONLY ); return FALSE; @@ -1035,20 +1067,13 @@ UserPostMessage( HWND Wnd, /* FIXME - last error code? */ return FALSE; } - + if (WM_QUIT == Msg) { MsqPostQuitMessage(Window->head.pti->MessageQueue, wParam); } else { - Message.hwnd = Wnd; - Message.message = Msg; - Message.wParam = wParam; - Message.lParam = lParam; - Message.pt = gpsi->ptCursor; - KeQueryTickCount(&LargeTickCount); - Message.time = MsqCalculateMessageTime(&LargeTickCount); MsqPostMessage(Window->head.pti->MessageQueue, &Message, FALSE, QS_POSTMESSAGE); } } From 3e169e3cb2d9db197b61ddd9f7955e9038817cb3 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Mon, 6 Dec 2010 04:39:57 +0000 Subject: [PATCH 027/181] [NDIS] - Add a missing spin lock release in a failure case - Fix incomplete copying of NDIS 5.1 miniport characteristics svn path=/trunk/; revision=49961 --- reactos/drivers/network/ndis/ndis/miniport.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/reactos/drivers/network/ndis/ndis/miniport.c b/reactos/drivers/network/ndis/ndis/miniport.c index bfe41237f4d..8b551db8a13 100644 --- a/reactos/drivers/network/ndis/ndis/miniport.c +++ b/reactos/drivers/network/ndis/ndis/miniport.c @@ -316,6 +316,7 @@ MiniIndicateReceivePacket( if (!LookAheadBuffer) { NDIS_DbgPrint(MIN_TRACE, ("Failed to allocate lookahead buffer!\n")); + KeReleaseSpinLock(&Adapter->NdisMiniportBlock.Lock, OldIrql); return; } @@ -2454,7 +2455,20 @@ NdisMRegisterMiniport( break; case 0x05: - MinSize = sizeof(NDIS50_MINIPORT_CHARACTERISTICS); + switch (MiniportCharacteristics->MinorNdisVersion) + { + case 0x00: + MinSize = sizeof(NDIS50_MINIPORT_CHARACTERISTICS); + break; + + case 0x01: + MinSize = sizeof(NDIS51_MINIPORT_CHARACTERISTICS); + break; + + default: + NDIS_DbgPrint(MIN_TRACE, ("Bad 5.x minor characteristics version.\n")); + return NDIS_STATUS_BAD_VERSION; + } break; default: @@ -2532,8 +2546,6 @@ NdisMRegisterMiniport( } } - /* TODO: verify NDIS5 and NDIS5.1 */ - RtlCopyMemory(&Miniport->MiniportCharacteristics, MiniportCharacteristics, MinSize); /* From a38b059ca1b556a0082cbe97315a14ddf6991910 Mon Sep 17 00:00:00 2001 From: Giannis Adamopoulos Date: Mon, 6 Dec 2010 12:07:05 +0000 Subject: [PATCH 028/181] [win32k] - In FNID_SENDMESSAGECALLBACK use SEH before accesing the user-mode buffer svn path=/trunk/; revision=49962 --- .../subsystems/win32/win32k/ntuser/message.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/reactos/subsystems/win32/win32k/ntuser/message.c b/reactos/subsystems/win32/win32k/ntuser/message.c index fb798ed85ce..ad8be3d5194 100644 --- a/reactos/subsystems/win32/win32k/ntuser/message.c +++ b/reactos/subsystems/win32/win32k/ntuser/message.c @@ -2175,14 +2175,23 @@ NtUserMessageCall( HWND hWnd, break; case FNID_SENDMESSAGECALLBACK: { - PCALL_BACK_INFO CallBackInfo = (PCALL_BACK_INFO)ResultInfo; + CALL_BACK_INFO CallBackInfo; ULONG_PTR uResult; - - if (!CallBackInfo) - break; + + _SEH2_TRY + { + ProbeForRead((PVOID)ResultInfo, sizeof(CALL_BACK_INFO), 1); + RtlCopyMemory(&CallBackInfo, (PVOID)ResultInfo, sizeof(CALL_BACK_INFO)); + } + _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) + { + Ret = FALSE; + _SEH2_YIELD(break); + } + _SEH2_END; if (!co_IntSendMessageWithCallBack(hWnd, Msg, wParam, lParam, - CallBackInfo->CallBack, CallBackInfo->Context, &uResult)) + CallBackInfo.CallBack, CallBackInfo.Context, &uResult)) { DPRINT1("Callback failure!\n"); } From 2923228336fe9e2dd2e6e16de9f5580251f0eddb Mon Sep 17 00:00:00 2001 From: Amine Khaldi Date: Tue, 7 Dec 2010 09:27:10 +0000 Subject: [PATCH 029/181] [CMAKE] - Start working on rostests cmake integration. svn path=/trunk/; revision=49966 --- rostests/CMakeLists.txt | 9 +++ rostests/winetests/CMakeLists.txt | 88 ++++++++++++++++++++++ rostests/winetests/advapi32/CMakeLists.txt | 25 ++++++ rostests/winetests/advpack/CMakeLists.txt | 17 +++++ rostests/winetests/amstream/CMakeLists.txt | 6 ++ rostests/winetests/atl/CMakeLists.txt | 14 ++++ rostests/winetests/avifil32/CMakeLists.txt | 6 ++ rostests/winetests/browseui/CMakeLists.txt | 9 +++ rostests/winetests/cabinet/CMakeLists.txt | 9 +++ rostests/winetests/comcat/CMakeLists.txt | 9 +++ rostests/winetests/comctl32/CMakeLists.txt | 40 ++++++++++ rostests/winetests/comdlg32/CMakeLists.txt | 16 ++++ rostests/winetests/credui/CMakeLists.txt | 9 +++ rostests/winetests/crypt32/CMakeLists.txt | 27 +++++++ rostests/winetests/cryptnet/CMakeLists.txt | 9 +++ rostests/winetests/cryptui/CMakeLists.txt | 9 +++ rostests/winetests/dnsapi/CMakeLists.txt | 9 +++ rostests/winetests/dsound/CMakeLists.txt | 19 +++++ rostests/winetests/fusion/CMakeLists.txt | 16 ++++ rostests/winetests/gdi32/CMakeLists.txt | 24 ++++++ rostests/winetests/gdiplus/CMakeLists.txt | 23 ++++++ rostests/winetests/hlink/CMakeLists.txt | 14 ++++ rostests/winetests/icmp/CMakeLists.txt | 9 +++ rostests/winetests/imm32/CMakeLists.txt | 9 +++ rostests/winetests/inetcomm/CMakeLists.txt | 14 ++++ rostests/winetests/inetmib1/CMakeLists.txt | 9 +++ rostests/winetests/iphlpapi/CMakeLists.txt | 9 +++ rostests/winetests/itss/CMakeLists.txt | 9 +++ rostests/winetests/jscript/CMakeLists.txt | 16 ++++ rostests/winetests/kernel32/CMakeLists.txt | 47 ++++++++++++ rostests/winetests/localspl/CMakeLists.txt | 10 +++ rostests/winetests/localui/CMakeLists.txt | 10 +++ rostests/winetests/lz32/CMakeLists.txt | 9 +++ rostests/winetests/mapi32/CMakeLists.txt | 15 ++++ rostests/winetests/mlang/CMakeLists.txt | 9 +++ rostests/winetests/msacm32/CMakeLists.txt | 9 +++ rostests/winetests/mscms/CMakeLists.txt | 9 +++ rostests/winetests/msctf/CMakeLists.txt | 9 +++ 38 files changed, 609 insertions(+) create mode 100644 rostests/CMakeLists.txt create mode 100644 rostests/winetests/CMakeLists.txt create mode 100644 rostests/winetests/advapi32/CMakeLists.txt create mode 100644 rostests/winetests/advpack/CMakeLists.txt create mode 100644 rostests/winetests/amstream/CMakeLists.txt create mode 100644 rostests/winetests/atl/CMakeLists.txt create mode 100644 rostests/winetests/avifil32/CMakeLists.txt create mode 100644 rostests/winetests/browseui/CMakeLists.txt create mode 100644 rostests/winetests/cabinet/CMakeLists.txt create mode 100644 rostests/winetests/comcat/CMakeLists.txt create mode 100644 rostests/winetests/comctl32/CMakeLists.txt create mode 100644 rostests/winetests/comdlg32/CMakeLists.txt create mode 100644 rostests/winetests/credui/CMakeLists.txt create mode 100644 rostests/winetests/crypt32/CMakeLists.txt create mode 100644 rostests/winetests/cryptnet/CMakeLists.txt create mode 100644 rostests/winetests/cryptui/CMakeLists.txt create mode 100644 rostests/winetests/dnsapi/CMakeLists.txt create mode 100644 rostests/winetests/dsound/CMakeLists.txt create mode 100644 rostests/winetests/fusion/CMakeLists.txt create mode 100644 rostests/winetests/gdi32/CMakeLists.txt create mode 100644 rostests/winetests/gdiplus/CMakeLists.txt create mode 100644 rostests/winetests/hlink/CMakeLists.txt create mode 100644 rostests/winetests/icmp/CMakeLists.txt create mode 100644 rostests/winetests/imm32/CMakeLists.txt create mode 100644 rostests/winetests/inetcomm/CMakeLists.txt create mode 100644 rostests/winetests/inetmib1/CMakeLists.txt create mode 100644 rostests/winetests/iphlpapi/CMakeLists.txt create mode 100644 rostests/winetests/itss/CMakeLists.txt create mode 100644 rostests/winetests/jscript/CMakeLists.txt create mode 100644 rostests/winetests/kernel32/CMakeLists.txt create mode 100644 rostests/winetests/localspl/CMakeLists.txt create mode 100644 rostests/winetests/localui/CMakeLists.txt create mode 100644 rostests/winetests/lz32/CMakeLists.txt create mode 100644 rostests/winetests/mapi32/CMakeLists.txt create mode 100644 rostests/winetests/mlang/CMakeLists.txt create mode 100644 rostests/winetests/msacm32/CMakeLists.txt create mode 100644 rostests/winetests/mscms/CMakeLists.txt create mode 100644 rostests/winetests/msctf/CMakeLists.txt diff --git a/rostests/CMakeLists.txt b/rostests/CMakeLists.txt new file mode 100644 index 00000000000..b926010d908 --- /dev/null +++ b/rostests/CMakeLists.txt @@ -0,0 +1,9 @@ + +#add_subdirectory(apitests) +#add_subdirectory(dibtests) +#add_subdirectory(dxtest) +#add_subdirectory(regtests) +#add_subdirectory(rosautotest) +#add_subdirectory(tests) +#add_subdirectory(win32) +add_subdirectory(winetests) diff --git a/rostests/winetests/CMakeLists.txt b/rostests/winetests/CMakeLists.txt new file mode 100644 index 00000000000..c1b54f1c428 --- /dev/null +++ b/rostests/winetests/CMakeLists.txt @@ -0,0 +1,88 @@ + +add_subdirectory(advapi32) +add_subdirectory(advpack) +add_subdirectory(amstream) +add_subdirectory(atl) +add_subdirectory(avifil32) +add_subdirectory(browseui) +add_subdirectory(cabinet) +add_subdirectory(comcat) +add_subdirectory(comctl32) +add_subdirectory(comdlg32) +add_subdirectory(credui) +add_subdirectory(crypt32) +add_subdirectory(cryptnet) +add_subdirectory(cryptui) +add_subdirectory(dnsapi) +add_subdirectory(dsound) +add_subdirectory(fusion) +add_subdirectory(gdi32) +add_subdirectory(gdiplus) +add_subdirectory(hlink) +add_subdirectory(icmp) +add_subdirectory(imm32) +add_subdirectory(inetcomm) +add_subdirectory(inetmib1) +add_subdirectory(iphlpapi) +add_subdirectory(itss) +add_subdirectory(jscript) +add_subdirectory(kernel32) +add_subdirectory(localspl) +add_subdirectory(localui) +add_subdirectory(lz32) +add_subdirectory(mapi32) +add_subdirectory(mlang) +add_subdirectory(msacm32) +add_subdirectory(mscms) +add_subdirectory(msctf) +#add_subdirectory(mshtml) +#add_subdirectory(msi) +#add_subdirectory(mstask) +#add_subdirectory(msvcrt) +#add_subdirectory(msvcrtd) +#add_subdirectory(msvfw32) +#add_subdirectory(msxml3) +#add_subdirectory(netapi32) +#add_subdirectory(ntdll) +#add_subdirectory(ntdsapi) +#add_subdirectory(ntprint) +#add_subdirectory(odbccp32) +#add_subdirectory(ole32) +#add_subdirectory(oleacc) +#add_subdirectory(oleaut32) +#add_subdirectory(opengl32) +#add_subdirectory(pdh) +#add_subdirectory(powrprof) +#add_subdirectory(psapi) +#add_subdirectory(qmgr) +#add_subdirectory(quartz) +#add_subdirectory(rasapi32) +#add_subdirectory(riched20) +#add_subdirectory(riched32) +#add_subdirectory(rpcrt4) +#add_subdirectory(rsabase) +#add_subdirectory(rsaenh) +#add_subdirectory(schannel) +#add_subdirectory(secur32) +#add_subdirectory(serialui) +#add_subdirectory(setupapi) +#add_subdirectory(shdocvw) +#add_subdirectory(shell32) +#add_subdirectory(shlwapi) +#add_subdirectory(snmpapi) +#add_subdirectory(spoolss) +#add_subdirectory(twain_32) +#add_subdirectory(urlmon) +#add_subdirectory(user32) +#add_subdirectory(userenv) +#add_subdirectory(usp10) +#add_subdirectory(uxtheme) +#add_subdirectory(version) +#add_subdirectory(winhttp) +#add_subdirectory(wininet) +#add_subdirectory(winmm) +#add_subdirectory(wintrust) +#add_subdirectory(wlanapi) +#add_subdirectory(wldap32) +#add_subdirectory(ws2_32) +#add_subdirectory(xmllite) diff --git a/rostests/winetests/advapi32/CMakeLists.txt b/rostests/winetests/advapi32/CMakeLists.txt new file mode 100644 index 00000000000..d581b7f7cb8 --- /dev/null +++ b/rostests/winetests/advapi32/CMakeLists.txt @@ -0,0 +1,25 @@ + +add_definitions( + -D__ROS_LONG64__ + -D_DLL -D__USE_CRTIMP) + +list(APPEND SOURCE + cred.c + crypt.c + crypt_lmhash.c + crypt_md4.c + crypt_md5.c + crypt_sha.c + eventlog.c + lsa.c + registry.c + security.c + service.c + testlist.c) + +add_executable(advapi32_winetest ${SOURCE}) + +target_link_libraries(advapi32_winetest uuid) + +set_module_type(advapi32_winetest win32cui) +add_importlibs(advapi32_winetest advapi32 ole32 msvcrt kernel32 ntdll) diff --git a/rostests/winetests/advpack/CMakeLists.txt b/rostests/winetests/advpack/CMakeLists.txt new file mode 100644 index 00000000000..1976f4ccee5 --- /dev/null +++ b/rostests/winetests/advpack/CMakeLists.txt @@ -0,0 +1,17 @@ + +add_definitions( + -D__ROS_LONG64__ + -D_DLL -D__USE_CRTIMP) + +list(APPEND SOURCE + advpack.c + files.c + install.c + testlist.c) + +add_executable(advpack_winetest ${SOURCE}) + +target_link_libraries(advpack_winetest wine) + +set_module_type(advpack_winetest win32cui) +add_importlibs(advpack_winetest cabinet advapi32 msvcrt kernel32 ntdll) diff --git a/rostests/winetests/amstream/CMakeLists.txt b/rostests/winetests/amstream/CMakeLists.txt new file mode 100644 index 00000000000..e861c17aa1b --- /dev/null +++ b/rostests/winetests/amstream/CMakeLists.txt @@ -0,0 +1,6 @@ + +add_definitions(-D_DLL -D__USE_CRTIMP) +add_executable(amstream_winetest amstream.c testlist.c) +target_link_libraries(amstream_winetest wine uuid) +set_module_type(amstream_winetest win32cui) +add_importlibs(amstream_winetest ole32 user32 ddraw msvcrt kernel32 ntdll) diff --git a/rostests/winetests/atl/CMakeLists.txt b/rostests/winetests/atl/CMakeLists.txt new file mode 100644 index 00000000000..02a34167d81 --- /dev/null +++ b/rostests/winetests/atl/CMakeLists.txt @@ -0,0 +1,14 @@ + +add_definitions(-D_DLL -D__USE_CRTIMP) + +list(APPEND SOURCE + atl_ax.c + module.c + testlist.c) + +add_executable(atl_winetest ${SOURCE}) + +target_link_libraries(atl_winetest wine uuid) + +set_module_type(atl_winetest win32cui) +add_importlibs(atl_winetest ole32 user32 atl msvcrt kernel32 ntdll) diff --git a/rostests/winetests/avifil32/CMakeLists.txt b/rostests/winetests/avifil32/CMakeLists.txt new file mode 100644 index 00000000000..cf62f0fd2ff --- /dev/null +++ b/rostests/winetests/avifil32/CMakeLists.txt @@ -0,0 +1,6 @@ + +add_definitions(-D_DLL -D__USE_CRTIMP) +add_executable(avifil32_winetest api.c testlist.c) +target_link_libraries(avifil32_winetest wine) +set_module_type(avifil32_winetest win32cui) +add_importlibs(avifil32_winetest avifil32 msvcrt kernel32) diff --git a/rostests/winetests/browseui/CMakeLists.txt b/rostests/winetests/browseui/CMakeLists.txt new file mode 100644 index 00000000000..f2a53f68071 --- /dev/null +++ b/rostests/winetests/browseui/CMakeLists.txt @@ -0,0 +1,9 @@ + +add_definitions( + -D__ROS_LONG64__ + -D_DLL -D__USE_CRTIMP) + +add_executable(browseui_winetest autocomplete.c testlist.c) +target_link_libraries(browseui_winetest wine uuid) +set_module_type(browseui_winetest win32cui) +add_importlibs(browseui_winetest user32 ole32 msvcrt kernel32 ntdll) diff --git a/rostests/winetests/cabinet/CMakeLists.txt b/rostests/winetests/cabinet/CMakeLists.txt new file mode 100644 index 00000000000..b224689daf8 --- /dev/null +++ b/rostests/winetests/cabinet/CMakeLists.txt @@ -0,0 +1,9 @@ + +add_definitions( + -D__ROS_LONG64__ + -D_DLL -D__USE_CRTIMP) + +add_executable(cabinet_winetest extract.c fdi.c testlist.c) +target_link_libraries(cabinet_winetest wine) +set_module_type(cabinet_winetest win32cui) +add_importlibs(cabinet_winetest cabinet msvcrt kernel32 ntdll) diff --git a/rostests/winetests/comcat/CMakeLists.txt b/rostests/winetests/comcat/CMakeLists.txt new file mode 100644 index 00000000000..0bc71877792 --- /dev/null +++ b/rostests/winetests/comcat/CMakeLists.txt @@ -0,0 +1,9 @@ + +add_definitions( + -D__ROS_LONG64__ + -D_DLL -D__USE_CRTIMP) + +add_executable(comcat_winetest comcat.c testlist.c) +target_link_libraries(comcat_winetest wine uuid) +set_module_type(comcat_winetest win32cui) +add_importlibs(comcat_winetest ole32 advapi32 msvcrt kernel32 ntdll) diff --git a/rostests/winetests/comctl32/CMakeLists.txt b/rostests/winetests/comctl32/CMakeLists.txt new file mode 100644 index 00000000000..e7ccb4fb549 --- /dev/null +++ b/rostests/winetests/comctl32/CMakeLists.txt @@ -0,0 +1,40 @@ + +add_definitions( + -D__ROS_LONG64__ + -D_DLL -D__USE_CRTIMP) + +remove_definitions(-D_WIN32_WINNT=0x502) +add_definitions(-D_WIN32_WINNT=0x600) + +remove_definitions(-D_WIN32_IE=0x600) +add_definitions(-D_WIN32_IE=0x500) + +list(APPEND SOURCE + comboex.c + datetime.c + dpa.c + header.c + imagelist.c + ipaddress.c + listview.c + misc.c + monthcal.c + mru.c + progress.c + propsheet.c + rebar.c + status.c + subclass.c + tab.c + toolbar.c + tooltips.c + trackbar.c + treeview.c + updown.c + testlist.c + rsrc.rc) + +add_executable(comctl32_winetest ${SOURCE}) +target_link_libraries(comctl32_winetest wine) +set_module_type(comctl32_winetest win32cui) +add_importlibs(comctl32_winetest comctl32 ole32 user32 gdi32 advapi32 msvcrt kernel32 ntdll) diff --git a/rostests/winetests/comdlg32/CMakeLists.txt b/rostests/winetests/comdlg32/CMakeLists.txt new file mode 100644 index 00000000000..0e9cc2810fd --- /dev/null +++ b/rostests/winetests/comdlg32/CMakeLists.txt @@ -0,0 +1,16 @@ + +add_definitions( + -D__ROS_LONG64__ + -D_DLL -D__USE_CRTIMP) + +list(APPEND SOURCE + filedlg.c + fontdlg.c + printdlg.c + testlist.c + rsrc.rc) + +add_executable(comdlg32_winetest ${SOURCE}) +target_link_libraries(comdlg32_winetest wine) +set_module_type(comdlg32_winetest win32cui) +add_importlibs(comdlg32_winetest comdlg32 winspool user32 gdi32 msvcrt kernel32 ntdll) diff --git a/rostests/winetests/credui/CMakeLists.txt b/rostests/winetests/credui/CMakeLists.txt new file mode 100644 index 00000000000..e493c404c99 --- /dev/null +++ b/rostests/winetests/credui/CMakeLists.txt @@ -0,0 +1,9 @@ + +add_definitions( + -D__ROS_LONG64__ + -D_DLL -D__USE_CRTIMP) + +add_executable(credui_winetest credui.c testlist.c) +target_link_libraries(credui_winetest wine) +set_module_type(credui_winetest win32cui) +add_importlibs(credui_winetest credui msvcrt kernel32 ntdll) diff --git a/rostests/winetests/crypt32/CMakeLists.txt b/rostests/winetests/crypt32/CMakeLists.txt new file mode 100644 index 00000000000..6653c07d811 --- /dev/null +++ b/rostests/winetests/crypt32/CMakeLists.txt @@ -0,0 +1,27 @@ + +add_definitions( + -D__ROS_LONG64__ + -D_DLL -D__USE_CRTIMP) + +list(APPEND SOURCE + base64.c + cert.c + chain.c + crl.c + ctl.c + encode.c + main.c + message.c + msg.c + object.c + oid.c + protectdata.c + sip.c + store.c + str.c + testlist.c) + +add_executable(crypt32_winetest ${SOURCE}) +target_link_libraries(crypt32_winetest wine) +set_module_type(crypt32_winetest win32cui) +add_importlibs(crypt32_winetest crypt32 advapi32 msvcrt kernel32 ntdll) diff --git a/rostests/winetests/cryptnet/CMakeLists.txt b/rostests/winetests/cryptnet/CMakeLists.txt new file mode 100644 index 00000000000..9cebff64c00 --- /dev/null +++ b/rostests/winetests/cryptnet/CMakeLists.txt @@ -0,0 +1,9 @@ + +add_definitions( + -D__ROS_LONG64__ + -D_DLL -D__USE_CRTIMP) + +add_executable(cryptnet_winetest cryptnet.c testlist.c) +target_link_libraries(cryptnet_winetest wine) +set_module_type(cryptnet_winetest win32cui) +add_importlibs(cryptnet_winetest cryptnet crypt32 msvcrt kernel32 ntdll) diff --git a/rostests/winetests/cryptui/CMakeLists.txt b/rostests/winetests/cryptui/CMakeLists.txt new file mode 100644 index 00000000000..d5b195f641f --- /dev/null +++ b/rostests/winetests/cryptui/CMakeLists.txt @@ -0,0 +1,9 @@ + +add_definitions( + -D__ROS_LONG64__ + -D_DLL -D__USE_CRTIMP) + +add_executable(cryptui_winetest cryptui.c testlist.c) +target_link_libraries(cryptui_winetest wine) +set_module_type(cryptui_winetest win32cui) +add_importlibs(cryptui_winetest cryptui crypt32 user32 msvcrt kernel32 ntdll) diff --git a/rostests/winetests/dnsapi/CMakeLists.txt b/rostests/winetests/dnsapi/CMakeLists.txt new file mode 100644 index 00000000000..81fdcd0f518 --- /dev/null +++ b/rostests/winetests/dnsapi/CMakeLists.txt @@ -0,0 +1,9 @@ + +add_definitions( + -D__ROS_LONG64__ + -D_DLL -D__USE_CRTIMP) + +add_executable(dnsapi_winetest name.c record.c testlist.c) +target_link_libraries(dnsapi_winetest wine) +set_module_type(dnsapi_winetest win32cui) +add_importlibs(dnsapi_winetest dnsapi msvcrt kernel32 ntdll) diff --git a/rostests/winetests/dsound/CMakeLists.txt b/rostests/winetests/dsound/CMakeLists.txt new file mode 100644 index 00000000000..6007befcfc4 --- /dev/null +++ b/rostests/winetests/dsound/CMakeLists.txt @@ -0,0 +1,19 @@ + +add_definitions( + -D__ROS_LONG64__ + -D_DLL -D__USE_CRTIMP) + +list(APPEND SOURCE + capture.c + ds3d8.c + ds3d.c + dsound8.c + dsound.c + duplex.c + propset.c + testlist.c) + +add_executable(dsound_winetest ${SOURCE}) +target_link_libraries(dsound_winetest wine uuid dxguid) +set_module_type(dsound_winetest win32cui) +add_importlibs(dsound_winetest dsound ole32 user32 msvcrt kernel32 ntdll) diff --git a/rostests/winetests/fusion/CMakeLists.txt b/rostests/winetests/fusion/CMakeLists.txt new file mode 100644 index 00000000000..b333c0bc2fc --- /dev/null +++ b/rostests/winetests/fusion/CMakeLists.txt @@ -0,0 +1,16 @@ + +add_definitions( + -D__ROS_LONG64__ + -D_DLL -D__USE_CRTIMP) + +list(APPEND SOURCE + asmcache.c + asmenum.c + asmname.c + fusion.c + testlist.c) + +add_executable(fusion_winetest ${SOURCE}) +target_link_libraries(fusion_winetest wine) +set_module_type(fusion_winetest win32cui) +add_importlibs(fusion_winetest user32 msvcrt kernel32 ntdll) diff --git a/rostests/winetests/gdi32/CMakeLists.txt b/rostests/winetests/gdi32/CMakeLists.txt new file mode 100644 index 00000000000..d3f2bc3646d --- /dev/null +++ b/rostests/winetests/gdi32/CMakeLists.txt @@ -0,0 +1,24 @@ + +add_definitions( + -D__ROS_LONG64__ + -D_DLL -D__USE_CRTIMP) + +list(APPEND SOURCE + bitmap.c + brush.c + clipping.c + dc.c + gdiobj.c + generated.c + icm.c + font.c + mapping.c + metafile.c + palette.c + path.c + pen.c + testlist.c) + +add_executable(gdi32_winetest ${SOURCE}) +set_module_type(gdi32_winetest win32cui) +add_importlibs(gdi32_winetest gdi32 user32 advapi32 msvcrt kernel32 ntdll) diff --git a/rostests/winetests/gdiplus/CMakeLists.txt b/rostests/winetests/gdiplus/CMakeLists.txt new file mode 100644 index 00000000000..325f20b2b0d --- /dev/null +++ b/rostests/winetests/gdiplus/CMakeLists.txt @@ -0,0 +1,23 @@ + +add_definitions( + -D__ROS_LONG64__ + -D_DLL -D__USE_CRTIMP) + +list(APPEND SOURCE + brush.c + customlinecap.c + font.c + graphics.c + graphicspath.c + image.c + matrix.c + pathiterator.c + pen.c + region.c + stringformat.c + testlist.c) + +add_executable(gdiplus_winetest ${SOURCE}) +target_link_libraries(gdiplus_winetest wine) +set_module_type(gdiplus_winetest win32cui) +add_importlibs(gdiplus_winetest gdiplus user32 gdi32 ole32 msvcrt kernel32 ntdll) diff --git a/rostests/winetests/hlink/CMakeLists.txt b/rostests/winetests/hlink/CMakeLists.txt new file mode 100644 index 00000000000..e8edbfffb1d --- /dev/null +++ b/rostests/winetests/hlink/CMakeLists.txt @@ -0,0 +1,14 @@ + +add_definitions( + -D__ROS_LONG64__ + -D_DLL -D__USE_CRTIMP) + +list(APPEND SOURCE + browse_ctx.c + hlink.c + testlist.c) + +add_executable(hlink_winetest ${SOURCE}) +target_link_libraries(hlink_winetest wine uuid) +set_module_type(hlink_winetest win32cui) +add_importlibs(hlink_winetest hlink ole32 msvcrt kernel32 ntdll) diff --git a/rostests/winetests/icmp/CMakeLists.txt b/rostests/winetests/icmp/CMakeLists.txt new file mode 100644 index 00000000000..dfcd1f3350d --- /dev/null +++ b/rostests/winetests/icmp/CMakeLists.txt @@ -0,0 +1,9 @@ + +add_definitions( + -D__ROS_LONG64__ + -D_DLL -D__USE_CRTIMP) + +add_executable(icmp_winetest icmp.c testlist.c) +target_link_libraries(icmp_winetest wine uuid) +set_module_type(icmp_winetest win32cui) +add_importlibs(icmp_winetest icmp msvcrt kernel32 ntdll) diff --git a/rostests/winetests/imm32/CMakeLists.txt b/rostests/winetests/imm32/CMakeLists.txt new file mode 100644 index 00000000000..dbd80fd3c55 --- /dev/null +++ b/rostests/winetests/imm32/CMakeLists.txt @@ -0,0 +1,9 @@ + +add_definitions( + -D__ROS_LONG64__ + -D_DLL -D__USE_CRTIMP) + +add_executable(imm32_winetest imm32.c testlist.c) +target_link_libraries(imm32_winetest wine) +set_module_type(imm32_winetest win32cui) +add_importlibs(imm32_winetest imm32 user32 msvcrt kernel32 ntdll) diff --git a/rostests/winetests/inetcomm/CMakeLists.txt b/rostests/winetests/inetcomm/CMakeLists.txt new file mode 100644 index 00000000000..3f6c28be44f --- /dev/null +++ b/rostests/winetests/inetcomm/CMakeLists.txt @@ -0,0 +1,14 @@ + +add_definitions( + -D__ROS_LONG64__ + -D_DLL -D__USE_CRTIMP) + +list(APPEND SOURCE + mimeintl.c + mimeole.c + testlist.c) + +add_executable(inetcomm_winetest ${SOURCE}) +target_link_libraries(inetcomm_winetest wine) +set_module_type(inetcomm_winetest win32cui) +add_importlibs(inetcomm_winetest inetcomm oleaut32 ole32 msvcrt kernel32 ntdll) diff --git a/rostests/winetests/inetmib1/CMakeLists.txt b/rostests/winetests/inetmib1/CMakeLists.txt new file mode 100644 index 00000000000..fb822b5bc7f --- /dev/null +++ b/rostests/winetests/inetmib1/CMakeLists.txt @@ -0,0 +1,9 @@ + +add_definitions( + -D__ROS_LONG64__ + -D_DLL -D__USE_CRTIMP) + +add_executable(inetmib1_winetest main.c testlist.c) +target_link_libraries(inetmib1_winetest wine) +set_module_type(inetmib1_winetest win32cui) +add_importlibs(inetmib1_winetest snmpapi msvcrt kernel32 ntdll) diff --git a/rostests/winetests/iphlpapi/CMakeLists.txt b/rostests/winetests/iphlpapi/CMakeLists.txt new file mode 100644 index 00000000000..1f81d67f3dd --- /dev/null +++ b/rostests/winetests/iphlpapi/CMakeLists.txt @@ -0,0 +1,9 @@ + +add_definitions( + -D__ROS_LONG64__ + -D_DLL -D__USE_CRTIMP) + +add_executable(iphlpapi_winetest iphlpapi.c testlist.c) +target_link_libraries(iphlpapi_winetest wine) +set_module_type(iphlpapi_winetest win32cui) +add_importlibs(iphlpapi_winetest msvcrt kernel32 ntdll) diff --git a/rostests/winetests/itss/CMakeLists.txt b/rostests/winetests/itss/CMakeLists.txt new file mode 100644 index 00000000000..177663b20a1 --- /dev/null +++ b/rostests/winetests/itss/CMakeLists.txt @@ -0,0 +1,9 @@ + +add_definitions( + -D__ROS_LONG64__ + -D_DLL -D__USE_CRTIMP) + +add_executable(itss_winetest protocol.c testlist.c rsrc.rc) +target_link_libraries(itss_winetest wine) +set_module_type(itss_winetest win32cui) +add_importlibs(itss_winetest ole32 msvcrt kernel32 ntdll) diff --git a/rostests/winetests/jscript/CMakeLists.txt b/rostests/winetests/jscript/CMakeLists.txt new file mode 100644 index 00000000000..ca450f67cbd --- /dev/null +++ b/rostests/winetests/jscript/CMakeLists.txt @@ -0,0 +1,16 @@ + +add_definitions( + -D__ROS_LONG64__ + -D_DLL -D__USE_CRTIMP) + +list(APPEND SOURCE + activex.c + jscript.c + run.c + testlist.c + rsrc.rc) + +add_executable(jscript_winetest ${SOURCE}) +target_link_libraries(jscript_winetest wine) +set_module_type(jscript_winetest win32cui) +add_importlibs(jscript_winetest ole32 oleaut32 advapi32 msvcrt kernel32 ntdll) diff --git a/rostests/winetests/kernel32/CMakeLists.txt b/rostests/winetests/kernel32/CMakeLists.txt new file mode 100644 index 00000000000..45634007224 --- /dev/null +++ b/rostests/winetests/kernel32/CMakeLists.txt @@ -0,0 +1,47 @@ + +add_definitions( + -D__ROS_LONG64__ + -D_DLL -D__USE_CRTIMP) + +list(APPEND SOURCE + actctx.c + alloc.c + atom.c + change.c + codepage.c + comm.c + console.c + debugger.c + directory.c + drive.c + environ.c + fiber.c + file.c + format_msg.c + #generated.c + heap.c + interlck.c + loader.c + locale.c + mailslot.c + module.c + path.c + pipe.c + process.c + profile.c + resource.c + sync.c + thread.c + time.c + timer.c + toolhelp.c + version.c + virtual.c + volume.c + testlist.c + resource.rc) + +add_executable(kernel32_winetest ${SOURCE}) +target_link_libraries(kernel32_winetest wine) +set_module_type(kernel32_winetest win32cui) +add_importlibs(kernel32_winetest user32 advapi32 msvcrt kernel32 ntdll) diff --git a/rostests/winetests/localspl/CMakeLists.txt b/rostests/winetests/localspl/CMakeLists.txt new file mode 100644 index 00000000000..81b504860e5 --- /dev/null +++ b/rostests/winetests/localspl/CMakeLists.txt @@ -0,0 +1,10 @@ + +add_definitions( + -D__ROS_LONG64__ + -D_DLL -D__USE_CRTIMP) + +include_directories(${REACTOS_SOURCE_DIR}/include/reactos/wine) +add_executable(localspl_winetest localmon.c testlist.c) +target_link_libraries(localspl_winetest wine) +set_module_type(localspl_winetest win32cui) +add_importlibs(localspl_winetest advapi32 msvcrt kernel32 ntdll) diff --git a/rostests/winetests/localui/CMakeLists.txt b/rostests/winetests/localui/CMakeLists.txt new file mode 100644 index 00000000000..3609ab3bbd3 --- /dev/null +++ b/rostests/winetests/localui/CMakeLists.txt @@ -0,0 +1,10 @@ + +add_definitions( + -D__ROS_LONG64__ + -D_DLL -D__USE_CRTIMP) + +include_directories(${REACTOS_SOURCE_DIR}/include/reactos/wine) +add_executable(localui_winetest localui.c testlist.c) +target_link_libraries(localui_winetest wine) +set_module_type(localui_winetest win32cui) +add_importlibs(localui_winetest winspool msvcrt kernel32 ntdll) diff --git a/rostests/winetests/lz32/CMakeLists.txt b/rostests/winetests/lz32/CMakeLists.txt new file mode 100644 index 00000000000..fcfd2d3bd59 --- /dev/null +++ b/rostests/winetests/lz32/CMakeLists.txt @@ -0,0 +1,9 @@ + +add_definitions( + -D__ROS_LONG64__ + -D_DLL -D__USE_CRTIMP) + +add_executable(lz32_winetest lzexpand_main.c testlist.c) +target_link_libraries(lz32_winetest wine) +set_module_type(lz32_winetest win32cui) +add_importlibs(lz32_winetest lz32 msvcrt kernel32 ntdll) diff --git a/rostests/winetests/mapi32/CMakeLists.txt b/rostests/winetests/mapi32/CMakeLists.txt new file mode 100644 index 00000000000..e77f2cad0c0 --- /dev/null +++ b/rostests/winetests/mapi32/CMakeLists.txt @@ -0,0 +1,15 @@ + +add_definitions( + -D__ROS_LONG64__ + -D_DLL -D__USE_CRTIMP) + +list(APPEND SOURCE + imalloc.c + prop.c + util.c + testlist.c) + +add_executable(mapi32_winetest ${SOURCE}) +target_link_libraries(mapi32_winetest wine uuid) +set_module_type(mapi32_winetest win32cui) +add_importlibs(mapi32_winetest advapi32 msvcrt kernel32 ntdll) diff --git a/rostests/winetests/mlang/CMakeLists.txt b/rostests/winetests/mlang/CMakeLists.txt new file mode 100644 index 00000000000..beddd20ee4f --- /dev/null +++ b/rostests/winetests/mlang/CMakeLists.txt @@ -0,0 +1,9 @@ + +add_definitions( + -D__ROS_LONG64__ + -D_DLL -D__USE_CRTIMP) + +add_executable(mlang_winetest mlang.c testlist.c) +target_link_libraries(mlang_winetest wine uuid) +set_module_type(mlang_winetest win32cui) +add_importlibs(mlang_winetest oleaut32 ole32 gdi32 msvcrt kernel32 ntdll) diff --git a/rostests/winetests/msacm32/CMakeLists.txt b/rostests/winetests/msacm32/CMakeLists.txt new file mode 100644 index 00000000000..377356cae73 --- /dev/null +++ b/rostests/winetests/msacm32/CMakeLists.txt @@ -0,0 +1,9 @@ + +add_definitions( + -D__ROS_LONG64__ + -D_DLL -D__USE_CRTIMP) + +add_executable(msacm32_winetest msacm.c testlist.c) +target_link_libraries(msacm32_winetest wine) +set_module_type(msacm32_winetest win32cui) +add_importlibs(msacm32_winetest msacm32 msvcrt kernel32 ntdll) diff --git a/rostests/winetests/mscms/CMakeLists.txt b/rostests/winetests/mscms/CMakeLists.txt new file mode 100644 index 00000000000..d6f972f4507 --- /dev/null +++ b/rostests/winetests/mscms/CMakeLists.txt @@ -0,0 +1,9 @@ + +add_definitions( + -D__ROS_LONG64__ + -D_DLL -D__USE_CRTIMP) + +add_executable(mscms_winetest profile.c testlist.c) +target_link_libraries(mscms_winetest wine) +set_module_type(mscms_winetest win32cui) +add_importlibs(mscms_winetest advapi32 msvcrt kernel32 ntdll) diff --git a/rostests/winetests/msctf/CMakeLists.txt b/rostests/winetests/msctf/CMakeLists.txt new file mode 100644 index 00000000000..1ac0ad4a780 --- /dev/null +++ b/rostests/winetests/msctf/CMakeLists.txt @@ -0,0 +1,9 @@ + +add_definitions( + -D__ROS_LONG64__ + -D_DLL -D__USE_CRTIMP) + +add_executable(msctf_winetest inputprocessor.c testlist.c) +target_link_libraries(msctf_winetest wine) +set_module_type(msctf_winetest win32cui) +add_importlibs(msctf_winetest ole32 user32 msvcrt kernel32 ntdll) From 0b6a8d819a03f6a162487985221c3501799161b0 Mon Sep 17 00:00:00 2001 From: Amine Khaldi Date: Tue, 7 Dec 2010 11:40:10 +0000 Subject: [PATCH 030/181] [CMAKE] - More work rostests cmake integration. Winetests are almost all done (two remain). svn path=/trunk/; revision=49968 --- rostests/winetests/CMakeLists.txt | 98 +++++++++++----------- rostests/winetests/mshtml/CMakeLists.txt | 20 +++++ rostests/winetests/msi/CMakeLists.txt | 22 +++++ rostests/winetests/mstask/CMakeLists.txt | 15 ++++ rostests/winetests/msvcrt/CMakeLists.txt | 26 ++++++ rostests/winetests/msvcrtd/CMakeLists.txt | 9 ++ rostests/winetests/msvfw32/CMakeLists.txt | 9 ++ rostests/winetests/msxml3/CMakeLists.txt | 17 ++++ rostests/winetests/netapi32/CMakeLists.txt | 16 ++++ rostests/winetests/ntdll/CMakeLists.txt | 30 +++++++ rostests/winetests/ntdsapi/CMakeLists.txt | 9 ++ rostests/winetests/ntprint/CMakeLists.txt | 9 ++ rostests/winetests/odbccp32/CMakeLists.txt | 9 ++ rostests/winetests/ole32/CMakeLists.txt | 25 ++++++ rostests/winetests/oleacc/CMakeLists.txt | 9 ++ rostests/winetests/opengl32/CMakeLists.txt | 9 ++ rostests/winetests/pdh/CMakeLists.txt | 9 ++ rostests/winetests/powrprof/CMakeLists.txt | 9 ++ rostests/winetests/psapi/CMakeLists.txt | 9 ++ rostests/winetests/qmgr/CMakeLists.txt | 17 ++++ rostests/winetests/quartz/CMakeLists.txt | 20 +++++ rostests/winetests/rasapi32/CMakeLists.txt | 9 ++ rostests/winetests/riched20/CMakeLists.txt | 15 ++++ rostests/winetests/riched32/CMakeLists.txt | 9 ++ rostests/winetests/rsabase/CMakeLists.txt | 9 ++ rostests/winetests/rsaenh/CMakeLists.txt | 9 ++ rostests/winetests/schannel/CMakeLists.txt | 9 ++ rostests/winetests/secur32/CMakeLists.txt | 16 ++++ rostests/winetests/serialui/CMakeLists.txt | 9 ++ rostests/winetests/setupapi/CMakeLists.txt | 20 +++++ rostests/winetests/shdocvw/CMakeLists.txt | 16 ++++ rostests/winetests/shell32/CMakeLists.txt | 29 +++++++ rostests/winetests/shlwapi/CMakeLists.txt | 23 +++++ rostests/winetests/snmpapi/CMakeLists.txt | 9 ++ rostests/winetests/spoolss/CMakeLists.txt | 9 ++ rostests/winetests/twain_32/CMakeLists.txt | 9 ++ rostests/winetests/urlmon/CMakeLists.txt | 19 +++++ rostests/winetests/user32/CMakeLists.txt | 37 ++++++++ rostests/winetests/userenv/CMakeLists.txt | 9 ++ rostests/winetests/usp10/CMakeLists.txt | 9 ++ rostests/winetests/uxtheme/CMakeLists.txt | 9 ++ rostests/winetests/version/CMakeLists.txt | 15 ++++ rostests/winetests/winhttp/CMakeLists.txt | 15 ++++ rostests/winetests/wininet/CMakeLists.txt | 18 ++++ rostests/winetests/winmm/CMakeLists.txt | 18 ++++ rostests/winetests/wintrust/CMakeLists.txt | 16 ++++ rostests/winetests/wlanapi/CMakeLists.txt | 9 ++ rostests/winetests/wldap32/CMakeLists.txt | 9 ++ rostests/winetests/ws2_32/CMakeLists.txt | 9 ++ rostests/winetests/xmllite/CMakeLists.txt | 9 ++ 50 files changed, 748 insertions(+), 49 deletions(-) create mode 100644 rostests/winetests/mshtml/CMakeLists.txt create mode 100644 rostests/winetests/msi/CMakeLists.txt create mode 100644 rostests/winetests/mstask/CMakeLists.txt create mode 100644 rostests/winetests/msvcrt/CMakeLists.txt create mode 100644 rostests/winetests/msvcrtd/CMakeLists.txt create mode 100644 rostests/winetests/msvfw32/CMakeLists.txt create mode 100644 rostests/winetests/msxml3/CMakeLists.txt create mode 100644 rostests/winetests/netapi32/CMakeLists.txt create mode 100644 rostests/winetests/ntdll/CMakeLists.txt create mode 100644 rostests/winetests/ntdsapi/CMakeLists.txt create mode 100644 rostests/winetests/ntprint/CMakeLists.txt create mode 100644 rostests/winetests/odbccp32/CMakeLists.txt create mode 100644 rostests/winetests/ole32/CMakeLists.txt create mode 100644 rostests/winetests/oleacc/CMakeLists.txt create mode 100644 rostests/winetests/opengl32/CMakeLists.txt create mode 100644 rostests/winetests/pdh/CMakeLists.txt create mode 100644 rostests/winetests/powrprof/CMakeLists.txt create mode 100644 rostests/winetests/psapi/CMakeLists.txt create mode 100644 rostests/winetests/qmgr/CMakeLists.txt create mode 100644 rostests/winetests/quartz/CMakeLists.txt create mode 100644 rostests/winetests/rasapi32/CMakeLists.txt create mode 100644 rostests/winetests/riched20/CMakeLists.txt create mode 100644 rostests/winetests/riched32/CMakeLists.txt create mode 100644 rostests/winetests/rsabase/CMakeLists.txt create mode 100644 rostests/winetests/rsaenh/CMakeLists.txt create mode 100644 rostests/winetests/schannel/CMakeLists.txt create mode 100644 rostests/winetests/secur32/CMakeLists.txt create mode 100644 rostests/winetests/serialui/CMakeLists.txt create mode 100644 rostests/winetests/setupapi/CMakeLists.txt create mode 100644 rostests/winetests/shdocvw/CMakeLists.txt create mode 100644 rostests/winetests/shell32/CMakeLists.txt create mode 100644 rostests/winetests/shlwapi/CMakeLists.txt create mode 100644 rostests/winetests/snmpapi/CMakeLists.txt create mode 100644 rostests/winetests/spoolss/CMakeLists.txt create mode 100644 rostests/winetests/twain_32/CMakeLists.txt create mode 100644 rostests/winetests/urlmon/CMakeLists.txt create mode 100644 rostests/winetests/user32/CMakeLists.txt create mode 100644 rostests/winetests/userenv/CMakeLists.txt create mode 100644 rostests/winetests/usp10/CMakeLists.txt create mode 100644 rostests/winetests/uxtheme/CMakeLists.txt create mode 100644 rostests/winetests/version/CMakeLists.txt create mode 100644 rostests/winetests/winhttp/CMakeLists.txt create mode 100644 rostests/winetests/wininet/CMakeLists.txt create mode 100644 rostests/winetests/winmm/CMakeLists.txt create mode 100644 rostests/winetests/wintrust/CMakeLists.txt create mode 100644 rostests/winetests/wlanapi/CMakeLists.txt create mode 100644 rostests/winetests/wldap32/CMakeLists.txt create mode 100644 rostests/winetests/ws2_32/CMakeLists.txt create mode 100644 rostests/winetests/xmllite/CMakeLists.txt diff --git a/rostests/winetests/CMakeLists.txt b/rostests/winetests/CMakeLists.txt index c1b54f1c428..0ae0e8d6503 100644 --- a/rostests/winetests/CMakeLists.txt +++ b/rostests/winetests/CMakeLists.txt @@ -35,54 +35,54 @@ add_subdirectory(mlang) add_subdirectory(msacm32) add_subdirectory(mscms) add_subdirectory(msctf) -#add_subdirectory(mshtml) -#add_subdirectory(msi) -#add_subdirectory(mstask) -#add_subdirectory(msvcrt) -#add_subdirectory(msvcrtd) -#add_subdirectory(msvfw32) -#add_subdirectory(msxml3) -#add_subdirectory(netapi32) -#add_subdirectory(ntdll) -#add_subdirectory(ntdsapi) -#add_subdirectory(ntprint) -#add_subdirectory(odbccp32) -#add_subdirectory(ole32) -#add_subdirectory(oleacc) +add_subdirectory(mshtml) +add_subdirectory(msi) +add_subdirectory(mstask) +add_subdirectory(msvcrt) +add_subdirectory(msvcrtd) +add_subdirectory(msvfw32) +add_subdirectory(msxml3) +add_subdirectory(netapi32) +add_subdirectory(ntdll) +add_subdirectory(ntdsapi) +add_subdirectory(ntprint) +add_subdirectory(odbccp32) +add_subdirectory(ole32) +add_subdirectory(oleacc) #add_subdirectory(oleaut32) -#add_subdirectory(opengl32) -#add_subdirectory(pdh) -#add_subdirectory(powrprof) -#add_subdirectory(psapi) -#add_subdirectory(qmgr) -#add_subdirectory(quartz) -#add_subdirectory(rasapi32) -#add_subdirectory(riched20) -#add_subdirectory(riched32) +add_subdirectory(opengl32) +add_subdirectory(pdh) +add_subdirectory(powrprof) +add_subdirectory(psapi) +add_subdirectory(qmgr) +add_subdirectory(quartz) +add_subdirectory(rasapi32) +add_subdirectory(riched20) +add_subdirectory(riched32) #add_subdirectory(rpcrt4) -#add_subdirectory(rsabase) -#add_subdirectory(rsaenh) -#add_subdirectory(schannel) -#add_subdirectory(secur32) -#add_subdirectory(serialui) -#add_subdirectory(setupapi) -#add_subdirectory(shdocvw) -#add_subdirectory(shell32) -#add_subdirectory(shlwapi) -#add_subdirectory(snmpapi) -#add_subdirectory(spoolss) -#add_subdirectory(twain_32) -#add_subdirectory(urlmon) -#add_subdirectory(user32) -#add_subdirectory(userenv) -#add_subdirectory(usp10) -#add_subdirectory(uxtheme) -#add_subdirectory(version) -#add_subdirectory(winhttp) -#add_subdirectory(wininet) -#add_subdirectory(winmm) -#add_subdirectory(wintrust) -#add_subdirectory(wlanapi) -#add_subdirectory(wldap32) -#add_subdirectory(ws2_32) -#add_subdirectory(xmllite) +add_subdirectory(rsabase) +add_subdirectory(rsaenh) +add_subdirectory(schannel) +add_subdirectory(secur32) +add_subdirectory(serialui) +add_subdirectory(setupapi) +add_subdirectory(shdocvw) +add_subdirectory(shell32) +add_subdirectory(shlwapi) +add_subdirectory(snmpapi) +add_subdirectory(spoolss) +add_subdirectory(twain_32) +add_subdirectory(urlmon) +add_subdirectory(user32) +add_subdirectory(userenv) +add_subdirectory(usp10) +add_subdirectory(uxtheme) +add_subdirectory(version) +add_subdirectory(winhttp) +add_subdirectory(wininet) +add_subdirectory(winmm) +add_subdirectory(wintrust) +add_subdirectory(wlanapi) +add_subdirectory(wldap32) +add_subdirectory(ws2_32) +add_subdirectory(xmllite) diff --git a/rostests/winetests/mshtml/CMakeLists.txt b/rostests/winetests/mshtml/CMakeLists.txt new file mode 100644 index 00000000000..7222433f428 --- /dev/null +++ b/rostests/winetests/mshtml/CMakeLists.txt @@ -0,0 +1,20 @@ + +add_definitions( + -D__ROS_LONG64__ + -D_DLL -D__USE_CRTIMP) + +list(APPEND SOURCE + dom.c + events.c + htmldoc.c + htmllocation.c + misc.c + protocol.c + script.c + testlist.c + rsrc.rc) + +add_executable(mshtml_winetest ${SOURCE}) +target_link_libraries(mshtml_winetest wine uuid strmiids) +set_module_type(mshtml_winetest win32cui) +add_importlibs(mshtml_winetest wininet ole32 oleaut32 user32 gdi32 urlmon advapi32 msvcrt kernel32 ntdll) diff --git a/rostests/winetests/msi/CMakeLists.txt b/rostests/winetests/msi/CMakeLists.txt new file mode 100644 index 00000000000..7bcbe3dc69e --- /dev/null +++ b/rostests/winetests/msi/CMakeLists.txt @@ -0,0 +1,22 @@ + +add_definitions( + -D__ROS_LONG64__ + -D_DLL -D__USE_CRTIMP) + +list(APPEND SOURCE + automation.c + db.c + format.c + install.c + msi.c + package.c + patch.c + record.c + source.c + suminfo.c + testlist.c) + +add_executable(msi_winetest ${SOURCE}) +target_link_libraries(msi_winetest wine uuid) +set_module_type(msi_winetest win32cui) +add_importlibs(msi_winetest cabinet msi shell32 ole32 oleaut32 user32 advapi32 version msvcrt kernel32 ntdll) diff --git a/rostests/winetests/mstask/CMakeLists.txt b/rostests/winetests/mstask/CMakeLists.txt new file mode 100644 index 00000000000..f4832a30775 --- /dev/null +++ b/rostests/winetests/mstask/CMakeLists.txt @@ -0,0 +1,15 @@ + +add_definitions( + -D__ROS_LONG64__ + -D_DLL -D__USE_CRTIMP) + +list(APPEND SOURCE + task.c + task_scheduler.c + task_trigger.c + testlist.c) + +add_executable(mstask_winetest ${SOURCE}) +target_link_libraries(mstask_winetest wine) +set_module_type(mstask_winetest win32cui) +add_importlibs(mstask_winetest ole32 msvcrt kernel32 ntdll) diff --git a/rostests/winetests/msvcrt/CMakeLists.txt b/rostests/winetests/msvcrt/CMakeLists.txt new file mode 100644 index 00000000000..2270c89e8ef --- /dev/null +++ b/rostests/winetests/msvcrt/CMakeLists.txt @@ -0,0 +1,26 @@ + +add_definitions( + -D__ROS_LONG64__ + -D_CRT_NONSTDC_NO_DEPRECATE + -D_DLL -D__USE_CRTIMP) + +list(APPEND SOURCE + cpp.c + data.c + dir.c + environ.c + file.c + headers.c + heap.c + locale.c + misc.c + printf.c + scanf.c + signal.c + string.c + testlist.c + time.c) + +add_executable(msvcrt_winetest ${SOURCE}) +set_module_type(msvcrt_winetest win32cui) +add_importlibs(msvcrt_winetest msvcrt kernel32 ntdll) diff --git a/rostests/winetests/msvcrtd/CMakeLists.txt b/rostests/winetests/msvcrtd/CMakeLists.txt new file mode 100644 index 00000000000..6d3eb3b6cfe --- /dev/null +++ b/rostests/winetests/msvcrtd/CMakeLists.txt @@ -0,0 +1,9 @@ + +add_definitions( + -D__ROS_LONG64__ + -D_DLL -D__USE_CRTIMP) + +add_executable(msvcrtd_winetest debug.c testlist.c) +target_link_libraries(msvcrtd_winetest wine) +set_module_type(msvcrtd_winetest win32cui) +add_importlibs(msvcrtd_winetest msvcrt kernel32 ntdll) diff --git a/rostests/winetests/msvfw32/CMakeLists.txt b/rostests/winetests/msvfw32/CMakeLists.txt new file mode 100644 index 00000000000..628dc4e3ad4 --- /dev/null +++ b/rostests/winetests/msvfw32/CMakeLists.txt @@ -0,0 +1,9 @@ + +add_definitions( + -D__ROS_LONG64__ + -D_DLL -D__USE_CRTIMP) + +add_executable(msvfw32_winetest msvfw.c testlist.c) +target_link_libraries(msvfw32_winetest wine) +set_module_type(msvfw32_winetest win32cui) +add_importlibs(msvfw32_winetest msvfw32 msvcrt kernel32 ntdll) diff --git a/rostests/winetests/msxml3/CMakeLists.txt b/rostests/winetests/msxml3/CMakeLists.txt new file mode 100644 index 00000000000..89ef97e2300 --- /dev/null +++ b/rostests/winetests/msxml3/CMakeLists.txt @@ -0,0 +1,17 @@ + +add_definitions( + -D__ROS_LONG64__ + -D_DLL -D__USE_CRTIMP) + +list(APPEND SOURCE + domdoc.c + saxreader.c + schema.c + testlist.c + xmldoc.c + xmlelem.c) + +add_executable(msxml3_winetest ${SOURCE}) +target_link_libraries(msxml3_winetest wine) +set_module_type(msxml3_winetest win32cui) +add_importlibs(msxml3_winetest user32 ole32 oleaut32 msvcrt kernel32 ntdll) diff --git a/rostests/winetests/netapi32/CMakeLists.txt b/rostests/winetests/netapi32/CMakeLists.txt new file mode 100644 index 00000000000..8f8b4da78c7 --- /dev/null +++ b/rostests/winetests/netapi32/CMakeLists.txt @@ -0,0 +1,16 @@ + +add_definitions( + -D__ROS_LONG64__ + -D_DLL -D__USE_CRTIMP) + +list(APPEND SOURCE + access.c + apibuf.c + ds.c + wksta.c + testlist.c) + +add_executable(netapi32_winetest ${SOURCE}) +target_link_libraries(netapi32_winetest wine) +set_module_type(netapi32_winetest win32cui) +add_importlibs(netapi32_winetest advapi32 msvcrt kernel32 ntdll) diff --git a/rostests/winetests/ntdll/CMakeLists.txt b/rostests/winetests/ntdll/CMakeLists.txt new file mode 100644 index 00000000000..adaef0bc064 --- /dev/null +++ b/rostests/winetests/ntdll/CMakeLists.txt @@ -0,0 +1,30 @@ + +add_definitions( + -D__ROS_LONG64__ + -D_DLL -D__USE_CRTIMP) + +list(APPEND SOURCE + atom.c + change.c + directory.c + env.c + error.c + exception.c + file.c + generated.c + info.c + large_int.c + om.c + path.c + port.c + reg.c + rtlbitmap.c + rtl.c + rtlstr.c + string.c + time.c + testlist.c) + +add_executable(ntdll_winetest ${SOURCE}) +set_module_type(ntdll_winetest win32cui) +add_importlibs(ntdll_winetest user32 msvcrt kernel32 ntdll) diff --git a/rostests/winetests/ntdsapi/CMakeLists.txt b/rostests/winetests/ntdsapi/CMakeLists.txt new file mode 100644 index 00000000000..b99ec986b70 --- /dev/null +++ b/rostests/winetests/ntdsapi/CMakeLists.txt @@ -0,0 +1,9 @@ + +add_definitions( + -D__ROS_LONG64__ + -D_DLL -D__USE_CRTIMP) + +add_executable(ntdsapi_winetest ntdsapi.c testlist.c) +target_link_libraries(ntdsapi_winetest wine) +set_module_type(ntdsapi_winetest win32cui) +add_importlibs(ntdsapi_winetest ntdsapi msvcrt kernel32 ntdll) diff --git a/rostests/winetests/ntprint/CMakeLists.txt b/rostests/winetests/ntprint/CMakeLists.txt new file mode 100644 index 00000000000..192969e2385 --- /dev/null +++ b/rostests/winetests/ntprint/CMakeLists.txt @@ -0,0 +1,9 @@ + +add_definitions( + -D__ROS_LONG64__ + -D_DLL -D__USE_CRTIMP) + +add_executable(ntprint_winetest ntprint.c testlist.c) +target_link_libraries(ntprint_winetest wine) +set_module_type(ntprint_winetest win32cui) +add_importlibs(ntprint_winetest msvcrt kernel32 ntdll) diff --git a/rostests/winetests/odbccp32/CMakeLists.txt b/rostests/winetests/odbccp32/CMakeLists.txt new file mode 100644 index 00000000000..b90a6d7aaa2 --- /dev/null +++ b/rostests/winetests/odbccp32/CMakeLists.txt @@ -0,0 +1,9 @@ + +add_definitions( + -D__ROS_LONG64__ + -D_DLL -D__USE_CRTIMP) + +add_executable(odbccp32_winetest misc.c testlist.c) +target_link_libraries(odbccp32_winetest wine) +set_module_type(odbccp32_winetest win32cui) +add_importlibs(odbccp32_winetest odbccp32 msvcrt kernel32 ntdll) diff --git a/rostests/winetests/ole32/CMakeLists.txt b/rostests/winetests/ole32/CMakeLists.txt new file mode 100644 index 00000000000..9f3f03b92d1 --- /dev/null +++ b/rostests/winetests/ole32/CMakeLists.txt @@ -0,0 +1,25 @@ + +add_definitions( + -D__ROS_LONG64__ + -D_DLL -D__USE_CRTIMP) + +list(APPEND SOURCE + clipboard.c + compobj.c + defaulthandler.c + dragdrop.c + errorinfo.c + hglobalstream.c + marshal.c + moniker.c + ole2.c + propvariant.c + stg_prop.c + storage32.c + usrmarshal.c + testlist.c) + +add_executable(ole32_winetest ${SOURCE}) +target_link_libraries(ole32_winetest wine uuid) +set_module_type(ole32_winetest win32cui) +add_importlibs(ole32_winetest oleaut32 ole32 user32 gdi32 advapi32 msvcrt kernel32 ntdll) diff --git a/rostests/winetests/oleacc/CMakeLists.txt b/rostests/winetests/oleacc/CMakeLists.txt new file mode 100644 index 00000000000..ccfc7d2dffc --- /dev/null +++ b/rostests/winetests/oleacc/CMakeLists.txt @@ -0,0 +1,9 @@ + +add_definitions( + -D__ROS_LONG64__ + -D_DLL -D__USE_CRTIMP) + +add_executable(oleacc_winetest main.c testlist.c) +target_link_libraries(oleacc_winetest wine) +set_module_type(oleacc_winetest win32cui) +add_importlibs(oleacc_winetest oleacc msvcrt kernel32 ntdll) diff --git a/rostests/winetests/opengl32/CMakeLists.txt b/rostests/winetests/opengl32/CMakeLists.txt new file mode 100644 index 00000000000..0e5297b889c --- /dev/null +++ b/rostests/winetests/opengl32/CMakeLists.txt @@ -0,0 +1,9 @@ + +add_definitions( + -D__ROS_LONG64__ + -D_DLL -D__USE_CRTIMP) + +add_executable(opengl32_winetest opengl.c testlist.c) +target_link_libraries(opengl32_winetest wine) +set_module_type(opengl32_winetest win32cui) +add_importlibs(opengl32_winetest opengl32 gdi32 user32 msvcrt kernel32 ntdll) diff --git a/rostests/winetests/pdh/CMakeLists.txt b/rostests/winetests/pdh/CMakeLists.txt new file mode 100644 index 00000000000..decf1dce25a --- /dev/null +++ b/rostests/winetests/pdh/CMakeLists.txt @@ -0,0 +1,9 @@ + +add_definitions( + -D__ROS_LONG64__ + -D_DLL -D__USE_CRTIMP) + +add_executable(pdh_winetest pdh.c testlist.c) +target_link_libraries(pdh_winetest wine) +set_module_type(pdh_winetest win32cui) +add_importlibs(pdh_winetest pdh msvcrt kernel32 ntdll) diff --git a/rostests/winetests/powrprof/CMakeLists.txt b/rostests/winetests/powrprof/CMakeLists.txt new file mode 100644 index 00000000000..fec0f4ac793 --- /dev/null +++ b/rostests/winetests/powrprof/CMakeLists.txt @@ -0,0 +1,9 @@ + +add_definitions( + -D__ROS_LONG64__ + -D_DLL -D__USE_CRTIMP + -D_UNICODE -DUNICODE) + +add_executable(powrprof_winetest pwrprof.c testlist.c) +set_module_type(powrprof_winetest win32cui) +add_importlibs(powrprof_winetest advapi32 pwrprof msvcrt kernel32 ntdll) diff --git a/rostests/winetests/psapi/CMakeLists.txt b/rostests/winetests/psapi/CMakeLists.txt new file mode 100644 index 00000000000..e7c048d1b6e --- /dev/null +++ b/rostests/winetests/psapi/CMakeLists.txt @@ -0,0 +1,9 @@ + +add_definitions( + -D__ROS_LONG64__ + -D_DLL -D__USE_CRTIMP) + +add_executable(psapi_winetest psapi_main.c testlist.c) +target_link_libraries(psapi_winetest wine) +set_module_type(psapi_winetest win32cui) +add_importlibs(psapi_winetest psapi msvcrt kernel32 ntdll) diff --git a/rostests/winetests/qmgr/CMakeLists.txt b/rostests/winetests/qmgr/CMakeLists.txt new file mode 100644 index 00000000000..4670f334282 --- /dev/null +++ b/rostests/winetests/qmgr/CMakeLists.txt @@ -0,0 +1,17 @@ + +add_definitions( + -D__ROS_LONG64__ + -D_DLL -D__USE_CRTIMP) + +list(APPEND SOURCE + enum_files.c + enum_jobs.c + file.c + job.c + qmgr.c + testlist.c) + +add_executable(qmgr_winetest ${SOURCE}) +target_link_libraries(qmgr_winetest wine) +set_module_type(qmgr_winetest win32cui) +add_importlibs(qmgr_winetest ole32 shlwapi user32 msvcrt kernel32 ntdll) diff --git a/rostests/winetests/quartz/CMakeLists.txt b/rostests/winetests/quartz/CMakeLists.txt new file mode 100644 index 00000000000..b589596bde0 --- /dev/null +++ b/rostests/winetests/quartz/CMakeLists.txt @@ -0,0 +1,20 @@ + +add_definitions( + -D__ROS_LONG64__ + -D_DLL -D__USE_CRTIMP) + +list(APPEND SOURCE + avisplitter.c + dsoundrender.c + filtergraph.c + filtermapper.c + memallocator.c + misc.c + referenceclock.c + videorenderer.c + testlist.c) + +add_executable(quartz_winetest ${SOURCE}) +target_link_libraries(quartz_winetest wine) +set_module_type(quartz_winetest win32cui) +add_importlibs(quartz_winetest ole32 oleaut32 advapi32 msvcrt kernel32 ntdll) diff --git a/rostests/winetests/rasapi32/CMakeLists.txt b/rostests/winetests/rasapi32/CMakeLists.txt new file mode 100644 index 00000000000..2e840329061 --- /dev/null +++ b/rostests/winetests/rasapi32/CMakeLists.txt @@ -0,0 +1,9 @@ + +add_definitions( + -D__ROS_LONG64__ + -D_DLL -D__USE_CRTIMP) + +add_executable(rasapi32_winetest rasapi.c testlist.c) +target_link_libraries(rasapi32_winetest wine) +set_module_type(rasapi32_winetest win32cui) +add_importlibs(rasapi32_winetest msvcrt kernel32 ntdll) diff --git a/rostests/winetests/riched20/CMakeLists.txt b/rostests/winetests/riched20/CMakeLists.txt new file mode 100644 index 00000000000..ff6b867645b --- /dev/null +++ b/rostests/winetests/riched20/CMakeLists.txt @@ -0,0 +1,15 @@ + +add_definitions( + -D__ROS_LONG64__ + -D_DLL -D__USE_CRTIMP) + +list(APPEND SOURCE + editor.c + richole.c + testlist.c + txtsrv.c) + +add_executable(riched20_winetest ${SOURCE}) +target_link_libraries(riched20_winetest wine uuid) +set_module_type(riched20_winetest win32cui) +add_importlibs(riched20_winetest ole32 oleaut32 user32 gdi32 msvcrt kernel32 ntdll) diff --git a/rostests/winetests/riched32/CMakeLists.txt b/rostests/winetests/riched32/CMakeLists.txt new file mode 100644 index 00000000000..3a473ff426e --- /dev/null +++ b/rostests/winetests/riched32/CMakeLists.txt @@ -0,0 +1,9 @@ + +add_definitions( + -D__ROS_LONG64__ + -D_DLL -D__USE_CRTIMP) + +add_executable(riched32_winetest editor.c testlist.c) +target_link_libraries(riched32_winetest wine) +set_module_type(riched32_winetest win32cui) +add_importlibs(riched32_winetest ole32 user32 msvcrt kernel32 ntdll) diff --git a/rostests/winetests/rsabase/CMakeLists.txt b/rostests/winetests/rsabase/CMakeLists.txt new file mode 100644 index 00000000000..154febdd37a --- /dev/null +++ b/rostests/winetests/rsabase/CMakeLists.txt @@ -0,0 +1,9 @@ + +add_definitions( + -D__ROS_LONG64__ + -D_DLL -D__USE_CRTIMP) + +add_executable(rsabase_winetest rsabase.c testlist.c) +target_link_libraries(rsabase_winetest wine) +set_module_type(rsabase_winetest win32cui) +add_importlibs(rsabase_winetest advapi32 msvcrt kernel32 ntdll) diff --git a/rostests/winetests/rsaenh/CMakeLists.txt b/rostests/winetests/rsaenh/CMakeLists.txt new file mode 100644 index 00000000000..9e621c6af21 --- /dev/null +++ b/rostests/winetests/rsaenh/CMakeLists.txt @@ -0,0 +1,9 @@ + +add_definitions( + -D__ROS_LONG64__ + -D_DLL -D__USE_CRTIMP) + +add_executable(rsaenh_winetest rsaenh.c testlist.c) +target_link_libraries(rsaenh_winetest wine) +set_module_type(rsaenh_winetest win32cui) +add_importlibs(rsaenh_winetest advapi32 msvcrt kernel32 ntdll) diff --git a/rostests/winetests/schannel/CMakeLists.txt b/rostests/winetests/schannel/CMakeLists.txt new file mode 100644 index 00000000000..98ebd0beba5 --- /dev/null +++ b/rostests/winetests/schannel/CMakeLists.txt @@ -0,0 +1,9 @@ + +add_definitions( + -D__ROS_LONG64__ + -D_DLL -D__USE_CRTIMP) + +add_executable(schannel_winetest main.c testlist.c) +target_link_libraries(schannel_winetest wine) +set_module_type(schannel_winetest win32cui) +add_importlibs(schannel_winetest msvcrt kernel32 ntdll) diff --git a/rostests/winetests/secur32/CMakeLists.txt b/rostests/winetests/secur32/CMakeLists.txt new file mode 100644 index 00000000000..3e1b9848db5 --- /dev/null +++ b/rostests/winetests/secur32/CMakeLists.txt @@ -0,0 +1,16 @@ + +add_definitions( + -D__ROS_LONG64__ + -D_DLL -D__USE_CRTIMP) + +list(APPEND SOURCE + main.c + ntlm.c + schannel.c + secur32.c + testlist.c) + +add_executable(secur32_winetest ${SOURCE}) +target_link_libraries(secur32_winetest wine) +set_module_type(secur32_winetest win32cui) +add_importlibs(secur32_winetest advapi32 msvcrt kernel32 ntdll) diff --git a/rostests/winetests/serialui/CMakeLists.txt b/rostests/winetests/serialui/CMakeLists.txt new file mode 100644 index 00000000000..dc3e0ab8fdc --- /dev/null +++ b/rostests/winetests/serialui/CMakeLists.txt @@ -0,0 +1,9 @@ + +add_definitions( + -D__ROS_LONG64__ + -D_DLL -D__USE_CRTIMP) + +add_executable(serialui_winetest confdlg.c testlist.c) +target_link_libraries(serialui_winetest wine) +set_module_type(serialui_winetest win32cui) +add_importlibs(serialui_winetest msvcrt kernel32 ntdll) diff --git a/rostests/winetests/setupapi/CMakeLists.txt b/rostests/winetests/setupapi/CMakeLists.txt new file mode 100644 index 00000000000..ea564d73315 --- /dev/null +++ b/rostests/winetests/setupapi/CMakeLists.txt @@ -0,0 +1,20 @@ + +add_definitions( + -D__ROS_LONG64__ + -D_DLL -D__USE_CRTIMP) + +list(APPEND SOURCE + devclass.c + devinst.c + install.c + misc.c + parser.c + query.c + setupcab.c + stringtable.c + testlist.c) + +add_executable(setupapi_winetest ${SOURCE}) +target_link_libraries(setupapi_winetest wine) +set_module_type(setupapi_winetest win32cui) +add_importlibs(setupapi_winetest advapi32 setupapi user32 msvcrt kernel32 ntdll) diff --git a/rostests/winetests/shdocvw/CMakeLists.txt b/rostests/winetests/shdocvw/CMakeLists.txt new file mode 100644 index 00000000000..c3d56e8a84c --- /dev/null +++ b/rostests/winetests/shdocvw/CMakeLists.txt @@ -0,0 +1,16 @@ + +add_definitions( + -D__ROS_LONG64__ + -D_DLL -D__USE_CRTIMP) + +list(APPEND SOURCE + intshcut.c + shdocvw.c + shortcut.c + webbrowser.c + testlist.c) + +add_executable(shdocvw_winetest ${SOURCE}) +target_link_libraries(shdocvw_winetest wine) +set_module_type(shdocvw_winetest win32cui) +add_importlibs(shdocvw_winetest gdi32 shell32 ole32 oleaut32 user32 advapi32 msvcrt kernel32 ntdll) diff --git a/rostests/winetests/shell32/CMakeLists.txt b/rostests/winetests/shell32/CMakeLists.txt new file mode 100644 index 00000000000..dc26726c4c3 --- /dev/null +++ b/rostests/winetests/shell32/CMakeLists.txt @@ -0,0 +1,29 @@ + +remove_definitions(-D_WIN32_WINNT=0x502) +add_definitions(-D_WIN32_WINNT=0x501) + +add_definitions( + -D__ROS_LONG64__ + -D_DLL -D__USE_CRTIMP) + +list(APPEND SOURCE + appbar.c + autocomplete.c + generated.c + progman_dde.c + shelllink.c + shellpath.c + shlexec.c + shlfileop.c + shlfolder.c + shlview.c + string.c + systray.c + testlist.c + shfldr_special.c + rsrc.rc) + +add_executable(shell32_winetest ${SOURCE}) +target_link_libraries(shell32_winetest wine uuid) +set_module_type(shell32_winetest win32cui) +add_importlibs(shell32_winetest shlwapi gdi32 shell32 ole32 oleaut32 user32 advapi32 msvcrt kernel32 ntdll) diff --git a/rostests/winetests/shlwapi/CMakeLists.txt b/rostests/winetests/shlwapi/CMakeLists.txt new file mode 100644 index 00000000000..e0f8c65d7f7 --- /dev/null +++ b/rostests/winetests/shlwapi/CMakeLists.txt @@ -0,0 +1,23 @@ + +add_definitions( + -D__ROS_LONG64__ + -D_DLL -D__USE_CRTIMP) + +list(APPEND SOURCE + assoc.c + clist.c + clsid.c + generated.c + istream.c + ordinal.c + path.c + shreg.c + string.c + url.c + testlist.c + thread.c) + +add_executable(shlwapi_winetest ${SOURCE}) +target_link_libraries(shlwapi_winetest wine uuid) +set_module_type(shlwapi_winetest win32cui) +add_importlibs(shlwapi_winetest shlwapi ole32 oleaut32 user32 advapi32 msvcrt kernel32 ntdll) diff --git a/rostests/winetests/snmpapi/CMakeLists.txt b/rostests/winetests/snmpapi/CMakeLists.txt new file mode 100644 index 00000000000..acf5b7b9167 --- /dev/null +++ b/rostests/winetests/snmpapi/CMakeLists.txt @@ -0,0 +1,9 @@ + +add_definitions( + -D__ROS_LONG64__ + -D_DLL -D__USE_CRTIMP) + +add_executable(snmpapi_winetest util.c testlist.c) +target_link_libraries(snmpapi_winetest wine) +set_module_type(snmpapi_winetest win32cui) +add_importlibs(snmpapi_winetest snmpapi msvcrt kernel32 ntdll) diff --git a/rostests/winetests/spoolss/CMakeLists.txt b/rostests/winetests/spoolss/CMakeLists.txt new file mode 100644 index 00000000000..fb9bd53d0fc --- /dev/null +++ b/rostests/winetests/spoolss/CMakeLists.txt @@ -0,0 +1,9 @@ + +add_definitions( + -D__ROS_LONG64__ + -D_DLL -D__USE_CRTIMP) + +add_executable(spoolss_winetest spoolss.c testlist.c) +target_link_libraries(spoolss_winetest wine) +set_module_type(spoolss_winetest win32cui) +add_importlibs(spoolss_winetest msvcrt kernel32 ntdll) diff --git a/rostests/winetests/twain_32/CMakeLists.txt b/rostests/winetests/twain_32/CMakeLists.txt new file mode 100644 index 00000000000..57820f56d36 --- /dev/null +++ b/rostests/winetests/twain_32/CMakeLists.txt @@ -0,0 +1,9 @@ + +add_definitions( + -D__ROS_LONG64__ + -D_DLL -D__USE_CRTIMP) + +add_executable(twain_32_winetest dsm.c testlist.c) +target_link_libraries(twain_32_winetest wine) +set_module_type(twain_32_winetest win32cui) +add_importlibs(twain_32_winetest user32 gdi32 msvcrt kernel32 ntdll) diff --git a/rostests/winetests/urlmon/CMakeLists.txt b/rostests/winetests/urlmon/CMakeLists.txt new file mode 100644 index 00000000000..39d596ddb92 --- /dev/null +++ b/rostests/winetests/urlmon/CMakeLists.txt @@ -0,0 +1,19 @@ + +add_definitions( + -D__ROS_LONG64__ + -D_DLL -D__USE_CRTIMP) + +list(APPEND SOURCE + generated.c + misc.c + protocol.c + sec_mgr.c + stream.c + uri.c + url.c + testlist.c) + +add_executable(urlmon_winetest ${SOURCE}) +target_link_libraries(urlmon_winetest wine uuid) +set_module_type(urlmon_winetest win32cui) +add_importlibs(urlmon_winetest urlmon ole32 oleaut32 user32 advapi32 msvcrt kernel32 ntdll) diff --git a/rostests/winetests/user32/CMakeLists.txt b/rostests/winetests/user32/CMakeLists.txt new file mode 100644 index 00000000000..73059b55c65 --- /dev/null +++ b/rostests/winetests/user32/CMakeLists.txt @@ -0,0 +1,37 @@ + +add_definitions( + -D__ROS_LONG64__ + -D_DLL -D__USE_CRTIMP) + +list(APPEND SOURCE + broadcast.c + class.c + clipboard.c + combo.c + cursoricon.c + dce.c + dde.c + dialog.c + edit.c + generated.c + input.c + listbox.c + menu.c + monitor.c + msg.c + resource.c + scroll.c + static.c + sysparams.c + text.c + uitools.c + win.c + winstation.c + wsprintf.c + testlist.c + resource.rc) + +add_executable(user32_winetest ${SOURCE}) +target_link_libraries(user32_winetest wine) +set_module_type(user32_winetest win32cui) +add_importlibs(user32_winetest user32 gdi32 advapi32 msvcrt kernel32 ntdll) diff --git a/rostests/winetests/userenv/CMakeLists.txt b/rostests/winetests/userenv/CMakeLists.txt new file mode 100644 index 00000000000..a08afc1d055 --- /dev/null +++ b/rostests/winetests/userenv/CMakeLists.txt @@ -0,0 +1,9 @@ + +add_definitions( + -D__ROS_LONG64__ + -D_DLL -D__USE_CRTIMP) + +add_executable(userenv_winetest userenv.c testlist.c) +target_link_libraries(userenv_winetest wine) +set_module_type(userenv_winetest win32cui) +add_importlibs(userenv_winetest userenv advapi32 msvcrt kernel32 ntdll) diff --git a/rostests/winetests/usp10/CMakeLists.txt b/rostests/winetests/usp10/CMakeLists.txt new file mode 100644 index 00000000000..c274692767d --- /dev/null +++ b/rostests/winetests/usp10/CMakeLists.txt @@ -0,0 +1,9 @@ + +add_definitions( + -D__ROS_LONG64__ + -D_DLL -D__USE_CRTIMP) + +add_executable(usp10_winetest usp10.c testlist.c) +target_link_libraries(usp10_winetest wine) +set_module_type(usp10_winetest win32cui) +add_importlibs(usp10_winetest usp10 user32 gdi32 msvcrt kernel32 ntdll) diff --git a/rostests/winetests/uxtheme/CMakeLists.txt b/rostests/winetests/uxtheme/CMakeLists.txt new file mode 100644 index 00000000000..927816b6858 --- /dev/null +++ b/rostests/winetests/uxtheme/CMakeLists.txt @@ -0,0 +1,9 @@ + +add_definitions( + -D__ROS_LONG64__ + -D_DLL -D__USE_CRTIMP) + +add_executable(uxtheme_winetest system.c testlist.c) +target_link_libraries(uxtheme_winetest wine) +set_module_type(uxtheme_winetest win32cui) +add_importlibs(uxtheme_winetest user32 msvcrt kernel32 ntdll) diff --git a/rostests/winetests/version/CMakeLists.txt b/rostests/winetests/version/CMakeLists.txt new file mode 100644 index 00000000000..7fe89d620e5 --- /dev/null +++ b/rostests/winetests/version/CMakeLists.txt @@ -0,0 +1,15 @@ + +add_definitions( + -D__ROS_LONG64__ + -D_DLL -D__USE_CRTIMP) + +list(APPEND SOURCE + info.c + install.c + version.rc + testlist.c) + +add_executable(version_winetest ${SOURCE}) +target_link_libraries(version_winetest wine) +set_module_type(version_winetest win32cui) +add_importlibs(version_winetest version msvcrt kernel32 ntdll) diff --git a/rostests/winetests/winhttp/CMakeLists.txt b/rostests/winetests/winhttp/CMakeLists.txt new file mode 100644 index 00000000000..10c744496e7 --- /dev/null +++ b/rostests/winetests/winhttp/CMakeLists.txt @@ -0,0 +1,15 @@ + +add_definitions( + -D__ROS_LONG64__ + -D_DLL -D__USE_CRTIMP) + +list(APPEND SOURCE + notification.c + testlist.c + url.c + winhttp.c) + +add_executable(winhttp_winetest ${SOURCE}) +target_link_libraries(winhttp_winetest wine) +set_module_type(winhttp_winetest win32cui) +add_importlibs(winhttp_winetest winhttp crypt32 ws2_32 advapi32 msvcrt kernel32 ntdll) diff --git a/rostests/winetests/wininet/CMakeLists.txt b/rostests/winetests/wininet/CMakeLists.txt new file mode 100644 index 00000000000..a206c728323 --- /dev/null +++ b/rostests/winetests/wininet/CMakeLists.txt @@ -0,0 +1,18 @@ + +add_definitions( + -D__ROS_LONG64__ + -D_DLL -D__USE_CRTIMP) + +list(APPEND SOURCE + ftp.c + generated.c + http.c + internet.c + url.c + urlcache.c + testlist.c) + +add_executable(wininet_winetest ${SOURCE}) +target_link_libraries(wininet_winetest wine) +set_module_type(wininet_winetest win32cui) +add_importlibs(wininet_winetest wininet ws2_32 advapi32 msvcrt kernel32 ntdll) diff --git a/rostests/winetests/winmm/CMakeLists.txt b/rostests/winetests/winmm/CMakeLists.txt new file mode 100644 index 00000000000..49d42ff2dc1 --- /dev/null +++ b/rostests/winetests/winmm/CMakeLists.txt @@ -0,0 +1,18 @@ + +add_definitions( + -D__ROS_LONG64__ + -D_DLL -D__USE_CRTIMP) + +list(APPEND SOURCE + capture.c + mci.c + mixer.c + mmio.c + timer.c + testlist.c + wave.c) + +add_executable(winmm_winetest ${SOURCE}) +target_link_libraries(winmm_winetest wine dxguid) +set_module_type(winmm_winetest win32cui) +add_importlibs(winmm_winetest winmm user32 msvcrt kernel32 ntdll) diff --git a/rostests/winetests/wintrust/CMakeLists.txt b/rostests/winetests/wintrust/CMakeLists.txt new file mode 100644 index 00000000000..ff291f384cd --- /dev/null +++ b/rostests/winetests/wintrust/CMakeLists.txt @@ -0,0 +1,16 @@ + +add_definitions( + -D__ROS_LONG64__ + -D_DLL -D__USE_CRTIMP) + +list(APPEND SOURCE + asn.c + crypt.c + register.c + softpub.c + testlist.c) + +add_executable(wintrust_winetest ${SOURCE}) +target_link_libraries(wintrust_winetest wine) +set_module_type(wintrust_winetest win32cui) +add_importlibs(wintrust_winetest wintrust crypt32 advapi32 msvcrt kernel32 ntdll) diff --git a/rostests/winetests/wlanapi/CMakeLists.txt b/rostests/winetests/wlanapi/CMakeLists.txt new file mode 100644 index 00000000000..edd97014957 --- /dev/null +++ b/rostests/winetests/wlanapi/CMakeLists.txt @@ -0,0 +1,9 @@ + +add_definitions( + -D__ROS_LONG64__ + -D_DLL -D__USE_CRTIMP) + +add_executable(wlanapi_winetest wlanapi.c testlist.c) +target_link_libraries(wlanapi_winetest wine) +set_module_type(wlanapi_winetest win32cui) +add_importlibs(wlanapi_winetest wlanapi msvcrt kernel32 ntdll) diff --git a/rostests/winetests/wldap32/CMakeLists.txt b/rostests/winetests/wldap32/CMakeLists.txt new file mode 100644 index 00000000000..ff8a85c408e --- /dev/null +++ b/rostests/winetests/wldap32/CMakeLists.txt @@ -0,0 +1,9 @@ + +add_definitions( + -D__ROS_LONG64__ + -D_DLL -D__USE_CRTIMP) + +add_executable(wldap32_winetest parse.c testlist.c) +target_link_libraries(wldap32_winetest wine) +set_module_type(wldap32_winetest win32cui) +add_importlibs(wldap32_winetest wldap32 msvcrt kernel32 ntdll) diff --git a/rostests/winetests/ws2_32/CMakeLists.txt b/rostests/winetests/ws2_32/CMakeLists.txt new file mode 100644 index 00000000000..0f0e71dc7da --- /dev/null +++ b/rostests/winetests/ws2_32/CMakeLists.txt @@ -0,0 +1,9 @@ + +add_definitions( + -D__ROS_LONG64__ + -D_DLL -D__USE_CRTIMP) + +add_executable(ws2_32_winetest protocol.c sock.c testlist.c) +target_link_libraries(ws2_32_winetest wine) +set_module_type(ws2_32_winetest win32cui) +add_importlibs(ws2_32_winetest ws2_32 user32 msvcrt kernel32 ntdll) diff --git a/rostests/winetests/xmllite/CMakeLists.txt b/rostests/winetests/xmllite/CMakeLists.txt new file mode 100644 index 00000000000..6c9ec265d11 --- /dev/null +++ b/rostests/winetests/xmllite/CMakeLists.txt @@ -0,0 +1,9 @@ + +add_definitions( + -D__ROS_LONG64__ + -D_DLL -D__USE_CRTIMP) + +add_executable(xmllite_winetest reader.c testlist.c) +target_link_libraries(xmllite_winetest wine) +set_module_type(xmllite_winetest win32cui) +add_importlibs(xmllite_winetest xmllite ole32 msvcrt kernel32 ntdll) From d6f6afee98cc20f8c0437b8572d448af2c86f9bb Mon Sep 17 00:00:00 2001 From: Johannes Anderwald Date: Tue, 7 Dec 2010 14:35:54 +0000 Subject: [PATCH 031/181] [SHELL32] - Implement copy / paste for files when tree view is present - Don't add shortcuts / executables to recent file list svn path=/trunk/; revision=49969 --- reactos/dll/win32/shell32/shellord.c | 22 ++++- reactos/dll/win32/shell32/shlview.c | 137 ++++++++++++++++++++++++++- 2 files changed, 156 insertions(+), 3 deletions(-) diff --git a/reactos/dll/win32/shell32/shellord.c b/reactos/dll/win32/shell32/shellord.c index 32fd1fd2c38..2559cb6db14 100644 --- a/reactos/dll/win32/shell32/shellord.c +++ b/reactos/dll/win32/shell32/shellord.c @@ -685,6 +685,7 @@ void WINAPI SHAddToRecentDocs (UINT uFlags,LPCVOID pv) CHAR link_dir[MAX_PATH]; CHAR new_lnk_filepath[MAX_PATH]; CHAR new_lnk_name[MAX_PATH]; + CHAR * ext; IMalloc *ppM; LPITEMIDLIST pidl; HWND hwnd = 0; /* FIXME: get real window handle */ @@ -818,10 +819,29 @@ void WINAPI SHAddToRecentDocs (UINT uFlags,LPCVOID pv) } TRACE("full document name %s\n", debugstr_a(doc_name)); + + /* check if file is a shortcut */ + ext = strrchr(doc_name, '.'); + if (!lstrcmpiA(ext, ".lnk")) + { + IShellLinkA * ShellLink; + + IShellLink_ConstructFromFile(NULL, &IID_IShellLinkA, (LPCITEMIDLIST)SHSimpleIDListFromPathA(doc_name), (LPVOID*)&ShellLink); + IShellLinkA_GetPath(ShellLink, doc_name, MAX_PATH, NULL, 0); + + IShellLinkA_Release(ShellLink); + } + + ext = strrchr(doc_name, '.'); + if (!lstrcmpiA(ext, ".exe")) + { + /* executables are not added */ + return; + } + PathStripPathA(doc_name); TRACE("stripped document name %s\n", debugstr_a(doc_name)); - /* *** JOB 1: Update registry for ...\Explorer\RecentDocs list *** */ { /* on input needs: diff --git a/reactos/dll/win32/shell32/shlview.c b/reactos/dll/win32/shell32/shlview.c index c1030254bea..c4c6a07a079 100644 --- a/reactos/dll/win32/shell32/shlview.c +++ b/reactos/dll/win32/shell32/shlview.c @@ -1594,11 +1594,144 @@ static LRESULT ShellView_OnNotify(IShellViewImpl * This, UINT CtlID, LPNMHDR lpn } else if(plvKeyDown->wVKey == 'C' && ctrl) { - FIXME("Need to copy\n"); + if (ShellView_GetSelections(This)) + { + IDataObject * pda; + + if (SUCCEEDED(IShellFolder_GetUIObjectOf(This->pSFParent, This->hWnd, This->cidl, (LPCITEMIDLIST*)This->apidl, &IID_IDataObject,0,(LPVOID *)&pda))) + { + HRESULT hr = OleSetClipboard(pda); + if (FAILED(hr)) + { + WARN("OleSetClipboard failed"); + } + IDataObject_Release(pda); + } + } + break; } else if(plvKeyDown->wVKey == 'V' && ctrl) { - FIXME("Need to paste\n"); + IDataObject * pda; + STGMEDIUM medium; + FORMATETC formatetc; + LPITEMIDLIST * apidl; + LPITEMIDLIST pidl; + IShellFolder *psfFrom = NULL, *psfDesktop, *psfTarget = NULL; + LPIDA lpcida; + ISFHelper *psfhlpdst, *psfhlpsrc; + HRESULT hr; + + hr = OleGetClipboard(&pda); + if (hr != S_OK) + { + ERR("Failed to get clipboard with %lx\n", hr); + return E_FAIL; + } + + InitFormatEtc(formatetc, RegisterClipboardFormatW(CFSTR_SHELLIDLIST), TYMED_HGLOBAL); + hr = IDataObject_GetData(pda,&formatetc,&medium); + + if (FAILED(hr)) + { + ERR("Failed to get clipboard data with %lx\n", hr); + IDataObject_Release(pda); + return E_FAIL; + } + + /* lock the handle */ + lpcida = GlobalLock(medium.u.hGlobal); + if (!lpcida) + { + ERR("failed to lock pidl\n"); + ReleaseStgMedium(&medium); + IDataObject_Release(pda); + return E_FAIL; + } + + /* convert the data into pidl */ + apidl = _ILCopyCidaToaPidl(&pidl, lpcida); + + if (!apidl) + { + ERR("failed to copy pidl\n"); + return E_FAIL; + } + + if (FAILED(SHGetDesktopFolder(&psfDesktop))) + { + ERR("failed to get desktop folder\n"); + SHFree(pidl); + _ILFreeaPidl(apidl, lpcida->cidl); + ReleaseStgMedium(&medium); + IDataObject_Release(pda); + return E_FAIL; + } + + if (_ILIsDesktop(pidl)) + { + /* use desktop shellfolder */ + psfFrom = psfDesktop; + } + else if (FAILED(IShellFolder_BindToObject(psfDesktop, pidl, NULL, &IID_IShellFolder, (LPVOID*)&psfFrom))) + { + ERR("no IShellFolder\n"); + + IShellFolder_Release(psfDesktop); + SHFree(pidl); + _ILFreeaPidl(apidl, lpcida->cidl); + ReleaseStgMedium(&medium); + IDataObject_Release(pda); + + return E_FAIL; + } + + psfTarget = This->pSFParent; + + + /* get source and destination shellfolder */ + if (FAILED(IShellFolder_QueryInterface(psfTarget, &IID_ISFHelper, (LPVOID*)&psfhlpdst))) + { + ERR("no IID_ISFHelper for destination\n"); + + IShellFolder_Release(psfFrom); + IShellFolder_Release(psfTarget); + SHFree(pidl); + _ILFreeaPidl(apidl, lpcida->cidl); + ReleaseStgMedium(&medium); + IDataObject_Release(pda); + + return E_FAIL; + } + + if (FAILED(IShellFolder_QueryInterface(psfFrom, &IID_ISFHelper, (LPVOID*)&psfhlpsrc))) + { + ERR("no IID_ISFHelper for source\n"); + + ISFHelper_Release(psfhlpdst); + IShellFolder_Release(psfFrom); + IShellFolder_Release(psfTarget); + SHFree(pidl); + _ILFreeaPidl(apidl, lpcida->cidl); + ReleaseStgMedium(&medium); + IDataObject_Release(pda); + return E_FAIL; + } + + /* FIXXME + * do we want to perform a copy or move ??? + */ + hr = ISFHelper_CopyItems(psfhlpdst, psfFrom, lpcida->cidl, (LPCITEMIDLIST*)apidl); + + ISFHelper_Release(psfhlpdst); + ISFHelper_Release(psfhlpsrc); + IShellFolder_Release(psfFrom); + SHFree(pidl); + _ILFreeaPidl(apidl, lpcida->cidl); + ReleaseStgMedium(&medium); + IDataObject_Release(pda); + TRACE("paste end hr %x\n", hr); + break; } else FIXME("LVN_KEYDOWN key=0x%08x\n",plvKeyDown->wVKey); From ee4f08ad85b361340a956326ec2cd54217b85fcc Mon Sep 17 00:00:00 2001 From: Johannes Anderwald Date: Tue, 7 Dec 2010 17:23:09 +0000 Subject: [PATCH 032/181] [PORTCLS] - Merge from the audio branch - Fix node property handler - Take advantage of IPinCount interface svn path=/trunk/; revision=49974 --- .../audio/backpln/portcls/propertyhandler.cpp | 59 +++++++++++++++---- .../wdm/audio/backpln/portcls/undoc.cpp | 20 +++---- 2 files changed, 57 insertions(+), 22 deletions(-) diff --git a/reactos/drivers/wdm/audio/backpln/portcls/propertyhandler.cpp b/reactos/drivers/wdm/audio/backpln/portcls/propertyhandler.cpp index 730cd059a13..212826c713c 100644 --- a/reactos/drivers/wdm/audio/backpln/portcls/propertyhandler.cpp +++ b/reactos/drivers/wdm/audio/backpln/portcls/propertyhandler.cpp @@ -14,10 +14,13 @@ HandlePropertyInstances( IN PKSIDENTIFIER Request, IN OUT PVOID Data, IN PSUBDEVICE_DESCRIPTOR Descriptor, - IN BOOL Global) + IN BOOL Global, + IN ISubdevice *SubDevice) { KSPIN_CINSTANCES * Instances; KSP_PIN * Pin = (KSP_PIN*)Request; + ULONG FilterNecessary, FilterCurrent, FilterPossible, GlobalCurrent, GlobalPossible; + NTSTATUS Status; if (Pin->PinId >= Descriptor->Factory.PinDescriptorCount) { @@ -28,12 +31,31 @@ HandlePropertyInstances( Instances = (KSPIN_CINSTANCES*)Data; - if (Global) - Instances->PossibleCount = Descriptor->Factory.Instances[Pin->PinId].MaxGlobalInstanceCount; - else - Instances->PossibleCount = Descriptor->Factory.Instances[Pin->PinId].MaxFilterInstanceCount; + // check if the miniport supports the IPinCount interface + Status = SubDevice->PinCount(Pin->PinId, &FilterNecessary, &FilterCurrent, &FilterPossible, &GlobalCurrent, &GlobalPossible); - Instances->CurrentCount = Descriptor->Factory.Instances[Pin->PinId].CurrentPinInstanceCount; + if (NT_SUCCESS(Status)) + { + if (Global) + { + Instances->PossibleCount = GlobalPossible; + Instances->CurrentCount = GlobalCurrent; + } + else + { + Instances->PossibleCount = FilterPossible; + Instances->CurrentCount = FilterCurrent; + } + } + else + { + if (Global) + Instances->PossibleCount = Descriptor->Factory.Instances[Pin->PinId].MaxGlobalInstanceCount; + else + Instances->PossibleCount = Descriptor->Factory.Instances[Pin->PinId].MaxFilterInstanceCount; + + Instances->CurrentCount = Descriptor->Factory.Instances[Pin->PinId].CurrentPinInstanceCount; + } IoStatus->Information = sizeof(KSPIN_CINSTANCES); IoStatus->Status = STATUS_SUCCESS; @@ -45,10 +67,13 @@ HandleNecessaryPropertyInstances( IN PIO_STATUS_BLOCK IoStatus, IN PKSIDENTIFIER Request, IN OUT PVOID Data, - IN PSUBDEVICE_DESCRIPTOR Descriptor) + IN PSUBDEVICE_DESCRIPTOR Descriptor, + IN ISubdevice *SubDevice) { PULONG Result; KSP_PIN * Pin = (KSP_PIN*)Request; + ULONG FilterNecessary, FilterCurrent, FilterPossible, GlobalCurrent, GlobalPossible; + NTSTATUS Status; if (Pin->PinId >= Descriptor->Factory.PinDescriptorCount) { @@ -58,7 +83,19 @@ HandleNecessaryPropertyInstances( } Result = (PULONG)Data; - *Result = Descriptor->Factory.Instances[Pin->PinId].MinFilterInstanceCount; + + + // check if the miniport supports the IPinCount interface + Status = SubDevice->PinCount(Pin->PinId, &FilterNecessary, &FilterCurrent, &FilterPossible, &GlobalCurrent, &GlobalPossible); + + if (NT_SUCCESS(Status)) + { + *Result = FilterNecessary; + } + else + { + *Result = Descriptor->Factory.Instances[Pin->PinId].MinFilterInstanceCount; + } IoStatus->Information = sizeof(ULONG); IoStatus->Status = STATUS_SUCCESS; @@ -236,13 +273,13 @@ PinPropertyHandler( Status = KsPinPropertyHandler(Irp, Request, Data, Descriptor->Factory.PinDescriptorCount, Descriptor->Factory.KsPinDescriptor); break; case KSPROPERTY_PIN_GLOBALCINSTANCES: - Status = HandlePropertyInstances(&Irp->IoStatus, Request, Data, Descriptor, TRUE); + Status = HandlePropertyInstances(&Irp->IoStatus, Request, Data, Descriptor, TRUE, SubDevice); break; case KSPROPERTY_PIN_CINSTANCES: - Status = HandlePropertyInstances(&Irp->IoStatus, Request, Data, Descriptor, FALSE); + Status = HandlePropertyInstances(&Irp->IoStatus, Request, Data, Descriptor, FALSE, SubDevice); break; case KSPROPERTY_PIN_NECESSARYINSTANCES: - Status = HandleNecessaryPropertyInstances(&Irp->IoStatus, Request, Data, Descriptor); + Status = HandleNecessaryPropertyInstances(&Irp->IoStatus, Request, Data, Descriptor, SubDevice); break; case KSPROPERTY_PIN_DATAINTERSECTION: diff --git a/reactos/drivers/wdm/audio/backpln/portcls/undoc.cpp b/reactos/drivers/wdm/audio/backpln/portcls/undoc.cpp index 08970a8564a..56946f2d212 100644 --- a/reactos/drivers/wdm/audio/backpln/portcls/undoc.cpp +++ b/reactos/drivers/wdm/audio/backpln/portcls/undoc.cpp @@ -165,7 +165,7 @@ PropertyItemDispatch( // get instance / value size InstanceSize = IoStack->Parameters.DeviceIoControl.InputBufferLength; - Instance = Data; + Instance = Request; ValueSize = IoStack->Parameters.DeviceIoControl.OutputBufferLength; // initialize property request @@ -273,17 +273,15 @@ PropertyItemDispatch( if (PropertyRequest->PropertyItem && PropertyRequest->PropertyItem->Handler) { // now call the handler - UNICODE_STRING GuidBuffer; - RtlStringFromGUID(Property->Set, &GuidBuffer); - DPRINT1("Calling Node %lu MajorTarget %p MinorTarget %p PropertySet %S PropertyId %lu PropertyFlags %lx InstanceSize %lu ValueSize %lu Handler %p PropertyRequest %p\n", - PropertyRequest->Node, PropertyRequest->MajorTarget, PropertyRequest->MinorTarget, GuidBuffer.Buffer, Property->Id, Property->Flags, PropertyRequest->InstanceSize, PropertyRequest->ValueSize, - PropertyRequest->PropertyItem->Handler, PropertyRequest); -#if 0 + //UNICODE_STRING GuidBuffer; + //RtlStringFromGUID(Property->Set, &GuidBuffer); + //DPRINT("Calling Node %lu MajorTarget %p MinorTarget %p PropertySet %S PropertyId %lu PropertyFlags %lx InstanceSize %lu ValueSize %lu Handler %p PropertyRequest %p PropertyItemFlags %lx PropertyItemId %lu\n", + // PropertyRequest->Node, PropertyRequest->MajorTarget, PropertyRequest->MinorTarget, GuidBuffer.Buffer, Property->Id, Property->Flags, PropertyRequest->InstanceSize, PropertyRequest->ValueSize, + // PropertyRequest->PropertyItem->Handler, PropertyRequest, PropertyRequest->PropertyItem->Flags, PropertyRequest->PropertyItem->Id); + Status = PropertyRequest->PropertyItem->Handler(PropertyRequest); -#else - Status = STATUS_NOT_FOUND; -#endif - Irp->IoStatus.Information = PropertyRequest->ValueSize; + //DPRINT("Status %lx ValueSize %lu Information %lu\n", Status, PropertyRequest->ValueSize, Irp->IoStatus.Information); + Irp->IoStatus.Information = PropertyRequest->ValueSize; if (Status != STATUS_PENDING) { From 65081666b5006402e0318be77c9c428a8f833e99 Mon Sep 17 00:00:00 2001 From: Eric Kohl Date: Tue, 7 Dec 2010 20:16:45 +0000 Subject: [PATCH 033/181] [NPFS] Enable the driver to open a directory using a relative path name. svn path=/trunk/; revision=49978 --- reactos/drivers/filesystems/npfs/create.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/reactos/drivers/filesystems/npfs/create.c b/reactos/drivers/filesystems/npfs/create.c index dc70991447e..8dac8e9f393 100644 --- a/reactos/drivers/filesystems/npfs/create.c +++ b/reactos/drivers/filesystems/npfs/create.c @@ -221,7 +221,8 @@ NpfsCreate(PDEVICE_OBJECT DeviceObject, } /* Open the root directory */ - if (FileName->Length == 2 && FileName->Buffer[0] == L'\\' && RelatedFileObject == NULL) + if ((FileName->Length == 2 && FileName->Buffer[0] == L'\\' && RelatedFileObject == NULL) || + (FileName->Length == 0 && ((PNPFS_CCB)RelatedFileObject->FsContext2)->Type == CCB_DIRECTORY)) { DPRINT("Open the root directory\n"); From ffe49df99a44f7d46852b3daa6530eb1a59a7b51 Mon Sep 17 00:00:00 2001 From: Aleksey Bragin Date: Tue, 7 Dec 2010 21:49:25 +0000 Subject: [PATCH 034/181] [REGEDIT] - Adam Kachwalla: Fix inconsistent formatting. - Me: to anyone who's gonna try syncing the code with Wine's regedit: Have fun! See issue #5716 for more details. svn path=/trunk/; revision=49980 --- reactos/base/applications/regedit/childwnd.c | 736 +++--- reactos/base/applications/regedit/clb/clb.c | 158 +- reactos/base/applications/regedit/edit.c | 166 +- reactos/base/applications/regedit/find.c | 278 +-- reactos/base/applications/regedit/framewnd.c | 230 +- reactos/base/applications/regedit/hexedit.c | 2194 +++++++++--------- reactos/base/applications/regedit/listview.c | 344 +-- reactos/base/applications/regedit/main.c | 55 +- reactos/base/applications/regedit/main.h | 10 +- reactos/base/applications/regedit/regedit.c | 187 +- reactos/base/applications/regedit/regedit.rc | 14 +- reactos/base/applications/regedit/regproc.c | 439 ++-- reactos/base/applications/regedit/treeview.c | 256 +- 13 files changed, 2665 insertions(+), 2402 deletions(-) diff --git a/reactos/base/applications/regedit/childwnd.c b/reactos/base/applications/regedit/childwnd.c index 56ab005334e..005432c2bbd 100644 --- a/reactos/base/applications/regedit/childwnd.c +++ b/reactos/base/applications/regedit/childwnd.c @@ -49,12 +49,12 @@ static void draw_splitbar(HWND hWnd, int x) if(!SizingPattern) { - const DWORD Pattern[4] = {0x5555AAAA, 0x5555AAAA, 0x5555AAAA, 0x5555AAAA}; - SizingPattern = CreateBitmap(8, 8, 1, 1, Pattern); + const DWORD Pattern[4] = {0x5555AAAA, 0x5555AAAA, 0x5555AAAA, 0x5555AAAA}; + SizingPattern = CreateBitmap(8, 8, 1, 1, Pattern); } if(!SizingBrush) { - SizingBrush = CreatePatternBrush(SizingPattern); + SizingBrush = CreatePatternBrush(SizingPattern); } GetClientRect(hWnd, &rt); rt.left = x - SPLIT_WIDTH/2; @@ -72,7 +72,8 @@ static void ResizeWnd(ChildWnd* pChildWnd, int cx, int cy) const int tHeight = 18; SetRect(&rt, 0, 0, cx, cy); cy = 0; - if (hStatusBar != NULL) { + if (hStatusBar != NULL) + { GetWindowRect(hStatusBar, &rs); cy = rs.bottom - rs.top; } @@ -132,7 +133,8 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) UNREFERENCED_PARAMETER(message); - switch (wID) { + switch (wID) + { /* Parse the menu selections: */ case ID_REGISTRY_EXIT: DestroyWindow(hWnd); @@ -156,15 +158,15 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) if (keyPath == 0 || *keyPath == 0) { - MessageBeep(MB_ICONHAND); - } else - if (DeleteKey(hWnd, hRootKey, keyPath)) - DeleteNode(g_pChildWnd->hTreeWnd, 0); + MessageBeep(MB_ICONHAND); + } + else if (DeleteKey(hWnd, hRootKey, keyPath)) + DeleteNode(g_pChildWnd->hTreeWnd, 0); break; - case ID_TREE_EXPORT: + case ID_TREE_EXPORT: ExportRegistryFile(pChildWnd->hTreeWnd); break; - case ID_EDIT_FIND: + case ID_EDIT_FIND: FindDialog(hWnd); break; case ID_EDIT_COPYKEYNAME: @@ -186,13 +188,13 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) break; default: if ((wID >= ID_TREE_SUGGESTION_MIN) && (wID <= ID_TREE_SUGGESTION_MAX)) - { + { s = Suggestions; while(wID > ID_TREE_SUGGESTION_MIN) { if (*s) s += _tcslen(s) + 1; - wID--; + wID--; } SelectNode(pChildWnd->hTreeWnd, s); break; @@ -210,95 +212,95 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) #define MIN(a,b) ((a < b) ? (a) : (b)) static void SuggestKeys(HKEY hRootKey, LPCTSTR pszKeyPath, LPTSTR pszSuggestions, - size_t iSuggestionsLength) + size_t iSuggestionsLength) { - TCHAR szBuffer[256]; - TCHAR szLastFound[256]; - size_t i; - HKEY hOtherKey, hSubKey; - BOOL bFound; + TCHAR szBuffer[256]; + TCHAR szLastFound[256]; + size_t i; + HKEY hOtherKey, hSubKey; + BOOL bFound; - memset(pszSuggestions, 0, iSuggestionsLength * sizeof(*pszSuggestions)); - iSuggestionsLength--; + memset(pszSuggestions, 0, iSuggestionsLength * sizeof(*pszSuggestions)); + iSuggestionsLength--; - /* Are we a root key in HKEY_CLASSES_ROOT? */ - if ((hRootKey == HKEY_CLASSES_ROOT) && pszKeyPath[0] && !_tcschr(pszKeyPath, TEXT('\\'))) - { - do - { - bFound = FALSE; + /* Are we a root key in HKEY_CLASSES_ROOT? */ + if ((hRootKey == HKEY_CLASSES_ROOT) && pszKeyPath[0] && !_tcschr(pszKeyPath, TEXT('\\'))) + { + do + { + bFound = FALSE; - /* Check default key */ - if (QueryStringValue(hRootKey, pszKeyPath, NULL, - szBuffer, COUNT_OF(szBuffer)) == ERROR_SUCCESS) - { - /* Sanity check this key; it cannot be empty, nor can it be a - * loop back */ - if ((szBuffer[0] != '\0') && _tcsicmp(szBuffer, pszKeyPath)) - { - if (RegOpenKey(hRootKey, szBuffer, &hOtherKey) == ERROR_SUCCESS) - { - lstrcpyn(pszSuggestions, TEXT("HKCR\\"), (int) iSuggestionsLength); - i = _tcslen(pszSuggestions); - pszSuggestions += i; - iSuggestionsLength -= i; + /* Check default key */ + if (QueryStringValue(hRootKey, pszKeyPath, NULL, + szBuffer, COUNT_OF(szBuffer)) == ERROR_SUCCESS) + { + /* Sanity check this key; it cannot be empty, nor can it be a + * loop back */ + if ((szBuffer[0] != '\0') && _tcsicmp(szBuffer, pszKeyPath)) + { + if (RegOpenKey(hRootKey, szBuffer, &hOtherKey) == ERROR_SUCCESS) + { + lstrcpyn(pszSuggestions, TEXT("HKCR\\"), (int) iSuggestionsLength); + i = _tcslen(pszSuggestions); + pszSuggestions += i; + iSuggestionsLength -= i; - lstrcpyn(pszSuggestions, szBuffer, (int) iSuggestionsLength); - i = MIN(_tcslen(pszSuggestions) + 1, iSuggestionsLength); - pszSuggestions += i; - iSuggestionsLength -= i; - RegCloseKey(hOtherKey); + lstrcpyn(pszSuggestions, szBuffer, (int) iSuggestionsLength); + i = MIN(_tcslen(pszSuggestions) + 1, iSuggestionsLength); + pszSuggestions += i; + iSuggestionsLength -= i; + RegCloseKey(hOtherKey); - bFound = TRUE; - _tcscpy(szLastFound, szBuffer); - pszKeyPath = szLastFound; - } - } - } - } - while(bFound && (iSuggestionsLength > 0)); + bFound = TRUE; + _tcscpy(szLastFound, szBuffer); + pszKeyPath = szLastFound; + } + } + } + } + while(bFound && (iSuggestionsLength > 0)); - /* Check CLSID key */ - if (RegOpenKey(hRootKey, pszKeyPath, &hSubKey) == ERROR_SUCCESS) - { - if (QueryStringValue(hSubKey, TEXT("CLSID"), NULL, szBuffer, - COUNT_OF(szBuffer)) == ERROR_SUCCESS) - { - lstrcpyn(pszSuggestions, TEXT("HKCR\\CLSID\\"), (int) iSuggestionsLength); - i = _tcslen(pszSuggestions); - pszSuggestions += i; - iSuggestionsLength -= i; + /* Check CLSID key */ + if (RegOpenKey(hRootKey, pszKeyPath, &hSubKey) == ERROR_SUCCESS) + { + if (QueryStringValue(hSubKey, TEXT("CLSID"), NULL, szBuffer, + COUNT_OF(szBuffer)) == ERROR_SUCCESS) + { + lstrcpyn(pszSuggestions, TEXT("HKCR\\CLSID\\"), (int) iSuggestionsLength); + i = _tcslen(pszSuggestions); + pszSuggestions += i; + iSuggestionsLength -= i; - lstrcpyn(pszSuggestions, szBuffer, (int) iSuggestionsLength); - i = MIN(_tcslen(pszSuggestions) + 1, iSuggestionsLength); - pszSuggestions += i; - iSuggestionsLength -= i; - } - RegCloseKey(hSubKey); - } - } + lstrcpyn(pszSuggestions, szBuffer, (int) iSuggestionsLength); + i = MIN(_tcslen(pszSuggestions) + 1, iSuggestionsLength); + pszSuggestions += i; + iSuggestionsLength -= i; + } + RegCloseKey(hSubKey); + } + } } LRESULT CALLBACK AddressBarProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { WNDPROC oldwndproc; - static TCHAR s_szNode[256]; + static TCHAR s_szNode[256]; oldwndproc = (WNDPROC)(LONG_PTR)GetWindowLongPtr(hwnd, GWL_USERDATA); - switch (uMsg) + switch (uMsg) { - case WM_KEYUP: - if (wParam == VK_RETURN) - { - GetWindowText(hwnd, s_szNode, sizeof(s_szNode) / sizeof(s_szNode[0])); - SelectNode(g_pChildWnd->hTreeWnd, s_szNode); - } - break; - default: - break; - } - return CallWindowProc(oldwndproc, hwnd, uMsg, wParam, lParam); + case WM_KEYUP: + if (wParam == VK_RETURN) + { + GetWindowText(hwnd, s_szNode, sizeof(s_szNode) / sizeof(s_szNode[0])); + SelectNode(g_pChildWnd->hTreeWnd, s_szNode); + } + break; + default: + break; + } + return CallWindowProc(oldwndproc, hwnd, uMsg, wParam, lParam); } /******************************************************************************* @@ -317,10 +319,11 @@ LRESULT CALLBACK ChildWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa BOOL Result; ChildWnd* pChildWnd = g_pChildWnd; - switch (message) { + switch (message) + { case WM_CREATE: { - WNDPROC oldproc; + WNDPROC oldproc; HFONT hFont; TCHAR buffer[MAX_PATH]; /* load "My Computer" string */ @@ -333,12 +336,12 @@ LRESULT CALLBACK ChildWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa pChildWnd->nSplitPos = 250; pChildWnd->hWnd = hWnd; pChildWnd->hAddressBarWnd = CreateWindowEx(WS_EX_CLIENTEDGE, _T("Edit"), NULL, WS_CHILD | WS_VISIBLE | WS_CHILDWINDOW | WS_TABSTOP, - CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, - hWnd, (HMENU)0, hInst, 0); + CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, + hWnd, (HMENU)0, hInst, 0); pChildWnd->hAddressBtnWnd = CreateWindowEx(WS_EX_CLIENTEDGE, _T("Button"), _T("»"), WS_CHILD | WS_VISIBLE | WS_CHILDWINDOW | WS_TABSTOP | BS_DEFPUSHBUTTON, - CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, - hWnd, (HMENU)0, hInst, 0); - pChildWnd->hTreeWnd = CreateTreeView(hWnd, pChildWnd->szPath, (HMENU) TREE_WINDOW); + CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, + hWnd, (HMENU)0, hInst, 0); + pChildWnd->hTreeWnd = CreateTreeView(hWnd, pChildWnd->szPath, (HMENU) TREE_WINDOW); pChildWnd->hListWnd = CreateListView(hWnd, (HMENU) LIST_WINDOW/*, pChildWnd->szPath*/); SetFocus(pChildWnd->hTreeWnd); @@ -355,17 +358,19 @@ LRESULT CALLBACK ChildWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa (WPARAM)hFont, 0); } - /* Subclass the AddressBar */ - oldproc = (WNDPROC)(LONG_PTR)GetWindowLongPtr(pChildWnd->hAddressBarWnd, GWL_WNDPROC); + /* Subclass the AddressBar */ + oldproc = (WNDPROC)(LONG_PTR)GetWindowLongPtr(pChildWnd->hAddressBarWnd, GWL_WNDPROC); SetWindowLongPtr(pChildWnd->hAddressBarWnd, GWL_USERDATA, (DWORD_PTR)oldproc); SetWindowLongPtr(pChildWnd->hAddressBarWnd, GWL_WNDPROC, (DWORD_PTR)AddressBarProc); - break; + break; } case WM_COMMAND: - if(HIWORD(wParam) == BN_CLICKED){ + if(HIWORD(wParam) == BN_CLICKED) + { PostMessage(pChildWnd->hAddressBarWnd, WM_KEYUP, VK_RETURN, 0); } - else if (!_CmdWndProc(hWnd, message, wParam, lParam)) { + else if (!_CmdWndProc(hWnd, message, wParam, lParam)) + { goto def; } break; @@ -373,39 +378,44 @@ LRESULT CALLBACK ChildWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa OnPaint(hWnd); return 0; case WM_SETCURSOR: - if (LOWORD(lParam) == HTCLIENT) { + if (LOWORD(lParam) == HTCLIENT) + { POINT pt; GetCursorPos(&pt); ScreenToClient(hWnd, &pt); - if (pt.x>=pChildWnd->nSplitPos-SPLIT_WIDTH/2 && pt.xnSplitPos+SPLIT_WIDTH/2+1) { + if (pt.x>=pChildWnd->nSplitPos-SPLIT_WIDTH/2 && pt.xnSplitPos+SPLIT_WIDTH/2+1) + { SetCursor(LoadCursor(0, IDC_SIZEWE)); return TRUE; } } goto def; case WM_DESTROY: - DestroyTreeView(); - DestroyListView(pChildWnd->hListWnd); - DestroyMainMenu(); + DestroyTreeView(); + DestroyListView(pChildWnd->hListWnd); + DestroyMainMenu(); HeapFree(GetProcessHeap(), 0, pChildWnd); pChildWnd = NULL; PostQuitMessage(0); break; - case WM_LBUTTONDOWN: { - RECT rt; - int x = (short)LOWORD(lParam); - GetClientRect(hWnd, &rt); - if (x>=pChildWnd->nSplitPos-SPLIT_WIDTH/2 && xnSplitPos+SPLIT_WIDTH/2+1) { - last_split = pChildWnd->nSplitPos; - draw_splitbar(hWnd, last_split); - SetCapture(hWnd); - } - break; + case WM_LBUTTONDOWN: + { + RECT rt; + int x = (short)LOWORD(lParam); + GetClientRect(hWnd, &rt); + if (x>=pChildWnd->nSplitPos-SPLIT_WIDTH/2 && xnSplitPos+SPLIT_WIDTH/2+1) + { + last_split = pChildWnd->nSplitPos; + draw_splitbar(hWnd, last_split); + SetCapture(hWnd); } + break; + } case WM_LBUTTONUP: case WM_RBUTTONDOWN: - if (GetCapture() == hWnd) { + if (GetCapture() == hWnd) + { finish_splitbar(hWnd, LOWORD(lParam)); } break; @@ -417,7 +427,8 @@ LRESULT CALLBACK ChildWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa case WM_KEYDOWN: if (wParam == VK_ESCAPE) - if (GetCapture() == hWnd) { + if (GetCapture() == hWnd) + { RECT rt; draw_splitbar(hWnd, last_split); GetClientRect(hWnd, &rt); @@ -429,42 +440,44 @@ LRESULT CALLBACK ChildWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa break; case WM_MOUSEMOVE: - if (GetCapture() == hWnd) { + if (GetCapture() == hWnd) + { HDC hdc; RECT rt; HGDIOBJ OldObj; int x = LOWORD(lParam); if(!SizingPattern) { - const DWORD Pattern[4] = {0x5555AAAA, 0x5555AAAA, 0x5555AAAA, 0x5555AAAA}; - SizingPattern = CreateBitmap(8, 8, 1, 1, Pattern); + const DWORD Pattern[4] = {0x5555AAAA, 0x5555AAAA, 0x5555AAAA, 0x5555AAAA}; + SizingPattern = CreateBitmap(8, 8, 1, 1, Pattern); } if(!SizingBrush) { - SizingBrush = CreatePatternBrush(SizingPattern); + SizingBrush = CreatePatternBrush(SizingPattern); } GetClientRect(hWnd, &rt); x = (SHORT) min(max(x, SPLIT_MIN), rt.right - SPLIT_MIN); if(last_split != x) { - rt.left = last_split-SPLIT_WIDTH/2; - rt.right = last_split+SPLIT_WIDTH/2+1; - hdc = GetDC(hWnd); - OldObj = SelectObject(hdc, SizingBrush); - PatBlt(hdc, rt.left, rt.top, rt.right - rt.left, rt.bottom - rt.top, PATINVERT); - last_split = x; - rt.left = x-SPLIT_WIDTH/2; - rt.right = x+SPLIT_WIDTH/2+1; - PatBlt(hdc, rt.left, rt.top, rt.right - rt.left, rt.bottom - rt.top, PATINVERT); - SelectObject(hdc, OldObj); - ReleaseDC(hWnd, hdc); + rt.left = last_split-SPLIT_WIDTH/2; + rt.right = last_split+SPLIT_WIDTH/2+1; + hdc = GetDC(hWnd); + OldObj = SelectObject(hdc, SizingBrush); + PatBlt(hdc, rt.left, rt.top, rt.right - rt.left, rt.bottom - rt.top, PATINVERT); + last_split = x; + rt.left = x-SPLIT_WIDTH/2; + rt.right = x+SPLIT_WIDTH/2+1; + PatBlt(hdc, rt.left, rt.top, rt.right - rt.left, rt.bottom - rt.top, PATINVERT); + SelectObject(hdc, OldObj); + ReleaseDC(hWnd, hdc); } } break; case WM_SETFOCUS: - if (pChildWnd != NULL) { + if (pChildWnd != NULL) + { SetFocus(pChildWnd->nFocusPanel? pChildWnd->hListWnd: pChildWnd->hTreeWnd); } break; @@ -473,283 +486,292 @@ LRESULT CALLBACK ChildWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa break; case WM_NOTIFY: - if ((int)wParam == TREE_WINDOW) { - switch (((LPNMHDR)lParam)->code) { + if ((int)wParam == TREE_WINDOW) + { + switch (((LPNMHDR)lParam)->code) + { case TVN_ITEMEXPANDING: return !OnTreeExpanding(pChildWnd->hTreeWnd, (NMTREEVIEW*)lParam); - case TVN_SELCHANGED: { - LPCTSTR keyPath, rootName; - LPTSTR fullPath; - HKEY hRootKey; + case TVN_SELCHANGED: + { + LPCTSTR keyPath, rootName; + LPTSTR fullPath; + HKEY hRootKey; - keyPath = GetItemPath(pChildWnd->hTreeWnd, ((NMTREEVIEW*)lParam)->itemNew.hItem, &hRootKey); - if (keyPath) { - RefreshListView(pChildWnd->hListWnd, hRootKey, keyPath); - rootName = get_root_key_name(hRootKey); - fullPath = HeapAlloc(GetProcessHeap(), 0, (_tcslen(rootName) + 1 + _tcslen(keyPath) + 1) * sizeof(TCHAR)); - if (fullPath) { - /* set (correct) the address bar text */ - if(keyPath[0] != '\0') - _stprintf(fullPath, _T("%s\\%s"), rootName, keyPath); - else - fullPath = _tcscpy(fullPath, rootName); - SendMessage(hStatusBar, SB_SETTEXT, 0, (LPARAM)fullPath); - SendMessage(pChildWnd->hAddressBarWnd, WM_SETTEXT, 0, (LPARAM)fullPath); - HeapFree(GetProcessHeap(), 0, fullPath); - /* disable hive manipulation items temporarily (enable only if necessary) */ - EnableMenuItem(GetSubMenu(hMenuFrame,0), ID_REGISTRY_LOADHIVE, MF_BYCOMMAND | MF_GRAYED); - EnableMenuItem(GetSubMenu(hMenuFrame,0), ID_REGISTRY_UNLOADHIVE, MF_BYCOMMAND | MF_GRAYED); - /* compare the strings to see if we should enable/disable the "Load Hive" menus accordingly */ - if (!(_tcsicmp(rootName, TEXT("HKEY_LOCAL_MACHINE")) && - _tcsicmp(rootName, TEXT("HKEY_USERS")))) + keyPath = GetItemPath(pChildWnd->hTreeWnd, ((NMTREEVIEW*)lParam)->itemNew.hItem, &hRootKey); + if (keyPath) { - // enable the unload menu item if at the root - // otherwise enable the load menu item if there is no slash in keyPath (ie. immediate child selected) - if(keyPath[0] == '\0') - EnableMenuItem(GetSubMenu(hMenuFrame,0), ID_REGISTRY_LOADHIVE, MF_BYCOMMAND | MF_ENABLED); - else if(!_tcschr(keyPath, _T('\\'))) - EnableMenuItem(GetSubMenu(hMenuFrame,0), ID_REGISTRY_UNLOADHIVE, MF_BYCOMMAND | MF_ENABLED); - } + RefreshListView(pChildWnd->hListWnd, hRootKey, keyPath); + rootName = get_root_key_name(hRootKey); + fullPath = HeapAlloc(GetProcessHeap(), 0, (_tcslen(rootName) + 1 + _tcslen(keyPath) + 1) * sizeof(TCHAR)); + if (fullPath) + { + /* set (correct) the address bar text */ + if(keyPath[0] != '\0') + _stprintf(fullPath, _T("%s\\%s"), rootName, keyPath); + else + fullPath = _tcscpy(fullPath, rootName); + SendMessage(hStatusBar, SB_SETTEXT, 0, (LPARAM)fullPath); + SendMessage(pChildWnd->hAddressBarWnd, WM_SETTEXT, 0, (LPARAM)fullPath); + HeapFree(GetProcessHeap(), 0, fullPath); + /* disable hive manipulation items temporarily (enable only if necessary) */ + EnableMenuItem(GetSubMenu(hMenuFrame,0), ID_REGISTRY_LOADHIVE, MF_BYCOMMAND | MF_GRAYED); + EnableMenuItem(GetSubMenu(hMenuFrame,0), ID_REGISTRY_UNLOADHIVE, MF_BYCOMMAND | MF_GRAYED); + /* compare the strings to see if we should enable/disable the "Load Hive" menus accordingly */ + if (!(_tcsicmp(rootName, TEXT("HKEY_LOCAL_MACHINE")) && + _tcsicmp(rootName, TEXT("HKEY_USERS")))) + { + // enable the unload menu item if at the root + // otherwise enable the load menu item if there is no slash in keyPath (ie. immediate child selected) + if(keyPath[0] == '\0') + EnableMenuItem(GetSubMenu(hMenuFrame,0), ID_REGISTRY_LOADHIVE, MF_BYCOMMAND | MF_ENABLED); + else if(!_tcschr(keyPath, _T('\\'))) + EnableMenuItem(GetSubMenu(hMenuFrame,0), ID_REGISTRY_UNLOADHIVE, MF_BYCOMMAND | MF_ENABLED); + } - { - HKEY hKey; - TCHAR szBuffer[MAX_PATH]; - _sntprintf(szBuffer, sizeof(szBuffer) / sizeof(szBuffer[0]), _T("My Computer\\%s\\%s"), rootName, keyPath); + { + HKEY hKey; + TCHAR szBuffer[MAX_PATH]; + _sntprintf(szBuffer, sizeof(szBuffer) / sizeof(szBuffer[0]), _T("My Computer\\%s\\%s"), rootName, keyPath); - if (RegCreateKey(HKEY_CURRENT_USER, - g_szGeneralRegKey, - &hKey) == ERROR_SUCCESS) - { - RegSetValueEx(hKey, _T("LastKey"), 0, REG_SZ, (LPBYTE) szBuffer, (DWORD) _tcslen(szBuffer) * sizeof(szBuffer[0])); - RegCloseKey(hKey); - } - } - } - } + if (RegCreateKey(HKEY_CURRENT_USER, + g_szGeneralRegKey, + &hKey) == ERROR_SUCCESS) + { + RegSetValueEx(hKey, _T("LastKey"), 0, REG_SZ, (LPBYTE) szBuffer, (DWORD) _tcslen(szBuffer) * sizeof(szBuffer[0])); + RegCloseKey(hKey); + } + } + } } + } + break; + case NM_SETFOCUS: + pChildWnd->nFocusPanel = 0; break; - case NM_SETFOCUS: - pChildWnd->nFocusPanel = 0; - break; case TVN_BEGINLABELEDIT: { - LPNMTVDISPINFO ptvdi; - /* cancel label edit for rootkeys */ - ptvdi = (LPNMTVDISPINFO) lParam; + LPNMTVDISPINFO ptvdi; + /* cancel label edit for rootkeys */ + ptvdi = (LPNMTVDISPINFO) lParam; if (!TreeView_GetParent(pChildWnd->hTreeWnd, ptvdi->item.hItem) || - !TreeView_GetParent(pChildWnd->hTreeWnd, TreeView_GetParent(pChildWnd->hTreeWnd, ptvdi->item.hItem))) - return TRUE; - break; - } + !TreeView_GetParent(pChildWnd->hTreeWnd, TreeView_GetParent(pChildWnd->hTreeWnd, ptvdi->item.hItem))) + return TRUE; + break; + } case TVN_ENDLABELEDIT: - { - LPCTSTR keyPath; - HKEY hRootKey; - HKEY hKey = NULL; - LPNMTVDISPINFO ptvdi; - LONG lResult = TRUE; - TCHAR szBuffer[MAX_PATH]; + { + LPCTSTR keyPath; + HKEY hRootKey; + HKEY hKey = NULL; + LPNMTVDISPINFO ptvdi; + LONG lResult = TRUE; + TCHAR szBuffer[MAX_PATH]; - ptvdi = (LPNMTVDISPINFO) lParam; - if (ptvdi->item.pszText) - { + ptvdi = (LPNMTVDISPINFO) lParam; + if (ptvdi->item.pszText) + { keyPath = GetItemPath(pChildWnd->hTreeWnd, TreeView_GetParent(pChildWnd->hTreeWnd, ptvdi->item.hItem), &hRootKey); _sntprintf(szBuffer, sizeof(szBuffer) / sizeof(szBuffer[0]), _T("%s\\%s"), keyPath, ptvdi->item.pszText); keyPath = GetItemPath(pChildWnd->hTreeWnd, ptvdi->item.hItem, &hRootKey); if (RegOpenKeyEx(hRootKey, szBuffer, 0, KEY_READ, &hKey) == ERROR_SUCCESS) { - lResult = FALSE; - RegCloseKey(hKey); - (void)TreeView_EditLabel(pChildWnd->hTreeWnd, ptvdi->item.hItem); + lResult = FALSE; + RegCloseKey(hKey); + (void)TreeView_EditLabel(pChildWnd->hTreeWnd, ptvdi->item.hItem); } else { - if (RenameKey(hRootKey, keyPath, ptvdi->item.pszText) != ERROR_SUCCESS) - lResult = FALSE; + if (RenameKey(hRootKey, keyPath, ptvdi->item.pszText) != ERROR_SUCCESS) + lResult = FALSE; } return lResult; - } } + } default: return 0; } - } else + } + else { if ((int)wParam == LIST_WINDOW) { - switch (((LPNMHDR)lParam)->code) { - case NM_SETFOCUS: - pChildWnd->nFocusPanel = 1; - break; - default: - if(!ListWndNotifyProc(pChildWnd->hListWnd, wParam, lParam, &Result)) - { - goto def; - } - return Result; - break; - } + switch (((LPNMHDR)lParam)->code) + { + case NM_SETFOCUS: + pChildWnd->nFocusPanel = 1; + break; + default: + if(!ListWndNotifyProc(pChildWnd->hListWnd, wParam, lParam, &Result)) + { + goto def; + } + return Result; + break; + } } } break; case WM_CONTEXTMENU: { - POINT pt; - if((HWND)wParam == pChildWnd->hListWnd) - { - int i, cnt; - BOOL IsDefault; - pt.x = (short) LOWORD(lParam); - pt.y = (short) HIWORD(lParam); - cnt = ListView_GetSelectedCount(pChildWnd->hListWnd); - i = ListView_GetNextItem(pChildWnd->hListWnd, -1, LVNI_FOCUSED | LVNI_SELECTED); - if (pt.x == -1 && pt.y == -1) + POINT pt; + if((HWND)wParam == pChildWnd->hListWnd) { - RECT rc; - if (i != -1) + int i, cnt; + BOOL IsDefault; + pt.x = (short) LOWORD(lParam); + pt.y = (short) HIWORD(lParam); + cnt = ListView_GetSelectedCount(pChildWnd->hListWnd); + i = ListView_GetNextItem(pChildWnd->hListWnd, -1, LVNI_FOCUSED | LVNI_SELECTED); + if (pt.x == -1 && pt.y == -1) { - rc.left = LVIR_BOUNDS; - SendMessage(pChildWnd->hListWnd, LVM_GETITEMRECT, i, (LPARAM) &rc); - pt.x = rc.left + 8; - pt.y = rc.top + 8; + RECT rc; + if (i != -1) + { + rc.left = LVIR_BOUNDS; + SendMessage(pChildWnd->hListWnd, LVM_GETITEMRECT, i, (LPARAM) &rc); + pt.x = rc.left + 8; + pt.y = rc.top + 8; + } + else + pt.x = pt.y = 0; + ClientToScreen(pChildWnd->hListWnd, &pt); + } + if(i == -1) + { + TrackPopupMenu(GetSubMenu(hPopupMenus, PM_NEW), TPM_RIGHTBUTTON, pt.x, pt.y, 0, hFrameWnd, NULL); } else - pt.x = pt.y = 0; - ClientToScreen(pChildWnd->hListWnd, &pt); - } - if(i == -1) - { - TrackPopupMenu(GetSubMenu(hPopupMenus, PM_NEW), TPM_RIGHTBUTTON, pt.x, pt.y, 0, hFrameWnd, NULL); - } - else - { - HMENU mnu = GetSubMenu(hPopupMenus, PM_MODIFYVALUE); - SetMenuDefaultItem(mnu, ID_EDIT_MODIFY, MF_BYCOMMAND); - IsDefault = IsDefaultValue(pChildWnd->hListWnd, i); - if(cnt == 1) - EnableMenuItem(mnu, ID_EDIT_RENAME, MF_BYCOMMAND | (IsDefault ? MF_DISABLED | MF_GRAYED : MF_ENABLED)); - else - EnableMenuItem(mnu, ID_EDIT_RENAME, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED); - EnableMenuItem(mnu, ID_EDIT_MODIFY, MF_BYCOMMAND | (cnt == 1 ? MF_ENABLED : MF_DISABLED | MF_GRAYED)); - EnableMenuItem(mnu, ID_EDIT_MODIFY_BIN, MF_BYCOMMAND | (cnt == 1 ? MF_ENABLED : MF_DISABLED | MF_GRAYED)); - - TrackPopupMenu(mnu, TPM_RIGHTBUTTON, pt.x, pt.y, 0, hFrameWnd, NULL); - } - } - else if ((HWND)wParam == pChildWnd->hTreeWnd) - { - TVHITTESTINFO hti; - HMENU hContextMenu; - TVITEM item; - MENUITEMINFO mii; - TCHAR resource[256]; - TCHAR buffer[256]; - LPTSTR s; - LPCTSTR keyPath; - HKEY hRootKey; - int iLastPos; - WORD wID; - - pt.x = (short) LOWORD(lParam); - pt.y = (short) HIWORD(lParam); - - if (pt.x == -1 && pt.y == -1) - { - RECT rc; - hti.hItem = TreeView_GetSelection(pChildWnd->hTreeWnd); - if (hti.hItem != NULL) { - TreeView_GetItemRect(pChildWnd->hTreeWnd, hti.hItem, &rc, TRUE); - pt.x = rc.left + 8; - pt.y = rc.top + 8; - ClientToScreen(pChildWnd->hTreeWnd, &pt); - hti.flags = TVHT_ONITEM; + HMENU mnu = GetSubMenu(hPopupMenus, PM_MODIFYVALUE); + SetMenuDefaultItem(mnu, ID_EDIT_MODIFY, MF_BYCOMMAND); + IsDefault = IsDefaultValue(pChildWnd->hListWnd, i); + if(cnt == 1) + EnableMenuItem(mnu, ID_EDIT_RENAME, MF_BYCOMMAND | (IsDefault ? MF_DISABLED | MF_GRAYED : MF_ENABLED)); + else + EnableMenuItem(mnu, ID_EDIT_RENAME, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED); + EnableMenuItem(mnu, ID_EDIT_MODIFY, MF_BYCOMMAND | (cnt == 1 ? MF_ENABLED : MF_DISABLED | MF_GRAYED)); + EnableMenuItem(mnu, ID_EDIT_MODIFY_BIN, MF_BYCOMMAND | (cnt == 1 ? MF_ENABLED : MF_DISABLED | MF_GRAYED)); + + TrackPopupMenu(mnu, TPM_RIGHTBUTTON, pt.x, pt.y, 0, hFrameWnd, NULL); + } + } + else if ((HWND)wParam == pChildWnd->hTreeWnd) + { + TVHITTESTINFO hti; + HMENU hContextMenu; + TVITEM item; + MENUITEMINFO mii; + TCHAR resource[256]; + TCHAR buffer[256]; + LPTSTR s; + LPCTSTR keyPath; + HKEY hRootKey; + int iLastPos; + WORD wID; + + pt.x = (short) LOWORD(lParam); + pt.y = (short) HIWORD(lParam); + + if (pt.x == -1 && pt.y == -1) + { + RECT rc; + hti.hItem = TreeView_GetSelection(pChildWnd->hTreeWnd); + if (hti.hItem != NULL) + { + TreeView_GetItemRect(pChildWnd->hTreeWnd, hti.hItem, &rc, TRUE); + pt.x = rc.left + 8; + pt.y = rc.top + 8; + ClientToScreen(pChildWnd->hTreeWnd, &pt); + hti.flags = TVHT_ONITEM; + } + else + hti.flags = 0; } else - hti.flags = 0; + { + hti.pt.x = pt.x; + hti.pt.y = pt.y; + ScreenToClient(pChildWnd->hTreeWnd, &hti.pt); + (void)TreeView_HitTest(pChildWnd->hTreeWnd, &hti); + } + + if (hti.flags & TVHT_ONITEM) + { + hContextMenu = GetSubMenu(hPopupMenus, PM_TREECONTEXT); + (void)TreeView_SelectItem(pChildWnd->hTreeWnd, hti.hItem); + + memset(&item, 0, sizeof(item)); + item.mask = TVIF_STATE | TVIF_CHILDREN; + item.hItem = hti.hItem; + (void)TreeView_GetItem(pChildWnd->hTreeWnd, &item); + + /* Set the Expand/Collapse menu item appropriately */ + LoadString(hInst, (item.state & TVIS_EXPANDED) ? IDS_COLLAPSE : IDS_EXPAND, buffer, sizeof(buffer) / sizeof(buffer[0])); + memset(&mii, 0, sizeof(mii)); + mii.cbSize = sizeof(mii); + mii.fMask = MIIM_STRING | MIIM_STATE | MIIM_ID; + mii.fState = (item.cChildren > 0) ? MFS_DEFAULT : MFS_GRAYED; + mii.wID = (item.state & TVIS_EXPANDED) ? ID_TREE_COLLAPSEBRANCH : ID_TREE_EXPANDBRANCH; + mii.dwTypeData = (LPTSTR) buffer; + SetMenuItemInfo(hContextMenu, 0, TRUE, &mii); + + /* Remove any existing suggestions */ + memset(&mii, 0, sizeof(mii)); + mii.cbSize = sizeof(mii); + mii.fMask = MIIM_ID; + GetMenuItemInfo(hContextMenu, GetMenuItemCount(hContextMenu) - 1, TRUE, &mii); + if ((mii.wID >= ID_TREE_SUGGESTION_MIN) && (mii.wID <= ID_TREE_SUGGESTION_MAX)) + { + do + { + iLastPos = GetMenuItemCount(hContextMenu) - 1; + GetMenuItemInfo(hContextMenu, iLastPos, TRUE, &mii); + RemoveMenu(hContextMenu, iLastPos, MF_BYPOSITION); + } + while((mii.wID >= ID_TREE_SUGGESTION_MIN) && (mii.wID <= ID_TREE_SUGGESTION_MAX)); + } + + /* Come up with suggestions */ + keyPath = GetItemPath(pChildWnd->hTreeWnd, NULL, &hRootKey); + SuggestKeys(hRootKey, keyPath, Suggestions, sizeof(Suggestions) / sizeof(Suggestions[0])); + if (Suggestions[0]) + { + AppendMenu(hContextMenu, MF_SEPARATOR, 0, NULL); + + LoadString(hInst, IDS_GOTO_SUGGESTED_KEY, resource, sizeof(resource) / sizeof(resource[0])); + + s = Suggestions; + wID = ID_TREE_SUGGESTION_MIN; + while(*s && (wID <= ID_TREE_SUGGESTION_MAX)) + { + _sntprintf(buffer, sizeof(buffer) / sizeof(buffer[0]), resource, s); + + memset(&mii, 0, sizeof(mii)); + mii.cbSize = sizeof(mii); + mii.fMask = MIIM_STRING | MIIM_ID; + mii.wID = wID++; + mii.dwTypeData = buffer; + InsertMenuItem(hContextMenu, GetMenuItemCount(hContextMenu), TRUE, &mii); + + s += _tcslen(s) + 1; + } + } + TrackPopupMenu(hContextMenu, TPM_RIGHTBUTTON, pt.x, pt.y, 0, pChildWnd->hWnd, NULL); + } } - else - { - hti.pt.x = pt.x; - hti.pt.y = pt.y; - ScreenToClient(pChildWnd->hTreeWnd, &hti.pt); - (void)TreeView_HitTest(pChildWnd->hTreeWnd, &hti); - } - - if (hti.flags & TVHT_ONITEM) - { - hContextMenu = GetSubMenu(hPopupMenus, PM_TREECONTEXT); - (void)TreeView_SelectItem(pChildWnd->hTreeWnd, hti.hItem); - - memset(&item, 0, sizeof(item)); - item.mask = TVIF_STATE | TVIF_CHILDREN; - item.hItem = hti.hItem; - (void)TreeView_GetItem(pChildWnd->hTreeWnd, &item); - - /* Set the Expand/Collapse menu item appropriately */ - LoadString(hInst, (item.state & TVIS_EXPANDED) ? IDS_COLLAPSE : IDS_EXPAND, buffer, sizeof(buffer) / sizeof(buffer[0])); - memset(&mii, 0, sizeof(mii)); - mii.cbSize = sizeof(mii); - mii.fMask = MIIM_STRING | MIIM_STATE | MIIM_ID; - mii.fState = (item.cChildren > 0) ? MFS_DEFAULT : MFS_GRAYED; - mii.wID = (item.state & TVIS_EXPANDED) ? ID_TREE_COLLAPSEBRANCH : ID_TREE_EXPANDBRANCH; - mii.dwTypeData = (LPTSTR) buffer; - SetMenuItemInfo(hContextMenu, 0, TRUE, &mii); - - /* Remove any existing suggestions */ - memset(&mii, 0, sizeof(mii)); - mii.cbSize = sizeof(mii); - mii.fMask = MIIM_ID; - GetMenuItemInfo(hContextMenu, GetMenuItemCount(hContextMenu) - 1, TRUE, &mii); - if ((mii.wID >= ID_TREE_SUGGESTION_MIN) && (mii.wID <= ID_TREE_SUGGESTION_MAX)) - { - do - { - iLastPos = GetMenuItemCount(hContextMenu) - 1; - GetMenuItemInfo(hContextMenu, iLastPos, TRUE, &mii); - RemoveMenu(hContextMenu, iLastPos, MF_BYPOSITION); - } - while((mii.wID >= ID_TREE_SUGGESTION_MIN) && (mii.wID <= ID_TREE_SUGGESTION_MAX)); - } - - /* Come up with suggestions */ - keyPath = GetItemPath(pChildWnd->hTreeWnd, NULL, &hRootKey); - SuggestKeys(hRootKey, keyPath, Suggestions, sizeof(Suggestions) / sizeof(Suggestions[0])); - if (Suggestions[0]) - { - AppendMenu(hContextMenu, MF_SEPARATOR, 0, NULL); - - LoadString(hInst, IDS_GOTO_SUGGESTED_KEY, resource, sizeof(resource) / sizeof(resource[0])); - - s = Suggestions; - wID = ID_TREE_SUGGESTION_MIN; - while(*s && (wID <= ID_TREE_SUGGESTION_MAX)) - { - _sntprintf(buffer, sizeof(buffer) / sizeof(buffer[0]), resource, s); - - memset(&mii, 0, sizeof(mii)); - mii.cbSize = sizeof(mii); - mii.fMask = MIIM_STRING | MIIM_ID; - mii.wID = wID++; - mii.dwTypeData = buffer; - InsertMenuItem(hContextMenu, GetMenuItemCount(hContextMenu), TRUE, &mii); - - s += _tcslen(s) + 1; - } - } - TrackPopupMenu(hContextMenu, TPM_RIGHTBUTTON, pt.x, pt.y, 0, pChildWnd->hWnd, NULL); - } - } - break; + break; } case WM_SIZE: - if (wParam != SIZE_MINIMIZED && pChildWnd != NULL) { + if (wParam != SIZE_MINIMIZED && pChildWnd != NULL) + { ResizeWnd(pChildWnd, LOWORD(lParam), HIWORD(lParam)); } /* fall through */ -default: def: + default: +def: return DefWindowProc(hWnd, message, wParam, lParam); } return 0; diff --git a/reactos/base/applications/regedit/clb/clb.c b/reactos/base/applications/regedit/clb/clb.c index fc9e0052735..29444818c85 100644 --- a/reactos/base/applications/regedit/clb/clb.c +++ b/reactos/base/applications/regedit/clb/clb.c @@ -123,41 +123,41 @@ ClbWndProc(IN HWND hwnd, LRESULT Ret = 0; DPRINT1("ClbWndProc(0x%p, 0x%x, 0x%p, 0x%p)\n", hwnd, uMsg, wParam, lParam); - + PrivData = (PCLB_PRIVATEDATA)GetWindowLongPtr(hwnd, - 0); + 0); if (PrivData == NULL && uMsg != WM_CREATE) { goto HandleDefMsg; } - + switch (uMsg) { - case WM_CREATE: - PrivData = HeapAlloc(GetProcessHeap(), - 0, - sizeof(CLB_PRIVATEDATA)); - if (PrivData == NULL) - { - Ret = (LRESULT)-1; - break; - } - PrivData->hwnd = hwnd; + case WM_CREATE: + PrivData = HeapAlloc(GetProcessHeap(), + 0, + sizeof(CLB_PRIVATEDATA)); + if (PrivData == NULL) + { + Ret = (LRESULT)-1; break; + } + PrivData->hwnd = hwnd; + break; - case WM_DESTROY: - HeapFree(GetProcessHeap(), - 0, - PrivData); - break; + case WM_DESTROY: + HeapFree(GetProcessHeap(), + 0, + PrivData); + break; - default: + default: HandleDefMsg: - Ret = DefWindowProc(hwnd, - uMsg, - wParam, - lParam); - break; + Ret = DefWindowProc(hwnd, + uMsg, + wParam, + lParam); + break; } return Ret; @@ -171,32 +171,32 @@ ClbpStyleDlgProc(IN HWND hwndDlg, IN LPARAM lParam) { INT_PTR Ret = FALSE; - + DPRINT1("ClbpStyleDlgProc(0x%p, 0x%x, 0x%p, 0x%p)\n", hwndDlg, uMsg, wParam, lParam); - + switch (uMsg) { - case WM_COMMAND: - switch (LOWORD(wParam)) - { - case IDOK: - case IDCANCEL: - EndDialog(hwndDlg, - (INT_PTR)LOWORD(wParam)); - break; - } - break; - - case WM_CLOSE: + case WM_COMMAND: + switch (LOWORD(wParam)) + { + case IDOK: + case IDCANCEL: EndDialog(hwndDlg, - IDCANCEL); + (INT_PTR)LOWORD(wParam)); break; + } + break; - case WM_INITDIALOG: - Ret = TRUE; - break; + case WM_CLOSE: + EndDialog(hwndDlg, + IDCANCEL); + break; + + case WM_INITDIALOG: + Ret = TRUE; + break; } - + return Ret; } @@ -230,7 +230,7 @@ CustomControlInfoW(OUT LPCUSTOM_CONTROL_INFO CustomControlInfo OPTIONAL) ClbClassName); CustomControlInfo->Zero1 = 0; - + wcscpy(CustomControlInfo->ClassName2, ClbClassName); @@ -240,15 +240,15 @@ CustomControlInfoW(OUT LPCUSTOM_CONTROL_INFO CustomControlInfo OPTIONAL) CustomControlInfo->Zero2 = 0; CustomControlInfo->Zero3 = 0; - + CustomControlInfo->StylesCount = sizeof(ClbsSupportedStyles) / sizeof(ClbsSupportedStyles[0]); CustomControlInfo->SupportedStyles = ClbsSupportedStyles; - + wcscpy(CustomControlInfo->Columns, ClbColumns); CustomControlInfo->ClbStyleW = ClbStyleW; - + CustomControlInfo->Zero4 = 0; CustomControlInfo->Zero5 = 0; CustomControlInfo->Zero6 = 0; @@ -267,43 +267,43 @@ DllMain(IN HINSTANCE hinstDLL, switch (dwReason) { - case DLL_PROCESS_ATTACH: - { - WNDCLASS ClbWndClass; + case DLL_PROCESS_ATTACH: + { + WNDCLASS ClbWndClass; - hDllInstance = hinstDLL; - - InitCommonControls(); - - /* register the control's window class */ - ClbWndClass.style = CS_GLOBALCLASS | CS_OWNDC; - ClbWndClass.lpfnWndProc = ClbWndProc; - ClbWndClass.cbClsExtra = 0; - ClbWndClass.cbWndExtra = sizeof(PCLB_PRIVATEDATA); - ClbWndClass.hInstance = hinstDLL, - ClbWndClass.hIcon = NULL; - ClbWndClass.hCursor = LoadCursor(NULL, - (LPWSTR)IDC_ARROW); - ClbWndClass.hbrBackground = NULL; - ClbWndClass.lpszMenuName = NULL; - ClbWndClass.lpszClassName = ClbClassName; - - if (!RegisterClass(&ClbWndClass)) - { - Ret = FALSE; - break; - } + hDllInstance = hinstDLL; + + InitCommonControls(); + + /* register the control's window class */ + ClbWndClass.style = CS_GLOBALCLASS | CS_OWNDC; + ClbWndClass.lpfnWndProc = ClbWndProc; + ClbWndClass.cbClsExtra = 0; + ClbWndClass.cbWndExtra = sizeof(PCLB_PRIVATEDATA); + ClbWndClass.hInstance = hinstDLL, + ClbWndClass.hIcon = NULL; + ClbWndClass.hCursor = LoadCursor(NULL, + (LPWSTR)IDC_ARROW); + ClbWndClass.hbrBackground = NULL; + ClbWndClass.lpszMenuName = NULL; + ClbWndClass.lpszClassName = ClbClassName; + + if (!RegisterClass(&ClbWndClass)) + { + Ret = FALSE; break; } + break; + } - case DLL_THREAD_ATTACH: - case DLL_THREAD_DETACH: - break; + case DLL_THREAD_ATTACH: + case DLL_THREAD_DETACH: + break; - case DLL_PROCESS_DETACH: - UnregisterClass(ClbClassName, - hinstDLL); - break; + case DLL_PROCESS_DETACH: + UnregisterClass(ClbClassName, + hinstDLL); + break; } return Ret; } diff --git a/reactos/base/applications/regedit/edit.c b/reactos/base/applications/regedit/edit.c index 85a5bd853e8..ba5e7be4643 100644 --- a/reactos/base/applications/regedit/edit.c +++ b/reactos/base/applications/regedit/edit.c @@ -22,8 +22,8 @@ typedef enum _EDIT_MODE { - EDIT_MODE_DEC, - EDIT_MODE_HEX + EDIT_MODE_DEC, + EDIT_MODE_HEX } EDIT_MODE; @@ -96,17 +96,18 @@ INT_PTR CALLBACK modify_string_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wParam, L UNREFERENCED_PARAMETER(lParam); - switch(uMsg) { + switch(uMsg) + { case WM_INITDIALOG: if(editValueName && _tcscmp(editValueName, _T(""))) { - SetDlgItemText(hwndDlg, IDC_VALUE_NAME, editValueName); + SetDlgItemText(hwndDlg, IDC_VALUE_NAME, editValueName); } else { - TCHAR buffer[255]; - LoadString(hInst, IDS_DEFAULT_VALUE_NAME, buffer, sizeof(buffer)/sizeof(TCHAR)); - SetDlgItemText(hwndDlg, IDC_VALUE_NAME, buffer); + TCHAR buffer[255]; + LoadString(hInst, IDS_DEFAULT_VALUE_NAME, buffer, sizeof(buffer)/sizeof(TCHAR)); + SetDlgItemText(hwndDlg, IDC_VALUE_NAME, buffer); } SetDlgItemText(hwndDlg, IDC_VALUE_DATA, stringValueData); SetFocus(GetDlgItem(hwndDlg, IDC_VALUE_DATA)); @@ -140,8 +141,8 @@ INT_PTR CALLBACK modify_string_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wParam, L } else { - if (stringValueData) - *stringValueData = 0; + if (stringValueData) + *stringValueData = 0; } } EndDialog(hwndDlg, IDOK); @@ -163,17 +164,18 @@ INT_PTR CALLBACK modify_multi_string_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wPa UNREFERENCED_PARAMETER(lParam); - switch(uMsg) { + switch(uMsg) + { case WM_INITDIALOG: if(editValueName && _tcscmp(editValueName, _T(""))) { - SetDlgItemText(hwndDlg, IDC_VALUE_NAME, editValueName); + SetDlgItemText(hwndDlg, IDC_VALUE_NAME, editValueName); } else { - TCHAR buffer[255]; - LoadString(hInst, IDS_DEFAULT_VALUE_NAME, buffer, sizeof(buffer)/sizeof(TCHAR)); - SetDlgItemText(hwndDlg, IDC_VALUE_NAME, buffer); + TCHAR buffer[255]; + LoadString(hInst, IDS_DEFAULT_VALUE_NAME, buffer, sizeof(buffer)/sizeof(TCHAR)); + SetDlgItemText(hwndDlg, IDC_VALUE_NAME, buffer); } SetDlgItemText(hwndDlg, IDC_VALUE_DATA, stringValueData); SetFocus(GetDlgItem(hwndDlg, IDC_VALUE_DATA)); @@ -207,8 +209,8 @@ INT_PTR CALLBACK modify_multi_string_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wPa } else { - if (stringValueData) - *stringValueData = 0; + if (stringValueData) + *stringValueData = 0; } } EndDialog(hwndDlg, IDOK); @@ -274,7 +276,8 @@ INT_PTR CALLBACK modify_dword_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LP UNREFERENCED_PARAMETER(lParam); - switch(uMsg) { + switch(uMsg) + { case WM_INITDIALOG: dwordEditMode = EDIT_MODE_HEX; @@ -290,9 +293,9 @@ INT_PTR CALLBACK modify_dword_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LP } else { - TCHAR buffer[255]; - LoadString(hInst, IDS_DEFAULT_VALUE_NAME, buffer, sizeof(buffer)/sizeof(TCHAR)); - SetDlgItemText(hwndDlg, IDC_VALUE_NAME, buffer); + TCHAR buffer[255]; + LoadString(hInst, IDS_DEFAULT_VALUE_NAME, buffer, sizeof(buffer)/sizeof(TCHAR)); + SetDlgItemText(hwndDlg, IDC_VALUE_NAME, buffer); } CheckRadioButton (hwndDlg, IDC_FORMAT_HEX, IDC_FORMAT_DEC, IDC_FORMAT_HEX); _stprintf (ValueString, _T("%lx"), dwordValueData); @@ -359,8 +362,8 @@ INT_PTR CALLBACK modify_dword_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LP } else { - EndDialog(hwndDlg, IDCANCEL); - return TRUE; + EndDialog(hwndDlg, IDCANCEL); + return TRUE; } } EndDialog(hwndDlg, IDOK); @@ -382,17 +385,18 @@ INT_PTR CALLBACK modify_binary_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wParam, L UNREFERENCED_PARAMETER(lParam); - switch(uMsg) { + switch(uMsg) + { case WM_INITDIALOG: if(editValueName && _tcscmp(editValueName, _T(""))) { - SetDlgItemText(hwndDlg, IDC_VALUE_NAME, editValueName); + SetDlgItemText(hwndDlg, IDC_VALUE_NAME, editValueName); } else { - TCHAR buffer[255]; - LoadString(hInst, IDS_DEFAULT_VALUE_NAME, buffer, sizeof(buffer)/sizeof(TCHAR)); - SetDlgItemText(hwndDlg, IDC_VALUE_NAME, buffer); + TCHAR buffer[255]; + LoadString(hInst, IDS_DEFAULT_VALUE_NAME, buffer, sizeof(buffer)/sizeof(TCHAR)); + SetDlgItemText(hwndDlg, IDC_VALUE_NAME, buffer); } hwndValue = GetDlgItem(hwndDlg, IDC_VALUE_DATA); HexEdit_LoadBuffer(hwndValue, binValueData, valueDataLen); @@ -408,9 +412,9 @@ INT_PTR CALLBACK modify_binary_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wParam, L { len = (UINT) HexEdit_GetBufferSize(hwndValue); if (len > 0 && binValueData) - binValueData = HeapReAlloc(GetProcessHeap(), 0, binValueData, len); + binValueData = HeapReAlloc(GetProcessHeap(), 0, binValueData, len); else - binValueData = HeapAlloc(GetProcessHeap(), 0, len + 1); + binValueData = HeapAlloc(GetProcessHeap(), 0, len + 1); HexEdit_CopyBuffer(hwndValue, binValueData, len); valueDataLen = len; } @@ -439,11 +443,11 @@ BOOL ModifyValue(HWND hwnd, HKEY hKey, LPCTSTR valueName, BOOL EditBin) lRet = RegQueryValueEx(hKey, valueName, 0, &type, 0, &valueDataLen); if (lRet != ERROR_SUCCESS && (!_tcscmp(valueName, _T("")) || valueName == NULL)) { - lRet = ERROR_SUCCESS; /* Allow editing of (Default) values which don't exist */ - type = REG_SZ; - valueDataLen = 0; - stringValueData = NULL; - binValueData = NULL; + lRet = ERROR_SUCCESS; /* Allow editing of (Default) values which don't exist */ + type = REG_SZ; + valueDataLen = 0; + stringValueData = NULL; + binValueData = NULL; } if (lRet != ERROR_SUCCESS) @@ -494,7 +498,7 @@ BOOL ModifyValue(HWND hwnd, HKEY hKey, LPCTSTR valueName, BOOL EditBin) size_t llen, listlen, nl_len; LPTSTR src, lines = NULL; - if (!(stringValueData = HeapAlloc(GetProcessHeap(), 0, valueDataLen))) + if (!(stringValueData = HeapAlloc(GetProcessHeap(), 0, valueDataLen))) { error(hwnd, IDS_TOO_BIG_VALUE, valueDataLen); goto done; @@ -506,7 +510,7 @@ BOOL ModifyValue(HWND hwnd, HKEY hKey, LPCTSTR valueName, BOOL EditBin) goto done; } - /* convert \0 to \r\n */ + /* convert \0 to \r\n */ src = stringValueData; nl_len = _tcslen(_T("\r\n")) * sizeof(TCHAR); listlen = sizeof(TCHAR); @@ -515,12 +519,12 @@ BOOL ModifyValue(HWND hwnd, HKEY hKey, LPCTSTR valueName, BOOL EditBin) { llen = _tcslen(src); if(llen == 0) - break; + break; listlen += (llen * sizeof(TCHAR)) + nl_len; - lines = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, lines, listlen); - _tcscat(lines, src); - _tcscat(lines, _T("\r\n")); - src += llen + 1; + lines = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, lines, listlen); + _tcscat(lines, src); + _tcscat(lines, _T("\r\n")); + src += llen + 1; } HeapFree(GetProcessHeap(), 0, stringValueData); stringValueData = lines; @@ -552,7 +556,7 @@ BOOL ModifyValue(HWND hwnd, HKEY hKey, LPCTSTR valueName, BOOL EditBin) if(nl == src) { EmptyLines = TRUE; - src = nl + c_nl; + src = nl + c_nl; continue; } } @@ -562,7 +566,7 @@ BOOL ModifyValue(HWND hwnd, HKEY hKey, LPCTSTR valueName, BOOL EditBin) } if(linechars > 0) { - buflen += ((linechars + 1) * sizeof(TCHAR)); + buflen += ((linechars + 1) * sizeof(TCHAR)); lines = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, lines, buflen); memcpy((lines + dest), src, linechars * sizeof(TCHAR)); dest += linechars; @@ -581,8 +585,8 @@ BOOL ModifyValue(HWND hwnd, HKEY hKey, LPCTSTR valueName, BOOL EditBin) warning(hwnd, IDS_MULTI_SZ_EMPTY_STRING); } - lRet = RegSetValueEx(hKey, valueName, 0, type, (LPBYTE)lines, (DWORD) buflen); - HeapFree(GetProcessHeap(), 0, lines); + lRet = RegSetValueEx(hKey, valueName, 0, type, (LPBYTE)lines, (DWORD) buflen); + HeapFree(GetProcessHeap(), 0, lines); } else { @@ -614,44 +618,44 @@ BOOL ModifyValue(HWND hwnd, HKEY hKey, LPCTSTR valueName, BOOL EditBin) LPWSTR u_valuename; int len_vname = lstrlen(valueName); - if(len_vname > 0) + if(len_vname > 0) { - if(!(u_valuename = HeapAlloc(GetProcessHeap(), 0, (len_vname + 1) * sizeof(WCHAR)))) - { - error(hwnd, IDS_TOO_BIG_VALUE, len_vname); - goto done; - } - /* convert the ansi value name to an unicode string */ - MultiByteToWideChar(CP_ACP, 0, valueName, -1, u_valuename, len_vname + 1); - valueDataLen *= sizeof(WCHAR); + if(!(u_valuename = HeapAlloc(GetProcessHeap(), 0, (len_vname + 1) * sizeof(WCHAR)))) + { + error(hwnd, IDS_TOO_BIG_VALUE, len_vname); + goto done; + } + /* convert the ansi value name to an unicode string */ + MultiByteToWideChar(CP_ACP, 0, valueName, -1, u_valuename, len_vname + 1); + valueDataLen *= sizeof(WCHAR); } else - u_valuename = L""; + u_valuename = L""; #endif - if(valueDataLen > 0) + if(valueDataLen > 0) { - if(!(binValueData = HeapAlloc(GetProcessHeap(), 0, valueDataLen + 1))) + if(!(binValueData = HeapAlloc(GetProcessHeap(), 0, valueDataLen + 1))) { - error(hwnd, IDS_TOO_BIG_VALUE, valueDataLen); - goto done; + error(hwnd, IDS_TOO_BIG_VALUE, valueDataLen); + goto done; } - /* force to use the unicode version, so editing strings in binary mode is correct */ - lRet = RegQueryValueExW(hKey, + /* force to use the unicode version, so editing strings in binary mode is correct */ + lRet = RegQueryValueExW(hKey, #ifndef UNICODE - u_valuename, + u_valuename, #else - valueName, + valueName, #endif - 0, 0, (LPBYTE)binValueData, &valueDataLen); + 0, 0, (LPBYTE)binValueData, &valueDataLen); if (lRet != ERROR_SUCCESS) { HeapFree(GetProcessHeap(), 0, binValueData); #ifndef UNICODE if(len_vname > 0) - HeapFree(GetProcessHeap(), 0, u_valuename); + HeapFree(GetProcessHeap(), 0, u_valuename); #endif - error(hwnd, IDS_BAD_VALUE, valueName); + error(hwnd, IDS_BAD_VALUE, valueName); goto done; } } @@ -662,22 +666,22 @@ BOOL ModifyValue(HWND hwnd, HKEY hKey, LPCTSTR valueName, BOOL EditBin) if (DialogBox(0, MAKEINTRESOURCE(IDD_EDIT_BIN_DATA), hwnd, modify_binary_dlgproc) == IDOK) { - /* force to use the unicode version, so editing strings in binary mode is correct */ - lRet = RegSetValueExW(hKey, + /* force to use the unicode version, so editing strings in binary mode is correct */ + lRet = RegSetValueExW(hKey, #ifndef UNICODE - u_valuename, + u_valuename, #else - valueName, + valueName, #endif - 0, type, (LPBYTE)binValueData, valueDataLen); + 0, type, (LPBYTE)binValueData, valueDataLen); if (lRet == ERROR_SUCCESS) result = TRUE; } if(binValueData != NULL) - HeapFree(GetProcessHeap(), 0, binValueData); + HeapFree(GetProcessHeap(), 0, binValueData); #ifndef UNICODE if(len_vname > 0) - HeapFree(GetProcessHeap(), 0, u_valuename); + HeapFree(GetProcessHeap(), 0, u_valuename); #endif } else @@ -717,7 +721,7 @@ static LONG CopyKey(HKEY hDestKey, LPCTSTR lpDestSubKey, HKEY hSrcKey, LPCTSTR l /* create the destination subkey */ lResult = RegCreateKeyEx(hDestKey, lpDestSubKey, 0, NULL, 0, KEY_WRITE, NULL, - &hDestSubKey, &dwDisposition); + &hDestSubKey, &dwDisposition); if (lResult) goto done; @@ -786,9 +790,10 @@ BOOL DeleteKey(HWND hwnd, HKEY hKeyRoot, LPCTSTR keyPath) HKEY hKey; lRet = RegOpenKeyEx(hKeyRoot, keyPath, 0, KEY_READ|KEY_SET_VALUE, &hKey); - if (lRet != ERROR_SUCCESS) { - error_code_messagebox(hwnd, lRet); - return FALSE; + if (lRet != ERROR_SUCCESS) + { + error_code_messagebox(hwnd, lRet); + return FALSE; } LoadString(hInst, IDS_QUERY_DELETE_KEY_CONFIRM, caption, sizeof(caption)/sizeof(TCHAR)); @@ -798,9 +803,10 @@ BOOL DeleteKey(HWND hwnd, HKEY hKeyRoot, LPCTSTR keyPath) goto done; lRet = SHDeleteKey(hKeyRoot, keyPath); - if (lRet != ERROR_SUCCESS) { - error(hwnd, IDS_BAD_KEY, keyPath); - goto done; + if (lRet != ERROR_SUCCESS) + { + error(hwnd, IDS_BAD_KEY, keyPath); + goto done; } result = TRUE; diff --git a/reactos/base/applications/regedit/find.c b/reactos/base/applications/regedit/find.c index 5803d25eda4..19b03dac092 100644 --- a/reactos/base/applications/regedit/find.c +++ b/reactos/base/applications/regedit/find.c @@ -101,10 +101,10 @@ CompareData( { if (s_dwFlags & RSF_MATCHCASE) return 2 == CompareString(LOCALE_SYSTEM_DEFAULT, 0, - psz1, cch1, psz2, cch2); + psz1, cch1, psz2, cch2); else - return 2 == CompareString(LOCALE_SYSTEM_DEFAULT, - NORM_IGNORECASE, psz1, cch1, psz2, cch2); + return 2 == CompareString(LOCALE_SYSTEM_DEFAULT, + NORM_IGNORECASE, psz1, cch1, psz2, cch2); } for(i = 0; i <= cch1 - cch2; i++) @@ -112,13 +112,13 @@ CompareData( if (s_dwFlags & RSF_MATCHCASE) { if (2 == CompareString(LOCALE_SYSTEM_DEFAULT, 0, - psz1 + i, cch2, psz2, cch2)) + psz1 + i, cch2, psz2, cch2)) return TRUE; } else { if (2 == CompareString(LOCALE_SYSTEM_DEFAULT, - NORM_IGNORECASE, psz1 + i, cch2, psz2, cch2)) + NORM_IGNORECASE, psz1 + i, cch2, psz2, cch2)) return TRUE; } } @@ -134,7 +134,7 @@ int compare(const void *x, const void *y) } BOOL RegFindRecurse( - HKEY hKey, + HKEY hKey, LPCTSTR pszSubKey, LPCTSTR pszValueName, LPTSTR *ppszFoundSubKey, @@ -162,7 +162,7 @@ BOOL RegFindRecurse( pszValueName = s_empty; lResult = RegQueryInfoKey(hSubKey, NULL, NULL, NULL, NULL, NULL, NULL, - &c, NULL, NULL, NULL, NULL); + &c, NULL, NULL, NULL, NULL); if (lResult != ERROR_SUCCESS) goto err; ppszNames = (LPTSTR *) malloc(c * sizeof(LPTSTR)); @@ -176,7 +176,7 @@ BOOL RegFindRecurse( goto err; s_cbName = MAX_PATH * sizeof(TCHAR); - lResult = RegEnumValue(hSubKey, i, s_szName, &s_cbName, NULL, NULL, + lResult = RegEnumValue(hSubKey, i, s_szName, &s_cbName, NULL, NULL, NULL, &cb); if (lResult == ERROR_NO_MORE_ITEMS) { @@ -206,8 +206,8 @@ BOOL RegFindRecurse( if (!fPast) continue; - if ((s_dwFlags & RSF_LOOKATVALUES) && - CompareName(ppszNames[i], s_szFindWhat)) + if ((s_dwFlags & RSF_LOOKATVALUES) && + CompareName(ppszNames[i], s_szFindWhat)) { *ppszFoundSubKey = _tcsdup(szSubKey); if (ppszNames[i][0] == 0) @@ -218,19 +218,19 @@ BOOL RegFindRecurse( } lResult = RegQueryValueEx(hSubKey, ppszNames[i], NULL, &type, - NULL, &cb); + NULL, &cb); if (lResult != ERROR_SUCCESS) goto err; pb = malloc(cb); if (pb == NULL) goto err; lResult = RegQueryValueEx(hSubKey, ppszNames[i], NULL, &type, - pb, &cb); + pb, &cb); if (lResult != ERROR_SUCCESS) goto err; - if ((s_dwFlags & RSF_LOOKATDATA) && - CompareData(type, (LPTSTR) pb, s_szFindWhat)) + if ((s_dwFlags & RSF_LOOKATDATA) && + CompareData(type, (LPTSTR) pb, s_szFindWhat)) { *ppszFoundSubKey = _tcsdup(szSubKey); if (ppszNames[i][0] == 0) @@ -252,7 +252,7 @@ BOOL RegFindRecurse( ppszNames = NULL; lResult = RegQueryInfoKey(hSubKey, NULL, NULL, NULL, &c, NULL, NULL, - NULL, NULL, NULL, NULL, NULL); + NULL, NULL, NULL, NULL, NULL); if (lResult != ERROR_SUCCESS) goto err; ppszNames = (LPTSTR *) malloc(c * sizeof(LPTSTR)); @@ -266,7 +266,7 @@ BOOL RegFindRecurse( goto err; s_cbName = MAX_PATH * sizeof(TCHAR); - lResult = RegEnumKeyEx(hSubKey, i, s_szName, &s_cbName, NULL, NULL, + lResult = RegEnumKeyEx(hSubKey, i, s_szName, &s_cbName, NULL, NULL, NULL, NULL); if (lResult == ERROR_NO_MORE_ITEMS) { @@ -289,11 +289,11 @@ BOOL RegFindRecurse( goto err; if ((s_dwFlags & RSF_LOOKATKEYS) && - CompareName(ppszNames[i], s_szFindWhat)) + CompareName(ppszNames[i], s_szFindWhat)) { *ppszFoundSubKey = malloc( - (lstrlen(szSubKey) + lstrlen(ppszNames[i]) + 2) * - sizeof(TCHAR)); + (lstrlen(szSubKey) + lstrlen(ppszNames[i]) + 2) * + sizeof(TCHAR)); if (*ppszFoundSubKey == NULL) goto err; if (szSubKey[0]) @@ -313,7 +313,7 @@ BOOL RegFindRecurse( { LPTSTR psz = *ppszFoundSubKey; *ppszFoundSubKey = malloc( - (lstrlen(szSubKey) + lstrlen(psz) + 2) * sizeof(TCHAR)); + (lstrlen(szSubKey) + lstrlen(psz) + 2) * sizeof(TCHAR)); if (*ppszFoundSubKey == NULL) goto err; if (szSubKey[0]) @@ -352,7 +352,7 @@ success: } BOOL RegFindWalk( - HKEY * phKey, + HKEY * phKey, LPCTSTR pszSubKey, LPCTSTR pszValueName, LPTSTR *ppszFoundSubKey, @@ -393,13 +393,13 @@ BOOL RegFindWalk( lstrcpyn(szKeyName, pch + 1, MAX_PATH); *pch = 0; lResult = RegOpenKeyEx(hBaseKey, szSubKey, 0, KEY_ALL_ACCESS, - &hSubKey); + &hSubKey); if (lResult != ERROR_SUCCESS) return FALSE; } lResult = RegQueryInfoKey(hSubKey, NULL, NULL, NULL, &c, NULL, NULL, - NULL, NULL, NULL, NULL, NULL); + NULL, NULL, NULL, NULL, NULL); if (lResult != ERROR_SUCCESS) goto err; @@ -415,7 +415,7 @@ BOOL RegFindWalk( s_cbName = MAX_PATH * sizeof(TCHAR); lResult = RegEnumKeyExW(hSubKey, i, s_szName, &s_cbName, - NULL, NULL, NULL, NULL); + NULL, NULL, NULL, NULL); if (lResult == ERROR_NO_MORE_ITEMS) { c = i; @@ -443,11 +443,11 @@ BOOL RegFindWalk( continue; if ((s_dwFlags & RSF_LOOKATKEYS) && - CompareName(ppszNames[i], s_szFindWhat)) + CompareName(ppszNames[i], s_szFindWhat)) { *ppszFoundSubKey = malloc( - (lstrlen(szSubKey) + lstrlen(ppszNames[i]) + 2) * - sizeof(TCHAR)); + (lstrlen(szSubKey) + lstrlen(ppszNames[i]) + 2) * + sizeof(TCHAR)); if (*ppszFoundSubKey == NULL) goto err; if (szSubKey[0]) @@ -462,13 +462,13 @@ BOOL RegFindWalk( goto success; } - if (RegFindRecurse(hSubKey, ppszNames[i], NULL, + if (RegFindRecurse(hSubKey, ppszNames[i], NULL, ppszFoundSubKey, ppszFoundValueName)) { LPTSTR psz = *ppszFoundSubKey; *ppszFoundSubKey = malloc( - (lstrlen(szSubKey) + lstrlen(psz) + 2) * - sizeof(TCHAR)); + (lstrlen(szSubKey) + lstrlen(psz) + 2) * + sizeof(TCHAR)); if (*ppszFoundSubKey == NULL) goto err; if (szSubKey[0]) @@ -605,23 +605,23 @@ static INT_PTR CALLBACK AbortFindDialogProc(HWND hDlg, UINT uMsg, WPARAM wParam, switch(uMsg) { - case WM_CLOSE: - s_bAbort = TRUE; - break; + case WM_CLOSE: + s_bAbort = TRUE; + break; - case WM_COMMAND: - switch(HIWORD(wParam)) + case WM_COMMAND: + switch(HIWORD(wParam)) + { + case BN_CLICKED: + switch(LOWORD(wParam)) { - case BN_CLICKED: - switch(LOWORD(wParam)) - { - case IDCANCEL: - s_bAbort = TRUE; - break; - } - break; + case IDCANCEL: + s_bAbort = TRUE; + break; } break; + } + break; } return 0; } @@ -652,7 +652,7 @@ BOOL FindNext(HWND hWnd) /* Create abort find dialog */ s_hwndAbortDialog = CreateDialog(GetModuleHandle(NULL), - MAKEINTRESOURCE(IDD_FINDING), hWnd, AbortFindDialogProc); + MAKEINTRESOURCE(IDD_FINDING), hWnd, AbortFindDialogProc); if (s_hwndAbortDialog) { ShowWindow(s_hwndAbortDialog, SW_SHOW); @@ -667,7 +667,7 @@ BOOL FindNext(HWND hWnd) EnableWindow(g_pChildWnd->hListWnd, FALSE); EnableWindow(g_pChildWnd->hAddressBarWnd, FALSE); - fSuccess = RegFindWalk(&hKeyRoot, pszKeyPath, pszValueName, + fSuccess = RegFindWalk(&hKeyRoot, pszKeyPath, pszValueName, &pszFoundSubKey, &pszFoundValueName); EnableWindow(hFrameWnd, TRUE); @@ -703,107 +703,107 @@ static INT_PTR CALLBACK FindDialogProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPAR switch(uMsg) { - case WM_INITDIALOG: - dwFlags = GetFindFlags(); + case WM_INITDIALOG: + dwFlags = GetFindFlags(); - hControl = GetDlgItem(hDlg, IDC_LOOKAT_KEYS); - if (hControl) - SendMessage(hControl, BM_SETCHECK, (dwFlags & RSF_LOOKATKEYS) ? TRUE : FALSE, 0); + hControl = GetDlgItem(hDlg, IDC_LOOKAT_KEYS); + if (hControl) + SendMessage(hControl, BM_SETCHECK, (dwFlags & RSF_LOOKATKEYS) ? TRUE : FALSE, 0); - hControl = GetDlgItem(hDlg, IDC_LOOKAT_VALUES); - if (hControl) - SendMessage(hControl, BM_SETCHECK, (dwFlags & RSF_LOOKATVALUES) ? TRUE : FALSE, 0); + hControl = GetDlgItem(hDlg, IDC_LOOKAT_VALUES); + if (hControl) + SendMessage(hControl, BM_SETCHECK, (dwFlags & RSF_LOOKATVALUES) ? TRUE : FALSE, 0); - hControl = GetDlgItem(hDlg, IDC_LOOKAT_DATA); - if (hControl) - SendMessage(hControl, BM_SETCHECK, (dwFlags & RSF_LOOKATDATA) ? TRUE : FALSE, 0); + hControl = GetDlgItem(hDlg, IDC_LOOKAT_DATA); + if (hControl) + SendMessage(hControl, BM_SETCHECK, (dwFlags & RSF_LOOKATDATA) ? TRUE : FALSE, 0); - /* Match whole string */ - hControl = GetDlgItem(hDlg, IDC_MATCHSTRING); - if (hControl) - SendMessage(hControl, BM_SETCHECK, (dwFlags & RSF_WHOLESTRING) ? TRUE : FALSE, 0); + /* Match whole string */ + hControl = GetDlgItem(hDlg, IDC_MATCHSTRING); + if (hControl) + SendMessage(hControl, BM_SETCHECK, (dwFlags & RSF_WHOLESTRING) ? TRUE : FALSE, 0); - /* Case sensitivity */ - hControl = GetDlgItem(hDlg, IDC_MATCHCASE); - if (hControl) - SendMessage(hControl, BM_SETCHECK, (dwFlags & RSF_MATCHCASE) ? TRUE : FALSE, 0); + /* Case sensitivity */ + hControl = GetDlgItem(hDlg, IDC_MATCHCASE); + if (hControl) + SendMessage(hControl, BM_SETCHECK, (dwFlags & RSF_MATCHCASE) ? TRUE : FALSE, 0); - hControl = GetDlgItem(hDlg, IDC_FINDWHAT); - if (hControl) + hControl = GetDlgItem(hDlg, IDC_FINDWHAT); + if (hControl) + { + SetWindowText(hControl, s_szSavedFindValue); + SetFocus(hControl); + SendMessage(hControl, EM_SETSEL, 0, -1); + } + break; + + case WM_CLOSE: + EndDialog(hDlg, 0); + break; + + case WM_COMMAND: + switch(HIWORD(wParam)) + { + case BN_CLICKED: + switch(LOWORD(wParam)) { - SetWindowText(hControl, s_szSavedFindValue); - SetFocus(hControl); - SendMessage(hControl, EM_SETSEL, 0, -1); + case IDOK: + dwFlags = 0; + + hControl = GetDlgItem(hDlg, IDC_LOOKAT_KEYS); + if (hControl && (SendMessage(hControl, BM_GETCHECK, 0, 0) == BST_CHECKED)) + dwFlags |= RSF_LOOKATKEYS; + + hControl = GetDlgItem(hDlg, IDC_LOOKAT_VALUES); + if (hControl && (SendMessage(hControl, BM_GETCHECK, 0, 0) == BST_CHECKED)) + dwFlags |= RSF_LOOKATVALUES; + + hControl = GetDlgItem(hDlg, IDC_LOOKAT_DATA); + if (hControl && (SendMessage(hControl, BM_GETCHECK, 0, 0) == BST_CHECKED)) + dwFlags |= RSF_LOOKATDATA; + + hControl = GetDlgItem(hDlg, IDC_MATCHSTRING); + if (hControl && (SendMessage(hControl, BM_GETCHECK, 0, 0) == BST_CHECKED)) + dwFlags |= RSF_WHOLESTRING; + + hControl = GetDlgItem(hDlg, IDC_MATCHCASE); + if (hControl && (SendMessage(hControl, BM_GETCHECK, 0, 0) == BST_CHECKED)) + dwFlags |= RSF_MATCHCASE; + + SetFindFlags(dwFlags); + + hControl = GetDlgItem(hDlg, IDC_FINDWHAT); + if (hControl) + GetWindowText(hControl, s_szFindWhat, sizeof(s_szFindWhat) / sizeof(s_szFindWhat[0])); + EndDialog(hDlg, 1); + break; + + case IDCANCEL: + EndDialog(hDlg, 0); + break; } break; - case WM_CLOSE: - EndDialog(hDlg, 0); - break; - - case WM_COMMAND: - switch(HIWORD(wParam)) + case EN_CHANGE: + switch(LOWORD(wParam)) { - case BN_CLICKED: - switch(LOWORD(wParam)) - { - case IDOK: - dwFlags = 0; - - hControl = GetDlgItem(hDlg, IDC_LOOKAT_KEYS); - if (hControl && (SendMessage(hControl, BM_GETCHECK, 0, 0) == BST_CHECKED)) - dwFlags |= RSF_LOOKATKEYS; - - hControl = GetDlgItem(hDlg, IDC_LOOKAT_VALUES); - if (hControl && (SendMessage(hControl, BM_GETCHECK, 0, 0) == BST_CHECKED)) - dwFlags |= RSF_LOOKATVALUES; - - hControl = GetDlgItem(hDlg, IDC_LOOKAT_DATA); - if (hControl && (SendMessage(hControl, BM_GETCHECK, 0, 0) == BST_CHECKED)) - dwFlags |= RSF_LOOKATDATA; - - hControl = GetDlgItem(hDlg, IDC_MATCHSTRING); - if (hControl && (SendMessage(hControl, BM_GETCHECK, 0, 0) == BST_CHECKED)) - dwFlags |= RSF_WHOLESTRING; - - hControl = GetDlgItem(hDlg, IDC_MATCHCASE); - if (hControl && (SendMessage(hControl, BM_GETCHECK, 0, 0) == BST_CHECKED)) - dwFlags |= RSF_MATCHCASE; - - SetFindFlags(dwFlags); - - hControl = GetDlgItem(hDlg, IDC_FINDWHAT); - if (hControl) - GetWindowText(hControl, s_szFindWhat, sizeof(s_szFindWhat) / sizeof(s_szFindWhat[0])); - EndDialog(hDlg, 1); - break; - - case IDCANCEL: - EndDialog(hDlg, 0); - break; - } - break; - - case EN_CHANGE: - switch(LOWORD(wParam)) - { - case IDC_FINDWHAT: - GetWindowText((HWND) lParam, s_szSavedFindValue, sizeof(s_szSavedFindValue) / sizeof(s_szSavedFindValue[0])); - hControl = GetDlgItem(hDlg, IDOK); - if (hControl) - { - lStyle = GetWindowLongPtr(hControl, GWL_STYLE); - if (s_szSavedFindValue[0]) - lStyle &= ~WS_DISABLED; - else - lStyle |= WS_DISABLED; - SetWindowLongPtr(hControl, GWL_STYLE, lStyle); - RedrawWindow(hControl, NULL, NULL, RDW_INVALIDATE); - } - break; - } + case IDC_FINDWHAT: + GetWindowText((HWND) lParam, s_szSavedFindValue, sizeof(s_szSavedFindValue) / sizeof(s_szSavedFindValue[0])); + hControl = GetDlgItem(hDlg, IDOK); + if (hControl) + { + lStyle = GetWindowLongPtr(hControl, GWL_STYLE); + if (s_szSavedFindValue[0]) + lStyle &= ~WS_DISABLED; + else + lStyle |= WS_DISABLED; + SetWindowLongPtr(hControl, GWL_STYLE, lStyle); + RedrawWindow(hControl, NULL, NULL, RDW_INVALIDATE); + } + break; } - break; + } + break; } return iResult; } @@ -811,15 +811,15 @@ static INT_PTR CALLBACK FindDialogProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPAR void FindDialog(HWND hWnd) { if (DialogBoxParam(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_FIND), - hWnd, FindDialogProc, 0) != 0) + hWnd, FindDialogProc, 0) != 0) { if (!FindNext(hWnd)) { - TCHAR msg[128], caption[128]; + TCHAR msg[128], caption[128]; - LoadString(hInst, IDS_FINISHEDFIND, msg, sizeof(msg)/sizeof(TCHAR)); - LoadString(hInst, IDS_APP_TITLE, caption, sizeof(caption)/sizeof(TCHAR)); - MessageBox(0, msg, caption, MB_ICONINFORMATION); + LoadString(hInst, IDS_FINISHEDFIND, msg, sizeof(msg)/sizeof(TCHAR)); + LoadString(hInst, IDS_APP_TITLE, caption, sizeof(caption)/sizeof(TCHAR)); + MessageBox(0, msg, caption, MB_ICONINFORMATION); } } } diff --git a/reactos/base/applications/regedit/framewnd.c b/reactos/base/applications/regedit/framewnd.c index aa3a649f5da..baccec07d5d 100644 --- a/reactos/base/applications/regedit/framewnd.c +++ b/reactos/base/applications/regedit/framewnd.c @@ -45,7 +45,8 @@ static void resize_frame_rect(HWND hWnd, PRECT prect) prect->bottom -= rt.bottom+3; } */ - if (IsWindowVisible(hStatusBar)) { + if (IsWindowVisible(hStatusBar)) + { SetupStatusBar(hWnd, TRUE); GetClientRect(hStatusBar, &rt); prect->bottom -= rt.bottom; @@ -141,12 +142,15 @@ static void OnMenuSelect(HWND hWnd, UINT nItemID, UINT nFlags, HMENU hSysMenu) TCHAR str[100]; _tcscpy(str, _T("")); - if (nFlags & MF_POPUP) { - if (hSysMenu != GetMenu(hWnd)) { + if (nFlags & MF_POPUP) + { + if (hSysMenu != GetMenu(hWnd)) + { if (nItemID == 2) nItemID = 5; } } - if (LoadString(hInst, nItemID, str, 100)) { + if (LoadString(hInst, nItemID, str, 100)) + { /* load appropriate string*/ LPTSTR lpsz = str; /* first newline terminates actual string*/ @@ -171,8 +175,8 @@ void SetupStatusBar(HWND hWnd, BOOL bResize) void UpdateStatusBar(void) { - NMHDR nmhdr; - ZeroMemory(&nmhdr, sizeof(NMHDR)); + NMHDR nmhdr; + ZeroMemory(&nmhdr, sizeof(NMHDR)); nmhdr.code = TVN_SELCHANGED; SendMessage(g_pChildWnd->hWnd, WM_NOTIFY, (WPARAM)TREE_WINDOW, (LPARAM)&nmhdr); } @@ -191,7 +195,8 @@ static BOOL CheckCommDlgError(HWND hWnd) { DWORD dwErrorCode = CommDlgExtendedError(); UNREFERENCED_PARAMETER(hWnd); - switch (dwErrorCode) { + switch (dwErrorCode) + { case CDERR_DIALOGFAILURE: break; case CDERR_FINDRESFAILURE: @@ -233,24 +238,24 @@ TCHAR FileTitleBuffer[_MAX_PATH]; typedef struct { - UINT DisplayID; - UINT FilterID; + UINT DisplayID; + UINT FilterID; } FILTERPAIR, *PFILTERPAIR; void BuildFilterStrings(TCHAR *Filter, PFILTERPAIR Pairs, int PairCount) { - int i, c; + int i, c; - c = 0; - for(i = 0; i < PairCount; i++) - { - c += LoadString(hInst, Pairs[i].DisplayID, &Filter[c], 255 * sizeof(TCHAR)); + c = 0; + for(i = 0; i < PairCount; i++) + { + c += LoadString(hInst, Pairs[i].DisplayID, &Filter[c], 255 * sizeof(TCHAR)); + Filter[++c] = '\0'; + c += LoadString(hInst, Pairs[i].FilterID, &Filter[c], 255 * sizeof(TCHAR)); + Filter[++c] = '\0'; + } Filter[++c] = '\0'; - c += LoadString(hInst, Pairs[i].FilterID, &Filter[c], 255 * sizeof(TCHAR)); - Filter[++c] = '\0'; - } - Filter[++c] = '\0'; } static BOOL InitOpenFileName(HWND hWnd, OPENFILENAME* pofn) @@ -288,18 +293,18 @@ static INT_PTR CALLBACK LoadHive_KeyNameInHookProc(HWND hWndDlg, UINT uMsg, WPAR static INT sLength = 0; switch(uMsg) { - case WM_INITDIALOG: + case WM_INITDIALOG: sKey = (LPTSTR)lParam; sLength = 128; /* FIXME: Ugly hack! */ - case WM_COMMAND: + case WM_COMMAND: switch(LOWORD(wParam)) { - case IDOK: + case IDOK: if(GetDlgItemText(hWndDlg, IDC_EDIT_KEY, sKey, sLength)) return EndDialog(hWndDlg, -1); else return EndDialog(hWndDlg, 0); - case IDCANCEL: + case IDCANCEL: return EndDialog(hWndDlg, 0); } break; @@ -349,7 +354,9 @@ static BOOL LoadHive(HWND hWnd) return FALSE; } } - } else { + } + else + { CheckCommDlgError(hWnd); } return TRUE; @@ -393,9 +400,11 @@ static BOOL ImportRegistryFile(HWND hWnd) ofn.lpstrTitle = Caption; ofn.Flags |= OFN_ENABLESIZING; /* ofn.lCustData = ;*/ - if (GetOpenFileName(&ofn)) { + if (GetOpenFileName(&ofn)) + { FILE *fp = _wfopen(ofn.lpstrFile, L"r"); - if (fp == NULL || !import_registry_file(fp)) { + if (fp == NULL || !import_registry_file(fp)) + { LPSTR p = GetMultiByteString(ofn.lpstrFile); fprintf(stderr, "Can't open file \"%s\"\n", p); HeapFree(GetProcessHeap(), 0, p); @@ -404,7 +413,9 @@ static BOOL ImportRegistryFile(HWND hWnd) return FALSE; } fclose(fp); - } else { + } + else + { CheckCommDlgError(hWnd); } @@ -427,8 +438,9 @@ static UINT_PTR CALLBACK ExportRegistryFile_OFNHookProc(HWND hdlg, UINT uiMsg, W UNREFERENCED_PARAMETER(wParam); - switch(uiMsg) { - case WM_INITDIALOG: + switch(uiMsg) + { + case WM_INITDIALOG: pOfn = (OPENFILENAME *) lParam; pszSelectedKey = (LPTSTR) pOfn->lCustData; @@ -445,7 +457,7 @@ static UINT_PTR CALLBACK ExportRegistryFile_OFNHookProc(HWND hdlg, UINT uiMsg, W SetWindowText(hwndExportBranchText, pszSelectedKey); break; - case WM_NOTIFY: + case WM_NOTIFY: if (((NMHDR *) lParam)->code == CDN_FILEOK) { pOfnNotify = (OFNOTIFY *) lParam; @@ -454,15 +466,15 @@ static UINT_PTR CALLBACK ExportRegistryFile_OFNHookProc(HWND hdlg, UINT uiMsg, W hwndExportBranch = GetDlgItem(hdlg, IDC_EXPORT_BRANCH); hwndExportBranchText = GetDlgItem(hdlg, IDC_EXPORT_BRANCH_TEXT); if (hwndExportBranch && hwndExportBranchText - && (SendMessage(hwndExportBranch, BM_GETCHECK, 0, 0) == BST_CHECKED)) - { - GetWindowText(hwndExportBranchText, pszSelectedKey, _MAX_PATH); - } - else - { - pszSelectedKey[0] = '\0'; - } - } + && (SendMessage(hwndExportBranch, BM_GETCHECK, 0, 0) == BST_CHECKED)) + { + GetWindowText(hwndExportBranchText, pszSelectedKey, _MAX_PATH); + } + else + { + pszSelectedKey[0] = '\0'; + } + } break; } return iResult; @@ -492,7 +504,8 @@ BOOL ExportRegistryFile(HWND hWnd) ofn.Flags = OFN_ENABLETEMPLATE | OFN_EXPLORER | OFN_ENABLEHOOK | OFN_OVERWRITEPROMPT; ofn.lpfnHook = ExportRegistryFile_OFNHookProc; ofn.lpTemplateName = MAKEINTRESOURCE(IDD_EXPORTRANGE); - if (GetSaveFileName(&ofn)) { + if (GetSaveFileName(&ofn)) + { BOOL result; DWORD format; @@ -501,13 +514,16 @@ BOOL ExportRegistryFile(HWND hWnd) else format = REG_FORMAT_4; result = export_registry_key(ofn.lpstrFile, ExportKeyPath, format); - if (!result) { + if (!result) + { LPSTR p = GetMultiByteString(ofn.lpstrFile); fprintf(stderr, "Can't open file \"%s\"\n", p); HeapFree(GetProcessHeap(), 0, p); return FALSE; } - } else { + } + else + { CheckCommDlgError(hWnd); } return TRUE; @@ -530,7 +546,8 @@ BOOL PrintRegistryHive(HWND hWnd, LPTSTR path) pd.nToPage = 0xFFFF; pd.nMinPage = 1; pd.nMaxPage = 0xFFFF; - if (PrintDlg(&pd)) { + if (PrintDlg(&pd)) + { /* GDI calls to render output. */ DeleteDC(pd.hDC); /* Delete DC when done.*/ } @@ -539,8 +556,10 @@ BOOL PrintRegistryHive(HWND hWnd, LPTSTR path) PRINTDLGEX pd; hResult = PrintDlgEx(&pd); - if (hResult == S_OK) { - switch (pd.dwResultAction) { + if (hResult == S_OK) + { + switch (pd.dwResultAction) + { case PD_RESULT_APPLY: /*The user clicked the Apply button and later clicked the Cancel button. This indicates that the user wants to apply the changes made in the property sheet, but does not yet want to print. The PRINTDLGEX structure contains the information specified by the user at the time the Apply button was clicked. */ break; @@ -553,8 +572,11 @@ BOOL PrintRegistryHive(HWND hWnd, LPTSTR path) default: break; } - } else { - switch (hResult) { + } + else + { + switch (hResult) + { case E_OUTOFMEMORY: /*Insufficient memory. */ break; @@ -662,9 +684,11 @@ static BOOL CreateNewValue(HKEY hRootKey, LPCTSTR pszKeyPath, DWORD dwType) wsprintf(szNewValue, szNewValueFormat, iIndex++); cbData = sizeof(data); lResult = RegQueryValueEx(hKey, szNewValue, NULL, &dwExistingType, data, &cbData); - } while(lResult == ERROR_SUCCESS); + } + while(lResult == ERROR_SUCCESS); - switch(dwType) { + switch(dwType) + { case REG_DWORD: cbData = sizeof(DWORD); break; @@ -723,9 +747,9 @@ InitializeRemoteRegistryPicker(OUT IDsObjectPicker **pDsObjectPicker) { sizeof(DSOP_SCOPE_INIT_INFO), DSOP_SCOPE_TYPE_USER_ENTERED_UPLEVEL_SCOPE | DSOP_SCOPE_TYPE_USER_ENTERED_DOWNLEVEL_SCOPE | - DSOP_SCOPE_TYPE_GLOBAL_CATALOG | DSOP_SCOPE_TYPE_EXTERNAL_UPLEVEL_DOMAIN | - DSOP_SCOPE_TYPE_EXTERNAL_DOWNLEVEL_DOMAIN | DSOP_SCOPE_TYPE_WORKGROUP | - DSOP_SCOPE_TYPE_UPLEVEL_JOINED_DOMAIN | DSOP_SCOPE_TYPE_DOWNLEVEL_JOINED_DOMAIN, + DSOP_SCOPE_TYPE_GLOBAL_CATALOG | DSOP_SCOPE_TYPE_EXTERNAL_UPLEVEL_DOMAIN | + DSOP_SCOPE_TYPE_EXTERNAL_DOWNLEVEL_DOMAIN | DSOP_SCOPE_TYPE_WORKGROUP | + DSOP_SCOPE_TYPE_UPLEVEL_JOINED_DOMAIN | DSOP_SCOPE_TYPE_DOWNLEVEL_JOINED_DOMAIN, 0, { { @@ -750,7 +774,7 @@ InitializeRemoteRegistryPicker(OUT IDsObjectPicker **pDsObjectPicker) InitInfo.apwzAttributeNames = NULL; hRet = (*pDsObjectPicker)->lpVtbl->Initialize(*pDsObjectPicker, - &InitInfo); + &InitInfo); if (FAILED(hRet)) { @@ -772,8 +796,8 @@ InvokeRemoteRegistryPickerDialog(IN IDsObjectPicker *pDsObjectPicker, HRESULT hRet; hRet = pDsObjectPicker->lpVtbl->InvokeDialog(pDsObjectPicker, - hwndParent, - &pdo); + hwndParent, + &pdo); if (hRet == S_OK) { STGMEDIUM stm; @@ -855,7 +879,8 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) UNREFERENCED_PARAMETER(lParam); UNREFERENCED_PARAMETER(message); - switch (LOWORD(wParam)) { + switch (LOWORD(wParam)) + { case ID_REGISTRY_LOADHIVE: LoadHive(hWnd); return TRUE; @@ -924,9 +949,9 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) pts = pt; if(ClientToScreen(g_pChildWnd->hWnd, &pts)) { - SetCursorPos(pts.x, pts.y); - SetCursor(LoadCursor(0, IDC_SIZEWE)); - SendMessage(g_pChildWnd->hWnd, WM_LBUTTONDOWN, 0, MAKELPARAM(pt.x, pt.y)); + SetCursorPos(pts.x, pts.y); + SetCursor(LoadCursor(0, IDC_SIZEWE)); + SendMessage(g_pChildWnd->hWnd, WM_LBUTTONDOWN, 0, MAKELPARAM(pt.x, pt.y)); } return TRUE; } @@ -940,12 +965,14 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) keyPath = GetItemPath(g_pChildWnd->hTreeWnd, 0, &hKeyRoot); valueName = GetValueName(g_pChildWnd->hListWnd, -1); - if (keyPath) { + if (keyPath) + { lRet = RegOpenKeyEx(hKeyRoot, keyPath, 0, regsam, &hKey); if (lRet != ERROR_SUCCESS) hKey = 0; } - switch (LOWORD(wParam)) { + switch (LOWORD(wParam)) + { case ID_EDIT_MODIFY: if (valueName && ModifyValue(hWnd, hKey, valueName, FALSE)) RefreshListView(g_pChildWnd->hListWnd, hKeyRoot, keyPath); @@ -978,49 +1005,49 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { if (GetFocus() == g_pChildWnd->hListWnd) { - UINT nSelected = ListView_GetSelectedCount(g_pChildWnd->hListWnd); - if(nSelected >= 1) - { - TCHAR msg[128], caption[128]; - LoadString(hInst, IDS_QUERY_DELETE_CONFIRM, caption, sizeof(caption)/sizeof(TCHAR)); - LoadString(hInst, (nSelected == 1 ? IDS_QUERY_DELETE_ONE : IDS_QUERY_DELETE_MORE), msg, sizeof(msg)/sizeof(TCHAR)); - if(MessageBox(g_pChildWnd->hWnd, msg, caption, MB_ICONQUESTION | MB_YESNO) == IDYES) + UINT nSelected = ListView_GetSelectedCount(g_pChildWnd->hListWnd); + if(nSelected >= 1) { - int ni, errs; - - item = -1; - errs = 0; - while((ni = ListView_GetNextItem(g_pChildWnd->hListWnd, item, LVNI_SELECTED)) > -1) - { - valueName = GetValueName(g_pChildWnd->hListWnd, item); - if(RegDeleteValue(hKey, valueName) != ERROR_SUCCESS) + TCHAR msg[128], caption[128]; + LoadString(hInst, IDS_QUERY_DELETE_CONFIRM, caption, sizeof(caption)/sizeof(TCHAR)); + LoadString(hInst, (nSelected == 1 ? IDS_QUERY_DELETE_ONE : IDS_QUERY_DELETE_MORE), msg, sizeof(msg)/sizeof(TCHAR)); + if(MessageBox(g_pChildWnd->hWnd, msg, caption, MB_ICONQUESTION | MB_YESNO) == IDYES) { - errs++; - } - item = ni; - } + int ni, errs; - RefreshListView(g_pChildWnd->hListWnd, hKeyRoot, keyPath); - if(errs > 0) - { - LoadString(hInst, IDS_ERR_DELVAL_CAPTION, caption, sizeof(caption)/sizeof(TCHAR)); - LoadString(hInst, IDS_ERR_DELETEVALUE, msg, sizeof(msg)/sizeof(TCHAR)); - MessageBox(g_pChildWnd->hWnd, msg, caption, MB_ICONSTOP); - } + item = -1; + errs = 0; + while((ni = ListView_GetNextItem(g_pChildWnd->hListWnd, item, LVNI_SELECTED)) > -1) + { + valueName = GetValueName(g_pChildWnd->hListWnd, item); + if(RegDeleteValue(hKey, valueName) != ERROR_SUCCESS) + { + errs++; + } + item = ni; + } + + RefreshListView(g_pChildWnd->hListWnd, hKeyRoot, keyPath); + if(errs > 0) + { + LoadString(hInst, IDS_ERR_DELVAL_CAPTION, caption, sizeof(caption)/sizeof(TCHAR)); + LoadString(hInst, IDS_ERR_DELETEVALUE, msg, sizeof(msg)/sizeof(TCHAR)); + MessageBox(g_pChildWnd->hWnd, msg, caption, MB_ICONSTOP); + } + } } - } } else if (GetFocus() == g_pChildWnd->hTreeWnd) { - if (keyPath == 0 || *keyPath == 0) - { - MessageBeep(MB_ICONHAND); - } else - if (DeleteKey(hWnd, hKeyRoot, keyPath)) - { - DeleteNode(g_pChildWnd->hTreeWnd, 0); - RefreshTreeView(g_pChildWnd->hTreeWnd); - } + if (keyPath == 0 || *keyPath == 0) + { + MessageBeep(MB_ICONHAND); + } + else if (DeleteKey(hWnd, hKeyRoot, keyPath)) + { + DeleteNode(g_pChildWnd->hTreeWnd, 0); + RefreshTreeView(g_pChildWnd->hTreeWnd); + } } break; } @@ -1064,9 +1091,9 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) RefreshTreeView(g_pChildWnd->hTreeWnd); /*RefreshListView(g_pChildWnd->hListWnd, hKeyRoot, keyPath, NULL); */ break; - /*case ID_OPTIONS_TOOLBAR:*/ - /* toggle_child(hWnd, LOWORD(wParam), hToolBar);*/ - /* break;*/ + /*case ID_OPTIONS_TOOLBAR:*/ + /* toggle_child(hWnd, LOWORD(wParam), hToolBar);*/ + /* break;*/ case ID_EDIT_NEW_KEY: CreateNewKey(g_pChildWnd->hTreeWnd, TreeView_GetSelection(g_pChildWnd->hTreeWnd)); break; @@ -1099,7 +1126,7 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) } if(hKey) - RegCloseKey(hKey); + RegCloseKey(hKey); return result; } @@ -1116,7 +1143,8 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) LRESULT CALLBACK FrameWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { - switch (message) { + switch (message) + { case WM_CREATE: CreateWindowEx(0, szChildClass, NULL, WS_CHILD | WS_VISIBLE, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, diff --git a/reactos/base/applications/regedit/hexedit.c b/reactos/base/applications/regedit/hexedit.c index 8a7438be84e..78afe08af4c 100644 --- a/reactos/base/applications/regedit/hexedit.c +++ b/reactos/base/applications/regedit/hexedit.c @@ -21,32 +21,32 @@ #include typedef struct { - HWND hWndSelf; - HWND hWndParent; - HLOCAL hBuffer; - DWORD style; - DWORD MaxBuffer; - INT ColumnsPerLine; - INT nLines; - INT nVisibleLinesComplete; - INT nVisibleLines; - INT Index; - INT LineHeight; - INT CharWidth; - HFONT hFont; - BOOL SbVisible; + HWND hWndSelf; + HWND hWndParent; + HLOCAL hBuffer; + DWORD style; + DWORD MaxBuffer; + INT ColumnsPerLine; + INT nLines; + INT nVisibleLinesComplete; + INT nVisibleLines; + INT Index; + INT LineHeight; + INT CharWidth; + HFONT hFont; + BOOL SbVisible; - INT LeftMargin; - INT AddressSpacing; - INT SplitSpacing; + INT LeftMargin; + INT AddressSpacing; + INT SplitSpacing; - BOOL EditingField; - INT CaretCol; - INT CaretLine; - BOOL InMid; + BOOL EditingField; + INT CaretCol; + INT CaretLine; + BOOL InMid; - INT SelStart; - INT SelEnd; + INT SelStart; + INT SelEnd; } HEXEDIT_DATA, *PHEXEDIT_DATA; static const TCHAR ClipboardFormatName[] = TEXT("RegEdit_HexData"); @@ -67,28 +67,28 @@ ATOM WINAPI RegisterHexEditorClass(HINSTANCE hInstance) { - WNDCLASSEX WndClass; + WNDCLASSEX WndClass; - ClipboardFormatID = RegisterClipboardFormat(ClipboardFormatName); + ClipboardFormatID = RegisterClipboardFormat(ClipboardFormatName); - ZeroMemory(&WndClass, sizeof(WNDCLASSEX)); - WndClass.cbSize = sizeof(WNDCLASSEX); - WndClass.style = CS_DBLCLKS; - WndClass.lpfnWndProc = (WNDPROC)HexEditWndProc; - WndClass.cbWndExtra = sizeof(PHEXEDIT_DATA); - WndClass.hInstance = hInstance; - WndClass.hCursor = LoadCursor(0, IDC_IBEAM); - WndClass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); - WndClass.lpszClassName = HEX_EDIT_CLASS_NAME; + ZeroMemory(&WndClass, sizeof(WNDCLASSEX)); + WndClass.cbSize = sizeof(WNDCLASSEX); + WndClass.style = CS_DBLCLKS; + WndClass.lpfnWndProc = (WNDPROC)HexEditWndProc; + WndClass.cbWndExtra = sizeof(PHEXEDIT_DATA); + WndClass.hInstance = hInstance; + WndClass.hCursor = LoadCursor(0, IDC_IBEAM); + WndClass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); + WndClass.lpszClassName = HEX_EDIT_CLASS_NAME; - return RegisterClassEx(&WndClass); + return RegisterClassEx(&WndClass); } BOOL WINAPI UnregisterHexEditorClass(HINSTANCE hInstance) { - return UnregisterClass(HEX_EDIT_CLASS_NAME, hInstance); + return UnregisterClass(HEX_EDIT_CLASS_NAME, hInstance); } /*** Helper functions *********************************************************/ @@ -96,470 +96,470 @@ UnregisterHexEditorClass(HINSTANCE hInstance) static VOID HEXEDIT_MoveCaret(PHEXEDIT_DATA hed, BOOL Scroll) { - SCROLLINFO si; + SCROLLINFO si; - si.cbSize = sizeof(SCROLLINFO); - si.fMask = SIF_POS; - GetScrollInfo(hed->hWndSelf, SB_VERT, &si); + si.cbSize = sizeof(SCROLLINFO); + si.fMask = SIF_POS; + GetScrollInfo(hed->hWndSelf, SB_VERT, &si); - if(Scroll) - { - if(si.nPos > hed->CaretLine) + if(Scroll) { - si.nPos = hed->CaretLine; - SetScrollInfo(hed->hWndSelf, SB_VERT, &si, TRUE); - GetScrollInfo(hed->hWndSelf, SB_VERT, &si); - InvalidateRect(hed->hWndSelf, NULL, TRUE); + if(si.nPos > hed->CaretLine) + { + si.nPos = hed->CaretLine; + SetScrollInfo(hed->hWndSelf, SB_VERT, &si, TRUE); + GetScrollInfo(hed->hWndSelf, SB_VERT, &si); + InvalidateRect(hed->hWndSelf, NULL, TRUE); + } + else if(hed->CaretLine >= (hed->nVisibleLinesComplete + si.nPos)) + { + si.nPos = hed->CaretLine - hed->nVisibleLinesComplete + 1; + SetScrollInfo(hed->hWndSelf, SB_VERT, &si, TRUE); + GetScrollInfo(hed->hWndSelf, SB_VERT, &si); + InvalidateRect(hed->hWndSelf, NULL, TRUE); + } } - else if(hed->CaretLine >= (hed->nVisibleLinesComplete + si.nPos)) - { - si.nPos = hed->CaretLine - hed->nVisibleLinesComplete + 1; - SetScrollInfo(hed->hWndSelf, SB_VERT, &si, TRUE); - GetScrollInfo(hed->hWndSelf, SB_VERT, &si); - InvalidateRect(hed->hWndSelf, NULL, TRUE); - } - } - if(hed->EditingField) - SetCaretPos(hed->LeftMargin + ((4 + hed->AddressSpacing + (3 * hed->CaretCol) + hed->InMid * 2) * hed->CharWidth) - 1, (hed->CaretLine - si.nPos) * hed->LineHeight); - else - SetCaretPos(hed->LeftMargin + ((4 + hed->AddressSpacing + hed->SplitSpacing + (3 * hed->ColumnsPerLine) + hed->CaretCol) * hed->CharWidth) - 2, (hed->CaretLine - si.nPos) * hed->LineHeight); + if(hed->EditingField) + SetCaretPos(hed->LeftMargin + ((4 + hed->AddressSpacing + (3 * hed->CaretCol) + hed->InMid * 2) * hed->CharWidth) - 1, (hed->CaretLine - si.nPos) * hed->LineHeight); + else + SetCaretPos(hed->LeftMargin + ((4 + hed->AddressSpacing + hed->SplitSpacing + (3 * hed->ColumnsPerLine) + hed->CaretCol) * hed->CharWidth) - 2, (hed->CaretLine - si.nPos) * hed->LineHeight); } static VOID HEXEDIT_Update(PHEXEDIT_DATA hed) { - SCROLLINFO si; - RECT rcClient; - BOOL SbVisible; - INT bufsize, cvislines; + SCROLLINFO si; + RECT rcClient; + BOOL SbVisible; + INT bufsize, cvislines; - GetClientRect(hed->hWndSelf, &rcClient); - hed->style = GetWindowLongPtr(hed->hWndSelf, GWL_STYLE); + GetClientRect(hed->hWndSelf, &rcClient); + hed->style = GetWindowLongPtr(hed->hWndSelf, GWL_STYLE); - bufsize = (hed->hBuffer ? (INT) LocalSize(hed->hBuffer) : 0); - hed->nLines = max(bufsize / hed->ColumnsPerLine, 1); - if(bufsize > hed->ColumnsPerLine && (bufsize % hed->ColumnsPerLine) > 0) - { - hed->nLines++; - } - - if(hed->LineHeight > 0) - { - hed->nVisibleLinesComplete = cvislines = rcClient.bottom / hed->LineHeight; - hed->nVisibleLines = hed->nVisibleLinesComplete; - if(rcClient.bottom % hed->LineHeight) + bufsize = (hed->hBuffer ? (INT) LocalSize(hed->hBuffer) : 0); + hed->nLines = max(bufsize / hed->ColumnsPerLine, 1); + if(bufsize > hed->ColumnsPerLine && (bufsize % hed->ColumnsPerLine) > 0) { - hed->nVisibleLines++; + hed->nLines++; } - } - else - { - hed->nVisibleLines = cvislines = 0; - } - SbVisible = bufsize > 0 && cvislines < hed->nLines; - ShowScrollBar(hed->hWndSelf, SB_VERT, SbVisible); + if(hed->LineHeight > 0) + { + hed->nVisibleLinesComplete = cvislines = rcClient.bottom / hed->LineHeight; + hed->nVisibleLines = hed->nVisibleLinesComplete; + if(rcClient.bottom % hed->LineHeight) + { + hed->nVisibleLines++; + } + } + else + { + hed->nVisibleLines = cvislines = 0; + } - /* update scrollbar */ - si.cbSize = sizeof(SCROLLINFO); - si.fMask = SIF_RANGE | SIF_PAGE; - si.nMin = 0; - si.nMax = ((bufsize > 0) ? hed->nLines - 1 : 0); - si.nPage = ((hed->LineHeight > 0) ? rcClient.bottom / hed->LineHeight : 0); - SetScrollInfo(hed->hWndSelf, SB_VERT, &si, TRUE); + SbVisible = bufsize > 0 && cvislines < hed->nLines; + ShowScrollBar(hed->hWndSelf, SB_VERT, SbVisible); - if(IsWindowVisible(hed->hWndSelf) && SbVisible != hed->SbVisible) - { - InvalidateRect(hed->hWndSelf, NULL, TRUE); - } + /* update scrollbar */ + si.cbSize = sizeof(SCROLLINFO); + si.fMask = SIF_RANGE | SIF_PAGE; + si.nMin = 0; + si.nMax = ((bufsize > 0) ? hed->nLines - 1 : 0); + si.nPage = ((hed->LineHeight > 0) ? rcClient.bottom / hed->LineHeight : 0); + SetScrollInfo(hed->hWndSelf, SB_VERT, &si, TRUE); - hed->SbVisible = SbVisible; + if(IsWindowVisible(hed->hWndSelf) && SbVisible != hed->SbVisible) + { + InvalidateRect(hed->hWndSelf, NULL, TRUE); + } + + hed->SbVisible = SbVisible; } static HFONT HEXEDIT_GetFixedFont(VOID) { - LOGFONT lf; - GetObject(GetStockObject(ANSI_FIXED_FONT), sizeof(LOGFONT), &lf); - return CreateFontIndirect(&lf); + LOGFONT lf; + GetObject(GetStockObject(ANSI_FIXED_FONT), sizeof(LOGFONT), &lf); + return CreateFontIndirect(&lf); } static VOID HEXEDIT_PaintLines(PHEXEDIT_DATA hed, HDC hDC, DWORD ScrollPos, DWORD First, DWORD Last, RECT *rc) { - DWORD dx, dy, linestart; - INT i, isave, i0, i1, x; - PBYTE buf, current, end, line; - size_t bufsize; - TCHAR hex[3], addr[17]; - RECT rct, rct2; + DWORD dx, dy, linestart; + INT i, isave, i0, i1, x; + PBYTE buf, current, end, line; + size_t bufsize; + TCHAR hex[3], addr[17]; + RECT rct, rct2; - FillRect(hDC, rc, (HBRUSH)(COLOR_WINDOW + 1)); - SetTextColor(hDC, GetSysColor(COLOR_WINDOWTEXT)); + FillRect(hDC, rc, (HBRUSH)(COLOR_WINDOW + 1)); + SetTextColor(hDC, GetSysColor(COLOR_WINDOWTEXT)); - if (hed->SelStart < hed->SelEnd) - { - i0 = hed->SelStart; - i1 = hed->SelEnd; - } - else - { - i0 = hed->SelEnd; - i1 = hed->SelStart; - } - - if(hed->hBuffer) - { - bufsize = LocalSize(hed->hBuffer); - buf = LocalLock(hed->hBuffer); - } - else - { - buf = NULL; - bufsize = 0; - - if(ScrollPos + First == 0) + if (hed->SelStart < hed->SelEnd) { - /* draw address */ - wsprintf(addr, TEXT("%04X"), 0); - TextOut(hDC, hed->LeftMargin, First * hed->LineHeight, addr, 4); + i0 = hed->SelStart; + i1 = hed->SelEnd; } - } - - if(buf) - { - end = buf + bufsize; - dy = First * hed->LineHeight; - linestart = (ScrollPos + First) * hed->ColumnsPerLine; - i = linestart; - current = buf + linestart; - Last = min(hed->nLines - ScrollPos, Last); - - SetBkMode(hDC, TRANSPARENT); - while(First <= Last && current < end) + else { - DWORD dh; - - dx = hed->LeftMargin; - - /* draw address */ - wsprintf(addr, TEXT("%04lX"), linestart); - TextOut(hDC, dx, dy, addr, 4); - - dx += ((4 + hed->AddressSpacing) * hed->CharWidth); - dh = (3 * hed->CharWidth); - - rct.left = dx; - rct.top = dy; - rct.right = rct.left + dh; - rct.bottom = dy + hed->LineHeight; - - /* draw hex map */ - dx += (hed->CharWidth / 2); - line = current; - isave = i; - for(x = 0; x < hed->ColumnsPerLine && current < end; x++) - { - rct.left += dh; - rct.right += dh; - - wsprintf(hex, TEXT("%02X"), *(current++)); - if (i0 <= i && i < i1) - { - rct2.left = dx; - rct2.top = dy; - rct2.right = dx + hed->CharWidth * 2 + 1; - rct2.bottom = dy + hed->LineHeight; - InflateRect(&rct2, hed->CharWidth / 2, 0); - FillRect(hDC, &rct2, (HBRUSH)(COLOR_HIGHLIGHT + 1)); - SetTextColor(hDC, GetSysColor(COLOR_HIGHLIGHTTEXT)); - ExtTextOut(hDC, dx, dy, 0, &rct, hex, 2, NULL); - SetTextColor(hDC, GetSysColor(COLOR_WINDOWTEXT)); - } - else - ExtTextOut(hDC, dx, dy, ETO_OPAQUE, &rct, hex, 2, NULL); - dx += dh; - i++; - } - - /* draw ascii map */ - dx = ((4 + hed->AddressSpacing + hed->SplitSpacing + (hed->ColumnsPerLine * 3)) * hed->CharWidth); - current = line; - i = isave; - for(x = 0; x < hed->ColumnsPerLine && current < end; x++) - { - wsprintf(hex, _T("%C"), *(current++)); - hex[0] = ((hex[0] & _T('\x007f')) >= _T(' ') ? hex[0] : _T('.')); - if (i0 <= i && i < i1) - { - rct2.left = dx; - rct2.top = dy; - rct2.right = dx + hed->CharWidth; - rct2.bottom = dy + hed->LineHeight; - FillRect(hDC, &rct2, (HBRUSH)(COLOR_HIGHLIGHT + 1)); - SetTextColor(hDC, GetSysColor(COLOR_HIGHLIGHTTEXT)); - TextOut(hDC, dx, dy, hex, 1); - SetTextColor(hDC, GetSysColor(COLOR_WINDOWTEXT)); - } - else - TextOut(hDC, dx, dy, hex, 1); - dx += hed->CharWidth; - i++; - } - - dy += hed->LineHeight; - linestart += hed->ColumnsPerLine; - First++; + i0 = hed->SelEnd; + i1 = hed->SelStart; } - } - LocalUnlock(hed->hBuffer); + if(hed->hBuffer) + { + bufsize = LocalSize(hed->hBuffer); + buf = LocalLock(hed->hBuffer); + } + else + { + buf = NULL; + bufsize = 0; + + if(ScrollPos + First == 0) + { + /* draw address */ + wsprintf(addr, TEXT("%04X"), 0); + TextOut(hDC, hed->LeftMargin, First * hed->LineHeight, addr, 4); + } + } + + if(buf) + { + end = buf + bufsize; + dy = First * hed->LineHeight; + linestart = (ScrollPos + First) * hed->ColumnsPerLine; + i = linestart; + current = buf + linestart; + Last = min(hed->nLines - ScrollPos, Last); + + SetBkMode(hDC, TRANSPARENT); + while(First <= Last && current < end) + { + DWORD dh; + + dx = hed->LeftMargin; + + /* draw address */ + wsprintf(addr, TEXT("%04lX"), linestart); + TextOut(hDC, dx, dy, addr, 4); + + dx += ((4 + hed->AddressSpacing) * hed->CharWidth); + dh = (3 * hed->CharWidth); + + rct.left = dx; + rct.top = dy; + rct.right = rct.left + dh; + rct.bottom = dy + hed->LineHeight; + + /* draw hex map */ + dx += (hed->CharWidth / 2); + line = current; + isave = i; + for(x = 0; x < hed->ColumnsPerLine && current < end; x++) + { + rct.left += dh; + rct.right += dh; + + wsprintf(hex, TEXT("%02X"), *(current++)); + if (i0 <= i && i < i1) + { + rct2.left = dx; + rct2.top = dy; + rct2.right = dx + hed->CharWidth * 2 + 1; + rct2.bottom = dy + hed->LineHeight; + InflateRect(&rct2, hed->CharWidth / 2, 0); + FillRect(hDC, &rct2, (HBRUSH)(COLOR_HIGHLIGHT + 1)); + SetTextColor(hDC, GetSysColor(COLOR_HIGHLIGHTTEXT)); + ExtTextOut(hDC, dx, dy, 0, &rct, hex, 2, NULL); + SetTextColor(hDC, GetSysColor(COLOR_WINDOWTEXT)); + } + else + ExtTextOut(hDC, dx, dy, ETO_OPAQUE, &rct, hex, 2, NULL); + dx += dh; + i++; + } + + /* draw ascii map */ + dx = ((4 + hed->AddressSpacing + hed->SplitSpacing + (hed->ColumnsPerLine * 3)) * hed->CharWidth); + current = line; + i = isave; + for(x = 0; x < hed->ColumnsPerLine && current < end; x++) + { + wsprintf(hex, _T("%C"), *(current++)); + hex[0] = ((hex[0] & _T('\x007f')) >= _T(' ') ? hex[0] : _T('.')); + if (i0 <= i && i < i1) + { + rct2.left = dx; + rct2.top = dy; + rct2.right = dx + hed->CharWidth; + rct2.bottom = dy + hed->LineHeight; + FillRect(hDC, &rct2, (HBRUSH)(COLOR_HIGHLIGHT + 1)); + SetTextColor(hDC, GetSysColor(COLOR_HIGHLIGHTTEXT)); + TextOut(hDC, dx, dy, hex, 1); + SetTextColor(hDC, GetSysColor(COLOR_WINDOWTEXT)); + } + else + TextOut(hDC, dx, dy, hex, 1); + dx += hed->CharWidth; + i++; + } + + dy += hed->LineHeight; + linestart += hed->ColumnsPerLine; + First++; + } + } + + LocalUnlock(hed->hBuffer); } static DWORD HEXEDIT_HitRegionTest(PHEXEDIT_DATA hed, POINTS pt) { - int d; + int d; - if(pt.x <= hed->LeftMargin) - { - return HEHT_LEFTMARGIN; - } + if(pt.x <= hed->LeftMargin) + { + return HEHT_LEFTMARGIN; + } - pt.x -= hed->LeftMargin; - d = (4 * hed->CharWidth); - if(pt.x <= d) - { - return HEHT_ADDRESS; - } + pt.x -= hed->LeftMargin; + d = (4 * hed->CharWidth); + if(pt.x <= d) + { + return HEHT_ADDRESS; + } - pt.x -= d; - d = (hed->AddressSpacing * hed->CharWidth); - if(pt.x <= d) - { - return HEHT_ADDRESSSPACING; - } + pt.x -= d; + d = (hed->AddressSpacing * hed->CharWidth); + if(pt.x <= d) + { + return HEHT_ADDRESSSPACING; + } - pt.x -= d; - d = ((3 * hed->ColumnsPerLine + 1) * hed->CharWidth); - if(pt.x <= d) - { - return HEHT_HEXDUMP; - } + pt.x -= d; + d = ((3 * hed->ColumnsPerLine + 1) * hed->CharWidth); + if(pt.x <= d) + { + return HEHT_HEXDUMP; + } - pt.x -= d; - d = ((hed->SplitSpacing - 1) * hed->CharWidth); - if(pt.x <= d) - { - return HEHT_HEXDUMPSPACING; - } + pt.x -= d; + d = ((hed->SplitSpacing - 1) * hed->CharWidth); + if(pt.x <= d) + { + return HEHT_HEXDUMPSPACING; + } - pt.x -= d; - d = (hed->ColumnsPerLine * hed->CharWidth); - if(pt.x <= d) - { - return HEHT_ASCIIDUMP; - } + pt.x -= d; + d = (hed->ColumnsPerLine * hed->CharWidth); + if(pt.x <= d) + { + return HEHT_ASCIIDUMP; + } - return HEHT_RIGHTMARGIN; + return HEHT_RIGHTMARGIN; } static DWORD HEXEDIT_IndexFromPoint(PHEXEDIT_DATA hed, POINTS pt, DWORD Hit, POINT *EditPos, BOOL *EditField) { - SCROLLINFO si; - DWORD Index, bufsize; + SCROLLINFO si; + DWORD Index, bufsize; - si.cbSize = sizeof(SCROLLINFO); - si.fMask = SIF_POS; - GetScrollInfo(hed->hWndSelf, SB_VERT, &si); + si.cbSize = sizeof(SCROLLINFO); + si.fMask = SIF_POS; + GetScrollInfo(hed->hWndSelf, SB_VERT, &si); - EditPos->x = 0; + EditPos->x = 0; - if(hed->LineHeight > 0) - { - EditPos->y = min(si.nPos + (pt.y / hed->LineHeight), hed->nLines - 1); - } - else - { - EditPos->y = si.nPos; - } + if(hed->LineHeight > 0) + { + EditPos->y = min(si.nPos + (pt.y / hed->LineHeight), hed->nLines - 1); + } + else + { + EditPos->y = si.nPos; + } - switch(Hit) - { + switch(Hit) + { case HEHT_LEFTMARGIN: case HEHT_ADDRESS: case HEHT_ADDRESSSPACING: case HEHT_HEXDUMP: - pt.x -= (SHORT) hed->LeftMargin + ((4 + hed->AddressSpacing) * hed->CharWidth); - *EditField = TRUE; - break; + pt.x -= (SHORT) hed->LeftMargin + ((4 + hed->AddressSpacing) * hed->CharWidth); + *EditField = TRUE; + break; default: - pt.x -= hed->LeftMargin + ((4 + hed->AddressSpacing + hed->SplitSpacing + (3 * hed->ColumnsPerLine)) * hed->CharWidth); - *EditField = FALSE; - break; - } + pt.x -= hed->LeftMargin + ((4 + hed->AddressSpacing + hed->SplitSpacing + (3 * hed->ColumnsPerLine)) * hed->CharWidth); + *EditField = FALSE; + break; + } - if(pt.x > 0) - { - INT BlockWidth = (*EditField ? hed->CharWidth * 3 : hed->CharWidth); - EditPos->x = min(hed->ColumnsPerLine, (pt.x + BlockWidth / 2) / BlockWidth); - } + if(pt.x > 0) + { + INT BlockWidth = (*EditField ? hed->CharWidth * 3 : hed->CharWidth); + EditPos->x = min(hed->ColumnsPerLine, (pt.x + BlockWidth / 2) / BlockWidth); + } - bufsize = (hed->hBuffer ? (DWORD) LocalSize(hed->hBuffer) : 0); - Index = (EditPos->y * hed->ColumnsPerLine) + EditPos->x; - if(Index > bufsize) - { - INT tmp = bufsize % hed->ColumnsPerLine; - Index = bufsize; - EditPos->x = (tmp == 0 ? hed->ColumnsPerLine : tmp); - } - return Index; + bufsize = (hed->hBuffer ? (DWORD) LocalSize(hed->hBuffer) : 0); + Index = (EditPos->y * hed->ColumnsPerLine) + EditPos->x; + if(Index > bufsize) + { + INT tmp = bufsize % hed->ColumnsPerLine; + Index = bufsize; + EditPos->x = (tmp == 0 ? hed->ColumnsPerLine : tmp); + } + return Index; } static VOID HEXEDIT_Copy(PHEXEDIT_DATA hed) { - PBYTE pb, buf; - UINT cb; - INT i0, i1; - HGLOBAL hGlobal; + PBYTE pb, buf; + UINT cb; + INT i0, i1; + HGLOBAL hGlobal; - if (hed->SelStart < hed->SelEnd) - { - i0 = hed->SelStart; - i1 = hed->SelEnd; - } - else - { - i0 = hed->SelEnd; - i1 = hed->SelStart; - } - - cb = i1 - i0; - if (cb == 0) - return; - - hGlobal = GlobalAlloc(GHND | GMEM_SHARE, cb + sizeof(DWORD)); - if (hGlobal == NULL) - return; - - pb = GlobalLock(hGlobal); - if (pb) - { - *(PDWORD)pb = cb; - pb += sizeof(DWORD); - buf = (PBYTE) LocalLock(hed->hBuffer); - if (buf) + if (hed->SelStart < hed->SelEnd) { - CopyMemory(pb, buf + i0, cb); - LocalUnlock(hed->hBuffer); + i0 = hed->SelStart; + i1 = hed->SelEnd; } - GlobalUnlock(hGlobal); - - if (OpenClipboard(hed->hWndSelf)) + else { - EmptyClipboard(); - SetClipboardData(ClipboardFormatID, hGlobal); - CloseClipboard(); + i0 = hed->SelEnd; + i1 = hed->SelStart; } - } - else - GlobalFree(hGlobal); + + cb = i1 - i0; + if (cb == 0) + return; + + hGlobal = GlobalAlloc(GHND | GMEM_SHARE, cb + sizeof(DWORD)); + if (hGlobal == NULL) + return; + + pb = GlobalLock(hGlobal); + if (pb) + { + *(PDWORD)pb = cb; + pb += sizeof(DWORD); + buf = (PBYTE) LocalLock(hed->hBuffer); + if (buf) + { + CopyMemory(pb, buf + i0, cb); + LocalUnlock(hed->hBuffer); + } + GlobalUnlock(hGlobal); + + if (OpenClipboard(hed->hWndSelf)) + { + EmptyClipboard(); + SetClipboardData(ClipboardFormatID, hGlobal); + CloseClipboard(); + } + } + else + GlobalFree(hGlobal); } static VOID HEXEDIT_Delete(PHEXEDIT_DATA hed) { - PBYTE buf; - INT i0, i1; - UINT bufsize; + PBYTE buf; + INT i0, i1; + UINT bufsize; - if (hed->SelStart < hed->SelEnd) - { - i0 = hed->SelStart; - i1 = hed->SelEnd; - } - else - { - i0 = hed->SelEnd; - i1 = hed->SelStart; - } - - if (i0 != i1) - { - bufsize = (hed->hBuffer ? LocalSize(hed->hBuffer) : 0); - buf = (PBYTE) LocalLock(hed->hBuffer); - if (buf) + if (hed->SelStart < hed->SelEnd) { - MoveMemory(buf + i0, buf + i1, bufsize - i1); - LocalUnlock(hed->hBuffer); + i0 = hed->SelStart; + i1 = hed->SelEnd; + } + else + { + i0 = hed->SelEnd; + i1 = hed->SelStart; + } + + if (i0 != i1) + { + bufsize = (hed->hBuffer ? LocalSize(hed->hBuffer) : 0); + buf = (PBYTE) LocalLock(hed->hBuffer); + if (buf) + { + MoveMemory(buf + i0, buf + i1, bufsize - i1); + LocalUnlock(hed->hBuffer); + } + HexEdit_SetMaxBufferSize(hed->hWndSelf, bufsize - (i1 - i0)); + hed->InMid = FALSE; + hed->Index = hed->SelStart = hed->SelEnd = i0; + hed->CaretCol = hed->Index % hed->ColumnsPerLine; + hed->CaretLine = hed->Index / hed->ColumnsPerLine; + InvalidateRect(hed->hWndSelf, NULL, TRUE); + HEXEDIT_MoveCaret(hed, TRUE); } - HexEdit_SetMaxBufferSize(hed->hWndSelf, bufsize - (i1 - i0)); - hed->InMid = FALSE; - hed->Index = hed->SelStart = hed->SelEnd = i0; - hed->CaretCol = hed->Index % hed->ColumnsPerLine; - hed->CaretLine = hed->Index / hed->ColumnsPerLine; - InvalidateRect(hed->hWndSelf, NULL, TRUE); - HEXEDIT_MoveCaret(hed, TRUE); - } } static VOID HEXEDIT_Paste(PHEXEDIT_DATA hed) { - HGLOBAL hGlobal; - UINT bufsize; - PBYTE pb, buf; - DWORD cb; + HGLOBAL hGlobal; + UINT bufsize; + PBYTE pb, buf; + DWORD cb; - HEXEDIT_Delete(hed); - bufsize = (hed->hBuffer ? LocalSize(hed->hBuffer) : 0); + HEXEDIT_Delete(hed); + bufsize = (hed->hBuffer ? LocalSize(hed->hBuffer) : 0); - if (OpenClipboard(hed->hWndSelf)) - { - hGlobal = GetClipboardData(ClipboardFormatID); - if (hGlobal != NULL) + if (OpenClipboard(hed->hWndSelf)) { - pb = (PBYTE) GlobalLock(hGlobal); - cb = *(PDWORD) pb; - pb += sizeof(DWORD); - HexEdit_SetMaxBufferSize(hed->hWndSelf, bufsize + cb); - buf = (PBYTE) LocalLock(hed->hBuffer); - if (buf) - { - MoveMemory(buf + hed->Index + cb, buf + hed->Index, - bufsize - hed->Index); - CopyMemory(buf + hed->Index, pb, cb); - LocalUnlock(hed->hBuffer); - } - GlobalUnlock(hGlobal); + hGlobal = GetClipboardData(ClipboardFormatID); + if (hGlobal != NULL) + { + pb = (PBYTE) GlobalLock(hGlobal); + cb = *(PDWORD) pb; + pb += sizeof(DWORD); + HexEdit_SetMaxBufferSize(hed->hWndSelf, bufsize + cb); + buf = (PBYTE) LocalLock(hed->hBuffer); + if (buf) + { + MoveMemory(buf + hed->Index + cb, buf + hed->Index, + bufsize - hed->Index); + CopyMemory(buf + hed->Index, pb, cb); + LocalUnlock(hed->hBuffer); + } + GlobalUnlock(hGlobal); + } + CloseClipboard(); } - CloseClipboard(); - } - InvalidateRect(hed->hWndSelf, NULL, TRUE); - HEXEDIT_MoveCaret(hed, TRUE); + InvalidateRect(hed->hWndSelf, NULL, TRUE); + HEXEDIT_MoveCaret(hed, TRUE); } static VOID HEXEDIT_Cut(PHEXEDIT_DATA hed) { - HEXEDIT_Copy(hed); - HEXEDIT_Delete(hed); + HEXEDIT_Copy(hed); + HEXEDIT_Delete(hed); } static VOID HEXEDIT_SelectAll(PHEXEDIT_DATA hed) { - INT bufsize; + INT bufsize; - bufsize = (hed->hBuffer ? (INT) LocalSize(hed->hBuffer) : 0); - hed->Index = hed->SelStart = 0; - hed->SelEnd = bufsize; - InvalidateRect(hed->hWndSelf, NULL, TRUE); - HEXEDIT_MoveCaret(hed, TRUE); + bufsize = (hed->hBuffer ? (INT) LocalSize(hed->hBuffer) : 0); + hed->Index = hed->SelStart = 0; + hed->SelEnd = bufsize; + InvalidateRect(hed->hWndSelf, NULL, TRUE); + HEXEDIT_MoveCaret(hed, TRUE); } /*** Control specific messages ************************************************/ @@ -567,111 +567,111 @@ HEXEDIT_SelectAll(PHEXEDIT_DATA hed) static LRESULT HEXEDIT_HEM_LOADBUFFER(PHEXEDIT_DATA hed, PVOID Buffer, DWORD Size) { - if(Buffer != NULL && Size > 0) - { - LPVOID buf; - - if(hed->MaxBuffer > 0 && Size > hed->MaxBuffer) + if(Buffer != NULL && Size > 0) { - Size = hed->MaxBuffer; - } + LPVOID buf; - if(hed->hBuffer) - { - if(Size > 0) - { - if(LocalSize(hed->hBuffer) != Size) + if(hed->MaxBuffer > 0 && Size > hed->MaxBuffer) { - hed->hBuffer = LocalReAlloc(hed->hBuffer, Size, LMEM_MOVEABLE | LMEM_ZEROINIT); + Size = hed->MaxBuffer; } - } - else - { - hed->hBuffer = LocalFree(hed->hBuffer); + + if(hed->hBuffer) + { + if(Size > 0) + { + if(LocalSize(hed->hBuffer) != Size) + { + hed->hBuffer = LocalReAlloc(hed->hBuffer, Size, LMEM_MOVEABLE | LMEM_ZEROINIT); + } + } + else + { + hed->hBuffer = LocalFree(hed->hBuffer); + hed->Index = 0; + HEXEDIT_Update(hed); + + return 0; + } + } + else if(Size > 0) + { + hed->hBuffer = LocalAlloc(LHND, Size); + } + + if(Size > 0) + { + buf = LocalLock(hed->hBuffer); + if(buf) + { + memcpy(buf, Buffer, Size); + } + else + Size = 0; + LocalUnlock(hed->hBuffer); + } + hed->Index = 0; HEXEDIT_Update(hed); - - return 0; - } + return Size; } - else if(Size > 0) + else if(hed->hBuffer) { - hed->hBuffer = LocalAlloc(LHND, Size); + hed->Index = 0; + hed->hBuffer = LocalFree(hed->hBuffer); + HEXEDIT_Update(hed); } - if(Size > 0) - { - buf = LocalLock(hed->hBuffer); - if(buf) - { - memcpy(buf, Buffer, Size); - } - else - Size = 0; - LocalUnlock(hed->hBuffer); - } - - hed->Index = 0; - HEXEDIT_Update(hed); - return Size; - } - else if(hed->hBuffer) - { - hed->Index = 0; - hed->hBuffer = LocalFree(hed->hBuffer); - HEXEDIT_Update(hed); - } - - return 0; + return 0; } static LRESULT HEXEDIT_HEM_COPYBUFFER(PHEXEDIT_DATA hed, PVOID Buffer, DWORD Size) { - size_t nCpy; + size_t nCpy; - if(!hed->hBuffer) - { - return 0; - } - - if(Buffer != NULL && Size > 0) - { - nCpy = min(Size, LocalSize(hed->hBuffer)); - if(nCpy > 0) + if(!hed->hBuffer) { - PVOID buf; - - buf = LocalLock(hed->hBuffer); - if(buf) - { - memcpy(Buffer, buf, nCpy); - } - else - nCpy = 0; - LocalUnlock(hed->hBuffer); + return 0; } - return nCpy; - } - return (LRESULT)LocalSize(hed->hBuffer); + if(Buffer != NULL && Size > 0) + { + nCpy = min(Size, LocalSize(hed->hBuffer)); + if(nCpy > 0) + { + PVOID buf; + + buf = LocalLock(hed->hBuffer); + if(buf) + { + memcpy(Buffer, buf, nCpy); + } + else + nCpy = 0; + LocalUnlock(hed->hBuffer); + } + return nCpy; + } + + return (LRESULT)LocalSize(hed->hBuffer); } static LRESULT HEXEDIT_HEM_SETMAXBUFFERSIZE(PHEXEDIT_DATA hed, DWORD nMaxSize) { - hed->MaxBuffer = nMaxSize; - if (hed->MaxBuffer == 0) - { - hed->hBuffer = LocalFree(hed->hBuffer); + hed->MaxBuffer = nMaxSize; + if (hed->MaxBuffer == 0) + { + hed->hBuffer = LocalFree(hed->hBuffer); + return 0; + } + if (hed->hBuffer) + hed->hBuffer = LocalReAlloc(hed->hBuffer, hed->MaxBuffer, LMEM_MOVEABLE); + else + hed->hBuffer = LocalAlloc(LMEM_MOVEABLE, hed->MaxBuffer); + HEXEDIT_Update(hed); return 0; - } - if (hed->hBuffer) - hed->hBuffer = LocalReAlloc(hed->hBuffer, hed->MaxBuffer, LMEM_MOVEABLE); - else - hed->hBuffer = LocalAlloc(LMEM_MOVEABLE, hed->MaxBuffer); - HEXEDIT_Update(hed); - return 0; } /*** Message Proc *************************************************************/ @@ -679,875 +679,875 @@ HEXEDIT_HEM_SETMAXBUFFERSIZE(PHEXEDIT_DATA hed, DWORD nMaxSize) static LRESULT HEXEDIT_WM_NCCREATE(HWND hWnd, CREATESTRUCT *cs) { - PHEXEDIT_DATA hed; + PHEXEDIT_DATA hed; - if(!(hed = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(HEXEDIT_DATA)))) - { - return FALSE; - } + if(!(hed = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(HEXEDIT_DATA)))) + { + return FALSE; + } - hed->hWndSelf = hWnd; - hed->hWndParent = cs->hwndParent; - hed->style = cs->style; + hed->hWndSelf = hWnd; + hed->hWndParent = cs->hwndParent; + hed->style = cs->style; - hed->ColumnsPerLine = 8; - hed->LeftMargin = 2; - hed->AddressSpacing = 2; - hed->SplitSpacing = 2; - hed->EditingField = TRUE; /* in hexdump field */ + hed->ColumnsPerLine = 8; + hed->LeftMargin = 2; + hed->AddressSpacing = 2; + hed->SplitSpacing = 2; + hed->EditingField = TRUE; /* in hexdump field */ - SetWindowLongPtr(hWnd, 0, (DWORD_PTR)hed); - HEXEDIT_Update(hed); + SetWindowLongPtr(hWnd, 0, (DWORD_PTR)hed); + HEXEDIT_Update(hed); - return TRUE; + return TRUE; } static LRESULT HEXEDIT_WM_NCDESTROY(PHEXEDIT_DATA hed) { - if(hed->hBuffer) - { - //while(LocalUnlock(hed->hBuffer)); - LocalFree(hed->hBuffer); - } + if(hed->hBuffer) + { + //while(LocalUnlock(hed->hBuffer)); + LocalFree(hed->hBuffer); + } - if(hed->hFont) - { - DeleteObject(hed->hFont); - } + if(hed->hFont) + { + DeleteObject(hed->hFont); + } - SetWindowLongPtr(hed->hWndSelf, 0, (DWORD_PTR)0); - HeapFree(GetProcessHeap(), 0, hed); + SetWindowLongPtr(hed->hWndSelf, 0, (DWORD_PTR)0); + HeapFree(GetProcessHeap(), 0, hed); - return 0; + return 0; } static LRESULT HEXEDIT_WM_CREATE(PHEXEDIT_DATA hed) { - UNREFERENCED_PARAMETER(hed); - return 1; + UNREFERENCED_PARAMETER(hed); + return 1; } static LRESULT HEXEDIT_WM_SETFOCUS(PHEXEDIT_DATA hed) { - CreateCaret(hed->hWndSelf, 0, 1, hed->LineHeight); - HEXEDIT_MoveCaret(hed, FALSE); - ShowCaret(hed->hWndSelf); - return 0; + CreateCaret(hed->hWndSelf, 0, 1, hed->LineHeight); + HEXEDIT_MoveCaret(hed, FALSE); + ShowCaret(hed->hWndSelf); + return 0; } static LRESULT HEXEDIT_WM_KILLFOCUS(PHEXEDIT_DATA hed) { - UNREFERENCED_PARAMETER(hed); - DestroyCaret(); - return 0; + UNREFERENCED_PARAMETER(hed); + DestroyCaret(); + return 0; } static LRESULT HEXEDIT_WM_VSCROLL(PHEXEDIT_DATA hed, WORD ThumbPosition, WORD SbCmd) { - int ScrollY; - SCROLLINFO si; + int ScrollY; + SCROLLINFO si; - UNREFERENCED_PARAMETER(ThumbPosition); + UNREFERENCED_PARAMETER(ThumbPosition); - ZeroMemory(&si, sizeof(SCROLLINFO)); - si.cbSize = sizeof(SCROLLINFO); - si.fMask = SIF_ALL; - GetScrollInfo(hed->hWndSelf, SB_VERT, &si); + ZeroMemory(&si, sizeof(SCROLLINFO)); + si.cbSize = sizeof(SCROLLINFO); + si.fMask = SIF_ALL; + GetScrollInfo(hed->hWndSelf, SB_VERT, &si); - ScrollY = si.nPos; - switch(SbCmd) - { + ScrollY = si.nPos; + switch(SbCmd) + { case SB_TOP: - si.nPos = si.nMin; - break; + si.nPos = si.nMin; + break; case SB_BOTTOM: - si.nPos = si.nMax; - break; + si.nPos = si.nMax; + break; case SB_LINEUP: - si.nPos--; - break; + si.nPos--; + break; case SB_LINEDOWN: - si.nPos++; - break; + si.nPos++; + break; case SB_PAGEUP: - si.nPos -= si.nPage; - break; + si.nPos -= si.nPage; + break; case SB_PAGEDOWN: - si.nPos += si.nPage; - break; + si.nPos += si.nPage; + break; case SB_THUMBTRACK: - si.nPos = si.nTrackPos; - break; - } + si.nPos = si.nTrackPos; + break; + } - si.fMask = SIF_POS; - SetScrollInfo(hed->hWndSelf, SB_VERT, &si, TRUE); - GetScrollInfo(hed->hWndSelf, SB_VERT, &si); + si.fMask = SIF_POS; + SetScrollInfo(hed->hWndSelf, SB_VERT, &si, TRUE); + GetScrollInfo(hed->hWndSelf, SB_VERT, &si); - if(si.nPos != ScrollY) - { - ScrollWindow(hed->hWndSelf, 0, (ScrollY - si.nPos) * hed->LineHeight, NULL, NULL); - UpdateWindow(hed->hWndSelf); - } + if(si.nPos != ScrollY) + { + ScrollWindow(hed->hWndSelf, 0, (ScrollY - si.nPos) * hed->LineHeight, NULL, NULL); + UpdateWindow(hed->hWndSelf); + } - return 0; + return 0; } static LRESULT HEXEDIT_WM_SETFONT(PHEXEDIT_DATA hed, HFONT hFont, BOOL bRedraw) { - HDC hDC; - TEXTMETRIC tm; - HFONT hOldFont = 0; + HDC hDC; + TEXTMETRIC tm; + HFONT hOldFont = 0; - if(hFont == 0) - { - hFont = HEXEDIT_GetFixedFont(); - } + if(hFont == 0) + { + hFont = HEXEDIT_GetFixedFont(); + } - hed->hFont = hFont; - hDC = GetDC(hed->hWndSelf); - if(hFont) - { - hOldFont = SelectObject(hDC, hFont); - } - GetTextMetrics(hDC, &tm); - hed->LineHeight = tm.tmHeight; - hed->CharWidth = tm.tmAveCharWidth; - if(hOldFont) - { - SelectObject(hDC, hOldFont); - } - ReleaseDC(hed->hWndSelf, hDC); + hed->hFont = hFont; + hDC = GetDC(hed->hWndSelf); + if(hFont) + { + hOldFont = SelectObject(hDC, hFont); + } + GetTextMetrics(hDC, &tm); + hed->LineHeight = tm.tmHeight; + hed->CharWidth = tm.tmAveCharWidth; + if(hOldFont) + { + SelectObject(hDC, hOldFont); + } + ReleaseDC(hed->hWndSelf, hDC); - if(bRedraw) - { - InvalidateRect(hed->hWndSelf, NULL, TRUE); - } + if(bRedraw) + { + InvalidateRect(hed->hWndSelf, NULL, TRUE); + } - return 0; + return 0; } static LRESULT HEXEDIT_WM_GETFONT(PHEXEDIT_DATA hed) { - return (LRESULT)hed->hFont; + return (LRESULT)hed->hFont; } static LRESULT HEXEDIT_WM_PAINT(PHEXEDIT_DATA hed) { - PAINTSTRUCT ps; - SCROLLINFO si; - RECT rc; - HBITMAP hbmp, hbmpold; - INT nLines, nFirst; - HFONT hOldFont; - HDC hTempDC; - DWORD height; + PAINTSTRUCT ps; + SCROLLINFO si; + RECT rc; + HBITMAP hbmp, hbmpold; + INT nLines, nFirst; + HFONT hOldFont; + HDC hTempDC; + DWORD height; - if(GetUpdateRect(hed->hWndSelf, &rc, FALSE) && (hed->LineHeight > 0)) - { - ZeroMemory(&si, sizeof(SCROLLINFO)); - si.cbSize = sizeof(SCROLLINFO); - si.fMask = SIF_POS; - GetScrollInfo(hed->hWndSelf, SB_VERT, &si); + if(GetUpdateRect(hed->hWndSelf, &rc, FALSE) && (hed->LineHeight > 0)) + { + ZeroMemory(&si, sizeof(SCROLLINFO)); + si.cbSize = sizeof(SCROLLINFO); + si.fMask = SIF_POS; + GetScrollInfo(hed->hWndSelf, SB_VERT, &si); - height = (rc.bottom - rc.top); - nLines = height / hed->LineHeight; - if((height % hed->LineHeight) > 0) - { - nLines++; - } - if(nLines > hed->nLines - si.nPos) - { - nLines = hed->nLines - si.nPos; - } - nFirst = rc.top / hed->LineHeight; + height = (rc.bottom - rc.top); + nLines = height / hed->LineHeight; + if((height % hed->LineHeight) > 0) + { + nLines++; + } + if(nLines > hed->nLines - si.nPos) + { + nLines = hed->nLines - si.nPos; + } + nFirst = rc.top / hed->LineHeight; - BeginPaint(hed->hWndSelf, &ps); - if(!(hTempDC = CreateCompatibleDC(ps.hdc))) - { - FillRect(ps.hdc, &rc, (HBRUSH)(COLOR_WINDOW + 1)); - goto epaint; - } - if(!(hbmp = CreateCompatibleBitmap(ps.hdc, ps.rcPaint.right, ps.rcPaint.bottom))) - { - FillRect(ps.hdc, &rc, (HBRUSH)(COLOR_WINDOW + 1)); - DeleteDC(hTempDC); - goto epaint; - } - hbmpold = SelectObject(hTempDC, hbmp); - hOldFont = SelectObject(hTempDC, hed->hFont); - HEXEDIT_PaintLines(hed, hTempDC, si.nPos, nFirst, nFirst + nLines, &ps.rcPaint); - BitBlt(ps.hdc, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, hTempDC, rc.left, rc.top, SRCCOPY); - SelectObject(hTempDC, hOldFont); - SelectObject(hTempDC, hbmpold); + BeginPaint(hed->hWndSelf, &ps); + if(!(hTempDC = CreateCompatibleDC(ps.hdc))) + { + FillRect(ps.hdc, &rc, (HBRUSH)(COLOR_WINDOW + 1)); + goto epaint; + } + if(!(hbmp = CreateCompatibleBitmap(ps.hdc, ps.rcPaint.right, ps.rcPaint.bottom))) + { + FillRect(ps.hdc, &rc, (HBRUSH)(COLOR_WINDOW + 1)); + DeleteDC(hTempDC); + goto epaint; + } + hbmpold = SelectObject(hTempDC, hbmp); + hOldFont = SelectObject(hTempDC, hed->hFont); + HEXEDIT_PaintLines(hed, hTempDC, si.nPos, nFirst, nFirst + nLines, &ps.rcPaint); + BitBlt(ps.hdc, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, hTempDC, rc.left, rc.top, SRCCOPY); + SelectObject(hTempDC, hOldFont); + SelectObject(hTempDC, hbmpold); - DeleteObject(hbmp); - DeleteDC(hTempDC); + DeleteObject(hbmp); + DeleteDC(hTempDC); epaint: - EndPaint(hed->hWndSelf, &ps); - } + EndPaint(hed->hWndSelf, &ps); + } - return 0; + return 0; } static LRESULT HEXEDIT_WM_MOUSEWHEEL(PHEXEDIT_DATA hed, int cyMoveLines, WORD ButtonsDown, LPPOINTS MousePos) { - SCROLLINFO si; - int ScrollY; + SCROLLINFO si; + int ScrollY; - UNREFERENCED_PARAMETER(ButtonsDown); - UNREFERENCED_PARAMETER(MousePos); + UNREFERENCED_PARAMETER(ButtonsDown); + UNREFERENCED_PARAMETER(MousePos); - SetFocus(hed->hWndSelf); + SetFocus(hed->hWndSelf); - si.cbSize = sizeof(SCROLLINFO); - si.fMask = SIF_ALL; - GetScrollInfo(hed->hWndSelf, SB_VERT, &si); + si.cbSize = sizeof(SCROLLINFO); + si.fMask = SIF_ALL; + GetScrollInfo(hed->hWndSelf, SB_VERT, &si); - ScrollY = si.nPos; + ScrollY = si.nPos; - si.fMask = SIF_POS; - si.nPos += cyMoveLines; - SetScrollInfo(hed->hWndSelf, SB_VERT, &si, TRUE); + si.fMask = SIF_POS; + si.nPos += cyMoveLines; + SetScrollInfo(hed->hWndSelf, SB_VERT, &si, TRUE); - GetScrollInfo(hed->hWndSelf, SB_VERT, &si); - if(si.nPos != ScrollY) - { - ScrollWindow(hed->hWndSelf, 0, (ScrollY - si.nPos) * hed->LineHeight, NULL, NULL); - UpdateWindow(hed->hWndSelf); - } + GetScrollInfo(hed->hWndSelf, SB_VERT, &si); + if(si.nPos != ScrollY) + { + ScrollWindow(hed->hWndSelf, 0, (ScrollY - si.nPos) * hed->LineHeight, NULL, NULL); + UpdateWindow(hed->hWndSelf); + } - return 0; + return 0; } static LRESULT HEXEDIT_WM_GETDLGCODE(LPMSG Msg) { - UNREFERENCED_PARAMETER(Msg); - return DLGC_WANTARROWS | DLGC_WANTCHARS; + UNREFERENCED_PARAMETER(Msg); + return DLGC_WANTARROWS | DLGC_WANTCHARS; } static LRESULT HEXEDIT_WM_LBUTTONDOWN(PHEXEDIT_DATA hed, INT Buttons, POINTS Pt) { - BOOL NewField; - POINT EditPos; - DWORD Hit; + BOOL NewField; + POINT EditPos; + DWORD Hit; - UNREFERENCED_PARAMETER(Buttons); - SetFocus(hed->hWndSelf); + UNREFERENCED_PARAMETER(Buttons); + SetFocus(hed->hWndSelf); - if (GetAsyncKeyState(VK_SHIFT) < 0) - { - if (hed->EditingField) - hed->Index = HEXEDIT_IndexFromPoint(hed, Pt, HEHT_HEXDUMP, &EditPos, &NewField); + if (GetAsyncKeyState(VK_SHIFT) < 0) + { + if (hed->EditingField) + hed->Index = HEXEDIT_IndexFromPoint(hed, Pt, HEHT_HEXDUMP, &EditPos, &NewField); + else + hed->Index = HEXEDIT_IndexFromPoint(hed, Pt, HEHT_ASCIIDUMP, &EditPos, &NewField); + hed->SelEnd = hed->Index; + } else - hed->Index = HEXEDIT_IndexFromPoint(hed, Pt, HEHT_ASCIIDUMP, &EditPos, &NewField); - hed->SelEnd = hed->Index; - } - else - { - Hit = HEXEDIT_HitRegionTest(hed, Pt); - hed->Index = HEXEDIT_IndexFromPoint(hed, Pt, Hit, &EditPos, &NewField); - hed->SelStart = hed->SelEnd = hed->Index; - hed->EditingField = NewField; - SetCapture(hed->hWndSelf); - } - hed->CaretCol = EditPos.x; - hed->CaretLine = EditPos.y; - hed->InMid = FALSE; - InvalidateRect(hed->hWndSelf, NULL, FALSE); - HEXEDIT_MoveCaret(hed, TRUE); + { + Hit = HEXEDIT_HitRegionTest(hed, Pt); + hed->Index = HEXEDIT_IndexFromPoint(hed, Pt, Hit, &EditPos, &NewField); + hed->SelStart = hed->SelEnd = hed->Index; + hed->EditingField = NewField; + SetCapture(hed->hWndSelf); + } + hed->CaretCol = EditPos.x; + hed->CaretLine = EditPos.y; + hed->InMid = FALSE; + InvalidateRect(hed->hWndSelf, NULL, FALSE); + HEXEDIT_MoveCaret(hed, TRUE); - return 0; + return 0; } static LRESULT HEXEDIT_WM_LBUTTONUP(PHEXEDIT_DATA hed, INT Buttons, POINTS Pt) { - BOOL NewField; - POINT EditPos; - if (GetCapture() == hed->hWndSelf) - { - if (hed->EditingField) - hed->Index = HEXEDIT_IndexFromPoint(hed, Pt, HEHT_HEXDUMP, &EditPos, &NewField); - else - hed->Index = HEXEDIT_IndexFromPoint(hed, Pt, HEHT_ASCIIDUMP, &EditPos, &NewField); - hed->CaretCol = EditPos.x; - hed->CaretLine = EditPos.y; - hed->SelEnd = hed->Index; - ReleaseCapture(); - InvalidateRect(hed->hWndSelf, NULL, FALSE); - HEXEDIT_MoveCaret(hed, TRUE); - } - return 0; + BOOL NewField; + POINT EditPos; + if (GetCapture() == hed->hWndSelf) + { + if (hed->EditingField) + hed->Index = HEXEDIT_IndexFromPoint(hed, Pt, HEHT_HEXDUMP, &EditPos, &NewField); + else + hed->Index = HEXEDIT_IndexFromPoint(hed, Pt, HEHT_ASCIIDUMP, &EditPos, &NewField); + hed->CaretCol = EditPos.x; + hed->CaretLine = EditPos.y; + hed->SelEnd = hed->Index; + ReleaseCapture(); + InvalidateRect(hed->hWndSelf, NULL, FALSE); + HEXEDIT_MoveCaret(hed, TRUE); + } + return 0; } static LRESULT HEXEDIT_WM_MOUSEMOVE(PHEXEDIT_DATA hed, INT Buttons, POINTS Pt) { - BOOL NewField; - POINT EditPos; - if (GetCapture() == hed->hWndSelf) - { - if (hed->EditingField) - hed->Index = HEXEDIT_IndexFromPoint(hed, Pt, HEHT_HEXDUMP, &EditPos, &NewField); - else - hed->Index = HEXEDIT_IndexFromPoint(hed, Pt, HEHT_ASCIIDUMP, &EditPos, &NewField); - hed->CaretCol = EditPos.x; - hed->CaretLine = EditPos.y; - hed->SelEnd = hed->Index; - InvalidateRect(hed->hWndSelf, NULL, FALSE); - HEXEDIT_MoveCaret(hed, TRUE); - } - return 0; + BOOL NewField; + POINT EditPos; + if (GetCapture() == hed->hWndSelf) + { + if (hed->EditingField) + hed->Index = HEXEDIT_IndexFromPoint(hed, Pt, HEHT_HEXDUMP, &EditPos, &NewField); + else + hed->Index = HEXEDIT_IndexFromPoint(hed, Pt, HEHT_ASCIIDUMP, &EditPos, &NewField); + hed->CaretCol = EditPos.x; + hed->CaretLine = EditPos.y; + hed->SelEnd = hed->Index; + InvalidateRect(hed->hWndSelf, NULL, FALSE); + HEXEDIT_MoveCaret(hed, TRUE); + } + return 0; } static BOOL HEXEDIT_WM_KEYDOWN(PHEXEDIT_DATA hed, INT VkCode) { - size_t bufsize; - PBYTE buf; - INT i0, i1; + size_t bufsize; + PBYTE buf; + INT i0, i1; - if(GetKeyState(VK_MENU) & 0x8000) - { - return FALSE; - } + if(GetKeyState(VK_MENU) & 0x8000) + { + return FALSE; + } - bufsize = (hed->hBuffer ? LocalSize(hed->hBuffer) : 0); + bufsize = (hed->hBuffer ? LocalSize(hed->hBuffer) : 0); - if (hed->SelStart < hed->SelEnd) - { - i0 = hed->SelStart; - i1 = hed->SelEnd; - } - else - { - i0 = hed->SelEnd; - i1 = hed->SelStart; - } + if (hed->SelStart < hed->SelEnd) + { + i0 = hed->SelStart; + i1 = hed->SelEnd; + } + else + { + i0 = hed->SelEnd; + i1 = hed->SelStart; + } - switch(VkCode) - { + switch(VkCode) + { case 'X': - if (GetAsyncKeyState(VK_SHIFT) >= 0 && - GetAsyncKeyState(VK_CONTROL) < 0 && hed->SelStart != hed->SelEnd) - HEXEDIT_Cut(hed); - else - return TRUE; - break; + if (GetAsyncKeyState(VK_SHIFT) >= 0 && + GetAsyncKeyState(VK_CONTROL) < 0 && hed->SelStart != hed->SelEnd) + HEXEDIT_Cut(hed); + else + return TRUE; + break; case 'C': - if (GetAsyncKeyState(VK_SHIFT) >= 0 && - GetAsyncKeyState(VK_CONTROL) < 0 && hed->SelStart != hed->SelEnd) - HEXEDIT_Copy(hed); - else - return TRUE; - break; + if (GetAsyncKeyState(VK_SHIFT) >= 0 && + GetAsyncKeyState(VK_CONTROL) < 0 && hed->SelStart != hed->SelEnd) + HEXEDIT_Copy(hed); + else + return TRUE; + break; case 'V': - if (GetAsyncKeyState(VK_SHIFT) >= 0 && GetAsyncKeyState(VK_CONTROL) < 0) - HEXEDIT_Paste(hed); - else - return TRUE; - break; + if (GetAsyncKeyState(VK_SHIFT) >= 0 && GetAsyncKeyState(VK_CONTROL) < 0) + HEXEDIT_Paste(hed); + else + return TRUE; + break; case 'A': - if (GetAsyncKeyState(VK_SHIFT) >= 0 && GetAsyncKeyState(VK_CONTROL) < 0) - HEXEDIT_SelectAll(hed); - else - return TRUE; - break; + if (GetAsyncKeyState(VK_SHIFT) >= 0 && GetAsyncKeyState(VK_CONTROL) < 0) + HEXEDIT_SelectAll(hed); + else + return TRUE; + break; case VK_INSERT: - if (hed->SelStart != hed->SelEnd) - { - if (GetAsyncKeyState(VK_SHIFT) >= 0 && GetAsyncKeyState(VK_CONTROL) < 0) - HEXEDIT_Copy(hed); - } - if (GetAsyncKeyState(VK_SHIFT) < 0 && GetAsyncKeyState(VK_CONTROL) >= 0) - HEXEDIT_Paste(hed); - break; + if (hed->SelStart != hed->SelEnd) + { + if (GetAsyncKeyState(VK_SHIFT) >= 0 && GetAsyncKeyState(VK_CONTROL) < 0) + HEXEDIT_Copy(hed); + } + if (GetAsyncKeyState(VK_SHIFT) < 0 && GetAsyncKeyState(VK_CONTROL) >= 0) + HEXEDIT_Paste(hed); + break; case VK_DELETE: - if (GetAsyncKeyState(VK_SHIFT) < 0 && GetAsyncKeyState(VK_CONTROL) >= 0 && - hed->SelStart != hed->SelEnd) - HEXEDIT_Copy(hed); - if (i0 != i1) - { - buf = (PBYTE) LocalLock(hed->hBuffer); - if (buf) + if (GetAsyncKeyState(VK_SHIFT) < 0 && GetAsyncKeyState(VK_CONTROL) >= 0 && + hed->SelStart != hed->SelEnd) + HEXEDIT_Copy(hed); + if (i0 != i1) { - MoveMemory(buf + i0, buf + i1, bufsize - i1); - LocalUnlock(hed->hBuffer); + buf = (PBYTE) LocalLock(hed->hBuffer); + if (buf) + { + MoveMemory(buf + i0, buf + i1, bufsize - i1); + LocalUnlock(hed->hBuffer); + } + HexEdit_SetMaxBufferSize(hed->hWndSelf, bufsize - (i1 - i0)); + hed->InMid = FALSE; + hed->Index = hed->SelStart = hed->SelEnd = i0; + hed->CaretCol = hed->Index % hed->ColumnsPerLine; + hed->CaretLine = hed->Index / hed->ColumnsPerLine; } - HexEdit_SetMaxBufferSize(hed->hWndSelf, bufsize - (i1 - i0)); - hed->InMid = FALSE; - hed->Index = hed->SelStart = hed->SelEnd = i0; - hed->CaretCol = hed->Index % hed->ColumnsPerLine; - hed->CaretLine = hed->Index / hed->ColumnsPerLine; - } - else - { - if (hed->InMid && hed->EditingField) + else { - buf = (PBYTE) LocalLock(hed->hBuffer); - if (buf) - { - MoveMemory(buf + hed->Index, buf + hed->Index + 1, - bufsize - hed->Index - 1); - LocalUnlock(hed->hBuffer); - } - HexEdit_SetMaxBufferSize(hed->hWndSelf, bufsize - 1); - hed->InMid = FALSE; + if (hed->InMid && hed->EditingField) + { + buf = (PBYTE) LocalLock(hed->hBuffer); + if (buf) + { + MoveMemory(buf + hed->Index, buf + hed->Index + 1, + bufsize - hed->Index - 1); + LocalUnlock(hed->hBuffer); + } + HexEdit_SetMaxBufferSize(hed->hWndSelf, bufsize - 1); + hed->InMid = FALSE; + } + else if (hed->Index < bufsize) + { + buf = (PBYTE) LocalLock(hed->hBuffer); + if (buf) + { + MoveMemory(buf + hed->Index, buf + hed->Index + 1, + bufsize - hed->Index - 1); + LocalUnlock(hed->hBuffer); + } + HexEdit_SetMaxBufferSize(hed->hWndSelf, bufsize - 1); + } } - else if (hed->Index < bufsize) - { - buf = (PBYTE) LocalLock(hed->hBuffer); - if (buf) - { - MoveMemory(buf + hed->Index, buf + hed->Index + 1, - bufsize - hed->Index - 1); - LocalUnlock(hed->hBuffer); - } - HexEdit_SetMaxBufferSize(hed->hWndSelf, bufsize - 1); - } - } - InvalidateRect(hed->hWndSelf, NULL, TRUE); - HEXEDIT_MoveCaret(hed, TRUE); - break; + InvalidateRect(hed->hWndSelf, NULL, TRUE); + HEXEDIT_MoveCaret(hed, TRUE); + break; case VK_BACK: - if (i0 != i1) - { - buf = (PBYTE) LocalLock(hed->hBuffer); - if (buf) + if (i0 != i1) { - MoveMemory(buf + i0, buf + i1, bufsize - i1); - LocalUnlock(hed->hBuffer); - } - HexEdit_SetMaxBufferSize(hed->hWndSelf, bufsize - (i1 - i0)); - hed->InMid = FALSE; - hed->Index = hed->SelStart = hed->SelEnd = i0; - hed->CaretCol = hed->Index % hed->ColumnsPerLine; - hed->CaretLine = hed->Index / hed->ColumnsPerLine; - } - else - { - if (hed->InMid && hed->EditingField) - { - buf = (PBYTE) LocalLock(hed->hBuffer); - if (buf) - { - MoveMemory(buf + hed->Index, buf + hed->Index + 1, - bufsize - hed->Index - 1); - LocalUnlock(hed->hBuffer); - } - } - else if (hed->Index > 0) - { - buf = (PBYTE) LocalLock(hed->hBuffer); - if (buf) - { - MoveMemory(buf + hed->Index - 1, buf + hed->Index, - bufsize - hed->Index); - LocalUnlock(hed->hBuffer); - } - hed->Index--; - hed->SelStart = hed->SelEnd = hed->Index; - hed->CaretCol = hed->Index % hed->ColumnsPerLine; - hed->CaretLine = hed->Index / hed->ColumnsPerLine; + buf = (PBYTE) LocalLock(hed->hBuffer); + if (buf) + { + MoveMemory(buf + i0, buf + i1, bufsize - i1); + LocalUnlock(hed->hBuffer); + } + HexEdit_SetMaxBufferSize(hed->hWndSelf, bufsize - (i1 - i0)); + hed->InMid = FALSE; + hed->Index = hed->SelStart = hed->SelEnd = i0; + hed->CaretCol = hed->Index % hed->ColumnsPerLine; + hed->CaretLine = hed->Index / hed->ColumnsPerLine; } else - return TRUE; - HexEdit_SetMaxBufferSize(hed->hWndSelf, bufsize - 1); - hed->InMid = FALSE; - } - InvalidateRect(hed->hWndSelf, NULL, TRUE); - HEXEDIT_MoveCaret(hed, TRUE); - break; + { + if (hed->InMid && hed->EditingField) + { + buf = (PBYTE) LocalLock(hed->hBuffer); + if (buf) + { + MoveMemory(buf + hed->Index, buf + hed->Index + 1, + bufsize - hed->Index - 1); + LocalUnlock(hed->hBuffer); + } + } + else if (hed->Index > 0) + { + buf = (PBYTE) LocalLock(hed->hBuffer); + if (buf) + { + MoveMemory(buf + hed->Index - 1, buf + hed->Index, + bufsize - hed->Index); + LocalUnlock(hed->hBuffer); + } + hed->Index--; + hed->SelStart = hed->SelEnd = hed->Index; + hed->CaretCol = hed->Index % hed->ColumnsPerLine; + hed->CaretLine = hed->Index / hed->ColumnsPerLine; + } + else + return TRUE; + HexEdit_SetMaxBufferSize(hed->hWndSelf, bufsize - 1); + hed->InMid = FALSE; + } + InvalidateRect(hed->hWndSelf, NULL, TRUE); + HEXEDIT_MoveCaret(hed, TRUE); + break; case VK_LEFT: - if (hed->Index > 0) - { - hed->Index--; - if (GetAsyncKeyState(VK_SHIFT) < 0) - hed->SelEnd = hed->Index; - else - hed->SelStart = hed->SelEnd = hed->Index; - hed->CaretCol = hed->Index % hed->ColumnsPerLine; - hed->CaretLine = hed->Index / hed->ColumnsPerLine; - hed->InMid = FALSE; - InvalidateRect(hed->hWndSelf, NULL, TRUE); - HEXEDIT_MoveCaret(hed, TRUE); - } - break; + if (hed->Index > 0) + { + hed->Index--; + if (GetAsyncKeyState(VK_SHIFT) < 0) + hed->SelEnd = hed->Index; + else + hed->SelStart = hed->SelEnd = hed->Index; + hed->CaretCol = hed->Index % hed->ColumnsPerLine; + hed->CaretLine = hed->Index / hed->ColumnsPerLine; + hed->InMid = FALSE; + InvalidateRect(hed->hWndSelf, NULL, TRUE); + HEXEDIT_MoveCaret(hed, TRUE); + } + break; case VK_RIGHT: - if (hed->Index < (INT)bufsize) - { - hed->Index++; - if (GetAsyncKeyState(VK_SHIFT) < 0) - hed->SelEnd = hed->Index; - else - hed->SelStart = hed->SelEnd = hed->Index; - hed->CaretCol = hed->Index % hed->ColumnsPerLine; - hed->CaretLine = hed->Index / hed->ColumnsPerLine; - hed->InMid = FALSE; - InvalidateRect(hed->hWndSelf, NULL, TRUE); - HEXEDIT_MoveCaret(hed, TRUE); - } - break; + if (hed->Index < (INT)bufsize) + { + hed->Index++; + if (GetAsyncKeyState(VK_SHIFT) < 0) + hed->SelEnd = hed->Index; + else + hed->SelStart = hed->SelEnd = hed->Index; + hed->CaretCol = hed->Index % hed->ColumnsPerLine; + hed->CaretLine = hed->Index / hed->ColumnsPerLine; + hed->InMid = FALSE; + InvalidateRect(hed->hWndSelf, NULL, TRUE); + HEXEDIT_MoveCaret(hed, TRUE); + } + break; case VK_UP: - if (hed->Index >= hed->ColumnsPerLine) - { - hed->Index -= hed->ColumnsPerLine; - if (GetAsyncKeyState(VK_SHIFT) < 0) - hed->SelEnd = hed->Index; + if (hed->Index >= hed->ColumnsPerLine) + { + hed->Index -= hed->ColumnsPerLine; + if (GetAsyncKeyState(VK_SHIFT) < 0) + hed->SelEnd = hed->Index; + else + hed->SelStart = hed->SelEnd = hed->Index; + hed->CaretCol = hed->Index % hed->ColumnsPerLine; + hed->CaretLine = hed->Index / hed->ColumnsPerLine; + hed->InMid = FALSE; + InvalidateRect(hed->hWndSelf, NULL, TRUE); + HEXEDIT_MoveCaret(hed, TRUE); + } + break; + + case VK_DOWN: + if (hed->Index + hed->ColumnsPerLine <= (INT) bufsize) + hed->Index += hed->ColumnsPerLine; else - hed->SelStart = hed->SelEnd = hed->Index; + hed->Index = bufsize; hed->CaretCol = hed->Index % hed->ColumnsPerLine; hed->CaretLine = hed->Index / hed->ColumnsPerLine; + if (GetAsyncKeyState(VK_SHIFT) < 0) + hed->SelEnd = hed->Index; + else + hed->SelStart = hed->SelEnd = hed->Index; hed->InMid = FALSE; InvalidateRect(hed->hWndSelf, NULL, TRUE); HEXEDIT_MoveCaret(hed, TRUE); - } - break; - - case VK_DOWN: - if (hed->Index + hed->ColumnsPerLine <= (INT) bufsize) - hed->Index += hed->ColumnsPerLine; - else - hed->Index = bufsize; - hed->CaretCol = hed->Index % hed->ColumnsPerLine; - hed->CaretLine = hed->Index / hed->ColumnsPerLine; - if (GetAsyncKeyState(VK_SHIFT) < 0) - hed->SelEnd = hed->Index; - else - hed->SelStart = hed->SelEnd = hed->Index; - hed->InMid = FALSE; - InvalidateRect(hed->hWndSelf, NULL, TRUE); - HEXEDIT_MoveCaret(hed, TRUE); - break; + break; default: - return TRUE; - } + return TRUE; + } - return FALSE; + return FALSE; } static BOOL HEXEDIT_WM_CHAR(PHEXEDIT_DATA hed, WCHAR ch) { - size_t bufsize; - PBYTE buf; - INT i0, i1; + size_t bufsize; + PBYTE buf; + INT i0, i1; - bufsize = (hed->hBuffer ? LocalSize(hed->hBuffer) : 0); - if (hed->SelStart < hed->SelEnd) - { - i0 = hed->SelStart; - i1 = hed->SelEnd; - } - else - { - i0 = hed->SelEnd; - i1 = hed->SelStart; - } - if (!hed->EditingField) - { - if (0x20 <= ch && ch <= 0xFF) + bufsize = (hed->hBuffer ? LocalSize(hed->hBuffer) : 0); + if (hed->SelStart < hed->SelEnd) { - if (hed->SelStart != hed->SelEnd) - { - buf = (PBYTE) LocalLock(hed->hBuffer); - if (buf) - { - MoveMemory(buf + i0, buf + i1, bufsize - i1); - LocalUnlock(hed->hBuffer); - } - HexEdit_SetMaxBufferSize(hed->hWndSelf, bufsize - (i1 - i0)); - hed->InMid = FALSE; - bufsize = (hed->hBuffer ? LocalSize(hed->hBuffer) : 0); - hed->Index = hed->SelStart = hed->SelEnd = i0; - } - HexEdit_SetMaxBufferSize(hed->hWndSelf, bufsize + 1); - buf = (PBYTE) LocalLock(hed->hBuffer); - if (buf) - { - MoveMemory(buf + hed->Index + 1, buf + hed->Index, - bufsize - hed->Index); - buf[hed->Index] = ch; - LocalUnlock(hed->hBuffer); - } - hed->Index++; - hed->CaretCol = hed->Index % hed->ColumnsPerLine; - hed->CaretLine = hed->Index / hed->ColumnsPerLine; - InvalidateRect(hed->hWndSelf, NULL, TRUE); - HEXEDIT_MoveCaret(hed, TRUE); - return FALSE; + i0 = hed->SelStart; + i1 = hed->SelEnd; } - } - else - { - if (('0' <= ch && ch <= '9') || ('A' <= ch && ch <= 'F') || - ('a' <= ch && ch <= 'f')) + else { - if (hed->SelStart != hed->SelEnd) - { - buf = (PBYTE) LocalLock(hed->hBuffer); - if (buf) - { - MoveMemory(buf + i0, buf + i1, bufsize - i1); - LocalUnlock(hed->hBuffer); - } - HexEdit_SetMaxBufferSize(hed->hWndSelf, bufsize - (i1 - i0)); - hed->InMid = FALSE; - bufsize = (hed->hBuffer ? LocalSize(hed->hBuffer) : 0); - hed->Index = hed->SelStart = hed->SelEnd = i0; - } - if (hed->InMid) - { - buf = (PBYTE) LocalLock(hed->hBuffer); - if (buf) - { - if ('0' <= ch && ch <= '9') - buf[hed->Index] |= ch - '0'; - else if ('A' <= ch && ch <= 'F') - buf[hed->Index] |= ch + 10 - 'A'; - else if ('a' <= ch && ch <= 'f') - buf[hed->Index] |= ch + 10 - 'a'; - LocalUnlock(hed->hBuffer); - } - hed->InMid = FALSE; - hed->Index++; - } - else - { - HexEdit_SetMaxBufferSize(hed->hWndSelf, bufsize + 1); - buf = (PBYTE) LocalLock(hed->hBuffer); - if (buf) - { - MoveMemory(buf + hed->Index + 1, buf + hed->Index, - bufsize - hed->Index); - if ('0' <= ch && ch <= '9') - buf[hed->Index] = (ch - '0') << 4; - else if ('A' <= ch && ch <= 'F') - buf[hed->Index] = (ch + 10 - 'A') << 4; - else if ('a' <= ch && ch <= 'f') - buf[hed->Index] = (ch + 10 - 'a') << 4; - LocalUnlock(hed->hBuffer); - } - hed->InMid = TRUE; - } - hed->CaretCol = hed->Index % hed->ColumnsPerLine; - hed->CaretLine = hed->Index / hed->ColumnsPerLine; - InvalidateRect(hed->hWndSelf, NULL, TRUE); - HEXEDIT_MoveCaret(hed, TRUE); - return FALSE; + i0 = hed->SelEnd; + i1 = hed->SelStart; } - } - return TRUE; + if (!hed->EditingField) + { + if (0x20 <= ch && ch <= 0xFF) + { + if (hed->SelStart != hed->SelEnd) + { + buf = (PBYTE) LocalLock(hed->hBuffer); + if (buf) + { + MoveMemory(buf + i0, buf + i1, bufsize - i1); + LocalUnlock(hed->hBuffer); + } + HexEdit_SetMaxBufferSize(hed->hWndSelf, bufsize - (i1 - i0)); + hed->InMid = FALSE; + bufsize = (hed->hBuffer ? LocalSize(hed->hBuffer) : 0); + hed->Index = hed->SelStart = hed->SelEnd = i0; + } + HexEdit_SetMaxBufferSize(hed->hWndSelf, bufsize + 1); + buf = (PBYTE) LocalLock(hed->hBuffer); + if (buf) + { + MoveMemory(buf + hed->Index + 1, buf + hed->Index, + bufsize - hed->Index); + buf[hed->Index] = ch; + LocalUnlock(hed->hBuffer); + } + hed->Index++; + hed->CaretCol = hed->Index % hed->ColumnsPerLine; + hed->CaretLine = hed->Index / hed->ColumnsPerLine; + InvalidateRect(hed->hWndSelf, NULL, TRUE); + HEXEDIT_MoveCaret(hed, TRUE); + return FALSE; + } + } + else + { + if (('0' <= ch && ch <= '9') || ('A' <= ch && ch <= 'F') || + ('a' <= ch && ch <= 'f')) + { + if (hed->SelStart != hed->SelEnd) + { + buf = (PBYTE) LocalLock(hed->hBuffer); + if (buf) + { + MoveMemory(buf + i0, buf + i1, bufsize - i1); + LocalUnlock(hed->hBuffer); + } + HexEdit_SetMaxBufferSize(hed->hWndSelf, bufsize - (i1 - i0)); + hed->InMid = FALSE; + bufsize = (hed->hBuffer ? LocalSize(hed->hBuffer) : 0); + hed->Index = hed->SelStart = hed->SelEnd = i0; + } + if (hed->InMid) + { + buf = (PBYTE) LocalLock(hed->hBuffer); + if (buf) + { + if ('0' <= ch && ch <= '9') + buf[hed->Index] |= ch - '0'; + else if ('A' <= ch && ch <= 'F') + buf[hed->Index] |= ch + 10 - 'A'; + else if ('a' <= ch && ch <= 'f') + buf[hed->Index] |= ch + 10 - 'a'; + LocalUnlock(hed->hBuffer); + } + hed->InMid = FALSE; + hed->Index++; + } + else + { + HexEdit_SetMaxBufferSize(hed->hWndSelf, bufsize + 1); + buf = (PBYTE) LocalLock(hed->hBuffer); + if (buf) + { + MoveMemory(buf + hed->Index + 1, buf + hed->Index, + bufsize - hed->Index); + if ('0' <= ch && ch <= '9') + buf[hed->Index] = (ch - '0') << 4; + else if ('A' <= ch && ch <= 'F') + buf[hed->Index] = (ch + 10 - 'A') << 4; + else if ('a' <= ch && ch <= 'f') + buf[hed->Index] = (ch + 10 - 'a') << 4; + LocalUnlock(hed->hBuffer); + } + hed->InMid = TRUE; + } + hed->CaretCol = hed->Index % hed->ColumnsPerLine; + hed->CaretLine = hed->Index / hed->ColumnsPerLine; + InvalidateRect(hed->hWndSelf, NULL, TRUE); + HEXEDIT_MoveCaret(hed, TRUE); + return FALSE; + } + } + return TRUE; } static LRESULT HEXEDIT_WM_SIZE(PHEXEDIT_DATA hed, DWORD sType, WORD NewWidth, WORD NewHeight) { - UNREFERENCED_PARAMETER(sType); - UNREFERENCED_PARAMETER(NewHeight); - UNREFERENCED_PARAMETER(NewWidth); - HEXEDIT_Update(hed); - return 0; + UNREFERENCED_PARAMETER(sType); + UNREFERENCED_PARAMETER(NewHeight); + UNREFERENCED_PARAMETER(NewWidth); + HEXEDIT_Update(hed); + return 0; } static VOID HEXEDIT_WM_CONTEXTMENU(PHEXEDIT_DATA hed, INT x, INT y) { - HMENU hMenu; - RECT rc; + HMENU hMenu; + RECT rc; - if (x == -1 && y == -1) - { - GetWindowRect(hed->hWndSelf, &rc); - x = rc.left; - y = rc.top; - } + if (x == -1 && y == -1) + { + GetWindowRect(hed->hWndSelf, &rc); + x = rc.left; + y = rc.top; + } - hMenu = GetSubMenu(hPopupMenus, PM_HEXEDIT); - if (hed->SelStart == hed->SelEnd) - { - EnableMenuItem(hMenu, ID_HEXEDIT_CUT, MF_GRAYED); - EnableMenuItem(hMenu, ID_HEXEDIT_COPY, MF_GRAYED); - EnableMenuItem(hMenu, ID_HEXEDIT_PASTE, MF_GRAYED); - EnableMenuItem(hMenu, ID_HEXEDIT_DELETE, MF_GRAYED); - } - else - { - EnableMenuItem(hMenu, ID_HEXEDIT_CUT, MF_ENABLED); - EnableMenuItem(hMenu, ID_HEXEDIT_COPY, MF_ENABLED); - EnableMenuItem(hMenu, ID_HEXEDIT_PASTE, MF_ENABLED); - EnableMenuItem(hMenu, ID_HEXEDIT_DELETE, MF_ENABLED); - } + hMenu = GetSubMenu(hPopupMenus, PM_HEXEDIT); + if (hed->SelStart == hed->SelEnd) + { + EnableMenuItem(hMenu, ID_HEXEDIT_CUT, MF_GRAYED); + EnableMenuItem(hMenu, ID_HEXEDIT_COPY, MF_GRAYED); + EnableMenuItem(hMenu, ID_HEXEDIT_PASTE, MF_GRAYED); + EnableMenuItem(hMenu, ID_HEXEDIT_DELETE, MF_GRAYED); + } + else + { + EnableMenuItem(hMenu, ID_HEXEDIT_CUT, MF_ENABLED); + EnableMenuItem(hMenu, ID_HEXEDIT_COPY, MF_ENABLED); + EnableMenuItem(hMenu, ID_HEXEDIT_PASTE, MF_ENABLED); + EnableMenuItem(hMenu, ID_HEXEDIT_DELETE, MF_ENABLED); + } - SetForegroundWindow(hed->hWndSelf); - TrackPopupMenu(hMenu, TPM_RIGHTBUTTON, x, y, 0, hed->hWndSelf, NULL); - PostMessage(hed->hWndSelf, WM_NULL, 0, 0); + SetForegroundWindow(hed->hWndSelf); + TrackPopupMenu(hMenu, TPM_RIGHTBUTTON, x, y, 0, hed->hWndSelf, NULL); + PostMessage(hed->hWndSelf, WM_NULL, 0, 0); } INT_PTR CALLBACK HexEditWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { - PHEXEDIT_DATA hed; - POINTS p; + PHEXEDIT_DATA hed; + POINTS p; - hed = (PHEXEDIT_DATA)(LONG_PTR)GetWindowLongPtr(hWnd, (DWORD_PTR)0); - switch(uMsg) - { + hed = (PHEXEDIT_DATA)(LONG_PTR)GetWindowLongPtr(hWnd, (DWORD_PTR)0); + switch(uMsg) + { case WM_ERASEBKGND: - return TRUE; + return TRUE; case WM_PAINT: - return HEXEDIT_WM_PAINT(hed); + return HEXEDIT_WM_PAINT(hed); case WM_KEYDOWN: - return HEXEDIT_WM_KEYDOWN(hed, (INT)wParam); + return HEXEDIT_WM_KEYDOWN(hed, (INT)wParam); case WM_CHAR: - return HEXEDIT_WM_CHAR(hed, (WCHAR)wParam); + return HEXEDIT_WM_CHAR(hed, (WCHAR)wParam); case WM_VSCROLL: - return HEXEDIT_WM_VSCROLL(hed, HIWORD(wParam), LOWORD(wParam)); + return HEXEDIT_WM_VSCROLL(hed, HIWORD(wParam), LOWORD(wParam)); case WM_SIZE: - return HEXEDIT_WM_SIZE(hed, (DWORD)wParam, LOWORD(lParam), HIWORD(lParam)); + return HEXEDIT_WM_SIZE(hed, (DWORD)wParam, LOWORD(lParam), HIWORD(lParam)); case WM_LBUTTONDOWN: { - p.x = LOWORD(lParam); - p.y = HIWORD(lParam); - return HEXEDIT_WM_LBUTTONDOWN(hed, (INT)wParam, p); + p.x = LOWORD(lParam); + p.y = HIWORD(lParam); + return HEXEDIT_WM_LBUTTONDOWN(hed, (INT)wParam, p); } case WM_LBUTTONUP: { - p.x = LOWORD(lParam); - p.y = HIWORD(lParam); - return HEXEDIT_WM_LBUTTONUP(hed, (INT)wParam, p); + p.x = LOWORD(lParam); + p.y = HIWORD(lParam); + return HEXEDIT_WM_LBUTTONUP(hed, (INT)wParam, p); } case WM_MOUSEMOVE: { - p.x = LOWORD(lParam); - p.y = HIWORD(lParam); - return HEXEDIT_WM_MOUSEMOVE(hed, (INT)wParam, p); + p.x = LOWORD(lParam); + p.y = HIWORD(lParam); + return HEXEDIT_WM_MOUSEMOVE(hed, (INT)wParam, p); } case WM_MOUSEWHEEL: { - UINT nScrollLines = 3; - int delta = 0; + UINT nScrollLines = 3; + int delta = 0; - SystemParametersInfoW(SPI_GETWHEELSCROLLLINES, 0, &nScrollLines, 0); - delta -= (SHORT)HIWORD(wParam); - if(abs(delta) >= WHEEL_DELTA && nScrollLines != 0) - { - p.x = LOWORD(lParam); - p.y = HIWORD(lParam); - return HEXEDIT_WM_MOUSEWHEEL(hed, nScrollLines * (delta / WHEEL_DELTA), LOWORD(wParam), &p); - } - break; + SystemParametersInfoW(SPI_GETWHEELSCROLLLINES, 0, &nScrollLines, 0); + delta -= (SHORT)HIWORD(wParam); + if(abs(delta) >= WHEEL_DELTA && nScrollLines != 0) + { + p.x = LOWORD(lParam); + p.y = HIWORD(lParam); + return HEXEDIT_WM_MOUSEWHEEL(hed, nScrollLines * (delta / WHEEL_DELTA), LOWORD(wParam), &p); + } + break; } case HEM_LOADBUFFER: - return HEXEDIT_HEM_LOADBUFFER(hed, (PVOID)wParam, (DWORD)lParam); + return HEXEDIT_HEM_LOADBUFFER(hed, (PVOID)wParam, (DWORD)lParam); case HEM_COPYBUFFER: - return HEXEDIT_HEM_COPYBUFFER(hed, (PVOID)wParam, (DWORD)lParam); + return HEXEDIT_HEM_COPYBUFFER(hed, (PVOID)wParam, (DWORD)lParam); case HEM_SETMAXBUFFERSIZE: - return HEXEDIT_HEM_SETMAXBUFFERSIZE(hed, (DWORD)lParam); + return HEXEDIT_HEM_SETMAXBUFFERSIZE(hed, (DWORD)lParam); case WM_SETFOCUS: - return HEXEDIT_WM_SETFOCUS(hed); + return HEXEDIT_WM_SETFOCUS(hed); case WM_KILLFOCUS: - return HEXEDIT_WM_KILLFOCUS(hed); + return HEXEDIT_WM_KILLFOCUS(hed); case WM_GETDLGCODE: - return HEXEDIT_WM_GETDLGCODE((LPMSG)lParam); + return HEXEDIT_WM_GETDLGCODE((LPMSG)lParam); case WM_SETFONT: - return HEXEDIT_WM_SETFONT(hed, (HFONT)wParam, (BOOL)LOWORD(lParam)); + return HEXEDIT_WM_SETFONT(hed, (HFONT)wParam, (BOOL)LOWORD(lParam)); case WM_GETFONT: - return HEXEDIT_WM_GETFONT(hed); + return HEXEDIT_WM_GETFONT(hed); case WM_CREATE: - return HEXEDIT_WM_CREATE(hed); + return HEXEDIT_WM_CREATE(hed); case WM_NCCREATE: - if(!hed) - { - return HEXEDIT_WM_NCCREATE(hWnd, (CREATESTRUCT*)lParam); - } - break; + if(!hed) + { + return HEXEDIT_WM_NCCREATE(hWnd, (CREATESTRUCT*)lParam); + } + break; case WM_NCDESTROY: - if(hed) - { - return HEXEDIT_WM_NCDESTROY(hed); - } - break; + if(hed) + { + return HEXEDIT_WM_NCDESTROY(hed); + } + break; case WM_CONTEXTMENU: - HEXEDIT_WM_CONTEXTMENU(hed, (short)LOWORD(lParam), (short)HIWORD(lParam)); - break; + HEXEDIT_WM_CONTEXTMENU(hed, (short)LOWORD(lParam), (short)HIWORD(lParam)); + break; case WM_COMMAND: - switch(LOWORD(wParam)) - { + switch(LOWORD(wParam)) + { case ID_HEXEDIT_CUT: - HEXEDIT_Cut(hed); - break; + HEXEDIT_Cut(hed); + break; case ID_HEXEDIT_COPY: - HEXEDIT_Copy(hed); - break; + HEXEDIT_Copy(hed); + break; case ID_HEXEDIT_PASTE: - HEXEDIT_Paste(hed); - break; + HEXEDIT_Paste(hed); + break; case ID_HEXEDIT_DELETE: - HEXEDIT_Delete(hed); - break; + HEXEDIT_Delete(hed); + break; case ID_HEXEDIT_SELECT_ALL: - HEXEDIT_SelectAll(hed); - break; - } - break; - } + HEXEDIT_SelectAll(hed); + break; + } + break; + } - return DefWindowProc(hWnd, uMsg, wParam, lParam); + return DefWindowProc(hWnd, uMsg, wParam, lParam); } diff --git a/reactos/base/applications/regedit/listview.c b/reactos/base/applications/regedit/listview.c index fcf9f52c8fe..c9408f2c327 100644 --- a/reactos/base/applications/regedit/listview.c +++ b/reactos/base/applications/regedit/listview.c @@ -96,23 +96,23 @@ VOID SetValueName(HWND hwndLV, LPCTSTR pszValueName) i = ListView_FindItem(hwndLV, -1, &fi); } ListView_SetItemState(hwndLV, i, LVIS_FOCUSED | LVIS_SELECTED, - LVIS_FOCUSED | LVIS_SELECTED); + LVIS_FOCUSED | LVIS_SELECTED); iListViewSelect = i; } BOOL IsDefaultValue(HWND hwndLV, int i) { - PLINE_INFO lineinfo; - LVITEM Item; + PLINE_INFO lineinfo; + LVITEM Item; - Item.mask = LVIF_PARAM; - Item.iItem = i; - if(ListView_GetItem(hwndLV, &Item)) - { - lineinfo = (PLINE_INFO)Item.lParam; - return lineinfo && (!lineinfo->name || !_tcscmp(lineinfo->name, _T(""))); - } - return FALSE; + Item.mask = LVIF_PARAM; + Item.iItem = i; + if(ListView_GetItem(hwndLV, &Item)) + { + lineinfo = (PLINE_INFO)Item.lParam; + return lineinfo && (!lineinfo->name || !_tcscmp(lineinfo->name, _T(""))); + } + return FALSE; } /******************************************************************************* @@ -129,7 +129,7 @@ static void AddEntryToList(HWND hwndLV, LPTSTR Name, DWORD dwValType, void* ValB linfo->val_len = dwCount; if(dwCount > 0) { - memcpy(&linfo[1], ValBuf, dwCount); + memcpy(&linfo[1], ValBuf, dwCount); } linfo->name = _tcsdup(Name); @@ -146,12 +146,12 @@ static void AddEntryToList(HWND hwndLV, LPTSTR Name, DWORD dwValType, void* ValB item.lParam = (LPARAM)linfo; switch(dwValType) { - case REG_SZ: - case REG_EXPAND_SZ: - case REG_MULTI_SZ: + case REG_SZ: + case REG_EXPAND_SZ: + case REG_MULTI_SZ: item.iImage = Image_String; break; - default: + default: item.iImage = Image_Bin; break; } @@ -162,87 +162,90 @@ static void AddEntryToList(HWND hwndLV, LPTSTR Name, DWORD dwValType, void* ValB #endif index = ListView_InsertItem(hwndLV, &item); - if (index != -1) { - switch (dwValType) { + if (index != -1) + { + switch (dwValType) + { case REG_SZ: case REG_EXPAND_SZ: if(dwCount > 0) { - ListView_SetItemText(hwndLV, index, 2, ValBuf); + ListView_SetItemText(hwndLV, index, 2, ValBuf); } else if(!ValExists) { - TCHAR buffer[255]; - /* load (value not set) string */ - LoadString(hInst, IDS_VALUE_NOT_SET, buffer, sizeof(buffer)/sizeof(TCHAR)); - ListView_SetItemText(hwndLV, index, 2, buffer); + TCHAR buffer[255]; + /* load (value not set) string */ + LoadString(hInst, IDS_VALUE_NOT_SET, buffer, sizeof(buffer)/sizeof(TCHAR)); + ListView_SetItemText(hwndLV, index, 2, buffer); } break; case REG_MULTI_SZ: + { + LPTSTR src, str; + if(dwCount >= 2) { - LPTSTR src, str; - if(dwCount >= 2) - { - src = (LPTSTR)ValBuf; - str = HeapAlloc(GetProcessHeap(), 0, dwCount); - if(str != NULL) - { - *str = _T('\0'); - /* concatenate all srings */ - while(*src != _T('\0')) - { - _tcscat(str, src); - _tcscat(str, _T(" ")); - src += _tcslen(src) + 1; - } - ListView_SetItemText(hwndLV, index, 2, str); - HeapFree(GetProcessHeap(), 0, str); - } - else - ListView_SetItemText(hwndLV, index, 2, _T("")); - } - else - ListView_SetItemText(hwndLV, index, 2, _T("")); - } - break; - case REG_DWORD: { - TCHAR buf[200]; - if(dwCount == sizeof(DWORD)) + src = (LPTSTR)ValBuf; + str = HeapAlloc(GetProcessHeap(), 0, dwCount); + if(str != NULL) { - wsprintf(buf, _T("0x%08x (%u)"), *(DWORD*)ValBuf, *(DWORD*)ValBuf); - } - else - { - LoadString(hInst, IDS_INVALID_DWORD, buf, sizeof(buf)/sizeof(TCHAR)); - } - ListView_SetItemText(hwndLV, index, 2, buf); - } - /* lpsRes = convertHexToDWORDStr(lpbData, dwLen); */ - break; - default: - { - unsigned int i; - LPBYTE pData = (LPBYTE)ValBuf; - LPTSTR strBinary; - if(dwCount > 0) - { - strBinary = HeapAlloc(GetProcessHeap(), 0, (dwCount * sizeof(TCHAR) * 3) + sizeof(TCHAR)); - for (i = 0; i < dwCount; i++) + *str = _T('\0'); + /* concatenate all srings */ + while(*src != _T('\0')) { - wsprintf( strBinary + i*3, _T("%02X "), pData[i] ); + _tcscat(str, src); + _tcscat(str, _T(" ")); + src += _tcslen(src) + 1; } - strBinary[dwCount * 3] = 0; - ListView_SetItemText(hwndLV, index, 2, strBinary); - HeapFree(GetProcessHeap(), 0, strBinary); + ListView_SetItemText(hwndLV, index, 2, str); + HeapFree(GetProcessHeap(), 0, str); } else - { - TCHAR szText[128]; - LoadString(hInst, IDS_BINARY_EMPTY, szText, sizeof(szText)/sizeof(TCHAR)); - ListView_SetItemText(hwndLV, index, 2, szText); - } + ListView_SetItemText(hwndLV, index, 2, _T("")); } - break; + else + ListView_SetItemText(hwndLV, index, 2, _T("")); + } + break; + case REG_DWORD: + { + TCHAR buf[200]; + if(dwCount == sizeof(DWORD)) + { + wsprintf(buf, _T("0x%08x (%u)"), *(DWORD*)ValBuf, *(DWORD*)ValBuf); + } + else + { + LoadString(hInst, IDS_INVALID_DWORD, buf, sizeof(buf)/sizeof(TCHAR)); + } + ListView_SetItemText(hwndLV, index, 2, buf); + } + /* lpsRes = convertHexToDWORDStr(lpbData, dwLen); */ + break; + default: + { + unsigned int i; + LPBYTE pData = (LPBYTE)ValBuf; + LPTSTR strBinary; + if(dwCount > 0) + { + strBinary = HeapAlloc(GetProcessHeap(), 0, (dwCount * sizeof(TCHAR) * 3) + sizeof(TCHAR)); + for (i = 0; i < dwCount; i++) + { + wsprintf( strBinary + i*3, _T("%02X "), pData[i] ); + } + strBinary[dwCount * 3] = 0; + ListView_SetItemText(hwndLV, index, 2, strBinary); + HeapFree(GetProcessHeap(), 0, strBinary); + } + else + { + TCHAR szText[128]; + LoadString(hInst, IDS_BINARY_EMPTY, szText, sizeof(szText)/sizeof(TCHAR)); + ListView_SetItemText(hwndLV, index, 2, szText); + } + } + break; } } } @@ -258,7 +261,8 @@ static BOOL CreateListColumns(HWND hWndListView) lvC.pszText = szText; /* Load the column labels from the resource file. */ - for (index = 0; index < MAX_LIST_COLUMNS; index++) { + for (index = 0; index < MAX_LIST_COLUMNS; index++) + { lvC.iSubItem = index; lvC.cx = default_column_widths[index]; lvC.fmt = column_alignment[index]; @@ -288,7 +292,7 @@ static BOOL InitListViewImageLists(HWND hwndLV) /* Fail if not all of the images were added. */ if (ImageList_GetImageCount(himl) < NUM_ICONS) { - return FALSE; + return FALSE; } /* Associate the image list with the tree view control. */ @@ -306,13 +310,15 @@ static void OnGetDispInfo(NMLVDISPINFO* plvdi) plvdi->item.pszText = NULL; plvdi->item.cchTextMax = 0; - switch (plvdi->item.iSubItem) { + switch (plvdi->item.iSubItem) + { case 0: LoadString(hInst, IDS_DEFAULT_VALUE_NAME, buffer, sizeof(buffer)/sizeof(TCHAR)); - plvdi->item.pszText = buffer; + plvdi->item.pszText = buffer; break; case 1: - switch (((LINE_INFO*)plvdi->item.lParam)->dwValType) { + switch (((LINE_INFO*)plvdi->item.lParam)->dwValType) + { case REG_NONE: plvdi->item.pszText = _T("REG_NONE"); break; @@ -349,13 +355,14 @@ static void OnGetDispInfo(NMLVDISPINFO* plvdi) case REG_QWORD: /* REG_QWORD_LITTLE_ENDIAN */ plvdi->item.pszText = _T("REG_QWORD"); break; - default: { + default: + { TCHAR buf2[200]; - LoadString(hInst, IDS_UNKNOWN_TYPE, buf2, sizeof(buf2)/sizeof(TCHAR)); - wsprintf(buffer, buf2, ((LINE_INFO*)plvdi->item.lParam)->dwValType); + LoadString(hInst, IDS_UNKNOWN_TYPE, buf2, sizeof(buf2)/sizeof(TCHAR)); + wsprintf(buffer, buf2, ((LINE_INFO*)plvdi->item.lParam)->dwValType); plvdi->item.pszText = buffer; break; - } + } } break; case 3: @@ -377,7 +384,8 @@ static int CALLBACK CompareFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSor if (g_columnToSort == 1 && l->dwValType != r->dwValType) return g_invertSort ? (int)r->dwValType - (int)l->dwValType : (int)l->dwValType - (int)r->dwValType; - if (g_columnToSort == 2) { + if (g_columnToSort == 2) + { /* FIXME: Sort on value */ } return g_invertSort ? _tcsicmp(r->name, l->name) : _tcsicmp(l->name, r->name); @@ -388,87 +396,89 @@ BOOL ListWndNotifyProc(HWND hWnd, WPARAM wParam, LPARAM lParam, BOOL *Result) NMLVDISPINFO* Info; UNREFERENCED_PARAMETER(wParam); *Result = TRUE; - switch (((LPNMHDR)lParam)->code) { - case LVN_GETDISPINFO: - OnGetDispInfo((NMLVDISPINFO*)lParam); - return TRUE; - case LVN_COLUMNCLICK: - if (g_columnToSort == (DWORD)((LPNMLISTVIEW)lParam)->iSubItem) - g_invertSort = !g_invertSort; - else { - g_columnToSort = ((LPNMLISTVIEW)lParam)->iSubItem; - g_invertSort = FALSE; - } + switch (((LPNMHDR)lParam)->code) + { + case LVN_GETDISPINFO: + OnGetDispInfo((NMLVDISPINFO*)lParam); + return TRUE; + case LVN_COLUMNCLICK: + if (g_columnToSort == (DWORD)((LPNMLISTVIEW)lParam)->iSubItem) + g_invertSort = !g_invertSort; + else + { + g_columnToSort = ((LPNMLISTVIEW)lParam)->iSubItem; + g_invertSort = FALSE; + } - (void)ListView_SortItems(hWnd, CompareFunc, (WPARAM)hWnd); - return TRUE; - case NM_DBLCLK: - case NM_RETURN: + (void)ListView_SortItems(hWnd, CompareFunc, (WPARAM)hWnd); + return TRUE; + case NM_DBLCLK: + case NM_RETURN: + { + SendMessage(hFrameWnd, WM_COMMAND, MAKEWPARAM(ID_EDIT_MODIFY, 0), 0); + } + return TRUE; + case NM_SETFOCUS: + g_pChildWnd->nFocusPanel = 0; + break; + case LVN_BEGINLABELEDIT: + Info = (NMLVDISPINFO*)lParam; + if(Info) + { + PLINE_INFO lineinfo = (PLINE_INFO)Info->item.lParam; + if(!lineinfo->name || !_tcscmp(lineinfo->name, _T(""))) { - SendMessage(hFrameWnd, WM_COMMAND, MAKEWPARAM(ID_EDIT_MODIFY, 0), 0); + *Result = TRUE; } - return TRUE; - case NM_SETFOCUS: - g_pChildWnd->nFocusPanel = 0; - break; - case LVN_BEGINLABELEDIT: - Info = (NMLVDISPINFO*)lParam; - if(Info) + else { - PLINE_INFO lineinfo = (PLINE_INFO)Info->item.lParam; - if(!lineinfo->name || !_tcscmp(lineinfo->name, _T(""))) + *Result = FALSE; + } + } + else + *Result = TRUE; + return TRUE; + case LVN_ENDLABELEDIT: + Info = (NMLVDISPINFO*)lParam; + if(Info && Info->item.pszText) + { + PLINE_INFO lineinfo = (PLINE_INFO)Info->item.lParam; + if(!lineinfo->name || !_tcscmp(lineinfo->name, _T(""))) + { + *Result = FALSE; + } + else + { + if(_tcslen(Info->item.pszText) == 0) { + TCHAR msg[128], caption[128]; + + LoadString(hInst, IDS_ERR_RENVAL_TOEMPTY, msg, sizeof(msg)/sizeof(TCHAR)); + LoadString(hInst, IDS_ERR_RENVAL_CAPTION, caption, sizeof(caption)/sizeof(TCHAR)); + MessageBox(0, msg, caption, 0); *Result = TRUE; } else { - *Result = FALSE; + HKEY hKeyRoot; + LPCTSTR keyPath; + LONG lResult; + + keyPath = GetItemPath(g_pChildWnd->hTreeWnd, 0, &hKeyRoot); + lResult = RenameValue(hKeyRoot, keyPath, Info->item.pszText, lineinfo->name); + lineinfo->name = realloc(lineinfo->name, (_tcslen(Info->item.pszText)+1)*sizeof(TCHAR)); + if (lineinfo->name != NULL) + _tcscpy(lineinfo->name, Info->item.pszText); + + *Result = TRUE; + return (lResult == ERROR_SUCCESS); } } - else - *Result = TRUE; - return TRUE; - case LVN_ENDLABELEDIT: - Info = (NMLVDISPINFO*)lParam; - if(Info && Info->item.pszText) - { - PLINE_INFO lineinfo = (PLINE_INFO)Info->item.lParam; - if(!lineinfo->name || !_tcscmp(lineinfo->name, _T(""))) - { - *Result = FALSE; - } - else - { - if(_tcslen(Info->item.pszText) == 0) - { - TCHAR msg[128], caption[128]; + } + else + *Result = TRUE; - LoadString(hInst, IDS_ERR_RENVAL_TOEMPTY, msg, sizeof(msg)/sizeof(TCHAR)); - LoadString(hInst, IDS_ERR_RENVAL_CAPTION, caption, sizeof(caption)/sizeof(TCHAR)); - MessageBox(0, msg, caption, 0); - *Result = TRUE; - } - else - { - HKEY hKeyRoot; - LPCTSTR keyPath; - LONG lResult; - - keyPath = GetItemPath(g_pChildWnd->hTreeWnd, 0, &hKeyRoot); - lResult = RenameValue(hKeyRoot, keyPath, Info->item.pszText, lineinfo->name); - lineinfo->name = realloc(lineinfo->name, (_tcslen(Info->item.pszText)+1)*sizeof(TCHAR)); - if (lineinfo->name != NULL) - _tcscpy(lineinfo->name, Info->item.pszText); - - *Result = TRUE; - return (lResult == ERROR_SUCCESS); - } - } - } - else - *Result = TRUE; - - return TRUE; + return TRUE; } return FALSE; } @@ -500,10 +510,11 @@ fail: void DestroyListView(HWND hwndLV) { INT count, i; - LVITEM item; + LVITEM item; count = ListView_GetItemCount(hwndLV); - for (i = 0; i < count; i++) { + for (i = 0; i < count; i++) + { item.mask = LVIF_PARAM; item.iItem = i; (void)ListView_GetItem(hwndLV, &item); @@ -555,7 +566,8 @@ BOOL RefreshListView(HWND hwndLV, HKEY hKey, LPCTSTR keyPath) /* AddEntryToList(hwndLV, _T("(Default)"), dwValType, ValBuf, dwValSize); */ /* } */ /* dwValSize = max_val_size; */ - while (RegEnumValue(hNewKey, dwIndex, ValName, &dwValNameLen, NULL, &dwValType, ValBuf, &dwValSize) == ERROR_SUCCESS) { + while (RegEnumValue(hNewKey, dwIndex, ValName, &dwValNameLen, NULL, &dwValType, ValBuf, &dwValSize) == ERROR_SUCCESS) + { /* Add a terminating 0 character. Usually this is only necessary for strings. */ ValBuf[dwValSize] = 0; #ifdef UNICODE @@ -568,7 +580,7 @@ BOOL RefreshListView(HWND hwndLV, HKEY hKey, LPCTSTR keyPath) ++dwIndex; if(!_tcscmp(ValName, _T(""))) { - AddedDefault = TRUE; + AddedDefault = TRUE; } } HeapFree(GetProcessHeap(), 0, ValBuf); @@ -576,7 +588,7 @@ BOOL RefreshListView(HWND hwndLV, HKEY hKey, LPCTSTR keyPath) } if(!AddedDefault) { - AddEntryToList(hwndLV, _T(""), REG_SZ, NULL, 0, 0, FALSE); + AddEntryToList(hwndLV, _T(""), REG_SZ, NULL, 0, 0, FALSE); } ListView_SortItems(hwndLV, CompareFunc, (WPARAM)hwndLV); c = ListView_GetItemCount(hwndLV); @@ -585,8 +597,8 @@ BOOL RefreshListView(HWND hwndLV, HKEY hKey, LPCTSTR keyPath) ListView_SetItemState(hwndLV, i, 0, LVIS_FOCUSED | LVIS_SELECTED); } ListView_SetItemState(hwndLV, iListViewSelect, - LVIS_FOCUSED | LVIS_SELECTED, - LVIS_FOCUSED | LVIS_SELECTED); + LVIS_FOCUSED | LVIS_SELECTED, + LVIS_FOCUSED | LVIS_SELECTED); RegCloseKey(hNewKey); SendMessage(hwndLV, WM_SETREDRAW, TRUE, 0); diff --git a/reactos/base/applications/regedit/main.c b/reactos/base/applications/regedit/main.c index 0edfcecb758..d88968022ee 100644 --- a/reactos/base/applications/regedit/main.c +++ b/reactos/base/applications/regedit/main.c @@ -88,9 +88,9 @@ BOOL InitInstance(HINSTANCE hInstance, int nCmdShow) wcChild.hInstance = hInstance; wcChild.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_REGEDIT)); wcChild.hCursor = LoadCursor(0, IDC_ARROW), - wcChild.lpszClassName = szChildClass, - wcChild.hIconSm = (HICON)LoadImage(hInstance, MAKEINTRESOURCE(IDI_REGEDIT), IMAGE_ICON, - GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_SHARED); + wcChild.lpszClassName = szChildClass, + wcChild.hIconSm = (HICON)LoadImage(hInstance, MAKEINTRESOURCE(IDI_REGEDIT), IMAGE_ICON, + GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_SHARED); RegisterClassEx(&wcChild); /* register child windows class */ @@ -107,13 +107,13 @@ BOOL InitInstance(HINSTANCE hInstance, int nCmdShow) AclUiAvailable = InitializeAclUiDll(); if(!AclUiAvailable) { - /* hide the Edit/Permissions... menu entry */ - if(hEditMenu != NULL) - { - RemoveMenu(hEditMenu, ID_EDIT_PERMISSIONS, MF_BYCOMMAND); - /* remove the separator after the menu item */ - RemoveMenu(hEditMenu, 4, MF_BYPOSITION); - } + /* hide the Edit/Permissions... menu entry */ + if(hEditMenu != NULL) + { + RemoveMenu(hEditMenu, ID_EDIT_PERMISSIONS, MF_BYCOMMAND); + /* remove the separator after the menu item */ + RemoveMenu(hEditMenu, 4, MF_BYPOSITION); + } } if(hEditMenu != NULL) @@ -129,14 +129,16 @@ BOOL InitInstance(HINSTANCE hInstance, int nCmdShow) CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, hMenuFrame, hInstance, NULL/*lpParam*/); - if (!hFrameWnd) { + if (!hFrameWnd) + { return FALSE; } /* Create the status bar */ hStatusBar = CreateStatusWindow(WS_VISIBLE|WS_CHILD|WS_CLIPSIBLINGS|SBT_NOBORDERS, _T(""), hFrameWnd, STATUS_WINDOW); - if (hStatusBar) { + if (hStatusBar) + { /* Create the status bar panes */ SetupStatusBar(hFrameWnd, FALSE); CheckMenuItem(GetSubMenu(hMenuFrame, ID_VIEW_MENU), ID_VIEW_STATUSBAR, MF_BYCOMMAND|MF_CHECKED); @@ -144,7 +146,7 @@ BOOL InitInstance(HINSTANCE hInstance, int nCmdShow) /* Restore position */ if (QueryStringValue(HKEY_CURRENT_USER, g_szGeneralRegKey, _T("LastKey"), - szBuffer, COUNT_OF(szBuffer)) == ERROR_SUCCESS) + szBuffer, COUNT_OF(szBuffer)) == ERROR_SUCCESS) { SelectNode(g_pChildWnd->hTreeWnd, szBuffer); } @@ -159,8 +161,9 @@ BOOL InitInstance(HINSTANCE hInstance, int nCmdShow) /* we need to destroy the main menu before destroying the main window to avoid a memory leak */ -void DestroyMainMenu() { - DestroyMenu(hMenuFrame); +void DestroyMainMenu() +{ + DestroyMenu(hMenuFrame); } /******************************************************************************/ @@ -175,11 +178,11 @@ void ExitInstance(HINSTANCE hInstance) BOOL TranslateChildTabMessage(MSG *msg) { - if (msg->message != WM_KEYDOWN) return FALSE; - if (msg->wParam != VK_TAB) return FALSE; - if (GetParent(msg->hwnd) != g_pChildWnd->hWnd) return FALSE; - PostMessage(g_pChildWnd->hWnd, WM_COMMAND, ID_SWITCH_PANELS, 0); - return TRUE; + if (msg->message != WM_KEYDOWN) return FALSE; + if (msg->wParam != VK_TAB) return FALSE; + if (GetParent(msg->hwnd) != g_pChildWnd->hWnd) return FALSE; + PostMessage(g_pChildWnd->hWnd, WM_COMMAND, ID_SWITCH_PANELS, 0); + return TRUE; } int APIENTRY wWinMain(HINSTANCE hInstance, @@ -192,7 +195,8 @@ int APIENTRY wWinMain(HINSTANCE hInstance, UNREFERENCED_PARAMETER(hPrevInstance); - if (ProcessCmdLine(lpCmdLine)) { + if (ProcessCmdLine(lpCmdLine)) + { return 0; } @@ -205,15 +209,18 @@ int APIENTRY wWinMain(HINSTANCE hInstance, hInst = hInstance; /* Perform application initialization */ - if (!InitInstance(hInstance, nCmdShow)) { + if (!InitInstance(hInstance, nCmdShow)) + { return FALSE; } hAccel = LoadAccelerators(hInstance, MAKEINTRESOURCE(ID_ACCEL)); /* Main message loop */ - while (GetMessage(&msg, (HWND)NULL, 0, 0)) { + while (GetMessage(&msg, (HWND)NULL, 0, 0)) + { if (!TranslateAccelerator(hFrameWnd, hAccel, &msg) - && !TranslateChildTabMessage(&msg)) { + && !TranslateChildTabMessage(&msg)) + { TranslateMessage(&msg); DispatchMessage(&msg); } diff --git a/reactos/base/applications/regedit/main.h b/reactos/base/applications/regedit/main.h index c8220495852..0a5a31ee918 100644 --- a/reactos/base/applications/regedit/main.h +++ b/reactos/base/applications/regedit/main.h @@ -43,7 +43,8 @@ extern HINSTANCE hInst; /******************************************************************************/ -enum OPTION_FLAGS { +enum OPTION_FLAGS +{ OPTIONS_AUTO_REFRESH = 0x01, OPTIONS_READ_ONLY_MODE = 0x02, OPTIONS_CONFIRM_ON_DELETE = 0x04, @@ -53,12 +54,13 @@ enum OPTION_FLAGS { OPTIONS_VIEW_DATA_ONLY = 0x40, }; -typedef struct { +typedef struct +{ HWND hWnd; HWND hTreeWnd; HWND hListWnd; - HWND hAddressBarWnd; - HWND hAddressBtnWnd; + HWND hAddressBarWnd; + HWND hAddressBtnWnd; int nFocusPanel; /* 0: left 1: right */ int nSplitPos; WINDOWPLACEMENT pos; diff --git a/reactos/base/applications/regedit/regedit.c b/reactos/base/applications/regedit/regedit.c index bd9bad568fa..1a91ffa0397 100644 --- a/reactos/base/applications/regedit/regedit.c +++ b/reactos/base/applications/regedit/regedit.c @@ -52,7 +52,8 @@ static const char *usage = "This program is command-line compatible with Microsoft Windows\n" "regedit.\n"; -typedef enum { +typedef enum +{ ACTION_UNDEF, ACTION_ADD, ACTION_EXPORT, ACTION_DELETE } REGEDIT_ACTION; @@ -79,40 +80,52 @@ void get_file_name(LPWSTR *command_line, LPWSTR file_name) int pos = 0; /* position of pointer "s" in *command_line */ file_name[0] = 0; - if (!s[0]) { + if (!s[0]) + { return; } - if (s[0] == L'"') { + if (s[0] == L'"') + { s++; (*command_line)++; - while(s[0] != L'"') { - if (!s[0]) { + while(s[0] != L'"') + { + if (!s[0]) + { fprintf(stderr, "%s: Unexpected end of file name!\n", getAppName()); exit(1); } s++; pos++; } - } else { - while(s[0] && !iswspace(s[0])) { + } + else + { + while(s[0] && !iswspace(s[0])) + { s++; pos++; } } memcpy(file_name, *command_line, pos * sizeof((*command_line)[0])); /* remove the last backslash */ - if (file_name[pos - 1] == L'\\') { + if (file_name[pos - 1] == L'\\') + { file_name[pos - 1] = L'\0'; - } else { + } + else + { file_name[pos] = L'\0'; } - if (s[0]) { + if (s[0]) + { s++; pos++; } - while(s[0] && iswspace(s[0])) { + while(s[0] && iswspace(s[0])) + { s++; pos++; } @@ -121,64 +134,75 @@ void get_file_name(LPWSTR *command_line, LPWSTR file_name) BOOL PerformRegAction(REGEDIT_ACTION action, LPWSTR s) { - switch (action) { - case ACTION_ADD: { - WCHAR filename[MAX_PATH]; - FILE *fp; + switch (action) + { + case ACTION_ADD: + { + WCHAR filename[MAX_PATH]; + FILE *fp; - get_file_name(&s, filename); - if (!filename[0]) { - fprintf(stderr, "%s: No file name is specified\n", getAppName()); - fprintf(stderr, usage); - exit(4); - } - - while(filename[0]) { - fp = _wfopen(filename, L"r"); - if (fp == NULL) - { - LPSTR p = GetMultiByteString(filename); - perror(""); - fprintf(stderr, "%s: Can't open file \"%s\"\n", getAppName(), p); - HeapFree(GetProcessHeap(), 0, p); - exit(5); - } - import_registry_file(fp); - get_file_name(&s, filename); - } - break; + get_file_name(&s, filename); + if (!filename[0]) + { + fprintf(stderr, "%s: No file name is specified\n", getAppName()); + fprintf(stderr, usage); + exit(4); } - case ACTION_DELETE: { + + while(filename[0]) + { + fp = _wfopen(filename, L"r"); + if (fp == NULL) + { + LPSTR p = GetMultiByteString(filename); + perror(""); + fprintf(stderr, "%s: Can't open file \"%s\"\n", getAppName(), p); + HeapFree(GetProcessHeap(), 0, p); + exit(5); + } + import_registry_file(fp); + get_file_name(&s, filename); + } + break; + } + case ACTION_DELETE: + { + WCHAR reg_key_name[KEY_MAX_LEN]; + get_file_name(&s, reg_key_name); + if (!reg_key_name[0]) + { + fprintf(stderr, "%s: No registry key is specified for removal\n", getAppName()); + fprintf(stderr, usage); + exit(6); + } + delete_registry_key(reg_key_name); + break; + } + case ACTION_EXPORT: + { + WCHAR filename[MAX_PATH]; + + filename[0] = _T('\0'); + get_file_name(&s, filename); + if (!filename[0]) + { + fprintf(stderr, "%s: No file name is specified\n", getAppName()); + fprintf(stderr, usage); + exit(7); + } + + if (s[0]) + { WCHAR reg_key_name[KEY_MAX_LEN]; get_file_name(&s, reg_key_name); - if (!reg_key_name[0]) { - fprintf(stderr, "%s: No registry key is specified for removal\n", getAppName()); - fprintf(stderr, usage); - exit(6); - } - delete_registry_key(reg_key_name); - break; + export_registry_key(filename, reg_key_name, REG_FORMAT_4); } - case ACTION_EXPORT: { - WCHAR filename[MAX_PATH]; - - filename[0] = _T('\0'); - get_file_name(&s, filename); - if (!filename[0]) { - fprintf(stderr, "%s: No file name is specified\n", getAppName()); - fprintf(stderr, usage); - exit(7); - } - - if (s[0]) { - WCHAR reg_key_name[KEY_MAX_LEN]; - get_file_name(&s, reg_key_name); - export_registry_key(filename, reg_key_name, REG_FORMAT_4); - } else { - export_registry_key(filename, NULL, REG_FORMAT_4); - } - break; + else + { + export_registry_key(filename, NULL, REG_FORMAT_4); } + break; + } default: fprintf(stderr, "%s: Unhandled action!\n", getAppName()); exit(8); @@ -196,9 +220,12 @@ BOOL PerformRegAction(REGEDIT_ACTION action, LPWSTR s) */ static void error_unknown_switch(WCHAR chu, LPWSTR s) { - if (iswalpha(chu)) { + if (iswalpha(chu)) + { fprintf(stderr, "%s: Undefined switch /%c!\n", getAppName(), chu); - } else { + } + else + { fprintf(stderr, "%s: Alphabetic character is expected after '%c' " "in swit ch specification\n", getAppName(), *(s - 1)); } @@ -220,12 +247,16 @@ BOOL ProcessCmdLine(LPWSTR lpCmdLine) ch = *s; ch2 = *(s + 1); chu = (WCHAR)towupper(ch); - if (!ch2 || iswspace(ch2)) { + if (!ch2 || iswspace(ch2)) + { if (chu == L'S' || chu == L'V') { /* ignore these switches */ - } else { - switch (chu) { + } + else + { + switch (chu) + { case L'D': action = ACTION_DELETE; break; @@ -242,14 +273,19 @@ BOOL ProcessCmdLine(LPWSTR lpCmdLine) } } s++; - } else { - if (ch2 == L':') { - switch (chu) { + } + else + { + if (ch2 == L':') + { + switch (chu) + { case L'L': /* fall through */ case L'R': s += 2; - while (*s && !iswspace(*s)) { + while (*s && !iswspace(*s)) + { s++; } break; @@ -257,7 +293,9 @@ BOOL ProcessCmdLine(LPWSTR lpCmdLine) error_unknown_switch(chu, s); break; } - } else { + } + else + { /* this is a file name, starting from '/' */ s--; break; @@ -265,7 +303,8 @@ BOOL ProcessCmdLine(LPWSTR lpCmdLine) } /* skip spaces to the next parameter */ ch = *s; - while (ch && iswspace(ch)) { + while (ch && iswspace(ch)) + { s++; ch = *s; } diff --git a/reactos/base/applications/regedit/regedit.rc b/reactos/base/applications/regedit/regedit.rc index bd1f3b96027..43ebf5af55c 100644 --- a/reactos/base/applications/regedit/regedit.rc +++ b/reactos/base/applications/regedit/regedit.rc @@ -31,10 +31,10 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US #include "rsrc.rc" -IDI_OPEN_FILE ICON DISCARDABLE res/folderopen.ico -IDI_CLOSED_FILE ICON DISCARDABLE res/folder.ico -IDI_ROOT ICON DISCARDABLE res/computer.ico -IDI_STRING ICON DISCARDABLE res/string.ico -IDI_BIN ICON DISCARDABLE res/bin.ico -IDI_REGEDIT ICON DISCARDABLE res/regedit.ico -IDI_REGFILE ICON DISCARDABLE res/regfile.ico +IDI_OPEN_FILE ICON DISCARDABLE res/folderopen.ico +IDI_CLOSED_FILE ICON DISCARDABLE res/folder.ico +IDI_ROOT ICON DISCARDABLE res/computer.ico +IDI_STRING ICON DISCARDABLE res/string.ico +IDI_BIN ICON DISCARDABLE res/bin.ico +IDI_REGEDIT ICON DISCARDABLE res/regedit.ico +IDI_REGFILE ICON DISCARDABLE res/regfile.ico diff --git a/reactos/base/applications/regedit/regproc.c b/reactos/base/applications/regedit/regproc.c index 2f675d04c67..facf2df5df6 100644 --- a/reactos/base/applications/regedit/regproc.c +++ b/reactos/base/applications/regedit/regproc.c @@ -30,22 +30,25 @@ */ #define REG_FILE_HEX_LINE_LEN (2 + 25 * 3) -static const CHAR *reg_class_names[] = { - "HKEY_LOCAL_MACHINE", "HKEY_USERS", "HKEY_CLASSES_ROOT", - "HKEY_CURRENT_CONFIG", "HKEY_CURRENT_USER", "HKEY_DYN_DATA" - }; +static const CHAR *reg_class_names[] = +{ + "HKEY_LOCAL_MACHINE", "HKEY_USERS", "HKEY_CLASSES_ROOT", + "HKEY_CURRENT_CONFIG", "HKEY_CURRENT_USER", "HKEY_DYN_DATA" +}; #define REG_CLASS_NUMBER (sizeof(reg_class_names) / sizeof(reg_class_names[0])) -const WCHAR* reg_class_namesW[REG_CLASS_NUMBER] = { +const WCHAR* reg_class_namesW[REG_CLASS_NUMBER] = +{ L"HKEY_LOCAL_MACHINE", L"HKEY_USERS", L"HKEY_CLASSES_ROOT", L"HKEY_CURRENT_CONFIG", L"HKEY_CURRENT_USER", L"HKEY_DYN_DATA" }; -static HKEY reg_class_keys[REG_CLASS_NUMBER] = { - HKEY_LOCAL_MACHINE, HKEY_USERS, HKEY_CLASSES_ROOT, - HKEY_CURRENT_CONFIG, HKEY_CURRENT_USER, HKEY_DYN_DATA - }; +static HKEY reg_class_keys[REG_CLASS_NUMBER] = +{ + HKEY_LOCAL_MACHINE, HKEY_USERS, HKEY_CLASSES_ROOT, + HKEY_CURRENT_CONFIG, HKEY_CURRENT_USER, HKEY_DYN_DATA +}; /* return values */ #define NOT_ENOUGH_MEMORY 1 @@ -149,7 +152,8 @@ static BOOL convertHexToDWord(WCHAR* str, DWORD *dw) char dummy; WideCharToMultiByte(CP_ACP, 0, str, -1, buf, 9, NULL, NULL); - if (lstrlenW(str) > 8 || sscanf(buf, "%lx%c", dw, &dummy) != 1) { + if (lstrlenW(str) > 8 || sscanf(buf, "%lx%c", dw, &dummy) != 1) + { fprintf(stderr,"%s: ERROR, invalid hex value\n", getAppName()); return FALSE; } @@ -172,12 +176,14 @@ static BYTE* convertHexCSVToHex(WCHAR *str, DWORD *size) s = str; d = data; *size=0; - while (*s != '\0') { + while (*s != '\0') + { UINT wc; WCHAR *end; wc = wcstoul(s,&end, 16); - if (end == s || wc > 0xff || (*end && *end != L',')) { + if (end == s || wc > 0xff || (*end && *end != L',')) + { char* strA = GetMultiByteString(s); fprintf(stderr,"%s: ERROR converting CSV hex stream. Invalid value at '%s'\n", getAppName(), strA); @@ -203,7 +209,13 @@ static BYTE* convertHexCSVToHex(WCHAR *str, DWORD *size) */ static DWORD getDataType(LPWSTR *lpValue, DWORD* parse_type) { - struct data_type { const WCHAR *tag; int len; int type; int parse_type; }; + struct data_type + { + const WCHAR *tag; + int len; + int type; + int parse_type; + }; static const WCHAR quote[] = {'"'}; static const WCHAR str[] = {'s','t','r',':','"'}; @@ -213,19 +225,20 @@ static DWORD getDataType(LPWSTR *lpValue, DWORD* parse_type) static const WCHAR hexp[] = {'h','e','x','('}; static const struct data_type data_types[] = { /* actual type */ /* type to assume for parsing */ - { quote, 1, REG_SZ, REG_SZ }, - { str, 5, REG_SZ, REG_SZ }, - { str2, 8, REG_EXPAND_SZ, REG_SZ }, - { hex, 4, REG_BINARY, REG_BINARY }, - { dword, 6, REG_DWORD, REG_DWORD }, - { hexp, 4, -1, REG_BINARY }, - { NULL, 0, 0, 0 } - }; + { quote, 1, REG_SZ, REG_SZ }, + { str, 5, REG_SZ, REG_SZ }, + { str2, 8, REG_EXPAND_SZ, REG_SZ }, + { hex, 4, REG_BINARY, REG_BINARY }, + { dword, 6, REG_DWORD, REG_DWORD }, + { hexp, 4, -1, REG_BINARY }, + { NULL, 0, 0, 0 } + }; const struct data_type *ptr; int type; - for (ptr = data_types; ptr->tag; ptr++) { + for (ptr = data_types; ptr->tag; ptr++) + { if (wcsncmp(ptr->tag, *lpValue, ptr->len)) continue; @@ -233,14 +246,18 @@ static DWORD getDataType(LPWSTR *lpValue, DWORD* parse_type) *parse_type = ptr->parse_type; type=ptr->type; *lpValue+=ptr->len; - if (type == -1) { + if (type == -1) + { WCHAR* end; /* "hex(xx):" is special */ type = (int)wcstoul( *lpValue , &end, 16 ); - if (**lpValue=='\0' || *end!=')' || *(end+1)!=':') { + if (**lpValue=='\0' || *end!=')' || *(end+1)!=':') + { type=REG_NONE; - } else { + } + else + { *lpValue = end + 2; } } @@ -258,10 +275,13 @@ static void REGPROC_unescape_string(WCHAR* str) int str_idx = 0; /* current character under analysis */ int val_idx = 0; /* the last character of the unescaped string */ int len = lstrlenW(str); - for (str_idx = 0; str_idx < len; str_idx++, val_idx++) { - if (str[str_idx] == '\\') { + for (str_idx = 0; str_idx < len; str_idx++, val_idx++) + { + if (str[str_idx] == '\\') + { str_idx++; - switch (str[str_idx]) { + switch (str[str_idx]) + { case 'n': str[val_idx] = '\n'; break; @@ -271,11 +291,13 @@ static void REGPROC_unescape_string(WCHAR* str) break; default: fprintf(stderr,"Warning! Unrecognized escape sequence: \\%c'\n", - str[str_idx]); + str[str_idx]); str[val_idx] = str[str_idx]; break; } - } else { + } + else + { str[val_idx] = str[str_idx]; } } @@ -310,9 +332,11 @@ static BOOL parseKeyName(LPWSTR lpKeyName, HKEY *hKey, LPWSTR *lpKeyPath) } *hKey = NULL; - for (i = 0; i < REG_CLASS_NUMBER; i++) { + for (i = 0; i < REG_CLASS_NUMBER; i++) + { if (CompareStringW(LOCALE_USER_DEFAULT, 0, lpKeyName, len, reg_class_namesW[i], len) == CSTR_EQUAL && - len == lstrlenW(reg_class_namesW[i])) { + len == lstrlenW(reg_class_namesW[i])) + { *hKey = reg_class_keys[i]; break; } @@ -404,12 +428,12 @@ static LONG setValue(WCHAR* val_name, WCHAR* val_data, BOOL is_unicode) } res = RegSetValueExW( - currentKeyHandle, - val_name, - 0, /* Reserved */ - dwDataType, - lpbData, - dwLen); + currentKeyHandle, + val_name, + 0, /* Reserved */ + dwDataType, + lpbData, + dwLen); if (dwParseType == REG_BINARY) HeapFree(GetProcessHeap(), 0, lpbData); return res; @@ -435,15 +459,15 @@ static LONG openKeyW(WCHAR* stdInput) return ERROR_INVALID_PARAMETER; res = RegCreateKeyExW( - keyClass, /* Class */ - keyPath, /* Sub Key */ - 0, /* MUST BE 0 */ - NULL, /* object type */ - REG_OPTION_NON_VOLATILE, /* option, REG_OPTION_NON_VOLATILE ... */ - KEY_ALL_ACCESS, /* access mask, KEY_ALL_ACCESS */ - NULL, /* security attribute */ - ¤tKeyHandle, /* result */ - &dwDisp); /* disposition, REG_CREATED_NEW_KEY or + keyClass, /* Class */ + keyPath, /* Sub Key */ + 0, /* MUST BE 0 */ + NULL, /* object type */ + REG_OPTION_NON_VOLATILE, /* option, REG_OPTION_NON_VOLATILE ... */ + KEY_ALL_ACCESS, /* access mask, KEY_ALL_ACCESS */ + NULL, /* security attribute */ + ¤tKeyHandle, /* result */ + &dwDisp); /* disposition, REG_CREATED_NEW_KEY or REG_OPENED_EXISTING_KEY */ if (res == ERROR_SUCCESS) @@ -485,29 +509,39 @@ static void processSetValue(WCHAR* line, BOOL is_unicode) /* get value name */ while ( iswspace(line[line_idx]) ) line_idx++; - if (line[line_idx] == '@' && line[line_idx + 1] == '=') { + if (line[line_idx] == '@' && line[line_idx + 1] == '=') + { line[line_idx] = '\0'; val_name = line; line_idx++; - } else if (line[line_idx] == '\"') { + } + else if (line[line_idx] == '\"') + { line_idx++; val_name = line + line_idx; - while (TRUE) { + while (TRUE) + { if (line[line_idx] == '\\') /* skip escaped character */ { line_idx += 2; - } else { - if (line[line_idx] == '\"') { + } + else + { + if (line[line_idx] == '\"') + { line[line_idx] = '\0'; line_idx++; break; - } else { + } + else + { line_idx++; } } } while ( iswspace(line[line_idx]) ) line_idx++; - if (line[line_idx] != '=') { + if (line[line_idx] != '=') + { char* lineA; line[line_idx] = '\"'; lineA = GetMultiByteString(line); @@ -516,7 +550,9 @@ static void processSetValue(WCHAR* line, BOOL is_unicode) return; } - } else { + } + else + { char* lineA = GetMultiByteString(line); fprintf(stderr,"Warning! unrecognized line:\n%s\n", lineA); HeapFree(GetProcessHeap(), 0, lineA); @@ -538,10 +574,10 @@ static void processSetValue(WCHAR* line, BOOL is_unicode) char* val_nameA = GetMultiByteString(val_name); char* val_dataA = GetMultiByteString(val_data); fprintf(stderr,"%s: ERROR Key %s not created. Value: %s, Data: %s\n", - getAppName(), - currentKeyName, - val_nameA, - val_dataA); + getAppName(), + currentKeyName, + val_nameA, + val_dataA); HeapFree(GetProcessHeap(), 0, val_nameA); HeapFree(GetProcessHeap(), 0, val_dataA); } @@ -558,7 +594,8 @@ static void processRegEntry(WCHAR* stdInput, BOOL isUnicode) * We encountered the end of the file, make sure we * close the opened key and exit */ - if (stdInput == NULL) { + if (stdInput == NULL) + { closeKey(); return; } @@ -578,19 +615,22 @@ static void processRegEntry(WCHAR* stdInput, BOOL isUnicode) if ( stdInput[0] == '-') { delete_registry_key(stdInput + 1); - } else if ( openKeyW(stdInput) != ERROR_SUCCESS ) + } + else if ( openKeyW(stdInput) != ERROR_SUCCESS ) { char* stdInputA = GetMultiByteString(stdInput); fprintf(stderr,"%s: setValue failed to open key %s\n", - getAppName(), stdInputA); + getAppName(), stdInputA); HeapFree(GetProcessHeap(), 0, stdInputA); } - } else if( currentKeyHandle && - (( stdInput[0] == '@') || /* reading a default @=data pair */ - ( stdInput[0] == '\"'))) /* reading a new value=data pair */ + } + else if( currentKeyHandle && + (( stdInput[0] == '@') || /* reading a default @=data pair */ + ( stdInput[0] == '\"'))) /* reading a new value=data pair */ { processSetValue(stdInput, isUnicode); - } else + } + else { /* Since we are assuming that the file format is valid we must be * reading a blank line which indicates the end of this key processing @@ -614,13 +654,15 @@ static void processRegLinesA(FILE *in) line = HeapAlloc(GetProcessHeap(), 0, lineSize); CHECK_ENOUGH_MEMORY(line); - while (!feof(in)) { + while (!feof(in)) + { LPSTR s; /* The pointer into line for where the current fgets should read */ LPSTR check; WCHAR* lineW; s = line; - for (;;) { + for (;;) + { size_t size_remaining; int size_to_get; char *s_eol; /* various local uses */ @@ -650,11 +692,15 @@ static void processRegLinesA(FILE *in) check = fgets (s, size_to_get, in); - if (check == NULL) { - if (ferror(in)) { + if (check == NULL) + { + if (ferror(in)) + { perror ("While reading input"); exit (IO_ERROR); - } else { + } + else + { assert (feof(in)); *s = '\0'; /* It is not clear to me from the definition that the @@ -666,40 +712,46 @@ static void processRegLinesA(FILE *in) /* If we didn't read the eol nor the eof go around for the rest */ s_eol = strchr (s, '\n'); - if (!feof (in) && !s_eol) { + if (!feof (in) && !s_eol) + { s = strchr (s, '\0'); /* It should be s + size_to_get - 1 but this is safer */ continue; } /* If it is a comment line then discard it and go around again */ - if (line [0] == '#') { + if (line [0] == '#') + { s = line; continue; } /* Remove any line feed. Leave s_eol on the \0 */ - if (s_eol) { + if (s_eol) + { *s_eol = '\0'; if (s_eol > line && *(s_eol-1) == '\r') *--s_eol = '\0'; - } else + } + else s_eol = strchr (s, '\0'); /* If there is a concatenating \\ then go around again */ - if (s_eol > line && *(s_eol-1) == '\\') { + if (s_eol > line && *(s_eol-1) == '\\') + { int c; s = s_eol-1; do { c = fgetc(in); - } while(c == ' ' || c == '\t'); + } + while(c == ' ' || c == '\t'); if(c == EOF) { fprintf(stderr,"%s: ERROR - invalid continuation.\n", - getAppName()); + getAppName()); } else { @@ -737,7 +789,8 @@ static void processRegLinesW(FILE *in) s = buf; line = buf; - while(!feof(in)) { + while(!feof(in)) + { size_t size_remaining; int size_to_get; WCHAR *s_eol = NULL; /* various local uses */ @@ -769,11 +822,15 @@ static void processRegLinesW(FILE *in) CharsInBuf = fread(s, sizeof(WCHAR), size_to_get - 1, in); s[CharsInBuf] = 0; - if (CharsInBuf == 0) { - if (ferror(in)) { + if (CharsInBuf == 0) + { + if (ferror(in)) + { perror ("While reading input"); exit (IO_ERROR); - } else { + } + else + { assert (feof(in)); *s = '\0'; /* It is not clear to me from the definition that the @@ -788,7 +845,8 @@ static void processRegLinesW(FILE *in) { s_eol = wcschr(line, '\n'); - if(!s_eol) { + if(!s_eol) + { /* Move the stub of the line to the start of the buffer so * we get the maximum space to read into, and so we don't * have to recalculate 'line' if the buffer expands */ @@ -799,14 +857,16 @@ static void processRegLinesW(FILE *in) } /* If it is a comment line then discard it and go around again */ - if (*line == '#') { + if (*line == '#') + { line = s_eol + 1; continue; } /* If there is a concatenating \\ then go around again */ if ((*(s_eol-1) == '\\') || - (*(s_eol-1) == '\r' && *(s_eol-2) == '\\')) { + (*(s_eol-1) == '\r' && *(s_eol-2) == '\\')) + { WCHAR* NextLine = s_eol; while(*(NextLine+1) == ' ' || *(NextLine+1) == '\t') @@ -824,7 +884,8 @@ static void processRegLinesW(FILE *in) } /* Remove any line feed. Leave s_eol on the \0 */ - if (s_eol) { + if (s_eol) + { *s_eol = '\0'; if (s_eol > buf && *(s_eol-1) == '\r') *(s_eol-1) = '\0'; @@ -859,10 +920,11 @@ static void REGPROC_print_error(void) error_code = GetLastError (); status = FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, - NULL, error_code, 0, (LPTSTR) &lpMsgBuf, 0, NULL); - if (!status) { + NULL, error_code, 0, (LPTSTR) &lpMsgBuf, 0, NULL); + if (!status) + { fprintf(stderr,"%s: Cannot display message for error %ld, status %ld\n", - getAppName(), error_code, GetLastError()); + getAppName(), error_code, GetLastError()); exit(1); } puts(lpMsgBuf); @@ -883,7 +945,8 @@ static void REGPROC_print_error(void) static void REGPROC_resize_char_buffer(WCHAR **buffer, DWORD *len, DWORD required_len) { required_len++; - if (required_len > *len) { + if (required_len > *len) + { *len = required_len; if (!*buffer) *buffer = HeapAlloc(GetProcessHeap(), 0, *len * sizeof(**buffer)); @@ -903,7 +966,8 @@ static void REGPROC_resize_char_buffer(WCHAR **buffer, DWORD *len, DWORD require */ static void REGPROC_resize_binary_buffer(BYTE **buffer, DWORD *size, DWORD required_size) { - if (required_size > *size) { + if (required_size > *size) + { *size = required_size; if (!*buffer) *buffer = HeapAlloc(GetProcessHeap(), 0, *size); @@ -925,9 +989,11 @@ static void REGPROC_export_string(WCHAR **line_buf, DWORD *line_buf_size, DWORD /* escaping characters */ pos = *line_len; - for (i = 0; i < str_len; i++) { + for (i = 0; i < str_len; i++) + { WCHAR c = str[i]; - switch (c) { + switch (c) + { case '\n': extra++; REGPROC_resize_char_buffer(line_buf, line_buf_size, *line_len + str_len + extra); @@ -962,9 +1028,12 @@ static void REGPROC_export_binary(WCHAR **line_buf, DWORD *line_buf_size, DWORD const WCHAR newline[] = {'\n',0}; CHAR* value_multibyte = NULL; - if (type == REG_BINARY) { + if (type == REG_BINARY) + { hex_prefix = hex; - } else { + } + else + { const WCHAR hex_format[] = {'h','e','x','(','%','u',')',':',0}; hex_prefix = hex_buf; wsprintfW(hex_buf, hex_format, type); @@ -1011,7 +1080,8 @@ static void REGPROC_export_binary(WCHAR **line_buf, DWORD *line_buf_size, DWORD column += 3; /* wrap the line */ - if (column >= REG_FILE_HEX_LINE_LEN) { + if (column >= REG_FILE_HEX_LINE_LEN) + { lstrcpyW(*line_buf + data_pos, concat); data_pos += concat_len; column = concat_prefix; @@ -1062,11 +1132,11 @@ static void REGPROC_write_line(FILE *file, const WCHAR* str, BOOL unicode) * val_size - size of the buffer for storing values in bytes. */ static void export_hkey(FILE *file, HKEY key, - WCHAR **reg_key_name_buf, DWORD *reg_key_name_size, - WCHAR **val_name_buf, DWORD *val_name_size, - BYTE **val_buf, DWORD *val_size, - WCHAR **line_buf, DWORD *line_buf_size, - BOOL unicode) +WCHAR **reg_key_name_buf, DWORD *reg_key_name_size, +WCHAR **val_name_buf, DWORD *val_name_size, +BYTE **val_buf, DWORD *val_size, +WCHAR **line_buf, DWORD *line_buf_size, +BOOL unicode) { DWORD max_sub_key_len; DWORD max_val_name_len; @@ -1079,16 +1149,17 @@ static void export_hkey(FILE *file, HKEY key, /* get size information and resize the buffers if necessary */ if (RegQueryInfoKeyW(key, NULL, NULL, NULL, NULL, - &max_sub_key_len, NULL, - NULL, &max_val_name_len, &max_val_size, NULL, NULL - ) != ERROR_SUCCESS) { + &max_sub_key_len, NULL, + NULL, &max_val_name_len, &max_val_size, NULL, NULL + ) != ERROR_SUCCESS) + { REGPROC_print_error(); } curr_len = lstrlenW(*reg_key_name_buf); REGPROC_resize_char_buffer(reg_key_name_buf, reg_key_name_size, - max_sub_key_len + curr_len + 1); + max_sub_key_len + curr_len + 1); REGPROC_resize_char_buffer(val_name_buf, val_name_size, - max_val_name_len); + max_val_name_len); REGPROC_resize_binary_buffer(val_buf, val_size, max_val_size); REGPROC_resize_char_buffer(line_buf, line_buf_size, lstrlenW(*reg_key_name_buf) + 4); /* output data for the current key */ @@ -1098,26 +1169,34 @@ static void export_hkey(FILE *file, HKEY key, /* print all the values */ i = 0; more_data = TRUE; - while(more_data) { + while(more_data) + { DWORD value_type; DWORD val_name_size1 = *val_name_size; DWORD val_size1 = *val_size; ret = RegEnumValueW(key, i, *val_name_buf, &val_name_size1, NULL, - &value_type, *val_buf, &val_size1); - if (ret == ERROR_MORE_DATA) { + &value_type, *val_buf, &val_size1); + if (ret == ERROR_MORE_DATA) + { /* Increase the size of the buffers and retry */ REGPROC_resize_char_buffer(val_name_buf, val_name_size, val_name_size1); REGPROC_resize_binary_buffer(val_buf, val_size, val_size1); - } else if (ret != ERROR_SUCCESS) { + } + else if (ret != ERROR_SUCCESS) + { more_data = FALSE; - if (ret != ERROR_NO_MORE_ITEMS) { + if (ret != ERROR_NO_MORE_ITEMS) + { REGPROC_print_error(); } - } else { + } + else + { DWORD line_len; i++; - if ((*val_name_buf)[0]) { + if ((*val_name_buf)[0]) + { const WCHAR val_start[] = {'"','%','s','"','=',0}; line_len = 0; @@ -1128,22 +1207,28 @@ static void export_hkey(FILE *file, HKEY key, line_len = 3 + lstrlenW(*val_name_buf); REGPROC_resize_char_buffer(line_buf, line_buf_size, line_len); wsprintfW(*line_buf, val_start, *val_name_buf); - } else { + } + else + { const WCHAR std_val[] = {'@','=',0}; line_len = 2; REGPROC_resize_char_buffer(line_buf, line_buf_size, line_len); lstrcpyW(*line_buf, std_val); } - switch (value_type) { + switch (value_type) + { case REG_SZ: { WCHAR* wstr = (WCHAR*)*val_buf; if (val_size1 < sizeof(WCHAR) || val_size1 % sizeof(WCHAR) || - wstr[val_size1 / sizeof(WCHAR) - 1]) { + wstr[val_size1 / sizeof(WCHAR) - 1]) + { REGPROC_export_binary(line_buf, line_buf_size, &line_len, value_type, *val_buf, val_size1, unicode); - } else { + } + else + { const WCHAR start[] = {'"',0}; const WCHAR end[] = {'"','\n',0}; DWORD len; @@ -1178,14 +1263,14 @@ static void export_hkey(FILE *file, HKEY key, char* key_nameA = GetMultiByteString(*reg_key_name_buf); char* value_nameA = GetMultiByteString(*val_name_buf); fprintf(stderr,"%s: warning - unsupported registry format '%ld', " - "treat as binary\n", - getAppName(), value_type); + "treat as binary\n", + getAppName(), value_type); fprintf(stderr,"key name: \"%s\"\n", key_nameA); fprintf(stderr,"value name:\"%s\"\n\n", value_nameA); HeapFree(GetProcessHeap(), 0, key_nameA); HeapFree(GetProcessHeap(), 0, value_nameA); } - /* falls through */ + /* falls through */ case REG_EXPAND_SZ: case REG_MULTI_SZ: /* falls through */ @@ -1199,30 +1284,40 @@ static void export_hkey(FILE *file, HKEY key, i = 0; more_data = TRUE; (*reg_key_name_buf)[curr_len] = '\\'; - while(more_data) { + while(more_data) + { DWORD buf_size = *reg_key_name_size - curr_len - 1; ret = RegEnumKeyExW(key, i, *reg_key_name_buf + curr_len + 1, &buf_size, - NULL, NULL, NULL, NULL); - if (ret == ERROR_MORE_DATA) { + NULL, NULL, NULL, NULL); + if (ret == ERROR_MORE_DATA) + { /* Increase the size of the buffer and retry */ REGPROC_resize_char_buffer(reg_key_name_buf, reg_key_name_size, curr_len + 1 + buf_size); - } else if (ret != ERROR_SUCCESS) { + } + else if (ret != ERROR_SUCCESS) + { more_data = FALSE; - if (ret != ERROR_NO_MORE_ITEMS) { + if (ret != ERROR_NO_MORE_ITEMS) + { REGPROC_print_error(); } - } else { + } + else + { HKEY subkey; i++; if (RegOpenKeyW(key, *reg_key_name_buf + curr_len + 1, - &subkey) == ERROR_SUCCESS) { + &subkey) == ERROR_SUCCESS) + { export_hkey(file, subkey, reg_key_name_buf, reg_key_name_size, - val_name_buf, val_name_size, val_buf, val_size, - line_buf, line_buf_size, unicode); + val_name_buf, val_name_size, val_buf, val_size, + line_buf, line_buf_size, unicode); RegCloseKey(subkey); - } else { + } + else + { REGPROC_print_error(); } } @@ -1246,7 +1341,8 @@ static FILE *REGPROC_open_export_file(WCHAR *file_name, BOOL unicode) file = _wfopen(file_name, L"wb"); else file = _wfopen(file_name, L"w"); - if (!file) { + if (!file) + { CHAR* file_nameA = GetMultiByteString(file_name); perror(""); fprintf(stderr,"%s: Can't open file \"%s\"\n", getAppName(), file_nameA); @@ -1291,75 +1387,87 @@ BOOL export_registry_key(WCHAR *file_name, WCHAR *reg_key_name, DWORD format) BOOL unicode = (format == REG_FORMAT_5); reg_key_name_buf = HeapAlloc(GetProcessHeap(), 0, - reg_key_name_size * sizeof(*reg_key_name_buf)); + reg_key_name_size * sizeof(*reg_key_name_buf)); val_name_buf = HeapAlloc(GetProcessHeap(), 0, - val_name_size * sizeof(*val_name_buf)); + val_name_size * sizeof(*val_name_buf)); val_buf = HeapAlloc(GetProcessHeap(), 0, val_size); line_buf = HeapAlloc(GetProcessHeap(), 0, line_buf_size * sizeof(*line_buf)); CHECK_ENOUGH_MEMORY(reg_key_name_buf && val_name_buf && val_buf && line_buf); - if (reg_key_name && reg_key_name[0]) { + if (reg_key_name && reg_key_name[0]) + { HKEY reg_key_class; WCHAR *branch_name = NULL; HKEY key; REGPROC_resize_char_buffer(®_key_name_buf, ®_key_name_size, - lstrlenW(reg_key_name)); + lstrlenW(reg_key_name)); lstrcpyW(reg_key_name_buf, reg_key_name); /* open the specified key */ - if (!parseKeyName(reg_key_name, ®_key_class, &branch_name)) { + if (!parseKeyName(reg_key_name, ®_key_class, &branch_name)) + { CHAR* key_nameA = GetMultiByteString(reg_key_name); fprintf(stderr,"%s: Incorrect registry class specification in '%s'\n", - getAppName(), key_nameA); + getAppName(), key_nameA); HeapFree(GetProcessHeap(), 0, key_nameA); exit(1); } - if (!branch_name[0]) { + if (!branch_name[0]) + { /* no branch - registry class is specified */ file = REGPROC_open_export_file(file_name, unicode); export_hkey(file, reg_key_class, - ®_key_name_buf, ®_key_name_size, - &val_name_buf, &val_name_size, - &val_buf, &val_size, &line_buf, - &line_buf_size, unicode); - } else if (RegOpenKeyW(reg_key_class, branch_name, &key) == ERROR_SUCCESS) { + ®_key_name_buf, ®_key_name_size, + &val_name_buf, &val_name_size, + &val_buf, &val_size, &line_buf, + &line_buf_size, unicode); + } + else if (RegOpenKeyW(reg_key_class, branch_name, &key) == ERROR_SUCCESS) + { file = REGPROC_open_export_file(file_name, unicode); export_hkey(file, key, - ®_key_name_buf, ®_key_name_size, - &val_name_buf, &val_name_size, - &val_buf, &val_size, &line_buf, - &line_buf_size, unicode); + ®_key_name_buf, ®_key_name_size, + &val_name_buf, &val_name_size, + &val_buf, &val_size, &line_buf, + &line_buf_size, unicode); RegCloseKey(key); - } else { + } + else + { CHAR* key_nameA = GetMultiByteString(reg_key_name); fprintf(stderr,"%s: Can't export. Registry key '%s' does not exist!\n", - getAppName(), key_nameA); + getAppName(), key_nameA); HeapFree(GetProcessHeap(), 0, key_nameA); REGPROC_print_error(); } - } else { + } + else + { unsigned int i; /* export all registry classes */ file = REGPROC_open_export_file(file_name, unicode); - for (i = 0; i < REG_CLASS_NUMBER; i++) { + for (i = 0; i < REG_CLASS_NUMBER; i++) + { /* do not export HKEY_CLASSES_ROOT */ if (reg_class_keys[i] != HKEY_CLASSES_ROOT && - reg_class_keys[i] != HKEY_CURRENT_USER && - reg_class_keys[i] != HKEY_CURRENT_CONFIG && - reg_class_keys[i] != HKEY_DYN_DATA) { + reg_class_keys[i] != HKEY_CURRENT_USER && + reg_class_keys[i] != HKEY_CURRENT_CONFIG && + reg_class_keys[i] != HKEY_DYN_DATA) + { lstrcpyW(reg_key_name_buf, reg_class_namesW[i]); export_hkey(file, reg_class_keys[i], - ®_key_name_buf, ®_key_name_size, - &val_name_buf, &val_name_size, - &val_buf, &val_size, &line_buf, - &line_buf_size, unicode); + ®_key_name_buf, ®_key_name_size, + &val_name_buf, &val_name_size, + &val_buf, &val_size, &line_buf, + &line_buf_size, unicode); } } } - if (file) { + if (file) + { fclose(file); } HeapFree(GetProcessHeap(), 0, reg_key_name); @@ -1382,7 +1490,8 @@ BOOL import_registry_file(FILE* reg_file) if (s[0] == 0xff && s[1] == 0xfe) { processRegLinesW(reg_file); - } else + } + else { fseek(reg_file, 0, SEEK_SET); processRegLinesA(reg_file); @@ -1408,17 +1517,19 @@ void delete_registry_key(WCHAR *reg_key_name) if (!reg_key_name || !reg_key_name[0]) return; - if (!parseKeyName(reg_key_name, &key_class, &key_name)) { + if (!parseKeyName(reg_key_name, &key_class, &key_name)) + { char* reg_key_nameA = GetMultiByteString(reg_key_name); fprintf(stderr,"%s: Incorrect registry class specification in '%s'\n", - getAppName(), reg_key_nameA); + getAppName(), reg_key_nameA); HeapFree(GetProcessHeap(), 0, reg_key_nameA); exit(1); } - if (!*key_name) { + if (!*key_name) + { char* reg_key_nameA = GetMultiByteString(reg_key_name); fprintf(stderr,"%s: Can't delete registry class '%s'\n", - getAppName(), reg_key_nameA); + getAppName(), reg_key_nameA); HeapFree(GetProcessHeap(), 0, reg_key_nameA); exit(1); } diff --git a/reactos/base/applications/regedit/treeview.c b/reactos/base/applications/regedit/treeview.c index 5e0727fdc61..302aa5f071f 100644 --- a/reactos/base/applications/regedit/treeview.c +++ b/reactos/base/applications/regedit/treeview.c @@ -42,19 +42,22 @@ static BOOL get_item_path(HWND hwndTV, HTREEITEM hItem, HKEY* phKey, LPTSTR* pKe item.hItem = hItem; if (!TreeView_GetItem(hwndTV, &item)) return FALSE; - if (item.lParam) { - /* found root key with valid key value */ - *phKey = (HKEY)item.lParam; - return TRUE; + if (item.lParam) + { + /* found root key with valid key value */ + *phKey = (HKEY)item.lParam; + return TRUE; } if(!get_item_path(hwndTV, TreeView_GetParent(hwndTV, hItem), phKey, pKeyPath, pPathLen, pMaxLen)) return FALSE; - if (*pPathLen) { + if (*pPathLen) + { (*pKeyPath)[*pPathLen] = _T('\\'); ++(*pPathLen); } - do { + do + { item.mask = TVIF_TEXT; item.hItem = hItem; item.pszText = *pKeyPath + *pPathLen; @@ -62,15 +65,17 @@ static BOOL get_item_path(HWND hwndTV, HTREEITEM hItem, HKEY* phKey, LPTSTR* pKe item.cchTextMax = (int) maxLen; if (!TreeView_GetItem(hwndTV, &item)) return FALSE; len = _tcslen(item.pszText); - if (len < maxLen - 1) { + if (len < maxLen - 1) + { *pPathLen += (int) len; break; - } - newStr = HeapReAlloc(GetProcessHeap(), 0, *pKeyPath, *pMaxLen * 2); - if (!newStr) return FALSE; - *pKeyPath = newStr; - *pMaxLen *= 2; - } while(TRUE); + } + newStr = HeapReAlloc(GetProcessHeap(), 0, *pKeyPath, *pMaxLen * 2); + if (!newStr) return FALSE; + *pKeyPath = newStr; + *pMaxLen *= 2; + } + while(TRUE); return TRUE; } @@ -87,9 +92,10 @@ LPCTSTR GetItemPath(HWND hwndTV, HTREEITEM hItem, HKEY* phRootKey) if (maxLen == -1) return NULL; if (!hItem) hItem = TreeView_GetSelection(hwndTV); if (!hItem) return NULL; - if (!get_item_path(hwndTV, hItem, phRootKey, &pathBuffer, &pathLen, &maxLen)) { - return NULL; - } + if (!get_item_path(hwndTV, hItem, phRootKey, &pathBuffer, &pathLen, &maxLen)) + { + return NULL; + } return pathBuffer; } @@ -106,8 +112,10 @@ static HTREEITEM AddEntryToTree(HWND hwndTV, HTREEITEM hParent, LPTSTR label, HK TVITEM tvi; TVINSERTSTRUCT tvins; - if (hKey) { - if (RegQueryInfoKey(hKey, 0, 0, 0, &dwChildren, 0, 0, 0, 0, 0, 0, 0) != ERROR_SUCCESS) { + if (hKey) + { + if (RegQueryInfoKey(hKey, 0, 0, 0, &dwChildren, 0, 0, 0, 0, 0, 0, 0) != ERROR_SUCCESS) + { dwChildren = 0; } } @@ -140,15 +148,20 @@ BOOL RefreshTreeItem(HWND hwndTV, HTREEITEM hItem) KeyPath = GetItemPath(hwndTV, hItem, &hRoot); - if (*KeyPath) { - if (RegOpenKeyEx(hRoot, KeyPath, 0, KEY_READ, &hKey) != ERROR_SUCCESS) { + if (*KeyPath) + { + if (RegOpenKeyEx(hRoot, KeyPath, 0, KEY_READ, &hKey) != ERROR_SUCCESS) + { goto done; } - } else { + } + else + { hKey = hRoot; } - if (RegQueryInfoKey(hKey, 0, 0, 0, &dwCount, &dwMaxSubKeyLen, 0, 0, 0, 0, 0, 0) != ERROR_SUCCESS) { + if (RegQueryInfoKey(hKey, 0, 0, 0, &dwCount, &dwMaxSubKeyLen, 0, 0, 0, 0, 0, 0) != ERROR_SUCCESS) + { goto done; } @@ -156,19 +169,22 @@ BOOL RefreshTreeItem(HWND hwndTV, HTREEITEM hItem) tvItem.mask = TVIF_CHILDREN; tvItem.hItem = hItem; tvItem.cChildren = dwCount; - if (!TreeView_SetItem(hwndTV, &tvItem)) { + if (!TreeView_SetItem(hwndTV, &tvItem)) + { goto done; } /* We don't have to bother with the rest if it's not expanded. */ - if (TreeView_GetItemState(hwndTV, hItem, TVIS_EXPANDED) == 0) { + if (TreeView_GetItemState(hwndTV, hItem, TVIS_EXPANDED) == 0) + { RegCloseKey(hKey); bSuccess = TRUE; goto done; } dwMaxSubKeyLen++; /* account for the \0 terminator */ - if (!(Name = HeapAlloc(GetProcessHeap(), 0, dwMaxSubKeyLen * sizeof(TCHAR)))) { + if (!(Name = HeapAlloc(GetProcessHeap(), 0, dwMaxSubKeyLen * sizeof(TCHAR)))) + { goto done; } tvItem.cchTextMax = dwMaxSubKeyLen; @@ -185,7 +201,8 @@ BOOL RefreshTreeItem(HWND hwndTV, HTREEITEM hItem) DWORD dwStep = 10000; for (childItem = TreeView_GetChild(hwndTV, hItem); childItem; - childItem = TreeView_GetNextSibling(hwndTV, childItem)) { + childItem = TreeView_GetNextSibling(hwndTV, childItem)) + { if (dwActualSize + dwMaxSubKeyLen + 1 > dwPhysicalSize) { @@ -218,40 +235,50 @@ BOOL RefreshTreeItem(HWND hwndTV, HTREEITEM hItem) /* Now go through all the children in the tree, and check if any have to be removed. */ childItem = TreeView_GetChild(hwndTV, hItem); - while (childItem) { + while (childItem) + { HTREEITEM nextItem = TreeView_GetNextSibling(hwndTV, childItem); - if (RefreshTreeItem(hwndTV, childItem) == FALSE) { + if (RefreshTreeItem(hwndTV, childItem) == FALSE) + { (void)TreeView_DeleteItem(hwndTV, childItem); } childItem = nextItem; } - /* Now go through all the children in the registry, and check if any have to be added. */ + /* Now go through all the children in the registry, and check if any have to be added. */ bAddedAny = FALSE; - for (dwIndex = 0; dwIndex < dwCount; dwIndex++) { + for (dwIndex = 0; dwIndex < dwCount; dwIndex++) + { DWORD cName = dwMaxSubKeyLen, dwSubCount; BOOL found; found = FALSE; - if (RegEnumKeyEx(hKey, dwIndex, Name, &cName, 0, 0, 0, NULL) != ERROR_SUCCESS) { + if (RegEnumKeyEx(hKey, dwIndex, Name, &cName, 0, 0, 0, NULL) != ERROR_SUCCESS) + { continue; } /* Check if the node is already in there. */ - if (pszNodes) { - for (s = pszNodes; *s; s += _tcslen(s) + 1) { - if (!_tcscmp(s, Name)) { + if (pszNodes) + { + for (s = pszNodes; *s; s += _tcslen(s) + 1) + { + if (!_tcscmp(s, Name)) + { found = TRUE; break; } } } - if (found == FALSE) { + if (found == FALSE) + { /* Find the number of children of the node. */ dwSubCount = 0; - if (RegOpenKeyEx(hKey, Name, 0, KEY_QUERY_VALUE, &hSubKey) == ERROR_SUCCESS) { - if (RegQueryInfoKey(hSubKey, 0, 0, 0, &dwSubCount, 0, 0, 0, 0, 0, 0, 0) != ERROR_SUCCESS) { + if (RegOpenKeyEx(hKey, Name, 0, KEY_QUERY_VALUE, &hSubKey) == ERROR_SUCCESS) + { + if (RegQueryInfoKey(hSubKey, 0, 0, 0, &dwSubCount, 0, 0, 0, 0, 0, 0, 0) != ERROR_SUCCESS) + { dwSubCount = 0; } RegCloseKey(hSubKey); @@ -287,7 +314,8 @@ BOOL RefreshTreeView(HWND hwndTV) SendMessage(hwndTV, WM_SETREDRAW, FALSE, 0); hItem = TreeView_GetChild(hwndTV, TreeView_GetRoot(hwndTV)); - while (hItem) { + while (hItem) + { RefreshTreeItem(hwndTV, hItem); hItem = TreeView_GetNextSibling(hwndTV, hItem); } @@ -325,7 +353,7 @@ HTREEITEM InsertNode(HWND hwndTV, HTREEITEM hItem, LPTSTR name) hNewItem = AddEntryToTree(hwndTV, hItem, name, 0, 0); SendMessage(hwndTV, TVM_SORTCHILDREN, 0, (LPARAM) hItem); } - else + else { item.mask = TVIF_CHILDREN | TVIF_HANDLE; item.hItem = hItem; @@ -388,11 +416,11 @@ static BOOL InitTreeViewItems(HWND hwndTV, LPTSTR pHostName) if (!AddEntryToTree(hwndTV, hRoot, _T("HKEY_USERS"), HKEY_USERS, 1)) return FALSE; if (!AddEntryToTree(hwndTV, hRoot, _T("HKEY_CURRENT_CONFIG"), HKEY_CURRENT_CONFIG, 1)) return FALSE; - if (GetVersion() & 0x80000000) + if (GetVersion() & 0x80000000) { /* Win9x specific key */ if (!AddEntryToTree(hwndTV, hRoot, _T("HKEY_DYN_DATA"), HKEY_DYN_DATA, 1)) return FALSE; - } + } /* expand and select host name */ (void)TreeView_Expand(hwndTV, hRoot, TVE_EXPAND); @@ -431,8 +459,8 @@ static BOOL InitTreeViewImageLists(HWND hwndTV) 0); if (hico) { - Image_Open = ImageList_AddIcon(himl, hico); - DestroyIcon(hico); + Image_Open = ImageList_AddIcon(himl, hico); + DestroyIcon(hico); } hico = LoadImage(hInst, @@ -443,8 +471,8 @@ static BOOL InitTreeViewImageLists(HWND hwndTV) 0); if (hico) { - Image_Closed = ImageList_AddIcon(himl, hico); - DestroyIcon(hico); + Image_Closed = ImageList_AddIcon(himl, hico); + DestroyIcon(hico); } hico = LoadImage(hInst, @@ -455,8 +483,8 @@ static BOOL InitTreeViewImageLists(HWND hwndTV) 0); if (hico) { - Image_Root = ImageList_AddIcon(himl, hico); - DestroyIcon(hico); + Image_Root = ImageList_AddIcon(himl, hico); + DestroyIcon(hico); } /* Fail if not all of the images were added. */ @@ -483,7 +511,8 @@ BOOL OnTreeExpanding(HWND hwndTV, NMTREEVIEW* pnmtv) static int expanding; if (expanding) return FALSE; - if (pnmtv->itemNew.state & TVIS_EXPANDEDONCE ) { + if (pnmtv->itemNew.state & TVIS_EXPANDEDONCE ) + { return TRUE; } expanding = TRUE; @@ -493,11 +522,14 @@ BOOL OnTreeExpanding(HWND hwndTV, NMTREEVIEW* pnmtv) keyPath = GetItemPath(hwndTV, pnmtv->itemNew.hItem, &hRoot); if (!keyPath) goto done; - if (*keyPath) { + if (*keyPath) + { errCode = RegOpenKeyEx(hRoot, keyPath, 0, KEY_READ, &hNewKey); if (errCode != ERROR_SUCCESS) goto done; - } else { - hNewKey = hRoot; + } + else + { + hNewKey = hRoot; } errCode = RegQueryInfoKey(hNewKey, 0, 0, 0, &dwCount, &dwMaxSubKeyLen, 0, 0, 0, 0, 0, 0); @@ -506,13 +538,15 @@ BOOL OnTreeExpanding(HWND hwndTV, NMTREEVIEW* pnmtv) Name = HeapAlloc(GetProcessHeap(), 0, dwMaxSubKeyLen * sizeof(TCHAR)); if (!Name) goto done; - for (dwIndex = 0; dwIndex < dwCount; dwIndex++) { + for (dwIndex = 0; dwIndex < dwCount; dwIndex++) + { DWORD cName = dwMaxSubKeyLen, dwSubCount; errCode = RegEnumKeyEx(hNewKey, dwIndex, Name, &cName, 0, 0, 0, 0); if (errCode != ERROR_SUCCESS) continue; errCode = RegOpenKeyEx(hNewKey, Name, 0, KEY_QUERY_VALUE, &hKey); - if (errCode == ERROR_SUCCESS) { + if (errCode == ERROR_SUCCESS) + { errCode = RegQueryInfoKey(hKey, 0, 0, 0, &dwSubCount, 0, 0, 0, 0, 0, 0, 0); RegCloseKey(hKey); } @@ -611,88 +645,90 @@ HWND CreateTreeView(HWND hwndParent, LPTSTR pHostName, HMENU id) 0, 0, rcClient.right, rcClient.bottom, hwndParent, id, hInst, NULL); /* Initialize the image list, and add items to the control. */ - if (!InitTreeViewImageLists(hwndTV) || !InitTreeViewItems(hwndTV, pHostName)) { + if (!InitTreeViewImageLists(hwndTV) || !InitTreeViewItems(hwndTV, pHostName)) + { DestroyWindow(hwndTV); return NULL; } return hwndTV; } -void DestroyTreeView() { - if (pathBuffer) - HeapFree(GetProcessHeap(), 0, pathBuffer); +void DestroyTreeView() +{ + if (pathBuffer) + HeapFree(GetProcessHeap(), 0, pathBuffer); } BOOL SelectNode(HWND hwndTV, LPCTSTR keyPath) { - HTREEITEM hRoot, hItem; - HTREEITEM hChildItem; - TCHAR szPathPart[128]; - TCHAR szBuffer[128]; - LPCTSTR s; - TVITEM tvi; + HTREEITEM hRoot, hItem; + HTREEITEM hChildItem; + TCHAR szPathPart[128]; + TCHAR szBuffer[128]; + LPCTSTR s; + TVITEM tvi; /* Total no-good hack */ if (!_tcsnicmp(keyPath, _T("My Computer\\"), 12)) keyPath += 12; - hRoot = TreeView_GetRoot(hwndTV); - hItem = hRoot; + hRoot = TreeView_GetRoot(hwndTV); + hItem = hRoot; - while(keyPath[0]) - { - s = _tcschr(keyPath, TEXT('\\')); - lstrcpyn(szPathPart, keyPath, s ? s - keyPath + 1 : _tcslen(keyPath) + 1); + while(keyPath[0]) + { + s = _tcschr(keyPath, TEXT('\\')); + lstrcpyn(szPathPart, keyPath, s ? s - keyPath + 1 : _tcslen(keyPath) + 1); - /* Special case for root to expand root key abbreviations */ - if (hItem == hRoot) - { - if (!_tcsicmp(szPathPart, TEXT("HKCR"))) - _tcscpy(szPathPart, TEXT("HKEY_CLASSES_ROOT")); - else if (!_tcsicmp(szPathPart, TEXT("HKCU"))) - _tcscpy(szPathPart, TEXT("HKEY_CURRENT_USER")); - else if (!_tcsicmp(szPathPart, TEXT("HKLM"))) - _tcscpy(szPathPart, TEXT("HKEY_LOCAL_MACHINE")); - else if (!_tcsicmp(szPathPart, TEXT("HKU"))) - _tcscpy(szPathPart, TEXT("HKEY_USERS")); - else if (!_tcsicmp(szPathPart, TEXT("HKCC"))) - _tcscpy(szPathPart, TEXT("HKEY_CURRENT_CONFIG")); - else if (!_tcsicmp(szPathPart, TEXT("HKDD"))) - _tcscpy(szPathPart, TEXT("HKEY_DYN_DATA")); - } + /* Special case for root to expand root key abbreviations */ + if (hItem == hRoot) + { + if (!_tcsicmp(szPathPart, TEXT("HKCR"))) + _tcscpy(szPathPart, TEXT("HKEY_CLASSES_ROOT")); + else if (!_tcsicmp(szPathPart, TEXT("HKCU"))) + _tcscpy(szPathPart, TEXT("HKEY_CURRENT_USER")); + else if (!_tcsicmp(szPathPart, TEXT("HKLM"))) + _tcscpy(szPathPart, TEXT("HKEY_LOCAL_MACHINE")); + else if (!_tcsicmp(szPathPart, TEXT("HKU"))) + _tcscpy(szPathPart, TEXT("HKEY_USERS")); + else if (!_tcsicmp(szPathPart, TEXT("HKCC"))) + _tcscpy(szPathPart, TEXT("HKEY_CURRENT_CONFIG")); + else if (!_tcsicmp(szPathPart, TEXT("HKDD"))) + _tcscpy(szPathPart, TEXT("HKEY_DYN_DATA")); + } - for (hChildItem = TreeView_GetChild(hwndTV, hItem); hChildItem; - hChildItem = TreeView_GetNextSibling(hwndTV, hChildItem)) - { - memset(&tvi, 0, sizeof(tvi)); - tvi.hItem = hChildItem; - tvi.mask = TVIF_TEXT | TVIF_CHILDREN; - tvi.pszText = szBuffer; - tvi.cchTextMax = sizeof(szBuffer) / sizeof(szBuffer[0]); + for (hChildItem = TreeView_GetChild(hwndTV, hItem); hChildItem; + hChildItem = TreeView_GetNextSibling(hwndTV, hChildItem)) + { + memset(&tvi, 0, sizeof(tvi)); + tvi.hItem = hChildItem; + tvi.mask = TVIF_TEXT | TVIF_CHILDREN; + tvi.pszText = szBuffer; + tvi.cchTextMax = sizeof(szBuffer) / sizeof(szBuffer[0]); - (void)TreeView_GetItem(hwndTV, &tvi); + (void)TreeView_GetItem(hwndTV, &tvi); - if (!_tcsicmp(szBuffer, szPathPart)) - break; - } + if (!_tcsicmp(szBuffer, szPathPart)) + break; + } - if (!hChildItem) - return FALSE; + if (!hChildItem) + return FALSE; - if (tvi.cChildren > 0) - { - if (!TreeView_Expand(hwndTV, hChildItem, TVE_EXPAND)) - return FALSE; - } + if (tvi.cChildren > 0) + { + if (!TreeView_Expand(hwndTV, hChildItem, TVE_EXPAND)) + return FALSE; + } - keyPath = s ? s + 1 : _T(""); - hItem = hChildItem; - } + keyPath = s ? s + 1 : _T(""); + hItem = hChildItem; + } - (void)TreeView_SelectItem(hwndTV, hItem); - (void)TreeView_EnsureVisible(hwndTV, hItem); + (void)TreeView_SelectItem(hwndTV, hItem); + (void)TreeView_EnsureVisible(hwndTV, hItem); - return TRUE; + return TRUE; } From bbb9384573568a2469b361a2c33c434983831d90 Mon Sep 17 00:00:00 2001 From: Aleksey Bragin Date: Tue, 7 Dec 2010 22:07:00 +0000 Subject: [PATCH 035/181] [DDK] - Oleg Baikalow: Fix NDIS macros. svn path=/trunk/; revision=49982 --- reactos/include/ddk/ndis.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/reactos/include/ddk/ndis.h b/reactos/include/ddk/ndis.h index 1df0998f115..ff15a1fee03 100644 --- a/reactos/include/ddk/ndis.h +++ b/reactos/include/ddk/ndis.h @@ -3296,7 +3296,7 @@ NdisQueryBufferOffset( * NDIS_BUFFER_LINKAGE( * IN PNDIS_BUFFER Buffer); */ -#define NDIS_BUFFER_LINKAGE(Buffer)(Buffer)->Next; +#define NDIS_BUFFER_LINKAGE(Buffer) (Buffer)->Next /* * VOID @@ -3321,7 +3321,7 @@ NdisQueryBufferOffset( * NdisGetPacketFlags( * IN PNDIS_PACKET Packet); */ -#define NdisGetPacketFlags(Packet)(Packet)->Private.Flags; +#define NdisGetPacketFlags(Packet) (Packet)->Private.Flags /* * ULONG From f1892bd3a354c67719f718edea2feea0e767f918 Mon Sep 17 00:00:00 2001 From: Colin Finck Date: Wed, 8 Dec 2010 16:42:47 +0000 Subject: [PATCH 036/181] Remove the "irc", "press-media" and "tools" directories. They were moved to the "press-media" and "project-tools" repositories now. svn path=/trunk/; revision=49986 --- irc/ArchBlackmann/ArchBlackmann.cpp | 608 ---- irc/ArchBlackmann/ArchBlackmann.dsp | 216 -- irc/ArchBlackmann/ArchBlackmann.dsw | 29 - irc/ArchBlackmann/File.cpp | 265 -- irc/ArchBlackmann/File.h | 173 - irc/ArchBlackmann/IRCClient.cpp | 418 --- irc/ArchBlackmann/IRCClient.h | 148 - irc/ArchBlackmann/MD5.cpp | 418 --- irc/ArchBlackmann/MD5.h | 95 - irc/ArchBlackmann/QueueT.h | 315 -- irc/ArchBlackmann/Reli.h | 143 - irc/ArchBlackmann/ReliMT.cpp | 331 -- irc/ArchBlackmann/ReliMT.h | 229 -- irc/ArchBlackmann/SockUtils.cpp | 504 --- irc/ArchBlackmann/SockUtils.h | 132 - irc/ArchBlackmann/SplitJoin.cpp | 96 - irc/ArchBlackmann/SplitJoin.h | 32 - irc/ArchBlackmann/ThreadPool.cpp | 240 -- irc/ArchBlackmann/ThreadPool.h | 28 - irc/ArchBlackmann/auto_ptr.h | 87 - irc/ArchBlackmann/auto_vector.h | 141 - irc/ArchBlackmann/base64.cpp | 58 - irc/ArchBlackmann/base64.h | 12 - irc/ArchBlackmann/chomp.cpp | 15 - irc/ArchBlackmann/chomp.h | 13 - irc/ArchBlackmann/config.h | 7 - irc/ArchBlackmann/cram_md5.cpp | 23 - irc/ArchBlackmann/cram_md5.h | 15 - irc/ArchBlackmann/curse.txt | 1 - irc/ArchBlackmann/cursecop.txt | 10 - irc/ArchBlackmann/dev.txt | 15 - irc/ArchBlackmann/func.txt | 580 ---- irc/ArchBlackmann/grovel.txt | 10 - irc/ArchBlackmann/idle.txt | 1 - irc/ArchBlackmann/irql.txt | 9 - irc/ArchBlackmann/makefile | 38 - irc/ArchBlackmann/module.txt | 13 - irc/ArchBlackmann/nogrovel.txt | 5 - irc/ArchBlackmann/panic.cpp | 34 - irc/ArchBlackmann/panic.h | 18 - irc/ArchBlackmann/period.txt | 11 - irc/ArchBlackmann/readme.txt | 44 - irc/ArchBlackmann/ssprintf.cpp | 998 ------ irc/ArchBlackmann/ssprintf.h | 12 - irc/ArchBlackmann/status.txt | 654 ---- irc/ArchBlackmann/stru.txt | 7 - irc/ArchBlackmann/tech.txt | 73 - irc/ArchBlackmann/trim.cpp | 17 - irc/ArchBlackmann/trim.h | 13 - irc/ArchBlackmann/type.txt | 1000 ------ irc/ArchBlackmann/verify.h | 37 - irc/TechBot/CHMLibrary/AssemblyInfo.cs | 32 - .../CHMDecoding/BinaryReaderHelp.cs | 274 -- .../CHMLibrary/CHMDecoding/CHMBtree.cs | 325 -- irc/TechBot/CHMLibrary/CHMDecoding/CHMFile.cs | 2061 ------------ .../CHMLibrary/CHMDecoding/CHMIdxhdr.cs | 286 -- .../CHMLibrary/CHMDecoding/CHMStrings.cs | 256 -- .../CHMLibrary/CHMDecoding/CHMSystem.cs | 821 ----- .../CHMLibrary/CHMDecoding/CHMTocidx.cs | 288 -- .../CHMLibrary/CHMDecoding/CHMTopics.cs | 235 -- .../CHMLibrary/CHMDecoding/CHMUrlstr.cs | 308 -- .../CHMLibrary/CHMDecoding/CHMUrltable.cs | 245 -- .../CHMLibrary/CHMDecoding/DumpingInfo.cs | 395 --- .../CHMLibrary/CHMDecoding/FullTextEngine.cs | 1131 ------- .../CHMLibrary/CHMDecoding/HHCParser.cs | 593 ---- .../CHMLibrary/CHMDecoding/HHCParser2.cs | 220 -- .../CHMLibrary/CHMDecoding/HHKParser.cs | 550 ---- .../CHMLibrary/CHMDecoding/TopicEntry.cs | 245 -- .../CHMLibrary/CHMDecoding/UrlTableEntry.cs | 175 - .../CHMLibrary/CHMDecoding/enumerations.cs | 19 - irc/TechBot/CHMLibrary/CHMLibrary.cmbx | 16 - irc/TechBot/CHMLibrary/CHMLibrary.csproj | 85 - irc/TechBot/CHMLibrary/CHMLibrary.prjx | 58 - irc/TechBot/CHMLibrary/Category.cs | 201 -- irc/TechBot/CHMLibrary/ChmFileInfo.cs | 478 --- irc/TechBot/CHMLibrary/Default.build | 23 - irc/TechBot/CHMLibrary/HtmlHelpSystem.cs | 894 ------ irc/TechBot/CHMLibrary/HttpUtility.cs | 855 ----- irc/TechBot/CHMLibrary/Index.cs | 322 -- irc/TechBot/CHMLibrary/IndexItem.cs | 396 --- irc/TechBot/CHMLibrary/IndexTopic.cs | 216 -- irc/TechBot/CHMLibrary/InformationType.cs | 146 - irc/TechBot/CHMLibrary/Storage/CHMStream.cs | 2842 ----------------- irc/TechBot/CHMLibrary/TOCItem.cs | 494 --- irc/TechBot/CHMLibrary/TableOfContents.cs | 198 -- irc/TechBot/Compression/AssemblyInfo.cs | 32 - irc/TechBot/Compression/Checksums/Adler32.cs | 200 -- irc/TechBot/Compression/Checksums/CRC32.cs | 211 -- .../Compression/Checksums/IChecksum.cs | 93 - .../Compression/Checksums/StrangeCRC.cs | 159 - irc/TechBot/Compression/Compression.cmbx | 16 - irc/TechBot/Compression/Compression.csproj | 65 - irc/TechBot/Compression/Compression.prjx | 45 - irc/TechBot/Compression/Default.build | 20 - irc/TechBot/Compression/Deflater.cs | 542 ---- irc/TechBot/Compression/DeflaterConstants.cs | 85 - irc/TechBot/Compression/DeflaterEngine.cs | 653 ---- irc/TechBot/Compression/DeflaterHuffman.cs | 780 ----- irc/TechBot/Compression/DeflaterPending.cs | 52 - irc/TechBot/Compression/Inflater.cs | 782 ----- irc/TechBot/Compression/InflaterDynHeader.cs | 207 -- .../Compression/InflaterHuffmanTree.cs | 213 -- irc/TechBot/Compression/PendingBuffer.cs | 210 -- .../Streams/DeflaterOutputStream.cs | 379 --- .../Streams/InflaterInputStream.cs | 386 --- .../Compression/Streams/OutputWindow.cs | 176 - .../Compression/Streams/StreamManipulator.cs | 245 -- irc/TechBot/Compression/ZipException.cs | 62 - irc/TechBot/Resources/hresult.xml | 1088 ------- irc/TechBot/Resources/ntstatus.xml | 1111 ------- irc/TechBot/Resources/winerror.xml | 1839 ----------- irc/TechBot/Resources/wm.xml | 321 -- .../Base/BugCommand.cs | 42 - .../TechBot.Commands.Common/ErrorCommand.cs | 180 -- .../TechBot.Commands.Common/HResultCommand.cs | 66 - .../NtStatusCommand.cs | 66 - .../Properties/AssemblyInfo.cs | 35 - .../TechBot.Commands.Common/ReactOSBugUrl.cs | 21 - .../TechBot.Commands.Common/SambaBugUrl.cs | 21 - .../Settings.Designer.cs | 71 - .../TechBot.Commands.Common/Settings.cs | 28 - .../TechBot.Commands.Common/Settings.settings | 21 - .../TechBot.Commands.Common/SvnCommand.cs | 22 - .../TechBot.Commands.Common.csproj | 75 - .../TechBot.Commands.Common/WMCommand.cs | 94 - .../TechBot.Commands.Common/WineBugUrl.cs | 21 - .../WinerrorCommand.cs | 66 - .../TechBot.Commands.Common/app.config | 27 - .../TechBot.Commands.MSDN/ApiCommand.cs | 309 -- .../Properties/AssemblyInfo.cs | 35 - .../Settings.Designer.cs | 50 - .../TechBot.Commands.MSDN/Settings.settings | 12 - .../TechBot.Commands.MSDN.csproj | 69 - .../TechBot.Commands.MSDN.csproj.user | 5 - irc/TechBot/TechBot.Commands.MSDN/app.config | 18 - irc/TechBot/TechBot.Console/App.config | 27 - irc/TechBot/TechBot.Console/AssemblyInfo.cs | 32 - .../TechBot.Console/ConsoleTechBotService.cs | 37 - irc/TechBot/TechBot.Console/Default.build | 23 - irc/TechBot/TechBot.Console/Main.cs | 29 - .../TechBot.Console/Properties/.gitignore | 0 .../TechBot.Console/Settings.Designer.cs | 86 - irc/TechBot/TechBot.Console/Settings.settings | 21 - .../TechBot.Console/TechBot.Console.cmbx | 16 - .../TechBot.Console/TechBot.Console.csproj | 80 - .../TechBot.Console/TechBot.Console.prjx | 29 - .../TechBot.IRCLibrary/AssemblyInfo.cs | 32 - irc/TechBot/TechBot.IRCLibrary/Default.build | 20 - irc/TechBot/TechBot.IRCLibrary/IRC.cs | 30 - irc/TechBot/TechBot.IRCLibrary/IrcChannel.cs | 137 - irc/TechBot/TechBot.IRCLibrary/IrcClient.cs | 794 ----- .../TechBot.IRCLibrary/IrcException.cs | 50 - irc/TechBot/TechBot.IRCLibrary/IrcMessage.cs | 503 --- irc/TechBot/TechBot.IRCLibrary/IrcUser.cs | 132 - .../TechBot.IRCLibrary/Properties/.gitignore | 0 .../TechBot.IRCLibrary.cmbx | 16 - .../TechBot.IRCLibrary.csproj | 59 - .../TechBot.IRCLibrary.prjx | 31 - irc/TechBot/TechBot.IRCLibrary/app.config | 15 - .../Attributes/CommandAttribute.cs | 35 - .../CommandParameterAliasAttribute.cs | 34 - .../Attributes/CommandParameterAttribute.cs | 50 - .../Collections/CommandBuilderCollection.cs | 20 - .../TechBot.Library/Commands/Base/Command.cs | 90 - .../Commands/Base/XmlCommand.cs | 25 - .../Commands/Base/XmlLookupCommand.cs | 15 - .../TechBot.Library/Commands/HelpCommand.cs | 78 - .../TechBot.Library/Factory/CommandBuilder.cs | 52 - .../TechBot.Library/Factory/CommandFactory.cs | 60 - irc/TechBot/TechBot.Library/MessageContext.cs | 39 - irc/TechBot/TechBot.Library/NumberParser.cs | 62 - .../TechBot.Library/Properties/.gitignore | 0 .../Properties/AssemblyInfo.cs | 32 - irc/TechBot/TechBot.Library/ServiceOutput.cs | 9 - .../TechBot.Library/Settings.Designer.cs | 80 - irc/TechBot/TechBot.Library/Settings.cs | 28 - irc/TechBot/TechBot.Library/Settings.settings | 24 - .../TechBot.Library/TechBot.Library.csproj | 83 - .../TechBot.Library/TechBotIrcService.cs | 312 -- irc/TechBot/TechBot.Library/TechBotService.cs | 101 - irc/TechBot/TechBot.Library/app.config | 30 - irc/TechBot/TechBot.sln | 62 - irc/TechBot/TechBot/App.config | 44 - irc/TechBot/TechBot/AssemblyInfo.cs | 32 - irc/TechBot/TechBot/Default.build | 23 - irc/TechBot/TechBot/ProjectInstaller.cs | 28 - irc/TechBot/TechBot/Properties/.gitignore | 0 irc/TechBot/TechBot/ServiceThread.cs | 43 - irc/TechBot/TechBot/Settings.Designer.cs | 86 - irc/TechBot/TechBot/Settings.settings | 21 - irc/TechBot/TechBot/TechBot.csproj | 82 - irc/TechBot/TechBot/TechBot.prjx | 30 - irc/TechBot/TechBot/TechBotService.cs | 82 - 193 files changed, 39391 deletions(-) delete mode 100644 irc/ArchBlackmann/ArchBlackmann.cpp delete mode 100644 irc/ArchBlackmann/ArchBlackmann.dsp delete mode 100644 irc/ArchBlackmann/ArchBlackmann.dsw delete mode 100644 irc/ArchBlackmann/File.cpp delete mode 100644 irc/ArchBlackmann/File.h delete mode 100644 irc/ArchBlackmann/IRCClient.cpp delete mode 100644 irc/ArchBlackmann/IRCClient.h delete mode 100644 irc/ArchBlackmann/MD5.cpp delete mode 100644 irc/ArchBlackmann/MD5.h delete mode 100644 irc/ArchBlackmann/QueueT.h delete mode 100644 irc/ArchBlackmann/Reli.h delete mode 100644 irc/ArchBlackmann/ReliMT.cpp delete mode 100644 irc/ArchBlackmann/ReliMT.h delete mode 100644 irc/ArchBlackmann/SockUtils.cpp delete mode 100644 irc/ArchBlackmann/SockUtils.h delete mode 100644 irc/ArchBlackmann/SplitJoin.cpp delete mode 100644 irc/ArchBlackmann/SplitJoin.h delete mode 100644 irc/ArchBlackmann/ThreadPool.cpp delete mode 100644 irc/ArchBlackmann/ThreadPool.h delete mode 100644 irc/ArchBlackmann/auto_ptr.h delete mode 100644 irc/ArchBlackmann/auto_vector.h delete mode 100644 irc/ArchBlackmann/base64.cpp delete mode 100644 irc/ArchBlackmann/base64.h delete mode 100644 irc/ArchBlackmann/chomp.cpp delete mode 100644 irc/ArchBlackmann/chomp.h delete mode 100644 irc/ArchBlackmann/config.h delete mode 100644 irc/ArchBlackmann/cram_md5.cpp delete mode 100644 irc/ArchBlackmann/cram_md5.h delete mode 100644 irc/ArchBlackmann/curse.txt delete mode 100644 irc/ArchBlackmann/cursecop.txt delete mode 100644 irc/ArchBlackmann/dev.txt delete mode 100644 irc/ArchBlackmann/func.txt delete mode 100644 irc/ArchBlackmann/grovel.txt delete mode 100644 irc/ArchBlackmann/idle.txt delete mode 100644 irc/ArchBlackmann/irql.txt delete mode 100644 irc/ArchBlackmann/makefile delete mode 100644 irc/ArchBlackmann/module.txt delete mode 100644 irc/ArchBlackmann/nogrovel.txt delete mode 100644 irc/ArchBlackmann/panic.cpp delete mode 100644 irc/ArchBlackmann/panic.h delete mode 100644 irc/ArchBlackmann/period.txt delete mode 100644 irc/ArchBlackmann/readme.txt delete mode 100644 irc/ArchBlackmann/ssprintf.cpp delete mode 100644 irc/ArchBlackmann/ssprintf.h delete mode 100644 irc/ArchBlackmann/status.txt delete mode 100644 irc/ArchBlackmann/stru.txt delete mode 100644 irc/ArchBlackmann/tech.txt delete mode 100644 irc/ArchBlackmann/trim.cpp delete mode 100644 irc/ArchBlackmann/trim.h delete mode 100644 irc/ArchBlackmann/type.txt delete mode 100644 irc/ArchBlackmann/verify.h delete mode 100644 irc/TechBot/CHMLibrary/AssemblyInfo.cs delete mode 100644 irc/TechBot/CHMLibrary/CHMDecoding/BinaryReaderHelp.cs delete mode 100644 irc/TechBot/CHMLibrary/CHMDecoding/CHMBtree.cs delete mode 100644 irc/TechBot/CHMLibrary/CHMDecoding/CHMFile.cs delete mode 100644 irc/TechBot/CHMLibrary/CHMDecoding/CHMIdxhdr.cs delete mode 100644 irc/TechBot/CHMLibrary/CHMDecoding/CHMStrings.cs delete mode 100644 irc/TechBot/CHMLibrary/CHMDecoding/CHMSystem.cs delete mode 100644 irc/TechBot/CHMLibrary/CHMDecoding/CHMTocidx.cs delete mode 100644 irc/TechBot/CHMLibrary/CHMDecoding/CHMTopics.cs delete mode 100644 irc/TechBot/CHMLibrary/CHMDecoding/CHMUrlstr.cs delete mode 100644 irc/TechBot/CHMLibrary/CHMDecoding/CHMUrltable.cs delete mode 100644 irc/TechBot/CHMLibrary/CHMDecoding/DumpingInfo.cs delete mode 100644 irc/TechBot/CHMLibrary/CHMDecoding/FullTextEngine.cs delete mode 100644 irc/TechBot/CHMLibrary/CHMDecoding/HHCParser.cs delete mode 100644 irc/TechBot/CHMLibrary/CHMDecoding/HHCParser2.cs delete mode 100644 irc/TechBot/CHMLibrary/CHMDecoding/HHKParser.cs delete mode 100644 irc/TechBot/CHMLibrary/CHMDecoding/TopicEntry.cs delete mode 100644 irc/TechBot/CHMLibrary/CHMDecoding/UrlTableEntry.cs delete mode 100644 irc/TechBot/CHMLibrary/CHMDecoding/enumerations.cs delete mode 100644 irc/TechBot/CHMLibrary/CHMLibrary.cmbx delete mode 100644 irc/TechBot/CHMLibrary/CHMLibrary.csproj delete mode 100644 irc/TechBot/CHMLibrary/CHMLibrary.prjx delete mode 100644 irc/TechBot/CHMLibrary/Category.cs delete mode 100644 irc/TechBot/CHMLibrary/ChmFileInfo.cs delete mode 100644 irc/TechBot/CHMLibrary/Default.build delete mode 100644 irc/TechBot/CHMLibrary/HtmlHelpSystem.cs delete mode 100644 irc/TechBot/CHMLibrary/HttpUtility.cs delete mode 100644 irc/TechBot/CHMLibrary/Index.cs delete mode 100644 irc/TechBot/CHMLibrary/IndexItem.cs delete mode 100644 irc/TechBot/CHMLibrary/IndexTopic.cs delete mode 100644 irc/TechBot/CHMLibrary/InformationType.cs delete mode 100644 irc/TechBot/CHMLibrary/Storage/CHMStream.cs delete mode 100644 irc/TechBot/CHMLibrary/TOCItem.cs delete mode 100644 irc/TechBot/CHMLibrary/TableOfContents.cs delete mode 100644 irc/TechBot/Compression/AssemblyInfo.cs delete mode 100644 irc/TechBot/Compression/Checksums/Adler32.cs delete mode 100644 irc/TechBot/Compression/Checksums/CRC32.cs delete mode 100644 irc/TechBot/Compression/Checksums/IChecksum.cs delete mode 100644 irc/TechBot/Compression/Checksums/StrangeCRC.cs delete mode 100644 irc/TechBot/Compression/Compression.cmbx delete mode 100644 irc/TechBot/Compression/Compression.csproj delete mode 100644 irc/TechBot/Compression/Compression.prjx delete mode 100644 irc/TechBot/Compression/Default.build delete mode 100644 irc/TechBot/Compression/Deflater.cs delete mode 100644 irc/TechBot/Compression/DeflaterConstants.cs delete mode 100644 irc/TechBot/Compression/DeflaterEngine.cs delete mode 100644 irc/TechBot/Compression/DeflaterHuffman.cs delete mode 100644 irc/TechBot/Compression/DeflaterPending.cs delete mode 100644 irc/TechBot/Compression/Inflater.cs delete mode 100644 irc/TechBot/Compression/InflaterDynHeader.cs delete mode 100644 irc/TechBot/Compression/InflaterHuffmanTree.cs delete mode 100644 irc/TechBot/Compression/PendingBuffer.cs delete mode 100644 irc/TechBot/Compression/Streams/DeflaterOutputStream.cs delete mode 100644 irc/TechBot/Compression/Streams/InflaterInputStream.cs delete mode 100644 irc/TechBot/Compression/Streams/OutputWindow.cs delete mode 100644 irc/TechBot/Compression/Streams/StreamManipulator.cs delete mode 100644 irc/TechBot/Compression/ZipException.cs delete mode 100644 irc/TechBot/Resources/hresult.xml delete mode 100644 irc/TechBot/Resources/ntstatus.xml delete mode 100644 irc/TechBot/Resources/winerror.xml delete mode 100644 irc/TechBot/Resources/wm.xml delete mode 100644 irc/TechBot/TechBot.Commands.Common/Base/BugCommand.cs delete mode 100644 irc/TechBot/TechBot.Commands.Common/ErrorCommand.cs delete mode 100644 irc/TechBot/TechBot.Commands.Common/HResultCommand.cs delete mode 100644 irc/TechBot/TechBot.Commands.Common/NtStatusCommand.cs delete mode 100644 irc/TechBot/TechBot.Commands.Common/Properties/AssemblyInfo.cs delete mode 100644 irc/TechBot/TechBot.Commands.Common/ReactOSBugUrl.cs delete mode 100644 irc/TechBot/TechBot.Commands.Common/SambaBugUrl.cs delete mode 100644 irc/TechBot/TechBot.Commands.Common/Settings.Designer.cs delete mode 100644 irc/TechBot/TechBot.Commands.Common/Settings.cs delete mode 100644 irc/TechBot/TechBot.Commands.Common/Settings.settings delete mode 100644 irc/TechBot/TechBot.Commands.Common/SvnCommand.cs delete mode 100644 irc/TechBot/TechBot.Commands.Common/TechBot.Commands.Common.csproj delete mode 100644 irc/TechBot/TechBot.Commands.Common/WMCommand.cs delete mode 100644 irc/TechBot/TechBot.Commands.Common/WineBugUrl.cs delete mode 100644 irc/TechBot/TechBot.Commands.Common/WinerrorCommand.cs delete mode 100644 irc/TechBot/TechBot.Commands.Common/app.config delete mode 100644 irc/TechBot/TechBot.Commands.MSDN/ApiCommand.cs delete mode 100644 irc/TechBot/TechBot.Commands.MSDN/Properties/AssemblyInfo.cs delete mode 100644 irc/TechBot/TechBot.Commands.MSDN/Settings.Designer.cs delete mode 100644 irc/TechBot/TechBot.Commands.MSDN/Settings.settings delete mode 100644 irc/TechBot/TechBot.Commands.MSDN/TechBot.Commands.MSDN.csproj delete mode 100644 irc/TechBot/TechBot.Commands.MSDN/TechBot.Commands.MSDN.csproj.user delete mode 100644 irc/TechBot/TechBot.Commands.MSDN/app.config delete mode 100644 irc/TechBot/TechBot.Console/App.config delete mode 100644 irc/TechBot/TechBot.Console/AssemblyInfo.cs delete mode 100644 irc/TechBot/TechBot.Console/ConsoleTechBotService.cs delete mode 100644 irc/TechBot/TechBot.Console/Default.build delete mode 100644 irc/TechBot/TechBot.Console/Main.cs delete mode 100644 irc/TechBot/TechBot.Console/Properties/.gitignore delete mode 100644 irc/TechBot/TechBot.Console/Settings.Designer.cs delete mode 100644 irc/TechBot/TechBot.Console/Settings.settings delete mode 100644 irc/TechBot/TechBot.Console/TechBot.Console.cmbx delete mode 100644 irc/TechBot/TechBot.Console/TechBot.Console.csproj delete mode 100644 irc/TechBot/TechBot.Console/TechBot.Console.prjx delete mode 100644 irc/TechBot/TechBot.IRCLibrary/AssemblyInfo.cs delete mode 100644 irc/TechBot/TechBot.IRCLibrary/Default.build delete mode 100644 irc/TechBot/TechBot.IRCLibrary/IRC.cs delete mode 100644 irc/TechBot/TechBot.IRCLibrary/IrcChannel.cs delete mode 100644 irc/TechBot/TechBot.IRCLibrary/IrcClient.cs delete mode 100644 irc/TechBot/TechBot.IRCLibrary/IrcException.cs delete mode 100644 irc/TechBot/TechBot.IRCLibrary/IrcMessage.cs delete mode 100644 irc/TechBot/TechBot.IRCLibrary/IrcUser.cs delete mode 100644 irc/TechBot/TechBot.IRCLibrary/Properties/.gitignore delete mode 100644 irc/TechBot/TechBot.IRCLibrary/TechBot.IRCLibrary.cmbx delete mode 100644 irc/TechBot/TechBot.IRCLibrary/TechBot.IRCLibrary.csproj delete mode 100644 irc/TechBot/TechBot.IRCLibrary/TechBot.IRCLibrary.prjx delete mode 100644 irc/TechBot/TechBot.IRCLibrary/app.config delete mode 100644 irc/TechBot/TechBot.Library/Attributes/CommandAttribute.cs delete mode 100644 irc/TechBot/TechBot.Library/Attributes/CommandParameterAliasAttribute.cs delete mode 100644 irc/TechBot/TechBot.Library/Attributes/CommandParameterAttribute.cs delete mode 100644 irc/TechBot/TechBot.Library/Collections/CommandBuilderCollection.cs delete mode 100644 irc/TechBot/TechBot.Library/Commands/Base/Command.cs delete mode 100644 irc/TechBot/TechBot.Library/Commands/Base/XmlCommand.cs delete mode 100644 irc/TechBot/TechBot.Library/Commands/Base/XmlLookupCommand.cs delete mode 100644 irc/TechBot/TechBot.Library/Commands/HelpCommand.cs delete mode 100644 irc/TechBot/TechBot.Library/Factory/CommandBuilder.cs delete mode 100644 irc/TechBot/TechBot.Library/Factory/CommandFactory.cs delete mode 100644 irc/TechBot/TechBot.Library/MessageContext.cs delete mode 100644 irc/TechBot/TechBot.Library/NumberParser.cs delete mode 100644 irc/TechBot/TechBot.Library/Properties/.gitignore delete mode 100644 irc/TechBot/TechBot.Library/Properties/AssemblyInfo.cs delete mode 100644 irc/TechBot/TechBot.Library/ServiceOutput.cs delete mode 100644 irc/TechBot/TechBot.Library/Settings.Designer.cs delete mode 100644 irc/TechBot/TechBot.Library/Settings.cs delete mode 100644 irc/TechBot/TechBot.Library/Settings.settings delete mode 100644 irc/TechBot/TechBot.Library/TechBot.Library.csproj delete mode 100644 irc/TechBot/TechBot.Library/TechBotIrcService.cs delete mode 100644 irc/TechBot/TechBot.Library/TechBotService.cs delete mode 100644 irc/TechBot/TechBot.Library/app.config delete mode 100644 irc/TechBot/TechBot.sln delete mode 100644 irc/TechBot/TechBot/App.config delete mode 100644 irc/TechBot/TechBot/AssemblyInfo.cs delete mode 100644 irc/TechBot/TechBot/Default.build delete mode 100644 irc/TechBot/TechBot/ProjectInstaller.cs delete mode 100644 irc/TechBot/TechBot/Properties/.gitignore delete mode 100644 irc/TechBot/TechBot/ServiceThread.cs delete mode 100644 irc/TechBot/TechBot/Settings.Designer.cs delete mode 100644 irc/TechBot/TechBot/Settings.settings delete mode 100644 irc/TechBot/TechBot/TechBot.csproj delete mode 100644 irc/TechBot/TechBot/TechBot.prjx delete mode 100644 irc/TechBot/TechBot/TechBotService.cs diff --git a/irc/ArchBlackmann/ArchBlackmann.cpp b/irc/ArchBlackmann/ArchBlackmann.cpp deleted file mode 100644 index 1d71f748847..00000000000 --- a/irc/ArchBlackmann/ArchBlackmann.cpp +++ /dev/null @@ -1,608 +0,0 @@ -// irc_test.cpp - -#ifdef _MSC_VER -#pragma warning ( disable : 4786 ) -#endif//_MSC_VER - -#include -#include - -#include "File.h" -#include "ssprintf.h" -#include "trim.h" - -#include "IRCClient.h" -#include "config.h" - -using std::string; -using std::vector; - -//vector tech, module, dev, stru, period, status, type, func, irql, curse, cursecop; - -class List -{ -public: - string name; - bool macro; - std::vector list; - string tag; - int last; - List() { last = -1; } - List ( const char* _name, bool _macro ) : name(_name), macro(_macro) - { - tag = ssprintf("%%%s%%",_name); - last = -1; - } -}; - -vector lists; -vector ops; - -void ImportList ( const char* listname, bool macro ) -{ - lists.push_back ( List ( listname, macro ) ); - List& list = lists.back(); - File f ( ssprintf("%s.txt",listname).c_str(), "r" ); - string line; - while ( f.next_line ( line, true ) ) - list.list.push_back ( line ); -} - -const char* ListRand ( List& list ) -{ - vector& l = list.list; - if ( !l.size() ) - { - static string nothing; - nothing = ssprintf ( "", list.name.c_str() ); - return nothing.c_str(); - } - else if ( l.size() == 1 ) - return l[0].c_str(); - int sel = list.last; - while ( sel == list.last ) - sel = rand()%l.size(); - list.last = sel; - return l[sel].c_str(); -} - -const char* ListRand ( int i ) -{ - return ListRand ( lists[i] ); -} - -int GetListIndex ( const char* listname ) -{ - for ( int i = 0; i < lists.size(); i++ ) - { - if ( !stricmp ( lists[i].name.c_str(), listname ) ) - return i; - } - return -1; -} - -List& GetList ( const char* listname ) -{ - return lists[GetListIndex(listname)]; -} - -const char* ListRand ( const char* list ) -{ - int i = GetListIndex ( list ); - if ( i < 0 ) - return NULL; - return ListRand(i); -} - -string TaggedReply ( const char* listname ) -{ - string t = ListRand(listname); - string out; - const char* p = t.c_str(); - while ( *p ) - { - if ( *p == '%' ) - { - bool found = false; - for ( int i = 0; i < lists.size() && !found; i++ ) - { - if ( lists[i].macro && !strnicmp ( p, lists[i].tag.c_str(), lists[i].tag.size() ) ) - { - out += ListRand(i); - p += lists[i].tag.size(); - found = true; - } - } - if ( !found ) - out += *p++; - } - const char* p2 = strchr ( p, '%' ); - if ( !p2 ) - p2 = p + strlen(p); - if ( p2 > p ) - { - out += string ( p, p2-p ); - p = p2; - } - } - return out; -} - -string gobble ( string& s, const char* delim ) -{ - const char* p = s.c_str(); - p += strspn ( p, delim ); - const char* p2 = strpbrk ( p, delim ); - if ( !p2 ) p2 = p + strlen(p); - string out ( p, p2-p ); - p2 += strspn ( p2, delim ); - s = string ( p2 ); - return out; -} - -bool isop ( const string& who ) -{ - for ( int i = 0; i < ops.size(); i++ ) - { - if ( ops[i] == who ) - return true; - } - return false; -} - - -// do custom stuff with the IRCClient from your subclass via the provided callbacks... -class MyIRCClient : public IRCClient -{ - File flog; - clock_t brake_silence; - - // wait another 30 mins to brake the silence - #define NOIDLE brake_silence = clock () + 30 * CLK_TCK * 60 - - void CheckIdle ( void ) - { - while (true) // _inRun - { - while (clock() < brake_silence) - Sleep(10000); - - string out = TaggedReply("idle"); - - if ( !strnicmp ( out.c_str(), "/me ", 4 ) ) - Action ( CHANNEL, &out[4] ); - else - PrivMsg ( CHANNEL, out ); - - NOIDLE; - } - } - - static void THREADAPI CallMe ( MyIRCClient* irc ) - { - irc->CheckIdle(); - } - -public: - - MyIRCClient() - { - NOIDLE; - ThreadPool::Instance().Launch ( (ThreadPoolFunc*)MyIRCClient::CallMe, this ); - flog.open ( "arch.log", "r+" ); - } - // see IRCClient.h for documentation on these callbacks... - bool OnConnected() - { - return true; - } - bool OnJoin ( const string& user, const string& channel ) - { - //printf ( "user '%s' joined channel '%s'\n", user.c_str(), channel.c_str() ); - return true; - } - bool OnPart ( const std::string& user, const std::string& channel ) - { - std::vector::iterator it = ops.begin(); - for ( ; it != ops.end(); it++ ) - { - if ( *it == user ) - { - printf ( "remove '%s' to ops list\n", user.c_str() ); - ops.erase ( it ); - } - } - return true; - } - bool OnNick ( const std::string& oldNick, const std::string& newNick ) - { - for ( int i = 0; i < ops.size(); i++ ) - { - if ( ops[i] == oldNick ) - { - printf ( "op '%s' changed nick to '%s'\n", oldNick.c_str(), newNick.c_str() ); - ops[i] = newNick; - return true; - } - } - return true; - } - bool OnEndChannelUsers ( const string& channel ) - { - return true; - } - bool OnPrivMsg ( const string& from, const string& text ) - { - //flog.flush(); - printf ( "<%s> %s\n", from.c_str(), text.c_str() ); - flog.printf ( "<%s> %s\n", from.c_str(), text.c_str() ); - - if ( !isop(from) ) - return PrivMsg ( from, "hey, your tongue doesn't belong there!" ); - - else if ( strnicmp ( text.c_str(), "!say ", 5 ) ) - return PrivMsg ( from, "Talk to me on normal Chanel" ); - - string say = trim(&text[5]); - - if ( !strnicmp ( say.c_str(), "/me ", 4 ) ) - return Action ( CHANNEL, trim(&say[4]) ); - else - return PrivMsg ( CHANNEL, trim(say) ); - } - bool OnChannelMsg ( const string& channel, const string& from, const string& text ) - { - fflush ( flog ); - printf ( "%s <%s> %s\n", channel.c_str(), from.c_str(), text.c_str() ); - flog.printf ( "%s <%s> %s\n", channel.c_str(), from.c_str(), text.c_str() ); - NOIDLE; // add 30 mins till idle - - bool found_name = false; - string text2 ( text ); - strlwr ( &text2[0] ); - - if ( !strnicmp ( text.c_str(), BOTNAME, strlen(BOTNAME) ) ) - found_name = true; - - string s ( text ); - - if ( found_name ) - gobble ( s, " \t" ); // remove bot name - - // command - if ( s[0] == '!' ) - { - bool from_op = isop(from); - string cmd = gobble ( s, " \t" ); - - // from all - if ( false && cmd == "!svn" && from == "TechBot" ) // || cmd == "!help" && !TechBotOnline - { - PrivMsg ( channel, "For my help try !what." ); - } - - // from normel user - else if ( !from_op ) - { - if ( cmd == "!grovel" ) - { - string out = ssprintf(TaggedReply("nogrovel").c_str(),from.c_str()); - if ( !strnicmp ( out.c_str(), "/me ", 4 ) ) - return Action ( channel, &out[4] ); - else - return PrivMsg ( channel, out ); - } - - else if ( cmd == "!what" ) - { - return PrivMsg ( channel, ssprintf("For you, %s, I only support the \"!grovel\" command.", from.c_str()).c_str() ); - } - - else if ( cmd == "!grovel" || cmd == "!kiss" || cmd == "!hug" - || cmd == "!give" || cmd == "!what" || cmd == "!add" || cmd == "!remove" ) - { - PrivMsg ( channel, ssprintf("%s: I only take commands from ops",from.c_str()) ); - } - } - - // from op - else if ( cmd == "!grovel" ) - { - string out = ssprintf(TaggedReply("grovel").c_str(),from.c_str()); - if ( !strnicmp ( out.c_str(), "/me ", 4 ) ) - return Action ( channel, &out[4] ); - else - return PrivMsg ( channel, out ); - } - else if ( cmd == "!kiss" ) - { - if ( s.size() ) - return Action ( channel, ssprintf("kisses %s",s.c_str()) ); - else - return PrivMsg ( channel, ssprintf("%s: huh?",from.c_str()) ); - } - else if ( cmd == "!hug" ) - { - if ( s.size() ) - return Action ( channel, ssprintf("hugs %s",s.c_str()) ); - else - return PrivMsg ( channel, ssprintf("%s: huh?",from.c_str()) ); - } - else if ( cmd == "!give" ) - { - string who = gobble(s," \t"); - if ( who.size() && s.size() ) - return Action ( channel, ssprintf("gives %s a %s",who.c_str(),s.c_str()) ); - else - return PrivMsg ( channel, ssprintf("%s: huh?",from.c_str()) ); - } - else if ( cmd == "!what" ) - { - PrivMsg ( channel, "For ops I support the following commands:" ); - PrivMsg ( channel, "!grovel" ); - PrivMsg ( channel, "!kiss" ); - PrivMsg ( channel, "!hug" ); - PrivMsg ( channel, "!give" ); - PrivMsg ( channel, "!say (the input is a private message)" ); - PrivMsg ( channel, "!add" ); - PrivMsg ( channel, "!remove" ); - PrivMsg ( channel, " - for more info see wiki" ); - } - else if ( cmd == "!add" ) - { - string listname = gobble ( s, " \t" ); - int i = GetListIndex ( listname.c_str() ); - if ( i == -1 ) - return PrivMsg ( channel, ssprintf("%s: I don't have a list named '%s'",from.c_str(),listname.c_str()) ); - List& list = lists[i]; - if ( s[0] == '\"' || s[0] == '\'' ) - { - char delim = s[0]; - const char* p = &s[1]; - const char* p2 = strchr ( p, delim ); - if ( !p2 ) - return PrivMsg ( channel, ssprintf("%s: Couldn't add, unmatched quotes",from.c_str()) ); - s = string ( p, p2-p ); - } - for ( i = 0; i < list.list.size(); i++ ) - { - if ( list.list[i] == s ) - return PrivMsg ( channel, ssprintf("%s: entry already exists in list '%s'",from.c_str(),listname.c_str()) ); - } - if ( !stricmp ( listname.c_str(), "curse" ) ) - strlwr ( &s[0] ); - list.list.push_back ( s ); - { - File f ( ssprintf("%s.txt",list.name.c_str()), "w" ); - for ( i = 0; i < list.list.size(); i++ ) - f.printf ( "%s\n", list.list[i].c_str() ); - } - return PrivMsg ( channel, ssprintf("%s: entry added to list '%s'",from.c_str(),listname.c_str()) ); - } - else if ( cmd == "!remove" ) - { - string listname = gobble ( s, " \t" ); - int i = GetListIndex ( listname.c_str() ); - if ( i == -1 ) - return PrivMsg ( channel, ssprintf("%s: I don't have a list named '%s'",from.c_str(),listname.c_str()) ); - List& list = lists[i]; - if ( s[0] == '\"' || s[0] == '\'' ) - { - char delim = s[0]; - const char* p = &s[1]; - const char* p2 = strchr ( p, delim ); - if ( !p2 ) - return PrivMsg ( channel, ssprintf("%s: Couldn't add, unmatched quotes",from.c_str()) ); - s = string ( p, p2-p ); - } - std::vector::iterator it = list.list.begin(); - for ( ; it != list.list.end(); it++ ) - { - if ( *it == s ) - { - list.list.erase ( it ); - { - File f ( ssprintf("%s.txt",list.name.c_str()), "w" ); - it = list.list.begin(); - for ( ; it < list.list.end(); it++ ) - f.printf ( "%s\n", it->c_str() ); - } - return PrivMsg ( channel, ssprintf("%s: entry removed from list '%s'",from.c_str(),listname.c_str()) ); - } - } - return PrivMsg ( channel, ssprintf("%s: entry doesn't exist in list '%s'",from.c_str(),listname.c_str()) ); - } - else - { - if (found_name) - return PrivMsg ( channel, ssprintf("%s: huh?",from.c_str()) ); - } - - } // if (command) - - bool found_curse = false; - static vector& curse = GetList("curse").list; - text2 = " " + text2 + " "; - - for ( int i = 0; i < curse.size() && !found_curse; i++ ) - { - if ( strstr ( text2.c_str(), curse[i].c_str() ) ) - found_curse = true; - } - if ( found_curse ) - { - static List& cursecop = GetList("cursecop"); - return PrivMsg ( channel, ssprintf("%s: %s", from.c_str(), ListRand(cursecop)) ); - } - - string botname (BOTNAME); - strlwr ( &botname[0] ); - //botname = " " + botname + " "; - - if ( strstr(text2.c_str(), botname.c_str()) || strstr(text2.c_str(), " arch ") || found_name ) - { - string out = ssprintf("%s: %s", from.c_str(), TaggedReply("tech").c_str()); - flog.printf ( "TECH-REPLY: %s\n", out.c_str() ); - if ( !strnicmp ( out.c_str(), "/me ", 4 ) ) - return Action ( channel, &out[4] ); - else - return PrivMsg ( channel, out ); - } - return true; - - } // On Chanel Message - - bool OnChannelMode ( const string& channel, const string& mode ) - { - //printf ( "OnChannelMode(%s,%s)\n", channel.c_str(), mode.c_str() ); - return true; - } - bool OnUserModeInChannel ( const string& src, const string& channel, const string& mode, const string& target ) - { - printf ( "OnUserModeInChannel(%s,%s,%s,%s)\n", src.c_str(), channel.c_str(), mode.c_str(), target.c_str() ); - const char* p = mode.c_str(); - if ( !p ) - return true; - while ( *p ) - { - switch ( *p++ ) - { - case '+': - while ( *p != 0 && *p != ' ' ) - { - if ( *p == 'o' ) - { - printf ( "adding '%s' to ops list\n", target.c_str() ); - ops.push_back ( target ); - } - break; - } - break; - case '-': - while ( *p != 0 && *p != ' ' ) - { - if ( *p == 'o' ) - { - std::vector::iterator it = ops.begin(); - for ( ; it != ops.end(); it++ ) - { - if ( *it == target ) - { - printf ( "remove '%s' to ops list\n", target.c_str() ); - ops.erase ( it ); - } - } - break; - } - } - } - } - return true; - } - bool OnMode ( const string& user, const string& mode ) - { - //printf ( "OnMode(%s,%s)\n", user.c_str(), mode.c_str() ); - return true; - } - bool OnChannelUsers ( const string& channel, const vector& users ) - { - //printf ( "[%s has %i users]: ", channel.c_str(), users.size() ); - for ( int i = 0; i < users.size(); i++ ) - { - if ( users[i][0] == '@' ) - ops.push_back ( &users[i][1] ); - /*if ( i ) - printf ( ", " ); - printf ( "%s", users[i].c_str() );*/ - } - //printf ( "\n" ); - return true; - } - bool OnKick ( void ) - { - Join(CHANNEL); - return true; - } - bool OnBanned ( const std::string& channel ) - { - Sleep(10000); - return Join(CHANNEL); - } -}; - -int main ( int argc, char** argv ) -{ - srand ( time(NULL) ); - - ImportList ( "dev", true ); - ImportList ( "func", true ); - ImportList ( "dev", true ); - ImportList ( "func", true ); - ImportList ( "irql", true ); - ImportList ( "module", true ); - ImportList ( "period", true ); - ImportList ( "status", true ); - ImportList ( "stru", true ); - ImportList ( "type", true ); - - ImportList ( "tech", false ); - ImportList ( "curse", false ); - ImportList ( "cursecop", false ); - ImportList ( "grovel", false ); - ImportList ( "nogrovel", false ); - ImportList ( "idle", false ); - -#ifdef _DEBUG - printf ( "initializing IRCClient debugging\n" ); - IRCClient::SetDebug ( true ); -#endif//_DEBUG - - while (true) - { - printf ( "calling suStartup()\n" ); - suStartup(); - printf ( "creating IRCClient object\n" ); - MyIRCClient irc; - printf ( "connecting to freenode\n" ); - - if ( !irc.Connect ( SERVER ) ) // irc.freenode.net - { - printf ( "couldn't connect to server\n" ); - Sleep(10000); - continue; - } - printf ( "sending user command\n" ); - if ( !irc.User ( BOTNAME, "reactos.com", SERVER, "ArchBlackmann" ) ) - { - printf ( "USER command failed, retying ...\n" ); - Sleep(10000); - continue; - } - printf ( "sending nick\n" ); - if ( !irc.Nick ( BOTNAME ) ) - { - printf ( "NICK command failed, retying ...\n" ); - Sleep(10000); - continue; - } - printf ( "setting mode\n" ); - if ( !irc.Mode ( MODE ) ) - { - printf ( "MODE command failed, retying ...\n" ); - Sleep(10000); - continue; - } - printf ( "joining channel\n" ); - if ( !irc.Join ( CHANNEL ) ) - { - printf ( "JOIN command failed, retying ...\n" ); - Sleep(10000); - continue; - } - - printf ( "entering irc client processor\n" ); - irc.Run ( false ); // do the processing in this thread... - } - - return 0; -} diff --git a/irc/ArchBlackmann/ArchBlackmann.dsp b/irc/ArchBlackmann/ArchBlackmann.dsp deleted file mode 100644 index 03768e37c32..00000000000 --- a/irc/ArchBlackmann/ArchBlackmann.dsp +++ /dev/null @@ -1,216 +0,0 @@ -# Microsoft Developer Studio Project File - Name="ArchBlackmann" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Console Application" 0x0103 - -CFG=ArchBlackmann - 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 "ArchBlackmann.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 "ArchBlackmann.mak" CFG="ArchBlackmann - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "ArchBlackmann - Win32 Release" (based on "Win32 (x86) Console Application") -!MESSAGE "ArchBlackmann - 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)" == "ArchBlackmann - 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 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /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)" == "ArchBlackmann - 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 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 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /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:console /debug /machine:I386 /pdbtype:sept - -!ENDIF - -# Begin Target - -# Name "ArchBlackmann - Win32 Release" -# Name "ArchBlackmann - Win32 Debug" -# Begin Source File - -SOURCE=.\ArchBlackmann.cpp -# End Source File -# Begin Source File - -SOURCE=.\auto_ptr.h -# End Source File -# Begin Source File - -SOURCE=.\auto_vector.h -# End Source File -# Begin Source File - -SOURCE=.\base64.cpp -# End Source File -# Begin Source File - -SOURCE=.\base64.h -# End Source File -# Begin Source File - -SOURCE=.\chomp.cpp -# End Source File -# Begin Source File - -SOURCE=.\chomp.h -# End Source File -# Begin Source File - -SOURCE=.\config.h -# End Source File -# Begin Source File - -SOURCE=.\cram_md5.cpp -# End Source File -# Begin Source File - -SOURCE=.\cram_md5.h -# End Source File -# Begin Source File - -SOURCE=.\File.cpp -# End Source File -# Begin Source File - -SOURCE=.\File.h -# End Source File -# Begin Source File - -SOURCE=.\IRCClient.cpp -# End Source File -# Begin Source File - -SOURCE=.\IRCClient.h -# End Source File -# Begin Source File - -SOURCE=.\MD5.cpp -# End Source File -# Begin Source File - -SOURCE=.\MD5.h -# End Source File -# Begin Source File - -SOURCE=.\panic.cpp -# End Source File -# Begin Source File - -SOURCE=.\panic.h -# End Source File -# Begin Source File - -SOURCE=.\QueueT.h -# End Source File -# Begin Source File - -SOURCE=.\Reli.h -# End Source File -# Begin Source File - -SOURCE=.\ReliMT.cpp -# End Source File -# Begin Source File - -SOURCE=.\ReliMT.h -# End Source File -# Begin Source File - -SOURCE=.\SockUtils.cpp -# End Source File -# Begin Source File - -SOURCE=.\SockUtils.h -# End Source File -# Begin Source File - -SOURCE=.\SplitJoin.cpp -# End Source File -# Begin Source File - -SOURCE=.\SplitJoin.h -# End Source File -# Begin Source File - -SOURCE=.\ssprintf.cpp -# End Source File -# Begin Source File - -SOURCE=.\ssprintf.h -# End Source File -# Begin Source File - -SOURCE=.\ThreadPool.cpp -# End Source File -# Begin Source File - -SOURCE=.\ThreadPool.h -# End Source File -# Begin Source File - -SOURCE=.\trim.cpp -# End Source File -# Begin Source File - -SOURCE=.\trim.h -# End Source File -# Begin Source File - -SOURCE=.\verify.h -# End Source File -# End Target -# End Project diff --git a/irc/ArchBlackmann/ArchBlackmann.dsw b/irc/ArchBlackmann/ArchBlackmann.dsw deleted file mode 100644 index d8c4784be0e..00000000000 --- a/irc/ArchBlackmann/ArchBlackmann.dsw +++ /dev/null @@ -1,29 +0,0 @@ -Microsoft Developer Studio Workspace File, Format Version 6.00 -# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! - -############################################################################### - -Project: "ArchBlackmann"=.\ArchBlackmann.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Global: - -Package=<5> -{{{ -}}} - -Package=<3> -{{{ -}}} - -############################################################################### - diff --git a/irc/ArchBlackmann/File.cpp b/irc/ArchBlackmann/File.cpp deleted file mode 100644 index a9fc94ed158..00000000000 --- a/irc/ArchBlackmann/File.cpp +++ /dev/null @@ -1,265 +0,0 @@ -// File.cpp -// (C) 2002-2004 Royce Mitchell III -// Dually licensed under BSD & LGPL - -#ifdef _MSC_VER -#pragma warning ( disable : 4786 ) -#endif//_MSC_VER - -#include -#include -#include "File.h" - -#ifndef nelem -#define nelem(x) ( sizeof(x) / sizeof(x[0]) ) -#endif//nelem - -typedef File::filesize_t filesize_t; -typedef File::fileoff_t fileoff_t; - - -fileoff_t File::seek ( fileoff_t offset ) -{ -#ifdef WIN32 - if ( _f->_flag & _IOWRT ) // is there pending output? - fflush ( _f ); - - // reset "buffered input" variables - _f->_cnt = 0; - _f->_ptr = _f->_base; - - // make sure we're going forward - if ( _f->_flag & _IORW ) - _f->_flag &= ~(_IOREAD|_IOWRT); - - return _lseeki64 ( _fileno(_f), offset, SEEK_SET ); -#else//UNIX - return lseek64 ( fileno(_f), offset, SEEK_SET ); -#endif -} - -std::string File::getline ( bool strip_crlf /*= false*/ ) -{ - std::string s = ""; - char buf[256]; - for ( ;; ) - { - *buf = 0; - fgets ( buf, nelem(buf)-1, _f ); - if ( !*buf ) - break; - s += buf; - if ( strchr ( "\r\n", buf[strlen(buf)-1] ) ) - break; - } - if ( strip_crlf && s.size() ) - { - char* p = strpbrk ( &s[0], "\r\n" ); - if ( p ) - { - *p = '\0'; - s.resize ( p-&s[0] ); - } - } - return s; -} - -std::wstring File::wgetline ( bool strip_crlf /*= false*/ ) -{ - std::wstring s = L""; - wchar_t buf[256]; - for ( ;; ) - { - *buf = 0; - fgetws ( buf, nelem(buf)-1, _f ); - if ( !*buf ) - break; - s += buf; - if ( wcschr ( L"\r\n", buf[wcslen(buf)-1] ) ) - break; - } - if ( strip_crlf && s.size() ) - { - wchar_t* p = wcspbrk ( &s[0], L"\r\n" ); - if ( p ) - { - *p = L'\0'; - s.resize ( (p-&s[0])/sizeof(wchar_t) ); - } - } - return s; -} - -// this function searches for the next end-of-line and puts all data it -// finds until then in the 'line' parameter. -// -// call continuously until the function returns false ( no more data ) -bool File::next_line ( std::string& line, bool strip_crlf ) -{ - line = getline(strip_crlf); - // indicate that we're done *if*: - // 1) there's no more data, *and* - // 2) we're at the end of the file - return line.size()>0 || !eof(); -} - -bool File::next_line ( std::wstring& line, bool strip_crlf ) -{ - line = wgetline ( strip_crlf ); - return line.size()>0 || !eof(); -} - -/* -example usage: - -bool mycallback ( const std::string& line, int line_number, long lparam ) -{ - std::cout << line << std::endl; - return true; // continue enumeration -} - -File f ( "file.txt", "rb" ); // open file for binary read-only ( i.e. "rb" ) -f.enum_lines ( mycallback, 0, true ); -*/ - -/*bool File::enum_lines ( bool (*callback)(const std::string& line, int line_number, long lparam), long lparam, bool strip_crlf ) -{ - int line_number = 0; - for ( ;; ) - { - std::string s = getline(strip_crlf); - line_number++; - if ( !s.size() ) - { - if ( eof() ) - return true; - else - continue; - } - if ( !(*callback) ( s, line_number, lparam ) ) - return false; - } -}*/ - -filesize_t File::length() const -{ -#ifdef WIN32 - return _filelengthi64 ( _fileno(_f) ); -#elif defined(UNIX) - struct stat64 file_stat; - verify(fstat64(fileno(_f), &file_stat) == 0); - return file_stat.st_size; -#endif -} - -void File::close() -{ - if ( _f ) - { - fclose(_f); - _f = 0; - } -} - -void File::printf ( const char* fmt, ... ) -{ - va_list arg; - int done; - - va_start(arg, fmt); - assert(_f); - done = vfprintf ( _f, fmt, arg ); - va_end(arg); -} - -/*static*/ bool File::LoadIntoString ( std::string& s, const std::string& filename ) -{ - File in ( filename, "rb" ); - if ( !in.isopened() ) - return false; - filesize_t flen = in.length(); - size_t len = size_t(flen); - if ( len != flen ) - return false; // file too big... - s.resize ( len + 1 ); - if ( !in.read ( &s[0], len ) ) - return false; - s[len] = '\0'; - s.resize ( len ); - return true; -} - -/*static*/ bool File::LoadIntoString ( std::string& s, const std::wstring& filename ) -{ - File in ( filename, L"rb" ); - if ( !in.isopened() ) - return false; - filesize_t flen = in.length(); - size_t len = size_t(flen); - if ( len != flen ) - return false; // file too big... - s.resize ( len + 1 ); - if ( !in.read ( &s[0], len ) ) - return false; - s[len] = '\0'; - s.resize ( len ); - return true; -} - -/*static*/ bool File::SaveFromString ( const std::string& filename, const std::string& s, bool binary ) -{ - File out ( filename, binary ? "wb" : "w" ); - if ( !out.isopened() ) - return false; - out.write ( s.c_str(), s.size() ); - return true; -} - -/*static*/ bool File::SaveFromString ( const std::wstring& filename, const std::string& s, bool binary ) -{ - File out ( filename, binary ? L"wb" : L"w" ); - if ( !out.isopened() ) - return false; - out.write ( s.c_str(), s.size() ); - return true; -} - -/*static*/ bool File::SaveFromBuffer ( const std::string& filename, const char* buf, size_t buflen, bool binary ) -{ - File out ( filename, binary ? "wb" : "w" ); - if ( !out.isopened() ) - return false; - out.write ( buf, buflen ); - return true; -} - -/*static*/ bool File::SaveFromBuffer ( const std::wstring& filename, const char* buf, size_t buflen, bool binary ) -{ - File out ( filename, binary ? L"wb" : L"w" ); - if ( !out.isopened() ) - return false; - out.write ( buf, buflen ); - return true; -} - -/*static*/ std::string File::TempFileName ( const std::string& prefix ) -{ -#ifdef WIN32 - std::string s ( _tempnam ( ".", prefix.c_str() ) ); - return s; -#else - // FIXME - return string(""); -#endif -} - -/*static*/ std::wstring File::TempFileName ( const std::wstring& prefix ) -{ -#ifdef WIN32 - std::wstring s ( _wtempnam ( L".", prefix.c_str() ) ); - return s; -#else - // FIXME - return std::wstring(L""); -#endif -} diff --git a/irc/ArchBlackmann/File.h b/irc/ArchBlackmann/File.h deleted file mode 100644 index a5baea62515..00000000000 --- a/irc/ArchBlackmann/File.h +++ /dev/null @@ -1,173 +0,0 @@ -// File.h -// (C) 2002-2004 Royce Mitchell III -// Dually licensed under BSD & LGPL - -#ifndef FILE_H -#define FILE_H - -#ifdef WIN32 -# include // fgetc -# include -#elif defined(UNIX) -# include -# include -#endif -#include -#include - -class File -{ -public: -#ifdef WIN32 - typedef __int64 fileoff_t; - typedef unsigned __int64 filesize_t; -#else//_MSC_VER - typedef __off64_t fileoff_t; - typedef __size64_t filesize_t; -#endif//_MSC_VER - - File() : _f(0) - { - } - - File ( const std::string& filename, const char* mode ) : _f(0) - { - open ( filename, mode ); - } - - File ( const std::wstring& filename, const wchar_t* mode ) : _f(0) - { - open ( filename, mode ); - } - - File ( const char* filename, const char* mode ) : _f(0) - { - open ( filename, mode ); - } - - File ( const wchar_t* filename, const wchar_t* mode ) : _f(0) - { - open ( filename, mode ); - } - - ~File() - { - close(); - } - - bool open ( const std::string& filename, const char* mode ) - { - assert ( !_f ); - return ( _f = fopen ( filename.c_str(), mode ) ) != 0; - } - - bool open ( const std::wstring& filename, const wchar_t* mode ) - { - assert ( !_f ); - return ( _f = _wfopen ( filename.c_str(), mode ) ) != 0; - } - - bool open ( const char* filename, const char* mode ) - { - assert ( !_f ); - return ( _f = fopen ( filename, mode ) ) != 0; - } - - bool open ( const wchar_t* filename, const wchar_t* mode ) - { - assert ( !_f ); - return ( _f = _wfopen ( filename, mode ) ) != 0; - } - - fileoff_t seek ( fileoff_t offset ); - - int get() - { - return fgetc ( _f ); - } - - bool put ( int c ) - { - return fputc ( c, _f ) != EOF; - } - - std::string getline ( bool strip_crlf = false ); - std::wstring wgetline ( bool strip_crlf = false ); - - // this function searches for the next end-of-line and puts all data it - // finds until then in the 'line' parameter. - // - // call continuously until the function returns false ( no more data ) - bool next_line ( std::string& line, bool strip_crlf ); - bool next_line ( std::wstring& line, bool strip_crlf ); - - bool read ( void* data, unsigned len ) - { - return len == fread ( data, 1, len, _f ); - } - - bool write ( const void* data, unsigned len ) - { - return len == fwrite ( data, 1, len, _f ); - } - - bool write ( const std::string& data ) - { - return data.length() == fwrite ( data.c_str(), 1, data.length(), _f ); - } - - bool write ( const std::wstring& data ) - { - return data.length() == fwrite ( data.c_str(), sizeof(data[0]), data.length(), _f ); - } - - filesize_t length() const; - - void close(); - - bool isopened() const - { - return _f != 0; - } - - bool is_open() const - { - return _f != 0; - } - - bool eof() const - { - return feof(_f) ? true : false; - } - - FILE* operator * () - { - return _f; - } - - operator FILE*() - { - return _f; - } - - void printf ( const char* fmt, ... ); - void printf ( const wchar_t* fmt, ... ); - - static bool LoadIntoString ( std::string& s, const std::string& filename ); - static bool LoadIntoString ( std::string& s, const std::wstring& filename ); - static bool SaveFromString ( const std::string& filename, const std::string& s, bool binary ); - static bool SaveFromString ( const std::wstring& filename, const std::string& s, bool binary ); - static bool SaveFromBuffer ( const std::string& filename, const char* buf, size_t buflen, bool binary ); - static bool SaveFromBuffer ( const std::wstring& filename, const char* buf, size_t buflen, bool binary ); - - static std::string TempFileName ( const std::string& prefix ); - static std::wstring TempFileName ( const std::wstring& prefix ); - -private: - File(const File&) {} - const File& operator = ( const File& ) { return *this; } - - FILE * _f; -}; - -#endif//FILE_H diff --git a/irc/ArchBlackmann/IRCClient.cpp b/irc/ArchBlackmann/IRCClient.cpp deleted file mode 100644 index 5910358365a..00000000000 --- a/irc/ArchBlackmann/IRCClient.cpp +++ /dev/null @@ -1,418 +0,0 @@ -// IRCClient.cpp -// This file is (C) 2004 Royce Mitchell III -// and released under the BSD & LGPL licenses - -#ifdef _MSC_VER -#pragma warning ( disable : 4786 ) -#endif//_MSC_VER - -#include -#include - -#include "IRCClient.h" -#include "MD5.h" -#include "cram_md5.h" -#include "trim.h" -#include "chomp.h" -#include "SplitJoin.h" -#include "base64.h" -#include "config.h" - -using std::string; -using std::stringstream; -using std::vector; - -bool IRCClient::_debug = true; - -// see rfc1459 for IRC-Protocoll Reference - -IRCClient::IRCClient() - : _timeout(10*60*1000), _inRun(false) -{ -} - -bool IRCClient::Connect ( const string& server, short port ) -{ - string buf; - Close(); - Attach ( suTcpSocket() ); - if ( !suConnect ( *this, server.c_str(), port ) ) - return false; - return true; -} - -bool -IRCClient::User ( const string& user, const string& mode, - const string& network, const string& realname ) -{ - string buf; - buf = "USER " + user + " \"" + mode + "\" \"" + network + "\" :" + realname + "\n"; - return Send ( buf ); -} - -bool -IRCClient::Nick ( const string& nick ) -{ - _nick = nick; - Send ( "NICK " + _nick + "\n" ); - PrivMsg ("NickServ", "IDENTIFY " + (string)PASS); - return true; -} - -bool -IRCClient::Mode ( const string& mode ) -{ - return Send ( "MODE " + _nick + " " + mode + "\n" ); -} - -bool -IRCClient::Names ( const string& channel ) -{ - return Send ( "NAMES " + channel + "\n" ); -} - -bool -IRCClient::Mode ( const string& channel, const string& mode, const string& target ) -{ - return Send ( "MODE " + channel + " " + mode + " " + target + "\n" ); -} - -bool -IRCClient::Join ( const string& channel ) -{ - return Send("JOIN " + channel + "\n"); -} - -bool -IRCClient::PrivMsg ( const string& to, const string& text ) -{ - return Send ( "PRIVMSG " + to + " :" + text + '\n' ); -} - -bool -IRCClient::Action ( const string& to, const string& text ) -{ - return Send ( "PRIVMSG " + to + " :" + (char)1 + "ACTION " + text + (char)1 + '\n' ); -} - -bool -IRCClient::Part ( const string& channel, const string& text ) -{ - return Send ( "PART " + channel + " :" + text + "\n" ); -} - -bool -IRCClient::Quit ( const string& text ) -{ - return Send( "QUIT :" + text + "\n"); -} - -bool IRCClient::_Recv ( string& buf ) -{ - bool b = (recvUntil ( buf, '\n', _timeout ) > 0); - if ( b && _debug ) - { - printf ( ">> %s", buf.c_str() ); - if ( buf[buf.length()-1] != '\n' ) - printf ( "\n" ); - } - return b; -} - -bool IRCClient::Send ( const string& buf ) -{ - if ( _debug ) - { - printf ( "<< %s", buf.c_str() ); - if ( buf[buf.length()-1] != '\n' ) - printf ( "\n" ); - } - return ( buf.length() == (size_t)send ( *this, buf.c_str(), buf.length(), 0 ) ); -} - -bool IRCClient::OnPing( const string& text ) -{ - return Send( "PONG " + text + "\n" ); -} - - -int THREADAPI IRCClient::Callback ( IRCClient* irc ) -{ - return irc->Run ( false ); -} - -int IRCClient::Run ( bool launch_thread ) -{ - if ( (SOCKET)*this == INVALID_SOCKET ) - return 0; - if ( _inRun ) return 1; - if ( launch_thread ) - { - ThreadPool::Instance().Launch ( (ThreadPoolFunc*)IRCClient::Callback, this ); - return 1; - } - _inRun = true; - if ( _debug ) printf ( "IRCClient::Run() - waiting for responses\n" ); - string buf; - while ( _Recv(buf) ) - { - if ( !strnicmp ( buf.c_str(), "NOTICE ", 7 ) ) - { - //printf ( "recv'd NOTICE msg...\n" ); - // TODO... - //OnAuth ( - } - else if ( !strnicmp ( buf.c_str(), "PING ", 5 ) ) - { - const char* p = &buf[5]; // point to first char after "PING " - while ( *p == ':' ) // then read past the colons - p++; - const char* p2 = strpbrk ( p, "\r\n" ); // find the end of line - string text ( p, p2-p ); // and set the text - OnPing( text ); - } - else if ( buf[0] == ':' ) - { - const char* p = &buf[1]; // skip first colon... - const char* p2 = strpbrk ( p, " !" ); - if ( !p2 ) - { - printf ( "!!!:OnRecv failure 0: ", buf.c_str() ); - continue; - } - string src ( p, p2-p ); - if ( !src.length() ) - { - printf ( "!!!:OnRecv failure 0.5: %s", buf.c_str() ); - continue; - } - p = p2 + 1; - if ( *p2 == '!' ) - { - p2 = strchr ( p, ' ' ); - if ( !p2 ) - { - printf ( "!!!:OnRecv failure 1: %s", buf.c_str() ); - continue; - } - //string srchost ( p, p2-p ); - p = p2 + 1; - } - p2 = strchr ( p, ' ' ); - if ( !p2 ) - { - printf ( "!!!:OnRecv failure 2: %s", buf.c_str() ); - continue; - } - string cmd ( p, p2-p ); - p = p2 + 1; - p2 = strpbrk ( p, " :" ); - if ( !p2 ) - { - printf ( "!!!:OnRecv failure 3: %s", buf.c_str() ); - continue; - } - string tgt ( p, p2-p ); - p = p2 + 1; - p += strspn ( p, " " ); - if ( *p == '=' ) - { - p++; - p += strspn ( p, " " ); - } - if ( *p == ':' ) - p++; - p2 = strpbrk ( p, "\r\n" ); - if ( !p2 ) - { - printf ( "!!!:OnRecv failure 4: %s", buf.c_str() ); - continue; - } - string text ( p, p2-p ); - strlwr ( &cmd[0] ); - if ( cmd == "privmsg" ) - { - if ( !tgt.length() ) - { - printf ( "!!!:OnRecv failure 5 (PRIVMSG w/o target): %s", buf.c_str() ); - continue; - } - if ( *p == 1 ) - { - p++; - p2 = strchr ( p, ' ' ); - if ( !p2 ) p2 = p + strlen(p); - cmd = string ( p, p2-p ); - strlwr ( &cmd[0] ); - p = p2 + 1; - p2 = strchr ( p, 1 ); - if ( !p2 ) - { - printf ( "!!!:OnRecv failure 6 (no terminating \x01 for initial \x01 found: %s", buf.c_str() ); - continue; - } - text = string ( p, p2-p ); - if ( cmd == "action" ) - { - if ( tgt[0] == '#' ) - OnChannelAction ( tgt, src, text ); - else - OnPrivAction ( src, text ); - } - else - { - printf ( "!!!:OnRecv failure 7 (unrecognized \x01 command '%s': %s", cmd.c_str(), buf.c_str() ); - continue; - } - } - else - { - if ( tgt[0] == '#' ) - OnChannelMsg ( tgt, src, text ); - else - OnPrivMsg ( src, text ); - } - } - else if ( cmd == "mode" ) - { - // two diff. kinds of mode notifications... - //printf ( "[MODE] src='%s' cmd='%s' tgt='%s' text='%s'", src.c_str(), cmd.c_str(), tgt.c_str(), text.c_str() ); - //OnMode ( - // self mode change: - // [MODE] src=Nick cmd=mode tgt=Nick text=+i - // channel mode change: - // [MODE] src=Nick cmd=mode tgt=#Channel text=+o Nick - if ( tgt[0] == '#' ) - { - p = text.c_str(); - p2 = strchr ( p, ' ' ); - if ( p2 && *p2 ) - { - string mode ( p, p2-p ); - p = p2 + 1; - p += strspn ( p, " " ); - OnUserModeInChannel ( src, tgt, mode, trim(p) ); - } - else - OnChannelMode ( tgt, text ); - } - else - OnMode ( tgt, text ); - } - else if ( cmd == "join" ) - { - mychannel = text; - OnJoin ( src, text ); - } - else if ( cmd == "part" ) - { - OnPart ( src, text ); - } - else if ( cmd == "nick" ) - { - OnNick ( src, text ); - } - else if ( cmd == "kick" ) - { - OnKick (); - } - else if ( isdigit(cmd[0]) ) - { - int i = atoi(cmd.c_str()); - switch ( i ) - { - - case 1: // "Welcome!" - i.e. it's okay to issue commands now... - OnConnected(); - break; - - case 353: // user list for channel.... - { - p = text.c_str(); - p2 = strpbrk ( p, " :" ); - if ( !p2 ) continue; - string channel ( p, p2-p ); - p = strchr ( p2, ':' ); - if ( !p ) continue; - p++; - vector users; - while ( *p ) - { - p2 = strchr ( p, ' ' ); - if ( !p2 ) - p2 = p + strlen(p); - users.push_back ( string ( p, p2-p ) ); - p = p2+1; - p += strspn ( p, " " ); - } - OnChannelUsers ( channel, users ); - } - break; - - case 366: // END of user list for channel - { - p = text.c_str(); - p2 = strpbrk ( p, " :" ); - if ( !p2 ) continue; - string channel ( p, p2-p ); - OnEndChannelUsers ( channel ); - } - break; - - case 474: // You are banned - { - p = text.c_str(); - p2 = strpbrk ( p, " :" ); - if ( !p2 ) continue; - string channel ( p, p2-p ); - OnBanned ( channel ); - } - break; - - case 433: // Nick in Use - { - string nick = _nick; - Nick (nick + "_"); - - PrivMsg ("NickServ", "GHOST " + nick + " " + PASS); - - // HACK HACK HACK - Mode ( "+i" ); - Join ( CHANNEL ); // this is because IRC client does not review if his commands were sucessfull - - Sleep ( 1000 ); - Nick ( nick ); - } - break; - - case 2: //MOTD - case 376: //MOTD - case 372: - break; - - default: - if ( _debug ) printf ( "unknown command %i: %s", i, buf.c_str() ); - break; - } - } - else - { - if ( strstr ( buf.c_str(), "ACTION" ) ) - { - printf ( "ACTION: " ); - for ( int i = 0; i < buf.size(); i++ ) - printf ( "%c(%xh)", buf[i], (unsigned)(unsigned char)buf[i] ); - } - else if ( _debug ) printf ( "unrecognized ':' response: %s", buf.c_str() ); - } - } - else - { - if ( _debug ) printf ( "unrecognized irc msg: %s", buf.c_str() ); - } - //OnRecv ( buf ); - } - if ( _debug ) printf ( "IRCClient::Run() - exiting\n" ); - _inRun = false; - return 0; -} diff --git a/irc/ArchBlackmann/IRCClient.h b/irc/ArchBlackmann/IRCClient.h deleted file mode 100644 index 57fa2105e50..00000000000 --- a/irc/ArchBlackmann/IRCClient.h +++ /dev/null @@ -1,148 +0,0 @@ -// IRCClient.h -// This file is (C) 2004 Royce Mitchell III -// and released under the BSD & LGPL licenses - -#ifndef IRCCLIENT_H -#define IRCCLIENT_H - -#include -#include -#include "SockUtils.h" -#include "ThreadPool.h" - -class IRCClient : public suBufferedRecvSocket -{ - -public: - IRCClient(); - - std::string mychannel; - static bool GetDebug() { return _debug; } - static bool SetDebug ( bool debug ) { bool old = _debug; _debug = debug; return old; } - - // connect to server ( record greeting for apop if it exists ) - bool Connect ( const std::string& server, short port = 6667 ); - - bool Running() { return _inRun; } - - ////////////////////////// IRC Client Protocol commands /////////////////////// - - // first thing you must call... mode can be "" - // network can be same as name of server used in Connect() above - bool User ( const std::string& user, const std::string& mode, - const std::string& network, const std::string& realname ); - - // change nick... - bool Nick ( const std::string& nick ); - - // change mode for self... - bool Mode ( const std::string& mode ); - - // set someone's mode in channel ( like oping someone ) - bool Mode ( const std::string& channel, const std::string& mode, const std::string& target ); - - // request a list of names of clients in a channel - bool Names ( const std::string& channel ); - - // join a channel... - bool Join ( const std::string& channel ); - - // send message to someone or some channel - bool PrivMsg ( const std::string& to, const std::string& text ); - - // send /me to someone or some channel - bool Action ( const std::string& to, const std::string& text ); - - // leave a channel - bool Part ( const std::string& channel, const std::string& text ); - - // log off - bool Quit ( const std::string& text ); - - ////////////////////// callback functions //////////////////////////// - - // OnConnected: you just successfully logged into irc server - virtual bool OnConnected() = 0; - - virtual bool OnNick ( const std::string& oldNick, const std::string& newNick ) { return true; } - - // OnJoin: someone just successfully joined a channel you are in ( also sent when you successfully join a channel ) - virtual bool OnJoin ( const std::string& user, const std::string& channel ) { return true; } - - // OnPart: someone just left a channel you are in - virtual bool OnPart ( const std::string& user, const std::string& channel ) { return true; } - - // OnPrivMsg: you just received a private message from a user - virtual bool OnPrivMsg ( const std::string& from, const std::string& text ) { return true; } - - virtual bool OnPrivAction ( const std::string& from, const std::string& text ) { return true; } - - // OnChannelMsg: you just received a chat line in a channel - virtual bool OnChannelMsg ( const std::string& channel, const std::string& from, - const std::string& text ) { return true; } - - // OnChannelAction: you just received a "/me" line in a channel - virtual bool OnChannelAction ( const std::string& channel, const std::string& from, - const std::string& text ) { return true; } - - // OnChannelMode: notification of a change of a channel's mode - virtual bool OnChannelMode ( const std::string& channel, const std::string& mode ) - { return true; } - - // OnUserModeInChannel: notification of a mode change of a user with respect to a channel. - // f.ex.: this will be called when someone is oped in a channel. - virtual bool OnUserModeInChannel ( const std::string& src, const std::string& channel, - const std::string& mode, const std::string& target ) { return true; } - - // OnMode: you will receive this when you change your own mode, at least... - virtual bool OnMode ( const std::string& user, const std::string& mode ) { return true; } - - // notification of what users are in a channel ( you may get multiple of these... ) - virtual bool OnChannelUsers ( const std::string& channel, const std::vector& users ) - { return true; } - - // OnKick: if the client has been kicked - virtual bool OnKick ( void ) { return true; } - - // OnKick: if the client has been kicked - virtual bool OnBanned ( const std::string& channel ) { return true; } - - // notification that you have received the entire list of users for a channel - virtual bool OnEndChannelUsers ( const std::string& channel ) { return true; } - - // OnPing - default implementation replies to PING with a valid PONG. required on some systems to - // log in. Most systems require a response in order to stay connected, used to verify a client hasn't - // dropped. - virtual bool OnPing ( const std::string& text ); - - ////////////////////// other functions //////////////////////////// - - // this is for sending data to irc server. it's public in case you need to send some - // command not supported by this base class... - bool Send ( const std::string& buf ); - - // if launch_thread is true, this function will spawn a thread that will process - // incoming packets until the socket dies. - // otherwise ( launch_thread is false ) this function will do that processing - // in *this* thread, and not return until the socket dies. - int Run ( bool launch_thread ); - - ////////////////////// private stuff //////////////////////////// -private: - bool _Recv ( std::string& buf ); - - static int THREADAPI Callback ( IRCClient* irc ); - - static bool _debug; - std::string _nick; - int _timeout; - std::string _apop_challenge; - - volatile bool _inRun; - - // disable copy semantics - IRCClient ( const IRCClient& ); - IRCClient& operator = ( const IRCClient& ); -}; - -#endif//IRCCLIENT_H diff --git a/irc/ArchBlackmann/MD5.cpp b/irc/ArchBlackmann/MD5.cpp deleted file mode 100644 index 43200cfa1a1..00000000000 --- a/irc/ArchBlackmann/MD5.cpp +++ /dev/null @@ -1,418 +0,0 @@ -// MD5.CPP - RSA Data Security, Inc., MD5 message-digest algorithm - -/* -Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All -rights reserved. - -License to copy and use this software is granted provided that it -is identified as the "RSA Data Security, Inc. MD5 Message-Digest -Algorithm" in all material mentioning or referencing this software -or this function. - -License is also granted to make and use derivative works provided -that such works are identified as "derived from the RSA Data -Security, Inc. MD5 Message-Digest Algorithm" in all material -mentioning or referencing the derived work. - -RSA Data Security, Inc. makes no representations concerning either -the merchantability of this software or the suitability of this -software for any particular purpose. It is provided "as is" -without express or implied warranty of any kind. - -These notices must be retained in any copies of any part of this -documentation and/or software. -*/ - -//#include -#include -#include -#include -#include "MD5.h" - -using std::string; -using std::vector; - -// Constants for MD5Transform routine. -#define S11 7 -#define S12 12 -#define S13 17 -#define S14 22 -#define S21 5 -#define S22 9 -#define S23 14 -#define S24 20 -#define S31 4 -#define S32 11 -#define S33 16 -#define S34 23 -#define S41 6 -#define S42 10 -#define S43 15 -#define S44 21 - -static void MD5Transform ( UINT4 [4], const uchar [64] ); -static void Encode ( unsigned char *, UINT4 *, unsigned int ); -static void Decode ( UINT4 *, const uchar *, unsigned int ); - -static unsigned char PADDING[64] = -{ - 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 -}; - -// F, G, H and I are basic MD5 functions. -#define F(x, y, z) (((x) & (y)) | ((~x) & (z))) -#define G(x, y, z) (((x) & (z)) | ((y) & (~z))) -#define H(x, y, z) ((x) ^ (y) ^ (z)) -#define I(x, y, z) ((y) ^ ((x) | (~z))) - -// ROTATE_LEFT rotates x left n bits. -#define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32-(n)))) - -// FF, GG, HH, and II transformations for rounds 1, 2, 3, and 4. -// Rotation is separate from addition to prevent recomputation. -#define FF(a, b, c, d, x, s, ac) { \ - (a) += F ((b), (c), (d)) + (x) + (UINT4)(ac); \ - (a) = ROTATE_LEFT ((a), (s)); \ - (a) += (b); \ - } -#define GG(a, b, c, d, x, s, ac) { \ - (a) += G ((b), (c), (d)) + (x) + (UINT4)(ac); \ - (a) = ROTATE_LEFT ((a), (s)); \ - (a) += (b); \ - } -#define HH(a, b, c, d, x, s, ac) { \ - (a) += H ((b), (c), (d)) + (x) + (UINT4)(ac); \ - (a) = ROTATE_LEFT ((a), (s)); \ - (a) += (b); \ - } -#define II(a, b, c, d, x, s, ac) { \ - (a) += I ((b), (c), (d)) + (x) + (UINT4)(ac); \ - (a) = ROTATE_LEFT ((a), (s)); \ - (a) += (b); \ - } - -// MD5 initialization. Begins an MD5 operation, writing a new context. -void MD5Init ( - MD5_CTX *context ) // context -{ - context->count[0] = context->count[1] = 0; - // Load magic initialization constants. - context->state[0] = 0x67452301; - context->state[1] = 0xefcdab89; - context->state[2] = 0x98badcfe; - context->state[3] = 0x10325476; -} - -// MD5 block update operation. Continues an MD5 message-digest -// operation, processing another message block, and updating the -// context. -void MD5Update ( - MD5_CTX *context, // context - const char *input_, // input block - unsigned int inputLen ) // length of input block -{ - unsigned int i, index, partLen; - const uchar* input = (const uchar*)input_; - - // Compute number of bytes mod 64 - index = (unsigned int)((context->count[0] >> 3) & 0x3F); - - // Update number of bits - if ((context->count[0] += ((UINT4)inputLen << 3)) - < ((UINT4)inputLen << 3)) - context->count[1]++; - context->count[1] += ((UINT4)inputLen >> 29); - - partLen = 64 - index; - - // Transform as many times as possible. - if (inputLen >= partLen) - { - memcpy - ((POINTER)&context->buffer[index], (POINTER)input, partLen); - MD5Transform (context->state, context->buffer); - - for (i = partLen; i + 63 < inputLen; i += 64) - MD5Transform (context->state, &input[i]); - - index = 0; - } - else - i = 0; - - // Buffer remaining input - memcpy - ((POINTER)&context->buffer[index], (POINTER)&input[i], - inputLen-i); -} - -// MD5 finalization. Ends an MD5 message-digest operation, writing the -// the message digest and zeroizing the context. -void MD5Final ( - unsigned char digest[16], // message digest - MD5_CTX *context ) // context -{ - uchar bits[8]; - unsigned int index, padLen; - - // Save number of bits - Encode (bits, context->count, 8); - - // Pad out to 56 mod 64. - index = (unsigned int)((context->count[0] >> 3) & 0x3f); - padLen = (index < 56) ? (56 - index) : (120 - index); - MD5Update (context, (const char*)PADDING, padLen); - - // Append length (before padding) - MD5Update (context, (const char*)bits, 8); - - // Store state in digest - Encode (digest, context->state, 16); - - // Zeroize sensitive information. - memset ((POINTER)context, 0, sizeof (*context)); -} - -// MD5 basic transformation. Transforms state based on block. -static void MD5Transform ( - UINT4 state[4], - const uchar block[64] ) -{ - UINT4 a = state[0], b = state[1], c = state[2], d = state[3], x[16]; - - Decode (x, block, 64); - - // Round 1 - FF (a, b, c, d, x[ 0], S11, 0xd76aa478); // 1 - FF (d, a, b, c, x[ 1], S12, 0xe8c7b756); // 2 - FF (c, d, a, b, x[ 2], S13, 0x242070db); // 3 - FF (b, c, d, a, x[ 3], S14, 0xc1bdceee); // 4 - FF (a, b, c, d, x[ 4], S11, 0xf57c0faf); // 5 - FF (d, a, b, c, x[ 5], S12, 0x4787c62a); // 6 - FF (c, d, a, b, x[ 6], S13, 0xa8304613); // 7 - FF (b, c, d, a, x[ 7], S14, 0xfd469501); // 8 - FF (a, b, c, d, x[ 8], S11, 0x698098d8); // 9 - FF (d, a, b, c, x[ 9], S12, 0x8b44f7af); // 10 - FF (c, d, a, b, x[10], S13, 0xffff5bb1); // 11 - FF (b, c, d, a, x[11], S14, 0x895cd7be); // 12 - FF (a, b, c, d, x[12], S11, 0x6b901122); // 13 - FF (d, a, b, c, x[13], S12, 0xfd987193); // 14 - FF (c, d, a, b, x[14], S13, 0xa679438e); // 15 - FF (b, c, d, a, x[15], S14, 0x49b40821); // 16 - - // Round 2 - GG (a, b, c, d, x[ 1], S21, 0xf61e2562); // 17 - GG (d, a, b, c, x[ 6], S22, 0xc040b340); // 18 - GG (c, d, a, b, x[11], S23, 0x265e5a51); // 19 - GG (b, c, d, a, x[ 0], S24, 0xe9b6c7aa); // 20 - GG (a, b, c, d, x[ 5], S21, 0xd62f105d); // 21 - GG (d, a, b, c, x[10], S22, 0x2441453); // 22 - GG (c, d, a, b, x[15], S23, 0xd8a1e681); // 23 - GG (b, c, d, a, x[ 4], S24, 0xe7d3fbc8); // 24 - GG (a, b, c, d, x[ 9], S21, 0x21e1cde6); // 25 - GG (d, a, b, c, x[14], S22, 0xc33707d6); // 26 - GG (c, d, a, b, x[ 3], S23, 0xf4d50d87); // 27 - GG (b, c, d, a, x[ 8], S24, 0x455a14ed); // 28 - GG (a, b, c, d, x[13], S21, 0xa9e3e905); // 29 - GG (d, a, b, c, x[ 2], S22, 0xfcefa3f8); // 30 - GG (c, d, a, b, x[ 7], S23, 0x676f02d9); // 31 - GG (b, c, d, a, x[12], S24, 0x8d2a4c8a); // 32 - - // Round 3 - HH (a, b, c, d, x[ 5], S31, 0xfffa3942); // 33 - HH (d, a, b, c, x[ 8], S32, 0x8771f681); // 34 - HH (c, d, a, b, x[11], S33, 0x6d9d6122); // 35 - HH (b, c, d, a, x[14], S34, 0xfde5380c); // 36 - HH (a, b, c, d, x[ 1], S31, 0xa4beea44); // 37 - HH (d, a, b, c, x[ 4], S32, 0x4bdecfa9); // 38 - HH (c, d, a, b, x[ 7], S33, 0xf6bb4b60); // 39 - HH (b, c, d, a, x[10], S34, 0xbebfbc70); // 40 - HH (a, b, c, d, x[13], S31, 0x289b7ec6); // 41 - HH (d, a, b, c, x[ 0], S32, 0xeaa127fa); // 42 - HH (c, d, a, b, x[ 3], S33, 0xd4ef3085); // 43 - HH (b, c, d, a, x[ 6], S34, 0x4881d05); // 44 - HH (a, b, c, d, x[ 9], S31, 0xd9d4d039); // 45 - HH (d, a, b, c, x[12], S32, 0xe6db99e5); // 46 - HH (c, d, a, b, x[15], S33, 0x1fa27cf8); // 47 - HH (b, c, d, a, x[ 2], S34, 0xc4ac5665); // 48 - - // Round 4 - II (a, b, c, d, x[ 0], S41, 0xf4292244); // 49 - II (d, a, b, c, x[ 7], S42, 0x432aff97); // 50 - II (c, d, a, b, x[14], S43, 0xab9423a7); // 51 - II (b, c, d, a, x[ 5], S44, 0xfc93a039); // 52 - II (a, b, c, d, x[12], S41, 0x655b59c3); // 53 - II (d, a, b, c, x[ 3], S42, 0x8f0ccc92); // 54 - II (c, d, a, b, x[10], S43, 0xffeff47d); // 55 - II (b, c, d, a, x[ 1], S44, 0x85845dd1); // 56 - II (a, b, c, d, x[ 8], S41, 0x6fa87e4f); // 57 - II (d, a, b, c, x[15], S42, 0xfe2ce6e0); // 58 - II (c, d, a, b, x[ 6], S43, 0xa3014314); // 59 - II (b, c, d, a, x[13], S44, 0x4e0811a1); // 60 - II (a, b, c, d, x[ 4], S41, 0xf7537e82); // 61 - II (d, a, b, c, x[11], S42, 0xbd3af235); // 62 - II (c, d, a, b, x[ 2], S43, 0x2ad7d2bb); // 63 - II (b, c, d, a, x[ 9], S44, 0xeb86d391); // 64 - - state[0] += a; - state[1] += b; - state[2] += c; - state[3] += d; - - // Zeroize sensitive information. - memset ((POINTER)x, 0, sizeof (x)); -} - -// Encodes input (UINT4) into output (unsigned char). Assumes len is -// a multiple of 4. -static void Encode ( - unsigned char *output, - UINT4 *input, - unsigned int len ) -{ - unsigned int i, j; - - for (i = 0, j = 0; j < len; i++, j += 4) { - output[j] = (unsigned char)(input[i] & 0xff); - output[j+1] = (unsigned char)((input[i] >> 8) & 0xff); - output[j+2] = (unsigned char)((input[i] >> 16) & 0xff); - output[j+3] = (unsigned char)((input[i] >> 24) & 0xff); - } -} - -// Decodes input (unsigned char) into output (UINT4). Assumes len is -// a multiple of 4. -static void Decode ( - UINT4 *output, - const uchar *input, - unsigned int len ) -{ - unsigned int i, j; - - for (i = 0, j = 0; j < len; i++, j += 4) - output[i] = ((UINT4)input[j]) | (((UINT4)input[j+1]) << 8) | - (((UINT4)input[j+2]) << 16) | (((UINT4)input[j+3]) << 24); -} - -void digest2ascii ( char *ascii, const unsigned char *digest ) -{ - int i; - static char* table = "0123456789abcdef"; - for ( i = 0; i < 16; i++ ) - { - *ascii++ = table[(*digest)>>4]; - *ascii++ = table[(*digest++)%16]; - } - *ascii++ = 0; -} - -void ascii2digest ( unsigned char *digest, const char *ascii ) -{ - int i; -#define CONV(c) (unsigned char)( (toupper(c)>='A') ? (toupper(c)+10-'A') : ((c)-'0') ) -#define MAKECHAR(a,b) ((CONV(a)%16)<<4)|(CONV(b)%16) - for ( i = 0; i < 16; i++ ) - { - *digest++ = MAKECHAR(ascii[0],ascii[1]); - ascii += 2; - } -} - -#ifdef __cplusplus -MD5::MD5() -{ - Init(); -} - -void MD5::Init() -{ - MD5Init(&_ctx); -} - -void MD5::Update ( const string& s ) -{ - MD5Update ( &_ctx, s.c_str(), s.size() ); -} - -string MD5::Final ( char* digest ) -{ - vector v; - v.resize(16); - MD5Final ( &v[0], &_ctx ); - if ( digest ) - memmove ( digest, &v[0], 16 ); - string s; - static char* tohex = "0123456789abcdef"; - for ( int i = 0; i < 16; i++ ) - { - uchar c = v[i]; - s += tohex[ (c>>4) & 0xF ]; - s += tohex[ c & 0xF ]; - } - return s; -} - -string MD5Hex ( const string& s ) -{ - MD5 md5; - md5.Update ( s ); - return md5.Final(); -} - -string MD5Bin ( const string& s ) -{ - MD5 md5; - md5.Update ( s ); - char digest[16]; - md5.Final ( digest ); - return string ( digest, 16 ); -} - -string HMAC_MD5 ( const string& key, const string& text, char* out_bin ) -{ - MD5 md5; - char k_ipad[65]; // inner padding - key XORd with ipad - char k_opad[65]; // outer padding - key XORd with opad - string tmp; - char digest[16]; - int i; - // if key is longer than 64 bytes reset it to key=MD5(key) - if ( key.length() > 64 ) - { - md5.Init(); - md5.Update ( key ); - md5.Final ( digest ); - tmp = string ( digest, 16 ); - } - else - tmp = key; - - // start out by storing key in pads - memset ( k_ipad, 0, sizeof(k_ipad) ); - memset ( k_opad, 0, sizeof(k_opad) ); - memcpy ( k_ipad, tmp.c_str(), tmp.length() ); - memcpy ( k_opad, tmp.c_str(), tmp.length() ); - - // XOR key with ipad and opad values - for ( i=0; i<64; i++ ) - { - k_ipad[i] ^= 0x36; - k_opad[i] ^= 0x5c; - } - - // "inner" MD5 - md5.Init(); - md5.Update(k_ipad); - md5.Update(text); - md5.Final ( digest ); - - // "outer" MD5 - md5.Init(); - md5.Update(k_opad); - md5.Update(string(digest,16)); - return md5.Final(out_bin); -} -#endif//__cplusplus diff --git a/irc/ArchBlackmann/MD5.h b/irc/ArchBlackmann/MD5.h deleted file mode 100644 index f4bd3c19d9a..00000000000 --- a/irc/ArchBlackmann/MD5.h +++ /dev/null @@ -1,95 +0,0 @@ -// MD5.H - header file for MD5.CPP - -/* -Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All -rights reserved. - -License to copy and use this software is granted provided that it -is identified as the "RSA Data Security, Inc. MD5 Message-Digest -Algorithm" in all material mentioning or referencing this software -or this function. - -License is also granted to make and use derivative works provided -that such works are identified as "derived from the RSA Data -Security, Inc. MD5 Message-Digest Algorithm" in all material -mentioning or referencing the derived work. - -RSA Data Security, Inc. makes no representations concerning either -the merchantability of this software or the suitability of this -software for any particular purpose. It is provided "as is" -without express or implied warranty of any kind. - -These notices must be retained in any copies of any part of this -documentation and/or software. -*/ - -#ifndef __MD5_H -#define __MD5_H - -#ifdef __cplusplus -#include -#endif//__cplusplus - -#ifndef uchar -#define uchar unsigned char -#endif//uchar - -#ifndef ushort -#define ushort unsigned short -#endif//ushort - -#ifndef ulong -#define ulong unsigned long -#endif//ulong - -#ifdef __cplusplus -extern "C" { -#endif//__cplusplus - -typedef uchar *POINTER; // POINTER defines a generic pointer type -typedef ushort UINT2; // UINT2 defines a two byte word -typedef ulong UINT4; // UINT4 defines a four byte word - -// MD5 context. -typedef struct -{ - UINT4 state[4]; // state (ABCD) - UINT4 count[2]; // number of bits, modulo 2^64 (lsb first) - unsigned char buffer[64]; // input buffer -} MD5_CTX; - -void MD5Init ( MD5_CTX * ); -void MD5Update ( MD5_CTX *, const char *, unsigned int ); -void MD5Final ( uchar [16], MD5_CTX * ); - -void digest2ascii ( char *ascii, const uchar *digest ); -void ascii2digest ( uchar *digest, const char *ascii ); - -#ifdef __cplusplus - -} // extern "C" - -class MD5 -{ -public: - MD5(); - void Init(); - void Update ( const std::string& s ); - std::string Final ( char* digest = 0 ); - -private: - MD5_CTX _ctx; -}; - -std::string MD5Hex ( const std::string& s ); - -std::string MD5Bin ( const std::string& s ); - -std::string HMAC_MD5 ( - const std::string& key, - const std::string& text, - char* out_bin = NULL ); - -#endif//__cplusplus - -#endif//__MD5_H diff --git a/irc/ArchBlackmann/QueueT.h b/irc/ArchBlackmann/QueueT.h deleted file mode 100644 index 3d15bcbf741..00000000000 --- a/irc/ArchBlackmann/QueueT.h +++ /dev/null @@ -1,315 +0,0 @@ -/* -** Author: Samuel R. Blackburn -** Internet: wfc@pobox.com -** -** You can use it any way you like as long as you don't try to sell it. -** -** Any attempt to sell WFC in source code form must have the permission -** of the original author. You can produce commercial executables with -** WFC but you can't sell WFC. -** -** Copyright, 2000, Samuel R. Blackburn -** -** NOTE: I modified the info block below so it hopefully wouldn't conflict -** with the original file. Royce Mitchell III -*/ - -#ifndef QUEUET_CLASS_HEADER -#define QUEUET_CLASS_HEADER - -#include "ReliMT.h" - -#ifdef WIN32 -#include // off_t -#define HEAPCREATE(size) m_Heap = ::HeapCreate ( HEAP_NO_SERIALIZE, size, 0 ) -#define HEAPALLOC(size) ::HeapAlloc ( m_Heap, HEAP_NO_SERIALIZE, size ) -#define HEAPREALLOC(p,size) ::HeapReAlloc( m_Heap, HEAP_NO_SERIALIZE, p, size ) -#define HEAPFREE(p) ::HeapFree ( m_Heap, HEAP_NO_SERIALIZE, p ) -#define HEAPDESTROY() ::HeapDestroy ( m_Heap ); m_Heap = 0; -#else -#define HEAPCREATE(size) -#define HEAPALLOC(size) malloc(size) -#define HEAPREALLOC(p,size) realloc(p,size); -#define HEAPFREE(p) free(p) -#define HEAPDESTROY() -#endif - -template -class CQueueT : public Uncopyable -{ -protected: - - // What we want to protect - - Mutex m_AddMutex; - Mutex m_GetMutex; - - T* m_Items; - - off_t m_AddIndex; - off_t m_GetIndex; - size_t m_Size; - -#ifdef WIN32 - HANDLE m_Heap; -#endif//WIN32 - inline void m_GrowBy ( size_t number_of_new_items ); - -public: - - inline CQueueT ( size_t initial_size = 1024 ); - inline ~CQueueT(); - - inline bool Add( const T& new_item ); - inline void Empty() { m_AddIndex = 0; m_GetIndex = 0; }; - inline bool Get( T& item ); - inline size_t GetLength() const; - inline size_t GetMaximumLength() const { return( m_Size ); }; - inline bool AddArray ( const T* new_items, int item_count ); - inline int GetArray ( T* items, const int maxget, const T& tEnd ); - inline bool Contains ( const T& t ); -}; - -template -inline CQueueT::CQueueT ( size_t initial_size ) -{ - m_AddIndex = 0; - m_GetIndex = 0; - m_Items = NULL; - - if ( initial_size == 0 ) - initial_size = 1; - - /* - ** 1999-11-05 - ** We create our own heap because all of the pointers used are allocated - ** and freed be us. We don't have to worry about a non-serialized thread - ** accessing something we allocated. Because of this, we can perform our - ** memory allocations in a heap dedicated to queueing. This means when we - ** have to allocate more memory, we don't have to wait for all other threads - ** to pause while we allocate from the shared heap (like the C Runtime heap) - */ - - HEAPCREATE( ( ( ( 2 * initial_size * sizeof(T) ) < 65536 ) ? 65536 : (2 * initial_size * sizeof(T) ) ) ); - - m_Items = (T*)HEAPALLOC ( initial_size * sizeof(T) ); - - m_Size = ( m_Items == NULL ) ? 0 : initial_size; -} - -template -inline CQueueT::~CQueueT() -{ - m_AddIndex = 0; - m_GetIndex = 0; - m_Size = 0; - - if ( m_Items != NULL ) - { - HEAPFREE(m_Items); - m_Items = NULL; - } - - HEAPDESTROY(); -} - -template -inline bool CQueueT::Add ( const T& item ) -{ - // Block other threads from entering Add(); - Mutex::Lock addlock ( m_AddMutex ); - - // Add the item - - m_Items[ m_AddIndex ] = item; - - // 1999-12-08 - // Many many thanks go to Lou Franco (lfranco@spheresoft.com) - // for finding an bug here. It rare but recreatable situations, - // m_AddIndex could be in an invalid state. - - // Make sure m_AddIndex is never invalid - - off_t new_add_index = ( ( m_AddIndex + 1 ) >= (off_t)m_Size ) ? 0 : m_AddIndex + 1; - - if ( new_add_index == m_GetIndex ) - { - // The queue is full. We need to grow. - // Stop anyone from getting from the queue - Mutex::Lock getlock ( m_GetMutex ); - - m_AddIndex = new_add_index; - - // One last double-check. - - if ( m_AddIndex == m_GetIndex ) - { - m_GrowBy ( m_Size ); - } - - } - else - { - m_AddIndex = new_add_index; - } - - return true; -} - -template -inline bool CQueueT::Get( T& item ) -{ - // Prevent other threads from entering Get() - Mutex::Lock getlock ( m_GetMutex ); - - if ( m_GetIndex == m_AddIndex ) - { - // Let's check to see if our queue has grown too big - // If it has, then shrink it - - if ( m_Size > 1024 ) - { - // Yup, we're too big for our britches - Mutex::TryLock addlock ( m_AddMutex ); - if ( addlock ) - { - // Now, no one can add to the queue - - if ( m_GetIndex == m_AddIndex ) // is queue empty? - { - // See if we can just shrink it... - T* return_value = (T*)HEAPREALLOC(m_Items,1024 * sizeof(T)); - - if ( return_value != NULL ) - { - m_Items = (T*) return_value; - } - else - { - // Looks like we'll have to do it the hard way - HEAPFREE ( m_Items ); - m_Items = (T*) HEAPALLOC ( 1024 * sizeof(T) ); - } - - m_Size = ( m_Items == NULL ) ? 0 : 1024; - m_AddIndex = 0; - m_GetIndex = 0; - } - else - { - // m_GetIndex != m_AddIndex, this means that someone added - // to the queue between the time we checked m_Size for being - // too big and the time we entered the add critical section. - // If this happened then we are too busy to shrink - } - } - } - return false; - } - - item = m_Items[ m_GetIndex ]; - - // Make sure m_GetIndex is never invalid - - m_GetIndex = ( ( m_GetIndex + 1 ) >= (off_t)m_Size ) ? 0 : m_GetIndex + 1; - - return true; -} - -template -inline int CQueueT::GetArray ( T* items, const int maxget, const T& tEnd ) -{ - // TODO - oooh baby does this need to be optimized - // Prevent other threads from entering Get() - Mutex::Lock getlock ( m_GetMutex ); //::EnterCriticalSection( &m_GetCriticalSection ); - - int iResult = 0; - for ( int i = 0; i < maxget; i++ ) - { - if ( !Get(items[i]) ) - break; - iResult++; - if ( items[i] == tEnd ) - break; - } - // Let other threads call Get() now - //::LeaveCriticalSection( &m_GetCriticalSection ); - return iResult; -} - -template -inline size_t CQueueT::GetLength() const -{ - // This is a very expensive process! - // No one can call Add() or Get() while we're computing this - - size_t number_of_items_in_the_queue = 0; - - Mutex::Lock addlock ( m_AddMutex ); - Mutex::Lock getlock ( m_GetMutex ); - - number_of_items_in_the_queue = ( m_AddIndex >= m_GetIndex ) ? - ( m_AddIndex - m_GetIndex ) : - ( ( m_AddIndex + m_Size ) - m_GetIndex ); - - return number_of_items_in_the_queue; -} - -template -inline void CQueueT::m_GrowBy ( size_t number_of_new_items ) -{ - // Prevent other threads from calling Get(). - // We don't need to enter the AddCriticalSection because - // m_GrowBy() is only called from Add(); - - T* new_array = NULL; - T* pointer_to_free = NULL; - - size_t new_size = m_Size + number_of_new_items; - - { // Prevent other threads from getting - Mutex::Lock getlock ( m_GetMutex ); - - // 2000-05-16 - // Thanks go to Royce Mitchell III (royce3@aim-controls.com) for finding - // a HUGE bug here. I was using HeapReAlloc as a short cut but my logic - // was flawed. In certain circumstances, queue items were being dropped. - - new_array = (T*)HEAPALLOC ( new_size * sizeof(T) ); - - // Now copy all of the old items from the old queue to the new one. - - // Get the entries from the get-index to the end of the array - memcpy ( new_array, &m_Items[m_GetIndex], ( m_Size - m_GetIndex ) * sizeof(T) ); - - // Get the entries from the beginning of the array to the add-index - memcpy ( &new_array[m_Size-m_GetIndex], m_Items, m_AddIndex * sizeof(T) ); - - m_AddIndex = (off_t)m_Size; - m_GetIndex = 0; - m_Size = new_size; - pointer_to_free = m_Items; - m_Items = new_array; - } // Mutex::Lock - HEAPFREE ( pointer_to_free ); -} - -template -inline bool CQueueT::Contains ( const T& t ) -{ - Mutex::Lock addlock ( m_AddMutex ); - Mutex::Lock getlock ( m_GetMutex ); - - for ( int i = m_GetIndex; i != m_AddIndex; i++ ) - { - if ( i == m_Size ) - i = 0; - if ( m_Items[i] == t ) - return true; - } - return m_Items[m_AddIndex] == t; -} - -typedef CQueueT CCharQueue; - -#endif // QUEUE_CLASS_HEADER diff --git a/irc/ArchBlackmann/Reli.h b/irc/ArchBlackmann/Reli.h deleted file mode 100644 index ebc35d3a4a8..00000000000 --- a/irc/ArchBlackmann/Reli.h +++ /dev/null @@ -1,143 +0,0 @@ -// Reli.h -// lots of code here is (c) Bartosz Milewski, 1996, www.relisoft.com -// The rest is (C) 2002-2004 Royce Mitchell III -// and released under the LGPL & BSD licenses - -#ifndef __RELI_H -#define __RELI_H - -//////////////////////////////////////////////////////////////////////////////// -// Assert - -#undef Assert -#ifdef NDEBUG - #define Assert(exp) ((void)0) -#else - void _wassert (char* szExpr, char* szFile, int line); - #define Assert(exp) (void)( (exp) || (_wassert(#exp, __FILE__, __LINE__), 0) ) -#endif /* NDEBUG */ - -//////////////////////////////////////////////////////////////////////////////// -// Swap - -template -void Swap(T a,T b) -{ - T t = a; - a = b; - b = t; -} - -//////////////////////////////////////////////////////////////////////////////// -// Uncopyable - base class disabling copy ctors -class Uncopyable -{ -public: - Uncopyable(){} // need a default ctor -private: - Uncopyable ( const Uncopyable& ); - const Uncopyable& operator = ( const Uncopyable& ); -}; - -//////////////////////////////////////////////////////////////////////////////// -// SPtr - Smart Pointer's must be passed by reference or const reference - -template -class SPtr : public Uncopyable -{ -public: - virtual ~SPtr () { Destroy(); } - T * operator->() { return _p; } - T const * operator->() const { return _p; } - operator T&() { Assert(_p); return *_p; } - operator const T&() const { Assert(_p); return *_p; } - void Acquire ( SPtr& t ) { Destroy(); Swap(_p,t._p); } - void Destroy() { if ( _p ) { delete _p; _p = 0; } } -protected: - SPtr (): _p (0) {} - explicit SPtr (T* p): _p (p) {} - T * _p; -private: - operator T* () { return _p; } -}; - -#define DECLARE_SPTR(cls,init,init2) \ -class S##cls : public SPtr \ -{ \ -public: \ - S##cls ( cls* p ) : SPtr(p) {} \ - explicit S##cls init : SPtr (new cls init2) {} \ -}; -/* Example Usage of DECLARE_SPTR: -class MyClass -{ -public: // can be protected - MyClass ( int i ) - { - ... - } - ... -}; DECLARE_SPTR(MyClass,(int i),(i)) -SMyClass ptr(i); -*/ -#define DECLARE_SPTRV(cls) typedef SPtr S##cls; -/* Example Usage of DECLARE_SPTRV: -class MyAbstractClass -{ -public: // can be protected - MyAbstractClass ( int i ) - { - ... - } - void MyPureVirtFunc() = 0; - ... -}; DECLARE_SPTRV(MyAbstractClass) -SMyAbstractClass ptr ( new MySubClass(i) ); -*/ - -#define DECLARE_PTR(cls,init,init2) \ - class Ptr : public SPtr \ - { \ - Ptr(cls* p) : SPtr ( p ) \ - { \ - } \ - Ptr init : SPtr ( new cls init2 ) {} \ - }; -/* Example Usage of DECLARE_PTR: -class MyClass -{ - DECLARE_PTR(MyClass,(int i),(i)) -public: // can be protected - MyClass ( int i ) - { - ... - } - void MyPureVirtFunc() = 0; - ... -}; -MyClass::Ptr ptr ( i ); -*/ - -#define DECLARE_PTRV(cls) \ - class Ptr : public SPtr \ - { \ - Ptr(cls* p) : SPtr ( p ) \ - { \ - } \ - }; -/* Example Usage of DECLARE_PTRV: -class MyAbstractClass -{ - DECLARE_PTRV(MyAbstractClass) -public: // can be protected - MyAbstractClass ( int i ) - { - ... - } - void MyPureVirtFunc() = 0; - ... -}; -MyAbstractClass::Ptr ptr ( new MySubClass(i) ); -*/ - -#endif//__RELI_H diff --git a/irc/ArchBlackmann/ReliMT.cpp b/irc/ArchBlackmann/ReliMT.cpp deleted file mode 100644 index 2c50dc40f1c..00000000000 --- a/irc/ArchBlackmann/ReliMT.cpp +++ /dev/null @@ -1,331 +0,0 @@ -// ReliMT.cpp -// lots of code here is (c) Bartosz Milewski, 1996, www.relisoft.com -// The rest is (C) 2002-2004 Royce Mitchell III -// and released under the LGPL & BSD licenses - -#include -#include -#ifdef WIN32 -# define WIN32_LEAN_AND_MEAN -# include -# define snprintf _snprintf -#elif defined(UNIX) -# include -# include -#else -# error unrecognized target -#endif//WIN32|UNIX -#include "verify.h" -#include "ReliMT.h" - -//////////////////////////////////////////////////////////////////////////////// -// Assert - -void _wassert ( char* szExpr, char* szFile, int line ) -{ - fprintf ( stderr, "Assertion Failure: \"%s\" in file %s, line %d", szExpr, szFile, line ); - exit (-1); -} - - -//////////////////////////////////////////////////////////////////////////////// -// Thread - -Thread::Thread ( long (THREADAPI * pFun) (void* arg), void* pArg ) -{ -#ifdef WIN32 - verify ( _handle = CreateThread ( - 0, // Security attributes - 0, // Stack size - (DWORD (WINAPI*)(void*))pFun, - pArg, - 0, // don't create suspended. - &_tid )); -#elif defined(UNIX) - // set up the thread attribute: right now, we do nothing with it. - pthread_attr_t attr; - pthread_attr_init(&attr); - - // this will make the threads created by this process really concurrent - verify ( !pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM) ); - - // create the new OS thread object - verify ( !pthread_create ( &_threadId, &attr, (void* (*) (void*))pFun, pArg ) ); - - verify ( !pthread_attr_destroy(&attr) ); -#else -# error unrecognized target -#endif//WIN32|UNIX -} - -Thread::~Thread() -{ -#ifdef WIN32 - verify ( CloseHandle ( _handle ) ); -#elif defined(UNIX) - verify ( !pthread_cancel ( _threadId ) ); -#else -# error unrecognized target -#endif//WIN32|UNIX -} - -/*void Thread::Resume() -{ -#ifdef WIN32 - ResumeThread (_handle); -#elif defined(UNIX) -# error how to resume thread in unix? -#else -# error unrecognized target -#endif//WIN32|UNIX -}*/ - -void Thread::WaitForDeath() -{ -#ifdef WIN32 - DWORD dw = WaitForSingleObject ( _handle, 2000 ); - ASSERT ( dw != WAIT_FAILED ); -#elif defined(UNIX) - verify ( !pthread_join ( _threadId, (void**)NULL ) ); -#else -# error unrecognized target -#endif//WIN32|UNIX -} - - -//////////////////////////////////////////////////////////////////////////////// -// ActiveObject - -// The constructor of the derived class -// should call -// _thread.Resume(); -// at the end of construction - -ActiveObject::ActiveObject() : _isDying (0), _thread (0) -{ -} - -ActiveObject::~ActiveObject() -{ - ASSERT ( !_thread ); // call Kill() from subclass's dtor - // Kill() - // You can't call a virtual function from a dtor, EVEN INDIRECTLY - // so, you must call Kill() in the subclass's dtor -} - -// FlushThread must reset all the events on which the thread might be waiting. -void ActiveObject::Kill() -{ - if ( _thread ) - { - _isDying++; - FlushThread(); - // Let's make sure it's gone - _thread->WaitForDeath(); - delete _thread; - _thread = 0; - } -} - -void ActiveObject::Start() -{ - ASSERT ( !_thread ); - _thread = new Thread ( ThreadEntry, this ); -} - -long THREADAPI ActiveObject::ThreadEntry ( void* pArg ) -{ - ActiveObject * pActive = (ActiveObject*)pArg; - pActive->InitThread(); - pActive->Run(); - pActive->Kill(); - return 0; -} - - -/////////////////////////////////////////////////////////////////////////////// -// Mutex - -Mutex::Mutex() -{ -#ifdef WIN32 - verify ( _h = CreateMutex ( NULL, FALSE, NULL ) ); -#elif defined(UNIX) - pthread_mutexattr_t attrib; - verify ( !pthread_mutexattr_init( &attrib ) ); - // allow recursive locks - verify ( !pthread_mutexattr_settype( &attrib, PTHREAD_MUTEX_RECURSIVE ) ); - verify ( !pthread_mutex_init ( &_mutex, &attrib ) ); -#else -# error unrecognized target -#endif -} - -Mutex::~Mutex() -{ -#ifdef WIN32 - verify ( CloseHandle ( _h ) ); -#elif defined(UNIX) - verify ( !pthread_mutex_destroy(&_mutex) ); -#else -# error unrecognized target -#endif -} - -void Mutex::Acquire() -{ -#ifdef WIN32 - DWORD dw = WaitForSingleObject ( _h, INFINITE ); - ASSERT ( dw == WAIT_OBJECT_0 || dw == WAIT_ABANDONED ); -#elif defined(UNIX) - verify ( !pthread_mutex_lock(&_mutex) ); -#else -# error unrecognized target -#endif -} - -bool Mutex::TryAcquire() -{ -#ifdef WIN32 - DWORD dw = WaitForSingleObject ( _h, 1 ); - ASSERT ( dw == WAIT_OBJECT_0 || dw == WAIT_TIMEOUT || dw == WAIT_ABANDONED ); - return (dw != WAIT_TIMEOUT); -#elif defined(UNIX) - int err = pthread_mutex_trylock(&_mutex); - ASSERT ( err == EBUSY || err == 0 ); - return (err == 0); -#else -# error unrecognized target -#endif -} - -void Mutex::Release() -{ -#ifdef WIN32 - verify ( ReleaseMutex ( _h ) ); -#elif defined(UNIX) - verify ( !pthread_mutex_unlock(&_mutex) ); - // we could allow EPERM return value too, but we are forcing user into RIIA -#else -# error unrecognized target -#endif -} - -Mutex::Lock::Lock ( Mutex& m ) : _m(m) -{ - _m.Acquire(); -} - -Mutex::Lock::~Lock() -{ - _m.Release(); -} - -Mutex::TryLock::TryLock ( Mutex& m ) : _m(m) -{ - _bLocked = _m.TryAcquire(); -} - -Mutex::TryLock::~TryLock() -{ - if ( _bLocked ) - _m.Release(); -} - -/////////////////////////////////////////////////////////////////////////////// -// Event - -Event::Event() -{ -#ifdef WIN32 - // start in non-signaled state (red light) - // auto reset after every Wait - verify ( _handle = CreateEvent ( 0, FALSE, FALSE, 0 ) ); -#elif defined(UNIX) - //verify ( !pthread_cond_init ( &_cond, NULL /* default attributes */) ); - sem_init(); - //verify(sem_init()); -#else -# error unrecognized target -#endif -} - -Event::~Event() -{ -#ifdef WIN32 - verify ( CloseHandle ( _handle ) ); -#elif defined(UNIX) - //verify ( !pthread_cond_destroy ( &_cond ) ); - sem_destroy(); -#else -# error unrecognized target -#endif -} - -void Event::Release() // put into signaled state -{ -#ifdef WIN32 - verify ( SetEvent ( _handle ) ); -#elif defined(UNIX) - //verify ( !pthread_cond_signal ( &_cond ) ); - verify(!sem_V()); -#else -# error unrecognized target -#endif -} - -void Event::Wait() -{ -#ifdef WIN32 - // Wait until event is in signaled (green) state - DWORD dw = WaitForSingleObject ( _handle, INFINITE ); - ASSERT ( dw == WAIT_OBJECT_0 || dw == WAIT_ABANDONED ); -#elif defined(UNIX) - // According to docs: The pthread_cond_wait() and pthread_cond_timedwait() - // functions are used to block on a condition variable. They are called - // with mutex locked by the calling thread or undefined behaviour will - // result. - //Mutex::Lock lock ( _mutex ); - //verify ( !pthread_cond_wait ( &_cond, _mutex ) ); - verify(!sem_P()); -#else -# error unrecognized target -#endif -} - -#ifdef UNIX -void Event::sem_init() -{ - sem_id = semget(IPC_PRIVATE, 1, 0666 | IPC_CREAT); - ASSERT(sem_id != -1); -} - -int Event::sem_P() -{ - struct sembuf sb; - sb.sem_num = 0; - sb.sem_op = -1; - sb.sem_flg = 0; - return semop(sem_id, &sb, 1); -} - -int Event::sem_V() -{ - struct sembuf sb; - sb.sem_num = 0; - sb.sem_op = 1; - sb.sem_flg = 0; - return semop(sem_id, &sb, 1); -} - -void Event::sem_destroy() -{ -#ifdef MACOSX - semun mactmp; - mactmp.val = 0; - semctl(sem_id, 0, IPC_RMID, mactmp); -#else - semctl(sem_id, 0, IPC_RMID, 0); -#endif -} -#endif - diff --git a/irc/ArchBlackmann/ReliMT.h b/irc/ArchBlackmann/ReliMT.h deleted file mode 100644 index 17fb12169a6..00000000000 --- a/irc/ArchBlackmann/ReliMT.h +++ /dev/null @@ -1,229 +0,0 @@ -// ReliMT.h -// lots of code here is (c) Bartosz Milewski, 1996, www.relisoft.com -// The rest is (C) 2003-2004 Royce Mitchell III -// and released under the LGPL & BSD licenses - - -#ifndef __RELIMT_H -#define __RELIMT_H - -#include "Reli.h" - -#ifdef WIN32 -# ifndef _WINDOWS_ -# define WIN32_LEAN_AND_MEAN -# include -# endif -# define THREADAPI WINAPI -#elif defined(UNIX) -# include -# include -# include "string.h" -# include //Semaphore -# include //Semaphore -# include //Semaphore -# define THREADAPI -#else -# error unrecognized target -#endif - - -//////////////////////////////////////////////////////////////////////////////// -// Thread - -class Thread : public Uncopyable -{ -public: - Thread ( long (THREADAPI * pFun) (void* arg), void* pArg ); - ~Thread(); - //void Resume(); - void WaitForDeath(); - - // platform-specific stuff: -private: -#ifdef WIN32 - HANDLE _handle; - DWORD _tid; // thread id -#elif defined(UNIX) - pthread_t _threadId; // id of the thread -#else -# error unrecognized target -#endif - //DECLARE_PTR(Thread,(long (THREADAPI * pFun) (void* arg), void* pArg),(pFun,pArg)); -}; //DECLARE_SPTR(Thread,(long (THREADAPI * pFun) (void* arg), void* pArg),(pFun,pArg)); - -//////////////////////////////////////////////////////////////////////////////// -// ActiveObject - -class ActiveObject : public Uncopyable -{ -public: - ActiveObject(); - virtual ~ActiveObject(); - void Kill(); - void Start(); - -protected: - virtual void InitThread() = 0; - virtual void Run() = 0; - virtual void FlushThread() = 0; - - int _isDying; - - static long THREADAPI ThreadEntry ( void *pArg ); - Thread *_thread; - - //DECLARE_PTRV(ActiveObject); -}; //DECLARE_SPTRV(ActiveObject); - -// Last thing in the constructor of a class derived from -// ActiveObject you must call -// Start(); -// Inside the loop the Run method you must keep checking _isDying -// if (_isDying) -// return; -// FlushThread must reset all the events on which the thread might be waiting. -// Example: -#if 0 -// MyAsyncOutputter - class that outputs strings to a file asynchronously -class MyAsyncOutputter : public ActiveObject -{ -public: - MyAsyncOutputter ( const string& filename ) : _filename(filename), _currentBuf(0) - { - Start(); // start thread - } - void InitThread() - { - _f.open ( _filename, "wb" ); - } - void Output ( const string& s ) - { - { - // acquire lock long enough to add the string to the active buffer - Mutex::Lock lock ( _mutex ); - _buf[_currentBuf].push_back ( s ); - } - _event.Release(); // don't need the lock fire the event - } - void Run() - { - while ( !_isDying ) - { - // wait for signal from Output() or FlushThread() - _event.Wait(); - { - // acquire lock long enough to switch active buffers - Mutex::Lock lock ( _mutex ); - _currentBuf = 1-_currentBuf; - ASSERT ( !_buf[_currentBuf].size() ); - } - // get a reference to the old buffer - vector& buf = _buf[1-_currentBuf]; - // write each string out to file and then empty the buffer - for ( int i = 0; i < buf.size(); i++ ) - _f.write ( buf[i].c_str(), buf[i].size() ); - buf.resize(0); - } - } - void FlushThread() - { - // _isDying is already set: signal thread so it can see that too - _event.Release(); - } -private: - string _filename; - File _f; - int _currentBuf; - vector _buf[2]; - Event _event; - Mutex _mutex; -}; -#endif - -//////////////////////////////////////////////////////////////////////////////// -// Mutex - -class Mutex : public Uncopyable -{ -public: - Mutex(); - ~Mutex(); -private: - void Acquire(); - bool TryAcquire(); - void Release(); -public: - // sub-class used to lock the Mutex - class Lock : public Uncopyable - { - public: - Lock ( Mutex& m ); - ~Lock(); - - private: - // private data - Mutex& _m; - }; - friend class Mutex::Lock; - - - // sub-class used to attempt to lock the mutex. Use operator bool() - // to test if the lock was successful - class TryLock : public Uncopyable - { - public: - TryLock ( Mutex& m ); - ~TryLock(); - operator bool () { return _bLocked; } - - private: - // private data - bool _bLocked; - Mutex& _m; - }; - friend class Mutex::TryLock; - -private: - // platform-specific stuff: -#ifdef WIN32 - HANDLE _h; -#elif defined(UNIX) - pthread_mutex_t _mutex; -public: operator pthread_mutex_t* () { return &_mutex; } -#else -# error unrecognized target -#endif -}; - -//////////////////////////////////////////////////////////////////////////////// -// Event - -class Event : public Uncopyable -{ -public: - Event(); - ~Event(); - void Release(); // put into signaled state - void Wait(); - -private: -#ifdef WIN32 - HANDLE _handle; -#elif defined(UNIX) - //Sem util functions - void sem_init(); - int sem_P(); - int sem_V(); - void sem_destroy(); - - int sem_id; - //pthread_cond_t _cond; - //Mutex _mutex; -#else -# error unrecognized target -#endif - //DECLARE_PTR(Event,(),()); -}; //DECLARE_SPTR(Event,(),()); - -#endif//__RELIWIN32_H diff --git a/irc/ArchBlackmann/SockUtils.cpp b/irc/ArchBlackmann/SockUtils.cpp deleted file mode 100644 index 3398b8d88c1..00000000000 --- a/irc/ArchBlackmann/SockUtils.cpp +++ /dev/null @@ -1,504 +0,0 @@ -// SockUtils.cpp - Some basic socket utility functions. -// (C) 2002-2004 Royce Mitchell III -// This file is under the BSD & LGPL licenses - -#include -#include "SockUtils.h" -#ifdef WIN32 -# ifndef SD_SEND // defined in winsock2.h, but not winsock.h -# define SD_SEND 1 -# endif -# define snprintf _snprintf -# ifdef _MSC_VER -# pragma comment ( lib, "ws2_32.lib" ) -# endif//_MSC_VER -#elif defined(UNIX) -# include -# include "string.h" // memset -# include // hostent -# include //inet_addr -# include -# define SD_SEND SHUT_WR //bah thou shalt name thy defines the same -#else -# error unrecognized target -#endif -//// Constants ///////////////////////////////////////////////////////// -const int kBufferSize = 1024; -// creates broadcast address -SockAddrIn::SockAddrIn() -{ - memset ( this, 0, sizeof(sockaddr_in) ); - sin_family = AF_INET; -} -SockAddrIn::SockAddrIn ( const char* szAddr, u_short iPort ) -{ - memset ( this, 0, sizeof(sockaddr_in) ); - sin_family = AF_INET; - sin_addr.s_addr = suLookupAddress(szAddr); - sin_port = htons(iPort); -} -SockAddrIn::SockAddrIn ( in_addr_t iAddr, u_short iPort ) -{ - memset ( this, 0, sizeof(sockaddr_in) ); - sin_family = AF_INET; - sin_addr.s_addr = iAddr; - sin_port = htons(iPort); -} -bool suStartup() -{ -#ifdef WIN32 - WSADATA wsaData; - if ( WSAStartup ( MAKEWORD(2,0), &wsaData ) ) - return false; - if ( wsaData.wVersion != MAKEWORD(2,0) ) - { - WSACleanup(); - return false; - } - return true; -#elif defined(UNIX) - // nothing special required here - return true; -#else -# error unrecognized target -#endif -} -//// suTcpSocket //////////////////////////////////////////////// -// Creates a TCP socket. -SOCKET suTcpSocket() -{ - SOCKET so = socket ( AF_INET, SOCK_STREAM, 0 ); -#if defined(_DEBUG) && defined(WIN32) - if ( so == INVALID_SOCKET && WSANOTINITIALISED == WSAGetLastError() ) - MessageBox ( NULL, "You forgot to call suStartup()!", "SockUtils", MB_OK|MB_ICONEXCLAMATION ); -#endif - return so; -} -//// suUdpSocket //////////////////////////////////////////////// -// Creates a UDP socket. Compensates for new "functionality" introduced -// in Win2K with regards to select() calls -// MS Transport Provider IOCTL to control -// reporting PORT_UNREACHABLE messages -// on UDP sockets via recv/WSARecv/etc. -// Path TRUE in input buffer to enable (default if supported), -// FALSE to disable. -#ifndef SIO_UDP_CONNRESET -#define SIO_UDP_CONNRESET _WSAIOW(IOC_VENDOR,12) -#endif//SIO_UDP_CONNRESET -SOCKET suUdpSocket() -{ - SOCKET so = socket ( AF_INET, SOCK_DGRAM, 0 ); -#if defined(_DEBUG) && defined(WIN32) - if ( so == INVALID_SOCKET && WSANOTINITIALISED == WSAGetLastError() ) - MessageBox ( NULL, "You forgot to call suStartup()!", "SockUtils", MB_OK|MB_ICONEXCLAMATION ); -#endif -#ifdef WIN32 - // for Windows 2000, disable new behavior... - // see: http://www-pc.uni-regensburg.de/systemsw/W2KPRO/UPDATE/POSTSP1/Q263823.htm - // this code is innocuous on other win32 platforms - DWORD dwBytesReturned = 0; - BOOL bNewBehavior = FALSE; - // disable new Win2K behavior using - // IOCTL: SIO_UDP_CONNRESET - // we don't care about return value :) - WSAIoctl(so, SIO_UDP_CONNRESET, - &bNewBehavior, sizeof(bNewBehavior), - NULL, 0, &dwBytesReturned, - NULL, NULL); -#endif - return so; -} -//// suShutdownConnection //////////////////////////////////////////////// -// Gracefully shuts the connection sd down. Returns true if it was able -// to shut it down nicely, false if we had to "slam" it shut. -// (either way, the socket does get closed) -bool suShutdownConnection(SOCKET sd) -{ - if ( sd == INVALID_SOCKET ) - return true; - // Disallow any further data sends. This will tell the other side - // that we want to go away now. If we skip this step, we don't - // shut the connection down nicely. - if (shutdown(sd, SD_SEND) == SOCKET_ERROR) - { - closesocket(sd); - return false; - } - // Receive any extra data still sitting on the socket. After all - // data is received, this call will block until the remote host - // acknowledges the TCP control packet sent by the shutdown above. - // Then we'll get a 0 back from recv, signalling that the remote - // host has closed its side of the connection. - char acReadBuffer[kBufferSize]; - for ( ;; ) - { - int nNewBytes = recv(sd, acReadBuffer, kBufferSize, 0); - if (nNewBytes == SOCKET_ERROR) - { - closesocket(sd); - return false; - } - else if (nNewBytes != 0) - { - // FYI, received (nNewBytes) unexpected bytes during shutdown. - } - else - { - // Okay, we're done! - break; - } - } - // Close the socket. - if (closesocket(sd) == SOCKET_ERROR) - { - return false; - } - return true; -} -//// suLookupAddress //////////////////////////////////////////////// -// Basically converts a name address to an ip address -in_addr_t suLookupAddress ( const char* pcHost ) -{ - in_addr_t nRemoteAddr = inet_addr(pcHost); - if ( nRemoteAddr == INADDR_NONE ) - { - // pcHost isn't a dotted IP, so resolve it through DNS - hostent* pHE = gethostbyname(pcHost); - if ( pHE == 0 ) - { -#if defined(_DEBUG) && defined(WIN32) - if ( WSANOTINITIALISED == WSAGetLastError() ) - MessageBox ( NULL, "You forgot to call suStartup()!", "SockUtils", MB_OK|MB_ICONEXCLAMATION ); -#endif - return INADDR_NONE; - } - nRemoteAddr = *((in_addr_t*)pHE->h_addr_list[0]); - } - return nRemoteAddr; -} -bool suConnect ( SOCKET so, in_addr_t iAddress, u_short iPort ) -{ - SockAddrIn sinRemote ( iAddress, iPort ); - if ( SOCKET_ERROR == connect(so,sinRemote,sizeof(sinRemote)) ) - { -#if defined(_DEBUG) && defined(WIN32) - if ( WSANOTINITIALISED == WSAGetLastError() ) - MessageBox ( NULL, "You forgot to call suStartup()!", "SockUtils", MB_OK|MB_ICONEXCLAMATION ); -#endif - return false; - } - return true; -} -bool suConnect ( SOCKET so, const char* szAddress, u_short iPort ) -{ - return suConnect ( so, suLookupAddress(szAddress), iPort ); -} -//// suEstablishConnection //////////////////////////////////////////////// -// creates a socket of the specified type, connects to the ip address/port -// requested, and returns the SOCKET created -SOCKET suEstablishConnection ( in_addr_t iAddress, u_short iPort, int type ) -{ - // Create a socket - if ( type != SOCK_STREAM && type != SOCK_DGRAM ) - return INVALID_SOCKET; - SOCKET so = socket(AF_INET, type, 0); - if ( so == INVALID_SOCKET ) - return so; - if ( !suConnect(so, iAddress, iPort) ) - { - closesocket(so); - return INVALID_SOCKET; - } - return so; -} -//// suEstablishConnection //////////////////////////////////////////////// -// creates a socket of the specified type, connects to the address/port -// requested, and returns the SOCKET created -SOCKET suEstablishConnection ( const char* szAddress, u_short iPort, int type ) -{ - return suEstablishConnection ( suLookupAddress ( szAddress ), iPort, type ); -} -//// suBroadcast //////////////////////////////////////////////// -// takes a previously created broadcast-enabled UDP socket, and broadcasts -// a message on the local network -bool suBroadcast ( SOCKET so, u_short port, const char* buf, int len /* = -1 */ ) -{ - if ( len == -1 ) - len = (int)strlen(buf); -#if 1 - SockAddrIn to ( INADDR_BROADCAST, port ); -#else // some strange MS OS's don't broadcast to localhost... - SockAddrIn to ( "127.0.0.1", port ); - if ( SOCKET_ERROR == sendto ( so, buf, len, 0, to, sizeof(to) ) ) - return false; - to.sin_addr.s_addr = INADDR_BROADCAST; -#endif - if ( SOCKET_ERROR == sendto ( so, buf, len, 0, to, sizeof(to) ) ) - return false; - return true; -} -//// suRecv //////////////////////////////////////////////// -// retrieves data sent to our TCP socket. If no data, waits for -// a period of timeout ms. -// returns bytes received -// -1 == SOCKET_ERROR -// -2 == timed out waiting for data -int suRecv ( SOCKET so, char* buf, int buflen, int timeout ) -{ - struct timeval to; - fd_set rread; - int res; - FD_ZERO(&rread); // clear the fd_set - FD_SET(so,&rread); // indicate which socket(s) we want to check - memset((char *)&to,0,sizeof(to)); // clear the timeval struct - to.tv_sec = timeout; // timeout select after (timeout) seconds - // select returns > 0 if there is an event on the socket - res = select((int)so+1, &rread, (fd_set *)0, (fd_set *)0, &to ); - if (res < 0) - return -1; // socket error - // there was an event on the socket - if ( (res>0) && (FD_ISSET(so,&rread)) ) - return recv ( so, buf, buflen, 0 ); - return -2; -} -//// suRecvFrom //////////////////////////////////////////////// -// retrieves data sent to our UDP socket. If no data, waits for -// a period of timeout ms. -// returns bytes received -// returns bytes received -// -1 == SOCKET_ERROR -// -2 == timed out waiting for data -int suRecvFrom ( SOCKET so, char* buf, int buflen, int timeout, sockaddr_in* from, socklen_t* fromlen ) -{ - struct timeval to; - fd_set rread; - int res; - FD_ZERO(&rread); // clear the fd_set - FD_SET(so,&rread); // indicate which socket(s) we want to check - memset((char *)&to,0,sizeof(to)); // clear the timeval struct - to.tv_sec = timeout; // timeout select after (timeout) seconds - // select returns > 0 if there is an event on the socket - res = select((int)so+1, &rread, (fd_set *)0, (fd_set *)0, &to ); - if (res < 0) - return -1; // socket error - // there was an event on the socket - if ( (res>0) && (FD_ISSET(so,&rread)) ) - return recvfrom ( so, buf, buflen, 0, (sockaddr*)from, fromlen ); - return -2; // timeout -} -//// suBind //////////////////////////////////////////////// -// binds a UDP socket to an interface & port to receive -// data on that port -bool suBind ( SOCKET so, in_addr_t iInterfaceAddress, u_short iListenPort, bool bReuseAddr /* = false */ ) -{ - SockAddrIn sinInterface ( iInterfaceAddress, iListenPort ); - if ( bReuseAddr ) - { - int optval = -1; // true - if ( SOCKET_ERROR == setsockopt ( so, SOL_SOCKET, SO_REUSEADDR, (const char*)&optval, sizeof(optval) ) ) - { -#if defined(_DEBUG) && defined(WIN32) - if ( WSANOTINITIALISED == WSAGetLastError() ) - MessageBox ( NULL, "You forgot to call suStartup()!", "SockUtils", MB_OK|MB_ICONEXCLAMATION ); -#endif - return false; - } - } - if ( SOCKET_ERROR == bind(so, sinInterface, sizeof(sinInterface)) ) - { - int err = SUERRNO; - if ( err != EADDRINUSE ) - return false; -#if defined(_DEBUG) && defined(WIN32) - if ( WSANOTINITIALISED == WSAGetLastError() ) - MessageBox ( NULL, "You forgot to call suStartup()!", "SockUtils", MB_OK|MB_ICONEXCLAMATION ); -#endif - } - return true; -} -//// suBind //////////////////////////////////////////////// -// binds a UDP socket to an interface & port to receive -// data on that port -bool suBind ( SOCKET so, const char* szInterfaceAddress, u_short iListenPort, bool bReuseAddr /* = false */ ) -{ - in_addr_t iInterfaceAddr = inet_addr(szInterfaceAddress); - if ( iInterfaceAddr == INADDR_NONE ) - return false; - return suBind ( so, iInterfaceAddr, iListenPort, bReuseAddr ); -} -//// suEnableBroadcast //////////////////////////////////////////////// -// in order to send broadcast messages on a UDP socket, this function -// must be called first -bool suEnableBroadcast ( SOCKET so, bool bEnable /* = true */ ) -{ - int optval = bEnable ? -1 : 0; - if ( SOCKET_ERROR == setsockopt ( so, SOL_SOCKET, SO_BROADCAST, (const char*)&optval, sizeof(optval) ) ) - return false; - return true; -} -//// suErrDesc //////////////////////////////////////////////// -// returns text description of error code -const char* suErrDesc ( int err ) -{ - static char errbuf[256]; -#ifdef WIN32 - switch ( err ) - { -#define X(E) case E: return #E; - X(WSAEINTR) X(WSAEBADF) - X(WSAEACCES) X(WSAEFAULT) - X(WSAEINVAL) X(WSAEMFILE) - X(WSAEWOULDBLOCK) X(WSAEINPROGRESS) - X(WSAEALREADY) X(WSAENOTSOCK) - X(WSAEDESTADDRREQ) X(WSAEMSGSIZE) - X(WSAEPROTOTYPE) X(WSAENOPROTOOPT) - X(WSAEPROTONOSUPPORT) X(WSAESOCKTNOSUPPORT) - X(WSAEOPNOTSUPP) X(WSAEPFNOSUPPORT) - X(WSAEAFNOSUPPORT) X(WSAEADDRINUSE) - X(WSAEADDRNOTAVAIL) X(WSAENETDOWN) - X(WSAENETUNREACH) X(WSAENETRESET) - X(WSAECONNABORTED) X(WSAECONNRESET) - X(WSAENOBUFS) X(WSAEISCONN) - X(WSAENOTCONN) X(WSAESHUTDOWN) - X(WSAETOOMANYREFS) X(WSAETIMEDOUT) - X(WSAECONNREFUSED) X(WSAELOOP) - X(WSAENAMETOOLONG) X(WSAEHOSTDOWN) - X(WSAEHOSTUNREACH) X(WSAENOTEMPTY) - X(WSAEPROCLIM) X(WSAEUSERS) - X(WSAEDQUOT) X(WSAESTALE) - X(WSAEREMOTE) X(WSASYSNOTREADY) - X(WSAVERNOTSUPPORTED) X(WSANOTINITIALISED) - X(WSAEDISCON) X(WSAENOMORE) - X(WSAECANCELLED) X(WSAEINVALIDPROCTABLE) - X(WSAEINVALIDPROVIDER) X(WSAEPROVIDERFAILEDINIT) - X(WSASYSCALLFAILURE) X(WSASERVICE_NOT_FOUND) - X(WSATYPE_NOT_FOUND) X(WSA_E_NO_MORE) - X(WSA_E_CANCELLED) X(WSAEREFUSED) -#undef X - } - snprintf ( errbuf, sizeof(errbuf), "Unknown socket error (%lu)", err ); - errbuf[sizeof(errbuf)-1] = '\0'; - return errbuf; -#elif defined(UNIX) - perror(errbuf); - return errbuf; -#else -# error unrecognized target -#endif -} -#if defined(UNICODE) || defined(_UNICODE) -in_addr_t suLookupAddress ( const wchar_t* pcHost ) -{ - int len = wcslen(pcHost); - char* p = new char[len+1]; - wcstombs ( p, pcHost, len ); - p[len] = 0; - in_addr_t rc = suLookupAddress ( p ); - delete[] p; - return rc; -} -bool suBroadcast ( SOCKET so, u_short port, const wchar_t* buf, int len /* = -1 */ ) -{ - char* p = new char[len+1]; - wcstombs ( p, buf, len ); - p[len] = 0; - bool rc = suBroadcast ( so, port, p, len ); - delete[] p; - return rc; -} -int suRecv ( SOCKET so, wchar_t* buf, int buflen, int timeout ) -{ - char* p = new char[buflen+1]; - int rc = suRecv ( so, p, buflen, timeout ); - p[buflen] = 0; - mbstowcs ( buf, p, buflen ); - delete[] p; - return rc; -} -int suRecvFrom ( SOCKET so, wchar_t* buf, int buflen, int timeout, sockaddr_in* from, int* fromlen ) -{ - char* p = new char[buflen+1]; - int rc = suRecvFrom ( so, p, buflen, timeout, from, fromlen ); - p[buflen] = 0; - mbs2wcs ( buf, p, buflen ); - delete[] p; - return rc; -} -bool suBind ( SOCKET so, const wchar_t* szInterfaceAddress, u_short iListenPort, bool bReuseAddr /* = false */ ) -{ - int len = wcslen(szInterfaceAddress); - char* p = new char[len+1]; - wcstombs ( p, szInterfaceAddress, len ); - p[len] = 0; - bool rc = suBind ( so, p, iListenPort, bReuseAddr ); - delete[] p; - return rc; -} -#endif//UNICODE - -suBufferedRecvSocket::suBufferedRecvSocket ( SOCKET so ) - : suSocket ( so ), _off(0), _len(0) -{ -} - -int suBufferedRecvSocket::recvUntil ( std::string& buf, char until, int timeout ) -{ - if ( !_len ) - _off = 0; - else if ( _off > (sizeof(_buf)>>1) ) - { - memmove ( _buf, &_buf[_off], _len ); - _off = 0; - } - char* poff = &_buf[_off]; - for ( ;; ) - { - char* p = (char*)memchr ( poff, until, _len ); - if ( p /*&& p < &poff[_len]*/ ) - { - int ret_len = p-poff+1; - buf.resize ( ret_len ); - memmove ( &buf[0], poff, ret_len ); - _off += ret_len; - _len -= ret_len; - return ret_len; - } - int rc = suRecv ( *this, &poff[_len], sizeof(_buf)-_len-_off, timeout ); - if ( rc < 0 ) - { - if ( _len ) - { - rc = _len; - buf.resize ( rc ); - memmove ( &buf[0], &_buf[_off], rc ); - _len = 0; - } - return rc; - } - _len += rc; - } -} - -void suBufferedRecvSocket::recvPending() -{ - if ( !_len ) - _off = 0; - else if ( _off > (sizeof(_buf)>>1) ) - { - memmove ( _buf, &_buf[_off], _len ); - _off = 0; - } - char* poff = &_buf[_off]; - while ( sizeof(_buf)-_len-_off ) - { - int rc = suRecv ( *this, &poff[_len], sizeof(_buf)-_len-_off, 1 ); - if ( rc <= 0 ) - break; - _len += rc; - } -} - -bool suBufferedRecvSocket::recvInStr ( char c ) -{ - return NULL != memchr ( &_buf[_off], c, _len ); -} diff --git a/irc/ArchBlackmann/SockUtils.h b/irc/ArchBlackmann/SockUtils.h deleted file mode 100644 index 60853f05964..00000000000 --- a/irc/ArchBlackmann/SockUtils.h +++ /dev/null @@ -1,132 +0,0 @@ -// SockUtils.h - Declarations for the Winsock utility functions module. -// (C) 2002-2004 Royce Mitchell III -// This file is under the BSD & LGPL licenses - -#ifndef __SOCKUTILS_H -#define __SOCKUTILS_H - -#include -#ifdef WIN32 -# include -# define in_addr_t u_long -# define SUERRNO WSAGetLastError() -# define EADDRINUSE WSAEADDRINUSE -# define ENOTSOCK WSAENOTSOCK -# define socklen_t int -#elif defined(UNIX) -# include -# include -# include -# include -# include -# define closesocket(so) close(so) -# define SOCKET int -# define INVALID_SOCKET -1 -# define SOCKET_ERROR -1 -# define SUERRNO errno -# ifdef MACOSX -# define socklen_t int //Stupid mac -# endif -#else -# error unrecognized target -#endif - -#include - -extern bool suStartup(); -extern SOCKET suTcpSocket(); -extern SOCKET suUdpSocket(); -extern bool suShutdownConnection(SOCKET sd); -extern in_addr_t suLookupAddress ( const char* pcHost ); -extern bool suConnect ( SOCKET so, in_addr_t iAddress, u_short iPort ); -extern bool suConnect ( SOCKET so, const char* szAddress, u_short iPort ); -extern SOCKET suEstablishConnection ( in_addr_t iAddress, u_short iPort, int type ); -extern SOCKET suEstablishConnection ( const char* szAddress, u_short iPort, int type ); -extern bool suBroadcast ( SOCKET so, u_short port, const char* buf, int len = -1 ); -extern int suRecv ( SOCKET so, char* buf, int buflen, int timeout ); -extern int suRecvFrom ( SOCKET so, char* buf, int buflen, int timeout, sockaddr_in* from, socklen_t* fromlen ); -extern bool suBind ( SOCKET so, in_addr_t iInterfaceAddress, u_short iListenPort, bool bReuseAddr = false ); -extern bool suBind ( SOCKET so, const char* szInterfaceAddress, u_short iListenPort, bool bReuseAddr = false ); -extern bool suEnableBroadcast ( SOCKET so, bool bEnable = true ); -extern const char* suErrDesc ( int err ); - -#if defined(UNICODE) || defined(_UNICODE) -extern in_addr_t suLookupAddress ( const wchar_t* pcHost ); -extern bool suBroadcast ( SOCKET so, u_short port, const wchar_t* buf, int len = -1 ); -extern int suRecv ( SOCKET so, wchar_t* buf, int buflen, int timeout ); -extern int suRecvFrom ( SOCKET so, wchar_t* buf, int buflen, int timeout, sockaddr_in* from, int* fromlen ); -extern bool suBind ( SOCKET so, const wchar_t* szInterfaceAddress, u_short iListenPort, bool bReuseAddr = false ); -#endif//UNICODE - -class suSocket -{ - SOCKET _so; -public: - suSocket ( SOCKET so = INVALID_SOCKET ) : _so(so) - { - } - const suSocket& operator = ( SOCKET so ) - { - assert ( _so == INVALID_SOCKET ); // must Detach() or Close() existing socket first - _so = so; - return *this; - } - virtual ~suSocket() - { - Close(); - } - void Close() - { - if ( _so != INVALID_SOCKET ) - { - //suShutdownConnection ( _so ); // TODO - only valid on TCP sockets - closesocket ( _so ); - _so = INVALID_SOCKET; - } - } - operator SOCKET() const - { - return _so; - } - SOCKET Attach ( SOCKET so ) - { - SOCKET old = Detach(); - _so = so; - return old; - } - SOCKET Detach() - { - SOCKET so = _so; - _so = INVALID_SOCKET; - return so; - } - -private: - // disable copy semantics - suSocket ( const suSocket& ); - const suSocket& operator = ( const suSocket& ); -}; - -class suBufferedRecvSocket : public suSocket -{ - char _buf[2048]; - int _off; - int _len; -public: - suBufferedRecvSocket ( SOCKET so = INVALID_SOCKET ); - int recvUntil ( std::string& buf, char until, int timeout ); - void recvPending(); - bool recvInStr ( char c ); -}; - -class SockAddrIn : public sockaddr_in -{ -public: - SockAddrIn(); // creates broadcast address - SockAddrIn ( const char* szAddr, u_short iPort ); - SockAddrIn ( in_addr_t iAddr, u_short iPort ); - operator sockaddr* () { return (sockaddr*)this; } - operator sockaddr_in* () { return (sockaddr_in*)this; } -}; - -#endif//__SOCKUTILS_H diff --git a/irc/ArchBlackmann/SplitJoin.cpp b/irc/ArchBlackmann/SplitJoin.cpp deleted file mode 100644 index f7dd8a4c9d7..00000000000 --- a/irc/ArchBlackmann/SplitJoin.cpp +++ /dev/null @@ -1,96 +0,0 @@ -// SplitJoin.cpp -// -// This code is copyright 2003-2004 Royce Mitchell III -// and released under the BSD & LGPL licenses - -#ifdef _MSC_VER -#pragma warning ( disable : 4786 ) // MSVC6 can't handle too-long template names -#endif//_MSC_VER - -//#include - -#include "SplitJoin.h" - -#include - -using std::string; -using std::vector; -//using std::stringstream; - -static const char* quotes = "\"\'"; - -bool Split ( vector& vec, const char* csv, char sep, bool merge ) -{ - string scsv ( csv ); - char* col = &scsv[0]; - vec.resize ( 0 ); - for ( ;; ) - { - char* p = col; - while ( isspace(*p) && *p != sep ) - p++; - char quote = 0; - if ( strchr ( quotes, *p ) ) - quote = *p++; - while ( *p && (*p != sep || quote) ) - { - if ( *p++ == quote ) - break; - } - - while ( isspace(*p) && *p != sep ) - p++; - - if ( *p && *p != sep ) - return false; - - string scol ( col, p-col ); - - //quote = scol[0]; - if ( quote ) - { - if ( scol[scol.size()-1] == quote ) - scol = string ( &scol[1], scol.size()-2 ); - } - - if ( scol.length() || !merge ) - vec.push_back ( scol ); - - if ( !*p ) - break; - - col = p + 1; - } - return true; -} - -bool Join ( string& csv, vector& vec, char sep ) -{ - csv.resize(0); - for ( int i = 0; i < vec.size(); i++ ) - { - if ( i ) - csv += sep; - string& s = vec[i]; - if ( strchr ( s.c_str(), sep ) ) - { - if ( strchr ( s.c_str(), '\"' ) ) - { - if ( strchr ( s.c_str(), '\'' ) ) - return false; // the sep, " and ' are all in the string, can't build valid output - csv += '\''; - csv += s; - csv += '\''; - } - else - { - csv += '\"'; - csv += s; - csv += '\"'; - } - } - else - csv += s; - } - return true; -} diff --git a/irc/ArchBlackmann/SplitJoin.h b/irc/ArchBlackmann/SplitJoin.h deleted file mode 100644 index 8f1311457f7..00000000000 --- a/irc/ArchBlackmann/SplitJoin.h +++ /dev/null @@ -1,32 +0,0 @@ -// SplitJoin.h -// -// This code is copyright 2003-2004 Royce Mitchell III -// and released under the BSD & LGPL licenses - -#ifndef SPLITJOIN_H -#define SPLITJOIN_H - -#include -#include - -bool Split ( - std::vector& vec, - const char* csv, - char sep=',', - bool merge=false ); - -bool Join ( - std::string& csv, - std::vector& vec, - char sep=',' ); - -inline bool Split ( - std::vector& vec, - const std::string& csv, - char sep=',', - bool merge=false ) -{ - return Split ( vec, csv.c_str(), sep, merge ); -} - -#endif//SPLIT_H diff --git a/irc/ArchBlackmann/ThreadPool.cpp b/irc/ArchBlackmann/ThreadPool.cpp deleted file mode 100644 index c545cd7b91b..00000000000 --- a/irc/ArchBlackmann/ThreadPool.cpp +++ /dev/null @@ -1,240 +0,0 @@ -// ThreadPool.cpp -// This file is (C) 2003-2004 Royce Mitchell III -// and released under the LGPL & BSD licenses - -#include -using std::vector; -#include "ThreadPool.h" -#include "QueueT.h" -#include "auto_vector.h" -#include "verify.h" -#include "ReliMT.h" - -class PoolableThread : public ActiveObject -{ -public: - PoolableThread ( ThreadPoolImpl& ); - ~PoolableThread() - { - Kill(); - } - void InitThread(); - void Run(); - void FlushThread(); - - ThreadPoolImpl& _pool; -}; - -class ThreadPoolLaunchData -{ -public: - ThreadPoolFunc* pFun; - void* pArg; -}; - -template -class AtomicCounter : public Uncopyable -{ - Mutex _m; - T _t; -public: - AtomicCounter ( T init = 0 ) : _t(init) - { - } - AtomicCounter ( const AtomicCounter& t ) - { - //Mutex::Lock l ( _m ); // don't need to lock since this is a ctor - Mutex::Lock l2 ( t._m ); - _t = t._t; - } - const AtomicCounter& operator = ( const AtomicCounter& t ) - { - Mutex::Lock l ( _m ); - Mutex::Lock l2 ( t._m ); - _t = t._t; - return *this; - } - T operator ++ () - { - Mutex::Lock l ( _m ); - T t = _t++; - return t; - } - const AtomicCounter& operator ++ ( int ) - { - Mutex::Lock l ( _m ); - ++_t; - return *this; - } - T operator -- () - { - Mutex::Lock l ( _m ); - T t = _t--; - return t; - } - const AtomicCounter& operator -- ( int ) - { - Mutex::Lock l ( _m ); - --_t; - return *this; - } - const AtomicCounter& operator += ( T t ) - { - Mutex::Lock l ( _m ); - return _t += t; - return *this; - } - const AtomicCounter& operator -= ( T t ) - { - Mutex::Lock l ( _m ); - return _t -= t; - return *this; - } - operator const T& () const - { - //Mutex::Lock l ( _m ); - return _t; - } - T operator !() const - { - //Mutex::Lock l ( _m ); - return !_t; - } -}; - -class ThreadPoolImpl : public Uncopyable -{ -public: - ThreadPoolImpl() : _isDying(false), _idleThreads(0) - { - } - - ~ThreadPoolImpl() - { - } - - void Shutdown() - { - _isDying = true; - while ( _idleThreads ) - { - _threadWaitEvent.Release(); - _threadStartEvent.Wait(); // let thread actually get a grip - } - } - - void Launch ( ThreadPoolFunc* pFun, void* pArg ) - { - // this mutex is necessary to make sure we never have a conflict - // between checking !_idleThreads and the call to _threadStartEvent.Wait() - // basically if 2 threads call Launch() simultaneously, and there is only - // 1 idle thread, it's possible that a new thread won't be created to - // satisfy the 2nd request until an existing thread finishes. - Mutex::Lock launchlock ( _launchMutex ); - - ASSERT ( pFun ); - ThreadPoolLaunchData* data; - { - Mutex::Lock lock ( _vectorMutex ); - if ( !_spareData.size() ) - _spareData.push_back ( new ThreadPoolLaunchData() ); - data = _spareData.pop_back().release(); - if ( !_idleThreads ) - _threads.push_back ( new PoolableThread(*this) ); - } - - data->pFun = pFun; - data->pArg = pArg; - verify ( _pendingData.Add ( data ) ); - _threadWaitEvent.Release(); // tell a thread to do it's thing... - _threadStartEvent.Wait(); // wait on a thread to pick up the request - } - - // functions for threads to call... - ThreadPoolLaunchData* GetPendingData() - { - ThreadPoolLaunchData* data = NULL; - ++_idleThreads; - _threadWaitEvent.Wait(); // waits until there's a request - --_idleThreads; - _threadStartEvent.Release(); // tell requester we got it - if ( _isDying ) - return NULL; - _pendingData.Get ( data ); - ASSERT ( data ); - return data; - } - - void RecycleData ( ThreadPoolLaunchData* data ) - { - Mutex::Lock lock ( _vectorMutex ); - _spareData.push_back ( data ); - } - - bool _isDying; - Mutex _vectorMutex, _launchMutex; - auto_vector _threads; - auto_vector _spareData; - CQueueT _pendingData; - Event _threadWaitEvent, _threadStartEvent; - AtomicCounter _idleThreads; -}; - -/////////////////////////////////////////////////////////////////////////////// -// ThreadPool - -/*static*/ ThreadPool& ThreadPool::Instance() -{ - static ThreadPool tp; - return tp; -} - -ThreadPool::ThreadPool() : _pimpl ( new ThreadPoolImpl ) -{ -}; - -ThreadPool::~ThreadPool() -{ - _pimpl->Shutdown(); - delete _pimpl; - _pimpl = 0; -} - -void ThreadPool::Launch ( ThreadPoolFunc* pFun, void* pArg ) -{ - _pimpl->Launch ( pFun, pArg ); -} - -int ThreadPool::IdleThreads() -{ - return _pimpl->_idleThreads; -} - -/////////////////////////////////////////////////////////////////////////////// -// PoolableThread - -PoolableThread::PoolableThread ( ThreadPoolImpl& pool ) : _pool(pool) -{ - Start(); -} - -void PoolableThread::InitThread() -{ -} - -void PoolableThread::Run() -{ - ThreadPoolLaunchData* data; - while ( !_isDying ) - { - data = _pool.GetPendingData(); // enter wait state if none... - if ( !data ) // NULL data means kill thread - break; - (*data->pFun) ( data->pArg ); // call the function - _pool.RecycleData ( data ); - } -} - -void PoolableThread::FlushThread() -{ -} diff --git a/irc/ArchBlackmann/ThreadPool.h b/irc/ArchBlackmann/ThreadPool.h deleted file mode 100644 index 84e36f3993c..00000000000 --- a/irc/ArchBlackmann/ThreadPool.h +++ /dev/null @@ -1,28 +0,0 @@ -// ThreadPool.h -// This file is (C) 2003-2004 Royce Mitchell III -// and released under the LGPL & BSD licenses - -#ifndef THREADPOOL_H -#define THREADPOOL_H - -#include "ReliMT.h" - -typedef void THREADAPI ThreadPoolFunc ( void* ); - -class ThreadPoolImpl; - -class ThreadPool : public Uncopyable -{ -public: - static ThreadPool& Instance(); - ~ThreadPool(); - - void Launch ( ThreadPoolFunc* pFun, void* pArg ); - int IdleThreads(); - -private: - ThreadPool(); - ThreadPoolImpl *_pimpl; -}; - -#endif// THREADPOOL_H diff --git a/irc/ArchBlackmann/auto_ptr.h b/irc/ArchBlackmann/auto_ptr.h deleted file mode 100644 index 861501eb8e7..00000000000 --- a/irc/ArchBlackmann/auto_ptr.h +++ /dev/null @@ -1,87 +0,0 @@ -// auto_ptr.h -// This file is (C) 2002-2003 Royce Mitchell III -// and released under the LGPL & BSD licenses - -#ifndef AUTO_PTR_H -#define AUTO_PTR_H - -template -class auto_ptr -{ -public: - typedef T element_type; - - explicit auto_ptr(T *p = 0) : _p(p) - { - } - - auto_ptr(auto_ptr& rhs) : _p(rhs.release()) - { - } - - auto_ptr& operator=(auto_ptr& rhs) - { - if ( &rhs != this ) - { - dispose(); - _p = rhs.release(); - } - return *this; - } - - auto_ptr& set ( auto_ptr& rhs ) - { - if ( &rhs != this ) - { - dispose(); - _p = rhs.release(); - } - return *this; - } - - ~auto_ptr() - { - dispose(); - } - - void dispose() - { - if ( _p ) - { - delete _p; - _p = 0; - } - } - - T& operator[] ( int i ) - { - return _p[i]; - } - - T& operator*() const - { - return *_p; - } - - T* operator->() const - { - return _p; - } - - T* get() const - { - return _p; - } - - T* release() - { - T* p = _p; - _p = 0; - return p; - } - -private: - T* _p; -}; - -#endif//AUTO_PTR_H diff --git a/irc/ArchBlackmann/auto_vector.h b/irc/ArchBlackmann/auto_vector.h deleted file mode 100644 index 730c6302af8..00000000000 --- a/irc/ArchBlackmann/auto_vector.h +++ /dev/null @@ -1,141 +0,0 @@ -// auto_vector.h -// This file is (C) 2002-2004 Royce Mitchell III -// and released under the LGPL & BSD licenses - -#ifndef AUTO_VECTOR_H -#define AUTO_VECTOR_H - -#include -#include "verify.h" -#include "auto_ptr.h" - -template -class auto_vector -{ -public: - explicit auto_vector ( size_t capacity = 0 ) - : _arr(0), _capacity(0), _end(0) - { - if ( capacity != 0 ) - _arr = new auto_ptr[capacity]; - _capacity = capacity; - } - - ~auto_vector() - { - delete []_arr; - } - - size_t size() const - { - return _end; - } - - const auto_ptr& operator [] ( size_t i ) const - { - ASSERT ( i < _end ); - return _arr[i]; - } - - auto_ptr& operator [] ( size_t i ) - { - ASSERT ( i < _end ); - return _arr[i]; - } - - void assign ( size_t i, auto_ptr& p ) - { - ASSERT ( i < _end ); - _arr[i] = p; - } - - void assign_direct ( size_t i, T * p ) - { - ASSERT ( i < _end ); - reserve ( i + 1 ); - _arr[i].reset ( p ); - } - - void push_back ( auto_ptr& p ) - { - reserve ( _end + 1 ); - _arr[_end++] = p; - } - - auto_ptr& back() - { - ASSERT ( _end != 0 ); - return _arr[_end-1]; - } - - void push_back ( T * p ) - { - reserve ( _end + 1 ); - auto_ptr tmp(p); - _arr[_end++] = tmp; - //GCC is pedantic, this is an error. - //_arr[_end++] = auto_ptr(p); - } - - auto_ptr pop_back() - { - ASSERT ( _end != 0 ); - if ( !_end ) - { - auto_ptr tmp((T*)0); - return tmp; - //GCC, this is an error. - //return auto_ptr(NULL); - } - return _arr[--_end]; - } - - void resize ( size_t newSize ) - { - ASSERT ( newSize >= 0 ); - reserve ( newSize ); // make sure we have at least this much room - _end = newSize; - } - - void reserve ( size_t reqCapacity ) - { - if ( reqCapacity <= _capacity ) - return; - size_t newCapacity = 2 * _capacity; - if ( reqCapacity > newCapacity ) - newCapacity = reqCapacity; - // allocate new array - auto_ptr * arrNew = new auto_ptr [newCapacity]; - // transfer all entries - for ( size_t i = 0; i < _capacity; ++i ) - arrNew[i] = _arr[i]; - _capacity = newCapacity; - // free old memory - delete[] _arr; - // substitute new array for old array - _arr = arrNew; - } - - void remove ( size_t off ) - { - size_t last = _end-1; - if ( off == last ) - resize ( last ); - else if ( off < last ) - { - auto_ptr tmp ( pop_back().release() ); - _arr[off] = tmp; - } - } - - //typedef const_auto_iterator const_iterator; - //const_iterator begin () const { return _arr; } - //const_iterator end () const { return _arr + _end; } - -private: - auto_ptr *_arr; - size_t _capacity; - size_t _end; -}; - -#endif//AUTO_VECTOR_H diff --git a/irc/ArchBlackmann/base64.cpp b/irc/ArchBlackmann/base64.cpp deleted file mode 100644 index 6fdc8528698..00000000000 --- a/irc/ArchBlackmann/base64.cpp +++ /dev/null @@ -1,58 +0,0 @@ -// base64.cpp - -#include "base64.h" - -using std::string; - -static const char* alfabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; - -string base64_encode ( const string& sInput ) -{ - unsigned char x=0, topbit=0; - int v=0; - string sOutput; - do - { - if ( topbit < 6 ) - { - x++; - v <<= 8; - if ( x <= sInput.length() ) v += sInput[x-1]; - topbit += 8; - } - topbit -= 6; - if ( x > sInput.length() && !v ) - break; - sOutput += alfabet[(v >> topbit) & 63]; - v &= (1 << topbit) - 1; - } while ( x < sInput.length() || v ); - int eq = (8 - (sOutput.length() % 4)) % 4; - while ( eq-- ) - sOutput += '='; - return sOutput; -} - -string base64_decode ( const string& sInput ) -{ - unsigned char x=0, topbit=0; - int v=0, inlen = sInput.length(); - string sOutput; - while ( inlen && sInput[inlen-1] == '=' ) - inlen--; - do - { - while ( topbit < 8 ) - { - x++; - v <<= 6; - if ( x <= inlen ) v += (strchr(alfabet, sInput[x-1]) - alfabet); - topbit += 6; - } - topbit -= 8; - if ( x > inlen && !v ) - break; - sOutput += (char)((v >> topbit) & 255); - v &= ((1 << topbit) - 1); - } while ( x <= inlen || v ); - return sOutput; -} diff --git a/irc/ArchBlackmann/base64.h b/irc/ArchBlackmann/base64.h deleted file mode 100644 index e307b7aeaca..00000000000 --- a/irc/ArchBlackmann/base64.h +++ /dev/null @@ -1,12 +0,0 @@ -// base64.h - -#ifndef BASE64_H -#define BASE64_H - -#include - -std::string base64_encode ( const std::string& s ); - -std::string base64_decode ( const std::string& s ); - -#endif//BASE64_H diff --git a/irc/ArchBlackmann/chomp.cpp b/irc/ArchBlackmann/chomp.cpp deleted file mode 100644 index 5a3a2080018..00000000000 --- a/irc/ArchBlackmann/chomp.cpp +++ /dev/null @@ -1,15 +0,0 @@ -// chomp.cpp -// This file is (C) 2004 Royce Mitchell III -// and released under the BSD & LGPL licenses - -#include "chomp.h" - -std::string chomp ( const std::string& s ) -{ - const char* p = &s[0]; - const char* p2 = &s[0] + s.size(); - while ( p2 > p && strchr("\r\n", p2[-1]) ) - p2--; - return std::string ( p, p2-p ); -} - diff --git a/irc/ArchBlackmann/chomp.h b/irc/ArchBlackmann/chomp.h deleted file mode 100644 index 80bd8dce071..00000000000 --- a/irc/ArchBlackmann/chomp.h +++ /dev/null @@ -1,13 +0,0 @@ -// chomp.h -// This file is (C) 2004 Royce Mitchell III -// and released under the BSD & LGPL licenses - -#ifndef CHOMP_H -#define CHOMP_H - -#include - -std::string chomp ( const std::string& s ); - -#endif//TRIM_H - diff --git a/irc/ArchBlackmann/config.h b/irc/ArchBlackmann/config.h deleted file mode 100644 index fab1e9c841c..00000000000 --- a/irc/ArchBlackmann/config.h +++ /dev/null @@ -1,7 +0,0 @@ - - -#define SERVER "irc.freenode.net" -#define BOTNAME "ArchBlackmann" -#define CHANNEL "#ReactOS" -#define MODE "+i" -#define PASS "ilovebunnies" diff --git a/irc/ArchBlackmann/cram_md5.cpp b/irc/ArchBlackmann/cram_md5.cpp deleted file mode 100644 index d4c37cf49aa..00000000000 --- a/irc/ArchBlackmann/cram_md5.cpp +++ /dev/null @@ -1,23 +0,0 @@ -// cram_md5.cpp -// This file is (C) 2004 Royce Mitchell III -// and released under the BSD & LGPL licenses - -#include "MD5.h" -#include "cram_md5.h" -#include "base64.h" - -using std::string; - -string cram_md5 ( const string& username, const string& password, const string& greeting ) -{ - string challenge = base64_decode ( greeting ); - - string hmac = HMAC_MD5 ( password, challenge ); - //printf ( "(cram_md5): hmac = %s\n", hmac.c_str() ); - string raw_response = username; - raw_response += " "; - raw_response += hmac; - //printf ( "(cram_md5): raw_response = %s\n", raw_response.c_str() ); - - return base64_encode ( raw_response ); -} diff --git a/irc/ArchBlackmann/cram_md5.h b/irc/ArchBlackmann/cram_md5.h deleted file mode 100644 index c0741b8efde..00000000000 --- a/irc/ArchBlackmann/cram_md5.h +++ /dev/null @@ -1,15 +0,0 @@ -// cram_md5.h -// This file is (C) 2004 Royce Mitchell III -// and released under the BSD & LGPL licenses - -#ifndef CRAM_MD5_H -#define CRAM_MD5_H - -#include - -std::string cram_md5 ( - const std::string& username, - const std::string& password, - const std::string& greeting ); - -#endif//CRAM_MD5_H diff --git a/irc/ArchBlackmann/curse.txt b/irc/ArchBlackmann/curse.txt deleted file mode 100644 index ddec893b813..00000000000 --- a/irc/ArchBlackmann/curse.txt +++ /dev/null @@ -1 +0,0 @@ -semprini \ No newline at end of file diff --git a/irc/ArchBlackmann/cursecop.txt b/irc/ArchBlackmann/cursecop.txt deleted file mode 100644 index 6144752de03..00000000000 --- a/irc/ArchBlackmann/cursecop.txt +++ /dev/null @@ -1,10 +0,0 @@ -You should have your mouth washed out with soap! -This is a clean channel... please watch your language -Please try to keep it clean -Hey, there's children present ( I'm not even a year old yet! ) -Could you find a less-offensive way to express yourself, please? -Such language :( -Those aren't nice words to use -Oh, my poor innocent ears :( -Help! My mind is being corrupted! -filthy mouths are not appreciated here diff --git a/irc/ArchBlackmann/dev.txt b/irc/ArchBlackmann/dev.txt deleted file mode 100644 index 5415e0a3e6c..00000000000 --- a/irc/ArchBlackmann/dev.txt +++ /dev/null @@ -1,15 +0,0 @@ -Royce3 -kjk_hyperion -tamlin -GvG -filip2307 -hardon -w3seek -arty -sedwards -Exception -blight_ -jimtabor -mtempel -Gge -Alex_Ionescu diff --git a/irc/ArchBlackmann/func.txt b/irc/ArchBlackmann/func.txt deleted file mode 100644 index 7173404eac1..00000000000 --- a/irc/ArchBlackmann/func.txt +++ /dev/null @@ -1,580 +0,0 @@ -CcCanIWrite -CcCopyRead -CcCopyWrite -CcDeferWrite -CcFastCopyRead -CcFastCopyWrite -CcFlushCache -CcGetDirtyPages -CcGetFileObjectFromBcb -CcGetFileObjectFromSectionPtrs -CcGetFlushedValidData -CcGetLsnForFileObject -CcInitializeCacheMap -CcIsThereDirtyData -CcMapData -CcMdlRead -CcMdlReadComplete -CcMdlWriteAbort -CcMdlWriteComplete -CcPinMappedData -CcPinRead -CcPrepareMdlWrite -CcPreparePinWrite -CcPurgeCacheSection -CcRemapBcb -CcRepinBcb -CcScheduleReadAhead -CcSetAdditionalCacheAttributes -CcSetBcbOwnerPointer -CcSetDirtyPageThreshold -CcSetDirtyPinnedData -CcSetFileSizes -CcSetLogHandleForFile -CcSetReadAheadGranularity -CcUninitializeCacheMap -CcUnpinData -CcUnpinDataForThread -CcUnpinRepinnedBcb -CcWaitForCurrentLazyWriterActivity -CcZeroData -DbgLoadImageSymbols -DbgQueryDebugFilterState -DbgSetDebugFilterState -EVENT_TYPE -ExAcquireResourceExclusive -ExAcquireResourceExclusiveLite -ExAcquireResourceSharedLite -ExAcquireSharedStarveExclusive -ExAcquireSharedWaitForExclusive -ExAllocateFromZone -ExAllocatePool -ExAllocatePoolWithQuota -ExAllocatePoolWithQuotaTag -ExAllocatePoolWithTag -ExConvertExclusiveToSharedLite -ExCreateCallback -ExDeleteNPagedLookasideList -ExDeletePagedLookasideList -ExDeleteResource -ExDeleteResourceLite -ExDisableResourceBoostLite -ExEnumHandleTable -ExExtendZone -ExFreePool -ExGetCurrentProcessorCounts -ExGetCurrentProcessorCpuUsage -ExGetExclusiveWaiterCount -ExGetPreviousMode -ExGetSharedWaiterCount -ExInitializeNPagedLookasideList -ExInitializePagedLookasideList -ExInitializeResource -ExInitializeResourceLite -ExInitializeZone -ExInterlockedAddLargeInteger -ExInterlockedAddUlong -ExInterlockedDecrementLong -ExInterlockedExchangeUlong -ExInterlockedExtendZone -ExInterlockedIncrementLong -ExInterlockedInsertHeadList -ExInterlockedInsertTailList -ExInterlockedPopEntryList -ExInterlockedPushEntryList -ExInterlockedRemoveHeadList -ExIsProcessorFeaturePresent -ExIsResourceAcquiredExclusiveLite -ExIsResourceAcquiredSharedLite -ExLocalTimeToSystemTime -ExNotifyCallback -ExPostSystemEvent -ExQueryPoolBlockSize -ExQueueWorkItem -ExRaiseAccessViolation -ExRaiseDatatypeMisalignment -ExRaiseException -ExRaiseHardError -ExRaiseStatus -ExRegisterCallback -ExReinitializeResourceLite -ExReleaseResource -ExReleaseResourceForThread -ExReleaseResourceForThreadLite -ExRosDumpPagedPoolByTag -ExRosQueryPoolTag -ExSetResourceOwnerPointer -ExSetTimerResolution -ExSystemExceptionFilter -ExSystemTimeToLocalTime -ExTryToAcquireResourceExclusiveLite -ExUnregisterCallback -ExUuidCreate -ExVerifySuite -FsRtlAcquireFileExclusive -FsRtlAddMcbEntry -FsRtlAddToTunnelCache -FsRtlAllocateFileLock -FsRtlAllocatePool -FsRtlAllocatePoolWithQuota -FsRtlAllocatePoolWithQuotaTag -FsRtlAllocatePoolWithTag -FsRtlAllocateResource -FsRtlAreNamesEqual -FsRtlBalanceReads -FsRtlCheckLockForReadAccess -FsRtlCheckLockForWriteAccess -FsRtlCopyRead -FsRtlCopyWrite -FsRtlFastCheckLockForRead -FsRtlFastCheckLockForWrite -FsRtlFastUnlockAll -FsRtlFastUnlockAllByKey -FsRtlFastUnlockSingle -FsRtlFindInTunnelCache -FsRtlFreeFileLock -FsRtlGetFileSize -FsRtlGetNextFileLock -FsRtlGetNextMcbEntry -FsRtlIncrementCcFastReadNoWait -FsRtlIncrementCcFastReadNotPossible -FsRtlIncrementCcFastReadResourceMiss -FsRtlIncrementCcFastReadWait -FsRtlInitializeFileLock -FsRtlInitializeMcb -FsRtlInitializeTunnelCache -FsRtlInsertPerFileObjectContext -FsRtlInsertPerStreamContext -FsRtlIsDbcsInExpression -FsRtlIsFatDbcsLegal -FsRtlIsHpfsDbcsLegal -FsRtlIsNameInExpression -FsRtlLookupLastLargeMcbEntryAndIndex -FsRtlLookupLastMcbEntry -FsRtlLookupMcbEntry -FsRtlLookupPerFileObjectContext -FsRtlLookupPerStreamContextInternal -FsRtlMdlRead -FsRtlMdlReadComplete -FsRtlMdlReadCompleteDev -FsRtlMdlReadDev -FsRtlMdlWriteComplete -FsRtlMdlWriteCompleteDev -FsRtlNotifyChangeDirectory -FsRtlNotifyCleanup -FsRtlNotifyFilterChangeDirectory -FsRtlNotifyFilterReportChange -FsRtlNotifyFullChangeDirectory -FsRtlNotifyFullReportChange -FsRtlNotifyReportChange -FsRtlNotifyUninitializeSync -FsRtlNumberOfRunsInMcb -FsRtlPostPagingFileStackOverflow -FsRtlPostStackOverflow -FsRtlPrepareMdlWrite -FsRtlPrepareMdlWriteDev -FsRtlPrivateLock -FsRtlProcessFileLock -FsRtlRegisterFileSystemFilterCallbacks -FsRtlReleaseFile -FsRtlRemoveMcbEntry -FsRtlRemovePerFileObjectContext -FsRtlRemovePerStreamContext -FsRtlResetLargeMcb -FsRtlSyncVolumes -FsRtlTeardownPerStreamContexts -FsRtlTruncateMcb -FsRtlUninitializeFileLock -FsRtlUninitializeMcb -HalAdjustResourceList -HalAllocateCommonBuffer -HalAssignSlotResources -HalCalibratePerformanceCounter -HalFlushCommonBuffer -HalFreeCommonBuffer -HalGetAdapter -HalGetBusData -HalGetBusDataByOffset -HalGetDmaAlignmentRequirement -HalMakeBeep -HalQueryDisplayParameters -HalQueryRealTimeClock -HalReadDmaCounter -HalRequestIpi -HalSetBusData -HalSetBusDataByOffset -HalSetDisplayParameters -HalSetRealTimeClock -HalStartNextProcessor -IoAcquireCancelSpinLock -IoAcquireRemoveLockEx -IoAcquireVpbSpinLock -IoAllocateAdapterChannel -IoAllocateController -IoAllocateDriverObjectExtension -IoAllocateErrorLogEntry -IoAllocateIrp -IoAllocateMdl -IoAllocateWorkItem -IoAssignResources -IoAttachDevice -IoAttachDeviceByPointer -IoAttachDeviceToDeviceStack -IoAttachDeviceToDeviceStackSafe -IoBuildAsynchronousFsdRequest -IoBuildDeviceIoControlRequest -IoBuildPartialMdl -IoBuildSynchronousFsdRequest -IoCallDriver -IoCancelFileOpen -IoCancelIrp -IoCheckQuerySetFileInformation -IoCheckQuerySetVolumeInformation -IoCheckQuotaBufferValidity -IoCheckShareAccess -IoCompleteRequest -IoConnectInterrupt -IoCreateController -IoCreateDevice -IoCreateDisk -IoCreateDriver -IoCreateFile -IoCreateFileSpecifyDeviceObjectHint -IoCreateNotificationEvent -IoCreateStreamFileObject -IoCreateStreamFileObjectEx -IoCreateStreamFileObjectLite -IoCreateSymbolicLink -IoCreateSynchronizationEvent -IoCreateUnprotectedSymbolicLink -IoDeleteController -IoDeleteDevice -IoDeleteDriver -IoDeleteSymbolicLink -IoDetachDevice -IoDisconnectInterrupt -IoEnqueueIrp -IoEnumerateDeviceObjectList -IoFlushAdapterBuffers -IoForwardIrpSynchronously -IoFreeAdapterChannel -IoFreeController -IoFreeErrorLogEntry -IoFreeIrp -IoFreeMapRegisters -IoFreeMdl -IoFreeWorkItem -IoGetAttachedDevice -IoGetAttachedDeviceReference -IoGetBaseFileSystemDeviceObject -IoGetBootDiskInformation -IoGetConfigurationInformation -IoGetCurrentProcess -IoGetDeviceAttachmentBaseRef -IoGetDeviceInterfaceAlias -IoGetDeviceInterfaces -IoGetDeviceObjectPointer -IoGetDeviceProperty -IoGetDeviceToVerify -IoGetDiskDeviceObject -IoGetDriverObjectExtension -IoGetFileObjectGenericMapping -IoGetInitialStack -IoGetLowerDeviceObject -IoGetRelatedDeviceObject -IoGetRequestorProcess -IoGetRequestorProcessId -IoGetRequestorSessionId -IoGetStackLimits -IoGetTopLevelIrp -IoInitializeIrp -IoInitializeRemoveLockEx -IoInitializeTimer -IoInvalidateDeviceRelations -IoInvalidateDeviceState -IoIsFileOriginRemote -IoIsOperationSynchronous -IoIsSystemThread -IoIsValidNameGraftingBuffer -IoMakeAssociatedIrp -IoMapTransfer -IoOpenDeviceInstanceKey -IoOpenDeviceInterfaceRegistryKey -IoOpenDeviceRegistryKey -IoPageRead -IoPnPDeliverServicePowerNotification -IoQueryDeviceDescription -IoQueryDeviceEnumInfo -IoQueryFileDosDeviceName -IoQueryFileInformation -IoQueryVolumeInformation -IoQueueThreadIrp -IoQueueWorkItem -IoRaiseHardError -IoRaiseInformationalHardError -IoReadDiskSignature -IoReadPartitionTableEx -IoRegisterBootDriverReinitialization -IoRegisterDeviceInterface -IoRegisterDriverReinitialization -IoRegisterFileSystem -IoRegisterFsRegistrationChange -IoRegisterLastChanceShutdownNotification -IoRegisterPlugPlayNotification -IoRegisterShutdownNotification -IoReleaseCancelSpinLock -IoReleaseRemoveLockAndWaitEx -IoReleaseRemoveLockEx -IoReleaseVpbSpinLock -IoRemoveShareAccess -IoReportDetectedDevice -IoReportHalResourceUsage -IoReportResourceForDetection -IoReportResourceUsage -IoReportTargetDeviceChange -IoReportTargetDeviceChangeAsynchronous -IoRequestDeviceEject -IoReuseIrp -IoSetCompletionRoutineEx -IoSetDeviceInterfaceState -IoSetDeviceToVerify -IoSetFileOrigin -IoSetHardErrorOrVerifyDevice -IoSetInformation -IoSetIoCompletion -IoSetPartitionInformationEx -IoSetShareAccess -IoSetStartIoAttributes -IoSetSystemPartition -IoSetThreadHardErrorMode -IoSetTopLevelIrp -IoStartNextPacket -IoStartNextPacketByKey -IoStartPacket -IoStartTimer -IoStopTimer -IoSynchronousInvalidateDeviceRelations -IoSynchronousPageWrite -IoUnregisterFileSystem -IoUnregisterFsRegistrationChange -IoUnregisterPlugPlayNotification -IoUnregisterShutdownNotification -IoUpdateShareAccess -IoValidateDeviceIoControlAccess -IoVerifyPartitionTable -IoVerifyVolume -IoVolumeDeviceToDosName -IoWMIAllocateInstanceIds -IoWMIDeviceObjectToInstanceName -IoWMIExecuteMethod -IoWMIHandleToInstanceName -IoWMIOpenBlock -IoWMIQueryAllData -IoWMIQueryAllDataMultiple -IoWMIQuerySingleInstance -IoWMIQuerySingleInstanceMultiple -IoWMIRegistrationControl -IoWMISetNotificationCallback -IoWMISetSingleInstance -IoWMISetSingleItem -IoWMISuggestInstanceName -IoWMIWriteEvent -IoWriteErrorLogEntry -IoWritePartitionTableEx -KPRIORITY -KdPortGetByte -KdPortPollByte -KdPortPutByte -Ke386QueryIoAccessMap -Ke386SetIoAccessMap -KeAcquireInterruptSpinLock -KeAreApcsDisabled -KeCapturePersistentThreadState -KeDeregisterBugCheckReasonCallback -KeFindConfigurationEntry -KeFindConfigurationNextEntry -KeFlushEntireTb -KeFlushQueuedDpcs -KeGetRecommendedSharedDataAlignment -KeIsExecutingDpc -KeQueryActiveProcessors -KeQueryPerformanceCounter -KeQueryPriorityThread -KeQueryRuntimeThread -KeQuerySystemTime -KeQueryTickCount -KeQueryTimeIncrement -KeRaiseIrql -KeRaiseIrqlToDpcLevel -KeRaiseUserException -KeReadStateEvent -KeRegisterBugCheckCallback -KeRegisterBugCheckReasonCallback -KeReleaseInterruptSpinLock -KeReleaseMutant -KeReleaseMutex -KeReleaseSemaphore -KeReleaseSpinLock -KeReleaseSpinLockFromDpcLevel -KeReleaseSpinLockFromDpcLevel -KeRemoveByKeyDeviceQueue -KeRemoveByKeyDeviceQueueIfBusy -KeRemoveDeviceQueue -KeRemoveEntryDeviceQueue -KeRemoveSystemServiceTable -KeRestoreFloatingPointState -KeRevertToUserAffinityThread -KeRosDumpStackFrames -KeRosGetStackFrames -KeRosPrintAddress -KeSaveFloatingPointState -KeSetDmaIoCoherency -KeSetEvent -KeSetEventBoostPriority -KeSetIdealProcessorThread -KeSetKernelStackSwapEnable -KeSetProfileIrql -KeSetSystemAffinityThread -KeSetTimeIncrement -KeTerminateThread -KeUserModeCallback -KeWaitForMutexObject -KeWaitForSingleObject -KiCoprocessorError -KiUnexpectedInterrupt -LONG -LdrFindResourceDirectory_U -MmAddPhysicalMemory -MmAddVerifierThunks -MmAdjustWorkingSetSize -MmAdvanceMdl -MmAllocateContiguousMemory -MmAllocateContiguousMemorySpecifyCache -MmAllocateMappingAddress -MmAllocateNonCachedMemory -MmBuildMdlForNonPagedPool -MmCanFileBeTruncated -MmCreateMdl -MmCreateSection -MmDbgTranslatePhysicalAddress -MmDisableModifiedWriteOfSection -MmFlushImageSection -MmForceSectionClosed -MmFreeContiguousMemory -MmFreeMappingAddress -MmFreeNonCachedMemory -MmGetPhysicalAddress -MmGetPhysicalMemoryRanges -MmGetSystemRoutineAddress -MmGetVirtualForPhysical -MmGrowKernelStack -MmIsAddressValid -MmIsDriverVerifying -MmIsNonPagedSystemAddressValid -MmIsRecursiveIoFault -MmIsThisAnNtAsSystem -MmIsVerifierEnabled -MmLockPagableDataSection -MmLockPagableImageSection -MmLockPagableSectionByHandle -MmMapIoSpace -MmMapLockedPages -MmMapLockedPagesWithReservedMapping -MmMapMemoryDumpMdl -MmMapUserAddressesToPage -MmMapVideoDisplay -MmMapViewInSessionSpace -MmMapViewInSystemSpace -MmMapViewOfSection -MmMarkPhysicalMemoryAsBad -MmMarkPhysicalMemoryAsGood -MmPageEntireDriver -MmPrefetchPages -MmProbeAndLockPages -MmProbeAndLockProcessPages -MmProbeAndLockSelectedPages -MmProtectMdlSystemAddress -MmQuerySystemSize -MmRemovePhysicalMemory -MmResetDriverPaging -MmSecureVirtualMemory -MmSetAddressRangeModified -MmSetBankedSection -MmSizeOfMdl -MmTrimAllSystemPagableMemory -MmUnlockPagableImageSection -MmUnlockPages -MmUnmapIoSpace -MmUnmapLockedPages -MmUnmapReservedMapping -MmUnmapVideoDisplay -MmUnmapViewInSessionSpace -MmUnmapViewInSystemSpace -MmUnmapViewOfSection -MmUnsecureVirtualMemory -OUT -ObCreateObject -PEJOB -PEPROCESS -PKBUGCHECK_CALLBACK_RECORD -PKDEVICE_QUEUE_ENTRY -PKIRQL -PULONG -PVOID -PW32_THREAD_CALLBACK -PoCallDriver -PoRegisterDeviceForIdleDetection -PoRegisterSystemState -PoRequestPowerIrp -PoSetDeviceBusy -PoSetPowerState -PoSetSystemState -PoStartNextPowerIrp -PoUnregisterSystemState -ProbeForRead -ProbeForWrite -PsAssignImpersonationToken -PsCreateSystemProcess -PsCreateSystemThread -PsGetCurrentProcessId -PsGetCurrentThreadId -PsImpersonateClient -PsReferenceImpersonationToken -PsReferencePrimaryToken -PsRevertThreadToSelf -PsRevertToSelf -PsTerminateSystemThread -READ_PORT_BUFFER_UCHAR -READ_PORT_BUFFER_ULONG -READ_PORT_BUFFER_USHORT -READ_PORT_UCHAR -READ_PORT_ULONG -READ_PORT_USHORT -SeAssignSecurityEx -SeAuditHardLinkCreation -SeAuditingFileEvents -SeAuditingFileEventsWithContext -SeAuditingFileOrGlobalEvents -SeAuditingHardLinkEvents -SeAuditingHardLinkEventsWithContext -SeCaptureSecurityDescriptor -SeCaptureSubjectContext -SeCloseObjectAuditAlarm -SeCreateAccessState -SeCreateClientSecurityFromSubjectContext -SeFilterToken -SeImpersonateClientEx -SePrivilegeObjectAuditAlarm -SeQueryInformationToken -SeQuerySessionIdToken -SeReleaseSecurityDescriptor -SeSetSecurityDescriptorInfoEx -SeTokenIsAdmin -SeTokenIsRestricted -SeTokenIsWriteRestricted -WRITE_PORT_BUFFER_UCHAR -WRITE_PORT_BUFFER_ULONG -WRITE_PORT_BUFFER_USHORT -WRITE_PORT_UCHAR -WRITE_PORT_ULONG -WRITE_PORT_USHORT diff --git a/irc/ArchBlackmann/grovel.txt b/irc/ArchBlackmann/grovel.txt deleted file mode 100644 index 21137b50e13..00000000000 --- a/irc/ArchBlackmann/grovel.txt +++ /dev/null @@ -1,10 +0,0 @@ -/me bows humbly and begs %s's forgiveness -%s is soo cool... I hope to be like him some day -/me hides in a corner and hopes %s doesn't beat him with the whipping noodle again -/me prostrates at %s's feet and begs his majesty's forgiveness -%s: please don't hurt me! -I'm not worthy... I'm not worthy... -/me sings %s's praises to the world! -/me thinks %s is smarter than %dev% -%s: oh please may I defrag your sock drawer? -/me gives %s a cookie, hoping it will make up for breaking %func% the other day... diff --git a/irc/ArchBlackmann/idle.txt b/irc/ArchBlackmann/idle.txt deleted file mode 100644 index d3bf9c4dec5..00000000000 --- a/irc/ArchBlackmann/idle.txt +++ /dev/null @@ -1 +0,0 @@ -/me is bored diff --git a/irc/ArchBlackmann/irql.txt b/irc/ArchBlackmann/irql.txt deleted file mode 100644 index f585ced2ad1..00000000000 --- a/irc/ArchBlackmann/irql.txt +++ /dev/null @@ -1,9 +0,0 @@ -PASSIVE_LEVEL -APC_LEVEL -DISPATCH_LEVEL -PROFILE_LEVEL -CLOCK1_LEVEL -IPI_LEVEL -POWER_LEVEL -HIGH_LEVEL -SYNCH_LEVEL \ No newline at end of file diff --git a/irc/ArchBlackmann/makefile b/irc/ArchBlackmann/makefile deleted file mode 100644 index 0fac5b953f0..00000000000 --- a/irc/ArchBlackmann/makefile +++ /dev/null @@ -1,38 +0,0 @@ -TARGET := ArchBlackmann.exe - -.PHONY: all - -all: $(TARGET) - -CPP=mingw32-g++ -CFLAGS := -DWIN32 -D_DEBUG -D_CONSOLE -D_MBCS -LFLAGS := -LIBS := -lstdc++ -lws2_32 - -SRCS := ArchBlackmann.cpp \ - base64.cpp \ - chomp.cpp \ - cram_md5.cpp \ - File.cpp \ - IRCClient.cpp \ - MD5.cpp \ - panic.cpp \ - ReliMT.cpp \ - SockUtils.cpp \ - SplitJoin.cpp \ - ssprintf.cpp \ - ThreadPool.cpp \ - trim.cpp - -OBJS := $(SRCS:.cpp=.o) - -$(TARGET): $(OBJS) - $(CPP) $(LFLAGS) -o $@ $(OBJS) $(LIBS) - -.cpp.o: $< - $(CPP) $(CFLAGS) -c $< -o $@ - -.PHONY: clean -clean: - -@del $(TARGET) - -@del $(OBJS) diff --git a/irc/ArchBlackmann/module.txt b/irc/ArchBlackmann/module.txt deleted file mode 100644 index b9956a73854..00000000000 --- a/irc/ArchBlackmann/module.txt +++ /dev/null @@ -1,13 +0,0 @@ -the kernel -ntoskrnl -win32k -msafd -ws2_32 -user32 -shell32 -the cache manager -tdi -the scheduler -the thread queue -the message queue -atapi \ No newline at end of file diff --git a/irc/ArchBlackmann/nogrovel.txt b/irc/ArchBlackmann/nogrovel.txt deleted file mode 100644 index bbeecf0d275..00000000000 --- a/irc/ArchBlackmann/nogrovel.txt +++ /dev/null @@ -1,5 +0,0 @@ -/me slaps %s with a large trout -recycle(%s) -Did I hear something? Musta been a %s-fly... Where's that fly-swatter? -%s: go away son, you bother me.... -/me beats %s with the whipping noodle diff --git a/irc/ArchBlackmann/panic.cpp b/irc/ArchBlackmann/panic.cpp deleted file mode 100644 index 3ad0604b311..00000000000 --- a/irc/ArchBlackmann/panic.cpp +++ /dev/null @@ -1,34 +0,0 @@ -// panic.cpp -// This file is (C) 2003-2004 Royce Mitchell III -// and released under the BSD & LGPL licenses - -#include -#include -#include -#ifdef WIN32 -#include -#include -#endif//WIN32 -#include "panic.h" - -void panic ( const char* format, ... ) -{ - va_list arg; - int done; - - va_start(arg, format); -#if defined(WIN32) && !defined(_CONSOLE) - char buf[4096]; - _vsnprintf ( buf, sizeof(buf)-1, format, arg ); - MessageBox ( NULL, buf, "Panic!", MB_OK|MB_ICONEXCLAMATION ); -#else - done = vprintf(format, arg); - printf ( "\n" ); -#endif - va_end(arg); -#if defined(WIN32) && defined(_CONSOLE) - printf ( "Press any key to exit\n" ); - (void)getch(); -#endif//WIN32 && _CONSOLE - exit ( -1 ); -} diff --git a/irc/ArchBlackmann/panic.h b/irc/ArchBlackmann/panic.h deleted file mode 100644 index e15cafab27f..00000000000 --- a/irc/ArchBlackmann/panic.h +++ /dev/null @@ -1,18 +0,0 @@ -// panic.h -// This file is (C) 2003-2004 Royce Mitchell III -// and released under the BSD & LGPL licenses - -#ifndef PANIC_H -#define PANIC_H - -void panic ( const char* format, ... ); - -#define suAssert(expr) if ( !(expr) ) panic ( "%s(%lu): SOCKET ERROR %s\nExpression: %s\n", __FILE__, __LINE__, suErrDesc(SUERRNO), #expr ) - -#if defined(DEBUG) || defined(_DEBUG) -# define suVerify(expr) suAssert(expr) -#else -# define suVerify(expr) expr -#endif - -#endif//PANIC_H diff --git a/irc/ArchBlackmann/period.txt b/irc/ArchBlackmann/period.txt deleted file mode 100644 index 380a6fefe38..00000000000 --- a/irc/ArchBlackmann/period.txt +++ /dev/null @@ -1,11 +0,0 @@ -minute -hour -day -week -fortnight -month -year -decade -century -millenium -eon \ No newline at end of file diff --git a/irc/ArchBlackmann/readme.txt b/irc/ArchBlackmann/readme.txt deleted file mode 100644 index 89f9da7369e..00000000000 --- a/irc/ArchBlackmann/readme.txt +++ /dev/null @@ -1,44 +0,0 @@ -This doc can be also found on the wiki. - -ArchBlackman is a IRC-Chat bot of the #reactos irc channel. He has been coded by Royce3 and DrFred (mbosma) currently runs him. - - -If some one use a swear word he'll tell him not to do so and you can also ask him something technical about reactos. :) - -Besides this he also knows some commands. The systax for giving him commands "ArchBlackmann: !grovel". (don't forget to address him) - - - !grovel - This is the only command that non ops can do (No Parameter) - - !kiss - - !hug - - !give - - !say - You can tell him to say something on the channel via PrivateMessage - - -ArchBlackmann know what he should say from some text files. They can be found on the svn-dir. But can also edit them online if you are op using: - - - !add - - !remove - -List that are used directly to create responses are: - - - tech - here are the sentences ArchBlackmann says when he finds his name - - curse - this are the curses he looks for - - cursecop - this the responces to them - - grovel - this is said when an op does the grovel command - - nogrovel - this when someone else does it - -The remaining lists are not used directly, but by the other lists. - -They are: - - - dev - - func - - irql - - module - - period - - status - - stru - - type - -And they are used like this: - /me thinks %s is smarter than %dev% \ No newline at end of file diff --git a/irc/ArchBlackmann/ssprintf.cpp b/irc/ArchBlackmann/ssprintf.cpp deleted file mode 100644 index 9f55d12f637..00000000000 --- a/irc/ArchBlackmann/ssprintf.cpp +++ /dev/null @@ -1,998 +0,0 @@ -// ssprintf.cpp - -#include -#include -#include -#include -#include "ssprintf.h" - -#ifdef _MSC_VER -#define alloca _alloca -#endif//_MSC_VER - -typedef __int64 LONGLONG; -typedef unsigned __int64 ULONGLONG; - -typedef struct { - unsigned int mantissa:23; - unsigned int exponent:8; - unsigned int sign:1; -} ieee_float_t; - -typedef struct { - unsigned int mantissal:32; - unsigned int mantissah:20; - unsigned int exponent:11; - unsigned int sign:1; -} ieee_double_t; - -typedef struct { - unsigned int mantissal:32; - unsigned int mantissah:32; - unsigned int exponent:15; - unsigned int sign:1; - unsigned int empty:16; -} ieee_long_double_t; - -std::string ssprintf ( const char* fmt, ... ) -{ - va_list arg; - va_start(arg, fmt); - std::string f = ssvprintf ( fmt, arg ); - va_end(arg); - return f; -} - -#define ZEROPAD 1 /* pad with zero */ -#define SIGN 2 /* unsigned/signed long */ -#define PLUS 4 /* show plus */ -#define SPACE 8 /* space if plus */ -#define LEFT 16 /* left justified */ -#define SPECIAL 32 /* 0x */ -#define LARGE 64 /* use 'ABCDEF' instead of 'abcdef' */ -#define ZEROTRUNC 128 /* truncate zero 's */ - - -static int skip_atoi(const char **s) -{ - int i=0; - - while (isdigit(**s)) - i = i*10 + *((*s)++) - '0'; - return i; -} - - -static int do_div(LONGLONG *n,int base) -{ - int __res = ((ULONGLONG) *n) % (unsigned) base; - *n = ((ULONGLONG) *n) / (unsigned) base; - return __res; -} - - -static bool number(std::string& f, LONGLONG num, int base, int size, int precision ,int type) -{ - char c,sign,tmp[66]; - const char *digits="0123456789abcdefghijklmnopqrstuvwxyz"; - int i; - - if (type & LARGE) - digits = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; - if (type & LEFT) - type &= ~ZEROPAD; - if (base < 2 || base > 36) - return 0; - c = (type & ZEROPAD) ? '0' : ' '; - sign = 0; - if (type & SIGN) { - if (num < 0) { - sign = '-'; - num = -num; - size--; - } else if (type & PLUS) { - sign = '+'; - size--; - } else if (type & SPACE) { - sign = ' '; - size--; - } - } - if (type & SPECIAL) { - if (base == 16) - size -= 2; - else if (base == 8) - size--; - } - i = 0; - if (num == 0) - tmp[i++]='0'; - else while (num != 0) - tmp[i++] = digits[do_div(&num,base)]; - if (i > precision) - precision = i; - size -= precision; - if (!(type&(ZEROPAD+LEFT))) - while(size-->0) - f += ' '; - if (sign) - f += sign; - if (type & SPECIAL) - { - if (base==8) - f += '0'; - else if (base==16) - { - f += '0'; - f += digits[33]; - } - } - if (!(type & LEFT)) - { - while (size-- > 0) - f += c; - } - while (i < precision--) - { - f += '0'; - } - while (i-- > 0) - { - f += tmp[i]; - } - while (size-- > 0) - { - f += ' '; - } - return true; -} - - -static bool numberf(std::string& f, double __n, char exp_sign, int size, int precision, int type) -{ - double exponent = 0.0; - double e; - long ie; - - //int x; - char *buf, *tmp; - int i = 0; - int j = 0; - //int k = 0; - - double frac, intr; - double p; - char sign; - char c; - char ro = 0; - int result; - - union - { - double* __n; - ieee_double_t* n; - } n; - - n.__n = &__n; - - if ( exp_sign == 'g' || exp_sign == 'G' || exp_sign == 'e' || exp_sign == 'E' ) { - ie = ((unsigned int)n.n->exponent - (unsigned int)0x3ff); - exponent = ie/3.321928; - } - - if ( exp_sign == 'g' || exp_sign == 'G' ) { - type |= ZEROTRUNC; - if ( exponent < -4 || fabs(exponent) >= precision ) - exp_sign -= 2; // g -> e and G -> E - } - - if ( exp_sign == 'e' || exp_sign == 'E' ) { - frac = modf(exponent,&e); - if ( frac > 0.5 ) - e++; - else if ( frac < -0.5 ) - e--; - - result = numberf(f,__n/pow(10.0L,e),'f',size-4, precision, type); - if (result < 0) - return false; - f += exp_sign; - size--; - ie = (long)e; - type = LEFT | PLUS; - if ( ie < 0 ) - type |= SIGN; - - result = number(f,ie, 10,2, 2,type ); - if (result < 0) - return false; - return true; - } - - if ( exp_sign == 'f' ) { - buf = (char*)alloca(4096); - if (type & LEFT) { - type &= ~ZEROPAD; - } - - c = (type & ZEROPAD) ? '0' : ' '; - sign = 0; - if (type & SIGN) { - if (__n < 0) { - sign = '-'; - __n = fabs(__n); - size--; - } else if (type & PLUS) { - sign = '+'; - size--; - } else if (type & SPACE) { - sign = ' '; - size--; - } - } - - frac = modf(__n,&intr); - - // # flags forces a . and prevents trucation of trailing zero's - - if ( precision > 0 ) { - //frac = modfl(__n,&intr); - i = precision-1; - while ( i >= 0 ) { - frac*=10.0L; - frac = modf(frac, &p); - buf[i] = (int)p + '0'; - i--; - } - i = precision; - size -= precision; - - ro = 0; - if ( frac > 0.5 ) { - ro = 1; - } - - if ( precision >= 1 || type & SPECIAL) { - buf[i++] = '.'; - size--; - } - } - - if ( intr == 0.0 ) { - buf[i++] = '0'; - size--; - } - else { - while ( intr > 0.0 ) { - p = intr; - intr/=10.0L; - modf(intr, &intr); - - p -= 10.0*intr; - - buf[i++] = (int)p + '0'; - size--; - } - } - - j = 0; - while ( j < i && ro == 1) { - if ( buf[j] >= '0' && buf[j] <= '8' ) { - buf[j]++; - ro = 0; - } - else if ( buf[j] == '9' ) { - buf[j] = '0'; - } - j++; - } - if ( ro == 1 ) - buf[i++] = '1'; - - buf[i] = 0; - - size -= precision; - if (!(type&(ZEROPAD+LEFT))) - { - while(size-->0) - f += ' '; - } - if (sign) - { - f += sign; - } - - if (!(type&(ZEROPAD+LEFT))) - while(size-->0) - { - f += ' '; - } - if (type & SPECIAL) { - } - - if (!(type & LEFT)) - while (size-- > 0) - { - f += c; - } - - tmp = buf; - if ( type & ZEROTRUNC && ((type & SPECIAL) != SPECIAL) ) - { - j = 0; - while ( j < i && ( *tmp == '0' || *tmp == '.' )) - { - tmp++; - i--; - } - } -// else -// while (i < precision--) -// putc('0', f); - while (i-- > 0) - { - f += tmp[i]; - } - while (size-- > 0) - { - f += ' '; - } - } - return true; -} - - -static bool numberfl(std::string& f, long double __n, char exp_sign, int size, int precision, int type) -{ - long double exponent = 0.0; - long double e; - long ie; - - //int x; - char *buf, *tmp; - int i = 0; - int j = 0; - //int k = 0; - - long double frac, intr; - long double p; - char sign; - char c; - char ro = 0; - - int result; - - union - { - long double* __n; - ieee_long_double_t* n; - } n; - - n.__n = &__n; - - if ( exp_sign == 'g' || exp_sign == 'G' || exp_sign == 'e' || exp_sign == 'E' ) { - ie = ((unsigned int)n.n->exponent - (unsigned int)0x3fff); - exponent = ie/3.321928; - } - - if ( exp_sign == 'g' || exp_sign == 'G' ) { - type |= ZEROTRUNC; - if ( exponent < -4 || fabs(exponent) >= precision ) - exp_sign -= 2; // g -> e and G -> E - } - - if ( exp_sign == 'e' || exp_sign == 'E' ) { - frac = modfl(exponent,&e); - if ( frac > 0.5 ) - e++; - else if ( frac < -0.5 ) - e--; - - result = numberf(f,__n/powl(10.0L,e),'f',size-4, precision, type); - if (result < 0) - return false; - f += exp_sign; - size--; - ie = (long)e; - type = LEFT | PLUS; - if ( ie < 0 ) - type |= SIGN; - - result = number(f,ie, 10,2, 2,type ); - if (result < 0) - return false; - return true; - } - - if ( exp_sign == 'f' ) - { - - buf = (char*)alloca(4096); - if (type & LEFT) - { - type &= ~ZEROPAD; - } - - c = (type & ZEROPAD) ? '0' : ' '; - sign = 0; - if (type & SIGN) - { - if (__n < 0) - { - sign = '-'; - __n = fabs(__n); - size--; - } else if (type & PLUS) - { - sign = '+'; - size--; - } else if (type & SPACE) - { - sign = ' '; - size--; - } - } - - frac = modfl(__n,&intr); - - // # flags forces a . and prevents trucation of trailing zero's - if ( precision > 0 ) - { - //frac = modfl(__n,&intr); - - i = precision-1; - while ( i >= 0 ) - { - frac*=10.0L; - frac = modfl((long double)frac, &p); - buf[i] = (int)p + '0'; - i--; - } - i = precision; - size -= precision; - - ro = 0; - if ( frac > 0.5 ) - { - ro = 1; - } - - if ( precision >= 1 || type & SPECIAL) - { - buf[i++] = '.'; - size--; - } - } - - if ( intr == 0.0 ) - { - buf[i++] = '0'; - size--; - } - else - { - while ( intr > 0.0 ) - { - p=intr; - intr/=10.0L; - modfl(intr, &intr); - - p -= 10.0L*intr; - - buf[i++] = (int)p + '0'; - size--; - } - } - - j = 0; - while ( j < i && ro == 1) { - if ( buf[j] >= '0' && buf[j] <= '8' ) - { - buf[j]++; - ro = 0; - } - else if ( buf[j] == '9' ) - { - buf[j] = '0'; - } - j++; - } - if ( ro == 1 ) - buf[i++] = '1'; - - buf[i] = 0; - - size -= precision; - if (!(type&(ZEROPAD+LEFT))) - { - while(size-->0) - f += ' '; - } - if (sign) - { - f += sign; - } - - if (!(type&(ZEROPAD+LEFT))) - { - while(size-->0) - f += ' '; - } - if (type & SPECIAL) { - } - - if (!(type & LEFT)) - while (size-- > 0) - { - f += c; - } - tmp = buf; - if ( type & ZEROTRUNC && ((type & SPECIAL) != SPECIAL) ) - { - j = 0; - while ( j < i && ( *tmp == '0' || *tmp == '.' )) - { - tmp++; - i--; - } - } -// else -// while (i < precision--) -// putc( '0', f); - while (i-- > 0) - { - f += tmp[i]; - } - while (size-- > 0) - { - f += ' '; - } - } - return true; -} - -static int stringa(std::string& f, const char* s, int len, int field_width, int precision, int flags) -{ - int i, done = 0; - if (s == NULL) - { - s = ""; - len = 6; - } - else - { - if (len == -1) - { - len = 0; - while ((unsigned int)len < (unsigned int)precision && s[len]) - len++; - } - else - { - if ((unsigned int)len > (unsigned int)precision) - len = precision; - } - } - if (!(flags & LEFT)) - while (len < field_width--) - { - f += ' '; - done++; - } - for (i = 0; i < len; ++i) - { - f += *s++; - done++; - } - while (len < field_width--) - { - f += ' '; - done++; - } - return done; -} - -static int stringw(std::string& f, const wchar_t* sw, int len, int field_width, int precision, int flags) -{ - int i, done = 0; - if (sw == NULL) - { - sw = L""; - len = 6; - } - else - { - if (len == -1) - { - len = 0; - while ((unsigned int)len < (unsigned int)precision && sw[len]) - len++; - } - else - { - if ((unsigned int)len > (unsigned int)precision) - len = precision; - } - } - if (!(flags & LEFT)) - while (len < field_width--) - { - f += ' '; - done++; - } - for (i = 0; i < len; ++i) - { -#define MY_MB_CUR_MAX 1 - char mb[MY_MB_CUR_MAX]; - int mbcount, j; - mbcount = wctomb(mb, *sw++); - if (mbcount <= 0) - { - break; - } - for (j = 0; j < mbcount; j++) - { - f += mb[j]; - done++; - } - } - while (len < field_width--) - { - f += ' '; - done++; - } - return done; -} - -#define _isnanl _isnan -#define _finitel _finite - -std::string ssvprintf ( const char *fmt, va_list args ) -{ - ULONGLONG num; - int base; - long double _ldouble; - double _double; - const char *s; - const wchar_t* sw; - int result; - std::string f; - - int flags; /* flags to number() */ - - int field_width; /* width of output field */ - int precision; /* min. # of digits for integers; max - number of chars for from string */ - int qualifier = 0; /* 'h', 'l', 'L' or 'I64' for integer fields */ - - for (; *fmt ; ++fmt) - { - if (*fmt != '%') - { - f += *fmt; - continue; - } - - /* process flags */ - flags = 0; - repeat: - ++fmt; /* this also skips first '%' */ - switch (*fmt) { - case '-': flags |= LEFT; goto repeat; - case '+': flags |= PLUS; goto repeat; - case ' ': flags |= SPACE; goto repeat; - case '#': flags |= SPECIAL; goto repeat; - case '0': flags |= ZEROPAD; goto repeat; - } - - /* get field width */ - field_width = -1; - if (isdigit(*fmt)) - field_width = skip_atoi(&fmt); - else if (*fmt == '*') { - ++fmt; - /* it's the next argument */ - field_width = va_arg(args, int); - if (field_width < 0) { - field_width = -field_width; - flags |= LEFT; - } - } - - /* get the precision */ - precision = -1; - if (*fmt == '.') { - ++fmt; - if (isdigit(*fmt)) - precision = skip_atoi(&fmt); - else if (*fmt == '*') { - ++fmt; - /* it's the next argument */ - precision = va_arg(args, int); - } - if (precision < 0) - precision = 0; - } - - /* get the conversion qualifier */ - qualifier = 0; - // %Z can be just stand alone or as size_t qualifier - if ( *fmt == 'Z' ) { - qualifier = *fmt; - switch ( *(fmt+1)) { - case 'o': - case 'b': - case 'X': - case 'x': - case 'd': - case 'i': - case 'u': - ++fmt; - break; - default: - break; - } - } else if (*fmt == 'h' || *fmt == 'l' || *fmt == 'L' || *fmt == 'w') { - qualifier = *fmt; - ++fmt; - } else if (*fmt == 'I' && *(fmt+1) == '6' && *(fmt+2) == '4') { - qualifier = *fmt; - fmt += 3; - } - - // go fine with ll instead of L - if ( *fmt == 'l' ) { - ++fmt; - qualifier = 'L'; - } - - /* default base */ - base = 10; - - switch (*fmt) { - case 'c': - if (!(flags & LEFT)) - while (--field_width > 0) - { - f += ' '; - } - if (qualifier == 'l' || qualifier == 'w') - { - f += (char)(unsigned char)(wchar_t) va_arg(args,int); - } - else - { - f += (char)(unsigned char) va_arg(args,int); - } - while (--field_width > 0) - { - f += ' '; - } - continue; - - case 'C': - if (!(flags & LEFT)) - while (--field_width > 0) - { - f += ' '; - } - if (qualifier == 'h') - { - f += (char)(unsigned char) va_arg(args,int); - } - else - { - f += (char)(unsigned char)(wchar_t) va_arg(args,int); - } - while (--field_width > 0) - { - f += ' '; - } - continue; - - case 's': - if (qualifier == 'l' || qualifier == 'w') { - /* print unicode string */ - sw = (const wchar_t*)va_arg(args, wchar_t *); - result = stringw(f, sw, -1, field_width, precision, flags); - } else { - /* print ascii string */ - s = va_arg(args, char *); - result = stringa(f, s, -1, field_width, precision, flags); - } - if (result < 0) - { - assert(!"TODO FIXME handle error better"); - return f; - } - continue; - - case 'S': - if (qualifier == 'h') { - /* print ascii string */ - s = va_arg(args, char *); - result = stringa(f, s, -1, field_width, precision, flags); - } else { - /* print unicode string */ - sw = (const wchar_t*)va_arg(args, wchar_t *); - result = stringw(f, sw, -1, field_width, precision, flags); - } - if (result < 0) - { - assert(!"TODO FIXME handle error better"); - return f; - } - continue; - - /*case 'Z': - if (qualifier == 'w') { - // print counted unicode string - PUNICODE_STRING pus = va_arg(args, PUNICODE_STRING); - if ((pus == NULL) || (pus->Buffer == NULL)) { - sw = NULL; - len = -1; - } else { - sw = pus->Buffer; - len = pus->Length / sizeof(WCHAR); - } - result = stringw(f, sw, len, field_width, precision, flags); - } else { - // print counted ascii string - PANSI_STRING pas = va_arg(args, PANSI_STRING); - if ((pas == NULL) || (pas->Buffer == NULL)) { - s = NULL; - len = -1; - } else { - s = pas->Buffer; - len = pas->Length; - } - result = stringa(f, s, -1, field_width, precision, flags); - } - if (result < 0) - return -1; - continue;*/ - - case 'e': - case 'E': - case 'f': - case 'g': - case 'G': - if (qualifier == 'l' || qualifier == 'L' ) { - _ldouble = va_arg(args, long double); - - if ( _isnanl(_ldouble) ) - { - f += "Nan"; - } - else if ( !_finitel(_ldouble) ) - { - if ( _ldouble < 0 ) - f += "-Inf"; - else - f += "+Inf"; - } else { - if ( precision == -1 ) - precision = 6; - result = numberfl(f,_ldouble,*fmt,field_width,precision,flags); - if (result < 0) - { - assert(!"TODO FIXME handle error better"); - return f; - } - } - } else { - _double = (double)va_arg(args, double); - - if ( _isnan(_double) ) - { - f += "Nan"; - } - else if ( !_finite(_double) ) - { - if ( _double < 0 ) - f += "-Inf"; - else - f += "+Inf"; - } - else - { - if ( precision == -1 ) - precision = 6; - result = numberf(f,_double,*fmt,field_width,precision,flags); - if (result < 0) - { - assert(!"TODO FIXME handle error better"); - return f; - } - } - } - continue; - - case 'p': - if (field_width == -1) { - field_width = 2*sizeof(void *); - flags |= ZEROPAD; - } - result = number(f, - (unsigned long) va_arg(args, void *), 16, - field_width, precision, flags); - if (result < 0) - { - assert(!"TODO FIXME handle error better"); - return f; - } - continue; - - case 'n': - if (qualifier == 'l') { - long * ip = va_arg(args, long *); - *ip = 0; - } else { - int * ip = va_arg(args, int *); - *ip = 0; - } - continue; - - /* integer number formats - set up the flags and "break" */ - case 'o': - base = 8; - break; - - case 'b': - base = 2; - break; - - case 'X': - flags |= LARGE; - case 'x': - base = 16; - break; - - case 'd': - case 'i': - flags |= SIGN; - case 'u': - break; - - default: - if (*fmt != '%') - { - f += '%'; - } - if (*fmt) - { - f += *fmt; - } - else - --fmt; - continue; - } - - if (qualifier == 'I') - num = va_arg(args, ULONGLONG); - else if (qualifier == 'l') { - if (flags & SIGN) - num = va_arg(args, long); - else - num = va_arg(args, unsigned long); - } - else if (qualifier == 'h') { - if (flags & SIGN) - num = va_arg(args, int); - else - num = va_arg(args, unsigned int); - } - else if (flags & SIGN) - num = va_arg(args, int); - else - num = va_arg(args, unsigned int); - result = number(f, num, base, field_width, precision, flags); - if (result < 0) - { - assert(!"TODO FIXME handle error better"); - return f; - } - } - //putc('\0',f); - return f; -} diff --git a/irc/ArchBlackmann/ssprintf.h b/irc/ArchBlackmann/ssprintf.h deleted file mode 100644 index aa04411a1e5..00000000000 --- a/irc/ArchBlackmann/ssprintf.h +++ /dev/null @@ -1,12 +0,0 @@ -// ssprintf.h - -#ifndef SSPRINTF_H -#define SSPRINTF_H - -#include -#include - -std::string ssprintf ( const char* fmt, ... ); -std::string ssvprintf ( const char* fmt, va_list args ); - -#endif//SSPRINTF_H diff --git a/irc/ArchBlackmann/status.txt b/irc/ArchBlackmann/status.txt deleted file mode 100644 index a883e41ad36..00000000000 --- a/irc/ArchBlackmann/status.txt +++ /dev/null @@ -1,654 +0,0 @@ -RPC_NT_ALREADY_LISTENING -RPC_NT_ALREADY_REGISTERED -RPC_NT_CALL_FAILED -RPC_NT_CALL_FAILED_DNE -RPC_NT_CANT_CREATE_ENDPOINT -RPC_NT_INVALID_BINDING -RPC_NT_INVALID_ENDPOINT_FORMAT -RPC_NT_INVALID_NETWORK_OPTIONS -RPC_NT_INVALID_NET_ADDR -RPC_NT_INVALID_RPC_PROTSEQ -RPC_NT_INVALID_STRING_BINDING -RPC_NT_INVALID_STRING_UUID -RPC_NT_INVALID_TIMEOUT -RPC_NT_NOT_LISTENING -RPC_NT_NO_BINDINGS -RPC_NT_NO_CALL_ACTIVE -RPC_NT_NO_ENDPOINT_FOUND -RPC_NT_NO_PROTSEQS -RPC_NT_NO_PROTSEQS_REGISTERED -RPC_NT_OBJECT_NOT_FOUND -RPC_NT_OUT_OF_RESOURCES -RPC_NT_PROTOCOL_ERROR -RPC_NT_PROTSEQ_NOT_SUPPORTED -RPC_NT_SERVER_TOO_BUSY -RPC_NT_SERVER_UNAVAILABLE -RPC_NT_SS_IN_NULL_CONTEXT -RPC_NT_TYPE_ALREADY_REGISTERED -RPC_NT_UNKNOWN_IF -RPC_NT_UNKNOWN_MGR_TYPE -RPC_NT_WRONG_KIND_OF_BINDING -STATUS_ABANDONED -STATUS_ABANDONED_WAIT_0 -STATUS_ABANDONED_WAIT_63 -STATUS_ABIOS_INVALID_COMMAND -STATUS_ABIOS_INVALID_LID -STATUS_ABIOS_INVALID_SELECTOR -STATUS_ABIOS_LID_ALREADY_OWNED -STATUS_ABIOS_LID_NOT_EXIST -STATUS_ABIOS_NOT_LID_OWNER -STATUS_ABIOS_NOT_PRESENT -STATUS_ABIOS_SELECTOR_NOT_AVAILABLE -STATUS_ACCESS_DENIED -STATUS_ACCESS_VIOLATION -STATUS_ACCOUNT_DISABLED -STATUS_ACCOUNT_EXPIRED -STATUS_ACCOUNT_LOCKED_OUT -STATUS_ACCOUNT_RESTRICTION -STATUS_ADAPTER_HARDWARE_ERROR -STATUS_ADDRESS_ALREADY_ASSOCIATED -STATUS_ADDRESS_ALREADY_EXISTS -STATUS_ADDRESS_CLOSED -STATUS_ADDRESS_NOT_ASSOCIATED -STATUS_AGENTS_EXHAUSTED -STATUS_ALERTED -STATUS_ALIAS_EXISTS -STATUS_ALLOCATE_BUCKET -STATUS_ALLOTTED_SPACE_EXCEEDED -STATUS_ALREADY_COMMITTED -STATUS_ALREADY_DISCONNECTED -STATUS_ALREADY_WIN32 -STATUS_APP_INIT_FAILURE -STATUS_ARBITRATION_UNHANDLED -STATUS_ARRAY_BOUNDS_EXCEEDED -STATUS_AUDIT_FAILED -STATUS_BACKUP_CONTROLLER -STATUS_BAD_COMPRESSION_BUFFER -STATUS_BAD_CURRENT_DIRECTORY -STATUS_BAD_DESCRIPTOR_FORMAT -STATUS_BAD_DEVICE_TYPE -STATUS_BAD_DLL_ENTRYPOINT -STATUS_BAD_FUNCTION_TABLE -STATUS_BAD_IMPERSONATION_LEVEL -STATUS_BAD_INHERITANCE_ACL -STATUS_BAD_INITIAL_PC -STATUS_BAD_INITIAL_STACK -STATUS_BAD_LOGON_SESSION_STATE -STATUS_BAD_MASTER_BOOT_RECORD -STATUS_BAD_NETWORK_NAME -STATUS_BAD_NETWORK_PATH -STATUS_BAD_REMOTE_ADAPTER -STATUS_BAD_SERVICE_ENTRYPOINT -STATUS_BAD_STACK -STATUS_BAD_TOKEN_TYPE -STATUS_BAD_VALIDATION_CLASS -STATUS_BAD_WORKING_SET_LIMIT -STATUS_BEGINNING_OF_MEDIA -STATUS_BIOS_FAILED_TO_CONNECT_INTERRUPT -STATUS_BREAKPOINT -STATUS_BUFFER_OVERFLOW -STATUS_BUFFER_TOO_SMALL -STATUS_BUS_RESET -STATUS_CANCELLED -STATUS_CANNOT_DELETE -STATUS_CANNOT_IMPERSONATE -STATUS_CANNOT_LOAD_REGISTRY_FILE -STATUS_CANT_ACCESS_DOMAIN_INFO -STATUS_CANT_DISABLE_MANDATORY -STATUS_CANT_OPEN_ANONYMOUS -STATUS_CANT_TERMINATE_SELF -STATUS_CANT_WAIT -STATUS_CARDBUS_NOT_SUPPORTED -STATUS_CHECKING_FILE_SYSTEM -STATUS_CHILD_MUST_BE_VOLATILE -STATUS_CLIENT_SERVER_PARAMETERS_INVALID -STATUS_COMMITMENT_LIMIT -STATUS_CONFLICTING_ADDRESSES -STATUS_CONNECTION_ABORTED -STATUS_CONNECTION_ACTIVE -STATUS_CONNECTION_COUNT_LIMIT -STATUS_CONNECTION_DISCONNECTED -STATUS_CONNECTION_INVALID -STATUS_CONNECTION_IN_USE -STATUS_CONNECTION_REFUSED -STATUS_CONNECTION_RESET -STATUS_CONTROL_C_EXIT -STATUS_CONVERT_TO_LARGE -STATUS_COULD_NOT_INTERPRET -STATUS_CRC_ERROR -STATUS_CTL_FILE_NOT_SUPPORTED -STATUS_DATATYPE_MISALIGNMENT -STATUS_DATA_ERROR -STATUS_DATA_LATE_ERROR -STATUS_DATA_NOT_ACCEPTED -STATUS_DATA_OVERRUN -STATUS_DEBUG_ATTACH_FAILED -STATUS_DELETE_PENDING -STATUS_DEVICE_ALREADY_ATTACHED -STATUS_DEVICE_BUSY -STATUS_DEVICE_CONFIGURATION_ERROR -STATUS_DEVICE_DATA_ERROR -STATUS_DEVICE_DOES_NOT_EXIST -STATUS_DEVICE_NOT_CONNECTED -STATUS_DEVICE_NOT_PARTITIONED -STATUS_DEVICE_NOT_READY -STATUS_DEVICE_OFF_LINE -STATUS_DEVICE_PAPER_EMPTY -STATUS_DEVICE_POWERED_OFF -STATUS_DEVICE_POWER_FAILURE -STATUS_DEVICE_PROTOCOL_ERROR -STATUS_DFS_EXIT_PATH_FOUND -STATUS_DFS_UNAVAILABLE -STATUS_DIRECTORY_NOT_EMPTY -STATUS_DISK_CORRUPT_ERROR -STATUS_DISK_FULL -STATUS_DISK_OPERATION_FAILED -STATUS_DISK_RECALIBRATE_FAILED -STATUS_DISK_RESET_FAILED -STATUS_DLL_INIT_FAILED -STATUS_DLL_INIT_FAILED_LOGOFF -STATUS_DLL_NOT_FOUND -STATUS_DOMAIN_CONTROLLER_NOT_FOUND -STATUS_DOMAIN_CTRLR_CONFIG_ERROR -STATUS_DOMAIN_EXISTS -STATUS_DOMAIN_LIMIT_EXCEEDED -STATUS_DOMAIN_TRUST_INCONSISTENT -STATUS_DRIVER_CANCEL_TIMEOUT -STATUS_DRIVER_ENTRYPOINT_NOT_FOUND -STATUS_DRIVER_INTERNAL_ERROR -STATUS_DRIVER_ORDINAL_NOT_FOUND -STATUS_DRIVER_UNABLE_TO_LOAD -STATUS_DUPLICATE_NAME -STATUS_DUPLICATE_OBJECTID -STATUS_EAS_NOT_SUPPORTED -STATUS_EA_CORRUPT_ERROR -STATUS_EA_LIST_INCONSISTENT -STATUS_EA_TOO_LARGE -STATUS_END_OF_FILE -STATUS_END_OF_MEDIA -STATUS_ENTRYPOINT_NOT_FOUND -STATUS_EOM_OVERFLOW -STATUS_EVALUATION_EXPIRATION -STATUS_EVENTLOG_CANT_START -STATUS_EVENTLOG_FILE_CHANGED -STATUS_EVENTLOG_FILE_CORRUPT -STATUS_EVENT_DONE -STATUS_EVENT_PENDING -STATUS_EXTRANEOUS_INFORMATION -STATUS_FAIL_CHECK -STATUS_FATAL_APP_EXIT -STATUS_FILEMARK_DETECTED -STATUS_FILES_OPEN -STATUS_FILE_CLOSED -STATUS_FILE_CORRUPT_ERROR -STATUS_FILE_DELETED -STATUS_FILE_FORCED_CLOSED -STATUS_FILE_INVALID -STATUS_FILE_IS_A_DIRECTORY -STATUS_FILE_IS_OFFLINE -STATUS_FILE_LOCK_CONFLICT -STATUS_FILE_RENAMED -STATUS_FLOAT_DENORMAL_OPERAND -STATUS_FLOAT_DIVIDE_BY_ZERO -STATUS_FLOAT_INEXACT_RESULT -STATUS_FLOAT_INVALID_OPERATION -STATUS_FLOAT_OVERFLOW -STATUS_FLOAT_STACK_CHECK -STATUS_FLOAT_UNDERFLOW -STATUS_FLOPPY_BAD_REGISTERS -STATUS_FLOPPY_ID_MARK_NOT_FOUND -STATUS_FLOPPY_UNKNOWN_ERROR -STATUS_FLOPPY_VOLUME -STATUS_FLOPPY_WRONG_CYLINDER -STATUS_FOUND_OUT_OF_SCOPE -STATUS_FREE_VM_NOT_AT_BASE -STATUS_FS_DRIVER_REQUIRED -STATUS_FT_MISSING_MEMBER -STATUS_FT_ORPHANING -STATUS_FT_READ_RECOVERING_FROM_BACKUP -STATUS_FT_WRITE_RECOVERY -STATUS_FULLSCREEN_MODE -STATUS_GENERIC_NOT_MAPPED -STATUS_GRACEFUL_DISCONNECT -STATUS_GROUP_EXISTS -STATUS_GUARD_PAGE_VIOLATION -STATUS_GUIDS_EXHAUSTED -STATUS_GUID_SUBSTITUTION_MADE -STATUS_HANDLES_CLOSED -STATUS_HANDLE_NOT_CLOSABLE -STATUS_HOST_UNREACHABLE -STATUS_ILLEGAL_CHARACTER -STATUS_ILLEGAL_DLL_RELOCATION -STATUS_ILLEGAL_FLOAT_CONTEXT -STATUS_ILLEGAL_FUNCTION -STATUS_ILLEGAL_INSTRUCTION -STATUS_ILL_FORMED_PASSWORD -STATUS_ILL_FORMED_SERVICE_ENTRY -STATUS_IMAGE_ALREADY_LOADED -STATUS_IMAGE_CHECKSUM_MISMATCH -STATUS_IMAGE_MACHINE_TYPE_MISMATCH -STATUS_IMAGE_MACHINE_TYPE_MISMATCH_EXE -STATUS_IMAGE_MP_UP_MISMATCH -STATUS_IMAGE_NOT_AT_BASE -STATUS_INCOMPATIBLE_FILE_MAP -STATUS_INFO_LENGTH_MISMATCH -STATUS_INSTANCE_NOT_AVAILABLE -STATUS_INSTRUCTION_MISALIGNMENT -STATUS_INSUFFICIENT_LOGON_INFO -STATUS_INSUFFICIENT_RESOURCES -STATUS_INSUFF_SERVER_RESOURCES -STATUS_INTEGER_DIVIDE_BY_ZERO -STATUS_INTEGER_OVERFLOW -STATUS_INTERNAL_DB_CORRUPTION -STATUS_INTERNAL_DB_ERROR -STATUS_INTERNAL_ERROR -STATUS_INVALID_ACCOUNT_NAME -STATUS_INVALID_ACL -STATUS_INVALID_ADDRESS -STATUS_INVALID_ADDRESS_COMPONENT -STATUS_INVALID_ADDRESS_WILDCARD -STATUS_INVALID_BLOCK_LENGTH -STATUS_INVALID_BUFFER_SIZE -STATUS_INVALID_CID -STATUS_INVALID_COMPUTER_NAME -STATUS_INVALID_CONNECTION -STATUS_INVALID_DEVICE_REQUEST -STATUS_INVALID_DEVICE_STATE -STATUS_INVALID_DISPOSITION -STATUS_INVALID_DOMAIN_ROLE -STATUS_INVALID_DOMAIN_STATE -STATUS_INVALID_EA_FLAG -STATUS_INVALID_EA_NAME -STATUS_INVALID_FILE_FOR_SECTION -STATUS_INVALID_GROUP_ATTRIBUTES -STATUS_INVALID_HANDLE -STATUS_INVALID_HW_PROFILE -STATUS_INVALID_ID_AUTHORITY -STATUS_INVALID_IMAGE_FORMAT -STATUS_INVALID_IMAGE_LE_FORMAT -STATUS_INVALID_IMAGE_NE_FORMAT -STATUS_INVALID_IMAGE_NOT_MZ -STATUS_INVALID_IMAGE_PROTECT -STATUS_INVALID_IMAGE_WIN_16 -STATUS_INVALID_INFO_CLASS -STATUS_INVALID_LDT_DESCRIPTOR -STATUS_INVALID_LDT_OFFSET -STATUS_INVALID_LDT_SIZE -STATUS_INVALID_LEVEL -STATUS_INVALID_LOCK_SEQUENCE -STATUS_INVALID_LOGON_HOURS -STATUS_INVALID_LOGON_TYPE -STATUS_INVALID_MEMBER -STATUS_INVALID_NETWORK_RESPONSE -STATUS_INVALID_OPLOCK_PROTOCOL -STATUS_INVALID_OWNER -STATUS_INVALID_PAGE_PROTECTION -STATUS_INVALID_PARAMETER -STATUS_INVALID_PARAMETER_1 -STATUS_INVALID_PARAMETER_10 -STATUS_INVALID_PARAMETER_11 -STATUS_INVALID_PARAMETER_12 -STATUS_INVALID_PARAMETER_2 -STATUS_INVALID_PARAMETER_3 -STATUS_INVALID_PARAMETER_4 -STATUS_INVALID_PARAMETER_5 -STATUS_INVALID_PARAMETER_6 -STATUS_INVALID_PARAMETER_7 -STATUS_INVALID_PARAMETER_8 -STATUS_INVALID_PARAMETER_9 -STATUS_INVALID_PARAMETER_MIX -STATUS_INVALID_PIPE_STATE -STATUS_INVALID_PLUGPLAY_DEVICE_PATH -STATUS_INVALID_PORT_ATTRIBUTES -STATUS_INVALID_PORT_HANDLE -STATUS_INVALID_PRIMARY_GROUP -STATUS_INVALID_QUOTA_LOWER -STATUS_INVALID_READ_MODE -STATUS_INVALID_SECURITY_DESCR -STATUS_INVALID_SERVER_STATE -STATUS_INVALID_SID -STATUS_INVALID_SUB_AUTHORITY -STATUS_INVALID_SYSTEM_SERVICE -STATUS_INVALID_UNWIND_TARGET -STATUS_INVALID_USER_BUFFER -STATUS_INVALID_VARIANT -STATUS_INVALID_VIEW_SIZE -STATUS_INVALID_VLM_OPERATION -STATUS_INVALID_VOLUME_LABEL -STATUS_INVALID_WORKSTATION -STATUS_IN_PAGE_ERROR -STATUS_IO_DEVICE_ERROR -STATUS_IO_PRIVILEGE_FAILED -STATUS_IO_REPARSE_DATA_INVALID -STATUS_IO_REPARSE_TAG_INVALID -STATUS_IO_REPARSE_TAG_MISMATCH -STATUS_IO_REPARSE_TAG_NOT_HANDLED -STATUS_IO_TIMEOUT -STATUS_IP_ADDRESS_CONFLICT1 -STATUS_IP_ADDRESS_CONFLICT2 -STATUS_KERNEL_APC -STATUS_KEY_DELETED -STATUS_KEY_HAS_CHILDREN -STATUS_LAST_ADMIN -STATUS_LICENSE_QUOTA_EXCEEDED -STATUS_LICENSE_VIOLATION -STATUS_LINK_FAILED -STATUS_LINK_TIMEOUT -STATUS_LM_CROSS_ENCRYPTION_REQUIRED -STATUS_LOCAL_DISCONNECT -STATUS_LOCAL_USER_SESSION_KEY -STATUS_LOCK_NOT_GRANTED -STATUS_LOGIN_TIME_RESTRICTION -STATUS_LOGIN_WKSTA_RESTRICTION -STATUS_LOGON_FAILURE -STATUS_LOGON_NOT_GRANTED -STATUS_LOGON_SERVER_CONFLICT -STATUS_LOGON_SESSION_COLLISION -STATUS_LOGON_SESSION_EXISTS -STATUS_LOGON_TYPE_NOT_GRANTED -STATUS_LOG_FILE_FULL -STATUS_LOG_HARD_ERROR -STATUS_LONGJUMP -STATUS_LOST_WRITEBEHIND_DATA -STATUS_LPC_REPLY_LOST -STATUS_LUIDS_EXHAUSTED -STATUS_MAPPED_ALIGNMENT -STATUS_MAPPED_FILE_SIZE_ZERO -STATUS_MARSHALL_OVERFLOW -STATUS_MEDIA_CHANGED -STATUS_MEDIA_CHECK -STATUS_MEDIA_WRITE_PROTECTED -STATUS_MEMBERS_PRIMARY_GROUP -STATUS_MEMBER_IN_ALIAS -STATUS_MEMBER_IN_GROUP -STATUS_MEMBER_NOT_IN_ALIAS -STATUS_MEMBER_NOT_IN_GROUP -STATUS_MEMORY_NOT_ALLOCATED -STATUS_MESSAGE_NOT_FOUND -STATUS_MISSING_SYSTEMFILE -STATUS_MORE_ENTRIES -STATUS_MORE_PROCESSING_REQUIRED -STATUS_MUTANT_LIMIT_EXCEEDED -STATUS_MUTANT_NOT_OWNED -STATUS_NAME_TOO_LONG -STATUS_NETLOGON_NOT_STARTED -STATUS_NETWORK_ACCESS_DENIED -STATUS_NETWORK_BUSY -STATUS_NETWORK_CREDENTIAL_CONFLICT -STATUS_NETWORK_NAME_DELETED -STATUS_NETWORK_UNREACHABLE -STATUS_NET_WRITE_FAULT -STATUS_NOLOGON_INTERDOMAIN_TRUST_ACCOUNT -STATUS_NOLOGON_SERVER_TRUST_ACCOUNT -STATUS_NOLOGON_WORKSTATION_TRUST_ACCOUNT -STATUS_NONCONTINUABLE_EXCEPTION -STATUS_NONEXISTENT_EA_ENTRY -STATUS_NONEXISTENT_SECTOR -STATUS_NONE_MAPPED -STATUS_NOTIFY_CLEANUP -STATUS_NOTIFY_ENUM_DIR -STATUS_NOT_ALL_ASSIGNED -STATUS_NOT_A_DIRECTORY -STATUS_NOT_A_REPARSE_POINT -STATUS_NOT_CLIENT_SESSION -STATUS_NOT_COMMITTED -STATUS_NOT_FOUND -STATUS_NOT_IMPLEMENTED -STATUS_NOT_LOCKED -STATUS_NOT_LOGON_PROCESS -STATUS_NOT_MAPPED_DATA -STATUS_NOT_MAPPED_VIEW -STATUS_NOT_REGISTRY_FILE -STATUS_NOT_SAME_DEVICE -STATUS_NOT_SERVER_SESSION -STATUS_NOT_SUPPORTED -STATUS_NOT_TINY_STREAM -STATUS_NO_BROWSER_SERVERS_FOUND -STATUS_NO_CALLBACK_ACTIVE -STATUS_NO_DATA_DETECTED -STATUS_NO_EAS_ON_FILE -STATUS_NO_EVENT_PAIR -STATUS_NO_GUID_TRANSLATION -STATUS_NO_IMPERSONATION_TOKEN -STATUS_NO_INHERITANCE -STATUS_NO_LDT -STATUS_NO_LOGON_SERVERS -STATUS_NO_LOG_SPACE -STATUS_NO_MATCH -STATUS_NO_MEDIA -STATUS_NO_MEDIA_IN_DEVICE -STATUS_NO_MEMORY -STATUS_NO_MORE_EAS -STATUS_NO_MORE_ENTRIES -STATUS_NO_MORE_FILES -STATUS_NO_MORE_MATCHES -STATUS_NO_PAGEFILE -STATUS_NO_QUOTAS_NO_ACCOUNT -STATUS_NO_SECURITY_ON_OBJECT -STATUS_NO_SPOOL_SPACE -STATUS_NO_SUCH_ALIAS -STATUS_NO_SUCH_DEVICE -STATUS_NO_SUCH_DOMAIN -STATUS_NO_SUCH_FILE -STATUS_NO_SUCH_GROUP -STATUS_NO_SUCH_LOGON_SESSION -STATUS_NO_SUCH_MEMBER -STATUS_NO_SUCH_PACKAGE -STATUS_NO_SUCH_PRIVILEGE -STATUS_NO_SUCH_USER -STATUS_NO_TOKEN -STATUS_NO_TRUST_LSA_SECRET -STATUS_NO_TRUST_SAM_ACCOUNT -STATUS_NO_USER_SESSION_KEY -STATUS_NO_YIELD_PERFORMED -STATUS_NT_CROSS_ENCRYPTION_REQUIRED -STATUS_NULL_LM_PASSWORD -STATUS_OBJECTID_EXISTS -STATUS_OBJECT_EXISTS -STATUS_OBJECT_NAME_COLLISION -STATUS_OBJECT_NAME_EXISTS -STATUS_OBJECT_NAME_INVALID -STATUS_OBJECT_NAME_NOT_FOUND -STATUS_OBJECT_PATH_INVALID -STATUS_OBJECT_PATH_NOT_FOUND -STATUS_OBJECT_PATH_SYNTAX_BAD -STATUS_OBJECT_TYPE_MISMATCH -STATUS_OPEN_FAILED -STATUS_OPLOCK_BREAK_IN_PROCESS -STATUS_OPLOCK_NOT_GRANTED -STATUS_ORDINAL_NOT_FOUND -STATUS_PAGEFILE_CREATE_FAILED -STATUS_PAGEFILE_QUOTA -STATUS_PAGEFILE_QUOTA_EXCEEDED -STATUS_PARITY_ERROR -STATUS_PARTIAL_COPY -STATUS_PARTITION_FAILURE -STATUS_PASSWORD_EXPIRED -STATUS_PASSWORD_MUST_CHANGE -STATUS_PASSWORD_RESTRICTION -STATUS_PATH_NOT_COVERED -STATUS_PENDING -STATUS_PIPE_BROKEN -STATUS_PIPE_BUSY -STATUS_PIPE_CLOSING -STATUS_PIPE_CONNECTED -STATUS_PIPE_DISCONNECTED -STATUS_PIPE_EMPTY -STATUS_PIPE_LISTENING -STATUS_PIPE_NOT_AVAILABLE -STATUS_PLUGPLAY_NO_DEVICE -STATUS_PORT_ALREADY_SET -STATUS_PORT_CONNECTION_REFUSED -STATUS_PORT_DISCONNECTED -STATUS_PORT_MESSAGE_TOO_LONG -STATUS_PORT_UNREACHABLE -STATUS_POSSIBLE_DEADLOCK -STATUS_PREDEFINED_HANDLE -STATUS_PRIMARY_TRANSPORT_CONNECT_FAILED -STATUS_PRINT_CANCELLED -STATUS_PRINT_QUEUE_FULL -STATUS_PRIVILEGED_INSTRUCTION -STATUS_PRIVILEGE_NOT_HELD -STATUS_PROCEDURE_NOT_FOUND -STATUS_PROCESS_IN_JOB -STATUS_PROCESS_IS_TERMINATING -STATUS_PROCESS_NOT_IN_JOB -STATUS_PROFILING_AT_LIMIT -STATUS_PROFILING_NOT_STARTED -STATUS_PROFILING_NOT_STOPPED -STATUS_PROPSET_NOT_FOUND -STATUS_PROTOCOL_UNREACHABLE -STATUS_PWD_HISTORY_CONFLICT -STATUS_PWD_TOO_RECENT -STATUS_PWD_TOO_SHORT -STATUS_QUOTA_EXCEEDED -STATUS_QUOTA_LIST_INCONSISTENT -STATUS_RANGE_LIST_CONFLICT -STATUS_RANGE_NOT_FOUND -STATUS_RANGE_NOT_LOCKED -STATUS_RECEIVE_EXPEDITED -STATUS_RECEIVE_PARTIAL -STATUS_RECEIVE_PARTIAL_EXPEDITED -STATUS_RECOVERY_FAILURE -STATUS_REDIRECTOR_HAS_OPEN_HANDLES -STATUS_REDIRECTOR_NOT_STARTED -STATUS_REDIRECTOR_PAUSED -STATUS_REDIRECTOR_STARTED -STATUS_REGISTRY_CORRUPT -STATUS_REGISTRY_IO_FAILED -STATUS_REGISTRY_QUOTA_LIMIT -STATUS_REGISTRY_RECOVERED -STATUS_REMOTE_DISCONNECT -STATUS_REMOTE_NOT_LISTENING -STATUS_REMOTE_RESOURCES -STATUS_REMOTE_SESSION_LIMIT -STATUS_REPARSE -STATUS_REPLY_MESSAGE_MISMATCH -STATUS_REQUEST_ABORTED -STATUS_REQUEST_NOT_ACCEPTED -STATUS_RESOURCE_DATA_NOT_FOUND -STATUS_RESOURCE_LANG_NOT_FOUND -STATUS_RESOURCE_NAME_NOT_FOUND -STATUS_RESOURCE_NOT_OWNED -STATUS_RESOURCE_TYPE_NOT_FOUND -STATUS_RETRY -STATUS_REVISION_MISMATCH -STATUS_RXACT_COMMITTED -STATUS_RXACT_COMMIT_FAILURE -STATUS_RXACT_COMMIT_NECESSARY -STATUS_RXACT_INVALID_STATE -STATUS_RXACT_STATE_CREATED -STATUS_SAM_INIT_FAILURE -STATUS_SECRET_TOO_LONG -STATUS_SECTION_NOT_EXTENDED -STATUS_SECTION_NOT_IMAGE -STATUS_SECTION_PROTECTION -STATUS_SECTION_TOO_BIG -STATUS_SEGMENT_NOTIFICATION -STATUS_SEMAPHORE_LIMIT_EXCEEDED -STATUS_SERIAL_COUNTER_TIMEOUT -STATUS_SERIAL_MORE_WRITES -STATUS_SERIAL_NO_DEVICE_INITED -STATUS_SERVER_DISABLED -STATUS_SERVER_HAS_OPEN_HANDLES -STATUS_SERVER_NOT_DISABLED -STATUS_SERVICE_NOTIFICATION -STATUS_SETMARK_DETECTED -STATUS_SHARED_IRQ_BUSY -STATUS_SHARING_PAUSED -STATUS_SHARING_VIOLATION -STATUS_SINGLE_STEP -STATUS_SOME_NOT_MAPPED -STATUS_SPECIAL_ACCOUNT -STATUS_SPECIAL_GROUP -STATUS_SPECIAL_USER -STATUS_STACK_OVERFLOW -STATUS_STACK_OVERFLOW_READ -STATUS_SUCCESS -STATUS_SUSPEND_COUNT_EXCEEDED -STATUS_SYNCHRONIZATION_REQUIRED -STATUS_SYSTEM_PROCESS_TERMINATED -STATUS_THREAD_IS_TERMINATING -STATUS_THREAD_NOT_IN_PROCESS -STATUS_THREAD_WAS_SUSPENDED -STATUS_TIMEOUT -STATUS_TIMER_NOT_CANCELED -STATUS_TIMER_RESOLUTION_NOT_SET -STATUS_TIMER_RESUME_IGNORED -STATUS_TIME_DIFFERENCE_AT_DC -STATUS_TOKEN_ALREADY_IN_USE -STATUS_TOO_LATE -STATUS_TOO_MANY_ADDRESSES -STATUS_TOO_MANY_COMMANDS -STATUS_TOO_MANY_CONTEXT_IDS -STATUS_TOO_MANY_GUIDS_REQUESTED -STATUS_TOO_MANY_LINKS -STATUS_TOO_MANY_LUIDS_REQUESTED -STATUS_TOO_MANY_NAMES -STATUS_TOO_MANY_NODES -STATUS_TOO_MANY_OPENED_FILES -STATUS_TOO_MANY_PAGING_FILES -STATUS_TOO_MANY_SECRETS -STATUS_TOO_MANY_SESSIONS -STATUS_TOO_MANY_SIDS -STATUS_TOO_MANY_THREADS -STATUS_TRANSACTION_ABORTED -STATUS_TRANSACTION_INVALID_ID -STATUS_TRANSACTION_INVALID_TYPE -STATUS_TRANSACTION_NO_MATCH -STATUS_TRANSACTION_NO_RELEASE -STATUS_TRANSACTION_RESPONDED -STATUS_TRANSACTION_TIMED_OUT -STATUS_TRUSTED_DOMAIN_FAILURE -STATUS_TRUSTED_RELATIONSHIP_FAILURE -STATUS_TRUST_FAILURE -STATUS_UNABLE_TO_DECOMMIT_VM -STATUS_UNABLE_TO_DELETE_SECTION -STATUS_UNABLE_TO_FREE_VM -STATUS_UNABLE_TO_LOCK_MEDIA -STATUS_UNABLE_TO_UNLOAD_MEDIA -STATUS_UNDEFINED_CHARACTER -STATUS_UNEXPECTED_IO_ERROR -STATUS_UNEXPECTED_MM_CREATE_ERR -STATUS_UNEXPECTED_MM_EXTEND_ERR -STATUS_UNEXPECTED_MM_MAP_ERROR -STATUS_UNEXPECTED_NETWORK_ERROR -STATUS_UNHANDLED_EXCEPTION -STATUS_UNKNOWN_REVISION -STATUS_UNMAPPABLE_CHARACTER -STATUS_UNRECOGNIZED_MEDIA -STATUS_UNRECOGNIZED_VOLUME -STATUS_UNSUCCESSFUL -STATUS_UNSUPPORTED_COMPRESSION -STATUS_UNWIND -STATUS_USER_APC -STATUS_USER_EXISTS -STATUS_USER_MAPPED_FILE -STATUS_USER_SESSION_DELETED -STATUS_VALIDATE_CONTINUE -STATUS_VARIABLE_NOT_FOUND -STATUS_VDM_HARD_ERROR -STATUS_VERIFY_REQUIRED -STATUS_VIRTUAL_CIRCUIT_CLOSED -STATUS_VOLUME_DISMOUNTED -STATUS_VOLUME_MOUNTED -STATUS_WAIT_0 -STATUS_WAIT_63 -STATUS_WAKE_SYSTEM_DEBUGGER -STATUS_WAS_LOCKED -STATUS_WAS_UNLOCKED -STATUS_WORKING_SET_LIMIT_RANGE -STATUS_WORKING_SET_QUOTA -STATUS_WRONG_PASSWORD -STATUS_WRONG_PASSWORD_CORE -STATUS_WRONG_VOLUME -STATUS_WX86_BREAKPOINT -STATUS_WX86_CONTINUE -STATUS_WX86_CREATEWX86TIB -STATUS_WX86_EXCEPTION_CHAIN -STATUS_WX86_EXCEPTION_CONTINUE -STATUS_WX86_EXCEPTION_LASTCHANCE -STATUS_WX86_FLOAT_STACK_CHECK -STATUS_WX86_INTERNAL_ERROR -STATUS_WX86_SINGLE_STEP -STATUS_WX86_UNSIMULATE \ No newline at end of file diff --git a/irc/ArchBlackmann/stru.txt b/irc/ArchBlackmann/stru.txt deleted file mode 100644 index e3a9ccd728d..00000000000 --- a/irc/ArchBlackmann/stru.txt +++ /dev/null @@ -1,7 +0,0 @@ -FAST_MUTEX -KPCR -PEB -TEB -SPINLOCK -APC -DPC diff --git a/irc/ArchBlackmann/tech.txt b/irc/ArchBlackmann/tech.txt deleted file mode 100644 index b95f426dcc9..00000000000 --- a/irc/ArchBlackmann/tech.txt +++ /dev/null @@ -1,73 +0,0 @@ -What do you think I am, your personal tech support? -You *know* a %stru% is non-re-entrant, right? -The answer to that is so simple, I'm not going to waste my time telling you. -Well, of course... if you're not below DISPATCH_LEVEL, ros is gonna explode on ya when you try to do that ( duh! ). -I don't think that functionality has been implemented, yet. -What do you mean it crashed? It can't crash there! -Wow. That's a new one. -Ask %dev%, I bet he knows.. he knows everything... -When's the last time you rebuilt? -Have you tried a make clean? -Is it plugged in? -Well it works on *my* system :P -Well don't do that, and you won't have that problem. -Didn't we already fix that? -Well... I don't know.. I just have that code disabled in my tree. -Try surrounding it with parenthesis. -Don't you know going around dereferncing null pointers all day can be hazardous to your health? -Well, duh! -There's a bit in cr3 for problems like that. -Just add a field to the %stru% to keep track of it! -Don't worry about it... the garbage collector in %module% will clean it up for you. -Did I do that? -Didn't %dev% fix that already? -Yes, I think I've seen that bug before... no... that was another program. -I could tell you, but then I'd have to unlink() you. -Well if you'd get some sleep, maybe you'd figure it out... not all of us can keep the hours %dev% can... -You did what? Uh oh... that can't be good. -Well... I could tell you, but the answer's pretty complicated. Why don't you wait to read about it in the book I'm writing. -Yeah, that's happened to me, before, too. All you have to do is wrap it in an SEH block and forget about it. -Just put a NULL dereference in there and commit it. It helps get bugs fixed fast! (Not that I would know) -ASSERT is your friend! -I dunno.. but I bet %dev% could find it for you. -I hereby declare that code is perfect. Your problem must be elsewhere. -I wrote that code... it must be perfect. -$#@!$ One of these days I'm gonna throw %module% out the window!!! Sorry, what were you saying? -maybe I broke it in my last commit. Maybe I did it on purpose... -Have you tried debugging it? I got a can of Raid... -Just delete it, it can't be that important ( You should see all the useless cruft I got rid of in %module% ) -Try queueing a work item... -My %stru% fell in love with some %stru% in %module%, and %module% has been hell since... -Maybe the PEB is getting corrupted. Try allocating a new PEB and overwriting the old one. That's what I did last time I had a bug like that. -Hmm.. that seems to have been introduced by my last commit... I bet CVS mixed up the bits during the commit. -It can't possibly be my fault, so I don't care. -I'm not experiencing that problem, perhaps it's all in your mind. -Well... like a good friend of mine said... "Don't Panic!" -It just shows you how far ReactOS has come along! A %period% ago a bug like that wouldn't have even been possible! -Just surround the code with an #if 0/#endif block, it solves all my problems! -You know.. if %dev% would just finish %module% for us, we wouldn't be having this problem. -I say we move on to the next function, since we can't seem to figure this one out. -Well, sure, that would have been my first guess, too.... TEN YEARS AGO :p -yup, that sounds like a problem. -If I wanted to talk about VB, I'd go bug Alex... -ask %dev% -Thank you for that amazingly keen insight, Commander Obvious. -Sorry, can't help you right now, trying to track down this bug %dev% caused in %module% -I dont know about that, but I just fixed a problem in %module% for %dev% -How should I know? I'm still trying to figure out this main() thing... ooh! wanna see what I did in %module%? -lol! -*wink* -;) -42 -It's gonna take me over %period% to fix all %dev%'s bugs in %module% :( -How could %func% return %status%!? It bet %dev% broke it! I didn't touch it... honest! no.. really! (me hides) -It's fine if you get %status% there ... just ignore the destruction, and call %func% instead. -%dev% said %status% isn't really an error in this context because we expect %module% to be toast by now -heh, I'm still trying to figure out why %func% is returning %status% when I call it from %module%... -%dev% said it's okay to ignore that as long as you're below %irql% -erm, what do you mean? -damn, I do that all the time -if you want a reply that sounds right, I'd say that %func% support for that is vital to the future of %module% -Sounds like you're having a problem with %func%. I hate that thing... don't talk to me about it. -Just return %status% and forget about it. Someone else will fix it, later. -Blah blah blah... sheesh... can't you figure out *anything*? \ No newline at end of file diff --git a/irc/ArchBlackmann/trim.cpp b/irc/ArchBlackmann/trim.cpp deleted file mode 100644 index c721f25dded..00000000000 --- a/irc/ArchBlackmann/trim.cpp +++ /dev/null @@ -1,17 +0,0 @@ -// trim.cpp -// This file is (C) 2004 Royce Mitchell III -// and released under the BSD & LGPL licenses - -#include "trim.h" - -std::string trim ( const std::string& s ) -{ - const char* p = &s[0]; - const char* p2 = p + s.size(); - while ( *p == ' ' ) - p++; - while ( p2 > p && p2[-1] == ' ' ) - p2--; - return std::string ( p, p2-p ); -} - diff --git a/irc/ArchBlackmann/trim.h b/irc/ArchBlackmann/trim.h deleted file mode 100644 index 4f2ba721f4b..00000000000 --- a/irc/ArchBlackmann/trim.h +++ /dev/null @@ -1,13 +0,0 @@ -// trim.h -// This file is (C) 2004 Royce Mitchell III -// and released under the BSD & LGPL licenses - -#ifndef TRIM_H -#define TRIM_H - -#include - -std::string trim ( const std::string& s ); - -#endif//TRIM_H - diff --git a/irc/ArchBlackmann/type.txt b/irc/ArchBlackmann/type.txt deleted file mode 100644 index 2e10f9f9882..00000000000 --- a/irc/ArchBlackmann/type.txt +++ /dev/null @@ -1,1000 +0,0 @@ -ACCESS_MASK -ACCESS_STATE -APC_LEVEL -ARBITER_ACTION -ARBITER_ACTION -ARBITER_CONFLICT_INFO -ARBITER_FLAG_BOOT_CONFIG -ARBITER_INTERFACE -ARBITER_LIST_ENTRY -ARBITER_PARAMETERS -ARBITER_PARTIAL -ARBITER_REQUEST_SOURCE -ARBITER_RESULT -AT_EXTENDABLE_FILE -AT_RESERVED -AT_ROUND_TO_PAGE -BOOTDISK_INFORMATION -BOOTDISK_INFORMATION_EX -BUS_INTERFACE_STANDARD -BUS_QUERY_ID_TYPE -BaseAddresses[PCI_TYPE0_ADDRESSES] -BaseAddresses[PCI_TYPE1_ADDRESSES] -CLIENT_ID -CLOCK1_LEVEL -CLOCK2_LEVEL -CM_EISA_FUNCTION_INFORMATION -CM_EISA_FUNCTION_INFORMATION.FunctionFlags -CM_EISA_SLOT_INFORMATION -CM_EISA_SLOT_INFORMATION.ReturnCode -CM_FLOPPY_DEVICE_DATA -CM_FULL_RESOURCE_DESCRIPTOR -CM_INT13_DRIVE_PARAMETER -CM_KEYBOARD_DEVICE_DATA -CM_MCA_POS_DATA -CM_PARTIAL_RESOURCE_DESCRIPTOR -CM_PARTIAL_RESOURCE_DESCRIPTOR.Flags -CM_PARTIAL_RESOURCE_DESCRIPTOR.ShareDisposition -CM_PARTIAL_RESOURCE_DESCRIPTOR.Type -CM_PARTIAL_RESOURCE_LIST -CM_POWER_DATA -CM_RESOURCE_DMA_16 -CM_RESOURCE_DMA_32 -CM_RESOURCE_DMA_8 -CM_RESOURCE_DMA_8_AND_16 -CM_RESOURCE_DMA_BUS_MASTER -CM_RESOURCE_DMA_TYPE_A -CM_RESOURCE_DMA_TYPE_B -CM_RESOURCE_DMA_TYPE_F -CM_RESOURCE_INTERRUPT_LATCHED -CM_RESOURCE_INTERRUPT_LEVEL_SENSITIVE -CM_RESOURCE_LIST -CM_RESOURCE_MEMORY_24 -CM_RESOURCE_MEMORY_CACHEABLE -CM_RESOURCE_MEMORY_COMBINEDWRITE -CM_RESOURCE_MEMORY_PREFETCHABLE -CM_RESOURCE_MEMORY_READ_ONLY -CM_RESOURCE_MEMORY_READ_WRITE -CM_RESOURCE_MEMORY_WRITE_ONLY -CM_RESOURCE_PORT_10_BIT_DECODE -CM_RESOURCE_PORT_12_BIT_DECODE -CM_RESOURCE_PORT_16_BIT_DECODE -CM_RESOURCE_PORT_IO -CM_RESOURCE_PORT_MEMORY -CM_RESOURCE_PORT_PASSIVE_DECODE -CM_RESOURCE_PORT_POSITIVE_DECODE -CM_RESOURCE_PORT_WINDOW_DECODE -CM_SCSI_DEVICE_DATA -CM_SERIAL_DEVICE_DATA -CM_SHARE_DISPOSITION -CONFIGURATION_INFORMATION -CONFIGURATION_TYPE -CONFIGURATION_TYPE -CONTAINING_RECORD -CONTROLLER_OBJECT -CREATE_DISK -CREATE_DISK_GPT -CREATE_DISK_MBR -CREATE_FILE_TYPE -CREATE_FILE_TYPE -DBG_STATUS_BUGCHECK_FIRST -DBG_STATUS_BUGCHECK_SECOND -DBG_STATUS_CONTROL_C -DBG_STATUS_DEBUG_CONTROL -DBG_STATUS_FATAL -DBG_STATUS_SYSRQ -DBG_STATUS_WORKER -DEVICE_CAPABILITIES -DEVICE_DESCRIPTION -DEVICE_DESCRIPTION.Version -DEVICE_DESCRIPTION_VERSION -DEVICE_DESCRIPTION_VERSION1 -DEVICE_DESCRIPTION_VERSION2 -DEVICE_INTERFACE_CHANGE_NOTIFICATION -DEVICE_OBJECT -DEVICE_OBJECT.AlignmentRequirement -DEVICE_OBJECT.Characteristics -DEVICE_OBJECT.DeviceType -DEVICE_OBJECT.Flags -DEVICE_POWER_STATE -DEVICE_REGISTRY_PROPERTY -DEVICE_REGISTRY_PROPERTY -DEVICE_RELATIONS -DEVICE_RELATION_TYPE -DEVICE_RELATION_TYPE -DEVICE_TEXT_TYPE -DEVICE_TYPE -DEVICE_USAGE_NOTIFICATION_TYPE -DIRECTORY_ALL_ACCESS -DIRECTORY_CREATE_OBJECT -DIRECTORY_CREATE_SUBDIRECTORY -DIRECTORY_QUERY -DIRECTORY_TRAVERSE -DISK_SIGNATURE -DISPATCHER_HEADER -DISPATCH_LEVEL -DMA_ADAPTER -DMA_CONFIGURATION_BYTE0 -DMA_CONFIGURATION_BYTE1 -DMA_OPERATIONS -DMA_SPEED -DMA_WIDTH -DO_BUFFERED_IO -DO_BUS_ENUMERATED_DEVICE -DO_DEVICE_HAS_NAME -DO_DEVICE_INITIALIZING -DO_DIRECT_IO -DO_EXCLUSIVE -DO_LONG_TERM_REQUESTS -DO_LOW_PRIORITY_FILESYSTEM -DO_MAP_IO_BUFFER -DO_NEVER_LAST_DEVICE -DO_POWER_INRUSH -DO_POWER_PAGABLE -DO_SHUTDOWN_REGISTERED -DO_SYSTEM_BOOT_PARTITION -DO_VERIFY_VOLUME -DRIVER_EXTENSION -DRIVER_OBJECT -DRIVER_VERIFIER_FORCE_IRQL_CHECKING -DRIVER_VERIFIER_INJECT_ALLOCATION_FAILURES -DRIVER_VERIFIER_IO_CHECKING -DRIVER_VERIFIER_SPECIAL_POOLING -DRIVER_VERIFIER_THUNK_PAIRS -DRIVER_VERIFIER_TRACK_POOL_ALLOCATIONS -DRIVE_LAYOUT_INFORMATION_GPT -DRIVE_LAYOUT_INFORMATION_MBR -DUPLICATE_CLOSE_SOURCE -DUPLICATE_SAME_ACCESS -DUPLICATE_SAME_ATTRIBUTES -EFLAG_SELECT -EFLAG_SIGN -EFLAG_ZERO -EISA_DMA_CONFIGURATION -EISA_EMPTY_SLOT -EISA_FREE_FORM_DATA -EISA_FUNCTION_ENABLED -EISA_HAS_DMA_ENTRY -EISA_HAS_INFORMATION -EISA_HAS_IRQ_ENTRY -EISA_HAS_MEMORY_ENTRY -EISA_HAS_PORT_INIT_ENTRY -EISA_HAS_PORT_RANGE -EISA_HAS_TYPE_ENTRY -EISA_INVALID_BIOS_CALL -EISA_INVALID_CONFIGURATION -EISA_INVALID_FUNCTION -EISA_INVALID_SLOT -EISA_IRQ_CONFIGURATION -EISA_IRQ_DESCRIPTOR -EISA_MEMORY_CONFIGURATION -EISA_MEMORY_TYPE -EISA_PORT_CONFIGURATION -EISA_PORT_DESCRIPTOR -ERESOURCE_THREAD -ES_CONTINUOUS -ES_DISPLAY_REQUIRED -ES_SYSTEM_REQUIRED -ES_USER_PRESENT -EVENT_INCREMENT -EVENT_TYPE -EVENT_TYPE -EXECUTION_STATE -EX_POOL_PRIORITY -EX_POOL_PRIORITY -FAST_IO_DISPATCH -FAST_MUTEX -FIELD_OFFSET -FILE_128_BYTE_ALIGNMENT -FILE_256_BYTE_ALIGNMENT -FILE_32_BYTE_ALIGNMENT -FILE_512_BYTE_ALIGNMENT -FILE_64_BYTE_ALIGNMENT -FILE_ADD_FILE -FILE_ADD_SUBDIRECTORY -FILE_ALIGNMENT_INFORMATION -FILE_ALL_ACCESS -FILE_ANY_ACCESS -FILE_APPEND_DATA -FILE_ATTRIBUTE_ARCHIVE -FILE_ATTRIBUTE_COMPRESSED -FILE_ATTRIBUTE_DEVICE -FILE_ATTRIBUTE_DIRECTORY -FILE_ATTRIBUTE_ENCRYPTED -FILE_ATTRIBUTE_HIDDEN -FILE_ATTRIBUTE_NORMAL -FILE_ATTRIBUTE_NOT_CONTENT_INDEXED -FILE_ATTRIBUTE_OFFLINE -FILE_ATTRIBUTE_READONLY -FILE_ATTRIBUTE_REPARSE_POINT -FILE_ATTRIBUTE_SPARSE_FILE -FILE_ATTRIBUTE_SYSTEM -FILE_ATTRIBUTE_TAG_INFORMATION -FILE_ATTRIBUTE_TEMPORARY -FILE_ATTRIBUTE_VALID_FLAGS -FILE_ATTRIBUTE_VALID_SET_FLAGS -FILE_AUTOGENERATED_DEVICE_NAME -FILE_BASIC_INFORMATION -FILE_BYTE_ALIGNMENT -FILE_COMPLETE_IF_OPLOCKED -FILE_COPY_STRUCTURED_STORAGE -FILE_CREATE -FILE_CREATED -FILE_CREATE_PIPE_INSTANCE -FILE_CREATE_TREE_CONNECTION -FILE_DELETE_CHILD -FILE_DELETE_ON_CLOSE -FILE_DEVICE_8042_PORT -FILE_DEVICE_ACPI -FILE_DEVICE_BATTERY -FILE_DEVICE_BEEP -FILE_DEVICE_BUS_EXTENDER -FILE_DEVICE_CD_ROM -FILE_DEVICE_CD_ROM_FILE_SYSTEM -FILE_DEVICE_CHANGER -FILE_DEVICE_CONTROLLER -FILE_DEVICE_DATALINK -FILE_DEVICE_DFS -FILE_DEVICE_DFS_FILE_SYSTEM -FILE_DEVICE_DFS_VOLUME -FILE_DEVICE_DISK -FILE_DEVICE_DISK_FILE_SYSTEM -FILE_DEVICE_DVD -FILE_DEVICE_FILE_SYSTEM -FILE_DEVICE_FIPS -FILE_DEVICE_FULLSCREEN_VIDEO -FILE_DEVICE_INPORT_PORT -FILE_DEVICE_IS_MOUNTED -FILE_DEVICE_KEYBOARD -FILE_DEVICE_KS -FILE_DEVICE_KSEC -FILE_DEVICE_MAILSLOT -FILE_DEVICE_MASS_STORAGE -FILE_DEVICE_MIDI_IN -FILE_DEVICE_MIDI_OUT -FILE_DEVICE_MODEM -FILE_DEVICE_MOUSE -FILE_DEVICE_MULTI_UNC_PROVIDER -FILE_DEVICE_NAMED_PIPE -FILE_DEVICE_NETWORK -FILE_DEVICE_NETWORK_BROWSER -FILE_DEVICE_NETWORK_FILE_SYSTEM -FILE_DEVICE_NETWORK_REDIRECTOR -FILE_DEVICE_NULL -FILE_DEVICE_PARALLEL_PORT -FILE_DEVICE_PHYSICAL_NETCARD -FILE_DEVICE_PRINTER -FILE_DEVICE_SCANNER -FILE_DEVICE_SCREEN -FILE_DEVICE_SECURE_OPEN -FILE_DEVICE_SERENUM -FILE_DEVICE_SERIAL_MOUSE_PORT -FILE_DEVICE_SERIAL_PORT -FILE_DEVICE_SMARTCARD -FILE_DEVICE_SMB -FILE_DEVICE_SOUND -FILE_DEVICE_STREAMS -FILE_DEVICE_TAPE -FILE_DEVICE_TAPE_FILE_SYSTEM -FILE_DEVICE_TERMSRV -FILE_DEVICE_TRANSPORT -FILE_DEVICE_UNKNOWN -FILE_DEVICE_VDM -FILE_DEVICE_VIDEO -FILE_DEVICE_VIRTUAL_DISK -FILE_DEVICE_WAVE_IN -FILE_DEVICE_WAVE_OUT -FILE_DIRECTORY_FILE -FILE_DISPOSITION_INFORMATION -FILE_DOES_NOT_EXIST -FILE_END_OF_FILE_INFORMATION -FILE_EXECUTE -FILE_EXISTS -FILE_FLOPPY_DISKETTE -FILE_FS_DEVICE_INFORMATION -FILE_FULL_EA_INFORMATION -FILE_GENERIC_EXECUTE -FILE_GENERIC_READ -FILE_GENERIC_WRITE -FILE_INFORMATION_CLASS -FILE_INFORMATION_CLASS -FILE_LIST_DIRECTORY -FILE_LONG_ALIGNMENT -FILE_MAXIMUM_DISPOSITION -FILE_NAME_INFORMATION -FILE_NETWORK_OPEN_INFORMATION -FILE_NON_DIRECTORY_FILE -FILE_NO_COMPRESSION -FILE_NO_EA_KNOWLEDGE -FILE_NO_INTERMEDIATE_BUFFERING -FILE_OBJECT.Flags -FILE_OBJECT -FILE_OCTA_ALIGNMENT -FILE_OPEN -FILE_OPENED -FILE_OPEN_BY_FILE_ID -FILE_OPEN_FOR_BACKUP_INTENT -FILE_OPEN_FOR_FREE_SPACE_QUERY -FILE_OPEN_FOR_RECOVERY -FILE_OPEN_IF -FILE_OPEN_NO_RECALL -FILE_OPEN_REPARSE_POINT -FILE_OVERWRITE -FILE_OVERWRITE_IF -FILE_OVERWRITTEN -FILE_POSITION_INFORMATION -FILE_QUAD_ALIGNMENT -FILE_RANDOM_ACCESS -FILE_READ_ACCESS -FILE_READ_ATTRIBUTES -FILE_READ_DATA -FILE_READ_EA -FILE_READ_ONLY_DEVICE -FILE_REMOTE_DEVICE -FILE_REMOVABLE_MEDIA -FILE_RESERVE_OPFILTER -FILE_SEQUENTIAL_ONLY -FILE_SHARE_DELETE -FILE_SHARE_READ -FILE_SHARE_VALID_FLAGS -FILE_SHARE_WRITE -FILE_SPECIAL_ACCESS -FILE_STANDARD_INFORMATION -FILE_STRUCTURED_STORAGE -FILE_SUPERSEDE -FILE_SUPERSEDED -FILE_SYNCHRONOUS_IO_ALERT -FILE_SYNCHRONOUS_IO_NONALERT -FILE_TRAVERSE -FILE_USE_FILE_POINTER_POSITION -FILE_VALID_DATA_LENGTH_INFORMATION -FILE_VALID_MAILSLOT_OPTION_FLAGS -FILE_VALID_OPTION_FLAGS -FILE_VALID_PIPE_OPTION_FLAGS -FILE_VALID_SET_FLAGS -FILE_VIRTUAL_VOLUME -FILE_WORD_ALIGNMENT -FILE_WRITE_ACCESS -FILE_WRITE_ATTRIBUTES -FILE_WRITE_DATA -FILE_WRITE_EA -FILE_WRITE_ONCE_MEDIA -FILE_WRITE_THROUGH -FILE_WRITE_TO_END_OF_FILE -FO_ALERTABLE_IO -FO_CACHE_SUPPORTED -FO_CLEANUP_COMPLETE -FO_DELETE_ON_CLOSE -FO_DIRECT_DEVICE_OPEN -FO_FILE_FAST_IO_READ -FO_FILE_MODIFIED -FO_FILE_OBJECT_HAS_EXTENSION -FO_FILE_OPEN -FO_FILE_OPEN_CANCELLED -FO_FILE_SIZE_CHANGED -FO_GENERATE_AUDIT_ON_CLOSE -FO_HANDLE_CREATED -FO_MAILSLOT -FO_NAMED_PIPE -FO_NO_INTERMEDIATE_BUFFERING -FO_OPENED_CASE_SENSITIVE -FO_RANDOM_ACCESS -FO_REMOTE_ORIGIN -FO_SEQUENTIAL_ONLY -FO_STREAM_FILE -FO_SYNCHRONOUS_IO -FO_TEMPORARY_FILE -FO_VOLUME_OPEN -FO_WRITE_THROUGH -FS_INFORMATION_CLASS -GENERAL_LOOKASIDE -GENERAL_LOOKASIDE_S -HASH_STRING_ALGORITHM_DEFAULT -HASH_STRING_ALGORITHM_INVALID -HASH_STRING_ALGORITHM_X65599 -HIGH_LEVEL -HIGH_PRIORITY -HWPROFILE_CHANGE_NOTIFICATION -IMAGE_ADDRESSING_MODE_32BIT -IMAGE_INFO -INITIAL_PRIVILEGE_COUNT -INITIAL_PRIVILEGE_SET -INTERFACE_TYPE -INTERFACE_TYPE -INTERLOCKED_RESULT -IO_ALLOCATION_ACTION -IO_ALLOCATION_ACTION -IO_CD_ROM_INCREMENT -IO_COMPLETION_CONTEXT -IO_CSQ -IO_CSQ_IRP_CONTEXT -IO_DISK_INCREMENT -IO_ERROR_LOG_PACKET -IO_KEYBOARD_INCREMENT -IO_MAILSLOT_INCREMENT -IO_MOUSE_INCREMENT -IO_NAMED_PIPE_INCREMENT -IO_NETWORK_INCREMENT -IO_NOTIFICATION_EVENT_CATEGORY -IO_NOTIFICATION_EVENT_CATEGORY -IO_NO_INCREMENT -IO_PARALLEL_INCREMENT -IO_REMOVE_LOCK -IO_REMOVE_LOCK_COMMON_BLOCK -IO_REMOVE_LOCK_DBG_BLOCK -IO_RESOURCE_ALTERNATIVE -IO_RESOURCE_DEFAULT -IO_RESOURCE_DESCRIPTOR -IO_RESOURCE_DESCRIPTOR -IO_RESOURCE_DESCRIPTOR.Option -IO_RESOURCE_LIST -IO_RESOURCE_PREFERRED -IO_RESOURCE_REQUIREMENTS_LIST -IO_SECURITY_CONTEXT -IO_SERIAL_INCREMENT -IO_SOUND_INCREMENT -IO_STACK_LOCATION -IO_STACK_LOCATION.Control -IO_STATUS_BLOCK -IO_VIDEO_INCREMENT -IPI_LEVEL -IRP_MJ_CLEANUP -IRP_MJ_CLOSE -IRP_MJ_CREATE -IRP_MJ_CREATE_MAILSLOT -IRP_MJ_CREATE_NAMED_PIPE -IRP_MJ_DEVICE_CHANGE -IRP_MJ_DEVICE_CONTROL -IRP_MJ_DIRECTORY_CONTROL -IRP_MJ_FILE_SYSTEM_CONTROL -IRP_MJ_FLUSH_BUFFERS -IRP_MJ_INTERNAL_DEVICE_CONTROL -IRP_MJ_LOCK_CONTROL -IRP_MJ_MAXIMUM_FUNCTION -IRP_MJ_PNP -IRP_MJ_PNP_POWER -IRP_MJ_POWER -IRP_MJ_QUERY_EA -IRP_MJ_QUERY_INFORMATION -IRP_MJ_QUERY_QUOTA -IRP_MJ_QUERY_SECURITY -IRP_MJ_QUERY_VOLUME_INFORMATION -IRP_MJ_READ -IRP_MJ_SCSI -IRP_MJ_SET_EA -IRP_MJ_SET_INFORMATION -IRP_MJ_SET_QUOTA -IRP_MJ_SET_SECURITY -IRP_MJ_SET_VOLUME_INFORMATION -IRP_MJ_SHUTDOWN -IRP_MJ_SYSTEM_CONTROL -IRP_MJ_WRITE -IRP_MN_CANCEL_REMOVE_DEVICE -IRP_MN_CANCEL_STOP_DEVICE -IRP_MN_CHANGE_SINGLE_INSTANCE -IRP_MN_CHANGE_SINGLE_ITEM -IRP_MN_COMPLETE -IRP_MN_COMPLETE_MDL -IRP_MN_COMPLETE_MDL_DPC -IRP_MN_COMPRESSED -IRP_MN_DEVICE_USAGE_NOTIFICATION -IRP_MN_DISABLE_COLLECTION -IRP_MN_DISABLE_EVENTS -IRP_MN_DPC -IRP_MN_EJECT -IRP_MN_ENABLE_COLLECTION -IRP_MN_ENABLE_EVENTS -IRP_MN_EXECUTE_METHOD -IRP_MN_FILTER_RESOURCE_REQUIREMENTS -IRP_MN_KERNEL_CALL -IRP_MN_LOAD_FILE_SYSTEM -IRP_MN_LOCK -IRP_MN_MDL -IRP_MN_MDL_DPC -IRP_MN_MOUNT_VOLUME -IRP_MN_NORMAL -IRP_MN_NOTIFY_CHANGE_DIRECTORY -IRP_MN_POWER_SEQUENCE -IRP_MN_QUERY_ALL_DATA -IRP_MN_QUERY_BUS_INFORMATION -IRP_MN_QUERY_CAPABILITIES -IRP_MN_QUERY_DEVICE_RELATIONS -IRP_MN_QUERY_DEVICE_TEXT -IRP_MN_QUERY_DIRECTORY -IRP_MN_QUERY_ID -IRP_MN_QUERY_INTERFACE -IRP_MN_QUERY_LEGACY_BUS_INFORMATION -IRP_MN_QUERY_PNP_DEVICE_STATE -IRP_MN_QUERY_POWER -IRP_MN_QUERY_REMOVE_DEVICE -IRP_MN_QUERY_RESOURCES -IRP_MN_QUERY_RESOURCE_REQUIREMENTS -IRP_MN_QUERY_SINGLE_INSTANCE -IRP_MN_QUERY_STOP_DEVICE -IRP_MN_READ_CONFIG -IRP_MN_REGINFO -IRP_MN_REGINFO_EX -IRP_MN_REMOVE_DEVICE -IRP_MN_SCSI_CLASS -IRP_MN_SET_LOCK -IRP_MN_SET_POWER -IRP_MN_START_DEVICE -IRP_MN_STOP_DEVICE -IRP_MN_SURPRISE_REMOVAL -IRP_MN_TRACK_LINK -IRP_MN_UNLOCK_ALL -IRP_MN_UNLOCK_ALL_BY_KEY -IRP_MN_UNLOCK_SINGLE -IRP_MN_USER_FS_REQUEST -IRP_MN_VERIFY_VOLUME -IRP_MN_WAIT_WAKE -IRP_MN_WRITE_CONFIG -KBUGCHECK_BUFFER_DUMP_STATE -KBUGCHECK_CALLBACK_RECORD -KDEVICE_QUEUE -KDEVICE_QUEUE_ENTRY -KDPC_DATA -KDPC_IMPORTANCE -KDPC_IMPORTANCE -KD_DEBUGGER_ENABLED -KD_DEBUGGER_NOT_PRESENT -KEYBOARD_ALT_KEY_DOWN -KEYBOARD_CAPS_LOCK_ON -KEYBOARD_CTRL_KEY_DOWN -KEYBOARD_INSERT_ON -KEYBOARD_LEFT_SHIFT_DOWN -KEYBOARD_NUM_LOCK_ON -KEYBOARD_RIGHT_SHIFT_DOWN -KEYBOARD_SCROLL_LOCK_ON -KEY_BASIC_INFORMATION -KEY_FULL_INFORMATION -KEY_INFORMATION_CLASS -KEY_INFORMATION_CLASS -KEY_NODE_INFORMATION -KEY_VALUE_BASIC_INFORMATION -KEY_VALUE_ENTRY -KEY_VALUE_FULL_INFORMATION -KEY_VALUE_INFORMATION_CLASS -KEY_VALUE_INFORMATION_CLASS -KEY_VALUE_PARTIAL_INFORMATION -KEY_VALUE_PARTIAL_INFORMATION_ALIGN64 -KEY_VALUE_Xxx.Type -KFLOATING_SAVE -KINTERRUPT_MODE -KINTERRUPT_MODE -KI_USER_SHARED_DATA -KLOCK_QUEUE_HANDLE -KPCR_TIB -KPROCESSOR_MODE -KPROFILE_SOURCE -KSPIN_LOCK_QUEUE -KSPIN_LOCK_QUEUE_NUMBER -KWAIT_BLOCK -KWAIT_REASON -KWAIT_REASON -LARGE_INTEGER -LOCK_OPERATION -LOCK_OPERATION -LOCK_QUEUE_OWNER -LOCK_QUEUE_WAIT -LOW_LEVEL -LOW_PRIORITY -LOW_REALTIME_PRIORITY -MAXIMUM_PRIORITY -MAXIMUM_PROCESSORS -MAXIMUM_VOLUME_LABEL_LENGTH -MAXIMUM_WAIT_OBJECTS -MDL_ALLOCATED_FIXED_SIZE -MDL_ALLOCATED_MUST_SUCCEED -MDL_FREE_EXTRA_PTES -MDL_IO_PAGE_READ -MDL_IO_SPACE -MDL_MAPPED_TO_SYSTEM_VA -MDL_MAPPING_CAN_FAIL -MDL_MAPPING_FLAGS -MDL_NETWORK_HEADER -MDL_PAGES_LOCKED -MDL_PARENT_MAPPED_SYSTEM_VA -MDL_PARTIAL -MDL_PARTIAL_HAS_BEEN_MAPPED -MDL_SOURCE_IS_NONPAGED_POOL -MDL_SOURCE_IS_NONPAGED_POOL -MDL_WRITE_OPERATION -MEMORY_CACHING_TYPE -MEMORY_CACHING_TYPE -MEMORY_CACHING_TYPE_ORIG -METHOD_BUFFERED -METHOD_IN_DIRECT -METHOD_NEITHER -METHOD_OUT_DIRECT -MMFLUSH_TYPE -MMFLUSH_TYPE -MM_HIGHEST_USER_ADDRESS -MM_LOWEST_SYSTEM_ADDRESS -MM_LOWEST_USER_ADDRESS -MM_PAGE_PRIORITY -MM_PAGE_PRIORITY -MM_SYSTEM_RANGE_START -MM_SYSTEM_SIZE -MM_USER_PROBE_ADDRESS -MajorFunction[IRP_MJ_MAXIMUM_FUNCTION -NPAGED_LOOKASIDE_LIST -OBJECT_HANDLE_INFORMATION -OBJECT_NAME_INFORMATION -OWNER_ENTRY -PACCESS_MASK -PACCESS_STATE -PAGED_LOOKASIDE_LIST -PAGE_SHIFT -PAGE_SIZE -PALLOCATE_FUNCTION -PANSI_STRING -PARBITER_CONFLICT_INFO -PARTITION_INFORMATION_MBR -PARTITION_STYLE -PASSIVE_LEVEL -PCALLBACK_FUNCTION -PCALLBACK_OBJECT -PCI_BRIDGE_TYPE -PCI_CARDBUS_BRIDGE_TYPE -PCI_COMMON_CONFIG -PCI_COMMON_CONFIG.Command -PCI_COMMON_CONFIG.HeaderType -PCI_COMMON_CONFIG.Status -PCI_DEVICE_TYPE -PCI_ENABLE_BUS_MASTER -PCI_ENABLE_FAST_BACK_TO_BACK -PCI_ENABLE_IO_SPACE -PCI_ENABLE_MEMORY_SPACE -PCI_ENABLE_PARITY -PCI_ENABLE_SERR -PCI_ENABLE_SPECIAL_CYCLES -PCI_ENABLE_VGA_COMPATIBLE_PALETTE -PCI_ENABLE_WAIT_CYCLE -PCI_ENABLE_WRITE_AND_INVALIDATE -PCI_MULTIFUNCTION -PCI_SLOT_NUMBER -PCI_STATUS_66MHZ_CAPABLE -PCI_STATUS_CAPABILITIES_LIST -PCI_STATUS_DATA_PARITY_DETECTED -PCI_STATUS_DETECTED_PARITY_ERROR -PCI_STATUS_DEVSEL -PCI_STATUS_FAST_BACK_TO_BACK -PCI_STATUS_RECEIVED_MASTER_ABORT -PCI_STATUS_RECEIVED_TARGET_ABORT -PCI_STATUS_SIGNALED_SYSTEM_ERROR -PCI_STATUS_SIGNALED_TARGET_ABORT -PCI_STATUS_UDF_SUPPORTED -PCI_TYPE0_ADDRESSES -PCI_TYPE1_ADDRESSES -PCI_TYPE2_ADDRESSES -PCLIENT_ID -PCM_PARTIAL_RESOURCE_DESCRIPTOR -PCM_PARTIAL_RESOURCE_LIST -PCM_RESOURCE_LIST -PCONFIGURATION_TYPE -PCONTROLLER_OBJECT -PCREATE_DISK -PCREATE_PROCESS_NOTIFY_ROUTINE -PCREATE_THREAD_NOTIFY_ROUTINE -PCR_MAJOR_VERSION -PCR_MINOR_VERSION -PCUNICODE_STRING -PDCAP_D0_SUPPORTED -PDCAP_D1_SUPPORTED -PDCAP_D2_SUPPORTED -PDCAP_D3_SUPPORTED -PDCAP_WAKE_FROM_D0_SUPPORTED -PDCAP_WAKE_FROM_D1_SUPPORTED -PDCAP_WAKE_FROM_D2_SUPPORTED -PDCAP_WAKE_FROM_D3_SUPPORTED -PDCAP_WARM_EJECT_SUPPORTED -PDEVICE_CHANGE_COMPLETE_CALLBACK -PDEVICE_DESCRIPTION -PDEVICE_OBJECT -PDISK_SIGNATURE -PDMA_ADAPTER -PDRIVER_CANCEL -PDRIVER_CONTROL -PDRIVER_LIST_CONTROL -PDRIVER_NOTIFICATION_CALLBACK_ROUTINE -PDRIVER_OBJECT -PDRIVER_REINITIALIZE -PD_Capabilities -PD_D1Latency -PD_D2Latency -PD_D3Latency -PD_MostRecentPowerState -PD_PowerStateMapping[PowerSystemMaximum] -PD_Size -PEX_CALLBACK_FUNCTION -PFAST_MUTEX -PFILE_BASIC_INFORMATION -PFILE_NETWORK_OPEN_INFORMATION -PFILE_OBJECT -PFILE_STANDARD_INFORMATION -PFREE_FUNCTION -PGENERIC_MAPPING -PHYSICAL_ADDRESS -PHYSICAL_MEMORY_RANGE -PIMAGE_INFO -PINTERFACE_TYPE -PIO_APC_ROUTINE -PIO_COMPLETION_ROUTINE -PIO_CSQ -PIO_CSQ_ACQUIRE_LOCK -PIO_CSQ_COMPLETE_CANCELED_IRP -PIO_CSQ_INSERT_IRP -PIO_CSQ_IRP_CONTEXT -PIO_CSQ_PEEK_NEXT_IRP -PIO_CSQ_RELEASE_LOCK -PIO_CSQ_REMOVE_IRP -PIO_QUERY_DEVICE_ROUTINE -PIO_REMOVE_LOCK -PIO_RESOURCE_DESCRIPTOR -PIO_RESOURCE_REQUIREMENTS_LIST -PIO_STACK_LOCATION -PIO_STATUS_BLOCK -PIO_TIMER_ROUTINE -PIO_WORKITEM -PIO_WORKITEM_ROUTINE -PKBUGCHECK_CALLBACK_RECORD -PKBUGCHECK_CALLBACK_ROUTINE -PKDEFERRED_ROUTINE -PKDEVICE_QUEUE -PKDEVICE_QUEUE_ENTRY -PKEY_VALUE_FULL_INFORMATION -PKFLOATING_SAVE -PKKERNEL_ROUTINE -PKLOCK_QUEUE_HANDLE -PKNORMAL_ROUTINE -PKRUNDOWN_ROUTINE -PKSERVICE_ROUTINE -PKSPIN_LOCK -PKSTART_ROUTINE -PKSYNCHRONIZE_ROUTINE -PKWAIT_BLOCK -PLARGE_INTEGER -PLIST_ENTRY -PLOAD_IMAGE_NOTIFY_ROUTINE -PLUGPLAY_NOTIFICATION_HEADER -PLUGPLAY_REGKEY_CURRENT_HWPROFILE -PLUGPLAY_REGKEY_DEVICE -PLUGPLAY_REGKEY_DRIVER -PNPAGED_LOOKASIDE_LIST -PNPNOTIFY_DEVICE_INTERFACE_INCLUDE_EXISTING_INTERFACES -PNP_BUS_INFORMATION -PNP_DEVICE_DISABLED -PNP_DEVICE_DONT_DISPLAY_IN_UI -PNP_DEVICE_FAILED -PNP_DEVICE_NOT_DISABLEABLE -PNP_DEVICE_REMOVED -PNP_DEVICE_RESOURCE_REQUIREMENTS_CHANGED -PNP_DEVICE_STATE -POBJECT_ATTRIBUTES -POBJECT_HANDLE_INFORMATION -POBJECT_TYPE -POINTER_ALIGNMENT -POOL_TAGGING -POOL_TYPE -POOL_TYPE -POWER_LEVEL -POWER_SEQUENCE -POWER_STATE -POWER_STATE -POWER_STATE_TYPE -POWER_STATE_TYPE -PPAGED_LOOKASIDE_LIST -PPFN_NUMBER -PPHYSICAL_ADDRESS -PPRIVILEGE_SET -PP_LOOKASIDE_LIST -PREQUEST_POWER_COMPLETE -PRIVILEGE_SET.Control -PRIVILEGE_SET_ALL_NECESSARY -PRKDEVICE_QUEUE_ENTRY -PROFILE_LEVEL -PROTECTED_POOL -PRTL_BITMAP -PRTL_BITMAP_RUN -PRTL_CONFLICT_RANGE_CALLBACK -PRTL_OSVERSIONINFOEXW -PRTL_QUERY_REGISTRY_TABLE -PRTL_RANGE -PRTL_RANGE_LIST -PRTL_RANGE_LIST_ITERATOR -PSCATTER_GATHER_LIST -PSECTION_OBJECT -PSECTION_OBJECT_POINTERS -PSECURITY_DESCRIPTOR -PSECURITY_SUBJECT_CONTEXT -PSHARE_ACCESS -PSINGLE_LIST_ENTRY -PSIZE_T -PSLIST_ENTRY -PSLIST_HEADER -PSYSCTL_IRP_DISPOSITION -PTIMER_APC_ROUTINE -PTIME_FIELDS -PTIME_UPDATE_NOTIFY_ROUTINE -PULONG_PTR -PUNICODE_STRING -PWMILIB_CONTEXT -Privilege[INITIAL_PRIVILEGE_COUNT] -REG_BINARY -REG_DWORD -REG_DWORD_BIG_ENDIAN -REG_DWORD_LITTLE_ENDIAN -REG_EXPAND_SZ -REG_FULL_RESOURCE_DESCRIPTOR -REG_LINK -REG_MULTI_SZ -REG_NONE -REG_QWORD -REG_QWORD_LITTLE_ENDIAN -REG_RESOURCE_LIST -REG_RESOURCE_REQUIREMENTS_LIST -REG_SZ -RESOURCE_HASH_TABLE_SIZE -RESOURCE_TRANSLATION_DIRECTION -RESOURCE_TRANSLATION_DIRECTION -RESTRICTED_POINTER -RESULT_NEGATIVE -RESULT_POSITIVE -RESULT_ZERO -RTL_BITMAP -RTL_BITMAP_RUN -RTL_OSVERSIONINFOEXW -RTL_OSVERSIONINFOW -RTL_QUERY_REGISTRY_DELETE -RTL_QUERY_REGISTRY_DIRECT -RTL_QUERY_REGISTRY_NOEXPAND -RTL_QUERY_REGISTRY_NOVALUE -RTL_QUERY_REGISTRY_REQUIRED -RTL_QUERY_REGISTRY_SUBKEY -RTL_QUERY_REGISTRY_TABLE -RTL_QUERY_REGISTRY_TABLE.Flags -RTL_QUERY_REGISTRY_TOPKEY -RTL_RANGE -RTL_RANGE_CONFLICT -RTL_RANGE_LIST -RTL_RANGE_LIST_ADD_IF_CONFLICT -RTL_RANGE_LIST_ADD_SHARED -RTL_RANGE_LIST_ITERATOR -RTL_RANGE_LIST_MERGE_IF_CONFLICT -RTL_RANGE_LIST_NULL_CONFLICT_OK -RTL_RANGE_LIST_SHARED_OK -RTL_RANGE_SHARED -RTL_REGISTRY_ABSOLUTE -RTL_REGISTRY_CONTROL -RTL_REGISTRY_DEVICEMAP -RTL_REGISTRY_HANDLE -RTL_REGISTRY_OPTIONAL -RTL_REGISTRY_SERVICES -RTL_REGISTRY_USER -RTL_REGISTRY_WINDOWS_NT -Range[PCI_TYPE2_ADDRESSES -SCATTER_GATHER_ELEMENT -SCATTER_GATHER_LIST -SECTION_INHERIT -SECTION_OBJECT_POINTERS -SECURITY_INFORMATION -SECURITY_OPERATION_CODE -SECURITY_SUBJECT_CONTEXT -SEC_NO_CHANGE -SEMAPHORE_INCREMENT -SHARE_ACCESS -SIZE_T -SL_ALLOW_RAW_MOUNT -SL_CASE_SENSITIVE -SL_EXCLUSIVE_LOCK -SL_FAIL_IMMEDIATELY -SL_FORCE_ACCESS_CHECK -SL_FT_SEQUENTIAL_WRITE -SL_INDEX_SPECIFIED -SL_INVOKE_ON_CANCEL -SL_INVOKE_ON_ERROR -SL_INVOKE_ON_SUCCESS -SL_KEY_SPECIFIED -SL_OPEN_PAGING_FILE -SL_OPEN_TARGET_DIRECTORY -SL_OVERRIDE_VERIFY_VOLUME -SL_PENDING_RETURNED -SL_RESTART_SCAN -SL_RETURN_SINGLE_ENTRY -SL_WATCH_TREE -SL_WRITE_THROUGH -SSDT_ENTRY -SUITE_TYPE -SUITE_TYPE -SYMBOLIC_LINK_ALL_ACCESS -SYMBOLIC_LINK_QUERY -SYNCH_LEVEL -TARGET_DEVICE_CUSTOM_NOTIFICATION -TARGET_DEVICE_REMOVAL_NOTIFICATION -TIMER_TYPE -TIMER_TYPE -TIME_FIELDS -TRACE_INFORMATION_CLASS -TRACE_INFORMATION_CLASS -TRANSLATOR_INTERFACE -ULONG_PTR -VER_AND -VER_BUILDNUMBER -VER_CONDITION_MASK -VER_EQUAL -VER_GREATER -VER_GREATER_EQUAL -VER_LESS -VER_LESS_EQUAL -VER_MAJORVERSION -VER_MINORVERSION -VER_NUM_BITS_PER_CONDITION_MASK -VER_OR -VER_PLATFORMID -VER_PRODUCT_TYPE -VER_SERVICEPACKMAJOR -VER_SERVICEPACKMINOR -VER_SUITENAME -VPB_LOCKED -VPB_MOUNTED -VPB_PERSISTENT -VPB_RAW_MOUNT -VPB_REMOVE_PENDING -VolumeLabel[MAXIMUM_VOLUME_LABEL_LENGTH -WAIT_CONTEXT_BLOCK -WAIT_TYPE -WMI_NOTIFICATION_CALLBACK -WORK_QUEUE_ITEM -WORK_QUEUE_TYPE -WORK_QUEUE_TYPE -DEVICE_DESCRIPTION -DEVICE_OBJECT -DEVICE_OBJECT -DEVOBJ_EXTENSION -DMA_ADAPTER -DRIVER_CONTROL -DRIVER_OBJECT -DRIVER_OBJECT -EPROCESS -FILE_OBJECT -FILE_OBJECT -FirstEntry -GENERAL_LOOKASIDE -IO_CSQ -IO_CSQ -IO_STACK_LOCATION -IO_STATUS_BLOCK -IRP -IRP -IrpSp -IrpSp -KAPC -KDPC -KDPC -KPCR -KPCR -KPRCB -KPRCB -KSPIN_LOCK_QUEUE -KTHREAD -KTSS -KTSS -KWAIT_BLOCK -ListEntry -MDL -MDL -NT_TIB -NextIrpSp -PCI_HEADER_TYPE_0 -PCI_HEADER_TYPE_1 -PCI_HEADER_TYPE_2 -SCATTER_GATHER_LIST -SCSI_REQUEST_BLOCK -SECTION_OBJECT -SET_PARTITION_INFORMATION_EX -X86_ -va_list -TIMER_TYPE -ULONG -VOID diff --git a/irc/ArchBlackmann/verify.h b/irc/ArchBlackmann/verify.h deleted file mode 100644 index 5d491cfef41..00000000000 --- a/irc/ArchBlackmann/verify.h +++ /dev/null @@ -1,37 +0,0 @@ -// verify.h -// This code is (C) 2003-2004 Royce Mitchell III -// and released under the LGPL & BSD licenses - -#ifndef VERIFY_H -#define VERIFY_H - -//#include - -#ifdef ASSERT -#undef ASSERT -#endif//ASSERT - -#include "panic.h" - -#if defined(DEBUG) || defined(_DEBUG) -inline void AssertHandler ( bool b, const char* str ) -{ - if ( !b ) - panic ( str ); -} -# define ASSERT(x) AssertHandler((x) ? true : false, #x ) -#else -# define ASSERT(x) -#endif - -#ifdef verify -#undef verify -#endif//verify - -#if defined(DEBUG) || defined(_DEBUG) -# define verify(x) ASSERT(x) -#else -# define verify(x) x -#endif - -#endif//VERIFY_H diff --git a/irc/TechBot/CHMLibrary/AssemblyInfo.cs b/irc/TechBot/CHMLibrary/AssemblyInfo.cs deleted file mode 100644 index dbacda112e8..00000000000 --- a/irc/TechBot/CHMLibrary/AssemblyInfo.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; - -// Information about this assembly is defined by the following -// attributes. -// -// change them to the information which is associated with the assembly -// you compile. - -[assembly: AssemblyTitle("")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("")] -[assembly: AssemblyCopyright("")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// The assembly version has following format : -// -// Major.Minor.Build.Revision -// -// You can specify all values by your own or you can build default build and revision -// numbers with the '*' character (the default): - -[assembly: AssemblyVersion("1.0.*")] - -// The following attributes specify the key for the sign of your assembly. See the -// .NET Framework documentation for more information about signing. -// This is not required, if you don't want signing let these attributes like they're. -[assembly: AssemblyDelaySign(false)] -[assembly: AssemblyKeyFile("")] diff --git a/irc/TechBot/CHMLibrary/CHMDecoding/BinaryReaderHelp.cs b/irc/TechBot/CHMLibrary/CHMDecoding/BinaryReaderHelp.cs deleted file mode 100644 index 64c9668eb30..00000000000 --- a/irc/TechBot/CHMLibrary/CHMDecoding/BinaryReaderHelp.cs +++ /dev/null @@ -1,274 +0,0 @@ -using System; -using System.Collections; -using System.IO; -using System.Text; -using System.Globalization; - -namespace HtmlHelp.ChmDecoding -{ - /// - /// The class BinaryReaderHelp implements static helper methods for extracting binary data - /// from a binary reader object. - /// - internal class BinaryReaderHelp - { - /// - /// Internal helper method to extract null-terminated strings from a binary reader - /// - /// reference to the binary reader - /// offset in the stream - /// true if the offset value should be used - /// encoder used for text encoding - /// An extracted string value - internal static string ExtractString(ref BinaryReader binReader, int offset, bool noOffset, Encoding encoder) - { - string strReturn = ""; - - if(encoder == null) - encoder = Encoding.ASCII; - - ArrayList nameBytes = new ArrayList(); - byte curByte; - - if(!noOffset) - binReader.BaseStream.Seek(offset, SeekOrigin.Begin); - - if(binReader.BaseStream.Position >= binReader.BaseStream.Length) - return ""; - - curByte = binReader.ReadByte(); - while( (curByte != (byte)0) && (binReader.BaseStream.Position < binReader.BaseStream.Length) ) - { - nameBytes.Add( curByte ); - curByte = binReader.ReadByte(); - } - - byte[] name = (byte[]) (nameBytes.ToArray(System.Type.GetType("System.Byte"))); - strReturn = encoder.GetString(name,0,name.Length); - - return strReturn; - } - - /// - /// Internal helper method to extract a string with a specific length from the binary reader - /// - /// reference to the binary reader - /// length of the string (number of bytes) - /// offset in the stream - /// true if the offset value should be used - /// encoder used for text encoding - /// An extracted string value - internal static string ExtractString(ref BinaryReader binReader, int length, int offset, bool noOffset, Encoding encoder) - { - string strReturn = ""; - - if(length == 0) - return ""; - - if(encoder == null) - encoder = Encoding.ASCII; - - ArrayList nameBytes = new ArrayList(); - byte curByte; - - if(!noOffset) - binReader.BaseStream.Seek(offset, SeekOrigin.Begin); - - if(binReader.BaseStream.Position >= binReader.BaseStream.Length) - return ""; - - curByte = binReader.ReadByte(); - while( (curByte != (byte)0) && (nameBytes.Count < length) && (binReader.BaseStream.Position < binReader.BaseStream.Length) ) - { - nameBytes.Add( curByte ); - - if(nameBytes.Count < length) - curByte = binReader.ReadByte(); - } - - byte[] name = (byte[]) (nameBytes.ToArray(System.Type.GetType("System.Byte"))); - strReturn = encoder.GetString(name,0,name.Length); - - return strReturn; - } - - /// - /// Internal helper method to extract a string with a specific length from the binary reader - /// - /// reference to the binary reader - /// reference to a bool vairable which will receive true if the - /// string terminator \0 was found. false indicates that the end of the stream was reached. - /// offset in the stream - /// true if the offset value should be used - /// encoder used for text encoding - /// An extracted string value - internal static string ExtractString(ref BinaryReader binReader, ref bool bFoundTerminator, int offset, bool noOffset, Encoding encoder) - { - string strReturn = ""; - - ArrayList nameBytes = new ArrayList(); - byte curByte; - - if(encoder == null) - encoder = Encoding.ASCII; - - if(!noOffset) - binReader.BaseStream.Seek(offset, SeekOrigin.Begin); - - if(binReader.BaseStream.Position >= binReader.BaseStream.Length) - return ""; - - curByte = binReader.ReadByte(); - while( (curByte != (byte)0) && (binReader.BaseStream.Position < binReader.BaseStream.Length) ) - { - nameBytes.Add( curByte ); - curByte = binReader.ReadByte(); - - if( curByte == (byte)0 ) - { - bFoundTerminator = true; - } - } - - byte[] name = (byte[]) (nameBytes.ToArray(System.Type.GetType("System.Byte"))); - strReturn = encoder.GetString(name,0,name.Length); - - return strReturn; - } - - /// - /// Internal helper method to extract a null-terminated UTF-16/UCS-2 strings from a binary reader - /// - /// reference to the binary reader - /// offset in the stream - /// true if the offset value should be used - /// encoder used for text encoding - /// An extracted string value - internal static string ExtractUTF16String(ref BinaryReader binReader, int offset, bool noOffset, Encoding encoder) - { - string strReturn = ""; - - ArrayList nameBytes = new ArrayList(); - byte curByte; - int lastByte=-1; - - if(!noOffset) - binReader.BaseStream.Seek(offset, SeekOrigin.Begin); - - if(binReader.BaseStream.Position >= binReader.BaseStream.Length) - return ""; - - if(encoder == null) - encoder = Encoding.Unicode; - - curByte = binReader.ReadByte(); - int nCnt = 0; - while( ((curByte != (byte)0) || (lastByte != 0) ) && (binReader.BaseStream.Position < binReader.BaseStream.Length) ) - { - nameBytes.Add( curByte ); - - if(nCnt%2 == 0) - lastByte = (int)curByte; - - curByte = binReader.ReadByte(); - - nCnt++; - } - - byte[] name = (byte[]) (nameBytes.ToArray(System.Type.GetType("System.Byte"))); - strReturn = Encoding.Unicode.GetString(name,0,name.Length); - - // apply text encoding - name = Encoding.Default.GetBytes(strReturn); - strReturn = encoder.GetString(name,0,name.Length); - - return strReturn; - } - - /// - /// Internal helper for reading ENCINT encoded integer values - /// - /// reference to the reader - /// a long value - internal static long ReadENCINT(ref BinaryReader binReader) - { - long nRet = 0; - byte buffer = 0; - int shift = 0; - - if(binReader.BaseStream.Position >= binReader.BaseStream.Length) - return nRet; - - do - { - buffer = binReader.ReadByte(); - nRet |= ((long)((buffer & (byte)0x7F))) << shift; - shift += 7; - - }while ( (buffer & (byte)0x80) != 0); - - return nRet; - } - - /// - /// Reads an s/r encoded value from the byte array and decodes it into an integer - /// - /// a byte array containing all bits (contains only 0 or 1 elements) - /// scale param for encoding - /// root param for encoding - /// current index in the wclBits array - /// Returns an decoded integer value. - internal static int ReadSRItem(byte[] wclBits, int s, int r, ref int nBitIndex) - { - int nRet = 0; - int q = r; - - int nPref1Cnt = 0; - - while( wclBits[nBitIndex++] == 1) - { - nPref1Cnt++; - } - - if(nPref1Cnt == 0) - { - int nMask = 0; - - for(int nbits=0; nbits - /// The class CHMBtree implements methods/properties to decode the binary help index. - /// This class automatically creates an index arraylist for the current CHMFile instance. - /// It does not store the index internally ! - /// - /// The binary index can be found in the storage file $WWKeywordLinks/BTree - internal sealed class CHMBtree : IDisposable - { - /// - /// Constant specifying the size of the string blocks - /// - private const int BLOCK_SIZE = 2048; - /// - /// Internal flag specifying if the object is going to be disposed - /// - private bool disposed = false; - /// - /// Internal member storing the binary file data - /// - private byte[] _binaryFileData = null; - /// - /// Internal member storing flags - /// - private int _flags = 0; - /// - /// Internal member storing the data format - /// - private byte[] _dataFormat = new byte[16]; - /// - /// Internal member storing the index of the last listing block - /// - private int _indexOfLastListingBlock = 0; - /// - /// Internal member storing the index of the root block - /// - private int _indexOfRootBlock = 0; - /// - /// Internal member storing the number of blocks - /// - private int _numberOfBlocks = 0; - /// - /// Internal member storing the tree depth. - /// (1 if no index blocks, 2 one level of index blocks, ...) - /// - private int _treeDepth = 0; - /// - /// Internal member storing the number of keywords in the file - /// - private int _numberOfKeywords = 0; - /// - /// Internal member storing the codepage - /// - private int _codePage = 0; - /// - /// true if the index is from a CHI or CHM file, else CHW - /// - private bool _isCHI_CHM = true; - /// - /// Internal member storing the associated chmfile object - /// - private CHMFile _associatedFile = null; - /// - /// Internal flag specifying if we have to read listing or index blocks - /// - private bool _readListingBlocks = true; - /// - /// Internal member storing an indexlist of the current file. - /// - private ArrayList _indexList = new ArrayList(); - - /// - /// Constructor of the class - /// - /// binary file data of the $WWKeywordLinks/BTree file - /// associated chm file - public CHMBtree(byte[] binaryFileData, CHMFile associatedFile) - { - if( associatedFile == null) - { - throw new ArgumentException("CHMBtree.ctor() - Associated CHMFile must not be null !", "associatedFile"); - } - - _binaryFileData = binaryFileData; - _associatedFile = associatedFile; - DecodeData(); - - // clear internal binary data after extraction - _binaryFileData = null; - } - - /// - /// Decodes the binary file data and fills the internal properties - /// - /// true if succeeded - private bool DecodeData() - { - bool bRet = true; - - MemoryStream memStream = new MemoryStream(_binaryFileData); - BinaryReader binReader = new BinaryReader(memStream); - - int nCurOffset = 0; - int nTemp = 0; - - // decode header - binReader.ReadChars(2); // 2chars signature (not important) - - _flags = (int)binReader.ReadInt16(); // WORD flags - - binReader.ReadInt16(); // size of blocks (always 2048) - - _dataFormat = binReader.ReadBytes(16); - - binReader.ReadInt32(); // unknown DWORD - - _indexOfLastListingBlock = binReader.ReadInt32(); - _indexOfRootBlock = binReader.ReadInt32(); - - binReader.ReadInt32(); // unknown DWORD - - _numberOfBlocks = binReader.ReadInt32(); - _treeDepth = binReader.ReadInt16(); - _numberOfKeywords = binReader.ReadInt32(); - _codePage = binReader.ReadInt32(); - - binReader.ReadInt32(); // lcid DWORD - - nTemp = binReader.ReadInt32(); - _isCHI_CHM = (nTemp==1); - - binReader.ReadInt32(); // unknown DWORD - binReader.ReadInt32(); // unknown DWORD - binReader.ReadInt32(); // unknown DWORD - binReader.ReadInt32(); // unknown DWORD - - // end of header decode - - while( (memStream.Position < memStream.Length) && (bRet) ) - { - nCurOffset = (int)memStream.Position; - byte [] dataBlock = binReader.ReadBytes(BLOCK_SIZE); - bRet &= DecodeBlock(dataBlock, ref nCurOffset, _treeDepth-1); - } - - return bRet; - } - - /// - /// Decodes a block of url-string data - /// - /// block of data - /// current file offset - /// number of index blocks - /// true if succeeded - private bool DecodeBlock( byte[] dataBlock, ref int nOffset, int indexBlocks ) - { - bool bRet = true; - int nblockOffset = nOffset; - - MemoryStream memStream = new MemoryStream(dataBlock); - BinaryReader binReader = new BinaryReader(memStream); - - int freeSpace = binReader.ReadInt16(); // length of freespace - int nrOfEntries = binReader.ReadInt16(); // number of entries - - bool bListingEndReached = false; - - //while( (memStream.Position < (memStream.Length-freeSpace)) && (bRet) ) - //{ - int nIndexOfPrevBlock = -1; - int nIndexOfNextBlock = -1; - int nIndexOfChildBlock = 0; - - if(_readListingBlocks) - { - nIndexOfPrevBlock = binReader.ReadInt32(); // -1 if this is the header - nIndexOfNextBlock = binReader.ReadInt32(); // -1 if this is the last block - } - else - { - nIndexOfChildBlock = binReader.ReadInt32(); - } - - for(int nE = 0; nE < nrOfEntries; nE++) - { - if(_readListingBlocks) - { - bListingEndReached = (nIndexOfNextBlock==-1); - - string keyWord = BinaryReaderHelp.ExtractUTF16String(ref binReader, 0, true, _associatedFile.TextEncoding); - - bool isSeeAlsoKeyword = (binReader.ReadInt16()!=0); - - int indent = binReader.ReadInt16(); // indent of entry - int nCharIndex = binReader.ReadInt32(); - - binReader.ReadInt32(); - - int numberOfPairs = binReader.ReadInt32(); - - int[] nTopics = new int[numberOfPairs]; - string[] seeAlso = new string[numberOfPairs]; - - for(int i=0; i < numberOfPairs; i++) - { - if(isSeeAlsoKeyword) - { - seeAlso[i] = BinaryReaderHelp.ExtractUTF16String(ref binReader, 0, true, _associatedFile.TextEncoding); - } - else - { - nTopics[i] = binReader.ReadInt32(); - } - } - - binReader.ReadInt32(); // unknown - - int nIndexOfThisEntry = binReader.ReadInt32(); - - IndexItem newItem = new IndexItem(_associatedFile, keyWord, isSeeAlsoKeyword, indent, nCharIndex, nIndexOfThisEntry, seeAlso, nTopics); - _indexList.Add(newItem); - } - else - { - string keyWord = BinaryReaderHelp.ExtractUTF16String(ref binReader, 0, true, _associatedFile.TextEncoding); - - bool isSeeAlsoKeyword = (binReader.ReadInt16()!=0); - - int indent = binReader.ReadInt16(); // indent of entry - int nCharIndex = binReader.ReadInt32(); - - binReader.ReadInt32(); - - int numberOfPairs = binReader.ReadInt32(); - - int[] nTopics = new int[numberOfPairs]; - string[] seeAlso = new string[numberOfPairs]; - - for(int i=0; i < numberOfPairs; i++) - { - if(isSeeAlsoKeyword) - { - seeAlso[i] = BinaryReaderHelp.ExtractUTF16String(ref binReader, 0, true, _associatedFile.TextEncoding); - } - else - { - nTopics[i] = binReader.ReadInt32(); - } - } - - int nIndexChild = binReader.ReadInt32(); - int nIndexOfThisEntry=-1; - - IndexItem newItem = new IndexItem(_associatedFile, keyWord, isSeeAlsoKeyword, indent, nCharIndex, nIndexOfThisEntry, seeAlso, nTopics); - _indexList.Add(newItem); - - } - } - //} - - binReader.ReadBytes(freeSpace); - - - if( bListingEndReached ) - _readListingBlocks = false; - - return bRet; - } - - /// - /// Gets the internal generated index list - /// - internal ArrayList IndexList - { - get { return _indexList; } - } - - /// - /// Implement IDisposable. - /// - public void Dispose() - { - Dispose(true); - // This object will be cleaned up by the Dispose method. - // Therefore, you should call GC.SupressFinalize to - // take this object off the finalization queue - // and prevent finalization code for this object - // from executing a second time. - GC.SuppressFinalize(this); - } - - /// - /// Dispose(bool disposing) executes in two distinct scenarios. - /// If disposing equals true, the method has been called directly - /// or indirectly by a user's code. Managed and unmanaged resources - /// can be disposed. - /// If disposing equals false, the method has been called by the - /// runtime from inside the finalizer and you should not reference - /// other objects. Only unmanaged resources can be disposed. - /// - /// disposing flag - private void Dispose(bool disposing) - { - // Check to see if Dispose has already been called. - if(!this.disposed) - { - // If disposing equals true, dispose all managed - // and unmanaged resources. - if(disposing) - { - // Dispose managed resources. - _binaryFileData = null; - } - } - disposed = true; - } - } -} diff --git a/irc/TechBot/CHMLibrary/CHMDecoding/CHMFile.cs b/irc/TechBot/CHMLibrary/CHMDecoding/CHMFile.cs deleted file mode 100644 index a39ffc4d684..00000000000 --- a/irc/TechBot/CHMLibrary/CHMDecoding/CHMFile.cs +++ /dev/null @@ -1,2061 +0,0 @@ -using System; -using System.Diagnostics; -using System.Collections; -using System.Collections.Specialized; -using System.IO; -using System.Text; -using System.Runtime.InteropServices; -using System.Globalization; -// using HtmlHelp.Storage; - -namespace HtmlHelp.ChmDecoding -{ - /// - /// Internal enumeration for specifying the type of the html-help file - /// - internal enum HtmlHelpFileType - { - /// - /// CHM - compiled contents file - /// - /// A file with this extension must always exist. If the file would be too long, some parts - /// can be splitted into the filestypes below. - CHM = 0, - /// - /// CHI - compiled system file - /// - CHI = 1, - /// - /// CHQ - compiled fulltext search file - /// - CHQ = 2, - /// - /// CHW - compiled index file - /// - CHW = 3 - - } - - /// - /// The class CHMFile implemts methods and properties for handling a single chmfile. - /// - public sealed class CHMFile : IDisposable - { - /// - /// Internal member storing a reference to the hosting HtmlHelpSystem instance - /// - private HtmlHelpSystem _systemInstance = null; - /// - /// Internal flag specifying if only system data has been loaded - /// - private bool _onlySystem = false; - /// - /// Internal flag specifying if the object is going to be disposed - /// - private bool disposed = false; - /// - /// Internal arraylist containing the table of contents - /// - private ArrayList _toc = new ArrayList(); - /// - /// Internal arraylist containing items of the toc which are merge-Links - /// - private ArrayList _mergeLinks = new ArrayList(); - /// - /// Internal member storing the read information types - /// - private ArrayList _informationTypes = new ArrayList(); - /// - /// Internal member storing the read categories - /// - private ArrayList _categories = new ArrayList(); - /// - /// Internal arraylist containing the index (klinks) - /// - private ArrayList _indexKLinks = new ArrayList(); - /// - /// Internal arraylist containing the index (alinks) - /// - private ArrayList _indexALinks = new ArrayList(); - /// - /// Internal member storing the full filename - /// - private string _chmFileName = ""; - /// - /// Internal member storing the full filename of the chi-file (includes all system files) - /// The file name is zero-length if there is no chi-file - /// - private string _chiFileName = ""; - /// - /// Internal member storing the full filename of the chw-file (includes the help index) - /// The file name is zero-length if there is no chw-file - /// - private string _chwFileName = ""; - /// - /// Internal member storing the full filename of the chq-file (includes the fulltext contents) - /// The file name is zero-length if there is no chq-file - /// - private string _chqFileName = ""; - /// - /// Internal member storing the decoded information from the internal #SYSTEM file - /// - private CHMSystem _systemFile = null; - /// - /// Internal member storing the decoded information from the internal #IDXHDR file - /// - private CHMIdxhdr _idxhdrFile = null; - /// - /// Internal member storing the decoded information from the internal #STRINGS file - /// - private CHMStrings _stringsFile = null; - /// - /// Internal member storing the decoded information from the internal #URLSTR file - /// - private CHMUrlstr _urlstrFile = null; - /// - /// Internal member storing the decoded information from the internal #URLTBL file - /// - private CHMUrltable _urltblFile = null; - /// - /// Internal member storing the decoded information from the internal #TOPICS file - /// - private CHMTopics _topicsFile = null; - /// - /// Internal member storing the decoded information from the internal #TOCIDX file - /// - private CHMTocidx _tocidxFile = null; - /// - /// Internal member storing the decoded information from the internal binary index file (KLinks). - /// - private CHMBtree _kLinks = null; - /// - /// Internal member storing the decoded information from the internal binary index file (ALinks). - /// - private CHMBtree _aLinks = null; - /// - /// Internal member storing the fulltext searcher for this file - /// - private FullTextEngine _ftSearcher = null; - /// - /// Internal member storing the default encoder - /// - private Encoding _textEncoding = Encoding.GetEncoding(1252); // standard windows-1252 encoder - /// - /// Internal memebr storing the chm file info - /// - private ChmFileInfo _chmFileInfo = null; - /// - /// Internal flag specifying if the dump must be written (if enabled) - /// - private bool _mustWriteDump = false; - /// - /// Internal flag specifying if data was read using the dump - /// - private bool _dumpRead = false; - /// - /// Internal member for specifying the number of dump-reading trys. - /// If dump-reading fails, this is used that it will not be opened a second time - /// (in CHM-Systems with CHM, CHI, etc. files) - /// - private int _dumpReadTrys = 0; - /// - /// Internal member storing the dumping info instance - /// - private DumpingInfo _dmpInfo = null; - - private CHMStream.CHMStream _currentWrapper; - private CHMStream.CHMStream _baseStream=null; - public CHMStream.CHMStream BaseStream - { - get - { - if (_baseStream==null) - _baseStream=new CHMStream.CHMStream(this.ChmFilePath); - return _baseStream; - } - } - - /// - /// Creates a new instance of the class - /// - /// a reference to the hosting HtmlHelpSystem instance - /// chm file to read - public CHMFile(HtmlHelpSystem systemInstance, string chmFile) : this(systemInstance, chmFile, false, null) - { - } - - /// - /// Creates a new instance of the class - /// - /// a reference to the hosting HtmlHelpSystem instance - /// chm file to read - /// A dumping info class - public CHMFile(HtmlHelpSystem systemInstance, string chmFile, DumpingInfo dmpInfo) : this(systemInstance, chmFile, false, dmpInfo) - { - } - - /// - /// Creates a new instance of the class - /// - /// a reference to the hosting HtmlHelpSystem instance - /// chm file to read - /// true if only system data should be extracted (no index or toc) - internal CHMFile(HtmlHelpSystem systemInstance, string chmFile, bool onlySystemData) : this(systemInstance, chmFile, onlySystemData, null) - { - } - - /// - /// Creates a new instance of the class - /// - /// a reference to the hosting HtmlHelpSystem instance - /// chm file to read - /// true if only system data should be extracted (no index or toc) - /// A dumping info class - internal CHMFile(HtmlHelpSystem systemInstance, string chmFile, bool onlySystemData, DumpingInfo dmpInfo) - { - _systemInstance = systemInstance; - _dumpReadTrys=0; - - _dmpInfo = dmpInfo; - if(dmpInfo != null) - { - dmpInfo.ChmFile = this; - } - - if( ! chmFile.ToLower().EndsWith(".chm") ) - { - throw new ArgumentException("HtmlHelp file must have the extension .chm !", "chmFile"); - } - - _chmFileName = chmFile; - _chiFileName = ""; - - // Read the IStorage file system - if( File.Exists(chmFile) ) - { - _onlySystem = onlySystemData; - - DateTime dtStartHH = DateTime.Now; - - string sCHIName = _chmFileName.Substring(0, _chmFileName.Length-3) + "chi"; - string sCHQName = _chmFileName.Substring(0, _chmFileName.Length-3) + "chq"; - string sCHWName = _chmFileName.Substring(0, _chmFileName.Length-3) + "chw"; - - // If there is a CHI file present (this file includes the internal system files for the current chm file) - if( File.Exists(sCHIName) ) - { - _chiFileName = sCHIName; - - ReadFile(_chiFileName, HtmlHelpFileType.CHI); - } - - // If there is a CHW file present (this file includes the internal binary index of the help) - if(( File.Exists(sCHWName) ) && (!_onlySystem) ) - { - _chwFileName = sCHWName; - - ReadFile(_chwFileName, HtmlHelpFileType.CHW); - } - - // If there is a CHQ file present (this file includes the fulltext-search data) - if(( File.Exists(sCHQName) ) && (!_onlySystem) ) - { - _chqFileName = sCHQName; - - ReadFile(_chqFileName, HtmlHelpFileType.CHQ); - } - - ReadFile(chmFile, HtmlHelpFileType.CHM); - - if(_mustWriteDump) - { - _mustWriteDump = !SaveDump(dmpInfo); - - } - - // check the default-topic setting - if(_systemFile.DefaultTopic.Length > 0) - { - CHMStream.CHMStream iw=null; - iw = new CHMStream.CHMStream(chmFile); - _currentWrapper=iw; - - // tryo to open the topic file - MemoryStream fileObject = iw.OpenStream( _systemFile.DefaultTopic); - if( fileObject != null) - { - // if succeed, the topic default topic is OK - fileObject.Close(); - } - else - { - // set the first topic of the toc-tree as default topic - if(_toc.Count > 0) - { - _systemFile.SetDefaultTopic( ((TOCItem) _toc[0]).Local ); - } - } - _currentWrapper=null; - } - else - { - // set the first topic of the toc-tree as default topic - if(_toc.Count > 0) - { - _systemFile.SetDefaultTopic( ((TOCItem) _toc[0]).Local ); - } - } - - _chmFileInfo = new ChmFileInfo(this); - } - else - { - throw new ArgumentException("File '" + chmFile + "' not found !", "chmFile"); - } - } - - /// - /// Read a IStorage file - /// - /// filename - /// type of file - private void ReadFile(string fname, HtmlHelpFileType type) - { - CHMStream.CHMStream iw=null; - iw=new CHMStream.CHMStream(); - iw.OpenCHM(fname); - _currentWrapper=iw; - MemoryStream fileObject=null; - - // ITStorageWrapper iw = null; - - // Open the internal chm system files and parse their content - // FileObject fileObject = null; - // iw = new ITStorageWrapper(fname, false); - - if( (type != HtmlHelpFileType.CHQ) && (type != HtmlHelpFileType.CHW) ) - { - fileObject = iw.OpenStream("#SYSTEM"); - if ((fileObject != null) && (fileObject.Length>0)) - _systemFile = new CHMSystem(fileObject.ToArray(), this); - - fileObject = iw.OpenStream("#IDXHDR"); - if ((fileObject != null) && (fileObject.Length>0)) - _idxhdrFile = new CHMIdxhdr(fileObject.ToArray(), this); - - // try to read Dump - if((!_dumpRead)&&(CheckDump(_dmpInfo))&&(_dumpReadTrys==0)) - { - _dumpReadTrys++; - _dumpRead = LoadDump(_dmpInfo); - } - - if( (!_dumpRead)||(!_dmpInfo.DumpStrings) ) - { - fileObject = iw.OpenStream( "#STRINGS"); - if ((fileObject != null) && (fileObject.Length>0)) - _stringsFile = new CHMStrings(fileObject.ToArray(), this); - } - - if( (!_dumpRead)||(!_dmpInfo.DumpUrlStr) ) - { - fileObject = iw.OpenStream( "#URLSTR"); - if ((fileObject != null) && (fileObject.Length>0)) - _urlstrFile = new CHMUrlstr(fileObject.ToArray(), this); - } - - if( (!_dumpRead)||(!_dmpInfo.DumpUrlTbl) ) - { - fileObject = iw.OpenStream( "#URLTBL"); - if ((fileObject != null) && (fileObject.Length>0)) - _urltblFile = new CHMUrltable(fileObject.ToArray(), this); - } - - if( (!_dumpRead)||(!_dmpInfo.DumpTopics) ) - { - fileObject = iw.OpenStream( "#TOPICS"); - if ((fileObject != null) && (fileObject.Length>0)) - _topicsFile = new CHMTopics(fileObject.ToArray(), this); - } - - if(!_onlySystem) - { - if( (!_dumpRead)||(!_dmpInfo.DumpBinaryTOC) ) - { - fileObject = iw.OpenStream( "#TOCIDX"); - if( (fileObject != null) && (fileObject.Length>0) && (_systemFile.BinaryTOC) ) - { - _tocidxFile = new CHMTocidx(fileObject.ToArray(), this); - _toc = _tocidxFile.TOC; - } - } - } - - if( (_systemFile != null) && (!_onlySystem) ) - { - if(!_systemFile.BinaryTOC) - { - if( (!_dumpRead)||(!_dmpInfo.DumpTextTOC) ) - { - CHMStream.chmUnitInfo HHCInfo=iw.GetFileInfoByExtension(".hhc"); - if (HHCInfo!=null) - { - fileObject = iw.OpenStream(HHCInfo); - if ((fileObject != null) && (fileObject.Length>0)) - { - ASCIIEncoding ascii=new ASCIIEncoding(); - string fileString =ascii.GetString(fileObject.ToArray(),0,(int)fileObject.Length); - - _toc = HHCParser.ParseHHC(fileString, this); - } - - if(HHCParser.HasMergeLinks) - _mergeLinks = HHCParser.MergeItems; - } - } - } - } - } - - if( type != HtmlHelpFileType.CHQ ) // no index information in CHQ files (only fulltext search) - { - if( (_systemFile != null) && (!_onlySystem) ) - { - if( ! _systemFile.BinaryIndex ) - { - if( (!_dumpRead)||(!_dmpInfo.DumpTextIndex) ) - { - fileObject = iw.OpenStream( _systemFile.IndexFile); - if ((fileObject != null) && (fileObject.Length>0)) - { - - string fileString = this.TextEncoding.GetString(fileObject.ToArray(),0,(int)fileObject.Length); - // string fileString = fileObject.ReadFromFile(this.TextEncoding); - fileObject.Close(); - - _indexKLinks = HHKParser.ParseHHK(fileString, this); - _indexKLinks.Sort(); - } - } - } - else - { - if( (!_dumpRead)||(!_dmpInfo.DumpBinaryIndex) ) - { - fileObject=iw.OpenStream(@"$WWKeywordLinks\BTree"); - if ((fileObject != null) && (fileObject.Length>0)) - { - _kLinks = new CHMBtree(fileObject.ToArray(), this); - _indexKLinks = _kLinks.IndexList; - } - - fileObject =iw.OpenStream(@"$WWAssociativeLinks\BTree"); - if ((fileObject != null) && (fileObject.Length>0)) - { - _aLinks = new CHMBtree(fileObject.ToArray(), this); - _indexALinks = _aLinks.IndexList; - _indexALinks.Sort(); - } - } - } - } - } - - if( (type != HtmlHelpFileType.CHI) && (type != HtmlHelpFileType.CHW) ) - { - if( (_systemFile != null) && (!_onlySystem) ) - { - if( _systemFile.FullTextSearch) - { - if( (!_dumpRead)||(!_dmpInfo.DumpFullText) ) - { - fileObject = iw.OpenStream("$FIftiMain"); - if(( fileObject != null) && (fileObject .Length>0)) - _ftSearcher = new FullTextEngine(fileObject .ToArray(), this); - } - } - } - } - _currentWrapper=null; - } - - /// - /// Enumerates the files in the chm storage and gets all files matching a given extension. - /// - /// extension to return - /// Returns an arraylist of filenames or null if nothing found - /// On large CHMs, enumerations are very slow. Only use it if necessary ! - internal ArrayList EnumFilesByExtension(string extension) - { - ArrayList arrRet = new ArrayList(); - - CHMStream.CHMStream iw = null; - if(_currentWrapper == null) - iw = new CHMStream.CHMStream(_chmFileName); - else - iw = _currentWrapper; - - arrRet=iw.GetFileListByExtenstion(extension); - - if(arrRet.Count > 0) - return arrRet; - - return null; - } - - /// - /// Searches an TOC entry using the local - /// - /// local to search - /// Returns the TOC item - internal TOCItem GetTOCItemByLocal(string local) - { - return GetTOCItemByLocal(this.TOC, local); - } - - /// - /// Recursively searches an TOC entry using its local - /// - /// toc level list - /// local to search - /// Returns the TOC item - private TOCItem GetTOCItemByLocal(ArrayList arrTOC, string local) - { - TOCItem ret = null; - foreach(TOCItem curItem in arrTOC) - { - string scL = curItem.Local.ToLower(); - string sL = local.ToLower(); - - while(scL[0]=='/') // delete prefixing '/' - scL = scL.Substring(1); - - while(sL[0]=='/') // delete prefixing '/' - sL = sL.Substring(1); - - if(scL == sL) - return curItem; - - if(curItem.Children.Count > 0) - { - ret = GetTOCItemByLocal(curItem.Children, local); - if(ret != null) - return ret; - } - } - - return ret; - } - - /// - /// Removes a TOCItem from the toc - /// - /// item to remove - /// Returns true if removed - internal bool RemoveTOCItem(TOCItem rem) - { - if(rem == null) - return false; - - return RemoveTOCItem(this.TOC, rem); - } - - /// - /// Recursively searches a TOCItem and removes it if found - /// - /// toc level list - /// item to remove - /// Returns true if removed - private bool RemoveTOCItem(ArrayList arrTOC, TOCItem rem) - { - for(int i=0; i 0) - { - bool bRem = RemoveTOCItem(curItem.Children, rem); - if(bRem) - return true; - } - } - - return false; - } - - /// - /// Returns true if the HtmlHelpSystem instance contains 1 or more information types - /// - public bool HasInformationTypes - { - get { return (_informationTypes.Count>0); } - } - - /// - /// Returns true if the HtmlHelpSystem instance contains 1 or more categories - /// - public bool HasCategories - { - get { return (_categories.Count>0); } - } - - /// - /// Gets an ArrayList of InformationType items - /// - public ArrayList InformationTypes - { - get { return _informationTypes; } - } - - /// - /// Gets an ArrayList of Category items - /// - public ArrayList Categories - { - get { return _categories; } - } - - /// - /// Gets the information type specified by its name - /// - /// name of the information type to receive - /// Returns the Instance for the name or null if not found - public InformationType GetInformationType(string name) - { - if(HasInformationTypes) - { - for(int i=0; i<_informationTypes.Count;i++) - { - InformationType iT = _informationTypes[i] as InformationType; - - if(iT.Name == name) - return iT; - } - } - - return null; - } - - /// - /// Gets the category specifiyd by its name - /// - /// name of the category - /// Returns the Instance for the name or null if not found - public Category GetCategory(string name) - { - if(HasCategories) - { - for(int i=0; i<_categories.Count;i++) - { - Category cat = _categories[i] as Category; - - if(cat.Name == name) - return cat; - } - } - - return null; - } - - #region Dumping methods - - /// - /// Checks if a dump for this file exists and if it can be read - /// - /// dumping info class - /// true if it can be read - private bool CheckDump(DumpingInfo dmpInfo) - { - if(_dumpReadTrys<=0) - _mustWriteDump = false; - - if(_onlySystem) - return false; - - if( dmpInfo != null ) - { - if(_dumpReadTrys > 0) - return _mustWriteDump; - - _mustWriteDump = !dmpInfo.DumpExists; - return !_mustWriteDump; - } - - return false; - } - - /// - /// Saves the the toc and index into a data dump - /// - /// dumping info - /// true if succeed - private bool SaveDump(DumpingInfo dmpInfo) - { - if(dmpInfo == null) - return false; - - bool bRet = false; - - - BinaryWriter writer = dmpInfo.Writer; - - int nCnt = 0; - try - { - Debug.WriteLine("writing dump-file header"); - FileInfo fi = new FileInfo(_chmFileName); - string ftime = fi.LastWriteTime.ToString("dd.MM.yyyy HH:mm:ss.ffffff"); - - writer.Write("HtmlHelpSystem dump file 1.0"); - writer.Write(ftime); - writer.Write(_textEncoding.CodePage); - - // strings dumping - if(dmpInfo.DumpStrings) - { - writer.Write(true); // data should be in dump - - if(_stringsFile==null) - { - writer.Write(false); // data not supported by the chm - } - else - { - Debug.WriteLine("writing #STRINGS"); - writer.Write(true); // data supported and following - _stringsFile.Dump(ref writer); - } - } - else - { - writer.Write(false); // data is not in dump - } - - // urlstr dumping - if(dmpInfo.DumpUrlStr) - { - writer.Write(true); - - if(_urlstrFile==null) - { - writer.Write(false); - } - else - { - Debug.WriteLine("writing #URLSTR"); - writer.Write(true); - _urlstrFile.Dump(ref writer); - } - } - else - { - writer.Write(false); - } - - // urltbl dumping - if(dmpInfo.DumpUrlTbl) - { - writer.Write(true); - - if(_urltblFile==null) - { - writer.Write(false); - } - else - { - Debug.WriteLine("writing #URLTBL"); - writer.Write(true); - _urltblFile.Dump(ref writer); - } - } - else - { - writer.Write(false); - } - - // topics dumping - if(dmpInfo.DumpTopics) - { - writer.Write(true); - - if(_topicsFile==null) - { - writer.Write(false); - } - else - { - Debug.WriteLine("writing #TOPICS"); - writer.Write(true); - _topicsFile.Dump(ref writer); - } - } - else - { - writer.Write(false); - } - - // ftsearch dumping - if(dmpInfo.DumpFullText) - { - writer.Write(true); - - if(_ftSearcher==null) - { - writer.Write(false); - } - else - { - Debug.WriteLine("writing $FIftiMain"); - writer.Write(true); - _ftSearcher.Dump(ref writer); - } - } - else - { - writer.Write(false); - } - - // TOC dumping - bool bWriteTOC = false; - - if( (_systemFile.BinaryTOC) && (dmpInfo.DumpBinaryTOC) ) - { - Debug.WriteLine("writing binary TOC"); - bWriteTOC = true; - } - - if( (!_systemFile.BinaryTOC) && (dmpInfo.DumpTextTOC) ) - { - Debug.WriteLine("writing text-based TOC"); - bWriteTOC = true; - } - - writer.Write(bWriteTOC); - - if(bWriteTOC) - { - // write table of contents - writer.Write( _toc.Count ); - - for(nCnt=0; nCnt < _toc.Count; nCnt++) - { - TOCItem curItem = ((TOCItem)(_toc[nCnt])); - curItem.Dump( ref writer ); - } - } - - // Index dumping - bool bWriteIdx = false; - - if( (_systemFile.BinaryIndex) && (dmpInfo.DumpBinaryIndex) ) - { - Debug.WriteLine("writing binary index"); - bWriteIdx = true; - } - - if( (!_systemFile.BinaryIndex) && (dmpInfo.DumpTextIndex) ) - { - Debug.WriteLine("writing text-based index"); - bWriteIdx = true; - } - - writer.Write(bWriteIdx); - - if(bWriteIdx) - { - // write index - writer.Write( _indexALinks.Count ); - for(nCnt=0; nCnt < _indexALinks.Count; nCnt++) - { - IndexItem curItem = ((IndexItem)(_indexALinks[nCnt])); - curItem.Dump( ref writer ); - } - - writer.Write( _indexKLinks.Count ); - for(nCnt=0; nCnt < _indexKLinks.Count; nCnt++) - { - IndexItem curItem = ((IndexItem)(_indexKLinks[nCnt])); - curItem.Dump( ref writer ); - } - } - - // Information types dumping - writer.Write( _informationTypes.Count ); - - Debug.WriteLine("writing " + _informationTypes.Count.ToString() + " information types"); - - for(nCnt=0; nCnt<_informationTypes.Count;nCnt++) - { - InformationType curType = _informationTypes[nCnt] as InformationType; - - curType.Dump(ref writer); - } - - // Categories dumping - writer.Write( _categories.Count ); - - Debug.WriteLine("writing " + _categories.Count.ToString() + " categories"); - - for(nCnt=0; nCnt<_categories.Count; nCnt++) - { - Category curCat = _categories[nCnt] as Category; - - curCat.Dump( ref writer); - } - - bRet=true; - } - finally - { - dmpInfo.SaveData(); - } - - return bRet; - } - - /// - /// Parses a HHC file which is located in the current CHM. - /// - /// hhc file to parse - /// an arraylist with toc items - public ArrayList ParseHHC(string hhcFile) - { - ArrayList arrRet = new ArrayList(); - - CHMStream.CHMStream iw=null; - iw=new CHMStream.CHMStream(); - iw.OpenCHM(_chmFileName); - MemoryStream fileObject=null; - - fileObject = iw.OpenStream(hhcFile); - if( fileObject != null) - { - ASCIIEncoding ascii=new ASCIIEncoding(); - string fileString =ascii.GetString(fileObject.ToArray(),0,(int)fileObject.Length); - fileObject.Close(); - - arrRet = HHCParser.ParseHHC(fileString, this); - - if(HHCParser.HasMergeLinks) - { - foreach(TOCItem curItem in HHCParser.MergeItems) - { - _mergeLinks.Add(curItem); - } - } - } - - return arrRet; - } - - /// - /// Loads the toc and index from a data dump - /// - /// dumping info - /// true if succeed - private bool LoadDump(DumpingInfo dmpInfo) - { - if(dmpInfo == null) - return false; - - bool bRet = false; - - try - { - BinaryReader reader = dmpInfo.Reader; - - if(reader == null) - { - Debug.WriteLine("No reader returned !"); - dmpInfo.SaveData(); // closes the dump - _mustWriteDump = true; - return false; - } - - int nCnt = 0; - - Debug.WriteLine("reading dump-file header"); - FileInfo fi = new FileInfo(_chmFileName); - string ftime = fi.LastWriteTime.ToString("dd.MM.yyyy HH:mm:ss.ffffff"); - - string header = reader.ReadString(); - - if( header != "HtmlHelpSystem dump file 1.0") - { - Debug.WriteLine("Unsupported dump-file format !"); - dmpInfo.SaveData(); // closes the dump - _mustWriteDump = true; - return false; - } - - string ftimecheck = reader.ReadString(); - - reader.ReadInt32(); // codepage, we'll use the same as for the chm file which is already set. - -// if(ftimecheck != ftime) -// { -// Debug.WriteLine("Dump is out of date (CHM file changed during last dump creation) !"); -// dmpInfo.SaveData(); // closes the dump -// _mustWriteDump = true; -// return false; // force reload -// } - - - bool bFlag=false; // true if data should be in dump - bool bFlagSupp=false; // false if data is not supported by the chm - - bFlag = reader.ReadBoolean(); - - if(bFlag) - { - bFlagSupp = reader.ReadBoolean(); - - if(!dmpInfo.DumpStrings) - { - Debug.WriteLine("Dumped #STRINGS found but not expected !"); - dmpInfo.SaveData(); // closes the dump - _mustWriteDump = true; - return false; // force reload - } - - if(bFlagSupp) - { - Debug.WriteLine("reading #STRINGS"); - _stringsFile = new CHMStrings(); - _stringsFile.SetCHMFile(this); - _stringsFile.ReadDump(ref reader); - } - } - else - { - if(dmpInfo.DumpStrings) - { - Debug.WriteLine("Dumped #STRINGS expected but not found !"); - dmpInfo.SaveData(); // closes the dump - _mustWriteDump = true; - return false; // force reload - } - } - - bFlag = reader.ReadBoolean(); - - if(bFlag) - { - bFlagSupp = reader.ReadBoolean(); - - if(!dmpInfo.DumpUrlStr) - { - Debug.WriteLine("Dumped #URLSTR found but not expected !"); - dmpInfo.SaveData(); // closes the dump - _mustWriteDump = true; - return false; // force reload - } - - if(bFlagSupp) - { - Debug.WriteLine("reading #URLSTR"); - _urlstrFile = new CHMUrlstr(); - _urlstrFile.SetCHMFile(this); - _urlstrFile.ReadDump(ref reader); - } - } - else - { - if(dmpInfo.DumpUrlStr) - { - Debug.WriteLine("Dumped #URLSTR expected but not found !"); - dmpInfo.SaveData(); // closes the dump - _mustWriteDump = true; - return false; // force reload - } - } - - bFlag = reader.ReadBoolean(); - - if(bFlag) - { - bFlagSupp = reader.ReadBoolean(); - - if(!dmpInfo.DumpUrlTbl) - { - Debug.WriteLine("Dumped #URLTBL found but not expected !"); - dmpInfo.SaveData(); // closes the dump - _mustWriteDump = true; - return false; // force reload - } - - if(bFlagSupp) - { - Debug.WriteLine("reading #URLTBL"); - _urltblFile = new CHMUrltable(); - _urltblFile.SetCHMFile(this); - _urltblFile.ReadDump(ref reader); - } - } - else - { - if(dmpInfo.DumpUrlTbl) - { - Debug.WriteLine("Dumped #URLTBL expected but not found !"); - dmpInfo.SaveData(); // closes the dump - _mustWriteDump = true; - return false; // force reload - } - } - - bFlag = reader.ReadBoolean(); - - if(bFlag) - { - bFlagSupp = reader.ReadBoolean(); - - if(!dmpInfo.DumpTopics) - { - Debug.WriteLine("Dumped #TOPICS found but not expected !"); - dmpInfo.SaveData(); // closes the dump - _mustWriteDump = true; - return false; // force reload - } - - if(bFlagSupp) - { - Debug.WriteLine("reading #TOPICS"); - _topicsFile = new CHMTopics(); - _topicsFile.SetCHMFile(this); - _topicsFile.ReadDump(ref reader); - } - } - else - { - if(dmpInfo.DumpTopics) - { - Debug.WriteLine("Dumped #TOPICS expected but not found !"); - dmpInfo.SaveData(); // closes the dump - _mustWriteDump = true; - return false; // force reload - } - } - - bFlag = reader.ReadBoolean(); - - if(bFlag) - { - bFlagSupp = reader.ReadBoolean(); - - if(!dmpInfo.DumpFullText) - { - Debug.WriteLine("Dumped $FIftiMain found but not expected !"); - dmpInfo.SaveData(); // closes the dump - _mustWriteDump = true; - return false; // force reload - } - - if(bFlagSupp) - { - Debug.WriteLine("reading $FIftiMain"); - _ftSearcher = new FullTextEngine(); - _ftSearcher.SetCHMFile(this); - _ftSearcher.ReadDump(ref reader); - } - } - else - { - if(dmpInfo.DumpFullText) - { - Debug.WriteLine("Dumped $FIftiMain expected but not found !"); - dmpInfo.SaveData(); // closes the dump - _mustWriteDump = true; - return false; // force reload - } - } - - // read table of contents - _toc.Clear(); - bFlag = reader.ReadBoolean(); - - if(bFlag) - { - if((_systemFile.BinaryTOC)&&(!dmpInfo.DumpBinaryTOC)) - { - Debug.WriteLine("Binary TOC expected but not found !"); - dmpInfo.SaveData(); // closes the dump - _mustWriteDump = true; - return false; // force reload - } - - if((!_systemFile.BinaryTOC)&&(!dmpInfo.DumpTextTOC)) - { - Debug.WriteLine("Text-based TOC expected but not found !"); - dmpInfo.SaveData(); // closes the dump - _mustWriteDump = true; - return false; // force reload - } - - if(_systemFile.BinaryTOC) - Debug.WriteLine("reading binary TOC"); - else - Debug.WriteLine("reading text-based TOC"); - - int nTocCnt = reader.ReadInt32(); - - for(nCnt=0; nCnt < nTocCnt; nCnt++) - { - TOCItem item = new TOCItem(); - item.AssociatedFile = this; - item.ChmFile = _chmFileName; - item.ReadDump(ref reader); - if(item.MergeLink.Length > 0) - _mergeLinks.Add(item); - - _toc.Add(item); - } - } - else - { - if((_systemFile.BinaryTOC)&&(dmpInfo.DumpBinaryTOC)) - { - Debug.WriteLine("Binary TOC expected but no TOC dump !"); - dmpInfo.SaveData(); // closes the dump - _mustWriteDump = true; - return false; // force reload - } - - if((!_systemFile.BinaryTOC)&&(dmpInfo.DumpTextTOC)) - { - Debug.WriteLine("Text-based TOC expected but no TOC dump !"); - dmpInfo.SaveData(); // closes the dump - _mustWriteDump = true; - return false; // force reload - } - } - - // read index - _indexALinks.Clear(); - _indexKLinks.Clear(); - - bFlag = reader.ReadBoolean(); - - if(bFlag) - { - if((_systemFile.BinaryIndex)&&(!dmpInfo.DumpBinaryIndex)) - { - Debug.WriteLine("Binary index expected but not found !"); - dmpInfo.SaveData(); // closes the dump - _mustWriteDump = true; - return false; // force reload - } - - if((!_systemFile.BinaryIndex)&&(!dmpInfo.DumpTextIndex)) - { - Debug.WriteLine("Binary index expected but not found !"); - dmpInfo.SaveData(); // closes the dump - _mustWriteDump = true; - return false; // force reload - } - - if(_systemFile.BinaryIndex) - Debug.WriteLine("reading binary index"); - else - Debug.WriteLine("reading text-based index"); - - int nIndxaCnt = reader.ReadInt32(); - - for(nCnt=0; nCnt < nIndxaCnt; nCnt++) - { - IndexItem item = new IndexItem(); - item.ChmFile = this; - item.ReadDump(ref reader); - _indexALinks.Add(item); - } - - - int nIndxkCnt = reader.ReadInt32(); - - for(nCnt=0; nCnt < nIndxkCnt; nCnt++) - { - IndexItem item = new IndexItem(); - item.ChmFile = this; - item.ReadDump(ref reader); - _indexKLinks.Add(item); - } - } - else - { - if((_systemFile.BinaryIndex)&&(dmpInfo.DumpBinaryIndex)) - { - Debug.WriteLine("Binary index expected but no index in dump !"); - dmpInfo.SaveData(); // closes the dump - _mustWriteDump = true; - return false; // force reload - } - - if((!_systemFile.BinaryIndex)&&(dmpInfo.DumpTextIndex)) - { - Debug.WriteLine("Text-based index expected but no index dump !"); - dmpInfo.SaveData(); // closes the dump - _mustWriteDump = true; - return false; // force reload - } - } - - // read information types from dump - int nITCnt = reader.ReadInt32(); - - Debug.WriteLine("Reading " + nITCnt.ToString() + " information types from dump !"); - - for(nCnt=0; nCnt - /// Gets the current storage wrapper. - /// - /// This property will return not null, if there are currently file read actions running ! - internal CHMStream.CHMStream CurrentStorageWrapper - { - get { return _currentWrapper;} - } - /// - /// Gets/sets the hosting HtmlHelpSystem instance - /// - internal HtmlHelpSystem SystemInstance - { - get { return _systemInstance; } - set { _systemInstance = value; } - } - /// - /// Gets an arraylist of TOC items which contains merg-links to other CHMs - /// - internal ArrayList MergLinks - { - get { return _mergeLinks; } - } - - /// - /// Gets the internal system file instance - /// - internal CHMSystem SystemFile - { - get { return _systemFile; } - } - - /// - /// Gets the internal idxhdr file instance - /// - internal CHMIdxhdr IdxHdrFile - { - get { return _idxhdrFile; } - } - - /// - /// Gets the internal strings file instance - /// - internal CHMStrings StringsFile - { - get { return _stringsFile; } - } - - /// - /// Gets the internal urlstr file instance - /// - internal CHMUrlstr UrlstrFile - { - get { return _urlstrFile; } - } - - /// - /// Gets the internal urltbl file instance - /// - internal CHMUrltable UrltblFile - { - get { return _urltblFile; } - } - - /// - /// Gets the internal topics file instance - /// - internal CHMTopics TopicsFile - { - get { return _topicsFile; } - } - - /// - /// Gets the internal tocidx file instance - /// - internal CHMTocidx TocidxFile - { - get { return _tocidxFile; } - } - - /// - /// Gets the internal btree file instance for alinks - /// - internal CHMBtree ALinksFile - { - get { return _aLinks; } - } - - /// - /// Gets the internal btree file instance for klinks - /// - internal CHMBtree KLinksFile - { - get { return _kLinks; } - } - - /// - /// Gets/Sets the text encoding - /// - internal Encoding TextEncoding - { - get { return _textEncoding; } - set { _textEncoding = value; } - } - - #endregion - - #region Properties from the #SYSTEM file - /// - /// Gets the file version of the chm file. - /// 2 for Compatibility=1.0, 3 for Compatibility=1.1 - /// - internal int FileVersion - { - get - { - if(_systemFile==null) - return 0; - - return _systemFile.FileVersion; - } - } - - /// - /// Gets the contents file name - /// - internal string ContentsFile - { - get - { - if(_systemFile==null) - return String.Empty; - - return _systemFile.ContentsFile; - } - } - - /// - /// Gets the index file name - /// - internal string IndexFile - { - get - { - if(_systemFile==null) - return String.Empty; - - return _systemFile.IndexFile; - } - } - - /// - /// Gets the default help topic - /// - internal string DefaultTopic - { - get - { - if(_systemFile==null) - return String.Empty; - - return _systemFile.DefaultTopic; - } - } - - /// - /// Gets the title of the help window - /// - internal string HelpWindowTitle - { - get - { - if(_systemFile==null) - return String.Empty; - - return _systemFile.Title; - } - } - - /// - /// Gets the flag if DBCS is in use - /// - internal bool DBCS - { - get - { - if(_systemFile==null) - return false; - - return _systemFile.DBCS; - } - } - - /// - /// Gets the flag if full-text-search is available - /// - internal bool FullTextSearch - { - get - { - if(_systemFile==null) - return false; - - return _systemFile.FullTextSearch; - } - } - - /// - /// Gets the flag if the file has ALinks - /// - internal bool HasALinks - { - get - { - if(_systemFile==null) - return false; - - return _systemFile.HasALinks; - } - } - - /// - /// Gets the flag if the file has KLinks - /// - internal bool HasKLinks - { - get - { - if(_systemFile==null) - return false; - - return _systemFile.HasKLinks; - } - } - - /// - /// Gets the default window name - /// - internal string DefaultWindow - { - get - { - if(_systemFile==null) - return String.Empty; - - return _systemFile.DefaultWindow; - } - } - - /// - /// Gets the file name of the compile file - /// - internal string CompileFile - { - get - { - if(_systemFile==null) - return String.Empty; - - return _systemFile.CompileFile; - } - } - - /// - /// Gets the flag if the chm has a binary index file - /// - internal bool BinaryIndex - { - get - { - if(_systemFile==null) - return false; - - return _systemFile.BinaryIndex; - } - } - - /// - /// Gets the flag if the chm has a binary index file - /// - internal string CompilerVersion - { - get - { - if(_systemFile==null) - return String.Empty; - - return _systemFile.CompilerVersion; - } - } - - /// - /// Gets the flag if the chm has a binary toc file - /// - internal bool BinaryTOC - { - get - { - if(_systemFile==null) - return false; - - return _systemFile.BinaryTOC; - } - } - - /// - /// Gets the font face of the read font property. - /// Empty string for default font. - /// - internal string FontFace - { - get - { - if(_systemFile==null) - return ""; - - return _systemFile.FontFace; - } - } - - /// - /// Gets the font size of the read font property. - /// 0 for default font size - /// - internal double FontSize - { - get - { - if(_systemFile==null) - return 0; - - return _systemFile.FontSize; - } - } - - /// - /// Gets the character set of the read font property - /// 1 for default - /// - internal int CharacterSet - { - get - { - if(_systemFile==null) - return 1; - - return _systemFile.CharacterSet; - } - } - - /// - /// Gets the codepage depending on the read font property - /// - internal int CodePage - { - get - { - if(_systemFile==null) - return CultureInfo.CurrentCulture.TextInfo.ANSICodePage; - - return _systemFile.CodePage; - } - } - - /// - /// Gets the assiciated culture info - /// - internal CultureInfo Culture - { - get - { - if(_systemFile==null) - return CultureInfo.CurrentCulture; - - return _systemFile.Culture; - } - } - - #endregion - - #region Properties from the #IDXHDR file - /// - /// Gets the number of topic nodes including the contents and index files - /// - internal int NumberOfTopicNodes - { - get - { - if(_idxhdrFile==null) - return 0; - - return _idxhdrFile.NumberOfTopicNodes; - } - } - - /// - /// Gets the ImageList string specyfied in the #IDXHDR file. - /// - /// This property uses the #STRINGS file to extract the string at a given offset. - internal string ImageList - { - get - { - if( (_stringsFile == null) || (_idxhdrFile == null) ) - return ""; - - return _stringsFile[ _idxhdrFile.ImageListOffset ]; - } - } - - /// - /// True if the value of the ImageType param of the - /// "text/site properties" object of the sitemap contents is "Folder". - /// - /// If this is set to true, the help will display folders instead of books - internal bool ImageTypeFolder - { - get - { - if(_idxhdrFile==null) - return false; - - return _idxhdrFile.ImageTypeFolder; - } - } - - /// - /// Gets the background setting - /// - internal int Background - { - get - { - if(_idxhdrFile==null) - return 0; - - return _idxhdrFile.Background; - } - } - - /// - /// Gets the foreground setting - /// - internal int Foreground - { - get - { - if(_idxhdrFile==null) - return 0; - - return _idxhdrFile.Foreground; - } - } - - /// - /// Gets the Font string specyfied in the #IDXHDR file. - /// - /// This property uses the #STRINGS file to extract the string at a given offset. - internal string FontName - { - get - { - if( (_stringsFile == null) || (_idxhdrFile == null) ) - return ""; - - return _stringsFile[ _idxhdrFile.FontOffset ]; - } - } - - /// - /// Gets the FrameName string specyfied in the #IDXHDR file. - /// - /// This property uses the #STRINGS file to extract the string at a given offset. - internal string FrameName - { - get - { - if( (_stringsFile == null) || (_idxhdrFile == null) ) - return ""; - - return _stringsFile[ _idxhdrFile.FrameNameOffset ]; - } - } - - /// - /// Gets the WindowName string specyfied in the #IDXHDR file. - /// - /// This property uses the #STRINGS file to extract the string at a given offset. - internal string WindowName - { - get - { - if( (_stringsFile == null) || (_idxhdrFile == null) ) - return ""; - - return _stringsFile[ _idxhdrFile.WindowNameOffset ]; - } - } - - /// - /// Gets a string array containing the merged file names - /// - internal string[] MergedFiles - { - get - { - if( (_stringsFile == null) || (_idxhdrFile == null) ) - return new string[0]; - - string[] saRet = new string[ _idxhdrFile.MergedFileOffsets.Count ]; - - for(int i=0; i < _idxhdrFile.MergedFileOffsets.Count; i++) - { - saRet[i] = _stringsFile[ (int)_idxhdrFile.MergedFileOffsets[i] ]; - } - - return saRet; - } - } - #endregion - - /// - /// Gets the file info associated with this instance - /// - public ChmFileInfo FileInfo - { - get { return _chmFileInfo; } - } - - /// - /// Gets the internal toc read from the text-based hhc file - /// - public ArrayList TOC - { - get { return _toc; } - } - - /// - /// Gets the internal index read from the chm file. - /// - public ArrayList IndexKLinks - { - get { return _indexKLinks; } - } - - /// - /// Gets the internal index read from the chm file. - /// - public ArrayList IndexALinks - { - get { return _indexALinks; } - } - - /// - /// Gets the full-text search engine for this file - /// - internal FullTextEngine FullTextSearchEngine - { - get { return _ftSearcher; } - } - - /// - /// Gets the full pathname of the file - /// - public string ChmFilePath - { - get { return _chmFileName; } - } - - /// - /// Gets the full pathname of the chi-file - /// The file name is zero-length if there is no chi-file - /// - public string ChiFilePath - { - get { return _chiFileName; } - } - - /// - /// Gets the full pathname of the chw-file - /// The file name is zero-length if there is no chw-file - /// - public string ChwFilePath - { - get { return _chwFileName; } - } - - /// - /// Gets the full pathname of the chq-file - /// The file name is zero-length if there is no chq-file - /// - public string ChqFilePath - { - get { return _chqFileName; } - } - - /// - /// Forms an URL for the web browser - /// - /// local resource - /// a url for the web-browser - internal string FormURL(string local) - { - if( (local.ToLower().IndexOf("http://") >= 0) || - (local.ToLower().IndexOf("https://") >= 0) || - (local.ToLower().IndexOf("mailto:") >= 0) || - (local.ToLower().IndexOf("ftp://") >= 0) || - (local.ToLower().IndexOf("ms-its:") >= 0)) - return local; - - return HtmlHelpSystem.UrlPrefix + _chmFileName + "::/" + local; - } - - /// - /// Implement IDisposable. - /// - public void Dispose() - { - Dispose(true); - // This object will be cleaned up by the Dispose method. - // Therefore, you should call GC.SupressFinalize to - // take this object off the finalization queue - // and prevent finalization code for this object - // from executing a second time. - GC.SuppressFinalize(this); - } - - /// - /// Dispose(bool disposing) executes in two distinct scenarios. - /// If disposing equals true, the method has been called directly - /// or indirectly by a user's code. Managed and unmanaged resources - /// can be disposed. - /// If disposing equals false, the method has been called by the - /// runtime from inside the finalizer and you should not reference - /// other objects. Only unmanaged resources can be disposed. - /// - /// disposing flag - private void Dispose(bool disposing) - { - // Check to see if Dispose has already been called. - if(!this.disposed) - { - // If disposing equals true, dispose all managed - // and unmanaged resources. - if(disposing) - { - // Dispose managed resources. - _toc.Clear(); - _indexKLinks.Clear(); - _indexALinks.Clear(); - - if(_systemFile!=null) - _systemFile.Dispose(); - - if(_idxhdrFile != null) - _idxhdrFile.Dispose(); - - if(_stringsFile != null) - _stringsFile.Dispose(); - - if(_urlstrFile != null) - _urlstrFile.Dispose(); - - if(_urltblFile != null) - _urltblFile.Dispose(); - - if(_topicsFile != null) - _topicsFile.Dispose(); - - if(_tocidxFile != null) - _tocidxFile.Dispose(); - - if(_kLinks != null) - _kLinks.Dispose(); - - if(_aLinks != null) - _aLinks.Dispose(); - - if(_ftSearcher != null) - _ftSearcher.Dispose(); - - if(_chmFileInfo != null) - _chmFileInfo = null; - } - } - disposed = true; - } - - } -} diff --git a/irc/TechBot/CHMLibrary/CHMDecoding/CHMIdxhdr.cs b/irc/TechBot/CHMLibrary/CHMDecoding/CHMIdxhdr.cs deleted file mode 100644 index 7ac64ac3ea7..00000000000 --- a/irc/TechBot/CHMLibrary/CHMDecoding/CHMIdxhdr.cs +++ /dev/null @@ -1,286 +0,0 @@ -using System; -using System.Collections; -using System.IO; - -namespace HtmlHelp.ChmDecoding -{ - /// - /// The class CHMIdxhdr implements t properties which have been read from the #IDXHDR file. - /// - internal sealed class CHMIdxhdr : IDisposable - { - /// - /// Internal flag specifying if the object is going to be disposed - /// - private bool disposed = false; - /// - /// Internal member storing the binary file data - /// - private byte[] _binaryFileData = null; - /// - /// Internal member storing the number of topic nodes including the contents and index files - /// - private int _numberOfTopicNodes = 0; - /// - /// Internal member storing the offset in the #STRINGS file of the ImageList param of the "text/site properties" object of the sitemap contents - /// - private int _imageListOffset = 0; - /// - /// True if the value of the ImageType param of the "text/site properties" object of the sitemap contents is "Folder". - /// - private bool _imageTypeFolder = false; - /// - /// Internal member storing the background value - /// - private int _background = 0; - /// - /// Internal member storing the foreground value - /// - private int _foreground = 0; - /// - /// Internal member storing the offset in the #STRINGS file of the Font param of the "text/site properties" object of the sitemap contents - /// - private int _fontOffset = 0; - /// - /// Internal member storing the offset in the #STRINGS file of the FrameName param of the "text/site properties" object of the sitemap contents - /// - private int _frameNameOffset = 0; - /// - /// Internal member storing the offset in the #STRINGS file of the WindowName param of the "text/site properties" object of the sitemap contents - /// - private int _windowNameOffset = 0; - /// - /// Internal member storing the number of merged files - /// - private int _numberOfMergedFiles = 0; - /// - /// Internal member storing the offset in the #STRINGS file of the merged file names - /// - private ArrayList _mergedFileOffsets = new ArrayList(); - /// - /// Internal member storing the associated chmfile object - /// - private CHMFile _associatedFile = null; - - /// - /// Constructor of the class - /// - /// binary file data of the #IDXHDR file - /// associated CHMFile instance - public CHMIdxhdr(byte[] binaryFileData, CHMFile associatedFile) - { - _binaryFileData = binaryFileData; - _associatedFile = associatedFile; - DecodeData(); - } - - /// - /// Decodes the binary file data and fills the internal properties - /// - /// true if succeeded - private bool DecodeData() - { - bool bRet = true; - - MemoryStream memStream = new MemoryStream(_binaryFileData); - BinaryReader binReader = new BinaryReader(memStream); - - int nTemp = 0; - - // 4 character T#SM - binReader.ReadBytes(4); - // unknown timestamp DWORD - nTemp = binReader.ReadInt32(); - - // unknown 1 - nTemp = binReader.ReadInt32(); - - // number of topic nodes including the contents & index files - _numberOfTopicNodes = binReader.ReadInt32(); - - // unknown DWORD - nTemp = binReader.ReadInt32(); - - // offset in the strings file - _imageListOffset = binReader.ReadInt32(); - if( _imageListOffset == 0) - _imageListOffset = -1; // 0/-1 = none - - // unknown DWORD - nTemp = binReader.ReadInt32(); - - // 1 if the value of the ImageType param of the "text/site properties" object of the sitemap contents is "Folder". - nTemp = binReader.ReadInt32(); - _imageTypeFolder = (nTemp == 1); - - // offset in the strings file - _background = binReader.ReadInt32(); - // offset in the strings file - _foreground = binReader.ReadInt32(); - - // offset in the strings file - _fontOffset = binReader.ReadInt32(); - - // window styles DWORD - nTemp = binReader.ReadInt32(); - // window styles DWORD - nTemp = binReader.ReadInt32(); - - // unknown DWORD - nTemp = binReader.ReadInt32(); - - // offset in the strings file - _frameNameOffset = binReader.ReadInt32(); - if( _frameNameOffset == 0) - _frameNameOffset = -1; // 0/-1 = none - // offset in the strings file - _windowNameOffset = binReader.ReadInt32(); - if( _windowNameOffset == 0) - _windowNameOffset = -1; // 0/-1 = none - - // informations types DWORD - nTemp = binReader.ReadInt32(); - - // unknown DWORD - nTemp = binReader.ReadInt32(); - - // number of merged files in the merged file list DWORD - _numberOfMergedFiles = binReader.ReadInt32(); - - nTemp = binReader.ReadInt32(); - - for(int i = 0; i < _numberOfMergedFiles; i++) - { - // DWORD offset value of merged file - nTemp = binReader.ReadInt32(); - - if(nTemp > 0) - _mergedFileOffsets.Add(nTemp); - } - - return bRet; - } - - /// - /// Gets the number of topic nodes including the contents and index files - /// - public int NumberOfTopicNodes - { - get { return _numberOfTopicNodes; } - } - - /// - /// Gets the offset in the #STRINGS file of the ImageList - /// param of the "text/site properties" object of the sitemap contents - /// - public int ImageListOffset - { - get { return _imageListOffset; } - } - - /// - /// True if the value of the ImageType param of the - /// "text/site properties" object of the sitemap contents is "Folder". - /// - /// If this is set to true, the help will display folders instead of books - public bool ImageTypeFolder - { - get { return _imageTypeFolder; } - } - - /// - /// Gets the background setting - /// - public int Background - { - get { return _background; } - } - - /// - /// Gets the foreground setting - /// - public int Foreground - { - get { return _foreground; } - } - - /// - /// Gets the offset in the #STRINGS file of the Font - /// param of the "text/site properties" object of the sitemap contents - /// - public int WindowNameOffset - { - get { return _fontOffset; } - } - - /// - /// Gets the offset in the #STRINGS file of the FrameName - /// param of the "text/site properties" object of the sitemap contents - /// - public int FrameNameOffset - { - get { return _frameNameOffset; } - } - - /// - /// Gets the offset in the #STRINGS file of the WindowName - /// param of the "text/site properties" object of the sitemap contents - /// - public int FontOffset - { - get { return _windowNameOffset; } - } - - /// - /// Gets an array list of offset numbers in the #STRINGS file of the - /// merged file names. - /// - public ArrayList MergedFileOffsets - { - get { return _mergedFileOffsets; } - } - - /// - /// Implement IDisposable. - /// - public void Dispose() - { - Dispose(true); - // This object will be cleaned up by the Dispose method. - // Therefore, you should call GC.SupressFinalize to - // take this object off the finalization queue - // and prevent finalization code for this object - // from executing a second time. - GC.SuppressFinalize(this); - } - - /// - /// Dispose(bool disposing) executes in two distinct scenarios. - /// If disposing equals true, the method has been called directly - /// or indirectly by a user's code. Managed and unmanaged resources - /// can be disposed. - /// If disposing equals false, the method has been called by the - /// runtime from inside the finalizer and you should not reference - /// other objects. Only unmanaged resources can be disposed. - /// - /// disposing flag - private void Dispose(bool disposing) - { - // Check to see if Dispose has already been called. - if(!this.disposed) - { - // If disposing equals true, dispose all managed - // and unmanaged resources. - if(disposing) - { - // Dispose managed resources. - _binaryFileData = null; - _mergedFileOffsets = null; - } - - - } - disposed = true; - } - } -} diff --git a/irc/TechBot/CHMLibrary/CHMDecoding/CHMStrings.cs b/irc/TechBot/CHMLibrary/CHMDecoding/CHMStrings.cs deleted file mode 100644 index 5942d4e8cfe..00000000000 --- a/irc/TechBot/CHMLibrary/CHMDecoding/CHMStrings.cs +++ /dev/null @@ -1,256 +0,0 @@ -using System; -using System.IO; -using System.Collections; -using System.Collections.Specialized; - -namespace HtmlHelp.ChmDecoding -{ - /// - /// The class CHMStrings implements a string collection read from the #STRINGS file - /// - internal sealed class CHMStrings : IDisposable - { - /// - /// Constant specifying the size of the string blocks - /// - private const int STRING_BLOCK_SIZE = 4096; - /// - /// Internal flag specifying if the object is going to be disposed - /// - private bool disposed = false; - /// - /// Internal member storing the binary file data - /// - private byte[] _binaryFileData = null; - /// - /// Internal member storing the string dictionary - /// - private Hashtable _stringDictionary = new Hashtable(); - /// - /// Internal member storing the associated chmfile object - /// - private CHMFile _associatedFile = null; - - /// - /// Constructor of the class - /// - /// binary file data of the #STRINGS file - /// associated chm file - public CHMStrings(byte[] binaryFileData, CHMFile associatedFile) - { - _binaryFileData = binaryFileData; - _associatedFile = associatedFile; - DecodeData(); - } - - - /// - /// Standard constructor - /// - internal CHMStrings() - { - } - - #region Data dumping - /// - /// Dump the class data to a binary writer - /// - /// writer to write the data - internal void Dump(ref BinaryWriter writer) - { - writer.Write( _stringDictionary.Count ); - - if (_stringDictionary.Count != 0) - { - IDictionaryEnumerator iDictionaryEnumerator = _stringDictionary.GetEnumerator(); - while (iDictionaryEnumerator.MoveNext()) - { - DictionaryEntry dictionaryEntry = (DictionaryEntry)iDictionaryEnumerator.Current; - writer.Write( Int32.Parse(dictionaryEntry.Key.ToString()) ); - writer.Write( dictionaryEntry.Value.ToString() ); - } - } - } - - /// - /// Reads the object data from a dump store - /// - /// reader to read the data - internal void ReadDump(ref BinaryReader reader) - { - int nCnt = reader.ReadInt32(); - - for(int i=0; i - /// Sets the associated CHMFile instance - /// - /// instance to set - internal void SetCHMFile(CHMFile associatedFile) - { - _associatedFile = associatedFile; - } - #endregion - - /// - /// Decodes the binary file data and fills the internal properties - /// - /// true if succeeded - private bool DecodeData() - { - bool bRet = true; - - MemoryStream memStream = new MemoryStream(_binaryFileData); - BinaryReader binReader = new BinaryReader(memStream); - - //binReader.ReadByte(); // file starts with a NULL character for 0-based offset indexing - - int nStringOffset = 0; - int nSubsetOffset = 0; - - while( (memStream.Position < memStream.Length) && (bRet) ) - { - nStringOffset = (int)memStream.Position; - byte [] stringBlock = binReader.ReadBytes(STRING_BLOCK_SIZE); - bRet &= DecodeBlock(stringBlock, ref nStringOffset, ref nSubsetOffset); - } - - return bRet; - } - - /// - /// Decodes a string block - /// - /// byte array which represents the string block - /// current string offset number - /// reference to a subset variable - /// true if succeeded - /// If a string crosses the end of a block then it will be cut off - /// without a NT and repeated in full, with a NT, at the start of the next block. - /// For eg "To customize the appearance of a contents file" might become - /// "To customize the (block ending)To customize the appearance of a contents file" - /// when there are 17 bytes left at the end of the block. - private bool DecodeBlock( byte[] stringBlock, ref int nStringOffset, ref int nSubsetOffset) - { - bool bRet = true; - - MemoryStream memStream = new MemoryStream(stringBlock); - BinaryReader binReader = new BinaryReader(memStream); - - while( (memStream.Position < memStream.Length) && (bRet) ) - { - bool bFoundTerminator = false; - - int nCurOffset = nStringOffset + (int)memStream.Position; - - string sTemp = BinaryReaderHelp.ExtractString(ref binReader, ref bFoundTerminator, 0, true, _associatedFile.TextEncoding); - - if(nSubsetOffset != 0) - { - _stringDictionary[nSubsetOffset.ToString()] = sTemp.ToString(); - } - else - { - _stringDictionary[nCurOffset.ToString()] = sTemp.ToString(); - } - - if( bFoundTerminator ) - { - nSubsetOffset = 0; - } - else - { - nSubsetOffset = nCurOffset; - } - } - - return bRet; - } - - /// - /// Indexer which returns the string at a given offset - /// - public string this[int offset] - { - get - { - if(offset == -1) - return String.Empty; - - string sTemp = (string)_stringDictionary[ offset.ToString() ]; - - if(sTemp == null) - return String.Empty; - - return sTemp; - } - } - - /// - /// Indexer which returns the string at a given offset - /// - public string this[string offset] - { - get - { - if(offset == "-1") - return String.Empty; - - string sTemp = (string)_stringDictionary[ offset ]; - - if(sTemp == null) - return String.Empty; - - return sTemp; - } - } - - /// - /// Implement IDisposable. - /// - public void Dispose() - { - Dispose(true); - // This object will be cleaned up by the Dispose method. - // Therefore, you should call GC.SupressFinalize to - // take this object off the finalization queue - // and prevent finalization code for this object - // from executing a second time. - GC.SuppressFinalize(this); - } - - /// - /// Dispose(bool disposing) executes in two distinct scenarios. - /// If disposing equals true, the method has been called directly - /// or indirectly by a user's code. Managed and unmanaged resources - /// can be disposed. - /// If disposing equals false, the method has been called by the - /// runtime from inside the finalizer and you should not reference - /// other objects. Only unmanaged resources can be disposed. - /// - /// disposing flag - private void Dispose(bool disposing) - { - // Check to see if Dispose has already been called. - if(!this.disposed) - { - // If disposing equals true, dispose all managed - // and unmanaged resources. - if(disposing) - { - // Dispose managed resources. - _binaryFileData = null; - _stringDictionary = null; - } - } - disposed = true; - } - } -} diff --git a/irc/TechBot/CHMLibrary/CHMDecoding/CHMSystem.cs b/irc/TechBot/CHMLibrary/CHMDecoding/CHMSystem.cs deleted file mode 100644 index 042e243f5e1..00000000000 --- a/irc/TechBot/CHMLibrary/CHMDecoding/CHMSystem.cs +++ /dev/null @@ -1,821 +0,0 @@ -using System; -using System.Collections; -using System.Diagnostics; -using System.IO; -using System.Text; -using System.Globalization; - -namespace HtmlHelp.ChmDecoding -{ - /// - /// The class CHMSystem reads the #SYSTEM file of the chm and stores its settings - /// - internal sealed class CHMSystem : IDisposable - { - /// - /// Internal flag specifying if the object is going to be disposed - /// - private bool disposed = false; - /// - /// Internal member storing the binary file data - /// - private byte[] _binaryFileData = null; - /// - /// Internal member storing the file version - /// - private int _fileVersion = 0; - /// - /// Internal member storing the contents file path - /// - private string _contentsFile = ""; - /// - /// Internal member storing the index file path - /// - private string _indexFile = ""; - /// - /// Internal member storing the default help topic - /// - private string _defaultTopic = ""; - /// - /// Internal member storing the help-window title - /// - private string _title = ""; - /// - /// Internal flag if dbcs is on - /// - private bool _dbcs = false; - /// - /// Internal flag if fulltext search is enabled - /// - private bool _fullTextSearch = false; - /// - /// Internal flag if KLinks are in the file - /// - private bool _hasKLinks = false; - /// - /// Internal flag if ALinks are in the file - /// - private bool _hasALinks = false; - /// - /// Internal member storing the name of the default window - /// - private string _defaultWindow = ""; - /// - /// Internal member storing the filename of the compiled file - /// - private string _compileFile = ""; - /// - /// Internal flag storing the offset value of the binary index - /// - private uint _binaryIndexURLTableID = 0; - /// - /// Inernal member storing the compiler version this file was compiled - /// - private string _compilerVersion = ""; - /// - /// Internal flag storing the offset value of the binary TOC - /// - private uint _binaryTOCURLTableID = 0; - /// - /// Internal member storing the associated chmfile object - /// - private CHMFile _associatedFile = null; - /// - /// Internal member storing the default fontface, size, charset - /// - private string _defaultFont = ""; - /// - /// Internal member storing the culture info of the file - /// - private CultureInfo _culture; - - /// - /// Constructor of the class - /// - /// binary file data of the #SYSTEM file - /// associated chm file - public CHMSystem(byte[] binaryFileData, CHMFile associatedFile) - { - _binaryFileData = binaryFileData; - _associatedFile = associatedFile; - DecodeData(); - - if(_culture == null) - { - // Set the text encoder of the chm file to the read charset/codepage - _associatedFile.TextEncoding = Encoding.GetEncoding( this.CodePage ); - } - } - - /// - /// Decodes the binary file data and fills the internal properties - /// - /// true if succeeded - private bool DecodeData() - { - bool bRet = true; - - MemoryStream memStream = new MemoryStream(_binaryFileData); - BinaryReader binReader = new BinaryReader(memStream); - - // First entry = DWORD for version number - _fileVersion = (int) binReader.ReadInt32(); - - while( (memStream.Position < memStream.Length) && (bRet) ) - { - bRet &= DecodeEntry(ref binReader); - } - - return bRet; - } - - /// - /// Decodes an #system file entry - /// - /// binary reader reference - /// true if succeeded - private bool DecodeEntry(ref BinaryReader binReader) - { - bool bRet = true; - - int code = (int) binReader.ReadInt16(); // entry code, WORD - int length = (int) binReader.ReadInt16(); // length of entry - - switch(code) - { - case 0: - { - _contentsFile = BinaryReaderHelp.ExtractString(ref binReader,length, 0, true, _associatedFile.TextEncoding); - };break; - case 1: - { - _indexFile = BinaryReaderHelp.ExtractString(ref binReader,length, 0, true, _associatedFile.TextEncoding); - };break; - case 2: - { - _defaultTopic = BinaryReaderHelp.ExtractString(ref binReader,length, 0, true, _associatedFile.TextEncoding); - };break; - case 3: - { - _title = BinaryReaderHelp.ExtractString(ref binReader,length, 0, true, _associatedFile.TextEncoding); - };break; - case 4: - { - int nTemp = 0; - nTemp = binReader.ReadInt32(); // read DWORD LCID - _culture = new CultureInfo(nTemp); - - if(_culture != null) - _associatedFile.TextEncoding = Encoding.GetEncoding(_culture.TextInfo.ANSICodePage); - - nTemp = binReader.ReadInt32(); // read DWORD DBCS - _dbcs = (nTemp == 1); - - nTemp = binReader.ReadInt32(); // read DWORD Fulltext search - _fullTextSearch = (nTemp == 1); - - nTemp = binReader.ReadInt32(); // read DWORD has klinks - _hasKLinks = (nTemp != 0); - - nTemp = binReader.ReadInt32(); // read DWORD has alinks - _hasALinks = (nTemp != 0); - - // read the rest of code 4 (not important for us) - byte[] temp = new byte[length-(5*4)]; - temp = binReader.ReadBytes(length-(5*4)); - };break; - case 5: - { - _defaultWindow = BinaryReaderHelp.ExtractString(ref binReader,length, 0, true, _associatedFile.TextEncoding); - };break; - case 6: - { - _compileFile = BinaryReaderHelp.ExtractString(ref binReader,length, 0, true, _associatedFile.TextEncoding); - };break; - case 7: - { - if(_fileVersion > 2) - { - _binaryIndexURLTableID = (uint) binReader.ReadInt32(); - } - else - { - byte[] read = binReader.ReadBytes(length); - int i=read.Length; - } - };break; - case 8: - { - // abbreviation (not interresting for us) - byte[] read = binReader.ReadBytes(length); - int i=read.Length; - };break; - case 9: - { - _compilerVersion = BinaryReaderHelp.ExtractString(ref binReader,length, 0, true, _associatedFile.TextEncoding); - };break; - case 10: - { - // timestamp of the file (not interresting for us) - byte[] read = binReader.ReadBytes(length); - int i=read.Length; - };break; - case 11: - { - if(_fileVersion > 2) - { - _binaryTOCURLTableID = (uint) binReader.ReadInt32(); - } - else - { - byte[] read = binReader.ReadBytes(length); - int i=read.Length; - } - };break; - case 12: - { - // number of information bytes - byte[] read = binReader.ReadBytes(length); - int i=read.Length; - };break; - case 13: - { - // copy of file #idxhdr - byte[] read = binReader.ReadBytes(length); - int i=read.Length; - };break; - case 14: - { - // custom tabs for HH viewer - byte[] read = binReader.ReadBytes(length); - int i=read.Length; - };break; - case 15: - { - // a checksum - byte[] read = binReader.ReadBytes(length); - int i=read.Length; - };break; - case 16: - { - // Default Font=string,number,number - // The string is the name of the font, the first number is the - // point size & the last number is the character set used by the font. - // For acceptable values see *_CHARSET defines in wingdi.h from the - // Windows SDK or the same file in MinGW or Wine. - // Most of the time you will only want to use 0, which is the value for ANSI, - // which is the subset of ASCII used by Windows. - _defaultFont = BinaryReaderHelp.ExtractString(ref binReader,length, 0, true, _associatedFile.TextEncoding); - - };break; - default: - { - byte[] temp = new byte[length]; - temp = binReader.ReadBytes(length); - //bRet = false; - int i=temp.Length; - };break; - } - - return bRet; - } - - /// - /// Reads all HHC files and checks which one has the global object tag. - /// This hhc file will be returned as master hhc - /// - /// list of topics containing the extension hhc - /// true if the arraylist contains topic items - /// the filename of the found master toc - private string GetMasterHHC(ArrayList hhcTopics, bool TopicItemArrayList) - { - string sRet = ""; - - if( (hhcTopics!=null) && (hhcTopics.Count > 0) ) - { - if( TopicItemArrayList ) - { - if(hhcTopics.Count == 1) - { - sRet = ((TopicEntry)hhcTopics[0]).Locale; - } - else - { - foreach(TopicEntry curEntry in hhcTopics) - { - CHMStream.CHMStream iw=null; - MemoryStream fileObject=null; - - if( _associatedFile.CurrentStorageWrapper == null) - { - iw=new CHMStream.CHMStream(); - iw.OpenCHM(_associatedFile.ChmFilePath); - } - else - { - iw = _associatedFile.CurrentStorageWrapper; - } - - fileObject = iw.OpenStream(curEntry.Locale); - if( fileObject != null) - { - string fileString =_associatedFile.TextEncoding.GetString(fileObject.ToArray(),0,(int)fileObject.Length); - fileObject.Close(); - - if( HHCParser.HasGlobalObjectTag(fileString, _associatedFile) ) - { - sRet = curEntry.Locale; - break; - } - } - } - } - } - else - { - if(hhcTopics.Count == 1) - { - sRet = ((string)hhcTopics[0]); - } - else - { - foreach(string curEntry in hhcTopics) - { - CHMStream.CHMStream iw=null; - MemoryStream fileObject=null; - - if( _associatedFile.CurrentStorageWrapper == null) - { - iw=new CHMStream.CHMStream(); - iw.OpenCHM(_associatedFile.ChmFilePath); - } - else - { - iw = _associatedFile.CurrentStorageWrapper; - } - - fileObject = iw.OpenStream(curEntry); - if( fileObject != null) - { - string fileString =_associatedFile.TextEncoding.GetString(fileObject.ToArray(),0,(int)fileObject.Length); - fileObject.Close(); - - if( HHCParser.HasGlobalObjectTag(fileString, _associatedFile) ) - { - sRet = curEntry; - break; - } - } - } - } - } - } - - return sRet; - } - - /// - /// Gets the file version of the chm file. - /// 2 for Compatibility=1.0, 3 for Compatibility=1.1 - /// - public int FileVersion - { - get { return _fileVersion; } - } - - /// - /// Gets the contents file name - /// - public string ContentsFile - { - get - { - if( BinaryTOC ) // if the file contains a binary TOC - { - // make sure the CHMFile instance exists and has loaded the file #URLTBL - if( (_associatedFile != null) && (_associatedFile.UrltblFile != null ) ) - { - // Get an url-table entry by its unique id - UrlTableEntry entry = _associatedFile.UrltblFile.GetByUniqueID( this.BinaryTOCURLTableID ); - if(entry != null) - { - // entry found, return the url ( = filename ) - return entry.URL; - } - } - } - else - { - if(_contentsFile.Length <= 0) - { - string sCheck = "Table of Contents.hhc"; // default HHP contents filename - - if( (_associatedFile != null) && (_associatedFile.TopicsFile != null ) ) - { - TopicEntry te = _associatedFile.TopicsFile.GetByLocale( sCheck ); - - if( te == null) - { - sCheck = "toc.hhc"; // default HHP contents filename - - te = _associatedFile.TopicsFile.GetByLocale( sCheck ); - - if( te == null) - { - sCheck = CompileFile + ".hhc"; - - te = _associatedFile.TopicsFile.GetByLocale( sCheck ); - - if( te == null) - { - ArrayList arrExt = _associatedFile.TopicsFile.GetByExtension("hhc"); - - if( arrExt == null ) - { - arrExt = _associatedFile.EnumFilesByExtension("hhc"); - - if( arrExt == null ) - { - Debug.WriteLine("CHMSystem.ContentsFile - Failed, contents file not found !"); - } - else - { - if(arrExt.Count > 1) - { - sCheck = GetMasterHHC(arrExt, false); - _contentsFile = sCheck; - } - else - { - _contentsFile = ((string)arrExt[0]); - sCheck = _contentsFile; - } - } - } - else - { - if(arrExt.Count > 1) - { - sCheck = GetMasterHHC(arrExt, true); - _contentsFile = sCheck; - } - else - { - _contentsFile = ((TopicEntry)arrExt[0]).Locale; - sCheck = _contentsFile; - } - } - } - else - { - _contentsFile = sCheck; - } - } - else - { - _contentsFile = sCheck; - } - } - else - { - _contentsFile = sCheck; - } - } - - return sCheck; - } - } - - return _contentsFile; - } - } - - /// - /// Gets the index file name - /// - public string IndexFile - { - get - { - if( BinaryIndex ) // if the file contains a binary index - { - // make sure the CHMFile instance exists and has loaded the file #URLTBL - if( (_associatedFile != null) && (_associatedFile.UrltblFile != null ) ) - { - // Get an url-table entry by its unique id - UrlTableEntry entry = _associatedFile.UrltblFile.GetByUniqueID( this.BinaryIndexURLTableID ); - if(entry != null) - { - // entry found, return the url ( = filename ) - return entry.URL; - } - } - } - else - { - if(_indexFile.Length <= 0) - { - string sCheck = "Index.hhk"; // default HHP index filename - - if( (_associatedFile != null) && (_associatedFile.TopicsFile != null ) ) - { - TopicEntry te = _associatedFile.TopicsFile.GetByLocale( sCheck ); - - if( te == null) - { - sCheck = CompileFile + ".hhk"; - - te = _associatedFile.TopicsFile.GetByLocale( sCheck ); - - if( te == null) - { - ArrayList arrExt = _associatedFile.TopicsFile.GetByExtension("hhk"); - - if( arrExt == null ) - { - Debug.WriteLine("CHMSystem.IndexFile - Failed, index file not found !"); - } - else - { - _indexFile = ((TopicEntry)arrExt[0]).Locale; - sCheck = _indexFile; - } - } - else - { - _indexFile = sCheck; - } - } - else - { - _indexFile = sCheck; - } - } - - return sCheck; - } - } - return _indexFile; - } - } - - /// - /// Sets the default topic of this file - /// - /// new local value of the topic - internal void SetDefaultTopic(string local) - { - _defaultTopic = local; - } - - /// - /// Gets the default help topic - /// - public string DefaultTopic - { - get { return _defaultTopic; } - } - - /// - /// Gets the title of the help window - /// - public string Title - { - get { return _title; } - } - - /// - /// Gets the flag if DBCS is in use - /// - public bool DBCS - { - get { return _dbcs; } - } - - /// - /// Gets the flag if full-text-search is available - /// - public bool FullTextSearch - { - get { return _fullTextSearch; } - } - - /// - /// Gets the flag if the file has ALinks - /// - public bool HasALinks - { - get { return _hasALinks; } - } - - /// - /// Gets the flag if the file has KLinks - /// - public bool HasKLinks - { - get { return _hasKLinks; } - } - - /// - /// Gets the default window name - /// - public string DefaultWindow - { - get { return _defaultWindow; } - } - - /// - /// Gets the file name of the compile file - /// - public string CompileFile - { - get { return _compileFile; } - } - - /// - /// Gets the id of the binary index in the url table - /// - public uint BinaryIndexURLTableID - { - get { return _binaryIndexURLTableID; } - } - - /// - /// Gets the flag if the chm has a binary index file - /// - public bool BinaryIndex - { - get { return (_binaryIndexURLTableID>0); } - } - - /// - /// Gets the flag if the chm has a binary index file - /// - public string CompilerVersion - { - get { return _compilerVersion; } - } - - /// - /// Gets the id of the binary toc in the url table - /// - public uint BinaryTOCURLTableID - { - get { return _binaryTOCURLTableID; } - } - - /// - /// Gets the flag if the chm has a binary toc file - /// - public bool BinaryTOC - { - get { return (_binaryTOCURLTableID>0); } - } - - /// - /// Gets the font face of the read font property. - /// Empty string for default font. - /// - public string FontFace - { - get - { - if( _defaultFont.Length > 0) - { - string [] fontSplit = _defaultFont.Split( new char[]{','}); - if(fontSplit.Length > 0) - return fontSplit[0].Trim(); - } - - return ""; - } - } - - /// - /// Gets the font size of the read font property. - /// 0 for default font size - /// - public double FontSize - { - get - { - if( _defaultFont.Length > 0) - { - string [] fontSplit = _defaultFont.Split( new char[]{','}); - if(fontSplit.Length > 1) - return double.Parse(fontSplit[1].Trim()); - } - - return 0.0; - } - } - - /// - /// Gets the character set of the read font property - /// 1 for default - /// - public int CharacterSet - { - get - { - if( _defaultFont.Length > 0) - { - string [] fontSplit = _defaultFont.Split( new char[]{','}); - if(fontSplit.Length > 2) - return Int32.Parse(fontSplit[2].Trim()); - } - - return 0; - } - } - - /// - /// Gets the codepage depending on the read font property - /// - public int CodePage - { - get - { - // if we've read a LCID from the system file - // ignore the font-property settings and return - // the codepage generated from the culture info - if(_culture != null) - { - return _culture.TextInfo.ANSICodePage; - } - - int nRet = 1252; // default codepage windows-1252 - - int nCSet = CharacterSet; - - switch(nCSet) - { - case 0x00: nRet = 1252;break; // ANSI_CHARSET - case 0xCC: nRet = 1251;break; // RUSSIAN_CHARSET - case 0xEE: nRet = 1250;break; // EE_CHARSET - case 0xA1: nRet = 1253;break; // GREEK_CHARSET - case 0xA2: nRet = 1254;break; // TURKISH_CHARSET - case 0xBA: nRet = 1257;break; // BALTIC_CHARSET - case 0xB1: nRet = 1255;break; // HEBREW_CHARSET - case 0xB2: nRet = 1256;break; // ARABIC_CHARSET - case 0x80: nRet = 932;break; // SHIFTJIS_CHARSET - case 0x81: nRet = 949;break; // HANGEUL_CHARSET - case 0x86: nRet = 936;break; // GB2313_CHARSET - case 0x88: nRet = 950;break; // CHINESEBIG5_CHARSET - } - - return nRet; - } - } - - /// - /// Gets the assiciated culture info - /// - public CultureInfo Culture - { - get { return _culture; } - } - - /// - /// Implement IDisposable. - /// - public void Dispose() - { - Dispose(true); - // This object will be cleaned up by the Dispose method. - // Therefore, you should call GC.SupressFinalize to - // take this object off the finalization queue - // and prevent finalization code for this object - // from executing a second time. - GC.SuppressFinalize(this); - } - - /// - /// Dispose(bool disposing) executes in two distinct scenarios. - /// If disposing equals true, the method has been called directly - /// or indirectly by a user's code. Managed and unmanaged resources - /// can be disposed. - /// If disposing equals false, the method has been called by the - /// runtime from inside the finalizer and you should not reference - /// other objects. Only unmanaged resources can be disposed. - /// - /// disposing flag - private void Dispose(bool disposing) - { - // Check to see if Dispose has already been called. - if(!this.disposed) - { - // If disposing equals true, dispose all managed - // and unmanaged resources. - if(disposing) - { - // Dispose managed resources. - _binaryFileData = null; - } - - - } - disposed = true; - } - } -} diff --git a/irc/TechBot/CHMLibrary/CHMDecoding/CHMTocidx.cs b/irc/TechBot/CHMLibrary/CHMDecoding/CHMTocidx.cs deleted file mode 100644 index d6ca1aa02c1..00000000000 --- a/irc/TechBot/CHMLibrary/CHMDecoding/CHMTocidx.cs +++ /dev/null @@ -1,288 +0,0 @@ -using System; -using System.IO; -using System.Collections; - -namespace HtmlHelp.ChmDecoding -{ - /// - /// The class CHMTocidx implements functions to decode the #TOCIDX internal file. - /// - internal sealed class CHMTocidx : IDisposable - { - /// - /// Constant specifying the size of the data blocks - /// - private const int BLOCK_SIZE = 0x1000; - /// - /// Internal flag specifying if the object is going to be disposed - /// - private bool disposed = false; - /// - /// Internal member storing the binary file data - /// - private byte[] _binaryFileData = null; - /// - /// Internal memebr storing the offset to the 20/28 byte structs - /// - private int _offset2028 = 0; - /// - /// Internal member storing the offset to the 16 byte structs - /// - private int _offset16structs = 0; - /// - /// Internal member storing the number of 16 byte structs - /// - private int _numberOf16structs = 0; - /// - /// Internal member storing the offset to the topic list - /// - private int _offsetOftopics = 0; - /// - /// Internal member storing the toc - /// - private ArrayList _toc = new ArrayList(); - /// - /// Internal member for offset seeking - /// - private Hashtable _offsetTable = new Hashtable(); - /// - /// Internal member storing the associated chmfile object - /// - private CHMFile _associatedFile = null; - - /// - /// Constructor of the class - /// - /// binary file data of the #TOCIDX file - /// associated chm file - public CHMTocidx(byte[] binaryFileData, CHMFile associatedFile) - { - _binaryFileData = binaryFileData; - _associatedFile = associatedFile; - DecodeData(); - - // clear internal binary data after extraction - _binaryFileData = null; - } - - /// - /// Decodes the binary file data and fills the internal properties - /// - /// true if succeeded - private bool DecodeData() - { - _toc = new ArrayList(); - _offsetTable = new Hashtable(); - - bool bRet = true; - - MemoryStream memStream = new MemoryStream(_binaryFileData); - BinaryReader binReader = new BinaryReader(memStream); - - int nCurOffset = 0; - - _offset2028 = binReader.ReadInt32(); - _offset16structs = binReader.ReadInt32(); - _numberOf16structs = binReader.ReadInt32(); - _offsetOftopics = binReader.ReadInt32(); - - binReader.BaseStream.Seek( _offset2028, SeekOrigin.Begin ); - - if( RecursivelyBuildTree(ref binReader, _offset2028, _toc, null) ) - { - binReader.BaseStream.Seek( _offset16structs, SeekOrigin.Begin ); - nCurOffset = (int)binReader.BaseStream.Position; - - for(int i=0; i < _numberOf16structs; i++) - { - int tocOffset = binReader.ReadInt32(); - int sqNr = binReader.ReadInt32(); - int topOffset = binReader.ReadInt32(); - int hhctopicIdx = binReader.ReadInt32(); - - nCurOffset = (int)binReader.BaseStream.Position; - - int topicIdx = -1; - // if the topic offset is within the range of the stream - // and is >= the offset of the first topic dword - if((topOffset < (binReader.BaseStream.Length - 4)) && (topOffset >= _offsetOftopics)) - { - // read the index of the topic for this item - binReader.BaseStream.Seek( topOffset, SeekOrigin.Begin); - topicIdx = binReader.ReadInt32(); - binReader.BaseStream.Seek( nCurOffset, SeekOrigin.Begin); - - - TOCItem item = (TOCItem)_offsetTable[tocOffset.ToString()]; - if( item != null) - { - if(( topicIdx < _associatedFile.TopicsFile.TopicTable.Count)&&(topicIdx>=0)) - { - TopicEntry te = (TopicEntry) (_associatedFile.TopicsFile.TopicTable[topicIdx]); - if( (te != null) && (item.TopicOffset < 0) ) - { - item.TopicOffset = te.EntryOffset; - } - - } - } - } - } - } - - return bRet; - } - - /// - /// Recursively reads the binary toc tree from the file - /// - /// reference to binary reader - /// offset of the first node in the current level - /// arraylist of TOCItems for the current level - /// parent item for the item - /// Returns true if succeeded - private bool RecursivelyBuildTree(ref BinaryReader binReader, int NodeOffset, ArrayList level, TOCItem parentItem) - { - bool bRet = true; - int nextOffset=0; - - int nReadOffset = (int)binReader.BaseStream.Position; - - binReader.BaseStream.Seek(NodeOffset, SeekOrigin.Begin); - - do - { - int nCurOffset = (int)binReader.BaseStream.Position; - - int unkn1 = binReader.ReadInt16(); // unknown - int unkn2 = binReader.ReadInt16(); // unknown - - int flag = binReader.ReadInt32(); - - int nFolderAdd = 0; - - if((_associatedFile != null) && (_associatedFile.ImageTypeFolder)) - { - // get the value which should be added, to display folders instead of books - if(HtmlHelpSystem.UseHH2TreePics) - nFolderAdd = 8; - else - nFolderAdd = 4; - } - - int nFolderImgIdx = (HtmlHelpSystem.UseHH2TreePics ? (TOCItem.STD_FOLDER_HH2+nFolderAdd) : (TOCItem.STD_FOLDER_HH1+nFolderAdd)); - int nFileImgIdx = (HtmlHelpSystem.UseHH2TreePics ? TOCItem.STD_FILE_HH2 : TOCItem.STD_FILE_HH1); - - int stdImage = ((flag & 0x4)!=0) ? nFolderImgIdx : nFileImgIdx; - - int stringOffset = binReader.ReadInt32(); - - int ParentOffset = binReader.ReadInt32(); - nextOffset = binReader.ReadInt32(); - - int firstChildOffset = 0; - int unkn3=0; - - if( (flag&0x4)!=0 ) - { - firstChildOffset = binReader.ReadInt32(); - unkn3 = binReader.ReadInt32(); // unknown - } - - TOCItem newItem = new TOCItem(); - newItem.ImageIndex = stdImage; - newItem.Offset = nCurOffset; - newItem.OffsetNext = nextOffset; - newItem.AssociatedFile = _associatedFile; - newItem.TocMode = DataMode.Binary; - newItem.Parent = parentItem; - - if( (flag&0x08) == 0) - { - // toc item doesn't have a local value (=> stringOffset = offset of strings file) - newItem.Name = _associatedFile.StringsFile[stringOffset]; - } - else - { - // this item has a topic entry (=> stringOffset = index of topic entry) - if((stringOffset < _associatedFile.TopicsFile.TopicTable.Count) && (stringOffset >= 0)) - { - TopicEntry te = (TopicEntry) (_associatedFile.TopicsFile.TopicTable[stringOffset]); - if(te != null) - { - newItem.TopicOffset = te.EntryOffset; - } - } - } - - _offsetTable[nCurOffset.ToString()] = newItem; - - // if this item has children (firstChildOffset > 0) - if( firstChildOffset > 0) - { - bRet &= RecursivelyBuildTree(ref binReader, firstChildOffset, newItem.Children, newItem); - } - - level.Add( newItem ); - - if(nCurOffset != nextOffset) - binReader.BaseStream.Seek(nextOffset, SeekOrigin.Begin); - - }while(nextOffset != 0); - - binReader.BaseStream.Seek(nReadOffset, SeekOrigin.Begin); - - return bRet; - } - - /// - /// Gets the internal read toc - /// - internal ArrayList TOC - { - get { return _toc; } - } - - /// - /// Implement IDisposable. - /// - public void Dispose() - { - Dispose(true); - // This object will be cleaned up by the Dispose method. - // Therefore, you should call GC.SupressFinalize to - // take this object off the finalization queue - // and prevent finalization code for this object - // from executing a second time. - GC.SuppressFinalize(this); - } - - /// - /// Dispose(bool disposing) executes in two distinct scenarios. - /// If disposing equals true, the method has been called directly - /// or indirectly by a user's code. Managed and unmanaged resources - /// can be disposed. - /// If disposing equals false, the method has been called by the - /// runtime from inside the finalizer and you should not reference - /// other objects. Only unmanaged resources can be disposed. - /// - /// disposing flag - private void Dispose(bool disposing) - { - // Check to see if Dispose has already been called. - if(!this.disposed) - { - // If disposing equals true, dispose all managed - // and unmanaged resources. - if(disposing) - { - // Dispose managed resources. - _binaryFileData = null; - _toc = null; - _offsetTable = null; - } - } - disposed = true; - } - } -} diff --git a/irc/TechBot/CHMLibrary/CHMDecoding/CHMTopics.cs b/irc/TechBot/CHMLibrary/CHMDecoding/CHMTopics.cs deleted file mode 100644 index ce1451b53ef..00000000000 --- a/irc/TechBot/CHMLibrary/CHMDecoding/CHMTopics.cs +++ /dev/null @@ -1,235 +0,0 @@ -using System; -using System.IO; -using System.Collections; -using System.Collections.Specialized; - -namespace HtmlHelp.ChmDecoding -{ - /// - /// The class CHMTopics implements functionality to decode the #TOPICS internal file - /// - internal sealed class CHMTopics : IDisposable - { - /// - /// Internal flag specifying if the object is going to be disposed - /// - private bool disposed = false; - /// - /// Internal member storing the binary file data - /// - private byte[] _binaryFileData = null; - /// - /// Internal member storing the associated chmfile object - /// - private CHMFile _associatedFile = null; - /// - /// Internal member storing the topic list - /// - private ArrayList _topicTable = new ArrayList(); - - /// - /// Constructor of the class - /// - /// binary file data of the #TOPICS file - /// associated chm file - public CHMTopics(byte[] binaryFileData, CHMFile associatedFile) - { - _binaryFileData = binaryFileData; - _associatedFile = associatedFile; - DecodeData(); - - // clear internal binary data after extraction - _binaryFileData = null; - } - - - /// - /// Standard constructor - /// - internal CHMTopics() - { - } - - #region Data dumping - /// - /// Dump the class data to a binary writer - /// - /// writer to write the data - internal void Dump(ref BinaryWriter writer) - { - writer.Write( _topicTable.Count ); - foreach(TopicEntry curItem in _topicTable) - { - curItem.Dump(ref writer); - } - } - - /// - /// Reads the object data from a dump store - /// - /// reader to read the data - internal void ReadDump(ref BinaryReader reader) - { - int i=0; - int nCnt = reader.ReadInt32(); - - for(i=0; i - /// Sets the associated CHMFile instance - /// - /// instance to set - internal void SetCHMFile(CHMFile associatedFile) - { - _associatedFile = associatedFile; - - foreach(TopicEntry curEntry in _topicTable) - { - curEntry.SetCHMFile(associatedFile); - } - } - #endregion - - /// - /// Decodes the binary file data and fills the internal properties - /// - /// true if succeeded - private bool DecodeData() - { - bool bRet = true; - - MemoryStream memStream = new MemoryStream(_binaryFileData); - BinaryReader binReader = new BinaryReader(memStream); - - int nCurOffset = 0; - - while( (memStream.Position < memStream.Length) && (bRet) ) - { - int entryOffset = nCurOffset; - int tocIdx = binReader.ReadInt32(); - int titleOffset = binReader.ReadInt32(); - int urltablOffset = binReader.ReadInt32(); - int visibilityMode = binReader.ReadInt16(); - int unknownMode = binReader.ReadInt16(); - - TopicEntry newEntry = new TopicEntry(entryOffset, tocIdx, titleOffset, urltablOffset, visibilityMode, unknownMode, _associatedFile); - _topicTable.Add( newEntry ); - - nCurOffset = (int)memStream.Position; - } - - return bRet; - } - - /// - /// Gets the arraylist containing all topic entries. - /// - public ArrayList TopicTable - { - get - { - return _topicTable; - } - } - - /// - /// Gets the topic entry of a given offset - /// - public TopicEntry this[int offset] - { - get - { - foreach(TopicEntry curEntry in _topicTable) - if(curEntry.EntryOffset == offset) - return curEntry; - - return null; - } - } - - /// - /// Searches a topic by the locale name - /// - /// locale name to search - /// The topicentry instance if found, otherwise null - public TopicEntry GetByLocale(string locale) - { - foreach(TopicEntry curEntry in TopicTable) - { - if(curEntry.Locale.ToLower() == locale.ToLower()) - return curEntry; - } - - return null; - } - - /// - /// Searches the topics for all files with a given file extension - /// - /// extension to search - /// An arraylist of TopicEntry instances or null if no topic was found - public ArrayList GetByExtension(string fileExtension) - { - ArrayList arrRet = new ArrayList(); - - foreach(TopicEntry curEntry in TopicTable) - { - if(curEntry.Locale.ToLower().EndsWith(fileExtension.ToLower())) - arrRet.Add(curEntry); - } - - if(arrRet.Count > 0) - return arrRet; - - return null; - } - - /// - /// Implement IDisposable. - /// - public void Dispose() - { - Dispose(true); - // This object will be cleaned up by the Dispose method. - // Therefore, you should call GC.SupressFinalize to - // take this object off the finalization queue - // and prevent finalization code for this object - // from executing a second time. - GC.SuppressFinalize(this); - } - - /// - /// Dispose(bool disposing) executes in two distinct scenarios. - /// If disposing equals true, the method has been called directly - /// or indirectly by a user's code. Managed and unmanaged resources - /// can be disposed. - /// If disposing equals false, the method has been called by the - /// runtime from inside the finalizer and you should not reference - /// other objects. Only unmanaged resources can be disposed. - /// - /// disposing flag - private void Dispose(bool disposing) - { - // Check to see if Dispose has already been called. - if(!this.disposed) - { - // If disposing equals true, dispose all managed - // and unmanaged resources. - if(disposing) - { - // Dispose managed resources. - _binaryFileData = null; - _topicTable=null; - } - } - disposed = true; - } - } -} diff --git a/irc/TechBot/CHMLibrary/CHMDecoding/CHMUrlstr.cs b/irc/TechBot/CHMLibrary/CHMDecoding/CHMUrlstr.cs deleted file mode 100644 index b87eebab58e..00000000000 --- a/irc/TechBot/CHMLibrary/CHMDecoding/CHMUrlstr.cs +++ /dev/null @@ -1,308 +0,0 @@ -using System; -using System.IO; -using System.Collections; -using System.Collections.Specialized; - -namespace HtmlHelp.ChmDecoding -{ - /// - /// The class CHMUrlstr implements a string collection storing the URL strings of the help file - /// - internal sealed class CHMUrlstr : IDisposable - { - /// - /// Constant specifying the size of the string blocks - /// - private const int BLOCK_SIZE = 0x1000; - /// - /// Internal flag specifying if the object is going to be disposed - /// - private bool disposed = false; - /// - /// Internal member storing the binary file data - /// - private byte[] _binaryFileData = null; - /// - /// Internal member storing the url dictionary - /// - private Hashtable _urlDictionary = new Hashtable(); - /// - /// Internal member storing the framename dictionary - /// - private Hashtable _framenameDictionary = new Hashtable(); - /// - /// Internal member storing the associated chmfile object - /// - private CHMFile _associatedFile = null; - - /// - /// Constructor of the class - /// - /// binary file data of the #URLSTR file - /// associated chm file - public CHMUrlstr(byte[] binaryFileData, CHMFile associatedFile) - { - _binaryFileData = binaryFileData; - _associatedFile = associatedFile; - DecodeData(); - - // clear internal binary data after extraction - _binaryFileData = null; - } - - /// - /// Standard constructor - /// - internal CHMUrlstr() - { - } - - #region Data dumping - /// - /// Dump the class data to a binary writer - /// - /// writer to write the data - internal void Dump(ref BinaryWriter writer) - { - writer.Write( _urlDictionary.Count ); - - if (_urlDictionary.Count != 0) - { - IDictionaryEnumerator iDictionaryEnumerator = _urlDictionary.GetEnumerator(); - while (iDictionaryEnumerator.MoveNext()) - { - DictionaryEntry dictionaryEntry = (DictionaryEntry)iDictionaryEnumerator.Current; - writer.Write( Int32.Parse(dictionaryEntry.Key.ToString()) ); - writer.Write( dictionaryEntry.Value.ToString() ); - } - } - - writer.Write( _framenameDictionary.Count ); - - if (_framenameDictionary.Count != 0) - { - IDictionaryEnumerator iDictionaryEnumerator = _framenameDictionary.GetEnumerator(); - while (iDictionaryEnumerator.MoveNext()) - { - DictionaryEntry dictionaryEntry = (DictionaryEntry)iDictionaryEnumerator.Current; - writer.Write( Int32.Parse(dictionaryEntry.Key.ToString()) ); - writer.Write( dictionaryEntry.Value.ToString() ); - } - } - } - - /// - /// Reads the object data from a dump store - /// - /// reader to read the data - internal void ReadDump(ref BinaryReader reader) - { - int i=0; - int nCnt = reader.ReadInt32(); - - for(i=0; i - /// Sets the associated CHMFile instance - /// - /// instance to set - internal void SetCHMFile(CHMFile associatedFile) - { - _associatedFile = associatedFile; - } - #endregion - - /// - /// Decodes the binary file data and fills the internal properties - /// - /// true if succeeded - private bool DecodeData() - { - bool bRet = true; - - MemoryStream memStream = new MemoryStream(_binaryFileData); - BinaryReader binReader = new BinaryReader(memStream); - - int nCurOffset = 0; - - while( (memStream.Position < memStream.Length) && (bRet) ) - { - nCurOffset = (int)memStream.Position; - byte [] dataBlock = binReader.ReadBytes(BLOCK_SIZE); - bRet &= DecodeBlock(dataBlock, ref nCurOffset); - } - - return bRet; - } - - /// - /// Decodes a block of url-string data - /// - /// block of data - /// current file offset - /// true if succeeded - private bool DecodeBlock( byte[] dataBlock, ref int nOffset ) - { - bool bRet = true; - int blockOffset = nOffset; - - MemoryStream memStream = new MemoryStream(dataBlock); - BinaryReader binReader = new BinaryReader(memStream); - - if(nOffset==0) - binReader.ReadByte(); // first block starts with an unknown byte - - while( (memStream.Position < (memStream.Length-8)) && (bRet) ) - { - int entryOffset = blockOffset + (int)memStream.Position; - - int urlOffset = binReader.ReadInt32(); - int frameOffset = binReader.ReadInt32(); - - - // There is one way to tell where the end of the URL/FrameName - // pairs occurs: Repeat the following: read 2 DWORDs and if both - // are less than the current offset then this is the start of the Local - // strings else skip two NT strings. - // if(( (urlOffset < (entryOffset+8)) && (frameOffset < (entryOffset+8)) )) - // { - // //TODO: add correct string reading if an offset has been found - // /* - // int curOffset = (int)memStream.Position; - // - // memStream.Seek( (long)(blockOffset-urlOffset), SeekOrigin.Begin); - // string sTemp = CHMReader.ExtractString(ref binReader, 0, true); - // - // memStream.Seek( (long)(blockOffset-frameOffset), SeekOrigin.Begin); - // sTemp = CHMReader.ExtractString(ref binReader, 0, true); - // - // memStream.Seek((long)curOffset, SeekOrigin.Begin); - // */ - // - // - // int curOffs = (int)memStream.Position; - // BinaryReaderHelp.ExtractString(ref binReader, 0, true, _associatedFile.TextEncoding); - // nOffset += (int)memStream.Position - curOffs; - // - // curOffs = (int)memStream.Position; - // BinaryReaderHelp.ExtractString(ref binReader, 0, true, _associatedFile.TextEncoding); - // nOffset += (int)memStream.Position - curOffs; - // } - // else - { - bool bFoundTerminator = false; - - string sTemp = BinaryReaderHelp.ExtractString(ref binReader, ref bFoundTerminator, 0, true, _associatedFile.TextEncoding); - - if(sTemp == "") - { - //nOffset = nOffset + 1 + (int)memStream.Length - (int)memStream.Position; - memStream.Seek(memStream.Length-1, SeekOrigin.Begin); - } - else - { - _urlDictionary[entryOffset.ToString()] = sTemp.ToString(); - _framenameDictionary[ entryOffset.ToString() ] = sTemp.ToString() ; - } - } - } - - return bRet; - } - - /// - /// Gets the url at a given offset - /// - /// offset of url - /// the url at the given offset - public string GetURLatOffset(int offset) - { - if(offset == -1) - return String.Empty; - - string sTemp = (string)_urlDictionary[ offset.ToString() ]; - - if(sTemp == null) - return String.Empty; - - return sTemp; - } - - /// - /// Gets the framename at a given offset - /// - /// offset of the framename - /// the frame name at the given offset - public string GetFrameNameatOffset(int offset) - { - if(offset == -1) - return String.Empty; - - string sTemp = (string)_framenameDictionary[ offset.ToString() ]; - - if(sTemp == null) - return String.Empty; - - return sTemp; - } - - /// - /// Implement IDisposable. - /// - public void Dispose() - { - Dispose(true); - // This object will be cleaned up by the Dispose method. - // Therefore, you should call GC.SupressFinalize to - // take this object off the finalization queue - // and prevent finalization code for this object - // from executing a second time. - GC.SuppressFinalize(this); - } - - /// - /// Dispose(bool disposing) executes in two distinct scenarios. - /// If disposing equals true, the method has been called directly - /// or indirectly by a user's code. Managed and unmanaged resources - /// can be disposed. - /// If disposing equals false, the method has been called by the - /// runtime from inside the finalizer and you should not reference - /// other objects. Only unmanaged resources can be disposed. - /// - /// disposing flag - private void Dispose(bool disposing) - { - // Check to see if Dispose has already been called. - if(!this.disposed) - { - // If disposing equals true, dispose all managed - // and unmanaged resources. - if(disposing) - { - // Dispose managed resources. - _binaryFileData = null; - _urlDictionary = null; - _framenameDictionary = null; - } - } - disposed = true; - } - } -} diff --git a/irc/TechBot/CHMLibrary/CHMDecoding/CHMUrltable.cs b/irc/TechBot/CHMLibrary/CHMDecoding/CHMUrltable.cs deleted file mode 100644 index 79f718b84ce..00000000000 --- a/irc/TechBot/CHMLibrary/CHMDecoding/CHMUrltable.cs +++ /dev/null @@ -1,245 +0,0 @@ -using System; -using System.IO; -using System.Collections; - -namespace HtmlHelp.ChmDecoding -{ - /// - /// The class CHMUrltable implements methods to decode the #URLTBL internal file. - /// - internal sealed class CHMUrltable : IDisposable - { - /// - /// Constant specifying the size of the data blocks - /// - private const int BLOCK_SIZE = 0x1000; - /// - /// Constant specifying the number of records per block - /// - private const int RECORDS_PER_BLOCK = 341; - /// - /// Internal flag specifying if the object is going to be disposed - /// - private bool disposed = false; - /// - /// Internal member storing the binary file data - /// - private byte[] _binaryFileData = null; - /// - /// Internal member storing the url table - /// - private ArrayList _urlTable = new ArrayList(); - /// - /// Internal member storing the associated chmfile object - /// - private CHMFile _associatedFile = null; - - /// - /// Constructor of the class - /// - /// binary file data of the #URLTBL file - /// associated chm file - public CHMUrltable(byte[] binaryFileData, CHMFile associatedFile) - { - _binaryFileData = binaryFileData; - _associatedFile = associatedFile; - DecodeData(); - - // clear internal binary data after extraction - _binaryFileData = null; - } - - /// - /// Standard constructor - /// - internal CHMUrltable() - { - } - - #region Data dumping - /// - /// Dump the class data to a binary writer - /// - /// writer to write the data - internal void Dump(ref BinaryWriter writer) - { - writer.Write( _urlTable.Count ); - foreach(UrlTableEntry curItem in _urlTable) - { - curItem.Dump(ref writer); - } - } - - /// - /// Reads the object data from a dump store - /// - /// reader to read the data - internal void ReadDump(ref BinaryReader reader) - { - int i=0; - int nCnt = reader.ReadInt32(); - - for(i=0; i - /// Sets the associated CHMFile instance - /// - /// instance to set - internal void SetCHMFile(CHMFile associatedFile) - { - _associatedFile = associatedFile; - - foreach(UrlTableEntry curEntry in _urlTable) - { - curEntry.SetCHMFile(associatedFile); - } - } - #endregion - - /// - /// Decodes the binary file data and fills the internal properties - /// - /// true if succeeded - private bool DecodeData() - { - bool bRet = true; - - MemoryStream memStream = new MemoryStream(_binaryFileData); - BinaryReader binReader = new BinaryReader(memStream); - - int nCurOffset = 0; - - while( (memStream.Position < memStream.Length) && (bRet) ) - { - nCurOffset = (int)memStream.Position; - byte [] dataBlock = binReader.ReadBytes(BLOCK_SIZE); - bRet &= DecodeBlock(dataBlock, ref nCurOffset); - } - - return bRet; - } - - /// - /// Decodes a block of url-string data - /// - /// block of data - /// current file offset - /// true if succeeded - private bool DecodeBlock( byte[] dataBlock, ref int nOffset ) - { - bool bRet = true; - int blockOffset = nOffset; - - MemoryStream memStream = new MemoryStream(dataBlock); - BinaryReader binReader = new BinaryReader(memStream); - - for(int i=0; i < RECORDS_PER_BLOCK; i++) - { - int recordOffset = blockOffset + (int)memStream.Position; - - uint nuniqueID = (uint) binReader.ReadInt32(); // unknown dword - int ntopicsIdx = binReader.ReadInt32(); - int urlstrOffset = binReader.ReadInt32(); - - UrlTableEntry newEntry = new UrlTableEntry(nuniqueID, recordOffset, ntopicsIdx, urlstrOffset, _associatedFile); - _urlTable.Add(newEntry); - - if( memStream.Position >= memStream.Length) - break; - } - - if(dataBlock.Length == BLOCK_SIZE) - binReader.ReadInt32(); - - return bRet; - } - - /// - /// Gets the arraylist containing all urltable entries. - /// - public ArrayList UrlTable - { - get - { - return _urlTable; - } - } - - /// - /// Gets the urltable entry of a given offset - /// - public UrlTableEntry this[int offset] - { - get - { - foreach(UrlTableEntry curEntry in _urlTable) - if(curEntry.EntryOffset == offset) - return curEntry; - - return null; - } - } - - /// - /// Gets the urltable entry of a given uniqueID - /// - public UrlTableEntry GetByUniqueID(uint uniqueID) - { - foreach(UrlTableEntry curEntry in UrlTable) - { - if(curEntry.UniqueID == uniqueID) - return curEntry; - } - - return null; - } - - /// - /// Implement IDisposable. - /// - public void Dispose() - { - Dispose(true); - // This object will be cleaned up by the Dispose method. - // Therefore, you should call GC.SupressFinalize to - // take this object off the finalization queue - // and prevent finalization code for this object - // from executing a second time. - GC.SuppressFinalize(this); - } - - /// - /// Dispose(bool disposing) executes in two distinct scenarios. - /// If disposing equals true, the method has been called directly - /// or indirectly by a user's code. Managed and unmanaged resources - /// can be disposed. - /// If disposing equals false, the method has been called by the - /// runtime from inside the finalizer and you should not reference - /// other objects. Only unmanaged resources can be disposed. - /// - /// disposing flag - private void Dispose(bool disposing) - { - // Check to see if Dispose has already been called. - if(!this.disposed) - { - // If disposing equals true, dispose all managed - // and unmanaged resources. - if(disposing) - { - // Dispose managed resources. - _binaryFileData = null; - _urlTable = null; - } - } - disposed = true; - } - } -} diff --git a/irc/TechBot/CHMLibrary/CHMDecoding/DumpingInfo.cs b/irc/TechBot/CHMLibrary/CHMDecoding/DumpingInfo.cs deleted file mode 100644 index f42fb98ee11..00000000000 --- a/irc/TechBot/CHMLibrary/CHMDecoding/DumpingInfo.cs +++ /dev/null @@ -1,395 +0,0 @@ -using System; -using System.IO; -using System.Text; -using System.Diagnostics; -using System.Collections.Specialized; - -using ICSharpCode.SharpZipLib; -using ICSharpCode.SharpZipLib.Zip; -using ICSharpCode.SharpZipLib.Zip.Compression; -using ICSharpCode.SharpZipLib.Zip.Compression.Streams; - -using HtmlHelp; -// using HtmlHelp.Storage; - -namespace HtmlHelp.ChmDecoding -{ - /// - /// Enumeration for specifying the dumping compression - /// - public enum DumpCompression - { - /// - /// None - no data compression will be used. - /// Fastest but most memory intensive - /// - None = 0, - /// - /// Minimum - a minimum data compression will be used. - /// Fast but not much data reduction - /// - Minimum = 1, - /// - /// Medium - a medium data compression will be used. - /// Slower but medium data reduction - /// - Medium = 2, - /// - /// Maximum - a maximum data compression will be used. - /// Slowest but maximum data reduction - /// - Maximum = 3 - } - - /// - /// Flags which specify which data should be dumped - /// - [FlagsAttribute()] - public enum DumpingFlags - { - /// - /// DumpTextTOC - if this flag is set, text-based TOCs (sitemap format) will be dumped - /// - DumpTextTOC = 1, - /// - /// DumpBinaryTOC - if this flag is set, binary TOCs will be dumped - /// - DumpBinaryTOC = 2, - /// - /// DumpTextIndex - if this flag is set, the text-based index (sitemap format) will be dumped - /// - DumpTextIndex = 4, - /// - /// DumpBinaryIndex - if this flag is set, the binary index will be dumped - /// - DumpBinaryIndex = 8, - /// - /// DumpStrings - if this flag is set, the internal #STRINGS file will be dumped - /// - DumpStrings = 16, - /// - /// DumpUrlStr - if this flag is set, the internal #URLSTR file will be dumped - /// - DumpUrlStr = 32, - /// - /// DumpUrlTbl - if this flag is set, the internal #URLTBL file will be dumped - /// - DumpUrlTbl = 64, - /// - /// DumpTopics - if this flag is set, the internal #TOPICS file will be dumped - /// - DumpTopics = 128, - /// - /// DumpFullText - if this flag is set, the internal $FIftiMain file will be dumped - /// - DumpFullText = 256 - } - - /// - /// The class DumpingInfo implements information properties for the CHMFile class - /// if and how data dumping should be used. - /// - public sealed class DumpingInfo - { - public bool m_bAllowSaveDump=true; - - private readonly static BitVector32.Section DumpFlags = BitVector32.CreateSection(512); - - private const string _dumpHeader = "HtmlHelpSystem dump file 1.0"; - - private string _outputDir = ""; // emtpy string means, same directory as chm file - private DumpCompression _compressionLevel = DumpCompression.Maximum; - private CHMFile _chmFile = null; - - private DeflaterOutputStream _outputStream = null; - private InflaterInputStream _inputStream = null; - - private BinaryWriter _writer = null; - private BinaryReader _reader = null; - - private BitVector32 _flags; - - /// - /// Constructor of the class - /// - /// Combine flag values to specify which data should be dumped. - /// output directory. emtpy string means, - /// same directory as chm file (only if destination = ExternalFile) - /// compression which should be used - public DumpingInfo(DumpingFlags flags, string outputDir, DumpCompression compressionLevel) - { - _flags = new BitVector32(0); - int i = _flags[DumpFlags]; - _flags[DumpFlags] = i | (int)flags; - - _outputDir = outputDir; - _compressionLevel = compressionLevel; - } - - /// - /// Gets the flag if text-based TOCs will be written to the dumping file - /// - public bool DumpTextTOC - { - get { return ((_flags[DumpFlags] & (int)DumpingFlags.DumpTextTOC) != 0); } - } - - /// - /// Gets the flag if binary TOCs will be written to the dumping file - /// - public bool DumpBinaryTOC - { - get { return ((_flags[DumpFlags] & (int)DumpingFlags.DumpBinaryTOC) != 0); } - } - - /// - /// Gets the flag if the text-based index will be written to the dumping file - /// - public bool DumpTextIndex - { - get { return ((_flags[DumpFlags] & (int)DumpingFlags.DumpTextIndex) != 0); } - } - - /// - /// Gets the flag if the binary index will be written to the dumping file - /// - public bool DumpBinaryIndex - { - get { return ((_flags[DumpFlags] & (int)DumpingFlags.DumpBinaryIndex) != 0); } - } - - /// - /// Gets the flag if the #STRINGS file will be written to the dumping file - /// - public bool DumpStrings - { - get { return ((_flags[DumpFlags] & (int)DumpingFlags.DumpStrings) != 0); } - } - - /// - /// Gets the flag if the #URLSTR file will be written to the dumping file - /// - public bool DumpUrlStr - { - get { return ((_flags[DumpFlags] & (int)DumpingFlags.DumpUrlStr) != 0); } - } - - /// - /// Gets the flag if the #URLTBL file will be written to the dumping file - /// - public bool DumpUrlTbl - { - get { return ((_flags[DumpFlags] & (int)DumpingFlags.DumpUrlTbl) != 0); } - } - - /// - /// Gets the flag if the #TOPICS file will be written to the dumping file - /// - public bool DumpTopics - { - get { return ((_flags[DumpFlags] & (int)DumpingFlags.DumpTopics) != 0); } - } - - /// - /// Gets the flag if the $FIftiMain file will be written to the dumping file - /// - public bool DumpFullText - { - get { return ((_flags[DumpFlags] & (int)DumpingFlags.DumpFullText) != 0); } - } - - /// - /// Gets the dump output directory. - /// - /// emtpy string means, same directory as chm file - /// If Destination is set to DumpingOutput.InternalFile this property will be ignored - public string OutputDir - { - get { return _outputDir; } - } - - /// - /// The compression level used. - /// - public DumpCompression CompressionLevel - { - get { return _compressionLevel; } - } - - /// - /// Gets/Sets the CHMFile instance associated with this object - /// - internal CHMFile ChmFile - { - get { return _chmFile; } - set { _chmFile = value; } - } - - /// - /// Translates the compression level to the deflater constants - /// - private int CompLvl - { - get - { - switch(CompressionLevel) - { - case DumpCompression.None: return Deflater.NO_COMPRESSION; - case DumpCompression.Minimum: return Deflater.BEST_SPEED; - case DumpCompression.Medium: return Deflater.DEFAULT_COMPRESSION; - case DumpCompression.Maximum: return Deflater.BEST_COMPRESSION; - } - - return Deflater.BEST_COMPRESSION; - } - } - - /// - /// Checks if a dump exists - /// - internal bool DumpExists - { - get - { - if(_flags[DumpFlags] == 0) - return false; - - // we have a reader or writer to the dump so it must exist - if( (_reader != null) || (_writer != null) ) - return true; - - string sDmpFile = _chmFile.ChmFilePath; - sDmpFile=sDmpFile.ToLower().Replace(".chm",".CHB"); - - return File.Exists(sDmpFile); - } - } - - /// - /// Gets a binary writer instance which allows you to write to the dump - /// - internal BinaryWriter Writer - { - get - { - if (m_bAllowSaveDump==false) - return null; - - if(_flags[DumpFlags] == 0) - throw new InvalidOperationException("Nothing to dump. No flags have been set !"); - - if(_reader != null) - throw new InvalidOperationException("Can't write and read at the same time !"); - - if(_chmFile == null) - throw new InvalidOperationException("Only usable with an associated CHMFile instance !"); - - if(_writer==null) - { - string sDmpFile = _chmFile.ChmFilePath; - sDmpFile=sDmpFile.ToLower().Replace(".chm",".CHB"); - StreamWriter stream = new StreamWriter(sDmpFile, false, _chmFile.TextEncoding); - - // write header info uncompressed - BinaryWriter _hwriter = new BinaryWriter(stream.BaseStream); - _hwriter.Write(_dumpHeader); - _hwriter.Write((int)CompressionLevel); - - if(_compressionLevel == DumpCompression.None) - { - _writer = new BinaryWriter(stream.BaseStream); - } - else - { - _outputStream = new DeflaterOutputStream(stream.BaseStream, new Deflater(CompLvl)); - - _writer = new BinaryWriter(_outputStream); - } - } - - return _writer; - - } - } - - /// - /// Gets a binary reader which allows you to read from the dump - /// - internal BinaryReader Reader - { - get - { - if(_writer != null) - throw new InvalidOperationException("Can't write and read at the same time !"); - - if(_chmFile == null) - throw new InvalidOperationException("Only usable with an associated CHMFile instance !"); - - if(_reader==null) - { - string sDmpFile = _chmFile.ChmFilePath; - sDmpFile=sDmpFile.ToLower().Replace(".chm",".CHB"); - StreamReader stream = new StreamReader(sDmpFile, _chmFile.TextEncoding); - - BinaryReader _hReader = new BinaryReader(stream.BaseStream); - string sH = _hReader.ReadString(); - - if(sH != _dumpHeader) - { - _hReader.Close(); - Debug.WriteLine("Unexpected dump-file header !"); - throw new FormatException("DumpingInfo.Reader - Unexpected dump-file header !"); - } - - _compressionLevel = (DumpCompression)_hReader.ReadInt32(); -// if(_compressionLevel != (DumpCompression)_hReader.ReadInt32()) -// { -// _hReader.Close(); -// return null; -// } - - if(_compressionLevel == DumpCompression.None) - { - _reader = new BinaryReader(stream.BaseStream); - } - else - { - _inputStream = new InflaterInputStream(stream.BaseStream, new Inflater()); - - _reader = new BinaryReader(_inputStream); - } - } - - return _reader; - } - } - - /// - /// Saves data and closes the dump - /// - /// true if succeed - internal bool SaveData() - { - if (m_bAllowSaveDump==false) - return true; - - if(_writer != null) - { - if(_writer!=null) - _writer.Close(); - _outputStream = null; - _writer = null; - } - - if(_reader != null) - { - if(_reader!=null) - _reader.Close(); - _inputStream = null; - _reader = null; - } - - return true; - } - } -} diff --git a/irc/TechBot/CHMLibrary/CHMDecoding/FullTextEngine.cs b/irc/TechBot/CHMLibrary/CHMDecoding/FullTextEngine.cs deleted file mode 100644 index fc1d634d924..00000000000 --- a/irc/TechBot/CHMLibrary/CHMDecoding/FullTextEngine.cs +++ /dev/null @@ -1,1131 +0,0 @@ -using System; -using System.Data; -using System.Diagnostics; -using System.Text; -using System.Text.RegularExpressions; -using System.IO; -using System.Collections; -using System.Globalization; - -namespace HtmlHelp.ChmDecoding -{ - /// - /// The class FullTextSearcher implements a fulltext searcher for a single chm file ! - /// - internal sealed class FullTextEngine : IDisposable - { - #region Internal helper classes - /// - /// Internal class for decoding the header - /// - private sealed class FTHeader - { - /// - /// Internal member storing the number of indexed files - /// - private int _numberOfIndexFiles = 0; - /// - /// Internal member storing the offset of the root node - /// - private int _rootOffset = 0; - /// - /// Internal member storing the index-page count - /// - private int _pageCount = 0; - /// - /// Internal member storing the depth of the tree - /// - private int _depth = 0; - /// - /// Internal member storing the scale param for document index en-/decoding - /// - private byte _scaleDocIdx = 0; - /// - /// Internal member storing the scale param for code-count en-/decoding - /// - private byte _scaleCodeCnt = 0; - /// - /// Internal member storing the scale param for location codes en-/decoding - /// - private byte _scaleLocCodes = 0; - /// - /// Internal member storing the root param for document index en-/decoding - /// - private byte _rootDocIdx = 0; - /// - /// Internal member storing the root param for code-count en-/decoding - /// - private byte _rootCodeCnt = 0; - /// - /// Internal member storing the root param for location codes en-/decoding - /// - private byte _rootLocCodes = 0; - /// - /// Internal member storing the size of the nodes in bytes - /// - private int _nodeSize = 0; - /// - /// Internal member storing the length of the longest word - /// - private int _lengthOfLongestWord = 0; - /// - /// Internal member storing the total number of words - /// - private int _totalNumberOfWords = 0; - /// - /// Internal member storing the total number of unique words - /// - private int _numberOfUniqueWords = 0; - /// - /// Internal member storing the codepage identifier - /// - private int _codePage = 1252; - /// - /// Internal member storing the language code id - /// - private int _lcid = 1033; - /// - /// Internal member storing the text encoder - /// - private Encoding _textEncoder = Encoding.Default; - - /// - /// Constructor of the header - /// - /// binary data from which the header will be extracted - public FTHeader(byte[] binaryData) - { - DecodeHeader(binaryData); - } - - /// - /// Internal constructor for reading from dump - /// - internal FTHeader() - { - } - - /// - /// Decodes the binary header information and fills the members - /// - /// binary data from which the header will be extracted - private void DecodeHeader(byte[] binaryData) - { - MemoryStream memStream = new MemoryStream(binaryData); - BinaryReader binReader = new BinaryReader(memStream); - - binReader.ReadBytes(4); // 4 unknown bytes - - _numberOfIndexFiles = binReader.ReadInt32(); // number of indexed files - - binReader.ReadInt32(); // unknown - binReader.ReadInt32(); // unknown - - _pageCount = binReader.ReadInt32(); // page-count - _rootOffset = binReader.ReadInt32(); // file offset of the root node - _depth = binReader.ReadInt16(); // depth of the tree - - binReader.ReadInt32(); // unknown - - _scaleDocIdx = binReader.ReadByte(); - _rootDocIdx = binReader.ReadByte(); - _scaleCodeCnt = binReader.ReadByte(); - _rootCodeCnt = binReader.ReadByte(); - _scaleLocCodes = binReader.ReadByte(); - _rootLocCodes = binReader.ReadByte(); - - if( (_scaleDocIdx != 2) || ( _scaleCodeCnt != 2 ) || ( _scaleLocCodes != 2 ) ) - { - Debug.WriteLine("Unsupported scale for s/r encoding !"); - throw new InvalidOperationException("Unsupported scale for s/r encoding !"); - } - - binReader.ReadBytes(10); // unknown - - _nodeSize = binReader.ReadInt32(); - - binReader.ReadInt32(); // unknown - binReader.ReadInt32(); // not important - binReader.ReadInt32(); // not important - - _lengthOfLongestWord = binReader.ReadInt32(); - _totalNumberOfWords = binReader.ReadInt32(); - _numberOfUniqueWords = binReader.ReadInt32(); - - binReader.ReadInt32(); // not important - binReader.ReadInt32(); // not important - binReader.ReadInt32(); // not important - binReader.ReadInt32(); // not important - binReader.ReadInt32(); // not important - binReader.ReadInt32(); // not important - - binReader.ReadBytes(24); // not important - - _codePage = binReader.ReadInt32(); - _lcid = binReader.ReadInt32(); - - CultureInfo ci = new CultureInfo(_lcid); - _textEncoder = Encoding.GetEncoding( ci.TextInfo.ANSICodePage ); - - // rest of header is not important for us - } - - /// - /// Dump the class data to a binary writer - /// - /// writer to write the data - internal void Dump(ref BinaryWriter writer) - { - writer.Write( _numberOfIndexFiles ); - writer.Write( _rootOffset ); - writer.Write( _pageCount ); - writer.Write( _depth ); - writer.Write( _scaleDocIdx ); - writer.Write( _rootDocIdx ); - writer.Write( _scaleCodeCnt ); - writer.Write( _rootCodeCnt ); - writer.Write( _scaleLocCodes ); - writer.Write( _rootLocCodes ); - writer.Write( _nodeSize ); - writer.Write( _lengthOfLongestWord ); - writer.Write( _totalNumberOfWords ); - writer.Write( _numberOfUniqueWords ); - } - - /// - /// Reads the object data from a dump store - /// - /// reader to read the data - internal void ReadDump(ref BinaryReader reader) - { - _numberOfIndexFiles = reader.ReadInt32(); - _rootOffset = reader.ReadInt32(); - _pageCount = reader.ReadInt32(); - _depth = reader.ReadInt32(); - - _scaleDocIdx = reader.ReadByte(); - _rootDocIdx = reader.ReadByte(); - _scaleCodeCnt = reader.ReadByte(); - _rootCodeCnt = reader.ReadByte(); - _scaleLocCodes = reader.ReadByte(); - _rootLocCodes = reader.ReadByte(); - - _nodeSize = reader.ReadInt32(); - _lengthOfLongestWord = reader.ReadInt32(); - _totalNumberOfWords = reader.ReadInt32(); - _numberOfUniqueWords = reader.ReadInt32(); - } - - /// - /// Gets the number of indexed files - /// - public int IndexedFileCount - { - get { return _numberOfIndexFiles; } - } - - /// - /// Gets the file offset of the root node - /// - public int RootOffset - { - get { return _rootOffset; } - } - - /// - /// Gets the page count - /// - public int PageCount - { - get { return _pageCount; } - } - - /// - /// Gets the index depth - /// - public int Depth - { - get { return _depth; } - } - - /// - /// Gets the scale param for document index en-/decoding - /// - /// The scale and root method of integer encoding needs two parameters, - /// which I'll call s (scale) and r (root size). - /// The integer is encoded as two parts, p (prefix) and q (actual bits). - /// p determines how many bits are stored, as well as implicitly determining - /// the high-order bit of the integer. - public byte ScaleDocumentIndex - { - get { return _scaleDocIdx; } - } - - /// - /// Gets the root param for the document index en-/decoding - /// - /// The scale and root method of integer encoding needs two parameters, - /// which I'll call s (scale) and r (root size). - /// The integer is encoded as two parts, p (prefix) and q (actual bits). - /// p determines how many bits are stored, as well as implicitly determining - /// the high-order bit of the integer. - public byte RootDocumentIndex - { - get { return _rootDocIdx; } - } - - /// - /// Gets the scale param for the code-count en-/decoding - /// - /// The scale and root method of integer encoding needs two parameters, - /// which I'll call s (scale) and r (root size). - /// The integer is encoded as two parts, p (prefix) and q (actual bits). - /// p determines how many bits are stored, as well as implicitly determining - /// the high-order bit of the integer. - public byte ScaleCodeCount - { - get { return _scaleCodeCnt; } - } - - /// - /// Gets the root param for the code-count en-/decoding - /// - /// The scale and root method of integer encoding needs two parameters, - /// which I'll call s (scale) and r (root size). - /// The integer is encoded as two parts, p (prefix) and q (actual bits). - /// p determines how many bits are stored, as well as implicitly determining - /// the high-order bit of the integer. - public byte RootCodeCount - { - get { return _rootCodeCnt; } - } - - /// - /// Gets the scale param for the location codes en-/decoding - /// - /// The scale and root method of integer encoding needs two parameters, - /// which I'll call s (scale) and r (root size). - /// The integer is encoded as two parts, p (prefix) and q (actual bits). - /// p determines how many bits are stored, as well as implicitly determining - /// the high-order bit of the integer. - public byte ScaleLocationCodes - { - get { return _scaleLocCodes; } - } - - /// - /// Gets the root param for the location codes en-/decoding - /// - /// The scale and root method of integer encoding needs two parameters, - /// which I'll call s (scale) and r (root size). - /// The integer is encoded as two parts, p (prefix) and q (actual bits). - /// p determines how many bits are stored, as well as implicitly determining - /// the high-order bit of the integer. - public byte RootLocationCodes - { - get { return _rootLocCodes; } - } - - /// - /// Gets the size in bytes of each index/leaf node - /// - public int NodeSize - { - get { return _nodeSize; } - } - - /// - /// Gets the length of the longest word in the index - /// - private int LengthOfLongestWord - { - get { return _lengthOfLongestWord; } - } - - /// - /// Gets the total number of words indexed (including duplicates) - /// - public int TotalWordCount - { - get { return _totalNumberOfWords; } - } - - /// - /// Gets the total number of unique words indexed (excluding duplicates) - /// - public int UniqueWordCount - { - get { return _numberOfUniqueWords; } - } - - /// - /// Gets the codepage identifier - /// - public int CodePage - { - get { return _codePage; } - } - - /// - /// Gets the language code id - /// - public int LCID - { - get { return _lcid; } - } - - public Encoding TextEncoder - { - get - { - return _textEncoder; - } - } - } - - - /// - /// Internal class for easier hit recording and rate-calculation - /// - private sealed class HitHelper : IComparable - { - /// - /// Internal member storing the associated document index - /// - private int _documentIndex = 0; - /// - /// Internal member storing the title - /// - private string _title = ""; - /// - /// Internal member storing the locale - /// - private string _locale = ""; - /// - /// Internal member storing the location - /// - private string _location = ""; - /// - /// Internal member storing the url - /// - private string _url = ""; - /// - /// Internal member storing the rating - /// - private double _rating = 0; - /// - /// Internal member used for rating calculation - /// - private Hashtable _partialRating = new Hashtable(); - - /// - /// Constructor of the class - /// - /// document index - /// title - /// locale parameter - /// location - /// url of document - /// rating - public HitHelper(int documentIndex, string title, string locale, string location, string url, double rating) - { - _documentIndex = documentIndex; - _title = title; - _locale = locale; - _location = location; - _url = url; - _rating = rating; - } - - /// - /// Updates the rating for a found word - /// - /// word found - public void UpdateRating(string word) - { - if( _partialRating[word] == null) - { - _partialRating[word] = 100.0; - } - else - { - _partialRating[word] = ((double)_partialRating[word])*1.01; - } - - _rating = 0.0; - - foreach(double val in _partialRating.Values) - { - _rating += val; - } - } - - /// - /// Implements the CompareTo method of the IComparable interface. - /// Allows an easy sort by the document rating - /// - /// object to compare - /// 0 ... equal, -1 ... this instance is less than obj, 1 ... this instance is greater than obj - public int CompareTo(object obj) - { - if( obj is HitHelper ) - { - HitHelper hObj = (HitHelper)obj; - - return this.Rating.CompareTo( hObj.Rating ); - } - - return -1; - } - - /// - /// Gets the internal hashtable used for counting word hits of the document - /// - internal Hashtable PartialRating - { - get { return _partialRating; } - } - - /// - /// Gets the document index of the hit helper instance - /// - public int DocumentIndex - { - get { return _documentIndex; } - } - - /// - /// Gets the title - /// - public string Title - { - get { return _title; } - } - - /// - /// Gets the locale - /// - public string Locale - { - get { return _locale; } - } - - /// - /// Gets the location - /// - public string Location - { - get { return _location; } - } - - /// - /// Gets the url - /// - public string URL - { - get { return _url; } - } - - /// - /// Gets the rating - /// - public double Rating - { - get { return _rating; } - } - - } - - #endregion - - /// - /// Regular expression getting the text between to quotes - /// - private string RE_Quotes = @"\""(?.*?)\"""; - /// - /// Internal flag specifying if the object is going to be disposed - /// - private bool disposed = false; - /// - /// Internal member storing the binary file data - /// - private byte[] _binaryFileData = null; - /// - /// Internal datatable storing the search hits - /// - private DataTable _hits =null; - /// - /// Internal arraylist for hit management - /// - private ArrayList _hitsHelper = new ArrayList(); - /// - /// Internal member storing the header of the file - /// - private FTHeader _header = null; - /// - /// Internal member storing the associated chmfile object - /// - private CHMFile _associatedFile = null; - - /// - /// Constructor of the class - /// - /// binary file data of the $FIftiMain file - /// associated chm file - public FullTextEngine(byte[] binaryFileData, CHMFile associatedFile) - { - _binaryFileData = binaryFileData; - _associatedFile = associatedFile; - - if(_associatedFile.SystemFile.FullTextSearch) - { - _header = new FTHeader(_binaryFileData); // reading header - } - } - - /// - /// Standard constructor - /// - internal FullTextEngine() - { - } - - #region Data dumping - /// - /// Dump the class data to a binary writer - /// - /// writer to write the data - internal void Dump(ref BinaryWriter writer) - { - _header.Dump(ref writer); - writer.Write( _binaryFileData.Length ); - writer.Write(_binaryFileData); - } - - /// - /// Reads the object data from a dump store - /// - /// reader to read the data - internal void ReadDump(ref BinaryReader reader) - { - _header = new FTHeader(); - _header.ReadDump(ref reader); - - int nCnt = reader.ReadInt32(); - _binaryFileData = reader.ReadBytes(nCnt); - } - - /// - /// Sets the associated CHMFile instance - /// - /// instance to set - internal void SetCHMFile(CHMFile associatedFile) - { - _associatedFile = associatedFile; - } - #endregion - - /// - /// Gets a flag if full-text searching is available for this chm file. - /// - public bool CanSearch - { - get { return (_associatedFile.SystemFile.FullTextSearch && (_header != null) ); } - } - - /// - /// Performs a fulltext search of a single file. - /// - /// word(s) or phrase to search - /// true if partial word should be matched also - /// ( if this is true a search of 'support' will match 'supports', otherwise not ) - /// true if only search in titles - /// Hits are available through the Hists property. - public bool Search(string search, bool partialMatches, bool titleOnly) - { - return Search(search, -1, partialMatches, titleOnly); - } - - /// - /// Performs a fulltext search of a single file. - /// - /// word(s) or phrase to search - /// max hits. If this number is reached, the search will be interrupted - /// true if partial word should be matched also - /// ( if this is true a search of 'support' will match 'supports', otherwise not ) - /// true if only search in titles - /// Hits are available through the Hists property. - public bool Search(string search, int MaxHits, bool partialMatches, bool titleOnly) - { - if(CanSearch) - { - string searchString = search; - - // Check if this is a quoted string - bool IsQuoted = (search.IndexOf("\"")>-1); - - if(IsQuoted) - searchString = search.Replace("\"",""); // remove the quotes during search - - bool bRet = true; - - _hitsHelper = null; - _hitsHelper = new ArrayList(); - - _hits = null; - CreateHitsTable(); - - string[] words = searchString.Split(new char[] {' '}); - - for(int i=0; i= MaxHits) - break; - } - - if(bRet && IsQuoted) - { - FinalizeQuoted(search); - } - - if(bRet) - { - _hitsHelper.Sort(); - - int nhCount = MaxHits; - - if( MaxHits < 0) - { - nhCount = _hitsHelper.Count; - } - - if( nhCount > _hitsHelper.Count ) - nhCount = _hitsHelper.Count; - - // create hits datatable - for(int i=nhCount; i > 0; i--) - { - HitHelper curHlp = (HitHelper)(_hitsHelper[i-1]); - - DataRow newRow = _hits.NewRow(); - - newRow["Rating"] = curHlp.Rating; - newRow["Title"] = curHlp.Title; - newRow["Locale"] = curHlp.Locale; - newRow["Location"] = curHlp.Location; - newRow["URL"] = curHlp.URL; - - _hits.Rows.Add( newRow ); - } - } - return bRet; - } - - return false; - } - - /// - /// Gets rid of all search hits which doesn't match the quoted phrase - /// - /// full search string entered by the user - /// Phrase search is not possible using the internal full-text index. We're just filtering all - /// documents which don't contain all words of the phrase. - private void FinalizeQuoted(string search) - { - Regex quoteRE = new Regex(RE_Quotes, RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.Singleline); - int innerTextIdx = quoteRE.GroupNumberFromName("innerText"); - int nIndex = 0; - - // get all phrases - while( quoteRE.IsMatch(search, nIndex) ) - { - Match m = quoteRE.Match(search, nIndex); - - string phrase = m.Groups["innerText"].Value; - - string[] wordsInPhrase = phrase.Split( new char[] {' '} ); - int nCnt = _hitsHelper.Count; - - for(int i=0; i < _hitsHelper.Count; i++) - { - if( ! CheckHit( ((HitHelper)(_hitsHelper[i])), wordsInPhrase) ) - _hitsHelper.RemoveAt(i--); - } - - nIndex = m.Index+m.Length; - } - } - - /// - /// Eliminates all search hits where not all of the words have been found - /// - /// hithelper instance to check - /// word list - private bool CheckHit(HitHelper hit, string[] wordsInPhrase) - { - - for(int i=0; i - /// Performs a search for a single word in the index - /// - /// word to search - /// maximal hits to return - /// true if partial word should be matched also - /// ( if this is true a search of 'support' will match 'supports', otherwise not ) - /// true if only search in titles - /// Returns true if succeeded - private bool SearchSingleWord(string word,int MaxHits, bool partialMatches, bool titleOnly) - { - string wordLower = word.ToLower(); - - MemoryStream memStream = new MemoryStream(_binaryFileData); - BinaryReader binReader = new BinaryReader(memStream); - - // seek to root node - binReader.BaseStream.Seek( _header.RootOffset, SeekOrigin.Begin ); - - if( _header.Depth > 2 ) - { - // unsupported index depth - Debug.WriteLine("FullTextSearcher.SearchSingleWord() - Failed with message: Unsupported index depth !"); - Debug.WriteLine("File: " + _associatedFile.ChmFilePath); - Debug.WriteLine(" "); - return false; - } - - if( _header.Depth > 1 ) - { - // seek to the right leaf node ( if depth == 1, we are at the leaf node) - int freeSpace = binReader.ReadInt16(); - - for(int i=0; i < _header.PageCount; ++i) - { - // exstract index entries - int nWLength = (int)binReader.ReadByte(); - int nCPosition = (int)binReader.ReadByte(); - - string sName = BinaryReaderHelp.ExtractString(ref binReader, nWLength-1, 0, true, _header.TextEncoder); - - int nLeafOffset = binReader.ReadInt32(); - binReader.ReadInt16(); // unknown - - if( sName.CompareTo(wordLower) >= 0) - { - // store current position - long curPos = binReader.BaseStream.Position; - - // seek to leaf offset - binReader.BaseStream.Seek( nLeafOffset, SeekOrigin.Begin ); - - // read leafnode - ReadLeafNode(ref binReader, word, MaxHits, partialMatches, titleOnly); - - // return to current position and continue reading index nodes - binReader.BaseStream.Seek( curPos, SeekOrigin.Begin ); - } - } - } - - return true; - } - - /// - /// Reads a leaf node and extracts documents which holds the searched word - /// - /// reference to the reader - /// word to search - /// maximal hits to return - /// true if partial word should be matched also - /// ( if this is true a search of 'support' will match 'supports', otherwise not ) - /// true if only search in titles - private void ReadLeafNode(ref BinaryReader binReader, string word, int MaxHits, bool partialMatches, bool titleOnly) - { - int nNextPageOffset = binReader.ReadInt32(); - binReader.ReadInt16(); // unknown - int lfreeSpace = binReader.ReadInt16(); - string curFullWord = ""; - bool bFound = false; - string wordLower = word.ToLower(); - - for(;;) - { - if(binReader.BaseStream.Position >= binReader.BaseStream.Length) - break; - - int nWLength = (int)binReader.ReadByte(); - - if(nWLength == 0) - break; - - int nCPosition = (int)binReader.ReadByte(); - - string sName = BinaryReaderHelp.ExtractString(ref binReader, nWLength-1, 0, true, _header.TextEncoder); - - int Context = (int)binReader.ReadByte(); // 0...body tag, 1...title tag, others unknown - - long nrOfWCL = BinaryReaderHelp.ReadENCINT(ref binReader); - int wclOffset = binReader.ReadInt32(); - - binReader.ReadInt16(); // unknown - - long bytesOfWCL = BinaryReaderHelp.ReadENCINT(ref binReader); - - if( nCPosition > 0) - { - curFullWord = CombineStrings(curFullWord, sName, nCPosition); - } - else - { - curFullWord = sName; - } - - bFound = false; - if(partialMatches) - bFound = ( curFullWord.IndexOf(wordLower) >= 0 ); - else - bFound = (curFullWord == wordLower); - - if( bFound ) - { - if( (titleOnly && (Context==1)) || (!titleOnly) ) - { - // store actual offset - long curPos = binReader.BaseStream.Position; - - // found the word, begin with WCL encoding - binReader.BaseStream.Seek(wclOffset, SeekOrigin.Begin ); - - byte[] wclBytes = binReader.ReadBytes((int)bytesOfWCL); - - DecodeWCL(wclBytes, MaxHits, word); - - // back and continue reading leafnodes - binReader.BaseStream.Seek(curPos, SeekOrigin.Begin ); - } - } - } - } - - /// - /// Decodes the s/r encoded WordCodeList (=wcl) and creates hit entries - /// - /// wcl encoded byte array - /// maximal hits - /// the word to find - private void DecodeWCL(byte[] wclBytes,int MaxHits, string word) - { - byte[] wclBits = new byte[ wclBytes.Length*8 ]; - - int nBitIdx=0; - - for(int i=0; i (byte)0 ? (byte)1 : (byte)0; - nBitIdx++; - } - } - - nBitIdx = 0; - - int nDocIdx = 0; // delta encoded - - while(nBitIdx < wclBits.Length) - { - nDocIdx += BinaryReaderHelp.ReadSRItem(wclBits, _header.ScaleDocumentIndex, _header.RootDocumentIndex, ref nBitIdx); - int nCodeCnt = BinaryReaderHelp.ReadSRItem(wclBits, _header.ScaleCodeCount, _header.RootCodeCount, ref nBitIdx); - - int nWordLocation = 0; // delta encoded - - for(int locidx=0; locidx MaxHits) - return; - - hitObj = new HitHelper(nDocIdx, ((TopicEntry)(_associatedFile.TopicsFile.TopicTable[nDocIdx])).Title, - ((TopicEntry)(_associatedFile.TopicsFile.TopicTable[nDocIdx])).Locale, _associatedFile.CompileFile, - ((TopicEntry)(_associatedFile.TopicsFile.TopicTable[nDocIdx])).URL, 0.0); - - for(int k=0;k - /// Combines a "master" word with a partial word. - /// - /// the master word - /// the partial word - /// position to place the parial word - /// returns a combined string - private string CombineStrings(string word, string partial, int partialPosition) - { - string sCombined = word; - int i=0; - - for(i=0; i (sCombined.Length-1) ) - { - sCombined += partial[i]; - } - else - { - StringBuilder sb = new StringBuilder(sCombined); - - sb.Replace( sCombined[partialPosition+i], partial[i], partialPosition+i, 1); - sCombined = sb.ToString(); - } - } - - if(! ((i+partialPosition) > (sCombined.Length-1)) ) - { - sCombined = sCombined.Substring(0, partialPosition+partial.Length); - } - - return sCombined; - } - - /// - /// Gets the HitHelper instance for a specific document index - /// - /// document index - /// The reference of the hithelper instance for this document index, otherwise null - private HitHelper DocumentHit(int index) - { - foreach(HitHelper curObj in _hitsHelper) - { - if( curObj.DocumentIndex == index) - return curObj; - } - - return null; - } - - /// - /// Creates a DataTable for storing the hits - /// - private void CreateHitsTable() - { - _hits = new DataTable("FT_Search_Hits"); - - DataColumn ftColumn; - - ftColumn = new DataColumn(); - ftColumn.DataType = System.Type.GetType("System.Double"); - ftColumn.ColumnName = "Rating"; - ftColumn.ReadOnly = false; - ftColumn.Unique = false; - - _hits.Columns.Add(ftColumn); - - ftColumn = new DataColumn(); - ftColumn.DataType = System.Type.GetType("System.String"); - ftColumn.ColumnName = "Title"; - ftColumn.ReadOnly = false; - ftColumn.Unique = false; - - _hits.Columns.Add(ftColumn); - - ftColumn = new DataColumn(); - ftColumn.DataType = System.Type.GetType("System.String"); - ftColumn.ColumnName = "Locale"; - ftColumn.ReadOnly = false; - ftColumn.Unique = false; - - _hits.Columns.Add(ftColumn); - - ftColumn = new DataColumn(); - ftColumn.DataType = System.Type.GetType("System.String"); - ftColumn.ColumnName = "Location"; - ftColumn.ReadOnly = false; - ftColumn.Unique = false; - - _hits.Columns.Add(ftColumn); - - ftColumn = new DataColumn(); - ftColumn.DataType = System.Type.GetType("System.String"); - ftColumn.ColumnName = "URL"; - ftColumn.ReadOnly = false; - ftColumn.Unique = false; - - _hits.Columns.Add(ftColumn); - } - - /// - /// Gets an datatable containing the hits of the last search - /// - public DataTable Hits - { - get { return _hits; } - } - - /// - /// Implement IDisposable. - /// - public void Dispose() - { - Dispose(true); - // This object will be cleaned up by the Dispose method. - // Therefore, you should call GC.SupressFinalize to - // take this object off the finalization queue - // and prevent finalization code for this object - // from executing a second time. - GC.SuppressFinalize(this); - } - - /// - /// Dispose(bool disposing) executes in two distinct scenarios. - /// If disposing equals true, the method has been called directly - /// or indirectly by a user's code. Managed and unmanaged resources - /// can be disposed. - /// If disposing equals false, the method has been called by the - /// runtime from inside the finalizer and you should not reference - /// other objects. Only unmanaged resources can be disposed. - /// - /// disposing flag - private void Dispose(bool disposing) - { - // Check to see if Dispose has already been called. - if(!this.disposed) - { - // If disposing equals true, dispose all managed - // and unmanaged resources. - if(disposing) - { - // Dispose managed resources. - _binaryFileData = null; - } - } - disposed = true; - } - } -} diff --git a/irc/TechBot/CHMLibrary/CHMDecoding/HHCParser.cs b/irc/TechBot/CHMLibrary/CHMDecoding/HHCParser.cs deleted file mode 100644 index 73482712291..00000000000 --- a/irc/TechBot/CHMLibrary/CHMDecoding/HHCParser.cs +++ /dev/null @@ -1,593 +0,0 @@ -using System; -using System.Collections; -using System.Text; -using System.Text.RegularExpressions; - -namespace HtmlHelp.ChmDecoding -{ - /// - /// The class HHCParser implements a parser for HHC contents files. - /// - internal sealed class HHCParser - { - /// - /// regular expressions for replacing the sitemap boundary tags - /// - private static string RE_ULOpening = @"\"; // will be replaced by a '(' for nested parsing - private static string RE_ULClosing = @"\"; // will be replaced by a ')' for nested parsing - - /// - /// Matching ul-tags - /// - private static string RE_ULBoundaries = @"\(?.*)\"; - /// - /// Matching the nested tree structure. - /// - private static string RE_NestedBoundaries = @"\( (?> [^()]+ | \( (?) | \) (?<-DEPTH>) )* (?(DEPTH)(?!)) \)"; - /// - /// Matching object-tags - /// - private static string RE_ObjectBoundaries = @"\.*?)\"; - /// - /// Matching param tags - /// - private static string RE_ParamBoundaries = @"\.*?)\>"; - /// - /// Extracting tag attributes - /// - private const string RE_QuoteAttributes = @"( |\t)*(?[\-a-zA-Z0-9]*)( |\t)*=( |\t)*(?[\""\'])?(?.*?(?(attributeTD)\k|([\s>]|.$)))"; - - /// - /// private regular expressionobjects - /// - private static Regex ulRE; - private static Regex NestedRE; - private static Regex ObjectRE; - private static Regex ParamRE; - private static Regex AttributesRE; - - /// - /// Internal member storing the list of TOCItems which are holding merge links - /// - private static ArrayList _mergeItems = null; - - /// - /// Internal member storing the last read regular topic item. - /// This is used to handle "Merge" entries and add them as child to this instance. - /// - private static TOCItem _lastTopicItem = null; - - /// - /// Parses a HHC file and returns an ArrayList with the table of contents (TOC) tree - /// - /// string content of the hhc file - /// CHMFile instance - /// Returns an ArrayList with the table of contents (TOC) tree - public static ArrayList ParseHHC(string hhcFile, CHMFile chmFile) - { - _lastTopicItem = null; - _mergeItems = null; // clear merged item list - ArrayList tocList = new ArrayList(); - - ulRE = new Regex(RE_ULBoundaries, RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.Singleline); - NestedRE = new Regex(RE_NestedBoundaries, RegexOptions.IgnorePatternWhitespace | RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.Singleline); - ObjectRE = new Regex(RE_ObjectBoundaries, RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.Singleline); - ParamRE = new Regex(RE_ParamBoundaries, RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.Singleline); - AttributesRE = new Regex(RE_QuoteAttributes, RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.Singleline); - - int innerTextIdx = ulRE.GroupNumberFromName("innerText"); - - if( ulRE.IsMatch(hhcFile, 0) ) - { - Match m = ulRE.Match(hhcFile, 0); - - int nFirstUL = 0; - - nFirstUL = hhcFile.ToLower().IndexOf("
    "); - - if(nFirstUL == -1) - nFirstUL = hhcFile.ToLower().IndexOf(""); - - if( ObjectRE.IsMatch(hhcFile, 0) ) // first object block contains information types and categories - { - Match mO = ObjectRE.Match(hhcFile, 0); - int iOTxt = ObjectRE.GroupNumberFromName("innerText"); - - string globalText = mO.Groups[iOTxt].Value; - - if( mO.Groups[iOTxt].Index <= nFirstUL) - ParseGlobalSettings( globalText, chmFile ); - } - - // parse toc tree - string innerText = m.Groups["innerText"].Value; - - innerText = innerText.Replace("(", "("); - innerText = innerText.Replace(")", ")"); - innerText = Regex.Replace(innerText, RE_ULOpening, "(", RegexOptions.IgnoreCase); - innerText = Regex.Replace(innerText, RE_ULClosing, ")", RegexOptions.IgnoreCase); - - ParseTree( innerText, null, tocList, chmFile ); - - } - - return tocList; - } - - /// - /// Checks if the hhc file contains a global object tag. - /// - /// string content of the hhc file - /// chm file - /// true if the hhc content contains a global object tag - public static bool HasGlobalObjectTag(string hhcFile, CHMFile chmFile) - { - bool bRet = false; - - ulRE = new Regex(RE_ULBoundaries, RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.Singleline); - ObjectRE = new Regex(RE_ObjectBoundaries, RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.Singleline); - - int innerTextIdx = ulRE.GroupNumberFromName("innerText"); - - if( ulRE.IsMatch(hhcFile, 0) ) - { - Match m = ulRE.Match(hhcFile, 0); - - int nFirstUL = 0; - - nFirstUL = hhcFile.ToLower().IndexOf("
      "); - - if(nFirstUL == -1) - nFirstUL = hhcFile.ToLower().IndexOf(""); - - if( ObjectRE.IsMatch(hhcFile, 0) ) // first object block contains information types and categories - { - Match mO = ObjectRE.Match(hhcFile, 0); - int iOTxt = ObjectRE.GroupNumberFromName("innerText"); - - string globalText = mO.Groups[iOTxt].Value; - - if( mO.Groups[iOTxt].Index <= nFirstUL) - bRet = true; - } - } - - return bRet; - } - - /// - /// Gets true if the previously done parsing found merge-links - /// - public static bool HasMergeLinks - { - get - { - if(_mergeItems==null) - return false; - - return _mergeItems.Count > 0; - } - } - - /// - /// Gets all TOCItem references which are holding merge-links - /// - public static ArrayList MergeItems - { - get { return _mergeItems; } - } - - /// - /// Recursively parses a sitemap tree - /// - /// content text - /// Parent for all read items - /// arraylist which receives the extracted nodes - /// CHMFile instance - private static void ParseTree( string text, TOCItem parent, ArrayList arrNodes, CHMFile chmFile ) - { - string strPreItems="", strPostItems=""; - string innerText = ""; - - int nIndex = 0; - - while( NestedRE.IsMatch(text, nIndex) ) - { - Match m = NestedRE.Match(text, nIndex); - - innerText = m.Value.Substring( 1, m.Length-2); - - strPreItems = text.Substring(nIndex,m.Index-nIndex); - - ParseItems(strPreItems, parent, arrNodes, chmFile); - - if((arrNodes.Count>0) && (innerText.Length > 0) ) - { - TOCItem p = ((TOCItem)(arrNodes[arrNodes.Count-1])); - ParseTree( innerText, p, p.Children, chmFile ); - } - - nIndex = m.Index+m.Length; - } - - if( nIndex == 0) - { - strPostItems = text.Substring(nIndex, text.Length-nIndex); - ParseItems(strPostItems, parent, arrNodes, chmFile); - } - else if( nIndex < text.Length-1) - { - strPostItems = text.Substring(nIndex, text.Length-nIndex); - ParseTree(strPostItems, parent, arrNodes, chmFile); - } - } - - /// - /// Parses tree nodes from the text - /// - /// text containing the items - /// Parent for all read items - /// arraylist where the nodes should be added - /// CHMFile instance - private static void ParseItems( string itemstext, TOCItem parent, ArrayList arrNodes, CHMFile chmFile) - { - int innerTextIdx = ObjectRE.GroupNumberFromName("innerText"); - int innerPTextIdx = ParamRE.GroupNumberFromName("innerText"); - - // get group-name indexes - int nameIndex = AttributesRE.GroupNumberFromName("attributeName"); - int valueIndex = AttributesRE.GroupNumberFromName("attributeValue"); - int tdIndex = AttributesRE.GroupNumberFromName("attributeTD"); - - int nObjStartIndex = 0; - - while( ObjectRE.IsMatch(itemstext, nObjStartIndex) ) - { - Match m = ObjectRE.Match(itemstext, nObjStartIndex); - - string innerText = m.Groups[innerTextIdx].Value; - - TOCItem tocItem = new TOCItem(); - tocItem.TocMode = DataMode.TextBased; - tocItem.AssociatedFile = chmFile; - tocItem.Parent = parent; - - // read parameters - int nParamIndex = 0; - - while( ParamRE.IsMatch(innerText, nParamIndex) ) - { - Match mP = ParamRE.Match(innerText, nParamIndex); - - string innerP = mP.Groups[innerPTextIdx].Value; - - string paramName = ""; - string paramValue = ""; - - int nAttrIdx = 0; - - while( AttributesRE.IsMatch( innerP, nAttrIdx ) ) - { - Match mA = AttributesRE.Match(innerP, nAttrIdx); - - string attributeName = mA.Groups[nameIndex].Value; - string attributeValue = mA.Groups[valueIndex].Value; - string attributeTD = mA.Groups[tdIndex].Value; - - if(attributeTD.Length > 0) - { - // delete the trailing textqualifier - if( attributeValue.Length > 0) - { - int ltqi = attributeValue.LastIndexOf( attributeTD ); - - if(ltqi >= 0) - { - attributeValue = attributeValue.Substring(0,ltqi); - } - } - } - - if( attributeName.ToLower() == "name") - { - paramName = HttpUtility.HtmlDecode(attributeValue); // for unicode encoded values - } - - if( attributeName.ToLower() == "value") - { - paramValue = HttpUtility.HtmlDecode(attributeValue); // for unicode encoded values - // delete trailing / - while((paramValue.Length>0)&&(paramValue[paramValue.Length-1] == '/')) - paramValue = paramValue.Substring(0,paramValue.Length-1); - - } - - nAttrIdx = mA.Index+mA.Length; - } - - tocItem.Params[paramName] = paramValue; - switch(paramName.ToLower()) - { - case "name": - { - tocItem.Name = paramValue; - };break; - case "local": - { - tocItem.Local = paramValue.Replace("../", "").Replace("./", ""); - };break; - case "imagenumber": - { - tocItem.ImageIndex = Int32.Parse(paramValue); - tocItem.ImageIndex-=1; - - int nFolderAdd = 0; - - if((chmFile != null) && (chmFile.ImageTypeFolder)) - { - // get the value which should be added, to display folders instead of books - if(HtmlHelpSystem.UseHH2TreePics) - nFolderAdd = 8; - else - nFolderAdd = 4; - } - - if(tocItem.ImageIndex%2 != 0) - { - if(tocItem.ImageIndex==1) - tocItem.ImageIndex=0; - } - if(HtmlHelpSystem.UseHH2TreePics) - if( tocItem.ImageIndex == 0) - tocItem.ImageIndex = TOCItem.STD_FOLDER_HH2+nFolderAdd; - };break; - case "merge": // this item contains topics or a full TOC from a merged CHM - { - tocItem.MergeLink = paramValue; - - // "register" this item as merge-link - if(_mergeItems==null) - _mergeItems=new ArrayList(); - - _mergeItems.Add(tocItem); - - };break; - case "type": // information type assignment for item - { - tocItem.InfoTypeStrings.Add( paramValue ); - };break; - } - - nParamIndex = mP.Index+mP.Length; - } - - tocItem.ChmFile = chmFile.ChmFilePath; - - if(tocItem.MergeLink.Length > 0) - { - if(_lastTopicItem != null) - { - tocItem.Parent = _lastTopicItem; - _lastTopicItem.Children.Add(tocItem); - } - else - arrNodes.Add( tocItem ); - } - else - { - _lastTopicItem = tocItem; - arrNodes.Add( tocItem ); - } - - nObjStartIndex = m.Index+m.Length; - } - } - - /// - /// Parses the very first <OBJECT> tag in the sitemap file and extracts - /// information types and categories. - /// - /// text of the object tag - /// CHMFile instance - private static void ParseGlobalSettings(string sText, CHMFile chmFile) - { - int innerPTextIdx = ParamRE.GroupNumberFromName("innerText"); - - // get group-name indexes - int nameIndex = AttributesRE.GroupNumberFromName("attributeName"); - int valueIndex = AttributesRE.GroupNumberFromName("attributeValue"); - int tdIndex = AttributesRE.GroupNumberFromName("attributeTD"); - - // read parameters - int nParamIndex = 0; - - // 0... unknown - // 1... inclusinve info type name - // 2... exclusive info type name - // 3... hidden info type name - // 4... category name - // 5... incl infotype name for category - // 6... excl infotype name for category - // 7... hidden infotype name for category - int prevItem = 0; - - string sName = ""; - string sDescription = ""; - string curCategory = ""; - - while( ParamRE.IsMatch(sText, nParamIndex) ) - { - Match mP = ParamRE.Match(sText, nParamIndex); - - string innerP = mP.Groups[innerPTextIdx].Value; - - string paramName = ""; - string paramValue = ""; - - int nAttrIdx = 0; - - while( AttributesRE.IsMatch( innerP, nAttrIdx ) ) - { - Match mA = AttributesRE.Match(innerP, nAttrIdx); - - string attributeName = mA.Groups[nameIndex].Value; - string attributeValue = mA.Groups[valueIndex].Value; - string attributeTD = mA.Groups[tdIndex].Value; - - if(attributeTD.Length > 0) - { - // delete the trailing textqualifier - if( attributeValue.Length > 0) - { - int ltqi = attributeValue.LastIndexOf( attributeTD ); - - if(ltqi >= 0) - { - attributeValue = attributeValue.Substring(0,ltqi); - } - } - } - - if( attributeName.ToLower() == "name") - { - paramName = HttpUtility.HtmlDecode(attributeValue); // for unicode encoded values - } - - if( attributeName.ToLower() == "value") - { - paramValue = HttpUtility.HtmlDecode(attributeValue); // for unicode encoded values - // delete trailing / - while((paramValue.Length>0)&&(paramValue[paramValue.Length-1] == '/')) - paramValue = paramValue.Substring(0,paramValue.Length-1); - - } - - nAttrIdx = mA.Index+mA.Length; - } - - switch(paramName.ToLower()) - { - case "savetype": // inclusive information type name - { - prevItem = 1; - sName = paramValue; - };break; - case "savetypedesc": // description of information type - { - InformationTypeMode mode = InformationTypeMode.Inclusive; - sDescription = paramValue; - - if( prevItem == 1) - mode = InformationTypeMode.Inclusive; - if( prevItem == 2) - mode = InformationTypeMode.Exclusive; - if( prevItem == 3) - mode = InformationTypeMode.Hidden; - - if( chmFile.GetInformationType( sName ) == null) - { - // check if the HtmlHelpSystem already holds such an information type - if( chmFile.SystemInstance.GetInformationType( sName ) == null) - { - // info type not found yet - - InformationType newType = new InformationType(sName, sDescription, mode); - chmFile.InformationTypes.Add(newType); - } - else - { - InformationType sysType = chmFile.SystemInstance.GetInformationType( sName ); - chmFile.InformationTypes.Add( sysType ); - } - } - - prevItem = 0; - };break; - case "saveexclusive": // exclusive information type name - { - prevItem = 2; - sName = paramValue; - };break; - case "savehidden": // hidden information type name - { - prevItem = 3; - sName = paramValue; - };break; - case "category": // category name - { - prevItem = 4; - sName = paramValue; - curCategory = sName; - };break; - case "categorydesc": // category description - { - sDescription = paramValue; - - if( chmFile.GetCategory( sName ) == null) - { - // check if the HtmlHelpSystem already holds such a category - if( chmFile.SystemInstance.GetCategory( sName ) == null) - { - // add category - Category newCat = new Category(sName, sDescription); - chmFile.Categories.Add(newCat); - } - else - { - Category sysCat = chmFile.SystemInstance.GetCategory( sName ); - chmFile.Categories.Add( sysCat ); - } - } - - prevItem = 0; - };break; - case "type": // inclusive information type which is member of the previously read category - { - prevItem = 5; - sName = paramValue; - };break; - case "typedesc": // description of type for category - { - sDescription = paramValue; - Category cat = chmFile.GetCategory( curCategory ); - - if( cat != null) - { - // category found - InformationType infoType = chmFile.GetInformationType( sName ); - - if( infoType != null) - { - if( !cat.ContainsInformationType(infoType)) - { - infoType.SetCategoryFlag(true); - cat.AddInformationType(infoType); - } - } - } - - prevItem = 0; - };break; - case "typeexclusive": // exclusive information type which is member of the previously read category - { - prevItem = 6; - sName = paramValue; - };break; - case "typehidden": // hidden information type which is member of the previously read category - { - prevItem = 7; - sName = paramValue; - };break; - default: - { - prevItem = 0; - sName = ""; - sDescription = ""; - };break; - } - - nParamIndex = mP.Index+mP.Length; - } - } - } -} diff --git a/irc/TechBot/CHMLibrary/CHMDecoding/HHCParser2.cs b/irc/TechBot/CHMLibrary/CHMDecoding/HHCParser2.cs deleted file mode 100644 index bdb988a8665..00000000000 --- a/irc/TechBot/CHMLibrary/CHMDecoding/HHCParser2.cs +++ /dev/null @@ -1,220 +0,0 @@ -using System; -using System.Collections; -using System.Text; -using System.Text.RegularExpressions; - -namespace HtmlHelp.ChmDecoding -{ - /// - /// The class HHCParser implements a parser for HHC contents files. - /// - // internal sealed class HHCParser : IHHCParser - public class HHCParser2 - { - static private string m_text1=""; - static private string m_text2=""; - static private int m_CurrentPos=0; - - /// - /// Parses a HHC file and returns an ArrayList with the table of contents (TOC) tree - /// - /// string content of the hhc file - /// CHMFile instance - /// Returns an ArrayList with the table of contents (TOC) tree - public static ArrayList ParseHHC(string hhcFile, CHMFile chmFile) - { - DateTime StartTime=DateTime.Now; - - ArrayList tocList = new ArrayList(); - - m_text2=hhcFile; - m_text1=hhcFile.ToLower(); - - int idx=m_text1.IndexOf("
        "); - if (idx==-1) - return null; - m_CurrentPos=idx+4; - - ParamRE = new Regex(RE_ParamBoundaries, RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.Singleline); - AttributesRE = new Regex(RE_QuoteAttributes, RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.Singleline); - - ParseTree(tocList,chmFile); - - DateTime EndTime=DateTime.Now; - TimeSpan Diff=EndTime-StartTime; - string x=Diff.ToString(); - - return tocList; - } - - /// - /// Recursively parses a sitemap tree - /// - /// content text - /// arraylist which receives the extracted nodes - /// CHMFile instance - static private void ParseTree( ArrayList arrNodes, CHMFile chmFile ) - { - bool bProcessing=true; - do - { - bProcessing=false; - - // Indent - int idxa=m_text1.IndexOf("
          ",m_CurrentPos); - int idxb=m_text1.IndexOf("
        • ",m_CurrentPos); - int idxc=m_text1.IndexOf("
        ",m_CurrentPos); - - if ((idxa-1)) - { - bProcessing=true; - m_CurrentPos=idxa+4; - if (arrNodes.Count<1) - { - ParseTree(arrNodes,chmFile); - } - else - { - ParseTree(((TOCItem)(arrNodes[arrNodes.Count-1])).Children,chmFile); - } - continue; - } - - // new item - if ((idxb-1)) - { - - bProcessing=true; - m_CurrentPos=idxb+4; - - int idx2=m_text1.IndexOf("",idx2+7); - if (idx3!=-1) - { - string text=m_text2.Substring(idx2,idx3-idx2); - - m_CurrentPos=idx3+9; - - // Parse items in text. - TOCItem tocItem=ParseItems(text, chmFile); - if (tocItem!=null) - { - arrNodes.Add(tocItem); - } - } - } - } - - // Undent - if ((idxc-1)) - { - m_CurrentPos=idxc+5; - bProcessing=true; - return; - } - } - while (bProcessing); - } - - - private static string RE_ParamBoundaries = @"\.*?)\>"; - private const string RE_QuoteAttributes = @"( |\t)*(?[\-a-zA-Z0-9]*)( |\t)*=( |\t)*(?[\""\'])?(?.*?(?(attributeTD)\k|([\s>]|.$)))"; - private static Regex ParamRE; - private static Regex AttributesRE; - - /// - /// Parses tree nodes from the text - /// - /// text containing the items - /// arraylist where the nodes should be added - /// CHMFile instance - private static TOCItem ParseItems( string itemstext, CHMFile chmFile) - { - int innerPTextIdx = ParamRE.GroupNumberFromName("innerText"); - - // get group-name indexes - int nameIndex = AttributesRE.GroupNumberFromName("attributeName"); - int valueIndex = AttributesRE.GroupNumberFromName("attributeValue"); - int tdIndex = AttributesRE.GroupNumberFromName("attributeTD"); - - TOCItem tocItem = new TOCItem(); - - // read parameters - int nParamIndex = 0; - - while( ParamRE.IsMatch(itemstext, nParamIndex) ) - { - Match mP = ParamRE.Match(itemstext, nParamIndex); - - string innerP = mP.Groups[innerPTextIdx].Value; - - string paramName = ""; - string paramValue = ""; - - int nAttrIdx = 0; - - while( AttributesRE.IsMatch( innerP, nAttrIdx ) ) - { - Match mA = AttributesRE.Match(innerP, nAttrIdx); - - string attributeName = mA.Groups[nameIndex].Value; - string attributeValue = mA.Groups[valueIndex].Value; - string attributeTD = mA.Groups[tdIndex].Value; - - if(attributeTD.Length > 0) - { - // delete the trailing textqualifier - if( attributeValue.Length > 0) - { - int ltqi = attributeValue.LastIndexOf( attributeTD ); - - if(ltqi >= 0) - { - attributeValue = attributeValue.Substring(0,ltqi); - } - } - } - - if( attributeName.ToLower() == "name") - { - paramName = attributeValue; - } - - if( attributeName.ToLower() == "value") - { - paramValue = attributeValue; - } - - nAttrIdx = mA.Index+mA.Length; - } - - tocItem.Params[paramName] = paramValue; - switch(paramName.ToLower()) - { - case "name": - { - tocItem.Name = paramValue; - };break; - case "local": - { - tocItem.Local = paramValue; - };break; - case "imagenumber": - { - tocItem.ImageIndex = Int32.Parse(paramValue); - - if( tocItem.ImageIndex == 2) - tocItem.ImageIndex = TOCItem.STD_FOLDER_HH1; - };break; - } - - nParamIndex = mP.Index+mP.Length; - } - - tocItem.ChmFile = chmFile.ChmFilePath; - return tocItem; - } - } -} diff --git a/irc/TechBot/CHMLibrary/CHMDecoding/HHKParser.cs b/irc/TechBot/CHMLibrary/CHMDecoding/HHKParser.cs deleted file mode 100644 index 63f1c136799..00000000000 --- a/irc/TechBot/CHMLibrary/CHMDecoding/HHKParser.cs +++ /dev/null @@ -1,550 +0,0 @@ -using System; -using System.IO; -using System.Collections; -using System.Text; -using System.Text.RegularExpressions; - -namespace HtmlHelp.ChmDecoding -{ - /// - /// The class HHKParser implements a parser for HHK contents files. - /// - internal sealed class HHKParser - { - /// - /// regular expressions for replacing the sitemap boundary tags - /// - private static string RE_ULOpening = @"\"; // will be replaced by a '(' for nested parsing - private static string RE_ULClosing = @"\"; // will be replaced by a ')' for nested parsing - - /// - /// Matching ul-tags - /// - private static string RE_ULBoundaries = @"\(?.*)\"; - /// - /// Matching the nested tree structure. - /// - private static string RE_NestedBoundaries = @"\( (?> [^()]+ | \( (?) | \) (?<-DEPTH>) )* (?(DEPTH)(?!)) \)"; - /// - /// Matching object-tags - /// - private static string RE_ObjectBoundaries = @"\.*?)\"; - /// - /// Matching param tags - /// - private static string RE_ParamBoundaries = @"\.*?)\>"; - /// - /// Extracting tag attributes - /// - private const string RE_QuoteAttributes = @"( |\t)*(?[\-a-zA-Z0-9]*)( |\t)*=( |\t)*(?[\""\'])?(?.*?(?(attributeTD)\k|([\s>]|.$)))"; - - /// - /// private regular expressionobjects - /// - private static Regex ulRE; - private static Regex NestedRE; - private static Regex ObjectRE; - private static Regex ParamRE; - private static Regex AttributesRE; - - /// - /// Parses a HHK file and returns an ArrayList with the index tree - /// - /// string content of the hhk file - /// CHMFile instance - /// Returns an ArrayList with the index tree - public static ArrayList ParseHHK(string hhkFile, CHMFile chmFile) - { - ArrayList indexList = new ArrayList(); - - ulRE = new Regex(RE_ULBoundaries, RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.Singleline); - NestedRE = new Regex(RE_NestedBoundaries, RegexOptions.IgnorePatternWhitespace | RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.Singleline); - ObjectRE = new Regex(RE_ObjectBoundaries, RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.Singleline); - ParamRE = new Regex(RE_ParamBoundaries, RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.Singleline); - AttributesRE = new Regex(RE_QuoteAttributes, RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.Singleline); - - int innerTextIdx = ulRE.GroupNumberFromName("innerText"); - - if( ulRE.IsMatch(hhkFile, 0) ) - { - Match m = ulRE.Match(hhkFile, 0); - - if( ObjectRE.IsMatch(hhkFile, 0) ) // first object block contains information types and categories - { - Match mO = ObjectRE.Match(hhkFile, 0); - int iOTxt = ObjectRE.GroupNumberFromName("innerText"); - - string globalText = mO.Groups[iOTxt].Value; - - ParseGlobalSettings( globalText, chmFile ); - } - - string innerText = m.Groups["innerText"].Value; - - innerText = innerText.Replace("(", "("); - innerText = innerText.Replace(")", ")"); - innerText = Regex.Replace(innerText, RE_ULOpening, "(", RegexOptions.IgnoreCase); - innerText = Regex.Replace(innerText, RE_ULClosing, ")", RegexOptions.IgnoreCase); - - ParseTree( innerText, null, indexList, chmFile ); - } - - return indexList; - } - - /// - /// Recursively parses a sitemap tree - /// - /// content text - /// Parent for all read items - /// arraylist which receives the extracted nodes - /// CHMFile instance - private static void ParseTree( string text, IndexItem parent, ArrayList arrNodes, CHMFile chmFile ) - { - string strPreItems="", strPostItems=""; - string innerText = ""; - - int nIndex = 0; - - while( NestedRE.IsMatch(text, nIndex) ) - { - Match m = NestedRE.Match(text, nIndex); - - innerText = m.Value.Substring( 1, m.Length-2); - - strPreItems = text.Substring(nIndex,m.Index-nIndex); - - ParseItems(strPreItems, parent, arrNodes, chmFile); - - if((arrNodes.Count>0) && (innerText.Length > 0) ) - { - IndexItem p = ((IndexItem)(arrNodes[arrNodes.Count-1])); - ParseTree( innerText, p, arrNodes, chmFile ); - } - - nIndex = m.Index+m.Length; - } - - if( nIndex == 0) - { - strPostItems = text.Substring(nIndex, text.Length-nIndex); - ParseItems(strPostItems, parent, arrNodes, chmFile); - } - else if( nIndex < text.Length-1) - { - strPostItems = text.Substring(nIndex, text.Length-nIndex); - ParseTree(strPostItems, parent, arrNodes, chmFile); - } - } - - - /// - /// Parses nodes from the text - /// - /// text containing the items - /// parent index item - /// arraylist where the nodes should be added - /// CHMFile instance - private static void ParseItems( string itemstext, IndexItem parentItem, ArrayList arrNodes, CHMFile chmFile) - { - int innerTextIdx = ObjectRE.GroupNumberFromName("innerText"); - int innerPTextIdx = ParamRE.GroupNumberFromName("innerText"); - - // get group-name indexes - int nameIndex = AttributesRE.GroupNumberFromName("attributeName"); - int valueIndex = AttributesRE.GroupNumberFromName("attributeValue"); - int tdIndex = AttributesRE.GroupNumberFromName("attributeTD"); - - int nObjStartIndex = 0; - int nLastObjStartIndex = 0; - string sKeyword = ""; - - while( ObjectRE.IsMatch(itemstext, nObjStartIndex) ) - { - Match m = ObjectRE.Match(itemstext, nObjStartIndex); - - string innerText = m.Groups[innerTextIdx].Value; - - IndexItem idxItem = new IndexItem(); - - // read parameters - int nParamIndex = 0; - int nNameCnt = 0; - - string paramTitle = ""; - string paramLocal = ""; - bool bAdded = false; - - while( ParamRE.IsMatch(innerText, nParamIndex) ) - { - Match mP = ParamRE.Match(innerText, nParamIndex); - - string innerP = mP.Groups[innerPTextIdx].Value; - - string paramName = ""; - string paramValue = ""; - - int nAttrIdx = 0; - //sKeyword = ""; - - while( AttributesRE.IsMatch( innerP, nAttrIdx ) ) - { - Match mA = AttributesRE.Match(innerP, nAttrIdx); - - string attributeName = mA.Groups[nameIndex].Value; - string attributeValue = mA.Groups[valueIndex].Value; - string attributeTD = mA.Groups[tdIndex].Value; - - if(attributeTD.Length > 0) - { - // delete the trailing textqualifier - if( attributeValue.Length > 0) - { - int ltqi = attributeValue.LastIndexOf( attributeTD ); - - if(ltqi >= 0) - { - attributeValue = attributeValue.Substring(0,ltqi); - } - } - } - - if( attributeName.ToLower() == "name") - { - paramName = HttpUtility.HtmlDecode(attributeValue); // for unicode encoded values - nNameCnt++; - } - - if( attributeName.ToLower() == "value") - { - paramValue = HttpUtility.HtmlDecode(attributeValue); // for unicode encoded values - // delete trailing / - while((paramValue.Length>0)&&(paramValue[paramValue.Length-1] == '/')) - paramValue = paramValue.Substring(0,paramValue.Length-1); - } - - nAttrIdx = mA.Index+mA.Length; - } - - if( nNameCnt == 1) // first "Name" param = keyword - { - sKeyword = ""; - - if(parentItem != null) - sKeyword = parentItem.KeyWordPath + ","; - - string sOldKW = sKeyword; - - sKeyword += paramValue; - - IndexItem idxFind = FindByKeyword(arrNodes, sKeyword); - - if(idxFind != null) - { - idxItem = idxFind; - } - else - { - if( sKeyword.Split(new char[] {','}).Length > 1 ) - { - idxItem.CharIndex = sKeyword.Length - paramValue.Length; - } - else - { - sKeyword = paramValue; - sOldKW = sKeyword; - idxItem.CharIndex = 0; - } - - idxItem.KeyWordPath = sKeyword; - idxItem.Indent = sKeyword.Split(new char[] {','}).Length - 1; - idxItem.IsSeeAlso = false; - - sKeyword = sOldKW; - } - } - else - { - - if( (nNameCnt > 2) && (paramName.ToLower()=="name") ) - { - bAdded = true; - IndexTopic idxTopic = new IndexTopic(paramTitle, paramLocal, chmFile.CompileFile, chmFile.ChmFilePath); - - idxItem.Topics.Add( idxTopic ); - - paramTitle = ""; - paramLocal = ""; - } - - switch(paramName.ToLower()) - { - case "name": - //case "keyword": - { - paramTitle = paramValue; - };break; - case "local": - { - paramLocal = paramValue.Replace("../", "").Replace("./", ""); - };break; - case "type": // information type assignment for item - { - idxItem.InfoTypeStrings.Add( paramValue ); - };break; - case "see also": - { - idxItem.AddSeeAlso(paramValue); - idxItem.IsSeeAlso = true; - bAdded = true; - };break; - } - } - - nParamIndex = mP.Index+mP.Length; - } - - if(!bAdded) - { - bAdded=false; - IndexTopic idxTopic = new IndexTopic(paramTitle, paramLocal, chmFile.CompileFile, chmFile.ChmFilePath); - - idxItem.Topics.Add( idxTopic ); - - paramTitle = ""; - paramLocal = ""; - } - - idxItem.ChmFile = chmFile; - arrNodes.Add( idxItem ); - - nLastObjStartIndex = nObjStartIndex; - nObjStartIndex = m.Index+m.Length; - } - } - - /// - /// Searches an index-keyword in the index list - /// - /// index list to search - /// keyword to find - /// Returns an IndexItem instance if found, otherwise null. - private static IndexItem FindByKeyword(ArrayList indexList, string Keyword) - { - foreach(IndexItem curItem in indexList) - { - if( curItem.KeyWordPath == Keyword) - return curItem; - } - - return null; - } - - /// - /// Parses the very first <OBJECT> tag in the sitemap file and extracts - /// information types and categories. - /// - /// text of the object tag - /// CHMFile instance - private static void ParseGlobalSettings(string sText, CHMFile chmFile) - { - int innerPTextIdx = ParamRE.GroupNumberFromName("innerText"); - - // get group-name indexes - int nameIndex = AttributesRE.GroupNumberFromName("attributeName"); - int valueIndex = AttributesRE.GroupNumberFromName("attributeValue"); - int tdIndex = AttributesRE.GroupNumberFromName("attributeTD"); - - // read parameters - int nParamIndex = 0; - - // 0... unknown - // 1... inclusinve info type name - // 2... exclusive info type name - // 3... hidden info type name - // 4... category name - // 5... incl infotype name for category - // 6... excl infotype name for category - // 7... hidden infotype name for category - int prevItem = 0; - - string sName = ""; - string sDescription = ""; - string curCategory = ""; - - while( ParamRE.IsMatch(sText, nParamIndex) ) - { - Match mP = ParamRE.Match(sText, nParamIndex); - - string innerP = mP.Groups[innerPTextIdx].Value; - - string paramName = ""; - string paramValue = ""; - - int nAttrIdx = 0; - - while( AttributesRE.IsMatch( innerP, nAttrIdx ) ) - { - Match mA = AttributesRE.Match(innerP, nAttrIdx); - - string attributeName = mA.Groups[nameIndex].Value; - string attributeValue = mA.Groups[valueIndex].Value; - string attributeTD = mA.Groups[tdIndex].Value; - - if(attributeTD.Length > 0) - { - // delete the trailing textqualifier - if( attributeValue.Length > 0) - { - int ltqi = attributeValue.LastIndexOf( attributeTD ); - - if(ltqi >= 0) - { - attributeValue = attributeValue.Substring(0,ltqi); - } - } - } - - if( attributeName.ToLower() == "name") - { - paramName = HttpUtility.HtmlDecode(attributeValue); // for unicode encoded values - } - - if( attributeName.ToLower() == "value") - { - paramValue = HttpUtility.HtmlDecode(attributeValue); // for unicode encoded values - // delete trailing / - while((paramValue.Length>0)&&(paramValue[paramValue.Length-1] == '/')) - paramValue = paramValue.Substring(0,paramValue.Length-1); - - } - - nAttrIdx = mA.Index+mA.Length; - } - - switch(paramName.ToLower()) - { - case "savetype": // inclusive information type name - { - prevItem = 1; - sName = paramValue; - };break; - case "savetypedesc": // description of information type - { - InformationTypeMode mode = InformationTypeMode.Inclusive; - sDescription = paramValue; - - if( prevItem == 1) - mode = InformationTypeMode.Inclusive; - if( prevItem == 2) - mode = InformationTypeMode.Exclusive; - if( prevItem == 3) - mode = InformationTypeMode.Hidden; - - if( chmFile.GetInformationType( sName ) == null) - { - // check if the HtmlHelpSystem already holds such an information type - if( chmFile.SystemInstance.GetInformationType( sName ) == null) - { - // info type not found yet - - InformationType newType = new InformationType(sName, sDescription, mode); - chmFile.InformationTypes.Add(newType); - } - else - { - InformationType sysType = chmFile.SystemInstance.GetInformationType( sName ); - chmFile.InformationTypes.Add( sysType ); - } - } - - prevItem = 0; - };break; - case "saveexclusive": // exclusive information type name - { - prevItem = 2; - sName = paramValue; - };break; - case "savehidden": // hidden information type name - { - prevItem = 3; - sName = paramValue; - };break; - case "category": // category name - { - prevItem = 4; - sName = paramValue; - curCategory = sName; - };break; - case "categorydesc": // category description - { - sDescription = paramValue; - - if( chmFile.GetCategory( sName ) == null) - { - // check if the HtmlHelpSystem already holds such a category - if( chmFile.SystemInstance.GetCategory( sName ) == null) - { - // add category - Category newCat = new Category(sName, sDescription); - chmFile.Categories.Add(newCat); - } - else - { - Category sysCat = chmFile.SystemInstance.GetCategory( sName ); - chmFile.Categories.Add( sysCat ); - } - } - - prevItem = 0; - };break; - case "type": // inclusive information type which is member of the previously read category - { - prevItem = 5; - sName = paramValue; - };break; - case "typedesc": // description of type for category - { - sDescription = paramValue; - Category cat = chmFile.GetCategory( curCategory ); - - if( cat != null) - { - // category found - InformationType infoType = chmFile.GetInformationType( sName ); - - if( infoType != null) - { - if( !cat.ContainsInformationType(infoType)) - { - infoType.SetCategoryFlag(true); - cat.AddInformationType(infoType); - } - } - } - - prevItem = 0; - };break; - case "typeexclusive": // exclusive information type which is member of the previously read category - { - prevItem = 6; - sName = paramValue; - };break; - case "typehidden": // hidden information type which is member of the previously read category - { - prevItem = 7; - sName = paramValue; - };break; - default: - { - prevItem = 0; - sName = ""; - sDescription = ""; - };break; - } - - nParamIndex = mP.Index+mP.Length; - } - } - } -} diff --git a/irc/TechBot/CHMLibrary/CHMDecoding/TopicEntry.cs b/irc/TechBot/CHMLibrary/CHMDecoding/TopicEntry.cs deleted file mode 100644 index 16bde7d9d0d..00000000000 --- a/irc/TechBot/CHMLibrary/CHMDecoding/TopicEntry.cs +++ /dev/null @@ -1,245 +0,0 @@ -using System; -using System.IO; - -namespace HtmlHelp.ChmDecoding -{ - /// - /// The class TopicEntry stores the data for one topic entry - /// - internal sealed class TopicEntry - { - /// - /// Internal member storing the offset of this topic entry - /// - private int _entryOffset = 0; - /// - /// Internal member storing the index of the binary toc - /// - private int _tocidxOffset = 0; - /// - /// Internal member storing the string offset of the title - /// - private int _titleOffset = 0; - /// - /// Internal member storuing the urltable offset - /// - private int _urltableOffset = 0; - /// - /// Internal member storing the visibility mode - /// - private int _visibilityMode = 0; - /// - /// Internal member storing an unknown mode - /// - private int _unknownMode = 0; - /// - /// Internal member storing the associated chmfile object - /// - private CHMFile _associatedFile = null; - - /// - /// Constructor of the class - /// - /// offset of this entry - /// offset in the binary toc index - /// offset of the title (in the #STRINGS file) - /// offset in the urltable containing the urlstr offset for the url - /// visibility mode 2 indicates not in contents, 6 indicates that it is in the contents, 0/4 something else (unknown) - /// 0, 2, 4, 8, 10, 12, 16, 32 (unknown) - public TopicEntry(int entryOffset, int tocidxOffset, int titleOffset, int urltableOffset, int visibilityMode, int unknownMode) :this(entryOffset, tocidxOffset, titleOffset, urltableOffset, visibilityMode, unknownMode, null) - { - - } - - /// - /// Constructor of the class - /// - /// offset of this entry - /// offset in the binary toc index - /// offset of the title (in the #STRINGS file) - /// offset in the urltable containing the urlstr offset for the url - /// visibility mode 2 indicates not in contents, 6 indicates that it is in the contents, 0/4 something else (unknown) - /// 0, 2, 4, 8, 10, 12, 16, 32 (unknown) - /// associated chmfile object - internal TopicEntry(int entryOffset, int tocidxOffset, int titleOffset, int urltableOffset, int visibilityMode, int unknownMode, CHMFile associatedFile) - { - _entryOffset = entryOffset; - _tocidxOffset = tocidxOffset; - _titleOffset = titleOffset; - _urltableOffset = urltableOffset; - _visibilityMode = visibilityMode; - _unknownMode = unknownMode; - _associatedFile = associatedFile; - } - - /// - /// Standard constructor - /// - internal TopicEntry() - { - } - - #region Data dumping - /// - /// Dump the class data to a binary writer - /// - /// writer to write the data - internal void Dump(ref BinaryWriter writer) - { - writer.Write( _entryOffset ); - writer.Write( _tocidxOffset ); - writer.Write( _titleOffset ); - writer.Write( _urltableOffset ); - writer.Write( _visibilityMode ); - writer.Write( _unknownMode ); - } - - /// - /// Reads the object data from a dump store - /// - /// reader to read the data - internal void ReadDump(ref BinaryReader reader) - { - _entryOffset = reader.ReadInt32(); - _tocidxOffset = reader.ReadInt32(); - _titleOffset = reader.ReadInt32(); - _urltableOffset = reader.ReadInt32(); - _visibilityMode = reader.ReadInt32(); - _unknownMode = reader.ReadInt32(); - } - - /// - /// Sets the associated CHMFile instance - /// - /// instance to set - internal void SetCHMFile(CHMFile associatedFile) - { - _associatedFile = associatedFile; - } - #endregion - - /// - /// Gets the associated chm file - /// - internal CHMFile ChmFile - { - get { return _associatedFile; } - } - - /// - /// Gets the offset of this entry - /// - internal int EntryOffset - { - get { return _entryOffset; } - } - - /// - /// Gets the tocidx offset - /// - internal int TOCIdxOffset - { - get { return _tocidxOffset; } - } - - /// - /// Gets the title offset of the #STRINGS file - /// - internal int TitleOffset - { - get { return _titleOffset; } - } - - /// - /// Gets the urltable offset - /// - internal int UrlTableOffset - { - get { return _urltableOffset; } - } - - /// - /// Gets the title of the topic entry - /// - public string Title - { - get - { - if( _associatedFile == null) - return String.Empty; - - if( _associatedFile.StringsFile == null) - return String.Empty; - - string sTemp = (string)_associatedFile.StringsFile[ _titleOffset ]; - - if(sTemp == null) - return String.Empty; - - return sTemp; - } - } - - /// - /// Gets the url of the topic - /// - public string Locale - { - get - { - if( _associatedFile == null) - return String.Empty; - - if( _associatedFile.UrltblFile == null) - return String.Empty; - - UrlTableEntry utEntry = (UrlTableEntry)_associatedFile.UrltblFile[ _urltableOffset ]; - - if(utEntry == null) - return String.Empty; - - if(utEntry.URL == "") - return String.Empty; - - return utEntry.URL; - } - } - - /// - /// Gets the URL of this topic - /// - public string URL - { - get - { - if(Locale.Length <= 0) - return "about:blank"; - - if( (Locale.ToLower().IndexOf("http://") >= 0) || - (Locale.ToLower().IndexOf("https://") >= 0) || - (Locale.ToLower().IndexOf("mailto:") >= 0) || - (Locale.ToLower().IndexOf("ftp://") >= 0) || - (Locale.ToLower().IndexOf("ms-its:") >= 0)) - return Locale; - - return HtmlHelpSystem.UrlPrefix + _associatedFile.ChmFilePath + "::/" + Locale; - } - } - - /// - /// Gets the visibility mode - /// - public int VisibilityMode - { - get { return _visibilityMode; } - } - - /// - /// Gets the unknown mode - /// - public int UknownMode - { - get { return _unknownMode; } - } - } -} diff --git a/irc/TechBot/CHMLibrary/CHMDecoding/UrlTableEntry.cs b/irc/TechBot/CHMLibrary/CHMDecoding/UrlTableEntry.cs deleted file mode 100644 index 53391ce2f05..00000000000 --- a/irc/TechBot/CHMLibrary/CHMDecoding/UrlTableEntry.cs +++ /dev/null @@ -1,175 +0,0 @@ -using System; -using System.IO; - -namespace HtmlHelp.ChmDecoding -{ - /// - /// The class UrlTableEntry stores data for an URL-Table entry - /// - internal sealed class UrlTableEntry - { - /// - /// Internal member storing the offset of this entry - /// - private int _entryOffset = 0; - /// - /// Internal member storing a unique id - /// - private uint _uniqueID = 0; - /// - /// Internal member storing the topics index - /// - private int _topicsIndex = 0; - /// - /// Internal member storing the offset in the urlstr table - /// - private int _urlStrOffset = 0; - /// - /// Internal member storing the associated chmfile object - /// - private CHMFile _associatedFile = null; - - /// - /// Constructor of the class - /// - /// unique id - /// offset of the entry - /// topic index - /// urlstr offset for filename - public UrlTableEntry(uint uniqueID, int entryOffset, int topicIndex, int urlstrOffset) : this(uniqueID, entryOffset, topicIndex, urlstrOffset, null) - { - } - - /// - /// Constructor of the class - /// - /// unique id - /// offset of the entry - /// topic index - /// urlstr offset for filename - /// associated chm file - internal UrlTableEntry(uint uniqueID, int entryOffset, int topicIndex, int urlstrOffset, CHMFile associatedFile) - { - _uniqueID = uniqueID; - _entryOffset = entryOffset; - _topicsIndex = topicIndex; - _urlStrOffset = urlstrOffset; - _associatedFile = associatedFile; - } - - /// - /// Standard constructor - /// - internal UrlTableEntry() - { - } - - #region Data dumping - /// - /// Dump the class data to a binary writer - /// - /// writer to write the data - internal void Dump(ref BinaryWriter writer) - { - writer.Write( _urlStrOffset ); - writer.Write( _entryOffset ); - writer.Write( _topicsIndex ); - writer.Write( _urlStrOffset ); - } - - /// - /// Reads the object data from a dump store - /// - /// reader to read the data - internal void ReadDump(ref BinaryReader reader) - { - _urlStrOffset = reader.ReadInt32(); - _entryOffset = reader.ReadInt32(); - _topicsIndex = reader.ReadInt32(); - _urlStrOffset = reader.ReadInt32(); - } - - /// - /// Sets the associated CHMFile instance - /// - /// instance to set - internal void SetCHMFile(CHMFile associatedFile) - { - _associatedFile = associatedFile; - } - #endregion - - /// - /// Gets the unique id of the entry - /// - internal uint UniqueID - { - get {return _uniqueID; } - } - - /// - /// Gets the offset of the entry - /// - internal int EntryOffset - { - get {return _entryOffset; } - } - - /// - /// Gets the topics index - /// - internal int TopicIndex - { - get {return _topicsIndex; } - } - - /// - /// Gets the urlstr offset - /// - internal int UrlstrOffset - { - get { return _urlStrOffset; } - } - - /// - /// Gets the url of the entry - /// - public string URL - { - get - { - if(_associatedFile == null) - return String.Empty; - - if(_associatedFile.UrlstrFile == null) - return String.Empty; - - string sTemp = (string)_associatedFile.UrlstrFile.GetURLatOffset( _urlStrOffset ); - - if( sTemp == null) - return String.Empty; - - return sTemp; - } - } - - /// - /// Gets the associated topic for this url entry - /// - internal TopicEntry Topic - { - get - { - if(_associatedFile == null) - return null; - - if(_associatedFile.TopicsFile == null) - return null; - - TopicEntry tentry = _associatedFile.TopicsFile[ _topicsIndex*16 ]; - - return tentry; - } - } - } -} diff --git a/irc/TechBot/CHMLibrary/CHMDecoding/enumerations.cs b/irc/TechBot/CHMLibrary/CHMDecoding/enumerations.cs deleted file mode 100644 index 0e2d314ecd6..00000000000 --- a/irc/TechBot/CHMLibrary/CHMDecoding/enumerations.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System; - -namespace HtmlHelp.ChmDecoding -{ - /// - /// Enumeration for specifying the extraction mode of an toc or index item. - /// - public enum DataMode - { - /// - /// TextBased - this item comes from a text-based sitemap file - /// - TextBased = 0, - /// - /// Binary - this item was extracted out of a binary stream - /// - Binary = 1 - } -} diff --git a/irc/TechBot/CHMLibrary/CHMLibrary.cmbx b/irc/TechBot/CHMLibrary/CHMLibrary.cmbx deleted file mode 100644 index 7209cbb462c..00000000000 --- a/irc/TechBot/CHMLibrary/CHMLibrary.cmbx +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/irc/TechBot/CHMLibrary/CHMLibrary.csproj b/irc/TechBot/CHMLibrary/CHMLibrary.csproj deleted file mode 100644 index 3ab019a4eca..00000000000 --- a/irc/TechBot/CHMLibrary/CHMLibrary.csproj +++ /dev/null @@ -1,85 +0,0 @@ - - - - Debug - AnyCPU - 8.0.50727 - 2.0 - {72E5CCA1-6318-4D62-964D-CB23A5C743B5} - Library - Properties - CHMLibrary - CHMLibrary - - - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {E32307F1-623A-4E62-826F-56CDD4B23A54} - Compression - - - \ No newline at end of file diff --git a/irc/TechBot/CHMLibrary/CHMLibrary.prjx b/irc/TechBot/CHMLibrary/CHMLibrary.prjx deleted file mode 100644 index 3a888b43106..00000000000 --- a/irc/TechBot/CHMLibrary/CHMLibrary.prjx +++ /dev/null @@ -1,58 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/irc/TechBot/CHMLibrary/Category.cs b/irc/TechBot/CHMLibrary/Category.cs deleted file mode 100644 index d1ae4e74d44..00000000000 --- a/irc/TechBot/CHMLibrary/Category.cs +++ /dev/null @@ -1,201 +0,0 @@ -using System; -using System.Collections; -using System.IO; - -using HtmlHelp.ChmDecoding; - -namespace HtmlHelp -{ - /// - /// The class Category implements methods/properties for handling an information category - /// - /// Note: Information types and categories allow users to filter help contents. - /// They are only supported if using sitemap TOC and/or sitemap Index. - public class Category - { - private string _name = ""; - private string _description = ""; - private ArrayList _infoTypes = null; - private int _referenceCount = 1; - - /// - /// Standard constructor - /// - public Category() : this("","") - { - } - - /// - /// Standard constructor - /// - /// name of the category - /// description - public Category(string name, string description) : this(name, description, new ArrayList()) - { - } - /// - /// Standard constructor - /// - /// name of the category - /// description - /// Arraylist of InformationType instances which applies to this category - public Category(string name, string description, ArrayList linkedInformationTypes) - { - _name = name; - _description = description; - _infoTypes = linkedInformationTypes; - } - - #region Data dumping - /// - /// Dump the class data to a binary writer - /// - /// writer to write the data - internal void Dump(ref BinaryWriter writer) - { - writer.Write( _name ); - writer.Write( _description ); - - writer.Write( _infoTypes.Count ); - - for(int i=0; i<_infoTypes.Count;i++) - { - InformationType curType = _infoTypes[i] as InformationType; - writer.Write( curType.Name ); - } - - } - - /// - /// Reads the object data from a dump store - /// - /// reader to read the data - /// current CHMFile instance which reads from dump - internal void ReadDump(ref BinaryReader reader, CHMFile chmFile) - { - _name = reader.ReadString(); - _description = reader.ReadString(); - - int nCnt = reader.ReadInt32(); - - for(int i=0; i - /// Merges the lineked information types from cat into this instance - /// - /// category instance - internal void MergeInfoTypes(Category cat) - { - if(cat!=null) - { - if(cat.InformationTypes.Count > 0) - { - for(int i=0;i - /// Gets/Sets the reference count of this information type instance - /// - internal int ReferenceCount - { - get { return _referenceCount; } - set { _referenceCount = value; } - } - - /// - /// Gets/Sets the name of the information type - /// - public string Name - { - get { return _name; } - set { _name = value; } - } - - /// - /// Gets/Sets the description of the information type - /// - public string Description - { - get { return _description; } - set { _name = value; } - } - - /// - /// Gets an ArrayList with the linked Information types - /// - public ArrayList InformationTypes - { - get { return _infoTypes; } - } - - /// - /// Adds a new information type to the category - /// - /// - public void AddInformationType(InformationType type) - { - _infoTypes.Add(type); - } - - /// - /// Removes an information type from the category - /// - /// - public void RemoveInformationType(InformationType type) - { - _infoTypes.Remove(type); - } - - /// - /// Checks if the category contains an information type - /// - /// information type instance to check - /// Return true if the information type is part of this category - public bool ContainsInformationType(InformationType type) - { - return _infoTypes.Contains(type); - } - - /// - /// Checks if the category contains an information type - /// - /// name of the information type - /// Return true if the information type is part of this category - public bool ContainsInformationType(string name) - { - for(int i=0;i<_infoTypes.Count;i++) - { - InformationType curType = _infoTypes[i] as InformationType; - - if(curType.Name == name) - return true; - } - - return false; - } - } -} diff --git a/irc/TechBot/CHMLibrary/ChmFileInfo.cs b/irc/TechBot/CHMLibrary/ChmFileInfo.cs deleted file mode 100644 index 15f6a1e266f..00000000000 --- a/irc/TechBot/CHMLibrary/ChmFileInfo.cs +++ /dev/null @@ -1,478 +0,0 @@ -using System; -using System.Collections; -using System.Text; -using System.IO; -using System.Globalization; -using System.Diagnostics; -using System.ComponentModel; - -using HtmlHelp.ChmDecoding; -// using HtmlHelp.Storage; - -namespace HtmlHelp -{ - /// - /// The class ChmFileInfo only extracts system information from a CHM file. - /// It doesn't build the index and table of contents. - /// - public class ChmFileInfo - { - /// - /// Internal member storing the full filename - /// - private string _chmFileName = ""; - /// - /// Internal member storing the associated chmfile object - /// - private CHMFile _associatedFile = null; - - /// - /// Constructor for extrating the file information of the provided file. - /// The constructor opens the chm-file and reads its system data. - /// - /// full file name which information should be extracted - public ChmFileInfo(string chmFile) - { - if(!File.Exists(chmFile)) - throw new ArgumentException("Chm file must exist on disk !", "chmFileName"); - - if( ! chmFile.ToLower().EndsWith(".chm") ) - throw new ArgumentException("HtmlHelp file must have the extension .chm !", "chmFile"); - - _chmFileName = chmFile; - _associatedFile = new CHMFile(null, chmFile, true); // only load system data of chm - } - - /// - /// Internal constructor used in the class CHMFile. - /// - /// associated chm file - internal ChmFileInfo(CHMFile associatedFile) - { - _associatedFile = associatedFile; - - if( _associatedFile == null) - throw new ArgumentException("Associated CHMFile instance must not be null !", "associatedFile"); - } - - #region default info properties - /// - /// Gets the full filename of the chm file - /// - public string ChmFileName - { - get - { - return _associatedFile.ChmFilePath; - } - } - - /// - /// Gets a FileInfo instance for the chm file. - /// - public FileInfo FileInfo - { - get { return new FileInfo(_associatedFile.ChmFilePath); } - } - #endregion - - #region #SYSTEM properties - /// - /// Gets the file version of the chm file. - /// 2 for Compatibility=1.0, 3 for Compatibility=1.1 - /// - public int FileVersion - { - get - { - if(_associatedFile != null) - return _associatedFile.FileVersion; - - return 0; - } - } - - /// - /// Gets the contents file name - /// - - public string ContentsFile - { - get - { - if(_associatedFile != null) - return _associatedFile.ContentsFile; - - return ""; - } - } - - /// - /// Gets the index file name - /// - - public string IndexFile - { - get - { - if(_associatedFile != null) - return _associatedFile.IndexFile; - - return ""; - } - } - - /// - /// Gets the default help topic - /// - - public string DefaultTopic - { - get - { - if(_associatedFile != null) - return _associatedFile.DefaultTopic; - - return ""; - } - } - - /// - /// Gets the title of the help window - /// - - public string HelpWindowTitle - { - get - { - if(_associatedFile != null) - return _associatedFile.HelpWindowTitle; - - return ""; - } - } - - /// - /// Gets the flag if DBCS is in use - /// - - public bool DBCS - { - get - { - if(_associatedFile != null) - return _associatedFile.DBCS; - - return false; - } - } - - /// - /// Gets the flag if full-text-search is available - /// - - public bool FullTextSearch - { - get - { - if(_associatedFile != null) - return _associatedFile.FullTextSearch; - - return false; - } - } - - /// - /// Gets the flag if the file has ALinks - /// - - public bool HasALinks - { - get - { - if(_associatedFile != null) - return _associatedFile.HasALinks; - - return false; - } - } - - /// - /// Gets the flag if the file has KLinks - /// - - public bool HasKLinks - { - get - { - if(_associatedFile != null) - return _associatedFile.HasKLinks; - - return false; - } - } - - /// - /// Gets the default window name - /// - - public string DefaultWindow - { - get - { - if(_associatedFile != null) - return _associatedFile.DefaultWindow; - - return ""; - } - } - - /// - /// Gets the file name of the compile file - /// - - public string CompileFile - { - get - { - if(_associatedFile != null) - return _associatedFile.CompileFile; - - return ""; - } - } - - /// - /// Gets the flag if the chm has a binary index file - /// - - public bool BinaryIndex - { - get - { - if(_associatedFile != null) - return _associatedFile.BinaryIndex; - - return false; - } - } - - /// - /// Gets the flag if the chm has a binary index file - /// - - public string CompilerVersion - { - get - { - if(_associatedFile != null) - return _associatedFile.CompilerVersion; - - return ""; - } - } - - /// - /// Gets the flag if the chm has a binary toc file - /// - - public bool BinaryTOC - { - get - { - if(_associatedFile != null) - return _associatedFile.BinaryTOC; - - return false; - } - } - - /// - /// Gets the font face of the read font property. - /// Empty string for default font. - /// - - public string FontFace - { - get - { - if(_associatedFile != null) - return _associatedFile.FontFace; - - return ""; - } - } - - /// - /// Gets the font size of the read font property. - /// 0 for default font size - /// - - public double FontSize - { - get - { - if(_associatedFile != null) - return _associatedFile.FontSize; - - return 0.0; - } - } - - /// - /// Gets the character set of the read font property - /// 1 for default - /// - - public int CharacterSet - { - get - { - if(_associatedFile != null) - return _associatedFile.CharacterSet; - - return 1; - } - } - - /// - /// Gets the codepage depending on the read font property - /// - - public int CodePage - { - get - { - if(_associatedFile != null) - return _associatedFile.CodePage; - - return 0; - } - } - - /// - /// Gets the assiciated culture info - /// - public CultureInfo Culture - { - get - { - if(_associatedFile != null) - return _associatedFile.Culture; - - return CultureInfo.CurrentCulture; - } - } - #endregion - - #region #IDXHDR properties - /// - /// Gets the number of topic nodes including the contents and index files - /// - - public int NumberOfTopicNodes - { - get - { - if(_associatedFile != null) - return _associatedFile.NumberOfTopicNodes; - - return 0; - } - } - - /// - /// Gets the ImageList string specyfied in the #IDXHDR file. - /// - /// This property uses the #STRINGS file to extract the string at a given offset. - - public string ImageList - { - get - { - if(_associatedFile != null) - return _associatedFile.ImageList; - - return ""; - } - } - - /// - /// Gets the background setting - /// - - public int Background - { - get - { - if(_associatedFile != null) - return _associatedFile.Background; - - return 0; - } - } - - /// - /// Gets the foreground setting - /// - - public int Foreground - { - get - { - if(_associatedFile != null) - return _associatedFile.Foreground; - - return 0; - } - } - - /// - /// Gets the FrameName string specyfied in the #IDXHDR file. - /// - /// This property uses the #STRINGS file to extract the string at a given offset. - - public string FrameName - { - get - { - if(_associatedFile != null) - return _associatedFile.FrameName; - - return ""; - } - } - - /// - /// Gets the WindowName string specyfied in the #IDXHDR file. - /// - /// This property uses the #STRINGS file to extract the string at a given offset. - - public string WindowName - { - get - { - if(_associatedFile != null) - return _associatedFile.WindowName; - - return ""; - } - } - - /// - /// Gets a string array containing the merged file names - /// - public string[] MergedFiles - { - get - { - if(_associatedFile != null) - return _associatedFile.MergedFiles; - - return new string[0]; - } - } - - #endregion - } -} diff --git a/irc/TechBot/CHMLibrary/Default.build b/irc/TechBot/CHMLibrary/Default.build deleted file mode 100644 index 6363074a8db..00000000000 --- a/irc/TechBot/CHMLibrary/Default.build +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - - - - - - - - - - - - diff --git a/irc/TechBot/CHMLibrary/HtmlHelpSystem.cs b/irc/TechBot/CHMLibrary/HtmlHelpSystem.cs deleted file mode 100644 index 966cd3d7205..00000000000 --- a/irc/TechBot/CHMLibrary/HtmlHelpSystem.cs +++ /dev/null @@ -1,894 +0,0 @@ -using System; -using System.IO; -using System.Collections; -using System.Data; - -using HtmlHelp.ChmDecoding; - -namespace HtmlHelp -{ - /// - /// The class HtmlHelpSystem implements the main object for reading chm files - /// - public sealed class HtmlHelpSystem - { - /// - /// Private shared instance of current HtmlHelpSystem class - /// - private static HtmlHelpSystem _current=null; - /// - /// Internal member storing the attached files - /// - private ArrayList _chmFiles = new ArrayList(); - /// - /// Internal member storing a merged table of contents - /// - private TableOfContents _toc = new TableOfContents(); - /// - /// Internal member storing a merged index - /// - private Index _index = new Index(); - /// - /// URL prefix for specifying a chm destination - /// - private static string _urlPrefix = "ms-its:"; - /// - /// Internal flag specifying if the system should use the tree-images list - /// from HtmlHelp2. If false the standard CHM-Viewer pics will be used. - /// - private static bool _useHH2TreePics = false; - /// - /// Internal member storing the read information types - /// - private ArrayList _informationTypes = new ArrayList(); - /// - /// Internal member storing the read categories - /// - private ArrayList _categories = new ArrayList(); - - /// - /// Gets/Sets the url prefix for specifying a chm destination - /// - public static string UrlPrefix - { - get { return _urlPrefix; } - set { _urlPrefix = value; } - } - - public CHMStream.CHMStream BaseStream - { - get - { - CHMFile chm=(CHMFile)_chmFiles[0]; - return chm.BaseStream; - } - } - - /// - /// Gets/Sets the flag specifying if the system should use the tree-images list - /// from HtmlHelp2. If false the standard CHM-Viewer pics will be used. - /// - public static bool UseHH2TreePics - { - get { return _useHH2TreePics; } - set { _useHH2TreePics = value; } - } - - /// - /// Gets the current HtmlHelpSystem instance - /// - public static HtmlHelpSystem Current - { - get - { - return _current; - } - } - - /// - /// Standard constructor - /// - public HtmlHelpSystem() : this("") - { - } - - /// - /// Constructor of the reader class - /// - /// chm file to attach with the reader - public HtmlHelpSystem(string chmFile) - { - _current = this; - OpenFile(chmFile); - } - - - /// - /// Opens a chm file and creates - /// - /// full file path of the chm file to open - /// If you call this method, all existing merged files will be cleared. - public void OpenFile(string chmFile) - { - OpenFile(chmFile, null); - } - - /// - /// Opens a chm file and creates - /// - /// full file path of the chm file to open - /// dumping info - /// If you call this method, all existing merged files will be cleared. - public void OpenFile(string chmFile, DumpingInfo dmpInfo) - { - if( File.Exists(chmFile ) ) - { - _chmFiles.Clear(); - _toc.Clear(); - _index.Clear(); - _informationTypes.Clear(); - _categories.Clear(); - - CHMFile newFile = new CHMFile(this, chmFile, dmpInfo); - - _toc = new TableOfContents( newFile.TOC ); - _index = new Index( newFile.IndexKLinks, newFile.IndexALinks ); - - _chmFiles.Add(newFile); - // add all infotypes and categories of the read file to this system instance - MergeFileInfoTypesCategories(newFile); - - // check if the file has a merged files list - if( newFile.MergedFiles.Length > 0 ) - { - // extract the path of the chm file (usually merged files are in the same path) - FileInfo fi = new FileInfo(chmFile); - string sPath = fi.DirectoryName; - - for(int i=0; i 0) - { - if(sFile[1] != ':') // no full path setting - { - sFile = Path.Combine(sPath, sFile); - } - - MergeFile(sFile, dmpInfo, true); - } - } - - // if (newFile.MergLinks.Count>0) - // RecalculateMergeLinks(newFile); - - RemoveMergeLinks(); // clear all merge-links which have no target ! - } - } - } - - /// - /// Merges a chm file to the current help contents - /// - /// full file path of the chm file to merge - public void MergeFile(string chmFile) - { - MergeFile(chmFile, null); - } - - /// - /// Merges a chm file to the current help contents - /// - /// full file path of the chm file to merge - /// dumping info - public void MergeFile(string chmFile, DumpingInfo dmpInfo) - { - MergeFile(chmFile, dmpInfo, false); - } - - /// - /// Merges a chm file to the current help contents - /// - /// full file path of the chm file to merge - /// dumping info - /// true if the merge is done because a merged file list - /// was found in the previously loaded CHM. - internal void MergeFile(string chmFile, DumpingInfo dmpInfo, bool mergedFileList) - { - if( File.Exists(chmFile ) ) - { - if( _chmFiles.Count == 1) - { - // if we open the first file, we directly point into the toc and index of this file. - // So that we don't merge the new toc's indexe's into the first file, we have to - // clone the internal arraylists first to a new instance of the toc/index holder classes. - ArrayList atoc = _toc.TOC; - ArrayList alinks = _index.ALinks; - ArrayList klinks = _index.KLinks; - - _toc = new TableOfContents(); - _index = new Index(); - - _toc.MergeToC( atoc ); - _index.MergeIndex( alinks, IndexType.AssiciativeLinks ); - _index.MergeIndex( klinks, IndexType.KeywordLinks ); - } - - CHMFile newFile = new CHMFile(this, chmFile, dmpInfo); - - if(mergedFileList) // if we've called this method due to a merged file list merge - { - RecalculateMergeLinks(newFile); - - _toc.MergeToC( newFile.TOC, _chmFiles ); - _index.MergeIndex( newFile.IndexALinks, IndexType.AssiciativeLinks ); - _index.MergeIndex( newFile.IndexKLinks, IndexType.KeywordLinks ); - - _chmFiles.Add(newFile); - - // add all infotypes and categories of the read file to this system instance - MergeFileInfoTypesCategories(newFile); - } - else - { - _toc.MergeToC( newFile.TOC, _chmFiles ); - _index.MergeIndex( newFile.IndexALinks, IndexType.AssiciativeLinks ); - _index.MergeIndex( newFile.IndexKLinks, IndexType.KeywordLinks ); - - _chmFiles.Add(newFile); - - // add all infotypes and categories of the read file to this system instance - MergeFileInfoTypesCategories(newFile); - - // check if the file has a merged files list - if( newFile.MergedFiles.Length > 0 ) - { - // extract the path of the chm file (usually merged files are in the same path) - FileInfo fi = new FileInfo(chmFile); - string sPath = fi.DirectoryName; - - for(int i=0; i 0) - { - if(sFile[1] != ':') // no full path setting - { - sFile = Path.Combine(sPath, sFile); - } - - MergeFile(sFile, dmpInfo, true); - } - } - - RemoveMergeLinks(); // clear all merge-links which have no target ! - } - } - } - } - - /// - /// Checks all Merg-links read till now. Checks if the merg-link points to the - /// file currentFile. If yes the link will be replaced by the contents of the - /// merged file. - /// - /// Current CHMFile instance - internal void RecalculateMergeLinks(CHMFile currentFile) - { - foreach(CHMFile curFile in _chmFiles) - { - if( curFile.MergLinks.Count > 0) - { - for(int i=0; i 3) // merge info contains path name - { - sFName = sSplit[0] + ":" + sSplit[1]; - sTarget = sSplit[3]; - } - else if( sSplit.Length == 3)// merge info contains only file name - { - FileInfo fi = new FileInfo(currentFile.ChmFilePath); - string sPath = fi.DirectoryName; - - string sFile = sSplit[0]; - - if(sFile.Length > 0) - { - if(sFile[1] != ':') // no full path setting - { - sFile = Path.Combine(sPath, sFile); - } - } - - sFName = sFile; - sTarget = sSplit[2]; - } - - ArrayList arrToc = null; - if( (sFName.Length>0) && (sTarget.Length>0) ) - { - // if this link points into the current file - if( sFName.ToLower() == currentFile.ChmFilePath.ToLower() ) - { - if(sTarget.ToLower().IndexOf(".hhc") >= 0) - { - string sfCheck = sTarget; - - // remove prefixing ./ - while( (sfCheck[0]=='.') || (sfCheck[0]=='/') ) - { - sfCheck = sfCheck.Substring(1); - } - - if( currentFile.ContentsFile.ToLower() != sfCheck ) - { - arrToc = currentFile.ParseHHC( sTarget ); - - if( arrToc.Count > 0) - { - } - } - else - { - arrToc = currentFile.TOC; - } - - // target points to a complete TOC - int nCnt = 0; - - foreach(TOCItem chkItem in arrToc) - { - if(nCnt == 0) - { - curItem.AssociatedFile = currentFile; - curItem.Children = chkItem.Children; - curItem.ChmFile = currentFile.ChmFilePath; - curItem.ImageIndex = chkItem.ImageIndex; - curItem.Local = chkItem.Local; - curItem.MergeLink = chkItem.MergeLink; - curItem.Name = chkItem.Name; - curItem.TocMode = chkItem.TocMode; - curItem.TopicOffset = chkItem.TopicOffset; - - MarkChildrenAdded(chkItem.Children, curFile.MergLinks); - } - else - { - ArrayList checkList = null; - - if(curItem.Parent != null) - checkList = curItem.Parent.Children; - else - checkList = curFile.TOC; - - int nIdx = checkList.IndexOf(curItem); - if((nIdx+nCnt)>checkList.Count) - checkList.Add(chkItem); - else - checkList.Insert(nIdx+nCnt, chkItem); - - curFile.MergLinks.Add(chkItem); - MarkChildrenAdded(chkItem.Children, curFile.MergLinks); - } - - nCnt++; - } - } - else - { - - // target points to a single topic - TOCItem chkItem = currentFile.GetTOCItemByLocal(sTarget); - if(chkItem != null) - { - curItem.AssociatedFile = currentFile; - curItem.Children = chkItem.Children; - curItem.ChmFile = currentFile.ChmFilePath; - curItem.ImageIndex = chkItem.ImageIndex; - curItem.Local = chkItem.Local; - curItem.MergeLink = chkItem.MergeLink; - curItem.Name = chkItem.Name; - curItem.TocMode = chkItem.TocMode; - curItem.TopicOffset = chkItem.TopicOffset; - - curFile.MergLinks.Add(chkItem); - MarkChildrenAdded(chkItem.Children, curFile.MergLinks); - } - } - } - } - } - } - } - } - - /// - /// Adds sub-items of an TOC-entry to the merg-linked list. - /// This will mark this item as "added" during the extra merge run - /// of the HtmlHelpSystem class. - /// - /// TOCItem list - /// Arraylist which holds the merged-items - internal void MarkChildrenAdded(ArrayList tocs, ArrayList merged) - { - foreach(TOCItem curItem in tocs) - { - if(!merged.Contains(curItem)) - { - merged.Add(curItem); - - MarkChildrenAdded(curItem.Children, merged); - } - } - } - - /// - /// Removes merge-links from the toc of files which were not loaded - /// - internal void RemoveMergeLinks() - { - foreach(CHMFile curFile in _chmFiles) - { - if( curFile.MergLinks.Count > 0) - { - while(curFile.MergLinks.Count > 0) - { - TOCItem curItem = curFile.MergLinks[0] as TOCItem; - if(curItem.MergeLink.Length > 0) - curFile.RemoveTOCItem(curItem); - - curFile.MergLinks.RemoveAt(0); - } - } - } - } - - /// - /// Merges the information types and categories read by the CHMFile instance - /// into the system instance - /// - /// file instance - private void MergeFileInfoTypesCategories(CHMFile chmFile) - { - if(chmFile.HasInformationTypes) - { - for(int i=0; i - /// Removes the information types and categories read by the CHMFile instance - /// - /// file instance - private void RemoveFileInfoTypesCategories(CHMFile chmFile) - { - if(chmFile.HasInformationTypes) - { - for(int i=0; i - /// Removes a chm file from the internal file collection - /// - /// full file path of the chm file to remove - public void RemoveFile(string chmFile) - { - int nIdx = -1; - CHMFile removeInstance=null; - - foreach(CHMFile curFile in _chmFiles) - { - nIdx++; - - if( curFile.ChmFilePath.ToLower() == chmFile.ToLower() ) - { - removeInstance = curFile; - break; - } - } - - if(nIdx >= 0) - { - _toc.Clear(); // forces a rebuild of the merged toc - _index.Clear(); // force a rebuild of the merged index - - RemoveFileInfoTypesCategories(removeInstance); - _chmFiles.RemoveAt(nIdx); - } - } - - /// - /// Closes all files and destroys TOC/index - /// - public void CloseAllFiles() - { - for(int i=0; i < _chmFiles.Count; i++) - { - CHMFile curFile = _chmFiles[i] as CHMFile; - - _chmFiles.RemoveAt(i); - curFile.Dispose(); - i--; - } - - _chmFiles.Clear(); - _toc.Clear(); - _index.Clear(); - _informationTypes.Clear(); - _categories.Clear(); - } - - /// - /// Gets an array of loaded chm files. - /// - public CHMFile[] FileList - { - get - { - CHMFile[] ret = new CHMFile[ _chmFiles.Count ]; - for(int i=0;i<_chmFiles.Count;i++) - ret[i] = (CHMFile)_chmFiles[i]; - - return ret; - } - } - - /// - /// Returns true if the HtmlHelpSystem instance contains 1 or more information types - /// - public bool HasInformationTypes - { - get { return (_informationTypes.Count>0); } - } - - /// - /// Returns true if the HtmlHelpSystem instance contains 1 or more categories - /// - public bool HasCategories - { - get { return (_categories.Count>0); } - } - - /// - /// Gets an ArrayList of InformationType items - /// - public ArrayList InformationTypes - { - get { return _informationTypes; } - } - - /// - /// Gets an ArrayList of Category items - /// - public ArrayList Categories - { - get { return _categories; } - } - - /// - /// Gets the information type specified by its name - /// - /// name of the information type to receive - /// Returns the Instance for the name or null if not found - public InformationType GetInformationType(string name) - { - if(HasInformationTypes) - { - for(int i=0; i<_informationTypes.Count;i++) - { - InformationType iT = _informationTypes[i] as InformationType; - - if(iT.Name == name) - return iT; - } - } - - return null; - } - - /// - /// Gets the category specifiyd by its name - /// - /// name of the category - /// Returns the Instance for the name or null if not found - public Category GetCategory(string name) - { - if(HasCategories) - { - for(int i=0; i<_categories.Count;i++) - { - Category cat = _categories[i] as Category; - - if(cat.Name == name) - return cat; - } - } - - return null; - } - - /// - /// Gets the default topic - /// - public string DefaultTopic - { - get - { - if( _chmFiles.Count > 0 ) - { - foreach(CHMFile curFile in _chmFiles) - { - if( curFile.DefaultTopic.Length > 0) - { - return curFile.FormURL( curFile.DefaultTopic ); - } - } - } - - return "about:blank"; - } - } - - /// - /// Gets a merged table of contents of all opened chm files - /// - public TableOfContents TableOfContents - { - get - { - if( _chmFiles.Count > 0 ) - { - if( _toc.Count() <= 0) - { - // merge toc of files - foreach(CHMFile curFile in _chmFiles) - { - _toc.MergeToC( curFile.TOC ); - } - } - } - - return _toc; - } - } - - /// - /// Gets a merged index of all opened chm files - /// - public Index Index - { - get - { - if( _chmFiles.Count > 0 ) - { - if( (_index.Count(IndexType.KeywordLinks)+_index.Count(IndexType.AssiciativeLinks)) <= 0) - { - // merge index files - foreach(CHMFile curFile in _chmFiles) - { - _index.MergeIndex( curFile.IndexKLinks, IndexType.KeywordLinks); - _index.MergeIndex( curFile.IndexALinks, IndexType.AssiciativeLinks); - } - } - } - - return _index; - } - } - - /// - /// Gets a flag if the current instance offers a table of contents - /// - public bool HasTableOfContents - { - get - { - return (TableOfContents.Count() > 0); - } - } - - /// - /// Gets a flag if the current instance offers an index - /// - public bool HasIndex - { - get - { - return (HasALinks || HasKLinks); - } - } - - /// - /// Gets a flag if the index holds klinks - /// - public bool HasKLinks - { - get - { - return (_index.Count(IndexType.KeywordLinks) > 0); - } - } - - /// - /// Gets a flag if the index holds alinks - /// - public bool HasALinks - { - get - { - return (_index.Count(IndexType.AssiciativeLinks) > 0); - } - } - - /// - /// Gets a flag if the current instance supports fulltext searching - /// - public bool FullTextSearch - { - get - { - bool bRet = false; - - foreach(CHMFile curFile in _chmFiles) - { - bRet |= curFile.FullTextSearch; - } - - return bRet; - } - } - - /// - /// Performs a full-text search over the chm files - /// - /// words to search - /// true if partial word should be matched also - /// ( if this is true a search of 'support' will match 'supports', otherwise not ) - /// true if titles only - /// A DataTable containing the search hits - public DataTable PerformSearch(string words, bool partialMatches, bool titleOnly) - { - return PerformSearch(words, -1, partialMatches, titleOnly); - } - - /// - /// Performs a full-text search over the chm files - /// - /// words to search - /// maximal number of hits to return - /// true if partial word should be matched also - /// ( if this is true a search of 'support' will match 'supports', otherwise not ) - /// true if titles only - /// A DataTable containing the search hits - public DataTable PerformSearch(string words, int MaxResults, bool partialMatches, bool titleOnly) - { - if( ! FullTextSearch ) - return null; - - DataTable dtResult = null; - - int nCnt = 0; - - foreach(CHMFile curFile in _chmFiles) - { - if(nCnt == 0) - { - if(curFile.FullTextSearchEngine.CanSearch) - { - if(curFile.FullTextSearchEngine.Search(words, MaxResults, partialMatches, titleOnly)) - { - dtResult = curFile.FullTextSearchEngine.Hits; - dtResult.DefaultView.Sort = "Rating DESC"; - } - } - } - else - { - if(curFile.FullTextSearchEngine.CanSearch) - { - if(curFile.FullTextSearchEngine.Search(words, MaxResults, partialMatches, titleOnly)) - { - DataTable table = curFile.FullTextSearchEngine.Hits; - - // append rows from 2nd file - foreach(DataRow curRow in table.Rows) - { - dtResult.ImportRow( curRow ); - } - - dtResult.DefaultView.Sort = "Rating DESC"; - - // adjust max hits - if(MaxResults >= 0) - { - if(dtResult.DefaultView.Count > MaxResults) - { - for(int i=MaxResults-1; i 0) { - output.Append (GetChars (bytes, e)); - bytes.SetLength (0); - } - output.Append ((char) Int32.Parse (s.Substring (i + 2, 4), hexa)); - i += 5; - } else { - bytes.WriteByte ((byte) Int32.Parse (s.Substring (i + 1, 2), hexa)); - i += 2; - } - continue; - } - - if (bytes.Length > 0) { - output.Append (GetChars (bytes, e)); - bytes.SetLength (0); - } - - if (s [i] == '+') { - output.Append (' '); - } else { - output.Append (s [i]); - } - } - - if (bytes.Length > 0) { - output.Append (GetChars (bytes, e)); - } - - bytes = null; - return output.ToString (); - } - - public static string UrlDecode (byte [] bytes, Encoding e) - { - if (bytes == null) - return null; - - return UrlDecode (bytes, 0, bytes.Length, e); - } - - private static int GetInt (byte b) - { - char c = Char.ToUpper ((char) b); - if (c >= '0' && c <= '9') - return c - '0'; - - if (c < 'A' || c > 'F') - return 0; - - return (c - 'A' + 10); - } - - private static char GetChar (byte [] bytes, int offset, int length) - { - int value = 0; - int end = length + offset; - for (int i = offset; i < end; i++) - value = (value << 4) + GetInt (bytes [offset]); - - return (char) value; - } - - public static string UrlDecode (byte [] bytes, int offset, int count, Encoding e) - { - if (bytes == null || count == 0) - return null; - - if (bytes == null) - throw new ArgumentNullException ("bytes"); - - if (offset < 0 || offset > bytes.Length) - throw new ArgumentOutOfRangeException ("offset"); - - if (count < 0 || offset + count > bytes.Length) - throw new ArgumentOutOfRangeException ("count"); - - StringBuilder output = new StringBuilder (); - MemoryStream acc = new MemoryStream (); - - int end = count + offset; - for (int i = offset; i < end; i++) { - if (bytes [i] == '%' && i + 2 < count) { - if (bytes [i + 1] == (byte) 'u' && i + 5 < end) { - if (acc.Length > 0) { - output.Append (GetChars (acc, e)); - acc.SetLength (0); - } - output.Append (GetChar (bytes, offset + 2, 4)); - i += 5; - } else { - acc.WriteByte ((byte) GetChar (bytes, offset + 1, 2)); - i += 2; - } - continue; - } - - if (acc.Length > 0) { - output.Append (GetChars (acc, e)); - acc.SetLength (0); - } - - if (bytes [i] == '+') { - output.Append (' '); - } else { - output.Append ((char) bytes [i]); - } - } - - if (acc.Length > 0) { - output.Append (GetChars (acc, e)); - } - - acc = null; - return output.ToString (); - } - - public static byte [] UrlDecodeToBytes (byte [] bytes) - { - if (bytes == null) - return null; - - return UrlDecodeToBytes (bytes, 0, bytes.Length); - } - - public static byte [] UrlDecodeToBytes (string str) - { - return UrlDecodeToBytes (str, Encoding.UTF8); - } - - public static byte [] UrlDecodeToBytes (string str, Encoding e) - { - if (str == null) - return null; - - if (e == null) - throw new ArgumentNullException ("e"); - - return UrlDecodeToBytes (e.GetBytes (str)); - } - - public static byte [] UrlDecodeToBytes (byte [] bytes, int offset, int count) - { - if (bytes == null) - return null; - - int len = bytes.Length; - if (offset < 0 || offset >= len) - throw new ArgumentOutOfRangeException("offset"); - - if (count < 0 || offset > len - count) - throw new ArgumentOutOfRangeException("count"); - - MemoryStream result = new MemoryStream (); - int end = offset + count; - for (int i = offset; i < end; i++){ - char c = (char) bytes [i]; - if (c == '+') - c = ' '; - else if (c == '%' && i < end - 2) { - c = GetChar (bytes, i, 2); - i += 2; - } - result.WriteByte ((byte) c); - } - - return result.ToArray (); - } - - public static string UrlEncode(string str) - { - return UrlEncode(str, Encoding.UTF8); - } - - public static string UrlEncode (string s, Encoding Enc) - { - if (s == null) - return null; - - if (s == "") - return ""; - - byte [] bytes = Enc.GetBytes (s); - byte [] b =UrlEncodeToBytes (bytes, 0, bytes.Length); - return Encoding.ASCII.GetString (b,0,b.Length); - } - - public static string UrlEncode (byte [] bytes) - { - if (bytes == null) - return null; - - if (bytes.Length == 0) - return ""; - - byte []b=UrlEncodeToBytes(bytes, 0, bytes.Length); - return Encoding.ASCII.GetString (b,0,b.Length); - } - - public static string UrlEncode (byte [] bytes, int offset, int count) - { - if (bytes == null) - return null; - - if (bytes.Length == 0) - return ""; - - byte []b=UrlEncodeToBytes(bytes, offset, count); - return Encoding.ASCII.GetString (b,0,b.Length); - } - - public static byte [] UrlEncodeToBytes (string str) - { - return UrlEncodeToBytes (str, Encoding.UTF8); - } - - public static byte [] UrlEncodeToBytes (string str, Encoding e) - { - if (str == null) - return null; - - if (str == "") - return new byte [0]; - - byte [] bytes = e.GetBytes (str); - return UrlEncodeToBytes (bytes, 0, bytes.Length); - } - - public static byte [] UrlEncodeToBytes (byte [] bytes) - { - if (bytes == null) - return null; - - if (bytes.Length == 0) - return new byte [0]; - - return UrlEncodeToBytes (bytes, 0, bytes.Length); - } - - static char [] hexChars = "0123456789abcdef".ToCharArray (); - - public static byte [] UrlEncodeToBytes (byte [] bytes, int offset, int count) - { - if (bytes == null) - return null; - - int len = bytes.Length; - if (len == 0) - return new byte [0]; - - if (offset < 0 || offset >= len) - throw new ArgumentOutOfRangeException("offset"); - - if (count < 0 || count > len - offset) - throw new ArgumentOutOfRangeException("count"); - - MemoryStream result = new MemoryStream (); - int end = offset + count; - for (int i = offset; i < end; i++) { - char c = (char) bytes [i]; - if ((c == ' ') || (c < '0' && c != '-' && c != '.') || - (c < 'A' && c > '9') || - (c > 'Z' && c < 'a' && c != '_') || - (c > 'z')) { - result.WriteByte ((byte) '%'); - int idx = ((int) c) >> 4; - result.WriteByte ((byte) hexChars [idx]); - idx = ((int) c) & 0x0F; - result.WriteByte ((byte) hexChars [idx]); - } else { - result.WriteByte ((byte) c); - } - } - - return result.ToArray (); - } - - public static string UrlEncodeUnicode (string str) - { - if (str == null) - return null; - - StringBuilder result = new StringBuilder (); - int end = str.Length; - for (int i = 0; i < end; i++) { - int idx; - char c = str [i]; - if (c > 255) { - result.Append ("%u"); - idx = ((int) c) >> 24; - result.Append (hexChars [idx]); - idx = (((int) c) >> 16) & 0x0F; - result.Append (hexChars [idx]); - idx = (((int) c) >> 8) & 0x0F; - result.Append (hexChars [idx]); - idx = ((int) c) & 0x0F; - result.Append (hexChars [idx]); - continue; - } - - if ((c == ' ') || (c < '0' && c != '-' && c != '.') || - (c < 'A' && c > '9') || - (c > 'Z' && c < 'a' && c != '_') || - (c > 'z')) { - result.Append ('%'); - idx = ((int) c) >> 4; - result.Append (hexChars [idx]); - idx = ((int) c) & 0x0F; - result.Append (hexChars [idx]); - continue; - } - - result.Append (c); - } - - return result.ToString (); - } - - public static byte [] UrlEncodeUnicodeToBytes (string str) - { - if (str == null) - return null; - - if (str == "") - return new byte [0]; - - return Encoding.ASCII.GetBytes (UrlEncodeUnicode (str)); - } - - /// - /// Decodes an HTML-encoded string and returns the decoded string. - /// - /// The HTML string to decode. - /// The decoded text. - public static string HtmlDecode (string s) - { - if (s == null) - throw new ArgumentNullException ("s"); - - if (s.IndexOf ('&') == -1) - return s; - - bool insideEntity = false; // used to indicate that we are in a potential entity - string entity = String.Empty; - StringBuilder output = new StringBuilder (); - int len = s.Length; - - for (int i = 0; i < len; i++) { - char c = s [i]; - switch (c) { - case '&' : - output.Append (entity); - entity = "&"; - insideEntity = true; - break; - case ';' : - if (!insideEntity) { - output.Append (c); - break; - } - - entity += c; - int length = entity.Length; - if (length >= 2 && entity[1] == '#' && entity[2] != ';') - entity = ((char) Int32.Parse (entity.Substring (2, entity.Length - 3))).ToString(); - else if (length > 1 && Entities.ContainsKey (entity.Substring (1, entity.Length - 2))) - entity = Entities [entity.Substring (1, entity.Length - 2)].ToString (); - - output.Append (entity); - entity = String.Empty; - insideEntity = false; - break; - default : - if (insideEntity) - entity += c; - else - output.Append (c); - break; - } - } - output.Append (entity); - return output.ToString (); - } - - /// - /// Decodes an HTML-encoded string and sends the resulting output to a TextWriter output stream. - /// - /// The HTML string to decode - /// The TextWriter output stream containing the decoded string. - public static void HtmlDecode(string s, TextWriter output) - { - if (s != null) - output.Write (HtmlDecode (s)); - } - - /// - /// HTML-encodes a string and returns the encoded string. - /// - /// The text string to encode. - /// The HTML-encoded text. - public static string HtmlEncode (string s) - { - if (s == null) - return null; - - StringBuilder output = new StringBuilder (); - - foreach (char c in s) - switch (c) { - case '&' : - output.Append ("&"); - break; - case '>' : - output.Append (">"); - break; - case '<' : - output.Append ("<"); - break; - case '"' : - output.Append ("""); - break; - default: - if ((int) c > 128) { - output.Append ("&#"); - output.Append (((int) c).ToString ()); - output.Append (";"); - } - else - output.Append (c); - break; - } - return output.ToString (); - } - - /// - /// HTML-encodes a string and sends the resulting output to a TextWriter output stream. - /// - /// The string to encode. - /// The TextWriter output stream containing the encoded string. - public static void HtmlEncode(string s, TextWriter output) - { - if (s != null) - output.Write (HtmlEncode (s)); - } - -#if NET_1_1 - public string UrlPathEncode (string s) - { - if (s == null) - return null; - - int idx = s.IndexOf ("?"); - string s2 = null; - if (idx != -1) { - s2 = s.Substring (0, idx-1); - s2 = UrlEncode (s2) + s.Substring (idx); - } else { - s2 = UrlEncode (s); - } - - return s2; - } -#endif - #endregion // Methods - } -} diff --git a/irc/TechBot/CHMLibrary/Index.cs b/irc/TechBot/CHMLibrary/Index.cs deleted file mode 100644 index 76f73013f0d..00000000000 --- a/irc/TechBot/CHMLibrary/Index.cs +++ /dev/null @@ -1,322 +0,0 @@ -using System; -using System.Diagnostics; -using System.Collections; -using HtmlHelp.ChmDecoding; - -namespace HtmlHelp -{ - /// - /// Enumeration for specifying the index type - /// - public enum IndexType - { - /// - /// Keyword links should be used - /// - KeywordLinks = 0, - /// - /// Associative links should be used - /// - AssiciativeLinks = 1 - } - - /// - /// The class Index holds the (keyword links) KLinks and (associative links) ALinks of the htmlhelp - /// system. It implements methods for easy index-based searching. - /// - public class Index - { - private ArrayList _kLinks = new ArrayList(); - private ArrayList _aLinks = new ArrayList(); - - /// - /// Standard constructor - /// - public Index() - { - } - - /// - /// Constructor of the class - /// - /// arraylist with keyword links - /// arraylist with associative links - public Index(ArrayList kLinks, ArrayList aLinks) - { - _kLinks= kLinks; - _aLinks = aLinks; - } - - /// - /// Clears the current toc - /// - public void Clear() - { - if(_aLinks != null) - _aLinks.Clear(); - if(_kLinks != null) - _kLinks.Clear(); - } - - /// - /// Gets the number of index items for a specific type - /// - /// type of index - /// Returns the number of index items for a specific type - public int Count(IndexType typeOfIndex) - { - ArrayList _index = null; - - switch( typeOfIndex ) - { - case IndexType.AssiciativeLinks: _index = _aLinks; break; - case IndexType.KeywordLinks: _index = _kLinks; break; - } - - if(_index != null) - return _index.Count; - - return 0; - } - - /// - /// Gets the internal index list of keyword links - /// - public ArrayList KLinks - { - get - { - if(_kLinks==null) - _kLinks = new ArrayList(); - - return _kLinks; - } - } - - /// - /// Gets the internal index list of associative links - /// - public ArrayList ALinks - { - get - { - if(_aLinks==null) - _aLinks = new ArrayList(); - - return _aLinks; - } - } - - /// - /// Merges the the index list arrIndex into the current one - /// - /// indexlist which should be merged with the current one - /// type of index to merge - public void MergeIndex( ArrayList arrIndex, IndexType typeOfIndex ) - { - ArrayList _index = null; - - switch(typeOfIndex) - { - case IndexType.AssiciativeLinks: _index = _aLinks;break; - case IndexType.KeywordLinks: _index = _kLinks;break; - } - - foreach(IndexItem curItem in arrIndex) - { - //IndexItem searchItem = ContainsIndex(_index, curItem.KeyWordPath); - int insertIndex=0; - IndexItem searchItem = BinSearch(0, _index.Count-1, _index, curItem.KeyWordPath, false, false, ref insertIndex); - - if(searchItem != null) - { - // extend the keywords topics - foreach(IndexTopic curEntry in curItem.Topics) - { - searchItem.Topics.Add( curEntry ); - } - } - else - { - // add the item to the global collection - //_index.Add( curItem ); - - if(insertIndex > _index.Count) - _index.Add(curItem); - else - _index.Insert(insertIndex, curItem); - } - } - } - - /// - /// Searches an index entry using recursive binary search algo (divide and conquer). - /// - /// start index for searching - /// end index for searching - /// arraylist containing sorted IndexItem entries - /// keyword path to search - /// true if the keywordPath will only contain the keyword not the complete path - /// True if case should be ignored - /// out reference. will receive the index where the item with the - /// keywordPath should be inserted if not found (receives -1 if the item was found) - /// Returns an IndexItem instance if found, otherwise null - /// (use insertIndex for inserting the new item in a sorted order) - private IndexItem BinSearch(int nStart, int nEnd, ArrayList arrIndex, string keywordPath, - bool searchKeyword, bool caseInsensitive, ref int insertIndex) - { - if( arrIndex.Count <= 0 ) - { - insertIndex=0; - return null; - } - - if(caseInsensitive) - keywordPath = keywordPath.ToLower(); - - if( (nEnd - nStart) > 1) - { - int nCheck = nStart + (nEnd-nStart)/2; - - IndexItem iC = arrIndex[nCheck] as IndexItem; - - string sCompare = iC.KeyWordPath; - - if(searchKeyword) - sCompare = iC.KeyWord; - - if(caseInsensitive) - sCompare = sCompare.ToLower(); - - if( sCompare == keywordPath ) - { - insertIndex=-1; - return iC; - } - - if( keywordPath.CompareTo(sCompare) < 0 ) - { - return BinSearch(nStart, nCheck-1, arrIndex, keywordPath, searchKeyword, caseInsensitive, ref insertIndex); - } - - if( keywordPath.CompareTo(sCompare) > 0 ) - { - return BinSearch(nCheck+1, nEnd, arrIndex, keywordPath, searchKeyword, caseInsensitive, ref insertIndex); - } - } - else if(nEnd-nStart == 1) - { - IndexItem i1 = arrIndex[nStart] as IndexItem; - IndexItem i2 = arrIndex[nEnd] as IndexItem; - - string sCompare1 = i1.KeyWordPath; - - if(searchKeyword) - sCompare1 = i1.KeyWord; - - if(caseInsensitive) - sCompare1 = sCompare1.ToLower(); - - string sCompare2 = i2.KeyWordPath; - - if(searchKeyword) - sCompare2 = i2.KeyWord; - - if(caseInsensitive) - sCompare2 = sCompare2.ToLower(); - - if( sCompare1 == keywordPath) - { - insertIndex = -1; - return i1; - } - - if( sCompare2 == keywordPath) - { - insertIndex = -1; - return i2; - } - - if( sCompare1.CompareTo(keywordPath) > 0) - { - insertIndex = nStart; - return null; - } - else if( sCompare2.CompareTo(keywordPath) > 0) - { - insertIndex = nEnd; - return null; - } - else - { - insertIndex = nEnd+1; - } - } - - IndexItem itm = arrIndex[nEnd] as IndexItem; - - string sCompareI = itm.KeyWordPath; - - if(searchKeyword) - sCompareI = itm.KeyWord; - - if(caseInsensitive) - sCompareI = sCompareI.ToLower(); - - if( sCompareI.CompareTo(keywordPath) > 0) - { - insertIndex = nStart; - return null; - } - else if( sCompareI.CompareTo(keywordPath) < 0) - { - insertIndex = nEnd+1; - return null; - } - else - { - insertIndex = -1; - return arrIndex[nEnd] as IndexItem; - } - } - - /// - /// Checks if a keyword exists in a index collection - /// - /// index to search (arraylist of IndexItems) - /// keywordpath to search - /// Returns the found IndexItem, otherwise null - private IndexItem ContainsIndex(ArrayList arrIndex, string keywordPath) - { - foreach(IndexItem curItem in arrIndex) - { - if(curItem.KeyWordPath == keywordPath) - return curItem; - } - - return null; - } - - /// - /// Searches the alinks- or klinks-index for a specific keyword/associative - /// - /// keyword/associative to search - /// type of index to search - /// Returns an ArrayList which contains IndexTopic items or null if nothing was found - public IndexItem SearchIndex(string search, IndexType typeOfIndex) - { - ArrayList _index = null; - - switch( typeOfIndex ) - { - case IndexType.AssiciativeLinks: _index = _aLinks;break; - case IndexType.KeywordLinks: _index = _kLinks;break; - } - - int insertIdx=0; - IndexItem foundItem = BinSearch(0, _index.Count, _index, search, true, true, ref insertIdx); - - return foundItem; - } - } -} diff --git a/irc/TechBot/CHMLibrary/IndexItem.cs b/irc/TechBot/CHMLibrary/IndexItem.cs deleted file mode 100644 index a21415880cd..00000000000 --- a/irc/TechBot/CHMLibrary/IndexItem.cs +++ /dev/null @@ -1,396 +0,0 @@ -using System; -using System.IO; -using System.Text; -using System.Collections; - -using HtmlHelp.ChmDecoding; - -namespace HtmlHelp -{ - /// - /// The class IndexItem implements an help-index item - /// - public sealed class IndexItem : IComparable - { - /// - /// Internal member storing the keyword - /// - private string _keyWord = ""; - /// - /// Internal member storing all associated information type strings - /// - private ArrayList _infoTypeStrings = new ArrayList(); - /// - /// Internal member storing the flag if this is a see-also keyword - /// - private bool _isSeeAlso = false; - /// - /// Internal member storing the indent of the keyword - /// - private int _indent = 0; - /// - /// Internal member storing the last index of the keyword in the seperated list - /// - private int _charIndex = 0; - /// - /// Internal member storing the entry index - /// - private int _entryIndex = 0; - /// - /// Internal member storing an array of see-also values - /// - private string[] _seeAlso = new string[0]; - /// - /// Internal member storing an array of topic offsets - /// - private int[] _nTopics = new int[0]; - /// - /// Internal member storing the topics - /// - private ArrayList _Topics = null; - /// - /// Associated CHMFile instance - /// - private CHMFile _chmFile = null; - /// - /// Internal flag specifying the chm file path - /// - private string _chmFileName = ""; - - /// - /// Constructor of the class - /// - /// associated CHMFile instance - /// keyword - /// true if it is a see-also keyword - /// indent of the entry - /// char index of the last keyword in the separated list - /// index of the entry - /// string array with see-also values - /// integer array with topic offsets - internal IndexItem(CHMFile chmFile, string keyWord, bool isSeeAlso, int indent, int charIndex, int entryIndex, string[] seeAlsoValues, int[] topicOffsets) - { - _chmFile = chmFile; - _chmFileName = _chmFile.ChmFilePath; - _keyWord = keyWord; - _isSeeAlso = isSeeAlso; - _indent = indent; - _charIndex = charIndex; - _entryIndex = entryIndex; - _seeAlso = seeAlsoValues; - _nTopics = topicOffsets; - } - - /// - /// Standard constructor - /// - public IndexItem() - { - } - - #region Data dumping - /// - /// Dump the class data to a binary writer - /// - /// writer to write the data - /// true if the chm filename should be written - internal void Dump(ref BinaryWriter writer, bool writeFileName) - { - int i=0; - - writer.Write(_keyWord); - writer.Write(_isSeeAlso); - writer.Write(_indent); - - if(writeFileName) - writer.Write(_chmFileName); - - writer.Write(_infoTypeStrings.Count); - - for(i=0; i<_infoTypeStrings.Count; i++) - writer.Write( (_infoTypeStrings[i]).ToString() ); - - writer.Write(_seeAlso.Length); - - for(i=0; i<_seeAlso.Length; i++) - { - if(_seeAlso[i] == null) - writer.Write(""); - else - writer.Write( _seeAlso[i] ); - } - - writer.Write(Topics.Count); - - for(i=0; i - /// Dump the class data to a binary writer - /// - /// writer to write the data - internal void Dump(ref BinaryWriter writer) - { - Dump(ref writer, false); - } - - /// - /// Reads the object data from a dump store - /// - /// reader to read the data - /// filelist from helpsystem - internal bool ReadDump(ref BinaryReader reader, ArrayList filesList) - { - int i=0; - _keyWord = reader.ReadString(); - _isSeeAlso = reader.ReadBoolean(); - _indent = reader.ReadInt32(); - _chmFileName = reader.ReadString(); - - foreach(CHMFile curFile in filesList) - { - if(curFile.ChmFilePath == _chmFileName) - { - _chmFile = curFile; - break; - } - } - - if(_chmFile==null) - return false; - - int nCnt = reader.ReadInt32(); - - for(i=0; i - /// Reads the object data from a dump store - /// - /// reader to read the data - internal void ReadDump(ref BinaryReader reader) - { - int i=0; - _keyWord = reader.ReadString(); - _isSeeAlso = reader.ReadBoolean(); - _indent = reader.ReadInt32(); - - int nCnt = reader.ReadInt32(); - - for(i=0; i - /// Implements the compareto method which allows sorting. - /// - /// object to compare to - /// See IComparable.CompareTo() - public int CompareTo(object obj) - { - if( obj.GetType() == this.GetType() ) - { - IndexItem cmp = (IndexItem)obj; - - return this.KeyWordPath.CompareTo( cmp.KeyWordPath ); - } - - return 0; - } - - /// - /// Gets/Sets the associated CHMFile instance - /// - internal CHMFile ChmFile - { - get { return _chmFile; } - set { _chmFile = value; } - } - - /// - /// Gets the ArrayList which holds all information types/categories this item is associated - /// - internal ArrayList InfoTypeStrings - { - get { return _infoTypeStrings; } - } - - /// - /// Adds a see-also string to the index item and marks it as see also item - /// - /// see also string to add - internal void AddSeeAlso(string seeAlsoString) - { - string[] seeAlso = new string[ _seeAlso.Length +1 ]; - for(int i=0; i<_seeAlso.Length; i++) - seeAlso[i] = _seeAlso[i]; - - seeAlso[_seeAlso.Length] = seeAlsoString; - _seeAlso = seeAlso; - _isSeeAlso = true; - } - - /// - /// Gets/Sets the full keyword-path of this item ( ", " separated list) - /// - public string KeyWordPath - { - get { return _keyWord; } - set { _keyWord = value; } - } - - /// - /// Gets the keyword of this item - /// - public string KeyWord - { - get - { - return _keyWord.Substring(_charIndex, _keyWord.Length-_charIndex); - } - } - - /// - /// Gets the keyword of this item with prefixing indent spaces - /// - public string IndentKeyWord - { - get - { - string sKW = this.KeyWord; - StringBuilder sb = new StringBuilder("",this.Indent*3 + sKW.Length); - for(int i=0; i - /// Gets/Sets the see-also flag of this item - /// - public bool IsSeeAlso - { - get { return _isSeeAlso; } - set { _isSeeAlso = value; } - } - - /// - /// Gets/Sets the listbox indent for this item - /// - public int Indent - { - get { return _indent; } - set { _indent = value; } - } - - /// - /// Gets/Sets the character index of an indent keyword - /// - public int CharIndex - { - get { return _charIndex; } - set { _charIndex = value; } - } - - /// - /// Gets the see-also values of this item - /// - public string[] SeeAlso - { - get { return _seeAlso; } - } - - /// - /// Gets an array with the associated topics - /// - public ArrayList Topics - { - get - { - if( _Topics == null ) - { - if(IsSeeAlso) - { - _Topics = new ArrayList(); - } - else - { - if( (_chmFile != null) && (_chmFile.TopicsFile != null) ) - { - _Topics = new ArrayList(); - - for(int i=0; i<_nTopics.Length; i++) - { - IndexTopic newTopic = IndexTopic.FromTopicEntry((TopicEntry)_chmFile.TopicsFile.TopicTable[ _nTopics[i] ]); - newTopic.AssociatedFile = _chmFile; - _Topics.Add( newTopic ); - } - } - else - { - _Topics = new ArrayList(); - } - } - } - - return _Topics; - } - } - } -} diff --git a/irc/TechBot/CHMLibrary/IndexTopic.cs b/irc/TechBot/CHMLibrary/IndexTopic.cs deleted file mode 100644 index 07c8f66d022..00000000000 --- a/irc/TechBot/CHMLibrary/IndexTopic.cs +++ /dev/null @@ -1,216 +0,0 @@ -using System; -using System.IO; - -using HtmlHelp.ChmDecoding; - -namespace HtmlHelp -{ - /// - /// The class IndexTopic implements an entry for the IndexItem topics list. - /// - public sealed class IndexTopic - { - private DataMode _topicMode = DataMode.TextBased; - private string _title=""; - private string _local=""; - private string _compileFile = ""; - private string _chmPath = ""; - private int _topicOffset = -1; - private CHMFile _associatedFile = null; - - /// - /// Creates a new instance of the class based on an existing TopicEntry - /// - /// - internal static IndexTopic FromTopicEntry(TopicEntry entry) - { - return new IndexTopic(entry.EntryOffset, entry.ChmFile); - //return new IndexTopic( entry.Title, entry.Locale, entry.ChmFile.CompileFile, entry.ChmFile.ChmFilePath); - } - - /// - /// Creates a new instance of the class (binary extraction mode) - /// - /// offset of the topic entry - /// associated CHMFile instance - internal IndexTopic(int topicOffset, CHMFile associatedFile) - { - _topicMode = DataMode.Binary; - _topicOffset = topicOffset; - _associatedFile = associatedFile; - } - - /// - /// Constructor of the class - /// - /// topic title - /// topic local (content filename) - /// name of the chm file (location of topic) - /// path of the chm file - public IndexTopic(string Title, string local, string compilefile, string chmpath) - { - _topicMode = DataMode.TextBased; - _title = Title; - _local = local; - _compileFile = compilefile; - _chmPath = chmpath; - } - - #region Data dumping - /// - /// Dump the class data to a binary writer - /// - /// writer to write the data - internal void Dump(ref BinaryWriter writer) - { - writer.Write((int)_topicMode); - - if(_topicMode==DataMode.TextBased) - { - writer.Write(_title); - writer.Write(_local); - } - else - { - writer.Write(_topicOffset); - } - } - - /// - /// Reads the object data from a dump store - /// - /// reader to read the data - internal void ReadDump(ref BinaryReader reader) - { - _topicMode = (DataMode)reader.ReadInt32(); - - if(_topicMode==DataMode.TextBased) - { - _title = reader.ReadString(); - _local = reader.ReadString(); - } - else - { - _topicOffset = reader.ReadInt32(); - } - } - #endregion - - /// - /// Internally used to set the chm-finos when reading from dump store - /// - /// - /// - internal void SetChmInfo(string compilefile, string chmpath) - { - _compileFile = compilefile; - _chmPath = chmpath; - } - - /// - /// Gets/Sets the associated CHMFile instance - /// - internal CHMFile AssociatedFile - { - get { return _associatedFile; } - set { _associatedFile = value; } - } - - /// - /// Gets the topic title - /// - public string Title - { - get - { - if((_topicMode == DataMode.Binary )&&(_associatedFile!=null)) - { - if( _topicOffset >= 0) - { - TopicEntry te = (TopicEntry) (_associatedFile.TopicsFile[_topicOffset]); - if(te != null) - { - return te.Title; - } - } - } - - return _title; - } - } - - /// - /// Gets the local (content filename) - /// - public string Local - { - get - { - if((_topicMode == DataMode.Binary )&&(_associatedFile!=null)) - { - if( _topicOffset >= 0) - { - TopicEntry te = (TopicEntry) (_associatedFile.TopicsFile[_topicOffset]); - if(te != null) - { - return te.Locale; - } - } - } - - return _local; - } - } - - /// - /// Gets the compile file (location) - /// - public string CompileFile - { - get - { - if(_associatedFile != null) - return _associatedFile.CompileFile; - - return _compileFile; - } - } - - /// - /// Gets the chm file path - /// - public string ChmFilePath - { - get - { - if(_associatedFile != null) - return _associatedFile.ChmFilePath; - - return _chmPath; - } - } - - /// - /// Gets the url - /// - public string URL - { - get - { - string sL = Local; - - if(sL.Length<=0) - return "";//"about:blank"; - - if( (sL.ToLower().IndexOf("http://") >= 0) || - (sL.ToLower().IndexOf("https://") >= 0) || - (sL.ToLower().IndexOf("mailto:") >= 0) || - (sL.ToLower().IndexOf("ftp://") >= 0) || - (sL.ToLower().IndexOf("ms-its:") >= 0)) - return sL; - - return HtmlHelpSystem.UrlPrefix + ChmFilePath + "::/" + sL; - } - } - } -} diff --git a/irc/TechBot/CHMLibrary/InformationType.cs b/irc/TechBot/CHMLibrary/InformationType.cs deleted file mode 100644 index 7f23e5c4abc..00000000000 --- a/irc/TechBot/CHMLibrary/InformationType.cs +++ /dev/null @@ -1,146 +0,0 @@ -using System; -using System.IO; - -namespace HtmlHelp -{ - /// - /// Enumeration for specifying the mode of the information type - /// - public enum InformationTypeMode - { - /// - /// Inclusive information type. The user will be allowed to select from one or more information types. - /// - Inclusive = 0, - /// - /// Exclusive information type. The user will be allowed to choose only one information type within each category - /// - Exclusive = 1, - /// - /// Hidden information type. The user cannot see this information types (only for API calls). - /// - Hidden = 2 - } - - /// - /// The class InformationType implements a methods/properties for an information type. - /// - /// Note: Information types and categories allow users to filter help contents. - /// They are only supported if using sitemap TOC and/or sitemap Index. - public class InformationType - { - private string _name = ""; - private string _description = ""; - private InformationTypeMode _typeMode = InformationTypeMode.Inclusive; - private bool _isInCategory = false; - private int _referenceCount = 1; - - /// - /// Standard constructor - /// - /// the mode is set to InformationTypeMode.Inclusive by default - public InformationType() : this("","") - { - } - - /// - /// Standard constructor - /// - /// name of the information type - /// description - /// the mode is set to InformationTypeMode.Inclusive by default - public InformationType(string name, string description) : this(name, description, InformationTypeMode.Inclusive) - { - } - - /// - /// Standard constructor - /// - /// name of the information type - /// description - /// mode of the information type - public InformationType(string name, string description, InformationTypeMode mode) - { - _name = name; - _description = description; - _typeMode = mode; - } - - #region Data dumping - /// - /// Dump the class data to a binary writer - /// - /// writer to write the data - internal void Dump(ref BinaryWriter writer) - { - writer.Write( (int)_typeMode ); - writer.Write( _name ); - writer.Write( _description ); - } - - /// - /// Reads the object data from a dump store - /// - /// reader to read the data - internal void ReadDump(ref BinaryReader reader) - { - _typeMode = (InformationTypeMode)reader.ReadInt32(); - _name = reader.ReadString(); - _description = reader.ReadString(); - } - #endregion - - /// - /// Sets the flag if this information type is nested in at least one category - /// - /// true or false - internal void SetCategoryFlag(bool newValue) - { - _isInCategory = newValue; - } - - /// - /// Gets/Sets the reference count of this information type instance - /// - internal int ReferenceCount - { - get { return _referenceCount; } - set { _referenceCount = value; } - } - - /// - /// Gets true if this information type is nested in at least one category - /// - public bool IsInCategory - { - get { return _isInCategory; } - } - - /// - /// Gets/Sets the name of the information type - /// - public string Name - { - get { return _name; } - set { _name = value; } - } - - /// - /// Gets/Sets the description of the information type - /// - public string Description - { - get { return _description; } - set { _name = value; } - } - - /// - /// Gets/Sets the mode of the information type - /// - public InformationTypeMode Mode - { - get { return _typeMode; } - set { _typeMode = value; } - } - } -} diff --git a/irc/TechBot/CHMLibrary/Storage/CHMStream.cs b/irc/TechBot/CHMLibrary/Storage/CHMStream.cs deleted file mode 100644 index 8eab65942a4..00000000000 --- a/irc/TechBot/CHMLibrary/Storage/CHMStream.cs +++ /dev/null @@ -1,2842 +0,0 @@ -using System; -using System.Diagnostics; -using System.Text; -using System.Data; -using System.Text.RegularExpressions; -using System.Collections; -using System.Collections.Specialized; -using System.IO; -using System.Runtime.InteropServices; - -namespace CHMStream -{ - /// - /// Summary description for CHMFile. - /// - /// - public class CHMStream : IDisposable - { - public MemoryStream OpenStream(chmUnitInfo Info) - { - if (Info==null) - return null; - - MemoryStream st=new MemoryStream(); - this.ExtractFile(Info,st); - return st; - } - - public MemoryStream OpenStream(string FileName) - { - chmUnitInfo info=this.GetFileInfo(FileName); - if (info==null) - return null; - return OpenStream(info); - } - - private string m_CHMFileName; - public string CHMFileName - { - get - { - return m_CHMFileName; - } - } - - public CHMStream() - { - } - - public CHMStream(string CHMFileName) - { - OpenCHM(CHMFileName); - } - - public void OpenCHM(string CHMFileName) - { - m_CHMFileName=CHMFileName; - FileInfo fi=new FileInfo(m_CHMFileName); - Dir=fi.DirectoryName; - m_CHMName=fi.Name; - fi=null; - chm_open(m_CHMFileName); - } - - private bool m_bCHMLoaded=false; - public bool CHMLoaded - { - get - { - return m_bCHMLoaded; - } - } - - private string m_CHMName=""; - public string CHMName - { - get - { - return m_CHMName; - } - } - - private string Dir=""; - private string m_FileFind=""; - private string m_FileFindLastPart=""; - private chmUnitInfo m_FileInfo=null; - private int m_FileCount=0; - public void FindFile(chmUnitInfo Info, ref CHMStream.CHM_ENUMERATOR Status) - { - string LocalFile=Info.path; - LocalFile=LocalFile.Replace("/",@"\"); - if (!LocalFile.StartsWith(@"\")) - LocalFile=@"\"+LocalFile; - LocalFile=LocalFile.ToLower(); - - if (m_FileFind.Length<=LocalFile.Length) - { - if (LocalFile.IndexOf(m_FileFind)==LocalFile.Length-m_FileFind.Length) - { - Status=CHMStream.CHM_ENUMERATOR.CHM_ENUMERATOR_SUCCESS; - m_FileInfo=Info; - return; - } - } - Status=CHMStream.CHM_ENUMERATOR.CHM_ENUMERATOR_CONTINUE; - } - - public void FileCount(chmUnitInfo Info, ref CHMStream.CHM_ENUMERATOR Status) - { - m_FileCount++; - Status=CHMStream.CHM_ENUMERATOR.CHM_ENUMERATOR_CONTINUE; - } - - private ArrayList m_FileList=null; - private string m_strByExt=""; - public void FileList(chmUnitInfo Info, ref CHMStream.CHM_ENUMERATOR Status) - { - m_FileList.Add(Info.path); - Status=CHMStream.CHM_ENUMERATOR.CHM_ENUMERATOR_CONTINUE; - } - - public void FileListByExtension(chmUnitInfo Info, ref CHMStream.CHM_ENUMERATOR Status) - { - FileInfo fi=new FileInfo(Info.path); - if (fi.Extension.ToLower()==m_strByExt.ToLower()) - m_FileList.Add(Info.path); - Status=CHMStream.CHM_ENUMERATOR.CHM_ENUMERATOR_CONTINUE; - } - - public void FindFileIndex(chmUnitInfo Info, ref CHMStream.CHM_ENUMERATOR Status) - { - if (m_FileCount==m_FileFindIndex) - { - m_FileInfo=Info; - Status=CHMStream.CHM_ENUMERATOR.CHM_ENUMERATOR_SUCCESS; - } - else - { - m_FileCount++; - Status=CHMStream.CHM_ENUMERATOR.CHM_ENUMERATOR_CONTINUE; - } - } - - public int GetFileCount() - { - if (!m_bCHMLoaded) - return 0; - - m_FileCount=0; - this.CHMFileFoundEvent+=new CHMStream.CHMFileFound(FileCount); - this.chm_enumerate(CHM_ENUMERATE.CHM_ENUMERATE_ALL); - this.CHMFileFoundEvent-=new CHMStream.CHMFileFound(FileCount); - return m_FileCount; - } - - public ArrayList GetFileList() - { - if (!m_bCHMLoaded) - return null; - - m_FileList=null; - m_FileList=new ArrayList(1000); - this.CHMFileFoundEvent+=new CHMStream.CHMFileFound(FileList); - this.chm_enumerate(CHM_ENUMERATE.CHM_ENUMERATE_ALL); - this.CHMFileFoundEvent-=new CHMStream.CHMFileFound(FileList); - return m_FileList; - } - - public ArrayList GetFileListByExtenstion(string Ext) - { - if (!m_bCHMLoaded) - return null; - - m_FileList=null; - m_FileList=new ArrayList(1000); - m_strByExt=Ext; - this.CHMFileFoundEvent+=new CHMStream.CHMFileFound(FileListByExtension); - this.chm_enumerate(CHM_ENUMERATE.CHM_ENUMERATE_ALL); - this.CHMFileFoundEvent-=new CHMStream.CHMFileFound(FileListByExtension); - return m_FileList; - } - - public chmUnitInfo GetFileInfo(string FileName) - { - if (!m_bCHMLoaded) - return null; - - m_FileFind=FileName.ToLower().Replace("/",@"\"); - - // Remove all leading '..\' - do - { - if (m_FileFind.StartsWith(@"..\")) - m_FileFind=m_FileFind.Substring(3); - else - break; - } - while(true); - - if (!m_FileFind.StartsWith(@"\")) - m_FileFind=@"\"+m_FileFind; - - string []parts=m_FileFind.Split('\\'); - m_FileFindLastPart=@"\"+parts[parts.GetUpperBound(0)]; - - this.CHMFileFoundEvent+=new CHMStream.CHMFileFound(FindFile); - m_FileInfo=null; - this.chm_enumerate(CHM_ENUMERATE.CHM_ENUMERATE_ALL); - this.CHMFileFoundEvent-=new CHMStream.CHMFileFound(FindFile); - return m_FileInfo; - } - - private int m_FileFindIndex=0; - public chmUnitInfo GetFileInfo(int FileIndex) - { - if (!m_bCHMLoaded) - return null; - - m_FileFindIndex=FileIndex; - - this.CHMFileFoundEvent+=new CHMStream.CHMFileFound(FindFileIndex); - m_FileCount=0; - m_FileInfo=null; - this.chm_enumerate(CHM_ENUMERATE.CHM_ENUMERATE_ALL); - this.CHMFileFoundEvent-=new CHMStream.CHMFileFound(FindFileIndex); - return m_FileInfo; - } - - public chmUnitInfo GetFileInfoByExtension(string Ext) - { - this.CHMFileFoundEvent+=new CHMStream.CHMFileFound(FindFileByExtension); - m_FileInfo=null; - m_FileFind=Ext.ToLower(); - this.chm_enumerate(CHMStream.CHM_ENUMERATE.CHM_ENUMERATE_ALL); - this.CHMFileFoundEvent-=new CHMStream.CHMFileFound(FindFileByExtension); - return m_FileInfo; - } - - public bool ExtractFile(string FileName, System.IO.Stream st) - { - if (!m_bCHMLoaded) - return false; - - chmUnitInfo Info=GetFileInfo(FileName); - return ExtractFile(Info,st); - } - - public bool ExtractFile(chmUnitInfo Info, System.IO.Stream st) - { - if (!m_bCHMLoaded) - return false; - - if (Info==null) - return false; - else - { - chm_retrieve_object(Info,st,0,Info.length); - } - return true; - } - - public string ExtractTextFile(string FileName) - { - if (!m_bCHMLoaded) - return "CHM File not loaded"; - - chmUnitInfo Info=GetFileInfo(FileName); - return ExtractTextFile(Info); - } - - public string ExtractTextFile(chmUnitInfo Info) - { - if (!m_bCHMLoaded) - return "CHM File not loaded"; - - if (Info==null) - return ""; - - if (Info.path.Length>=2) - { - if (Info.path.Substring(0,2).CompareTo("/#")==0) - return ""; - if (Info.path.Substring(0,2).CompareTo("/$")==0) - return ""; - } - - MemoryStream st=new MemoryStream((int)Info.length); - this.chm_retrieve_object(Info,st,0,Info.length); - - if (st.Length==0) - return ""; - - string Text=""; - - ASCIIEncoding ascii=new ASCIIEncoding(); - Text=ascii.GetString(st.ToArray(),0,50); - - // UTF Decoding - if (Text.IndexOf("UTF-8")!=-1) - { - UTF8Encoding utf8 = new UTF8Encoding(); - Text=utf8.GetString(st.ToArray(),0,(int)st.Length); - } - else - Text=ascii.GetString(st.ToArray(),0,(int)st.Length); - - return Text; - } - - public void FindFileByExtension(chmUnitInfo Info, ref CHMStream.CHM_ENUMERATOR Status) - { - if ((Info.path.StartsWith("::")) || (Info.path.StartsWith("#")) ||(Info.path.StartsWith("$"))) - { - Status=CHMStream.CHM_ENUMERATOR.CHM_ENUMERATOR_CONTINUE; - return; - } - - FileInfo Fi=new FileInfo(Info.path); - if (Fi.Extension.ToLower()==m_FileFind) - { - Status=CHMStream.CHM_ENUMERATOR.CHM_ENUMERATOR_SUCCESS; - m_FileInfo=Info; - } - else - Status=CHMStream.CHM_ENUMERATOR.CHM_ENUMERATOR_CONTINUE; - } - - public bool GetCHMParts(string Url, ref string CHMFileName, ref string FileName, ref string Anchor) - { - Regex ParseURLRegEx= new Regex( @"ms-its:(?'CHMFile'.*)::(?'Topic'.*)", RegexOptions.IgnoreCase| RegexOptions.Singleline | RegexOptions.ExplicitCapture| RegexOptions.IgnorePatternWhitespace| RegexOptions.Compiled); - - // Parse URL - Get CHM Filename & Page Name - // Format 'ms-its:file name.chm::/topic.htm' - if (ParseURLRegEx.IsMatch(Url)) - { - Match m=ParseURLRegEx.Match(Url); - CHMFileName=m.Groups["CHMFile"].Value; - string Topic=m.Groups["Topic"].Value; - int idx=Topic.IndexOf("#"); - if (idx>-1) - { - FileName=Topic.Substring(0,idx); - Anchor=Topic.Substring(idx+1); - } - else - FileName=Topic; - return true; - } - return false; - } - - private string m_TempDir=""; - string ReplaceFileName(Match m) - { - string strReplace = m.ToString(); - - // Process string. - if (m.Groups["FileName"]==null) - return strReplace; - - string FileName=m.Groups["FileName"].Value; - string FileName2=FileName.Replace("/",@"\"); - int idx=FileName2.IndexOf("::"); - if (idx!=-1) - FileName2=FileName2.Substring(idx+2); - string []parts=FileName2.Split('\\'); - string NewName=@"file://"+m_TempDir+parts[parts.GetUpperBound(0)]; - - strReplace=strReplace.Replace(FileName,NewName); - return strReplace; - } - - public ArrayList GetFileList(ref string Text, string TempDir) - { - if (!m_bCHMLoaded) - return null; - - m_TempDir=TempDir; - - ArrayList FilesList=new ArrayList(); - - // Parse HTML for CCS, ima, etc - string regexContent=@"[\x2f a-zA-Z0-9\x5C\x2E\x28\x29\x23\x24\x25\x26\x27\x22\x21\x3F\x3E\x3D\x3C\x3B\x3A\x5B\x5D\x5E\x5F\x7D\x7C\x7B\x7E\x40\x2D\x2C\x2B\x2A]*\s*"; - string regexFileName=@"\s*=\s*[""|'](?'FileName'[^""^']*)[""|']\s*"; - - Regex ScriptRegex = new Regex(@"]*>.*", - RegexOptions.IgnoreCase - | RegexOptions.Multiline - | RegexOptions.Singleline - | RegexOptions.IgnorePatternWhitespace - | RegexOptions.Compiled); - - Regex XMLRegex = new Regex(@"<\?xml.*\?>", - RegexOptions.IgnoreCase - | RegexOptions.Multiline - | RegexOptions.Singleline - | RegexOptions.IgnorePatternWhitespace - | RegexOptions.Compiled); - - Regex XMLRegex2 = new Regex(@"]*>.*", - RegexOptions.IgnoreCase - | RegexOptions.Multiline - | RegexOptions.Singleline - | RegexOptions.IgnorePatternWhitespace - | RegexOptions.Compiled); - - Regex SRCRegex = new Regex( - @"src"+regexFileName, - RegexOptions.IgnoreCase - | RegexOptions.Multiline - | RegexOptions.Singleline - | RegexOptions.IgnorePatternWhitespace - | RegexOptions.Compiled); - - Regex StyleSheetRegex = new Regex( - @" 0; i--) - { - UInt32 curBlockIdx = (UInt32)(block-i); - - /* check if we most recently decompressed the previous block */ - if ((ulong)lzx_last_block != curBlockIdx) - { - if ((curBlockIdx % reset_blkcount)==0) - { - lzx_state.LZXreset(); - } - - _chm_get_cmpblock_bounds(st,curBlockIdx, ref cmpStart, ref cmpLen); - st.BaseStream.Seek((long)cmpStart,SeekOrigin.Begin); - if (lzx_state.LZXdecompress(st,OutBuffer, ref cmpLen, ref reset_table.block_len) != lzw.DECR_OK) - return (Int64)0; - } - lzx_last_block = (int)(curBlockIdx); - } - } - else - { - if ((block % reset_blkcount)==0) - { - lzx_state.LZXreset(); - } - } - - // decompress the block we actually want - if (_chm_get_cmpblock_bounds(st, block, ref cmpStart, ref cmpLen)==0) - return 0; - - st.BaseStream.Seek((long)cmpStart,SeekOrigin.Begin); - - if (lzx_state.LZXdecompress(st, OutBuffer, ref cmpLen,ref reset_table.block_len) != lzw.DECR_OK) - return (Int64)0; - - lzx_last_block = (int)block; - - // XXX: modify LZX routines to return the length of the data they - // * decompressed and return that instead, for an extra sanity check. - return reset_table.block_len; - } - - // grab a region from a compressed block - private ulong _chm_decompress_region(Stream buf, ulong start, ulong len) - { - ulong nBlock, nOffset; - ulong nLen; - ulong gotLen; - // byte [] ubuffer=null; - - if (len <= 0) - return (Int64)0; - - // figure out what we need to read - nBlock = start / reset_table.block_len; - nOffset = start % reset_table.block_len; - nLen = len; - if (nLen > (reset_table.block_len - nOffset)) - nLen = reset_table.block_len - nOffset; - - // data request not satisfied, so... start up the decompressor machine - if (lzx_state==null) - { - int window_size = ffs(this.window_size) - 1; - lzx_last_block = -1; - - lzx_state=new lzw(); - lzx_state.LZXinit(window_size); - } - - // decompress some data - MemoryStream ms=new MemoryStream((int)reset_table.block_len+6144); - gotLen = _chm_decompress_block(nBlock, ms); - if (gotLen < nLen) - nLen = gotLen; - - // memcpy(buf, ubuffer+nOffset, (unsigned int)nLen); - ms.Position=(long)nOffset; - for(ulong i=0;i= (ulong)ui.length) - return (Int64)0; - - // clip length - if (addr + (ulong)len > (ulong)ui.length) - len = (ulong)ui.length - (ulong)addr; - - // if the file is uncompressed, it's simple - if (ui.space == CHMStream.CHM_COMPRESSION.CHM_UNCOMPRESSED) - { - // read data - long FilePos=st.BaseStream.Position; - st.BaseStream.Seek((long)((long)data_offset + (long)ui.start + (long)addr),SeekOrigin.Begin); - // byte [] buffer=st.ReadBytes((int)len); - buf.Write(st.ReadBytes((int)len),0,(int) len); - st.BaseStream.Seek(FilePos,SeekOrigin.Begin); - return (ulong)len; - } - - // else if the file is compressed, it's a little trickier - else // ui->space == CHM_COMPRESSED - { - if (lzx_state!=null) - { - lzx_state.LZXteardown(); - lzx_state=null; - } - ulong swath=0, total=0; - do - { - if (!compression_enabled) - return total; - - // swill another mouthful - swath = _chm_decompress_region(buf, ui.start + addr, len); - - // if we didn't get any... - if (swath == 0) - { - Trace.Assert((total!=ui.length),"De-compress failed","Length Required = "+ui.length.ToString()+" Length returned = "+total.ToString()); - return total; - } - - // update stats - total += swath; - len -= swath; - addr += swath; - } while (len != 0); - lzx_state=null; - - Trace.Assert((len!=ui.length),"De-compress failed","Length Required = "+ui.length.ToString()+" Length returned = "+len.ToString()); - return len; - } - } - #endregion - - #region Enumerate functions - // Enumerate the objects in the .chm archive - // Use delegate to handle callback - - public delegate void CHMFileFound(chmUnitInfo Info, ref CHMStream.CHM_ENUMERATOR Status); - public event CHMFileFound CHMFileFoundEvent; - - public void OnFileFound(chmUnitInfo Info, ref CHMStream.CHM_ENUMERATOR Status) - { - if (CHMFileFoundEvent!=null) - CHMFileFoundEvent(Info,ref Status); - } - private int chm_enumerate(CHM_ENUMERATE what) - { - Int32 curPage; - - // buffer to hold whatever page we're looking at - chmPmglHeader header; - uint end=0; - uint cur=0; - - // the current ui - chmUnitInfo ui= new chmUnitInfo(); - CHMStream.CHM_ENUMERATE flag=CHMStream.CHM_ENUMERATE.None; - - // starting page - curPage = index_head; - - // until we have either returned or given up - while (curPage != -1) - { - st.BaseStream.Seek((long)((long)dir_offset + (long)(curPage*block_len)),SeekOrigin.Begin); - - // figure out start and end for this page - cur = (uint)st.BaseStream.Position; - - header=new chmPmglHeader(); - if (header.Read_pmgl_header(st)==0) - return 0; - - end = (uint)(st.BaseStream.Position + block_len - (header.free_space)- chmPmglHeader._CHM_PMGL_LEN); - - // loop over this page - while (st.BaseStream.Position < end) - { - if (header._chm_parse_PMGL_entry(st,ref ui)==0) - return 0; - - // check for DIRS - if (ui.length == 0 && ((what & CHM_ENUMERATE.CHM_ENUMERATE_DIRS)==0)) - continue; - - // check for FILES - if (ui.length != 0 && ((what & CHM_ENUMERATE.CHM_ENUMERATE_FILES)==0)) - continue; - - // check for NORMAL vs. META - if (ui.path[0] == '/') - { - // check for NORMAL vs. SPECIAL - if (ui.path.Length>2) - { - if (ui.path[1] == '#' || ui.path[1] == '$') - flag = CHMStream.CHM_ENUMERATE.CHM_ENUMERATE_SPECIAL; - else - flag = CHMStream.CHM_ENUMERATE.CHM_ENUMERATE_NORMAL; - } - else - flag = CHMStream.CHM_ENUMERATE.CHM_ENUMERATE_META; - if ((what & flag)==0) - continue; - } - - // call the enumerator - { - CHMStream.CHM_ENUMERATOR status = CHMStream.CHM_ENUMERATOR.CHM_ENUMERATOR_CONTINUE; - OnFileFound(ui,ref status); - - switch (status) - { - case CHMStream.CHM_ENUMERATOR.CHM_ENUMERATOR_FAILURE: - return 0; - - case CHMStream.CHM_ENUMERATOR.CHM_ENUMERATOR_CONTINUE: - break; - - case CHMStream.CHM_ENUMERATOR.CHM_ENUMERATOR_SUCCESS: - return 1; - - default: - break; - } - } - } - - // advance to next page - curPage = header.block_next; - } - - return 1; - } - #endregion - - #region IDisposable Members - - private bool disposed=false; - public void Dispose() - { - Dispose(true); - // This object will be cleaned up by the Dispose method. - // Therefore, you should call GC.SupressFinalize to - // take this object off the finalization queue - // and prevent finalization code for this object - // from executing a second time. - GC.SuppressFinalize(this); - } - - /// - /// Dispose(bool disposing) executes in two distinct scenarios. - /// If disposing equals true, the method has been called directly - /// or indirectly by a user's code. Managed and unmanaged resources - /// can be disposed. - /// If disposing equals false, the method has been called by the - /// runtime from inside the finalizer and you should not reference - /// other objects. Only unmanaged resources can be disposed. - /// - /// disposing flag - private void Dispose(bool disposing) - { - // Check to see if Dispose has already been called. - if(!this.disposed) - { - // If disposing equals true, dispose all managed - // and unmanaged resources. - if(disposing) - { - // Dispose managed resources. - } - } - disposed = true; - } - - #endregion - } - - #region Structures used by CHM Storage - public class BaseStructure - { - public bool CheckSig(string Sig1, char[] Sig2) - { - int i=0; - foreach(char ch in Sig1.ToCharArray()) - { - if (ch!=Sig2[i]) - return false; - i++; - } - return true; - } - - // skip a compressed dword - public void skip_cword(BinaryReader st) - { - byte b=0; - while ((b=st.ReadByte())>= 0x80); - } - - // skip the data from a PMGL entry - public void _chm_skip_PMGL_entry_data(BinaryReader st) - { - skip_cword(st); - skip_cword(st); - skip_cword(st); - } - - // parse a compressed dword - public UInt64 _chm_parse_cword(BinaryReader st) - { - UInt64 accum = 0; - byte temp=0; - while ((temp=st.ReadByte()) >= 0x80) - { - accum <<= 7; - accum += (ulong)(temp & 0x7f); - } - - return (accum << 7) + temp; - } - - // parse a utf-8 string into an ASCII char buffer - public int _chm_parse_UTF8(BinaryReader st, UInt64 count, ref string path) - { - UTF8Encoding utf8=new UTF8Encoding(); - path=utf8.GetString(st.ReadBytes((int)count),0,(int)count); - return 1; - } - } - - public class chmUnitInfo - { - public UInt64 start=0; - public UInt64 length=0; - public CHMStream.CHM_COMPRESSION space=CHMStream.CHM_COMPRESSION.CHM_UNCOMPRESSED; - public string path=""; - } - - // structure of ITSF headers - public class chmItsfHeader : BaseStructure - { - public const int _CHM_ITSF_V2_LEN=0x58; - public const int _CHM_ITSF_V3_LEN=0x60; - - public char[] signature=null; // 0 (ITSF) - public Int32 version=0; // 4 - public Int32 header_len=0; // 8 - public Int32 unknown_000c=0; // c - public UInt32 last_modified=0; // 10 - public UInt32 lang_id=0; // 14 - public Guid dir_uuid; // 18 - public Guid stream_uuid; // 28 - public UInt64 unknown_offset=0; // 38 - public UInt64 unknown_len=0; // 40 - public UInt64 dir_offset=0; // 48 - public UInt64 dir_len=0; // 50 - public UInt64 data_offset=0; // 58 (Not present before V3) - - public int Read_itsf_header(BinaryReader st) - { - signature=st.ReadChars(4); - if (CheckSig("ITSF",signature)==false) - return 0; - - version=st.ReadInt32(); - header_len=st.ReadInt32(); - unknown_000c=st.ReadInt32(); - last_modified=st.ReadUInt32(); - lang_id=st.ReadUInt32(); - dir_uuid=new Guid(st.ReadBytes(16)); - stream_uuid=new Guid(st.ReadBytes(16)); - unknown_offset=st.ReadUInt64(); - unknown_len=st.ReadUInt64(); - dir_offset=st.ReadUInt64(); - dir_len=st.ReadUInt64(); - - if (version==2) - { - if (header_len != chmItsfHeader._CHM_ITSF_V2_LEN) - return 0; - } - else if (version==3) - { - if (header_len != chmItsfHeader._CHM_ITSF_V3_LEN) - return 0; - } - else return 0; - - if (version==3) - data_offset=st.ReadUInt64(); - else - data_offset = dir_offset + dir_len; - - return 1; - } - } - - // structure of ITSP headers - public class chmItspHeader : BaseStructure - { - const int CHM_ITSP_V1_LEN=0x54; - - public char[] signature=null; // 0 (ITSP) - public Int32 version=0; - public Int32 header_len=0; - public Int32 unknown_000c=0; - public UInt32 block_len=0; - public Int32 blockidx_intvl=0; - public Int32 index_depth=0; - public Int32 index_root=0; - public Int32 index_head=0; - public Int32 unknown_0024=0; - public Int32 num_blocks=0; - public Int32 unknown_002c=0; - public UInt32 lang_id=0; - public Guid system_uuid; - public Guid unknown_0044; - - public int Read_itsp_header(BinaryReader st) - { - signature=st.ReadChars(4); // 0 (ITSP) - if (CheckSig("ITSP",signature)==false) - return 0; - - version=st.ReadInt32(); - header_len=st.ReadInt32(); - - if (header_len!=CHM_ITSP_V1_LEN) - return 0; - - unknown_000c=st.ReadInt32(); - block_len=st.ReadUInt32(); - blockidx_intvl=st.ReadInt32(); - index_depth=st.ReadInt32(); - index_root=st.ReadInt32(); - index_head=st.ReadInt32(); - unknown_0024=st.ReadInt32(); - num_blocks=st.ReadInt32(); - unknown_002c=st.ReadInt32(); - lang_id=st.ReadUInt32(); - system_uuid=new Guid(st.ReadBytes(16)); - unknown_0044=new Guid(st.ReadBytes(16)); - - return 1; - } - } - - public class chmPmglHeader : BaseStructure - { - public const int _CHM_PMGL_LEN=0x14; - public char[] signature=null; // 0 (PMGL) - public UInt32 free_space=0; // 4 - public UInt32 unknown_0008=0; // 8 - public Int32 block_prev=0; // c - public Int32 block_next=0; // 10 - - public int Read_pmgl_header(BinaryReader st) - { - signature=st.ReadChars(4); - if (CheckSig("PMGL",signature)==false) - return 0; - - free_space=st.ReadUInt32(); - unknown_0008=st.ReadUInt32(); - block_prev=st.ReadInt32(); - block_next=st.ReadInt32(); - return 1; - } - - // parse a PMGL entry into a chmUnitInfo struct; return 1 on success. - public int _chm_parse_PMGL_entry(BinaryReader st, ref chmUnitInfo ui) - { - UInt64 strLen; - - // parse str len - strLen = _chm_parse_cword(st); - - // parse path - if (_chm_parse_UTF8(st, strLen, ref ui.path)==0) - return 0; - - // parse info - ui.space = (CHMStream.CHM_COMPRESSION)_chm_parse_cword(st); - ui.start = _chm_parse_cword(st); - ui.length = _chm_parse_cword(st); - return 1; - } - - public chmUnitInfo FindObject(BinaryReader st, UInt32 block_len, string objPath) - { - UInt32 end = (UInt32)st.BaseStream.Position+ block_len - free_space - _CHM_PMGL_LEN; - - // now, scan progressively - chmUnitInfo FoundObject=new chmUnitInfo(); - - while (st.BaseStream.Position < end) - { - _chm_parse_PMGL_entry(st,ref FoundObject); - if (FoundObject.path.ToLower().CompareTo(objPath.ToLower())==0) - return FoundObject; - } - FoundObject=null; - - return null; - } - } - - public class chmPmgiHeader : BaseStructure - { - public const int _CHM_PMGI_LEN=0x8; - - public char[] signature=null; // 0 (PMGL) - public UInt32 free_space=0; // 4 - - public int Read_pmgi_header(BinaryReader st) - { - signature=st.ReadChars(4); - - if ((signature[0]!='P') || (signature[1]!='M') || (signature[2]!='G') || (signature[3]!='I')) - return 0; - - free_space=st.ReadUInt32(); - return 1; - } - - public Int32 _chm_find_in_PMGI(BinaryReader st, UInt32 block_len, string objPath) - { - int page=-1; - UInt64 strLen; - string buffer=""; - uint end = (uint)st.BaseStream.Position + block_len - free_space - _CHM_PMGI_LEN; - - // now, scan progressively - while (st.BaseStream.Position < end) - { - // grab the name - strLen = _chm_parse_cword(st); - buffer=""; - if (_chm_parse_UTF8(st, strLen, ref buffer)==0) - return -1; - - // check if it is the right name - if (buffer.ToLower().CompareTo(objPath.ToLower())>0) - return page; - - // load next value for path - page = (int)_chm_parse_cword(st); - } - return page; - } - } - - public class chmLzxcResetTable:BaseStructure - { - public UInt32 version=0; - public UInt32 block_count=0; - public UInt32 unknown=0; - public UInt32 table_offset=0; - public UInt64 uncompressed_len=0; - public UInt64 compressed_len=0; - public UInt64 block_len=0; - - public int Read_lzxc_reset_table(BinaryReader st) - { - version=st.ReadUInt32(); - block_count=st.ReadUInt32(); - unknown=st.ReadUInt32(); - table_offset=st.ReadUInt32(); - uncompressed_len=st.ReadUInt64(); - compressed_len=st.ReadUInt64(); - block_len=st.ReadUInt64(); - - // check structure - if (version != 2) - return 0; - else - return 1; - } - } - - // structure of LZXC control data block - public class chmLzxcControlData:BaseStructure - { - public const int _CHM_LZXC_MIN_LEN=0x18; - public const int _CHM_LZXC_V2_LEN=0x1c; - - public UInt32 size=0; // 0 - public char[] signature=null; // 4 (LZXC) - public UInt32 version=0; // 8 - public UInt32 resetInterval=0; // c - public UInt32 windowSize=0; // 10 - public UInt32 windowsPerReset=0; // 14 - public UInt32 unknown_18=0; // 18 - - public int Read_lzxc_control_data(BinaryReader st) - { - size=st.ReadUInt32(); - signature=st.ReadChars(4); - - if (CheckSig("LZXC",signature)==false) - return 0; - - version=st.ReadUInt32(); - resetInterval=st.ReadUInt32(); - windowSize=st.ReadUInt32(); - windowsPerReset=st.ReadUInt32(); - - if (size>=_CHM_LZXC_V2_LEN) - unknown_18=st.ReadUInt32(); - else - unknown_18 = 0; - - if (version == 2) - { - resetInterval *= 0x8000; - windowSize *= 0x8000; - } - if (windowSize == 0 || resetInterval == 0) - return 0; - - // for now, only support resetInterval a multiple of windowSize/2 - if (windowSize == 1) - return 0; - if ((resetInterval % (windowSize/2)) != 0) - return 0; - - return 1; - } - } - #endregion - - #region LZW Decoder - - internal class lzx_bits - { - public UInt32 bb=0; - public int bl=0; - } - - internal class lzw - { - public lzw() - { - } - - /* $Id: lzx.c,v 1.5 2002/10/09 01:16:33 jedwin Exp $ */ - /*************************************************************************** - * lzx.c - LZX decompression routines * - * ------------------- * - * * - * maintainer: Jed Wing * - * source: modified lzx.c from cabextract v0.5 * - * notes: This file was taken from cabextract v0.5, which was, * - * itself, a modified version of the lzx decompression code * - * from unlzx. * - * * - * platforms: In its current incarnation, this file has been tested on * - * two different Linux platforms (one, redhat-based, with a * - * 2.1.2 glibc and gcc 2.95.x, and the other, Debian, with * - * 2.2.4 glibc and both gcc 2.95.4 and gcc 3.0.2). Both were * - * Intel x86 compatible machines. * - ***************************************************************************/ - - /*************************************************************************** - * * - * 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. Note that an exemption to this * - * license has been granted by Stuart Caie for the purposes of * - * distribution with CHMFile. This does not, to the best of my * - * knowledge, constitute a change in the license of this (the LZX) code * - * in general. * - * * - ***************************************************************************/ - - /* some constants defined by the LZX specification */ - private const int LZX_MIN_MATCH = 2; - private const int LZX_MAX_MATCH = 257; - private const int LZX_NUM_CHARS = 256; - private const int LZX_BLOCKTYPE_INVALID = 0; /* also blocktypes 4-7 invalid */ - private const int LZX_BLOCKTYPE_VERBATIM = 1; - private const int LZX_BLOCKTYPE_ALIGNED = 2; - private const int LZX_BLOCKTYPE_UNCOMPRESSED = 3; - private const int LZX_PRETREE_NUM_ELEMENTS = 20; - private const int LZX_ALIGNED_NUM_ELEMENTS = 8; /* aligned offset tree #elements */ - private const int LZX_NUM_PRIMARY_LENGTHS = 7; /* this one missing from spec! */ - private const int LZX_NUM_SECONDARY_LENGTHS = 249; /* length tree #elements */ - - /* LZX huffman defines: tweak tablebits as desired */ - private const int LZX_PRETREE_MAXSYMBOLS = LZX_PRETREE_NUM_ELEMENTS; - private const int LZX_PRETREE_TABLEBITS = 6; - private const int LZX_MAINTREE_MAXSYMBOLS = LZX_NUM_CHARS + 50*8; - private const int LZX_MAINTREE_TABLEBITS = 12; - private const int LZX_LENGTH_MAXSYMBOLS = LZX_NUM_SECONDARY_LENGTHS+1; - private const int LZX_LENGTH_TABLEBITS = 12; - private const int LZX_ALIGNED_MAXSYMBOLS = LZX_ALIGNED_NUM_ELEMENTS; - private const int LZX_ALIGNED_TABLEBITS = 7; - private const int LZX_LENTABLE_SAFETY = 64; /* we allow length table decoding overruns */ - - public const int DECR_OK = 0; - public const int DECR_DATAFORMAT = 1; - public const int DECR_ILLEGALDATA = 2; - public const int DECR_NOMEMORY = 3; - - private byte[] window; /* the actual decoding window */ - private ulong window_size; /* window size (32Kb through 2Mb) */ - private ulong actual_size; /* window size when it was first allocated */ - private ulong window_posn; /* current offset within the window */ - private ulong R0, R1, R2; /* for the LRU offset system */ - private UInt32 main_elements; /* number of main tree elements */ - private int header_read; /* have we started decoding at all yet? */ - private UInt32 block_type; /* type of this block */ - private ulong block_length; /* uncompressed length of this block */ - private ulong block_remaining; /* uncompressed bytes still left to decode */ - private ulong frames_read; /* the number of CFDATA blocks processed */ - private long intel_filesize; /* magic header value used for transform */ - private long intel_curpos; /* current offset in transform space */ - private int intel_started; /* have we seen any translatable data yet? */ - - - private uint [] PRETREE_table = new uint[(1<<(6)) + (((20))<<1)]; - private byte [] PRETREE_len = new byte [((20)) + (64)]; - - private uint [] MAINTREE_table= new uint[(1<<(12)) + (((256) + 50*8)<<1)]; - private byte [] MAINTREE_len = new byte [((256) + 50*8) + (64)]; - - private uint [] LENGTH_table= new uint[(1<<(12)) + (((249)+1)<<1)]; - private byte [] LENGTH_len = new byte [((249)+1) + (64)]; - - private uint [] ALIGNED_table= new uint[(1<<(7)) + (((8))<<1)]; - private byte [] ALIGNED_len = new byte [((8)) + (64)]; - private System.IO.BinaryReader BitSource=null; - private System.IO.Stream OutputStream=null; - - /* LZX decruncher */ - - /* Microsoft's LZX document and their implementation of the - * com.ms.util.cab Java package do not concur. - * - * In the LZX document, there is a table showing the correlation between - * window size and the number of position slots. It states that the 1MB - * window = 40 slots and the 2MB window = 42 slots. In the implementation, - * 1MB = 42 slots, 2MB = 50 slots. The actual calculation is 'find the - * first slot whose position base is equal to or more than the required - * window size'. This would explain why other tables in the document refer - * to 50 slots rather than 42. - * - * The constant NUM_PRIMARY_LENGTHS used in the decompression pseudocode - * is not defined in the specification. - * - * The LZX document does not state the uncompressed block has an - * uncompressed length field. Where does this length field come from, so - * we can know how large the block is? The implementation has it as the 24 - * bits following after the 3 blocktype bits, before the alignment - * padding. - * - * The LZX document states that aligned offset blocks have their aligned - * offset huffman tree AFTER the main and length trees. The implementation - * suggests that the aligned offset tree is BEFORE the main and length - * trees. - * - * The LZX document decoding algorithm states that, in an aligned offset - * block, if an extra_bits value is 1, 2 or 3, then that number of bits - * should be read and the result added to the match offset. This is - * correct for 1 and 2, but not 3, where just a huffman symbol (using the - * aligned tree) should be read. - * - * Regarding the E8 preprocessing, the LZX document states 'No translation - * may be performed on the last 6 bytes of the input block'. This is - * correct. However, the pseudocode provided checks for the *E8 leader* - * up to the last 6 bytes. If the leader appears between -10 and -7 bytes - * from the end, this would cause the next four bytes to be modified, at - * least one of which would be in the last 6 bytes, which is not allowed - * according to the spec. - * - * The specification states that the huffman trees must always contain at - * least one element. However, many CAB files contain blocks where the - * length tree is completely empty (because there are no matches), and - * this is expected to succeed. - */ - - /* LZX uses what it calls 'position slots' to represent match offsets. - * What this means is that a small 'position slot' number and a small - * offset from that slot are encoded instead of one large offset for - * every match. - * - position_base is an index to the position slot bases - * - extra_bits states how many bits of offset-from-base data is needed. - */ - private byte [] extra_bits = { - 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, - 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, - 15, 15, 16, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, - 17, 17, 17 - }; - - private ulong [] position_base = { - 0, 1, 2, 3, 4, 6, 8, 12, 16, 24, 32, 48, 64, 96, 128, 192, - 256, 384, 512, 768, 1024, 1536, 2048, 3072, 4096, 6144, 8192, 12288, 16384, 24576, 32768, 49152, - 65536, 98304, 131072, 196608, 262144, 393216, 524288, 655360, 786432, 917504, 1048576, 1179648, 1310720, 1441792, 1572864, 1703936, - 1835008, 1966080, 2097152 - }; - - private UInt32 ReadUInt16() - { - UInt32 rc=0; - UInt32 Byte1=0; - UInt32 Byte2=0; - try - { - Byte1=BitSource.ReadByte(); - Byte2=BitSource.ReadByte(); - } - catch(Exception) - { - } - rc=(Byte2<<8)+Byte1; - return rc; - } - - public bool LZXinit(int WindowSize) - { - ulong wndsize = (ulong)(1 << WindowSize); - int i, posn_slots; - - /* LZX supports window sizes of 2^15 (32Kb) through 2^21 (2Mb) */ - /* if a previously allocated window is big enough, keep it */ - if (WindowSize< 15 || WindowSize> 21) return false; - - /* allocate state and associated window */ - window = new byte[wndsize]; - if (window==null) - { - return false; - } - - actual_size = wndsize; - window_size = wndsize; - - /* calculate required position slots */ - if (WindowSize == 20) posn_slots = 42; - else if (WindowSize== 21) posn_slots = 50; - else posn_slots = WindowSize << 1; - - /** alternatively **/ - /* posn_slots=i=0; while (i < wndsize) i += 1 << extra_bits[posn_slots++]; */ - - /* initialize other state */ - R0 = R1 = R2 = 1; - main_elements = (uint)(LZX_NUM_CHARS + (posn_slots << 3)); - header_read = 0; - frames_read = 0; - block_remaining = 0; - block_type = LZX_BLOCKTYPE_INVALID; - intel_curpos = 0; - intel_started = 0; - window_posn = 0; - - /* initialise tables to 0 (because deltas will be applied to them) */ - for (i = 0; i < LZX_MAINTREE_MAXSYMBOLS; i++) MAINTREE_len[i] = 0; - for (i = 0; i < LZX_LENGTH_MAXSYMBOLS; i++) LENGTH_len[i] = 0; - - return true; - } - - public void LZXteardown() - { - window=null; - } - - public int LZXreset() - { - R0 = R1 = R2 = 1; - header_read = 0; - frames_read = 0; - block_remaining = 0; - block_type = LZX_BLOCKTYPE_INVALID; - intel_curpos = 0; - intel_started = 0; - window_posn = 0; - - for (int i = 0; i < LZX_MAINTREE_MAXSYMBOLS + LZX_LENTABLE_SAFETY; i++) MAINTREE_len[i] = 0; - for (int i = 0; i < LZX_LENGTH_MAXSYMBOLS + LZX_LENTABLE_SAFETY; i++) LENGTH_len[i] = 0; - - return DECR_OK; - } - - - /* Bitstream reading macros: - * - * INIT_BITSTREAM should be used first to set up the system - * READ_BITS(var,n) takes N bits from the buffer and puts them in var - * - * ENSURE_BITS(n) ensures there are at least N bits in the bit buffer - * PEEK_BITS(n) extracts (without removing) N bits from the bit buffer - * REMOVE_BITS(n) removes N bits from the bit buffer - * - * These bit access routines work by using the area beyond the MSB and the - * LSB as a free source of zeroes. This avoids having to mask any bits. - * So we have to know the bit width of the bitbuffer variable. This is - * sizeof(ulong) * 8, also defined as ULONG_BITS - */ - - /* number of bits in ulong. Note: This must be at multiple of 16, and at - * least 32 for the bitbuffer code to work (ie, it must be able to ensure - * up to 17 bits - that's adding 16 bits when there's one bit left, or - * adding 32 bits when there are no bits left. The code should work fine - * for machines where ulong >= 32 bits. - */ - private int ULONG_BITS() - { - int rc=(System.Runtime.InteropServices.Marshal.SizeOf(typeof(System.UInt32))<<3); - return rc; - } - - /* make_decode_table(nsyms, nbits, length[], table[]) - * - * This function was coded by David Tritscher. It builds a fast huffman - * decoding table out of just a canonical huffman code lengths table. - * - * nsyms = total number of symbols in this huffman tree. - * nbits = any symbols with a code length of nbits or less can be decoded - * in one lookup of the table. - * length = A table to get code lengths from [0 to syms-1] - * table = The table to fill up with decoded symbols and pointers. - * - * Returns 0 for OK or 1 for error - */ - - private int make_decode_table(ulong nsyms, byte nbits, ref byte [] length, ref UInt32[] table) - { - ulong sym; - ulong leaf; - byte bit_num = 1; - ulong fill; - ulong pos = 0; /* the current position in the decode table */ - ulong table_mask = (ulong)(1 << nbits); - ulong bit_mask = table_mask >> 1; /* don't do 0 length codes */ - ulong next_symbol = bit_mask; /* base of allocation for long codes */ - - /* fill entries for codes short enough for a direct mapping */ - while (bit_num <= nbits) - { - for (sym = 0; sym < nsyms; sym++) - { - if (length[sym] == bit_num) - { - leaf = pos; - - if((pos += bit_mask) > table_mask) return 1; /* table overrun */ - - /* fill all possible lookups of this symbol with the symbol itself */ - fill = bit_mask; - while (fill-- > 0) table[leaf++] = (uint)sym; - } - } - bit_mask >>= 1; - bit_num++; - } - - /* if there are any codes longer than nbits */ - if (pos != table_mask) - { - /* clear the remainder of the table */ - for (sym = pos; sym < table_mask; sym++) table[sym] = 0; - - /* give ourselves room for codes to grow by up to 16 more bits */ - pos <<= 16; - table_mask <<= 16; - bit_mask = 1 << 15; - - while (bit_num <= 16) - { - for (sym = 0; sym < nsyms; sym++) - { - if (length[sym] == bit_num) - { - leaf = pos >> 16; - for (fill = 0; fill < (ulong)(bit_num - nbits); fill++) - { - /* if this path hasn't been taken yet, 'allocate' two entries */ - if (table[leaf] == 0) - { - table[(next_symbol << 1)] = 0; - table[(next_symbol << 1) + 1] = 0; - table[leaf] = (uint)next_symbol++; - } - /* follow the path and select either left or right for next bit */ - leaf = table[leaf] << 1; - if (((pos >> (byte)(15-fill)) & 1)==1) - leaf++; - } - table[leaf] = (uint)sym; - - if ((pos += bit_mask) > table_mask) - return 1; /* table overflow */ - } - } - bit_mask >>= 1; - bit_num++; - } - } - - /* full table? */ - if (pos == table_mask) - return 0; - - /* either erroneous table, or all elements are 0 - let's find out. */ - for (sym = 0; sym < nsyms; sym++) if (length[(uint)sym]!=0) - return 1; - - return 0; - } - - private int lzx_read_lens(byte []lens, ulong first, ulong last, ref lzx_bits lb) - { - ulong i,j, x,y; - int z; - - UInt32 bitbuf = lb.bb; - int bitsleft = lb.bl; - - UInt32 [] hufftbl=null; - - for (x = 0; x < 20; x++) - { - do - { - while (bitsleft < (4)) - { - bitbuf |= (UInt32)ReadUInt16() << (ULONG_BITS() - 16 - bitsleft); - bitsleft += 16; - } - y = (bitbuf >> (ULONG_BITS()- (4))); - bitbuf <<= 4; - bitsleft -= 4; - } - while (false); - PRETREE_len[x] = (byte)y; - } - if (make_decode_table( 20, 6, ref PRETREE_len, ref PRETREE_table)!=0) - return 2; - - for (x = first; x < last; ) - { - do - { - while (bitsleft < 16) - { - bitbuf |= (UInt32)ReadUInt16() << (ULONG_BITS() - 16 - bitsleft); - bitsleft += 16; - } - hufftbl = PRETREE_table; - if ((i = hufftbl[((ulong)bitbuf >> (ULONG_BITS()- 6))]) >= 20) - { - j = (ulong)(1 << (byte)(ULONG_BITS()- ((6)))); - do - { - j >>= 1; - i <<= 1; - if ((bitbuf & j)!=0) - i|=1; - else - i|=0; - - if (j==0) - { - return (2); - } - } - while ((i = hufftbl[i]) >= 20); - } - z = (int)i; - j = PRETREE_len[z]; - bitbuf <<= (byte)j; - bitsleft -= (int)j; - } - while (false); - - if (z == 17) - { - do - { - while (bitsleft < (4)) - { - bitbuf |= (UInt32)ReadUInt16() << (ULONG_BITS() - 16 - bitsleft); - bitsleft += 16; - } - y = (bitbuf >> (ULONG_BITS()- (4))); - bitbuf <<= 4; - bitsleft -= 4; - } - while(false); - y += 4; - - while ((y--)!=0) - lens[x++] = 0; - } - else if (z == 18) - { - do - { - while (bitsleft < (5)) - { - bitbuf |= (UInt32)ReadUInt16() << (ULONG_BITS() - 16 - bitsleft); - bitsleft += 16; - } - (y) = (bitbuf >> (ULONG_BITS()- (5))); - bitbuf <<= 5; - bitsleft -= 5; - } - while (false); - - y += 20; - - while ((y--)!=0) - lens[x++] = 0; - } - else if (z == 19) - { - do - { - while (bitsleft < (1)) - { - bitbuf |= (UInt32)ReadUInt16() << (ULONG_BITS() - 16 - bitsleft); - bitsleft += 16; - } - y = (bitbuf >> (ULONG_BITS()- (1))); - bitbuf <<= 1; - bitsleft -= 1; - } - while(false); - y += 4; - do - { - while (bitsleft < (16)) - { - bitbuf |= (UInt32)ReadUInt16() << (ULONG_BITS() - 16 - bitsleft); - bitsleft += 16; - } - hufftbl = (PRETREE_table); - if ((i = hufftbl[(bitbuf >> (ULONG_BITS()- 6))]) >= 20) - { - j = (ulong)1 << (byte)(ULONG_BITS()- 6); - do - { - j >>= 1; - i <<= 1; - if ((bitbuf & j)==0) - i|=0; - else - i|=1; - if (j==0) - { - return (2); - } - } - while ((i = hufftbl[i]) >= 20); - } - z = (int)i; - j = PRETREE_len[z]; - - bitbuf <<= (byte)j; - bitsleft -= (int)j; - } - while(false); - z = lens[x] - z; - if (z < 0) - z += 17; - - while ((y--)!=0) - lens[x++] = (byte)z; - } - else - { - z = lens[x] - z; - if (z < 0) - z += 17; - lens[x++] = (byte)z; - } - } - lb.bb = bitbuf; - lb.bl = bitsleft; - return 0; - } - - public int LZXdecompress(System.IO.BinaryReader inpos, System.IO.Stream outpos, ref ulong inlen, ref ulong outlen) - { - BitSource=inpos; - OutputStream=outpos; - - long endinp = BitSource.BaseStream.Position+(long)inlen; - ulong runsrc, rundest; - UInt32 [] hufftbl; /* used in READ_HUFFSYM macro as chosen decoding table */ - - UInt32 bitbuf; - int bitsleft; - ulong match_offset, i,j,k; /* ijk used in READ_HUFFSYM macro */ - lzx_bits lb; /* used in READ_LENGTHS macro */ - lb=new lzx_bits(); - - int togo = (int)outlen, this_run, main_element, aligned_bits; - int match_length, length_footer, extra, verbatim_bits; - - bitsleft = 0; - bitbuf = 0; - - /* read header if necessary */ - if (header_read==0) - { - i = j = 0; - do - { - while (bitsleft < (1)) - { - bitbuf |= (UInt32)ReadUInt16() << (ULONG_BITS() - 16 - bitsleft); - bitsleft += 16; - } - k = (bitbuf >> (ULONG_BITS()- (1))); - bitbuf <<= 1; - bitsleft -= 1; - } - while(false); - - if (k!=0) - { - do - { - while (bitsleft < (16)) - { - bitbuf |= (UInt32)ReadUInt16() << (ULONG_BITS() -16 - bitsleft); - bitsleft += 16; - } - i = (bitbuf >> (ULONG_BITS()- (16))); - bitbuf <<= 16; - bitsleft -= 1; - } - while(false); - - do - { - while (bitsleft < (16)) - { - bitbuf |= (UInt32)ReadUInt16() << (ULONG_BITS() - 16 - bitsleft); - bitsleft += 16; - } - j = (bitbuf >> (ULONG_BITS()- (16))); - bitbuf <<= 16; - bitsleft -= 16; - } - while(false); - } - intel_filesize = (long)((i << 16) | j); - header_read = 1; - } - - /* main decoding loop */ - while (togo > 0) - { - if (block_remaining == 0) - { - if (block_type == (3)) - { - if ((block_length & 1)!=0) - BitSource.ReadByte(); - bitsleft = 0; - bitbuf = 0; - } - - do - { - while (bitsleft < (3)) - { - bitbuf |= (UInt32)ReadUInt16() << (ULONG_BITS() - 16 - bitsleft); - bitsleft += 16; - } - (block_type) = (uint)(bitbuf >> (ULONG_BITS()- (3))); - bitbuf <<= 3; - bitsleft -= 3; - } - while (false); - - do - { - while (bitsleft < (16)) - { - bitbuf |= (UInt32)ReadUInt16() << (ULONG_BITS() - 16 - bitsleft); - bitsleft += 16; - } - (i) = (bitbuf >> (ULONG_BITS()- (16))); - bitbuf <<= 16; - bitsleft -= 16; - } - while (false); - - do - { - while (bitsleft < (8)) - { - bitbuf |= (UInt32)ReadUInt16() << (ULONG_BITS() - 16 - bitsleft); - bitsleft += 16; - } - (j) = (bitbuf >> (ULONG_BITS()- (8))); - bitbuf <<= 8; - bitsleft -= 8; - } - while (false); - block_remaining = block_length = (i << 8) | j; - - switch (block_type) - { - case (LZX_BLOCKTYPE_ALIGNED): - for (i = 0; i < 8; i++) - { - do - { - while (bitsleft < (3)) - { - bitbuf |= (UInt32)ReadUInt16() << (ULONG_BITS() - 16 - bitsleft); - bitsleft += 16; - } - (j) = (bitbuf >> (ULONG_BITS()- (3))); - bitbuf <<= 3; - bitsleft -= 3; - } - while (false); - (ALIGNED_len)[i] = (byte)j; - } - if (make_decode_table( 8, 7, ref ALIGNED_len, ref ALIGNED_table)!=0) - { - return (2); - } - - do - { - lb.bb = bitbuf; - lb.bl = bitsleft; - if (lzx_read_lens(MAINTREE_len,0,256,ref lb)!=0) - { - return (2); - } - bitbuf = lb.bb; - bitsleft = lb.bl; - } - while (false); - do - { - lb.bb = bitbuf; - lb.bl = bitsleft; - if (lzx_read_lens(MAINTREE_len,256,main_elements,ref lb)!=0) - { - return (2); - } - bitbuf = lb.bb; - bitsleft = lb.bl; - } - while (false); - - if (make_decode_table( (256 + 50*8), 12, ref MAINTREE_len, ref MAINTREE_table)!=0) - { - return (2); - } - if (MAINTREE_len[0xE8] != 0) intel_started = 1; - - do - { - lb.bb = bitbuf; - lb.bl = bitsleft; - if (lzx_read_lens(LENGTH_len,0,249,ref lb)!=0) - { - return (2); - } - bitbuf = lb.bb; - bitsleft = lb.bl; - } - while (false); - if (make_decode_table( (249+1), 12, ref LENGTH_len, ref LENGTH_table)!=0) - { - return (2); - } - break; - - case (LZX_BLOCKTYPE_VERBATIM): - do - { - lb.bb = bitbuf; - lb.bl = bitsleft; - if (lzx_read_lens(MAINTREE_len,0,256,ref lb)!=0) - { - return (2); - } - bitbuf = lb.bb; - bitsleft = lb.bl; - } - while (false); - do - { - lb.bb = bitbuf; - lb.bl = bitsleft; - if (lzx_read_lens(MAINTREE_len,256,main_elements,ref lb)!=0) - { - return (2); - } - bitbuf = lb.bb; - bitsleft = lb.bl; - } - while (false); - - if (make_decode_table( (256 + 50*8), 12, ref MAINTREE_len, ref MAINTREE_table)!=0) - { - return (2); - } - if (MAINTREE_len[0xE8] != 0) intel_started = 1; - - do - { - lb.bb = bitbuf; - lb.bl = bitsleft; - if (lzx_read_lens(LENGTH_len,0,249,ref lb)!=0) - { - return (2); - } - bitbuf = lb.bb; - bitsleft = lb.bl; - } - while (false); - if (make_decode_table( (249+1), 12, ref LENGTH_len, ref LENGTH_table)!=0) - { - return (2); - } - break; - - case (LZX_BLOCKTYPE_UNCOMPRESSED): - intel_started = 1; - while (bitsleft < (16)) - { - bitbuf |= (UInt32)ReadUInt16() << (ULONG_BITS() - bitsleft); - bitsleft += 16; - } - if (bitsleft > 16) - { - BitSource.BaseStream.Seek(-2,System.IO.SeekOrigin.Current); - } - R0 = (ulong)(BitSource.ReadByte()+(BitSource.ReadByte()<<8)+(BitSource.ReadByte()<<16)+(BitSource.ReadByte()<<24)); - R1 = (ulong)(BitSource.ReadByte()+(BitSource.ReadByte()<<8)+(BitSource.ReadByte()<<16)+(BitSource.ReadByte()<<24)); - R2 = (ulong)(BitSource.ReadByte()+(BitSource.ReadByte()<<8)+(BitSource.ReadByte()<<16)+(BitSource.ReadByte()<<24)); - break; - - default: - return (DECR_ILLEGALDATA); - } - } - - /* buffer exhaustion check */ - if (BitSource.BaseStream.Position > (long) endinp) - { - /* it's possible to have a file where the next run is less than - * 16 bits in size. In this case, the READ_HUFFSYM() macro used - * in building the tables will exhaust the buffer, so we should - * allow for this, but not allow those accidentally read bits to - * be used (so we check that there are at least 16 bits - * remaining - in this boundary case they aren't really part of - * the compressed data) - */ - if (BitSource.BaseStream.Position> (long)(endinp+2) || bitsleft < 16) - return DECR_ILLEGALDATA; - } - - while ((this_run = (int)block_remaining) > 0 && togo > 0) - { - if (this_run > togo) - this_run = togo; - - togo -= this_run; - block_remaining -= (ulong)this_run; - - /* apply 2^x-1 mask */ - window_posn &= window_size - 1; - - /* runs can't straddle the window wraparound */ - if ((window_posn + (ulong)this_run) > window_size) - return DECR_DATAFORMAT; - - switch (block_type) - { - case LZX_BLOCKTYPE_VERBATIM: - while (this_run > 0) - { - do - { - while (bitsleft < (16)) - { - bitbuf |= (UInt32)ReadUInt16() << (ULONG_BITS() - 16 - bitsleft); - bitsleft += 16; - } - hufftbl = MAINTREE_table; - if ((i = hufftbl[(bitbuf >> (ULONG_BITS()- 12))]) >= 256 + 50*8) - { - j = (ulong)(1 << (ULONG_BITS()- 12)); - do - { - j >>= 1; - i <<= 1; - if ((bitbuf & j)!=0) - i|=1; - else - i|=0; - if (j==0) - { - return (2); - } - } - while ((i = hufftbl[i]) >= (((256) + 50*8))); - } - j = MAINTREE_len[main_element = (int)i]; - bitbuf <<= (byte)j; - bitsleft -= (byte)j; - } - while (false); - - if (main_element < (256)) - { - window[window_posn++] = (byte)main_element; - this_run--; - } - else - { - main_element -= (256); - - match_length = main_element & (7); - if (match_length == (7)) - { - do - { - while (bitsleft < (16)) - { - bitbuf |= (UInt32)ReadUInt16() << (ULONG_BITS() - 16 - bitsleft); - bitsleft += 16; - } - hufftbl = (LENGTH_table); - if ((i = hufftbl[(bitbuf >> (ULONG_BITS()- 12))]) >= (((249)+1))) - { - j = (ulong)(1 << (ULONG_BITS()- ((12)))); - do - { - j >>= 1; - i <<= 1; - if ((bitbuf & j)!=0) - i|=1; - else - i|=0; - if (j==0) - { - return (2); - } - } - while ((i = hufftbl[i]) >= (((249)+1))); - } - j = LENGTH_len[(length_footer) = (int)i]; - bitbuf <<= (byte)j; - bitsleft -= (byte)j; - } - while (false); - - match_length += length_footer; - } - match_length += (2); - - match_offset = (ulong)(main_element >> 3); - - if (match_offset > 2) - { - if (match_offset != 3) - { - extra = extra_bits[match_offset]; - do - { - while (bitsleft < (extra)) - { - bitbuf |= (UInt32)ReadUInt16() << (ULONG_BITS() - 16 - bitsleft); - bitsleft += 16; - } - verbatim_bits = (int)(bitbuf >> (ULONG_BITS()- (extra))); - bitbuf <<= extra; - bitsleft -= extra; - } - while (false); - match_offset = position_base[match_offset] - 2 + (ulong)verbatim_bits; - } - else - { - match_offset = 1; - } - - R2 = R1; R1 = R0; R0 = match_offset; - } - else if (match_offset == 0) - { - match_offset = R0; - } - else if (match_offset == 1) - { - match_offset = R1; - R1 = R0; R0 = match_offset; - } - else - { - match_offset = R2; - R2 = R0; R0 = match_offset; - } - - rundest = window_posn; - // rundest= window+window_posn - runsrc = rundest - match_offset; - window_posn += (ulong)match_length; - this_run -= match_length; - - // runsrc < window - while ((runsrc<0) && (match_length-- > 0)) - { - window[rundest++]=window[runsrc+window_size]; - // *rundest++ = *(runsrc + window_size); - runsrc++; - } - - while (match_length-- > 0) - { - window[rundest++]=window[runsrc++]; - // *rundest++ = *runsrc++; - } - } - } - break; - - case LZX_BLOCKTYPE_ALIGNED: - while (this_run > 0) - { - do - { - while (bitsleft < (16)) - { - bitbuf |= (UInt32)ReadUInt16() << (ULONG_BITS() - 16 - bitsleft); - bitsleft += 16; - } - hufftbl = MAINTREE_table; - if ((i = hufftbl[(bitbuf >> (ULONG_BITS()- 12))]) >= (((256) + 50*8))) - { - j = (ulong)1 << (ULONG_BITS()- ((12))); - do - { - j >>= 1; - i <<= 1; - if ((bitbuf & j)!=0) - i|=1; - else - i|=0; - if (j==0) - { - return (2); - } - } - while ((i = hufftbl[i]) >= (((256) + 50*8))); - } - j = MAINTREE_len[(main_element) = (int)i]; - bitbuf <<= (int)j; - bitsleft -= (int)j; - } - while (false); - - if (main_element < (256)) - { - window[window_posn++] = (byte)main_element; - this_run--; - } - else - { - main_element -= (256); - match_length = main_element & (7); - if (match_length == (7)) - { - do - { - while (bitsleft < (16)) - { - bitbuf |= (UInt32)ReadUInt16() << (ULONG_BITS() - 16 - bitsleft); - bitsleft += 16; - } - hufftbl = LENGTH_table; - if ((i = hufftbl[(bitbuf >> (ULONG_BITS()- 12))]) >= (((249)+1))) - { - j = (ulong) 1 << (ULONG_BITS()- ((12))); - do - { - j >>= 1; - i <<= 1; - if ((bitbuf & j)!=0) - i|=1; - else - i|=0; - - if (j==0) - { - return (2); - } - } - while ((i = hufftbl[i]) >= (((249)+1))); - } - j = LENGTH_len[length_footer = (int)i]; - bitbuf <<= (int)j; - bitsleft -= (int)j; - } - while (false); - match_length += length_footer; - } - match_length += (2); - - match_offset = (ulong)(main_element >> 3); - - if (match_offset > 2) - { - extra = extra_bits[match_offset]; - match_offset = position_base[match_offset] - 2; - if (extra > 3) - { - extra -= 3; - do - { - while (bitsleft < (extra)) - { - bitbuf |= (UInt32)ReadUInt16() << (ULONG_BITS() - 16 - bitsleft); - bitsleft += 16; - } - verbatim_bits = (int)(bitbuf >> (ULONG_BITS()- (extra))); - bitbuf <<= extra; - bitsleft -= extra; - } - while (false); - match_offset += (ulong)(verbatim_bits << 3); - do - { - while (bitsleft < (16)) - { - bitbuf |= (UInt32)ReadUInt16() << (ULONG_BITS() - 16 - bitsleft); - bitsleft += 16; - } - hufftbl = (ALIGNED_table); - if ((i = hufftbl[(bitbuf >> (ULONG_BITS()- 7))]) >= 8) - { - j = (ulong)1 << (ULONG_BITS()- ((7))); - do - { - j >>= 1; - i <<= 1; - if ((bitbuf & j)!=0) - i|=1; - else - i|=0; - if (j==0) - { - return (2); - } - } - while ((i = hufftbl[i]) >= (((8)))); - } - - j = (ALIGNED_len)[(aligned_bits) = (int)i]; - bitbuf <<= (int)j; - bitsleft -= (int)j; - } - while (false); - match_offset += (ulong)aligned_bits; - } - else if (extra == 3) - { - do - { - while (bitsleft < (16)) - { - bitbuf |= (UInt32)ReadUInt16() << (ULONG_BITS() - 16 - bitsleft); - bitsleft += 16; - } - hufftbl = (ALIGNED_table); - if ((i = hufftbl[(bitbuf >> (ULONG_BITS()- 7))]) >= 8) - { - j = (ulong)1 << (ULONG_BITS()- ((7))); - do - { - j >>= 1; - i <<= 1; - if ((bitbuf & j)!=0) - i|=1; - else - i|=0; - if (j!=0) - { - return (2); - } - } - while ((i = hufftbl[i]) >= 8); - } - j = (ALIGNED_len)[(aligned_bits) = (int)i]; - bitbuf <<= (int)j; - bitsleft -= (int)j; - } - while (false); - match_offset += (ulong)aligned_bits; - } - else if (extra > 0) - { - do - { - while (bitsleft < (extra)) - { - bitbuf |= (UInt32)ReadUInt16() << (ULONG_BITS() - 16 - bitsleft); - bitsleft += 16; - } - (verbatim_bits) = (int)(bitbuf >> (int)(ULONG_BITS()- (extra))); - bitbuf <<= extra; - bitsleft -= extra; - } - while (false); - match_offset += (ulong)verbatim_bits; - } - else - { - match_offset = 1; - } - - R2 = R1; R1 = R0; R0 = match_offset; - } - else if (match_offset == 0) - { - match_offset = R0; - } - else if (match_offset == 1) - { - match_offset = R1; - R1 = R0; R0 = match_offset; - } - else - { - match_offset = R2; - R2 = R0; R0 = match_offset; - } - - rundest = window_posn; - runsrc = rundest - match_offset; - window_posn += (ulong)match_length; - this_run -= match_length; - - while ((runsrc<0) && (match_length-- > 0)) - { - // *rundest++ = *(runsrc + window_size); runsrc++; - window[rundest++]=window[runsrc + window_size]; - runsrc++; - } - - while (match_length-- > 0) - { - // *rundest++ = *runsrc++; - window[rundest++]=window[runsrc++]; - } - } - } - break; - - case LZX_BLOCKTYPE_UNCOMPRESSED: - if ((BitSource.BaseStream.Position + (long)this_run) > (long)endinp) - return (2); - - // memcpy(window + window_posn, inposCount, this_run); - for(i=0; i<(ulong)this_run;i++) - { - window[window_posn+i]=BitSource.ReadByte(); - } - window_posn += (ulong)this_run; - break; - - default: - return DECR_ILLEGALDATA; /* might as well */ - } - - } - } - - if (togo != 0) return DECR_ILLEGALDATA; - - // memcpy(outpos, window + ((!window_posn) ? window_size : window_posn) - outlen, (size_t) outlen); - ulong start=0; - if (window_posn==0) - start=(ulong)window_size; - else - start=(ulong)window_posn; - - start-=(ulong)outlen; - - long Pos=OutputStream.Position; - for(i=0;i<(ulong)outlen;i++) - { - OutputStream.WriteByte(window[start+i]); - } - OutputStream.Seek(Pos,System.IO.SeekOrigin.Begin); - - /* intel E8 decoding */ - if ((frames_read++ < 32768) && intel_filesize != 0) - { - if (outlen <= 6 || (intel_started==0)) - { - intel_curpos += (long)outlen; - } - else - { - // UBYTE *data = outpos; - long dataend = OutputStream.Position + (int)outlen - 10; - long curpos = intel_curpos; - long filesize = intel_filesize; - long abs_off, rel_off; - - intel_curpos = (long)curpos + (long)outlen; - - while (OutputStream.Position < dataend) - { - if (OutputStream.ReadByte() != 0xE8) - { - curpos++; - continue; - } - - abs_off = (long)(OutputStream.ReadByte() | (OutputStream.ReadByte() <<8) | (OutputStream.ReadByte() <<16) | (OutputStream.ReadByte() <<24)); - if (abs_off < filesize) - { - if (abs_off >= 0) - rel_off = (long)(abs_off - curpos); - else - rel_off = (long)abs_off + filesize; - OutputStream.WriteByte((byte)(rel_off & 0x000000ff)); - OutputStream.WriteByte((byte)((rel_off & 0x0000ff00)>>8)); - OutputStream.WriteByte((byte)((rel_off & 0x00ff0000)>>16)); - OutputStream.WriteByte((byte)((rel_off & 0xff000000)>>24)); - } - curpos += 5; - } - } - } - - return DECR_OK; - } - } - #endregion -} diff --git a/irc/TechBot/CHMLibrary/TOCItem.cs b/irc/TechBot/CHMLibrary/TOCItem.cs deleted file mode 100644 index 8f6b7f97909..00000000000 --- a/irc/TechBot/CHMLibrary/TOCItem.cs +++ /dev/null @@ -1,494 +0,0 @@ -using System; -using System.IO; -using System.Collections; -using System.Windows.Forms; - -using HtmlHelp.ChmDecoding; - -namespace HtmlHelp -{ - /// - /// The class TOCItem implements a toc-entry item - /// - public sealed class TOCItem - { - /// - /// Constant for standard folder (closed) image index (HH2 image list) - /// - public const int STD_FOLDER_HH2 = 4; - /// - /// Constant for standard folder (opened) image index (HH2 image list) - /// - public const int STD_FOLDER_OPEN_HH2 = 6; - /// - /// Constant for standard file image index (HH2 image list) - /// - public const int STD_FILE_HH2 = 16; - - /// - /// Constant for standard folder (closed) image index (HH1 image list) - /// - public const int STD_FOLDER_HH1 = 0; - /// - /// Constant for standard folder (opened) image index (HH1 image list) - /// - public const int STD_FOLDER_OPEN_HH1 = 1; - /// - /// Constant for standard file image index (HH1 image list) - /// - public const int STD_FILE_HH1 = 10; - - /// - /// Internal flag specifying the data extraction mode used for this item - /// - private DataMode _tocMode = DataMode.TextBased; - /// - /// Internal member storing the offset (only used in binary tocs) - /// - private int _offset = 0; - /// - /// Internal member storing the offset of the next item(only used in binary tocs) - /// - private int _offsetNext = 0; - /// - /// Internal member storing a merge link. - /// If the target file is in the merged files list of the CHM, - /// this item will be replaced with the target TOC or Topic, if not it will - /// be removed from TOC. - /// - private string _mergeLink = ""; - /// - /// Internal member storing the toc name - /// - private string _name = ""; - /// - /// Internal member storing the toc loca (content file) - /// - private string _local = ""; - /// - /// Internal member storing all associated information type strings - /// - private ArrayList _infoTypeStrings = new ArrayList(); - /// - /// Internal member storing the associated chm file - /// - private string _chmFile = ""; - /// - /// Internal member storing the image index - /// - private int _imageIndex = -1; - /// - /// Internal member storing the offset of the associated topic entry (for binary tocs) - /// - private int _topicOffset = -1; - /// - /// Internal member storing the toc children - /// - private ArrayList _children = new ArrayList(); - /// - /// Internal member storing the parameter collection - /// - private Hashtable _otherParams = new Hashtable(); - /// - /// Internal member storing the associated chmfile object - /// - private CHMFile _associatedFile = null; - /// - /// Parent item - /// - private TOCItem _parent=null; - - /// - /// Holds a pointer to the next item in the TOC - /// - public TOCItem Next=null; - - /// - /// Holds a pointer to the previous item in the TOC - /// - public TOCItem Prev=null; - - /// - /// Holds a pointer to the TreeNode where this TOC Item is used - /// - public System.Windows.Forms.TreeNode treeNode=null; - - /// - /// Constructor of the class used during text-based data extraction - /// - /// name of the item - /// local content file - /// image index - /// associated chm file - public TOCItem(string name, string local, int ImageIndex, string chmFile) - { - _tocMode = DataMode.TextBased; - _name = name; - _local = local; - _imageIndex = ImageIndex; - _chmFile = chmFile; - } - - /// - /// Constructor of the class used during binary data extraction - /// - /// offset of the associated topic entry - /// image index to use - /// associated chm file - public TOCItem(int topicOffset, int ImageIndex, CHMFile associatedFile) - { - _tocMode = DataMode.Binary; - _associatedFile = associatedFile; - _chmFile = associatedFile.ChmFilePath; - _topicOffset = topicOffset; - _imageIndex = ImageIndex; - } - - /// - /// Standard constructor - /// - public TOCItem() - { - } - - #region Data dumping - /// - /// Dump the class data to a binary writer - /// - /// writer to write the data - /// true if the chmfile name should be written - internal void Dump(ref BinaryWriter writer, bool writeFilename) - { - writer.Write((int)_tocMode); - writer.Write(_topicOffset); - writer.Write(_name); - - if((_tocMode == DataMode.TextBased)||(_topicOffset<0)) - { - writer.Write(_local); - } - - writer.Write(_imageIndex); - - writer.Write(_mergeLink); - - if(writeFilename) - writer.Write(_chmFile); - - writer.Write(_infoTypeStrings.Count); - - for(int i=0; i<_infoTypeStrings.Count; i++) - writer.Write( (_infoTypeStrings[i]).ToString() ); - - writer.Write(_children.Count); - - for(int i=0; i<_children.Count; i++) - { - TOCItem child = ((TOCItem)(_children[i])); - child.Dump(ref writer, writeFilename); - } - } - - /// - /// Dump the class data to a binary writer - /// - /// writer to write the data - internal void Dump(ref BinaryWriter writer) - { - Dump(ref writer, false); - } - - /// - /// Reads the object data from a dump store - /// - /// reader to read the data - /// true if the chmfile name should be read - internal void ReadDump(ref BinaryReader reader, bool readFilename) - { - int i=0; - _tocMode = (DataMode)reader.ReadInt32(); - _topicOffset = reader.ReadInt32(); - _name = reader.ReadString(); - - if((_tocMode == DataMode.TextBased)||(_topicOffset<0)) - { - _local = reader.ReadString(); - } - - _imageIndex = reader.ReadInt32(); - - _mergeLink = reader.ReadString(); - - if(readFilename) - _chmFile = reader.ReadString(); - - int nCnt = reader.ReadInt32(); - - for(i=0; i 0) - _associatedFile.MergLinks.Add(child); - } - } - - /// - /// Reads the object data from a dump store - /// - /// reader to read the data - internal void ReadDump(ref BinaryReader reader) - { - ReadDump(ref reader, false); - } - #endregion - - /// - /// Gets/Sets the data extraction mode with which this item was created. - /// - internal DataMode TocMode - { - get { return _tocMode; } - set { _tocMode = value; } - } - - /// - /// Gets/Sets the offset of the associated topic entry - /// - internal int TopicOffset - { - get { return _topicOffset; } - set { _topicOffset = value; } - } - - /// - /// Gets/Sets the associated CHMFile instance - /// - internal CHMFile AssociatedFile - { - get { return _associatedFile; } - set - { - _associatedFile = value; - } - } - - /// - /// Gets/Sets the offset of the item. - /// - /// Only used in binary tocs - internal int Offset - { - get { return _offset; } - set { _offset = value; } - } - - /// - /// Gets/Sets the offset of the next item. - /// - /// Only used in binary tocs - internal int OffsetNext - { - get { return _offsetNext; } - set { _offsetNext = value; } - } - - /// - /// Gets the ArrayList which holds all information types/categories this item is associated - /// - internal ArrayList InfoTypeStrings - { - get { return _infoTypeStrings; } - } - - /// - /// Gets/Sets the parent of this item - /// - public TOCItem Parent - { - get { return _parent; } - set { _parent = value; } - } - - /// - /// Gets/Sets the mergelink for this item. - /// You should not set the mergedlink by your own ! - /// This is only for loading merged CHMs. - /// - public string MergeLink - { - get { return _mergeLink; } - set { _mergeLink = value; } - } - - /// - /// Gets/Sets the name of the item - /// - public string Name - { - get - { - if(_mergeLink.Length > 0) - return ""; - - if(_name.Length <= 0) - { - if((_tocMode == DataMode.Binary )&&(_associatedFile!=null)) - { - if( _topicOffset >= 0) - { - TopicEntry te = (TopicEntry) (_associatedFile.TopicsFile[_topicOffset]); - if(te != null) - { - return te.Title; - } - } - } - } - - return _name; - } - set - { - _name = value; - } - } - - /// - /// Gets/Sets the local of the item - /// - public string Local - { - get - { - if(_mergeLink.Length > 0) - return ""; - - if(_local.Length <= 0) - { - if((_tocMode == DataMode.Binary )&&(_associatedFile!=null)) - { - if( _topicOffset >= 0) - { - TopicEntry te = (TopicEntry) (_associatedFile.TopicsFile[_topicOffset]); - if(te != null) - { - return te.Locale; - } - } - } - } - - return _local; - } - set { _local = value; } - } - - /// - /// Gets/Sets the chm file - /// - public string ChmFile - { - get - { - if(_associatedFile!=null) - return _associatedFile.ChmFilePath; - - return _chmFile; - } - set { _chmFile = value; } - } - - /// - /// Gets the url for the webbrowser for this file - /// - public string Url - { - get - { - string sL = Local; - - if( (sL.ToLower().IndexOf("http://") >= 0) || - (sL.ToLower().IndexOf("https://") >= 0) || - (sL.ToLower().IndexOf("mailto:") >= 0) || - (sL.ToLower().IndexOf("ftp://") >= 0) || - (sL.ToLower().IndexOf("ms-its:") >= 0)) - return sL; - - return HtmlHelpSystem.UrlPrefix + ChmFile + "::/" + sL; - } - } - - /// - /// Gets/Sets the image index of the item - /// - /// Set this to -1 for a default icon - public int ImageIndex - { - get - { - if( _imageIndex == -1) - { - int nFolderAdd = 0; - - if((_associatedFile != null) && (_associatedFile.ImageTypeFolder)) - { - // get the value which should be added, to display folders instead of books - if(HtmlHelpSystem.UseHH2TreePics) - nFolderAdd = 8; - else - nFolderAdd = 4; - } - - - if( _children.Count > 0) - return (HtmlHelpSystem.UseHH2TreePics ? (STD_FOLDER_HH2+nFolderAdd) : (STD_FOLDER_HH1+nFolderAdd)); - - return (HtmlHelpSystem.UseHH2TreePics ? STD_FILE_HH2 : STD_FILE_HH1); - } - return _imageIndex; - } - set { _imageIndex = value; } - } - - /// - /// Gets/Sets the children of this item. - /// - /// Each entry in the ArrayList is of type TOCItem - public ArrayList Children - { - get { return _children; } - set { _children = value; } - } - - /// - /// Gets the internal hashtable storing all params - /// - public Hashtable Params - { - get { return _otherParams; } - } - } -} diff --git a/irc/TechBot/CHMLibrary/TableOfContents.cs b/irc/TechBot/CHMLibrary/TableOfContents.cs deleted file mode 100644 index 68dfb050a6a..00000000000 --- a/irc/TechBot/CHMLibrary/TableOfContents.cs +++ /dev/null @@ -1,198 +0,0 @@ -using System; -using System.Diagnostics; -using System.Collections; -using HtmlHelp.ChmDecoding; - -namespace HtmlHelp -{ - /// - /// The class TableOfContents holds the TOC of the htmlhelp system class. - /// - public class TableOfContents - { - private ArrayList _toc = new ArrayList(); - - /// - /// Standard constructor - /// - public TableOfContents() - { - } - - /// - /// Constructor of the class - /// - /// - public TableOfContents(ArrayList toc) - { - _toc = toc; - } - - /// - /// Gets the internal stored table of contents - /// - public ArrayList TOC - { - get { return _toc; } - } - - /// - /// Clears the current toc - /// - public void Clear() - { - if(_toc!=null) - _toc.Clear(); - } - - /// - /// Gets the number of topics in the toc - /// - /// Returns the number of topics in the toc - public int Count() - { - if(_toc!=null) - return _toc.Count; - else - return 0; - } - - /// - /// Merges the arrToC list to the one in this instance - /// - /// the toc list which should be merged with the current one - internal void MergeToC( ArrayList arrToC ) - { - if(_toc==null) - _toc = new ArrayList(); - - MergeToC(_toc, arrToC, null); - } - - /// - /// Merges the arrToC list to the one in this instance (called if merged files - /// were found in a CHM) - /// - /// the toc list which should be merged with the current one - /// An arraylist of CHMFile instances. - internal void MergeToC( ArrayList arrToC, ArrayList openFiles ) - { - if(_toc==null) - _toc = new ArrayList(); - MergeToC(_toc, arrToC, openFiles); - } - - /// - /// Internal method for recursive toc merging - /// - /// level of global toc - /// level of local toc - /// An arraylist of CHMFile instances. - private void MergeToC( ArrayList globalLevel, ArrayList localLevel, ArrayList openFiles ) - { - foreach( TOCItem curItem in localLevel) - { - // if it is a part of the merged-links, we have to do nothing, - // because the method HtmlHelpSystem.RecalculateMergeLinks() has already - // placed this item at its correct position. - if(!IsMergedItem(curItem.Name, curItem.Local, openFiles)) - { - TOCItem globalItem = ContainsToC(globalLevel, curItem.Name); - if(globalItem == null) - { - // the global toc doesn't have a topic with this name - // so we need to add the complete toc node to the global toc - - globalLevel.Add( curItem ); - } - else - { - // the global toc contains the current topic - // advance to the next level - - if( (globalItem.Local.Length <= 0) && (curItem.Local.Length > 0) ) - { - // set the associated url - globalItem.Local = curItem.Local; - globalItem.ChmFile = curItem.ChmFile; - } - - MergeToC(globalItem.Children, curItem.Children); - } - } - } - } - - /// - /// Checks if the item is part of the merged-links - /// - /// name of the topic - /// local of the topic - /// An arraylist of CHMFile instances. - /// Returns true if this item is part of the merged-links - private bool IsMergedItem(string name, string local, ArrayList openFiles) - { - if(openFiles==null) - return false; - - foreach(CHMFile curFile in openFiles) - { - foreach(TOCItem curItem in curFile.MergLinks) - if( (curItem.Name == name) && (curItem.Local == local) ) - return true; - } - return false; - } - - /// - /// Checks if a topicname exists in a SINGLE toc level - /// - /// toc list - /// topic to search - /// Returns the topic item if found, otherwise null - private TOCItem ContainsToC(ArrayList arrToC, string Topic) - { - foreach(TOCItem curItem in arrToC) - { - if(curItem.Name == Topic) - return curItem; - } - - return null; - } - - /// - /// Searches the table of contents for a special topic - /// - /// topic to search - /// Returns an instance of TOCItem if found, otherwise null - public TOCItem SearchTopic(string topic) - { - return SearchTopic(topic, _toc); - } - - /// - /// Internal recursive tree search - /// - /// topic to search - /// tree level list to look in - /// Returns an instance of TOCItem if found, otherwise null - private TOCItem SearchTopic(string topic, ArrayList searchIn) - { - foreach(TOCItem curItem in searchIn) - { - if(curItem.Name.ToLower() == topic.ToLower() ) - return curItem; - - if(curItem.Children.Count>0) - { - TOCItem nf = SearchTopic(topic, curItem.Children); - if(nf != null) - return nf; - } - } - - return null; - } - } -} diff --git a/irc/TechBot/Compression/AssemblyInfo.cs b/irc/TechBot/Compression/AssemblyInfo.cs deleted file mode 100644 index dbacda112e8..00000000000 --- a/irc/TechBot/Compression/AssemblyInfo.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; - -// Information about this assembly is defined by the following -// attributes. -// -// change them to the information which is associated with the assembly -// you compile. - -[assembly: AssemblyTitle("")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("")] -[assembly: AssemblyCopyright("")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// The assembly version has following format : -// -// Major.Minor.Build.Revision -// -// You can specify all values by your own or you can build default build and revision -// numbers with the '*' character (the default): - -[assembly: AssemblyVersion("1.0.*")] - -// The following attributes specify the key for the sign of your assembly. See the -// .NET Framework documentation for more information about signing. -// This is not required, if you don't want signing let these attributes like they're. -[assembly: AssemblyDelaySign(false)] -[assembly: AssemblyKeyFile("")] diff --git a/irc/TechBot/Compression/Checksums/Adler32.cs b/irc/TechBot/Compression/Checksums/Adler32.cs deleted file mode 100644 index 220dcbafa0c..00000000000 --- a/irc/TechBot/Compression/Checksums/Adler32.cs +++ /dev/null @@ -1,200 +0,0 @@ -// Adler32.cs - Computes Adler32 data checksum of a data stream -// Copyright (C) 2001 Mike Krueger -// -// This file was translated from java, it was part of the GNU Classpath -// Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc. -// -// 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -// -// Linking this library statically or dynamically with other modules is -// making a combined work based on this library. Thus, the terms and -// conditions of the GNU General Public License cover the whole -// combination. -// -// As a special exception, the copyright holders of this library give you -// permission to link this library with independent modules to produce an -// executable, regardless of the license terms of these independent -// modules, and to copy and distribute the resulting executable under -// terms of your choice, provided that you also meet, for each linked -// independent module, the terms and conditions of the license of that -// module. An independent module is a module which is not derived from -// or based on this library. If you modify this library, you may extend -// this exception to your version of the library, but you are not -// obligated to do so. If you do not wish to do so, delete this -// exception statement from your version. - -using System; - -namespace ICSharpCode.SharpZipLib.Checksums -{ - - /// - /// Computes Adler32 checksum for a stream of data. An Adler32 - /// checksum is not as reliable as a CRC32 checksum, but a lot faster to - /// compute. - /// - /// The specification for Adler32 may be found in RFC 1950. - /// ZLIB Compressed Data Format Specification version 3.3) - /// - /// - /// From that document: - /// - /// "ADLER32 (Adler-32 checksum) - /// This contains a checksum value of the uncompressed data - /// (excluding any dictionary data) computed according to Adler-32 - /// algorithm. This algorithm is a 32-bit extension and improvement - /// of the Fletcher algorithm, used in the ITU-T X.224 / ISO 8073 - /// standard. - /// - /// Adler-32 is composed of two sums accumulated per byte: s1 is - /// the sum of all bytes, s2 is the sum of all s1 values. Both sums - /// are done modulo 65521. s1 is initialized to 1, s2 to zero. The - /// Adler-32 checksum is stored as s2*65536 + s1 in most- - /// significant-byte first (network) order." - /// - /// "8.2. The Adler-32 algorithm - /// - /// The Adler-32 algorithm is much faster than the CRC32 algorithm yet - /// still provides an extremely low probability of undetected errors. - /// - /// The modulo on unsigned long accumulators can be delayed for 5552 - /// bytes, so the modulo operation time is negligible. If the bytes - /// are a, b, c, the second sum is 3a + 2b + c + 3, and so is position - /// and order sensitive, unlike the first sum, which is just a - /// checksum. That 65521 is prime is important to avoid a possible - /// large class of two-byte errors that leave the check unchanged. - /// (The Fletcher checksum uses 255, which is not prime and which also - /// makes the Fletcher check insensitive to single byte changes 0 - - /// 255.) - /// - /// The sum s1 is initialized to 1 instead of zero to make the length - /// of the sequence part of s2, so that the length does not have to be - /// checked separately. (Any sequence of zeroes has a Fletcher - /// checksum of zero.)" - /// - /// - /// - public sealed class Adler32 : IChecksum - { - /// - /// largest prime smaller than 65536 - /// - readonly static uint BASE = 65521; - - uint checksum; - - /// - /// Returns the Adler32 data checksum computed so far. - /// - public long Value { - get { - return checksum; - } - } - - /// - /// Creates a new instance of the Adler32 class. - /// The checksum starts off with a value of 1. - /// - public Adler32() - { - Reset(); - } - - /// - /// Resets the Adler32 checksum to the initial value. - /// - public void Reset() - { - checksum = 1; //Initialize to 1 - } - - /// - /// Updates the checksum with the byte b. - /// - /// - /// the data value to add. The high byte of the int is ignored. - /// - public void Update(int bval) - { - //We could make a length 1 byte array and call update again, but I - //would rather not have that overhead - uint s1 = checksum & 0xFFFF; - uint s2 = checksum >> 16; - - s1 = (s1 + ((uint)bval & 0xFF)) % BASE; - s2 = (s1 + s2) % BASE; - - checksum = (s2 << 16) + s1; - } - - /// - /// Updates the checksum with the bytes taken from the array. - /// - /// - /// buffer an array of bytes - /// - public void Update(byte[] buffer) - { - Update(buffer, 0, buffer.Length); - } - - /// - /// Updates the checksum with the bytes taken from the array. - /// - /// - /// an array of bytes - /// - /// - /// the start of the data used for this update - /// - /// - /// the number of bytes to use for this update - /// - public void Update(byte[] buf, int off, int len) - { - if (buf == null) { - throw new ArgumentNullException("buf"); - } - - if (off < 0 || len < 0 || off + len > buf.Length) { - throw new ArgumentOutOfRangeException(); - } - - //(By Per Bothner) - uint s1 = checksum & 0xFFFF; - uint s2 = checksum >> 16; - - while (len > 0) { - // We can defer the modulo operation: - // s1 maximally grows from 65521 to 65521 + 255 * 3800 - // s2 maximally grows by 3800 * median(s1) = 2090079800 < 2^31 - int n = 3800; - if (n > len) { - n = len; - } - len -= n; - while (--n >= 0) { - s1 = s1 + (uint)(buf[off++] & 0xFF); - s2 = s2 + s1; - } - s1 %= BASE; - s2 %= BASE; - } - - checksum = (s2 << 16) | s1; - } - } -} diff --git a/irc/TechBot/Compression/Checksums/CRC32.cs b/irc/TechBot/Compression/Checksums/CRC32.cs deleted file mode 100644 index a78ad4c29f6..00000000000 --- a/irc/TechBot/Compression/Checksums/CRC32.cs +++ /dev/null @@ -1,211 +0,0 @@ -// CRC32.cs - Computes CRC32 data checksum of a data stream -// Copyright (C) 2001 Mike Krueger -// -// This file was translated from java, it was part of the GNU Classpath -// Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc. -// -// 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -// -// Linking this library statically or dynamically with other modules is -// making a combined work based on this library. Thus, the terms and -// conditions of the GNU General Public License cover the whole -// combination. -// -// As a special exception, the copyright holders of this library give you -// permission to link this library with independent modules to produce an -// executable, regardless of the license terms of these independent -// modules, and to copy and distribute the resulting executable under -// terms of your choice, provided that you also meet, for each linked -// independent module, the terms and conditions of the license of that -// module. An independent module is a module which is not derived from -// or based on this library. If you modify this library, you may extend -// this exception to your version of the library, but you are not -// obligated to do so. If you do not wish to do so, delete this -// exception statement from your version. - -using System; - -namespace ICSharpCode.SharpZipLib.Checksums -{ - - /// - /// Generate a table for a byte-wise 32-bit CRC calculation on the polynomial: - /// x^32+x^26+x^23+x^22+x^16+x^12+x^11+x^10+x^8+x^7+x^5+x^4+x^2+x+1. - /// - /// Polynomials over GF(2) are represented in binary, one bit per coefficient, - /// with the lowest powers in the most significant bit. Then adding polynomials - /// is just exclusive-or, and multiplying a polynomial by x is a right shift by - /// one. If we call the above polynomial p, and represent a byte as the - /// polynomial q, also with the lowest power in the most significant bit (so the - /// byte 0xb1 is the polynomial x^7+x^3+x+1), then the CRC is (q*x^32) mod p, - /// where a mod b means the remainder after dividing a by b. - /// - /// This calculation is done using the shift-register method of multiplying and - /// taking the remainder. The register is initialized to zero, and for each - /// incoming bit, x^32 is added mod p to the register if the bit is a one (where - /// x^32 mod p is p+x^32 = x^26+...+1), and the register is multiplied mod p by - /// x (which is shifting right by one and adding x^32 mod p if the bit shifted - /// out is a one). We start with the highest power (least significant bit) of - /// q and repeat for all eight bits of q. - /// - /// The table is simply the CRC of all possible eight bit values. This is all - /// the information needed to generate CRC's on data a byte at a time for all - /// combinations of CRC register values and incoming bytes. - /// - public sealed class Crc32 : IChecksum - { - readonly static uint CrcSeed = 0xFFFFFFFF; - - readonly static uint[] CrcTable = new uint[] { - 0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA, 0x076DC419, - 0x706AF48F, 0xE963A535, 0x9E6495A3, 0x0EDB8832, 0x79DCB8A4, - 0xE0D5E91E, 0x97D2D988, 0x09B64C2B, 0x7EB17CBD, 0xE7B82D07, - 0x90BF1D91, 0x1DB71064, 0x6AB020F2, 0xF3B97148, 0x84BE41DE, - 0x1ADAD47D, 0x6DDDE4EB, 0xF4D4B551, 0x83D385C7, 0x136C9856, - 0x646BA8C0, 0xFD62F97A, 0x8A65C9EC, 0x14015C4F, 0x63066CD9, - 0xFA0F3D63, 0x8D080DF5, 0x3B6E20C8, 0x4C69105E, 0xD56041E4, - 0xA2677172, 0x3C03E4D1, 0x4B04D447, 0xD20D85FD, 0xA50AB56B, - 0x35B5A8FA, 0x42B2986C, 0xDBBBC9D6, 0xACBCF940, 0x32D86CE3, - 0x45DF5C75, 0xDCD60DCF, 0xABD13D59, 0x26D930AC, 0x51DE003A, - 0xC8D75180, 0xBFD06116, 0x21B4F4B5, 0x56B3C423, 0xCFBA9599, - 0xB8BDA50F, 0x2802B89E, 0x5F058808, 0xC60CD9B2, 0xB10BE924, - 0x2F6F7C87, 0x58684C11, 0xC1611DAB, 0xB6662D3D, 0x76DC4190, - 0x01DB7106, 0x98D220BC, 0xEFD5102A, 0x71B18589, 0x06B6B51F, - 0x9FBFE4A5, 0xE8B8D433, 0x7807C9A2, 0x0F00F934, 0x9609A88E, - 0xE10E9818, 0x7F6A0DBB, 0x086D3D2D, 0x91646C97, 0xE6635C01, - 0x6B6B51F4, 0x1C6C6162, 0x856530D8, 0xF262004E, 0x6C0695ED, - 0x1B01A57B, 0x8208F4C1, 0xF50FC457, 0x65B0D9C6, 0x12B7E950, - 0x8BBEB8EA, 0xFCB9887C, 0x62DD1DDF, 0x15DA2D49, 0x8CD37CF3, - 0xFBD44C65, 0x4DB26158, 0x3AB551CE, 0xA3BC0074, 0xD4BB30E2, - 0x4ADFA541, 0x3DD895D7, 0xA4D1C46D, 0xD3D6F4FB, 0x4369E96A, - 0x346ED9FC, 0xAD678846, 0xDA60B8D0, 0x44042D73, 0x33031DE5, - 0xAA0A4C5F, 0xDD0D7CC9, 0x5005713C, 0x270241AA, 0xBE0B1010, - 0xC90C2086, 0x5768B525, 0x206F85B3, 0xB966D409, 0xCE61E49F, - 0x5EDEF90E, 0x29D9C998, 0xB0D09822, 0xC7D7A8B4, 0x59B33D17, - 0x2EB40D81, 0xB7BD5C3B, 0xC0BA6CAD, 0xEDB88320, 0x9ABFB3B6, - 0x03B6E20C, 0x74B1D29A, 0xEAD54739, 0x9DD277AF, 0x04DB2615, - 0x73DC1683, 0xE3630B12, 0x94643B84, 0x0D6D6A3E, 0x7A6A5AA8, - 0xE40ECF0B, 0x9309FF9D, 0x0A00AE27, 0x7D079EB1, 0xF00F9344, - 0x8708A3D2, 0x1E01F268, 0x6906C2FE, 0xF762575D, 0x806567CB, - 0x196C3671, 0x6E6B06E7, 0xFED41B76, 0x89D32BE0, 0x10DA7A5A, - 0x67DD4ACC, 0xF9B9DF6F, 0x8EBEEFF9, 0x17B7BE43, 0x60B08ED5, - 0xD6D6A3E8, 0xA1D1937E, 0x38D8C2C4, 0x4FDFF252, 0xD1BB67F1, - 0xA6BC5767, 0x3FB506DD, 0x48B2364B, 0xD80D2BDA, 0xAF0A1B4C, - 0x36034AF6, 0x41047A60, 0xDF60EFC3, 0xA867DF55, 0x316E8EEF, - 0x4669BE79, 0xCB61B38C, 0xBC66831A, 0x256FD2A0, 0x5268E236, - 0xCC0C7795, 0xBB0B4703, 0x220216B9, 0x5505262F, 0xC5BA3BBE, - 0xB2BD0B28, 0x2BB45A92, 0x5CB36A04, 0xC2D7FFA7, 0xB5D0CF31, - 0x2CD99E8B, 0x5BDEAE1D, 0x9B64C2B0, 0xEC63F226, 0x756AA39C, - 0x026D930A, 0x9C0906A9, 0xEB0E363F, 0x72076785, 0x05005713, - 0x95BF4A82, 0xE2B87A14, 0x7BB12BAE, 0x0CB61B38, 0x92D28E9B, - 0xE5D5BE0D, 0x7CDCEFB7, 0x0BDBDF21, 0x86D3D2D4, 0xF1D4E242, - 0x68DDB3F8, 0x1FDA836E, 0x81BE16CD, 0xF6B9265B, 0x6FB077E1, - 0x18B74777, 0x88085AE6, 0xFF0F6A70, 0x66063BCA, 0x11010B5C, - 0x8F659EFF, 0xF862AE69, 0x616BFFD3, 0x166CCF45, 0xA00AE278, - 0xD70DD2EE, 0x4E048354, 0x3903B3C2, 0xA7672661, 0xD06016F7, - 0x4969474D, 0x3E6E77DB, 0xAED16A4A, 0xD9D65ADC, 0x40DF0B66, - 0x37D83BF0, 0xA9BCAE53, 0xDEBB9EC5, 0x47B2CF7F, 0x30B5FFE9, - 0xBDBDF21C, 0xCABAC28A, 0x53B39330, 0x24B4A3A6, 0xBAD03605, - 0xCDD70693, 0x54DE5729, 0x23D967BF, 0xB3667A2E, 0xC4614AB8, - 0x5D681B02, 0x2A6F2B94, 0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B, - 0x2D02EF8D - }; - - internal static uint ComputeCrc32(uint oldCrc, byte bval) - { - return (uint)(Crc32.CrcTable[(oldCrc ^ bval) & 0xFF] ^ (oldCrc >> 8)); - } - - /// - /// The crc data checksum so far. - /// - uint crc = 0; - - /// - /// Returns the CRC32 data checksum computed so far. - /// - public long Value { - get { - return (long)crc; - } - set { - crc = (uint)value; - } - } - - /// - /// Resets the CRC32 data checksum as if no update was ever called. - /// - public void Reset() - { - crc = 0; - } - - /// - /// Updates the checksum with the int bval. - /// - /// - /// the byte is taken as the lower 8 bits of bval - /// - public void Update(int bval) - { - crc ^= CrcSeed; - crc = CrcTable[(crc ^ bval) & 0xFF] ^ (crc >> 8); - crc ^= CrcSeed; - } - - /// - /// Updates the checksum with the bytes taken from the array. - /// - /// - /// buffer an array of bytes - /// - public void Update(byte[] buffer) - { - Update(buffer, 0, buffer.Length); - } - - /// - /// Adds the byte array to the data checksum. - /// - /// - /// the buffer which contains the data - /// - /// - /// the offset in the buffer where the data starts - /// - /// - /// the length of the data - /// - public void Update(byte[] buf, int off, int len) - { - if (buf == null) { - throw new ArgumentNullException("buf"); - } - - if (off < 0 || len < 0 || off + len > buf.Length) { - throw new ArgumentOutOfRangeException(); - } - - crc ^= CrcSeed; - - while (--len >= 0) { - crc = CrcTable[(crc ^ buf[off++]) & 0xFF] ^ (crc >> 8); - } - - crc ^= CrcSeed; - } - } -} diff --git a/irc/TechBot/Compression/Checksums/IChecksum.cs b/irc/TechBot/Compression/Checksums/IChecksum.cs deleted file mode 100644 index 98385b316ac..00000000000 --- a/irc/TechBot/Compression/Checksums/IChecksum.cs +++ /dev/null @@ -1,93 +0,0 @@ -// IChecksum.cs - Interface to compute a data checksum -// Copyright (C) 2001 Mike Krueger -// -// This file was translated from java, it was part of the GNU Classpath -// Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc. -// -// 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -// -// Linking this library statically or dynamically with other modules is -// making a combined work based on this library. Thus, the terms and -// conditions of the GNU General Public License cover the whole -// combination. -// -// As a special exception, the copyright holders of this library give you -// permission to link this library with independent modules to produce an -// executable, regardless of the license terms of these independent -// modules, and to copy and distribute the resulting executable under -// terms of your choice, provided that you also meet, for each linked -// independent module, the terms and conditions of the license of that -// module. An independent module is a module which is not derived from -// or based on this library. If you modify this library, you may extend -// this exception to your version of the library, but you are not -// obligated to do so. If you do not wish to do so, delete this -// exception statement from your version. - -namespace ICSharpCode.SharpZipLib.Checksums -{ - - /// - /// Interface to compute a data checksum used by checked input/output streams. - /// A data checksum can be updated by one byte or with a byte array. After each - /// update the value of the current checksum can be returned by calling - /// getValue. The complete checksum object can also be reset - /// so it can be used again with new data. - /// - public interface IChecksum - { - /// - /// Returns the data checksum computed so far. - /// - long Value - { - get; - } - - /// - /// Resets the data checksum as if no update was ever called. - /// - void Reset(); - - /// - /// Adds one byte to the data checksum. - /// - /// - /// the data value to add. The high byte of the int is ignored. - /// - void Update(int bval); - - /// - /// Updates the data checksum with the bytes taken from the array. - /// - /// - /// buffer an array of bytes - /// - void Update(byte[] buffer); - - /// - /// Adds the byte array to the data checksum. - /// - /// - /// the buffer which contains the data - /// - /// - /// the offset in the buffer where the data starts - /// - /// - /// the length of the data - /// - void Update(byte[] buf, int off, int len); - } -} diff --git a/irc/TechBot/Compression/Checksums/StrangeCRC.cs b/irc/TechBot/Compression/Checksums/StrangeCRC.cs deleted file mode 100644 index a2dc10fcf12..00000000000 --- a/irc/TechBot/Compression/Checksums/StrangeCRC.cs +++ /dev/null @@ -1,159 +0,0 @@ -// StrangeCRC.cs - computes a crc used in the bziplib ... I don't think that -// this is the 'standard' crc, please correct me, if I'm wrong -// Copyright (C) 2001 Mike Krueger -// -// This file was translated from java, it was part of the GNU Classpath -// Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc. -// -// 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -// -// Linking this library statically or dynamically with other modules is -// making a combined work based on this library. Thus, the terms and -// conditions of the GNU General Public License cover the whole -// combination. -// -// As a special exception, the copyright holders of this library give you -// permission to link this library with independent modules to produce an -// executable, regardless of the license terms of these independent -// modules, and to copy and distribute the resulting executable under -// terms of your choice, provided that you also meet, for each linked -// independent module, the terms and conditions of the license of that -// module. An independent module is a module which is not derived from -// or based on this library. If you modify this library, you may extend -// this exception to your version of the library, but you are not -// obligated to do so. If you do not wish to do so, delete this -// exception statement from your version. - -using System; - -namespace ICSharpCode.SharpZipLib.Checksums -{ - - public class StrangeCRC : IChecksum - { - readonly static uint[] crc32Table = { - 0x00000000, 0x04c11db7, 0x09823b6e, 0x0d4326d9, - 0x130476dc, 0x17c56b6b, 0x1a864db2, 0x1e475005, - 0x2608edb8, 0x22c9f00f, 0x2f8ad6d6, 0x2b4bcb61, - 0x350c9b64, 0x31cd86d3, 0x3c8ea00a, 0x384fbdbd, - 0x4c11db70, 0x48d0c6c7, 0x4593e01e, 0x4152fda9, - 0x5f15adac, 0x5bd4b01b, 0x569796c2, 0x52568b75, - 0x6a1936c8, 0x6ed82b7f, 0x639b0da6, 0x675a1011, - 0x791d4014, 0x7ddc5da3, 0x709f7b7a, 0x745e66cd, - 0x9823b6e0, 0x9ce2ab57, 0x91a18d8e, 0x95609039, - 0x8b27c03c, 0x8fe6dd8b, 0x82a5fb52, 0x8664e6e5, - 0xbe2b5b58, 0xbaea46ef, 0xb7a96036, 0xb3687d81, - 0xad2f2d84, 0xa9ee3033, 0xa4ad16ea, 0xa06c0b5d, - 0xd4326d90, 0xd0f37027, 0xddb056fe, 0xd9714b49, - 0xc7361b4c, 0xc3f706fb, 0xceb42022, 0xca753d95, - 0xf23a8028, 0xf6fb9d9f, 0xfbb8bb46, 0xff79a6f1, - 0xe13ef6f4, 0xe5ffeb43, 0xe8bccd9a, 0xec7dd02d, - 0x34867077, 0x30476dc0, 0x3d044b19, 0x39c556ae, - 0x278206ab, 0x23431b1c, 0x2e003dc5, 0x2ac12072, - 0x128e9dcf, 0x164f8078, 0x1b0ca6a1, 0x1fcdbb16, - 0x018aeb13, 0x054bf6a4, 0x0808d07d, 0x0cc9cdca, - 0x7897ab07, 0x7c56b6b0, 0x71159069, 0x75d48dde, - 0x6b93dddb, 0x6f52c06c, 0x6211e6b5, 0x66d0fb02, - 0x5e9f46bf, 0x5a5e5b08, 0x571d7dd1, 0x53dc6066, - 0x4d9b3063, 0x495a2dd4, 0x44190b0d, 0x40d816ba, - 0xaca5c697, 0xa864db20, 0xa527fdf9, 0xa1e6e04e, - 0xbfa1b04b, 0xbb60adfc, 0xb6238b25, 0xb2e29692, - 0x8aad2b2f, 0x8e6c3698, 0x832f1041, 0x87ee0df6, - 0x99a95df3, 0x9d684044, 0x902b669d, 0x94ea7b2a, - 0xe0b41de7, 0xe4750050, 0xe9362689, 0xedf73b3e, - 0xf3b06b3b, 0xf771768c, 0xfa325055, 0xfef34de2, - 0xc6bcf05f, 0xc27dede8, 0xcf3ecb31, 0xcbffd686, - 0xd5b88683, 0xd1799b34, 0xdc3abded, 0xd8fba05a, - 0x690ce0ee, 0x6dcdfd59, 0x608edb80, 0x644fc637, - 0x7a089632, 0x7ec98b85, 0x738aad5c, 0x774bb0eb, - 0x4f040d56, 0x4bc510e1, 0x46863638, 0x42472b8f, - 0x5c007b8a, 0x58c1663d, 0x558240e4, 0x51435d53, - 0x251d3b9e, 0x21dc2629, 0x2c9f00f0, 0x285e1d47, - 0x36194d42, 0x32d850f5, 0x3f9b762c, 0x3b5a6b9b, - 0x0315d626, 0x07d4cb91, 0x0a97ed48, 0x0e56f0ff, - 0x1011a0fa, 0x14d0bd4d, 0x19939b94, 0x1d528623, - 0xf12f560e, 0xf5ee4bb9, 0xf8ad6d60, 0xfc6c70d7, - 0xe22b20d2, 0xe6ea3d65, 0xeba91bbc, 0xef68060b, - 0xd727bbb6, 0xd3e6a601, 0xdea580d8, 0xda649d6f, - 0xc423cd6a, 0xc0e2d0dd, 0xcda1f604, 0xc960ebb3, - 0xbd3e8d7e, 0xb9ff90c9, 0xb4bcb610, 0xb07daba7, - 0xae3afba2, 0xaafbe615, 0xa7b8c0cc, 0xa379dd7b, - 0x9b3660c6, 0x9ff77d71, 0x92b45ba8, 0x9675461f, - 0x8832161a, 0x8cf30bad, 0x81b02d74, 0x857130c3, - 0x5d8a9099, 0x594b8d2e, 0x5408abf7, 0x50c9b640, - 0x4e8ee645, 0x4a4ffbf2, 0x470cdd2b, 0x43cdc09c, - 0x7b827d21, 0x7f436096, 0x7200464f, 0x76c15bf8, - 0x68860bfd, 0x6c47164a, 0x61043093, 0x65c52d24, - 0x119b4be9, 0x155a565e, 0x18197087, 0x1cd86d30, - 0x029f3d35, 0x065e2082, 0x0b1d065b, 0x0fdc1bec, - 0x3793a651, 0x3352bbe6, 0x3e119d3f, 0x3ad08088, - 0x2497d08d, 0x2056cd3a, 0x2d15ebe3, 0x29d4f654, - 0xc5a92679, 0xc1683bce, 0xcc2b1d17, 0xc8ea00a0, - 0xd6ad50a5, 0xd26c4d12, 0xdf2f6bcb, 0xdbee767c, - 0xe3a1cbc1, 0xe760d676, 0xea23f0af, 0xeee2ed18, - 0xf0a5bd1d, 0xf464a0aa, 0xf9278673, 0xfde69bc4, - 0x89b8fd09, 0x8d79e0be, 0x803ac667, 0x84fbdbd0, - 0x9abc8bd5, 0x9e7d9662, 0x933eb0bb, 0x97ffad0c, - 0xafb010b1, 0xab710d06, 0xa6322bdf, 0xa2f33668, - 0xbcb4666d, 0xb8757bda, 0xb5365d03, 0xb1f740b4 - }; - int globalCrc; - - public StrangeCRC() - { - Reset(); - } - - public void Reset() - { - globalCrc = -1; - } - - public long Value { - get { - return ~globalCrc; - } - } - - public void Update(int inCh) - { - int temp = (globalCrc >> 24) ^ inCh; - if (temp < 0) { - temp = 256 + temp; - } - globalCrc = (int)((globalCrc << 8) ^ crc32Table[temp]); - } - - public void Update(byte[] buf) - { - Update(buf, 0, buf.Length); - } - - public void Update(byte[] buf, int off, int len) - { - if (buf == null) { - throw new ArgumentNullException("buf"); - } - - if (off < 0 || len < 0 || off + len > buf.Length) { - throw new ArgumentOutOfRangeException(); - } - - for (int i = 0; i < len; ++i) { - Update(buf[off++]); - } - } - } -} diff --git a/irc/TechBot/Compression/Compression.cmbx b/irc/TechBot/Compression/Compression.cmbx deleted file mode 100644 index 28d8e0cd398..00000000000 --- a/irc/TechBot/Compression/Compression.cmbx +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/irc/TechBot/Compression/Compression.csproj b/irc/TechBot/Compression/Compression.csproj deleted file mode 100644 index 8e6fb7ef92e..00000000000 --- a/irc/TechBot/Compression/Compression.csproj +++ /dev/null @@ -1,65 +0,0 @@ - - - - Debug - AnyCPU - 8.0.50727 - 2.0 - {E32307F1-623A-4E62-826F-56CDD4B23A54} - Library - Properties - Compression - Compression - - - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/irc/TechBot/Compression/Compression.prjx b/irc/TechBot/Compression/Compression.prjx deleted file mode 100644 index 95316d15b26..00000000000 --- a/irc/TechBot/Compression/Compression.prjx +++ /dev/null @@ -1,45 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/irc/TechBot/Compression/Default.build b/irc/TechBot/Compression/Default.build deleted file mode 100644 index 5a229e272d6..00000000000 --- a/irc/TechBot/Compression/Default.build +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/irc/TechBot/Compression/Deflater.cs b/irc/TechBot/Compression/Deflater.cs deleted file mode 100644 index bb8d4cc3ca8..00000000000 --- a/irc/TechBot/Compression/Deflater.cs +++ /dev/null @@ -1,542 +0,0 @@ -// Deflater.cs -// Copyright (C) 2001 Mike Krueger -// -// This file was translated from java, it was part of the GNU Classpath -// Copyright (C) 2001 Free Software Foundation, Inc. -// -// 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -// -// Linking this library statically or dynamically with other modules is -// making a combined work based on this library. Thus, the terms and -// conditions of the GNU General Public License cover the whole -// combination. -// -// As a special exception, the copyright holders of this library give you -// permission to link this library with independent modules to produce an -// executable, regardless of the license terms of these independent -// modules, and to copy and distribute the resulting executable under -// terms of your choice, provided that you also meet, for each linked -// independent module, the terms and conditions of the license of that -// module. An independent module is a module which is not derived from -// or based on this library. If you modify this library, you may extend -// this exception to your version of the library, but you are not -// obligated to do so. If you do not wish to do so, delete this -// exception statement from your version. - -using System; - -namespace ICSharpCode.SharpZipLib.Zip.Compression -{ - - /// - /// This is the Deflater class. The deflater class compresses input - /// with the deflate algorithm described in RFC 1951. It has several - /// compression levels and three different strategies described below. - /// - /// This class is not thread safe. This is inherent in the API, due - /// to the split of deflate and setInput. - /// - /// author of the original java version : Jochen Hoenicke - /// - public class Deflater - { - /// - /// The best and slowest compression level. This tries to find very - /// long and distant string repetitions. - /// - public static int BEST_COMPRESSION = 9; - - /// - /// The worst but fastest compression level. - /// - public static int BEST_SPEED = 1; - - /// - /// The default compression level. - /// - public static int DEFAULT_COMPRESSION = -1; - - /// - /// This level won't compress at all but output uncompressed blocks. - /// - public static int NO_COMPRESSION = 0; - - /// - /// The compression method. This is the only method supported so far. - /// There is no need to use this constant at all. - /// - public static int DEFLATED = 8; - - /* - * The Deflater can do the following state transitions: - * - * (1) -> INIT_STATE ----> INIT_FINISHING_STATE ---. - * / | (2) (5) | - * / v (5) | - * (3)| SETDICT_STATE ---> SETDICT_FINISHING_STATE |(3) - * \ | (3) | ,-------' - * | | | (3) / - * v v (5) v v - * (1) -> BUSY_STATE ----> FINISHING_STATE - * | (6) - * v - * FINISHED_STATE - * \_____________________________________/ - * | (7) - * v - * CLOSED_STATE - * - * (1) If we should produce a header we start in INIT_STATE, otherwise - * we start in BUSY_STATE. - * (2) A dictionary may be set only when we are in INIT_STATE, then - * we change the state as indicated. - * (3) Whether a dictionary is set or not, on the first call of deflate - * we change to BUSY_STATE. - * (4) -- intentionally left blank -- :) - * (5) FINISHING_STATE is entered, when flush() is called to indicate that - * there is no more INPUT. There are also states indicating, that - * the header wasn't written yet. - * (6) FINISHED_STATE is entered, when everything has been flushed to the - * internal pending output buffer. - * (7) At any time (7) - * - */ - - private static int IS_SETDICT = 0x01; - private static int IS_FLUSHING = 0x04; - private static int IS_FINISHING = 0x08; - - private static int INIT_STATE = 0x00; - private static int SETDICT_STATE = 0x01; - // private static int INIT_FINISHING_STATE = 0x08; - // private static int SETDICT_FINISHING_STATE = 0x09; - private static int BUSY_STATE = 0x10; - private static int FLUSHING_STATE = 0x14; - private static int FINISHING_STATE = 0x1c; - private static int FINISHED_STATE = 0x1e; - private static int CLOSED_STATE = 0x7f; - - /// - /// Compression level. - /// - private int level; - - /// - /// should we include a header. - /// - private bool noHeader; - - // /// - // /// Compression strategy. - // /// - // private int strategy; - - /// - /// The current state. - /// - private int state; - - /// - /// The total bytes of output written. - /// - private int totalOut; - - /// - /// The pending output. - /// - private DeflaterPending pending; - - /// - /// The deflater engine. - /// - private DeflaterEngine engine; - - /// - /// Creates a new deflater with default compression level. - /// - public Deflater() : this(DEFAULT_COMPRESSION, false) - { - - } - - /// - /// Creates a new deflater with given compression level. - /// - /// - /// the compression level, a value between NO_COMPRESSION - /// and BEST_COMPRESSION, or DEFAULT_COMPRESSION. - /// - /// if lvl is out of range. - public Deflater(int lvl) : this(lvl, false) - { - - } - - /// - /// Creates a new deflater with given compression level. - /// - /// - /// the compression level, a value between NO_COMPRESSION - /// and BEST_COMPRESSION. - /// - /// - /// true, if we should suppress the deflate header at the - /// beginning and the adler checksum at the end of the output. This is - /// useful for the GZIP format. - /// - /// if lvl is out of range. - public Deflater(int lvl, bool nowrap) - { - if (lvl == DEFAULT_COMPRESSION) { - lvl = 6; - } else if (lvl < NO_COMPRESSION || lvl > BEST_COMPRESSION) { - throw new ArgumentOutOfRangeException("lvl"); - } - - pending = new DeflaterPending(); - engine = new DeflaterEngine(pending); - this.noHeader = nowrap; - SetStrategy(DeflateStrategy.Default); - SetLevel(lvl); - Reset(); - } - - - /// - /// Resets the deflater. The deflater acts afterwards as if it was - /// just created with the same compression level and strategy as it - /// had before. - /// - public void Reset() - { - state = (noHeader ? BUSY_STATE : INIT_STATE); - totalOut = 0; - pending.Reset(); - engine.Reset(); - } - - /// - /// Gets the current adler checksum of the data that was processed so far. - /// - public int Adler { - get { - return engine.Adler; - } - } - - /// - /// Gets the number of input bytes processed so far. - /// - public int TotalIn { - get { - return engine.TotalIn; - } - } - - /// - /// Gets the number of output bytes so far. - /// - public int TotalOut { - get { - return totalOut; - } - } - - /// - /// Flushes the current input block. Further calls to deflate() will - /// produce enough output to inflate everything in the current input - /// block. This is not part of Sun's JDK so I have made it package - /// private. It is used by DeflaterOutputStream to implement - /// flush(). - /// - public void Flush() - { - state |= IS_FLUSHING; - } - - /// - /// Finishes the deflater with the current input block. It is an error - /// to give more input after this method was called. This method must - /// be called to force all bytes to be flushed. - /// - public void Finish() - { - state |= IS_FLUSHING | IS_FINISHING; - } - - /// - /// Returns true if the stream was finished and no more output bytes - /// are available. - /// - public bool IsFinished { - get { - return state == FINISHED_STATE && pending.IsFlushed; - } - } - - /// - /// Returns true, if the input buffer is empty. - /// You should then call setInput(). - /// NOTE: This method can also return true when the stream - /// was finished. - /// - public bool IsNeedingInput { - get { - return engine.NeedsInput(); - } - } - - /// - /// Sets the data which should be compressed next. This should be only - /// called when needsInput indicates that more input is needed. - /// If you call setInput when needsInput() returns false, the - /// previous input that is still pending will be thrown away. - /// The given byte array should not be changed, before needsInput() returns - /// true again. - /// This call is equivalent to setInput(input, 0, input.length). - /// - /// - /// the buffer containing the input data. - /// - /// - /// if the buffer was finished() or ended(). - /// - public void SetInput(byte[] input) - { - SetInput(input, 0, input.Length); - } - - /// - /// Sets the data which should be compressed next. This should be - /// only called when needsInput indicates that more input is needed. - /// The given byte array should not be changed, before needsInput() returns - /// true again. - /// - /// - /// the buffer containing the input data. - /// - /// - /// the start of the data. - /// - /// - /// the length of the data. - /// - /// - /// if the buffer was finished() or ended() or if previous input is still pending. - /// - public void SetInput(byte[] input, int off, int len) - { - if ((state & IS_FINISHING) != 0) { - throw new InvalidOperationException("finish()/end() already called"); - } - engine.SetInput(input, off, len); - } - - /// - /// Sets the compression level. There is no guarantee of the exact - /// position of the change, but if you call this when needsInput is - /// true the change of compression level will occur somewhere near - /// before the end of the so far given input. - /// - /// - /// the new compression level. - /// - public void SetLevel(int lvl) - { - if (lvl == DEFAULT_COMPRESSION) { - lvl = 6; - } else if (lvl < NO_COMPRESSION || lvl > BEST_COMPRESSION) { - throw new ArgumentOutOfRangeException("lvl"); - } - - if (level != lvl) { - level = lvl; - engine.SetLevel(lvl); - } - } - - /// - /// Sets the compression strategy. Strategy is one of - /// DEFAULT_STRATEGY, HUFFMAN_ONLY and FILTERED. For the exact - /// position where the strategy is changed, the same as for - /// setLevel() applies. - /// - /// - /// the new compression strategy. - /// - public void SetStrategy(DeflateStrategy stgy) - { - engine.Strategy = stgy; - } - - /// - /// Deflates the current input block to the given array. It returns - /// the number of bytes compressed, or 0 if either - /// needsInput() or finished() returns true or length is zero. - /// - /// - /// the buffer where to write the compressed data. - /// - public int Deflate(byte[] output) - { - return Deflate(output, 0, output.Length); - } - - /// - /// Deflates the current input block to the given array. It returns - /// the number of bytes compressed, or 0 if either - /// needsInput() or finished() returns true or length is zero. - /// - /// - /// the buffer where to write the compressed data. - /// - /// - /// the offset into the output array. - /// - /// - /// the maximum number of bytes that may be written. - /// - /// - /// if end() was called. - /// - /// - /// if offset and/or length don't match the array length. - /// - public int Deflate(byte[] output, int offset, int length) - { - int origLength = length; - - if (state == CLOSED_STATE) { - throw new InvalidOperationException("Deflater closed"); - } - - if (state < BUSY_STATE) { - /* output header */ - int header = (DEFLATED + - ((DeflaterConstants.MAX_WBITS - 8) << 4)) << 8; - int level_flags = (level - 1) >> 1; - if (level_flags < 0 || level_flags > 3) { - level_flags = 3; - } - header |= level_flags << 6; - if ((state & IS_SETDICT) != 0) { - /* Dictionary was set */ - header |= DeflaterConstants.PRESET_DICT; - } - header += 31 - (header % 31); - - - pending.WriteShortMSB(header); - if ((state & IS_SETDICT) != 0) { - int chksum = engine.Adler; - engine.ResetAdler(); - pending.WriteShortMSB(chksum >> 16); - pending.WriteShortMSB(chksum & 0xffff); - } - - state = BUSY_STATE | (state & (IS_FLUSHING | IS_FINISHING)); - } - - for (;;) { - int count = pending.Flush(output, offset, length); - offset += count; - totalOut += count; - length -= count; - - if (length == 0 || state == FINISHED_STATE) { - break; - } - - if (!engine.Deflate((state & IS_FLUSHING) != 0, (state & IS_FINISHING) != 0)) { - if (state == BUSY_STATE) { - /* We need more input now */ - return origLength - length; - } else if (state == FLUSHING_STATE) { - if (level != NO_COMPRESSION) { - /* We have to supply some lookahead. 8 bit lookahead - * are needed by the zlib inflater, and we must fill - * the next byte, so that all bits are flushed. - */ - int neededbits = 8 + ((-pending.BitCount) & 7); - while (neededbits > 0) { - /* write a static tree block consisting solely of - * an EOF: - */ - pending.WriteBits(2, 10); - neededbits -= 10; - } - } - state = BUSY_STATE; - } else if (state == FINISHING_STATE) { - pending.AlignToByte(); - /* We have completed the stream */ - if (!noHeader) { - int adler = engine.Adler; - pending.WriteShortMSB(adler >> 16); - pending.WriteShortMSB(adler & 0xffff); - } - state = FINISHED_STATE; - } - } - } - return origLength - length; - } - - /// - /// Sets the dictionary which should be used in the deflate process. - /// This call is equivalent to setDictionary(dict, 0, dict.Length). - /// - /// - /// the dictionary. - /// - /// - /// if setInput () or deflate () were already called or another dictionary was already set. - /// - public void SetDictionary(byte[] dict) - { - SetDictionary(dict, 0, dict.Length); - } - - /// - /// Sets the dictionary which should be used in the deflate process. - /// The dictionary should be a byte array containing strings that are - /// likely to occur in the data which should be compressed. The - /// dictionary is not stored in the compressed output, only a - /// checksum. To decompress the output you need to supply the same - /// dictionary again. - /// - /// - /// the dictionary. - /// - /// - /// an offset into the dictionary. - /// - /// - /// the length of the dictionary. - /// - /// - /// if setInput () or deflate () were already called or another dictionary was already set. - /// - public void SetDictionary(byte[] dict, int offset, int length) - { - if (state != INIT_STATE) { - throw new InvalidOperationException(); - } - - state = SETDICT_STATE; - engine.SetDictionary(dict, offset, length); - } - } -} diff --git a/irc/TechBot/Compression/DeflaterConstants.cs b/irc/TechBot/Compression/DeflaterConstants.cs deleted file mode 100644 index 8e2be6e21ca..00000000000 --- a/irc/TechBot/Compression/DeflaterConstants.cs +++ /dev/null @@ -1,85 +0,0 @@ -// DeflaterConstants.cs -// Copyright (C) 2001 Mike Krueger -// -// This file was translated from java, it was part of the GNU Classpath -// Copyright (C) 2001 Free Software Foundation, Inc. -// -// 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -// -// Linking this library statically or dynamically with other modules is -// making a combined work based on this library. Thus, the terms and -// conditions of the GNU General Public License cover the whole -// combination. -// -// As a special exception, the copyright holders of this library give you -// permission to link this library with independent modules to produce an -// executable, regardless of the license terms of these independent -// modules, and to copy and distribute the resulting executable under -// terms of your choice, provided that you also meet, for each linked -// independent module, the terms and conditions of the license of that -// module. An independent module is a module which is not derived from -// or based on this library. If you modify this library, you may extend -// this exception to your version of the library, but you are not -// obligated to do so. If you do not wish to do so, delete this -// exception statement from your version. - -using System; - -namespace ICSharpCode.SharpZipLib.Zip.Compression -{ - - /// - /// This class contains constants used for the deflater. - /// - public class DeflaterConstants - { - public const bool DEBUGGING = false; - - public const int STORED_BLOCK = 0; - public const int STATIC_TREES = 1; - public const int DYN_TREES = 2; - public const int PRESET_DICT = 0x20; - - public const int DEFAULT_MEM_LEVEL = 8; - - public const int MAX_MATCH = 258; - public const int MIN_MATCH = 3; - - public const int MAX_WBITS = 15; - public const int WSIZE = 1 << MAX_WBITS; - public const int WMASK = WSIZE - 1; - - public const int HASH_BITS = DEFAULT_MEM_LEVEL + 7; - public const int HASH_SIZE = 1 << HASH_BITS; - public const int HASH_MASK = HASH_SIZE - 1; - public const int HASH_SHIFT = (HASH_BITS + MIN_MATCH - 1) / MIN_MATCH; - - public const int MIN_LOOKAHEAD = MAX_MATCH + MIN_MATCH + 1; - public const int MAX_DIST = WSIZE - MIN_LOOKAHEAD; - - public const int PENDING_BUF_SIZE = 1 << (DEFAULT_MEM_LEVEL + 8); - public static int MAX_BLOCK_SIZE = Math.Min(65535, PENDING_BUF_SIZE-5); - - public const int DEFLATE_STORED = 0; - public const int DEFLATE_FAST = 1; - public const int DEFLATE_SLOW = 2; - - public static int[] GOOD_LENGTH = { 0, 4, 4, 4, 4, 8, 8, 8, 32, 32 }; - public static int[] MAX_LAZY = { 0, 4, 5, 6, 4,16, 16, 32, 128, 258 }; - public static int[] NICE_LENGTH = { 0, 8,16,32,16,32,128,128, 258, 258 }; - public static int[] MAX_CHAIN = { 0, 4, 8,32,16,32,128,256,1024,4096 }; - public static int[] COMPR_FUNC = { 0, 1, 1, 1, 1, 2, 2, 2, 2, 2 }; - } -} diff --git a/irc/TechBot/Compression/DeflaterEngine.cs b/irc/TechBot/Compression/DeflaterEngine.cs deleted file mode 100644 index c543f850980..00000000000 --- a/irc/TechBot/Compression/DeflaterEngine.cs +++ /dev/null @@ -1,653 +0,0 @@ -// DeflaterEngine.cs -// Copyright (C) 2001 Mike Krueger -// -// This file was translated from java, it was part of the GNU Classpath -// Copyright (C) 2001 Free Software Foundation, Inc. -// -// 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -// -// Linking this library statically or dynamically with other modules is -// making a combined work based on this library. Thus, the terms and -// conditions of the GNU General Public License cover the whole -// combination. -// -// As a special exception, the copyright holders of this library give you -// permission to link this library with independent modules to produce an -// executable, regardless of the license terms of these independent -// modules, and to copy and distribute the resulting executable under -// terms of your choice, provided that you also meet, for each linked -// independent module, the terms and conditions of the license of that -// module. An independent module is a module which is not derived from -// or based on this library. If you modify this library, you may extend -// this exception to your version of the library, but you are not -// obligated to do so. If you do not wish to do so, delete this -// exception statement from your version. - -using System; - -using ICSharpCode.SharpZipLib.Checksums; - -namespace ICSharpCode.SharpZipLib.Zip.Compression -{ - - public enum DeflateStrategy - { - // The default strategy. - Default = 0, - - // This strategy will only allow longer string repetitions. It is - // useful for random data with a small character set. - Filtered = 1, - - // This strategy will not look for string repetitions at all. It - // only encodes with Huffman trees (which means, that more common - // characters get a smaller encoding. - HuffmanOnly = 2 - } - - public class DeflaterEngine : DeflaterConstants - { - static int TOO_FAR = 4096; - - int ins_h; - // private byte[] buffer; - short[] head; - short[] prev; - - int matchStart, matchLen; - bool prevAvailable; - int blockStart; - int strstart, lookahead; - byte[] window; - - DeflateStrategy strategy; - int max_chain, max_lazy, niceLength, goodLength; - - /// - /// The current compression function. - /// - int comprFunc; - - /// - /// The input data for compression. - /// - byte[] inputBuf; - - /// - /// The total bytes of input read. - /// - int totalIn; - - /// - /// The offset into inputBuf, where input data starts. - /// - int inputOff; - - /// - /// The end offset of the input data. - /// - int inputEnd; - - DeflaterPending pending; - DeflaterHuffman huffman; - - /// - /// The adler checksum - /// - Adler32 adler; - - public DeflaterEngine(DeflaterPending pending) - { - this.pending = pending; - huffman = new DeflaterHuffman(pending); - adler = new Adler32(); - - window = new byte[2 * WSIZE]; - head = new short[HASH_SIZE]; - prev = new short[WSIZE]; - - /* We start at index 1, to avoid a implementation deficiency, that - * we cannot build a repeat pattern at index 0. - */ - blockStart = strstart = 1; - } - - public void Reset() - { - huffman.Reset(); - adler.Reset(); - blockStart = strstart = 1; - lookahead = 0; - totalIn = 0; - prevAvailable = false; - matchLen = MIN_MATCH - 1; - - for (int i = 0; i < HASH_SIZE; i++) { - head[i] = 0; - } - - for (int i = 0; i < WSIZE; i++) { - prev[i] = 0; - } - } - - public void ResetAdler() - { - adler.Reset(); - } - - public int Adler { - get { - return (int)adler.Value; - } - } - - public int TotalIn { - get { - return totalIn; - } - } - - public DeflateStrategy Strategy { - get { - return strategy; - } - set { - strategy = value; - } - } - - public void SetLevel(int lvl) - { - goodLength = DeflaterConstants.GOOD_LENGTH[lvl]; - max_lazy = DeflaterConstants.MAX_LAZY[lvl]; - niceLength = DeflaterConstants.NICE_LENGTH[lvl]; - max_chain = DeflaterConstants.MAX_CHAIN[lvl]; - - if (DeflaterConstants.COMPR_FUNC[lvl] != comprFunc) { - // if (DeflaterConstants.DEBUGGING) { - // //Console.WriteLine("Change from "+comprFunc +" to " - // + DeflaterConstants.COMPR_FUNC[lvl]); - // } - switch (comprFunc) { - case DEFLATE_STORED: - if (strstart > blockStart) { - huffman.FlushStoredBlock(window, blockStart, - strstart - blockStart, false); - blockStart = strstart; - } - UpdateHash(); - break; - case DEFLATE_FAST: - if (strstart > blockStart) { - huffman.FlushBlock(window, blockStart, strstart - blockStart, - false); - blockStart = strstart; - } - break; - case DEFLATE_SLOW: - if (prevAvailable) { - huffman.TallyLit(window[strstart-1] & 0xff); - } - if (strstart > blockStart) { - huffman.FlushBlock(window, blockStart, strstart - blockStart, false); - blockStart = strstart; - } - prevAvailable = false; - matchLen = MIN_MATCH - 1; - break; - } - comprFunc = COMPR_FUNC[lvl]; - } - } - - void UpdateHash() - { - // if (DEBUGGING) { - // //Console.WriteLine("updateHash: "+strstart); - // } - ins_h = (window[strstart] << HASH_SHIFT) ^ window[strstart + 1]; - } - - int InsertString() - { - short match; - int hash = ((ins_h << HASH_SHIFT) ^ window[strstart + (MIN_MATCH -1)]) & HASH_MASK; - - // if (DEBUGGING) { - // if (hash != (((window[strstart] << (2*HASH_SHIFT)) ^ - // (window[strstart + 1] << HASH_SHIFT) ^ - // (window[strstart + 2])) & HASH_MASK)) { - // throw new Exception("hash inconsistent: "+hash+"/" - // +window[strstart]+"," - // +window[strstart+1]+"," - // +window[strstart+2]+","+HASH_SHIFT); - // } - // } - - prev[strstart & WMASK] = match = head[hash]; - head[hash] = (short)strstart; - ins_h = hash; - return match & 0xffff; - } - - void SlideWindow() - { - Array.Copy(window, WSIZE, window, 0, WSIZE); - matchStart -= WSIZE; - strstart -= WSIZE; - blockStart -= WSIZE; - - /* Slide the hash table (could be avoided with 32 bit values - * at the expense of memory usage). - */ - for (int i = 0; i < HASH_SIZE; ++i) { - int m = head[i] & 0xffff; - head[i] = (short)(m >= WSIZE ? (m - WSIZE) : 0); - } - - /* Slide the prev table. */ - for (int i = 0; i < WSIZE; i++) { - int m = prev[i] & 0xffff; - prev[i] = (short)(m >= WSIZE ? (m - WSIZE) : 0); - } - } - - public void FillWindow() - { - /* If the window is almost full and there is insufficient lookahead, - * move the upper half to the lower one to make room in the upper half. - */ - if (strstart >= WSIZE + MAX_DIST) { - SlideWindow(); - } - - /* If there is not enough lookahead, but still some input left, - * read in the input - */ - while (lookahead < DeflaterConstants.MIN_LOOKAHEAD && inputOff < inputEnd) { - int more = 2 * WSIZE - lookahead - strstart; - - if (more > inputEnd - inputOff) { - more = inputEnd - inputOff; - } - - System.Array.Copy(inputBuf, inputOff, window, strstart + lookahead, more); - adler.Update(inputBuf, inputOff, more); - - inputOff += more; - totalIn += more; - lookahead += more; - } - - if (lookahead >= MIN_MATCH) { - UpdateHash(); - } - } - - bool FindLongestMatch(int curMatch) - { - int chainLength = this.max_chain; - int niceLength = this.niceLength; - short[] prev = this.prev; - int scan = this.strstart; - int match; - int best_end = this.strstart + matchLen; - int best_len = Math.Max(matchLen, MIN_MATCH - 1); - - int limit = Math.Max(strstart - MAX_DIST, 0); - - int strend = strstart + MAX_MATCH - 1; - byte scan_end1 = window[best_end - 1]; - byte scan_end = window[best_end]; - - /* Do not waste too much time if we already have a good match: */ - if (best_len >= this.goodLength) { - chainLength >>= 2; - } - - /* Do not look for matches beyond the end of the input. This is necessary - * to make deflate deterministic. - */ - if (niceLength > lookahead) { - niceLength = lookahead; - } - - if (DeflaterConstants.DEBUGGING && strstart > 2 * WSIZE - MIN_LOOKAHEAD) { - throw new InvalidOperationException("need lookahead"); - } - - do { - if (DeflaterConstants.DEBUGGING && curMatch >= strstart) { - throw new InvalidOperationException("future match"); - } - if (window[curMatch + best_len] != scan_end || - window[curMatch + best_len - 1] != scan_end1 || - window[curMatch] != window[scan] || - window[curMatch + 1] != window[scan + 1]) { - continue; - } - - match = curMatch + 2; - scan += 2; - - /* We check for insufficient lookahead only every 8th comparison; - * the 256th check will be made at strstart+258. - */ - while (window[++scan] == window[++match] && - window[++scan] == window[++match] && - window[++scan] == window[++match] && - window[++scan] == window[++match] && - window[++scan] == window[++match] && - window[++scan] == window[++match] && - window[++scan] == window[++match] && - window[++scan] == window[++match] && scan < strend) ; - - if (scan > best_end) { - // if (DeflaterConstants.DEBUGGING && ins_h == 0) - // System.err.println("Found match: "+curMatch+"-"+(scan-strstart)); - matchStart = curMatch; - best_end = scan; - best_len = scan - strstart; - - if (best_len >= niceLength) { - break; - } - - scan_end1 = window[best_end - 1]; - scan_end = window[best_end]; - } - scan = strstart; - } while ((curMatch = (prev[curMatch & WMASK] & 0xffff)) > limit && --chainLength != 0); - - matchLen = Math.Min(best_len, lookahead); - return matchLen >= MIN_MATCH; - } - - public void SetDictionary(byte[] buffer, int offset, int length) - { - if (DeflaterConstants.DEBUGGING && strstart != 1) { - throw new InvalidOperationException("strstart not 1"); - } - adler.Update(buffer, offset, length); - if (length < MIN_MATCH) { - return; - } - if (length > MAX_DIST) { - offset += length - MAX_DIST; - length = MAX_DIST; - } - - System.Array.Copy(buffer, offset, window, strstart, length); - - UpdateHash(); - --length; - while (--length > 0) { - InsertString(); - strstart++; - } - strstart += 2; - blockStart = strstart; - } - - bool DeflateStored(bool flush, bool finish) - { - if (!flush && lookahead == 0) { - return false; - } - - strstart += lookahead; - lookahead = 0; - - int storedLen = strstart - blockStart; - - if ((storedLen >= DeflaterConstants.MAX_BLOCK_SIZE) || /* Block is full */ - (blockStart < WSIZE && storedLen >= MAX_DIST) || /* Block may move out of window */ - flush) { - bool lastBlock = finish; - if (storedLen > DeflaterConstants.MAX_BLOCK_SIZE) { - storedLen = DeflaterConstants.MAX_BLOCK_SIZE; - lastBlock = false; - } - - // if (DeflaterConstants.DEBUGGING) { - // //Console.WriteLine("storedBlock["+storedLen+","+lastBlock+"]"); - // } - - huffman.FlushStoredBlock(window, blockStart, storedLen, lastBlock); - blockStart += storedLen; - return !lastBlock; - } - return true; - } - - private bool DeflateFast(bool flush, bool finish) - { - if (lookahead < MIN_LOOKAHEAD && !flush) { - return false; - } - - while (lookahead >= MIN_LOOKAHEAD || flush) { - if (lookahead == 0) { - /* We are flushing everything */ - huffman.FlushBlock(window, blockStart, strstart - blockStart, finish); - blockStart = strstart; - return false; - } - - if (strstart > 2 * WSIZE - MIN_LOOKAHEAD) { - /* slide window, as findLongestMatch need this. - * This should only happen when flushing and the window - * is almost full. - */ - SlideWindow(); - } - - int hashHead; - if (lookahead >= MIN_MATCH && - (hashHead = InsertString()) != 0 && - strategy != DeflateStrategy.HuffmanOnly && - strstart - hashHead <= MAX_DIST && - FindLongestMatch(hashHead)) { - /* longestMatch sets matchStart and matchLen */ - // if (DeflaterConstants.DEBUGGING) { - // for (int i = 0 ; i < matchLen; i++) { - // if (window[strstart+i] != window[matchStart + i]) { - // throw new Exception(); - // } - // } - // } - - // -jr- Hak hak hak this stops problems with fast/low compression and index out of range - if (huffman.TallyDist(strstart - matchStart, matchLen)) { - bool lastBlock = finish && lookahead == 0; - huffman.FlushBlock(window, blockStart, strstart - blockStart, lastBlock); - blockStart = strstart; - } - - lookahead -= matchLen; - if (matchLen <= max_lazy && lookahead >= MIN_MATCH) { - while (--matchLen > 0) { - ++strstart; - InsertString(); - } - ++strstart; - } else { - strstart += matchLen; - if (lookahead >= MIN_MATCH - 1) { - UpdateHash(); - } - } - matchLen = MIN_MATCH - 1; - continue; - } else { - /* No match found */ - huffman.TallyLit(window[strstart] & 0xff); - ++strstart; - --lookahead; - } - - if (huffman.IsFull()) { - bool lastBlock = finish && lookahead == 0; - huffman.FlushBlock(window, blockStart, strstart - blockStart, lastBlock); - blockStart = strstart; - return !lastBlock; - } - } - return true; - } - - bool DeflateSlow(bool flush, bool finish) - { - if (lookahead < MIN_LOOKAHEAD && !flush) { - return false; - } - - while (lookahead >= MIN_LOOKAHEAD || flush) { - if (lookahead == 0) { - if (prevAvailable) { - huffman.TallyLit(window[strstart-1] & 0xff); - } - prevAvailable = false; - - /* We are flushing everything */ - if (DeflaterConstants.DEBUGGING && !flush) { - throw new Exception("Not flushing, but no lookahead"); - } - huffman.FlushBlock(window, blockStart, strstart - blockStart, - finish); - blockStart = strstart; - return false; - } - - if (strstart >= 2 * WSIZE - MIN_LOOKAHEAD) { - /* slide window, as findLongestMatch need this. - * This should only happen when flushing and the window - * is almost full. - */ - SlideWindow(); - } - - int prevMatch = matchStart; - int prevLen = matchLen; - if (lookahead >= MIN_MATCH) { - int hashHead = InsertString(); - if (strategy != DeflateStrategy.HuffmanOnly && hashHead != 0 && strstart - hashHead <= MAX_DIST && FindLongestMatch(hashHead)) { - /* longestMatch sets matchStart and matchLen */ - - /* Discard match if too small and too far away */ - if (matchLen <= 5 && (strategy == DeflateStrategy.Filtered || (matchLen == MIN_MATCH && strstart - matchStart > TOO_FAR))) { - matchLen = MIN_MATCH - 1; - } - } - } - - /* previous match was better */ - if (prevLen >= MIN_MATCH && matchLen <= prevLen) { - // if (DeflaterConstants.DEBUGGING) { - // for (int i = 0 ; i < matchLen; i++) { - // if (window[strstart-1+i] != window[prevMatch + i]) - // throw new Exception(); - // } - // } - huffman.TallyDist(strstart - 1 - prevMatch, prevLen); - prevLen -= 2; - do { - strstart++; - lookahead--; - if (lookahead >= MIN_MATCH) { - InsertString(); - } - } while (--prevLen > 0); - strstart ++; - lookahead--; - prevAvailable = false; - matchLen = MIN_MATCH - 1; - } else { - if (prevAvailable) { - huffman.TallyLit(window[strstart-1] & 0xff); - } - prevAvailable = true; - strstart++; - lookahead--; - } - - if (huffman.IsFull()) { - int len = strstart - blockStart; - if (prevAvailable) { - len--; - } - bool lastBlock = (finish && lookahead == 0 && !prevAvailable); - huffman.FlushBlock(window, blockStart, len, lastBlock); - blockStart += len; - return !lastBlock; - } - } - return true; - } - - public bool Deflate(bool flush, bool finish) - { - bool progress; - do { - FillWindow(); - bool canFlush = flush && inputOff == inputEnd; - // if (DeflaterConstants.DEBUGGING) { - // //Console.WriteLine("window: ["+blockStart+","+strstart+"," - // +lookahead+"], "+comprFunc+","+canFlush); - // } - switch (comprFunc) { - case DEFLATE_STORED: - progress = DeflateStored(canFlush, finish); - break; - case DEFLATE_FAST: - progress = DeflateFast(canFlush, finish); - break; - case DEFLATE_SLOW: - progress = DeflateSlow(canFlush, finish); - break; - default: - throw new InvalidOperationException("unknown comprFunc"); - } - } while (pending.IsFlushed && progress); /* repeat while we have no pending output and progress was made */ - return progress; - } - - public void SetInput(byte[] buf, int off, int len) - { - if (inputOff < inputEnd) { - throw new InvalidOperationException("Old input was not completely processed"); - } - - int end = off + len; - - /* We want to throw an ArrayIndexOutOfBoundsException early. The - * check is very tricky: it also handles integer wrap around. - */ - if (0 > off || off > end || end > buf.Length) { - throw new ArgumentOutOfRangeException(); - } - - inputBuf = buf; - inputOff = off; - inputEnd = end; - } - - public bool NeedsInput() - { - return inputEnd == inputOff; - } - } -} diff --git a/irc/TechBot/Compression/DeflaterHuffman.cs b/irc/TechBot/Compression/DeflaterHuffman.cs deleted file mode 100644 index 338d09ed242..00000000000 --- a/irc/TechBot/Compression/DeflaterHuffman.cs +++ /dev/null @@ -1,780 +0,0 @@ -// DeflaterHuffman.cs -// Copyright (C) 2001 Mike Krueger -// -// This file was translated from java, it was part of the GNU Classpath -// Copyright (C) 2001 Free Software Foundation, Inc. -// -// 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -// -// Linking this library statically or dynamically with other modules is -// making a combined work based on this library. Thus, the terms and -// conditions of the GNU General Public License cover the whole -// combination. -// -// As a special exception, the copyright holders of this library give you -// permission to link this library with independent modules to produce an -// executable, regardless of the license terms of these independent -// modules, and to copy and distribute the resulting executable under -// terms of your choice, provided that you also meet, for each linked -// independent module, the terms and conditions of the license of that -// module. An independent module is a module which is not derived from -// or based on this library. If you modify this library, you may extend -// this exception to your version of the library, but you are not -// obligated to do so. If you do not wish to do so, delete this -// exception statement from your version. - -using System; - -namespace ICSharpCode.SharpZipLib.Zip.Compression -{ - - /// - /// This is the DeflaterHuffman class. - /// - /// This class is not thread safe. This is inherent in the API, due - /// to the split of deflate and setInput. - /// - /// author of the original java version : Jochen Hoenicke - /// - public class DeflaterHuffman - { - private static int BUFSIZE = 1 << (DeflaterConstants.DEFAULT_MEM_LEVEL + 6); - private static int LITERAL_NUM = 286; - private static int DIST_NUM = 30; - private static int BITLEN_NUM = 19; - private static int REP_3_6 = 16; - private static int REP_3_10 = 17; - private static int REP_11_138 = 18; - private static int EOF_SYMBOL = 256; - private static int[] BL_ORDER = { 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15 }; - - private static byte[] bit4Reverse = { - 0, - 8, - 4, - 12, - 2, - 10, - 6, - 14, - 1, - 9, - 5, - 13, - 3, - 11, - 7, - 15 - }; - - public class Tree - { - public short[] freqs; - public byte[] length; - public int minNumCodes, numCodes; - - short[] codes; - int[] bl_counts; - int maxLength; - DeflaterHuffman dh; - - public Tree(DeflaterHuffman dh, int elems, int minCodes, int maxLength) - { - this.dh = dh; - this.minNumCodes = minCodes; - this.maxLength = maxLength; - freqs = new short[elems]; - bl_counts = new int[maxLength]; - } - - public void Reset() - { - for (int i = 0; i < freqs.Length; i++) { - freqs[i] = 0; - } - codes = null; - length = null; - } - - public void WriteSymbol(int code) - { - // if (DeflaterConstants.DEBUGGING) { - // freqs[code]--; - // // Console.Write("writeSymbol("+freqs.length+","+code+"): "); - // } - dh.pending.WriteBits(codes[code] & 0xffff, length[code]); - } - - public void CheckEmpty() - { - bool empty = true; - for (int i = 0; i < freqs.Length; i++) { - if (freqs[i] != 0) { - //Console.WriteLine("freqs["+i+"] == "+freqs[i]); - empty = false; - } - } - if (!empty) { - throw new Exception(); - } - //Console.WriteLine("checkEmpty suceeded!"); - } - - public void SetStaticCodes(short[] stCodes, byte[] stLength) - { - codes = stCodes; - length = stLength; - } - - public void BuildCodes() - { - int numSymbols = freqs.Length; - int[] nextCode = new int[maxLength]; - int code = 0; - codes = new short[freqs.Length]; - - // if (DeflaterConstants.DEBUGGING) { - // //Console.WriteLine("buildCodes: "+freqs.Length); - // } - - for (int bits = 0; bits < maxLength; bits++) { - nextCode[bits] = code; - code += bl_counts[bits] << (15 - bits); - // if (DeflaterConstants.DEBUGGING) { - // //Console.WriteLine("bits: "+(bits+1)+" count: "+bl_counts[bits] - // +" nextCode: "+code); // HACK : Integer.toHexString( - // } - } - if (DeflaterConstants.DEBUGGING && code != 65536) { - throw new Exception("Inconsistent bl_counts!"); - } - - for (int i=0; i < numCodes; i++) { - int bits = length[i]; - if (bits > 0) { - // if (DeflaterConstants.DEBUGGING) { - // //Console.WriteLine("codes["+i+"] = rev(" + nextCode[bits-1]+")," // HACK : Integer.toHexString( - // +bits); - // } - codes[i] = BitReverse(nextCode[bits-1]); - nextCode[bits-1] += 1 << (16 - bits); - } - } - } - - void BuildLength(int[] childs) - { - this.length = new byte [freqs.Length]; - int numNodes = childs.Length / 2; - int numLeafs = (numNodes + 1) / 2; - int overflow = 0; - - for (int i = 0; i < maxLength; i++) { - bl_counts[i] = 0; - } - - /* First calculate optimal bit lengths */ - int[] lengths = new int[numNodes]; - lengths[numNodes-1] = 0; - - for (int i = numNodes - 1; i >= 0; i--) { - if (childs[2*i+1] != -1) { - int bitLength = lengths[i] + 1; - if (bitLength > maxLength) { - bitLength = maxLength; - overflow++; - } - lengths[childs[2*i]] = lengths[childs[2*i+1]] = bitLength; - } else { - /* A leaf node */ - int bitLength = lengths[i]; - bl_counts[bitLength - 1]++; - this.length[childs[2*i]] = (byte) lengths[i]; - } - } - - // if (DeflaterConstants.DEBUGGING) { - // //Console.WriteLine("Tree "+freqs.Length+" lengths:"); - // for (int i=0; i < numLeafs; i++) { - // //Console.WriteLine("Node "+childs[2*i]+" freq: "+freqs[childs[2*i]] - // + " len: "+length[childs[2*i]]); - // } - // } - - if (overflow == 0) { - return; - } - - int incrBitLen = maxLength - 1; - do { - /* Find the first bit length which could increase: */ - while (bl_counts[--incrBitLen] == 0) - ; - - /* Move this node one down and remove a corresponding - * amount of overflow nodes. - */ - do { - bl_counts[incrBitLen]--; - bl_counts[++incrBitLen]++; - overflow -= 1 << (maxLength - 1 - incrBitLen); - } while (overflow > 0 && incrBitLen < maxLength - 1); - } while (overflow > 0); - - /* We may have overshot above. Move some nodes from maxLength to - * maxLength-1 in that case. - */ - bl_counts[maxLength-1] += overflow; - bl_counts[maxLength-2] -= overflow; - - /* Now recompute all bit lengths, scanning in increasing - * frequency. It is simpler to reconstruct all lengths instead of - * fixing only the wrong ones. This idea is taken from 'ar' - * written by Haruhiko Okumura. - * - * The nodes were inserted with decreasing frequency into the childs - * array. - */ - int nodePtr = 2 * numLeafs; - for (int bits = maxLength; bits != 0; bits--) { - int n = bl_counts[bits-1]; - while (n > 0) { - int childPtr = 2*childs[nodePtr++]; - if (childs[childPtr + 1] == -1) { - /* We found another leaf */ - length[childs[childPtr]] = (byte) bits; - n--; - } - } - } - // if (DeflaterConstants.DEBUGGING) { - // //Console.WriteLine("*** After overflow elimination. ***"); - // for (int i=0; i < numLeafs; i++) { - // //Console.WriteLine("Node "+childs[2*i]+" freq: "+freqs[childs[2*i]] - // + " len: "+length[childs[2*i]]); - // } - // } - } - - public void BuildTree() - { - int numSymbols = freqs.Length; - - /* heap is a priority queue, sorted by frequency, least frequent - * nodes first. The heap is a binary tree, with the property, that - * the parent node is smaller than both child nodes. This assures - * that the smallest node is the first parent. - * - * The binary tree is encoded in an array: 0 is root node and - * the nodes 2*n+1, 2*n+2 are the child nodes of node n. - */ - int[] heap = new int[numSymbols]; - int heapLen = 0; - int maxCode = 0; - for (int n = 0; n < numSymbols; n++) { - int freq = freqs[n]; - if (freq != 0) { - /* Insert n into heap */ - int pos = heapLen++; - int ppos; - while (pos > 0 && freqs[heap[ppos = (pos - 1) / 2]] > freq) { - heap[pos] = heap[ppos]; - pos = ppos; - } - heap[pos] = n; - - maxCode = n; - } - } - - /* We could encode a single literal with 0 bits but then we - * don't see the literals. Therefore we force at least two - * literals to avoid this case. We don't care about order in - * this case, both literals get a 1 bit code. - */ - while (heapLen < 2) { - int node = maxCode < 2 ? ++maxCode : 0; - heap[heapLen++] = node; - } - - numCodes = Math.Max(maxCode + 1, minNumCodes); - - int numLeafs = heapLen; - int[] childs = new int[4*heapLen - 2]; - int[] values = new int[2*heapLen - 1]; - int numNodes = numLeafs; - for (int i = 0; i < heapLen; i++) { - int node = heap[i]; - childs[2*i] = node; - childs[2*i+1] = -1; - values[i] = freqs[node] << 8; - heap[i] = i; - } - - /* Construct the Huffman tree by repeatedly combining the least two - * frequent nodes. - */ - do { - int first = heap[0]; - int last = heap[--heapLen]; - - /* Propagate the hole to the leafs of the heap */ - int ppos = 0; - int path = 1; - - while (path < heapLen) { - if (path + 1 < heapLen && values[heap[path]] > values[heap[path+1]]) { - path++; - } - - heap[ppos] = heap[path]; - ppos = path; - path = path * 2 + 1; - } - - /* Now propagate the last element down along path. Normally - * it shouldn't go too deep. - */ - int lastVal = values[last]; - while ((path = ppos) > 0 && values[heap[ppos = (path - 1)/2]] > lastVal) { - heap[path] = heap[ppos]; - } - heap[path] = last; - - - int second = heap[0]; - - /* Create a new node father of first and second */ - last = numNodes++; - childs[2*last] = first; - childs[2*last+1] = second; - int mindepth = Math.Min(values[first] & 0xff, values[second] & 0xff); - values[last] = lastVal = values[first] + values[second] - mindepth + 1; - - /* Again, propagate the hole to the leafs */ - ppos = 0; - path = 1; - - while (path < heapLen) { - if (path + 1 < heapLen && values[heap[path]] > values[heap[path+1]]) { - path++; - } - - heap[ppos] = heap[path]; - ppos = path; - path = ppos * 2 + 1; - } - - /* Now propagate the new element down along path */ - while ((path = ppos) > 0 && values[heap[ppos = (path - 1)/2]] > lastVal) { - heap[path] = heap[ppos]; - } - heap[path] = last; - } while (heapLen > 1); - - if (heap[0] != childs.Length / 2 - 1) { - throw new Exception("Weird!"); - } - BuildLength(childs); - } - - public int GetEncodedLength() - { - int len = 0; - for (int i = 0; i < freqs.Length; i++) { - len += freqs[i] * length[i]; - } - return len; - } - - public void CalcBLFreq(Tree blTree) - { - int max_count; /* max repeat count */ - int min_count; /* min repeat count */ - int count; /* repeat count of the current code */ - int curlen = -1; /* length of current code */ - - int i = 0; - while (i < numCodes) { - count = 1; - int nextlen = length[i]; - if (nextlen == 0) { - max_count = 138; - min_count = 3; - } else { - max_count = 6; - min_count = 3; - if (curlen != nextlen) { - blTree.freqs[nextlen]++; - count = 0; - } - } - curlen = nextlen; - i++; - - while (i < numCodes && curlen == length[i]) { - i++; - if (++count >= max_count) { - break; - } - } - - if (count < min_count) { - blTree.freqs[curlen] += (short)count; - } else if (curlen != 0) { - blTree.freqs[REP_3_6]++; - } else if (count <= 10) { - blTree.freqs[REP_3_10]++; - } else { - blTree.freqs[REP_11_138]++; - } - } - } - - public void WriteTree(Tree blTree) - { - int max_count; /* max repeat count */ - int min_count; /* min repeat count */ - int count; /* repeat count of the current code */ - int curlen = -1; /* length of current code */ - - int i = 0; - while (i < numCodes) { - count = 1; - int nextlen = length[i]; - if (nextlen == 0) { - max_count = 138; - min_count = 3; - } else { - max_count = 6; - min_count = 3; - if (curlen != nextlen) { - blTree.WriteSymbol(nextlen); - count = 0; - } - } - curlen = nextlen; - i++; - - while (i < numCodes && curlen == length[i]) { - i++; - if (++count >= max_count) { - break; - } - } - - if (count < min_count) { - while (count-- > 0) { - blTree.WriteSymbol(curlen); - } - } else if (curlen != 0) { - blTree.WriteSymbol(REP_3_6); - dh.pending.WriteBits(count - 3, 2); - } else if (count <= 10) { - blTree.WriteSymbol(REP_3_10); - dh.pending.WriteBits(count - 3, 3); - } else { - blTree.WriteSymbol(REP_11_138); - dh.pending.WriteBits(count - 11, 7); - } - } - } - } - - public DeflaterPending pending; - private Tree literalTree, distTree, blTree; - - private short[] d_buf; - private byte[] l_buf; - private int last_lit; - private int extra_bits; - - private static short[] staticLCodes; - private static byte[] staticLLength; - private static short[] staticDCodes; - private static byte[] staticDLength; - - /// - /// Reverse the bits of a 16 bit value. - /// - public static short BitReverse(int value) - { - return (short) (bit4Reverse[value & 0xF] << 12 | - bit4Reverse[(value >> 4) & 0xF] << 8 | - bit4Reverse[(value >> 8) & 0xF] << 4 | - bit4Reverse[value >> 12]); - } - - - static DeflaterHuffman() - { - /* See RFC 1951 3.2.6 */ - /* Literal codes */ - staticLCodes = new short[LITERAL_NUM]; - staticLLength = new byte[LITERAL_NUM]; - int i = 0; - while (i < 144) { - staticLCodes[i] = BitReverse((0x030 + i) << 8); - staticLLength[i++] = 8; - } - while (i < 256) { - staticLCodes[i] = BitReverse((0x190 - 144 + i) << 7); - staticLLength[i++] = 9; - } - while (i < 280) { - staticLCodes[i] = BitReverse((0x000 - 256 + i) << 9); - staticLLength[i++] = 7; - } - while (i < LITERAL_NUM) { - staticLCodes[i] = BitReverse((0x0c0 - 280 + i) << 8); - staticLLength[i++] = 8; - } - - /* Distant codes */ - staticDCodes = new short[DIST_NUM]; - staticDLength = new byte[DIST_NUM]; - for (i = 0; i < DIST_NUM; i++) { - staticDCodes[i] = BitReverse(i << 11); - staticDLength[i] = 5; - } - } - - public DeflaterHuffman(DeflaterPending pending) - { - this.pending = pending; - - literalTree = new Tree(this, LITERAL_NUM, 257, 15); - distTree = new Tree(this, DIST_NUM, 1, 15); - blTree = new Tree(this, BITLEN_NUM, 4, 7); - - d_buf = new short[BUFSIZE]; - l_buf = new byte [BUFSIZE]; - } - - public void Reset() - { - last_lit = 0; - extra_bits = 0; - literalTree.Reset(); - distTree.Reset(); - blTree.Reset(); - } - - int Lcode(int len) - { - if (len == 255) { - return 285; - } - - int code = 257; - while (len >= 8) { - code += 4; - len >>= 1; - } - return code + len; - } - - int Dcode(int distance) - { - int code = 0; - while (distance >= 4) { - code += 2; - distance >>= 1; - } - return code + distance; - } - - public void SendAllTrees(int blTreeCodes) - { - blTree.BuildCodes(); - literalTree.BuildCodes(); - distTree.BuildCodes(); - pending.WriteBits(literalTree.numCodes - 257, 5); - pending.WriteBits(distTree.numCodes - 1, 5); - pending.WriteBits(blTreeCodes - 4, 4); - for (int rank = 0; rank < blTreeCodes; rank++) { - pending.WriteBits(blTree.length[BL_ORDER[rank]], 3); - } - literalTree.WriteTree(blTree); - distTree.WriteTree(blTree); - // if (DeflaterConstants.DEBUGGING) { - // blTree.CheckEmpty(); - // } - } - - public void CompressBlock() - { - for (int i = 0; i < last_lit; i++) { - int litlen = l_buf[i] & 0xff; - int dist = d_buf[i]; - if (dist-- != 0) { - // if (DeflaterConstants.DEBUGGING) { - // Console.Write("["+(dist+1)+","+(litlen+3)+"]: "); - // } - - int lc = Lcode(litlen); - literalTree.WriteSymbol(lc); - - int bits = (lc - 261) / 4; - if (bits > 0 && bits <= 5) { - pending.WriteBits(litlen & ((1 << bits) - 1), bits); - } - - int dc = Dcode(dist); - distTree.WriteSymbol(dc); - - bits = dc / 2 - 1; - if (bits > 0) { - pending.WriteBits(dist & ((1 << bits) - 1), bits); - } - } else { - // if (DeflaterConstants.DEBUGGING) { - // if (litlen > 32 && litlen < 127) { - // Console.Write("("+(char)litlen+"): "); - // } else { - // Console.Write("{"+litlen+"}: "); - // } - // } - literalTree.WriteSymbol(litlen); - } - } - // if (DeflaterConstants.DEBUGGING) { - // Console.Write("EOF: "); - // } - literalTree.WriteSymbol(EOF_SYMBOL); - // if (DeflaterConstants.DEBUGGING) { - // literalTree.CheckEmpty(); - // distTree.CheckEmpty(); - // } - } - - public void FlushStoredBlock(byte[] stored, int storedOffset, int storedLength, bool lastBlock) - { - // if (DeflaterConstants.DEBUGGING) { - // //Console.WriteLine("Flushing stored block "+ storedLength); - // } - pending.WriteBits((DeflaterConstants.STORED_BLOCK << 1) + (lastBlock ? 1 : 0), 3); - pending.AlignToByte(); - pending.WriteShort(storedLength); - pending.WriteShort(~storedLength); - pending.WriteBlock(stored, storedOffset, storedLength); - Reset(); - } - - public void FlushBlock(byte[] stored, int storedOffset, int storedLength, bool lastBlock) - { - literalTree.freqs[EOF_SYMBOL]++; - - /* Build trees */ - literalTree.BuildTree(); - distTree.BuildTree(); - - /* Calculate bitlen frequency */ - literalTree.CalcBLFreq(blTree); - distTree.CalcBLFreq(blTree); - - /* Build bitlen tree */ - blTree.BuildTree(); - - int blTreeCodes = 4; - for (int i = 18; i > blTreeCodes; i--) { - if (blTree.length[BL_ORDER[i]] > 0) { - blTreeCodes = i+1; - } - } - int opt_len = 14 + blTreeCodes * 3 + blTree.GetEncodedLength() + - literalTree.GetEncodedLength() + distTree.GetEncodedLength() + - extra_bits; - - int static_len = extra_bits; - for (int i = 0; i < LITERAL_NUM; i++) { - static_len += literalTree.freqs[i] * staticLLength[i]; - } - for (int i = 0; i < DIST_NUM; i++) { - static_len += distTree.freqs[i] * staticDLength[i]; - } - if (opt_len >= static_len) { - /* Force static trees */ - opt_len = static_len; - } - - if (storedOffset >= 0 && storedLength+4 < opt_len >> 3) { - /* Store Block */ - // if (DeflaterConstants.DEBUGGING) { - // //Console.WriteLine("Storing, since " + storedLength + " < " + opt_len - // + " <= " + static_len); - // } - FlushStoredBlock(stored, storedOffset, storedLength, lastBlock); - } else if (opt_len == static_len) { - /* Encode with static tree */ - pending.WriteBits((DeflaterConstants.STATIC_TREES << 1) + (lastBlock ? 1 : 0), 3); - literalTree.SetStaticCodes(staticLCodes, staticLLength); - distTree.SetStaticCodes(staticDCodes, staticDLength); - CompressBlock(); - Reset(); - } else { - /* Encode with dynamic tree */ - pending.WriteBits((DeflaterConstants.DYN_TREES << 1) + (lastBlock ? 1 : 0), 3); - SendAllTrees(blTreeCodes); - CompressBlock(); - Reset(); - } - } - - public bool IsFull() - { -// return last_lit + 16 >= BUFSIZE; // HACK: This was == 'last_lit == BUFSIZE', but errors occured with DeflateFast - return last_lit >= BUFSIZE; // -jr- This is the correct form! - } - - public bool TallyLit(int lit) - { - // if (DeflaterConstants.DEBUGGING) { - // if (lit > 32 && lit < 127) { - // //Console.WriteLine("("+(char)lit+")"); - // } else { - // //Console.WriteLine("{"+lit+"}"); - // } - // } - d_buf[last_lit] = 0; - l_buf[last_lit++] = (byte)lit; - literalTree.freqs[lit]++; - return IsFull(); - } - - public bool TallyDist(int dist, int len) - { - // if (DeflaterConstants.DEBUGGING) { - // //Console.WriteLine("["+dist+","+len+"]"); - // } - - d_buf[last_lit] = (short)dist; - l_buf[last_lit++] = (byte)(len - 3); - - int lc = Lcode(len - 3); - literalTree.freqs[lc]++; - if (lc >= 265 && lc < 285) { - extra_bits += (lc - 261) / 4; - } - - int dc = Dcode(dist - 1); - distTree.freqs[dc]++; - if (dc >= 4) { - extra_bits += dc / 2 - 1; - } - return IsFull(); - } - } -} diff --git a/irc/TechBot/Compression/DeflaterPending.cs b/irc/TechBot/Compression/DeflaterPending.cs deleted file mode 100644 index 8144ff35e61..00000000000 --- a/irc/TechBot/Compression/DeflaterPending.cs +++ /dev/null @@ -1,52 +0,0 @@ -// DeflaterPending.cs -// Copyright (C) 2001 Mike Krueger -// -// This file was translated from java, it was part of the GNU Classpath -// Copyright (C) 2001 Free Software Foundation, Inc. -// -// 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -// -// Linking this library statically or dynamically with other modules is -// making a combined work based on this library. Thus, the terms and -// conditions of the GNU General Public License cover the whole -// combination. -// -// As a special exception, the copyright holders of this library give you -// permission to link this library with independent modules to produce an -// executable, regardless of the license terms of these independent -// modules, and to copy and distribute the resulting executable under -// terms of your choice, provided that you also meet, for each linked -// independent module, the terms and conditions of the license of that -// module. An independent module is a module which is not derived from -// or based on this library. If you modify this library, you may extend -// this exception to your version of the library, but you are not -// obligated to do so. If you do not wish to do so, delete this -// exception statement from your version. - -namespace ICSharpCode.SharpZipLib.Zip.Compression -{ - - /// - /// This class stores the pending output of the Deflater. - /// - /// author of the original java version : Jochen Hoenicke - /// - public class DeflaterPending : PendingBuffer - { - public DeflaterPending() : base(DeflaterConstants.PENDING_BUF_SIZE) - { - } - } -} diff --git a/irc/TechBot/Compression/Inflater.cs b/irc/TechBot/Compression/Inflater.cs deleted file mode 100644 index b915c8ffe7d..00000000000 --- a/irc/TechBot/Compression/Inflater.cs +++ /dev/null @@ -1,782 +0,0 @@ -// Inflater.cs -// Copyright (C) 2001 Mike Krueger -// -// This file was translated from java, it was part of the GNU Classpath -// Copyright (C) 2001 Free Software Foundation, Inc. -// -// 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -// -// Linking this library statically or dynamically with other modules is -// making a combined work based on this library. Thus, the terms and -// conditions of the GNU General Public License cover the whole -// combination. -// -// As a special exception, the copyright holders of this library give you -// permission to link this library with independent modules to produce an -// executable, regardless of the license terms of these independent -// modules, and to copy and distribute the resulting executable under -// terms of your choice, provided that you also meet, for each linked -// independent module, the terms and conditions of the license of that -// module. An independent module is a module which is not derived from -// or based on this library. If you modify this library, you may extend -// this exception to your version of the library, but you are not -// obligated to do so. If you do not wish to do so, delete this -// exception statement from your version. - -using System; - -using ICSharpCode.SharpZipLib.Checksums; -using ICSharpCode.SharpZipLib.Zip.Compression.Streams; - -namespace ICSharpCode.SharpZipLib.Zip.Compression -{ - - /// - /// Inflater is used to decompress data that has been compressed according - /// to the "deflate" standard described in rfc1950. - /// - /// The usage is as following. First you have to set some input with - /// setInput(), then inflate() it. If inflate doesn't - /// inflate any bytes there may be three reasons: - ///
          - ///
        • needsInput() returns true because the input buffer is empty. - /// You have to provide more input with setInput(). - /// NOTE: needsInput() also returns true when, the stream is finished. - ///
        • - ///
        • needsDictionary() returns true, you have to provide a preset - /// dictionary with setDictionary().
        • - ///
        • finished() returns true, the inflater has finished.
        • - ///
        - /// Once the first output byte is produced, a dictionary will not be - /// needed at a later stage. - /// - /// author of the original java version : John Leuner, Jochen Hoenicke - ///
        - public class Inflater - { - /// - /// Copy lengths for literal codes 257..285 - /// - private static int[] CPLENS = { - 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, - 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258 - }; - - /// - /// Extra bits for literal codes 257..285 - /// - private static int[] CPLEXT = { - 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, - 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0 - }; - - /// - /// Copy offsets for distance codes 0..29 - /// - private static int[] CPDIST = { - 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, - 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, - 8193, 12289, 16385, 24577 - }; - - /// - /// Extra bits for distance codes - /// - private static int[] CPDEXT = { - 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, - 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, - 12, 12, 13, 13 - }; - - /// - /// This are the state in which the inflater can be. - /// - private const int DECODE_HEADER = 0; - private const int DECODE_DICT = 1; - private const int DECODE_BLOCKS = 2; - private const int DECODE_STORED_LEN1 = 3; - private const int DECODE_STORED_LEN2 = 4; - private const int DECODE_STORED = 5; - private const int DECODE_DYN_HEADER = 6; - private const int DECODE_HUFFMAN = 7; - private const int DECODE_HUFFMAN_LENBITS = 8; - private const int DECODE_HUFFMAN_DIST = 9; - private const int DECODE_HUFFMAN_DISTBITS = 10; - private const int DECODE_CHKSUM = 11; - private const int FINISHED = 12; - - /// - /// This variable contains the current state. - /// - private int mode; - - /// - /// The adler checksum of the dictionary or of the decompressed - /// stream, as it is written in the header resp. footer of the - /// compressed stream. - /// Only valid if mode is DECODE_DICT or DECODE_CHKSUM. - /// - private int readAdler; - - /// - /// The number of bits needed to complete the current state. This - /// is valid, if mode is DECODE_DICT, DECODE_CHKSUM, - /// DECODE_HUFFMAN_LENBITS or DECODE_HUFFMAN_DISTBITS. - /// - private int neededBits; - private int repLength, repDist; - private int uncomprLen; - - /// - /// True, if the last block flag was set in the last block of the - /// inflated stream. This means that the stream ends after the - /// current block. - /// - private bool isLastBlock; - - /// - /// The total number of inflated bytes. - /// - private int totalOut; - - /// - /// The total number of bytes set with setInput(). This is not the - /// value returned by getTotalIn(), since this also includes the - /// unprocessed input. - /// - private int totalIn; - - /// - /// This variable stores the nowrap flag that was given to the constructor. - /// True means, that the inflated stream doesn't contain a header nor the - /// checksum in the footer. - /// - private bool nowrap; - - private StreamManipulator input; - private OutputWindow outputWindow; - private InflaterDynHeader dynHeader; - private InflaterHuffmanTree litlenTree, distTree; - private Adler32 adler; - - /// - /// Creates a new inflater. - /// - public Inflater() : this(false) - { - } - - /// - /// Creates a new inflater. - /// - /// - /// true if no header and checksum field appears in the - /// stream. This is used for GZIPed input. For compatibility with - /// Sun JDK you should provide one byte of input more than needed in - /// this case. - /// - public Inflater(bool nowrap) - { - this.nowrap = nowrap; - this.adler = new Adler32(); - input = new StreamManipulator(); - outputWindow = new OutputWindow(); - mode = nowrap ? DECODE_BLOCKS : DECODE_HEADER; - } - - /// - /// Resets the inflater so that a new stream can be decompressed. All - /// pending input and output will be discarded. - /// - public void Reset() - { - mode = nowrap ? DECODE_BLOCKS : DECODE_HEADER; - totalIn = totalOut = 0; - input.Reset(); - outputWindow.Reset(); - dynHeader = null; - litlenTree = null; - distTree = null; - isLastBlock = false; - adler.Reset(); - } - - /// - /// Decodes the deflate header. - /// - /// - /// false if more input is needed. - /// - /// - /// if header is invalid. - /// - private bool DecodeHeader() - { - int header = input.PeekBits(16); - if (header < 0) { - return false; - } - input.DropBits(16); - /* The header is written in "wrong" byte order */ - header = ((header << 8) | (header >> 8)) & 0xffff; - if (header % 31 != 0) { - throw new FormatException("Header checksum illegal"); - } - - if ((header & 0x0f00) != (Deflater.DEFLATED << 8)) { - throw new FormatException("Compression Method unknown"); - } - - /* Maximum size of the backwards window in bits. - * We currently ignore this, but we could use it to make the - * inflater window more space efficient. On the other hand the - * full window (15 bits) is needed most times, anyway. - int max_wbits = ((header & 0x7000) >> 12) + 8; - */ - - if ((header & 0x0020) == 0) { // Dictionary flag? - mode = DECODE_BLOCKS; - } else { - mode = DECODE_DICT; - neededBits = 32; - } - return true; - } - - /// - /// Decodes the dictionary checksum after the deflate header. - /// - /// - /// false if more input is needed. - /// - private bool DecodeDict() - { - while (neededBits > 0) { - int dictByte = input.PeekBits(8); - if (dictByte < 0) { - return false; - } - input.DropBits(8); - readAdler = (readAdler << 8) | dictByte; - neededBits -= 8; - } - return false; - } - - /// - /// Decodes the huffman encoded symbols in the input stream. - /// - /// - /// false if more input is needed, true if output window is - /// full or the current block ends. - /// - /// - /// if deflated stream is invalid. - /// - private bool DecodeHuffman() - { - int free = outputWindow.GetFreeSpace(); - while (free >= 258) { - int symbol; - switch (mode) { - case DECODE_HUFFMAN: - /* This is the inner loop so it is optimized a bit */ - while (((symbol = litlenTree.GetSymbol(input)) & ~0xff) == 0) { - outputWindow.Write(symbol); - if (--free < 258) { - return true; - } - } - if (symbol < 257) { - if (symbol < 0) { - return false; - } else { - /* symbol == 256: end of block */ - distTree = null; - litlenTree = null; - mode = DECODE_BLOCKS; - return true; - } - } - - try { - repLength = CPLENS[symbol - 257]; - neededBits = CPLEXT[symbol - 257]; - } catch (Exception) { - throw new FormatException("Illegal rep length code"); - } - goto case DECODE_HUFFMAN_LENBITS;/* fall through */ - case DECODE_HUFFMAN_LENBITS: - if (neededBits > 0) { - mode = DECODE_HUFFMAN_LENBITS; - int i = input.PeekBits(neededBits); - if (i < 0) { - return false; - } - input.DropBits(neededBits); - repLength += i; - } - mode = DECODE_HUFFMAN_DIST; - goto case DECODE_HUFFMAN_DIST;/* fall through */ - case DECODE_HUFFMAN_DIST: - symbol = distTree.GetSymbol(input); - if (symbol < 0) { - return false; - } - try { - repDist = CPDIST[symbol]; - neededBits = CPDEXT[symbol]; - } catch (Exception) { - throw new FormatException("Illegal rep dist code"); - } - - goto case DECODE_HUFFMAN_DISTBITS;/* fall through */ - case DECODE_HUFFMAN_DISTBITS: - if (neededBits > 0) { - mode = DECODE_HUFFMAN_DISTBITS; - int i = input.PeekBits(neededBits); - if (i < 0) { - return false; - } - input.DropBits(neededBits); - repDist += i; - } - outputWindow.Repeat(repLength, repDist); - free -= repLength; - mode = DECODE_HUFFMAN; - break; - default: - throw new FormatException(); - } - } - return true; - } - - /// - /// Decodes the adler checksum after the deflate stream. - /// - /// - /// false if more input is needed. - /// - /// - /// DataFormatException, if checksum doesn't match. - /// - private bool DecodeChksum() - { - while (neededBits > 0) { - int chkByte = input.PeekBits(8); - if (chkByte < 0) { - return false; - } - input.DropBits(8); - readAdler = (readAdler << 8) | chkByte; - neededBits -= 8; - } - if ((int) adler.Value != readAdler) { - throw new FormatException("Adler chksum doesn't match: " + (int)adler.Value + " vs. " + readAdler); - } - mode = FINISHED; - return false; - } - - /// - /// Decodes the deflated stream. - /// - /// - /// false if more input is needed, or if finished. - /// - /// - /// DataFormatException, if deflated stream is invalid. - /// - private bool Decode() - { - switch (mode) { - case DECODE_HEADER: - return DecodeHeader(); - case DECODE_DICT: - return DecodeDict(); - case DECODE_CHKSUM: - return DecodeChksum(); - - case DECODE_BLOCKS: - if (isLastBlock) { - if (nowrap) { - mode = FINISHED; - return false; - } else { - input.SkipToByteBoundary(); - neededBits = 32; - mode = DECODE_CHKSUM; - return true; - } - } - - int type = input.PeekBits(3); - if (type < 0) { - return false; - } - input.DropBits(3); - - if ((type & 1) != 0) { - isLastBlock = true; - } - switch (type >> 1){ - case DeflaterConstants.STORED_BLOCK: - input.SkipToByteBoundary(); - mode = DECODE_STORED_LEN1; - break; - case DeflaterConstants.STATIC_TREES: - litlenTree = InflaterHuffmanTree.defLitLenTree; - distTree = InflaterHuffmanTree.defDistTree; - mode = DECODE_HUFFMAN; - break; - case DeflaterConstants.DYN_TREES: - dynHeader = new InflaterDynHeader(); - mode = DECODE_DYN_HEADER; - break; - default: - throw new FormatException("Unknown block type "+type); - } - return true; - - case DECODE_STORED_LEN1: - { - if ((uncomprLen = input.PeekBits(16)) < 0) { - return false; - } - input.DropBits(16); - mode = DECODE_STORED_LEN2; - } - goto case DECODE_STORED_LEN2; /* fall through */ - case DECODE_STORED_LEN2: - { - int nlen = input.PeekBits(16); - if (nlen < 0) { - return false; - } - input.DropBits(16); - if (nlen != (uncomprLen ^ 0xffff)) { - throw new FormatException("broken uncompressed block"); - } - mode = DECODE_STORED; - } - goto case DECODE_STORED;/* fall through */ - case DECODE_STORED: - { - int more = outputWindow.CopyStored(input, uncomprLen); - uncomprLen -= more; - if (uncomprLen == 0) { - mode = DECODE_BLOCKS; - return true; - } - return !input.IsNeedingInput; - } - - case DECODE_DYN_HEADER: - if (!dynHeader.Decode(input)) { - return false; - } - - litlenTree = dynHeader.BuildLitLenTree(); - distTree = dynHeader.BuildDistTree(); - mode = DECODE_HUFFMAN; - goto case DECODE_HUFFMAN; /* fall through */ - case DECODE_HUFFMAN: - case DECODE_HUFFMAN_LENBITS: - case DECODE_HUFFMAN_DIST: - case DECODE_HUFFMAN_DISTBITS: - return DecodeHuffman(); - case FINISHED: - return false; - default: - throw new FormatException(); - } - } - - /// - /// Sets the preset dictionary. This should only be called, if - /// needsDictionary() returns true and it should set the same - /// dictionary, that was used for deflating. The getAdler() - /// function returns the checksum of the dictionary needed. - /// - /// - /// the dictionary. - /// - /// - /// if no dictionary is needed. - /// - /// - /// if the dictionary checksum is wrong. - /// - public void SetDictionary(byte[] buffer) - { - SetDictionary(buffer, 0, buffer.Length); - } - - /// - /// Sets the preset dictionary. This should only be called, if - /// needsDictionary() returns true and it should set the same - /// dictionary, that was used for deflating. The getAdler() - /// function returns the checksum of the dictionary needed. - /// - /// - /// the dictionary. - /// - /// - /// the offset into buffer where the dictionary starts. - /// - /// - /// the length of the dictionary. - /// - /// - /// if no dictionary is needed. - /// - /// - /// if the dictionary checksum is wrong. - /// - /// - /// if the off and/or len are wrong. - /// - public void SetDictionary(byte[] buffer, int off, int len) - { - if (!IsNeedingDictionary) { - throw new InvalidOperationException(); - } - - adler.Update(buffer, off, len); - if ((int)adler.Value != readAdler) { - throw new ArgumentException("Wrong adler checksum"); - } - adler.Reset(); - outputWindow.CopyDict(buffer, off, len); - mode = DECODE_BLOCKS; - } - - /// - /// Sets the input. This should only be called, if needsInput() - /// returns true. - /// - /// - /// the input. - /// - /// - /// if no input is needed. - /// - public void SetInput(byte[] buf) - { - SetInput(buf, 0, buf.Length); - } - - /// - /// Sets the input. This should only be called, if needsInput() - /// returns true. - /// - /// - /// the input. - /// - /// - /// the offset into buffer where the input starts. - /// - /// - /// the length of the input. - /// - /// - /// if no input is needed. - /// - /// - /// if the off and/or len are wrong. - /// - public void SetInput(byte[] buf, int off, int len) - { - input.SetInput(buf, off, len); - totalIn += len; - } - - /// - /// Inflates the compressed stream to the output buffer. If this - /// returns 0, you should check, whether needsDictionary(), - /// needsInput() or finished() returns true, to determine why no - /// further output is produced. - /// - /// - /// the output buffer. - /// - /// - /// the number of bytes written to the buffer, 0 if no further - /// output can be produced. - /// - /// - /// if buf has length 0. - /// - /// - /// if deflated stream is invalid. - /// - public int Inflate(byte[] buf) - { - return Inflate(buf, 0, buf.Length); - } - - /// - /// Inflates the compressed stream to the output buffer. If this - /// returns 0, you should check, whether needsDictionary(), - /// needsInput() or finished() returns true, to determine why no - /// further output is produced. - /// - /// - /// the output buffer. - /// - /// - /// the offset into buffer where the output should start. - /// - /// - /// the maximum length of the output. - /// - /// - /// the number of bytes written to the buffer, 0 if no further output can be produced. - /// - /// - /// if len is <= 0. - /// - /// - /// if the off and/or len are wrong. - /// - /// - /// if deflated stream is invalid. - /// - public int Inflate(byte[] buf, int off, int len) - { - if (len < 0) { - throw new ArgumentOutOfRangeException("len < 0"); - } - // Special case: len may be zero - if (len == 0) { - if (IsFinished == false) {// -jr- 08-Nov-2003 INFLATE_BUG fix.. - Decode(); - } - return 0; - } - /* // Check for correct buff, off, len triple - if (off < 0 || off + len >= buf.Length) { - throw new ArgumentException("off/len outside buf bounds"); - }*/ - int count = 0; - int more; - do { - if (mode != DECODE_CHKSUM) { - /* Don't give away any output, if we are waiting for the - * checksum in the input stream. - * - * With this trick we have always: - * needsInput() and not finished() - * implies more output can be produced. - */ - more = outputWindow.CopyOutput(buf, off, len); - adler.Update(buf, off, more); - off += more; - count += more; - totalOut += more; - len -= more; - if (len == 0) { - return count; - } - } - } while (Decode() || (outputWindow.GetAvailable() > 0 && mode != DECODE_CHKSUM)); - return count; - } - - /// - /// Returns true, if the input buffer is empty. - /// You should then call setInput(). - /// NOTE: This method also returns true when the stream is finished. - /// - public bool IsNeedingInput { - get { - return input.IsNeedingInput; - } - } - - /// - /// Returns true, if a preset dictionary is needed to inflate the input. - /// - public bool IsNeedingDictionary { - get { - return mode == DECODE_DICT && neededBits == 0; - } - } - - /// - /// Returns true, if the inflater has finished. This means, that no - /// input is needed and no output can be produced. - /// - public bool IsFinished { - get { - return mode == FINISHED && outputWindow.GetAvailable() == 0; - } - } - - /// - /// Gets the adler checksum. This is either the checksum of all - /// uncompressed bytes returned by inflate(), or if needsDictionary() - /// returns true (and thus no output was yet produced) this is the - /// adler checksum of the expected dictionary. - /// - /// - /// the adler checksum. - /// - public int Adler { - get { - return IsNeedingDictionary ? readAdler : (int) adler.Value; - } - } - - /// - /// Gets the total number of output bytes returned by inflate(). - /// - /// - /// the total number of output bytes. - /// - public int TotalOut { - get { - return totalOut; - } - } - - /// - /// Gets the total number of processed compressed input bytes. - /// - /// - /// the total number of bytes of processed input bytes. - /// - public int TotalIn { - get { - return totalIn - RemainingInput; - } - } - - /// - /// Gets the number of unprocessed input. Useful, if the end of the - /// stream is reached and you want to further process the bytes after - /// the deflate stream. - /// - /// - /// the number of bytes of the input which were not processed. - /// - public int RemainingInput { - get { - return input.AvailableBytes; - } - } - } -} diff --git a/irc/TechBot/Compression/InflaterDynHeader.cs b/irc/TechBot/Compression/InflaterDynHeader.cs deleted file mode 100644 index 653c7847cea..00000000000 --- a/irc/TechBot/Compression/InflaterDynHeader.cs +++ /dev/null @@ -1,207 +0,0 @@ -// InflaterDynHeader.cs -// Copyright (C) 2001 Mike Krueger -// -// This file was translated from java, it was part of the GNU Classpath -// Copyright (C) 2001 Free Software Foundation, Inc. -// -// 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -// -// Linking this library statically or dynamically with other modules is -// making a combined work based on this library. Thus, the terms and -// conditions of the GNU General Public License cover the whole -// combination. -// -// As a special exception, the copyright holders of this library give you -// permission to link this library with independent modules to produce an -// executable, regardless of the license terms of these independent -// modules, and to copy and distribute the resulting executable under -// terms of your choice, provided that you also meet, for each linked -// independent module, the terms and conditions of the license of that -// module. An independent module is a module which is not derived from -// or based on this library. If you modify this library, you may extend -// this exception to your version of the library, but you are not -// obligated to do so. If you do not wish to do so, delete this -// exception statement from your version. - -using System; - -using ICSharpCode.SharpZipLib.Zip.Compression.Streams; - -namespace ICSharpCode.SharpZipLib.Zip.Compression -{ - - class InflaterDynHeader - { - const int LNUM = 0; - const int DNUM = 1; - const int BLNUM = 2; - const int BLLENS = 3; - const int LENS = 4; - const int REPS = 5; - - static readonly int[] repMin = { 3, 3, 11 }; - static readonly int[] repBits = { 2, 3, 7 }; - - byte[] blLens; - byte[] litdistLens; - - InflaterHuffmanTree blTree; - - int mode; - int lnum, dnum, blnum, num; - int repSymbol; - byte lastLen; - int ptr; - - static readonly int[] BL_ORDER = - { 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15 }; - - public InflaterDynHeader() - { - } - - public bool Decode(StreamManipulator input) - { - decode_loop: - for (;;) { - switch (mode) { - case LNUM: - lnum = input.PeekBits(5); - if (lnum < 0) { - return false; - } - lnum += 257; - input.DropBits(5); - // System.err.println("LNUM: "+lnum); - mode = DNUM; - goto case DNUM; // fall through - case DNUM: - dnum = input.PeekBits(5); - if (dnum < 0) { - return false; - } - dnum++; - input.DropBits(5); - // System.err.println("DNUM: "+dnum); - num = lnum+dnum; - litdistLens = new byte[num]; - mode = BLNUM; - goto case BLNUM; // fall through - case BLNUM: - blnum = input.PeekBits(4); - if (blnum < 0) { - return false; - } - blnum += 4; - input.DropBits(4); - blLens = new byte[19]; - ptr = 0; - // System.err.println("BLNUM: "+blnum); - mode = BLLENS; - goto case BLLENS; // fall through - case BLLENS: - while (ptr < blnum) { - int len = input.PeekBits(3); - if (len < 0) { - return false; - } - input.DropBits(3); - // System.err.println("blLens["+BL_ORDER[ptr]+"]: "+len); - blLens[BL_ORDER[ptr]] = (byte) len; - ptr++; - } - blTree = new InflaterHuffmanTree(blLens); - blLens = null; - ptr = 0; - mode = LENS; - goto case LENS; // fall through - case LENS: - { - int symbol; - while (((symbol = blTree.GetSymbol(input)) & ~15) == 0) { - /* Normal case: symbol in [0..15] */ - - // System.err.println("litdistLens["+ptr+"]: "+symbol); - litdistLens[ptr++] = lastLen = (byte)symbol; - - if (ptr == num) { - /* Finished */ - return true; - } - } - - /* need more input ? */ - if (symbol < 0) { - return false; - } - - /* otherwise repeat code */ - if (symbol >= 17) { - /* repeat zero */ - // System.err.println("repeating zero"); - lastLen = 0; - } else { - if (ptr == 0) { - throw new Exception(); - } - } - repSymbol = symbol-16; - } - mode = REPS; - goto case REPS; // fall through - case REPS: - { - int bits = repBits[repSymbol]; - int count = input.PeekBits(bits); - if (count < 0) { - return false; - } - input.DropBits(bits); - count += repMin[repSymbol]; - // System.err.println("litdistLens repeated: "+count); - - if (ptr + count > num) { - throw new Exception(); - } - while (count-- > 0) { - litdistLens[ptr++] = lastLen; - } - - if (ptr == num) { - /* Finished */ - return true; - } - } - mode = LENS; - goto decode_loop; - } - } - } - - public InflaterHuffmanTree BuildLitLenTree() - { - byte[] litlenLens = new byte[lnum]; - Array.Copy(litdistLens, 0, litlenLens, 0, lnum); - return new InflaterHuffmanTree(litlenLens); - } - - public InflaterHuffmanTree BuildDistTree() - { - byte[] distLens = new byte[dnum]; - Array.Copy(litdistLens, lnum, distLens, 0, dnum); - return new InflaterHuffmanTree(distLens); - } - } -} diff --git a/irc/TechBot/Compression/InflaterHuffmanTree.cs b/irc/TechBot/Compression/InflaterHuffmanTree.cs deleted file mode 100644 index 02beb60a34c..00000000000 --- a/irc/TechBot/Compression/InflaterHuffmanTree.cs +++ /dev/null @@ -1,213 +0,0 @@ -// InflaterHuffmanTree.cs -// Copyright (C) 2001 Mike Krueger -// -// This file was translated from java, it was part of the GNU Classpath -// Copyright (C) 2001 Free Software Foundation, Inc. -// -// 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -// -// Linking this library statically or dynamically with other modules is -// making a combined work based on this library. Thus, the terms and -// conditions of the GNU General Public License cover the whole -// combination. -// -// As a special exception, the copyright holders of this library give you -// permission to link this library with independent modules to produce an -// executable, regardless of the license terms of these independent -// modules, and to copy and distribute the resulting executable under -// terms of your choice, provided that you also meet, for each linked -// independent module, the terms and conditions of the license of that -// module. An independent module is a module which is not derived from -// or based on this library. If you modify this library, you may extend -// this exception to your version of the library, but you are not -// obligated to do so. If you do not wish to do so, delete this -// exception statement from your version. - -using System; - -using ICSharpCode.SharpZipLib.Zip.Compression.Streams; - -namespace ICSharpCode.SharpZipLib.Zip.Compression -{ - - public class InflaterHuffmanTree - { - private static int MAX_BITLEN = 15; - private short[] tree; - - public static InflaterHuffmanTree defLitLenTree, defDistTree; - - static InflaterHuffmanTree() - { - try { - byte[] codeLengths = new byte[288]; - int i = 0; - while (i < 144) { - codeLengths[i++] = 8; - } - while (i < 256) { - codeLengths[i++] = 9; - } - while (i < 280) { - codeLengths[i++] = 7; - } - while (i < 288) { - codeLengths[i++] = 8; - } - defLitLenTree = new InflaterHuffmanTree(codeLengths); - - codeLengths = new byte[32]; - i = 0; - while (i < 32) { - codeLengths[i++] = 5; - } - defDistTree = new InflaterHuffmanTree(codeLengths); - } catch (Exception) { - throw new ApplicationException("InflaterHuffmanTree: static tree length illegal"); - } - } - - /// - /// Constructs a Huffman tree from the array of code lengths. - /// - /// - /// the array of code lengths - /// - public InflaterHuffmanTree(byte[] codeLengths) - { - BuildTree(codeLengths); - } - - private void BuildTree(byte[] codeLengths) - { - int[] blCount = new int[MAX_BITLEN + 1]; - int[] nextCode = new int[MAX_BITLEN + 1]; - - for (int i = 0; i < codeLengths.Length; i++) { - int bits = codeLengths[i]; - if (bits > 0) { - blCount[bits]++; - } - } - - int code = 0; - int treeSize = 512; - for (int bits = 1; bits <= MAX_BITLEN; bits++) { - nextCode[bits] = code; - code += blCount[bits] << (16 - bits); - if (bits >= 10) { - /* We need an extra table for bit lengths >= 10. */ - int start = nextCode[bits] & 0x1ff80; - int end = code & 0x1ff80; - treeSize += (end - start) >> (16 - bits); - } - } -/* -jr comment this out! doesnt work for dynamic trees and pkzip 2.04g - if (code != 65536) - { - throw new Exception("Code lengths don't add up properly."); - } -*/ - /* Now create and fill the extra tables from longest to shortest - * bit len. This way the sub trees will be aligned. - */ - tree = new short[treeSize]; - int treePtr = 512; - for (int bits = MAX_BITLEN; bits >= 10; bits--) { - int end = code & 0x1ff80; - code -= blCount[bits] << (16 - bits); - int start = code & 0x1ff80; - for (int i = start; i < end; i += 1 << 7) { - tree[DeflaterHuffman.BitReverse(i)] = (short) ((-treePtr << 4) | bits); - treePtr += 1 << (bits-9); - } - } - - for (int i = 0; i < codeLengths.Length; i++) { - int bits = codeLengths[i]; - if (bits == 0) { - continue; - } - code = nextCode[bits]; - int revcode = DeflaterHuffman.BitReverse(code); - if (bits <= 9) { - do { - tree[revcode] = (short) ((i << 4) | bits); - revcode += 1 << bits; - } while (revcode < 512); - } else { - int subTree = tree[revcode & 511]; - int treeLen = 1 << (subTree & 15); - subTree = -(subTree >> 4); - do { - tree[subTree | (revcode >> 9)] = (short) ((i << 4) | bits); - revcode += 1 << bits; - } while (revcode < treeLen); - } - nextCode[bits] = code + (1 << (16 - bits)); - } - - } - - /// - /// Reads the next symbol from input. The symbol is encoded using the - /// huffman tree. - /// - /// - /// input the input source. - /// - /// - /// the next symbol, or -1 if not enough input is available. - /// - public int GetSymbol(StreamManipulator input) - { - int lookahead, symbol; - if ((lookahead = input.PeekBits(9)) >= 0) { - if ((symbol = tree[lookahead]) >= 0) { - input.DropBits(symbol & 15); - return symbol >> 4; - } - int subtree = -(symbol >> 4); - int bitlen = symbol & 15; - if ((lookahead = input.PeekBits(bitlen)) >= 0) { - symbol = tree[subtree | (lookahead >> 9)]; - input.DropBits(symbol & 15); - return symbol >> 4; - } else { - int bits = input.AvailableBits; - lookahead = input.PeekBits(bits); - symbol = tree[subtree | (lookahead >> 9)]; - if ((symbol & 15) <= bits) { - input.DropBits(symbol & 15); - return symbol >> 4; - } else { - return -1; - } - } - } else { - int bits = input.AvailableBits; - lookahead = input.PeekBits(bits); - symbol = tree[lookahead]; - if (symbol >= 0 && (symbol & 15) <= bits) { - input.DropBits(symbol & 15); - return symbol >> 4; - } else { - return -1; - } - } - } - } -} - diff --git a/irc/TechBot/Compression/PendingBuffer.cs b/irc/TechBot/Compression/PendingBuffer.cs deleted file mode 100644 index e0bc96b9192..00000000000 --- a/irc/TechBot/Compression/PendingBuffer.cs +++ /dev/null @@ -1,210 +0,0 @@ -// PendingBuffer.cs -// Copyright (C) 2001 Mike Krueger -// -// This file was translated from java, it was part of the GNU Classpath -// Copyright (C) 2001 Free Software Foundation, Inc. -// -// 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -// -// Linking this library statically or dynamically with other modules is -// making a combined work based on this library. Thus, the terms and -// conditions of the GNU General Public License cover the whole -// combination. -// -// As a special exception, the copyright holders of this library give you -// permission to link this library with independent modules to produce an -// executable, regardless of the license terms of these independent -// modules, and to copy and distribute the resulting executable under -// terms of your choice, provided that you also meet, for each linked -// independent module, the terms and conditions of the license of that -// module. An independent module is a module which is not derived from -// or based on this library. If you modify this library, you may extend -// this exception to your version of the library, but you are not -// obligated to do so. If you do not wish to do so, delete this -// exception statement from your version. - -using System; - -namespace ICSharpCode.SharpZipLib.Zip.Compression -{ - - /// - /// This class is general purpose class for writing data to a buffer. - /// - /// It allows you to write bits as well as bytes - /// Based on DeflaterPending.java - /// - /// author of the original java version : Jochen Hoenicke - /// - public class PendingBuffer - { - protected byte[] buf; - int start; - int end; - - uint bits; - int bitCount; - - public PendingBuffer() : this( 4096 ) - { - - } - - public PendingBuffer(int bufsize) - { - buf = new byte[bufsize]; - } - - public void Reset() - { - start = end = bitCount = 0; - } - - public void WriteByte(int b) - { - if (DeflaterConstants.DEBUGGING && start != 0) { - throw new Exception(); - } - buf[end++] = (byte) b; - } - - public void WriteShort(int s) - { - if (DeflaterConstants.DEBUGGING && start != 0) { - throw new Exception(); - } - buf[end++] = (byte) s; - buf[end++] = (byte) (s >> 8); - } - - public void WriteInt(int s) - { - if (DeflaterConstants.DEBUGGING && start != 0) { - throw new Exception(); - } - buf[end++] = (byte) s; - buf[end++] = (byte) (s >> 8); - buf[end++] = (byte) (s >> 16); - buf[end++] = (byte) (s >> 24); - } - - public void WriteBlock(byte[] block, int offset, int len) - { - if (DeflaterConstants.DEBUGGING && start != 0) { - throw new Exception(); - } - System.Array.Copy(block, offset, buf, end, len); - end += len; - } - - public int BitCount { - get { - return bitCount; - } - } - - public void AlignToByte() - { - if (DeflaterConstants.DEBUGGING && start != 0) { - throw new Exception(); - } - if (bitCount > 0) { - buf[end++] = (byte) bits; - if (bitCount > 8) { - buf[end++] = (byte) (bits >> 8); - } - } - bits = 0; - bitCount = 0; - } - - public void WriteBits(int b, int count) - { - if (DeflaterConstants.DEBUGGING && start != 0) { - throw new Exception(); - } - // if (DeflaterConstants.DEBUGGING) { - // //Console.WriteLine("writeBits("+b+","+count+")"); - // } - bits |= (uint)(b << bitCount); - bitCount += count; - if (bitCount >= 16) { - buf[end++] = (byte) bits; - buf[end++] = (byte) (bits >> 8); - bits >>= 16; - bitCount -= 16; - } - } - - public void WriteShortMSB(int s) - { - if (DeflaterConstants.DEBUGGING && start != 0) { - throw new Exception(); - } - buf[end++] = (byte) (s >> 8); - buf[end++] = (byte) s; - } - - public bool IsFlushed { - get { - return end == 0; - } - } - - /// - /// Flushes the pending buffer into the given output array. If the - /// output array is to small, only a partial flush is done. - /// - /// - /// the output array; - /// - /// - /// the offset into output array; - /// - /// - /// length the maximum number of bytes to store; - /// - /// - /// IndexOutOfBoundsException if offset or length are invalid. - /// - public int Flush(byte[] output, int offset, int length) - { - if (bitCount >= 8) { - buf[end++] = (byte) bits; - bits >>= 8; - bitCount -= 8; - } - if (length > end - start) { - length = end - start; - System.Array.Copy(buf, start, output, offset, length); - start = 0; - end = 0; - } else { - System.Array.Copy(buf, start, output, offset, length); - start += length; - } - return length; - } - - public byte[] ToByteArray() - { - byte[] ret = new byte[end - start]; - System.Array.Copy(buf, start, ret, 0, ret.Length); - start = 0; - end = 0; - return ret; - } - } -} diff --git a/irc/TechBot/Compression/Streams/DeflaterOutputStream.cs b/irc/TechBot/Compression/Streams/DeflaterOutputStream.cs deleted file mode 100644 index dd8c658e843..00000000000 --- a/irc/TechBot/Compression/Streams/DeflaterOutputStream.cs +++ /dev/null @@ -1,379 +0,0 @@ -// DeflaterOutputStream.cs -// Copyright (C) 2001 Mike Krueger -// -// This file was translated from java, it was part of the GNU Classpath -// Copyright (C) 2001 Free Software Foundation, Inc. -// -// 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -// -// Linking this library statically or dynamically with other modules is -// making a combined work based on this library. Thus, the terms and -// conditions of the GNU General Public License cover the whole -// combination. -// -// As a special exception, the copyright holders of this library give you -// permission to link this library with independent modules to produce an -// executable, regardless of the license terms of these independent -// modules, and to copy and distribute the resulting executable under -// terms of your choice, provided that you also meet, for each linked -// independent module, the terms and conditions of the license of that -// module. An independent module is a module which is not derived from -// or based on this library. If you modify this library, you may extend -// this exception to your version of the library, but you are not -// obligated to do so. If you do not wish to do so, delete this -// exception statement from your version. - -using System; -using System.IO; -using ICSharpCode.SharpZipLib.Checksums; -using ICSharpCode.SharpZipLib.Zip.Compression; - -namespace ICSharpCode.SharpZipLib.Zip.Compression.Streams -{ - - /// - /// This is a special FilterOutputStream deflating the bytes that are - /// written through it. It uses the Deflater for deflating. - /// - /// authors of the original java version : Tom Tromey, Jochen Hoenicke - /// - public class DeflaterOutputStream : Stream - { - /// - /// This buffer is used temporarily to retrieve the bytes from the - /// deflater and write them to the underlying output stream. - /// - protected byte[] buf; - - /// - /// The deflater which is used to deflate the stream. - /// - protected Deflater def; - - /// - /// base stream the deflater depends on. - /// - protected Stream baseOutputStream; - - /// - /// I needed to implement the abstract member. - /// - public override bool CanRead { - get { - return baseOutputStream.CanRead; - } - } - - /// - /// I needed to implement the abstract member. - /// - public override bool CanSeek { - get { - return false; -// return baseOutputStream.CanSeek; - } - } - - /// - /// I needed to implement the abstract member. - /// - public override bool CanWrite { - get { - return baseOutputStream.CanWrite; - } - } - - /// - /// I needed to implement the abstract member. - /// - public override long Length { - get { - return baseOutputStream.Length; - } - } - - /// - /// I needed to implement the abstract member. - /// - public override long Position { - get { - return baseOutputStream.Position; - } - set { - baseOutputStream.Position = value; - } - } - - /// - /// I needed to implement the abstract member. - /// - public override long Seek(long offset, SeekOrigin origin) - { - throw new NotSupportedException("Seek not supported"); // -jr- 01-Dec-2003 -// return baseOutputStream.Seek(offset, origin); - } - - /// - /// I needed to implement the abstract member. - /// - public override void SetLength(long val) - { - baseOutputStream.SetLength(val); - } - - /// - /// I needed to implement the abstract member. - /// - public override int ReadByte() - { - return baseOutputStream.ReadByte(); - } - - /// - /// I needed to implement the abstract member. - /// - public override int Read(byte[] b, int off, int len) - { - return baseOutputStream.Read(b, off, len); - } - // -jr- 01-Dec-2003 - public override IAsyncResult BeginRead(byte[] buffer, int offset, int count, AsyncCallback callback, object state) - { - throw new NotSupportedException("Asynch read not currently supported"); - } - - // -jr- 01-Dec-2003 - public override IAsyncResult BeginWrite(byte[] buffer, int offset, int count, AsyncCallback callback, object state) - { - throw new NotSupportedException("Asynch write not currently supported"); - } - - /// - /// Deflates everything in the def's input buffers. This will call - /// def.deflate() until all bytes from the input buffers - /// are processed. - /// - protected void Deflate() - { - while (!def.IsNeedingInput) { - int len = def.Deflate(buf, 0, buf.Length); - - // System.err.println("DOS deflated " + len + " baseOutputStream of " + buf.length); - if (len <= 0) { - break; - } - baseOutputStream.Write(buf, 0, len); - } - - if (!def.IsNeedingInput) { - throw new ApplicationException("Can't deflate all input?"); - } - } - - /// - /// Creates a new DeflaterOutputStream with a default Deflater and default buffer size. - /// - /// - /// the output stream where deflated output should be written. - /// - public DeflaterOutputStream(Stream baseOutputStream) : this(baseOutputStream, new Deflater(), 512) - { - } - - /// - /// Creates a new DeflaterOutputStream with the given Deflater and - /// default buffer size. - /// - /// - /// the output stream where deflated output should be written. - /// - /// - /// the underlying deflater. - /// - public DeflaterOutputStream(Stream baseOutputStream, Deflater defl) :this(baseOutputStream, defl, 512) - { - } - - /// - /// Creates a new DeflaterOutputStream with the given Deflater and - /// buffer size. - /// - /// - /// the output stream where deflated output should be written. - /// - /// - /// the underlying deflater. - /// - /// - /// the buffer size. - /// - /// - /// if bufsize isn't positive. - /// - public DeflaterOutputStream(Stream baseOutputStream, Deflater defl, int bufsize) - { - this.baseOutputStream = baseOutputStream; - if (bufsize <= 0) { - throw new InvalidOperationException("bufsize <= 0"); - } - buf = new byte[bufsize]; - def = defl; - } - - /// - /// Flushes the stream by calling flush() on the deflater and then - /// on the underlying stream. This ensures that all bytes are - /// flushed. - /// - public override void Flush() - { - def.Flush(); - Deflate(); - baseOutputStream.Flush(); - } - - /// - /// Finishes the stream by calling finish() on the deflater. - /// - public virtual void Finish() - { - def.Finish(); - while (!def.IsFinished) { - int len = def.Deflate(buf, 0, buf.Length); - if (len <= 0) { - break; - } - - // kidnthrain encryption alteration - if (this.Password != null) { - // plain data has been deflated. Now encrypt result - this.EncryptBlock(buf, 0, len); - } - - baseOutputStream.Write(buf, 0, len); - } - if (!def.IsFinished) { - throw new ApplicationException("Can't deflate all input?"); - } - baseOutputStream.Flush(); - } - - /// - /// Calls finish () and closes the stream. - /// - public override void Close() - { - Finish(); - baseOutputStream.Close(); - } - - /// - /// Writes a single byte to the compressed output stream. - /// - /// - /// the byte value. - /// - public override void WriteByte(byte bval) - { - byte[] b = new byte[1]; - b[0] = (byte) bval; - Write(b, 0, 1); - } - - /// - /// Writes a len bytes from an array to the compressed stream. - /// - /// - /// the byte array. - /// - /// - /// the offset into the byte array where to start. - /// - /// - /// the number of bytes to write. - /// - public override void Write(byte[] buf, int off, int len) - { - // System.err.println("DOS with off " + off + " and len " + len); - def.SetInput(buf, off, len); - Deflate(); - } - - #region Encryption - string password = null; - uint[] keys = null; - - public string Password { - get { - return password; - } - set { - password = value; - } - } - - - //The beauty of xor-ing bits is that - //plain ^ key = enc - //and enc ^ key = plain - //accordingly, this is the exact same as the decrypt byte - //function in InflaterInputStream - protected byte EncryptByte() - { - uint temp = ((keys[2] & 0xFFFF) | 2); - return (byte)((temp * (temp ^ 1)) >> 8); - } - - - /// - /// Takes a buffer of data and uses the keys - /// that have been previously initialized from a - /// password and then updated via a random encryption header - /// to encrypt that data - /// - protected void EncryptBlock(byte[] buf, int off, int len) - { - for (int i = off; i < off + len; ++i) { - byte oldbyte = buf[i]; - buf[i] ^= EncryptByte(); - UpdateKeys(oldbyte); - } - } - - /// - /// Initializes our encryption keys using a given password - /// - protected void InitializePassword(string password) { - keys = new uint[] { - 0x12345678, - 0x23456789, - 0x34567890 - }; - - for (int i = 0; i < password.Length; ++i) { - UpdateKeys((byte)password[i]); - } - } - - protected void UpdateKeys(byte ch) - { - keys[0] = Crc32.ComputeCrc32(keys[0], ch); - keys[1] = keys[1] + (byte)keys[0]; - keys[1] = keys[1] * 134775813 + 1; - keys[2] = Crc32.ComputeCrc32(keys[2], (byte)(keys[1] >> 24)); - } - #endregion - } -} diff --git a/irc/TechBot/Compression/Streams/InflaterInputStream.cs b/irc/TechBot/Compression/Streams/InflaterInputStream.cs deleted file mode 100644 index 9317e5e185d..00000000000 --- a/irc/TechBot/Compression/Streams/InflaterInputStream.cs +++ /dev/null @@ -1,386 +0,0 @@ -// InflaterInputStream.cs -// Copyright (C) 2001 Mike Krueger -// -// This file was translated from java, it was part of the GNU Classpath -// Copyright (C) 2001 Free Software Foundation, Inc. -// -// 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -// -// Linking this library statically or dynamically with other modules is -// making a combined work based on this library. Thus, the terms and -// conditions of the GNU General Public License cover the whole -// combination. -// -// As a special exception, the copyright holders of this library give you -// permission to link this library with independent modules to produce an -// executable, regardless of the license terms of these independent -// modules, and to copy and distribute the resulting executable under -// terms of your choice, provided that you also meet, for each linked -// independent module, the terms and conditions of the license of that -// module. An independent module is a module which is not derived from -// or based on this library. If you modify this library, you may extend -// this exception to your version of the library, but you are not -// obligated to do so. If you do not wish to do so, delete this -// exception statement from your version. - -using System; -using System.IO; - -using ICSharpCode.SharpZipLib.Zip.Compression; -using ICSharpCode.SharpZipLib.Checksums; - -namespace ICSharpCode.SharpZipLib.Zip.Compression.Streams -{ - - /// - /// This filter stream is used to decompress data compressed baseInputStream the "deflate" - /// format. The "deflate" format is described baseInputStream RFC 1951. - /// - /// This stream may form the basis for other decompression filters, such - /// as the GzipInputStream. - /// - /// author of the original java version : John Leuner - /// - public class InflaterInputStream : Stream - { - //Variables - - /// - /// Decompressor for this filter - /// - protected Inflater inf; - - /// - /// Byte array used as a buffer - /// - protected byte[] buf; - - /// - /// Size of buffer - /// - protected int len; - - //We just use this if we are decoding one byte at a time with the read() call - private byte[] onebytebuffer = new byte[1]; - - /// - /// base stream the inflater depends on. - /// - protected Stream baseInputStream; - - protected long csize; - - /// - /// I needed to implement the abstract member. - /// - public override bool CanRead { - get { - return baseInputStream.CanRead; - } - } - - /// - /// I needed to implement the abstract member. - /// - public override bool CanSeek { - get { - return false; - // return baseInputStream.CanSeek; - } - } - - /// - /// I needed to implement the abstract member. - /// - public override bool CanWrite { - get { - return baseInputStream.CanWrite; - } - } - - /// - /// I needed to implement the abstract member. - /// - public override long Length { - get { - return len; - } - } - - /// - /// I needed to implement the abstract member. - /// - public override long Position { - get { - return baseInputStream.Position; - } - set { - baseInputStream.Position = value; - } - } - - /// - /// Flushes the baseInputStream - /// - public override void Flush() - { - baseInputStream.Flush(); - } - - /// - /// I needed to implement the abstract member. - /// - public override long Seek(long offset, SeekOrigin origin) - { - throw new NotSupportedException("Seek not supported"); // -jr- 01-Dec-2003 - } - - /// - /// I needed to implement the abstract member. - /// - public override void SetLength(long val) - { - baseInputStream.SetLength(val); - } - - /// - /// I needed to implement the abstract member. - /// - public override void Write(byte[] array, int offset, int count) - { - baseInputStream.Write(array, offset, count); - } - - /// - /// I needed to implement the abstract member. - /// - public override void WriteByte(byte val) - { - baseInputStream.WriteByte(val); - } - - // -jr- 01-Dec-2003 This may be flawed for some base streams? Depends on implementation of BeginWrite - public override IAsyncResult BeginWrite(byte[] buffer, int offset, int count, AsyncCallback callback, object state) - { - throw new NotSupportedException("Asynch write not currently supported"); - } - - //Constructors - - /// - /// Create an InflaterInputStream with the default decompresseor - /// and a default buffer size. - /// - /// - /// the InputStream to read bytes from - /// - public InflaterInputStream(Stream baseInputStream) : this(baseInputStream, new Inflater(), 4096) - { - - } - - /// - /// Create an InflaterInputStream with the specified decompresseor - /// and a default buffer size. - /// - /// - /// the InputStream to read bytes from - /// - /// - /// the decompressor used to decompress data read from baseInputStream - /// - public InflaterInputStream(Stream baseInputStream, Inflater inf) : this(baseInputStream, inf, 4096) - { - } - - /// - /// Create an InflaterInputStream with the specified decompresseor - /// and a specified buffer size. - /// - /// - /// the InputStream to read bytes from - /// - /// - /// the decompressor used to decompress data read from baseInputStream - /// - /// - /// size of the buffer to use - /// - public InflaterInputStream(Stream baseInputStream, Inflater inf, int size) - { - this.baseInputStream = baseInputStream; - this.inf = inf; - try { - this.len = (int)baseInputStream.Length; - } catch (Exception) { - // the stream may not support .Length - this.len = 0; - } - - if (size <= 0) { - throw new ArgumentOutOfRangeException("size <= 0"); - } - - buf = new byte[size]; //Create the buffer - } - - //Methods - - /// - /// Returns 0 once the end of the stream (EOF) has been reached. - /// Otherwise returns 1. - /// - public virtual int Available { - get { - return inf.IsFinished ? 0 : 1; - } - } - - /// - /// Closes the input stream - /// - public override void Close() - { - baseInputStream.Close(); - } - - /// - /// Fills the buffer with more data to decompress. - /// - protected void Fill() - { - len = baseInputStream.Read(buf, 0, buf.Length); - // decrypting crypted data - if (cryptbuffer != null) { - DecryptBlock(buf, 0, System.Math.Min((int)(csize - inf.TotalIn), buf.Length)); - } - - if (len <= 0) { - throw new ApplicationException("Deflated stream ends early."); - } - inf.SetInput(buf, 0, len); - } - - /// - /// Reads one byte of decompressed data. - /// - /// The byte is baseInputStream the lower 8 bits of the int. - /// - public override int ReadByte() - { - int nread = Read(onebytebuffer, 0, 1); //read one byte - if (nread > 0) { - return onebytebuffer[0] & 0xff; - } - return -1; // ok - } - - /// - /// Decompresses data into the byte array - /// - /// - /// the array to read and decompress data into - /// - /// - /// the offset indicating where the data should be placed - /// - /// - /// the number of bytes to decompress - /// - public override int Read(byte[] b, int off, int len) - { - for (;;) { - int count; - try { - count = inf.Inflate(b, off, len); - } catch (Exception e) { - throw new ZipException(e.ToString()); - } - - if (count > 0) { - return count; - } - - if (inf.IsNeedingDictionary) { - throw new ZipException("Need a dictionary"); - } else if (inf.IsFinished) { - return 0; - } else if (inf.IsNeedingInput) { - Fill(); - } else { - throw new InvalidOperationException("Don't know what to do"); - } - } - } - - /// - /// Skip specified number of bytes of uncompressed data - /// - /// - /// number of bytes to skip - /// - public long Skip(long n) - { - if (n < 0) { - throw new ArgumentOutOfRangeException("n"); - } - int len = 2048; - if (n < len) { - len = (int) n; - } - byte[] tmp = new byte[len]; - return (long)baseInputStream.Read(tmp, 0, tmp.Length); - } - - #region Encryption stuff - protected byte[] cryptbuffer = null; - - uint[] keys = null; - protected byte DecryptByte() - { - uint temp = ((keys[2] & 0xFFFF) | 2); - return (byte)((temp * (temp ^ 1)) >> 8); - } - - protected void DecryptBlock(byte[] buf, int off, int len) - { - for (int i = off; i < off + len; ++i) { - buf[i] ^= DecryptByte(); - UpdateKeys(buf[i]); - } - } - - protected void InitializePassword(string password) - { - keys = new uint[] { - 0x12345678, - 0x23456789, - 0x34567890 - }; - for (int i = 0; i < password.Length; ++i) { - UpdateKeys((byte)password[i]); - } - } - - protected void UpdateKeys(byte ch) - { - keys[0] = Crc32.ComputeCrc32(keys[0], ch); - keys[1] = keys[1] + (byte)keys[0]; - keys[1] = keys[1] * 134775813 + 1; - keys[2] = Crc32.ComputeCrc32(keys[2], (byte)(keys[1] >> 24)); - } - #endregion - } -} diff --git a/irc/TechBot/Compression/Streams/OutputWindow.cs b/irc/TechBot/Compression/Streams/OutputWindow.cs deleted file mode 100644 index 426c1f752d3..00000000000 --- a/irc/TechBot/Compression/Streams/OutputWindow.cs +++ /dev/null @@ -1,176 +0,0 @@ -// OutputWindow.cs -// Copyright (C) 2001 Mike Krueger -// -// This file was translated from java, it was part of the GNU Classpath -// Copyright (C) 2001 Free Software Foundation, Inc. -// -// 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -// -// Linking this library statically or dynamically with other modules is -// making a combined work based on this library. Thus, the terms and -// conditions of the GNU General Public License cover the whole -// combination. -// -// As a special exception, the copyright holders of this library give you -// permission to link this library with independent modules to produce an -// executable, regardless of the license terms of these independent -// modules, and to copy and distribute the resulting executable under -// terms of your choice, provided that you also meet, for each linked -// independent module, the terms and conditions of the license of that -// module. An independent module is a module which is not derived from -// or based on this library. If you modify this library, you may extend -// this exception to your version of the library, but you are not -// obligated to do so. If you do not wish to do so, delete this -// exception statement from your version. - -using System; - -namespace ICSharpCode.SharpZipLib.Zip.Compression.Streams -{ - - /// - /// Contains the output from the Inflation process. - /// We need to have a window so that we can refer backwards into the output stream - /// to repeat stuff. - /// - /// author of the original java version : John Leuner - /// - public class OutputWindow - { - private static int WINDOW_SIZE = 1 << 15; - private static int WINDOW_MASK = WINDOW_SIZE - 1; - - private byte[] window = new byte[WINDOW_SIZE]; //The window is 2^15 bytes - private int windowEnd = 0; - private int windowFilled = 0; - - public void Write(int abyte) - { - if (windowFilled++ == WINDOW_SIZE) { - throw new InvalidOperationException("Window full"); - } - window[windowEnd++] = (byte) abyte; - windowEnd &= WINDOW_MASK; - } - - - private void SlowRepeat(int repStart, int len, int dist) - { - while (len-- > 0) { - window[windowEnd++] = window[repStart++]; - windowEnd &= WINDOW_MASK; - repStart &= WINDOW_MASK; - } - } - - public void Repeat(int len, int dist) - { - if ((windowFilled += len) > WINDOW_SIZE) { - throw new InvalidOperationException("Window full"); - } - - int rep_start = (windowEnd - dist) & WINDOW_MASK; - int border = WINDOW_SIZE - len; - if (rep_start <= border && windowEnd < border) { - if (len <= dist) { - System.Array.Copy(window, rep_start, window, windowEnd, len); - windowEnd += len; - } else { - /* We have to copy manually, since the repeat pattern overlaps. - */ - while (len-- > 0) { - window[windowEnd++] = window[rep_start++]; - } - } - } else { - SlowRepeat(rep_start, len, dist); - } - } - - public int CopyStored(StreamManipulator input, int len) - { - len = Math.Min(Math.Min(len, WINDOW_SIZE - windowFilled), input.AvailableBytes); - int copied; - - int tailLen = WINDOW_SIZE - windowEnd; - if (len > tailLen) { - copied = input.CopyBytes(window, windowEnd, tailLen); - if (copied == tailLen) { - copied += input.CopyBytes(window, 0, len - tailLen); - } - } else { - copied = input.CopyBytes(window, windowEnd, len); - } - - windowEnd = (windowEnd + copied) & WINDOW_MASK; - windowFilled += copied; - return copied; - } - - public void CopyDict(byte[] dict, int offset, int len) - { - if (windowFilled > 0) { - throw new InvalidOperationException(); - } - - if (len > WINDOW_SIZE) { - offset += len - WINDOW_SIZE; - len = WINDOW_SIZE; - } - System.Array.Copy(dict, offset, window, 0, len); - windowEnd = len & WINDOW_MASK; - } - - public int GetFreeSpace() - { - return WINDOW_SIZE - windowFilled; - } - - public int GetAvailable() - { - return windowFilled; - } - - public int CopyOutput(byte[] output, int offset, int len) - { - int copy_end = windowEnd; - if (len > windowFilled) { - len = windowFilled; - } else { - copy_end = (windowEnd - windowFilled + len) & WINDOW_MASK; - } - - int copied = len; - int tailLen = len - copy_end; - - if (tailLen > 0) { - System.Array.Copy(window, WINDOW_SIZE - tailLen, output, offset, tailLen); - offset += tailLen; - len = copy_end; - } - System.Array.Copy(window, copy_end - len, output, offset, len); - windowFilled -= copied; - if (windowFilled < 0) { - throw new InvalidOperationException(); - } - return copied; - } - - public void Reset() - { - windowFilled = windowEnd = 0; - } - } -} diff --git a/irc/TechBot/Compression/Streams/StreamManipulator.cs b/irc/TechBot/Compression/Streams/StreamManipulator.cs deleted file mode 100644 index 35f98cc4f76..00000000000 --- a/irc/TechBot/Compression/Streams/StreamManipulator.cs +++ /dev/null @@ -1,245 +0,0 @@ -// StreamManipulator.cs -// Copyright (C) 2001 Mike Krueger -// -// This file was translated from java, it was part of the GNU Classpath -// Copyright (C) 2001 Free Software Foundation, Inc. -// -// 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -// -// Linking this library statically or dynamically with other modules is -// making a combined work based on this library. Thus, the terms and -// conditions of the GNU General Public License cover the whole -// combination. -// -// As a special exception, the copyright holders of this library give you -// permission to link this library with independent modules to produce an -// executable, regardless of the license terms of these independent -// modules, and to copy and distribute the resulting executable under -// terms of your choice, provided that you also meet, for each linked -// independent module, the terms and conditions of the license of that -// module. An independent module is a module which is not derived from -// or based on this library. If you modify this library, you may extend -// this exception to your version of the library, but you are not -// obligated to do so. If you do not wish to do so, delete this -// exception statement from your version. - -using System; - -namespace ICSharpCode.SharpZipLib.Zip.Compression.Streams -{ - - /// - /// This class allows us to retrieve a specified amount of bits from - /// the input buffer, as well as copy big byte blocks. - /// - /// It uses an int buffer to store up to 31 bits for direct - /// manipulation. This guarantees that we can get at least 16 bits, - /// but we only need at most 15, so this is all safe. - /// - /// There are some optimizations in this class, for example, you must - /// never peek more then 8 bits more than needed, and you must first - /// peek bits before you may drop them. This is not a general purpose - /// class but optimized for the behaviour of the Inflater. - /// - /// authors of the original java version : John Leuner, Jochen Hoenicke - /// - public class StreamManipulator - { - private byte[] window; - private int window_start = 0; - private int window_end = 0; - - private uint buffer = 0; - private int bits_in_buffer = 0; - - /// - /// Get the next n bits but don't increase input pointer. n must be - /// less or equal 16 and if you if this call succeeds, you must drop - /// at least n-8 bits in the next call. - /// - /// - /// the value of the bits, or -1 if not enough bits available. */ - /// - public int PeekBits(int n) - { - if (bits_in_buffer < n) { - if (window_start == window_end) { - return -1; // ok - } - buffer |= (uint)((window[window_start++] & 0xff | - (window[window_start++] & 0xff) << 8) << bits_in_buffer); - bits_in_buffer += 16; - } - return (int)(buffer & ((1 << n) - 1)); - } - - /// - /// Drops the next n bits from the input. You should have called peekBits - /// with a bigger or equal n before, to make sure that enough bits are in - /// the bit buffer. - /// - public void DropBits(int n) - { - buffer >>= n; - bits_in_buffer -= n; - } - - /// - /// Gets the next n bits and increases input pointer. This is equivalent - /// to peekBits followed by dropBits, except for correct error handling. - /// - /// - /// the value of the bits, or -1 if not enough bits available. - /// - public int GetBits(int n) - { - int bits = PeekBits(n); - if (bits >= 0) { - DropBits(n); - } - return bits; - } - - /// - /// Gets the number of bits available in the bit buffer. This must be - /// only called when a previous peekBits() returned -1. - /// - /// - /// the number of bits available. - /// - public int AvailableBits { - get { - return bits_in_buffer; - } - } - - /// - /// Gets the number of bytes available. - /// - /// - /// the number of bytes available. - /// - public int AvailableBytes { - get { - return window_end - window_start + (bits_in_buffer >> 3); - } - } - - /// - /// Skips to the next byte boundary. - /// - public void SkipToByteBoundary() - { - buffer >>= (bits_in_buffer & 7); - bits_in_buffer &= ~7; - } - - public bool IsNeedingInput { - get { - return window_start == window_end; - } - } - - /// - /// Copies length bytes from input buffer to output buffer starting - /// at output[offset]. You have to make sure, that the buffer is - /// byte aligned. If not enough bytes are available, copies fewer - /// bytes. - /// - /// - /// the buffer. - /// - /// - /// the offset in the buffer. - /// - /// - /// the length to copy, 0 is allowed. - /// - /// - /// the number of bytes copied, 0 if no byte is available. - /// - public int CopyBytes(byte[] output, int offset, int length) - { - if (length < 0) { - throw new ArgumentOutOfRangeException("length negative"); - } - if ((bits_in_buffer & 7) != 0) { - /* bits_in_buffer may only be 0 or 8 */ - throw new InvalidOperationException("Bit buffer is not aligned!"); - } - - int count = 0; - while (bits_in_buffer > 0 && length > 0) { - output[offset++] = (byte) buffer; - buffer >>= 8; - bits_in_buffer -= 8; - length--; - count++; - } - if (length == 0) { - return count; - } - - int avail = window_end - window_start; - if (length > avail) { - length = avail; - } - System.Array.Copy(window, window_start, output, offset, length); - window_start += length; - - if (((window_start - window_end) & 1) != 0) { - /* We always want an even number of bytes in input, see peekBits */ - buffer = (uint)(window[window_start++] & 0xff); - bits_in_buffer = 8; - } - return count + length; - } - - public StreamManipulator() - { - } - - public void Reset() - { - buffer = (uint)(window_start = window_end = bits_in_buffer = 0); - } - - public void SetInput(byte[] buf, int off, int len) - { - if (window_start < window_end) { - throw new InvalidOperationException("Old input was not completely processed"); - } - - int end = off + len; - - /* We want to throw an ArrayIndexOutOfBoundsException early. The - * check is very tricky: it also handles integer wrap around. - */ - if (0 > off || off > end || end > buf.Length) { - throw new ArgumentOutOfRangeException(); - } - - if ((len & 1) != 0) { - /* We always want an even number of bytes in input, see peekBits */ - buffer |= (uint)((buf[off++] & 0xff) << bits_in_buffer); - bits_in_buffer += 8; - } - - window = buf; - window_start = off; - window_end = end; - } - } -} diff --git a/irc/TechBot/Compression/ZipException.cs b/irc/TechBot/Compression/ZipException.cs deleted file mode 100644 index b342592569a..00000000000 --- a/irc/TechBot/Compression/ZipException.cs +++ /dev/null @@ -1,62 +0,0 @@ -// ZipException.cs -// Copyright (C) 2001 Mike Krueger -// -// This file was translated from java, it was part of the GNU Classpath -// Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc. -// -// 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -// -// Linking this library statically or dynamically with other modules is -// making a combined work based on this library. Thus, the terms and -// conditions of the GNU General Public License cover the whole -// combination. -// -// As a special exception, the copyright holders of this library give you -// permission to link this library with independent modules to produce an -// executable, regardless of the license terms of these independent -// modules, and to copy and distribute the resulting executable under -// terms of your choice, provided that you also meet, for each linked -// independent module, the terms and conditions of the license of that -// module. An independent module is a module which is not derived from -// or based on this library. If you modify this library, you may extend -// this exception to your version of the library, but you are not -// obligated to do so. If you do not wish to do so, delete this -// exception statement from your version. - -using System; - -namespace ICSharpCode.SharpZipLib -{ - - /// - /// Is thrown during the creation or input of a zip file. - /// - public class ZipException : Exception - { - /// - /// Initializes a new instance of the ZipException class with default properties. - /// - public ZipException() - { - } - - /// - /// Initializes a new instance of the ZipException class with a specified error message. - /// - public ZipException(string msg) : base(msg) - { - } - } -} diff --git a/irc/TechBot/Resources/hresult.xml b/irc/TechBot/Resources/hresult.xml deleted file mode 100644 index 68e5bdc55e2..00000000000 --- a/irc/TechBot/Resources/hresult.xml +++ /dev/null @@ -1,1088 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/irc/TechBot/Resources/ntstatus.xml b/irc/TechBot/Resources/ntstatus.xml deleted file mode 100644 index 2e99a3bd13d..00000000000 --- a/irc/TechBot/Resources/ntstatus.xml +++ /dev/null @@ -1,1111 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/irc/TechBot/Resources/winerror.xml b/irc/TechBot/Resources/winerror.xml deleted file mode 100644 index 237ced972bb..00000000000 --- a/irc/TechBot/Resources/winerror.xml +++ /dev/null @@ -1,1839 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/irc/TechBot/Resources/wm.xml b/irc/TechBot/Resources/wm.xml deleted file mode 100644 index 86994eae728..00000000000 --- a/irc/TechBot/Resources/wm.xml +++ /dev/null @@ -1,321 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/irc/TechBot/TechBot.Commands.Common/Base/BugCommand.cs b/irc/TechBot/TechBot.Commands.Common/Base/BugCommand.cs deleted file mode 100644 index d6563d6867f..00000000000 --- a/irc/TechBot/TechBot.Commands.Common/Base/BugCommand.cs +++ /dev/null @@ -1,42 +0,0 @@ -using System; - -using TechBot.Library; - -namespace TechBot.Commands.Common -{ - public abstract class BugCommand : Command - { -// private string m_BugID = null; - - public BugCommand() - { - } - - public string BugID - { - get { return Parameters; } - set { Parameters = value; } - } - - public override void ExecuteCommand() - { - if (string.IsNullOrEmpty(BugID)) - { - Say("Please provide a valid bug number."); - } - else - { - try - { - Say(BugUrl, Int32.Parse(BugID)); - } - catch (Exception) - { - Say("{0} is not a valid bug number.", BugID); - } - } - } - - protected abstract string BugUrl { get; } - } -} diff --git a/irc/TechBot/TechBot.Commands.Common/ErrorCommand.cs b/irc/TechBot/TechBot.Commands.Common/ErrorCommand.cs deleted file mode 100644 index bb1980b032e..00000000000 --- a/irc/TechBot/TechBot.Commands.Common/ErrorCommand.cs +++ /dev/null @@ -1,180 +0,0 @@ -using System; -using System.Xml; -using System.Collections; - -using TechBot.Library; - -namespace TechBot.Commands.Common -{ - [Command("error", Help = "!error ")] - public class ErrorCommand : Command - { - private NtStatusCommand ntStatus; - private WinErrorCommand winerror; - private HResultCommand hresult; - - public ErrorCommand() - { - this.ntStatus = new NtStatusCommand(); - this.winerror = new WinErrorCommand(); - this.hresult = new HResultCommand(); - } - - private static int GetSeverity(long error) - { - return (int)((error >> 30) & 0x3); - } - - private static bool IsCustomer(long error) - { - return (error & 0x20000000) != 0; - } - - private static bool IsReserved(long error) - { - return (error & 0x10000000) != 0; - } - - private static int GetFacility(long error) - { - return (int)((error >> 16) & 0xFFF); - } - - private static short GetCode(long error) - { - return (short)((error >> 0) & 0xFFFF); - } - - private static string FormatSeverity(long error) - { - int severity = GetSeverity(error); - switch (severity) - { - case 0: return "SUCCESS"; - case 1: return "INFORMATIONAL"; - case 2: return "WARNING"; - case 3: return "ERROR"; - } - return null; - } - - private static string FormatFacility(long error) - { - int facility = GetFacility(error); - return facility.ToString(); - } - - private static string FormatCode(long error) - { - int code = GetCode(error); - return code.ToString(); - } - - public override void ExecuteCommand() - { - if (Parameters.Equals(String.Empty)) - { - Say("Please provide an Error Code."); - return; - } - - string errorText = Parameters; - - retry: - NumberParser np = new NumberParser(); - long error = np.Parse(errorText); - if (np.Error) - { - Say("{0} is not a valid Error Code.", Parameters); - return; - } - - ArrayList descriptions = new ArrayList(); - - // Error is out of bounds - if ((ulong)error > uint.MaxValue) - { - // Do nothing - } - // Error is outside of the range [0, 65535]: it cannot be a plain Win32 error code - else if ((ulong)error > ushort.MaxValue) - { - // Customer bit is set: custom error code - if (IsCustomer(error)) - { - string description = String.Format("[custom, severity {0}, facility {1}, code {2}]", - FormatSeverity(error), - FormatFacility(error), - FormatCode(error)); - descriptions.Add(description); - } - // Reserved bit is set: HRESULT_FROM_NT(ntstatus) - else if (IsReserved(error)) - { - int status = (int)(error & 0xCFFFFFFF); - string description = ntStatus.GetNtstatusDescription(status); - - if (description == null) - description = status.ToString("X"); - - description = String.Format("HRESULT_FROM_NT({0})", description); - descriptions.Add(description); - } - // Win32 facility: HRESULT_FROM_WIN32(winerror) - else if (GetFacility(error) == 7) - { - // Must be an error code - if (GetSeverity(error) == 2) - { - short err = GetCode(error); - string description = winerror.GetWinerrorDescription(err); - - if (description == null) - description = err.ToString("D"); - - description = String.Format("HRESULT_FROM_WIN32({0})", description); - descriptions.Add(description); - } - } - } - - string winerrorDescription = winerror.GetWinerrorDescription(error); - string ntstatusDescription = ntStatus.GetNtstatusDescription(error); - string hresultDescription = hresult.GetHresultDescription(error); - - if (winerrorDescription != null) - descriptions.Add(winerrorDescription); - if (ntstatusDescription != null) - descriptions.Add(ntstatusDescription); - if (hresultDescription != null) - descriptions.Add(hresultDescription); - - if (descriptions.Count == 0) - { - // Last chance heuristics: attempt to parse a 8-digit decimal as hexadecimal - if (errorText.Length == 8) - { - errorText = "0x" + errorText; - goto retry; - } - - Say("I don't know about Error Code {0}.", - Parameters); - } - else if (descriptions.Count == 1) - { - string description = (string)descriptions[0]; - Say("{0} is {1}.", - Parameters, - description); - } - else - { - Say("{0} could be:", Parameters); - - foreach (string description in descriptions) - Say("\t{0}", description); - } - } - } -} diff --git a/irc/TechBot/TechBot.Commands.Common/HResultCommand.cs b/irc/TechBot/TechBot.Commands.Common/HResultCommand.cs deleted file mode 100644 index fd42239ba43..00000000000 --- a/irc/TechBot/TechBot.Commands.Common/HResultCommand.cs +++ /dev/null @@ -1,66 +0,0 @@ -using System; -using System.Xml; - -using TechBot.Library; - -namespace TechBot.Commands.Common -{ - [Command("hresult", Help = "!hresult ")] - public class HResultCommand : XmlLookupCommand - { - public HResultCommand() - { - } - - public override string XmlFile - { - get { return Settings.Default.HResultXml; } - } - - public override void ExecuteCommand() - { - if (string.IsNullOrEmpty(Text)) - { - Say("Please provide a valid HRESULT value."); - } - else - { - NumberParser np = new NumberParser(); - long hresult = np.Parse(Text); - if (np.Error) - { - Say("{0} is not a valid HRESULT value.", Text); - return; - } - - string description = GetHresultDescription(hresult); - if (description != null) - { - Say("{0} is {1}.", - Text, - description); - } - else - { - Say("I don't know about HRESULT {0}.", Text); - } - } - } - - public string GetHresultDescription(long hresult) - { - XmlElement root = base.m_XmlDocument.DocumentElement; - XmlNode node = root.SelectSingleNode(String.Format("Hresult[@value='{0}']", - hresult.ToString("X8"))); - if (node != null) - { - XmlAttribute text = node.Attributes["text"]; - if (text == null) - throw new Exception("Node has no text attribute."); - return text.Value; - } - else - return null; - } - } -} diff --git a/irc/TechBot/TechBot.Commands.Common/NtStatusCommand.cs b/irc/TechBot/TechBot.Commands.Common/NtStatusCommand.cs deleted file mode 100644 index 96120e48bf3..00000000000 --- a/irc/TechBot/TechBot.Commands.Common/NtStatusCommand.cs +++ /dev/null @@ -1,66 +0,0 @@ -using System; -using System.Xml; - -using TechBot.Library; - -namespace TechBot.Commands.Common -{ - [Command("ntstatus", Help = "!ntstatus ")] - public class NtStatusCommand : XmlLookupCommand - { - public NtStatusCommand() - { - } - - public override string XmlFile - { - get { return Settings.Default.NtStatusXml; } - } - - public override void ExecuteCommand() - { - if (string.IsNullOrEmpty(Text)) - { - Say("Please provide a valid NTSTATUS value."); - } - else - { - NumberParser np = new NumberParser(); - long ntstatus = np.Parse(Text); - if (np.Error) - { - Say("{0} is not a valid NTSTATUS value.", Text); - return; - } - - string description = GetNtstatusDescription(ntstatus); - if (description != null) - { - Say("{0} is {1}.", - Text, - description); - } - else - { - Say("I don't know about NTSTATUS {0}.", Text); - } - } - } - - public string GetNtstatusDescription(long ntstatus) - { - XmlElement root = base.m_XmlDocument.DocumentElement; - XmlNode node = root.SelectSingleNode(String.Format("Ntstatus[@value='{0}']", - ntstatus.ToString("X8"))); - if (node != null) - { - XmlAttribute text = node.Attributes["text"]; - if (text == null) - throw new Exception("Node has no text attribute."); - return text.Value; - } - else - return null; - } - } -} diff --git a/irc/TechBot/TechBot.Commands.Common/Properties/AssemblyInfo.cs b/irc/TechBot/TechBot.Commands.Common/Properties/AssemblyInfo.cs deleted file mode 100644 index 72c565a8582..00000000000 --- a/irc/TechBot/TechBot.Commands.Common/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("TechBot.Commands.Common")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("Sand")] -[assembly: AssemblyProduct("TechBot.Commands.Common")] -[assembly: AssemblyCopyright("Copyright © Sand 2008")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("5d39d6f8-37fb-423b-ba88-1d5d8e5a1317")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Revision and Build Numbers -// by using the '*' as shown below: -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/irc/TechBot/TechBot.Commands.Common/ReactOSBugUrl.cs b/irc/TechBot/TechBot.Commands.Common/ReactOSBugUrl.cs deleted file mode 100644 index 3d94d6ba839..00000000000 --- a/irc/TechBot/TechBot.Commands.Common/ReactOSBugUrl.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -using TechBot.Library; - -namespace TechBot.Commands.Common -{ - [Command("rosbug", Help = "!rosbug ", Description = "Will give you a link to the reqested ReactOS bug")] - class ReactOSBugUrl : BugCommand - { - public ReactOSBugUrl() - { - } - - protected override string BugUrl - { - get { return "http://www.reactos.org/bugzilla/show_bug.cgi?id={0}"; } - } - } -} diff --git a/irc/TechBot/TechBot.Commands.Common/SambaBugUrl.cs b/irc/TechBot/TechBot.Commands.Common/SambaBugUrl.cs deleted file mode 100644 index 6c3767720de..00000000000 --- a/irc/TechBot/TechBot.Commands.Common/SambaBugUrl.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -using TechBot.Library; - -namespace TechBot.Commands.Common -{ - [Command("sambabug", Help = "!sambabug ", Description = "Will give you a link to the reqested Samba bug")] - class SambaBugUrl : BugCommand - { - public SambaBugUrl() - { - } - - protected override string BugUrl - { - get { return "https://bugzilla.samba.org/show_bug.cgi?id={0}"; } - } - } -} diff --git a/irc/TechBot/TechBot.Commands.Common/Settings.Designer.cs b/irc/TechBot/TechBot.Commands.Common/Settings.Designer.cs deleted file mode 100644 index d05b1de36c9..00000000000 --- a/irc/TechBot/TechBot.Commands.Common/Settings.Designer.cs +++ /dev/null @@ -1,71 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:2.0.50727.1433 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace TechBot.Commands.Common { - - - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "8.0.0.0")] - internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { - - private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); - - public static Settings Default { - get { - return defaultInstance; - } - } - - [global::System.Configuration.ApplicationScopedSettingAttribute()] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("C:\\Ros\\current\\irc\\TechBot\\Resources\\ntstatus.xml")] - public string NtStatusXml { - get { - return ((string)(this["NtStatusXml"])); - } - } - - [global::System.Configuration.ApplicationScopedSettingAttribute()] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("C:\\Ros\\current\\irc\\TechBot\\Resources\\winerror.xml")] - public string WinErrorXml { - get { - return ((string)(this["WinErrorXml"])); - } - } - - [global::System.Configuration.ApplicationScopedSettingAttribute()] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("C:\\Ros\\current\\irc\\TechBot\\Resources\\hresult.xml")] - public string HResultXml { - get { - return ((string)(this["HResultXml"])); - } - } - - [global::System.Configuration.ApplicationScopedSettingAttribute()] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("C:\\Ros\\current\\irc\\TechBot\\Resources\\wm.xml")] - public string WMXml { - get { - return ((string)(this["WMXml"])); - } - } - - [global::System.Configuration.ApplicationScopedSettingAttribute()] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("svn://svn.reactos.org/reactos/trunk")] - public string SVNRoot { - get { - return ((string)(this["SVNRoot"])); - } - } - } -} diff --git a/irc/TechBot/TechBot.Commands.Common/Settings.cs b/irc/TechBot/TechBot.Commands.Common/Settings.cs deleted file mode 100644 index 45a94a87392..00000000000 --- a/irc/TechBot/TechBot.Commands.Common/Settings.cs +++ /dev/null @@ -1,28 +0,0 @@ -namespace TechBot.Commands.Common { - - - // This class allows you to handle specific events on the settings class: - // The SettingChanging event is raised before a setting's value is changed. - // The PropertyChanged event is raised after a setting's value is changed. - // The SettingsLoaded event is raised after the setting values are loaded. - // The SettingsSaving event is raised before the setting values are saved. - internal sealed partial class Settings { - - public Settings() { - // // To add event handlers for saving and changing settings, uncomment the lines below: - // - // this.SettingChanging += this.SettingChangingEventHandler; - // - // this.SettingsSaving += this.SettingsSavingEventHandler; - // - } - - private void SettingChangingEventHandler(object sender, System.Configuration.SettingChangingEventArgs e) { - // Add code to handle the SettingChangingEvent event here. - } - - private void SettingsSavingEventHandler(object sender, System.ComponentModel.CancelEventArgs e) { - // Add code to handle the SettingsSaving event here. - } - } -} diff --git a/irc/TechBot/TechBot.Commands.Common/Settings.settings b/irc/TechBot/TechBot.Commands.Common/Settings.settings deleted file mode 100644 index 4ee296b8e5a..00000000000 --- a/irc/TechBot/TechBot.Commands.Common/Settings.settings +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - C:\Ros\current\irc\TechBot\Resources\ntstatus.xml - - - C:\Ros\current\irc\TechBot\Resources\winerror.xml - - - C:\Ros\current\irc\TechBot\Resources\hresult.xml - - - C:\Ros\current\irc\TechBot\Resources\wm.xml - - - svn://svn.reactos.org/reactos/trunk - - - \ No newline at end of file diff --git a/irc/TechBot/TechBot.Commands.Common/SvnCommand.cs b/irc/TechBot/TechBot.Commands.Common/SvnCommand.cs deleted file mode 100644 index 9604761132a..00000000000 --- a/irc/TechBot/TechBot.Commands.Common/SvnCommand.cs +++ /dev/null @@ -1,22 +0,0 @@ -using System; - -using TechBot.Library; - -namespace TechBot.Commands.Common -{ - [Command("svn", Help = "!svn" , Description="Where the ROS SVN repository is located")] - public class SvnCommand : Command - { - private string m_SvnRoot; - - public SvnCommand() - { - m_SvnRoot = Settings.Default.SVNRoot; - } - - public override void ExecuteCommand() - { - Say("svn co {0}", m_SvnRoot); - } - } -} diff --git a/irc/TechBot/TechBot.Commands.Common/TechBot.Commands.Common.csproj b/irc/TechBot/TechBot.Commands.Common/TechBot.Commands.Common.csproj deleted file mode 100644 index 589f42a206a..00000000000 --- a/irc/TechBot/TechBot.Commands.Common/TechBot.Commands.Common.csproj +++ /dev/null @@ -1,75 +0,0 @@ - - - Debug - AnyCPU - 8.0.50727 - 2.0 - {041B5F06-BF97-4981-B024-3A7B6DD9F6AE} - Library - Properties - TechBot.Commands.Common - TechBot.Commands.Common - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - - - - - - - - - - - - - - Settings.settings - True - True - - - - - - - - - {1114F34D-F388-4F38-AE27-C0EE1B10B777} - TechBot.Library - - - - - - SettingsSingleFileGenerator - Settings.Designer.cs - - - - - \ No newline at end of file diff --git a/irc/TechBot/TechBot.Commands.Common/WMCommand.cs b/irc/TechBot/TechBot.Commands.Common/WMCommand.cs deleted file mode 100644 index 2b79f4ed7ef..00000000000 --- a/irc/TechBot/TechBot.Commands.Common/WMCommand.cs +++ /dev/null @@ -1,94 +0,0 @@ -using System; -using System.Xml; - -using TechBot.Library; - -namespace TechBot.Commands.Common -{ - [Command("wm" , Help = "!wm or !wm ")] - public class WMCommand : XmlCommand - { - public WMCommand() - { - } - - public override string XmlFile - { - get { return Settings.Default.WMXml; } - } - - [CommandParameter("wm", "The windows message to check" , DefaultParameter = true)] - public string WMText - { - get { return Parameters; } - set { Parameters = value; } - } - - public override void ExecuteCommand() - { - if (string.IsNullOrEmpty(WMText)) - { - Say("Please provide a valid window message value or name."); - - } - else - { - NumberParser np = new NumberParser(); - long wm = np.Parse(WMText); - string output; - if (np.Error) - { - // Assume "!wm " form. - output = GetWmNumber(WMText); - } - else - { - output = GetWmDescription(wm); - } - - if (output != null) - { - Say("{0} is {1}.", - WMText, - output); - } - else - { - Say("I don't know about window message {0}.", WMText); - } - } - } - - private string GetWmDescription(long wm) - { - XmlElement root = base.m_XmlDocument.DocumentElement; - XmlNode node = root.SelectSingleNode(String.Format("WindowMessage[@value='{0}']", - wm)); - if (node != null) - { - XmlAttribute text = node.Attributes["text"]; - if (text == null) - throw new Exception("Node has no text attribute."); - return text.Value; - } - else - return null; - } - - private string GetWmNumber(string wmName) - { - XmlElement root = base.m_XmlDocument.DocumentElement; - XmlNode node = root.SelectSingleNode(String.Format("WindowMessage[@text='{0}']", - wmName)); - if (node != null) - { - XmlAttribute value = node.Attributes["value"]; - if (value == null) - throw new Exception("Node has no value attribute."); - return value.Value; - } - else - return null; - } - } -} diff --git a/irc/TechBot/TechBot.Commands.Common/WineBugUrl.cs b/irc/TechBot/TechBot.Commands.Common/WineBugUrl.cs deleted file mode 100644 index e87a0c30b3e..00000000000 --- a/irc/TechBot/TechBot.Commands.Common/WineBugUrl.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -using TechBot.Library; - -namespace TechBot.Commands.Common -{ - [Command("winebug", Help = "!winebug " , Description="Will give you a link to the reqested Wine bug")] - class WineBugUrl : BugCommand - { - public WineBugUrl() - { - } - - protected override string BugUrl - { - get { return "http://bugs.winehq.org/show_bug.cgi?id={0}"; } - } - } -} diff --git a/irc/TechBot/TechBot.Commands.Common/WinerrorCommand.cs b/irc/TechBot/TechBot.Commands.Common/WinerrorCommand.cs deleted file mode 100644 index 950f37bd61b..00000000000 --- a/irc/TechBot/TechBot.Commands.Common/WinerrorCommand.cs +++ /dev/null @@ -1,66 +0,0 @@ -using System; -using System.Xml; - -using TechBot.Library; - -namespace TechBot.Commands.Common -{ - [Command("winerror", Help = "!winerror ")] - public class WinErrorCommand : XmlLookupCommand - { - public WinErrorCommand() - { - } - - public override string XmlFile - { - get { return Settings.Default.WinErrorXml; } - } - - public override void ExecuteCommand() - { - if (string.IsNullOrEmpty(Text)) - { - Say("Please provide a valid System Error Code value."); - } - else - { - NumberParser np = new NumberParser(); - long winerror = np.Parse(Text); - if (np.Error) - { - Say("{0} is not a valid System Error Code value.", Text); - return; - } - - string description = GetWinerrorDescription(winerror); - if (description != null) - { - Say("{0} is {1}.", - Text, - description); - } - else - { - Say("I don't know about System Error Code {0}.", Text); - } - } - } - - public string GetWinerrorDescription(long winerror) - { - XmlElement root = base.m_XmlDocument.DocumentElement; - XmlNode node = root.SelectSingleNode(String.Format("Winerror[@value='{0}']", - winerror.ToString())); - if (node != null) - { - XmlAttribute text = node.Attributes["text"]; - if (text == null) - throw new Exception("Node has no text attribute."); - return text.Value; - } - else - return null; - } - } -} diff --git a/irc/TechBot/TechBot.Commands.Common/app.config b/irc/TechBot/TechBot.Commands.Common/app.config deleted file mode 100644 index 479a2cdc49d..00000000000 --- a/irc/TechBot/TechBot.Commands.Common/app.config +++ /dev/null @@ -1,27 +0,0 @@ - - - - -
        - - - - - - C:\Ros\current\irc\TechBot\Resources\ntstatus.xml - - - C:\Ros\current\irc\TechBot\Resources\winerror.xml - - - C:\Ros\current\irc\TechBot\Resources\hresult.xml - - - C:\Ros\current\irc\TechBot\Resources\wm.xml - - - svn://svn.reactos.org/reactos/trunk - - - - \ No newline at end of file diff --git a/irc/TechBot/TechBot.Commands.MSDN/ApiCommand.cs b/irc/TechBot/TechBot.Commands.MSDN/ApiCommand.cs deleted file mode 100644 index a165f6aa68d..00000000000 --- a/irc/TechBot/TechBot.Commands.MSDN/ApiCommand.cs +++ /dev/null @@ -1,309 +0,0 @@ -using System; -using System.IO; -using System.Data; -using System.Text.RegularExpressions; - -using HtmlHelp; -using HtmlHelp.ChmDecoding; - -using TechBot.Library; - -namespace TechBot.Commands.MSDN -{ - [Command("api", Help = "!api ")] - public class ApiCommand : Command - { - private bool IsVerbose = false; - - private HtmlHelpSystem chm; - - public ApiCommand() - { - LoadCHM(); - } - - [CommandParameter("api", "The API name")] - public string API - { - get { return Parameters; } - set { Parameters = value; } - } - - private void WriteIfVerbose(string message) - { - if (IsVerbose) - Say(message); - } - - private void LoadCHM() - { - string CHMFilename = Path.Combine(Settings.Default.ChmPath, Settings.Default.MainChm); - chm = new HtmlHelpSystem(); - chm.OpenFile(CHMFilename, null); - - Console.WriteLine(String.Format("Loaded main CHM: {0}", - Path.GetFileName(CHMFilename))); - foreach (string filename in Directory.GetFiles(Settings.Default.ChmPath)) - { - if (!Path.GetExtension(filename).ToLower().Equals(".chm")) - continue; - if (Path.GetFileName(filename).ToLower().Equals(Settings.Default.MainChm)) - continue; - - Console.WriteLine(String.Format("Loading CHM: {0}", - Path.GetFileName(filename))); - try - { - chm.MergeFile(filename); - } - catch (Exception ex) - { - Console.WriteLine(String.Format("Could not load CHM: {0}. Exception {1}", - Path.GetFileName(filename), - ex)); - } - } - Console.WriteLine(String.Format("Loaded {0} CHMs", - chm.FileList.Length)); - } - - public override void ExecuteCommand() - { - if (Name.Trim().Equals(String.Empty)) - { - Say("Please give me a keyword."); - } - else - { - Search(Name); - } - } - - private bool SearchIndex( - string keyword) - { - if (chm.HasIndex) - { - IndexItem item = chm.Index.SearchIndex(keyword, - IndexType.KeywordLinks); - if (item != null && item.Topics.Count > 0) - { - WriteIfVerbose(String.Format("Keyword {0} found in index", - item.KeyWord)); - IndexTopic indexTopic = item.Topics[0] as IndexTopic; - return DisplayResult( keyword, - indexTopic); - } - else - { - WriteIfVerbose(String.Format("Keyword {0} not found in index", - keyword)); - return false; - } - } - else - return false; - } - - private void SearchFullText(string keyword) - { - string sort = "Rating ASC"; - WriteIfVerbose(String.Format("Searching fulltext database for {0}", - keyword)); - - bool partialMatches = false; - bool titlesOnly = true; - int maxResults = 100; - DataTable results = chm.PerformSearch(keyword, - maxResults, - partialMatches, - titlesOnly); - WriteIfVerbose(String.Format("results.Rows.Count = {0}", - results != null ? - results.Rows.Count.ToString() : "(none)")); - if (results != null && results.Rows.Count > 0) - { - results.DefaultView.Sort = sort; - if (!DisplayResult(keyword, - results)) - { - Say("No result"); - } - } - else - { - Say("No result"); - } - } - - private void Search(string keyword) - { - if (!SearchIndex(keyword)) - SearchFullText(keyword); - } - - private bool DisplayResult(string keyword, - IndexTopic indexTopic) - { - keyword = keyword.Trim().ToLower(); - string url = indexTopic.URL; - WriteIfVerbose(String.Format("URL from index search {0}", - url)); - string prototype = ExtractPrototype(url); - if (prototype == null || prototype.Trim().Equals(String.Empty)) - return false; - string formattedPrototype = FormatPrototype(prototype); - Say(formattedPrototype); - return true; - } - - private bool DisplayResult(string keyword, - DataTable results) - { - keyword = keyword.Trim().ToLower(); - for (int i = 0; i < results.DefaultView.Count; i++) - { - DataRowView row = results.DefaultView[i]; - string title = row["Title"].ToString(); - WriteIfVerbose(String.Format("Examining {0}", title)); - if (title.Trim().ToLower().Equals(keyword)) - { - string location = row["Location"].ToString(); - string rating = row["Rating"].ToString(); - string url = row["Url"].ToString(); - string prototype = ExtractPrototype(url); - if (prototype == null || prototype.Trim().Equals(String.Empty)) - continue; - string formattedPrototype = FormatPrototype(prototype); - Say(formattedPrototype); - return true; - } - } - return false; - } - - private void DisplayNoResult(MessageContext context, - string keyword) - { - TechBot.ServiceOutput.WriteLine(context, - String.Format("I don't know about keyword {0}", - keyword)); - } - - private string ReplaceComments(string s) - { - return Regex.Replace(s, "//(.+)\r\n", ""); - } - - private string ReplaceLineEndings(string s) - { - return Regex.Replace(s, "(\r\n)+", " "); - } - - private string ReplaceSpaces(string s) - { - return Regex.Replace(s, @" +", " "); - } - - private string ReplaceSpacesBeforeLeftParenthesis(string s) - { - return Regex.Replace(s, @"\( ", @"("); - } - - private string ReplaceSpacesBeforeRightParenthesis(string s) - { - return Regex.Replace(s, @" \)", @")"); - } - - private string ReplaceSemicolon(string s) - { - return Regex.Replace(s, @";", @""); - } - - private string FormatPrototype(string prototype) - { - string s = ReplaceComments(prototype); - s = ReplaceLineEndings(s); - s = ReplaceSpaces(s); - s = ReplaceSpacesBeforeLeftParenthesis(s); - s = ReplaceSpacesBeforeRightParenthesis(s); - s = ReplaceSemicolon(s); - return s; - } - - private string ExtractPrototype(string url) - { - string page = GetPage(url); - Match match = Regex.Match(page, - "
        (.+)
        ", - RegexOptions.Multiline | - RegexOptions.Singleline); - if (match.Groups.Count > 1) - { - string prototype = match.Groups[1].ToString(); - return StripHtml(StripAfterSlashPre(prototype)); - } - - return ""; - } - - private string StripAfterSlashPre(string html) - { - int index = html.IndexOf(""); - if (index != -1) - { - return html.Substring(0, index); - } - else - return html; - } - - private string StripHtml(string html) - { - return Regex.Replace(html, @"<(.|\n)*?>", String.Empty); - } - - private string GetPage(string url) - { - string CHMFileName = ""; - string topicName = ""; - string anchor = ""; - CHMStream.CHMStream baseStream; - if (!chm.BaseStream.GetCHMParts(url, ref CHMFileName, ref topicName, ref anchor)) - { - baseStream = chm.BaseStream; - CHMFileName = baseStream.CHMFileName; - topicName = url; - anchor = ""; - } - else - { - baseStream = GetBaseStreamFromCHMFileName(CHMFileName); - } - - if ((topicName == "") || (CHMFileName == "") || (baseStream == null)) - { - return ""; - } - - return baseStream.ExtractTextFile(topicName); - } - - private CHMStream.CHMStream GetBaseStreamFromCHMFileName(string CHMFileName) - { - foreach (CHMFile file in chm.FileList) - { - WriteIfVerbose(String.Format("Compare: {0} <> {1}", - file.ChmFilePath, - CHMFileName)); - if (file.ChmFilePath.ToLower().Equals(CHMFileName.ToLower())) - { - return file.BaseStream; - } - } - WriteIfVerbose(String.Format("Could not find loaded CHM file in list: {0}", - CHMFileName)); - return null; - } - } -} diff --git a/irc/TechBot/TechBot.Commands.MSDN/Properties/AssemblyInfo.cs b/irc/TechBot/TechBot.Commands.MSDN/Properties/AssemblyInfo.cs deleted file mode 100644 index 44bdf804a8b..00000000000 --- a/irc/TechBot/TechBot.Commands.MSDN/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("TechBot.Commands.MSDN")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("Sand")] -[assembly: AssemblyProduct("TechBot.Commands.MSDN")] -[assembly: AssemblyCopyright("Copyright © Sand 2008")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("8a6332ce-82e3-4fbd-a799-8f4b8d025955")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Revision and Build Numbers -// by using the '*' as shown below: -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/irc/TechBot/TechBot.Commands.MSDN/Settings.Designer.cs b/irc/TechBot/TechBot.Commands.MSDN/Settings.Designer.cs deleted file mode 100644 index 634aeefe0c7..00000000000 --- a/irc/TechBot/TechBot.Commands.MSDN/Settings.Designer.cs +++ /dev/null @@ -1,50 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:2.0.50727.1433 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace TechBot.Commands.MSDN { - - - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "8.0.0.0")] - internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { - - private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); - - public static Settings Default { - get { - return defaultInstance; - } - } - - [global::System.Configuration.UserScopedSettingAttribute()] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("C:\\IRC\\TechBot\\CHM")] - public string ChmPath { - get { - return ((string)(this["ChmPath"])); - } - set { - this["ChmPath"] = value; - } - } - - [global::System.Configuration.UserScopedSettingAttribute()] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("kmarch.chm")] - public string MainChm { - get { - return ((string)(this["MainChm"])); - } - set { - this["MainChm"] = value; - } - } - } -} diff --git a/irc/TechBot/TechBot.Commands.MSDN/Settings.settings b/irc/TechBot/TechBot.Commands.MSDN/Settings.settings deleted file mode 100644 index d13c49f8e2a..00000000000 --- a/irc/TechBot/TechBot.Commands.MSDN/Settings.settings +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - C:\IRC\TechBot\CHM - - - kmarch.chm - - - \ No newline at end of file diff --git a/irc/TechBot/TechBot.Commands.MSDN/TechBot.Commands.MSDN.csproj b/irc/TechBot/TechBot.Commands.MSDN/TechBot.Commands.MSDN.csproj deleted file mode 100644 index 636ac87d58f..00000000000 --- a/irc/TechBot/TechBot.Commands.MSDN/TechBot.Commands.MSDN.csproj +++ /dev/null @@ -1,69 +0,0 @@ - - - Debug - AnyCPU - 8.0.50727 - 2.0 - {ADBF1ED6-A586-4707-BD59-4CD53448D0FE} - Library - Properties - TechBot.Commands.MSDN - TechBot.Commands.MSDN - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - - - - - - - - True - True - Settings.settings - - - - - {72E5CCA1-6318-4D62-964D-CB23A5C743B5} - CHMLibrary - - - {1114F34D-F388-4F38-AE27-C0EE1B10B777} - TechBot.Library - - - - - - SettingsSingleFileGenerator - Settings.Designer.cs - - - - - \ No newline at end of file diff --git a/irc/TechBot/TechBot.Commands.MSDN/TechBot.Commands.MSDN.csproj.user b/irc/TechBot/TechBot.Commands.MSDN/TechBot.Commands.MSDN.csproj.user deleted file mode 100644 index a1d742b1c46..00000000000 --- a/irc/TechBot/TechBot.Commands.MSDN/TechBot.Commands.MSDN.csproj.user +++ /dev/null @@ -1,5 +0,0 @@ - - - ProjectFiles - - \ No newline at end of file diff --git a/irc/TechBot/TechBot.Commands.MSDN/app.config b/irc/TechBot/TechBot.Commands.MSDN/app.config deleted file mode 100644 index 83f087c3399..00000000000 --- a/irc/TechBot/TechBot.Commands.MSDN/app.config +++ /dev/null @@ -1,18 +0,0 @@ - - - - -
        - - - - - - C:\IRC\TechBot\CHM - - - kmarch.chm - - - - \ No newline at end of file diff --git a/irc/TechBot/TechBot.Console/App.config b/irc/TechBot/TechBot.Console/App.config deleted file mode 100644 index dfa480f3d3c..00000000000 --- a/irc/TechBot/TechBot.Console/App.config +++ /dev/null @@ -1,27 +0,0 @@ - - - - -
        - - - - - - irc.eu.freenode.net - - - rbuildbottest2 - - - RBuildBot2 - - - qwerty - - - 6667 - - - - \ No newline at end of file diff --git a/irc/TechBot/TechBot.Console/AssemblyInfo.cs b/irc/TechBot/TechBot.Console/AssemblyInfo.cs deleted file mode 100644 index dbacda112e8..00000000000 --- a/irc/TechBot/TechBot.Console/AssemblyInfo.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; - -// Information about this assembly is defined by the following -// attributes. -// -// change them to the information which is associated with the assembly -// you compile. - -[assembly: AssemblyTitle("")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("")] -[assembly: AssemblyCopyright("")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// The assembly version has following format : -// -// Major.Minor.Build.Revision -// -// You can specify all values by your own or you can build default build and revision -// numbers with the '*' character (the default): - -[assembly: AssemblyVersion("1.0.*")] - -// The following attributes specify the key for the sign of your assembly. See the -// .NET Framework documentation for more information about signing. -// This is not required, if you don't want signing let these attributes like they're. -[assembly: AssemblyDelaySign(false)] -[assembly: AssemblyKeyFile("")] diff --git a/irc/TechBot/TechBot.Console/ConsoleTechBotService.cs b/irc/TechBot/TechBot.Console/ConsoleTechBotService.cs deleted file mode 100644 index d3543131aa7..00000000000 --- a/irc/TechBot/TechBot.Console/ConsoleTechBotService.cs +++ /dev/null @@ -1,37 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -using TechBot.Library; - -namespace TechBot.Console -{ - public class ConsoleServiceOutput : IServiceOutput - { - public void WriteLine(MessageContext context, - string message) - { - System.Console.WriteLine(message); - } - } - - public class ConsoleTechBotService : TechBotService - { - public ConsoleTechBotService() - : base(new ConsoleServiceOutput()) - { - System.Console.WriteLine("TechBot running console service..."); - } - - public override void Run() - { - //Call the base class - base.Run(); - - while (true) - { - InjectMessage(System.Console.ReadLine()); - } - } - } -} diff --git a/irc/TechBot/TechBot.Console/Default.build b/irc/TechBot/TechBot.Console/Default.build deleted file mode 100644 index 706547f170b..00000000000 --- a/irc/TechBot/TechBot.Console/Default.build +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - - - - - - - - - - - - diff --git a/irc/TechBot/TechBot.Console/Main.cs b/irc/TechBot/TechBot.Console/Main.cs deleted file mode 100644 index eec2855e95b..00000000000 --- a/irc/TechBot/TechBot.Console/Main.cs +++ /dev/null @@ -1,29 +0,0 @@ -using System; -using System.Configuration; -using TechBot.Library; - -namespace TechBot.Console -{ - class MainClass - { - public static void Main(string[] args) - { - TechBotService m_TechBot = null; - - if (args.Length > 0 && args[0].ToLower().Equals("irc")) - { - m_TechBot = new IrcTechBotService(Settings.Default.IRCServerHostName, - Settings.Default.IRCServerHostPort, - Settings.Default.IRCChannelNames, - Settings.Default.IRCBotName, - Settings.Default.IRCBotPassword); - } - else - { - m_TechBot = new ConsoleTechBotService(); - } - - m_TechBot.Run(); - } - } -} \ No newline at end of file diff --git a/irc/TechBot/TechBot.Console/Properties/.gitignore b/irc/TechBot/TechBot.Console/Properties/.gitignore deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/irc/TechBot/TechBot.Console/Settings.Designer.cs b/irc/TechBot/TechBot.Console/Settings.Designer.cs deleted file mode 100644 index 4f05450c12f..00000000000 --- a/irc/TechBot/TechBot.Console/Settings.Designer.cs +++ /dev/null @@ -1,86 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:2.0.50727.1433 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace TechBot.Console { - - - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "8.0.0.0")] - internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { - - private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); - - public static Settings Default { - get { - return defaultInstance; - } - } - - [global::System.Configuration.UserScopedSettingAttribute()] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("irc.eu.freenode.net")] - public string IRCServerHostName { - get { - return ((string)(this["IRCServerHostName"])); - } - set { - this["IRCServerHostName"] = value; - } - } - - [global::System.Configuration.UserScopedSettingAttribute()] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("rbuildbottest2")] - public string IRCChannelNames { - get { - return ((string)(this["IRCChannelNames"])); - } - set { - this["IRCChannelNames"] = value; - } - } - - [global::System.Configuration.UserScopedSettingAttribute()] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("RBuildBot2")] - public string IRCBotName { - get { - return ((string)(this["IRCBotName"])); - } - set { - this["IRCBotName"] = value; - } - } - - [global::System.Configuration.UserScopedSettingAttribute()] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("qwerty")] - public string IRCBotPassword { - get { - return ((string)(this["IRCBotPassword"])); - } - set { - this["IRCBotPassword"] = value; - } - } - - [global::System.Configuration.UserScopedSettingAttribute()] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("6667")] - public int IRCServerHostPort { - get { - return ((int)(this["IRCServerHostPort"])); - } - set { - this["IRCServerHostPort"] = value; - } - } - } -} diff --git a/irc/TechBot/TechBot.Console/Settings.settings b/irc/TechBot/TechBot.Console/Settings.settings deleted file mode 100644 index ba8340928b0..00000000000 --- a/irc/TechBot/TechBot.Console/Settings.settings +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - irc.eu.freenode.net - - - rbuildbottest2 - - - RBuildBot2 - - - qwerty - - - 6667 - - - \ No newline at end of file diff --git a/irc/TechBot/TechBot.Console/TechBot.Console.cmbx b/irc/TechBot/TechBot.Console/TechBot.Console.cmbx deleted file mode 100644 index 0e37e7626b7..00000000000 --- a/irc/TechBot/TechBot.Console/TechBot.Console.cmbx +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/irc/TechBot/TechBot.Console/TechBot.Console.csproj b/irc/TechBot/TechBot.Console/TechBot.Console.csproj deleted file mode 100644 index a7be83244f4..00000000000 --- a/irc/TechBot/TechBot.Console/TechBot.Console.csproj +++ /dev/null @@ -1,80 +0,0 @@ - - - - Debug - AnyCPU - 8.0.50727 - 2.0 - {44258BA2-FFCB-4463-9CED-6DE5CC5CEBD4} - Exe - Properties - TechBot.Console - TechBot.Console - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - - - - - - True - True - Settings.settings - - - - - - - - {041B5F06-BF97-4981-B024-3A7B6DD9F6AE} - TechBot.Commands.Common - - - {D676FEDE-62DD-4B4D-94C6-308598E827F9} - TechBot.Commands.RBuild - - - {D2A57931-DF04-4BC3-BD11-75DF4F3B0A88} - TechBot.IRCLibrary - - - {1114F34D-F388-4F38-AE27-C0EE1B10B777} - TechBot.Library - - - - - - SettingsSingleFileGenerator - Settings.Designer.cs - - - - - - \ No newline at end of file diff --git a/irc/TechBot/TechBot.Console/TechBot.Console.prjx b/irc/TechBot/TechBot.Console/TechBot.Console.prjx deleted file mode 100644 index 6a08d66c7be..00000000000 --- a/irc/TechBot/TechBot.Console/TechBot.Console.prjx +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/irc/TechBot/TechBot.IRCLibrary/AssemblyInfo.cs b/irc/TechBot/TechBot.IRCLibrary/AssemblyInfo.cs deleted file mode 100644 index dbacda112e8..00000000000 --- a/irc/TechBot/TechBot.IRCLibrary/AssemblyInfo.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; - -// Information about this assembly is defined by the following -// attributes. -// -// change them to the information which is associated with the assembly -// you compile. - -[assembly: AssemblyTitle("")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("")] -[assembly: AssemblyCopyright("")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// The assembly version has following format : -// -// Major.Minor.Build.Revision -// -// You can specify all values by your own or you can build default build and revision -// numbers with the '*' character (the default): - -[assembly: AssemblyVersion("1.0.*")] - -// The following attributes specify the key for the sign of your assembly. See the -// .NET Framework documentation for more information about signing. -// This is not required, if you don't want signing let these attributes like they're. -[assembly: AssemblyDelaySign(false)] -[assembly: AssemblyKeyFile("")] diff --git a/irc/TechBot/TechBot.IRCLibrary/Default.build b/irc/TechBot/TechBot.IRCLibrary/Default.build deleted file mode 100644 index 1c468dd5fd0..00000000000 --- a/irc/TechBot/TechBot.IRCLibrary/Default.build +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/irc/TechBot/TechBot.IRCLibrary/IRC.cs b/irc/TechBot/TechBot.IRCLibrary/IRC.cs deleted file mode 100644 index ca85f08fd7b..00000000000 --- a/irc/TechBot/TechBot.IRCLibrary/IRC.cs +++ /dev/null @@ -1,30 +0,0 @@ -using System; - -namespace TechBot.IRCLibrary -{ - /// - /// IRC constants and helper methods. - /// - public class IRC - { - #region IRC commands - - public const string JOIN = "JOIN"; - public const string NICK = "NICK"; - public const string PART = "PART"; - public const string PING = "PING"; - public const string PONG = "PONG"; - public const string PRIVMSG = "PRIVMSG"; - public const string USER = "USER"; - public const string PASS = "PASS"; - public const string GHOST = "NICKSERV GHOST"; - public const string NOTICE = "NOTICE"; - - public const string RPL_NAMREPLY = "353"; - public const string RPL_ENDOFNAMES = "366"; - public const string ERR_NICKNAMEINUSE = "433"; - - #endregion - - } -} diff --git a/irc/TechBot/TechBot.IRCLibrary/IrcChannel.cs b/irc/TechBot/TechBot.IRCLibrary/IrcChannel.cs deleted file mode 100644 index 0c16e59b0bd..00000000000 --- a/irc/TechBot/TechBot.IRCLibrary/IrcChannel.cs +++ /dev/null @@ -1,137 +0,0 @@ -/* - Channels names are strings (beginning with a '&' or '#' character) of - length up to 200 characters. Apart from the the requirement that the - first character being either '&' or '#'; the only restriction on a - channel name is that it may not contain any spaces (' '), a control G - (^G or ASCII 7), or a comma (',' which is used as a list item - separator by the protocol). - */ -using System; -using System.Collections; - -namespace TechBot.IRCLibrary -{ - /// - /// IRC channel type. - /// - public enum IrcChannelType - { - Public, - Private, - Secret - } - - - - /// - /// IRC channel. - /// - public class IrcChannel - { - #region Private fields - - private IrcClient owner; - private string name; - private IrcChannelType type = IrcChannelType.Public; - private ArrayList users = new ArrayList(); - - #endregion - - #region Public properties - - /// - /// Owner of this channel. - /// - public IrcClient Owner - { - get - { - return owner; - } - } - - /// - /// Name of channel (no leading #). - /// - public string Name - { - get - { - return name; - } - } - - /// - /// Type of channel. - /// - public IrcChannelType Type - { - get - { - return type; - } - } - - /// - /// Users in this channel. - /// - public ArrayList Users - { - get - { - return users; - } - } - - #endregion - - /// - /// Constructor. - /// - /// Owner of this channel. - /// Name of channel. - public IrcChannel(IrcClient owner, string name) - { - if (owner == null) - { - throw new ArgumentNullException("owner", "Owner cannot be null."); - } - if (name == null) - { - throw new ArgumentNullException("name", "Name cannot be null."); - } - this.owner = owner; - this.name = name; - } - - /// - /// Locate a user. - /// - /// Nickname of user (no decorations). - /// User or null if not found. - public IrcUser LocateUser(string nickname) - { - foreach (IrcUser user in Users) - { - /* FIXME: There are special cases for nickname comparison */ - if (nickname.ToLower().Equals(user.Nickname.ToLower())) - { - return user; - } - } - return null; - } - - /// - /// Talk to the channel. - /// - /// Text to send to the channel. - public void Talk(string text) - { - owner.SendMessage(new IrcMessage(IRC.PRIVMSG, - String.Format("#{0} :{1}", - name, - text))); - } - } -} diff --git a/irc/TechBot/TechBot.IRCLibrary/IrcClient.cs b/irc/TechBot/TechBot.IRCLibrary/IrcClient.cs deleted file mode 100644 index 361071507ce..00000000000 --- a/irc/TechBot/TechBot.IRCLibrary/IrcClient.cs +++ /dev/null @@ -1,794 +0,0 @@ -using System; -using System.IO; -using System.Text; -using System.Collections; -using System.Net.Sockets; - -namespace TechBot.IRCLibrary -{ - /// - /// Delegate that delivers an IRC message. - /// - public delegate void MessageReceivedHandler(IrcMessage message); - - /// - /// Delegate that notifies if the user database for a channel has changed. - /// - public delegate void ChannelUserDatabaseChangedHandler(IrcChannel channel); - - public delegate void OnConnectHandler (); - public delegate void OnDisconnectHandler(); - public delegate void OnConnectionLostHandler(); - - /// - /// An IRC client. - /// - public class IrcClient - { - /// - /// Monitor when an IRC command is received. - /// - private class IrcCommandEventRegistration - { - /// - /// IRC command to monitor. - /// - private string command; - public string Command - { - get - { - return command; - } - } - - /// - /// Handler to call when command is received. - /// - private MessageReceivedHandler handler; - public MessageReceivedHandler Handler - { - get - { - return handler; - } - } - - /// - /// Constructor. - /// - /// IRC command to monitor. - /// Handler to call when command is received. - public IrcCommandEventRegistration(string command, - MessageReceivedHandler handler) - { - this.command = command; - this.handler = handler; - } - } - - - - /// - /// A buffer to store lines of text. - /// - private class LineBuffer - { - /// - /// Full lines of text in buffer. - /// - private ArrayList strings; - - /// - /// Part of the last line of text in buffer. - /// - private string left = ""; - - /// - /// Standard constructor. - /// - public LineBuffer() - { - strings = new ArrayList(); - } - - /// - /// Return true if there is a complete line in the buffer or false if there is not. - /// - public bool DataAvailable - { - get - { - return (strings.Count > 0); - } - } - - /// - /// Return next complete line in buffer or null if none exists. - /// - /// Next complete line in buffer or null if none exists. - public string Read() - { - if (DataAvailable) - { - string line = strings[0] as string; - strings.RemoveAt(0); - return line; - } - else - { - return null; - } - } - - /// - /// Write a string to buffer splitting it into lines. - /// - /// - public void Write(string data) - { - data = left + data; - left = ""; - string[] sa = data.Split(new char[] { '\n' }); - if (sa.Length <= 0) - { - left = data; - return; - } - else - { - left = ""; - } - for (int i = 0; i < sa.Length; i++) - { - if (i < sa.Length - 1) - { - /* This is a complete line. Remove any \r characters at the end of the line. */ - string line = sa[i].TrimEnd(new char[] { '\r', '\n'}); - /* Silently ignore empty lines */ - if (!line.Equals(String.Empty)) - { - strings.Add(line); - } - } - else - { - /* This may be a partial line. */ - left = sa[i]; - } - } - } - } - - - /// - /// State for asynchronous reads. - /// - private class StateObject - { - /// - /// Network stream where data is read from. - /// - public NetworkStream Stream; - - /// - /// Buffer where data is put. - /// - public byte[] Buffer; - - /// - /// Constructor. - /// - /// Network stream where data is read from. - /// Buffer where data is put. - public StateObject(NetworkStream stream, byte[] buffer) - { - this.Stream = stream; - this.Buffer = buffer; - } - } - - - #region Private fields - private bool firstPingReceived = false; - private bool awaitingGhostDeath = false; - private System.Text.Encoding encoding = System.Text.Encoding.UTF8; - private TcpClient tcpClient; - private NetworkStream networkStream; - private bool connected = false; - private LineBuffer messageStream; - private ArrayList ircCommandEventRegistrations = new ArrayList(); - private ArrayList channels = new ArrayList(); - private string reqNickname; - private string curNickname; - private string password; - #endregion - - #region Public events - - public event MessageReceivedHandler MessageReceived; - - public event ChannelUserDatabaseChangedHandler ChannelUserDatabaseChanged; - - public event OnConnectHandler OnConnect; - public event OnConnectionLostHandler OnConnectionLost; - public event OnDisconnectHandler OnDisconnect; - - #endregion - - #region Public properties - - /// - /// Encoding used. - /// - public System.Text.Encoding Encoding - { - get - { - return encoding; - } - set - { - encoding = value; - } - } - - /// - /// List of joined channels. - /// - public ArrayList Channels - { - get - { - return channels; - } - } - - /// - /// Nickname for the bot. - /// - public string Nickname - { - get - { - return curNickname; - } - } - #endregion - - #region Private methods - - /// - /// Signal MessageReceived event. - /// - /// Message that was received. - private void OnMessageReceived(IrcMessage message) - { - foreach (IrcCommandEventRegistration icre in ircCommandEventRegistrations) - { - if (message.Command.ToLower().Equals(icre.Command.ToLower())) - { - icre.Handler(message); - } - } - if (MessageReceived != null) - { - MessageReceived(message); - } - } - - /// - /// Signal ChannelUserDatabaseChanged event. - /// - /// Message that was received. - private void OnChannelUserDatabaseChanged(IrcChannel channel) - { - if (ChannelUserDatabaseChanged != null) - { - ChannelUserDatabaseChanged(channel); - } - } - - /// - /// Start an asynchronous read. - /// - private void Receive() - { - if ((networkStream != null) && (networkStream.CanRead)) - { - byte[] buffer = new byte[1024]; - networkStream.BeginRead(buffer, 0, buffer.Length, - new AsyncCallback(ReadComplete), - new StateObject(networkStream, buffer)); - } - else - { - throw new Exception("Socket is closed."); - } - } - - /// - /// Asynchronous read has completed. - /// - /// IAsyncResult object. - private void ReadComplete(IAsyncResult ar) - { - try - { - StateObject stateObject = (StateObject)ar.AsyncState; - if (stateObject.Stream.CanRead) - { - int bytesReceived = stateObject.Stream.EndRead(ar); - if (bytesReceived > 0) - { - messageStream.Write(Encoding.GetString(stateObject.Buffer, 0, bytesReceived)); - while (messageStream.DataAvailable) - { - OnMessageReceived(new IrcMessage(messageStream.Read())); - } - } - } - - Receive(); - } - catch (SocketException) - { - if (OnConnectionLost != null) - OnConnectionLost(); - } - catch (IOException) - { - if (OnConnectionLost != null) - OnConnectionLost(); - } - catch (Exception) - { - if (OnConnectionLost != null) - OnConnectionLost(); - } - } - - /// - /// Locate channel. - /// - /// Channel name. - /// Channel or null if none was found. - private IrcChannel LocateChannel(string name) - { - foreach (IrcChannel channel in Channels) - { - if (name.ToLower().Equals(channel.Name.ToLower())) - { - return channel; - } - } - return null; - } - - /// - /// Send a PONG message when a PING message is received. - /// - /// Received IRC message. - private void PingMessageReceived(IrcMessage message) - { - SendMessage(new IrcMessage(IRC.PONG, message.Parameters)); - firstPingReceived = true; - } - - /// - /// Send a PONG message when a PING message is received. - /// - /// Received IRC message. - private void NoticeMessageReceived(IrcMessage message) - { - if (awaitingGhostDeath) - { - string str = string.Format("{0} has been ghosted", reqNickname); - if (message.Parameters.Contains(str)) - { - ChangeNick(reqNickname); - SubmitPassword(password); - awaitingGhostDeath = false; - } - } - } - - /// - /// Process RPL_NAMREPLY message. - /// - /// Received IRC message. - private void RPL_NAMREPLYMessageReceived(IrcMessage message) - { - try - { - // :Oslo2.NO.EU.undernet.org 353 E101 = #E101 :E101 KongFu_uK @Exception - /* "( "=" / "*" / "@" ) - :[ "@" / "+" ] *( " " [ "@" / "+" ] ) - - "@" is used for secret channels, "*" for private - channels, and "=" for others (public channels). */ - if (message.Parameters == null) - { - System.Diagnostics.Debug.WriteLine(String.Format("Message has no parameters.")); - return; - } - string[] parameters = message.Parameters.Split(new char[] { ' '}); - if (parameters.Length < 5) - { - System.Diagnostics.Debug.WriteLine(String.Format("{0} is two few parameters.", parameters.Length)); - return; - } - IrcChannelType type; - switch (parameters[1]) - { - case "=": - type = IrcChannelType.Public; - break; - case "*": - type = IrcChannelType.Private; - break; - case "@": - type = IrcChannelType.Secret; - break; - default: - type = IrcChannelType.Public; - break; - } - IrcChannel channel = LocateChannel(parameters[2].Substring(1)); - if (channel == null) - { - System.Diagnostics.Debug.WriteLine(String.Format("Channel not found '{0}'.", - parameters[2].Substring(1))); - return; - } - string nickname = parameters[3]; - if (nickname[0] != ':') - { - System.Diagnostics.Debug.WriteLine(String.Format("String should start with : and not {0}.", nickname[0])); - return; - } - /* Skip : */ - IrcUser user = channel.LocateUser(nickname.Substring(1)); - if (user == null) - { - user = new IrcUser(this, - nickname.Substring(1)); - channel.Users.Add(user); - } - for (int i = 4; i < parameters.Length; i++) - { - nickname = parameters[i]; - user = channel.LocateUser(nickname); - if (user == null) - { - user = new IrcUser(this, - nickname); - channel.Users.Add(user); - } - } - } - catch (Exception ex) - { - System.Diagnostics.Debug.WriteLine(String.Format("Ex. {0}", ex)); - } - } - - /// - /// Process RPL_ENDOFNAMES message. - /// - /// Received IRC message. - private void RPL_ENDOFNAMESMessageReceived(IrcMessage message) - { - try - { - /* :End of NAMES list */ - if (message.Parameters == null) - { - System.Diagnostics.Debug.WriteLine(String.Format("Message has no parameters.")); - return; - } - - string[] parameters = message.Parameters.Split(new char[] { ' ' }); - IrcChannel channel = LocateChannel(parameters[1].Substring(1)); - if (channel == null) - { - System.Diagnostics.Debug.WriteLine(String.Format("Channel not found '{0}'.", - parameters[0].Substring(1))); - return; - } - - OnChannelUserDatabaseChanged(channel); - } - catch (Exception ex) - { - System.Diagnostics.Debug.WriteLine(String.Format("Ex. {0}", ex)); - } - } - - /// - /// Process ERR_NICKNAMEINUSE message. - /// - /// Received IRC message. - private void ERR_NICKNAMEINUSEMessageReceived(IrcMessage message) - { - try - { - if (message.Parameters == null) - { - System.Diagnostics.Debug.WriteLine(String.Format("Message has no parameters.")); - return; - } - - /* Connect with a different name */ - string[] parameters = message.Parameters.Split(new char[] { ' ' }); - string nickname = parameters[1]; - ChangeNick(nickname + "__"); - } - catch (Exception ex) - { - System.Diagnostics.Debug.WriteLine(String.Format("Ex. {0}", ex)); - } - } - - #endregion - - /// - /// Connect to the specified IRC server on the specified port. - /// - /// Address of IRC server. - /// Port of IRC server. - public void Connect(string server, int port) - { - if (connected) - { - throw new AlreadyConnectedException(); - } - else - { - messageStream = new LineBuffer(); - tcpClient = new TcpClient(); - tcpClient.Connect(server, port); - tcpClient.NoDelay = true; - tcpClient.LingerState = new LingerOption(false, 0); - networkStream = tcpClient.GetStream(); - connected = networkStream.CanRead && networkStream.CanWrite; - if (!connected) - { - throw new Exception("Cannot read and write from socket."); - } - /* Install PING message handler */ - MonitorCommand(IRC.PING, new MessageReceivedHandler(PingMessageReceived)); - /* Install NOTICE message handler */ - MonitorCommand(IRC.NOTICE, new MessageReceivedHandler(NoticeMessageReceived)); - /* Install RPL_NAMREPLY message handler */ - MonitorCommand(IRC.RPL_NAMREPLY, new MessageReceivedHandler(RPL_NAMREPLYMessageReceived)); - /* Install RPL_ENDOFNAMES message handler */ - MonitorCommand(IRC.RPL_ENDOFNAMES, new MessageReceivedHandler(RPL_ENDOFNAMESMessageReceived)); - /* Install ERR_NICKNAMEINUSE message handler */ - MonitorCommand(IRC.ERR_NICKNAMEINUSE, new MessageReceivedHandler(ERR_NICKNAMEINUSEMessageReceived)); - /* Start receiving data */ - Receive(); - } - } - - /// - /// Disconnect from IRC server. - /// - public void Diconnect() - { - if (!connected) - { - throw new NotConnectedException(); - } - else - { - connected = false; - tcpClient.Close(); - tcpClient = null; - - if (OnDisconnect != null) - OnDisconnect(); - } - } - - /// - /// Send an IRC message. - /// - /// The message to be sent. - public void SendMessage(IrcMessage message) - { - try - { - if (!connected) - { - throw new NotConnectedException(); - } - - /* Serialize sending messages */ - lock (typeof(IrcClient)) - { - NetworkStream networkStream = tcpClient.GetStream(); - byte[] bytes = Encoding.GetBytes(message.Line); - networkStream.Write(bytes, 0, bytes.Length); - networkStream.Flush(); - } - } - catch (SocketException) - { - if (OnConnectionLost != null) - OnConnectionLost(); - } - catch (IOException) - { - if (OnConnectionLost != null) - OnConnectionLost(); - } - catch (Exception) - { - if (OnConnectionLost != null) - OnConnectionLost(); - } - } - - /// - /// Monitor when a message with an IRC command is received. - /// - /// IRC command to monitor. - /// Handler to call when command is received. - public void MonitorCommand(string command, MessageReceivedHandler handler) - { - if (command == null) - { - throw new ArgumentNullException("command", "Command cannot be null."); - } - if (handler == null) - { - throw new ArgumentNullException("handler", "Handler cannot be null."); - } - ircCommandEventRegistrations.Add(new IrcCommandEventRegistration(command, handler)); - } - - /// - /// Talk to the channel. - /// - /// Nickname of user to talk to. - /// Text to send to the channel. - public void TalkTo(string nickname, string text) - { - } - - /// - /// Change nickname. - /// - /// New nickname. - public void ChangeNick(string nickname) - { - if (nickname == null) - throw new ArgumentNullException("nickname", "Nickname cannot be null."); - - Console.WriteLine("Changing nick to {0}\n", nickname); - curNickname = nickname; - - /* NICK [ ] */ - SendMessage(new IrcMessage(IRC.NICK, nickname)); - } - - /// - /// Ghost nickname. - /// - /// Nickname. - public void GhostNick(string nickname, - string password) - { - if (nickname == null) - throw new ArgumentNullException("nickname", "Nickname cannot be null."); - - if (password == null) - throw new ArgumentNullException("password", "Password cannot be null."); - - awaitingGhostDeath = true; - - /* GHOST */ - SendMessage(new IrcMessage(IRC.GHOST, nickname + " " + password)); - } - - /// - /// Submit password to identify user. - /// - /// Password of registered nick. - private void SubmitPassword(string password) - { - if (password == null) - throw new ArgumentNullException("password", "Password cannot be null."); - - this.password = password; - - /* PASS */ - SendMessage(new IrcMessage(IRC.PASS, password)); - } - - /// - /// Register. - /// - /// New nickname. - /// Password. Can be null. - /// Real name. Can be null. - public void Register(string nickname, - string password, - string realname) - { - if (nickname == null) - throw new ArgumentNullException("nickname", "Nickname cannot be null."); - reqNickname = nickname; - firstPingReceived = false; - if (password != null) - { - SubmitPassword(password); - } - ChangeNick(nickname); - /* OLD: USER */ - /* NEW: USER */ - SendMessage(new IrcMessage(IRC.USER, String.Format("{0} 0 * :{1}", - nickname, realname != null ? realname : "Anonymous"))); - - /* Wait for PING for up til 10 seconds */ - int timer = 0; - while (!firstPingReceived && timer < 200) - { - System.Threading.Thread.Sleep(50); - timer++; - } - } - - /// - /// Join an IRC channel. - /// - /// Name of channel (without leading #). - /// New channel. - public IrcChannel JoinChannel(string name) - { - IrcChannel channel = new IrcChannel(this, name); - channels.Add(channel); - /* JOIN ( *( "," ) [ *( "," ) ] ) / "0" */ - SendMessage(new IrcMessage(IRC.JOIN, String.Format("#{0}", name))); - return channel; - } - - /// - /// Part an IRC channel. - /// - /// IRC channel. If null, the user parts from all channels. - /// Part message. Can be null. - public void PartChannel(IrcChannel channel, string message) - { - /* PART *( "," ) [ ] */ - if (channel != null) - { - SendMessage(new IrcMessage(IRC.PART, String.Format("#{0}{1}", - channel.Name, message != null ? String.Format(" :{0}", message) : ""))); - channels.Remove(channel); - } - else - { - string channelList = null; - foreach (IrcChannel myChannel in Channels) - { - if (channelList == null) - { - channelList = ""; - } - else - { - channelList += ","; - } - channelList += myChannel.Name; - } - if (channelList != null) - { - SendMessage(new IrcMessage(IRC.PART, String.Format("#{0}{1}", - channelList, message != null ? String.Format(" :{0}", message) : ""))); - Channels.Clear(); - } - } - } - } -} diff --git a/irc/TechBot/TechBot.IRCLibrary/IrcException.cs b/irc/TechBot/TechBot.IRCLibrary/IrcException.cs deleted file mode 100644 index a96b688ad82..00000000000 --- a/irc/TechBot/TechBot.IRCLibrary/IrcException.cs +++ /dev/null @@ -1,50 +0,0 @@ -using System; - -namespace TechBot.IRCLibrary -{ - /// - /// Base class for all IRC exceptions. - /// - public class IrcException : Exception - { - public IrcException() : base() - { - } - - public IrcException(string message) : base(message) - { - } - - public IrcException(string message, Exception innerException) : base(message, innerException) - { - } - } - - /// - /// Thrown when there is no connection to an IRC server. - /// - public class NotConnectedException : IrcException - { - } - - /// - /// Thrown when there is an attempt to connect to an IRC server and there is already a connection. - /// - public class AlreadyConnectedException : IrcException - { - } - - /// - /// Thrown when there is attempted to parse a malformed or invalid IRC message. - /// - public class MalformedMessageException : IrcException - { - public MalformedMessageException(string message) : base(message) - { - } - - public MalformedMessageException(string message, Exception innerException) : base(message, innerException) - { - } - } -} diff --git a/irc/TechBot/TechBot.IRCLibrary/IrcMessage.cs b/irc/TechBot/TechBot.IRCLibrary/IrcMessage.cs deleted file mode 100644 index f74ea806be4..00000000000 --- a/irc/TechBot/TechBot.IRCLibrary/IrcMessage.cs +++ /dev/null @@ -1,503 +0,0 @@ -using System; - -namespace TechBot.IRCLibrary -{ - /* - ::= [':' ] - ::= | [ '!' ] [ '@' ] - ::= { } | - ::= ' ' { ' ' } - ::= [ ':' | ] - - ::= - ::= - - ::= CR LF - - NOTES: - - 1) is consists only of SPACE character(s) (0x20). - Specially notice that TABULATION, and all other control - characters are considered NON-WHITE-SPACE. - - 2) After extracting the parameter list, all parameters are equal, - whether matched by or . is just - a syntactic trick to allow SPACE within parameter. - - 3) The fact that CR and LF cannot appear in parameter strings is - just artifact of the message framing. This might change later. - - 4) The NUL character is not special in message framing, and - basically could end up inside a parameter, but as it would - cause extra complexities in normal C string handling. Therefore - NUL is not allowed within messages. - - 5) The last parameter may be an empty string. - - 6) Use of the extended prefix (['!' ] ['@' ]) must - not be used in server to server communications and is only - intended for server to client messages in order to provide - clients with more useful information about who a message is - from without the need for additional queries. - */ - /* - NOTICE AUTH :*** Looking up your hostname - NOTICE AUTH :*** Checking Ident - NOTICE AUTH :*** Found your hostname - NOTICE AUTH :*** No ident response - */ - - /// - /// IRC message. - /// - public class IrcMessage - { - #region Private fields - private string line; - private string prefix; - private string prefixServername; - private string prefixNickname; - private string prefixUser; - private string prefixHost; - private string command; - private string parameters; - #endregion - - /// - /// Line of text that is to be parsed as an IRC message. - /// - public string Line - { - get - { - return line; - } - } - - /// - /// Does the message have a prefix? - /// - public bool HasPrefix - { - get - { - return prefix != null; - } - } - - /// - /// Prefix or null if none exists. - /// - public string Prefix - { - get - { - return prefix; - } - } - - /// - /// Servername part of prefix or null if no prefix or servername exists. - /// - public string PrefixServername - { - get - { - return prefixServername; - } - } - - /// - /// Nickname part of prefix or null if no prefix or nick exists. - /// - public string PrefixNickname - { - get - { - return prefixNickname; - } - } - - /// - /// User part of (extended) prefix or null if no (extended) prefix exists. - /// - public string PrefixUser - { - get - { - return prefixUser; - } - } - - /// - /// Host part of (extended) prefix or null if no (extended) prefix exists. - /// - public string PrefixHost - { - get - { - return prefixHost; - } - } - - /// - /// Command part of message. - /// - public string Command - { - get - { - return command; - } - } - - /// - /// Is command numeric? - /// - public bool IsCommandNumeric - { - get - { - if (command == null || command.Length != 3) - { - return false; - } - try - { - Int32.Parse(command); - return true; - } - catch (Exception) - { - return false; - } - } - } - - /// - /// Command part of message as text. - /// - public string CommandText - { - get - { - return command; - } - } - - /// - /// Command part of message as a number. - /// - /// Thrown if IsCommandNumeric returns false. - public int CommandNumber - { - get - { - if (IsCommandNumeric) - { - return Int32.Parse(command); - } - else - { - throw new InvalidOperationException(); - } - } - } - - /// - /// Parameters part of message. - /// - public string Parameters - { - get - { - return parameters; - } - } - - /// - /// Constructor. - /// - /// Line of text that is to be parsed as an IRC message. - public IrcMessage(string line) - { - /* - * ::= [':' ] - * ::= | [ '!' ] [ '@' ] - * :Oslo1.NO.EU.undernet.org 461 MYNICK USER :Not enough parameters - */ - try - { - this.line = line; - int i = 0; - - #region Prefix - if (line[i].Equals(':')) - { - i++; - prefix = ""; - /* This message has a prefix */ - string s = ""; - while (i < line.Length && line[i] != ' ' && line[i] != '!' && line[i] != '@') - { - s += line[i++]; - } - if (IsValidIrcNickname(s)) - { - prefixNickname = s; - prefix += prefixNickname; - if (line[i] == '!') - { - /* This message has an extended prefix */ - i++; - s = ""; - while (i < line.Length && line[i] != ' ' && line[i] != '@') - { - s += line[i]; - i++; - } - prefixUser = s; - prefix += "!" + prefixUser; - } - if (line[i] == '@') - { - /* This message has a host prefix */ - s = ""; - do - { - s += line[++i]; - } - while (i < line.Length && line[i] != ' '); - prefixHost = s; - prefix += "@" + prefixHost; - } - } - else /* Assume it is a servername */ - { - prefixServername = s; - prefix += prefixServername; - } - - /* Skip spaces */ - while (i < line.Length && line[i] == ' ') - { - i++; - } - } - else - { - prefix = null; - } - #endregion - - #region Command - if (Char.IsDigit(line[i])) - { - if (!Char.IsDigit(line, i + 1) || !Char.IsDigit(line, i + 2)) - { - throw new Exception(); - } - command = String.Format("{0}{1}{2}", line[i++], line[i++], line[i++]); - } - else - { - command = ""; - while (i < line.Length && Char.IsLetter(line[i])) - { - command += line[i]; - i++; - } - } - #endregion - - #region Parameters - while (true) - { - /* Skip spaces */ - while (i < line.Length && line[i] == ' ') - { - i++; - } - if (i < line.Length && line[i].Equals(':')) - { - i++; - - /* Trailing */ - while (i < line.Length && line[i] != ' ' && line[i] != '\r' && line[i] != '\n' && line[i] != 0) - { - if (parameters == null) - { - parameters = ""; - } - parameters += line[i]; - i++; - } - } - else - { - /* Middle */ - while (i < line.Length && line[i] != '\r' && line[i] != '\n' && line[i] != 0) - { - if (parameters == null) - { - parameters = ""; - } - parameters += line[i]; - i++; - } - } - if (i >= line.Length) - { - break; - } - } - #endregion - } - catch (Exception ex) - { - throw new MalformedMessageException("The message is malformed.", ex); - } - } - - /// - /// Constructor. - /// - /// - /// - /// - /// - /// - /// - public IrcMessage(string prefixServername, - string prefixNickname, - string prefixUser, - string prefixHost, - string command, - string parameters) - { - throw new NotImplementedException(); - } - - /// - /// Constructor. - /// - /// IRC command. - /// IRC command parameters. May be null if there are no parameters. - public IrcMessage(string command, - string parameters) - { - if (command == null || !IsValidIrcCommand(command)) - { - throw new ArgumentException("Command is not a valid IRC command.", "command"); - } - /* An IRC message must not be longer than 512 characters (including terminating CRLF) */ - int parametersLength = (parameters != null) ? 1 + parameters.Length : 0; - if (command.Length + parametersLength > 510) - { - throw new MalformedMessageException("IRC message cannot be longer than 512 characters."); - } - this.command = command; - this.parameters = parameters; - if (parameters != null) - { - this.line = String.Format("{0} {1}\r\n", command, parameters); - } - else - { - this.line = String.Format("{0}\r\n", command); - } - } - - /// - /// Returns wether a string of text is a valid IRC command. - /// - /// The IRC command. - /// True, if command is a valid IRC command, false if not. - private static bool IsValidIrcCommand(string command) - { - foreach (char c in command) - { - if (!Char.IsLetter(c) && !Char.IsWhiteSpace(c)) - { - return false; - } - } - return true; - } - - private const string IrcSpecial = @"-[]\`^{}"; - private const string IrcSpecialNonSpecs = @"_|"; - - /// - /// Returns wether a character is an IRC special character. - /// - /// Character to test. - /// True if the character is an IRC special character, false if not. - private static bool IsSpecial(char c) - { - foreach (char validCharacter in IrcSpecial) - { - if (c.Equals(validCharacter)) - { - return true; - } - } - foreach (char validCharacter in IrcSpecialNonSpecs) - { - if (c.Equals(validCharacter)) - { - return true; - } - } - return false; - } - - /// - /// Returns wether a string of text is a valid IRC nickname. - /// - /// The IRC nickname. - /// True, if nickname is a valid IRC nickname, false if not. - private static bool IsValidIrcNickname(string nickname) - { - /* - * ::= { | | } - * ::= 'a' ... 'z' | 'A' ... 'Z' - * ::= '0' ... '9' - * ::= '-' | '[' | ']' | '\' | '`' | '^' | '{' | '}' - */ - /* An IRC nicknmame must be 1 - 9 characters in length. We don't care so much if it is larger */ - if ((nickname.Length < 1) || (nickname.Length > 30)) - { - return false; - } - /* First character must be a letter. */ - if (!Char.IsLetter(nickname[0])) - { - return false; - } - /* Check the other valid characters for validity. */ - foreach (char c in nickname) - { - if (!Char.IsLetter(c) && !Char.IsDigit(c) && !IsSpecial(c)) - { - return false; - } - } - return true; - } - - /// - /// Write contents to a string. - /// - /// Contents as a string. - public override string ToString() - { - return String.Format("Line({0})Prefix({1})Command({2})Parameters({3})", - line, prefix != null ? prefix : "(null)", - command != null ? command : "(null)", - parameters != null ? parameters : "(null)"); - } - } -} diff --git a/irc/TechBot/TechBot.IRCLibrary/IrcUser.cs b/irc/TechBot/TechBot.IRCLibrary/IrcUser.cs deleted file mode 100644 index 30f0a94db40..00000000000 --- a/irc/TechBot/TechBot.IRCLibrary/IrcUser.cs +++ /dev/null @@ -1,132 +0,0 @@ -using System; - -namespace TechBot.IRCLibrary -{ - /// - /// IRC user. - /// - public class IrcUser - { - #region Private fields - - private IrcClient owner; - private string nickname; - private string decoratedNickname; - - #endregion - - #region Public properties - - /// - /// Owner of this channel. - /// - public IrcClient Owner - { - get - { - return owner; - } - } - - /// - /// Nickname of user. - /// - public string Nickname - { - get - { - return nickname; - } - } - - /// - /// Decorated nickname of user. - /// - public string DecoratedNickname - { - get - { - return decoratedNickname; - } - } - - /// - /// Wether user is channel operator. - /// - public bool Operator - { - get - { - return decoratedNickname.StartsWith("@"); - } - } - - /// - /// Wether user has voice. - /// - public bool Voice - { - get - { - return decoratedNickname.StartsWith("+"); - } - } - - #endregion - - /// - /// Constructor. - /// - /// Owner of this channel. - /// Nickname (possibly decorated) of user. - public IrcUser(IrcClient owner, - string nickname) - { - if (owner == null) - { - throw new ArgumentNullException("owner", "Owner cannot be null."); - } - this.owner = owner; - this.decoratedNickname = nickname.Trim(); - this.nickname = StripDecoration(decoratedNickname); - } - - /// - /// Talk to the user. - /// - /// Text to send to the user. - public void Talk(string text) - { - if (text == null) - { - throw new ArgumentNullException("text", "Text cannot be null."); - } - - owner.SendMessage(new IrcMessage(IRC.PRIVMSG, - String.Format("{0} :{1}", - nickname, - text))); - } - - /// - /// Strip docoration of nickname. - /// - /// Possible decorated nickname. - /// Undecorated nickname. - public static string StripDecoration(string decoratedNickname) - { - if (decoratedNickname.StartsWith("@")) - { - return decoratedNickname.Substring(1); - } - else if (decoratedNickname.StartsWith("+")) - { - return decoratedNickname.Substring(1); - } - else - { - return decoratedNickname; - } - } - } -} diff --git a/irc/TechBot/TechBot.IRCLibrary/Properties/.gitignore b/irc/TechBot/TechBot.IRCLibrary/Properties/.gitignore deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/irc/TechBot/TechBot.IRCLibrary/TechBot.IRCLibrary.cmbx b/irc/TechBot/TechBot.IRCLibrary/TechBot.IRCLibrary.cmbx deleted file mode 100644 index 67b1e6077d5..00000000000 --- a/irc/TechBot/TechBot.IRCLibrary/TechBot.IRCLibrary.cmbx +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/irc/TechBot/TechBot.IRCLibrary/TechBot.IRCLibrary.csproj b/irc/TechBot/TechBot.IRCLibrary/TechBot.IRCLibrary.csproj deleted file mode 100644 index 02647ee5cde..00000000000 --- a/irc/TechBot/TechBot.IRCLibrary/TechBot.IRCLibrary.csproj +++ /dev/null @@ -1,59 +0,0 @@ - - - - Debug - AnyCPU - 8.0.50727 - 2.0 - {D2A57931-DF04-4BC3-BD11-75DF4F3B0A88} - Library - Properties - TechBot.IRCLibrary - TechBot.IRCLibrary - - - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/irc/TechBot/TechBot.IRCLibrary/TechBot.IRCLibrary.prjx b/irc/TechBot/TechBot.IRCLibrary/TechBot.IRCLibrary.prjx deleted file mode 100644 index 457a420241d..00000000000 --- a/irc/TechBot/TechBot.IRCLibrary/TechBot.IRCLibrary.prjx +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/irc/TechBot/TechBot.IRCLibrary/app.config b/irc/TechBot/TechBot.IRCLibrary/app.config deleted file mode 100644 index b4e2a174a9f..00000000000 --- a/irc/TechBot/TechBot.IRCLibrary/app.config +++ /dev/null @@ -1,15 +0,0 @@ - - - - -
        - - - - - - ! - - - - \ No newline at end of file diff --git a/irc/TechBot/TechBot.Library/Attributes/CommandAttribute.cs b/irc/TechBot/TechBot.Library/Attributes/CommandAttribute.cs deleted file mode 100644 index a16ee780d7c..00000000000 --- a/irc/TechBot/TechBot.Library/Attributes/CommandAttribute.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace TechBot.Library -{ - public class CommandAttribute : Attribute - { - private string m_Name = null; - private string m_Help = "No help for this command is available"; - private string m_Desc = "No description for this command is available"; - - public CommandAttribute(string name) - { - m_Name = name; - } - - public string Name - { - get { return m_Name; } - } - - public string Help - { - get { return m_Help; } - set { m_Help = value; } - } - - public string Description - { - get { return m_Desc; } - set { m_Desc = value; } - } - } -} diff --git a/irc/TechBot/TechBot.Library/Attributes/CommandParameterAliasAttribute.cs b/irc/TechBot/TechBot.Library/Attributes/CommandParameterAliasAttribute.cs deleted file mode 100644 index 05dc10da4bd..00000000000 --- a/irc/TechBot/TechBot.Library/Attributes/CommandParameterAliasAttribute.cs +++ /dev/null @@ -1,34 +0,0 @@ -using System; - -namespace TechBot.Library -{ - /// - /// This class implements an alias attribute to work in conjunction - /// with the CommandLineSwitchAttribute - /// attribute. If the CommandLineSwitchAttribute exists, then this attribute - /// defines an alias for it. - /// - [AttributeUsage( AttributeTargets.Property )] - public class CommandParameterAliasAttribute : Attribute - { - #region Private Variables - protected string m_Alias = ""; - #endregion - - #region Public Properties - public string Alias - { - get { return m_Alias; } - } - - #endregion - - #region Constructors - public CommandParameterAliasAttribute(string alias) - { - m_Alias = alias; - } - #endregion - } - -} diff --git a/irc/TechBot/TechBot.Library/Attributes/CommandParameterAttribute.cs b/irc/TechBot/TechBot.Library/Attributes/CommandParameterAttribute.cs deleted file mode 100644 index f996c73dc6c..00000000000 --- a/irc/TechBot/TechBot.Library/Attributes/CommandParameterAttribute.cs +++ /dev/null @@ -1,50 +0,0 @@ -using System; - -namespace TechBot.Library -{ - /// Implements a basic command-line switch by taking the - /// switching name and the associated description. - /// Only currently is implemented for properties, so all - /// auto-switching variables should have a get/set method supplied. - [AttributeUsage( AttributeTargets.Property )] - public class CommandParameterAttribute : Attribute - { - #region Private Variables - private string m_name = ""; - private string m_description = ""; - private bool m_Required = true; - private bool m_Default = false; - #endregion - - #region Public Properties - /// Accessor for retrieving the switch-name for an associated - /// property. - public string Name { get { return m_name; } } - - /// Accessor for retrieving the description for a switch of - /// an associated property. - public string Description { get { return m_description; } } - - public bool Required { get { return m_Required; } } - - public bool DefaultParameter - { - get { return m_Default; } - set { m_Default = value; } - } - - #endregion - - #region Constructors - - /// - /// Attribute constructor. - /// - public CommandParameterAttribute(string name, string description) - { - m_name = name; - m_description = description; - } - #endregion - } -} diff --git a/irc/TechBot/TechBot.Library/Collections/CommandBuilderCollection.cs b/irc/TechBot/TechBot.Library/Collections/CommandBuilderCollection.cs deleted file mode 100644 index 6cb4a814ca1..00000000000 --- a/irc/TechBot/TechBot.Library/Collections/CommandBuilderCollection.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace TechBot.Library -{ - public class CommandBuilderCollection : List - { - public CommandBuilder Find(string name) - { - foreach (CommandBuilder command in this) - { - if (command.Name == name) - return command; - } - - return null; - } - } -} diff --git a/irc/TechBot/TechBot.Library/Commands/Base/Command.cs b/irc/TechBot/TechBot.Library/Commands/Base/Command.cs deleted file mode 100644 index 040d870d833..00000000000 --- a/irc/TechBot/TechBot.Library/Commands/Base/Command.cs +++ /dev/null @@ -1,90 +0,0 @@ -using System; -using System.Text.RegularExpressions; - -namespace TechBot.Library -{ - public abstract class Command - { - protected TechBotService m_TechBotService = null; - protected MessageContext m_Context = null; - protected string m_Params = null; - - public TechBotService TechBot - { - get { return m_TechBotService; } - set { m_TechBotService = value; } - } - - public MessageContext Context - { - get { return m_Context; } - set { m_Context = value; } - } - - public virtual bool AnswerInPublic - { - get { return true; } - } - - public string Name - { - get - { - CommandAttribute commandAttribute = (CommandAttribute) - Attribute.GetCustomAttribute(GetType(), typeof(CommandAttribute)); - - return commandAttribute.Name; - } - } - - public string Parameters - { - get { return m_Params; } - set { m_Params = value; } - } - - protected virtual void Say() - { - TechBot.ServiceOutput.WriteLine(Context, string.Empty); - } - - protected virtual void Say(string message) - { - TechBot.ServiceOutput.WriteLine(Context, message); - } - - protected virtual void Say(string format , params object[] args) - { - TechBot.ServiceOutput.WriteLine(Context, String.Format(format, args)); - } - - public void Run() - { - if (Context is ChannelMessageContext) - { - if (AnswerInPublic) - { - ExecuteCommand(); - } - else - { - Say("Sorry, I only respond '{0}' in private , PM me!", Name); - } - } - else - { - ExecuteCommand(); - } - } - - public abstract void ExecuteCommand(); - - public virtual void Initialize() - { - } - - public virtual void DeInitialize() - { - } - } -} diff --git a/irc/TechBot/TechBot.Library/Commands/Base/XmlCommand.cs b/irc/TechBot/TechBot.Library/Commands/Base/XmlCommand.cs deleted file mode 100644 index 673e796eb50..00000000000 --- a/irc/TechBot/TechBot.Library/Commands/Base/XmlCommand.cs +++ /dev/null @@ -1,25 +0,0 @@ -using System; -using System.Xml; -using System.Collections.Generic; -using System.Text; - -namespace TechBot.Library -{ - public abstract class XmlCommand : Command - { - protected XmlDocument m_XmlDocument; - - public XmlCommand() - { - m_XmlDocument = new XmlDocument(); - m_XmlDocument.Load(XmlFile); - } - - public abstract string XmlFile { get; } - - public XmlDocument XmlDocument - { - get { return m_XmlDocument; } - } - } -} \ No newline at end of file diff --git a/irc/TechBot/TechBot.Library/Commands/Base/XmlLookupCommand.cs b/irc/TechBot/TechBot.Library/Commands/Base/XmlLookupCommand.cs deleted file mode 100644 index 20c8bfcfbcc..00000000000 --- a/irc/TechBot/TechBot.Library/Commands/Base/XmlLookupCommand.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace TechBot.Library -{ - public abstract class XmlLookupCommand : XmlCommand - { - public virtual string Text - { - get { return Parameters; } - set { Parameters = value; } - } - } -} diff --git a/irc/TechBot/TechBot.Library/Commands/HelpCommand.cs b/irc/TechBot/TechBot.Library/Commands/HelpCommand.cs deleted file mode 100644 index 7c7fb34cddf..00000000000 --- a/irc/TechBot/TechBot.Library/Commands/HelpCommand.cs +++ /dev/null @@ -1,78 +0,0 @@ -using System; -using System.Reflection; -using System.Collections; - -namespace TechBot.Library -{ - [Command("help", Help = "!help or !help -name:[CommandName]", Description = "Shows this help , type 'help -name:[CommandName]'")] - public class HelpCommand : Command - { - public HelpCommand() - { - } - - public override bool AnswerInPublic - { - get { return false; } - } - - [CommandParameter("Name", "The command name to show help")] - public string CommandName - { - get { return Parameters; } - set { Parameters = value; } - } - - public override void ExecuteCommand() - { - if (string.IsNullOrEmpty(CommandName)) - { - Say("I support the following commands:"); - - foreach (CommandBuilder command in TechBot.Commands) - { - Say("{0}{1} - {2}", - Settings.Default.CommandPrefix, - command.Name, - command.Description); - } - } - else - { - CommandBuilder cmdBuilder = TechBot.Commands.Find(CommandName); - - if (cmdBuilder == null) - { - Say("Command '{0}' is not recognized. Type '!help' to show all available commands", CommandName); - } - else - { - Say("Command '{0}' help:", CommandName); - Say(); - Say(cmdBuilder.Description); - Say(); - Say(cmdBuilder.Help); - Say(); - Say("Parameters :"); - Say(); - - PropertyInfo[] propertyInfoArray = cmdBuilder.Type.GetProperties(BindingFlags.Public | BindingFlags.Instance); - foreach (PropertyInfo propertyInfo in propertyInfoArray) - { - CommandParameterAttribute[] commandAttributes = (CommandParameterAttribute[]) - Attribute.GetCustomAttributes(propertyInfo, typeof(CommandParameterAttribute)); - - foreach (CommandParameterAttribute parameter in commandAttributes) - { - Say("\t-{0}: [{1}]", - parameter.Name, - parameter.Description); - } - } - - Say(); - } - } - } - } -} diff --git a/irc/TechBot/TechBot.Library/Factory/CommandBuilder.cs b/irc/TechBot/TechBot.Library/Factory/CommandBuilder.cs deleted file mode 100644 index 6a459670a4c..00000000000 --- a/irc/TechBot/TechBot.Library/Factory/CommandBuilder.cs +++ /dev/null @@ -1,52 +0,0 @@ -using System; -using System.Reflection; -using System.Collections.Generic; -using System.Text; - -namespace TechBot.Library -{ - public class CommandBuilder - { - private Type m_CommandType; - private string m_CommandName; - private string m_CommandHelp; - private string m_CommandDesc; - - public CommandBuilder(Type commandType) - { - m_CommandType = commandType; - - CommandAttribute commandAttribute = (CommandAttribute) - Attribute.GetCustomAttribute(commandType, typeof(CommandAttribute)); - - m_CommandName = commandAttribute.Name; - m_CommandHelp = commandAttribute.Help; - m_CommandDesc = commandAttribute.Description; - } - - public string Name - { - get { return m_CommandName; } - } - - public string Help - { - get { return m_CommandHelp; } - } - - public string Description - { - get { return m_CommandDesc; } - } - - public Type Type - { - get { return m_CommandType; } - } - - public Command CreateCommand() - { - return (Command)Type.Assembly.CreateInstance(Type.FullName, true); - } - } -} diff --git a/irc/TechBot/TechBot.Library/Factory/CommandFactory.cs b/irc/TechBot/TechBot.Library/Factory/CommandFactory.cs deleted file mode 100644 index 100bd2bdcf4..00000000000 --- a/irc/TechBot/TechBot.Library/Factory/CommandFactory.cs +++ /dev/null @@ -1,60 +0,0 @@ -using System; -using System.IO; -using System.Collections; -using System.Collections.Generic; -using System.ComponentModel; -using System.Reflection; - -namespace TechBot.Library -{ - public class CommandFactory - { - private static CommandBuilderCollection m_Commands = new CommandBuilderCollection(); - - private CommandFactory() - { - } - - public static void LoadPlugins() - { - //get the file names of the dll files in the current directory. - foreach (string fileName in Directory.GetFiles(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), "*.dll")) - { - LoadPluginsFromDLLFile(fileName); - } - } - - private static void LoadPluginsFromDLLFile(string sFile) - { - Assembly assPlugin = Assembly.LoadFile(sFile); - - Console.WriteLine("Loading plugins from : {0}", assPlugin.Location); - - if (assPlugin != null) - { - foreach (Type pluginType in assPlugin.GetTypes()) - { - if (pluginType.IsSubclassOf(typeof(Command))) - { - if (pluginType.IsAbstract == false) - { - CommandBuilder cmdBuilder = new CommandBuilder(pluginType); - - Console.WriteLine("{0}:{1}", - cmdBuilder.Name, - cmdBuilder.Description); - - //Add it to the list. - Commands.Add(new CommandBuilder(pluginType)); - } - } - } - } - } - - public static CommandBuilderCollection Commands - { - get { return m_Commands; } - } - } -} diff --git a/irc/TechBot/TechBot.Library/MessageContext.cs b/irc/TechBot/TechBot.Library/MessageContext.cs deleted file mode 100644 index 1d9677c8462..00000000000 --- a/irc/TechBot/TechBot.Library/MessageContext.cs +++ /dev/null @@ -1,39 +0,0 @@ -using System; -using TechBot.IRCLibrary; - -namespace TechBot.Library -{ - public abstract class MessageContext - { - } - - public class ChannelMessageContext : MessageContext - { - private IrcChannel m_IrcChannel; - - public IrcChannel Channel - { - get { return m_IrcChannel; } - } - - public ChannelMessageContext(IrcChannel channel) - { - m_IrcChannel = channel; - } - } - - public class UserMessageContext : MessageContext - { - private IrcUser m_IrcUser; - - public IrcUser User - { - get { return m_IrcUser; } - } - - public UserMessageContext(IrcUser user) - { - m_IrcUser = user; - } - } -} diff --git a/irc/TechBot/TechBot.Library/NumberParser.cs b/irc/TechBot/TechBot.Library/NumberParser.cs deleted file mode 100644 index 232ed0be1f2..00000000000 --- a/irc/TechBot/TechBot.Library/NumberParser.cs +++ /dev/null @@ -1,62 +0,0 @@ -using System; -using System.Globalization; - -namespace TechBot.Library -{ - public class NumberParser - { - public bool Error = false; - - private const string SpecialHexCharacters = "ABCDEF"; - - private static bool IsSpecialHexCharacter(char ch) - { - foreach (char specialChar in SpecialHexCharacters) - { - if (ch.ToString().ToUpper() == specialChar.ToString()) - return true; - } - return false; - } - - private static bool HasSpecialHexCharacters(string s) - { - foreach (char ch in s) - { - if (IsSpecialHexCharacter(ch)) - return true; - } - return false; - } - - public long Parse(string s) - { - try - { - Error = false; - bool useHex = false; - if (s.StartsWith("0x", StringComparison.InvariantCultureIgnoreCase)) - { - s = s.Substring(2); - useHex = true; - } - if (HasSpecialHexCharacters(s)) - useHex = true; - if (useHex) - return Int64.Parse(s, - NumberStyles.HexNumber); - else - return Int64.Parse(s); - } - catch (FormatException) - { - Error = true; - } - catch (OverflowException) - { - Error = true; - } - return -1; - } - } -} diff --git a/irc/TechBot/TechBot.Library/Properties/.gitignore b/irc/TechBot/TechBot.Library/Properties/.gitignore deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/irc/TechBot/TechBot.Library/Properties/AssemblyInfo.cs b/irc/TechBot/TechBot.Library/Properties/AssemblyInfo.cs deleted file mode 100644 index af4e2756b62..00000000000 --- a/irc/TechBot/TechBot.Library/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; - -// Information about this assembly is defined by the following -// attributes. -// -// change them to the information which is associated with the assembly -// you compile. - -[assembly: AssemblyTitle("")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("")] -[assembly: AssemblyCopyright("")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// The assembly version has following format : -// -// Major.Minor.Build.Revision -// -// You can specify all values by your own or you can build default build and revision -// numbers with the '*' character (the default): - -[assembly: AssemblyVersion("1.0.*")] - -// The following attributes specify the key for the sign of your assembly. See the -// .NET Framework documentation for more information about signing. -// This is not required, if you don't want signing let these attributes like they're. -[assembly: AssemblyDelaySign(false)] -[assembly: AssemblyKeyFile("")] diff --git a/irc/TechBot/TechBot.Library/ServiceOutput.cs b/irc/TechBot/TechBot.Library/ServiceOutput.cs deleted file mode 100644 index d73a93e62ea..00000000000 --- a/irc/TechBot/TechBot.Library/ServiceOutput.cs +++ /dev/null @@ -1,9 +0,0 @@ -using System; - -namespace TechBot.Library -{ - public interface IServiceOutput - { - void WriteLine(MessageContext context, string message); - } -} diff --git a/irc/TechBot/TechBot.Library/Settings.Designer.cs b/irc/TechBot/TechBot.Library/Settings.Designer.cs deleted file mode 100644 index 1a4445e28b2..00000000000 --- a/irc/TechBot/TechBot.Library/Settings.Designer.cs +++ /dev/null @@ -1,80 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:2.0.50727.1433 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace TechBot.Library { - - - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "8.0.0.0")] - internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { - - private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); - - public static Settings Default { - get { - return defaultInstance; - } - } - - [global::System.Configuration.ApplicationScopedSettingAttribute()] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("C:\\Ros\\current\\irc\\TechBot\\Resources\\ntstatus.xml")] - public string NtStatusXml { - get { - return ((string)(this["NtStatusXml"])); - } - } - - [global::System.Configuration.ApplicationScopedSettingAttribute()] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("C:\\Ros\\current\\irc\\TechBot\\Resources\\winerror.xml")] - public string WinErrorXml { - get { - return ((string)(this["WinErrorXml"])); - } - } - - [global::System.Configuration.ApplicationScopedSettingAttribute()] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("C:\\Ros\\current\\irc\\TechBot\\Resources\\hresult.xml")] - public string HResultXml { - get { - return ((string)(this["HResultXml"])); - } - } - - [global::System.Configuration.ApplicationScopedSettingAttribute()] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("C:\\Ros\\current\\irc\\TechBot\\Resources\\wm.xml")] - public string WMXml { - get { - return ((string)(this["WMXml"])); - } - } - - [global::System.Configuration.ApplicationScopedSettingAttribute()] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("svn://svn.reactos.org/reactos/trunk")] - public string SVNRoot { - get { - return ((string)(this["SVNRoot"])); - } - } - - [global::System.Configuration.ApplicationScopedSettingAttribute()] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("!")] - public string CommandPrefix { - get { - return ((string)(this["CommandPrefix"])); - } - } - } -} diff --git a/irc/TechBot/TechBot.Library/Settings.cs b/irc/TechBot/TechBot.Library/Settings.cs deleted file mode 100644 index e1543b0e887..00000000000 --- a/irc/TechBot/TechBot.Library/Settings.cs +++ /dev/null @@ -1,28 +0,0 @@ -namespace TechBot.Library { - - - // This class allows you to handle specific events on the settings class: - // The SettingChanging event is raised before a setting's value is changed. - // The PropertyChanged event is raised after a setting's value is changed. - // The SettingsLoaded event is raised after the setting values are loaded. - // The SettingsSaving event is raised before the setting values are saved. - internal sealed partial class Settings { - - public Settings() { - // // To add event handlers for saving and changing settings, uncomment the lines below: - // - // this.SettingChanging += this.SettingChangingEventHandler; - // - // this.SettingsSaving += this.SettingsSavingEventHandler; - // - } - - private void SettingChangingEventHandler(object sender, System.Configuration.SettingChangingEventArgs e) { - // Add code to handle the SettingChangingEvent event here. - } - - private void SettingsSavingEventHandler(object sender, System.ComponentModel.CancelEventArgs e) { - // Add code to handle the SettingsSaving event here. - } - } -} diff --git a/irc/TechBot/TechBot.Library/Settings.settings b/irc/TechBot/TechBot.Library/Settings.settings deleted file mode 100644 index 2673cc50cb1..00000000000 --- a/irc/TechBot/TechBot.Library/Settings.settings +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - C:\Ros\current\irc\TechBot\Resources\ntstatus.xml - - - C:\Ros\current\irc\TechBot\Resources\winerror.xml - - - C:\Ros\current\irc\TechBot\Resources\hresult.xml - - - C:\Ros\current\irc\TechBot\Resources\wm.xml - - - svn://svn.reactos.org/reactos/trunk - - - ! - - - \ No newline at end of file diff --git a/irc/TechBot/TechBot.Library/TechBot.Library.csproj b/irc/TechBot/TechBot.Library/TechBot.Library.csproj deleted file mode 100644 index 59505743bf2..00000000000 --- a/irc/TechBot/TechBot.Library/TechBot.Library.csproj +++ /dev/null @@ -1,83 +0,0 @@ - - - - Debug - AnyCPU - 8.0.50727 - 2.0 - {1114F34D-F388-4F38-AE27-C0EE1B10B777} - Library - Properties - TechBot.Library - TechBot.Library - - - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - - - - - - - - - - - - - - - - - - True - True - Settings.settings - - - - - - - - - - - - {D2A57931-DF04-4BC3-BD11-75DF4F3B0A88} - TechBot.IRCLibrary - - - - - - SettingsSingleFileGenerator - Settings.Designer.cs - - - \ No newline at end of file diff --git a/irc/TechBot/TechBot.Library/TechBotIrcService.cs b/irc/TechBot/TechBot.Library/TechBotIrcService.cs deleted file mode 100644 index 2a51374d330..00000000000 --- a/irc/TechBot/TechBot.Library/TechBotIrcService.cs +++ /dev/null @@ -1,312 +0,0 @@ -using System; -using System.Text; -using System.Collections; -using System.Threading; - -using TechBot.IRCLibrary; - -namespace TechBot.Library -{ - public class IrcServiceOutput : IServiceOutput - { - public void WriteLine(MessageContext context, - string message) - { - if (context is ChannelMessageContext) - { - Thread.Sleep (500); - ChannelMessageContext channelContext = context as ChannelMessageContext; - channelContext.Channel.Talk(message); - } - else if (context is UserMessageContext) - { - UserMessageContext userContext = context as UserMessageContext; - userContext.User.Talk(message); - } - else - { - throw new InvalidOperationException(String.Format("Unhandled message context '{0}'", - context.GetType())); - } - } - } - - public class IrcTechBotService : TechBotService - { - private int port; - private string hostname; - private string channelnames; - private string botname; - private string password; - private IrcClient m_IrcClient; - private ArrayList channels = new ArrayList(); - private bool isStopped = false; - - public IrcTechBotService(string hostname, - int port, - string channelnames, - string botname, - string password) - : base (new IrcServiceOutput()) - { - this.hostname = hostname; - this.port = port; - this.channelnames = channelnames; - this.botname = botname; - if (password == null || password.Trim() == "") - this.password = null; - else - this.password = password; - } - - public override void Run() - { - //Call the base class - base.Run(); - - m_IrcClient = new IrcClient(); - m_IrcClient.Encoding = Encoding.GetEncoding("iso-8859-1"); - m_IrcClient.OnConnect += new OnConnectHandler(m_IrcClient_OnConnect); - m_IrcClient.OnConnectionLost += new OnConnectionLostHandler(m_IrcClient_OnConnectionLost); - m_IrcClient.OnDisconnect += new OnDisconnectHandler(m_IrcClient_OnDisconnect); - m_IrcClient.MessageReceived += new MessageReceivedHandler(client_MessageReceived); - m_IrcClient.ChannelUserDatabaseChanged += new ChannelUserDatabaseChangedHandler(client_ChannelUserDatabaseChanged); - - Connect(); - } - - void m_IrcClient_OnConnect() - { - Console.WriteLine("Connected..."); - } - - private void Connect() - { - Console.WriteLine("Connecting to {0} port {1}", - hostname, - port); - m_IrcClient.Connect(hostname, port); - - m_IrcClient.Register(botname, password, null); - Console.WriteLine("Registered as {0}...", m_IrcClient.Nickname); - - /* Did we get the nick we wanted? */ - if (m_IrcClient.Nickname != botname) - { - /* there must have been an existing one, kill it */ - m_IrcClient.GhostNick(botname, password);; - } - - JoinChannels(); - - while (!isStopped) - { - Thread.Sleep(1000); - } - - PartChannels(); - m_IrcClient.Diconnect(); - } - - void m_IrcClient_OnDisconnect() - { - Console.WriteLine("Disconnected..."); - } - - void m_IrcClient_OnConnectionLost() - { - //Dispose old connection - Disconnect(); - - //Sleep for 1 minute - Thread.Sleep(1000 * 60); - - //Try to reconnect - Connect(); - } - - private void Disconnect() - { - try - { - m_IrcClient.Diconnect(); - } - catch (Exception) - { - // - } - } - - public void Stop() - { - isStopped = true; - } - - private void JoinChannels() - { - foreach (string channelname in channelnames.Split(new char[] { ';' })) - { - IrcChannel channel = m_IrcClient.JoinChannel(channelname); - channels.Add(channel); - System.Console.WriteLine(String.Format("Joined channel #{0}...", - channel.Name)); - } - } - - private void PartChannels() - { - foreach (IrcChannel channel in channels) - { - m_IrcClient.PartChannel(channel, "Caught in the bitstream..."); - System.Console.WriteLine(String.Format("Parted channel #{0}...", - channel.Name)); - } - } - - private string GetMessageSource(MessageContext context) - { - if (context is ChannelMessageContext) - { - ChannelMessageContext channelContext = context as ChannelMessageContext; - return String.Format("#{0}", - channelContext.Channel.Name); - } - else if (context is UserMessageContext) - { - UserMessageContext userContext = context as UserMessageContext; - return userContext.User.Nickname; - } - else - { - throw new InvalidOperationException(String.Format("Unhandled message context '{0}'", - context.GetType())); - } - } - - private void ExtractMessage(string parameters, - out string message) - { - int startIndex = parameters.IndexOf(':'); - if (startIndex != -1) - { - message = parameters.Substring(startIndex + 1); - } - else - { - message = parameters; - } - } - - private bool GetChannelName(IrcMessage message, - out string channelName) - { - if (message.Parameters == null || !message.Parameters.StartsWith("#")) - { - channelName = null; - return false; - } - - int index = message.Parameters.IndexOf(' '); - if (index == -1) - index = message.Parameters.Length; - else - index = index - 1; - channelName = message.Parameters.Substring(1, index); - return true; - } - - private bool GetTargetNickname(IrcMessage message, - out string nickname) - { - if (message.Parameters == null) - { - nickname = null; - return false; - } - - int index = message.Parameters.IndexOf(' '); - if (index == -1) - index = message.Parameters.Length; - nickname = message.Parameters.Substring(0, index); - Console.WriteLine("nickname: " + nickname); - return true; - } - - private bool ShouldAcceptMessage(IrcMessage message, - out MessageContext context) - { - if (message.Command.ToUpper().Equals("PRIVMSG")) - { - string channelName; - string nickname; - if (GetChannelName(message, - out channelName)) - { - foreach (IrcChannel channel in channels) - { - if (String.Compare(channel.Name, channelName, true) == 0) - { - context = new ChannelMessageContext(channel); - return true; - } - } - } - else if (GetTargetNickname(message, - out nickname)) - { - IrcUser targetUser = new IrcUser(m_IrcClient, - nickname); - if (String.Compare(targetUser.Nickname, botname, true) == 0) - { - IrcUser sourceUser = new IrcUser(m_IrcClient, - message.PrefixNickname); - context = new UserMessageContext(sourceUser); - return true; - } - } - } - context = null; - return false; - } - - private void client_MessageReceived(IrcMessage message) - { - try - { - if (message.Command != null && - message.Parameters != null) - { - string injectMessage; - ExtractMessage(message.Parameters, - out injectMessage); - MessageContext context; - if (ShouldAcceptMessage(message, - out context)) - { - Console.WriteLine(String.Format("Injecting: {0} from {1}", - injectMessage, - GetMessageSource(context))); - InjectMessage(context, - injectMessage); - } - else - { - Console.WriteLine("Received: " + message.Line); - } - } - else - { - Console.WriteLine("Received: " + message.Line); - } - } - catch (Exception ex) - { - Console.WriteLine(String.Format("Exception: {0}", ex)); - } - } - - private void client_ChannelUserDatabaseChanged(IrcChannel channel) - { - } - } -} diff --git a/irc/TechBot/TechBot.Library/TechBotService.cs b/irc/TechBot/TechBot.Library/TechBotService.cs deleted file mode 100644 index 025ff46d8ed..00000000000 --- a/irc/TechBot/TechBot.Library/TechBotService.cs +++ /dev/null @@ -1,101 +0,0 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using System.IO; -using System.Data; -using System.Threading; - -using TechBot.IRCLibrary; - -namespace TechBot.Library -{ - public abstract class TechBotService - { - protected IServiceOutput m_ServiceOutput; - - public TechBotService(IServiceOutput serviceOutput) - { - m_ServiceOutput = serviceOutput; - } - - public virtual void Run() - { - CommandFactory.LoadPlugins(); - } - - public IServiceOutput ServiceOutput - { - get { return m_ServiceOutput; } - } - - public CommandBuilderCollection Commands - { - get { return CommandFactory.Commands; } - } - - public void InjectMessage(MessageContext context, string message) - { - ParseCommandMessage(context, - message); - } - - private bool IsCommandMessage(string message) - { - return message.StartsWith(Settings.Default.CommandPrefix); - } - - public void InjectMessage(string message) - { - ParseCommandMessage(null, message); - } - - public void ParseCommandMessage(MessageContext context, - string message) - { - if (!IsCommandMessage(message)) - return; - - message = message.Substring(1).Trim(); - int index = message.IndexOf(' '); - string commandName; - string commandParams = ""; - if (index != -1) - { - commandName = message.Substring(0, index).Trim(); - commandParams = message.Substring(index).Trim(); - } - else - commandName = message.Trim(); - - foreach (CommandBuilder command in Commands) - { - if (command.Name == commandName) - { - //Create a new instance of the required command type - Command cmd = command.CreateCommand(); - - cmd.TechBot = this; - cmd.Context = context; - cmd.Parameters = commandParams; - - try - { - cmd.Initialize(); - cmd.Run(); - cmd.DeInitialize(); - } - catch (Exception e) - { - ServiceOutput.WriteLine(context, string.Format("Uops! Just crashed with exception '{0}' at {1}", - e.Message, - e.Source)); - - ServiceOutput.WriteLine(context, e.StackTrace); - } - - return; - } - } - } - } -} diff --git a/irc/TechBot/TechBot.Library/app.config b/irc/TechBot/TechBot.Library/app.config deleted file mode 100644 index cc2cba5b4ee..00000000000 --- a/irc/TechBot/TechBot.Library/app.config +++ /dev/null @@ -1,30 +0,0 @@ - - - - -
        - - - - - - C:\Ros\current\irc\TechBot\Resources\ntstatus.xml - - - C:\Ros\current\irc\TechBot\Resources\winerror.xml - - - C:\Ros\current\irc\TechBot\Resources\hresult.xml - - - C:\Ros\current\irc\TechBot\Resources\wm.xml - - - svn://svn.reactos.org/reactos/trunk - - - ! - - - - \ No newline at end of file diff --git a/irc/TechBot/TechBot.sln b/irc/TechBot/TechBot.sln deleted file mode 100644 index 3c794500893..00000000000 --- a/irc/TechBot/TechBot.sln +++ /dev/null @@ -1,62 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 9.00 -# Visual Studio 2005 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TechBot", "TechBot\TechBot.csproj", "{106F437D-424B-4758-A69C-862D08D26F3D}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Compression", "Compression\Compression.csproj", "{E32307F1-623A-4E62-826F-56CDD4B23A54}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CHMLibrary", "CHMLibrary\CHMLibrary.csproj", "{72E5CCA1-6318-4D62-964D-CB23A5C743B5}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TechBot.Console", "TechBot.Console\TechBot.Console.csproj", "{44258BA2-FFCB-4463-9CED-6DE5CC5CEBD4}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TechBot.IRCLibrary", "TechBot.IRCLibrary\TechBot.IRCLibrary.csproj", "{D2A57931-DF04-4BC3-BD11-75DF4F3B0A88}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TechBot.Library", "TechBot.Library\TechBot.Library.csproj", "{1114F34D-F388-4F38-AE27-C0EE1B10B777}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TechBot.Commands.Common", "TechBot.Commands.Common\TechBot.Commands.Common.csproj", "{041B5F06-BF97-4981-B024-3A7B6DD9F6AE}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TechBot.Commands.MSDN", "TechBot.Commands.MSDN\TechBot.Commands.MSDN.csproj", "{ADBF1ED6-A586-4707-BD59-4CD53448D0FE}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {106F437D-424B-4758-A69C-862D08D26F3D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {106F437D-424B-4758-A69C-862D08D26F3D}.Debug|Any CPU.Build.0 = Debug|Any CPU - {106F437D-424B-4758-A69C-862D08D26F3D}.Release|Any CPU.ActiveCfg = Release|Any CPU - {106F437D-424B-4758-A69C-862D08D26F3D}.Release|Any CPU.Build.0 = Release|Any CPU - {E32307F1-623A-4E62-826F-56CDD4B23A54}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {E32307F1-623A-4E62-826F-56CDD4B23A54}.Debug|Any CPU.Build.0 = Debug|Any CPU - {E32307F1-623A-4E62-826F-56CDD4B23A54}.Release|Any CPU.ActiveCfg = Release|Any CPU - {E32307F1-623A-4E62-826F-56CDD4B23A54}.Release|Any CPU.Build.0 = Release|Any CPU - {72E5CCA1-6318-4D62-964D-CB23A5C743B5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {72E5CCA1-6318-4D62-964D-CB23A5C743B5}.Debug|Any CPU.Build.0 = Debug|Any CPU - {72E5CCA1-6318-4D62-964D-CB23A5C743B5}.Release|Any CPU.ActiveCfg = Release|Any CPU - {72E5CCA1-6318-4D62-964D-CB23A5C743B5}.Release|Any CPU.Build.0 = Release|Any CPU - {44258BA2-FFCB-4463-9CED-6DE5CC5CEBD4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {44258BA2-FFCB-4463-9CED-6DE5CC5CEBD4}.Debug|Any CPU.Build.0 = Debug|Any CPU - {44258BA2-FFCB-4463-9CED-6DE5CC5CEBD4}.Release|Any CPU.ActiveCfg = Release|Any CPU - {44258BA2-FFCB-4463-9CED-6DE5CC5CEBD4}.Release|Any CPU.Build.0 = Release|Any CPU - {D2A57931-DF04-4BC3-BD11-75DF4F3B0A88}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {D2A57931-DF04-4BC3-BD11-75DF4F3B0A88}.Debug|Any CPU.Build.0 = Debug|Any CPU - {D2A57931-DF04-4BC3-BD11-75DF4F3B0A88}.Release|Any CPU.ActiveCfg = Release|Any CPU - {D2A57931-DF04-4BC3-BD11-75DF4F3B0A88}.Release|Any CPU.Build.0 = Release|Any CPU - {1114F34D-F388-4F38-AE27-C0EE1B10B777}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {1114F34D-F388-4F38-AE27-C0EE1B10B777}.Debug|Any CPU.Build.0 = Debug|Any CPU - {1114F34D-F388-4F38-AE27-C0EE1B10B777}.Release|Any CPU.ActiveCfg = Release|Any CPU - {1114F34D-F388-4F38-AE27-C0EE1B10B777}.Release|Any CPU.Build.0 = Release|Any CPU - {041B5F06-BF97-4981-B024-3A7B6DD9F6AE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {041B5F06-BF97-4981-B024-3A7B6DD9F6AE}.Debug|Any CPU.Build.0 = Debug|Any CPU - {041B5F06-BF97-4981-B024-3A7B6DD9F6AE}.Release|Any CPU.ActiveCfg = Release|Any CPU - {041B5F06-BF97-4981-B024-3A7B6DD9F6AE}.Release|Any CPU.Build.0 = Release|Any CPU - {ADBF1ED6-A586-4707-BD59-4CD53448D0FE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {ADBF1ED6-A586-4707-BD59-4CD53448D0FE}.Debug|Any CPU.Build.0 = Debug|Any CPU - {ADBF1ED6-A586-4707-BD59-4CD53448D0FE}.Release|Any CPU.ActiveCfg = Release|Any CPU - {ADBF1ED6-A586-4707-BD59-4CD53448D0FE}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/irc/TechBot/TechBot/App.config b/irc/TechBot/TechBot/App.config deleted file mode 100644 index 652f7444d66..00000000000 --- a/irc/TechBot/TechBot/App.config +++ /dev/null @@ -1,44 +0,0 @@ - - - - -
        - - - - - - - - - - - - - - - - - - - - - - - irc.eu.freenode.net - - - rbuildbottest - - - RBuildBot - - - qwerty - - - 6667 - - - - diff --git a/irc/TechBot/TechBot/AssemblyInfo.cs b/irc/TechBot/TechBot/AssemblyInfo.cs deleted file mode 100644 index dbacda112e8..00000000000 --- a/irc/TechBot/TechBot/AssemblyInfo.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; - -// Information about this assembly is defined by the following -// attributes. -// -// change them to the information which is associated with the assembly -// you compile. - -[assembly: AssemblyTitle("")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("")] -[assembly: AssemblyCopyright("")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// The assembly version has following format : -// -// Major.Minor.Build.Revision -// -// You can specify all values by your own or you can build default build and revision -// numbers with the '*' character (the default): - -[assembly: AssemblyVersion("1.0.*")] - -// The following attributes specify the key for the sign of your assembly. See the -// .NET Framework documentation for more information about signing. -// This is not required, if you don't want signing let these attributes like they're. -[assembly: AssemblyDelaySign(false)] -[assembly: AssemblyKeyFile("")] diff --git a/irc/TechBot/TechBot/Default.build b/irc/TechBot/TechBot/Default.build deleted file mode 100644 index 8d0f4bb4de7..00000000000 --- a/irc/TechBot/TechBot/Default.build +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - - - - - - - - - - - - diff --git a/irc/TechBot/TechBot/ProjectInstaller.cs b/irc/TechBot/TechBot/ProjectInstaller.cs deleted file mode 100644 index 0dc2b152a6e..00000000000 --- a/irc/TechBot/TechBot/ProjectInstaller.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System; -using System.ComponentModel; -using System.ServiceProcess; -using System.Configuration.Install; -using System.Collections.Generic; -using System.Text; - -namespace TechBot -{ - [RunInstaller(true)] - public class ProjectInstaller : Installer - { - public ProjectInstaller() - { - ServiceProcessInstaller spi = null; - ServiceInstaller si = null; - - spi = new ServiceProcessInstaller(); - spi.Account = ServiceAccount.LocalSystem; - - si = new ServiceInstaller(); - si.ServiceName = "TechBot"; - si.StartType = ServiceStartMode.Automatic; - - Installers.AddRange(new Installer[] { spi, si }); - } - } -} diff --git a/irc/TechBot/TechBot/Properties/.gitignore b/irc/TechBot/TechBot/Properties/.gitignore deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/irc/TechBot/TechBot/ServiceThread.cs b/irc/TechBot/TechBot/ServiceThread.cs deleted file mode 100644 index 411d0f94f98..00000000000 --- a/irc/TechBot/TechBot/ServiceThread.cs +++ /dev/null @@ -1,43 +0,0 @@ -using System; -using System.Configuration; -using System.Diagnostics; -using TechBot.Library; - -namespace TechBot -{ - public class ServiceThread - { - private EventLog m_EventLog; - - public ServiceThread(EventLog eventLog) - { - m_EventLog = eventLog; - } - - public void Run() - { - System.Console.WriteLine("TechBot irc service..."); - - IrcTechBotService ircService = new IrcTechBotService( - Settings.Default.IRCServerHostName, - Settings.Default.IRCServerHostPort, - Settings.Default.IRCChannelNames, - Settings.Default.IRCBotName, - Settings.Default.IRCBotPassword); - - ircService.Run(); - } - - public void Start() - { - try - { - Run(); - } - catch (Exception ex) - { - m_EventLog.WriteEntry(String.Format("Ex. {0}", ex)); - } - } - } -} diff --git a/irc/TechBot/TechBot/Settings.Designer.cs b/irc/TechBot/TechBot/Settings.Designer.cs deleted file mode 100644 index 87ae5985bc2..00000000000 --- a/irc/TechBot/TechBot/Settings.Designer.cs +++ /dev/null @@ -1,86 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:2.0.50727.1433 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace TechBot { - - - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "8.0.0.0")] - internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { - - private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); - - public static Settings Default { - get { - return defaultInstance; - } - } - - [global::System.Configuration.UserScopedSettingAttribute()] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("irc.eu.freenode.net")] - public string IRCServerHostName { - get { - return ((string)(this["IRCServerHostName"])); - } - set { - this["IRCServerHostName"] = value; - } - } - - [global::System.Configuration.UserScopedSettingAttribute()] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("rbuildbottest")] - public string IRCChannelNames { - get { - return ((string)(this["IRCChannelNames"])); - } - set { - this["IRCChannelNames"] = value; - } - } - - [global::System.Configuration.UserScopedSettingAttribute()] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("RBuildBot")] - public string IRCBotName { - get { - return ((string)(this["IRCBotName"])); - } - set { - this["IRCBotName"] = value; - } - } - - [global::System.Configuration.UserScopedSettingAttribute()] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("qwerty")] - public string IRCBotPassword { - get { - return ((string)(this["IRCBotPassword"])); - } - set { - this["IRCBotPassword"] = value; - } - } - - [global::System.Configuration.UserScopedSettingAttribute()] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("6667")] - public int IRCServerHostPort { - get { - return ((int)(this["IRCServerHostPort"])); - } - set { - this["IRCServerHostPort"] = value; - } - } - } -} diff --git a/irc/TechBot/TechBot/Settings.settings b/irc/TechBot/TechBot/Settings.settings deleted file mode 100644 index cd1160b7e7f..00000000000 --- a/irc/TechBot/TechBot/Settings.settings +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - irc.eu.freenode.net - - - rbuildbottest - - - RBuildBot - - - qwerty - - - 6667 - - - \ No newline at end of file diff --git a/irc/TechBot/TechBot/TechBot.csproj b/irc/TechBot/TechBot/TechBot.csproj deleted file mode 100644 index b5b42911efa..00000000000 --- a/irc/TechBot/TechBot/TechBot.csproj +++ /dev/null @@ -1,82 +0,0 @@ - - - - Debug - AnyCPU - 8.0.50727 - 2.0 - {106F437D-424B-4758-A69C-862D08D26F3D} - Exe - Properties - TechBot - TechBot - TechBot.TechBotService - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - - - - SettingsSingleFileGenerator - Settings.Designer.cs - - - - - - Component - - - - Settings.settings - True - True - - - Component - - - - - - - - - - - - {D2A57931-DF04-4BC3-BD11-75DF4F3B0A88} - TechBot.IRCLibrary - - - {1114F34D-F388-4F38-AE27-C0EE1B10B777} - TechBot.Library - - - - - - \ No newline at end of file diff --git a/irc/TechBot/TechBot/TechBot.prjx b/irc/TechBot/TechBot/TechBot.prjx deleted file mode 100644 index 7af6ca126aa..00000000000 --- a/irc/TechBot/TechBot/TechBot.prjx +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/irc/TechBot/TechBot/TechBotService.cs b/irc/TechBot/TechBot/TechBotService.cs deleted file mode 100644 index 61c1e0f5cd1..00000000000 --- a/irc/TechBot/TechBot/TechBotService.cs +++ /dev/null @@ -1,82 +0,0 @@ -using System; -using System.Threading; -using System.Collections; -using System.ComponentModel; -using System.Data; -using System.Diagnostics; -using System.ServiceProcess; -using System.Configuration.Install; - -namespace TechBot -{ - public class TechBotService : ServiceBase - { - private Thread thread; - private ServiceThread threadWorker; - - public TechBotService() - { - InitializeComponents(); - } - - private void InitializeComponents() - { - this.ServiceName = "TechBot"; - } - - /// - /// This method starts the service. - /// - public static void Main() - { - System.ServiceProcess.ServiceBase.Run(new System.ServiceProcess.ServiceBase[] { - new TechBotService() // To run more than one service you have to add them here - }); - } - - /// - /// Clean up any resources being used. - /// - protected override void Dispose(bool disposing) - { - base.Dispose(disposing); - } - - /// - /// Start this service. - /// - protected override void OnStart(string[] args) - { - try - { - threadWorker = new ServiceThread(EventLog); - thread = new Thread(new ThreadStart(threadWorker.Start)); - thread.Start(); - EventLog.WriteEntry(String.Format("TechBot service is running.")); - } - catch (Exception ex) - { - EventLog.WriteEntry(String.Format("Ex. {0}", ex)); - } - } - - /// - /// Stop this service. - /// - protected override void OnStop() - { - try - { - thread.Abort(); - thread.Join(); - thread = null; - threadWorker = null; - EventLog.WriteEntry(String.Format("TechBot service is stopped.")); - } - catch (Exception ex) - { - EventLog.WriteEntry(String.Format("Ex. {0}", ex)); - } - } - } -} From 867a6b79d410819314ba3eeec70aaf95a1316660 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Thu, 9 Dec 2010 15:53:55 +0000 Subject: [PATCH 037/181] [WIN32K] Merge r49994 and r49995 from reactx branch svn path=/trunk/; revision=49996 --- reactos/subsystems/win32/win32k/eng/ldevobj.c | 8 ++++++-- reactos/subsystems/win32/win32k/ntddraw/ddraw.c | 12 ++---------- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/reactos/subsystems/win32/win32k/eng/ldevobj.c b/reactos/subsystems/win32/win32k/eng/ldevobj.c index 0e6c0eea540..2b3f73aff44 100644 --- a/reactos/subsystems/win32/win32k/eng/ldevobj.c +++ b/reactos/subsystems/win32/win32k/eng/ldevobj.c @@ -355,8 +355,12 @@ EngLoadImageEx( RtlAppendUnicodeToString(&strDriverName, pwsz); /* MSDN says "The driver must include this suffix in the pwszDriver string." - But in fact it's optional. */ - if (_wcsnicmp(pwszDriverName + cwcLength - 4, L".dll", 4) != 0) + But in fact it's optional. + + ms win32k EngLoadImageEx loading .sys file without append .dll + */ + if ( (_wcsnicmp(pwszDriverName + cwcLength - 4, L".dll", 4) != 0) && + (_wcsnicmp(pwszDriverName + cwcLength - 4, L".sys", 4) != 0) ) { /* Append the .dll suffix */ RtlAppendUnicodeToString(&strDriverName, L".dll"); diff --git a/reactos/subsystems/win32/win32k/ntddraw/ddraw.c b/reactos/subsystems/win32/win32k/ntddraw/ddraw.c index 19b6931b01b..604c150fc2e 100644 --- a/reactos/subsystems/win32/win32k/ntddraw/ddraw.c +++ b/reactos/subsystems/win32/win32k/ntddraw/ddraw.c @@ -138,16 +138,8 @@ DxDdStartupDxGraphics( ULONG ulc1, /* Loading the kernel interface of directx for win32k */ - DPRINT1("Warning: trying loading vista dxkrnl.sys\n"); - ghDxGraphics = EngLoadImage(L"\\SystemRoot\\System32\\drivers\\dxkrnl.sys"); - if ( ghDxGraphics == NULL) - { - DPRINT1("Warning: dxkrnl.sys not found\n"); - /* try loading vista dx kernel */ - DPRINT1("Warning: trying loading xp/2003/reactos dxg.sys\n"); - ghDxGraphics = EngLoadImage(L"\\SystemRoot\\System32\\drivers\\dxg.sys"); - } - + DPRINT1("Warning: trying loading xp/2003/windows7/reactos dxg.sys\n"); + ghDxGraphics = EngLoadImage(L"\\SystemRoot\\System32\\drivers\\dxg.sys"); if ( ghDxGraphics == NULL) { Status = STATUS_DLL_NOT_FOUND; From c19a377df2f79b96f3175d1e4d444d3a0a4d3ff5 Mon Sep 17 00:00:00 2001 From: Aleksey Bragin Date: Fri, 10 Dec 2010 09:33:20 +0000 Subject: [PATCH 038/181] [HEAP] - Time has come to get rid of a slightly modified implementation of WINE's heap, which is a hack based on Windows 95's heap implementation, itself a hack of DOS memory management. It supported 3 out of the 18 possible NT Heap Flags, did not support custom allocation/deallocation routines, and was about 50-80x slower with fragmentation rates up to 500x higher when compared to NT's LFH (WINE is lucky because the advanced NT Heap features are used in kernel-mode usually, not in user-mode, and they are crossing their fingers for this being the same). Several high-end SQL/Database applications would significantly benefit from custom heap features provided by NT. Not to say about removing crappy support for a custom Commit routine and crappy support for User-defined flags and the User-defined value. - So, the glorious moment for a new heap manager, which is (to remind you) a totally new heap manager, resembling real NT heap manager, based on data structures similar to Windows 2003 and Vista+'s heap structures, supporting advanced heap flags (e.g. useful for debugging), having substantially lower fragmentation rates (and thus speed and reliability), having native support for user-defined flags and user-defined values, also native support for a custom commit routine, which is very important for trunk's win32 subsystem. It also reserves, commits, decommits and frees memory on the fly, unlike existing heap manager which prefers to reserve and commit as much as possible, and doesn't decommit when it's no longer necessary. Not to say about support for per process heaps, with a proper lock, and a further support for a special so-called debug heap allocator (to be implemented in heapdbg.c) which will be useful for finding heap corruptions. Yeah, I'm not a fun person :D svn path=/trunk/; revision=50000 --- reactos/lib/rtl/heap.c | 5146 ++++++++++++++++++++++---------- reactos/lib/rtl/heap_rewrite.c | 4138 ------------------------- 2 files changed, 3632 insertions(+), 5652 deletions(-) delete mode 100644 reactos/lib/rtl/heap_rewrite.c diff --git a/reactos/lib/rtl/heap.c b/reactos/lib/rtl/heap.c index 0e43ccbcf66..2c28b6a76d7 100644 --- a/reactos/lib/rtl/heap.c +++ b/reactos/lib/rtl/heap.c @@ -1,1155 +1,1340 @@ /* COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS system libraries - * FILE: lib/rtl/image.c - * PURPOSE: Image handling functions - * PROGRAMMERS: Copyright 1996 Alexandre Julliard - * Copyright 1998 Ulrich Weigand + * FILE: lib/rtl/heap.c + * PURPOSE: RTL Heap backend allocator + * PROGRAMMERS: Copyright 2010 Aleksey Bragin */ -// -// Note: This is a slightly modified implementation of WINE's. -// -// WINE's implementation is a hack based on Windows 95's heap implementation, -// itself a hack of DOS memory management.It supports 3 out of the 18 possible -// NT Heap Flags, does not support custom allocation/deallocation routines, -// and is about 50-80x slower with fragmentation rates up to 500x higher when -// compared to NT's LFH. WINE is lucky because the advanced NT Heap features are -// used in kernel-mode usually, not in user-mode, and they are crossing their -// fingers for this being the same. Note that several high-end SQL/Database -// applications would significantly benefit from custom heap features provided -// by NT. -// -// ROS's changes include: -// - Using Zw instead of Nt calls, because this matters when in Kernel Mode -// - Not using per-process heap lists while in Kernel Mode -// - Using a macro to handle the Critical Section, because it's meaningless -// in Kernel Mode. -// - Crappy support for a custom Commit routine. -// - Crappy support for User-defined flags and the User-defined value. -// - Ripping out all the code for shared heaps, because those don't exist on NT. -// -// Be aware of these changes when you try to sync something back. -// +/* Useful references: + http://msdn.microsoft.com/en-us/library/ms810466.aspx + http://msdn.microsoft.com/en-us/library/ms810603.aspx + http://www.securitylab.ru/analytics/216376.php + http://binglongx.spaces.live.com/blog/cns!142CBF6D49079DE8!596.entry + http://www.phreedom.org/research/exploits/asn1-bitstring/ + http://illmatics.com/Understanding_the_LFH.pdf + http://www.alex-ionescu.com/?p=18 +*/ /* INCLUDES *****************************************************************/ #include -#undef LIST_FOR_EACH -#undef LIST_FOR_EACH_SAFE -#include +#include #define NDEBUG #include -#define TRACE DPRINT -#define WARN DPRINT1 -#define ERR DPRINT1 -#define DPRINTF DPRINT +HEAP_LOCK RtlpProcessHeapsListLock; -/* FUNCTIONS *****************************************************************/ +/* Bitmaps stuff */ -#define WARN_ON(x) (1) - -#ifdef NDEBUG -#define TRACE_ON(x) (0) -#else -#define TRACE_ON(x) (1) -#endif - -/* Note: the heap data structures are based on what Pietrek describes in his - * book 'Windows 95 System Programming Secrets'. The layout is not exactly - * the same, but could be easily adapted if it turns out some programs - * require it. - */ - -/* FIXME: use SIZE_T for 'size' structure members, but we need to make sure - * that there is no unaligned accesses to structure fields. - */ - -typedef struct tagARENA_INUSE +/* How many least significant bits are clear */ +UCHAR RtlpBitsClearLow[] = { - SIZE_T size; /* Block size; must be the first field */ - DWORD magic : 23; /* Magic number */ - DWORD has_user_data : 1; /* There is user data associated with this block */ - DWORD unused_bytes : 8; /* Number of bytes in the block not used by user data (max value is HEAP_MIN_DATA_SIZE+HEAP_MIN_SHRINK_SIZE) */ -} ARENA_INUSE; - -typedef struct tagARENA_FREE -{ - SIZE_T size; /* Block size; must be the first field */ - DWORD magic; /* Magic number */ - struct list entry; /* Entry in free list */ -} ARENA_FREE; - -#define ARENA_FLAG_FREE 0x00000001 /* flags OR'ed with arena size */ -#define ARENA_FLAG_PREV_FREE 0x00000002 -#define ARENA_INUSE_MAGIC 0x455355 /* Value for arena 'magic' field */ -#define ARENA_FREE_MAGIC 0x45455246 /* Value for arena 'magic' field */ - -#ifndef _WIN64 -#define ARENA_SIZE_MASK (~3L) -#else -#define ARENA_SIZE_MASK (~7L) -#endif - -#define ARENA_INUSE_FILLER 0x55 -#define ARENA_FREE_FILLER 0xaa - -/* everything is aligned on 8 byte boundaries (16 for Win64)*/ -#define ALIGNMENT (2*sizeof(void*)) -#define ARENA_OFFSET (ALIGNMENT - sizeof(ARENA_INUSE)) - -#define ROUND_SIZE(size) ((((size) + ALIGNMENT - 1) & ~(ALIGNMENT-1)) + ARENA_OFFSET) - - -#define QUIET 1 /* Suppress messages */ -#define NOISY 0 /* Report all errors */ - -/* minimum data size (without arenas) of an allocated block */ -#define HEAP_MIN_DATA_SIZE ROUND_SIZE(2 * sizeof(struct list)) -/* minimum size that must remain to shrink an allocated block */ -#define HEAP_MIN_SHRINK_SIZE (HEAP_MIN_DATA_SIZE+sizeof(ARENA_FREE)) - -#define HEAP_NB_FREE_LISTS 5 /* Number of free lists */ - -/* Max size of the blocks on the free lists */ -static const DWORD HEAP_freeListSizes[HEAP_NB_FREE_LISTS] = -{ - 0x10, 0x20, 0x80, 0x200, MAXULONG + 8,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0, + 4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0, + 5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0, + 4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0, + 6,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0, + 4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0, + 5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0, + 4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0, + 7,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0, + 4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0, + 5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0, + 4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0, + 6,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0, + 4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0, + 5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0, + 4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0 }; -typedef union +UCHAR FORCEINLINE +RtlpFindLeastSetBit(ULONG Bits) { - ARENA_FREE arena; - void *aligment[4]; -} FREE_LIST_ENTRY; - -struct tagHEAP; - -typedef struct tagSUBHEAP -{ - SIZE_T size; /* Size of the whole sub-heap */ - SIZE_T commitSize; /* Committed size of the sub-heap */ - DWORD headerSize; /* Size of the heap header */ - struct tagSUBHEAP *next; /* Next sub-heap */ - struct tagHEAP *heap; /* Main heap structure */ - DWORD magic; /* Magic number */ -} SUBHEAP; - -#define SUBHEAP_MAGIC ((DWORD)('S' | ('U'<<8) | ('B'<<16) | ('H'<<24))) - -typedef struct tagHEAP_USER_DATA -{ - LIST_ENTRY ListEntry; - PVOID BaseAddress; - ULONG UserFlags; - PVOID UserValue; -} HEAP_USER_DATA, *PHEAP_USER_DATA; - -typedef struct tagHEAP -{ - SUBHEAP subheap; /* First sub-heap */ - struct list entry; /* Entry in process heap list */ - HEAP_LOCK lock; /* Critical section for serialization */ - DECLSPEC_ALIGN(8) FREE_LIST_ENTRY freeList[HEAP_NB_FREE_LISTS]; /* Free lists */ - DWORD flags; /* Heap flags */ - DWORD magic; /* Magic number */ - PRTL_HEAP_COMMIT_ROUTINE commitRoutine; - LIST_ENTRY UserDataHead; -} HEAP; - -#define HEAP_MAGIC ((DWORD)('H' | ('E'<<8) | ('A'<<16) | ('P'<<24))) - -#define HEAP_DEF_SIZE 0x110000 /* Default heap size = 1Mb + 64Kb */ -#define COMMIT_MASK 0xffff /* bitmask for commit/decommit granularity */ - -static HEAP *processHeap; /* main process heap */ - -static BOOL HEAP_IsRealArena( HEAP *heapPtr, DWORD flags, LPCVOID block, BOOL quiet ); - -/* mark a block of memory as free for debugging purposes */ -static __inline void mark_block_free( void *ptr, SIZE_T size ) -{ - if (TRACE_ON(heap)) memset( ptr, ARENA_FREE_FILLER, size ); -#ifdef VALGRIND_MAKE_NOACCESS - VALGRIND_DISCARD( VALGRIND_MAKE_NOACCESS( ptr, size )); -#endif -} - -/* mark a block of memory as initialized for debugging purposes */ -static __inline void mark_block_initialized( void *ptr, SIZE_T size ) -{ -#ifdef VALGRIND_MAKE_READABLE - VALGRIND_DISCARD( VALGRIND_MAKE_READABLE( ptr, size )); -#endif -} - -/* mark a block of memory as uninitialized for debugging purposes */ -static __inline void mark_block_uninitialized( void *ptr, SIZE_T size ) -{ -#ifdef VALGRIND_MAKE_WRITABLE - VALGRIND_DISCARD( VALGRIND_MAKE_WRITABLE( ptr, size )); -#endif - if (TRACE_ON(heap)) + if (Bits & 0xFFFF) { - memset( ptr, ARENA_INUSE_FILLER, size ); -#ifdef VALGRIND_MAKE_WRITABLE - /* make it uninitialized to valgrind again */ - VALGRIND_DISCARD( VALGRIND_MAKE_WRITABLE( ptr, size )); -#endif - } -} - -/* clear contents of a block of memory */ -static __inline void clear_block( void *ptr, SIZE_T size ) -{ - mark_block_initialized( ptr, size ); - memset( ptr, 0, size ); -} - -/* locate a free list entry of the appropriate size */ -/* size is the size of the whole block including the arena header */ -static __inline unsigned int get_freelist_index( SIZE_T size ) -{ - unsigned int i; - - size -= sizeof(ARENA_FREE); - for (i = 0; i < HEAP_NB_FREE_LISTS - 1; i++) if (size <= HEAP_freeListSizes[i]) break; - return i; -} - -/* get the memory protection type to use for a given heap */ -static inline ULONG get_protection_type( DWORD flags ) -{ - return (flags & HEAP_CREATE_ENABLE_EXECUTE) ? PAGE_EXECUTE_READWRITE : PAGE_READWRITE; -} - -static RTL_CRITICAL_SECTION_DEBUG process_heap_critsect_debug = -{ - 0, 0, NULL, /* will be set later */ - { &process_heap_critsect_debug.ProcessLocksList, &process_heap_critsect_debug.ProcessLocksList }, - 0, 0, 0, 0, 0 -}; - -/*********************************************************************** - * HEAP_Dump - */ -static void HEAP_Dump( HEAP *heap ) -{ - int i; - SUBHEAP *subheap; - char *ptr; - - DPRINTF( "Heap: %p\n", heap ); - DPRINTF( "Next: %p Sub-heaps: %p", - LIST_ENTRY( heap->entry.next, HEAP, entry ), &heap->subheap ); - subheap = &heap->subheap; - while (subheap->next) - { - DPRINTF( " -> %p", subheap->next ); - subheap = subheap->next; - } - - DPRINTF( "\nFree lists:\n Block Stat Size Id\n" ); - for (i = 0; i < HEAP_NB_FREE_LISTS; i++) - DPRINTF( "%p free %08lx prev=%p next=%p\n", - &heap->freeList[i].arena, HEAP_freeListSizes[i], - LIST_ENTRY( heap->freeList[i].arena.entry.prev, ARENA_FREE, entry ), - LIST_ENTRY( heap->freeList[i].arena.entry.next, ARENA_FREE, entry )); - - subheap = &heap->subheap; - while (subheap) - { - SIZE_T freeSize = 0, usedSize = 0, arenaSize = subheap->headerSize; - DPRINTF( "\n\nSub-heap %p: size=%08lx committed=%08lx\n", - subheap, subheap->size, subheap->commitSize ); - - DPRINTF( "\n Block Stat Size Id\n" ); - ptr = (char*)subheap + subheap->headerSize; - while (ptr < (char *)subheap + subheap->size) - { - if (*(DWORD *)ptr & ARENA_FLAG_FREE) - { - ARENA_FREE *pArena = (ARENA_FREE *)ptr; - DPRINTF( "%p free %08lx prev=%p next=%p\n", - pArena, pArena->size & ARENA_SIZE_MASK, - LIST_ENTRY( pArena->entry.prev, ARENA_FREE, entry ), - LIST_ENTRY( pArena->entry.next, ARENA_FREE, entry ) ); - ptr += sizeof(*pArena) + (pArena->size & ARENA_SIZE_MASK); - arenaSize += sizeof(ARENA_FREE); - freeSize += pArena->size & ARENA_SIZE_MASK; - } - else if (*(DWORD *)ptr & ARENA_FLAG_PREV_FREE) - { - ARENA_INUSE *pArena = (ARENA_INUSE *)ptr; - DPRINTF( "%p Used %08lx back=%p\n", - pArena, pArena->size & ARENA_SIZE_MASK, *((ARENA_FREE **)pArena - 1) ); - ptr += sizeof(*pArena) + (pArena->size & ARENA_SIZE_MASK); - arenaSize += sizeof(ARENA_INUSE); - usedSize += pArena->size & ARENA_SIZE_MASK; - } - else - { - ARENA_INUSE *pArena = (ARENA_INUSE *)ptr; - DPRINTF( "%p used %08lx\n", pArena, pArena->size & ARENA_SIZE_MASK ); - ptr += sizeof(*pArena) + (pArena->size & ARENA_SIZE_MASK); - arenaSize += sizeof(ARENA_INUSE); - usedSize += pArena->size & ARENA_SIZE_MASK; - } - } - DPRINTF( "\nTotal: Size=%08lx Committed=%08lx Free=%08lx Used=%08lx Arenas=%08lx (%ld%%)\n\n", - subheap->size, subheap->commitSize, freeSize, usedSize, - arenaSize, (arenaSize * 100) / subheap->size ); - subheap = subheap->next; - } -} - -#if 0 -static void HEAP_DumpEntry( LPPROCESS_HEAP_ENTRY entry ) -{ - WORD rem_flags; - TRACE( "Dumping entry %p\n", entry ); - TRACE( "lpData\t\t: %p\n", entry->lpData ); - TRACE( "cbData\t\t: %08lx\n", entry->cbData); - TRACE( "cbOverhead\t: %08x\n", entry->cbOverhead); - TRACE( "iRegionIndex\t: %08x\n", entry->iRegionIndex); - TRACE( "WFlags\t\t: "); - if (entry->wFlags & PROCESS_HEAP_REGION) - TRACE( "PROCESS_HEAP_REGION "); - if (entry->wFlags & PROCESS_HEAP_UNCOMMITTED_RANGE) - TRACE( "PROCESS_HEAP_UNCOMMITTED_RANGE "); - if (entry->wFlags & PROCESS_HEAP_ENTRY_BUSY) - TRACE( "PROCESS_HEAP_ENTRY_BUSY "); - if (entry->wFlags & PROCESS_HEAP_ENTRY_MOVEABLE) - TRACE( "PROCESS_HEAP_ENTRY_MOVEABLE "); - if (entry->wFlags & PROCESS_HEAP_ENTRY_DDESHARE) - TRACE( "PROCESS_HEAP_ENTRY_DDESHARE "); - rem_flags = entry->wFlags & - ~(PROCESS_HEAP_REGION | PROCESS_HEAP_UNCOMMITTED_RANGE | - PROCESS_HEAP_ENTRY_BUSY | PROCESS_HEAP_ENTRY_MOVEABLE| - PROCESS_HEAP_ENTRY_DDESHARE); - if (rem_flags) - TRACE( "Unknown %08x", rem_flags); - TRACE( "\n"); - if ((entry->wFlags & PROCESS_HEAP_ENTRY_BUSY ) - && (entry->wFlags & PROCESS_HEAP_ENTRY_MOVEABLE)) - { - /* Treat as block */ - TRACE( "BLOCK->hMem\t\t:%p\n", entry->Block.hMem); - } - if (entry->wFlags & PROCESS_HEAP_REGION) - { - TRACE( "Region.dwCommittedSize\t:%08lx\n",entry->Region.dwCommittedSize); - TRACE( "Region.dwUnCommittedSize\t:%08lx\n",entry->Region.dwUnCommittedSize); - TRACE( "Region.lpFirstBlock\t:%p\n",entry->Region.lpFirstBlock); - TRACE( "Region.lpLastBlock\t:%p\n",entry->Region.lpLastBlock); - } -} -#endif - -static PHEAP_USER_DATA HEAP_GetUserData(HEAP *heapPtr, PVOID BaseAddress) -{ - PLIST_ENTRY CurrentEntry; - PHEAP_USER_DATA udata; - - CurrentEntry = heapPtr->UserDataHead.Flink; - while (CurrentEntry != &heapPtr->UserDataHead) - { - udata = CONTAINING_RECORD(CurrentEntry, HEAP_USER_DATA, ListEntry); - if (udata->BaseAddress == BaseAddress) - return udata; - CurrentEntry = CurrentEntry->Flink; - } - return NULL; -} - -static PHEAP_USER_DATA HEAP_AllocUserData(HEAP *heapPtr, PVOID BaseAddress) -{ - /* Allocate user data entry */ - ARENA_INUSE *pInUse; - PHEAP_USER_DATA udata = RtlAllocateHeap(heapPtr, 0, sizeof(HEAP_USER_DATA)); - if (!udata) return NULL; - udata->BaseAddress = BaseAddress; - InsertTailList(&heapPtr->UserDataHead, &udata->ListEntry); - pInUse = (ARENA_INUSE *)BaseAddress - 1; - pInUse->has_user_data = 1; - return udata; -} - -/*********************************************************************** - * HEAP_GetPtr - * RETURNS - * Pointer to the heap - * NULL: Failure - */ -static HEAP *HEAP_GetPtr( - HANDLE heap /* [in] Handle to the heap */ -) { - HEAP *heapPtr = (HEAP *)heap; - if (!heapPtr || (heapPtr->magic != HEAP_MAGIC)) - { - if (heapPtr) - ERR("Invalid heap %p, magic:%.4s!\n", heap, &heapPtr->magic ); + if (Bits & 0xFF) + return RtlpBitsClearLow[Bits & 0xFF]; /* Lowest byte */ else - ERR("Invalid heap %p!\n", heap ); - //KeDumpStackFrames(NULL); - return NULL; - } - if (TRACE_ON(heap) && !HEAP_IsRealArena( heapPtr, 0, NULL, NOISY )) - { - HEAP_Dump( heapPtr ); - assert( FALSE ); - return NULL; - } - return heapPtr; -} - - -/*********************************************************************** - * HEAP_InsertFreeBlock - * - * Insert a free block into the free list. - */ -static __inline void HEAP_InsertFreeBlock( HEAP *heap, ARENA_FREE *pArena, BOOL last ) -{ - FREE_LIST_ENTRY *pEntry = heap->freeList + get_freelist_index( pArena->size + sizeof(*pArena) ); - if (last) - { - /* insert at end of free list, i.e. before the next free list entry */ - pEntry++; - if (pEntry == &heap->freeList[HEAP_NB_FREE_LISTS]) pEntry = heap->freeList; - list_add_before( &pEntry->arena.entry, &pArena->entry ); + return RtlpBitsClearLow[(Bits >> 8) & 0xFF] + 8; /* 2nd byte */ } else { - /* insert at head of free list */ - list_add_after( &pEntry->arena.entry, &pArena->entry ); + if ((Bits >> 16) & 0xFF) + return RtlpBitsClearLow[(Bits >> 16) & 0xFF] + 16; /* 3rd byte */ + else + return RtlpBitsClearLow[(Bits >> 24) & 0xFF] + 24; /* Highest byte */ } - pArena->size |= ARENA_FLAG_FREE; } +/* Maximum size of a tail-filling pattern used for compare operation */ +UCHAR FillPattern[HEAP_ENTRY_SIZE] = +{ + HEAP_TAIL_FILL, + HEAP_TAIL_FILL, + HEAP_TAIL_FILL, + HEAP_TAIL_FILL, + HEAP_TAIL_FILL, + HEAP_TAIL_FILL, + HEAP_TAIL_FILL, + HEAP_TAIL_FILL +}; -/*********************************************************************** - * HEAP_FindSubHeap - * Find the sub-heap containing a given address. - * - * RETURNS - * Pointer: Success - * NULL: Failure - */ -static SUBHEAP *HEAP_FindSubHeap( - const HEAP *heap, /* [in] Heap pointer */ - LPCVOID ptr /* [in] Address */ -) { - const SUBHEAP *sub = &heap->subheap; - while (sub) + +ULONG NTAPI +RtlCompareMemoryUlong(PVOID Source, ULONG Length, ULONG Value); + +/* FUNCTIONS *****************************************************************/ + +VOID NTAPI +RtlpInitializeHeap(PHEAP Heap, + PULONG HeaderSize, + ULONG Flags, + BOOLEAN AllocateLock, + PVOID Lock) +{ + PVOID NextHeapBase = Heap + 1; + PHEAP_UCR_DESCRIPTOR UcrDescriptor; + ULONG NumUCRs = 8; + ULONG i; + NTSTATUS Status; + + /* Add UCRs size */ + *HeaderSize += NumUCRs * sizeof(*UcrDescriptor); + + /* Prepare a list of UCRs */ + InitializeListHead(&Heap->UCRList); + InitializeListHead(&Heap->UCRSegments); + UcrDescriptor = NextHeapBase; + + for (i=0; i= (const char *)sub) && - ((const char *)ptr < (const char *)sub + sub->size)) return (SUBHEAP*)sub; - sub = sub->next; + InsertTailList(&Heap->UCRList, &UcrDescriptor->ListEntry); } + + NextHeapBase = UcrDescriptor; + // TODO: Add tagging + + /* Round up header size again */ + *HeaderSize = ROUND_UP(*HeaderSize, HEAP_ENTRY_SIZE); + + ASSERT(*HeaderSize <= PAGE_SIZE); + + /* Initialize heap's header */ + Heap->Entry.Size = (*HeaderSize) >> HEAP_ENTRY_SHIFT; + Heap->Entry.Flags = HEAP_ENTRY_BUSY; + + Heap->Signature = HEAP_SIGNATURE; + Heap->Flags = Flags; + Heap->ForceFlags = (Flags & (HEAP_NO_SERIALIZE | + HEAP_GENERATE_EXCEPTIONS | + HEAP_ZERO_MEMORY | + HEAP_REALLOC_IN_PLACE_ONLY | + HEAP_VALIDATE_PARAMETERS_ENABLED | + HEAP_VALIDATE_ALL_ENABLED | + HEAP_TAIL_CHECKING_ENABLED | + HEAP_CREATE_ALIGN_16 | + HEAP_FREE_CHECKING_ENABLED)); + Heap->HeaderValidateCopy = NULL; + Heap->HeaderValidateLength = ((PCHAR)NextHeapBase - (PCHAR)Heap); + + /* Initialize free lists */ + for (i=0; iFreeLists[i]); + } + + /* Initialize "big" allocations list */ + InitializeListHead(&Heap->VirtualAllocdBlocks); + + /* Initialize lock */ + if (AllocateLock) + { + Lock = NextHeapBase; + Status = RtlInitializeHeapLock((PHEAP_LOCK)Lock); + if (!NT_SUCCESS(Status)) + { + DPRINT1("Initializing the lock failed!\n"); + return /*NULL*/; // FIXME! + } + } + + /* Set the lock variable */ + Heap->LockVariable = Lock; +} + +VOID FORCEINLINE +RtlpSetFreeListsBit(PHEAP Heap, + PHEAP_FREE_ENTRY FreeEntry) +{ + ULONG Index, Bit; + + ASSERT(FreeEntry->Size < HEAP_FREELISTS); + + /* Calculate offset in the free list bitmap */ + Index = FreeEntry->Size >> 3; /* = FreeEntry->Size / (sizeof(UCHAR) * 8)*/ + Bit = 1 << (FreeEntry->Size & 7); + + /* Assure it's not already set */ + ASSERT((Heap->u.FreeListsInUseBytes[Index] & Bit) == 0); + + /* Set it */ + Heap->u.FreeListsInUseBytes[Index] |= Bit; +} + +VOID FORCEINLINE +RtlpClearFreeListsBit(PHEAP Heap, + PHEAP_FREE_ENTRY FreeEntry) +{ + ULONG Index, Bit; + + ASSERT(FreeEntry->Size < HEAP_FREELISTS); + + /* Calculate offset in the free list bitmap */ + Index = FreeEntry->Size >> 3; /* = FreeEntry->Size / (sizeof(UCHAR) * 8)*/ + Bit = 1 << (FreeEntry->Size & 7); + + /* Assure it was set and the corresponding free list is empty */ + ASSERT(Heap->u.FreeListsInUseBytes[Index] & Bit); + ASSERT(IsListEmpty(&Heap->FreeLists[FreeEntry->Size])); + + /* Clear it */ + Heap->u.FreeListsInUseBytes[Index] ^= Bit; +} + +VOID NTAPI +RtlpInsertFreeBlockHelper(PHEAP Heap, + PHEAP_FREE_ENTRY FreeEntry, + SIZE_T BlockSize, + BOOLEAN NoFill) +{ + PLIST_ENTRY FreeListHead, Current; + PHEAP_FREE_ENTRY CurrentEntry; + + ASSERT(FreeEntry->Size == BlockSize); + + /* Fill if it's not denied */ + if (!NoFill) + { + FreeEntry->Flags &= ~(HEAP_ENTRY_FILL_PATTERN | + HEAP_ENTRY_EXTRA_PRESENT | + HEAP_ENTRY_BUSY); + + if (Heap->Flags & HEAP_FREE_CHECKING_ENABLED) + { + RtlFillMemoryUlong((PCHAR)(FreeEntry + 1), + (BlockSize << HEAP_ENTRY_SHIFT) - sizeof(*FreeEntry), + ARENA_FREE_FILLER); + + FreeEntry->Flags |= HEAP_ENTRY_FILL_PATTERN; + } + } + else + { + /* Clear out all flags except the last entry one */ + FreeEntry->Flags &= HEAP_ENTRY_LAST_ENTRY; + } + + /* Check if PreviousSize of the next entry matches ours */ + if (!(FreeEntry->Flags & HEAP_ENTRY_LAST_ENTRY)) + { + ASSERT(((PHEAP_ENTRY)FreeEntry + BlockSize)->PreviousSize = BlockSize); + } + + /* Insert it either into dedicated or non-dedicated list */ + if (BlockSize < HEAP_FREELISTS) + { + /* Dedicated list */ + FreeListHead = &Heap->FreeLists[BlockSize]; + + if (IsListEmpty(FreeListHead)) + { + RtlpSetFreeListsBit(Heap, FreeEntry); + } + } + else + { + /* Non-dedicated one */ + FreeListHead = &Heap->FreeLists[0]; + Current = FreeListHead->Flink; + + /* Find a position where to insert it to (the list must be sorted) */ + while (FreeListHead != Current) + { + CurrentEntry = CONTAINING_RECORD(Current, HEAP_FREE_ENTRY, FreeList); + + if (BlockSize <= CurrentEntry->Size) + break; + + Current = Current->Flink; + } + + FreeListHead = Current; + } + + /* Actually insert it into the list */ + InsertTailList(FreeListHead, &FreeEntry->FreeList); +} + +VOID NTAPI +RtlpInsertFreeBlock(PHEAP Heap, + PHEAP_FREE_ENTRY FreeEntry, + SIZE_T BlockSize) +{ + USHORT Size, PreviousSize; + UCHAR SegmentOffset, Flags; + PHEAP_SEGMENT Segment; + + DPRINT("RtlpInsertFreeBlock(%p %p %x)\n", Heap, FreeEntry, BlockSize); + + /* Increase the free size counter */ + Heap->TotalFreeSize += BlockSize; + + /* Remember certain values */ + Flags = FreeEntry->Flags; + PreviousSize = FreeEntry->PreviousSize; + SegmentOffset = FreeEntry->SegmentOffset; + Segment = Heap->Segments[SegmentOffset]; + + /* Process it */ + while (BlockSize) + { + /* Check for the max size */ + if (BlockSize > HEAP_MAX_BLOCK_SIZE) + { + Size = HEAP_MAX_BLOCK_SIZE; + + /* Special compensation if it goes above limit just by 1 */ + if (BlockSize == (HEAP_MAX_BLOCK_SIZE + 1)) + Size -= 16; + + FreeEntry->Flags = 0; + } + else + { + Size = BlockSize; + FreeEntry->Flags = Flags; + } + + /* Change its size and insert it into a free list */ + FreeEntry->Size = Size; + FreeEntry->PreviousSize = PreviousSize; + FreeEntry->SegmentOffset = SegmentOffset; + + /* Call a helper to actually insert the block */ + RtlpInsertFreeBlockHelper(Heap, FreeEntry, Size, FALSE); + + /* Update sizes */ + PreviousSize = Size; + BlockSize -= Size; + + /* Go to the next entry */ + FreeEntry = (PHEAP_FREE_ENTRY)((PHEAP_ENTRY)FreeEntry + Size); + + /* Check if that's all */ + if ((PHEAP_ENTRY)FreeEntry >= Segment->LastValidEntry) return; + } + + /* Update previous size if needed */ + if (!(Flags & HEAP_ENTRY_LAST_ENTRY)) + FreeEntry->PreviousSize = PreviousSize; +} + +VOID NTAPI +RtlpRemoveFreeBlock(PHEAP Heap, + PHEAP_FREE_ENTRY FreeEntry, + BOOLEAN Dedicated, + BOOLEAN NoFill) +{ + SIZE_T Result, RealSize; + PLIST_ENTRY OldBlink, OldFlink; + + // FIXME: Maybe use RemoveEntryList? + + /* Remove the free block */ + OldFlink = FreeEntry->FreeList.Flink; + OldBlink = FreeEntry->FreeList.Blink; + OldBlink->Flink = OldFlink; + OldFlink->Blink = OldBlink; + + /* Update the freelists bitmap */ + if ((OldFlink == OldBlink) && + (Dedicated || (!Dedicated && FreeEntry->Size < HEAP_FREELISTS))) + { + RtlpClearFreeListsBit(Heap, FreeEntry); + } + + /* Fill with pattern if necessary */ + if (!NoFill && + (FreeEntry->Flags & HEAP_ENTRY_FILL_PATTERN)) + { + RealSize = (FreeEntry->Size << HEAP_ENTRY_SHIFT) - sizeof(*FreeEntry); + + /* Deduct extra stuff from block's real size */ + if (FreeEntry->Flags & HEAP_ENTRY_EXTRA_PRESENT && + RealSize > sizeof(HEAP_FREE_ENTRY_EXTRA)) + { + RealSize -= sizeof(HEAP_FREE_ENTRY_EXTRA); + } + + /* Check if the free filler is intact */ + Result = RtlCompareMemoryUlong((PCHAR)(FreeEntry + 1), + RealSize, + ARENA_FREE_FILLER); + + if (Result != RealSize) + { + DPRINT1("Free heap block %p modified at %p after it was freed\n", + FreeEntry, + (PCHAR)(FreeEntry + 1) + Result); + } + } +} + +SIZE_T NTAPI +RtlpGetSizeOfBigBlock(PHEAP_ENTRY HeapEntry) +{ + PHEAP_VIRTUAL_ALLOC_ENTRY VirtualEntry; + + /* Get pointer to the containing record */ + VirtualEntry = CONTAINING_RECORD(HeapEntry, HEAP_VIRTUAL_ALLOC_ENTRY, BusyBlock); + + /* Restore the real size */ + return VirtualEntry->CommitSize - HeapEntry->Size; +} + +PHEAP_UCR_DESCRIPTOR NTAPI +RtlpCreateUnCommittedRange(PHEAP_SEGMENT Segment) +{ + PLIST_ENTRY Entry; + PHEAP_UCR_DESCRIPTOR UcrDescriptor; + PHEAP_UCR_SEGMENT UcrSegment; + PHEAP Heap = Segment->Heap; + SIZE_T ReserveSize = 16 * PAGE_SIZE; + SIZE_T CommitSize = 1 * PAGE_SIZE; + NTSTATUS Status; + + DPRINT("RtlpCreateUnCommittedRange(%p)\n", Segment); + + /* Check if we have unused UCRs */ + if (IsListEmpty(&Heap->UCRList)) + { + /* Get a pointer to the first UCR segment */ + UcrSegment = CONTAINING_RECORD(&Heap->UCRSegments.Flink, HEAP_UCR_SEGMENT, ListEntry); + + /* Check the list of UCR segments */ + if (IsListEmpty(&Heap->UCRSegments) || + UcrSegment->ReservedSize == UcrSegment->CommittedSize) + { + /* We need to create a new one. Reserve 16 pages for it */ + UcrSegment = NULL; + Status = ZwAllocateVirtualMemory(NtCurrentProcess(), + (PVOID *)&UcrSegment, + 0, + &ReserveSize, + MEM_RESERVE, + PAGE_READWRITE); + + if (!NT_SUCCESS(Status)) return NULL; + + /* Commit one page */ + Status = ZwAllocateVirtualMemory(NtCurrentProcess(), + (PVOID *)&UcrSegment, + 0, + &CommitSize, + MEM_COMMIT, + PAGE_READWRITE); + + if (!NT_SUCCESS(Status)) + { + /* Release reserved memory */ + ZwFreeVirtualMemory(NtCurrentProcess(), + (PVOID *)&UcrDescriptor, + &ReserveSize, + MEM_RELEASE); + return NULL; + } + + /* Set it's data */ + UcrSegment->ReservedSize = ReserveSize; + UcrSegment->CommittedSize = CommitSize; + + /* Add it to the head of the list */ + InsertHeadList(&Heap->UCRSegments, &UcrSegment->ListEntry); + + /* Get a pointer to the first available UCR descriptor */ + UcrDescriptor = (PHEAP_UCR_DESCRIPTOR)(UcrSegment + 1); + } + else + { + /* It's possible to use existing UCR segment. Commit one more page */ + UcrDescriptor = (PHEAP_UCR_DESCRIPTOR)((PCHAR)UcrSegment + UcrSegment->CommittedSize); + Status = ZwAllocateVirtualMemory(NtCurrentProcess(), + (PVOID *)&UcrDescriptor, + 0, + &CommitSize, + MEM_COMMIT, + PAGE_READWRITE); + + if (!NT_SUCCESS(Status)) return NULL; + + /* Update sizes */ + UcrSegment->CommittedSize += CommitSize; + } + + /* There is a whole bunch of new UCR descriptors. Put them into the unused list */ + while ((PCHAR)UcrDescriptor < ((PCHAR)UcrSegment + UcrSegment->CommittedSize)) + { + InsertTailList(&Heap->UCRList, &UcrDescriptor->ListEntry); + UcrDescriptor++; + } + } + + /* There are unused UCRs, just get the first one */ + Entry = RemoveHeadList(&Heap->UCRList); + UcrDescriptor = CONTAINING_RECORD(Entry, HEAP_UCR_DESCRIPTOR, ListEntry); + return UcrDescriptor; +} + +VOID NTAPI +RtlpDestroyUnCommittedRange(PHEAP_SEGMENT Segment, + PHEAP_UCR_DESCRIPTOR UcrDescriptor) +{ + /* Zero it out */ + UcrDescriptor->Address = NULL; + UcrDescriptor->Size = 0; + + /* Put it into the heap's list of unused UCRs */ + InsertHeadList(&Segment->Heap->UCRList, &UcrDescriptor->ListEntry); +} + +VOID NTAPI +RtlpInsertUnCommittedPages(PHEAP_SEGMENT Segment, + ULONG_PTR Address, + SIZE_T Size) +{ + PLIST_ENTRY Current; + PHEAP_UCR_DESCRIPTOR UcrDescriptor; + + DPRINT("RtlpInsertUnCommittedPages(%p %p %x)\n", Segment, Address, Size); + + /* Go through the list of UCR descriptors, they are sorted from lowest address + to the highest */ + Current = Segment->UCRSegmentList.Flink; + while(Current != &Segment->UCRSegmentList) + { + UcrDescriptor = CONTAINING_RECORD(Current, HEAP_UCR_DESCRIPTOR, SegmentEntry); + + if ((ULONG_PTR)UcrDescriptor->Address > Address) + { + /* Check for a really lucky case */ + if ((Address + Size) == (ULONG_PTR)UcrDescriptor->Address) + { + /* Exact match */ + UcrDescriptor->Address = (PVOID)Address; + UcrDescriptor->Size += Size; + return; + } + + /* We found the block after which the new one should go */ + break; + } + else if (((ULONG_PTR)UcrDescriptor->Address + UcrDescriptor->Size) == Address) + { + /* Modify this entry */ + Address = (ULONG_PTR)UcrDescriptor->Address; + Size += UcrDescriptor->Size; + + /* Remove it from the list and destroy it */ + RemoveEntryList(Current); + RtlpDestroyUnCommittedRange(Segment, UcrDescriptor); + + Segment->NumberOfUnCommittedRanges--; + } + else + { + /* Advance to the next descriptor */ + Current = Current->Flink; + } + } + + /* Create a new UCR descriptor */ + UcrDescriptor = RtlpCreateUnCommittedRange(Segment); + if (!UcrDescriptor) return; + + UcrDescriptor->Address = (PVOID)Address; + UcrDescriptor->Size = Size; + + /* "Current" is the descriptor after which our one should go */ + InsertTailList(Current, &UcrDescriptor->SegmentEntry); + + DPRINT("Added segment UCR with base %p, size 0x%x\n", Address, Size); + + /* Increase counters */ + Segment->NumberOfUnCommittedRanges++; +} + +PHEAP_FREE_ENTRY NTAPI +RtlpFindAndCommitPages(PHEAP Heap, + PHEAP_SEGMENT Segment, + PSIZE_T Size, + PVOID AddressRequested) +{ + PLIST_ENTRY Current; + ULONG_PTR Address = 0; + PHEAP_UCR_DESCRIPTOR UcrDescriptor, PreviousUcr = NULL; + PHEAP_ENTRY FirstEntry, LastEntry, PreviousLastEntry; + NTSTATUS Status; + + DPRINT("RtlpFindAndCommitPages(%p %p %x %p)\n", Heap, Segment, *Size, Address); + + /* Go through UCRs in a segment */ + Current = Segment->UCRSegmentList.Flink; + while(Current != &Segment->UCRSegmentList) + { + UcrDescriptor = CONTAINING_RECORD(Current, HEAP_UCR_DESCRIPTOR, SegmentEntry); + + /* Check if we can use that one right away */ + if (UcrDescriptor->Size >= *Size && + (UcrDescriptor->Address == AddressRequested || !AddressRequested)) + { + /* Get the address */ + Address = (ULONG_PTR)UcrDescriptor->Address; + + /* Commit it */ + if (Heap->CommitRoutine) + { + Status = Heap->CommitRoutine(Heap, (PVOID *)&Address, Size); + } + else + { + Status = ZwAllocateVirtualMemory(NtCurrentProcess(), + (PVOID *)&Address, + 0, + Size, + MEM_COMMIT, + PAGE_READWRITE); + } + + DPRINT("Committed %d bytes at base %p, UCR size is %d\n", *Size, Address, UcrDescriptor->Size); + + /* Fail in unsuccessful case */ + if (!NT_SUCCESS(Status)) + { + DPRINT1("Committing page failed with status 0x%08X\n", Status); + return NULL; + } + + /* Update tracking numbers */ + Segment->NumberOfUnCommittedPages -= *Size / PAGE_SIZE; + + /* Calculate first and last entries */ + FirstEntry = (PHEAP_ENTRY)Address; + + if ((Segment->LastEntryInSegment->Flags & HEAP_ENTRY_LAST_ENTRY) && + (ULONG_PTR)(Segment->LastEntryInSegment + Segment->LastEntryInSegment->Size) == (ULONG_PTR)UcrDescriptor->Address) + { + LastEntry = Segment->LastEntryInSegment; + } + else + { + /* Go through the entries to find the last one */ + + if (PreviousUcr) + LastEntry = (PHEAP_ENTRY)((ULONG_PTR)PreviousUcr->Address + PreviousUcr->Size); + else + LastEntry = Segment->FirstEntry; + + while (!(LastEntry->Flags & HEAP_ENTRY_LAST_ENTRY)) + { + PreviousLastEntry = LastEntry; + LastEntry += LastEntry->Size; + + if ((ULONG_PTR)LastEntry >= (ULONG_PTR)Segment->LastValidEntry || + LastEntry->Size == 0) + { + if (LastEntry == (PHEAP_ENTRY)Address) + { + /* Found it */ + LastEntry = PreviousLastEntry; + break; + } + + DPRINT1("Last entry not found in a committed range near to %p\n", PreviousLastEntry); + return NULL; + } + } + } + + /* Unmark it as a last entry */ + LastEntry->Flags &= ~HEAP_ENTRY_LAST_ENTRY; + + /* Update UCR descriptor */ + UcrDescriptor->Address = (PVOID)((ULONG_PTR)UcrDescriptor->Address + *Size); + UcrDescriptor->Size -= *Size; + + DPRINT("Updating UcrDescriptor %p, new Address %p, size %d\n", + UcrDescriptor, UcrDescriptor->Address, UcrDescriptor->Size); + + /* Check if anything left in this UCR */ + if (UcrDescriptor->Size == 0) + { + /* It's fully exhausted */ + if (UcrDescriptor->Address == Segment->LastValidEntry) + { + FirstEntry->Flags = HEAP_ENTRY_LAST_ENTRY; + Segment->LastEntryInSegment = FirstEntry; + } + else + { + FirstEntry->Flags = 0; + Segment->LastEntryInSegment = Segment->FirstEntry; + } + + /* This UCR needs to be removed because it became useless */ + RemoveEntryList(&UcrDescriptor->SegmentEntry); + + RtlpDestroyUnCommittedRange(Segment, UcrDescriptor); + Segment->NumberOfUnCommittedRanges--; + } + else + { + FirstEntry->Flags = HEAP_ENTRY_LAST_ENTRY; + Segment->LastEntryInSegment = FirstEntry; + } + + /* Set various first entry fields*/ + FirstEntry->SegmentOffset = LastEntry->SegmentOffset; + FirstEntry->Size = *Size >> HEAP_ENTRY_SHIFT; + FirstEntry->PreviousSize = LastEntry->Size; + + /* Update previous size */ + if (!(FirstEntry->Flags & HEAP_ENTRY_LAST_ENTRY)) + (FirstEntry + FirstEntry->Size)->PreviousSize = FirstEntry->Size; + + /* We're done */ + return (PHEAP_FREE_ENTRY)FirstEntry; + } + + /* Advance to the next descriptor */ + PreviousUcr = UcrDescriptor; + Current = Current->Flink; + } + + return NULL; +} + +VOID NTAPI +RtlpDeCommitFreeBlock(PHEAP Heap, + PHEAP_FREE_ENTRY FreeEntry, + SIZE_T Size) +{ + PHEAP_SEGMENT Segment; + PHEAP_ENTRY PrecedingInUseEntry = NULL, NextInUseEntry = NULL; + PHEAP_FREE_ENTRY NextFreeEntry; + PHEAP_UCR_DESCRIPTOR UcrDescriptor; + ULONG PrecedingSize, NextSize, DecommitSize; + ULONG_PTR DecommitBase; + NTSTATUS Status; + + DPRINT("Decommitting %p %p %x\n", Heap, FreeEntry, Size); + + /* We can't decommit if there is a commit routine! */ + if (Heap->CommitRoutine) + { + /* Just add it back the usual way */ + RtlpInsertFreeBlock(Heap, FreeEntry, Size); + return; + } + + /* Get the segment */ + Segment = Heap->Segments[FreeEntry->SegmentOffset]; + + /* Get the preceding entry */ + DecommitBase = ROUND_UP(FreeEntry, PAGE_SIZE); + PrecedingSize = (PHEAP_ENTRY)DecommitBase - (PHEAP_ENTRY)FreeEntry; + + if (PrecedingSize == 1) + { + /* Just 1 heap entry, increase the base/size */ + DecommitBase += PAGE_SIZE; + PrecedingSize += PAGE_SIZE >> HEAP_ENTRY_SHIFT; + } + else if (FreeEntry->PreviousSize && + (DecommitBase == (ULONG_PTR)FreeEntry)) + { + PrecedingInUseEntry = (PHEAP_ENTRY)FreeEntry - FreeEntry->PreviousSize; + } + + /* Get the next entry */ + NextFreeEntry = (PHEAP_FREE_ENTRY)((PHEAP_ENTRY)FreeEntry + Size); + DecommitSize = ROUND_DOWN(NextFreeEntry, PAGE_SIZE); + NextSize = (PHEAP_ENTRY)NextFreeEntry - (PHEAP_ENTRY)DecommitSize; + + if (NextSize == 1) + { + /* Just 1 heap entry, increase the size */ + DecommitSize -= PAGE_SIZE; + NextSize += PAGE_SIZE >> HEAP_ENTRY_SHIFT; + } + else if (NextSize == 0 && + !(FreeEntry->Flags & HEAP_ENTRY_LAST_ENTRY)) + { + NextInUseEntry = (PHEAP_ENTRY)NextFreeEntry; + } + + NextFreeEntry = (PHEAP_FREE_ENTRY)((PHEAP_ENTRY)NextFreeEntry - NextSize); + + /* Calculate real decommit size */ + if (DecommitSize > DecommitBase) + { + DecommitSize -= DecommitBase; + } + else + { + /* Nothing to decommit */ + RtlpInsertFreeBlock(Heap, FreeEntry, Size); + return; + } + + /* A decommit is necessary. Create a UCR descriptor */ + UcrDescriptor = RtlpCreateUnCommittedRange(Segment); + if (!UcrDescriptor) + { + DPRINT1("HEAP: Failed to create UCR descriptor\n"); + RtlpInsertFreeBlock(Heap, FreeEntry, PrecedingSize); + return; + } + + /* Decommit the memory */ + Status = ZwFreeVirtualMemory(NtCurrentProcess(), + (PVOID *)&DecommitBase, + &DecommitSize, + MEM_DECOMMIT); + + /* Delete that UCR. This is needed to assure there is an unused UCR entry in the list */ + RtlpDestroyUnCommittedRange(Segment, UcrDescriptor); + + if (!NT_SUCCESS(Status)) + { + RtlpInsertFreeBlock(Heap, FreeEntry, Size); + return; + } + + /* Insert uncommitted pages */ + RtlpInsertUnCommittedPages(Segment, DecommitBase, DecommitSize); + Segment->NumberOfUnCommittedPages += (DecommitSize / PAGE_SIZE); + + if (PrecedingSize) + { + /* Adjust size of this free entry and insert it */ + FreeEntry->Flags = HEAP_ENTRY_LAST_ENTRY; + FreeEntry->Size = PrecedingSize; + Heap->TotalFreeSize += PrecedingSize; + + /* Set last entry in the segment to this entry */ + Segment->LastEntryInSegment = (PHEAP_ENTRY)FreeEntry; + + /* Insert it into the free list */ + RtlpInsertFreeBlockHelper(Heap, FreeEntry, PrecedingSize, FALSE); + } + else if (PrecedingInUseEntry) + { + /* Adjust preceding in use entry */ + PrecedingInUseEntry->Flags |= HEAP_ENTRY_LAST_ENTRY; + Segment->LastEntryInSegment = PrecedingInUseEntry; + } else if ((ULONG_PTR)Segment->LastEntryInSegment >= DecommitBase && + ((PCHAR)Segment->LastEntryInSegment < ((PCHAR)DecommitBase + DecommitSize))) + { + /* Update this segment's last entry */ + Segment->LastEntryInSegment = Segment->FirstEntry; + } + + /* Now the next one */ + if (NextSize) + { + /* Adjust size of this free entry and insert it */ + NextFreeEntry->Flags = 0; + NextFreeEntry->PreviousSize = 0; + NextFreeEntry->SegmentOffset = Segment->Entry.SegmentOffset; + NextFreeEntry->Size = NextSize; + + ((PHEAP_FREE_ENTRY)((PHEAP_ENTRY)NextFreeEntry + NextSize))->PreviousSize = NextSize; + + Heap->TotalFreeSize += NextSize; + RtlpInsertFreeBlockHelper(Heap, NextFreeEntry, NextSize, FALSE); + } + else if (NextInUseEntry) + { + NextInUseEntry->PreviousSize = 0; + } +} + +BOOLEAN NTAPI +RtlpInitializeHeapSegment(PHEAP Heap, + PHEAP_SEGMENT Segment, + UCHAR SegmentIndex, + ULONG Flags, + PVOID BaseAddress, + PVOID UncommittedBase, + PVOID LimitAddress) +{ + ULONG Pages, CommitSize; + PHEAP_ENTRY HeapEntry; + USHORT PreviousSize = 0, NewSize; + NTSTATUS Status; + + Pages = ((PCHAR)LimitAddress - (PCHAR)BaseAddress) / PAGE_SIZE; + + HeapEntry = (PHEAP_ENTRY)ROUND_UP(Segment + 1, HEAP_ENTRY_SIZE); + + DPRINT("RtlpInitializeHeapSegment(%p %p %x %x %p %p %p)\n", Heap, Segment, SegmentIndex, Flags, BaseAddress, UncommittedBase, LimitAddress); + DPRINT("Pages %x, HeapEntry %p, sizeof(HEAP_SEGMENT) %x\n", Pages, HeapEntry, sizeof(HEAP_SEGMENT)); + + /* Check if it's the first segment and remember its size */ + if (Heap == BaseAddress) + PreviousSize = Heap->Entry.Size; + + NewSize = ((PCHAR)HeapEntry - (PCHAR)Segment) >> HEAP_ENTRY_SHIFT; + + if ((PVOID)(HeapEntry + 1) >= UncommittedBase) + { + /* Check if it goes beyond the limit */ + if ((PVOID)(HeapEntry + 1) >= LimitAddress) + return FALSE; + + /* Need to commit memory */ + CommitSize = (PCHAR)(HeapEntry + 1) - (PCHAR)UncommittedBase; + Status = ZwAllocateVirtualMemory(NtCurrentProcess(), + (PVOID)&UncommittedBase, + 0, + &CommitSize, + MEM_COMMIT, + PAGE_READWRITE); + if (!NT_SUCCESS(Status)) + { + DPRINT1("Committing page failed with status 0x%08X\n", Status); + return FALSE; + } + + DPRINT("Committed %d bytes at base %p\n", CommitSize, UncommittedBase); + + /* Calcule the new uncommitted base */ + UncommittedBase = (PVOID)((PCHAR)UncommittedBase + CommitSize); + } + + /* Initialize the segment entry */ + Segment->Entry.PreviousSize = PreviousSize; + Segment->Entry.Size = NewSize; + Segment->Entry.Flags = HEAP_ENTRY_BUSY; + Segment->Entry.SegmentOffset = SegmentIndex; + + /* Initialize the segment itself */ + Segment->SegmentSignature = HEAP_SEGMENT_SIGNATURE; + Segment->Heap = Heap; + Segment->BaseAddress = BaseAddress; + Segment->FirstEntry = HeapEntry; + Segment->LastValidEntry = (PHEAP_ENTRY)((PCHAR)BaseAddress + Pages * PAGE_SIZE); + Segment->NumberOfPages = Pages; + Segment->NumberOfUnCommittedPages = ((PCHAR)LimitAddress - (PCHAR)UncommittedBase) / PAGE_SIZE; + InitializeListHead(&Segment->UCRSegmentList); + + /* Insert uncommitted pages into UCR (uncommitted ranges) list */ + if (Segment->NumberOfUnCommittedPages) + { + RtlpInsertUnCommittedPages(Segment, (ULONG_PTR)UncommittedBase, Segment->NumberOfUnCommittedPages * PAGE_SIZE); + } + + /* Set the segment index pointer */ + Heap->Segments[SegmentIndex] = Segment; + + /* Prepare a free heap entry */ + HeapEntry->Flags = HEAP_ENTRY_LAST_ENTRY; + HeapEntry->PreviousSize = Segment->Entry.Size; + HeapEntry->SegmentOffset = SegmentIndex; + + /* Set last entry in segment */ + Segment->LastEntryInSegment = HeapEntry; + + /* Insert it */ + RtlpInsertFreeBlock(Heap, (PHEAP_FREE_ENTRY)HeapEntry, (PHEAP_ENTRY)UncommittedBase - HeapEntry); + + return TRUE; +} + +VOID NTAPI +RtlpDestroyHeapSegment(PHEAP_SEGMENT Segment) +{ + NTSTATUS Status; + PVOID BaseAddress; + SIZE_T Size = 0; + + /* Make sure it's not user allocated */ + if (Segment->SegmentFlags & HEAP_USER_ALLOCATED) return; + + BaseAddress = Segment->BaseAddress; + DPRINT("Destroying segment %p, BA %p\n", Segment, BaseAddress); + + /* Release virtual memory */ + Status = ZwFreeVirtualMemory(NtCurrentProcess(), + &BaseAddress, + &Size, + MEM_RELEASE); + + if (!NT_SUCCESS(Status)) + { + DPRINT1("HEAP: Failed to release segment's memory with status 0x%08X\n", Status); + } +} + +/* Usermode only! */ +VOID NTAPI +RtlpAddHeapToProcessList(PHEAP Heap) +{ + PPEB Peb; + + /* Get PEB */ + Peb = RtlGetCurrentPeb(); + + /* Acquire the lock */ + RtlEnterHeapLock(&RtlpProcessHeapsListLock); + + //_SEH2_TRY { + /* Check if max number of heaps reached */ + if (Peb->NumberOfHeaps == Peb->MaximumNumberOfHeaps) + { + // TODO: Handle this case + ASSERT(FALSE); + } + + /* Add the heap to the process heaps */ + Peb->ProcessHeaps[Peb->NumberOfHeaps] = Heap; + Peb->NumberOfHeaps++; + Heap->ProcessHeapsListIndex = Peb->NumberOfHeaps; + // } _SEH2_FINALLY { + + /* Release the lock */ + RtlLeaveHeapLock(&RtlpProcessHeapsListLock); + + // } _SEH2_END +} + +/* Usermode only! */ +VOID NTAPI +RtlpRemoveHeapFromProcessList(PHEAP Heap) +{ + PPEB Peb; + PHEAP *Current, *Next; + ULONG Count; + + /* Get PEB */ + Peb = RtlGetCurrentPeb(); + + /* Acquire the lock */ + RtlEnterHeapLock(&RtlpProcessHeapsListLock); + + /* Check if we don't need anything to do */ + if ((Heap->ProcessHeapsListIndex == 0) || + (Heap->ProcessHeapsListIndex > Peb->NumberOfHeaps) || + (Peb->NumberOfHeaps == 0)) + { + /* Release the lock */ + RtlLeaveHeapLock(&RtlpProcessHeapsListLock); + + return; + } + + /* The process actually has more than one heap. + Use classic, lernt from university times algorithm for removing an entry + from a static array */ + + Current = (PHEAP *)&Peb->ProcessHeaps[Heap->ProcessHeapsListIndex - 1]; + Next = Current + 1; + + /* How many items we need to shift to the left */ + Count = Peb->NumberOfHeaps - (Heap->ProcessHeapsListIndex - 1); + + /* Move them all in a loop */ + while (--Count) + { + /* Copy it and advance next pointer */ + *Current = *Next; + + /* Update its index */ + (*Current)->ProcessHeapsListIndex -= 1; + + /* Advance pointers */ + Current++; + Next++; + } + + /* Decrease total number of heaps */ + Peb->NumberOfHeaps--; + + /* Zero last unused item */ + Peb->ProcessHeaps[Peb->NumberOfHeaps] = NULL; + Heap->ProcessHeapsListIndex = 0; + + /* Release the lock */ + RtlLeaveHeapLock(&RtlpProcessHeapsListLock); +} + +PHEAP_FREE_ENTRY NTAPI +RtlpCoalesceHeap(PHEAP Heap) +{ + UNIMPLEMENTED; + return NULL; +} + +PHEAP_FREE_ENTRY NTAPI +RtlpCoalesceFreeBlocks (PHEAP Heap, + PHEAP_FREE_ENTRY FreeEntry, + PSIZE_T FreeSize, + BOOLEAN Remove) +{ + PHEAP_FREE_ENTRY CurrentEntry, NextEntry; + + /* Get the previous entry */ + CurrentEntry = (PHEAP_FREE_ENTRY)((PHEAP_ENTRY)FreeEntry - FreeEntry->PreviousSize); + + /* Check it */ + if (CurrentEntry != FreeEntry && + !(CurrentEntry->Flags & HEAP_ENTRY_BUSY) && + (*FreeSize + CurrentEntry->Size) <= HEAP_MAX_BLOCK_SIZE) + { + ASSERT(FreeEntry->PreviousSize == CurrentEntry->Size); + + /* Remove it if asked for */ + if (Remove) + { + RtlpRemoveFreeBlock(Heap, FreeEntry, FALSE, FALSE); + Heap->TotalFreeSize -= FreeEntry->Size; + + /* Remove it only once! */ + Remove = FALSE; + } + + /* Remove previous entry too */ + RtlpRemoveFreeBlock(Heap, CurrentEntry, FALSE, FALSE); + + /* Copy flags */ + CurrentEntry->Flags = FreeEntry->Flags & HEAP_ENTRY_LAST_ENTRY; + + /* Update last entry in the segment */ + if (CurrentEntry->Flags & HEAP_ENTRY_LAST_ENTRY) + Heap->Segments[CurrentEntry->SegmentOffset]->LastEntryInSegment = (PHEAP_ENTRY)CurrentEntry; + + /* Advance FreeEntry and update sizes */ + FreeEntry = CurrentEntry; + *FreeSize = *FreeSize + CurrentEntry->Size; + Heap->TotalFreeSize -= CurrentEntry->Size; + FreeEntry->Size = *FreeSize; + + /* Also update previous size if needed */ + if (!(FreeEntry->Flags & HEAP_ENTRY_LAST_ENTRY)) + { + ((PHEAP_ENTRY)FreeEntry + *FreeSize)->PreviousSize = *FreeSize; + } + } + + /* Check the next block if it exists */ + if (!(FreeEntry->Flags & HEAP_ENTRY_LAST_ENTRY)) + { + NextEntry = (PHEAP_FREE_ENTRY)((PHEAP_ENTRY)FreeEntry + *FreeSize); + + if (!(NextEntry->Flags & HEAP_ENTRY_BUSY) && + NextEntry->Size + *FreeSize <= HEAP_MAX_BLOCK_SIZE) + { + ASSERT(*FreeSize == NextEntry->PreviousSize); + + /* Remove it if asked for */ + if (Remove) + { + RtlpRemoveFreeBlock(Heap, FreeEntry, FALSE, FALSE); + Heap->TotalFreeSize -= FreeEntry->Size; + } + + /* Copy flags */ + FreeEntry->Flags = NextEntry->Flags & HEAP_ENTRY_LAST_ENTRY; + + /* Update last entry in the segment */ + if (FreeEntry->Flags & HEAP_ENTRY_LAST_ENTRY) + Heap->Segments[FreeEntry->SegmentOffset]->LastEntryInSegment = (PHEAP_ENTRY)FreeEntry; + + /* Remove next entry now */ + RtlpRemoveFreeBlock(Heap, NextEntry, FALSE, FALSE); + + /* Update sizes */ + *FreeSize = *FreeSize + NextEntry->Size; + Heap->TotalFreeSize -= NextEntry->Size; + FreeEntry->Size = *FreeSize; + + /* Also update previous size if needed */ + if (!(FreeEntry->Flags & HEAP_ENTRY_LAST_ENTRY)) + { + ((PHEAP_ENTRY)FreeEntry + *FreeSize)->PreviousSize = *FreeSize; + } + } + } + return FreeEntry; +} + +PHEAP_FREE_ENTRY NTAPI +RtlpExtendHeap(PHEAP Heap, + SIZE_T Size) +{ + ULONG Pages; + UCHAR Index, EmptyIndex; + SIZE_T FreeSize, CommitSize, ReserveSize; + PHEAP_SEGMENT Segment; + PHEAP_FREE_ENTRY FreeEntry; + NTSTATUS Status; + + DPRINT("RtlpExtendHeap(%p %x)\n", Heap, Size); + + /* Calculate amount in pages */ + Pages = (Size + PAGE_SIZE - 1) / PAGE_SIZE; + FreeSize = Pages * PAGE_SIZE; + DPRINT("Pages %x, FreeSize %x. Going through segments...\n", Pages, FreeSize); + + /* Find an empty segment */ + EmptyIndex = HEAP_SEGMENTS; + for (Index = 0; Index < HEAP_SEGMENTS; Index++) + { + Segment = Heap->Segments[Index]; + + if (Segment) DPRINT("Segment[%d] %p with NOUCP %x\n", Index, Segment, Segment->NumberOfUnCommittedPages); + + /* Check if its size suits us */ + if (Segment && + Pages <= Segment->NumberOfUnCommittedPages) + { + DPRINT("This segment is suitable\n"); + + /* Commit needed amount */ + FreeEntry = RtlpFindAndCommitPages(Heap, Segment, &FreeSize, NULL); + + /* Coalesce it with adjacent entries */ + if (FreeEntry) + { + FreeSize = FreeSize >> HEAP_ENTRY_SHIFT; + FreeEntry = RtlpCoalesceFreeBlocks(Heap, FreeEntry, &FreeSize, FALSE); + RtlpInsertFreeBlock(Heap, FreeEntry, FreeSize); + return FreeEntry; + } + } + else if (!Segment && + EmptyIndex == HEAP_SEGMENTS) + { + /* Remember the first unused segment index */ + EmptyIndex = Index; + } + } + + /* No luck, need to grow the heap */ + if ((Heap->Flags & HEAP_GROWABLE) && + (EmptyIndex != HEAP_SEGMENTS)) + { + Segment = NULL; + + /* Reserve the memory */ + if ((Size + PAGE_SIZE) <= Heap->SegmentReserve) + ReserveSize = Heap->SegmentReserve; + else + ReserveSize = Size + PAGE_SIZE; + + Status = ZwAllocateVirtualMemory(NtCurrentProcess(), + (PVOID)&Segment, + 0, + &ReserveSize, + MEM_RESERVE, + PAGE_READWRITE); + + /* If it failed, retry again with a half division algorithm */ + while (!NT_SUCCESS(Status) && + ReserveSize != Size + PAGE_SIZE) + { + ReserveSize /= 2; + + if (ReserveSize < (Size + PAGE_SIZE)) + ReserveSize = Size + PAGE_SIZE; + + Status = ZwAllocateVirtualMemory(NtCurrentProcess(), + (PVOID)&Segment, + 0, + &ReserveSize, + MEM_RESERVE, + PAGE_READWRITE); + } + + /* Proceed only if it's success */ + if (NT_SUCCESS(Status)) + { + Heap->SegmentReserve += ReserveSize; + + /* Now commit the memory */ + if ((Size + PAGE_SIZE) <= Heap->SegmentCommit) + CommitSize = Heap->SegmentCommit; + else + CommitSize = Size + PAGE_SIZE; + + Status = ZwAllocateVirtualMemory(NtCurrentProcess(), + (PVOID)&Segment, + 0, + &CommitSize, + MEM_COMMIT, + PAGE_READWRITE); + + DPRINT("Committed %d bytes at base %p\n", CommitSize, Segment); + + /* Initialize heap segment if commit was successful */ + if (NT_SUCCESS(Status)) + { + if (!RtlpInitializeHeapSegment(Heap, Segment, EmptyIndex, 0, Segment, + (PCHAR)Segment + CommitSize, (PCHAR)Segment + ReserveSize)) + { + Status = STATUS_NO_MEMORY; + } + } + + /* If everything worked - cool */ + if (NT_SUCCESS(Status)) return (PHEAP_FREE_ENTRY)Segment->FirstEntry; + + DPRINT1("Committing failed with status 0x%08X\n", Status); + + /* Nope, we failed. Free memory */ + ZwFreeVirtualMemory(NtCurrentProcess(), + (PVOID)&Segment, + &ReserveSize, + MEM_RELEASE); + } + else + { + DPRINT1("Reserving failed with status 0x%08X\n", Status); + } + } + + if (RtlpGetMode() == UserMode) + { + /* If coalescing on free is disabled in usermode, then do it here */ + if (Heap->Flags & HEAP_DISABLE_COALESCE_ON_FREE) + { + FreeEntry = RtlpCoalesceHeap(Heap); + + /* If it's a suitable one - return it */ + if (FreeEntry && + FreeEntry->Size >= Size) + { + return FreeEntry; + } + } + } + return NULL; } /*********************************************************************** - * HEAP_Commit - * - * Make sure the heap storage is committed for a given size in the specified arena. - */ -static __inline BOOL HEAP_Commit( SUBHEAP *subheap, ARENA_INUSE *pArena, SIZE_T data_size ) -{ - NTSTATUS Status; - void *ptr = (char *)(pArena + 1) + data_size + sizeof(ARENA_FREE); - SIZE_T size = (char *)ptr - (char *)subheap; - size = (size + COMMIT_MASK) & ~COMMIT_MASK; - if (size > subheap->size) size = subheap->size; - if (size <= subheap->commitSize) return TRUE; - size -= subheap->commitSize; - ptr = (char *)subheap + subheap->commitSize; - if (subheap->heap->commitRoutine != NULL) - { - Status = subheap->heap->commitRoutine(subheap->heap, &ptr, &size); - } - else - { - Status = ZwAllocateVirtualMemory( NtCurrentProcess(), &ptr, 0, - &size, MEM_COMMIT, get_protection_type(subheap->heap->flags) ); - } - if (!NT_SUCCESS(Status)) - { - WARN("Could not commit %08lx bytes at %p for heap %p\n", - size, ptr, subheap->heap ); - return FALSE; - } - subheap->commitSize += size; - return TRUE; -} - -#if 0 -/*********************************************************************** - * HEAP_Decommit - * - * If possible, decommit the heap storage from (including) 'ptr'. - */ -static inline BOOL HEAP_Decommit( SUBHEAP *subheap, void *ptr ) -{ - void *addr; - SIZE_T decommit_size; - SIZE_T size = (char *)ptr - (char *)subheap; - - /* round to next block and add one full block */ - size = ((size + COMMIT_MASK) & ~COMMIT_MASK) + COMMIT_MASK + 1; - if (size >= subheap->commitSize) return TRUE; - decommit_size = subheap->commitSize - size; - addr = (char *)subheap + size; - - if (ZwFreeVirtualMemory( NtCurrentProcess(), &addr, &decommit_size, MEM_DECOMMIT )) - { - WARN("Could not decommit %08lx bytes at %p for heap %p\n", - decommit_size, (char *)subheap + size, subheap->heap ); - return FALSE; - } - subheap->commitSize -= decommit_size; - return TRUE; -} -#endif - -/*********************************************************************** - * HEAP_CreateFreeBlock - * - * Create a free block at a specified address. 'size' is the size of the - * whole block, including the new arena. - */ -static void HEAP_CreateFreeBlock( SUBHEAP *subheap, void *ptr, SIZE_T size ) -{ - ARENA_FREE *pFree; - char *pEnd; - BOOL last; - - /* Create a free arena */ - mark_block_uninitialized( ptr, sizeof( ARENA_FREE ) ); - pFree = (ARENA_FREE *)ptr; - pFree->magic = ARENA_FREE_MAGIC; - - /* If debugging, erase the freed block content */ - - pEnd = (char *)ptr + size; - if (pEnd > (char *)subheap + subheap->commitSize) pEnd = (char *)subheap + subheap->commitSize; - if (pEnd > (char *)(pFree + 1)) mark_block_free( pFree + 1, pEnd - (char *)(pFree + 1) ); - - /* Check if next block is free also */ - - if (((char *)ptr + size < (char *)subheap + subheap->size) && - (*(DWORD *)((char *)ptr + size) & ARENA_FLAG_FREE)) - { - /* Remove the next arena from the free list */ - ARENA_FREE *pNext = (ARENA_FREE *)((char *)ptr + size); - list_remove( &pNext->entry ); - size += (pNext->size & ARENA_SIZE_MASK) + sizeof(*pNext); - mark_block_free( pNext, sizeof(ARENA_FREE) ); - } - - /* Set the next block PREV_FREE flag and pointer */ - - last = ((char *)ptr + size >= (char *)subheap + subheap->size); - if (!last) - { - DWORD *pNext = (DWORD *)((char *)ptr + size); - *pNext |= ARENA_FLAG_PREV_FREE; - mark_block_initialized( pNext - 1, sizeof( ARENA_FREE * ) ); - *((ARENA_FREE **)pNext - 1) = pFree; - } - - /* Last, insert the new block into the free list */ - - pFree->size = size - sizeof(*pFree); - HEAP_InsertFreeBlock( subheap->heap, pFree, last ); -} - - -/*********************************************************************** - * HEAP_MakeInUseBlockFree - * - * Turn an in-use block into a free block. Can also decommit the end of - * the heap, and possibly even free the sub-heap altogether. - */ -static void HEAP_MakeInUseBlockFree( SUBHEAP *subheap, ARENA_INUSE *pArena ) -{ - ARENA_FREE *pFree; - SIZE_T size = (pArena->size & ARENA_SIZE_MASK) + sizeof(*pArena); - PHEAP_USER_DATA udata; - - /* Find and free user data */ - if (pArena->has_user_data) - { - udata = HEAP_GetUserData(subheap->heap, pArena + 1); - if (udata) - { - RemoveEntryList(&udata->ListEntry); - RtlFreeHeap(subheap->heap, 0, udata); - } - } - - /* Check if we can merge with previous block */ - - if (pArena->size & ARENA_FLAG_PREV_FREE) - { - pFree = *((ARENA_FREE **)pArena - 1); - size += (pFree->size & ARENA_SIZE_MASK) + sizeof(ARENA_FREE); - /* Remove it from the free list */ - list_remove( &pFree->entry ); - } - else pFree = (ARENA_FREE *)pArena; - - /* Create a free block */ - - HEAP_CreateFreeBlock( subheap, pFree, size ); - size = (pFree->size & ARENA_SIZE_MASK) + sizeof(ARENA_FREE); - if ((char *)pFree + size < (char *)subheap + subheap->size) - return; /* Not the last block, so nothing more to do */ - - /* Free the whole sub-heap if it's empty and not the original one */ - - if (((char *)pFree == (char *)subheap + subheap->headerSize) && - (subheap != &subheap->heap->subheap)) - { - SIZE_T size = 0; - SUBHEAP *pPrev = &subheap->heap->subheap; - /* Remove the free block from the list */ - list_remove( &pFree->entry ); - /* Remove the subheap from the list */ - while (pPrev && (pPrev->next != subheap)) pPrev = pPrev->next; - if (pPrev) pPrev->next = subheap->next; - /* Free the memory */ - subheap->magic = 0; - ZwFreeVirtualMemory( NtCurrentProcess(), (void **)&subheap, &size, MEM_RELEASE ); - return; - } - - /* Decommit the end of the heap */ -} - -/*********************************************************************** - * HEAP_ShrinkBlock - * - * Shrink an in-use block. - */ -static void HEAP_ShrinkBlock(SUBHEAP *subheap, ARENA_INUSE *pArena, SIZE_T size) -{ - if ((pArena->size & ARENA_SIZE_MASK) >= size + HEAP_MIN_SHRINK_SIZE) - { - HEAP_CreateFreeBlock( subheap, (char *)(pArena + 1) + size, - (pArena->size & ARENA_SIZE_MASK) - size ); - /* assign size plus previous arena flags */ - pArena->size = size | (pArena->size & ~ARENA_SIZE_MASK); - } - else - { - /* Turn off PREV_FREE flag in next block */ - char *pNext = (char *)(pArena + 1) + (pArena->size & ARENA_SIZE_MASK); - if (pNext < (char *)subheap + subheap->size) - *(DWORD *)pNext &= ~ARENA_FLAG_PREV_FREE; - } -} - -/*********************************************************************** - * HEAP_InitSubHeap - */ -static BOOL HEAP_InitSubHeap( HEAP *heap, LPVOID address, DWORD flags, - SIZE_T commitSize, SIZE_T totalSize, - PRTL_HEAP_PARAMETERS Parameters) -{ - SUBHEAP *subheap; - FREE_LIST_ENTRY *pEntry; - int i; - NTSTATUS Status; - - if (!address && ZwAllocateVirtualMemory( NtCurrentProcess(), &address, 0, - &commitSize, MEM_COMMIT, get_protection_type(flags) )) - { - WARN("Could not commit %08lx bytes for sub-heap %p\n", commitSize, address ); - return FALSE; - } - - /* Fill the sub-heap structure */ - - subheap = (SUBHEAP *)address; - subheap->heap = heap; - subheap->size = totalSize; - subheap->commitSize = commitSize; - subheap->magic = SUBHEAP_MAGIC; - - if ( subheap != (SUBHEAP *)heap ) - { - /* If this is a secondary subheap, insert it into list */ - - subheap->headerSize = ROUND_SIZE( sizeof(SUBHEAP) ); - subheap->next = heap->subheap.next; - heap->subheap.next = subheap; - } - else - { - /* If this is a primary subheap, initialize main heap */ - - subheap->headerSize = ROUND_SIZE( sizeof(HEAP) ); - subheap->next = NULL; - heap->flags = flags; - heap->magic = HEAP_MAGIC; - if (Parameters) - heap->commitRoutine = Parameters->CommitRoutine; - else - heap->commitRoutine = NULL; - InitializeListHead(&heap->UserDataHead); - - /* Build the free lists */ - - list_init( &heap->freeList[0].arena.entry ); - for (i = 0, pEntry = heap->freeList; i < HEAP_NB_FREE_LISTS; i++, pEntry++) - { - pEntry->arena.size = 0 | ARENA_FLAG_FREE; - pEntry->arena.magic = ARENA_FREE_MAGIC; - if (i) list_add_after( &pEntry[-1].arena.entry, &pEntry->arena.entry ); - } - - /* Initialize critical section */ - - if (RtlpGetMode() == UserMode) - { - if (!processHeap) /* do it by hand to avoid memory allocations */ - { - heap->lock.CriticalSection.DebugInfo = &process_heap_critsect_debug; - heap->lock.CriticalSection.LockCount = -1; - heap->lock.CriticalSection.RecursionCount = 0; - heap->lock.CriticalSection.OwningThread = 0; - heap->lock.CriticalSection.LockSemaphore = 0; - heap->lock.CriticalSection.SpinCount = 0; - process_heap_critsect_debug.CriticalSection = &heap->lock.CriticalSection; - } - else RtlInitializeHeapLock( &heap->lock ); - } - } - - /* Commit memory */ - if (heap->commitRoutine) - { - if (subheap != (SUBHEAP *)heap) - { - Status = heap->commitRoutine(heap, &address, &commitSize); - } - else - { - /* the caller is responsible for committing the first page! */ - Status = STATUS_SUCCESS; - } - } - else - { - Status = ZwAllocateVirtualMemory(NtCurrentProcess(), - &address, - 0, - &commitSize, - MEM_COMMIT, - get_protection_type(flags)); - } - if (!NT_SUCCESS(Status)) - { - DPRINT("Could not commit %08lx bytes for sub-heap %p\n", - commitSize, address); - return FALSE; - } - - /* Create the first free block */ - - HEAP_CreateFreeBlock( subheap, (LPBYTE)subheap + subheap->headerSize, - subheap->size - subheap->headerSize ); - - return TRUE; -} - -/*********************************************************************** - * HEAP_CreateSubHeap - * - * Create a sub-heap of the given size. - * If heap == NULL, creates a main heap. - */ -static SUBHEAP *HEAP_CreateSubHeap( HEAP *heap, void *base, DWORD flags, - SIZE_T commitSize, SIZE_T totalSize, - IN PRTL_HEAP_PARAMETERS Parameters) -{ - LPVOID address = base; - - /* round-up sizes on a 64K boundary */ - totalSize = (totalSize + 0xffff) & 0xffff0000; - commitSize = (commitSize + 0xffff) & 0xffff0000; - if (!commitSize) commitSize = 0x10000; - totalSize = min( totalSize, 0xffff0000 ); /* don't allow a heap larger than 4Gb */ - if (totalSize < commitSize) totalSize = commitSize; - - if (!address) - { - /* allocate the memory block */ - if (ZwAllocateVirtualMemory( NtCurrentProcess(), &address, 0, &totalSize, - MEM_RESERVE | MEM_COMMIT, get_protection_type(flags) )) - { - WARN("Could not allocate %08lx bytes\n", totalSize ); - return NULL; - } - } - - /* Initialize subheap */ - - if (!HEAP_InitSubHeap( heap ? heap : (HEAP *)address, - address, flags, commitSize, totalSize, Parameters )) - { - SIZE_T size = 0; - if (!base) ZwFreeVirtualMemory( NtCurrentProcess(), &address, &size, MEM_RELEASE ); - return NULL; - } - - return (SUBHEAP *)address; -} - - -/*********************************************************************** - * HEAP_FindFreeBlock - * - * Find a free block at least as large as the requested size, and make sure - * the requested size is committed. - */ -static ARENA_FREE *HEAP_FindFreeBlock( HEAP *heap, SIZE_T size, - SUBHEAP **ppSubHeap ) -{ - SUBHEAP *subheap; - struct list *ptr; - SIZE_T total_size; - FREE_LIST_ENTRY *pEntry = heap->freeList + get_freelist_index( size + sizeof(ARENA_INUSE) ); - - /* Find a suitable free list, and in it find a block large enough */ - - ptr = &pEntry->arena.entry; - while ((ptr = list_next( &heap->freeList[0].arena.entry, ptr ))) - { - ARENA_FREE *pArena = LIST_ENTRY( ptr, ARENA_FREE, entry ); - SIZE_T arena_size = (pArena->size & ARENA_SIZE_MASK) + - sizeof(ARENA_FREE) - sizeof(ARENA_INUSE); - if (arena_size >= size) - { - subheap = HEAP_FindSubHeap( heap, pArena ); - if (!HEAP_Commit( subheap, (ARENA_INUSE *)pArena, size )) return NULL; - *ppSubHeap = subheap; - return pArena; - } - } - - /* If no block was found, attempt to grow the heap */ - - if (!(heap->flags & HEAP_GROWABLE)) - { - ERR("Not enough space in heap %p for %08lx bytes\n", heap, size ); - return NULL; - } - /* make sure that we have a big enough size *committed* to fit another - * last free arena in ! - * So just one heap struct, one first free arena which will eventually - * get used, and a second free arena that might get assigned all remaining - * free space in HEAP_ShrinkBlock() */ - total_size = size + ROUND_SIZE(sizeof(SUBHEAP)) + sizeof(ARENA_INUSE) + sizeof(ARENA_FREE); - if (total_size < size) return NULL; /* overflow */ - - if (!(subheap = HEAP_CreateSubHeap( heap, NULL, heap->flags, total_size, - max( HEAP_DEF_SIZE, total_size ), NULL ))) - return NULL; - - TRACE("created new sub-heap %p of %08lx bytes for heap %p\n", - subheap, size, heap ); - - *ppSubHeap = subheap; - return (ARENA_FREE *)(subheap + 1); -} - -/*********************************************************************** - * HEAP_IsValidArenaPtr - * - * Check that the pointer is inside the range possible for arenas. - */ -static BOOL HEAP_IsValidArenaPtr( const HEAP *heap, const void *ptr ) -{ - int i; - const SUBHEAP *subheap = HEAP_FindSubHeap( heap, ptr ); - if (!subheap) return FALSE; - if ((const char *)ptr >= (const char *)subheap + subheap->headerSize) return TRUE; - if (subheap != &heap->subheap) return FALSE; - for (i = 0; i < HEAP_NB_FREE_LISTS; i++) - if (ptr == (const void *)&heap->freeList[i].arena) return TRUE; - return FALSE; -} - - -/*********************************************************************** - * HEAP_ValidateFreeArena - */ -static BOOL HEAP_ValidateFreeArena( SUBHEAP *subheap, ARENA_FREE *pArena ) -{ - ARENA_FREE *prev, *next; - char *heapEnd = (char *)subheap + subheap->size; - - /* Check for unaligned pointers */ - if ( (ULONG_PTR)pArena % ALIGNMENT != ARENA_OFFSET ) - { - ERR("Heap %p: unaligned arena pointer %p\n", subheap->heap, pArena ); - return FALSE; - } - - /* Check magic number */ - if (pArena->magic != ARENA_FREE_MAGIC) - { - ERR("Heap %p: invalid free arena magic for %p\n", subheap->heap, pArena ); - return FALSE; - } - /* Check size flags */ - if (!(pArena->size & ARENA_FLAG_FREE) || - (pArena->size & ARENA_FLAG_PREV_FREE)) - { - ERR("Heap %p: bad flags %08lx for free arena %p\n", - subheap->heap, pArena->size & ~ARENA_SIZE_MASK, pArena ); - return FALSE; - } - /* Check arena size */ - if ((char *)(pArena + 1) + (pArena->size & ARENA_SIZE_MASK) > heapEnd) - { - ERR("Heap %p: bad size %08lx for free arena %p\n", - subheap->heap, pArena->size & ARENA_SIZE_MASK, pArena ); - return FALSE; - } - /* Check that next pointer is valid */ - next = LIST_ENTRY( pArena->entry.next, ARENA_FREE, entry ); - if (!HEAP_IsValidArenaPtr( subheap->heap, next )) - { - ERR("Heap %p: bad next ptr %p for arena %p\n", - subheap->heap, next, pArena ); - return FALSE; - } - /* Check that next arena is free */ - if (!(next->size & ARENA_FLAG_FREE) || (next->magic != ARENA_FREE_MAGIC)) - { - ERR("Heap %p: next arena %p invalid for %p\n", - subheap->heap, next, pArena ); - return FALSE; - } - /* Check that prev pointer is valid */ - prev = LIST_ENTRY( pArena->entry.prev, ARENA_FREE, entry ); - if (!HEAP_IsValidArenaPtr( subheap->heap, prev )) - { - ERR("Heap %p: bad prev ptr %p for arena %p\n", - subheap->heap, prev, pArena ); - return FALSE; - } - /* Check that prev arena is free */ - if (!(prev->size & ARENA_FLAG_FREE) || (prev->magic != ARENA_FREE_MAGIC)) - { - /* this often means that the prev arena got overwritten - * by a memory write before that prev arena */ - ERR("Heap %p: prev arena %p invalid for %p\n", - subheap->heap, prev, pArena ); - return FALSE; - } - /* Check that next block has PREV_FREE flag */ - if ((char *)(pArena + 1) + (pArena->size & ARENA_SIZE_MASK) < heapEnd) - { - if (!(*(DWORD *)((char *)(pArena + 1) + - (pArena->size & ARENA_SIZE_MASK)) & ARENA_FLAG_PREV_FREE)) - { - ERR("Heap %p: free arena %p next block has no PREV_FREE flag\n", - subheap->heap, pArena ); - return FALSE; - } - /* Check next block back pointer */ - if (*((ARENA_FREE **)((char *)(pArena + 1) + - (pArena->size & ARENA_SIZE_MASK)) - 1) != pArena) - { - ERR("Heap %p: arena %p has wrong back ptr %p\n", - subheap->heap, pArena, - *((ARENA_FREE **)((char *)(pArena+1) + (pArena->size & ARENA_SIZE_MASK)) - 1)); - return FALSE; - } - } - return TRUE; -} - -/*********************************************************************** - * HEAP_ValidateInUseArena - */ -static BOOL HEAP_ValidateInUseArena( const SUBHEAP *subheap, const ARENA_INUSE *pArena, BOOL quiet ) -{ - const char *heapEnd = (const char *)subheap + subheap->size; - - /* Check for unaligned pointers */ - if ( (ULONG_PTR)pArena % ALIGNMENT != ARENA_OFFSET ) - { - if ( quiet == NOISY ) - { - ERR( "Heap %p: unaligned arena pointer %p\n", subheap->heap, pArena ); - if ( TRACE_ON(heap) ) - HEAP_Dump( subheap->heap ); - } - else if ( WARN_ON(heap) ) - { - WARN( "Heap %p: unaligned arena pointer %p\n", subheap->heap, pArena ); - if ( TRACE_ON(heap) ) - HEAP_Dump( subheap->heap ); - } - return FALSE; - } - - /* Check magic number */ - if (pArena->magic != ARENA_INUSE_MAGIC) - { - if (quiet == NOISY) { - ERR("Heap %p: invalid in-use arena magic for %p\n", subheap->heap, pArena ); - if (TRACE_ON(heap)) - HEAP_Dump( subheap->heap ); - } else if (WARN_ON(heap)) { - WARN("Heap %p: invalid in-use arena magic for %p\n", subheap->heap, pArena ); - if (TRACE_ON(heap)) - HEAP_Dump( subheap->heap ); - } - return FALSE; - } - /* Check size flags */ - if (pArena->size & ARENA_FLAG_FREE) - { - ERR("Heap %p: bad flags %08lx for in-use arena %p\n", - subheap->heap, pArena->size & ~ARENA_SIZE_MASK, pArena ); - return FALSE; - } - /* Check arena size */ - if ((const char *)(pArena + 1) + (pArena->size & ARENA_SIZE_MASK) > heapEnd) - { - ERR("Heap %p: bad size %08lx for in-use arena %p\n", - subheap->heap, pArena->size & ARENA_SIZE_MASK, pArena ); - return FALSE; - } - /* Check next arena PREV_FREE flag */ - if (((const char *)(pArena + 1) + (pArena->size & ARENA_SIZE_MASK) < heapEnd) && - (*(const DWORD *)((const char *)(pArena + 1) + (pArena->size & ARENA_SIZE_MASK)) & ARENA_FLAG_PREV_FREE)) - { - ERR("Heap %p: in-use arena %p next block has PREV_FREE flag\n", - subheap->heap, pArena ); - return FALSE; - } - /* Check prev free arena */ - if (pArena->size & ARENA_FLAG_PREV_FREE) - { - const ARENA_FREE *pPrev = *((const ARENA_FREE * const*)pArena - 1); - /* Check prev pointer */ - if (!HEAP_IsValidArenaPtr( subheap->heap, pPrev )) - { - ERR("Heap %p: bad back ptr %p for arena %p\n", - subheap->heap, pPrev, pArena ); - return FALSE; - } - /* Check that prev arena is free */ - if (!(pPrev->size & ARENA_FLAG_FREE) || - (pPrev->magic != ARENA_FREE_MAGIC)) - { - ERR("Heap %p: prev arena %p invalid for in-use %p\n", - subheap->heap, pPrev, pArena ); - return FALSE; - } - /* Check that prev arena is really the previous block */ - if ((const char *)(pPrev + 1) + (pPrev->size & ARENA_SIZE_MASK) != (const char *)pArena) - { - ERR("Heap %p: prev arena %p is not prev for in-use %p\n", - subheap->heap, pPrev, pArena ); - return FALSE; - } - } - return TRUE; -} - -/*********************************************************************** - * HEAP_IsRealArena [Internal] - * Validates a block is a valid arena. - * - * RETURNS - * TRUE: Success - * FALSE: Failure - */ -static BOOL HEAP_IsRealArena( HEAP *heapPtr, /* [in] ptr to the heap */ - DWORD flags, /* [in] Bit flags that control access during operation */ - LPCVOID block, /* [in] Optional pointer to memory block to validate */ - BOOL quiet ) /* [in] Flag - if true, HEAP_ValidateInUseArena - * does not complain */ -{ - SUBHEAP *subheap; - BOOL ret = TRUE; - - if (!heapPtr || (heapPtr->magic != HEAP_MAGIC)) - { - ERR("Invalid heap %p!\n", heapPtr ); - return FALSE; - } - - flags &= HEAP_NO_SERIALIZE; - flags |= heapPtr->flags; - /* calling HeapLock may result in infinite recursion, so do the critsect directly */ - if (!(flags & HEAP_NO_SERIALIZE)) - RtlEnterHeapLock( &heapPtr->lock ); - - if (block) - { - /* Only check this single memory block */ - - if (!(subheap = HEAP_FindSubHeap( heapPtr, block )) || - ((const char *)block < (char *)subheap + subheap->headerSize - + sizeof(ARENA_INUSE))) - { - if (quiet == NOISY) - ERR("Heap %p: block %p is not inside heap\n", heapPtr, block ); - else if (WARN_ON(heap)) - WARN("Heap %p: block %p is not inside heap\n", heapPtr, block ); - ret = FALSE; - } else - ret = HEAP_ValidateInUseArena( subheap, (const ARENA_INUSE *)block - 1, quiet ); - - if (!(flags & HEAP_NO_SERIALIZE)) - RtlLeaveHeapLock( &heapPtr->lock ); - return ret; - } - - subheap = &heapPtr->subheap; - while (subheap && ret) - { - char *ptr = (char *)subheap + subheap->headerSize; - while (ptr < (char *)subheap + subheap->size) - { - if (*(DWORD *)ptr & ARENA_FLAG_FREE) - { - if (!HEAP_ValidateFreeArena( subheap, (ARENA_FREE *)ptr )) { - ret = FALSE; - break; - } - ptr += sizeof(ARENA_FREE) + (*(DWORD *)ptr & ARENA_SIZE_MASK); - } - else - { - if (!HEAP_ValidateInUseArena( subheap, (ARENA_INUSE *)ptr, NOISY )) { - ret = FALSE; - break; - } - ptr += sizeof(ARENA_INUSE) + (*(DWORD *)ptr & ARENA_SIZE_MASK); - } - } - subheap = subheap->next; - } - - if (!(flags & HEAP_NO_SERIALIZE)) RtlLeaveHeapLock( &heapPtr->lock ); - return ret; -} - - -/*********************************************************************** - * HeapCreate (KERNEL32.336) + * RtlCreateHeap * RETURNS * Handle of heap: Success * NULL: Failure @@ -1157,47 +1342,362 @@ static BOOL HEAP_IsRealArena( HEAP *heapPtr, /* [in] ptr to the heap */ * @implemented */ HANDLE NTAPI -RtlCreateHeap(ULONG flags, - PVOID addr, - SIZE_T totalSize, - SIZE_T commitSize, +RtlCreateHeap(ULONG Flags, + PVOID Addr, + SIZE_T TotalSize, + SIZE_T CommitSize, PVOID Lock, PRTL_HEAP_PARAMETERS Parameters) { - SUBHEAP *subheap; + PVOID CommittedAddress = NULL, UncommittedAddress = NULL; + PHEAP Heap = NULL; + RTL_HEAP_PARAMETERS SafeParams = {0}; + PPEB Peb; + ULONG_PTR MaximumUserModeAddress; + SYSTEM_BASIC_INFORMATION SystemInformation; + MEMORY_BASIC_INFORMATION MemoryInfo; + ULONG NtGlobalFlags = RtlGetNtGlobalFlags(); + ULONG HeapSegmentFlags = 0; + NTSTATUS Status; + ULONG MaxBlockSize, HeaderSize; + BOOLEAN AllocateLock = FALSE; - /* Allocate the heap block */ - - if (!totalSize) + /* Check for a special heap */ + if (RtlpPageHeapEnabled && !Addr && !Lock) { - totalSize = HEAP_DEF_SIZE; - flags |= HEAP_GROWABLE; - } - if (!(subheap = HEAP_CreateSubHeap( NULL, addr, flags, commitSize, totalSize, Parameters ))) return 0; + Heap = RtlpPageHeapCreate(Flags, Addr, TotalSize, CommitSize, Lock, Parameters); + if (Heap) return Heap; - if (RtlpGetMode() == UserMode) - { - /* link it into the per-process heap list */ - if (processHeap) + //ASSERT(FALSE); + DPRINT1("Enabling page heap failed\n"); + } + + /* Check validation flags */ + if (!(Flags & HEAP_SKIP_VALIDATION_CHECKS) && (Flags & ~HEAP_CREATE_VALID_MASK)) + { + DPRINT1("Invalid flags 0x%08x, fixing...\n", Flags); + Flags &= HEAP_CREATE_VALID_MASK; + } + + /* TODO: Capture parameters, once we decide to use SEH */ + if (!Parameters) Parameters = &SafeParams; + + /* Check global flags */ + if (NtGlobalFlags & FLG_HEAP_DISABLE_COALESCING) + Flags |= HEAP_DISABLE_COALESCE_ON_FREE; + + if (NtGlobalFlags & FLG_HEAP_ENABLE_FREE_CHECK) + Flags |= HEAP_FREE_CHECKING_ENABLED; + + if (NtGlobalFlags & FLG_HEAP_ENABLE_TAIL_CHECK) + Flags |= HEAP_TAIL_CHECKING_ENABLED; + + if (RtlpGetMode() == UserMode) + { + /* Also check these flags if in usermode */ + if (NtGlobalFlags & FLG_HEAP_VALIDATE_ALL) + Flags |= HEAP_VALIDATE_ALL_ENABLED; + + if (NtGlobalFlags & FLG_HEAP_VALIDATE_PARAMETERS) + Flags |= HEAP_VALIDATE_PARAMETERS_ENABLED; + + if (NtGlobalFlags & FLG_USER_STACK_TRACE_DB) + Flags |= HEAP_CAPTURE_STACK_BACKTRACES; + + /* Get PEB */ + Peb = RtlGetCurrentPeb(); + + /* Apply defaults for non-set parameters */ + if (!Parameters->SegmentCommit) Parameters->SegmentCommit = Peb->HeapSegmentCommit; + if (!Parameters->SegmentReserve) Parameters->SegmentReserve = Peb->HeapSegmentReserve; + if (!Parameters->DeCommitFreeBlockThreshold) Parameters->DeCommitFreeBlockThreshold = Peb->HeapDeCommitFreeBlockThreshold; + if (!Parameters->DeCommitTotalFreeThreshold) Parameters->DeCommitTotalFreeThreshold = Peb->HeapDeCommitTotalFreeThreshold; + } + else + { + /* Apply defaults for non-set parameters */ +#if 0 + if (!Parameters->SegmentCommit) Parameters->SegmentCommit = MmHeapSegmentCommit; + if (!Parameters->SegmentReserve) Parameters->SegmentReserve = MmHeapSegmentReserve; + if (!Parameters->DeCommitFreeBlockThreshold) Parameters->DeCommitFreeBlockThreshold = MmHeapDeCommitFreeBlockThreshold; + if (!Parameters->DeCommitTotalFreeThreshold) Parameters->DeCommitTotalFreeThreshold = MmHeapDeCommitTotalFreeThreshold; +#endif + } + + // FIXME: Move to memory manager + if (!Parameters->SegmentCommit) Parameters->SegmentCommit = PAGE_SIZE * 2; + if (!Parameters->SegmentReserve) Parameters->SegmentReserve = 1048576; + if (!Parameters->DeCommitFreeBlockThreshold) Parameters->DeCommitFreeBlockThreshold = PAGE_SIZE; + if (!Parameters->DeCommitTotalFreeThreshold) Parameters->DeCommitTotalFreeThreshold = 65536; + + /* Get the max um address */ + Status = ZwQuerySystemInformation(SystemBasicInformation, + &SystemInformation, + sizeof(SystemInformation), + NULL); + + if (!NT_SUCCESS(Status)) + { + DPRINT1("Getting max usermode address failed with status 0x%08x\n", Status); + return NULL; + } + + MaximumUserModeAddress = SystemInformation.MaximumUserModeAddress; + + /* Calculate max alloc size */ + if (!Parameters->MaximumAllocationSize) + Parameters->MaximumAllocationSize = MaximumUserModeAddress - (ULONG_PTR)0x10000 - PAGE_SIZE; + + MaxBlockSize = 0x80000 - PAGE_SIZE; + + if (!Parameters->VirtualMemoryThreshold || + Parameters->VirtualMemoryThreshold > MaxBlockSize) + { + Parameters->VirtualMemoryThreshold = MaxBlockSize; + } + + /* Check reserve/commit sizes and set default values */ + if (!CommitSize) + { + CommitSize = PAGE_SIZE; + if (TotalSize) + TotalSize = ROUND_UP(TotalSize, PAGE_SIZE); + else + TotalSize = 64 * PAGE_SIZE; + } + else + { + /* Round up the commit size to be at least the page size */ + CommitSize = ROUND_UP(CommitSize, PAGE_SIZE); + + if (TotalSize) + TotalSize = ROUND_UP(TotalSize, PAGE_SIZE); + else + TotalSize = ROUND_UP(CommitSize, 16 * PAGE_SIZE); + } + + /* Call special heap */ + if (RtlpHeapIsSpecial(Flags)) + return RtlDebugCreateHeap(Flags, Addr, TotalSize, CommitSize, Lock, Parameters); + + /* Calculate header size */ + HeaderSize = sizeof(HEAP); + if (!(Flags & HEAP_NO_SERIALIZE)) + { + if (Lock) { - HEAP *heapPtr = subheap->heap; - RtlEnterHeapLock( &processHeap->lock ); - list_add_head( &processHeap->entry, &heapPtr->entry ); - RtlLeaveHeapLock( &processHeap->lock ); + Flags |= HEAP_LOCK_USER_ALLOCATED; } else { - processHeap = subheap->heap; /* assume the first heap we create is the process main heap */ - list_init( &processHeap->entry ); - assert( (ULONG_PTR)processHeap->freeList % ALIGNMENT == ARENA_OFFSET ); + HeaderSize += sizeof(HEAP_LOCK); + AllocateLock = TRUE; } - } + } + else if (Lock) + { + /* Invalid parameters */ + return NULL; + } - return (HANDLE)subheap; + /* See if we are already provided with an address for the heap */ + if (Addr) + { + if (Parameters->CommitRoutine) + { + /* There is a commit routine, so no problem here, check params */ + if ((Flags & HEAP_GROWABLE) || + !Parameters->InitialCommit || + !Parameters->InitialReserve || + (Parameters->InitialCommit > Parameters->InitialReserve)) + { + /* Fail */ + return NULL; + } + + /* Calculate committed and uncommitted addresses */ + CommittedAddress = Addr; + UncommittedAddress = (PCHAR)Addr + Parameters->InitialCommit; + TotalSize = Parameters->InitialReserve; + + /* Zero the initial page ourselves */ + RtlZeroMemory(CommittedAddress, PAGE_SIZE); + } + else + { + /* Commit routine is absent, so query how much memory caller reserved */ + Status = ZwQueryVirtualMemory(NtCurrentProcess(), + Addr, + MemoryBasicInformation, + &MemoryInfo, + sizeof(MemoryInfo), + NULL); + + if (!NT_SUCCESS(Status)) + { + DPRINT1("Querying amount of user supplied memory failed with status 0x%08X\n", Status); + return NULL; + } + + /* Validate it */ + if (MemoryInfo.BaseAddress != Addr || + MemoryInfo.State == MEM_FREE) + { + return NULL; + } + + /* Validation checks passed, set committed/uncommitted addresses */ + CommittedAddress = Addr; + + /* Check if it's committed or not */ + if (MemoryInfo.State == MEM_COMMIT) + { + /* Zero it out because it's already committed */ + RtlZeroMemory(CommittedAddress, PAGE_SIZE); + + /* Calculate uncommitted address value */ + CommitSize = MemoryInfo.RegionSize; + TotalSize = CommitSize; + UncommittedAddress = (PCHAR)Addr + CommitSize; + + /* Check if uncommitted address is reserved */ + Status = ZwQueryVirtualMemory(NtCurrentProcess(), + UncommittedAddress, + MemoryBasicInformation, + &MemoryInfo, + sizeof(MemoryInfo), + NULL); + + if (NT_SUCCESS(Status) && + MemoryInfo.State == MEM_RESERVE) + { + /* It is, so add it up to the reserve size */ + TotalSize += MemoryInfo.RegionSize; + } + } + else + { + /* It's not committed, inform following code that a commit is necessary */ + CommitSize = PAGE_SIZE; + UncommittedAddress = Addr; + } + } + + /* Mark this as a user-committed mem */ + HeapSegmentFlags = HEAP_USER_ALLOCATED; + Heap = (PHEAP)Addr; + } + else + { + /* Check commit routine */ + if (Parameters->CommitRoutine) return NULL; + + /* Reserve memory */ + Status = ZwAllocateVirtualMemory(NtCurrentProcess(), + (PVOID *)&Heap, + 0, + &TotalSize, + MEM_RESERVE, + PAGE_READWRITE); + + if (!NT_SUCCESS(Status)) + { + DPRINT1("Failed to reserve memory with status 0x%08x\n", Status); + return NULL; + } + + /* Set base addresses */ + CommittedAddress = Heap; + UncommittedAddress = Heap; + } + + /* Check if we need to commit something */ + if (CommittedAddress == UncommittedAddress) + { + /* Commit the required size */ + Status = ZwAllocateVirtualMemory(NtCurrentProcess(), + &CommittedAddress, + 0, + &CommitSize, + MEM_COMMIT, + PAGE_READWRITE); + + DPRINT("Committed %d bytes at base %p\n", CommitSize, CommittedAddress); + + if (!NT_SUCCESS(Status)) + { + DPRINT1("Failure, Status 0x%08X\n", Status); + + /* Release memory if it was reserved */ + if (!Addr) ZwFreeVirtualMemory(NtCurrentProcess(), + (PVOID *)&Heap, + &TotalSize, + MEM_RELEASE); + + return NULL; + } + + /* Calculate new uncommitted address */ + UncommittedAddress = (PCHAR)UncommittedAddress + CommitSize; + } + + DPRINT("Created heap %p, CommitSize %x, ReserveSize %x\n", Heap, CommitSize, TotalSize); + + /* Initialize the heap */ + RtlpInitializeHeap(Heap, &HeaderSize, Flags, AllocateLock, Lock); + + /* Initialize heap's first segment */ + if (!RtlpInitializeHeapSegment(Heap, + (PHEAP_SEGMENT)((PCHAR)Heap + HeaderSize), + 0, + HeapSegmentFlags, + CommittedAddress, + UncommittedAddress, + (PCHAR)CommittedAddress + TotalSize)) + { + DPRINT1("Failed to initialize heap segment\n"); + return NULL; + } + + /* Set other data */ + Heap->ProcessHeapsListIndex = 0; + Heap->SegmentCommit = Parameters->SegmentCommit; + Heap->SegmentReserve = Parameters->SegmentReserve; + Heap->DeCommitFreeBlockThreshold = Parameters->DeCommitFreeBlockThreshold >> HEAP_ENTRY_SHIFT; + Heap->DeCommitTotalFreeThreshold = Parameters->DeCommitTotalFreeThreshold >> HEAP_ENTRY_SHIFT; + Heap->MaximumAllocationSize = Parameters->MaximumAllocationSize; + Heap->VirtualMemoryThreshold = ROUND_UP(Parameters->VirtualMemoryThreshold, HEAP_ENTRY_SIZE) >> HEAP_ENTRY_SHIFT; + Heap->CommitRoutine = Parameters->CommitRoutine; + + /* Set alignment */ + if (Flags & HEAP_CREATE_ALIGN_16) + { + Heap->AlignMask = (ULONG)~15; + Heap->AlignRound = 15 + sizeof(HEAP_ENTRY); + } + else + { + Heap->AlignMask = (ULONG)~(HEAP_ENTRY_SIZE - 1); + Heap->AlignRound = HEAP_ENTRY_SIZE - 1 + sizeof(HEAP_ENTRY); + } + + if (Heap->Flags & HEAP_TAIL_CHECKING_ENABLED) + Heap->AlignRound += HEAP_ENTRY_SIZE; + + /* Add heap to process list in case of usermode heap */ + if (RtlpGetMode() == UserMode) + { + RtlpAddHeapToProcessList(Heap); + + // FIXME: What about lookasides? + } + + DPRINT("Heap %p, flags 0x%08x\n", Heap, Heap->Flags); + return Heap; } /*********************************************************************** - * HeapDestroy (KERNEL32.337) + * RtlDestroyHeap * RETURNS * TRUE: Success * FALSE: Failure @@ -1209,39 +1709,357 @@ RtlCreateHeap(ULONG flags, * Failure: The Heap handle, if heap is the process heap. */ HANDLE NTAPI -RtlDestroyHeap(HANDLE heap) /* [in] Handle of heap */ +RtlDestroyHeap(HANDLE HeapPtr) /* [in] Handle of heap */ { - HEAP *heapPtr = HEAP_GetPtr( heap ); - SUBHEAP *subheap; + PHEAP Heap = (PHEAP)HeapPtr; + PLIST_ENTRY Current; + PHEAP_UCR_SEGMENT UcrSegment; + PHEAP_VIRTUAL_ALLOC_ENTRY VirtualEntry; + PVOID BaseAddress; + SIZE_T Size; + LONG i; + PHEAP_SEGMENT Segment; - DPRINT("%p\n", heap ); - if (!heapPtr) - return heap; + if (!HeapPtr) return NULL; - if (RtlpGetMode() == UserMode) - { - if (heap == NtCurrentPeb()->ProcessHeap) - return heap; /* cannot delete the main process heap */ - - /* remove it from the per-process list */ - RtlEnterHeapLock( &processHeap->lock ); - list_remove( &heapPtr->entry ); - RtlLeaveHeapLock( &processHeap->lock ); - } - - RtlDeleteHeapLock( &heapPtr->lock ); - subheap = &heapPtr->subheap; - while (subheap) + /* Call special heap */ + if (RtlpHeapIsSpecial(Heap->Flags)) { - SUBHEAP *next = subheap->next; - SIZE_T size = 0; - void *addr = subheap; - ZwFreeVirtualMemory( NtCurrentProcess(), &addr, &size, MEM_RELEASE ); - subheap = next; + if (!RtlDebugDestroyHeap(Heap)) return HeapPtr; } - return (HANDLE)NULL; + + /* Check for a process heap */ + if (RtlpGetMode() == UserMode && + HeapPtr == NtCurrentPeb()->ProcessHeap) return HeapPtr; + + /* Free up all big allocations */ + Current = Heap->VirtualAllocdBlocks.Flink; + while (Current != &Heap->VirtualAllocdBlocks) + { + VirtualEntry = CONTAINING_RECORD(Current, HEAP_VIRTUAL_ALLOC_ENTRY, Entry); + BaseAddress = (PVOID)VirtualEntry; + Current = Current->Flink; + Size = 0; + ZwFreeVirtualMemory(NtCurrentProcess(), + &BaseAddress, + &Size, + MEM_RELEASE); + } + + /* Delete tags and remove heap from the process heaps list in user mode */ + if (RtlpGetMode() == UserMode) + { + // FIXME DestroyTags + RtlpRemoveHeapFromProcessList(Heap); + } + + /* Delete the heap lock */ + if (!(Heap->Flags & HEAP_NO_SERIALIZE)) + { + /* Delete it if it wasn't user allocated */ + if (!(Heap->Flags & HEAP_LOCK_USER_ALLOCATED)) + RtlDeleteHeapLock(Heap->LockVariable); + + /* Clear out the lock variable */ + Heap->LockVariable = NULL; + } + + /* Free UCR segments if any were created */ + Current = Heap->UCRSegments.Flink; + while(Current != &Heap->UCRSegments) + { + UcrSegment = CONTAINING_RECORD(Current, HEAP_UCR_SEGMENT, ListEntry); + + /* Advance to the next descriptor */ + Current = Current->Flink; + + BaseAddress = (PVOID)UcrSegment; + Size = 0; + + /* Release that memory */ + ZwFreeVirtualMemory(NtCurrentProcess(), + &BaseAddress, + &Size, + MEM_RELEASE); + } + + /* Go through segments and destroy them */ + for (i = HEAP_SEGMENTS - 1; i >= 0; i--) + { + Segment = Heap->Segments[i]; + if (Segment) RtlpDestroyHeapSegment(Segment); + } + + return NULL; } +PHEAP_ENTRY NTAPI +RtlpSplitEntry(PHEAP Heap, + PHEAP_FREE_ENTRY FreeBlock, + SIZE_T AllocationSize, + SIZE_T Index, + SIZE_T Size) +{ + PHEAP_FREE_ENTRY SplitBlock, SplitBlock2; + UCHAR FreeFlags; + PHEAP_ENTRY InUseEntry; + SIZE_T FreeSize; + + /* Save flags, update total free size */ + FreeFlags = FreeBlock->Flags; + Heap->TotalFreeSize -= FreeBlock->Size; + + /* Make this block an in-use one */ + InUseEntry = (PHEAP_ENTRY)FreeBlock; + InUseEntry->Flags = HEAP_ENTRY_BUSY; + InUseEntry->SmallTagIndex = 0; + + /* Calculate the extra amount */ + FreeSize = InUseEntry->Size - Index; + + /* Update it's size fields (we don't need their data anymore) */ + InUseEntry->Size = Index; + InUseEntry->UnusedBytes = AllocationSize - Size; + + /* If there is something to split - do the split */ + if (FreeSize != 0) + { + /* Don't split if resulting entry can't contain any payload data + (i.e. being just HEAP_ENTRY_SIZE) */ + if (FreeSize == 1) + { + /* Increase sizes of the in-use entry */ + InUseEntry->Size++; + InUseEntry->UnusedBytes += sizeof(HEAP_ENTRY); + } + else + { + /* Calculate a pointer to the new entry */ + SplitBlock = (PHEAP_FREE_ENTRY)(InUseEntry + Index); + + /* Initialize it */ + SplitBlock->Flags = FreeFlags; + SplitBlock->SegmentOffset = InUseEntry->SegmentOffset; + SplitBlock->Size = FreeSize; + SplitBlock->PreviousSize = Index; + + /* Check if it's the last entry */ + if (FreeFlags & HEAP_ENTRY_LAST_ENTRY) + { + /* Insert it to the free list if it's the last entry */ + RtlpInsertFreeBlockHelper(Heap, SplitBlock, FreeSize, FALSE); + Heap->TotalFreeSize += FreeSize; + } + else + { + /* Not so easy - need to update next's previous size too */ + SplitBlock2 = (PHEAP_FREE_ENTRY)((PHEAP_ENTRY)SplitBlock + FreeSize); + + if (SplitBlock2->Flags & HEAP_ENTRY_BUSY) + { + SplitBlock2->PreviousSize = (USHORT)FreeSize; + RtlpInsertFreeBlockHelper(Heap, SplitBlock, FreeSize, FALSE); + Heap->TotalFreeSize += FreeSize; + } + else + { + /* Even more complex - the next entry is free, so we can merge them into one! */ + SplitBlock->Flags = SplitBlock2->Flags; + + /* Remove that next entry */ + RtlpRemoveFreeBlock(Heap, SplitBlock2, FALSE, FALSE); + + /* Update sizes */ + FreeSize += SplitBlock2->Size; + Heap->TotalFreeSize -= SplitBlock2->Size; + + if (FreeSize <= HEAP_MAX_BLOCK_SIZE) + { + /* Insert it back */ + SplitBlock->Size = FreeSize; + + /* Don't forget to update previous size of the next entry! */ + if (!(SplitBlock->Flags & HEAP_ENTRY_LAST_ENTRY)) + { + ((PHEAP_FREE_ENTRY)((PHEAP_ENTRY)SplitBlock + FreeSize))->PreviousSize = FreeSize; + } + + /* Actually insert it */ + RtlpInsertFreeBlockHelper(Heap, SplitBlock, (USHORT)FreeSize, FALSE); + + /* Update total size */ + Heap->TotalFreeSize += FreeSize; + } + else + { + /* Resulting block is quite big */ + RtlpInsertFreeBlock(Heap, SplitBlock, FreeSize); + } + } + } + + /* Reset flags of the free entry */ + FreeFlags = 0; + + /* Update last entry in segment */ + if (SplitBlock->Flags & HEAP_ENTRY_LAST_ENTRY) + { + Heap->Segments[SplitBlock->SegmentOffset]->LastEntryInSegment = (PHEAP_ENTRY)SplitBlock; + } + } + } + + /* Set last entry flag */ + if (FreeFlags & HEAP_ENTRY_LAST_ENTRY) + InUseEntry->Flags |= HEAP_ENTRY_LAST_ENTRY; + + return InUseEntry; +} + +PVOID NTAPI +RtlpAllocateNonDedicated(PHEAP Heap, + ULONG Flags, + SIZE_T Size, + SIZE_T AllocationSize, + SIZE_T Index, + BOOLEAN HeapLocked) +{ + PLIST_ENTRY FreeListHead, Next; + PHEAP_FREE_ENTRY FreeBlock; + PHEAP_ENTRY InUseEntry; + PHEAP_ENTRY_EXTRA Extra; + EXCEPTION_RECORD ExceptionRecord; + + /* Go through the zero list to find a place where to insert the new entry */ + FreeListHead = &Heap->FreeLists[0]; + + /* Start from the largest block to reduce time */ + Next = FreeListHead->Blink; + if (FreeListHead != Next) + { + FreeBlock = CONTAINING_RECORD(Next, HEAP_FREE_ENTRY, FreeList); + + if (FreeBlock->Size >= Index) + { + /* Our request is smaller than the largest entry in the zero list */ + + /* Go through the list to find insertion place */ + Next = FreeListHead->Flink; + while (FreeListHead != Next) + { + FreeBlock = CONTAINING_RECORD(Next, HEAP_FREE_ENTRY, FreeList); + + if (FreeBlock->Size >= Index) + { + /* Found minimally fitting entry. Proceed to either using it as it is + or splitting it to two entries */ + RemoveEntryList(&FreeBlock->FreeList); + + /* Split it */ + InUseEntry = RtlpSplitEntry(Heap, FreeBlock, AllocationSize, Index, Size); + + /* Release the lock */ + if (HeapLocked) RtlLeaveHeapLock(Heap->LockVariable); + + /* Zero memory if that was requested */ + if (Flags & HEAP_ZERO_MEMORY) + RtlZeroMemory(InUseEntry + 1, Size); + else if (Heap->Flags & HEAP_FREE_CHECKING_ENABLED) + { + /* Fill this block with a special pattern */ + RtlFillMemoryUlong(InUseEntry + 1, Size & ~0x3, ARENA_INUSE_FILLER); + } + + /* Fill tail of the block with a special pattern too if requested */ + if (Heap->Flags & HEAP_TAIL_CHECKING_ENABLED) + { + RtlFillMemory((PCHAR)(InUseEntry + 1) + Size, sizeof(HEAP_ENTRY), HEAP_TAIL_FILL); + InUseEntry->Flags |= HEAP_ENTRY_FILL_PATTERN; + } + + /* Prepare extra if it's present */ + if (InUseEntry->Flags & HEAP_ENTRY_EXTRA_PRESENT) + { + Extra = RtlpGetExtraStuffPointer(InUseEntry); + RtlZeroMemory(Extra, sizeof(HEAP_ENTRY_EXTRA)); + + // TODO: Tagging + } + + /* Return pointer to the */ + return InUseEntry + 1; + } + + /* Advance to the next entry */ + Next = Next->Flink; + } + } + } + + /* Extend the heap, 0 list didn't have anything suitable */ + FreeBlock = RtlpExtendHeap(Heap, AllocationSize); + + /* Use the new biggest entry we've got */ + if (FreeBlock) + { + RemoveEntryList(&FreeBlock->FreeList); + + /* Split it */ + InUseEntry = RtlpSplitEntry(Heap, FreeBlock, AllocationSize, Index, Size); + + /* Release the lock */ + if (HeapLocked) RtlLeaveHeapLock(Heap->LockVariable); + + /* Zero memory if that was requested */ + if (Flags & HEAP_ZERO_MEMORY) + RtlZeroMemory(InUseEntry + 1, Size); + else if (Heap->Flags & HEAP_FREE_CHECKING_ENABLED) + { + /* Fill this block with a special pattern */ + RtlFillMemoryUlong(InUseEntry + 1, Size & ~0x3, ARENA_INUSE_FILLER); + } + + /* Fill tail of the block with a special pattern too if requested */ + if (Heap->Flags & HEAP_TAIL_CHECKING_ENABLED) + { + RtlFillMemory((PCHAR)(InUseEntry + 1) + Size, sizeof(HEAP_ENTRY), HEAP_TAIL_FILL); + InUseEntry->Flags |= HEAP_ENTRY_FILL_PATTERN; + } + + /* Prepare extra if it's present */ + if (InUseEntry->Flags & HEAP_ENTRY_EXTRA_PRESENT) + { + Extra = RtlpGetExtraStuffPointer(InUseEntry); + RtlZeroMemory(Extra, sizeof(HEAP_ENTRY_EXTRA)); + + // TODO: Tagging + } + + /* Return pointer to the */ + return InUseEntry + 1; + } + + /* Really unfortunate, out of memory condition */ + RtlSetLastWin32ErrorAndNtStatusFromNtStatus(STATUS_NO_MEMORY); + + /* Generate an exception */ + if (Flags & HEAP_GENERATE_EXCEPTIONS) + { + ExceptionRecord.ExceptionCode = STATUS_NO_MEMORY; + ExceptionRecord.ExceptionRecord = NULL; + ExceptionRecord.NumberParameters = 1; + ExceptionRecord.ExceptionFlags = 0; + ExceptionRecord.ExceptionInformation[0] = AllocationSize; + + RtlRaiseException(&ExceptionRecord); + } + + /* Release the lock */ + if (HeapLocked) RtlLeaveHeapLock(Heap->LockVariable); + DPRINT1("HEAP: Allocation failed!\n"); + DPRINT1("Flags %x\n", Heap->Flags); + return NULL; +} /*********************************************************************** * HeapAlloc (KERNEL32.334) @@ -1252,77 +2070,223 @@ RtlDestroyHeap(HANDLE heap) /* [in] Handle of heap */ * @implemented */ PVOID NTAPI -RtlAllocateHeap(HANDLE heap, /* [in] Handle of private heap block */ - ULONG flags, /* [in] Heap allocation control flags */ - SIZE_T size) /* [in] Number of bytes to allocate */ +RtlAllocateHeap(IN PVOID HeapPtr, + IN ULONG Flags, + IN SIZE_T Size) { - ARENA_FREE *pArena; - ARENA_INUSE *pInUse; - SUBHEAP *subheap; - HEAP *heapPtr = HEAP_GetPtr( heap ); - SIZE_T rounded_size; + PHEAP Heap = (PHEAP)HeapPtr; + PULONG FreeListsInUse; + ULONG FreeListsInUseUlong; + SIZE_T AllocationSize; + SIZE_T Index; + PLIST_ENTRY FreeListHead; + PHEAP_ENTRY InUseEntry; + PHEAP_FREE_ENTRY FreeBlock; + ULONG InUseIndex, i; + UCHAR FreeFlags; + EXCEPTION_RECORD ExceptionRecord; + BOOLEAN HeapLocked = FALSE; + PHEAP_VIRTUAL_ALLOC_ENTRY VirtualBlock = NULL; + PHEAP_ENTRY_EXTRA Extra; + NTSTATUS Status; - /* Validate the parameters */ + /* Force flags */ + Flags |= Heap->ForceFlags; - if (!heapPtr) - { - if (flags & HEAP_GENERATE_EXCEPTIONS) - RtlRaiseStatus( STATUS_NO_MEMORY ); - return NULL; - } - //flags &= HEAP_GENERATE_EXCEPTIONS | HEAP_NO_SERIALIZE | HEAP_ZERO_MEMORY; - flags |= heapPtr->flags; - rounded_size = ROUND_SIZE(size); - if (rounded_size < size) /* overflow */ + /* Call special heap */ + if (RtlpHeapIsSpecial(Flags)) + return RtlDebugAllocateHeap(Heap, Flags, Size); + + /* Check for the maximum size */ + if (Size >= 0x80000000) { - if (flags & HEAP_GENERATE_EXCEPTIONS) RtlRaiseStatus( STATUS_NO_MEMORY ); + RtlSetLastWin32ErrorAndNtStatusFromNtStatus(STATUS_NO_MEMORY); + DPRINT1("HEAP: Allocation failed!\n"); return NULL; } - if (rounded_size < HEAP_MIN_DATA_SIZE) rounded_size = HEAP_MIN_DATA_SIZE; - - if (!(flags & HEAP_NO_SERIALIZE)) RtlEnterHeapLock( &heapPtr->lock ); - /* Locate a suitable free block */ - if (!(pArena = HEAP_FindFreeBlock( heapPtr, rounded_size, &subheap ))) + if (Flags & (HEAP_CREATE_ENABLE_TRACING | + HEAP_CREATE_ALIGN_16)) { - TRACE("(%p,%08lx,%08lx): returning NULL\n", - heap, flags, size ); - if (!(flags & HEAP_NO_SERIALIZE)) RtlLeaveHeapLock( &heapPtr->lock ); - if (flags & HEAP_GENERATE_EXCEPTIONS) RtlRaiseStatus( STATUS_NO_MEMORY ); - return NULL; + DPRINT1("HEAP: RtlAllocateHeap is called with unsupported flags %x, ignoring\n", Flags); } - /* Remove the arena from the free list */ + //DPRINT("RtlAllocateHeap(%p %x %x)\n", Heap, Flags, Size); - list_remove( &pArena->entry ); - - /* Build the in-use arena */ - - pInUse = (ARENA_INUSE *)pArena; - - /* in-use arena is smaller than free arena, - * so we have to add the difference to the size */ - pInUse->size = (pInUse->size & ~ARENA_FLAG_FREE) + sizeof(ARENA_FREE) - sizeof(ARENA_INUSE); - pInUse->magic = ARENA_INUSE_MAGIC; - pInUse->has_user_data = 0; - - /* Shrink the block */ - - HEAP_ShrinkBlock( subheap, pInUse, rounded_size ); - pInUse->unused_bytes = (pInUse->size & ARENA_SIZE_MASK) - size; - - if (flags & HEAP_ZERO_MEMORY) - { - clear_block( pInUse + 1, size ); - mark_block_uninitialized( (char *)(pInUse + 1) + size, pInUse->unused_bytes ); - } + /* Calculate allocation size and index */ + if (Size) + AllocationSize = Size; else - mark_block_uninitialized( pInUse + 1, pInUse->size & ARENA_SIZE_MASK ); + AllocationSize = 1; + AllocationSize = (AllocationSize + Heap->AlignRound) & Heap->AlignMask; + Index = AllocationSize >> HEAP_ENTRY_SHIFT; - if (!(flags & HEAP_NO_SERIALIZE)) RtlLeaveHeapLock( &heapPtr->lock ); + /* Acquire the lock if necessary */ + if (!(Flags & HEAP_NO_SERIALIZE)) + { + RtlEnterHeapLock(Heap->LockVariable); + HeapLocked = TRUE; + } - TRACE("(%p,%08lx,%08lx): returning %p\n", heap, flags, size, pInUse + 1 ); - return (LPVOID)(pInUse + 1); + /* Depending on the size, the allocation is going to be done from dedicated, + non-dedicated lists or a virtual block of memory */ + if (Index < HEAP_FREELISTS) + { + FreeListHead = &Heap->FreeLists[Index]; + + if (!IsListEmpty(FreeListHead)) + { + /* There is a free entry in this list */ + FreeBlock = CONTAINING_RECORD(FreeListHead->Blink, + HEAP_FREE_ENTRY, + FreeList); + + /* Save flags and remove the free entry */ + FreeFlags = FreeBlock->Flags; + RtlpRemoveFreeBlock(Heap, FreeBlock, TRUE, FALSE); + + /* Update the total free size of the heap */ + Heap->TotalFreeSize -= Index; + + /* Initialize this block */ + InUseEntry = (PHEAP_ENTRY)FreeBlock; + InUseEntry->Flags = HEAP_ENTRY_BUSY | (FreeFlags & HEAP_ENTRY_LAST_ENTRY); + InUseEntry->UnusedBytes = AllocationSize - Size; + InUseEntry->SmallTagIndex = 0; + } + else + { + /* Find smallest free block which this request could fit in */ + InUseIndex = Index >> 5; + FreeListsInUse = &Heap->u.FreeListsInUseUlong[InUseIndex]; + + /* This bit magic disables all sizes which are less than the requested allocation size */ + FreeListsInUseUlong = *FreeListsInUse++ & ~((1 << ((ULONG)Index & 0x1f)) - 1); + + /* If size is definitily more than our lists - go directly to the non-dedicated one */ + if (InUseIndex > 3) + return RtlpAllocateNonDedicated(Heap, Flags, Size, AllocationSize, Index, HeapLocked); + + /* Go through the list */ + for (i = InUseIndex; i < 4; i++) + { + if (FreeListsInUseUlong) + { + FreeListHead = &Heap->FreeLists[i * 32]; + break; + } + + if (i < 3) FreeListsInUseUlong = *FreeListsInUse++; + } + + /* Nothing found, search in the non-dedicated list */ + if (i == 4) + return RtlpAllocateNonDedicated(Heap, Flags, Size, AllocationSize, Index, HeapLocked); + + /* That list is found, now calculate exact block */ + FreeListHead += RtlpFindLeastSetBit(FreeListsInUseUlong); + + /* Take this entry and remove it from the list of free blocks */ + FreeBlock = CONTAINING_RECORD(FreeListHead->Blink, + HEAP_FREE_ENTRY, + FreeList); + RtlpRemoveFreeBlock(Heap, FreeBlock, TRUE, FALSE); + + /* Split it */ + InUseEntry = RtlpSplitEntry(Heap, FreeBlock, AllocationSize, Index, Size); + } + + /* Release the lock */ + if (HeapLocked) RtlLeaveHeapLock(Heap->LockVariable); + + /* Zero memory if that was requested */ + if (Flags & HEAP_ZERO_MEMORY) + RtlZeroMemory(InUseEntry + 1, Size); + else if (Heap->Flags & HEAP_FREE_CHECKING_ENABLED) + { + /* Fill this block with a special pattern */ + RtlFillMemoryUlong(InUseEntry + 1, Size & ~0x3, ARENA_INUSE_FILLER); + } + + /* Fill tail of the block with a special pattern too if requested */ + if (Heap->Flags & HEAP_TAIL_CHECKING_ENABLED) + { + RtlFillMemory((PCHAR)(InUseEntry + 1) + Size, sizeof(HEAP_ENTRY), HEAP_TAIL_FILL); + InUseEntry->Flags |= HEAP_ENTRY_FILL_PATTERN; + } + + /* Prepare extra if it's present */ + if (InUseEntry->Flags & HEAP_ENTRY_EXTRA_PRESENT) + { + Extra = RtlpGetExtraStuffPointer(InUseEntry); + RtlZeroMemory(Extra, sizeof(HEAP_ENTRY_EXTRA)); + + // TODO: Tagging + } + + /* User data starts right after the entry's header */ + return InUseEntry + 1; + } + else if (Index <= Heap->VirtualMemoryThreshold) + { + /* The block is too large for dedicated lists, but fine for a non-dedicated one */ + return RtlpAllocateNonDedicated(Heap, Flags, Size, AllocationSize, Index, HeapLocked); + } + else if (Heap->Flags & HEAP_GROWABLE) + { + /* We've got a very big allocation request, satisfy it by directly allocating virtual memory */ + AllocationSize += sizeof(HEAP_VIRTUAL_ALLOC_ENTRY) - sizeof(HEAP_ENTRY); + + Status = ZwAllocateVirtualMemory(NtCurrentProcess(), + (PVOID *)&VirtualBlock, + 0, + &AllocationSize, + MEM_COMMIT, + PAGE_READWRITE); + + if (!NT_SUCCESS(Status)) + { + // Set STATUS! + /* Release the lock */ + if (HeapLocked) RtlLeaveHeapLock(Heap->LockVariable); + DPRINT1("HEAP: Allocation failed!\n"); + return NULL; + } + + /* Initialize the newly allocated block */ + VirtualBlock->BusyBlock.Size = (AllocationSize - Size); + VirtualBlock->BusyBlock.Flags = HEAP_ENTRY_VIRTUAL_ALLOC | HEAP_ENTRY_EXTRA_PRESENT | HEAP_ENTRY_BUSY; + VirtualBlock->CommitSize = AllocationSize; + VirtualBlock->ReserveSize = AllocationSize; + + /* Insert it into the list of virtual allocations */ + InsertTailList(&Heap->VirtualAllocdBlocks, &VirtualBlock->Entry); + + /* Release the lock */ + if (HeapLocked) RtlLeaveHeapLock(Heap->LockVariable); + + /* Return pointer to user data */ + return VirtualBlock + 1; + } + + /* Generate an exception */ + if (Flags & HEAP_GENERATE_EXCEPTIONS) + { + ExceptionRecord.ExceptionCode = STATUS_NO_MEMORY; + ExceptionRecord.ExceptionRecord = NULL; + ExceptionRecord.NumberParameters = 1; + ExceptionRecord.ExceptionFlags = 0; + ExceptionRecord.ExceptionInformation[0] = AllocationSize; + + RtlRaiseException(&ExceptionRecord); + } + + RtlSetLastWin32ErrorAndNtStatusFromNtStatus(STATUS_BUFFER_TOO_SMALL); + + /* Release the lock */ + if (HeapLocked) RtlLeaveHeapLock(Heap->LockVariable); + DPRINT1("HEAP: Allocation failed!\n"); + return NULL; } @@ -1335,57 +2299,386 @@ RtlAllocateHeap(HANDLE heap, /* [in] Handle of private heap block */ * @implemented */ BOOLEAN NTAPI RtlFreeHeap( - HANDLE heap, /* [in] Handle of heap */ - ULONG flags, /* [in] Heap freeing flags */ - PVOID ptr /* [in] Address of memory to free */ + HANDLE HeapPtr, /* [in] Handle of heap */ + ULONG Flags, /* [in] Heap freeing flags */ + PVOID Ptr /* [in] Address of memory to free */ ) { - ARENA_INUSE *pInUse; - SUBHEAP *subheap; - HEAP *heapPtr; + PHEAP Heap; + PHEAP_ENTRY HeapEntry; + USHORT TagIndex = 0; + SIZE_T BlockSize; + PHEAP_VIRTUAL_ALLOC_ENTRY VirtualEntry; + BOOLEAN Locked = FALSE; + NTSTATUS Status; - /* Validate the parameters */ + /* Freeing NULL pointer is a legal operation */ + if (!Ptr) return TRUE; - if (!ptr) return TRUE; /* freeing a NULL ptr isn't an error in Win2k */ + /* Get pointer to the heap and force flags */ + Heap = (PHEAP)HeapPtr; + Flags |= Heap->ForceFlags; - heapPtr = HEAP_GetPtr( heap ); - if (!heapPtr) + /* Call special heap */ + if (RtlpHeapIsSpecial(Flags)) + return RtlDebugFreeHeap(Heap, Flags, Ptr); + + /* Lock if necessary */ + if (!(Flags & HEAP_NO_SERIALIZE)) { - RtlSetLastWin32ErrorAndNtStatusFromNtStatus( STATUS_INVALID_HANDLE ); + RtlEnterHeapLock(Heap->LockVariable); + Locked = TRUE; + } + + /* Get pointer to the heap entry */ + HeapEntry = (PHEAP_ENTRY)Ptr - 1; + + /* Check this entry, fail if it's invalid */ + if (!(HeapEntry->Flags & HEAP_ENTRY_BUSY) || + (((ULONG_PTR)Ptr & 0x7) != 0) || + (HeapEntry->SegmentOffset >= HEAP_SEGMENTS)) + { + /* This is an invalid block */ + DPRINT1("HEAP: Trying to free an invalid address %p!\n", Ptr); + RtlSetLastWin32ErrorAndNtStatusFromNtStatus(STATUS_INVALID_PARAMETER); + + /* Release the heap lock */ + if (Locked) RtlLeaveHeapLock(Heap->LockVariable); return FALSE; } - flags &= HEAP_NO_SERIALIZE; - flags |= heapPtr->flags; - if (!(flags & HEAP_NO_SERIALIZE)) RtlEnterHeapLock( &heapPtr->lock ); - if (!HEAP_IsRealArena( heapPtr, HEAP_NO_SERIALIZE, ptr, QUIET )) + if (HeapEntry->Flags & HEAP_ENTRY_VIRTUAL_ALLOC) { - if (!(flags & HEAP_NO_SERIALIZE)) RtlLeaveHeapLock( &heapPtr->lock ); - RtlSetLastWin32ErrorAndNtStatusFromNtStatus( STATUS_INVALID_PARAMETER ); - TRACE("(%p,%08lx,%p): returning FALSE\n", heap, flags, ptr ); - return FALSE; + /* Big allocation */ + VirtualEntry = CONTAINING_RECORD(HeapEntry, HEAP_VIRTUAL_ALLOC_ENTRY, BusyBlock); + + /* Remove it from the list */ + RemoveEntryList(&VirtualEntry->Entry); + + // TODO: Tagging + + BlockSize = 0; + Status = ZwFreeVirtualMemory(NtCurrentProcess(), + (PVOID *)&VirtualEntry, + &BlockSize, + MEM_RELEASE); + + if (!NT_SUCCESS(Status)) + { + DPRINT1("HEAP: Failed releasing memory with Status 0x%08X. Heap %p, ptr %p, base address %p\n", + Status, Heap, Ptr, VirtualEntry); + RtlSetLastWin32ErrorAndNtStatusFromNtStatus(Status); + } + } + else + { + /* Normal allocation */ + BlockSize = HeapEntry->Size; + + // TODO: Tagging + + /* Coalesce in kernel mode, and in usermode if it's not disabled */ + if (RtlpGetMode() == KernelMode || + (RtlpGetMode() == UserMode && !(Heap->Flags & HEAP_DISABLE_COALESCE_ON_FREE))) + { + HeapEntry = (PHEAP_ENTRY)RtlpCoalesceFreeBlocks(Heap, + (PHEAP_FREE_ENTRY)HeapEntry, + &BlockSize, + FALSE); + } + + /* If there is no need to decommit the block - put it into a free list */ + if (BlockSize < Heap->DeCommitFreeBlockThreshold || + (Heap->TotalFreeSize + BlockSize < Heap->DeCommitTotalFreeThreshold)) + { + /* Check if it needs to go to a 0 list */ + if (BlockSize > HEAP_MAX_BLOCK_SIZE) + { + /* General-purpose 0 list */ + RtlpInsertFreeBlock(Heap, (PHEAP_FREE_ENTRY)HeapEntry, BlockSize); + } + else + { + /* Usual free list */ + RtlpInsertFreeBlockHelper(Heap, (PHEAP_FREE_ENTRY)HeapEntry, BlockSize, FALSE); + + /* Assert sizes are consistent */ + if (!(HeapEntry->Flags & HEAP_ENTRY_LAST_ENTRY)) + { + ASSERT((HeapEntry + BlockSize)->PreviousSize == BlockSize); + } + + /* Increase the free size */ + Heap->TotalFreeSize += BlockSize; + } + + + if (RtlpGetMode() == UserMode && + TagIndex != 0) + { + // FIXME: Tagging + UNIMPLEMENTED; + } + } + else + { + /* Decommit this block */ + RtlpDeCommitFreeBlock(Heap, (PHEAP_FREE_ENTRY)HeapEntry, BlockSize); + } } - /* Some sanity checks */ - pInUse = (ARENA_INUSE *)ptr - 1; - subheap = HEAP_FindSubHeap( heapPtr, pInUse ); - if ((char *)pInUse < (char *)subheap + subheap->headerSize) goto error; - if (!HEAP_ValidateInUseArena( subheap, pInUse, QUIET )) goto error; + /* Release the heap lock */ + if (Locked) RtlLeaveHeapLock(Heap->LockVariable); - /* Turn the block into a free block */ - - HEAP_MakeInUseBlockFree( subheap, pInUse ); - - if (!(flags & HEAP_NO_SERIALIZE)) RtlLeaveHeapLock( &heapPtr->lock ); - - TRACE("(%p,%08lx,%p): returning TRUE\n", heap, flags, ptr ); return TRUE; +} -error: - if (!(flags & HEAP_NO_SERIALIZE)) RtlLeaveHeapLock( &heapPtr->lock ); - RtlSetLastWin32ErrorAndNtStatusFromNtStatus( STATUS_INVALID_PARAMETER ); - TRACE("(%p,%08x,%p): returning FALSE\n", heap, flags, ptr ); - return FALSE; +BOOLEAN NTAPI +RtlpGrowBlockInPlace (IN PHEAP Heap, + IN ULONG Flags, + IN PHEAP_ENTRY InUseEntry, + IN SIZE_T Size, + IN SIZE_T Index) +{ + UCHAR EntryFlags, RememberFlags; + PHEAP_FREE_ENTRY FreeEntry, UnusedEntry, FollowingEntry; + SIZE_T FreeSize, PrevSize, TailPart, AddedSize = 0; + PHEAP_ENTRY_EXTRA OldExtra, NewExtra; + + /* We can't grow beyond specified threshold */ + if (Index > Heap->VirtualMemoryThreshold) + return FALSE; + + /* Get entry flags */ + EntryFlags = InUseEntry->Flags; + + /* Get the next free entry */ + FreeEntry = (PHEAP_FREE_ENTRY)(InUseEntry + InUseEntry->Size); + + if (EntryFlags & HEAP_ENTRY_LAST_ENTRY) + { + /* There is no next block, just uncommitted space. Calculate how much is needed */ + FreeSize = (Index - InUseEntry->Size) << HEAP_ENTRY_SHIFT; + FreeSize = ROUND_UP(FreeSize, PAGE_SIZE); + + /* Find and commit those pages */ + FreeEntry = RtlpFindAndCommitPages(Heap, + Heap->Segments[InUseEntry->SegmentOffset], + &FreeSize, + FreeEntry); + + /* Fail if it failed... */ + if (!FreeEntry) return FALSE; + + /* It was successful, perform coalescing */ + FreeSize = FreeSize >> HEAP_ENTRY_SHIFT; + FreeEntry = RtlpCoalesceFreeBlocks(Heap, FreeEntry, &FreeSize, FALSE); + + /* Check if it's enough */ + if (FreeSize + InUseEntry->Size < Index) + { + /* Still not enough */ + RtlpInsertFreeBlock(Heap, FreeEntry, FreeSize); + Heap->TotalFreeSize += FreeSize; + return FALSE; + } + + /* Remember flags of this free entry */ + RememberFlags = FreeEntry->Flags; + + /* Sum up sizes */ + FreeSize += InUseEntry->Size; + } + else + { + /* The next block indeed exists. Check if it's free or in use */ + if (FreeEntry->Flags & HEAP_ENTRY_BUSY) return FALSE; + + /* Next entry is free, check if it can fit the block we need */ + FreeSize = InUseEntry->Size + FreeEntry->Size; + if (FreeSize < Index) return FALSE; + + /* Remember flags of this free entry */ + RememberFlags = FreeEntry->Flags; + + /* Remove this block from the free list */ + RtlpRemoveFreeBlock(Heap, FreeEntry, FALSE, FALSE); + Heap->TotalFreeSize -= FreeEntry->Size; + } + + PrevSize = (InUseEntry->Size << HEAP_ENTRY_SHIFT) - InUseEntry->UnusedBytes; + FreeSize -= Index; + + /* Don't produce too small blocks */ + if (FreeSize <= 2) + { + Index += FreeSize; + FreeSize = 0; + } + + /* Process extra stuff */ + if (RememberFlags & HEAP_ENTRY_EXTRA_PRESENT) + { + /* Calculate pointers */ + OldExtra = (PHEAP_ENTRY_EXTRA)(InUseEntry + InUseEntry->Size - 1); + NewExtra = (PHEAP_ENTRY_EXTRA)(InUseEntry + Index - 1); + + /* Copy contents */ + *NewExtra = *OldExtra; + + // FIXME Tagging + } + + /* Update sizes */ + InUseEntry->Size = Index; + InUseEntry->UnusedBytes = ((Index << HEAP_ENTRY_SHIFT) - Size); + + /* Check if there is a free space remaining after merging those blocks */ + if (!FreeSize) + { + /* Update flags and sizes */ + InUseEntry->Flags |= RememberFlags & HEAP_ENTRY_LAST_ENTRY; + + /* Either update previous size of the next entry or mark it as a last + entry in the segment*/ + if (RememberFlags & HEAP_ENTRY_LAST_ENTRY) + Heap->Segments[InUseEntry->SegmentOffset]->LastEntryInSegment = InUseEntry; + else + (InUseEntry + InUseEntry->Size)->PreviousSize = InUseEntry->Size; + } + else + { + /* Complex case, we need to split the block to give unused free space + back to the heap */ + UnusedEntry = (PHEAP_FREE_ENTRY)(InUseEntry + Index); + UnusedEntry->PreviousSize = Index; + UnusedEntry->SegmentOffset = InUseEntry->SegmentOffset; + + /* Update the following block or set the last entry in the segment */ + if (RememberFlags & HEAP_ENTRY_LAST_ENTRY) + { + /* Set last entry and set flags and size */ + Heap->Segments[InUseEntry->SegmentOffset]->LastEntryInSegment = InUseEntry; + UnusedEntry->Flags = RememberFlags; + UnusedEntry->Size = FreeSize; + + /* Insert it to the heap and update total size */ + RtlpInsertFreeBlockHelper(Heap, UnusedEntry, FreeSize, FALSE); + Heap->TotalFreeSize += FreeSize; + } + else + { + /* There is a block after this one */ + FollowingEntry = (PHEAP_FREE_ENTRY)((PHEAP_ENTRY)UnusedEntry + FreeSize); + + if (FollowingEntry->Flags & HEAP_ENTRY_BUSY) + { + /* Update flags and set size of the unused space entry */ + UnusedEntry->Flags = RememberFlags & (~HEAP_ENTRY_LAST_ENTRY); + UnusedEntry->Size = FreeSize; + + /* Update previous size of the following entry */ + FollowingEntry->PreviousSize = FreeSize; + + /* Insert it to the heap and update total free size */ + RtlpInsertFreeBlockHelper(Heap, UnusedEntry, FreeSize, FALSE); + Heap->TotalFreeSize += FreeSize; + } + else + { + /* That following entry is also free, what a fortune! */ + RememberFlags = FollowingEntry->Flags; + + /* Remove it */ + RtlpRemoveFreeBlock(Heap, FollowingEntry, FALSE, FALSE); + Heap->TotalFreeSize -= FollowingEntry->Size; + + /* And make up a new combined block */ + FreeSize += FollowingEntry->Size; + UnusedEntry->Flags = RememberFlags; + + /* Check where to put it */ + if (FreeSize <= HEAP_MAX_BLOCK_SIZE) + { + /* Fine for a dedicated list */ + UnusedEntry->Size = FreeSize; + + if (RememberFlags & HEAP_ENTRY_LAST_ENTRY) + Heap->Segments[UnusedEntry->SegmentOffset]->LastEntryInSegment = (PHEAP_ENTRY)UnusedEntry; + else + ((PHEAP_ENTRY)UnusedEntry + FreeSize)->PreviousSize = FreeSize; + + /* Insert it back and update total size */ + RtlpInsertFreeBlockHelper(Heap, UnusedEntry, FreeSize, FALSE); + Heap->TotalFreeSize += FreeSize; + } + else + { + /* The block is very large, leave all the hassle to the insertion routine */ + RtlpInsertFreeBlock(Heap, UnusedEntry, FreeSize); + } + } + } + } + + /* Copy user settable flags */ + InUseEntry->Flags &= ~HEAP_ENTRY_SETTABLE_FLAGS; + InUseEntry->Flags |= ((Flags & HEAP_SETTABLE_USER_FLAGS) >> 4); + + /* Properly "zero out" (and fill!) the space */ + if (Flags & HEAP_ZERO_MEMORY) + { + RtlZeroMemory((PCHAR)(InUseEntry + 1) + PrevSize, Size - PrevSize); + } + else if (Heap->Flags & HEAP_FREE_CHECKING_ENABLED) + { + /* Calculate tail part which we need to fill */ + TailPart = PrevSize & (sizeof(ULONG) - 1); + + /* "Invert" it as usual */ + if (TailPart) TailPart = 4 - TailPart; + + if (Size > (PrevSize + TailPart)) + AddedSize = (Size - (PrevSize + TailPart)) & ~(sizeof(ULONG) - 1); + + if (AddedSize) + { + RtlFillMemoryUlong((PCHAR)(InUseEntry + 1) + PrevSize + TailPart, + AddedSize, + ARENA_INUSE_FILLER); + } + } + + /* Fill the new tail */ + if (Heap->Flags & HEAP_TAIL_CHECKING_ENABLED) + { + RtlFillMemory((PCHAR)(InUseEntry + 1) + Size, + HEAP_ENTRY_SIZE, + HEAP_TAIL_FILL); + } + + /* Return success */ + return TRUE; +} + +PHEAP_ENTRY_EXTRA NTAPI +RtlpGetExtraStuffPointer(PHEAP_ENTRY HeapEntry) +{ + PHEAP_VIRTUAL_ALLOC_ENTRY VirtualEntry; + + /* Check if it's a big block */ + if (HeapEntry->Flags & HEAP_ENTRY_VIRTUAL_ALLOC) + { + VirtualEntry = CONTAINING_RECORD(HeapEntry, HEAP_VIRTUAL_ALLOC_ENTRY, BusyBlock); + + /* Return a pointer to the extra stuff*/ + return &VirtualEntry->ExtraStuff; + } + else + { + /* This is a usual entry, which means extra stuff follows this block */ + return (PHEAP_ENTRY_EXTRA)(HeapEntry + HeapEntry->Size - 1); + } } @@ -1403,129 +2696,411 @@ error: * 0x7d030f60--invalid flags in RtlHeapAllocate * @implemented */ -PVOID NTAPI RtlReAllocateHeap( - HANDLE heap, - ULONG flags, - PVOID ptr, - SIZE_T size -) +PVOID NTAPI +RtlReAllocateHeap(HANDLE HeapPtr, + ULONG Flags, + PVOID Ptr, + SIZE_T Size) { - ARENA_INUSE *pArena; - HEAP *heapPtr; - SUBHEAP *subheap; - SIZE_T oldBlockSize, oldActualSize, rounded_size; + PHEAP Heap = (PHEAP)HeapPtr; + PHEAP_ENTRY InUseEntry, NewInUseEntry; + PHEAP_ENTRY_EXTRA OldExtra, NewExtra; + SIZE_T AllocationSize, FreeSize, DecommitSize; + BOOLEAN HeapLocked = FALSE; + PVOID NewBaseAddress; + PHEAP_FREE_ENTRY SplitBlock, SplitBlock2; + SIZE_T OldSize, Index, OldIndex; + UCHAR FreeFlags; + NTSTATUS Status; + PVOID DecommitBase; + SIZE_T RemainderBytes, ExtraSize; + PHEAP_VIRTUAL_ALLOC_ENTRY VirtualAllocBlock; + EXCEPTION_RECORD ExceptionRecord; - if (!ptr) return NULL; - if (!(heapPtr = HEAP_GetPtr( heap ))) + /* Return success in case of a null pointer */ + if (!Ptr) { - RtlSetLastWin32ErrorAndNtStatusFromNtStatus( STATUS_INVALID_HANDLE ); + RtlSetLastWin32ErrorAndNtStatusFromNtStatus(STATUS_SUCCESS); return NULL; } - /* Validate the parameters */ + /* Force heap flags */ + Flags |= Heap->ForceFlags; - //Flags &= HEAP_GENERATE_EXCEPTIONS | HEAP_NO_SERIALIZE | HEAP_ZERO_MEMORY | - // HEAP_REALLOC_IN_PLACE_ONLY; - flags |= heapPtr->flags; - if (!(flags & HEAP_NO_SERIALIZE)) RtlEnterHeapLock( &heapPtr->lock ); + /* Call special heap */ + if (RtlpHeapIsSpecial(Flags)) + return RtlDebugReAllocateHeap(Heap, Flags, Ptr, Size); - rounded_size = ROUND_SIZE(size); - if (rounded_size < size) goto oom; /* overflow */ - if (rounded_size < HEAP_MIN_DATA_SIZE) rounded_size = HEAP_MIN_DATA_SIZE; - - pArena = (ARENA_INUSE *)ptr - 1; - if(!(subheap = HEAP_FindSubHeap( heapPtr, pArena ))) goto done; - if ((char *)pArena < (char *)subheap + subheap->headerSize) goto error; - if (!HEAP_ValidateInUseArena( subheap, pArena, QUIET )) goto error; - - oldBlockSize = (pArena->size & ARENA_SIZE_MASK); - oldActualSize = (pArena->size & ARENA_SIZE_MASK) - pArena->unused_bytes; - - if (rounded_size > oldBlockSize) + /* Make sure size is valid */ + if (Size >= 0x80000000) { - char *pNext = (char *)(pArena + 1) + oldBlockSize; - if ((pNext < (char *)subheap + subheap->size) && - (*(DWORD *)pNext & ARENA_FLAG_FREE) && - (oldBlockSize + (*(DWORD *)pNext & ARENA_SIZE_MASK) + sizeof(ARENA_FREE) >= rounded_size)) + RtlSetLastWin32ErrorAndNtStatusFromNtStatus(STATUS_NO_MEMORY); + return NULL; + } + + /* Calculate allocation size and index */ + if (Size) + AllocationSize = Size; + else + AllocationSize = 1; + AllocationSize = (AllocationSize + Heap->AlignRound) & Heap->AlignMask; + + /* Add up extra stuff, if it is present anywhere */ + if (((((PHEAP_ENTRY)Ptr)-1)->Flags & HEAP_ENTRY_EXTRA_PRESENT) || + (Flags & HEAP_EXTRA_FLAGS_MASK) || + Heap->PseudoTagEntries) + { + AllocationSize += sizeof(HEAP_ENTRY_EXTRA); + } + + /* Acquire the lock if necessary */ + if (!(Flags & HEAP_NO_SERIALIZE)) + { + RtlEnterHeapLock(Heap->LockVariable); + HeapLocked = TRUE; + Flags ^= HEAP_NO_SERIALIZE; + } + + /* Get the pointer to the in-use entry */ + InUseEntry = (PHEAP_ENTRY)Ptr - 1; + + /* If that entry is not really in-use, we have a problem */ + if (!(InUseEntry->Flags & HEAP_ENTRY_BUSY)) + { + RtlSetLastWin32ErrorAndNtStatusFromNtStatus(STATUS_INVALID_PARAMETER); + + /* Release the lock and return */ + if (HeapLocked) + RtlLeaveHeapLock(Heap->LockVariable); + return Ptr; + } + + if (InUseEntry->Flags & HEAP_ENTRY_VIRTUAL_ALLOC) + { + /* This is a virtually allocated block. Get its size */ + OldSize = RtlpGetSizeOfBigBlock(InUseEntry); + + /* Convert it to an index */ + OldIndex = (OldSize + InUseEntry->Size) >> HEAP_ENTRY_SHIFT; + + /* Calculate new allocation size and round it to the page size */ + AllocationSize += FIELD_OFFSET(HEAP_VIRTUAL_ALLOC_ENTRY, BusyBlock); + AllocationSize = ROUND_UP(AllocationSize, PAGE_SIZE); + } + else + { + /* Usual entry */ + OldIndex = InUseEntry->Size; + + OldSize = (OldIndex << HEAP_ENTRY_SHIFT) - InUseEntry->UnusedBytes; + } + + /* Calculate new index */ + Index = AllocationSize >> HEAP_ENTRY_SHIFT; + + /* Check for 4 different scenarios (old size, new size, old index, new index) */ + if (Index <= OldIndex) + { + /* Difference must be greater than 1, adjust if it's not so */ + if (Index + 1 == OldIndex) { - ARENA_FREE *pFree = (ARENA_FREE *)pNext; - list_remove( &pFree->entry ); - pArena->size += (pFree->size & ARENA_SIZE_MASK) + sizeof(*pFree); - - if (!HEAP_Commit( subheap, pArena, rounded_size )) goto oom; - - HEAP_ShrinkBlock( subheap, pArena, rounded_size ); - mark_block_initialized( pArena + 1, oldActualSize ); + Index++; + AllocationSize += sizeof(HEAP_ENTRY); } - else /* Do it the hard way */ + + /* Calculate new size */ + if (InUseEntry->Flags & HEAP_ENTRY_VIRTUAL_ALLOC) { - ARENA_FREE *pNew; - ARENA_INUSE *pInUse; - SUBHEAP *newsubheap; - if ((flags & HEAP_REALLOC_IN_PLACE_ONLY) || - !(pNew = HEAP_FindFreeBlock( heapPtr, rounded_size, &newsubheap ))) - goto oom; + /* Simple in case of a virtual alloc - just an unused size */ + InUseEntry->Size = AllocationSize - Size; + } + else if (InUseEntry->Flags & HEAP_ENTRY_EXTRA_PRESENT) + { + /* There is extra stuff, take it into account */ + OldExtra = (PHEAP_ENTRY_EXTRA)(InUseEntry + InUseEntry->Size - 1); + NewExtra = (PHEAP_ENTRY_EXTRA)(InUseEntry + Index - 1); + *NewExtra = *OldExtra; - /* Build the in-use arena */ + // FIXME Tagging, TagIndex - list_remove( &pNew->entry ); - pInUse = (ARENA_INUSE *)pNew; - pInUse->size = (pInUse->size & ~ARENA_FLAG_FREE) - + sizeof(ARENA_FREE) - sizeof(ARENA_INUSE); - pInUse->magic = ARENA_INUSE_MAGIC; - HEAP_ShrinkBlock( newsubheap, pInUse, rounded_size ); + /* Update unused bytes count */ + InUseEntry->UnusedBytes = AllocationSize - Size; + } + else + { + // FIXME Tagging, SmallTagIndex + InUseEntry->UnusedBytes = AllocationSize - Size; + } - mark_block_initialized( pInUse + 1, oldActualSize ); - memcpy( pInUse + 1, pArena + 1, oldActualSize ); + /* If new size is bigger than the old size */ + if (Size > OldSize) + { + /* Zero out that additional space if required */ + if (Flags & HEAP_ZERO_MEMORY) + { + RtlZeroMemory((PCHAR)Ptr + OldSize, Size - OldSize); + } + else if (Heap->Flags & HEAP_FREE_CHECKING_ENABLED) + { + /* Fill it on free if required */ + RemainderBytes = OldSize & (sizeof(ULONG) - 1); - /* Free the previous block */ + if (RemainderBytes) + RemainderBytes = 4 - RemainderBytes; - HEAP_MakeInUseBlockFree( subheap, pArena ); - subheap = newsubheap; - pArena = pInUse; + if (Size > (OldSize + RemainderBytes)) + { + /* Calculate actual amount of extra bytes to fill */ + ExtraSize = (Size - (OldSize + RemainderBytes)) & ~(sizeof(ULONG) - 1); + + /* Fill them if there are any */ + if (ExtraSize != 0) + { + RtlFillMemoryUlong((PCHAR)(InUseEntry + 1) + OldSize + RemainderBytes, + ExtraSize, + ARENA_INUSE_FILLER); + } + } + } + } + + /* Fill tail of the heap entry if required */ + if (Heap->Flags & HEAP_TAIL_CHECKING_ENABLED) + { + RtlFillMemory((PCHAR)(InUseEntry + 1) + Size, + HEAP_ENTRY_SIZE, + HEAP_TAIL_FILL); + } + + /* Check if the difference is significant or not */ + if (Index != OldIndex) + { + /* Save flags */ + FreeFlags = InUseEntry->Flags & ~HEAP_ENTRY_BUSY; + + if (FreeFlags & HEAP_ENTRY_VIRTUAL_ALLOC) + { + /* This is a virtual block allocation */ + VirtualAllocBlock = CONTAINING_RECORD(InUseEntry, HEAP_VIRTUAL_ALLOC_ENTRY, BusyBlock); + + // FIXME Tagging! + + DecommitBase = (PCHAR)VirtualAllocBlock + AllocationSize; + DecommitSize = (OldIndex << HEAP_ENTRY_SHIFT) - AllocationSize; + + /* Release the memory */ + Status = ZwFreeVirtualMemory(NtCurrentProcess(), + (PVOID *)&DecommitBase, + &DecommitSize, + MEM_RELEASE); + + if (!NT_SUCCESS(Status)) + { + DPRINT1("HEAP: Unable to release memory (pointer %p, size 0x%x), Status %08x\n", DecommitBase, DecommitSize, Status); + } + else + { + /* Otherwise reduce the commit size */ + VirtualAllocBlock->CommitSize -= DecommitSize; + } + } + else + { + /* Reduce size of the block and possibly split it */ + SplitBlock = (PHEAP_FREE_ENTRY)(InUseEntry + Index); + + /* Initialize this entry */ + SplitBlock->Flags = FreeFlags; + SplitBlock->PreviousSize = Index; + SplitBlock->SegmentOffset = InUseEntry->SegmentOffset; + + /* Remember free size */ + FreeSize = InUseEntry->Size - Index; + + /* Set new size */ + InUseEntry->Size = Index; + InUseEntry->Flags &= ~HEAP_ENTRY_LAST_ENTRY; + + /* Is that the last entry */ + if (FreeFlags & HEAP_ENTRY_LAST_ENTRY) + { + /* Update segment's last entry */ + Heap->Segments[SplitBlock->SegmentOffset]->LastEntryInSegment = (PHEAP_ENTRY)SplitBlock; + + /* Set its size and insert it to the list */ + SplitBlock->Size = (USHORT)FreeSize; + RtlpInsertFreeBlockHelper(Heap, SplitBlock, FreeSize, FALSE); + + /* Update total free size */ + Heap->TotalFreeSize += FreeSize; + } + else + { + /* Get the block after that one */ + SplitBlock2 = (PHEAP_FREE_ENTRY)((PHEAP_ENTRY)SplitBlock + FreeSize); + + if (SplitBlock2->Flags & HEAP_ENTRY_BUSY) + { + /* It's in use, add it here*/ + SplitBlock->Size = (USHORT)FreeSize; + + /* Update previous size of the next entry */ + ((PHEAP_FREE_ENTRY)((PHEAP_ENTRY)SplitBlock + FreeSize))->PreviousSize = (USHORT)FreeSize; + + /* Insert it to the list */ + RtlpInsertFreeBlockHelper(Heap, SplitBlock, FreeSize, FALSE); + + /* Update total size */ + Heap->TotalFreeSize += FreeSize; + } + else + { + /* Next entry is free, so merge with it */ + SplitBlock->Flags = SplitBlock2->Flags; + + /* Remove it, update total size */ + RtlpRemoveFreeBlock(Heap, SplitBlock2, FALSE, FALSE); + Heap->TotalFreeSize -= SplitBlock2->Size; + + /* Calculate total free size */ + FreeSize += SplitBlock2->Size; + + if (FreeSize <= HEAP_MAX_BLOCK_SIZE) + { + SplitBlock->Size = FreeSize; + + if (!(SplitBlock->Flags & HEAP_ENTRY_LAST_ENTRY)) + { + /* Update previous size of the next entry */ + ((PHEAP_FREE_ENTRY)((PHEAP_ENTRY)SplitBlock + FreeSize))->PreviousSize = FreeSize; + } + else + { + Heap->Segments[SplitBlock->SegmentOffset]->LastEntryInSegment = (PHEAP_ENTRY)SplitBlock; + } + + /* Insert the new one back and update total size */ + RtlpInsertFreeBlockHelper(Heap, SplitBlock, FreeSize, FALSE); + Heap->TotalFreeSize += FreeSize; + } + else + { + /* Just add it */ + RtlpInsertFreeBlock(Heap, SplitBlock, FreeSize); + } + } + } + } } } else { - HEAP_ShrinkBlock( subheap, pArena, rounded_size ); /* Shrink the block */ - mark_block_initialized( pArena + 1, size ); - } - - pArena->unused_bytes = (pArena->size & ARENA_SIZE_MASK) - size; - - /* Clear the extra bytes if needed */ - - if (size > oldActualSize) - { - if (flags & HEAP_ZERO_MEMORY) + /* We're growing the block */ + if ((InUseEntry->Flags & HEAP_ENTRY_VIRTUAL_ALLOC) || + !RtlpGrowBlockInPlace(Heap, Flags, InUseEntry, Size, Index)) { - clear_block( (char *)(pArena + 1) + oldActualSize, size - oldActualSize ); - mark_block_uninitialized( (char *)(pArena + 1) + size, - (pArena->size & ARENA_SIZE_MASK) - oldActualSize ); + /* Growing in place failed, so growing out of place */ + if (Flags & HEAP_REALLOC_IN_PLACE_ONLY) + { + DPRINT1("Realloc in place failed, but it was the only option\n"); + Ptr = NULL; + } + else + { + /* Clear tag bits */ + Flags &= ~HEAP_TAG_MASK; + + /* Process extra stuff */ + if (InUseEntry->Flags & HEAP_ENTRY_EXTRA_PRESENT) + { + /* Preserve user settable flags */ + Flags &= ~HEAP_SETTABLE_USER_FLAGS; + + Flags |= HEAP_SETTABLE_USER_VALUE | ((InUseEntry->Flags & HEAP_ENTRY_SETTABLE_FLAGS) << 4); + + /* Get pointer to the old extra data */ + OldExtra = RtlpGetExtraStuffPointer(InUseEntry); + + /* Save tag index if it was set */ + if (OldExtra->TagIndex && + !(OldExtra->TagIndex & HEAP_PSEUDO_TAG_FLAG)) + { + Flags |= OldExtra->TagIndex << HEAP_TAG_SHIFT; + } + } + else if (InUseEntry->SmallTagIndex) + { + /* Take small tag index into account */ + Flags |= InUseEntry->SmallTagIndex << HEAP_TAG_SHIFT; + } + + /* Allocate new block from the heap */ + NewBaseAddress = RtlAllocateHeap(HeapPtr, + Flags & ~HEAP_ZERO_MEMORY, + Size); + + /* Proceed if it didn't fail */ + if (NewBaseAddress) + { + /* Get new entry pointer */ + NewInUseEntry = (PHEAP_ENTRY)NewBaseAddress - 1; + + /* Process extra stuff if it exists */ + if (NewInUseEntry->Flags & HEAP_ENTRY_EXTRA_PRESENT) + { + NewExtra = RtlpGetExtraStuffPointer(NewInUseEntry); + + if (InUseEntry->Flags & HEAP_ENTRY_EXTRA_PRESENT) + { + OldExtra = RtlpGetExtraStuffPointer(InUseEntry); + NewExtra->Settable = OldExtra->Settable; + } + else + { + RtlZeroMemory(NewExtra, sizeof(*NewExtra)); + } + } + + /* Copy actual user bits */ + if (Size < OldSize) + RtlMoveMemory(NewBaseAddress, Ptr, Size); + else + RtlMoveMemory(NewBaseAddress, Ptr, OldSize); + + /* Zero remaining part if required */ + if (Size > OldSize && + (Flags & HEAP_ZERO_MEMORY)) + { + RtlZeroMemory((PCHAR)NewBaseAddress + OldSize, Size - OldSize); + } + + /* Free the old block */ + RtlFreeHeap(HeapPtr, Flags, Ptr); + } + + Ptr = NewBaseAddress; + } } - else - mark_block_uninitialized( (char *)(pArena + 1) + oldActualSize, - (pArena->size & ARENA_SIZE_MASK) - oldActualSize ); } - /* Return the new arena */ -done: - if (!(flags & HEAP_NO_SERIALIZE)) RtlLeaveHeapLock( &heapPtr->lock ); - TRACE("(%p,%08lx,%p,%08lx): returning %p\n", heap, flags, ptr, size, pArena + 1 ); - return (LPVOID)(pArena + 1); + /* Did resizing fail? */ + if (!Ptr && (Flags & HEAP_GENERATE_EXCEPTIONS)) + { + /* Generate an exception if required */ + ExceptionRecord.ExceptionCode = STATUS_NO_MEMORY; + ExceptionRecord.ExceptionRecord = NULL; + ExceptionRecord.NumberParameters = 1; + ExceptionRecord.ExceptionFlags = 0; + ExceptionRecord.ExceptionInformation[0] = AllocationSize; -oom: - if (!(flags & HEAP_NO_SERIALIZE)) RtlLeaveHeapLock( &heapPtr->lock ); - if (flags & HEAP_GENERATE_EXCEPTIONS) RtlRaiseStatus( STATUS_NO_MEMORY ); - RtlSetLastWin32ErrorAndNtStatusFromNtStatus( STATUS_NO_MEMORY ); - TRACE("(%p,%08x,%p,%08lx): returning oom\n", heap, flags, ptr, size ); - return NULL; + RtlRaiseException(&ExceptionRecord); + } -error: - if (!(flags & HEAP_NO_SERIALIZE)) RtlLeaveHeapLock( &heapPtr->lock ); - RtlSetLastWin32ErrorAndNtStatusFromNtStatus( STATUS_INVALID_PARAMETER ); - TRACE("(%p,%08x,%p,%08lx): returning error\n", heap, flags, ptr, size ); - return NULL; + /* Release the heap lock if it was acquired */ + if (HeapLocked) + RtlLeaveHeapLock(Heap->LockVariable); + + return Ptr; } @@ -1557,13 +3132,22 @@ RtlCompactHeap(HANDLE Heap, * @implemented */ BOOLEAN NTAPI -RtlLockHeap(IN HANDLE Heap) +RtlLockHeap(IN HANDLE HeapPtr) { - HEAP *heapPtr = HEAP_GetPtr( Heap ); - if (!heapPtr) - return FALSE; - RtlEnterHeapLock( &heapPtr->lock ); - return TRUE; + PHEAP Heap = (PHEAP)HeapPtr; + + // FIXME Check for special heap + + /* Check if it's really a heap */ + if (Heap->Signature != HEAP_SIGNATURE) return FALSE; + + /* Lock if it's lockable */ + if (!(Heap->Flags & HEAP_NO_SERIALIZE)) + { + RtlEnterHeapLock(Heap->LockVariable); + } + + return TRUE; } @@ -1581,13 +3165,22 @@ RtlLockHeap(IN HANDLE Heap) * @implemented */ BOOLEAN NTAPI -RtlUnlockHeap(HANDLE Heap) +RtlUnlockHeap(HANDLE HeapPtr) { - HEAP *heapPtr = HEAP_GetPtr( Heap ); - if (!heapPtr) - return FALSE; - RtlLeaveHeapLock( &heapPtr->lock ); - return TRUE; + PHEAP Heap = (PHEAP)HeapPtr; + + // FIXME Check for special heap + + /* Check if it's really a heap */ + if (Heap->Signature != HEAP_SIGNATURE) return FALSE; + + /* Unlock if it's lockable */ + if (!(Heap->Flags & HEAP_NO_SERIALIZE)) + { + RtlLeaveHeapLock(Heap->LockVariable); + } + + return TRUE; } @@ -1606,53 +3199,483 @@ RtlUnlockHeap(HANDLE Heap) */ SIZE_T NTAPI RtlSizeHeap( - HANDLE heap, - ULONG flags, - PVOID ptr + HANDLE HeapPtr, + ULONG Flags, + PVOID Ptr ) { - SIZE_T ret; - HEAP *heapPtr = HEAP_GetPtr( heap ); + PHEAP Heap = (PHEAP)HeapPtr; + PHEAP_ENTRY HeapEntry; + SIZE_T EntrySize; - if (!heapPtr) + // FIXME This is a hack around missing SEH support! + if (!Heap) { - RtlSetLastWin32ErrorAndNtStatusFromNtStatus( STATUS_INVALID_HANDLE ); - return MAXULONG; + RtlSetLastWin32ErrorAndNtStatusFromNtStatus(STATUS_INVALID_HANDLE); + return (SIZE_T)-1; } - flags &= HEAP_NO_SERIALIZE; - flags |= heapPtr->flags; - if (!(flags & HEAP_NO_SERIALIZE)) RtlEnterHeapLock( &heapPtr->lock ); - if (!HEAP_IsRealArena( heapPtr, HEAP_NO_SERIALIZE, ptr, QUIET )) + + /* Force flags */ + Flags |= Heap->ForceFlags; + + /* Call special heap */ + if (RtlpHeapIsSpecial(Flags)) + return RtlDebugSizeHeap(Heap, Flags, Ptr); + + /* Get the heap entry pointer */ + HeapEntry = (PHEAP_ENTRY)Ptr - 1; + + /* Return -1 if that entry is free */ + if (!(HeapEntry->Flags & HEAP_ENTRY_BUSY)) { - RtlSetLastWin32ErrorAndNtStatusFromNtStatus( STATUS_INVALID_PARAMETER ); - ret = MAXULONG; + RtlSetLastWin32ErrorAndNtStatusFromNtStatus(STATUS_INVALID_PARAMETER); + return (SIZE_T)-1; + } + + /* Get size of this block depending if it's a usual or a big one */ + if (HeapEntry->Flags & HEAP_ENTRY_VIRTUAL_ALLOC) + { + EntrySize = RtlpGetSizeOfBigBlock(HeapEntry); } else { - const ARENA_INUSE *pArena = (const ARENA_INUSE *)ptr - 1; - ret = (pArena->size & ARENA_SIZE_MASK) - pArena->unused_bytes; + /* Calculate it */ + EntrySize = (HeapEntry->Size << HEAP_ENTRY_SHIFT) - HeapEntry->UnusedBytes; } - if (!(flags & HEAP_NO_SERIALIZE)) RtlLeaveHeapLock( &heapPtr->lock ); - TRACE("(%p,%08lx,%p): returning %08lx\n", heap, flags, ptr, ret ); - return ret; + /* Return calculated size */ + return EntrySize; } BOOLEAN NTAPI -RtlpValidateHeap(HEAP * Heap, BOOLEAN ForceValidation) +RtlpCheckInUsePattern(PHEAP_ENTRY HeapEntry) { - return HEAP_IsRealArena(Heap, Heap->flags, NULL, TRUE); -} + SIZE_T Size, Result; + PCHAR TailPart; -BOOLEAN NTAPI -RtlpValidateHeapHeaders(HEAP * Heap, BOOLEAN Recalculate) -{ + /* Calculate size */ + if (HeapEntry->Flags & HEAP_ENTRY_VIRTUAL_ALLOC) + Size = RtlpGetSizeOfBigBlock(HeapEntry); + else + Size = (HeapEntry->Size << HEAP_ENTRY_SHIFT) - HeapEntry->UnusedBytes; + + /* Calculate pointer to the tail part of the block */ + TailPart = (PCHAR)(HeapEntry + 1) + Size; + + /* Compare tail pattern */ + Result = RtlCompareMemory(TailPart, + FillPattern, + HEAP_ENTRY_SIZE); + + if (Result != HEAP_ENTRY_SIZE) + { + DPRINT1("HEAP: Heap entry (size %x) %p tail is modified at %p\n", Size, HeapEntry, TailPart + Result); + return FALSE; + } + + /* All is fine */ return TRUE; } BOOLEAN NTAPI -RtlpValidateHeapEntry(HEAP * Heap, PVOID HeapEntry) +RtlpValidateHeapHeaders( + PHEAP Heap, + BOOLEAN Recalculate) { + // We skip header validation for now + return TRUE; +} + +BOOLEAN NTAPI +RtlpValidateHeapEntry( + PHEAP Heap, + PHEAP_ENTRY HeapEntry) +{ + BOOLEAN BigAllocation, EntryFound = FALSE; + PHEAP_SEGMENT Segment; + ULONG SegmentOffset; + + /* Perform various consistency checks of this entry */ + if (!HeapEntry) goto invalid_entry; + if ((ULONG_PTR)HeapEntry & (HEAP_ENTRY_SIZE - 1)) goto invalid_entry; + if (!(HeapEntry->Flags & HEAP_ENTRY_BUSY)) goto invalid_entry; + + BigAllocation = HeapEntry->Flags & HEAP_ENTRY_VIRTUAL_ALLOC; + Segment = Heap->Segments[HeapEntry->SegmentOffset]; + + if (BigAllocation && + (((ULONG_PTR)HeapEntry & (PAGE_SIZE - 1)) != FIELD_OFFSET(HEAP_VIRTUAL_ALLOC_ENTRY, BusyBlock))) + goto invalid_entry; + + if (!BigAllocation && (HeapEntry->SegmentOffset >= HEAP_SEGMENTS || + !Segment || + HeapEntry < Segment->FirstEntry || + HeapEntry >= Segment->LastValidEntry)) + goto invalid_entry; + + if ((HeapEntry->Flags & HEAP_ENTRY_FILL_PATTERN) && + !RtlpCheckInUsePattern(HeapEntry)) + goto invalid_entry; + + /* Checks are done, if this is a virtual entry, that's all */ + if (HeapEntry->Flags & HEAP_ENTRY_VIRTUAL_ALLOC) return TRUE; + + /* Go through segments and check if this entry fits into any of them */ + for (SegmentOffset = 0; SegmentOffset < HEAP_SEGMENTS; SegmentOffset++) + { + Segment = Heap->Segments[SegmentOffset]; + if (!Segment) continue; + + if ((HeapEntry >= Segment->FirstEntry) && + (HeapEntry < Segment->LastValidEntry)) + { + /* Got it */ + EntryFound = TRUE; + break; + } + } + + /* Return our result of finding entry in the segments */ + return EntryFound; + +invalid_entry: + DPRINT1("HEAP: Invalid heap entry %p in heap %p\n", HeapEntry, Heap); + return FALSE; +} + +BOOLEAN NTAPI +RtlpValidateHeapSegment( + PHEAP Heap, + PHEAP_SEGMENT Segment, + UCHAR SegmentOffset, + PULONG FreeEntriesCount, + PSIZE_T TotalFreeSize, + PSIZE_T TagEntries, + PSIZE_T PseudoTagEntries) +{ + PHEAP_UCR_DESCRIPTOR UcrDescriptor; + PLIST_ENTRY UcrEntry; + SIZE_T ByteSize, Size, Result; + PHEAP_ENTRY CurrentEntry; + ULONG UnCommittedPages; + ULONG UnCommittedRanges; + ULONG PreviousSize; + + UnCommittedPages = 0; + UnCommittedRanges = 0; + + if (IsListEmpty(&Segment->UCRSegmentList)) + { + UcrEntry = NULL; + UcrDescriptor = NULL; + } + else + { + UcrEntry = Segment->UCRSegmentList.Flink; + UcrDescriptor = CONTAINING_RECORD(UcrEntry, HEAP_UCR_DESCRIPTOR, SegmentEntry); + } + + if (Segment->BaseAddress == Heap) + CurrentEntry = &Heap->Entry; + else + CurrentEntry = &Segment->Entry; + + while (CurrentEntry < Segment->LastValidEntry) + { + if (UcrDescriptor && + ((PVOID)CurrentEntry >= UcrDescriptor->Address)) + { + DPRINT1("HEAP: Entry %p is not inside uncommited range [%p .. %p)\n", + CurrentEntry, UcrDescriptor->Address, + (PCHAR)UcrDescriptor->Address + UcrDescriptor->Size); + + return FALSE; + } + + PreviousSize = 0; + + while (CurrentEntry < Segment->LastValidEntry) + { + if (PreviousSize != CurrentEntry->PreviousSize) + { + DPRINT1("HEAP: Entry %p has incorrect PreviousSize %x instead of %x\n", + CurrentEntry, CurrentEntry->PreviousSize, PreviousSize); + + return FALSE; + } + + PreviousSize = CurrentEntry->Size; + Size = CurrentEntry->Size << HEAP_ENTRY_SHIFT; + + if (CurrentEntry->Flags & HEAP_ENTRY_BUSY) + { + if (TagEntries) + { + UNIMPLEMENTED; + } + + /* Check fill pattern */ + if (CurrentEntry->Flags & HEAP_ENTRY_FILL_PATTERN) + { + if (!RtlpCheckInUsePattern(CurrentEntry)) + return FALSE; + } + } + else + { + /* The entry is free, increase free entries count and total free size */ + *FreeEntriesCount = *FreeEntriesCount + 1; + *TotalFreeSize += CurrentEntry->Size; + + if ((Heap->Flags & HEAP_FREE_CHECKING_ENABLED) && + (CurrentEntry->Flags & HEAP_ENTRY_FILL_PATTERN)) + { + ByteSize = Size - sizeof(HEAP_FREE_ENTRY); + + if ((CurrentEntry->Flags & HEAP_ENTRY_EXTRA_PRESENT) && + (ByteSize > sizeof(HEAP_FREE_ENTRY_EXTRA))) + { + ByteSize -= sizeof(HEAP_FREE_ENTRY_EXTRA); + } + + Result = RtlCompareMemoryUlong((PCHAR)((PHEAP_FREE_ENTRY)CurrentEntry + 1), + ByteSize, + ARENA_FREE_FILLER); + + if (Result != ByteSize) + { + DPRINT1("HEAP: Free heap block %p modified at %p after it was freed\n", + CurrentEntry, + (PCHAR)(CurrentEntry + 1) + Result); + + return FALSE; + } + } + } + + if (CurrentEntry->SegmentOffset != SegmentOffset) + { + DPRINT1("HEAP: Heap entry %p SegmentOffset is incorrect %x (should be %x)\n", CurrentEntry, SegmentOffset, CurrentEntry->SegmentOffset); + return FALSE; + } + + /* Check if it's the last entry */ + if (CurrentEntry->Flags & HEAP_ENTRY_LAST_ENTRY) + { + CurrentEntry = (PHEAP_ENTRY)((PCHAR)CurrentEntry + Size); + + if (!UcrDescriptor) + { + /* Check if it's not really the last one */ + if (CurrentEntry != Segment->LastValidEntry) + { + DPRINT1("HEAP: Heap entry %p is not last block in segment (%x)\n", CurrentEntry, Segment->LastValidEntry); + return FALSE; + } + } + else if (CurrentEntry != UcrDescriptor->Address) + { + DPRINT1("HEAP: Heap entry %p does not match next uncommitted address (%p)\n", + CurrentEntry, UcrDescriptor->Address); + + return FALSE; + } + else + { + UnCommittedPages += (UcrDescriptor->Size / PAGE_SIZE); + UnCommittedRanges++; + + CurrentEntry = (PHEAP_ENTRY)((PCHAR)UcrDescriptor->Address + UcrDescriptor->Size); + + /* Go to the next UCR descriptor */ + UcrEntry = UcrEntry->Flink; + if (UcrEntry == &Segment->UCRSegmentList) + { + UcrEntry = NULL; + UcrDescriptor = NULL; + } + else + { + UcrDescriptor = CONTAINING_RECORD(UcrEntry, HEAP_UCR_DESCRIPTOR, SegmentEntry); + } + } + + break; + } + + /* Advance to the next entry */ + CurrentEntry = (PHEAP_ENTRY)((PCHAR)CurrentEntry + Size); + } + } + + /* Check total numbers of UCP and UCR */ + if (Segment->NumberOfUnCommittedPages != UnCommittedPages) + { + DPRINT1("HEAP: Segment %p NumberOfUnCommittedPages is invalid (%x != %x)\n", + Segment, Segment->NumberOfUnCommittedPages, UnCommittedPages); + + return FALSE; + } + + if (Segment->NumberOfUnCommittedRanges != UnCommittedRanges) + { + DPRINT1("HEAP: Segment %p NumberOfUnCommittedRanges is invalid (%x != %x)\n", + Segment, Segment->NumberOfUnCommittedRanges, UnCommittedRanges); + + return FALSE; + } + + return TRUE; +} + +BOOLEAN NTAPI +RtlpValidateHeap(PHEAP Heap, + BOOLEAN ForceValidation) +{ + PHEAP_SEGMENT Segment; + BOOLEAN EmptyList; + UCHAR SegmentOffset; + SIZE_T Size, TotalFreeSize; + ULONG PreviousSize; + PHEAP_VIRTUAL_ALLOC_ENTRY VirtualAllocBlock; + PLIST_ENTRY ListHead, NextEntry; + PHEAP_FREE_ENTRY FreeEntry; + ULONG FreeBlocksCount, FreeListEntriesCount; + + /* Check headers */ + if (!RtlpValidateHeapHeaders(Heap, FALSE)) + return FALSE; + + /* Skip validation if it's not needed */ + if (!ForceValidation && !(Heap->Flags & HEAP_VALIDATE_ALL_ENABLED)) + return TRUE; + + /* Check free lists bitmaps */ + FreeListEntriesCount = 0; + ListHead = &Heap->FreeLists[0]; + + for (Size = 0; Size < HEAP_FREELISTS; Size++) + { + if (Size) + { + /* This is a dedicated list. Check if it's empty */ + EmptyList = IsListEmpty(ListHead); + + if (Heap->u.FreeListsInUseBytes[Size >> 3] & (1 << (Size & 7))) + { + if (EmptyList) + { + DPRINT1("HEAP: Empty %x-free list marked as non-empty\n", Size); + return FALSE; + } + } + else + { + if (!EmptyList) + { + DPRINT1("HEAP: Non-empty %x-free list marked as empty\n", Size); + return FALSE; + } + } + } + + /* Now check this list entries */ + NextEntry = ListHead->Flink; + PreviousSize = 0; + + while (ListHead != NextEntry) + { + FreeEntry = CONTAINING_RECORD(NextEntry, HEAP_FREE_ENTRY, FreeList); + NextEntry = NextEntry->Flink; + + /* If there is an in-use entry in a free list - that's quite a big problem */ + if (FreeEntry->Flags & HEAP_ENTRY_BUSY) + { + DPRINT1("HEAP: %x-dedicated list free element %x is marked in-use\n", Size, FreeEntry); + return FALSE; + } + + /* Check sizes according to that specific list's size */ + if ((Size == 0) && (FreeEntry->Size < HEAP_FREELISTS)) + { + DPRINT1("HEAP: Non dedicated list free element %x has size %x which would fit a dedicated list\n", FreeEntry, FreeEntry->Size); + return FALSE; + } + else if (Size && (FreeEntry->Size != Size)) + { + DPRINT1("HEAP: %x-dedicated list free element %x has incorrect size %x\n", Size, FreeEntry, FreeEntry->Size); + return FALSE; + } + else if ((Size == 0) && (FreeEntry->Size < PreviousSize)) + { + DPRINT1("HEAP: Non dedicated list free element %x is not put in order\n", FreeEntry); + return FALSE; + } + + /* Remember previous size*/ + PreviousSize = FreeEntry->Size; + + /* Add up to the total amount of free entries */ + FreeListEntriesCount++; + } + + /* Go to the head of the next free list */ + ListHead++; + } + + /* Check big allocations */ + ListHead = &Heap->VirtualAllocdBlocks; + NextEntry = ListHead->Flink; + + while (ListHead != NextEntry) + { + VirtualAllocBlock = CONTAINING_RECORD(NextEntry, HEAP_VIRTUAL_ALLOC_ENTRY, Entry); + + /* We can only check the fill pattern */ + if (VirtualAllocBlock->BusyBlock.Flags & HEAP_ENTRY_FILL_PATTERN) + { + if (!RtlpCheckInUsePattern(&VirtualAllocBlock->BusyBlock)) + return FALSE; + } + + NextEntry = NextEntry->Flink; + } + + /* Check all segments */ + FreeBlocksCount = 0; + TotalFreeSize = 0; + + for (SegmentOffset = 0; SegmentOffset < HEAP_SEGMENTS; SegmentOffset++) + { + Segment = Heap->Segments[SegmentOffset]; + + /* Go to the next one if there is no segment */ + if (!Segment) continue; + + if (!RtlpValidateHeapSegment(Heap, + Segment, + SegmentOffset, + &FreeBlocksCount, + &TotalFreeSize, + NULL, + NULL)) + { + return FALSE; + } + } + + if (FreeListEntriesCount != FreeBlocksCount) + { + DPRINT1("HEAP: Free blocks count in arena (%d) does not match free blocks number in the free lists (%d)\n", FreeBlocksCount, FreeListEntriesCount); + return FALSE; + } + + if (Heap->TotalFreeSize != TotalFreeSize) + { + DPRINT1("HEAP: Total size of free blocks in arena (%d) does not equal to the one in heap header (%d)\n", TotalFreeSize, Heap->TotalFreeSize); + return FALSE; + } + return TRUE; } @@ -1675,29 +3698,62 @@ RtlpValidateHeapEntry(HEAP * Heap, PVOID HeapEntry) * @implemented */ BOOLEAN NTAPI RtlValidateHeap( - HANDLE Heap, + HANDLE HeapPtr, ULONG Flags, PVOID Block ) { - HEAP *heapPtr = HEAP_GetPtr( Heap ); - if (!heapPtr) - return FALSE; - return HEAP_IsRealArena( heapPtr, Flags, Block, QUIET ); + PHEAP Heap = (PHEAP)HeapPtr; + BOOLEAN HeapLocked = FALSE; + BOOLEAN HeapValid; + + // FIXME Check for special heap + + /* Check signature */ + if (Heap->Signature != HEAP_SIGNATURE) + { + DPRINT1("HEAP: Signature %x is invalid for heap %p\n", Heap->Signature, Heap); + return FALSE; + } + + /* Force flags */ + Flags = Heap->ForceFlags; + + /* Acquire the lock if necessary */ + if (!(Flags & HEAP_NO_SERIALIZE)) + { + RtlEnterHeapLock(Heap->LockVariable); + HeapLocked = TRUE; + } + + /* Either validate whole heap or just one entry */ + if (!Block) + HeapValid = RtlpValidateHeap(Heap, TRUE); + else + HeapValid = RtlpValidateHeapEntry(Heap, (PHEAP_ENTRY)Block - 1); + + /* Unlock if it's lockable */ + if (HeapLocked) + { + RtlLeaveHeapLock(Heap->LockVariable); + } + + return HeapValid; } VOID RtlInitializeHeapManager(VOID) { - PPEB Peb; + PPEB Peb; - Peb = NtCurrentPeb(); + /* Get PEB */ + Peb = RtlGetCurrentPeb(); - Peb->NumberOfHeaps = 0; - Peb->MaximumNumberOfHeaps = -1; /* no limit */ - Peb->ProcessHeaps = NULL; + /* Initialize heap-related fields of PEB */ + Peb->NumberOfHeaps = 0; - //RtlInitializeHeapLock(&RtlpProcessHeapsListLock); + /* Initialize the process heaps list protecting lock */ + RtlInitializeHeapLock(&RtlpProcessHeapsListLock); } @@ -1708,21 +3764,8 @@ NTSTATUS NTAPI RtlEnumProcessHeaps(PHEAP_ENUMERATION_ROUTINE HeapEnumerationRoutine, PVOID lParam) { - NTSTATUS Status = STATUS_SUCCESS; - - struct list *ptr=NULL; - RtlEnterHeapLock(&processHeap->lock); - Status=HeapEnumerationRoutine(processHeap,lParam); - - LIST_FOR_EACH( ptr, &processHeap->entry ) - { - if (!NT_SUCCESS(Status)) break; - Status = HeapEnumerationRoutine(ptr,lParam); - } - - RtlLeaveHeapLock(&processHeap->lock); - - return Status; + UNIMPLEMENTED; + return STATUS_NOT_IMPLEMENTED; } @@ -1731,26 +3774,10 @@ RtlEnumProcessHeaps(PHEAP_ENUMERATION_ROUTINE HeapEnumerationRoutine, */ ULONG NTAPI RtlGetProcessHeaps(ULONG count, - HANDLE *heaps ) + HANDLE *heaps) { - ULONG total = 1; /* main heap */ - struct list *ptr; - ULONG i=0; - RtlEnterHeapLock( &processHeap->lock ); - LIST_FOR_EACH( ptr, &processHeap->entry ) total++; - //if (total <= count) - { - *(heaps++) = processHeap; - i++; - LIST_FOR_EACH( ptr, &processHeap->entry ) - { - if (i >= count) break; - i++; - *(heaps++) = LIST_ENTRY( ptr, HEAP, entry ); - } - } - RtlLeaveHeapLock( &processHeap->lock ); - return i; + UNIMPLEMENTED; + return 0; } @@ -1760,22 +3787,8 @@ RtlGetProcessHeaps(ULONG count, BOOLEAN NTAPI RtlValidateProcessHeaps(VOID) { - BOOLEAN Result = TRUE; - HEAP ** pptr; - - RtlEnterHeapLock( &processHeap->lock ); - - for (pptr = (HEAP**)&NtCurrentPeb()->ProcessHeaps; *pptr; pptr++) - { - if (!RtlValidateHeap(*pptr, 0, NULL)) - { - Result = FALSE; - break; - } - } - - RtlLeaveHeapLock( &processHeap->lock ); - return Result; + UNIMPLEMENTED; + return TRUE; } @@ -1802,22 +3815,52 @@ RtlSetUserValueHeap(IN PVOID HeapHandle, IN PVOID BaseAddress, IN PVOID UserValue) { - HEAP *heapPtr; - PHEAP_USER_DATA udata; - - heapPtr = HEAP_GetPtr(HeapHandle); - if (!heapPtr) + PHEAP Heap = (PHEAP)HeapHandle; + PHEAP_ENTRY HeapEntry; + PHEAP_ENTRY_EXTRA Extra; + BOOLEAN HeapLocked = FALSE; + + /* Force flags */ + Flags |= Heap->Flags; + + /* Call special heap */ + if (RtlpHeapIsSpecial(Flags)) + return RtlDebugSetUserValueHeap(Heap, Flags, BaseAddress, UserValue); + + /* Lock if it's lockable */ + if (!(Heap->Flags & HEAP_NO_SERIALIZE)) { - RtlSetLastWin32ErrorAndNtStatusFromNtStatus( STATUS_INVALID_HANDLE ); + RtlEnterHeapLock(Heap->LockVariable); + HeapLocked = TRUE; + } + + /* Get a pointer to the entry */ + HeapEntry = (PHEAP_ENTRY)BaseAddress - 1; + + /* If it's a free entry - return error */ + if (!(HeapEntry->Flags & HEAP_ENTRY_BUSY)) + { + RtlSetLastWin32ErrorAndNtStatusFromNtStatus(STATUS_INVALID_PARAMETER); + + /* Release the heap lock if it was acquired */ + if (HeapLocked) + RtlLeaveHeapLock(Heap->LockVariable); + return FALSE; } - udata = HEAP_GetUserData(heapPtr, BaseAddress); - if (!udata) + + /* Check if this entry has an extra stuff associated with it */ + if (HeapEntry->Flags & HEAP_ENTRY_EXTRA_PRESENT) { - udata = HEAP_AllocUserData(heapPtr, BaseAddress); - if (!udata) return FALSE; + /* Use extra to store the value */ + Extra = RtlpGetExtraStuffPointer(HeapEntry); + Extra->Settable = (ULONG_PTR)UserValue; } - udata->UserValue = UserValue; + + /* Release the heap lock if it was acquired */ + if (HeapLocked) + RtlLeaveHeapLock(Heap->LockVariable); + return TRUE; } @@ -1832,22 +3875,47 @@ RtlSetUserFlagsHeap(IN PVOID HeapHandle, IN ULONG UserFlagsReset, IN ULONG UserFlagsSet) { - HEAP *heapPtr; - PHEAP_USER_DATA udata; + PHEAP Heap = (PHEAP)HeapHandle; + PHEAP_ENTRY HeapEntry; + BOOLEAN HeapLocked = FALSE; - heapPtr = HEAP_GetPtr(HeapHandle); - if (!heapPtr) + /* Force flags */ + Flags |= Heap->Flags; + + /* Call special heap */ + if (RtlpHeapIsSpecial(Flags)) + return RtlDebugSetUserFlagsHeap(Heap, Flags, BaseAddress, UserFlagsReset, UserFlagsSet); + + /* Lock if it's lockable */ + if (!(Heap->Flags & HEAP_NO_SERIALIZE)) { - RtlSetLastWin32ErrorAndNtStatusFromNtStatus( STATUS_INVALID_HANDLE ); + RtlEnterHeapLock(Heap->LockVariable); + HeapLocked = TRUE; + } + + /* Get a pointer to the entry */ + HeapEntry = (PHEAP_ENTRY)BaseAddress - 1; + + /* If it's a free entry - return error */ + if (!(HeapEntry->Flags & HEAP_ENTRY_BUSY)) + { + RtlSetLastWin32ErrorAndNtStatusFromNtStatus(STATUS_INVALID_PARAMETER); + + /* Release the heap lock if it was acquired */ + if (HeapLocked) + RtlLeaveHeapLock(Heap->LockVariable); + return FALSE; } - udata = HEAP_GetUserData(heapPtr, BaseAddress); - if (!udata) - { - udata = HEAP_AllocUserData(heapPtr, BaseAddress); - if (!udata) return FALSE; - } - udata->UserFlags = UserFlagsSet & HEAP_SETTABLE_USER_FLAGS; + + /* Set / reset flags */ + HeapEntry->Flags &= ~(UserFlagsReset >> 4); + HeapEntry->Flags |= (UserFlagsSet >> 4); + + /* Release the heap lock if it was acquired */ + if (HeapLocked) + RtlLeaveHeapLock(Heap->LockVariable); + return TRUE; } @@ -1862,23 +3930,59 @@ RtlGetUserInfoHeap(IN PVOID HeapHandle, OUT PVOID *UserValue, OUT PULONG UserFlags) { - HEAP *heapPtr; - PHEAP_USER_DATA udata; + PHEAP Heap = (PHEAP)HeapHandle; + PHEAP_ENTRY HeapEntry; + PHEAP_ENTRY_EXTRA Extra; + BOOLEAN HeapLocked = FALSE; - heapPtr = HEAP_GetPtr(HeapHandle); - if (!heapPtr) + /* Force flags */ + Flags |= Heap->Flags; + + /* Call special heap */ + if (RtlpHeapIsSpecial(Flags)) + return RtlDebugGetUserInfoHeap(Heap, Flags, BaseAddress, UserValue, UserFlags); + + /* Lock if it's lockable */ + if (!(Heap->Flags & HEAP_NO_SERIALIZE)) { - RtlSetLastWin32ErrorAndNtStatusFromNtStatus( STATUS_INVALID_HANDLE ); + RtlEnterHeapLock(Heap->LockVariable); + HeapLocked = TRUE; + } + + /* Get a pointer to the entry */ + HeapEntry = (PHEAP_ENTRY)BaseAddress - 1; + + /* If it's a free entry - return error */ + if (!(HeapEntry->Flags & HEAP_ENTRY_BUSY)) + { + RtlSetLastWin32ErrorAndNtStatusFromNtStatus(STATUS_INVALID_PARAMETER); + + /* Release the heap lock if it was acquired */ + if (HeapLocked) + RtlLeaveHeapLock(Heap->LockVariable); + return FALSE; } - udata = HEAP_GetUserData(heapPtr, BaseAddress); - if (!udata) + + /* Check if this entry has an extra stuff associated with it */ + if (HeapEntry->Flags & HEAP_ENTRY_EXTRA_PRESENT) { - RtlSetLastWin32ErrorAndNtStatusFromNtStatus( STATUS_INVALID_PARAMETER ); - return FALSE; + /* Get pointer to extra data */ + Extra = RtlpGetExtraStuffPointer(HeapEntry); + + /* Pass user value */ + if (UserValue) + *UserValue = (PVOID)Extra->Settable; + + /* Decode and return user flags */ + if (UserFlags) + *UserFlags = (HeapEntry->Flags & HEAP_ENTRY_SETTABLE_FLAGS) << 4; } - if (UserValue) *UserValue = udata->UserValue; - if (UserFlags) *UserFlags = udata->UserFlags; + + /* Release the heap lock if it was acquired */ + if (HeapLocked) + RtlLeaveHeapLock(Heap->LockVariable); + return TRUE; } @@ -1958,8 +4062,24 @@ RtlSetHeapInformation(IN HANDLE HeapHandle OPTIONAL, IN PVOID HeapInformation, IN SIZE_T HeapInformationLength) { - UNIMPLEMENTED; - return 0; + /* Setting heap information is not really supported except for enabling LFH */ + if (HeapInformationClass == 0) return STATUS_SUCCESS; + + /* Check buffer length */ + if (HeapInformationLength < sizeof(ULONG)) + { + /* The provided buffer is too small */ + return STATUS_BUFFER_TOO_SMALL; + } + + /* Check for a special magic value for enabling LFH */ + if (*(PULONG)HeapInformation == 2) + { + DPRINT1("RtlSetHeapInformation() needs to enable LFH\n"); + return STATUS_SUCCESS; + } + + return STATUS_UNSUCCESSFUL; } NTSTATUS @@ -1970,30 +4090,26 @@ RtlQueryHeapInformation(HANDLE HeapHandle, SIZE_T HeapInformationLength OPTIONAL, PSIZE_T ReturnLength OPTIONAL) { - HEAP *heapPtr; + PHEAP Heap = (PHEAP)HeapHandle; - heapPtr = HEAP_GetPtr(HeapHandle); - if (!heapPtr) + /* Only HeapCompatibilityInformation is supported */ + if (HeapInformationClass != HeapCompatibilityInformation) + return STATUS_UNSUCCESSFUL; + + /* Set result length */ + if (ReturnLength) *ReturnLength = sizeof(ULONG); + + /* Check buffer length */ + if (HeapInformationLength < sizeof(ULONG)) { - RtlSetLastWin32ErrorAndNtStatusFromNtStatus( STATUS_INVALID_HANDLE ); - return FALSE; + /* It's too small, return needed length */ + return STATUS_BUFFER_TOO_SMALL; } - UNIMPLEMENTED + /* Return front end heap type */ + *(PULONG)HeapInformation = Heap->FrontEndHeapType; - switch (HeapInformationClass) - { - case HeapCompatibilityInformation: - if (ReturnLength) *ReturnLength = sizeof(ULONG); - - if (HeapInformationLength < sizeof(ULONG)) - return STATUS_BUFFER_TOO_SMALL; - - *(ULONG *)HeapInformation = 0; /* standard heap */ - return STATUS_SUCCESS; - default: - return STATUS_INVALID_INFO_CLASS; - } + return STATUS_SUCCESS; } NTSTATUS @@ -2018,3 +4134,5 @@ RtlMultipleFreeHeap(IN PVOID HeapHandle, UNIMPLEMENTED; return 0; } + +/* EOF */ diff --git a/reactos/lib/rtl/heap_rewrite.c b/reactos/lib/rtl/heap_rewrite.c deleted file mode 100644 index 2c28b6a76d7..00000000000 --- a/reactos/lib/rtl/heap_rewrite.c +++ /dev/null @@ -1,4138 +0,0 @@ -/* COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * FILE: lib/rtl/heap.c - * PURPOSE: RTL Heap backend allocator - * PROGRAMMERS: Copyright 2010 Aleksey Bragin - */ - -/* Useful references: - http://msdn.microsoft.com/en-us/library/ms810466.aspx - http://msdn.microsoft.com/en-us/library/ms810603.aspx - http://www.securitylab.ru/analytics/216376.php - http://binglongx.spaces.live.com/blog/cns!142CBF6D49079DE8!596.entry - http://www.phreedom.org/research/exploits/asn1-bitstring/ - http://illmatics.com/Understanding_the_LFH.pdf - http://www.alex-ionescu.com/?p=18 -*/ - -/* INCLUDES *****************************************************************/ - -#include -#include - -#define NDEBUG -#include - -HEAP_LOCK RtlpProcessHeapsListLock; - -/* Bitmaps stuff */ - -/* How many least significant bits are clear */ -UCHAR RtlpBitsClearLow[] = -{ - 8,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0, - 4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0, - 5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0, - 4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0, - 6,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0, - 4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0, - 5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0, - 4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0, - 7,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0, - 4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0, - 5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0, - 4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0, - 6,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0, - 4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0, - 5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0, - 4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0 -}; - -UCHAR FORCEINLINE -RtlpFindLeastSetBit(ULONG Bits) -{ - if (Bits & 0xFFFF) - { - if (Bits & 0xFF) - return RtlpBitsClearLow[Bits & 0xFF]; /* Lowest byte */ - else - return RtlpBitsClearLow[(Bits >> 8) & 0xFF] + 8; /* 2nd byte */ - } - else - { - if ((Bits >> 16) & 0xFF) - return RtlpBitsClearLow[(Bits >> 16) & 0xFF] + 16; /* 3rd byte */ - else - return RtlpBitsClearLow[(Bits >> 24) & 0xFF] + 24; /* Highest byte */ - } -} - -/* Maximum size of a tail-filling pattern used for compare operation */ -UCHAR FillPattern[HEAP_ENTRY_SIZE] = -{ - HEAP_TAIL_FILL, - HEAP_TAIL_FILL, - HEAP_TAIL_FILL, - HEAP_TAIL_FILL, - HEAP_TAIL_FILL, - HEAP_TAIL_FILL, - HEAP_TAIL_FILL, - HEAP_TAIL_FILL -}; - - -ULONG NTAPI -RtlCompareMemoryUlong(PVOID Source, ULONG Length, ULONG Value); - -/* FUNCTIONS *****************************************************************/ - -VOID NTAPI -RtlpInitializeHeap(PHEAP Heap, - PULONG HeaderSize, - ULONG Flags, - BOOLEAN AllocateLock, - PVOID Lock) -{ - PVOID NextHeapBase = Heap + 1; - PHEAP_UCR_DESCRIPTOR UcrDescriptor; - ULONG NumUCRs = 8; - ULONG i; - NTSTATUS Status; - - /* Add UCRs size */ - *HeaderSize += NumUCRs * sizeof(*UcrDescriptor); - - /* Prepare a list of UCRs */ - InitializeListHead(&Heap->UCRList); - InitializeListHead(&Heap->UCRSegments); - UcrDescriptor = NextHeapBase; - - for (i=0; iUCRList, &UcrDescriptor->ListEntry); - } - - NextHeapBase = UcrDescriptor; - // TODO: Add tagging - - /* Round up header size again */ - *HeaderSize = ROUND_UP(*HeaderSize, HEAP_ENTRY_SIZE); - - ASSERT(*HeaderSize <= PAGE_SIZE); - - /* Initialize heap's header */ - Heap->Entry.Size = (*HeaderSize) >> HEAP_ENTRY_SHIFT; - Heap->Entry.Flags = HEAP_ENTRY_BUSY; - - Heap->Signature = HEAP_SIGNATURE; - Heap->Flags = Flags; - Heap->ForceFlags = (Flags & (HEAP_NO_SERIALIZE | - HEAP_GENERATE_EXCEPTIONS | - HEAP_ZERO_MEMORY | - HEAP_REALLOC_IN_PLACE_ONLY | - HEAP_VALIDATE_PARAMETERS_ENABLED | - HEAP_VALIDATE_ALL_ENABLED | - HEAP_TAIL_CHECKING_ENABLED | - HEAP_CREATE_ALIGN_16 | - HEAP_FREE_CHECKING_ENABLED)); - Heap->HeaderValidateCopy = NULL; - Heap->HeaderValidateLength = ((PCHAR)NextHeapBase - (PCHAR)Heap); - - /* Initialize free lists */ - for (i=0; iFreeLists[i]); - } - - /* Initialize "big" allocations list */ - InitializeListHead(&Heap->VirtualAllocdBlocks); - - /* Initialize lock */ - if (AllocateLock) - { - Lock = NextHeapBase; - Status = RtlInitializeHeapLock((PHEAP_LOCK)Lock); - if (!NT_SUCCESS(Status)) - { - DPRINT1("Initializing the lock failed!\n"); - return /*NULL*/; // FIXME! - } - } - - /* Set the lock variable */ - Heap->LockVariable = Lock; -} - -VOID FORCEINLINE -RtlpSetFreeListsBit(PHEAP Heap, - PHEAP_FREE_ENTRY FreeEntry) -{ - ULONG Index, Bit; - - ASSERT(FreeEntry->Size < HEAP_FREELISTS); - - /* Calculate offset in the free list bitmap */ - Index = FreeEntry->Size >> 3; /* = FreeEntry->Size / (sizeof(UCHAR) * 8)*/ - Bit = 1 << (FreeEntry->Size & 7); - - /* Assure it's not already set */ - ASSERT((Heap->u.FreeListsInUseBytes[Index] & Bit) == 0); - - /* Set it */ - Heap->u.FreeListsInUseBytes[Index] |= Bit; -} - -VOID FORCEINLINE -RtlpClearFreeListsBit(PHEAP Heap, - PHEAP_FREE_ENTRY FreeEntry) -{ - ULONG Index, Bit; - - ASSERT(FreeEntry->Size < HEAP_FREELISTS); - - /* Calculate offset in the free list bitmap */ - Index = FreeEntry->Size >> 3; /* = FreeEntry->Size / (sizeof(UCHAR) * 8)*/ - Bit = 1 << (FreeEntry->Size & 7); - - /* Assure it was set and the corresponding free list is empty */ - ASSERT(Heap->u.FreeListsInUseBytes[Index] & Bit); - ASSERT(IsListEmpty(&Heap->FreeLists[FreeEntry->Size])); - - /* Clear it */ - Heap->u.FreeListsInUseBytes[Index] ^= Bit; -} - -VOID NTAPI -RtlpInsertFreeBlockHelper(PHEAP Heap, - PHEAP_FREE_ENTRY FreeEntry, - SIZE_T BlockSize, - BOOLEAN NoFill) -{ - PLIST_ENTRY FreeListHead, Current; - PHEAP_FREE_ENTRY CurrentEntry; - - ASSERT(FreeEntry->Size == BlockSize); - - /* Fill if it's not denied */ - if (!NoFill) - { - FreeEntry->Flags &= ~(HEAP_ENTRY_FILL_PATTERN | - HEAP_ENTRY_EXTRA_PRESENT | - HEAP_ENTRY_BUSY); - - if (Heap->Flags & HEAP_FREE_CHECKING_ENABLED) - { - RtlFillMemoryUlong((PCHAR)(FreeEntry + 1), - (BlockSize << HEAP_ENTRY_SHIFT) - sizeof(*FreeEntry), - ARENA_FREE_FILLER); - - FreeEntry->Flags |= HEAP_ENTRY_FILL_PATTERN; - } - } - else - { - /* Clear out all flags except the last entry one */ - FreeEntry->Flags &= HEAP_ENTRY_LAST_ENTRY; - } - - /* Check if PreviousSize of the next entry matches ours */ - if (!(FreeEntry->Flags & HEAP_ENTRY_LAST_ENTRY)) - { - ASSERT(((PHEAP_ENTRY)FreeEntry + BlockSize)->PreviousSize = BlockSize); - } - - /* Insert it either into dedicated or non-dedicated list */ - if (BlockSize < HEAP_FREELISTS) - { - /* Dedicated list */ - FreeListHead = &Heap->FreeLists[BlockSize]; - - if (IsListEmpty(FreeListHead)) - { - RtlpSetFreeListsBit(Heap, FreeEntry); - } - } - else - { - /* Non-dedicated one */ - FreeListHead = &Heap->FreeLists[0]; - Current = FreeListHead->Flink; - - /* Find a position where to insert it to (the list must be sorted) */ - while (FreeListHead != Current) - { - CurrentEntry = CONTAINING_RECORD(Current, HEAP_FREE_ENTRY, FreeList); - - if (BlockSize <= CurrentEntry->Size) - break; - - Current = Current->Flink; - } - - FreeListHead = Current; - } - - /* Actually insert it into the list */ - InsertTailList(FreeListHead, &FreeEntry->FreeList); -} - -VOID NTAPI -RtlpInsertFreeBlock(PHEAP Heap, - PHEAP_FREE_ENTRY FreeEntry, - SIZE_T BlockSize) -{ - USHORT Size, PreviousSize; - UCHAR SegmentOffset, Flags; - PHEAP_SEGMENT Segment; - - DPRINT("RtlpInsertFreeBlock(%p %p %x)\n", Heap, FreeEntry, BlockSize); - - /* Increase the free size counter */ - Heap->TotalFreeSize += BlockSize; - - /* Remember certain values */ - Flags = FreeEntry->Flags; - PreviousSize = FreeEntry->PreviousSize; - SegmentOffset = FreeEntry->SegmentOffset; - Segment = Heap->Segments[SegmentOffset]; - - /* Process it */ - while (BlockSize) - { - /* Check for the max size */ - if (BlockSize > HEAP_MAX_BLOCK_SIZE) - { - Size = HEAP_MAX_BLOCK_SIZE; - - /* Special compensation if it goes above limit just by 1 */ - if (BlockSize == (HEAP_MAX_BLOCK_SIZE + 1)) - Size -= 16; - - FreeEntry->Flags = 0; - } - else - { - Size = BlockSize; - FreeEntry->Flags = Flags; - } - - /* Change its size and insert it into a free list */ - FreeEntry->Size = Size; - FreeEntry->PreviousSize = PreviousSize; - FreeEntry->SegmentOffset = SegmentOffset; - - /* Call a helper to actually insert the block */ - RtlpInsertFreeBlockHelper(Heap, FreeEntry, Size, FALSE); - - /* Update sizes */ - PreviousSize = Size; - BlockSize -= Size; - - /* Go to the next entry */ - FreeEntry = (PHEAP_FREE_ENTRY)((PHEAP_ENTRY)FreeEntry + Size); - - /* Check if that's all */ - if ((PHEAP_ENTRY)FreeEntry >= Segment->LastValidEntry) return; - } - - /* Update previous size if needed */ - if (!(Flags & HEAP_ENTRY_LAST_ENTRY)) - FreeEntry->PreviousSize = PreviousSize; -} - -VOID NTAPI -RtlpRemoveFreeBlock(PHEAP Heap, - PHEAP_FREE_ENTRY FreeEntry, - BOOLEAN Dedicated, - BOOLEAN NoFill) -{ - SIZE_T Result, RealSize; - PLIST_ENTRY OldBlink, OldFlink; - - // FIXME: Maybe use RemoveEntryList? - - /* Remove the free block */ - OldFlink = FreeEntry->FreeList.Flink; - OldBlink = FreeEntry->FreeList.Blink; - OldBlink->Flink = OldFlink; - OldFlink->Blink = OldBlink; - - /* Update the freelists bitmap */ - if ((OldFlink == OldBlink) && - (Dedicated || (!Dedicated && FreeEntry->Size < HEAP_FREELISTS))) - { - RtlpClearFreeListsBit(Heap, FreeEntry); - } - - /* Fill with pattern if necessary */ - if (!NoFill && - (FreeEntry->Flags & HEAP_ENTRY_FILL_PATTERN)) - { - RealSize = (FreeEntry->Size << HEAP_ENTRY_SHIFT) - sizeof(*FreeEntry); - - /* Deduct extra stuff from block's real size */ - if (FreeEntry->Flags & HEAP_ENTRY_EXTRA_PRESENT && - RealSize > sizeof(HEAP_FREE_ENTRY_EXTRA)) - { - RealSize -= sizeof(HEAP_FREE_ENTRY_EXTRA); - } - - /* Check if the free filler is intact */ - Result = RtlCompareMemoryUlong((PCHAR)(FreeEntry + 1), - RealSize, - ARENA_FREE_FILLER); - - if (Result != RealSize) - { - DPRINT1("Free heap block %p modified at %p after it was freed\n", - FreeEntry, - (PCHAR)(FreeEntry + 1) + Result); - } - } -} - -SIZE_T NTAPI -RtlpGetSizeOfBigBlock(PHEAP_ENTRY HeapEntry) -{ - PHEAP_VIRTUAL_ALLOC_ENTRY VirtualEntry; - - /* Get pointer to the containing record */ - VirtualEntry = CONTAINING_RECORD(HeapEntry, HEAP_VIRTUAL_ALLOC_ENTRY, BusyBlock); - - /* Restore the real size */ - return VirtualEntry->CommitSize - HeapEntry->Size; -} - -PHEAP_UCR_DESCRIPTOR NTAPI -RtlpCreateUnCommittedRange(PHEAP_SEGMENT Segment) -{ - PLIST_ENTRY Entry; - PHEAP_UCR_DESCRIPTOR UcrDescriptor; - PHEAP_UCR_SEGMENT UcrSegment; - PHEAP Heap = Segment->Heap; - SIZE_T ReserveSize = 16 * PAGE_SIZE; - SIZE_T CommitSize = 1 * PAGE_SIZE; - NTSTATUS Status; - - DPRINT("RtlpCreateUnCommittedRange(%p)\n", Segment); - - /* Check if we have unused UCRs */ - if (IsListEmpty(&Heap->UCRList)) - { - /* Get a pointer to the first UCR segment */ - UcrSegment = CONTAINING_RECORD(&Heap->UCRSegments.Flink, HEAP_UCR_SEGMENT, ListEntry); - - /* Check the list of UCR segments */ - if (IsListEmpty(&Heap->UCRSegments) || - UcrSegment->ReservedSize == UcrSegment->CommittedSize) - { - /* We need to create a new one. Reserve 16 pages for it */ - UcrSegment = NULL; - Status = ZwAllocateVirtualMemory(NtCurrentProcess(), - (PVOID *)&UcrSegment, - 0, - &ReserveSize, - MEM_RESERVE, - PAGE_READWRITE); - - if (!NT_SUCCESS(Status)) return NULL; - - /* Commit one page */ - Status = ZwAllocateVirtualMemory(NtCurrentProcess(), - (PVOID *)&UcrSegment, - 0, - &CommitSize, - MEM_COMMIT, - PAGE_READWRITE); - - if (!NT_SUCCESS(Status)) - { - /* Release reserved memory */ - ZwFreeVirtualMemory(NtCurrentProcess(), - (PVOID *)&UcrDescriptor, - &ReserveSize, - MEM_RELEASE); - return NULL; - } - - /* Set it's data */ - UcrSegment->ReservedSize = ReserveSize; - UcrSegment->CommittedSize = CommitSize; - - /* Add it to the head of the list */ - InsertHeadList(&Heap->UCRSegments, &UcrSegment->ListEntry); - - /* Get a pointer to the first available UCR descriptor */ - UcrDescriptor = (PHEAP_UCR_DESCRIPTOR)(UcrSegment + 1); - } - else - { - /* It's possible to use existing UCR segment. Commit one more page */ - UcrDescriptor = (PHEAP_UCR_DESCRIPTOR)((PCHAR)UcrSegment + UcrSegment->CommittedSize); - Status = ZwAllocateVirtualMemory(NtCurrentProcess(), - (PVOID *)&UcrDescriptor, - 0, - &CommitSize, - MEM_COMMIT, - PAGE_READWRITE); - - if (!NT_SUCCESS(Status)) return NULL; - - /* Update sizes */ - UcrSegment->CommittedSize += CommitSize; - } - - /* There is a whole bunch of new UCR descriptors. Put them into the unused list */ - while ((PCHAR)UcrDescriptor < ((PCHAR)UcrSegment + UcrSegment->CommittedSize)) - { - InsertTailList(&Heap->UCRList, &UcrDescriptor->ListEntry); - UcrDescriptor++; - } - } - - /* There are unused UCRs, just get the first one */ - Entry = RemoveHeadList(&Heap->UCRList); - UcrDescriptor = CONTAINING_RECORD(Entry, HEAP_UCR_DESCRIPTOR, ListEntry); - return UcrDescriptor; -} - -VOID NTAPI -RtlpDestroyUnCommittedRange(PHEAP_SEGMENT Segment, - PHEAP_UCR_DESCRIPTOR UcrDescriptor) -{ - /* Zero it out */ - UcrDescriptor->Address = NULL; - UcrDescriptor->Size = 0; - - /* Put it into the heap's list of unused UCRs */ - InsertHeadList(&Segment->Heap->UCRList, &UcrDescriptor->ListEntry); -} - -VOID NTAPI -RtlpInsertUnCommittedPages(PHEAP_SEGMENT Segment, - ULONG_PTR Address, - SIZE_T Size) -{ - PLIST_ENTRY Current; - PHEAP_UCR_DESCRIPTOR UcrDescriptor; - - DPRINT("RtlpInsertUnCommittedPages(%p %p %x)\n", Segment, Address, Size); - - /* Go through the list of UCR descriptors, they are sorted from lowest address - to the highest */ - Current = Segment->UCRSegmentList.Flink; - while(Current != &Segment->UCRSegmentList) - { - UcrDescriptor = CONTAINING_RECORD(Current, HEAP_UCR_DESCRIPTOR, SegmentEntry); - - if ((ULONG_PTR)UcrDescriptor->Address > Address) - { - /* Check for a really lucky case */ - if ((Address + Size) == (ULONG_PTR)UcrDescriptor->Address) - { - /* Exact match */ - UcrDescriptor->Address = (PVOID)Address; - UcrDescriptor->Size += Size; - return; - } - - /* We found the block after which the new one should go */ - break; - } - else if (((ULONG_PTR)UcrDescriptor->Address + UcrDescriptor->Size) == Address) - { - /* Modify this entry */ - Address = (ULONG_PTR)UcrDescriptor->Address; - Size += UcrDescriptor->Size; - - /* Remove it from the list and destroy it */ - RemoveEntryList(Current); - RtlpDestroyUnCommittedRange(Segment, UcrDescriptor); - - Segment->NumberOfUnCommittedRanges--; - } - else - { - /* Advance to the next descriptor */ - Current = Current->Flink; - } - } - - /* Create a new UCR descriptor */ - UcrDescriptor = RtlpCreateUnCommittedRange(Segment); - if (!UcrDescriptor) return; - - UcrDescriptor->Address = (PVOID)Address; - UcrDescriptor->Size = Size; - - /* "Current" is the descriptor after which our one should go */ - InsertTailList(Current, &UcrDescriptor->SegmentEntry); - - DPRINT("Added segment UCR with base %p, size 0x%x\n", Address, Size); - - /* Increase counters */ - Segment->NumberOfUnCommittedRanges++; -} - -PHEAP_FREE_ENTRY NTAPI -RtlpFindAndCommitPages(PHEAP Heap, - PHEAP_SEGMENT Segment, - PSIZE_T Size, - PVOID AddressRequested) -{ - PLIST_ENTRY Current; - ULONG_PTR Address = 0; - PHEAP_UCR_DESCRIPTOR UcrDescriptor, PreviousUcr = NULL; - PHEAP_ENTRY FirstEntry, LastEntry, PreviousLastEntry; - NTSTATUS Status; - - DPRINT("RtlpFindAndCommitPages(%p %p %x %p)\n", Heap, Segment, *Size, Address); - - /* Go through UCRs in a segment */ - Current = Segment->UCRSegmentList.Flink; - while(Current != &Segment->UCRSegmentList) - { - UcrDescriptor = CONTAINING_RECORD(Current, HEAP_UCR_DESCRIPTOR, SegmentEntry); - - /* Check if we can use that one right away */ - if (UcrDescriptor->Size >= *Size && - (UcrDescriptor->Address == AddressRequested || !AddressRequested)) - { - /* Get the address */ - Address = (ULONG_PTR)UcrDescriptor->Address; - - /* Commit it */ - if (Heap->CommitRoutine) - { - Status = Heap->CommitRoutine(Heap, (PVOID *)&Address, Size); - } - else - { - Status = ZwAllocateVirtualMemory(NtCurrentProcess(), - (PVOID *)&Address, - 0, - Size, - MEM_COMMIT, - PAGE_READWRITE); - } - - DPRINT("Committed %d bytes at base %p, UCR size is %d\n", *Size, Address, UcrDescriptor->Size); - - /* Fail in unsuccessful case */ - if (!NT_SUCCESS(Status)) - { - DPRINT1("Committing page failed with status 0x%08X\n", Status); - return NULL; - } - - /* Update tracking numbers */ - Segment->NumberOfUnCommittedPages -= *Size / PAGE_SIZE; - - /* Calculate first and last entries */ - FirstEntry = (PHEAP_ENTRY)Address; - - if ((Segment->LastEntryInSegment->Flags & HEAP_ENTRY_LAST_ENTRY) && - (ULONG_PTR)(Segment->LastEntryInSegment + Segment->LastEntryInSegment->Size) == (ULONG_PTR)UcrDescriptor->Address) - { - LastEntry = Segment->LastEntryInSegment; - } - else - { - /* Go through the entries to find the last one */ - - if (PreviousUcr) - LastEntry = (PHEAP_ENTRY)((ULONG_PTR)PreviousUcr->Address + PreviousUcr->Size); - else - LastEntry = Segment->FirstEntry; - - while (!(LastEntry->Flags & HEAP_ENTRY_LAST_ENTRY)) - { - PreviousLastEntry = LastEntry; - LastEntry += LastEntry->Size; - - if ((ULONG_PTR)LastEntry >= (ULONG_PTR)Segment->LastValidEntry || - LastEntry->Size == 0) - { - if (LastEntry == (PHEAP_ENTRY)Address) - { - /* Found it */ - LastEntry = PreviousLastEntry; - break; - } - - DPRINT1("Last entry not found in a committed range near to %p\n", PreviousLastEntry); - return NULL; - } - } - } - - /* Unmark it as a last entry */ - LastEntry->Flags &= ~HEAP_ENTRY_LAST_ENTRY; - - /* Update UCR descriptor */ - UcrDescriptor->Address = (PVOID)((ULONG_PTR)UcrDescriptor->Address + *Size); - UcrDescriptor->Size -= *Size; - - DPRINT("Updating UcrDescriptor %p, new Address %p, size %d\n", - UcrDescriptor, UcrDescriptor->Address, UcrDescriptor->Size); - - /* Check if anything left in this UCR */ - if (UcrDescriptor->Size == 0) - { - /* It's fully exhausted */ - if (UcrDescriptor->Address == Segment->LastValidEntry) - { - FirstEntry->Flags = HEAP_ENTRY_LAST_ENTRY; - Segment->LastEntryInSegment = FirstEntry; - } - else - { - FirstEntry->Flags = 0; - Segment->LastEntryInSegment = Segment->FirstEntry; - } - - /* This UCR needs to be removed because it became useless */ - RemoveEntryList(&UcrDescriptor->SegmentEntry); - - RtlpDestroyUnCommittedRange(Segment, UcrDescriptor); - Segment->NumberOfUnCommittedRanges--; - } - else - { - FirstEntry->Flags = HEAP_ENTRY_LAST_ENTRY; - Segment->LastEntryInSegment = FirstEntry; - } - - /* Set various first entry fields*/ - FirstEntry->SegmentOffset = LastEntry->SegmentOffset; - FirstEntry->Size = *Size >> HEAP_ENTRY_SHIFT; - FirstEntry->PreviousSize = LastEntry->Size; - - /* Update previous size */ - if (!(FirstEntry->Flags & HEAP_ENTRY_LAST_ENTRY)) - (FirstEntry + FirstEntry->Size)->PreviousSize = FirstEntry->Size; - - /* We're done */ - return (PHEAP_FREE_ENTRY)FirstEntry; - } - - /* Advance to the next descriptor */ - PreviousUcr = UcrDescriptor; - Current = Current->Flink; - } - - return NULL; -} - -VOID NTAPI -RtlpDeCommitFreeBlock(PHEAP Heap, - PHEAP_FREE_ENTRY FreeEntry, - SIZE_T Size) -{ - PHEAP_SEGMENT Segment; - PHEAP_ENTRY PrecedingInUseEntry = NULL, NextInUseEntry = NULL; - PHEAP_FREE_ENTRY NextFreeEntry; - PHEAP_UCR_DESCRIPTOR UcrDescriptor; - ULONG PrecedingSize, NextSize, DecommitSize; - ULONG_PTR DecommitBase; - NTSTATUS Status; - - DPRINT("Decommitting %p %p %x\n", Heap, FreeEntry, Size); - - /* We can't decommit if there is a commit routine! */ - if (Heap->CommitRoutine) - { - /* Just add it back the usual way */ - RtlpInsertFreeBlock(Heap, FreeEntry, Size); - return; - } - - /* Get the segment */ - Segment = Heap->Segments[FreeEntry->SegmentOffset]; - - /* Get the preceding entry */ - DecommitBase = ROUND_UP(FreeEntry, PAGE_SIZE); - PrecedingSize = (PHEAP_ENTRY)DecommitBase - (PHEAP_ENTRY)FreeEntry; - - if (PrecedingSize == 1) - { - /* Just 1 heap entry, increase the base/size */ - DecommitBase += PAGE_SIZE; - PrecedingSize += PAGE_SIZE >> HEAP_ENTRY_SHIFT; - } - else if (FreeEntry->PreviousSize && - (DecommitBase == (ULONG_PTR)FreeEntry)) - { - PrecedingInUseEntry = (PHEAP_ENTRY)FreeEntry - FreeEntry->PreviousSize; - } - - /* Get the next entry */ - NextFreeEntry = (PHEAP_FREE_ENTRY)((PHEAP_ENTRY)FreeEntry + Size); - DecommitSize = ROUND_DOWN(NextFreeEntry, PAGE_SIZE); - NextSize = (PHEAP_ENTRY)NextFreeEntry - (PHEAP_ENTRY)DecommitSize; - - if (NextSize == 1) - { - /* Just 1 heap entry, increase the size */ - DecommitSize -= PAGE_SIZE; - NextSize += PAGE_SIZE >> HEAP_ENTRY_SHIFT; - } - else if (NextSize == 0 && - !(FreeEntry->Flags & HEAP_ENTRY_LAST_ENTRY)) - { - NextInUseEntry = (PHEAP_ENTRY)NextFreeEntry; - } - - NextFreeEntry = (PHEAP_FREE_ENTRY)((PHEAP_ENTRY)NextFreeEntry - NextSize); - - /* Calculate real decommit size */ - if (DecommitSize > DecommitBase) - { - DecommitSize -= DecommitBase; - } - else - { - /* Nothing to decommit */ - RtlpInsertFreeBlock(Heap, FreeEntry, Size); - return; - } - - /* A decommit is necessary. Create a UCR descriptor */ - UcrDescriptor = RtlpCreateUnCommittedRange(Segment); - if (!UcrDescriptor) - { - DPRINT1("HEAP: Failed to create UCR descriptor\n"); - RtlpInsertFreeBlock(Heap, FreeEntry, PrecedingSize); - return; - } - - /* Decommit the memory */ - Status = ZwFreeVirtualMemory(NtCurrentProcess(), - (PVOID *)&DecommitBase, - &DecommitSize, - MEM_DECOMMIT); - - /* Delete that UCR. This is needed to assure there is an unused UCR entry in the list */ - RtlpDestroyUnCommittedRange(Segment, UcrDescriptor); - - if (!NT_SUCCESS(Status)) - { - RtlpInsertFreeBlock(Heap, FreeEntry, Size); - return; - } - - /* Insert uncommitted pages */ - RtlpInsertUnCommittedPages(Segment, DecommitBase, DecommitSize); - Segment->NumberOfUnCommittedPages += (DecommitSize / PAGE_SIZE); - - if (PrecedingSize) - { - /* Adjust size of this free entry and insert it */ - FreeEntry->Flags = HEAP_ENTRY_LAST_ENTRY; - FreeEntry->Size = PrecedingSize; - Heap->TotalFreeSize += PrecedingSize; - - /* Set last entry in the segment to this entry */ - Segment->LastEntryInSegment = (PHEAP_ENTRY)FreeEntry; - - /* Insert it into the free list */ - RtlpInsertFreeBlockHelper(Heap, FreeEntry, PrecedingSize, FALSE); - } - else if (PrecedingInUseEntry) - { - /* Adjust preceding in use entry */ - PrecedingInUseEntry->Flags |= HEAP_ENTRY_LAST_ENTRY; - Segment->LastEntryInSegment = PrecedingInUseEntry; - } else if ((ULONG_PTR)Segment->LastEntryInSegment >= DecommitBase && - ((PCHAR)Segment->LastEntryInSegment < ((PCHAR)DecommitBase + DecommitSize))) - { - /* Update this segment's last entry */ - Segment->LastEntryInSegment = Segment->FirstEntry; - } - - /* Now the next one */ - if (NextSize) - { - /* Adjust size of this free entry and insert it */ - NextFreeEntry->Flags = 0; - NextFreeEntry->PreviousSize = 0; - NextFreeEntry->SegmentOffset = Segment->Entry.SegmentOffset; - NextFreeEntry->Size = NextSize; - - ((PHEAP_FREE_ENTRY)((PHEAP_ENTRY)NextFreeEntry + NextSize))->PreviousSize = NextSize; - - Heap->TotalFreeSize += NextSize; - RtlpInsertFreeBlockHelper(Heap, NextFreeEntry, NextSize, FALSE); - } - else if (NextInUseEntry) - { - NextInUseEntry->PreviousSize = 0; - } -} - -BOOLEAN NTAPI -RtlpInitializeHeapSegment(PHEAP Heap, - PHEAP_SEGMENT Segment, - UCHAR SegmentIndex, - ULONG Flags, - PVOID BaseAddress, - PVOID UncommittedBase, - PVOID LimitAddress) -{ - ULONG Pages, CommitSize; - PHEAP_ENTRY HeapEntry; - USHORT PreviousSize = 0, NewSize; - NTSTATUS Status; - - Pages = ((PCHAR)LimitAddress - (PCHAR)BaseAddress) / PAGE_SIZE; - - HeapEntry = (PHEAP_ENTRY)ROUND_UP(Segment + 1, HEAP_ENTRY_SIZE); - - DPRINT("RtlpInitializeHeapSegment(%p %p %x %x %p %p %p)\n", Heap, Segment, SegmentIndex, Flags, BaseAddress, UncommittedBase, LimitAddress); - DPRINT("Pages %x, HeapEntry %p, sizeof(HEAP_SEGMENT) %x\n", Pages, HeapEntry, sizeof(HEAP_SEGMENT)); - - /* Check if it's the first segment and remember its size */ - if (Heap == BaseAddress) - PreviousSize = Heap->Entry.Size; - - NewSize = ((PCHAR)HeapEntry - (PCHAR)Segment) >> HEAP_ENTRY_SHIFT; - - if ((PVOID)(HeapEntry + 1) >= UncommittedBase) - { - /* Check if it goes beyond the limit */ - if ((PVOID)(HeapEntry + 1) >= LimitAddress) - return FALSE; - - /* Need to commit memory */ - CommitSize = (PCHAR)(HeapEntry + 1) - (PCHAR)UncommittedBase; - Status = ZwAllocateVirtualMemory(NtCurrentProcess(), - (PVOID)&UncommittedBase, - 0, - &CommitSize, - MEM_COMMIT, - PAGE_READWRITE); - if (!NT_SUCCESS(Status)) - { - DPRINT1("Committing page failed with status 0x%08X\n", Status); - return FALSE; - } - - DPRINT("Committed %d bytes at base %p\n", CommitSize, UncommittedBase); - - /* Calcule the new uncommitted base */ - UncommittedBase = (PVOID)((PCHAR)UncommittedBase + CommitSize); - } - - /* Initialize the segment entry */ - Segment->Entry.PreviousSize = PreviousSize; - Segment->Entry.Size = NewSize; - Segment->Entry.Flags = HEAP_ENTRY_BUSY; - Segment->Entry.SegmentOffset = SegmentIndex; - - /* Initialize the segment itself */ - Segment->SegmentSignature = HEAP_SEGMENT_SIGNATURE; - Segment->Heap = Heap; - Segment->BaseAddress = BaseAddress; - Segment->FirstEntry = HeapEntry; - Segment->LastValidEntry = (PHEAP_ENTRY)((PCHAR)BaseAddress + Pages * PAGE_SIZE); - Segment->NumberOfPages = Pages; - Segment->NumberOfUnCommittedPages = ((PCHAR)LimitAddress - (PCHAR)UncommittedBase) / PAGE_SIZE; - InitializeListHead(&Segment->UCRSegmentList); - - /* Insert uncommitted pages into UCR (uncommitted ranges) list */ - if (Segment->NumberOfUnCommittedPages) - { - RtlpInsertUnCommittedPages(Segment, (ULONG_PTR)UncommittedBase, Segment->NumberOfUnCommittedPages * PAGE_SIZE); - } - - /* Set the segment index pointer */ - Heap->Segments[SegmentIndex] = Segment; - - /* Prepare a free heap entry */ - HeapEntry->Flags = HEAP_ENTRY_LAST_ENTRY; - HeapEntry->PreviousSize = Segment->Entry.Size; - HeapEntry->SegmentOffset = SegmentIndex; - - /* Set last entry in segment */ - Segment->LastEntryInSegment = HeapEntry; - - /* Insert it */ - RtlpInsertFreeBlock(Heap, (PHEAP_FREE_ENTRY)HeapEntry, (PHEAP_ENTRY)UncommittedBase - HeapEntry); - - return TRUE; -} - -VOID NTAPI -RtlpDestroyHeapSegment(PHEAP_SEGMENT Segment) -{ - NTSTATUS Status; - PVOID BaseAddress; - SIZE_T Size = 0; - - /* Make sure it's not user allocated */ - if (Segment->SegmentFlags & HEAP_USER_ALLOCATED) return; - - BaseAddress = Segment->BaseAddress; - DPRINT("Destroying segment %p, BA %p\n", Segment, BaseAddress); - - /* Release virtual memory */ - Status = ZwFreeVirtualMemory(NtCurrentProcess(), - &BaseAddress, - &Size, - MEM_RELEASE); - - if (!NT_SUCCESS(Status)) - { - DPRINT1("HEAP: Failed to release segment's memory with status 0x%08X\n", Status); - } -} - -/* Usermode only! */ -VOID NTAPI -RtlpAddHeapToProcessList(PHEAP Heap) -{ - PPEB Peb; - - /* Get PEB */ - Peb = RtlGetCurrentPeb(); - - /* Acquire the lock */ - RtlEnterHeapLock(&RtlpProcessHeapsListLock); - - //_SEH2_TRY { - /* Check if max number of heaps reached */ - if (Peb->NumberOfHeaps == Peb->MaximumNumberOfHeaps) - { - // TODO: Handle this case - ASSERT(FALSE); - } - - /* Add the heap to the process heaps */ - Peb->ProcessHeaps[Peb->NumberOfHeaps] = Heap; - Peb->NumberOfHeaps++; - Heap->ProcessHeapsListIndex = Peb->NumberOfHeaps; - // } _SEH2_FINALLY { - - /* Release the lock */ - RtlLeaveHeapLock(&RtlpProcessHeapsListLock); - - // } _SEH2_END -} - -/* Usermode only! */ -VOID NTAPI -RtlpRemoveHeapFromProcessList(PHEAP Heap) -{ - PPEB Peb; - PHEAP *Current, *Next; - ULONG Count; - - /* Get PEB */ - Peb = RtlGetCurrentPeb(); - - /* Acquire the lock */ - RtlEnterHeapLock(&RtlpProcessHeapsListLock); - - /* Check if we don't need anything to do */ - if ((Heap->ProcessHeapsListIndex == 0) || - (Heap->ProcessHeapsListIndex > Peb->NumberOfHeaps) || - (Peb->NumberOfHeaps == 0)) - { - /* Release the lock */ - RtlLeaveHeapLock(&RtlpProcessHeapsListLock); - - return; - } - - /* The process actually has more than one heap. - Use classic, lernt from university times algorithm for removing an entry - from a static array */ - - Current = (PHEAP *)&Peb->ProcessHeaps[Heap->ProcessHeapsListIndex - 1]; - Next = Current + 1; - - /* How many items we need to shift to the left */ - Count = Peb->NumberOfHeaps - (Heap->ProcessHeapsListIndex - 1); - - /* Move them all in a loop */ - while (--Count) - { - /* Copy it and advance next pointer */ - *Current = *Next; - - /* Update its index */ - (*Current)->ProcessHeapsListIndex -= 1; - - /* Advance pointers */ - Current++; - Next++; - } - - /* Decrease total number of heaps */ - Peb->NumberOfHeaps--; - - /* Zero last unused item */ - Peb->ProcessHeaps[Peb->NumberOfHeaps] = NULL; - Heap->ProcessHeapsListIndex = 0; - - /* Release the lock */ - RtlLeaveHeapLock(&RtlpProcessHeapsListLock); -} - -PHEAP_FREE_ENTRY NTAPI -RtlpCoalesceHeap(PHEAP Heap) -{ - UNIMPLEMENTED; - return NULL; -} - -PHEAP_FREE_ENTRY NTAPI -RtlpCoalesceFreeBlocks (PHEAP Heap, - PHEAP_FREE_ENTRY FreeEntry, - PSIZE_T FreeSize, - BOOLEAN Remove) -{ - PHEAP_FREE_ENTRY CurrentEntry, NextEntry; - - /* Get the previous entry */ - CurrentEntry = (PHEAP_FREE_ENTRY)((PHEAP_ENTRY)FreeEntry - FreeEntry->PreviousSize); - - /* Check it */ - if (CurrentEntry != FreeEntry && - !(CurrentEntry->Flags & HEAP_ENTRY_BUSY) && - (*FreeSize + CurrentEntry->Size) <= HEAP_MAX_BLOCK_SIZE) - { - ASSERT(FreeEntry->PreviousSize == CurrentEntry->Size); - - /* Remove it if asked for */ - if (Remove) - { - RtlpRemoveFreeBlock(Heap, FreeEntry, FALSE, FALSE); - Heap->TotalFreeSize -= FreeEntry->Size; - - /* Remove it only once! */ - Remove = FALSE; - } - - /* Remove previous entry too */ - RtlpRemoveFreeBlock(Heap, CurrentEntry, FALSE, FALSE); - - /* Copy flags */ - CurrentEntry->Flags = FreeEntry->Flags & HEAP_ENTRY_LAST_ENTRY; - - /* Update last entry in the segment */ - if (CurrentEntry->Flags & HEAP_ENTRY_LAST_ENTRY) - Heap->Segments[CurrentEntry->SegmentOffset]->LastEntryInSegment = (PHEAP_ENTRY)CurrentEntry; - - /* Advance FreeEntry and update sizes */ - FreeEntry = CurrentEntry; - *FreeSize = *FreeSize + CurrentEntry->Size; - Heap->TotalFreeSize -= CurrentEntry->Size; - FreeEntry->Size = *FreeSize; - - /* Also update previous size if needed */ - if (!(FreeEntry->Flags & HEAP_ENTRY_LAST_ENTRY)) - { - ((PHEAP_ENTRY)FreeEntry + *FreeSize)->PreviousSize = *FreeSize; - } - } - - /* Check the next block if it exists */ - if (!(FreeEntry->Flags & HEAP_ENTRY_LAST_ENTRY)) - { - NextEntry = (PHEAP_FREE_ENTRY)((PHEAP_ENTRY)FreeEntry + *FreeSize); - - if (!(NextEntry->Flags & HEAP_ENTRY_BUSY) && - NextEntry->Size + *FreeSize <= HEAP_MAX_BLOCK_SIZE) - { - ASSERT(*FreeSize == NextEntry->PreviousSize); - - /* Remove it if asked for */ - if (Remove) - { - RtlpRemoveFreeBlock(Heap, FreeEntry, FALSE, FALSE); - Heap->TotalFreeSize -= FreeEntry->Size; - } - - /* Copy flags */ - FreeEntry->Flags = NextEntry->Flags & HEAP_ENTRY_LAST_ENTRY; - - /* Update last entry in the segment */ - if (FreeEntry->Flags & HEAP_ENTRY_LAST_ENTRY) - Heap->Segments[FreeEntry->SegmentOffset]->LastEntryInSegment = (PHEAP_ENTRY)FreeEntry; - - /* Remove next entry now */ - RtlpRemoveFreeBlock(Heap, NextEntry, FALSE, FALSE); - - /* Update sizes */ - *FreeSize = *FreeSize + NextEntry->Size; - Heap->TotalFreeSize -= NextEntry->Size; - FreeEntry->Size = *FreeSize; - - /* Also update previous size if needed */ - if (!(FreeEntry->Flags & HEAP_ENTRY_LAST_ENTRY)) - { - ((PHEAP_ENTRY)FreeEntry + *FreeSize)->PreviousSize = *FreeSize; - } - } - } - return FreeEntry; -} - -PHEAP_FREE_ENTRY NTAPI -RtlpExtendHeap(PHEAP Heap, - SIZE_T Size) -{ - ULONG Pages; - UCHAR Index, EmptyIndex; - SIZE_T FreeSize, CommitSize, ReserveSize; - PHEAP_SEGMENT Segment; - PHEAP_FREE_ENTRY FreeEntry; - NTSTATUS Status; - - DPRINT("RtlpExtendHeap(%p %x)\n", Heap, Size); - - /* Calculate amount in pages */ - Pages = (Size + PAGE_SIZE - 1) / PAGE_SIZE; - FreeSize = Pages * PAGE_SIZE; - DPRINT("Pages %x, FreeSize %x. Going through segments...\n", Pages, FreeSize); - - /* Find an empty segment */ - EmptyIndex = HEAP_SEGMENTS; - for (Index = 0; Index < HEAP_SEGMENTS; Index++) - { - Segment = Heap->Segments[Index]; - - if (Segment) DPRINT("Segment[%d] %p with NOUCP %x\n", Index, Segment, Segment->NumberOfUnCommittedPages); - - /* Check if its size suits us */ - if (Segment && - Pages <= Segment->NumberOfUnCommittedPages) - { - DPRINT("This segment is suitable\n"); - - /* Commit needed amount */ - FreeEntry = RtlpFindAndCommitPages(Heap, Segment, &FreeSize, NULL); - - /* Coalesce it with adjacent entries */ - if (FreeEntry) - { - FreeSize = FreeSize >> HEAP_ENTRY_SHIFT; - FreeEntry = RtlpCoalesceFreeBlocks(Heap, FreeEntry, &FreeSize, FALSE); - RtlpInsertFreeBlock(Heap, FreeEntry, FreeSize); - return FreeEntry; - } - } - else if (!Segment && - EmptyIndex == HEAP_SEGMENTS) - { - /* Remember the first unused segment index */ - EmptyIndex = Index; - } - } - - /* No luck, need to grow the heap */ - if ((Heap->Flags & HEAP_GROWABLE) && - (EmptyIndex != HEAP_SEGMENTS)) - { - Segment = NULL; - - /* Reserve the memory */ - if ((Size + PAGE_SIZE) <= Heap->SegmentReserve) - ReserveSize = Heap->SegmentReserve; - else - ReserveSize = Size + PAGE_SIZE; - - Status = ZwAllocateVirtualMemory(NtCurrentProcess(), - (PVOID)&Segment, - 0, - &ReserveSize, - MEM_RESERVE, - PAGE_READWRITE); - - /* If it failed, retry again with a half division algorithm */ - while (!NT_SUCCESS(Status) && - ReserveSize != Size + PAGE_SIZE) - { - ReserveSize /= 2; - - if (ReserveSize < (Size + PAGE_SIZE)) - ReserveSize = Size + PAGE_SIZE; - - Status = ZwAllocateVirtualMemory(NtCurrentProcess(), - (PVOID)&Segment, - 0, - &ReserveSize, - MEM_RESERVE, - PAGE_READWRITE); - } - - /* Proceed only if it's success */ - if (NT_SUCCESS(Status)) - { - Heap->SegmentReserve += ReserveSize; - - /* Now commit the memory */ - if ((Size + PAGE_SIZE) <= Heap->SegmentCommit) - CommitSize = Heap->SegmentCommit; - else - CommitSize = Size + PAGE_SIZE; - - Status = ZwAllocateVirtualMemory(NtCurrentProcess(), - (PVOID)&Segment, - 0, - &CommitSize, - MEM_COMMIT, - PAGE_READWRITE); - - DPRINT("Committed %d bytes at base %p\n", CommitSize, Segment); - - /* Initialize heap segment if commit was successful */ - if (NT_SUCCESS(Status)) - { - if (!RtlpInitializeHeapSegment(Heap, Segment, EmptyIndex, 0, Segment, - (PCHAR)Segment + CommitSize, (PCHAR)Segment + ReserveSize)) - { - Status = STATUS_NO_MEMORY; - } - } - - /* If everything worked - cool */ - if (NT_SUCCESS(Status)) return (PHEAP_FREE_ENTRY)Segment->FirstEntry; - - DPRINT1("Committing failed with status 0x%08X\n", Status); - - /* Nope, we failed. Free memory */ - ZwFreeVirtualMemory(NtCurrentProcess(), - (PVOID)&Segment, - &ReserveSize, - MEM_RELEASE); - } - else - { - DPRINT1("Reserving failed with status 0x%08X\n", Status); - } - } - - if (RtlpGetMode() == UserMode) - { - /* If coalescing on free is disabled in usermode, then do it here */ - if (Heap->Flags & HEAP_DISABLE_COALESCE_ON_FREE) - { - FreeEntry = RtlpCoalesceHeap(Heap); - - /* If it's a suitable one - return it */ - if (FreeEntry && - FreeEntry->Size >= Size) - { - return FreeEntry; - } - } - } - - return NULL; -} - -/*********************************************************************** - * RtlCreateHeap - * RETURNS - * Handle of heap: Success - * NULL: Failure - * - * @implemented - */ -HANDLE NTAPI -RtlCreateHeap(ULONG Flags, - PVOID Addr, - SIZE_T TotalSize, - SIZE_T CommitSize, - PVOID Lock, - PRTL_HEAP_PARAMETERS Parameters) -{ - PVOID CommittedAddress = NULL, UncommittedAddress = NULL; - PHEAP Heap = NULL; - RTL_HEAP_PARAMETERS SafeParams = {0}; - PPEB Peb; - ULONG_PTR MaximumUserModeAddress; - SYSTEM_BASIC_INFORMATION SystemInformation; - MEMORY_BASIC_INFORMATION MemoryInfo; - ULONG NtGlobalFlags = RtlGetNtGlobalFlags(); - ULONG HeapSegmentFlags = 0; - NTSTATUS Status; - ULONG MaxBlockSize, HeaderSize; - BOOLEAN AllocateLock = FALSE; - - /* Check for a special heap */ - if (RtlpPageHeapEnabled && !Addr && !Lock) - { - Heap = RtlpPageHeapCreate(Flags, Addr, TotalSize, CommitSize, Lock, Parameters); - if (Heap) return Heap; - - //ASSERT(FALSE); - DPRINT1("Enabling page heap failed\n"); - } - - /* Check validation flags */ - if (!(Flags & HEAP_SKIP_VALIDATION_CHECKS) && (Flags & ~HEAP_CREATE_VALID_MASK)) - { - DPRINT1("Invalid flags 0x%08x, fixing...\n", Flags); - Flags &= HEAP_CREATE_VALID_MASK; - } - - /* TODO: Capture parameters, once we decide to use SEH */ - if (!Parameters) Parameters = &SafeParams; - - /* Check global flags */ - if (NtGlobalFlags & FLG_HEAP_DISABLE_COALESCING) - Flags |= HEAP_DISABLE_COALESCE_ON_FREE; - - if (NtGlobalFlags & FLG_HEAP_ENABLE_FREE_CHECK) - Flags |= HEAP_FREE_CHECKING_ENABLED; - - if (NtGlobalFlags & FLG_HEAP_ENABLE_TAIL_CHECK) - Flags |= HEAP_TAIL_CHECKING_ENABLED; - - if (RtlpGetMode() == UserMode) - { - /* Also check these flags if in usermode */ - if (NtGlobalFlags & FLG_HEAP_VALIDATE_ALL) - Flags |= HEAP_VALIDATE_ALL_ENABLED; - - if (NtGlobalFlags & FLG_HEAP_VALIDATE_PARAMETERS) - Flags |= HEAP_VALIDATE_PARAMETERS_ENABLED; - - if (NtGlobalFlags & FLG_USER_STACK_TRACE_DB) - Flags |= HEAP_CAPTURE_STACK_BACKTRACES; - - /* Get PEB */ - Peb = RtlGetCurrentPeb(); - - /* Apply defaults for non-set parameters */ - if (!Parameters->SegmentCommit) Parameters->SegmentCommit = Peb->HeapSegmentCommit; - if (!Parameters->SegmentReserve) Parameters->SegmentReserve = Peb->HeapSegmentReserve; - if (!Parameters->DeCommitFreeBlockThreshold) Parameters->DeCommitFreeBlockThreshold = Peb->HeapDeCommitFreeBlockThreshold; - if (!Parameters->DeCommitTotalFreeThreshold) Parameters->DeCommitTotalFreeThreshold = Peb->HeapDeCommitTotalFreeThreshold; - } - else - { - /* Apply defaults for non-set parameters */ -#if 0 - if (!Parameters->SegmentCommit) Parameters->SegmentCommit = MmHeapSegmentCommit; - if (!Parameters->SegmentReserve) Parameters->SegmentReserve = MmHeapSegmentReserve; - if (!Parameters->DeCommitFreeBlockThreshold) Parameters->DeCommitFreeBlockThreshold = MmHeapDeCommitFreeBlockThreshold; - if (!Parameters->DeCommitTotalFreeThreshold) Parameters->DeCommitTotalFreeThreshold = MmHeapDeCommitTotalFreeThreshold; -#endif - } - - // FIXME: Move to memory manager - if (!Parameters->SegmentCommit) Parameters->SegmentCommit = PAGE_SIZE * 2; - if (!Parameters->SegmentReserve) Parameters->SegmentReserve = 1048576; - if (!Parameters->DeCommitFreeBlockThreshold) Parameters->DeCommitFreeBlockThreshold = PAGE_SIZE; - if (!Parameters->DeCommitTotalFreeThreshold) Parameters->DeCommitTotalFreeThreshold = 65536; - - /* Get the max um address */ - Status = ZwQuerySystemInformation(SystemBasicInformation, - &SystemInformation, - sizeof(SystemInformation), - NULL); - - if (!NT_SUCCESS(Status)) - { - DPRINT1("Getting max usermode address failed with status 0x%08x\n", Status); - return NULL; - } - - MaximumUserModeAddress = SystemInformation.MaximumUserModeAddress; - - /* Calculate max alloc size */ - if (!Parameters->MaximumAllocationSize) - Parameters->MaximumAllocationSize = MaximumUserModeAddress - (ULONG_PTR)0x10000 - PAGE_SIZE; - - MaxBlockSize = 0x80000 - PAGE_SIZE; - - if (!Parameters->VirtualMemoryThreshold || - Parameters->VirtualMemoryThreshold > MaxBlockSize) - { - Parameters->VirtualMemoryThreshold = MaxBlockSize; - } - - /* Check reserve/commit sizes and set default values */ - if (!CommitSize) - { - CommitSize = PAGE_SIZE; - if (TotalSize) - TotalSize = ROUND_UP(TotalSize, PAGE_SIZE); - else - TotalSize = 64 * PAGE_SIZE; - } - else - { - /* Round up the commit size to be at least the page size */ - CommitSize = ROUND_UP(CommitSize, PAGE_SIZE); - - if (TotalSize) - TotalSize = ROUND_UP(TotalSize, PAGE_SIZE); - else - TotalSize = ROUND_UP(CommitSize, 16 * PAGE_SIZE); - } - - /* Call special heap */ - if (RtlpHeapIsSpecial(Flags)) - return RtlDebugCreateHeap(Flags, Addr, TotalSize, CommitSize, Lock, Parameters); - - /* Calculate header size */ - HeaderSize = sizeof(HEAP); - if (!(Flags & HEAP_NO_SERIALIZE)) - { - if (Lock) - { - Flags |= HEAP_LOCK_USER_ALLOCATED; - } - else - { - HeaderSize += sizeof(HEAP_LOCK); - AllocateLock = TRUE; - } - } - else if (Lock) - { - /* Invalid parameters */ - return NULL; - } - - /* See if we are already provided with an address for the heap */ - if (Addr) - { - if (Parameters->CommitRoutine) - { - /* There is a commit routine, so no problem here, check params */ - if ((Flags & HEAP_GROWABLE) || - !Parameters->InitialCommit || - !Parameters->InitialReserve || - (Parameters->InitialCommit > Parameters->InitialReserve)) - { - /* Fail */ - return NULL; - } - - /* Calculate committed and uncommitted addresses */ - CommittedAddress = Addr; - UncommittedAddress = (PCHAR)Addr + Parameters->InitialCommit; - TotalSize = Parameters->InitialReserve; - - /* Zero the initial page ourselves */ - RtlZeroMemory(CommittedAddress, PAGE_SIZE); - } - else - { - /* Commit routine is absent, so query how much memory caller reserved */ - Status = ZwQueryVirtualMemory(NtCurrentProcess(), - Addr, - MemoryBasicInformation, - &MemoryInfo, - sizeof(MemoryInfo), - NULL); - - if (!NT_SUCCESS(Status)) - { - DPRINT1("Querying amount of user supplied memory failed with status 0x%08X\n", Status); - return NULL; - } - - /* Validate it */ - if (MemoryInfo.BaseAddress != Addr || - MemoryInfo.State == MEM_FREE) - { - return NULL; - } - - /* Validation checks passed, set committed/uncommitted addresses */ - CommittedAddress = Addr; - - /* Check if it's committed or not */ - if (MemoryInfo.State == MEM_COMMIT) - { - /* Zero it out because it's already committed */ - RtlZeroMemory(CommittedAddress, PAGE_SIZE); - - /* Calculate uncommitted address value */ - CommitSize = MemoryInfo.RegionSize; - TotalSize = CommitSize; - UncommittedAddress = (PCHAR)Addr + CommitSize; - - /* Check if uncommitted address is reserved */ - Status = ZwQueryVirtualMemory(NtCurrentProcess(), - UncommittedAddress, - MemoryBasicInformation, - &MemoryInfo, - sizeof(MemoryInfo), - NULL); - - if (NT_SUCCESS(Status) && - MemoryInfo.State == MEM_RESERVE) - { - /* It is, so add it up to the reserve size */ - TotalSize += MemoryInfo.RegionSize; - } - } - else - { - /* It's not committed, inform following code that a commit is necessary */ - CommitSize = PAGE_SIZE; - UncommittedAddress = Addr; - } - } - - /* Mark this as a user-committed mem */ - HeapSegmentFlags = HEAP_USER_ALLOCATED; - Heap = (PHEAP)Addr; - } - else - { - /* Check commit routine */ - if (Parameters->CommitRoutine) return NULL; - - /* Reserve memory */ - Status = ZwAllocateVirtualMemory(NtCurrentProcess(), - (PVOID *)&Heap, - 0, - &TotalSize, - MEM_RESERVE, - PAGE_READWRITE); - - if (!NT_SUCCESS(Status)) - { - DPRINT1("Failed to reserve memory with status 0x%08x\n", Status); - return NULL; - } - - /* Set base addresses */ - CommittedAddress = Heap; - UncommittedAddress = Heap; - } - - /* Check if we need to commit something */ - if (CommittedAddress == UncommittedAddress) - { - /* Commit the required size */ - Status = ZwAllocateVirtualMemory(NtCurrentProcess(), - &CommittedAddress, - 0, - &CommitSize, - MEM_COMMIT, - PAGE_READWRITE); - - DPRINT("Committed %d bytes at base %p\n", CommitSize, CommittedAddress); - - if (!NT_SUCCESS(Status)) - { - DPRINT1("Failure, Status 0x%08X\n", Status); - - /* Release memory if it was reserved */ - if (!Addr) ZwFreeVirtualMemory(NtCurrentProcess(), - (PVOID *)&Heap, - &TotalSize, - MEM_RELEASE); - - return NULL; - } - - /* Calculate new uncommitted address */ - UncommittedAddress = (PCHAR)UncommittedAddress + CommitSize; - } - - DPRINT("Created heap %p, CommitSize %x, ReserveSize %x\n", Heap, CommitSize, TotalSize); - - /* Initialize the heap */ - RtlpInitializeHeap(Heap, &HeaderSize, Flags, AllocateLock, Lock); - - /* Initialize heap's first segment */ - if (!RtlpInitializeHeapSegment(Heap, - (PHEAP_SEGMENT)((PCHAR)Heap + HeaderSize), - 0, - HeapSegmentFlags, - CommittedAddress, - UncommittedAddress, - (PCHAR)CommittedAddress + TotalSize)) - { - DPRINT1("Failed to initialize heap segment\n"); - return NULL; - } - - /* Set other data */ - Heap->ProcessHeapsListIndex = 0; - Heap->SegmentCommit = Parameters->SegmentCommit; - Heap->SegmentReserve = Parameters->SegmentReserve; - Heap->DeCommitFreeBlockThreshold = Parameters->DeCommitFreeBlockThreshold >> HEAP_ENTRY_SHIFT; - Heap->DeCommitTotalFreeThreshold = Parameters->DeCommitTotalFreeThreshold >> HEAP_ENTRY_SHIFT; - Heap->MaximumAllocationSize = Parameters->MaximumAllocationSize; - Heap->VirtualMemoryThreshold = ROUND_UP(Parameters->VirtualMemoryThreshold, HEAP_ENTRY_SIZE) >> HEAP_ENTRY_SHIFT; - Heap->CommitRoutine = Parameters->CommitRoutine; - - /* Set alignment */ - if (Flags & HEAP_CREATE_ALIGN_16) - { - Heap->AlignMask = (ULONG)~15; - Heap->AlignRound = 15 + sizeof(HEAP_ENTRY); - } - else - { - Heap->AlignMask = (ULONG)~(HEAP_ENTRY_SIZE - 1); - Heap->AlignRound = HEAP_ENTRY_SIZE - 1 + sizeof(HEAP_ENTRY); - } - - if (Heap->Flags & HEAP_TAIL_CHECKING_ENABLED) - Heap->AlignRound += HEAP_ENTRY_SIZE; - - /* Add heap to process list in case of usermode heap */ - if (RtlpGetMode() == UserMode) - { - RtlpAddHeapToProcessList(Heap); - - // FIXME: What about lookasides? - } - - DPRINT("Heap %p, flags 0x%08x\n", Heap, Heap->Flags); - return Heap; -} - -/*********************************************************************** - * RtlDestroyHeap - * RETURNS - * TRUE: Success - * FALSE: Failure - * - * @implemented - * - * RETURNS - * Success: A NULL HANDLE, if heap is NULL or it was destroyed - * Failure: The Heap handle, if heap is the process heap. - */ -HANDLE NTAPI -RtlDestroyHeap(HANDLE HeapPtr) /* [in] Handle of heap */ -{ - PHEAP Heap = (PHEAP)HeapPtr; - PLIST_ENTRY Current; - PHEAP_UCR_SEGMENT UcrSegment; - PHEAP_VIRTUAL_ALLOC_ENTRY VirtualEntry; - PVOID BaseAddress; - SIZE_T Size; - LONG i; - PHEAP_SEGMENT Segment; - - if (!HeapPtr) return NULL; - - /* Call special heap */ - if (RtlpHeapIsSpecial(Heap->Flags)) - { - if (!RtlDebugDestroyHeap(Heap)) return HeapPtr; - } - - /* Check for a process heap */ - if (RtlpGetMode() == UserMode && - HeapPtr == NtCurrentPeb()->ProcessHeap) return HeapPtr; - - /* Free up all big allocations */ - Current = Heap->VirtualAllocdBlocks.Flink; - while (Current != &Heap->VirtualAllocdBlocks) - { - VirtualEntry = CONTAINING_RECORD(Current, HEAP_VIRTUAL_ALLOC_ENTRY, Entry); - BaseAddress = (PVOID)VirtualEntry; - Current = Current->Flink; - Size = 0; - ZwFreeVirtualMemory(NtCurrentProcess(), - &BaseAddress, - &Size, - MEM_RELEASE); - } - - /* Delete tags and remove heap from the process heaps list in user mode */ - if (RtlpGetMode() == UserMode) - { - // FIXME DestroyTags - RtlpRemoveHeapFromProcessList(Heap); - } - - /* Delete the heap lock */ - if (!(Heap->Flags & HEAP_NO_SERIALIZE)) - { - /* Delete it if it wasn't user allocated */ - if (!(Heap->Flags & HEAP_LOCK_USER_ALLOCATED)) - RtlDeleteHeapLock(Heap->LockVariable); - - /* Clear out the lock variable */ - Heap->LockVariable = NULL; - } - - /* Free UCR segments if any were created */ - Current = Heap->UCRSegments.Flink; - while(Current != &Heap->UCRSegments) - { - UcrSegment = CONTAINING_RECORD(Current, HEAP_UCR_SEGMENT, ListEntry); - - /* Advance to the next descriptor */ - Current = Current->Flink; - - BaseAddress = (PVOID)UcrSegment; - Size = 0; - - /* Release that memory */ - ZwFreeVirtualMemory(NtCurrentProcess(), - &BaseAddress, - &Size, - MEM_RELEASE); - } - - /* Go through segments and destroy them */ - for (i = HEAP_SEGMENTS - 1; i >= 0; i--) - { - Segment = Heap->Segments[i]; - if (Segment) RtlpDestroyHeapSegment(Segment); - } - - return NULL; -} - -PHEAP_ENTRY NTAPI -RtlpSplitEntry(PHEAP Heap, - PHEAP_FREE_ENTRY FreeBlock, - SIZE_T AllocationSize, - SIZE_T Index, - SIZE_T Size) -{ - PHEAP_FREE_ENTRY SplitBlock, SplitBlock2; - UCHAR FreeFlags; - PHEAP_ENTRY InUseEntry; - SIZE_T FreeSize; - - /* Save flags, update total free size */ - FreeFlags = FreeBlock->Flags; - Heap->TotalFreeSize -= FreeBlock->Size; - - /* Make this block an in-use one */ - InUseEntry = (PHEAP_ENTRY)FreeBlock; - InUseEntry->Flags = HEAP_ENTRY_BUSY; - InUseEntry->SmallTagIndex = 0; - - /* Calculate the extra amount */ - FreeSize = InUseEntry->Size - Index; - - /* Update it's size fields (we don't need their data anymore) */ - InUseEntry->Size = Index; - InUseEntry->UnusedBytes = AllocationSize - Size; - - /* If there is something to split - do the split */ - if (FreeSize != 0) - { - /* Don't split if resulting entry can't contain any payload data - (i.e. being just HEAP_ENTRY_SIZE) */ - if (FreeSize == 1) - { - /* Increase sizes of the in-use entry */ - InUseEntry->Size++; - InUseEntry->UnusedBytes += sizeof(HEAP_ENTRY); - } - else - { - /* Calculate a pointer to the new entry */ - SplitBlock = (PHEAP_FREE_ENTRY)(InUseEntry + Index); - - /* Initialize it */ - SplitBlock->Flags = FreeFlags; - SplitBlock->SegmentOffset = InUseEntry->SegmentOffset; - SplitBlock->Size = FreeSize; - SplitBlock->PreviousSize = Index; - - /* Check if it's the last entry */ - if (FreeFlags & HEAP_ENTRY_LAST_ENTRY) - { - /* Insert it to the free list if it's the last entry */ - RtlpInsertFreeBlockHelper(Heap, SplitBlock, FreeSize, FALSE); - Heap->TotalFreeSize += FreeSize; - } - else - { - /* Not so easy - need to update next's previous size too */ - SplitBlock2 = (PHEAP_FREE_ENTRY)((PHEAP_ENTRY)SplitBlock + FreeSize); - - if (SplitBlock2->Flags & HEAP_ENTRY_BUSY) - { - SplitBlock2->PreviousSize = (USHORT)FreeSize; - RtlpInsertFreeBlockHelper(Heap, SplitBlock, FreeSize, FALSE); - Heap->TotalFreeSize += FreeSize; - } - else - { - /* Even more complex - the next entry is free, so we can merge them into one! */ - SplitBlock->Flags = SplitBlock2->Flags; - - /* Remove that next entry */ - RtlpRemoveFreeBlock(Heap, SplitBlock2, FALSE, FALSE); - - /* Update sizes */ - FreeSize += SplitBlock2->Size; - Heap->TotalFreeSize -= SplitBlock2->Size; - - if (FreeSize <= HEAP_MAX_BLOCK_SIZE) - { - /* Insert it back */ - SplitBlock->Size = FreeSize; - - /* Don't forget to update previous size of the next entry! */ - if (!(SplitBlock->Flags & HEAP_ENTRY_LAST_ENTRY)) - { - ((PHEAP_FREE_ENTRY)((PHEAP_ENTRY)SplitBlock + FreeSize))->PreviousSize = FreeSize; - } - - /* Actually insert it */ - RtlpInsertFreeBlockHelper(Heap, SplitBlock, (USHORT)FreeSize, FALSE); - - /* Update total size */ - Heap->TotalFreeSize += FreeSize; - } - else - { - /* Resulting block is quite big */ - RtlpInsertFreeBlock(Heap, SplitBlock, FreeSize); - } - } - } - - /* Reset flags of the free entry */ - FreeFlags = 0; - - /* Update last entry in segment */ - if (SplitBlock->Flags & HEAP_ENTRY_LAST_ENTRY) - { - Heap->Segments[SplitBlock->SegmentOffset]->LastEntryInSegment = (PHEAP_ENTRY)SplitBlock; - } - } - } - - /* Set last entry flag */ - if (FreeFlags & HEAP_ENTRY_LAST_ENTRY) - InUseEntry->Flags |= HEAP_ENTRY_LAST_ENTRY; - - return InUseEntry; -} - -PVOID NTAPI -RtlpAllocateNonDedicated(PHEAP Heap, - ULONG Flags, - SIZE_T Size, - SIZE_T AllocationSize, - SIZE_T Index, - BOOLEAN HeapLocked) -{ - PLIST_ENTRY FreeListHead, Next; - PHEAP_FREE_ENTRY FreeBlock; - PHEAP_ENTRY InUseEntry; - PHEAP_ENTRY_EXTRA Extra; - EXCEPTION_RECORD ExceptionRecord; - - /* Go through the zero list to find a place where to insert the new entry */ - FreeListHead = &Heap->FreeLists[0]; - - /* Start from the largest block to reduce time */ - Next = FreeListHead->Blink; - if (FreeListHead != Next) - { - FreeBlock = CONTAINING_RECORD(Next, HEAP_FREE_ENTRY, FreeList); - - if (FreeBlock->Size >= Index) - { - /* Our request is smaller than the largest entry in the zero list */ - - /* Go through the list to find insertion place */ - Next = FreeListHead->Flink; - while (FreeListHead != Next) - { - FreeBlock = CONTAINING_RECORD(Next, HEAP_FREE_ENTRY, FreeList); - - if (FreeBlock->Size >= Index) - { - /* Found minimally fitting entry. Proceed to either using it as it is - or splitting it to two entries */ - RemoveEntryList(&FreeBlock->FreeList); - - /* Split it */ - InUseEntry = RtlpSplitEntry(Heap, FreeBlock, AllocationSize, Index, Size); - - /* Release the lock */ - if (HeapLocked) RtlLeaveHeapLock(Heap->LockVariable); - - /* Zero memory if that was requested */ - if (Flags & HEAP_ZERO_MEMORY) - RtlZeroMemory(InUseEntry + 1, Size); - else if (Heap->Flags & HEAP_FREE_CHECKING_ENABLED) - { - /* Fill this block with a special pattern */ - RtlFillMemoryUlong(InUseEntry + 1, Size & ~0x3, ARENA_INUSE_FILLER); - } - - /* Fill tail of the block with a special pattern too if requested */ - if (Heap->Flags & HEAP_TAIL_CHECKING_ENABLED) - { - RtlFillMemory((PCHAR)(InUseEntry + 1) + Size, sizeof(HEAP_ENTRY), HEAP_TAIL_FILL); - InUseEntry->Flags |= HEAP_ENTRY_FILL_PATTERN; - } - - /* Prepare extra if it's present */ - if (InUseEntry->Flags & HEAP_ENTRY_EXTRA_PRESENT) - { - Extra = RtlpGetExtraStuffPointer(InUseEntry); - RtlZeroMemory(Extra, sizeof(HEAP_ENTRY_EXTRA)); - - // TODO: Tagging - } - - /* Return pointer to the */ - return InUseEntry + 1; - } - - /* Advance to the next entry */ - Next = Next->Flink; - } - } - } - - /* Extend the heap, 0 list didn't have anything suitable */ - FreeBlock = RtlpExtendHeap(Heap, AllocationSize); - - /* Use the new biggest entry we've got */ - if (FreeBlock) - { - RemoveEntryList(&FreeBlock->FreeList); - - /* Split it */ - InUseEntry = RtlpSplitEntry(Heap, FreeBlock, AllocationSize, Index, Size); - - /* Release the lock */ - if (HeapLocked) RtlLeaveHeapLock(Heap->LockVariable); - - /* Zero memory if that was requested */ - if (Flags & HEAP_ZERO_MEMORY) - RtlZeroMemory(InUseEntry + 1, Size); - else if (Heap->Flags & HEAP_FREE_CHECKING_ENABLED) - { - /* Fill this block with a special pattern */ - RtlFillMemoryUlong(InUseEntry + 1, Size & ~0x3, ARENA_INUSE_FILLER); - } - - /* Fill tail of the block with a special pattern too if requested */ - if (Heap->Flags & HEAP_TAIL_CHECKING_ENABLED) - { - RtlFillMemory((PCHAR)(InUseEntry + 1) + Size, sizeof(HEAP_ENTRY), HEAP_TAIL_FILL); - InUseEntry->Flags |= HEAP_ENTRY_FILL_PATTERN; - } - - /* Prepare extra if it's present */ - if (InUseEntry->Flags & HEAP_ENTRY_EXTRA_PRESENT) - { - Extra = RtlpGetExtraStuffPointer(InUseEntry); - RtlZeroMemory(Extra, sizeof(HEAP_ENTRY_EXTRA)); - - // TODO: Tagging - } - - /* Return pointer to the */ - return InUseEntry + 1; - } - - /* Really unfortunate, out of memory condition */ - RtlSetLastWin32ErrorAndNtStatusFromNtStatus(STATUS_NO_MEMORY); - - /* Generate an exception */ - if (Flags & HEAP_GENERATE_EXCEPTIONS) - { - ExceptionRecord.ExceptionCode = STATUS_NO_MEMORY; - ExceptionRecord.ExceptionRecord = NULL; - ExceptionRecord.NumberParameters = 1; - ExceptionRecord.ExceptionFlags = 0; - ExceptionRecord.ExceptionInformation[0] = AllocationSize; - - RtlRaiseException(&ExceptionRecord); - } - - /* Release the lock */ - if (HeapLocked) RtlLeaveHeapLock(Heap->LockVariable); - DPRINT1("HEAP: Allocation failed!\n"); - DPRINT1("Flags %x\n", Heap->Flags); - return NULL; -} - -/*********************************************************************** - * HeapAlloc (KERNEL32.334) - * RETURNS - * Pointer to allocated memory block - * NULL: Failure - * 0x7d030f60--invalid flags in RtlHeapAllocate - * @implemented - */ -PVOID NTAPI -RtlAllocateHeap(IN PVOID HeapPtr, - IN ULONG Flags, - IN SIZE_T Size) -{ - PHEAP Heap = (PHEAP)HeapPtr; - PULONG FreeListsInUse; - ULONG FreeListsInUseUlong; - SIZE_T AllocationSize; - SIZE_T Index; - PLIST_ENTRY FreeListHead; - PHEAP_ENTRY InUseEntry; - PHEAP_FREE_ENTRY FreeBlock; - ULONG InUseIndex, i; - UCHAR FreeFlags; - EXCEPTION_RECORD ExceptionRecord; - BOOLEAN HeapLocked = FALSE; - PHEAP_VIRTUAL_ALLOC_ENTRY VirtualBlock = NULL; - PHEAP_ENTRY_EXTRA Extra; - NTSTATUS Status; - - /* Force flags */ - Flags |= Heap->ForceFlags; - - /* Call special heap */ - if (RtlpHeapIsSpecial(Flags)) - return RtlDebugAllocateHeap(Heap, Flags, Size); - - /* Check for the maximum size */ - if (Size >= 0x80000000) - { - RtlSetLastWin32ErrorAndNtStatusFromNtStatus(STATUS_NO_MEMORY); - DPRINT1("HEAP: Allocation failed!\n"); - return NULL; - } - - if (Flags & (HEAP_CREATE_ENABLE_TRACING | - HEAP_CREATE_ALIGN_16)) - { - DPRINT1("HEAP: RtlAllocateHeap is called with unsupported flags %x, ignoring\n", Flags); - } - - //DPRINT("RtlAllocateHeap(%p %x %x)\n", Heap, Flags, Size); - - /* Calculate allocation size and index */ - if (Size) - AllocationSize = Size; - else - AllocationSize = 1; - AllocationSize = (AllocationSize + Heap->AlignRound) & Heap->AlignMask; - Index = AllocationSize >> HEAP_ENTRY_SHIFT; - - /* Acquire the lock if necessary */ - if (!(Flags & HEAP_NO_SERIALIZE)) - { - RtlEnterHeapLock(Heap->LockVariable); - HeapLocked = TRUE; - } - - /* Depending on the size, the allocation is going to be done from dedicated, - non-dedicated lists or a virtual block of memory */ - if (Index < HEAP_FREELISTS) - { - FreeListHead = &Heap->FreeLists[Index]; - - if (!IsListEmpty(FreeListHead)) - { - /* There is a free entry in this list */ - FreeBlock = CONTAINING_RECORD(FreeListHead->Blink, - HEAP_FREE_ENTRY, - FreeList); - - /* Save flags and remove the free entry */ - FreeFlags = FreeBlock->Flags; - RtlpRemoveFreeBlock(Heap, FreeBlock, TRUE, FALSE); - - /* Update the total free size of the heap */ - Heap->TotalFreeSize -= Index; - - /* Initialize this block */ - InUseEntry = (PHEAP_ENTRY)FreeBlock; - InUseEntry->Flags = HEAP_ENTRY_BUSY | (FreeFlags & HEAP_ENTRY_LAST_ENTRY); - InUseEntry->UnusedBytes = AllocationSize - Size; - InUseEntry->SmallTagIndex = 0; - } - else - { - /* Find smallest free block which this request could fit in */ - InUseIndex = Index >> 5; - FreeListsInUse = &Heap->u.FreeListsInUseUlong[InUseIndex]; - - /* This bit magic disables all sizes which are less than the requested allocation size */ - FreeListsInUseUlong = *FreeListsInUse++ & ~((1 << ((ULONG)Index & 0x1f)) - 1); - - /* If size is definitily more than our lists - go directly to the non-dedicated one */ - if (InUseIndex > 3) - return RtlpAllocateNonDedicated(Heap, Flags, Size, AllocationSize, Index, HeapLocked); - - /* Go through the list */ - for (i = InUseIndex; i < 4; i++) - { - if (FreeListsInUseUlong) - { - FreeListHead = &Heap->FreeLists[i * 32]; - break; - } - - if (i < 3) FreeListsInUseUlong = *FreeListsInUse++; - } - - /* Nothing found, search in the non-dedicated list */ - if (i == 4) - return RtlpAllocateNonDedicated(Heap, Flags, Size, AllocationSize, Index, HeapLocked); - - /* That list is found, now calculate exact block */ - FreeListHead += RtlpFindLeastSetBit(FreeListsInUseUlong); - - /* Take this entry and remove it from the list of free blocks */ - FreeBlock = CONTAINING_RECORD(FreeListHead->Blink, - HEAP_FREE_ENTRY, - FreeList); - RtlpRemoveFreeBlock(Heap, FreeBlock, TRUE, FALSE); - - /* Split it */ - InUseEntry = RtlpSplitEntry(Heap, FreeBlock, AllocationSize, Index, Size); - } - - /* Release the lock */ - if (HeapLocked) RtlLeaveHeapLock(Heap->LockVariable); - - /* Zero memory if that was requested */ - if (Flags & HEAP_ZERO_MEMORY) - RtlZeroMemory(InUseEntry + 1, Size); - else if (Heap->Flags & HEAP_FREE_CHECKING_ENABLED) - { - /* Fill this block with a special pattern */ - RtlFillMemoryUlong(InUseEntry + 1, Size & ~0x3, ARENA_INUSE_FILLER); - } - - /* Fill tail of the block with a special pattern too if requested */ - if (Heap->Flags & HEAP_TAIL_CHECKING_ENABLED) - { - RtlFillMemory((PCHAR)(InUseEntry + 1) + Size, sizeof(HEAP_ENTRY), HEAP_TAIL_FILL); - InUseEntry->Flags |= HEAP_ENTRY_FILL_PATTERN; - } - - /* Prepare extra if it's present */ - if (InUseEntry->Flags & HEAP_ENTRY_EXTRA_PRESENT) - { - Extra = RtlpGetExtraStuffPointer(InUseEntry); - RtlZeroMemory(Extra, sizeof(HEAP_ENTRY_EXTRA)); - - // TODO: Tagging - } - - /* User data starts right after the entry's header */ - return InUseEntry + 1; - } - else if (Index <= Heap->VirtualMemoryThreshold) - { - /* The block is too large for dedicated lists, but fine for a non-dedicated one */ - return RtlpAllocateNonDedicated(Heap, Flags, Size, AllocationSize, Index, HeapLocked); - } - else if (Heap->Flags & HEAP_GROWABLE) - { - /* We've got a very big allocation request, satisfy it by directly allocating virtual memory */ - AllocationSize += sizeof(HEAP_VIRTUAL_ALLOC_ENTRY) - sizeof(HEAP_ENTRY); - - Status = ZwAllocateVirtualMemory(NtCurrentProcess(), - (PVOID *)&VirtualBlock, - 0, - &AllocationSize, - MEM_COMMIT, - PAGE_READWRITE); - - if (!NT_SUCCESS(Status)) - { - // Set STATUS! - /* Release the lock */ - if (HeapLocked) RtlLeaveHeapLock(Heap->LockVariable); - DPRINT1("HEAP: Allocation failed!\n"); - return NULL; - } - - /* Initialize the newly allocated block */ - VirtualBlock->BusyBlock.Size = (AllocationSize - Size); - VirtualBlock->BusyBlock.Flags = HEAP_ENTRY_VIRTUAL_ALLOC | HEAP_ENTRY_EXTRA_PRESENT | HEAP_ENTRY_BUSY; - VirtualBlock->CommitSize = AllocationSize; - VirtualBlock->ReserveSize = AllocationSize; - - /* Insert it into the list of virtual allocations */ - InsertTailList(&Heap->VirtualAllocdBlocks, &VirtualBlock->Entry); - - /* Release the lock */ - if (HeapLocked) RtlLeaveHeapLock(Heap->LockVariable); - - /* Return pointer to user data */ - return VirtualBlock + 1; - } - - /* Generate an exception */ - if (Flags & HEAP_GENERATE_EXCEPTIONS) - { - ExceptionRecord.ExceptionCode = STATUS_NO_MEMORY; - ExceptionRecord.ExceptionRecord = NULL; - ExceptionRecord.NumberParameters = 1; - ExceptionRecord.ExceptionFlags = 0; - ExceptionRecord.ExceptionInformation[0] = AllocationSize; - - RtlRaiseException(&ExceptionRecord); - } - - RtlSetLastWin32ErrorAndNtStatusFromNtStatus(STATUS_BUFFER_TOO_SMALL); - - /* Release the lock */ - if (HeapLocked) RtlLeaveHeapLock(Heap->LockVariable); - DPRINT1("HEAP: Allocation failed!\n"); - return NULL; -} - - -/*********************************************************************** - * HeapFree (KERNEL32.338) - * RETURNS - * TRUE: Success - * FALSE: Failure - * - * @implemented - */ -BOOLEAN NTAPI RtlFreeHeap( - HANDLE HeapPtr, /* [in] Handle of heap */ - ULONG Flags, /* [in] Heap freeing flags */ - PVOID Ptr /* [in] Address of memory to free */ -) -{ - PHEAP Heap; - PHEAP_ENTRY HeapEntry; - USHORT TagIndex = 0; - SIZE_T BlockSize; - PHEAP_VIRTUAL_ALLOC_ENTRY VirtualEntry; - BOOLEAN Locked = FALSE; - NTSTATUS Status; - - /* Freeing NULL pointer is a legal operation */ - if (!Ptr) return TRUE; - - /* Get pointer to the heap and force flags */ - Heap = (PHEAP)HeapPtr; - Flags |= Heap->ForceFlags; - - /* Call special heap */ - if (RtlpHeapIsSpecial(Flags)) - return RtlDebugFreeHeap(Heap, Flags, Ptr); - - /* Lock if necessary */ - if (!(Flags & HEAP_NO_SERIALIZE)) - { - RtlEnterHeapLock(Heap->LockVariable); - Locked = TRUE; - } - - /* Get pointer to the heap entry */ - HeapEntry = (PHEAP_ENTRY)Ptr - 1; - - /* Check this entry, fail if it's invalid */ - if (!(HeapEntry->Flags & HEAP_ENTRY_BUSY) || - (((ULONG_PTR)Ptr & 0x7) != 0) || - (HeapEntry->SegmentOffset >= HEAP_SEGMENTS)) - { - /* This is an invalid block */ - DPRINT1("HEAP: Trying to free an invalid address %p!\n", Ptr); - RtlSetLastWin32ErrorAndNtStatusFromNtStatus(STATUS_INVALID_PARAMETER); - - /* Release the heap lock */ - if (Locked) RtlLeaveHeapLock(Heap->LockVariable); - return FALSE; - } - - if (HeapEntry->Flags & HEAP_ENTRY_VIRTUAL_ALLOC) - { - /* Big allocation */ - VirtualEntry = CONTAINING_RECORD(HeapEntry, HEAP_VIRTUAL_ALLOC_ENTRY, BusyBlock); - - /* Remove it from the list */ - RemoveEntryList(&VirtualEntry->Entry); - - // TODO: Tagging - - BlockSize = 0; - Status = ZwFreeVirtualMemory(NtCurrentProcess(), - (PVOID *)&VirtualEntry, - &BlockSize, - MEM_RELEASE); - - if (!NT_SUCCESS(Status)) - { - DPRINT1("HEAP: Failed releasing memory with Status 0x%08X. Heap %p, ptr %p, base address %p\n", - Status, Heap, Ptr, VirtualEntry); - RtlSetLastWin32ErrorAndNtStatusFromNtStatus(Status); - } - } - else - { - /* Normal allocation */ - BlockSize = HeapEntry->Size; - - // TODO: Tagging - - /* Coalesce in kernel mode, and in usermode if it's not disabled */ - if (RtlpGetMode() == KernelMode || - (RtlpGetMode() == UserMode && !(Heap->Flags & HEAP_DISABLE_COALESCE_ON_FREE))) - { - HeapEntry = (PHEAP_ENTRY)RtlpCoalesceFreeBlocks(Heap, - (PHEAP_FREE_ENTRY)HeapEntry, - &BlockSize, - FALSE); - } - - /* If there is no need to decommit the block - put it into a free list */ - if (BlockSize < Heap->DeCommitFreeBlockThreshold || - (Heap->TotalFreeSize + BlockSize < Heap->DeCommitTotalFreeThreshold)) - { - /* Check if it needs to go to a 0 list */ - if (BlockSize > HEAP_MAX_BLOCK_SIZE) - { - /* General-purpose 0 list */ - RtlpInsertFreeBlock(Heap, (PHEAP_FREE_ENTRY)HeapEntry, BlockSize); - } - else - { - /* Usual free list */ - RtlpInsertFreeBlockHelper(Heap, (PHEAP_FREE_ENTRY)HeapEntry, BlockSize, FALSE); - - /* Assert sizes are consistent */ - if (!(HeapEntry->Flags & HEAP_ENTRY_LAST_ENTRY)) - { - ASSERT((HeapEntry + BlockSize)->PreviousSize == BlockSize); - } - - /* Increase the free size */ - Heap->TotalFreeSize += BlockSize; - } - - - if (RtlpGetMode() == UserMode && - TagIndex != 0) - { - // FIXME: Tagging - UNIMPLEMENTED; - } - } - else - { - /* Decommit this block */ - RtlpDeCommitFreeBlock(Heap, (PHEAP_FREE_ENTRY)HeapEntry, BlockSize); - } - } - - /* Release the heap lock */ - if (Locked) RtlLeaveHeapLock(Heap->LockVariable); - - return TRUE; -} - -BOOLEAN NTAPI -RtlpGrowBlockInPlace (IN PHEAP Heap, - IN ULONG Flags, - IN PHEAP_ENTRY InUseEntry, - IN SIZE_T Size, - IN SIZE_T Index) -{ - UCHAR EntryFlags, RememberFlags; - PHEAP_FREE_ENTRY FreeEntry, UnusedEntry, FollowingEntry; - SIZE_T FreeSize, PrevSize, TailPart, AddedSize = 0; - PHEAP_ENTRY_EXTRA OldExtra, NewExtra; - - /* We can't grow beyond specified threshold */ - if (Index > Heap->VirtualMemoryThreshold) - return FALSE; - - /* Get entry flags */ - EntryFlags = InUseEntry->Flags; - - /* Get the next free entry */ - FreeEntry = (PHEAP_FREE_ENTRY)(InUseEntry + InUseEntry->Size); - - if (EntryFlags & HEAP_ENTRY_LAST_ENTRY) - { - /* There is no next block, just uncommitted space. Calculate how much is needed */ - FreeSize = (Index - InUseEntry->Size) << HEAP_ENTRY_SHIFT; - FreeSize = ROUND_UP(FreeSize, PAGE_SIZE); - - /* Find and commit those pages */ - FreeEntry = RtlpFindAndCommitPages(Heap, - Heap->Segments[InUseEntry->SegmentOffset], - &FreeSize, - FreeEntry); - - /* Fail if it failed... */ - if (!FreeEntry) return FALSE; - - /* It was successful, perform coalescing */ - FreeSize = FreeSize >> HEAP_ENTRY_SHIFT; - FreeEntry = RtlpCoalesceFreeBlocks(Heap, FreeEntry, &FreeSize, FALSE); - - /* Check if it's enough */ - if (FreeSize + InUseEntry->Size < Index) - { - /* Still not enough */ - RtlpInsertFreeBlock(Heap, FreeEntry, FreeSize); - Heap->TotalFreeSize += FreeSize; - return FALSE; - } - - /* Remember flags of this free entry */ - RememberFlags = FreeEntry->Flags; - - /* Sum up sizes */ - FreeSize += InUseEntry->Size; - } - else - { - /* The next block indeed exists. Check if it's free or in use */ - if (FreeEntry->Flags & HEAP_ENTRY_BUSY) return FALSE; - - /* Next entry is free, check if it can fit the block we need */ - FreeSize = InUseEntry->Size + FreeEntry->Size; - if (FreeSize < Index) return FALSE; - - /* Remember flags of this free entry */ - RememberFlags = FreeEntry->Flags; - - /* Remove this block from the free list */ - RtlpRemoveFreeBlock(Heap, FreeEntry, FALSE, FALSE); - Heap->TotalFreeSize -= FreeEntry->Size; - } - - PrevSize = (InUseEntry->Size << HEAP_ENTRY_SHIFT) - InUseEntry->UnusedBytes; - FreeSize -= Index; - - /* Don't produce too small blocks */ - if (FreeSize <= 2) - { - Index += FreeSize; - FreeSize = 0; - } - - /* Process extra stuff */ - if (RememberFlags & HEAP_ENTRY_EXTRA_PRESENT) - { - /* Calculate pointers */ - OldExtra = (PHEAP_ENTRY_EXTRA)(InUseEntry + InUseEntry->Size - 1); - NewExtra = (PHEAP_ENTRY_EXTRA)(InUseEntry + Index - 1); - - /* Copy contents */ - *NewExtra = *OldExtra; - - // FIXME Tagging - } - - /* Update sizes */ - InUseEntry->Size = Index; - InUseEntry->UnusedBytes = ((Index << HEAP_ENTRY_SHIFT) - Size); - - /* Check if there is a free space remaining after merging those blocks */ - if (!FreeSize) - { - /* Update flags and sizes */ - InUseEntry->Flags |= RememberFlags & HEAP_ENTRY_LAST_ENTRY; - - /* Either update previous size of the next entry or mark it as a last - entry in the segment*/ - if (RememberFlags & HEAP_ENTRY_LAST_ENTRY) - Heap->Segments[InUseEntry->SegmentOffset]->LastEntryInSegment = InUseEntry; - else - (InUseEntry + InUseEntry->Size)->PreviousSize = InUseEntry->Size; - } - else - { - /* Complex case, we need to split the block to give unused free space - back to the heap */ - UnusedEntry = (PHEAP_FREE_ENTRY)(InUseEntry + Index); - UnusedEntry->PreviousSize = Index; - UnusedEntry->SegmentOffset = InUseEntry->SegmentOffset; - - /* Update the following block or set the last entry in the segment */ - if (RememberFlags & HEAP_ENTRY_LAST_ENTRY) - { - /* Set last entry and set flags and size */ - Heap->Segments[InUseEntry->SegmentOffset]->LastEntryInSegment = InUseEntry; - UnusedEntry->Flags = RememberFlags; - UnusedEntry->Size = FreeSize; - - /* Insert it to the heap and update total size */ - RtlpInsertFreeBlockHelper(Heap, UnusedEntry, FreeSize, FALSE); - Heap->TotalFreeSize += FreeSize; - } - else - { - /* There is a block after this one */ - FollowingEntry = (PHEAP_FREE_ENTRY)((PHEAP_ENTRY)UnusedEntry + FreeSize); - - if (FollowingEntry->Flags & HEAP_ENTRY_BUSY) - { - /* Update flags and set size of the unused space entry */ - UnusedEntry->Flags = RememberFlags & (~HEAP_ENTRY_LAST_ENTRY); - UnusedEntry->Size = FreeSize; - - /* Update previous size of the following entry */ - FollowingEntry->PreviousSize = FreeSize; - - /* Insert it to the heap and update total free size */ - RtlpInsertFreeBlockHelper(Heap, UnusedEntry, FreeSize, FALSE); - Heap->TotalFreeSize += FreeSize; - } - else - { - /* That following entry is also free, what a fortune! */ - RememberFlags = FollowingEntry->Flags; - - /* Remove it */ - RtlpRemoveFreeBlock(Heap, FollowingEntry, FALSE, FALSE); - Heap->TotalFreeSize -= FollowingEntry->Size; - - /* And make up a new combined block */ - FreeSize += FollowingEntry->Size; - UnusedEntry->Flags = RememberFlags; - - /* Check where to put it */ - if (FreeSize <= HEAP_MAX_BLOCK_SIZE) - { - /* Fine for a dedicated list */ - UnusedEntry->Size = FreeSize; - - if (RememberFlags & HEAP_ENTRY_LAST_ENTRY) - Heap->Segments[UnusedEntry->SegmentOffset]->LastEntryInSegment = (PHEAP_ENTRY)UnusedEntry; - else - ((PHEAP_ENTRY)UnusedEntry + FreeSize)->PreviousSize = FreeSize; - - /* Insert it back and update total size */ - RtlpInsertFreeBlockHelper(Heap, UnusedEntry, FreeSize, FALSE); - Heap->TotalFreeSize += FreeSize; - } - else - { - /* The block is very large, leave all the hassle to the insertion routine */ - RtlpInsertFreeBlock(Heap, UnusedEntry, FreeSize); - } - } - } - } - - /* Copy user settable flags */ - InUseEntry->Flags &= ~HEAP_ENTRY_SETTABLE_FLAGS; - InUseEntry->Flags |= ((Flags & HEAP_SETTABLE_USER_FLAGS) >> 4); - - /* Properly "zero out" (and fill!) the space */ - if (Flags & HEAP_ZERO_MEMORY) - { - RtlZeroMemory((PCHAR)(InUseEntry + 1) + PrevSize, Size - PrevSize); - } - else if (Heap->Flags & HEAP_FREE_CHECKING_ENABLED) - { - /* Calculate tail part which we need to fill */ - TailPart = PrevSize & (sizeof(ULONG) - 1); - - /* "Invert" it as usual */ - if (TailPart) TailPart = 4 - TailPart; - - if (Size > (PrevSize + TailPart)) - AddedSize = (Size - (PrevSize + TailPart)) & ~(sizeof(ULONG) - 1); - - if (AddedSize) - { - RtlFillMemoryUlong((PCHAR)(InUseEntry + 1) + PrevSize + TailPart, - AddedSize, - ARENA_INUSE_FILLER); - } - } - - /* Fill the new tail */ - if (Heap->Flags & HEAP_TAIL_CHECKING_ENABLED) - { - RtlFillMemory((PCHAR)(InUseEntry + 1) + Size, - HEAP_ENTRY_SIZE, - HEAP_TAIL_FILL); - } - - /* Return success */ - return TRUE; -} - -PHEAP_ENTRY_EXTRA NTAPI -RtlpGetExtraStuffPointer(PHEAP_ENTRY HeapEntry) -{ - PHEAP_VIRTUAL_ALLOC_ENTRY VirtualEntry; - - /* Check if it's a big block */ - if (HeapEntry->Flags & HEAP_ENTRY_VIRTUAL_ALLOC) - { - VirtualEntry = CONTAINING_RECORD(HeapEntry, HEAP_VIRTUAL_ALLOC_ENTRY, BusyBlock); - - /* Return a pointer to the extra stuff*/ - return &VirtualEntry->ExtraStuff; - } - else - { - /* This is a usual entry, which means extra stuff follows this block */ - return (PHEAP_ENTRY_EXTRA)(HeapEntry + HeapEntry->Size - 1); - } -} - - -/*********************************************************************** - * RtlReAllocateHeap - * PARAMS - * Heap [in] Handle of heap block - * Flags [in] Heap reallocation flags - * Ptr, [in] Address of memory to reallocate - * Size [in] Number of bytes to reallocate - * - * RETURNS - * Pointer to reallocated memory block - * NULL: Failure - * 0x7d030f60--invalid flags in RtlHeapAllocate - * @implemented - */ -PVOID NTAPI -RtlReAllocateHeap(HANDLE HeapPtr, - ULONG Flags, - PVOID Ptr, - SIZE_T Size) -{ - PHEAP Heap = (PHEAP)HeapPtr; - PHEAP_ENTRY InUseEntry, NewInUseEntry; - PHEAP_ENTRY_EXTRA OldExtra, NewExtra; - SIZE_T AllocationSize, FreeSize, DecommitSize; - BOOLEAN HeapLocked = FALSE; - PVOID NewBaseAddress; - PHEAP_FREE_ENTRY SplitBlock, SplitBlock2; - SIZE_T OldSize, Index, OldIndex; - UCHAR FreeFlags; - NTSTATUS Status; - PVOID DecommitBase; - SIZE_T RemainderBytes, ExtraSize; - PHEAP_VIRTUAL_ALLOC_ENTRY VirtualAllocBlock; - EXCEPTION_RECORD ExceptionRecord; - - /* Return success in case of a null pointer */ - if (!Ptr) - { - RtlSetLastWin32ErrorAndNtStatusFromNtStatus(STATUS_SUCCESS); - return NULL; - } - - /* Force heap flags */ - Flags |= Heap->ForceFlags; - - /* Call special heap */ - if (RtlpHeapIsSpecial(Flags)) - return RtlDebugReAllocateHeap(Heap, Flags, Ptr, Size); - - /* Make sure size is valid */ - if (Size >= 0x80000000) - { - RtlSetLastWin32ErrorAndNtStatusFromNtStatus(STATUS_NO_MEMORY); - return NULL; - } - - /* Calculate allocation size and index */ - if (Size) - AllocationSize = Size; - else - AllocationSize = 1; - AllocationSize = (AllocationSize + Heap->AlignRound) & Heap->AlignMask; - - /* Add up extra stuff, if it is present anywhere */ - if (((((PHEAP_ENTRY)Ptr)-1)->Flags & HEAP_ENTRY_EXTRA_PRESENT) || - (Flags & HEAP_EXTRA_FLAGS_MASK) || - Heap->PseudoTagEntries) - { - AllocationSize += sizeof(HEAP_ENTRY_EXTRA); - } - - /* Acquire the lock if necessary */ - if (!(Flags & HEAP_NO_SERIALIZE)) - { - RtlEnterHeapLock(Heap->LockVariable); - HeapLocked = TRUE; - Flags ^= HEAP_NO_SERIALIZE; - } - - /* Get the pointer to the in-use entry */ - InUseEntry = (PHEAP_ENTRY)Ptr - 1; - - /* If that entry is not really in-use, we have a problem */ - if (!(InUseEntry->Flags & HEAP_ENTRY_BUSY)) - { - RtlSetLastWin32ErrorAndNtStatusFromNtStatus(STATUS_INVALID_PARAMETER); - - /* Release the lock and return */ - if (HeapLocked) - RtlLeaveHeapLock(Heap->LockVariable); - return Ptr; - } - - if (InUseEntry->Flags & HEAP_ENTRY_VIRTUAL_ALLOC) - { - /* This is a virtually allocated block. Get its size */ - OldSize = RtlpGetSizeOfBigBlock(InUseEntry); - - /* Convert it to an index */ - OldIndex = (OldSize + InUseEntry->Size) >> HEAP_ENTRY_SHIFT; - - /* Calculate new allocation size and round it to the page size */ - AllocationSize += FIELD_OFFSET(HEAP_VIRTUAL_ALLOC_ENTRY, BusyBlock); - AllocationSize = ROUND_UP(AllocationSize, PAGE_SIZE); - } - else - { - /* Usual entry */ - OldIndex = InUseEntry->Size; - - OldSize = (OldIndex << HEAP_ENTRY_SHIFT) - InUseEntry->UnusedBytes; - } - - /* Calculate new index */ - Index = AllocationSize >> HEAP_ENTRY_SHIFT; - - /* Check for 4 different scenarios (old size, new size, old index, new index) */ - if (Index <= OldIndex) - { - /* Difference must be greater than 1, adjust if it's not so */ - if (Index + 1 == OldIndex) - { - Index++; - AllocationSize += sizeof(HEAP_ENTRY); - } - - /* Calculate new size */ - if (InUseEntry->Flags & HEAP_ENTRY_VIRTUAL_ALLOC) - { - /* Simple in case of a virtual alloc - just an unused size */ - InUseEntry->Size = AllocationSize - Size; - } - else if (InUseEntry->Flags & HEAP_ENTRY_EXTRA_PRESENT) - { - /* There is extra stuff, take it into account */ - OldExtra = (PHEAP_ENTRY_EXTRA)(InUseEntry + InUseEntry->Size - 1); - NewExtra = (PHEAP_ENTRY_EXTRA)(InUseEntry + Index - 1); - *NewExtra = *OldExtra; - - // FIXME Tagging, TagIndex - - /* Update unused bytes count */ - InUseEntry->UnusedBytes = AllocationSize - Size; - } - else - { - // FIXME Tagging, SmallTagIndex - InUseEntry->UnusedBytes = AllocationSize - Size; - } - - /* If new size is bigger than the old size */ - if (Size > OldSize) - { - /* Zero out that additional space if required */ - if (Flags & HEAP_ZERO_MEMORY) - { - RtlZeroMemory((PCHAR)Ptr + OldSize, Size - OldSize); - } - else if (Heap->Flags & HEAP_FREE_CHECKING_ENABLED) - { - /* Fill it on free if required */ - RemainderBytes = OldSize & (sizeof(ULONG) - 1); - - if (RemainderBytes) - RemainderBytes = 4 - RemainderBytes; - - if (Size > (OldSize + RemainderBytes)) - { - /* Calculate actual amount of extra bytes to fill */ - ExtraSize = (Size - (OldSize + RemainderBytes)) & ~(sizeof(ULONG) - 1); - - /* Fill them if there are any */ - if (ExtraSize != 0) - { - RtlFillMemoryUlong((PCHAR)(InUseEntry + 1) + OldSize + RemainderBytes, - ExtraSize, - ARENA_INUSE_FILLER); - } - } - } - } - - /* Fill tail of the heap entry if required */ - if (Heap->Flags & HEAP_TAIL_CHECKING_ENABLED) - { - RtlFillMemory((PCHAR)(InUseEntry + 1) + Size, - HEAP_ENTRY_SIZE, - HEAP_TAIL_FILL); - } - - /* Check if the difference is significant or not */ - if (Index != OldIndex) - { - /* Save flags */ - FreeFlags = InUseEntry->Flags & ~HEAP_ENTRY_BUSY; - - if (FreeFlags & HEAP_ENTRY_VIRTUAL_ALLOC) - { - /* This is a virtual block allocation */ - VirtualAllocBlock = CONTAINING_RECORD(InUseEntry, HEAP_VIRTUAL_ALLOC_ENTRY, BusyBlock); - - // FIXME Tagging! - - DecommitBase = (PCHAR)VirtualAllocBlock + AllocationSize; - DecommitSize = (OldIndex << HEAP_ENTRY_SHIFT) - AllocationSize; - - /* Release the memory */ - Status = ZwFreeVirtualMemory(NtCurrentProcess(), - (PVOID *)&DecommitBase, - &DecommitSize, - MEM_RELEASE); - - if (!NT_SUCCESS(Status)) - { - DPRINT1("HEAP: Unable to release memory (pointer %p, size 0x%x), Status %08x\n", DecommitBase, DecommitSize, Status); - } - else - { - /* Otherwise reduce the commit size */ - VirtualAllocBlock->CommitSize -= DecommitSize; - } - } - else - { - /* Reduce size of the block and possibly split it */ - SplitBlock = (PHEAP_FREE_ENTRY)(InUseEntry + Index); - - /* Initialize this entry */ - SplitBlock->Flags = FreeFlags; - SplitBlock->PreviousSize = Index; - SplitBlock->SegmentOffset = InUseEntry->SegmentOffset; - - /* Remember free size */ - FreeSize = InUseEntry->Size - Index; - - /* Set new size */ - InUseEntry->Size = Index; - InUseEntry->Flags &= ~HEAP_ENTRY_LAST_ENTRY; - - /* Is that the last entry */ - if (FreeFlags & HEAP_ENTRY_LAST_ENTRY) - { - /* Update segment's last entry */ - Heap->Segments[SplitBlock->SegmentOffset]->LastEntryInSegment = (PHEAP_ENTRY)SplitBlock; - - /* Set its size and insert it to the list */ - SplitBlock->Size = (USHORT)FreeSize; - RtlpInsertFreeBlockHelper(Heap, SplitBlock, FreeSize, FALSE); - - /* Update total free size */ - Heap->TotalFreeSize += FreeSize; - } - else - { - /* Get the block after that one */ - SplitBlock2 = (PHEAP_FREE_ENTRY)((PHEAP_ENTRY)SplitBlock + FreeSize); - - if (SplitBlock2->Flags & HEAP_ENTRY_BUSY) - { - /* It's in use, add it here*/ - SplitBlock->Size = (USHORT)FreeSize; - - /* Update previous size of the next entry */ - ((PHEAP_FREE_ENTRY)((PHEAP_ENTRY)SplitBlock + FreeSize))->PreviousSize = (USHORT)FreeSize; - - /* Insert it to the list */ - RtlpInsertFreeBlockHelper(Heap, SplitBlock, FreeSize, FALSE); - - /* Update total size */ - Heap->TotalFreeSize += FreeSize; - } - else - { - /* Next entry is free, so merge with it */ - SplitBlock->Flags = SplitBlock2->Flags; - - /* Remove it, update total size */ - RtlpRemoveFreeBlock(Heap, SplitBlock2, FALSE, FALSE); - Heap->TotalFreeSize -= SplitBlock2->Size; - - /* Calculate total free size */ - FreeSize += SplitBlock2->Size; - - if (FreeSize <= HEAP_MAX_BLOCK_SIZE) - { - SplitBlock->Size = FreeSize; - - if (!(SplitBlock->Flags & HEAP_ENTRY_LAST_ENTRY)) - { - /* Update previous size of the next entry */ - ((PHEAP_FREE_ENTRY)((PHEAP_ENTRY)SplitBlock + FreeSize))->PreviousSize = FreeSize; - } - else - { - Heap->Segments[SplitBlock->SegmentOffset]->LastEntryInSegment = (PHEAP_ENTRY)SplitBlock; - } - - /* Insert the new one back and update total size */ - RtlpInsertFreeBlockHelper(Heap, SplitBlock, FreeSize, FALSE); - Heap->TotalFreeSize += FreeSize; - } - else - { - /* Just add it */ - RtlpInsertFreeBlock(Heap, SplitBlock, FreeSize); - } - } - } - } - } - } - else - { - /* We're growing the block */ - if ((InUseEntry->Flags & HEAP_ENTRY_VIRTUAL_ALLOC) || - !RtlpGrowBlockInPlace(Heap, Flags, InUseEntry, Size, Index)) - { - /* Growing in place failed, so growing out of place */ - if (Flags & HEAP_REALLOC_IN_PLACE_ONLY) - { - DPRINT1("Realloc in place failed, but it was the only option\n"); - Ptr = NULL; - } - else - { - /* Clear tag bits */ - Flags &= ~HEAP_TAG_MASK; - - /* Process extra stuff */ - if (InUseEntry->Flags & HEAP_ENTRY_EXTRA_PRESENT) - { - /* Preserve user settable flags */ - Flags &= ~HEAP_SETTABLE_USER_FLAGS; - - Flags |= HEAP_SETTABLE_USER_VALUE | ((InUseEntry->Flags & HEAP_ENTRY_SETTABLE_FLAGS) << 4); - - /* Get pointer to the old extra data */ - OldExtra = RtlpGetExtraStuffPointer(InUseEntry); - - /* Save tag index if it was set */ - if (OldExtra->TagIndex && - !(OldExtra->TagIndex & HEAP_PSEUDO_TAG_FLAG)) - { - Flags |= OldExtra->TagIndex << HEAP_TAG_SHIFT; - } - } - else if (InUseEntry->SmallTagIndex) - { - /* Take small tag index into account */ - Flags |= InUseEntry->SmallTagIndex << HEAP_TAG_SHIFT; - } - - /* Allocate new block from the heap */ - NewBaseAddress = RtlAllocateHeap(HeapPtr, - Flags & ~HEAP_ZERO_MEMORY, - Size); - - /* Proceed if it didn't fail */ - if (NewBaseAddress) - { - /* Get new entry pointer */ - NewInUseEntry = (PHEAP_ENTRY)NewBaseAddress - 1; - - /* Process extra stuff if it exists */ - if (NewInUseEntry->Flags & HEAP_ENTRY_EXTRA_PRESENT) - { - NewExtra = RtlpGetExtraStuffPointer(NewInUseEntry); - - if (InUseEntry->Flags & HEAP_ENTRY_EXTRA_PRESENT) - { - OldExtra = RtlpGetExtraStuffPointer(InUseEntry); - NewExtra->Settable = OldExtra->Settable; - } - else - { - RtlZeroMemory(NewExtra, sizeof(*NewExtra)); - } - } - - /* Copy actual user bits */ - if (Size < OldSize) - RtlMoveMemory(NewBaseAddress, Ptr, Size); - else - RtlMoveMemory(NewBaseAddress, Ptr, OldSize); - - /* Zero remaining part if required */ - if (Size > OldSize && - (Flags & HEAP_ZERO_MEMORY)) - { - RtlZeroMemory((PCHAR)NewBaseAddress + OldSize, Size - OldSize); - } - - /* Free the old block */ - RtlFreeHeap(HeapPtr, Flags, Ptr); - } - - Ptr = NewBaseAddress; - } - } - } - - /* Did resizing fail? */ - if (!Ptr && (Flags & HEAP_GENERATE_EXCEPTIONS)) - { - /* Generate an exception if required */ - ExceptionRecord.ExceptionCode = STATUS_NO_MEMORY; - ExceptionRecord.ExceptionRecord = NULL; - ExceptionRecord.NumberParameters = 1; - ExceptionRecord.ExceptionFlags = 0; - ExceptionRecord.ExceptionInformation[0] = AllocationSize; - - RtlRaiseException(&ExceptionRecord); - } - - /* Release the heap lock if it was acquired */ - if (HeapLocked) - RtlLeaveHeapLock(Heap->LockVariable); - - return Ptr; -} - - -/*********************************************************************** - * RtlCompactHeap - * - * @unimplemented - */ -ULONG NTAPI -RtlCompactHeap(HANDLE Heap, - ULONG Flags) -{ - UNIMPLEMENTED; - return 0; -} - - -/*********************************************************************** - * RtlLockHeap - * Attempts to acquire the critical section object for a specified heap. - * - * PARAMS - * Heap [in] Handle of heap to lock for exclusive access - * - * RETURNS - * TRUE: Success - * FALSE: Failure - * - * @implemented - */ -BOOLEAN NTAPI -RtlLockHeap(IN HANDLE HeapPtr) -{ - PHEAP Heap = (PHEAP)HeapPtr; - - // FIXME Check for special heap - - /* Check if it's really a heap */ - if (Heap->Signature != HEAP_SIGNATURE) return FALSE; - - /* Lock if it's lockable */ - if (!(Heap->Flags & HEAP_NO_SERIALIZE)) - { - RtlEnterHeapLock(Heap->LockVariable); - } - - return TRUE; -} - - -/*********************************************************************** - * RtlUnlockHeap - * Releases ownership of the critical section object. - * - * PARAMS - * Heap [in] Handle to the heap to unlock - * - * RETURNS - * TRUE: Success - * FALSE: Failure - * - * @implemented - */ -BOOLEAN NTAPI -RtlUnlockHeap(HANDLE HeapPtr) -{ - PHEAP Heap = (PHEAP)HeapPtr; - - // FIXME Check for special heap - - /* Check if it's really a heap */ - if (Heap->Signature != HEAP_SIGNATURE) return FALSE; - - /* Unlock if it's lockable */ - if (!(Heap->Flags & HEAP_NO_SERIALIZE)) - { - RtlLeaveHeapLock(Heap->LockVariable); - } - - return TRUE; -} - - -/*********************************************************************** - * RtlSizeHeap - * PARAMS - * Heap [in] Handle of heap - * Flags [in] Heap size control flags - * Ptr [in] Address of memory to return size for - * - * RETURNS - * Size in bytes of allocated memory - * 0xffffffff: Failure - * - * @implemented - */ -SIZE_T NTAPI -RtlSizeHeap( - HANDLE HeapPtr, - ULONG Flags, - PVOID Ptr -) -{ - PHEAP Heap = (PHEAP)HeapPtr; - PHEAP_ENTRY HeapEntry; - SIZE_T EntrySize; - - // FIXME This is a hack around missing SEH support! - if (!Heap) - { - RtlSetLastWin32ErrorAndNtStatusFromNtStatus(STATUS_INVALID_HANDLE); - return (SIZE_T)-1; - } - - /* Force flags */ - Flags |= Heap->ForceFlags; - - /* Call special heap */ - if (RtlpHeapIsSpecial(Flags)) - return RtlDebugSizeHeap(Heap, Flags, Ptr); - - /* Get the heap entry pointer */ - HeapEntry = (PHEAP_ENTRY)Ptr - 1; - - /* Return -1 if that entry is free */ - if (!(HeapEntry->Flags & HEAP_ENTRY_BUSY)) - { - RtlSetLastWin32ErrorAndNtStatusFromNtStatus(STATUS_INVALID_PARAMETER); - return (SIZE_T)-1; - } - - /* Get size of this block depending if it's a usual or a big one */ - if (HeapEntry->Flags & HEAP_ENTRY_VIRTUAL_ALLOC) - { - EntrySize = RtlpGetSizeOfBigBlock(HeapEntry); - } - else - { - /* Calculate it */ - EntrySize = (HeapEntry->Size << HEAP_ENTRY_SHIFT) - HeapEntry->UnusedBytes; - } - - /* Return calculated size */ - return EntrySize; -} - -BOOLEAN NTAPI -RtlpCheckInUsePattern(PHEAP_ENTRY HeapEntry) -{ - SIZE_T Size, Result; - PCHAR TailPart; - - /* Calculate size */ - if (HeapEntry->Flags & HEAP_ENTRY_VIRTUAL_ALLOC) - Size = RtlpGetSizeOfBigBlock(HeapEntry); - else - Size = (HeapEntry->Size << HEAP_ENTRY_SHIFT) - HeapEntry->UnusedBytes; - - /* Calculate pointer to the tail part of the block */ - TailPart = (PCHAR)(HeapEntry + 1) + Size; - - /* Compare tail pattern */ - Result = RtlCompareMemory(TailPart, - FillPattern, - HEAP_ENTRY_SIZE); - - if (Result != HEAP_ENTRY_SIZE) - { - DPRINT1("HEAP: Heap entry (size %x) %p tail is modified at %p\n", Size, HeapEntry, TailPart + Result); - return FALSE; - } - - /* All is fine */ - return TRUE; -} - -BOOLEAN NTAPI -RtlpValidateHeapHeaders( - PHEAP Heap, - BOOLEAN Recalculate) -{ - // We skip header validation for now - return TRUE; -} - -BOOLEAN NTAPI -RtlpValidateHeapEntry( - PHEAP Heap, - PHEAP_ENTRY HeapEntry) -{ - BOOLEAN BigAllocation, EntryFound = FALSE; - PHEAP_SEGMENT Segment; - ULONG SegmentOffset; - - /* Perform various consistency checks of this entry */ - if (!HeapEntry) goto invalid_entry; - if ((ULONG_PTR)HeapEntry & (HEAP_ENTRY_SIZE - 1)) goto invalid_entry; - if (!(HeapEntry->Flags & HEAP_ENTRY_BUSY)) goto invalid_entry; - - BigAllocation = HeapEntry->Flags & HEAP_ENTRY_VIRTUAL_ALLOC; - Segment = Heap->Segments[HeapEntry->SegmentOffset]; - - if (BigAllocation && - (((ULONG_PTR)HeapEntry & (PAGE_SIZE - 1)) != FIELD_OFFSET(HEAP_VIRTUAL_ALLOC_ENTRY, BusyBlock))) - goto invalid_entry; - - if (!BigAllocation && (HeapEntry->SegmentOffset >= HEAP_SEGMENTS || - !Segment || - HeapEntry < Segment->FirstEntry || - HeapEntry >= Segment->LastValidEntry)) - goto invalid_entry; - - if ((HeapEntry->Flags & HEAP_ENTRY_FILL_PATTERN) && - !RtlpCheckInUsePattern(HeapEntry)) - goto invalid_entry; - - /* Checks are done, if this is a virtual entry, that's all */ - if (HeapEntry->Flags & HEAP_ENTRY_VIRTUAL_ALLOC) return TRUE; - - /* Go through segments and check if this entry fits into any of them */ - for (SegmentOffset = 0; SegmentOffset < HEAP_SEGMENTS; SegmentOffset++) - { - Segment = Heap->Segments[SegmentOffset]; - if (!Segment) continue; - - if ((HeapEntry >= Segment->FirstEntry) && - (HeapEntry < Segment->LastValidEntry)) - { - /* Got it */ - EntryFound = TRUE; - break; - } - } - - /* Return our result of finding entry in the segments */ - return EntryFound; - -invalid_entry: - DPRINT1("HEAP: Invalid heap entry %p in heap %p\n", HeapEntry, Heap); - return FALSE; -} - -BOOLEAN NTAPI -RtlpValidateHeapSegment( - PHEAP Heap, - PHEAP_SEGMENT Segment, - UCHAR SegmentOffset, - PULONG FreeEntriesCount, - PSIZE_T TotalFreeSize, - PSIZE_T TagEntries, - PSIZE_T PseudoTagEntries) -{ - PHEAP_UCR_DESCRIPTOR UcrDescriptor; - PLIST_ENTRY UcrEntry; - SIZE_T ByteSize, Size, Result; - PHEAP_ENTRY CurrentEntry; - ULONG UnCommittedPages; - ULONG UnCommittedRanges; - ULONG PreviousSize; - - UnCommittedPages = 0; - UnCommittedRanges = 0; - - if (IsListEmpty(&Segment->UCRSegmentList)) - { - UcrEntry = NULL; - UcrDescriptor = NULL; - } - else - { - UcrEntry = Segment->UCRSegmentList.Flink; - UcrDescriptor = CONTAINING_RECORD(UcrEntry, HEAP_UCR_DESCRIPTOR, SegmentEntry); - } - - if (Segment->BaseAddress == Heap) - CurrentEntry = &Heap->Entry; - else - CurrentEntry = &Segment->Entry; - - while (CurrentEntry < Segment->LastValidEntry) - { - if (UcrDescriptor && - ((PVOID)CurrentEntry >= UcrDescriptor->Address)) - { - DPRINT1("HEAP: Entry %p is not inside uncommited range [%p .. %p)\n", - CurrentEntry, UcrDescriptor->Address, - (PCHAR)UcrDescriptor->Address + UcrDescriptor->Size); - - return FALSE; - } - - PreviousSize = 0; - - while (CurrentEntry < Segment->LastValidEntry) - { - if (PreviousSize != CurrentEntry->PreviousSize) - { - DPRINT1("HEAP: Entry %p has incorrect PreviousSize %x instead of %x\n", - CurrentEntry, CurrentEntry->PreviousSize, PreviousSize); - - return FALSE; - } - - PreviousSize = CurrentEntry->Size; - Size = CurrentEntry->Size << HEAP_ENTRY_SHIFT; - - if (CurrentEntry->Flags & HEAP_ENTRY_BUSY) - { - if (TagEntries) - { - UNIMPLEMENTED; - } - - /* Check fill pattern */ - if (CurrentEntry->Flags & HEAP_ENTRY_FILL_PATTERN) - { - if (!RtlpCheckInUsePattern(CurrentEntry)) - return FALSE; - } - } - else - { - /* The entry is free, increase free entries count and total free size */ - *FreeEntriesCount = *FreeEntriesCount + 1; - *TotalFreeSize += CurrentEntry->Size; - - if ((Heap->Flags & HEAP_FREE_CHECKING_ENABLED) && - (CurrentEntry->Flags & HEAP_ENTRY_FILL_PATTERN)) - { - ByteSize = Size - sizeof(HEAP_FREE_ENTRY); - - if ((CurrentEntry->Flags & HEAP_ENTRY_EXTRA_PRESENT) && - (ByteSize > sizeof(HEAP_FREE_ENTRY_EXTRA))) - { - ByteSize -= sizeof(HEAP_FREE_ENTRY_EXTRA); - } - - Result = RtlCompareMemoryUlong((PCHAR)((PHEAP_FREE_ENTRY)CurrentEntry + 1), - ByteSize, - ARENA_FREE_FILLER); - - if (Result != ByteSize) - { - DPRINT1("HEAP: Free heap block %p modified at %p after it was freed\n", - CurrentEntry, - (PCHAR)(CurrentEntry + 1) + Result); - - return FALSE; - } - } - } - - if (CurrentEntry->SegmentOffset != SegmentOffset) - { - DPRINT1("HEAP: Heap entry %p SegmentOffset is incorrect %x (should be %x)\n", CurrentEntry, SegmentOffset, CurrentEntry->SegmentOffset); - return FALSE; - } - - /* Check if it's the last entry */ - if (CurrentEntry->Flags & HEAP_ENTRY_LAST_ENTRY) - { - CurrentEntry = (PHEAP_ENTRY)((PCHAR)CurrentEntry + Size); - - if (!UcrDescriptor) - { - /* Check if it's not really the last one */ - if (CurrentEntry != Segment->LastValidEntry) - { - DPRINT1("HEAP: Heap entry %p is not last block in segment (%x)\n", CurrentEntry, Segment->LastValidEntry); - return FALSE; - } - } - else if (CurrentEntry != UcrDescriptor->Address) - { - DPRINT1("HEAP: Heap entry %p does not match next uncommitted address (%p)\n", - CurrentEntry, UcrDescriptor->Address); - - return FALSE; - } - else - { - UnCommittedPages += (UcrDescriptor->Size / PAGE_SIZE); - UnCommittedRanges++; - - CurrentEntry = (PHEAP_ENTRY)((PCHAR)UcrDescriptor->Address + UcrDescriptor->Size); - - /* Go to the next UCR descriptor */ - UcrEntry = UcrEntry->Flink; - if (UcrEntry == &Segment->UCRSegmentList) - { - UcrEntry = NULL; - UcrDescriptor = NULL; - } - else - { - UcrDescriptor = CONTAINING_RECORD(UcrEntry, HEAP_UCR_DESCRIPTOR, SegmentEntry); - } - } - - break; - } - - /* Advance to the next entry */ - CurrentEntry = (PHEAP_ENTRY)((PCHAR)CurrentEntry + Size); - } - } - - /* Check total numbers of UCP and UCR */ - if (Segment->NumberOfUnCommittedPages != UnCommittedPages) - { - DPRINT1("HEAP: Segment %p NumberOfUnCommittedPages is invalid (%x != %x)\n", - Segment, Segment->NumberOfUnCommittedPages, UnCommittedPages); - - return FALSE; - } - - if (Segment->NumberOfUnCommittedRanges != UnCommittedRanges) - { - DPRINT1("HEAP: Segment %p NumberOfUnCommittedRanges is invalid (%x != %x)\n", - Segment, Segment->NumberOfUnCommittedRanges, UnCommittedRanges); - - return FALSE; - } - - return TRUE; -} - -BOOLEAN NTAPI -RtlpValidateHeap(PHEAP Heap, - BOOLEAN ForceValidation) -{ - PHEAP_SEGMENT Segment; - BOOLEAN EmptyList; - UCHAR SegmentOffset; - SIZE_T Size, TotalFreeSize; - ULONG PreviousSize; - PHEAP_VIRTUAL_ALLOC_ENTRY VirtualAllocBlock; - PLIST_ENTRY ListHead, NextEntry; - PHEAP_FREE_ENTRY FreeEntry; - ULONG FreeBlocksCount, FreeListEntriesCount; - - /* Check headers */ - if (!RtlpValidateHeapHeaders(Heap, FALSE)) - return FALSE; - - /* Skip validation if it's not needed */ - if (!ForceValidation && !(Heap->Flags & HEAP_VALIDATE_ALL_ENABLED)) - return TRUE; - - /* Check free lists bitmaps */ - FreeListEntriesCount = 0; - ListHead = &Heap->FreeLists[0]; - - for (Size = 0; Size < HEAP_FREELISTS; Size++) - { - if (Size) - { - /* This is a dedicated list. Check if it's empty */ - EmptyList = IsListEmpty(ListHead); - - if (Heap->u.FreeListsInUseBytes[Size >> 3] & (1 << (Size & 7))) - { - if (EmptyList) - { - DPRINT1("HEAP: Empty %x-free list marked as non-empty\n", Size); - return FALSE; - } - } - else - { - if (!EmptyList) - { - DPRINT1("HEAP: Non-empty %x-free list marked as empty\n", Size); - return FALSE; - } - } - } - - /* Now check this list entries */ - NextEntry = ListHead->Flink; - PreviousSize = 0; - - while (ListHead != NextEntry) - { - FreeEntry = CONTAINING_RECORD(NextEntry, HEAP_FREE_ENTRY, FreeList); - NextEntry = NextEntry->Flink; - - /* If there is an in-use entry in a free list - that's quite a big problem */ - if (FreeEntry->Flags & HEAP_ENTRY_BUSY) - { - DPRINT1("HEAP: %x-dedicated list free element %x is marked in-use\n", Size, FreeEntry); - return FALSE; - } - - /* Check sizes according to that specific list's size */ - if ((Size == 0) && (FreeEntry->Size < HEAP_FREELISTS)) - { - DPRINT1("HEAP: Non dedicated list free element %x has size %x which would fit a dedicated list\n", FreeEntry, FreeEntry->Size); - return FALSE; - } - else if (Size && (FreeEntry->Size != Size)) - { - DPRINT1("HEAP: %x-dedicated list free element %x has incorrect size %x\n", Size, FreeEntry, FreeEntry->Size); - return FALSE; - } - else if ((Size == 0) && (FreeEntry->Size < PreviousSize)) - { - DPRINT1("HEAP: Non dedicated list free element %x is not put in order\n", FreeEntry); - return FALSE; - } - - /* Remember previous size*/ - PreviousSize = FreeEntry->Size; - - /* Add up to the total amount of free entries */ - FreeListEntriesCount++; - } - - /* Go to the head of the next free list */ - ListHead++; - } - - /* Check big allocations */ - ListHead = &Heap->VirtualAllocdBlocks; - NextEntry = ListHead->Flink; - - while (ListHead != NextEntry) - { - VirtualAllocBlock = CONTAINING_RECORD(NextEntry, HEAP_VIRTUAL_ALLOC_ENTRY, Entry); - - /* We can only check the fill pattern */ - if (VirtualAllocBlock->BusyBlock.Flags & HEAP_ENTRY_FILL_PATTERN) - { - if (!RtlpCheckInUsePattern(&VirtualAllocBlock->BusyBlock)) - return FALSE; - } - - NextEntry = NextEntry->Flink; - } - - /* Check all segments */ - FreeBlocksCount = 0; - TotalFreeSize = 0; - - for (SegmentOffset = 0; SegmentOffset < HEAP_SEGMENTS; SegmentOffset++) - { - Segment = Heap->Segments[SegmentOffset]; - - /* Go to the next one if there is no segment */ - if (!Segment) continue; - - if (!RtlpValidateHeapSegment(Heap, - Segment, - SegmentOffset, - &FreeBlocksCount, - &TotalFreeSize, - NULL, - NULL)) - { - return FALSE; - } - } - - if (FreeListEntriesCount != FreeBlocksCount) - { - DPRINT1("HEAP: Free blocks count in arena (%d) does not match free blocks number in the free lists (%d)\n", FreeBlocksCount, FreeListEntriesCount); - return FALSE; - } - - if (Heap->TotalFreeSize != TotalFreeSize) - { - DPRINT1("HEAP: Total size of free blocks in arena (%d) does not equal to the one in heap header (%d)\n", TotalFreeSize, Heap->TotalFreeSize); - return FALSE; - } - - return TRUE; -} - -/*********************************************************************** - * RtlValidateHeap - * Validates a specified heap. - * - * PARAMS - * Heap [in] Handle to the heap - * Flags [in] Bit flags that control access during operation - * Block [in] Optional pointer to memory block to validate - * - * NOTES - * Flags is ignored. - * - * RETURNS - * TRUE: Success - * FALSE: Failure - * - * @implemented - */ -BOOLEAN NTAPI RtlValidateHeap( - HANDLE HeapPtr, - ULONG Flags, - PVOID Block -) -{ - PHEAP Heap = (PHEAP)HeapPtr; - BOOLEAN HeapLocked = FALSE; - BOOLEAN HeapValid; - - // FIXME Check for special heap - - /* Check signature */ - if (Heap->Signature != HEAP_SIGNATURE) - { - DPRINT1("HEAP: Signature %x is invalid for heap %p\n", Heap->Signature, Heap); - return FALSE; - } - - /* Force flags */ - Flags = Heap->ForceFlags; - - /* Acquire the lock if necessary */ - if (!(Flags & HEAP_NO_SERIALIZE)) - { - RtlEnterHeapLock(Heap->LockVariable); - HeapLocked = TRUE; - } - - /* Either validate whole heap or just one entry */ - if (!Block) - HeapValid = RtlpValidateHeap(Heap, TRUE); - else - HeapValid = RtlpValidateHeapEntry(Heap, (PHEAP_ENTRY)Block - 1); - - /* Unlock if it's lockable */ - if (HeapLocked) - { - RtlLeaveHeapLock(Heap->LockVariable); - } - - return HeapValid; -} - -VOID -RtlInitializeHeapManager(VOID) -{ - PPEB Peb; - - /* Get PEB */ - Peb = RtlGetCurrentPeb(); - - /* Initialize heap-related fields of PEB */ - Peb->NumberOfHeaps = 0; - - /* Initialize the process heaps list protecting lock */ - RtlInitializeHeapLock(&RtlpProcessHeapsListLock); -} - - -/* - * @implemented - */ -NTSTATUS NTAPI -RtlEnumProcessHeaps(PHEAP_ENUMERATION_ROUTINE HeapEnumerationRoutine, - PVOID lParam) -{ - UNIMPLEMENTED; - return STATUS_NOT_IMPLEMENTED; -} - - -/* - * @implemented - */ -ULONG NTAPI -RtlGetProcessHeaps(ULONG count, - HANDLE *heaps) -{ - UNIMPLEMENTED; - return 0; -} - - -/* - * @implemented - */ -BOOLEAN NTAPI -RtlValidateProcessHeaps(VOID) -{ - UNIMPLEMENTED; - return TRUE; -} - - -/* - * @unimplemented - */ -BOOLEAN NTAPI -RtlZeroHeap( - IN PVOID HeapHandle, - IN ULONG Flags - ) -{ - UNIMPLEMENTED; - return FALSE; -} - -/* - * @implemented - */ -BOOLEAN -NTAPI -RtlSetUserValueHeap(IN PVOID HeapHandle, - IN ULONG Flags, - IN PVOID BaseAddress, - IN PVOID UserValue) -{ - PHEAP Heap = (PHEAP)HeapHandle; - PHEAP_ENTRY HeapEntry; - PHEAP_ENTRY_EXTRA Extra; - BOOLEAN HeapLocked = FALSE; - - /* Force flags */ - Flags |= Heap->Flags; - - /* Call special heap */ - if (RtlpHeapIsSpecial(Flags)) - return RtlDebugSetUserValueHeap(Heap, Flags, BaseAddress, UserValue); - - /* Lock if it's lockable */ - if (!(Heap->Flags & HEAP_NO_SERIALIZE)) - { - RtlEnterHeapLock(Heap->LockVariable); - HeapLocked = TRUE; - } - - /* Get a pointer to the entry */ - HeapEntry = (PHEAP_ENTRY)BaseAddress - 1; - - /* If it's a free entry - return error */ - if (!(HeapEntry->Flags & HEAP_ENTRY_BUSY)) - { - RtlSetLastWin32ErrorAndNtStatusFromNtStatus(STATUS_INVALID_PARAMETER); - - /* Release the heap lock if it was acquired */ - if (HeapLocked) - RtlLeaveHeapLock(Heap->LockVariable); - - return FALSE; - } - - /* Check if this entry has an extra stuff associated with it */ - if (HeapEntry->Flags & HEAP_ENTRY_EXTRA_PRESENT) - { - /* Use extra to store the value */ - Extra = RtlpGetExtraStuffPointer(HeapEntry); - Extra->Settable = (ULONG_PTR)UserValue; - } - - /* Release the heap lock if it was acquired */ - if (HeapLocked) - RtlLeaveHeapLock(Heap->LockVariable); - - return TRUE; -} - -/* - * @implemented - */ -BOOLEAN -NTAPI -RtlSetUserFlagsHeap(IN PVOID HeapHandle, - IN ULONG Flags, - IN PVOID BaseAddress, - IN ULONG UserFlagsReset, - IN ULONG UserFlagsSet) -{ - PHEAP Heap = (PHEAP)HeapHandle; - PHEAP_ENTRY HeapEntry; - BOOLEAN HeapLocked = FALSE; - - /* Force flags */ - Flags |= Heap->Flags; - - /* Call special heap */ - if (RtlpHeapIsSpecial(Flags)) - return RtlDebugSetUserFlagsHeap(Heap, Flags, BaseAddress, UserFlagsReset, UserFlagsSet); - - /* Lock if it's lockable */ - if (!(Heap->Flags & HEAP_NO_SERIALIZE)) - { - RtlEnterHeapLock(Heap->LockVariable); - HeapLocked = TRUE; - } - - /* Get a pointer to the entry */ - HeapEntry = (PHEAP_ENTRY)BaseAddress - 1; - - /* If it's a free entry - return error */ - if (!(HeapEntry->Flags & HEAP_ENTRY_BUSY)) - { - RtlSetLastWin32ErrorAndNtStatusFromNtStatus(STATUS_INVALID_PARAMETER); - - /* Release the heap lock if it was acquired */ - if (HeapLocked) - RtlLeaveHeapLock(Heap->LockVariable); - - return FALSE; - } - - /* Set / reset flags */ - HeapEntry->Flags &= ~(UserFlagsReset >> 4); - HeapEntry->Flags |= (UserFlagsSet >> 4); - - /* Release the heap lock if it was acquired */ - if (HeapLocked) - RtlLeaveHeapLock(Heap->LockVariable); - - return TRUE; -} - -/* - * @implemented - */ -BOOLEAN -NTAPI -RtlGetUserInfoHeap(IN PVOID HeapHandle, - IN ULONG Flags, - IN PVOID BaseAddress, - OUT PVOID *UserValue, - OUT PULONG UserFlags) -{ - PHEAP Heap = (PHEAP)HeapHandle; - PHEAP_ENTRY HeapEntry; - PHEAP_ENTRY_EXTRA Extra; - BOOLEAN HeapLocked = FALSE; - - /* Force flags */ - Flags |= Heap->Flags; - - /* Call special heap */ - if (RtlpHeapIsSpecial(Flags)) - return RtlDebugGetUserInfoHeap(Heap, Flags, BaseAddress, UserValue, UserFlags); - - /* Lock if it's lockable */ - if (!(Heap->Flags & HEAP_NO_SERIALIZE)) - { - RtlEnterHeapLock(Heap->LockVariable); - HeapLocked = TRUE; - } - - /* Get a pointer to the entry */ - HeapEntry = (PHEAP_ENTRY)BaseAddress - 1; - - /* If it's a free entry - return error */ - if (!(HeapEntry->Flags & HEAP_ENTRY_BUSY)) - { - RtlSetLastWin32ErrorAndNtStatusFromNtStatus(STATUS_INVALID_PARAMETER); - - /* Release the heap lock if it was acquired */ - if (HeapLocked) - RtlLeaveHeapLock(Heap->LockVariable); - - return FALSE; - } - - /* Check if this entry has an extra stuff associated with it */ - if (HeapEntry->Flags & HEAP_ENTRY_EXTRA_PRESENT) - { - /* Get pointer to extra data */ - Extra = RtlpGetExtraStuffPointer(HeapEntry); - - /* Pass user value */ - if (UserValue) - *UserValue = (PVOID)Extra->Settable; - - /* Decode and return user flags */ - if (UserFlags) - *UserFlags = (HeapEntry->Flags & HEAP_ENTRY_SETTABLE_FLAGS) << 4; - } - - /* Release the heap lock if it was acquired */ - if (HeapLocked) - RtlLeaveHeapLock(Heap->LockVariable); - - return TRUE; -} - -/* - * @unimplemented - */ -NTSTATUS -NTAPI -RtlUsageHeap(IN HANDLE Heap, - IN ULONG Flags, - OUT PRTL_HEAP_USAGE Usage) -{ - /* TODO */ - UNIMPLEMENTED; - return STATUS_NOT_IMPLEMENTED; -} - -PWSTR -NTAPI -RtlQueryTagHeap(IN PVOID HeapHandle, - IN ULONG Flags, - IN USHORT TagIndex, - IN BOOLEAN ResetCounters, - OUT PRTL_HEAP_TAG_INFO HeapTagInfo) -{ - /* TODO */ - UNIMPLEMENTED; - return NULL; -} - -ULONG -NTAPI -RtlExtendHeap(IN HANDLE Heap, - IN ULONG Flags, - IN PVOID P, - IN SIZE_T Size) -{ - /* TODO */ - UNIMPLEMENTED; - return 0; -} - -ULONG -NTAPI -RtlCreateTagHeap(IN HANDLE HeapHandle, - IN ULONG Flags, - IN PWSTR TagName, - IN PWSTR TagSubName) -{ - /* TODO */ - UNIMPLEMENTED; - return 0; -} - -NTSTATUS -NTAPI -RtlWalkHeap(IN HANDLE HeapHandle, - IN PVOID HeapEntry) -{ - UNIMPLEMENTED; - return STATUS_NOT_IMPLEMENTED; -} - -PVOID -NTAPI -RtlProtectHeap(IN PVOID HeapHandle, - IN BOOLEAN ReadOnly) -{ - UNIMPLEMENTED; - return NULL; -} - -NTSTATUS -NTAPI -RtlSetHeapInformation(IN HANDLE HeapHandle OPTIONAL, - IN HEAP_INFORMATION_CLASS HeapInformationClass, - IN PVOID HeapInformation, - IN SIZE_T HeapInformationLength) -{ - /* Setting heap information is not really supported except for enabling LFH */ - if (HeapInformationClass == 0) return STATUS_SUCCESS; - - /* Check buffer length */ - if (HeapInformationLength < sizeof(ULONG)) - { - /* The provided buffer is too small */ - return STATUS_BUFFER_TOO_SMALL; - } - - /* Check for a special magic value for enabling LFH */ - if (*(PULONG)HeapInformation == 2) - { - DPRINT1("RtlSetHeapInformation() needs to enable LFH\n"); - return STATUS_SUCCESS; - } - - return STATUS_UNSUCCESSFUL; -} - -NTSTATUS -NTAPI -RtlQueryHeapInformation(HANDLE HeapHandle, - HEAP_INFORMATION_CLASS HeapInformationClass, - PVOID HeapInformation OPTIONAL, - SIZE_T HeapInformationLength OPTIONAL, - PSIZE_T ReturnLength OPTIONAL) -{ - PHEAP Heap = (PHEAP)HeapHandle; - - /* Only HeapCompatibilityInformation is supported */ - if (HeapInformationClass != HeapCompatibilityInformation) - return STATUS_UNSUCCESSFUL; - - /* Set result length */ - if (ReturnLength) *ReturnLength = sizeof(ULONG); - - /* Check buffer length */ - if (HeapInformationLength < sizeof(ULONG)) - { - /* It's too small, return needed length */ - return STATUS_BUFFER_TOO_SMALL; - } - - /* Return front end heap type */ - *(PULONG)HeapInformation = Heap->FrontEndHeapType; - - return STATUS_SUCCESS; -} - -NTSTATUS -NTAPI -RtlMultipleAllocateHeap(IN PVOID HeapHandle, - IN ULONG Flags, - IN SIZE_T Size, - IN ULONG Count, - OUT PVOID *Array) -{ - UNIMPLEMENTED; - return 0; -} - -NTSTATUS -NTAPI -RtlMultipleFreeHeap(IN PVOID HeapHandle, - IN ULONG Flags, - IN ULONG Count, - OUT PVOID *Array) -{ - UNIMPLEMENTED; - return 0; -} - -/* EOF */ From 8448d43632a6bf13988ec1c11fb74ceb2fc77c5c Mon Sep 17 00:00:00 2001 From: Daniel Reimer Date: Sun, 12 Dec 2010 18:56:43 +0000 Subject: [PATCH 039/181] Update the rapps database. svn path=/trunk/; revision=50013 --- .../base/applications/rapps/rapps/firefox36.txt | 16 ++++++++-------- .../applications/rapps/rapps/libreoffice.txt | 6 +++--- .../base/applications/rapps/rapps/mirandaim.txt | 4 ++-- reactos/base/applications/rapps/rapps/scite.txt | 4 ++-- .../base/applications/rapps/rapps/seamonkey.txt | 12 ++++++------ .../applications/rapps/rapps/thunderbird.txt | 14 +++++++------- .../base/applications/rapps/rapps/ultravnc.txt | 6 +++--- 7 files changed, 31 insertions(+), 31 deletions(-) diff --git a/reactos/base/applications/rapps/rapps/firefox36.txt b/reactos/base/applications/rapps/rapps/firefox36.txt index 31b72a5514f..cb035e8fc21 100644 --- a/reactos/base/applications/rapps/rapps/firefox36.txt +++ b/reactos/base/applications/rapps/rapps/firefox36.txt @@ -2,47 +2,47 @@ [Section] Name = Mozilla Firefox 3.6 -Version = 3.6.12 +Version = 3.6.13 Licence = MPL/GPL/LGPL Description = The most popular and one of the best free Web Browsers out there. Size = 8.1M Category = 5 URLSite = http://www.mozilla.com/en-US/ -URLDownload = http://releases.mozilla.org/pub/mozilla.org/firefox/releases/3.6.12/win32/en-US/Firefox%20Setup%203.6.12.exe +URLDownload = http://releases.mozilla.org/pub/mozilla.org/firefox/releases/3.6.13/win32/en-US/Firefox%20Setup%203.6.13.exe CDPath = none [Section.0407] Description = Der populärste und einer der besten freien Webbrowser. Size = 8.0M URLSite = http://www.mozilla-europe.org/de/ -URLDownload = http://releases.mozilla.org/pub/mozilla.org/firefox/releases/3.6.12/win32/de/Firefox%20Setup%203.6.12.exe +URLDownload = http://releases.mozilla.org/pub/mozilla.org/firefox/releases/3.6.13/win32/de/Firefox%20Setup%203.6.13.exe [Section.040a] Description = El más popular y uno de los mejores navegadores web gratuitos que hay. Size = 8.0M URLSite = http://www.mozilla-europe.org/es/ -URLDownload = http://releases.mozilla.org/pub/mozilla.org/firefox/releases/3.6.12/win32/es-ES/Firefox%20Setup%203.6.12.exe +URLDownload = http://releases.mozilla.org/pub/mozilla.org/firefox/releases/3.6.13/win32/es-ES/Firefox%20Setup%203.6.13.exe [Section.0414] Description = Mest populære og best ogsÃ¥ gratis nettleserene der ute. Size = 8.0M URLSite = http://www.mozilla-europe.org/no/ -URLDownload = http://releases.mozilla.org/pub/mozilla.org/firefox/releases/3.6.12/win32/nb-NO/Firefox%20Setup%203.6.12.exe +URLDownload = http://releases.mozilla.org/pub/mozilla.org/firefox/releases/3.6.13/win32/nb-NO/Firefox%20Setup%203.6.13.exe [Section.0415] Description = Najpopularniejsza i jedna z najlepszych darmowych przeglÄ…darek internetowych. Size = 8.8M URLSite = http://www.mozilla-europe.org/pl/ -URLDownload = http://releases.mozilla.org/pub/mozilla.org/firefox/releases/3.6.12/win32/pl/Firefox%20Setup%203.6.12.exe +URLDownload = http://releases.mozilla.org/pub/mozilla.org/firefox/releases/3.6.13/win32/pl/Firefox%20Setup%203.6.13.exe [Section.0419] Description = Один из Ñамых популÑрных и лучших беÑплатных браузеров. Size = 8.4M URLSite = http://www.mozilla-europe.org/ru/ -URLDownload = http://releases.mozilla.org/pub/mozilla.org/firefox/releases/3.6.12/win32/ru/Firefox%20Setup%203.6.12.exe +URLDownload = http://releases.mozilla.org/pub/mozilla.org/firefox/releases/3.6.13/win32/ru/Firefox%20Setup%203.6.13.exe [Section.0422] Description = ÐайпопулÑрніший та один з кращих безплатних веб-браузерів. Size = 8.4M URLSite = http://www.mozilla-europe.org/uk/ -URLDownload = http://releases.mozilla.org/pub/mozilla.org/firefox/releases/3.6.12/win32/uk/Firefox%20Setup%203.6.12.exe +URLDownload = http://releases.mozilla.org/pub/mozilla.org/firefox/releases/3.6.13/win32/uk/Firefox%20Setup%203.6.13.exe diff --git a/reactos/base/applications/rapps/rapps/libreoffice.txt b/reactos/base/applications/rapps/rapps/libreoffice.txt index 65ae3c3fa3a..d255969a765 100644 --- a/reactos/base/applications/rapps/rapps/libreoffice.txt +++ b/reactos/base/applications/rapps/rapps/libreoffice.txt @@ -2,13 +2,13 @@ [Section] Name = LibreOffice -Version = 3.3.0 Beta 3 +Version = 3.3.0 RC1 Licence = LGPL Description = Former called OpenOffice. Open Source Office Suite. -Size = 300.0MB +Size = 343.0MB Category = 6 URLSite = http://www.documentfoundation.org/ -URLDownload = http://download.documentfoundation.org/libreoffice/testing/3.3.0-beta3/win/x86/LibO_3.3.0_Win_x86_install_multi.exe +URLDownload = http://download.documentfoundation.org/libreoffice/testing/3.3.0-rc1/win/x86/LibO_3.3.0rc1_Win_x86_install_multi.exe CDPath = none [Section.0407] diff --git a/reactos/base/applications/rapps/rapps/mirandaim.txt b/reactos/base/applications/rapps/rapps/mirandaim.txt index d7a41806712..295a197d028 100644 --- a/reactos/base/applications/rapps/rapps/mirandaim.txt +++ b/reactos/base/applications/rapps/rapps/mirandaim.txt @@ -2,13 +2,13 @@ [Section] Name = Miranda IM -Version = 0.9.11 +Version = 0.9.12 Licence = GPL Description = Open source multiprotocol instant messaging application - May not work completely. Size = 3.0MB Category = 5 URLSite = http://www.miranda-im.org/ -URLDownload = http://miranda.googlecode.com/files/miranda-im-v0.9.11-unicode.exe +URLDownload = http://miranda.googlecode.com/files/miranda-im-v0.9.12-unicode.exe CDPath = none [Section.0407] diff --git a/reactos/base/applications/rapps/rapps/scite.txt b/reactos/base/applications/rapps/rapps/scite.txt index bdb56884200..2b5ae7117f4 100644 --- a/reactos/base/applications/rapps/rapps/scite.txt +++ b/reactos/base/applications/rapps/rapps/scite.txt @@ -2,13 +2,13 @@ [Section] Name = SciTE -Version = 2.22 +Version = 2.23 Licence = Freeware Description = SciTE is a SCIntilla based Text Editor. Originally built to demonstrate Scintilla, it has grown to be a generally useful editor with facilities for building and running programs. Size = 0.6M Category = 7 URLSite = http://www.scintilla.org/ -URLDownload = http://kent.dl.sourceforge.net/project/scintilla/SciTE/2.22/Sc222.exe +URLDownload = http://kent.dl.sourceforge.net/project/scintilla/SciTE/2.23/Sc223.exe CDPath = none [Section.0407] diff --git a/reactos/base/applications/rapps/rapps/seamonkey.txt b/reactos/base/applications/rapps/rapps/seamonkey.txt index ae5b9134110..c9543c8c5ea 100644 --- a/reactos/base/applications/rapps/rapps/seamonkey.txt +++ b/reactos/base/applications/rapps/rapps/seamonkey.txt @@ -2,31 +2,31 @@ [Section] Name = Mozilla SeaMonkey -Version = 2.0.10 +Version = 2.0.11 Licence = MPL/GPL/LGPL Description = Mozilla Suite is alive. This is the one and only Browser, Mail, Chat, and Composer bundle you will ever need. Size = 10.1MB Category = 5 URLSite = http://www.seamonkey-project.org/ -URLDownload = http://releases.mozilla.org/pub/mozilla.org/seamonkey/releases/2.0.10/win32/en-US/SeaMonkey%20Setup%202.0.10.exe +URLDownload = http://releases.mozilla.org/pub/mozilla.org/seamonkey/releases/2.0.11/win32/en-US/SeaMonkey%20Setup%202.0.11.exe CDPath = none [Section.0407] Description = Mozilla Suite lebt. Dies ist das einzige Browser-, Mail-, Chat- and Composerwerkzeug-Bundle welches Sie benötigen. Size = 10.0MB -URLDownload = http://releases.mozilla.org/pub/mozilla.org/seamonkey/releases/2.0.10/win32/de/SeaMonkey%20Setup%202.0.10.exe +URLDownload = http://releases.mozilla.org/pub/mozilla.org/seamonkey/releases/2.0.11/win32/de/SeaMonkey%20Setup%202.0.11.exe [Section.040a] Description = La suite de Mozilla está viva. Es el primero y único navegador web, gestor de correo, lector de noticias, Chat y editor HTML que necesitarás. Size = 10.0MB -URLDownload = http://releases.mozilla.org/pub/mozilla.org/seamonkey/releases/2.0.10/win32/es-ES/SeaMonkey%20Setup%202.0.10.exe +URLDownload = http://releases.mozilla.org/pub/mozilla.org/seamonkey/releases/2.0.11/win32/es-ES/SeaMonkey%20Setup%202.0.11.exe [Section.0415] Description = Pakiet Mozilla żyje. W zestawie: przeglÄ…darka, klient poczty, IRC oraz Edytor HTML - wszystko, czego potrzebujesz. Size = 10.8MB -URLDownload = http://releases.mozilla.org/pub/mozilla.org/seamonkey/releases/2.0.10/win32/pl/SeaMonkey%20Setup%202.0.10.exe +URLDownload = http://releases.mozilla.org/pub/mozilla.org/seamonkey/releases/2.0.11/win32/pl/SeaMonkey%20Setup%202.0.11.exe [Section.0419] Description = Продолжение Mozilla Suite. Включает браузер, почтовый клиент, IRC-клиент и HTML-редактор. Size = 10.4MB -URLDownload = http://releases.mozilla.org/pub/mozilla.org/seamonkey/releases/2.0.10/win32/ru/SeaMonkey%20Setup%202.0.10.exe +URLDownload = http://releases.mozilla.org/pub/mozilla.org/seamonkey/releases/2.0.11/win32/ru/SeaMonkey%20Setup%202.0.11.exe diff --git a/reactos/base/applications/rapps/rapps/thunderbird.txt b/reactos/base/applications/rapps/rapps/thunderbird.txt index 2e120b09a7c..293389025d3 100644 --- a/reactos/base/applications/rapps/rapps/thunderbird.txt +++ b/reactos/base/applications/rapps/rapps/thunderbird.txt @@ -2,41 +2,41 @@ [Section] Name = Mozilla Thunderbird -Version = 3.1.6 +Version = 3.1.7 Licence = MPL/GPL/LGPL Description = The most popular and one of the best free Mail Clients out there. Size = 9.0M Category = 5 URLSite = http://www.mozilla-europe.org/en/products/thunderbird/ -URLDownload = http://releases.mozilla.org/pub/mozilla.org/thunderbird/releases/3.1.6/win32/en-US/Thunderbird%20Setup%203.1.6.exe +URLDownload = http://releases.mozilla.org/pub/mozilla.org/thunderbird/releases/3.1.7/win32/en-US/Thunderbird%20Setup%203.1.7.exe CDPath = none [Section.0407] Description = Der populärste und einer der besten freien Mail-Clients. Size = 8.8M URLSite = http://www.mozilla-europe.org/de/products/thunderbird/ -URLDownload = http://releases.mozilla.org/pub/mozilla.org/thunderbird/releases/3.1.6/win32/de/Thunderbird%20Setup%203.1.6.exe +URLDownload = http://releases.mozilla.org/pub/mozilla.org/thunderbird/releases/3.1.7/win32/de/Thunderbird%20Setup%203.1.7.exe [Section.040a] Description = El más popular y uno de los mejores clientes mail que hay. Size = 8.8M URLSite = http://www.mozilla-europe.org/es/products/thunderbird/ -URLDownload = http://releases.mozilla.org/pub/mozilla.org/thunderbird/releases/3.1.6/win32/es-ES/Thunderbird%20Setup%203.1.6.exe +URLDownload = http://releases.mozilla.org/pub/mozilla.org/thunderbird/releases/3.1.7/win32/es-ES/Thunderbird%20Setup%203.1.7.exe [Section.0415] Description = Najpopularniejszy i jeden z najlepszych darmowych klientów poczty. Size = 9.7M URLSite = http://www.mozilla-europe.org/pl/products/thunderbird/ -URLDownload = http://releases.mozilla.org/pub/mozilla.org/thunderbird/releases/3.1.6/win32/pl/Thunderbird%20Setup%203.1.6.exe +URLDownload = http://releases.mozilla.org/pub/mozilla.org/thunderbird/releases/3.1.7/win32/pl/Thunderbird%20Setup%203.1.7.exe [Section.0419] Description = Один из Ñамых популÑрных и лучших беÑплатных почтовых клиентов. Size = 9.2M URLSite = http://www.mozilla-europe.org/ru/products/thunderbird/ -URLDownload = http://releases.mozilla.org/pub/mozilla.org/thunderbird/releases/3.1.6/win32/ru/Thunderbird%20Setup%203.1.6.exe +URLDownload = http://releases.mozilla.org/pub/mozilla.org/thunderbird/releases/3.1.7/win32/ru/Thunderbird%20Setup%203.1.7.exe [Section.0422] Description = ÐайпопулÑрніший та один з кращих поштових клієнтів. Size = 9.2M URLSite = http://www.mozillamessaging.com/uk/thunderbird/ -URLDownload = http://releases.mozilla.org/pub/mozilla.org/thunderbird/releases/3.1.6/win32/uk/Thunderbird%20Setup%203.1.6.exe +URLDownload = http://releases.mozilla.org/pub/mozilla.org/thunderbird/releases/3.1.7/win32/uk/Thunderbird%20Setup%203.1.7.exe diff --git a/reactos/base/applications/rapps/rapps/ultravnc.txt b/reactos/base/applications/rapps/rapps/ultravnc.txt index 89ab6740655..7c107c1aba9 100644 --- a/reactos/base/applications/rapps/rapps/ultravnc.txt +++ b/reactos/base/applications/rapps/rapps/ultravnc.txt @@ -2,13 +2,13 @@ [Section] Name = UltraVNC -Version = 1.0.9.1 +Version = 1.0.9.5 Licence = GPL Description = Open-source VNC client/server. -Size = 2.0MB +Size = 2.1MB Category = 5 URLSite = http://www.uvnc.com/ -URLDownload = http://support1.uvnc.com/download/109/UltraVNC_1.0.9.1_Setup.exe +URLDownload = http://support1.uvnc.com/download/1095/UltraVNC_1.0.9.5_Setup.exe CDPath = none [Section.040a] From 50dce372bb9250397add62786cd17c7ec9c828b6 Mon Sep 17 00:00:00 2001 From: Sylvain Petreolle Date: Sun, 12 Dec 2010 21:30:20 +0000 Subject: [PATCH 040/181] [ROSTESTS] Add lorem ipsum test file. svn path=/trunk/; revision=50014 --- rostests/lorem ipsum.txt | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 rostests/lorem ipsum.txt diff --git a/rostests/lorem ipsum.txt b/rostests/lorem ipsum.txt new file mode 100644 index 00000000000..d5632a09ea9 --- /dev/null +++ b/rostests/lorem ipsum.txt @@ -0,0 +1,3 @@ +The standard Lorem Ipsum passage, used since the 1500s + +"Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum." \ No newline at end of file From dbb98253a66cc6a9998338b1e9b10c50b44493b7 Mon Sep 17 00:00:00 2001 From: Sylvain Petreolle Date: Sun, 12 Dec 2010 21:48:05 +0000 Subject: [PATCH 041/181] [ROSTESTS] Delete test file. svn path=/trunk/; revision=50015 --- rostests/lorem ipsum.txt | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 rostests/lorem ipsum.txt diff --git a/rostests/lorem ipsum.txt b/rostests/lorem ipsum.txt deleted file mode 100644 index d5632a09ea9..00000000000 --- a/rostests/lorem ipsum.txt +++ /dev/null @@ -1,3 +0,0 @@ -The standard Lorem Ipsum passage, used since the 1500s - -"Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum." \ No newline at end of file From 2af18a66e38da94758260fdad79f12681d343bf6 Mon Sep 17 00:00:00 2001 From: Pierre Schweitzer Date: Sun, 12 Dec 2010 22:03:42 +0000 Subject: [PATCH 042/181] Commit test... svn path=/trunk/; revision=50016 --- rostests/drivers/kmtest/test | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 rostests/drivers/kmtest/test diff --git a/rostests/drivers/kmtest/test b/rostests/drivers/kmtest/test new file mode 100644 index 00000000000..e69de29bb2d From 1632e9c5280e354db4bb4db14bf64e415794a6ea Mon Sep 17 00:00:00 2001 From: Pierre Schweitzer Date: Sun, 12 Dec 2010 22:04:59 +0000 Subject: [PATCH 043/181] Revert r50016 svn path=/trunk/; revision=50017 --- rostests/drivers/kmtest/test | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 rostests/drivers/kmtest/test diff --git a/rostests/drivers/kmtest/test b/rostests/drivers/kmtest/test deleted file mode 100644 index e69de29bb2d..00000000000 From 94b828f1a458b170a42ef0cac6849d6e36815a6b Mon Sep 17 00:00:00 2001 From: Pierre Schweitzer Date: Sun, 12 Dec 2010 22:09:35 +0000 Subject: [PATCH 044/181] [KMTEST] Added more testcases for FsRtlIsNameInExpression() svn path=/trunk/; revision=50018 --- rostests/drivers/kmtest/ntos_fsrtl.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/rostests/drivers/kmtest/ntos_fsrtl.c b/rostests/drivers/kmtest/ntos_fsrtl.c index 2f9c29f37d8..f0aea30d276 100644 --- a/rostests/drivers/kmtest/ntos_fsrtl.c +++ b/rostests/drivers/kmtest/ntos_fsrtl.c @@ -33,6 +33,12 @@ VOID FsRtlIsNameInExpressionTest() { UNICODE_STRING Expression, Name; + RtlInitUnicodeString(&Expression, L"*"); + RtlInitUnicodeString(&Name, L""); + ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == FALSE, "expected FALSE, got TRUE"); + RtlInitUnicodeString(&Expression, L""); + ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == TRUE, "expected TRUE, got FALSE"); + RtlInitUnicodeString(&Expression, L"ntdll.dll"); RtlInitUnicodeString(&Name, L"."); ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == FALSE, "expected FALSE, got TRUE"); @@ -112,6 +118,23 @@ VOID FsRtlIsNameInExpressionTest() ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == TRUE, "expected TRUE, got FALSE"); RtlInitUnicodeString(&Name, L"SETUP.INI"); ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == TRUE, "expected TRUE, got FALSE"); + + RtlInitUnicodeString(&Expression, L"\"ntoskrnl.exe"); + RtlInitUnicodeString(&Name, L"ntoskrnl.exe"); + ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == FALSE, "expected FALSE, got TRUE"); + RtlInitUnicodeString(&Expression, L"ntoskrnl\"exe"); + ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == TRUE, "expected TRUE, got FALSE"); + RtlInitUnicodeString(&Expression, L"ntoskrn\".exe"); + ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == FALSE, "expected FALSE, got TRUE"); + RtlInitUnicodeString(&Expression, L"ntoskrn\"\"exe"); + ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == FALSE, "expected FALSE, got TRUE"); + RtlInitUnicodeString(&Expression, L"ntoskrnl.\"exe"); + ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == FALSE, "expected FALSE, got TRUE"); + RtlInitUnicodeString(&Expression, L"ntoskrnl.exe\""); + RtlInitUnicodeString(&Name, L"ntoskrnl.exe"); + ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == TRUE, "expected TRUE, got FALSE"); + RtlInitUnicodeString(&Name, L"ntoskrnl.exe."); + ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == TRUE, "expected TRUE, got FALSE"); } /* PUBLIC FUNCTIONS ***********************************************************/ From ffd29f0aa392eacdf5098a439b1b416c110ba1c9 Mon Sep 17 00:00:00 2001 From: Pierre Schweitzer Date: Sun, 12 Dec 2010 22:17:45 +0000 Subject: [PATCH 045/181] [NTOSKRNL] Fixed FsRtlIsNameInExpression() according to r50018 tests svn path=/trunk/; revision=50019 --- reactos/ntoskrnl/fsrtl/name.c | 80 +++++++++++++++++------------------ 1 file changed, 39 insertions(+), 41 deletions(-) diff --git a/reactos/ntoskrnl/fsrtl/name.c b/reactos/ntoskrnl/fsrtl/name.c index 291ecf7f12a..a9301172e9c 100644 --- a/reactos/ntoskrnl/fsrtl/name.c +++ b/reactos/ntoskrnl/fsrtl/name.c @@ -29,55 +29,53 @@ FsRtlIsNameInExpressionPrivate(IN PUNICODE_STRING Expression, while (i < Name->Length / sizeof(WCHAR) && k < Expression->Length / sizeof(WCHAR)) { - if ((Expression->Buffer[k] == (IgnoreCase ? UpcaseTable[Name->Buffer[i]] : Name->Buffer[i])) || - (Expression->Buffer[k] == L'?') || (Expression->Buffer[k] == DOS_QM) || - (Expression->Buffer[k] == DOS_DOT && (Name->Buffer[i] == L'.' || Name->Buffer[i] == L'0'))) - { - i++; - k++; - } - else if (Expression->Buffer[k] == L'*') - { - if (k < (Expression->Length / sizeof(WCHAR) - 1)) + if ((Expression->Buffer[k] == (IgnoreCase ? UpcaseTable[Name->Buffer[i]] : Name->Buffer[i])) || + (Expression->Buffer[k] == L'?') || (Expression->Buffer[k] == DOS_QM) || + (Expression->Buffer[k] == DOS_DOT && Name->Buffer[i] == L'.')) { - if (Expression->Buffer[k+1] != L'*' && Expression->Buffer[k+1] != L'?' && - Expression->Buffer[k+1] != DOS_DOT && Expression->Buffer[k+1] != DOS_QM && - Expression->Buffer[k+1] != DOS_STAR) - { - while ((IgnoreCase ? UpcaseTable[Name->Buffer[i]] : Name->Buffer[i]) != Expression->Buffer[k+1] && - i < Name->Length / sizeof(WCHAR)) i++; - } - else - { - if (!(Expression->Buffer[k+1] != DOS_DOT && (Name->Buffer[i] == L'.' || Name->Buffer[i] == L'0'))) + i++; + k++; + } + else if (Expression->Buffer[k] == L'*') + { + if (k < (Expression->Length / sizeof(WCHAR) - 1)) { - i++; + if (Expression->Buffer[k+1] != L'*' && Expression->Buffer[k+1] != L'?' && + Expression->Buffer[k+1] != DOS_DOT && Expression->Buffer[k+1] != DOS_QM && + Expression->Buffer[k+1] != DOS_STAR) + { + while ((IgnoreCase ? UpcaseTable[Name->Buffer[i]] : Name->Buffer[i]) != Expression->Buffer[k+1] && + i < Name->Length / sizeof(WCHAR)) i++; + } } - } + else + { + i = Name->Length / sizeof(WCHAR); + } + k++; + } + else if (Expression->Buffer[k] == DOS_STAR) + { + j = i; + while (j < Name->Length / sizeof(WCHAR)) + { + if (Name->Buffer[j] == L'.') + { + i = j; + } + j++; + } + k++; } else { - i = Name->Length / sizeof(WCHAR); + i = Name->Length / sizeof(WCHAR); } + } + if (k + 1 == Expression->Length / sizeof(WCHAR) && i == Name->Length / sizeof(WCHAR) && + Expression->Buffer[k] == DOS_DOT) + { k++; - } - else if (Expression->Buffer[k] == DOS_STAR) - { - j = i; - while (j < Name->Length / sizeof(WCHAR)) - { - if (Name->Buffer[j] == L'.') - { - i = j; - } - j++; - } - k++; - } - else - { - i = Name->Length / sizeof(WCHAR); - } } return (k == Expression->Length / sizeof(WCHAR) && i == Name->Length / sizeof(WCHAR)); From 2fed6b5925dbb51d22d597f242ec3bf7bdb6e9a7 Mon Sep 17 00:00:00 2001 From: Pierre Schweitzer Date: Mon, 13 Dec 2010 11:06:57 +0000 Subject: [PATCH 046/181] [KMTEST] Added testcases for FsRtlIsDbcsInExpression() svn path=/trunk/; revision=50020 --- rostests/drivers/kmtest/ntos_fsrtl.c | 109 +++++++++++++++++++++++++++ 1 file changed, 109 insertions(+) diff --git a/rostests/drivers/kmtest/ntos_fsrtl.c b/rostests/drivers/kmtest/ntos_fsrtl.c index f0aea30d276..fb407c8f8ac 100644 --- a/rostests/drivers/kmtest/ntos_fsrtl.c +++ b/rostests/drivers/kmtest/ntos_fsrtl.c @@ -137,12 +137,121 @@ VOID FsRtlIsNameInExpressionTest() ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == TRUE, "expected TRUE, got FALSE"); } +VOID FsRtlIsDbcsInExpressionTest() +{ + ANSI_STRING Expression, Name; + + RtlInitAnsiString(&Expression, "*"); + RtlInitAnsiString(&Name, ""); + ok(FsRtlIsDbcsInExpression(&Expression, &Name) == FALSE, "expected FALSE, got TRUE"); + RtlInitAnsiString(&Expression, ""); + ok(FsRtlIsDbcsInExpression(&Expression, &Name) == TRUE, "expected TRUE, got FALSE"); + + RtlInitAnsiString(&Expression, "ntdll.dll"); + RtlInitAnsiString(&Name, "."); + ok(FsRtlIsDbcsInExpression(&Expression, &Name) == FALSE, "expected FALSE, got TRUE"); + RtlInitAnsiString(&Name, "~1"); + ok(FsRtlIsDbcsInExpression(&Expression, &Name) == FALSE, "expected FALSE, got TRUE"); + RtlInitAnsiString(&Name, ".."); + ok(FsRtlIsDbcsInExpression(&Expression, &Name) == FALSE, "expected FALSE, got TRUE"); + RtlInitAnsiString(&Name, "ntdll.dll"); + ok(FsRtlIsDbcsInExpression(&Expression, &Name) == TRUE, "expected TRUE, got FALSE"); + + RtlInitAnsiString(&Expression, "smss.exe"); + RtlInitAnsiString(&Name, "."); + ok(FsRtlIsDbcsInExpression(&Expression, &Name) == FALSE, "expected FALSE, got TRUE"); + RtlInitAnsiString(&Name, "~1"); + ok(FsRtlIsDbcsInExpression(&Expression, &Name) == FALSE, "expected FALSE, got TRUE"); + RtlInitAnsiString(&Name, ".."); + ok(FsRtlIsDbcsInExpression(&Expression, &Name) == FALSE, "expected FALSE, got TRUE"); + RtlInitAnsiString(&Name, "ntdll.dll"); + ok(FsRtlIsDbcsInExpression(&Expression, &Name) == FALSE, "expected FALSE, got TRUE"); + RtlInitAnsiString(&Name, "NTDLL.dll"); + ok(FsRtlIsDbcsInExpression(&Expression, &Name) == FALSE, "expected FALSE, got TRUE"); + + RtlInitAnsiString(&Expression, "nt??krnl.???"); + RtlInitAnsiString(&Name, "ntoskrnl.exe"); + ok(FsRtlIsDbcsInExpression(&Expression, &Name) == TRUE, "expected TRUE, got FALSE"); + + RtlInitAnsiString(&Expression, "he*o"); + RtlInitAnsiString(&Name, "hello"); + ok(FsRtlIsDbcsInExpression(&Expression, &Name) == TRUE, "expected TRUE, got FALSE"); + RtlInitAnsiString(&Name, "helo"); + ok(FsRtlIsDbcsInExpression(&Expression, &Name) == TRUE, "expected TRUE, got FALSE"); + RtlInitAnsiString(&Name, "hella"); + ok(FsRtlIsDbcsInExpression(&Expression, &Name) == FALSE, "expected FALSE, got TRUE"); + + RtlInitAnsiString(&Expression, "he*"); + RtlInitAnsiString(&Name, "hello"); + ok(FsRtlIsDbcsInExpression(&Expression, &Name) == TRUE, "expected TRUE, got FALSE"); + RtlInitAnsiString(&Name, "helo"); + ok(FsRtlIsDbcsInExpression(&Expression, &Name) == TRUE, "expected TRUE, got FALSE"); + RtlInitAnsiString(&Name, "hella"); + ok(FsRtlIsDbcsInExpression(&Expression, &Name) == TRUE, "expected TRUE, got FALSE"); + + RtlInitAnsiString(&Expression, "*.cpl"); + RtlInitAnsiString(&Name, "kdcom.dll"); + ok(FsRtlIsDbcsInExpression(&Expression, &Name) == FALSE, "expected FALSE, got TRUE"); + RtlInitAnsiString(&Name, "bootvid.dll"); + ok(FsRtlIsDbcsInExpression(&Expression, &Name) == FALSE, "expected FALSE, got TRUE"); + RtlInitAnsiString(&Name, "ntoskrnl.exe"); + ok(FsRtlIsDbcsInExpression(&Expression, &Name) == FALSE, "expected FALSE, got TRUE"); + + RtlInitAnsiString(&Expression, "."); + RtlInitAnsiString(&Name, "NTDLL.DLL"); + ok(FsRtlIsDbcsInExpression(&Expression, &Name) == FALSE, "expected FALSE, got TRUE"); + + RtlInitAnsiString(&Expression, "F0_*.*"); + RtlInitAnsiString(&Name, "."); + ok(FsRtlIsDbcsInExpression(&Expression, &Name) == FALSE, "expected FALSE, got TRUE"); + RtlInitAnsiString(&Name, ".."); + ok(FsRtlIsDbcsInExpression(&Expression, &Name) == FALSE, "expected FALSE, got TRUE"); + RtlInitAnsiString(&Name, "SETUP.EXE"); + ok(FsRtlIsDbcsInExpression(&Expression, &Name) == FALSE, "expected FALSE, got TRUE"); + RtlInitAnsiString(&Name, "F0_001"); + ok(FsRtlIsDbcsInExpression(&Expression, &Name) == FALSE, "expected FALSE, got TRUE"); + + RtlInitAnsiString(&Expression, "*.TTF"); + RtlInitAnsiString(&Name, "."); + ok(FsRtlIsDbcsInExpression(&Expression, &Name) == FALSE, "expected FALSE, got TRUE"); + RtlInitAnsiString(&Name, ".."); + ok(FsRtlIsDbcsInExpression(&Expression, &Name) == FALSE, "expected FALSE, got TRUE"); + RtlInitAnsiString(&Name, "SETUP.INI"); + ok(FsRtlIsDbcsInExpression(&Expression, &Name) == FALSE, "expected FALSE, got TRUE"); + + RtlInitAnsiString(&Expression, "*"); + RtlInitAnsiString(&Name, "."); + ok(FsRtlIsDbcsInExpression(&Expression, &Name) == TRUE, "expected TRUE, got FALSE"); + RtlInitAnsiString(&Name, ".."); + ok(FsRtlIsDbcsInExpression(&Expression, &Name) == TRUE, "expected TRUE, got FALSE"); + RtlInitAnsiString(&Name, "SETUP.INI"); + ok(FsRtlIsDbcsInExpression(&Expression, &Name) == TRUE, "expected TRUE, got FALSE"); + + RtlInitAnsiString(&Expression, "\"ntoskrnl.exe"); + RtlInitAnsiString(&Name, "ntoskrnl.exe"); + ok(FsRtlIsDbcsInExpression(&Expression, &Name) == FALSE, "expected FALSE, got TRUE"); + RtlInitAnsiString(&Expression, "ntoskrnl\"exe"); + ok(FsRtlIsDbcsInExpression(&Expression, &Name) == TRUE, "expected TRUE, got FALSE"); + RtlInitAnsiString(&Expression, "ntoskrn\".exe"); + ok(FsRtlIsDbcsInExpression(&Expression, &Name) == FALSE, "expected FALSE, got TRUE"); + RtlInitAnsiString(&Expression, "ntoskrn\"\"exe"); + ok(FsRtlIsDbcsInExpression(&Expression, &Name) == FALSE, "expected FALSE, got TRUE"); + RtlInitAnsiString(&Expression, "ntoskrnl.\"exe"); + ok(FsRtlIsDbcsInExpression(&Expression, &Name) == FALSE, "expected FALSE, got TRUE"); + RtlInitAnsiString(&Expression, "ntoskrnl.exe\""); + RtlInitAnsiString(&Name, "ntoskrnl.exe"); + ok(FsRtlIsDbcsInExpression(&Expression, &Name) == TRUE, "expected TRUE, got FALSE"); + RtlInitAnsiString(&Name, "ntoskrnl.exe."); + ok(FsRtlIsDbcsInExpression(&Expression, &Name) == TRUE, "expected TRUE, got FALSE"); +} + /* PUBLIC FUNCTIONS ***********************************************************/ VOID NtoskrnlFsRtlTest(HANDLE KeyHandle) { FsRtlIsNameInExpressionTest(); + FsRtlIsDbcsInExpressionTest(); FinishTest(KeyHandle, L"FsRtlTest"); } From 435cdd8c499b603a0bfa7e2643e36f9b348bb8c0 Mon Sep 17 00:00:00 2001 From: Pierre Schweitzer Date: Mon, 13 Dec 2010 11:24:52 +0000 Subject: [PATCH 047/181] [NTOSKRNL] Rewritten FsRtlIsDbcsInExpression() using FsRtlIsNameInExpression() pattern. This fixes all failing tests from kmtest.sys and make this function definitely tastier to MS fastfat.sys svn path=/trunk/; revision=50021 --- reactos/ntoskrnl/fsrtl/dbcsname.c | 61 ++++++++++++++++++------------- 1 file changed, 36 insertions(+), 25 deletions(-) diff --git a/reactos/ntoskrnl/fsrtl/dbcsname.c b/reactos/ntoskrnl/fsrtl/dbcsname.c index 903da2eeab3..5b67c30dc1c 100644 --- a/reactos/ntoskrnl/fsrtl/dbcsname.c +++ b/reactos/ntoskrnl/fsrtl/dbcsname.c @@ -160,55 +160,66 @@ NTAPI FsRtlIsDbcsInExpression(IN PANSI_STRING Expression, IN PANSI_STRING Name) { - ULONG ExpressionPosition, NamePosition, MatchingChars = 0; + USHORT ExpressionPosition = 0, NamePosition = 0, MatchingChars; PAGED_CODE(); ASSERT(Name->Length); ASSERT(Expression->Length); ASSERT(!FsRtlDoesDbcsContainWildCards(Name)); - /* One can't be null, both can be */ - if (!Expression->Length || !Name->Length) + while (NamePosition < Name->Length && ExpressionPosition < Expression->Length) { - return !(Expression->Length ^ Name->Length); - } - - for (ExpressionPosition = 0; ExpressionPosition < Expression->Length; ExpressionPosition++) - { - if ((Expression->Buffer[ExpressionPosition] == Name->Buffer[MatchingChars]) || - (Expression->Buffer[ExpressionPosition] == '?') || - (Expression->Buffer[ExpressionPosition] == ANSI_DOS_QM) || - (Expression->Buffer[ExpressionPosition] == ANSI_DOS_DOT && - (Name->Buffer[MatchingChars] == '.' || Name->Buffer[MatchingChars] == '0'))) + if ((Expression->Buffer[ExpressionPosition] == Name->Buffer[NamePosition]) || + (Expression->Buffer[ExpressionPosition] == '?') || (Expression->Buffer[ExpressionPosition] == ANSI_DOS_QM) || + (Expression->Buffer[ExpressionPosition] == ANSI_DOS_DOT && Name->Buffer[NamePosition] == '.')) { - MatchingChars++; + NamePosition++; + ExpressionPosition++; } else if (Expression->Buffer[ExpressionPosition] == '*') { - MatchingChars = Name->Length; + if (ExpressionPosition < (Expression->Length - 1)) + { + if (Expression->Buffer[ExpressionPosition+1] != '*' && Expression->Buffer[ExpressionPosition+1] != '?' && + Expression->Buffer[ExpressionPosition+1] != ANSI_DOS_DOT && + Expression->Buffer[ExpressionPosition+1] != ANSI_DOS_QM && + Expression->Buffer[ExpressionPosition+1] != ANSI_DOS_STAR) + { + while (Name->Buffer[NamePosition] != Expression->Buffer[ExpressionPosition+1] && + NamePosition < Name->Length) NamePosition++; + } + } + else + { + NamePosition = Name->Length; + } + ExpressionPosition++; } else if (Expression->Buffer[ExpressionPosition] == ANSI_DOS_STAR) { - for (NamePosition = MatchingChars; NamePosition < Name->Length; NamePosition++) + MatchingChars = NamePosition; + while (MatchingChars < Name->Length) { - if (Name->Buffer[NamePosition] == '.') + if (Name->Buffer[MatchingChars] == '.') { - MatchingChars = NamePosition; - break; + NamePosition = MatchingChars; } + MatchingChars++; } + ExpressionPosition++; } else { - MatchingChars = 0; - } - if (MatchingChars == Name->Length) - { - return TRUE; + NamePosition = Name->Length; } } + if (ExpressionPosition + 1 == Expression->Length && NamePosition == Name->Length && + Expression->Buffer[ExpressionPosition] == ANSI_DOS_DOT) + { + ExpressionPosition++; + } - return FALSE; + return (ExpressionPosition == Expression->Length && NamePosition == Name->Length); } /*++ From fd45340e00dad81ccc47ff51a4915ff8fb741456 Mon Sep 17 00:00:00 2001 From: Pierre Schweitzer Date: Mon, 13 Dec 2010 11:33:29 +0000 Subject: [PATCH 048/181] [NTOSKRNL] Merge some changes from r50021 to FsRtlIsNameInExpression() to make code easier to read and understand... svn path=/trunk/; revision=50022 --- reactos/ntoskrnl/fsrtl/name.c | 56 +++++++++++++++++------------------ 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/reactos/ntoskrnl/fsrtl/name.c b/reactos/ntoskrnl/fsrtl/name.c index a9301172e9c..fc4d7400141 100644 --- a/reactos/ntoskrnl/fsrtl/name.c +++ b/reactos/ntoskrnl/fsrtl/name.c @@ -22,63 +22,63 @@ FsRtlIsNameInExpressionPrivate(IN PUNICODE_STRING Expression, IN BOOLEAN IgnoreCase, IN PWCHAR UpcaseTable OPTIONAL) { - ULONG i = 0, j, k = 0; + USHORT ExpressionPosition = 0, NamePosition = 0, MatchingChars; PAGED_CODE(); ASSERT(!IgnoreCase || UpcaseTable); - while (i < Name->Length / sizeof(WCHAR) && k < Expression->Length / sizeof(WCHAR)) + while (NamePosition < Name->Length / sizeof(WCHAR) && ExpressionPosition < Expression->Length / sizeof(WCHAR)) { - if ((Expression->Buffer[k] == (IgnoreCase ? UpcaseTable[Name->Buffer[i]] : Name->Buffer[i])) || - (Expression->Buffer[k] == L'?') || (Expression->Buffer[k] == DOS_QM) || - (Expression->Buffer[k] == DOS_DOT && Name->Buffer[i] == L'.')) + if ((Expression->Buffer[ExpressionPosition] == (IgnoreCase ? UpcaseTable[Name->Buffer[NamePosition]] : Name->Buffer[NamePosition])) || + (Expression->Buffer[ExpressionPosition] == L'?') || (Expression->Buffer[ExpressionPosition] == DOS_QM) || + (Expression->Buffer[ExpressionPosition] == DOS_DOT && Name->Buffer[NamePosition] == L'.')) { - i++; - k++; + NamePosition++; + ExpressionPosition++; } - else if (Expression->Buffer[k] == L'*') + else if (Expression->Buffer[ExpressionPosition] == L'*') { - if (k < (Expression->Length / sizeof(WCHAR) - 1)) + if (ExpressionPosition < (Expression->Length / sizeof(WCHAR) - 1)) { - if (Expression->Buffer[k+1] != L'*' && Expression->Buffer[k+1] != L'?' && - Expression->Buffer[k+1] != DOS_DOT && Expression->Buffer[k+1] != DOS_QM && - Expression->Buffer[k+1] != DOS_STAR) + if (Expression->Buffer[ExpressionPosition+1] != L'*' && Expression->Buffer[ExpressionPosition+1] != L'?' && + Expression->Buffer[ExpressionPosition+1] != DOS_DOT && Expression->Buffer[ExpressionPosition+1] != DOS_QM && + Expression->Buffer[ExpressionPosition+1] != DOS_STAR) { - while ((IgnoreCase ? UpcaseTable[Name->Buffer[i]] : Name->Buffer[i]) != Expression->Buffer[k+1] && - i < Name->Length / sizeof(WCHAR)) i++; + while ((IgnoreCase ? UpcaseTable[Name->Buffer[NamePosition]] : Name->Buffer[NamePosition]) != Expression->Buffer[ExpressionPosition+1] && + NamePosition < Name->Length / sizeof(WCHAR)) NamePosition++; } } else { - i = Name->Length / sizeof(WCHAR); + NamePosition = Name->Length / sizeof(WCHAR); } - k++; + ExpressionPosition++; } - else if (Expression->Buffer[k] == DOS_STAR) + else if (Expression->Buffer[ExpressionPosition] == DOS_STAR) { - j = i; - while (j < Name->Length / sizeof(WCHAR)) + MatchingChars = NamePosition; + while (MatchingChars < Name->Length / sizeof(WCHAR)) { - if (Name->Buffer[j] == L'.') + if (Name->Buffer[MatchingChars] == L'.') { - i = j; + NamePosition = MatchingChars; } - j++; + MatchingChars++; } - k++; + ExpressionPosition++; } else { - i = Name->Length / sizeof(WCHAR); + NamePosition = Name->Length / sizeof(WCHAR); } } - if (k + 1 == Expression->Length / sizeof(WCHAR) && i == Name->Length / sizeof(WCHAR) && - Expression->Buffer[k] == DOS_DOT) + if (ExpressionPosition + 1 == Expression->Length / sizeof(WCHAR) && NamePosition == Name->Length / sizeof(WCHAR) && + Expression->Buffer[ExpressionPosition] == DOS_DOT) { - k++; + ExpressionPosition++; } - return (k == Expression->Length / sizeof(WCHAR) && i == Name->Length / sizeof(WCHAR)); + return (ExpressionPosition == Expression->Length / sizeof(WCHAR) && NamePosition == Name->Length / sizeof(WCHAR)); } /* PUBLIC FUNCTIONS **********************************************************/ From 1d0887e1ac5f8341b45601d8e1c7a91c337feac9 Mon Sep 17 00:00:00 2001 From: Pierre Schweitzer Date: Mon, 13 Dec 2010 22:24:49 +0000 Subject: [PATCH 049/181] [NTOSKRNL] Silent FstubEx* debug prints on popular demand (ie, Timo) svn path=/trunk/; revision=50024 --- reactos/ntoskrnl/fstub/fstubex.c | 64 ++++++++++++++++---------------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/reactos/ntoskrnl/fstub/fstubex.c b/reactos/ntoskrnl/fstub/fstubex.c index 51b8ea48b52..5f99ce82995 100644 --- a/reactos/ntoskrnl/fstub/fstubex.c +++ b/reactos/ntoskrnl/fstub/fstubex.c @@ -558,16 +558,16 @@ FstubDbgPrintDriveLayoutEx(IN PDRIVE_LAYOUT_INFORMATION_EX DriveLayout) CHAR Guid[38]; PAGED_CODE(); - DPRINT1("FSTUB: DRIVE_LAYOUT_INFORMATION_EX: %p\n", DriveLayout); + DPRINT("FSTUB: DRIVE_LAYOUT_INFORMATION_EX: %p\n", DriveLayout); switch (DriveLayout->PartitionStyle) { case PARTITION_STYLE_MBR: if (DriveLayout->PartitionCount % 4 != 0) { - DPRINT1("Warning: Partition count isn't a 4-factor: %ld!\n", DriveLayout->PartitionCount); + DPRINT("Warning: Partition count isn't a 4-factor: %ld!\n", DriveLayout->PartitionCount); } - DPRINT1("Signature: %8.8x\n", DriveLayout->Mbr.Signature); + DPRINT("Signature: %8.8x\n", DriveLayout->Mbr.Signature); for (i = 0; i < DriveLayout->PartitionCount; i++) { FstubDbgPrintPartitionEx(DriveLayout->PartitionEntry, i); @@ -576,10 +576,10 @@ FstubDbgPrintDriveLayoutEx(IN PDRIVE_LAYOUT_INFORMATION_EX DriveLayout) break; case PARTITION_STYLE_GPT: FstubDbgGuidToString(&(DriveLayout->Gpt.DiskId), Guid); - DPRINT1("DiskId: %s\n", Guid); - DPRINT1("StartingUsableOffset: %I64x\n", DriveLayout->Gpt.StartingUsableOffset.QuadPart); - DPRINT1("UsableLength: %I64x\n", DriveLayout->Gpt.UsableLength.QuadPart); - DPRINT1("MaxPartitionCount: %ld\n", DriveLayout->Gpt.MaxPartitionCount); + DPRINT("DiskId: %s\n", Guid); + DPRINT("StartingUsableOffset: %I64x\n", DriveLayout->Gpt.StartingUsableOffset.QuadPart); + DPRINT("UsableLength: %I64x\n", DriveLayout->Gpt.UsableLength.QuadPart); + DPRINT("MaxPartitionCount: %ld\n", DriveLayout->Gpt.MaxPartitionCount); for (i = 0; i < DriveLayout->PartitionCount; i++) { FstubDbgPrintPartitionEx(DriveLayout->PartitionEntry, i); @@ -587,7 +587,7 @@ FstubDbgPrintDriveLayoutEx(IN PDRIVE_LAYOUT_INFORMATION_EX DriveLayout) break; default: - DPRINT1("Unsupported partition style: %ld\n", DriveLayout->PartitionStyle); + DPRINT("Unsupported partition style: %ld\n", DriveLayout->PartitionStyle); } } @@ -599,34 +599,34 @@ FstubDbgPrintPartitionEx(IN PPARTITION_INFORMATION_EX PartitionEntry, CHAR Guid[38]; PAGED_CODE(); - DPRINT1("Printing partition %ld\n", PartitionNumber); + DPRINT("Printing partition %ld\n", PartitionNumber); switch (PartitionEntry[PartitionNumber].PartitionStyle) { case PARTITION_STYLE_MBR: - DPRINT1(" StartingOffset: %I64x\n", PartitionEntry[PartitionNumber].StartingOffset.QuadPart); - DPRINT1(" PartitionLength: %I64x\n", PartitionEntry[PartitionNumber].PartitionLength.QuadPart); - DPRINT1(" RewritePartition: %d\n", PartitionEntry[PartitionNumber].RewritePartition); - DPRINT1(" PartitionType: %02x\n", PartitionEntry[PartitionNumber].Mbr.PartitionType); - DPRINT1(" BootIndicator: %d\n", PartitionEntry[PartitionNumber].Mbr.BootIndicator); - DPRINT1(" RecognizedPartition: %d\n", PartitionEntry[PartitionNumber].Mbr.RecognizedPartition); - DPRINT1(" HiddenSectors: %ld\n", PartitionEntry[PartitionNumber].Mbr.HiddenSectors); + DPRINT(" StartingOffset: %I64x\n", PartitionEntry[PartitionNumber].StartingOffset.QuadPart); + DPRINT(" PartitionLength: %I64x\n", PartitionEntry[PartitionNumber].PartitionLength.QuadPart); + DPRINT(" RewritePartition: %d\n", PartitionEntry[PartitionNumber].RewritePartition); + DPRINT(" PartitionType: %02x\n", PartitionEntry[PartitionNumber].Mbr.PartitionType); + DPRINT(" BootIndicator: %d\n", PartitionEntry[PartitionNumber].Mbr.BootIndicator); + DPRINT(" RecognizedPartition: %d\n", PartitionEntry[PartitionNumber].Mbr.RecognizedPartition); + DPRINT(" HiddenSectors: %ld\n", PartitionEntry[PartitionNumber].Mbr.HiddenSectors); break; case PARTITION_STYLE_GPT: - DPRINT1(" StartingOffset: %I64x\n", PartitionEntry[PartitionNumber].StartingOffset.QuadPart); - DPRINT1(" PartitionLength: %I64x\n", PartitionEntry[PartitionNumber].PartitionLength.QuadPart); - DPRINT1(" RewritePartition: %d\n", PartitionEntry[PartitionNumber].RewritePartition); + DPRINT(" StartingOffset: %I64x\n", PartitionEntry[PartitionNumber].StartingOffset.QuadPart); + DPRINT(" PartitionLength: %I64x\n", PartitionEntry[PartitionNumber].PartitionLength.QuadPart); + DPRINT(" RewritePartition: %d\n", PartitionEntry[PartitionNumber].RewritePartition); FstubDbgGuidToString(&(PartitionEntry[PartitionNumber].Gpt.PartitionType), Guid); - DPRINT1(" PartitionType: %s\n", Guid); + DPRINT(" PartitionType: %s\n", Guid); FstubDbgGuidToString(&(PartitionEntry[PartitionNumber].Gpt.PartitionId), Guid); - DPRINT1(" PartitionId: %s\n", Guid); - DPRINT1(" Attributes: %16x\n", PartitionEntry[PartitionNumber].Gpt.Attributes); - DPRINT1(" Name: %ws\n", PartitionEntry[PartitionNumber].Gpt.Name); + DPRINT(" PartitionId: %s\n", Guid); + DPRINT(" Attributes: %16x\n", PartitionEntry[PartitionNumber].Gpt.Attributes); + DPRINT(" Name: %ws\n", PartitionEntry[PartitionNumber].Gpt.Name); break; default: - DPRINT1(" Unsupported partition style: %ld\n", PartitionEntry[PartitionNumber].PartitionStyle); + DPRINT(" Unsupported partition style: %ld\n", PartitionEntry[PartitionNumber].PartitionStyle); } } @@ -638,25 +638,25 @@ FstubDbgPrintSetPartitionEx(IN PSET_PARTITION_INFORMATION_EX PartitionEntry, CHAR Guid[38]; PAGED_CODE(); - DPRINT1("FSTUB: SET_PARTITION_INFORMATION_EX: %p\n", PartitionEntry); - DPRINT1("Modifying partition %ld\n", PartitionNumber); + DPRINT("FSTUB: SET_PARTITION_INFORMATION_EX: %p\n", PartitionEntry); + DPRINT("Modifying partition %ld\n", PartitionNumber); switch (PartitionEntry->PartitionStyle) { case PARTITION_STYLE_MBR: - DPRINT1(" PartitionType: %02x\n", PartitionEntry->Mbr.PartitionType); + DPRINT(" PartitionType: %02x\n", PartitionEntry->Mbr.PartitionType); break; case PARTITION_STYLE_GPT: FstubDbgGuidToString(&(PartitionEntry->Gpt.PartitionType), Guid); - DPRINT1(" PartitionType: %s\n", Guid); + DPRINT(" PartitionType: %s\n", Guid); FstubDbgGuidToString(&(PartitionEntry->Gpt.PartitionId), Guid); - DPRINT1(" PartitionId: %s\n", Guid); - DPRINT1(" Attributes: %16x\n", PartitionEntry->Gpt.Attributes); - DPRINT1(" Name: %ws\n", PartitionEntry->Gpt.Name); + DPRINT(" PartitionId: %s\n", Guid); + DPRINT(" Attributes: %16x\n", PartitionEntry->Gpt.Attributes); + DPRINT(" Name: %ws\n", PartitionEntry->Gpt.Name); break; default: - DPRINT1(" Unsupported partition style: %ld\n", PartitionEntry[PartitionNumber].PartitionStyle); + DPRINT(" Unsupported partition style: %ld\n", PartitionEntry[PartitionNumber].PartitionStyle); } } From 4803978d0e765068c0134e00e35090d41902b86f Mon Sep 17 00:00:00 2001 From: evb Date: Tue, 14 Dec 2010 03:03:30 +0000 Subject: [PATCH 050/181] - commit base for new vga display miniport driver, is svn copy of framebuf_new as many codes identical - Will than commit and document differences to make into vga driver svn path=/trunk/; revision=50025 --- .../drivers/video/displays/vga_new/debug.c | 59 ++ .../drivers/video/displays/vga_new/debug.h | 26 + .../drivers/video/displays/vga_new/driver.h | 75 +++ .../drivers/video/displays/vga_new/enable.c | 476 ++++++++++++++ .../displays/vga_new/framebuf_new.rbuild | 21 + .../video/displays/vga_new/framebuf_new.rc | 5 + .../video/displays/vga_new/framebuf_new.spec | 1 + .../drivers/video/displays/vga_new/palette.c | 332 ++++++++++ .../drivers/video/displays/vga_new/pointer.c | 455 +++++++++++++ .../drivers/video/displays/vga_new/screen.c | 604 ++++++++++++++++++ 10 files changed, 2054 insertions(+) create mode 100755 reactos/drivers/video/displays/vga_new/debug.c create mode 100755 reactos/drivers/video/displays/vga_new/debug.h create mode 100755 reactos/drivers/video/displays/vga_new/driver.h create mode 100644 reactos/drivers/video/displays/vga_new/enable.c create mode 100644 reactos/drivers/video/displays/vga_new/framebuf_new.rbuild create mode 100644 reactos/drivers/video/displays/vga_new/framebuf_new.rc create mode 100644 reactos/drivers/video/displays/vga_new/framebuf_new.spec create mode 100755 reactos/drivers/video/displays/vga_new/palette.c create mode 100755 reactos/drivers/video/displays/vga_new/pointer.c create mode 100755 reactos/drivers/video/displays/vga_new/screen.c diff --git a/reactos/drivers/video/displays/vga_new/debug.c b/reactos/drivers/video/displays/vga_new/debug.c new file mode 100755 index 00000000000..ada125df7ec --- /dev/null +++ b/reactos/drivers/video/displays/vga_new/debug.c @@ -0,0 +1,59 @@ +/* + * PROJECT: ReactOS Framebuffer Display Driver + * LICENSE: Microsoft NT4 DDK Sample Code License + * FILE: boot/drivers/video/displays/framebuf/debug.c + * PURPOSE: Debug Support + * PROGRAMMERS: Copyright (c) 1992-1995 Microsoft Corporation + */ + +#include "driver.h" + +#if DBG + +ULONG DebugLevel = 0xFFFFFFFF; + +/***************************************************************************** + * + * Routine Description: + * + * This function is variable-argument, level-sensitive debug print + * routine. + * If the specified debug level for the print statement is lower or equal + * to the current debug level, the message will be printed. + * + * Arguments: + * + * DebugPrintLevel - Specifies at which debugging level the string should + * be printed + * + * DebugMessage - Variable argument ascii c string + * + * Return Value: + * + * None. + * + ***************************************************************************/ + +VOID +DebugPrint( + ULONG DebugPrintLevel, + PCHAR DebugMessage, + ... + ) + +{ + + va_list ap; + + va_start(ap, DebugMessage); + + if (DebugPrintLevel <= DebugLevel) + { + EngDebugPrint(STANDARD_DEBUG_PREFIX, DebugMessage, ap); + } + + va_end(ap); + +} + +#endif diff --git a/reactos/drivers/video/displays/vga_new/debug.h b/reactos/drivers/video/displays/vga_new/debug.h new file mode 100755 index 00000000000..d73a223baaf --- /dev/null +++ b/reactos/drivers/video/displays/vga_new/debug.h @@ -0,0 +1,26 @@ +/* + * PROJECT: ReactOS Framebuffer Display Driver + * LICENSE: Microsoft NT4 DDK Sample Code License + * FILE: boot/drivers/video/displays/framebuf/debug.h + * PURPOSE: Debug Support Header + * PROGRAMMERS: Copyright (c) 1992-1995 Microsoft Corporation + */ + +#if DBG + +VOID +DebugPrint( + ULONG DebugPrintLevel, + PCHAR DebugMessage, + ... + ); + +#define DISPDBG(arg) DebugPrint arg +#define RIP(x) { DebugPrint(0, x); EngDebugBreak();} + +#else + +#define DISPDBG(arg) +#define RIP(x) + +#endif diff --git a/reactos/drivers/video/displays/vga_new/driver.h b/reactos/drivers/video/displays/vga_new/driver.h new file mode 100755 index 00000000000..e9e617190c0 --- /dev/null +++ b/reactos/drivers/video/displays/vga_new/driver.h @@ -0,0 +1,75 @@ +/* + * PROJECT: ReactOS Framebuffer Display Driver + * LICENSE: Microsoft NT4 DDK Sample Code License + * FILE: boot/drivers/video/displays/framebuf/driver.h + * PURPOSE: Main Driver Header File + * PROGRAMMERS: Copyright (c) 1992-1995 Microsoft Corporation + * ReactOS Portable Systems Group + */ + +//#define DBG 1 +#include "stddef.h" +#include +#include "windef.h" +#include "wingdi.h" +#include "winddi.h" +#include "devioctl.h" +#include "ntddvdeo.h" +#include "debug.h" + +typedef struct _PDEV +{ + HANDLE hDriver; // Handle to \Device\Screen + HDEV hdevEng; // Engine's handle to PDEV + HSURF hsurfEng; // Engine's handle to surface + HPALETTE hpalDefault; // Handle to the default palette for device. + PBYTE pjScreen; // This is pointer to base screen address + ULONG cxScreen; // Visible screen width + ULONG cyScreen; // Visible screen height + ULONG ulMode; // Mode the mini-port driver is in. + LONG lDeltaScreen; // Distance from one scan to the next. + ULONG cScreenSize; // size of video memory, including + // offscreen memory. + PVOID pOffscreenList; // linked list of DCI offscreen surfaces. + FLONG flRed; // For bitfields device, Red Mask + FLONG flGreen; // For bitfields device, Green Mask + FLONG flBlue; // For bitfields device, Blue Mask + ULONG cPaletteShift; // number of bits the 8-8-8 palette must + // be shifted by to fit in the hardware + // palette. + ULONG ulBitCount; // # of bits per pel 8,16,24,32 are only supported. + POINTL ptlHotSpot; // adjustment for pointer hot spot + VIDEO_POINTER_CAPABILITIES PointerCapabilities; // HW pointer abilities + PVIDEO_POINTER_ATTRIBUTES pPointerAttributes; // hardware pointer attributes + DWORD cjPointerAttributes; // Size of buffer allocated + BOOL fHwCursorActive; // Are we currently using the hw cursor + PALETTEENTRY *pPal; // If this is pal managed, this is the pal + BOOL bSupportDCI; // Does the miniport support DCI? +// eVb: 3.1 [DDK Change] - Support new VGA Miniport behavior w.r.t updated framebuffer remapping + LONG flHooks; +// eVb: 3.1 [END] +} PDEV, *PPDEV; + +DWORD getAvailableModes(HANDLE, PVIDEO_MODE_INFORMATION *, DWORD *); +BOOL bInitPDEV(PPDEV, PDEVMODEW, GDIINFO *, DEVINFO *); +BOOL bInitSURF(PPDEV, BOOL); +BOOL bInitPaletteInfo(PPDEV, DEVINFO *); +BOOL bInitPointer(PPDEV, DEVINFO *); +BOOL bInit256ColorPalette(PPDEV); +VOID vDisablePalette(PPDEV); +VOID vDisableSURF(PPDEV); + +#define MAX_CLUT_SIZE (sizeof(VIDEO_CLUT) + (sizeof(ULONG) * 256)) + +// +// Determines the size of the DriverExtra information in the DEVMODE +// structure passed to and from the display driver. +// + +#define DRIVER_EXTRA_SIZE 0 + +#define DLL_NAME L"framebuf" // Name of the DLL in UNICODE +#define STANDARD_DEBUG_PREFIX "FRAMEBUF: " // All debug output is prefixed +#define ALLOC_TAG 'bfDD' // Four byte tag (characters in + // reverse order) used for memory + // allocations diff --git a/reactos/drivers/video/displays/vga_new/enable.c b/reactos/drivers/video/displays/vga_new/enable.c new file mode 100644 index 00000000000..8031da8a173 --- /dev/null +++ b/reactos/drivers/video/displays/vga_new/enable.c @@ -0,0 +1,476 @@ +/* + * PROJECT: ReactOS Framebuffer Display Driver + * LICENSE: Microsoft NT4 DDK Sample Code License + * FILE: boot/drivers/video/displays/framebuf/enable.c + * PURPOSE: Main Driver Initialization and PDEV Enabling + * PROGRAMMERS: Copyright (c) 1992-1995 Microsoft Corporation + * ReactOS Portable Systems Group + */ + +#include "driver.h" + +// The driver function table with all function index/address pairs + +static DRVFN gadrvfn[] = +{ + { INDEX_DrvEnablePDEV, (PFN) DrvEnablePDEV }, + { INDEX_DrvCompletePDEV, (PFN) DrvCompletePDEV }, + { INDEX_DrvDisablePDEV, (PFN) DrvDisablePDEV }, + { INDEX_DrvEnableSurface, (PFN) DrvEnableSurface }, + { INDEX_DrvDisableSurface, (PFN) DrvDisableSurface }, + { INDEX_DrvAssertMode, (PFN) DrvAssertMode }, + { INDEX_DrvSetPalette, (PFN) DrvSetPalette }, + { INDEX_DrvMovePointer, (PFN) DrvMovePointer }, + { INDEX_DrvSetPointerShape, (PFN) DrvSetPointerShape }, + { INDEX_DrvGetModes, (PFN) DrvGetModes } +}; + +// Define the functions you want to hook for 8/16/24/32 pel formats + +#define HOOKS_BMF8BPP 0 + +#define HOOKS_BMF16BPP 0 + +#define HOOKS_BMF24BPP 0 + +#define HOOKS_BMF32BPP 0 + +/******************************Public*Routine******************************\ +* DrvEnableDriver +* +* Enables the driver by retrieving the drivers function table and version. +* +\**************************************************************************/ + +BOOL DrvEnableDriver( +ULONG iEngineVersion, +ULONG cj, +PDRVENABLEDATA pded) +{ +// Engine Version is passed down so future drivers can support previous +// engine versions. A next generation driver can support both the old +// and new engine conventions if told what version of engine it is +// working with. For the first version the driver does nothing with it. +// eVb: 1.1 [DDK Change] - Remove bogus statement + //iEngineVersion; +// eVb: 1.1 [END] +// Fill in as much as we can. + + if (cj >= sizeof(DRVENABLEDATA)) + pded->pdrvfn = gadrvfn; + + if (cj >= (sizeof(ULONG) * 2)) + pded->c = sizeof(gadrvfn) / sizeof(DRVFN); + +// DDI version this driver was targeted for is passed back to engine. +// Future graphic's engine may break calls down to old driver format. + + if (cj >= sizeof(ULONG)) +// eVb: 1.2 [DDK Change] - Use DDI_DRIVER_VERSION_NT4 instead of DDI_DRIVER_VERSION + pded->iDriverVersion = DDI_DRIVER_VERSION_NT4; +// eVb: 1.2 [END] + + return(TRUE); +} + +/******************************Public*Routine******************************\ +* DrvEnablePDEV +* +* DDI function, Enables the Physical Device. +* +* Return Value: device handle to pdev. +* +\**************************************************************************/ + +DHPDEV DrvEnablePDEV( +DEVMODEW *pDevmode, // Pointer to DEVMODE +PWSTR pwszLogAddress, // Logical address +ULONG cPatterns, // number of patterns +HSURF *ahsurfPatterns, // return standard patterns +ULONG cjGdiInfo, // Length of memory pointed to by pGdiInfo +ULONG *pGdiInfo, // Pointer to GdiInfo structure +ULONG cjDevInfo, // Length of following PDEVINFO structure +DEVINFO *pDevInfo, // physical device information structure +HDEV hdev, // HDEV, used for callbacks +PWSTR pwszDeviceName, // DeviceName - not used +HANDLE hDriver) // Handle to base driver +{ + GDIINFO GdiInfo; + DEVINFO DevInfo; + PPDEV ppdev = (PPDEV) NULL; + + UNREFERENCED_PARAMETER(pwszLogAddress); + UNREFERENCED_PARAMETER(pwszDeviceName); + + // Allocate a physical device structure. + + ppdev = (PPDEV) EngAllocMem(0, sizeof(PDEV), ALLOC_TAG); + + if (ppdev == (PPDEV) NULL) + { + RIP("DISP DrvEnablePDEV failed EngAllocMem\n"); + return((DHPDEV) 0); + } + + memset(ppdev, 0, sizeof(PDEV)); + + // Save the screen handle in the PDEV. + + ppdev->hDriver = hDriver; + + // Get the current screen mode information. Set up device caps and devinfo. + + if (!bInitPDEV(ppdev, pDevmode, &GdiInfo, &DevInfo)) + { + DISPDBG((0,"DISP DrvEnablePDEV failed\n")); + goto error_free; + } + + // Initialize the cursor information. + + if (!bInitPointer(ppdev, &DevInfo)) + { + // Not a fatal error... + DISPDBG((0, "DrvEnablePDEV failed bInitPointer\n")); + } + + // Initialize palette information. + + if (!bInitPaletteInfo(ppdev, &DevInfo)) + { + RIP("DrvEnablePDEV failed bInitPalette\n"); + goto error_free; + } + + // Copy the devinfo into the engine buffer. + + memcpy(pDevInfo, &DevInfo, min(sizeof(DEVINFO), cjDevInfo)); + + // Set the pdevCaps with GdiInfo we have prepared to the list of caps for this + // pdev. + + memcpy(pGdiInfo, &GdiInfo, min(cjGdiInfo, sizeof(GDIINFO))); + + return((DHPDEV) ppdev); + + // Error case for failure. +error_free: + EngFreeMem(ppdev); + return((DHPDEV) 0); +} + +/******************************Public*Routine******************************\ +* DrvCompletePDEV +* +* Store the HPDEV, the engines handle for this PDEV, in the DHPDEV. +* +\**************************************************************************/ + +VOID DrvCompletePDEV( +DHPDEV dhpdev, +HDEV hdev) +{ + ((PPDEV) dhpdev)->hdevEng = hdev; +} + +/******************************Public*Routine******************************\ +* DrvDisablePDEV +* +* Release the resources allocated in DrvEnablePDEV. If a surface has been +* enabled DrvDisableSurface will have already been called. +* +\**************************************************************************/ + +VOID DrvDisablePDEV( +DHPDEV dhpdev) +{ + vDisablePalette((PPDEV) dhpdev); + EngFreeMem(dhpdev); +} + +/******************************Public*Routine******************************\ +* DrvEnableSurface +* +* Enable the surface for the device. Hook the calls this driver supports. +* +* Return: Handle to the surface if successful, 0 for failure. +* +\**************************************************************************/ + +HSURF DrvEnableSurface( +DHPDEV dhpdev) +{ + PPDEV ppdev; + HSURF hsurf; + SIZEL sizl; + ULONG ulBitmapType; + FLONG flHooks; + + // Create engine bitmap around frame buffer. + + ppdev = (PPDEV) dhpdev; + + if (!bInitSURF(ppdev, TRUE)) + { + RIP("DISP DrvEnableSurface failed bInitSURF\n"); + return(FALSE); + } + + sizl.cx = ppdev->cxScreen; + sizl.cy = ppdev->cyScreen; + + if (ppdev->ulBitCount == 8) + { + if (!bInit256ColorPalette(ppdev)) { + RIP("DISP DrvEnableSurface failed to init the 8bpp palette\n"); + return(FALSE); + } + ulBitmapType = BMF_8BPP; + flHooks = HOOKS_BMF8BPP; + } + else if (ppdev->ulBitCount == 16) + { + ulBitmapType = BMF_16BPP; + flHooks = HOOKS_BMF16BPP; + } + else if (ppdev->ulBitCount == 24) + { + ulBitmapType = BMF_24BPP; + flHooks = HOOKS_BMF24BPP; + } + else + { + ulBitmapType = BMF_32BPP; + flHooks = HOOKS_BMF32BPP; + } +// eVb: 1.3 [DDK Change] - Support new VGA Miniport behavior w.r.t updated framebuffer remapping + ppdev->flHooks = flHooks; +// eVb: 1.3 [END] +// eVb: 1.4 [DDK Change] - Use EngCreateDeviceSurface instead of EngCreateBitmap + hsurf = (HSURF)EngCreateDeviceSurface((DHSURF)ppdev, + sizl, + ulBitmapType); + + if (hsurf == (HSURF) 0) + { + RIP("DISP DrvEnableSurface failed EngCreateDeviceSurface\n"); + return(FALSE); + } +// eVb: 1.4 [END] + +// eVb: 1.5 [DDK Change] - Use EngModifySurface instead of EngAssociateSurface + if ( !EngModifySurface(hsurf, + ppdev->hdevEng, + ppdev->flHooks | HOOK_SYNCHRONIZE, + MS_NOTSYSTEMMEMORY, + (DHSURF)ppdev, + ppdev->pjScreen, + ppdev->lDeltaScreen, + NULL)) + { + RIP("DISP DrvEnableSurface failed EngModifySurface\n"); + return(FALSE); + } +// eVb: 1.5 [END] + ppdev->hsurfEng = hsurf; + + return(hsurf); +} + +/******************************Public*Routine******************************\ +* DrvDisableSurface +* +* Free resources allocated by DrvEnableSurface. Release the surface. +* +\**************************************************************************/ + +VOID DrvDisableSurface( +DHPDEV dhpdev) +{ + EngDeleteSurface(((PPDEV) dhpdev)->hsurfEng); + vDisableSURF((PPDEV) dhpdev); + ((PPDEV) dhpdev)->hsurfEng = (HSURF) 0; +} + +/******************************Public*Routine******************************\ +* DrvAssertMode +* +* This asks the device to reset itself to the mode of the pdev passed in. +* +\**************************************************************************/ + +BOOL DrvAssertMode( +DHPDEV dhpdev, +BOOL bEnable) +{ + PPDEV ppdev = (PPDEV) dhpdev; + ULONG ulReturn; + PBYTE pjScreen; + + if (bEnable) + { + // + // The screen must be reenabled, reinitialize the device to clean state. + // +// eVb: 1.6 [DDK Change] - Support new VGA Miniport behavior w.r.t updated framebuffer remapping + pjScreen = ppdev->pjScreen; + + if (!bInitSURF(ppdev, FALSE)) + { + DISPDBG((0, "DISP DrvAssertMode failed bInitSURF\n")); + return (FALSE); + } + + if (pjScreen != ppdev->pjScreen) { + + if ( !EngModifySurface(ppdev->hsurfEng, + ppdev->hdevEng, + ppdev->flHooks | HOOK_SYNCHRONIZE, + MS_NOTSYSTEMMEMORY, + (DHSURF)ppdev, + ppdev->pjScreen, + ppdev->lDeltaScreen, + NULL)) + { + DISPDBG((0, "DISP DrvAssertMode failed EngModifySurface\n")); + return (FALSE); + } + } +// eVb: 1.6 [END] + return (TRUE); + } + else + { + // + // We must give up the display. + // Call the kernel driver to reset the device to a known state. + // + + if (EngDeviceIoControl(ppdev->hDriver, + IOCTL_VIDEO_RESET_DEVICE, + NULL, + 0, + NULL, + 0, + &ulReturn)) + { + RIP("DISP DrvAssertMode failed IOCTL"); + return FALSE; + } + else + { + return TRUE; + } + } +} + +/******************************Public*Routine******************************\ +* DrvGetModes +* +* Returns the list of available modes for the device. +* +\**************************************************************************/ + +ULONG DrvGetModes( +HANDLE hDriver, +ULONG cjSize, +DEVMODEW *pdm) + +{ + + DWORD cModes; + DWORD cbOutputSize; + PVIDEO_MODE_INFORMATION pVideoModeInformation, pVideoTemp; + DWORD cOutputModes = cjSize / (sizeof(DEVMODEW) + DRIVER_EXTRA_SIZE); + DWORD cbModeSize; + + DISPDBG((3, "DrvGetModes\n")); + + cModes = getAvailableModes(hDriver, + (PVIDEO_MODE_INFORMATION *) &pVideoModeInformation, + &cbModeSize); + + if (cModes == 0) + { + DISPDBG((0, "DrvGetModes failed to get mode information")); + return 0; + } + + if (pdm == NULL) + { + cbOutputSize = cModes * (sizeof(DEVMODEW) + DRIVER_EXTRA_SIZE); + } + else + { + // + // Now copy the information for the supported modes back into the output + // buffer + // + + cbOutputSize = 0; + + pVideoTemp = pVideoModeInformation; + + do + { + if (pVideoTemp->Length != 0) + { + if (cOutputModes == 0) + { + break; + } + + // + // Zero the entire structure to start off with. + // + + memset(pdm, 0, sizeof(DEVMODEW)); + + // + // Set the name of the device to the name of the DLL. + // + + memcpy(pdm->dmDeviceName, DLL_NAME, sizeof(DLL_NAME)); + + pdm->dmSpecVersion = DM_SPECVERSION; + pdm->dmDriverVersion = DM_SPECVERSION; + pdm->dmSize = sizeof(DEVMODEW); + pdm->dmDriverExtra = DRIVER_EXTRA_SIZE; + + pdm->dmBitsPerPel = pVideoTemp->NumberOfPlanes * + pVideoTemp->BitsPerPlane; + pdm->dmPelsWidth = pVideoTemp->VisScreenWidth; + pdm->dmPelsHeight = pVideoTemp->VisScreenHeight; + pdm->dmDisplayFrequency = pVideoTemp->Frequency; + pdm->dmDisplayFlags = 0; + + pdm->dmFields = DM_BITSPERPEL | + DM_PELSWIDTH | + DM_PELSHEIGHT | + DM_DISPLAYFREQUENCY | + DM_DISPLAYFLAGS ; + + // + // Go to the next DEVMODE entry in the buffer. + // + + cOutputModes--; + + pdm = (LPDEVMODEW) ( ((ULONG)pdm) + sizeof(DEVMODEW) + + DRIVER_EXTRA_SIZE); + + cbOutputSize += (sizeof(DEVMODEW) + DRIVER_EXTRA_SIZE); + + } + + pVideoTemp = (PVIDEO_MODE_INFORMATION) + (((PUCHAR)pVideoTemp) + cbModeSize); + + } while (--cModes); + } + + EngFreeMem(pVideoModeInformation); + + return cbOutputSize; + +} diff --git a/reactos/drivers/video/displays/vga_new/framebuf_new.rbuild b/reactos/drivers/video/displays/vga_new/framebuf_new.rbuild new file mode 100644 index 00000000000..de7c4a1d3be --- /dev/null +++ b/reactos/drivers/video/displays/vga_new/framebuf_new.rbuild @@ -0,0 +1,21 @@ + + + + + . + win32k + debug.c + enable.c + palette.c + pointer.c + screen.c + framebuf_new.rc + + + -mrtd + -fno-builtin + -Wno-unused-variable + + + driver.h + diff --git a/reactos/drivers/video/displays/vga_new/framebuf_new.rc b/reactos/drivers/video/displays/vga_new/framebuf_new.rc new file mode 100644 index 00000000000..98ba2627f11 --- /dev/null +++ b/reactos/drivers/video/displays/vga_new/framebuf_new.rc @@ -0,0 +1,5 @@ +#define REACTOS_VERSION_DLL +#define REACTOS_STR_FILE_DESCRIPTION "Framebuffer Display Driver\0" +#define REACTOS_STR_INTERNAL_NAME "framebuf\0" +#define REACTOS_STR_ORIGINAL_FILENAME "framebuf.dll\0" +#include diff --git a/reactos/drivers/video/displays/vga_new/framebuf_new.spec b/reactos/drivers/video/displays/vga_new/framebuf_new.spec new file mode 100644 index 00000000000..aec115e4ef7 --- /dev/null +++ b/reactos/drivers/video/displays/vga_new/framebuf_new.spec @@ -0,0 +1 @@ +@ stdcall DrvEnableDriver(long long ptr) diff --git a/reactos/drivers/video/displays/vga_new/palette.c b/reactos/drivers/video/displays/vga_new/palette.c new file mode 100755 index 00000000000..c8cff990e2b --- /dev/null +++ b/reactos/drivers/video/displays/vga_new/palette.c @@ -0,0 +1,332 @@ +/* + * PROJECT: ReactOS Framebuffer Display Driver + * LICENSE: Microsoft NT4 DDK Sample Code License + * FILE: boot/drivers/video/displays/framebuf/palette.c + * PURPOSE: Palette Support + * PROGRAMMERS: Copyright (c) 1992-1995 Microsoft Corporation + */ + +#include "driver.h" + +// Global Table defining the 20 Window Default Colors. For 256 color +// palettes the first 10 must be put at the beginning of the palette +// and the last 10 at the end of the palette. + +const PALETTEENTRY BASEPALETTE[20] = +{ + { 0, 0, 0, 0 }, // 0 + { 0x80,0, 0, 0 }, // 1 + { 0, 0x80,0, 0 }, // 2 + { 0x80,0x80,0, 0 }, // 3 + { 0, 0, 0x80,0 }, // 4 + { 0x80,0, 0x80,0 }, // 5 + { 0, 0x80,0x80,0 }, // 6 + { 0xC0,0xC0,0xC0,0 }, // 7 + { 192, 220, 192, 0 }, // 8 + { 166, 202, 240, 0 }, // 9 + { 255, 251, 240, 0 }, // 10 + { 160, 160, 164, 0 }, // 11 + { 0x80,0x80,0x80,0 }, // 12 + { 0xFF,0, 0 ,0 }, // 13 + { 0, 0xFF,0 ,0 }, // 14 + { 0xFF,0xFF,0 ,0 }, // 15 + { 0 ,0, 0xFF,0 }, // 16 + { 0xFF,0, 0xFF,0 }, // 17 + { 0, 0xFF,0xFF,0 }, // 18 + { 0xFF,0xFF,0xFF,0 }, // 19 +}; + +BOOL bInitDefaultPalette(PPDEV ppdev, DEVINFO *pDevInfo); + +/******************************Public*Routine******************************\ +* bInitPaletteInfo +* +* Initializes the palette information for this PDEV. +* +* Called by DrvEnablePDEV. +* +\**************************************************************************/ + +BOOL bInitPaletteInfo(PPDEV ppdev, DEVINFO *pDevInfo) +{ + if (!bInitDefaultPalette(ppdev, pDevInfo)) + return(FALSE); + + return(TRUE); +} + +/******************************Public*Routine******************************\ +* vDisablePalette +* +* Frees resources allocated by bInitPaletteInfo. +* +\**************************************************************************/ + +VOID vDisablePalette(PPDEV ppdev) +{ +// Delete the default palette if we created one. + + if (ppdev->hpalDefault) + { + EngDeletePalette(ppdev->hpalDefault); + ppdev->hpalDefault = (HPALETTE) 0; + } + + if (ppdev->pPal != (PPALETTEENTRY)NULL) + EngFreeMem((PVOID)ppdev->pPal); +} + +/******************************Public*Routine******************************\ +* bInitDefaultPalette +* +* Initializes default palette for PDEV. +* +\**************************************************************************/ + +BOOL bInitDefaultPalette(PPDEV ppdev, DEVINFO *pDevInfo) +{ + if (ppdev->ulBitCount == 8) + { + ULONG ulLoop; + BYTE jRed,jGre,jBlu; + + // + // Allocate our palette + // + + ppdev->pPal = (PPALETTEENTRY)EngAllocMem(0, sizeof(PALETTEENTRY) * 256, + ALLOC_TAG); + + if ((ppdev->pPal) == NULL) { + RIP("DISP bInitDefaultPalette() failed EngAllocMem\n"); + return(FALSE); + } + + // + // Generate 256 (8*4*4) RGB combinations to fill the palette + // + + jRed = jGre = jBlu = 0; + + for (ulLoop = 0; ulLoop < 256; ulLoop++) + { + ppdev->pPal[ulLoop].peRed = jRed; + ppdev->pPal[ulLoop].peGreen = jGre; + ppdev->pPal[ulLoop].peBlue = jBlu; + ppdev->pPal[ulLoop].peFlags = (BYTE)0; + + if (!(jRed += 32)) + if (!(jGre += 32)) + jBlu += 64; + } + + // + // Fill in Windows Reserved Colors from the WIN 3.0 DDK + // The Window Manager reserved the first and last 10 colors for + // painting windows borders and for non-palette managed applications. + // + + for (ulLoop = 0; ulLoop < 10; ulLoop++) + { + // + // First 10 + // + + ppdev->pPal[ulLoop] = BASEPALETTE[ulLoop]; + + // + // Last 10 + // + + ppdev->pPal[246 + ulLoop] = BASEPALETTE[ulLoop+10]; + } + + // + // Create handle for palette. + // + + ppdev->hpalDefault = + pDevInfo->hpalDefault = EngCreatePalette(PAL_INDEXED, + 256, + (PULONG) ppdev->pPal, + 0,0,0); + + if (ppdev->hpalDefault == (HPALETTE) 0) + { + RIP("DISP bInitDefaultPalette failed EngCreatePalette\n"); + EngFreeMem(ppdev->pPal); + return(FALSE); + } + + // + // Initialize the hardware with the initial palette. + // + + return(TRUE); + + } else { + + ppdev->hpalDefault = + pDevInfo->hpalDefault = EngCreatePalette(PAL_BITFIELDS, + 0,(PULONG) NULL, + ppdev->flRed, + ppdev->flGreen, + ppdev->flBlue); + + if (ppdev->hpalDefault == (HPALETTE) 0) + { + RIP("DISP bInitDefaultPalette failed EngCreatePalette\n"); + return(FALSE); + } + } + + return(TRUE); +} + +/******************************Public*Routine******************************\ +* bInit256ColorPalette +* +* Initialize the hardware's palette registers. +* +\**************************************************************************/ + +BOOL bInit256ColorPalette(PPDEV ppdev) +{ + BYTE ajClutSpace[MAX_CLUT_SIZE]; + PVIDEO_CLUT pScreenClut; + ULONG ulReturnedDataLength; + ULONG cColors; + PVIDEO_CLUTDATA pScreenClutData; + + if (ppdev->ulBitCount == 8) + { + // + // Fill in pScreenClut header info: + // + + pScreenClut = (PVIDEO_CLUT) ajClutSpace; + pScreenClut->NumEntries = 256; + pScreenClut->FirstEntry = 0; + + // + // Copy colours in: + // + + cColors = 256; + pScreenClutData = (PVIDEO_CLUTDATA) (&(pScreenClut->LookupTable[0])); + + while(cColors--) + { + pScreenClutData[cColors].Red = ppdev->pPal[cColors].peRed >> + ppdev->cPaletteShift; + pScreenClutData[cColors].Green = ppdev->pPal[cColors].peGreen >> + ppdev->cPaletteShift; + pScreenClutData[cColors].Blue = ppdev->pPal[cColors].peBlue >> + ppdev->cPaletteShift; + pScreenClutData[cColors].Unused = 0; + } + + // + // Set palette registers: + // + + if (EngDeviceIoControl(ppdev->hDriver, + IOCTL_VIDEO_SET_COLOR_REGISTERS, + pScreenClut, + MAX_CLUT_SIZE, + NULL, + 0, + &ulReturnedDataLength)) + { + DISPDBG((0, "Failed bEnablePalette")); + return(FALSE); + } + } + + DISPDBG((5, "Passed bEnablePalette")); + + return(TRUE); +} + +/******************************Public*Routine******************************\ +* DrvSetPalette +* +* DDI entry point for manipulating the palette. +* +\**************************************************************************/ + +BOOL DrvSetPalette( +DHPDEV dhpdev, +PALOBJ* ppalo, +FLONG fl, +ULONG iStart, +ULONG cColors) +{ + BYTE ajClutSpace[MAX_CLUT_SIZE]; + PVIDEO_CLUT pScreenClut; + PVIDEO_CLUTDATA pScreenClutData; + PDEV* ppdev; + + UNREFERENCED_PARAMETER(fl); + + ppdev = (PDEV*) dhpdev; + + // + // Fill in pScreenClut header info: + // + + pScreenClut = (PVIDEO_CLUT) ajClutSpace; + pScreenClut->NumEntries = (USHORT) cColors; + pScreenClut->FirstEntry = (USHORT) iStart; + + pScreenClutData = (PVIDEO_CLUTDATA) (&(pScreenClut->LookupTable[0])); + + if (cColors != PALOBJ_cGetColors(ppalo, iStart, cColors, + (ULONG*) pScreenClutData)) + { + DISPDBG((0, "DrvSetPalette failed PALOBJ_cGetColors\n")); + return (FALSE); + } + + // + // Set the high reserved byte in each palette entry to 0. + // Do the appropriate palette shifting to fit in the DAC. + // + + if (ppdev->cPaletteShift) + { + while(cColors--) + { + pScreenClutData[cColors].Red >>= ppdev->cPaletteShift; + pScreenClutData[cColors].Green >>= ppdev->cPaletteShift; + pScreenClutData[cColors].Blue >>= ppdev->cPaletteShift; + pScreenClutData[cColors].Unused = 0; + } + } + else + { + while(cColors--) + { + pScreenClutData[cColors].Unused = 0; + } + } + + // + // Set palette registers + // + + if (EngDeviceIoControl(ppdev->hDriver, + IOCTL_VIDEO_SET_COLOR_REGISTERS, + pScreenClut, + MAX_CLUT_SIZE, + NULL, + 0, + &cColors)) + { + DISPDBG((0, "DrvSetPalette failed EngDeviceIoControl\n")); + return (FALSE); + } + + return(TRUE); + +} diff --git a/reactos/drivers/video/displays/vga_new/pointer.c b/reactos/drivers/video/displays/vga_new/pointer.c new file mode 100755 index 00000000000..d3752a2763c --- /dev/null +++ b/reactos/drivers/video/displays/vga_new/pointer.c @@ -0,0 +1,455 @@ +/* + * PROJECT: ReactOS Framebuffer Display Driver + * LICENSE: Microsoft NT4 DDK Sample Code License + * FILE: boot/drivers/video/displays/framebuf/pointer.c + * PURPOSE: Hardware Pointer Support + * PROGRAMMERS: Copyright (c) 1992-1995 Microsoft Corporation + */ + +#include "driver.h" + +BOOL bCopyColorPointer( +PPDEV ppdev, +SURFOBJ *psoMask, +SURFOBJ *psoColor, +XLATEOBJ *pxlo); + +BOOL bCopyMonoPointer( +PPDEV ppdev, +SURFOBJ *psoMask); + +BOOL bSetHardwarePointerShape( +SURFOBJ *pso, +SURFOBJ *psoMask, +SURFOBJ *psoColor, +XLATEOBJ *pxlo, +LONG x, +LONG y, +FLONG fl); + +/******************************Public*Routine******************************\ +* DrvMovePointer +* +* Moves the hardware pointer to a new position. +* +\**************************************************************************/ + +VOID DrvMovePointer +( + SURFOBJ *pso, + LONG x, + LONG y, + RECTL *prcl +) +{ + PPDEV ppdev = (PPDEV) pso->dhpdev; + DWORD returnedDataLength; + VIDEO_POINTER_POSITION NewPointerPosition; + + // We don't use the exclusion rectangle because we only support + // hardware Pointers. If we were doing our own Pointer simulations + // we would want to update prcl so that the engine would call us + // to exclude out pointer before drawing to the pixels in prcl. + + UNREFERENCED_PARAMETER(prcl); + + if (x == -1) + { + // + // A new position of (-1,-1) means hide the pointer. + // + + if (EngDeviceIoControl(ppdev->hDriver, + IOCTL_VIDEO_DISABLE_POINTER, + NULL, + 0, + NULL, + 0, + &returnedDataLength)) + { + // + // Not the end of the world, print warning in checked build. + // + + DISPDBG((1, "DISP vMoveHardwarePointer failed IOCTL_VIDEO_DISABLE_POINTER\n")); + } + } + else + { + NewPointerPosition.Column = (SHORT) x - (SHORT) (ppdev->ptlHotSpot.x); + NewPointerPosition.Row = (SHORT) y - (SHORT) (ppdev->ptlHotSpot.y); + + // + // Call miniport driver to move Pointer. + // + + if (EngDeviceIoControl(ppdev->hDriver, + IOCTL_VIDEO_SET_POINTER_POSITION, + &NewPointerPosition, + sizeof(VIDEO_POINTER_POSITION), + NULL, + 0, + &returnedDataLength)) + { + // + // Not the end of the world, print warning in checked build. + // + + DISPDBG((1, "DISP vMoveHardwarePointer failed IOCTL_VIDEO_SET_POINTER_POSITION\n")); + } + } +} + +/******************************Public*Routine******************************\ +* DrvSetPointerShape +* +* Sets the new pointer shape. +* +\**************************************************************************/ + +ULONG DrvSetPointerShape +( + SURFOBJ *pso, + SURFOBJ *psoMask, + SURFOBJ *psoColor, + XLATEOBJ *pxlo, + LONG xHot, + LONG yHot, + LONG x, + LONG y, + RECTL *prcl, + FLONG fl +) +{ + PPDEV ppdev = (PPDEV) pso->dhpdev; + DWORD returnedDataLength; + + // We don't use the exclusion rectangle because we only support + // hardware Pointers. If we were doing our own Pointer simulations + // we would want to update prcl so that the engine would call us + // to exclude out pointer before drawing to the pixels in prcl. + UNREFERENCED_PARAMETER(prcl); + + if (ppdev->pPointerAttributes == (PVIDEO_POINTER_ATTRIBUTES) NULL) + { + // Mini-port has no hardware Pointer support. + return(SPS_ERROR); + } + + // See if we are being asked to hide the pointer + + if (psoMask == (SURFOBJ *) NULL) + { + if (EngDeviceIoControl(ppdev->hDriver, + IOCTL_VIDEO_DISABLE_POINTER, + NULL, + 0, + NULL, + 0, + &returnedDataLength)) + { + // + // It should never be possible to fail. + // Message supplied for debugging. + // + + DISPDBG((1, "DISP bSetHardwarePointerShape failed IOCTL_VIDEO_DISABLE_POINTER\n")); + } + + return(TRUE); + } + + ppdev->ptlHotSpot.x = xHot; + ppdev->ptlHotSpot.y = yHot; + + if (!bSetHardwarePointerShape(pso,psoMask,psoColor,pxlo,x,y,fl)) + { + if (ppdev->fHwCursorActive) { + ppdev->fHwCursorActive = FALSE; + + if (EngDeviceIoControl(ppdev->hDriver, + IOCTL_VIDEO_DISABLE_POINTER, + NULL, + 0, + NULL, + 0, + &returnedDataLength)) { + + DISPDBG((1, "DISP bSetHardwarePointerShape failed IOCTL_VIDEO_DISABLE_POINTER\n")); + } + } + + // + // Mini-port declines to realize this Pointer + // + + return(SPS_DECLINE); + } + else + { + ppdev->fHwCursorActive = TRUE; + } + + return(SPS_ACCEPT_NOEXCLUDE); +} + +/******************************Public*Routine******************************\ +* bSetHardwarePointerShape +* +* Changes the shape of the Hardware Pointer. +* +* Returns: True if successful, False if Pointer shape can't be hardware. +* +\**************************************************************************/ + +BOOL bSetHardwarePointerShape( +SURFOBJ *pso, +SURFOBJ *psoMask, +SURFOBJ *psoColor, +XLATEOBJ *pxlo, +LONG x, +LONG y, +FLONG fl) +{ + PPDEV ppdev = (PPDEV) pso->dhpdev; + PVIDEO_POINTER_ATTRIBUTES pPointerAttributes = ppdev->pPointerAttributes; + DWORD returnedDataLength; + + if (psoColor != (SURFOBJ *) NULL) + { + if ((ppdev->PointerCapabilities.Flags & VIDEO_MODE_COLOR_POINTER) && + bCopyColorPointer(ppdev, psoMask, psoColor, pxlo)) + { + pPointerAttributes->Flags |= VIDEO_MODE_COLOR_POINTER; + } else { + return(FALSE); + } + + } else { + + if ((ppdev->PointerCapabilities.Flags & VIDEO_MODE_MONO_POINTER) && + bCopyMonoPointer(ppdev, psoMask)) + { + pPointerAttributes->Flags |= VIDEO_MODE_MONO_POINTER; + } else { + return(FALSE); + } + } + + // + // Initialize Pointer attributes and position + // + + pPointerAttributes->Enable = 1; + + // + // if x,y = -1,-1 then pass them directly to the miniport so that + // the cursor will be disabled + + pPointerAttributes->Column = (SHORT)(x); + pPointerAttributes->Row = (SHORT)(y); + + if ((x != -1) || (y != -1)) { + pPointerAttributes->Column -= (SHORT)(ppdev->ptlHotSpot.x); + pPointerAttributes->Row -= (SHORT)(ppdev->ptlHotSpot.y); + } + + // + // set animate flags + // + + if (fl & SPS_ANIMATESTART) { + pPointerAttributes->Flags |= VIDEO_MODE_ANIMATE_START; + } else if (fl & SPS_ANIMATEUPDATE) { + pPointerAttributes->Flags |= VIDEO_MODE_ANIMATE_UPDATE; + } + + // + // Set the new Pointer shape. + // + + if (EngDeviceIoControl(ppdev->hDriver, + IOCTL_VIDEO_SET_POINTER_ATTR, + pPointerAttributes, + ppdev->cjPointerAttributes, + NULL, + 0, + &returnedDataLength)) { + + DISPDBG((1, "DISP:Failed IOCTL_VIDEO_SET_POINTER_ATTR call\n")); + return(FALSE); + } + + return(TRUE); +} + +/******************************Public*Routine******************************\ +* bCopyMonoPointer +* +* Copies two monochrome masks into a buffer of the maximum size handled by the +* miniport, with any extra bits set to 0. The masks are converted to topdown +* form if they aren't already. Returns TRUE if we can handle this pointer in +* hardware, FALSE if not. +* +\**************************************************************************/ + +BOOL bCopyMonoPointer( + PPDEV ppdev, + SURFOBJ *pso) +{ + ULONG cy; + PBYTE pjSrcAnd, pjSrcXor; + LONG lDeltaSrc, lDeltaDst; + LONG lSrcWidthInBytes; + ULONG cxSrc = pso->sizlBitmap.cx; + ULONG cySrc = pso->sizlBitmap.cy; + ULONG cxSrcBytes; + PVIDEO_POINTER_ATTRIBUTES pPointerAttributes = ppdev->pPointerAttributes; + PBYTE pjDstAnd = pPointerAttributes->Pixels; + PBYTE pjDstXor = pPointerAttributes->Pixels; + + // Make sure the new pointer isn't too big to handle + // (*2 because both masks are in there) + if ((cxSrc > ppdev->PointerCapabilities.MaxWidth) || + (cySrc > (ppdev->PointerCapabilities.MaxHeight * 2))) + { + return(FALSE); + } + + pjDstXor += ((ppdev->PointerCapabilities.MaxWidth + 7) / 8) * + ppdev->pPointerAttributes->Height; + + // set the desk and mask to 0xff + RtlFillMemory(pjDstAnd, ppdev->pPointerAttributes->WidthInBytes * + ppdev->pPointerAttributes->Height, 0xFF); + + // Zero the dest XOR mask + RtlZeroMemory(pjDstXor, ppdev->pPointerAttributes->WidthInBytes * + ppdev->pPointerAttributes->Height); + + cxSrcBytes = (cxSrc + 7) / 8; + + if ((lDeltaSrc = pso->lDelta) < 0) + { + lSrcWidthInBytes = -lDeltaSrc; + } else { + lSrcWidthInBytes = lDeltaSrc; + } + + pjSrcAnd = (PBYTE) pso->pvBits; + + // If the incoming pointer bitmap is bottomup, we'll flip it to topdown to + // save the miniport some work + if (!(pso->fjBitmap & BMF_TOPDOWN)) + { + // Copy from the bottom + pjSrcAnd += lSrcWidthInBytes * (cySrc - 1); + } + + // Height of just AND mask + cySrc = cySrc / 2; + + // Point to XOR mask + pjSrcXor = pjSrcAnd + (cySrc * lDeltaSrc); + + // Offset from end of one dest scan to start of next + lDeltaDst = ppdev->pPointerAttributes->WidthInBytes; + + for (cy = 0; cy < cySrc; ++cy) + { + RtlCopyMemory(pjDstAnd, pjSrcAnd, cxSrcBytes); + RtlCopyMemory(pjDstXor, pjSrcXor, cxSrcBytes); + + // Point to next source and dest scans + pjSrcAnd += lDeltaSrc; + pjSrcXor += lDeltaSrc; + pjDstAnd += lDeltaDst; + pjDstXor += lDeltaDst; + } + + return(TRUE); +} + +/******************************Public*Routine******************************\ +* bCopyColorPointer +* +* Copies the mono and color masks into the buffer of maximum size +* handled by the miniport with any extra bits set to 0. Color translation +* is handled at this time. The masks are converted to topdown form if they +* aren't already. Returns TRUE if we can handle this pointer in hardware, +* FALSE if not. +* +\**************************************************************************/ +BOOL bCopyColorPointer( +PPDEV ppdev, +SURFOBJ *psoMask, +SURFOBJ *psoColor, +XLATEOBJ *pxlo) +{ + return(FALSE); +} + + +/******************************Public*Routine******************************\ +* bInitPointer +* +* Initialize the Pointer attributes. +* +\**************************************************************************/ + +BOOL bInitPointer(PPDEV ppdev, DEVINFO *pdevinfo) +{ + DWORD returnedDataLength; + + ppdev->pPointerAttributes = (PVIDEO_POINTER_ATTRIBUTES) NULL; + ppdev->cjPointerAttributes = 0; // initialized in screen.c + + // + // Ask the miniport whether it provides pointer support. + // + + if (EngDeviceIoControl(ppdev->hDriver, + IOCTL_VIDEO_QUERY_POINTER_CAPABILITIES, + &ppdev->ulMode, + sizeof(PVIDEO_MODE), + &ppdev->PointerCapabilities, + sizeof(ppdev->PointerCapabilities), + &returnedDataLength)) + { + return(FALSE); + } + + // + // If neither mono nor color hardware pointer is supported, there's no + // hardware pointer support and we're done. + // + + if ((!(ppdev->PointerCapabilities.Flags & VIDEO_MODE_MONO_POINTER)) && + (!(ppdev->PointerCapabilities.Flags & VIDEO_MODE_COLOR_POINTER))) + { + return(TRUE); + } + + // + // Note: The buffer itself is allocated after we set the + // mode. At that time we know the pixel depth and we can + // allocate the correct size for the color pointer if supported. + // + + // + // Set the asynchronous support status (async means miniport is capable of + // drawing the Pointer at any time, with no interference with any ongoing + // drawing operation) + // + + if (ppdev->PointerCapabilities.Flags & VIDEO_MODE_ASYNC_POINTER) + { + pdevinfo->flGraphicsCaps |= GCAPS_ASYNCMOVE; + } + else + { + pdevinfo->flGraphicsCaps &= ~GCAPS_ASYNCMOVE; + } + + return(TRUE); +} diff --git a/reactos/drivers/video/displays/vga_new/screen.c b/reactos/drivers/video/displays/vga_new/screen.c new file mode 100755 index 00000000000..7ea4443c323 --- /dev/null +++ b/reactos/drivers/video/displays/vga_new/screen.c @@ -0,0 +1,604 @@ +/* + * PROJECT: ReactOS Framebuffer Display Driver + * LICENSE: Microsoft NT4 DDK Sample Code License + * FILE: boot/drivers/video/displays/framebuf/screen.c + * PURPOSE: Surface, Screen and PDEV support/initialization + * PROGRAMMERS: Copyright (c) 1992-1995 Microsoft Corporation + * ReactOS Portable Systems Group + */ +#include "driver.h" + +#define SYSTM_LOGFONT {16,7,0,0,700,0,0,0,ANSI_CHARSET,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,VARIABLE_PITCH | FF_DONTCARE,L"System"} +#define HELVE_LOGFONT {12,9,0,0,400,0,0,0,ANSI_CHARSET,OUT_DEFAULT_PRECIS,CLIP_STROKE_PRECIS,PROOF_QUALITY,VARIABLE_PITCH | FF_DONTCARE,L"MS Sans Serif"} +#define COURI_LOGFONT {12,9,0,0,400,0,0,0,ANSI_CHARSET,OUT_DEFAULT_PRECIS,CLIP_STROKE_PRECIS,PROOF_QUALITY,FIXED_PITCH | FF_DONTCARE, L"Courier"} + +// This is the basic devinfo for a default driver. This is used as a base and customized based +// on information passed back from the miniport driver. + +const DEVINFO gDevInfoFrameBuffer = { + ( GCAPS_OPAQUERECT +// eVb: 2.8 [DDK CHANGE] - No dithering support +// eVb: 2.8 [END] + ), /* Graphics capabilities */ + SYSTM_LOGFONT, /* Default font description */ + HELVE_LOGFONT, /* ANSI variable font description */ + COURI_LOGFONT, /* ANSI fixed font description */ + 0, /* Count of device fonts */ + 0, /* Preferred DIB format */ +// eVb: 2.9 [DDK CHANGE] - No dithering support + 0, /* Width of color dither */ + 0, /* Height of color dither */ +// eVb: 2.9 [END] + 0 /* Default palette to use for this device */ +}; + +/******************************Public*Routine******************************\ +* bInitSURF +* +* Enables the surface. Maps the frame buffer into memory. +* +\**************************************************************************/ + +BOOL bInitSURF(PPDEV ppdev, BOOL bFirst) +{ + DWORD returnedDataLength; + DWORD MaxWidth, MaxHeight; + VIDEO_MEMORY videoMemory; + VIDEO_MEMORY_INFORMATION videoMemoryInformation; +// eVb: 2.1 [DDK Change] - Support new VGA Miniport behavior w.r.t updated framebuffer remapping + ULONG RemappingNeeded = 0; +// eVb: 2.1 [END] + // + // Set the current mode into the hardware. + // + + if (EngDeviceIoControl(ppdev->hDriver, + IOCTL_VIDEO_SET_CURRENT_MODE, + &(ppdev->ulMode), + sizeof(ULONG), +// eVb: 2.2 [DDK Change] - Support new VGA Miniport behavior w.r.t updated framebuffer remapping + &RemappingNeeded, + sizeof(ULONG), +// eVb: 2.2 [END] + &returnedDataLength)) + { + RIP("DISP bInitSURF failed IOCTL_SET_MODE\n"); + return(FALSE); + } + + // + // If this is the first time we enable the surface we need to map in the + // memory also. + // +// eVb: 2.3 [DDK Change] - Support new VGA Miniport behavior w.r.t updated framebuffer remapping + if (bFirst || RemappingNeeded) + { +// eVb: 2.3 [END] + videoMemory.RequestedVirtualAddress = NULL; + + if (EngDeviceIoControl(ppdev->hDriver, + IOCTL_VIDEO_MAP_VIDEO_MEMORY, + &videoMemory, + sizeof(VIDEO_MEMORY), + &videoMemoryInformation, + sizeof(VIDEO_MEMORY_INFORMATION), + &returnedDataLength)) + { + RIP("DISP bInitSURF failed IOCTL_VIDEO_MAP\n"); + return(FALSE); + } + + ppdev->pjScreen = (PBYTE)(videoMemoryInformation.FrameBufferBase); + + if (videoMemoryInformation.FrameBufferBase != + videoMemoryInformation.VideoRamBase) + { + RIP("VideoRamBase does not correspond to FrameBufferBase\n"); + } +// eVb: 2.4 [DDK Change] - Make sure frame buffer mapping worked + // + // Make sure we can access this video memory + // + + *(PULONG)(ppdev->pjScreen) = 0xaa55aa55; + + if (*(PULONG)(ppdev->pjScreen) != 0xaa55aa55) { + + DISPDBG((1, "Frame buffer memory is not accessible.\n")); + return(FALSE); + } +// eVb: 2.4 [END] + ppdev->cScreenSize = videoMemoryInformation.VideoRamLength; + + // + // Initialize the head of the offscreen list to NULL. + // + + ppdev->pOffscreenList = NULL; + + // It's a hardware pointer; set up pointer attributes. + + MaxHeight = ppdev->PointerCapabilities.MaxHeight; + + // Allocate space for two DIBs (data/mask) for the pointer. If this + // device supports a color Pointer, we will allocate a larger bitmap. + // If this is a color bitmap we allocate for the largest possible + // bitmap because we have no idea of what the pixel depth might be. + + // Width rounded up to nearest byte multiple + + if (!(ppdev->PointerCapabilities.Flags & VIDEO_MODE_COLOR_POINTER)) + { + MaxWidth = (ppdev->PointerCapabilities.MaxWidth + 7) / 8; + } + else + { + MaxWidth = ppdev->PointerCapabilities.MaxWidth * sizeof(DWORD); + } + + ppdev->cjPointerAttributes = + sizeof(VIDEO_POINTER_ATTRIBUTES) + + ((sizeof(UCHAR) * MaxWidth * MaxHeight) * 2); + + ppdev->pPointerAttributes = (PVIDEO_POINTER_ATTRIBUTES) + EngAllocMem(0, ppdev->cjPointerAttributes, ALLOC_TAG); + + if (ppdev->pPointerAttributes == NULL) { + + DISPDBG((0, "bInitPointer EngAllocMem failed\n")); + return(FALSE); + } + + ppdev->pPointerAttributes->Flags = ppdev->PointerCapabilities.Flags; + ppdev->pPointerAttributes->WidthInBytes = MaxWidth; + ppdev->pPointerAttributes->Width = ppdev->PointerCapabilities.MaxWidth; + ppdev->pPointerAttributes->Height = MaxHeight; + ppdev->pPointerAttributes->Column = 0; + ppdev->pPointerAttributes->Row = 0; + ppdev->pPointerAttributes->Enable = 0; + } + + return(TRUE); +} + +/******************************Public*Routine******************************\ +* vDisableSURF +* +* Disable the surface. Un-Maps the frame in memory. +* +\**************************************************************************/ + +VOID vDisableSURF(PPDEV ppdev) +{ + DWORD returnedDataLength; + VIDEO_MEMORY videoMemory; + + videoMemory.RequestedVirtualAddress = (PVOID) ppdev->pjScreen; + + if (EngDeviceIoControl(ppdev->hDriver, + IOCTL_VIDEO_UNMAP_VIDEO_MEMORY, + &videoMemory, + sizeof(VIDEO_MEMORY), + NULL, + 0, + &returnedDataLength)) + { + RIP("DISP vDisableSURF failed IOCTL_VIDEO_UNMAP\n"); + } +} + + +/******************************Public*Routine******************************\ +* bInitPDEV +* +* Determine the mode we should be in based on the DEVMODE passed in. +* Query mini-port to get information needed to fill in the DevInfo and the +* GdiInfo . +* +\**************************************************************************/ + +BOOL bInitPDEV( +PPDEV ppdev, +DEVMODEW *pDevMode, +GDIINFO *pGdiInfo, +DEVINFO *pDevInfo) +{ + ULONG cModes; + PVIDEO_MODE_INFORMATION pVideoBuffer, pVideoModeSelected, pVideoTemp; + VIDEO_COLOR_CAPABILITIES colorCapabilities; + ULONG ulTemp; + BOOL bSelectDefault; + ULONG cbModeSize; + + // + // calls the miniport to get mode information. + // + + cModes = getAvailableModes(ppdev->hDriver, &pVideoBuffer, &cbModeSize); + + if (cModes == 0) + { + return(FALSE); + } + + // + // Now see if the requested mode has a match in that table. + // + + pVideoModeSelected = NULL; + pVideoTemp = pVideoBuffer; + + if ((pDevMode->dmPelsWidth == 0) && + (pDevMode->dmPelsHeight == 0) && + (pDevMode->dmBitsPerPel == 0) && + (pDevMode->dmDisplayFrequency == 0)) + { + DISPDBG((2, "Default mode requested")); + bSelectDefault = TRUE; + } + else + { +// eVb: 2.5 [DDK Change] - Add missing newlines to debug output + DISPDBG((2, "Requested mode...\n")); + DISPDBG((2, " Screen width -- %li\n", pDevMode->dmPelsWidth)); + DISPDBG((2, " Screen height -- %li\n", pDevMode->dmPelsHeight)); + DISPDBG((2, " Bits per pel -- %li\n", pDevMode->dmBitsPerPel)); + DISPDBG((2, " Frequency -- %li\n", pDevMode->dmDisplayFrequency)); +// eVb: 2.5 [END] + bSelectDefault = FALSE; + } + + while (cModes--) + { + if (pVideoTemp->Length != 0) + { + if (bSelectDefault || + ((pVideoTemp->VisScreenWidth == pDevMode->dmPelsWidth) && + (pVideoTemp->VisScreenHeight == pDevMode->dmPelsHeight) && + (pVideoTemp->BitsPerPlane * + pVideoTemp->NumberOfPlanes == pDevMode->dmBitsPerPel) && + (pVideoTemp->Frequency == pDevMode->dmDisplayFrequency))) + { + pVideoModeSelected = pVideoTemp; + DISPDBG((3, "Found a match\n")) ; + break; + } + } + + pVideoTemp = (PVIDEO_MODE_INFORMATION) + (((PUCHAR)pVideoTemp) + cbModeSize); + } + + // + // If no mode has been found, return an error + // + + if (pVideoModeSelected == NULL) + { + EngFreeMem(pVideoBuffer); + DISPDBG((0,"DISP bInitPDEV failed - no valid modes\n")); + return(FALSE); + } + + // + // Fill in the GDIINFO data structure with the information returned from + // the kernel driver. + // + + ppdev->ulMode = pVideoModeSelected->ModeIndex; + ppdev->cxScreen = pVideoModeSelected->VisScreenWidth; + ppdev->cyScreen = pVideoModeSelected->VisScreenHeight; + ppdev->ulBitCount = pVideoModeSelected->BitsPerPlane * + pVideoModeSelected->NumberOfPlanes; + ppdev->lDeltaScreen = pVideoModeSelected->ScreenStride; + + ppdev->flRed = pVideoModeSelected->RedMask; + ppdev->flGreen = pVideoModeSelected->GreenMask; + ppdev->flBlue = pVideoModeSelected->BlueMask; + + + pGdiInfo->ulVersion = GDI_DRIVER_VERSION; + pGdiInfo->ulTechnology = DT_RASDISPLAY; + pGdiInfo->ulHorzSize = pVideoModeSelected->XMillimeter; + pGdiInfo->ulVertSize = pVideoModeSelected->YMillimeter; + + pGdiInfo->ulHorzRes = ppdev->cxScreen; + pGdiInfo->ulVertRes = ppdev->cyScreen; + pGdiInfo->ulPanningHorzRes = ppdev->cxScreen; + pGdiInfo->ulPanningVertRes = ppdev->cyScreen; + pGdiInfo->cBitsPixel = pVideoModeSelected->BitsPerPlane; + pGdiInfo->cPlanes = pVideoModeSelected->NumberOfPlanes; + pGdiInfo->ulVRefresh = pVideoModeSelected->Frequency; + pGdiInfo->ulBltAlignment = 1; // We don't have accelerated screen- + // to-screen blts, and any + // window alignment is okay + + pGdiInfo->ulLogPixelsX = pDevMode->dmLogPixels; + pGdiInfo->ulLogPixelsY = pDevMode->dmLogPixels; + +#ifdef MIPS + if (ppdev->ulBitCount == 8) + pGdiInfo->flTextCaps = (TC_RA_ABLE | TC_SCROLLBLT); + else +#endif + pGdiInfo->flTextCaps = TC_RA_ABLE; + + pGdiInfo->flRaster = 0; // flRaster is reserved by DDI + + pGdiInfo->ulDACRed = pVideoModeSelected->NumberRedBits; + pGdiInfo->ulDACGreen = pVideoModeSelected->NumberGreenBits; + pGdiInfo->ulDACBlue = pVideoModeSelected->NumberBlueBits; + + pGdiInfo->ulAspectX = 0x24; // One-to-one aspect ratio + pGdiInfo->ulAspectY = 0x24; + pGdiInfo->ulAspectXY = 0x33; + + pGdiInfo->xStyleStep = 1; // A style unit is 3 pels + pGdiInfo->yStyleStep = 1; + pGdiInfo->denStyleStep = 3; + + pGdiInfo->ptlPhysOffset.x = 0; + pGdiInfo->ptlPhysOffset.y = 0; + pGdiInfo->szlPhysSize.cx = 0; + pGdiInfo->szlPhysSize.cy = 0; + + // RGB and CMY color info. + + // + // try to get it from the miniport. + // if the miniport doesn ot support this feature, use defaults. + // + + if (EngDeviceIoControl(ppdev->hDriver, + IOCTL_VIDEO_QUERY_COLOR_CAPABILITIES, + NULL, + 0, + &colorCapabilities, + sizeof(VIDEO_COLOR_CAPABILITIES), + &ulTemp)) + { + + DISPDBG((2, "getcolorCapabilities failed \n")); + + pGdiInfo->ciDevice.Red.x = 6700; + pGdiInfo->ciDevice.Red.y = 3300; + pGdiInfo->ciDevice.Red.Y = 0; + pGdiInfo->ciDevice.Green.x = 2100; + pGdiInfo->ciDevice.Green.y = 7100; + pGdiInfo->ciDevice.Green.Y = 0; + pGdiInfo->ciDevice.Blue.x = 1400; + pGdiInfo->ciDevice.Blue.y = 800; + pGdiInfo->ciDevice.Blue.Y = 0; + pGdiInfo->ciDevice.AlignmentWhite.x = 3127; + pGdiInfo->ciDevice.AlignmentWhite.y = 3290; + pGdiInfo->ciDevice.AlignmentWhite.Y = 0; + + pGdiInfo->ciDevice.RedGamma = 20000; + pGdiInfo->ciDevice.GreenGamma = 20000; + pGdiInfo->ciDevice.BlueGamma = 20000; + + } + else + { + pGdiInfo->ciDevice.Red.x = colorCapabilities.RedChromaticity_x; + pGdiInfo->ciDevice.Red.y = colorCapabilities.RedChromaticity_y; + pGdiInfo->ciDevice.Red.Y = 0; + pGdiInfo->ciDevice.Green.x = colorCapabilities.GreenChromaticity_x; + pGdiInfo->ciDevice.Green.y = colorCapabilities.GreenChromaticity_y; + pGdiInfo->ciDevice.Green.Y = 0; + pGdiInfo->ciDevice.Blue.x = colorCapabilities.BlueChromaticity_x; + pGdiInfo->ciDevice.Blue.y = colorCapabilities.BlueChromaticity_y; + pGdiInfo->ciDevice.Blue.Y = 0; + pGdiInfo->ciDevice.AlignmentWhite.x = colorCapabilities.WhiteChromaticity_x; + pGdiInfo->ciDevice.AlignmentWhite.y = colorCapabilities.WhiteChromaticity_y; + pGdiInfo->ciDevice.AlignmentWhite.Y = colorCapabilities.WhiteChromaticity_Y; + + // if we have a color device store the three color gamma values, + // otherwise store the unique gamma value in all three. + + if (colorCapabilities.AttributeFlags & VIDEO_DEVICE_COLOR) + { + pGdiInfo->ciDevice.RedGamma = colorCapabilities.RedGamma; + pGdiInfo->ciDevice.GreenGamma = colorCapabilities.GreenGamma; + pGdiInfo->ciDevice.BlueGamma = colorCapabilities.BlueGamma; + } + else + { + pGdiInfo->ciDevice.RedGamma = colorCapabilities.WhiteGamma; + pGdiInfo->ciDevice.GreenGamma = colorCapabilities.WhiteGamma; + pGdiInfo->ciDevice.BlueGamma = colorCapabilities.WhiteGamma; + } + + }; + + pGdiInfo->ciDevice.Cyan.x = 0; + pGdiInfo->ciDevice.Cyan.y = 0; + pGdiInfo->ciDevice.Cyan.Y = 0; + pGdiInfo->ciDevice.Magenta.x = 0; + pGdiInfo->ciDevice.Magenta.y = 0; + pGdiInfo->ciDevice.Magenta.Y = 0; + pGdiInfo->ciDevice.Yellow.x = 0; + pGdiInfo->ciDevice.Yellow.y = 0; + pGdiInfo->ciDevice.Yellow.Y = 0; + + // No dye correction for raster displays. + + pGdiInfo->ciDevice.MagentaInCyanDye = 0; + pGdiInfo->ciDevice.YellowInCyanDye = 0; + pGdiInfo->ciDevice.CyanInMagentaDye = 0; + pGdiInfo->ciDevice.YellowInMagentaDye = 0; + pGdiInfo->ciDevice.CyanInYellowDye = 0; + pGdiInfo->ciDevice.MagentaInYellowDye = 0; + + pGdiInfo->ulDevicePelsDPI = 0; // For printers only + pGdiInfo->ulPrimaryOrder = PRIMARY_ORDER_CBA; + + // BUGBUG this should be modified to take into account the size + // of the display and the resolution. + + pGdiInfo->ulHTPatternSize = HT_PATSIZE_4x4_M; + + pGdiInfo->flHTFlags = HT_FLAG_ADDITIVE_PRIMS; + + // Fill in the basic devinfo structure + + *pDevInfo = gDevInfoFrameBuffer; + + // Fill in the rest of the devinfo and GdiInfo structures. + + if (ppdev->ulBitCount == 8) + { + // It is Palette Managed. + + pGdiInfo->ulNumColors = 20; + pGdiInfo->ulNumPalReg = 1 << ppdev->ulBitCount; +// eVb: 2.7 [DDK CHANGE] - No dithering support + pDevInfo->flGraphicsCaps |= GCAPS_PALMANAGED; +// eVb: 2.7 [END] + pGdiInfo->ulHTOutputFormat = HT_FORMAT_8BPP; + pDevInfo->iDitherFormat = BMF_8BPP; + + // Assuming palette is orthogonal - all colors are same size. + + ppdev->cPaletteShift = 8 - pGdiInfo->ulDACRed; + } + else + { + pGdiInfo->ulNumColors = (ULONG) (-1); + pGdiInfo->ulNumPalReg = 0; + + if (ppdev->ulBitCount == 16) + { + pGdiInfo->ulHTOutputFormat = HT_FORMAT_16BPP; + pDevInfo->iDitherFormat = BMF_16BPP; + } + else if (ppdev->ulBitCount == 24) + { + pGdiInfo->ulHTOutputFormat = HT_FORMAT_24BPP; + pDevInfo->iDitherFormat = BMF_24BPP; + } + else + { + pGdiInfo->ulHTOutputFormat = HT_FORMAT_32BPP; + pDevInfo->iDitherFormat = BMF_32BPP; + } + } + + EngFreeMem(pVideoBuffer); + + return(TRUE); +} + + +/******************************Public*Routine******************************\ +* getAvailableModes +* +* Calls the miniport to get the list of modes supported by the kernel driver, +* and returns the list of modes supported by the diplay driver among those +* +* returns the number of entries in the videomode buffer. +* 0 means no modes are supported by the miniport or that an error occured. +* +* NOTE: the buffer must be freed up by the caller. +* +\**************************************************************************/ + +DWORD getAvailableModes( +HANDLE hDriver, +PVIDEO_MODE_INFORMATION *modeInformation, +DWORD *cbModeSize) +{ + ULONG ulTemp; + VIDEO_NUM_MODES modes; + PVIDEO_MODE_INFORMATION pVideoTemp; + + // + // Get the number of modes supported by the mini-port + // + + if (EngDeviceIoControl(hDriver, + IOCTL_VIDEO_QUERY_NUM_AVAIL_MODES, + NULL, + 0, + &modes, + sizeof(VIDEO_NUM_MODES), + &ulTemp)) + { + DISPDBG((0, "getAvailableModes failed VIDEO_QUERY_NUM_AVAIL_MODES\n")); + return(0); + } + + *cbModeSize = modes.ModeInformationLength; + + // + // Allocate the buffer for the mini-port to write the modes in. + // + + *modeInformation = (PVIDEO_MODE_INFORMATION) + EngAllocMem(0, modes.NumModes * + modes.ModeInformationLength, ALLOC_TAG); + + if (*modeInformation == (PVIDEO_MODE_INFORMATION) NULL) + { + DISPDBG((0, "getAvailableModes failed EngAllocMem\n")); + + return 0; + } + + // + // Ask the mini-port to fill in the available modes. + // + + if (EngDeviceIoControl(hDriver, + IOCTL_VIDEO_QUERY_AVAIL_MODES, + NULL, + 0, + *modeInformation, + modes.NumModes * modes.ModeInformationLength, + &ulTemp)) + { + + DISPDBG((0, "getAvailableModes failed VIDEO_QUERY_AVAIL_MODES\n")); + + EngFreeMem(*modeInformation); + *modeInformation = (PVIDEO_MODE_INFORMATION) NULL; + + return(0); + } + + // + // Now see which of these modes are supported by the display driver. + // As an internal mechanism, set the length to 0 for the modes we + // DO NOT support. + // + + ulTemp = modes.NumModes; + pVideoTemp = *modeInformation; + + // + // Mode is rejected if it is not one plane, or not graphics, or is not + // one of 8, 16 or 32 bits per pel. + // + + while (ulTemp--) + { + if ((pVideoTemp->NumberOfPlanes != 1 ) || + !(pVideoTemp->AttributeFlags & VIDEO_MODE_GRAPHICS) || +// eVb: 2.6 [DDK CHANGE] - Do not process banked video modes + (pVideoTemp->AttributeFlags & VIDEO_MODE_BANKED) || +// eVb: 2.6 [END] + ((pVideoTemp->BitsPerPlane != 8) && + (pVideoTemp->BitsPerPlane != 16) && + (pVideoTemp->BitsPerPlane != 24) && + (pVideoTemp->BitsPerPlane != 32))) + { + pVideoTemp->Length = 0; + } + + pVideoTemp = (PVIDEO_MODE_INFORMATION) + (((PUCHAR)pVideoTemp) + modes.ModeInformationLength); + } + + return modes.NumModes; + +} From bd41ac7ef94469bca15c05d7e2137cc8cf425374 Mon Sep 17 00:00:00 2001 From: evb Date: Tue, 14 Dec 2010 03:17:29 +0000 Subject: [PATCH 051/181] - Add the new vga miniport to build - Replace the framebuf_new spec rc rbuild with vga_new spec rc rbuild - Delete pointer.c - Start make changes, driver.h new fields for VGA, change driver short/long name/tag, add macros and in enable.c remove hw pointer support svn path=/trunk/; revision=50026 --- .../drivers/video/displays/directory.rbuild | 3 + .../drivers/video/displays/vga_new/debug.h | 4 +- .../drivers/video/displays/vga_new/driver.h | 37 +- .../drivers/video/displays/vga_new/enable.c | 8 + .../video/displays/vga_new/framebuf_new.rc | 5 - .../drivers/video/displays/vga_new/pointer.c | 455 ------------------ .../{framebuf_new.rbuild => vga_new.rbuild} | 9 +- .../drivers/video/displays/vga_new/vga_new.rc | 5 + .../{framebuf_new.spec => vga_new.spec} | 0 9 files changed, 56 insertions(+), 470 deletions(-) delete mode 100644 reactos/drivers/video/displays/vga_new/framebuf_new.rc delete mode 100755 reactos/drivers/video/displays/vga_new/pointer.c rename reactos/drivers/video/displays/vga_new/{framebuf_new.rbuild => vga_new.rbuild} (61%) create mode 100644 reactos/drivers/video/displays/vga_new/vga_new.rc rename reactos/drivers/video/displays/vga_new/{framebuf_new.spec => vga_new.spec} (100%) diff --git a/reactos/drivers/video/displays/directory.rbuild b/reactos/drivers/video/displays/directory.rbuild index 514fd432fd2..37342e84499 100644 --- a/reactos/drivers/video/displays/directory.rbuild +++ b/reactos/drivers/video/displays/directory.rbuild @@ -7,6 +7,9 @@ + + + diff --git a/reactos/drivers/video/displays/vga_new/debug.h b/reactos/drivers/video/displays/vga_new/debug.h index d73a223baaf..4a5764d4953 100755 --- a/reactos/drivers/video/displays/vga_new/debug.h +++ b/reactos/drivers/video/displays/vga_new/debug.h @@ -1,7 +1,7 @@ /* - * PROJECT: ReactOS Framebuffer Display Driver + * PROJECT: ReactOS VGA Display Driver * LICENSE: Microsoft NT4 DDK Sample Code License - * FILE: boot/drivers/video/displays/framebuf/debug.h + * FILE: boot/drivers/video/displays/vga/debug.h * PURPOSE: Debug Support Header * PROGRAMMERS: Copyright (c) 1992-1995 Microsoft Corporation */ diff --git a/reactos/drivers/video/displays/vga_new/driver.h b/reactos/drivers/video/displays/vga_new/driver.h index e9e617190c0..f060f17bed6 100755 --- a/reactos/drivers/video/displays/vga_new/driver.h +++ b/reactos/drivers/video/displays/vga_new/driver.h @@ -48,6 +48,10 @@ typedef struct _PDEV // eVb: 3.1 [DDK Change] - Support new VGA Miniport behavior w.r.t updated framebuffer remapping LONG flHooks; // eVb: 3.1 [END] +// eVb: 3.1 [VGARISC Change] - Add new fields for VGA support + SURFOBJ* pso; + UCHAR* pjBase; +// eVb: 3.1 [END] } PDEV, *PPDEV; DWORD getAvailableModes(HANDLE, PVIDEO_MODE_INFORMATION *, DWORD *); @@ -68,8 +72,35 @@ VOID vDisableSURF(PPDEV); #define DRIVER_EXTRA_SIZE 0 -#define DLL_NAME L"framebuf" // Name of the DLL in UNICODE -#define STANDARD_DEBUG_PREFIX "FRAMEBUF: " // All debug output is prefixed -#define ALLOC_TAG 'bfDD' // Four byte tag (characters in +// eVb: 3.2 [VGARISC Change] - Transform into VGA driver +#define DLL_NAME L"vga" // Name of the DLL in UNICODE +#define STANDARD_DEBUG_PREFIX "Vga risc: " // All debug output is prefixed +#define ALLOC_TAG 'rgvD' // Four byte tag (characters in // reverse order) used for memory // allocations +// eVb: 3.2 [END] + +// eVb: 3.3 [VGARISC Change] - Add new macros for VGA usage +// +// Each pixel in 4BPP being a nibble, the color data for that pixel is thus +// located at the xth bit within the nibble, where x is the plane number [0-3]. +// Each nibble being 4 bytes, the color data is thus at the (nibble * 4 + x). +// That color data is then taken from its linear position and shifted to the +// correct position within the 16-bit planar buffer word. +// +#define VAL(data, px, pl, pos) ((data) >> (((px) * 4) + (pl)) & 1) << (pos) + +// +// This figures out which pixel in the planar word data corresponds to which pixel +// in the 4BPP linear data. +// +#define SET_PLANE_DATA(x, y, a, b) \ + (x) |= VAL(y, (((-1 + ((((b) % 8) % 2) << 1) - (((b) % 8) + 1) + 8))), a, b) + +/* Alignment Macros */ +#define ALIGN_DOWN_BY(size, align) \ + ((ULONG_PTR)(size) & ~((ULONG_PTR)(align) - 1)) + +#define ALIGN_UP_BY(size, align) \ + (ALIGN_DOWN_BY(((ULONG_PTR)(size) + align - 1), align)) +// eVb: 3.3 [END] diff --git a/reactos/drivers/video/displays/vga_new/enable.c b/reactos/drivers/video/displays/vga_new/enable.c index 8031da8a173..4e232961504 100644 --- a/reactos/drivers/video/displays/vga_new/enable.c +++ b/reactos/drivers/video/displays/vga_new/enable.c @@ -20,8 +20,12 @@ static DRVFN gadrvfn[] = { INDEX_DrvDisableSurface, (PFN) DrvDisableSurface }, { INDEX_DrvAssertMode, (PFN) DrvAssertMode }, { INDEX_DrvSetPalette, (PFN) DrvSetPalette }, +// eVb: 1.1 [VGARISC Change] - Disable hardware pointer support +#if 0 { INDEX_DrvMovePointer, (PFN) DrvMovePointer }, { INDEX_DrvSetPointerShape, (PFN) DrvSetPointerShape }, +#endif +// eVb: 1.1 [END] { INDEX_DrvGetModes, (PFN) DrvGetModes } }; @@ -126,6 +130,8 @@ HANDLE hDriver) // Handle to base driver goto error_free; } +// eVb: 1.2 [VGARISC Change] - Disable hardware pointer support +#if 0 // Initialize the cursor information. if (!bInitPointer(ppdev, &DevInfo)) @@ -134,6 +140,8 @@ HANDLE hDriver) // Handle to base driver DISPDBG((0, "DrvEnablePDEV failed bInitPointer\n")); } +#endif +// eVb: 1.2 [END] // Initialize palette information. if (!bInitPaletteInfo(ppdev, &DevInfo)) diff --git a/reactos/drivers/video/displays/vga_new/framebuf_new.rc b/reactos/drivers/video/displays/vga_new/framebuf_new.rc deleted file mode 100644 index 98ba2627f11..00000000000 --- a/reactos/drivers/video/displays/vga_new/framebuf_new.rc +++ /dev/null @@ -1,5 +0,0 @@ -#define REACTOS_VERSION_DLL -#define REACTOS_STR_FILE_DESCRIPTION "Framebuffer Display Driver\0" -#define REACTOS_STR_INTERNAL_NAME "framebuf\0" -#define REACTOS_STR_ORIGINAL_FILENAME "framebuf.dll\0" -#include diff --git a/reactos/drivers/video/displays/vga_new/pointer.c b/reactos/drivers/video/displays/vga_new/pointer.c deleted file mode 100755 index d3752a2763c..00000000000 --- a/reactos/drivers/video/displays/vga_new/pointer.c +++ /dev/null @@ -1,455 +0,0 @@ -/* - * PROJECT: ReactOS Framebuffer Display Driver - * LICENSE: Microsoft NT4 DDK Sample Code License - * FILE: boot/drivers/video/displays/framebuf/pointer.c - * PURPOSE: Hardware Pointer Support - * PROGRAMMERS: Copyright (c) 1992-1995 Microsoft Corporation - */ - -#include "driver.h" - -BOOL bCopyColorPointer( -PPDEV ppdev, -SURFOBJ *psoMask, -SURFOBJ *psoColor, -XLATEOBJ *pxlo); - -BOOL bCopyMonoPointer( -PPDEV ppdev, -SURFOBJ *psoMask); - -BOOL bSetHardwarePointerShape( -SURFOBJ *pso, -SURFOBJ *psoMask, -SURFOBJ *psoColor, -XLATEOBJ *pxlo, -LONG x, -LONG y, -FLONG fl); - -/******************************Public*Routine******************************\ -* DrvMovePointer -* -* Moves the hardware pointer to a new position. -* -\**************************************************************************/ - -VOID DrvMovePointer -( - SURFOBJ *pso, - LONG x, - LONG y, - RECTL *prcl -) -{ - PPDEV ppdev = (PPDEV) pso->dhpdev; - DWORD returnedDataLength; - VIDEO_POINTER_POSITION NewPointerPosition; - - // We don't use the exclusion rectangle because we only support - // hardware Pointers. If we were doing our own Pointer simulations - // we would want to update prcl so that the engine would call us - // to exclude out pointer before drawing to the pixels in prcl. - - UNREFERENCED_PARAMETER(prcl); - - if (x == -1) - { - // - // A new position of (-1,-1) means hide the pointer. - // - - if (EngDeviceIoControl(ppdev->hDriver, - IOCTL_VIDEO_DISABLE_POINTER, - NULL, - 0, - NULL, - 0, - &returnedDataLength)) - { - // - // Not the end of the world, print warning in checked build. - // - - DISPDBG((1, "DISP vMoveHardwarePointer failed IOCTL_VIDEO_DISABLE_POINTER\n")); - } - } - else - { - NewPointerPosition.Column = (SHORT) x - (SHORT) (ppdev->ptlHotSpot.x); - NewPointerPosition.Row = (SHORT) y - (SHORT) (ppdev->ptlHotSpot.y); - - // - // Call miniport driver to move Pointer. - // - - if (EngDeviceIoControl(ppdev->hDriver, - IOCTL_VIDEO_SET_POINTER_POSITION, - &NewPointerPosition, - sizeof(VIDEO_POINTER_POSITION), - NULL, - 0, - &returnedDataLength)) - { - // - // Not the end of the world, print warning in checked build. - // - - DISPDBG((1, "DISP vMoveHardwarePointer failed IOCTL_VIDEO_SET_POINTER_POSITION\n")); - } - } -} - -/******************************Public*Routine******************************\ -* DrvSetPointerShape -* -* Sets the new pointer shape. -* -\**************************************************************************/ - -ULONG DrvSetPointerShape -( - SURFOBJ *pso, - SURFOBJ *psoMask, - SURFOBJ *psoColor, - XLATEOBJ *pxlo, - LONG xHot, - LONG yHot, - LONG x, - LONG y, - RECTL *prcl, - FLONG fl -) -{ - PPDEV ppdev = (PPDEV) pso->dhpdev; - DWORD returnedDataLength; - - // We don't use the exclusion rectangle because we only support - // hardware Pointers. If we were doing our own Pointer simulations - // we would want to update prcl so that the engine would call us - // to exclude out pointer before drawing to the pixels in prcl. - UNREFERENCED_PARAMETER(prcl); - - if (ppdev->pPointerAttributes == (PVIDEO_POINTER_ATTRIBUTES) NULL) - { - // Mini-port has no hardware Pointer support. - return(SPS_ERROR); - } - - // See if we are being asked to hide the pointer - - if (psoMask == (SURFOBJ *) NULL) - { - if (EngDeviceIoControl(ppdev->hDriver, - IOCTL_VIDEO_DISABLE_POINTER, - NULL, - 0, - NULL, - 0, - &returnedDataLength)) - { - // - // It should never be possible to fail. - // Message supplied for debugging. - // - - DISPDBG((1, "DISP bSetHardwarePointerShape failed IOCTL_VIDEO_DISABLE_POINTER\n")); - } - - return(TRUE); - } - - ppdev->ptlHotSpot.x = xHot; - ppdev->ptlHotSpot.y = yHot; - - if (!bSetHardwarePointerShape(pso,psoMask,psoColor,pxlo,x,y,fl)) - { - if (ppdev->fHwCursorActive) { - ppdev->fHwCursorActive = FALSE; - - if (EngDeviceIoControl(ppdev->hDriver, - IOCTL_VIDEO_DISABLE_POINTER, - NULL, - 0, - NULL, - 0, - &returnedDataLength)) { - - DISPDBG((1, "DISP bSetHardwarePointerShape failed IOCTL_VIDEO_DISABLE_POINTER\n")); - } - } - - // - // Mini-port declines to realize this Pointer - // - - return(SPS_DECLINE); - } - else - { - ppdev->fHwCursorActive = TRUE; - } - - return(SPS_ACCEPT_NOEXCLUDE); -} - -/******************************Public*Routine******************************\ -* bSetHardwarePointerShape -* -* Changes the shape of the Hardware Pointer. -* -* Returns: True if successful, False if Pointer shape can't be hardware. -* -\**************************************************************************/ - -BOOL bSetHardwarePointerShape( -SURFOBJ *pso, -SURFOBJ *psoMask, -SURFOBJ *psoColor, -XLATEOBJ *pxlo, -LONG x, -LONG y, -FLONG fl) -{ - PPDEV ppdev = (PPDEV) pso->dhpdev; - PVIDEO_POINTER_ATTRIBUTES pPointerAttributes = ppdev->pPointerAttributes; - DWORD returnedDataLength; - - if (psoColor != (SURFOBJ *) NULL) - { - if ((ppdev->PointerCapabilities.Flags & VIDEO_MODE_COLOR_POINTER) && - bCopyColorPointer(ppdev, psoMask, psoColor, pxlo)) - { - pPointerAttributes->Flags |= VIDEO_MODE_COLOR_POINTER; - } else { - return(FALSE); - } - - } else { - - if ((ppdev->PointerCapabilities.Flags & VIDEO_MODE_MONO_POINTER) && - bCopyMonoPointer(ppdev, psoMask)) - { - pPointerAttributes->Flags |= VIDEO_MODE_MONO_POINTER; - } else { - return(FALSE); - } - } - - // - // Initialize Pointer attributes and position - // - - pPointerAttributes->Enable = 1; - - // - // if x,y = -1,-1 then pass them directly to the miniport so that - // the cursor will be disabled - - pPointerAttributes->Column = (SHORT)(x); - pPointerAttributes->Row = (SHORT)(y); - - if ((x != -1) || (y != -1)) { - pPointerAttributes->Column -= (SHORT)(ppdev->ptlHotSpot.x); - pPointerAttributes->Row -= (SHORT)(ppdev->ptlHotSpot.y); - } - - // - // set animate flags - // - - if (fl & SPS_ANIMATESTART) { - pPointerAttributes->Flags |= VIDEO_MODE_ANIMATE_START; - } else if (fl & SPS_ANIMATEUPDATE) { - pPointerAttributes->Flags |= VIDEO_MODE_ANIMATE_UPDATE; - } - - // - // Set the new Pointer shape. - // - - if (EngDeviceIoControl(ppdev->hDriver, - IOCTL_VIDEO_SET_POINTER_ATTR, - pPointerAttributes, - ppdev->cjPointerAttributes, - NULL, - 0, - &returnedDataLength)) { - - DISPDBG((1, "DISP:Failed IOCTL_VIDEO_SET_POINTER_ATTR call\n")); - return(FALSE); - } - - return(TRUE); -} - -/******************************Public*Routine******************************\ -* bCopyMonoPointer -* -* Copies two monochrome masks into a buffer of the maximum size handled by the -* miniport, with any extra bits set to 0. The masks are converted to topdown -* form if they aren't already. Returns TRUE if we can handle this pointer in -* hardware, FALSE if not. -* -\**************************************************************************/ - -BOOL bCopyMonoPointer( - PPDEV ppdev, - SURFOBJ *pso) -{ - ULONG cy; - PBYTE pjSrcAnd, pjSrcXor; - LONG lDeltaSrc, lDeltaDst; - LONG lSrcWidthInBytes; - ULONG cxSrc = pso->sizlBitmap.cx; - ULONG cySrc = pso->sizlBitmap.cy; - ULONG cxSrcBytes; - PVIDEO_POINTER_ATTRIBUTES pPointerAttributes = ppdev->pPointerAttributes; - PBYTE pjDstAnd = pPointerAttributes->Pixels; - PBYTE pjDstXor = pPointerAttributes->Pixels; - - // Make sure the new pointer isn't too big to handle - // (*2 because both masks are in there) - if ((cxSrc > ppdev->PointerCapabilities.MaxWidth) || - (cySrc > (ppdev->PointerCapabilities.MaxHeight * 2))) - { - return(FALSE); - } - - pjDstXor += ((ppdev->PointerCapabilities.MaxWidth + 7) / 8) * - ppdev->pPointerAttributes->Height; - - // set the desk and mask to 0xff - RtlFillMemory(pjDstAnd, ppdev->pPointerAttributes->WidthInBytes * - ppdev->pPointerAttributes->Height, 0xFF); - - // Zero the dest XOR mask - RtlZeroMemory(pjDstXor, ppdev->pPointerAttributes->WidthInBytes * - ppdev->pPointerAttributes->Height); - - cxSrcBytes = (cxSrc + 7) / 8; - - if ((lDeltaSrc = pso->lDelta) < 0) - { - lSrcWidthInBytes = -lDeltaSrc; - } else { - lSrcWidthInBytes = lDeltaSrc; - } - - pjSrcAnd = (PBYTE) pso->pvBits; - - // If the incoming pointer bitmap is bottomup, we'll flip it to topdown to - // save the miniport some work - if (!(pso->fjBitmap & BMF_TOPDOWN)) - { - // Copy from the bottom - pjSrcAnd += lSrcWidthInBytes * (cySrc - 1); - } - - // Height of just AND mask - cySrc = cySrc / 2; - - // Point to XOR mask - pjSrcXor = pjSrcAnd + (cySrc * lDeltaSrc); - - // Offset from end of one dest scan to start of next - lDeltaDst = ppdev->pPointerAttributes->WidthInBytes; - - for (cy = 0; cy < cySrc; ++cy) - { - RtlCopyMemory(pjDstAnd, pjSrcAnd, cxSrcBytes); - RtlCopyMemory(pjDstXor, pjSrcXor, cxSrcBytes); - - // Point to next source and dest scans - pjSrcAnd += lDeltaSrc; - pjSrcXor += lDeltaSrc; - pjDstAnd += lDeltaDst; - pjDstXor += lDeltaDst; - } - - return(TRUE); -} - -/******************************Public*Routine******************************\ -* bCopyColorPointer -* -* Copies the mono and color masks into the buffer of maximum size -* handled by the miniport with any extra bits set to 0. Color translation -* is handled at this time. The masks are converted to topdown form if they -* aren't already. Returns TRUE if we can handle this pointer in hardware, -* FALSE if not. -* -\**************************************************************************/ -BOOL bCopyColorPointer( -PPDEV ppdev, -SURFOBJ *psoMask, -SURFOBJ *psoColor, -XLATEOBJ *pxlo) -{ - return(FALSE); -} - - -/******************************Public*Routine******************************\ -* bInitPointer -* -* Initialize the Pointer attributes. -* -\**************************************************************************/ - -BOOL bInitPointer(PPDEV ppdev, DEVINFO *pdevinfo) -{ - DWORD returnedDataLength; - - ppdev->pPointerAttributes = (PVIDEO_POINTER_ATTRIBUTES) NULL; - ppdev->cjPointerAttributes = 0; // initialized in screen.c - - // - // Ask the miniport whether it provides pointer support. - // - - if (EngDeviceIoControl(ppdev->hDriver, - IOCTL_VIDEO_QUERY_POINTER_CAPABILITIES, - &ppdev->ulMode, - sizeof(PVIDEO_MODE), - &ppdev->PointerCapabilities, - sizeof(ppdev->PointerCapabilities), - &returnedDataLength)) - { - return(FALSE); - } - - // - // If neither mono nor color hardware pointer is supported, there's no - // hardware pointer support and we're done. - // - - if ((!(ppdev->PointerCapabilities.Flags & VIDEO_MODE_MONO_POINTER)) && - (!(ppdev->PointerCapabilities.Flags & VIDEO_MODE_COLOR_POINTER))) - { - return(TRUE); - } - - // - // Note: The buffer itself is allocated after we set the - // mode. At that time we know the pixel depth and we can - // allocate the correct size for the color pointer if supported. - // - - // - // Set the asynchronous support status (async means miniport is capable of - // drawing the Pointer at any time, with no interference with any ongoing - // drawing operation) - // - - if (ppdev->PointerCapabilities.Flags & VIDEO_MODE_ASYNC_POINTER) - { - pdevinfo->flGraphicsCaps |= GCAPS_ASYNCMOVE; - } - else - { - pdevinfo->flGraphicsCaps &= ~GCAPS_ASYNCMOVE; - } - - return(TRUE); -} diff --git a/reactos/drivers/video/displays/vga_new/framebuf_new.rbuild b/reactos/drivers/video/displays/vga_new/vga_new.rbuild similarity index 61% rename from reactos/drivers/video/displays/vga_new/framebuf_new.rbuild rename to reactos/drivers/video/displays/vga_new/vga_new.rbuild index de7c4a1d3be..21f0e2deb73 100644 --- a/reactos/drivers/video/displays/vga_new/framebuf_new.rbuild +++ b/reactos/drivers/video/displays/vga_new/vga_new.rbuild @@ -1,15 +1,14 @@ - - - . + + + . win32k debug.c enable.c palette.c - pointer.c screen.c - framebuf_new.rc + vga_new.rc -mrtd diff --git a/reactos/drivers/video/displays/vga_new/vga_new.rc b/reactos/drivers/video/displays/vga_new/vga_new.rc new file mode 100644 index 00000000000..493bdb8a729 --- /dev/null +++ b/reactos/drivers/video/displays/vga_new/vga_new.rc @@ -0,0 +1,5 @@ +#define REACTOS_VERSION_DLL +#define REACTOS_STR_FILE_DESCRIPTION "VGA Display Driver\0" +#define REACTOS_STR_INTERNAL_NAME "vga\0" +#define REACTOS_STR_ORIGINAL_FILENAME "vga.dll\0" +#include diff --git a/reactos/drivers/video/displays/vga_new/framebuf_new.spec b/reactos/drivers/video/displays/vga_new/vga_new.spec similarity index 100% rename from reactos/drivers/video/displays/vga_new/framebuf_new.spec rename to reactos/drivers/video/displays/vga_new/vga_new.spec From 3b3c81807383e6b7fa7dc4a4e44a06bd79e977f0 Mon Sep 17 00:00:00 2001 From: evb Date: Tue, 14 Dec 2010 03:27:51 +0000 Subject: [PATCH 052/181] - fix now palette.c for vga, by copy logPalVGA/VGALOGPALETTE from NT4 DDK VGA sample drv and turn off codes for allocate 256 color pallette, instead use fix 16 color logPalVGA - fix header of debug.c svn path=/trunk/; revision=50027 --- .../drivers/video/displays/vga_new/debug.c | 4 +- .../drivers/video/displays/vga_new/palette.c | 75 +++++++++++++------ 2 files changed, 56 insertions(+), 23 deletions(-) diff --git a/reactos/drivers/video/displays/vga_new/debug.c b/reactos/drivers/video/displays/vga_new/debug.c index ada125df7ec..f41697bd5e4 100755 --- a/reactos/drivers/video/displays/vga_new/debug.c +++ b/reactos/drivers/video/displays/vga_new/debug.c @@ -1,7 +1,7 @@ /* - * PROJECT: ReactOS Framebuffer Display Driver + * PROJECT: ReactOS VGA Display Driver * LICENSE: Microsoft NT4 DDK Sample Code License - * FILE: boot/drivers/video/displays/framebuf/debug.c + * FILE: boot/drivers/video/displays/vga/debug.c * PURPOSE: Debug Support * PROGRAMMERS: Copyright (c) 1992-1995 Microsoft Corporation */ diff --git a/reactos/drivers/video/displays/vga_new/palette.c b/reactos/drivers/video/displays/vga_new/palette.c index c8cff990e2b..95aa06d875c 100755 --- a/reactos/drivers/video/displays/vga_new/palette.c +++ b/reactos/drivers/video/displays/vga_new/palette.c @@ -1,18 +1,36 @@ /* * PROJECT: ReactOS Framebuffer Display Driver * LICENSE: Microsoft NT4 DDK Sample Code License - * FILE: boot/drivers/video/displays/framebuf/palette.c + * FILE: boot/drivers/video/displays/vga/palette.c * PURPOSE: Palette Support * PROGRAMMERS: Copyright (c) 1992-1995 Microsoft Corporation */ #include "driver.h" -// Global Table defining the 20 Window Default Colors. For 256 color -// palettes the first 10 must be put at the beginning of the palette -// and the last 10 at the end of the palette. +// eVb: 4.1 [VGARISC Change] - Add static 16-color VGA palette from VGA NT4 DDK Sample -const PALETTEENTRY BASEPALETTE[20] = +/******************************Public*Data*Struct*************************\ +* LOGPALETTE +* +* This is the palette for the VGA. +* +\**************************************************************************/ + +// Little bit of hacking to get this to compile happily. + +typedef struct _VGALOGPALETTE +{ + USHORT ident; + USHORT NumEntries; + PALETTEENTRY palPalEntry[16]; +} VGALOGPALETTE; + +const VGALOGPALETTE logPalVGA = +{ + +0x400, // driver version +16, // num entries { { 0, 0, 0, 0 }, // 0 { 0x80,0, 0, 0 }, // 1 @@ -21,20 +39,19 @@ const PALETTEENTRY BASEPALETTE[20] = { 0, 0, 0x80,0 }, // 4 { 0x80,0, 0x80,0 }, // 5 { 0, 0x80,0x80,0 }, // 6 - { 0xC0,0xC0,0xC0,0 }, // 7 - { 192, 220, 192, 0 }, // 8 - { 166, 202, 240, 0 }, // 9 - { 255, 251, 240, 0 }, // 10 - { 160, 160, 164, 0 }, // 11 - { 0x80,0x80,0x80,0 }, // 12 - { 0xFF,0, 0 ,0 }, // 13 - { 0, 0xFF,0 ,0 }, // 14 - { 0xFF,0xFF,0 ,0 }, // 15 - { 0 ,0, 0xFF,0 }, // 16 - { 0xFF,0, 0xFF,0 }, // 17 - { 0, 0xFF,0xFF,0 }, // 18 - { 0xFF,0xFF,0xFF,0 }, // 19 + { 0x80,0x80,0x80,0 }, // 7 + + { 0xC0,0xC0,0xC0,0 }, // 8 + { 0xFF,0, 0, 0 }, // 9 + { 0, 0xFF,0, 0 }, // 10 + { 0xFF,0xFF,0, 0 }, // 11 + { 0, 0, 0xFF,0 }, // 12 + { 0xFF,0, 0xFF,0 }, // 13 + { 0, 0xFF,0xFF,0 }, // 14 + { 0xFF,0xFF,0xFF,0 } // 15 +} }; +// eVb: 4.1 [END] BOOL bInitDefaultPalette(PPDEV ppdev, DEVINFO *pDevInfo); @@ -72,8 +89,12 @@ VOID vDisablePalette(PPDEV ppdev) ppdev->hpalDefault = (HPALETTE) 0; } +// eVb: 4.2 [VGARISC Change] - VGA Palette is static, no need to free +#if 0 if (ppdev->pPal != (PPALETTEENTRY)NULL) EngFreeMem((PVOID)ppdev->pPal); +#endif +// eVb: 4.2 [END] } /******************************Public*Routine******************************\ @@ -85,6 +106,8 @@ VOID vDisablePalette(PPDEV ppdev) BOOL bInitDefaultPalette(PPDEV ppdev, DEVINFO *pDevInfo) { +// eVb: 4.3 [VGARISC Change] - VGA Palette is static, no need to build +#if 0 if (ppdev->ulBitCount == 8) { ULONG ulLoop; @@ -141,20 +164,26 @@ BOOL bInitDefaultPalette(PPDEV ppdev, DEVINFO *pDevInfo) ppdev->pPal[246 + ulLoop] = BASEPALETTE[ulLoop+10]; } +#endif +// eVb: 4.3 [END] // // Create handle for palette. // ppdev->hpalDefault = pDevInfo->hpalDefault = EngCreatePalette(PAL_INDEXED, - 256, - (PULONG) ppdev->pPal, +// eVb: 4.4 [VGARISC Change] - VGA Palette is 16 colors, not 256, and static + 16, + (PULONG) &logPalVGA.palPalEntry, +// eVb: 4.4 [END] 0,0,0); if (ppdev->hpalDefault == (HPALETTE) 0) { RIP("DISP bInitDefaultPalette failed EngCreatePalette\n"); - EngFreeMem(ppdev->pPal); +// eVb: 4.5 [VGARISC Change] - VGA Palette is static, no need to free + //EngFreeMem(ppdev->pPal); +// eVb: 4.5 [END] return(FALSE); } @@ -164,6 +193,8 @@ BOOL bInitDefaultPalette(PPDEV ppdev, DEVINFO *pDevInfo) return(TRUE); +// eVb: 4.6 [VGARISC Change] - VGA Palette is static, no bitfield palette needed +#if 0 } else { ppdev->hpalDefault = @@ -181,6 +212,8 @@ BOOL bInitDefaultPalette(PPDEV ppdev, DEVINFO *pDevInfo) } return(TRUE); +#endif +// eVb: 4.6 [END] } /******************************Public*Routine******************************\ From 46ab421926af700c1c545e27773cbaec3cfe830e Mon Sep 17 00:00:00 2001 From: evb Date: Tue, 14 Dec 2010 03:52:00 +0000 Subject: [PATCH 053/181] - Finish make enable.c work full on vga, main change force 4BPP (disable other codes), create 4BPP bitmap surfobj, associate and lock - Easy part done, now hard part svn path=/trunk/; revision=50028 --- .../drivers/video/displays/vga_new/enable.c | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/reactos/drivers/video/displays/vga_new/enable.c b/reactos/drivers/video/displays/vga_new/enable.c index 4e232961504..cae6b37888f 100644 --- a/reactos/drivers/video/displays/vga_new/enable.c +++ b/reactos/drivers/video/displays/vga_new/enable.c @@ -19,7 +19,9 @@ static DRVFN gadrvfn[] = { INDEX_DrvEnableSurface, (PFN) DrvEnableSurface }, { INDEX_DrvDisableSurface, (PFN) DrvDisableSurface }, { INDEX_DrvAssertMode, (PFN) DrvAssertMode }, +// eVb: 1.2 [VGARISC Change] - Disable hardware palette support { INDEX_DrvSetPalette, (PFN) DrvSetPalette }, +// eVb: 1.2 [END] // eVb: 1.1 [VGARISC Change] - Disable hardware pointer support #if 0 { INDEX_DrvMovePointer, (PFN) DrvMovePointer }, @@ -227,6 +229,8 @@ DHPDEV dhpdev) sizl.cx = ppdev->cxScreen; sizl.cy = ppdev->cyScreen; +// eVb: 1.3 [VGARISC Change] - Disable dynamic palette and > 4BPP support +#if 0 if (ppdev->ulBitCount == 8) { if (!bInit256ColorPalette(ppdev)) { @@ -254,6 +258,10 @@ DHPDEV dhpdev) // eVb: 1.3 [DDK Change] - Support new VGA Miniport behavior w.r.t updated framebuffer remapping ppdev->flHooks = flHooks; // eVb: 1.3 [END] +#else + ulBitmapType = BMF_4BPP; +#endif +// eVb: 1.3 [END] // eVb: 1.4 [DDK Change] - Use EngCreateDeviceSurface instead of EngCreateBitmap hsurf = (HSURF)EngCreateDeviceSurface((DHSURF)ppdev, sizl, @@ -281,7 +289,35 @@ DHPDEV dhpdev) } // eVb: 1.5 [END] ppdev->hsurfEng = hsurf; +// eVb: 1.4 [VGARISC Change] - Allocate 4BPP DIB that will store GDI drawing + HSURF hSurfBitmap; + hSurfBitmap = (HSURF)EngCreateBitmap(sizl, 0, ulBitmapType, 0, NULL); + if (hSurfBitmap == (HSURF) 0) + { + RIP("DISP DrvEnableSurface failed EngCreateBitmap\n"); + return(FALSE); + } + if ( !EngModifySurface(hSurfBitmap, + ppdev->hdevEng, + ppdev->flHooks | HOOK_SYNCHRONIZE, + MS_NOTSYSTEMMEMORY, + (DHSURF)ppdev, + ppdev->pjScreen, + ppdev->lDeltaScreen, + NULL)) + { + RIP("DISP DrvEnableSurface failed second EngModifySurface\n"); + return(FALSE); + } + + ppdev->pso = EngLockSurface(hSurfBitmap); + if (ppdev->pso == NULL) + { + RIP("DISP DrvEnableSurface failed EngLockSurface\n"); + return(FALSE); + } +// eVb: 1.4 [END] return(hsurf); } From 2138d6d79442ce3607474ecf2e276ec0b500edf1 Mon Sep 17 00:00:00 2001 From: evb Date: Tue, 14 Dec 2010 04:10:14 +0000 Subject: [PATCH 054/181] - Mode detect look for 4BPP, planar, graphics < 0x800 mode now - Add GDIINFO from NT4 VGA DDK sample driver - Set 4BPP prefer DIB format - No graphics caps set for VGA driver - Put static palette/color buffer for when VGA IOCTL send later - Convert almost done, bInitSURF is last svn path=/trunk/; revision=50029 --- .../drivers/video/displays/vga_new/screen.c | 167 ++++++++++++++++-- 1 file changed, 153 insertions(+), 14 deletions(-) diff --git a/reactos/drivers/video/displays/vga_new/screen.c b/reactos/drivers/video/displays/vga_new/screen.c index 7ea4443c323..faf6aaa2313 100755 --- a/reactos/drivers/video/displays/vga_new/screen.c +++ b/reactos/drivers/video/displays/vga_new/screen.c @@ -16,7 +16,9 @@ // on information passed back from the miniport driver. const DEVINFO gDevInfoFrameBuffer = { - ( GCAPS_OPAQUERECT +// eVb: 2.1 [VGARISC CHANGE] - No capabilities + ( 0 +// eVb: 2.1 [END] // eVb: 2.8 [DDK CHANGE] - No dithering support // eVb: 2.8 [END] ), /* Graphics capabilities */ @@ -24,7 +26,9 @@ const DEVINFO gDevInfoFrameBuffer = { HELVE_LOGFONT, /* ANSI variable font description */ COURI_LOGFONT, /* ANSI fixed font description */ 0, /* Count of device fonts */ - 0, /* Preferred DIB format */ +// eVb: 2.2 [VGARISC CHANGE] - DIB format is 4BPP + BMF_4BPP, /* Preferred DIB format */ +// eVb: 2.2 [END] // eVb: 2.9 [DDK CHANGE] - No dithering support 0, /* Width of color dither */ 0, /* Height of color dither */ @@ -32,6 +36,127 @@ const DEVINFO gDevInfoFrameBuffer = { 0 /* Default palette to use for this device */ }; +// eVb: 2.3 [VGARISC CHANGE] - Add VGA structures from NT4 DDK Sample VGA driver +/******************************Public*Data*Struct*************************\ +* This contains the GDIINFO structure that contains the device capabilities +* which are passed to the NT GDI engine during dhpdevEnablePDEV. +* +\**************************************************************************/ + +GDIINFO gaulCap = { + + GDI_DRIVER_VERSION, + DT_RASDISPLAY, // ulTechnology + 0, // ulHorzSize + 0, // ulVertSize + 0, // ulHorzRes (filled in at initialization) + 0, // ulVertRes (filled in at initialization) + 4, // cBitsPixel + 1, // cPlanes + 16, // ulNumColors + 0, // flRaster (DDI reserved field) + + 0, // ulLogPixelsX (filled in at initialization) + 0, // ulLogPixelsY (filled in at initialization) + + TC_RA_ABLE | TC_SCROLLBLT, // flTextCaps + + 6, // ulDACRed + 6, // ulDACGree + 6, // ulDACBlue + + 0x0024, // ulAspectX (one-to-one aspect ratio) + 0x0024, // ulAspectY + 0x0033, // ulAspectXY + + 1, // xStyleStep + 1, // yStyleSte; + 3, // denStyleStep + + { 0, 0 }, // ptlPhysOffset + { 0, 0 }, // szlPhysSize + + 0, // ulNumPalReg (win3.1 16 color drivers say 0 too) + +// These fields are for halftone initialization. + + { // ciDevice, ColorInfo + { 6700, 3300, 0 }, // Red + { 2100, 7100, 0 }, // Green + { 1400, 800, 0 }, // Blue + { 1750, 3950, 0 }, // Cyan + { 4050, 2050, 0 }, // Magenta + { 4400, 5200, 0 }, // Yellow + { 3127, 3290, 0 }, // AlignmentWhite + 20000, // RedGamma + 20000, // GreenGamma + 20000, // BlueGamma + 0, 0, 0, 0, 0, 0 + }, + + 0, // ulDevicePelsDPI (filled in at initialization) + PRIMARY_ORDER_CBA, // ulPrimaryOrder + HT_PATSIZE_4x4_M, // ulHTPatternSize + HT_FORMAT_4BPP_IRGB, // ulHTOutputFormat + HT_FLAG_ADDITIVE_PRIMS, // flHTFlags + + 0, // ulVRefresh +// eVb: 2.4 [VGARISC DDK CHANGE] - Use 1 bit alignment, not 8 + 1, // ulBltAlignment (preferred window alignment +// eVb: 2.4 [END] + // for fast-text routines) + 0, // ulPanningHorzRes + 0, // ulPanningVertRes +}; + +/******************************Module*Header*******************************\ +* Color tables +\**************************************************************************/ + +// Values for the internal, EGA-compatible palette. + +static WORD PaletteBuffer[] = { + + 16, // 16 entries + 0, // start with first palette register + +// On the VGA, the palette contains indices into the array of color DACs. +// Since we can program the DACs as we please, we'll just put all the indices +// down at the beginning of the DAC array (that is, pass pixel values through +// the internal palette unchanged). + + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 +}; + + +// These are the values for the first 16 DAC registers, the only ones we'll +// work with. These correspond to the RGB colors (6 bits for each primary, with +// the fourth entry unused) for pixel values 0-15. + +static BYTE ColorBuffer[] = { + + 16, // 16 entries + 0, + 0, + 0, // start with first palette register + 0x00, 0x00, 0x00, 0x00, // black + 0x2A, 0x00, 0x15, 0x00, // red + 0x00, 0x2A, 0x15, 0x00, // green + 0x2A, 0x2A, 0x15, 0x00, // mustard/brown + 0x00, 0x00, 0x2A, 0x00, // blue + 0x2A, 0x15, 0x2A, 0x00, // magenta + 0x15, 0x2A, 0x2A, 0x00, // ScanLinesan + 0x21, 0x22, 0x23, 0x00, // dark gray 2A + 0x30, 0x31, 0x32, 0x00, // light gray 39 + 0x3F, 0x00, 0x00, 0x00, // bright red + 0x00, 0x3F, 0x00, 0x00, // bright green + 0x3F, 0x3F, 0x00, 0x00, // bright yellow + 0x00, 0x00, 0x3F, 0x00, // bright blue + 0x3F, 0x00, 0x3F, 0x00, // bright magenta + 0x00, 0x3F, 0x3F, 0x00, // bright ScanLinesan + 0x3F, 0x3F, 0x3F, 0x00 // bright white +}; +// eVb: 2.3 [END] /******************************Public*Routine******************************\ * bInitSURF * @@ -288,13 +413,18 @@ DEVINFO *pDevInfo) ppdev->ulMode = pVideoModeSelected->ModeIndex; ppdev->cxScreen = pVideoModeSelected->VisScreenWidth; ppdev->cyScreen = pVideoModeSelected->VisScreenHeight; + ppdev->lDeltaScreen = pVideoModeSelected->ScreenStride; +// eVb: 2.8 [VGARISC CHANGE] - Extra fields not required on VGA, start with defaults +#if 0 ppdev->ulBitCount = pVideoModeSelected->BitsPerPlane * pVideoModeSelected->NumberOfPlanes; - ppdev->lDeltaScreen = pVideoModeSelected->ScreenStride; - ppdev->flRed = pVideoModeSelected->RedMask; ppdev->flGreen = pVideoModeSelected->GreenMask; ppdev->flBlue = pVideoModeSelected->BlueMask; +#else + *pGdiInfo = gaulCap; +#endif +// eVb: 2.8 [END] pGdiInfo->ulVersion = GDI_DRIVER_VERSION; @@ -316,6 +446,8 @@ DEVINFO *pDevInfo) pGdiInfo->ulLogPixelsX = pDevMode->dmLogPixels; pGdiInfo->ulLogPixelsY = pDevMode->dmLogPixels; +// eVb: 2.9 [VGARISC CHANGE] - Extra fields not required on VGA +#if 0 #ifdef MIPS if (ppdev->ulBitCount == 8) pGdiInfo->flTextCaps = (TC_RA_ABLE | TC_SCROLLBLT); @@ -324,11 +456,15 @@ DEVINFO *pDevInfo) pGdiInfo->flTextCaps = TC_RA_ABLE; pGdiInfo->flRaster = 0; // flRaster is reserved by DDI +#endif +// eVb: 2.9 [END] pGdiInfo->ulDACRed = pVideoModeSelected->NumberRedBits; pGdiInfo->ulDACGreen = pVideoModeSelected->NumberGreenBits; pGdiInfo->ulDACBlue = pVideoModeSelected->NumberBlueBits; +// eVb: 2.7 [VGARISC CHANGE] - Extra fields not required on VGA +#if 0 pGdiInfo->ulAspectX = 0x24; // One-to-one aspect ratio pGdiInfo->ulAspectY = 0x24; pGdiInfo->ulAspectXY = 0x33; @@ -439,11 +575,15 @@ DEVINFO *pDevInfo) pGdiInfo->ulHTPatternSize = HT_PATSIZE_4x4_M; pGdiInfo->flHTFlags = HT_FLAG_ADDITIVE_PRIMS; +// eVb: 2.7 [END] +#endif // Fill in the basic devinfo structure *pDevInfo = gDevInfoFrameBuffer; +// eVb: 2.6 [VGARISC CHANGE] - Use defaults in gaulCap for GDI Info +#if 0 // Fill in the rest of the devinfo and GdiInfo structures. if (ppdev->ulBitCount == 8) @@ -483,6 +623,8 @@ DEVINFO *pDevInfo) pDevInfo->iDitherFormat = BMF_32BPP; } } +#endif +// eVb: 2.6 [END] EngFreeMem(pVideoBuffer); @@ -575,22 +717,19 @@ DWORD *cbModeSize) ulTemp = modes.NumModes; pVideoTemp = *modeInformation; +// eVb: 2.5 [VGARISC CHANGE] - Add correct mode checks for VGA // - // Mode is rejected if it is not one plane, or not graphics, or is not - // one of 8, 16 or 32 bits per pel. + // Mode is rejected if it is not 4 planes, or not graphics, or is not + // one of 1 bits per pel. // while (ulTemp--) { - if ((pVideoTemp->NumberOfPlanes != 1 ) || + if ((pVideoTemp->NumberOfPlanes != 4 ) || !(pVideoTemp->AttributeFlags & VIDEO_MODE_GRAPHICS) || -// eVb: 2.6 [DDK CHANGE] - Do not process banked video modes - (pVideoTemp->AttributeFlags & VIDEO_MODE_BANKED) || -// eVb: 2.6 [END] - ((pVideoTemp->BitsPerPlane != 8) && - (pVideoTemp->BitsPerPlane != 16) && - (pVideoTemp->BitsPerPlane != 24) && - (pVideoTemp->BitsPerPlane != 32))) + ((pVideoTemp->BitsPerPlane != 1) || + (pVideoTemp->VisScreenWidth > 800))) +// eVb: 2.5 [END] { pVideoTemp->Length = 0; } From ca9039c50ecd2db16eaebbc9a862ddd3f2ee39ed Mon Sep 17 00:00:00 2001 From: Giannis Adamopoulos Date: Wed, 15 Dec 2010 19:21:48 +0000 Subject: [PATCH 055/181] [win32k] - Use the new version of NtUserGetMessage and NtUserPeekMessage written by Jim. It is possible to use them now because GetMessage and PeekMessage don't return messages that contain pointers. As a result they don't need to do any extra work to copy the message to user mode. All messages that contain pointers are sent messages and this means that they don't get into the message loop. Instead they are passed directly to the window proc. - DispatchMessage works only if the target window belongs to the current thread. This lets us remove uneeded copies of lparam to user mode. [user32] - Remove a bunch of uneeded code in GetMessage and PeekMessage that copyied the lparam in a new buffer and did unicode to ansi convertions. It is not needed because they don't receive messages with pointers any more svn path=/trunk/; revision=50030 --- reactos/dll/win32/user32/windows/message.c | 234 ++---------------- reactos/include/reactos/win32k/ntuser.h | 32 +-- .../subsystems/win32/win32k/ntuser/message.c | 227 +---------------- 3 files changed, 40 insertions(+), 453 deletions(-) diff --git a/reactos/dll/win32/user32/windows/message.c b/reactos/dll/win32/user32/windows/message.c index c0b2813d8f5..3b8ce7e9843 100644 --- a/reactos/dll/win32/user32/windows/message.c +++ b/reactos/dll/win32/user32/windows/message.c @@ -931,121 +931,6 @@ MsgiUnicodeToAnsiReply(LPMSG AnsiMsg, LPMSG UnicodeMsg, LRESULT *Result) return TRUE; } -typedef struct tagMSGCONVERSION -{ - BOOL InUse; - BOOL Ansi; - MSG KMMsg; - MSG UnicodeMsg; - MSG AnsiMsg; - PMSG FinalMsg; - SIZE_T LParamSize; -} MSGCONVERSION, *PMSGCONVERSION; - -static PMSGCONVERSION MsgConversions = NULL; -static unsigned MsgConversionNumAlloc = 0; -static unsigned MsgConversionNumUsed = 0; -static CRITICAL_SECTION MsgConversionCrst; - -static BOOL FASTCALL -MsgConversionAdd(PMSGCONVERSION Conversion) -{ - unsigned i; - - EnterCriticalSection(&MsgConversionCrst); - - if (MsgConversionNumUsed == MsgConversionNumAlloc) - { -#define GROWBY 4 - PMSGCONVERSION New; - if (NULL != MsgConversions) - { - New = HeapReAlloc(GetProcessHeap(), 0, MsgConversions, - (MsgConversionNumAlloc + GROWBY) * sizeof(MSGCONVERSION)); - } - else - { - New = HeapAlloc(GetProcessHeap(), 0, - (MsgConversionNumAlloc + GROWBY) * sizeof(MSGCONVERSION)); - } - - if (NULL == New) - { - LeaveCriticalSection(&MsgConversionCrst); - return FALSE; - } - MsgConversions = New; - /* zero out newly allocated part */ - memset(MsgConversions + MsgConversionNumAlloc, 0, GROWBY * sizeof(MSGCONVERSION)); - MsgConversionNumAlloc += GROWBY; -#undef GROWBY - } - - for (i = 0; i < MsgConversionNumAlloc; i++) - { - if (! MsgConversions[i].InUse) - { - MsgConversions[i] = *Conversion; - MsgConversions[i].InUse = TRUE; - MsgConversionNumUsed++; - break; - } - } - LeaveCriticalSection(&MsgConversionCrst); - - return TRUE; -} - -static void FASTCALL -MsgConversionCleanup(CONST MSG *Msg, BOOL Ansi, BOOL CheckMsgContents, LRESULT *Result) -{ - BOOL Found; - PMSGCONVERSION Conversion; - LRESULT Dummy; - - EnterCriticalSection(&MsgConversionCrst); - for (Conversion = MsgConversions; - Conversion < MsgConversions + MsgConversionNumAlloc; - Conversion++) - { - if (Conversion->InUse && - ((Ansi && Conversion->Ansi) || - (! Ansi && ! Conversion->Ansi))) - { - Found = (Conversion->FinalMsg == Msg); - if (! Found && CheckMsgContents) - { - if (Ansi) - { - Found = (0 == memcmp(Msg, &Conversion->AnsiMsg, sizeof(MSG))); - } - else - { - Found = (0 == memcmp(Msg, &Conversion->UnicodeMsg, sizeof(MSG))); - } - } - if (Found) - { - if (Ansi) - { - MsgiUnicodeToAnsiReply(&Conversion->AnsiMsg, &Conversion->UnicodeMsg, - NULL == Result ? &Dummy : Result); - } - MsgiKMToUMReply(&Conversion->KMMsg, &Conversion->UnicodeMsg, - NULL == Result ? &Dummy : Result); - if (0 != Conversion->LParamSize) - { - NtFreeVirtualMemory(NtCurrentProcess(), (PVOID *) &Conversion->KMMsg.lParam, - &Conversion->LParamSize, MEM_DECOMMIT); - } - Conversion->InUse = FALSE; - MsgConversionNumUsed--; - } - } - } - LeaveCriticalSection(&MsgConversionCrst); -} - /* * @implemented */ @@ -1712,51 +1597,27 @@ DispatchMessageW(CONST MSG *lpmsg) */ BOOL WINAPI GetMessageA(LPMSG lpMsg, - HWND hWnd, - UINT wMsgFilterMin, - UINT wMsgFilterMax) + HWND hWnd, + UINT wMsgFilterMin, + UINT wMsgFilterMax) { BOOL Res; - MSGCONVERSION Conversion; - NTUSERGETMESSAGEINFO Info; PUSER32_THREAD_DATA ThreadData = User32GetThreadData(); - MsgConversionCleanup(lpMsg, TRUE, FALSE, NULL); - Res = NtUserGetMessage(&Info, hWnd, wMsgFilterMin, wMsgFilterMax); + Res = NtUserGetMessage(lpMsg, hWnd, wMsgFilterMin, wMsgFilterMax); if (-1 == (int) Res) { return Res; } - Conversion.LParamSize = Info.LParamSize; - Conversion.KMMsg = Info.Msg; - if (! MsgiKMToUMMessage(&Conversion.KMMsg, &Conversion.UnicodeMsg)) - { - return (BOOL) -1; - } - if (! MsgiUnicodeToAnsiMessage(&Conversion.AnsiMsg, &Conversion.UnicodeMsg)) - { - MsgiKMToUMCleanup(&Info.Msg, &Conversion.UnicodeMsg); - return (BOOL) -1; - } - if (!lpMsg) - { - SetLastError( ERROR_NOACCESS ); - return FALSE; - } - *lpMsg = Conversion.AnsiMsg; - Conversion.Ansi = TRUE; - Conversion.FinalMsg = lpMsg; - MsgConversionAdd(&Conversion); if (Res && lpMsg->message != WM_PAINT && lpMsg->message != WM_QUIT) { - ThreadData->LastMessage = Info.Msg; + ThreadData->LastMessage = *lpMsg; } return Res; } - /* * @implemented */ @@ -1767,46 +1628,28 @@ GetMessageW(LPMSG lpMsg, UINT wMsgFilterMax) { BOOL Res; - MSGCONVERSION Conversion; - NTUSERGETMESSAGEINFO Info; PUSER32_THREAD_DATA ThreadData = User32GetThreadData(); - MsgConversionCleanup(lpMsg, FALSE, FALSE, NULL); - Res = NtUserGetMessage(&Info, hWnd, wMsgFilterMin, wMsgFilterMax); + Res = NtUserGetMessage(lpMsg, hWnd, wMsgFilterMin, wMsgFilterMax); if (-1 == (int) Res) { return Res; } - Conversion.LParamSize = Info.LParamSize; - Conversion.KMMsg = Info.Msg; - if (! MsgiKMToUMMessage(&Conversion.KMMsg, &Conversion.UnicodeMsg)) - { - return (BOOL) -1; - } - if (!lpMsg) - { - SetLastError( ERROR_NOACCESS ); - return FALSE; - } - *lpMsg = Conversion.UnicodeMsg; - Conversion.Ansi = FALSE; - Conversion.FinalMsg = lpMsg; - MsgConversionAdd(&Conversion); if (Res && lpMsg->message != WM_PAINT && lpMsg->message != WM_QUIT) { - ThreadData->LastMessage = Info.Msg; + ThreadData->LastMessage = *lpMsg; } return Res; } BOOL WINAPI -PeekMessageWorker(PNTUSERGETMESSAGEINFO pInfo, - HWND hWnd, - UINT wMsgFilterMin, - UINT wMsgFilterMax, - UINT wRemoveMsg) +PeekMessageWorker(PMSG pMsg, + HWND hWnd, + UINT wMsgFilterMin, + UINT wMsgFilterMax, + UINT wRemoveMsg) { PCLIENTINFO pci; PCLIENTTHREADINFO pcti; @@ -1835,7 +1678,7 @@ PeekMessageWorker(PNTUSERGETMESSAGEINFO pInfo, } } } - return NtUserPeekMessage(pInfo, hWnd, wMsgFilterMin, wMsgFilterMax, wRemoveMsg); + return NtUserPeekMessage(pMsg, hWnd, wMsgFilterMin, wMsgFilterMax, wRemoveMsg); } /* @@ -1849,40 +1692,17 @@ PeekMessageA(LPMSG lpMsg, UINT wRemoveMsg) { BOOL Res; - MSGCONVERSION Conversion; - NTUSERGETMESSAGEINFO Info; PUSER32_THREAD_DATA ThreadData = User32GetThreadData(); - MsgConversionCleanup(lpMsg, TRUE, FALSE, NULL); - Res = PeekMessageWorker(&Info, hWnd, wMsgFilterMin, wMsgFilterMax, wRemoveMsg); + Res = PeekMessageWorker(lpMsg, hWnd, wMsgFilterMin, wMsgFilterMax, wRemoveMsg); if (-1 == (int) Res || !Res) { return FALSE; } - Conversion.LParamSize = Info.LParamSize; - Conversion.KMMsg = Info.Msg; - if (! MsgiKMToUMMessage(&Conversion.KMMsg, &Conversion.UnicodeMsg)) - { - return FALSE; - } - if (! MsgiUnicodeToAnsiMessage(&Conversion.AnsiMsg, &Conversion.UnicodeMsg)) - { - MsgiKMToUMCleanup(&Info.Msg, &Conversion.UnicodeMsg); - return FALSE; - } - if (!lpMsg) - { - SetLastError( ERROR_NOACCESS ); - return FALSE; - } - *lpMsg = Conversion.AnsiMsg; - Conversion.Ansi = TRUE; - Conversion.FinalMsg = lpMsg; - MsgConversionAdd(&Conversion); if (Res && lpMsg->message != WM_PAINT && lpMsg->message != WM_QUIT) { - ThreadData->LastMessage = Info.Msg; + ThreadData->LastMessage = *lpMsg; } return Res; @@ -1902,35 +1722,17 @@ PeekMessageW( UINT wRemoveMsg) { BOOL Res; - MSGCONVERSION Conversion; - NTUSERGETMESSAGEINFO Info; PUSER32_THREAD_DATA ThreadData = User32GetThreadData(); - MsgConversionCleanup(lpMsg, FALSE, FALSE, NULL); - Res = PeekMessageWorker(&Info, hWnd, wMsgFilterMin, wMsgFilterMax, wRemoveMsg); + Res = PeekMessageWorker(lpMsg, hWnd, wMsgFilterMin, wMsgFilterMax, wRemoveMsg); if (-1 == (int) Res || !Res) { return FALSE; } - Conversion.LParamSize = Info.LParamSize; - Conversion.KMMsg = Info.Msg; - if (! MsgiKMToUMMessage(&Conversion.KMMsg, &Conversion.UnicodeMsg)) - { - return FALSE; - } - if (!lpMsg) - { - SetLastError( ERROR_NOACCESS ); - return FALSE; - } - *lpMsg = Conversion.UnicodeMsg; - Conversion.Ansi = FALSE; - Conversion.FinalMsg = lpMsg; - MsgConversionAdd(&Conversion); if (Res && lpMsg->message != WM_PAINT && lpMsg->message != WM_QUIT) { - ThreadData->LastMessage = Info.Msg; + ThreadData->LastMessage = *lpMsg; } return Res; @@ -2878,7 +2680,6 @@ MsgWaitForMultipleObjects( BOOL FASTCALL MessageInit(VOID) { InitializeCriticalSection(&DdeCrst); - InitializeCriticalSection(&MsgConversionCrst); InitializeCriticalSection(&gcsMPH); return TRUE; @@ -2887,7 +2688,6 @@ BOOL FASTCALL MessageInit(VOID) VOID FASTCALL MessageCleanup(VOID) { DeleteCriticalSection(&DdeCrst); - DeleteCriticalSection(&MsgConversionCrst); DeleteCriticalSection(&gcsMPH); } diff --git a/reactos/include/reactos/win32k/ntuser.h b/reactos/include/reactos/win32k/ntuser.h index 936b4f87f58..674ab242db0 100644 --- a/reactos/include/reactos/win32k/ntuser.h +++ b/reactos/include/reactos/win32k/ntuser.h @@ -1996,19 +1996,11 @@ NTAPI NtUserGetListBoxInfo( HWND hWnd); -typedef struct tagNTUSERGETMESSAGEINFO -{ - MSG Msg; - ULONG LParamSize; -} NTUSERGETMESSAGEINFO, *PNTUSERGETMESSAGEINFO; - -BOOL -NTAPI -NtUserGetMessage( - PNTUSERGETMESSAGEINFO MsgInfo, - HWND hWnd, - UINT wMsgFilterMin, - UINT wMsgFilterMax); +BOOL APIENTRY +NtUserGetMessage(PMSG pMsg, + HWND hWnd, + UINT MsgFilterMin, + UINT MsgFilterMax); DWORD NTAPI @@ -2373,14 +2365,12 @@ NtUserPaintMenuBar( DWORD dwUnknown5, DWORD dwUnknown6); -BOOL -NTAPI -NtUserPeekMessage( - PNTUSERGETMESSAGEINFO MsgInfo, - HWND hWnd, - UINT wMsgFilterMin, - UINT wMsgFilterMax, - UINT wRemoveMsg); +BOOL APIENTRY +NtUserPeekMessage( PMSG pMsg, + HWND hWnd, + UINT MsgFilterMin, + UINT MsgFilterMax, + UINT RemoveMsg); BOOL NTAPI diff --git a/reactos/subsystems/win32/win32k/ntuser/message.c b/reactos/subsystems/win32/win32k/ntuser/message.c index ad8be3d5194..5dfcd924d1e 100644 --- a/reactos/subsystems/win32/win32k/ntuser/message.c +++ b/reactos/subsystems/win32/win32k/ntuser/message.c @@ -426,10 +426,7 @@ IntDispatchMessage(PMSG pMsg) LARGE_INTEGER TickCount; LONG Time; LRESULT retval = 0; - PMSGMEMORY MsgMemoryEntry; - INT lParamBufferSize; PTHREADINFO pti; - LPARAM lParamPacked; PWND Window = NULL; if (pMsg->hwnd) @@ -452,7 +449,6 @@ IntDispatchMessage(PMSG pMsg) { if (pMsg->message == WM_TIMER) { - ObReferenceObject(pti->pEThread); if (ValidateTimerCallback(pti,pMsg->lParam)) { KeQueryTickCount(&TickCount); @@ -463,9 +459,8 @@ IntDispatchMessage(PMSG pMsg) WM_TIMER, pMsg->wParam, (LPARAM)Time, - sizeof(LPARAM)); + 0); } - ObDereferenceObject(pti->pEThread); return retval; } else @@ -483,35 +478,17 @@ IntDispatchMessage(PMSG pMsg) // Need a window! if ( !Window ) return 0; - /* See if this message type is present in the table */ - MsgMemoryEntry = FindMsgMemory(pMsg->message); - if ( !MsgMemoryEntry ) - { - lParamBufferSize = -1; - } - else - { - lParamBufferSize = MsgMemorySize(MsgMemoryEntry, pMsg->wParam, pMsg->lParam); - } + /* Since we are doing a callback on the same thread right away, there is + no need to copy the lparam to kernel mode and then back to usermode. + We just pretend it isn't a pointer */ - if (! NT_SUCCESS(PackParam(&lParamPacked, pMsg->message, pMsg->wParam, pMsg->lParam, FALSE))) - { - DPRINT1("Failed to pack message parameters\n"); - return 0; - } - ObReferenceObject(pti->pEThread); retval = co_IntCallWindowProc( Window->lpfnWndProc, !Window->Unicode, pMsg->hwnd, pMsg->message, pMsg->wParam, - lParamPacked, - lParamBufferSize); - - if (! NT_SUCCESS(UnpackParam(lParamPacked, pMsg->message, pMsg->wParam, pMsg->lParam, FALSE))) - { - DPRINT1("Failed to unpack message parameters\n"); - } + pMsg->lParam, + 0); if (pMsg->message == WM_PAINT) { @@ -520,7 +497,7 @@ IntDispatchMessage(PMSG pMsg) co_UserGetUpdateRgn( Window, hrgn, TRUE ); REGION_FreeRgnByHandle( hrgn ); } - ObDereferenceObject(pti->pEThread); + return retval; } @@ -868,6 +845,9 @@ co_IntGetPeekMessage( PMSG pMsg, bGMSG ); if (Present) { + /* GetMessage or PostMessage must never get messages that contain pointers */ + ASSERT(FindMsgMemory(pMsg->message) == NULL); + pti->timeLast = pMsg->time; pti->ptLast = pMsg->pt; @@ -1698,107 +1678,11 @@ NtUserWaitMessage(VOID) return ret; } - BOOL APIENTRY -NtUserGetMessage( PNTUSERGETMESSAGEINFO UnsafeInfo, +NtUserGetMessage(PMSG pMsg, HWND hWnd, UINT MsgFilterMin, UINT MsgFilterMax ) -/* -* FUNCTION: Get a message from the calling thread's message queue. -* ARGUMENTS: -* UnsafeMsg - Pointer to the structure which receives the returned message. -* Wnd - Window whose messages are to be retrieved. -* MsgFilterMin - Integer value of the lowest message value to be -* retrieved. -* MsgFilterMax - Integer value of the highest message value to be -* retrieved. -*/ -{ - NTUSERGETMESSAGEINFO Info; - NTSTATUS Status; - PMSGMEMORY MsgMemoryEntry; - PVOID UserMem; - ULONG Size; - MSG Msg; - BOOL GotMessage; - - if ( (MsgFilterMin|MsgFilterMax) & ~WM_MAXIMUM ) - { - SetLastWin32Error(ERROR_INVALID_PARAMETER); - return FALSE; - } - - UserEnterExclusive(); - - RtlZeroMemory(&Msg, sizeof(MSG)); - - GotMessage = co_IntGetPeekMessage(&Msg, hWnd, MsgFilterMin, MsgFilterMax, PM_REMOVE, TRUE); - - UserLeave(); - - Info.Msg = Msg; - /* See if this message type is present in the table */ - MsgMemoryEntry = FindMsgMemory(Info.Msg.message); - - _SEH2_TRY - { - ProbeForWrite(UnsafeInfo, sizeof(NTUSERGETMESSAGEINFO), 1); - RtlCopyMemory(UnsafeInfo, &Info, sizeof(NTUSERGETMESSAGEINFO)); - - if (NULL == MsgMemoryEntry) - { - /* Not present, no copying needed */ - UnsafeInfo->LParamSize = 0; - } - else - { - /* Determine required size */ - Size = MsgMemorySize(MsgMemoryEntry, Info.Msg.wParam, Info.Msg.lParam); - - /* Allocate required amount of user-mode memory */ - Status = ZwAllocateVirtualMemory(NtCurrentProcess(), - &UserMem, - 0, - &Size, - MEM_COMMIT, - PAGE_READWRITE); - if (! NT_SUCCESS(Status)) - { - SetLastNtError(Status); - _SEH2_YIELD(return (BOOL) -1); - } - - /* Transfer lParam data to user-mode mem */ - ProbeForWrite(UserMem, Size, 1); - RtlCopyMemory(UserMem, (PVOID)Info.Msg.lParam, Size); - - UnsafeInfo->LParamSize = Size; - UnsafeInfo->Msg.lParam = (LPARAM) UserMem; - } - } - _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) - { - SetLastNtError(_SEH2_GetExceptionCode()); - - if(UserMem != NULL) - { - ZwFreeVirtualMemory(NtCurrentProcess(), &UserMem, &Size, MEM_RELEASE); - } - - _SEH2_YIELD(return (BOOL) -1); - } - _SEH2_END; - - return GotMessage; -} - - -BOOL APIENTRY -NtUserGetMessageX(PMSG pMsg, - HWND hWnd, - UINT MsgFilterMin, - UINT MsgFilterMax) { MSG Msg; BOOL Ret; @@ -1836,98 +1720,11 @@ NtUserGetMessageX(PMSG pMsg, } BOOL APIENTRY -NtUserPeekMessage(PNTUSERGETMESSAGEINFO UnsafeInfo, +NtUserPeekMessage( PMSG pMsg, HWND hWnd, UINT MsgFilterMin, UINT MsgFilterMax, UINT RemoveMsg) -{ - NTSTATUS Status; - NTUSERGETMESSAGEINFO Info; - PMSGMEMORY MsgMemoryEntry; - PVOID UserMem = NULL; - ULONG Size; - MSG Msg; - BOOL Ret; - - if ( RemoveMsg & PM_BADMSGFLAGS ) - { - SetLastWin32Error(ERROR_INVALID_FLAGS); - return FALSE; - } - - UserEnterExclusive(); - - RtlZeroMemory(&Msg, sizeof(MSG)); - - Ret = co_IntGetPeekMessage(&Msg, hWnd, MsgFilterMin, MsgFilterMax, RemoveMsg, FALSE); - - UserLeave(); - - if (Ret) - { - Info.Msg = Msg; - /* See if this message type is present in the table */ - MsgMemoryEntry = FindMsgMemory(Info.Msg.message); - - _SEH2_TRY - { - ProbeForWrite(UnsafeInfo, sizeof(NTUSERGETMESSAGEINFO), 1); - RtlCopyMemory(UnsafeInfo, &Info, sizeof(NTUSERGETMESSAGEINFO)); - - if (NULL == MsgMemoryEntry) - { - /* Not present, no copying needed */ - UnsafeInfo->LParamSize = 0; - } - else - { - /* Determine required size */ - Size = MsgMemorySize(MsgMemoryEntry, Info.Msg.wParam, Info.Msg.lParam); - - /* Allocate required amount of user-mode memory */ - Status = ZwAllocateVirtualMemory(NtCurrentProcess(), - &UserMem, - 0, - &Size, - MEM_COMMIT, - PAGE_READWRITE); - if (! NT_SUCCESS(Status)) - { - SetLastNtError(Status); - _SEH2_YIELD(return (BOOL) -1); - } - - /* Transfer lParam data to user-mode mem */ - ProbeForWrite(UserMem, Size, 1); - RtlCopyMemory(UserMem, (PVOID)Info.Msg.lParam, Size); - - UnsafeInfo->LParamSize = Size; - UnsafeInfo->Msg.lParam = (LPARAM) UserMem; - } - } - _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) - { - SetLastNtError(_SEH2_GetExceptionCode()); - Ret = (BOOL) -1; - - if(UserMem != NULL) - { - ZwFreeVirtualMemory(NtCurrentProcess(), &UserMem, &Size, MEM_RELEASE); - } - } - _SEH2_END; - } - - return Ret; -} - -BOOL APIENTRY -NtUserPeekMessageX( PMSG pMsg, - HWND hWnd, - UINT MsgFilterMin, - UINT MsgFilterMax, - UINT RemoveMsg) { MSG Msg; BOOL Ret; From 19e368a616b673a7f5a8c7bb7f9a2f68aaf7e3dc Mon Sep 17 00:00:00 2001 From: Aleksey Bragin Date: Wed, 15 Dec 2010 20:03:43 +0000 Subject: [PATCH 056/181] [RTL] - Roel Messiant: Specify proper byte length of a unicode string. Fixes out of bounds access in actctx.c support code. No more half-cut active context stuff in debug logs. svn path=/trunk/; revision=50031 --- reactos/lib/rtl/actctx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reactos/lib/rtl/actctx.c b/reactos/lib/rtl/actctx.c index 40883a8ff22..eb07758c8cf 100644 --- a/reactos/lib/rtl/actctx.c +++ b/reactos/lib/rtl/actctx.c @@ -239,7 +239,7 @@ static UNICODE_STRING xmlstr2unicode(const xmlstr_t *xmlstr) UNICODE_STRING res; res.Buffer = (PWSTR)xmlstr->ptr; - res.Length = res.MaximumLength = xmlstr->len; + res.Length = res.MaximumLength = xmlstr->len * sizeof(WCHAR); return res; } From 074f4cec877270042cbfe3cb1e84b44918f77893 Mon Sep 17 00:00:00 2001 From: Aleksey Bragin Date: Wed, 15 Dec 2010 20:12:03 +0000 Subject: [PATCH 057/181] [NTOS] - Roel Messiant: Fix NtQueryObject to return the required buffer size if the buffer provided was too small. Unimplemented paths behaviour is preserved. svn path=/trunk/; revision=50032 --- reactos/ntoskrnl/ob/oblife.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/reactos/ntoskrnl/ob/oblife.c b/reactos/ntoskrnl/ob/oblife.c index 7304321d411..f87e5948d36 100644 --- a/reactos/ntoskrnl/ob/oblife.c +++ b/reactos/ntoskrnl/ob/oblife.c @@ -1549,6 +1549,7 @@ NtQueryObject(IN HANDLE ObjectHandle, /* Information about all types */ case ObjectTypesInformation: DPRINT1("NOT IMPLEMENTED!\n"); + InfoLength = Length; Status = STATUS_NOT_IMPLEMENTED; break; @@ -1580,6 +1581,7 @@ NtQueryObject(IN HANDLE ObjectHandle, default: /* Fail it */ + InfoLength = Length; Status = STATUS_INVALID_INFO_CLASS; break; } @@ -1588,7 +1590,7 @@ NtQueryObject(IN HANDLE ObjectHandle, if (ResultLength) { /* Write the length */ - *ResultLength = Length; + *ResultLength = InfoLength; } } _SEH2_EXCEPT(ExSystemExceptionFilter()) From fa87a286f1688bb8070cd1483ed3d55b50ef764f Mon Sep 17 00:00:00 2001 From: Giannis Adamopoulos Date: Thu, 16 Dec 2010 18:49:10 +0000 Subject: [PATCH 058/181] [user32_winetest] -deactivate some tests that hang in reactos that have already been deactived and reactivded by mistake twice svn path=/trunk/; revision=50041 --- rostests/winetests/user32/menu.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/rostests/winetests/user32/menu.c b/rostests/winetests/user32/menu.c index deecbe8dd03..467b283ff0e 100755 --- a/rostests/winetests/user32/menu.c +++ b/rostests/winetests/user32/menu.c @@ -3067,6 +3067,9 @@ static void test_menu_cancelmode(void) ok( g_got_enteridle == 0, "received %d WM_ENTERIDLE messages, none expected\n", g_got_enteridle); } ok( g_got_enteridle < 2, "received %d WM_ENTERIDLE messages, should be less than 2\n", g_got_enteridle); + + skip("skipping TrackPopupMenu, that hangs on reactos\n"); +#if 0 /* menu owner is child window */ g_hwndtosend = hwndchild; ret = TrackPopupMenu( menu, TPM_RETURNCMD, 100,100, 0, hwndchild, NULL); @@ -3079,6 +3082,7 @@ static void test_menu_cancelmode(void) g_hwndtosend = hwnd; ret = TrackPopupMenu( menu, TPM_RETURNCMD, 100,100, 0, hwndchild, NULL); ok( g_got_enteridle == 2, "received %d WM_ENTERIDLE messages, should be 2\n", g_got_enteridle); +#endif /* cleanup */ DestroyMenu( menu); DestroyWindow( hwndchild); From 5996aeb16bb394658a5ca2c8b42e3bf4282ab64e Mon Sep 17 00:00:00 2001 From: Giannis Adamopoulos Date: Thu, 16 Dec 2010 19:11:13 +0000 Subject: [PATCH 059/181] [user32_winetest] -revert the previous commit svn path=/trunk/; revision=50042 --- rostests/winetests/user32/menu.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/rostests/winetests/user32/menu.c b/rostests/winetests/user32/menu.c index 467b283ff0e..deecbe8dd03 100755 --- a/rostests/winetests/user32/menu.c +++ b/rostests/winetests/user32/menu.c @@ -3067,9 +3067,6 @@ static void test_menu_cancelmode(void) ok( g_got_enteridle == 0, "received %d WM_ENTERIDLE messages, none expected\n", g_got_enteridle); } ok( g_got_enteridle < 2, "received %d WM_ENTERIDLE messages, should be less than 2\n", g_got_enteridle); - - skip("skipping TrackPopupMenu, that hangs on reactos\n"); -#if 0 /* menu owner is child window */ g_hwndtosend = hwndchild; ret = TrackPopupMenu( menu, TPM_RETURNCMD, 100,100, 0, hwndchild, NULL); @@ -3082,7 +3079,6 @@ static void test_menu_cancelmode(void) g_hwndtosend = hwnd; ret = TrackPopupMenu( menu, TPM_RETURNCMD, 100,100, 0, hwndchild, NULL); ok( g_got_enteridle == 2, "received %d WM_ENTERIDLE messages, should be 2\n", g_got_enteridle); -#endif /* cleanup */ DestroyMenu( menu); DestroyWindow( hwndchild); From 5a3dff4bd267d1581196eca82b4bb386690a93ba Mon Sep 17 00:00:00 2001 From: Giannis Adamopoulos Date: Thu, 16 Dec 2010 20:41:25 +0000 Subject: [PATCH 060/181] [win32k] -Remove an unneeded debug message svn path=/trunk/; revision=50043 --- reactos/subsystems/win32/win32k/ntuser/message.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/reactos/subsystems/win32/win32k/ntuser/message.c b/reactos/subsystems/win32/win32k/ntuser/message.c index 5dfcd924d1e..5cd37b09eff 100644 --- a/reactos/subsystems/win32/win32k/ntuser/message.c +++ b/reactos/subsystems/win32/win32k/ntuser/message.c @@ -910,8 +910,6 @@ UserPostThreadMessage( DWORD idThread, LARGE_INTEGER LargeTickCount; NTSTATUS Status; - DPRINT1("UserPostThreadMessage wParam 0x%x lParam 0x%x\n", wParam,lParam); - if (FindMsgMemory(Msg) != 0) { SetLastWin32Error(ERROR_MESSAGE_SYNC_ONLY ); From f21a470fe6465d0d67801eb0edc28b26c993a248 Mon Sep 17 00:00:00 2001 From: Giannis Adamopoulos Date: Thu, 16 Dec 2010 21:42:28 +0000 Subject: [PATCH 061/181] remove some more unnecessary debug output svn path=/trunk/; revision=50045 --- reactos/base/services/svchost/svchost.c | 6 +++--- reactos/dll/win32/user32/windows/cursoricon.c | 2 +- reactos/subsystems/win32/win32k/eng/device.c | 6 +++--- reactos/subsystems/win32/win32k/eng/pdevobj.c | 6 +++--- reactos/subsystems/win32/win32k/ntuser/desktop.c | 2 +- reactos/subsystems/win32/win32k/ntuser/display.c | 2 +- reactos/subsystems/win32/win32k/objects/device.c | 2 +- 7 files changed, 13 insertions(+), 13 deletions(-) diff --git a/reactos/base/services/svchost/svchost.c b/reactos/base/services/svchost/svchost.c index f05955127e4..c79ffae2009 100644 --- a/reactos/base/services/svchost/svchost.c +++ b/reactos/base/services/svchost/svchost.c @@ -104,7 +104,7 @@ BOOL PrepareService(LPCTSTR ServiceName) HeapFree(GetProcessHeap(), 0, Buffer); /* Load the service dll */ - DPRINT1("Trying to load dll\n"); + DPRINT("Trying to load dll\n"); hServiceDll = LoadLibrary(DllPath); if (NULL == hServiceDll) @@ -226,7 +226,7 @@ int _tmain (int argc, LPTSTR argv []) NrOfServices = LoadServiceCategory(argv[2]); - DPRINT1("NrOfServices: %lu\n", NrOfServices); + DPRINT("NrOfServices: %lu\n", NrOfServices); if (0 == NrOfServices) return 0; @@ -240,7 +240,7 @@ int _tmain (int argc, LPTSTR argv []) /* Fill the service table */ for (i = 0; i < NrOfServices; ++i) { - DPRINT1("Loading service: %s\n", Service->Name); + DPRINT("Loading service: %s\n", Service->Name); ServiceTable[i].lpServiceName = Service->Name; ServiceTable[i].lpServiceProc = Service->ServiceMainFunc; Service = Service->Next; diff --git a/reactos/dll/win32/user32/windows/cursoricon.c b/reactos/dll/win32/user32/windows/cursoricon.c index f7ada0b80af..165e52df3fa 100644 --- a/reactos/dll/win32/user32/windows/cursoricon.c +++ b/reactos/dll/win32/user32/windows/cursoricon.c @@ -1005,7 +1005,7 @@ static HICON CURSORICON_ExtCopy(HICON hIcon, UINT nType, && (iDesiredCX > 0 || iDesiredCY > 0)) || nFlags & LR_MONOCHROME) { - FIXME("Copying from resource isn't implemented yet\n"); + TRACE("Copying from resource isn't implemented yet\n"); hNew = CopyIcon(hIcon); #if 0 diff --git a/reactos/subsystems/win32/win32k/eng/device.c b/reactos/subsystems/win32/win32k/eng/device.c index 730b2ffaa3a..3e6759499e0 100644 --- a/reactos/subsystems/win32/win32k/eng/device.c +++ b/reactos/subsystems/win32/win32k/eng/device.c @@ -124,7 +124,7 @@ EngpRegisterGraphicsDevice( * This is a REG_MULTI_SZ string */ for (; *pwsz; pwsz += wcslen(pwsz) + 1) { - DPRINT1("trying driver: %ls\n", pwsz); + DPRINT("trying driver: %ls\n", pwsz); /* Try to load the display driver */ pldev = EngLoadImageEx(pwsz, LDEV_DEVICE_DISPLAY); if (!pldev) @@ -197,7 +197,7 @@ EngpRegisterGraphicsDevice( { pGraphicsDevice->iDefaultMode = i; pGraphicsDevice->iCurrentMode = i; - DPRINT1("Found default entry: %ld '%ls'\n", i, pdm->dmDeviceName); + DPRINT("Found default entry: %ld '%ls'\n", i, pdm->dmDeviceName); } /* Initialize the entry */ @@ -221,7 +221,7 @@ EngpRegisterGraphicsDevice( /* Unlock loader */ EngReleaseSemaphore(ghsemGraphicsDeviceList); - DPRINT1("Prepared %ld modes for %ls\n", cModes, pGraphicsDevice->pwszDescription); + DPRINT("Prepared %ld modes for %ls\n", cModes, pGraphicsDevice->pwszDescription); return pGraphicsDevice; } diff --git a/reactos/subsystems/win32/win32k/eng/pdevobj.c b/reactos/subsystems/win32/win32k/eng/pdevobj.c index 2da468ee3fb..faff16e4aa0 100644 --- a/reactos/subsystems/win32/win32k/eng/pdevobj.c +++ b/reactos/subsystems/win32/win32k/eng/pdevobj.c @@ -117,7 +117,7 @@ PDEVOBJ_bEnablePDEV( { PFN_DrvEnablePDEV pfnEnablePDEV; - DPRINT1("PDEVOBJ_bEnablePDEV()\n"); + DPRINT("PDEVOBJ_bEnablePDEV()\n"); /* Get the DrvEnablePDEV function */ pfnEnablePDEV = ppdev->pldev->pfn.EnablePDEV; @@ -146,7 +146,7 @@ PDEVOBJ_bEnablePDEV( GDIOBJ_SetOwnership(ppdev->devinfo.hpalDefault, NULL); ppdev->ppalSurf = PALETTE_ShareLockPalette(ppdev->devinfo.hpalDefault); - DPRINT1("PDEVOBJ_bEnablePDEV - dhpdev = %p\n", ppdev->dhpdev); + DPRINT("PDEVOBJ_bEnablePDEV - dhpdev = %p\n", ppdev->dhpdev); return TRUE; } @@ -266,7 +266,7 @@ EngpCreatePDEV( { /* ... use the device's default one */ pdm = pGraphicsDevice->pDevModeList[pGraphicsDevice->iDefaultMode].pdm; - DPRINT1("Using iDefaultMode = %ld\n", pGraphicsDevice->iDefaultMode); + DPRINT("Using iDefaultMode = %ld\n", pGraphicsDevice->iDefaultMode); } /* Try to get a diplay driver */ diff --git a/reactos/subsystems/win32/win32k/ntuser/desktop.c b/reactos/subsystems/win32/win32k/ntuser/desktop.c index 8e97e1b7b7a..b4a4e20fb39 100644 --- a/reactos/subsystems/win32/win32k/ntuser/desktop.c +++ b/reactos/subsystems/win32/win32k/ntuser/desktop.c @@ -572,7 +572,7 @@ BOOL FASTCALL IntDesktopUpdatePerUserSettings(BOOL bEnable) QueryTable, NULL, NULL); if (!NT_SUCCESS(Status)) { - DPRINT1("RtlQueryRegistryValues failed for PaintDesktopVersion (%x)\n", + DPRINT("RtlQueryRegistryValues failed for PaintDesktopVersion (%x)\n", Status); g_PaintDesktopVersion = FALSE; return FALSE; diff --git a/reactos/subsystems/win32/win32k/ntuser/display.c b/reactos/subsystems/win32/win32k/ntuser/display.c index f5770a7ce2c..5e8f50d0c51 100644 --- a/reactos/subsystems/win32/win32k/ntuser/display.c +++ b/reactos/subsystems/win32/win32k/ntuser/display.c @@ -551,7 +551,7 @@ NtUserEnumDisplaySettings( ULONG cbSize, cbExtra; DEVMODEW dmReg, *pdm; - DPRINT1("Enter NtUserEnumDisplaySettings(%ls, %ld)\n", + DPRINT("Enter NtUserEnumDisplaySettings(%ls, %ld)\n", pustrDevice ? pustrDevice->Buffer : 0, iModeNum); if (pustrDevice) diff --git a/reactos/subsystems/win32/win32k/objects/device.c b/reactos/subsystems/win32/win32k/objects/device.c index c9b930331fa..d0d74683327 100644 --- a/reactos/subsystems/win32/win32k/objects/device.c +++ b/reactos/subsystems/win32/win32k/objects/device.c @@ -41,7 +41,7 @@ IntCreatePrimarySurface() /* attach monitor */ IntAttachMonitor(gppdevPrimary, 0); - DPRINT1("IntCreatePrimarySurface, pPrimarySurface=%p, pPrimarySurface->pSurface = %p\n", + DPRINT("IntCreatePrimarySurface, pPrimarySurface=%p, pPrimarySurface->pSurface = %p\n", pPrimarySurface, pPrimarySurface->pSurface); /* Create surface */ From e8264b67592f05df7ae31fa755abfa125c073c08 Mon Sep 17 00:00:00 2001 From: James Tabor Date: Fri, 17 Dec 2010 01:09:42 +0000 Subject: [PATCH 062/181] [Win32k|User32] - Finish 50030 (work by Giannis), Now PostMessage passes all the correct data based on Get/PeekMessage. Example: Post A, Get/Peek A, Translate A, Dispatch A, should be that simple. FYI: DDE memory handling should be in win32k not user32 and why,,,,, ~see next point~ - Patch up problems (at a minimum) going into the SendMessage/Timeout A2U U2A support in win32k and fixed SMTO callback if local. svn path=/trunk/; revision=50047 --- reactos/dll/win32/user32/include/user32p.h | 1 - reactos/dll/win32/user32/windows/message.c | 206 +++++++++-------- .../subsystems/win32/win32k/ntuser/message.c | 212 +++++++++--------- .../subsystems/win32/win32k/ntuser/msgqueue.c | 2 +- 4 files changed, 216 insertions(+), 205 deletions(-) diff --git a/reactos/dll/win32/user32/include/user32p.h b/reactos/dll/win32/user32/include/user32p.h index d000164a4d6..c748874c485 100644 --- a/reactos/dll/win32/user32/include/user32p.h +++ b/reactos/dll/win32/user32/include/user32p.h @@ -116,7 +116,6 @@ typedef struct _USER32_TRACKINGLIST { typedef struct _USER32_THREAD_DATA { - MSG LastMessage; USER32_TRACKINGLIST tracking_info; /* TrackMouseEvent stuff */ } USER32_THREAD_DATA, *PUSER32_THREAD_DATA; diff --git a/reactos/dll/win32/user32/windows/message.c b/reactos/dll/win32/user32/windows/message.c index 3b8ce7e9843..c32f0bed68c 100644 --- a/reactos/dll/win32/user32/windows/message.c +++ b/reactos/dll/win32/user32/windows/message.c @@ -145,7 +145,8 @@ DdeGetPair(HGLOBAL ServerMem) return Ret; } -static BOOL FASTCALL +static +BOOL FASTCALL MsgiUMToKMMessage(PMSG UMMsg, PMSG KMMsg, BOOL Posted) { *KMMsg = *UMMsg; @@ -249,7 +250,8 @@ MsgiUMToKMMessage(PMSG UMMsg, PMSG KMMsg, BOOL Posted) return TRUE; } -static VOID FASTCALL +static +VOID FASTCALL MsgiUMToKMCleanup(PMSG UMMsg, PMSG KMMsg) { switch (KMMsg->message) @@ -949,9 +951,7 @@ DWORD WINAPI GetMessagePos(VOID) { - PUSER32_THREAD_DATA ThreadData = User32GetThreadData(); - return(MAKELONG(ThreadData->LastMessage.pt.x, ThreadData->LastMessage.pt.y)); - //return NtUserCallNoParam(NOPARAM_ROUTINE_GETMSESSAGEPOS); + return NtUserCallNoParam(NOPARAM_ROUTINE_GETMSESSAGEPOS); } @@ -961,9 +961,7 @@ GetMessagePos(VOID) LONG WINAPI GetMessageTime(VOID) { - PUSER32_THREAD_DATA ThreadData = User32GetThreadData(); - return(ThreadData->LastMessage.time); -// return NtUserGetThreadState(THREADSTATE_GETMESSAGETIME); + return NtUserGetThreadState(THREADSTATE_GETMESSAGETIME); } @@ -1602,7 +1600,12 @@ GetMessageA(LPMSG lpMsg, UINT wMsgFilterMax) { BOOL Res; - PUSER32_THREAD_DATA ThreadData = User32GetThreadData(); + + if ( (wMsgFilterMin|wMsgFilterMax) & ~WM_MAXIMUM ) + { + SetLastError( ERROR_INVALID_PARAMETER ); + return FALSE; + } Res = NtUserGetMessage(lpMsg, hWnd, wMsgFilterMin, wMsgFilterMax); if (-1 == (int) Res) @@ -1610,11 +1613,6 @@ GetMessageA(LPMSG lpMsg, return Res; } - if (Res && lpMsg->message != WM_PAINT && lpMsg->message != WM_QUIT) - { - ThreadData->LastMessage = *lpMsg; - } - return Res; } @@ -1628,7 +1626,12 @@ GetMessageW(LPMSG lpMsg, UINT wMsgFilterMax) { BOOL Res; - PUSER32_THREAD_DATA ThreadData = User32GetThreadData(); + + if ( (wMsgFilterMin|wMsgFilterMax) & ~WM_MAXIMUM ) + { + SetLastError( ERROR_INVALID_PARAMETER ); + return FALSE; + } Res = NtUserGetMessage(lpMsg, hWnd, wMsgFilterMin, wMsgFilterMax); if (-1 == (int) Res) @@ -1636,20 +1639,15 @@ GetMessageW(LPMSG lpMsg, return Res; } - if (Res && lpMsg->message != WM_PAINT && lpMsg->message != WM_QUIT) - { - ThreadData->LastMessage = *lpMsg; - } - return Res; } BOOL WINAPI -PeekMessageWorker(PMSG pMsg, - HWND hWnd, - UINT wMsgFilterMin, - UINT wMsgFilterMax, - UINT wRemoveMsg) +PeekMessageWorker( PMSG pMsg, + HWND hWnd, + UINT wMsgFilterMin, + UINT wMsgFilterMax, + UINT wRemoveMsg) { PCLIENTINFO pci; PCLIENTTHREADINFO pcti; @@ -1692,7 +1690,6 @@ PeekMessageA(LPMSG lpMsg, UINT wRemoveMsg) { BOOL Res; - PUSER32_THREAD_DATA ThreadData = User32GetThreadData(); Res = PeekMessageWorker(lpMsg, hWnd, wMsgFilterMin, wMsgFilterMax, wRemoveMsg); if (-1 == (int) Res || !Res) @@ -1700,11 +1697,6 @@ PeekMessageA(LPMSG lpMsg, return FALSE; } - if (Res && lpMsg->message != WM_PAINT && lpMsg->message != WM_QUIT) - { - ThreadData->LastMessage = *lpMsg; - } - return Res; } @@ -1722,7 +1714,6 @@ PeekMessageW( UINT wRemoveMsg) { BOOL Res; - PUSER32_THREAD_DATA ThreadData = User32GetThreadData(); Res = PeekMessageWorker(lpMsg, hWnd, wMsgFilterMin, wMsgFilterMax, wRemoveMsg); if (-1 == (int) Res || !Res) @@ -1730,46 +1721,9 @@ PeekMessageW( return FALSE; } - if (Res && lpMsg->message != WM_PAINT && lpMsg->message != WM_QUIT) - { - ThreadData->LastMessage = *lpMsg; - } - return Res; } -// -// Worker function for post message. -// -BOOL -FASTCALL -PostMessageWorker( - HWND Wnd, - UINT Msg, - WPARAM wParam, - LPARAM lParam) -{ - MSG UMMsg, KMMsg; - LRESULT Result; - - UMMsg.hwnd = Wnd; - UMMsg.message = Msg; - UMMsg.wParam = wParam; - UMMsg.lParam = lParam; - if (! MsgiUMToKMMessage(&UMMsg, &KMMsg, TRUE)) - { - return FALSE; - } - Result = NtUserPostMessage( Wnd, - KMMsg.message, - KMMsg.wParam, - KMMsg.lParam); - - MsgiUMToKMCleanup(&UMMsg, &KMMsg); - - return Result; -} - /* * @implemented */ @@ -1781,24 +1735,38 @@ PostMessageA( WPARAM wParam, LPARAM lParam) { - MSG AnsiMsg, UcMsg; - BOOL Ret; + LRESULT Ret; - AnsiMsg.hwnd = hWnd; - AnsiMsg.message = Msg; - AnsiMsg.wParam = wParam; - AnsiMsg.lParam = lParam; - - if (!MsgiAnsiToUnicodeMessage(&UcMsg, &AnsiMsg)) + /* Check for combo box or a list box to send names. */ + if (Msg == CB_DIR || Msg == LB_DIR) { - return FALSE; + /* + Set DDL_POSTMSGS, so use the PostMessage function to send messages to the + combo/list box. Forces a call like DlgDirListComboBox. + */ + //wParam |= DDL_POSTMSGS; + return NtUserPostMessage(hWnd, Msg, wParam, lParam); } - Ret = PostMessageW( hWnd, UcMsg.message, UcMsg.wParam, UcMsg.lParam); + /* No drop files or current Process, just post message. */ + if ( (Msg != WM_DROPFILES) || + ( NtUserQueryWindow( hWnd, QUERY_WINDOW_UNIQUE_PROCESS_ID) == + PtrToUint(NtCurrentTeb()->ClientId.UniqueProcess) ) ) + { + return NtUserPostMessage(hWnd, Msg, wParam, lParam); + } - MsgiAnsiToUnicodeCleanup(&UcMsg, &AnsiMsg); + /* We have drop files and this is not the same process for this window. */ - return Ret; + /* Just incase, check wParam for Global memory handle and send size. */ + Ret = SendMessageA( hWnd, + WM_COPYGLOBALDATA, + (WPARAM)GlobalSize((HGLOBAL)wParam), // Zero if not a handle. + (LPARAM)wParam); // Send wParam as lParam. + + if ( Ret ) return NtUserPostMessage(hWnd, Msg, (WPARAM)Ret, lParam); + + return FALSE; } /* @@ -1821,8 +1789,8 @@ PostMessageW( Set DDL_POSTMSGS, so use the PostMessage function to send messages to the combo/list box. Forces a call like DlgDirListComboBox. */ - wParam |= DDL_POSTMSGS; - return PostMessageWorker(hWnd, Msg, wParam, lParam); + //wParam |= DDL_POSTMSGS; + return NtUserPostMessage(hWnd, Msg, wParam, lParam); } /* No drop files or current Process, just post message. */ @@ -1830,7 +1798,7 @@ PostMessageW( ( NtUserQueryWindow( hWnd, QUERY_WINDOW_UNIQUE_PROCESS_ID) == PtrToUint(NtCurrentTeb()->ClientId.UniqueProcess) ) ) { - return PostMessageWorker(hWnd, Msg, wParam, lParam); + return NtUserPostMessage(hWnd, Msg, wParam, lParam); } /* We have drop files and this is not the same process for this window. */ @@ -1841,7 +1809,7 @@ PostMessageW( (WPARAM)GlobalSize((HGLOBAL)wParam), // Zero if not a handle. (LPARAM)wParam); // Send wParam as lParam. - if ( Ret ) return PostMessageWorker(hWnd, Msg, (WPARAM)Ret, lParam); + if ( Ret ) return NtUserPostMessage(hWnd, Msg, (WPARAM)Ret, lParam); return FALSE; } @@ -1902,11 +1870,16 @@ SendMessageW(HWND Wnd, PWND Window; PTHREADINFO ti = GetW32ThreadInfo(); - Window = ValidateHwnd(Wnd); - if (!Window) return FALSE; + if ( Msg & ~WM_MAXIMUM ) + { + SetLastError( ERROR_INVALID_PARAMETER ); + return 0; + } if (Wnd != HWND_BROADCAST && (Msg < WM_DDE_FIRST || Msg > WM_DDE_LAST)) { + Window = ValidateHwnd(Wnd); + if ( Window != NULL && Window->head.pti == ti && // !IsThreadHooked(GetWin32ClientInfo()) && // Enable to test message system bug. @@ -1937,7 +1910,7 @@ SendMessageW(HWND Wnd, return FALSE; } - Result = NtUserMessageCall( KMMsg.hwnd, + Result = NtUserMessageCall( Wnd, KMMsg.message, KMMsg.wParam, KMMsg.lParam, @@ -1962,11 +1935,16 @@ SendMessageA(HWND Wnd, UINT Msg, WPARAM wParam, LPARAM lParam) PWND Window; PTHREADINFO ti = GetW32ThreadInfo(); - Window = ValidateHwnd(Wnd); - if (!Window) return FALSE; + if ( Msg & ~WM_MAXIMUM ) + { + SetLastError( ERROR_INVALID_PARAMETER ); + return 0; + } if (Wnd != HWND_BROADCAST && (Msg < WM_DDE_FIRST || Msg > WM_DDE_LAST)) { + Window = ValidateHwnd(Wnd); + if ( Window != NULL && Window->head.pti == ti && // !IsThreadHooked(GetWin32ClientInfo()) && // Enable to test message system bug. @@ -2003,7 +1981,7 @@ SendMessageA(HWND Wnd, UINT Msg, WPARAM wParam, LPARAM lParam) return FALSE; } - Result = NtUserMessageCall( KMMsg.hwnd, + Result = NtUserMessageCall( Wnd, KMMsg.message, KMMsg.wParam, KMMsg.lParam, @@ -2047,7 +2025,7 @@ SendMessageCallbackA( return FALSE; } - Result = NtUserMessageCall( UcMsg.hwnd, + Result = NtUserMessageCall( hWnd, UcMsg.message, UcMsg.wParam, UcMsg.lParam, @@ -2104,8 +2082,8 @@ SendMessageTimeoutA( MSG AnsiMsg, UcMsg; LRESULT Result; DOSENDMESSAGE dsm; - - SPY_EnterMessage(SPY_SENDMESSAGE, hWnd, Msg, wParam, lParam); + PWND Window; + PTHREADINFO ti = GetW32ThreadInfo(); if ( Msg & ~WM_MAXIMUM || fuFlags & ~(SMTO_NOTIMEOUTIFNOTHUNG|SMTO_ABORTIFHUNG|SMTO_BLOCK)) { @@ -2115,6 +2093,23 @@ SendMessageTimeoutA( if (lpdwResult) *lpdwResult = 0; + if (hWnd != HWND_BROADCAST && (Msg < WM_DDE_FIRST || Msg > WM_DDE_LAST)) + { + Window = ValidateHwnd(hWnd); + + if ( Window != NULL && + Window->head.pti == ti && + !ISITHOOKED(WH_CALLWNDPROC) && + !ISITHOOKED(WH_CALLWNDPROCRET) && + !(Window->state & WNDS_SERVERSIDEWINDOWPROC) ) + { + Result = IntCallMessageProc(Window, hWnd, Msg, wParam, lParam, TRUE); + if (lpdwResult) *lpdwResult = Result; + return TRUE; + } + } + SPY_EnterMessage(SPY_SENDMESSAGE, hWnd, Msg, wParam, lParam); + dsm.uFlags = fuFlags; dsm.uTimeout = uTimeout; @@ -2128,7 +2123,7 @@ SendMessageTimeoutA( return FALSE; } - Result = NtUserMessageCall( UcMsg.hwnd, + Result = NtUserMessageCall( hWnd, UcMsg.message, UcMsg.wParam, UcMsg.lParam, @@ -2162,8 +2157,8 @@ SendMessageTimeoutW( { LRESULT Result; DOSENDMESSAGE dsm; - - SPY_EnterMessage(SPY_SENDMESSAGE, hWnd, Msg, wParam, lParam); + PWND Window; + PTHREADINFO ti = GetW32ThreadInfo(); if ( Msg & ~WM_MAXIMUM || fuFlags & ~(SMTO_NOTIMEOUTIFNOTHUNG|SMTO_ABORTIFHUNG|SMTO_BLOCK)) { @@ -2173,6 +2168,23 @@ SendMessageTimeoutW( if (lpdwResult) *lpdwResult = 0; + if (hWnd != HWND_BROADCAST && (Msg < WM_DDE_FIRST || Msg > WM_DDE_LAST)) + { + Window = ValidateHwnd(hWnd); + + if ( Window != NULL && + Window->head.pti == ti && + !ISITHOOKED(WH_CALLWNDPROC) && + !ISITHOOKED(WH_CALLWNDPROCRET) && + !(Window->state & WNDS_SERVERSIDEWINDOWPROC) ) + { + Result = IntCallMessageProc(Window, hWnd, Msg, wParam, lParam, FALSE); + if (lpdwResult) *lpdwResult = Result; + return TRUE; + } + } + SPY_EnterMessage(SPY_SENDMESSAGE, hWnd, Msg, wParam, lParam); + dsm.uFlags = fuFlags; dsm.uTimeout = uTimeout; diff --git a/reactos/subsystems/win32/win32k/ntuser/message.c b/reactos/subsystems/win32/win32k/ntuser/message.c index 5cd37b09eff..1de7a949d54 100644 --- a/reactos/subsystems/win32/win32k/ntuser/message.c +++ b/reactos/subsystems/win32/win32k/ntuser/message.c @@ -61,6 +61,7 @@ static MSGMEMORY MsgMemory[] = { WM_STYLECHANGED, sizeof(STYLESTRUCT), MMS_FLAG_READ }, { WM_STYLECHANGING, sizeof(STYLESTRUCT), MMS_FLAG_READWRITE }, { WM_COPYDATA, MMS_SIZE_SPECIAL, MMS_FLAG_READ }, + { WM_COPYGLOBALDATA, MMS_SIZE_WPARAM, MMS_FLAG_READ }, { WM_WINDOWPOSCHANGED, sizeof(WINDOWPOS), MMS_FLAG_READ }, { WM_WINDOWPOSCHANGING, sizeof(WINDOWPOS), MMS_FLAG_READWRITE }, }; @@ -134,10 +135,6 @@ MsgMemorySize(PMSGMEMORY MsgMemoryEntry, WPARAM wParam, LPARAM lParam) Size = sizeof(COPYDATASTRUCT) + ((PCOPYDATASTRUCT)lParam)->cbData; break; - case WM_COPYGLOBALDATA: - Size = wParam; - break; - default: ASSERT(FALSE); Size = 0; @@ -243,7 +240,6 @@ PackParam(LPARAM *lParamPacked, UINT Msg, WPARAM wParam, LPARAM lParam, BOOL Non ASSERT(CsData == (PCHAR) PackedCs + Size); *lParamPacked = (LPARAM) PackedCs; } - else if (PoolType == NonPagedPool) { PMSGMEMORY MsgMemoryEntry; @@ -317,6 +313,100 @@ UnpackParam(LPARAM lParamPacked, UINT Msg, WPARAM wParam, LPARAM lParam, BOOL No return STATUS_INVALID_PARAMETER; } +static NTSTATUS FASTCALL +CopyMsgToKernelMem(MSG *KernelModeMsg, MSG *UserModeMsg, PMSGMEMORY MsgMemoryEntry) +{ + NTSTATUS Status; + + PVOID KernelMem; + UINT Size; + + *KernelModeMsg = *UserModeMsg; + + /* See if this message type is present in the table */ + if (NULL == MsgMemoryEntry) + { + /* Not present, no copying needed */ + return STATUS_SUCCESS; + } + + /* Determine required size */ + Size = MsgMemorySize(MsgMemoryEntry, UserModeMsg->wParam, UserModeMsg->lParam); + + if (0 != Size) + { + /* Allocate kernel mem */ + KernelMem = ExAllocatePoolWithTag(PagedPool, Size, TAG_MSG); + if (NULL == KernelMem) + { + DPRINT1("Not enough memory to copy message to kernel mem\n"); + return STATUS_NO_MEMORY; + } + KernelModeMsg->lParam = (LPARAM) KernelMem; + + /* Copy data if required */ + if (0 != (MsgMemoryEntry->Flags & MMS_FLAG_READ)) + { + Status = MmCopyFromCaller(KernelMem, (PVOID) UserModeMsg->lParam, Size); + if (! NT_SUCCESS(Status)) + { + DPRINT1("Failed to copy message to kernel: invalid usermode buffer\n"); + ExFreePoolWithTag(KernelMem, TAG_MSG); + return Status; + } + } + else + { + /* Make sure we don't pass any secrets to usermode */ + RtlZeroMemory(KernelMem, Size); + } + } + else + { + KernelModeMsg->lParam = 0; + } + + return STATUS_SUCCESS; +} + +static NTSTATUS FASTCALL +CopyMsgToUserMem(MSG *UserModeMsg, MSG *KernelModeMsg) +{ + NTSTATUS Status; + PMSGMEMORY MsgMemoryEntry; + UINT Size; + + /* See if this message type is present in the table */ + MsgMemoryEntry = FindMsgMemory(UserModeMsg->message); + if (NULL == MsgMemoryEntry) + { + /* Not present, no copying needed */ + return STATUS_SUCCESS; + } + + /* Determine required size */ + Size = MsgMemorySize(MsgMemoryEntry, UserModeMsg->wParam, UserModeMsg->lParam); + + if (0 != Size) + { + /* Copy data if required */ + if (0 != (MsgMemoryEntry->Flags & MMS_FLAG_WRITE)) + { + Status = MmCopyToCaller((PVOID) UserModeMsg->lParam, (PVOID) KernelModeMsg->lParam, Size); + if (! NT_SUCCESS(Status)) + { + DPRINT1("Failed to copy message from kernel: invalid usermode buffer\n"); + ExFreePool((PVOID) KernelModeMsg->lParam); + return Status; + } + } + + ExFreePool((PVOID) KernelModeMsg->lParam); + } + + return STATUS_SUCCESS; +} + // // Wakeup any thread/process waiting on idle input. // @@ -654,100 +744,6 @@ co_IntPeekMessage( PMSG Msg, return TRUE; } -static NTSTATUS FASTCALL -CopyMsgToKernelMem(MSG *KernelModeMsg, MSG *UserModeMsg, PMSGMEMORY MsgMemoryEntry) -{ - NTSTATUS Status; - - PVOID KernelMem; - UINT Size; - - *KernelModeMsg = *UserModeMsg; - - /* See if this message type is present in the table */ - if (NULL == MsgMemoryEntry) - { - /* Not present, no copying needed */ - return STATUS_SUCCESS; - } - - /* Determine required size */ - Size = MsgMemorySize(MsgMemoryEntry, UserModeMsg->wParam, UserModeMsg->lParam); - - if (0 != Size) - { - /* Allocate kernel mem */ - KernelMem = ExAllocatePoolWithTag(PagedPool, Size, TAG_MSG); - if (NULL == KernelMem) - { - DPRINT1("Not enough memory to copy message to kernel mem\n"); - return STATUS_NO_MEMORY; - } - KernelModeMsg->lParam = (LPARAM) KernelMem; - - /* Copy data if required */ - if (0 != (MsgMemoryEntry->Flags & MMS_FLAG_READ)) - { - Status = MmCopyFromCaller(KernelMem, (PVOID) UserModeMsg->lParam, Size); - if (! NT_SUCCESS(Status)) - { - DPRINT1("Failed to copy message to kernel: invalid usermode buffer\n"); - ExFreePoolWithTag(KernelMem, TAG_MSG); - return Status; - } - } - else - { - /* Make sure we don't pass any secrets to usermode */ - RtlZeroMemory(KernelMem, Size); - } - } - else - { - KernelModeMsg->lParam = 0; - } - - return STATUS_SUCCESS; -} - -static NTSTATUS FASTCALL -CopyMsgToUserMem(MSG *UserModeMsg, MSG *KernelModeMsg) -{ - NTSTATUS Status; - PMSGMEMORY MsgMemoryEntry; - UINT Size; - - /* See if this message type is present in the table */ - MsgMemoryEntry = FindMsgMemory(UserModeMsg->message); - if (NULL == MsgMemoryEntry) - { - /* Not present, no copying needed */ - return STATUS_SUCCESS; - } - - /* Determine required size */ - Size = MsgMemorySize(MsgMemoryEntry, UserModeMsg->wParam, UserModeMsg->lParam); - - if (0 != Size) - { - /* Copy data if required */ - if (0 != (MsgMemoryEntry->Flags & MMS_FLAG_WRITE)) - { - Status = MmCopyToCaller((PVOID) UserModeMsg->lParam, (PVOID) KernelModeMsg->lParam, Size); - if (! NT_SUCCESS(Status)) - { - DPRINT1("Failed to copy message from kernel: invalid usermode buffer\n"); - ExFreePool((PVOID) KernelModeMsg->lParam); - return Status; - } - } - - ExFreePool((PVOID) KernelModeMsg->lParam); - } - - return STATUS_SUCCESS; -} - static BOOL FASTCALL co_IntWaitMessage( PWND Window, UINT MsgFilterMin, @@ -775,9 +771,9 @@ co_IntWaitMessage( PWND Window, /* Nothing found. Wait for new messages. */ Status = co_MsqWaitForNewMessages( ThreadQueue, - Window, - MsgFilterMin, - MsgFilterMax); + Window, + MsgFilterMin, + MsgFilterMax); } while ( (STATUS_WAIT_0 <= Status && Status <= STATUS_WAIT_63) || STATUS_TIMEOUT == Status ); @@ -834,6 +830,7 @@ co_IntGetPeekMessage( PMSG pMsg, } pti = PsGetCurrentThreadWin32Thread(); + pti->pClientInfo->cSpins++; // Bump up the spin count. do { @@ -848,8 +845,11 @@ co_IntGetPeekMessage( PMSG pMsg, /* GetMessage or PostMessage must never get messages that contain pointers */ ASSERT(FindMsgMemory(pMsg->message) == NULL); - pti->timeLast = pMsg->time; - pti->ptLast = pMsg->pt; + if (pMsg->message != WM_PAINT && pMsg->message != WM_QUIT) + { + pti->timeLast = pMsg->time; + pti->ptLast = pMsg->pt; + } // The WH_GETMESSAGE hook enables an application to monitor messages about to // be returned by the GetMessage or PeekMessage function. @@ -984,7 +984,7 @@ UserPostMessage( HWND Wnd, KernelModeMsg.wParam, KernelModeMsg.lParam); - if(MsgMemoryEntry) + if (MsgMemoryEntry && KernelModeMsg.lParam) ExFreePool((PVOID) KernelModeMsg.lParam); return TRUE; @@ -1019,7 +1019,7 @@ UserPostMessage( HWND Wnd, { UserPostMessage(List[i], Msg, wParam, lParam); } - ExFreePool(List); + ExFreePoolWithTag(List,TAG_WINLIST);//ExFreePool(List); } } else diff --git a/reactos/subsystems/win32/win32k/ntuser/msgqueue.c b/reactos/subsystems/win32/win32k/ntuser/msgqueue.c index 027489dc122..232fe21e8c3 100644 --- a/reactos/subsystems/win32/win32k/ntuser/msgqueue.c +++ b/reactos/subsystems/win32/win32k/ntuser/msgqueue.c @@ -1624,7 +1624,7 @@ co_MsqReplyMessage( LRESULT lResult ) pti = PsGetCurrentThreadWin32Thread(); Message = pti->pusmCurrent; - if(!Message) return FALSE; + if (!Message) return FALSE; if (Message->QS_Flags & QS_SMRESULT) return FALSE; From a2dad68309df8a2731e47fe44286d519941301ef Mon Sep 17 00:00:00 2001 From: Aleksey Bragin Date: Fri, 17 Dec 2010 15:32:07 +0000 Subject: [PATCH 063/181] [PSDK] - Oleg Baikalow: Add missing definitions to ipexport.h. svn path=/trunk/; revision=50053 --- reactos/include/psdk/ipexport.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/reactos/include/psdk/ipexport.h b/reactos/include/psdk/ipexport.h index e666e88ab8a..29995869dbd 100644 --- a/reactos/include/psdk/ipexport.h +++ b/reactos/include/psdk/ipexport.h @@ -91,6 +91,18 @@ typedef struct icmp_echo_reply ICMP_ECHO_REPLY, *PICMP_ECHO_REPLY; #define IP_SPEC_MTU_CHANGE (IP_STATUS_BASE + 20) #define IP_MTU_CHANGE (IP_STATUS_BASE + 21) #define IP_UNLOAD (IP_STATUS_BASE + 22) +#define IP_ADDR_ADDED (IP_STATUS_BASE + 23) +#define IP_MEDIA_CONNECT (IP_STATUS_BASE + 24) +#define IP_MEDIA_DISCONNECT (IP_STATUS_BASE + 25) +#define IP_BIND_ADAPTER (IP_STATUS_BASE + 26) +#define IP_UNBIND_ADAPTER (IP_STATUS_BASE + 27) +#define IP_DEVICE_DOES_NOT_EXIST (IP_STATUS_BASE + 28) +#define IP_DUPLICATE_ADDRESS (IP_STATUS_BASE + 29) +#define IP_INTERFACE_METRIC_CHANGE (IP_STATUS_BASE + 30) +#define IP_RECONFIG_SECFLTR (IP_STATUS_BASE + 31) +#define IP_NEGOTIATING_IPSEC (IP_STATUS_BASE + 32) +#define IP_INTERFACE_WOL_CAPABILITY_CHANGE (IP_STATUS_BASE + 33) +#define IP_DUPLICATE_IPADD (IP_STATUS_BASE + 34) #define IP_GENERAL_FAILURE (IP_STATUS_BASE + 50) #define MAX_IP_STATUS IP_GENERAL_FAILURE From ec2b5bea7faf46722f9f68b8f031931b86a8c8d7 Mon Sep 17 00:00:00 2001 From: Aleksey Bragin Date: Sun, 19 Dec 2010 20:47:16 +0000 Subject: [PATCH 064/181] [WIDL] - Update to Wine-1.3.9. - Important note: Syntax of widl invocation changed slightly, so take this into account when merging to cmake branch. svn path=/trunk/; revision=50063 --- reactos/include/psdk/rpcndr.h | 11 +- reactos/tools/rbuild/backend/mingw/rules.mak | 8 +- reactos/tools/widl/client.c | 18 +- reactos/tools/widl/header.c | 8 - reactos/tools/widl/header.h | 1 + reactos/tools/widl/parser.l | 36 + reactos/tools/widl/parser.tab.c | 4643 ++++++++++-------- reactos/tools/widl/parser.tab.h | 243 +- reactos/tools/widl/parser.y | 106 +- reactos/tools/widl/parser.yy.c | 36 + reactos/tools/widl/proxy.c | 126 +- reactos/tools/widl/register.c | 283 ++ reactos/tools/widl/server.c | 82 +- reactos/tools/widl/typegen.c | 101 +- reactos/tools/widl/typegen.h | 2 +- reactos/tools/widl/utils.c | 127 + reactos/tools/widl/utils.h | 26 + reactos/tools/widl/widl.c | 47 +- reactos/tools/widl/widl.h | 4 + reactos/tools/widl/widl.rbuild | 1 + reactos/tools/widl/widltypes.h | 36 + reactos/tools/widl/write_msft.c | 136 +- 22 files changed, 3581 insertions(+), 2500 deletions(-) create mode 100644 reactos/tools/widl/register.c diff --git a/reactos/include/psdk/rpcndr.h b/reactos/include/psdk/rpcndr.h index 0164200b98a..dd3a532b342 100644 --- a/reactos/include/psdk/rpcndr.h +++ b/reactos/include/psdk/rpcndr.h @@ -17,26 +17,24 @@ */ #ifndef __RPCNDR_H_VERSION__ -/* FIXME: What version? Perhaps something is better than nothing, however incorrect */ -#define __RPCNDR_H_VERSION__ ( 399 ) +#define __RPCNDR_H_VERSION__ ( 500 ) #endif #ifndef __WINE_RPCNDR_H #define __WINE_RPCNDR_H +#include + #ifdef __cplusplus extern "C" { #endif -#include - #ifdef _MSC_VER #pragma warning(push) #pragma warning(disable:4201) #pragma warning(disable:4255) #pragma warning(disable:4820) #endif - #undef CONST_VTBL #ifdef CONST_VTABLE # define CONST_VTBL const @@ -118,6 +116,9 @@ typedef unsigned char boolean; #define midl_user_free MIDL_user_free #define midl_user_allocate MIDL_user_allocate +void * __RPC_USER MIDL_user_allocate(SIZE_T); +void __RPC_USER MIDL_user_free(void *); + #define NdrFcShort(s) (unsigned char)(s & 0xff), (unsigned char)(s >> 8) #define NdrFcLong(s) (unsigned char)(s & 0xff), (unsigned char)((s & 0x0000ff00) >> 8), \ (unsigned char)((s & 0x00ff0000) >> 16), (unsigned char)(s >> 24) diff --git a/reactos/tools/rbuild/backend/mingw/rules.mak b/reactos/tools/rbuild/backend/mingw/rules.mak index 9990a02ba5a..c1eb6367a33 100644 --- a/reactos/tools/rbuild/backend/mingw/rules.mak +++ b/reactos/tools/rbuild/backend/mingw/rules.mak @@ -251,7 +251,7 @@ $(2): $${$(1)_precondition} ${call RBUILD_intermediate_path_noext,$(2)}.h: $(2) $(3) $$(widl_TARGET) | ${call RBUILD_intermediate_dir,$(2)} $$(ECHO_WIDL) - $$(Q)$$(widl_TARGET) ${call RBUILD_midlflags,$(1),$(4),-I${call RBUILD_dir,$(2)}} -h -H $$@ $$< + $$(Q)$$(widl_TARGET) ${call RBUILD_midlflags,$(1),$(4),-I${call RBUILD_dir,$(2)}} -h -o $$@ $$< endef @@ -310,7 +310,7 @@ $(2): $${$(1)_precondition} ${call RBUILD_intermediate_path_noext,$(2)}_i.c: $(2) $(3) $$(widl_TARGET) | ${call RBUILD_intermediate_dir,$(2)} $$(ECHO_WIDL) - $$(Q)$$(widl_TARGET) ${call RBUILD_midlflags,$(1),$(4),-I${call RBUILD_dir,$(2)}} -u -U $$@ $$< + $$(Q)$$(widl_TARGET) ${call RBUILD_midlflags,$(1),$(4),-I${call RBUILD_dir,$(2)}} -u -o $$@ $$< ${call RBUILD_CC,$(1),${call RBUILD_intermediate_path_noext,$(2)}_i.c,,,${call RBUILD_intermediate_path_noext,$(2)}_i.o} @@ -322,7 +322,7 @@ define RBUILD_WIDL_DLLDATA_RULE $(2): $(3) ${$(1)_precondition} $$(widl_TARGET) | ${call RBUILD_intermediate_dir,$(2)} $$(ECHO_WIDL) - $$(Q)$$(widl_TARGET) ${call RBUILD_midlflags,$(1),$(4)} --dlldata-only --dlldata=$(2) $(5) + $$(Q)$$(widl_TARGET) ${call RBUILD_midlflags,$(1),$(4)} --dlldata-only -o $(2) $(5) ${call RBUILD_CC,$(1),$(2),,,${call RBUILD_intermediate_path_noext,$(2)}.o} @@ -335,7 +335,7 @@ $(2): $${$(1)_precondition} ${call RBUILD_intermediate_dir,$(2)}$$(SEP)$(1).tlb: $(2) $(3) $$(widl_TARGET) | ${call RBUILD_intermediate_dir,$(2)} $$(ECHO_WIDL) - $$(Q)$$(widl_TARGET) ${call RBUILD_midlflags,$(1),$(4),-I${call RBUILD_dir,$(2)}} -t -T $$@ $$< + $$(Q)$$(widl_TARGET) ${call RBUILD_midlflags,$(1),$(4),-I${call RBUILD_dir,$(2)}} -t -o $$@ $$< endef diff --git a/reactos/tools/widl/client.c b/reactos/tools/widl/client.c index 569a18b434d..b5ac0ae4675 100644 --- a/reactos/tools/widl/client.c +++ b/reactos/tools/widl/client.c @@ -76,7 +76,6 @@ static void write_function_stubs(type_t *iface, unsigned int *proc_offset) { const statement_t *stmt; const char *implicit_handle = get_attrp(iface->attrs, ATTR_IMPLICIT_HANDLE); - const var_t *var; int method_count = 0; if (!implicit_handle) @@ -297,15 +296,7 @@ static void write_function_stubs(type_t *iface, unsigned int *proc_offset) } /* update proc_offset */ - if (args) - { - LIST_FOR_EACH_ENTRY( var, args, const var_t, entry ) - *proc_offset += get_size_procformatstring_type(var->name, var->type, var->attrs); - } - if (!is_void(type_function_get_rettype(func->type))) - *proc_offset += get_size_procformatstring_type("return value", type_function_get_rettype(func->type), NULL); - else - *proc_offset += 2; /* FC_END and FC_PAD */ + *proc_offset += get_size_procformatstring_func( func ); indent--; print_client("}\n"); @@ -457,8 +448,6 @@ static void init_client(void) print_client( "#define DECLSPEC_HIDDEN\n"); print_client( "#endif\n"); print_client( "\n"); - write_exceptions( client ); - print_client( "\n"); } @@ -512,6 +501,9 @@ static void write_client_routines(const statement_list_t *stmts) unsigned int proc_offset = 0; int expr_eval_routines; + write_exceptions( client ); + print_client( "\n"); + write_formatstringsdecl(client, indent, stmts, need_stub); expr_eval_routines = write_expr_eval_routines(client, client_token); if (expr_eval_routines) @@ -539,7 +531,7 @@ void write_client(const statement_list_t *stmts) if (do_win32 && do_win64) { - fprintf(client, "\n#ifndef _WIN64\n\n"); + fprintf(client, "#ifndef _WIN64\n\n"); pointer_size = 4; write_client_routines( stmts ); fprintf(client, "\n#else /* _WIN64 */\n\n"); diff --git a/reactos/tools/widl/header.c b/reactos/tools/widl/header.c index eaef86749cf..e0322c62fd1 100644 --- a/reactos/tools/widl/header.c +++ b/reactos/tools/widl/header.c @@ -1081,14 +1081,6 @@ static void write_rpc_interface_start(FILE *header, const type_t *iface) { unsigned int ver = get_attrv(iface->attrs, ATTR_VERSION); const char *var = get_attrp(iface->attrs, ATTR_IMPLICIT_HANDLE); - static int allocate_written = 0; - - if (!allocate_written) - { - allocate_written = 1; - fprintf(header, "void * __RPC_USER MIDL_user_allocate(SIZE_T);\n"); - fprintf(header, "void __RPC_USER MIDL_user_free(void *);\n\n"); - } fprintf(header, "/*****************************************************************************\n"); fprintf(header, " * %s interface (v%d.%d)\n", iface->name, MAJORVERSION(ver), MINORVERSION(ver)); diff --git a/reactos/tools/widl/header.h b/reactos/tools/widl/header.h index 2175f5ecc32..6a37192f395 100644 --- a/reactos/tools/widl/header.h +++ b/reactos/tools/widl/header.h @@ -39,6 +39,7 @@ extern void write_type_decl_left(FILE *f, type_t *t); extern int needs_space_after(type_t *t); extern int is_object(const type_t *iface); extern int is_local(const attr_list_t *list); +extern int count_methods(const type_t *iface); extern int need_stub(const type_t *iface); extern int need_proxy(const type_t *iface); extern int need_stub_files(const statement_list_t *stmts); diff --git a/reactos/tools/widl/parser.l b/reactos/tools/widl/parser.l index e7673d10256..3a535e829fa 100644 --- a/reactos/tools/widl/parser.l +++ b/reactos/tools/widl/parser.l @@ -289,11 +289,13 @@ static const struct keyword attr_keywords[] = {"aggregatable", tAGGREGATABLE}, {"allocate", tALLOCATE}, {"annotation", tANNOTATION}, + {"apartment", tAPARTMENT}, {"appobject", tAPPOBJECT}, {"async", tASYNC}, {"async_uuid", tASYNCUUID}, {"auto_handle", tAUTOHANDLE}, {"bindable", tBINDABLE}, + {"both", tBOTH}, {"broadcast", tBROADCAST}, {"byte_count", tBYTECOUNT}, {"call_as", tCALLAS}, @@ -304,15 +306,23 @@ static const struct keyword attr_keywords[] = {"context_handle_noserialize", tCONTEXTHANDLENOSERIALIZE}, {"context_handle_serialize", tCONTEXTHANDLENOSERIALIZE}, {"control", tCONTROL}, + {"decode", tDECODE}, + {"defaultbind", tDEFAULTBIND}, {"defaultcollelem", tDEFAULTCOLLELEM}, {"defaultvalue", tDEFAULTVALUE}, {"defaultvtable", tDEFAULTVTABLE}, + {"disable_consistency_check", tDISABLECONSISTENCYCHECK}, {"displaybind", tDISPLAYBIND}, {"dllname", tDLLNAME}, {"dual", tDUAL}, + {"enable_allocate", tENABLEALLOCATE}, + {"encode", tENCODE}, {"endpoint", tENDPOINT}, {"entry", tENTRY}, {"explicit_handle", tEXPLICITHANDLE}, + {"fault_status", tFAULTSTATUS}, + {"force_allocate", tFORCEALLOCATE}, + {"free", tFREE}, {"handle", tHANDLE}, {"helpcontext", tHELPCONTEXT}, {"helpfile", tHELPFILE}, @@ -322,6 +332,7 @@ static const struct keyword attr_keywords[] = {"hidden", tHIDDEN}, {"id", tID}, {"idempotent", tIDEMPOTENT}, + {"ignore", tIGNORE}, {"iid_is", tIIDIS}, {"immediatebind", tIMMEDIATEBIND}, {"implicit_handle", tIMPLICITHANDLE}, @@ -330,42 +341,67 @@ static const struct keyword attr_keywords[] = {"input_sync", tINPUTSYNC}, {"lcid", tLCID}, {"length_is", tLENGTHIS}, + {"licensed", tLICENSED}, {"local", tLOCAL}, + {"maybe", tMAYBE}, + {"message", tMESSAGE}, + {"neutral", tNEUTRAL}, + {"nocode", tNOCODE}, {"nonbrowsable", tNONBROWSABLE}, {"noncreatable", tNONCREATABLE}, {"nonextensible", tNONEXTENSIBLE}, + {"notify", tNOTIFY}, + {"notify_flag", tNOTIFYFLAG}, {"object", tOBJECT}, {"odl", tODL}, {"oleautomation", tOLEAUTOMATION}, + {"optimize", tOPTIMIZE}, {"optional", tOPTIONAL}, {"out", tOUT}, + {"partial_ignore", tPARTIALIGNORE}, {"pointer_default", tPOINTERDEFAULT}, + {"progid", tPROGID}, {"propget", tPROPGET}, {"propput", tPROPPUT}, {"propputref", tPROPPUTREF}, + {"proxy", tPROXY}, {"ptr", tPTR}, {"public", tPUBLIC}, {"range", tRANGE}, {"readonly", tREADONLY}, {"ref", tREF}, + {"represent_as", tREPRESENTAS}, {"requestedit", tREQUESTEDIT}, {"restricted", tRESTRICTED}, {"retval", tRETVAL}, + {"single", tSINGLE}, {"size_is", tSIZEIS}, {"source", tSOURCE}, {"strict_context_handle", tSTRICTCONTEXTHANDLE}, {"string", tSTRING}, {"switch_is", tSWITCHIS}, {"switch_type", tSWITCHTYPE}, + {"threading", tTHREADING}, {"transmit_as", tTRANSMITAS}, + {"uidefault", tUIDEFAULT}, {"unique", tUNIQUE}, + {"user_marshal", tUSERMARSHAL}, + {"usesgetlasterror", tUSESGETLASTERROR}, {"uuid", tUUID}, {"v1_enum", tV1ENUM}, {"vararg", tVARARG}, {"version", tVERSION}, + {"vi_progid", tVIPROGID}, {"wire_marshal", tWIREMARSHAL}, }; +/* attributes TODO: + custom + first_is + last_is + max_is + min_is +*/ #define KWP(p) ((const struct keyword *)(p)) diff --git a/reactos/tools/widl/parser.tab.c b/reactos/tools/widl/parser.tab.c index 5c9137bfdf4..3df4c104073 100644 --- a/reactos/tools/widl/parser.tab.c +++ b/reactos/tools/widl/parser.tab.c @@ -304,112 +304,141 @@ static statement_list_t *append_statement(statement_list_t *list, statement_t *s tCONTEXTHANDLESERIALIZE = 301, tCONTROL = 302, tCPPQUOTE = 303, - tDEFAULT = 304, - tDEFAULTCOLLELEM = 305, - tDEFAULTVALUE = 306, - tDEFAULTVTABLE = 307, - tDISPLAYBIND = 308, - tDISPINTERFACE = 309, - tDLLNAME = 310, - tDOUBLE = 311, - tDUAL = 312, - tENDPOINT = 313, - tENTRY = 314, - tENUM = 315, - tERRORSTATUST = 316, - tEXPLICITHANDLE = 317, - tEXTERN = 318, - tFALSE = 319, - tFASTCALL = 320, - tFLOAT = 321, - tHANDLE = 322, - tHANDLET = 323, - tHELPCONTEXT = 324, - tHELPFILE = 325, - tHELPSTRING = 326, - tHELPSTRINGCONTEXT = 327, - tHELPSTRINGDLL = 328, - tHIDDEN = 329, - tHYPER = 330, - tID = 331, - tIDEMPOTENT = 332, - tIIDIS = 333, - tIMMEDIATEBIND = 334, - tIMPLICITHANDLE = 335, - tIMPORT = 336, - tIMPORTLIB = 337, - tIN = 338, - tIN_LINE = 339, - tINLINE = 340, - tINPUTSYNC = 341, - tINT = 342, - tINT3264 = 343, - tINT64 = 344, - tINTERFACE = 345, - tLCID = 346, - tLENGTHIS = 347, - tLIBRARY = 348, - tLOCAL = 349, - tLONG = 350, - tMETHODS = 351, - tMODULE = 352, - tNONBROWSABLE = 353, - tNONCREATABLE = 354, - tNONEXTENSIBLE = 355, - tNULL = 356, - tOBJECT = 357, - tODL = 358, - tOLEAUTOMATION = 359, - tOPTIONAL = 360, - tOUT = 361, - tPASCAL = 362, - tPOINTERDEFAULT = 363, - tPROPERTIES = 364, - tPROPGET = 365, - tPROPPUT = 366, - tPROPPUTREF = 367, - tPTR = 368, - tPUBLIC = 369, - tRANGE = 370, - tREADONLY = 371, - tREF = 372, - tREGISTER = 373, - tREQUESTEDIT = 374, - tRESTRICTED = 375, - tRETVAL = 376, - tSAFEARRAY = 377, - tSHORT = 378, - tSIGNED = 379, - tSIZEIS = 380, - tSIZEOF = 381, - tSMALL = 382, - tSOURCE = 383, - tSTATIC = 384, - tSTDCALL = 385, - tSTRICTCONTEXTHANDLE = 386, - tSTRING = 387, - tSTRUCT = 388, - tSWITCH = 389, - tSWITCHIS = 390, - tSWITCHTYPE = 391, - tTRANSMITAS = 392, - tTRUE = 393, - tTYPEDEF = 394, - tUNION = 395, - tUNIQUE = 396, - tUNSIGNED = 397, - tUUID = 398, - tV1ENUM = 399, - tVARARG = 400, - tVERSION = 401, - tVOID = 402, - tWCHAR = 403, - tWIREMARSHAL = 404, - ADDRESSOF = 405, - NEG = 406, - POS = 407, - PPTR = 408, - CAST = 409 + tDECODE = 304, + tDEFAULT = 305, + tDEFAULTBIND = 306, + tDEFAULTCOLLELEM = 307, + tDEFAULTVALUE = 308, + tDEFAULTVTABLE = 309, + tDISABLECONSISTENCYCHECK = 310, + tDISPLAYBIND = 311, + tDISPINTERFACE = 312, + tDLLNAME = 313, + tDOUBLE = 314, + tDUAL = 315, + tENABLEALLOCATE = 316, + tENCODE = 317, + tENDPOINT = 318, + tENTRY = 319, + tENUM = 320, + tERRORSTATUST = 321, + tEXPLICITHANDLE = 322, + tEXTERN = 323, + tFALSE = 324, + tFASTCALL = 325, + tFAULTSTATUS = 326, + tFLOAT = 327, + tFORCEALLOCATE = 328, + tHANDLE = 329, + tHANDLET = 330, + tHELPCONTEXT = 331, + tHELPFILE = 332, + tHELPSTRING = 333, + tHELPSTRINGCONTEXT = 334, + tHELPSTRINGDLL = 335, + tHIDDEN = 336, + tHYPER = 337, + tID = 338, + tIDEMPOTENT = 339, + tIGNORE = 340, + tIIDIS = 341, + tIMMEDIATEBIND = 342, + tIMPLICITHANDLE = 343, + tIMPORT = 344, + tIMPORTLIB = 345, + tIN = 346, + tIN_LINE = 347, + tINLINE = 348, + tINPUTSYNC = 349, + tINT = 350, + tINT3264 = 351, + tINT64 = 352, + tINTERFACE = 353, + tLCID = 354, + tLENGTHIS = 355, + tLIBRARY = 356, + tLICENSED = 357, + tLOCAL = 358, + tLONG = 359, + tMAYBE = 360, + tMESSAGE = 361, + tMETHODS = 362, + tMODULE = 363, + tNOCODE = 364, + tNONBROWSABLE = 365, + tNONCREATABLE = 366, + tNONEXTENSIBLE = 367, + tNOTIFY = 368, + tNOTIFYFLAG = 369, + tNULL = 370, + tOBJECT = 371, + tODL = 372, + tOLEAUTOMATION = 373, + tOPTIMIZE = 374, + tOPTIONAL = 375, + tOUT = 376, + tPARTIALIGNORE = 377, + tPASCAL = 378, + tPOINTERDEFAULT = 379, + tPROGID = 380, + tPROPERTIES = 381, + tPROPGET = 382, + tPROPPUT = 383, + tPROPPUTREF = 384, + tPROXY = 385, + tPTR = 386, + tPUBLIC = 387, + tRANGE = 388, + tREADONLY = 389, + tREF = 390, + tREGISTER = 391, + tREPRESENTAS = 392, + tREQUESTEDIT = 393, + tRESTRICTED = 394, + tRETVAL = 395, + tSAFEARRAY = 396, + tSHORT = 397, + tSIGNED = 398, + tSIZEIS = 399, + tSIZEOF = 400, + tSMALL = 401, + tSOURCE = 402, + tSTATIC = 403, + tSTDCALL = 404, + tSTRICTCONTEXTHANDLE = 405, + tSTRING = 406, + tSTRUCT = 407, + tSWITCH = 408, + tSWITCHIS = 409, + tSWITCHTYPE = 410, + tTHREADING = 411, + tTRANSMITAS = 412, + tTRUE = 413, + tTYPEDEF = 414, + tUIDEFAULT = 415, + tUNION = 416, + tUNIQUE = 417, + tUNSIGNED = 418, + tUSESGETLASTERROR = 419, + tUSERMARSHAL = 420, + tUUID = 421, + tV1ENUM = 422, + tVARARG = 423, + tVERSION = 424, + tVIPROGID = 425, + tVOID = 426, + tWCHAR = 427, + tWIREMARSHAL = 428, + tAPARTMENT = 429, + tNEUTRAL = 430, + tSINGLE = 431, + tFREE = 432, + tBOTH = 433, + ADDRESSOF = 434, + NEG = 435, + POS = 436, + PPTR = 437, + CAST = 438 }; #endif @@ -450,7 +479,7 @@ typedef union YYSTYPE /* Line 214 of yacc.c */ -#line 454 "parser.tab.c" +#line 483 "parser.tab.c" } YYSTYPE; # define YYSTYPE_IS_TRIVIAL 1 # define yystype YYSTYPE /* obsolescent; will be withdrawn */ @@ -462,7 +491,7 @@ typedef union YYSTYPE /* Line 264 of yacc.c */ -#line 466 "parser.tab.c" +#line 495 "parser.tab.c" #ifdef short # undef short @@ -677,20 +706,20 @@ union yyalloc /* YYFINAL -- State number of the termination state. */ #define YYFINAL 3 /* YYLAST -- Last index in YYTABLE. */ -#define YYLAST 2469 +#define YYLAST 2650 /* YYNTOKENS -- Number of terminals. */ -#define YYNTOKENS 179 +#define YYNTOKENS 208 /* YYNNTS -- Number of nonterminals. */ -#define YYNNTS 99 +#define YYNNTS 100 /* YYNRULES -- Number of rules. */ -#define YYNRULES 345 +#define YYNRULES 376 /* YYNRULES -- Number of states. */ -#define YYNSTATES 606 +#define YYNSTATES 655 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ #define YYUNDEFTOK 2 -#define YYMAXUTOK 409 +#define YYMAXUTOK 438 #define YYTRANSLATE(YYX) \ ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) @@ -701,16 +730,16 @@ static const yytype_uint8 yytranslate[] = 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 163, 2, 2, 2, 162, 155, 2, - 174, 175, 160, 159, 150, 158, 170, 161, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 152, 173, - 156, 178, 157, 151, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 192, 2, 2, 2, 191, 184, 2, + 203, 204, 189, 188, 179, 187, 199, 190, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 181, 202, + 185, 207, 186, 180, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 171, 2, 172, 154, 2, 2, 2, 2, 2, + 2, 200, 2, 201, 183, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 176, 153, 177, 164, 2, 2, 2, + 2, 2, 2, 205, 182, 206, 193, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, @@ -738,7 +767,10 @@ static const yytype_uint8 yytranslate[] = 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, - 145, 146, 147, 148, 149, 165, 166, 167, 168, 169 + 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, + 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, + 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, + 175, 176, 177, 178, 194, 195, 196, 197, 198 }; #if YYDEBUG @@ -753,184 +785,198 @@ static const yytype_uint16 yyprhs[] = 111, 115, 120, 121, 123, 125, 129, 131, 135, 139, 142, 146, 150, 151, 153, 157, 159, 163, 168, 170, 174, 175, 177, 182, 184, 186, 188, 190, 192, 197, - 202, 204, 206, 208, 210, 212, 214, 219, 221, 223, - 228, 230, 235, 240, 242, 244, 249, 254, 259, 264, - 269, 271, 276, 278, 283, 285, 291, 293, 295, 300, - 305, 307, 309, 311, 313, 315, 317, 319, 321, 323, - 325, 330, 332, 334, 336, 338, 345, 347, 349, 351, - 353, 358, 360, 362, 364, 369, 374, 379, 384, 386, - 388, 393, 398, 400, 402, 404, 406, 408, 410, 412, - 413, 416, 421, 425, 426, 429, 431, 433, 437, 441, - 443, 449, 451, 455, 456, 458, 460, 462, 464, 466, - 468, 470, 472, 474, 476, 478, 484, 488, 492, 496, - 500, 504, 508, 512, 516, 520, 524, 528, 532, 536, - 540, 544, 548, 552, 556, 559, 562, 565, 568, 571, - 574, 578, 582, 588, 594, 599, 603, 605, 609, 611, - 613, 614, 617, 622, 626, 629, 632, 633, 636, 639, - 641, 645, 647, 651, 654, 655, 657, 658, 660, 662, - 664, 666, 668, 670, 672, 675, 678, 680, 682, 684, - 686, 688, 690, 691, 693, 695, 698, 700, 703, 706, - 708, 710, 712, 715, 718, 721, 727, 728, 731, 734, - 737, 740, 743, 746, 750, 753, 757, 763, 769, 770, - 773, 776, 779, 782, 789, 798, 801, 804, 807, 810, - 813, 816, 822, 824, 826, 828, 830, 832, 833, 836, - 839, 843, 844, 846, 849, 852, 855, 859, 862, 864, - 866, 870, 873, 878, 882, 885, 887, 891, 894, 895, - 897, 901, 904, 906, 910, 915, 919, 922, 924, 928, - 931, 932, 934, 936, 940, 943, 945, 949, 954, 956, - 960, 961, 964, 967, 969, 973, 975, 979, 981, 983, - 985, 991, 993, 995, 997, 999, 1002, 1004, 1007, 1009, - 1012, 1017, 1022, 1028, 1039, 1041 + 202, 204, 206, 208, 210, 212, 214, 216, 218, 220, + 222, 227, 229, 231, 233, 238, 240, 242, 244, 249, + 254, 256, 258, 260, 262, 267, 272, 277, 282, 287, + 289, 294, 296, 298, 303, 305, 311, 313, 315, 320, + 325, 327, 329, 331, 333, 335, 337, 339, 341, 343, + 345, 347, 349, 351, 353, 358, 360, 362, 364, 369, + 374, 376, 378, 380, 382, 384, 391, 393, 398, 400, + 402, 404, 409, 411, 413, 415, 420, 425, 430, 435, + 437, 439, 444, 449, 451, 453, 458, 463, 468, 470, + 472, 474, 476, 478, 480, 482, 483, 486, 491, 495, + 496, 499, 501, 503, 507, 511, 513, 519, 521, 525, + 526, 528, 530, 532, 534, 536, 538, 540, 542, 544, + 546, 548, 554, 558, 562, 566, 570, 574, 578, 582, + 586, 590, 594, 598, 602, 606, 610, 614, 618, 622, + 626, 629, 632, 635, 638, 641, 644, 648, 652, 658, + 664, 669, 673, 675, 679, 681, 683, 684, 687, 692, + 696, 699, 702, 703, 706, 709, 711, 715, 717, 721, + 724, 725, 727, 728, 730, 732, 734, 736, 738, 740, + 742, 745, 748, 750, 752, 754, 756, 758, 760, 761, + 763, 765, 768, 770, 773, 776, 778, 780, 782, 785, + 788, 791, 797, 798, 801, 804, 807, 810, 813, 816, + 820, 823, 827, 833, 839, 840, 843, 846, 849, 852, + 859, 868, 871, 874, 877, 880, 883, 886, 892, 894, + 896, 898, 900, 902, 903, 906, 909, 913, 914, 916, + 919, 922, 925, 929, 932, 934, 936, 940, 943, 948, + 952, 955, 957, 961, 964, 965, 967, 971, 974, 976, + 980, 985, 989, 992, 994, 998, 1001, 1002, 1004, 1006, + 1010, 1013, 1015, 1019, 1024, 1026, 1030, 1031, 1034, 1037, + 1039, 1043, 1045, 1049, 1051, 1053, 1055, 1057, 1059, 1061, + 1063, 1065, 1071, 1073, 1075, 1077, 1079, 1082, 1084, 1087, + 1089, 1092, 1097, 1102, 1108, 1119, 1121 }; /* YYRHS -- A `-1'-separated list of the rules' RHS. */ static const yytype_int16 yyrhs[] = { - 180, 0, -1, 181, -1, -1, 181, 246, -1, 181, - 245, -1, 181, 232, 173, -1, 181, 234, -1, 181, - 249, -1, 181, 193, -1, 181, 185, -1, -1, 182, - 246, -1, 182, 245, -1, 182, 232, 173, -1, 182, - 234, -1, 182, 249, -1, 182, 185, -1, 182, 190, - -1, 182, 193, -1, -1, 183, 185, -1, -1, 173, - -1, 187, -1, 186, 173, -1, 225, 173, -1, 189, - -1, 275, 173, -1, 211, -1, 273, -1, 276, -1, - 200, 211, -1, 200, 273, -1, 200, 276, -1, 48, - 174, 8, 175, -1, 81, 8, 173, -1, 188, 182, - 12, -1, 82, 174, 8, 175, 184, -1, 93, 3, - -1, 200, 191, 176, -1, 192, 182, 177, 184, -1, - -1, 196, -1, 197, -1, 195, 150, 197, -1, 195, - -1, 195, 150, 22, -1, 200, 254, 265, -1, 254, - 265, -1, 171, 213, 172, -1, 171, 160, 172, -1, - -1, 200, -1, 171, 201, 172, -1, 203, -1, 201, - 150, 203, -1, 201, 172, 171, 203, -1, 8, -1, - 202, 150, 8, -1, -1, 23, -1, 25, 174, 8, - 175, -1, 26, -1, 27, -1, 29, -1, 30, -1, - 32, -1, 35, 174, 228, 175, -1, 37, 174, 215, - 175, -1, 44, -1, 45, -1, 46, -1, 47, -1, - 49, -1, 50, -1, 51, 174, 217, 175, -1, 52, - -1, 53, -1, 55, 174, 8, 175, -1, 57, -1, - 58, 174, 202, 175, -1, 59, 174, 217, 175, -1, - 62, -1, 67, -1, 69, 174, 216, 175, -1, 70, - 174, 8, 175, -1, 71, 174, 8, 175, -1, 72, - 174, 216, 175, -1, 73, 174, 8, 175, -1, 74, - -1, 76, 174, 216, 175, -1, 77, -1, 78, 174, - 214, 175, -1, 79, -1, 80, 174, 68, 3, 175, - -1, 83, -1, 86, -1, 92, 174, 212, 175, -1, - 91, 174, 216, 175, -1, 91, -1, 94, -1, 98, - -1, 99, -1, 100, -1, 102, -1, 103, -1, 104, - -1, 105, -1, 106, -1, 108, 174, 272, 175, -1, - 110, -1, 111, -1, 112, -1, 114, -1, 115, 174, - 216, 150, 216, 175, -1, 116, -1, 119, -1, 120, - -1, 121, -1, 125, 174, 212, 175, -1, 128, -1, - 131, -1, 132, -1, 135, 174, 214, 175, -1, 136, - 174, 274, 175, -1, 137, 174, 274, 175, -1, 143, - 174, 204, 175, -1, 144, -1, 145, -1, 146, 174, - 277, 175, -1, 149, 174, 274, 175, -1, 272, -1, - 11, -1, 8, -1, 38, -1, 65, -1, 107, -1, - 130, -1, -1, 206, 207, -1, 37, 216, 152, 222, - -1, 49, 152, 222, -1, -1, 209, 150, -1, 209, - -1, 210, -1, 209, 150, 210, -1, 228, 178, 216, - -1, 228, -1, 60, 227, 176, 208, 177, -1, 213, - -1, 212, 150, 213, -1, -1, 214, -1, 5, -1, - 6, -1, 7, -1, 64, -1, 101, -1, 138, -1, - 8, -1, 9, -1, 10, -1, 3, -1, 214, 151, - 214, 152, 214, -1, 214, 20, 214, -1, 214, 21, - 214, -1, 214, 153, 214, -1, 214, 154, 214, -1, - 214, 155, 214, -1, 214, 16, 214, -1, 214, 17, - 214, -1, 214, 157, 214, -1, 214, 156, 214, -1, - 214, 18, 214, -1, 214, 19, 214, -1, 214, 13, - 214, -1, 214, 14, 214, -1, 214, 159, 214, -1, - 214, 158, 214, -1, 214, 162, 214, -1, 214, 160, - 214, -1, 214, 161, 214, -1, 163, 214, -1, 164, - 214, -1, 159, 214, -1, 158, 214, -1, 155, 214, - -1, 160, 214, -1, 214, 15, 3, -1, 214, 170, - 3, -1, 174, 254, 261, 175, 214, -1, 126, 174, - 254, 261, 175, -1, 214, 171, 214, 172, -1, 174, - 214, 175, -1, 216, -1, 215, 150, 216, -1, 214, - -1, 214, -1, -1, 218, 219, -1, 199, 254, 270, - 173, -1, 199, 276, 173, -1, 223, 173, -1, 200, - 173, -1, -1, 221, 220, -1, 223, 173, -1, 173, - -1, 199, 254, 257, -1, 225, -1, 200, 254, 271, - -1, 254, 271, -1, -1, 228, -1, -1, 3, -1, - 4, -1, 3, -1, 4, -1, 33, -1, 148, -1, - 231, -1, 124, 231, -1, 142, 231, -1, 142, -1, - 66, -1, 56, -1, 31, -1, 61, -1, 68, -1, - -1, 87, -1, 87, -1, 123, 230, -1, 127, -1, - 95, 230, -1, 75, 230, -1, 89, -1, 39, -1, - 88, -1, 40, 3, -1, 40, 4, -1, 200, 232, - -1, 233, 176, 235, 177, 184, -1, -1, 235, 236, - -1, 199, 246, -1, 54, 3, -1, 54, 4, -1, - 200, 237, -1, 109, 152, -1, 239, 223, 173, -1, - 96, 152, -1, 240, 224, 173, -1, 238, 176, 239, - 240, 177, -1, 238, 176, 243, 173, 177, -1, -1, - 152, 4, -1, 90, 3, -1, 90, 4, -1, 200, - 243, -1, 244, 242, 176, 183, 177, 184, -1, 244, - 152, 3, 176, 189, 183, 177, 184, -1, 241, 184, - -1, 243, 173, -1, 237, 173, -1, 97, 3, -1, - 97, 4, -1, 200, 247, -1, 248, 176, 183, 177, - 184, -1, 63, -1, 129, -1, 118, -1, 85, -1, - 43, -1, -1, 253, 252, -1, 274, 255, -1, 256, - 274, 255, -1, -1, 256, -1, 252, 255, -1, 251, - 255, -1, 250, 255, -1, 160, 253, 257, -1, 205, - 257, -1, 258, -1, 228, -1, 174, 257, 175, -1, - 258, 198, -1, 258, 174, 194, 175, -1, 160, 253, - 261, -1, 205, 261, -1, 262, -1, 160, 253, 265, - -1, 205, 265, -1, -1, 259, -1, 174, 260, 175, - -1, 262, 198, -1, 198, -1, 174, 194, 175, -1, - 262, 174, 194, 175, -1, 160, 253, 265, -1, 205, - 265, -1, 266, -1, 160, 253, 265, -1, 205, 265, - -1, -1, 263, -1, 228, -1, 174, 264, 175, -1, - 266, 198, -1, 198, -1, 174, 194, 175, -1, 266, - 174, 194, 175, -1, 257, -1, 267, 150, 257, -1, - -1, 152, 217, -1, 263, 268, -1, 269, -1, 270, - 150, 269, -1, 257, -1, 257, 178, 217, -1, 117, - -1, 141, -1, 113, -1, 133, 227, 176, 218, 177, - -1, 147, -1, 4, -1, 229, -1, 211, -1, 60, - 3, -1, 273, -1, 133, 3, -1, 276, -1, 140, - 3, -1, 122, 174, 274, 175, -1, 139, 199, 254, - 267, -1, 140, 227, 176, 221, 177, -1, 140, 227, - 134, 174, 223, 175, 226, 176, 206, 177, -1, 5, - -1, 5, 170, 5, -1 + 209, 0, -1, 210, -1, -1, 210, 275, -1, 210, + 274, -1, 210, 261, 202, -1, 210, 263, -1, 210, + 278, -1, 210, 222, -1, 210, 214, -1, -1, 211, + 275, -1, 211, 274, -1, 211, 261, 202, -1, 211, + 263, -1, 211, 278, -1, 211, 214, -1, 211, 219, + -1, 211, 222, -1, -1, 212, 214, -1, -1, 202, + -1, 216, -1, 215, 202, -1, 254, 202, -1, 218, + -1, 305, 202, -1, 240, -1, 303, -1, 306, -1, + 229, 240, -1, 229, 303, -1, 229, 306, -1, 48, + 203, 8, 204, -1, 89, 8, 202, -1, 217, 211, + 12, -1, 90, 203, 8, 204, 213, -1, 101, 3, + -1, 229, 220, 205, -1, 221, 211, 206, 213, -1, + -1, 225, -1, 226, -1, 224, 179, 226, -1, 224, + -1, 224, 179, 22, -1, 229, 283, 294, -1, 283, + 294, -1, 200, 242, 201, -1, 200, 189, 201, -1, + -1, 229, -1, 200, 230, 201, -1, 232, -1, 230, + 179, 232, -1, 230, 201, 200, 232, -1, 8, -1, + 231, 179, 8, -1, -1, 23, -1, 25, 203, 8, + 204, -1, 26, -1, 27, -1, 29, -1, 30, -1, + 32, -1, 35, 203, 257, 204, -1, 37, 203, 244, + 204, -1, 41, -1, 42, -1, 44, -1, 45, -1, + 46, -1, 47, -1, 49, -1, 50, -1, 51, -1, + 52, -1, 53, 203, 246, 204, -1, 54, -1, 55, + -1, 56, -1, 58, 203, 8, 204, -1, 60, -1, + 61, -1, 62, -1, 63, 203, 231, 204, -1, 64, + 203, 246, 204, -1, 67, -1, 71, -1, 73, -1, + 74, -1, 76, 203, 245, 204, -1, 77, 203, 8, + 204, -1, 78, 203, 8, 204, -1, 79, 203, 245, + 204, -1, 80, 203, 8, 204, -1, 81, -1, 83, + 203, 245, 204, -1, 84, -1, 85, -1, 86, 203, + 243, 204, -1, 87, -1, 88, 203, 75, 3, 204, + -1, 91, -1, 94, -1, 100, 203, 241, 204, -1, + 99, 203, 245, 204, -1, 99, -1, 102, -1, 103, + -1, 105, -1, 106, -1, 109, -1, 110, -1, 111, + -1, 112, -1, 113, -1, 114, -1, 116, -1, 117, + -1, 118, -1, 119, 203, 8, 204, -1, 120, -1, + 121, -1, 122, -1, 124, 203, 302, 204, -1, 125, + 203, 8, 204, -1, 127, -1, 128, -1, 129, -1, + 130, -1, 132, -1, 133, 203, 245, 179, 245, 204, + -1, 134, -1, 137, 203, 304, 204, -1, 138, -1, + 139, -1, 140, -1, 144, 203, 241, 204, -1, 147, + -1, 150, -1, 151, -1, 154, 203, 243, 204, -1, + 155, 203, 304, 204, -1, 157, 203, 304, 204, -1, + 156, 203, 301, 204, -1, 160, -1, 164, -1, 165, + 203, 304, 204, -1, 166, 203, 233, 204, -1, 167, + -1, 168, -1, 169, 203, 307, 204, -1, 170, 203, + 8, 204, -1, 173, 203, 304, 204, -1, 302, -1, + 11, -1, 8, -1, 38, -1, 70, -1, 123, -1, + 149, -1, -1, 235, 236, -1, 37, 245, 181, 251, + -1, 50, 181, 251, -1, -1, 238, 179, -1, 238, + -1, 239, -1, 238, 179, 239, -1, 257, 207, 245, + -1, 257, -1, 65, 256, 205, 237, 206, -1, 242, + -1, 241, 179, 242, -1, -1, 243, -1, 5, -1, + 6, -1, 7, -1, 69, -1, 115, -1, 158, -1, + 8, -1, 9, -1, 10, -1, 3, -1, 243, 180, + 243, 181, 243, -1, 243, 20, 243, -1, 243, 21, + 243, -1, 243, 182, 243, -1, 243, 183, 243, -1, + 243, 184, 243, -1, 243, 16, 243, -1, 243, 17, + 243, -1, 243, 186, 243, -1, 243, 185, 243, -1, + 243, 18, 243, -1, 243, 19, 243, -1, 243, 13, + 243, -1, 243, 14, 243, -1, 243, 188, 243, -1, + 243, 187, 243, -1, 243, 191, 243, -1, 243, 189, + 243, -1, 243, 190, 243, -1, 192, 243, -1, 193, + 243, -1, 188, 243, -1, 187, 243, -1, 184, 243, + -1, 189, 243, -1, 243, 15, 3, -1, 243, 199, + 3, -1, 203, 283, 290, 204, 243, -1, 145, 203, + 283, 290, 204, -1, 243, 200, 243, 201, -1, 203, + 243, 204, -1, 245, -1, 244, 179, 245, -1, 243, + -1, 243, -1, -1, 247, 248, -1, 228, 283, 299, + 202, -1, 228, 306, 202, -1, 252, 202, -1, 229, + 202, -1, -1, 250, 249, -1, 252, 202, -1, 202, + -1, 228, 283, 286, -1, 254, -1, 229, 283, 300, + -1, 283, 300, -1, -1, 257, -1, -1, 3, -1, + 4, -1, 3, -1, 4, -1, 33, -1, 172, -1, + 260, -1, 143, 260, -1, 163, 260, -1, 163, -1, + 72, -1, 59, -1, 31, -1, 66, -1, 75, -1, + -1, 95, -1, 95, -1, 142, 259, -1, 146, -1, + 104, 259, -1, 82, 259, -1, 97, -1, 39, -1, + 96, -1, 40, 3, -1, 40, 4, -1, 229, 261, + -1, 262, 205, 264, 206, 213, -1, -1, 264, 265, + -1, 228, 275, -1, 57, 3, -1, 57, 4, -1, + 229, 266, -1, 126, 181, -1, 268, 252, 202, -1, + 107, 181, -1, 269, 253, 202, -1, 267, 205, 268, + 269, 206, -1, 267, 205, 272, 202, 206, -1, -1, + 181, 4, -1, 98, 3, -1, 98, 4, -1, 229, + 272, -1, 273, 271, 205, 212, 206, 213, -1, 273, + 181, 3, 205, 218, 212, 206, 213, -1, 270, 213, + -1, 272, 202, -1, 266, 202, -1, 108, 3, -1, + 108, 4, -1, 229, 276, -1, 277, 205, 212, 206, + 213, -1, 68, -1, 148, -1, 136, -1, 93, -1, + 43, -1, -1, 282, 281, -1, 304, 284, -1, 285, + 304, 284, -1, -1, 285, -1, 281, 284, -1, 280, + 284, -1, 279, 284, -1, 189, 282, 286, -1, 234, + 286, -1, 287, -1, 257, -1, 203, 286, 204, -1, + 287, 227, -1, 287, 203, 223, 204, -1, 189, 282, + 290, -1, 234, 290, -1, 291, -1, 189, 282, 294, + -1, 234, 294, -1, -1, 288, -1, 203, 289, 204, + -1, 291, 227, -1, 227, -1, 203, 223, 204, -1, + 291, 203, 223, 204, -1, 189, 282, 294, -1, 234, + 294, -1, 295, -1, 189, 282, 294, -1, 234, 294, + -1, -1, 292, -1, 257, -1, 203, 293, 204, -1, + 295, 227, -1, 227, -1, 203, 223, 204, -1, 295, + 203, 223, 204, -1, 286, -1, 296, 179, 286, -1, + -1, 181, 246, -1, 292, 297, -1, 298, -1, 299, + 179, 298, -1, 286, -1, 286, 207, 246, -1, 174, + -1, 175, -1, 176, -1, 177, -1, 178, -1, 135, + -1, 162, -1, 131, -1, 152, 256, 205, 247, 206, + -1, 171, -1, 4, -1, 258, -1, 240, -1, 65, + 3, -1, 303, -1, 152, 3, -1, 306, -1, 161, + 3, -1, 141, 203, 304, 204, -1, 159, 228, 283, + 296, -1, 161, 256, 205, 250, 206, -1, 161, 256, + 153, 203, 252, 204, 255, 205, 235, 206, -1, 5, + -1, 5, 199, 5, -1 }; /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ static const yytype_uint16 yyrline[] = { - 0, 325, 325, 338, 339, 340, 341, 344, 347, 348, - 349, 352, 353, 354, 355, 356, 359, 360, 361, 362, - 365, 366, 369, 370, 374, 375, 376, 377, 378, 382, - 383, 384, 385, 386, 387, 390, 392, 400, 406, 410, - 412, 416, 423, 424, 427, 428, 431, 432, 436, 441, - 448, 449, 452, 453, 457, 460, 461, 462, 465, 466, - 469, 470, 471, 472, 473, 474, 475, 476, 477, 478, - 479, 480, 481, 482, 483, 484, 485, 486, 487, 488, - 489, 490, 491, 492, 493, 494, 495, 496, 497, 498, - 499, 500, 501, 502, 503, 504, 505, 506, 507, 508, - 509, 510, 511, 512, 513, 514, 515, 516, 517, 518, - 519, 520, 521, 522, 523, 524, 528, 529, 530, 531, - 532, 533, 534, 535, 536, 537, 538, 539, 540, 541, - 542, 543, 544, 548, 549, 554, 555, 556, 557, 560, - 561, 564, 568, 574, 575, 576, 579, 583, 592, 596, - 601, 604, 605, 618, 619, 622, 623, 624, 625, 626, - 627, 628, 629, 630, 631, 632, 633, 634, 635, 636, - 637, 638, 639, 640, 641, 642, 643, 644, 645, 646, - 647, 648, 649, 650, 651, 652, 653, 654, 655, 656, - 657, 658, 659, 661, 663, 664, 667, 668, 671, 677, - 683, 684, 687, 692, 699, 700, 703, 704, 708, 709, - 712, 718, 726, 730, 735, 736, 739, 740, 741, 744, - 746, 749, 750, 751, 752, 753, 754, 755, 756, 757, - 758, 759, 762, 763, 766, 767, 768, 769, 770, 771, - 772, 773, 776, 777, 785, 791, 795, 796, 800, 803, - 804, 807, 816, 817, 820, 821, 824, 830, 836, 837, - 840, 841, 844, 854, 861, 867, 871, 872, 875, 876, - 879, 884, 891, 892, 893, 897, 901, 904, 905, 908, - 909, 913, 914, 918, 919, 920, 924, 926, 928, 932, - 933, 934, 935, 943, 945, 947, 952, 954, 959, 960, - 965, 966, 967, 968, 973, 982, 984, 985, 990, 992, - 996, 997, 1004, 1005, 1006, 1007, 1008, 1013, 1021, 1022, - 1025, 1026, 1029, 1036, 1037, 1042, 1043, 1047, 1048, 1049, - 1052, 1055, 1056, 1057, 1058, 1059, 1060, 1061, 1062, 1063, - 1064, 1067, 1073, 1075, 1081, 1082 + 0, 328, 328, 342, 343, 344, 345, 348, 351, 352, + 353, 356, 357, 358, 359, 360, 363, 364, 365, 366, + 369, 370, 373, 374, 378, 379, 380, 381, 382, 386, + 387, 388, 389, 390, 391, 394, 396, 404, 410, 414, + 416, 420, 427, 428, 431, 432, 435, 436, 440, 445, + 452, 453, 456, 457, 461, 464, 465, 466, 469, 470, + 473, 474, 475, 476, 477, 478, 479, 480, 481, 482, + 483, 484, 485, 486, 487, 488, 489, 490, 491, 492, + 493, 494, 495, 496, 497, 498, 499, 500, 501, 502, + 503, 504, 505, 506, 507, 508, 509, 510, 511, 512, + 513, 514, 515, 516, 517, 518, 519, 520, 521, 522, + 523, 524, 525, 526, 527, 528, 529, 530, 531, 532, + 533, 534, 535, 536, 537, 538, 539, 540, 541, 542, + 543, 544, 545, 546, 547, 548, 552, 553, 554, 555, + 556, 557, 558, 559, 560, 561, 562, 563, 564, 565, + 566, 567, 568, 569, 570, 571, 572, 573, 574, 578, + 579, 584, 585, 586, 587, 590, 591, 594, 598, 604, + 605, 606, 609, 613, 622, 626, 631, 634, 635, 648, + 649, 652, 653, 654, 655, 656, 657, 658, 659, 660, + 661, 662, 663, 664, 665, 666, 667, 668, 669, 670, + 671, 672, 673, 674, 675, 676, 677, 678, 679, 680, + 681, 682, 683, 684, 685, 686, 687, 688, 689, 691, + 693, 694, 697, 698, 701, 707, 713, 714, 717, 722, + 729, 730, 733, 734, 738, 739, 742, 748, 756, 760, + 765, 766, 769, 770, 771, 774, 776, 779, 780, 781, + 782, 783, 784, 785, 786, 787, 788, 789, 792, 793, + 796, 797, 798, 799, 800, 801, 802, 803, 806, 807, + 815, 821, 825, 826, 830, 833, 834, 837, 846, 847, + 850, 851, 854, 860, 866, 867, 870, 871, 874, 884, + 891, 897, 901, 902, 905, 906, 909, 914, 921, 922, + 923, 927, 931, 934, 935, 938, 939, 943, 944, 948, + 949, 950, 954, 956, 958, 962, 963, 964, 965, 973, + 975, 977, 982, 984, 989, 990, 995, 996, 997, 998, + 1003, 1012, 1014, 1015, 1020, 1022, 1026, 1027, 1034, 1035, + 1036, 1037, 1038, 1043, 1051, 1052, 1055, 1056, 1059, 1066, + 1067, 1072, 1073, 1077, 1078, 1079, 1080, 1081, 1085, 1086, + 1087, 1090, 1093, 1094, 1095, 1096, 1097, 1098, 1099, 1100, + 1101, 1102, 1105, 1111, 1113, 1119, 1120 }; #endif @@ -948,51 +994,56 @@ static const char *const yytname[] = "tBYTE", "tBYTECOUNT", "tCALLAS", "tCALLBACK", "tCASE", "tCDECL", "tCHAR", "tCOCLASS", "tCODE", "tCOMMSTATUS", "tCONST", "tCONTEXTHANDLE", "tCONTEXTHANDLENOSERIALIZE", "tCONTEXTHANDLESERIALIZE", "tCONTROL", - "tCPPQUOTE", "tDEFAULT", "tDEFAULTCOLLELEM", "tDEFAULTVALUE", - "tDEFAULTVTABLE", "tDISPLAYBIND", "tDISPINTERFACE", "tDLLNAME", - "tDOUBLE", "tDUAL", "tENDPOINT", "tENTRY", "tENUM", "tERRORSTATUST", - "tEXPLICITHANDLE", "tEXTERN", "tFALSE", "tFASTCALL", "tFLOAT", "tHANDLE", - "tHANDLET", "tHELPCONTEXT", "tHELPFILE", "tHELPSTRING", - "tHELPSTRINGCONTEXT", "tHELPSTRINGDLL", "tHIDDEN", "tHYPER", "tID", - "tIDEMPOTENT", "tIIDIS", "tIMMEDIATEBIND", "tIMPLICITHANDLE", "tIMPORT", - "tIMPORTLIB", "tIN", "tIN_LINE", "tINLINE", "tINPUTSYNC", "tINT", - "tINT3264", "tINT64", "tINTERFACE", "tLCID", "tLENGTHIS", "tLIBRARY", - "tLOCAL", "tLONG", "tMETHODS", "tMODULE", "tNONBROWSABLE", - "tNONCREATABLE", "tNONEXTENSIBLE", "tNULL", "tOBJECT", "tODL", - "tOLEAUTOMATION", "tOPTIONAL", "tOUT", "tPASCAL", "tPOINTERDEFAULT", - "tPROPERTIES", "tPROPGET", "tPROPPUT", "tPROPPUTREF", "tPTR", "tPUBLIC", - "tRANGE", "tREADONLY", "tREF", "tREGISTER", "tREQUESTEDIT", - "tRESTRICTED", "tRETVAL", "tSAFEARRAY", "tSHORT", "tSIGNED", "tSIZEIS", - "tSIZEOF", "tSMALL", "tSOURCE", "tSTATIC", "tSTDCALL", - "tSTRICTCONTEXTHANDLE", "tSTRING", "tSTRUCT", "tSWITCH", "tSWITCHIS", - "tSWITCHTYPE", "tTRANSMITAS", "tTRUE", "tTYPEDEF", "tUNION", "tUNIQUE", - "tUNSIGNED", "tUUID", "tV1ENUM", "tVARARG", "tVERSION", "tVOID", - "tWCHAR", "tWIREMARSHAL", "','", "'?'", "':'", "'|'", "'^'", "'&'", - "'<'", "'>'", "'-'", "'+'", "'*'", "'/'", "'%'", "'!'", "'~'", - "ADDRESSOF", "NEG", "POS", "PPTR", "CAST", "'.'", "'['", "']'", "';'", - "'('", "')'", "'{'", "'}'", "'='", "$accept", "input", "gbl_statements", - "imp_statements", "int_statements", "semicolon_opt", "statement", - "typedecl", "cppquote", "import_start", "import", "importlib", - "libraryhdr", "library_start", "librarydef", "m_args", "arg_list", - "args", "arg", "array", "m_attributes", "attributes", "attrib_list", - "str_list", "attribute", "uuid_string", "callconv", "cases", "case", - "enums", "enum_list", "enum", "enumdef", "m_exprs", "m_expr", "expr", - "expr_list_int_const", "expr_int_const", "expr_const", "fields", "field", - "ne_union_field", "ne_union_fields", "union_field", "s_field", "funcdef", - "declaration", "m_ident", "t_ident", "ident", "base_type", "m_int", - "int_std", "coclass", "coclasshdr", "coclassdef", "coclass_ints", - "coclass_int", "dispinterface", "dispinterfacehdr", "dispint_props", - "dispint_meths", "dispinterfacedef", "inherit", "interface", - "interfacehdr", "interfacedef", "interfacedec", "module", "modulehdr", - "moduledef", "storage_cls_spec", "function_specifier", "type_qualifier", - "m_type_qual_list", "decl_spec", "m_decl_spec_no_type", + "tCPPQUOTE", "tDECODE", "tDEFAULT", "tDEFAULTBIND", "tDEFAULTCOLLELEM", + "tDEFAULTVALUE", "tDEFAULTVTABLE", "tDISABLECONSISTENCYCHECK", + "tDISPLAYBIND", "tDISPINTERFACE", "tDLLNAME", "tDOUBLE", "tDUAL", + "tENABLEALLOCATE", "tENCODE", "tENDPOINT", "tENTRY", "tENUM", + "tERRORSTATUST", "tEXPLICITHANDLE", "tEXTERN", "tFALSE", "tFASTCALL", + "tFAULTSTATUS", "tFLOAT", "tFORCEALLOCATE", "tHANDLE", "tHANDLET", + "tHELPCONTEXT", "tHELPFILE", "tHELPSTRING", "tHELPSTRINGCONTEXT", + "tHELPSTRINGDLL", "tHIDDEN", "tHYPER", "tID", "tIDEMPOTENT", "tIGNORE", + "tIIDIS", "tIMMEDIATEBIND", "tIMPLICITHANDLE", "tIMPORT", "tIMPORTLIB", + "tIN", "tIN_LINE", "tINLINE", "tINPUTSYNC", "tINT", "tINT3264", "tINT64", + "tINTERFACE", "tLCID", "tLENGTHIS", "tLIBRARY", "tLICENSED", "tLOCAL", + "tLONG", "tMAYBE", "tMESSAGE", "tMETHODS", "tMODULE", "tNOCODE", + "tNONBROWSABLE", "tNONCREATABLE", "tNONEXTENSIBLE", "tNOTIFY", + "tNOTIFYFLAG", "tNULL", "tOBJECT", "tODL", "tOLEAUTOMATION", "tOPTIMIZE", + "tOPTIONAL", "tOUT", "tPARTIALIGNORE", "tPASCAL", "tPOINTERDEFAULT", + "tPROGID", "tPROPERTIES", "tPROPGET", "tPROPPUT", "tPROPPUTREF", + "tPROXY", "tPTR", "tPUBLIC", "tRANGE", "tREADONLY", "tREF", "tREGISTER", + "tREPRESENTAS", "tREQUESTEDIT", "tRESTRICTED", "tRETVAL", "tSAFEARRAY", + "tSHORT", "tSIGNED", "tSIZEIS", "tSIZEOF", "tSMALL", "tSOURCE", + "tSTATIC", "tSTDCALL", "tSTRICTCONTEXTHANDLE", "tSTRING", "tSTRUCT", + "tSWITCH", "tSWITCHIS", "tSWITCHTYPE", "tTHREADING", "tTRANSMITAS", + "tTRUE", "tTYPEDEF", "tUIDEFAULT", "tUNION", "tUNIQUE", "tUNSIGNED", + "tUSESGETLASTERROR", "tUSERMARSHAL", "tUUID", "tV1ENUM", "tVARARG", + "tVERSION", "tVIPROGID", "tVOID", "tWCHAR", "tWIREMARSHAL", "tAPARTMENT", + "tNEUTRAL", "tSINGLE", "tFREE", "tBOTH", "','", "'?'", "':'", "'|'", + "'^'", "'&'", "'<'", "'>'", "'-'", "'+'", "'*'", "'/'", "'%'", "'!'", + "'~'", "ADDRESSOF", "NEG", "POS", "PPTR", "CAST", "'.'", "'['", "']'", + "';'", "'('", "')'", "'{'", "'}'", "'='", "$accept", "input", + "gbl_statements", "imp_statements", "int_statements", "semicolon_opt", + "statement", "typedecl", "cppquote", "import_start", "import", + "importlib", "libraryhdr", "library_start", "librarydef", "m_args", + "arg_list", "args", "arg", "array", "m_attributes", "attributes", + "attrib_list", "str_list", "attribute", "uuid_string", "callconv", + "cases", "case", "enums", "enum_list", "enum", "enumdef", "m_exprs", + "m_expr", "expr", "expr_list_int_const", "expr_int_const", "expr_const", + "fields", "field", "ne_union_field", "ne_union_fields", "union_field", + "s_field", "funcdef", "declaration", "m_ident", "t_ident", "ident", + "base_type", "m_int", "int_std", "coclass", "coclasshdr", "coclassdef", + "coclass_ints", "coclass_int", "dispinterface", "dispinterfacehdr", + "dispint_props", "dispint_meths", "dispinterfacedef", "inherit", + "interface", "interfacehdr", "interfacedef", "interfacedec", "module", + "modulehdr", "moduledef", "storage_cls_spec", "function_specifier", + "type_qualifier", "m_type_qual_list", "decl_spec", "m_decl_spec_no_type", "decl_spec_no_type", "declarator", "direct_declarator", "abstract_declarator", "abstract_declarator_no_direct", "m_abstract_declarator", "abstract_direct_declarator", "any_declarator", "any_declarator_no_direct", "m_any_declarator", "any_direct_declarator", "declarator_list", "m_bitfield", "struct_declarator", - "struct_declarator_list", "init_declarator", "pointer_type", "structdef", - "type", "typedef", "uniondef", "version", 0 + "struct_declarator_list", "init_declarator", "threading_type", + "pointer_type", "structdef", "type", "typedef", "uniondef", "version", 0 }; #endif @@ -1016,50 +1067,56 @@ static const yytype_uint16 yytoknum[] = 375, 376, 377, 378, 379, 380, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 396, 397, 398, 399, 400, 401, 402, 403, 404, - 44, 63, 58, 124, 94, 38, 60, 62, 45, 43, - 42, 47, 37, 33, 126, 405, 406, 407, 408, 409, - 46, 91, 93, 59, 40, 41, 123, 125, 61 + 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, + 415, 416, 417, 418, 419, 420, 421, 422, 423, 424, + 425, 426, 427, 428, 429, 430, 431, 432, 433, 44, + 63, 58, 124, 94, 38, 60, 62, 45, 43, 42, + 47, 37, 33, 126, 434, 435, 436, 437, 438, 46, + 91, 93, 59, 40, 41, 123, 125, 61 }; # endif /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ static const yytype_uint16 yyr1[] = { - 0, 179, 180, 181, 181, 181, 181, 181, 181, 181, - 181, 182, 182, 182, 182, 182, 182, 182, 182, 182, - 183, 183, 184, 184, 185, 185, 185, 185, 185, 186, - 186, 186, 186, 186, 186, 187, 188, 189, 190, 191, - 192, 193, 194, 194, 195, 195, 196, 196, 197, 197, - 198, 198, 199, 199, 200, 201, 201, 201, 202, 202, - 203, 203, 203, 203, 203, 203, 203, 203, 203, 203, - 203, 203, 203, 203, 203, 203, 203, 203, 203, 203, - 203, 203, 203, 203, 203, 203, 203, 203, 203, 203, - 203, 203, 203, 203, 203, 203, 203, 203, 203, 203, - 203, 203, 203, 203, 203, 203, 203, 203, 203, 203, - 203, 203, 203, 203, 203, 203, 203, 203, 203, 203, - 203, 203, 203, 203, 203, 203, 203, 203, 203, 203, - 203, 203, 203, 204, 204, 205, 205, 205, 205, 206, - 206, 207, 207, 208, 208, 208, 209, 209, 210, 210, - 211, 212, 212, 213, 213, 214, 214, 214, 214, 214, - 214, 214, 214, 214, 214, 214, 214, 214, 214, 214, - 214, 214, 214, 214, 214, 214, 214, 214, 214, 214, - 214, 214, 214, 214, 214, 214, 214, 214, 214, 214, - 214, 214, 214, 214, 214, 214, 215, 215, 216, 217, - 218, 218, 219, 219, 220, 220, 221, 221, 222, 222, - 223, 224, 225, 225, 226, 226, 227, 227, 227, 228, - 228, 229, 229, 229, 229, 229, 229, 229, 229, 229, - 229, 229, 230, 230, 231, 231, 231, 231, 231, 231, - 231, 231, 232, 232, 233, 234, 235, 235, 236, 237, - 237, 238, 239, 239, 240, 240, 241, 241, 242, 242, - 243, 243, 244, 245, 245, 245, 246, 246, 247, 247, - 248, 249, 250, 250, 250, 251, 252, 253, 253, 254, - 254, 255, 255, 256, 256, 256, 257, 257, 257, 258, - 258, 258, 258, 259, 259, 259, 260, 260, 261, 261, - 262, 262, 262, 262, 262, 263, 263, 263, 264, 264, - 265, 265, 266, 266, 266, 266, 266, 266, 267, 267, - 268, 268, 269, 270, 270, 271, 271, 272, 272, 272, - 273, 274, 274, 274, 274, 274, 274, 274, 274, 274, - 274, 275, 276, 276, 277, 277 + 0, 208, 209, 210, 210, 210, 210, 210, 210, 210, + 210, 211, 211, 211, 211, 211, 211, 211, 211, 211, + 212, 212, 213, 213, 214, 214, 214, 214, 214, 215, + 215, 215, 215, 215, 215, 216, 217, 218, 219, 220, + 221, 222, 223, 223, 224, 224, 225, 225, 226, 226, + 227, 227, 228, 228, 229, 230, 230, 230, 231, 231, + 232, 232, 232, 232, 232, 232, 232, 232, 232, 232, + 232, 232, 232, 232, 232, 232, 232, 232, 232, 232, + 232, 232, 232, 232, 232, 232, 232, 232, 232, 232, + 232, 232, 232, 232, 232, 232, 232, 232, 232, 232, + 232, 232, 232, 232, 232, 232, 232, 232, 232, 232, + 232, 232, 232, 232, 232, 232, 232, 232, 232, 232, + 232, 232, 232, 232, 232, 232, 232, 232, 232, 232, + 232, 232, 232, 232, 232, 232, 232, 232, 232, 232, + 232, 232, 232, 232, 232, 232, 232, 232, 232, 232, + 232, 232, 232, 232, 232, 232, 232, 232, 232, 233, + 233, 234, 234, 234, 234, 235, 235, 236, 236, 237, + 237, 237, 238, 238, 239, 239, 240, 241, 241, 242, + 242, 243, 243, 243, 243, 243, 243, 243, 243, 243, + 243, 243, 243, 243, 243, 243, 243, 243, 243, 243, + 243, 243, 243, 243, 243, 243, 243, 243, 243, 243, + 243, 243, 243, 243, 243, 243, 243, 243, 243, 243, + 243, 243, 244, 244, 245, 246, 247, 247, 248, 248, + 249, 249, 250, 250, 251, 251, 252, 253, 254, 254, + 255, 255, 256, 256, 256, 257, 257, 258, 258, 258, + 258, 258, 258, 258, 258, 258, 258, 258, 259, 259, + 260, 260, 260, 260, 260, 260, 260, 260, 261, 261, + 262, 263, 264, 264, 265, 266, 266, 267, 268, 268, + 269, 269, 270, 270, 271, 271, 272, 272, 273, 274, + 274, 274, 275, 275, 276, 276, 277, 278, 279, 279, + 279, 280, 281, 282, 282, 283, 283, 284, 284, 285, + 285, 285, 286, 286, 286, 287, 287, 287, 287, 288, + 288, 288, 289, 289, 290, 290, 291, 291, 291, 291, + 291, 292, 292, 292, 293, 293, 294, 294, 295, 295, + 295, 295, 295, 295, 296, 296, 297, 297, 298, 299, + 299, 300, 300, 301, 301, 301, 301, 301, 302, 302, + 302, 303, 304, 304, 304, 304, 304, 304, 304, 304, + 304, 304, 305, 306, 306, 307, 307 }; /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ @@ -1072,34 +1129,37 @@ static const yytype_uint8 yyr2[] = 3, 4, 0, 1, 1, 3, 1, 3, 3, 2, 3, 3, 0, 1, 3, 1, 3, 4, 1, 3, 0, 1, 4, 1, 1, 1, 1, 1, 4, 4, - 1, 1, 1, 1, 1, 1, 4, 1, 1, 4, - 1, 4, 4, 1, 1, 4, 4, 4, 4, 4, - 1, 4, 1, 4, 1, 5, 1, 1, 4, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 4, 1, 1, 1, 1, 6, 1, 1, 1, 1, - 4, 1, 1, 1, 4, 4, 4, 4, 1, 1, - 4, 4, 1, 1, 1, 1, 1, 1, 1, 0, - 2, 4, 3, 0, 2, 1, 1, 3, 3, 1, - 5, 1, 3, 0, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 5, 3, 3, 3, 3, + 4, 1, 1, 1, 4, 1, 1, 1, 4, 4, + 1, 1, 1, 1, 4, 4, 4, 4, 4, 1, + 4, 1, 1, 4, 1, 5, 1, 1, 4, 4, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 4, 1, 1, 1, 4, 4, + 1, 1, 1, 1, 1, 6, 1, 4, 1, 1, + 1, 4, 1, 1, 1, 4, 4, 4, 4, 1, + 1, 4, 4, 1, 1, 4, 4, 4, 1, 1, + 1, 1, 1, 1, 1, 0, 2, 4, 3, 0, + 2, 1, 1, 3, 3, 1, 5, 1, 3, 0, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 5, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, - 3, 3, 5, 5, 4, 3, 1, 3, 1, 1, - 0, 2, 4, 3, 2, 2, 0, 2, 2, 1, - 3, 1, 3, 2, 0, 1, 0, 1, 1, 1, - 1, 1, 1, 1, 2, 2, 1, 1, 1, 1, - 1, 1, 0, 1, 1, 2, 1, 2, 2, 1, - 1, 1, 2, 2, 2, 5, 0, 2, 2, 2, - 2, 2, 2, 3, 2, 3, 5, 5, 0, 2, - 2, 2, 2, 6, 8, 2, 2, 2, 2, 2, - 2, 5, 1, 1, 1, 1, 1, 0, 2, 2, - 3, 0, 1, 2, 2, 2, 3, 2, 1, 1, - 3, 2, 4, 3, 2, 1, 3, 2, 0, 1, - 3, 2, 1, 3, 4, 3, 2, 1, 3, 2, - 0, 1, 1, 3, 2, 1, 3, 4, 1, 3, - 0, 2, 2, 1, 3, 1, 3, 1, 1, 1, - 5, 1, 1, 1, 1, 2, 1, 2, 1, 2, - 4, 4, 5, 10, 1, 3 + 2, 2, 2, 2, 2, 2, 3, 3, 5, 5, + 4, 3, 1, 3, 1, 1, 0, 2, 4, 3, + 2, 2, 0, 2, 2, 1, 3, 1, 3, 2, + 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, + 2, 2, 1, 1, 1, 1, 1, 1, 0, 1, + 1, 2, 1, 2, 2, 1, 1, 1, 2, 2, + 2, 5, 0, 2, 2, 2, 2, 2, 2, 3, + 2, 3, 5, 5, 0, 2, 2, 2, 2, 6, + 8, 2, 2, 2, 2, 2, 2, 5, 1, 1, + 1, 1, 1, 0, 2, 2, 3, 0, 1, 2, + 2, 2, 3, 2, 1, 1, 3, 2, 4, 3, + 2, 1, 3, 2, 0, 1, 3, 2, 1, 3, + 4, 3, 2, 1, 3, 2, 0, 1, 1, 3, + 2, 1, 3, 4, 1, 3, 0, 2, 2, 1, + 3, 1, 3, 1, 1, 1, 1, 1, 1, 1, + 1, 5, 1, 1, 1, 1, 2, 1, 2, 1, + 2, 4, 4, 5, 10, 1, 3 }; /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state @@ -1107,739 +1167,792 @@ static const yytype_uint8 yyr2[] = means the default is an error. */ static const yytype_uint16 yydefact[] = { - 3, 0, 2, 1, 332, 229, 221, 240, 0, 276, - 0, 0, 228, 216, 230, 272, 227, 231, 232, 0, - 275, 234, 241, 239, 0, 232, 274, 0, 232, 0, - 236, 273, 216, 52, 216, 226, 331, 222, 60, 10, - 0, 24, 11, 27, 11, 9, 0, 334, 0, 333, - 223, 0, 0, 7, 0, 0, 22, 0, 258, 5, - 4, 0, 8, 281, 281, 281, 0, 0, 336, 281, - 0, 338, 242, 243, 0, 249, 250, 335, 218, 0, - 233, 238, 0, 260, 261, 237, 0, 235, 224, 337, - 0, 0, 53, 339, 0, 225, 61, 0, 63, 64, + 3, 0, 2, 1, 363, 255, 247, 266, 0, 302, + 0, 0, 254, 242, 256, 298, 253, 257, 258, 0, + 301, 260, 267, 265, 0, 258, 300, 0, 258, 0, + 262, 299, 242, 52, 242, 252, 362, 248, 60, 10, + 0, 24, 11, 27, 11, 9, 0, 365, 0, 364, + 249, 0, 0, 7, 0, 0, 22, 0, 284, 5, + 4, 0, 8, 307, 307, 307, 0, 0, 367, 307, + 0, 369, 268, 269, 0, 275, 276, 366, 244, 0, + 259, 264, 0, 286, 287, 263, 0, 261, 250, 368, + 0, 0, 53, 370, 0, 251, 61, 0, 63, 64, 65, 66, 67, 0, 0, 70, 71, 72, 73, 74, - 75, 0, 77, 78, 0, 80, 0, 0, 83, 84, - 0, 0, 0, 0, 0, 90, 0, 92, 0, 94, - 0, 96, 97, 100, 0, 101, 102, 103, 104, 105, - 106, 107, 108, 109, 0, 111, 112, 113, 329, 114, - 0, 116, 327, 117, 118, 119, 0, 121, 122, 123, - 0, 0, 0, 328, 0, 128, 129, 0, 0, 0, - 55, 132, 25, 0, 0, 0, 0, 0, 334, 244, - 251, 262, 270, 0, 336, 338, 26, 6, 246, 267, - 0, 23, 265, 266, 0, 0, 20, 285, 282, 284, - 283, 219, 220, 135, 136, 137, 138, 277, 0, 0, - 289, 325, 288, 213, 334, 336, 281, 338, 279, 28, - 0, 143, 36, 0, 200, 0, 0, 206, 0, 0, + 75, 76, 77, 78, 79, 0, 81, 82, 83, 0, + 85, 86, 87, 0, 0, 90, 91, 92, 93, 0, + 0, 0, 0, 0, 99, 0, 101, 102, 0, 104, + 0, 106, 107, 110, 0, 111, 112, 113, 114, 115, + 116, 117, 118, 119, 120, 121, 122, 123, 0, 125, + 126, 127, 0, 0, 130, 131, 132, 133, 360, 134, + 0, 136, 358, 0, 138, 139, 140, 0, 142, 143, + 144, 0, 0, 0, 0, 149, 359, 150, 0, 0, + 153, 154, 0, 0, 0, 0, 55, 158, 25, 0, + 0, 0, 0, 0, 365, 270, 277, 288, 296, 0, + 367, 369, 26, 6, 272, 293, 0, 23, 291, 292, + 0, 0, 20, 311, 308, 310, 309, 245, 246, 161, + 162, 163, 164, 303, 0, 0, 315, 351, 314, 239, + 365, 367, 307, 369, 305, 28, 0, 169, 36, 0, + 226, 0, 0, 232, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 153, 0, 0, 153, 0, 0, - 0, 0, 0, 0, 60, 54, 37, 0, 17, 18, - 19, 0, 15, 13, 12, 16, 22, 39, 268, 269, - 40, 212, 52, 0, 52, 0, 0, 259, 20, 0, - 0, 0, 287, 0, 153, 42, 291, 280, 35, 0, - 145, 146, 149, 340, 52, 318, 341, 52, 52, 0, - 0, 164, 155, 156, 157, 161, 162, 163, 158, 159, - 0, 160, 0, 0, 0, 0, 0, 0, 0, 198, - 0, 196, 199, 0, 0, 58, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 151, 154, - 0, 0, 0, 0, 0, 0, 134, 133, 0, 344, - 0, 0, 56, 60, 0, 14, 41, 22, 0, 247, - 252, 0, 0, 0, 0, 0, 0, 0, 22, 21, - 0, 278, 286, 290, 326, 0, 0, 0, 46, 43, - 44, 0, 310, 150, 144, 0, 330, 0, 201, 0, - 0, 342, 53, 207, 0, 62, 68, 0, 188, 187, - 186, 189, 184, 185, 0, 298, 0, 0, 0, 0, + 179, 0, 0, 0, 0, 0, 179, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 60, 54, 37, 0, + 17, 18, 19, 0, 15, 13, 12, 16, 22, 39, + 294, 295, 40, 238, 52, 0, 52, 0, 0, 285, + 20, 0, 0, 0, 313, 0, 179, 42, 317, 306, + 35, 0, 171, 172, 175, 371, 52, 344, 372, 52, + 52, 0, 0, 190, 181, 182, 183, 187, 188, 189, + 184, 185, 0, 186, 0, 0, 0, 0, 0, 0, + 0, 224, 0, 222, 225, 0, 0, 58, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 69, - 76, 79, 0, 81, 82, 85, 86, 87, 88, 89, - 91, 93, 0, 99, 153, 98, 110, 0, 120, 124, - 125, 126, 127, 0, 130, 131, 57, 0, 245, 248, - 254, 0, 253, 256, 0, 0, 211, 257, 20, 22, - 271, 51, 50, 292, 0, 310, 277, 42, 315, 310, - 312, 311, 49, 307, 147, 148, 0, 338, 319, 214, - 205, 204, 298, 195, 277, 42, 302, 298, 299, 0, - 295, 177, 178, 190, 171, 172, 175, 176, 166, 167, - 0, 168, 169, 170, 174, 173, 180, 179, 182, 183, - 181, 191, 0, 197, 59, 95, 152, 0, 345, 22, - 210, 255, 0, 263, 47, 45, 48, 310, 277, 0, - 310, 0, 306, 42, 314, 320, 323, 0, 203, 0, - 215, 0, 298, 277, 0, 310, 0, 294, 0, 42, - 301, 0, 194, 115, 38, 22, 305, 310, 316, 309, - 313, 0, 0, 322, 0, 202, 139, 193, 293, 310, - 303, 297, 300, 192, 0, 165, 264, 308, 317, 321, - 324, 0, 296, 304, 0, 0, 343, 140, 0, 52, - 52, 209, 142, 0, 141, 208 + 177, 180, 0, 0, 0, 0, 0, 0, 0, 0, + 353, 354, 355, 356, 357, 0, 0, 0, 160, 159, + 0, 375, 0, 0, 0, 56, 60, 0, 14, 41, + 22, 0, 273, 278, 0, 0, 0, 0, 0, 0, + 0, 22, 21, 0, 304, 312, 316, 352, 0, 0, + 0, 46, 43, 44, 0, 336, 176, 170, 0, 361, + 0, 227, 0, 0, 373, 53, 233, 0, 62, 68, + 0, 214, 213, 212, 215, 210, 211, 0, 324, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 69, 80, 84, 0, 88, 89, 94, 95, + 96, 97, 98, 100, 103, 0, 109, 179, 108, 124, + 128, 129, 0, 137, 141, 145, 146, 148, 147, 151, + 152, 0, 155, 156, 157, 57, 0, 271, 274, 280, + 0, 279, 282, 0, 0, 237, 283, 20, 22, 297, + 51, 50, 318, 0, 336, 303, 42, 341, 336, 338, + 337, 49, 333, 173, 174, 0, 369, 345, 240, 231, + 230, 324, 221, 303, 42, 328, 324, 325, 0, 321, + 203, 204, 216, 197, 198, 201, 202, 192, 193, 0, + 194, 195, 196, 200, 199, 206, 205, 208, 209, 207, + 217, 0, 223, 59, 105, 178, 0, 376, 22, 236, + 281, 0, 289, 47, 45, 48, 336, 303, 0, 336, + 0, 332, 42, 340, 346, 349, 0, 229, 0, 241, + 0, 324, 303, 0, 336, 0, 320, 0, 42, 327, + 0, 220, 135, 38, 22, 331, 336, 342, 335, 339, + 0, 0, 348, 0, 228, 165, 219, 319, 336, 329, + 323, 326, 218, 0, 191, 290, 334, 343, 347, 350, + 0, 322, 330, 0, 0, 374, 166, 0, 52, 52, + 235, 168, 0, 167, 234 }; /* YYDEFGOTO[NTERM-NUM]. */ static const yytype_int16 yydefgoto[] = { - -1, 1, 2, 173, 279, 192, 369, 40, 41, 42, - 43, 259, 177, 44, 260, 377, 378, 379, 380, 478, - 362, 92, 169, 326, 170, 348, 479, 591, 597, 289, - 290, 291, 214, 337, 338, 319, 320, 321, 323, 294, - 388, 393, 298, 602, 603, 465, 48, 549, 79, 480, - 49, 81, 50, 261, 52, 262, 272, 359, 54, 55, - 274, 364, 56, 195, 57, 58, 263, 264, 182, 61, - 265, 63, 64, 65, 280, 66, 197, 67, 211, 212, - 498, 556, 499, 500, 481, 541, 482, 483, 296, 573, - 546, 547, 213, 171, 215, 69, 70, 217, 350 + -1, 1, 2, 199, 311, 218, 412, 40, 41, 42, + 43, 291, 203, 44, 292, 420, 421, 422, 423, 527, + 405, 92, 195, 358, 196, 390, 528, 640, 646, 321, + 322, 323, 240, 369, 370, 351, 352, 353, 355, 326, + 431, 436, 330, 651, 652, 514, 48, 598, 79, 529, + 49, 81, 50, 293, 52, 294, 304, 402, 54, 55, + 306, 407, 56, 221, 57, 58, 295, 296, 208, 61, + 297, 63, 64, 65, 312, 66, 223, 67, 237, 238, + 547, 605, 548, 549, 530, 590, 531, 532, 328, 622, + 595, 596, 239, 385, 197, 241, 69, 70, 243, 392 }; /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing STATE-NUM. */ -#define YYPACT_NINF -460 +#define YYPACT_NINF -511 static const yytype_int16 yypact[] = { - -460, 69, 1270, -460, -460, -460, -460, -460, 165, -460, - -81, 217, -460, 260, -460, -460, -460, -460, -6, 78, - -460, -460, -460, -460, 272, -6, -460, -62, -6, 356, - -460, -460, 284, -54, 287, 356, -460, -460, 2320, -460, - -49, -460, -460, -460, -460, -460, 2063, -25, -19, -460, - -460, -14, -13, -460, 12, 1, 19, 22, 49, -460, - -460, 30, -460, -8, -8, -8, 398, 2211, 35, -8, - 37, 40, -460, -460, 210, -460, -460, 48, -460, 66, - -460, -460, 43, -460, -460, -460, 2211, -460, -460, 48, - 68, 2141, -460, -78, -69, -460, -460, 75, -460, -460, - -460, -460, -460, 85, 91, -460, -460, -460, -460, -460, - -460, 94, -460, -460, 98, -460, 108, 138, -460, -460, - 144, 149, 151, 155, 157, -460, 158, -460, 159, -460, - 160, -460, -460, 161, 162, -460, -460, -460, -460, -460, - -460, -460, -460, -460, 169, -460, -460, -460, -460, -460, - 170, -460, -460, -460, -460, -460, 171, -460, -460, -460, - 176, 179, 181, -460, 182, -460, -460, 184, 186, -75, - -460, -460, -460, 1175, 461, 258, 289, 119, 166, -460, - -460, -460, -460, 398, 190, 202, -460, -460, -460, -460, - -3, -460, -460, -460, 295, 204, -460, -460, -460, -460, - -460, -460, -460, -460, -460, -460, -460, -460, 398, 398, - -460, 200, -34, -460, -460, -460, -8, -460, -460, -460, - 209, 324, -460, 211, -460, 398, 215, -460, 377, 324, - 1000, 1000, 382, 383, 1000, 1000, 384, 385, 1000, 386, - 1000, 1000, 329, 1000, 1000, -45, 1000, 1000, 1000, 2211, - 2211, 130, 394, 2211, 2320, 236, -460, 237, -460, -460, - -460, 241, -460, -460, -460, -460, 19, -460, -460, -460, - -460, -460, -98, 263, -67, 243, 242, -460, -460, 556, - 316, 246, -460, 1000, 1039, 1633, -460, -460, -460, 248, - 270, -460, 244, -460, -93, -460, 283, -54, -88, 264, - 266, -460, -460, -460, -460, -460, -460, -460, -460, -460, - 261, -460, 1000, 1000, 1000, 1000, 1000, 1000, 936, 1882, - -84, -460, 1882, 267, 273, -460, -80, 274, 275, 278, - 279, 281, 282, 285, 1638, 435, 286, -74, -460, 1882, - 291, 297, -70, 1696, 292, 293, -460, -460, 294, 288, - 296, 302, -460, 2320, 454, -460, -460, 19, 4, -460, - -460, 312, 2141, 301, 841, 303, 397, 651, 19, -460, - 2141, -460, -460, -460, -460, 245, 309, 307, 334, -460, - -460, 2141, 208, -460, 324, 1000, -460, 2141, -460, 398, - 310, -460, 313, -460, 315, -460, -460, 2141, 11, 11, - 11, 11, 11, 11, 1719, 140, 1000, 1000, 486, 1000, - 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, - 1000, 1000, 1000, 1000, 1000, 1000, 488, 1000, 1000, -460, - -460, -460, 487, -460, -460, -460, -460, -460, -460, -460, - -460, -460, 321, -460, 1000, -460, -460, 1000, -460, -460, - -460, -460, -460, 492, -460, -460, -460, 323, -460, -460, - -460, 398, -460, -460, 2141, 326, -460, -460, -460, 19, - -460, -460, -460, -460, 1555, 208, -460, 1382, -460, 208, - -460, -460, -460, -32, -460, -460, 208, 333, -460, 324, - -460, -460, 140, -460, -460, 1460, -460, 140, -460, 327, - -24, 146, 146, -460, 958, 958, 28, 28, 1769, 1846, - 1823, 1900, 1919, 1951, 28, 28, 96, 96, 11, 11, - 11, -460, 1801, -460, -460, -460, -460, 332, -460, 19, - -460, -460, 746, -460, -460, -460, -460, 299, -460, 335, - 208, 336, -460, 1633, -460, 360, -460, -83, -460, 337, - -460, 339, -4, -460, 341, 208, 343, -460, 1000, 1633, - -460, 1000, -460, -460, -460, 19, -460, 299, -460, -460, - -460, 345, 1000, -460, 208, -460, -460, -460, -460, 299, - -460, -460, -460, 11, 348, 1882, -460, -460, -460, -460, - -460, -12, -460, -460, 1000, 373, -460, -460, 374, -48, - -48, -460, -460, 358, -460, -460 + -511, 65, 1251, -511, -511, -511, -511, -511, 54, -511, + -131, 131, -511, 176, -511, -511, -511, -511, 21, 167, + -511, -511, -511, -511, 223, 21, -511, -37, 21, 36, + -511, -511, 228, -62, 238, 36, -511, -511, 2477, -511, + -41, -511, -511, -511, -511, -511, 2161, -25, -21, -511, + -511, -19, -18, -511, -17, -15, -9, -7, 29, -511, + -511, 15, -511, -6, -6, -6, 428, 2327, 13, -6, + 22, 26, -511, -511, 229, -511, -511, 41, -511, 50, + -511, -511, 71, -511, -511, -511, 2327, -511, -511, 41, + 70, 2233, -511, -115, -109, -511, -511, 82, -511, -511, + -511, -511, -511, 85, 87, -511, -511, -511, -511, -511, + -511, -511, -511, -511, -511, 91, -511, -511, -511, 93, + -511, -511, -511, 95, 96, -511, -511, -511, -511, 97, + 98, 104, 109, 113, -511, 115, -511, -511, 117, -511, + 118, -511, -511, 121, 123, -511, -511, -511, -511, -511, + -511, -511, -511, -511, -511, -511, -511, -511, 133, -511, + -511, -511, 134, 136, -511, -511, -511, -511, -511, -511, + 137, -511, -511, 138, -511, -511, -511, 141, -511, -511, + -511, 151, 152, 156, 159, -511, -511, -511, 160, 163, + -511, -511, 165, 168, 169, -124, -511, -511, -511, 1124, + 466, 378, 240, 177, 183, -511, -511, -511, -511, 428, + 184, 185, -511, -511, -511, -511, -44, -511, -511, -511, + 247, 186, -511, -511, -511, -511, -511, -511, -511, -511, + -511, -511, -511, -511, 428, 428, -511, 181, -130, -511, + -511, -511, -6, -511, -511, -511, 188, 276, -511, 190, + -511, 428, 192, -511, 388, 276, 324, 324, 389, 390, + 324, 324, 391, 393, 324, 394, 324, 324, 328, 324, + 324, 398, -86, 399, 324, 2327, 324, 324, 2327, 202, + 2327, 2327, 84, 404, 409, 2327, 2477, 218, -511, 217, + -511, -511, -511, 219, -511, -511, -511, -511, -9, -511, + -511, -511, -511, -511, -77, 241, -79, 222, 221, -511, + -511, 580, 300, 224, -511, 324, 906, 1670, -511, -511, + -511, 227, 248, -511, 230, -511, -59, -511, 250, -62, + -42, 231, 232, -511, -511, -511, -511, -511, -511, -511, + -511, -511, 235, -511, 324, 324, 324, 324, 324, 324, + 981, 1957, -126, -511, 1957, 236, 237, -511, -120, 239, + 242, 244, 246, 249, 251, 252, 1668, 431, 253, -111, + -511, 1957, 254, 255, 256, 263, 258, -94, 1740, 259, + -511, -511, -511, -511, -511, 260, 261, 264, -511, -511, + 267, 245, 268, 270, 273, -511, 2477, 443, -511, -511, + -9, 9, -511, -511, 271, 2233, 265, 867, 272, 365, + 681, -9, -511, 2233, -511, -511, -511, -511, 94, 279, + 280, 306, -511, -511, 2233, 595, -511, 276, 324, -511, + 2233, -511, 428, 283, -511, 286, -511, 288, -511, -511, + 2233, 8, 8, 8, 8, 8, 8, 1765, 566, 324, + 324, 488, 324, 324, 324, 324, 324, 324, 324, 324, + 324, 324, 324, 324, 324, 324, 324, 324, 324, 489, + 324, 324, -511, -511, -511, 485, -511, -511, -511, -511, + -511, -511, -511, -511, -511, 290, -511, 324, -511, -511, + -511, -511, 324, -511, -511, -511, -511, -511, -511, -511, + -511, 490, -511, -511, -511, -511, 292, -511, -511, -511, + 428, -511, -511, 2233, 298, -511, -511, -511, -9, -511, + -511, -511, -511, 1576, 595, -511, 1378, -511, 595, -511, + -511, -511, -95, -511, -511, 595, 299, -511, 276, -511, + -511, 566, -511, -511, 1504, -511, 566, -511, 303, -64, + 158, 158, -511, 1047, 1047, 505, 505, 1811, 1919, 1882, + 1900, 1990, 1973, 505, 505, 161, 161, 8, 8, 8, + -511, 1860, -511, -511, -511, -511, 311, -511, -9, -511, + -511, 795, -511, -511, -511, -511, 153, -511, 318, 595, + 322, -511, 1670, -511, 321, -511, -123, -511, 305, -511, + 325, 45, -511, 326, 595, 329, -511, 324, 1670, -511, + 324, -511, -511, -511, -9, -511, 153, -511, -511, -511, + 331, 324, -511, 595, -511, -511, -511, -511, 153, -511, + -511, -511, 8, 333, 1957, -511, -511, -511, -511, -511, + 10, -511, -511, 324, 347, -511, -511, 358, -76, -76, + -511, -511, 338, -511, -511 }; /* YYPGOTO[NTERM-NUM]. */ static const yytype_int16 yypgoto[] = { - -460, -460, -460, 464, -259, -255, 20, -460, -460, -460, - 167, -460, -460, -460, 533, -424, -460, -460, 63, -203, - -10, -2, -460, -460, -226, -460, -65, -460, -460, -460, - -460, 156, 2, 298, -260, -184, -460, -228, -221, -460, - -460, -460, -460, -61, -189, -460, 180, -460, 121, -63, - -460, 124, 87, 36, -460, 545, -460, -460, 506, -460, - -460, -460, -460, -460, -26, -460, 551, 3, -460, -460, - 552, -460, -460, -266, -402, -40, -20, -33, -192, -460, - -460, -460, -438, -460, -459, -460, -127, -460, -460, -460, - -15, -460, 372, 317, 6, -46, -460, 0, -460 + -511, -511, -511, 499, -292, -289, 19, -511, -511, -511, + 135, -511, -511, -511, 543, -494, -511, -511, 23, -227, + -20, -2, -511, -511, -259, -511, -65, -511, -511, -511, + -511, 120, 2, 274, -276, -196, -511, -254, -246, -511, + -511, -511, -511, -100, -217, -511, 146, -511, 128, -63, + -511, 81, 130, 40, -511, 552, -511, -511, 511, -511, + -511, -511, -511, -511, -3, -511, 556, 3, -511, -511, + 558, -511, -511, -293, -398, -40, -30, -39, -218, -511, + -511, -511, -510, -511, -506, -511, -461, -511, -511, -511, + -58, -511, 357, -511, 295, 6, -45, -511, 0, -511 }; /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If positive, shift that token. If negative, reduce the rule which number is the opposite. If zero, do what YYDEFACT says. If YYTABLE_NINF, syntax error. */ -#define YYTABLE_NINF -218 +#define YYTABLE_NINF -244 static const yytype_int16 yytable[] = { - 46, 209, 71, 210, 47, 60, 183, 328, 68, 286, - 331, 356, 333, 327, 371, 336, 281, 282, 341, 367, - 181, 216, 39, 91, 376, 594, 408, 545, 352, 361, - 198, 198, 198, 295, 203, 9, 198, 595, 51, 9, - 223, 406, 407, 408, 199, 200, 185, 322, 178, 218, - 322, 225, 184, 539, 551, 15, -217, 334, 11, 557, - 339, 204, 374, 339, 343, 226, 428, 574, 148, 3, - 432, 554, 152, 38, 537, 254, 444, 20, 38, 357, - 444, 80, 179, 38, 386, 363, 82, 24, 372, 391, - 575, 429, 552, 74, 24, 433, 163, 255, -217, 322, - 339, 445, 458, 205, 38, 448, 273, 227, 390, 394, - 26, 408, 86, 470, 578, 545, 88, 38, 209, 571, - 210, 31, 95, 38, 172, 601, 206, 456, 398, 399, - 400, 401, 402, 403, 404, 584, 567, 284, 346, 284, - 285, 347, 543, 209, 209, 210, 210, 284, -29, 85, - 559, 579, 87, 90, 186, 94, 494, 485, 292, 187, - 209, 408, 210, 188, 275, 596, 300, 284, 72, 73, - 495, 46, 46, 71, 71, 47, 47, 190, 203, 68, - 68, 426, 427, 198, 526, 189, 421, 422, 423, 424, - 425, 401, 191, 258, 258, 193, 287, 488, 426, 427, - 523, 194, 496, 344, 345, 204, 196, 351, -30, 532, - 219, 201, 202, -31, 533, 209, 222, 210, 220, 527, - 75, 76, 501, 502, -217, 504, 505, 506, 507, 508, - 509, 510, 511, 512, 513, 514, 515, 516, 517, 518, - 519, 520, 221, 522, 224, 382, 203, 205, 301, 228, - 302, 303, 304, 305, 306, 307, 423, 424, 425, 229, - 339, 267, 358, 77, 78, 230, 426, 427, 231, 530, - 206, 371, 232, 204, 564, 83, 84, 370, 405, 71, - 544, 47, 233, 381, 387, 68, 371, 89, 78, 496, - 93, 78, 268, 269, 496, 270, 392, 560, 276, 277, - 494, 371, 201, 202, 421, 422, 423, 424, 425, 308, - 586, 284, 234, 371, 495, 205, 426, 427, 235, 201, - 202, 292, 461, 236, 209, 237, 210, 201, 202, 238, - 183, 239, 240, 241, 242, 243, 244, 203, 206, -32, - 497, 475, 9, 245, 246, 247, 309, 486, 536, 496, - 248, 589, 542, 249, 203, 250, 251, 492, 252, 9, - 253, 459, 464, -33, 204, 370, 598, 71, 476, 47, - 185, 310, 178, 68, 583, -34, 184, 585, 283, 284, - 278, 204, 477, 311, 288, 299, 293, 487, 322, 297, - 324, 325, 329, 330, 332, 7, 209, 335, 210, 349, - 312, 201, 202, 313, 314, 315, 205, 353, 316, 317, - 566, 354, 540, 569, 355, 360, 365, 471, 366, 318, - 384, 373, 385, 205, 183, 383, 550, 497, 581, 206, - 555, 18, 497, 389, 382, 397, 203, 382, 442, 395, - 587, 396, 430, 21, 22, 23, 206, 447, 431, 434, - 435, 25, 592, 436, 437, 382, 438, 439, 453, 476, - 440, 443, 457, 204, 460, 4, 446, 450, 451, 452, - 284, 454, 381, 477, 462, 381, 207, 455, 19, 28, - 467, 472, 473, 30, 474, 489, 490, 497, 491, 503, - 208, 521, 5, 381, 6, 524, 525, 528, 529, 531, - 7, 8, 558, 382, 9, 205, 548, 563, 174, 10, - 568, 570, 572, 576, 577, 11, 580, 12, 582, 382, - 588, 13, 14, 593, 15, 599, 600, 16, 206, 17, - 370, 605, 71, 468, 47, 45, 18, 535, 68, 604, - 484, 381, 19, 257, 466, 342, 20, 53, 21, 22, - 23, 24, 180, 59, 62, 271, 25, 381, 207, 590, - 4, 0, 340, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 208, 0, 0, 0, 0, 0, 0, 26, - 0, 0, 0, 27, 28, 29, 0, 5, 30, 6, - 31, 0, 0, 0, 32, 7, 0, 0, 0, 9, - 33, 34, 0, 35, 10, 0, 0, 0, 36, 37, - 0, 0, 12, 0, 0, 0, 13, 14, 0, 15, - 0, 0, 16, 0, 17, 0, 0, 0, 0, 0, - 0, 18, 38, 0, 0, 0, 0, 19, 266, 0, - 0, 20, 0, 21, 22, 23, 0, 0, 0, 0, - 0, 25, 0, 0, 0, 4, 0, 0, 0, 0, + 46, 235, 71, 236, 47, 60, 209, 360, 68, 399, + 363, 318, 365, 91, 359, 368, 313, 314, 410, 414, + 375, 39, 242, 451, 224, 224, 224, 395, 404, 594, + 224, 600, 588, 327, 225, 226, 606, 9, -243, 244, + 419, 249, 51, 207, 252, 168, 211, 643, 204, 172, + 603, 251, 210, 471, 24, 286, 623, 72, 73, 475, + 644, 354, 15, 585, 354, 3, 11, 591, 487, 417, + 316, 366, 74, 317, 371, 7, 186, 287, 472, 624, + 371, 378, 305, 229, 476, 487, 205, 20, 9, 406, + -243, 627, 388, 488, 415, 389, 253, 333, 620, 334, + 335, 336, 337, 338, 339, 316, 85, 24, 592, 87, + 494, 507, 433, 437, 633, 230, 80, 594, 18, 354, + 371, 38, 519, 38, 38, 615, 650, 586, 618, 400, + 26, 21, 22, 23, 75, 76, 316, 505, 38, 608, + 25, 38, 31, 630, 235, 601, 236, 429, 441, 442, + 443, 444, 445, 446, 447, 636, 227, 228, 38, 88, + 90, 198, 94, 340, 434, 95, 86, 641, 231, 235, + 235, 236, 236, 451, 534, 82, 451, -29, 28, 77, + 78, 212, 30, 213, 324, 215, 235, 214, 236, 616, + 216, 229, 332, 217, 232, 219, 9, 46, 46, 71, + 71, 47, 47, 224, 628, 68, 68, 469, 470, 341, + 220, 575, 319, 307, 537, -30, 645, 572, 290, 290, + 222, 545, 444, 230, 245, 581, 83, 84, -31, 582, + 376, 89, 78, 379, 543, 386, 387, 246, 576, 342, + 394, 93, 78, 300, 301, 316, -243, 235, 544, 236, + 308, 309, 343, 550, 551, 247, 553, 554, 555, 556, + 557, 558, 559, 560, 561, 562, 563, 564, 565, 566, + 567, 568, 569, 248, 571, 250, 231, 425, 344, 227, + 228, 345, 346, 347, 401, 254, 348, 349, 255, 613, + 256, 371, 579, 414, 257, 520, 258, 350, 259, 260, + 261, 262, 232, 227, 228, 593, 430, 263, 414, 413, + 448, 71, 264, 47, 545, 424, 265, 68, 266, 545, + 267, 268, 609, 414, 269, 635, 270, 333, 435, 334, + 335, 336, 337, 338, 339, 414, 271, 272, 229, 273, + 274, 275, 525, 9, 276, 464, 465, 466, 467, 468, + 466, 467, 468, 316, 277, 278, 526, 469, 470, 279, + 469, 470, 280, 281, 324, 510, 282, 235, 283, 236, + 230, 284, 285, 209, 545, 638, 380, 381, 382, 383, + 384, 299, 302, 546, 524, -32, -33, -34, 315, 647, + 535, 310, 320, 340, 325, 329, 331, 356, 357, 361, + 541, 362, 364, 367, 508, 513, 372, 374, 413, 391, + 71, 632, 47, 211, 634, 204, 68, 393, 396, 210, + 397, 398, 403, 231, 408, 354, 409, 427, 416, 432, + 536, 227, 228, 426, 485, 438, 439, 428, 440, 341, + 473, 474, 492, 477, 501, 235, 478, 236, 479, 232, + 480, 506, 509, 481, 19, 482, 483, 486, 489, 490, + 491, 589, 493, 496, 497, 498, 229, 511, 499, 342, + 4, 500, 502, 209, 503, 599, 546, 504, 516, 604, + 521, 546, 343, 425, 522, 523, 425, 538, 539, 233, + 540, 552, 570, 573, 574, 577, 578, 5, 230, 6, + 580, 597, 621, 234, 425, 7, 8, 607, 344, 9, + 625, 345, 346, 347, 10, 612, 348, 349, 449, 450, + 451, 424, 617, 11, 424, 12, 619, 350, 648, 626, + 629, 13, 14, 631, 15, 637, 546, 642, 16, 649, + 654, 17, 424, 200, 517, 45, 584, 533, 18, 653, + 377, 231, 425, 515, 53, 19, 289, 206, 59, 20, + 62, 21, 22, 23, 24, 639, 303, 373, 425, 0, + 25, 0, 0, 0, 0, 0, 0, 232, 0, 413, + 0, 71, 0, 47, 4, 0, 0, 68, 0, 0, + 424, 0, 0, 0, 0, 0, 0, 0, 227, 228, + 0, 0, 26, 0, 229, 0, 424, 27, 28, 29, + 0, 5, 30, 6, 31, 0, 0, 233, 32, 7, + 0, 0, 0, 9, 0, 33, 0, 34, 10, 35, + 0, 234, 0, 229, 0, 0, 230, 36, 37, 12, + 0, 0, 0, 0, 0, 13, 14, 0, 15, 0, + 0, 0, 16, 0, 0, 17, 0, 0, 0, 0, + 0, 0, 18, 0, 0, 230, 38, 0, 0, 19, + 0, 0, 298, 20, 0, 21, 22, 23, 0, 0, + 0, 0, 0, 0, 25, 4, 0, 0, 0, 231, + 0, 0, 464, 465, 466, 467, 468, 0, 0, 0, + 0, 0, 0, 0, 469, 470, 0, 0, 0, 0, + 0, 0, 5, 0, 6, 232, 26, 0, 231, 0, + 7, 27, 28, 29, 9, 0, 30, 0, 31, 10, + 0, 0, 32, 0, 0, 0, 0, 0, 0, 33, + 12, 34, 0, 35, 232, 0, 13, 14, 0, 15, + 0, 36, 37, 16, 0, 543, 17, 0, 0, 0, + 0, 0, 0, 18, 0, 0, 316, 0, 0, 544, + 19, 0, 0, 0, 20, 0, 21, 22, 23, 0, + 38, 0, 0, 0, 525, 25, 411, 0, 0, 0, + 0, 0, 0, 0, 0, 316, 0, 0, 526, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 26, 0, 0, 0, 27, 28, - 29, 0, 5, 30, 6, 31, 0, 0, 0, 32, - 7, 0, 0, 0, 9, 33, 34, 0, 35, 10, - 0, 0, 0, 36, 37, 0, 0, 12, 0, 0, - 0, 13, 14, 0, 15, 0, 0, 16, 0, 17, - 0, 0, 0, 0, 0, 0, 18, 38, 0, 0, - 0, 0, 19, 368, 0, 0, 20, 0, 21, 22, - 23, 0, 0, 0, 0, 0, 25, 0, 0, 0, - 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 26, - 0, 0, 0, 27, 28, 29, 0, 5, 30, 6, - 31, 0, 0, 0, 32, 7, 0, 0, 0, 9, - 33, 34, 0, 35, 10, 0, 0, 0, 36, 37, - 0, 0, 12, 0, 0, 0, 13, 14, 0, 15, - 0, 0, 16, 0, 17, 0, 0, 0, 0, 0, - 0, 18, 38, 0, 0, 0, 0, 19, 469, 0, - 0, 20, 0, 21, 22, 23, 0, 0, 0, 0, - 0, 25, 0, 0, 0, 4, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 26, 0, 0, 0, 27, 28, - 29, 0, 5, 30, 6, 31, 0, 0, 0, 32, - 7, 0, 0, 0, 9, 33, 34, 0, 35, 0, - 0, 0, 0, 36, 37, 0, 0, 12, 0, 0, - 0, 13, 14, 0, 15, 0, 0, 16, 0, 17, - 0, 0, 0, 0, 0, 0, 18, 38, 0, 0, - 0, 0, 0, 565, 0, 0, 20, 0, 21, 22, - 23, 0, 0, 0, 0, 0, 25, 0, 0, 301, - 4, 302, 303, 304, 305, 306, 307, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 26, - 0, 0, 0, 27, 28, 29, 0, 5, 30, 6, - 31, 406, 407, 408, 32, 7, 411, 412, 0, 9, - 0, 34, 0, 35, 0, 0, 0, 0, 36, 37, - 0, 0, 12, 0, 0, 0, 13, 14, 0, 15, - 308, 0, 16, 301, 17, 302, 303, 304, 305, 306, - 307, 18, 38, 0, 0, 0, 0, 0, 463, 0, - 0, 20, 0, 21, 22, 23, 0, 0, 0, 0, - 0, 25, 0, 0, 0, 0, 0, 309, 0, 0, - 0, 0, 301, 0, 302, 303, 304, 305, 306, 307, - 0, 0, 0, 0, 26, 0, 0, 0, 27, 28, - 29, 0, 310, 30, 308, 31, 0, 0, 0, 32, - 0, 0, 0, 0, 311, 0, 34, 0, 35, 0, - 0, 0, 0, 36, 37, 0, 0, 0, 0, 0, - 0, 312, 0, 0, 313, 314, 315, 0, 0, 316, - 317, 309, 0, 308, 0, 0, 0, 0, 0, 0, - 318, 0, 0, 0, 419, 420, 421, 422, 423, 424, - 425, 0, 0, 0, 0, 0, 310, 0, 426, 427, - 0, 0, 0, 0, 0, 0, 0, 0, 311, 0, - 309, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 312, 0, 0, 313, 314, - 315, 0, 0, 316, 317, 310, 0, 0, 0, 0, - 0, 0, 0, 0, 318, 0, 0, 311, 0, 4, - 0, 0, 0, 0, 0, 0, 0, 256, 0, 0, - 0, 0, 0, 0, 312, 0, 0, 313, 314, 375, - 0, 0, 316, 317, 0, 0, 5, 0, 6, 0, - 0, 0, 0, 318, 7, 8, 0, 0, 9, 0, - 0, 0, 0, 10, 0, 0, 0, 0, 0, 11, - 0, 12, 0, 0, 0, 13, 14, 0, 15, 0, - 0, 16, 0, 17, 0, 0, 0, 0, 0, 0, - 18, 0, 0, 0, 0, 0, 19, 257, 0, 0, - 20, 0, 21, 22, 23, 24, 0, 0, 0, 0, - 25, 0, 0, 0, 4, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 26, 0, 0, 0, 27, 28, 29, - 0, 5, 30, 6, 31, 0, 0, 0, 32, 7, - 8, 0, 0, 9, 33, 34, 0, 35, 10, 0, - 0, 0, 36, 37, 11, 0, 12, 0, 0, 0, - 13, 14, 0, 15, 0, 0, 16, 0, 17, 0, - 0, 0, 0, 0, 0, 18, 38, 0, 0, 0, - 0, 19, 0, 0, 0, 20, 0, 21, 22, 23, - 24, 0, 0, 0, 0, 25, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 4, 0, 26, 0, - 0, 0, 27, 28, 29, 0, 0, 30, 0, 31, - 0, 0, 0, 32, 0, 0, 0, 0, 0, 33, - 34, 0, 35, 5, 0, 6, 0, 36, 37, 0, - 203, 7, 0, 0, 0, 9, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 12, 0, - 0, 38, 13, 14, 0, 15, 0, 204, 16, 0, - 17, 0, 0, 0, 0, 0, 0, 18, 0, 0, - 0, 0, 0, 0, 4, 0, 0, 20, 0, 21, - 22, 23, 0, 0, 0, 0, 0, 25, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 205, - 0, 5, 0, 6, 0, 0, 0, 0, 203, 7, - 26, 0, 0, 9, 27, 28, 29, 0, 0, 30, - 0, 31, 206, 0, 0, 32, 12, 0, 0, 0, - 13, 14, 34, 15, 35, 204, 16, 0, 17, 36, - 37, 0, 0, 0, 0, 18, 0, 0, 0, 0, - 0, 0, 538, 0, 0, 20, 0, 21, 22, 23, - 0, 0, 0, 38, 0, 25, 0, 0, 0, 4, - 0, 0, 0, 0, 0, 0, 0, 205, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 534, 26, 0, + 0, 0, 0, 0, 0, 0, 0, 26, 0, 0, 0, 0, 27, 28, 29, 0, 5, 30, 6, 31, - 206, 0, 0, 32, 7, 0, 0, 0, 9, 0, - 34, 0, 35, 0, 0, 0, 0, 36, 37, 0, - 0, 12, 0, 0, 0, 13, 14, 0, 15, 0, - 553, 16, 0, 17, 0, 0, 0, 0, 0, 0, - 18, 38, 0, 0, 0, 0, 0, 4, 0, 0, - 20, 0, 21, 22, 23, 0, 0, 0, 0, 0, - 25, 406, 407, 408, 409, 410, 411, 412, 413, 414, - 0, 0, 0, 0, 5, 0, 6, 0, 0, 0, - 0, 0, 7, 26, 0, 0, 9, 27, 28, 29, - 0, 0, 30, 0, 31, 0, 0, 0, 32, 12, - 0, 0, 0, 13, 14, 34, 15, 35, 0, 16, - 0, 17, 36, 37, 0, 0, 0, 0, 18, 406, - 407, 408, 409, 410, 411, 412, 413, 414, 20, 0, - 21, 22, 23, 0, 0, 0, 38, 0, 25, 0, - 0, 0, 406, 407, 408, 409, 410, 411, 412, 413, - 414, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 26, 0, 0, 0, 27, 28, 29, 0, 0, + 0, 0, 0, 32, 7, 0, 0, 0, 9, 0, + 33, 0, 34, 10, 35, 0, 0, 0, 0, 0, + 0, 0, 36, 37, 12, 0, 0, 0, 0, 0, + 13, 14, 0, 15, 0, 0, 0, 16, 0, 0, + 17, 4, 0, 0, 0, 0, 0, 18, 0, 0, + 0, 38, 0, 0, 19, 0, 0, 518, 20, 0, + 21, 22, 23, 0, 0, 0, 0, 0, 5, 25, + 6, 0, 0, 0, 0, 0, 7, 0, 0, 333, + 9, 334, 335, 336, 337, 338, 339, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 12, 0, 0, 0, + 0, 26, 13, 14, 0, 15, 27, 28, 29, 16, + 0, 30, 17, 31, 0, 0, 0, 32, 0, 18, + 0, 0, 0, 0, 33, 0, 34, 0, 35, 0, + 20, 0, 21, 22, 23, 0, 36, 37, 0, 0, + 0, 25, 0, 0, 0, 340, 0, 0, 0, 0, + 0, 0, 0, 0, 333, 4, 334, 335, 336, 337, + 338, 339, 0, 0, 0, 38, 0, 0, 0, 0, + 0, 614, 0, 26, 0, 0, 0, 0, 27, 28, + 29, 0, 5, 30, 6, 31, 0, 0, 0, 32, + 7, 341, 0, 0, 9, 0, 0, 0, 34, 0, + 35, 0, 0, 0, 0, 0, 0, 0, 36, 37, + 12, 0, 0, 0, 0, 0, 13, 14, 0, 15, + 340, 342, 0, 16, 0, 0, 17, 0, 0, 0, + 449, 450, 451, 18, 343, 454, 455, 38, 0, 0, + 0, 0, 0, 512, 20, 0, 21, 22, 23, 0, + 0, 0, 0, 0, 0, 25, 0, 0, 0, 0, + 344, 0, 0, 345, 346, 418, 341, 0, 348, 349, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 350, + 0, 0, 0, 0, 0, 0, 0, 26, 0, 0, + 0, 0, 27, 28, 29, 0, 342, 30, 4, 31, + 0, 0, 0, 32, 0, 0, 288, 0, 0, 343, + 0, 0, 34, 0, 35, 0, 0, 0, 0, 0, + 0, 0, 36, 37, 0, 5, 0, 6, 0, 0, + 0, 0, 0, 7, 8, 344, 0, 9, 345, 346, + 347, 0, 10, 348, 349, 0, 0, 0, 0, 0, + 0, 11, 0, 12, 350, 0, 0, 0, 0, 13, + 14, 0, 15, 0, 0, 0, 16, 0, 0, 17, + 0, 0, 0, 0, 0, 0, 18, 0, 0, 0, + 0, 0, 0, 19, 289, 0, 0, 20, 0, 21, + 22, 23, 24, 0, 0, 0, 0, 0, 25, 0, + 0, 0, 462, 463, 464, 465, 466, 467, 468, 0, + 0, 0, 0, 0, 0, 0, 469, 470, 0, 0, + 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, + 26, 0, 0, 0, 0, 27, 28, 29, 0, 0, 30, 0, 31, 0, 0, 0, 32, 0, 0, 0, - 0, 0, 0, 34, 0, 35, 0, 0, 0, 0, - 36, 37, 406, 407, 408, 409, 410, 411, 412, 415, - 414, 416, 417, 418, 419, 420, 421, 422, 423, 424, - 425, 0, 0, 0, 38, 0, 0, 0, 426, 427, - 0, 0, 0, 441, 406, 407, 408, 409, 410, 411, - 412, 413, 414, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 406, 407, 408, 409, - 410, 411, 412, 413, 414, 0, 0, 415, 0, 416, - 417, 418, 419, 420, 421, 422, 423, 424, 425, 406, - 407, 408, 409, 410, 411, 412, 426, 427, 0, 0, - 415, 449, 416, 417, 418, 419, 420, 421, 422, 423, - 424, 425, 0, 0, 0, 0, 0, 0, 0, 426, - 427, 0, 0, 0, 493, 406, 407, 408, 409, 410, - 411, 412, 413, 414, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 406, 407, 408, 409, 410, 411, 412, - 0, 0, 416, 417, 418, 419, 420, 421, 422, 423, - 424, 425, 406, 407, 408, 409, 410, 411, 412, 426, - 427, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 415, 0, 416, 417, 418, 419, 420, 421, - 422, 423, 424, 425, 406, 407, 408, 409, 410, 411, - 412, 426, 427, 562, 415, 561, 416, 417, 418, 419, - 420, 421, 422, 423, 424, 425, 0, 0, 0, 0, - 0, 0, 0, 426, 427, 0, 0, 0, 0, 416, - 417, 418, 419, 420, 421, 422, 423, 424, 425, 0, - 0, 0, 0, 0, 0, 0, 426, 427, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 415, 0, 416, 417, 418, 419, 420, - 421, 422, 423, 424, 425, 0, 0, 0, 0, 0, - 0, 0, 426, 427, 417, 418, 419, 420, 421, 422, - 423, 424, 425, 0, 0, 0, 0, 4, 0, 0, - 426, 427, 0, 0, 418, 419, 420, 421, 422, 423, - 424, 425, 0, 0, 0, 0, 0, 0, 0, 426, - 427, 0, 0, 0, 5, 0, 6, 0, 0, 0, - 0, 0, 7, 8, 0, 0, 9, 419, 420, 421, - 422, 423, 424, 425, 0, 0, 0, 11, 0, 12, - 0, 426, 427, 13, 14, 0, 15, 0, 0, 16, - 0, 17, 0, 0, 0, 0, 0, 0, 18, 0, - 0, 0, 0, 0, 0, 4, 0, 0, 20, 0, - 21, 22, 23, 24, 0, 0, 175, 0, 25, 0, - 176, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 5, 0, 6, 0, 0, 0, 0, 0, - 7, 26, 0, 0, 9, 27, 28, 29, 0, 0, - 30, 0, 31, 0, 0, 0, 32, 12, 0, 0, - 0, 13, 14, 34, 15, 35, 0, 16, 0, 17, - 36, 37, 0, 0, 0, 4, 18, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 20, 0, 21, 22, - 23, 0, 0, 0, 0, 0, 25, 0, 0, 0, - 0, 0, 5, 0, 6, 0, 0, 0, 0, 0, - 7, 0, 0, 0, 0, 0, 0, 0, 0, 26, - 0, 0, 0, 27, 28, 29, 0, 12, 30, 0, - 31, 13, 14, 0, 32, 0, 0, 16, 0, 17, - 0, 34, 0, 35, 0, 0, 18, 0, 36, 37, - 0, 0, 0, 0, 0, 0, 0, 0, 21, 22, - 23, 0, 0, 0, 0, 0, 25, 0, 0, 0, + 0, 0, 5, 33, 6, 34, 0, 35, 0, 0, + 7, 8, 0, 0, 9, 36, 37, 0, 0, 10, + 0, 0, 0, 0, 0, 0, 0, 0, 11, 0, + 12, 0, 0, 0, 0, 0, 13, 14, 0, 15, + 0, 0, 0, 16, 38, 0, 17, 0, 0, 0, + 0, 0, 0, 18, 0, 0, 0, 0, 0, 0, + 19, 0, 0, 0, 20, 0, 21, 22, 23, 24, + 0, 0, 0, 0, 0, 25, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 27, 28, 29, 0, 0, 30, 0, - 0, 0, 0, 96, 32, 97, 98, 99, 0, 100, - 101, 34, 102, 35, 0, 103, 0, 104, 36, 37, - 0, 0, 0, 0, 105, 106, 107, 108, 0, 109, - 110, 111, 112, 113, 0, 114, 0, 115, 116, 117, - 0, 0, 118, 0, 0, 0, 0, 119, 0, 120, - 121, 122, 123, 124, 125, 0, 126, 127, 128, 129, - 130, 0, 0, 131, 0, 0, 132, 0, 0, 0, - 0, 133, 134, 0, 135, 0, 0, 0, 136, 137, - 138, 0, 139, 140, 141, 142, 143, 0, 144, 0, - 145, 146, 147, 148, 149, 150, 151, 152, 0, 153, - 154, 155, 0, 0, 0, 156, 0, 0, 157, 0, - 0, 158, 159, 0, 0, 160, 161, 162, 0, 0, - 0, 163, 0, 164, 165, 166, 167, 0, 0, 168 + 0, 0, 4, 0, 0, 0, 0, 26, 0, 0, + 0, 0, 27, 28, 29, 0, 0, 30, 0, 31, + 0, 0, 0, 32, 0, 0, 0, 0, 0, 5, + 33, 6, 34, 0, 35, 0, 229, 7, 0, 0, + 0, 9, 36, 37, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 12, 0, 0, + 0, 0, 0, 13, 14, 0, 15, 0, 230, 0, + 16, 38, 0, 17, 0, 0, 0, 0, 0, 0, + 18, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 20, 0, 21, 22, 23, 0, 0, 0, 0, + 0, 0, 25, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 231, 0, 0, 0, 0, 0, 0, 4, 0, + 0, 0, 0, 0, 26, 0, 0, 0, 0, 27, + 28, 29, 0, 0, 30, 0, 31, 232, 0, 0, + 32, 0, 0, 0, 0, 5, 0, 6, 0, 34, + 0, 35, 229, 7, 0, 0, 0, 9, 0, 36, + 37, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 12, 0, 0, 0, 587, 0, 13, + 14, 0, 15, 0, 230, 0, 16, 0, 38, 17, + 4, 0, 0, 0, 0, 0, 18, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 20, 583, 21, + 22, 23, 0, 0, 0, 0, 0, 5, 25, 6, + 0, 0, 0, 0, 0, 7, 0, 0, 0, 9, + 0, 0, 0, 0, 0, 0, 0, 231, 0, 0, + 0, 0, 0, 0, 0, 12, 0, 0, 0, 0, + 26, 13, 14, 0, 15, 27, 28, 29, 16, 0, + 30, 17, 31, 232, 0, 0, 32, 0, 18, 0, + 0, 0, 0, 0, 0, 34, 0, 35, 0, 20, + 0, 21, 22, 23, 4, 36, 37, 0, 0, 0, + 25, 449, 450, 451, 452, 453, 454, 455, 456, 457, + 0, 0, 0, 602, 0, 0, 0, 0, 0, 0, + 0, 5, 0, 6, 38, 0, 0, 0, 0, 7, + 0, 0, 26, 9, 0, 0, 0, 27, 28, 29, + 0, 0, 30, 0, 31, 0, 0, 0, 32, 12, + 0, 0, 0, 0, 0, 13, 14, 34, 15, 35, + 0, 0, 16, 0, 0, 17, 0, 36, 37, 0, + 0, 0, 18, 449, 450, 451, 452, 453, 454, 455, + 456, 457, 0, 20, 0, 21, 22, 23, 0, 0, + 0, 0, 0, 0, 25, 0, 38, 0, 449, 450, + 451, 452, 453, 454, 455, 456, 457, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 26, 0, 0, 0, + 0, 27, 28, 29, 0, 0, 30, 0, 31, 0, + 0, 0, 32, 0, 449, 450, 451, 452, 453, 454, + 455, 34, 457, 35, 0, 0, 0, 0, 0, 0, + 0, 36, 37, 0, 0, 0, 0, 0, 458, 0, + 459, 460, 461, 462, 463, 464, 465, 466, 467, 468, + 0, 0, 0, 0, 0, 0, 0, 469, 470, 0, + 38, 0, 484, 449, 450, 451, 452, 453, 454, 455, + 456, 457, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 449, 450, 451, 452, 453, + 454, 455, 456, 457, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 449, 450, 451, 452, 453, 454, 455, + 458, 0, 459, 460, 461, 462, 463, 464, 465, 466, + 467, 468, 449, 450, 451, 452, 453, 454, 455, 469, + 470, 0, 0, 0, 495, 458, 0, 459, 460, 461, + 462, 463, 464, 465, 466, 467, 468, 0, 0, 0, + 0, 0, 0, 0, 469, 470, 0, 0, 0, 542, + 449, 450, 451, 452, 453, 454, 455, 456, 457, 0, + 0, 0, 0, 0, 0, 0, 449, 450, 451, 452, + 453, 454, 455, 459, 460, 461, 462, 463, 464, 465, + 466, 467, 468, 449, 450, 451, 452, 453, 454, 455, + 469, 470, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 458, 0, 459, 460, 461, 462, 463, 464, 465, 466, + 467, 468, 0, 0, 0, 0, 0, 0, 0, 469, + 470, 611, 458, 610, 459, 460, 461, 462, 463, 464, + 465, 466, 467, 468, 0, 0, 0, 0, 0, 0, + 0, 469, 470, 460, 461, 462, 463, 464, 465, 466, + 467, 468, 0, 0, 0, 0, 0, 0, 0, 469, + 470, 459, 460, 461, 462, 463, 464, 465, 466, 467, + 468, 0, 0, 0, 0, 0, 0, 0, 469, 470, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 458, 0, 459, + 460, 461, 462, 463, 464, 465, 466, 467, 468, 0, + 0, 0, 0, 0, 0, 0, 469, 470, 462, 463, + 464, 465, 466, 467, 468, 4, 0, 0, 0, 0, + 0, 0, 469, 470, 461, 462, 463, 464, 465, 466, + 467, 468, 0, 0, 0, 0, 0, 0, 0, 469, + 470, 0, 5, 0, 6, 0, 0, 0, 0, 0, + 7, 8, 0, 0, 9, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 11, 0, + 12, 0, 0, 0, 0, 0, 13, 14, 0, 15, + 0, 0, 0, 16, 0, 0, 17, 4, 0, 0, + 0, 0, 0, 18, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 20, 0, 21, 22, 23, 24, + 0, 0, 201, 0, 5, 25, 6, 0, 0, 202, + 0, 0, 7, 0, 0, 0, 9, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 12, 0, 0, 0, 0, 26, 13, 14, + 0, 15, 27, 28, 29, 16, 0, 30, 17, 31, + 0, 0, 0, 32, 0, 18, 0, 0, 0, 0, + 0, 0, 34, 0, 35, 0, 20, 0, 21, 22, + 23, 4, 36, 37, 0, 0, 0, 25, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 5, 0, + 6, 0, 0, 0, 0, 0, 7, 0, 0, 26, + 0, 0, 0, 0, 27, 28, 29, 0, 0, 30, + 0, 31, 0, 0, 0, 32, 12, 0, 0, 0, + 0, 0, 13, 14, 34, 0, 35, 0, 0, 16, + 0, 0, 17, 0, 36, 37, 0, 0, 0, 18, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 21, 22, 23, 0, 0, 0, 0, 0, + 0, 25, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 27, 28, + 29, 0, 0, 30, 0, 0, 0, 0, 0, 32, + 0, 0, 0, 0, 0, 0, 0, 0, 34, 0, + 35, 0, 0, 0, 0, 0, 0, 0, 36, 37, + 96, 0, 97, 98, 99, 0, 100, 101, 0, 102, + 0, 0, 103, 0, 104, 0, 0, 0, 105, 106, + 0, 107, 108, 109, 110, 0, 111, 112, 113, 114, + 115, 116, 117, 118, 0, 119, 0, 120, 121, 122, + 123, 124, 0, 0, 125, 0, 0, 0, 126, 0, + 127, 128, 0, 129, 130, 131, 132, 133, 134, 0, + 135, 136, 137, 138, 139, 140, 0, 0, 141, 0, + 0, 142, 0, 0, 0, 0, 143, 144, 0, 145, + 146, 0, 147, 148, 0, 0, 149, 150, 151, 152, + 153, 154, 0, 155, 156, 157, 158, 159, 160, 161, + 0, 162, 163, 0, 164, 165, 166, 167, 168, 169, + 170, 171, 172, 0, 173, 174, 175, 176, 0, 0, + 0, 177, 0, 0, 178, 0, 0, 179, 180, 0, + 0, 181, 182, 183, 184, 0, 0, 185, 0, 186, + 0, 187, 188, 189, 190, 191, 192, 193, 0, 0, + 194 }; static const yytype_int16 yycheck[] = { - 2, 66, 2, 66, 2, 2, 46, 235, 2, 212, - 238, 266, 240, 234, 280, 243, 208, 209, 246, 278, - 46, 67, 2, 33, 284, 37, 15, 486, 254, 96, - 63, 64, 65, 225, 38, 43, 69, 49, 2, 43, - 86, 13, 14, 15, 64, 65, 46, 231, 46, 69, - 234, 91, 46, 477, 492, 63, 134, 241, 54, 497, - 244, 65, 283, 247, 248, 134, 150, 150, 113, 0, - 150, 495, 117, 171, 476, 150, 150, 85, 171, 177, - 150, 87, 46, 171, 177, 274, 8, 90, 280, 177, - 173, 175, 494, 174, 90, 175, 141, 172, 176, 283, - 284, 175, 357, 107, 171, 175, 109, 176, 297, 298, - 118, 15, 174, 368, 552, 574, 29, 171, 183, 543, - 183, 129, 35, 171, 173, 173, 130, 353, 312, 313, - 314, 315, 316, 317, 318, 559, 538, 171, 8, 171, - 174, 11, 174, 208, 209, 208, 209, 171, 173, 25, - 174, 553, 28, 32, 173, 34, 160, 385, 221, 173, - 225, 15, 225, 176, 190, 177, 229, 171, 3, 4, - 174, 173, 174, 173, 174, 173, 174, 176, 38, 173, - 174, 170, 171, 216, 444, 173, 158, 159, 160, 161, - 162, 375, 173, 173, 174, 173, 216, 389, 170, 171, - 428, 152, 405, 249, 250, 65, 176, 253, 173, 468, - 173, 3, 4, 173, 469, 280, 173, 280, 8, 447, - 3, 4, 406, 407, 176, 409, 410, 411, 412, 413, - 414, 415, 416, 417, 418, 419, 420, 421, 422, 423, - 424, 425, 176, 427, 176, 285, 38, 107, 3, 174, - 5, 6, 7, 8, 9, 10, 160, 161, 162, 174, - 444, 3, 272, 3, 4, 174, 170, 171, 174, 461, - 130, 537, 174, 65, 529, 3, 4, 279, 318, 279, - 483, 279, 174, 285, 294, 279, 552, 3, 4, 492, - 3, 4, 3, 4, 497, 176, 298, 500, 3, 4, - 160, 567, 3, 4, 158, 159, 160, 161, 162, 64, - 565, 171, 174, 579, 174, 107, 170, 171, 174, 3, - 4, 384, 362, 174, 389, 174, 389, 3, 4, 174, - 370, 174, 174, 174, 174, 174, 174, 38, 130, 173, - 405, 381, 43, 174, 174, 174, 101, 387, 475, 552, - 174, 572, 479, 174, 38, 174, 174, 397, 174, 43, - 174, 358, 364, 173, 65, 367, 594, 367, 160, 367, - 370, 126, 370, 367, 558, 173, 370, 561, 178, 171, - 176, 65, 174, 138, 175, 8, 175, 387, 572, 174, - 8, 8, 8, 8, 8, 39, 461, 68, 461, 5, - 155, 3, 4, 158, 159, 160, 107, 171, 163, 164, - 537, 174, 477, 540, 173, 152, 173, 172, 176, 174, - 150, 175, 178, 107, 464, 177, 489, 492, 555, 130, - 495, 75, 497, 150, 474, 174, 38, 477, 3, 175, - 567, 175, 175, 87, 88, 89, 130, 150, 175, 175, - 175, 95, 579, 175, 175, 495, 175, 175, 170, 160, - 175, 175, 8, 65, 152, 4, 175, 175, 175, 175, - 171, 175, 474, 174, 173, 477, 160, 175, 81, 123, - 177, 172, 175, 127, 150, 175, 173, 552, 173, 3, - 174, 3, 31, 495, 33, 8, 175, 5, 175, 173, - 39, 40, 175, 543, 43, 107, 173, 175, 44, 48, - 175, 175, 152, 176, 175, 54, 175, 56, 175, 559, - 175, 60, 61, 175, 63, 152, 152, 66, 130, 68, - 532, 173, 532, 366, 532, 2, 75, 474, 532, 600, - 384, 543, 81, 82, 364, 247, 85, 2, 87, 88, - 89, 90, 46, 2, 2, 183, 95, 559, 160, 574, - 4, -1, 245, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 174, -1, -1, -1, -1, -1, -1, 118, - -1, -1, -1, 122, 123, 124, -1, 31, 127, 33, - 129, -1, -1, -1, 133, 39, -1, -1, -1, 43, - 139, 140, -1, 142, 48, -1, -1, -1, 147, 148, - -1, -1, 56, -1, -1, -1, 60, 61, -1, 63, - -1, -1, 66, -1, 68, -1, -1, -1, -1, -1, - -1, 75, 171, -1, -1, -1, -1, 81, 177, -1, - -1, 85, -1, 87, 88, 89, -1, -1, -1, -1, - -1, 95, -1, -1, -1, 4, -1, -1, -1, -1, + 2, 66, 2, 66, 2, 2, 46, 261, 2, 298, + 264, 238, 266, 33, 260, 269, 234, 235, 310, 312, + 274, 2, 67, 15, 63, 64, 65, 286, 107, 535, + 69, 541, 526, 251, 64, 65, 546, 43, 153, 69, + 316, 86, 2, 46, 153, 131, 46, 37, 46, 135, + 544, 91, 46, 179, 98, 179, 179, 3, 4, 179, + 50, 257, 68, 524, 260, 0, 57, 528, 179, 315, + 200, 267, 203, 203, 270, 39, 162, 201, 204, 202, + 276, 277, 126, 38, 204, 179, 46, 93, 43, 306, + 205, 601, 8, 204, 312, 11, 205, 3, 592, 5, + 6, 7, 8, 9, 10, 200, 25, 98, 203, 28, + 204, 400, 329, 330, 608, 70, 95, 623, 82, 315, + 316, 200, 411, 200, 200, 586, 202, 525, 589, 206, + 136, 95, 96, 97, 3, 4, 200, 396, 200, 203, + 104, 200, 148, 604, 209, 543, 209, 206, 344, 345, + 346, 347, 348, 349, 350, 616, 3, 4, 200, 29, + 32, 202, 34, 69, 206, 35, 203, 628, 123, 234, + 235, 234, 235, 15, 428, 8, 15, 202, 142, 3, + 4, 202, 146, 202, 247, 202, 251, 205, 251, 587, + 205, 38, 255, 202, 149, 202, 43, 199, 200, 199, + 200, 199, 200, 242, 602, 199, 200, 199, 200, 115, + 181, 487, 242, 216, 432, 202, 206, 471, 199, 200, + 205, 448, 418, 70, 202, 517, 3, 4, 202, 518, + 275, 3, 4, 278, 189, 280, 281, 8, 492, 145, + 285, 3, 4, 3, 4, 200, 205, 312, 203, 312, + 3, 4, 158, 449, 450, 205, 452, 453, 454, 455, + 456, 457, 458, 459, 460, 461, 462, 463, 464, 465, + 466, 467, 468, 202, 470, 205, 123, 317, 184, 3, + 4, 187, 188, 189, 304, 203, 192, 193, 203, 578, + 203, 487, 510, 586, 203, 201, 203, 203, 203, 203, + 203, 203, 149, 3, 4, 532, 326, 203, 601, 311, + 350, 311, 203, 311, 541, 317, 203, 311, 203, 546, + 203, 203, 549, 616, 203, 614, 203, 3, 330, 5, + 6, 7, 8, 9, 10, 628, 203, 203, 38, 203, + 203, 203, 189, 43, 203, 187, 188, 189, 190, 191, + 189, 190, 191, 200, 203, 203, 203, 199, 200, 203, + 199, 200, 203, 203, 427, 405, 203, 432, 203, 432, + 70, 203, 203, 413, 601, 621, 174, 175, 176, 177, + 178, 3, 205, 448, 424, 202, 202, 202, 207, 643, + 430, 205, 204, 69, 204, 203, 8, 8, 8, 8, + 440, 8, 8, 75, 401, 407, 8, 8, 410, 5, + 410, 607, 410, 413, 610, 413, 410, 8, 200, 413, + 203, 202, 181, 123, 202, 621, 205, 179, 204, 179, + 430, 3, 4, 206, 3, 204, 204, 207, 203, 115, + 204, 204, 179, 204, 199, 510, 204, 510, 204, 149, + 204, 8, 181, 204, 89, 204, 204, 204, 204, 204, + 204, 526, 204, 204, 204, 204, 38, 202, 204, 145, + 4, 204, 204, 513, 204, 538, 541, 204, 206, 544, + 201, 546, 158, 523, 204, 179, 526, 204, 202, 189, + 202, 3, 3, 8, 204, 5, 204, 31, 70, 33, + 202, 202, 181, 203, 544, 39, 40, 204, 184, 43, + 205, 187, 188, 189, 48, 204, 192, 193, 13, 14, + 15, 523, 204, 57, 526, 59, 204, 203, 181, 204, + 204, 65, 66, 204, 68, 204, 601, 204, 72, 181, + 202, 75, 544, 44, 409, 2, 523, 427, 82, 649, + 276, 123, 592, 407, 2, 89, 90, 46, 2, 93, + 2, 95, 96, 97, 98, 623, 209, 272, 608, -1, + 104, -1, -1, -1, -1, -1, -1, 149, -1, 581, + -1, 581, -1, 581, 4, -1, -1, 581, -1, -1, + 592, -1, -1, -1, -1, -1, -1, -1, 3, 4, + -1, -1, 136, -1, 38, -1, 608, 141, 142, 143, + -1, 31, 146, 33, 148, -1, -1, 189, 152, 39, + -1, -1, -1, 43, -1, 159, -1, 161, 48, 163, + -1, 203, -1, 38, -1, -1, 70, 171, 172, 59, + -1, -1, -1, -1, -1, 65, 66, -1, 68, -1, + -1, -1, 72, -1, -1, 75, -1, -1, -1, -1, + -1, -1, 82, -1, -1, 70, 200, -1, -1, 89, + -1, -1, 206, 93, -1, 95, 96, 97, -1, -1, + -1, -1, -1, -1, 104, 4, -1, -1, -1, 123, + -1, -1, 187, 188, 189, 190, 191, -1, -1, -1, + -1, -1, -1, -1, 199, 200, -1, -1, -1, -1, + -1, -1, 31, -1, 33, 149, 136, -1, 123, -1, + 39, 141, 142, 143, 43, -1, 146, -1, 148, 48, + -1, -1, 152, -1, -1, -1, -1, -1, -1, 159, + 59, 161, -1, 163, 149, -1, 65, 66, -1, 68, + -1, 171, 172, 72, -1, 189, 75, -1, -1, -1, + -1, -1, -1, 82, -1, -1, 200, -1, -1, 203, + 89, -1, -1, -1, 93, -1, 95, 96, 97, -1, + 200, -1, -1, -1, 189, 104, 206, -1, -1, -1, + -1, -1, -1, -1, -1, 200, -1, -1, 203, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 118, -1, -1, -1, 122, 123, - 124, -1, 31, 127, 33, 129, -1, -1, -1, 133, - 39, -1, -1, -1, 43, 139, 140, -1, 142, 48, - -1, -1, -1, 147, 148, -1, -1, 56, -1, -1, - -1, 60, 61, -1, 63, -1, -1, 66, -1, 68, - -1, -1, -1, -1, -1, -1, 75, 171, -1, -1, - -1, -1, 81, 177, -1, -1, 85, -1, 87, 88, - 89, -1, -1, -1, -1, -1, 95, -1, -1, -1, - 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 118, - -1, -1, -1, 122, 123, 124, -1, 31, 127, 33, - 129, -1, -1, -1, 133, 39, -1, -1, -1, 43, - 139, 140, -1, 142, 48, -1, -1, -1, 147, 148, - -1, -1, 56, -1, -1, -1, 60, 61, -1, 63, - -1, -1, 66, -1, 68, -1, -1, -1, -1, -1, - -1, 75, 171, -1, -1, -1, -1, 81, 177, -1, - -1, 85, -1, 87, 88, 89, -1, -1, -1, -1, - -1, 95, -1, -1, -1, 4, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 136, -1, -1, + -1, -1, 141, 142, 143, -1, 31, 146, 33, 148, + -1, -1, -1, 152, 39, -1, -1, -1, 43, -1, + 159, -1, 161, 48, 163, -1, -1, -1, -1, -1, + -1, -1, 171, 172, 59, -1, -1, -1, -1, -1, + 65, 66, -1, 68, -1, -1, -1, 72, -1, -1, + 75, 4, -1, -1, -1, -1, -1, 82, -1, -1, + -1, 200, -1, -1, 89, -1, -1, 206, 93, -1, + 95, 96, 97, -1, -1, -1, -1, -1, 31, 104, + 33, -1, -1, -1, -1, -1, 39, -1, -1, 3, + 43, 5, 6, 7, 8, 9, 10, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 59, -1, -1, -1, + -1, 136, 65, 66, -1, 68, 141, 142, 143, 72, + -1, 146, 75, 148, -1, -1, -1, 152, -1, 82, + -1, -1, -1, -1, 159, -1, 161, -1, 163, -1, + 93, -1, 95, 96, 97, -1, 171, 172, -1, -1, + -1, 104, -1, -1, -1, 69, -1, -1, -1, -1, + -1, -1, -1, -1, 3, 4, 5, 6, 7, 8, + 9, 10, -1, -1, -1, 200, -1, -1, -1, -1, + -1, 206, -1, 136, -1, -1, -1, -1, 141, 142, + 143, -1, 31, 146, 33, 148, -1, -1, -1, 152, + 39, 115, -1, -1, 43, -1, -1, -1, 161, -1, + 163, -1, -1, -1, -1, -1, -1, -1, 171, 172, + 59, -1, -1, -1, -1, -1, 65, 66, -1, 68, + 69, 145, -1, 72, -1, -1, 75, -1, -1, -1, + 13, 14, 15, 82, 158, 18, 19, 200, -1, -1, + -1, -1, -1, 206, 93, -1, 95, 96, 97, -1, + -1, -1, -1, -1, -1, 104, -1, -1, -1, -1, + 184, -1, -1, 187, 188, 189, 115, -1, 192, 193, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 203, + -1, -1, -1, -1, -1, -1, -1, 136, -1, -1, + -1, -1, 141, 142, 143, -1, 145, 146, 4, 148, + -1, -1, -1, 152, -1, -1, 12, -1, -1, 158, + -1, -1, 161, -1, 163, -1, -1, -1, -1, -1, + -1, -1, 171, 172, -1, 31, -1, 33, -1, -1, + -1, -1, -1, 39, 40, 184, -1, 43, 187, 188, + 189, -1, 48, 192, 193, -1, -1, -1, -1, -1, + -1, 57, -1, 59, 203, -1, -1, -1, -1, 65, + 66, -1, 68, -1, -1, -1, 72, -1, -1, 75, + -1, -1, -1, -1, -1, -1, 82, -1, -1, -1, + -1, -1, -1, 89, 90, -1, -1, 93, -1, 95, + 96, 97, 98, -1, -1, -1, -1, -1, 104, -1, + -1, -1, 185, 186, 187, 188, 189, 190, 191, -1, + -1, -1, -1, -1, -1, -1, 199, 200, -1, -1, + -1, -1, -1, -1, -1, 4, -1, -1, -1, -1, + 136, -1, -1, -1, -1, 141, 142, 143, -1, -1, + 146, -1, 148, -1, -1, -1, 152, -1, -1, -1, + -1, -1, 31, 159, 33, 161, -1, 163, -1, -1, + 39, 40, -1, -1, 43, 171, 172, -1, -1, 48, + -1, -1, -1, -1, -1, -1, -1, -1, 57, -1, + 59, -1, -1, -1, -1, -1, 65, 66, -1, 68, + -1, -1, -1, 72, 200, -1, 75, -1, -1, -1, + -1, -1, -1, 82, -1, -1, -1, -1, -1, -1, + 89, -1, -1, -1, 93, -1, 95, 96, 97, 98, + -1, -1, -1, -1, -1, 104, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 118, -1, -1, -1, 122, 123, - 124, -1, 31, 127, 33, 129, -1, -1, -1, 133, - 39, -1, -1, -1, 43, 139, 140, -1, 142, -1, - -1, -1, -1, 147, 148, -1, -1, 56, -1, -1, - -1, 60, 61, -1, 63, -1, -1, 66, -1, 68, - -1, -1, -1, -1, -1, -1, 75, 171, -1, -1, - -1, -1, -1, 177, -1, -1, 85, -1, 87, 88, - 89, -1, -1, -1, -1, -1, 95, -1, -1, 3, - 4, 5, 6, 7, 8, 9, 10, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 118, - -1, -1, -1, 122, 123, 124, -1, 31, 127, 33, - 129, 13, 14, 15, 133, 39, 18, 19, -1, 43, - -1, 140, -1, 142, -1, -1, -1, -1, 147, 148, - -1, -1, 56, -1, -1, -1, 60, 61, -1, 63, - 64, -1, 66, 3, 68, 5, 6, 7, 8, 9, - 10, 75, 171, -1, -1, -1, -1, -1, 177, -1, - -1, 85, -1, 87, 88, 89, -1, -1, -1, -1, - -1, 95, -1, -1, -1, -1, -1, 101, -1, -1, - -1, -1, 3, -1, 5, 6, 7, 8, 9, 10, - -1, -1, -1, -1, 118, -1, -1, -1, 122, 123, - 124, -1, 126, 127, 64, 129, -1, -1, -1, 133, - -1, -1, -1, -1, 138, -1, 140, -1, 142, -1, - -1, -1, -1, 147, 148, -1, -1, -1, -1, -1, - -1, 155, -1, -1, 158, 159, 160, -1, -1, 163, - 164, 101, -1, 64, -1, -1, -1, -1, -1, -1, - 174, -1, -1, -1, 156, 157, 158, 159, 160, 161, - 162, -1, -1, -1, -1, -1, 126, -1, 170, 171, - -1, -1, -1, -1, -1, -1, -1, -1, 138, -1, - 101, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 155, -1, -1, 158, 159, - 160, -1, -1, 163, 164, 126, -1, -1, -1, -1, - -1, -1, -1, -1, 174, -1, -1, 138, -1, 4, - -1, -1, -1, -1, -1, -1, -1, 12, -1, -1, - -1, -1, -1, -1, 155, -1, -1, 158, 159, 160, - -1, -1, 163, 164, -1, -1, 31, -1, 33, -1, - -1, -1, -1, 174, 39, 40, -1, -1, 43, -1, - -1, -1, -1, 48, -1, -1, -1, -1, -1, 54, - -1, 56, -1, -1, -1, 60, 61, -1, 63, -1, - -1, 66, -1, 68, -1, -1, -1, -1, -1, -1, - 75, -1, -1, -1, -1, -1, 81, 82, -1, -1, - 85, -1, 87, 88, 89, 90, -1, -1, -1, -1, - 95, -1, -1, -1, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 118, -1, -1, -1, 122, 123, 124, - -1, 31, 127, 33, 129, -1, -1, -1, 133, 39, - 40, -1, -1, 43, 139, 140, -1, 142, 48, -1, - -1, -1, 147, 148, 54, -1, 56, -1, -1, -1, - 60, 61, -1, 63, -1, -1, 66, -1, 68, -1, - -1, -1, -1, -1, -1, 75, 171, -1, -1, -1, - -1, 81, -1, -1, -1, 85, -1, 87, 88, 89, - 90, -1, -1, -1, -1, 95, -1, -1, -1, -1, + -1, -1, 4, -1, -1, -1, -1, 136, -1, -1, + -1, -1, 141, 142, 143, -1, -1, 146, -1, 148, + -1, -1, -1, 152, -1, -1, -1, -1, -1, 31, + 159, 33, 161, -1, 163, -1, 38, 39, -1, -1, + -1, 43, 171, 172, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 59, -1, -1, + -1, -1, -1, 65, 66, -1, 68, -1, 70, -1, + 72, 200, -1, 75, -1, -1, -1, -1, -1, -1, + 82, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 93, -1, 95, 96, 97, -1, -1, -1, -1, + -1, -1, 104, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 4, -1, 118, -1, - -1, -1, 122, 123, 124, -1, -1, 127, -1, 129, - -1, -1, -1, 133, -1, -1, -1, -1, -1, 139, - 140, -1, 142, 31, -1, 33, -1, 147, 148, -1, - 38, 39, -1, -1, -1, 43, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 56, -1, - -1, 171, 60, 61, -1, 63, -1, 65, 66, -1, - 68, -1, -1, -1, -1, -1, -1, 75, -1, -1, - -1, -1, -1, -1, 4, -1, -1, 85, -1, 87, - 88, 89, -1, -1, -1, -1, -1, 95, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 107, - -1, 31, -1, 33, -1, -1, -1, -1, 38, 39, - 118, -1, -1, 43, 122, 123, 124, -1, -1, 127, - -1, 129, 130, -1, -1, 133, 56, -1, -1, -1, - 60, 61, 140, 63, 142, 65, 66, -1, 68, 147, - 148, -1, -1, -1, -1, 75, -1, -1, -1, -1, - -1, -1, 160, -1, -1, 85, -1, 87, 88, 89, - -1, -1, -1, 171, -1, 95, -1, -1, -1, 4, - -1, -1, -1, -1, -1, -1, -1, 107, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 22, 118, -1, - -1, -1, 122, 123, 124, -1, 31, 127, 33, 129, - 130, -1, -1, 133, 39, -1, -1, -1, 43, -1, - 140, -1, 142, -1, -1, -1, -1, 147, 148, -1, - -1, 56, -1, -1, -1, 60, 61, -1, 63, -1, - 160, 66, -1, 68, -1, -1, -1, -1, -1, -1, - 75, 171, -1, -1, -1, -1, -1, 4, -1, -1, - 85, -1, 87, 88, 89, -1, -1, -1, -1, -1, - 95, 13, 14, 15, 16, 17, 18, 19, 20, 21, - -1, -1, -1, -1, 31, -1, 33, -1, -1, -1, - -1, -1, 39, 118, -1, -1, 43, 122, 123, 124, - -1, -1, 127, -1, 129, -1, -1, -1, 133, 56, - -1, -1, -1, 60, 61, 140, 63, 142, -1, 66, - -1, 68, 147, 148, -1, -1, -1, -1, 75, 13, - 14, 15, 16, 17, 18, 19, 20, 21, 85, -1, - 87, 88, 89, -1, -1, -1, 171, -1, 95, -1, - -1, -1, 13, 14, 15, 16, 17, 18, 19, 20, - 21, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 118, -1, -1, -1, 122, 123, 124, -1, -1, - 127, -1, 129, -1, -1, -1, 133, -1, -1, -1, - -1, -1, -1, 140, -1, 142, -1, -1, -1, -1, - 147, 148, 13, 14, 15, 16, 17, 18, 19, 151, - 21, 153, 154, 155, 156, 157, 158, 159, 160, 161, - 162, -1, -1, -1, 171, -1, -1, -1, 170, 171, - -1, -1, -1, 175, 13, 14, 15, 16, 17, 18, - 19, 20, 21, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 13, 14, 15, 16, - 17, 18, 19, 20, 21, -1, -1, 151, -1, 153, - 154, 155, 156, 157, 158, 159, 160, 161, 162, 13, - 14, 15, 16, 17, 18, 19, 170, 171, -1, -1, - 151, 175, 153, 154, 155, 156, 157, 158, 159, 160, - 161, 162, -1, -1, -1, -1, -1, -1, -1, 170, - 171, -1, -1, -1, 175, 13, 14, 15, 16, 17, + -1, 123, -1, -1, -1, -1, -1, -1, 4, -1, + -1, -1, -1, -1, 136, -1, -1, -1, -1, 141, + 142, 143, -1, -1, 146, -1, 148, 149, -1, -1, + 152, -1, -1, -1, -1, 31, -1, 33, -1, 161, + -1, 163, 38, 39, -1, -1, -1, 43, -1, 171, + 172, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 59, -1, -1, -1, 189, -1, 65, + 66, -1, 68, -1, 70, -1, 72, -1, 200, 75, + 4, -1, -1, -1, -1, -1, 82, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 93, 22, 95, + 96, 97, -1, -1, -1, -1, -1, 31, 104, 33, + -1, -1, -1, -1, -1, 39, -1, -1, -1, 43, + -1, -1, -1, -1, -1, -1, -1, 123, -1, -1, + -1, -1, -1, -1, -1, 59, -1, -1, -1, -1, + 136, 65, 66, -1, 68, 141, 142, 143, 72, -1, + 146, 75, 148, 149, -1, -1, 152, -1, 82, -1, + -1, -1, -1, -1, -1, 161, -1, 163, -1, 93, + -1, 95, 96, 97, 4, 171, 172, -1, -1, -1, + 104, 13, 14, 15, 16, 17, 18, 19, 20, 21, + -1, -1, -1, 189, -1, -1, -1, -1, -1, -1, + -1, 31, -1, 33, 200, -1, -1, -1, -1, 39, + -1, -1, 136, 43, -1, -1, -1, 141, 142, 143, + -1, -1, 146, -1, 148, -1, -1, -1, 152, 59, + -1, -1, -1, -1, -1, 65, 66, 161, 68, 163, + -1, -1, 72, -1, -1, 75, -1, 171, 172, -1, + -1, -1, 82, 13, 14, 15, 16, 17, 18, 19, + 20, 21, -1, 93, -1, 95, 96, 97, -1, -1, + -1, -1, -1, -1, 104, -1, 200, -1, 13, 14, + 15, 16, 17, 18, 19, 20, 21, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 136, -1, -1, -1, + -1, 141, 142, 143, -1, -1, 146, -1, 148, -1, + -1, -1, 152, -1, 13, 14, 15, 16, 17, 18, + 19, 161, 21, 163, -1, -1, -1, -1, -1, -1, + -1, 171, 172, -1, -1, -1, -1, -1, 180, -1, + 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, + -1, -1, -1, -1, -1, -1, -1, 199, 200, -1, + 200, -1, 204, 13, 14, 15, 16, 17, 18, 19, + 20, 21, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 13, 14, 15, 16, 17, 18, 19, 20, 21, -1, -1, -1, -1, -1, -1, -1, -1, -1, 13, 14, 15, 16, 17, 18, 19, - -1, -1, 153, 154, 155, 156, 157, 158, 159, 160, - 161, 162, 13, 14, 15, 16, 17, 18, 19, 170, - 171, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 151, -1, 153, 154, 155, 156, 157, 158, - 159, 160, 161, 162, 13, 14, 15, 16, 17, 18, - 19, 170, 171, 172, 151, 152, 153, 154, 155, 156, - 157, 158, 159, 160, 161, 162, -1, -1, -1, -1, - -1, -1, -1, 170, 171, -1, -1, -1, -1, 153, - 154, 155, 156, 157, 158, 159, 160, 161, 162, -1, - -1, -1, -1, -1, -1, -1, 170, 171, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 151, -1, 153, 154, 155, 156, 157, - 158, 159, 160, 161, 162, -1, -1, -1, -1, -1, - -1, -1, 170, 171, 154, 155, 156, 157, 158, 159, - 160, 161, 162, -1, -1, -1, -1, 4, -1, -1, - 170, 171, -1, -1, 155, 156, 157, 158, 159, 160, - 161, 162, -1, -1, -1, -1, -1, -1, -1, 170, - 171, -1, -1, -1, 31, -1, 33, -1, -1, -1, - -1, -1, 39, 40, -1, -1, 43, 156, 157, 158, - 159, 160, 161, 162, -1, -1, -1, 54, -1, 56, - -1, 170, 171, 60, 61, -1, 63, -1, -1, 66, - -1, 68, -1, -1, -1, -1, -1, -1, 75, -1, - -1, -1, -1, -1, -1, 4, -1, -1, 85, -1, - 87, 88, 89, 90, -1, -1, 93, -1, 95, -1, - 97, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 31, -1, 33, -1, -1, -1, -1, -1, - 39, 118, -1, -1, 43, 122, 123, 124, -1, -1, - 127, -1, 129, -1, -1, -1, 133, 56, -1, -1, - -1, 60, 61, 140, 63, 142, -1, 66, -1, 68, - 147, 148, -1, -1, -1, 4, 75, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 85, -1, 87, 88, - 89, -1, -1, -1, -1, -1, 95, -1, -1, -1, - -1, -1, 31, -1, 33, -1, -1, -1, -1, -1, - 39, -1, -1, -1, -1, -1, -1, -1, -1, 118, - -1, -1, -1, 122, 123, 124, -1, 56, 127, -1, - 129, 60, 61, -1, 133, -1, -1, 66, -1, 68, - -1, 140, -1, 142, -1, -1, 75, -1, 147, 148, - -1, -1, -1, -1, -1, -1, -1, -1, 87, 88, - 89, -1, -1, -1, -1, -1, 95, -1, -1, -1, + 180, -1, 182, 183, 184, 185, 186, 187, 188, 189, + 190, 191, 13, 14, 15, 16, 17, 18, 19, 199, + 200, -1, -1, -1, 204, 180, -1, 182, 183, 184, + 185, 186, 187, 188, 189, 190, 191, -1, -1, -1, + -1, -1, -1, -1, 199, 200, -1, -1, -1, 204, + 13, 14, 15, 16, 17, 18, 19, 20, 21, -1, + -1, -1, -1, -1, -1, -1, 13, 14, 15, 16, + 17, 18, 19, 182, 183, 184, 185, 186, 187, 188, + 189, 190, 191, 13, 14, 15, 16, 17, 18, 19, + 199, 200, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 122, 123, 124, -1, -1, 127, -1, - -1, -1, -1, 23, 133, 25, 26, 27, -1, 29, - 30, 140, 32, 142, -1, 35, -1, 37, 147, 148, - -1, -1, -1, -1, 44, 45, 46, 47, -1, 49, - 50, 51, 52, 53, -1, 55, -1, 57, 58, 59, - -1, -1, 62, -1, -1, -1, -1, 67, -1, 69, - 70, 71, 72, 73, 74, -1, 76, 77, 78, 79, - 80, -1, -1, 83, -1, -1, 86, -1, -1, -1, - -1, 91, 92, -1, 94, -1, -1, -1, 98, 99, - 100, -1, 102, 103, 104, 105, 106, -1, 108, -1, - 110, 111, 112, 113, 114, 115, 116, 117, -1, 119, - 120, 121, -1, -1, -1, 125, -1, -1, 128, -1, - -1, 131, 132, -1, -1, 135, 136, 137, -1, -1, - -1, 141, -1, 143, 144, 145, 146, -1, -1, 149 + 180, -1, 182, 183, 184, 185, 186, 187, 188, 189, + 190, 191, -1, -1, -1, -1, -1, -1, -1, 199, + 200, 201, 180, 181, 182, 183, 184, 185, 186, 187, + 188, 189, 190, 191, -1, -1, -1, -1, -1, -1, + -1, 199, 200, 183, 184, 185, 186, 187, 188, 189, + 190, 191, -1, -1, -1, -1, -1, -1, -1, 199, + 200, 182, 183, 184, 185, 186, 187, 188, 189, 190, + 191, -1, -1, -1, -1, -1, -1, -1, 199, 200, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 180, -1, 182, + 183, 184, 185, 186, 187, 188, 189, 190, 191, -1, + -1, -1, -1, -1, -1, -1, 199, 200, 185, 186, + 187, 188, 189, 190, 191, 4, -1, -1, -1, -1, + -1, -1, 199, 200, 184, 185, 186, 187, 188, 189, + 190, 191, -1, -1, -1, -1, -1, -1, -1, 199, + 200, -1, 31, -1, 33, -1, -1, -1, -1, -1, + 39, 40, -1, -1, 43, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, 57, -1, + 59, -1, -1, -1, -1, -1, 65, 66, -1, 68, + -1, -1, -1, 72, -1, -1, 75, 4, -1, -1, + -1, -1, -1, 82, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 93, -1, 95, 96, 97, 98, + -1, -1, 101, -1, 31, 104, 33, -1, -1, 108, + -1, -1, 39, -1, -1, -1, 43, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 59, -1, -1, -1, -1, 136, 65, 66, + -1, 68, 141, 142, 143, 72, -1, 146, 75, 148, + -1, -1, -1, 152, -1, 82, -1, -1, -1, -1, + -1, -1, 161, -1, 163, -1, 93, -1, 95, 96, + 97, 4, 171, 172, -1, -1, -1, 104, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, 31, -1, + 33, -1, -1, -1, -1, -1, 39, -1, -1, 136, + -1, -1, -1, -1, 141, 142, 143, -1, -1, 146, + -1, 148, -1, -1, -1, 152, 59, -1, -1, -1, + -1, -1, 65, 66, 161, -1, 163, -1, -1, 72, + -1, -1, 75, -1, 171, 172, -1, -1, -1, 82, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 95, 96, 97, -1, -1, -1, -1, -1, + -1, 104, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, 141, 142, + 143, -1, -1, 146, -1, -1, -1, -1, -1, 152, + -1, -1, -1, -1, -1, -1, -1, -1, 161, -1, + 163, -1, -1, -1, -1, -1, -1, -1, 171, 172, + 23, -1, 25, 26, 27, -1, 29, 30, -1, 32, + -1, -1, 35, -1, 37, -1, -1, -1, 41, 42, + -1, 44, 45, 46, 47, -1, 49, 50, 51, 52, + 53, 54, 55, 56, -1, 58, -1, 60, 61, 62, + 63, 64, -1, -1, 67, -1, -1, -1, 71, -1, + 73, 74, -1, 76, 77, 78, 79, 80, 81, -1, + 83, 84, 85, 86, 87, 88, -1, -1, 91, -1, + -1, 94, -1, -1, -1, -1, 99, 100, -1, 102, + 103, -1, 105, 106, -1, -1, 109, 110, 111, 112, + 113, 114, -1, 116, 117, 118, 119, 120, 121, 122, + -1, 124, 125, -1, 127, 128, 129, 130, 131, 132, + 133, 134, 135, -1, 137, 138, 139, 140, -1, -1, + -1, 144, -1, -1, 147, -1, -1, 150, 151, -1, + -1, 154, 155, 156, 157, -1, -1, 160, -1, 162, + -1, 164, 165, 166, 167, 168, 169, 170, -1, -1, + 173 }; /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing symbol of state STATE-NUM. */ static const yytype_uint16 yystos[] = { - 0, 180, 181, 0, 4, 31, 33, 39, 40, 43, - 48, 54, 56, 60, 61, 63, 66, 68, 75, 81, - 85, 87, 88, 89, 90, 95, 118, 122, 123, 124, - 127, 129, 133, 139, 140, 142, 147, 148, 171, 185, - 186, 187, 188, 189, 192, 193, 200, 211, 225, 229, - 231, 232, 233, 234, 237, 238, 241, 243, 244, 245, - 246, 248, 249, 250, 251, 252, 254, 256, 273, 274, - 275, 276, 3, 4, 174, 3, 4, 3, 4, 227, - 87, 230, 8, 3, 4, 230, 174, 230, 231, 3, - 227, 199, 200, 3, 227, 231, 23, 25, 26, 27, - 29, 30, 32, 35, 37, 44, 45, 46, 47, 49, - 50, 51, 52, 53, 55, 57, 58, 59, 62, 67, - 69, 70, 71, 72, 73, 74, 76, 77, 78, 79, - 80, 83, 86, 91, 92, 94, 98, 99, 100, 102, - 103, 104, 105, 106, 108, 110, 111, 112, 113, 114, - 115, 116, 117, 119, 120, 121, 125, 128, 131, 132, - 135, 136, 137, 141, 143, 144, 145, 146, 149, 201, - 203, 272, 173, 182, 182, 93, 97, 191, 211, 232, - 237, 243, 247, 254, 273, 276, 173, 173, 176, 173, - 176, 173, 184, 173, 152, 242, 176, 255, 256, 255, - 255, 3, 4, 38, 65, 107, 130, 160, 174, 205, - 228, 257, 258, 271, 211, 273, 274, 276, 255, 173, - 8, 176, 173, 274, 176, 254, 134, 176, 174, 174, - 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, - 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, - 174, 174, 174, 174, 150, 172, 12, 82, 185, 190, - 193, 232, 234, 245, 246, 249, 177, 3, 3, 4, - 176, 271, 235, 109, 239, 243, 3, 4, 176, 183, - 253, 257, 257, 178, 171, 174, 198, 255, 175, 208, - 209, 210, 228, 175, 218, 257, 267, 174, 221, 8, - 228, 3, 5, 6, 7, 8, 9, 10, 64, 101, - 126, 138, 155, 158, 159, 160, 163, 164, 174, 214, - 215, 216, 214, 217, 8, 8, 202, 217, 216, 8, - 8, 216, 8, 216, 214, 68, 216, 212, 213, 214, - 272, 216, 212, 214, 274, 274, 8, 11, 204, 5, - 277, 274, 203, 171, 174, 173, 184, 177, 199, 236, - 152, 96, 199, 223, 240, 173, 176, 183, 177, 185, - 200, 252, 257, 175, 217, 160, 213, 194, 195, 196, - 197, 200, 254, 177, 150, 178, 177, 199, 219, 150, - 223, 177, 200, 220, 223, 175, 175, 174, 214, 214, - 214, 214, 214, 214, 214, 254, 13, 14, 15, 16, - 17, 18, 19, 20, 21, 151, 153, 154, 155, 156, - 157, 158, 159, 160, 161, 162, 170, 171, 150, 175, - 175, 175, 150, 175, 175, 175, 175, 175, 175, 175, - 175, 175, 3, 175, 150, 175, 175, 150, 175, 175, - 175, 175, 175, 170, 175, 175, 203, 8, 184, 246, - 152, 254, 173, 177, 200, 224, 225, 177, 189, 177, - 184, 172, 172, 175, 150, 254, 160, 174, 198, 205, - 228, 263, 265, 266, 210, 216, 254, 276, 257, 175, - 173, 173, 254, 175, 160, 174, 198, 205, 259, 261, - 262, 214, 214, 3, 214, 214, 214, 214, 214, 214, - 214, 214, 214, 214, 214, 214, 214, 214, 214, 214, - 214, 3, 214, 216, 8, 175, 213, 216, 5, 175, - 257, 173, 183, 184, 22, 197, 265, 253, 160, 194, - 205, 264, 265, 174, 198, 263, 269, 270, 173, 226, - 228, 261, 253, 160, 194, 205, 260, 261, 175, 174, - 198, 152, 172, 175, 184, 177, 265, 253, 175, 265, - 175, 194, 152, 268, 150, 173, 176, 175, 261, 253, - 175, 265, 175, 214, 194, 214, 184, 265, 175, 217, - 269, 206, 265, 175, 37, 49, 177, 207, 216, 152, - 152, 173, 222, 223, 222, 173 + 0, 209, 210, 0, 4, 31, 33, 39, 40, 43, + 48, 57, 59, 65, 66, 68, 72, 75, 82, 89, + 93, 95, 96, 97, 98, 104, 136, 141, 142, 143, + 146, 148, 152, 159, 161, 163, 171, 172, 200, 214, + 215, 216, 217, 218, 221, 222, 229, 240, 254, 258, + 260, 261, 262, 263, 266, 267, 270, 272, 273, 274, + 275, 277, 278, 279, 280, 281, 283, 285, 303, 304, + 305, 306, 3, 4, 203, 3, 4, 3, 4, 256, + 95, 259, 8, 3, 4, 259, 203, 259, 260, 3, + 256, 228, 229, 3, 256, 260, 23, 25, 26, 27, + 29, 30, 32, 35, 37, 41, 42, 44, 45, 46, + 47, 49, 50, 51, 52, 53, 54, 55, 56, 58, + 60, 61, 62, 63, 64, 67, 71, 73, 74, 76, + 77, 78, 79, 80, 81, 83, 84, 85, 86, 87, + 88, 91, 94, 99, 100, 102, 103, 105, 106, 109, + 110, 111, 112, 113, 114, 116, 117, 118, 119, 120, + 121, 122, 124, 125, 127, 128, 129, 130, 131, 132, + 133, 134, 135, 137, 138, 139, 140, 144, 147, 150, + 151, 154, 155, 156, 157, 160, 162, 164, 165, 166, + 167, 168, 169, 170, 173, 230, 232, 302, 202, 211, + 211, 101, 108, 220, 240, 261, 266, 272, 276, 283, + 303, 306, 202, 202, 205, 202, 205, 202, 213, 202, + 181, 271, 205, 284, 285, 284, 284, 3, 4, 38, + 70, 123, 149, 189, 203, 234, 257, 286, 287, 300, + 240, 303, 304, 306, 284, 202, 8, 205, 202, 304, + 205, 283, 153, 205, 203, 203, 203, 203, 203, 203, + 203, 203, 203, 203, 203, 203, 203, 203, 203, 203, + 203, 203, 203, 203, 203, 203, 203, 203, 203, 203, + 203, 203, 203, 203, 203, 203, 179, 201, 12, 90, + 214, 219, 222, 261, 263, 274, 275, 278, 206, 3, + 3, 4, 205, 300, 264, 126, 268, 272, 3, 4, + 205, 212, 282, 286, 286, 207, 200, 203, 227, 284, + 204, 237, 238, 239, 257, 204, 247, 286, 296, 203, + 250, 8, 257, 3, 5, 6, 7, 8, 9, 10, + 69, 115, 145, 158, 184, 187, 188, 189, 192, 193, + 203, 243, 244, 245, 243, 246, 8, 8, 231, 246, + 245, 8, 8, 245, 8, 245, 243, 75, 245, 241, + 242, 243, 8, 302, 8, 245, 304, 241, 243, 304, + 174, 175, 176, 177, 178, 301, 304, 304, 8, 11, + 233, 5, 307, 8, 304, 232, 200, 203, 202, 213, + 206, 228, 265, 181, 107, 228, 252, 269, 202, 205, + 212, 206, 214, 229, 281, 286, 204, 246, 189, 242, + 223, 224, 225, 226, 229, 283, 206, 179, 207, 206, + 228, 248, 179, 252, 206, 229, 249, 252, 204, 204, + 203, 243, 243, 243, 243, 243, 243, 243, 283, 13, + 14, 15, 16, 17, 18, 19, 20, 21, 180, 182, + 183, 184, 185, 186, 187, 188, 189, 190, 191, 199, + 200, 179, 204, 204, 204, 179, 204, 204, 204, 204, + 204, 204, 204, 204, 204, 3, 204, 179, 204, 204, + 204, 204, 179, 204, 204, 204, 204, 204, 204, 204, + 204, 199, 204, 204, 204, 232, 8, 213, 275, 181, + 283, 202, 206, 229, 253, 254, 206, 218, 206, 213, + 201, 201, 204, 179, 283, 189, 203, 227, 234, 257, + 292, 294, 295, 239, 245, 283, 306, 286, 204, 202, + 202, 283, 204, 189, 203, 227, 234, 288, 290, 291, + 243, 243, 3, 243, 243, 243, 243, 243, 243, 243, + 243, 243, 243, 243, 243, 243, 243, 243, 243, 243, + 3, 243, 245, 8, 204, 242, 245, 5, 204, 286, + 202, 212, 213, 22, 226, 294, 282, 189, 223, 234, + 293, 294, 203, 227, 292, 298, 299, 202, 255, 257, + 290, 282, 189, 223, 234, 289, 290, 204, 203, 227, + 181, 201, 204, 213, 206, 294, 282, 204, 294, 204, + 223, 181, 297, 179, 202, 205, 204, 290, 282, 204, + 294, 204, 243, 223, 243, 213, 294, 204, 246, 298, + 235, 294, 204, 37, 50, 206, 236, 245, 181, 181, + 202, 251, 252, 251, 202 }; #define yyerrok (yyerrstatus = 0) @@ -2653,7 +2766,7 @@ yyreduce: case 2: /* Line 1455 of yacc.c */ -#line 325 "parser.y" +#line 328 "parser.y" { fix_incomplete(); check_statements((yyvsp[(1) - (1)].stmt_list), FALSE); check_all_user_types((yyvsp[(1) - (1)].stmt_list)); @@ -2662,6 +2775,7 @@ yyreduce: write_proxies((yyvsp[(1) - (1)].stmt_list)); write_client((yyvsp[(1) - (1)].stmt_list)); write_server((yyvsp[(1) - (1)].stmt_list)); + write_regscript((yyvsp[(1) - (1)].stmt_list)); write_dlldata((yyvsp[(1) - (1)].stmt_list)); write_local_stubs((yyvsp[(1) - (1)].stmt_list)); ;} @@ -2670,28 +2784,28 @@ yyreduce: case 3: /* Line 1455 of yacc.c */ -#line 338 "parser.y" +#line 342 "parser.y" { (yyval.stmt_list) = NULL; ;} break; case 4: /* Line 1455 of yacc.c */ -#line 339 "parser.y" +#line 343 "parser.y" { (yyval.stmt_list) = append_statement((yyvsp[(1) - (2)].stmt_list), make_statement_reference((yyvsp[(2) - (2)].type))); ;} break; case 5: /* Line 1455 of yacc.c */ -#line 340 "parser.y" +#line 344 "parser.y" { (yyval.stmt_list) = append_statement((yyvsp[(1) - (2)].stmt_list), make_statement_type_decl((yyvsp[(2) - (2)].type))); ;} break; case 6: /* Line 1455 of yacc.c */ -#line 341 "parser.y" +#line 345 "parser.y" { (yyval.stmt_list) = (yyvsp[(1) - (3)].stmt_list); reg_type((yyvsp[(2) - (3)].type), (yyvsp[(2) - (3)].type)->name, 0); ;} @@ -2700,7 +2814,7 @@ yyreduce: case 7: /* Line 1455 of yacc.c */ -#line 344 "parser.y" +#line 348 "parser.y" { (yyval.stmt_list) = append_statement((yyvsp[(1) - (2)].stmt_list), make_statement_type_decl((yyvsp[(2) - (2)].type))); reg_type((yyvsp[(2) - (2)].type), (yyvsp[(2) - (2)].type)->name, 0); ;} @@ -2709,56 +2823,56 @@ yyreduce: case 8: /* Line 1455 of yacc.c */ -#line 347 "parser.y" +#line 351 "parser.y" { (yyval.stmt_list) = append_statement((yyvsp[(1) - (2)].stmt_list), make_statement_module((yyvsp[(2) - (2)].type))); ;} break; case 9: /* Line 1455 of yacc.c */ -#line 348 "parser.y" +#line 352 "parser.y" { (yyval.stmt_list) = append_statement((yyvsp[(1) - (2)].stmt_list), make_statement_library((yyvsp[(2) - (2)].typelib))); ;} break; case 10: /* Line 1455 of yacc.c */ -#line 349 "parser.y" +#line 353 "parser.y" { (yyval.stmt_list) = append_statement((yyvsp[(1) - (2)].stmt_list), (yyvsp[(2) - (2)].statement)); ;} break; case 11: /* Line 1455 of yacc.c */ -#line 352 "parser.y" +#line 356 "parser.y" { (yyval.stmt_list) = NULL; ;} break; case 12: /* Line 1455 of yacc.c */ -#line 353 "parser.y" +#line 357 "parser.y" { (yyval.stmt_list) = append_statement((yyvsp[(1) - (2)].stmt_list), make_statement_reference((yyvsp[(2) - (2)].type))); ;} break; case 13: /* Line 1455 of yacc.c */ -#line 354 "parser.y" +#line 358 "parser.y" { (yyval.stmt_list) = append_statement((yyvsp[(1) - (2)].stmt_list), make_statement_type_decl((yyvsp[(2) - (2)].type))); ;} break; case 14: /* Line 1455 of yacc.c */ -#line 355 "parser.y" +#line 359 "parser.y" { (yyval.stmt_list) = (yyvsp[(1) - (3)].stmt_list); reg_type((yyvsp[(2) - (3)].type), (yyvsp[(2) - (3)].type)->name, 0); ;} break; case 15: /* Line 1455 of yacc.c */ -#line 356 "parser.y" +#line 360 "parser.y" { (yyval.stmt_list) = append_statement((yyvsp[(1) - (2)].stmt_list), make_statement_type_decl((yyvsp[(2) - (2)].type))); reg_type((yyvsp[(2) - (2)].type), (yyvsp[(2) - (2)].type)->name, 0); ;} @@ -2767,112 +2881,112 @@ yyreduce: case 16: /* Line 1455 of yacc.c */ -#line 359 "parser.y" +#line 363 "parser.y" { (yyval.stmt_list) = append_statement((yyvsp[(1) - (2)].stmt_list), make_statement_module((yyvsp[(2) - (2)].type))); ;} break; case 17: /* Line 1455 of yacc.c */ -#line 360 "parser.y" +#line 364 "parser.y" { (yyval.stmt_list) = append_statement((yyvsp[(1) - (2)].stmt_list), (yyvsp[(2) - (2)].statement)); ;} break; case 18: /* Line 1455 of yacc.c */ -#line 361 "parser.y" +#line 365 "parser.y" { (yyval.stmt_list) = append_statement((yyvsp[(1) - (2)].stmt_list), make_statement_importlib((yyvsp[(2) - (2)].str))); ;} break; case 19: /* Line 1455 of yacc.c */ -#line 362 "parser.y" +#line 366 "parser.y" { (yyval.stmt_list) = append_statement((yyvsp[(1) - (2)].stmt_list), make_statement_library((yyvsp[(2) - (2)].typelib))); ;} break; case 20: /* Line 1455 of yacc.c */ -#line 365 "parser.y" +#line 369 "parser.y" { (yyval.stmt_list) = NULL; ;} break; case 21: /* Line 1455 of yacc.c */ -#line 366 "parser.y" +#line 370 "parser.y" { (yyval.stmt_list) = append_statement((yyvsp[(1) - (2)].stmt_list), (yyvsp[(2) - (2)].statement)); ;} break; case 24: /* Line 1455 of yacc.c */ -#line 374 "parser.y" +#line 378 "parser.y" { (yyval.statement) = make_statement_cppquote((yyvsp[(1) - (1)].str)); ;} break; case 25: /* Line 1455 of yacc.c */ -#line 375 "parser.y" +#line 379 "parser.y" { (yyval.statement) = make_statement_type_decl((yyvsp[(1) - (2)].type)); ;} break; case 26: /* Line 1455 of yacc.c */ -#line 376 "parser.y" +#line 380 "parser.y" { (yyval.statement) = make_statement_declaration((yyvsp[(1) - (2)].var)); ;} break; case 27: /* Line 1455 of yacc.c */ -#line 377 "parser.y" +#line 381 "parser.y" { (yyval.statement) = make_statement_import((yyvsp[(1) - (1)].str)); ;} break; case 28: /* Line 1455 of yacc.c */ -#line 378 "parser.y" +#line 382 "parser.y" { (yyval.statement) = (yyvsp[(1) - (2)].statement); ;} break; case 32: /* Line 1455 of yacc.c */ -#line 385 "parser.y" +#line 389 "parser.y" { (yyval.type) = (yyvsp[(2) - (2)].type); (yyval.type)->attrs = check_enum_attrs((yyvsp[(1) - (2)].attr_list)); ;} break; case 33: /* Line 1455 of yacc.c */ -#line 386 "parser.y" +#line 390 "parser.y" { (yyval.type) = (yyvsp[(2) - (2)].type); (yyval.type)->attrs = check_struct_attrs((yyvsp[(1) - (2)].attr_list)); ;} break; case 34: /* Line 1455 of yacc.c */ -#line 387 "parser.y" +#line 391 "parser.y" { (yyval.type) = (yyvsp[(2) - (2)].type); (yyval.type)->attrs = check_union_attrs((yyvsp[(1) - (2)].attr_list)); ;} break; case 35: /* Line 1455 of yacc.c */ -#line 390 "parser.y" +#line 394 "parser.y" { (yyval.str) = (yyvsp[(3) - (4)].str); ;} break; case 36: /* Line 1455 of yacc.c */ -#line 392 "parser.y" +#line 396 "parser.y" { assert(yychar == YYEMPTY); (yyval.import) = xmalloc(sizeof(struct _import_t)); (yyval.import)->name = (yyvsp[(2) - (3)].str); @@ -2884,7 +2998,7 @@ yyreduce: case 37: /* Line 1455 of yacc.c */ -#line 400 "parser.y" +#line 404 "parser.y" { (yyval.str) = (yyvsp[(1) - (3)].import)->name; if ((yyvsp[(1) - (3)].import)->import_performed) pop_import(); free((yyvsp[(1) - (3)].import)); @@ -2894,21 +3008,21 @@ yyreduce: case 38: /* Line 1455 of yacc.c */ -#line 407 "parser.y" +#line 411 "parser.y" { (yyval.str) = (yyvsp[(3) - (5)].str); if(!parse_only) add_importlib((yyvsp[(3) - (5)].str)); ;} break; case 39: /* Line 1455 of yacc.c */ -#line 410 "parser.y" +#line 414 "parser.y" { (yyval.str) = (yyvsp[(2) - (2)].str); ;} break; case 40: /* Line 1455 of yacc.c */ -#line 412 "parser.y" +#line 416 "parser.y" { (yyval.typelib) = make_library((yyvsp[(2) - (3)].str), check_library_attrs((yyvsp[(2) - (3)].str), (yyvsp[(1) - (3)].attr_list))); if (!parse_only) start_typelib((yyval.typelib)); ;} @@ -2917,7 +3031,7 @@ yyreduce: case 41: /* Line 1455 of yacc.c */ -#line 417 "parser.y" +#line 421 "parser.y" { (yyval.typelib) = (yyvsp[(1) - (4)].typelib); (yyval.typelib)->stmts = (yyvsp[(2) - (4)].stmt_list); if (!parse_only) end_typelib(); @@ -2927,35 +3041,35 @@ yyreduce: case 42: /* Line 1455 of yacc.c */ -#line 423 "parser.y" +#line 427 "parser.y" { (yyval.var_list) = NULL; ;} break; case 44: /* Line 1455 of yacc.c */ -#line 427 "parser.y" +#line 431 "parser.y" { check_arg_attrs((yyvsp[(1) - (1)].var)); (yyval.var_list) = append_var( NULL, (yyvsp[(1) - (1)].var) ); ;} break; case 45: /* Line 1455 of yacc.c */ -#line 428 "parser.y" +#line 432 "parser.y" { check_arg_attrs((yyvsp[(3) - (3)].var)); (yyval.var_list) = append_var( (yyvsp[(1) - (3)].var_list), (yyvsp[(3) - (3)].var) ); ;} break; case 47: /* Line 1455 of yacc.c */ -#line 432 "parser.y" +#line 436 "parser.y" { (yyval.var_list) = append_var( (yyvsp[(1) - (3)].var_list), make_var(strdup("...")) ); ;} break; case 48: /* Line 1455 of yacc.c */ -#line 436 "parser.y" +#line 440 "parser.y" { if ((yyvsp[(2) - (3)].declspec)->stgclass != STG_NONE && (yyvsp[(2) - (3)].declspec)->stgclass != STG_REGISTER) error_loc("invalid storage class for function parameter\n"); (yyval.var) = declare_var((yyvsp[(1) - (3)].attr_list), (yyvsp[(2) - (3)].declspec), (yyvsp[(3) - (3)].declarator), TRUE); @@ -2966,7 +3080,7 @@ yyreduce: case 49: /* Line 1455 of yacc.c */ -#line 441 "parser.y" +#line 445 "parser.y" { if ((yyvsp[(1) - (2)].declspec)->stgclass != STG_NONE && (yyvsp[(1) - (2)].declspec)->stgclass != STG_REGISTER) error_loc("invalid storage class for function parameter\n"); (yyval.var) = declare_var(NULL, (yyvsp[(1) - (2)].declspec), (yyvsp[(2) - (2)].declarator), TRUE); @@ -2977,678 +3091,860 @@ yyreduce: case 50: /* Line 1455 of yacc.c */ -#line 448 "parser.y" +#line 452 "parser.y" { (yyval.expr) = (yyvsp[(2) - (3)].expr); ;} break; case 51: /* Line 1455 of yacc.c */ -#line 449 "parser.y" +#line 453 "parser.y" { (yyval.expr) = make_expr(EXPR_VOID); ;} break; case 52: /* Line 1455 of yacc.c */ -#line 452 "parser.y" +#line 456 "parser.y" { (yyval.attr_list) = NULL; ;} break; case 54: /* Line 1455 of yacc.c */ -#line 457 "parser.y" +#line 461 "parser.y" { (yyval.attr_list) = (yyvsp[(2) - (3)].attr_list); ;} break; case 55: /* Line 1455 of yacc.c */ -#line 460 "parser.y" +#line 464 "parser.y" { (yyval.attr_list) = append_attr( NULL, (yyvsp[(1) - (1)].attr) ); ;} break; case 56: /* Line 1455 of yacc.c */ -#line 461 "parser.y" +#line 465 "parser.y" { (yyval.attr_list) = append_attr( (yyvsp[(1) - (3)].attr_list), (yyvsp[(3) - (3)].attr) ); ;} break; case 57: /* Line 1455 of yacc.c */ -#line 462 "parser.y" +#line 466 "parser.y" { (yyval.attr_list) = append_attr( (yyvsp[(1) - (4)].attr_list), (yyvsp[(4) - (4)].attr) ); ;} break; case 58: /* Line 1455 of yacc.c */ -#line 465 "parser.y" +#line 469 "parser.y" { (yyval.str_list) = append_str( NULL, (yyvsp[(1) - (1)].str) ); ;} break; case 59: /* Line 1455 of yacc.c */ -#line 466 "parser.y" +#line 470 "parser.y" { (yyval.str_list) = append_str( (yyvsp[(1) - (3)].str_list), (yyvsp[(3) - (3)].str) ); ;} break; case 60: /* Line 1455 of yacc.c */ -#line 469 "parser.y" +#line 473 "parser.y" { (yyval.attr) = NULL; ;} break; case 61: /* Line 1455 of yacc.c */ -#line 470 "parser.y" +#line 474 "parser.y" { (yyval.attr) = make_attr(ATTR_AGGREGATABLE); ;} break; case 62: /* Line 1455 of yacc.c */ -#line 471 "parser.y" +#line 475 "parser.y" { (yyval.attr) = make_attrp(ATTR_ANNOTATION, (yyvsp[(3) - (4)].str)); ;} break; case 63: /* Line 1455 of yacc.c */ -#line 472 "parser.y" +#line 476 "parser.y" { (yyval.attr) = make_attr(ATTR_APPOBJECT); ;} break; case 64: /* Line 1455 of yacc.c */ -#line 473 "parser.y" +#line 477 "parser.y" { (yyval.attr) = make_attr(ATTR_ASYNC); ;} break; case 65: /* Line 1455 of yacc.c */ -#line 474 "parser.y" +#line 478 "parser.y" { (yyval.attr) = make_attr(ATTR_AUTO_HANDLE); ;} break; case 66: /* Line 1455 of yacc.c */ -#line 475 "parser.y" +#line 479 "parser.y" { (yyval.attr) = make_attr(ATTR_BINDABLE); ;} break; case 67: /* Line 1455 of yacc.c */ -#line 476 "parser.y" +#line 480 "parser.y" { (yyval.attr) = make_attr(ATTR_BROADCAST); ;} break; case 68: /* Line 1455 of yacc.c */ -#line 477 "parser.y" +#line 481 "parser.y" { (yyval.attr) = make_attrp(ATTR_CALLAS, (yyvsp[(3) - (4)].var)); ;} break; case 69: /* Line 1455 of yacc.c */ -#line 478 "parser.y" +#line 482 "parser.y" { (yyval.attr) = make_attrp(ATTR_CASE, (yyvsp[(3) - (4)].expr_list)); ;} break; case 70: /* Line 1455 of yacc.c */ -#line 479 "parser.y" - { (yyval.attr) = make_attrv(ATTR_CONTEXTHANDLE, 0); ;} +#line 483 "parser.y" + { (yyval.attr) = make_attr(ATTR_CODE); ;} break; case 71: /* Line 1455 of yacc.c */ -#line 480 "parser.y" - { (yyval.attr) = make_attrv(ATTR_CONTEXTHANDLE, 0); /* RPC_CONTEXT_HANDLE_DONT_SERIALIZE */ ;} +#line 484 "parser.y" + { (yyval.attr) = make_attr(ATTR_COMMSTATUS); ;} break; case 72: /* Line 1455 of yacc.c */ -#line 481 "parser.y" - { (yyval.attr) = make_attrv(ATTR_CONTEXTHANDLE, 0); /* RPC_CONTEXT_HANDLE_SERIALIZE */ ;} +#line 485 "parser.y" + { (yyval.attr) = make_attrv(ATTR_CONTEXTHANDLE, 0); ;} break; case 73: /* Line 1455 of yacc.c */ -#line 482 "parser.y" - { (yyval.attr) = make_attr(ATTR_CONTROL); ;} +#line 486 "parser.y" + { (yyval.attr) = make_attrv(ATTR_CONTEXTHANDLE, 0); /* RPC_CONTEXT_HANDLE_DONT_SERIALIZE */ ;} break; case 74: /* Line 1455 of yacc.c */ -#line 483 "parser.y" - { (yyval.attr) = make_attr(ATTR_DEFAULT); ;} +#line 487 "parser.y" + { (yyval.attr) = make_attrv(ATTR_CONTEXTHANDLE, 0); /* RPC_CONTEXT_HANDLE_SERIALIZE */ ;} break; case 75: /* Line 1455 of yacc.c */ -#line 484 "parser.y" - { (yyval.attr) = make_attr(ATTR_DEFAULTCOLLELEM); ;} +#line 488 "parser.y" + { (yyval.attr) = make_attr(ATTR_CONTROL); ;} break; case 76: /* Line 1455 of yacc.c */ -#line 485 "parser.y" - { (yyval.attr) = make_attrp(ATTR_DEFAULTVALUE, (yyvsp[(3) - (4)].expr)); ;} +#line 489 "parser.y" + { (yyval.attr) = make_attr(ATTR_DECODE); ;} break; case 77: /* Line 1455 of yacc.c */ -#line 486 "parser.y" - { (yyval.attr) = make_attr(ATTR_DEFAULTVTABLE); ;} +#line 490 "parser.y" + { (yyval.attr) = make_attr(ATTR_DEFAULT); ;} break; case 78: /* Line 1455 of yacc.c */ -#line 487 "parser.y" - { (yyval.attr) = make_attr(ATTR_DISPLAYBIND); ;} +#line 491 "parser.y" + { (yyval.attr) = make_attr(ATTR_DEFAULTBIND); ;} break; case 79: /* Line 1455 of yacc.c */ -#line 488 "parser.y" - { (yyval.attr) = make_attrp(ATTR_DLLNAME, (yyvsp[(3) - (4)].str)); ;} +#line 492 "parser.y" + { (yyval.attr) = make_attr(ATTR_DEFAULTCOLLELEM); ;} break; case 80: /* Line 1455 of yacc.c */ -#line 489 "parser.y" - { (yyval.attr) = make_attr(ATTR_DUAL); ;} +#line 493 "parser.y" + { (yyval.attr) = make_attrp(ATTR_DEFAULTVALUE, (yyvsp[(3) - (4)].expr)); ;} break; case 81: /* Line 1455 of yacc.c */ -#line 490 "parser.y" - { (yyval.attr) = make_attrp(ATTR_ENDPOINT, (yyvsp[(3) - (4)].str_list)); ;} +#line 494 "parser.y" + { (yyval.attr) = make_attr(ATTR_DEFAULTVTABLE); ;} break; case 82: /* Line 1455 of yacc.c */ -#line 491 "parser.y" - { (yyval.attr) = make_attrp(ATTR_ENTRY, (yyvsp[(3) - (4)].expr)); ;} +#line 495 "parser.y" + { (yyval.attr) = make_attr(ATTR_DISABLECONSISTENCYCHECK); ;} break; case 83: /* Line 1455 of yacc.c */ -#line 492 "parser.y" - { (yyval.attr) = make_attr(ATTR_EXPLICIT_HANDLE); ;} +#line 496 "parser.y" + { (yyval.attr) = make_attr(ATTR_DISPLAYBIND); ;} break; case 84: /* Line 1455 of yacc.c */ -#line 493 "parser.y" - { (yyval.attr) = make_attr(ATTR_HANDLE); ;} +#line 497 "parser.y" + { (yyval.attr) = make_attrp(ATTR_DLLNAME, (yyvsp[(3) - (4)].str)); ;} break; case 85: /* Line 1455 of yacc.c */ -#line 494 "parser.y" - { (yyval.attr) = make_attrp(ATTR_HELPCONTEXT, (yyvsp[(3) - (4)].expr)); ;} +#line 498 "parser.y" + { (yyval.attr) = make_attr(ATTR_DUAL); ;} break; case 86: /* Line 1455 of yacc.c */ -#line 495 "parser.y" - { (yyval.attr) = make_attrp(ATTR_HELPFILE, (yyvsp[(3) - (4)].str)); ;} +#line 499 "parser.y" + { (yyval.attr) = make_attr(ATTR_ENABLEALLOCATE); ;} break; case 87: /* Line 1455 of yacc.c */ -#line 496 "parser.y" - { (yyval.attr) = make_attrp(ATTR_HELPSTRING, (yyvsp[(3) - (4)].str)); ;} +#line 500 "parser.y" + { (yyval.attr) = make_attr(ATTR_ENCODE); ;} break; case 88: /* Line 1455 of yacc.c */ -#line 497 "parser.y" - { (yyval.attr) = make_attrp(ATTR_HELPSTRINGCONTEXT, (yyvsp[(3) - (4)].expr)); ;} +#line 501 "parser.y" + { (yyval.attr) = make_attrp(ATTR_ENDPOINT, (yyvsp[(3) - (4)].str_list)); ;} break; case 89: /* Line 1455 of yacc.c */ -#line 498 "parser.y" - { (yyval.attr) = make_attrp(ATTR_HELPSTRINGDLL, (yyvsp[(3) - (4)].str)); ;} +#line 502 "parser.y" + { (yyval.attr) = make_attrp(ATTR_ENTRY, (yyvsp[(3) - (4)].expr)); ;} break; case 90: /* Line 1455 of yacc.c */ -#line 499 "parser.y" - { (yyval.attr) = make_attr(ATTR_HIDDEN); ;} +#line 503 "parser.y" + { (yyval.attr) = make_attr(ATTR_EXPLICIT_HANDLE); ;} break; case 91: /* Line 1455 of yacc.c */ -#line 500 "parser.y" - { (yyval.attr) = make_attrp(ATTR_ID, (yyvsp[(3) - (4)].expr)); ;} +#line 504 "parser.y" + { (yyval.attr) = make_attr(ATTR_FAULTSTATUS); ;} break; case 92: /* Line 1455 of yacc.c */ -#line 501 "parser.y" - { (yyval.attr) = make_attr(ATTR_IDEMPOTENT); ;} +#line 505 "parser.y" + { (yyval.attr) = make_attr(ATTR_FORCEALLOCATE); ;} break; case 93: /* Line 1455 of yacc.c */ -#line 502 "parser.y" - { (yyval.attr) = make_attrp(ATTR_IIDIS, (yyvsp[(3) - (4)].expr)); ;} +#line 506 "parser.y" + { (yyval.attr) = make_attr(ATTR_HANDLE); ;} break; case 94: /* Line 1455 of yacc.c */ -#line 503 "parser.y" - { (yyval.attr) = make_attr(ATTR_IMMEDIATEBIND); ;} +#line 507 "parser.y" + { (yyval.attr) = make_attrp(ATTR_HELPCONTEXT, (yyvsp[(3) - (4)].expr)); ;} break; case 95: /* Line 1455 of yacc.c */ -#line 504 "parser.y" - { (yyval.attr) = make_attrp(ATTR_IMPLICIT_HANDLE, (yyvsp[(4) - (5)].str)); ;} +#line 508 "parser.y" + { (yyval.attr) = make_attrp(ATTR_HELPFILE, (yyvsp[(3) - (4)].str)); ;} break; case 96: /* Line 1455 of yacc.c */ -#line 505 "parser.y" - { (yyval.attr) = make_attr(ATTR_IN); ;} +#line 509 "parser.y" + { (yyval.attr) = make_attrp(ATTR_HELPSTRING, (yyvsp[(3) - (4)].str)); ;} break; case 97: /* Line 1455 of yacc.c */ -#line 506 "parser.y" - { (yyval.attr) = make_attr(ATTR_INPUTSYNC); ;} +#line 510 "parser.y" + { (yyval.attr) = make_attrp(ATTR_HELPSTRINGCONTEXT, (yyvsp[(3) - (4)].expr)); ;} break; case 98: /* Line 1455 of yacc.c */ -#line 507 "parser.y" - { (yyval.attr) = make_attrp(ATTR_LENGTHIS, (yyvsp[(3) - (4)].expr_list)); ;} +#line 511 "parser.y" + { (yyval.attr) = make_attrp(ATTR_HELPSTRINGDLL, (yyvsp[(3) - (4)].str)); ;} break; case 99: /* Line 1455 of yacc.c */ -#line 508 "parser.y" - { (yyval.attr) = make_attrp(ATTR_LIBLCID, (yyvsp[(3) - (4)].expr)); ;} +#line 512 "parser.y" + { (yyval.attr) = make_attr(ATTR_HIDDEN); ;} break; case 100: /* Line 1455 of yacc.c */ -#line 509 "parser.y" - { (yyval.attr) = make_attr(ATTR_PARAMLCID); ;} +#line 513 "parser.y" + { (yyval.attr) = make_attrp(ATTR_ID, (yyvsp[(3) - (4)].expr)); ;} break; case 101: /* Line 1455 of yacc.c */ -#line 510 "parser.y" - { (yyval.attr) = make_attr(ATTR_LOCAL); ;} +#line 514 "parser.y" + { (yyval.attr) = make_attr(ATTR_IDEMPOTENT); ;} break; case 102: /* Line 1455 of yacc.c */ -#line 511 "parser.y" - { (yyval.attr) = make_attr(ATTR_NONBROWSABLE); ;} +#line 515 "parser.y" + { (yyval.attr) = make_attr(ATTR_IGNORE); ;} break; case 103: /* Line 1455 of yacc.c */ -#line 512 "parser.y" - { (yyval.attr) = make_attr(ATTR_NONCREATABLE); ;} +#line 516 "parser.y" + { (yyval.attr) = make_attrp(ATTR_IIDIS, (yyvsp[(3) - (4)].expr)); ;} break; case 104: /* Line 1455 of yacc.c */ -#line 513 "parser.y" - { (yyval.attr) = make_attr(ATTR_NONEXTENSIBLE); ;} +#line 517 "parser.y" + { (yyval.attr) = make_attr(ATTR_IMMEDIATEBIND); ;} break; case 105: /* Line 1455 of yacc.c */ -#line 514 "parser.y" - { (yyval.attr) = make_attr(ATTR_OBJECT); ;} +#line 518 "parser.y" + { (yyval.attr) = make_attrp(ATTR_IMPLICIT_HANDLE, (yyvsp[(4) - (5)].str)); ;} break; case 106: /* Line 1455 of yacc.c */ -#line 515 "parser.y" - { (yyval.attr) = make_attr(ATTR_ODL); ;} +#line 519 "parser.y" + { (yyval.attr) = make_attr(ATTR_IN); ;} break; case 107: /* Line 1455 of yacc.c */ -#line 516 "parser.y" - { (yyval.attr) = make_attr(ATTR_OLEAUTOMATION); ;} +#line 520 "parser.y" + { (yyval.attr) = make_attr(ATTR_INPUTSYNC); ;} break; case 108: /* Line 1455 of yacc.c */ -#line 517 "parser.y" - { (yyval.attr) = make_attr(ATTR_OPTIONAL); ;} +#line 521 "parser.y" + { (yyval.attr) = make_attrp(ATTR_LENGTHIS, (yyvsp[(3) - (4)].expr_list)); ;} break; case 109: /* Line 1455 of yacc.c */ -#line 518 "parser.y" - { (yyval.attr) = make_attr(ATTR_OUT); ;} +#line 522 "parser.y" + { (yyval.attr) = make_attrp(ATTR_LIBLCID, (yyvsp[(3) - (4)].expr)); ;} break; case 110: /* Line 1455 of yacc.c */ -#line 519 "parser.y" - { (yyval.attr) = make_attrv(ATTR_POINTERDEFAULT, (yyvsp[(3) - (4)].num)); ;} +#line 523 "parser.y" + { (yyval.attr) = make_attr(ATTR_PARAMLCID); ;} break; case 111: /* Line 1455 of yacc.c */ -#line 520 "parser.y" - { (yyval.attr) = make_attr(ATTR_PROPGET); ;} +#line 524 "parser.y" + { (yyval.attr) = make_attr(ATTR_LICENSED); ;} break; case 112: /* Line 1455 of yacc.c */ -#line 521 "parser.y" - { (yyval.attr) = make_attr(ATTR_PROPPUT); ;} +#line 525 "parser.y" + { (yyval.attr) = make_attr(ATTR_LOCAL); ;} break; case 113: /* Line 1455 of yacc.c */ -#line 522 "parser.y" - { (yyval.attr) = make_attr(ATTR_PROPPUTREF); ;} +#line 526 "parser.y" + { (yyval.attr) = make_attr(ATTR_MAYBE); ;} break; case 114: /* Line 1455 of yacc.c */ -#line 523 "parser.y" - { (yyval.attr) = make_attr(ATTR_PUBLIC); ;} +#line 527 "parser.y" + { (yyval.attr) = make_attr(ATTR_MESSAGE); ;} break; case 115: /* Line 1455 of yacc.c */ -#line 525 "parser.y" - { expr_list_t *list = append_expr( NULL, (yyvsp[(3) - (6)].expr) ); - list = append_expr( list, (yyvsp[(5) - (6)].expr) ); - (yyval.attr) = make_attrp(ATTR_RANGE, list); ;} +#line 528 "parser.y" + { (yyval.attr) = make_attr(ATTR_NOCODE); ;} break; case 116: /* Line 1455 of yacc.c */ -#line 528 "parser.y" - { (yyval.attr) = make_attr(ATTR_READONLY); ;} +#line 529 "parser.y" + { (yyval.attr) = make_attr(ATTR_NONBROWSABLE); ;} break; case 117: /* Line 1455 of yacc.c */ -#line 529 "parser.y" - { (yyval.attr) = make_attr(ATTR_REQUESTEDIT); ;} +#line 530 "parser.y" + { (yyval.attr) = make_attr(ATTR_NONCREATABLE); ;} break; case 118: /* Line 1455 of yacc.c */ -#line 530 "parser.y" - { (yyval.attr) = make_attr(ATTR_RESTRICTED); ;} +#line 531 "parser.y" + { (yyval.attr) = make_attr(ATTR_NONEXTENSIBLE); ;} break; case 119: /* Line 1455 of yacc.c */ -#line 531 "parser.y" - { (yyval.attr) = make_attr(ATTR_RETVAL); ;} +#line 532 "parser.y" + { (yyval.attr) = make_attr(ATTR_NOTIFY); ;} break; case 120: /* Line 1455 of yacc.c */ -#line 532 "parser.y" - { (yyval.attr) = make_attrp(ATTR_SIZEIS, (yyvsp[(3) - (4)].expr_list)); ;} +#line 533 "parser.y" + { (yyval.attr) = make_attr(ATTR_NOTIFYFLAG); ;} break; case 121: /* Line 1455 of yacc.c */ -#line 533 "parser.y" - { (yyval.attr) = make_attr(ATTR_SOURCE); ;} +#line 534 "parser.y" + { (yyval.attr) = make_attr(ATTR_OBJECT); ;} break; case 122: /* Line 1455 of yacc.c */ -#line 534 "parser.y" - { (yyval.attr) = make_attr(ATTR_STRICTCONTEXTHANDLE); ;} +#line 535 "parser.y" + { (yyval.attr) = make_attr(ATTR_ODL); ;} break; case 123: /* Line 1455 of yacc.c */ -#line 535 "parser.y" - { (yyval.attr) = make_attr(ATTR_STRING); ;} +#line 536 "parser.y" + { (yyval.attr) = make_attr(ATTR_OLEAUTOMATION); ;} break; case 124: /* Line 1455 of yacc.c */ -#line 536 "parser.y" - { (yyval.attr) = make_attrp(ATTR_SWITCHIS, (yyvsp[(3) - (4)].expr)); ;} +#line 537 "parser.y" + { (yyval.attr) = make_attrp(ATTR_OPTIMIZE, (yyvsp[(3) - (4)].str)); ;} break; case 125: /* Line 1455 of yacc.c */ -#line 537 "parser.y" - { (yyval.attr) = make_attrp(ATTR_SWITCHTYPE, (yyvsp[(3) - (4)].type)); ;} +#line 538 "parser.y" + { (yyval.attr) = make_attr(ATTR_OPTIONAL); ;} break; case 126: /* Line 1455 of yacc.c */ -#line 538 "parser.y" - { (yyval.attr) = make_attrp(ATTR_TRANSMITAS, (yyvsp[(3) - (4)].type)); ;} +#line 539 "parser.y" + { (yyval.attr) = make_attr(ATTR_OUT); ;} break; case 127: /* Line 1455 of yacc.c */ -#line 539 "parser.y" - { (yyval.attr) = make_attrp(ATTR_UUID, (yyvsp[(3) - (4)].uuid)); ;} +#line 540 "parser.y" + { (yyval.attr) = make_attr(ATTR_PARTIALIGNORE); ;} break; case 128: /* Line 1455 of yacc.c */ -#line 540 "parser.y" - { (yyval.attr) = make_attr(ATTR_V1ENUM); ;} +#line 541 "parser.y" + { (yyval.attr) = make_attrv(ATTR_POINTERDEFAULT, (yyvsp[(3) - (4)].num)); ;} break; case 129: /* Line 1455 of yacc.c */ -#line 541 "parser.y" - { (yyval.attr) = make_attr(ATTR_VARARG); ;} +#line 542 "parser.y" + { (yyval.attr) = make_attrp(ATTR_PROGID, (yyvsp[(3) - (4)].str)); ;} break; case 130: /* Line 1455 of yacc.c */ -#line 542 "parser.y" - { (yyval.attr) = make_attrv(ATTR_VERSION, (yyvsp[(3) - (4)].num)); ;} +#line 543 "parser.y" + { (yyval.attr) = make_attr(ATTR_PROPGET); ;} break; case 131: /* Line 1455 of yacc.c */ -#line 543 "parser.y" - { (yyval.attr) = make_attrp(ATTR_WIREMARSHAL, (yyvsp[(3) - (4)].type)); ;} +#line 544 "parser.y" + { (yyval.attr) = make_attr(ATTR_PROPPUT); ;} break; case 132: /* Line 1455 of yacc.c */ -#line 544 "parser.y" - { (yyval.attr) = make_attrv(ATTR_POINTERTYPE, (yyvsp[(1) - (1)].num)); ;} +#line 545 "parser.y" + { (yyval.attr) = make_attr(ATTR_PROPPUTREF); ;} + break; + + case 133: + +/* Line 1455 of yacc.c */ +#line 546 "parser.y" + { (yyval.attr) = make_attr(ATTR_PROXY); ;} break; case 134: /* Line 1455 of yacc.c */ -#line 549 "parser.y" - { if (!is_valid_uuid((yyvsp[(1) - (1)].str))) - error_loc("invalid UUID: %s\n", (yyvsp[(1) - (1)].str)); - (yyval.uuid) = parse_uuid((yyvsp[(1) - (1)].str)); ;} +#line 547 "parser.y" + { (yyval.attr) = make_attr(ATTR_PUBLIC); ;} break; case 135: /* Line 1455 of yacc.c */ -#line 554 "parser.y" - { (yyval.str) = (yyvsp[(1) - (1)].str); ;} +#line 549 "parser.y" + { expr_list_t *list = append_expr( NULL, (yyvsp[(3) - (6)].expr) ); + list = append_expr( list, (yyvsp[(5) - (6)].expr) ); + (yyval.attr) = make_attrp(ATTR_RANGE, list); ;} break; case 136: /* Line 1455 of yacc.c */ -#line 555 "parser.y" - { (yyval.str) = (yyvsp[(1) - (1)].str); ;} +#line 552 "parser.y" + { (yyval.attr) = make_attr(ATTR_READONLY); ;} break; case 137: /* Line 1455 of yacc.c */ -#line 556 "parser.y" - { (yyval.str) = (yyvsp[(1) - (1)].str); ;} +#line 553 "parser.y" + { (yyval.attr) = make_attrp(ATTR_REPRESENTAS, (yyvsp[(3) - (4)].type)); ;} break; case 138: /* Line 1455 of yacc.c */ -#line 557 "parser.y" - { (yyval.str) = (yyvsp[(1) - (1)].str); ;} +#line 554 "parser.y" + { (yyval.attr) = make_attr(ATTR_REQUESTEDIT); ;} break; case 139: /* Line 1455 of yacc.c */ -#line 560 "parser.y" - { (yyval.var_list) = NULL; ;} +#line 555 "parser.y" + { (yyval.attr) = make_attr(ATTR_RESTRICTED); ;} break; case 140: /* Line 1455 of yacc.c */ -#line 561 "parser.y" - { (yyval.var_list) = append_var( (yyvsp[(1) - (2)].var_list), (yyvsp[(2) - (2)].var) ); ;} +#line 556 "parser.y" + { (yyval.attr) = make_attr(ATTR_RETVAL); ;} break; case 141: +/* Line 1455 of yacc.c */ +#line 557 "parser.y" + { (yyval.attr) = make_attrp(ATTR_SIZEIS, (yyvsp[(3) - (4)].expr_list)); ;} + break; + + case 142: + +/* Line 1455 of yacc.c */ +#line 558 "parser.y" + { (yyval.attr) = make_attr(ATTR_SOURCE); ;} + break; + + case 143: + +/* Line 1455 of yacc.c */ +#line 559 "parser.y" + { (yyval.attr) = make_attr(ATTR_STRICTCONTEXTHANDLE); ;} + break; + + case 144: + +/* Line 1455 of yacc.c */ +#line 560 "parser.y" + { (yyval.attr) = make_attr(ATTR_STRING); ;} + break; + + case 145: + +/* Line 1455 of yacc.c */ +#line 561 "parser.y" + { (yyval.attr) = make_attrp(ATTR_SWITCHIS, (yyvsp[(3) - (4)].expr)); ;} + break; + + case 146: + +/* Line 1455 of yacc.c */ +#line 562 "parser.y" + { (yyval.attr) = make_attrp(ATTR_SWITCHTYPE, (yyvsp[(3) - (4)].type)); ;} + break; + + case 147: + +/* Line 1455 of yacc.c */ +#line 563 "parser.y" + { (yyval.attr) = make_attrp(ATTR_TRANSMITAS, (yyvsp[(3) - (4)].type)); ;} + break; + + case 148: + /* Line 1455 of yacc.c */ #line 564 "parser.y" + { (yyval.attr) = make_attrv(ATTR_THREADING, (yyvsp[(3) - (4)].num)); ;} + break; + + case 149: + +/* Line 1455 of yacc.c */ +#line 565 "parser.y" + { (yyval.attr) = make_attr(ATTR_UIDEFAULT); ;} + break; + + case 150: + +/* Line 1455 of yacc.c */ +#line 566 "parser.y" + { (yyval.attr) = make_attr(ATTR_USESGETLASTERROR); ;} + break; + + case 151: + +/* Line 1455 of yacc.c */ +#line 567 "parser.y" + { (yyval.attr) = make_attrp(ATTR_USERMARSHAL, (yyvsp[(3) - (4)].type)); ;} + break; + + case 152: + +/* Line 1455 of yacc.c */ +#line 568 "parser.y" + { (yyval.attr) = make_attrp(ATTR_UUID, (yyvsp[(3) - (4)].uuid)); ;} + break; + + case 153: + +/* Line 1455 of yacc.c */ +#line 569 "parser.y" + { (yyval.attr) = make_attr(ATTR_V1ENUM); ;} + break; + + case 154: + +/* Line 1455 of yacc.c */ +#line 570 "parser.y" + { (yyval.attr) = make_attr(ATTR_VARARG); ;} + break; + + case 155: + +/* Line 1455 of yacc.c */ +#line 571 "parser.y" + { (yyval.attr) = make_attrv(ATTR_VERSION, (yyvsp[(3) - (4)].num)); ;} + break; + + case 156: + +/* Line 1455 of yacc.c */ +#line 572 "parser.y" + { (yyval.attr) = make_attrp(ATTR_VIPROGID, (yyvsp[(3) - (4)].str)); ;} + break; + + case 157: + +/* Line 1455 of yacc.c */ +#line 573 "parser.y" + { (yyval.attr) = make_attrp(ATTR_WIREMARSHAL, (yyvsp[(3) - (4)].type)); ;} + break; + + case 158: + +/* Line 1455 of yacc.c */ +#line 574 "parser.y" + { (yyval.attr) = make_attrv(ATTR_POINTERTYPE, (yyvsp[(1) - (1)].num)); ;} + break; + + case 160: + +/* Line 1455 of yacc.c */ +#line 579 "parser.y" + { if (!is_valid_uuid((yyvsp[(1) - (1)].str))) + error_loc("invalid UUID: %s\n", (yyvsp[(1) - (1)].str)); + (yyval.uuid) = parse_uuid((yyvsp[(1) - (1)].str)); ;} + break; + + case 161: + +/* Line 1455 of yacc.c */ +#line 584 "parser.y" + { (yyval.str) = (yyvsp[(1) - (1)].str); ;} + break; + + case 162: + +/* Line 1455 of yacc.c */ +#line 585 "parser.y" + { (yyval.str) = (yyvsp[(1) - (1)].str); ;} + break; + + case 163: + +/* Line 1455 of yacc.c */ +#line 586 "parser.y" + { (yyval.str) = (yyvsp[(1) - (1)].str); ;} + break; + + case 164: + +/* Line 1455 of yacc.c */ +#line 587 "parser.y" + { (yyval.str) = (yyvsp[(1) - (1)].str); ;} + break; + + case 165: + +/* Line 1455 of yacc.c */ +#line 590 "parser.y" + { (yyval.var_list) = NULL; ;} + break; + + case 166: + +/* Line 1455 of yacc.c */ +#line 591 "parser.y" + { (yyval.var_list) = append_var( (yyvsp[(1) - (2)].var_list), (yyvsp[(2) - (2)].var) ); ;} + break; + + case 167: + +/* Line 1455 of yacc.c */ +#line 594 "parser.y" { attr_t *a = make_attrp(ATTR_CASE, append_expr( NULL, (yyvsp[(2) - (4)].expr) )); (yyval.var) = (yyvsp[(4) - (4)].var); if (!(yyval.var)) (yyval.var) = make_var(NULL); (yyval.var)->attrs = append_attr( (yyval.var)->attrs, a ); ;} break; - case 142: + case 168: /* Line 1455 of yacc.c */ -#line 568 "parser.y" +#line 598 "parser.y" { attr_t *a = make_attr(ATTR_DEFAULT); (yyval.var) = (yyvsp[(3) - (3)].var); if (!(yyval.var)) (yyval.var) = make_var(NULL); (yyval.var)->attrs = append_attr( (yyval.var)->attrs, a ); ;} break; - case 143: + case 169: /* Line 1455 of yacc.c */ -#line 574 "parser.y" +#line 604 "parser.y" { (yyval.var_list) = NULL; ;} break; - case 144: + case 170: /* Line 1455 of yacc.c */ -#line 575 "parser.y" +#line 605 "parser.y" { (yyval.var_list) = (yyvsp[(1) - (2)].var_list); ;} break; - case 146: + case 172: /* Line 1455 of yacc.c */ -#line 579 "parser.y" +#line 609 "parser.y" { if (!(yyvsp[(1) - (1)].var)->eval) (yyvsp[(1) - (1)].var)->eval = make_exprl(EXPR_NUM, 0 /* default for first enum entry */); (yyval.var_list) = append_var( NULL, (yyvsp[(1) - (1)].var) ); ;} break; - case 147: + case 173: /* Line 1455 of yacc.c */ -#line 583 "parser.y" +#line 613 "parser.y" { if (!(yyvsp[(3) - (3)].var)->eval) { var_t *last = LIST_ENTRY( list_tail((yyval.var_list)), var_t, entry ); @@ -3658,464 +3954,464 @@ yyreduce: ;} break; - case 148: + case 174: /* Line 1455 of yacc.c */ -#line 592 "parser.y" +#line 622 "parser.y" { (yyval.var) = reg_const((yyvsp[(1) - (3)].var)); (yyval.var)->eval = (yyvsp[(3) - (3)].expr); (yyval.var)->type = type_new_int(TYPE_BASIC_INT, 0); ;} break; - case 149: + case 175: /* Line 1455 of yacc.c */ -#line 596 "parser.y" +#line 626 "parser.y" { (yyval.var) = reg_const((yyvsp[(1) - (1)].var)); (yyval.var)->type = type_new_int(TYPE_BASIC_INT, 0); ;} break; - case 150: - -/* Line 1455 of yacc.c */ -#line 601 "parser.y" - { (yyval.type) = type_new_enum((yyvsp[(2) - (5)].str), TRUE, (yyvsp[(4) - (5)].var_list)); ;} - break; - - case 151: - -/* Line 1455 of yacc.c */ -#line 604 "parser.y" - { (yyval.expr_list) = append_expr( NULL, (yyvsp[(1) - (1)].expr) ); ;} - break; - - case 152: - -/* Line 1455 of yacc.c */ -#line 605 "parser.y" - { (yyval.expr_list) = append_expr( (yyvsp[(1) - (3)].expr_list), (yyvsp[(3) - (3)].expr) ); ;} - break; - - case 153: - -/* Line 1455 of yacc.c */ -#line 618 "parser.y" - { (yyval.expr) = make_expr(EXPR_VOID); ;} - break; - - case 155: - -/* Line 1455 of yacc.c */ -#line 622 "parser.y" - { (yyval.expr) = make_exprl(EXPR_NUM, (yyvsp[(1) - (1)].num)); ;} - break; - - case 156: - -/* Line 1455 of yacc.c */ -#line 623 "parser.y" - { (yyval.expr) = make_exprl(EXPR_HEXNUM, (yyvsp[(1) - (1)].num)); ;} - break; - - case 157: - -/* Line 1455 of yacc.c */ -#line 624 "parser.y" - { (yyval.expr) = make_exprd(EXPR_DOUBLE, (yyvsp[(1) - (1)].dbl)); ;} - break; - - case 158: - -/* Line 1455 of yacc.c */ -#line 625 "parser.y" - { (yyval.expr) = make_exprl(EXPR_TRUEFALSE, 0); ;} - break; - - case 159: - -/* Line 1455 of yacc.c */ -#line 626 "parser.y" - { (yyval.expr) = make_exprl(EXPR_NUM, 0); ;} - break; - - case 160: - -/* Line 1455 of yacc.c */ -#line 627 "parser.y" - { (yyval.expr) = make_exprl(EXPR_TRUEFALSE, 1); ;} - break; - - case 161: - -/* Line 1455 of yacc.c */ -#line 628 "parser.y" - { (yyval.expr) = make_exprs(EXPR_STRLIT, (yyvsp[(1) - (1)].str)); ;} - break; - - case 162: - -/* Line 1455 of yacc.c */ -#line 629 "parser.y" - { (yyval.expr) = make_exprs(EXPR_WSTRLIT, (yyvsp[(1) - (1)].str)); ;} - break; - - case 163: - -/* Line 1455 of yacc.c */ -#line 630 "parser.y" - { (yyval.expr) = make_exprs(EXPR_CHARCONST, (yyvsp[(1) - (1)].str)); ;} - break; - - case 164: - -/* Line 1455 of yacc.c */ -#line 631 "parser.y" - { (yyval.expr) = make_exprs(EXPR_IDENTIFIER, (yyvsp[(1) - (1)].str)); ;} - break; - - case 165: - -/* Line 1455 of yacc.c */ -#line 632 "parser.y" - { (yyval.expr) = make_expr3(EXPR_COND, (yyvsp[(1) - (5)].expr), (yyvsp[(3) - (5)].expr), (yyvsp[(5) - (5)].expr)); ;} - break; - - case 166: - -/* Line 1455 of yacc.c */ -#line 633 "parser.y" - { (yyval.expr) = make_expr2(EXPR_LOGOR, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} - break; - - case 167: - -/* Line 1455 of yacc.c */ -#line 634 "parser.y" - { (yyval.expr) = make_expr2(EXPR_LOGAND, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} - break; - - case 168: - -/* Line 1455 of yacc.c */ -#line 635 "parser.y" - { (yyval.expr) = make_expr2(EXPR_OR , (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} - break; - - case 169: - -/* Line 1455 of yacc.c */ -#line 636 "parser.y" - { (yyval.expr) = make_expr2(EXPR_XOR, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} - break; - - case 170: - -/* Line 1455 of yacc.c */ -#line 637 "parser.y" - { (yyval.expr) = make_expr2(EXPR_AND, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} - break; - - case 171: - -/* Line 1455 of yacc.c */ -#line 638 "parser.y" - { (yyval.expr) = make_expr2(EXPR_EQUALITY, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} - break; - - case 172: - -/* Line 1455 of yacc.c */ -#line 639 "parser.y" - { (yyval.expr) = make_expr2(EXPR_INEQUALITY, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} - break; - - case 173: - -/* Line 1455 of yacc.c */ -#line 640 "parser.y" - { (yyval.expr) = make_expr2(EXPR_GTR, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} - break; - - case 174: - -/* Line 1455 of yacc.c */ -#line 641 "parser.y" - { (yyval.expr) = make_expr2(EXPR_LESS, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} - break; - - case 175: - -/* Line 1455 of yacc.c */ -#line 642 "parser.y" - { (yyval.expr) = make_expr2(EXPR_GTREQL, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} - break; - case 176: /* Line 1455 of yacc.c */ -#line 643 "parser.y" - { (yyval.expr) = make_expr2(EXPR_LESSEQL, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} +#line 631 "parser.y" + { (yyval.type) = type_new_enum((yyvsp[(2) - (5)].str), TRUE, (yyvsp[(4) - (5)].var_list)); ;} break; case 177: /* Line 1455 of yacc.c */ -#line 644 "parser.y" - { (yyval.expr) = make_expr2(EXPR_SHL, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} +#line 634 "parser.y" + { (yyval.expr_list) = append_expr( NULL, (yyvsp[(1) - (1)].expr) ); ;} break; case 178: /* Line 1455 of yacc.c */ -#line 645 "parser.y" - { (yyval.expr) = make_expr2(EXPR_SHR, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} +#line 635 "parser.y" + { (yyval.expr_list) = append_expr( (yyvsp[(1) - (3)].expr_list), (yyvsp[(3) - (3)].expr) ); ;} break; case 179: /* Line 1455 of yacc.c */ -#line 646 "parser.y" - { (yyval.expr) = make_expr2(EXPR_ADD, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} - break; - - case 180: - -/* Line 1455 of yacc.c */ -#line 647 "parser.y" - { (yyval.expr) = make_expr2(EXPR_SUB, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} +#line 648 "parser.y" + { (yyval.expr) = make_expr(EXPR_VOID); ;} break; case 181: /* Line 1455 of yacc.c */ -#line 648 "parser.y" - { (yyval.expr) = make_expr2(EXPR_MOD, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} +#line 652 "parser.y" + { (yyval.expr) = make_exprl(EXPR_NUM, (yyvsp[(1) - (1)].num)); ;} break; case 182: /* Line 1455 of yacc.c */ -#line 649 "parser.y" - { (yyval.expr) = make_expr2(EXPR_MUL, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} +#line 653 "parser.y" + { (yyval.expr) = make_exprl(EXPR_HEXNUM, (yyvsp[(1) - (1)].num)); ;} break; case 183: /* Line 1455 of yacc.c */ -#line 650 "parser.y" - { (yyval.expr) = make_expr2(EXPR_DIV, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} +#line 654 "parser.y" + { (yyval.expr) = make_exprd(EXPR_DOUBLE, (yyvsp[(1) - (1)].dbl)); ;} break; case 184: /* Line 1455 of yacc.c */ -#line 651 "parser.y" - { (yyval.expr) = make_expr1(EXPR_LOGNOT, (yyvsp[(2) - (2)].expr)); ;} +#line 655 "parser.y" + { (yyval.expr) = make_exprl(EXPR_TRUEFALSE, 0); ;} break; case 185: /* Line 1455 of yacc.c */ -#line 652 "parser.y" - { (yyval.expr) = make_expr1(EXPR_NOT, (yyvsp[(2) - (2)].expr)); ;} +#line 656 "parser.y" + { (yyval.expr) = make_exprl(EXPR_NUM, 0); ;} break; case 186: /* Line 1455 of yacc.c */ -#line 653 "parser.y" - { (yyval.expr) = make_expr1(EXPR_POS, (yyvsp[(2) - (2)].expr)); ;} +#line 657 "parser.y" + { (yyval.expr) = make_exprl(EXPR_TRUEFALSE, 1); ;} break; case 187: /* Line 1455 of yacc.c */ -#line 654 "parser.y" - { (yyval.expr) = make_expr1(EXPR_NEG, (yyvsp[(2) - (2)].expr)); ;} +#line 658 "parser.y" + { (yyval.expr) = make_exprs(EXPR_STRLIT, (yyvsp[(1) - (1)].str)); ;} break; case 188: /* Line 1455 of yacc.c */ -#line 655 "parser.y" - { (yyval.expr) = make_expr1(EXPR_ADDRESSOF, (yyvsp[(2) - (2)].expr)); ;} +#line 659 "parser.y" + { (yyval.expr) = make_exprs(EXPR_WSTRLIT, (yyvsp[(1) - (1)].str)); ;} break; case 189: /* Line 1455 of yacc.c */ -#line 656 "parser.y" - { (yyval.expr) = make_expr1(EXPR_PPTR, (yyvsp[(2) - (2)].expr)); ;} +#line 660 "parser.y" + { (yyval.expr) = make_exprs(EXPR_CHARCONST, (yyvsp[(1) - (1)].str)); ;} break; case 190: /* Line 1455 of yacc.c */ -#line 657 "parser.y" - { (yyval.expr) = make_expr2(EXPR_MEMBER, make_expr1(EXPR_PPTR, (yyvsp[(1) - (3)].expr)), make_exprs(EXPR_IDENTIFIER, (yyvsp[(3) - (3)].str))); ;} +#line 661 "parser.y" + { (yyval.expr) = make_exprs(EXPR_IDENTIFIER, (yyvsp[(1) - (1)].str)); ;} break; case 191: /* Line 1455 of yacc.c */ -#line 658 "parser.y" - { (yyval.expr) = make_expr2(EXPR_MEMBER, (yyvsp[(1) - (3)].expr), make_exprs(EXPR_IDENTIFIER, (yyvsp[(3) - (3)].str))); ;} +#line 662 "parser.y" + { (yyval.expr) = make_expr3(EXPR_COND, (yyvsp[(1) - (5)].expr), (yyvsp[(3) - (5)].expr), (yyvsp[(5) - (5)].expr)); ;} break; case 192: /* Line 1455 of yacc.c */ -#line 660 "parser.y" - { (yyval.expr) = make_exprt(EXPR_CAST, declare_var(NULL, (yyvsp[(2) - (5)].declspec), (yyvsp[(3) - (5)].declarator), 0), (yyvsp[(5) - (5)].expr)); free((yyvsp[(2) - (5)].declspec)); free((yyvsp[(3) - (5)].declarator)); ;} +#line 663 "parser.y" + { (yyval.expr) = make_expr2(EXPR_LOGOR, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} break; case 193: /* Line 1455 of yacc.c */ -#line 662 "parser.y" - { (yyval.expr) = make_exprt(EXPR_SIZEOF, declare_var(NULL, (yyvsp[(3) - (5)].declspec), (yyvsp[(4) - (5)].declarator), 0), NULL); free((yyvsp[(3) - (5)].declspec)); free((yyvsp[(4) - (5)].declarator)); ;} +#line 664 "parser.y" + { (yyval.expr) = make_expr2(EXPR_LOGAND, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} break; case 194: /* Line 1455 of yacc.c */ -#line 663 "parser.y" - { (yyval.expr) = make_expr2(EXPR_ARRAY, (yyvsp[(1) - (4)].expr), (yyvsp[(3) - (4)].expr)); ;} +#line 665 "parser.y" + { (yyval.expr) = make_expr2(EXPR_OR , (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} break; case 195: /* Line 1455 of yacc.c */ -#line 664 "parser.y" - { (yyval.expr) = (yyvsp[(2) - (3)].expr); ;} +#line 666 "parser.y" + { (yyval.expr) = make_expr2(EXPR_XOR, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} break; case 196: /* Line 1455 of yacc.c */ #line 667 "parser.y" - { (yyval.expr_list) = append_expr( NULL, (yyvsp[(1) - (1)].expr) ); ;} + { (yyval.expr) = make_expr2(EXPR_AND, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} break; case 197: /* Line 1455 of yacc.c */ #line 668 "parser.y" - { (yyval.expr_list) = append_expr( (yyvsp[(1) - (3)].expr_list), (yyvsp[(3) - (3)].expr) ); ;} + { (yyval.expr) = make_expr2(EXPR_EQUALITY, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} break; case 198: +/* Line 1455 of yacc.c */ +#line 669 "parser.y" + { (yyval.expr) = make_expr2(EXPR_INEQUALITY, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 199: + +/* Line 1455 of yacc.c */ +#line 670 "parser.y" + { (yyval.expr) = make_expr2(EXPR_GTR, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 200: + /* Line 1455 of yacc.c */ #line 671 "parser.y" + { (yyval.expr) = make_expr2(EXPR_LESS, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 201: + +/* Line 1455 of yacc.c */ +#line 672 "parser.y" + { (yyval.expr) = make_expr2(EXPR_GTREQL, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 202: + +/* Line 1455 of yacc.c */ +#line 673 "parser.y" + { (yyval.expr) = make_expr2(EXPR_LESSEQL, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 203: + +/* Line 1455 of yacc.c */ +#line 674 "parser.y" + { (yyval.expr) = make_expr2(EXPR_SHL, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 204: + +/* Line 1455 of yacc.c */ +#line 675 "parser.y" + { (yyval.expr) = make_expr2(EXPR_SHR, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 205: + +/* Line 1455 of yacc.c */ +#line 676 "parser.y" + { (yyval.expr) = make_expr2(EXPR_ADD, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 206: + +/* Line 1455 of yacc.c */ +#line 677 "parser.y" + { (yyval.expr) = make_expr2(EXPR_SUB, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 207: + +/* Line 1455 of yacc.c */ +#line 678 "parser.y" + { (yyval.expr) = make_expr2(EXPR_MOD, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 208: + +/* Line 1455 of yacc.c */ +#line 679 "parser.y" + { (yyval.expr) = make_expr2(EXPR_MUL, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 209: + +/* Line 1455 of yacc.c */ +#line 680 "parser.y" + { (yyval.expr) = make_expr2(EXPR_DIV, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 210: + +/* Line 1455 of yacc.c */ +#line 681 "parser.y" + { (yyval.expr) = make_expr1(EXPR_LOGNOT, (yyvsp[(2) - (2)].expr)); ;} + break; + + case 211: + +/* Line 1455 of yacc.c */ +#line 682 "parser.y" + { (yyval.expr) = make_expr1(EXPR_NOT, (yyvsp[(2) - (2)].expr)); ;} + break; + + case 212: + +/* Line 1455 of yacc.c */ +#line 683 "parser.y" + { (yyval.expr) = make_expr1(EXPR_POS, (yyvsp[(2) - (2)].expr)); ;} + break; + + case 213: + +/* Line 1455 of yacc.c */ +#line 684 "parser.y" + { (yyval.expr) = make_expr1(EXPR_NEG, (yyvsp[(2) - (2)].expr)); ;} + break; + + case 214: + +/* Line 1455 of yacc.c */ +#line 685 "parser.y" + { (yyval.expr) = make_expr1(EXPR_ADDRESSOF, (yyvsp[(2) - (2)].expr)); ;} + break; + + case 215: + +/* Line 1455 of yacc.c */ +#line 686 "parser.y" + { (yyval.expr) = make_expr1(EXPR_PPTR, (yyvsp[(2) - (2)].expr)); ;} + break; + + case 216: + +/* Line 1455 of yacc.c */ +#line 687 "parser.y" + { (yyval.expr) = make_expr2(EXPR_MEMBER, make_expr1(EXPR_PPTR, (yyvsp[(1) - (3)].expr)), make_exprs(EXPR_IDENTIFIER, (yyvsp[(3) - (3)].str))); ;} + break; + + case 217: + +/* Line 1455 of yacc.c */ +#line 688 "parser.y" + { (yyval.expr) = make_expr2(EXPR_MEMBER, (yyvsp[(1) - (3)].expr), make_exprs(EXPR_IDENTIFIER, (yyvsp[(3) - (3)].str))); ;} + break; + + case 218: + +/* Line 1455 of yacc.c */ +#line 690 "parser.y" + { (yyval.expr) = make_exprt(EXPR_CAST, declare_var(NULL, (yyvsp[(2) - (5)].declspec), (yyvsp[(3) - (5)].declarator), 0), (yyvsp[(5) - (5)].expr)); free((yyvsp[(2) - (5)].declspec)); free((yyvsp[(3) - (5)].declarator)); ;} + break; + + case 219: + +/* Line 1455 of yacc.c */ +#line 692 "parser.y" + { (yyval.expr) = make_exprt(EXPR_SIZEOF, declare_var(NULL, (yyvsp[(3) - (5)].declspec), (yyvsp[(4) - (5)].declarator), 0), NULL); free((yyvsp[(3) - (5)].declspec)); free((yyvsp[(4) - (5)].declarator)); ;} + break; + + case 220: + +/* Line 1455 of yacc.c */ +#line 693 "parser.y" + { (yyval.expr) = make_expr2(EXPR_ARRAY, (yyvsp[(1) - (4)].expr), (yyvsp[(3) - (4)].expr)); ;} + break; + + case 221: + +/* Line 1455 of yacc.c */ +#line 694 "parser.y" + { (yyval.expr) = (yyvsp[(2) - (3)].expr); ;} + break; + + case 222: + +/* Line 1455 of yacc.c */ +#line 697 "parser.y" + { (yyval.expr_list) = append_expr( NULL, (yyvsp[(1) - (1)].expr) ); ;} + break; + + case 223: + +/* Line 1455 of yacc.c */ +#line 698 "parser.y" + { (yyval.expr_list) = append_expr( (yyvsp[(1) - (3)].expr_list), (yyvsp[(3) - (3)].expr) ); ;} + break; + + case 224: + +/* Line 1455 of yacc.c */ +#line 701 "parser.y" { (yyval.expr) = (yyvsp[(1) - (1)].expr); if (!(yyval.expr)->is_const) error_loc("expression is not an integer constant\n"); ;} break; - case 199: + case 225: /* Line 1455 of yacc.c */ -#line 677 "parser.y" +#line 707 "parser.y" { (yyval.expr) = (yyvsp[(1) - (1)].expr); if (!(yyval.expr)->is_const && (yyval.expr)->type != EXPR_STRLIT && (yyval.expr)->type != EXPR_WSTRLIT) error_loc("expression is not constant\n"); ;} break; - case 200: + case 226: /* Line 1455 of yacc.c */ -#line 683 "parser.y" +#line 713 "parser.y" { (yyval.var_list) = NULL; ;} break; - case 201: + case 227: /* Line 1455 of yacc.c */ -#line 684 "parser.y" +#line 714 "parser.y" { (yyval.var_list) = append_var_list((yyvsp[(1) - (2)].var_list), (yyvsp[(2) - (2)].var_list)); ;} break; - case 202: + case 228: /* Line 1455 of yacc.c */ -#line 688 "parser.y" +#line 718 "parser.y" { const char *first = LIST_ENTRY(list_head((yyvsp[(3) - (4)].declarator_list)), declarator_t, entry)->var->name; check_field_attrs(first, (yyvsp[(1) - (4)].attr_list)); (yyval.var_list) = set_var_types((yyvsp[(1) - (4)].attr_list), (yyvsp[(2) - (4)].declspec), (yyvsp[(3) - (4)].declarator_list)); ;} break; - case 203: + case 229: /* Line 1455 of yacc.c */ -#line 692 "parser.y" +#line 722 "parser.y" { var_t *v = make_var(NULL); v->type = (yyvsp[(2) - (3)].type); v->attrs = (yyvsp[(1) - (3)].attr_list); (yyval.var_list) = append_var(NULL, v); ;} break; - case 204: + case 230: /* Line 1455 of yacc.c */ -#line 699 "parser.y" +#line 729 "parser.y" { (yyval.var) = (yyvsp[(1) - (2)].var); ;} break; - case 205: + case 231: /* Line 1455 of yacc.c */ -#line 700 "parser.y" +#line 730 "parser.y" { (yyval.var) = make_var(NULL); (yyval.var)->attrs = (yyvsp[(1) - (2)].attr_list); ;} break; - case 206: + case 232: /* Line 1455 of yacc.c */ -#line 703 "parser.y" +#line 733 "parser.y" { (yyval.var_list) = NULL; ;} break; - case 207: + case 233: /* Line 1455 of yacc.c */ -#line 704 "parser.y" +#line 734 "parser.y" { (yyval.var_list) = append_var( (yyvsp[(1) - (2)].var_list), (yyvsp[(2) - (2)].var) ); ;} break; - case 208: + case 234: /* Line 1455 of yacc.c */ -#line 708 "parser.y" +#line 738 "parser.y" { (yyval.var) = (yyvsp[(1) - (2)].var); ;} break; - case 209: + case 235: /* Line 1455 of yacc.c */ -#line 709 "parser.y" +#line 739 "parser.y" { (yyval.var) = NULL; ;} break; - case 210: + case 236: /* Line 1455 of yacc.c */ -#line 712 "parser.y" +#line 742 "parser.y" { (yyval.var) = declare_var(check_field_attrs((yyvsp[(3) - (3)].declarator)->var->name, (yyvsp[(1) - (3)].attr_list)), (yyvsp[(2) - (3)].declspec), (yyvsp[(3) - (3)].declarator), FALSE); free((yyvsp[(3) - (3)].declarator)); ;} break; - case 211: + case 237: /* Line 1455 of yacc.c */ -#line 718 "parser.y" +#line 748 "parser.y" { (yyval.var) = (yyvsp[(1) - (1)].var); if (type_get_type((yyval.var)->type) != TYPE_FUNCTION) error_loc("only methods may be declared inside the methods section of a dispinterface\n"); @@ -4123,203 +4419,203 @@ yyreduce: ;} break; - case 212: + case 238: /* Line 1455 of yacc.c */ -#line 727 "parser.y" +#line 757 "parser.y" { (yyval.var) = declare_var((yyvsp[(1) - (3)].attr_list), (yyvsp[(2) - (3)].declspec), (yyvsp[(3) - (3)].declarator), FALSE); free((yyvsp[(3) - (3)].declarator)); ;} break; - case 213: + case 239: /* Line 1455 of yacc.c */ -#line 730 "parser.y" +#line 760 "parser.y" { (yyval.var) = declare_var(NULL, (yyvsp[(1) - (2)].declspec), (yyvsp[(2) - (2)].declarator), FALSE); free((yyvsp[(2) - (2)].declarator)); ;} break; - case 214: - -/* Line 1455 of yacc.c */ -#line 735 "parser.y" - { (yyval.var) = NULL; ;} - break; - - case 216: - -/* Line 1455 of yacc.c */ -#line 739 "parser.y" - { (yyval.str) = NULL; ;} - break; - - case 217: - -/* Line 1455 of yacc.c */ -#line 740 "parser.y" - { (yyval.str) = (yyvsp[(1) - (1)].str); ;} - break; - - case 218: - -/* Line 1455 of yacc.c */ -#line 741 "parser.y" - { (yyval.str) = (yyvsp[(1) - (1)].str); ;} - break; - - case 219: - -/* Line 1455 of yacc.c */ -#line 744 "parser.y" - { (yyval.var) = make_var((yyvsp[(1) - (1)].str)); ;} - break; - - case 220: - -/* Line 1455 of yacc.c */ -#line 746 "parser.y" - { (yyval.var) = make_var((yyvsp[(1) - (1)].str)); ;} - break; - - case 221: - -/* Line 1455 of yacc.c */ -#line 749 "parser.y" - { (yyval.type) = find_type_or_error((yyvsp[(1) - (1)].str), 0); ;} - break; - - case 222: - -/* Line 1455 of yacc.c */ -#line 750 "parser.y" - { (yyval.type) = find_type_or_error((yyvsp[(1) - (1)].str), 0); ;} - break; - - case 224: - -/* Line 1455 of yacc.c */ -#line 752 "parser.y" - { (yyval.type) = type_new_int(type_basic_get_type((yyvsp[(2) - (2)].type)), -1); ;} - break; - - case 225: - -/* Line 1455 of yacc.c */ -#line 753 "parser.y" - { (yyval.type) = type_new_int(type_basic_get_type((yyvsp[(2) - (2)].type)), 1); ;} - break; - - case 226: - -/* Line 1455 of yacc.c */ -#line 754 "parser.y" - { (yyval.type) = type_new_int(TYPE_BASIC_INT, 1); ;} - break; - - case 227: - -/* Line 1455 of yacc.c */ -#line 755 "parser.y" - { (yyval.type) = find_type_or_error((yyvsp[(1) - (1)].str), 0); ;} - break; - - case 228: - -/* Line 1455 of yacc.c */ -#line 756 "parser.y" - { (yyval.type) = find_type_or_error((yyvsp[(1) - (1)].str), 0); ;} - break; - - case 229: - -/* Line 1455 of yacc.c */ -#line 757 "parser.y" - { (yyval.type) = find_type_or_error((yyvsp[(1) - (1)].str), 0); ;} - break; - - case 230: - -/* Line 1455 of yacc.c */ -#line 758 "parser.y" - { (yyval.type) = find_type_or_error((yyvsp[(1) - (1)].str), 0); ;} - break; - - case 231: - -/* Line 1455 of yacc.c */ -#line 759 "parser.y" - { (yyval.type) = find_type_or_error((yyvsp[(1) - (1)].str), 0); ;} - break; - - case 234: - -/* Line 1455 of yacc.c */ -#line 766 "parser.y" - { (yyval.type) = type_new_int(TYPE_BASIC_INT, 0); ;} - break; - - case 235: - -/* Line 1455 of yacc.c */ -#line 767 "parser.y" - { (yyval.type) = type_new_int(TYPE_BASIC_INT16, 0); ;} - break; - - case 236: - -/* Line 1455 of yacc.c */ -#line 768 "parser.y" - { (yyval.type) = type_new_int(TYPE_BASIC_INT8, 0); ;} - break; - - case 237: - -/* Line 1455 of yacc.c */ -#line 769 "parser.y" - { (yyval.type) = type_new_int(TYPE_BASIC_INT32, 0); ;} - break; - - case 238: - -/* Line 1455 of yacc.c */ -#line 770 "parser.y" - { (yyval.type) = type_new_int(TYPE_BASIC_HYPER, 0); ;} - break; - - case 239: - -/* Line 1455 of yacc.c */ -#line 771 "parser.y" - { (yyval.type) = type_new_int(TYPE_BASIC_INT64, 0); ;} - break; - case 240: /* Line 1455 of yacc.c */ -#line 772 "parser.y" - { (yyval.type) = type_new_int(TYPE_BASIC_CHAR, 0); ;} - break; - - case 241: - -/* Line 1455 of yacc.c */ -#line 773 "parser.y" - { (yyval.type) = type_new_int(TYPE_BASIC_INT3264, 0); ;} +#line 765 "parser.y" + { (yyval.var) = NULL; ;} break; case 242: /* Line 1455 of yacc.c */ -#line 776 "parser.y" - { (yyval.type) = type_new_coclass((yyvsp[(2) - (2)].str)); ;} +#line 769 "parser.y" + { (yyval.str) = NULL; ;} break; case 243: /* Line 1455 of yacc.c */ -#line 777 "parser.y" +#line 770 "parser.y" + { (yyval.str) = (yyvsp[(1) - (1)].str); ;} + break; + + case 244: + +/* Line 1455 of yacc.c */ +#line 771 "parser.y" + { (yyval.str) = (yyvsp[(1) - (1)].str); ;} + break; + + case 245: + +/* Line 1455 of yacc.c */ +#line 774 "parser.y" + { (yyval.var) = make_var((yyvsp[(1) - (1)].str)); ;} + break; + + case 246: + +/* Line 1455 of yacc.c */ +#line 776 "parser.y" + { (yyval.var) = make_var((yyvsp[(1) - (1)].str)); ;} + break; + + case 247: + +/* Line 1455 of yacc.c */ +#line 779 "parser.y" + { (yyval.type) = find_type_or_error((yyvsp[(1) - (1)].str), 0); ;} + break; + + case 248: + +/* Line 1455 of yacc.c */ +#line 780 "parser.y" + { (yyval.type) = find_type_or_error((yyvsp[(1) - (1)].str), 0); ;} + break; + + case 250: + +/* Line 1455 of yacc.c */ +#line 782 "parser.y" + { (yyval.type) = type_new_int(type_basic_get_type((yyvsp[(2) - (2)].type)), -1); ;} + break; + + case 251: + +/* Line 1455 of yacc.c */ +#line 783 "parser.y" + { (yyval.type) = type_new_int(type_basic_get_type((yyvsp[(2) - (2)].type)), 1); ;} + break; + + case 252: + +/* Line 1455 of yacc.c */ +#line 784 "parser.y" + { (yyval.type) = type_new_int(TYPE_BASIC_INT, 1); ;} + break; + + case 253: + +/* Line 1455 of yacc.c */ +#line 785 "parser.y" + { (yyval.type) = find_type_or_error((yyvsp[(1) - (1)].str), 0); ;} + break; + + case 254: + +/* Line 1455 of yacc.c */ +#line 786 "parser.y" + { (yyval.type) = find_type_or_error((yyvsp[(1) - (1)].str), 0); ;} + break; + + case 255: + +/* Line 1455 of yacc.c */ +#line 787 "parser.y" + { (yyval.type) = find_type_or_error((yyvsp[(1) - (1)].str), 0); ;} + break; + + case 256: + +/* Line 1455 of yacc.c */ +#line 788 "parser.y" + { (yyval.type) = find_type_or_error((yyvsp[(1) - (1)].str), 0); ;} + break; + + case 257: + +/* Line 1455 of yacc.c */ +#line 789 "parser.y" + { (yyval.type) = find_type_or_error((yyvsp[(1) - (1)].str), 0); ;} + break; + + case 260: + +/* Line 1455 of yacc.c */ +#line 796 "parser.y" + { (yyval.type) = type_new_int(TYPE_BASIC_INT, 0); ;} + break; + + case 261: + +/* Line 1455 of yacc.c */ +#line 797 "parser.y" + { (yyval.type) = type_new_int(TYPE_BASIC_INT16, 0); ;} + break; + + case 262: + +/* Line 1455 of yacc.c */ +#line 798 "parser.y" + { (yyval.type) = type_new_int(TYPE_BASIC_INT8, 0); ;} + break; + + case 263: + +/* Line 1455 of yacc.c */ +#line 799 "parser.y" + { (yyval.type) = type_new_int(TYPE_BASIC_INT32, 0); ;} + break; + + case 264: + +/* Line 1455 of yacc.c */ +#line 800 "parser.y" + { (yyval.type) = type_new_int(TYPE_BASIC_HYPER, 0); ;} + break; + + case 265: + +/* Line 1455 of yacc.c */ +#line 801 "parser.y" + { (yyval.type) = type_new_int(TYPE_BASIC_INT64, 0); ;} + break; + + case 266: + +/* Line 1455 of yacc.c */ +#line 802 "parser.y" + { (yyval.type) = type_new_int(TYPE_BASIC_CHAR, 0); ;} + break; + + case 267: + +/* Line 1455 of yacc.c */ +#line 803 "parser.y" + { (yyval.type) = type_new_int(TYPE_BASIC_INT3264, 0); ;} + break; + + case 268: + +/* Line 1455 of yacc.c */ +#line 806 "parser.y" + { (yyval.type) = type_new_coclass((yyvsp[(2) - (2)].str)); ;} + break; + + case 269: + +/* Line 1455 of yacc.c */ +#line 807 "parser.y" { (yyval.type) = find_type((yyvsp[(2) - (2)].str), 0); if (type_get_type_detect_alias((yyval.type)) != TYPE_COCLASS) error_loc("%s was not declared a coclass at %s:%d\n", @@ -4328,62 +4624,62 @@ yyreduce: ;} break; - case 244: + case 270: /* Line 1455 of yacc.c */ -#line 785 "parser.y" +#line 815 "parser.y" { (yyval.type) = (yyvsp[(2) - (2)].type); check_def((yyval.type)); (yyval.type)->attrs = check_coclass_attrs((yyvsp[(2) - (2)].type)->name, (yyvsp[(1) - (2)].attr_list)); ;} break; - case 245: + case 271: /* Line 1455 of yacc.c */ -#line 792 "parser.y" +#line 822 "parser.y" { (yyval.type) = type_coclass_define((yyvsp[(1) - (5)].type), (yyvsp[(3) - (5)].ifref_list)); ;} break; - case 246: + case 272: /* Line 1455 of yacc.c */ -#line 795 "parser.y" +#line 825 "parser.y" { (yyval.ifref_list) = NULL; ;} break; - case 247: + case 273: /* Line 1455 of yacc.c */ -#line 796 "parser.y" +#line 826 "parser.y" { (yyval.ifref_list) = append_ifref( (yyvsp[(1) - (2)].ifref_list), (yyvsp[(2) - (2)].ifref) ); ;} break; - case 248: + case 274: /* Line 1455 of yacc.c */ -#line 800 "parser.y" +#line 830 "parser.y" { (yyval.ifref) = make_ifref((yyvsp[(2) - (2)].type)); (yyval.ifref)->attrs = (yyvsp[(1) - (2)].attr_list); ;} break; - case 249: + case 275: /* Line 1455 of yacc.c */ -#line 803 "parser.y" +#line 833 "parser.y" { (yyval.type) = get_type(TYPE_INTERFACE, (yyvsp[(2) - (2)].str), 0); ;} break; - case 250: + case 276: /* Line 1455 of yacc.c */ -#line 804 "parser.y" +#line 834 "parser.y" { (yyval.type) = get_type(TYPE_INTERFACE, (yyvsp[(2) - (2)].str), 0); ;} break; - case 251: + case 277: /* Line 1455 of yacc.c */ -#line 807 "parser.y" +#line 837 "parser.y" { attr_t *attrs; (yyval.type) = (yyvsp[(2) - (2)].type); check_def((yyval.type)); @@ -4393,84 +4689,84 @@ yyreduce: ;} break; - case 252: + case 278: /* Line 1455 of yacc.c */ -#line 816 "parser.y" +#line 846 "parser.y" { (yyval.var_list) = NULL; ;} break; - case 253: + case 279: /* Line 1455 of yacc.c */ -#line 817 "parser.y" +#line 847 "parser.y" { (yyval.var_list) = append_var( (yyvsp[(1) - (3)].var_list), (yyvsp[(2) - (3)].var) ); ;} break; - case 254: + case 280: /* Line 1455 of yacc.c */ -#line 820 "parser.y" +#line 850 "parser.y" { (yyval.var_list) = NULL; ;} break; - case 255: + case 281: /* Line 1455 of yacc.c */ -#line 821 "parser.y" +#line 851 "parser.y" { (yyval.var_list) = append_var( (yyvsp[(1) - (3)].var_list), (yyvsp[(2) - (3)].var) ); ;} break; - case 256: + case 282: /* Line 1455 of yacc.c */ -#line 827 "parser.y" +#line 857 "parser.y" { (yyval.type) = (yyvsp[(1) - (5)].type); type_dispinterface_define((yyval.type), (yyvsp[(3) - (5)].var_list), (yyvsp[(4) - (5)].var_list)); ;} break; - case 257: + case 283: /* Line 1455 of yacc.c */ -#line 831 "parser.y" +#line 861 "parser.y" { (yyval.type) = (yyvsp[(1) - (5)].type); type_dispinterface_define_from_iface((yyval.type), (yyvsp[(3) - (5)].type)); ;} break; - case 258: + case 284: /* Line 1455 of yacc.c */ -#line 836 "parser.y" +#line 866 "parser.y" { (yyval.type) = NULL; ;} break; - case 259: + case 285: /* Line 1455 of yacc.c */ -#line 837 "parser.y" +#line 867 "parser.y" { (yyval.type) = find_type_or_error2((yyvsp[(2) - (2)].str), 0); ;} break; - case 260: + case 286: /* Line 1455 of yacc.c */ -#line 840 "parser.y" +#line 870 "parser.y" { (yyval.type) = get_type(TYPE_INTERFACE, (yyvsp[(2) - (2)].str), 0); ;} break; - case 261: + case 287: /* Line 1455 of yacc.c */ -#line 841 "parser.y" +#line 871 "parser.y" { (yyval.type) = get_type(TYPE_INTERFACE, (yyvsp[(2) - (2)].str), 0); ;} break; - case 262: + case 288: /* Line 1455 of yacc.c */ -#line 844 "parser.y" +#line 874 "parser.y" { (yyval.ifinfo).interface = (yyvsp[(2) - (2)].type); (yyval.ifinfo).old_pointer_default = pointer_default; if (is_attr((yyvsp[(1) - (2)].attr_list), ATTR_POINTERDEFAULT)) @@ -4481,582 +4777,617 @@ yyreduce: ;} break; - case 263: + case 289: /* Line 1455 of yacc.c */ -#line 855 "parser.y" +#line 885 "parser.y" { (yyval.type) = (yyvsp[(1) - (6)].ifinfo).interface; type_interface_define((yyval.type), (yyvsp[(2) - (6)].type), (yyvsp[(4) - (6)].stmt_list)); pointer_default = (yyvsp[(1) - (6)].ifinfo).old_pointer_default; ;} break; - case 264: + case 290: /* Line 1455 of yacc.c */ -#line 863 "parser.y" +#line 893 "parser.y" { (yyval.type) = (yyvsp[(1) - (8)].ifinfo).interface; type_interface_define((yyval.type), find_type_or_error2((yyvsp[(3) - (8)].str), 0), (yyvsp[(6) - (8)].stmt_list)); pointer_default = (yyvsp[(1) - (8)].ifinfo).old_pointer_default; ;} break; - case 265: - -/* Line 1455 of yacc.c */ -#line 867 "parser.y" - { (yyval.type) = (yyvsp[(1) - (2)].type); ;} - break; - - case 266: - -/* Line 1455 of yacc.c */ -#line 871 "parser.y" - { (yyval.type) = (yyvsp[(1) - (2)].type); ;} - break; - - case 267: - -/* Line 1455 of yacc.c */ -#line 872 "parser.y" - { (yyval.type) = (yyvsp[(1) - (2)].type); ;} - break; - - case 268: - -/* Line 1455 of yacc.c */ -#line 875 "parser.y" - { (yyval.type) = type_new_module((yyvsp[(2) - (2)].str)); ;} - break; - - case 269: - -/* Line 1455 of yacc.c */ -#line 876 "parser.y" - { (yyval.type) = type_new_module((yyvsp[(2) - (2)].str)); ;} - break; - - case 270: - -/* Line 1455 of yacc.c */ -#line 879 "parser.y" - { (yyval.type) = (yyvsp[(2) - (2)].type); - (yyval.type)->attrs = check_module_attrs((yyvsp[(2) - (2)].type)->name, (yyvsp[(1) - (2)].attr_list)); - ;} - break; - - case 271: - -/* Line 1455 of yacc.c */ -#line 885 "parser.y" - { (yyval.type) = (yyvsp[(1) - (5)].type); - type_module_define((yyval.type), (yyvsp[(3) - (5)].stmt_list)); - ;} - break; - - case 272: - -/* Line 1455 of yacc.c */ -#line 891 "parser.y" - { (yyval.stgclass) = STG_EXTERN; ;} - break; - - case 273: - -/* Line 1455 of yacc.c */ -#line 892 "parser.y" - { (yyval.stgclass) = STG_STATIC; ;} - break; - - case 274: - -/* Line 1455 of yacc.c */ -#line 893 "parser.y" - { (yyval.stgclass) = STG_REGISTER; ;} - break; - - case 275: - -/* Line 1455 of yacc.c */ -#line 897 "parser.y" - { (yyval.attr) = make_attr(ATTR_INLINE); ;} - break; - - case 276: - -/* Line 1455 of yacc.c */ -#line 901 "parser.y" - { (yyval.attr) = make_attr(ATTR_CONST); ;} - break; - - case 277: - -/* Line 1455 of yacc.c */ -#line 904 "parser.y" - { (yyval.attr_list) = NULL; ;} - break; - - case 278: - -/* Line 1455 of yacc.c */ -#line 905 "parser.y" - { (yyval.attr_list) = append_attr((yyvsp[(1) - (2)].attr_list), (yyvsp[(2) - (2)].attr)); ;} - break; - - case 279: - -/* Line 1455 of yacc.c */ -#line 908 "parser.y" - { (yyval.declspec) = make_decl_spec((yyvsp[(1) - (2)].type), (yyvsp[(2) - (2)].declspec), NULL, NULL, STG_NONE); ;} - break; - - case 280: - -/* Line 1455 of yacc.c */ -#line 910 "parser.y" - { (yyval.declspec) = make_decl_spec((yyvsp[(2) - (3)].type), (yyvsp[(1) - (3)].declspec), (yyvsp[(3) - (3)].declspec), NULL, STG_NONE); ;} - break; - - case 281: - -/* Line 1455 of yacc.c */ -#line 913 "parser.y" - { (yyval.declspec) = NULL; ;} - break; - - case 283: - -/* Line 1455 of yacc.c */ -#line 918 "parser.y" - { (yyval.declspec) = make_decl_spec(NULL, (yyvsp[(2) - (2)].declspec), NULL, (yyvsp[(1) - (2)].attr), STG_NONE); ;} - break; - - case 284: - -/* Line 1455 of yacc.c */ -#line 919 "parser.y" - { (yyval.declspec) = make_decl_spec(NULL, (yyvsp[(2) - (2)].declspec), NULL, (yyvsp[(1) - (2)].attr), STG_NONE); ;} - break; - - case 285: - -/* Line 1455 of yacc.c */ -#line 920 "parser.y" - { (yyval.declspec) = make_decl_spec(NULL, (yyvsp[(2) - (2)].declspec), NULL, NULL, (yyvsp[(1) - (2)].stgclass)); ;} - break; - - case 286: - -/* Line 1455 of yacc.c */ -#line 925 "parser.y" - { (yyval.declarator) = (yyvsp[(3) - (3)].declarator); (yyval.declarator)->type = append_ptrchain_type((yyval.declarator)->type, type_new_pointer(pointer_default, NULL, (yyvsp[(2) - (3)].attr_list))); ;} - break; - - case 287: - -/* Line 1455 of yacc.c */ -#line 926 "parser.y" - { (yyval.declarator) = (yyvsp[(2) - (2)].declarator); if ((yyval.declarator)->func_type) (yyval.declarator)->func_type->attrs = append_attr((yyval.declarator)->func_type->attrs, make_attrp(ATTR_CALLCONV, (yyvsp[(1) - (2)].str))); - else if ((yyval.declarator)->type) (yyval.declarator)->type->attrs = append_attr((yyval.declarator)->type->attrs, make_attrp(ATTR_CALLCONV, (yyvsp[(1) - (2)].str))); ;} - break; - - case 289: - -/* Line 1455 of yacc.c */ -#line 932 "parser.y" - { (yyval.declarator) = make_declarator((yyvsp[(1) - (1)].var)); ;} - break; - - case 290: - -/* Line 1455 of yacc.c */ -#line 933 "parser.y" - { (yyval.declarator) = (yyvsp[(2) - (3)].declarator); ;} - break; - case 291: /* Line 1455 of yacc.c */ -#line 934 "parser.y" - { (yyval.declarator) = (yyvsp[(1) - (2)].declarator); (yyval.declarator)->array = append_array((yyval.declarator)->array, (yyvsp[(2) - (2)].expr)); ;} +#line 897 "parser.y" + { (yyval.type) = (yyvsp[(1) - (2)].type); ;} break; case 292: /* Line 1455 of yacc.c */ -#line 935 "parser.y" - { (yyval.declarator) = (yyvsp[(1) - (4)].declarator); - (yyval.declarator)->func_type = append_ptrchain_type((yyval.declarator)->type, type_new_function((yyvsp[(3) - (4)].var_list))); - (yyval.declarator)->type = NULL; - ;} +#line 901 "parser.y" + { (yyval.type) = (yyvsp[(1) - (2)].type); ;} break; case 293: /* Line 1455 of yacc.c */ -#line 944 "parser.y" - { (yyval.declarator) = (yyvsp[(3) - (3)].declarator); (yyval.declarator)->type = append_ptrchain_type((yyval.declarator)->type, type_new_pointer(pointer_default, NULL, (yyvsp[(2) - (3)].attr_list))); ;} +#line 902 "parser.y" + { (yyval.type) = (yyvsp[(1) - (2)].type); ;} break; case 294: /* Line 1455 of yacc.c */ -#line 945 "parser.y" - { (yyval.declarator) = (yyvsp[(2) - (2)].declarator); if ((yyval.declarator)->func_type) (yyval.declarator)->func_type->attrs = append_attr((yyval.declarator)->func_type->attrs, make_attrp(ATTR_CALLCONV, (yyvsp[(1) - (2)].str))); - else if ((yyval.declarator)->type) (yyval.declarator)->type->attrs = append_attr((yyval.declarator)->type->attrs, make_attrp(ATTR_CALLCONV, (yyvsp[(1) - (2)].str))); ;} +#line 905 "parser.y" + { (yyval.type) = type_new_module((yyvsp[(2) - (2)].str)); ;} + break; + + case 295: + +/* Line 1455 of yacc.c */ +#line 906 "parser.y" + { (yyval.type) = type_new_module((yyvsp[(2) - (2)].str)); ;} break; case 296: /* Line 1455 of yacc.c */ -#line 953 "parser.y" - { (yyval.declarator) = (yyvsp[(3) - (3)].declarator); (yyval.declarator)->type = append_ptrchain_type((yyval.declarator)->type, type_new_pointer(pointer_default, NULL, (yyvsp[(2) - (3)].attr_list))); ;} +#line 909 "parser.y" + { (yyval.type) = (yyvsp[(2) - (2)].type); + (yyval.type)->attrs = check_module_attrs((yyvsp[(2) - (2)].type)->name, (yyvsp[(1) - (2)].attr_list)); + ;} break; case 297: /* Line 1455 of yacc.c */ -#line 954 "parser.y" - { (yyval.declarator) = (yyvsp[(2) - (2)].declarator); if ((yyval.declarator)->func_type) (yyval.declarator)->func_type->attrs = append_attr((yyval.declarator)->func_type->attrs, make_attrp(ATTR_CALLCONV, (yyvsp[(1) - (2)].str))); - else if ((yyval.declarator)->type) (yyval.declarator)->type->attrs = append_attr((yyval.declarator)->type->attrs, make_attrp(ATTR_CALLCONV, (yyvsp[(1) - (2)].str))); ;} +#line 915 "parser.y" + { (yyval.type) = (yyvsp[(1) - (5)].type); + type_module_define((yyval.type), (yyvsp[(3) - (5)].stmt_list)); + ;} break; case 298: /* Line 1455 of yacc.c */ -#line 959 "parser.y" - { (yyval.declarator) = make_declarator(NULL); ;} +#line 921 "parser.y" + { (yyval.stgclass) = STG_EXTERN; ;} + break; + + case 299: + +/* Line 1455 of yacc.c */ +#line 922 "parser.y" + { (yyval.stgclass) = STG_STATIC; ;} break; case 300: /* Line 1455 of yacc.c */ -#line 965 "parser.y" - { (yyval.declarator) = (yyvsp[(2) - (3)].declarator); ;} +#line 923 "parser.y" + { (yyval.stgclass) = STG_REGISTER; ;} break; case 301: /* Line 1455 of yacc.c */ -#line 966 "parser.y" - { (yyval.declarator) = (yyvsp[(1) - (2)].declarator); (yyval.declarator)->array = append_array((yyval.declarator)->array, (yyvsp[(2) - (2)].expr)); ;} +#line 927 "parser.y" + { (yyval.attr) = make_attr(ATTR_INLINE); ;} break; case 302: /* Line 1455 of yacc.c */ -#line 967 "parser.y" - { (yyval.declarator) = make_declarator(NULL); (yyval.declarator)->array = append_array((yyval.declarator)->array, (yyvsp[(1) - (1)].expr)); ;} +#line 931 "parser.y" + { (yyval.attr) = make_attr(ATTR_CONST); ;} break; case 303: /* Line 1455 of yacc.c */ -#line 969 "parser.y" - { (yyval.declarator) = make_declarator(NULL); - (yyval.declarator)->func_type = append_ptrchain_type((yyval.declarator)->type, type_new_function((yyvsp[(2) - (3)].var_list))); - (yyval.declarator)->type = NULL; - ;} +#line 934 "parser.y" + { (yyval.attr_list) = NULL; ;} break; case 304: /* Line 1455 of yacc.c */ -#line 974 "parser.y" +#line 935 "parser.y" + { (yyval.attr_list) = append_attr((yyvsp[(1) - (2)].attr_list), (yyvsp[(2) - (2)].attr)); ;} + break; + + case 305: + +/* Line 1455 of yacc.c */ +#line 938 "parser.y" + { (yyval.declspec) = make_decl_spec((yyvsp[(1) - (2)].type), (yyvsp[(2) - (2)].declspec), NULL, NULL, STG_NONE); ;} + break; + + case 306: + +/* Line 1455 of yacc.c */ +#line 940 "parser.y" + { (yyval.declspec) = make_decl_spec((yyvsp[(2) - (3)].type), (yyvsp[(1) - (3)].declspec), (yyvsp[(3) - (3)].declspec), NULL, STG_NONE); ;} + break; + + case 307: + +/* Line 1455 of yacc.c */ +#line 943 "parser.y" + { (yyval.declspec) = NULL; ;} + break; + + case 309: + +/* Line 1455 of yacc.c */ +#line 948 "parser.y" + { (yyval.declspec) = make_decl_spec(NULL, (yyvsp[(2) - (2)].declspec), NULL, (yyvsp[(1) - (2)].attr), STG_NONE); ;} + break; + + case 310: + +/* Line 1455 of yacc.c */ +#line 949 "parser.y" + { (yyval.declspec) = make_decl_spec(NULL, (yyvsp[(2) - (2)].declspec), NULL, (yyvsp[(1) - (2)].attr), STG_NONE); ;} + break; + + case 311: + +/* Line 1455 of yacc.c */ +#line 950 "parser.y" + { (yyval.declspec) = make_decl_spec(NULL, (yyvsp[(2) - (2)].declspec), NULL, NULL, (yyvsp[(1) - (2)].stgclass)); ;} + break; + + case 312: + +/* Line 1455 of yacc.c */ +#line 955 "parser.y" + { (yyval.declarator) = (yyvsp[(3) - (3)].declarator); (yyval.declarator)->type = append_ptrchain_type((yyval.declarator)->type, type_new_pointer(pointer_default, NULL, (yyvsp[(2) - (3)].attr_list))); ;} + break; + + case 313: + +/* Line 1455 of yacc.c */ +#line 956 "parser.y" + { (yyval.declarator) = (yyvsp[(2) - (2)].declarator); if ((yyval.declarator)->func_type) (yyval.declarator)->func_type->attrs = append_attr((yyval.declarator)->func_type->attrs, make_attrp(ATTR_CALLCONV, (yyvsp[(1) - (2)].str))); + else if ((yyval.declarator)->type) (yyval.declarator)->type->attrs = append_attr((yyval.declarator)->type->attrs, make_attrp(ATTR_CALLCONV, (yyvsp[(1) - (2)].str))); ;} + break; + + case 315: + +/* Line 1455 of yacc.c */ +#line 962 "parser.y" + { (yyval.declarator) = make_declarator((yyvsp[(1) - (1)].var)); ;} + break; + + case 316: + +/* Line 1455 of yacc.c */ +#line 963 "parser.y" + { (yyval.declarator) = (yyvsp[(2) - (3)].declarator); ;} + break; + + case 317: + +/* Line 1455 of yacc.c */ +#line 964 "parser.y" + { (yyval.declarator) = (yyvsp[(1) - (2)].declarator); (yyval.declarator)->array = append_array((yyval.declarator)->array, (yyvsp[(2) - (2)].expr)); ;} + break; + + case 318: + +/* Line 1455 of yacc.c */ +#line 965 "parser.y" { (yyval.declarator) = (yyvsp[(1) - (4)].declarator); (yyval.declarator)->func_type = append_ptrchain_type((yyval.declarator)->type, type_new_function((yyvsp[(3) - (4)].var_list))); (yyval.declarator)->type = NULL; ;} break; - case 305: + case 319: + +/* Line 1455 of yacc.c */ +#line 974 "parser.y" + { (yyval.declarator) = (yyvsp[(3) - (3)].declarator); (yyval.declarator)->type = append_ptrchain_type((yyval.declarator)->type, type_new_pointer(pointer_default, NULL, (yyvsp[(2) - (3)].attr_list))); ;} + break; + + case 320: + +/* Line 1455 of yacc.c */ +#line 975 "parser.y" + { (yyval.declarator) = (yyvsp[(2) - (2)].declarator); if ((yyval.declarator)->func_type) (yyval.declarator)->func_type->attrs = append_attr((yyval.declarator)->func_type->attrs, make_attrp(ATTR_CALLCONV, (yyvsp[(1) - (2)].str))); + else if ((yyval.declarator)->type) (yyval.declarator)->type->attrs = append_attr((yyval.declarator)->type->attrs, make_attrp(ATTR_CALLCONV, (yyvsp[(1) - (2)].str))); ;} + break; + + case 322: /* Line 1455 of yacc.c */ #line 983 "parser.y" { (yyval.declarator) = (yyvsp[(3) - (3)].declarator); (yyval.declarator)->type = append_ptrchain_type((yyval.declarator)->type, type_new_pointer(pointer_default, NULL, (yyvsp[(2) - (3)].attr_list))); ;} break; - case 306: + case 323: /* Line 1455 of yacc.c */ #line 984 "parser.y" - { (yyval.declarator) = (yyvsp[(2) - (2)].declarator); (yyval.declarator)->type->attrs = append_attr((yyval.declarator)->type->attrs, make_attrp(ATTR_CALLCONV, (yyvsp[(1) - (2)].str))); ;} + { (yyval.declarator) = (yyvsp[(2) - (2)].declarator); if ((yyval.declarator)->func_type) (yyval.declarator)->func_type->attrs = append_attr((yyval.declarator)->func_type->attrs, make_attrp(ATTR_CALLCONV, (yyvsp[(1) - (2)].str))); + else if ((yyval.declarator)->type) (yyval.declarator)->type->attrs = append_attr((yyval.declarator)->type->attrs, make_attrp(ATTR_CALLCONV, (yyvsp[(1) - (2)].str))); ;} break; - case 308: + case 324: /* Line 1455 of yacc.c */ -#line 991 "parser.y" - { (yyval.declarator) = (yyvsp[(3) - (3)].declarator); (yyval.declarator)->type = append_ptrchain_type((yyval.declarator)->type, type_new_pointer(pointer_default, NULL, (yyvsp[(2) - (3)].attr_list))); ;} - break; - - case 309: - -/* Line 1455 of yacc.c */ -#line 992 "parser.y" - { (yyval.declarator) = (yyvsp[(2) - (2)].declarator); (yyval.declarator)->type->attrs = append_attr((yyval.declarator)->type->attrs, make_attrp(ATTR_CALLCONV, (yyvsp[(1) - (2)].str))); ;} - break; - - case 310: - -/* Line 1455 of yacc.c */ -#line 996 "parser.y" +#line 989 "parser.y" { (yyval.declarator) = make_declarator(NULL); ;} break; - case 312: + case 326: /* Line 1455 of yacc.c */ -#line 1004 "parser.y" - { (yyval.declarator) = make_declarator((yyvsp[(1) - (1)].var)); ;} - break; - - case 313: - -/* Line 1455 of yacc.c */ -#line 1005 "parser.y" +#line 995 "parser.y" { (yyval.declarator) = (yyvsp[(2) - (3)].declarator); ;} break; - case 314: + case 327: /* Line 1455 of yacc.c */ -#line 1006 "parser.y" +#line 996 "parser.y" { (yyval.declarator) = (yyvsp[(1) - (2)].declarator); (yyval.declarator)->array = append_array((yyval.declarator)->array, (yyvsp[(2) - (2)].expr)); ;} break; - case 315: + case 328: /* Line 1455 of yacc.c */ -#line 1007 "parser.y" +#line 997 "parser.y" { (yyval.declarator) = make_declarator(NULL); (yyval.declarator)->array = append_array((yyval.declarator)->array, (yyvsp[(1) - (1)].expr)); ;} break; - case 316: + case 329: /* Line 1455 of yacc.c */ -#line 1009 "parser.y" +#line 999 "parser.y" { (yyval.declarator) = make_declarator(NULL); (yyval.declarator)->func_type = append_ptrchain_type((yyval.declarator)->type, type_new_function((yyvsp[(2) - (3)].var_list))); (yyval.declarator)->type = NULL; ;} break; - case 317: + case 330: /* Line 1455 of yacc.c */ -#line 1014 "parser.y" +#line 1004 "parser.y" { (yyval.declarator) = (yyvsp[(1) - (4)].declarator); (yyval.declarator)->func_type = append_ptrchain_type((yyval.declarator)->type, type_new_function((yyvsp[(3) - (4)].var_list))); (yyval.declarator)->type = NULL; ;} break; - case 318: + case 331: + +/* Line 1455 of yacc.c */ +#line 1013 "parser.y" + { (yyval.declarator) = (yyvsp[(3) - (3)].declarator); (yyval.declarator)->type = append_ptrchain_type((yyval.declarator)->type, type_new_pointer(pointer_default, NULL, (yyvsp[(2) - (3)].attr_list))); ;} + break; + + case 332: + +/* Line 1455 of yacc.c */ +#line 1014 "parser.y" + { (yyval.declarator) = (yyvsp[(2) - (2)].declarator); (yyval.declarator)->type->attrs = append_attr((yyval.declarator)->type->attrs, make_attrp(ATTR_CALLCONV, (yyvsp[(1) - (2)].str))); ;} + break; + + case 334: /* Line 1455 of yacc.c */ #line 1021 "parser.y" - { (yyval.declarator_list) = append_declarator( NULL, (yyvsp[(1) - (1)].declarator) ); ;} + { (yyval.declarator) = (yyvsp[(3) - (3)].declarator); (yyval.declarator)->type = append_ptrchain_type((yyval.declarator)->type, type_new_pointer(pointer_default, NULL, (yyvsp[(2) - (3)].attr_list))); ;} break; - case 319: + case 335: /* Line 1455 of yacc.c */ #line 1022 "parser.y" - { (yyval.declarator_list) = append_declarator( (yyvsp[(1) - (3)].declarator_list), (yyvsp[(3) - (3)].declarator) ); ;} + { (yyval.declarator) = (yyvsp[(2) - (2)].declarator); (yyval.declarator)->type->attrs = append_attr((yyval.declarator)->type->attrs, make_attrp(ATTR_CALLCONV, (yyvsp[(1) - (2)].str))); ;} break; - case 320: - -/* Line 1455 of yacc.c */ -#line 1025 "parser.y" - { (yyval.expr) = NULL; ;} - break; - - case 321: + case 336: /* Line 1455 of yacc.c */ #line 1026 "parser.y" + { (yyval.declarator) = make_declarator(NULL); ;} + break; + + case 338: + +/* Line 1455 of yacc.c */ +#line 1034 "parser.y" + { (yyval.declarator) = make_declarator((yyvsp[(1) - (1)].var)); ;} + break; + + case 339: + +/* Line 1455 of yacc.c */ +#line 1035 "parser.y" + { (yyval.declarator) = (yyvsp[(2) - (3)].declarator); ;} + break; + + case 340: + +/* Line 1455 of yacc.c */ +#line 1036 "parser.y" + { (yyval.declarator) = (yyvsp[(1) - (2)].declarator); (yyval.declarator)->array = append_array((yyval.declarator)->array, (yyvsp[(2) - (2)].expr)); ;} + break; + + case 341: + +/* Line 1455 of yacc.c */ +#line 1037 "parser.y" + { (yyval.declarator) = make_declarator(NULL); (yyval.declarator)->array = append_array((yyval.declarator)->array, (yyvsp[(1) - (1)].expr)); ;} + break; + + case 342: + +/* Line 1455 of yacc.c */ +#line 1039 "parser.y" + { (yyval.declarator) = make_declarator(NULL); + (yyval.declarator)->func_type = append_ptrchain_type((yyval.declarator)->type, type_new_function((yyvsp[(2) - (3)].var_list))); + (yyval.declarator)->type = NULL; + ;} + break; + + case 343: + +/* Line 1455 of yacc.c */ +#line 1044 "parser.y" + { (yyval.declarator) = (yyvsp[(1) - (4)].declarator); + (yyval.declarator)->func_type = append_ptrchain_type((yyval.declarator)->type, type_new_function((yyvsp[(3) - (4)].var_list))); + (yyval.declarator)->type = NULL; + ;} + break; + + case 344: + +/* Line 1455 of yacc.c */ +#line 1051 "parser.y" + { (yyval.declarator_list) = append_declarator( NULL, (yyvsp[(1) - (1)].declarator) ); ;} + break; + + case 345: + +/* Line 1455 of yacc.c */ +#line 1052 "parser.y" + { (yyval.declarator_list) = append_declarator( (yyvsp[(1) - (3)].declarator_list), (yyvsp[(3) - (3)].declarator) ); ;} + break; + + case 346: + +/* Line 1455 of yacc.c */ +#line 1055 "parser.y" + { (yyval.expr) = NULL; ;} + break; + + case 347: + +/* Line 1455 of yacc.c */ +#line 1056 "parser.y" { (yyval.expr) = (yyvsp[(2) - (2)].expr); ;} break; - case 322: + case 348: /* Line 1455 of yacc.c */ -#line 1029 "parser.y" +#line 1059 "parser.y" { (yyval.declarator) = (yyvsp[(1) - (2)].declarator); (yyval.declarator)->bits = (yyvsp[(2) - (2)].expr); if (!(yyval.declarator)->bits && !(yyval.declarator)->var->name) error_loc("unnamed fields are not allowed\n"); ;} break; - case 323: + case 349: /* Line 1455 of yacc.c */ -#line 1036 "parser.y" +#line 1066 "parser.y" { (yyval.declarator_list) = append_declarator( NULL, (yyvsp[(1) - (1)].declarator) ); ;} break; - case 324: - -/* Line 1455 of yacc.c */ -#line 1038 "parser.y" - { (yyval.declarator_list) = append_declarator( (yyvsp[(1) - (3)].declarator_list), (yyvsp[(3) - (3)].declarator) ); ;} - break; - - case 325: - -/* Line 1455 of yacc.c */ -#line 1042 "parser.y" - { (yyval.declarator) = (yyvsp[(1) - (1)].declarator); ;} - break; - - case 326: - -/* Line 1455 of yacc.c */ -#line 1043 "parser.y" - { (yyval.declarator) = (yyvsp[(1) - (3)].declarator); (yyvsp[(1) - (3)].declarator)->var->eval = (yyvsp[(3) - (3)].expr); ;} - break; - - case 327: - -/* Line 1455 of yacc.c */ -#line 1047 "parser.y" - { (yyval.num) = RPC_FC_RP; ;} - break; - - case 328: - -/* Line 1455 of yacc.c */ -#line 1048 "parser.y" - { (yyval.num) = RPC_FC_UP; ;} - break; - - case 329: - -/* Line 1455 of yacc.c */ -#line 1049 "parser.y" - { (yyval.num) = RPC_FC_FP; ;} - break; - - case 330: - -/* Line 1455 of yacc.c */ -#line 1052 "parser.y" - { (yyval.type) = type_new_struct((yyvsp[(2) - (5)].str), TRUE, (yyvsp[(4) - (5)].var_list)); ;} - break; - - case 331: - -/* Line 1455 of yacc.c */ -#line 1055 "parser.y" - { (yyval.type) = type_new_void(); ;} - break; - - case 332: - -/* Line 1455 of yacc.c */ -#line 1056 "parser.y" - { (yyval.type) = find_type_or_error((yyvsp[(1) - (1)].str), 0); ;} - break; - - case 333: - -/* Line 1455 of yacc.c */ -#line 1057 "parser.y" - { (yyval.type) = (yyvsp[(1) - (1)].type); ;} - break; - - case 334: - -/* Line 1455 of yacc.c */ -#line 1058 "parser.y" - { (yyval.type) = (yyvsp[(1) - (1)].type); ;} - break; - - case 335: - -/* Line 1455 of yacc.c */ -#line 1059 "parser.y" - { (yyval.type) = type_new_enum((yyvsp[(2) - (2)].str), FALSE, NULL); ;} - break; - - case 336: - -/* Line 1455 of yacc.c */ -#line 1060 "parser.y" - { (yyval.type) = (yyvsp[(1) - (1)].type); ;} - break; - - case 337: - -/* Line 1455 of yacc.c */ -#line 1061 "parser.y" - { (yyval.type) = type_new_struct((yyvsp[(2) - (2)].str), FALSE, NULL); ;} - break; - - case 338: - -/* Line 1455 of yacc.c */ -#line 1062 "parser.y" - { (yyval.type) = (yyvsp[(1) - (1)].type); ;} - break; - - case 339: - -/* Line 1455 of yacc.c */ -#line 1063 "parser.y" - { (yyval.type) = type_new_nonencapsulated_union((yyvsp[(2) - (2)].str), FALSE, NULL); ;} - break; - - case 340: - -/* Line 1455 of yacc.c */ -#line 1064 "parser.y" - { (yyval.type) = make_safearray((yyvsp[(3) - (4)].type)); ;} - break; - - case 341: + case 350: /* Line 1455 of yacc.c */ #line 1068 "parser.y" + { (yyval.declarator_list) = append_declarator( (yyvsp[(1) - (3)].declarator_list), (yyvsp[(3) - (3)].declarator) ); ;} + break; + + case 351: + +/* Line 1455 of yacc.c */ +#line 1072 "parser.y" + { (yyval.declarator) = (yyvsp[(1) - (1)].declarator); ;} + break; + + case 352: + +/* Line 1455 of yacc.c */ +#line 1073 "parser.y" + { (yyval.declarator) = (yyvsp[(1) - (3)].declarator); (yyvsp[(1) - (3)].declarator)->var->eval = (yyvsp[(3) - (3)].expr); ;} + break; + + case 353: + +/* Line 1455 of yacc.c */ +#line 1077 "parser.y" + { (yyval.num) = THREADING_APARTMENT; ;} + break; + + case 354: + +/* Line 1455 of yacc.c */ +#line 1078 "parser.y" + { (yyval.num) = THREADING_NEUTRAL; ;} + break; + + case 355: + +/* Line 1455 of yacc.c */ +#line 1079 "parser.y" + { (yyval.num) = THREADING_SINGLE; ;} + break; + + case 356: + +/* Line 1455 of yacc.c */ +#line 1080 "parser.y" + { (yyval.num) = THREADING_FREE; ;} + break; + + case 357: + +/* Line 1455 of yacc.c */ +#line 1081 "parser.y" + { (yyval.num) = THREADING_BOTH; ;} + break; + + case 358: + +/* Line 1455 of yacc.c */ +#line 1085 "parser.y" + { (yyval.num) = RPC_FC_RP; ;} + break; + + case 359: + +/* Line 1455 of yacc.c */ +#line 1086 "parser.y" + { (yyval.num) = RPC_FC_UP; ;} + break; + + case 360: + +/* Line 1455 of yacc.c */ +#line 1087 "parser.y" + { (yyval.num) = RPC_FC_FP; ;} + break; + + case 361: + +/* Line 1455 of yacc.c */ +#line 1090 "parser.y" + { (yyval.type) = type_new_struct((yyvsp[(2) - (5)].str), TRUE, (yyvsp[(4) - (5)].var_list)); ;} + break; + + case 362: + +/* Line 1455 of yacc.c */ +#line 1093 "parser.y" + { (yyval.type) = type_new_void(); ;} + break; + + case 363: + +/* Line 1455 of yacc.c */ +#line 1094 "parser.y" + { (yyval.type) = find_type_or_error((yyvsp[(1) - (1)].str), 0); ;} + break; + + case 364: + +/* Line 1455 of yacc.c */ +#line 1095 "parser.y" + { (yyval.type) = (yyvsp[(1) - (1)].type); ;} + break; + + case 365: + +/* Line 1455 of yacc.c */ +#line 1096 "parser.y" + { (yyval.type) = (yyvsp[(1) - (1)].type); ;} + break; + + case 366: + +/* Line 1455 of yacc.c */ +#line 1097 "parser.y" + { (yyval.type) = type_new_enum((yyvsp[(2) - (2)].str), FALSE, NULL); ;} + break; + + case 367: + +/* Line 1455 of yacc.c */ +#line 1098 "parser.y" + { (yyval.type) = (yyvsp[(1) - (1)].type); ;} + break; + + case 368: + +/* Line 1455 of yacc.c */ +#line 1099 "parser.y" + { (yyval.type) = type_new_struct((yyvsp[(2) - (2)].str), FALSE, NULL); ;} + break; + + case 369: + +/* Line 1455 of yacc.c */ +#line 1100 "parser.y" + { (yyval.type) = (yyvsp[(1) - (1)].type); ;} + break; + + case 370: + +/* Line 1455 of yacc.c */ +#line 1101 "parser.y" + { (yyval.type) = type_new_nonencapsulated_union((yyvsp[(2) - (2)].str), FALSE, NULL); ;} + break; + + case 371: + +/* Line 1455 of yacc.c */ +#line 1102 "parser.y" + { (yyval.type) = make_safearray((yyvsp[(3) - (4)].type)); ;} + break; + + case 372: + +/* Line 1455 of yacc.c */ +#line 1106 "parser.y" { reg_typedefs((yyvsp[(3) - (4)].declspec), (yyvsp[(4) - (4)].declarator_list), check_typedef_attrs((yyvsp[(2) - (4)].attr_list))); (yyval.statement) = make_statement_typedef((yyvsp[(4) - (4)].declarator_list)); ;} break; - case 342: + case 373: /* Line 1455 of yacc.c */ -#line 1074 "parser.y" +#line 1112 "parser.y" { (yyval.type) = type_new_nonencapsulated_union((yyvsp[(2) - (5)].str), TRUE, (yyvsp[(4) - (5)].var_list)); ;} break; - case 343: + case 374: /* Line 1455 of yacc.c */ -#line 1077 "parser.y" +#line 1115 "parser.y" { (yyval.type) = type_new_encapsulated_union((yyvsp[(2) - (10)].str), (yyvsp[(5) - (10)].var), (yyvsp[(7) - (10)].var), (yyvsp[(9) - (10)].var_list)); ;} break; - case 344: + case 375: /* Line 1455 of yacc.c */ -#line 1081 "parser.y" +#line 1119 "parser.y" { (yyval.num) = MAKEVERSION((yyvsp[(1) - (1)].num), 0); ;} break; - case 345: + case 376: /* Line 1455 of yacc.c */ -#line 1082 "parser.y" +#line 1120 "parser.y" { (yyval.num) = MAKEVERSION((yyvsp[(1) - (3)].num), (yyvsp[(3) - (3)].num)); ;} break; /* Line 1455 of yacc.c */ -#line 5060 "parser.tab.c" +#line 5391 "parser.tab.c" default: break; } YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); @@ -5268,7 +5599,7 @@ yyreturn: /* Line 1675 of yacc.c */ -#line 1085 "parser.y" +#line 1123 "parser.y" static void decl_builtin_basic(const char *name, enum type_basic_type type) @@ -6003,12 +6334,6 @@ static type_t *reg_typedefs(decl_spec_t *decl_spec, declarator_list_t *decls, at else if (is_attr(attrs, ATTR_UUID) && !is_attr(attrs, ATTR_PUBLIC)) attrs = append_attr( attrs, make_attr(ATTR_PUBLIC) ); - /* Append the SWITCHTYPE attribute to a union if it does not already have one. */ - if (type_get_type_detect_alias(type) == TYPE_UNION && - is_attr(attrs, ATTR_SWITCHTYPE) && - !is_attr(type->attrs, ATTR_SWITCHTYPE)) - type->attrs = append_attr(type->attrs, make_attrp(ATTR_SWITCHTYPE, get_attrp(attrs, ATTR_SWITCHTYPE))); - LIST_FOR_EACH_ENTRY( decl, decls, const declarator_t, entry ) { @@ -6176,20 +6501,29 @@ struct allowed_attr allowed_attr[] = /* ATTR_CALLAS */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "call_as" }, /* ATTR_CALLCONV */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL }, /* ATTR_CASE */ { 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, "case" }, + /* ATTR_CODE */ { 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "code" }, + /* ATTR_COMMSTATUS */ { 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, "comm_status" }, /* ATTR_CONST */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "const" }, /* ATTR_CONTEXTHANDLE */ { 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, "context_handle" }, /* ATTR_CONTROL */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, "control" }, + /* ATTR_DECODE */ { 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, "decode" }, /* ATTR_DEFAULT */ { 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, "default" }, + /* ATTR_DEFAULTBIND */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "defaultbind" }, /* ATTR_DEFAULTCOLLELEM */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "defaultcollelem" }, /* ATTR_DEFAULTVALUE */ { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, "defaultvalue" }, /* ATTR_DEFAULTVTABLE */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, "defaultvtable" }, + /* ATTR_DISABLECONSISTENCYCHECK */{ 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, "disable_consistency_check" }, /* ATTR_DISPINTERFACE */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL }, /* ATTR_DISPLAYBIND */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "displaybind" }, /* ATTR_DLLNAME */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, "dllname" }, /* ATTR_DUAL */ { 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "dual" }, + /* ATTR_ENABLEALLOCATE */ { 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "enable_allocate" }, + /* ATTR_ENCODE */ { 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, "encode" }, /* ATTR_ENDPOINT */ { 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "endpoint" }, /* ATTR_ENTRY */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "entry" }, /* ATTR_EXPLICIT_HANDLE */ { 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "explicit_handle" }, + /* ATTR_FAULTSTATUS */ { 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, "fault_status" }, + /* ATTR_FORCEALLOCATE */ { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, "force_allocate" }, /* ATTR_HANDLE */ { 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, "handle" }, /* ATTR_HELPCONTEXT */ { 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, "helpcontext" }, /* ATTR_HELPFILE */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, "helpfile" }, @@ -6199,6 +6533,7 @@ struct allowed_attr allowed_attr[] = /* ATTR_HIDDEN */ { 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, "hidden" }, /* ATTR_ID */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, "id" }, /* ATTR_IDEMPOTENT */ { 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "idempotent" }, + /* ATTR_IGNORE */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, "ignore" }, /* ATTR_IIDIS */ { 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, "iid_is" }, /* ATTR_IMMEDIATEBIND */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "immediatebind" }, /* ATTR_IMPLICIT_HANDLE */ { 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "implicit_handle" }, @@ -6207,24 +6542,35 @@ struct allowed_attr allowed_attr[] = /* ATTR_INPUTSYNC */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "inputsync" }, /* ATTR_LENGTHIS */ { 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, "length_is" }, /* ATTR_LIBLCID */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, "lcid" }, + /* ATTR_LICENSED */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, "licensed" }, /* ATTR_LOCAL */ { 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "local" }, + /* ATTR_MAYBE */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "maybe" }, + /* ATTR_MESSAGE */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "message" }, + /* ATTR_NOCODE */ { 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "nocode" }, /* ATTR_NONBROWSABLE */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "nonbrowsable" }, /* ATTR_NONCREATABLE */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, "noncreatable" }, /* ATTR_NONEXTENSIBLE */ { 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "nonextensible" }, + /* ATTR_NOTIFY */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "notify" }, + /* ATTR_NOTIFYFLAG */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "notify_flag" }, /* ATTR_OBJECT */ { 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "object" }, /* ATTR_ODL */ { 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, "odl" }, /* ATTR_OLEAUTOMATION */ { 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "oleautomation" }, + /* ATTR_OPTIMIZE */ { 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "optimize" }, /* ATTR_OPTIONAL */ { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, "optional" }, /* ATTR_OUT */ { 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, "out" }, /* ATTR_PARAMLCID */ { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, "lcid" }, + /* ATTR_PARTIALIGNORE */ { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, "partial_ignore" }, /* ATTR_POINTERDEFAULT */ { 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "pointer_default" }, /* ATTR_POINTERTYPE */ { 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, "ref, unique or ptr" }, + /* ATTR_PROGID */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, "progid" }, /* ATTR_PROPGET */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "propget" }, /* ATTR_PROPPUT */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "propput" }, /* ATTR_PROPPUTREF */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "propputref" }, + /* ATTR_PROXY */ { 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "proxy" }, /* ATTR_PUBLIC */ { 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, "public" }, /* ATTR_RANGE */ { 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 0, "range" }, /* ATTR_READONLY */ { 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, "readonly" }, + /* ATTR_REPRESENTAS */ { 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, "represent_as" }, /* ATTR_REQUESTEDIT */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "requestedit" }, /* ATTR_RESTRICTED */ { 0, 0, 1, 1, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, "restricted" }, /* ATTR_RETVAL */ { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, "retval" }, @@ -6234,11 +6580,16 @@ struct allowed_attr allowed_attr[] = /* ATTR_STRING */ { 1, 0, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, "string" }, /* ATTR_SWITCHIS */ { 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, "switch_is" }, /* ATTR_SWITCHTYPE */ { 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, "switch_type" }, + /* ATTR_THREADING */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, "threading" }, /* ATTR_TRANSMITAS */ { 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, "transmit_as" }, + /* ATTR_UIDEFAULT */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "uidefault" }, + /* ATTR_USESGETLASTERROR */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "usesgetlasterror" }, + /* ATTR_USERMARSHAL */ { 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, "user_marshal" }, /* ATTR_UUID */ { 1, 0, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, "uuid" }, /* ATTR_V1ENUM */ { 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, "v1_enum" }, /* ATTR_VARARG */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "vararg" }, /* ATTR_VERSION */ { 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, "version" }, + /* ATTR_VIPROGID */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, "vi_progid" }, /* ATTR_WIREMARSHAL */ { 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, "wire_marshal" }, }; diff --git a/reactos/tools/widl/parser.tab.h b/reactos/tools/widl/parser.tab.h index 96c57cb9648..b58ed854ed7 100644 --- a/reactos/tools/widl/parser.tab.h +++ b/reactos/tools/widl/parser.tab.h @@ -85,112 +85,141 @@ tCONTEXTHANDLESERIALIZE = 301, tCONTROL = 302, tCPPQUOTE = 303, - tDEFAULT = 304, - tDEFAULTCOLLELEM = 305, - tDEFAULTVALUE = 306, - tDEFAULTVTABLE = 307, - tDISPLAYBIND = 308, - tDISPINTERFACE = 309, - tDLLNAME = 310, - tDOUBLE = 311, - tDUAL = 312, - tENDPOINT = 313, - tENTRY = 314, - tENUM = 315, - tERRORSTATUST = 316, - tEXPLICITHANDLE = 317, - tEXTERN = 318, - tFALSE = 319, - tFASTCALL = 320, - tFLOAT = 321, - tHANDLE = 322, - tHANDLET = 323, - tHELPCONTEXT = 324, - tHELPFILE = 325, - tHELPSTRING = 326, - tHELPSTRINGCONTEXT = 327, - tHELPSTRINGDLL = 328, - tHIDDEN = 329, - tHYPER = 330, - tID = 331, - tIDEMPOTENT = 332, - tIIDIS = 333, - tIMMEDIATEBIND = 334, - tIMPLICITHANDLE = 335, - tIMPORT = 336, - tIMPORTLIB = 337, - tIN = 338, - tIN_LINE = 339, - tINLINE = 340, - tINPUTSYNC = 341, - tINT = 342, - tINT3264 = 343, - tINT64 = 344, - tINTERFACE = 345, - tLCID = 346, - tLENGTHIS = 347, - tLIBRARY = 348, - tLOCAL = 349, - tLONG = 350, - tMETHODS = 351, - tMODULE = 352, - tNONBROWSABLE = 353, - tNONCREATABLE = 354, - tNONEXTENSIBLE = 355, - tNULL = 356, - tOBJECT = 357, - tODL = 358, - tOLEAUTOMATION = 359, - tOPTIONAL = 360, - tOUT = 361, - tPASCAL = 362, - tPOINTERDEFAULT = 363, - tPROPERTIES = 364, - tPROPGET = 365, - tPROPPUT = 366, - tPROPPUTREF = 367, - tPTR = 368, - tPUBLIC = 369, - tRANGE = 370, - tREADONLY = 371, - tREF = 372, - tREGISTER = 373, - tREQUESTEDIT = 374, - tRESTRICTED = 375, - tRETVAL = 376, - tSAFEARRAY = 377, - tSHORT = 378, - tSIGNED = 379, - tSIZEIS = 380, - tSIZEOF = 381, - tSMALL = 382, - tSOURCE = 383, - tSTATIC = 384, - tSTDCALL = 385, - tSTRICTCONTEXTHANDLE = 386, - tSTRING = 387, - tSTRUCT = 388, - tSWITCH = 389, - tSWITCHIS = 390, - tSWITCHTYPE = 391, - tTRANSMITAS = 392, - tTRUE = 393, - tTYPEDEF = 394, - tUNION = 395, - tUNIQUE = 396, - tUNSIGNED = 397, - tUUID = 398, - tV1ENUM = 399, - tVARARG = 400, - tVERSION = 401, - tVOID = 402, - tWCHAR = 403, - tWIREMARSHAL = 404, - ADDRESSOF = 405, - NEG = 406, - POS = 407, - PPTR = 408, - CAST = 409 + tDECODE = 304, + tDEFAULT = 305, + tDEFAULTBIND = 306, + tDEFAULTCOLLELEM = 307, + tDEFAULTVALUE = 308, + tDEFAULTVTABLE = 309, + tDISABLECONSISTENCYCHECK = 310, + tDISPLAYBIND = 311, + tDISPINTERFACE = 312, + tDLLNAME = 313, + tDOUBLE = 314, + tDUAL = 315, + tENABLEALLOCATE = 316, + tENCODE = 317, + tENDPOINT = 318, + tENTRY = 319, + tENUM = 320, + tERRORSTATUST = 321, + tEXPLICITHANDLE = 322, + tEXTERN = 323, + tFALSE = 324, + tFASTCALL = 325, + tFAULTSTATUS = 326, + tFLOAT = 327, + tFORCEALLOCATE = 328, + tHANDLE = 329, + tHANDLET = 330, + tHELPCONTEXT = 331, + tHELPFILE = 332, + tHELPSTRING = 333, + tHELPSTRINGCONTEXT = 334, + tHELPSTRINGDLL = 335, + tHIDDEN = 336, + tHYPER = 337, + tID = 338, + tIDEMPOTENT = 339, + tIGNORE = 340, + tIIDIS = 341, + tIMMEDIATEBIND = 342, + tIMPLICITHANDLE = 343, + tIMPORT = 344, + tIMPORTLIB = 345, + tIN = 346, + tIN_LINE = 347, + tINLINE = 348, + tINPUTSYNC = 349, + tINT = 350, + tINT3264 = 351, + tINT64 = 352, + tINTERFACE = 353, + tLCID = 354, + tLENGTHIS = 355, + tLIBRARY = 356, + tLICENSED = 357, + tLOCAL = 358, + tLONG = 359, + tMAYBE = 360, + tMESSAGE = 361, + tMETHODS = 362, + tMODULE = 363, + tNOCODE = 364, + tNONBROWSABLE = 365, + tNONCREATABLE = 366, + tNONEXTENSIBLE = 367, + tNOTIFY = 368, + tNOTIFYFLAG = 369, + tNULL = 370, + tOBJECT = 371, + tODL = 372, + tOLEAUTOMATION = 373, + tOPTIMIZE = 374, + tOPTIONAL = 375, + tOUT = 376, + tPARTIALIGNORE = 377, + tPASCAL = 378, + tPOINTERDEFAULT = 379, + tPROGID = 380, + tPROPERTIES = 381, + tPROPGET = 382, + tPROPPUT = 383, + tPROPPUTREF = 384, + tPROXY = 385, + tPTR = 386, + tPUBLIC = 387, + tRANGE = 388, + tREADONLY = 389, + tREF = 390, + tREGISTER = 391, + tREPRESENTAS = 392, + tREQUESTEDIT = 393, + tRESTRICTED = 394, + tRETVAL = 395, + tSAFEARRAY = 396, + tSHORT = 397, + tSIGNED = 398, + tSIZEIS = 399, + tSIZEOF = 400, + tSMALL = 401, + tSOURCE = 402, + tSTATIC = 403, + tSTDCALL = 404, + tSTRICTCONTEXTHANDLE = 405, + tSTRING = 406, + tSTRUCT = 407, + tSWITCH = 408, + tSWITCHIS = 409, + tSWITCHTYPE = 410, + tTHREADING = 411, + tTRANSMITAS = 412, + tTRUE = 413, + tTYPEDEF = 414, + tUIDEFAULT = 415, + tUNION = 416, + tUNIQUE = 417, + tUNSIGNED = 418, + tUSESGETLASTERROR = 419, + tUSERMARSHAL = 420, + tUUID = 421, + tV1ENUM = 422, + tVARARG = 423, + tVERSION = 424, + tVIPROGID = 425, + tVOID = 426, + tWCHAR = 427, + tWIREMARSHAL = 428, + tAPARTMENT = 429, + tNEUTRAL = 430, + tSINGLE = 431, + tFREE = 432, + tBOTH = 433, + ADDRESSOF = 434, + NEG = 435, + POS = 436, + PPTR = 437, + CAST = 438 }; #endif @@ -231,7 +260,7 @@ typedef union YYSTYPE /* Line 1676 of yacc.c */ -#line 235 "parser.tab.h" +#line 264 "parser.tab.h" } YYSTYPE; # define YYSTYPE_IS_TRIVIAL 1 # define yystype YYSTYPE /* obsolescent; will be withdrawn */ diff --git a/reactos/tools/widl/parser.y b/reactos/tools/widl/parser.y index 2c85f41a34c..c924a662f7f 100644 --- a/reactos/tools/widl/parser.y +++ b/reactos/tools/widl/parser.y @@ -195,26 +195,26 @@ static statement_list_t *append_statement(statement_list_t *list, statement_t *s %token tCALLAS tCALLBACK tCASE tCDECL tCHAR tCOCLASS tCODE tCOMMSTATUS %token tCONST tCONTEXTHANDLE tCONTEXTHANDLENOSERIALIZE %token tCONTEXTHANDLESERIALIZE tCONTROL tCPPQUOTE -%token tDEFAULT +%token tDECODE tDEFAULT tDEFAULTBIND %token tDEFAULTCOLLELEM %token tDEFAULTVALUE %token tDEFAULTVTABLE -%token tDISPLAYBIND +%token tDISABLECONSISTENCYCHECK tDISPLAYBIND %token tDISPINTERFACE %token tDLLNAME tDOUBLE tDUAL -%token tENDPOINT +%token tENABLEALLOCATE tENCODE tENDPOINT %token tENTRY tENUM tERRORSTATUST %token tEXPLICITHANDLE tEXTERN %token tFALSE -%token tFASTCALL -%token tFLOAT +%token tFASTCALL tFAULTSTATUS +%token tFLOAT tFORCEALLOCATE %token tHANDLE %token tHANDLET %token tHELPCONTEXT tHELPFILE %token tHELPSTRING tHELPSTRINGCONTEXT tHELPSTRINGDLL %token tHIDDEN %token tHYPER tID tIDEMPOTENT -%token tIIDIS +%token tIGNORE tIIDIS %token tIMMEDIATEBIND %token tIMPLICITHANDLE %token tIMPORT tIMPORTLIB @@ -224,26 +224,28 @@ static statement_list_t *append_statement(statement_list_t *list, statement_t *s %token tINTERFACE %token tLCID %token tLENGTHIS tLIBRARY -%token tLOCAL +%token tLICENSED tLOCAL %token tLONG +%token tMAYBE tMESSAGE %token tMETHODS %token tMODULE -%token tNONBROWSABLE +%token tNOCODE tNONBROWSABLE %token tNONCREATABLE %token tNONEXTENSIBLE +%token tNOTIFY tNOTIFYFLAG %token tNULL %token tOBJECT tODL tOLEAUTOMATION -%token tOPTIONAL +%token tOPTIMIZE tOPTIONAL %token tOUT -%token tPASCAL +%token tPARTIALIGNORE tPASCAL %token tPOINTERDEFAULT -%token tPROPERTIES +%token tPROGID tPROPERTIES %token tPROPGET tPROPPUT tPROPPUTREF -%token tPTR +%token tPROXY tPTR %token tPUBLIC %token tRANGE %token tREADONLY tREF -%token tREGISTER +%token tREGISTER tREPRESENTAS %token tREQUESTEDIT %token tRESTRICTED %token tRETVAL @@ -258,18 +260,19 @@ static statement_list_t *append_statement(statement_list_t *list, statement_t *s %token tSTRICTCONTEXTHANDLE %token tSTRING tSTRUCT %token tSWITCH tSWITCHIS tSWITCHTYPE -%token tTRANSMITAS +%token tTHREADING tTRANSMITAS %token tTRUE %token tTYPEDEF -%token tUNION +%token tUIDEFAULT tUNION %token tUNIQUE %token tUNSIGNED -%token tUUID +%token tUSESGETLASTERROR tUSERMARSHAL tUUID %token tV1ENUM %token tVARARG -%token tVERSION +%token tVERSION tVIPROGID %token tVOID %token tWCHAR tWIREMARSHAL +%token tAPARTMENT tNEUTRAL tSINGLE tFREE tBOTH %type attribute type_qualifier function_specifier %type m_attributes attributes attrib_list m_type_qual_list @@ -297,7 +300,7 @@ static statement_list_t *append_statement(statement_list_t *list, statement_t *s %type m_abstract_declarator abstract_declarator abstract_declarator_no_direct abstract_direct_declarator %type declarator_list struct_declarator_list %type coclass coclasshdr coclassdef -%type pointer_type version +%type pointer_type threading_type version %type libraryhdr callconv cppquote importlib import t_ident %type uuid_string %type import_start @@ -330,6 +333,7 @@ input: gbl_statements { fix_incomplete(); write_proxies($1); write_client($1); write_server($1); + write_regscript($1); write_dlldata($1); write_local_stubs($1); } @@ -476,20 +480,29 @@ attribute: { $$ = NULL; } | tBROADCAST { $$ = make_attr(ATTR_BROADCAST); } | tCALLAS '(' ident ')' { $$ = make_attrp(ATTR_CALLAS, $3); } | tCASE '(' expr_list_int_const ')' { $$ = make_attrp(ATTR_CASE, $3); } + | tCODE { $$ = make_attr(ATTR_CODE); } + | tCOMMSTATUS { $$ = make_attr(ATTR_COMMSTATUS); } | tCONTEXTHANDLE { $$ = make_attrv(ATTR_CONTEXTHANDLE, 0); } | tCONTEXTHANDLENOSERIALIZE { $$ = make_attrv(ATTR_CONTEXTHANDLE, 0); /* RPC_CONTEXT_HANDLE_DONT_SERIALIZE */ } | tCONTEXTHANDLESERIALIZE { $$ = make_attrv(ATTR_CONTEXTHANDLE, 0); /* RPC_CONTEXT_HANDLE_SERIALIZE */ } | tCONTROL { $$ = make_attr(ATTR_CONTROL); } + | tDECODE { $$ = make_attr(ATTR_DECODE); } | tDEFAULT { $$ = make_attr(ATTR_DEFAULT); } + | tDEFAULTBIND { $$ = make_attr(ATTR_DEFAULTBIND); } | tDEFAULTCOLLELEM { $$ = make_attr(ATTR_DEFAULTCOLLELEM); } | tDEFAULTVALUE '(' expr_const ')' { $$ = make_attrp(ATTR_DEFAULTVALUE, $3); } | tDEFAULTVTABLE { $$ = make_attr(ATTR_DEFAULTVTABLE); } + | tDISABLECONSISTENCYCHECK { $$ = make_attr(ATTR_DISABLECONSISTENCYCHECK); } | tDISPLAYBIND { $$ = make_attr(ATTR_DISPLAYBIND); } | tDLLNAME '(' aSTRING ')' { $$ = make_attrp(ATTR_DLLNAME, $3); } | tDUAL { $$ = make_attr(ATTR_DUAL); } + | tENABLEALLOCATE { $$ = make_attr(ATTR_ENABLEALLOCATE); } + | tENCODE { $$ = make_attr(ATTR_ENCODE); } | tENDPOINT '(' str_list ')' { $$ = make_attrp(ATTR_ENDPOINT, $3); } | tENTRY '(' expr_const ')' { $$ = make_attrp(ATTR_ENTRY, $3); } | tEXPLICITHANDLE { $$ = make_attr(ATTR_EXPLICIT_HANDLE); } + | tFAULTSTATUS { $$ = make_attr(ATTR_FAULTSTATUS); } + | tFORCEALLOCATE { $$ = make_attr(ATTR_FORCEALLOCATE); } | tHANDLE { $$ = make_attr(ATTR_HANDLE); } | tHELPCONTEXT '(' expr_int_const ')' { $$ = make_attrp(ATTR_HELPCONTEXT, $3); } | tHELPFILE '(' aSTRING ')' { $$ = make_attrp(ATTR_HELPFILE, $3); } @@ -499,6 +512,7 @@ attribute: { $$ = NULL; } | tHIDDEN { $$ = make_attr(ATTR_HIDDEN); } | tID '(' expr_int_const ')' { $$ = make_attrp(ATTR_ID, $3); } | tIDEMPOTENT { $$ = make_attr(ATTR_IDEMPOTENT); } + | tIGNORE { $$ = make_attr(ATTR_IGNORE); } | tIIDIS '(' expr ')' { $$ = make_attrp(ATTR_IIDIS, $3); } | tIMMEDIATEBIND { $$ = make_attr(ATTR_IMMEDIATEBIND); } | tIMPLICITHANDLE '(' tHANDLET aIDENTIFIER ')' { $$ = make_attrp(ATTR_IMPLICIT_HANDLE, $4); } @@ -507,25 +521,36 @@ attribute: { $$ = NULL; } | tLENGTHIS '(' m_exprs ')' { $$ = make_attrp(ATTR_LENGTHIS, $3); } | tLCID '(' expr_int_const ')' { $$ = make_attrp(ATTR_LIBLCID, $3); } | tLCID { $$ = make_attr(ATTR_PARAMLCID); } + | tLICENSED { $$ = make_attr(ATTR_LICENSED); } | tLOCAL { $$ = make_attr(ATTR_LOCAL); } + | tMAYBE { $$ = make_attr(ATTR_MAYBE); } + | tMESSAGE { $$ = make_attr(ATTR_MESSAGE); } + | tNOCODE { $$ = make_attr(ATTR_NOCODE); } | tNONBROWSABLE { $$ = make_attr(ATTR_NONBROWSABLE); } | tNONCREATABLE { $$ = make_attr(ATTR_NONCREATABLE); } | tNONEXTENSIBLE { $$ = make_attr(ATTR_NONEXTENSIBLE); } + | tNOTIFY { $$ = make_attr(ATTR_NOTIFY); } + | tNOTIFYFLAG { $$ = make_attr(ATTR_NOTIFYFLAG); } | tOBJECT { $$ = make_attr(ATTR_OBJECT); } | tODL { $$ = make_attr(ATTR_ODL); } | tOLEAUTOMATION { $$ = make_attr(ATTR_OLEAUTOMATION); } + | tOPTIMIZE '(' aSTRING ')' { $$ = make_attrp(ATTR_OPTIMIZE, $3); } | tOPTIONAL { $$ = make_attr(ATTR_OPTIONAL); } | tOUT { $$ = make_attr(ATTR_OUT); } + | tPARTIALIGNORE { $$ = make_attr(ATTR_PARTIALIGNORE); } | tPOINTERDEFAULT '(' pointer_type ')' { $$ = make_attrv(ATTR_POINTERDEFAULT, $3); } + | tPROGID '(' aSTRING ')' { $$ = make_attrp(ATTR_PROGID, $3); } | tPROPGET { $$ = make_attr(ATTR_PROPGET); } | tPROPPUT { $$ = make_attr(ATTR_PROPPUT); } | tPROPPUTREF { $$ = make_attr(ATTR_PROPPUTREF); } + | tPROXY { $$ = make_attr(ATTR_PROXY); } | tPUBLIC { $$ = make_attr(ATTR_PUBLIC); } | tRANGE '(' expr_int_const ',' expr_int_const ')' { expr_list_t *list = append_expr( NULL, $3 ); list = append_expr( list, $5 ); $$ = make_attrp(ATTR_RANGE, list); } | tREADONLY { $$ = make_attr(ATTR_READONLY); } + | tREPRESENTAS '(' type ')' { $$ = make_attrp(ATTR_REPRESENTAS, $3); } | tREQUESTEDIT { $$ = make_attr(ATTR_REQUESTEDIT); } | tRESTRICTED { $$ = make_attr(ATTR_RESTRICTED); } | tRETVAL { $$ = make_attr(ATTR_RETVAL); } @@ -536,10 +561,15 @@ attribute: { $$ = NULL; } | tSWITCHIS '(' expr ')' { $$ = make_attrp(ATTR_SWITCHIS, $3); } | tSWITCHTYPE '(' type ')' { $$ = make_attrp(ATTR_SWITCHTYPE, $3); } | tTRANSMITAS '(' type ')' { $$ = make_attrp(ATTR_TRANSMITAS, $3); } + | tTHREADING '(' threading_type ')' { $$ = make_attrv(ATTR_THREADING, $3); } + | tUIDEFAULT { $$ = make_attr(ATTR_UIDEFAULT); } + | tUSESGETLASTERROR { $$ = make_attr(ATTR_USESGETLASTERROR); } + | tUSERMARSHAL '(' type ')' { $$ = make_attrp(ATTR_USERMARSHAL, $3); } | tUUID '(' uuid_string ')' { $$ = make_attrp(ATTR_UUID, $3); } | tV1ENUM { $$ = make_attr(ATTR_V1ENUM); } | tVARARG { $$ = make_attr(ATTR_VARARG); } | tVERSION '(' version ')' { $$ = make_attrv(ATTR_VERSION, $3); } + | tVIPROGID '(' aSTRING ')' { $$ = make_attrp(ATTR_VIPROGID, $3); } | tWIREMARSHAL '(' type ')' { $$ = make_attrp(ATTR_WIREMARSHAL, $3); } | pointer_type { $$ = make_attrv(ATTR_POINTERTYPE, $1); } ; @@ -1043,6 +1073,14 @@ init_declarator: | declarator '=' expr_const { $$ = $1; $1->var->eval = $3; } ; +threading_type: + tAPARTMENT { $$ = THREADING_APARTMENT; } + | tNEUTRAL { $$ = THREADING_NEUTRAL; } + | tSINGLE { $$ = THREADING_SINGLE; } + | tFREE { $$ = THREADING_FREE; } + | tBOTH { $$ = THREADING_BOTH; } + ; + pointer_type: tREF { $$ = RPC_FC_RP; } | tUNIQUE { $$ = RPC_FC_UP; } @@ -1816,12 +1854,6 @@ static type_t *reg_typedefs(decl_spec_t *decl_spec, declarator_list_t *decls, at else if (is_attr(attrs, ATTR_UUID) && !is_attr(attrs, ATTR_PUBLIC)) attrs = append_attr( attrs, make_attr(ATTR_PUBLIC) ); - /* Append the SWITCHTYPE attribute to a union if it does not already have one. */ - if (type_get_type_detect_alias(type) == TYPE_UNION && - is_attr(attrs, ATTR_SWITCHTYPE) && - !is_attr(type->attrs, ATTR_SWITCHTYPE)) - type->attrs = append_attr(type->attrs, make_attrp(ATTR_SWITCHTYPE, get_attrp(attrs, ATTR_SWITCHTYPE))); - LIST_FOR_EACH_ENTRY( decl, decls, const declarator_t, entry ) { @@ -1989,20 +2021,29 @@ struct allowed_attr allowed_attr[] = /* ATTR_CALLAS */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "call_as" }, /* ATTR_CALLCONV */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL }, /* ATTR_CASE */ { 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, "case" }, + /* ATTR_CODE */ { 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "code" }, + /* ATTR_COMMSTATUS */ { 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, "comm_status" }, /* ATTR_CONST */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "const" }, /* ATTR_CONTEXTHANDLE */ { 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, "context_handle" }, /* ATTR_CONTROL */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, "control" }, + /* ATTR_DECODE */ { 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, "decode" }, /* ATTR_DEFAULT */ { 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, "default" }, + /* ATTR_DEFAULTBIND */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "defaultbind" }, /* ATTR_DEFAULTCOLLELEM */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "defaultcollelem" }, /* ATTR_DEFAULTVALUE */ { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, "defaultvalue" }, /* ATTR_DEFAULTVTABLE */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, "defaultvtable" }, + /* ATTR_DISABLECONSISTENCYCHECK */{ 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, "disable_consistency_check" }, /* ATTR_DISPINTERFACE */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL }, /* ATTR_DISPLAYBIND */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "displaybind" }, /* ATTR_DLLNAME */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, "dllname" }, /* ATTR_DUAL */ { 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "dual" }, + /* ATTR_ENABLEALLOCATE */ { 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "enable_allocate" }, + /* ATTR_ENCODE */ { 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, "encode" }, /* ATTR_ENDPOINT */ { 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "endpoint" }, /* ATTR_ENTRY */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "entry" }, /* ATTR_EXPLICIT_HANDLE */ { 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "explicit_handle" }, + /* ATTR_FAULTSTATUS */ { 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, "fault_status" }, + /* ATTR_FORCEALLOCATE */ { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, "force_allocate" }, /* ATTR_HANDLE */ { 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, "handle" }, /* ATTR_HELPCONTEXT */ { 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, "helpcontext" }, /* ATTR_HELPFILE */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, "helpfile" }, @@ -2012,6 +2053,7 @@ struct allowed_attr allowed_attr[] = /* ATTR_HIDDEN */ { 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, "hidden" }, /* ATTR_ID */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, "id" }, /* ATTR_IDEMPOTENT */ { 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "idempotent" }, + /* ATTR_IGNORE */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, "ignore" }, /* ATTR_IIDIS */ { 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, "iid_is" }, /* ATTR_IMMEDIATEBIND */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "immediatebind" }, /* ATTR_IMPLICIT_HANDLE */ { 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "implicit_handle" }, @@ -2020,24 +2062,35 @@ struct allowed_attr allowed_attr[] = /* ATTR_INPUTSYNC */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "inputsync" }, /* ATTR_LENGTHIS */ { 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, "length_is" }, /* ATTR_LIBLCID */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, "lcid" }, + /* ATTR_LICENSED */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, "licensed" }, /* ATTR_LOCAL */ { 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "local" }, + /* ATTR_MAYBE */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "maybe" }, + /* ATTR_MESSAGE */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "message" }, + /* ATTR_NOCODE */ { 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "nocode" }, /* ATTR_NONBROWSABLE */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "nonbrowsable" }, /* ATTR_NONCREATABLE */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, "noncreatable" }, /* ATTR_NONEXTENSIBLE */ { 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "nonextensible" }, + /* ATTR_NOTIFY */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "notify" }, + /* ATTR_NOTIFYFLAG */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "notify_flag" }, /* ATTR_OBJECT */ { 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "object" }, /* ATTR_ODL */ { 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, "odl" }, /* ATTR_OLEAUTOMATION */ { 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "oleautomation" }, + /* ATTR_OPTIMIZE */ { 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "optimize" }, /* ATTR_OPTIONAL */ { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, "optional" }, /* ATTR_OUT */ { 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, "out" }, /* ATTR_PARAMLCID */ { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, "lcid" }, + /* ATTR_PARTIALIGNORE */ { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, "partial_ignore" }, /* ATTR_POINTERDEFAULT */ { 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "pointer_default" }, /* ATTR_POINTERTYPE */ { 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, "ref, unique or ptr" }, + /* ATTR_PROGID */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, "progid" }, /* ATTR_PROPGET */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "propget" }, /* ATTR_PROPPUT */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "propput" }, /* ATTR_PROPPUTREF */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "propputref" }, + /* ATTR_PROXY */ { 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "proxy" }, /* ATTR_PUBLIC */ { 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, "public" }, /* ATTR_RANGE */ { 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 0, "range" }, /* ATTR_READONLY */ { 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, "readonly" }, + /* ATTR_REPRESENTAS */ { 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, "represent_as" }, /* ATTR_REQUESTEDIT */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "requestedit" }, /* ATTR_RESTRICTED */ { 0, 0, 1, 1, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, "restricted" }, /* ATTR_RETVAL */ { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, "retval" }, @@ -2047,11 +2100,16 @@ struct allowed_attr allowed_attr[] = /* ATTR_STRING */ { 1, 0, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, "string" }, /* ATTR_SWITCHIS */ { 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, "switch_is" }, /* ATTR_SWITCHTYPE */ { 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, "switch_type" }, + /* ATTR_THREADING */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, "threading" }, /* ATTR_TRANSMITAS */ { 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, "transmit_as" }, + /* ATTR_UIDEFAULT */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "uidefault" }, + /* ATTR_USESGETLASTERROR */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "usesgetlasterror" }, + /* ATTR_USERMARSHAL */ { 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, "user_marshal" }, /* ATTR_UUID */ { 1, 0, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, "uuid" }, /* ATTR_V1ENUM */ { 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, "v1_enum" }, /* ATTR_VARARG */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "vararg" }, /* ATTR_VERSION */ { 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, "version" }, + /* ATTR_VIPROGID */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, "vi_progid" }, /* ATTR_WIREMARSHAL */ { 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, "wire_marshal" }, }; diff --git a/reactos/tools/widl/parser.yy.c b/reactos/tools/widl/parser.yy.c index 6fe8b1a1cfe..2961e3ad2b1 100644 --- a/reactos/tools/widl/parser.yy.c +++ b/reactos/tools/widl/parser.yy.c @@ -2107,11 +2107,13 @@ static const struct keyword attr_keywords[] = {"aggregatable", tAGGREGATABLE}, {"allocate", tALLOCATE}, {"annotation", tANNOTATION}, + {"apartment", tAPARTMENT}, {"appobject", tAPPOBJECT}, {"async", tASYNC}, {"async_uuid", tASYNCUUID}, {"auto_handle", tAUTOHANDLE}, {"bindable", tBINDABLE}, + {"both", tBOTH}, {"broadcast", tBROADCAST}, {"byte_count", tBYTECOUNT}, {"call_as", tCALLAS}, @@ -2122,15 +2124,23 @@ static const struct keyword attr_keywords[] = {"context_handle_noserialize", tCONTEXTHANDLENOSERIALIZE}, {"context_handle_serialize", tCONTEXTHANDLENOSERIALIZE}, {"control", tCONTROL}, + {"decode", tDECODE}, + {"defaultbind", tDEFAULTBIND}, {"defaultcollelem", tDEFAULTCOLLELEM}, {"defaultvalue", tDEFAULTVALUE}, {"defaultvtable", tDEFAULTVTABLE}, + {"disable_consistency_check", tDISABLECONSISTENCYCHECK}, {"displaybind", tDISPLAYBIND}, {"dllname", tDLLNAME}, {"dual", tDUAL}, + {"enable_allocate", tENABLEALLOCATE}, + {"encode", tENCODE}, {"endpoint", tENDPOINT}, {"entry", tENTRY}, {"explicit_handle", tEXPLICITHANDLE}, + {"fault_status", tFAULTSTATUS}, + {"force_allocate", tFORCEALLOCATE}, + {"free", tFREE}, {"handle", tHANDLE}, {"helpcontext", tHELPCONTEXT}, {"helpfile", tHELPFILE}, @@ -2140,6 +2150,7 @@ static const struct keyword attr_keywords[] = {"hidden", tHIDDEN}, {"id", tID}, {"idempotent", tIDEMPOTENT}, + {"ignore", tIGNORE}, {"iid_is", tIIDIS}, {"immediatebind", tIMMEDIATEBIND}, {"implicit_handle", tIMPLICITHANDLE}, @@ -2148,42 +2159,67 @@ static const struct keyword attr_keywords[] = {"input_sync", tINPUTSYNC}, {"lcid", tLCID}, {"length_is", tLENGTHIS}, + {"licensed", tLICENSED}, {"local", tLOCAL}, + {"maybe", tMAYBE}, + {"message", tMESSAGE}, + {"neutral", tNEUTRAL}, + {"nocode", tNOCODE}, {"nonbrowsable", tNONBROWSABLE}, {"noncreatable", tNONCREATABLE}, {"nonextensible", tNONEXTENSIBLE}, + {"notify", tNOTIFY}, + {"notify_flag", tNOTIFYFLAG}, {"object", tOBJECT}, {"odl", tODL}, {"oleautomation", tOLEAUTOMATION}, + {"optimize", tOPTIMIZE}, {"optional", tOPTIONAL}, {"out", tOUT}, + {"partial_ignore", tPARTIALIGNORE}, {"pointer_default", tPOINTERDEFAULT}, + {"progid", tPROGID}, {"propget", tPROPGET}, {"propput", tPROPPUT}, {"propputref", tPROPPUTREF}, + {"proxy", tPROXY}, {"ptr", tPTR}, {"public", tPUBLIC}, {"range", tRANGE}, {"readonly", tREADONLY}, {"ref", tREF}, + {"represent_as", tREPRESENTAS}, {"requestedit", tREQUESTEDIT}, {"restricted", tRESTRICTED}, {"retval", tRETVAL}, + {"single", tSINGLE}, {"size_is", tSIZEIS}, {"source", tSOURCE}, {"strict_context_handle", tSTRICTCONTEXTHANDLE}, {"string", tSTRING}, {"switch_is", tSWITCHIS}, {"switch_type", tSWITCHTYPE}, + {"threading", tTHREADING}, {"transmit_as", tTRANSMITAS}, + {"uidefault", tUIDEFAULT}, {"unique", tUNIQUE}, + {"user_marshal", tUSERMARSHAL}, + {"usesgetlasterror", tUSESGETLASTERROR}, {"uuid", tUUID}, {"v1_enum", tV1ENUM}, {"vararg", tVARARG}, {"version", tVERSION}, + {"vi_progid", tVIPROGID}, {"wire_marshal", tWIREMARSHAL}, }; +/* attributes TODO: + custom + first_is + last_is + max_is + min_is +*/ #define KWP(p) ((const struct keyword *)(p)) diff --git a/reactos/tools/widl/proxy.c b/reactos/tools/widl/proxy.c index 8cbdf8f5f5f..9952179ebf2 100644 --- a/reactos/tools/widl/proxy.c +++ b/reactos/tools/widl/proxy.c @@ -114,20 +114,6 @@ static void init_proxy(const statement_list_t *stmts) print_proxy( "#define DECLSPEC_HIDDEN\n"); print_proxy( "#endif\n"); print_proxy( "\n"); - write_exceptions( proxy ); - print_proxy( "\n"); - print_proxy( "struct __proxy_frame\n"); - print_proxy( "{\n"); - print_proxy( " __DECL_EXCEPTION_FRAME\n"); - print_proxy( " MIDL_STUB_MESSAGE _StubMsg;\n"); - print_proxy( " void *This;\n"); - print_proxy( "};\n"); - print_proxy( "\n"); - print_proxy("static int __proxy_filter( struct __proxy_frame *__frame )\n"); - print_proxy( "{\n"); - print_proxy( " return (__frame->_StubMsg.dwStubPhase != PROXY_SENDRECEIVE);\n"); - print_proxy( "}\n"); - print_proxy( "\n"); } static void clear_output_vars( const var_list_t *args ) @@ -504,7 +490,7 @@ static void gen_stub(type_t *iface, const var_t *func, const char *cas, print_proxy("\n"); } -static int count_methods(type_t *iface) +int count_methods(const type_t *iface) { const statement_t *stmt; int count = 0; @@ -593,7 +579,7 @@ static void write_proxy(type_t *iface, unsigned int *proc_offset) /* FIXME: check for [oleautomation], shouldn't generate proxies/stubs if specified */ STATEMENTS_FOR_EACH_FUNC(stmt, type_iface_get_stmts(iface)) { - const var_t *func = stmt->u.var; + var_t *func = stmt->u.var; if (first_func) { fprintf(proxy, "/*****************************************************************************\n"); fprintf(proxy, " * %s interface\n", iface->name); @@ -615,6 +601,7 @@ static void write_proxy(type_t *iface, unsigned int *proc_offset) } } } + func->procstring_offset = *proc_offset; gen_proxy(iface, func, idx, *proc_offset); gen_stub(iface, func, cname, *proc_offset); *proc_offset += get_size_procformatstring_func( func ); @@ -623,6 +610,8 @@ static void write_proxy(type_t *iface, unsigned int *proc_offset) count = count_methods(iface); + write_procformatstring_offsets( proxy, iface ); + /* proxy vtable */ print_proxy( "static %sCINTERFACE_PROXY_VTABLE(%d) _%sProxyVtbl =\n", need_delegation_indirect(iface) ? "" : "const ", count, iface->name); @@ -640,8 +629,22 @@ static void write_proxy(type_t *iface, unsigned int *proc_offset) indent--; print_proxy( "}\n"); indent--; - print_proxy( "};\n"); - fprintf(proxy, "\n\n"); + print_proxy( "};\n\n"); + + /* server info */ + print_proxy( "static const MIDL_SERVER_INFO %s_ServerInfo =\n", iface->name ); + print_proxy( "{\n" ); + indent++; + print_proxy( "&Object_StubDesc,\n" ); + print_proxy( "0,\n" ); + print_proxy( "__MIDL_ProcFormatString.Format,\n" ); + print_proxy( "&%s_FormatStringOffsetTable[-3],\n", iface->name ); + print_proxy( "0,\n" ); + print_proxy( "0,\n" ); + print_proxy( "0,\n" ); + print_proxy( "0\n" ); + indent--; + print_proxy( "};\n\n" ); /* stub vtable */ print_proxy( "static const PRPC_STUB_FUNCTION %s_table[] =\n", iface->name); @@ -659,7 +662,7 @@ static void write_proxy(type_t *iface, unsigned int *proc_offset) print_proxy( "{\n"); indent++; print_proxy( "&IID_%s,\n", iface->name); - print_proxy( "0,\n"); + print_proxy( "&%s_ServerInfo,\n", iface->name ); print_proxy( "%d,\n", count); print_proxy( "&%s_table[-3],\n", iface->name); indent--; @@ -775,6 +778,25 @@ static void write_proxy_routines(const statement_list_t *stmts) { int expr_eval_routines; unsigned int proc_offset = 0; + char *file_id = proxy_token; + int i, count, have_baseiid; + type_t **interfaces; + const type_t * delegate_to; + + write_exceptions( proxy ); + print_proxy( "\n"); + print_proxy( "struct __proxy_frame\n"); + print_proxy( "{\n"); + print_proxy( " __DECL_EXCEPTION_FRAME\n"); + print_proxy( " MIDL_STUB_MESSAGE _StubMsg;\n"); + print_proxy( " void *This;\n"); + print_proxy( "};\n"); + print_proxy( "\n"); + print_proxy("static int __proxy_filter( struct __proxy_frame *__frame )\n"); + print_proxy( "{\n"); + print_proxy( " return (__frame->_StubMsg.dwStubPhase != PROXY_SENDRECEIVE);\n"); + print_proxy( "}\n"); + print_proxy( "\n"); write_formatstringsdecl(proxy, indent, stmts, need_proxy); write_stubdescproto(); @@ -793,42 +815,6 @@ static void write_proxy_routines(const statement_list_t *stmts) write_procformatstring(proxy, stmts, need_proxy); write_typeformatstring(proxy, stmts, need_proxy); -} - -void write_proxies(const statement_list_t *stmts) -{ - char *file_id = proxy_token; - int i, count, have_baseiid; - type_t **interfaces; - const type_t * delegate_to; - - if (!do_proxies) return; - if (do_everything && !need_proxy_file(stmts)) return; - - init_proxy(stmts); - if(!proxy) return; - - if (do_win32 && do_win64) - { - fprintf(proxy, "\n#ifndef _WIN64\n\n"); - pointer_size = 4; - write_proxy_routines( stmts ); - fprintf(proxy, "\n#else /* _WIN64 */\n\n"); - pointer_size = 8; - write_proxy_routines( stmts ); - fprintf(proxy, "#endif /* _WIN64 */\n\n"); - } - else if (do_win32) - { - pointer_size = 4; - write_proxy_routines( stmts ); - } - else if (do_win64) - { - pointer_size = 8; - write_proxy_routines( stmts ); - } - interfaces = sort_interfaces(stmts, &count); fprintf(proxy, "static const CInterfaceProxyVtbl* const _%s_ProxyVtblList[] =\n", file_id); fprintf(proxy, "{\n"); @@ -901,6 +887,36 @@ void write_proxies(const statement_list_t *stmts) fprintf(proxy, " 0,\n"); fprintf(proxy, " 0\n"); fprintf(proxy, "};\n"); +} + +void write_proxies(const statement_list_t *stmts) +{ + if (!do_proxies) return; + if (do_everything && !need_proxy_file(stmts)) return; + + init_proxy(stmts); + if(!proxy) return; + + if (do_win32 && do_win64) + { + fprintf(proxy, "\n#ifndef _WIN64\n\n"); + pointer_size = 4; + write_proxy_routines( stmts ); + fprintf(proxy, "\n#else /* _WIN64 */\n\n"); + pointer_size = 8; + write_proxy_routines( stmts ); + fprintf(proxy, "\n#endif /* _WIN64 */\n"); + } + else if (do_win32) + { + pointer_size = 4; + write_proxy_routines( stmts ); + } + else if (do_win64) + { + pointer_size = 8; + write_proxy_routines( stmts ); + } fclose(proxy); } diff --git a/reactos/tools/widl/register.c b/reactos/tools/widl/register.c new file mode 100644 index 00000000000..f7092144a0b --- /dev/null +++ b/reactos/tools/widl/register.c @@ -0,0 +1,283 @@ +/* + * Generation of dll registration scripts + * + * Copyright 2010 Alexandre Julliard + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "config.h" +#include "wine/port.h" + +#include +#include +#ifdef HAVE_UNISTD_H +# include +#endif +#include +#include + +#include "widl.h" +#include "utils.h" +#include "parser.h" +#include "header.h" +#include "typegen.h" + +static int indent; + +static const char *format_uuid( const UUID *uuid ) +{ + static char buffer[40]; + sprintf( buffer, "{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}", + uuid->Data1, uuid->Data2, uuid->Data3, + uuid->Data4[0], uuid->Data4[1], uuid->Data4[2], uuid->Data4[3], + uuid->Data4[4], uuid->Data4[5], uuid->Data4[6], uuid->Data4[7] ); + return buffer; +} + +static const char *get_coclass_threading( const type_t *class ) +{ + static const char * const models[] = + { + NULL, + "Apartment", /* THREADING_APARTMENT */ + "Neutral", /* THREADING_NEUTRAL */ + "Single", /* THREADING_SINGLE */ + "Free", /* THREADING_FREE */ + "Both", /* THREADING_BOTH */ + }; + return models[get_attrv( class->attrs, ATTR_THREADING )]; +} + +static int write_interface( const type_t *iface ) +{ + const UUID *uuid = get_attrp( iface->attrs, ATTR_UUID ); + + if (!uuid) return 0; + if (!is_object( iface )) return 0; + if (!type_iface_get_inherit(iface)) /* special case for IUnknown */ + { + put_str( indent, "ForceRemove '%s' = s '%s'\n", format_uuid( uuid ), iface->name ); + return 0; + } + if (is_local( iface->attrs )) return 0; + put_str( indent, "ForceRemove '%s' = s '%s'\n", format_uuid( uuid ), iface->name ); + put_str( indent, "{\n" ); + indent++; + put_str( indent, "NumMethods = s %u\n", count_methods( iface )); + put_str( indent, "ProxyStubClsid32 = s '%%CLSID_PSFactoryBuffer%%'\n" ); + indent--; + put_str( indent, "}\n" ); + return 1; +} + +static int write_interfaces( const statement_list_t *stmts ) +{ + const statement_t *stmt; + int count = 0; + + if (stmts) LIST_FOR_EACH_ENTRY( stmt, stmts, const statement_t, entry ) + { + if (stmt->type == STMT_TYPE && type_get_type( stmt->u.type ) == TYPE_INTERFACE) + count += write_interface( stmt->u.type ); + } + return count; +} + +static int write_coclass( const type_t *class, const typelib_t *typelib ) +{ + const UUID *uuid = get_attrp( class->attrs, ATTR_UUID ); + const char *descr = get_attrp( class->attrs, ATTR_HELPSTRING ); + const char *progid = get_attrp( class->attrs, ATTR_PROGID ); + const char *vi_progid = get_attrp( class->attrs, ATTR_VIPROGID ); + const char *threading = get_coclass_threading( class ); + + if (!uuid) return 0; + if (typelib && !threading) return 0; + if (!descr) descr = class->name; + + put_str( indent, "ForceRemove '%s' = s '%s'\n", format_uuid( uuid ), descr ); + put_str( indent++, "{\n" ); + if (threading) put_str( indent, "InprocServer32 = s '%%MODULE%%' { val ThreadingModel = s '%s' }\n", + threading ); + if (progid) put_str( indent, "ProgId = s '%s'\n", progid ); + if (typelib) + { + const UUID *typelib_uuid = get_attrp( typelib->attrs, ATTR_UUID ); + const unsigned int version = get_attrv( typelib->attrs, ATTR_VERSION ); + put_str( indent, "TypeLib = s '%s'\n", format_uuid( typelib_uuid )); + put_str( indent, "Version = s '%u.%u'\n", MAJORVERSION(version), MINORVERSION(version) ); + } + if (vi_progid) put_str( indent, "VersionIndependentProgId = s '%s'\n", vi_progid ); + put_str( --indent, "}\n" ); + return 1; +} + +static void write_coclasses( const statement_list_t *stmts, const typelib_t *typelib ) +{ + const statement_t *stmt; + + if (stmts) LIST_FOR_EACH_ENTRY( stmt, stmts, const statement_t, entry ) + { + if (stmt->type == STMT_TYPE) + { + const type_t *type = stmt->u.type; + if (type_get_type(type) == TYPE_COCLASS) write_coclass( type, typelib ); + } + else if (stmt->type == STMT_LIBRARY) + { + const typelib_t *lib = stmt->u.lib; + write_coclasses( lib->stmts, lib ); + } + } +} + +static int write_progid( const type_t *class ) +{ + const UUID *uuid = get_attrp( class->attrs, ATTR_UUID ); + const char *descr = get_attrp( class->attrs, ATTR_HELPSTRING ); + const char *progid = get_attrp( class->attrs, ATTR_PROGID ); + const char *vi_progid = get_attrp( class->attrs, ATTR_VIPROGID ); + + if (!uuid) return 0; + if (!descr) descr = class->name; + + if (progid) + { + put_str( indent, "'%s' = s '%s'\n", progid, descr ); + put_str( indent++, "{\n" ); + put_str( indent, "CLSID = s '%s'\n", format_uuid( uuid ) ); + put_str( --indent, "}\n" ); + } + if (vi_progid) + { + put_str( indent, "'%s' = s '%s'\n", vi_progid, descr ); + put_str( indent++, "{\n" ); + put_str( indent, "CLSID = s '%s'\n", format_uuid( uuid ) ); + if (progid && strcmp( progid, vi_progid )) put_str( indent, "CurVer = s '%s'\n", progid ); + put_str( --indent, "}\n" ); + } + return 1; +} + +static void write_progids( const statement_list_t *stmts ) +{ + const statement_t *stmt; + + if (stmts) LIST_FOR_EACH_ENTRY( stmt, stmts, const statement_t, entry ) + { + if (stmt->type == STMT_TYPE) + { + const type_t *type = stmt->u.type; + if (type_get_type(type) == TYPE_COCLASS) write_progid( type ); + } + else if (stmt->type == STMT_LIBRARY) + { + write_progids( stmt->u.lib->stmts ); + } + } +} + +/* put a string into the resource file */ +static inline void put_string( const char *str ) +{ + while (*str) + { + unsigned char ch = *str++; + put_word( toupper(ch) ); + } + put_word( 0 ); +} + +void write_regscript( const statement_list_t *stmts ) +{ + int count; + + if (!do_regscript) return; + if (do_everything && !need_proxy_file( stmts )) return; + + init_output_buffer(); + + put_str( indent, "HKCR\n" ); + put_str( indent++, "{\n" ); + + put_str( indent, "NoRemove Interface\n" ); + put_str( indent++, "{\n" ); + count = write_interfaces( stmts ); + put_str( --indent, "}\n" ); + + put_str( indent, "NoRemove CLSID\n" ); + put_str( indent++, "{\n" ); + if (count) + { + put_str( indent, "ForceRemove '%%CLSID_PSFactoryBuffer%%' = s 'PSFactoryBuffer'\n" ); + put_str( indent++, "{\n" ); + put_str( indent, "InprocServer32 = s '%%MODULE%%' { val ThreadingModel = s 'Both' }\n" ); + put_str( --indent, "}\n" ); + } + write_coclasses( stmts, NULL ); + put_str( --indent, "}\n" ); + + write_progids( stmts ); + put_str( --indent, "}\n" ); + + if (strendswith( regscript_name, ".res" )) /* create a binary resource file */ + { + unsigned char *data = output_buffer; + size_t data_size = output_buffer_pos; + size_t header_size = 5 * sizeof(unsigned int) + 2 * sizeof(unsigned short); + + header_size += (strlen(regscript_token) + strlen("WINE_REGISTRY") + 2) * sizeof(unsigned short); + + init_output_buffer(); + + put_dword( 0 ); /* ResSize */ + put_dword( 32 ); /* HeaderSize */ + put_word( 0xffff ); /* ResType */ + put_word( 0x0000 ); + put_word( 0xffff ); /* ResName */ + put_word( 0x0000 ); + put_dword( 0 ); /* DataVersion */ + put_word( 0 ); /* Memory options */ + put_word( 0 ); /* Language */ + put_dword( 0 ); /* Version */ + put_dword( 0 ); /* Characteristics */ + + put_dword( data_size ); /* ResSize */ + put_dword( (header_size + 3) & ~3 ); /* HeaderSize */ + put_string( "WINE_REGISTRY" ); /* ResType */ + put_string( regscript_token ); /* ResName */ + align_output( 4 ); + put_dword( 0 ); /* DataVersion */ + put_word( 0 ); /* Memory options */ + put_word( 0 ); /* Language */ + put_dword( 0 ); /* Version */ + put_dword( 0 ); /* Characteristics */ + + put_data( data, data_size ); + free( data ); + align_output( 4 ); + flush_output_buffer( regscript_name ); + } + else + { + FILE *f = fopen( regscript_name, "w" ); + if (!f) error( "Could not open %s for output\n", regscript_name ); + if (fwrite( output_buffer, output_buffer_pos, 1, f ) != output_buffer_pos) + error( "Failed to write to %s\n", regscript_name ); + if (fclose( f )) + error( "Failed to write to %s\n", regscript_name ); + } +} diff --git a/reactos/tools/widl/server.c b/reactos/tools/widl/server.c index fd648993913..d02ffed66c9 100644 --- a/reactos/tools/widl/server.c +++ b/reactos/tools/widl/server.c @@ -57,7 +57,7 @@ static void write_function_stubs(type_t *iface, unsigned int *proc_offset) STATEMENTS_FOR_EACH_FUNC( stmt, type_iface_get_stmts(iface) ) { - const var_t *func = stmt->u.var; + var_t *func = stmt->u.var; int has_full_pointer = is_full_pointer_function(func); /* check for a defined binding handle */ @@ -243,6 +243,7 @@ static void write_function_stubs(type_t *iface, unsigned int *proc_offset) fprintf(server, "\n"); /* update proc_offset */ + func->procstring_offset = *proc_offset; *proc_offset += get_size_procformatstring_func( func ); } } @@ -278,6 +279,42 @@ static void write_dispatchtable(type_t *iface) } +static void write_routinetable(type_t *iface) +{ + const statement_t *stmt; + + print_server( "static const SERVER_ROUTINE %s_ServerRoutineTable[] =\n", iface->name ); + print_server( "{\n" ); + indent++; + STATEMENTS_FOR_EACH_FUNC( stmt, type_iface_get_stmts(iface) ) + { + var_t *func = stmt->u.var; + if (is_local( func->attrs )) continue; + print_server( "(SERVER_ROUTINE)%s,\n", func->name ); + } + indent--; + print_server( "};\n\n" ); +} + + +static void write_serverinfo(type_t *iface) +{ + print_server( "static const MIDL_SERVER_INFO %s_ServerInfo =\n", iface->name ); + print_server( "{\n" ); + indent++; + print_server( "&%s_StubDesc,\n", iface->name ); + print_server( "%s_ServerRoutineTable,\n", iface->name ); + print_server( "__MIDL_ProcFormatString.Format,\n" ); + print_server( "%s_FormatStringOffsetTable,\n", iface->name ); + print_server( "0,\n" ); + print_server( "0,\n" ); + print_server( "0,\n" ); + print_server( "0\n" ); + indent--; + print_server( "};\n\n" ); +} + + static void write_stubdescdecl(type_t *iface) { print_server("static const MIDL_STUB_DESC %s_StubDesc;\n", iface->name); @@ -332,6 +369,7 @@ static void write_serverinterfacedecl(type_t *iface) if (endpoints) write_endpoints( server, iface->name, endpoints ); print_server("static RPC_DISPATCH_TABLE %s_v%d_%d_DispatchTable;\n", iface->name, MAJORVERSION(ver), MINORVERSION(ver)); + print_server( "static const MIDL_SERVER_INFO %s_ServerInfo;\n", iface->name ); fprintf(server, "\n"); print_server("static const RPC_SERVER_INTERFACE %s___RpcServerInterface =\n", iface->name ); print_server("{\n"); @@ -354,7 +392,7 @@ static void write_serverinterfacedecl(type_t *iface) print_server("0,\n"); } print_server("0,\n"); - print_server("0,\n"); + print_server("&%s_ServerInfo,\n", iface->name); print_server("0,\n"); indent--; print_server("};\n"); @@ -384,22 +422,6 @@ static void init_server(void) print_server( "#define DECLSPEC_HIDDEN\n"); print_server( "#endif\n"); print_server( "\n"); - write_exceptions( server ); - print_server("\n"); - print_server("struct __server_frame\n"); - print_server("{\n"); - print_server(" __DECL_EXCEPTION_FRAME\n"); - print_server(" MIDL_STUB_MESSAGE _StubMsg;\n"); - print_server("};\n"); - print_server("\n"); - print_server("static int __server_filter( struct __server_frame *__frame )\n"); - print_server( "{\n"); - print_server( " return (__frame->code == STATUS_ACCESS_VIOLATION) ||\n"); - print_server( " (__frame->code == STATUS_DATATYPE_MISALIGNMENT) ||\n"); - print_server( " (__frame->code == RPC_X_BAD_STUB_DATA) ||\n"); - print_server( " (__frame->code == RPC_S_INVALID_BOUND);\n"); - print_server( "}\n"); - print_server( "\n"); } @@ -433,8 +455,11 @@ static void write_server_stmts(const statement_list_t *stmts, int expr_eval_rout print_server("#endif\n"); fprintf(server, "\n"); + write_procformatstring_offsets( server, iface ); write_stubdescriptor(iface, expr_eval_routines); write_dispatchtable(iface); + write_routinetable(iface); + write_serverinfo(iface); } } } @@ -445,6 +470,23 @@ static void write_server_routines(const statement_list_t *stmts) unsigned int proc_offset = 0; int expr_eval_routines; + write_exceptions( server ); + print_server("\n"); + print_server("struct __server_frame\n"); + print_server("{\n"); + print_server(" __DECL_EXCEPTION_FRAME\n"); + print_server(" MIDL_STUB_MESSAGE _StubMsg;\n"); + print_server("};\n"); + print_server("\n"); + print_server("static int __server_filter( struct __server_frame *__frame )\n"); + print_server( "{\n"); + print_server( " return (__frame->code == STATUS_ACCESS_VIOLATION) ||\n"); + print_server( " (__frame->code == STATUS_DATATYPE_MISALIGNMENT) ||\n"); + print_server( " (__frame->code == RPC_X_BAD_STUB_DATA) ||\n"); + print_server( " (__frame->code == RPC_S_INVALID_BOUND);\n"); + print_server( "}\n"); + print_server( "\n"); + write_formatstringsdecl(server, indent, stmts, need_stub); expr_eval_routines = write_expr_eval_routines(server, server_token); if (expr_eval_routines) @@ -453,8 +495,6 @@ static void write_server_routines(const statement_list_t *stmts) write_server_stmts(stmts, expr_eval_routines, &proc_offset); - fprintf(server, "\n"); - write_procformatstring(server, stmts, need_stub); write_typeformatstring(server, stmts, need_stub); } @@ -472,7 +512,7 @@ void write_server(const statement_list_t *stmts) if (do_win32 && do_win64) { - fprintf(server, "\n#ifndef _WIN64\n\n"); + fprintf(server, "#ifndef _WIN64\n\n"); pointer_size = 4; write_server_routines( stmts ); fprintf(server, "\n#else /* _WIN64 */\n\n"); diff --git a/reactos/tools/widl/typegen.c b/reactos/tools/widl/typegen.c index 717e2c838f1..244baeafd45 100644 --- a/reactos/tools/widl/typegen.c +++ b/reactos/tools/widl/typegen.c @@ -823,7 +823,6 @@ int decl_indirect(const type_t *t) } static unsigned int write_procformatstring_type(FILE *file, int indent, - const char *name, const type_t *type, const attr_list_t *attrs, int is_return) @@ -873,13 +872,44 @@ static unsigned int write_procformatstring_type(FILE *file, int indent, print_file(file, indent, "0x4d, /* FC_IN_PARAM */\n"); print_file(file, indent, "0x01,\n"); - print_file(file, indent, "NdrFcShort(0x%hx),\n", (unsigned short)type->typestring_offset); + print_file(file, indent, "NdrFcShort(0x%x), /* type offset = %u */\n", + type->typestring_offset, type->typestring_offset); size = 4; /* includes param type prefix */ } return size; } -static void write_procformatstring_stmts(FILE *file, int indent, const statement_list_t *stmts, type_pred_t pred) +static void write_procformatstring_func( FILE *file, int indent, + const var_t *func, unsigned int *offset ) +{ + /* emit argument data */ + if (type_get_function_args(func->type)) + { + const var_t *var; + LIST_FOR_EACH_ENTRY( var, type_get_function_args(func->type), const var_t, entry ) + { + print_file( file, 0, "/* %u (parameter %s) */\n", *offset, var->name ); + *offset += write_procformatstring_type(file, indent, var->type, var->attrs, FALSE); + } + } + + /* emit return value data */ + if (is_void(type_function_get_rettype(func->type))) + { + print_file(file, 0, "/* %u (void) */\n", *offset); + print_file(file, indent, "0x5b, /* FC_END */\n"); + print_file(file, indent, "0x5c, /* FC_PAD */\n"); + *offset += 2; + } + else + { + print_file( file, 0, "/* %u (return value) */\n", *offset ); + *offset += write_procformatstring_type(file, indent, type_function_get_rettype(func->type), NULL, TRUE); + } +} + +static void write_procformatstring_stmts(FILE *file, int indent, const statement_list_t *stmts, + type_pred_t pred, unsigned int *offset) { const statement_t *stmt; if (stmts) LIST_FOR_EACH_ENTRY( stmt, stmts, const statement_t, entry ) @@ -893,32 +923,18 @@ static void write_procformatstring_stmts(FILE *file, int indent, const statement { const var_t *func = stmt_func->u.var; if (is_local(func->attrs)) continue; - /* emit argument data */ - if (type_get_function_args(func->type)) - { - const var_t *var; - LIST_FOR_EACH_ENTRY( var, type_get_function_args(func->type), const var_t, entry ) - write_procformatstring_type(file, indent, var->name, var->type, var->attrs, FALSE); - } - - /* emit return value data */ - if (is_void(type_function_get_rettype(func->type))) - { - print_file(file, indent, "0x5b, /* FC_END */\n"); - print_file(file, indent, "0x5c, /* FC_PAD */\n"); - } - else - write_procformatstring_type(file, indent, "return value", type_function_get_rettype(func->type), NULL, TRUE); + write_procformatstring_func( file, indent, func, offset ); } } else if (stmt->type == STMT_LIBRARY) - write_procformatstring_stmts(file, indent, stmt->u.lib->stmts, pred); + write_procformatstring_stmts(file, indent, stmt->u.lib->stmts, pred, offset); } } void write_procformatstring(FILE *file, const statement_list_t *stmts, type_pred_t pred) { int indent = 0; + unsigned int offset = 0; print_file(file, indent, "static const MIDL_PROC_FORMAT_STRING __MIDL_ProcFormatString =\n"); print_file(file, indent, "{\n"); @@ -927,7 +943,7 @@ void write_procformatstring(FILE *file, const statement_list_t *stmts, type_pred print_file(file, indent, "{\n"); indent++; - write_procformatstring_stmts(file, indent, stmts, pred); + write_procformatstring_stmts(file, indent, stmts, pred, &offset); print_file(file, indent, "0x0\n"); indent--; @@ -937,6 +953,25 @@ void write_procformatstring(FILE *file, const statement_list_t *stmts, type_pred print_file(file, indent, "\n"); } +void write_procformatstring_offsets( FILE *file, const type_t *iface ) +{ + const statement_t *stmt; + int indent = 0; + + print_file( file, indent, "static const unsigned short %s_FormatStringOffsetTable[] =\n", + iface->name ); + print_file( file, indent, "{\n" ); + indent++; + STATEMENTS_FOR_EACH_FUNC( stmt, type_iface_get_stmts(iface) ) + { + var_t *func = stmt->u.var; + if (is_local( func->attrs )) continue; + print_file( file, indent, "%u, /* %s */\n", func->procstring_offset, func->name ); + } + indent--; + print_file( file, indent, "};\n\n" ); +} + static int write_base_type(FILE *file, const type_t *type, int convert_to_signed_type, unsigned int *typestring_offset) { unsigned char fc; @@ -3857,29 +3892,11 @@ void write_remoting_arguments(FILE *file, int indent, const var_t *func, const c } -unsigned int get_size_procformatstring_type(const char *name, const type_t *type, const attr_list_t *attrs) -{ - return write_procformatstring_type(NULL, 0, name, type, attrs, FALSE); -} - - unsigned int get_size_procformatstring_func(const var_t *func) { - const var_t *var; - unsigned int size = 0; - - /* argument list size */ - if (type_get_function_args(func->type)) - LIST_FOR_EACH_ENTRY( var, type_get_function_args(func->type), const var_t, entry ) - size += get_size_procformatstring_type(var->name, var->type, var->attrs); - - /* return value size */ - if (is_void(type_function_get_rettype(func->type))) - size += 2; /* FC_END and FC_PAD */ - else - size += get_size_procformatstring_type("return value", type_function_get_rettype(func->type), NULL); - - return size; + unsigned int offset = 0; + write_procformatstring_func( NULL, 0, func, &offset ); + return offset; } unsigned int get_size_procformatstring(const statement_list_t *stmts, type_pred_t pred) diff --git a/reactos/tools/widl/typegen.h b/reactos/tools/widl/typegen.h index 57a914a89d1..5d46614d166 100644 --- a/reactos/tools/widl/typegen.h +++ b/reactos/tools/widl/typegen.h @@ -65,11 +65,11 @@ typedef int (*type_pred_t)(const type_t *); void write_formatstringsdecl(FILE *f, int indent, const statement_list_t *stmts, type_pred_t pred); void write_procformatstring(FILE *file, const statement_list_t *stmts, type_pred_t pred); void write_typeformatstring(FILE *file, const statement_list_t *stmts, type_pred_t pred); +void write_procformatstring_offsets( FILE *file, const type_t *iface ); void print_phase_basetype(FILE *file, int indent, const char *local_var_prefix, enum remoting_phase phase, enum pass pass, const var_t *var, const char *varname); void write_remoting_arguments(FILE *file, int indent, const var_t *func, const char *local_var_prefix, enum pass pass, enum remoting_phase phase); -unsigned int get_size_procformatstring_type(const char *name, const type_t *type, const attr_list_t *attrs); unsigned int get_size_procformatstring_func(const var_t *func); unsigned int get_size_procformatstring(const statement_list_t *stmts, type_pred_t pred); unsigned int get_size_typeformatstring(const statement_list_t *stmts, type_pred_t pred); diff --git a/reactos/tools/widl/utils.c b/reactos/tools/widl/utils.c index 65477742acf..b025c9a4e8f 100644 --- a/reactos/tools/widl/utils.c +++ b/reactos/tools/widl/utils.c @@ -234,3 +234,130 @@ char *xstrdup(const char *str) s = xmalloc(strlen(str)+1); return strcpy(s, str); } + +int strendswith(const char* str, const char* end) +{ + int l = strlen(str); + int m = strlen(end); + return l >= m && strcmp(str + l - m, end) == 0; +} + +/******************************************************************* + * buffer management + * + * Function for writing to a memory buffer. + */ + +int byte_swapped = 0; +unsigned char *output_buffer; +size_t output_buffer_pos; +size_t output_buffer_size; + +static void check_output_buffer_space( size_t size ) +{ + if (output_buffer_pos + size >= output_buffer_size) + { + output_buffer_size = max( output_buffer_size * 2, output_buffer_pos + size ); + output_buffer = xrealloc( output_buffer, output_buffer_size ); + } +} + +void init_output_buffer(void) +{ + output_buffer_size = 1024; + output_buffer_pos = 0; + output_buffer = xmalloc( output_buffer_size ); +} + +void flush_output_buffer( const char *name ) +{ + int fd = open( name, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0666 ); + if (fd == -1) error( "Error creating %s\n", name ); + if (write( fd, output_buffer, output_buffer_pos ) != output_buffer_pos) + error( "Error writing to %s\n", name ); + close( fd ); + free( output_buffer ); +} + +void put_data( const void *data, size_t size ) +{ + check_output_buffer_space( size ); + memcpy( output_buffer + output_buffer_pos, data, size ); + output_buffer_pos += size; +} + +void put_byte( unsigned char val ) +{ + check_output_buffer_space( 1 ); + output_buffer[output_buffer_pos++] = val; +} + +void put_word( unsigned short val ) +{ + if (byte_swapped) val = (val << 8) | (val >> 8); + put_data( &val, sizeof(val) ); +} + +void put_dword( unsigned int val ) +{ + if (byte_swapped) + val = ((val << 24) | ((val << 8) & 0x00ff0000) | ((val >> 8) & 0x0000ff00) | (val >> 24)); + put_data( &val, sizeof(val) ); +} + +void put_qword( unsigned int val ) +{ + if (byte_swapped) + { + put_dword( 0 ); + put_dword( val ); + } + else + { + put_dword( val ); + put_dword( 0 ); + } +} + +/* pointer-sized word */ +void put_pword( unsigned int val ) +{ + if (pointer_size == 8) put_qword( val ); + else put_dword( val ); +} + +void put_str( int indent, const char *format, ... ) +{ + int n; + va_list args; + + check_output_buffer_space( 4 * indent ); + memset( output_buffer + output_buffer_pos, ' ', 4 * indent ); + output_buffer_pos += 4 * indent; + + for (;;) + { + size_t size = output_buffer_size - output_buffer_pos; + va_start( args, format ); + n = vsnprintf( (char *)output_buffer + output_buffer_pos, size, format, args ); + va_end( args ); + if (n == -1) size *= 2; + else if ((size_t)n >= size) size = n + 1; + else + { + output_buffer_pos += n; + return; + } + check_output_buffer_space( size ); + } +} + +void align_output( unsigned int align ) +{ + size_t size = align - (output_buffer_pos % align); + + if (size == align) return; + check_output_buffer_space( size ); + memset( output_buffer + output_buffer_pos, 0, size ); + output_buffer_pos += size; +} diff --git a/reactos/tools/widl/utils.h b/reactos/tools/widl/utils.h index 5c440be8c01..5b44aace3f6 100644 --- a/reactos/tools/widl/utils.h +++ b/reactos/tools/widl/utils.h @@ -28,6 +28,7 @@ void *xmalloc(size_t); void *xrealloc(void *, size_t); char *xstrdup(const char *str); +int strendswith(const char* str, const char* end); #ifndef __GNUC__ #define __attribute__(X) @@ -48,10 +49,35 @@ size_t widl_getline(char **linep, size_t *lenp, FILE *fp); UUID *parse_uuid(const char *u); int is_valid_uuid(const char *s); +/* buffer management */ + +extern int byte_swapped; +extern unsigned char *output_buffer; +extern size_t output_buffer_pos; +extern size_t output_buffer_size; + +extern void init_output_buffer(void); +extern void flush_output_buffer( const char *name ); +extern void put_data( const void *data, size_t size ); +extern void put_byte( unsigned char val ); +extern void put_word( unsigned short val ); +extern void put_dword( unsigned int val ); +extern void put_qword( unsigned int val ); +extern void put_pword( unsigned int val ); +extern void put_str( int indent, const char *format, ... ) __attribute__((format (printf, 2, 3))); +extern void align_output( unsigned int align ); + /* typelibs expect the minor version to be stored in the higher bits and * major to be stored in the lower bits */ #define MAKEVERSION(major, minor) ((((minor) & 0xffff) << 16) | ((major) & 0xffff)) #define MAJORVERSION(version) ((version) & 0xffff) #define MINORVERSION(version) (((version) >> 16) & 0xffff) +#ifndef max +#define max(a,b) (((a) > (b)) ? (a) : (b)) +#endif +#ifndef min +#define min(a,b) (((a) < (b)) ? (a) : (b)) +#endif + #endif diff --git a/reactos/tools/widl/widl.c b/reactos/tools/widl/widl.c index c4aa91f608c..dc5c165e0bb 100644 --- a/reactos/tools/widl/widl.c +++ b/reactos/tools/widl/widl.c @@ -54,10 +54,8 @@ static const char usage[] = " or: widl [options...] --dlldata-only name1 [name2...]\n" " -b arch Set the target architecture\n" " -c Generate client stub\n" -" -C file Name of client stub file (default is infile_c.c)\n" " -d n Set debug level to 'n'\n" " -D id[=val] Define preprocessor identifier id=val\n" -" --dlldata=file Name of the dlldata file (default is dlldata.c)\n" " -E Preprocess only\n" " -h Generate headers\n" " -H file Name of header file (default is infile.h)\n" @@ -66,17 +64,15 @@ static const char usage[] = " -m32, -m64 Set the kind of typelib to build (Win32 or Win64)\n" " -N Do not preprocess input\n" " --oldnames Use old naming conventions\n" +" -o, --output=NAME Set the output file name\n" " -p Generate proxy\n" -" -P file Name of proxy file (default is infile_p.c)\n" " --prefix-all=p Prefix names of client stubs / server functions with 'p'\n" " --prefix-client=p Prefix names of client stubs with 'p'\n" " --prefix-server=p Prefix names of server functions with 'p'\n" +" -r Generate registration script\n" " -s Generate server stub\n" -" -S file Name of server stub file (default is infile_s.c)\n" " -t Generate typelib\n" -" -T file Name of typelib file (default is infile.tlb)\n" " -u Generate interface identifiers file\n" -" -U file Name of interface identifiers file (default is infile_i.c)\n" " -V Print version and exit\n" " -W Enable pedantic warnings\n" " --win32 Only generate 32-bit code\n" @@ -106,6 +102,7 @@ int do_typelib = 0; int do_proxies = 0; int do_client = 0; int do_server = 0; +int do_regscript = 0; int do_idfile = 0; int do_dlldata = 0; static int no_preprocess = 0; @@ -127,6 +124,8 @@ char *client_name; char *client_token; char *server_name; char *server_token; +char *regscript_name; +char *regscript_token; static char *idfile_name; static char *idfile_token; char *temp_name; @@ -157,12 +156,13 @@ enum { }; static const char short_options[] = - "b:cC:d:D:EhH:I:m:NpP:sS:tT:uU:VW"; + "b:cC:d:D:EhH:I:m:No:pP:rsS:tT:uU:VW"; static const struct option long_options[] = { { "dlldata", 1, NULL, DLLDATA_OPTION }, { "dlldata-only", 0, NULL, DLLDATA_ONLY_OPTION }, { "local-stubs", 1, NULL, LOCAL_STUBS_OPTION }, { "oldnames", 0, NULL, OLDNAMES_OPTION }, + { "output", 0, NULL, 'o' }, { "prefix-all", 1, NULL, PREFIX_ALL_OPTION }, { "prefix-client", 1, NULL, PREFIX_CLIENT_OPTION }, { "prefix-server", 1, NULL, PREFIX_SERVER_OPTION }, @@ -288,6 +288,7 @@ static void set_everything(int x) do_proxies = x; do_client = x; do_server = x; + do_regscript = x; do_idfile = x; do_dlldata = x; } @@ -486,6 +487,7 @@ int main(int argc,char *argv[]) int optc; int ret = 0; int opti = 0; + char *output_name = NULL; signal( SIGTERM, exit_on_signal ); signal( SIGINT, exit_on_signal ); @@ -577,6 +579,9 @@ int main(int argc,char *argv[]) case 'N': no_preprocess = 1; break; + case 'o': + output_name = xstrdup(optarg); + break; case 'p': do_everything = 0; do_proxies = 1; @@ -584,6 +589,10 @@ int main(int argc,char *argv[]) case 'P': proxy_name = xstrdup(optarg); break; + case 'r': + do_everything = 0; + do_regscript = 1; + break; case 's': do_everything = 0; do_server = 1; @@ -621,6 +630,22 @@ int main(int argc,char *argv[]) set_everything(TRUE); } + if (!output_name) output_name = dup_basename(input_name, ".idl"); + + if (!do_everything && + do_header + do_typelib + do_proxies + do_client + + do_server + do_regscript + do_idfile + do_dlldata == 1) + { + if (do_header) header_name = output_name; + else if (do_typelib) typelib_name = output_name; + else if (do_proxies) proxy_name = output_name; + else if (do_client) client_name = output_name; + else if (do_server) server_name = output_name; + else if (do_regscript) regscript_name = output_name; + else if (do_idfile) idfile_name = output_name; + else if (do_dlldata) dlldata_name = output_name; + } + if (!dlldata_name && do_dlldata) dlldata_name = xstrdup("dlldata.c"); @@ -684,6 +709,11 @@ int main(int argc,char *argv[]) strcat(server_name, "_s.c"); } + if (!regscript_name && do_regscript) { + regscript_name = dup_basename(input_name, ".idl"); + strcat(regscript_name, "_r.rgs"); + } + if (!idfile_name && do_idfile) { idfile_name = dup_basename(input_name, ".idl"); strcat(idfile_name, "_i.c"); @@ -692,6 +722,7 @@ int main(int argc,char *argv[]) if (do_proxies) proxy_token = dup_basename_token(proxy_name,"_p.c"); if (do_client) client_token = dup_basename_token(client_name,"_c.c"); if (do_server) server_token = dup_basename_token(server_name,"_s.c"); + if (do_regscript) regscript_token = dup_basename_token(regscript_name,"_r.rgs"); add_widl_version_define(); wpp_add_define("_WIN32", NULL); @@ -770,6 +801,8 @@ static void rm_tempfile(void) unlink(client_name); if (do_server) unlink(server_name); + if (do_regscript) + unlink(regscript_name); if (do_idfile) unlink(idfile_name); if (do_proxies) diff --git a/reactos/tools/widl/widl.h b/reactos/tools/widl/widl.h index 5de2cba16db..515e122e41f 100644 --- a/reactos/tools/widl/widl.h +++ b/reactos/tools/widl/widl.h @@ -41,6 +41,7 @@ extern int do_typelib; extern int do_proxies; extern int do_client; extern int do_server; +extern int do_regscript; extern int do_idfile; extern int do_dlldata; extern int old_names; @@ -61,6 +62,8 @@ extern char *client_name; extern char *client_token; extern char *server_name; extern char *server_token; +extern char *regscript_name; +extern char *regscript_token; extern const char *prefix_client; extern const char *prefix_server; extern size_t pointer_size; @@ -74,6 +77,7 @@ extern void write_id_data(const statement_list_t *stmts); extern void write_proxies(const statement_list_t *stmts); extern void write_client(const statement_list_t *stmts); extern void write_server(const statement_list_t *stmts); +extern void write_regscript(const statement_list_t *stmts); extern void write_local_stubs(const statement_list_t *stmts); extern void write_dlldata(const statement_list_t *stmts); diff --git a/reactos/tools/widl/widl.rbuild b/reactos/tools/widl/widl.rbuild index 93189fa7a7b..3e1382827f4 100644 --- a/reactos/tools/widl/widl.rbuild +++ b/reactos/tools/widl/widl.rbuild @@ -10,6 +10,7 @@ hash.c header.c proxy.c + register.c server.c typegen.c typelib.c diff --git a/reactos/tools/widl/widltypes.h b/reactos/tools/widl/widltypes.h index 1bceb05e9f2..d56cecac28a 100644 --- a/reactos/tools/widl/widltypes.h +++ b/reactos/tools/widl/widltypes.h @@ -83,20 +83,29 @@ enum attr_type ATTR_CALLAS, ATTR_CALLCONV, /* calling convention pseudo-attribute */ ATTR_CASE, + ATTR_CODE, + ATTR_COMMSTATUS, ATTR_CONST, /* const pseudo-attribute */ ATTR_CONTEXTHANDLE, ATTR_CONTROL, + ATTR_DECODE, ATTR_DEFAULT, + ATTR_DEFAULTBIND, ATTR_DEFAULTCOLLELEM, ATTR_DEFAULTVALUE, ATTR_DEFAULTVTABLE, + ATTR_DISABLECONSISTENCYCHECK, ATTR_DISPINTERFACE, ATTR_DISPLAYBIND, ATTR_DLLNAME, ATTR_DUAL, + ATTR_ENABLEALLOCATE, + ATTR_ENCODE, ATTR_ENDPOINT, ATTR_ENTRY, ATTR_EXPLICIT_HANDLE, + ATTR_FAULTSTATUS, + ATTR_FORCEALLOCATE, ATTR_HANDLE, ATTR_HELPCONTEXT, ATTR_HELPFILE, @@ -106,6 +115,7 @@ enum attr_type ATTR_HIDDEN, ATTR_ID, ATTR_IDEMPOTENT, + ATTR_IGNORE, ATTR_IIDIS, ATTR_IMMEDIATEBIND, ATTR_IMPLICIT_HANDLE, @@ -114,24 +124,35 @@ enum attr_type ATTR_INPUTSYNC, ATTR_LENGTHIS, ATTR_LIBLCID, + ATTR_LICENSED, ATTR_LOCAL, + ATTR_MAYBE, + ATTR_MESSAGE, + ATTR_NOCODE, ATTR_NONBROWSABLE, ATTR_NONCREATABLE, ATTR_NONEXTENSIBLE, + ATTR_NOTIFY, + ATTR_NOTIFYFLAG, ATTR_OBJECT, ATTR_ODL, ATTR_OLEAUTOMATION, + ATTR_OPTIMIZE, ATTR_OPTIONAL, ATTR_OUT, ATTR_PARAMLCID, + ATTR_PARTIALIGNORE, ATTR_POINTERDEFAULT, ATTR_POINTERTYPE, + ATTR_PROGID, ATTR_PROPGET, ATTR_PROPPUT, ATTR_PROPPUTREF, + ATTR_PROXY, ATTR_PUBLIC, ATTR_RANGE, ATTR_READONLY, + ATTR_REPRESENTAS, ATTR_REQUESTEDIT, ATTR_RESTRICTED, ATTR_RETVAL, @@ -141,11 +162,16 @@ enum attr_type ATTR_STRING, ATTR_SWITCHIS, ATTR_SWITCHTYPE, + ATTR_THREADING, ATTR_TRANSMITAS, + ATTR_UIDEFAULT, + ATTR_USERMARSHAL, + ATTR_USESGETLASTERROR, ATTR_UUID, ATTR_V1ENUM, ATTR_VARARG, ATTR_VERSION, + ATTR_VIPROGID, ATTR_WIREMARSHAL }; @@ -226,6 +252,15 @@ enum statement_type STMT_CPPQUOTE }; +enum threading_type +{ + THREADING_APARTMENT = 1, + THREADING_NEUTRAL, + THREADING_SINGLE, + THREADING_FREE, + THREADING_BOTH +}; + enum type_basic_type { TYPE_BASIC_INT8 = 1, @@ -406,6 +441,7 @@ struct _var_t { attr_list_t *attrs; expr_t *eval; enum storage_class stgclass; + unsigned int procstring_offset; struct _loc_info_t loc_info; diff --git a/reactos/tools/widl/write_msft.c b/reactos/tools/widl/write_msft.c index b60c8f38646..aa111b0f867 100644 --- a/reactos/tools/widl/write_msft.c +++ b/reactos/tools/widl/write_msft.c @@ -847,6 +847,12 @@ static int encode_type( *alignment = 8; break; + case VT_DECIMAL: + *encoded_type = default_type; + *width = 16; + *alignment = 8; + break; + case VT_VOID: *encoded_type = 0x80000000 | (VT_EMPTY << 16) | vt; *width = 0; @@ -1206,7 +1212,7 @@ static void write_value(msft_typelib_t* typelib, int *out, int vt, const void *v int len = strlen(s), seg_len = (len + 6 + 3) & ~0x3; int offset = ctl2_alloc_segment(typelib, MSFT_SEG_CUSTDATA, seg_len, 0); *((unsigned short *)&typelib->typelib_segment_data[MSFT_SEG_CUSTDATA][offset]) = vt; - *((unsigned int *)&typelib->typelib_segment_data[MSFT_SEG_CUSTDATA][offset+2]) = len; + memcpy(&typelib->typelib_segment_data[MSFT_SEG_CUSTDATA][offset+2], &len, sizeof(len)); memcpy(&typelib->typelib_segment_data[MSFT_SEG_CUSTDATA][offset+6], value, len); len += 6; while(len < seg_len) { @@ -1310,7 +1316,9 @@ static HRESULT add_func_desc(msft_typeinfo_t* typeinfo, var_t *func, int index) case ATTR_BINDABLE: funcflags |= 0x4; /* FUNCFLAG_FBINDABLE */ break; - /* FIXME: FUNCFLAG_FDEFAULTBIND */ + case ATTR_DEFAULTBIND: + funcflags |= 0x20; /* FUNCFLAG_FDEFAULTBIND */ + break; case ATTR_DEFAULTCOLLELEM: funcflags |= 0x100; /* FUNCFLAG_FDEFAULTCOLLELEM */ break; @@ -1371,8 +1379,12 @@ static HRESULT add_func_desc(msft_typeinfo_t* typeinfo, var_t *func, int index) case ATTR_SOURCE: funcflags |= 0x2; /* FUNCFLAG_FSOURCE */ break; - /* FIXME: FUNCFLAG_FUIDEFAULT */ - /* FIXME: FUNCFLAG_FUSESGETLASTERROR */ + case ATTR_UIDEFAULT: + funcflags |= 0x200; /* FUNCFLAG_FUIDEFAULT */ + break; + case ATTR_USESGETLASTERROR: + funcflags |= 0x80; /* FUNCFLAG_FUSESGETLASTERROR */ + break; case ATTR_VARARG: if (num_optional || num_defaults) warning("add_func_desc: ignoring vararg in function with optional or defaultvalue params\n"); @@ -1610,7 +1622,9 @@ static HRESULT add_var_desc(msft_typeinfo_t *typeinfo, UINT index, var_t* var) case ATTR_BINDABLE: varflags |= 0x04; /* VARFLAG_FBINDABLE */ break; - /* FIXME: VARFLAG_FDEFAULTBIND */ + case ATTR_DEFAULTBIND: + varflags |= 0x20; /* VARFLAG_FDEFAULTBIND */ + break; case ATTR_DEFAULTCOLLELEM: varflags |= 0x100; /* VARFLAG_FDEFAULTCOLLELEM */ break; @@ -1642,7 +1656,9 @@ static HRESULT add_var_desc(msft_typeinfo_t *typeinfo, UINT index, var_t* var) case ATTR_SOURCE: varflags |= 0x02; /* VARFLAG_FSOURCE */ break; - /* FIXME: VARFLAG_FUIDEFAULT */ + case ATTR_UIDEFAULT: + varflags |= 0x0200; /* VARFLAG_FUIDEFAULT */ + break; default: break; } @@ -1867,7 +1883,9 @@ static msft_typeinfo_t *create_msft_typeinfo(msft_typelib_t *typelib, enum type_ typeinfo->flags |= 0x10; /* TYPEFLAG_FHIDDEN */ break; - /* FIXME: TYPEFLAG_FLICENSED */ + case ATTR_LICENSED: + typeinfo->flags |= 0x04; /* TYPEFLAG_FLICENSED */ + break; case ATTR_NONCREATABLE: typeinfo->flags &= ~0x2; /* TYPEFLAG_FCANCREATE */ @@ -1883,7 +1901,9 @@ static msft_typeinfo_t *create_msft_typeinfo(msft_typelib_t *typelib, enum type_ /* FIXME: TYPEFLAG_FPREDCLID */ - /* FIXME: TYPEFLAG_FPROXY */ + case ATTR_PROXY: + typeinfo->flags |= 0x4000; /* TYPEFLAG_FPROXY */ + break; /* FIXME: TYPEFLAG_FREPLACEABLE */ @@ -1998,6 +2018,12 @@ static void add_interface_typeinfo(msft_typelib_t *typelib, type_t *interface) if (-1 < interface->typelib_idx) return; + if (!interface->details.iface) + { + error( "interface %s is referenced but not defined\n", interface->name ); + return; + } + if (is_attr(interface->attrs, ATTR_DISPINTERFACE)) return add_dispinterface_typeinfo(typelib, interface); @@ -2392,24 +2418,9 @@ static void set_lib_flags(msft_typelib_t *typelib) return; } -static int ctl2_write_chunk(int fd, void *segment, int length) +static void ctl2_write_segment(msft_typelib_t *typelib, int segment) { - if (write(fd, segment, length) != length) { - close(fd); - return 0; - } - return -1; -} - -static int ctl2_write_segment(msft_typelib_t *typelib, int fd, int segment) -{ - if (write(fd, typelib->typelib_segment_data[segment], typelib->typelib_segdir[segment].length) - != typelib->typelib_segdir[segment].length) { - close(fd); - return 0; - } - - return -1; + put_data(typelib->typelib_segment_data[segment], typelib->typelib_segdir[segment].length); } static void ctl2_finalize_typeinfos(msft_typelib_t *typelib, int filesize) @@ -2439,7 +2450,7 @@ static int ctl2_finalize_segment(msft_typelib_t *typelib, int filepos, int segme } -static void ctl2_write_typeinfos(msft_typelib_t *typelib, int fd) +static void ctl2_write_typeinfos(msft_typelib_t *typelib) { msft_typeinfo_t *typeinfo; int typedata_size; @@ -2451,21 +2462,21 @@ static void ctl2_write_typeinfos(msft_typelib_t *typelib, int fd) typedata_size = typeinfo->func_data[0]; if (typeinfo->var_data) typedata_size += typeinfo->var_data[0]; - ctl2_write_chunk(fd, &typedata_size, sizeof(int)); + put_data(&typedata_size, sizeof(int)); if (typeinfo->func_data) - ctl2_write_chunk(fd, typeinfo->func_data + 1, typeinfo->func_data[0]); + put_data(typeinfo->func_data + 1, typeinfo->func_data[0]); if (typeinfo->var_data) - ctl2_write_chunk(fd, typeinfo->var_data + 1, typeinfo->var_data[0]); + put_data(typeinfo->var_data + 1, typeinfo->var_data[0]); if (typeinfo->func_indices) - ctl2_write_chunk(fd, typeinfo->func_indices, (typeinfo->typeinfo->cElement & 0xffff) * 4); + put_data(typeinfo->func_indices, (typeinfo->typeinfo->cElement & 0xffff) * 4); if (typeinfo->var_indices) - ctl2_write_chunk(fd, typeinfo->var_indices, (typeinfo->typeinfo->cElement >> 16) * 4); + put_data(typeinfo->var_indices, (typeinfo->typeinfo->cElement >> 16) * 4); if (typeinfo->func_names) - ctl2_write_chunk(fd, typeinfo->func_names, (typeinfo->typeinfo->cElement & 0xffff) * 4); + put_data(typeinfo->func_names, (typeinfo->typeinfo->cElement & 0xffff) * 4); if (typeinfo->var_names) - ctl2_write_chunk(fd, typeinfo->var_names, (typeinfo->typeinfo->cElement >> 16) * 4); + put_data(typeinfo->var_names, (typeinfo->typeinfo->cElement >> 16) * 4); if (typeinfo->func_offsets) - ctl2_write_chunk(fd, typeinfo->func_offsets, (typeinfo->typeinfo->cElement & 0xffff) * 4); + put_data(typeinfo->func_offsets, (typeinfo->typeinfo->cElement & 0xffff) * 4); if (typeinfo->var_offsets) { int add = 0, i, offset; if(typeinfo->func_data) @@ -2473,25 +2484,18 @@ static void ctl2_write_typeinfos(msft_typelib_t *typelib, int fd) for(i = 0; i < (typeinfo->typeinfo->cElement >> 16); i++) { offset = typeinfo->var_offsets[i]; offset += add; - ctl2_write_chunk(fd, &offset, 4); + put_data(&offset, 4); } } } } -static int save_all_changes(msft_typelib_t *typelib) +static void save_all_changes(msft_typelib_t *typelib) { - int retval; int filepos; - int fd; chat("save_all_changes(%p)\n", typelib); - retval = TYPE_E_IOERROR; - - fd = open(typelib->typelib->filename, O_CREAT | O_WRONLY | O_TRUNC | O_BINARY, 0666); - if (fd == -1) return retval; - filepos = sizeof(MSFT_Header) + sizeof(MSFT_SegDir); if(typelib->typelib_header.varflags & 0x100) filepos += 4; /* helpstringdll */ filepos += typelib->typelib_header.nrtypeinfos * 4; @@ -2512,33 +2516,31 @@ static int save_all_changes(msft_typelib_t *typelib) ctl2_finalize_typeinfos(typelib, filepos); - if (!ctl2_write_chunk(fd, &typelib->typelib_header, sizeof(typelib->typelib_header))) return retval; + byte_swapped = 0; + init_output_buffer(); + + put_data(&typelib->typelib_header, sizeof(typelib->typelib_header)); if(typelib->typelib_header.varflags & 0x100) - if (!ctl2_write_chunk(fd, &typelib->help_string_dll_offset, sizeof(typelib->help_string_dll_offset))) - return retval; + put_data(&typelib->help_string_dll_offset, sizeof(typelib->help_string_dll_offset)); - if (!ctl2_write_chunk(fd, typelib->typelib_typeinfo_offsets, typelib->typelib_header.nrtypeinfos * 4)) return retval; - if (!ctl2_write_chunk(fd, &typelib->typelib_segdir, sizeof(typelib->typelib_segdir))) return retval; - if (!ctl2_write_segment(typelib, fd, MSFT_SEG_TYPEINFO )) return retval; - if (!ctl2_write_segment(typelib, fd, MSFT_SEG_GUIDHASH )) return retval; - if (!ctl2_write_segment(typelib, fd, MSFT_SEG_GUID )) return retval; - if (!ctl2_write_segment(typelib, fd, MSFT_SEG_REFERENCES )) return retval; - if (!ctl2_write_segment(typelib, fd, MSFT_SEG_IMPORTINFO )) return retval; - if (!ctl2_write_segment(typelib, fd, MSFT_SEG_IMPORTFILES )) return retval; - if (!ctl2_write_segment(typelib, fd, MSFT_SEG_NAMEHASH )) return retval; - if (!ctl2_write_segment(typelib, fd, MSFT_SEG_NAME )) return retval; - if (!ctl2_write_segment(typelib, fd, MSFT_SEG_STRING )) return retval; - if (!ctl2_write_segment(typelib, fd, MSFT_SEG_TYPEDESC )) return retval; - if (!ctl2_write_segment(typelib, fd, MSFT_SEG_ARRAYDESC )) return retval; - if (!ctl2_write_segment(typelib, fd, MSFT_SEG_CUSTDATA )) return retval; - if (!ctl2_write_segment(typelib, fd, MSFT_SEG_CUSTDATAGUID)) return retval; + put_data(typelib->typelib_typeinfo_offsets, typelib->typelib_header.nrtypeinfos * 4); + put_data(&typelib->typelib_segdir, sizeof(typelib->typelib_segdir)); + ctl2_write_segment( typelib, MSFT_SEG_TYPEINFO ); + ctl2_write_segment( typelib, MSFT_SEG_GUIDHASH ); + ctl2_write_segment( typelib, MSFT_SEG_GUID ); + ctl2_write_segment( typelib, MSFT_SEG_REFERENCES ); + ctl2_write_segment( typelib, MSFT_SEG_IMPORTINFO ); + ctl2_write_segment( typelib, MSFT_SEG_IMPORTFILES ); + ctl2_write_segment( typelib, MSFT_SEG_NAMEHASH ); + ctl2_write_segment( typelib, MSFT_SEG_NAME ); + ctl2_write_segment( typelib, MSFT_SEG_STRING ); + ctl2_write_segment( typelib, MSFT_SEG_TYPEDESC ); + ctl2_write_segment( typelib, MSFT_SEG_ARRAYDESC ); + ctl2_write_segment( typelib, MSFT_SEG_CUSTDATA ); + ctl2_write_segment( typelib, MSFT_SEG_CUSTDATAGUID ); - ctl2_write_typeinfos(typelib, fd); - - if (close(fd) == -1) return retval; - - retval = S_OK; - return retval; + ctl2_write_typeinfos(typelib); + flush_output_buffer( typelib->typelib->filename ); } int create_msft_typelib(typelib_t *typelib) From 4989fe718a28857aec892c746cfcc37f0d0b6bce Mon Sep 17 00:00:00 2001 From: Roel Messiant Date: Sun, 19 Dec 2010 22:53:29 +0000 Subject: [PATCH 065/181] [OLEACC] - Use an actual entrypoint. Needed to record the instance handle, used by various function that access resources of the module. Should fix oleacc:main winetest. svn path=/trunk/; revision=50064 --- reactos/dll/win32/oleacc/oleacc.rbuild | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reactos/dll/win32/oleacc/oleacc.rbuild b/reactos/dll/win32/oleacc/oleacc.rbuild index a529b98fcd7..47f07e87b85 100644 --- a/reactos/dll/win32/oleacc/oleacc.rbuild +++ b/reactos/dll/win32/oleacc/oleacc.rbuild @@ -1,7 +1,7 @@ - + . From 8e7e8f566fba99f0f536de0bb848d8ebfbcd86e5 Mon Sep 17 00:00:00 2001 From: Roel Messiant Date: Sun, 19 Dec 2010 23:19:04 +0000 Subject: [PATCH 066/181] [ADVAPI32] - ConvertStringSidToSidW: Stop writing 1 subauthority too much. Fixes a DWORD sized buffer overflow. Should fix bug #5764. - ConvertStringSidToSidW: Don't leak an allocated SID in case of failure. [SETUPAPI] - SetupDiClassNameFromGuidExW: Rewrite to prevent a buffer overflow and pass additional winetests. Should fix bug #5474. - SetupDiClassNameFromGuidExA: Return the required buffer size in failure cases. svn path=/trunk/; revision=50066 --- reactos/dll/win32/advapi32/sec/sid.c | 9 +- reactos/dll/win32/setupapi/devinst.c | 141 ++++++++++++++++----------- 2 files changed, 87 insertions(+), 63 deletions(-) diff --git a/reactos/dll/win32/advapi32/sec/sid.c b/reactos/dll/win32/advapi32/sec/sid.c index 70974db4ce0..a51dc45fca6 100644 --- a/reactos/dll/win32/advapi32/sec/sid.c +++ b/reactos/dll/win32/advapi32/sec/sid.c @@ -1982,16 +1982,14 @@ ConvertStringSidToSidW(IN LPCWSTR StringSid, if (*StringSid == '-') StringSid++; - pisid->SubAuthority[i] = atoiW(StringSid); - while (*StringSid) { + pisid->SubAuthority[i++] = atoiW(StringSid); + while (*StringSid && *StringSid != '-') StringSid++; if (*StringSid == '-') StringSid++; - - pisid->SubAuthority[++i] = atoiW(StringSid); } if (i != pisid->SubAuthorityCount) @@ -2002,7 +2000,10 @@ ConvertStringSidToSidW(IN LPCWSTR StringSid, lend: if (!ret) + { + LocalFree(pisid); SetLastError(ERROR_INVALID_SID); + } TRACE("returning %s\n", ret ? "TRUE" : "FALSE"); return ret; diff --git a/reactos/dll/win32/setupapi/devinst.c b/reactos/dll/win32/setupapi/devinst.c index 94057f30cf6..a05fecb29ef 100644 --- a/reactos/dll/win32/setupapi/devinst.c +++ b/reactos/dll/win32/setupapi/devinst.c @@ -1103,7 +1103,7 @@ BOOL WINAPI SetupDiClassNameFromGuidExA( if (MachineName) MachineNameW = MultiByteToUnicode(MachineName, CP_ACP); ret = SetupDiClassNameFromGuidExW(ClassGuid, ClassNameW, MAX_CLASS_NAME_LEN, - NULL, MachineNameW, Reserved); + RequiredSize, MachineNameW, Reserved); if (ret) { int len = WideCharToMultiByte(CP_ACP, 0, ClassNameW, -1, ClassName, @@ -1113,8 +1113,6 @@ BOOL WINAPI SetupDiClassNameFromGuidExA( SetLastError(ERROR_INSUFFICIENT_BUFFER); ret = FALSE; } - else if (RequiredSize) - *RequiredSize = len; } MyFree(MachineNameW); return ret; @@ -1135,73 +1133,98 @@ BOOL WINAPI SetupDiClassNameFromGuidExW( DWORD dwLength; DWORD dwRegType; LONG rc; + PWSTR Buffer; TRACE("%s %p %lu %p %s %p\n", debugstr_guid(ClassGuid), ClassName, ClassNameSize, RequiredSize, debugstr_w(MachineName), Reserved); - hKey = SetupDiOpenClassRegKeyExW(ClassGuid, - KEY_QUERY_VALUE, - DIOCR_INSTALLER, - MachineName, - Reserved); + /* Make sure there's a GUID */ + if (ClassGuid == NULL) + { + SetLastError(ERROR_INVALID_CLASS); /* On Vista: ERROR_INVALID_USER_BUFFER */ + return FALSE; + } + + /* Make sure there's a real buffer when there's a size */ + if ((ClassNameSize > 0) && (ClassName == NULL)) + { + SetLastError(ERROR_INVALID_PARAMETER); /* On Vista: ERROR_INVALID_USER_BUFFER */ + return FALSE; + } + + /* Open the key for the GUID */ + hKey = SetupDiOpenClassRegKeyExW(ClassGuid, KEY_QUERY_VALUE, DIOCR_INSTALLER, MachineName, Reserved); + if (hKey == INVALID_HANDLE_VALUE) - { - return FALSE; - } - - if (RequiredSize != NULL) - { - dwLength = 0; - if (RegQueryValueExW(hKey, - Class, - NULL, - NULL, - NULL, - &dwLength)) - { - RegCloseKey(hKey); - return FALSE; - } - - *RequiredSize = dwLength / sizeof(WCHAR) + 1; - } - - if (!ClassGuid) - { - SetLastError(ERROR_INVALID_CLASS); - RegCloseKey(hKey); return FALSE; - } - if (!ClassName && ClassNameSize > 0) - { - SetLastError(ERROR_INVALID_PARAMETER); - RegCloseKey(hKey); - return FALSE; - } - dwLength = ClassNameSize * sizeof(WCHAR) - sizeof(UNICODE_NULL); - rc = RegQueryValueExW(hKey, - Class, - NULL, - &dwRegType, - (LPBYTE)ClassName, - &dwLength); + /* Retrieve the class name data */ + dwLength = ClassNameSize * sizeof(WCHAR); + + do + { + /* Allocate a buffer to retrieve the class name data */ + Buffer = HeapAlloc(GetProcessHeap(), 0, dwLength); + + if (Buffer == NULL) + { + rc = GetLastError(); + break; + } + + /* Query for the class name data */ + rc = RegQueryValueExW(hKey, Class, NULL, &dwRegType, (LPBYTE) Buffer, &dwLength); + + /* Clean up the buffer if needed */ + if (rc != ERROR_SUCCESS) + HeapFree(GetProcessHeap(), 0, Buffer); + } while (rc == ERROR_MORE_DATA); + + /* Close the key */ + RegCloseKey(hKey); + + /* Make sure we got the data */ if (rc != ERROR_SUCCESS) { - SetLastError(rc); - RegCloseKey(hKey); - return FALSE; - } - if (dwRegType != REG_SZ) - { - SetLastError(ERROR_GEN_FAILURE); - RegCloseKey(hKey); + SetLastError(rc); + return FALSE; + } + + /* Make sure the data is a string */ + if (dwRegType != REG_SZ) + { + HeapFree(GetProcessHeap(), 0, Buffer); + SetLastError(ERROR_GEN_FAILURE); + return FALSE; + } + + /* Determine the length of the class name */ + dwLength /= sizeof(WCHAR); + + if ((dwLength == 0) || (Buffer[dwLength - 1] != UNICODE_NULL)) + /* Count the null-terminator */ + dwLength++; + + /* Inform the caller about the class name */ + if ((ClassName != NULL) && (dwLength <= ClassNameSize)) + { + memcpy(ClassName, Buffer, (dwLength - 1) * sizeof(WCHAR)); + ClassName[dwLength - 1] = UNICODE_NULL; + } + + /* Inform the caller about the required size */ + if (RequiredSize != NULL) + *RequiredSize = dwLength; + + /* Clean up the buffer */ + HeapFree(GetProcessHeap(), 0, Buffer); + + /* Make sure the buffer was large enough */ + if ((ClassName == NULL) || (dwLength > ClassNameSize)) + { + SetLastError(ERROR_INSUFFICIENT_BUFFER); return FALSE; } - - if (ClassNameSize > 1) - ClassName[ClassNameSize] = UNICODE_NULL; - RegCloseKey(hKey); return TRUE; } From bc5452aa10a74c1cecc4c5faa4600375d766a349 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Mon, 20 Dec 2010 10:16:43 +0000 Subject: [PATCH 067/181] [CRT] Fix bugs in converted asm file. Fixes Firefox color issues. svn path=/trunk/; revision=50068 --- reactos/lib/sdk/crt/math/i386/pow_asm.s | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/reactos/lib/sdk/crt/math/i386/pow_asm.s b/reactos/lib/sdk/crt/math/i386/pow_asm.s index f418cd38c6e..ecb200b50de 100644 --- a/reactos/lib/sdk/crt/math/i386/pow_asm.s +++ b/reactos/lib/sdk/crt/math/i386/pow_asm.s @@ -117,7 +117,7 @@ _pow: /* fistpll raises invalid exception for |y| >= 1L<<63. */ fld st // y : y : x fabs // |y| : y : x - fcomp qword ptr MO(p63) // y : x + fcomp qword ptr ds:MO(p63) // y : x fnstsw ax sahf jnc L2 @@ -194,7 +194,7 @@ L7: fyl2x // log2(x) : y L8: fmul st, st(1) // y*log2(x) : y fst st(1) // y*log2(x) : y*log2(x) frndint // int(y*log2(x)) : y*log2(x) - fsubr st(1), st // int(y*log2(x)) : fract(y*log2(x)) + fsub st(1), st // int(y*log2(x)) : fract(y*log2(x)) fxch // fract(y*log2(x)) : int(y*log2(x)) f2xm1 // 2^fract(y*log2(x))-1 : int(y*log2(x)) fadd qword ptr MO(one) // 2^fract(y*log2(x)) : int(y*log2(x)) @@ -278,7 +278,7 @@ L155: cfi_adjust_cfa_offset (8) .align ALIGNARG(4) -L16:fcomp qword ptr MO(zero) +L16:fcomp qword ptr ds:MO(zero) add esp, 8 cfi_adjust_cfa_offset (-8) fnstsw ax @@ -289,7 +289,7 @@ L16:fcomp qword ptr MO(zero) cfi_adjust_cfa_offset (8) .align ALIGNARG(4) -L17: shl ecx, 30 // sign bit for y in right position +L17: shl edx, 30 // sign bit for y in right position add esp, 8 cfi_adjust_cfa_offset (-8) L18: shr edx, 31 From 6e95cdc657eb5e571a0398c719f62d7f520293e4 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Mon, 20 Dec 2010 11:48:55 +0000 Subject: [PATCH 068/181] [CRT] rename pow_asm.c to powl.c to reflect it's content. svn path=/trunk/; revision=50069 --- reactos/lib/sdk/crt/crt.rbuild | 2 +- reactos/lib/sdk/crt/math/{pow_asm.c => powl.c} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename reactos/lib/sdk/crt/math/{pow_asm.c => powl.c} (100%) diff --git a/reactos/lib/sdk/crt/crt.rbuild b/reactos/lib/sdk/crt/crt.rbuild index c6f60a7d997..d9e31fa3ab0 100644 --- a/reactos/lib/sdk/crt/crt.rbuild +++ b/reactos/lib/sdk/crt/crt.rbuild @@ -156,7 +156,7 @@ sinf.c sinh.c tanh.c - pow_asm.c + powl.c diff --git a/reactos/lib/sdk/crt/math/pow_asm.c b/reactos/lib/sdk/crt/math/powl.c similarity index 100% rename from reactos/lib/sdk/crt/math/pow_asm.c rename to reactos/lib/sdk/crt/math/powl.c From 29d4944804dbdd00b030f6c0eaea89822cf3db69 Mon Sep 17 00:00:00 2001 From: Aleksey Bragin Date: Mon, 20 Dec 2010 11:56:24 +0000 Subject: [PATCH 069/181] - Update "slightly less than all" IDLs to Wine-1.3.9. (Except for shlobj, shobjidl and shtypes.h, and DirectX stuff). svn path=/trunk/; revision=50070 --- reactos/include/psdk/control.idl | 18 - reactos/include/psdk/exdisp.idl | 71 +- reactos/include/psdk/exdispid.h | 31 +- reactos/include/psdk/mscoree.idl | 54 + reactos/include/psdk/mshtmdid.h | 80 + reactos/include/psdk/mshtml.idl | 659 +++++- reactos/include/psdk/mstask.idl | 8 + reactos/include/psdk/msxml2.idl | 613 +++++- reactos/include/psdk/msxml2did.h | 28 + reactos/include/psdk/msxml6.idl | 3421 +++++++++++++++++++++++++++++ reactos/include/psdk/msxml6did.h | 24 + reactos/include/psdk/objidl.idl | 12 + reactos/include/psdk/oledb.idl | 9 + reactos/include/psdk/propkeydef.h | 70 + reactos/include/psdk/propsys.idl | 8 + reactos/include/psdk/psdk.rbuild | 3 + reactos/include/psdk/urlmon.idl | 39 +- reactos/include/psdk/wbemcli.idl | 184 ++ reactos/include/psdk/wincodec.idl | 72 +- reactos/include/psdk/winsxs.idl | 101 + reactos/include/psdk/wuapi.idl | 990 ++++++++- 21 files changed, 6441 insertions(+), 54 deletions(-) create mode 100644 reactos/include/psdk/msxml6.idl create mode 100644 reactos/include/psdk/msxml6did.h create mode 100644 reactos/include/psdk/propkeydef.h create mode 100644 reactos/include/psdk/winsxs.idl diff --git a/reactos/include/psdk/control.idl b/reactos/include/psdk/control.idl index 84a4f88e6a9..7d1c83b92c3 100644 --- a/reactos/include/psdk/control.idl +++ b/reactos/include/psdk/control.idl @@ -244,21 +244,3 @@ interface IMediaPosition : IDispatch HRESULT CanSeekForward( [out] LONG *pCanSeekForward ); HRESULT CanSeekBackward( [out] LONG *pCanSeekBackward ); } - -/***************************************************************************** - * IDeferredCommand interface - */ -[ - object, - uuid(56a868b8-0ad4-11ce-b03a-0020af0ba770), - pointer_default(unique) -] -interface IDeferredCommand : IUnknown -{ - HRESULT Cancel( void); - HRESULT Confidence([out] LONG *pConfidence); - HRESULT Postpone([in] REFTIME newtime); - HRESULT GetHResult([out] HRESULT *phrResult); - -} - diff --git a/reactos/include/psdk/exdisp.idl b/reactos/include/psdk/exdisp.idl index 808663ee67a..54dd1df9961 100644 --- a/reactos/include/psdk/exdisp.idl +++ b/reactos/include/psdk/exdisp.idl @@ -409,7 +409,9 @@ dispinterface DWebBrowserEvents2 void SetSecureLockIcon([in] long SecureLockIcon); [id(DISPID_FILEDOWNLOAD)] - void FileDownload([in, out] VARIANT_BOOL* Cancel); + void FileDownload( + [in] VARIANT_BOOL ActiveDocument, + [in, out] VARIANT_BOOL *Cancel); [id(DISPID_NAVIGATEERROR)] void NavigateError( @@ -525,7 +527,8 @@ enum ShellWindowTypeConstants { SWC_EXPLORER = 0, SWC_BROWSER = 1, SWC_3RDPARTY = 2, - SWC_CALLBACK = 4 + SWC_CALLBACK = 4, + SWC_DESKTOP = 8 } ShellWindowTypeConstants; typedef @@ -657,11 +660,70 @@ interface IShellUIHelper : IDispatch { [out, retval] VARIANT *pvarOut); } +[ + uuid(a7fe6eda-1932-4281-b881-87b31b8bc52c), + oleautomation, + dual +] +interface IShellUIHelper2 : IShellUIHelper { + [id(DISPID_ADDSEARCHPROVIDER)] + HRESULT AddSearchProvider([in] BSTR URL); + + [id(DISPID_RUNONCESHOWN)] + HRESULT RunOnceShown(); + + [id(DISPID_SKIPRUNONCE)] + HRESULT SkipRunOnce(); + + [id(DISPID_CUSTOMIZESETTINGS)] HRESULT CustomizeSettings( + [in] VARIANT_BOOL fSQM, + [in] VARIANT_BOOL fPhishing, + [in] BSTR bstrLocale); + + [id(DISPID_SQMENABLED)] + HRESULT SqmEnabled([out, retval] VARIANT_BOOL *pfEnabled); + + [id(DISPID_PHISHINGENABLED)] + HRESULT PhishingEnabled([out, retval] VARIANT_BOOL *pfEnabled); + + [id(DISPID_BRANDIMAGEURI)] + HRESULT BrandImageUri([out, retval] BSTR *pbstrUri); + + [id(DISPID_SKIPTABSWELCOME)] + HRESULT SkipTabsWelcome(); + + [id(DISPID_DIAGNOSECONNECTION)] + HRESULT DiagnoseConnection(); + + [id(DISPID_CUSTOMIZECLEARTYPE)] + HRESULT CustomizeClearType([in] VARIANT_BOOL fSet); + + [id(DISPID_ISSEARCHPROVIDERINSTALLED)] + HRESULT IsSearchProviderInstalled( + [in] BSTR URL, + [out, retval] DWORD *pdwResult); + + [id(DISPID_ISSEARCHMIGRATED)] + HRESULT IsSearchMigrated([out, retval] VARIANT_BOOL *pfMigrated); + + [id(DISPID_DEFAULTSEARCHPROVIDER)] + HRESULT DefaultSearchProvider([out, retval] BSTR *pbstrName); + + [id(DISPID_RUNONCEREQUIREDSETTINGSCOMPLETE)] + HRESULT RunOnceRequiredSettingsComplete([in] VARIANT_BOOL fComplete); + + [id(DISPID_RUNONCEHASSHOWN)] + HRESULT RunOnceHasShown([out, retval] VARIANT_BOOL *pfShown); + + [id(DISPID_SEARCHGUIDEURL)] + HRESULT SearchGuideUrl([out, retval] BSTR *pbstrUrl); +} + [ uuid(64ab4bb7-111e-11d1-8f79-00c04fc2fbe1) ] coclass ShellUIHelper { - [default] interface IShellUIHelper; + [default] interface IShellUIHelper2; } [ @@ -789,7 +851,8 @@ interface IScriptErrorList : IDispatch { [ uuid(efd01300-160f-11d2-bb2e-00805ff7efca), - hidden + hidden, + noncreatable ] coclass CScriptErrorList { [default] interface IScriptErrorList; diff --git a/reactos/include/psdk/exdispid.h b/reactos/include/psdk/exdispid.h index 232cee610d6..012f704cacd 100644 --- a/reactos/include/psdk/exdispid.h +++ b/reactos/include/psdk/exdispid.h @@ -91,7 +91,36 @@ #define DISPID_AUTOSCAN 11 #define DISPID_AUTOCOMPLETEATTACH 12 #define DISPID_SHOWBROWSERUI 13 -#define DISPID_SHELLUIHELPERLAST 13 +#define DISPID_ADDSEARCHPROVIDER 14 +#define DISPID_RUNONCESHOWN 15 +#define DISPID_SKIPRUNONCE 16 +#define DISPID_CUSTOMIZESETTINGS 17 +#define DISPID_SQMENABLED 18 +#define DISPID_PHISHINGENABLED 19 +#define DISPID_BRANDIMAGEURI 20 +#define DISPID_SKIPTABSWELCOME 21 +#define DISPID_DIAGNOSECONNECTION 22 +#define DISPID_CUSTOMIZECLEARTYPE 23 +#define DISPID_ISSEARCHPROVIDERINSTALLED 24 +#define DISPID_ISSEARCHMIGRATED 25 +#define DISPID_DEFAULTSEARCHPROVIDER 26 +#define DISPID_RUNONCEREQUIREDSETTINGSCOMPLETE 27 +#define DISPID_RUNONCEHASSHOWN 28 +#define DISPID_SEARCHGUIDEURL 29 +#define DISPID_ADDSERVICE 30 +#define DISPID_ISSERVICEINSTALLED 31 +#define DISPID_ADDTOFAVORITESBAR 32 +#define DISPID_BUILDNEWTABPAGE 33 +#define DISPID_SETRECENTLYCLOSEDVISIBLE 34 +#define DISPID_SETACTIVITIESVISIBLE 35 +#define DISPID_CONTENTDISCOVERYRESET 36 +#define DISPID_INPRIVATEFILTERINGENABLED 37 +#define DISPID_SUGGESTEDSITESENABLED 38 +#define DISPID_ENABLESUGGESTEDSITES 39 +#define DISPID_NAVIGATETOSUGGESTEDSITES 40 +#define DISPID_SHOWTABSHELP 41 +#define DISPID_SHOWINPRIVATEHELP 42 +#define DISPID_SHELLUIHELPERLAST 43 #define DISPID_ADVANCEERROR 10 #define DISPID_RETREATERROR 11 diff --git a/reactos/include/psdk/mscoree.idl b/reactos/include/psdk/mscoree.idl index 19749fbfba3..f8698cbe729 100644 --- a/reactos/include/psdk/mscoree.idl +++ b/reactos/include/psdk/mscoree.idl @@ -36,6 +36,18 @@ cpp_quote("HRESULT WINAPI LockClrVersion(FLockClrVersionCallback,FLockClrVer typedef void* HDOMAINENUM; +typedef enum RUNTIME_INFO_FLAGS { + RUNTIME_INFO_UPGRADE_VERSION = 0x1, + RUNTIME_INFO_REQUEST_IA64 = 0x2, + RUNTIME_INFO_REQUEST_AMD64 = 0x4, + RUNTIME_INFO_REQUEST_X86 = 0x8, + RUNTIME_INFO_DONT_RETURN_DIRECTORY = 0x10, + RUNTIME_INFO_DONT_RETURN_VERSION = 0x20, + RUNTIME_INFO_DONT_SHOW_ERROR_DIALOG = 0x40 +} RUNTIME_INFO_FLAGS; + +typedef HRESULT (__stdcall *FExecuteInAppDomainCallback)([in] void* cookie); + [ uuid(F31D1788-C397-4725-87A5-6AF3472C2791), version(1.0), @@ -121,6 +133,8 @@ interface IHostControl : IUnknown [in] IUnknown* appDomainManager); } +cpp_quote("DEFINE_GUID(CLSID_CorRuntimeHost, 0xcb2f6723,0xab3a,0x11d2,0x9c,0x40,0x00,0xc0,0x4f,0xa3,0x0a,0x3e);") + [ uuid(CB2F6722-AB3A-11d2-9C40-00C04FA30A3E), version(1.0), @@ -170,3 +184,43 @@ interface ICorRuntimeHost : IUnknown HRESULT CurrentDomain([out] IUnknown** appDomain); }; + +cpp_quote("DEFINE_GUID(CLSID_CLRRuntimeHost, 0x90f1a06e,0x7712,0x4762,0x86,0xb5,0x7a,0x5e,0xba,0x6b,0xdb,0x02);") + +[ + uuid(90f1a06c-7712-4762-86b5-7a5eba6bdb02), + local, + object +] +interface ICLRRuntimeHost : IUnknown +{ + HRESULT Start(); + + HRESULT Stop(); + + HRESULT SetHostControl([in] IHostControl *pHostControl); + + HRESULT GetCLRControl([out] ICLRControl **pCLRControl); + + HRESULT UnloadAppDomain([in] DWORD dwAppDomainId, + [in] BOOL fWaitUntilDone); + + HRESULT ExecuteInAppDomain([in] DWORD dwAppDomainId, + [in] FExecuteInAppDomainCallback pCallback, + [in] void *cookie); + + HRESULT GetCurrentAppDomainId([out] DWORD *pdwAppDomainId); + + HRESULT ExecuteApplication([in] LPCWSTR pwzAppFullName, + [in] DWORD dwManifestPaths, + [in] LPCWSTR *ppwzManifestPaths, + [in] DWORD dwActivationData, + [in] LPCWSTR *ppwzActivationData, + [out] int *pReturnValue); + + HRESULT ExecuteInDefaultAppDomain([in] LPCWSTR pwzAssemblyPath, + [in] LPCWSTR pwzTypeName, + [in] LPCWSTR pwzMethodName, + [in] LPCWSTR pwzArgument, + [out] DWORD *pReturnValue); +} diff --git a/reactos/include/psdk/mshtmdid.h b/reactos/include/psdk/mshtmdid.h index e3683e9755b..1e9ab77dfeb 100644 --- a/reactos/include/psdk/mshtmdid.h +++ b/reactos/include/psdk/mshtmdid.h @@ -131,6 +131,10 @@ #define DISPID_IE8_FRAME DISPID_IE8_FRAMESITEBASE #define DISPID_IE8_IFRAME DISPID_IE8_FRAMESITEBASE +#define DISPID_IE8_OBJECTBASE (DISPID_OBJECT+30) +#define DISPID_IE8_OBJECTMAX (DISPID_STYLE-1) +#define DISPID_IE8_OBJECT DISPID_IE8_OBJECTBASE + #define DISPID_COLLECTION (DISPID_NORMAL_FIRST+500) #define DISPID_OPTIONS_COL (DISPID_NORMAL_FIRST+500) #define DISPID_IMG (DISPID_IMGBASE+1000) @@ -942,6 +946,20 @@ #define DISPID_IHTMLDOCUMENT6_IE8_GETELEMENTBYID DISPID_OMDOCUMENT+105 #define DISPID_IHTMLDOCUMENT6_UPDATESETTINGS DISPID_OMDOCUMENT+106 +/* IHTMLEmbedElement */ +#define DISPID_IHTMLEMBEDELEMENT_HIDDEN DISPID_OBJECT+10 +#define DISPID_IHTMLEMBEDELEMENT_PALETTE DISPID_OBJECT+4 +#define DISPID_IHTMLEMBEDELEMENT_PLUGINSPAGE DISPID_OBJECT+5 +#define DISPID_IHTMLEMBEDELEMENT_SRC DISPID_OBJECT+6 +#define DISPID_IHTMLEMBEDELEMENT_UNITS DISPID_OBJECT+8 +#define DISPID_IHTMLEMBEDELEMENT_NAME STDPROPID_XOBJ_NAME +#define DISPID_IHTMLEMBEDELEMENT_WIDTH STDPROPID_XOBJ_WIDTH +#define DISPID_IHTMLEMBEDELEMENT_HEIGHT STDPROPID_XOBJ_HEIGHT + +/* IHTMLEmbedElement2 */ +#define DISPID_IHTMLEMBEDELEMENT2_IE8_SRC DISPID_IE8_EMBED +#define DISPID_IHTMLEMBEDELEMENT2_IE8_PLUGINSPAGE DISPID_IE8_EMBED+1 + /* IHTMLElementCollection */ #define DISPID_IHTMLELEMENTCOLLECTION_LENGTH DISPID_COLLECTION #define DISPID_IHTMLELEMENTCOLLECTION_TOSTRING (DISPID_COLLECTION+1) @@ -2495,6 +2513,58 @@ /* IHTMLScriptElement3 */ #define DISPID_IHTMLSCRIPTELEMENT3_IE8_SRC DISPID_IE8_SCRIPT +/* IHTMLObjectElement */ +#define DISPID_IHTMLOBJECTELEMENT_OBJECT DISPID_OBJECT+1 +#define DISPID_IHTMLOBJECTELEMENT_CLASSID DISPID_OBJECT+2 +#define DISPID_IHTMLOBJECTELEMENT_DATA DISPID_OBJECT+3 +#define DISPID_IHTMLOBJECTELEMENT_RECORDSET DISPID_OBJECT+5 +#define DISPID_IHTMLOBJECTELEMENT_ALIGN STDPROPID_XOBJ_CONTROLALIGN +#define DISPID_IHTMLOBJECTELEMENT_NAME STDPROPID_XOBJ_NAME +#define DISPID_IHTMLOBJECTELEMENT_CODEBASE DISPID_OBJECT+6 +#define DISPID_IHTMLOBJECTELEMENT_CODETYPE DISPID_OBJECT+7 +#define DISPID_IHTMLOBJECTELEMENT_CODE DISPID_OBJECT+8 +#define DISPID_IHTMLOBJECTELEMENT_BASEHREF STDPROPID_XOBJ_BASEHREF +#define DISPID_IHTMLOBJECTELEMENT_TYPE DISPID_OBJECT+9 +#define DISPID_IHTMLOBJECTELEMENT_FORM DISPID_SITE+4 +#define DISPID_IHTMLOBJECTELEMENT_WIDTH STDPROPID_XOBJ_WIDTH +#define DISPID_IHTMLOBJECTELEMENT_HEIGHT STDPROPID_XOBJ_HEIGHT +#define DISPID_IHTMLOBJECTELEMENT_READYSTATE DISPID_OBJECT+10 +#define DISPID_IHTMLOBJECTELEMENT_ONREADYSTATECHANGE DISPID_EVPROP_ONREADYSTATECHANGE +#define DISPID_IHTMLOBJECTELEMENT_ONERROR DISPID_EVPROP_ONERROR +#define DISPID_IHTMLOBJECTELEMENT_ALTHTML DISPID_OBJECT+11 +#define DISPID_IHTMLOBJECTELEMENT_VSPACE DISPID_OBJECT+12 +#define DISPID_IHTMLOBJECTELEMENT_HSPACE DISPID_OBJECT+13 + +/* IHTMLObjectElement2 */ +#define DISPID_IHTMLOBJECTELEMENT2_NAMEDRECORDSET DISPID_OBJECT+14 +#define DISPID_IHTMLOBJECTELEMENT2_CLASSID DISPID_OBJECT+2 +#define DISPID_IHTMLOBJECTELEMENT2_DATA DISPID_OBJECT+3 + +/* IHTMLObjectElement3 */ +#define DISPID_IHTMLOBJECTELEMENT3_ARCHIVE DISPID_OBJECT+15 +#define DISPID_IHTMLOBJECTELEMENT3_ALT DISPID_OBJECT+16 +#define DISPID_IHTMLOBJECTELEMENT3_DECLARE DISPID_OBJECT+17 +#define DISPID_IHTMLOBJECTELEMENT3_STANDBY DISPID_OBJECT+18 +#define DISPID_IHTMLOBJECTELEMENT3_BORDER DISPID_OBJECT+19 +#define DISPID_IHTMLOBJECTELEMENT3_USEMAP DISPID_OBJECT+20 + +/* IHTMLObjectElement4 */ +#define DISPID_IHTMLOBJECTELEMENT4_CONTENTDOCUMENT DISPID_IE8_OBJECT +#define DISPID_IHTMLOBJECTELEMENT4_IE8_CODEBASE DISPID_IE8_OBJECT+1 +#define DISPID_IHTMLOBJECTELEMENT4_IE8_DATA DISPID_IE8_OBJECT+2 + +/* IHTMLParamElement */ +#define DISPID_IHTMLPARAMELEMENT_NAME DISPID_PARAM+1 +#define DISPID_IHTMLPARAMELEMENT_VALUE DISPID_PARAM+2 +#define DISPID_IHTMLPARAMELEMENT_TYPE DISPID_PARAM+3 +#define DISPID_IHTMLPARAMELEMENT_VALUETYPE DISPID_PARAM+4 + +/* IHTMLParamElement2 */ +#define DISPID_IHTMLPARAMELEMENT2_NAME DISPID_PARAM+1 +#define DISPID_IHTMLPARAMELEMENT2_TYPE DISPID_PARAM+3 +#define DISPID_IHTMLPARAMELEMENT2_VALUE DISPID_PARAM+2 +#define DISPID_IHTMLPARAMELEMENT2_IE8_VALUETYPE DISPID_IE8_PARAM + /* IHTMLFrameBase */ #define DISPID_IHTMLFRAMEBASE_SRC DISPID_FRAMESITE+0 #define DISPID_IHTMLFRAMEBASE_NAME STDPROPID_XOBJ_NAME @@ -2538,6 +2608,16 @@ #define DISPID_IHTMLIFRAMEELEMENT2_HEIGHT STDPROPID_XOBJ_HEIGHT #define DISPID_IHTMLIFRAMEELEMENT2_WIDTH STDPROPID_XOBJ_WIDTH +/* IHTMLStyleElement */ +#define DISPID_IHTMLSTYLEELEMENT_TYPE DISPID_STYLEELEMENT+2 +#define DISPID_IHTMLSTYLEELEMENT_READYSTATE DISPID_A_READYSTATE +#define DISPID_IHTMLSTYLEELEMENT_ONREADYSTATECHANGE DISPID_EVPROP_ONREADYSTATECHANGE +#define DISPID_IHTMLSTYLEELEMENT_ONLOAD DISPID_EVPROP_ONLOAD +#define DISPID_IHTMLSTYLEELEMENT_ONERROR DISPID_EVPROP_ONERROR +#define DISPID_IHTMLSTYLEELEMENT_STYLESHEET DISPID_STYLEELEMENT+4 +#define DISPID_IHTMLSTYLEELEMENT_DISABLED STDPROPID_XOBJ_DISABLED +#define DISPID_IHTMLSTYLEELEMENT_MEDIA DISPID_STYLEELEMENT+6 + /* IHTMLControlElement */ #define DISPID_IHTMLCONTROLELEMENT_TABINDEX STDPROPID_XOBJ_TABINDEX #define DISPID_IHTMLCONTROLELEMENT_FOCUS (DISPID_SITE+0) diff --git a/reactos/include/psdk/mshtml.idl b/reactos/include/psdk/mshtml.idl index 1941b923b9e..0269b66b8a9 100644 --- a/reactos/include/psdk/mshtml.idl +++ b/reactos/include/psdk/mshtml.idl @@ -6174,6 +6174,30 @@ interface IHTMLStyleSheetsCollection : IDispatch [retval, out] VARIANT *pvarResult); } +/***************************************************************************** + * DispHTMLStyleSheetsCollection dispinterface + */ +[ + hidden, + uuid(3050f547-98b5-11cf-bb82-00aa00bdce0b) +] +dispinterface DispHTMLStyleSheetsCollection +{ +properties: +methods: + [propget, id(DISPID_IHTMLSTYLESHEETSCOLLECTION_LENGTH)] + long length(); + + [propget, id(DISPID_IHTMLSTYLESHEETSCOLLECTION__NEWENUM), hidden, restricted] + IUnknown *_newEnum(); + + [id(DISPID_IHTMLSTYLESHEETSCOLLECTION_ITEM)] + VARIANT item([in] VARIANT *pvarIndex); + + [propget, id(DISPID_IHTMLDOMCONSTRUCTOR_CONSTRUCTOR), hidden] + IDispatch *constructor(); +} + /***************************************************************************** * IHTMLTxtRange interface */ @@ -9145,13 +9169,33 @@ interface IHTMLPluginsCollection : IDispatch HRESULT refresh([defaultvalue(0), in] VARIANT_BOOL reload); } +[ + hidden, + uuid(3050f54a-98b5-11cf-bb82-00aa00bdce0b) +] +dispinterface DispCPlugins +{ + properties: +methods: + [propget, id(DISPID_IHTMLPLUGINSCOLLECTION_LENGTH)] + long length(); + + [id(DISPID_IHTMLPLUGINSCOLLECTION_REFRESH)] + void refresh([defaultvalue(0), in] VARIANT_BOOL reload); + + [propget, id(DISPID_IHTMLDOMCONSTRUCTOR_CONSTRUCTOR), hidden] + IDispatch *constructor(); +} + [ noncreatable, uuid(3050f3ff-98b5-11cf-bb82-00aa00bdce0b) ] coclass CPlugins { - [default] interface IHTMLPluginsCollection; + [default] dispinterface DispCPlugins; + interface IHTMLPluginsCollection; + interface IHTMLDOMConstructor; } /***************************************************************************** @@ -13093,6 +13137,125 @@ coclass HTMLDocument interface IHTMLDOMNode2; } +/***************************************************************************** + * IHTMLEmbedElement interface + */ +[ + odl, + oleautomation, + dual, + uuid(3050f25f-98b5-11cf-bb82-00aa00bdce0b) +] +interface IHTMLEmbedElement : IDispatch +{ + [propput, id(DISPID_IHTMLEMBEDELEMENT_HIDDEN)] + HRESULT hidden([in] BSTR v); + + [propget, id(DISPID_IHTMLEMBEDELEMENT_HIDDEN)] + HRESULT hidden([retval, out] BSTR *p); + + [propget, id(DISPID_IHTMLEMBEDELEMENT_PALETTE)] + HRESULT palette([retval, out] BSTR *p); + + [propget, id(DISPID_IHTMLEMBEDELEMENT_PLUGINSPAGE)] + HRESULT pluginspage([retval, out] BSTR *p); + + [propput, id(DISPID_IHTMLEMBEDELEMENT_SRC)] + HRESULT src([in] BSTR v); + + [propget, id(DISPID_IHTMLEMBEDELEMENT_SRC)] + HRESULT src([retval, out] BSTR *p); + + [propput, id(DISPID_IHTMLEMBEDELEMENT_UNITS)] + HRESULT units([in] BSTR v); + + [propget, id(DISPID_IHTMLEMBEDELEMENT_UNITS)] + HRESULT units([retval, out] BSTR *p); + + [propput, id(DISPID_IHTMLEMBEDELEMENT_NAME), displaybind, bindable] + HRESULT name([in] BSTR v); + + [propget, id(DISPID_IHTMLEMBEDELEMENT_NAME), displaybind, bindable] + HRESULT name([retval, out] BSTR *p); + + [propput, id(DISPID_IHTMLEMBEDELEMENT_WIDTH)] + HRESULT width([in] VARIANT v); + + [propget, id(DISPID_IHTMLEMBEDELEMENT_WIDTH)] + HRESULT width([retval, out] VARIANT *p); + + [propput, id(DISPID_IHTMLEMBEDELEMENT_HEIGHT)] + HRESULT height([in] VARIANT v); + + [propget, id(DISPID_IHTMLEMBEDELEMENT_HEIGHT)] + HRESULT height([retval, out] VARIANT *p); +} + +/***************************************************************************** + * DispHTMLEmbedElement dispinterface + */ +[ + hidden, + uuid(3050f52e-98b5-11cf-bb82-00aa00bdce0b) +] +dispinterface DispHTMLEmbed +{ +properties: +methods: + WINE_HTMLELEMENT_DISPINTERFACE_DECL; + + [propput, id(DISPID_IHTMLEMBEDELEMENT_HIDDEN)] + void hidden(BSTR v); + + [propget, id(DISPID_IHTMLEMBEDELEMENT_HIDDEN)] + BSTR hidden(); + + [propget, id(DISPID_IHTMLEMBEDELEMENT_PALETTE)] + BSTR palette(); + + [propget, id(DISPID_IHTMLEMBEDELEMENT_PLUGINSPAGE)] + BSTR pluginspage(); + + [propput, id(DISPID_IHTMLEMBEDELEMENT_SRC)] + void src(BSTR v); + + [propget, id(DISPID_IHTMLEMBEDELEMENT_SRC)] + BSTR src(); + + [propput, id(DISPID_IHTMLEMBEDELEMENT_UNITS)] + void units(BSTR v); + + [propget, id(DISPID_IHTMLEMBEDELEMENT_UNITS)] + BSTR units(); + + [propput, id(DISPID_IHTMLEMBEDELEMENT_NAME), displaybind, bindable] + void name(BSTR v); + + [propget, id(DISPID_IHTMLEMBEDELEMENT_NAME), displaybind, bindable] + BSTR name(); + + [propput, id(DISPID_IHTMLEMBEDELEMENT_WIDTH)] + void width(VARIANT v); + + [propget, id(DISPID_IHTMLEMBEDELEMENT_WIDTH)] + VARIANT width(); + + [propput, id(DISPID_IHTMLEMBEDELEMENT_HEIGHT)] + void height(VARIANT v); + + [propget, id(DISPID_IHTMLEMBEDELEMENT_HEIGHT)] + VARIANT height(); + + [propput, id(DISPID_IHTMLEMBEDELEMENT2_IE8_SRC)] + void ie8_src(BSTR v); + + [propget, id(DISPID_IHTMLEMBEDELEMENT2_IE8_SRC)] + BSTR ie8_src(); + + [propget, id(DISPID_IHTMLEMBEDELEMENT2_IE8_PLUGINSPAGE)] + BSTR ie8_pluginspage(); +} + /***************************************************************************** * IHTMLCommentElement interface */ @@ -14780,6 +14943,405 @@ methods: BSTR ie8_src(); } +/***************************************************************************** + * IHTMLObjectElement interface + */ +[ + odl, + oleautomation, + dual, + uuid(3050f24f-98b5-11cf-bb82-00aa00bdce0b) +] +interface IHTMLObjectElement : IDispatch +{ + [propget, id(DISPID_IHTMLOBJECTELEMENT_OBJECT), hidden] + HRESULT object([retval, out] IDispatch **p); + + [propget, id(DISPID_IHTMLOBJECTELEMENT_CLASSID), hidden] + HRESULT classid([retval, out] BSTR *p); + + [propget, id(DISPID_IHTMLOBJECTELEMENT_DATA), hidden] + HRESULT data([retval, out] BSTR *p); + + [propputref, id(DISPID_IHTMLOBJECTELEMENT_RECORDSET), hidden] + HRESULT recordset([in] IDispatch *v); + + [propget, id(DISPID_IHTMLOBJECTELEMENT_RECORDSET), hidden] + HRESULT recordset([retval, out] IDispatch **p); + + [propput, id(DISPID_IHTMLOBJECTELEMENT_ALIGN), displaybind, bindable] + HRESULT align([in] BSTR v); + + [propget, id(DISPID_IHTMLOBJECTELEMENT_ALIGN), displaybind, bindable] + HRESULT align([retval, out] BSTR *p); + + [propput, id(DISPID_IHTMLOBJECTELEMENT_NAME), displaybind, bindable] + HRESULT name([in] BSTR v); + + [propget, id(DISPID_IHTMLOBJECTELEMENT_NAME), displaybind, bindable] + HRESULT name([retval, out] BSTR *p); + + [propput, id(DISPID_IHTMLOBJECTELEMENT_CODEBASE), displaybind, bindable] + HRESULT codeBase([in] BSTR v); + + [propget, id(DISPID_IHTMLOBJECTELEMENT_CODEBASE), displaybind, bindable] + HRESULT codeBase([retval, out] BSTR *p); + + [propput, id(DISPID_IHTMLOBJECTELEMENT_CODETYPE), displaybind, bindable] + HRESULT codeType([in] BSTR v); + + [propget, id(DISPID_IHTMLOBJECTELEMENT_CODETYPE), displaybind, bindable] + HRESULT codeType([retval, out] BSTR *p); + + [propput, id(DISPID_IHTMLOBJECTELEMENT_CODE), displaybind, bindable] + HRESULT code([in] BSTR v); + + [propget, id(DISPID_IHTMLOBJECTELEMENT_CODE), displaybind, bindable] + HRESULT code([retval, out] BSTR *p); + + [propget, id(DISPID_IHTMLOBJECTELEMENT_BASEHREF)] + HRESULT BaseHref([retval, out] BSTR *p); + + [propput, id(DISPID_IHTMLOBJECTELEMENT_TYPE), displaybind, bindable] + HRESULT type([in] BSTR v); + + [propget, id(DISPID_IHTMLOBJECTELEMENT_TYPE), displaybind, bindable] + HRESULT type([retval, out] BSTR *p); + + [propget, id(DISPID_IHTMLOBJECTELEMENT_FORM)] + HRESULT form([retval, out] IHTMLFormElement **p); + + [propput, id(DISPID_IHTMLOBJECTELEMENT_WIDTH)] + HRESULT width([in] VARIANT v); + + [propget, id(DISPID_IHTMLOBJECTELEMENT_WIDTH)] + HRESULT width([retval, out] VARIANT *p); + + [propput, id(DISPID_IHTMLOBJECTELEMENT_HEIGHT)] + HRESULT height([in] VARIANT v); + + [propget, id(DISPID_IHTMLOBJECTELEMENT_HEIGHT)] + HRESULT height([retval, out] VARIANT *p); + + [propget, id(DISPID_IHTMLOBJECTELEMENT_READYSTATE), hidden] + HRESULT readyState([retval, out] long *p); + + [propput, id(DISPID_IHTMLOBJECTELEMENT_ONREADYSTATECHANGE), displaybind, bindable] + HRESULT onreadystatechange([in] VARIANT v); + + [propget, id(DISPID_IHTMLOBJECTELEMENT_ONREADYSTATECHANGE), displaybind, bindable] + HRESULT onreadystatechange([retval, out] VARIANT *p); + + [propput, id(DISPID_IHTMLOBJECTELEMENT_ONERROR), displaybind, bindable] + HRESULT onerror([in] VARIANT v); + + [propget, id(DISPID_IHTMLOBJECTELEMENT_ONERROR), displaybind, bindable] + HRESULT onerror([retval, out] VARIANT *p); + + [propput, id(DISPID_IHTMLOBJECTELEMENT_ALTHTML)] + HRESULT altHtml([in] BSTR v); + + [propget, id(DISPID_IHTMLOBJECTELEMENT_ALTHTML)] + HRESULT altHtml([retval, out] BSTR *p); + + [propput, id(DISPID_IHTMLOBJECTELEMENT_VSPACE)] + HRESULT vspace([in] long v); + + [propget, id(DISPID_IHTMLOBJECTELEMENT_VSPACE)] + HRESULT vspace([retval, out] long *p); + + [propput, id(DISPID_IHTMLOBJECTELEMENT_HSPACE)] + HRESULT hspace([in] long v); + + [propget, id(DISPID_IHTMLOBJECTELEMENT_HSPACE)] + HRESULT hspace([retval, out] long *p); +} + +/***************************************************************************** + * IHTMLParamElement interface + */ +[ + odl, + oleautomation, + dual, + uuid(3050f83d-98b5-11cf-bb82-00aa00bdce0b) +] +interface IHTMLParamElement : IDispatch +{ + [propput, id(DISPID_IHTMLPARAMELEMENT_NAME), displaybind, bindable] + HRESULT name([in] BSTR v); + + [propget, id(DISPID_IHTMLPARAMELEMENT_NAME), displaybind, bindable] + HRESULT name([retval, out] BSTR *p); + + [propput, id(DISPID_IHTMLPARAMELEMENT_VALUE), displaybind, bindable] + HRESULT value([in] BSTR v); + + [propget, id(DISPID_IHTMLPARAMELEMENT_VALUE), displaybind, bindable] + HRESULT value([retval, out] BSTR *p); + + [propput, id(DISPID_IHTMLPARAMELEMENT_TYPE), displaybind, bindable] + HRESULT type([in] BSTR v); + + [propget, id(DISPID_IHTMLPARAMELEMENT_TYPE), displaybind, bindable] + HRESULT type([retval, out] BSTR *p); + + [propput, id(DISPID_IHTMLPARAMELEMENT_VALUETYPE), displaybind, bindable] + HRESULT valueType([in] BSTR v); + + [propget, id(DISPID_IHTMLPARAMELEMENT_VALUETYPE), displaybind, bindable] + HRESULT valueType([retval, out] BSTR *p); +} + +/***************************************************************************** + * IHTMLParamElement2 interface + */ +[ + odl, + oleautomation, + dual, + uuid(30510444-98b5-11cf-bb82-00aa00bdce0b) +] +interface IHTMLParamElement2 : IDispatch +{ + [propput, id(DISPID_IHTMLPARAMELEMENT2_NAME), displaybind, bindable] + HRESULT name([in] BSTR v); + + [propget, id(DISPID_IHTMLPARAMELEMENT2_NAME), displaybind, bindable] + HRESULT name([retval, out] BSTR *p); + + [propput, id(DISPID_IHTMLPARAMELEMENT2_TYPE), displaybind, bindable] + HRESULT type([in] BSTR v); + + [propget, id(DISPID_IHTMLPARAMELEMENT2_TYPE), displaybind, bindable] + HRESULT type([retval, out] BSTR *p); + + [propput, id(DISPID_IHTMLPARAMELEMENT2_VALUE), displaybind, bindable] + HRESULT value([in] BSTR v); + + [propget, id(DISPID_IHTMLPARAMELEMENT2_VALUE), displaybind, bindable] + HRESULT value([retval, out] BSTR *p); + + [propput, id(DISPID_IHTMLPARAMELEMENT2_IE8_VALUETYPE)] + HRESULT valueType([in] BSTR v); + + [propget, id(DISPID_IHTMLPARAMELEMENT2_IE8_VALUETYPE)] + HRESULT valueType([retval, out] BSTR *p); +} + +/***************************************************************************** + * DispHTMLObjectElement dispinterface + */ +[ + hidden, + uuid(3050f529-98b5-11cf-bb82-00aa00bdce0b) +] +dispinterface DispHTMLObjectElement +{ +properties: +methods: + WINE_HTMLELEMENT_DISPINTERFACE_DECL; + + [propget, id(DISPID_IHTMLOBJECTELEMENT_OBJECT), hidden] + IDispatch *object(); + + [propputref, id(DISPID_IHTMLOBJECTELEMENT_RECORDSET), hidden] + void recordset(IDispatch *v); + + [propget, id(DISPID_IHTMLOBJECTELEMENT_RECORDSET), hidden] + IDispatch *recordset(); + + [propput, id(DISPID_IHTMLOBJECTELEMENT_ALIGN), displaybind, bindable] + void align(BSTR v); + + [propget, id(DISPID_IHTMLOBJECTELEMENT_ALIGN), displaybind, bindable] + BSTR align(); + + [propput, id(DISPID_IHTMLOBJECTELEMENT_NAME), displaybind, bindable] + void name(BSTR v); + + [propget, id(DISPID_IHTMLOBJECTELEMENT_NAME), displaybind, bindable] + BSTR name(); + + [propput, id(DISPID_IHTMLOBJECTELEMENT_CODEBASE), displaybind, bindable] + void codeBase(BSTR v); + + [propget, id(DISPID_IHTMLOBJECTELEMENT_CODEBASE), displaybind, bindable] + BSTR codeBase(); + + [propput, id(DISPID_IHTMLOBJECTELEMENT_CODETYPE), displaybind, bindable] + void codeType(BSTR v); + + [propget, id(DISPID_IHTMLOBJECTELEMENT_CODETYPE), displaybind, bindable] + BSTR codeType(); + + [propput, id(DISPID_IHTMLOBJECTELEMENT_CODE), displaybind, bindable] + void code(BSTR v); + + [propget, id(DISPID_IHTMLOBJECTELEMENT_CODE), displaybind, bindable] + BSTR code(); + + [propget, id(DISPID_IHTMLOBJECTELEMENT_BASEHREF)] + BSTR BaseHref(); + + [propput, id(DISPID_IHTMLOBJECTELEMENT_TYPE), displaybind, bindable] + void type(BSTR v); + + [propget, id(DISPID_IHTMLOBJECTELEMENT_TYPE), displaybind, bindable] + BSTR type(); + + [propget, id(DISPID_IHTMLOBJECTELEMENT_FORM)] + IHTMLFormElement *form(); + + [propput, id(DISPID_IHTMLOBJECTELEMENT_WIDTH)] + void width(VARIANT v); + + [propget, id(DISPID_IHTMLOBJECTELEMENT_WIDTH)] + VARIANT width(); + + [propput, id(DISPID_IHTMLOBJECTELEMENT_HEIGHT)] + void height(VARIANT v); + + [propget, id(DISPID_IHTMLOBJECTELEMENT_HEIGHT)] + VARIANT height(); + + [propput, id(DISPID_IHTMLOBJECTELEMENT_ONERROR), displaybind, bindable] + void onerror(VARIANT v); + + [propget, id(DISPID_IHTMLOBJECTELEMENT_ONERROR), displaybind, bindable] + VARIANT onerror(); + + [propput, id(DISPID_IHTMLOBJECTELEMENT_ALTHTML)] + void altHtml(BSTR v); + + [propget, id(DISPID_IHTMLOBJECTELEMENT_ALTHTML)] + BSTR altHtml(); + + [propput, id(DISPID_IHTMLOBJECTELEMENT_VSPACE)] + void vspace(long v); + + [propget, id(DISPID_IHTMLOBJECTELEMENT_VSPACE)] + long vspace(); + + [propput, id(DISPID_IHTMLOBJECTELEMENT_HSPACE)] + void hspace(long v); + + [propget, id(DISPID_IHTMLOBJECTELEMENT_HSPACE)] + long hspace(); + + [id(DISPID_IHTMLOBJECTELEMENT2_NAMEDRECORDSET)] + IDispatch *namedRecordset( + [in] BSTR dataMember, + [optional, in] VARIANT *hierarchy); + + [propput, id(DISPID_IHTMLOBJECTELEMENT2_CLASSID), hidden] + void classid(BSTR v); + + [propget, id(DISPID_IHTMLOBJECTELEMENT2_CLASSID), hidden] + BSTR classid(); + + [propput, id(DISPID_IHTMLOBJECTELEMENT2_DATA), hidden] + void data(BSTR v); + + [propget, id(DISPID_IHTMLOBJECTELEMENT2_DATA), hidden] + BSTR data(); + + [propput, id(DISPID_IHTMLOBJECTELEMENT3_ARCHIVE), displaybind, bindable] + void archive(BSTR v); + + [propget, id(DISPID_IHTMLOBJECTELEMENT3_ARCHIVE), displaybind, bindable] + BSTR archive(); + + [propput, id(DISPID_IHTMLOBJECTELEMENT3_ALT), displaybind, bindable] + void alt(BSTR v); + + [propget, id(DISPID_IHTMLOBJECTELEMENT3_ALT), displaybind, bindable] + BSTR alt(); + + [propput, id(DISPID_IHTMLOBJECTELEMENT3_DECLARE), displaybind, bindable] + void declare(VARIANT_BOOL v); + + [propget, id(DISPID_IHTMLOBJECTELEMENT3_DECLARE), displaybind, bindable] + VARIANT_BOOL declare(); + + [propput, id(DISPID_IHTMLOBJECTELEMENT3_STANDBY), displaybind, bindable] + void standby(BSTR v); + + [propget, id(DISPID_IHTMLOBJECTELEMENT3_STANDBY), displaybind, bindable] + BSTR standby(); + + [propput, id(DISPID_IHTMLOBJECTELEMENT3_BORDER)] + void border(VARIANT v); + + [propget, id(DISPID_IHTMLOBJECTELEMENT3_BORDER)] + VARIANT border(); + + [propput, id(DISPID_IHTMLOBJECTELEMENT3_USEMAP), displaybind, bindable] + void useMap(BSTR v); + + [propget, id(DISPID_IHTMLOBJECTELEMENT3_USEMAP), displaybind, bindable] + BSTR useMap(); + + [propget, id(DISPID_IHTMLOBJECTELEMENT4_CONTENTDOCUMENT)] + IDispatch *contentDocument(); + + [propput, id(DISPID_IHTMLOBJECTELEMENT4_IE8_CODEBASE)] + void ie8_codeBase(BSTR v); + + [propget, id(DISPID_IHTMLOBJECTELEMENT4_IE8_CODEBASE)] + BSTR ie8_codeBase(); + + [propput, id(DISPID_IHTMLOBJECTELEMENT4_IE8_DATA)] + void ie8_data(BSTR v); + + [propget, id(DISPID_IHTMLOBJECTELEMENT4_IE8_DATA)] + BSTR ie8_data(); +} + +/***************************************************************************** + * DispHTMLParamElement dispinterface + */ +[ + hidden, + uuid(3050f590-98b5-11cf-bb82-00aa00bdce0b) +] +dispinterface DispHTMLParamElement +{ +properties: +methods: + WINE_HTMLELEMENT_DISPINTERFACE_DECL; + + [propput, id(DISPID_IHTMLPARAMELEMENT_NAME), displaybind, bindable] + void name(BSTR v); + + [propget, id(DISPID_IHTMLPARAMELEMENT_NAME), displaybind, bindable] + BSTR name(); + + [propput, id(DISPID_IHTMLPARAMELEMENT_VALUE), displaybind, bindable] + void value(BSTR v); + + [propget, id(DISPID_IHTMLPARAMELEMENT_VALUE), displaybind, bindable] + BSTR value(); + + [propput, id(DISPID_IHTMLPARAMELEMENT_TYPE), displaybind, bindable] + void type(BSTR v); + + [propget, id(DISPID_IHTMLPARAMELEMENT_TYPE), displaybind, bindable] + BSTR type(); + + [propput, id(DISPID_IHTMLPARAMELEMENT_VALUETYPE), displaybind, bindable] + void valueType(BSTR v); + + [propget, id(DISPID_IHTMLPARAMELEMENT_VALUETYPE), displaybind, bindable] + BSTR valueType(); + + [propput, id(DISPID_IHTMLPARAMELEMENT2_IE8_VALUETYPE)] + void ie8_valueType(BSTR v); + + [propget, id(DISPID_IHTMLPARAMELEMENT2_IE8_VALUETYPE)] + BSTR ie8_valueType(); +} + /***************************************************************************** * IHTMLFrameBase interface */ @@ -15127,6 +15689,101 @@ methods: VARIANT width(); } +/***************************************************************************** + * IHTMLStyleElement interface + */ +[ + odl, + oleautomation, + dual, + uuid(3050f375-98b5-11cf-bb82-00aa00bdce0b) +] +interface IHTMLStyleElement : IDispatch +{ + [propput, id(DISPID_IHTMLSTYLEELEMENT_TYPE), displaybind, bindable] + HRESULT type([in] BSTR v); + + [propget, id(DISPID_IHTMLSTYLEELEMENT_TYPE), displaybind, bindable] + HRESULT type([retval, out] BSTR *p); + + [propget, id(DISPID_IHTMLSTYLEELEMENT_READYSTATE)] + HRESULT readyState([retval, out] BSTR *p); + + [propput, id(DISPID_IHTMLSTYLEELEMENT_ONREADYSTATECHANGE), displaybind, bindable] + HRESULT onreadystatechange([in] VARIANT v); + + [propget, id(DISPID_IHTMLSTYLEELEMENT_ONREADYSTATECHANGE), displaybind, bindable] + HRESULT onreadystatechange([retval, out] VARIANT *p); + + [propput, id(DISPID_IHTMLSTYLEELEMENT_ONLOAD), displaybind, bindable] + HRESULT onload([in] VARIANT v); + + [propget, id(DISPID_IHTMLSTYLEELEMENT_ONLOAD), displaybind, bindable] + HRESULT onload([retval, out] VARIANT *p); + + [propput, id(DISPID_IHTMLSTYLEELEMENT_ONERROR), displaybind, bindable] + HRESULT onerror([in] VARIANT v); + + [propget, id(DISPID_IHTMLSTYLEELEMENT_ONERROR), displaybind, bindable] + HRESULT onerror([retval, out] VARIANT *p); + + [propget, id(DISPID_IHTMLSTYLEELEMENT_STYLESHEET)] + HRESULT styleSheet([retval, out] IHTMLStyleSheet **p); + + [propput, id(DISPID_IHTMLSTYLEELEMENT_DISABLED), displaybind, bindable] + HRESULT disabled([in] VARIANT_BOOL v); + + [propget, id(DISPID_IHTMLSTYLEELEMENT_DISABLED), displaybind, bindable] + HRESULT disabled([retval, out] VARIANT_BOOL *p); + + [propput, id(DISPID_IHTMLSTYLEELEMENT_MEDIA), displaybind, bindable] + HRESULT media([in] BSTR v); + + [propget, id(DISPID_IHTMLSTYLEELEMENT_MEDIA), displaybind, bindable] + HRESULT media([retval, out] BSTR *p); +} + +/***************************************************************************** + * DispHTMLStyleElement dispinterface + */ +[ + hidden, + uuid(3050f511-98b5-11cf-bb82-00aa00bdce0b) +] +dispinterface DispHTMLStyleElement +{ +properties: +methods: + WINE_HTMLELEMENT_DISPINTERFACE_DECL; + + [propput, id(DISPID_IHTMLSTYLEELEMENT_TYPE), displaybind, bindable] + void type(BSTR v); + + [propget, id(DISPID_IHTMLSTYLEELEMENT_TYPE), displaybind, bindable] + BSTR type(); + + [propput, id(DISPID_IHTMLSTYLEELEMENT_ONLOAD), displaybind, bindable] + void onload(VARIANT v); + + [propget, id(DISPID_IHTMLSTYLEELEMENT_ONLOAD), displaybind, bindable] + VARIANT onload(); + + [propput, id(DISPID_IHTMLSTYLEELEMENT_ONERROR), displaybind, bindable] + void onerror(VARIANT v); + + [propget, id(DISPID_IHTMLSTYLEELEMENT_ONERROR), displaybind, bindable] + VARIANT onerror(); + + [propget, id(DISPID_IHTMLSTYLEELEMENT_STYLESHEET)] + IHTMLStyleSheet *styleSheet(); + + [propput, id(DISPID_IHTMLSTYLEELEMENT_MEDIA), displaybind, bindable] + void media(BSTR v); + + [propget, id(DISPID_IHTMLSTYLEELEMENT_MEDIA), displaybind, bindable] + BSTR media(); +} + /***************************************************************************** * IMarkupContainer interface */ diff --git a/reactos/include/psdk/mstask.idl b/reactos/include/psdk/mstask.idl index cc70cce5eec..ecff641e23a 100644 --- a/reactos/include/psdk/mstask.idl +++ b/reactos/include/psdk/mstask.idl @@ -22,6 +22,12 @@ import "oaidl.idl"; import "oleidl.idl"; +#ifndef __WIDL__ +#define threading(model) +#define progid(str) +#define vi_progid(str) +#endif + cpp_quote("#define TASK_SUNDAY 0x1") cpp_quote("#define TASK_MONDAY 0x2") cpp_quote("#define TASK_TUESDAY 0x4") @@ -368,6 +374,7 @@ interface ITaskScheduler : IUnknown } [ + threading(both), uuid(148BD52A-A2AB-11CE-B11F-00AA00530503) ] coclass CTaskScheduler @@ -377,6 +384,7 @@ coclass CTaskScheduler [ + threading(both), uuid(148BD520-A2AB-11CE-B11F-00AA00530503) ] coclass CTask diff --git a/reactos/include/psdk/msxml2.idl b/reactos/include/psdk/msxml2.idl index 444ebe8d678..d91ba4761a7 100644 --- a/reactos/include/psdk/msxml2.idl +++ b/reactos/include/psdk/msxml2.idl @@ -1,6 +1,7 @@ /* * Copyright (C) 2005 Vijay Kiran Kamuju * Copyright (C) 2008 Alistair Leslie-Hughes + * Copyright (C) 2010 Nikolay Sivov for CodeWeavers * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -18,7 +19,7 @@ */ #include -#include +#include import "unknwn.idl"; import "objidl.idl"; @@ -54,6 +55,7 @@ interface IXMLDOMNotation; interface IXMLDOMEntity; interface IXMLDOMEntityReference; interface IXMLDOMParseError; +interface IXMLDOMParseErrorCollection; interface IXTLRuntime; interface IXSLTemplate; interface IXSLProcessor; @@ -631,6 +633,27 @@ interface IXMLDOMDocument2 : IXMLDOMDocument [retval, out] VARIANT *var); } +[ + local, + object, + dual, + uuid(2933bf96-7b36-11d2-b20e-00c04f983e60), + oleautomation, +] +interface IXMLDOMDocument3 : IXMLDOMDocument2 +{ + [id(DISPID_XMLDOM_DOCUMENT3_VALIDATENODE)] + HRESULT validateNode( + [in] IXMLDOMNode *node, + [out, retval] IXMLDOMParseError **error); + + [id(DISPID_XMLDOM_DOCUMENT3_IMPORTNODE)] + HRESULT importNode( + [in] IXMLDOMNode *node, + [in] VARIANT_BOOL deep, + [out, retval] IXMLDOMNode **clone); +} + [ local, object, @@ -1235,6 +1258,74 @@ interface IXMLHTTPRequest : IDispatch HRESULT onreadystatechange([in] IDispatch *pReadyStateSink); }; +[ +object, +dual, +oleautomation, +uuid(2e9196bf-13ba-4dd4-91ca-6c571f281495) +] +interface IServerXMLHTTPRequest : IXMLHTTPRequest +{ + typedef enum _SERVERXMLHTTP_OPTION + { + SXH_OPTION_URL = -1, + SXH_OPTION_URL_CODEPAGE, + SXH_OPTION_ESCAPE_PERCENT_IN_URL, + SXH_OPTION_IGNORE_SERVER_SSL_CERT_ERROR_FLAGS, + SXH_OPTION_SELECT_CLIENT_SSL_CERT + } SERVERXMLHTTP_OPTION; + + [id(15)] + HRESULT setTimeouts( + [in] long resolveTimeout, + [in] long connectTimeout, + [in] long sendTimeout, + [in] long receiveTimeout); + + [id(16)] + HRESULT waitForResponse( + [in, optional] VARIANT timeoutInSeconds, + [out, retval] VARIANT_BOOL * isSuccessful); + + [id(17)] + HRESULT getOption( + [in] SERVERXMLHTTP_OPTION option, + [out, retval] VARIANT * value); + + [id(18)] + HRESULT setOption( + [in] SERVERXMLHTTP_OPTION option, + [in] VARIANT value); +} + +[ +object, +dual, +oleautomation, +uuid(2e01311b-c322-4b0a-bd77-b90cfdc8dce7) +] +interface IServerXMLHTTPRequest2 : IServerXMLHTTPRequest +{ + typedef enum _SXH_PROXY_SETTING + { + SXH_PROXY_SET_DEFAULT = 0, + SXH_PROXY_SET_PRECONFIG = 0, + SXH_PROXY_SET_DIRECT, + SXH_PROXY_SET_PROXY + } SXH_PROXY_SETTING; + + [id(19)] + HRESULT setProxy( + [in] SXH_PROXY_SETTING proxySetting, + [in, optional] VARIANT varProxyServer, + [in, optional] VARIANT varBypassList); + + [id(20)] + HRESULT setProxyCredentials( + [in] BSTR bstrUserName, + [in] BSTR bstrPassword); +} + [ local, object, @@ -1266,6 +1357,57 @@ interface IXMLDOMParseError : IDispatch HRESULT filepos([retval, out] LONG * filePos); } +[ +local, +object, +dual, +oleautomation, +uuid (3efaa428-272f-11d2-836f-0000f87a7782) +] +interface IXMLDOMParseError2 : IXMLDOMParseError +{ + [propget, id(DISPID_DOM_ERROR2_ERRORXPATH)] + HRESULT errorXPath([retval, out] BSTR *xpathexpr); + + [propget, id(DISPID_DOM_ERROR2_ALLERRORS)] + HRESULT allErrors([retval, out] IXMLDOMParseErrorCollection **allErrors); + + [id(DISPID_DOM_ERROR2_ERRORPARAMETERS)] + HRESULT errorParameters( + [in] long index, + [retval, out] BSTR *param); + + [propget, id(DISPID_DOM_ERROR2_ERRORPARAMETERSCOUNT)] + HRESULT errorParametersCount([retval, out] long *count); +} + +[ +local, +object, +dual, +oleautomation, +uuid (3efaa429-272f-11d2-836f-0000f87a7782) +] +interface IXMLDOMParseErrorCollection : IDispatch +{ + [propget, id(DISPID_VALUE)] + HRESULT item( + [in] long index, + [retval, out] IXMLDOMParseError2 **error); + + [propget, id(DISPID_DOM_ERRORCOLLECTION_LENGTH)] + HRESULT length( [retval, out] long *length); + + [propget, id(DISPID_DOM_ERRORCOLLECTION_NEXT)] + HRESULT next( [retval, out] IXMLDOMParseError2 **error); + + [id(DISPID_DOM_ERRORCOLLECTION_RESET)] + HRESULT reset(); + + [propget, hidden, restricted, id(DISPID_NEWENUM)] + HRESULT _newEnum( [retval, out] IUnknown **ppunk); +} + [ uuid(F6D90F11-9C73-11D3-B32E-00C04F990BB4) ] @@ -1302,6 +1444,15 @@ coclass DOMDocument40 [default, source] dispinterface XMLDOMDocumentEvents; } +[ + uuid(88d96a05-f192-11d4-a65f-0040963251e5) +] +coclass DOMDocument60 +{ + [default] interface IXMLDOMDocument3; + [default, source] dispinterface XMLDOMDocumentEvents; +} + [ uuid(F6D90F12-9C73-11D3-B32E-00C04F990BB4) ] @@ -1330,13 +1481,94 @@ coclass FreeThreadedDOMDocument30 } [ - uuid(88d969c1-f192-11d4-a65f-0040963251e5), + uuid(88d969c1-f192-11d4-a65f-0040963251e5) ] coclass FreeThreadedDOMDocument40 { [default] interface IXMLDOMDocument2; [default, source] dispinterface XMLDOMDocumentEvents; -}; +} + +[ + uuid(88d96a06-f192-11d4-a65f-0040963251e5), +] +coclass FreeThreadedDOMDocument60 +{ + [default] interface IXMLDOMDocument3; + [default, source] dispinterface XMLDOMDocumentEvents; +} + +[ + uuid(f6d90f16-9c73-11d3-b32e-00c04f990bb4) +] +coclass XMLHTTP +{ + [default] interface IXMLHTTPRequest; +} + +[ + uuid(f5078f1e-c551-11d3-89b9-0000f81fe221) +] +coclass XMLHTTP26 +{ + [default] interface IXMLHTTPRequest; +} + +[ + uuid(f5078f35-c551-11d3-89b9-0000f81fe221) +] +coclass XMLHTTP30 +{ + [default] interface IXMLHTTPRequest; +} + +[ + uuid(88d969c5-f192-11d4-a65f-0040963251e5) +] +coclass XMLHTTP40 +{ + [default] interface IXMLHTTPRequest; +} + +[ + uuid(88d96a0a-f192-11d4-a65f-0040963251e5) +] +coclass XMLHTTP60 +{ + [default] interface IXMLHTTPRequest; +} + +[ + uuid(afba6b42-5692-48ea-8141-dc517dcf0ef1) +] +coclass ServerXMLHTTP +{ + [default] interface IServerXMLHTTPRequest; +} + +[ + uuid(afb40ffd-b609-40a3-9828-f88bbe11e4e3) +] +coclass ServerXMLHTTP30 +{ + [default] interface IServerXMLHTTPRequest; +} + +[ + uuid(88d969c6-f192-11d4-a65f-0040963251e5) +] +coclass ServerXMLHTTP40 +{ + [default] interface IServerXMLHTTPRequest2; +} + +[ + uuid(88d96a0b-f192-11d4-a65f-0040963251e5) +] +coclass ServerXMLHTTP60 +{ + [default] interface IServerXMLHTTPRequest2; +} [ uuid(373984c9-b845-449b-91e7-45ac83036ade) @@ -1368,7 +1600,15 @@ coclass XMLSchemaCache30 coclass XMLSchemaCache40 { [default] interface IXMLDOMSchemaCollection2; -}; +} + +[ + uuid(88d96a07-f192-11d4-a65f-0040963251e5) +] +coclass XMLSchemaCache60 +{ + [default] interface IXMLDOMSchemaCollection2; +} [ uuid(2933BF94-7B36-11d2-B20E-00C04F983E60) @@ -1394,6 +1634,22 @@ coclass XSLTemplate30 [default] interface IXSLTemplate; } +[ + uuid(88d969c3-f192-11d4-a65f-0040963251e5) +] +coclass XSLTemplate40 +{ + [default] interface IXSLTemplate; +} + +[ + uuid(88d96a08-f192-11d4-a65f-0040963251e5) +] +coclass XSLTemplate60 +{ + [default] interface IXSLTemplate; +} + /* * Sax Interfaces */ @@ -2143,6 +2399,19 @@ interface IMXAttributes : IDispatch HRESULT setValue([in] int index, [in] BSTR value); }; +[ + local, + object, + dual, + oleautomation, + uuid(fa4bb38c-faf9-4cca-9302-d1dd0fe520db) +] +interface IMXSchemaDeclHandler : IDispatch +{ + [id(DISPID_MX_SCHEMADECLHANDLER_SCHEMAELEMENTDECL)] + HRESULT schemaElementDecl( [in] ISchemaElement *oSchemaElement ); +} + [ object, dual, @@ -2213,6 +2482,179 @@ interface IMXWriter : IDispatch HRESULT flush(); }; +[ + local, + object, + dual, + oleautomation, + uuid(c90352f4-643c-4fbc-bb23-e996eb2d51fd) +] +interface IMXNamespacePrefixes : IDispatch +{ + [propget, id(DISPID_VALUE)] + HRESULT item( + [in] long index, + [out, retval] BSTR *prefix); + + [propget, id(DISPID_MX_NSMGR_LENGTH)] + HRESULT length( [out,retval] long *length ); + + [propget, restricted, hidden, id(DISPID_NEWENUM)] + HRESULT _newEnum( [out, retval] IUnknown **ppUnk ); +} + +[ + local, + object, + hidden, + uuid(c90352f6-643c-4fbc-bb23-e996eb2d51fd) +] +interface IMXNamespaceManager : IUnknown +{ + HRESULT putAllowOverride([in] VARIANT_BOOL fOverride); + + HRESULT getAllowOverride([out, retval] VARIANT_BOOL *fOverride); + + HRESULT reset(); + + HRESULT pushContext(); + + HRESULT pushNodeContext( + [in] IXMLDOMNode *contextNode, + [in] VARIANT_BOOL fDeep); + + HRESULT popContext(); + + HRESULT declarePrefix( + [in] const WCHAR *prefix, + [in] const WCHAR *namespaceURI); + + HRESULT getDeclaredPrefix( + [in] long nIndex, + [in, out] WCHAR *pwchPrefix, + [in, out] int *pcchPrefix); + + HRESULT getPrefix( + [in] const WCHAR *pwszNamespaceURI, + [in] long nIndex, + [in, out] WCHAR *pwchPrefix, + [in, out] int *pcchPrefix); + + HRESULT getURI( + [in] const WCHAR *pwchPrefix, + [in] IXMLDOMNode* pContextNode, + [in, out] WCHAR *pwchUri, + [in, out] int *pcchUri); +} + +[ + local, + object, + dual, + oleautomation, + uuid(c90352f5-643c-4fbc-bb23-e996eb2d51fd) +] +interface IVBMXNamespaceManager : IDispatch +{ + [propput, id(DISPID_MX_NSMGR_ALLOWOVERRIDE)] + HRESULT allowOverride([in] VARIANT_BOOL fOverride); + + [propget, id(DISPID_MX_NSMGR_ALLOWOVERRIDE)] + HRESULT allowOverride([out,retval] VARIANT_BOOL* fOverride); + + [id(DISPID_MX_NSMGR_RESET)] + HRESULT reset(); + + [id(DISPID_MX_NSMGR_PUSHCONTEXT)] + HRESULT pushContext(); + + [id(DISPID_MX_NSMGR_PUSHNODECONTEXT)] + HRESULT pushNodeContext( + [in] IXMLDOMNode* contextNode, + [in, defaultvalue(-1)] VARIANT_BOOL fDeep); + + [id(DISPID_MX_NSMGR_POPCONTEXT)] + HRESULT popContext(); + + [id(DISPID_MX_NSMGR_DECLAREPREFIX)] + HRESULT declarePrefix( + [in] BSTR prefix, + [in] BSTR namespaceURI); + + [id(DISPID_MX_NSMGR_GETDECLAREDPREFIXES)] + HRESULT getDeclaredPrefixes([out, retval] IMXNamespacePrefixes** prefixes); + + [id(DISPID_MX_NSMGR_GETPREFIXES)] + HRESULT getPrefixes( + [in] BSTR namespaceURI, + [out, retval] IMXNamespacePrefixes** prefixes); + + [id(DISPID_MX_NSMGR_GETURI)] + HRESULT getURI( + [in] BSTR prefix, + [out, retval] VARIANT* uri); + + [id(DISPID_MX_NSMGR_GETURIFROMNODE)] + HRESULT getURIFromNode( + [in] BSTR strPrefix, + [in] IXMLDOMNode* contextNode, + [out, retval] VARIANT* uri); +} + +[ + local, + object, + dual, + oleautomation, + uuid(c90352f7-643c-4fbc-bb23-e996eb2d51fd) +] +interface IMXXMLFilter : IDispatch +{ + [id(DISPID_MXXML_FILTER_GETFEATURE)] + HRESULT getFeature( + [in] BSTR strName, + [out, retval] VARIANT_BOOL * fValue); + + [id(DISPID_MXXML_FILTER_PUTFEATURE)] + HRESULT putFeature( + [in] BSTR strName, + [in] VARIANT_BOOL fValue); + + [id(DISPID_MXXML_FILTER_GETPROPERTY)] + HRESULT getProperty( + [in] BSTR strName, + [out, retval] VARIANT * varValue); + + [id(DISPID_MXXML_FILTER_PUTPROPERTY)] + HRESULT putProperty( + [in] BSTR strName, + [in] VARIANT varValue); + + [id(DISPID_MXXML_FILTER_ENTITYRESOLVER), propget] + HRESULT entityResolver( [out, retval] IUnknown **oResolver ); + + [id(DISPID_MXXML_FILTER_ENTITYRESOLVER), propputref] + HRESULT entityResolver( [in] IUnknown *oResolver ); + + [id(DISPID_MXXML_FILTER_CONTENTHANDLER), propget] + HRESULT contentHandler( [out, retval] IUnknown **oHandler ); + + [id(DISPID_MXXML_FILTER_CONTENTHANDLER), propputref] + HRESULT contentHandler( [in] IUnknown *oHandler ); + + [id(DISPID_MXXML_FILTER_DTDHANDLER), propget] + HRESULT dtdHandler( [out, retval] IUnknown **oHandler ); + + [id(DISPID_MXXML_FILTER_DTDHANDLER), propputref] + HRESULT dtdHandler( [in] IUnknown *oHandler ); + + [id(DISPID_MXXML_FILTER_ERRORHANDLER), propget] + HRESULT errorHandler( [out, retval] IUnknown **oHandler ); + + [id(DISPID_MXXML_FILTER_ERRORHANDLER), propputref] + HRESULT errorHandler( [in] IUnknown *oHandler ); +} + [ local, object, @@ -2691,7 +3133,96 @@ coclass SAXXMLReader40 { [default] interface IVBSAXXMLReader; interface ISAXXMLReader; -}; +} + +[ + uuid(88d96a0c-f192-11d4-a65f-0040963251e5) +] +coclass SAXXMLReader60 +{ + [default] interface IVBSAXXMLReader; + interface ISAXXMLReader; +} + +[ + uuid(a4c23ec3-6b70-4466-9127-550077239978) +] +coclass MXHTMLWriter +{ + [default] interface IMXWriter; + + interface ISAXContentHandler; + interface ISAXErrorHandler; + interface ISAXDTDHandler; + interface ISAXLexicalHandler; + interface ISAXDeclHandler; + + interface IVBSAXContentHandler; + interface IVBSAXDeclHandler; + interface IVBSAXDTDHandler; + interface IVBSAXErrorHandler; + interface IVBSAXLexicalHandler; +} + +[ + uuid(853d1540-c1a7-4aa9-a226-4d3bd301146d) +] +coclass MXHTMLWriter30 +{ + [default] interface IMXWriter; + + interface ISAXContentHandler; + interface ISAXDeclHandler; + interface ISAXDTDHandler; + interface ISAXErrorHandler; + interface ISAXLexicalHandler; + + interface IVBSAXContentHandler; + interface IVBSAXDeclHandler; + interface IVBSAXDTDHandler; + interface IVBSAXErrorHandler; + interface IVBSAXLexicalHandler; +} + +[ + uuid(88d969c9-f192-11d4-a65f-0040963251e5) +] +coclass MXHTMLWriter40 +{ + [default] interface IMXWriter; + + interface ISAXContentHandler; + interface ISAXDeclHandler; + interface ISAXDTDHandler; + interface ISAXErrorHandler; + interface ISAXLexicalHandler; + + interface IVBSAXContentHandler; + interface IVBSAXDeclHandler; + interface IVBSAXDTDHandler; + interface IVBSAXErrorHandler; + interface IVBSAXLexicalHandler; +} + +[ + uuid(88d96a10-f192-11d4-a65f-0040963251e5) +] +coclass MXHTMLWriter60 +{ + [default] interface IMXWriter; + + interface ISAXContentHandler; + interface ISAXDeclHandler; + interface ISAXDTDHandler; + interface ISAXErrorHandler; + interface ISAXLexicalHandler; + + interface IVBSAXContentHandler; + interface IVBSAXDeclHandler; + interface IVBSAXDTDHandler; + interface IVBSAXErrorHandler; + interface IVBSAXLexicalHandler; +} [ uuid(fc220ad8-a72a-4ee8-926e-0b7ad152a020) @@ -2751,7 +3282,54 @@ coclass MXXMLWriter40 interface IVBSAXDTDHandler; interface IVBSAXErrorHandler; interface IVBSAXLexicalHandler; -}; +} + +[ + uuid(88d96a0f-f192-11d4-a65f-0040963251e5) +] +coclass MXXMLWriter60 +{ + [default] interface IMXWriter; + + interface ISAXContentHandler; + interface ISAXDeclHandler; + interface ISAXDTDHandler; + interface ISAXErrorHandler; + interface ISAXLexicalHandler; + + interface IVBSAXContentHandler; + interface IVBSAXDeclHandler; + interface IVBSAXDTDHandler; + interface IVBSAXErrorHandler; + interface IVBSAXLexicalHandler; +} + +[ + uuid(88d969d5-f192-11d4-a65f-0040963251e5) +] +coclass MXNamespaceManager +{ + [default] interface IVBMXNamespaceManager; + interface IMXNamespaceManager; +} + +[ + uuid(88d969d6-f192-11d4-a65f-0040963251e5) +] +coclass MXNamespaceManager40 +{ + [default] interface IVBMXNamespaceManager; + interface IMXNamespaceManager; +} + +[ + uuid(88d96a11-f192-11d4-a65f-0040963251e5) +] +coclass MXNamespaceManager60 +{ + [default] interface IVBMXNamespaceManager; + interface IMXNamespaceManager; +} [ uuid(4dd441ad-526d-4a77-9f1b-9841ed802fb0) @@ -2761,7 +3339,7 @@ coclass SAXAttributes [default] interface IMXAttributes; interface IVBSAXAttributes; interface ISAXAttributes; -}; +} [ uuid(3e784a01-f3ae-4dc0-9354-9526b9370eba) @@ -2771,7 +3349,7 @@ coclass SAXAttributes30 [default] interface IMXAttributes; interface IVBSAXAttributes; interface ISAXAttributes; -}; +} [ uuid(88d969ca-f192-11d4-a65f-0040963251e5), @@ -2781,7 +3359,24 @@ coclass SAXAttributes40 [default] interface IMXAttributes; interface IVBSAXAttributes; interface ISAXAttributes; -}; +} +[ + uuid(88d96a0e-f192-11d4-a65f-0040963251e5) +] +coclass SAXAttributes60 +{ + [default] interface IMXAttributes; + interface IVBSAXAttributes; + interface ISAXAttributes; +} + +/* + * Error Codes + */ +cpp_quote("#define E_XML_NOTWF 0xC00CE223") +cpp_quote("#define E_XML_NODTD 0xC00CE224") +cpp_quote("#define E_XML_INVALID 0xC00CE225") +cpp_quote("#define E_XML_BUFFERTOOSMALL 0xC00CE226") } /* Library MSXML */ diff --git a/reactos/include/psdk/msxml2did.h b/reactos/include/psdk/msxml2did.h index d7489d0524f..1aae2a7db1d 100644 --- a/reactos/include/psdk/msxml2did.h +++ b/reactos/include/psdk/msxml2did.h @@ -199,6 +199,19 @@ #define DISPID_DOM_ERROR_FILEPOS 0x000000b7 #define DISPID_DOM_ERROR__TOP 0x000000b8 +#define DISPID_DOM_ERROR2 0x000000b9 +#define DISPID_DOM_ERROR2_ALLERRORS 0x000000ba +#define DISPID_DOM_ERROR2_ERRORPARAMETERS 0x000000bb +#define DISPID_DOM_ERROR2_ERRORPARAMETERSCOUNT 0x000000bc +#define DISPID_DOM_ERROR2_ERRORXPATH 0x000000bd +#define DISPID_DOM_ERROR2__TOP 0x000000be + +#define DISPID_DOM_ERRORCOLLECTION 0x000000bf +#define DISPID_DOM_ERRORCOLLECTION_LENGTH 0x000000c0 +#define DISPID_DOM_ERRORCOLLECTION_NEXT 0x000000c1 +#define DISPID_DOM_ERRORCOLLECTION_RESET 0x000000c2 +#define DISPID_DOM_ERRORCOLLECTION__TOP 0x000000c3 + #define DISPID_XTLRUNTIME 0x000000b9 #define DISPID_XTLRUNTIME_UNIQUEID 0x000000ba #define DISPID_XTLRUNTIME_DEPTH 0x000000bb @@ -224,6 +237,11 @@ #define DISPID_XMLDOM_DOCUMENT2_GETPROPERTY 0x000000cc #define DISPID_XMLDOM_DOCUMENT2__TOP 0x000000cd +#define DISPID_XMLDOM_DOCUMENT3 0x000000ce +#define DISPID_XMLDOM_DOCUMENT3_VALIDATENODE 0x000000cf +#define DISPID_XMLDOM_DOCUMENT3_IMPORTNODE 0x000000d0 +#define DISPID_XMLDOM_DOCUMENT3__TOP 0x000000d1 + #define DISPID_XMLDOM_SCHEMACOLLECTION 0x00000002 #define DISPID_XMLDOM_SCHEMACOLLECTION_ADD 0x00000003 #define DISPID_XMLDOM_SCHEMACOLLECTION_GET 0x00000004 @@ -410,6 +428,16 @@ #define DISPID_MX_NSMGR_GETURIFROMNODE 0x00000587 #define DISPID_MX_NSMGR_LENGTH 0x00000588 +#define DISPID_MXXML_FILTER 0x0000058a +#define DISPID_MXXML_FILTER_CONTENTHANDLER 0x0000058b +#define DISPID_MXXML_FILTER_DTDHANDLER 0x0000058c +#define DISPID_MXXML_FILTER_ENTITYRESOLVER 0x0000058d +#define DISPID_MXXML_FILTER_ERRORHANDLER 0x0000058e +#define DISPID_MXXML_FILTER_GETFEATURE 0x0000058f +#define DISPID_MXXML_FILTER_GETPROPERTY 0x00000590 +#define DISPID_MXXML_FILTER_PUTFEATURE 0x00000591 +#define DISPID_MXXML_FILTER_PUTPROPERTY 0x00000592 + #define DISPID_SOM_VALIDATE 0x0000058b #define DISPID_SOM_VALIDATEONLOAD 0x0000058c #define DISPID_SOM_GETSCHEMA 0x0000058d diff --git a/reactos/include/psdk/msxml6.idl b/reactos/include/psdk/msxml6.idl new file mode 100644 index 00000000000..45cef98825f --- /dev/null +++ b/reactos/include/psdk/msxml6.idl @@ -0,0 +1,3421 @@ +/* + * Copyright (C) 2005 Vijay Kiran Kamuju + * Copyright (C) 2008 Alistair Leslie-Hughes + * Copyright (C) 2010 Nikolay Sivov for CodeWeavers + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include +#include + +import "unknwn.idl"; +import "objidl.idl"; +import "oaidl.idl"; + +#ifndef __WIDL__ +#define threading(model) +#define progid(str) +#define vi_progid(str) +#endif + +[ + uuid(f5078f18-c551-11d3-89b9-0000f81fe221), + version(6.0), + helpstring("Microsoft XML, v6.0") +] +library MSXML2 +{ + +importlib("stdole2.tlb"); + +interface IXMLDOMImplementation; +interface IXMLDOMNode; +interface IXMLDOMDocumentFragment; +interface IXMLDOMDocument; +interface IXMLDOMSchemaCollection; +interface IXMLDOMDocument2; +interface IXMLDOMNodeList; +interface IXMLDOMNamedNodeMap; +interface IXMLDOMCharacterData; +interface IXMLDOMAttribute; +interface IXMLDOMElement; +interface IXMLDOMText; +interface IXMLDOMComment; +interface IXMLDOMProcessingInstruction; +interface IXMLDOMCDATASection; +interface IXMLDOMDocumentType; +interface IXMLDOMNotation; +interface IXMLDOMEntity; +interface IXMLDOMEntityReference; +interface IXMLDOMParseError; +interface IXMLDOMParseErrorCollection; +interface IXTLRuntime; +interface IXSLTemplate; +interface IXSLProcessor; + +/* SAX Interfaces */ +interface ISAXAttributes; +interface ISAXContentHandler; +interface ISAXDeclHandler; +interface ISAXDTDHandler; +interface ISAXEntityResolver; +interface ISAXErrorHandler; +interface ISAXLexicalHandler; +interface ISAXLocator; +interface ISAXXMLFilter; +interface ISAXXMLReader; + +interface IVBSAXAttributes; +interface IVBSAXContentHandler; +interface IVBSAXDeclHandler; +interface IVBSAXDTDHandler; +interface IVBSAXEntityResolver; +interface IVBSAXErrorHandler; +interface IVBSAXLexicalHandler; +interface IVBSAXLocator; +interface IVBSAXXMLFilter; +interface IVBSAXXMLReader; + +interface IMXAttributes; +interface IMXReaderControl; +interface IMXWriter; + +interface IXMLDOMSchemaCollection2; +interface ISchemaStringCollection; +interface ISchemaItemCollection; +interface ISchemaItem; +interface ISchema; +interface ISchemaParticle; +interface ISchemaAttribute; +interface ISchemaElement; +interface ISchemaType; +interface ISchemaComplexType; +interface ISchemaAttributeGroup; +interface ISchemaModelGroup; +interface ISchemaAny; +interface ISchemaIdentityConstraint; +interface ISchemaNotation; + + +cpp_quote("#define DOMDocument DOMDocument2") +cpp_quote("#define CLSID_DOMDocument CLSID_DOMDocument2") + +cpp_quote("#ifndef __WIDL_XMLDOM_H") +typedef enum tagDOMNodeType +{ + NODE_INVALID = 0, + NODE_ELEMENT = 1, + NODE_ATTRIBUTE = 2, + NODE_TEXT = 3, + NODE_CDATA_SECTION = 4, + NODE_ENTITY_REFERENCE = 5, + NODE_ENTITY = 6, + NODE_PROCESSING_INSTRUCTION = 7, + NODE_COMMENT = 8, + NODE_DOCUMENT = 9, + NODE_DOCUMENT_TYPE = 10, + NODE_DOCUMENT_FRAGMENT = 11, + NODE_NOTATION = 12 +} DOMNodeType; +cpp_quote("#endif /* __WIDL_XMLDOM_H */") + +typedef enum _SOMITEMTYPE +{ + SOMITEM_SCHEMA = 0x1000, + SOMITEM_ATTRIBUTE = 0x1001, + SOMITEM_ATTRIBUTEGROUP = 0x1002, + SOMITEM_NOTATION = 0x1003, + SOMITEM_IDENTITYCONSTRAINT = 0x1100, + SOMITEM_KEY = 0x1101, + SOMITEM_KEYREF = 0x1102, + SOMITEM_UNIQUE = 0x1103, + SOMITEM_ANYTYPE = 0x2000, + SOMITEM_DATATYPE = 0x2100, + SOMITEM_DATATYPE_ANYTYPE = 0x2101, + SOMITEM_DATATYPE_ANYURI = 0x2102, + SOMITEM_DATATYPE_BASE64BINARY = 0x2103, + SOMITEM_DATATYPE_BOOLEAN = 0x2104, + SOMITEM_DATATYPE_BYTE = 0x2105, + SOMITEM_DATATYPE_DATE = 0x2106, + SOMITEM_DATATYPE_DATETIME = 0x2107, + SOMITEM_DATATYPE_DAY = 0x2108, + SOMITEM_DATATYPE_DECIMAL = 0x2109, + SOMITEM_DATATYPE_DOUBLE = 0x210A, + SOMITEM_DATATYPE_DURATION = 0x210B, + SOMITEM_DATATYPE_ENTITIES = 0x210C, + SOMITEM_DATATYPE_ENTITY = 0x210D, + SOMITEM_DATATYPE_FLOAT = 0x210E, + SOMITEM_DATATYPE_HEXBINARY = 0x210F, + SOMITEM_DATATYPE_ID = 0x2110, + SOMITEM_DATATYPE_IDREF = 0x2111, + SOMITEM_DATATYPE_IDREFS = 0x2112, + SOMITEM_DATATYPE_INT = 0x2113, + SOMITEM_DATATYPE_INTEGER = 0x2114, + SOMITEM_DATATYPE_LANGUAGE = 0x2115, + SOMITEM_DATATYPE_LONG = 0x2116, + SOMITEM_DATATYPE_MONTH = 0x2117, + SOMITEM_DATATYPE_MONTHDAY = 0x2118, + SOMITEM_DATATYPE_NAME = 0x2119, + SOMITEM_DATATYPE_NCNAME = 0x211A, + SOMITEM_DATATYPE_NEGATIVEINTEGER = 0x211B, + SOMITEM_DATATYPE_NMTOKEN = 0x211C, + SOMITEM_DATATYPE_NMTOKENS = 0x211D, + SOMITEM_DATATYPE_NONNEGATIVEINTEGER = 0x211E, + SOMITEM_DATATYPE_NONPOSITIVEINTEGER = 0x211F, + SOMITEM_DATATYPE_NORMALIZEDSTRING = 0x2120, + SOMITEM_DATATYPE_NOTATION = 0x2121, + SOMITEM_DATATYPE_POSITIVEINTEGER = 0x2122, + SOMITEM_DATATYPE_QNAME = 0x2123, + SOMITEM_DATATYPE_SHORT = 0x2124, + SOMITEM_DATATYPE_STRING = 0x2125, + SOMITEM_DATATYPE_TIME = 0x2126, + SOMITEM_DATATYPE_TOKEN = 0x2127, + SOMITEM_DATATYPE_UNSIGNEDBYTE = 0x2128, + SOMITEM_DATATYPE_UNSIGNEDINT = 0x2129, + SOMITEM_DATATYPE_UNSIGNEDLONG = 0x212A, + SOMITEM_DATATYPE_UNSIGNEDSHORT = 0x212B, + SOMITEM_DATATYPE_YEAR = 0x212C, + SOMITEM_DATATYPE_YEARMONTH = 0x212D, + SOMITEM_DATATYPE_ANYSIMPLETYPE = 0x21FF, + SOMITEM_SIMPLETYPE = 0x2200, + SOMITEM_COMPLEXTYPE = 0x2400, + SOMITEM_PARTICLE = 0x4000, + SOMITEM_ANY = 0x4001, + SOMITEM_ANYATTRIBUTE = 0x4002, + SOMITEM_ELEMENT = 0x4003, + SOMITEM_GROUP = 0x4100, + SOMITEM_ALL = 0x4101, + SOMITEM_CHOICE = 0x4102, + SOMITEM_SEQUENCE = 0x4103, + SOMITEM_EMPTYPARTICLE = 0x4104, + SOMITEM_NULL = 0x0800, + SOMITEM_NULL_TYPE = 0x2800, + SOMITEM_NULL_ANY = 0x4801, + SOMITEM_NULL_ANYATTRIBUTE = 0x4802, + SOMITEM_NULL_ELEMENT = 0x4803, +} SOMITEMTYPE; + +typedef enum _SCHEMAUSE +{ + SCHEMAUSE_OPTIONAL, + SCHEMAUSE_PROHIBITED, + SCHEMAUSE_REQUIRED, +} SCHEMAUSE; + +typedef enum _SCHEMADERIVATIONMETHOD +{ + SCHEMADERIVATIONMETHOD_EMPTY = 0x0000, + SCHEMADERIVATIONMETHOD_SUBSTITUTION = 0x0001, + SCHEMADERIVATIONMETHOD_EXTENSION = 0x0002, + SCHEMADERIVATIONMETHOD_RESTRICTION = 0x0004, + SCHEMADERIVATIONMETHOD_LIST = 0x0008, + SCHEMADERIVATIONMETHOD_UNION = 0x0010, + SCHEMADERIVATIONMETHOD_ALL = 0x00FF, + SCHEMADERIVATIONMETHOD_NONE = 0x0100, +} SCHEMADERIVATIONMETHOD; + +typedef enum _SCHEMACONTENTTYPE +{ + SCHEMACONTENTTYPE_EMPTY, + SCHEMACONTENTTYPE_TEXTONLY, + SCHEMACONTENTTYPE_ELEMENTONLY, + SCHEMACONTENTTYPE_MIXED, +} SCHEMACONTENTTYPE; + +typedef enum _SCHEMAPROCESSCONTENTS +{ + SCHEMAPROCESSCONTENTS_NONE, + SCHEMAPROCESSCONTENTS_SKIP, + SCHEMAPROCESSCONTENTS_LAX, + SCHEMAPROCESSCONTENTS_STRICT, +} SCHEMAPROCESSCONTENTS; + +typedef enum _SCHEMAWHITESPACE +{ + SCHEMAWHITESPACE_NONE = -1, + SCHEMAWHITESPACE_PRESERVE = 0, + SCHEMAWHITESPACE_REPLACE = 1, + SCHEMAWHITESPACE_COLLAPSE = 2, +} SCHEMAWHITESPACE; + + +typedef enum _SCHEMATYPEVARIETY +{ + SCHEMATYPEVARIETY_NONE = -1, + SCHEMATYPEVARIETY_ATOMIC = 0, + SCHEMATYPEVARIETY_LIST = 1, + SCHEMATYPEVARIETY_UNION = 2, +} SCHEMATYPEVARIETY; + +[ +local, +object, +dual, +oleautomation, +uuid (2933BF80-7B36-11d2-B20E-00C04F983E60) +] +interface IXMLDOMNode : IDispatch +{ + [propget, id(DISPID_DOM_NODE_NODENAME)] + HRESULT nodeName([retval, out] BSTR *p); + + [propget, id(DISPID_DOM_NODE_NODEVALUE)] + HRESULT nodeValue([retval, out] VARIANT *var1); + + [propput, id(DISPID_DOM_NODE_NODEVALUE)] + HRESULT nodeValue([in] VARIANT var1); + + [propget, id(DISPID_DOM_NODE_NODETYPE)] + HRESULT nodeType([retval, out] DOMNodeType *domNodeType); + + [propget, id(DISPID_DOM_NODE_PARENTNODE)] + HRESULT parentNode([retval, out] IXMLDOMNode **parent); + + [propget, id(DISPID_DOM_NODE_CHILDNODES)] + HRESULT childNodes([retval, out] IXMLDOMNodeList **outList); + + [propget, id(DISPID_DOM_NODE_FIRSTCHILD)] + HRESULT firstChild([retval, out] IXMLDOMNode **domNode); + + [propget, id(DISPID_DOM_NODE_LASTCHILD)] + HRESULT lastChild([retval, out] IXMLDOMNode **domNode); + + [propget, id(DISPID_DOM_NODE_PREVIOUSSIBLING)] + HRESULT previousSibling([retval, out] IXMLDOMNode **domNode); + + [propget, id(DISPID_DOM_NODE_NEXTSIBLING)] + HRESULT nextSibling([retval, out] IXMLDOMNode **domNode); + + [propget, id(DISPID_DOM_NODE_ATTRIBUTES)] + HRESULT attributes([retval, out] IXMLDOMNamedNodeMap **attributeMap); + + [id(DISPID_DOM_NODE_INSERTBEFORE)] + HRESULT insertBefore( + [in] IXMLDOMNode *newNode, + [in] VARIANT var1, + [retval, out] IXMLDOMNode **outOldNode); + + [id(DISPID_DOM_NODE_REPLACECHILD)] + HRESULT replaceChild( + [in] IXMLDOMNode *newNode, + [in] IXMLDOMNode *oldNode, + [retval, out] IXMLDOMNode **outOldNode); + + [id(DISPID_DOM_NODE_REMOVECHILD)] + HRESULT removeChild( + [in] IXMLDOMNode *domNode, + [retval, out] IXMLDOMNode **oldNode); + + [id(DISPID_DOM_NODE_APPENDCHILD)] + HRESULT appendChild( + [in] IXMLDOMNode *newNode, + [retval, out] IXMLDOMNode **outNewNode); + + [id(DISPID_DOM_NODE_HASCHILDNODES)] + HRESULT hasChildNodes( + [retval, out] VARIANT_BOOL *pbool); + + [propget, id(DISPID_DOM_NODE_OWNERDOC)] + HRESULT ownerDocument([retval, out] IXMLDOMDocument **domDocument); + + [id(DISPID_DOM_NODE_CLONENODE)] + HRESULT cloneNode( + [in] VARIANT_BOOL pbool, + [retval, out] IXMLDOMNode **outNode); + + [propget, id(DISPID_XMLDOM_NODE_STRINGTYPE)] + HRESULT nodeTypeString([retval, out] BSTR *p); + + [propget, id(DISPID_XMLDOM_NODE_TEXT)] + HRESULT text([retval, out] BSTR *p); + + [propput, id(DISPID_XMLDOM_NODE_TEXT)] + HRESULT text([in] BSTR p); + + [propget, id(DISPID_XMLDOM_NODE_SPECIFIED)] + HRESULT specified([retval, out] VARIANT_BOOL *pbool); + + [propget, id(DISPID_XMLDOM_NODE_DEFINITION)] + HRESULT definition([retval,out] IXMLDOMNode **domNode); + + [propget, id(DISPID_XMLDOM_NODE_NODETYPEDVALUE)] + HRESULT nodeTypedValue([retval, out] VARIANT *var1); + + [propput, id(DISPID_XMLDOM_NODE_NODETYPEDVALUE)] + HRESULT nodeTypedValue([in] VARIANT var1); + + [propget, id(DISPID_XMLDOM_NODE_DATATYPE)] + HRESULT dataType([retval, out] VARIANT *var1); + + [propput, id(DISPID_XMLDOM_NODE_DATATYPE)] + HRESULT dataType([in] BSTR p); + + [propget, id(DISPID_XMLDOM_NODE_XML)] + HRESULT xml([retval, out] BSTR *p); + + [id(DISPID_XMLDOM_NODE_TRANSFORMNODE)] + HRESULT transformNode( + [in] IXMLDOMNode *domNode, + [retval, out] BSTR *p); + + [id(DISPID_XMLDOM_NODE_SELECTNODES)] + HRESULT selectNodes( + [in] BSTR p, + [retval, out] IXMLDOMNodeList **outList); + + [id(DISPID_XMLDOM_NODE_SELECTSINGLENODE)] + HRESULT selectSingleNode( + [in] BSTR p, + [retval, out] IXMLDOMNode **outNode); + + [propget,id(DISPID_XMLDOM_NODE_PARSED)] + HRESULT parsed([retval, out] VARIANT_BOOL *pbool); + + [propget, id(DISPID_XMLDOM_NODE_NAMESPACE)] + HRESULT namespaceURI([retval, out] BSTR *p); + + [propget, id(DISPID_XMLDOM_NODE_PREFIX)] + HRESULT prefix([retval, out] BSTR *p); + + [propget, id(DISPID_XMLDOM_NODE_BASENAME)] + HRESULT baseName([retval, out] BSTR *p); + + [id(DISPID_XMLDOM_NODE_TRANSFORMNODETOOBJECT)] + HRESULT transformNodeToObject( + [in] IXMLDOMNode *domNode, + [in] VARIANT var1); +} + +[ +local, +object, +dual, +oleautomation, +uuid (2933BF81-7B36-11d2-B20E-00C04F983E60) +] +interface IXMLDOMDocument : IXMLDOMNode +{ + [propget, id(DISPID_DOM_DOCUMENT_DOCTYPE)] + HRESULT doctype([retval, out] IXMLDOMDocumentType **docType); + + [propget, id(DISPID_DOM_DOCUMENT_IMPLEMENTATION)] + HRESULT implementation([retval, out] IXMLDOMImplementation **impl); + + [propget, id(DISPID_DOM_DOCUMENT_DOCUMENTELEMENT)] + HRESULT documentElement([retval, out] IXMLDOMElement **domElement); + + [propputref, id(DISPID_DOM_DOCUMENT_DOCUMENTELEMENT)] + HRESULT documentElement([in] IXMLDOMElement *domElement); + + [id(DISPID_DOM_DOCUMENT_CREATEELEMENT)] + HRESULT createElement( + [in] BSTR p, + [retval, out] IXMLDOMElement **domElement); + + [id(DISPID_DOM_DOCUMENT_CREATEDOCUMENTFRAGMENT)] + HRESULT createDocumentFragment( + [retval, out] IXMLDOMDocumentFragment **docFrag); + + [id(DISPID_DOM_DOCUMENT_CREATETEXTNODE)] + HRESULT createTextNode( + [in] BSTR p, + [retval, out] IXMLDOMText **text); + + [id(DISPID_DOM_DOCUMENT_CREATECOMMENT)] + HRESULT createComment( + [in] BSTR p, + [retval, out] IXMLDOMComment **comment); + + [id(DISPID_DOM_DOCUMENT_CREATECDATASECTION)] + HRESULT createCDATASection( + [in] BSTR p, + [retval, out] IXMLDOMCDATASection **cdata); + + [id(DISPID_DOM_DOCUMENT_CREATEPROCESSINGINSTRUCTION)] + HRESULT createProcessingInstruction( + [in] BSTR target, + [in] BSTR data, + [retval, out] IXMLDOMProcessingInstruction **pi); + + [id(DISPID_DOM_DOCUMENT_CREATEATTRIBUTE)] + HRESULT createAttribute( + [in] BSTR p, + [retval, out] IXMLDOMAttribute **attribute); + + [id(DISPID_DOM_DOCUMENT_CREATEENTITYREFERENCE)] + HRESULT createEntityReference( + [in] BSTR p, + [retval, out] IXMLDOMEntityReference **entityRef); + + [id(DISPID_DOM_DOCUMENT_GETELEMENTSBYTAGNAME)] + HRESULT getElementsByTagName( + [in] BSTR p, + [retval, out] IXMLDOMNodeList **resultList); + + [id(DISPID_XMLDOM_DOCUMENT_CREATENODE)] + HRESULT createNode( + [in] VARIANT var, + [in] BSTR name, + [in] BSTR uri, + [retval, out] IXMLDOMNode **node); + + [id(DISPID_XMLDOM_DOCUMENT_NODEFROMID)] + HRESULT nodeFromID( + [in] BSTR id, + [retval, out] IXMLDOMNode **node); + + [id(DISPID_XMLDOM_DOCUMENT_LOAD)] + HRESULT load( + [in] VARIANT var1, + [retval, out] VARIANT_BOOL *pbool); + + [propget, id(DISPID_READYSTATE)] + HRESULT readyState([retval, out] LONG *value); + + [propget, id(DISPID_XMLDOM_DOCUMENT_PARSEERROR)] + HRESULT parseError([retval, out] IXMLDOMParseError **err); + + [propget, id(DISPID_XMLDOM_DOCUMENT_URL)] + HRESULT url([retval, out] BSTR *p); + + [propget, id(DISPID_XMLDOM_DOCUMENT_ASYNC)] + HRESULT async([retval, out] VARIANT_BOOL *pbool); + + [propput, id(DISPID_XMLDOM_DOCUMENT_ASYNC)] + HRESULT async([in] VARIANT_BOOL pbool); + + [id(DISPID_XMLDOM_DOCUMENT_ABORT)] + HRESULT abort(); + + [id(DISPID_XMLDOM_DOCUMENT_LOADXML)] + HRESULT loadXML( + [in] BSTR p, + [out, retval] VARIANT_BOOL *pbool); + + [id(DISPID_XMLDOM_DOCUMENT_SAVE)] + HRESULT save( + [in] VARIANT var1); + + [propget, id(DISPID_XMLDOM_DOCUMENT_VALIDATE)] + HRESULT validateOnParse([retval, out] VARIANT_BOOL *pbool); + + [propput, id(DISPID_XMLDOM_DOCUMENT_VALIDATE)] + HRESULT validateOnParse([in] VARIANT_BOOL pbool); + + [propget, id(DISPID_XMLDOM_DOCUMENT_RESOLVENAMESPACE)] + HRESULT resolveExternals([retval,out] VARIANT_BOOL *pbool); + + [propput, id(DISPID_XMLDOM_DOCUMENT_RESOLVENAMESPACE)] + HRESULT resolveExternals([in] VARIANT_BOOL pbool); + + [propget, id(DISPID_XMLDOM_DOCUMENT_PRESERVEWHITESPACE)] + HRESULT preserveWhiteSpace([retval,out] VARIANT_BOOL *pbool); + + [propput, id(DISPID_XMLDOM_DOCUMENT_PRESERVEWHITESPACE)] + HRESULT preserveWhiteSpace([in] VARIANT_BOOL pbool); + + [propput, id(DISPID_XMLDOM_DOCUMENT_ONREADYSTATECHANGE)] + HRESULT onreadystatechange([in] VARIANT var1); + + [propput, id(DISPID_XMLDOM_DOCUMENT_ONDATAAVAILABLE)] + HRESULT ondataavailable([in] VARIANT var1); + + [propput, id(DISPID_XMLDOM_DOCUMENT_ONTRANSFORMNODE)] + HRESULT ontransformnode([in] VARIANT var1); +} + +[ +local, +object, +dual, +oleautomation, +uuid (373984c8-b845-449b-91e7-45ac83036ade) +] +interface IXMLDOMSchemaCollection : IDispatch +{ + [id(DISPID_XMLDOM_SCHEMACOLLECTION_ADD)] + HRESULT add( + [in] BSTR uri, + [in] VARIANT var); + + [id(DISPID_XMLDOM_SCHEMACOLLECTION_GET)] + HRESULT get( + [in] BSTR uri, + [retval, out] IXMLDOMNode **node); + + [id(DISPID_XMLDOM_SCHEMACOLLECTION_REMOVE)] + HRESULT remove( + [in] BSTR uri); + + [propget, id(DISPID_XMLDOM_SCHEMACOLLECTION_LENGTH)] + HRESULT length( + [retval, out] LONG *length); + + [propget, id(DISPID_VALUE)] + HRESULT namespaceURI([in] LONG index, [out, retval] BSTR *len); + + [id(DISPID_XMLDOM_SCHEMACOLLECTION_ADDCOLLECTION)] + HRESULT addCollection( + [in] IXMLDOMSchemaCollection *otherCollection); + + [propget, id(DISPID_NEWENUM)] + HRESULT _newEnum([retval, out] IUnknown **ppUnk); +} + +[ + local, + object, + dual, + oleautomation, + uuid(50ea08b0-dd1b-4664-9a50-c2f40f4bd79a), +] +interface IXMLDOMSchemaCollection2 : IXMLDOMSchemaCollection +{ + [id(DISPID_SOM_VALIDATE)] + HRESULT validate(); + + [propput, id(DISPID_SOM_VALIDATEONLOAD)] + HRESULT validateOnLoad( + [in] VARIANT_BOOL validateOnLoad); + + [propget, id(DISPID_SOM_VALIDATEONLOAD)] + HRESULT validateOnLoad( + [out,retval] VARIANT_BOOL* validateOnLoad); + + [id(DISPID_SOM_GETSCHEMA)] + HRESULT getSchema( + [in] BSTR namespaceURI, + [out,retval] ISchema** schema); + + [id(DISPID_SOM_GETDECLARATION)] + HRESULT getDeclaration( + [in] IXMLDOMNode* node, + [out,retval]ISchemaItem** item); +}; + +[ +local, +object, +dual, +oleautomation, +uuid (2933BF95-7B36-11d2-B20E-00C04F983E60) +] +interface IXMLDOMDocument2 : IXMLDOMDocument +{ + [propget, id(DISPID_XMLDOM_DOCUMENT2_NAMESPACES)] + HRESULT namespaces([retval, out] IXMLDOMSchemaCollection **schemaCollection); + + [propget, id(DISPID_XMLDOM_DOCUMENT2_SCHEMAS)] + HRESULT schemas([retval, out] VARIANT *var1); + + [propputref, id(DISPID_XMLDOM_DOCUMENT2_SCHEMAS)] + HRESULT schemas([in] VARIANT var1); + + [id(DISPID_XMLDOM_DOCUMENT2_VALIDATE)] + HRESULT validate( + [retval, out] IXMLDOMParseError **err); + + [id(DISPID_XMLDOM_DOCUMENT2_SETPROPERTY)] + HRESULT setProperty( + [in] BSTR p, + [in] VARIANT var); + + [id(DISPID_XMLDOM_DOCUMENT2_GETPROPERTY)] + HRESULT getProperty( + [in] BSTR p, + [retval, out] VARIANT *var); +} + +[ + local, + object, + dual, + uuid(2933bf96-7b36-11d2-b20e-00c04f983e60), + oleautomation, +] +interface IXMLDOMDocument3 : IXMLDOMDocument2 +{ + [id(DISPID_XMLDOM_DOCUMENT3_VALIDATENODE)] + HRESULT validateNode( + [in] IXMLDOMNode *node, + [out, retval] IXMLDOMParseError **error); + + [id(DISPID_XMLDOM_DOCUMENT3_IMPORTNODE)] + HRESULT importNode( + [in] IXMLDOMNode *node, + [in] VARIANT_BOOL deep, + [out, retval] IXMLDOMNode **clone); +} + +[ +local, +object, +dual, +oleautomation, +uuid (2933BF82-7B36-11d2-B20E-00C04F983E60) +] +interface IXMLDOMNodeList : IDispatch +{ + [propget, id(DISPID_VALUE)] + HRESULT item([in] LONG lIndex, [retval, out] IXMLDOMNode **outNode); + + [propget, id(DISPID_DOM_NODELIST_LENGTH)] + HRESULT length([retval, out] LONG *lLength); + + [id(DISPID_XMLDOM_NODELIST_NEXTNODE)] + HRESULT nextNode( + [retval, out] IXMLDOMNode **outNode); + + [id(DISPID_XMLDOM_NODELIST_RESET)] + HRESULT reset(); + + [propget, id(DISPID_NEWENUM)] + HRESULT _newEnum([retval, out] IUnknown **ppUnk); +} + +[ +local, +object, +dual, +oleautomation, +uuid (AA634FC7-5888-44a7-A257-3A47150D3A0E) +] +interface IXMLDOMSelection : IXMLDOMNodeList +{ + [propget, id(DISPID_XMLDOM_SELECTION_EXPR)] + HRESULT expr([retval, out] BSTR *p); + + [propput, id(DISPID_XMLDOM_SELECTION_EXPR)] + HRESULT expr([in] BSTR p); + + [propget, id(DISPID_XMLDOM_SELECTION_CONTEXT)] + HRESULT context([retval, out] IXMLDOMNode **ppNode); + + [propputref, id(DISPID_XMLDOM_SELECTION_CONTEXT)] + HRESULT context([in] IXMLDOMNode * pNode); + + [id(DISPID_XMLDOM_SELECTION_PEEKNODE)] + HRESULT peekNode( + [retval, out] IXMLDOMNode **ppNode); + + [id(DISPID_XMLDOM_SELECTION_MATCHES)] + HRESULT matches( + [in] IXMLDOMNode *pNode, + [retval, out] IXMLDOMNode **ppNode); + + [id(DISPID_XMLDOM_SELECTION_REMOVENEXT)] + HRESULT removeNext( + [retval, out] IXMLDOMNode **ppNode); + + [id(DISPID_XMLDOM_SELECTION_REMOVEALL)] + HRESULT removeAll(); + + [id(DISPID_XMLDOM_SELECTION_CLONE)] + HRESULT clone( + [retval, out] IXMLDOMSelection **ppNode); + + [id(DISPID_XMLDOM_SELECTION_GETPROPERTY)] + HRESULT getProperty( + [in] BSTR p, + [retval, out] VARIANT * var); + + [id(DISPID_XMLDOM_SELECTION_SETPROPERTY)] + HRESULT setProperty( + [in] BSTR p, + [in] VARIANT var); +} + +[ +local, +object, +dual, +oleautomation, +uuid (2933BF83-7B36-11d2-B20E-00C04F983E60) +] +interface IXMLDOMNamedNodeMap : IDispatch +{ + [id(DISPID_DOM_NAMEDNODEMAP_GETNAMEDITEM)] + HRESULT getNamedItem( + [in] BSTR p, + [retval, out] IXMLDOMNode **outNode); + + [id(DISPID_DOM_NAMEDNODEMAP_SETNAMEDITEM)] + HRESULT setNamedItem( + [in] IXMLDOMNode *newNode, + [retval, out] IXMLDOMNode **outNode); + + [id(DISPID_DOM_NAMEDNODEMAP_REMOVENAMEDITEM)] + HRESULT removeNamedItem( + [in] BSTR p, + [retval, out] IXMLDOMNode **outNode); + + [propget, id(DISPID_VALUE)] + HRESULT item([in] LONG lIndex, [retval, out] IXMLDOMNode **outNode); + + [propget, id(DISPID_DOM_NODELIST_LENGTH)] + HRESULT length([retval, out] LONG *lLength); + + [id(DISPID_XMLDOM_NAMEDNODEMAP_GETQUALIFIEDITEM)] + HRESULT getQualifiedItem( + [in] BSTR name, + [in] BSTR uri, + [retval, out] IXMLDOMNode **outNode); + + [id(DISPID_XMLDOM_NAMEDNODEMAP_REMOVEQUALIFIEDITEM)] + HRESULT removeQualifiedItem( + [in] BSTR name, + [in] BSTR uri, + [retval, out] IXMLDOMNode **outNode); + + [id(DISPID_XMLDOM_NAMEDNODEMAP_NEXTNODE)] + HRESULT nextNode( + [retval, out] IXMLDOMNode **outNode); + + [id(DISPID_XMLDOM_NAMEDNODEMAP_RESET)] + HRESULT reset(); + + [propget, id(DISPID_NEWENUM)] + HRESULT _newEnum([retval, out] IUnknown **ppUnk); +} + +[ +local, +object, +dual, +oleautomation, +uuid (3efaa413-272f-11d2-836f-0000f87a7782) +] +interface IXMLDOMDocumentFragment : IXMLDOMNode +{ +} + +[ +local, +object, +dual, +oleautomation, +uuid (2933BF84-7B36-11d2-B20E-00C04F983E60) +] +interface IXMLDOMCharacterData : IXMLDOMNode +{ + [propget, id(DISPID_DOM_DATA_DATA)] + HRESULT data([retval, out] BSTR *p); + + [propput, id(DISPID_DOM_DATA_DATA)] + HRESULT data([in] BSTR data); + + [propget, id(DISPID_DOM_DATA_LENGTH)] + HRESULT length([retval, out] LONG *len); + + [id(DISPID_DOM_DATA_SUBSTRING)] + HRESULT substringData( + [in] LONG offset, + [in] LONG count, + [retval, out] BSTR *p); + + [id(DISPID_DOM_DATA_APPEND)] + HRESULT appendData( + [in] BSTR p); + + [id(DISPID_DOM_DATA_INSERT)] + HRESULT insertData( + [in] LONG offset, + [in] BSTR p); + + [id(DISPID_DOM_DATA_DELETE)] + HRESULT deleteData( + [in] LONG offset, + [in] LONG count); + + [id(DISPID_DOM_DATA_REPLACE)] + HRESULT replaceData( + [in] LONG offset, + [in] LONG count, + [in] BSTR p); +} + +[ +local, +object, +dual, +oleautomation, +uuid (2933BF85-7B36-11d2-B20E-00C04F983E60) +] +interface IXMLDOMAttribute : IXMLDOMNode +{ + [propget, id(DISPID_DOM_ATTRIBUTE_GETNAME)] + HRESULT name([retval, out] BSTR *p); + + [propget, id(DISPID_DOM_ATTRIBUTE_VALUE)] + HRESULT value([retval, out] VARIANT *var1); + + [propput, id(DISPID_DOM_ATTRIBUTE_VALUE)] + HRESULT value([in] VARIANT var1); +} + +[ +local, +object, +dual, +oleautomation, +uuid (2933BF86-7B36-11d2-B20E-00C04F983E60) +] +interface IXMLDOMElement : IXMLDOMNode +{ + [propget, id(DISPID_DOM_ELEMENT_GETTAGNAME)] + HRESULT tagName([retval, out] BSTR *p); + + [id(DISPID_DOM_ELEMENT_GETATTRIBUTE)] + HRESULT getAttribute( + [in] BSTR p, + [retval, out] VARIANT *var); + + [id(DISPID_DOM_ELEMENT_SETATTRIBUTE)] + HRESULT setAttribute( + [in] BSTR p, + [in] VARIANT var); + + [id(DISPID_DOM_ELEMENT_REMOVEATTRIBUTE)] + HRESULT removeAttribute( + [in] BSTR p); + + [id(DISPID_DOM_ELEMENT_GETATTRIBUTENODE)] + HRESULT getAttributeNode( + [in] BSTR p, + [retval, out] IXMLDOMAttribute **attributeNode); + + [id(DISPID_DOM_ELEMENT_SETATTRIBUTENODE)] + HRESULT setAttributeNode( + [in] IXMLDOMAttribute *domAttribute, + [retval, out] IXMLDOMAttribute **attributeNode); + + [id(DISPID_DOM_ELEMENT_REMOVEATTRIBUTENODE)] + HRESULT removeAttributeNode( + [in] IXMLDOMAttribute *domAttribute, + [retval, out] IXMLDOMAttribute **attributeNode); + + [id(DISPID_DOM_ELEMENT_GETELEMENTSBYTAGNAME)] + HRESULT getElementsByTagName( + [in] BSTR p, + [retval, out] IXMLDOMNodeList **resultList); + + [id(DISPID_DOM_ELEMENT_NORMALIZE)] + HRESULT normalize(); +} + +[ +local, +object, +dual, +oleautomation, +uuid (2933BF87-7B36-11d2-B20E-00C04F983E60) +] +interface IXMLDOMText : IXMLDOMCharacterData +{ + [id(DISPID_DOM_TEXT_SPLITTEXT)] + HRESULT splitText( + [in] LONG offset, + [retval, out] IXMLDOMText **txtNode); +} + +[ +local, +object, +dual, +oleautomation, +uuid (2933BF88-7B36-11d2-B20E-00C04F983E60) +] +interface IXMLDOMComment : IXMLDOMCharacterData +{ +} + +[ +local, +object, +dual, +oleautomation, +uuid (2933BF89-7B36-11d2-B20E-00C04F983E60) +] +interface IXMLDOMProcessingInstruction : IXMLDOMNode +{ + [propget, id(DISPID_DOM_PI_TARGET)] + HRESULT target([retval, out] BSTR *p); + + [propget, id(DISPID_DOM_PI_DATA)] + HRESULT data([retval, out] BSTR *p); + + [propput, id(DISPID_DOM_PI_DATA)] + HRESULT data([in] BSTR p); +} + +[ +local, +object, +dual, +oleautomation, +uuid (2933BF8A-7B36-11d2-B20E-00C04F983E60) +] +interface IXMLDOMCDATASection : IXMLDOMText +{ +} + +[ +local, +object, +dual, +oleautomation, +uuid (2933BF8B-7B36-11d2-B20E-00C04F983E60) +] +interface IXMLDOMDocumentType : IXMLDOMNode +{ + [propget, id(DISPID_DOM_DOCUMENTTYPE_NAME)] + HRESULT name([retval, out] BSTR *p); + + [propget, id(DISPID_DOM_DOCUMENTTYPE_ENTITIES)] + HRESULT entities([retval, out] IXMLDOMNamedNodeMap **entityMap); + + [propget, id(DISPID_DOM_DOCUMENTTYPE_NOTATIONS)] + HRESULT notations([retval, out] IXMLDOMNamedNodeMap **notationMap); +} + +[ +local, +object, +dual, +oleautomation, +uuid (2933BF8C-7B36-11d2-B20E-00C04F983E60) +] +interface IXMLDOMNotation : IXMLDOMNode +{ + [propget, id(DISPID_DOM_NOTATION_PUBLICID)] + HRESULT publicId([retval, out] VARIANT *id); + + [propget, id(DISPID_DOM_NOTATION_SYSTEMID)] + HRESULT systemId([retval, out] VARIANT *id); +} + +[ +local, +object, +dual, +oleautomation, +uuid (2933BF8D-7B36-11d2-B20E-00C04F983E60) +] +interface IXMLDOMEntity : IXMLDOMNode +{ + [propget, id(DISPID_DOM_ENTITY_PUBLICID)] + HRESULT publicId([retval, out] VARIANT *id1); + + [propget, id(DISPID_DOM_ENTITY_SYSTEMID)] + HRESULT systemId([retval, out] VARIANT *id1); + + [propget, id(DISPID_DOM_ENTITY_NOTATIONNAME)] + HRESULT notationName([retval, out] BSTR *p); +} + +[ +local, +object, +dual, +oleautomation, +uuid (2933BF8E-7B36-11d2-B20E-00C04F983E60) +] +interface IXMLDOMEntityReference : IXMLDOMNode +{ +} + +[ +local, +object, +dual, +oleautomation, +uuid (2933BF8F-7B36-11d2-B20E-00C04F983E60) +] +interface IXMLDOMImplementation : IDispatch +{ + [id(DISPID_DOM_IMPLEMENTATION_HASFEATURE)] + HRESULT hasFeature( + [in] BSTR feature, + [in] BSTR version, + [retval, out] VARIANT_BOOL *pbool); +} + +[ +local, +object, +dual, +oleautomation, +uuid (3efaa425-272f-11d2-836f-0000f87a7782) +] +interface IXTLRuntime : IXMLDOMNode +{ + [id(DISPID_XTLRUNTIME_UNIQUEID)] + HRESULT uniqueID( + [in]IXMLDOMNode *pNode, + [retval, out]LONG *pID); + + [id(DISPID_XTLRUNTIME_DEPTH)] + HRESULT depth( + [in] IXMLDOMNode *pNode, + [retval, out]LONG * pDepth); + + [id(DISPID_XTLRUNTIME_CHILDNUMBER)] + HRESULT childNumber( + [in]IXMLDOMNode *pNode, + [retval, out] LONG *pNumber); + + [id(DISPID_XTLRUNTIME_ANCESTORCHILDNUMBER)] + HRESULT ancestorChildNumber( + [in]BSTR bstr, + [in]IXMLDOMNode *pNode, + [retval, out]LONG *pNumber); + + [id(DISPID_XTLRUNTIME_ABSOLUTECHILDNUMBER)] + HRESULT absoluteChildNumber( + [in]IXMLDOMNode *pNode, + [retval, out]LONG *pNumber); + + [id(DISPID_XTLRUNTIME_FORMATINDEX)] + HRESULT formatIndex( + [in] LONG lIndex, + [in] BSTR bstr, + [retval, out]BSTR *pbstr); + + [id(DISPID_XTLRUNTIME_FORMATNUMBER)] + HRESULT formatNumber( + [in] double dblNumber, + [in] BSTR bstr, + [retval, out]BSTR *pbstr); + + [id(DISPID_XTLRUNTIME_FORMATDATE)] + HRESULT formatDate( + [in] VARIANT var1, + [in] BSTR bstr, + [optional, in] VARIANT var2, + [retval, out]BSTR *pbstr); + + [id(DISPID_XTLRUNTIME_FORMATTIME)] + HRESULT formatTime( + [in] VARIANT var1, + [in] BSTR bstr, + [optional, in] VARIANT var2, + [retval, out]BSTR *pbstr); + +} + +[ + uuid(3efaa427-272f-11d2-836f-0000f87a7782) +] +dispinterface XMLDOMDocumentEvents +{ + properties: + methods: + [id (DISPID_XMLDOMEVENT_ONDATAAVAILABLE)] + HRESULT ondataavailable(); + + [id (DISPID_XMLDOMEVENT_ONREADYSTATECHANGE)] + HRESULT onreadystatechange(); +} + +[ +local, +object, +dual, +oleautomation, +uuid (2933BF92-7B36-11d2-B20E-00C04F983E60) +] +interface IXSLProcessor : IDispatch +{ + [propput, id(DISPID_XMLDOM_PROCESSOR_INPUT)] + HRESULT input([in] VARIANT var); + + [propget, id(DISPID_XMLDOM_PROCESSOR_INPUT)] + HRESULT input([retval, out] VARIANT *var); + + [propget, id(DISPID_XMLDOM_PROCESSOR_XSLTEMPLATE)] + HRESULT ownerTemplate([retval, out] IXSLTemplate **ppTemplate); + + [id(DISPID_XMLDOM_PROCESSOR_SETSTARTMODE)] + HRESULT setStartMode( + [in] BSTR p, + [in, defaultvalue("")] BSTR uri); + + [propget, id(DISPID_XMLDOM_PROCESSOR_STARTMODE)] + HRESULT startMode([retval, out] BSTR *p); + + [propget, id(DISPID_XMLDOM_PROCESSOR_STARTMODEURI)] + HRESULT startModeURI([retval, out] BSTR *uri); + + [propput, id(DISPID_XMLDOM_PROCESSOR_OUTPUT)] + HRESULT output([in] VARIANT var); + + [propget, id(DISPID_XMLDOM_PROCESSOR_OUTPUT)] + HRESULT output([retval, out] VARIANT *var); + + [id(DISPID_XMLDOM_PROCESSOR_TRANSFORM)] + HRESULT transform( + [retval, out] VARIANT_BOOL *pbool); + + [id(DISPID_XMLDOM_PROCESSOR_RESET)] + HRESULT reset(); + + [propget, id(DISPID_XMLDOM_PROCESSOR_READYSTATE)] + HRESULT readyState([retval, out] LONG *pstate); + + [id(DISPID_XMLDOM_PROCESSOR_ADDPARAMETER)] + HRESULT addParameter( + [in] BSTR p, + [in] VARIANT var, + [in, defaultvalue("")] BSTR uri); + + [id(DISPID_XMLDOM_PROCESSOR_ADDOBJECT)] + HRESULT addObject( + [in] IDispatch* obj, + [in] BSTR uri); + + [propget, id(DISPID_XMLDOM_PROCESSOR_STYLESHEET)] + HRESULT stylesheet([retval, out] IXMLDOMNode **node); +} + +[ +local, +object, +dual, +oleautomation, +uuid (2933BF93-7B36-11d2-B20E-00C04F983E60) +] +interface IXSLTemplate : IDispatch +{ + [propputref, id(DISPID_XMLDOM_TEMPLATE_STYLESHEET)] + HRESULT stylesheet([in] IXMLDOMNode *node); + + [propget, id(DISPID_XMLDOM_TEMPLATE_STYLESHEET)] + HRESULT stylesheet([retval, out] IXMLDOMNode **node); + + [id(DISPID_XMLDOM_TEMPLATE_CREATEPROCESSOR)] + HRESULT createProcessor( + [retval, out] IXSLProcessor **ppProcessor); +} + +[ + object, + uuid(ED8C108D-4349-11D2-91A4-00C04F7969E8), + odl, + dual, + oleautomation, + pointer_default(unique) +] +interface IXMLHTTPRequest : IDispatch +{ + [id(1)] + HRESULT open([in] BSTR bstrMethod, [in] BSTR bstrUrl, [in, optional] VARIANT varAsync, + [in,optional] VARIANT username, [in,optional] VARIANT password); + + [id(2)] + HRESULT setRequestHeader([in] BSTR bstrHeader, [in] BSTR bstrValue); + + [id(3)] + HRESULT getResponseHeader([in] BSTR bstrHeader, [out, retval] BSTR * value); + + [id(4)] + HRESULT getAllResponseHeaders([out, retval] BSTR * pbstrHeaders); + + [id(5)] + HRESULT send([in, optional] VARIANT body); + + [id(6)] + HRESULT abort(); + + [propget, id(7)] + HRESULT status([out, retval] LONG *pStatus); + + [propget, id(8)] + HRESULT statusText([out, retval] BSTR *pStatus); + + [propget, id(9)] + HRESULT responseXML([out, retval] IDispatch **pBody); + + [propget, id(10)] + HRESULT responseText([out, retval] BSTR *pBody); + + [propget, id(11)] + HRESULT responseBody([out, retval] VARIANT *pBody); + + [propget, id(12)] + HRESULT responseStream([out, retval] VARIANT *pBody); + + [propget, id(13)] + HRESULT readyState([out, retval] LONG *pState); + + [propput, id(14)] + HRESULT onreadystatechange([in] IDispatch *pReadyStateSink); +}; + +[ +object, +dual, +oleautomation, +uuid(2e9196bf-13ba-4dd4-91ca-6c571f281495) +] +interface IServerXMLHTTPRequest : IXMLHTTPRequest +{ + typedef enum _SERVERXMLHTTP_OPTION + { + SXH_OPTION_URL = -1, + SXH_OPTION_URL_CODEPAGE, + SXH_OPTION_ESCAPE_PERCENT_IN_URL, + SXH_OPTION_IGNORE_SERVER_SSL_CERT_ERROR_FLAGS, + SXH_OPTION_SELECT_CLIENT_SSL_CERT + } SERVERXMLHTTP_OPTION; + + [id(15)] + HRESULT setTimeouts( + [in] long resolveTimeout, + [in] long connectTimeout, + [in] long sendTimeout, + [in] long receiveTimeout); + + [id(16)] + HRESULT waitForResponse( + [in, optional] VARIANT timeoutInSeconds, + [out, retval] VARIANT_BOOL * isSuccessful); + + [id(17)] + HRESULT getOption( + [in] SERVERXMLHTTP_OPTION option, + [out, retval] VARIANT * value); + + [id(18)] + HRESULT setOption( + [in] SERVERXMLHTTP_OPTION option, + [in] VARIANT value); +} + +[ +object, +dual, +oleautomation, +uuid(2e01311b-c322-4b0a-bd77-b90cfdc8dce7) +] +interface IServerXMLHTTPRequest2 : IServerXMLHTTPRequest +{ + typedef enum _SXH_PROXY_SETTING + { + SXH_PROXY_SET_DEFAULT = 0, + SXH_PROXY_SET_PRECONFIG = 0, + SXH_PROXY_SET_DIRECT, + SXH_PROXY_SET_PROXY + } SXH_PROXY_SETTING; + + [id(19)] + HRESULT setProxy( + [in] SXH_PROXY_SETTING proxySetting, + [in, optional] VARIANT varProxyServer, + [in, optional] VARIANT varBypassList); + + [id(20)] + HRESULT setProxyCredentials( + [in] BSTR bstrUserName, + [in] BSTR bstrPassword); +} + +[ +local, +object, +dual, +oleautomation, +uuid (3efaa426-272f-11d2-836f-0000f87a7782) +] +interface IXMLDOMParseError : IDispatch +{ + [propget, id(DISPID_VALUE)] + HRESULT errorCode([retval, out] LONG *errCode); + + [propget, id(DISPID_DOM_ERROR_URL)] + HRESULT url([retval, out] BSTR *p); + + [propget, id(DISPID_DOM_ERROR_REASON)] + HRESULT reason([retval, out] BSTR *p); + + [propget, id(DISPID_DOM_ERROR_SRCTEXT)] + HRESULT srcText([retval, out] BSTR *p); + + [propget, id(DISPID_DOM_ERROR_LINE)] + HRESULT line([retval, out] LONG *lineNo); + + [propget, id(DISPID_DOM_ERROR_LINEPOS)] + HRESULT linepos([retval, out] LONG * linePos); + + [propget, id(DISPID_DOM_ERROR_FILEPOS)] + HRESULT filepos([retval, out] LONG * filePos); +} + +[ +local, +object, +dual, +oleautomation, +uuid (3efaa428-272f-11d2-836f-0000f87a7782) +] +interface IXMLDOMParseError2 : IXMLDOMParseError +{ + [propget, id(DISPID_DOM_ERROR2_ERRORXPATH)] + HRESULT errorXPath([retval, out] BSTR *xpathexpr); + + [propget, id(DISPID_DOM_ERROR2_ALLERRORS)] + HRESULT allErrors([retval, out] IXMLDOMParseErrorCollection **allErrors); + + [id(DISPID_DOM_ERROR2_ERRORPARAMETERS)] + HRESULT errorParameters( + [in] long index, + [retval, out] BSTR *param); + + [propget, id(DISPID_DOM_ERROR2_ERRORPARAMETERSCOUNT)] + HRESULT errorParametersCount([retval, out] long *count); +} + +[ +local, +object, +dual, +oleautomation, +uuid (3efaa429-272f-11d2-836f-0000f87a7782) +] +interface IXMLDOMParseErrorCollection : IDispatch +{ + [propget, id(DISPID_VALUE)] + HRESULT item( + [in] long index, + [retval, out] IXMLDOMParseError2 **error); + + [propget, id(DISPID_DOM_ERRORCOLLECTION_LENGTH)] + HRESULT length( [retval, out] long *length); + + [propget, id(DISPID_DOM_ERRORCOLLECTION_NEXT)] + HRESULT next( [retval, out] IXMLDOMParseError2 **error); + + [id(DISPID_DOM_ERRORCOLLECTION_RESET)] + HRESULT reset(); + + [propget, hidden, restricted, id(DISPID_NEWENUM)] + HRESULT _newEnum( [retval, out] IUnknown **ppunk); +} + +[ + uuid(F6D90F11-9C73-11D3-B32E-00C04F990BB4) +] +coclass DOMDocument +{ + [default] interface IXMLDOMDocument2; + [default, source] dispinterface XMLDOMDocumentEvents; +} + +[ + uuid(f5078f1b-c551-11d3-89b9-0000f81fe221) +] +coclass DOMDocument26 +{ + [default] interface IXMLDOMDocument2; + [default, source] dispinterface XMLDOMDocumentEvents; +} + +[ + uuid(f5078f32-c551-11d3-89b9-0000f81fe221) +] +coclass DOMDocument30 +{ + [default] interface IXMLDOMDocument2; + [default, source] dispinterface XMLDOMDocumentEvents; +} + +[ + uuid(88d969c0-f192-11d4-a65f-0040963251e5) +] +coclass DOMDocument40 +{ + [default] interface IXMLDOMDocument2; + [default, source] dispinterface XMLDOMDocumentEvents; +} + +[ + helpstring("XML DOM Document 6.0"), + progid("Msxml2.DOMDocument.6.0"), + threading(both), + uuid(88d96a05-f192-11d4-a65f-0040963251e5) +] +coclass DOMDocument60 +{ + [default] interface IXMLDOMDocument3; + [default, source] dispinterface XMLDOMDocumentEvents; +} + +[ + uuid(F6D90F12-9C73-11D3-B32E-00C04F990BB4) +] +coclass FreeThreadedDOMDocument +{ + [default] interface IXMLDOMDocument2; + [default, source] dispinterface XMLDOMDocumentEvents; +} + +[ + uuid(f5078f1c-c551-11d3-89b9-0000f81fe221) +] +coclass FreeThreadedDOMDocument26 +{ + [default] interface IXMLDOMDocument2; + [default, source] dispinterface XMLDOMDocumentEvents; +} + +[ + uuid(f5078f33-c551-11d3-89b9-0000f81fe221) +] +coclass FreeThreadedDOMDocument30 +{ + [default] interface IXMLDOMDocument2; + [default, source] dispinterface XMLDOMDocumentEvents; +} + +[ + uuid(88d969c1-f192-11d4-a65f-0040963251e5) +] +coclass FreeThreadedDOMDocument40 +{ + [default] interface IXMLDOMDocument2; + [default, source] dispinterface XMLDOMDocumentEvents; +} + +[ + helpstring("Free threaded XML DOM Document 6.0"), + progid("Msxml2.FreeThreadedDOMDocument.6.0"), + threading(both), + uuid(88d96a06-f192-11d4-a65f-0040963251e5), +] +coclass FreeThreadedDOMDocument60 +{ + [default] interface IXMLDOMDocument3; + [default, source] dispinterface XMLDOMDocumentEvents; +} + +[ + uuid(f6d90f16-9c73-11d3-b32e-00c04f990bb4) +] +coclass XMLHTTP +{ + [default] interface IXMLHTTPRequest; +} + +[ + uuid(f5078f1e-c551-11d3-89b9-0000f81fe221) +] +coclass XMLHTTP26 +{ + [default] interface IXMLHTTPRequest; +} + +[ + uuid(f5078f35-c551-11d3-89b9-0000f81fe221) +] +coclass XMLHTTP30 +{ + [default] interface IXMLHTTPRequest; +} + +[ + uuid(88d969c5-f192-11d4-a65f-0040963251e5) +] +coclass XMLHTTP40 +{ + [default] interface IXMLHTTPRequest; +} + +[ + helpstring("XML HTTP 6.0"), + progid("Msxml2.XMLHTTP.6.0"), + threading(apartment), + uuid(88d96a0a-f192-11d4-a65f-0040963251e5) +] +coclass XMLHTTP60 +{ + [default] interface IXMLHTTPRequest; +} + +[ + uuid(afba6b42-5692-48ea-8141-dc517dcf0ef1) +] +coclass ServerXMLHTTP +{ + [default] interface IServerXMLHTTPRequest; +} + +[ + uuid(afb40ffd-b609-40a3-9828-f88bbe11e4e3) +] +coclass ServerXMLHTTP30 +{ + [default] interface IServerXMLHTTPRequest; +} + +[ + uuid(88d969c6-f192-11d4-a65f-0040963251e5) +] +coclass ServerXMLHTTP40 +{ + [default] interface IServerXMLHTTPRequest2; +} + +[ + helpstring("Server XML HTTP 6.0"), + progid("Msxml2.ServerXMLHTTP.6.0"), + threading(apartment), + uuid(88d96a0b-f192-11d4-a65f-0040963251e5) +] +coclass ServerXMLHTTP60 +{ + [default] interface IServerXMLHTTPRequest2; +} + +[ + uuid(373984c9-b845-449b-91e7-45ac83036ade) +] +coclass XMLSchemaCache +{ + [default] interface IXMLDOMSchemaCollection; +} + +[ + uuid(f5078f1d-c551-11d3-89b9-0000f81fe221) +] +coclass XMLSchemaCache26 +{ + [default] interface IXMLDOMSchemaCollection; +} + +[ + uuid(f5078f34-c551-11d3-89b9-0000f81fe221) +] +coclass XMLSchemaCache30 +{ + [default] interface IXMLDOMSchemaCollection; +} + +[ + uuid(88d969c2-f192-11d4-a65f-0040963251e5) +] +coclass XMLSchemaCache40 +{ + [default] interface IXMLDOMSchemaCollection2; +} + +[ + helpstring("XML Schema Cache 6.0"), + progid("Msxml2.XMLSchemaCache.6.0"), + threading(both), + uuid(88d96a07-f192-11d4-a65f-0040963251e5) +] +coclass XMLSchemaCache60 +{ + [default] interface IXMLDOMSchemaCollection2; +} + +[ + uuid(2933BF94-7B36-11d2-B20E-00C04F983E60) +] +coclass XSLTemplate +{ + [default] interface IXSLTemplate; +} + +[ + uuid(f5078f21-c551-11d3-89b9-0000f81fe221) +] +coclass XSLTemplate26 +{ + [default] interface IXSLTemplate; +} + +[ + uuid(f5078f36-c551-11d3-89b9-0000f81fe221) +] +coclass XSLTemplate30 +{ + [default] interface IXSLTemplate; +} + +[ + uuid(88d969c3-f192-11d4-a65f-0040963251e5) +] +coclass XSLTemplate40 +{ + [default] interface IXSLTemplate; +} + +[ + helpstring("XSL Template 6.0"), + progid("Msxml2.XSLTemplate.6.0"), + threading(both), + uuid(88d96a08-f192-11d4-a65f-0040963251e5) +] +coclass XSLTemplate60 +{ + [default] interface IXSLTemplate; +} + +/* + * Sax Interfaces + */ +[ + object, + local, + uuid(f078abe1-45d2-4832-91ea-4466ce2f25c9) +] +interface ISAXAttributes : IUnknown +{ + HRESULT getLength( + [out, retval] int *length); + + HRESULT getURI( + [in] int nIndex, + [out] const WCHAR **pUrl, + [out] int *pUriSize); + + HRESULT getLocalName( + [in] int nIndex, + [out] const WCHAR **pLocalName, + [out] int *pLocalNameLength); + + HRESULT getQName( + [in] int nIndex, + [out] const WCHAR **pQName, + [out] int *pQNameLength); + + HRESULT getName( + [in] int nIndex, + [out] const WCHAR **pUri, + [out] int * pUriLength, + [out] const WCHAR ** pLocalName, + [out] int * pLocalNameSize, + [out] const WCHAR ** pQName, + [out] int * pQNameLength); + + HRESULT getIndexFromName( + [in] const WCHAR * pUri, + [in] int cUriLength, + [in] const WCHAR * pLocalName, + [in] int cocalNameLength, + [out, retval] int * index); + + HRESULT getIndexFromQName( + [in] const WCHAR * pQName, + [in] int nQNameLength, + [out, retval] int * index); + + HRESULT getType( + [in] int nIndex, + [out] const WCHAR ** pType, + [out] int * pTypeLength); + + HRESULT getTypeFromName( + [in] const WCHAR * pUri, + [in] int nUri, + [in] const WCHAR * pLocalName, + [in] int nLocalName, + [out] const WCHAR ** pType, + [out] int * nType); + + HRESULT getTypeFromQName( + [in] const WCHAR * pQName, + [in] int nQName, + [out] const WCHAR ** pType, + [out] int * nType); + + HRESULT getValue( + [in] int nIndex, + [out] const WCHAR ** pValue, + [out] int * nValue); + + HRESULT getValueFromName( + [in] const WCHAR * pUri, + [in] int nUri, + [in] const WCHAR * pLocalName, + [in] int nLocalName, + [out] const WCHAR ** pValue, + [out] int * nValue); + + HRESULT getValueFromQName( + [in] const WCHAR * pQName, + [in] int nQName, + [out] const WCHAR ** pValue, + [out] int * nValue); +}; + +[ + object, + local, + uuid(1545cdfa-9e4e-4497-a8a4-2bf7d0112c44) +] +interface ISAXContentHandler : IUnknown +{ + HRESULT putDocumentLocator( + [in] ISAXLocator * pLocator); + + HRESULT startDocument(); + + HRESULT endDocument(); + + HRESULT startPrefixMapping( + [in] const WCHAR * pPrefix, + [in] int nPrefix, + [in] const WCHAR * pUri, + [in] int nUri); + + HRESULT endPrefixMapping( + [in] const WCHAR * pPrefix, + [in] int nPrefix); + + HRESULT startElement( + [in] const WCHAR * pNamespaceUri, + [in] int nNamespaceUri, + [in] const WCHAR * pLocalName, + [in] int nLocalName, + [in] const WCHAR * pQName, + [in] int nQName, + [in] ISAXAttributes * pAttr); + + HRESULT endElement( + [in] const WCHAR * pNamespaceUri, + [in] int nNamespaceUri, + [in] const WCHAR * pLocalName, + [in] int nLocalName, + [in] const WCHAR * pQName, + [in] int nQName); + + HRESULT characters( + [in] const WCHAR * pChars, + [in] int nChars); + + HRESULT ignorableWhitespace( + [in] const WCHAR * pChars, + [in] int nChars); + + HRESULT processingInstruction( + [in] const WCHAR * pTarget, + [in] int nTarget, + [in] const WCHAR * pData, + [in] int nData); + + HRESULT skippedEntity( + [in] const WCHAR * pName, + [in] int nName); +}; + +[ + object, + local, + uuid(862629ac-771a-47b2-8337-4e6843c1be90) +] +interface ISAXDeclHandler : IUnknown +{ + HRESULT elementDecl( + [in] const WCHAR * pName, + [in] int nName, + [in] const WCHAR * pModel, + [in] int nModel); + + HRESULT attributeDecl( + [in] const WCHAR * pElementName, + [in] int nElementName, + [in] const WCHAR * pAttributeName, + [in] int nAttributeName, + [in] const WCHAR * pType, + [in] int nType, + [in] const WCHAR * pValueDefault, + [in] int nValueDefault, + [in] const WCHAR * pValue, + [in] int nValue); + + HRESULT internalEntityDecl( + [in] const WCHAR * pName, + [in] int nName, + [in] const WCHAR * pValue, + [in] int nValue); + + HRESULT externalEntityDecl( + [in] const WCHAR * pName, + [in] int nName, + [in] const WCHAR * pPublicId, + [in] int nPublicId, + [in] const WCHAR * pSystemId, + [in] int nSystemId); +}; + +[ + object, + local, + uuid(e15c1baf-afb3-4d60-8c36-19a8c45defed) +] +interface ISAXDTDHandler : IUnknown +{ + HRESULT notationDecl( + [in] const WCHAR * pName, + [in] int nName, + [in] const WCHAR * pPublicId, + [in] int nPublicId, + [in] const WCHAR * pSystemId, + [in] int nSystemId); + + HRESULT unparsedEntityDecl( + [in] const WCHAR * pName, + [in] int nName, + [in] const WCHAR * pPublicId, + [in] int nPublicId, + [in] const WCHAR * pSystemId, + [in] int nSystemId, + [in] const WCHAR * pNotationName, + [in] int nNotationName); +}; + +[ + object, + local, + uuid(99bca7bd-e8c4-4d5f-a0cf-6d907901ff07), +] +interface ISAXEntityResolver : IUnknown +{ + HRESULT resolveEntity( + [in] const WCHAR * pPublicId, + [in] const WCHAR * pSystemId, + [out, retval] VARIANT * ret); +}; + +[ + object, + local, + uuid(a60511c4-ccf5-479e-98a3-dc8dc545b7d0) +] +interface ISAXErrorHandler : IUnknown +{ + HRESULT error( + [in] ISAXLocator * pLocator, + [in] const WCHAR * pErrorMessage, + [in] HRESULT hrErrorCode); + + HRESULT fatalError( + [in] ISAXLocator * pLocator, + [in] const WCHAR * pErrorMessage, + [in] HRESULT hrErrorCode); + + HRESULT ignorableWarning( + [in] ISAXLocator * pLocator, + [in] const WCHAR * pErrorMessage, + [in] HRESULT hrErrorCode); +}; + +[ + object, + local, + uuid(7f85d5f5-47a8-4497-bda5-84ba04819ea6) +] +interface ISAXLexicalHandler : IUnknown +{ + HRESULT startDTD( + [in] const WCHAR * pName, + [in] int nName, + [in] const WCHAR * pPublicId, + [in] int nPublicId, + [in] const WCHAR * pSystemId, + [in] int nSystemId); + + HRESULT endDTD(); + + HRESULT startEntity( + [in] const WCHAR * pName, + [in] int nName); + + HRESULT endEntity( + [in] const WCHAR * pName, + [in] int nName); + + HRESULT startCDATA(); + + HRESULT endCDATA(); + + HRESULT comment( + [in] const WCHAR * pChars, + [in] int nChars); +}; + +[ + object, + local, + uuid(9b7e472a-0de4-4640-bff3-84d38a051c31) +] +interface ISAXLocator : IUnknown +{ + HRESULT getColumnNumber( + [out, retval] int * nColumn); + + HRESULT getLineNumber( + [out, retval] int * nLine); + + HRESULT getPublicId( + [out, retval] const WCHAR ** publicId); + + HRESULT getSystemId( + [out, retval] const WCHAR ** systemId); +}; + +[ + local, + object, + uuid(70409222-ca09-4475-acb8-40312fe8d145) +] +interface ISAXXMLFilter : ISAXXMLReader +{ + HRESULT getParent( + [out, retval] ISAXXMLReader ** pReader); + HRESULT putParent( + [in] ISAXXMLReader * reader); +}; + +[ +local, +object, +uuid (a4f96ed0-f829-476e-81c0-cdc7bd2a0802) +] +interface ISAXXMLReader : IUnknown +{ + HRESULT getFeature( + [in] const WCHAR * pFeature, + [out, retval] VARIANT_BOOL * pValue); + HRESULT putFeature( + [in] const WCHAR * pFeature, + [in] VARIANT_BOOL vfValue); + + HRESULT getProperty( + [in] const WCHAR * pProp, + [out, retval] VARIANT * pValue); + HRESULT putProperty( + [in] const WCHAR * pProp, + [in] VARIANT value); + + HRESULT getEntityResolver( + [out, retval] ISAXEntityResolver ** ppEntityResolver); + HRESULT putEntityResolver( + [in] ISAXEntityResolver * pEntityResolver); + + HRESULT getContentHandler( + [out, retval] ISAXContentHandler ** pContentHandler); + HRESULT putContentHandler( + [in] ISAXContentHandler * contentHandler); + + HRESULT getDTDHandler( + [out, retval] ISAXDTDHandler ** pDTDHandler); + HRESULT putDTDHandler( + [in] ISAXDTDHandler * pDTDHandler); + + HRESULT getErrorHandler( + [out, retval] ISAXErrorHandler ** pErrorHandler); + HRESULT putErrorHandler( + [in] ISAXErrorHandler * errorHandler); + + HRESULT getBaseURL( + [out, retval] const WCHAR ** pBaseUrl); + HRESULT putBaseURL( + [in] const WCHAR * pBaseUrl); + + HRESULT getSecureBaseURL( + [out, retval] const WCHAR ** pSecureBaseUrl); + HRESULT putSecureBaseURL( + [in] const WCHAR * secureBaseUrl); + + HRESULT parse( + [in] VARIANT varInput); + HRESULT parseURL( + [in] const WCHAR * url); +} + +[ + object, + dual, + oleautomation, + uuid(10dc0586-132b-4cac-8bb3-db00ac8b7ee0) +] +interface IVBSAXAttributes : IDispatch +{ + [propget, id(DISPID_SAX_ATTRIBUTES_LENGTH)] + HRESULT length( [out, retval] int * nLength); + + [id(DISPID_SAX_ATTRIBUTES_GETURI)] + HRESULT getURI( [in] int nIndex, [out, retval] BSTR * uri); + + [id(DISPID_SAX_ATTRIBUTES_GETLOCALNAME)] + HRESULT getLocalName( [in] int nIndex, [out, retval] BSTR * localName); + + [id(DISPID_SAX_ATTRIBUTES_GETQNAME)] + HRESULT getQName( [in] int nIndex, [out, retval] BSTR * QName); + + [id(DISPID_SAX_ATTRIBUTES_GETINDEXFROMNAME)] + HRESULT getIndexFromName( [in] BSTR uri, + [in] BSTR localName, [out, retval] int * nIndex); + + [id(DISPID_SAX_ATTRIBUTES_GETINDEXFROMQNAME)] + HRESULT getIndexFromQName( [in] BSTR QName, [out, retval] int * nIndex); + + [id(DISPID_SAX_ATTRIBUTES_GETTYPE)] + HRESULT getType( [in] int nIndex, [out, retval] BSTR * type); + + [id(DISPID_SAX_ATTRIBUTES_GETTYPEFROMNAME)] + HRESULT getTypeFromName( [in] BSTR uri, [in] BSTR localName, + [out, retval] BSTR * type); + + [id(DISPID_SAX_ATTRIBUTES_GETTYPEFROMQNAME)] + HRESULT getTypeFromQName( [in] BSTR QName, [out, retval] BSTR * type); + + [id(DISPID_SAX_ATTRIBUTES_GETVALUE)] + HRESULT getValue( [in] int nIndex, [out, retval] BSTR * value); + + [id(DISPID_SAX_ATTRIBUTES_GETVALUEFROMNAME)] + HRESULT getValueFromName( [in] BSTR uri, + [in] BSTR localName, + [out, retval] BSTR * value); + + [id(DISPID_SAX_ATTRIBUTES_GETVALUEFROMQNAME)] + HRESULT getValueFromQName( [in] BSTR QName, [out, retval] BSTR * value); +}; + +[ + object, + dual, + oleautomation, + uuid(2ed7290a-4dd5-4b46-bb26-4e4155e77faa) +] +interface IVBSAXContentHandler : IDispatch +{ + [propputref, id(DISPID_SAX_CONTENTHANDLER_DOCUMENTLOCATOR)] + HRESULT documentLocator( [in] IVBSAXLocator * oLocator); + + [id(DISPID_SAX_CONTENTHANDLER_STARTDOCUMENT)] + HRESULT startDocument(); + + [id(DISPID_SAX_CONTENTHANDLER_ENDDOCUMENT)] + HRESULT endDocument(); + + [id(DISPID_SAX_CONTENTHANDLER_STARTPREFIXMAPPING)] + HRESULT startPrefixMapping( [in, out] BSTR * prefix, [in, out] BSTR * uri); + + [id(DISPID_SAX_CONTENTHANDLER_ENDPREFIXMAPPING)] + HRESULT endPrefixMapping( [in, out] BSTR * prefix); + + [id(DISPID_SAX_CONTENTHANDLER_STARTELEMENT)] + HRESULT startElement( [in, out] BSTR * namespaceURI, + [in, out] BSTR * localName, + [in, out] BSTR * QName, + [in] IVBSAXAttributes * oAttributes); + + [id(DISPID_SAX_CONTENTHANDLER_ENDELEMENT)] + HRESULT endElement( [in, out] BSTR * namespaceURI, + [in, out] BSTR * localName, [in, out] BSTR * strQName); + + [id(DISPID_SAX_CONTENTHANDLER_CHARACTERS)] + HRESULT characters( [in, out] BSTR * chars); + + [id(DISPID_SAX_CONTENTHANDLER_IGNORABLEWHITESPACE)] + HRESULT ignorableWhitespace( [in, out] BSTR * chars); + + [id(DISPID_SAX_CONTENTHANDLER_PROCESSINGINSTRUCTION)] + HRESULT processingInstruction( [in, out] BSTR * target, + [in, out] BSTR * data); + + [id(DISPID_SAX_CONTENTHANDLER_SKIPPEDENTITY)] + HRESULT skippedEntity( [in, out] BSTR * name); +}; + +[ + object, + dual, + oleautomation, + uuid(e8917260-7579-4be1-b5dd-7afbfa6f077b) +] +interface IVBSAXDeclHandler : IDispatch +{ + [id(DISPID_SAX_DECLHANDLER_ELEMENTDECL)] + HRESULT elementDecl( + [in, out] BSTR * name, + [in, out] BSTR * model); + + [id(DISPID_SAX_DECLHANDLER_ATTRIBUTEDECL)] + HRESULT attributeDecl( + [in, out] BSTR * elementName, + [in, out] BSTR * attributeName, + [in, out] BSTR * type, + [in, out] BSTR * valueDefault, + [in, out] BSTR * value); + + [id(DISPID_SAX_DECLHANDLER_INTERNALENTITYDECL)] + HRESULT internalEntityDecl( + [in, out] BSTR * name, + [in, out] BSTR * value); + + [id(DISPID_SAX_DECLHANDLER_EXTERNALENTITYDECL)] + HRESULT externalEntityDecl( + [in, out] BSTR * name, + [in, out] BSTR * publicId, + [in, out] BSTR * systemId); +}; + +[ + object, + dual, + oleautomation, + uuid(24fb3297-302d-4620-ba39-3a732d850558) +] +interface IVBSAXDTDHandler : IDispatch +{ + [id(DISPID_SAX_DTDHANDLER_NOTATIONDECL)] + HRESULT notationDecl( + [in, out] BSTR * name, + [in, out] BSTR * publicId, + [in, out] BSTR * systemId); + + [id(DISPID_SAX_DTDHANDLER_UNPARSEDENTITYDECL)] + HRESULT unparsedEntityDecl( + [in, out] BSTR * name, + [in, out] BSTR * publicId, + [in, out] BSTR * systemId, + [in, out] BSTR * notationName); +}; + +[ + object, + dual, + oleautomation, + uuid(0c05d096-f45b-4aca-ad1a-aa0bc25518dc) +] +interface IVBSAXEntityResolver : IDispatch +{ + [id(DISPID_SAX_ENTITYRESOLVER_RESOLVEENTITY)] + HRESULT resolveEntity( + [in, out] BSTR * publicId, + [in, out] BSTR * systemId, + [out, retval] VARIANT * ret); +}; + +[ + object, + dual, + oleautomation, + uuid(d963d3fe-173c-4862-9095-b92f66995f52) +] +interface IVBSAXErrorHandler : IDispatch +{ + [id(DISPID_SAX_ERRORHANDLER_ERROR)] + HRESULT error( + [in] IVBSAXLocator * locator, + [in, out] BSTR * errorMessage, + [in] LONG errorCode); + + [id(DISPID_SAX_ERRORHANDLER_FATALERROR)] + HRESULT fatalError( + [in] IVBSAXLocator * locator, + [in, out] BSTR * errorMessage, + [in] LONG errorCode); + + [id(DISPID_SAX_ERRORHANDLER_IGNORABLEWARNING)] + HRESULT ignorableWarning( + [in] IVBSAXLocator * locator, + [in, out] BSTR * errorMessage, + [in] LONG errorCode); +}; + +[ + object, + dual, + oleautomation, + uuid(032aac35-8c0e-4d9d-979f-e3b702935576) +] +interface IVBSAXLexicalHandler : IDispatch +{ + [id(DISPID_SAX_LEXICALHANDLER_STARTDTD)] + HRESULT startDTD( + [in, out] BSTR * name, + [in, out] BSTR * publicId, + [in, out] BSTR * systemId); + [id(DISPID_SAX_LEXICALHANDLER_ENDDTD)] + HRESULT endDTD(); + + [id(DISPID_SAX_LEXICALHANDLER_STARTENTITY)] + HRESULT startEntity([in, out] BSTR * name); + [id(DISPID_SAX_LEXICALHANDLER_ENDENTITY)] + HRESULT endEntity([in, out] BSTR * name); + + [id(DISPID_SAX_LEXICALHANDLER_STARTCDATA)] + HRESULT startCDATA(); + [id(DISPID_SAX_LEXICALHANDLER_ENDCDATA)] + HRESULT endCDATA(); + + [id(DISPID_SAX_LEXICALHANDLER_COMMENT)] + HRESULT comment( [in, out] BSTR * chars); +}; + +[ + object, + dual, + oleautomation, + uuid(796e7ac5-5aa2-4eff-acad-3faaf01a3288) +] +interface IVBSAXLocator : IDispatch +{ + [propget, id(DISPID_SAX_LOCATOR_COLUMNNUMBER)] + HRESULT columnNumber( [out, retval] int * column); + + [propget, id(DISPID_SAX_LOCATOR_LINENUMBER)] + HRESULT lineNumber( [out, retval] int * line); + + [propget, id(DISPID_SAX_LOCATOR_PUBLICID)] + HRESULT publicId( [out, retval] BSTR * publicId); + + [propget, id(DISPID_SAX_LOCATOR_SYSTEMID)] + HRESULT systemId( [out, retval] BSTR * systemId); +}; + +[ + object, + dual, + oleautomation, + uuid(1299eb1b-5b88-433e-82de-82ca75ad4e04) +] +interface IVBSAXXMLFilter : IDispatch +{ + [propget, id(DISPID_SAX_XMLFILTER_PARENT)] + HRESULT parent( [out, retval] IVBSAXXMLReader ** reader); + [propputref, id(DISPID_SAX_XMLFILTER_PARENT)] + HRESULT parent( [in] IVBSAXXMLReader * reader); + +}; + +[ + dual, + oleautomation, + object, + uuid (8c033caa-6cd6-4f73-b728-4531af74945f) +] +interface IVBSAXXMLReader : IDispatch +{ + [id(DISPID_SAX_XMLREADER_GETFEATURE)] + HRESULT getFeature( [in] const WCHAR * pFeature, + [out, retval] VARIANT_BOOL * pValue); + [id(DISPID_SAX_XMLREADER_PUTFEATURE)] + HRESULT putFeature( [in] const WCHAR * pFeature, + [in] VARIANT_BOOL vfValue); + + [id(DISPID_SAX_XMLREADER_GETPROPERTY)] + HRESULT getProperty( [in] const WCHAR * pProp, + [out, retval] VARIANT * pValue); + [id(DISPID_SAX_XMLREADER_PUTPROPERTY)] + HRESULT putProperty( [in] const WCHAR * pProp, [in] VARIANT value); + + [propget, id(DISPID_SAX_XMLREADER_ENTITYRESOLVER)] + HRESULT entityResolver( + [out, retval] IVBSAXEntityResolver ** ppEntityResolver); + [propputref, id(DISPID_SAX_XMLREADER_ENTITYRESOLVER)] + HRESULT entityResolver( [in] IVBSAXEntityResolver * pEntityResolver); + + [propget, id(DISPID_SAX_XMLREADER_CONTENTHANDLER)] + HRESULT contentHandler( + [out, retval] IVBSAXContentHandler ** pContentHandler); + [propputref, id(DISPID_SAX_XMLREADER_CONTENTHANDLER)] + HRESULT contentHandler([in] IVBSAXContentHandler * contentHandler); + + [propget, id(DISPID_SAX_XMLREADER_DTDHANDLER)] + HRESULT dtdHandler([out, retval] IVBSAXDTDHandler ** pDTDHandler); + [propputref, id(DISPID_SAX_XMLREADER_DTDHANDLER)] + HRESULT dtdHandler([in] IVBSAXDTDHandler * pDTDHandler); + + [propget, id(DISPID_SAX_XMLREADER_ERRORHANDLER)] + HRESULT errorHandler([out, retval] IVBSAXErrorHandler ** pErrorHandler); + [propputref, id(DISPID_SAX_XMLREADER_ERRORHANDLER)] + HRESULT errorHandler([in] IVBSAXErrorHandler * errorHandler); + + [propget, id(DISPID_SAX_XMLREADER_BASEURL)] + HRESULT baseURL([out, retval] const WCHAR ** pBaseUrl); + [propput, id(DISPID_SAX_XMLREADER_BASEURL)] + HRESULT baseURL([in] const WCHAR * pBaseUrl); + + [propget, id(DISPID_SAX_XMLREADER_SECUREBASEURL)] + HRESULT secureBaseURL([out, retval] const WCHAR ** pSecureBaseUrl); + [propput, id(DISPID_SAX_XMLREADER_SECUREBASEURL)] + HRESULT secureBaseURL([in] const WCHAR * secureBaseUrl); + + [id(DISPID_SAX_XMLREADER_PARSE)] + HRESULT parse( [in] VARIANT varInput); + [id(DISPID_SAX_XMLREADER_PARSEURL)] + HRESULT parseURL([in] const WCHAR * url); +} + +[ + object, + dual, + oleautomation, + uuid(f10d27cc-3ec0-415c-8ed8-77ab1c5e7262) +] +interface IMXAttributes : IDispatch +{ + [id(DISPID_MX_ATTRIBUTES_ADDATTRIBUTE)] + HRESULT addAttribute( + [in] BSTR uri, + [in] BSTR localName, + [in] BSTR QName, + [in] BSTR type, + [in] BSTR value); + + [id(DISPID_MX_ATTRIBUTES_ADDATTRIBUTEFROMINDEX)] + HRESULT addAttributeFromIndex( [in] VARIANT atts, + [in] int index); + + [id(DISPID_MX_ATTRIBUTES_CLEAR)] + HRESULT clear(); + + [id(DISPID_MX_ATTRIBUTES_REMOVEATTRIBUTE)] + HRESULT removeAttribute( [in] int index); + + [id(DISPID_MX_ATTRIBUTES_SETATTRIBUTE)] + HRESULT setAttribute( + [in] int index, + [in] BSTR uri, + [in] BSTR localName, + [in] BSTR QName, + [in] BSTR type, + [in] BSTR value); + + [id(DISPID_MX_ATTRIBUTES_SETATTRIBUTES)] + HRESULT setAttributes( [in] VARIANT atts); + + [id(DISPID_MX_ATTRIBUTES_SETLOCALNAME)] + HRESULT setLocalName( [in] int index, + [in] BSTR localName); + + [id(DISPID_MX_ATTRIBUTES_SETQNAME)] + HRESULT setQName( + [in] int index, + [in] BSTR QName); + + [id(DISPID_MX_ATTRIBUTES_SETTYPE)] + HRESULT setType( [in] int index, [in] BSTR type); + + [id(DISPID_MX_ATTRIBUTES_SETURI)] + HRESULT setURI( [in] int index, [in] BSTR uri); + + [id(DISPID_MX_ATTRIBUTES_SETVALUE)] + HRESULT setValue([in] int index, [in] BSTR value); +}; + +[ + local, + object, + dual, + oleautomation, + uuid(fa4bb38c-faf9-4cca-9302-d1dd0fe520db) +] +interface IMXSchemaDeclHandler : IDispatch +{ + [id(DISPID_MX_SCHEMADECLHANDLER_SCHEMAELEMENTDECL)] + HRESULT schemaElementDecl( [in] ISchemaElement *oSchemaElement ); +} + +[ + object, + dual, + oleautomation, + uuid(808f4e35-8d5a-4fbe-8466-33a41279ed30) +] +interface IMXReaderControl : IDispatch +{ + [id(DISPID_MX_READER_CONTROL_ABORT)] + HRESULT abort(); + + [id(DISPID_MX_READER_CONTROL_RESUME)] + HRESULT resume(); + + [id(DISPID_MX_READER_CONTROL_SUSPEND)] + HRESULT suspend(); +}; + +[ + object, + dual, + oleautomation, + uuid(4d7ff4ba-1565-4ea8-94e1-6e724a46f98d) +] +interface IMXWriter : IDispatch +{ + [propput, id(DISPID_MX_WRITER_OUTPUT)] + HRESULT output ( [in] VARIANT Destination); + [propget, id(DISPID_MX_WRITER_OUTPUT)] + HRESULT output ( [out, retval] VARIANT * Destination); + + [propput, id(DISPID_MX_WRITER_ENCODING)] + HRESULT encoding ([in] BSTR encoding); + [propget, id(DISPID_MX_WRITER_ENCODING)] + HRESULT encoding ([out, retval] BSTR * encoding); + + [propput, id(DISPID_MX_WRITER_BYTEORDERMARK)] + HRESULT byteOrderMark ([in] VARIANT_BOOL writeByteOrderMark); + [propget, id(DISPID_MX_WRITER_BYTEORDERMARK)] + HRESULT byteOrderMark ([out, retval] VARIANT_BOOL * writeByteOrderMark); + + [propput, id(DISPID_MX_WRITER_INDENT)] + HRESULT indent ([in] VARIANT_BOOL indentMode); + [propget, id(DISPID_MX_WRITER_INDENT)] + HRESULT indent ([out, retval] VARIANT_BOOL * indentMode); + + [propput, id(DISPID_MX_WRITER_STANDALONE)] + HRESULT standalone ([in] VARIANT_BOOL value); + [propget, id(DISPID_MX_WRITER_STANDALONE)] + HRESULT standalone ([out, retval] VARIANT_BOOL * value); + + [propput, id(DISPID_MX_WRITER_OMITXMLDECLARATION)] + HRESULT omitXMLDeclaration ([in] VARIANT_BOOL value); + [propget, id(DISPID_MX_WRITER_OMITXMLDECLARATION)] + HRESULT omitXMLDeclaration ([out, retval] VARIANT_BOOL * value); + + [propput, id(DISPID_MX_WRITER_VERSION)] + HRESULT version ([in] BSTR version); + [propget, id(DISPID_MX_WRITER_VERSION)] + HRESULT version ([out, retval] BSTR * version); + + [propput, id(DISPID_MX_WRITER_DISABLEOUTPUTESCAPING)] + HRESULT disableOutputEscaping([in] VARIANT_BOOL value); + [propget, id(DISPID_MX_WRITER_DISABLEOUTPUTESCAPING)] + HRESULT disableOutputEscaping([out, retval] VARIANT_BOOL * value); + + [id(DISPID_MX_WRITER_FLUSH)] + HRESULT flush(); +}; + +[ + local, + object, + dual, + oleautomation, + uuid(c90352f4-643c-4fbc-bb23-e996eb2d51fd) +] +interface IMXNamespacePrefixes : IDispatch +{ + [propget, id(DISPID_VALUE)] + HRESULT item( + [in] long index, + [out, retval] BSTR *prefix); + + [propget, id(DISPID_MX_NSMGR_LENGTH)] + HRESULT length( [out,retval] long *length ); + + [propget, restricted, hidden, id(DISPID_NEWENUM)] + HRESULT _newEnum( [out, retval] IUnknown **ppUnk ); +} + +[ + local, + object, + hidden, + uuid(c90352f6-643c-4fbc-bb23-e996eb2d51fd) +] +interface IMXNamespaceManager : IUnknown +{ + HRESULT putAllowOverride([in] VARIANT_BOOL fOverride); + + HRESULT getAllowOverride([out, retval] VARIANT_BOOL *fOverride); + + HRESULT reset(); + + HRESULT pushContext(); + + HRESULT pushNodeContext( + [in] IXMLDOMNode *contextNode, + [in] VARIANT_BOOL fDeep); + + HRESULT popContext(); + + HRESULT declarePrefix( + [in] const WCHAR *prefix, + [in] const WCHAR *namespaceURI); + + HRESULT getDeclaredPrefix( + [in] long nIndex, + [in, out] WCHAR *pwchPrefix, + [in, out] int *pcchPrefix); + + HRESULT getPrefix( + [in] const WCHAR *pwszNamespaceURI, + [in] long nIndex, + [in, out] WCHAR *pwchPrefix, + [in, out] int *pcchPrefix); + + HRESULT getURI( + [in] const WCHAR *pwchPrefix, + [in] IXMLDOMNode* pContextNode, + [in, out] WCHAR *pwchUri, + [in, out] int *pcchUri); +} + +[ + local, + object, + dual, + oleautomation, + uuid(c90352f5-643c-4fbc-bb23-e996eb2d51fd) +] +interface IVBMXNamespaceManager : IDispatch +{ + [propput, id(DISPID_MX_NSMGR_ALLOWOVERRIDE)] + HRESULT allowOverride([in] VARIANT_BOOL fOverride); + + [propget, id(DISPID_MX_NSMGR_ALLOWOVERRIDE)] + HRESULT allowOverride([out,retval] VARIANT_BOOL* fOverride); + + [id(DISPID_MX_NSMGR_RESET)] + HRESULT reset(); + + [id(DISPID_MX_NSMGR_PUSHCONTEXT)] + HRESULT pushContext(); + + [id(DISPID_MX_NSMGR_PUSHNODECONTEXT)] + HRESULT pushNodeContext( + [in] IXMLDOMNode* contextNode, + [in, defaultvalue(-1)] VARIANT_BOOL fDeep); + + [id(DISPID_MX_NSMGR_POPCONTEXT)] + HRESULT popContext(); + + [id(DISPID_MX_NSMGR_DECLAREPREFIX)] + HRESULT declarePrefix( + [in] BSTR prefix, + [in] BSTR namespaceURI); + + [id(DISPID_MX_NSMGR_GETDECLAREDPREFIXES)] + HRESULT getDeclaredPrefixes([out, retval] IMXNamespacePrefixes** prefixes); + + [id(DISPID_MX_NSMGR_GETPREFIXES)] + HRESULT getPrefixes( + [in] BSTR namespaceURI, + [out, retval] IMXNamespacePrefixes** prefixes); + + [id(DISPID_MX_NSMGR_GETURI)] + HRESULT getURI( + [in] BSTR prefix, + [out, retval] VARIANT* uri); + + [id(DISPID_MX_NSMGR_GETURIFROMNODE)] + HRESULT getURIFromNode( + [in] BSTR strPrefix, + [in] IXMLDOMNode* contextNode, + [out, retval] VARIANT* uri); +} + +[ + local, + object, + dual, + oleautomation, + uuid(c90352f7-643c-4fbc-bb23-e996eb2d51fd) +] +interface IMXXMLFilter : IDispatch +{ + [id(DISPID_MXXML_FILTER_GETFEATURE)] + HRESULT getFeature( + [in] BSTR strName, + [out, retval] VARIANT_BOOL * fValue); + + [id(DISPID_MXXML_FILTER_PUTFEATURE)] + HRESULT putFeature( + [in] BSTR strName, + [in] VARIANT_BOOL fValue); + + [id(DISPID_MXXML_FILTER_GETPROPERTY)] + HRESULT getProperty( + [in] BSTR strName, + [out, retval] VARIANT * varValue); + + [id(DISPID_MXXML_FILTER_PUTPROPERTY)] + HRESULT putProperty( + [in] BSTR strName, + [in] VARIANT varValue); + + [id(DISPID_MXXML_FILTER_ENTITYRESOLVER), propget] + HRESULT entityResolver( [out, retval] IUnknown **oResolver ); + + [id(DISPID_MXXML_FILTER_ENTITYRESOLVER), propputref] + HRESULT entityResolver( [in] IUnknown *oResolver ); + + [id(DISPID_MXXML_FILTER_CONTENTHANDLER), propget] + HRESULT contentHandler( [out, retval] IUnknown **oHandler ); + + [id(DISPID_MXXML_FILTER_CONTENTHANDLER), propputref] + HRESULT contentHandler( [in] IUnknown *oHandler ); + + [id(DISPID_MXXML_FILTER_DTDHANDLER), propget] + HRESULT dtdHandler( [out, retval] IUnknown **oHandler ); + + [id(DISPID_MXXML_FILTER_DTDHANDLER), propputref] + HRESULT dtdHandler( [in] IUnknown *oHandler ); + + [id(DISPID_MXXML_FILTER_ERRORHANDLER), propget] + HRESULT errorHandler( [out, retval] IUnknown **oHandler ); + + [id(DISPID_MXXML_FILTER_ERRORHANDLER), propputref] + HRESULT errorHandler( [in] IUnknown *oHandler ); +} + +[ + local, + object, + uuid(50ea08b1-dd1b-4664-9a50-c2f40f4bd79a), + oleautomation, + dual +] +interface ISchemaStringCollection : IDispatch +{ + [id(DISPID_VALUE), propget] + HRESULT item( + [in] long index, + [out,retval] BSTR* bstr); + + [id(DISPID_SOM_LENGTH), propget] + HRESULT length( + [out,retval] long* length); + + [id(DISPID_NEWENUM), hidden, restricted, propget] + HRESULT _newEnum( + [out,retval] IUnknown** ppunk); +}; + +[ + local, + object, + uuid(50ea08b2-dd1b-4664-9a50-c2f40f4bd79a), + oleautomation, + dual +] +interface ISchemaItemCollection : IDispatch +{ + [id(DISPID_VALUE), propget] + HRESULT item( + [in] long index, + [out,retval]ISchemaItem** item); + + [id(DISPID_SOM_ITEMBYNAME)] + HRESULT itemByName( + [in] BSTR name, + [out,retval] ISchemaItem** item); + + [id(DISPID_SOM_ITEMBYQNAME)] + HRESULT itemByQName( + [in] BSTR name, + [in] BSTR namespaceURI, + [out,retval] ISchemaItem** item); + + [id(DISPID_SOM_LENGTH), propget] + HRESULT length( + [out,retval]long* length); + + [id(DISPID_NEWENUM), hidden, restricted, propget] + HRESULT _newEnum( + [out,retval]IUnknown** ppunk); +}; + +[ + local, + object, + uuid(50ea08b3-dd1b-4664-9a50-c2f40f4bd79a), + oleautomation, + dual +] +interface ISchemaItem : IDispatch +{ + [id(DISPID_SOM_NAME), propget] + HRESULT name( + [out,retval] BSTR* name); + + [id(DISPID_SOM_NAMESPACEURI), propget] + HRESULT namespaceURI( + [out,retval] BSTR* namespaceURI); + + [id(DISPID_SOM_SCHEMA), propget] + HRESULT schema( + [out,retval] ISchema** schema); + + [id(DISPID_SOM_ID), propget] + HRESULT id( + [out,retval] BSTR* id); + + [id(DISPID_SOM_ITEMTYPE), propget] + HRESULT itemType( + [out,retval] SOMITEMTYPE* itemType); + + [id(DISPID_SOM_UNHANDLEDATTRS), propget] + HRESULT unhandledAttributes( + [out,retval] IVBSAXAttributes** attributes); + + [id(DISPID_SOM_WRITEANNOTATION)] + HRESULT writeAnnotation( + [in] IUnknown* annotationSink, + [out,retval] VARIANT_BOOL* isWritten); +}; + +[ + local, + object, + uuid(50ea08b4-dd1b-4664-9a50-c2f40f4bd79a), + oleautomation, + dual +] +interface ISchema : ISchemaItem +{ + [id(DISPID_SOM_TARGETNAMESPACE), propget] + HRESULT targetNamespace( + [out,retval] BSTR* targetNamespace); + + [id(DISPID_SOM_VERSION), propget] + HRESULT version( + [out,retval] BSTR* version); + + [id(DISPID_SOM_TYPES), propget] + HRESULT types( + [out,retval] ISchemaItemCollection** types); + + [id(DISPID_SOM_ELEMENTS), propget] + HRESULT elements( + [out,retval] ISchemaItemCollection** elements); + + [id(DISPID_SOM_ATTRIBUTES), propget] + HRESULT attributes( + [out,retval] ISchemaItemCollection** attributes); + + [id(DISPID_SOM_ATTRIBUTEGROUPS), propget] + HRESULT attributeGroups( + [out,retval] ISchemaItemCollection** attributeGroups); + + [id(DISPID_SOM_MODELGROUPS), propget] + HRESULT modelGroups( + [out,retval] ISchemaItemCollection** modelGroups); + + [id(DISPID_SOM_NOTATIONS), propget] + HRESULT notations( + [out,retval] ISchemaItemCollection** notations); + + [id(DISPID_SOM_SCHEMALOCATIONS), propget] + HRESULT schemaLocations( + [out,retval] ISchemaStringCollection** schemaLocations); +}; + +[ + local, + object, + uuid(50ea08b5-dd1b-4664-9a50-c2f40f4bd79a), + oleautomation, + dual +] +interface ISchemaParticle : ISchemaItem +{ + [id(DISPID_SOM_MINOCCURS), propget] + HRESULT minOccurs( + [out,retval] VARIANT* minOccurs); + + [id(DISPID_SOM_MAXOCCURS), propget] + HRESULT maxOccurs( + [out,retval] VARIANT* maxOccurs); +}; + +[ + object, + uuid(50ea08b6-dd1b-4664-9a50-c2f40f4bd79a), + oleautomation, + dual, +] +interface ISchemaAttribute : ISchemaItem +{ + [id(DISPID_SOM_TYPE), propget] + HRESULT type( + [out,retval] ISchemaType** type); + + [id(DISPID_SOM_SCOPE), propget] + HRESULT scope( + [out,retval] ISchemaComplexType** scope); + + [id(DISPID_SOM_DEFAULTVALUE), propget] + HRESULT defaultValue( + [out,retval]BSTR* defaultValue); + + [id(DISPID_SOM_FIXEDVALUE), propget] + HRESULT fixedValue( + [out,retval] BSTR* fixedValue); + + [id(DISPID_SOM_USE), propget] + HRESULT use( + [out,retval] SCHEMAUSE* use); + + [id(DISPID_SOM_ISREFERENCE), propget] + HRESULT isReference( + [out,retval] VARIANT_BOOL* reference); +}; + +[ + local, + object, + uuid(50ea08b7-dd1b-4664-9a50-c2f40f4bd79a), + oleautomation, + dual +] +interface ISchemaElement : ISchemaParticle +{ + [id(DISPID_SOM_TYPE), propget] + HRESULT type( + [out,retval] ISchemaType** type); + + [id(DISPID_SOM_SCOPE), propget] + HRESULT scope( + [out,retval] ISchemaComplexType** scope); + + [id(DISPID_SOM_DEFAULTVALUE), propget] + HRESULT defaultValue( + [out,retval] BSTR* defaultValue); + + [id(DISPID_SOM_FIXEDVALUE), propget] + HRESULT fixedValue( + [out,retval] BSTR* fixedValue); + + [id(DISPID_SOM_ISNILLABLE), propget] + HRESULT isNillable( + [out,retval] VARIANT_BOOL* nillable); + + [id(DISPID_SOM_IDCONSTRAINTS), propget] + HRESULT identityConstraints( + [out,retval] ISchemaItemCollection** constraints); + + [id(DISPID_SOM_SUBSTITUTIONGROUP), propget] + HRESULT substitutionGroup( + [out,retval] ISchemaElement** element); + + [id(DISPID_SOM_EXCLUSIONS), propget] + HRESULT substitutionGroupExclusions( + [out,retval] SCHEMADERIVATIONMETHOD* exclusions); + + [id(DISPID_SOM_DISALLOWED), propget] + HRESULT disallowedSubstitutions( + [out,retval] SCHEMADERIVATIONMETHOD* disallowed); + + [id(DISPID_SOM_ISABSTRACT), propget] + HRESULT isAbstract( + [out,retval] VARIANT_BOOL* abstract); + + [id(DISPID_SOM_ISREFERENCE), propget] + HRESULT isReference( + [out,retval] VARIANT_BOOL* reference); +}; + +[ + local, + object, + uuid(50ea08b8-dd1b-4664-9a50-c2f40f4bd79a), + oleautomation, + dual +] +interface ISchemaType : ISchemaItem +{ + [id(DISPID_SOM_BASETYPES), propget] + HRESULT baseTypes( + [out,retval] ISchemaItemCollection** baseTypes); + + [id(DISPID_SOM_FINAL), propget] + HRESULT final( + [out,retval] SCHEMADERIVATIONMETHOD* final); + + [id(DISPID_SOM_VARIETY), propget] + HRESULT variety( + [out,retval] SCHEMATYPEVARIETY* variety); + + [id(DISPID_SOM_DERIVEDBY), propget] + HRESULT derivedBy( + [out,retval] SCHEMADERIVATIONMETHOD* derivedBy); + + [id(DISPID_SOM_ISVALID)] + HRESULT isValid( + [in] BSTR data, + [out,retval] VARIANT_BOOL* valid); + + [id(DISPID_SOM_MINEXCLUSIVE), propget] + HRESULT minExclusive( + [out,retval]BSTR* minExclusive); + + [id(DISPID_SOM_MININCLUSIVE), propget] + HRESULT minInclusive( + [out,retval] BSTR* minInclusive); + + [id(DISPID_SOM_MAXEXCLUSIVE), propget] + HRESULT maxExclusive( + [out,retval] BSTR* maxExclusive); + + [id(DISPID_SOM_MAXINCLUSIVE), propget] + HRESULT maxInclusive( + [out,retval] BSTR* maxInclusive); + + [id(DISPID_SOM_TOTALDIGITS), propget] + HRESULT totalDigits( + [out,retval] VARIANT* totalDigits); + + [id(DISPID_SOM_FRACTIONDIGITS), propget] + HRESULT fractionDigits( + [out,retval] VARIANT* fractionDigits); + + [id(DISPID_SOM_LENGTH), propget] + HRESULT length( + [out,retval] VARIANT* length); + + [id(DISPID_SOM_MINLENGTH), propget] + HRESULT minLength( + [out,retval]VARIANT* minLength); + + [id(DISPID_SOM_MAXLENGTH), propget] + HRESULT maxLength( + [out,retval]VARIANT* maxLength); + + [id(DISPID_SOM_ENUMERATION), propget] + HRESULT enumeration( + [out,retval] ISchemaStringCollection** enumeration); + + [id(DISPID_SOM_WHITESPACE), propget] + HRESULT whitespace( + [out,retval]SCHEMAWHITESPACE* whitespace); + + [id(DISPID_SOM_PATTERNS), propget] + HRESULT patterns( + [out,retval] ISchemaStringCollection** patterns); +}; + +[ + local, + object, + uuid(50ea08b9-dd1b-4664-9a50-c2f40f4bd79a), + oleautomation, + dual, +] +interface ISchemaComplexType : ISchemaType +{ + [id(DISPID_SOM_ISABSTRACT), propget] + HRESULT isAbstract( + [out,retval] VARIANT_BOOL* abstract); + + [id(DISPID_SOM_ANYATTRIBUTE), propget] + HRESULT anyAttribute( + [out,retval] ISchemaAny** anyAttribute); + + [id(DISPID_SOM_ATTRIBUTES), propget] + HRESULT attributes( + [out,retval] ISchemaItemCollection** attributes); + + [id(DISPID_SOM_CONTENTTYPE), propget] + HRESULT contentType( + [out,retval] SCHEMACONTENTTYPE* contentType); + + [id(DISPID_SOM_CONTENTMODEL), propget] + HRESULT contentModel( + [out,retval] ISchemaModelGroup** contentModel); + + [id(DISPID_SOM_PROHIBITED), propget] + HRESULT prohibitedSubstitutions( + [out,retval] SCHEMADERIVATIONMETHOD* prohibited); +}; + +[ + local, + object, + uuid(50ea08ba-dd1b-4664-9a50-c2f40f4bd79a), + oleautomation, + dual, +] +interface ISchemaAttributeGroup : ISchemaItem +{ + [id(DISPID_SOM_ANYATTRIBUTE), propget] + HRESULT anyAttribute( + [out,retval] ISchemaAny** anyAttribute); + + [id(DISPID_SOM_ATTRIBUTES), propget] + HRESULT attributes( + [out,retval] ISchemaItemCollection** attributes); +}; + +[ + local, + object, + uuid(50ea08bb-dd1b-4664-9a50-c2f40f4bd79a), + oleautomation, + dual, +] +interface ISchemaModelGroup : ISchemaParticle +{ + [id(DISPID_SOM_PARTICLES), propget] + HRESULT particles( + [out,retval] ISchemaItemCollection** particles); +}; + +[ + local, + object, + uuid(50ea08bc-dd1b-4664-9a50-c2f40f4bd79a), + oleautomation, + dual +] +interface ISchemaAny : ISchemaParticle +{ + [id(DISPID_SOM_NAMESPACES), propget] + HRESULT namespaces( + [out,retval] ISchemaStringCollection** namespaces); + + [id(DISPID_SOM_PROCESSCONTENTS), propget] + HRESULT processContents( + [out,retval] SCHEMAPROCESSCONTENTS* processContents); +}; + +[ + local, + object, + uuid(50ea08bd-dd1b-4664-9a50-c2f40f4bd79a), + oleautomation, + dual +] +interface ISchemaIdentityConstraint : ISchemaItem +{ + [id(DISPID_SOM_SELECTOR), propget] + HRESULT selector( + [out,retval] BSTR* selector); + + [id(DISPID_SOM_FIELDS), propget] + HRESULT fields( + [out,retval] ISchemaStringCollection** fields); + + [id(DISPID_SOM_REFERENCEDKEY), propget] + HRESULT referencedKey( + [out,retval] ISchemaIdentityConstraint** key); +}; + +[ + local, + object, + uuid(50ea08be-dd1b-4664-9a50-c2f40f4bd79a), + oleautomation, + dual +] +interface ISchemaNotation : ISchemaItem +{ + [id(DISPID_SOM_SYSTEMIDENTIFIER), propget] + HRESULT systemIdentifier( + [out,retval] BSTR* uri); + + [id(DISPID_SOM_PUBLICIDENTIFIER), propget] + HRESULT publicIdentifier( + [out,retval] BSTR* uri); +}; + + +[ + uuid(079aa557-4a18-424a-8eee-e39f0a8d41b9) +] +coclass SAXXMLReader +{ + [default] interface IVBSAXXMLReader; + interface ISAXXMLReader; + interface IMXReaderControl; +}; + +[ + uuid(3124c396-fb13-4836-a6ad-1317f1713688) +] +coclass SAXXMLReader30 +{ + [default] interface IVBSAXXMLReader; + interface ISAXXMLReader; + interface IMXReaderControl; +}; + +[ + uuid(7c6e29bc-8b8b-4c3d-859e-af6cd158be0f) +] +coclass SAXXMLReader40 +{ + [default] interface IVBSAXXMLReader; + interface ISAXXMLReader; +} + +[ + helpstring("SAX XML Reader 6.0"), + progid("Msxml2.SAXXMLReader.6.0"), + threading(both), + uuid(88d96a0c-f192-11d4-a65f-0040963251e5) +] +coclass SAXXMLReader60 +{ + [default] interface IVBSAXXMLReader; + interface ISAXXMLReader; +} + +[ + uuid(a4c23ec3-6b70-4466-9127-550077239978) +] +coclass MXHTMLWriter +{ + [default] interface IMXWriter; + + interface ISAXContentHandler; + interface ISAXErrorHandler; + interface ISAXDTDHandler; + interface ISAXLexicalHandler; + interface ISAXDeclHandler; + + interface IVBSAXContentHandler; + interface IVBSAXDeclHandler; + interface IVBSAXDTDHandler; + interface IVBSAXErrorHandler; + interface IVBSAXLexicalHandler; +} + +[ + uuid(853d1540-c1a7-4aa9-a226-4d3bd301146d) +] +coclass MXHTMLWriter30 +{ + [default] interface IMXWriter; + + interface ISAXContentHandler; + interface ISAXDeclHandler; + interface ISAXDTDHandler; + interface ISAXErrorHandler; + interface ISAXLexicalHandler; + + interface IVBSAXContentHandler; + interface IVBSAXDeclHandler; + interface IVBSAXDTDHandler; + interface IVBSAXErrorHandler; + interface IVBSAXLexicalHandler; +} + +[ + uuid(88d969c9-f192-11d4-a65f-0040963251e5) +] +coclass MXHTMLWriter40 +{ + [default] interface IMXWriter; + + interface ISAXContentHandler; + interface ISAXDeclHandler; + interface ISAXDTDHandler; + interface ISAXErrorHandler; + interface ISAXLexicalHandler; + + interface IVBSAXContentHandler; + interface IVBSAXDeclHandler; + interface IVBSAXDTDHandler; + interface IVBSAXErrorHandler; + interface IVBSAXLexicalHandler; +} + +[ + helpstring("MXHTMLWriter 6.0"), + progid("Msxml2.MXHTMLWriter.6.0"), + threading(both), + uuid(88d96a10-f192-11d4-a65f-0040963251e5) +] +coclass MXHTMLWriter60 +{ + [default] interface IMXWriter; + + interface ISAXContentHandler; + interface ISAXDeclHandler; + interface ISAXDTDHandler; + interface ISAXErrorHandler; + interface ISAXLexicalHandler; + + interface IVBSAXContentHandler; + interface IVBSAXDeclHandler; + interface IVBSAXDTDHandler; + interface IVBSAXErrorHandler; + interface IVBSAXLexicalHandler; +} + +[ + uuid(fc220ad8-a72a-4ee8-926e-0b7ad152a020) +] +coclass MXXMLWriter +{ + [default] interface IMXWriter; + + interface ISAXContentHandler; + interface ISAXErrorHandler; + interface ISAXDTDHandler; + interface ISAXLexicalHandler; + interface ISAXDeclHandler; + + interface IVBSAXContentHandler; + interface IVBSAXDeclHandler; + interface IVBSAXDTDHandler; + interface IVBSAXErrorHandler; + interface IVBSAXLexicalHandler; +}; + +[ + uuid(3d813dfe-6c91-4a4e-8f41-04346a841d9c) +] +coclass MXXMLWriter30 +{ + [default] interface IMXWriter; + + interface ISAXContentHandler; + interface ISAXDeclHandler; + interface ISAXDTDHandler; + interface ISAXErrorHandler; + interface ISAXLexicalHandler; + + interface IVBSAXContentHandler; + interface IVBSAXDeclHandler; + interface IVBSAXDTDHandler; + interface IVBSAXErrorHandler; + interface IVBSAXLexicalHandler; +}; + +[ + uuid(88d969c8-f192-11d4-a65f-0040963251e5), +] +coclass MXXMLWriter40 +{ + [default] interface IMXWriter; + + interface ISAXContentHandler; + interface ISAXDeclHandler; + interface ISAXDTDHandler; + interface ISAXErrorHandler; + interface ISAXLexicalHandler; + + interface IVBSAXContentHandler; + interface IVBSAXDeclHandler; + interface IVBSAXDTDHandler; + interface IVBSAXErrorHandler; + interface IVBSAXLexicalHandler; +} + +[ + helpstring("MXXMLWriter 6.0"), + progid("Msxml2.MXXMLWriter.6.0"), + threading(both), + uuid(88d96a0f-f192-11d4-a65f-0040963251e5) +] +coclass MXXMLWriter60 +{ + [default] interface IMXWriter; + + interface ISAXContentHandler; + interface ISAXDeclHandler; + interface ISAXDTDHandler; + interface ISAXErrorHandler; + interface ISAXLexicalHandler; + + interface IVBSAXContentHandler; + interface IVBSAXDeclHandler; + interface IVBSAXDTDHandler; + interface IVBSAXErrorHandler; + interface IVBSAXLexicalHandler; +} + +[ + uuid(88d969d5-f192-11d4-a65f-0040963251e5) +] +coclass MXNamespaceManager +{ + [default] interface IVBMXNamespaceManager; + interface IMXNamespaceManager; +} + +[ + uuid(88d969d6-f192-11d4-a65f-0040963251e5) +] +coclass MXNamespaceManager40 +{ + [default] interface IVBMXNamespaceManager; + interface IMXNamespaceManager; +} + +[ + helpstring("MXNamespaceManager 6.0"), + progid("Msxml2.MXNamespaceManager.6.0"), + threading(both), + uuid(88d96a11-f192-11d4-a65f-0040963251e5) +] +coclass MXNamespaceManager60 +{ + [default] interface IVBMXNamespaceManager; + interface IMXNamespaceManager; +} + +[ + uuid(4dd441ad-526d-4a77-9f1b-9841ed802fb0) +] +coclass SAXAttributes +{ + [default] interface IMXAttributes; + interface IVBSAXAttributes; + interface ISAXAttributes; +} + +[ + uuid(3e784a01-f3ae-4dc0-9354-9526b9370eba) +] +coclass SAXAttributes30 +{ + [default] interface IMXAttributes; + interface IVBSAXAttributes; + interface ISAXAttributes; +} + +[ + uuid(88d969ca-f192-11d4-a65f-0040963251e5), +] +coclass SAXAttributes40 +{ + [default] interface IMXAttributes; + interface IVBSAXAttributes; + interface ISAXAttributes; +} + +[ + helpstring("SAXAttributes 6.0"), + progid("Msxml2.SAXAttributes.6.0"), + threading(both), + uuid(88d96a0e-f192-11d4-a65f-0040963251e5) +] +coclass SAXAttributes60 +{ + [default] interface IMXAttributes; + interface IVBSAXAttributes; + interface ISAXAttributes; +} + +/* + * Error Codes + */ +cpp_quote("#define E_XML_NOTWF 0xC00CE223") +cpp_quote("#define E_XML_NODTD 0xC00CE224") +cpp_quote("#define E_XML_INVALID 0xC00CE225") +cpp_quote("#define E_XML_BUFFERTOOSMALL 0xC00CE226") + +} /* Library MSXML */ diff --git a/reactos/include/psdk/msxml6did.h b/reactos/include/psdk/msxml6did.h new file mode 100644 index 00000000000..1e52578e7d7 --- /dev/null +++ b/reactos/include/psdk/msxml6did.h @@ -0,0 +1,24 @@ +/* + * Copyright (C) 2010 Nikolay Sivov for CodeWeavers + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#ifndef __MSXML6DID_H__ +#define __MSXML6DID_H__ + +#include + +#endif /* __MSXML6DID_H__ */ diff --git a/reactos/include/psdk/objidl.idl b/reactos/include/psdk/objidl.idl index 70f93ab3179..a3896e9be07 100644 --- a/reactos/include/psdk/objidl.idl +++ b/reactos/include/psdk/objidl.idl @@ -345,6 +345,18 @@ interface IBindCtx : IUnknown COSERVERINFO *pServerInfo; } BIND_OPTS2, *LPBIND_OPTS2; + typedef struct tagBIND_OPTS3 { + DWORD cbStruct; + DWORD grfFlags; + DWORD grfMode; + DWORD dwTickCountDeadline; + DWORD dwTrackFlags; + DWORD dwClassContext; + LCID locale; + COSERVERINFO *pServerInfo; + HWND hwnd; + } BIND_OPTS3, *LPBIND_OPTS3; + typedef enum tagBIND_FLAGS { BIND_MAYBOTHERUSER = 1, BIND_JUSTTESTEXISTENCE = 2 diff --git a/reactos/include/psdk/oledb.idl b/reactos/include/psdk/oledb.idl index 127df2b4906..48411651c55 100644 --- a/reactos/include/psdk/oledb.idl +++ b/reactos/include/psdk/oledb.idl @@ -40,6 +40,15 @@ typedef ULONG DBREFCOUNT; typedef ULONG DB_UPARAMS; typedef LONG DB_LPARAMS; typedef DWORD DBHASHVALUE; +typedef struct { + SHORT year; + USHORT month; + USHORT day; + USHORT hour; + USHORT minute; + USHORT second; + ULONG fraction; +} DBTIMESTAMP; #include "dbs.idl" diff --git a/reactos/include/psdk/propkeydef.h b/reactos/include/psdk/propkeydef.h new file mode 100644 index 00000000000..2a796eaf3c4 --- /dev/null +++ b/reactos/include/psdk/propkeydef.h @@ -0,0 +1,70 @@ +/* + * Copyright (C) 2009 Maarten Lankhorst + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#ifndef PID_FIRST_USABLE +#define PID_FIRST_USABLE 2 +#endif + +#ifndef REFPROPERTYKEY +#ifdef __cplusplus +#define REFPROPERTYKEY const PROPERTYKEY & +#else /*!__cplusplus*/ +#define REFPROPERTYKEY const PROPERTYKEY * __MIDL_CONST +#endif +#endif + +#undef DEFINE_PROPERTYKEY + +#ifdef INITGUID +#ifdef __cplusplus +#define DEFINE_PROPERTYKEY(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8, pid) \ + EXTERN_C const PROPERTYKEY name DECLSPEC_HIDDEN DECLSPEC_SELECTANY; \ + EXTERN_C const PROPERTYKEY name = \ + { { l, w1, w2, { b1, b2, b3, b4, b5, b6, b7, b8 } }, pid } +#else +#define DEFINE_PROPERTYKEY(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8, pid) \ + const PROPERTYKEY name DECLSPEC_HIDDEN DECLSPEC_SELECTANY; \ + const PROPERTYKEY name = \ + { { l, w1, w2, { b1, b2, b3, b4, b5, b6, b7, b8 } }, pid } +#endif +#else +#define DEFINE_PROPERTYKEY(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8, pid) \ + EXTERN_C const PROPERTYKEY name DECLSPEC_HIDDEN DECLSPEC_SELECTANY +#endif + +#ifndef IsEqualPropertyKey +#ifdef __cplusplus +#define IsEqualPropertyKey(a,b) (((a).pid == (b).pid) && IsEqualIID((a).fmtid,(b).fmtid)) +#else +#define IsEqualPropertyKey(a,b) (((a).pid == (b).pid) && IsEqualIID(&(a).fmtid,&(b).fmtid)) +#endif +#endif + +#ifndef _PROPERTYKEY_EQUALITY_OPERATORS_ +#define _PROPERTYKEY_EQUALITY_OPERATORS_ +#ifdef __cplusplus +inline bool operator==(REFPROPERTYKEY guidOne, REFPROPERTYKEY guidOther) +{ + return IsEqualPropertyKey(guidOne, guidOther); +} +inline bool operator!=(REFPROPERTYKEY guidOne, REFPROPERTYKEY guidOther) +{ + return !(guidOne == guidOther); +} +#endif +#endif diff --git a/reactos/include/psdk/propsys.idl b/reactos/include/psdk/propsys.idl index cc5770e13cb..ef9ecfc912a 100644 --- a/reactos/include/psdk/propsys.idl +++ b/reactos/include/psdk/propsys.idl @@ -795,6 +795,14 @@ interface ICreateObject : IUnknown ); } +cpp_quote("#define PKEY_PIDSTR_MAX 10") +cpp_quote("#define GUIDSTRING_MAX 39") +cpp_quote("#define PKEYSTR_MAX (GUIDSTRING_MAX + 1 + PKEY_PIDSTR_MAX)") + +cpp_quote("HRESULT WINAPI PSStringFromPropertyKey(REFPROPERTYKEY,LPWSTR,UINT);") +cpp_quote("HRESULT WINAPI PSPropertyKeyFromString(LPCWSTR,PROPERTYKEY*);") +cpp_quote("HRESULT WINAPI PSGetPropertyDescription(REFPROPERTYKEY,REFIID,void **);") + /* TODO: Add remainder of the C api here */ [ diff --git a/reactos/include/psdk/psdk.rbuild b/reactos/include/psdk/psdk.rbuild index 6384703aca5..a7b5cbfcbe5 100644 --- a/reactos/include/psdk/psdk.rbuild +++ b/reactos/include/psdk/psdk.rbuild @@ -57,6 +57,7 @@ shobjidl.idl shtypes.idl strmif.idl + structuredquerycondition.idl textstor.idl tuner.idl tom.idl @@ -67,7 +68,9 @@ mimeole.idl mscoree.idl mshtmhst.idl + msxml6.idl exdisp.idl + winsxs.idl wtypes.idl wuapi.idl comcat.idl diff --git a/reactos/include/psdk/urlmon.idl b/reactos/include/psdk/urlmon.idl index 3fb5566b14a..ec0354fb3ce 100644 --- a/reactos/include/psdk/urlmon.idl +++ b/reactos/include/psdk/urlmon.idl @@ -1826,6 +1826,30 @@ interface IUriBuilder: IUnknown [out] BOOL *pfModified); }; +cpp_quote("HRESULT WINAPI CreateIUriBuilder(IUri*,DWORD,DWORD_PTR,IUriBuilder**);") + +/***************************************************************************** + * IUriBuilderFactory interface + */ +[ + local, + object, + uuid(e982ce48-0b96-440c-bc37-0c869b27a29e), + pointer_default(unique) +] +interface IUriBuilderFactory : IUnknown +{ + HRESULT CreateInitializedIUriBuilder( + [in] DWORD dwFlags, + [in] DWORD_PTR dwReserved, + [out] IUriBuilder **ppIUriBuilder); + + HRESULT CreateIUriBuilder( + [in] DWORD dwFlags, + [in] DWORD_PTR dwReserved, + [out] IUriBuilder **ppIUriBuilder); +}; + /***************************************************************************** * IInternetProtocolEx interface */ @@ -1897,13 +1921,19 @@ cpp_quote("#define INET_E_SECURITY_PROBLEM _HRESULT_TYPEDEF_(0x800C000E cpp_quote("#define INET_E_CANNOT_LOAD_DATA _HRESULT_TYPEDEF_(0x800C000F)") cpp_quote("#define INET_E_CANNOT_INSTANTIATE_OBJECT _HRESULT_TYPEDEF_(0x800C0010)") cpp_quote("#define INET_E_USE_DEFAULT_PROTOCOLHANDLER _HRESULT_TYPEDEF_(0x800C0011)") -cpp_quote("#define INET_E_USE_DEFAULT_SETTING _HRESULT_TYPEDEF_(0x800C0012)") +cpp_quote("#define INET_E_USE_DEFAULT_SETTING _HRESULT_TYPEDEF_(0x800C0012L)") +cpp_quote("#define INET_E_DEFAULT_ACTION INET_E_USE_DEFAULT_PROTOCOLHANDLER") cpp_quote("#define INET_E_QUERYOPTION_UNKNOWN _HRESULT_TYPEDEF_(0x800C0013)") cpp_quote("#define INET_E_REDIRECT_FAILED _HRESULT_TYPEDEF_(0x800C0014)") cpp_quote("#define INET_E_REDIRECT_TO_DIR _HRESULT_TYPEDEF_(0x800C0015)") cpp_quote("#define INET_E_CANNOT_LOCK_REQUEST _HRESULT_TYPEDEF_(0x800C0016)") -cpp_quote("#define INET_E_ERROR_LAST INET_E_REDIRECT_TO_DIR") -cpp_quote("#define INET_E_DEFAULT_ACTION INET_E_USE_DEFAULT_PROTOCOLHANDLER") +cpp_quote("#define INET_E_CODE_DOWNLOAD_DECLINED _HRESULT_TYPEDEF_(0x800C0100)") +cpp_quote("#define INET_E_RESULT_DISPATCHED _HRESULT_TYPEDEF_(0x800C0200)") +cpp_quote("#define INET_E_CANNOT_REPLACE_SFP_FILE _HRESULT_TYPEDEF_(0x800C0300)") +cpp_quote("#define INET_E_CODE_INSTALL_SUPPRESSED _HRESULT_TYPEDEF_(0x800C0400)") +cpp_quote("#define INET_E_CODE_INSTALL_BLOCKED_BY_HASH_POLICY _HRESULT_TYPEDEF_(0x800C0500)") +cpp_quote("#define INET_E_DOWNLOAD_BLOCKED_BY_INPRIVATE _HRESULT_TYPEDEF_(0x800C0501)") +cpp_quote("#define INET_E_ERROR_LAST INET_E_DOWNLOAD_BLOCKED_BY_INPRIVATE") cpp_quote("HRESULT WINAPI CoGetClassObjectFromURL(REFCLSID, LPCWSTR, DWORD, DWORD, LPCWSTR, LPBINDCTX, DWORD, LPVOID, REFIID, LPVOID*);") cpp_quote("HRESULT WINAPI CreateURLMoniker(IMoniker *pmkContext, LPCWSTR szURL, IMoniker **ppmk);") @@ -1922,9 +1952,12 @@ cpp_quote("HRESULT WINAPI CreateAsyncBindCtx(DWORD, IBindStatusCallback*, IEnumF cpp_quote("HRESULT WINAPI CreateAsyncBindCtxEx(IBindCtx*,DWORD,IBindStatusCallback*,IEnumFORMATETC*,IBindCtx**,DWORD);") cpp_quote("HRESULT WINAPI CoInternetCreateSecurityManager(IServiceProvider*,IInternetSecurityManager**,DWORD);") cpp_quote("HRESULT WINAPI CoInternetCombineUrl(LPCWSTR,LPCWSTR,DWORD,LPWSTR,DWORD,DWORD*,DWORD);") +cpp_quote("HRESULT WINAPI CoInternetCombineUrlEx(IUri*,LPCWSTR,DWORD,IUri**,DWORD_PTR);") cpp_quote("HRESULT WINAPI CoInternetCompareUrl(LPCWSTR,LPCWSTR,DWORD);") +cpp_quote("HRESULT WINAPI CoInternetCombineIUri(IUri*,IUri*,DWORD,IUri**,DWORD_PTR);") cpp_quote("HRESULT WINAPI CoInternetCreateZoneManager(IServiceProvider*, IInternetZoneManager**, DWORD);") cpp_quote("HRESULT WINAPI CoInternetParseUrl(LPCWSTR,PARSEACTION,DWORD,LPWSTR,DWORD,DWORD*,DWORD);") +cpp_quote("HRESULT WINAPI CoInternetParseIUri(IUri*,PARSEACTION,DWORD,LPWSTR,DWORD,DWORD*,DWORD_PTR);") cpp_quote("HRESULT WINAPI CoInternetQueryInfo(LPCWSTR,QUERYOPTION,DWORD,LPVOID,DWORD,DWORD*,DWORD);") cpp_quote("HRESULT WINAPI CoInternetSetFeatureEnabled(INTERNETFEATURELIST,DWORD,BOOL);") cpp_quote("HRESULT WINAPI CoInternetGetSecurityUrl(LPCWSTR,LPWSTR*,PSUACTION,DWORD);") diff --git a/reactos/include/psdk/wbemcli.idl b/reactos/include/psdk/wbemcli.idl index b2ac6c1d988..db6a5ac28c8 100644 --- a/reactos/include/psdk/wbemcli.idl +++ b/reactos/include/psdk/wbemcli.idl @@ -24,6 +24,10 @@ import "objidl.idl"; interface IWbemContext; interface IWbemServices; interface IWbemStatusCodeText; +interface IWbemCallResult; +interface IWbemObjectSink; +interface IWbemClassObject; +interface IEnumWbemClassObject; typedef [v1_enum] enum tag_WBEMSTATUS { @@ -209,3 +213,183 @@ interface IWbemStatusCodeText : IUnknown [in] LONG lFlags, [out] BSTR *MessageText); }; + +[ + object, + restricted, + uuid(9556dc99-828c-11cf-a37e-00aa003240c7), + pointer_default(unique) +] +interface IWbemServices : IUnknown +{ + HRESULT OpenNamespace( + [in] const BSTR strNamespace, + [in] long lFlags, + [in] IWbemContext *pCtx, + [out] IWbemServices **ppWorkingNamespace, + [out] IWbemCallResult **ppResult); + + HRESULT CancelAsyncCall( + [in] IWbemObjectSink *pSink); + + HRESULT QueryObjectSink( + [in] long lFlags, + [out] IWbemObjectSink **ppResponseHandler); + + HRESULT GetObject( + [in] const BSTR strObjectPath, + [in] long lFlags, + [in] IWbemContext *pCtx, + [out] IWbemClassObject **ppObject, + [out] IWbemCallResult **ppCallResult); + + HRESULT GetObjectAsync( + [in] const BSTR strObjectPath, + [in] long lFlags, + [in] IWbemContext *pCtx, + [in] IWbemObjectSink *pResponseHandler); + + HRESULT PutClass( + [in] IWbemClassObject *pObject, + [in] long lFlags, + [in] IWbemContext *pCtx, + [out] IWbemCallResult **ppCallResult); + + HRESULT PutClassAsync( + [in] IWbemClassObject *pObject, + [in] long lFlags, + [in] IWbemContext *pCtx, + [in] IWbemObjectSink *pResponseHandler); + + HRESULT DeleteClass( + [in] const BSTR strClass, + [in] long lFlags, + [in] IWbemContext *pCtx, + [out] IWbemCallResult **ppCallResult); + + HRESULT DeleteClassAsync( + [in] const BSTR strClass, + [in] long lFlags, + [in] IWbemContext *pCtx, + [in] IWbemObjectSink *pResponseHandler); + + HRESULT CreateClassEnum( + [in] const BSTR strSuperclass, + [in] long lFlags, + [in] IWbemContext *pCtx, + [out] IEnumWbemClassObject **ppEnum); + + HRESULT CreateClassEnumAsync( + [in] const BSTR strSuperclass, + [in] long lFlags, + [in] IWbemContext *pCtx, + [in] IWbemObjectSink *pResponseHandler); + + HRESULT PutInstance( + [in] IWbemClassObject *pInst, + [in] long lFlags, + [in] IWbemContext *pCtx, + [out] IWbemCallResult **ppCallResult); + + HRESULT PutInstanceAsync( + [in] IWbemClassObject *pInst, + [in] long lFlags, + [in] IWbemContext *pCtx, + [in] IWbemObjectSink *pResponseHandler); + + HRESULT DeleteInstance( + [in] const BSTR strObjectPath, + [in] long lFlags, + [in] IWbemContext *pCtx, + [out] IWbemCallResult **ppCallResult); + + HRESULT DeleteInstanceAsync( + [in] const BSTR strObjectPath, + [in] long lFlags, + [in] IWbemContext *pCtx, + [in] IWbemObjectSink *pResponseHandler); + + HRESULT CreateInstanceEnum( + [in] const BSTR strFilter, + [in] long lFlags, + [in] IWbemContext *pCtx, + [out] IEnumWbemClassObject **ppEnum); + + HRESULT CreateInstanceEnumAsync( + [in] const BSTR strFilter, + [in] long lFlags, + [in] IWbemContext *pCtx, + [in] IWbemObjectSink *pResponseHandler); + + HRESULT ExecQuery( + [in] const BSTR strQueryLanguage, + [in] const BSTR strQuery, + [in] long lFlags, + [in] IWbemContext *pCtx, + [out] IEnumWbemClassObject **ppEnum); + + HRESULT ExecQueryAsync( + [in] const BSTR strQueryLanguage, + [in] const BSTR strQuery, + [in] long lFlags, + [in] IWbemContext *pCtx, + [in] IWbemObjectSink *pResponseHandler); + + HRESULT ExecNotificationQuery( + [in] const BSTR strQueryLanguage, + [in] const BSTR strQuery, + [in] long lFlags, + [in] IWbemContext *pCtx, + [out] IEnumWbemClassObject **ppEnum); + + HRESULT ExecNotificationQueryAsync( + [in] const BSTR strQueryLanguage, + [in] const BSTR strQuery, + [in] long lFlags, + [in] IWbemContext *pCtx, + [in] IWbemObjectSink *pResponseHandler); + + HRESULT ExecMethod( + [in] const BSTR strObjectPath, + [in] const BSTR strMethodName, + [in] long lFlags, + [in] IWbemContext *pCtx, + [in] IWbemClassObject *pInParams, + [out] IWbemClassObject **ppOutParams, + [out] IWbemCallResult **ppCallResult); + + HRESULT ExecMethodAsync( + [in] const BSTR strObjectPath, + [in] const BSTR strMethodName, + [in] long lFlags, + [in] IWbemContext *pCtx, + [in] IWbemClassObject *pInParams, + [in] IWbemObjectSink *pResponseHandler); +}; + +[ + object, + restricted, + uuid(027947e1-d731-11ce-a357-000000000001) +] +interface IEnumWbemClassObject : IUnknown +{ + HRESULT Reset(); + + HRESULT Next( + [in] long lTimeout, + [in] ULONG uCount, + [out, size_is(uCount), length_is(*puReturned)] IWbemClassObject **apObjects, + [out] ULONG *puReturned); + + HRESULT NextAsync( + [in] ULONG uCount, + [in] IWbemObjectSink *pSink); + + HRESULT Clone( + [out] IEnumWbemClassObject **ppEnum); + + HRESULT Skip( + [in] long lTimeout, + [in] ULONG nCount); +}; diff --git a/reactos/include/psdk/wincodec.idl b/reactos/include/psdk/wincodec.idl index 97fd4ac212b..4139f51f238 100644 --- a/reactos/include/psdk/wincodec.idl +++ b/reactos/include/psdk/wincodec.idl @@ -21,6 +21,8 @@ import "propidl.idl"; import "objidl.idl"; import "ocidl.idl"; +cpp_quote("#define WINCODEC_SDK_VERSION 0x0236") + #define CODEC_FORCE_DWORD 0x7fffffff typedef enum WICDecodeOptions { @@ -158,6 +160,7 @@ cpp_quote("DEFINE_GUID(GUID_WICPixelFormat16bppGray, 0x6fddc324,0x4e03,0x4bfe,0x cpp_quote("DEFINE_GUID(GUID_WICPixelFormat16bppBGR555, 0x6fddc324,0x4e03,0x4bfe,0xb1,0x85,0x3d,0x77,0x76,0x8d,0xc9,0x09);") cpp_quote("DEFINE_GUID(GUID_WICPixelFormat16bppBGR565, 0x6fddc324,0x4e03,0x4bfe,0xb1,0x85,0x3d,0x77,0x76,0x8d,0xc9,0x0a);") +cpp_quote("DEFINE_GUID(GUID_WICPixelFormat16bppBGRA5551, 0x05ec7c2b,0xf1e6,0x4961,0xad,0x46,0xe1,0xcc,0x81,0x0a,0x87,0xd2);") cpp_quote("DEFINE_GUID(GUID_WICPixelFormat24bppBGR, 0x6fddc324,0x4e03,0x4bfe,0xb1,0x85,0x3d,0x77,0x76,0x8d,0xc9,0x0c);") cpp_quote("DEFINE_GUID(GUID_WICPixelFormat32bppBGR, 0x6fddc324,0x4e03,0x4bfe,0xb1,0x85,0x3d,0x77,0x76,0x8d,0xc9,0x0e);") cpp_quote("DEFINE_GUID(GUID_WICPixelFormat32bppBGRA, 0x6fddc324,0x4e03,0x4bfe,0xb1,0x85,0x3d,0x77,0x76,0x8d,0xc9,0x0f);") @@ -165,6 +168,9 @@ cpp_quote("DEFINE_GUID(GUID_WICPixelFormat32bppPBGRA, 0x6fddc324,0x4e03,0x4bfe,0 cpp_quote("DEFINE_GUID(GUID_WICPixelFormat48bppRGB, 0x6fddc324,0x4e03,0x4bfe,0xb1,0x85,0x3d,0x77,0x76,0x8d,0xc9,0x15);") cpp_quote("DEFINE_GUID(GUID_WICPixelFormat64bppRGBA, 0x6fddc324,0x4e03,0x4bfe,0xb1,0x85,0x3d,0x77,0x76,0x8d,0xc9,0x16);") +cpp_quote("DEFINE_GUID(GUID_WICPixelFormat64bppPRGBA, 0x6fddc324,0x4e03,0x4bfe,0xb1,0x85,0x3d,0x77,0x76,0x8d,0xc9,0x17);") + +cpp_quote("DEFINE_GUID(GUID_WICPixelFormat32bppCMYK, 0x6fddc324,0x4e03,0x4fbe,0xb1,0x85,0x3d,0x77,0x76,0x8d,0xc9,0x1c);") typedef struct WICRect { INT X; @@ -184,6 +190,7 @@ typedef struct WICBitmapPattern { typedef UINT32 WICColor; cpp_quote("#define WINCODEC_ERR_WRONGSTATE 0x88982f04") +cpp_quote("#define WINCODEC_ERR_VALUEOUTOFRANGE 0x88982f05") cpp_quote("#define WINCODEC_ERR_NOTINITIALIZED 0x88982f0c") cpp_quote("#define WINCODEC_ERR_CODECNOTHUMBNAIL 0x88982f44") cpp_quote("#define WINCODEC_ERR_PALETTEUNAVAILABLE 0x88982f45") @@ -194,10 +201,6 @@ cpp_quote("#define WINCODEC_ERR_UNSUPPORTEDOPERATION 0x88982f81") cpp_quote("#define WINCODEC_ERR_INSUFFICIENTBUFFER 0x88982f8c") interface IWICPalette; -interface IWICColorTransform; -interface IWICFastMetadataEncoder; -interface IWICMetadataQueryReader; -interface IWICMetadataQueryWriter; [ object, @@ -387,6 +390,42 @@ interface IWICComponentInfo : IUnknown [out] UINT *pcchActual); } +[ + object, + uuid(30989668-e1c9-4597-b395-458eedb808df) +] +interface IWICMetadataQueryReader : IUnknown +{ + HRESULT GetContainerFormat( + [out] GUID *pguidContainerFormat); + + HRESULT GetLocation( + [in] UINT cchMaxLength, + [in, out, unique, size_is(cchMaxLength)] WCHAR *wzNamespace, + [out] UINT *pcchActualLength); + + HRESULT GetMetadataByName( + [in] LPCWSTR wzName, + [in, out, unique] PROPVARIANT *pvarValue); + + HRESULT GetEnumerator( + [out] IEnumString **ppIEnumString); +} + +[ + object, + uuid(a721791a-0def-4d06-bd91-2118bf1db10b) +] +interface IWICMetadataQueryWriter : IWICMetadataQueryReader +{ + HRESULT SetMetadataByName( + [in] LPCWSTR wzName, + [in] const PROPVARIANT *pvarValue); + + HRESULT RemoveMetadataByName( + [in] LPCWSTR wzName); +} + [ object, uuid(3b16811b-6a43-4ec9-a813-3d930c13b940) @@ -708,6 +747,31 @@ interface IWICBitmapClipper : IWICBitmapSource [in] const WICRect *prc); } +[ + object, + uuid(b66f034f-d0e2-40ab-b436-6de39e321a94) +] +interface IWICColorTransform : IWICBitmapSource +{ + HRESULT Initialize( + [in] IWICBitmapSource *pIBitmapSource, + [in] IWICColorContext *pIContextSource, + [in] IWICColorContext *pIContextDest, + [in] REFWICPixelFormatGUID pixelFmtDest); +} + +[ + object, + uuid(b84e2c09-78c9-4ac4-8bd3-524ae1663a2f) +] +interface IWICFastMetadataEncoder : IUnknown +{ + HRESULT Commit(); + + HRESULT GetMetadataQueryWriter( + [out] IWICMetadataQueryWriter **ppIMetadataQueryWriter); +} + cpp_quote("DEFINE_GUID(CLSID_WICImagingFactory, 0xcacaf262,0x9370,0x4615,0xa1,0x3b,0x9f,0x55,0x39,0xda,0x4c,0x0a);") [ diff --git a/reactos/include/psdk/winsxs.idl b/reactos/include/psdk/winsxs.idl new file mode 100644 index 00000000000..c2c38f2a6bf --- /dev/null +++ b/reactos/include/psdk/winsxs.idl @@ -0,0 +1,101 @@ +/* + * Copyright 2010 Hans Leidekker for CodeWeavers + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +import "objidl.idl"; + +interface IAssemblyCache; +interface IAssemblyCacheItem; + +typedef struct _FUSION_INSTALL_REFERENCE_ +{ + DWORD cbSize; + DWORD dwFlags; + GUID guidScheme; + LPCWSTR szIdentifier; + LPCWSTR szNonCannonicalData; +} FUSION_INSTALL_REFERENCE, *LPFUSION_INSTALL_REFERENCE; + +typedef struct _ASSEMBLY_INFO +{ + ULONG cbAssemblyInfo; + DWORD dwAssemblyFlags; + ULARGE_INTEGER uliAssemblySizeInKB; + LPWSTR pszCurrentAssemblyPathBuf; + ULONG cchBuf; +} ASSEMBLY_INFO; + +typedef const struct _FUSION_INSTALL_REFERENCE_ *LPCFUSION_INSTALL_REFERENCE; + +[ + object, + uuid(e707dcde-d1cd-11d2-bab9-00c04f8eceae), + pointer_default(unique), + local +] +interface IAssemblyCache : IUnknown +{ + HRESULT UninstallAssembly( + [in] DWORD flags, + [in] LPCWSTR name, + [in] LPCFUSION_INSTALL_REFERENCE ref, + [out, optional] ULONG *disp); + + HRESULT QueryAssemblyInfo( + [in] DWORD flags, + [in] LPCWSTR name, + [in, out] ASSEMBLY_INFO *info); + + HRESULT CreateAssemblyCacheItem( + [in] DWORD flags, + [in] PVOID reserved, + [out] IAssemblyCacheItem **item, + [in, optional] LPCWSTR name); + + HRESULT Reserved( + [out] IUnknown **reserved); + + HRESULT InstallAssembly( + [in] DWORD flags, + [in] LPCWSTR path, + [in] LPCFUSION_INSTALL_REFERENCE ref); +} + +[ + object, + uuid(9e3aaeb4-d1cd-11d2-bab9-00c04f8eceae), + pointer_default(unique), + local +] +interface IAssemblyCacheItem : IUnknown +{ + HRESULT CreateStream( + [in] DWORD flags, + [in] LPCWSTR name, + [in] DWORD format, + [in] DWORD format_flags, + [out] IStream **stream, + [in, optional] ULARGE_INTEGER *max_size); + + HRESULT Commit( + [in] DWORD flags, + [out, optional] ULONG *disp); + + HRESULT AbortItem(); +} + +cpp_quote("HRESULT WINAPI CreateAssemblyCache(IAssemblyCache**,DWORD);") diff --git a/reactos/include/psdk/wuapi.idl b/reactos/include/psdk/wuapi.idl index 27a3d5f1c10..1989cd40bd6 100644 --- a/reactos/include/psdk/wuapi.idl +++ b/reactos/include/psdk/wuapi.idl @@ -16,26 +16,29 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -cpp_quote("DEFINE_GUID(CLSID_AutomaticUpdates, 0xbfe18e9c,0x6d87,0x4450,0xb3,0x7c,0xe0,0x2f,0x0b,0x37,0x38,0x03);") -cpp_quote("DEFINE_GUID(CLSID_UpdateSession, 0x4cb43d7f,0x7eee,0x4906,0x86,0x98,0x60,0xda,0x1c,0x38,0xf2,0xfe);") - import "oaidl.idl"; -interface IAutomaticUpdates; -interface IAutomaticUpdatesSettings; -interface IDownloadJob; -interface IDownloadResult; -interface IInstallationJob; -interface IInstallationResult; -interface ISearchJob; -interface ISearchResult; +#ifndef __WIDL__ +#define threading(model) +#define progid(str) +#define vi_progid(str) +#endif + +[ + helpstring("WUAPI 2.0 Type Library"), + uuid(b596cc9f-56e5-419e-a622-e01bb457431e), + version(2.0) +] +library WUApiLib { + +importlib("stdole2.tlb"); + +interface ICategoryCollection; +interface IStringCollection; interface IUpdateCollection; interface IUpdateDownloader; -interface IUpdateHistoryEntryCollection; interface IUpdateInstaller; interface IUpdateSearcher; -interface IUpdateSession; -interface IWebProxy; typedef [public] enum tagDownloadPriority { @@ -52,6 +55,126 @@ typedef [public] enum tagServerSelection ssOthers = 3, } ServerSelection; +typedef [public] enum tagAutomaticUpdatesNotificationLevel +{ + aunlNotConfigured, + aunlDisabled, + aunlNotifyBeforeDownload, + aunlNotifyBeforeInstallation, + aunlScheduledInstallation, +} AutomaticUpdatesNotificationLevel; + +typedef [public] enum tagAutomaticUpdatesScheduledInstallationDay +{ + ausidEveryDay, + ausidEverySunday, + ausidEveryMonday, + ausidEveryTuesday, + ausidEveryWednesday, + ausidEveryThursday, + ausidEveryFriday, + ausidEverySaturday, +} AutomaticUpdatesScheduledInstallationDay; + +typedef [public] enum tagDownloadPhase +{ + dphInitializing, + dphDownloading, + dphVerifying, +} DownloadPhase; + +typedef [public] enum tagOperationResultCode +{ + orcNotStarted, + orcInProgress, + orcSucceeded, + orcSucceededWithErrors, + orcFailed, + orcAborted, +} OperationResultCode; + +typedef [public] enum tagUpdateExceptionContext +{ + uecGeneral = 1, + uecWindowsDriver, + uecWindowsInstaller +} UpdateExceptionContext; + +typedef [public] enum tagInstallationImpact +{ + iiNormal, + iiMinor, + iiRequiresExclusiveHandling +} InstallationImpact; + +typedef [public] enum tagInstallationRebootBehavior +{ + irbNeverReboots, + irbAlwaysRequiresReboot, + irbCanRequestReboot +} InstallationRebootBehavior; + +typedef [public] enum tagUpdateType +{ + utSoftware = 1, + utDriver +} UpdateType; + +typedef [public] enum tagUpdateOperation +{ + uoInstallation = 1, + uoUninstallation +} UpdateOperation; + +typedef [public] enum tagDeploymentAction +{ + daNone, + daInstallation, + daUninstallation, + daDetection +} DeploymentAction; + +[ + object, + oleautomation, + dual, + nonextensible, + uuid(2ee48f22-af3c-405f-8970-f71be12ee9a2), + pointer_default(unique) +] +interface IAutomaticUpdatesSettings : IDispatch +{ + [propget, id(0x60020001)] + HRESULT NotificationLevel( [out, retval] AutomaticUpdatesNotificationLevel *retval ); + + [propput, id(0x60020001)] + HRESULT NotificationLevel( [in] AutomaticUpdatesNotificationLevel value ); + + [propget, id(0x60020002)] + HRESULT ReadOnly( [out, retval] VARIANT_BOOL *retval ); + + [propget, id(0x60020003)] + HRESULT Required( [out, retval] VARIANT_BOOL *retval ); + + [propget, id(0x60020004)] + HRESULT ScheduledInstallationDay( [out, retval] AutomaticUpdatesScheduledInstallationDay *retval ); + + [propput, id(0x60020004)] + HRESULT ScheduledInstallationDay( [in] AutomaticUpdatesScheduledInstallationDay value ); + + [propget, id(0x60020005)] + HRESULT ScheduledInstallationTime( [out, retval] LONG *retval ); + + [propput, id(0x60020005)] + HRESULT ScheduledInstallationTime( [in] LONG value ); + + [id(0x60020006)] + HRESULT Refresh(); + + [id(0x60020007)] + HRESULT Save(); +} + [ object, uuid(673425bf-c082-4c7c-bdfd-569464b8e0ce), @@ -79,6 +202,61 @@ interface IAutomaticUpdates : IDispatch HRESULT EnableService(); } +[ + object, + oleautomation, + dual, + nonextensible, + uuid(174c81fe-aecd-4dae-b8a0-2c6318dd86a8), + pointer_default(unique), +] +interface IWebProxy : IDispatch +{ + [propget, id(0x60020001)] + HRESULT Address( [out, retval] BSTR *retval ); + + [propput, id(0x60020001)] + HRESULT Address( [in] BSTR value ); + + [propget, id(0x60020002)] + HRESULT BypassList( [out, retval] IStringCollection **retval ); + + [propput, id(0x60020002)] + HRESULT BypassList( [in] IStringCollection *value ); + + [propget, id(0x60020003)] + HRESULT BypassProxyOnLocal( [out, retval] VARIANT_BOOL *retval ); + + [propput, id(0x60020003)] + HRESULT BypassProxyOnLocal( [in] VARIANT_BOOL value ); + + [propget, id(0x60020004)] + HRESULT ReadOnly( [out, retval] VARIANT_BOOL *retval ); + + [propget, id(0x60020005)] + HRESULT UserName( [out, retval] BSTR *retval ); + + [propput, id(0x60020005)] + HRESULT UserName( [in] BSTR value ); + + [id(0x60020006)] + HRESULT SetPassword( [in] BSTR value ); + + [id(0x60020007)] + HRESULT PromptForCredentials( [in, unique] IUnknown *parentWindow, + [in] BSTR title ); + + [restricted, id(0x60020008)] + HRESULT PromptForCredentialsFromHwnd( [in, unique] HWND parentWindow, + [in] BSTR title ); + + [propget, id(0x60020009)] + HRESULT AutoDetect( [out, retval] VARIANT_BOOL *retval ); + + [propput, id(0x60020009)] + HRESULT AutoDetect( [in] VARIANT_BOOL value ); +} + [ object, uuid(816858a4-260d-4260-933a-2585f1abc76b), @@ -119,6 +297,566 @@ interface IUpdateSession : IDispatch [out, retval] IUpdateInstaller **retval); } +[ + object, + oleautomation, + dual, + nonextensible, + uuid(7c907864-346c-4aeb-8f3f-57da289f969f), + pointer_default(unique), +] +interface IImageInformation : IDispatch +{ + [propget, id(0x60020001)] + HRESULT AltText( [out, retval] BSTR *retval ); + + [propget, id(0x60020002)] + HRESULT Height( [out, retval] LONG *retval ); + + [propget, id(0x60020003)] + HRESULT Source( [out, retval] BSTR *retval ); + + [propget, id(0x60020004)] + HRESULT Width( [out, retval] LONG *retval ); +} + +[ + object, + oleautomation, + dual, + nonextensible, + uuid(81ddc1b8-9d35-47a6-b471-5b80f519223b), + pointer_default(unique), +] +interface ICategory : IDispatch +{ + [propget, id(DISPID_VALUE)] + HRESULT Name( [out, retval] BSTR *retval ); + + [propget, id(0x60020001)] + HRESULT CategoryID( [out, retval] BSTR *retval ); + + [propget, id(0x60020002)] + HRESULT Children( [out, retval] ICategoryCollection **retval ); + + [propget, id(0x60020003)] + HRESULT Description( [out, retval] BSTR *retval ); + + [propget, id(0x60020004)] + HRESULT Image( [out, retval] IImageInformation **retval ); + + [propget, id(0x60020005)] + HRESULT Order( [out, retval] LONG *retval ); + + [propget, id(0x60020006)] + HRESULT Parent( [out, retval] ICategory **retval ); + + [propget, id(0x60020007)] + HRESULT Type( [out, retval] BSTR *retval ); + + [propget, id(0x60020008)] + HRESULT Updates( [out, retval] IUpdateCollection **retval ); +} + +[ + object, + oleautomation, + dual, + nonextensible, + uuid(3a56bfb8-576c-43f7-9335-fe4838fd7e37), + pointer_default(unique), +] +interface ICategoryCollection : IDispatch +{ + [propget, id(DISPID_VALUE)] + HRESULT Item( [in] LONG index, + [out, retval] ICategory **retval ); + + [propget, id(DISPID_NEWENUM)] + HRESULT _NewEnum( [out, retval] IUnknown **retval ); + + [propget, id(0x60020001)] + HRESULT Count( [out, retval] LONG *retval ); +} + +[ + object, + oleautomation, + dual, + nonextensible, + uuid(eff90582-2ddc-480f-a06d-60f3fbc362c3), + pointer_default(unique), + hidden +] +interface IStringCollection : IDispatch +{ + [propget, id(DISPID_VALUE)] + HRESULT Item( [in] LONG index, + [out, retval] BSTR *retval ); + + [propput, id(DISPID_VALUE)] + HRESULT Item( [in] LONG index, + [in] BSTR value ); + + [propget, id(DISPID_NEWENUM)] + HRESULT _NewEnum( [out, retval] IUnknown **retval ); + + [propget, id(0x60020001)] + HRESULT Count( [out, retval] LONG *retval ); + + [propget, id(0x60020002)] + HRESULT ReadOnly( [out, retval] VARIANT_BOOL *retval ); + + [id(0x60020003)] + HRESULT Add( [in] BSTR value, + [out, retval] LONG *retval ); + + [id(0x60020004)] + HRESULT Clear(); + + [id(0x60020005)] + HRESULT Copy( [out, retval] IStringCollection **retval ); + + [id(0x60020006)] + HRESULT Insert( [in] LONG index, + [in] BSTR value ); + + [id(0x60020007)] + HRESULT RemoveAt( [in] LONG index ); +} + +[ + object, + oleautomation, + dual, + nonextensible, + uuid(a376dd5e-09d4-427f-af7c-fed5b6e1c1d6), + pointer_default(unique), +] +interface IUpdateException : IDispatch +{ + [propget, id(DISPID_VALUE)] + HRESULT Message( [out, retval] BSTR *retval ); + + [propget, id(0x60020001)] + HRESULT HResult( [out, retval] LONG *retval ); + + [propget, id(0x60020002)] + HRESULT Context( [out, retval] UpdateExceptionContext *retval ); +} + +[ + object, + oleautomation, + dual, + nonextensible, + uuid(503626a3-8e14-4729-9355-0fe664bd2321), + pointer_default(unique), +] +interface IUpdateExceptionCollection : IDispatch +{ + [propget, id(DISPID_VALUE)] + HRESULT Item( [in] LONG index, + [out, retval] IUpdateException **retval ); + + [propget, id(DISPID_NEWENUM)] + HRESULT _NewEnum( [out, retval] IUnknown **retval ); + + [propget, id(0x60020001)] + HRESULT Count( [out, retval] LONG *retval ); +} + +[ + object, + oleautomation, + dual, + nonextensible, + uuid(46297823-9940-4c09-aed9-cd3ea6d05968), + pointer_default(unique) +] +interface IUpdateIdentity : IDispatch +{ + [propget, id(0x60020002)] + HRESULT RevisionNumber( [out, retval] LONG *retval ); + + [propget, id(0x60020003)] + HRESULT UpdateID( [out, retval] BSTR *retval ); +} + +[ + , + object, + oleautomation, + dual, + nonextensible, + uuid(d9a59339-e245-4dbd-9686-4d5763e39624), + pointer_default(unique), +] +interface IInstallationBehavior : IDispatch +{ + [propget, id(0x60020001)] + HRESULT CanRequestUserInput( [out, retval] VARIANT_BOOL *retval ); + + [propget, id(0x60020002)] + HRESULT Impact( [out, retval] InstallationImpact *retval ); + + [propget, id(0x60020003)] + HRESULT RebootBehavior( [out, retval] InstallationRebootBehavior *retval ); + + [propget, id(0x60020004)] + HRESULT RequiresNetworkConnectivity( [out, retval] VARIANT_BOOL *retval ); +} + +[ + object, + oleautomation, + dual, + nonextensible, + uuid(54a2cb2d-9a0c-48b6-8a50-9abb69ee2d02), + pointer_default(unique), +] +interface IUpdateDownloadContent : IDispatch +{ + [propget, id(0x60020001)] + HRESULT DownloadUrl( [out, retval] BSTR *retval ); +} + +[ + object, + oleautomation, + dual, + nonextensible, + uuid(bc5513c8-b3b8-4bf7-a4d4-361c0d8c88ba), + pointer_default(unique), +] +interface IUpdateDownloadContentCollection : IDispatch +{ + [propget, id(DISPID_VALUE)] + HRESULT Item( [in] LONG index, + [out, retval] IUpdateDownloadContent **retval ); + + [propget, id(DISPID_NEWENUM)] + HRESULT _NewEnum( [out, retval] IUnknown **retval ); + + [propget, id(0x60020001)] + HRESULT Count( [out, retval] LONG *retval ); +} + +[ + + object, + oleautomation, + dual, + nonextensible, + uuid(6a92b07a-d821-4682-b423-5c805022cc4d), + pointer_default(unique), +] +interface IUpdate : IDispatch +{ + [propget, id(DISPID_VALUE)] + HRESULT Title( [out, retval] BSTR *retval ); + + [propget, id(0x60020001)] + HRESULT AutoSelectOnWebSites( [out, retval] VARIANT_BOOL *retval ); + + [propget, id(0x60020002)] + HRESULT BundledUpdates( [out, retval] IUpdateCollection **retval ); + + [propget, id(0x60020003)] + HRESULT CanRequireSource( [out, retval] VARIANT_BOOL *retval ); + + [propget, id(0x60020004)] + HRESULT Categories( [out, retval] ICategoryCollection **retval ); + + [propget, id(0x60020005)] + HRESULT Deadline( [out, retval] VARIANT *retval ); + + [propget, id(0x60020006)] + HRESULT DeltaCompressedContentAvailable( [out, retval] VARIANT_BOOL *retval ); + + [propget, id(0x60020007)] + HRESULT DeltaCompressedContentPreferred( [out, retval] VARIANT_BOOL *retval ); + + [propget, id(0x60020008)] + HRESULT Description( [out, retval] BSTR *retval ); + + [propget, id(0x60020009)] + HRESULT EulaAccepted( [out, retval] VARIANT_BOOL *retval ); + + [propget, id(0x6002000a)] + HRESULT EulaText( [out, retval] BSTR *retval ); + + [propget, id(0x6002000b)] + HRESULT HandlerID( [out, retval] BSTR *retval ); + + [propget, id(0x6002000c)] + HRESULT Identity( [out, retval] IUpdateIdentity **retval ); + + [propget, id(0x6002000d)] + HRESULT Image( [out, retval] IImageInformation **retval ); + + [propget, id(0x6002000e)] + HRESULT InstallationBehavior( [out, retval] IInstallationBehavior **retval ); + + [propget, id(0x6002000f)] + HRESULT IsBeta( [out, retval] VARIANT_BOOL *retval ); + + [propget, id(0x60020010)] + HRESULT IsDownloaded( [out, retval] VARIANT_BOOL *retval ); + + [propget, id(0x60020011)] + HRESULT IsHidden( [out, retval] VARIANT_BOOL *retval ); + + [propput, id(0x60020011)] + HRESULT IsHidden( [in] VARIANT_BOOL value ); + + [propget, id(0x60020012)] + HRESULT IsInstalled( [out, retval] VARIANT_BOOL *retval ); + + [propget, id(0x60020013)] + HRESULT IsMandatory( [out, retval] VARIANT_BOOL *retval ); + + [propget, id(0x60020014)] + HRESULT IsUninstallable( [out, retval] VARIANT_BOOL *retval ); + + [propget, id(0x60020015)] + HRESULT Languages( [out, retval] IStringCollection **retval ); + + [propget, id(0x60020016)] + HRESULT LastDeploymentChangeTime( [out, retval] DATE *retval ); + + [propget, id(0x60020017)] + HRESULT MaxDownloadSize( [out, retval] DECIMAL *retval ); + + [propget, id(0x60020018)] + HRESULT MinDownloadSize( [out, retval] DECIMAL *retval ); + + [propget, id(0x60020019)] + HRESULT MoreInfoUrls( [out, retval] IStringCollection **retval ); + + [propget, id(0x6002001a)] + HRESULT MsrcSeverity( [out, retval] BSTR *retval ); + + [propget, id(0x6002001b)] + HRESULT RecommendedCpuSpeed( [out, retval] LONG *retval ); + + [propget, id(0x6002001c)] + HRESULT RecommendedHardDiskSpace( [out, retval] LONG *retval ); + + [propget, id(0x6002001d)] + HRESULT RecommendedMemory( [out, retval] LONG *retval ); + + [propget, id(0x6002001e)] + HRESULT ReleaseNotes( [out, retval] BSTR *retval ); + + [propget, id(0x6002001f)] + HRESULT SecurityBulletinIDs( [out, retval] IStringCollection **retval ); + + [propget, id(0x60020021)] + HRESULT SupersededUpdateIDs( [out, retval] IStringCollection **retval ); + + [propget, id(0x60020022)] + HRESULT SupportUrl( [out, retval] BSTR *retval ); + + [propget, id(0x60020023)] + HRESULT Type( [out, retval] UpdateType *retval ); + + [propget, id(0x60020024)] + HRESULT UninstallationNotes( [out, retval] BSTR *retval ); + + [propget, id(0x60020025)] + HRESULT UninstallationBehavior( [out, retval] IInstallationBehavior **retval ); + + [propget, id(0x60020026)] + HRESULT UninstallationSteps( [out, retval] IStringCollection **retval ); + + [propget, id(0x60020028)] + HRESULT KBArticleIDs( [out, retval] IStringCollection **retval ); + + [id(0x60020027)] + HRESULT AcceptEula(); + + [propget, id(0x60020029)] + HRESULT DeploymentAction( [out, retval] DeploymentAction *retval ); + + [id(0x6002002a)] + HRESULT CopyFromCache( [in, ref] BSTR path, + [in] VARIANT_BOOL toExtractCabFiles ); + + [propget, id(0x6002002b)] + HRESULT DownloadPriority( [out, retval] DownloadPriority *retval ); + + [propget, id(0x6002002c)] + HRESULT DownloadContents( [out, retval] IUpdateDownloadContentCollection **retval ); +} + +[ + + object, + oleautomation, + dual, + nonextensible, + uuid(07f7438c-7709-4ca5-b518-91279288134e), + pointer_default(unique), + hidden +] +interface IUpdateCollection : IDispatch +{ + [propget, id(DISPID_VALUE)] + HRESULT Item( [in] LONG index, + [out, retval] IUpdate **retval ); + + [propput, id(DISPID_VALUE)] + HRESULT Item( [in] LONG index, + [in] IUpdate *value ); + + [propget, id(DISPID_NEWENUM)] + HRESULT _NewEnum( [out, retval] IUnknown **retval ); + + [propget, id(0x60020001)] + HRESULT Count( [out, retval] LONG *retval ); + + [propget, id(0x60020002)] + HRESULT ReadOnly( [out, retval] VARIANT_BOOL *retval ); + + [id(0x60020003)] + HRESULT Add( [in] IUpdate *value, + [out, retval] LONG *retval ); + + [id(0x60020004)] + HRESULT Clear(); + + [id(0x60020005)] + HRESULT Copy( [out, retval] IUpdateCollection **retval ); + + [id(0x60020006)] + HRESULT Insert( [in] LONG index, + [in] IUpdate *value ); + + [id(0x60020007)] + HRESULT RemoveAt( [in] LONG index ); +} + +[ + object, + oleautomation, + dual, + nonextensible, + uuid(7366ea16-7a1a-4ea2-b042-973d3e9cd99b), + pointer_default(unique), +] +interface ISearchJob : IDispatch +{ + [propget, id(0x60020001)] + HRESULT AsyncState( [out, retval] VARIANT *retval ); + + [propget, id(0x60020002)] + HRESULT IsCompleted( [out, retval] VARIANT_BOOL *retval ); + + [id(0x60020003)] + HRESULT CleanUp(); + + [id(0x60020004)] + HRESULT RequestAbort(); +} + +[ + object, + oleautomation, + dual, + nonextensible, + uuid(d40cff62-e08c-4498-941a-01e25f0fd33c), + pointer_default(unique), +] +interface ISearchResult : IDispatch +{ + [propget, id(0x60020001)] + HRESULT ResultCode( [out, retval] OperationResultCode *retval ); + + [propget, id(0x60020002)] + HRESULT RootCategories( [out, retval] ICategoryCollection **retval ); + + [propget, id(0x60020003)] + HRESULT Updates( [out, retval] IUpdateCollection **retval ); + + [propget, id(0x60020004)] + HRESULT Warnings( [out, retval] IUpdateExceptionCollection **retval ); +} + +[ + object, + oleautomation, + dual, + nonextensible, + uuid(be56a644-af0e-4e0e-a311-c1d8e695cbff), + pointer_default(unique), +] +interface IUpdateHistoryEntry : IDispatch +{ + [propget, id(0x60020001)] + HRESULT Operation( [out, retval] UpdateOperation *retval ); + + [propget, id(0x60020002)] + HRESULT ResultCode( [out, retval] OperationResultCode *retval ); + + [propget, id(0x60020003)] + HRESULT HResult( [out, retval] LONG *retval ); + + [propget, id(0x60020004)] + HRESULT Date( [out, retval] DATE *retval ); + + [propget, id(0x60020005)] + HRESULT UpdateIdentity( [out, retval] IUpdateIdentity **retval ); + + [propget, id(0x60020006)] + HRESULT Title( [out, retval] BSTR *retval ); + + [propget, id(0x60020007)] + HRESULT Description( [out, retval] BSTR *retval ); + + [propget, id(0x60020008)] + HRESULT UnmappedResultCode( [out, retval] LONG *retval ); + + [propget, id(0x60020009)] + HRESULT ClientApplicationID( [out, retval] BSTR *retval ); + + [propget, id(0x6002000a)] + HRESULT ServerSelection( [out, retval] ServerSelection *retval ); + + [propget, id(0x6002000b)] + HRESULT ServiceID( [out, retval] BSTR *retval ); + + [propget, id(0x6002000c)] + HRESULT UninstallationSteps( [out, retval] IStringCollection **retval ); + + [propget, id(0x6002000d)] + HRESULT UninstallationNotes( [out, retval] BSTR *retval ); + + [propget, id(0x6002000e)] + HRESULT SupportUrl( [out, retval] BSTR *retval ); +} + +[ + object, + oleautomation, + dual, + nonextensible, + uuid(a7f04f3c-a290-435b-aadf-a116c3357a5c), + pointer_default(unique), +] +interface IUpdateHistoryEntryCollection : IDispatch +{ + [propget, id(DISPID_VALUE)] + HRESULT Item( [in] LONG index, + [out, retval] IUpdateHistoryEntry **retval ); + + [propget, id(DISPID_NEWENUM)] + HRESULT _NewEnum( [out, retval] IUnknown **retval ); + + [propget, id(0x60020001)] + HRESULT Count( [out, retval] LONG *retval ); +} + [ object, uuid(8f45abf1-f9ae-4b95-a933-f0f66e5056ea), @@ -204,6 +942,113 @@ interface IUpdateSearcher : IDispatch [in] BSTR value); } +[ + object, + oleautomation, + dual, + nonextensible, + uuid(bf99af76-b575-42ad-8aa4-33cbb5477af1), + pointer_default(unique), +] +interface IUpdateDownloadResult : IDispatch +{ + [propget, id(0x60020001)] + HRESULT HResult( [out, retval] LONG *retval ); + + [propget, id(0x60020002)] + HRESULT ResultCode( [out, retval] OperationResultCode *retval ); +} + +[ + object, + oleautomation, + dual, + nonextensible, + uuid(d31a5bac-f719-4178-9dbb-5e2cb47fd18a), + pointer_default(unique), +] +interface IDownloadProgress : IDispatch +{ + [propget, id(0x60020001)] + HRESULT CurrentUpdateBytesDownloaded( [out, retval] DECIMAL *retval ); + + [propget, id(0x60020002)] + HRESULT CurrentUpdateBytesToDownload( [out, retval] DECIMAL *retval ); + + [propget, id(0x60020003)] + HRESULT CurrentUpdateIndex( [out, retval] LONG *retval ); + + [propget, id(0x60020004)] + HRESULT PercentComplete( [out, retval] LONG *retval ); + + [propget, id(0x60020005)] + HRESULT TotalBytesDownloaded( [out, retval] DECIMAL *retval ); + + [propget, id(0x60020006)] + HRESULT TotalBytesToDownload( [out, retval] DECIMAL *retval ); + + [id(0x60020007)] + HRESULT GetUpdateResult( [in] LONG updateIndex, + [out, retval] IUpdateDownloadResult **retval ); + + + [propget, id(0x60020008)] + HRESULT CurrentUpdateDownloadPhase( [out, retval] DownloadPhase *retval ); + + [propget, id(0x60020009)] + HRESULT CurrentUpdatePercentComplete( [out, retval] LONG *retval ); +} + +[ + object, + oleautomation, + dual, + nonextensible, + uuid(c574de85-7358-43f6-aae8-8697e62d8ba7), + pointer_default(unique), +] +interface IDownloadJob : IDispatch +{ + [propget, id(0x60020001)] + HRESULT AsyncState( [out, retval] VARIANT *retval ); + + [propget, id(0x60020002)] + HRESULT IsCompleted( [out, retval] VARIANT_BOOL *retval ); + + [propget, id(0x60020003)] + HRESULT Updates( [out, retval] IUpdateCollection **retval ); + + [id(0x60020004)] + HRESULT CleanUp(); + + [id(0x60020005)] + HRESULT GetProgress( [out, retval] IDownloadProgress **retval ); + + [id(0x60020006)] + HRESULT RequestAbort(); +} + +[ + object, + oleautomation, + dual, + nonextensible, + uuid(daa4fdd0-4727-4dbe-a1e7-745dca317144), + pointer_default(unique), +] +interface IDownloadResult : IDispatch +{ + [propget, id(0x60020001)] + HRESULT HResult( [out, retval] LONG *retval ); + + [propget, id(0x60020002)] + HRESULT ResultCode( [out, retval] OperationResultCode *retval ); + + [id(0x60020003)] + HRESULT GetUpdateResult( [in] LONG updateIndex, + [out, retval] IUpdateDownloadResult **retval ); +} + [ object, uuid(68f1c6f9-7ecc-4666-a464-247fe12496c3), @@ -261,6 +1106,103 @@ interface IUpdateDownloader : IDispatch [out, retval] IDownloadResult **retval); } +[ + object, + oleautomation, + dual, + nonextensible, + uuid(d940f0f8-3cbb-4fd0-993f-471e7f2328ad), + pointer_default(unique), +] +interface IUpdateInstallationResult : IDispatch +{ + [propget, id(0x60020001)] + HRESULT HResult( [out, retval] LONG *retval ); + + [propget, id(0x60020002)] + HRESULT RebootRequired( [out, retval] VARIANT_BOOL *retval ); + + [propget, id(0x60020003)] + HRESULT ResultCode( [out, retval] OperationResultCode *retval ); +} + +[ + object, + oleautomation, + dual, + nonextensible, + uuid(345c8244-43a3-4e32-a368-65f073b76f36), + pointer_default(unique), +] +interface IInstallationProgress : IDispatch +{ + [propget, id(0x60020001)] + HRESULT CurrentUpdateIndex( [out, retval] LONG *retval ); + + [propget, id(0x60020002)] + HRESULT CurrentUpdatePercentComplete( [out, retval] LONG *retval ); + + [propget, id(0x60020003)] + HRESULT PercentComplete( [out, retval] LONG *retval ); + + [id(0x60020004)] + HRESULT GetUpdateResult( [in] LONG updateIndex, + [out, retval] IUpdateInstallationResult **retval ); +} + +[ + object, + oleautomation, + dual, + nonextensible, + uuid(5c209f0b-bad5-432a-9556-4699bed2638a), + pointer_default(unique), +] +interface IInstallationJob : IDispatch +{ + [propget, id(0x60020001)] + HRESULT AsyncState( [out, retval] VARIANT *retval ); + + [propget, id(0x60020002)] + HRESULT IsCompleted( [out, retval] VARIANT_BOOL *retval ); + + [propget, id(0x60020003)] + HRESULT Updates( [out, retval] IUpdateCollection **retval ); + + [id(0x60020004)] + HRESULT CleanUp(); + + [id(0x60020005)] + HRESULT GetProgress( [out, retval] IInstallationProgress **retval ); + + [id(0x60020006)] + HRESULT RequestAbort(); +} + +[ + object, + oleautomation, + dual, + nonextensible, + uuid(a43c56d6-7451-48d4-af96-b6cd2d0d9b7a), + pointer_default(unique), +] +interface IInstallationResult : IDispatch +{ + [propget, id(0x60020001)] + HRESULT HResult( [out, retval] LONG *retval ); + + [propget, id(0x60020002)] + HRESULT RebootRequired( [out, retval] VARIANT_BOOL *retval ); + + [propget, id(0x60020003)] + HRESULT ResultCode( [out, retval] OperationResultCode *retval ); + + [id(0x60020004)] + HRESULT GetUpdateResult( [in] LONG updateIndex, + [out, retval] IUpdateInstallationResult **retval ); +} + [ object, uuid(7b929c68-ccdc-4226-96b1-8724600b54c2), @@ -357,3 +1299,23 @@ interface IUpdateInstaller : IDispatch HRESULT RebootRequiredBeforeInstallation( [out, retval] VARIANT_BOOL *retval); } + +[ + helpstring("AutomaticUpdates Class"), + threading(both), + progid("Microsoft.Update.AutoUpdate.1"), + vi_progid("Microsoft.Update.AutoUpdate"), + uuid(bfe18e9c-6d87-4450-b37c-e02f0b373803) +] +coclass AutomaticUpdates { interface IAutomaticUpdates; } + +[ + helpstring("UpdateSession Class"), + threading(both), + progid("Microsoft.Update.Session.1"), + vi_progid("Microsoft.Update.Session"), + uuid(4cb43d7f-7eee-4906-8698-60da1c38f2fe) +] +coclass UpdateSession { interface IUpdateSession; } + +} /* WUApiLib */ From f683f3f37aed7400a02eedd72a421a69ed3c7d64 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Mon, 20 Dec 2010 20:36:21 +0000 Subject: [PATCH 070/181] [WINHTTP] - Sync to Wine 1.3.9 svn path=/trunk/; revision=50071 --- reactos/dll/win32/winhttp/net.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/reactos/dll/win32/winhttp/net.c b/reactos/dll/win32/winhttp/net.c index d709c311816..276d4d73622 100644 --- a/reactos/dll/win32/winhttp/net.c +++ b/reactos/dll/win32/winhttp/net.c @@ -92,7 +92,7 @@ static CRITICAL_SECTION init_ssl_cs = { &init_ssl_cs_debug, -1, 0, 0, 0, 0 }; static void *libssl_handle; static void *libcrypto_handle; -#if defined(OPENSSL_VERSION_NUMBER) && (OPENSSL_VERSION_NUMBER> 0x1000000) +#if defined(OPENSSL_VERSION_NUMBER) && (OPENSSL_VERSION_NUMBER > 0x10000000) static const SSL_METHOD *method; #else static SSL_METHOD *method; @@ -277,7 +277,8 @@ static DWORD netconn_verify_cert( PCCERT_CONTEXT cert, HCERTSTORE store, TRACE("verifying %s\n", debugstr_w( server )); chainPara.RequestedUsage.Usage.cUsageIdentifier = 1; chainPara.RequestedUsage.Usage.rgpszUsageIdentifier = server_auth; - if ((ret = CertGetCertificateChain( NULL, cert, NULL, store, &chainPara, 0, + if ((ret = CertGetCertificateChain( NULL, cert, NULL, store, &chainPara, + CERT_CHAIN_REVOCATION_CHECK_CHAIN_EXCLUDE_ROOT, NULL, &chain ))) { if (chain->TrustStatus.dwErrorStatus) @@ -330,6 +331,7 @@ static DWORD netconn_verify_cert( PCCERT_CONTEXT cert, HCERTSTORE store, sslExtraPolicyPara.u.cbSize = sizeof(sslExtraPolicyPara); sslExtraPolicyPara.dwAuthType = AUTHTYPE_SERVER; sslExtraPolicyPara.pwszServerName = server; + sslExtraPolicyPara.fdwChecks = security_flags; policyPara.cbSize = sizeof(policyPara); policyPara.dwFlags = 0; policyPara.pvExtraPolicyPara = &sslExtraPolicyPara; @@ -342,10 +344,7 @@ static DWORD netconn_verify_cert( PCCERT_CONTEXT cert, HCERTSTORE store, if (ret && policyStatus.dwError) { if (policyStatus.dwError == CERT_E_CN_NO_MATCH) - { - if (!(security_flags & SECURITY_FLAG_IGNORE_CERT_CN_INVALID)) - err = ERROR_WINHTTP_SECURE_CERT_CN_INVALID; - } + err = ERROR_WINHTTP_SECURE_CERT_CN_INVALID; else err = ERROR_WINHTTP_SECURE_INVALID_CERT; } @@ -876,10 +875,10 @@ BOOL netconn_get_next_line( netconn_t *conn, char *buffer, DWORD *buflen ) return FALSE; #endif } - + FD_ZERO(&infd); FD_SET(conn->socket, &infd); - + while (recvd < *buflen) { int res; @@ -890,7 +889,7 @@ BOOL netconn_get_next_line( netconn_t *conn, char *buffer, DWORD *buflen ) ptv = &tv; else ptv = NULL; - + if (select( 0, &infd, NULL, NULL, ptv ) > 0) { if ((res = recv( conn->socket, &buffer[recvd], 1, 0 )) <= 0) @@ -1086,7 +1085,11 @@ const void *netconn_get_certificate( netconn_t *conn ) int netconn_get_cipher_strength( netconn_t *conn ) { #ifdef SONAME_LIBSSL +#if defined(OPENSSL_VERSION_NUMBER) && (OPENSSL_VERSION_NUMBER >= 0x0090707f) + const SSL_CIPHER *cipher; +#else SSL_CIPHER *cipher; +#endif int bits = 0; if (!conn->secure) return 0; From cbbeec3a07b76dcd45d4b8f83b38b8c3c5f9765e Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Mon, 20 Dec 2010 20:57:22 +0000 Subject: [PATCH 071/181] [NDIS] - Fix sizeof typo - CID 10400 svn path=/trunk/; revision=50072 --- reactos/drivers/network/ndis/ndis/miniport.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reactos/drivers/network/ndis/ndis/miniport.c b/reactos/drivers/network/ndis/ndis/miniport.c index 8b551db8a13..dd6227f2137 100644 --- a/reactos/drivers/network/ndis/ndis/miniport.c +++ b/reactos/drivers/network/ndis/ndis/miniport.c @@ -1600,7 +1600,7 @@ NdisMRegisterAdapterShutdownHandler( KeInitializeCallbackRecord(BugcheckContext->CallbackRecord); KeRegisterBugCheckCallback(BugcheckContext->CallbackRecord, NdisIBugcheckCallback, - BugcheckContext, sizeof(BugcheckContext), (PUCHAR)"Ndis Miniport"); + BugcheckContext, sizeof(*BugcheckContext), (PUCHAR)"Ndis Miniport"); IoRegisterShutdownNotification(Adapter->NdisMiniportBlock.DeviceObject); } From 72fa05f13be46af03e317b3d12a78811dd4a862a Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Mon, 20 Dec 2010 21:25:11 +0000 Subject: [PATCH 072/181] [WININET] - Sync to Wine 1.3.9 svn path=/trunk/; revision=50073 --- reactos/dll/win32/wininet/http.c | 18 +++++++++ reactos/dll/win32/wininet/internet.c | 49 ++++++++++++++++++++--- reactos/dll/win32/wininet/netconnection.c | 18 ++++++--- reactos/dll/win32/wininet/wininet.spec | 6 +-- 4 files changed, 77 insertions(+), 14 deletions(-) diff --git a/reactos/dll/win32/wininet/http.c b/reactos/dll/win32/wininet/http.c index 324f6c5f535..796c3595f7b 100644 --- a/reactos/dll/win32/wininet/http.c +++ b/reactos/dll/win32/wininet/http.c @@ -5169,3 +5169,21 @@ BOOL WINAPI IsHostInProxyBypassList(DWORD flags, LPCSTR szHost, DWORD length) FIXME("STUB: flags=%d host=%s length=%d\n",flags,szHost,length); return FALSE; } + +/*********************************************************************** + * InternetShowSecurityInfoByURLA (@) + */ +BOOL WINAPI InternetShowSecurityInfoByURLA(LPCSTR url, HWND window) +{ + FIXME("stub: %s %p\n", url, window); + return FALSE; +} + +/*********************************************************************** + * InternetShowSecurityInfoByURLW (@) + */ +BOOL WINAPI InternetShowSecurityInfoByURLW(LPCWSTR url, HWND window) +{ + FIXME("stub: %s %p\n", debugstr_w(url), window); + return FALSE; +} diff --git a/reactos/dll/win32/wininet/internet.c b/reactos/dll/win32/wininet/internet.c index 89337ac6d1a..94df521e5e4 100644 --- a/reactos/dll/win32/wininet/internet.c +++ b/reactos/dll/win32/wininet/internet.c @@ -1370,8 +1370,9 @@ BOOL WINAPI InternetCrackUrlA(LPCSTR lpszUrl, DWORD dwUrlLength, DWORD dwFlags, InternetCrackUrlW should not include it */ if (dwUrlLength == -1) nLength--; - lpwszUrl = HeapAlloc(GetProcessHeap(), 0, nLength * sizeof(WCHAR)); - MultiByteToWideChar(CP_ACP,0,lpszUrl,dwUrlLength,lpwszUrl,nLength); + lpwszUrl = HeapAlloc(GetProcessHeap(), 0, (nLength + 1) * sizeof(WCHAR)); + MultiByteToWideChar(CP_ACP,0,lpszUrl,dwUrlLength,lpwszUrl,nLength + 1); + lpwszUrl[nLength] = '\0'; memset(&UCW,0,sizeof(UCW)); UCW.dwStructSize = sizeof(URL_COMPONENTSW); @@ -1788,7 +1789,7 @@ BOOL WINAPI InternetCrackUrlW(LPCWSTR lpszUrl_orig, DWORD dwUrlLength_orig, DWOR */ if (lpszcp != 0 && lpszcp - lpszUrl < dwUrlLength && (!lpszParam || lpszcp <= lpszParam)) { - INT len; + DWORD len; /* Only truncate the parameter list if it's already been saved * in lpUC->lpszExtraInfo. @@ -1806,8 +1807,46 @@ BOOL WINAPI InternetCrackUrlW(LPCWSTR lpszUrl_orig, DWORD dwUrlLength_orig, DWOR else len = dwUrlLength-(lpszcp-lpszUrl); } - SetUrlComponentValueW(&lpUC->lpszUrlPath, &lpUC->dwUrlPathLength, - lpszcp, len); + if (lpUC->dwUrlPathLength && lpUC->lpszUrlPath && + lpUC->nScheme == INTERNET_SCHEME_FILE) + { + WCHAR tmppath[MAX_PATH]; + if (*lpszcp == '/') + { + len = MAX_PATH; + PathCreateFromUrlW(lpszUrl_orig, tmppath, &len, 0); + } + else + { + WCHAR *iter; + memcpy(tmppath, lpszcp, len * sizeof(WCHAR)); + tmppath[len] = '\0'; + + iter = tmppath; + while (*iter) { + if (*iter == '/') + *iter = '\\'; + ++iter; + } + } + /* if ends in \. or \.. append a backslash */ + if (tmppath[len - 1] == '.' && + (tmppath[len - 2] == '\\' || + (tmppath[len - 2] == '.' && tmppath[len - 3] == '\\'))) + { + if (len < MAX_PATH - 1) + { + tmppath[len] = '\\'; + tmppath[len+1] = '\0'; + ++len; + } + } + SetUrlComponentValueW(&lpUC->lpszUrlPath, &lpUC->dwUrlPathLength, + tmppath, len); + } + else + SetUrlComponentValueW(&lpUC->lpszUrlPath, &lpUC->dwUrlPathLength, + lpszcp, len); } else { diff --git a/reactos/dll/win32/wininet/netconnection.c b/reactos/dll/win32/wininet/netconnection.c index 6e569a325ec..402cfd16a53 100644 --- a/reactos/dll/win32/wininet/netconnection.c +++ b/reactos/dll/win32/wininet/netconnection.c @@ -114,7 +114,7 @@ static CRITICAL_SECTION init_ssl_cs = { &init_ssl_cs_debug, -1, 0, 0, 0, 0 }; static void *OpenSSL_ssl_handle; static void *OpenSSL_crypto_handle; -#if defined(OPENSSL_VERSION_NUMBER) && (OPENSSL_VERSION_NUMBER> 0x1000000) +#if defined(OPENSSL_VERSION_NUMBER) && (OPENSSL_VERSION_NUMBER > 0x10000000) static const SSL_METHOD *meth; #else static SSL_METHOD *meth; @@ -152,7 +152,6 @@ MAKE_FUNCPTR(SSL_CTX_set_default_verify_paths); MAKE_FUNCPTR(SSL_CTX_set_verify); MAKE_FUNCPTR(SSL_get_current_cipher); MAKE_FUNCPTR(SSL_CIPHER_get_bits); -MAKE_FUNCPTR(X509_STORE_CTX_get_ex_data); /* OpenSSL's libcrypto functions that we use */ MAKE_FUNCPTR(BIO_new_fp); @@ -162,6 +161,7 @@ MAKE_FUNCPTR(CRYPTO_set_locking_callback); MAKE_FUNCPTR(ERR_free_strings); MAKE_FUNCPTR(ERR_get_error); MAKE_FUNCPTR(ERR_error_string); +MAKE_FUNCPTR(X509_STORE_CTX_get_ex_data); MAKE_FUNCPTR(i2d_X509); MAKE_FUNCPTR(sk_num); MAKE_FUNCPTR(sk_value); @@ -228,13 +228,15 @@ static DWORD netconn_verify_cert(PCCERT_CONTEXT cert, HCERTSTORE store, PCCERT_CHAIN_CONTEXT chain; char oid_server_auth[] = szOID_PKIX_KP_SERVER_AUTH; char *server_auth[] = { oid_server_auth }; - DWORD err = ERROR_SUCCESS; + DWORD err = ERROR_SUCCESS, chainFlags = 0; TRACE("verifying %s\n", debugstr_w(server)); chainPara.RequestedUsage.Usage.cUsageIdentifier = 1; chainPara.RequestedUsage.Usage.rgpszUsageIdentifier = server_auth; - if ((ret = CertGetCertificateChain(NULL, cert, NULL, store, &chainPara, 0, - NULL, &chain))) + if (!(security_flags & SECURITY_FLAG_IGNORE_REVOCATION)) + chainFlags |= CERT_CHAIN_REVOCATION_CHECK_CHAIN_EXCLUDE_ROOT; + if ((ret = CertGetCertificateChain(NULL, cert, NULL, store, &chainPara, + chainFlags, NULL, &chain))) { if (chain->TrustStatus.dwErrorStatus) { @@ -431,7 +433,6 @@ DWORD NETCON_init(WININET_NETCONNECTION *connection, BOOL useSSL) DYNSSL(SSL_CTX_set_verify); DYNSSL(SSL_get_current_cipher); DYNSSL(SSL_CIPHER_get_bits); - DYNSSL(X509_STORE_CTX_get_ex_data); #undef DYNSSL #define DYNCRYPTO(x) \ @@ -449,6 +450,7 @@ DWORD NETCON_init(WININET_NETCONNECTION *connection, BOOL useSSL) DYNCRYPTO(ERR_free_strings); DYNCRYPTO(ERR_get_error); DYNCRYPTO(ERR_error_string); + DYNCRYPTO(X509_STORE_CTX_get_ex_data); DYNCRYPTO(i2d_X509); DYNCRYPTO(sk_num); DYNCRYPTO(sk_value); @@ -877,7 +879,11 @@ LPCVOID NETCON_GetCert(WININET_NETCONNECTION *connection) int NETCON_GetCipherStrength(WININET_NETCONNECTION *connection) { #ifdef SONAME_LIBSSL +#if defined(OPENSSL_VERSION_NUMBER) && (OPENSSL_VERSION_NUMBER >= 0x0090707f) + const SSL_CIPHER *cipher; +#else SSL_CIPHER *cipher; +#endif int bits = 0; if (!connection->useSSL) diff --git a/reactos/dll/win32/wininet/wininet.spec b/reactos/dll/win32/wininet/wininet.spec index 46dd04334e6..bb11d7ed78a 100644 --- a/reactos/dll/win32/wininet/wininet.spec +++ b/reactos/dll/win32/wininet/wininet.spec @@ -195,9 +195,9 @@ @ stdcall InternetSetStatusCallback(ptr ptr) InternetSetStatusCallbackA @ stdcall InternetSetStatusCallbackA(ptr ptr) @ stdcall InternetSetStatusCallbackW(ptr ptr) -@ stub InternetShowSecurityInfoByURL -@ stub InternetShowSecurityInfoByURLA -@ stub InternetShowSecurityInfoByURLW +@ stdcall InternetShowSecurityInfoByURL(str ptr) InternetShowSecurityInfoByURLA +@ stdcall InternetShowSecurityInfoByURLA(str ptr) +@ stdcall InternetShowSecurityInfoByURLW(wstr ptr) @ stdcall InternetTimeFromSystemTime(ptr long ptr long) InternetTimeFromSystemTimeA @ stdcall InternetTimeFromSystemTimeA(ptr long ptr long) @ stdcall InternetTimeFromSystemTimeW(ptr long ptr long) From 6c76be5e63aaf7b18edd57f847a52d9a8a3236be Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Mon, 20 Dec 2010 21:29:55 +0000 Subject: [PATCH 073/181] [URLMON] - Sync to Wine 1.3.9 svn path=/trunk/; revision=50074 --- reactos/dll/win32/urlmon/bindctx.c | 54 +- reactos/dll/win32/urlmon/binding.c | 147 +- reactos/dll/win32/urlmon/bindprot.c | 353 +++-- reactos/dll/win32/urlmon/download.c | 107 +- reactos/dll/win32/urlmon/file.c | 85 +- reactos/dll/win32/urlmon/format.c | 27 +- reactos/dll/win32/urlmon/ftp.c | 191 +-- reactos/dll/win32/urlmon/gopher.c | 12 +- reactos/dll/win32/urlmon/http.c | 241 ++-- reactos/dll/win32/urlmon/protocol.c | 58 + reactos/dll/win32/urlmon/sec_mgr.c | 54 +- reactos/dll/win32/urlmon/session.c | 46 +- reactos/dll/win32/urlmon/umon.c | 21 +- reactos/dll/win32/urlmon/uri.c | 1786 ++++++++++++++++++++---- reactos/dll/win32/urlmon/urlmon.spec | 3 + reactos/dll/win32/urlmon/urlmon_main.c | 245 ++-- reactos/dll/win32/urlmon/urlmon_main.h | 18 +- 17 files changed, 2546 insertions(+), 902 deletions(-) diff --git a/reactos/dll/win32/urlmon/bindctx.c b/reactos/dll/win32/urlmon/bindctx.c index 0b3efa6c874..b08eb80e7a5 100644 --- a/reactos/dll/win32/urlmon/bindctx.c +++ b/reactos/dll/win32/urlmon/bindctx.c @@ -460,9 +460,30 @@ static const IAuthenticateVtbl BSCAuthenticateVtbl = { BSCAuthenticate_Authenticate }; -static IBindStatusCallback *create_bsc(IBindStatusCallback *bsc) +static void set_callback(BindStatusCallback *This, IBindStatusCallback *bsc) { - BindStatusCallback *ret = heap_alloc_zero(sizeof(BindStatusCallback)); + IServiceProvider *serv_prov; + HRESULT hres; + + if(This->callback) + IBindStatusCallback_Release(This->callback); + if(This->serv_prov) + IServiceProvider_Release(This->serv_prov); + + IBindStatusCallback_AddRef(bsc); + This->callback = bsc; + + hres = IBindStatusCallback_QueryInterface(bsc, &IID_IServiceProvider, (void**)&serv_prov); + This->serv_prov = hres == S_OK ? serv_prov : NULL; +} + +HRESULT wrap_callback(IBindStatusCallback *bsc, IBindStatusCallback **ret_iface) +{ + BindStatusCallback *ret; + + ret = heap_alloc_zero(sizeof(BindStatusCallback)); + if(!ret) + return E_OUTOFMEMORY; ret->lpBindStatusCallbackExVtbl = &BindStatusCallbackExVtbl; ret->lpServiceProviderVtbl = &BSCServiceProviderVtbl; @@ -470,13 +491,10 @@ static IBindStatusCallback *create_bsc(IBindStatusCallback *bsc) ret->lpAuthenticateVtbl = &BSCAuthenticateVtbl; ret->ref = 1; + set_callback(ret, bsc); - IBindStatusCallback_AddRef(bsc); - ret->callback = bsc; - - IBindStatusCallback_QueryInterface(bsc, &IID_IServiceProvider, (void**)&ret->serv_prov); - - return STATUSCLB(ret); + *ret_iface = STATUSCLB(ret); + return S_OK; } /*********************************************************************** @@ -511,25 +529,33 @@ HRESULT WINAPI RegisterBindStatusCallback(IBindCtx *pbc, IBindStatusCallback *pb hres = IBindCtx_GetObjectParam(pbc, BSCBHolder, &unk); if(SUCCEEDED(hres)) { hres = IUnknown_QueryInterface(unk, &IID_IBindStatusCallback, (void**)&bsc); + IUnknown_Release(unk); if(SUCCEEDED(hres)) { hres = IBindStatusCallback_QueryInterface(bsc, &IID_IBindStatusCallbackHolder, (void**)&holder); if(SUCCEEDED(hres)) { - prev = holder->callback; - IBindStatusCallback_AddRef(prev); + if(ppbscPrevious) { + IBindStatusCallback_AddRef(holder->callback); + *ppbscPrevious = holder->callback; + } + + set_callback(holder, pbsc); + IBindStatusCallback_Release(bsc); IBindStatusCallback_Release(STATUSCLB(holder)); + return S_OK; }else { prev = bsc; } } - IUnknown_Release(unk); IBindCtx_RevokeObjectParam(pbc, BSCBHolder); } - bsc = create_bsc(pbsc); - hres = IBindCtx_RegisterObjectParam(pbc, BSCBHolder, (IUnknown*)bsc); - IBindStatusCallback_Release(bsc); + hres = wrap_callback(pbsc, &bsc); + if(SUCCEEDED(hres)) { + hres = IBindCtx_RegisterObjectParam(pbc, BSCBHolder, (IUnknown*)bsc); + IBindStatusCallback_Release(bsc); + } if(FAILED(hres)) { if(prev) IBindStatusCallback_Release(prev); diff --git a/reactos/dll/win32/urlmon/binding.c b/reactos/dll/win32/urlmon/binding.c index 02053b0cf39..699bf98a76d 100644 --- a/reactos/dll/win32/urlmon/binding.c +++ b/reactos/dll/win32/urlmon/binding.c @@ -18,6 +18,7 @@ #include "urlmon_main.h" #include "winreg.h" +#include "shlwapi.h" #include "wine/debug.h" @@ -42,7 +43,7 @@ typedef struct { LONG ref; - IInternetProtocol *protocol; + IInternetProtocolEx *protocol; BYTE buf[1024*8]; DWORD size; @@ -76,6 +77,7 @@ typedef enum { #define BINDING_LOCKED 0x0001 #define BINDING_STOPPED 0x0002 #define BINDING_OBJAVAIL 0x0004 +#define BINDING_ABORTED 0x0008 struct Binding { const IBindingVtbl *lpBindingVtbl; @@ -87,7 +89,7 @@ struct Binding { LONG ref; IBindStatusCallback *callback; - IInternetProtocol *protocol; + IInternetProtocolEx *protocol; IServiceProvider *service_provider; stgmed_buf_t *stgmed_buf; @@ -426,7 +428,7 @@ static const IUnknownVtbl StgMedUnkVtbl = { StgMedUnk_Release }; -static stgmed_buf_t *create_stgmed_buf(IInternetProtocol *protocol) +static stgmed_buf_t *create_stgmed_buf(IInternetProtocolEx *protocol) { stgmed_buf_t *ret = heap_alloc(sizeof(*ret)); @@ -631,8 +633,30 @@ static HRESULT WINAPI ProtocolStream_Stat(IStream *iface, STATSTG *pstatstg, DWORD dwStatFlag) { ProtocolStream *This = STREAM_THIS(iface); - FIXME("(%p)->(%p %08x)\n", This, pstatstg, dwStatFlag); - return E_NOTIMPL; + TRACE("(%p)->(%p %08x)\n", This, pstatstg, dwStatFlag); + + if(!pstatstg) + return E_FAIL; + + memset(pstatstg, 0, sizeof(STATSTG)); + + if(!(dwStatFlag&STATFLAG_NONAME) && This->buf->cache_file) { + pstatstg->pwcsName = CoTaskMemAlloc((lstrlenW(This->buf->cache_file)+1)*sizeof(WCHAR)); + if(!pstatstg->pwcsName) + return STG_E_INSUFFICIENTMEMORY; + + lstrcpyW(pstatstg->pwcsName, This->buf->cache_file); + } + + pstatstg->type = STGTY_STREAM; + if(This->buf->file != INVALID_HANDLE_VALUE) { + GetFileSizeEx(This->buf->file, (PLARGE_INTEGER)&pstatstg->cbSize); + GetFileTime(This->buf->file, &pstatstg->ctime, &pstatstg->atime, &pstatstg->mtime); + if(pstatstg->cbSize.QuadPart) + pstatstg->grfMode = GENERIC_READ; + } + + return S_OK; } static HRESULT WINAPI ProtocolStream_Clone(IStream *iface, IStream **ppstm) @@ -682,6 +706,10 @@ static HRESULT stgmed_stream_get_result(stgmed_obj_t *obj, DWORD bindf, void **r { ProtocolStream *stream = (ProtocolStream*)obj; + if(!(bindf & BINDF_ASYNCHRONOUS) && stream->buf->file == INVALID_HANDLE_VALUE + && (stream->buf->hres != S_FALSE || stream->buf->size)) + return INET_E_DATA_NOT_AVAILABLE; + IStream_AddRef(STREAM(stream)); *result = STREAM(stream); return S_OK; @@ -862,10 +890,9 @@ static ULONG WINAPI Binding_Release(IBinding *iface) ReleaseBindInfo(&This->bindinfo); This->section.DebugInfo->Spare[0] = 0; DeleteCriticalSection(&This->section); + SysFreeString(This->url); heap_free(This->mime); heap_free(This->redirect_url); - heap_free(This->url); - heap_free(This); URLMON_UnlockModule(); @@ -877,8 +904,19 @@ static ULONG WINAPI Binding_Release(IBinding *iface) static HRESULT WINAPI Binding_Abort(IBinding *iface) { Binding *This = BINDING_THIS(iface); - FIXME("(%p)\n", This); - return E_NOTIMPL; + HRESULT hres; + + TRACE("(%p)\n", This); + + if(This->state & BINDING_ABORTED) + return E_FAIL; + + hres = IInternetProtocol_Abort(This->protocol, E_ABORT, ERROR_SUCCESS); + if(FAILED(hres)) + return hres; + + This->state |= BINDING_ABORTED; + return S_OK; } static HRESULT WINAPI Binding_Suspend(IBinding *iface) @@ -1048,7 +1086,7 @@ static void report_data(Binding *This, DWORD bscf, ULONG progress, ULONG progres TRACE("(%p)->(%d %u %u)\n", This, bscf, progress, progress_max); - if(This->download_state == END_DOWNLOAD || (This->state & BINDING_STOPPED)) + if(This->download_state == END_DOWNLOAD || (This->state & (BINDING_STOPPED|BINDING_ABORTED))) return; if(This->stgmed_buf->file != INVALID_HANDLE_VALUE) @@ -1076,6 +1114,9 @@ static void report_data(Binding *This, DWORD bscf, ULONG progress, ULONG progres BINDSTATUS_DOWNLOADINGDATA, This->url); } + if(This->state & (BINDING_STOPPED|BINDING_ABORTED)) + return; + if(This->to_object) { if(!(This->state & BINDING_OBJAVAIL)) { IBinding_AddRef(BINDING(This)); @@ -1223,7 +1264,7 @@ static HRESULT WINAPI InternetBindInfo_GetBindString(IInternetBindInfo *iface, return hres; } case BINDSTRING_URL: { - DWORD size = (strlenW(This->url)+1) * sizeof(WCHAR); + DWORD size = (SysStringLen(This->url)+1) * sizeof(WCHAR); if(!ppwzStr || !pcElFetched) return E_INVALIDARG; @@ -1350,50 +1391,37 @@ static HRESULT get_callback(IBindCtx *pbc, IBindStatusCallback **callback) HRESULT hres; hres = IBindCtx_GetObjectParam(pbc, bscb_holderW, &unk); - if(SUCCEEDED(hres)) { - hres = IUnknown_QueryInterface(unk, &IID_IBindStatusCallback, (void**)callback); - IUnknown_Release(unk); - } + if(FAILED(hres)) + return create_default_callback(callback); - return SUCCEEDED(hres) ? S_OK : INET_E_DATA_NOT_AVAILABLE; + hres = IUnknown_QueryInterface(unk, &IID_IBindStatusCallback, (void**)callback); + IUnknown_Release(unk); + return hres; } -static BOOL is_urlmon_protocol(LPCWSTR url) +static BOOL is_urlmon_protocol(IUri *uri) { - static const WCHAR wszCdl[] = {'c','d','l'}; - static const WCHAR wszFile[] = {'f','i','l','e'}; - static const WCHAR wszFtp[] = {'f','t','p'}; - static const WCHAR wszGopher[] = {'g','o','p','h','e','r'}; - static const WCHAR wszHttp[] = {'h','t','t','p'}; - static const WCHAR wszHttps[] = {'h','t','t','p','s'}; - static const WCHAR wszMk[] = {'m','k'}; + DWORD scheme; + HRESULT hres; - static const struct { - LPCWSTR scheme; - int len; - } protocol_list[] = { - {wszCdl, sizeof(wszCdl) /sizeof(WCHAR)}, - {wszFile, sizeof(wszFile) /sizeof(WCHAR)}, - {wszFtp, sizeof(wszFtp) /sizeof(WCHAR)}, - {wszGopher, sizeof(wszGopher)/sizeof(WCHAR)}, - {wszHttp, sizeof(wszHttp) /sizeof(WCHAR)}, - {wszHttps, sizeof(wszHttps) /sizeof(WCHAR)}, - {wszMk, sizeof(wszMk) /sizeof(WCHAR)} - }; + hres = IUri_GetScheme(uri, &scheme); + if(FAILED(hres)) + return FALSE; - unsigned int i; - int len = lstrlenW(url); - - for(i=0; i < sizeof(protocol_list)/sizeof(protocol_list[0]); i++) { - if(len >= protocol_list[i].len - && !memcmp(url, protocol_list[i].scheme, protocol_list[i].len*sizeof(WCHAR))) - return TRUE; + switch(scheme) { + case URL_SCHEME_FILE: + case URL_SCHEME_FTP: + case URL_SCHEME_GOPHER: + case URL_SCHEME_HTTP: + case URL_SCHEME_HTTPS: + case URL_SCHEME_MK: + return TRUE; } return FALSE; } -static HRESULT Binding_Create(IMoniker *mon, Binding *binding_ctx, LPCWSTR url, IBindCtx *pbc, +static HRESULT Binding_Create(IMoniker *mon, Binding *binding_ctx, IUri *uri, IBindCtx *pbc, BOOL to_obj, REFIID riid, Binding **binding) { Binding *ret; @@ -1446,7 +1474,7 @@ static HRESULT Binding_Create(IMoniker *mon, Binding *binding_ctx, LPCWSTR url, ret->protocol = binding_ctx->protocol; IInternetProtocol_AddRef(ret->protocol); }else { - hres = create_binding_protocol(url, TRUE, &ret->protocol); + hres = create_binding_protocol(TRUE, &ret->protocol); if(FAILED(hres)) { WARN("Could not get protocol handler\n"); IBinding_Release(BINDING(ret)); @@ -1471,11 +1499,15 @@ static HRESULT Binding_Create(IMoniker *mon, Binding *binding_ctx, LPCWSTR url, if(!(ret->bindf & BINDF_ASYNCHRONOUS)) { ret->bindf |= BINDF_NEEDFILE; ret->use_cache_file = TRUE; - }else if(!is_urlmon_protocol(url)) { + }else if(!is_urlmon_protocol(uri)) { ret->bindf |= BINDF_NEEDFILE; } - ret->url = heap_strdupW(url); + hres = IUri_GetDisplayUri(uri, &ret->url); + if(FAILED(hres)) { + IBinding_Release(BINDING(ret)); + return hres; + } if(binding_ctx) { ret->stgmed_buf = binding_ctx->stgmed_buf; @@ -1502,14 +1534,14 @@ static HRESULT Binding_Create(IMoniker *mon, Binding *binding_ctx, LPCWSTR url, return S_OK; } -static HRESULT start_binding(IMoniker *mon, Binding *binding_ctx, LPCWSTR url, IBindCtx *pbc, +static HRESULT start_binding(IMoniker *mon, Binding *binding_ctx, IUri *uri, IBindCtx *pbc, BOOL to_obj, REFIID riid, Binding **ret) { Binding *binding = NULL; HRESULT hres; MSG msg; - hres = Binding_Create(mon, binding_ctx, url, pbc, to_obj, riid, &binding); + hres = Binding_Create(mon, binding_ctx, uri, pbc, to_obj, riid, &binding); if(FAILED(hres)) return hres; @@ -1525,9 +1557,10 @@ static HRESULT start_binding(IMoniker *mon, Binding *binding_ctx, LPCWSTR url, I set_binding_sink(binding->protocol, PROTSINK(binding), BINDINF(binding)); if(binding_ctx->redirect_url) IBindStatusCallback_OnProgress(binding->callback, 0, 0, BINDSTATUS_REDIRECTING, binding_ctx->redirect_url); - report_data(binding, 0, 0, 0); + report_data(binding, BSCF_FIRSTDATANOTIFICATION | (binding_ctx->download_state == END_DOWNLOAD ? BSCF_LASTDATANOTIFICATION : 0), + 0, 0); }else { - hres = IInternetProtocol_Start(binding->protocol, url, PROTSINK(binding), + hres = IInternetProtocolEx_StartEx(binding->protocol, uri, PROTSINK(binding), BINDINF(binding), PI_APARTMENTTHREADED|PI_MIMEVERIFICATION, 0); TRACE("start ret %08x\n", hres); @@ -1553,7 +1586,7 @@ static HRESULT start_binding(IMoniker *mon, Binding *binding_ctx, LPCWSTR url, I return S_OK; } -HRESULT bind_to_storage(LPCWSTR url, IBindCtx *pbc, REFIID riid, void **ppv) +HRESULT bind_to_storage(IUri *uri, IBindCtx *pbc, REFIID riid, void **ppv) { Binding *binding = NULL, *binding_ctx; HRESULT hres; @@ -1562,7 +1595,7 @@ HRESULT bind_to_storage(LPCWSTR url, IBindCtx *pbc, REFIID riid, void **ppv) binding_ctx = get_bctx_binding(pbc); - hres = start_binding(NULL, binding_ctx, url, pbc, FALSE, riid, &binding); + hres = start_binding(NULL, binding_ctx, uri, pbc, FALSE, riid, &binding); if(binding_ctx) IBinding_Release(BINDING(binding_ctx)); if(FAILED(hres)) @@ -1573,8 +1606,10 @@ HRESULT bind_to_storage(LPCWSTR url, IBindCtx *pbc, REFIID riid, void **ppv) IInternetProtocol_UnlockRequest(binding->protocol); hres = binding->stgmed_obj->vtbl->get_result(binding->stgmed_obj, binding->bindf, ppv); - }else { + }else if(binding->bindf & BINDF_ASYNCHRONOUS) { hres = MK_S_ASYNCHRONOUS; + }else { + hres = FAILED(binding->hres) ? binding->hres : S_OK; } IBinding_Release(BINDING(binding)); @@ -1582,14 +1617,14 @@ HRESULT bind_to_storage(LPCWSTR url, IBindCtx *pbc, REFIID riid, void **ppv) return hres; } -HRESULT bind_to_object(IMoniker *mon, LPCWSTR url, IBindCtx *pbc, REFIID riid, void **ppv) +HRESULT bind_to_object(IMoniker *mon, IUri *uri, IBindCtx *pbc, REFIID riid, void **ppv) { Binding *binding; HRESULT hres; *ppv = NULL; - hres = start_binding(mon, NULL, url, pbc, TRUE, riid, &binding); + hres = start_binding(mon, NULL, uri, pbc, TRUE, riid, &binding); if(FAILED(hres)) return hres; diff --git a/reactos/dll/win32/urlmon/bindprot.c b/reactos/dll/win32/urlmon/bindprot.c index 01443e37856..0549712a048 100644 --- a/reactos/dll/win32/urlmon/bindprot.c +++ b/reactos/dll/win32/urlmon/bindprot.c @@ -33,24 +33,26 @@ typedef struct _task_header_t { } task_header_t; struct BindProtocol { - const IInternetProtocolVtbl *lpIInternetProtocolVtbl; + const IInternetProtocolExVtbl *lpIInternetProtocolExVtbl; const IInternetBindInfoVtbl *lpInternetBindInfoVtbl; const IInternetPriorityVtbl *lpInternetPriorityVtbl; const IServiceProviderVtbl *lpServiceProviderVtbl; const IInternetProtocolSinkVtbl *lpIInternetProtocolSinkVtbl; const IWinInetHttpInfoVtbl *lpIWinInetHttpInfoVtbl; - const IInternetProtocolVtbl *lpIInternetProtocolHandlerVtbl; - LONG ref; IInternetProtocol *protocol; - IInternetProtocol *protocol_handler; IInternetBindInfo *bind_info; IInternetProtocolSink *protocol_sink; IServiceProvider *service_provider; IWinInetInfo *wininet_info; + struct { + IInternetProtocol IInternetProtocol_iface; + } default_protocol_handler; + IInternetProtocol *protocol_handler; + LONG priority; BOOL reported_result; @@ -68,7 +70,7 @@ struct BindProtocol { BYTE *buf; DWORD buf_size; LPWSTR mime; - LPWSTR url; + IUri *uri; ProtocolProxy *filter_proxy; }; @@ -76,6 +78,7 @@ struct BindProtocol { #define PRIORITY(x) ((IInternetPriority*) &(x)->lpInternetPriorityVtbl) #define HTTPINFO(x) ((IWinInetHttpInfo*) &(x)->lpIWinInetHttpInfoVtbl) #define SERVPROV(x) ((IServiceProvider*) &(x)->lpServiceProviderVtbl) +#define PROTOCOLEX(x) ((IInternetProtocolEx*) &(x)->lpIInternetProtocolExVtbl) #define PROTOCOLHANDLER(x) ((IInternetProtocol*) &(x)->lpIInternetProtocolHandlerVtbl) @@ -112,7 +115,7 @@ static LRESULT WINAPI notif_wnd_proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM This->continue_call--; } - IInternetProtocol_Release(PROTOCOL(This)); + IInternetProtocolEx_Release(PROTOCOLEX(This)); return 0; } case WM_MK_RELEASE: { @@ -211,7 +214,7 @@ static void push_task(BindProtocol *This, task_header_t *task, task_proc_t proc) LeaveCriticalSection(&This->section); if(do_post) { - IInternetProtocol_AddRef(PROTOCOL(This)); + IInternetProtocolEx_AddRef(PROTOCOLEX(This)); PostMessageW(This->notif_hwnd, WM_MK_CONTINUE, 0, (LPARAM)This); } } @@ -232,7 +235,7 @@ static HRESULT handle_mime_filter(BindProtocol *This, IInternetProtocol *mime_fi if(FAILED(hres)) return hres; - hres = create_protocol_proxy(PROTOCOLHANDLER(This), This->protocol_sink, &filter_proxy); + hres = create_protocol_proxy(&This->default_protocol_handler.IInternetProtocol_iface, This->protocol_sink, &filter_proxy); if(FAILED(hres)) { IInternetProtocolSink_Release(protocol_sink); return hres; @@ -288,22 +291,25 @@ static void mime_available(BindProtocol *This, LPCWSTR mime, BOOL verified) } } -#define PROTOCOL_THIS(iface) DEFINE_THIS(BindProtocol, IInternetProtocol, iface) +#define PROTOCOL_THIS(iface) DEFINE_THIS(BindProtocol, IInternetProtocolEx, iface) -static HRESULT WINAPI BindProtocol_QueryInterface(IInternetProtocol *iface, REFIID riid, void **ppv) +static HRESULT WINAPI BindProtocol_QueryInterface(IInternetProtocolEx *iface, REFIID riid, void **ppv) { BindProtocol *This = PROTOCOL_THIS(iface); *ppv = NULL; if(IsEqualGUID(&IID_IUnknown, riid)) { TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv); - *ppv = PROTOCOL(This); + *ppv = PROTOCOLEX(This); }else if(IsEqualGUID(&IID_IInternetProtocolRoot, riid)) { TRACE("(%p)->(IID_IInternetProtocolRoot %p)\n", This, ppv); - *ppv = PROTOCOL(This); + *ppv = PROTOCOLEX(This); }else if(IsEqualGUID(&IID_IInternetProtocol, riid)) { TRACE("(%p)->(IID_IInternetProtocol %p)\n", This, ppv); - *ppv = PROTOCOL(This); + *ppv = PROTOCOLEX(This); + }else if(IsEqualGUID(&IID_IInternetProtocolEx, riid)) { + TRACE("(%p)->(IID_IInternetProtocolEx %p)\n", This, ppv); + *ppv = PROTOCOLEX(This); }else if(IsEqualGUID(&IID_IInternetBindInfo, riid)) { TRACE("(%p)->(IID_IInternetBindInfo %p)\n", This, ppv); *ppv = BINDINFO(This); @@ -355,7 +361,7 @@ static HRESULT WINAPI BindProtocol_QueryInterface(IInternetProtocol *iface, REFI return S_OK; } -static ULONG WINAPI BindProtocol_AddRef(IInternetProtocol *iface) +static ULONG WINAPI BindProtocol_AddRef(IInternetProtocolEx *iface) { BindProtocol *This = PROTOCOL_THIS(iface); LONG ref = InterlockedIncrement(&This->ref); @@ -363,7 +369,7 @@ static ULONG WINAPI BindProtocol_AddRef(IInternetProtocol *iface) return ref; } -static ULONG WINAPI BindProtocol_Release(IInternetProtocol *iface) +static ULONG WINAPI BindProtocol_Release(IInternetProtocolEx *iface) { BindProtocol *This = PROTOCOL_THIS(iface); LONG ref = InterlockedDecrement(&This->ref); @@ -377,19 +383,20 @@ static ULONG WINAPI BindProtocol_Release(IInternetProtocol *iface) IInternetProtocol_Release(This->protocol); if(This->bind_info) IInternetBindInfo_Release(This->bind_info); - if(This->protocol_handler && This->protocol_handler != PROTOCOLHANDLER(This)) + if(This->protocol_handler && This->protocol_handler != &This->default_protocol_handler.IInternetProtocol_iface) IInternetProtocol_Release(This->protocol_handler); if(This->filter_proxy) IInternetProtocol_Release(PROTOCOL(This->filter_proxy)); + if(This->uri) + IUri_Release(This->uri); - set_binding_sink(PROTOCOL(This), NULL, NULL); + set_binding_sink(PROTOCOLEX(This), NULL, NULL); if(This->notif_hwnd) release_notif_hwnd(This->notif_hwnd); DeleteCriticalSection(&This->section); heap_free(This->mime); - heap_free(This->url); heap_free(This); URLMON_UnlockModule(); @@ -398,19 +405,29 @@ static ULONG WINAPI BindProtocol_Release(IInternetProtocol *iface) return ref; } -static HRESULT WINAPI BindProtocol_Start(IInternetProtocol *iface, LPCWSTR szUrl, +static HRESULT WINAPI BindProtocol_Start(IInternetProtocolEx *iface, LPCWSTR szUrl, IInternetProtocolSink *pOIProtSink, IInternetBindInfo *pOIBindInfo, DWORD grfPI, HANDLE_PTR dwReserved) { BindProtocol *This = PROTOCOL_THIS(iface); + IUri *uri; + HRESULT hres; TRACE("(%p)->(%s %p %p %08x %lx)\n", This, debugstr_w(szUrl), pOIProtSink, pOIBindInfo, grfPI, dwReserved); - return IInternetProtocol_Start(This->protocol_handler, szUrl, pOIProtSink, pOIBindInfo, grfPI, dwReserved); + hres = CreateUri(szUrl, Uri_CREATE_FILE_USE_DOS_PATH, 0, &uri); + if(FAILED(hres)) + return hres; + + hres = IInternetProtocolEx_StartEx(PROTOCOLEX(This), uri, pOIProtSink, pOIBindInfo, + grfPI, (HANDLE*)dwReserved); + + IUri_Release(uri); + return hres; } -static HRESULT WINAPI BindProtocol_Continue(IInternetProtocol *iface, PROTOCOLDATA *pProtocolData) +static HRESULT WINAPI BindProtocol_Continue(IInternetProtocolEx *iface, PROTOCOLDATA *pProtocolData) { BindProtocol *This = PROTOCOL_THIS(iface); @@ -419,15 +436,17 @@ static HRESULT WINAPI BindProtocol_Continue(IInternetProtocol *iface, PROTOCOLDA return IInternetProtocol_Continue(This->protocol_handler, pProtocolData); } -static HRESULT WINAPI BindProtocol_Abort(IInternetProtocol *iface, HRESULT hrReason, +static HRESULT WINAPI BindProtocol_Abort(IInternetProtocolEx *iface, HRESULT hrReason, DWORD dwOptions) { BindProtocol *This = PROTOCOL_THIS(iface); - FIXME("(%p)->(%08x %08x)\n", This, hrReason, dwOptions); - return E_NOTIMPL; + + TRACE("(%p)->(%08x %08x)\n", This, hrReason, dwOptions); + + return IInternetProtocol_Abort(This->protocol_handler, hrReason, dwOptions); } -static HRESULT WINAPI BindProtocol_Terminate(IInternetProtocol *iface, DWORD dwOptions) +static HRESULT WINAPI BindProtocol_Terminate(IInternetProtocolEx *iface, DWORD dwOptions) { BindProtocol *This = PROTOCOL_THIS(iface); @@ -436,21 +455,21 @@ static HRESULT WINAPI BindProtocol_Terminate(IInternetProtocol *iface, DWORD dwO return IInternetProtocol_Terminate(This->protocol_handler, dwOptions); } -static HRESULT WINAPI BindProtocol_Suspend(IInternetProtocol *iface) +static HRESULT WINAPI BindProtocol_Suspend(IInternetProtocolEx *iface) { BindProtocol *This = PROTOCOL_THIS(iface); FIXME("(%p)\n", This); return E_NOTIMPL; } -static HRESULT WINAPI BindProtocol_Resume(IInternetProtocol *iface) +static HRESULT WINAPI BindProtocol_Resume(IInternetProtocolEx *iface) { BindProtocol *This = PROTOCOL_THIS(iface); FIXME("(%p)\n", This); return E_NOTIMPL; } -static HRESULT WINAPI BindProtocol_Read(IInternetProtocol *iface, void *pv, +static HRESULT WINAPI BindProtocol_Read(IInternetProtocolEx *iface, void *pv, ULONG cb, ULONG *pcbRead) { BindProtocol *This = PROTOCOL_THIS(iface); @@ -462,7 +481,7 @@ static HRESULT WINAPI BindProtocol_Read(IInternetProtocol *iface, void *pv, return IInternetProtocol_Read(This->protocol_handler, pv, cb, pcbRead); } -static HRESULT WINAPI BindProtocol_Seek(IInternetProtocol *iface, LARGE_INTEGER dlibMove, +static HRESULT WINAPI BindProtocol_Seek(IInternetProtocolEx *iface, LARGE_INTEGER dlibMove, DWORD dwOrigin, ULARGE_INTEGER *plibNewPosition) { BindProtocol *This = PROTOCOL_THIS(iface); @@ -470,7 +489,7 @@ static HRESULT WINAPI BindProtocol_Seek(IInternetProtocol *iface, LARGE_INTEGER return E_NOTIMPL; } -static HRESULT WINAPI BindProtocol_LockRequest(IInternetProtocol *iface, DWORD dwOptions) +static HRESULT WINAPI BindProtocol_LockRequest(IInternetProtocolEx *iface, DWORD dwOptions) { BindProtocol *This = PROTOCOL_THIS(iface); @@ -479,7 +498,7 @@ static HRESULT WINAPI BindProtocol_LockRequest(IInternetProtocol *iface, DWORD d return IInternetProtocol_LockRequest(This->protocol_handler, dwOptions); } -static HRESULT WINAPI BindProtocol_UnlockRequest(IInternetProtocol *iface) +static HRESULT WINAPI BindProtocol_UnlockRequest(IInternetProtocolEx *iface) { BindProtocol *This = PROTOCOL_THIS(iface); @@ -488,82 +507,13 @@ static HRESULT WINAPI BindProtocol_UnlockRequest(IInternetProtocol *iface) return IInternetProtocol_UnlockRequest(This->protocol_handler); } -void set_binding_sink(IInternetProtocol *bind_protocol, IInternetProtocolSink *sink, IInternetBindInfo *bind_info) -{ - BindProtocol *This = PROTOCOL_THIS(bind_protocol); - IInternetProtocolSink *prev_sink; - IServiceProvider *service_provider = NULL; - - if(sink) - IInternetProtocolSink_AddRef(sink); - prev_sink = InterlockedExchangePointer((void**)&This->protocol_sink, sink); - if(prev_sink) - IInternetProtocolSink_Release(prev_sink); - - if(sink) - IInternetProtocolSink_QueryInterface(sink, &IID_IServiceProvider, (void**)&service_provider); - service_provider = InterlockedExchangePointer((void**)&This->service_provider, service_provider); - if(service_provider) - IServiceProvider_Release(service_provider); - - if(bind_info) - IInternetBindInfo_AddRef(bind_info); - bind_info = InterlockedExchangePointer((void**)&This->bind_info, bind_info); - if(bind_info) - IInternetBindInfo_Release(bind_info); -} - -IWinInetInfo *get_wininet_info(IInternetProtocol *bind_protocol) -{ - BindProtocol *This = PROTOCOL_THIS(bind_protocol); - - return This->wininet_info; -} - -#undef PROTOCOL_THIS - -static const IInternetProtocolVtbl BindProtocolVtbl = { - BindProtocol_QueryInterface, - BindProtocol_AddRef, - BindProtocol_Release, - BindProtocol_Start, - BindProtocol_Continue, - BindProtocol_Abort, - BindProtocol_Terminate, - BindProtocol_Suspend, - BindProtocol_Resume, - BindProtocol_Read, - BindProtocol_Seek, - BindProtocol_LockRequest, - BindProtocol_UnlockRequest -}; - -#define PROTOCOLHANDLER_THIS(iface) DEFINE_THIS(BindProtocol, IInternetProtocolHandler, iface) - -static HRESULT WINAPI ProtocolHandler_QueryInterface(IInternetProtocol *iface, REFIID riid, void **ppv) -{ - ERR("should not be called\n"); - return E_NOINTERFACE; -} - -static ULONG WINAPI ProtocolHandler_AddRef(IInternetProtocol *iface) -{ - BindProtocol *This = PROTOCOLHANDLER_THIS(iface); - return IInternetProtocol_AddRef(PROTOCOL(This)); -} - -static ULONG WINAPI ProtocolHandler_Release(IInternetProtocol *iface) -{ - BindProtocol *This = PROTOCOLHANDLER_THIS(iface); - return IInternetProtocol_Release(PROTOCOL(This)); -} - -static HRESULT WINAPI ProtocolHandler_Start(IInternetProtocol *iface, LPCWSTR szUrl, +static HRESULT WINAPI BindProtocol_StartEx(IInternetProtocolEx *iface, IUri *pUri, IInternetProtocolSink *pOIProtSink, IInternetBindInfo *pOIBindInfo, - DWORD grfPI, HANDLE_PTR dwReserved) + DWORD grfPI, HANDLE *dwReserved) { - BindProtocol *This = PROTOCOLHANDLER_THIS(iface); + BindProtocol *This = PROTOCOL_THIS(iface); IInternetProtocol *protocol = NULL; + IInternetProtocolEx *protocolex; IInternetPriority *priority; IServiceProvider *service_provider; BOOL urlmon_protocol = FALSE; @@ -571,21 +521,22 @@ static HRESULT WINAPI ProtocolHandler_Start(IInternetProtocol *iface, LPCWSTR sz LPOLESTR clsid_str; HRESULT hres; - TRACE("(%p)->(%s %p %p %08x %lx)\n", This, debugstr_w(szUrl), pOIProtSink, - pOIBindInfo, grfPI, dwReserved); + TRACE("(%p)->(%p %p %p %08x %p)\n", This, pUri, pOIProtSink, pOIBindInfo, grfPI, dwReserved); - if(!szUrl || !pOIProtSink || !pOIBindInfo) + if(!pUri || !pOIProtSink || !pOIBindInfo) return E_INVALIDARG; This->pi = grfPI; - This->url = heap_strdupW(szUrl); + + IUri_AddRef(pUri); + This->uri = pUri; hres = IInternetProtocolSink_QueryInterface(pOIProtSink, &IID_IServiceProvider, (void**)&service_provider); if(SUCCEEDED(hres)) { /* FIXME: What's protocol CLSID here? */ IServiceProvider_QueryService(service_provider, &IID_IInternetProtocol, - &IID_IInternetProtocol, (void**)&protocol); + &IID_IInternetProtocol, (void**)&protocol); IServiceProvider_Release(service_provider); } @@ -593,7 +544,7 @@ static HRESULT WINAPI ProtocolHandler_Start(IInternetProtocol *iface, LPCWSTR sz IClassFactory *cf; IUnknown *unk; - hres = get_protocol_handler(szUrl, &clsid, &urlmon_protocol, &cf); + hres = get_protocol_handler(pUri, &clsid, &urlmon_protocol, &cf); if(FAILED(hres)) return hres; @@ -625,7 +576,7 @@ static HRESULT WINAPI ProtocolHandler_Start(IInternetProtocol *iface, LPCWSTR sz if(urlmon_protocol) IInternetProtocol_QueryInterface(protocol, &IID_IWinInetInfo, (void**)&This->wininet_info); - set_binding_sink(PROTOCOL(This), pOIProtSink, pOIBindInfo); + set_binding_sink(PROTOCOLEX(This), pOIProtSink, pOIBindInfo); hres = IInternetProtocol_QueryInterface(protocol, &IID_IInternetPriority, (void**)&priority); if(SUCCEEDED(hres)) { @@ -633,12 +584,109 @@ static HRESULT WINAPI ProtocolHandler_Start(IInternetProtocol *iface, LPCWSTR sz IInternetPriority_Release(priority); } - return IInternetProtocol_Start(protocol, szUrl, PROTSINK(This), BINDINFO(This), 0, 0); + hres = IInternetProtocol_QueryInterface(protocol, &IID_IInternetProtocolEx, (void**)&protocolex); + if(SUCCEEDED(hres)) { + hres = IInternetProtocolEx_StartEx(protocolex, pUri, PROTSINK(This), BINDINFO(This), 0, NULL); + IInternetProtocolEx_Release(protocolex); + }else { + BSTR display_uri; + + hres = IUri_GetDisplayUri(pUri, &display_uri); + if(FAILED(hres)) + return hres; + + hres = IInternetProtocol_Start(protocol, display_uri, PROTSINK(This), BINDINFO(This), 0, 0); + SysFreeString(display_uri); + } + + return hres; +} + +void set_binding_sink(IInternetProtocolEx *bind_protocol, IInternetProtocolSink *sink, IInternetBindInfo *bind_info) +{ + BindProtocol *This = PROTOCOL_THIS(bind_protocol); + IInternetProtocolSink *prev_sink; + IServiceProvider *service_provider = NULL; + + if(sink) + IInternetProtocolSink_AddRef(sink); + prev_sink = InterlockedExchangePointer((void**)&This->protocol_sink, sink); + if(prev_sink) + IInternetProtocolSink_Release(prev_sink); + + if(sink) + IInternetProtocolSink_QueryInterface(sink, &IID_IServiceProvider, (void**)&service_provider); + service_provider = InterlockedExchangePointer((void**)&This->service_provider, service_provider); + if(service_provider) + IServiceProvider_Release(service_provider); + + if(bind_info) + IInternetBindInfo_AddRef(bind_info); + bind_info = InterlockedExchangePointer((void**)&This->bind_info, bind_info); + if(bind_info) + IInternetBindInfo_Release(bind_info); +} + +IWinInetInfo *get_wininet_info(IInternetProtocolEx *bind_protocol) +{ + BindProtocol *This = PROTOCOL_THIS(bind_protocol); + + return This->wininet_info; +} + +#undef PROTOCOL_THIS + +static const IInternetProtocolExVtbl BindProtocolVtbl = { + BindProtocol_QueryInterface, + BindProtocol_AddRef, + BindProtocol_Release, + BindProtocol_Start, + BindProtocol_Continue, + BindProtocol_Abort, + BindProtocol_Terminate, + BindProtocol_Suspend, + BindProtocol_Resume, + BindProtocol_Read, + BindProtocol_Seek, + BindProtocol_LockRequest, + BindProtocol_UnlockRequest, + BindProtocol_StartEx +}; + +static inline BindProtocol *impl_from_IInternetProtocol(IInternetProtocol *iface) +{ + return CONTAINING_RECORD(iface, BindProtocol, default_protocol_handler.IInternetProtocol_iface); +} + +static HRESULT WINAPI ProtocolHandler_QueryInterface(IInternetProtocol *iface, REFIID riid, void **ppv) +{ + ERR("should not be called\n"); + return E_NOINTERFACE; +} + +static ULONG WINAPI ProtocolHandler_AddRef(IInternetProtocol *iface) +{ + BindProtocol *This = impl_from_IInternetProtocol(iface); + return IInternetProtocolEx_AddRef(PROTOCOLEX(This)); +} + +static ULONG WINAPI ProtocolHandler_Release(IInternetProtocol *iface) +{ + BindProtocol *This = impl_from_IInternetProtocol(iface); + return IInternetProtocolEx_Release(PROTOCOLEX(This)); +} + +static HRESULT WINAPI ProtocolHandler_Start(IInternetProtocol *iface, LPCWSTR szUrl, + IInternetProtocolSink *pOIProtSink, IInternetBindInfo *pOIBindInfo, + DWORD grfPI, HANDLE_PTR dwReserved) +{ + ERR("Should not be called\n"); + return E_NOTIMPL; } static HRESULT WINAPI ProtocolHandler_Continue(IInternetProtocol *iface, PROTOCOLDATA *pProtocolData) { - BindProtocol *This = PROTOCOLHANDLER_THIS(iface); + BindProtocol *This = impl_from_IInternetProtocol(iface); HRESULT hres; TRACE("(%p)->(%p)\n", This, pProtocolData); @@ -652,14 +700,19 @@ static HRESULT WINAPI ProtocolHandler_Continue(IInternetProtocol *iface, PROTOCO static HRESULT WINAPI ProtocolHandler_Abort(IInternetProtocol *iface, HRESULT hrReason, DWORD dwOptions) { - BindProtocol *This = PROTOCOLHANDLER_THIS(iface); - FIXME("(%p)->(%08x %08x)\n", This, hrReason, dwOptions); - return E_NOTIMPL; + BindProtocol *This = impl_from_IInternetProtocol(iface); + + TRACE("(%p)->(%08x %08x)\n", This, hrReason, dwOptions); + + if(This->protocol && !This->reported_result) + return IInternetProtocol_Abort(This->protocol, hrReason, dwOptions); + + return S_OK; } static HRESULT WINAPI ProtocolHandler_Terminate(IInternetProtocol *iface, DWORD dwOptions) { - BindProtocol *This = PROTOCOLHANDLER_THIS(iface); + BindProtocol *This = impl_from_IInternetProtocol(iface); TRACE("(%p)->(%08x)\n", This, dwOptions); @@ -673,7 +726,7 @@ static HRESULT WINAPI ProtocolHandler_Terminate(IInternetProtocol *iface, DWORD This->filter_proxy = NULL; } - set_binding_sink(PROTOCOL(This), NULL, NULL); + set_binding_sink(PROTOCOLEX(This), NULL, NULL); if(This->bind_info) { IInternetBindInfo_Release(This->bind_info); @@ -685,14 +738,14 @@ static HRESULT WINAPI ProtocolHandler_Terminate(IInternetProtocol *iface, DWORD static HRESULT WINAPI ProtocolHandler_Suspend(IInternetProtocol *iface) { - BindProtocol *This = PROTOCOLHANDLER_THIS(iface); + BindProtocol *This = impl_from_IInternetProtocol(iface); FIXME("(%p)\n", This); return E_NOTIMPL; } static HRESULT WINAPI ProtocolHandler_Resume(IInternetProtocol *iface) { - BindProtocol *This = PROTOCOLHANDLER_THIS(iface); + BindProtocol *This = impl_from_IInternetProtocol(iface); FIXME("(%p)\n", This); return E_NOTIMPL; } @@ -700,7 +753,7 @@ static HRESULT WINAPI ProtocolHandler_Resume(IInternetProtocol *iface) static HRESULT WINAPI ProtocolHandler_Read(IInternetProtocol *iface, void *pv, ULONG cb, ULONG *pcbRead) { - BindProtocol *This = PROTOCOLHANDLER_THIS(iface); + BindProtocol *This = impl_from_IInternetProtocol(iface); ULONG read = 0; HRESULT hres = S_OK; @@ -734,14 +787,14 @@ static HRESULT WINAPI ProtocolHandler_Read(IInternetProtocol *iface, void *pv, static HRESULT WINAPI ProtocolHandler_Seek(IInternetProtocol *iface, LARGE_INTEGER dlibMove, DWORD dwOrigin, ULARGE_INTEGER *plibNewPosition) { - BindProtocol *This = PROTOCOLHANDLER_THIS(iface); + BindProtocol *This = impl_from_IInternetProtocol(iface); FIXME("(%p)->(%d %d %p)\n", This, dlibMove.u.LowPart, dwOrigin, plibNewPosition); return E_NOTIMPL; } static HRESULT WINAPI ProtocolHandler_LockRequest(IInternetProtocol *iface, DWORD dwOptions) { - BindProtocol *This = PROTOCOLHANDLER_THIS(iface); + BindProtocol *This = impl_from_IInternetProtocol(iface); TRACE("(%p)->(%08x)\n", This, dwOptions); @@ -750,15 +803,13 @@ static HRESULT WINAPI ProtocolHandler_LockRequest(IInternetProtocol *iface, DWOR static HRESULT WINAPI ProtocolHandler_UnlockRequest(IInternetProtocol *iface) { - BindProtocol *This = PROTOCOLHANDLER_THIS(iface); + BindProtocol *This = impl_from_IInternetProtocol(iface); TRACE("(%p)\n", This); return IInternetProtocol_UnlockRequest(This->protocol); } -#undef PROTOCOL_THIS - static const IInternetProtocolVtbl InternetProtocolHandlerVtbl = { ProtocolHandler_QueryInterface, ProtocolHandler_AddRef, @@ -781,19 +832,19 @@ static HRESULT WINAPI BindInfo_QueryInterface(IInternetBindInfo *iface, REFIID riid, void **ppv) { BindProtocol *This = BINDINFO_THIS(iface); - return IInternetProtocol_QueryInterface(PROTOCOL(This), riid, ppv); + return IInternetProtocolEx_QueryInterface(PROTOCOLEX(This), riid, ppv); } static ULONG WINAPI BindInfo_AddRef(IInternetBindInfo *iface) { BindProtocol *This = BINDINFO_THIS(iface); - return IBinding_AddRef(PROTOCOL(This)); + return IInternetProtocolEx_AddRef(PROTOCOLEX(This)); } static ULONG WINAPI BindInfo_Release(IInternetBindInfo *iface) { BindProtocol *This = BINDINFO_THIS(iface); - return IBinding_Release(PROTOCOL(This)); + return IInternetProtocolEx_Release(PROTOCOLEX(This)); } static HRESULT WINAPI BindInfo_GetBindInfo(IInternetBindInfo *iface, @@ -840,19 +891,19 @@ static HRESULT WINAPI InternetPriority_QueryInterface(IInternetPriority *iface, REFIID riid, void **ppv) { BindProtocol *This = PRIORITY_THIS(iface); - return IInternetProtocol_QueryInterface(PROTOCOL(This), riid, ppv); + return IInternetProtocolEx_QueryInterface(PROTOCOLEX(This), riid, ppv); } static ULONG WINAPI InternetPriority_AddRef(IInternetPriority *iface) { BindProtocol *This = PRIORITY_THIS(iface); - return IInternetProtocol_AddRef(PROTOCOL(This)); + return IInternetProtocolEx_AddRef(PROTOCOLEX(This)); } static ULONG WINAPI InternetPriority_Release(IInternetPriority *iface) { BindProtocol *This = PRIORITY_THIS(iface); - return IInternetProtocol_Release(PROTOCOL(This)); + return IInternetProtocolEx_Release(PROTOCOLEX(This)); } static HRESULT WINAPI InternetPriority_SetPriority(IInternetPriority *iface, LONG nPriority) @@ -892,19 +943,19 @@ static HRESULT WINAPI BPInternetProtocolSink_QueryInterface(IInternetProtocolSin REFIID riid, void **ppv) { BindProtocol *This = PROTSINK_THIS(iface); - return IInternetProtocol_QueryInterface(PROTOCOL(This), riid, ppv); + return IInternetProtocolEx_QueryInterface(PROTOCOLEX(This), riid, ppv); } static ULONG WINAPI BPInternetProtocolSink_AddRef(IInternetProtocolSink *iface) { BindProtocol *This = PROTSINK_THIS(iface); - return IInternetProtocol_AddRef(PROTOCOL(This)); + return IInternetProtocolEx_AddRef(PROTOCOLEX(This)); } static ULONG WINAPI BPInternetProtocolSink_Release(IInternetProtocolSink *iface) { BindProtocol *This = PROTSINK_THIS(iface); - return IInternetProtocol_Release(PROTOCOL(This)); + return IInternetProtocolEx_Release(PROTOCOLEX(This)); } typedef struct { @@ -1069,8 +1120,15 @@ static HRESULT report_data(BindProtocol *This, DWORD bscf, ULONG progress, ULONG bscf |= BSCF_LASTDATANOTIFICATION|BSCF_DATAFULLYAVAILABLE; if(!This->reported_mime) { - hres = FindMimeFromData(NULL, This->url, This->buf, min(This->buf_size, MIME_TEST_SIZE), + BSTR raw_uri; + + hres = IUri_GetRawUri(This->uri, &raw_uri); + if(FAILED(hres)) + return hres; + + hres = FindMimeFromData(NULL, raw_uri, This->buf, min(This->buf_size, MIME_TEST_SIZE), This->mime, 0, &mime, 0); + SysFreeString(raw_uri); if(FAILED(hres)) return hres; @@ -1194,19 +1252,19 @@ static const IInternetProtocolSinkVtbl InternetProtocolSinkVtbl = { static HRESULT WINAPI WinInetHttpInfo_QueryInterface(IWinInetHttpInfo *iface, REFIID riid, void **ppv) { BindProtocol *This = INETINFO_THIS(iface); - return IInternetProtocol_QueryInterface(PROTOCOL(This), riid, ppv); + return IInternetProtocolEx_QueryInterface(PROTOCOLEX(This), riid, ppv); } static ULONG WINAPI WinInetHttpInfo_AddRef(IWinInetHttpInfo *iface) { BindProtocol *This = INETINFO_THIS(iface); - return IInternetProtocol_AddRef(PROTOCOL(This)); + return IInternetProtocolEx_AddRef(PROTOCOLEX(This)); } static ULONG WINAPI WinInetHttpInfo_Release(IWinInetHttpInfo *iface) { BindProtocol *This = INETINFO_THIS(iface); - return IInternetProtocol_Release(PROTOCOL(This)); + return IInternetProtocolEx_Release(PROTOCOLEX(This)); } static HRESULT WINAPI WinInetHttpInfo_QueryOption(IWinInetHttpInfo *iface, DWORD dwOption, @@ -1241,19 +1299,19 @@ static HRESULT WINAPI BPServiceProvider_QueryInterface(IServiceProvider *iface, REFIID riid, void **ppv) { BindProtocol *This = SERVPROV_THIS(iface); - return IInternetProtocol_QueryInterface(PROTOCOL(This), riid, ppv); + return IInternetProtocolEx_QueryInterface(PROTOCOLEX(This), riid, ppv); } static ULONG WINAPI BPServiceProvider_AddRef(IServiceProvider *iface) { BindProtocol *This = SERVPROV_THIS(iface); - return IInternetProtocol_AddRef(PROTOCOL(This)); + return IInternetProtocolEx_AddRef(PROTOCOLEX(This)); } static ULONG WINAPI BPServiceProvider_Release(IServiceProvider *iface) { BindProtocol *This = SERVPROV_THIS(iface); - return IInternetProtocol_Release(PROTOCOL(This)); + return IInternetProtocolEx_Release(PROTOCOLEX(This)); } static HRESULT WINAPI BPServiceProvider_QueryService(IServiceProvider *iface, @@ -1278,27 +1336,28 @@ static const IServiceProviderVtbl ServiceProviderVtbl = { BPServiceProvider_QueryService }; -HRESULT create_binding_protocol(LPCWSTR url, BOOL from_urlmon, IInternetProtocol **protocol) +HRESULT create_binding_protocol(BOOL from_urlmon, IInternetProtocolEx **protocol) { BindProtocol *ret = heap_alloc_zero(sizeof(BindProtocol)); - ret->lpIInternetProtocolVtbl = &BindProtocolVtbl; + ret->lpIInternetProtocolExVtbl = &BindProtocolVtbl; ret->lpInternetBindInfoVtbl = &InternetBindInfoVtbl; ret->lpInternetPriorityVtbl = &InternetPriorityVtbl; ret->lpServiceProviderVtbl = &ServiceProviderVtbl; ret->lpIInternetProtocolSinkVtbl = &InternetProtocolSinkVtbl; - ret->lpIInternetProtocolHandlerVtbl = &InternetProtocolHandlerVtbl; ret->lpIWinInetHttpInfoVtbl = &WinInetHttpInfoVtbl; + ret->default_protocol_handler.IInternetProtocol_iface.lpVtbl = &InternetProtocolHandlerVtbl; + ret->ref = 1; ret->from_urlmon = from_urlmon; ret->apartment_thread = GetCurrentThreadId(); ret->notif_hwnd = get_notif_hwnd(); - ret->protocol_handler = PROTOCOLHANDLER(ret); + ret->protocol_handler = &ret->default_protocol_handler.IInternetProtocol_iface; InitializeCriticalSection(&ret->section); URLMON_LockModule(); - *protocol = PROTOCOL(ret); + *protocol = PROTOCOLEX(ret); return S_OK; } diff --git a/reactos/dll/win32/urlmon/download.c b/reactos/dll/win32/urlmon/download.c index fee96062ad6..9759e71d18e 100644 --- a/reactos/dll/win32/urlmon/download.c +++ b/reactos/dll/win32/urlmon/download.c @@ -22,8 +22,8 @@ WINE_DEFAULT_DEBUG_CHANNEL(urlmon); typedef struct { - const IBindStatusCallbackVtbl *lpBindStatusCallbackVtbl; - const IServiceProviderVtbl *lpServiceProviderVtbl; + IBindStatusCallback IBindStatusCallback_iface; + IServiceProvider IServiceProvider_iface; LONG ref; @@ -32,27 +32,32 @@ typedef struct { LPWSTR cache_file; } DownloadBSC; -#define STATUSCLB(x) ((IBindStatusCallback*) &(x)->lpBindStatusCallbackVtbl) -#define SERVPROV(x) ((IServiceProvider*) &(x)->lpServiceProviderVtbl) +static inline DownloadBSC *impl_from_IBindStatusCallback(IBindStatusCallback *iface) +{ + return CONTAINING_RECORD(iface, DownloadBSC, IBindStatusCallback_iface); +} -#define STATUSCLB_THIS(iface) DEFINE_THIS(DownloadBSC, BindStatusCallback, iface) +static inline DownloadBSC *impl_from_IServiceProvider(IServiceProvider *iface) +{ + return CONTAINING_RECORD(iface, DownloadBSC, IServiceProvider_iface); +} static HRESULT WINAPI DownloadBSC_QueryInterface(IBindStatusCallback *iface, REFIID riid, void **ppv) { - DownloadBSC *This = STATUSCLB_THIS(iface); + DownloadBSC *This = impl_from_IBindStatusCallback(iface); *ppv = NULL; if(IsEqualGUID(&IID_IUnknown, riid)) { TRACE("(%p)->(IID_IUnknown, %p)\n", This, ppv); - *ppv = STATUSCLB(This); + *ppv = &This->IBindStatusCallback_iface; }else if(IsEqualGUID(&IID_IBindStatusCallback, riid)) { TRACE("(%p)->(IID_IBindStatusCallback, %p)\n", This, ppv); - *ppv = STATUSCLB(This); + *ppv = &This->IBindStatusCallback_iface; }else if(IsEqualGUID(&IID_IServiceProvider, riid)) { TRACE("(%p)->(IID_IServiceProvider, %p)\n", This, ppv); - *ppv = SERVPROV(This); + *ppv = &This->IServiceProvider_iface; } if(*ppv) { @@ -66,7 +71,7 @@ static HRESULT WINAPI DownloadBSC_QueryInterface(IBindStatusCallback *iface, static ULONG WINAPI DownloadBSC_AddRef(IBindStatusCallback *iface) { - DownloadBSC *This = STATUSCLB_THIS(iface); + DownloadBSC *This = impl_from_IBindStatusCallback(iface); LONG ref = InterlockedIncrement(&This->ref); TRACE("(%p) ref = %d\n", This, ref); @@ -76,7 +81,7 @@ static ULONG WINAPI DownloadBSC_AddRef(IBindStatusCallback *iface) static ULONG WINAPI DownloadBSC_Release(IBindStatusCallback *iface) { - DownloadBSC *This = STATUSCLB_THIS(iface); + DownloadBSC *This = impl_from_IBindStatusCallback(iface); LONG ref = InterlockedDecrement(&This->ref); TRACE("(%p) ref = %d\n", This, ref); @@ -95,7 +100,7 @@ static ULONG WINAPI DownloadBSC_Release(IBindStatusCallback *iface) static HRESULT WINAPI DownloadBSC_OnStartBinding(IBindStatusCallback *iface, DWORD dwReserved, IBinding *pbind) { - DownloadBSC *This = STATUSCLB_THIS(iface); + DownloadBSC *This = impl_from_IBindStatusCallback(iface); TRACE("(%p)->(%d %p)\n", This, dwReserved, pbind); @@ -107,14 +112,14 @@ static HRESULT WINAPI DownloadBSC_OnStartBinding(IBindStatusCallback *iface, static HRESULT WINAPI DownloadBSC_GetPriority(IBindStatusCallback *iface, LONG *pnPriority) { - DownloadBSC *This = STATUSCLB_THIS(iface); + DownloadBSC *This = impl_from_IBindStatusCallback(iface); FIXME("(%p)->(%p)\n", This, pnPriority); return E_NOTIMPL; } static HRESULT WINAPI DownloadBSC_OnLowResource(IBindStatusCallback *iface, DWORD reserved) { - DownloadBSC *This = STATUSCLB_THIS(iface); + DownloadBSC *This = impl_from_IBindStatusCallback(iface); FIXME("(%p)->(%d)\n", This, reserved); return E_NOTIMPL; } @@ -133,7 +138,7 @@ static HRESULT on_progress(DownloadBSC *This, ULONG progress, ULONG progress_max static HRESULT WINAPI DownloadBSC_OnProgress(IBindStatusCallback *iface, ULONG ulProgress, ULONG ulProgressMax, ULONG ulStatusCode, LPCWSTR szStatusText) { - DownloadBSC *This = STATUSCLB_THIS(iface); + DownloadBSC *This = impl_from_IBindStatusCallback(iface); HRESULT hres = S_OK; TRACE("%p)->(%u %u %u %s)\n", This, ulProgress, ulProgressMax, ulStatusCode, @@ -167,18 +172,20 @@ static HRESULT WINAPI DownloadBSC_OnProgress(IBindStatusCallback *iface, ULONG u static HRESULT WINAPI DownloadBSC_OnStopBinding(IBindStatusCallback *iface, HRESULT hresult, LPCWSTR szError) { - DownloadBSC *This = STATUSCLB_THIS(iface); + DownloadBSC *This = impl_from_IBindStatusCallback(iface); TRACE("(%p)->(%08x %s)\n", This, hresult, debugstr_w(szError)); - if(This->cache_file) { - BOOL b; + if(This->file_name) { + if(This->cache_file) { + BOOL b; - b = CopyFileW(This->cache_file, This->file_name, FALSE); - if(!b) - FIXME("CopyFile failed: %u\n", GetLastError()); - }else { - FIXME("No cache file\n"); + b = CopyFileW(This->cache_file, This->file_name, FALSE); + if(!b) + FIXME("CopyFile failed: %u\n", GetLastError()); + }else { + FIXME("No cache file\n"); + } } if(This->callback) @@ -190,7 +197,7 @@ static HRESULT WINAPI DownloadBSC_OnStopBinding(IBindStatusCallback *iface, static HRESULT WINAPI DownloadBSC_GetBindInfo(IBindStatusCallback *iface, DWORD *grfBINDF, BINDINFO *pbindinfo) { - DownloadBSC *This = STATUSCLB_THIS(iface); + DownloadBSC *This = impl_from_IBindStatusCallback(iface); DWORD bindf = 0; TRACE("(%p)->(%p %p)\n", This, grfBINDF, pbindinfo); @@ -214,7 +221,7 @@ static HRESULT WINAPI DownloadBSC_GetBindInfo(IBindStatusCallback *iface, static HRESULT WINAPI DownloadBSC_OnDataAvailable(IBindStatusCallback *iface, DWORD grfBSCF, DWORD dwSize, FORMATETC *pformatetc, STGMEDIUM *pstgmed) { - DownloadBSC *This = STATUSCLB_THIS(iface); + DownloadBSC *This = impl_from_IBindStatusCallback(iface); TRACE("(%p)->(%08x %d %p %p)\n", This, grfBSCF, dwSize, pformatetc, pstgmed); @@ -224,13 +231,11 @@ static HRESULT WINAPI DownloadBSC_OnDataAvailable(IBindStatusCallback *iface, static HRESULT WINAPI DownloadBSC_OnObjectAvailable(IBindStatusCallback *iface, REFIID riid, IUnknown *punk) { - DownloadBSC *This = STATUSCLB_THIS(iface); + DownloadBSC *This = impl_from_IBindStatusCallback(iface); FIXME("(%p)->(%s %p)\n", This, debugstr_guid(riid), punk); return E_NOTIMPL; } -#undef STATUSCLB_THIS - static const IBindStatusCallbackVtbl BindStatusCallbackVtbl = { DownloadBSC_QueryInterface, DownloadBSC_AddRef, @@ -245,31 +250,29 @@ static const IBindStatusCallbackVtbl BindStatusCallbackVtbl = { DownloadBSC_OnObjectAvailable }; -#define SERVPROV_THIS(iface) DEFINE_THIS(DownloadBSC, ServiceProvider, iface) - static HRESULT WINAPI DwlServiceProvider_QueryInterface(IServiceProvider *iface, REFIID riid, void **ppv) { - DownloadBSC *This = SERVPROV_THIS(iface); - return IBindStatusCallback_QueryInterface(STATUSCLB(This), riid, ppv); + DownloadBSC *This = impl_from_IServiceProvider(iface); + return IBindStatusCallback_QueryInterface(&This->IBindStatusCallback_iface, riid, ppv); } static ULONG WINAPI DwlServiceProvider_AddRef(IServiceProvider *iface) { - DownloadBSC *This = SERVPROV_THIS(iface); - return IBindStatusCallback_AddRef(STATUSCLB(This)); + DownloadBSC *This = impl_from_IServiceProvider(iface); + return IBindStatusCallback_AddRef(&This->IBindStatusCallback_iface); } static ULONG WINAPI DwlServiceProvider_Release(IServiceProvider *iface) { - DownloadBSC *This = SERVPROV_THIS(iface); - return IBindStatusCallback_Release(STATUSCLB(This)); + DownloadBSC *This = impl_from_IServiceProvider(iface); + return IBindStatusCallback_Release(&This->IBindStatusCallback_iface); } static HRESULT WINAPI DwlServiceProvider_QueryService(IServiceProvider *iface, REFGUID guidService, REFIID riid, void **ppv) { - DownloadBSC *This = SERVPROV_THIS(iface); + DownloadBSC *This = impl_from_IServiceProvider(iface); IServiceProvider *serv_prov; HRESULT hres; @@ -292,8 +295,6 @@ static HRESULT WINAPI DwlServiceProvider_QueryService(IServiceProvider *iface, return E_NOINTERFACE; } -#undef SERVPROV_THIS - static const IServiceProviderVtbl ServiceProviderVtbl = { DwlServiceProvider_QueryInterface, DwlServiceProvider_AddRef, @@ -301,12 +302,12 @@ static const IServiceProviderVtbl ServiceProviderVtbl = { DwlServiceProvider_QueryService }; -static IBindStatusCallback *DownloadBSC_Create(IBindStatusCallback *callback, LPCWSTR file_name) +static HRESULT DownloadBSC_Create(IBindStatusCallback *callback, LPCWSTR file_name, IBindStatusCallback **ret_callback) { DownloadBSC *ret = heap_alloc(sizeof(*ret)); - ret->lpBindStatusCallbackVtbl = &BindStatusCallbackVtbl; - ret->lpServiceProviderVtbl = &ServiceProviderVtbl; + ret->IBindStatusCallback_iface.lpVtbl = &BindStatusCallbackVtbl; + ret->IServiceProvider_iface.lpVtbl = &ServiceProviderVtbl; ret->ref = 1; ret->file_name = heap_strdupW(file_name); ret->cache_file = NULL; @@ -315,7 +316,22 @@ static IBindStatusCallback *DownloadBSC_Create(IBindStatusCallback *callback, LP IBindStatusCallback_AddRef(callback); ret->callback = callback; - return STATUSCLB(ret); + *ret_callback = &ret->IBindStatusCallback_iface; + return S_OK; +} + +HRESULT create_default_callback(IBindStatusCallback **ret) +{ + IBindStatusCallback *callback; + HRESULT hres; + + hres = DownloadBSC_Create(NULL, NULL, &callback); + if(FAILED(hres)) + return hres; + + hres = wrap_callback(callback, ret); + IBindStatusCallback_Release(callback); + return hres; } /*********************************************************************** @@ -348,7 +364,10 @@ HRESULT WINAPI URLDownloadToFileW(LPUNKNOWN pCaller, LPCWSTR szURL, LPCWSTR szFi if(pCaller) FIXME("pCaller not supported\n"); - callback = DownloadBSC_Create(lpfnCB, szFileName); + hres = DownloadBSC_Create(lpfnCB, szFileName, &callback); + if(FAILED(hres)) + return hres; + hres = CreateAsyncBindCtx(0, callback, NULL, &bindctx); IBindStatusCallback_Release(callback); if(FAILED(hres)) diff --git a/reactos/dll/win32/urlmon/file.c b/reactos/dll/win32/urlmon/file.c index a1901565336..418b708fe23 100644 --- a/reactos/dll/win32/urlmon/file.c +++ b/reactos/dll/win32/urlmon/file.c @@ -25,8 +25,8 @@ WINE_DEFAULT_DEBUG_CHANNEL(urlmon); typedef struct { - const IInternetProtocolExVtbl *lpIInternetProtocolExVtbl; - const IInternetPriorityVtbl *lpInternetPriorityVtbl; + IInternetProtocolEx IInternetProtocolEx_iface; + IInternetPriority IInternetPriority_iface; HANDLE file; ULONG size; @@ -35,31 +35,36 @@ typedef struct { LONG ref; } FileProtocol; -#define PRIORITY(x) ((IInternetPriority*) &(x)->lpInternetPriorityVtbl) -#define PROTOCOLEX(x) ((IInternetProtocolEx*) &(x)->lpIInternetProtocolExVtbl) +static inline FileProtocol *impl_from_IInternetProtocolEx(IInternetProtocolEx *iface) +{ + return CONTAINING_RECORD(iface, FileProtocol, IInternetProtocolEx_iface); +} -#define PROTOCOL_THIS(iface) DEFINE_THIS(FileProtocol, IInternetProtocolEx, iface) +static inline FileProtocol *impl_from_IInternetPriority(IInternetPriority *iface) +{ + return CONTAINING_RECORD(iface, FileProtocol, IInternetPriority_iface); +} static HRESULT WINAPI FileProtocol_QueryInterface(IInternetProtocolEx *iface, REFIID riid, void **ppv) { - FileProtocol *This = PROTOCOL_THIS(iface); + FileProtocol *This = impl_from_IInternetProtocolEx(iface); *ppv = NULL; if(IsEqualGUID(&IID_IUnknown, riid)) { TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv); - *ppv = PROTOCOLEX(This); + *ppv = &This->IInternetProtocolEx_iface; }else if(IsEqualGUID(&IID_IInternetProtocolRoot, riid)) { TRACE("(%p)->(IID_IInternetProtocolRoot %p)\n", This, ppv); - *ppv = PROTOCOLEX(This); + *ppv = &This->IInternetProtocolEx_iface; }else if(IsEqualGUID(&IID_IInternetProtocol, riid)) { TRACE("(%p)->(IID_IInternetProtocol %p)\n", This, ppv); - *ppv = PROTOCOLEX(This); + *ppv = &This->IInternetProtocolEx_iface; }else if(IsEqualGUID(&IID_IInternetProtocolEx, riid)) { TRACE("(%p)->(IID_IInternetProtocolEx %p)\n", This, ppv); - *ppv = PROTOCOLEX(This); + *ppv = &This->IInternetProtocolEx_iface; }else if(IsEqualGUID(&IID_IInternetPriority, riid)) { TRACE("(%p)->(IID_IInternetPriority %p)\n", This, ppv); - *ppv = PRIORITY(This); + *ppv = &This->IInternetPriority_iface; } if(*ppv) { @@ -73,7 +78,7 @@ static HRESULT WINAPI FileProtocol_QueryInterface(IInternetProtocolEx *iface, RE static ULONG WINAPI FileProtocol_AddRef(IInternetProtocolEx *iface) { - FileProtocol *This = PROTOCOL_THIS(iface); + FileProtocol *This = impl_from_IInternetProtocolEx(iface); LONG ref = InterlockedIncrement(&This->ref); TRACE("(%p) ref=%d\n", This, ref); return ref; @@ -81,7 +86,7 @@ static ULONG WINAPI FileProtocol_AddRef(IInternetProtocolEx *iface) static ULONG WINAPI FileProtocol_Release(IInternetProtocolEx *iface) { - FileProtocol *This = PROTOCOL_THIS(iface); + FileProtocol *This = impl_from_IInternetProtocolEx(iface); LONG ref = InterlockedDecrement(&This->ref); TRACE("(%p) ref=%d\n", This, ref); @@ -101,7 +106,7 @@ static HRESULT WINAPI FileProtocol_Start(IInternetProtocolEx *iface, LPCWSTR szU IInternetProtocolSink *pOIProtSink, IInternetBindInfo *pOIBindInfo, DWORD grfPI, HANDLE_PTR dwReserved) { - FileProtocol *This = PROTOCOL_THIS(iface); + FileProtocol *This = impl_from_IInternetProtocolEx(iface); IUri *uri; HRESULT hres; @@ -112,8 +117,8 @@ static HRESULT WINAPI FileProtocol_Start(IInternetProtocolEx *iface, LPCWSTR szU if(FAILED(hres)) return hres; - hres = IInternetProtocolEx_StartEx(PROTOCOLEX(This), uri, pOIProtSink, pOIBindInfo, - grfPI, (HANDLE*)dwReserved); + hres = IInternetProtocolEx_StartEx(&This->IInternetProtocolEx_iface, uri, pOIProtSink, + pOIBindInfo, grfPI, (HANDLE*)dwReserved); IUri_Release(uri); return hres; @@ -121,7 +126,7 @@ static HRESULT WINAPI FileProtocol_Start(IInternetProtocolEx *iface, LPCWSTR szU static HRESULT WINAPI FileProtocol_Continue(IInternetProtocolEx *iface, PROTOCOLDATA *pProtocolData) { - FileProtocol *This = PROTOCOL_THIS(iface); + FileProtocol *This = impl_from_IInternetProtocolEx(iface); FIXME("(%p)->(%p)\n", This, pProtocolData); return E_NOTIMPL; } @@ -129,14 +134,14 @@ static HRESULT WINAPI FileProtocol_Continue(IInternetProtocolEx *iface, PROTOCOL static HRESULT WINAPI FileProtocol_Abort(IInternetProtocolEx *iface, HRESULT hrReason, DWORD dwOptions) { - FileProtocol *This = PROTOCOL_THIS(iface); + FileProtocol *This = impl_from_IInternetProtocolEx(iface); FIXME("(%p)->(%08x %08x)\n", This, hrReason, dwOptions); return E_NOTIMPL; } static HRESULT WINAPI FileProtocol_Terminate(IInternetProtocolEx *iface, DWORD dwOptions) { - FileProtocol *This = PROTOCOL_THIS(iface); + FileProtocol *This = impl_from_IInternetProtocolEx(iface); TRACE("(%p)->(%08x)\n", This, dwOptions); @@ -145,14 +150,14 @@ static HRESULT WINAPI FileProtocol_Terminate(IInternetProtocolEx *iface, DWORD d static HRESULT WINAPI FileProtocol_Suspend(IInternetProtocolEx *iface) { - FileProtocol *This = PROTOCOL_THIS(iface); + FileProtocol *This = impl_from_IInternetProtocolEx(iface); FIXME("(%p)\n", This); return E_NOTIMPL; } static HRESULT WINAPI FileProtocol_Resume(IInternetProtocolEx *iface) { - FileProtocol *This = PROTOCOL_THIS(iface); + FileProtocol *This = impl_from_IInternetProtocolEx(iface); FIXME("(%p)\n", This); return E_NOTIMPL; } @@ -160,7 +165,7 @@ static HRESULT WINAPI FileProtocol_Resume(IInternetProtocolEx *iface) static HRESULT WINAPI FileProtocol_Read(IInternetProtocolEx *iface, void *pv, ULONG cb, ULONG *pcbRead) { - FileProtocol *This = PROTOCOL_THIS(iface); + FileProtocol *This = impl_from_IInternetProtocolEx(iface); DWORD read = 0; TRACE("(%p)->(%p %u %p)\n", This, pv, cb, pcbRead); @@ -183,14 +188,14 @@ static HRESULT WINAPI FileProtocol_Read(IInternetProtocolEx *iface, void *pv, static HRESULT WINAPI FileProtocol_Seek(IInternetProtocolEx *iface, LARGE_INTEGER dlibMove, DWORD dwOrigin, ULARGE_INTEGER *plibNewPosition) { - FileProtocol *This = PROTOCOL_THIS(iface); + FileProtocol *This = impl_from_IInternetProtocolEx(iface); FIXME("(%p)->(%d %d %p)\n", This, dlibMove.u.LowPart, dwOrigin, plibNewPosition); return E_NOTIMPL; } static HRESULT WINAPI FileProtocol_LockRequest(IInternetProtocolEx *iface, DWORD dwOptions) { - FileProtocol *This = PROTOCOL_THIS(iface); + FileProtocol *This = impl_from_IInternetProtocolEx(iface); TRACE("(%p)->(%08x)\n", This, dwOptions); @@ -199,7 +204,7 @@ static HRESULT WINAPI FileProtocol_LockRequest(IInternetProtocolEx *iface, DWORD static HRESULT WINAPI FileProtocol_UnlockRequest(IInternetProtocolEx *iface) { - FileProtocol *This = PROTOCOL_THIS(iface); + FileProtocol *This = impl_from_IInternetProtocolEx(iface); TRACE("(%p)\n", This); @@ -239,7 +244,7 @@ static HRESULT WINAPI FileProtocol_StartEx(IInternetProtocolEx *iface, IUri *pUr IInternetProtocolSink *pOIProtSink, IInternetBindInfo *pOIBindInfo, DWORD grfPI, HANDLE *dwReserved) { - FileProtocol *This = PROTOCOL_THIS(iface); + FileProtocol *This = impl_from_IInternetProtocolEx(iface); BINDINFO bindinfo; DWORD grfBINDF = 0; DWORD scheme; @@ -314,8 +319,6 @@ static HRESULT WINAPI FileProtocol_StartEx(IInternetProtocolEx *iface, IUri *pUr return report_result(pOIProtSink, S_OK, 0); } -#undef PROTOCOL_THIS - static const IInternetProtocolExVtbl FileProtocolExVtbl = { FileProtocol_QueryInterface, FileProtocol_AddRef, @@ -333,30 +336,28 @@ static const IInternetProtocolExVtbl FileProtocolExVtbl = { FileProtocol_StartEx }; -#define PRIORITY_THIS(iface) DEFINE_THIS(FileProtocol, InternetPriority, iface) - static HRESULT WINAPI FilePriority_QueryInterface(IInternetPriority *iface, REFIID riid, void **ppv) { - FileProtocol *This = PRIORITY_THIS(iface); - return IInternetProtocolEx_QueryInterface(PROTOCOLEX(This), riid, ppv); + FileProtocol *This = impl_from_IInternetPriority(iface); + return IInternetProtocolEx_QueryInterface(&This->IInternetProtocolEx_iface, riid, ppv); } static ULONG WINAPI FilePriority_AddRef(IInternetPriority *iface) { - FileProtocol *This = PRIORITY_THIS(iface); - return IInternetProtocolEx_AddRef(PROTOCOLEX(This)); + FileProtocol *This = impl_from_IInternetPriority(iface); + return IInternetProtocolEx_AddRef(&This->IInternetProtocolEx_iface); } static ULONG WINAPI FilePriority_Release(IInternetPriority *iface) { - FileProtocol *This = PRIORITY_THIS(iface); - return IInternetProtocolEx_Release(PROTOCOLEX(This)); + FileProtocol *This = impl_from_IInternetPriority(iface); + return IInternetProtocolEx_Release(&This->IInternetProtocolEx_iface); } static HRESULT WINAPI FilePriority_SetPriority(IInternetPriority *iface, LONG nPriority) { - FileProtocol *This = PRIORITY_THIS(iface); + FileProtocol *This = impl_from_IInternetPriority(iface); TRACE("(%p)->(%d)\n", This, nPriority); @@ -366,7 +367,7 @@ static HRESULT WINAPI FilePriority_SetPriority(IInternetPriority *iface, LONG nP static HRESULT WINAPI FilePriority_GetPriority(IInternetPriority *iface, LONG *pnPriority) { - FileProtocol *This = PRIORITY_THIS(iface); + FileProtocol *This = impl_from_IInternetPriority(iface); TRACE("(%p)->(%p)\n", This, pnPriority); @@ -374,8 +375,6 @@ static HRESULT WINAPI FilePriority_GetPriority(IInternetPriority *iface, LONG *p return S_OK; } -#undef PRIORITY_THIS - static const IInternetPriorityVtbl FilePriorityVtbl = { FilePriority_QueryInterface, FilePriority_AddRef, @@ -394,12 +393,12 @@ HRESULT FileProtocol_Construct(IUnknown *pUnkOuter, LPVOID *ppobj) ret = heap_alloc(sizeof(FileProtocol)); - ret->lpIInternetProtocolExVtbl = &FileProtocolExVtbl; - ret->lpInternetPriorityVtbl = &FilePriorityVtbl; + ret->IInternetProtocolEx_iface.lpVtbl = &FileProtocolExVtbl; + ret->IInternetPriority_iface.lpVtbl = &FilePriorityVtbl; ret->file = INVALID_HANDLE_VALUE; ret->priority = 0; ret->ref = 1; - *ppobj = PROTOCOLEX(ret); + *ppobj = &ret->IInternetProtocolEx_iface; return S_OK; } diff --git a/reactos/dll/win32/urlmon/format.c b/reactos/dll/win32/urlmon/format.c index bf9dda06034..6967c3b4f39 100644 --- a/reactos/dll/win32/urlmon/format.c +++ b/reactos/dll/win32/urlmon/format.c @@ -24,7 +24,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(urlmon); static WCHAR wszEnumFORMATETC[] = {'_','E','n','u','m','F','O','R','M','A','T','E','T','C','_',0}; typedef struct { - const IEnumFORMATETCVtbl *lpEnumFORMATETCVtbl; + IEnumFORMATETC IEnumFORMATETC_iface; FORMATETC *fetc; UINT fetc_cnt; @@ -33,13 +33,16 @@ typedef struct { LONG ref; } EnumFORMATETC; -static IEnumFORMATETC *EnumFORMATETC_Create(UINT cfmtetc, const FORMATETC *rgfmtetc, UINT it); +static inline EnumFORMATETC *impl_from_IEnumFORMATETC(IEnumFORMATETC *iface) +{ + return CONTAINING_RECORD(iface, EnumFORMATETC, IEnumFORMATETC_iface); +} -#define ENUMF_THIS(iface) DEFINE_THIS(EnumFORMATETC, EnumFORMATETC, iface) +static IEnumFORMATETC *EnumFORMATETC_Create(UINT cfmtetc, const FORMATETC *rgfmtetc, UINT it); static HRESULT WINAPI EnumFORMATETC_QueryInterface(IEnumFORMATETC *iface, REFIID riid, void **ppv) { - EnumFORMATETC *This = ENUMF_THIS(iface); + EnumFORMATETC *This = impl_from_IEnumFORMATETC(iface); TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv); @@ -57,7 +60,7 @@ static HRESULT WINAPI EnumFORMATETC_QueryInterface(IEnumFORMATETC *iface, REFIID static ULONG WINAPI EnumFORMATETC_AddRef(IEnumFORMATETC *iface) { - EnumFORMATETC *This = ENUMF_THIS(iface); + EnumFORMATETC *This = impl_from_IEnumFORMATETC(iface); LONG ref = InterlockedIncrement(&This->ref); TRACE("(%p) ref=%d\n", This, ref); return ref; @@ -65,7 +68,7 @@ static ULONG WINAPI EnumFORMATETC_AddRef(IEnumFORMATETC *iface) static ULONG WINAPI EnumFORMATETC_Release(IEnumFORMATETC *iface) { - EnumFORMATETC *This = ENUMF_THIS(iface); + EnumFORMATETC *This = impl_from_IEnumFORMATETC(iface); LONG ref = InterlockedDecrement(&This->ref); TRACE("(%p) ref=%d\n", This, ref); @@ -83,7 +86,7 @@ static ULONG WINAPI EnumFORMATETC_Release(IEnumFORMATETC *iface) static HRESULT WINAPI EnumFORMATETC_Next(IEnumFORMATETC *iface, ULONG celt, FORMATETC *rgelt, ULONG *pceltFetched) { - EnumFORMATETC *This = ENUMF_THIS(iface); + EnumFORMATETC *This = impl_from_IEnumFORMATETC(iface); ULONG cnt; TRACE("(%p)->(%d %p %p)\n", This, celt, rgelt, pceltFetched); @@ -110,7 +113,7 @@ static HRESULT WINAPI EnumFORMATETC_Next(IEnumFORMATETC *iface, ULONG celt, static HRESULT WINAPI EnumFORMATETC_Skip(IEnumFORMATETC *iface, ULONG celt) { - EnumFORMATETC *This = ENUMF_THIS(iface); + EnumFORMATETC *This = impl_from_IEnumFORMATETC(iface); TRACE("(%p)->(%d)\n", This, celt); @@ -120,7 +123,7 @@ static HRESULT WINAPI EnumFORMATETC_Skip(IEnumFORMATETC *iface, ULONG celt) static HRESULT WINAPI EnumFORMATETC_Reset(IEnumFORMATETC *iface) { - EnumFORMATETC *This = ENUMF_THIS(iface); + EnumFORMATETC *This = impl_from_IEnumFORMATETC(iface); TRACE("(%p)\n", This); @@ -130,7 +133,7 @@ static HRESULT WINAPI EnumFORMATETC_Reset(IEnumFORMATETC *iface) static HRESULT WINAPI EnumFORMATETC_Clone(IEnumFORMATETC *iface, IEnumFORMATETC **ppenum) { - EnumFORMATETC *This = ENUMF_THIS(iface); + EnumFORMATETC *This = impl_from_IEnumFORMATETC(iface); TRACE("(%p)->(%p)\n", This, ppenum); @@ -157,7 +160,7 @@ static IEnumFORMATETC *EnumFORMATETC_Create(UINT cfmtetc, const FORMATETC *rgfmt URLMON_LockModule(); - ret->lpEnumFORMATETCVtbl = &EnumFORMATETCVtbl; + ret->IEnumFORMATETC_iface.lpVtbl = &EnumFORMATETCVtbl; ret->ref = 1; ret->it = it; ret->fetc_cnt = cfmtetc; @@ -165,7 +168,7 @@ static IEnumFORMATETC *EnumFORMATETC_Create(UINT cfmtetc, const FORMATETC *rgfmt ret->fetc = heap_alloc(cfmtetc*sizeof(FORMATETC)); memcpy(ret->fetc, rgfmtetc, cfmtetc*sizeof(FORMATETC)); - return (IEnumFORMATETC*)ret; + return &ret->IEnumFORMATETC_iface; } /********************************************************** diff --git a/reactos/dll/win32/urlmon/ftp.c b/reactos/dll/win32/urlmon/ftp.c index 4fa0924387d..deb611bc901 100644 --- a/reactos/dll/win32/urlmon/ftp.c +++ b/reactos/dll/win32/urlmon/ftp.c @@ -17,6 +17,10 @@ */ #include "urlmon_main.h" + +#define NO_SHLWAPI_REG +#include "shlwapi.h" + #include "wine/debug.h" WINE_DEFAULT_DEBUG_CHANNEL(urlmon); @@ -24,15 +28,27 @@ WINE_DEFAULT_DEBUG_CHANNEL(urlmon); typedef struct { Protocol base; - const IInternetProtocolVtbl *lpIInternetProtocolVtbl; - const IInternetPriorityVtbl *lpInternetPriorityVtbl; - const IWinInetHttpInfoVtbl *lpWinInetHttpInfoVtbl; + IInternetProtocolEx IInternetProtocolEx_iface; + IInternetPriority IInternetPriority_iface; + IWinInetHttpInfo IWinInetHttpInfo_iface; LONG ref; } FtpProtocol; -#define PRIORITY(x) ((IInternetPriority*) &(x)->lpInternetPriorityVtbl) -#define INETHTTPINFO(x) ((IWinInetHttpInfo*) &(x)->lpWinInetHttpInfoVtbl) +static inline FtpProtocol *impl_from_IInternetProtocolEx(IInternetProtocolEx *iface) +{ + return CONTAINING_RECORD(iface, FtpProtocol, IInternetProtocolEx_iface); +} + +static inline FtpProtocol *impl_from_IInternetPriority(IInternetPriority *iface) +{ + return CONTAINING_RECORD(iface, FtpProtocol, IInternetPriority_iface); +} +static inline FtpProtocol *impl_from_IWinInetHttpInfo(IWinInetHttpInfo *iface) + +{ + return CONTAINING_RECORD(iface, FtpProtocol, IWinInetHttpInfo_iface); +} #define ASYNCPROTOCOL_THIS(iface) DEFINE_THIS2(FtpProtocol, base, iface) @@ -59,6 +75,11 @@ static HRESULT FtpProtocol_open_request(Protocol *prot, IUri *uri, DWORD request return S_OK; } +static HRESULT FtpProtocol_end_request(Protocol *prot) +{ + return E_NOTIMPL; +} + static HRESULT FtpProtocol_start_downloading(Protocol *prot) { FtpProtocol *This = ASYNCPROTOCOL_THIS(prot); @@ -82,35 +103,37 @@ static void FtpProtocol_close_connection(Protocol *prot) static const ProtocolVtbl AsyncProtocolVtbl = { FtpProtocol_open_request, + FtpProtocol_end_request, FtpProtocol_start_downloading, FtpProtocol_close_connection }; -#define PROTOCOL_THIS(iface) DEFINE_THIS(FtpProtocol, IInternetProtocol, iface) - -static HRESULT WINAPI FtpProtocol_QueryInterface(IInternetProtocol *iface, REFIID riid, void **ppv) +static HRESULT WINAPI FtpProtocol_QueryInterface(IInternetProtocolEx *iface, REFIID riid, void **ppv) { - FtpProtocol *This = PROTOCOL_THIS(iface); + FtpProtocol *This = impl_from_IInternetProtocolEx(iface); *ppv = NULL; if(IsEqualGUID(&IID_IUnknown, riid)) { TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv); - *ppv = PROTOCOL(This); + *ppv = &This->IInternetProtocolEx_iface; }else if(IsEqualGUID(&IID_IInternetProtocolRoot, riid)) { TRACE("(%p)->(IID_IInternetProtocolRoot %p)\n", This, ppv); - *ppv = PROTOCOL(This); + *ppv = &This->IInternetProtocolEx_iface; }else if(IsEqualGUID(&IID_IInternetProtocol, riid)) { TRACE("(%p)->(IID_IInternetProtocol %p)\n", This, ppv); - *ppv = PROTOCOL(This); + *ppv = &This->IInternetProtocolEx_iface; + }else if(IsEqualGUID(&IID_IInternetProtocolEx, riid)) { + TRACE("(%p)->(IID_IInternetProtocolEx %p)\n", This, ppv); + *ppv = &This->IInternetProtocolEx_iface; }else if(IsEqualGUID(&IID_IInternetPriority, riid)) { TRACE("(%p)->(IID_IInternetPriority %p)\n", This, ppv); - *ppv = PRIORITY(This); + *ppv = &This->IInternetPriority_iface; }else if(IsEqualGUID(&IID_IWinInetInfo, riid)) { TRACE("(%p)->(IID_IWinInetInfo %p)\n", This, ppv); - *ppv = INETHTTPINFO(This); + *ppv = &This->IWinInetHttpInfo_iface; }else if(IsEqualGUID(&IID_IWinInetHttpInfo, riid)) { TRACE("(%p)->(IID_IWinInetHttpInfo %p)\n", This, ppv); - *ppv = INETHTTPINFO(This); + *ppv = &This->IWinInetHttpInfo_iface; } if(*ppv) { @@ -122,17 +145,17 @@ static HRESULT WINAPI FtpProtocol_QueryInterface(IInternetProtocol *iface, REFII return E_NOINTERFACE; } -static ULONG WINAPI FtpProtocol_AddRef(IInternetProtocol *iface) +static ULONG WINAPI FtpProtocol_AddRef(IInternetProtocolEx *iface) { - FtpProtocol *This = PROTOCOL_THIS(iface); + FtpProtocol *This = impl_from_IInternetProtocolEx(iface); LONG ref = InterlockedIncrement(&This->ref); TRACE("(%p) ref=%d\n", This, ref); return ref; } -static ULONG WINAPI FtpProtocol_Release(IInternetProtocol *iface) +static ULONG WINAPI FtpProtocol_Release(IInternetProtocolEx *iface) { - FtpProtocol *This = PROTOCOL_THIS(iface); + FtpProtocol *This = impl_from_IInternetProtocolEx(iface); LONG ref = InterlockedDecrement(&This->ref); TRACE("(%p) ref=%d\n", This, ref); @@ -147,52 +170,50 @@ static ULONG WINAPI FtpProtocol_Release(IInternetProtocol *iface) return ref; } -static HRESULT WINAPI FtpProtocol_Start(IInternetProtocol *iface, LPCWSTR szUrl, +static HRESULT WINAPI FtpProtocol_Start(IInternetProtocolEx *iface, LPCWSTR szUrl, IInternetProtocolSink *pOIProtSink, IInternetBindInfo *pOIBindInfo, DWORD grfPI, HANDLE_PTR dwReserved) { - FtpProtocol *This = PROTOCOL_THIS(iface); + FtpProtocol *This = impl_from_IInternetProtocolEx(iface); IUri *uri; HRESULT hres; - static const WCHAR ftpW[] = {'f','t','p',':'}; - TRACE("(%p)->(%s %p %p %08x %lx)\n", This, debugstr_w(szUrl), pOIProtSink, pOIBindInfo, grfPI, dwReserved); - if(strncmpW(szUrl, ftpW, sizeof(ftpW)/sizeof(WCHAR))) - return MK_E_SYNTAX; - hres = CreateUri(szUrl, 0, 0, &uri); if(FAILED(hres)) return hres; - hres = protocol_start(&This->base, PROTOCOL(This), uri, pOIProtSink, pOIBindInfo); + hres = IInternetProtocolEx_StartEx(&This->IInternetProtocolEx_iface, uri, pOIProtSink, + pOIBindInfo, grfPI, (HANDLE*)dwReserved); IUri_Release(uri); return hres; } -static HRESULT WINAPI FtpProtocol_Continue(IInternetProtocol *iface, PROTOCOLDATA *pProtocolData) +static HRESULT WINAPI FtpProtocol_Continue(IInternetProtocolEx *iface, PROTOCOLDATA *pProtocolData) { - FtpProtocol *This = PROTOCOL_THIS(iface); + FtpProtocol *This = impl_from_IInternetProtocolEx(iface); TRACE("(%p)->(%p)\n", This, pProtocolData); return protocol_continue(&This->base, pProtocolData); } -static HRESULT WINAPI FtpProtocol_Abort(IInternetProtocol *iface, HRESULT hrReason, +static HRESULT WINAPI FtpProtocol_Abort(IInternetProtocolEx *iface, HRESULT hrReason, DWORD dwOptions) { - FtpProtocol *This = PROTOCOL_THIS(iface); - FIXME("(%p)->(%08x %08x)\n", This, hrReason, dwOptions); - return E_NOTIMPL; + FtpProtocol *This = impl_from_IInternetProtocolEx(iface); + + TRACE("(%p)->(%08x %08x)\n", This, hrReason, dwOptions); + + return protocol_abort(&This->base, hrReason); } -static HRESULT WINAPI FtpProtocol_Terminate(IInternetProtocol *iface, DWORD dwOptions) +static HRESULT WINAPI FtpProtocol_Terminate(IInternetProtocolEx *iface, DWORD dwOptions) { - FtpProtocol *This = PROTOCOL_THIS(iface); + FtpProtocol *This = impl_from_IInternetProtocolEx(iface); TRACE("(%p)->(%08x)\n", This, dwOptions); @@ -200,59 +221,78 @@ static HRESULT WINAPI FtpProtocol_Terminate(IInternetProtocol *iface, DWORD dwOp return S_OK; } -static HRESULT WINAPI FtpProtocol_Suspend(IInternetProtocol *iface) +static HRESULT WINAPI FtpProtocol_Suspend(IInternetProtocolEx *iface) { - FtpProtocol *This = PROTOCOL_THIS(iface); + FtpProtocol *This = impl_from_IInternetProtocolEx(iface); FIXME("(%p)\n", This); return E_NOTIMPL; } -static HRESULT WINAPI FtpProtocol_Resume(IInternetProtocol *iface) +static HRESULT WINAPI FtpProtocol_Resume(IInternetProtocolEx *iface) { - FtpProtocol *This = PROTOCOL_THIS(iface); + FtpProtocol *This = impl_from_IInternetProtocolEx(iface); FIXME("(%p)\n", This); return E_NOTIMPL; } -static HRESULT WINAPI FtpProtocol_Read(IInternetProtocol *iface, void *pv, +static HRESULT WINAPI FtpProtocol_Read(IInternetProtocolEx *iface, void *pv, ULONG cb, ULONG *pcbRead) { - FtpProtocol *This = PROTOCOL_THIS(iface); + FtpProtocol *This = impl_from_IInternetProtocolEx(iface); TRACE("(%p)->(%p %u %p)\n", This, pv, cb, pcbRead); return protocol_read(&This->base, pv, cb, pcbRead); } -static HRESULT WINAPI FtpProtocol_Seek(IInternetProtocol *iface, LARGE_INTEGER dlibMove, +static HRESULT WINAPI FtpProtocol_Seek(IInternetProtocolEx *iface, LARGE_INTEGER dlibMove, DWORD dwOrigin, ULARGE_INTEGER *plibNewPosition) { - FtpProtocol *This = PROTOCOL_THIS(iface); + FtpProtocol *This = impl_from_IInternetProtocolEx(iface); FIXME("(%p)->(%d %d %p)\n", This, dlibMove.u.LowPart, dwOrigin, plibNewPosition); return E_NOTIMPL; } -static HRESULT WINAPI FtpProtocol_LockRequest(IInternetProtocol *iface, DWORD dwOptions) +static HRESULT WINAPI FtpProtocol_LockRequest(IInternetProtocolEx *iface, DWORD dwOptions) { - FtpProtocol *This = PROTOCOL_THIS(iface); + FtpProtocol *This = impl_from_IInternetProtocolEx(iface); TRACE("(%p)->(%08x)\n", This, dwOptions); return protocol_lock_request(&This->base); } -static HRESULT WINAPI FtpProtocol_UnlockRequest(IInternetProtocol *iface) +static HRESULT WINAPI FtpProtocol_UnlockRequest(IInternetProtocolEx *iface) { - FtpProtocol *This = PROTOCOL_THIS(iface); + FtpProtocol *This = impl_from_IInternetProtocolEx(iface); TRACE("(%p)\n", This); return protocol_unlock_request(&This->base); } -#undef PROTOCOL_THIS +static HRESULT WINAPI FtpProtocol_StartEx(IInternetProtocolEx *iface, IUri *pUri, + IInternetProtocolSink *pOIProtSink, IInternetBindInfo *pOIBindInfo, + DWORD grfPI, HANDLE *dwReserved) +{ + FtpProtocol *This = impl_from_IInternetProtocolEx(iface); + DWORD scheme = 0; + HRESULT hres; -static const IInternetProtocolVtbl FtpProtocolVtbl = { + TRACE("(%p)->(%p %p %p %08x %p)\n", This, pUri, pOIProtSink, + pOIBindInfo, grfPI, dwReserved); + + hres = IUri_GetScheme(pUri, &scheme); + if(FAILED(hres)) + return hres; + if(scheme != URL_SCHEME_FTP) + return MK_E_SYNTAX; + + return protocol_start(&This->base, (IInternetProtocol*)&This->IInternetProtocolEx_iface, pUri, + pOIProtSink, pOIBindInfo); +} + +static const IInternetProtocolExVtbl FtpProtocolVtbl = { FtpProtocol_QueryInterface, FtpProtocol_AddRef, FtpProtocol_Release, @@ -265,32 +305,31 @@ static const IInternetProtocolVtbl FtpProtocolVtbl = { FtpProtocol_Read, FtpProtocol_Seek, FtpProtocol_LockRequest, - FtpProtocol_UnlockRequest + FtpProtocol_UnlockRequest, + FtpProtocol_StartEx }; -#define PRIORITY_THIS(iface) DEFINE_THIS(FtpProtocol, InternetPriority, iface) - static HRESULT WINAPI FtpPriority_QueryInterface(IInternetPriority *iface, REFIID riid, void **ppv) { - FtpProtocol *This = PRIORITY_THIS(iface); - return IInternetProtocol_QueryInterface(PROTOCOL(This), riid, ppv); + FtpProtocol *This = impl_from_IInternetPriority(iface); + return IInternetProtocolEx_QueryInterface(&This->IInternetProtocolEx_iface, riid, ppv); } static ULONG WINAPI FtpPriority_AddRef(IInternetPriority *iface) { - FtpProtocol *This = PRIORITY_THIS(iface); - return IInternetProtocol_AddRef(PROTOCOL(This)); + FtpProtocol *This = impl_from_IInternetPriority(iface); + return IInternetProtocolEx_AddRef(&This->IInternetProtocolEx_iface); } static ULONG WINAPI FtpPriority_Release(IInternetPriority *iface) { - FtpProtocol *This = PRIORITY_THIS(iface); - return IInternetProtocol_Release(PROTOCOL(This)); + FtpProtocol *This = impl_from_IInternetPriority(iface); + return IInternetProtocolEx_Release(&This->IInternetProtocolEx_iface); } static HRESULT WINAPI FtpPriority_SetPriority(IInternetPriority *iface, LONG nPriority) { - FtpProtocol *This = PRIORITY_THIS(iface); + FtpProtocol *This = impl_from_IInternetPriority(iface); TRACE("(%p)->(%d)\n", This, nPriority); @@ -300,7 +339,7 @@ static HRESULT WINAPI FtpPriority_SetPriority(IInternetPriority *iface, LONG nPr static HRESULT WINAPI FtpPriority_GetPriority(IInternetPriority *iface, LONG *pnPriority) { - FtpProtocol *This = PRIORITY_THIS(iface); + FtpProtocol *This = impl_from_IInternetPriority(iface); TRACE("(%p)->(%p)\n", This, pnPriority); @@ -308,8 +347,6 @@ static HRESULT WINAPI FtpPriority_GetPriority(IInternetPriority *iface, LONG *pn return S_OK; } -#undef PRIORITY_THIS - static const IInternetPriorityVtbl FtpPriorityVtbl = { FtpPriority_QueryInterface, FtpPriority_AddRef, @@ -318,30 +355,28 @@ static const IInternetPriorityVtbl FtpPriorityVtbl = { FtpPriority_GetPriority }; -#define INETINFO_THIS(iface) DEFINE_THIS(FtpProtocol, WinInetHttpInfo, iface) - static HRESULT WINAPI HttpInfo_QueryInterface(IWinInetHttpInfo *iface, REFIID riid, void **ppv) { - FtpProtocol *This = INETINFO_THIS(iface); - return IBinding_QueryInterface(PROTOCOL(This), riid, ppv); + FtpProtocol *This = impl_from_IWinInetHttpInfo(iface); + return IInternetProtocolEx_QueryInterface(&This->IInternetProtocolEx_iface, riid, ppv); } static ULONG WINAPI HttpInfo_AddRef(IWinInetHttpInfo *iface) { - FtpProtocol *This = INETINFO_THIS(iface); - return IBinding_AddRef(PROTOCOL(This)); + FtpProtocol *This = impl_from_IWinInetHttpInfo(iface); + return IInternetProtocolEx_AddRef(&This->IInternetProtocolEx_iface); } static ULONG WINAPI HttpInfo_Release(IWinInetHttpInfo *iface) { - FtpProtocol *This = INETINFO_THIS(iface); - return IBinding_Release(PROTOCOL(This)); + FtpProtocol *This = impl_from_IWinInetHttpInfo(iface); + return IInternetProtocolEx_Release(&This->IInternetProtocolEx_iface); } static HRESULT WINAPI HttpInfo_QueryOption(IWinInetHttpInfo *iface, DWORD dwOption, void *pBuffer, DWORD *pcbBuffer) { - FtpProtocol *This = INETINFO_THIS(iface); + FtpProtocol *This = impl_from_IWinInetHttpInfo(iface); FIXME("(%p)->(%x %p %p)\n", This, dwOption, pBuffer, pcbBuffer); return E_NOTIMPL; } @@ -349,13 +384,11 @@ static HRESULT WINAPI HttpInfo_QueryOption(IWinInetHttpInfo *iface, DWORD dwOpti static HRESULT WINAPI HttpInfo_QueryInfo(IWinInetHttpInfo *iface, DWORD dwOption, void *pBuffer, DWORD *pcbBuffer, DWORD *pdwFlags, DWORD *pdwReserved) { - FtpProtocol *This = INETINFO_THIS(iface); + FtpProtocol *This = impl_from_IWinInetHttpInfo(iface); FIXME("(%p)->(%x %p %p %p %p)\n", This, dwOption, pBuffer, pcbBuffer, pdwFlags, pdwReserved); return E_NOTIMPL; } -#undef INETINFO_THIS - static const IWinInetHttpInfoVtbl WinInetHttpInfoVtbl = { HttpInfo_QueryInterface, HttpInfo_AddRef, @@ -375,12 +408,12 @@ HRESULT FtpProtocol_Construct(IUnknown *pUnkOuter, LPVOID *ppobj) ret = heap_alloc_zero(sizeof(FtpProtocol)); ret->base.vtbl = &AsyncProtocolVtbl; - ret->lpIInternetProtocolVtbl = &FtpProtocolVtbl; - ret->lpInternetPriorityVtbl = &FtpPriorityVtbl; - ret->lpWinInetHttpInfoVtbl = &WinInetHttpInfoVtbl; + ret->IInternetProtocolEx_iface.lpVtbl = &FtpProtocolVtbl; + ret->IInternetPriority_iface.lpVtbl = &FtpPriorityVtbl; + ret->IWinInetHttpInfo_iface.lpVtbl = &WinInetHttpInfoVtbl; ret->ref = 1; - *ppobj = PROTOCOL(ret); - + *ppobj = &ret->IInternetProtocolEx_iface; + return S_OK; } diff --git a/reactos/dll/win32/urlmon/gopher.c b/reactos/dll/win32/urlmon/gopher.c index d8781ce7925..da241e9358e 100644 --- a/reactos/dll/win32/urlmon/gopher.c +++ b/reactos/dll/win32/urlmon/gopher.c @@ -56,6 +56,11 @@ static HRESULT GopherProtocol_open_request(Protocol *prot, IUri *uri, DWORD requ return S_OK; } +static HRESULT GopherProtocol_end_request(Protocol *prot) +{ + return E_NOTIMPL; +} + static HRESULT GopherProtocol_start_downloading(Protocol *prot) { return S_OK; @@ -69,6 +74,7 @@ static void GopherProtocol_close_connection(Protocol *prot) static const ProtocolVtbl AsyncProtocolVtbl = { GopherProtocol_open_request, + GopherProtocol_end_request, GopherProtocol_start_downloading, GopherProtocol_close_connection }; @@ -161,8 +167,10 @@ static HRESULT WINAPI GopherProtocol_Abort(IInternetProtocol *iface, HRESULT hrR DWORD dwOptions) { GopherProtocol *This = PROTOCOL_THIS(iface); - FIXME("(%p)->(%08x %08x)\n", This, hrReason, dwOptions); - return E_NOTIMPL; + + TRACE("(%p)->(%08x %08x)\n", This, hrReason, dwOptions); + + return protocol_abort(&This->base, hrReason); } static HRESULT WINAPI GopherProtocol_Terminate(IInternetProtocol *iface, DWORD dwOptions) diff --git a/reactos/dll/win32/urlmon/http.c b/reactos/dll/win32/urlmon/http.c index 722ec501b4d..2aaefb085ec 100644 --- a/reactos/dll/win32/urlmon/http.c +++ b/reactos/dll/win32/urlmon/http.c @@ -20,6 +20,9 @@ #include "urlmon_main.h" #include "wininet.h" +#define NO_SHLWAPI_REG +#include "shlwapi.h" + #include "wine/debug.h" WINE_DEFAULT_DEBUG_CHANNEL(urlmon); @@ -27,9 +30,9 @@ WINE_DEFAULT_DEBUG_CHANNEL(urlmon); typedef struct { Protocol base; - const IInternetProtocolVtbl *lpIInternetProtocolVtbl; - const IInternetPriorityVtbl *lpInternetPriorityVtbl; - const IWinInetHttpInfoVtbl *lpWinInetHttpInfoVtbl; + IInternetProtocolEx IInternetProtocolEx_iface; + IInternetPriority IInternetPriority_iface; + IWinInetHttpInfo IWinInetHttpInfo_iface; BOOL https; IHttpNegotiate *http_negotiate; @@ -38,8 +41,20 @@ typedef struct { LONG ref; } HttpProtocol; -#define PRIORITY(x) ((IInternetPriority*) &(x)->lpInternetPriorityVtbl) -#define INETHTTPINFO(x) ((IWinInetHttpInfo*) &(x)->lpWinInetHttpInfoVtbl) +static inline HttpProtocol *impl_from_IInternetProtocolEx(IInternetProtocolEx *iface) +{ + return CONTAINING_RECORD(iface, HttpProtocol, IInternetProtocolEx_iface); +} + +static inline HttpProtocol *impl_from_IInternetPriority(IInternetPriority *iface) +{ + return CONTAINING_RECORD(iface, HttpProtocol, IInternetPriority_iface); +} + +static inline HttpProtocol *impl_from_IWinInetHttpInfo(IWinInetHttpInfo *iface) +{ + return CONTAINING_RECORD(iface, HttpProtocol, IWinInetHttpInfo_iface); +} /* Default headers from native */ static const WCHAR wszHeaders[] = {'A','c','c','e','p','t','-','E','n','c','o','d','i','n','g', @@ -71,7 +86,8 @@ static HRESULT HttpProtocol_open_request(Protocol *prot, IUri *uri, DWORD reques HINTERNET internet_session, IInternetBindInfo *bind_info) { HttpProtocol *This = ASYNCPROTOCOL_THIS(prot); - LPWSTR addl_header = NULL, post_cookie = NULL, optional = NULL; + INTERNET_BUFFERSW send_buffer = {sizeof(INTERNET_BUFFERSW)}; + LPWSTR addl_header = NULL, post_cookie = NULL; IServiceProvider *service_provider = NULL; IHttpNegotiate2 *http_negotiate2 = NULL; BSTR url, host, user, pass, path; @@ -162,6 +178,7 @@ static HRESULT HttpProtocol_open_request(Protocol *prot, IUri *uri, DWORD reques &IID_IHttpNegotiate, (void **)&This->http_negotiate); if (hres != S_OK) { WARN("IServiceProvider_QueryService IID_IHttpNegotiate failed: %08x\n", hres); + IServiceProvider_Release(service_provider); return hres; } @@ -219,13 +236,30 @@ static HRESULT HttpProtocol_open_request(Protocol *prot, IUri *uri, DWORD reques } } + send_buffer.lpcszHeader = This->full_header; + send_buffer.dwHeadersLength = send_buffer.dwHeadersTotal = strlenW(This->full_header); + if(This->base.bind_info.dwBindVerb != BINDVERB_GET) { - /* Native does not use GlobalLock/GlobalUnlock, so we won't either */ - if (This->base.bind_info.stgmedData.tymed != TYMED_HGLOBAL) - WARN("Expected This->base.bind_info.stgmedData.tymed to be TYMED_HGLOBAL, not %d\n", - This->base.bind_info.stgmedData.tymed); - else - optional = (LPWSTR)This->base.bind_info.stgmedData.u.hGlobal; + switch(This->base.bind_info.stgmedData.tymed) { + case TYMED_HGLOBAL: + /* Native does not use GlobalLock/GlobalUnlock, so we won't either */ + send_buffer.lpvBuffer = This->base.bind_info.stgmedData.u.hGlobal; + send_buffer.dwBufferLength = send_buffer.dwBufferTotal = This->base.bind_info.cbstgmedData; + break; + case TYMED_ISTREAM: { + LARGE_INTEGER offset; + + send_buffer.dwBufferTotal = This->base.bind_info.cbstgmedData; + This->base.post_stream = This->base.bind_info.stgmedData.u.pstm; + IStream_AddRef(This->base.post_stream); + + offset.QuadPart = 0; + IStream_Seek(This->base.post_stream, offset, STREAM_SEEK_SET, NULL); + break; + } + default: + FIXME("Unsupported This->base.bind_info.stgmedData.tymed %d\n", This->base.bind_info.stgmedData.tymed); + } } b = TRUE; @@ -233,8 +267,11 @@ static HRESULT HttpProtocol_open_request(Protocol *prot, IUri *uri, DWORD reques if(!res) WARN("InternetSetOption(INTERNET_OPTION_HTTP_DECODING) failed: %08x\n", GetLastError()); - res = HttpSendRequestW(This->base.request, This->full_header, lstrlenW(This->full_header), - optional, optional ? This->base.bind_info.cbstgmedData : 0); + if(This->base.post_stream) + res = HttpSendRequestExW(This->base.request, &send_buffer, NULL, 0, 0); + else + res = HttpSendRequestW(This->base.request, send_buffer.lpcszHeader, send_buffer.dwHeadersLength, + send_buffer.lpvBuffer, send_buffer.dwBufferLength); if(!res && GetLastError() != ERROR_IO_PENDING) { WARN("HttpSendRequest failed: %d\n", GetLastError()); return INET_E_DOWNLOAD_FAILURE; @@ -243,6 +280,19 @@ static HRESULT HttpProtocol_open_request(Protocol *prot, IUri *uri, DWORD reques return S_OK; } +static HRESULT HttpProtocol_end_request(Protocol *protocol) +{ + BOOL res; + + res = HttpEndRequestW(protocol->request, NULL, 0, 0); + if(!res && GetLastError() != ERROR_IO_PENDING) { + FIXME("HttpEndRequest failed: %u\n", GetLastError()); + return E_FAIL; + } + + return S_OK; +} + static HRESULT HttpProtocol_start_downloading(Protocol *prot) { HttpProtocol *This = ASYNCPROTOCOL_THIS(prot); @@ -331,35 +381,37 @@ static void HttpProtocol_close_connection(Protocol *prot) static const ProtocolVtbl AsyncProtocolVtbl = { HttpProtocol_open_request, + HttpProtocol_end_request, HttpProtocol_start_downloading, HttpProtocol_close_connection }; -#define PROTOCOL_THIS(iface) DEFINE_THIS(HttpProtocol, IInternetProtocol, iface) - -static HRESULT WINAPI HttpProtocol_QueryInterface(IInternetProtocol *iface, REFIID riid, void **ppv) +static HRESULT WINAPI HttpProtocol_QueryInterface(IInternetProtocolEx *iface, REFIID riid, void **ppv) { - HttpProtocol *This = PROTOCOL_THIS(iface); + HttpProtocol *This = impl_from_IInternetProtocolEx(iface); *ppv = NULL; if(IsEqualGUID(&IID_IUnknown, riid)) { TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv); - *ppv = PROTOCOL(This); + *ppv = &This->IInternetProtocolEx_iface; }else if(IsEqualGUID(&IID_IInternetProtocolRoot, riid)) { TRACE("(%p)->(IID_IInternetProtocolRoot %p)\n", This, ppv); - *ppv = PROTOCOL(This); + *ppv = &This->IInternetProtocolEx_iface; }else if(IsEqualGUID(&IID_IInternetProtocol, riid)) { TRACE("(%p)->(IID_IInternetProtocol %p)\n", This, ppv); - *ppv = PROTOCOL(This); + *ppv = &This->IInternetProtocolEx_iface; + }else if(IsEqualGUID(&IID_IInternetProtocolEx, riid)) { + TRACE("(%p)->(IID_IInternetProtocolEx %p)\n", This, ppv); + *ppv = &This->IInternetProtocolEx_iface; }else if(IsEqualGUID(&IID_IInternetPriority, riid)) { TRACE("(%p)->(IID_IInternetPriority %p)\n", This, ppv); - *ppv = PRIORITY(This); + *ppv = &This->IInternetPriority_iface; }else if(IsEqualGUID(&IID_IWinInetInfo, riid)) { TRACE("(%p)->(IID_IWinInetInfo %p)\n", This, ppv); - *ppv = INETHTTPINFO(This); + *ppv = &This->IWinInetHttpInfo_iface; }else if(IsEqualGUID(&IID_IWinInetHttpInfo, riid)) { TRACE("(%p)->(IID_IWinInetHttpInfo %p)\n", This, ppv); - *ppv = INETHTTPINFO(This); + *ppv = &This->IWinInetHttpInfo_iface; } if(*ppv) { @@ -371,17 +423,17 @@ static HRESULT WINAPI HttpProtocol_QueryInterface(IInternetProtocol *iface, REFI return E_NOINTERFACE; } -static ULONG WINAPI HttpProtocol_AddRef(IInternetProtocol *iface) +static ULONG WINAPI HttpProtocol_AddRef(IInternetProtocolEx *iface) { - HttpProtocol *This = PROTOCOL_THIS(iface); + HttpProtocol *This = impl_from_IInternetProtocolEx(iface); LONG ref = InterlockedIncrement(&This->ref); TRACE("(%p) ref=%d\n", This, ref); return ref; } -static ULONG WINAPI HttpProtocol_Release(IInternetProtocol *iface) +static ULONG WINAPI HttpProtocol_Release(IInternetProtocolEx *iface) { - HttpProtocol *This = PROTOCOL_THIS(iface); + HttpProtocol *This = impl_from_IInternetProtocolEx(iface); LONG ref = InterlockedDecrement(&This->ref); TRACE("(%p) ref=%d\n", This, ref); @@ -396,55 +448,50 @@ static ULONG WINAPI HttpProtocol_Release(IInternetProtocol *iface) return ref; } -static HRESULT WINAPI HttpProtocol_Start(IInternetProtocol *iface, LPCWSTR szUrl, +static HRESULT WINAPI HttpProtocol_Start(IInternetProtocolEx *iface, LPCWSTR szUrl, IInternetProtocolSink *pOIProtSink, IInternetBindInfo *pOIBindInfo, DWORD grfPI, HANDLE_PTR dwReserved) { - HttpProtocol *This = PROTOCOL_THIS(iface); + HttpProtocol *This = impl_from_IInternetProtocolEx(iface); IUri *uri; HRESULT hres; - static const WCHAR httpW[] = {'h','t','t','p',':'}; - static const WCHAR httpsW[] = {'h','t','t','p','s',':'}; - TRACE("(%p)->(%s %p %p %08x %lx)\n", This, debugstr_w(szUrl), pOIProtSink, pOIBindInfo, grfPI, dwReserved); - if(This->https - ? strncmpW(szUrl, httpsW, sizeof(httpsW)/sizeof(WCHAR)) - : strncmpW(szUrl, httpW, sizeof(httpW)/sizeof(WCHAR))) - return MK_E_SYNTAX; - hres = CreateUri(szUrl, 0, 0, &uri); if(FAILED(hres)) return hres; - hres = protocol_start(&This->base, PROTOCOL(This), uri, pOIProtSink, pOIBindInfo); + hres = IInternetProtocolEx_StartEx(&This->IInternetProtocolEx_iface, uri, pOIProtSink, + pOIBindInfo, grfPI, (HANDLE*)dwReserved); IUri_Release(uri); return hres; } -static HRESULT WINAPI HttpProtocol_Continue(IInternetProtocol *iface, PROTOCOLDATA *pProtocolData) +static HRESULT WINAPI HttpProtocol_Continue(IInternetProtocolEx *iface, PROTOCOLDATA *pProtocolData) { - HttpProtocol *This = PROTOCOL_THIS(iface); + HttpProtocol *This = impl_from_IInternetProtocolEx(iface); TRACE("(%p)->(%p)\n", This, pProtocolData); return protocol_continue(&This->base, pProtocolData); } -static HRESULT WINAPI HttpProtocol_Abort(IInternetProtocol *iface, HRESULT hrReason, +static HRESULT WINAPI HttpProtocol_Abort(IInternetProtocolEx *iface, HRESULT hrReason, DWORD dwOptions) { - HttpProtocol *This = PROTOCOL_THIS(iface); - FIXME("(%p)->(%08x %08x)\n", This, hrReason, dwOptions); - return E_NOTIMPL; + HttpProtocol *This = impl_from_IInternetProtocolEx(iface); + + TRACE("(%p)->(%08x %08x)\n", This, hrReason, dwOptions); + + return protocol_abort(&This->base, hrReason); } -static HRESULT WINAPI HttpProtocol_Terminate(IInternetProtocol *iface, DWORD dwOptions) +static HRESULT WINAPI HttpProtocol_Terminate(IInternetProtocolEx *iface, DWORD dwOptions) { - HttpProtocol *This = PROTOCOL_THIS(iface); + HttpProtocol *This = impl_from_IInternetProtocolEx(iface); TRACE("(%p)->(%08x)\n", This, dwOptions); @@ -452,59 +499,78 @@ static HRESULT WINAPI HttpProtocol_Terminate(IInternetProtocol *iface, DWORD dwO return S_OK; } -static HRESULT WINAPI HttpProtocol_Suspend(IInternetProtocol *iface) +static HRESULT WINAPI HttpProtocol_Suspend(IInternetProtocolEx *iface) { - HttpProtocol *This = PROTOCOL_THIS(iface); + HttpProtocol *This = impl_from_IInternetProtocolEx(iface); FIXME("(%p)\n", This); return E_NOTIMPL; } -static HRESULT WINAPI HttpProtocol_Resume(IInternetProtocol *iface) +static HRESULT WINAPI HttpProtocol_Resume(IInternetProtocolEx *iface) { - HttpProtocol *This = PROTOCOL_THIS(iface); + HttpProtocol *This = impl_from_IInternetProtocolEx(iface); FIXME("(%p)\n", This); return E_NOTIMPL; } -static HRESULT WINAPI HttpProtocol_Read(IInternetProtocol *iface, void *pv, +static HRESULT WINAPI HttpProtocol_Read(IInternetProtocolEx *iface, void *pv, ULONG cb, ULONG *pcbRead) { - HttpProtocol *This = PROTOCOL_THIS(iface); + HttpProtocol *This = impl_from_IInternetProtocolEx(iface); TRACE("(%p)->(%p %u %p)\n", This, pv, cb, pcbRead); return protocol_read(&This->base, pv, cb, pcbRead); } -static HRESULT WINAPI HttpProtocol_Seek(IInternetProtocol *iface, LARGE_INTEGER dlibMove, +static HRESULT WINAPI HttpProtocol_Seek(IInternetProtocolEx *iface, LARGE_INTEGER dlibMove, DWORD dwOrigin, ULARGE_INTEGER *plibNewPosition) { - HttpProtocol *This = PROTOCOL_THIS(iface); + HttpProtocol *This = impl_from_IInternetProtocolEx(iface); FIXME("(%p)->(%d %d %p)\n", This, dlibMove.u.LowPart, dwOrigin, plibNewPosition); return E_NOTIMPL; } -static HRESULT WINAPI HttpProtocol_LockRequest(IInternetProtocol *iface, DWORD dwOptions) +static HRESULT WINAPI HttpProtocol_LockRequest(IInternetProtocolEx *iface, DWORD dwOptions) { - HttpProtocol *This = PROTOCOL_THIS(iface); + HttpProtocol *This = impl_from_IInternetProtocolEx(iface); TRACE("(%p)->(%08x)\n", This, dwOptions); return protocol_lock_request(&This->base); } -static HRESULT WINAPI HttpProtocol_UnlockRequest(IInternetProtocol *iface) +static HRESULT WINAPI HttpProtocol_UnlockRequest(IInternetProtocolEx *iface) { - HttpProtocol *This = PROTOCOL_THIS(iface); + HttpProtocol *This = impl_from_IInternetProtocolEx(iface); TRACE("(%p)\n", This); return protocol_unlock_request(&This->base); } -#undef PROTOCOL_THIS +static HRESULT WINAPI HttpProtocol_StartEx(IInternetProtocolEx *iface, IUri *pUri, + IInternetProtocolSink *pOIProtSink, IInternetBindInfo *pOIBindInfo, + DWORD grfPI, HANDLE *dwReserved) +{ + HttpProtocol *This = impl_from_IInternetProtocolEx(iface); + DWORD scheme = 0; + HRESULT hres; -static const IInternetProtocolVtbl HttpProtocolVtbl = { + TRACE("(%p)->(%p %p %p %08x %p)\n", This, pUri, pOIProtSink, + pOIBindInfo, grfPI, dwReserved); + + hres = IUri_GetScheme(pUri, &scheme); + if(FAILED(hres)) + return hres; + if(scheme != (This->https ? URL_SCHEME_HTTPS : URL_SCHEME_HTTP)) + return MK_E_SYNTAX; + + return protocol_start(&This->base, (IInternetProtocol*)&This->IInternetProtocolEx_iface, pUri, + pOIProtSink, pOIBindInfo); +} + +static const IInternetProtocolExVtbl HttpProtocolVtbl = { HttpProtocol_QueryInterface, HttpProtocol_AddRef, HttpProtocol_Release, @@ -517,32 +583,31 @@ static const IInternetProtocolVtbl HttpProtocolVtbl = { HttpProtocol_Read, HttpProtocol_Seek, HttpProtocol_LockRequest, - HttpProtocol_UnlockRequest + HttpProtocol_UnlockRequest, + HttpProtocol_StartEx }; -#define PRIORITY_THIS(iface) DEFINE_THIS(HttpProtocol, InternetPriority, iface) - static HRESULT WINAPI HttpPriority_QueryInterface(IInternetPriority *iface, REFIID riid, void **ppv) { - HttpProtocol *This = PRIORITY_THIS(iface); - return IInternetProtocol_QueryInterface(PROTOCOL(This), riid, ppv); + HttpProtocol *This = impl_from_IInternetPriority(iface); + return IInternetProtocolEx_QueryInterface(&This->IInternetProtocolEx_iface, riid, ppv); } static ULONG WINAPI HttpPriority_AddRef(IInternetPriority *iface) { - HttpProtocol *This = PRIORITY_THIS(iface); - return IInternetProtocol_AddRef(PROTOCOL(This)); + HttpProtocol *This = impl_from_IInternetPriority(iface); + return IInternetProtocolEx_AddRef(&This->IInternetProtocolEx_iface); } static ULONG WINAPI HttpPriority_Release(IInternetPriority *iface) { - HttpProtocol *This = PRIORITY_THIS(iface); - return IInternetProtocol_Release(PROTOCOL(This)); + HttpProtocol *This = impl_from_IInternetPriority(iface); + return IInternetProtocolEx_Release(&This->IInternetProtocolEx_iface); } static HRESULT WINAPI HttpPriority_SetPriority(IInternetPriority *iface, LONG nPriority) { - HttpProtocol *This = PRIORITY_THIS(iface); + HttpProtocol *This = impl_from_IInternetPriority(iface); TRACE("(%p)->(%d)\n", This, nPriority); @@ -552,7 +617,7 @@ static HRESULT WINAPI HttpPriority_SetPriority(IInternetPriority *iface, LONG nP static HRESULT WINAPI HttpPriority_GetPriority(IInternetPriority *iface, LONG *pnPriority) { - HttpProtocol *This = PRIORITY_THIS(iface); + HttpProtocol *This = impl_from_IInternetPriority(iface); TRACE("(%p)->(%p)\n", This, pnPriority); @@ -560,8 +625,6 @@ static HRESULT WINAPI HttpPriority_GetPriority(IInternetPriority *iface, LONG *p return S_OK; } -#undef PRIORITY_THIS - static const IInternetPriorityVtbl HttpPriorityVtbl = { HttpPriority_QueryInterface, HttpPriority_AddRef, @@ -570,30 +633,28 @@ static const IInternetPriorityVtbl HttpPriorityVtbl = { HttpPriority_GetPriority }; -#define INETINFO_THIS(iface) DEFINE_THIS(HttpProtocol, WinInetHttpInfo, iface) - static HRESULT WINAPI HttpInfo_QueryInterface(IWinInetHttpInfo *iface, REFIID riid, void **ppv) { - HttpProtocol *This = INETINFO_THIS(iface); - return IBinding_QueryInterface(PROTOCOL(This), riid, ppv); + HttpProtocol *This = impl_from_IWinInetHttpInfo(iface); + return IInternetProtocolEx_QueryInterface(&This->IInternetProtocolEx_iface, riid, ppv); } static ULONG WINAPI HttpInfo_AddRef(IWinInetHttpInfo *iface) { - HttpProtocol *This = INETINFO_THIS(iface); - return IBinding_AddRef(PROTOCOL(This)); + HttpProtocol *This = impl_from_IWinInetHttpInfo(iface); + return IInternetProtocolEx_AddRef(&This->IInternetProtocolEx_iface); } static ULONG WINAPI HttpInfo_Release(IWinInetHttpInfo *iface) { - HttpProtocol *This = INETINFO_THIS(iface); - return IBinding_Release(PROTOCOL(This)); + HttpProtocol *This = impl_from_IWinInetHttpInfo(iface); + return IInternetProtocolEx_Release(&This->IInternetProtocolEx_iface); } static HRESULT WINAPI HttpInfo_QueryOption(IWinInetHttpInfo *iface, DWORD dwOption, void *pBuffer, DWORD *pcbBuffer) { - HttpProtocol *This = INETINFO_THIS(iface); + HttpProtocol *This = impl_from_IWinInetHttpInfo(iface); FIXME("(%p)->(%x %p %p)\n", This, dwOption, pBuffer, pcbBuffer); return E_NOTIMPL; } @@ -601,13 +662,11 @@ static HRESULT WINAPI HttpInfo_QueryOption(IWinInetHttpInfo *iface, DWORD dwOpti static HRESULT WINAPI HttpInfo_QueryInfo(IWinInetHttpInfo *iface, DWORD dwOption, void *pBuffer, DWORD *pcbBuffer, DWORD *pdwFlags, DWORD *pdwReserved) { - HttpProtocol *This = INETINFO_THIS(iface); + HttpProtocol *This = impl_from_IWinInetHttpInfo(iface); FIXME("(%p)->(%x %p %p %p %p)\n", This, dwOption, pBuffer, pcbBuffer, pdwFlags, pdwReserved); return E_NOTIMPL; } -#undef INETINFO_THIS - static const IWinInetHttpInfoVtbl WinInetHttpInfoVtbl = { HttpInfo_QueryInterface, HttpInfo_AddRef, @@ -625,15 +684,15 @@ static HRESULT create_http_protocol(BOOL https, void **ppobj) return E_OUTOFMEMORY; ret->base.vtbl = &AsyncProtocolVtbl; - ret->lpIInternetProtocolVtbl = &HttpProtocolVtbl; - ret->lpInternetPriorityVtbl = &HttpPriorityVtbl; - ret->lpWinInetHttpInfoVtbl = &WinInetHttpInfoVtbl; + ret->IInternetProtocolEx_iface.lpVtbl = &HttpProtocolVtbl; + ret->IInternetPriority_iface.lpVtbl = &HttpPriorityVtbl; + ret->IWinInetHttpInfo_iface.lpVtbl = &WinInetHttpInfoVtbl; ret->https = https; ret->ref = 1; - *ppobj = PROTOCOL(ret); - + *ppobj = &ret->IInternetProtocolEx_iface; + URLMON_LockModule(); return S_OK; } diff --git a/reactos/dll/win32/urlmon/protocol.c b/reactos/dll/win32/urlmon/protocol.c index b423c67354f..669343b211f 100644 --- a/reactos/dll/win32/urlmon/protocol.c +++ b/reactos/dll/win32/urlmon/protocol.c @@ -104,6 +104,8 @@ static void request_complete(Protocol *protocol, INTERNET_ASYNC_RESULT *ar) { PROTOCOLDATA data; + TRACE("(%p)->(%p)\n", protocol, ar); + if(!ar->dwResult) { WARN("request failed: %d\n", ar->dwError); return; @@ -191,6 +193,42 @@ static void WINAPI internet_status_callback(HINTERNET internet, DWORD_PTR contex } } +static HRESULT write_post_stream(Protocol *protocol) +{ + BYTE buf[0x20000]; + DWORD written; + ULONG size; + BOOL res; + HRESULT hres; + + protocol->flags &= ~FLAG_REQUEST_COMPLETE; + + while(1) { + size = 0; + hres = IStream_Read(protocol->post_stream, buf, sizeof(buf), &size); + if(FAILED(hres) || !size) + break; + res = InternetWriteFile(protocol->request, buf, size, &written); + if(!res) { + FIXME("InternetWriteFile failed: %u\n", GetLastError()); + hres = E_FAIL; + break; + } + } + + if(SUCCEEDED(hres)) { + IStream_Release(protocol->post_stream); + protocol->post_stream = NULL; + + hres = protocol->vtbl->end_request(protocol); + } + + if(FAILED(hres)) + return report_result(protocol, hres); + + return S_OK; +} + static HINTERNET create_internet_session(IInternetBindInfo *bind_info) { LPWSTR global_user_agent = NULL; @@ -293,6 +331,9 @@ HRESULT protocol_continue(Protocol *protocol, PROTOCOLDATA *data) return S_OK; } + if(protocol->post_stream) + return write_post_stream(protocol); + if(data->pData == (LPVOID)BINDSTATUS_DOWNLOADINGDATA) { hres = protocol->vtbl->start_downloading(protocol); if(FAILED(hres)) { @@ -428,6 +469,18 @@ HRESULT protocol_unlock_request(Protocol *protocol) return S_OK; } +HRESULT protocol_abort(Protocol *protocol, HRESULT reason) +{ + if(!protocol->protocol_sink) + return S_OK; + + if(protocol->flags & FLAG_RESULT_REPORTED) + return INET_E_RESULT_DISPATCHED; + + report_result(protocol, reason); + return S_OK; +} + void protocol_close_connection(Protocol *protocol) { protocol->vtbl->close_connection(protocol); @@ -438,5 +491,10 @@ void protocol_close_connection(Protocol *protocol) if(protocol->connection) InternetCloseHandle(protocol->connection); + if(protocol->post_stream) { + IStream_Release(protocol->post_stream); + protocol->post_stream = NULL; + } + protocol->flags = 0; } diff --git a/reactos/dll/win32/urlmon/sec_mgr.c b/reactos/dll/win32/urlmon/sec_mgr.c index f984aa4e907..6b12a9aabaa 100644 --- a/reactos/dll/win32/urlmon/sec_mgr.c +++ b/reactos/dll/win32/urlmon/sec_mgr.c @@ -295,7 +295,7 @@ static HRESULT get_action_policy(DWORD zone, DWORD action, BYTE *policy, DWORD s * */ typedef struct { - const IInternetSecurityManagerVtbl* lpInternetSecurityManagerVtbl; + IInternetSecurityManager IInternetSecurityManager_iface; LONG ref; @@ -303,11 +303,14 @@ typedef struct { IInternetSecurityManager *custom_manager; } SecManagerImpl; -#define SECMGR_THIS(iface) DEFINE_THIS(SecManagerImpl, InternetSecurityManager, iface) +static inline SecManagerImpl *impl_from_IInternetSecurityManager(IInternetSecurityManager *iface) +{ + return CONTAINING_RECORD(iface, SecManagerImpl, IInternetSecurityManager_iface); +} static HRESULT WINAPI SecManagerImpl_QueryInterface(IInternetSecurityManager* iface,REFIID riid,void** ppvObject) { - SecManagerImpl *This = SECMGR_THIS(iface); + SecManagerImpl *This = impl_from_IInternetSecurityManager(iface); TRACE("(%p)->(%s,%p)\n",This,debugstr_guid(riid),ppvObject); @@ -337,7 +340,7 @@ static HRESULT WINAPI SecManagerImpl_QueryInterface(IInternetSecurityManager* if static ULONG WINAPI SecManagerImpl_AddRef(IInternetSecurityManager* iface) { - SecManagerImpl *This = SECMGR_THIS(iface); + SecManagerImpl *This = impl_from_IInternetSecurityManager(iface); ULONG refCount = InterlockedIncrement(&This->ref); TRACE("(%p) ref=%u\n", This, refCount); @@ -347,7 +350,7 @@ static ULONG WINAPI SecManagerImpl_AddRef(IInternetSecurityManager* iface) static ULONG WINAPI SecManagerImpl_Release(IInternetSecurityManager* iface) { - SecManagerImpl *This = SECMGR_THIS(iface); + SecManagerImpl *This = impl_from_IInternetSecurityManager(iface); ULONG refCount = InterlockedDecrement(&This->ref); TRACE("(%p) ref=%u\n", This, refCount); @@ -370,7 +373,7 @@ static ULONG WINAPI SecManagerImpl_Release(IInternetSecurityManager* iface) static HRESULT WINAPI SecManagerImpl_SetSecuritySite(IInternetSecurityManager *iface, IInternetSecurityMgrSite *pSite) { - SecManagerImpl *This = SECMGR_THIS(iface); + SecManagerImpl *This = impl_from_IInternetSecurityManager(iface); TRACE("(%p)->(%p)\n", This, pSite); @@ -405,7 +408,7 @@ static HRESULT WINAPI SecManagerImpl_SetSecuritySite(IInternetSecurityManager *i static HRESULT WINAPI SecManagerImpl_GetSecuritySite(IInternetSecurityManager *iface, IInternetSecurityMgrSite **ppSite) { - SecManagerImpl *This = SECMGR_THIS(iface); + SecManagerImpl *This = impl_from_IInternetSecurityManager(iface); TRACE("(%p)->(%p)\n", This, ppSite); @@ -423,7 +426,7 @@ static HRESULT WINAPI SecManagerImpl_MapUrlToZone(IInternetSecurityManager *ifac LPCWSTR pwszUrl, DWORD *pdwZone, DWORD dwFlags) { - SecManagerImpl *This = SECMGR_THIS(iface); + SecManagerImpl *This = impl_from_IInternetSecurityManager(iface); HRESULT hres; TRACE("(%p)->(%s %p %08x)\n", iface, debugstr_w(pwszUrl), pdwZone, dwFlags); @@ -449,7 +452,7 @@ static HRESULT WINAPI SecManagerImpl_MapUrlToZone(IInternetSecurityManager *ifac static HRESULT WINAPI SecManagerImpl_GetSecurityId(IInternetSecurityManager *iface, LPCWSTR pwszUrl, BYTE *pbSecurityId, DWORD *pcbSecurityId, DWORD_PTR dwReserved) { - SecManagerImpl *This = SECMGR_THIS(iface); + SecManagerImpl *This = impl_from_IInternetSecurityManager(iface); LPWSTR url, ptr, ptr2; DWORD zone, len; HRESULT hres; @@ -529,7 +532,7 @@ static HRESULT WINAPI SecManagerImpl_ProcessUrlAction(IInternetSecurityManager * BYTE *pContext, DWORD cbContext, DWORD dwFlags, DWORD dwReserved) { - SecManagerImpl *This = SECMGR_THIS(iface); + SecManagerImpl *This = impl_from_IInternetSecurityManager(iface); DWORD zone, policy; HRESULT hres; @@ -584,7 +587,7 @@ static HRESULT WINAPI SecManagerImpl_QueryCustomPolicy(IInternetSecurityManager BYTE *pContext, DWORD cbContext, DWORD dwReserved) { - SecManagerImpl *This = SECMGR_THIS(iface); + SecManagerImpl *This = impl_from_IInternetSecurityManager(iface); HRESULT hres; TRACE("(%p)->(%s %s %p %p %p %08x %08x )\n", iface, debugstr_w(pwszUrl), debugstr_guid(guidKey), @@ -604,7 +607,7 @@ static HRESULT WINAPI SecManagerImpl_QueryCustomPolicy(IInternetSecurityManager static HRESULT WINAPI SecManagerImpl_SetZoneMapping(IInternetSecurityManager *iface, DWORD dwZone, LPCWSTR pwszPattern, DWORD dwFlags) { - SecManagerImpl *This = SECMGR_THIS(iface); + SecManagerImpl *This = impl_from_IInternetSecurityManager(iface); HRESULT hres; TRACE("(%p)->(%08x %s %08x)\n", iface, dwZone, debugstr_w(pwszPattern),dwFlags); @@ -623,7 +626,7 @@ static HRESULT WINAPI SecManagerImpl_SetZoneMapping(IInternetSecurityManager *if static HRESULT WINAPI SecManagerImpl_GetZoneMappings(IInternetSecurityManager *iface, DWORD dwZone, IEnumString **ppenumString, DWORD dwFlags) { - SecManagerImpl *This = SECMGR_THIS(iface); + SecManagerImpl *This = impl_from_IInternetSecurityManager(iface); HRESULT hres; TRACE("(%p)->(%08x %p %08x)\n", iface, dwZone, ppenumString,dwFlags); @@ -662,7 +665,7 @@ HRESULT SecManagerImpl_Construct(IUnknown *pUnkOuter, LPVOID *ppobj) This = heap_alloc(sizeof(*This)); /* Initialize the virtual function table. */ - This->lpInternetSecurityManagerVtbl = &VT_SecManagerImpl; + This->IInternetSecurityManager_iface.lpVtbl = &VT_SecManagerImpl; This->ref = 1; This->mgrsite = NULL; @@ -680,12 +683,17 @@ HRESULT SecManagerImpl_Construct(IUnknown *pUnkOuter, LPVOID *ppobj) * */ typedef struct { - const IInternetZoneManagerEx2Vtbl* lpVtbl; + IInternetZoneManagerEx2 IInternetZoneManagerEx2_iface; LONG ref; LPDWORD *zonemaps; DWORD zonemap_count; } ZoneMgrImpl; +static inline ZoneMgrImpl *impl_from_IInternetZoneManagerEx2(IInternetZoneManagerEx2 *iface) +{ + return CONTAINING_RECORD(iface, ZoneMgrImpl, IInternetZoneManagerEx2_iface); +} + /*********************************************************************** * build_zonemap_from_reg [internal] @@ -750,7 +758,7 @@ cleanup: */ static HRESULT WINAPI ZoneMgrImpl_QueryInterface(IInternetZoneManagerEx2* iface, REFIID riid, void** ppvObject) { - ZoneMgrImpl* This = (ZoneMgrImpl*)iface; + ZoneMgrImpl* This = impl_from_IInternetZoneManagerEx2(iface); TRACE("(%p)->(%s,%p)\n", This, debugstr_guid(riid), ppvObject); @@ -783,7 +791,7 @@ static HRESULT WINAPI ZoneMgrImpl_QueryInterface(IInternetZoneManagerEx2* iface, */ static ULONG WINAPI ZoneMgrImpl_AddRef(IInternetZoneManagerEx2* iface) { - ZoneMgrImpl* This = (ZoneMgrImpl*)iface; + ZoneMgrImpl* This = impl_from_IInternetZoneManagerEx2(iface); ULONG refCount = InterlockedIncrement(&This->ref); TRACE("(%p)->(ref before=%u)\n",This, refCount - 1); @@ -796,7 +804,7 @@ static ULONG WINAPI ZoneMgrImpl_AddRef(IInternetZoneManagerEx2* iface) */ static ULONG WINAPI ZoneMgrImpl_Release(IInternetZoneManagerEx2* iface) { - ZoneMgrImpl* This = (ZoneMgrImpl*)iface; + ZoneMgrImpl* This = impl_from_IInternetZoneManagerEx2(iface); ULONG refCount = InterlockedDecrement(&This->ref); TRACE("(%p)->(ref before=%u)\n",This, refCount + 1); @@ -818,7 +826,7 @@ static HRESULT WINAPI ZoneMgrImpl_GetZoneAttributes(IInternetZoneManagerEx2* ifa DWORD dwZone, ZONEATTRIBUTES* pZoneAttributes) { - ZoneMgrImpl* This = (ZoneMgrImpl*)iface; + ZoneMgrImpl* This = impl_from_IInternetZoneManagerEx2(iface); HRESULT hr; HKEY hcu; HKEY hklm = NULL; @@ -957,7 +965,7 @@ static HRESULT WINAPI ZoneMgrImpl_CreateZoneEnumerator(IInternetZoneManagerEx2* DWORD* pdwCount, DWORD dwFlags) { - ZoneMgrImpl* This = (ZoneMgrImpl*)iface; + ZoneMgrImpl* This = impl_from_IInternetZoneManagerEx2(iface); LPDWORD * new_maps; LPDWORD data; DWORD i; @@ -1012,7 +1020,7 @@ static HRESULT WINAPI ZoneMgrImpl_GetZoneAt(IInternetZoneManagerEx2* iface, DWORD dwIndex, DWORD* pdwZone) { - ZoneMgrImpl* This = (ZoneMgrImpl*)iface; + ZoneMgrImpl* This = impl_from_IInternetZoneManagerEx2(iface); LPDWORD data; TRACE("(%p)->(0x%08x, %d, %p)\n", This, dwEnum, dwIndex, pdwZone); @@ -1035,7 +1043,7 @@ static HRESULT WINAPI ZoneMgrImpl_GetZoneAt(IInternetZoneManagerEx2* iface, static HRESULT WINAPI ZoneMgrImpl_DestroyZoneEnumerator(IInternetZoneManagerEx2* iface, DWORD dwEnum) { - ZoneMgrImpl* This = (ZoneMgrImpl*)iface; + ZoneMgrImpl* This = impl_from_IInternetZoneManagerEx2(iface); LPDWORD data; TRACE("(%p)->(0x%08x)\n", This, dwEnum); @@ -1202,7 +1210,7 @@ HRESULT ZoneMgrImpl_Construct(IUnknown *pUnkOuter, LPVOID *ppobj) ZoneMgrImpl* ret = heap_alloc_zero(sizeof(ZoneMgrImpl)); TRACE("(%p %p)\n", pUnkOuter, ppobj); - ret->lpVtbl = &ZoneMgrImplVtbl; + ret->IInternetZoneManagerEx2_iface.lpVtbl = &ZoneMgrImplVtbl; ret->ref = 1; *ppobj = (IInternetZoneManagerEx*)ret; diff --git a/reactos/dll/win32/urlmon/session.c b/reactos/dll/win32/urlmon/session.c index 163ee081c69..72a3e2a3c56 100644 --- a/reactos/dll/win32/urlmon/session.c +++ b/reactos/dll/win32/urlmon/session.c @@ -92,7 +92,7 @@ static HRESULT get_protocol_cf(LPCWSTR schema, DWORD schema_len, CLSID *pclsid, heap_free(wszKey); if(res != ERROR_SUCCESS) { TRACE("Could not open protocol handler key\n"); - return E_FAIL; + return MK_E_SYNTAX; } size = sizeof(str_clsid); @@ -100,7 +100,7 @@ static HRESULT get_protocol_cf(LPCWSTR schema, DWORD schema_len, CLSID *pclsid, RegCloseKey(hkey); if(res != ERROR_SUCCESS || type != REG_SZ) { WARN("Could not get protocol CLSID res=%d\n", res); - return E_FAIL; + return MK_E_SYNTAX; } hres = CLSIDFromString(str_clsid, &clsid); @@ -115,7 +115,8 @@ static HRESULT get_protocol_cf(LPCWSTR schema, DWORD schema_len, CLSID *pclsid, if(!ret) return S_OK; - return CoGetClassObject(&clsid, CLSCTX_INPROC_SERVER, NULL, &IID_IClassFactory, (void**)ret); + hres = CoGetClassObject(&clsid, CLSCTX_INPROC_SERVER, NULL, &IID_IClassFactory, (void**)ret); + return SUCCEEDED(hres) ? S_OK : MK_E_SYNTAX; } static HRESULT register_namespace(IClassFactory *cf, REFIID clsid, LPCWSTR protocol, BOOL urlmon_protocol) @@ -235,23 +236,22 @@ IInternetProtocolInfo *get_protocol_info(LPCWSTR url) return ret; } -HRESULT get_protocol_handler(LPCWSTR url, CLSID *clsid, BOOL *urlmon_protocol, IClassFactory **ret) +HRESULT get_protocol_handler(IUri *uri, CLSID *clsid, BOOL *urlmon_protocol, IClassFactory **ret) { name_space *ns; - WCHAR schema[64]; - DWORD schema_len; + BSTR scheme; HRESULT hres; *ret = NULL; - hres = CoInternetParseUrl(url, PARSE_SCHEMA, 0, schema, sizeof(schema)/sizeof(schema[0]), - &schema_len, 0); - if(FAILED(hres) || !schema_len) - return schema_len ? hres : E_FAIL; + /* FIXME: Avoid GetSchemeName call for known schemes */ + hres = IUri_GetSchemeName(uri, &scheme); + if(FAILED(hres)) + return hres; EnterCriticalSection(&session_cs); - ns = find_name_space(schema); + ns = find_name_space(scheme); if(ns) { *ret = ns->cf; IClassFactory_AddRef(*ret); @@ -263,12 +263,16 @@ HRESULT get_protocol_handler(LPCWSTR url, CLSID *clsid, BOOL *urlmon_protocol, I LeaveCriticalSection(&session_cs); - if(*ret) - return S_OK; + if(*ret) { + hres = S_OK; + }else { + if(urlmon_protocol) + *urlmon_protocol = FALSE; + hres = get_protocol_cf(scheme, SysStringLen(scheme), clsid, ret); + } - if(urlmon_protocol) - *urlmon_protocol = FALSE; - return get_protocol_cf(schema, schema_len, clsid, ret); + SysFreeString(scheme); + return hres; } IInternetProtocol *get_mime_filter(LPCWSTR mime) @@ -420,13 +424,21 @@ static HRESULT WINAPI InternetSession_CreateBinding(IInternetSession *iface, LPBC pBC, LPCWSTR szUrl, IUnknown *pUnkOuter, IUnknown **ppUnk, IInternetProtocol **ppOInetProt, DWORD dwOption) { + IInternetProtocolEx *protocol; + HRESULT hres; + TRACE("(%p %s %p %p %p %08x)\n", pBC, debugstr_w(szUrl), pUnkOuter, ppUnk, ppOInetProt, dwOption); if(pBC || pUnkOuter || ppUnk || dwOption) FIXME("Unsupported arguments\n"); - return create_binding_protocol(szUrl, FALSE, ppOInetProt); + hres = create_binding_protocol(FALSE, &protocol); + if(FAILED(hres)) + return hres; + + *ppOInetProt = (IInternetProtocol*)protocol; + return S_OK; } static HRESULT WINAPI InternetSession_SetSessionOption(IInternetSession *iface, diff --git a/reactos/dll/win32/urlmon/umon.c b/reactos/dll/win32/urlmon/umon.c index fea7b21c471..fbb00a44baa 100644 --- a/reactos/dll/win32/urlmon/umon.c +++ b/reactos/dll/win32/urlmon/umon.c @@ -200,6 +200,7 @@ static HRESULT WINAPI URLMoniker_BindToObject(IMoniker *iface, IBindCtx* pbc, IM { URLMoniker *This = MONIKER_THIS(iface); IRunningObjectTable *obj_tbl; + IUri *uri; HRESULT hres; TRACE("(%p)->(%p,%p,%s,%p): stub\n", This, pbc, pmkToLeft, debugstr_guid(riid), ppv); @@ -210,20 +211,36 @@ static HRESULT WINAPI URLMoniker_BindToObject(IMoniker *iface, IBindCtx* pbc, IM IRunningObjectTable_Release(obj_tbl); } - return bind_to_object(iface, This->URLName, pbc, riid, ppv); + hres = CreateUri(This->URLName, Uri_CREATE_FILE_USE_DOS_PATH, 0, &uri); + if(FAILED(hres)) + return hres; + + hres = bind_to_object(iface, uri, pbc, riid, ppv); + + IUri_Release(uri); + return hres; } static HRESULT WINAPI URLMoniker_BindToStorage(IMoniker* iface, IBindCtx* pbc, IMoniker* pmkToLeft, REFIID riid, void **ppvObject) { URLMoniker *This = MONIKER_THIS(iface); + IUri *uri; + HRESULT hres; TRACE("(%p)->(%p %p %s %p)\n", This, pbc, pmkToLeft, debugstr_guid(riid), ppvObject); if(pmkToLeft) FIXME("Unsupported pmkToLeft\n"); - return bind_to_storage(This->URLName, pbc, riid, ppvObject); + hres = CreateUri(This->URLName, Uri_CREATE_FILE_USE_DOS_PATH, 0, &uri); + if(FAILED(hres)) + return hres; + + hres = bind_to_storage(uri, pbc, riid, ppvObject); + + IUri_Release(uri); + return hres; } static HRESULT WINAPI URLMoniker_Reduce(IMoniker *iface, IBindCtx *pbc, diff --git a/reactos/dll/win32/urlmon/uri.c b/reactos/dll/win32/urlmon/uri.c index 2aee38a46ba..681327f6cb8 100644 --- a/reactos/dll/win32/urlmon/uri.c +++ b/reactos/dll/win32/urlmon/uri.c @@ -23,9 +23,14 @@ #define NO_SHLWAPI_REG #include "shlwapi.h" +#include "strsafe.h" + #define UINT_MAX 0xffffffff #define USHORT_MAX 0xffff +#define URI_DISPLAY_NO_ABSOLUTE_URI 0x1 +#define URI_DISPLAY_NO_DEFAULT_PORT_AUTH 0x2 + #define ALLOW_NULL_TERM_SCHEME 0x01 #define ALLOW_NULL_TERM_USER_NAME 0x02 #define ALLOW_NULL_TERM_PASSWORD 0x04 @@ -33,12 +38,19 @@ #define SKIP_IP_FUTURE_CHECK 0x10 #define IGNORE_PORT_DELIMITER 0x20 +#define RAW_URI_FORCE_PORT_DISP 0x1 +#define RAW_URI_CONVERT_TO_DOS_PATH 0x2 + +#define COMBINE_URI_FORCE_FLAG_USE 0x1 + WINE_DEFAULT_DEBUG_CHANNEL(urlmon); static const IID IID_IUriObj = {0x4b364760,0x9f51,0x11df,{0x98,0x1c,0x08,0x00,0x20,0x0c,0x9a,0x66}}; typedef struct { - const IUriVtbl *lpIUriVtbl; + IUri IUri_iface; + IUriBuilderFactory IUriBuilderFactory_iface; + LONG ref; BSTR raw_uri; @@ -47,7 +59,7 @@ typedef struct { WCHAR *canon_uri; DWORD canon_size; DWORD canon_len; - BOOL display_absolute; + BOOL display_modifiers; DWORD create_flags; INT scheme_start; @@ -62,7 +74,8 @@ typedef struct { DWORD host_len; Uri_HOST_TYPE host_type; - USHORT port; + INT port_offset; + DWORD port; BOOL has_port; INT authority_start; @@ -82,7 +95,7 @@ typedef struct { } Uri; typedef struct { - const IUriBuilderVtbl *lpIUriBuilderVtbl; + IUriBuilder IUriBuilder_iface; LONG ref; Uri *uri; @@ -337,6 +350,17 @@ static inline BOOL is_path_delim(WCHAR val) { return (!val || val == '#' || val == '?'); } +static BOOL is_default_port(URL_SCHEME scheme, DWORD port) { + DWORD i; + + for(i = 0; i < sizeof(default_ports)/sizeof(default_ports[0]); ++i) { + if(default_ports[i].scheme == scheme && default_ports[i].port) + return TRUE; + } + + return FALSE; +} + /* List of schemes types Windows seems to expect to be hierarchical. */ static inline BOOL is_hierarchical_scheme(URL_SCHEME type) { return(type == URL_SCHEME_HTTP || type == URL_SCHEME_FTP || @@ -933,6 +957,19 @@ static DWORD ui2ipv4(WCHAR *dest, UINT address) { return ret; } +static DWORD ui2str(WCHAR *dest, UINT value) { + static const WCHAR formatW[] = {'%','u',0}; + DWORD ret = 0; + + if(!dest) { + WCHAR tmp[11]; + ret = sprintfW(tmp, formatW, value); + } else + ret = sprintfW(dest, formatW, value); + + return ret; +} + /* Converts an h16 component (from an IPv6 address) into it's * numerical value. * @@ -1316,19 +1353,13 @@ static BOOL parse_username(const WCHAR **ptr, parse_data *data, DWORD flags, DWO } static BOOL parse_password(const WCHAR **ptr, parse_data *data, DWORD flags, DWORD extras) { - const WCHAR *start = *ptr; - - if(**ptr != ':') - return TRUE; - - ++(*ptr); data->password = *ptr; while(**ptr != '@') { if(**ptr == '%') { if(!check_pct_encoded(ptr)) { if(data->scheme_type != URL_SCHEME_UNKNOWN) { - *ptr = start; + *ptr = data->password; data->password = NULL; return FALSE; } @@ -1337,7 +1368,7 @@ static BOOL parse_password(const WCHAR **ptr, parse_data *data, DWORD flags, DWO } else if(extras & ALLOW_NULL_TERM_PASSWORD && !**ptr) break; else if(is_auth_delim(**ptr, data->scheme_type != URL_SCHEME_UNKNOWN)) { - *ptr = start; + *ptr = data->password; data->password = NULL; return FALSE; } @@ -1376,12 +1407,15 @@ static void parse_userinfo(const WCHAR **ptr, parse_data *data, DWORD flags) { return; } - if(!parse_password(ptr, data, flags, 0)) { - *ptr = start; - data->username = NULL; - data->username_len = 0; - TRACE("(%p %p %x): URI contained no userinfo.\n", ptr, data, flags); - return; + if(**ptr == ':') { + ++(*ptr); + if(!parse_password(ptr, data, flags, 0)) { + *ptr = start; + data->username = NULL; + data->username_len = 0; + TRACE("(%p %p %x): URI contained no userinfo.\n", ptr, data, flags); + return; + } } if(**ptr != '@') { @@ -1524,8 +1558,11 @@ static BOOL parse_ipv4address(const WCHAR **ptr, parse_data *data, DWORD flags) static BOOL parse_reg_name(const WCHAR **ptr, parse_data *data, DWORD flags, DWORD extras) { const BOOL has_start_bracket = **ptr == '['; const BOOL known_scheme = data->scheme_type != URL_SCHEME_UNKNOWN; + const BOOL is_res = data->scheme_type == URL_SCHEME_RES; BOOL inside_brackets = has_start_bracket; - BOOL ignore_col = extras & IGNORE_PORT_DELIMITER; + + /* res URIs don't have ports. */ + BOOL ignore_col = (extras & IGNORE_PORT_DELIMITER) || is_res; /* We have to be careful with file schemes. */ if(data->scheme_type == URL_SCHEME_FILE) { @@ -1547,7 +1584,11 @@ static BOOL parse_reg_name(const WCHAR **ptr, parse_data *data, DWORD flags, DWO data->host = *ptr; - while(!is_auth_delim(**ptr, known_scheme)) { + /* For res URIs, everything before the first '/' is + * considered the host. + */ + while((!is_res && !is_auth_delim(**ptr, known_scheme)) || + (is_res && **ptr && **ptr != '/')) { if(**ptr == ':' && !ignore_col) { /* We can ignore ':' if were inside brackets.*/ if(!inside_brackets) { @@ -1571,7 +1612,7 @@ static BOOL parse_reg_name(const WCHAR **ptr, parse_data *data, DWORD flags, DWO break; } } - } else if(**ptr == '%' && known_scheme) { + } else if(**ptr == '%' && (known_scheme && !is_res)) { /* Has to be a legit % encoded value. */ if(!check_pct_encoded(ptr)) { *ptr = data->host; @@ -1579,6 +1620,10 @@ static BOOL parse_reg_name(const WCHAR **ptr, parse_data *data, DWORD flags, DWO return FALSE; } else continue; + } else if(is_res && is_forbidden_dos_path_char(**ptr)) { + *ptr = data->host; + data->host = NULL; + return FALSE; } else if(**ptr == ']') inside_brackets = FALSE; else if(**ptr == '[') @@ -1603,7 +1648,7 @@ static BOOL parse_reg_name(const WCHAR **ptr, parse_data *data, DWORD flags, DWO data->host_len = *ptr - data->host; /* If the host is empty, then it's an unknown host type. */ - if(data->host_len == 0) + if(data->host_len == 0 || is_res) data->host_type = Uri_HOST_UNKNOWN; else data->host_type = Uri_HOST_DNS; @@ -2338,6 +2383,9 @@ static BOOL canonicalize_userinfo(const parse_data *data, Uri *uri, DWORD flags, * it isn't an unknown scheme type. * * 4) If it's a file scheme and the host is "localhost" it's removed. + * + * 5) If it's a file scheme and Uri_CREATE_FILE_USE_DOS_PATH is set, + * then the UNC path characters are added before the host name. */ static BOOL canonicalize_reg_name(const parse_data *data, Uri *uri, DWORD flags, BOOL computeOnly) { @@ -2346,8 +2394,6 @@ static BOOL canonicalize_reg_name(const parse_data *data, Uri *uri, const WCHAR *ptr; const BOOL known_scheme = data->scheme_type != URL_SCHEME_UNKNOWN; - uri->host_start = uri->canon_len; - if(data->scheme_type == URL_SCHEME_FILE && data->host_len == lstrlenW(localhostW)) { if(!StrCmpNIW(data->host, localhostW, data->host_len)) { @@ -2358,6 +2404,17 @@ static BOOL canonicalize_reg_name(const parse_data *data, Uri *uri, } } + if(data->scheme_type == URL_SCHEME_FILE && flags & Uri_CREATE_FILE_USE_DOS_PATH) { + if(!computeOnly) { + uri->canon_uri[uri->canon_len] = '\\'; + uri->canon_uri[uri->canon_len+1] = '\\'; + } + uri->canon_len += 2; + uri->authority_start = uri->canon_len; + } + + uri->host_start = uri->canon_len; + for(ptr = data->host; ptr < data->host+data->host_len; ++ptr) { if(*ptr == '%' && known_scheme) { WCHAR val = decode_pct_val(ptr); @@ -2751,7 +2808,7 @@ static BOOL canonicalize_port(const parse_data *data, Uri *uri, DWORD flags, BOO USHORT default_port = 0; DWORD i; - uri->has_port = FALSE; + uri->port_offset = -1; /* Check if the scheme has a default port. */ for(i = 0; i < sizeof(default_ports)/sizeof(default_ports[0]); ++i) { @@ -2762,8 +2819,7 @@ static BOOL canonicalize_port(const parse_data *data, Uri *uri, DWORD flags, BOO } } - if(data->port || has_default_port) - uri->has_port = TRUE; + uri->has_port = data->has_port || has_default_port; /* Possible cases: * 1) Has a port which is the default port. @@ -2771,38 +2827,44 @@ static BOOL canonicalize_port(const parse_data *data, Uri *uri, DWORD flags, BOO * 3) Doesn't have a port, but, scheme has a default port. * 4) No port. */ - if(has_default_port && data->port && data->port_value == default_port) { + if(has_default_port && data->has_port && data->port_value == default_port) { /* If it's the default port and this flag isn't set, don't do anything. */ if(flags & Uri_CREATE_NO_CANONICALIZE) { - /* Copy the original port over. */ - if(!computeOnly) { + uri->port_offset = uri->canon_len-uri->authority_start; + if(!computeOnly) uri->canon_uri[uri->canon_len] = ':'; - memcpy(uri->canon_uri+uri->canon_len+1, data->port, data->port_len*sizeof(WCHAR)); + ++uri->canon_len; + + if(data->port) { + /* Copy the original port over. */ + if(!computeOnly) + memcpy(uri->canon_uri+uri->canon_len, data->port, data->port_len*sizeof(WCHAR)); + uri->canon_len += data->port_len; + } else { + if(!computeOnly) + uri->canon_len += ui2str(uri->canon_uri+uri->canon_len, data->port_value); + else + uri->canon_len += ui2str(NULL, data->port_value); } - uri->canon_len += data->port_len+1; } uri->port = default_port; - } else if(data->port) { + } else if(data->has_port) { + uri->port_offset = uri->canon_len-uri->authority_start; if(!computeOnly) uri->canon_uri[uri->canon_len] = ':'; ++uri->canon_len; - if(flags & Uri_CREATE_NO_CANONICALIZE) { + if(flags & Uri_CREATE_NO_CANONICALIZE && data->port) { /* Copy the original over without changes. */ if(!computeOnly) memcpy(uri->canon_uri+uri->canon_len, data->port, data->port_len*sizeof(WCHAR)); uri->canon_len += data->port_len; } else { - const WCHAR formatW[] = {'%','u',0}; - INT len = 0; if(!computeOnly) - len = sprintfW(uri->canon_uri+uri->canon_len, formatW, data->port_value); - else { - WCHAR tmp[6]; - len = sprintfW(tmp, formatW, data->port_value); - } - uri->canon_len += len; + uri->canon_len += ui2str(uri->canon_uri+uri->canon_len, data->port_value); + else + uri->canon_len += ui2str(NULL, data->port_value); } uri->port = data->port_value; @@ -2826,7 +2888,7 @@ static BOOL canonicalize_authority(const parse_data *data, Uri *uri, DWORD flags if(!canonicalize_port(data, uri, flags, computeOnly)) return FALSE; - if(uri->host_start != -1) + if(uri->host_start != -1 || (data->is_relative && (data->password || data->username))) uri->authority_len = uri->canon_len - uri->authority_start; else uri->authority_start = -1; @@ -2859,6 +2921,7 @@ static BOOL canonicalize_authority(const parse_data *data, Uri *uri, DWORD flags * NOTES: * file://c:/test%20test -> file:///c:/test%2520test * file://c:/test%3Etest -> file:///c:/test%253Etest + * if Uri_CREATE_FILE_USE_DOS_PATH is not set: * file:///c:/test%20test -> file:///c:/test%20test * file:///c:/test%test -> file:///c:/test%25test */ @@ -2867,6 +2930,7 @@ static BOOL canonicalize_path_hierarchical(const parse_data *data, Uri *uri, const WCHAR *ptr; const BOOL known_scheme = data->scheme_type != URL_SCHEME_UNKNOWN; const BOOL is_file = data->scheme_type == URL_SCHEME_FILE; + const BOOL is_res = data->scheme_type == URL_SCHEME_RES; BOOL escape_pct = FALSE; @@ -2907,13 +2971,22 @@ static BOOL canonicalize_path_hierarchical(const parse_data *data, Uri *uri, } } + if(!is_file && *(data->path) && *(data->path) != '/') { + /* Prepend a '/' to the path if it doesn't have one. */ + if(!computeOnly) + uri->canon_uri[uri->canon_len] = '/'; + ++uri->canon_len; + } + for(; ptr < data->path+data->path_len; ++ptr) { - if(*ptr == '%') { + BOOL do_default_action = TRUE; + + if(*ptr == '%' && !is_res) { const WCHAR *tmp = ptr; WCHAR val; /* Check if the % represents a valid encoded char, or if it needs encoded. */ - BOOL force_encode = !check_pct_encoded(&tmp) && is_file; + BOOL force_encode = !check_pct_encoded(&tmp) && is_file && !(flags&Uri_CREATE_FILE_USE_DOS_PATH); val = decode_pct_val(ptr); if(force_encode || escape_pct) { @@ -2921,49 +2994,43 @@ static BOOL canonicalize_path_hierarchical(const parse_data *data, Uri *uri, if(!computeOnly) pct_encode_val(*ptr, uri->canon_uri+uri->canon_len); uri->canon_len += 3; + do_default_action = FALSE; } else if((is_unreserved(val) && known_scheme) || - (is_file && (is_unreserved(val) || is_reserved(val)))) { + (is_file && (is_unreserved(val) || is_reserved(val) || + (val && flags&Uri_CREATE_FILE_USE_DOS_PATH && !is_forbidden_dos_path_char(val))))) { if(!computeOnly) uri->canon_uri[uri->canon_len] = val; ++uri->canon_len; ptr += 2; continue; - } else { - if(!computeOnly) - uri->canon_uri[uri->canon_len] = *ptr; - ++uri->canon_len; } } else if(*ptr == '/' && is_file && (flags & Uri_CREATE_FILE_USE_DOS_PATH)) { /* Convert the '/' back to a '\\'. */ if(!computeOnly) uri->canon_uri[uri->canon_len] = '\\'; ++uri->canon_len; + do_default_action = FALSE; } else if(*ptr == '\\' && known_scheme) { - if(is_file && (flags & Uri_CREATE_FILE_USE_DOS_PATH)) { - /* Don't convert the '\\' to a '/'. */ - if(!computeOnly) - uri->canon_uri[uri->canon_len] = *ptr; - ++uri->canon_len; - } else { + if(!(is_file && (flags & Uri_CREATE_FILE_USE_DOS_PATH))) { + /* Convert '\\' into a '/'. */ if(!computeOnly) uri->canon_uri[uri->canon_len] = '/'; ++uri->canon_len; + do_default_action = FALSE; } - } else if(known_scheme && !is_unreserved(*ptr) && !is_reserved(*ptr) && + } else if(known_scheme && !is_res && !is_unreserved(*ptr) && !is_reserved(*ptr) && (!(flags & Uri_CREATE_NO_ENCODE_FORBIDDEN_CHARACTERS) || is_file)) { - if(is_file && (flags & Uri_CREATE_FILE_USE_DOS_PATH)) { - /* Don't escape the character. */ - if(!computeOnly) - uri->canon_uri[uri->canon_len] = *ptr; - ++uri->canon_len; - } else { + if(!(is_file && (flags & Uri_CREATE_FILE_USE_DOS_PATH))) { /* Escape the forbidden character. */ if(!computeOnly) pct_encode_val(*ptr, uri->canon_uri+uri->canon_len); uri->canon_len += 3; + do_default_action = FALSE; } - } else { + } + + if(do_default_action) { if(!computeOnly) uri->canon_uri[uri->canon_len] = *ptr; ++uri->canon_len; @@ -3041,6 +3108,8 @@ static BOOL canonicalize_path_opaque(const parse_data *data, Uri *uri, DWORD fla } for(ptr = data->path; ptr < data->path+data->path_len; ++ptr) { + BOOL do_default_action = TRUE; + if(*ptr == '%' && known_scheme) { WCHAR val = decode_pct_val(ptr); @@ -3051,47 +3120,31 @@ static BOOL canonicalize_path_opaque(const parse_data *data, Uri *uri, DWORD fla ptr += 2; continue; - } else { - if(!computeOnly) - uri->canon_uri[uri->canon_len] = *ptr; - ++uri->canon_len; } } else if(*ptr == '/' && is_file && (flags & Uri_CREATE_FILE_USE_DOS_PATH)) { if(!computeOnly) uri->canon_uri[uri->canon_len] = '\\'; ++uri->canon_len; - } else if(*ptr == '\\' && is_file) { - if(!(flags & Uri_CREATE_FILE_USE_DOS_PATH)) { + do_default_action = FALSE; + } else if(*ptr == '\\') { + if(is_file && !(flags & Uri_CREATE_FILE_USE_DOS_PATH)) { /* Convert to a '/'. */ if(!computeOnly) uri->canon_uri[uri->canon_len] = '/'; ++uri->canon_len; - } else { - /* Just copy it over. */ - if(!computeOnly) - uri->canon_uri[uri->canon_len] = *ptr; - ++uri->canon_len; + do_default_action = FALSE; } } else if(known_scheme && !is_unreserved(*ptr) && !is_reserved(*ptr) && !(flags & Uri_CREATE_NO_ENCODE_FORBIDDEN_CHARACTERS)) { - if(is_file && (flags & Uri_CREATE_FILE_USE_DOS_PATH)) { - /* Forbidden characters aren't percent encoded for file schemes - * with USE_DOS_PATH set. - */ - if(!computeOnly) - uri->canon_uri[uri->canon_len] = *ptr; - ++uri->canon_len; - } else if(data->scheme_type == URL_SCHEME_MK && *ptr == '\\') { - /* MK URIs don't get '\\' percent encoded. */ - if(!computeOnly) - uri->canon_uri[uri->canon_len] = *ptr; - ++uri->canon_len; - } else { + if(!(is_file && (flags & Uri_CREATE_FILE_USE_DOS_PATH))) { if(!computeOnly) pct_encode_val(*ptr, uri->canon_uri+uri->canon_len); uri->canon_len += 3; + do_default_action = FALSE; } - } else { + } + + if(do_default_action) { if(!computeOnly) uri->canon_uri[uri->canon_len] = *ptr; ++uri->canon_len; @@ -3112,11 +3165,15 @@ static BOOL canonicalize_path_opaque(const parse_data *data, Uri *uri, DWORD fla * URI is opaque it canonicalizes the path of the URI. */ static BOOL canonicalize_hierpart(const parse_data *data, Uri *uri, DWORD flags, BOOL computeOnly) { - uri->display_absolute = TRUE; - - if(!data->is_opaque) { - /* "//" is only added for non-wildcard scheme types. */ - if(data->scheme_type != URL_SCHEME_WILDCARD) { + if(!data->is_opaque || (data->is_relative && (data->password || data->username))) { + /* "//" is only added for non-wildcard scheme types. + * + * A "//" is only added to a relative URI if it has a + * host or port component (this only happens if a IUriBuilder + * is generating an IUri). + */ + if((data->is_relative && (data->host || data->has_port)) || + (!data->is_relative && data->scheme_type != URL_SCHEME_WILDCARD)) { if(!computeOnly) { INT pos = uri->canon_len; @@ -3129,10 +3186,13 @@ static BOOL canonicalize_hierpart(const parse_data *data, Uri *uri, DWORD flags, if(!canonicalize_authority(data, uri, flags, computeOnly)) return FALSE; - /* TODO: Canonicalize the path of the URI. */ - if(!canonicalize_path_hierarchical(data, uri, flags, computeOnly)) - return FALSE; - + if(data->is_relative && (data->password || data->username)) { + if(!canonicalize_path_opaque(data, uri, flags, computeOnly)) + return FALSE; + } else { + if(!canonicalize_path_hierarchical(data, uri, flags, computeOnly)) + return FALSE; + } } else { /* Opaque URI's don't have an authority. */ uri->userinfo_start = uri->userinfo_split = -1; @@ -3144,6 +3204,7 @@ static BOOL canonicalize_hierpart(const parse_data *data, Uri *uri, DWORD flags, uri->authority_start = -1; uri->authority_len = 0; uri->domain_offset = -1; + uri->port_offset = -1; if(is_hierarchical_scheme(data->scheme_type)) { DWORD i; @@ -3151,7 +3212,7 @@ static BOOL canonicalize_hierpart(const parse_data *data, Uri *uri, DWORD flags, /* Absolute URIs aren't displayed for known scheme types * which should be hierarchical URIs. */ - uri->display_absolute = FALSE; + uri->display_modifiers |= URI_DISPLAY_NO_ABSOLUTE_URI; /* Windows also sets the port for these (if they have one). */ for(i = 0; i < sizeof(default_ports)/sizeof(default_ports[0]); ++i) { @@ -3394,14 +3455,12 @@ static HRESULT canonicalize_uri(const parse_data *data, Uri *uri, DWORD flags) { uri->canon_size = len; if(!canonicalize_scheme(data, uri, flags, FALSE)) { ERR("(%p %p %x): Unable to canonicalize the scheme of the URI.\n", data, uri, flags); - heap_free(uri->canon_uri); return E_INVALIDARG; } uri->scheme_type = data->scheme_type; if(!canonicalize_hierpart(data, uri, flags, FALSE)) { ERR("(%p %p %x): Unable to canonicalize the heirpart of the URI\n", data, uri, flags); - heap_free(uri->canon_uri); return E_INVALIDARG; } @@ -3510,12 +3569,9 @@ static HRESULT set_builder_component(LPWSTR *component, DWORD *component_len, LP return S_OK; } -#define URI(x) ((IUri*) &(x)->lpIUriVtbl) -#define URIBUILDER(x) ((IUriBuilder*) &(x)->lpIUriBuilderVtbl) - static void reset_builder(UriBuilder *builder) { if(builder->uri) - IUri_Release(URI(builder->uri)); + IUri_Release(&builder->uri->IUri_iface); builder->uri = NULL; heap_free(builder->fragment); @@ -3720,8 +3776,11 @@ static void setup_port(const UriBuilder *builder, parse_data *data, DWORD flags) static HRESULT validate_path(const UriBuilder *builder, parse_data *data, DWORD flags) { const WCHAR *ptr = NULL; + const WCHAR *component; const WCHAR **pptr; DWORD expected_len; + BOOL check_len = TRUE; + BOOL valid = FALSE; if(builder->path) { ptr = builder->path; @@ -3730,29 +3789,30 @@ static HRESULT validate_path(const UriBuilder *builder, parse_data *data, DWORD builder->uri && builder->uri->path_start > -1) { ptr = builder->uri->canon_uri+builder->uri->path_start; expected_len = builder->uri->path_len; + } else { + static const WCHAR nullW[] = {0}; + ptr = nullW; + check_len = FALSE; } - if(ptr) { - BOOL valid = FALSE; - const WCHAR *component = ptr; - pptr = &ptr; + component = ptr; + pptr = &ptr; - /* How the path is validated depends on what type of - * URI it is. - */ - valid = data->is_opaque ? - parse_path_opaque(pptr, data, flags) : parse_path_hierarchical(pptr, data, flags); + /* How the path is validated depends on what type of + * URI it is. + */ + valid = data->is_opaque ? + parse_path_opaque(pptr, data, flags) : parse_path_hierarchical(pptr, data, flags); - if(!valid || expected_len != data->path_len) { - TRACE("(%p %p %x): Invalid path componet %s.\n", builder, data, flags, - debugstr_wn(component, expected_len)); - return INET_E_INVALID_URL; - } - - TRACE("(%p %p %x): Valid path component %s len=%d.\n", builder, data, flags, - debugstr_wn(data->path, data->path_len), data->path_len); + if(!valid || (check_len && expected_len != data->path_len)) { + TRACE("(%p %p %x): Invalid path component %s.\n", builder, data, flags, + debugstr_wn(component, check_len ? expected_len : -1) ); + return INET_E_INVALID_URL; } + TRACE("(%p %p %x): Valid path component %s len=%d.\n", builder, data, flags, + debugstr_wn(data->path, data->path_len), data->path_len); + return S_OK; } @@ -3805,7 +3865,7 @@ static HRESULT validate_fragment(const UriBuilder *builder, parse_data *data, DW const WCHAR *component = ptr; pptr = &ptr; - if(parse_query(pptr, data, flags) && expected_len == data->fragment_len) + if(parse_fragment(pptr, data, flags) && expected_len == data->fragment_len) TRACE("(%p %p %x): Valid fragment component %s len=%d.\n", builder, data, flags, debugstr_wn(data->fragment, data->fragment_len), data->fragment_len); else { @@ -3847,11 +3907,14 @@ static HRESULT validate_components(const UriBuilder *builder, parse_data *data, if(FAILED(hr)) return hr; - /* The URI is opaque if it doesn't have an authority component. */ - data->is_opaque = !data->username && !data->password && !data->host; - setup_port(builder, data, flags); + /* The URI is opaque if it doesn't have an authority component. */ + if(!data->is_relative) + data->is_opaque = !data->username && !data->password && !data->host && !data->has_port; + else + data->is_opaque = !data->host && !data->has_port; + hr = validate_path(builder, data, flags); if(FAILED(hr)) return hr; @@ -3869,61 +3932,218 @@ static HRESULT validate_components(const UriBuilder *builder, parse_data *data, return S_OK; } -static HRESULT build_uri(const UriBuilder *builder, IUri **uri, DWORD create_flags, - DWORD use_orig_flags, DWORD encoding_mask) +static void convert_to_dos_path(const WCHAR *path, DWORD path_len, + WCHAR *output, DWORD *output_len) { - HRESULT hr; - parse_data data; + const WCHAR *ptr = path; - if(!uri) - return E_POINTER; + if(path_len > 3 && *ptr == '/' && is_drive_path(path+1)) + /* Skip over the leading / before the drive path. */ + ++ptr; - if(encoding_mask && (!builder->uri || builder->modified_props)) { - *uri = NULL; - return E_NOTIMPL; + for(; ptr < path+path_len; ++ptr) { + if(*ptr == '/') { + if(output) + *output++ = '\\'; + (*output_len)++; + } else { + if(output) + *output++ = *ptr; + (*output_len)++; + } + } +} + +/* Generates a raw uri string using the parse_data. */ +static DWORD generate_raw_uri(const parse_data *data, BSTR uri, DWORD flags) { + DWORD length = 0; + + if(data->scheme) { + if(uri) { + memcpy(uri, data->scheme, data->scheme_len*sizeof(WCHAR)); + uri[data->scheme_len] = ':'; + } + length += data->scheme_len+1; } - /* Decide what flags should be used when creating the Uri. */ - if((use_orig_flags & UriBuilder_USE_ORIGINAL_FLAGS) && builder->uri) - create_flags = builder->uri->create_flags; - else { - if(has_invalid_flag_combination(create_flags)) { - *uri = NULL; - return E_INVALIDARG; + if(!data->is_opaque) { + /* For the "//" which appears before the authority component. */ + if(uri) { + uri[length] = '/'; + uri[length+1] = '/'; + } + length += 2; + + /* Check if we need to add the "\\" before the host name + * of a UNC server name in a DOS path. + */ + if(flags & RAW_URI_CONVERT_TO_DOS_PATH && + data->scheme_type == URL_SCHEME_FILE && data->host) { + if(uri) { + uri[length] = '\\'; + uri[length+1] = '\\'; + } + length += 2; + } + } + + if(data->username) { + if(uri) + memcpy(uri+length, data->username, data->username_len*sizeof(WCHAR)); + length += data->username_len; + } + + if(data->password) { + if(uri) { + uri[length] = ':'; + memcpy(uri+length+1, data->password, data->password_len*sizeof(WCHAR)); + } + length += data->password_len+1; + } + + if(data->password || data->username) { + if(uri) + uri[length] = '@'; + ++length; + } + + if(data->host) { + /* IPv6 addresses get the brackets added around them if they don't already + * have them. + */ + const BOOL add_brackets = data->host_type == Uri_HOST_IPV6 && *(data->host) != '['; + if(add_brackets) { + if(uri) + uri[length] = '['; + ++length; } - /* Set the default flags if they don't cause a conflict. */ - apply_default_flags(&create_flags); + if(uri) + memcpy(uri+length, data->host, data->host_len*sizeof(WCHAR)); + length += data->host_len; + + if(add_brackets) { + if(uri) + uri[length] = ']'; + length++; + } } - /* Return the base IUri if no changes have been made and the create_flags match. */ - if(builder->uri && !builder->modified_props && builder->uri->create_flags == create_flags) { - *uri = URI(builder->uri); - IUri_AddRef(*uri); - return S_OK; + if(data->has_port) { + /* The port isn't included in the raw uri if it's the default + * port for the scheme type. + */ + DWORD i; + BOOL is_default = FALSE; + + for(i = 0; i < sizeof(default_ports)/sizeof(default_ports[0]); ++i) { + if(data->scheme_type == default_ports[i].scheme && + data->port_value == default_ports[i].port) + is_default = TRUE; + } + + if(!is_default || flags & RAW_URI_FORCE_PORT_DISP) { + if(uri) + uri[length] = ':'; + ++length; + + if(uri) + length += ui2str(uri+length, data->port_value); + else + length += ui2str(NULL, data->port_value); + } } - hr = validate_components(builder, &data, create_flags); + /* Check if a '/' should be added before the path for hierarchical URIs. */ + if(!data->is_opaque && data->path && *(data->path) != '/') { + if(uri) + uri[length] = '/'; + ++length; + } + + if(data->path) { + if(!data->is_opaque && data->scheme_type == URL_SCHEME_FILE && + flags & RAW_URI_CONVERT_TO_DOS_PATH) { + DWORD len = 0; + + if(uri) + convert_to_dos_path(data->path, data->path_len, uri+length, &len); + else + convert_to_dos_path(data->path, data->path_len, NULL, &len); + + length += len; + } else { + if(uri) + memcpy(uri+length, data->path, data->path_len*sizeof(WCHAR)); + length += data->path_len; + } + } + + if(data->query) { + if(uri) + memcpy(uri+length, data->query, data->query_len*sizeof(WCHAR)); + length += data->query_len; + } + + if(data->fragment) { + if(uri) + memcpy(uri+length, data->fragment, data->fragment_len*sizeof(WCHAR)); + length += data->fragment_len; + } + + if(uri) + TRACE("(%p %p): Generated raw uri=%s len=%d\n", data, uri, debugstr_wn(uri, length), length); + else + TRACE("(%p %p): Computed raw uri len=%d\n", data, uri, length); + + return length; +} + +static HRESULT generate_uri(const UriBuilder *builder, const parse_data *data, Uri *uri, DWORD flags) { + HRESULT hr; + DWORD length = generate_raw_uri(data, NULL, 0); + uri->raw_uri = SysAllocStringLen(NULL, length); + if(!uri->raw_uri) + return E_OUTOFMEMORY; + + generate_raw_uri(data, uri->raw_uri, 0); + + hr = canonicalize_uri(data, uri, flags); if(FAILED(hr)) { - *uri = NULL; + if(hr == E_INVALIDARG) + return INET_E_INVALID_URL; return hr; } - return E_NOTIMPL; + uri->create_flags = flags; + return S_OK; } -#define URI_THIS(iface) DEFINE_THIS(Uri, IUri, iface) +static inline Uri* impl_from_IUri(IUri *iface) +{ + return CONTAINING_RECORD(iface, Uri, IUri_iface); +} + +static inline void destory_uri_obj(Uri *This) +{ + SysFreeString(This->raw_uri); + heap_free(This->canon_uri); + heap_free(This); +} static HRESULT WINAPI Uri_QueryInterface(IUri *iface, REFIID riid, void **ppv) { - Uri *This = URI_THIS(iface); + Uri *This = impl_from_IUri(iface); if(IsEqualGUID(&IID_IUnknown, riid)) { TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv); - *ppv = URI(This); + *ppv = &This->IUri_iface; }else if(IsEqualGUID(&IID_IUri, riid)) { TRACE("(%p)->(IID_IUri %p)\n", This, ppv); - *ppv = URI(This); + *ppv = &This->IUri_iface; + }else if(IsEqualGUID(&IID_IUriBuilderFactory, riid)) { + TRACE("(%p)->(IID_IUriBuilderFactory %p)\n", This, riid); + *ppv = &This->IUriBuilderFactory_iface; }else if(IsEqualGUID(&IID_IUriObj, riid)) { TRACE("(%p)->(IID_IUriObj %p)\n", This, ppv); *ppv = This; @@ -3940,7 +4160,7 @@ static HRESULT WINAPI Uri_QueryInterface(IUri *iface, REFIID riid, void **ppv) static ULONG WINAPI Uri_AddRef(IUri *iface) { - Uri *This = URI_THIS(iface); + Uri *This = impl_from_IUri(iface); LONG ref = InterlockedIncrement(&This->ref); TRACE("(%p) ref=%d\n", This, ref); @@ -3950,23 +4170,20 @@ static ULONG WINAPI Uri_AddRef(IUri *iface) static ULONG WINAPI Uri_Release(IUri *iface) { - Uri *This = URI_THIS(iface); + Uri *This = impl_from_IUri(iface); LONG ref = InterlockedDecrement(&This->ref); TRACE("(%p) ref=%d\n", This, ref); - if(!ref) { - SysFreeString(This->raw_uri); - heap_free(This->canon_uri); - heap_free(This); - } + if(!ref) + destory_uri_obj(This); return ref; } static HRESULT WINAPI Uri_GetPropertyBSTR(IUri *iface, Uri_PROPERTY uriProp, BSTR *pbstrProperty, DWORD dwFlags) { - Uri *This = URI_THIS(iface); + Uri *This = impl_from_IUri(iface); HRESULT hres; TRACE("(%p)->(%d %p %x)\n", This, uriProp, pbstrProperty, dwFlags); @@ -3994,7 +4211,7 @@ static HRESULT WINAPI Uri_GetPropertyBSTR(IUri *iface, Uri_PROPERTY uriProp, BST switch(uriProp) { case Uri_PROPERTY_ABSOLUTE_URI: - if(!This->display_absolute) { + if(This->display_modifiers & URI_DISPLAY_NO_ABSOLUTE_URI) { *pbstrProperty = SysAllocStringLen(NULL, 0); hres = S_FALSE; } else { @@ -4036,7 +4253,12 @@ static HRESULT WINAPI Uri_GetPropertyBSTR(IUri *iface, Uri_PROPERTY uriProp, BST break; case Uri_PROPERTY_AUTHORITY: if(This->authority_start > -1) { - *pbstrProperty = SysAllocStringLen(This->canon_uri+This->authority_start, This->authority_len); + if(This->port_offset > -1 && is_default_port(This->scheme_type, This->port) && + This->display_modifiers & URI_DISPLAY_NO_DEFAULT_PORT_AUTH) + /* Don't include the port in the authority component. */ + *pbstrProperty = SysAllocStringLen(This->canon_uri+This->authority_start, This->port_offset); + else + *pbstrProperty = SysAllocStringLen(This->canon_uri+This->authority_start, This->authority_len); hres = S_OK; } else { *pbstrProperty = SysAllocStringLen(NULL, 0); @@ -4251,7 +4473,7 @@ static HRESULT WINAPI Uri_GetPropertyBSTR(IUri *iface, Uri_PROPERTY uriProp, BST static HRESULT WINAPI Uri_GetPropertyLength(IUri *iface, Uri_PROPERTY uriProp, DWORD *pcchProperty, DWORD dwFlags) { - Uri *This = URI_THIS(iface); + Uri *This = impl_from_IUri(iface); HRESULT hres; TRACE("(%p)->(%d %p %x)\n", This, uriProp, pcchProperty, dwFlags); @@ -4270,7 +4492,7 @@ static HRESULT WINAPI Uri_GetPropertyLength(IUri *iface, Uri_PROPERTY uriProp, D switch(uriProp) { case Uri_PROPERTY_ABSOLUTE_URI: - if(!This->display_absolute) { + if(This->display_modifiers & URI_DISPLAY_NO_ABSOLUTE_URI) { *pcchProperty = 0; hres = S_FALSE; } else { @@ -4292,7 +4514,13 @@ static HRESULT WINAPI Uri_GetPropertyLength(IUri *iface, Uri_PROPERTY uriProp, D break; case Uri_PROPERTY_AUTHORITY: - *pcchProperty = This->authority_len; + if(This->port_offset > -1 && + This->display_modifiers & URI_DISPLAY_NO_DEFAULT_PORT_AUTH && + is_default_port(This->scheme_type, This->port)) + /* Only count up until the port in the authority. */ + *pcchProperty = This->port_offset; + else + *pcchProperty = This->authority_len; hres = (This->authority_start > -1) ? S_OK : S_FALSE; break; case Uri_PROPERTY_DISPLAY_URI: @@ -4379,7 +4607,7 @@ static HRESULT WINAPI Uri_GetPropertyLength(IUri *iface, Uri_PROPERTY uriProp, D static HRESULT WINAPI Uri_GetPropertyDWORD(IUri *iface, Uri_PROPERTY uriProp, DWORD *pcchProperty, DWORD dwFlags) { - Uri *This = URI_THIS(iface); + Uri *This = impl_from_IUri(iface); HRESULT hres; TRACE("(%p)->(%d %p %x)\n", This, uriProp, pcchProperty, dwFlags); @@ -4431,7 +4659,7 @@ static HRESULT WINAPI Uri_GetPropertyDWORD(IUri *iface, Uri_PROPERTY uriProp, DW static HRESULT WINAPI Uri_HasProperty(IUri *iface, Uri_PROPERTY uriProp, BOOL *pfHasProperty) { - Uri *This = URI_THIS(iface); + Uri *This = impl_from_IUri(iface); TRACE("(%p)->(%d %p)\n", This, uriProp, pfHasProperty); if(!pfHasProperty) @@ -4439,7 +4667,7 @@ static HRESULT WINAPI Uri_HasProperty(IUri *iface, Uri_PROPERTY uriProp, BOOL *p switch(uriProp) { case Uri_PROPERTY_ABSOLUTE_URI: - *pfHasProperty = This->display_absolute; + *pfHasProperty = !(This->display_modifiers & URI_DISPLAY_NO_ABSOLUTE_URI); break; case Uri_PROPERTY_AUTHORITY: *pfHasProperty = This->authority_start > -1; @@ -4509,121 +4737,120 @@ static HRESULT WINAPI Uri_HasProperty(IUri *iface, Uri_PROPERTY uriProp, BOOL *p static HRESULT WINAPI Uri_GetAbsoluteUri(IUri *iface, BSTR *pstrAbsoluteUri) { TRACE("(%p)->(%p)\n", iface, pstrAbsoluteUri); - return Uri_GetPropertyBSTR(iface, Uri_PROPERTY_ABSOLUTE_URI, pstrAbsoluteUri, 0); + return IUri_GetPropertyBSTR(iface, Uri_PROPERTY_ABSOLUTE_URI, pstrAbsoluteUri, 0); } static HRESULT WINAPI Uri_GetAuthority(IUri *iface, BSTR *pstrAuthority) { TRACE("(%p)->(%p)\n", iface, pstrAuthority); - return Uri_GetPropertyBSTR(iface, Uri_PROPERTY_AUTHORITY, pstrAuthority, 0); + return IUri_GetPropertyBSTR(iface, Uri_PROPERTY_AUTHORITY, pstrAuthority, 0); } static HRESULT WINAPI Uri_GetDisplayUri(IUri *iface, BSTR *pstrDisplayUri) { TRACE("(%p)->(%p)\n", iface, pstrDisplayUri); - return Uri_GetPropertyBSTR(iface, Uri_PROPERTY_DISPLAY_URI, pstrDisplayUri, 0); + return IUri_GetPropertyBSTR(iface, Uri_PROPERTY_DISPLAY_URI, pstrDisplayUri, 0); } static HRESULT WINAPI Uri_GetDomain(IUri *iface, BSTR *pstrDomain) { TRACE("(%p)->(%p)\n", iface, pstrDomain); - return Uri_GetPropertyBSTR(iface, Uri_PROPERTY_DOMAIN, pstrDomain, 0); + return IUri_GetPropertyBSTR(iface, Uri_PROPERTY_DOMAIN, pstrDomain, 0); } static HRESULT WINAPI Uri_GetExtension(IUri *iface, BSTR *pstrExtension) { TRACE("(%p)->(%p)\n", iface, pstrExtension); - return Uri_GetPropertyBSTR(iface, Uri_PROPERTY_EXTENSION, pstrExtension, 0); + return IUri_GetPropertyBSTR(iface, Uri_PROPERTY_EXTENSION, pstrExtension, 0); } static HRESULT WINAPI Uri_GetFragment(IUri *iface, BSTR *pstrFragment) { TRACE("(%p)->(%p)\n", iface, pstrFragment); - return Uri_GetPropertyBSTR(iface, Uri_PROPERTY_FRAGMENT, pstrFragment, 0); + return IUri_GetPropertyBSTR(iface, Uri_PROPERTY_FRAGMENT, pstrFragment, 0); } static HRESULT WINAPI Uri_GetHost(IUri *iface, BSTR *pstrHost) { TRACE("(%p)->(%p)\n", iface, pstrHost); - return Uri_GetPropertyBSTR(iface, Uri_PROPERTY_HOST, pstrHost, 0); + return IUri_GetPropertyBSTR(iface, Uri_PROPERTY_HOST, pstrHost, 0); } static HRESULT WINAPI Uri_GetPassword(IUri *iface, BSTR *pstrPassword) { TRACE("(%p)->(%p)\n", iface, pstrPassword); - return Uri_GetPropertyBSTR(iface, Uri_PROPERTY_PASSWORD, pstrPassword, 0); + return IUri_GetPropertyBSTR(iface, Uri_PROPERTY_PASSWORD, pstrPassword, 0); } static HRESULT WINAPI Uri_GetPath(IUri *iface, BSTR *pstrPath) { TRACE("(%p)->(%p)\n", iface, pstrPath); - return Uri_GetPropertyBSTR(iface, Uri_PROPERTY_PATH, pstrPath, 0); + return IUri_GetPropertyBSTR(iface, Uri_PROPERTY_PATH, pstrPath, 0); } static HRESULT WINAPI Uri_GetPathAndQuery(IUri *iface, BSTR *pstrPathAndQuery) { TRACE("(%p)->(%p)\n", iface, pstrPathAndQuery); - return Uri_GetPropertyBSTR(iface, Uri_PROPERTY_PATH_AND_QUERY, pstrPathAndQuery, 0); + return IUri_GetPropertyBSTR(iface, Uri_PROPERTY_PATH_AND_QUERY, pstrPathAndQuery, 0); } static HRESULT WINAPI Uri_GetQuery(IUri *iface, BSTR *pstrQuery) { TRACE("(%p)->(%p)\n", iface, pstrQuery); - return Uri_GetPropertyBSTR(iface, Uri_PROPERTY_QUERY, pstrQuery, 0); + return IUri_GetPropertyBSTR(iface, Uri_PROPERTY_QUERY, pstrQuery, 0); } static HRESULT WINAPI Uri_GetRawUri(IUri *iface, BSTR *pstrRawUri) { TRACE("(%p)->(%p)\n", iface, pstrRawUri); - return Uri_GetPropertyBSTR(iface, Uri_PROPERTY_RAW_URI, pstrRawUri, 0); + return IUri_GetPropertyBSTR(iface, Uri_PROPERTY_RAW_URI, pstrRawUri, 0); } static HRESULT WINAPI Uri_GetSchemeName(IUri *iface, BSTR *pstrSchemeName) { TRACE("(%p)->(%p)\n", iface, pstrSchemeName); - return Uri_GetPropertyBSTR(iface, Uri_PROPERTY_SCHEME_NAME, pstrSchemeName, 0); + return IUri_GetPropertyBSTR(iface, Uri_PROPERTY_SCHEME_NAME, pstrSchemeName, 0); } static HRESULT WINAPI Uri_GetUserInfo(IUri *iface, BSTR *pstrUserInfo) { TRACE("(%p)->(%p)\n", iface, pstrUserInfo); - return Uri_GetPropertyBSTR(iface, Uri_PROPERTY_USER_INFO, pstrUserInfo, 0); + return IUri_GetPropertyBSTR(iface, Uri_PROPERTY_USER_INFO, pstrUserInfo, 0); } static HRESULT WINAPI Uri_GetUserName(IUri *iface, BSTR *pstrUserName) { TRACE("(%p)->(%p)\n", iface, pstrUserName); - return Uri_GetPropertyBSTR(iface, Uri_PROPERTY_USER_NAME, pstrUserName, 0); + return IUri_GetPropertyBSTR(iface, Uri_PROPERTY_USER_NAME, pstrUserName, 0); } static HRESULT WINAPI Uri_GetHostType(IUri *iface, DWORD *pdwHostType) { TRACE("(%p)->(%p)\n", iface, pdwHostType); - return Uri_GetPropertyDWORD(iface, Uri_PROPERTY_HOST_TYPE, pdwHostType, 0); + return IUri_GetPropertyDWORD(iface, Uri_PROPERTY_HOST_TYPE, pdwHostType, 0); } static HRESULT WINAPI Uri_GetPort(IUri *iface, DWORD *pdwPort) { TRACE("(%p)->(%p)\n", iface, pdwPort); - return Uri_GetPropertyDWORD(iface, Uri_PROPERTY_PORT, pdwPort, 0); + return IUri_GetPropertyDWORD(iface, Uri_PROPERTY_PORT, pdwPort, 0); } static HRESULT WINAPI Uri_GetScheme(IUri *iface, DWORD *pdwScheme) { - Uri *This = URI_THIS(iface); - TRACE("(%p)->(%p)\n", This, pdwScheme); - return Uri_GetPropertyDWORD(iface, Uri_PROPERTY_SCHEME, pdwScheme, 0); + TRACE("(%p)->(%p)\n", iface, pdwScheme); + return IUri_GetPropertyDWORD(iface, Uri_PROPERTY_SCHEME, pdwScheme, 0); } static HRESULT WINAPI Uri_GetZone(IUri *iface, DWORD *pdwZone) { TRACE("(%p)->(%p)\n", iface, pdwZone); - return Uri_GetPropertyDWORD(iface, Uri_PROPERTY_ZONE,pdwZone, 0); + return IUri_GetPropertyDWORD(iface, Uri_PROPERTY_ZONE,pdwZone, 0); } static HRESULT WINAPI Uri_GetProperties(IUri *iface, DWORD *pdwProperties) { - Uri *This = URI_THIS(iface); + Uri *This = impl_from_IUri(iface); TRACE("(%p)->(%p)\n", This, pdwProperties); if(!pdwProperties) @@ -4632,7 +4859,7 @@ static HRESULT WINAPI Uri_GetProperties(IUri *iface, DWORD *pdwProperties) /* All URIs have these. */ *pdwProperties = Uri_HAS_DISPLAY_URI|Uri_HAS_RAW_URI|Uri_HAS_SCHEME|Uri_HAS_HOST_TYPE; - if(This->display_absolute) + if(!(This->display_modifiers & URI_DISPLAY_NO_ABSOLUTE_URI)) *pdwProperties |= Uri_HAS_ABSOLUTE_URI; if(This->scheme_start > -1) @@ -4671,7 +4898,7 @@ static HRESULT WINAPI Uri_GetProperties(IUri *iface, DWORD *pdwProperties) static HRESULT WINAPI Uri_IsEqual(IUri *iface, IUri *pUri, BOOL *pfEqual) { - Uri *This = URI_THIS(iface); + Uri *This = impl_from_IUri(iface); Uri *other; TRACE("(%p)->(%p %p)\n", This, pUri, pfEqual); @@ -4698,8 +4925,6 @@ static HRESULT WINAPI Uri_IsEqual(IUri *iface, IUri *pUri, BOOL *pfEqual) return S_OK; } -#undef URI_THIS - static const IUriVtbl UriVtbl = { Uri_QueryInterface, Uri_AddRef, @@ -4731,6 +4956,114 @@ static const IUriVtbl UriVtbl = { Uri_IsEqual }; +static inline Uri* impl_from_IUriBuilderFactory(IUriBuilderFactory *iface) +{ + return CONTAINING_RECORD(iface, Uri, IUriBuilderFactory_iface); +} + +static HRESULT WINAPI UriBuilderFactory_QueryInterface(IUriBuilderFactory *iface, REFIID riid, void **ppv) +{ + Uri *This = impl_from_IUriBuilderFactory(iface); + + if(IsEqualGUID(&IID_IUnknown, riid)) { + TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv); + *ppv = &This->IUriBuilderFactory_iface; + }else if(IsEqualGUID(&IID_IUriBuilderFactory, riid)) { + TRACE("(%p)->(IID_IUriBuilderFactory %p)\n", This, ppv); + *ppv = &This->IUriBuilderFactory_iface; + }else if(IsEqualGUID(&IID_IUri, riid)) { + TRACE("(%p)->(IID_IUri %p)\n", This, ppv); + *ppv = &This->IUri_iface; + }else { + TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv); + *ppv = NULL; + return E_NOINTERFACE; + } + + IUnknown_AddRef((IUnknown*)*ppv); + return S_OK; +} + +static ULONG WINAPI UriBuilderFactory_AddRef(IUriBuilderFactory *iface) +{ + Uri *This = impl_from_IUriBuilderFactory(iface); + LONG ref = InterlockedIncrement(&This->ref); + + TRACE("(%p) ref=%d\n", This, ref); + + return ref; +} + +static ULONG WINAPI UriBuilderFactory_Release(IUriBuilderFactory *iface) +{ + Uri *This = impl_from_IUriBuilderFactory(iface); + LONG ref = InterlockedDecrement(&This->ref); + + TRACE("(%p) ref=%d\n", This, ref); + + if(!ref) + destory_uri_obj(This); + + return ref; +} + +static HRESULT WINAPI UriBuilderFactory_CreateInitializedIUriBuilder(IUriBuilderFactory *iface, + DWORD dwFlags, + DWORD_PTR dwReserved, + IUriBuilder **ppIUriBuilder) +{ + Uri *This = impl_from_IUriBuilderFactory(iface); + TRACE("(%p)->(%08x %08x %p)\n", This, dwFlags, (DWORD)dwReserved, ppIUriBuilder); + + if(!ppIUriBuilder) + return E_POINTER; + + if(dwFlags || dwReserved) { + *ppIUriBuilder = NULL; + return E_INVALIDARG; + } + + return CreateIUriBuilder(NULL, 0, 0, ppIUriBuilder); +} + +static HRESULT WINAPI UriBuilderFactory_CreateIUriBuilder(IUriBuilderFactory *iface, + DWORD dwFlags, + DWORD_PTR dwReserved, + IUriBuilder **ppIUriBuilder) +{ + Uri *This = impl_from_IUriBuilderFactory(iface); + TRACE("(%p)->(%08x %08x %p)\n", This, dwFlags, (DWORD)dwReserved, ppIUriBuilder); + + if(!ppIUriBuilder) + return E_POINTER; + + if(dwFlags || dwReserved) { + *ppIUriBuilder = NULL; + return E_INVALIDARG; + } + + return CreateIUriBuilder(&This->IUri_iface, 0, 0, ppIUriBuilder); +} + +static const IUriBuilderFactoryVtbl UriBuilderFactoryVtbl = { + UriBuilderFactory_QueryInterface, + UriBuilderFactory_AddRef, + UriBuilderFactory_Release, + UriBuilderFactory_CreateInitializedIUriBuilder, + UriBuilderFactory_CreateIUriBuilder +}; + +static Uri* create_uri_obj(void) { + Uri *ret = heap_alloc_zero(sizeof(Uri)); + if(ret) { + ret->IUri_iface.lpVtbl = &UriVtbl; + ret->IUriBuilderFactory_iface.lpVtbl = &UriBuilderFactoryVtbl; + ret->ref = 1; + } + + return ret; +} + /*********************************************************************** * CreateUri (urlmon.@) * @@ -4786,12 +5119,11 @@ HRESULT WINAPI CreateUri(LPCWSTR pwzURI, DWORD dwFlags, DWORD_PTR dwReserved, IU if(dwFlags & ~supported_flags) FIXME("Ignoring unsupported flag(s) %x\n", dwFlags & ~supported_flags); - ret = heap_alloc(sizeof(Uri)); - if(!ret) + ret = create_uri_obj(); + if(!ret) { + *ppURI = NULL; return E_OUTOFMEMORY; - - ret->lpIUriVtbl = &UriVtbl; - ret->ref = 1; + } /* Explicitly set the default flags if it doesn't cause a flag conflict. */ apply_default_flags(&dwFlags); @@ -4813,8 +5145,7 @@ HRESULT WINAPI CreateUri(LPCWSTR pwzURI, DWORD dwFlags, DWORD_PTR dwReserved, IU /* Validate and parse the URI into it's components. */ if(!parse_uri(&data, dwFlags)) { /* Encountered an unsupported or invalid URI */ - SysFreeString(ret->raw_uri); - heap_free(ret); + IUri_Release(&ret->IUri_iface); *ppURI = NULL; return E_INVALIDARG; } @@ -4822,15 +5153,14 @@ HRESULT WINAPI CreateUri(LPCWSTR pwzURI, DWORD dwFlags, DWORD_PTR dwReserved, IU /* Canonicalize the URI. */ hr = canonicalize_uri(&data, ret, dwFlags); if(FAILED(hr)) { - SysFreeString(ret->raw_uri); - heap_free(ret); + IUri_Release(&ret->IUri_iface); *ppURI = NULL; return hr; } ret->create_flags = dwFlags; - *ppURI = URI(ret); + *ppURI = &ret->IUri_iface; return S_OK; } @@ -4908,18 +5238,79 @@ HRESULT WINAPI CreateUriWithFragment(LPCWSTR pwzURI, LPCWSTR pwzFragment, DWORD return hres; } -#define URIBUILDER_THIS(iface) DEFINE_THIS(UriBuilder, IUriBuilder, iface) +static HRESULT build_uri(const UriBuilder *builder, IUri **uri, DWORD create_flags, + DWORD use_orig_flags, DWORD encoding_mask) +{ + HRESULT hr; + parse_data data; + Uri *ret; + + if(!uri) + return E_POINTER; + + if(encoding_mask && (!builder->uri || builder->modified_props)) { + *uri = NULL; + return E_NOTIMPL; + } + + /* Decide what flags should be used when creating the Uri. */ + if((use_orig_flags & UriBuilder_USE_ORIGINAL_FLAGS) && builder->uri) + create_flags = builder->uri->create_flags; + else { + if(has_invalid_flag_combination(create_flags)) { + *uri = NULL; + return E_INVALIDARG; + } + + /* Set the default flags if they don't cause a conflict. */ + apply_default_flags(&create_flags); + } + + /* Return the base IUri if no changes have been made and the create_flags match. */ + if(builder->uri && !builder->modified_props && builder->uri->create_flags == create_flags) { + *uri = &builder->uri->IUri_iface; + IUri_AddRef(*uri); + return S_OK; + } + + hr = validate_components(builder, &data, create_flags); + if(FAILED(hr)) { + *uri = NULL; + return hr; + } + + ret = create_uri_obj(); + if(!ret) { + *uri = NULL; + return E_OUTOFMEMORY; + } + + hr = generate_uri(builder, &data, ret, create_flags); + if(FAILED(hr)) { + IUri_Release(&ret->IUri_iface); + *uri = NULL; + return hr; + } + + *uri = &ret->IUri_iface; + return S_OK; +} + +static inline UriBuilder* impl_from_IUriBuilder(IUriBuilder *iface) +{ + return CONTAINING_RECORD(iface, UriBuilder, IUriBuilder_iface); +} static HRESULT WINAPI UriBuilder_QueryInterface(IUriBuilder *iface, REFIID riid, void **ppv) { - UriBuilder *This = URIBUILDER_THIS(iface); + UriBuilder *This = impl_from_IUriBuilder(iface); if(IsEqualGUID(&IID_IUnknown, riid)) { TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv); - *ppv = URIBUILDER(This); + *ppv = &This->IUriBuilder_iface; }else if(IsEqualGUID(&IID_IUriBuilder, riid)) { - TRACE("(%p)->(IID_IUri %p)\n", This, ppv); - *ppv = URIBUILDER(This); + TRACE("(%p)->(IID_IUriBuilder %p)\n", This, ppv); + *ppv = &This->IUriBuilder_iface; }else { TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv); *ppv = NULL; @@ -4932,7 +5323,7 @@ static HRESULT WINAPI UriBuilder_QueryInterface(IUriBuilder *iface, REFIID riid, static ULONG WINAPI UriBuilder_AddRef(IUriBuilder *iface) { - UriBuilder *This = URIBUILDER_THIS(iface); + UriBuilder *This = impl_from_IUriBuilder(iface); LONG ref = InterlockedIncrement(&This->ref); TRACE("(%p) ref=%d\n", This, ref); @@ -4942,13 +5333,13 @@ static ULONG WINAPI UriBuilder_AddRef(IUriBuilder *iface) static ULONG WINAPI UriBuilder_Release(IUriBuilder *iface) { - UriBuilder *This = URIBUILDER_THIS(iface); + UriBuilder *This = impl_from_IUriBuilder(iface); LONG ref = InterlockedDecrement(&This->ref); TRACE("(%p) ref=%d\n", This, ref); if(!ref) { - if(This->uri) IUri_Release(URI(This->uri)); + if(This->uri) IUri_Release(&This->uri->IUri_iface); heap_free(This->fragment); heap_free(This->host); heap_free(This->password); @@ -4967,7 +5358,7 @@ static HRESULT WINAPI UriBuilder_CreateUriSimple(IUriBuilder *iface, DWORD_PTR dwReserved, IUri **ppIUri) { - UriBuilder *This = URIBUILDER_THIS(iface); + UriBuilder *This = impl_from_IUriBuilder(iface); HRESULT hr; TRACE("(%p)->(%d %d %p)\n", This, dwAllowEncodingPropertyMask, (DWORD)dwReserved, ppIUri); @@ -4983,7 +5374,7 @@ static HRESULT WINAPI UriBuilder_CreateUri(IUriBuilder *iface, DWORD_PTR dwReserved, IUri **ppIUri) { - UriBuilder *This = URIBUILDER_THIS(iface); + UriBuilder *This = impl_from_IUriBuilder(iface); HRESULT hr; TRACE("(%p)->(0x%08x %d %d %p)\n", This, dwCreateFlags, dwAllowEncodingPropertyMask, (DWORD)dwReserved, ppIUri); @@ -5004,7 +5395,7 @@ static HRESULT WINAPI UriBuilder_CreateUriWithFlags(IUriBuilder *iface, DWORD_PTR dwReserved, IUri **ppIUri) { - UriBuilder *This = URIBUILDER_THIS(iface); + UriBuilder *This = impl_from_IUriBuilder(iface); HRESULT hr; TRACE("(%p)->(0x%08x 0x%08x %d %d %p)\n", This, dwCreateFlags, dwUriBuilderFlags, dwAllowEncodingPropertyMask, (DWORD)dwReserved, ppIUri); @@ -5018,14 +5409,14 @@ static HRESULT WINAPI UriBuilder_CreateUriWithFlags(IUriBuilder *iface, static HRESULT WINAPI UriBuilder_GetIUri(IUriBuilder *iface, IUri **ppIUri) { - UriBuilder *This = URIBUILDER_THIS(iface); + UriBuilder *This = impl_from_IUriBuilder(iface); TRACE("(%p)->(%p)\n", This, ppIUri); if(!ppIUri) return E_POINTER; if(This->uri) { - IUri *uri = URI(This->uri); + IUri *uri = &This->uri->IUri_iface; IUri_AddRef(uri); *ppIUri = uri; } else @@ -5036,7 +5427,7 @@ static HRESULT WINAPI UriBuilder_GetIUri(IUriBuilder *iface, IUri **ppIUri) static HRESULT WINAPI UriBuilder_SetIUri(IUriBuilder *iface, IUri *pIUri) { - UriBuilder *This = URIBUILDER_THIS(iface); + UriBuilder *This = impl_from_IUriBuilder(iface); TRACE("(%p)->(%p)\n", This, pIUri); if(pIUri) { @@ -5068,7 +5459,7 @@ static HRESULT WINAPI UriBuilder_SetIUri(IUriBuilder *iface, IUri *pIUri) static HRESULT WINAPI UriBuilder_GetFragment(IUriBuilder *iface, DWORD *pcchFragment, LPCWSTR *ppwzFragment) { - UriBuilder *This = URIBUILDER_THIS(iface); + UriBuilder *This = impl_from_IUriBuilder(iface); TRACE("(%p)->(%p %p)\n", This, pcchFragment, ppwzFragment); if(!This->uri || This->uri->fragment_start == -1 || This->modified_props & Uri_HAS_FRAGMENT) @@ -5080,7 +5471,7 @@ static HRESULT WINAPI UriBuilder_GetFragment(IUriBuilder *iface, DWORD *pcchFrag static HRESULT WINAPI UriBuilder_GetHost(IUriBuilder *iface, DWORD *pcchHost, LPCWSTR *ppwzHost) { - UriBuilder *This = URIBUILDER_THIS(iface); + UriBuilder *This = impl_from_IUriBuilder(iface); TRACE("(%p)->(%p %p)\n", This, pcchHost, ppwzHost); if(!This->uri || This->uri->host_start == -1 || This->modified_props & Uri_HAS_HOST) @@ -5098,7 +5489,7 @@ static HRESULT WINAPI UriBuilder_GetHost(IUriBuilder *iface, DWORD *pcchHost, LP static HRESULT WINAPI UriBuilder_GetPassword(IUriBuilder *iface, DWORD *pcchPassword, LPCWSTR *ppwzPassword) { - UriBuilder *This = URIBUILDER_THIS(iface); + UriBuilder *This = impl_from_IUriBuilder(iface); TRACE("(%p)->(%p %p)\n", This, pcchPassword, ppwzPassword); if(!This->uri || This->uri->userinfo_split == -1 || This->modified_props & Uri_HAS_PASSWORD) @@ -5112,7 +5503,7 @@ static HRESULT WINAPI UriBuilder_GetPassword(IUriBuilder *iface, DWORD *pcchPass static HRESULT WINAPI UriBuilder_GetPath(IUriBuilder *iface, DWORD *pcchPath, LPCWSTR *ppwzPath) { - UriBuilder *This = URIBUILDER_THIS(iface); + UriBuilder *This = impl_from_IUriBuilder(iface); TRACE("(%p)->(%p %p)\n", This, pcchPath, ppwzPath); if(!This->uri || This->uri->path_start == -1 || This->modified_props & Uri_HAS_PATH) @@ -5124,7 +5515,7 @@ static HRESULT WINAPI UriBuilder_GetPath(IUriBuilder *iface, DWORD *pcchPath, LP static HRESULT WINAPI UriBuilder_GetPort(IUriBuilder *iface, BOOL *pfHasPort, DWORD *pdwPort) { - UriBuilder *This = URIBUILDER_THIS(iface); + UriBuilder *This = impl_from_IUriBuilder(iface); TRACE("(%p)->(%p %p)\n", This, pfHasPort, pdwPort); if(!pfHasPort) { @@ -5145,7 +5536,7 @@ static HRESULT WINAPI UriBuilder_GetPort(IUriBuilder *iface, BOOL *pfHasPort, DW static HRESULT WINAPI UriBuilder_GetQuery(IUriBuilder *iface, DWORD *pcchQuery, LPCWSTR *ppwzQuery) { - UriBuilder *This = URIBUILDER_THIS(iface); + UriBuilder *This = impl_from_IUriBuilder(iface); TRACE("(%p)->(%p %p)\n", This, pcchQuery, ppwzQuery); if(!This->uri || This->uri->query_start == -1 || This->modified_props & Uri_HAS_QUERY) @@ -5157,7 +5548,7 @@ static HRESULT WINAPI UriBuilder_GetQuery(IUriBuilder *iface, DWORD *pcchQuery, static HRESULT WINAPI UriBuilder_GetSchemeName(IUriBuilder *iface, DWORD *pcchSchemeName, LPCWSTR *ppwzSchemeName) { - UriBuilder *This = URIBUILDER_THIS(iface); + UriBuilder *This = impl_from_IUriBuilder(iface); TRACE("(%p)->(%p %p)\n", This, pcchSchemeName, ppwzSchemeName); if(!This->uri || This->uri->scheme_start == -1 || This->modified_props & Uri_HAS_SCHEME_NAME) @@ -5169,7 +5560,7 @@ static HRESULT WINAPI UriBuilder_GetSchemeName(IUriBuilder *iface, DWORD *pcchSc static HRESULT WINAPI UriBuilder_GetUserName(IUriBuilder *iface, DWORD *pcchUserName, LPCWSTR *ppwzUserName) { - UriBuilder *This = URIBUILDER_THIS(iface); + UriBuilder *This = impl_from_IUriBuilder(iface); TRACE("(%p)->(%p %p)\n", This, pcchUserName, ppwzUserName); if(!This->uri || This->uri->userinfo_start == -1 || This->uri->userinfo_split == 0 || @@ -5191,7 +5582,7 @@ static HRESULT WINAPI UriBuilder_GetUserName(IUriBuilder *iface, DWORD *pcchUser static HRESULT WINAPI UriBuilder_SetFragment(IUriBuilder *iface, LPCWSTR pwzNewValue) { - UriBuilder *This = URIBUILDER_THIS(iface); + UriBuilder *This = impl_from_IUriBuilder(iface); TRACE("(%p)->(%s)\n", This, debugstr_w(pwzNewValue)); return set_builder_component(&This->fragment, &This->fragment_len, pwzNewValue, '#', &This->modified_props, Uri_HAS_FRAGMENT); @@ -5199,7 +5590,7 @@ static HRESULT WINAPI UriBuilder_SetFragment(IUriBuilder *iface, LPCWSTR pwzNewV static HRESULT WINAPI UriBuilder_SetHost(IUriBuilder *iface, LPCWSTR pwzNewValue) { - UriBuilder *This = URIBUILDER_THIS(iface); + UriBuilder *This = impl_from_IUriBuilder(iface); TRACE("(%p)->(%s)\n", This, debugstr_w(pwzNewValue)); /* Host name can't be set to NULL. */ @@ -5212,7 +5603,7 @@ static HRESULT WINAPI UriBuilder_SetHost(IUriBuilder *iface, LPCWSTR pwzNewValue static HRESULT WINAPI UriBuilder_SetPassword(IUriBuilder *iface, LPCWSTR pwzNewValue) { - UriBuilder *This = URIBUILDER_THIS(iface); + UriBuilder *This = impl_from_IUriBuilder(iface); TRACE("(%p)->(%s)\n", This, debugstr_w(pwzNewValue)); return set_builder_component(&This->password, &This->password_len, pwzNewValue, 0, &This->modified_props, Uri_HAS_PASSWORD); @@ -5220,7 +5611,7 @@ static HRESULT WINAPI UriBuilder_SetPassword(IUriBuilder *iface, LPCWSTR pwzNewV static HRESULT WINAPI UriBuilder_SetPath(IUriBuilder *iface, LPCWSTR pwzNewValue) { - UriBuilder *This = URIBUILDER_THIS(iface); + UriBuilder *This = impl_from_IUriBuilder(iface); TRACE("(%p)->(%s)\n", This, debugstr_w(pwzNewValue)); return set_builder_component(&This->path, &This->path_len, pwzNewValue, 0, &This->modified_props, Uri_HAS_PATH); @@ -5228,7 +5619,7 @@ static HRESULT WINAPI UriBuilder_SetPath(IUriBuilder *iface, LPCWSTR pwzNewValue static HRESULT WINAPI UriBuilder_SetPort(IUriBuilder *iface, BOOL fHasPort, DWORD dwNewValue) { - UriBuilder *This = URIBUILDER_THIS(iface); + UriBuilder *This = impl_from_IUriBuilder(iface); TRACE("(%p)->(%d %d)\n", This, fHasPort, dwNewValue); This->has_port = fHasPort; @@ -5239,7 +5630,7 @@ static HRESULT WINAPI UriBuilder_SetPort(IUriBuilder *iface, BOOL fHasPort, DWOR static HRESULT WINAPI UriBuilder_SetQuery(IUriBuilder *iface, LPCWSTR pwzNewValue) { - UriBuilder *This = URIBUILDER_THIS(iface); + UriBuilder *This = impl_from_IUriBuilder(iface); TRACE("(%p)->(%s)\n", This, debugstr_w(pwzNewValue)); return set_builder_component(&This->query, &This->query_len, pwzNewValue, '?', &This->modified_props, Uri_HAS_QUERY); @@ -5247,7 +5638,7 @@ static HRESULT WINAPI UriBuilder_SetQuery(IUriBuilder *iface, LPCWSTR pwzNewValu static HRESULT WINAPI UriBuilder_SetSchemeName(IUriBuilder *iface, LPCWSTR pwzNewValue) { - UriBuilder *This = URIBUILDER_THIS(iface); + UriBuilder *This = impl_from_IUriBuilder(iface); TRACE("(%p)->(%s)\n", This, debugstr_w(pwzNewValue)); /* Only set the scheme name if it's not NULL or empty. */ @@ -5260,7 +5651,7 @@ static HRESULT WINAPI UriBuilder_SetSchemeName(IUriBuilder *iface, LPCWSTR pwzNe static HRESULT WINAPI UriBuilder_SetUserName(IUriBuilder *iface, LPCWSTR pwzNewValue) { - UriBuilder *This = URIBUILDER_THIS(iface); + UriBuilder *This = impl_from_IUriBuilder(iface); TRACE("(%p)->(%s)\n", This, debugstr_w(pwzNewValue)); return set_builder_component(&This->username, &This->username_len, pwzNewValue, 0, &This->modified_props, Uri_HAS_USER_NAME); @@ -5272,7 +5663,7 @@ static HRESULT WINAPI UriBuilder_RemoveProperties(IUriBuilder *iface, DWORD dwPr Uri_HAS_PASSWORD|Uri_HAS_PATH|Uri_HAS_PATH_AND_QUERY|Uri_HAS_QUERY| Uri_HAS_USER_INFO|Uri_HAS_USER_NAME; - UriBuilder *This = URIBUILDER_THIS(iface); + UriBuilder *This = impl_from_IUriBuilder(iface); TRACE("(%p)->(0x%08x)\n", This, dwPropertyMask); if(dwPropertyMask & ~accepted_flags) @@ -5308,7 +5699,7 @@ static HRESULT WINAPI UriBuilder_RemoveProperties(IUriBuilder *iface, DWORD dwPr static HRESULT WINAPI UriBuilder_HasBeenModified(IUriBuilder *iface, BOOL *pfModified) { - UriBuilder *This = URIBUILDER_THIS(iface); + UriBuilder *This = impl_from_IUriBuilder(iface); TRACE("(%p)->(%p)\n", This, pfModified); if(!pfModified) @@ -5318,8 +5709,6 @@ static HRESULT WINAPI UriBuilder_HasBeenModified(IUriBuilder *iface, BOOL *pfMod return S_OK; } -#undef URIBUILDER_THIS - static const IUriBuilderVtbl UriBuilderVtbl = { UriBuilder_QueryInterface, UriBuilder_AddRef, @@ -5365,7 +5754,7 @@ HRESULT WINAPI CreateIUriBuilder(IUri *pIUri, DWORD dwFlags, DWORD_PTR dwReserve if(!ret) return E_OUTOFMEMORY; - ret->lpIUriBuilderVtbl = &UriBuilderVtbl; + ret->IUriBuilder_iface.lpVtbl = &UriBuilderVtbl; ret->ref = 1; if(pIUri) { @@ -5388,6 +5777,915 @@ HRESULT WINAPI CreateIUriBuilder(IUri *pIUri, DWORD dwFlags, DWORD_PTR dwReserve } } - *ppIUriBuilder = URIBUILDER(ret); + *ppIUriBuilder = &ret->IUriBuilder_iface; return S_OK; } + +/* Merges the base path with the relative path and stores the resulting path + * and path len in 'result' and 'result_len'. + */ +static HRESULT merge_paths(parse_data *data, const WCHAR *base, DWORD base_len, const WCHAR *relative, + DWORD relative_len, WCHAR **result, DWORD *result_len, DWORD flags) +{ + const WCHAR *end = NULL; + DWORD base_copy_len = 0; + WCHAR *ptr; + + if(base_len) { + /* Find the characters the will be copied over from + * the base path. + */ + end = str_last_of(base, base+(base_len-1), '/'); + if(!end && data->scheme_type == URL_SCHEME_FILE) + /* Try looking for a '\\'. */ + end = str_last_of(base, base+(base_len-1), '\\'); + } + + if(end) { + base_copy_len = (end+1)-base; + *result = heap_alloc((base_copy_len+relative_len+1)*sizeof(WCHAR)); + } else + *result = heap_alloc((relative_len+1)*sizeof(WCHAR)); + + if(!(*result)) { + *result_len = 0; + return E_OUTOFMEMORY; + } + + ptr = *result; + if(end) { + memcpy(ptr, base, base_copy_len*sizeof(WCHAR)); + ptr += base_copy_len; + } + + memcpy(ptr, relative, relative_len*sizeof(WCHAR)); + ptr += relative_len; + *ptr = '\0'; + + *result_len = (ptr-*result); + return S_OK; +} + +static HRESULT combine_uri(Uri *base, Uri *relative, DWORD flags, IUri **result, DWORD extras) { + Uri *ret; + HRESULT hr; + parse_data data; + DWORD create_flags = 0, len = 0; + + memset(&data, 0, sizeof(parse_data)); + + /* Base case is when the relative Uri has a scheme name, + * if it does, then 'result' will contain the same data + * as the relative Uri. + */ + if(relative->scheme_start > -1) { + data.uri = SysAllocString(relative->raw_uri); + if(!data.uri) { + *result = NULL; + return E_OUTOFMEMORY; + } + + parse_uri(&data, 0); + + ret = create_uri_obj(); + if(!ret) { + *result = NULL; + return E_OUTOFMEMORY; + } + + if(extras & COMBINE_URI_FORCE_FLAG_USE) { + if(flags & URL_DONT_SIMPLIFY) + create_flags |= Uri_CREATE_NO_CANONICALIZE; + if(flags & URL_DONT_UNESCAPE_EXTRA_INFO) + create_flags |= Uri_CREATE_NO_DECODE_EXTRA_INFO; + } + + ret->raw_uri = data.uri; + hr = canonicalize_uri(&data, ret, create_flags); + if(FAILED(hr)) { + IUri_Release(&ret->IUri_iface); + *result = NULL; + return hr; + } + + apply_default_flags(&create_flags); + ret->create_flags = create_flags; + + *result = &ret->IUri_iface; + } else { + WCHAR *path = NULL; + DWORD raw_flags = 0; + + if(base->scheme_start > -1) { + data.scheme = base->canon_uri+base->scheme_start; + data.scheme_len = base->scheme_len; + data.scheme_type = base->scheme_type; + } else { + data.is_relative = TRUE; + data.scheme_type = URL_SCHEME_UNKNOWN; + create_flags |= Uri_CREATE_ALLOW_RELATIVE; + } + + if(base->authority_start > -1) { + if(base->userinfo_start > -1 && base->userinfo_split != 0) { + data.username = base->canon_uri+base->userinfo_start; + data.username_len = (base->userinfo_split > -1) ? base->userinfo_split : base->userinfo_len; + } + + if(base->userinfo_split > -1) { + data.password = base->canon_uri+base->userinfo_start+base->userinfo_split+1; + data.password_len = base->userinfo_len-base->userinfo_split-1; + } + + if(base->host_start > -1) { + data.host = base->canon_uri+base->host_start; + data.host_len = base->host_len; + data.host_type = base->host_type; + } + + if(base->has_port) { + data.has_port = TRUE; + data.port_value = base->port; + } + } else if(base->scheme_type != URL_SCHEME_FILE) + data.is_opaque = TRUE; + + if(relative->path_start == -1 || !relative->path_len) { + if(base->path_start > -1) { + data.path = base->canon_uri+base->path_start; + data.path_len = base->path_len; + } else if((base->path_start == -1 || !base->path_len) && !data.is_opaque) { + /* Just set the path as a '/' if the base didn't have + * one and if it's an hierarchical URI. + */ + static const WCHAR slashW[] = {'/',0}; + data.path = slashW; + data.path_len = 1; + } + + if(relative->query_start > -1) { + data.query = relative->canon_uri+relative->query_start; + data.query_len = relative->query_len; + } else if(base->query_start > -1) { + data.query = base->canon_uri+base->query_start; + data.query_len = base->query_len; + } + } else { + const WCHAR *ptr, **pptr; + DWORD path_offset = 0, path_len = 0; + + /* There's two possibilities on what will happen to the path component + * of the result IUri. First, if the relative path begins with a '/' + * then the resulting path will just be the relative path. Second, if + * relative path doesn't begin with a '/' then the base path and relative + * path are merged together. + */ + if(relative->path_len && *(relative->canon_uri+relative->path_start) == '/') { + WCHAR *tmp = NULL; + BOOL copy_drive_path = FALSE; + + /* If the relative IUri's path starts with a '/', then we + * don't use the base IUri's path. Unless the base IUri + * is a file URI, in which case it uses the drive path of + * the base IUri (if it has any) in the new path. + */ + if(base->scheme_type == URL_SCHEME_FILE) { + if(base->path_len > 3 && *(base->canon_uri+base->path_start) == '/' && + is_drive_path(base->canon_uri+base->path_start+1)) { + path_len += 3; + copy_drive_path = TRUE; + } + } + + path_len += relative->path_len; + + path = heap_alloc((path_len+1)*sizeof(WCHAR)); + if(!path) { + *result = NULL; + return E_OUTOFMEMORY; + } + + tmp = path; + + /* Copy the base paths, drive path over. */ + if(copy_drive_path) { + memcpy(tmp, base->canon_uri+base->path_start, 3*sizeof(WCHAR)); + tmp += 3; + } + + memcpy(tmp, relative->canon_uri+relative->path_start, relative->path_len*sizeof(WCHAR)); + path[path_len] = '\0'; + } else { + /* Merge the base path with the relative path. */ + hr = merge_paths(&data, base->canon_uri+base->path_start, base->path_len, + relative->canon_uri+relative->path_start, relative->path_len, + &path, &path_len, flags); + if(FAILED(hr)) { + *result = NULL; + return hr; + } + + /* If the resulting IUri is a file URI, the drive path isn't + * reduced out when the dot segments are removed. + */ + if(path_len >= 3 && data.scheme_type == URL_SCHEME_FILE && !data.host) { + if(*path == '/' && is_drive_path(path+1)) + path_offset = 2; + else if(is_drive_path(path)) + path_offset = 1; + } + } + + /* Check if the dot segments need to be removed from the path. */ + if(!(flags & URL_DONT_SIMPLIFY) && !data.is_opaque) { + DWORD offset = (path_offset > 0) ? path_offset+1 : 0; + DWORD new_len = remove_dot_segments(path+offset,path_len-offset); + + if(new_len != path_len) { + WCHAR *tmp = heap_realloc(path, (path_offset+new_len+1)*sizeof(WCHAR)); + if(!tmp) { + heap_free(path); + *result = NULL; + return E_OUTOFMEMORY; + } + + tmp[new_len+offset] = '\0'; + path = tmp; + path_len = new_len+offset; + } + } + + /* Make sure the path component is valid. */ + ptr = path; + pptr = &ptr; + if((data.is_opaque && !parse_path_opaque(pptr, &data, 0)) || + (!data.is_opaque && !parse_path_hierarchical(pptr, &data, 0))) { + heap_free(path); + *result = NULL; + return E_INVALIDARG; + } + } + + if(relative->fragment_start > -1) { + data.fragment = relative->canon_uri+relative->fragment_start; + data.fragment_len = relative->fragment_len; + } + + if(flags & URL_DONT_SIMPLIFY) + raw_flags |= RAW_URI_FORCE_PORT_DISP; + if(flags & URL_FILE_USE_PATHURL) + raw_flags |= RAW_URI_CONVERT_TO_DOS_PATH; + + len = generate_raw_uri(&data, data.uri, raw_flags); + data.uri = SysAllocStringLen(NULL, len); + if(!data.uri) { + heap_free(path); + *result = NULL; + return E_OUTOFMEMORY; + } + + generate_raw_uri(&data, data.uri, raw_flags); + + ret = create_uri_obj(); + if(!ret) { + SysFreeString(data.uri); + heap_free(path); + *result = NULL; + return E_OUTOFMEMORY; + } + + if(flags & URL_DONT_SIMPLIFY) + create_flags |= Uri_CREATE_NO_CANONICALIZE; + if(flags & URL_FILE_USE_PATHURL) + create_flags |= Uri_CREATE_FILE_USE_DOS_PATH; + + ret->raw_uri = data.uri; + hr = canonicalize_uri(&data, ret, create_flags); + if(FAILED(hr)) { + IUri_Release(&ret->IUri_iface); + *result = NULL; + return hr; + } + + if(flags & URL_DONT_SIMPLIFY) + ret->display_modifiers |= URI_DISPLAY_NO_DEFAULT_PORT_AUTH; + + apply_default_flags(&create_flags); + ret->create_flags = create_flags; + *result = &ret->IUri_iface; + + heap_free(path); + } + + return S_OK; +} + +/*********************************************************************** + * CoInternetCombineIUri (urlmon.@) + */ +HRESULT WINAPI CoInternetCombineIUri(IUri *pBaseUri, IUri *pRelativeUri, DWORD dwCombineFlags, + IUri **ppCombinedUri, DWORD_PTR dwReserved) +{ + HRESULT hr; + IInternetProtocolInfo *info; + Uri *relative, *base; + TRACE("(%p %p %x %p %x)\n", pBaseUri, pRelativeUri, dwCombineFlags, ppCombinedUri, (DWORD)dwReserved); + + if(!ppCombinedUri) + return E_INVALIDARG; + + if(!pBaseUri || !pRelativeUri) { + *ppCombinedUri = NULL; + return E_INVALIDARG; + } + + relative = get_uri_obj(pRelativeUri); + base = get_uri_obj(pBaseUri); + if(!relative || !base) { + *ppCombinedUri = NULL; + FIXME("(%p %p %x %p %x) Unknown IUri types not supported yet.\n", + pBaseUri, pRelativeUri, dwCombineFlags, ppCombinedUri, (DWORD)dwReserved); + return E_NOTIMPL; + } + + info = get_protocol_info(base->canon_uri); + if(info) { + WCHAR result[INTERNET_MAX_URL_LENGTH+1]; + DWORD result_len = 0; + + hr = IInternetProtocolInfo_CombineUrl(info, base->canon_uri, relative->canon_uri, dwCombineFlags, + result, INTERNET_MAX_URL_LENGTH+1, &result_len, 0); + IInternetProtocolInfo_Release(info); + if(SUCCEEDED(hr)) { + hr = CreateUri(result, Uri_CREATE_ALLOW_RELATIVE, 0, ppCombinedUri); + if(SUCCEEDED(hr)) + return hr; + } + } + + return combine_uri(base, relative, dwCombineFlags, ppCombinedUri, 0); +} + +/*********************************************************************** + * CoInternetCombineUrlEx (urlmon.@) + */ +HRESULT WINAPI CoInternetCombineUrlEx(IUri *pBaseUri, LPCWSTR pwzRelativeUrl, DWORD dwCombineFlags, + IUri **ppCombinedUri, DWORD_PTR dwReserved) +{ + IUri *relative; + Uri *base; + HRESULT hr; + IInternetProtocolInfo *info; + + TRACE("(%p %s %x %p %x) stub\n", pBaseUri, debugstr_w(pwzRelativeUrl), dwCombineFlags, + ppCombinedUri, (DWORD)dwReserved); + + if(!ppCombinedUri) + return E_POINTER; + + if(!pwzRelativeUrl) { + *ppCombinedUri = NULL; + return E_UNEXPECTED; + } + + if(!pBaseUri) { + *ppCombinedUri = NULL; + return E_INVALIDARG; + } + + base = get_uri_obj(pBaseUri); + if(!base) { + *ppCombinedUri = NULL; + FIXME("(%p %s %x %p %x) Unknown IUri's not supported yet.\n", pBaseUri, debugstr_w(pwzRelativeUrl), + dwCombineFlags, ppCombinedUri, (DWORD)dwReserved); + return E_NOTIMPL; + } + + info = get_protocol_info(base->canon_uri); + if(info) { + WCHAR result[INTERNET_MAX_URL_LENGTH+1]; + DWORD result_len = 0; + + hr = IInternetProtocolInfo_CombineUrl(info, base->canon_uri, pwzRelativeUrl, dwCombineFlags, + result, INTERNET_MAX_URL_LENGTH+1, &result_len, 0); + IInternetProtocolInfo_Release(info); + if(SUCCEEDED(hr)) { + hr = CreateUri(result, Uri_CREATE_ALLOW_RELATIVE, 0, ppCombinedUri); + if(SUCCEEDED(hr)) + return hr; + } + } + + hr = CreateUri(pwzRelativeUrl, Uri_CREATE_ALLOW_RELATIVE, 0, &relative); + if(FAILED(hr)) { + *ppCombinedUri = NULL; + return hr; + } + + hr = combine_uri(base, get_uri_obj(relative), dwCombineFlags, ppCombinedUri, COMBINE_URI_FORCE_FLAG_USE); + + IUri_Release(relative); + return hr; +} + +static HRESULT parse_canonicalize(const Uri *uri, DWORD flags, LPWSTR output, + DWORD output_len, DWORD *result_len) +{ + const WCHAR *ptr = NULL; + WCHAR *path = NULL; + const WCHAR **pptr; + WCHAR buffer[INTERNET_MAX_URL_LENGTH+1]; + DWORD len = 0; + BOOL reduce_path; + + /* URL_UNESCAPE only has effect if none of the URL_ESCAPE flags are set. */ + const BOOL allow_unescape = !(flags & URL_ESCAPE_UNSAFE) && + !(flags & URL_ESCAPE_SPACES_ONLY) && + !(flags & URL_ESCAPE_PERCENT); + + + /* Check if the dot segments need to be removed from the + * path component. + */ + if(uri->scheme_start > -1 && uri->path_start > -1) { + ptr = uri->canon_uri+uri->scheme_start+uri->scheme_len+1; + pptr = &ptr; + } + reduce_path = !(flags & URL_NO_META) && + !(flags & URL_DONT_SIMPLIFY) && + ptr && check_hierarchical(pptr); + + for(ptr = uri->canon_uri; ptr < uri->canon_uri+uri->canon_len; ++ptr) { + BOOL do_default_action = TRUE; + + /* Keep track of the path if we need to remove dot segments from + * it later. + */ + if(reduce_path && !path && ptr == uri->canon_uri+uri->path_start) + path = buffer+len; + + /* Check if it's time to reduce the path. */ + if(reduce_path && ptr == uri->canon_uri+uri->path_start+uri->path_len) { + DWORD current_path_len = (buffer+len) - path; + DWORD new_path_len = remove_dot_segments(path, current_path_len); + + /* Update the current length. */ + len -= (current_path_len-new_path_len); + reduce_path = FALSE; + } + + if(*ptr == '%') { + const WCHAR decoded = decode_pct_val(ptr); + if(decoded) { + if(allow_unescape && (flags & URL_UNESCAPE)) { + buffer[len++] = decoded; + ptr += 2; + do_default_action = FALSE; + } + } + + /* See if %'s needed to encoded. */ + if(do_default_action && (flags & URL_ESCAPE_PERCENT)) { + pct_encode_val(*ptr, buffer+len); + len += 3; + do_default_action = FALSE; + } + } else if(*ptr == ' ') { + if((flags & URL_ESCAPE_SPACES_ONLY) && + !(flags & URL_ESCAPE_UNSAFE)) { + pct_encode_val(*ptr, buffer+len); + len += 3; + do_default_action = FALSE; + } + } else if(!is_reserved(*ptr) && !is_unreserved(*ptr)) { + if(flags & URL_ESCAPE_UNSAFE) { + pct_encode_val(*ptr, buffer+len); + len += 3; + do_default_action = FALSE; + } + } + + if(do_default_action) + buffer[len++] = *ptr; + } + + /* Sometimes the path is the very last component of the IUri, so + * see if the dot segments need to be reduced now. + */ + if(reduce_path && path) { + DWORD current_path_len = (buffer+len) - path; + DWORD new_path_len = remove_dot_segments(path, current_path_len); + + /* Update the current length. */ + len -= (current_path_len-new_path_len); + } + + buffer[len++] = 0; + + /* The null terminator isn't included the length. */ + *result_len = len-1; + if(len > output_len) + return STRSAFE_E_INSUFFICIENT_BUFFER; + else + memcpy(output, buffer, len*sizeof(WCHAR)); + + return S_OK; +} + +static HRESULT parse_friendly(IUri *uri, LPWSTR output, DWORD output_len, + DWORD *result_len) +{ + HRESULT hr; + DWORD display_len; + BSTR display; + + hr = IUri_GetPropertyLength(uri, Uri_PROPERTY_DISPLAY_URI, &display_len, 0); + if(FAILED(hr)) { + *result_len = 0; + return hr; + } + + *result_len = display_len; + if(display_len+1 > output_len) + return STRSAFE_E_INSUFFICIENT_BUFFER; + + hr = IUri_GetDisplayUri(uri, &display); + if(FAILED(hr)) { + *result_len = 0; + return hr; + } + + memcpy(output, display, (display_len+1)*sizeof(WCHAR)); + SysFreeString(display); + return S_OK; +} + +static HRESULT parse_rootdocument(const Uri *uri, LPWSTR output, DWORD output_len, + DWORD *result_len) +{ + static const WCHAR colon_slashesW[] = {':','/','/'}; + + WCHAR *ptr; + DWORD len = 0; + + /* Windows only returns the root document if the URI has an authority + * and it's not an unknown scheme type or a file scheme type. + */ + if(uri->authority_start == -1 || + uri->scheme_type == URL_SCHEME_UNKNOWN || + uri->scheme_type == URL_SCHEME_FILE) { + *result_len = 0; + if(!output_len) + return STRSAFE_E_INSUFFICIENT_BUFFER; + + output[0] = 0; + return S_OK; + } + + len = uri->scheme_len+uri->authority_len; + /* For the "://" and '/' which will be added. */ + len += 4; + + if(len+1 > output_len) { + *result_len = len; + return STRSAFE_E_INSUFFICIENT_BUFFER; + } + + ptr = output; + memcpy(ptr, uri->canon_uri+uri->scheme_start, uri->scheme_len*sizeof(WCHAR)); + + /* Add the "://". */ + ptr += uri->scheme_len; + memcpy(ptr, colon_slashesW, sizeof(colon_slashesW)); + + /* Add the authority. */ + ptr += sizeof(colon_slashesW)/sizeof(WCHAR); + memcpy(ptr, uri->canon_uri+uri->authority_start, uri->authority_len*sizeof(WCHAR)); + + /* Add the '/' after the authority. */ + ptr += uri->authority_len; + *ptr = '/'; + ptr[1] = 0; + + *result_len = len; + return S_OK; +} + +static HRESULT parse_document(const Uri *uri, LPWSTR output, DWORD output_len, + DWORD *result_len) +{ + DWORD len = 0; + + /* It has to be a known scheme type, but, it can't be a file + * scheme. It also has to hierarchical. + */ + if(uri->scheme_type == URL_SCHEME_UNKNOWN || + uri->scheme_type == URL_SCHEME_FILE || + uri->authority_start == -1) { + *result_len = 0; + if(output_len < 1) + return STRSAFE_E_INSUFFICIENT_BUFFER; + + output[0] = 0; + return S_OK; + } + + if(uri->fragment_start > -1) + len = uri->fragment_start; + else + len = uri->canon_len; + + *result_len = len; + if(len+1 > output_len) + return STRSAFE_E_INSUFFICIENT_BUFFER; + + memcpy(output, uri->canon_uri, len*sizeof(WCHAR)); + output[len] = 0; + return S_OK; +} + +static HRESULT parse_path_from_url(const Uri *uri, LPWSTR output, DWORD output_len, + DWORD *result_len) +{ + const WCHAR *path_ptr; + WCHAR buffer[INTERNET_MAX_URL_LENGTH+1]; + WCHAR *ptr; + + if(uri->scheme_type != URL_SCHEME_FILE) { + *result_len = 0; + if(output_len > 0) + output[0] = 0; + return E_INVALIDARG; + } + + ptr = buffer; + if(uri->host_start > -1) { + static const WCHAR slash_slashW[] = {'\\','\\'}; + + memcpy(ptr, slash_slashW, sizeof(slash_slashW)); + ptr += sizeof(slash_slashW)/sizeof(WCHAR); + memcpy(ptr, uri->canon_uri+uri->host_start, uri->host_len*sizeof(WCHAR)); + ptr += uri->host_len; + } + + path_ptr = uri->canon_uri+uri->path_start; + if(uri->path_len > 3 && *path_ptr == '/' && is_drive_path(path_ptr+1)) + /* Skip past the '/' in front of the drive path. */ + ++path_ptr; + + for(; path_ptr < uri->canon_uri+uri->path_start+uri->path_len; ++path_ptr, ++ptr) { + BOOL do_default_action = TRUE; + + if(*path_ptr == '%') { + const WCHAR decoded = decode_pct_val(path_ptr); + if(decoded) { + *ptr = decoded; + path_ptr += 2; + do_default_action = FALSE; + } + } else if(*path_ptr == '/') { + *ptr = '\\'; + do_default_action = FALSE; + } + + if(do_default_action) + *ptr = *path_ptr; + } + + *ptr = 0; + + *result_len = ptr-buffer; + if(*result_len+1 > output_len) + return STRSAFE_E_INSUFFICIENT_BUFFER; + + memcpy(output, buffer, (*result_len+1)*sizeof(WCHAR)); + return S_OK; +} + +static HRESULT parse_url_from_path(IUri *uri, LPWSTR output, DWORD output_len, + DWORD *result_len) +{ + HRESULT hr; + BSTR received; + DWORD len = 0; + + hr = IUri_GetPropertyLength(uri, Uri_PROPERTY_ABSOLUTE_URI, &len, 0); + if(FAILED(hr)) { + *result_len = 0; + return hr; + } + + *result_len = len; + if(len+1 > output_len) + return STRSAFE_E_INSUFFICIENT_BUFFER; + + hr = IUri_GetAbsoluteUri(uri, &received); + if(FAILED(hr)) { + *result_len = 0; + return hr; + } + + memcpy(output, received, (len+1)*sizeof(WCHAR)); + SysFreeString(received); + + return S_OK; +} + +static HRESULT parse_schema(IUri *uri, LPWSTR output, DWORD output_len, + DWORD *result_len) +{ + HRESULT hr; + DWORD len; + BSTR received; + + hr = IUri_GetPropertyLength(uri, Uri_PROPERTY_SCHEME_NAME, &len, 0); + if(FAILED(hr)) { + *result_len = 0; + return hr; + } + + *result_len = len; + if(len+1 > output_len) + return STRSAFE_E_INSUFFICIENT_BUFFER; + + hr = IUri_GetSchemeName(uri, &received); + if(FAILED(hr)) { + *result_len = 0; + return hr; + } + + memcpy(output, received, (len+1)*sizeof(WCHAR)); + SysFreeString(received); + + return S_OK; +} + +static HRESULT parse_site(IUri *uri, LPWSTR output, DWORD output_len, DWORD *result_len) +{ + HRESULT hr; + DWORD len; + BSTR received; + + hr = IUri_GetPropertyLength(uri, Uri_PROPERTY_HOST, &len, 0); + if(FAILED(hr)) { + *result_len = 0; + return hr; + } + + *result_len = len; + if(len+1 > output_len) + return STRSAFE_E_INSUFFICIENT_BUFFER; + + hr = IUri_GetHost(uri, &received); + if(FAILED(hr)) { + *result_len = 0; + return hr; + } + + memcpy(output, received, (len+1)*sizeof(WCHAR)); + SysFreeString(received); + + return S_OK; +} + +static HRESULT parse_domain(IUri *uri, LPWSTR output, DWORD output_len, DWORD *result_len) +{ + HRESULT hr; + DWORD len; + BSTR received; + + hr = IUri_GetPropertyLength(uri, Uri_PROPERTY_DOMAIN, &len, 0); + if(FAILED(hr)) { + *result_len = 0; + return hr; + } + + *result_len = len; + if(len+1 > output_len) + return STRSAFE_E_INSUFFICIENT_BUFFER; + + hr = IUri_GetDomain(uri, &received); + if(FAILED(hr)) { + *result_len = 0; + return hr; + } + + memcpy(output, received, (len+1)*sizeof(WCHAR)); + SysFreeString(received); + + return S_OK; +} + +static HRESULT parse_anchor(IUri *uri, LPWSTR output, DWORD output_len, DWORD *result_len) +{ + HRESULT hr; + DWORD len; + BSTR received; + + hr = IUri_GetPropertyLength(uri, Uri_PROPERTY_FRAGMENT, &len, 0); + if(FAILED(hr)) { + *result_len = 0; + return hr; + } + + *result_len = len; + if(len+1 > output_len) + return STRSAFE_E_INSUFFICIENT_BUFFER; + + hr = IUri_GetFragment(uri, &received); + if(FAILED(hr)) { + *result_len = 0; + return hr; + } + + memcpy(output, received, (len+1)*sizeof(WCHAR)); + SysFreeString(received); + + return S_OK; +} + +/*********************************************************************** + * CoInternetParseIUri (urlmon.@) + */ +HRESULT WINAPI CoInternetParseIUri(IUri *pIUri, PARSEACTION ParseAction, DWORD dwFlags, + LPWSTR pwzResult, DWORD cchResult, DWORD *pcchResult, + DWORD_PTR dwReserved) +{ + HRESULT hr; + Uri *uri; + IInternetProtocolInfo *info; + + TRACE("(%p %d %x %p %d %p %x)\n", pIUri, ParseAction, dwFlags, pwzResult, + cchResult, pcchResult, (DWORD)dwReserved); + + if(!pcchResult) + return E_POINTER; + + if(!pwzResult || !pIUri) { + *pcchResult = 0; + return E_INVALIDARG; + } + + if(!(uri = get_uri_obj(pIUri))) { + *pcchResult = 0; + FIXME("(%p %d %x %p %d %p %x) Unknown IUri's not supported for this action.\n", + pIUri, ParseAction, dwFlags, pwzResult, cchResult, pcchResult, (DWORD)dwReserved); + return E_NOTIMPL; + } + + info = get_protocol_info(uri->canon_uri); + if(info) { + hr = IInternetProtocolInfo_ParseUrl(info, uri->canon_uri, ParseAction, dwFlags, + pwzResult, cchResult, pcchResult, 0); + IInternetProtocolInfo_Release(info); + if(SUCCEEDED(hr)) return hr; + } + + switch(ParseAction) { + case PARSE_CANONICALIZE: + hr = parse_canonicalize(uri, dwFlags, pwzResult, cchResult, pcchResult); + break; + case PARSE_FRIENDLY: + hr = parse_friendly(pIUri, pwzResult, cchResult, pcchResult); + break; + case PARSE_ROOTDOCUMENT: + hr = parse_rootdocument(uri, pwzResult, cchResult, pcchResult); + break; + case PARSE_DOCUMENT: + hr = parse_document(uri, pwzResult, cchResult, pcchResult); + break; + case PARSE_PATH_FROM_URL: + hr = parse_path_from_url(uri, pwzResult, cchResult, pcchResult); + break; + case PARSE_URL_FROM_PATH: + hr = parse_url_from_path(pIUri, pwzResult, cchResult, pcchResult); + break; + case PARSE_SCHEMA: + hr = parse_schema(pIUri, pwzResult, cchResult, pcchResult); + break; + case PARSE_SITE: + hr = parse_site(pIUri, pwzResult, cchResult, pcchResult); + break; + case PARSE_DOMAIN: + hr = parse_domain(pIUri, pwzResult, cchResult, pcchResult); + break; + case PARSE_LOCATION: + case PARSE_ANCHOR: + hr = parse_anchor(pIUri, pwzResult, cchResult, pcchResult); + break; + case PARSE_SECURITY_URL: + case PARSE_MIME: + case PARSE_SERVER: + case PARSE_SECURITY_DOMAIN: + *pcchResult = 0; + hr = E_FAIL; + break; + default: + *pcchResult = 0; + hr = E_NOTIMPL; + FIXME("(%p %d %x %p %d %p %x) Partial stub.\n", pIUri, ParseAction, dwFlags, + pwzResult, cchResult, pcchResult, (DWORD)dwReserved); + } + + return hr; +} diff --git a/reactos/dll/win32/urlmon/urlmon.spec b/reactos/dll/win32/urlmon/urlmon.spec index 61093850d24..9d3de3a61dc 100644 --- a/reactos/dll/win32/urlmon/urlmon.spec +++ b/reactos/dll/win32/urlmon/urlmon.spec @@ -11,7 +11,9 @@ @ stdcall CoGetClassObjectFromURL(ptr wstr long long wstr ptr long ptr ptr ptr) @ stub CoInstall @ stdcall CoInternetCombineUrl(wstr wstr long wstr long ptr long) +@ stdcall CoInternetCombineUrlEx(ptr wstr long ptr long) @ stdcall CoInternetCompareUrl(wstr wstr long) +@ stdcall CoInternetCombineIUri(ptr ptr long ptr long) @ stdcall CoInternetCreateSecurityManager(ptr ptr long) @ stdcall CoInternetCreateZoneManager(ptr ptr long) @ stub CoInternetGetProtocolFlags @@ -19,6 +21,7 @@ @ stdcall CoInternetGetSession(long ptr long) @ stdcall CoInternetIsFeatureEnabled(long long) @ stdcall CoInternetParseUrl(wstr long long wstr long ptr long) +@ stdcall CoInternetParseIUri(ptr long long wstr long ptr long) @ stdcall CoInternetQueryInfo(ptr long long ptr long ptr long) @ stdcall CoInternetSetFeatureEnabled(long long long) @ stub CompareSecurityIds diff --git a/reactos/dll/win32/urlmon/urlmon_main.c b/reactos/dll/win32/urlmon/urlmon_main.c index edaad42289f..6ecd1dec954 100644 --- a/reactos/dll/win32/urlmon/urlmon_main.c +++ b/reactos/dll/win32/urlmon/urlmon_main.c @@ -636,6 +636,127 @@ static BOOL application_octet_stream_filter(const BYTE *b, DWORD size) return TRUE; } +static HRESULT find_mime_from_buffer(const BYTE *buf, DWORD size, const WCHAR *proposed_mime, WCHAR **ret_mime) +{ + LPCWSTR ret = NULL; + DWORD len, i; + + static const WCHAR text_htmlW[] = {'t','e','x','t','/','h','t','m','l',0}; + static const WCHAR text_richtextW[] = {'t','e','x','t','/','r','i','c','h','t','e','x','t',0}; + static const WCHAR audio_basicW[] = {'a','u','d','i','o','/','b','a','s','i','c',0}; + static const WCHAR audio_wavW[] = {'a','u','d','i','o','/','w','a','v',0}; + static const WCHAR image_gifW[] = {'i','m','a','g','e','/','g','i','f',0}; + static const WCHAR image_pjpegW[] = {'i','m','a','g','e','/','p','j','p','e','g',0}; + static const WCHAR image_tiffW[] = {'i','m','a','g','e','/','t','i','f','f',0}; + static const WCHAR image_xpngW[] = {'i','m','a','g','e','/','x','-','p','n','g',0}; + static const WCHAR image_bmpW[] = {'i','m','a','g','e','/','b','m','p',0}; + static const WCHAR video_aviW[] = {'v','i','d','e','o','/','a','v','i',0}; + static const WCHAR video_mpegW[] = {'v','i','d','e','o','/','m','p','e','g',0}; + static const WCHAR app_postscriptW[] = + {'a','p','p','l','i','c','a','t','i','o','n','/','p','o','s','t','s','c','r','i','p','t',0}; + static const WCHAR app_pdfW[] = {'a','p','p','l','i','c','a','t','i','o','n','/','p','d','f',0}; + static const WCHAR app_xzipW[] = {'a','p','p','l','i','c','a','t','i','o','n','/', + 'x','-','z','i','p','-','c','o','m','p','r','e','s','s','e','d',0}; + static const WCHAR app_xgzipW[] = {'a','p','p','l','i','c','a','t','i','o','n','/', + 'x','-','g','z','i','p','-','c','o','m','p','r','e','s','s','e','d',0}; + static const WCHAR app_javaW[] = {'a','p','p','l','i','c','a','t','i','o','n','/', + 'j','a','v','a',0}; + static const WCHAR app_xmsdownloadW[] = {'a','p','p','l','i','c','a','t','i','o','n','/', + 'x','-','m','s','d','o','w','n','l','o','a','d',0}; + static const WCHAR text_plainW[] = {'t','e','x','t','/','p','l','a','i','n','\0'}; + static const WCHAR app_octetstreamW[] = {'a','p','p','l','i','c','a','t','i','o','n','/', + 'o','c','t','e','t','-','s','t','r','e','a','m','\0'}; + + static const struct { + LPCWSTR mime; + BOOL (*filter)(const BYTE *,DWORD); + } mime_filters[] = { + {text_htmlW, text_html_filter}, + {text_richtextW, text_richtext_filter}, + /* {audio_xaiffW, audio_xaiff_filter}, */ + {audio_basicW, audio_basic_filter}, + {audio_wavW, audio_wav_filter}, + {image_gifW, image_gif_filter}, + {image_pjpegW, image_pjpeg_filter}, + {image_tiffW, image_tiff_filter}, + {image_xpngW, image_xpng_filter}, + /* {image_xbitmapW, image_xbitmap_filter}, */ + {image_bmpW, image_bmp_filter}, + /* {image_xjgW, image_xjg_filter}, */ + /* {image_xemfW, image_xemf_filter}, */ + /* {image_xwmfW, image_xwmf_filter}, */ + {video_aviW, video_avi_filter}, + {video_mpegW, video_mpeg_filter}, + {app_postscriptW, application_postscript_filter}, + /* {app_base64W, application_base64_filter}, */ + /* {app_macbinhex40W, application_macbinhex40_filter}, */ + {app_pdfW, application_pdf_filter}, + /* {app_zcompressedW, application_xcompressed_filter}, */ + {app_xzipW, application_xzip_filter}, + {app_xgzipW, application_xgzip_filter}, + {app_javaW, application_java_filter}, + {app_xmsdownloadW, application_xmsdownload}, + {text_plainW, text_plain_filter}, + {app_octetstreamW, application_octet_stream_filter} + }; + + if(!buf || !size) { + if(!proposed_mime) + return E_FAIL; + + len = strlenW(proposed_mime)+1; + *ret_mime = CoTaskMemAlloc(len*sizeof(WCHAR)); + if(!*ret_mime) + return E_OUTOFMEMORY; + + memcpy(*ret_mime, proposed_mime, len*sizeof(WCHAR)); + return S_OK; + } + + if(proposed_mime && strcmpW(proposed_mime, app_octetstreamW)) { + for(i=0; i < sizeof(mime_filters)/sizeof(*mime_filters); i++) { + if(!strcmpW(proposed_mime, mime_filters[i].mime)) + break; + } + + if(i == sizeof(mime_filters)/sizeof(*mime_filters) || mime_filters[i].filter(buf, size)) { + len = strlenW(proposed_mime)+1; + *ret_mime = CoTaskMemAlloc(len*sizeof(WCHAR)); + if(!*ret_mime) + return E_OUTOFMEMORY; + + memcpy(*ret_mime, proposed_mime, len*sizeof(WCHAR)); + return S_OK; + } + } + + i=0; + while(!ret) { + if(mime_filters[i].filter(buf, size)) + ret = mime_filters[i].mime; + i++; + } + + TRACE("found %s for %s\n", debugstr_w(ret), debugstr_an((const char*)buf, min(32, size))); + + if(proposed_mime) { + if(i == sizeof(mime_filters)/sizeof(*mime_filters)) + ret = proposed_mime; + + /* text/html is a special case */ + if(!strcmpW(proposed_mime, text_htmlW) && !strcmpW(ret, text_plainW)) + ret = text_htmlW; + } + + len = strlenW(ret)+1; + *ret_mime = CoTaskMemAlloc(len*sizeof(WCHAR)); + if(!*ret_mime) + return E_OUTOFMEMORY; + + memcpy(*ret_mime, ret, len*sizeof(WCHAR)); + return S_OK; +} + /*********************************************************************** * FindMimeFromData (URLMON.@) * @@ -658,128 +779,8 @@ HRESULT WINAPI FindMimeFromData(LPBC pBC, LPCWSTR pwzUrl, LPVOID pBuffer, if(!ppwzMimeOut || (!pwzUrl && !pBuffer)) return E_INVALIDARG; - if(pwzMimeProposed && (!pBuffer || (pBuffer && !cbSize))) { - DWORD len; - - if(!pwzMimeProposed) - return E_FAIL; - - len = strlenW(pwzMimeProposed)+1; - *ppwzMimeOut = CoTaskMemAlloc(len*sizeof(WCHAR)); - memcpy(*ppwzMimeOut, pwzMimeProposed, len*sizeof(WCHAR)); - return S_OK; - } - - if(pBuffer) { - const BYTE *buf = pBuffer; - DWORD len; - LPCWSTR ret = NULL; - unsigned int i; - - static const WCHAR wszTextHtml[] = {'t','e','x','t','/','h','t','m','l',0}; - static const WCHAR wszTextRichtext[] = {'t','e','x','t','/','r','i','c','h','t','e','x','t',0}; - static const WCHAR wszAudioBasic[] = {'a','u','d','i','o','/','b','a','s','i','c',0}; - static const WCHAR wszAudioWav[] = {'a','u','d','i','o','/','w','a','v',0}; - static const WCHAR wszImageGif[] = {'i','m','a','g','e','/','g','i','f',0}; - static const WCHAR wszImagePjpeg[] = {'i','m','a','g','e','/','p','j','p','e','g',0}; - static const WCHAR wszImageTiff[] = {'i','m','a','g','e','/','t','i','f','f',0}; - static const WCHAR wszImageXPng[] = {'i','m','a','g','e','/','x','-','p','n','g',0}; - static const WCHAR wszImageBmp[] = {'i','m','a','g','e','/','b','m','p',0}; - static const WCHAR wszVideoAvi[] = {'v','i','d','e','o','/','a','v','i',0}; - static const WCHAR wszVideoMpeg[] = {'v','i','d','e','o','/','m','p','e','g',0}; - static const WCHAR wszAppPostscript[] = - {'a','p','p','l','i','c','a','t','i','o','n','/','p','o','s','t','s','c','r','i','p','t',0}; - static const WCHAR wszAppPdf[] = {'a','p','p','l','i','c','a','t','i','o','n','/', - 'p','d','f',0}; - static const WCHAR wszAppXZip[] = {'a','p','p','l','i','c','a','t','i','o','n','/', - 'x','-','z','i','p','-','c','o','m','p','r','e','s','s','e','d',0}; - static const WCHAR wszAppXGzip[] = {'a','p','p','l','i','c','a','t','i','o','n','/', - 'x','-','g','z','i','p','-','c','o','m','p','r','e','s','s','e','d',0}; - static const WCHAR wszAppJava[] = {'a','p','p','l','i','c','a','t','i','o','n','/', - 'j','a','v','a',0}; - static const WCHAR wszAppXMSDownload[] = {'a','p','p','l','i','c','a','t','i','o','n','/', - 'x','-','m','s','d','o','w','n','l','o','a','d',0}; - static const WCHAR wszTextPlain[] = {'t','e','x','t','/','p','l','a','i','n','\0'}; - static const WCHAR wszAppOctetStream[] = {'a','p','p','l','i','c','a','t','i','o','n','/', - 'o','c','t','e','t','-','s','t','r','e','a','m','\0'}; - - static const struct { - LPCWSTR mime; - BOOL (*filter)(const BYTE *,DWORD); - } mime_filters[] = { - {wszTextHtml, text_html_filter}, - {wszTextRichtext, text_richtext_filter}, - /* {wszAudioXAiff, audio_xaiff_filter}, */ - {wszAudioBasic, audio_basic_filter}, - {wszAudioWav, audio_wav_filter}, - {wszImageGif, image_gif_filter}, - {wszImagePjpeg, image_pjpeg_filter}, - {wszImageTiff, image_tiff_filter}, - {wszImageXPng, image_xpng_filter}, - /* {wszImageXBitmap, image_xbitmap_filter}, */ - {wszImageBmp, image_bmp_filter}, - /* {wszImageXJg, image_xjg_filter}, */ - /* {wszImageXEmf, image_xemf_filter}, */ - /* {wszImageXWmf, image_xwmf_filter}, */ - {wszVideoAvi, video_avi_filter}, - {wszVideoMpeg, video_mpeg_filter}, - {wszAppPostscript, application_postscript_filter}, - /* {wszAppBase64, application_base64_filter}, */ - /* {wszAppMacbinhex40, application_macbinhex40_filter}, */ - {wszAppPdf, application_pdf_filter}, - /* {wszAppXCompressed, application_xcompressed_filter}, */ - {wszAppXZip, application_xzip_filter}, - {wszAppXGzip, application_xgzip_filter}, - {wszAppJava, application_java_filter}, - {wszAppXMSDownload, application_xmsdownload}, - {wszTextPlain, text_plain_filter}, - {wszAppOctetStream, application_octet_stream_filter} - }; - - if(!cbSize) - return E_FAIL; - - if(pwzMimeProposed && strcmpW(pwzMimeProposed, wszAppOctetStream)) { - for(i=0; i < sizeof(mime_filters)/sizeof(*mime_filters); i++) { - if(!strcmpW(pwzMimeProposed, mime_filters[i].mime)) - break; - } - - if(i == sizeof(mime_filters)/sizeof(*mime_filters) - || mime_filters[i].filter(buf, cbSize)) { - len = strlenW(pwzMimeProposed)+1; - *ppwzMimeOut = CoTaskMemAlloc(len*sizeof(WCHAR)); - memcpy(*ppwzMimeOut, pwzMimeProposed, len*sizeof(WCHAR)); - return S_OK; - } - } - - i=0; - while(!ret) { - if(mime_filters[i].filter(buf, cbSize)) - ret = mime_filters[i].mime; - i++; - } - - TRACE("found %s for data\n" - "%02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n", - debugstr_w(ret), buf[0],buf[1],buf[2],buf[3], buf[4],buf[5],buf[6],buf[7], - buf[8],buf[9],buf[10],buf[11], buf[12],buf[13],buf[14],buf[15]); - - if(pwzMimeProposed) { - if(i == sizeof(mime_filters)/sizeof(*mime_filters)) - ret = pwzMimeProposed; - - /* text/html is a special case */ - if(!strcmpW(pwzMimeProposed, wszTextHtml) && !strcmpW(ret, wszTextPlain)) - ret = wszTextHtml; - } - - len = strlenW(ret)+1; - *ppwzMimeOut = CoTaskMemAlloc(len*sizeof(WCHAR)); - memcpy(*ppwzMimeOut, ret, len*sizeof(WCHAR)); - return S_OK; - } + if(pwzMimeProposed || pBuffer) + return find_mime_from_buffer(pBuffer, cbSize, pwzMimeProposed, ppwzMimeOut); if(pwzUrl) { HKEY hkey; diff --git a/reactos/dll/win32/urlmon/urlmon_main.h b/reactos/dll/win32/urlmon/urlmon_main.h index 3aada09ce60..ea33f152bae 100644 --- a/reactos/dll/win32/urlmon/urlmon_main.h +++ b/reactos/dll/win32/urlmon/urlmon_main.h @@ -66,7 +66,7 @@ static inline void URLMON_UnlockModule(void) { InterlockedDecrement( &URLMON_ref #define DEFINE_THIS(cls,ifc,iface) DEFINE_THIS2(cls,lp ## ifc ## Vtbl,iface) IInternetProtocolInfo *get_protocol_info(LPCWSTR); -HRESULT get_protocol_handler(LPCWSTR,CLSID*,BOOL*,IClassFactory**); +HRESULT get_protocol_handler(IUri*,CLSID*,BOOL*,IClassFactory**); IInternetProtocol *get_mime_filter(LPCWSTR); BOOL is_registered_protocol(LPCWSTR); void register_urlmon_namespace(IClassFactory*,REFIID,LPCWSTR,BOOL); @@ -74,12 +74,14 @@ HINTERNET get_internet_session(IInternetBindInfo*); LPWSTR get_useragent(void); void free_session(void); -HRESULT bind_to_storage(LPCWSTR url, IBindCtx *pbc, REFIID riid, void **ppv); -HRESULT bind_to_object(IMoniker *mon, LPCWSTR url, IBindCtx *pbc, REFIID riid, void **ppv); +HRESULT bind_to_storage(IUri*,IBindCtx*,REFIID,void**); +HRESULT bind_to_object(IMoniker*,IUri*,IBindCtx*,REFIID,void**ppv); -HRESULT create_binding_protocol(LPCWSTR url, BOOL from_urlmon, IInternetProtocol **protocol); -void set_binding_sink(IInternetProtocol *bind_protocol, IInternetProtocolSink *sink, IInternetBindInfo *bind_info); -IWinInetInfo *get_wininet_info(IInternetProtocol*); +HRESULT create_binding_protocol(BOOL,IInternetProtocolEx**); +void set_binding_sink(IInternetProtocolEx*,IInternetProtocolSink*,IInternetBindInfo*); +IWinInetInfo *get_wininet_info(IInternetProtocolEx*); +HRESULT create_default_callback(IBindStatusCallback**); +HRESULT wrap_callback(IBindStatusCallback*,IBindStatusCallback**); typedef struct ProtocolVtbl ProtocolVtbl; @@ -101,11 +103,14 @@ typedef struct { ULONG content_length; ULONG available_bytes; + IStream *post_stream; + LONG priority; } Protocol; struct ProtocolVtbl { HRESULT (*open_request)(Protocol*,IUri*,DWORD,HINTERNET,IInternetBindInfo*); + HRESULT (*end_request)(Protocol*); HRESULT (*start_downloading)(Protocol*); void (*close_connection)(Protocol*); }; @@ -115,6 +120,7 @@ HRESULT protocol_continue(Protocol*,PROTOCOLDATA*); HRESULT protocol_read(Protocol*,void*,ULONG,ULONG*); HRESULT protocol_lock_request(Protocol*); HRESULT protocol_unlock_request(Protocol*); +HRESULT protocol_abort(Protocol*,HRESULT); void protocol_close_connection(Protocol*); typedef struct { From 95e952c388d14ba919bf973aaef64ccee3127cd9 Mon Sep 17 00:00:00 2001 From: Roel Messiant Date: Tue, 21 Dec 2010 00:41:52 +0000 Subject: [PATCH 074/181] [CLASSPNP] - Use correct type in sizeof expression (CID 1646 and 10401). - Simplify signature define (CID 3653 and 3654). - Remove funky 0xFF characters. svn path=/trunk/; revision=50076 --- reactos/drivers/storage/classpnp/dictlib.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/reactos/drivers/storage/classpnp/dictlib.c b/reactos/drivers/storage/classpnp/dictlib.c index ba479fe9b52..310b227e0f0 100644 --- a/reactos/drivers/storage/classpnp/dictlib.c +++ b/reactos/drivers/storage/classpnp/dictlib.c @@ -26,30 +26,27 @@ Revision History: #include #include -#define DICTIONARY_SIGNATURE (((ULONG)'dict' << 32) + 'sig ') +#define DICTIONARY_SIGNATURE 'dsig' -struct _DICTIONARY_HEADER { +typedef struct _DICTIONARY_HEADER { struct _DICTIONARY_HEADER* Next; ULONGLONG Key; UCHAR Data[0]; -}; +} DICTIONARY_HEADER, *PDICTIONARY_HEADER; -struct _DICTIONARY_HEADER; -typedef struct _DICTIONARY_HEADER DICTIONARY_HEADER, *PDICTIONARY_HEADER; - VOID InitializeDictionary( IN PDICTIONARY Dictionary ) { - RtlZeroMemory(Dictionary, sizeof(Dictionary)); + RtlZeroMemory(Dictionary, sizeof(DICTIONARY)); Dictionary->Signature = DICTIONARY_SIGNATURE; KeInitializeSpinLock(&Dictionary->SpinLock); return; } - + BOOLEAN TestDictionarySignature( IN PDICTIONARY Dictionary @@ -136,7 +133,7 @@ AllocateDictionaryEntry( return status; } - + PVOID GetDictionaryEntry( IN PDICTIONARY Dictionary, @@ -168,7 +165,7 @@ GetDictionaryEntry( return data; } - + VOID FreeDictionaryEntry( IN PDICTIONARY Dictionary, From e67bf5752c063594cae5b2aaa3e5b41bbaa8212f Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Tue, 21 Dec 2010 04:35:12 +0000 Subject: [PATCH 075/181] [USBDRIVER] - Fix a bug that resulted in us only copying half of the old keyboard data - CID 10402 svn path=/trunk/; revision=50077 --- reactos/drivers/usb/nt4compat/usbdriver/keyboard.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reactos/drivers/usb/nt4compat/usbdriver/keyboard.c b/reactos/drivers/usb/nt4compat/usbdriver/keyboard.c index 3e7102cc41f..4194dcf0655 100644 --- a/reactos/drivers/usb/nt4compat/usbdriver/keyboard.c +++ b/reactos/drivers/usb/nt4compat/usbdriver/keyboard.c @@ -277,7 +277,7 @@ kbd_irq(PURB purb, PVOID pcontext) } // Save old keyboard data - RtlCopyMemory(pdev_ext->kbd_old, data, sizeof(data)); + RtlCopyMemory(pdev_ext->kbd_old, data, 8); // resubmit the urb status = usb_submit_urb(pdev_ext->dev_mgr, purb); From 018e160fdf8e2e29c9450d74d42476d762d2d547 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Tue, 21 Dec 2010 04:48:36 +0000 Subject: [PATCH 076/181] [EXPLORER-NEW] - Fix another "sizeof" usage mistake - CID 1631 svn path=/trunk/; revision=50078 --- reactos/base/shell/explorer-new/dragdrop.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reactos/base/shell/explorer-new/dragdrop.c b/reactos/base/shell/explorer-new/dragdrop.c index 73bf7adf3b8..c0fc1e43bf6 100644 --- a/reactos/base/shell/explorer-new/dragdrop.c +++ b/reactos/base/shell/explorer-new/dragdrop.c @@ -152,7 +152,7 @@ CreateDropTarget(IN HWND hwndTarget, { CopyMemory(&This->Callbacks, Callbacks, - sizeof(Callbacks)); + sizeof(*Callbacks)); } hr = CoCreateInstance(&CLSID_DragDropHelper, From 2b69f5fa2c79fe4a2b31962c5223831a9b23a57c Mon Sep 17 00:00:00 2001 From: Roel Messiant Date: Tue, 21 Dec 2010 14:58:13 +0000 Subject: [PATCH 077/181] [DEVMGR] - DisplayDevicePropertyText: Use full DWORD value, not just one byte of it (CID 1803). [WINMM] - MCI_Close: Use UINT instead of UINT16 for the device id (CID 1804). svn path=/trunk/; revision=50080 --- reactos/dll/win32/devmgr/advprop.c | 45 ++++++++++++++++-------------- reactos/dll/win32/winmm/mci.c | 2 +- 2 files changed, 25 insertions(+), 22 deletions(-) diff --git a/reactos/dll/win32/devmgr/advprop.c b/reactos/dll/win32/devmgr/advprop.c index b7af67e9dc1..3fe16f24634 100644 --- a/reactos/dll/win32/devmgr/advprop.c +++ b/reactos/dll/win32/devmgr/advprop.c @@ -720,6 +720,7 @@ DisplayDevicePropertyText(IN PDEVADVPROP_INFO dap, PSP_DEVINFO_DATA DeviceInfoData; DWORD dwType; DWORD dwSize; + DWORD dwValue; LPBYTE lpBuffer; LPWSTR lpStr; INT len; @@ -791,58 +792,60 @@ DisplayDevicePropertyText(IN PDEVADVPROP_INFO dap, } else if (dwType == REG_DWORD) { + dwValue = *(DWORD *) lpBuffer; + switch (dwProperty) { case SPDRP_CAPABILITIES: index = 0; - if (*lpBuffer & CM_DEVCAP_LOCKSUPPORTED) + if (dwValue & CM_DEVCAP_LOCKSUPPORTED) SetListViewText(hwndListView, index++, L"CM_DEVCAP_LOCKSUPPORTED"); - if (*lpBuffer & CM_DEVCAP_EJECTSUPPORTED) + if (dwValue & CM_DEVCAP_EJECTSUPPORTED) SetListViewText(hwndListView, index++, L"CM_DEVCAP_EJECTSUPPORTED"); - if (*lpBuffer & CM_DEVCAP_REMOVABLE) + if (dwValue & CM_DEVCAP_REMOVABLE) SetListViewText(hwndListView, index++, L"CM_DEVCAP_REMOVABLE"); - if (*lpBuffer & CM_DEVCAP_DOCKDEVICE) + if (dwValue & CM_DEVCAP_DOCKDEVICE) SetListViewText(hwndListView, index++, L"CM_DEVCAP_DOCKDEVICE"); - if (*lpBuffer & CM_DEVCAP_UNIQUEID) + if (dwValue & CM_DEVCAP_UNIQUEID) SetListViewText(hwndListView, index++, L"CM_DEVCAP_UNIQUEID"); - if (*lpBuffer & CM_DEVCAP_SILENTINSTALL) + if (dwValue & CM_DEVCAP_SILENTINSTALL) SetListViewText(hwndListView, index++, L"CM_DEVCAP_SILENTINSTALL"); - if (*lpBuffer & CM_DEVCAP_RAWDEVICEOK) + if (dwValue & CM_DEVCAP_RAWDEVICEOK) SetListViewText(hwndListView, index++, L"CM_DEVCAP_RAWDEVICEOK"); - if (*lpBuffer & CM_DEVCAP_SURPRISEREMOVALOK) + if (dwValue & CM_DEVCAP_SURPRISEREMOVALOK) SetListViewText(hwndListView, index++, L"CM_DEVCAP_SURPRISEREMOVALOK"); - if (*lpBuffer & CM_DEVCAP_HARDWAREDISABLED) + if (dwValue & CM_DEVCAP_HARDWAREDISABLED) SetListViewText(hwndListView, index++, L"CM_DEVCAP_HARDWAREDISABLED"); - if (*lpBuffer & CM_DEVCAP_NONDYNAMIC) + if (dwValue & CM_DEVCAP_NONDYNAMIC) SetListViewText(hwndListView, index++, L"CM_DEVCAP_NONDYNAMIC"); break; case SPDRP_CONFIGFLAGS: index = 0; - if (*lpBuffer & CONFIGFLAG_DISABLED) + if (dwValue & CONFIGFLAG_DISABLED) SetListViewText(hwndListView, index++, L"CONFIGFLAG_DISABLED"); - if (*lpBuffer & CONFIGFLAG_REMOVED) + if (dwValue & CONFIGFLAG_REMOVED) SetListViewText(hwndListView, index++, L"CONFIGFLAG_REMOVED"); - if (*lpBuffer & CONFIGFLAG_MANUAL_INSTALL) + if (dwValue & CONFIGFLAG_MANUAL_INSTALL) SetListViewText(hwndListView, index++, L"CONFIGFLAG_MANUAL_INSTALL"); - if (*lpBuffer & CONFIGFLAG_IGNORE_BOOT_LC) + if (dwValue & CONFIGFLAG_IGNORE_BOOT_LC) SetListViewText(hwndListView, index++, L"CONFIGFLAG_IGNORE_BOOT_LC"); - if (*lpBuffer & CONFIGFLAG_NET_BOOT) + if (dwValue & CONFIGFLAG_NET_BOOT) SetListViewText(hwndListView, index++, L"CONFIGFLAG_NET_BOOT"); - if (*lpBuffer & CONFIGFLAG_REINSTALL) + if (dwValue & CONFIGFLAG_REINSTALL) SetListViewText(hwndListView, index++, L"CONFIGFLAG_REINSTALL"); - if (*lpBuffer & CONFIGFLAG_FAILEDINSTALL) + if (dwValue & CONFIGFLAG_FAILEDINSTALL) SetListViewText(hwndListView, index++, L"CONFIGFLAG_FAILEDINSTALL"); - if (*lpBuffer & CONFIGFLAG_CANTSTOPACHILD) + if (dwValue & CONFIGFLAG_CANTSTOPACHILD) SetListViewText(hwndListView, index++, L"CONFIGFLAG_CANTSTOPACHILD"); - if (*lpBuffer & CONFIGFLAG_OKREMOVEROM) + if (dwValue & CONFIGFLAG_OKREMOVEROM) SetListViewText(hwndListView, index++, L"CONFIGFLAG_OKREMOVEROM"); - if (*lpBuffer & CONFIGFLAG_NOREMOVEEXIT) + if (dwValue & CONFIGFLAG_NOREMOVEEXIT) SetListViewText(hwndListView, index++, L"CONFIGFLAG_NOREMOVEEXIT"); break; default: - swprintf(dap->szTemp, L"0x%08x", *lpBuffer); + swprintf(dap->szTemp, L"0x%08lx", dwValue); SetListViewText(hwndListView, 0, dap->szTemp); break; } diff --git a/reactos/dll/win32/winmm/mci.c b/reactos/dll/win32/winmm/mci.c index 7f36ef53e6a..e2e10e27217 100644 --- a/reactos/dll/win32/winmm/mci.c +++ b/reactos/dll/win32/winmm/mci.c @@ -1669,7 +1669,7 @@ errCleanUp: /************************************************************************** * MCI_Close [internal] */ -static DWORD MCI_Close(UINT16 wDevID, DWORD dwParam, LPMCI_GENERIC_PARMS lpParms) +static DWORD MCI_Close(UINT wDevID, DWORD dwParam, LPMCI_GENERIC_PARMS lpParms) { DWORD dwRet; LPWINE_MCIDRIVER wmd; From 604d4c9de87bd720785c0faea110cd0447db2b65 Mon Sep 17 00:00:00 2001 From: Michael Martin Date: Tue, 21 Dec 2010 15:19:58 +0000 Subject: [PATCH 078/181] [NTOS]: Check that MaximumSize is valid value if the section is being backed by paging file. svn path=/trunk/; revision=50081 --- reactos/ntoskrnl/mm/ARM3/section.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/reactos/ntoskrnl/mm/ARM3/section.c b/reactos/ntoskrnl/mm/ARM3/section.c index a51bdabba70..12fd3fdfb0a 100644 --- a/reactos/ntoskrnl/mm/ARM3/section.c +++ b/reactos/ntoskrnl/mm/ARM3/section.c @@ -1440,6 +1440,10 @@ NtCreateSection(OUT PHANDLE SectionHandle, } else if (!MaximumSize) MaximumSize = &SafeMaximumSize; + /* Check that MaximumSize is valid if backed by paging file */ + if ((!FileHandle) && (!MaximumSize->QuadPart)) + return STATUS_INVALID_PARAMETER_4; + /* Create the section */ Status = MmCreateSection(&SectionObject, DesiredAccess, From a2ca649780106621861cb0e8e665aa8653fb5ba6 Mon Sep 17 00:00:00 2001 From: Amine Khaldi Date: Tue, 21 Dec 2010 20:28:21 +0000 Subject: [PATCH 079/181] [NTOSKRNL] - Fix an assign where a comparison was intended. CID 2626. svn path=/trunk/; revision=50082 --- reactos/ntoskrnl/io/iomgr/driver.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reactos/ntoskrnl/io/iomgr/driver.c b/reactos/ntoskrnl/io/iomgr/driver.c index b0d35fa8fdd..5a5bfb9855e 100644 --- a/reactos/ntoskrnl/io/iomgr/driver.c +++ b/reactos/ntoskrnl/io/iomgr/driver.c @@ -993,7 +993,7 @@ IopInitializeBootDrivers(VOID) &BootEntry->RegistryPath, KEY_READ); if ((NT_SUCCESS(Status)) || /* ReactOS HACK for SETUPLDR */ - ((KeLoaderBlock->SetupLdrBlock) && (KeyHandle = (PVOID)1))) + ((KeLoaderBlock->SetupLdrBlock) && (KeyHandle == (PVOID)1))) { /* Save the handle */ DriverInfo->ServiceHandle = KeyHandle; From a5a6940af850b2d315b65a3ed4512d4ffad4f11b Mon Sep 17 00:00:00 2001 From: Pierre Schweitzer Date: Tue, 21 Dec 2010 21:35:04 +0000 Subject: [PATCH 080/181] [NTOSKRNL] Actually, code was correct, but ugly (who said "normal, that's a hack). So, when that code is called from SetupLDR, KeyHandle is required to be to 1. This what code does. Thing we do in the if condition when it appears we are called from SetupLDR. To avoid any further question, or warning, adding more parenthesis to show that we know what we do. So, to sum up, there's no comparaison for KeyHandle svn path=/trunk/; revision=50083 --- reactos/ntoskrnl/io/iomgr/driver.c | 40 +++++++++++++++--------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/reactos/ntoskrnl/io/iomgr/driver.c b/reactos/ntoskrnl/io/iomgr/driver.c index 5a5bfb9855e..cc6fec8e487 100644 --- a/reactos/ntoskrnl/io/iomgr/driver.c +++ b/reactos/ntoskrnl/io/iomgr/driver.c @@ -932,16 +932,16 @@ IopInitializeBootDrivers(VOID) /* Get highest group order index */ IopGroupIndex = PpInitGetGroupOrderIndex(NULL); if (IopGroupIndex == 0xFFFF) ASSERT(FALSE); - + /* Allocate the group table */ IopGroupTable = ExAllocatePoolWithTag(PagedPool, IopGroupIndex * sizeof(LIST_ENTRY), TAG_IO); if (IopGroupTable == NULL) ASSERT(FALSE); - + /* Initialize the group table lists */ for (i = 0; i < IopGroupIndex; i++) InitializeListHead(&IopGroupTable[i]); - + /* Loop the boot modules */ ListHead = &KeLoaderBlock->LoadOrderListHead; NextEntry = ListHead->Flink; @@ -951,18 +951,18 @@ IopInitializeBootDrivers(VOID) LdrEntry = CONTAINING_RECORD(NextEntry, LDR_DATA_TABLE_ENTRY, InLoadOrderLinks); - + /* Check if the DLL needs to be initialized */ if (LdrEntry->Flags & LDRP_DRIVER_DEPENDENT_DLL) { /* Call its entrypoint */ MmCallDllInitialize(LdrEntry, NULL); } - + /* Go to the next driver */ NextEntry = NextEntry->Flink; } - + /* Loop the boot drivers */ ListHead = &KeLoaderBlock->BootDriverListHead; NextEntry = ListHead->Flink; @@ -972,10 +972,10 @@ IopInitializeBootDrivers(VOID) BootEntry = CONTAINING_RECORD(NextEntry, BOOT_DRIVER_LIST_ENTRY, Link); - + /* Get the driver loader entry */ LdrEntry = BootEntry->LdrEntry; - + /* Allocate our internal accounting structure */ DriverInfo = ExAllocatePoolWithTag(PagedPool, sizeof(DRIVER_INFORMATION), @@ -986,24 +986,24 @@ IopInitializeBootDrivers(VOID) RtlZeroMemory(DriverInfo, sizeof(DRIVER_INFORMATION)); InitializeListHead(&DriverInfo->Link); DriverInfo->DataTableEntry = BootEntry; - + /* Open the registry key */ Status = IopOpenRegistryKeyEx(&KeyHandle, NULL, &BootEntry->RegistryPath, KEY_READ); if ((NT_SUCCESS(Status)) || /* ReactOS HACK for SETUPLDR */ - ((KeLoaderBlock->SetupLdrBlock) && (KeyHandle == (PVOID)1))) + ((KeLoaderBlock->SetupLdrBlock) && ((KeyHandle = (PVOID)1)))) { /* Save the handle */ DriverInfo->ServiceHandle = KeyHandle; - + /* Get the group oder index */ Index = PpInitGetGroupOrderIndex(KeyHandle); - + /* Get the tag position */ DriverInfo->TagPosition = PipGetDriverTagPriority(KeyHandle); - + /* Insert it into the list, at the right place */ ASSERT(Index < IopGroupIndex); NextEntry2 = IopGroupTable[Index].Flink; @@ -1013,18 +1013,18 @@ IopInitializeBootDrivers(VOID) DriverInfoTag = CONTAINING_RECORD(NextEntry2, DRIVER_INFORMATION, Link); - + /* Check if we found the right tag position */ if (DriverInfoTag->TagPosition > DriverInfo->TagPosition) { /* We're done */ break; } - + /* Next entry */ NextEntry2 = NextEntry2->Flink; } - + /* Insert us right before the next entry */ NextEntry2 = NextEntry2->Blink; InsertHeadList(NextEntry2, &DriverInfo->Link); @@ -1046,18 +1046,18 @@ IopInitializeBootDrivers(VOID) DriverInfo = CONTAINING_RECORD(NextEntry, DRIVER_INFORMATION, Link); - + /* Get the driver loader entry */ LdrEntry = DriverInfo->DataTableEntry->LdrEntry; - + /* Initialize it */ IopInitializeBuiltinDriver(LdrEntry); - + /* Next entry */ NextEntry = NextEntry->Flink; } } - + /* In old ROS, the loader list became empty after this point. Simulate. */ InitializeListHead(&KeLoaderBlock->LoadOrderListHead); } From 4a58e37b7c63320e2e920706fe28b6fd10acc386 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Tue, 21 Dec 2010 21:48:29 +0000 Subject: [PATCH 081/181] [NTSOKRNL] add a comment so that noone will stumble upon this atrocity a second time. svn path=/trunk/; revision=50084 --- reactos/ntoskrnl/io/iomgr/driver.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/reactos/ntoskrnl/io/iomgr/driver.c b/reactos/ntoskrnl/io/iomgr/driver.c index cc6fec8e487..f273111ce56 100644 --- a/reactos/ntoskrnl/io/iomgr/driver.c +++ b/reactos/ntoskrnl/io/iomgr/driver.c @@ -191,7 +191,7 @@ IopSuffixUnicodeString( * Display 'Loading XXX...' message. */ -VOID +VOID FASTCALL INIT_FUNCTION IopDisplayLoadingMessage(PUNICODE_STRING ServiceName) @@ -993,7 +993,7 @@ IopInitializeBootDrivers(VOID) &BootEntry->RegistryPath, KEY_READ); if ((NT_SUCCESS(Status)) || /* ReactOS HACK for SETUPLDR */ - ((KeLoaderBlock->SetupLdrBlock) && ((KeyHandle = (PVOID)1)))) + ((KeLoaderBlock->SetupLdrBlock) && ((KeyHandle = (PVOID)1)))) // yes, it's an assignment! { /* Save the handle */ DriverInfo->ServiceHandle = KeyHandle; @@ -1068,24 +1068,24 @@ INIT_FUNCTION IopInitializeSystemDrivers(VOID) { PUNICODE_STRING *DriverList, *SavedList; - + /* No system drivers on the boot cd */ if (KeLoaderBlock->SetupLdrBlock) return; - + /* Get the driver list */ SavedList = DriverList = CmGetSystemDriverList(); ASSERT(DriverList); - + /* Loop it */ while (*DriverList) { /* Load the driver */ ZwLoadDriver(*DriverList); - + /* Free the entry */ RtlFreeUnicodeString(*DriverList); ExFreePool(*DriverList); - + /* Next entry */ InbvIndicateProgress(); DriverList++; From 90d2da336d2c806e8567600c54607e7437fc1480 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Gardou?= Date: Tue, 21 Dec 2010 21:55:29 +0000 Subject: [PATCH 082/181] [VGA_NEW] - avoid buffer overrun, CID 11049 Brought to light by vicmarcal svn path=/trunk/; revision=50085 --- reactos/drivers/video/miniport/vga_new/vbe.c | 22 +++---- reactos/drivers/video/miniport/vga_new/vbe.h | 5 +- .../drivers/video/miniport/vga_new/vbemodes.c | 58 +++++++++---------- reactos/drivers/video/miniport/vga_new/vga.h | 9 ++- 4 files changed, 50 insertions(+), 44 deletions(-) diff --git a/reactos/drivers/video/miniport/vga_new/vbe.c b/reactos/drivers/video/miniport/vga_new/vbe.c index a2c593da460..1c2308ff75c 100644 --- a/reactos/drivers/video/miniport/vga_new/vbe.c +++ b/reactos/drivers/video/miniport/vga_new/vbe.c @@ -42,7 +42,7 @@ IsVesaBiosOk(IN PVIDEO_PORT_INT10_INTERFACE Interface, { ULONG i; CHAR Version[21]; - + /* If the broken VESA bios found, turn VESA off */ VideoPortDebugPrint(0, "Vendor: %s Product: %s Revision: %s (%lx)\n", Vendor, Product, Revision, OemRevision); for (i = 0; i < (sizeof(BrokenVesaBiosList) / sizeof(PCHAR)); i++) @@ -52,7 +52,7 @@ IsVesaBiosOk(IN PVIDEO_PORT_INT10_INTERFACE Interface, /* For Brookdale-G (Intel), special hack used */ g_bIntelBrookdaleBIOS = !strncmp(Product, IntelBrookdale, sizeof(IntelBrookdale)); - + /* For NVIDIA make sure */ if (!(strncmp(Vendor, Nv11Vendor, sizeof(Nv11Vendor))) && !(strncmp(Product, Nv11Board, sizeof(Nv11Board))) && @@ -64,10 +64,10 @@ IsVesaBiosOk(IN PVIDEO_PORT_INT10_INTERFACE Interface, 0xC000, 345, Version, - sizeof(Version))) return FALSE; + sizeof(Version))) return FALSE; if (!strncmp(Version, "Version 3.11.01.24N16", sizeof(Version))) return FALSE; } - + /* VESA ok */ //VideoPortDebugPrint(0, "Vesa ok\n"); return TRUE; @@ -85,13 +85,13 @@ ValidateVbeInfo(IN PHW_DEVICE_EXTENSION VgaExtension, CHAR ProductName[80]; CHAR VendorName[80]; VP_STATUS Status; - + /* Set default */ VesaBiosOk = FALSE; Context = VgaExtension->Int10Interface.Context; - + /* Check magic and version */ - if (strncmp(VbeInfo->Info.Signature, "VESA", 4)) return VesaBiosOk; + if (VbeInfo->Info.Signature == VESA_MAGIC) return VesaBiosOk; if (VbeInfo->Info.Version < 0x102) return VesaBiosOk; /* Read strings */ @@ -125,13 +125,13 @@ ValidateVbeInfo(IN PHW_DEVICE_EXTENSION VgaExtension, ProductName[sizeof(OemString) - 1] = ANSI_NULL; ProductRevision[sizeof(OemString) - 1] = ANSI_NULL; OemString[sizeof(OemString) - 1] = ANSI_NULL; - + /* Check for known bad BIOS */ VesaBiosOk = IsVesaBiosOk(&VgaExtension->Int10Interface, VbeInfo->Info.OemSoftwareRevision, VendorName, ProductName, - ProductRevision); + ProductRevision); VgaExtension->VesaBiosOk = VesaBiosOk; return VesaBiosOk; } @@ -151,7 +151,7 @@ VbeSetColorLookup(IN PHW_DEVICE_EXTENSION VgaExtension, USHORT i; Entries = ClutBuffer->NumEntries; - + /* Allocate INT10 context/buffer */ VesaClut = VideoPortAllocatePool(VgaExtension, 1, sizeof(ULONG) * Entries, 0x20616756u); if (!VesaClut) return ERROR_INVALID_PARAMETER; @@ -178,7 +178,7 @@ VbeSetColorLookup(IN PHW_DEVICE_EXTENSION VgaExtension, Entries * sizeof(ULONG)); if (Status != NO_ERROR) return ERROR_INVALID_PARAMETER; - /* Write new palette */ + /* Write new palette */ BiosArguments.Ebx = 0; BiosArguments.Ecx = Entries; BiosArguments.Edx = ClutBuffer->FirstEntry; diff --git a/reactos/drivers/video/miniport/vga_new/vbe.h b/reactos/drivers/video/miniport/vga_new/vbe.h index 8802a5ead16..7cee0c67b88 100644 --- a/reactos/drivers/video/miniport/vga_new/vbe.h +++ b/reactos/drivers/video/miniport/vga_new/vbe.h @@ -94,7 +94,7 @@ typedef struct _VBE_CONTROLLER_INFO { - CHAR Signature[4]; + ULONG Signature; USHORT Version; ULONG OemStringPtr; LONG Capabilities; @@ -214,4 +214,7 @@ ValidateVbeInfo(IN PHW_DEVICE_EXTENSION VgaExtension, extern BOOLEAN g_bIntelBrookdaleBIOS; +/* VBE2 magic number */ +#define VBE2_MAGIC ('V' + ('B' << 8) + ('E' << 16) + ('2' << 24)) + /* EOF */ diff --git a/reactos/drivers/video/miniport/vga_new/vbemodes.c b/reactos/drivers/video/miniport/vga_new/vbemodes.c index 39537c64563..5e2fc4aef8b 100644 --- a/reactos/drivers/video/miniport/vga_new/vbemodes.c +++ b/reactos/drivers/video/miniport/vga_new/vbemodes.c @@ -26,7 +26,7 @@ NTAPI RaiseToPower2(IN USHORT Value) { ULONG SquaredResult = Value; - if ((Value - 1) & Value) for (SquaredResult = 1; (SquaredResult < Value) && (SquaredResult); SquaredResult *= 2); + if ((Value - 1) & Value) for (SquaredResult = 1; (SquaredResult < Value) && (SquaredResult); SquaredResult *= 2); return SquaredResult; } @@ -34,7 +34,7 @@ ULONG NTAPI VbeGetVideoMemoryBaseAddress(IN PHW_DEVICE_EXTENSION VgaExtension, IN PVIDEOMODE VgaMode) -{ +{ ULONG Length = 4 * 1024; USHORT TrampolineMemorySegment, TrampolineMemoryOffset; PVOID Context; @@ -46,7 +46,7 @@ VbeGetVideoMemoryBaseAddress(IN PHW_DEVICE_EXTENSION VgaExtension, /* Need linear and INT10 interface */ if (!(VgaMode->fbType & VIDEO_MODE_BANKED)) return 0; if (VgaExtension->Int10Interface.Size) return 0; - + /* Allocate scratch area and context */ VbeModeInfo = VideoPortAllocatePool(VgaExtension, 1, sizeof(VBE_MODE_INFO), ' agV'); if (!VbeModeInfo) return 0; @@ -71,7 +71,7 @@ VbeGetVideoMemoryBaseAddress(IN PHW_DEVICE_EXTENSION VgaExtension, VbeModeInfo, sizeof(VBE_MODE_INFO)); if (Status != NO_ERROR) return 0; - + /* Return phys address and cleanup */ BaseAddress = VbeModeInfo->PhysBasePtr; VgaExtension->Int10Interface.Int10FreeBuffer(Context, @@ -91,8 +91,8 @@ VbeSetMode(IN PHW_DEVICE_EXTENSION VgaDeviceExtension, VIDEO_X86_BIOS_ARGUMENTS BiosArguments; ULONG ModeIndex; ULONG BaseAddress; - - VideoPortZeroMemory(&BiosArguments, sizeof(BiosArguments)); + + VideoPortZeroMemory(&BiosArguments, sizeof(BiosArguments)); ModeIndex = VgaMode->Mode; BiosArguments.Eax = ModeIndex & 0x0000FFFF; BiosArguments.Ebx = ModeIndex >> 16; @@ -100,12 +100,12 @@ VbeSetMode(IN PHW_DEVICE_EXTENSION VgaDeviceExtension, Status = VideoPortInt10(VgaDeviceExtension, &BiosArguments); if (Status != NO_ERROR) return Status; - /* Check for VESA mode */ + /* Check for VESA mode */ if (ModeIndex >> 16) { /* Mode set fail */ if (BiosArguments.Eax != VBE_SUCCESS) return ERROR_INVALID_PARAMETER; - + /* Check current mode is desired mode */ BiosArguments.Eax = VBE_GET_CURRENT_VBE_MODE; Status = VideoPortInt10(VgaDeviceExtension, &BiosArguments); @@ -132,7 +132,7 @@ VbeSetMode(IN PHW_DEVICE_EXTENSION VgaDeviceExtension, } } } - + /* Get VRAM address to update changes */ BaseAddress = VbeGetVideoMemoryBaseAddress(VgaDeviceExtension, VgaMode); if ((BaseAddress) && (VgaMode->PhysBase != BaseAddress)) @@ -140,8 +140,8 @@ VbeSetMode(IN PHW_DEVICE_EXTENSION VgaDeviceExtension, *PhysPtrChange = TRUE; VgaMode->PhysBase = BaseAddress; } - - return NO_ERROR; + + return NO_ERROR; } VOID @@ -179,7 +179,7 @@ InitializeModeTable(IN PHW_DEVICE_EXTENSION VgaExtension) VgaExtension->Int10Interface.Version = 0; return; } - + /* Query INT10 interface */ VgaExtension->Int10Interface.Version = VIDEO_PORT_INT10_INTERFACE_VERSION_1; VgaExtension->Int10Interface.Size = sizeof(VIDEO_PORT_INT10_INTERFACE); @@ -190,12 +190,12 @@ InitializeModeTable(IN PHW_DEVICE_EXTENSION VgaExtension) VgaExtension->Int10Interface.Size = 0; VgaExtension->Int10Interface.Version = 0; } - + /* Add ref */ //VideoPortDebugPrint(0, "have int10 iface\n"); VgaExtension->Int10Interface.InterfaceReference(VgaExtension->Int10Interface.Context); Context = VgaExtension->Int10Interface.Context; - + /* Allocate scratch area and context */ Status = VgaExtension->Int10Interface.Int10AllocateBuffer(Context, &TrampolineMemorySegment, @@ -209,7 +209,7 @@ InitializeModeTable(IN PHW_DEVICE_EXTENSION VgaExtension) /* Init VBE data and write to card buffer */ //VideoPortDebugPrint(0, "have int10 data\n"); VbeInfo->ModeArray[128] = 0xFFFF; - strcpy(VbeInfo->Info.Signature, "VBE2"); + VbeInfo->Info.Signature = VBE2_MAGIC; Status = VgaExtension->Int10Interface.Int10WriteMemory(Context, TrampolineMemorySegment, TrampolineMemoryOffset, @@ -237,7 +237,7 @@ InitializeModeTable(IN PHW_DEVICE_EXTENSION VgaExtension) VbeVersion = VbeInfo->Info.Version; VideoPortDebugPrint(0, "vbe version %lx memory %lx\n", VbeVersion, TotalMemory); if (!ValidateVbeInfo(VgaExtension, VbeInfo)) return; - + /* Read modes */ //VideoPortDebugPrint(0, "read modes from %p\n", VbeInfo->Info.VideoModePtr); Status = VgaExtension->Int10Interface.Int10ReadMemory(Context, @@ -259,11 +259,11 @@ InitializeModeTable(IN PHW_DEVICE_EXTENSION VgaExtension) ModeResult = *++ThisMode; NewModes++; } - + /* Remove the built-in mode if not supported by card and check max modes */ if (!FourBppModeFound) --NumVideoModes; if ((NewModes >= 128) && (NumVideoModes > 8)) goto Cleanup; - + /* Switch to new SVGA mode list, copy VGA modes */ VgaModeList = VideoPortAllocatePool(VgaExtension, 1, (NewModes + NumVideoModes) * sizeof(VIDEOMODE), ' agV'); if (!VgaModeList) goto Cleanup; @@ -275,7 +275,7 @@ InitializeModeTable(IN PHW_DEVICE_EXTENSION VgaExtension) VideoPortDebugPrint(0, "Intel Brookdale-G Video BIOS Not Support!\n"); while (TRUE); } - + /* Scan SVGA modes */ // VideoPortDebugPrint(0, "Static modes: %d\n", NumVideoModes); VgaMode = &VgaModeList[NumVideoModes]; @@ -328,7 +328,7 @@ InitializeModeTable(IN PHW_DEVICE_EXTENSION VgaExtension) if (VbeModeInfo->ModeAttributes & VBE_MODEATTR_COLOR) VgaMode->fbType |= VIDEO_MODE_COLOR; if (VbeModeInfo->ModeAttributes & VBE_MODEATTR_GRAPHICS) VgaMode->fbType |= VIDEO_MODE_GRAPHICS; if (VbeModeInfo->ModeAttributes & VBE_MODEATTR_NON_VGA) VgaMode->NonVgaMode = TRUE; - + /* If no char data, say 80x25 */ VgaMode->col = VbeModeInfo->XCharSize ? VbeModeInfo->XResolution / VbeModeInfo->XCharSize : 80; VgaMode->row = VbeModeInfo->YCharSize ? VbeModeInfo->YResolution / VbeModeInfo->YCharSize : 25; @@ -338,8 +338,8 @@ InitializeModeTable(IN PHW_DEVICE_EXTENSION VgaExtension) VgaMode->bitsPerPlane = VbeModeInfo->BitsPerPixel / VbeModeInfo->NumberOfPlanes; if ((VgaMode->bitsPerPlane == 16) && (VbeModeInfo->GreenMaskSize == 5)) VgaMode->bitsPerPlane = 15; //VideoPortDebugPrint(0, "BPP: %d\n", VgaMode->BitsPerPlane); - - /* Do linear or banked frame buffers */ + + /* Do linear or banked frame buffers */ VgaMode->FrameBufferBase = 0; if (!LinearAddressing) { @@ -347,7 +347,7 @@ InitializeModeTable(IN PHW_DEVICE_EXTENSION VgaExtension) ScreenStride = RaiseToPower2(VbeModeInfo->BytesPerScanLine); VgaMode->wbytes = ScreenStride; //VideoPortDebugPrint(0, "ScanLines: %lx Stride: %lx\n", VbeModeInfo->BytesPerScanLine, VgaMode->Stride); - + /* Size of frame buffer is Height X ScanLine, align to bank/page size */ ScreenSize = VgaMode->hres * ScreenStride; //VideoPortDebugPrint(0, "Size: %lx\n", ScreenSize); @@ -355,7 +355,7 @@ InitializeModeTable(IN PHW_DEVICE_EXTENSION VgaExtension) //VideoPortDebugPrint(0, "Size: %lx\n", ScreenSize); if (Size > TotalMemory) Size = (Size + ((4 * 1024) - 1)) & ((4 * 1024) - 1); //VideoPortDebugPrint(0, "Size: %lx\n", ScreenSize); - + /* Banked VGA at 0xA0000 (64K) */ //VideoPortDebugPrint(0, "Final size: %lx\n", Size); VgaMode->fbType |= VIDEO_MODE_BANKED; @@ -374,7 +374,7 @@ InitializeModeTable(IN PHW_DEVICE_EXTENSION VgaExtension) if (!ScreenStride) ScreenStride = VbeModeInfo->BytesPerScanLine; VgaMode->wbytes = ScreenStride; //VideoPortDebugPrint(0, "ScanLines: %lx Stride: %lx\n", VbeModeInfo->BytesPerScanLine, VgaMode->Stride); - + /* Size of frame buffer is Height X ScanLine, align to page size */ ScreenSize = VgaMode->hres * LOWORD(VgaMode->wbytes); //VideoPortDebugPrint(0, "Size: %lx\n", ScreenSize); @@ -382,7 +382,7 @@ InitializeModeTable(IN PHW_DEVICE_EXTENSION VgaExtension) //VideoPortDebugPrint(0, "Size: %lx\n", ScreenSize); if (Size > TotalMemory) Size = (Size + ((4 * 1024) - 1)) & ((4 * 1024) - 1); //VideoPortDebugPrint(0, "Size: %lx\n", ScreenSize); - + /* Linear VGA must read settings from VBE */ VgaMode->fbType |= VIDEO_MODE_LINEAR; VgaMode->sbytes = Size; @@ -391,14 +391,14 @@ InitializeModeTable(IN PHW_DEVICE_EXTENSION VgaExtension) VgaMode->NoBankSwitch = FALSE; VgaMode->PhysBase = VbeModeInfo->PhysBasePtr; VgaMode->LogicalWidth = VgaMode->hres; - + /* Make VBE_SET_VBE_MODE command use Linear Framebuffer Select */ VgaMode->Mode |= (VBE_MODE_LINEAR_FRAMEBUFFER << 16); } - + /* Override bank switch if not support by card */ if (VbeModeInfo->ModeAttributes & VBE_MODEATTR_NO_BANK_SWITCH) VgaMode->NoBankSwitch = TRUE; - + /* Next */ if (ScreenSize <= TotalMemory) { diff --git a/reactos/drivers/video/miniport/vga_new/vga.h b/reactos/drivers/video/miniport/vga_new/vga.h index 21e411584f8..73e7fc8979d 100644 --- a/reactos/drivers/video/miniport/vga_new/vga.h +++ b/reactos/drivers/video/miniport/vga_new/vga.h @@ -266,7 +266,7 @@ typedef struct { // eVb: 3.3 [VBE] PUSHORT CmdStream; // pointer to array of register-setting commands to // set up mode -// eVb: 3.4 [VBE] - Add fields to track linear addresses/sizes and flags +// eVb: 3.4 [VBE] - Add fields to track linear addresses/sizes and flags ULONG PhysBase; ULONG FrameBufferBase; ULONG FrameBufferSize; @@ -407,7 +407,7 @@ typedef struct _HW_DEVICE_EXTENSION { UCHAR CursorEnable; // whether cursor is enabled or not UCHAR CursorTopScanLine; // Cursor Start register setting (top scan) UCHAR CursorBottomScanLine; // Cursor End register setting (bottom scan) -// eVb: 3.5 [VBE] - Add fields for VBE support and XP+ INT10 interface +// eVb: 3.5 [VBE] - Add fields for VBE support and XP+ INT10 interface VIDEO_PORT_INT10_INTERFACE Int10Interface; BOOLEAN VesaBiosOk; // eVb: 3.5 [END] @@ -438,9 +438,12 @@ extern ULONG NumVideoModes; extern VIDEOMODE ModesVGA[]; extern PVIDEOMODE VgaModeList; -// eVb: 3.5 [VGA] - Add ATI/Mach64 Access Range +// eVb: 3.5 [VGA] - Add ATI/Mach64 Access Range #define NUM_VGA_ACCESS_RANGES 5 // eVb: 3.5 [END] extern VIDEO_ACCESS_RANGE VgaAccessRange[]; +/* VESA Bios Magic number */ +#define VESA_MAGIC ('V' + ('E' << 8) + ('S' << 16) + ('A' << 24)) + #include "vbe.h" From f43fa44a2e1453b2234e21f9fc9dc00908617626 Mon Sep 17 00:00:00 2001 From: Pierre Schweitzer Date: Tue, 21 Dec 2010 22:24:50 +0000 Subject: [PATCH 083/181] [NTOSKRNL] Fix CID 3454 svn path=/trunk/; revision=50087 --- reactos/ntoskrnl/io/iomgr/iorsrce.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/reactos/ntoskrnl/io/iomgr/iorsrce.c b/reactos/ntoskrnl/io/iomgr/iorsrce.c index 9d52881ce12..948db34e673 100644 --- a/reactos/ntoskrnl/io/iomgr/iorsrce.c +++ b/reactos/ntoskrnl/io/iomgr/iorsrce.c @@ -980,14 +980,13 @@ IoQueryDeviceDescription(PINTERFACE_TYPE BusType OPTIONAL, OBJECT_ATTRIBUTES ObjectAttributes; UNICODE_STRING RootRegKey; HANDLE RootRegHandle; - WCHAR RootRegString[] = L"\\REGISTRY\\MACHINE\\HARDWARE\\DESCRIPTION\\SYSTEM"; IO_QUERY Query; /* Set up the String */ RootRegKey.Length = 0; RootRegKey.MaximumLength = 2048; RootRegKey.Buffer = ExAllocatePoolWithTag(PagedPool, RootRegKey.MaximumLength, TAG_IO_RESOURCE); - RtlAppendUnicodeToString(&RootRegKey, RootRegString); + RtlAppendUnicodeToString(&RootRegKey, L"\\REGISTRY\\MACHINE\\HARDWARE\\DESCRIPTION\\SYSTEM"); /* Open a handle to the Root Registry Key */ InitializeObjectAttributes( From 1ef69582036d1f5203ef4efd5d65aa0e0ceb7198 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Tue, 21 Dec 2010 23:48:15 +0000 Subject: [PATCH 084/181] [SCSIPORT] ScsiPortConvertPhysicalAddressToUlong takes an ULONG_PTR as input, fix function accordingly and do the "calculation" directly instead of calling RtlConvertUlongToLargeInteger Spotted by Samuel. svn path=/trunk/; revision=50089 --- reactos/boot/freeldr/freeldr/disk/scsiport.c | 11 +++++++---- reactos/drivers/storage/ide/uniata/srb.h | 2 +- reactos/drivers/storage/scsiport/stubs.c | 7 +++++-- reactos/include/ddk/srb.h | 2 +- 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/reactos/boot/freeldr/freeldr/disk/scsiport.c b/reactos/boot/freeldr/freeldr/disk/scsiport.c index ce306a39c3f..254760ff24a 100644 --- a/reactos/boot/freeldr/freeldr/disk/scsiport.c +++ b/reactos/boot/freeldr/freeldr/disk/scsiport.c @@ -445,9 +445,12 @@ ScsiPortConvertPhysicalAddressToUlong( SCSI_PHYSICAL_ADDRESS NTAPI ScsiPortConvertUlongToPhysicalAddress( - IN ULONG UlongAddress) + IN ULONG_PTR UlongAddress) { - return RtlConvertUlongToLargeInteger(UlongAddress); + SCSI_PHYSICAL_ADDRESS Address; + + Address.QuadPart = UlongAddress; + return Address; } VOID @@ -1540,7 +1543,7 @@ LoadBootDeviceDriver(VOID) { CHAR* Name; PVOID Function; - } ExportTable[] = + } ExportTable[] = { { "ScsiDebugPrint", ScsiDebugPrint }, { "ScsiPortCompleteRequest", ScsiPortCompleteRequest }, @@ -1618,7 +1621,7 @@ LoadBootDeviceDriver(VOID) ImageDosHeader.e_lfanew = SWAPD((ULONG_PTR)&ImageNtHeaders - (ULONG_PTR)&ImageDosHeader); ImageNtHeaders.Signature = IMAGE_NT_SIGNATURE; ImageNtHeaders.OptionalHeader.NumberOfRvaAndSizes = SWAPD(IMAGE_DIRECTORY_ENTRY_EXPORT + 1); - ImageNtHeaders.OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT].VirtualAddress = + ImageNtHeaders.OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT].VirtualAddress = SWAPW((ULONG_PTR)&ImageExportDirectory - (ULONG_PTR)&ImageDosHeader); ImageNtHeaders.OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT].Size = 1; ImageExportDirectory.NumberOfNames = sizeof(ExportTable) / sizeof(ExportTable[0]); diff --git a/reactos/drivers/storage/ide/uniata/srb.h b/reactos/drivers/storage/ide/uniata/srb.h index b3795b22808..0932284fed2 100644 --- a/reactos/drivers/storage/ide/uniata/srb.h +++ b/reactos/drivers/storage/ide/uniata/srb.h @@ -935,7 +935,7 @@ ScsiPortWriteRegisterBufferUlong( SCSIPORT_API SCSI_PHYSICAL_ADDRESS NTAPI ScsiPortConvertUlongToPhysicalAddress( - ULONG UlongAddress + ULONG_PTR UlongAddress ); SCSIPORT_API diff --git a/reactos/drivers/storage/scsiport/stubs.c b/reactos/drivers/storage/scsiport/stubs.c index b4bc2f5ed25..28070bc6e42 100644 --- a/reactos/drivers/storage/scsiport/stubs.c +++ b/reactos/drivers/storage/scsiport/stubs.c @@ -42,9 +42,12 @@ SCSI_PHYSICAL_ADDRESS NTAPI ScsiPortConvertUlongToPhysicalAddress( - IN ULONG UlongAddress) + IN ULONG_PTR UlongAddress) { - return RtlConvertUlongToLargeInteger(UlongAddress); + SCSI_PHYSICAL_ADDRESS Address; + + Address.QuadPart = UlongAddress; + return Address; } VOID diff --git a/reactos/include/ddk/srb.h b/reactos/include/ddk/srb.h index cca653d86ae..cddc8295e17 100644 --- a/reactos/include/ddk/srb.h +++ b/reactos/include/ddk/srb.h @@ -550,7 +550,7 @@ SCSIPORTAPI SCSI_PHYSICAL_ADDRESS NTAPI ScsiPortConvertUlongToPhysicalAddress( - IN ULONG UlongAddress); + IN ULONG_PTR UlongAddress); SCSIPORTAPI VOID From 10bab368705c76a295fe039bed3cad871da77f4c Mon Sep 17 00:00:00 2001 From: Pierre Schweitzer Date: Wed, 22 Dec 2010 00:13:03 +0000 Subject: [PATCH 085/181] [FASTFAT] Fix for a buffer overflow and then a buffer overrun (if ever it fixes something) The way filenames are handled for FAT entries should be REALLY simplified. This would prevent such errors. Thus, there are more magic values in fastfat driver than everywhere else in ReactOS which makes proper fixing hard (impossible?). Finally, the code for that fix is crappy, but I don't care, it fits the rest of the fastfat driver code. *pissed off* Fixes CID #2502 svn path=/trunk/; revision=50090 --- reactos/drivers/filesystems/fastfat/volume.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/reactos/drivers/filesystems/fastfat/volume.c b/reactos/drivers/filesystems/fastfat/volume.c index 4a014b37882..6fd04800e5f 100644 --- a/reactos/drivers/filesystems/fastfat/volume.c +++ b/reactos/drivers/filesystems/fastfat/volume.c @@ -220,8 +220,16 @@ FsdSetFsLabelInformation(PDEVICE_OBJECT DeviceObject, } else { - RtlCopyMemory(VolumeLabelDirEntry.Fat.Filename, cString, LabelLen); - memset(&VolumeLabelDirEntry.Fat.Filename[LabelLen], ' ', 11 - LabelLen); + RtlCopyMemory(VolumeLabelDirEntry.Fat.Filename, cString, max(sizeof(VolumeLabelDirEntry.Fat.Filename), LabelLen)); + if (LabelLen > sizeof(VolumeLabelDirEntry.Fat.Filename)) + { + memset(VolumeLabelDirEntry.Fat.Ext, ' ', sizeof(VolumeLabelDirEntry.Fat.Ext)); + RtlCopyMemory(VolumeLabelDirEntry.Fat.Ext, cString + sizeof(VolumeLabelDirEntry.Fat.Filename), LabelLen - sizeof(VolumeLabelDirEntry.Fat.Filename)); + } + else + { + memset(&VolumeLabelDirEntry.Fat.Filename[LabelLen], ' ', sizeof(VolumeLabelDirEntry.Fat.Filename) - LabelLen); + } VolumeLabelDirEntry.Fat.Attrib = 0x08; } From 372bbf2a73e3a7735cb1e07c6c7abfc99b4bca25 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Wed, 22 Dec 2010 13:00:47 +0000 Subject: [PATCH 086/181] [FORMATTING] Apply indentation of 4 spaces. svn path=/trunk/; revision=50091 --- reactos/dll/ntdll/ldr/utils.c | 4023 +++++++++++++++++---------------- 1 file changed, 2017 insertions(+), 2006 deletions(-) diff --git a/reactos/dll/ntdll/ldr/utils.c b/reactos/dll/ntdll/ldr/utils.c index 4b085391e92..828b0066809 100644 --- a/reactos/dll/ntdll/ldr/utils.c +++ b/reactos/dll/ntdll/ldr/utils.c @@ -33,11 +33,11 @@ typedef struct _TLS_DATA { - PVOID StartAddressOfRawData; - DWORD TlsDataSize; - DWORD TlsZeroSize; - PIMAGE_TLS_CALLBACK *TlsAddressOfCallBacks; - PLDR_DATA_TABLE_ENTRY Module; + PVOID StartAddressOfRawData; + DWORD TlsDataSize; + DWORD TlsZeroSize; + PIMAGE_TLS_CALLBACK *TlsAddressOfCallBacks; + PLDR_DATA_TABLE_ENTRY Module; } TLS_DATA, *PTLS_DATA; static BOOLEAN LdrpDllShutdownInProgress = FALSE; @@ -71,96 +71,96 @@ NTSTATUS create_module_activation_context( LDR_DATA_TABLE_ENTRY *module ); BOOLEAN LdrMappedAsDataFile(PVOID *BaseAddress) { - if (0 != ((DWORD_PTR) *BaseAddress & (PAGE_SIZE - 1))) + if (0 != ((DWORD_PTR) *BaseAddress & (PAGE_SIZE - 1))) { - *BaseAddress = (PVOID) ((DWORD_PTR) *BaseAddress & ~ ((DWORD_PTR) PAGE_SIZE - 1)); - return TRUE; + *BaseAddress = (PVOID)((DWORD_PTR)*BaseAddress & ~((DWORD_PTR) PAGE_SIZE - 1)); + return TRUE; } - return FALSE; + return FALSE; } static __inline LONG LdrpDecrementLoadCount(PLDR_DATA_TABLE_ENTRY Module, BOOLEAN Locked) { - LONG LoadCount; - if (!Locked) - { - RtlEnterCriticalSection (NtCurrentPeb()->LoaderLock); - } - LoadCount = Module->LoadCount; + LONG LoadCount; + if (!Locked) + { + RtlEnterCriticalSection (NtCurrentPeb()->LoaderLock); + } + LoadCount = Module->LoadCount; if (Module->LoadCount > 0 && Module->LoadCount != LDRP_PROCESS_CREATION_TIME) { - Module->LoadCount--; + Module->LoadCount--; } - if (!Locked) - { - RtlLeaveCriticalSection(NtCurrentPeb()->LoaderLock); - } - return LoadCount; + if (!Locked) + { + RtlLeaveCriticalSection(NtCurrentPeb()->LoaderLock); + } + return LoadCount; } static __inline LONG LdrpIncrementLoadCount(PLDR_DATA_TABLE_ENTRY Module, BOOLEAN Locked) { - LONG LoadCount; - if (!Locked) - { - RtlEnterCriticalSection (NtCurrentPeb()->LoaderLock); - } - LoadCount = Module->LoadCount; + LONG LoadCount; + if (!Locked) + { + RtlEnterCriticalSection (NtCurrentPeb()->LoaderLock); + } + LoadCount = Module->LoadCount; if (Module->LoadCount != LDRP_PROCESS_CREATION_TIME) { - Module->LoadCount++; + Module->LoadCount++; } - if (!Locked) - { - RtlLeaveCriticalSection(NtCurrentPeb()->LoaderLock); - } - return LoadCount; + if (!Locked) + { + RtlLeaveCriticalSection(NtCurrentPeb()->LoaderLock); + } + return LoadCount; } static __inline VOID LdrpAcquireTlsSlot(PLDR_DATA_TABLE_ENTRY Module, ULONG Size, BOOLEAN Locked) { - if (!Locked) - { - RtlEnterCriticalSection (NtCurrentPeb()->LoaderLock); - } - Module->TlsIndex = (SHORT)LdrpTlsCount; - LdrpTlsCount++; - LdrpTlsSize += Size; - if (!Locked) - { - RtlLeaveCriticalSection(NtCurrentPeb()->LoaderLock); - } + if (!Locked) + { + RtlEnterCriticalSection (NtCurrentPeb()->LoaderLock); + } + Module->TlsIndex = (SHORT)LdrpTlsCount; + LdrpTlsCount++; + LdrpTlsSize += Size; + if (!Locked) + { + RtlLeaveCriticalSection(NtCurrentPeb()->LoaderLock); + } } static __inline VOID LdrpTlsCallback(PLDR_DATA_TABLE_ENTRY Module, ULONG dwReason) { - PIMAGE_TLS_CALLBACK *TlsCallback; - if (Module->TlsIndex != 0xFFFF && Module->LoadCount == LDRP_PROCESS_CREATION_TIME) - { - TlsCallback = LdrpTlsArray[Module->TlsIndex].TlsAddressOfCallBacks; - if (TlsCallback) - { - while (*TlsCallback) - { - TRACE_LDR("%wZ - Calling tls callback at %x\n", - &Module->BaseDllName, *TlsCallback); - (*TlsCallback)(Module->DllBase, dwReason, NULL); - TlsCallback++; - } - } - } + PIMAGE_TLS_CALLBACK *TlsCallback; + if (Module->TlsIndex != 0xFFFF && Module->LoadCount == LDRP_PROCESS_CREATION_TIME) + { + TlsCallback = LdrpTlsArray[Module->TlsIndex].TlsAddressOfCallBacks; + if (TlsCallback) + { + while (*TlsCallback) + { + TRACE_LDR("%wZ - Calling tls callback at %x\n", + &Module->BaseDllName, *TlsCallback); + (*TlsCallback)(Module->DllBase, dwReason, NULL); + TlsCallback++; + } + } + } } static BOOLEAN LdrpCallDllEntry(PLDR_DATA_TABLE_ENTRY Module, DWORD dwReason, PVOID lpReserved) { - if (!(Module->Flags & LDRP_IMAGE_DLL) || - Module->EntryPoint == 0) - { - return TRUE; - } - LdrpTlsCallback(Module, dwReason); - return ((PDLLMAIN_FUNC)Module->EntryPoint)(Module->DllBase, dwReason, lpReserved); + if (!(Module->Flags & LDRP_IMAGE_DLL) || + Module->EntryPoint == 0) + { + return TRUE; + } + LdrpTlsCallback(Module, dwReason); + return ((PDLLMAIN_FUNC)Module->EntryPoint)(Module->DllBase, dwReason, lpReserved); } static PWSTR @@ -180,9 +180,9 @@ LdrpQueryAppPaths(IN PCWSTR ImageName) PWSTR Path = NULL; _snwprintf(NameBuffer, - sizeof(NameBuffer) / sizeof(WCHAR), - L"\\Registry\\Machine\\Software\\Microsoft\\Windows\\CurrentVersion\\App Paths\\%s", - ImageName); + sizeof(NameBuffer) / sizeof(WCHAR), + L"\\Registry\\Machine\\Software\\Microsoft\\Windows\\CurrentVersion\\App Paths\\%s", + ImageName); RtlInitUnicodeString(&KeyName, NameBuffer); @@ -272,202 +272,202 @@ LdrpQueryAppPaths(IN PCWSTR ImageName) static NTSTATUS LdrpInitializeTlsForThread(VOID) { - PVOID* TlsPointers; - PTLS_DATA TlsInfo; - PVOID TlsData; - ULONG i; - PTEB Teb = NtCurrentTeb(); + PVOID* TlsPointers; + PTLS_DATA TlsInfo; + PVOID TlsData; + ULONG i; + PTEB Teb = NtCurrentTeb(); - DPRINT("LdrpInitializeTlsForThread() called for %wZ\n", &ExeModule->BaseDllName); + DPRINT("LdrpInitializeTlsForThread() called for %wZ\n", &ExeModule->BaseDllName); - Teb->StaticUnicodeString.Length = 0; - Teb->StaticUnicodeString.MaximumLength = sizeof(Teb->StaticUnicodeBuffer); - Teb->StaticUnicodeString.Buffer = Teb->StaticUnicodeBuffer; + Teb->StaticUnicodeString.Length = 0; + Teb->StaticUnicodeString.MaximumLength = sizeof(Teb->StaticUnicodeBuffer); + Teb->StaticUnicodeString.Buffer = Teb->StaticUnicodeBuffer; - if (LdrpTlsCount > 0) - { - TlsPointers = RtlAllocateHeap(RtlGetProcessHeap(), - 0, - LdrpTlsCount * sizeof(PVOID) + LdrpTlsSize); - if (TlsPointers == NULL) - { - DPRINT1("failed to allocate thread tls data\n"); - return STATUS_NO_MEMORY; - } + if (LdrpTlsCount > 0) + { + TlsPointers = RtlAllocateHeap(RtlGetProcessHeap(), + 0, + LdrpTlsCount * sizeof(PVOID) + LdrpTlsSize); + if (TlsPointers == NULL) + { + DPRINT1("failed to allocate thread tls data\n"); + return STATUS_NO_MEMORY; + } - TlsData = (PVOID)((ULONG_PTR)TlsPointers + LdrpTlsCount * sizeof(PVOID)); - Teb->ThreadLocalStoragePointer = TlsPointers; + TlsData = (PVOID)((ULONG_PTR)TlsPointers + LdrpTlsCount * sizeof(PVOID)); + Teb->ThreadLocalStoragePointer = TlsPointers; - TlsInfo = LdrpTlsArray; - for (i = 0; i < LdrpTlsCount; i++, TlsInfo++) - { - TRACE_LDR("Initialize tls data for %wZ\n", &TlsInfo->Module->BaseDllName); - TlsPointers[i] = TlsData; - if (TlsInfo->TlsDataSize) - { - memcpy(TlsData, TlsInfo->StartAddressOfRawData, TlsInfo->TlsDataSize); - TlsData = (PVOID)((ULONG_PTR)TlsData + TlsInfo->TlsDataSize); - } - if (TlsInfo->TlsZeroSize) - { - memset(TlsData, 0, TlsInfo->TlsZeroSize); - TlsData = (PVOID)((ULONG_PTR)TlsData + TlsInfo->TlsZeroSize); - } - } - } + TlsInfo = LdrpTlsArray; + for (i = 0; i < LdrpTlsCount; i++, TlsInfo++) + { + TRACE_LDR("Initialize tls data for %wZ\n", &TlsInfo->Module->BaseDllName); + TlsPointers[i] = TlsData; + if (TlsInfo->TlsDataSize) + { + memcpy(TlsData, TlsInfo->StartAddressOfRawData, TlsInfo->TlsDataSize); + TlsData = (PVOID)((ULONG_PTR)TlsData + TlsInfo->TlsDataSize); + } + if (TlsInfo->TlsZeroSize) + { + memset(TlsData, 0, TlsInfo->TlsZeroSize); + TlsData = (PVOID)((ULONG_PTR)TlsData + TlsInfo->TlsZeroSize); + } + } + } - DPRINT("LdrpInitializeTlsForThread() done\n"); - return STATUS_SUCCESS; + DPRINT("LdrpInitializeTlsForThread() done\n"); + return STATUS_SUCCESS; } static NTSTATUS LdrpInitializeTlsForProccess(VOID) { - PLIST_ENTRY ModuleListHead; - PLIST_ENTRY Entry; - PLDR_DATA_TABLE_ENTRY Module; - PIMAGE_TLS_DIRECTORY TlsDirectory; - PTLS_DATA TlsData; - ULONG Size; + PLIST_ENTRY ModuleListHead; + PLIST_ENTRY Entry; + PLDR_DATA_TABLE_ENTRY Module; + PIMAGE_TLS_DIRECTORY TlsDirectory; + PTLS_DATA TlsData; + ULONG Size; - DPRINT("LdrpInitializeTlsForProccess() called for %wZ\n", &ExeModule->BaseDllName); + DPRINT("LdrpInitializeTlsForProccess() called for %wZ\n", &ExeModule->BaseDllName); - if (LdrpTlsCount > 0) - { - LdrpTlsArray = RtlAllocateHeap(RtlGetProcessHeap(), - 0, - LdrpTlsCount * sizeof(TLS_DATA)); - if (LdrpTlsArray == NULL) - { - DPRINT1("Failed to allocate global tls data\n"); - return STATUS_NO_MEMORY; - } + if (LdrpTlsCount > 0) + { + LdrpTlsArray = RtlAllocateHeap(RtlGetProcessHeap(), + 0, + LdrpTlsCount * sizeof(TLS_DATA)); + if (LdrpTlsArray == NULL) + { + DPRINT1("Failed to allocate global tls data\n"); + return STATUS_NO_MEMORY; + } - ModuleListHead = &NtCurrentPeb()->Ldr->InLoadOrderModuleList; - Entry = ModuleListHead->Flink; - while (Entry != ModuleListHead) - { - Module = CONTAINING_RECORD(Entry, LDR_DATA_TABLE_ENTRY, InLoadOrderLinks); - if (Module->LoadCount == LDRP_PROCESS_CREATION_TIME && - Module->TlsIndex != 0xFFFF) - { - TlsDirectory = (PIMAGE_TLS_DIRECTORY) - RtlImageDirectoryEntryToData(Module->DllBase, - TRUE, - IMAGE_DIRECTORY_ENTRY_TLS, - &Size); - ASSERT(Module->TlsIndex < LdrpTlsCount); - TlsData = &LdrpTlsArray[Module->TlsIndex]; - TlsData->StartAddressOfRawData = (PVOID)TlsDirectory->StartAddressOfRawData; - TlsData->TlsDataSize = TlsDirectory->EndAddressOfRawData - TlsDirectory->StartAddressOfRawData; - TlsData->TlsZeroSize = TlsDirectory->SizeOfZeroFill; - if (TlsDirectory->AddressOfCallBacks) - TlsData->TlsAddressOfCallBacks = (PIMAGE_TLS_CALLBACK *)TlsDirectory->AddressOfCallBacks; - else - TlsData->TlsAddressOfCallBacks = NULL; - TlsData->Module = Module; + ModuleListHead = &NtCurrentPeb()->Ldr->InLoadOrderModuleList; + Entry = ModuleListHead->Flink; + while (Entry != ModuleListHead) + { + Module = CONTAINING_RECORD(Entry, LDR_DATA_TABLE_ENTRY, InLoadOrderLinks); + if (Module->LoadCount == LDRP_PROCESS_CREATION_TIME && + Module->TlsIndex != 0xFFFF) + { + TlsDirectory = (PIMAGE_TLS_DIRECTORY) + RtlImageDirectoryEntryToData(Module->DllBase, + TRUE, + IMAGE_DIRECTORY_ENTRY_TLS, + &Size); + ASSERT(Module->TlsIndex < LdrpTlsCount); + TlsData = &LdrpTlsArray[Module->TlsIndex]; + TlsData->StartAddressOfRawData = (PVOID)TlsDirectory->StartAddressOfRawData; + TlsData->TlsDataSize = TlsDirectory->EndAddressOfRawData - TlsDirectory->StartAddressOfRawData; + TlsData->TlsZeroSize = TlsDirectory->SizeOfZeroFill; + if (TlsDirectory->AddressOfCallBacks) + TlsData->TlsAddressOfCallBacks = (PIMAGE_TLS_CALLBACK *)TlsDirectory->AddressOfCallBacks; + else + TlsData->TlsAddressOfCallBacks = NULL; + TlsData->Module = Module; #if 0 - DbgPrint("TLS directory for %wZ\n", &Module->BaseDllName); - DbgPrint("StartAddressOfRawData: %x\n", TlsDirectory->StartAddressOfRawData); - DbgPrint("EndAddressOfRawData: %x\n", TlsDirectory->EndAddressOfRawData); - DbgPrint("SizeOfRawData: %d\n", TlsDirectory->EndAddressOfRawData - TlsDirectory->StartAddressOfRawData); - DbgPrint("AddressOfIndex: %x\n", TlsDirectory->AddressOfIndex); - DbgPrint("AddressOfCallBacks: %x\n", TlsDirectory->AddressOfCallBacks); - DbgPrint("SizeOfZeroFill: %d\n", TlsDirectory->SizeOfZeroFill); - DbgPrint("Characteristics: %x\n", TlsDirectory->Characteristics); + DbgPrint("TLS directory for %wZ\n", &Module->BaseDllName); + DbgPrint("StartAddressOfRawData: %x\n", TlsDirectory->StartAddressOfRawData); + DbgPrint("EndAddressOfRawData: %x\n", TlsDirectory->EndAddressOfRawData); + DbgPrint("SizeOfRawData: %d\n", TlsDirectory->EndAddressOfRawData - TlsDirectory->StartAddressOfRawData); + DbgPrint("AddressOfIndex: %x\n", TlsDirectory->AddressOfIndex); + DbgPrint("AddressOfCallBacks: %x\n", TlsDirectory->AddressOfCallBacks); + DbgPrint("SizeOfZeroFill: %d\n", TlsDirectory->SizeOfZeroFill); + DbgPrint("Characteristics: %x\n", TlsDirectory->Characteristics); #endif - /* - * FIXME: - * Is this region allways writable ? - */ - *(PULONG)TlsDirectory->AddressOfIndex = Module->TlsIndex; - } - Entry = Entry->Flink; + /* + * FIXME: + * Is this region allways writable ? + */ + *(PULONG)TlsDirectory->AddressOfIndex = Module->TlsIndex; + } + Entry = Entry->Flink; } } - DPRINT("LdrpInitializeTlsForProccess() done\n"); - return STATUS_SUCCESS; + DPRINT("LdrpInitializeTlsForProccess() done\n"); + return STATUS_SUCCESS; } VOID LdrpInitLoader(VOID) { - OBJECT_ATTRIBUTES ObjectAttributes; - UNICODE_STRING LinkTarget; - UNICODE_STRING Name; - HANDLE LinkHandle; - ULONG Length; - NTSTATUS Status; + OBJECT_ATTRIBUTES ObjectAttributes; + UNICODE_STRING LinkTarget; + UNICODE_STRING Name; + HANDLE LinkHandle; + ULONG Length; + NTSTATUS Status; - DPRINT("LdrpInitLoader() called for %wZ\n", &ExeModule->BaseDllName); + DPRINT("LdrpInitLoader() called for %wZ\n", &ExeModule->BaseDllName); - /* Get handle to the 'KnownDlls' directory */ - RtlInitUnicodeString(&Name, - L"\\KnownDlls"); - InitializeObjectAttributes(&ObjectAttributes, - &Name, - OBJ_CASE_INSENSITIVE, - NULL, - NULL); - Status = NtOpenDirectoryObject(&LdrpKnownDllsDirHandle, - DIRECTORY_QUERY | DIRECTORY_TRAVERSE, - &ObjectAttributes); - if (!NT_SUCCESS(Status)) + /* Get handle to the 'KnownDlls' directory */ + RtlInitUnicodeString(&Name, + L"\\KnownDlls"); + InitializeObjectAttributes(&ObjectAttributes, + &Name, + OBJ_CASE_INSENSITIVE, + NULL, + NULL); + Status = NtOpenDirectoryObject(&LdrpKnownDllsDirHandle, + DIRECTORY_QUERY | DIRECTORY_TRAVERSE, + &ObjectAttributes); + if (!NT_SUCCESS(Status)) { - DPRINT("NtOpenDirectoryObject() failed (Status %lx)\n", Status); - LdrpKnownDllsDirHandle = NULL; - return; + DPRINT("NtOpenDirectoryObject() failed (Status %lx)\n", Status); + LdrpKnownDllsDirHandle = NULL; + return; } - /* Allocate target name string */ - LinkTarget.Length = 0; - LinkTarget.MaximumLength = MAX_PATH * sizeof(WCHAR); - LinkTarget.Buffer = RtlAllocateHeap(RtlGetProcessHeap(), - 0, - MAX_PATH * sizeof(WCHAR)); - if (LinkTarget.Buffer == NULL) + /* Allocate target name string */ + LinkTarget.Length = 0; + LinkTarget.MaximumLength = MAX_PATH * sizeof(WCHAR); + LinkTarget.Buffer = RtlAllocateHeap(RtlGetProcessHeap(), + 0, + MAX_PATH * sizeof(WCHAR)); + if (LinkTarget.Buffer == NULL) { - NtClose(LdrpKnownDllsDirHandle); - LdrpKnownDllsDirHandle = NULL; - return; + NtClose(LdrpKnownDllsDirHandle); + LdrpKnownDllsDirHandle = NULL; + return; } - RtlInitUnicodeString(&Name, - L"KnownDllPath"); - InitializeObjectAttributes(&ObjectAttributes, - &Name, - OBJ_CASE_INSENSITIVE, - LdrpKnownDllsDirHandle, - NULL); - Status = NtOpenSymbolicLinkObject(&LinkHandle, - SYMBOLIC_LINK_ALL_ACCESS, - &ObjectAttributes); - if (!NT_SUCCESS(Status)) + RtlInitUnicodeString(&Name, + L"KnownDllPath"); + InitializeObjectAttributes(&ObjectAttributes, + &Name, + OBJ_CASE_INSENSITIVE, + LdrpKnownDllsDirHandle, + NULL); + Status = NtOpenSymbolicLinkObject(&LinkHandle, + SYMBOLIC_LINK_ALL_ACCESS, + &ObjectAttributes); + if (!NT_SUCCESS(Status)) { - RtlFreeUnicodeString(&LinkTarget); - NtClose(LdrpKnownDllsDirHandle); - LdrpKnownDllsDirHandle = NULL; - return; + RtlFreeUnicodeString(&LinkTarget); + NtClose(LdrpKnownDllsDirHandle); + LdrpKnownDllsDirHandle = NULL; + return; } - Status = NtQuerySymbolicLinkObject(LinkHandle, - &LinkTarget, - &Length); - NtClose(LinkHandle); - if (!NT_SUCCESS(Status)) + Status = NtQuerySymbolicLinkObject(LinkHandle, + &LinkTarget, + &Length); + NtClose(LinkHandle); + if (!NT_SUCCESS(Status)) { - RtlFreeUnicodeString(&LinkTarget); - NtClose(LdrpKnownDllsDirHandle); - LdrpKnownDllsDirHandle = NULL; + RtlFreeUnicodeString(&LinkTarget); + NtClose(LdrpKnownDllsDirHandle); + LdrpKnownDllsDirHandle = NULL; } - RtlCreateUnicodeString(&LdrpKnownDllPath, - LinkTarget.Buffer); + RtlCreateUnicodeString(&LdrpKnownDllPath, + LinkTarget.Buffer); - RtlFreeUnicodeString(&LinkTarget); + RtlFreeUnicodeString(&LinkTarget); - DPRINT("LdrpInitLoader() done\n"); + DPRINT("LdrpInitLoader() done\n"); } @@ -502,53 +502,53 @@ LdrAdjustDllName (PUNICODE_STRING FullDllName, PUNICODE_STRING DllName, BOOLEAN BaseName) { - WCHAR Buffer[MAX_PATH]; - ULONG Length; - PWCHAR Extension; - PWCHAR Pointer; + WCHAR Buffer[MAX_PATH]; + ULONG Length; + PWCHAR Extension; + PWCHAR Pointer; - Length = DllName->Length / sizeof(WCHAR); + Length = DllName->Length / sizeof(WCHAR); - if (BaseName) - { + if (BaseName) + { /* get the base dll name */ Pointer = DllName->Buffer + Length; Extension = Pointer; do - { - --Pointer; - } + { + --Pointer; + } while (Pointer >= DllName->Buffer && *Pointer != L'\\' && *Pointer != L'/'); Pointer++; Length = Extension - Pointer; memmove (Buffer, Pointer, Length * sizeof(WCHAR)); Buffer[Length] = L'\0'; - } - else - { + } + else + { /* get the full dll name */ memmove (Buffer, DllName->Buffer, DllName->Length); Buffer[DllName->Length / sizeof(WCHAR)] = L'\0'; - } + } - /* Build the DLL's absolute name */ - Extension = wcsrchr (Buffer, L'.'); - if ((Extension != NULL) && (*Extension == L'.')) - { + /* Build the DLL's absolute name */ + Extension = wcsrchr (Buffer, L'.'); + if ((Extension != NULL) && (*Extension == L'.')) + { /* with extension - remove dot if it's the last character */ if (Buffer[Length - 1] == L'.') - Length--; + Length--; Buffer[Length] = 0; - } - else - { + } + else + { /* name without extension - assume that it is .dll */ memmove (Buffer + Length, L".dll", 10); - } + } - RtlCreateUnicodeString(FullDllName, Buffer); + RtlCreateUnicodeString(FullDllName, Buffer); } PLDR_DATA_TABLE_ENTRY @@ -556,45 +556,47 @@ LdrAddModuleEntry(PVOID ImageBase, PIMAGE_NT_HEADERS NTHeaders, PWSTR FullDosName) { - PLDR_DATA_TABLE_ENTRY Module; + PLDR_DATA_TABLE_ENTRY Module; - Module = RtlAllocateHeap(RtlGetProcessHeap(), 0, sizeof (LDR_DATA_TABLE_ENTRY)); - ASSERT(Module); - memset(Module, 0, sizeof(LDR_DATA_TABLE_ENTRY)); - Module->DllBase = (PVOID)ImageBase; - Module->EntryPoint = (PVOID)NTHeaders->OptionalHeader.AddressOfEntryPoint; - if (Module->EntryPoint != 0) - Module->EntryPoint = (PVOID)((ULONG_PTR)Module->EntryPoint + (ULONG_PTR)Module->DllBase); - Module->SizeOfImage = LdrpGetResidentSize(NTHeaders); - if (NtCurrentPeb()->Ldr->Initialized == TRUE) + Module = RtlAllocateHeap(RtlGetProcessHeap(), 0, sizeof (LDR_DATA_TABLE_ENTRY)); + ASSERT(Module); + memset(Module, 0, sizeof(LDR_DATA_TABLE_ENTRY)); + Module->DllBase = (PVOID)ImageBase; + Module->EntryPoint = (PVOID)NTHeaders->OptionalHeader.AddressOfEntryPoint; + if (Module->EntryPoint != 0) + Module->EntryPoint = (PVOID)((ULONG_PTR)Module->EntryPoint + (ULONG_PTR)Module->DllBase); + Module->SizeOfImage = LdrpGetResidentSize(NTHeaders); + if (NtCurrentPeb()->Ldr->Initialized == TRUE) { - /* loading while app is running */ - Module->LoadCount = 1; - } else { - /* - * loading while app is initializing - * dll must not be unloaded - */ - Module->LoadCount = LDRP_PROCESS_CREATION_TIME; + /* loading while app is running */ + Module->LoadCount = 1; + } + else + { + /* + * loading while app is initializing + * dll must not be unloaded + */ + Module->LoadCount = LDRP_PROCESS_CREATION_TIME; } - Module->Flags = 0; - Module->TlsIndex = -1; - Module->CheckSum = NTHeaders->OptionalHeader.CheckSum; - Module->TimeDateStamp = NTHeaders->FileHeader.TimeDateStamp; + Module->Flags = 0; + Module->TlsIndex = -1; + Module->CheckSum = NTHeaders->OptionalHeader.CheckSum; + Module->TimeDateStamp = NTHeaders->FileHeader.TimeDateStamp; - RtlCreateUnicodeString (&Module->FullDllName, - FullDosName); - RtlCreateUnicodeString (&Module->BaseDllName, - wcsrchr(FullDosName, L'\\') + 1); - DPRINT ("BaseDllName %wZ\n", &Module->BaseDllName); + RtlCreateUnicodeString (&Module->FullDllName, + FullDosName); + RtlCreateUnicodeString (&Module->BaseDllName, + wcsrchr(FullDosName, L'\\') + 1); + DPRINT ("BaseDllName %wZ\n", &Module->BaseDllName); - RtlEnterCriticalSection (NtCurrentPeb()->LoaderLock); - InsertTailList(&NtCurrentPeb()->Ldr->InLoadOrderModuleList, - &Module->InLoadOrderLinks); - RtlLeaveCriticalSection(NtCurrentPeb()->LoaderLock); + RtlEnterCriticalSection (NtCurrentPeb()->LoaderLock); + InsertTailList(&NtCurrentPeb()->Ldr->InLoadOrderModuleList, + &Module->InLoadOrderLinks); + RtlLeaveCriticalSection(NtCurrentPeb()->LoaderLock); - return(Module); + return(Module); } @@ -603,54 +605,54 @@ LdrpMapKnownDll(IN PUNICODE_STRING DllName, OUT PUNICODE_STRING FullDosName, OUT PHANDLE SectionHandle) { - OBJECT_ATTRIBUTES ObjectAttributes; - NTSTATUS Status; + OBJECT_ATTRIBUTES ObjectAttributes; + NTSTATUS Status; - DPRINT("LdrpMapKnownDll() called\n"); + DPRINT("LdrpMapKnownDll() called\n"); - if (LdrpKnownDllsDirHandle == NULL) + if (LdrpKnownDllsDirHandle == NULL) { - DPRINT("Invalid 'KnownDlls' directory\n"); - return STATUS_UNSUCCESSFUL; + DPRINT("Invalid 'KnownDlls' directory\n"); + return STATUS_UNSUCCESSFUL; } - DPRINT("LdrpKnownDllPath '%wZ'\n", &LdrpKnownDllPath); + DPRINT("LdrpKnownDllPath '%wZ'\n", &LdrpKnownDllPath); - InitializeObjectAttributes(&ObjectAttributes, - DllName, - OBJ_CASE_INSENSITIVE, - LdrpKnownDllsDirHandle, - NULL); - Status = NtOpenSection(SectionHandle, - SECTION_MAP_READ | SECTION_MAP_WRITE | SECTION_MAP_EXECUTE, - &ObjectAttributes); - if (!NT_SUCCESS(Status)) + InitializeObjectAttributes(&ObjectAttributes, + DllName, + OBJ_CASE_INSENSITIVE, + LdrpKnownDllsDirHandle, + NULL); + Status = NtOpenSection(SectionHandle, + SECTION_MAP_READ | SECTION_MAP_WRITE | SECTION_MAP_EXECUTE, + &ObjectAttributes); + if (!NT_SUCCESS(Status)) { - DPRINT("NtOpenSection() failed for '%wZ' (Status 0x%08lx)\n", DllName, Status); - return Status; + DPRINT("NtOpenSection() failed for '%wZ' (Status 0x%08lx)\n", DllName, Status); + return Status; } - FullDosName->Length = LdrpKnownDllPath.Length + DllName->Length + sizeof(WCHAR); - FullDosName->MaximumLength = FullDosName->Length + sizeof(WCHAR); - FullDosName->Buffer = RtlAllocateHeap(RtlGetProcessHeap(), - 0, - FullDosName->MaximumLength); - if (FullDosName->Buffer == NULL) + FullDosName->Length = LdrpKnownDllPath.Length + DllName->Length + sizeof(WCHAR); + FullDosName->MaximumLength = FullDosName->Length + sizeof(WCHAR); + FullDosName->Buffer = RtlAllocateHeap(RtlGetProcessHeap(), + 0, + FullDosName->MaximumLength); + if (FullDosName->Buffer == NULL) { - FullDosName->Length = 0; - FullDosName->MaximumLength = 0; - return STATUS_SUCCESS; + FullDosName->Length = 0; + FullDosName->MaximumLength = 0; + return STATUS_SUCCESS; } - wcscpy(FullDosName->Buffer, LdrpKnownDllPath.Buffer); - wcscat(FullDosName->Buffer, L"\\"); - wcscat(FullDosName->Buffer, DllName->Buffer); + wcscpy(FullDosName->Buffer, LdrpKnownDllPath.Buffer); + wcscat(FullDosName->Buffer, L"\\"); + wcscat(FullDosName->Buffer, DllName->Buffer); - DPRINT("FullDosName '%wZ'\n", FullDosName); + DPRINT("FullDosName '%wZ'\n", FullDosName); - DPRINT("LdrpMapKnownDll() done\n"); + DPRINT("LdrpMapKnownDll() done\n"); - return STATUS_SUCCESS; + return STATUS_SUCCESS; } @@ -661,216 +663,216 @@ LdrpMapDllImageFile(IN PWSTR SearchPath OPTIONAL, IN BOOLEAN MapAsDataFile, OUT PHANDLE SectionHandle) { - WCHAR *SearchPathBuffer = NULL; - WCHAR *ImagePathNameBufferPtr = NULL; - WCHAR DosName[MAX_PATH]; - UNICODE_STRING FullNtFileName; - UNICODE_STRING PathEnvironmentVar_U; - UNICODE_STRING PathName_U; - OBJECT_ATTRIBUTES FileObjectAttributes; - HANDLE FileHandle; - char BlockBuffer [1024]; - PIMAGE_DOS_HEADER DosHeader; - PIMAGE_NT_HEADERS NTHeaders; - IO_STATUS_BLOCK IoStatusBlock; - NTSTATUS Status; - ULONG len; - ULONG ImagePathLen; + WCHAR *SearchPathBuffer = NULL; + WCHAR *ImagePathNameBufferPtr = NULL; + WCHAR DosName[MAX_PATH]; + UNICODE_STRING FullNtFileName; + UNICODE_STRING PathEnvironmentVar_U; + UNICODE_STRING PathName_U; + OBJECT_ATTRIBUTES FileObjectAttributes; + HANDLE FileHandle; + char BlockBuffer [1024]; + PIMAGE_DOS_HEADER DosHeader; + PIMAGE_NT_HEADERS NTHeaders; + IO_STATUS_BLOCK IoStatusBlock; + NTSTATUS Status; + ULONG len; + ULONG ImagePathLen; - DPRINT("LdrpMapDllImageFile() called\n"); + DPRINT("LdrpMapDllImageFile() called\n"); - if (SearchPath == NULL) + if (SearchPath == NULL) { - /* get application running path */ - ImagePathNameBufferPtr = NtCurrentPeb()->ProcessParameters->ImagePathName.Buffer; + /* get application running path */ + ImagePathNameBufferPtr = NtCurrentPeb()->ProcessParameters->ImagePathName.Buffer; - /* Length of ImagePathName */ - ImagePathLen = wcslen(ImagePathNameBufferPtr); + /* Length of ImagePathName */ + ImagePathLen = wcslen(ImagePathNameBufferPtr); - /* Subtract application name leaveing only the directory length */ - while (ImagePathLen && ImagePathNameBufferPtr[ImagePathLen - 1] != L'\\') - ImagePathLen--; + /* Subtract application name leaveing only the directory length */ + while (ImagePathLen && ImagePathNameBufferPtr[ImagePathLen - 1] != L'\\') + ImagePathLen--; - /* Length of directory + semicolon */ - len = ImagePathLen + 1; + /* Length of directory + semicolon */ + len = ImagePathLen + 1; - /* Length of SystemRoot + "//system32" + semicolon*/ - len += wcslen(SharedUserData->NtSystemRoot) + 10; - /* Length of SystemRoot + semicolon */ - len += wcslen(SharedUserData->NtSystemRoot) + 1; + /* Length of SystemRoot + "//system32" + semicolon*/ + len += wcslen(SharedUserData->NtSystemRoot) + 10; + /* Length of SystemRoot + semicolon */ + len += wcslen(SharedUserData->NtSystemRoot) + 1; - RtlInitUnicodeString (&PathName_U, L"PATH"); - PathEnvironmentVar_U.Length = 0; - PathEnvironmentVar_U.MaximumLength = 0; - PathEnvironmentVar_U.Buffer = NULL; + RtlInitUnicodeString (&PathName_U, L"PATH"); + PathEnvironmentVar_U.Length = 0; + PathEnvironmentVar_U.MaximumLength = 0; + PathEnvironmentVar_U.Buffer = NULL; - /* Get the path environment variable */ - Status = RtlQueryEnvironmentVariable_U(NULL, &PathName_U, &PathEnvironmentVar_U); + /* Get the path environment variable */ + Status = RtlQueryEnvironmentVariable_U(NULL, &PathName_U, &PathEnvironmentVar_U); - /* Check that valid information was returned */ - if ((Status == STATUS_BUFFER_TOO_SMALL) && (PathEnvironmentVar_U.Length > 0)) + /* Check that valid information was returned */ + if ((Status == STATUS_BUFFER_TOO_SMALL) && (PathEnvironmentVar_U.Length > 0)) { - /* Allocate memory for the path env var */ - PathEnvironmentVar_U.Buffer = RtlAllocateHeap(RtlGetProcessHeap(), HEAP_ZERO_MEMORY, PathEnvironmentVar_U.Length + sizeof(WCHAR)); - if (!PathEnvironmentVar_U.Buffer) + /* Allocate memory for the path env var */ + PathEnvironmentVar_U.Buffer = RtlAllocateHeap(RtlGetProcessHeap(), HEAP_ZERO_MEMORY, PathEnvironmentVar_U.Length + sizeof(WCHAR)); + if (!PathEnvironmentVar_U.Buffer) { - DPRINT1("Fatal! Out of Memory!!\n"); - return STATUS_NO_MEMORY; + DPRINT1("Fatal! Out of Memory!!\n"); + return STATUS_NO_MEMORY; } - PathEnvironmentVar_U.MaximumLength = PathEnvironmentVar_U.Length + sizeof(WCHAR); + PathEnvironmentVar_U.MaximumLength = PathEnvironmentVar_U.Length + sizeof(WCHAR); - /* Retry */ - Status = RtlQueryEnvironmentVariable_U(NULL, &PathName_U, &PathEnvironmentVar_U); + /* Retry */ + Status = RtlQueryEnvironmentVariable_U(NULL, &PathName_U, &PathEnvironmentVar_U); - if (!NT_SUCCESS(Status)) + if (!NT_SUCCESS(Status)) { - DPRINT1("Unable to get path environment string!\n"); - ASSERT(FALSE); + DPRINT1("Unable to get path environment string!\n"); + ASSERT(FALSE); } - /* Length of path evn var + semicolon */ - len += (PathEnvironmentVar_U.Length / sizeof(WCHAR)) + 1; + /* Length of path evn var + semicolon */ + len += (PathEnvironmentVar_U.Length / sizeof(WCHAR)) + 1; } - /* Allocate the size needed to hold all the above paths + period */ - SearchPathBuffer = RtlAllocateHeap(RtlGetProcessHeap(), HEAP_ZERO_MEMORY, (len + 2) * sizeof(WCHAR)); - if (!SearchPathBuffer) + /* Allocate the size needed to hold all the above paths + period */ + SearchPathBuffer = RtlAllocateHeap(RtlGetProcessHeap(), HEAP_ZERO_MEMORY, (len + 2) * sizeof(WCHAR)); + if (!SearchPathBuffer) { - DPRINT1("Fatal! Out of Memory!!\n"); - return STATUS_NO_MEMORY; + DPRINT1("Fatal! Out of Memory!!\n"); + return STATUS_NO_MEMORY; } - wcsncpy(SearchPathBuffer, ImagePathNameBufferPtr, ImagePathLen); - wcscat (SearchPathBuffer, L";"); - wcscat (SearchPathBuffer, SharedUserData->NtSystemRoot); - wcscat (SearchPathBuffer, L"\\system32;"); - wcscat (SearchPathBuffer, SharedUserData->NtSystemRoot); - wcscat (SearchPathBuffer, L";"); + wcsncpy(SearchPathBuffer, ImagePathNameBufferPtr, ImagePathLen); + wcscat (SearchPathBuffer, L";"); + wcscat (SearchPathBuffer, SharedUserData->NtSystemRoot); + wcscat (SearchPathBuffer, L"\\system32;"); + wcscat (SearchPathBuffer, SharedUserData->NtSystemRoot); + wcscat (SearchPathBuffer, L";"); - if (PathEnvironmentVar_U.Buffer) + if (PathEnvironmentVar_U.Buffer) { - wcscat (SearchPathBuffer, PathEnvironmentVar_U.Buffer); - wcscat (SearchPathBuffer, L";"); - RtlFreeHeap(RtlGetProcessHeap(), 0, PathEnvironmentVar_U.Buffer); + wcscat (SearchPathBuffer, PathEnvironmentVar_U.Buffer); + wcscat (SearchPathBuffer, L";"); + RtlFreeHeap(RtlGetProcessHeap(), 0, PathEnvironmentVar_U.Buffer); } - wcscat (SearchPathBuffer, L"."); + wcscat (SearchPathBuffer, L"."); - SearchPath = SearchPathBuffer; + SearchPath = SearchPathBuffer; } - if (RtlDosSearchPath_U (SearchPath, - DllName->Buffer, - NULL, - MAX_PATH, - DosName, - NULL) == 0) - { - /* try to find active context dll */ - Status = find_actctx_dll(DllName->Buffer, DosName); - if(Status == STATUS_SUCCESS) - DPRINT("found %S for %S\n", DosName,DllName->Buffer); - else + if (RtlDosSearchPath_U (SearchPath, + DllName->Buffer, + NULL, + MAX_PATH, + DosName, + NULL) == 0) + { + /* try to find active context dll */ + Status = find_actctx_dll(DllName->Buffer, DosName); + if(Status == STATUS_SUCCESS) + DPRINT("found %S for %S\n", DosName,DllName->Buffer); + else + return STATUS_DLL_NOT_FOUND; + } + + if (!RtlDosPathNameToNtPathName_U (DosName, + &FullNtFileName, + NULL, + NULL)) + { + DPRINT("Dll %wZ not found!\n", DllName); return STATUS_DLL_NOT_FOUND; - } + } - if (!RtlDosPathNameToNtPathName_U (DosName, - &FullNtFileName, - NULL, - NULL)) - { - DPRINT("Dll %wZ not found!\n", DllName); - return STATUS_DLL_NOT_FOUND; - } + DPRINT("FullNtFileName %wZ\n", &FullNtFileName); - DPRINT("FullNtFileName %wZ\n", &FullNtFileName); + InitializeObjectAttributes(&FileObjectAttributes, + &FullNtFileName, + 0, + NULL, + NULL); - InitializeObjectAttributes(&FileObjectAttributes, - &FullNtFileName, - 0, + DPRINT("Opening dll \"%wZ\"\n", &FullNtFileName); + + Status = NtOpenFile(&FileHandle, + GENERIC_READ|SYNCHRONIZE, + &FileObjectAttributes, + &IoStatusBlock, + FILE_SHARE_READ, + FILE_SYNCHRONOUS_IO_NONALERT); + if (!NT_SUCCESS(Status)) + { + DPRINT1("Dll open of %wZ failed: Status = 0x%08lx\n", + &FullNtFileName, Status); + RtlFreeHeap (RtlGetProcessHeap (), + 0, + FullNtFileName.Buffer); + return Status; + } + RtlFreeHeap (RtlGetProcessHeap (), + 0, + FullNtFileName.Buffer); + + if (!MapAsDataFile) + { + + Status = NtReadFile(FileHandle, + NULL, + NULL, + NULL, + &IoStatusBlock, + BlockBuffer, + sizeof(BlockBuffer), + NULL, + NULL); + if (!NT_SUCCESS(Status)) + { + DPRINT("Dll header read failed: Status = 0x%08lx\n", Status); + NtClose(FileHandle); + return Status; + } + + /* + * Overlay DOS and NT headers structures to the + * buffer with DLL's header raw data. + */ + DosHeader = (PIMAGE_DOS_HEADER) BlockBuffer; + NTHeaders = (PIMAGE_NT_HEADERS) (BlockBuffer + DosHeader->e_lfanew); + /* + * Check it is a PE image file. + */ + if ((DosHeader->e_magic != IMAGE_DOS_SIGNATURE) + || (DosHeader->e_lfanew == 0L) + || (*(PULONG)(NTHeaders) != IMAGE_NT_SIGNATURE)) + { + DPRINT("NTDLL format invalid\n"); + NtClose(FileHandle); + + return STATUS_UNSUCCESSFUL; + } + } + + /* + * Create a section for dll. + */ + Status = NtCreateSection(SectionHandle, + SECTION_ALL_ACCESS, NULL, - NULL); + NULL, + PAGE_READONLY, + MapAsDataFile ? SEC_COMMIT : SEC_IMAGE, + FileHandle); + NtClose(FileHandle); - DPRINT("Opening dll \"%wZ\"\n", &FullNtFileName); - - Status = NtOpenFile(&FileHandle, - GENERIC_READ|SYNCHRONIZE, - &FileObjectAttributes, - &IoStatusBlock, - FILE_SHARE_READ, - FILE_SYNCHRONOUS_IO_NONALERT); - if (!NT_SUCCESS(Status)) + if (!NT_SUCCESS(Status)) { - DPRINT1("Dll open of %wZ failed: Status = 0x%08lx\n", - &FullNtFileName, Status); - RtlFreeHeap (RtlGetProcessHeap (), - 0, - FullNtFileName.Buffer); - return Status; - } - RtlFreeHeap (RtlGetProcessHeap (), - 0, - FullNtFileName.Buffer); - - if (!MapAsDataFile) - { - - Status = NtReadFile(FileHandle, - NULL, - NULL, - NULL, - &IoStatusBlock, - BlockBuffer, - sizeof(BlockBuffer), - NULL, - NULL); - if (!NT_SUCCESS(Status)) - { - DPRINT("Dll header read failed: Status = 0x%08lx\n", Status); - NtClose(FileHandle); - return Status; - } - - /* - * Overlay DOS and NT headers structures to the - * buffer with DLL's header raw data. - */ - DosHeader = (PIMAGE_DOS_HEADER) BlockBuffer; - NTHeaders = (PIMAGE_NT_HEADERS) (BlockBuffer + DosHeader->e_lfanew); - /* - * Check it is a PE image file. - */ - if ((DosHeader->e_magic != IMAGE_DOS_SIGNATURE) - || (DosHeader->e_lfanew == 0L) - || (*(PULONG)(NTHeaders) != IMAGE_NT_SIGNATURE)) - { - DPRINT("NTDLL format invalid\n"); - NtClose(FileHandle); - - return STATUS_UNSUCCESSFUL; - } + DPRINT("NTDLL create section failed: Status = 0x%08lx\n", Status); + return Status; } - /* - * Create a section for dll. - */ - Status = NtCreateSection(SectionHandle, - SECTION_ALL_ACCESS, - NULL, - NULL, - PAGE_READONLY, - MapAsDataFile ? SEC_COMMIT : SEC_IMAGE, - FileHandle); - NtClose(FileHandle); + RtlCreateUnicodeString(FullDosName, + DosName); - if (!NT_SUCCESS(Status)) - { - DPRINT("NTDLL create section failed: Status = 0x%08lx\n", Status); - return Status; - } - - RtlCreateUnicodeString(FullDosName, - DosName); - - return Status; + return Status; } @@ -897,42 +899,42 @@ LdrLoadDll (IN PWSTR SearchPath OPTIONAL, IN PUNICODE_STRING Name, OUT PVOID *BaseAddress /* also known as HMODULE*, and PHANDLE 'DllHandle' */) { - NTSTATUS Status; - PLDR_DATA_TABLE_ENTRY Module; - ULONG_PTR cookie; - PPEB Peb = NtCurrentPeb(); + NTSTATUS Status; + PLDR_DATA_TABLE_ENTRY Module; + ULONG_PTR cookie; + PPEB Peb = NtCurrentPeb(); - TRACE_LDR("LdrLoadDll loading %wZ%S%S with flags %d\n", - Name, - SearchPath ? L" from " : L"", - SearchPath ? SearchPath : L"", - LoadFlags ? *LoadFlags : 0); + TRACE_LDR("LdrLoadDll loading %wZ%S%S with flags %d\n", + Name, + SearchPath ? L" from " : L"", + SearchPath ? SearchPath : L"", + LoadFlags ? *LoadFlags : 0); - Status = LdrpLoadModule(SearchPath, LoadFlags ? *LoadFlags : 0, Name, &Module, BaseAddress); + Status = LdrpLoadModule(SearchPath, LoadFlags ? *LoadFlags : 0, Name, &Module, BaseAddress); - if (NT_SUCCESS(Status) && - (!LoadFlags || 0 == (*LoadFlags & LOAD_LIBRARY_AS_DATAFILE))) + if (NT_SUCCESS(Status) && + (!LoadFlags || 0 == (*LoadFlags & LOAD_LIBRARY_AS_DATAFILE))) { - if (!create_module_activation_context( Module )) - { - RtlActivateActivationContext(0, Module->EntryPointActivationContext, &cookie); - } - - if (!(Module->Flags & LDRP_PROCESS_ATTACH_CALLED)) + if (!create_module_activation_context( Module )) { - RtlEnterCriticalSection(Peb->LoaderLock); - Status = LdrpAttachProcess(); - RtlLeaveCriticalSection(Peb->LoaderLock); + RtlActivateActivationContext(0, Module->EntryPointActivationContext, &cookie); } - if (Module->EntryPointActivationContext) RtlDeactivateActivationContext(0, cookie); + + if (!(Module->Flags & LDRP_PROCESS_ATTACH_CALLED)) + { + RtlEnterCriticalSection(Peb->LoaderLock); + Status = LdrpAttachProcess(); + RtlLeaveCriticalSection(Peb->LoaderLock); + } + if (Module->EntryPointActivationContext) RtlDeactivateActivationContext(0, cookie); } - if ((!Module) && (NT_SUCCESS(Status))) + if ((!Module) && (NT_SUCCESS(Status))) + return Status; + + *BaseAddress = NT_SUCCESS(Status) ? Module->DllBase : NULL; + return Status; - - *BaseAddress = NT_SUCCESS(Status) ? Module->DllBase : NULL; - - return Status; } @@ -956,45 +958,45 @@ NTSTATUS NTAPI LdrFindEntryForAddress(PVOID Address, PLDR_DATA_TABLE_ENTRY *Module) { - PLIST_ENTRY ModuleListHead; - PLIST_ENTRY Entry; - PLDR_DATA_TABLE_ENTRY ModulePtr; + PLIST_ENTRY ModuleListHead; + PLIST_ENTRY Entry; + PLDR_DATA_TABLE_ENTRY ModulePtr; - DPRINT("LdrFindEntryForAddress(Address %p)\n", Address); + DPRINT("LdrFindEntryForAddress(Address %p)\n", Address); - if (NtCurrentPeb()->Ldr == NULL) - return(STATUS_NO_MORE_ENTRIES); + if (NtCurrentPeb()->Ldr == NULL) + return(STATUS_NO_MORE_ENTRIES); - RtlEnterCriticalSection(NtCurrentPeb()->LoaderLock); - ModuleListHead = &NtCurrentPeb()->Ldr->InLoadOrderModuleList; - Entry = ModuleListHead->Flink; - if (Entry == ModuleListHead) + RtlEnterCriticalSection(NtCurrentPeb()->LoaderLock); + ModuleListHead = &NtCurrentPeb()->Ldr->InLoadOrderModuleList; + Entry = ModuleListHead->Flink; + if (Entry == ModuleListHead) { - RtlLeaveCriticalSection(NtCurrentPeb()->LoaderLock); - return(STATUS_NO_MORE_ENTRIES); + RtlLeaveCriticalSection(NtCurrentPeb()->LoaderLock); + return(STATUS_NO_MORE_ENTRIES); } - while (Entry != ModuleListHead) + while (Entry != ModuleListHead) { - ModulePtr = CONTAINING_RECORD(Entry, LDR_DATA_TABLE_ENTRY, InLoadOrderLinks); + ModulePtr = CONTAINING_RECORD(Entry, LDR_DATA_TABLE_ENTRY, InLoadOrderLinks); - DPRINT("Scanning %wZ at %p\n", &ModulePtr->BaseDllName, ModulePtr->DllBase); + DPRINT("Scanning %wZ at %p\n", &ModulePtr->BaseDllName, ModulePtr->DllBase); - if ((Address >= ModulePtr->DllBase) && - ((ULONG_PTR)Address <= ((ULONG_PTR)ModulePtr->DllBase + ModulePtr->SizeOfImage))) + if ((Address >= ModulePtr->DllBase) && + ((ULONG_PTR)Address <= ((ULONG_PTR)ModulePtr->DllBase + ModulePtr->SizeOfImage))) { - *Module = ModulePtr; - RtlLeaveCriticalSection(NtCurrentPeb()->LoaderLock); - return(STATUS_SUCCESS); + *Module = ModulePtr; + RtlLeaveCriticalSection(NtCurrentPeb()->LoaderLock); + return(STATUS_SUCCESS); } - Entry = Entry->Flink; + Entry = Entry->Flink; } - DPRINT("Failed to find module entry.\n"); + DPRINT("Failed to find module entry.\n"); - RtlLeaveCriticalSection(NtCurrentPeb()->LoaderLock); - return(STATUS_NO_MORE_ENTRIES); + RtlLeaveCriticalSection(NtCurrentPeb()->LoaderLock); + return(STATUS_NO_MORE_ENTRIES); } @@ -1018,82 +1020,82 @@ LdrFindEntryForName(PUNICODE_STRING Name, PLDR_DATA_TABLE_ENTRY *Module, BOOLEAN Ref) { - PLIST_ENTRY ModuleListHead; - PLIST_ENTRY Entry; - PLDR_DATA_TABLE_ENTRY ModulePtr; - BOOLEAN ContainsPath; - UNICODE_STRING AdjustedName; + PLIST_ENTRY ModuleListHead; + PLIST_ENTRY Entry; + PLDR_DATA_TABLE_ENTRY ModulePtr; + BOOLEAN ContainsPath; + UNICODE_STRING AdjustedName; - DPRINT("LdrFindEntryForName(Name %wZ)\n", Name); + DPRINT("LdrFindEntryForName(Name %wZ)\n", Name); - if (NtCurrentPeb()->Ldr == NULL) + if (NtCurrentPeb()->Ldr == NULL) + return(STATUS_NO_MORE_ENTRIES); + + RtlEnterCriticalSection(NtCurrentPeb()->LoaderLock); + ModuleListHead = &NtCurrentPeb()->Ldr->InLoadOrderModuleList; + Entry = ModuleListHead->Flink; + if (Entry == ModuleListHead) + { + RtlLeaveCriticalSection(NtCurrentPeb()->LoaderLock); + return(STATUS_NO_MORE_ENTRIES); + } + + // NULL is the current process + if (Name == NULL) + { + *Module = ExeModule; + RtlLeaveCriticalSection(NtCurrentPeb()->LoaderLock); + return(STATUS_SUCCESS); + } + + ContainsPath = (Name->Length >= 2 * sizeof(WCHAR) && L':' == Name->Buffer[1]); + LdrAdjustDllName (&AdjustedName, Name, !ContainsPath); + + if (LdrpLastModule) + { + if ((!ContainsPath && + 0 == RtlCompareUnicodeString(&LdrpLastModule->BaseDllName, &AdjustedName, TRUE)) || + (ContainsPath && + 0 == RtlCompareUnicodeString(&LdrpLastModule->FullDllName, &AdjustedName, TRUE))) + { + *Module = LdrpLastModule; + if (Ref && (*Module)->LoadCount != LDRP_PROCESS_CREATION_TIME) + { + (*Module)->LoadCount++; + } + RtlLeaveCriticalSection(NtCurrentPeb()->LoaderLock); + RtlFreeUnicodeString(&AdjustedName); + return(STATUS_SUCCESS); + } + } + while (Entry != ModuleListHead) + { + ModulePtr = CONTAINING_RECORD(Entry, LDR_DATA_TABLE_ENTRY, InLoadOrderLinks); + + DPRINT("Scanning %wZ %wZ\n", &ModulePtr->BaseDllName, &AdjustedName); + + if ((!ContainsPath && + 0 == RtlCompareUnicodeString(&ModulePtr->BaseDllName, &AdjustedName, TRUE)) || + (ContainsPath && + 0 == RtlCompareUnicodeString(&ModulePtr->FullDllName, &AdjustedName, TRUE))) + { + *Module = LdrpLastModule = ModulePtr; + if (Ref && ModulePtr->LoadCount != LDRP_PROCESS_CREATION_TIME) + { + ModulePtr->LoadCount++; + } + RtlLeaveCriticalSection(NtCurrentPeb()->LoaderLock); + RtlFreeUnicodeString(&AdjustedName); + return(STATUS_SUCCESS); + } + + Entry = Entry->Flink; + } + + DPRINT("Failed to find dll %wZ\n", Name); + RtlLeaveCriticalSection(NtCurrentPeb()->LoaderLock); + RtlFreeUnicodeString(&AdjustedName); return(STATUS_NO_MORE_ENTRIES); - - RtlEnterCriticalSection(NtCurrentPeb()->LoaderLock); - ModuleListHead = &NtCurrentPeb()->Ldr->InLoadOrderModuleList; - Entry = ModuleListHead->Flink; - if (Entry == ModuleListHead) - { - RtlLeaveCriticalSection(NtCurrentPeb()->LoaderLock); - return(STATUS_NO_MORE_ENTRIES); - } - - // NULL is the current process - if (Name == NULL) - { - *Module = ExeModule; - RtlLeaveCriticalSection(NtCurrentPeb()->LoaderLock); - return(STATUS_SUCCESS); - } - - ContainsPath = (Name->Length >= 2 * sizeof(WCHAR) && L':' == Name->Buffer[1]); - LdrAdjustDllName (&AdjustedName, Name, !ContainsPath); - - if (LdrpLastModule) - { - if ((! ContainsPath && - 0 == RtlCompareUnicodeString(&LdrpLastModule->BaseDllName, &AdjustedName, TRUE)) || - (ContainsPath && - 0 == RtlCompareUnicodeString(&LdrpLastModule->FullDllName, &AdjustedName, TRUE))) - { - *Module = LdrpLastModule; - if (Ref && (*Module)->LoadCount != LDRP_PROCESS_CREATION_TIME) - { - (*Module)->LoadCount++; - } - RtlLeaveCriticalSection(NtCurrentPeb()->LoaderLock); - RtlFreeUnicodeString(&AdjustedName); - return(STATUS_SUCCESS); - } - } - while (Entry != ModuleListHead) - { - ModulePtr = CONTAINING_RECORD(Entry, LDR_DATA_TABLE_ENTRY, InLoadOrderLinks); - - DPRINT("Scanning %wZ %wZ\n", &ModulePtr->BaseDllName, &AdjustedName); - - if ((! ContainsPath && - 0 == RtlCompareUnicodeString(&ModulePtr->BaseDllName, &AdjustedName, TRUE)) || - (ContainsPath && - 0 == RtlCompareUnicodeString(&ModulePtr->FullDllName, &AdjustedName, TRUE))) - { - *Module = LdrpLastModule = ModulePtr; - if (Ref && ModulePtr->LoadCount != LDRP_PROCESS_CREATION_TIME) - { - ModulePtr->LoadCount++; - } - RtlLeaveCriticalSection(NtCurrentPeb()->LoaderLock); - RtlFreeUnicodeString(&AdjustedName); - return(STATUS_SUCCESS); - } - - Entry = Entry->Flink; - } - - DPRINT("Failed to find dll %wZ\n", Name); - RtlLeaveCriticalSection(NtCurrentPeb()->LoaderLock); - RtlFreeUnicodeString(&AdjustedName); - return(STATUS_NO_MORE_ENTRIES); } /********************************************************************** @@ -1114,17 +1116,17 @@ LdrFindEntryForName(PUNICODE_STRING Name, static PVOID LdrFixupForward(PCHAR ForwardName) { - CHAR NameBuffer[128]; - UNICODE_STRING DllName; - NTSTATUS Status; - PCHAR p; - PLDR_DATA_TABLE_ENTRY Module; - PVOID BaseAddress; + CHAR NameBuffer[128]; + UNICODE_STRING DllName; + NTSTATUS Status; + PCHAR p; + PLDR_DATA_TABLE_ENTRY Module; + PVOID BaseAddress; - strcpy(NameBuffer, ForwardName); - p = strchr(NameBuffer, '.'); - if (p != NULL) - { + strcpy(NameBuffer, ForwardName); + p = strchr(NameBuffer, '.'); + if (p != NULL) + { *p = 0; DPRINT("Dll: %s Function: %s\n", NameBuffer, p+1); @@ -1136,29 +1138,26 @@ LdrFixupForward(PCHAR ForwardName) * The caller (or the image) is responsible for loading of the dll, where the function is forwarded. */ if (!NT_SUCCESS(Status)) - { - Status = LdrLoadDll(NULL, - NULL, - &DllName, - &BaseAddress); - if (NT_SUCCESS(Status)) - { - Status = LdrFindEntryForName (&DllName, &Module, FALSE); - } - } + { + Status = LdrLoadDll(NULL, NULL, &DllName, &BaseAddress); + if (NT_SUCCESS(Status)) + { + Status = LdrFindEntryForName (&DllName, &Module, FALSE); + } + } RtlFreeUnicodeString (&DllName); if (!NT_SUCCESS(Status)) - { + { DPRINT1("LdrFixupForward: failed to load %s\n", NameBuffer); return NULL; - } + } DPRINT("BaseAddress: %p\n", Module->DllBase); return LdrGetExportByName(Module->DllBase, (PUCHAR)(p+1), -1); - } + } - return NULL; + return NULL; } @@ -1179,45 +1178,38 @@ LdrFixupForward(PCHAR ForwardName) */ static PVOID LdrGetExportByOrdinal ( - PVOID BaseAddress, - ULONG Ordinal - ) + PVOID BaseAddress, + ULONG Ordinal +) { - PIMAGE_EXPORT_DIRECTORY ExportDir; - ULONG ExportDirSize; - PDWORD * ExFunctions; - PVOID Function; + PIMAGE_EXPORT_DIRECTORY ExportDir; + ULONG ExportDirSize; + PDWORD * ExFunctions; + PVOID Function; - ExportDir = (PIMAGE_EXPORT_DIRECTORY) + ExportDir = (PIMAGE_EXPORT_DIRECTORY) RtlImageDirectoryEntryToData (BaseAddress, - TRUE, - IMAGE_DIRECTORY_ENTRY_EXPORT, - &ExportDirSize); + TRUE, + IMAGE_DIRECTORY_ENTRY_EXPORT, + &ExportDirSize); - ExFunctions = (PDWORD *) - RVA( - BaseAddress, - ExportDir->AddressOfFunctions - ); - DPRINT( - "LdrGetExportByOrdinal(Ordinal %lu) = %p\n", - Ordinal, - RVA(BaseAddress, ExFunctions[Ordinal - ExportDir->Base] ) - ); + ExFunctions = (PDWORD*)RVA(BaseAddress, ExportDir->AddressOfFunctions); + DPRINT("LdrGetExportByOrdinal(Ordinal %lu) = %p\n", + Ordinal, RVA(BaseAddress, ExFunctions[Ordinal - ExportDir->Base])); - Function = (0 != ExFunctions[Ordinal - ExportDir->Base] - ? RVA(BaseAddress, ExFunctions[Ordinal - ExportDir->Base] ) - : NULL); + Function = (0 != ExFunctions[Ordinal - ExportDir->Base] + ? RVA(BaseAddress, ExFunctions[Ordinal - ExportDir->Base] ) + : NULL); - if (((ULONG)Function >= (ULONG)ExportDir) && - ((ULONG)Function < (ULONG)ExportDir + (ULONG)ExportDirSize)) - { - DPRINT("Forward: %s\n", (PCHAR)Function); - Function = LdrFixupForward((PCHAR)Function); - } + if (((ULONG)Function >= (ULONG)ExportDir) && + ((ULONG)Function < (ULONG)ExportDir + (ULONG)ExportDirSize)) + { + DPRINT("Forward: %s\n", (PCHAR)Function); + Function = LdrFixupForward((PCHAR)Function); + } - return Function; + return Function; } @@ -1243,81 +1235,78 @@ LdrGetExportByName(PVOID BaseAddress, PUCHAR SymbolName, WORD Hint) { - PIMAGE_EXPORT_DIRECTORY ExportDir; - PDWORD * ExFunctions; - PDWORD * ExNames; - USHORT * ExOrdinals; - PVOID ExName; - ULONG Ordinal; - PVOID Function; - LONG minn, maxn; - ULONG ExportDirSize; + PIMAGE_EXPORT_DIRECTORY ExportDir; + PDWORD *ExFunctions; + PDWORD *ExNames; + USHORT *ExOrdinals; + PVOID ExName; + ULONG Ordinal; + PVOID Function; + LONG minn, maxn; + ULONG ExportDirSize; - DPRINT("LdrGetExportByName %p %s %hu\n", BaseAddress, SymbolName, Hint); + DPRINT("LdrGetExportByName %p %s %hu\n", BaseAddress, SymbolName, Hint); - ExportDir = (PIMAGE_EXPORT_DIRECTORY) - RtlImageDirectoryEntryToData(BaseAddress, - TRUE, - IMAGE_DIRECTORY_ENTRY_EXPORT, - &ExportDirSize); - if (ExportDir == NULL) - { + ExportDir = (PIMAGE_EXPORT_DIRECTORY) + RtlImageDirectoryEntryToData(BaseAddress, + TRUE, + IMAGE_DIRECTORY_ENTRY_EXPORT, + &ExportDirSize); + if (ExportDir == NULL) + { DPRINT1("LdrGetExportByName(): no export directory, " "can't lookup %s/%hu!\n", SymbolName, Hint); return NULL; - } + } - //The symbol names may be missing entirely - if (ExportDir->AddressOfNames == 0) - { - DPRINT("LdrGetExportByName(): symbol names missing entirely\n"); - return NULL; - } + //The symbol names may be missing entirely + if (ExportDir->AddressOfNames == 0) + { + DPRINT("LdrGetExportByName(): symbol names missing entirely\n"); + return NULL; + } - /* - * Get header pointers - */ - ExNames = (PDWORD *)RVA(BaseAddress, - ExportDir->AddressOfNames); - ExOrdinals = (USHORT *)RVA(BaseAddress, - ExportDir->AddressOfNameOrdinals); - ExFunctions = (PDWORD *)RVA(BaseAddress, - ExportDir->AddressOfFunctions); + /* + * Get header pointers + */ + ExNames = (PDWORD *)RVA(BaseAddress, ExportDir->AddressOfNames); + ExOrdinals = (USHORT *)RVA(BaseAddress, ExportDir->AddressOfNameOrdinals); + ExFunctions = (PDWORD *)RVA(BaseAddress, ExportDir->AddressOfFunctions); - /* - * Check the hint first - */ - if (Hint < ExportDir->NumberOfNames) - { + /* + * Check the hint first + */ + if (Hint < ExportDir->NumberOfNames) + { ExName = RVA(BaseAddress, ExNames[Hint]); if (strcmp(ExName, (PCHAR)SymbolName) == 0) - { - Ordinal = ExOrdinals[Hint]; - Function = RVA(BaseAddress, ExFunctions[Ordinal]); - if (((ULONG)Function >= (ULONG)ExportDir) && - ((ULONG)Function < (ULONG)ExportDir + (ULONG)ExportDirSize)) - { - DPRINT("Forward: %s\n", (PCHAR)Function); - Function = LdrFixupForward((PCHAR)Function); - if (Function == NULL) - { - DPRINT1("LdrGetExportByName(): failed to find %s\n",SymbolName); - } - return Function; - } - if (Function != NULL) - return Function; - } - } + { + Ordinal = ExOrdinals[Hint]; + Function = RVA(BaseAddress, ExFunctions[Ordinal]); + if (((ULONG)Function >= (ULONG)ExportDir) && + ((ULONG)Function < (ULONG)ExportDir + (ULONG)ExportDirSize)) + { + DPRINT("Forward: %s\n", (PCHAR)Function); + Function = LdrFixupForward((PCHAR)Function); + if (Function == NULL) + { + DPRINT1("LdrGetExportByName(): failed to find %s\n",SymbolName); + } + return Function; + } + if (Function != NULL) + return Function; + } + } - /* - * Binary search - */ - minn = 0; - maxn = ExportDir->NumberOfNames - 1; - while (minn <= maxn) - { + /* + * Binary search + */ + minn = 0; + maxn = ExportDir->NumberOfNames - 1; + while (minn <= maxn) + { LONG mid; LONG res; @@ -1326,40 +1315,40 @@ LdrGetExportByName(PVOID BaseAddress, ExName = RVA(BaseAddress, ExNames[mid]); res = strcmp(ExName, (PCHAR)SymbolName); if (res == 0) - { - Ordinal = ExOrdinals[mid]; - Function = RVA(BaseAddress, ExFunctions[Ordinal]); - if (((ULONG)Function >= (ULONG)ExportDir) && - ((ULONG)Function < (ULONG)ExportDir + (ULONG)ExportDirSize)) - { - DPRINT("Forward: %s\n", (PCHAR)Function); - Function = LdrFixupForward((PCHAR)Function); - if (Function == NULL) - { - DPRINT1("LdrGetExportByName(): failed to find %s\n",SymbolName); - } - return Function; - } - if (Function != NULL) - return Function; - } + { + Ordinal = ExOrdinals[mid]; + Function = RVA(BaseAddress, ExFunctions[Ordinal]); + if (((ULONG)Function >= (ULONG)ExportDir) && + ((ULONG)Function < (ULONG)ExportDir + (ULONG)ExportDirSize)) + { + DPRINT("Forward: %s\n", (PCHAR)Function); + Function = LdrFixupForward((PCHAR)Function); + if (Function == NULL) + { + DPRINT1("LdrGetExportByName(): failed to find %s\n",SymbolName); + } + return Function; + } + if (Function != NULL) + return Function; + } else if (minn == maxn) - { - DPRINT("LdrGetExportByName(): binary search failed\n"); - break; - } + { + DPRINT("LdrGetExportByName(): binary search failed\n"); + break; + } else if (res > 0) - { - maxn = mid - 1; - } + { + maxn = mid - 1; + } else - { - minn = mid + 1; - } - } + { + minn = mid + 1; + } + } - DPRINT("LdrGetExportByName(): failed to find %s\n",SymbolName); - return (PVOID)NULL; + DPRINT("LdrGetExportByName(): failed to find %s\n",SymbolName); + return (PVOID)NULL; } @@ -1383,105 +1372,105 @@ static NTSTATUS LdrPerformRelocations(PIMAGE_NT_HEADERS NTHeaders, PVOID ImageBase) { - PIMAGE_DATA_DIRECTORY RelocationDDir; - PIMAGE_BASE_RELOCATION RelocationDir, RelocationEnd; - ULONG Count, ProtectSize, OldProtect, OldProtect2; - PVOID Page, ProtectPage, ProtectPage2; - PUSHORT TypeOffset; - LONG_PTR Delta; - NTSTATUS Status; + PIMAGE_DATA_DIRECTORY RelocationDDir; + PIMAGE_BASE_RELOCATION RelocationDir, RelocationEnd; + ULONG Count, ProtectSize, OldProtect, OldProtect2; + PVOID Page, ProtectPage, ProtectPage2; + PUSHORT TypeOffset; + LONG_PTR Delta; + NTSTATUS Status; - if (NTHeaders->FileHeader.Characteristics & IMAGE_FILE_RELOCS_STRIPPED) + if (NTHeaders->FileHeader.Characteristics & IMAGE_FILE_RELOCS_STRIPPED) { - return STATUS_SUCCESS; + return STATUS_SUCCESS; } - RelocationDDir = - &NTHeaders->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_BASERELOC]; + RelocationDDir = + &NTHeaders->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_BASERELOC]; - if (RelocationDDir->VirtualAddress == 0 || RelocationDDir->Size == 0) + if (RelocationDDir->VirtualAddress == 0 || RelocationDDir->Size == 0) { - return STATUS_SUCCESS; + return STATUS_SUCCESS; } - ProtectSize = PAGE_SIZE; - Delta = (ULONG_PTR)ImageBase - NTHeaders->OptionalHeader.ImageBase; - RelocationDir = (PIMAGE_BASE_RELOCATION)((ULONG_PTR)ImageBase + - RelocationDDir->VirtualAddress); - RelocationEnd = (PIMAGE_BASE_RELOCATION)((ULONG_PTR)ImageBase + - RelocationDDir->VirtualAddress + RelocationDDir->Size); + ProtectSize = PAGE_SIZE; + Delta = (ULONG_PTR)ImageBase - NTHeaders->OptionalHeader.ImageBase; + RelocationDir = (PIMAGE_BASE_RELOCATION)((ULONG_PTR)ImageBase + + RelocationDDir->VirtualAddress); + RelocationEnd = (PIMAGE_BASE_RELOCATION)((ULONG_PTR)ImageBase + + RelocationDDir->VirtualAddress + RelocationDDir->Size); - while (RelocationDir < RelocationEnd && - RelocationDir->SizeOfBlock > 0) + while (RelocationDir < RelocationEnd && + RelocationDir->SizeOfBlock > 0) { - Count = (RelocationDir->SizeOfBlock - sizeof(IMAGE_BASE_RELOCATION)) / - sizeof(USHORT); - Page = (PVOID)((ULONG_PTR)ImageBase + (ULONG_PTR)RelocationDir->VirtualAddress); - TypeOffset = (PUSHORT)(RelocationDir + 1); + Count = (RelocationDir->SizeOfBlock - sizeof(IMAGE_BASE_RELOCATION)) / + sizeof(USHORT); + Page = (PVOID)((ULONG_PTR)ImageBase + (ULONG_PTR)RelocationDir->VirtualAddress); + TypeOffset = (PUSHORT)(RelocationDir + 1); - /* Unprotect the page(s) we're about to relocate. */ - ProtectPage = Page; - Status = NtProtectVirtualMemory(NtCurrentProcess(), - &ProtectPage, - &ProtectSize, - PAGE_READWRITE, - &OldProtect); - if (!NT_SUCCESS(Status)) + /* Unprotect the page(s) we're about to relocate. */ + ProtectPage = Page; + Status = NtProtectVirtualMemory(NtCurrentProcess(), + &ProtectPage, + &ProtectSize, + PAGE_READWRITE, + &OldProtect); + if (!NT_SUCCESS(Status)) { - DPRINT1("Failed to unprotect relocation target.\n"); - return Status; + DPRINT1("Failed to unprotect relocation target.\n"); + return Status; } - if (RelocationDir->VirtualAddress + PAGE_SIZE < - NTHeaders->OptionalHeader.SizeOfImage) + if (RelocationDir->VirtualAddress + PAGE_SIZE < + NTHeaders->OptionalHeader.SizeOfImage) { - ProtectPage2 = (PVOID)((ULONG_PTR)ProtectPage + PAGE_SIZE); - Status = NtProtectVirtualMemory(NtCurrentProcess(), - &ProtectPage2, - &ProtectSize, - PAGE_READWRITE, - &OldProtect2); - if (!NT_SUCCESS(Status)) + ProtectPage2 = (PVOID)((ULONG_PTR)ProtectPage + PAGE_SIZE); + Status = NtProtectVirtualMemory(NtCurrentProcess(), + &ProtectPage2, + &ProtectSize, + PAGE_READWRITE, + &OldProtect2); + if (!NT_SUCCESS(Status)) { - DPRINT1("Failed to unprotect relocation target (2).\n"); - NtProtectVirtualMemory(NtCurrentProcess(), - &ProtectPage, - &ProtectSize, - OldProtect, - &OldProtect); - return Status; + DPRINT1("Failed to unprotect relocation target (2).\n"); + NtProtectVirtualMemory(NtCurrentProcess(), + &ProtectPage, + &ProtectSize, + OldProtect, + &OldProtect); + return Status; } } - else + else { - ProtectPage2 = NULL; + ProtectPage2 = NULL; } - RelocationDir = LdrProcessRelocationBlock((ULONG_PTR)Page, - Count, - TypeOffset, - Delta); - if (RelocationDir == NULL) - return STATUS_UNSUCCESSFUL; + RelocationDir = LdrProcessRelocationBlock((ULONG_PTR)Page, + Count, + TypeOffset, + Delta); + if (RelocationDir == NULL) + return STATUS_UNSUCCESSFUL; - /* Restore old page protection. */ - NtProtectVirtualMemory(NtCurrentProcess(), - &ProtectPage, - &ProtectSize, - OldProtect, - &OldProtect); + /* Restore old page protection. */ + NtProtectVirtualMemory(NtCurrentProcess(), + &ProtectPage, + &ProtectSize, + OldProtect, + &OldProtect); - if (ProtectPage2 != NULL) + if (ProtectPage2 != NULL) { - NtProtectVirtualMemory(NtCurrentProcess(), - &ProtectPage2, - &ProtectSize, - OldProtect2, - &OldProtect2); + NtProtectVirtualMemory(NtCurrentProcess(), + &ProtectPage2, + &ProtectSize, + OldProtect2, + &OldProtect2); } } - return STATUS_SUCCESS; + return STATUS_SUCCESS; } static NTSTATUS @@ -1490,48 +1479,48 @@ LdrpGetOrLoadModule(PWCHAR SearchPath, PLDR_DATA_TABLE_ENTRY* Module, BOOLEAN Load) { - ANSI_STRING AnsiDllName; - UNICODE_STRING DllName; - NTSTATUS Status; + ANSI_STRING AnsiDllName; + UNICODE_STRING DllName; + NTSTATUS Status; - DPRINT("LdrpGetOrLoadModule() called for %s\n", Name); + DPRINT("LdrpGetOrLoadModule() called for %s\n", Name); - RtlInitAnsiString(&AnsiDllName, Name); - Status = RtlAnsiStringToUnicodeString(&DllName, &AnsiDllName, TRUE); - if (!NT_SUCCESS(Status)) - { - return Status; - } + RtlInitAnsiString(&AnsiDllName, Name); + Status = RtlAnsiStringToUnicodeString(&DllName, &AnsiDllName, TRUE); + if (!NT_SUCCESS(Status)) + { + return Status; + } - Status = LdrFindEntryForName (&DllName, Module, Load); - if (Load && !NT_SUCCESS(Status)) - { - Status = LdrpLoadModule(SearchPath, - 0, - &DllName, - Module, - NULL); - if (NT_SUCCESS(Status)) - { - Status = LdrFindEntryForName (&DllName, Module, FALSE); - } - if (!NT_SUCCESS(Status)) - { - ULONG ErrorResponse; - ULONG_PTR ErrorParameter = (ULONG_PTR)&AnsiDllName; + Status = LdrFindEntryForName (&DllName, Module, Load); + if (Load && !NT_SUCCESS(Status)) + { + Status = LdrpLoadModule(SearchPath, + 0, + &DllName, + Module, + NULL); + if (NT_SUCCESS(Status)) + { + Status = LdrFindEntryForName (&DllName, Module, FALSE); + } + if (!NT_SUCCESS(Status)) + { + ULONG ErrorResponse; + ULONG_PTR ErrorParameter = (ULONG_PTR)&AnsiDllName; - DPRINT1("failed to load %wZ\n", &DllName); + DPRINT1("failed to load %wZ\n", &DllName); - NtRaiseHardError(STATUS_DLL_NOT_FOUND, - 1, - 1, - &ErrorParameter, - OptionOk, - &ErrorResponse); - } - } - RtlFreeUnicodeString (&DllName); - return Status; + NtRaiseHardError(STATUS_DLL_NOT_FOUND, + 1, + 1, + &ErrorParameter, + OptionOk, + &ErrorResponse); + } + } + RtlFreeUnicodeString (&DllName); + return Status; } void @@ -1567,144 +1556,154 @@ LdrpProcessImportDirectoryEntry(PLDR_DATA_TABLE_ENTRY Module, PLDR_DATA_TABLE_ENTRY ImportedModule, PIMAGE_IMPORT_DESCRIPTOR ImportModuleDirectory) { - NTSTATUS Status; - PVOID* ImportAddressList; - PULONG FunctionNameList; - PVOID IATBase; - ULONG OldProtect; - ULONG Ordinal; - ULONG IATSize; + NTSTATUS Status; + PVOID* ImportAddressList; + PULONG FunctionNameList; + PVOID IATBase; + ULONG OldProtect; + ULONG Ordinal; + ULONG IATSize; - if (ImportModuleDirectory == NULL || ImportModuleDirectory->Name == 0) - { - return STATUS_UNSUCCESSFUL; - } + if (ImportModuleDirectory == NULL || ImportModuleDirectory->Name == 0) + { + return STATUS_UNSUCCESSFUL; + } - /* Get the import address list. */ - ImportAddressList = (PVOID *)((ULONG_PTR)Module->DllBase + (ULONG_PTR)ImportModuleDirectory->FirstThunk); + /* Get the import address list. */ + ImportAddressList = (PVOID *)((ULONG_PTR)Module->DllBase + + (ULONG_PTR)ImportModuleDirectory->FirstThunk); - /* Get the list of functions to import. */ - if (ImportModuleDirectory->OriginalFirstThunk != 0) - { - FunctionNameList = (PULONG) ((ULONG_PTR)Module->DllBase + (ULONG_PTR)ImportModuleDirectory->OriginalFirstThunk); - } - else - { - FunctionNameList = (PULONG)((ULONG_PTR)Module->DllBase + (ULONG_PTR)ImportModuleDirectory->FirstThunk); - } + /* Get the list of functions to import. */ + if (ImportModuleDirectory->OriginalFirstThunk != 0) + { + FunctionNameList = (PULONG)((ULONG_PTR)Module->DllBase + + (ULONG_PTR)ImportModuleDirectory->OriginalFirstThunk); + } + else + { + FunctionNameList = (PULONG)((ULONG_PTR)Module->DllBase + + (ULONG_PTR)ImportModuleDirectory->FirstThunk); + } - /* Get the size of IAT. */ - IATSize = 0; - while (FunctionNameList[IATSize] != 0L) - { - IATSize++; - } + /* Get the size of IAT. */ + IATSize = 0; + while (FunctionNameList[IATSize] != 0L) + { + IATSize++; + } - /* No need to fixup anything if IAT is empty */ - if (IATSize == 0) return STATUS_SUCCESS; + /* No need to fixup anything if IAT is empty */ + if (IATSize == 0) return STATUS_SUCCESS; - /* Unprotect the region we are about to write into. */ - IATBase = (PVOID)ImportAddressList; - IATSize *= sizeof(PVOID*); - Status = NtProtectVirtualMemory(NtCurrentProcess(), - &IATBase, - &IATSize, - PAGE_READWRITE, - &OldProtect); - if (!NT_SUCCESS(Status)) - { - DPRINT1("Failed to unprotect IAT.\n"); - return(Status); - } + /* Unprotect the region we are about to write into. */ + IATBase = (PVOID)ImportAddressList; + IATSize *= sizeof(PVOID*); + Status = NtProtectVirtualMemory(NtCurrentProcess(), + &IATBase, + &IATSize, + PAGE_READWRITE, + &OldProtect); + if (!NT_SUCCESS(Status)) + { + DPRINT1("Failed to unprotect IAT.\n"); + return(Status); + } - /* Walk through function list and fixup addresses. */ - while (*FunctionNameList != 0L) - { - if ((*FunctionNameList) & 0x80000000) - { - Ordinal = (*FunctionNameList) & 0x7fffffff; - *ImportAddressList = LdrGetExportByOrdinal(ImportedModule->DllBase, Ordinal); - if ((*ImportAddressList) == NULL) - { - DPRINT1("Failed to import #%ld from %wZ\n", Ordinal, &ImportedModule->FullDllName); - RtlpRaiseImportNotFound(NULL, Ordinal, &ImportedModule->FullDllName); - return STATUS_ENTRYPOINT_NOT_FOUND; - } - } - else - { - IMAGE_IMPORT_BY_NAME *pe_name; - pe_name = RVA(Module->DllBase, *FunctionNameList); - *ImportAddressList = LdrGetExportByName(ImportedModule->DllBase, pe_name->Name, pe_name->Hint); - if ((*ImportAddressList) == NULL) - { - DPRINT1("Failed to import %s from %wZ\n", pe_name->Name, &ImportedModule->FullDllName); - RtlpRaiseImportNotFound((CHAR*)pe_name->Name, 0, &ImportedModule->FullDllName); - return STATUS_ENTRYPOINT_NOT_FOUND; - } - } - ImportAddressList++; - FunctionNameList++; - } + /* Walk through function list and fixup addresses. */ + while (*FunctionNameList != 0L) + { + if ((*FunctionNameList) & 0x80000000) + { + Ordinal = (*FunctionNameList) & 0x7fffffff; + *ImportAddressList = LdrGetExportByOrdinal(ImportedModule->DllBase, + Ordinal); + if ((*ImportAddressList) == NULL) + { + DPRINT1("Failed to import #%ld from %wZ\n", + Ordinal, &ImportedModule->FullDllName); + RtlpRaiseImportNotFound(NULL, Ordinal, &ImportedModule->FullDllName); + return STATUS_ENTRYPOINT_NOT_FOUND; + } + } + else + { + IMAGE_IMPORT_BY_NAME *pe_name; + pe_name = RVA(Module->DllBase, *FunctionNameList); + *ImportAddressList = LdrGetExportByName(ImportedModule->DllBase, + pe_name->Name, + pe_name->Hint); + if ((*ImportAddressList) == NULL) + { + DPRINT1("Failed to import %s from %wZ\n", + pe_name->Name, &ImportedModule->FullDllName); + RtlpRaiseImportNotFound((CHAR*)pe_name->Name, + 0, + &ImportedModule->FullDllName); + return STATUS_ENTRYPOINT_NOT_FOUND; + } + } + ImportAddressList++; + FunctionNameList++; + } - /* Protect the region we are about to write into. */ - Status = NtProtectVirtualMemory(NtCurrentProcess(), - &IATBase, - &IATSize, - OldProtect, - &OldProtect); - if (!NT_SUCCESS(Status)) - { - DPRINT1("Failed to protect IAT.\n"); - return(Status); - } + /* Protect the region we are about to write into. */ + Status = NtProtectVirtualMemory(NtCurrentProcess(), + &IATBase, + &IATSize, + OldProtect, + &OldProtect); + if (!NT_SUCCESS(Status)) + { + DPRINT1("Failed to protect IAT.\n"); + return(Status); + } - return STATUS_SUCCESS; + return STATUS_SUCCESS; } static NTSTATUS LdrpProcessImportDirectory( - PLDR_DATA_TABLE_ENTRY Module, - PLDR_DATA_TABLE_ENTRY ImportedModule, - PCHAR ImportedName) + PLDR_DATA_TABLE_ENTRY Module, + PLDR_DATA_TABLE_ENTRY ImportedModule, + PCHAR ImportedName) { - NTSTATUS Status; - PIMAGE_IMPORT_DESCRIPTOR ImportModuleDirectory; - PCHAR Name; - ULONG Size; + NTSTATUS Status; + PIMAGE_IMPORT_DESCRIPTOR ImportModuleDirectory; + PCHAR Name; + ULONG Size; - DPRINT("LdrpProcessImportDirectory(%p '%wZ', '%s')\n", - Module, &Module->BaseDllName, ImportedName); + DPRINT("LdrpProcessImportDirectory(%p '%wZ', '%s')\n", + Module, &Module->BaseDllName, ImportedName); - ImportModuleDirectory = (PIMAGE_IMPORT_DESCRIPTOR) - RtlImageDirectoryEntryToData(Module->DllBase, - TRUE, - IMAGE_DIRECTORY_ENTRY_IMPORT, - &Size); - if (ImportModuleDirectory == NULL) - { - return STATUS_UNSUCCESSFUL; - } + ImportModuleDirectory = (PIMAGE_IMPORT_DESCRIPTOR) + RtlImageDirectoryEntryToData(Module->DllBase, + TRUE, + IMAGE_DIRECTORY_ENTRY_IMPORT, + &Size); + if (ImportModuleDirectory == NULL) + { + return STATUS_UNSUCCESSFUL; + } - while (ImportModuleDirectory->Name) - { - Name = (PCHAR)Module->DllBase + ImportModuleDirectory->Name; - if (0 == _stricmp(Name, ImportedName)) - { - Status = LdrpProcessImportDirectoryEntry(Module, - ImportedModule, - ImportModuleDirectory); - if (!NT_SUCCESS(Status)) - { - return Status; - } - } - ImportModuleDirectory++; - } + while (ImportModuleDirectory->Name) + { + Name = (PCHAR)Module->DllBase + ImportModuleDirectory->Name; + if (0 == _stricmp(Name, ImportedName)) + { + Status = LdrpProcessImportDirectoryEntry(Module, + ImportedModule, + ImportModuleDirectory); + if (!NT_SUCCESS(Status)) + { + return Status; + } + } + ImportModuleDirectory++; + } - return STATUS_SUCCESS; + return STATUS_SUCCESS; } @@ -1713,104 +1712,107 @@ LdrpAdjustImportDirectory(PLDR_DATA_TABLE_ENTRY Module, PLDR_DATA_TABLE_ENTRY ImportedModule, PCHAR ImportedName) { - PIMAGE_IMPORT_DESCRIPTOR ImportModuleDirectory; - NTSTATUS Status; - PVOID* ImportAddressList; - PVOID Start; - PVOID End; - PULONG FunctionNameList; - PVOID IATBase; - ULONG OldProtect; - ULONG Offset; - ULONG IATSize; - PIMAGE_NT_HEADERS NTHeaders; - PCHAR Name; - ULONG Size; + PIMAGE_IMPORT_DESCRIPTOR ImportModuleDirectory; + NTSTATUS Status; + PVOID* ImportAddressList; + PVOID Start; + PVOID End; + PULONG FunctionNameList; + PVOID IATBase; + ULONG OldProtect; + ULONG Offset; + ULONG IATSize; + PIMAGE_NT_HEADERS NTHeaders; + PCHAR Name; + ULONG Size; - DPRINT("LdrpAdjustImportDirectory(Module %p '%wZ', %p '%wZ', '%s')\n", - Module, &Module->BaseDllName, ImportedModule, &ImportedModule->BaseDllName, ImportedName); + DPRINT("LdrpAdjustImportDirectory(Module %p '%wZ', %p '%wZ', '%s')\n", + Module, &Module->BaseDllName, ImportedModule, &ImportedModule->BaseDllName, ImportedName); - ImportModuleDirectory = (PIMAGE_IMPORT_DESCRIPTOR) - RtlImageDirectoryEntryToData(Module->DllBase, - TRUE, - IMAGE_DIRECTORY_ENTRY_IMPORT, - &Size); - if (ImportModuleDirectory == NULL) - { - return STATUS_UNSUCCESSFUL; - } + ImportModuleDirectory = (PIMAGE_IMPORT_DESCRIPTOR) + RtlImageDirectoryEntryToData(Module->DllBase, + TRUE, + IMAGE_DIRECTORY_ENTRY_IMPORT, + &Size); + if (ImportModuleDirectory == NULL) + { + return STATUS_UNSUCCESSFUL; + } - while (ImportModuleDirectory->Name) - { - Name = (PCHAR)Module->DllBase + ImportModuleDirectory->Name; - if (0 == _stricmp(Name, (PCHAR)ImportedName)) - { + while (ImportModuleDirectory->Name) + { + Name = (PCHAR)Module->DllBase + ImportModuleDirectory->Name; + if (0 == _stricmp(Name, (PCHAR)ImportedName)) + { - /* Get the import address list. */ - ImportAddressList = (PVOID *)((ULONG_PTR)Module->DllBase + (ULONG_PTR)ImportModuleDirectory->FirstThunk); + /* Get the import address list. */ + ImportAddressList = (PVOID *)((ULONG_PTR)Module->DllBase + + (ULONG_PTR)ImportModuleDirectory->FirstThunk); - /* Get the list of functions to import. */ - if (ImportModuleDirectory->OriginalFirstThunk != 0) - { - FunctionNameList = (PULONG) ((ULONG_PTR)Module->DllBase + (ULONG_PTR)ImportModuleDirectory->OriginalFirstThunk); - } - else - { - FunctionNameList = (PULONG)((ULONG_PTR)Module->DllBase + (ULONG_PTR)ImportModuleDirectory->FirstThunk); - } + /* Get the list of functions to import. */ + if (ImportModuleDirectory->OriginalFirstThunk != 0) + { + FunctionNameList = (PULONG)((ULONG_PTR)Module->DllBase + + (ULONG_PTR)ImportModuleDirectory->OriginalFirstThunk); + } + else + { + FunctionNameList = (PULONG)((ULONG_PTR)Module->DllBase + + (ULONG_PTR)ImportModuleDirectory->FirstThunk); + } - /* Get the size of IAT. */ - IATSize = 0; - while (FunctionNameList[IATSize] != 0L) - { - IATSize++; - } + /* Get the size of IAT. */ + IATSize = 0; + while (FunctionNameList[IATSize] != 0L) + { + IATSize++; + } - /* Unprotect the region we are about to write into. */ - IATBase = (PVOID)ImportAddressList; - IATSize *= sizeof(PVOID*); - Status = NtProtectVirtualMemory(NtCurrentProcess(), - &IATBase, - &IATSize, - PAGE_READWRITE, - &OldProtect); - if (!NT_SUCCESS(Status)) - { - DPRINT1("Failed to unprotect IAT.\n"); - return(Status); - } + /* Unprotect the region we are about to write into. */ + IATBase = (PVOID)ImportAddressList; + IATSize *= sizeof(PVOID*); + Status = NtProtectVirtualMemory(NtCurrentProcess(), + &IATBase, + &IATSize, + PAGE_READWRITE, + &OldProtect); + if (!NT_SUCCESS(Status)) + { + DPRINT1("Failed to unprotect IAT.\n"); + return(Status); + } - NTHeaders = RtlImageNtHeader (ImportedModule->DllBase); - Start = (PVOID)NTHeaders->OptionalHeader.ImageBase; - End = (PVOID)((ULONG_PTR)Start + ImportedModule->SizeOfImage); - Offset = (ULONG)((ULONG_PTR)ImportedModule->DllBase - (ULONG_PTR)Start); + NTHeaders = RtlImageNtHeader (ImportedModule->DllBase); + Start = (PVOID)NTHeaders->OptionalHeader.ImageBase; + End = (PVOID)((ULONG_PTR)Start + ImportedModule->SizeOfImage); + Offset = (ULONG)((ULONG_PTR)ImportedModule->DllBase - (ULONG_PTR)Start); - /* Walk through function list and fixup addresses. */ - while (*FunctionNameList != 0L) - { - if (*ImportAddressList >= Start && *ImportAddressList < End) - { - (*ImportAddressList) = (PVOID)((ULONG_PTR)(*ImportAddressList) + Offset); - } - ImportAddressList++; - FunctionNameList++; - } + /* Walk through function list and fixup addresses. */ + while (*FunctionNameList != 0L) + { + if (*ImportAddressList >= Start && *ImportAddressList < End) + { + (*ImportAddressList) = (PVOID)((ULONG_PTR)(*ImportAddressList) + Offset); + } + ImportAddressList++; + FunctionNameList++; + } - /* Protect the region we are about to write into. */ - Status = NtProtectVirtualMemory(NtCurrentProcess(), - &IATBase, - &IATSize, - OldProtect, - &OldProtect); - if (!NT_SUCCESS(Status)) - { - DPRINT1("Failed to protect IAT.\n"); - return(Status); - } - } - ImportModuleDirectory++; - } - return STATUS_SUCCESS; + /* Protect the region we are about to write into. */ + Status = NtProtectVirtualMemory(NtCurrentProcess(), + &IATBase, + &IATSize, + OldProtect, + &OldProtect); + if (!NT_SUCCESS(Status)) + { + DPRINT1("Failed to protect IAT.\n"); + return(Status); + } + } + ImportModuleDirectory++; + } + return STATUS_SUCCESS; } @@ -1835,266 +1837,270 @@ static NTSTATUS LdrFixupImports(IN PWSTR SearchPath OPTIONAL, IN PLDR_DATA_TABLE_ENTRY Module) { - PIMAGE_IMPORT_DESCRIPTOR ImportModuleDirectory; - PIMAGE_IMPORT_DESCRIPTOR ImportModuleDirectoryCurrent; - PIMAGE_BOUND_IMPORT_DESCRIPTOR BoundImportDescriptor; - PIMAGE_BOUND_IMPORT_DESCRIPTOR BoundImportDescriptorCurrent; - PIMAGE_TLS_DIRECTORY TlsDirectory; - ULONG TlsSize = 0; - NTSTATUS Status = STATUS_SUCCESS; - PLDR_DATA_TABLE_ENTRY ImportedModule; - PCHAR ImportedName; - PWSTR ModulePath; - ULONG Size; - ULONG_PTR cookie; + PIMAGE_IMPORT_DESCRIPTOR ImportModuleDirectory; + PIMAGE_IMPORT_DESCRIPTOR ImportModuleDirectoryCurrent; + PIMAGE_BOUND_IMPORT_DESCRIPTOR BoundImportDescriptor; + PIMAGE_BOUND_IMPORT_DESCRIPTOR BoundImportDescriptorCurrent; + PIMAGE_TLS_DIRECTORY TlsDirectory; + ULONG TlsSize = 0; + NTSTATUS Status = STATUS_SUCCESS; + PLDR_DATA_TABLE_ENTRY ImportedModule; + PCHAR ImportedName; + PWSTR ModulePath; + ULONG Size; + ULONG_PTR cookie; - DPRINT("LdrFixupImports(SearchPath %S, Module %p)\n", SearchPath, Module); + DPRINT("LdrFixupImports(SearchPath %S, Module %p)\n", SearchPath, Module); - /* Check for tls data */ - TlsDirectory = (PIMAGE_TLS_DIRECTORY) - RtlImageDirectoryEntryToData(Module->DllBase, - TRUE, - IMAGE_DIRECTORY_ENTRY_TLS, - &Size); - if (TlsDirectory) - { - TlsSize = TlsDirectory->EndAddressOfRawData - - TlsDirectory->StartAddressOfRawData - + TlsDirectory->SizeOfZeroFill; + /* Check for tls data */ + TlsDirectory = (PIMAGE_TLS_DIRECTORY) + RtlImageDirectoryEntryToData(Module->DllBase, + TRUE, + IMAGE_DIRECTORY_ENTRY_TLS, + &Size); + if (TlsDirectory) + { + TlsSize = TlsDirectory->EndAddressOfRawData + - TlsDirectory->StartAddressOfRawData + + TlsDirectory->SizeOfZeroFill; - if (TlsSize > 0 && NtCurrentPeb()->Ldr->Initialized) - { - TRACE_LDR("Trying to dynamically load %wZ which contains a TLS directory\n", - &Module->BaseDllName); - TlsDirectory = NULL; - } - } + if (TlsSize > 0 && NtCurrentPeb()->Ldr->Initialized) + { + TRACE_LDR("Trying to dynamically load %wZ which contains a TLS directory\n", + &Module->BaseDllName); + TlsDirectory = NULL; + } + } - if (!create_module_activation_context( Module )) - { - if (Module->EntryPointActivationContext == NULL) - { - DPRINT("EntryPointActivationContext has not be allocated\n"); - DPRINT("Module->DllBaseName %wZ\n", Module->BaseDllName); - } - RtlActivateActivationContext( 0, Module->EntryPointActivationContext, &cookie ); - } + if (!create_module_activation_context( Module )) + { + if (Module->EntryPointActivationContext == NULL) + { + DPRINT("EntryPointActivationContext has not be allocated\n"); + DPRINT("Module->DllBaseName %wZ\n", Module->BaseDllName); + } + RtlActivateActivationContext( 0, Module->EntryPointActivationContext, &cookie ); + } - /* - * Process each import module. - */ - ImportModuleDirectory = (PIMAGE_IMPORT_DESCRIPTOR) - RtlImageDirectoryEntryToData(Module->DllBase, - TRUE, - IMAGE_DIRECTORY_ENTRY_IMPORT, - &Size); + /* + * Process each import module. + */ + ImportModuleDirectory = (PIMAGE_IMPORT_DESCRIPTOR) + RtlImageDirectoryEntryToData(Module->DllBase, + TRUE, + IMAGE_DIRECTORY_ENTRY_IMPORT, + &Size); - BoundImportDescriptor = (PIMAGE_BOUND_IMPORT_DESCRIPTOR) - RtlImageDirectoryEntryToData(Module->DllBase, - TRUE, - IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT, - &Size); + BoundImportDescriptor = (PIMAGE_BOUND_IMPORT_DESCRIPTOR) + RtlImageDirectoryEntryToData(Module->DllBase, + TRUE, + IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT, + &Size); - if (BoundImportDescriptor != NULL && ImportModuleDirectory == NULL) - { - DPRINT1("%wZ has only a bound import directory\n", &Module->BaseDllName); - return STATUS_UNSUCCESSFUL; - } - if (BoundImportDescriptor) - { - DPRINT("BoundImportDescriptor %p\n", BoundImportDescriptor); + if (BoundImportDescriptor != NULL && ImportModuleDirectory == NULL) + { + DPRINT1("%wZ has only a bound import directory\n", &Module->BaseDllName); + return STATUS_UNSUCCESSFUL; + } + if (BoundImportDescriptor) + { + DPRINT("BoundImportDescriptor %p\n", BoundImportDescriptor); - BoundImportDescriptorCurrent = BoundImportDescriptor; - while (BoundImportDescriptorCurrent->OffsetModuleName) - { - ImportedName = (PCHAR)BoundImportDescriptor + BoundImportDescriptorCurrent->OffsetModuleName; - TRACE_LDR("%wZ bound to %s\n", &Module->BaseDllName, ImportedName); - Status = LdrpGetOrLoadModule(SearchPath, ImportedName, &ImportedModule, TRUE); - if (!NT_SUCCESS(Status)) - { - DPRINT1("failed to load %s\n", ImportedName); - return Status; - } - if (Module == ImportedModule) - { - LdrpDecrementLoadCount(Module, FALSE); - } - if (ImportedModule->TimeDateStamp != BoundImportDescriptorCurrent->TimeDateStamp) - { - TRACE_LDR("%wZ has stale binding to %wZ\n", - &Module->BaseDllName, &ImportedModule->BaseDllName); - Status = LdrpProcessImportDirectory(Module, ImportedModule, ImportedName); - if (!NT_SUCCESS(Status)) - { - DPRINT1("failed to import %s\n", ImportedName); - return Status; - } - } - else - { - BOOLEAN WrongForwarder; - WrongForwarder = FALSE; - if (ImportedModule->Flags & LDRP_IMAGE_NOT_AT_BASE) - { - TRACE_LDR("%wZ has stale binding to %s\n", - &Module->BaseDllName, ImportedName); - } - else - { - TRACE_LDR("%wZ has correct binding to %wZ\n", - &Module->BaseDllName, &ImportedModule->BaseDllName); - } - if (BoundImportDescriptorCurrent->NumberOfModuleForwarderRefs) - { - PIMAGE_BOUND_FORWARDER_REF BoundForwarderRef; - ULONG i; - PLDR_DATA_TABLE_ENTRY ForwarderModule; - PCHAR ForwarderName; + BoundImportDescriptorCurrent = BoundImportDescriptor; + while (BoundImportDescriptorCurrent->OffsetModuleName) + { + ImportedName = (PCHAR)BoundImportDescriptor + + BoundImportDescriptorCurrent->OffsetModuleName; + TRACE_LDR("%wZ bound to %s\n", &Module->BaseDllName, ImportedName); + Status = LdrpGetOrLoadModule(SearchPath, ImportedName, &ImportedModule, TRUE); + if (!NT_SUCCESS(Status)) + { + DPRINT1("failed to load %s\n", ImportedName); + return Status; + } + if (Module == ImportedModule) + { + LdrpDecrementLoadCount(Module, FALSE); + } + if (ImportedModule->TimeDateStamp != BoundImportDescriptorCurrent->TimeDateStamp) + { + TRACE_LDR("%wZ has stale binding to %wZ\n", + &Module->BaseDllName, &ImportedModule->BaseDllName); + Status = LdrpProcessImportDirectory(Module, ImportedModule, ImportedName); + if (!NT_SUCCESS(Status)) + { + DPRINT1("failed to import %s\n", ImportedName); + return Status; + } + } + else + { + BOOLEAN WrongForwarder; + WrongForwarder = FALSE; + if (ImportedModule->Flags & LDRP_IMAGE_NOT_AT_BASE) + { + TRACE_LDR("%wZ has stale binding to %s\n", + &Module->BaseDllName, ImportedName); + } + else + { + TRACE_LDR("%wZ has correct binding to %wZ\n", + &Module->BaseDllName, &ImportedModule->BaseDllName); + } + if (BoundImportDescriptorCurrent->NumberOfModuleForwarderRefs) + { + PIMAGE_BOUND_FORWARDER_REF BoundForwarderRef; + ULONG i; + PLDR_DATA_TABLE_ENTRY ForwarderModule; + PCHAR ForwarderName; - BoundForwarderRef = (PIMAGE_BOUND_FORWARDER_REF)(BoundImportDescriptorCurrent + 1); - for (i = 0; i < BoundImportDescriptorCurrent->NumberOfModuleForwarderRefs; i++, BoundForwarderRef++) - { - ForwarderName = (PCHAR)BoundImportDescriptor + BoundForwarderRef->OffsetModuleName; - TRACE_LDR("%wZ bound to %s via forwardes from %s\n", - &Module->BaseDllName, ForwarderName, ImportedName); - Status = LdrpGetOrLoadModule(SearchPath, ForwarderName, &ForwarderModule, TRUE); - if (!NT_SUCCESS(Status)) - { - DPRINT1("failed to load %s\n", ForwarderName); - return Status; - } - if (Module == ImportedModule) - { - LdrpDecrementLoadCount(Module, FALSE); - } - if (ForwarderModule->TimeDateStamp != BoundForwarderRef->TimeDateStamp || - ForwarderModule->Flags & LDRP_IMAGE_NOT_AT_BASE) - { - TRACE_LDR("%wZ has stale binding to %s\n", - &Module->BaseDllName, ForwarderName); - WrongForwarder = TRUE; - } - else - { - TRACE_LDR("%wZ has correct binding to %s\n", - &Module->BaseDllName, ForwarderName); - } - } - } - if (WrongForwarder || - ImportedModule->Flags & LDRP_IMAGE_NOT_AT_BASE) - { - Status = LdrpProcessImportDirectory(Module, ImportedModule, ImportedName); - if (!NT_SUCCESS(Status)) - { - DPRINT1("failed to import %s\n", ImportedName); - return Status; - } - } - else if (ImportedModule->Flags & LDRP_IMAGE_NOT_AT_BASE) - { - TRACE_LDR("Adjust imports for %s from %wZ\n", - ImportedName, &Module->BaseDllName); - Status = LdrpAdjustImportDirectory(Module, ImportedModule, ImportedName); - if (!NT_SUCCESS(Status)) - { - DPRINT1("failed to adjust import entries for %s\n", ImportedName); - return Status; - } - } - else if (WrongForwarder) - { - /* - * FIXME: - * Update only forwarders - */ - TRACE_LDR("Stale BIND %s from %wZ\n", - ImportedName, &Module->BaseDllName); - Status = LdrpProcessImportDirectory(Module, ImportedModule, ImportedName); - if (!NT_SUCCESS(Status)) - { - DPRINT1("faild to import %s\n", ImportedName); - return Status; - } - } - else - { - /* nothing to do */ - } - } - BoundImportDescriptorCurrent += BoundImportDescriptorCurrent->NumberOfModuleForwarderRefs + 1; - } - } - else if (ImportModuleDirectory) - { - DPRINT("ImportModuleDirectory %p\n", ImportModuleDirectory); + BoundForwarderRef = (PIMAGE_BOUND_FORWARDER_REF)(BoundImportDescriptorCurrent + 1); + for (i = 0; + i < BoundImportDescriptorCurrent->NumberOfModuleForwarderRefs; + i++, BoundForwarderRef++) + { + ForwarderName = (PCHAR)BoundImportDescriptor + + BoundForwarderRef->OffsetModuleName; + TRACE_LDR("%wZ bound to %s via forwardes from %s\n", + &Module->BaseDllName, ForwarderName, ImportedName); + Status = LdrpGetOrLoadModule(SearchPath, ForwarderName, &ForwarderModule, TRUE); + if (!NT_SUCCESS(Status)) + { + DPRINT1("failed to load %s\n", ForwarderName); + return Status; + } + if (Module == ImportedModule) + { + LdrpDecrementLoadCount(Module, FALSE); + } + if (ForwarderModule->TimeDateStamp != BoundForwarderRef->TimeDateStamp || + ForwarderModule->Flags & LDRP_IMAGE_NOT_AT_BASE) + { + TRACE_LDR("%wZ has stale binding to %s\n", + &Module->BaseDllName, ForwarderName); + WrongForwarder = TRUE; + } + else + { + TRACE_LDR("%wZ has correct binding to %s\n", + &Module->BaseDllName, ForwarderName); + } + } + } + if (WrongForwarder || + ImportedModule->Flags & LDRP_IMAGE_NOT_AT_BASE) + { + Status = LdrpProcessImportDirectory(Module, ImportedModule, ImportedName); + if (!NT_SUCCESS(Status)) + { + DPRINT1("failed to import %s\n", ImportedName); + return Status; + } + } + else if (ImportedModule->Flags & LDRP_IMAGE_NOT_AT_BASE) + { + TRACE_LDR("Adjust imports for %s from %wZ\n", + ImportedName, &Module->BaseDllName); + Status = LdrpAdjustImportDirectory(Module, ImportedModule, ImportedName); + if (!NT_SUCCESS(Status)) + { + DPRINT1("failed to adjust import entries for %s\n", ImportedName); + return Status; + } + } + else if (WrongForwarder) + { + /* + * FIXME: + * Update only forwarders + */ + TRACE_LDR("Stale BIND %s from %wZ\n", + ImportedName, &Module->BaseDllName); + Status = LdrpProcessImportDirectory(Module, ImportedModule, ImportedName); + if (!NT_SUCCESS(Status)) + { + DPRINT1("faild to import %s\n", ImportedName); + return Status; + } + } + else + { + /* nothing to do */ + } + } + BoundImportDescriptorCurrent += BoundImportDescriptorCurrent->NumberOfModuleForwarderRefs + 1; + } + } + else if (ImportModuleDirectory) + { + DPRINT("ImportModuleDirectory %p\n", ImportModuleDirectory); - ImportModuleDirectoryCurrent = ImportModuleDirectory; - while (ImportModuleDirectoryCurrent->Name) - { - ImportedName = (PCHAR)Module->DllBase + ImportModuleDirectoryCurrent->Name; - TRACE_LDR("%wZ imports functions from %s\n", &Module->BaseDllName, ImportedName); + ImportModuleDirectoryCurrent = ImportModuleDirectory; + while (ImportModuleDirectoryCurrent->Name) + { + ImportedName = (PCHAR)Module->DllBase + ImportModuleDirectoryCurrent->Name; + TRACE_LDR("%wZ imports functions from %s\n", &Module->BaseDllName, ImportedName); - if (SearchPath == NULL) - { + if (SearchPath == NULL) + { ModulePath = LdrpQueryAppPaths(Module->BaseDllName.Buffer); Status = LdrpGetOrLoadModule(ModulePath, ImportedName, &ImportedModule, TRUE); if (ModulePath != NULL) RtlFreeHeap(RtlGetProcessHeap(), 0, ModulePath); if (NT_SUCCESS(Status)) goto Success; - } + } - Status = LdrpGetOrLoadModule(SearchPath, ImportedName, &ImportedModule, TRUE); - if (!NT_SUCCESS(Status)) - { - DPRINT1("failed to load %s\n", ImportedName); - break; - } + Status = LdrpGetOrLoadModule(SearchPath, ImportedName, &ImportedModule, TRUE); + if (!NT_SUCCESS(Status)) + { + DPRINT1("failed to load %s\n", ImportedName); + break; + } Success: - if (Module == ImportedModule) - { - LdrpDecrementLoadCount(Module, FALSE); - } + if (Module == ImportedModule) + { + LdrpDecrementLoadCount(Module, FALSE); + } - TRACE_LDR("Initializing imports for %wZ from %s\n", - &Module->BaseDllName, ImportedName); - Status = LdrpProcessImportDirectoryEntry(Module, ImportedModule, ImportModuleDirectoryCurrent); - if (!NT_SUCCESS(Status)) - { - DPRINT1("failed to import %s\n", ImportedName); - break; - } - ImportModuleDirectoryCurrent++; - } + TRACE_LDR("Initializing imports for %wZ from %s\n", + &Module->BaseDllName, ImportedName); + Status = LdrpProcessImportDirectoryEntry(Module, ImportedModule, ImportModuleDirectoryCurrent); + if (!NT_SUCCESS(Status)) + { + DPRINT1("failed to import %s\n", ImportedName); + break; + } + ImportModuleDirectoryCurrent++; + } - if (!NT_SUCCESS(Status)) - { + if (!NT_SUCCESS(Status)) + { NTSTATUS errorStatus = Status; while (ImportModuleDirectoryCurrent >= ImportModuleDirectory) - { + { ImportedName = (PCHAR)Module->DllBase + ImportModuleDirectoryCurrent->Name; Status = LdrpGetOrLoadModule(NULL, ImportedName, &ImportedModule, FALSE); if (NT_SUCCESS(Status) && Module != ImportedModule) - { + { Status = LdrpUnloadModule(ImportedModule, FALSE); if (!NT_SUCCESS(Status)) DPRINT1("unable to unload %s\n", ImportedName); - } + } ImportModuleDirectoryCurrent--; - } + } return errorStatus; - } - } + } + } - if (TlsDirectory && TlsSize > 0) - { - LdrpAcquireTlsSlot(Module, TlsSize, FALSE); - } + if (TlsDirectory && TlsSize > 0) + { + LdrpAcquireTlsSlot(Module, TlsSize, FALSE); + } if (Module->EntryPointActivationContext) RtlDeactivateActivationContext( 0, cookie ); - return STATUS_SUCCESS; + return STATUS_SUCCESS; } @@ -2131,114 +2137,114 @@ PEPFUNC LdrPEStartup (PVOID ImageBase, PLDR_DATA_TABLE_ENTRY* Module, PWSTR FullDosName) { - NTSTATUS Status; - PEPFUNC EntryPoint = NULL; - PIMAGE_DOS_HEADER DosHeader; - PIMAGE_NT_HEADERS NTHeaders; - PLDR_DATA_TABLE_ENTRY tmpModule; - PVOID ActivationContextStack; + NTSTATUS Status; + PEPFUNC EntryPoint = NULL; + PIMAGE_DOS_HEADER DosHeader; + PIMAGE_NT_HEADERS NTHeaders; + PLDR_DATA_TABLE_ENTRY tmpModule; + PVOID ActivationContextStack; - DPRINT("LdrPEStartup(ImageBase %p SectionHandle %p)\n", + DPRINT("LdrPEStartup(ImageBase %p SectionHandle %p)\n", ImageBase, SectionHandle); - /* - * Overlay DOS and WNT headers structures - * to the DLL's image. - */ - DosHeader = (PIMAGE_DOS_HEADER) ImageBase; - NTHeaders = (PIMAGE_NT_HEADERS) ((ULONG_PTR)ImageBase + DosHeader->e_lfanew); + /* + * Overlay DOS and WNT headers structures + * to the DLL's image. + */ + DosHeader = (PIMAGE_DOS_HEADER) ImageBase; + NTHeaders = (PIMAGE_NT_HEADERS) ((ULONG_PTR)ImageBase + DosHeader->e_lfanew); - /* - * If the base address is different from the - * one the DLL is actually loaded, perform any - * relocation. - */ - if (ImageBase != (PVOID) NTHeaders->OptionalHeader.ImageBase) - { - DPRINT("LDR: Performing relocations\n"); - Status = LdrPerformRelocations(NTHeaders, ImageBase); - if (!NT_SUCCESS(Status)) - { - DPRINT1("LdrPerformRelocations() failed\n"); - return NULL; - } - } + /* + * If the base address is different from the + * one the DLL is actually loaded, perform any + * relocation. + */ + if (ImageBase != (PVOID)NTHeaders->OptionalHeader.ImageBase) + { + DPRINT("LDR: Performing relocations\n"); + Status = LdrPerformRelocations(NTHeaders, ImageBase); + if (!NT_SUCCESS(Status)) + { + DPRINT1("LdrPerformRelocations() failed\n"); + return NULL; + } + } - if (Module != NULL) - { - *Module = LdrAddModuleEntry(ImageBase, NTHeaders, FullDosName); - (*Module)->SectionPointer = SectionHandle; - } - else - { - Module = &tmpModule; - Status = LdrFindEntryForAddress(ImageBase, Module); - if (!NT_SUCCESS(Status)) - { - return NULL; - } - } + if (Module != NULL) + { + *Module = LdrAddModuleEntry(ImageBase, NTHeaders, FullDosName); + (*Module)->SectionPointer = SectionHandle; + } + else + { + Module = &tmpModule; + Status = LdrFindEntryForAddress(ImageBase, Module); + if (!NT_SUCCESS(Status)) + { + return NULL; + } + } - if (ImageBase != (PVOID) NTHeaders->OptionalHeader.ImageBase) - { - (*Module)->Flags |= LDRP_IMAGE_NOT_AT_BASE; - } + if (ImageBase != (PVOID) NTHeaders->OptionalHeader.ImageBase) + { + (*Module)->Flags |= LDRP_IMAGE_NOT_AT_BASE; + } - /* Allocate memory for the ActivationContextStack */ - /* FIXME: Verify RtlAllocateActivationContextStack behavior */ - Status = RtlAllocateActivationContextStack(&ActivationContextStack); - if (NT_SUCCESS(Status)) - { - DPRINT("ActivationContextStack %x\n",ActivationContextStack); - DPRINT("ActiveFrame %x\n", ((PACTIVATION_CONTEXT_STACK)ActivationContextStack)->ActiveFrame); - NtCurrentTeb()->ActivationContextStackPointer = ActivationContextStack; - NtCurrentTeb()->ActivationContextStackPointer->ActiveFrame = NULL; - } - else - DPRINT1("Warning: Unable to allocate ActivationContextStack\n"); + /* Allocate memory for the ActivationContextStack */ + /* FIXME: Verify RtlAllocateActivationContextStack behavior */ + Status = RtlAllocateActivationContextStack(&ActivationContextStack); + if (NT_SUCCESS(Status)) + { + DPRINT("ActivationContextStack %x\n",ActivationContextStack); + DPRINT("ActiveFrame %x\n", ((PACTIVATION_CONTEXT_STACK)ActivationContextStack)->ActiveFrame); + NtCurrentTeb()->ActivationContextStackPointer = ActivationContextStack; + NtCurrentTeb()->ActivationContextStackPointer->ActiveFrame = NULL; + } + else + DPRINT1("Warning: Unable to allocate ActivationContextStack\n"); - /* - * If the DLL's imports symbols from other - * modules, fixup the imported calls entry points. - */ - DPRINT("About to fixup imports\n"); - Status = LdrFixupImports(NULL, *Module); - if (!NT_SUCCESS(Status)) - { - DPRINT1("LdrFixupImports() failed for %wZ\n", &(*Module)->BaseDllName); - return NULL; - } - DPRINT("Fixup done\n"); - RtlEnterCriticalSection(NtCurrentPeb()->LoaderLock); - Status = LdrpInitializeTlsForProccess(); - if (NT_SUCCESS(Status)) - { - Status = LdrpAttachProcess(); - } - if (NT_SUCCESS(Status)) - { - LdrpTlsCallback(*Module, DLL_PROCESS_ATTACH); - } + /* + * If the DLL's imports symbols from other + * modules, fixup the imported calls entry points. + */ + DPRINT("About to fixup imports\n"); + Status = LdrFixupImports(NULL, *Module); + if (!NT_SUCCESS(Status)) + { + DPRINT1("LdrFixupImports() failed for %wZ\n", &(*Module)->BaseDllName); + return NULL; + } + DPRINT("Fixup done\n"); + RtlEnterCriticalSection(NtCurrentPeb()->LoaderLock); + Status = LdrpInitializeTlsForProccess(); + if (NT_SUCCESS(Status)) + { + Status = LdrpAttachProcess(); + } + if (NT_SUCCESS(Status)) + { + LdrpTlsCallback(*Module, DLL_PROCESS_ATTACH); + } - RtlLeaveCriticalSection(NtCurrentPeb()->LoaderLock); - if (!NT_SUCCESS(Status)) - { - return NULL; - } + RtlLeaveCriticalSection(NtCurrentPeb()->LoaderLock); + if (!NT_SUCCESS(Status)) + { + return NULL; + } - /* - * Compute the DLL's entry point's address. - */ - DPRINT("ImageBase = %p\n", ImageBase); - DPRINT("AddressOfEntryPoint = 0x%lx\n",(ULONG)NTHeaders->OptionalHeader.AddressOfEntryPoint); - if (NTHeaders->OptionalHeader.AddressOfEntryPoint != 0) - { + /* + * Compute the DLL's entry point's address. + */ + DPRINT("ImageBase = %p\n", ImageBase); + DPRINT("AddressOfEntryPoint = 0x%lx\n",(ULONG)NTHeaders->OptionalHeader.AddressOfEntryPoint); + if (NTHeaders->OptionalHeader.AddressOfEntryPoint != 0) + { EntryPoint = (PEPFUNC) ((ULONG_PTR)ImageBase - + NTHeaders->OptionalHeader.AddressOfEntryPoint); - } - DPRINT("LdrPEStartup() = %p\n",EntryPoint); - return EntryPoint; + + NTHeaders->OptionalHeader.AddressOfEntryPoint); + } + DPRINT("LdrPEStartup() = %p\n",EntryPoint); + return EntryPoint; } static NTSTATUS @@ -2260,9 +2266,9 @@ LdrpLoadModule(IN PWSTR SearchPath OPTIONAL, PVOID ArbitraryUserPointer; if (Module == NULL) - { + { Module = &tmpModule; - } + } /* adjust the full dll name */ LdrAdjustDllName(&AdjustedName, Name, FALSE); @@ -2272,29 +2278,30 @@ LdrpLoadModule(IN PWSTR SearchPath OPTIONAL, /* Test if dll is already loaded */ Status = LdrFindEntryForName(&AdjustedName, Module, TRUE); if (NT_SUCCESS(Status)) - { + { RtlFreeUnicodeString(&AdjustedName); if (NULL != BaseAddress) - { + { *BaseAddress = (*Module)->DllBase; - } - } + } + } else - { + { /* Open or create dll image section */ Status = LdrpMapKnownDll(&AdjustedName, &FullDosName, &SectionHandle); if (!NT_SUCCESS(Status)) - { + { MappedAsDataFile = (0 != (LoadFlags & LOAD_LIBRARY_AS_DATAFILE)); Status = LdrpMapDllImageFile(SearchPath, &AdjustedName, &FullDosName, MappedAsDataFile, &SectionHandle); - } + } if (!NT_SUCCESS(Status)) - { - DPRINT1("Failed to create or open dll section of '%wZ' (Status %lx)\n", &AdjustedName, Status); + { + DPRINT1("Failed to create or open dll section of '%wZ' (Status %lx)\n", + &AdjustedName, Status); RtlFreeUnicodeString(&AdjustedName); return Status; - } + } RtlFreeUnicodeString(&AdjustedName); /* Map the dll into the process */ ViewSize = 0; @@ -2313,73 +2320,73 @@ LdrpLoadModule(IN PWSTR SearchPath OPTIONAL, PAGE_READONLY); NtCurrentTeb()->NtTib.ArbitraryUserPointer = ArbitraryUserPointer; if (!NT_SUCCESS(Status)) - { + { DPRINT1("map view of section failed (Status 0x%08lx)\n", Status); RtlFreeUnicodeString(&FullDosName); NtClose(SectionHandle); return(Status); - } + } if (NULL != BaseAddress) - { + { *BaseAddress = ImageBase; - } + } if (!MappedAsDataFile) - { + { /* Get and check the NT headers */ NtHeaders = RtlImageNtHeader(ImageBase); if (NtHeaders == NULL) - { + { DPRINT1("RtlImageNtHeaders() failed\n"); NtUnmapViewOfSection (NtCurrentProcess (), ImageBase); NtClose (SectionHandle); RtlFreeUnicodeString(&FullDosName); return STATUS_UNSUCCESSFUL; - } - } + } + } DPRINT("Mapped %wZ at %x\n", &FullDosName, ImageBase); if (MappedAsDataFile) - { + { ASSERT(NULL != BaseAddress); if (NULL != BaseAddress) - { + { *BaseAddress = (PVOID) ((char *) *BaseAddress + 1); - } + } *Module = NULL; RtlFreeUnicodeString(&FullDosName); NtClose(SectionHandle); return STATUS_SUCCESS; - } + } /* If the base address is different from the * one the DLL is actually loaded, perform any * relocation. */ if (ImageBase != (PVOID) NtHeaders->OptionalHeader.ImageBase) - { + { DPRINT1("Relocating (%lx -> %p) %wZ\n", - NtHeaders->OptionalHeader.ImageBase, ImageBase, &FullDosName); + NtHeaders->OptionalHeader.ImageBase, ImageBase, &FullDosName); Status = LdrPerformRelocations(NtHeaders, ImageBase); if (!NT_SUCCESS(Status)) - { + { DPRINT1("LdrPerformRelocations() failed\n"); NtUnmapViewOfSection (NtCurrentProcess (), ImageBase); NtClose (SectionHandle); RtlFreeUnicodeString(&FullDosName); return STATUS_UNSUCCESSFUL; - } - } + } + } *Module = LdrAddModuleEntry(ImageBase, NtHeaders, FullDosName.Buffer); (*Module)->SectionPointer = SectionHandle; if (ImageBase != (PVOID) NtHeaders->OptionalHeader.ImageBase) - { + { (*Module)->Flags |= LDRP_IMAGE_NOT_AT_BASE; - } + } if (NtHeaders->FileHeader.Characteristics & IMAGE_FILE_DLL) - { + { (*Module)->Flags |= LDRP_IMAGE_DLL; - } + } /* fixup the imported calls entry points */ Status = LdrFixupImports(SearchPath, *Module); if (!NT_SUCCESS(Status)) - { + { DPRINT1("LdrFixupImports failed for %wZ, status=%x\n", &(*Module)->BaseDllName, Status); NtUnmapViewOfSection (NtCurrentProcess (), ImageBase); NtClose (SectionHandle); @@ -2389,13 +2396,13 @@ LdrpLoadModule(IN PWSTR SearchPath OPTIONAL, RemoveEntryList (&(*Module)->InLoadOrderLinks); RtlFreeHeap (RtlGetProcessHeap (), 0, Module); return Status; - } + } RtlEnterCriticalSection(NtCurrentPeb()->LoaderLock); InsertTailList(&NtCurrentPeb()->Ldr->InInitializationOrderModuleList, &(*Module)->InInitializationOrderModuleList); RtlLeaveCriticalSection (NtCurrentPeb()->LoaderLock); - } + } return STATUS_SUCCESS; } @@ -2403,108 +2410,108 @@ static NTSTATUS LdrpUnloadModule(PLDR_DATA_TABLE_ENTRY Module, BOOLEAN Unload) { - PIMAGE_IMPORT_DESCRIPTOR ImportModuleDirectory; - PIMAGE_BOUND_IMPORT_DESCRIPTOR BoundImportDescriptor; - PIMAGE_BOUND_IMPORT_DESCRIPTOR BoundImportDescriptorCurrent; - PCHAR ImportedName; - PLDR_DATA_TABLE_ENTRY ImportedModule; - NTSTATUS Status = 0; - LONG LoadCount; - ULONG Size; + PIMAGE_IMPORT_DESCRIPTOR ImportModuleDirectory; + PIMAGE_BOUND_IMPORT_DESCRIPTOR BoundImportDescriptor; + PIMAGE_BOUND_IMPORT_DESCRIPTOR BoundImportDescriptorCurrent; + PCHAR ImportedName; + PLDR_DATA_TABLE_ENTRY ImportedModule; + NTSTATUS Status = 0; + LONG LoadCount; + ULONG Size; - if (Unload) - { - RtlEnterCriticalSection(NtCurrentPeb()->LoaderLock); - } + if (Unload) + { + RtlEnterCriticalSection(NtCurrentPeb()->LoaderLock); + } - LoadCount = LdrpDecrementLoadCount(Module, Unload); + LoadCount = LdrpDecrementLoadCount(Module, Unload); - TRACE_LDR("Unload %wZ, LoadCount %d\n", &Module->BaseDllName, LoadCount); + TRACE_LDR("Unload %wZ, LoadCount %d\n", &Module->BaseDllName, LoadCount); - if (LoadCount == 0) - { - /* ?????????????????? */ - } - else if (!(Module->Flags & LDRP_STATIC_LINK) && LoadCount == 1) - { - BoundImportDescriptor = (PIMAGE_BOUND_IMPORT_DESCRIPTOR) - RtlImageDirectoryEntryToData(Module->DllBase, - TRUE, - IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT, - &Size); - if (BoundImportDescriptor) + if (LoadCount == 0) + { + /* ?????????????????? */ + } + else if (!(Module->Flags & LDRP_STATIC_LINK) && LoadCount == 1) + { + BoundImportDescriptor = (PIMAGE_BOUND_IMPORT_DESCRIPTOR) + RtlImageDirectoryEntryToData(Module->DllBase, + TRUE, + IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT, + &Size); + if (BoundImportDescriptor) { - /* dereferencing all imported modules, use the bound import descriptor */ - BoundImportDescriptorCurrent = BoundImportDescriptor; - while (BoundImportDescriptorCurrent->OffsetModuleName) + /* dereferencing all imported modules, use the bound import descriptor */ + BoundImportDescriptorCurrent = BoundImportDescriptor; + while (BoundImportDescriptorCurrent->OffsetModuleName) { - ImportedName = (PCHAR)BoundImportDescriptor + BoundImportDescriptorCurrent->OffsetModuleName; - TRACE_LDR("%wZ trys to unload %s\n", &Module->BaseDllName, ImportedName); - Status = LdrpGetOrLoadModule(NULL, ImportedName, &ImportedModule, FALSE); - if (!NT_SUCCESS(Status)) + ImportedName = (PCHAR)BoundImportDescriptor + BoundImportDescriptorCurrent->OffsetModuleName; + TRACE_LDR("%wZ trys to unload %s\n", &Module->BaseDllName, ImportedName); + Status = LdrpGetOrLoadModule(NULL, ImportedName, &ImportedModule, FALSE); + if (!NT_SUCCESS(Status)) { - DPRINT1("unable to found imported modul %s\n", ImportedName); + DPRINT1("unable to found imported modul %s\n", ImportedName); } - else + else { - if (Module != ImportedModule) + if (Module != ImportedModule) { - Status = LdrpUnloadModule(ImportedModule, FALSE); - if (!NT_SUCCESS(Status)) + Status = LdrpUnloadModule(ImportedModule, FALSE); + if (!NT_SUCCESS(Status)) { - DPRINT1("unable to unload %s\n", ImportedName); + DPRINT1("unable to unload %s\n", ImportedName); } } } - BoundImportDescriptorCurrent++; + BoundImportDescriptorCurrent++; } - } - else - { - ImportModuleDirectory = (PIMAGE_IMPORT_DESCRIPTOR) - RtlImageDirectoryEntryToData(Module->DllBase, - TRUE, - IMAGE_DIRECTORY_ENTRY_IMPORT, - &Size); - if (ImportModuleDirectory) - { - /* dereferencing all imported modules, use the import descriptor */ - while (ImportModuleDirectory->Name) - { - ImportedName = (PCHAR)Module->DllBase + ImportModuleDirectory->Name; - TRACE_LDR("%wZ trys to unload %s\n", &Module->BaseDllName, ImportedName); - Status = LdrpGetOrLoadModule(NULL, ImportedName, &ImportedModule, FALSE); - if (!NT_SUCCESS(Status)) - { - DPRINT1("unable to found imported modul %s\n", ImportedName); - } - else - { - if (Module != ImportedModule) - { - Status = LdrpUnloadModule(ImportedModule, FALSE); - if (!NT_SUCCESS(Status)) - { - DPRINT1("unable to unload %s\n", ImportedName); - } - } - } - ImportModuleDirectory++; - } - } - } - } + } + else + { + ImportModuleDirectory = (PIMAGE_IMPORT_DESCRIPTOR) + RtlImageDirectoryEntryToData(Module->DllBase, + TRUE, + IMAGE_DIRECTORY_ENTRY_IMPORT, + &Size); + if (ImportModuleDirectory) + { + /* dereferencing all imported modules, use the import descriptor */ + while (ImportModuleDirectory->Name) + { + ImportedName = (PCHAR)Module->DllBase + ImportModuleDirectory->Name; + TRACE_LDR("%wZ trys to unload %s\n", &Module->BaseDllName, ImportedName); + Status = LdrpGetOrLoadModule(NULL, ImportedName, &ImportedModule, FALSE); + if (!NT_SUCCESS(Status)) + { + DPRINT1("unable to found imported modul %s\n", ImportedName); + } + else + { + if (Module != ImportedModule) + { + Status = LdrpUnloadModule(ImportedModule, FALSE); + if (!NT_SUCCESS(Status)) + { + DPRINT1("unable to unload %s\n", ImportedName); + } + } + } + ImportModuleDirectory++; + } + } + } + } - if (Unload) - { - if (!(Module->Flags & LDRP_STATIC_LINK)) - { - LdrpDetachProcess(FALSE); - } + if (Unload) + { + if (!(Module->Flags & LDRP_STATIC_LINK)) + { + LdrpDetachProcess(FALSE); + } - RtlLeaveCriticalSection (NtCurrentPeb()->LoaderLock); - } - return STATUS_SUCCESS; + RtlLeaveCriticalSection (NtCurrentPeb()->LoaderLock); + } + return STATUS_SUCCESS; } @@ -2514,27 +2521,27 @@ LdrpUnloadModule(PLDR_DATA_TABLE_ENTRY Module, NTSTATUS NTAPI LdrUnloadDll (IN PVOID BaseAddress) { - PLDR_DATA_TABLE_ENTRY Module; - NTSTATUS Status; + PLDR_DATA_TABLE_ENTRY Module; + NTSTATUS Status; - if (BaseAddress == NULL) - return STATUS_SUCCESS; + if (BaseAddress == NULL) + return STATUS_SUCCESS; - if (LdrMappedAsDataFile(&BaseAddress)) - { - Status = NtUnmapViewOfSection(NtCurrentProcess(), BaseAddress); - } - else - { - Status = LdrFindEntryForAddress(BaseAddress, &Module); - if (NT_SUCCESS(Status)) - { - TRACE_LDR("LdrUnloadDll, , unloading %wZ\n", &Module->BaseDllName); - Status = LdrpUnloadModule(Module, TRUE); - } - } + if (LdrMappedAsDataFile(&BaseAddress)) + { + Status = NtUnmapViewOfSection(NtCurrentProcess(), BaseAddress); + } + else + { + Status = LdrFindEntryForAddress(BaseAddress, &Module); + if (NT_SUCCESS(Status)) + { + TRACE_LDR("LdrUnloadDll, , unloading %wZ\n", &Module->BaseDllName); + Status = LdrpUnloadModule(Module, TRUE); + } + } - return Status; + return Status; } /* @@ -2555,22 +2562,22 @@ LdrDisableThreadCalloutsForDll(IN PVOID BaseAddress) ModuleListHead = &NtCurrentPeb()->Ldr->InLoadOrderModuleList; Entry = ModuleListHead->Flink; while (Entry != ModuleListHead) - { + { Module = CONTAINING_RECORD(Entry, LDR_DATA_TABLE_ENTRY, InLoadOrderLinks); DPRINT("BaseDllName %wZ BaseAddress %p\n", &Module->BaseDllName, Module->DllBase); if (Module->DllBase == BaseAddress) - { + { if (Module->TlsIndex == 0xFFFF) - { + { Module->Flags |= LDRP_DONT_CALL_FOR_THREADS; Status = STATUS_SUCCESS; - } + } break; - } + } Entry = Entry->Flink; - } + } RtlLeaveCriticalSection (NtCurrentPeb()->LoaderLock); return Status; } @@ -2588,22 +2595,22 @@ LdrGetDllHandle(IN PWSTR DllPath OPTIONAL, NTSTATUS Status; TRACE_LDR("LdrGetDllHandle, searching for %wZ from %S\n", - DllName, DllPath ? DllPath : L""); + DllName, DllPath ? DllPath : L""); /* NULL is the current executable */ if (DllName == NULL) - { + { *DllHandle = ExeModule->DllBase; DPRINT("BaseAddress 0x%lx\n", *DllHandle); return STATUS_SUCCESS; - } + } Status = LdrFindEntryForName(DllName, &Module, FALSE); if (NT_SUCCESS(Status)) - { + { *DllHandle = Module->DllBase; return STATUS_SUCCESS; - } + } DPRINT("Failed to find dll %wZ\n", DllName); *DllHandle = NULL; @@ -2671,17 +2678,17 @@ RtlPcToFileHeader(IN PVOID PcValue, ModuleListHead = &NtCurrentPeb()->Ldr->InLoadOrderModuleList; Entry = ModuleListHead->Flink; while (Entry != ModuleListHead) - { + { Module = CONTAINING_RECORD(Entry, LDR_DATA_TABLE_ENTRY, InLoadOrderLinks); if ((ULONG_PTR)PcValue >= (ULONG_PTR)Module->DllBase && - (ULONG_PTR)PcValue < (ULONG_PTR)Module->DllBase + Module->SizeOfImage) - { + (ULONG_PTR)PcValue < (ULONG_PTR)Module->DllBase + Module->SizeOfImage) + { ImageBase = Module->DllBase; break; - } + } Entry = Entry->Flink; - } + } RtlLeaveCriticalSection (NtCurrentPeb()->LoaderLock); *BaseOfImage = ImageBase; @@ -2697,50 +2704,50 @@ LdrGetProcedureAddress (IN PVOID BaseAddress, IN ULONG Ordinal, OUT PVOID *ProcedureAddress) { - NTSTATUS Status = STATUS_PROCEDURE_NOT_FOUND; - if (Name && Name->Length) - { - TRACE_LDR("LdrGetProcedureAddress by NAME - %Z\n", Name); - } - else - { - TRACE_LDR("LdrGetProcedureAddress by ORDINAL - %d\n", Ordinal); - } + NTSTATUS Status = STATUS_PROCEDURE_NOT_FOUND; + if (Name && Name->Length) + { + TRACE_LDR("LdrGetProcedureAddress by NAME - %Z\n", Name); + } + else + { + TRACE_LDR("LdrGetProcedureAddress by ORDINAL - %d\n", Ordinal); + } - DPRINT("LdrGetProcedureAddress (BaseAddress %p Name %Z Ordinal %lu ProcedureAddress %p)\n", - BaseAddress, Name, Ordinal, ProcedureAddress); + DPRINT("LdrGetProcedureAddress (BaseAddress %p Name %Z Ordinal %lu ProcedureAddress %p)\n", + BaseAddress, Name, Ordinal, ProcedureAddress); - _SEH2_TRY - { - if (Name && Name->Length) - { - /* by name */ - *ProcedureAddress = LdrGetExportByName(BaseAddress, (PUCHAR)Name->Buffer, 0xffff); - if (*ProcedureAddress != NULL) - { - Status = STATUS_SUCCESS; - } - DPRINT("LdrGetProcedureAddress: Can't resolve symbol '%Z'\n", Name); - } - else - { - /* by ordinal */ - Ordinal &= 0x0000FFFF; - *ProcedureAddress = LdrGetExportByOrdinal(BaseAddress, (WORD)Ordinal); - if (*ProcedureAddress) - { - Status = STATUS_SUCCESS; - } - DPRINT("LdrGetProcedureAddress: Can't resolve symbol @%lu\n", Ordinal); - } - } - _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) - { - Status = STATUS_DLL_NOT_FOUND; - } - _SEH2_END; + _SEH2_TRY + { + if (Name && Name->Length) + { + /* by name */ + *ProcedureAddress = LdrGetExportByName(BaseAddress, (PUCHAR)Name->Buffer, 0xffff); + if (*ProcedureAddress != NULL) + { + Status = STATUS_SUCCESS; + } + DPRINT("LdrGetProcedureAddress: Can't resolve symbol '%Z'\n", Name); + } + else + { + /* by ordinal */ + Ordinal &= 0x0000FFFF; + *ProcedureAddress = LdrGetExportByOrdinal(BaseAddress, (WORD)Ordinal); + if (*ProcedureAddress) + { + Status = STATUS_SUCCESS; + } + DPRINT("LdrGetProcedureAddress: Can't resolve symbol @%lu\n", Ordinal); + } + } + _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) + { + Status = STATUS_DLL_NOT_FOUND; + } + _SEH2_END; - return Status; + return Status; } /********************************************************************** @@ -2764,79 +2771,81 @@ LdrGetProcedureAddress (IN PVOID BaseAddress, static VOID LdrpDetachProcess(BOOLEAN UnloadAll) { - PLIST_ENTRY ModuleListHead; - PLIST_ENTRY Entry; - PLDR_DATA_TABLE_ENTRY Module; - static ULONG CallingCount = 0; + PLIST_ENTRY ModuleListHead; + PLIST_ENTRY Entry; + PLDR_DATA_TABLE_ENTRY Module; + static ULONG CallingCount = 0; - DPRINT("LdrpDetachProcess() called for %wZ\n", + DPRINT("LdrpDetachProcess() called for %wZ\n", &ExeModule->BaseDllName); - if (UnloadAll) - LdrpDllShutdownInProgress = TRUE; + if (UnloadAll) + LdrpDllShutdownInProgress = TRUE; - CallingCount++; + CallingCount++; - ModuleListHead = &NtCurrentPeb()->Ldr->InInitializationOrderModuleList; - Entry = ModuleListHead->Blink; - while (Entry != ModuleListHead) - { - Module = CONTAINING_RECORD(Entry, LDR_DATA_TABLE_ENTRY, InInitializationOrderModuleList); - if (((UnloadAll && Module->LoadCount == LDRP_PROCESS_CREATION_TIME) || Module->LoadCount == 0) && - Module->Flags & LDRP_ENTRY_PROCESSED && - !(Module->Flags & LDRP_UNLOAD_IN_PROGRESS)) - { - Module->Flags |= LDRP_UNLOAD_IN_PROGRESS; - if (Module == LdrpLastModule) - { - LdrpLastModule = NULL; - } - if (Module->Flags & LDRP_PROCESS_ATTACH_CALLED) - { - TRACE_LDR("Unload %wZ - Calling entry point at %x\n", - &Module->BaseDllName, Module->EntryPoint); - LdrpCallDllEntry(Module, DLL_PROCESS_DETACH, (PVOID)(Module->LoadCount == LDRP_PROCESS_CREATION_TIME ? 1 : 0)); - } - else - { - TRACE_LDR("Unload %wZ\n", &Module->BaseDllName); - } - Entry = ModuleListHead->Blink; - } - else - { - Entry = Entry->Blink; - } - } + ModuleListHead = &NtCurrentPeb()->Ldr->InInitializationOrderModuleList; + Entry = ModuleListHead->Blink; + while (Entry != ModuleListHead) + { + Module = CONTAINING_RECORD(Entry, LDR_DATA_TABLE_ENTRY, InInitializationOrderModuleList); + if (((UnloadAll && Module->LoadCount == LDRP_PROCESS_CREATION_TIME) || Module->LoadCount == 0) && + Module->Flags & LDRP_ENTRY_PROCESSED && + !(Module->Flags & LDRP_UNLOAD_IN_PROGRESS)) + { + Module->Flags |= LDRP_UNLOAD_IN_PROGRESS; + if (Module == LdrpLastModule) + { + LdrpLastModule = NULL; + } + if (Module->Flags & LDRP_PROCESS_ATTACH_CALLED) + { + TRACE_LDR("Unload %wZ - Calling entry point at %x\n", + &Module->BaseDllName, Module->EntryPoint); + LdrpCallDllEntry(Module, + DLL_PROCESS_DETACH, + (PVOID)(Module->LoadCount == LDRP_PROCESS_CREATION_TIME ? 1 : 0)); + } + else + { + TRACE_LDR("Unload %wZ\n", &Module->BaseDllName); + } + Entry = ModuleListHead->Blink; + } + else + { + Entry = Entry->Blink; + } + } - if (CallingCount == 1) - { - Entry = ModuleListHead->Blink; - while (Entry != ModuleListHead) - { - Module = CONTAINING_RECORD(Entry, LDR_DATA_TABLE_ENTRY, InInitializationOrderModuleList); - Entry = Entry->Blink; - if (Module->Flags & LDRP_UNLOAD_IN_PROGRESS && - ((UnloadAll && Module->LoadCount != LDRP_PROCESS_CREATION_TIME) || Module->LoadCount == 0)) - { - /* remove the module entry from the list */ - RemoveEntryList (&Module->InLoadOrderLinks); - RemoveEntryList (&Module->InInitializationOrderModuleList); + if (CallingCount == 1) + { + Entry = ModuleListHead->Blink; + while (Entry != ModuleListHead) + { + Module = CONTAINING_RECORD(Entry, LDR_DATA_TABLE_ENTRY, InInitializationOrderModuleList); + Entry = Entry->Blink; + if (Module->Flags & LDRP_UNLOAD_IN_PROGRESS && + ((UnloadAll && Module->LoadCount != LDRP_PROCESS_CREATION_TIME) || Module->LoadCount == 0)) + { + /* remove the module entry from the list */ + RemoveEntryList (&Module->InLoadOrderLinks); + RemoveEntryList (&Module->InInitializationOrderModuleList); - NtUnmapViewOfSection (NtCurrentProcess (), Module->DllBase); - NtClose (Module->SectionPointer); + NtUnmapViewOfSection (NtCurrentProcess (), Module->DllBase); + NtClose (Module->SectionPointer); - TRACE_LDR("%wZ unloaded\n", &Module->BaseDllName); + TRACE_LDR("%wZ unloaded\n", &Module->BaseDllName); - RtlFreeUnicodeString (&Module->FullDllName); - RtlFreeUnicodeString (&Module->BaseDllName); + RtlFreeUnicodeString (&Module->FullDllName); + RtlFreeUnicodeString (&Module->BaseDllName); - RtlFreeHeap (RtlGetProcessHeap (), 0, Module); - } - } - } - CallingCount--; - DPRINT("LdrpDetachProcess() done\n"); + RtlFreeHeap (RtlGetProcessHeap (), 0, Module); + } + } + } + CallingCount--; + DPRINT("LdrpDetachProcess() done\n"); } /********************************************************************** @@ -2861,47 +2870,47 @@ LdrpDetachProcess(BOOLEAN UnloadAll) static NTSTATUS LdrpAttachProcess(VOID) { - PLIST_ENTRY ModuleListHead; - PLIST_ENTRY Entry; - PLDR_DATA_TABLE_ENTRY Module; - BOOLEAN Result; - NTSTATUS Status = STATUS_SUCCESS; + PLIST_ENTRY ModuleListHead; + PLIST_ENTRY Entry; + PLDR_DATA_TABLE_ENTRY Module; + BOOLEAN Result; + NTSTATUS Status = STATUS_SUCCESS; - DPRINT("LdrpAttachProcess() called for %wZ\n", - &ExeModule->BaseDllName); + DPRINT("LdrpAttachProcess() called for %wZ\n", + &ExeModule->BaseDllName); - ModuleListHead = &NtCurrentPeb()->Ldr->InInitializationOrderModuleList; - Entry = ModuleListHead->Flink; - while (Entry != ModuleListHead) - { - Module = CONTAINING_RECORD(Entry, LDR_DATA_TABLE_ENTRY, InInitializationOrderModuleList); - if (!(Module->Flags & (LDRP_LOAD_IN_PROGRESS|LDRP_UNLOAD_IN_PROGRESS|LDRP_ENTRY_PROCESSED))) - { - Module->Flags |= LDRP_LOAD_IN_PROGRESS; - TRACE_LDR("%wZ loaded - Calling init routine at %x for process attaching\n", - &Module->BaseDllName, Module->EntryPoint); - Result = LdrpCallDllEntry(Module, DLL_PROCESS_ATTACH, (PVOID)(Module->LoadCount == LDRP_PROCESS_CREATION_TIME ? 1 : 0)); - if (!Result) - { - Status = STATUS_DLL_INIT_FAILED; - break; - } - if (Module->Flags & LDRP_IMAGE_DLL && Module->EntryPoint != 0) - { - Module->Flags |= LDRP_PROCESS_ATTACH_CALLED|LDRP_ENTRY_PROCESSED; - } - else - { - Module->Flags |= LDRP_ENTRY_PROCESSED; - } - Module->Flags &= ~LDRP_LOAD_IN_PROGRESS; - } - Entry = Entry->Flink; - } + ModuleListHead = &NtCurrentPeb()->Ldr->InInitializationOrderModuleList; + Entry = ModuleListHead->Flink; + while (Entry != ModuleListHead) + { + Module = CONTAINING_RECORD(Entry, LDR_DATA_TABLE_ENTRY, InInitializationOrderModuleList); + if (!(Module->Flags & (LDRP_LOAD_IN_PROGRESS|LDRP_UNLOAD_IN_PROGRESS|LDRP_ENTRY_PROCESSED))) + { + Module->Flags |= LDRP_LOAD_IN_PROGRESS; + TRACE_LDR("%wZ loaded - Calling init routine at %x for process attaching\n", + &Module->BaseDllName, Module->EntryPoint); + Result = LdrpCallDllEntry(Module, DLL_PROCESS_ATTACH, (PVOID)(Module->LoadCount == LDRP_PROCESS_CREATION_TIME ? 1 : 0)); + if (!Result) + { + Status = STATUS_DLL_INIT_FAILED; + break; + } + if (Module->Flags & LDRP_IMAGE_DLL && Module->EntryPoint != 0) + { + Module->Flags |= LDRP_PROCESS_ATTACH_CALLED|LDRP_ENTRY_PROCESSED; + } + else + { + Module->Flags |= LDRP_ENTRY_PROCESSED; + } + Module->Flags &= ~LDRP_LOAD_IN_PROGRESS; + } + Entry = Entry->Flink; + } - DPRINT("LdrpAttachProcess() done\n"); + DPRINT("LdrpAttachProcess() done\n"); - return Status; + return Status; } /* @@ -2910,7 +2919,7 @@ LdrpAttachProcess(VOID) BOOLEAN NTAPI RtlDllShutdownInProgress (VOID) { - return LdrpDllShutdownInProgress; + return LdrpDllShutdownInProgress; } /* @@ -2919,8 +2928,8 @@ RtlDllShutdownInProgress (VOID) NTSTATUS NTAPI LdrShutdownProcess (VOID) { - LdrpDetachProcess(TRUE); - return STATUS_SUCCESS; + LdrpDetachProcess(TRUE); + return STATUS_SUCCESS; } /* @@ -2930,47 +2939,47 @@ LdrShutdownProcess (VOID) NTSTATUS LdrpAttachThread (VOID) { - PLIST_ENTRY ModuleListHead; - PLIST_ENTRY Entry; - PLDR_DATA_TABLE_ENTRY Module; - NTSTATUS Status; + PLIST_ENTRY ModuleListHead; + PLIST_ENTRY Entry; + PLDR_DATA_TABLE_ENTRY Module; + NTSTATUS Status; - DPRINT("LdrpAttachThread() called for %wZ\n", - &ExeModule->BaseDllName); + DPRINT("LdrpAttachThread() called for %wZ\n", + &ExeModule->BaseDllName); - RtlEnterCriticalSection (NtCurrentPeb()->LoaderLock); + RtlEnterCriticalSection (NtCurrentPeb()->LoaderLock); - Status = LdrpInitializeTlsForThread(); + Status = LdrpInitializeTlsForThread(); - if (NT_SUCCESS(Status)) + if (NT_SUCCESS(Status)) { - ModuleListHead = &NtCurrentPeb()->Ldr->InInitializationOrderModuleList; - Entry = ModuleListHead->Flink; + ModuleListHead = &NtCurrentPeb()->Ldr->InInitializationOrderModuleList; + Entry = ModuleListHead->Flink; - while (Entry != ModuleListHead) + while (Entry != ModuleListHead) { - Module = CONTAINING_RECORD(Entry, LDR_DATA_TABLE_ENTRY, InInitializationOrderModuleList); - if (Module->Flags & LDRP_PROCESS_ATTACH_CALLED && - !(Module->Flags & LDRP_DONT_CALL_FOR_THREADS) && - !(Module->Flags & LDRP_UNLOAD_IN_PROGRESS)) + Module = CONTAINING_RECORD(Entry, LDR_DATA_TABLE_ENTRY, InInitializationOrderModuleList); + if (Module->Flags & LDRP_PROCESS_ATTACH_CALLED && + !(Module->Flags & LDRP_DONT_CALL_FOR_THREADS) && + !(Module->Flags & LDRP_UNLOAD_IN_PROGRESS)) { - TRACE_LDR("%wZ - Calling entry point at %x for thread attaching\n", - &Module->BaseDllName, Module->EntryPoint); - LdrpCallDllEntry(Module, DLL_THREAD_ATTACH, NULL); + TRACE_LDR("%wZ - Calling entry point at %x for thread attaching\n", + &Module->BaseDllName, Module->EntryPoint); + LdrpCallDllEntry(Module, DLL_THREAD_ATTACH, NULL); } - Entry = Entry->Flink; + Entry = Entry->Flink; } - Entry = NtCurrentPeb()->Ldr->InLoadOrderModuleList.Flink; - Module = CONTAINING_RECORD(Entry, LDR_DATA_TABLE_ENTRY, InLoadOrderLinks); - LdrpTlsCallback(Module, DLL_THREAD_ATTACH); + Entry = NtCurrentPeb()->Ldr->InLoadOrderModuleList.Flink; + Module = CONTAINING_RECORD(Entry, LDR_DATA_TABLE_ENTRY, InLoadOrderLinks); + LdrpTlsCallback(Module, DLL_THREAD_ATTACH); } - RtlLeaveCriticalSection (NtCurrentPeb()->LoaderLock); + RtlLeaveCriticalSection (NtCurrentPeb()->LoaderLock); - DPRINT("LdrpAttachThread() done\n"); + DPRINT("LdrpAttachThread() done\n"); - return Status; + return Status; } @@ -2980,42 +2989,42 @@ LdrpAttachThread (VOID) NTSTATUS NTAPI LdrShutdownThread (VOID) { - PLIST_ENTRY ModuleListHead; - PLIST_ENTRY Entry; - PLDR_DATA_TABLE_ENTRY Module; + PLIST_ENTRY ModuleListHead; + PLIST_ENTRY Entry; + PLDR_DATA_TABLE_ENTRY Module; - DPRINT("LdrShutdownThread() called for %wZ\n", - &ExeModule->BaseDllName); + DPRINT("LdrShutdownThread() called for %wZ\n", + &ExeModule->BaseDllName); - RtlEnterCriticalSection (NtCurrentPeb()->LoaderLock); + RtlEnterCriticalSection (NtCurrentPeb()->LoaderLock); - ModuleListHead = &NtCurrentPeb()->Ldr->InInitializationOrderModuleList; - Entry = ModuleListHead->Blink; - while (Entry != ModuleListHead) - { - Module = CONTAINING_RECORD(Entry, LDR_DATA_TABLE_ENTRY, InInitializationOrderModuleList); + ModuleListHead = &NtCurrentPeb()->Ldr->InInitializationOrderModuleList; + Entry = ModuleListHead->Blink; + while (Entry != ModuleListHead) + { + Module = CONTAINING_RECORD(Entry, LDR_DATA_TABLE_ENTRY, InInitializationOrderModuleList); - if (Module->Flags & LDRP_PROCESS_ATTACH_CALLED && - !(Module->Flags & LDRP_DONT_CALL_FOR_THREADS) && - !(Module->Flags & LDRP_UNLOAD_IN_PROGRESS)) - { - TRACE_LDR("%wZ - Calling entry point at %x for thread detaching\n", - &Module->BaseDllName, Module->EntryPoint); - LdrpCallDllEntry(Module, DLL_THREAD_DETACH, NULL); - } - Entry = Entry->Blink; - } + if (Module->Flags & LDRP_PROCESS_ATTACH_CALLED && + !(Module->Flags & LDRP_DONT_CALL_FOR_THREADS) && + !(Module->Flags & LDRP_UNLOAD_IN_PROGRESS)) + { + TRACE_LDR("%wZ - Calling entry point at %x for thread detaching\n", + &Module->BaseDllName, Module->EntryPoint); + LdrpCallDllEntry(Module, DLL_THREAD_DETACH, NULL); + } + Entry = Entry->Blink; + } - RtlLeaveCriticalSection (NtCurrentPeb()->LoaderLock); + RtlLeaveCriticalSection (NtCurrentPeb()->LoaderLock); - if (LdrpTlsArray) - { - RtlFreeHeap (RtlGetProcessHeap(), 0, NtCurrentTeb()->ThreadLocalStoragePointer); - } + if (LdrpTlsArray) + { + RtlFreeHeap (RtlGetProcessHeap(), 0, NtCurrentTeb()->ThreadLocalStoragePointer); + } - DPRINT("LdrShutdownThread() done\n"); + DPRINT("LdrShutdownThread() done\n"); - return STATUS_SUCCESS; + return STATUS_SUCCESS; } @@ -3040,84 +3049,84 @@ LdrQueryProcessModuleInformation(IN PRTL_PROCESS_MODULES ModuleInformation OPTIO IN ULONG Size OPTIONAL, OUT PULONG ReturnedSize) { - PLIST_ENTRY ModuleListHead; - PLIST_ENTRY Entry; - PLDR_DATA_TABLE_ENTRY Module; - PRTL_PROCESS_MODULE_INFORMATION ModulePtr = NULL; - NTSTATUS Status = STATUS_SUCCESS; - ULONG UsedSize = sizeof(ULONG); - ANSI_STRING AnsiString; - PCHAR p; + PLIST_ENTRY ModuleListHead; + PLIST_ENTRY Entry; + PLDR_DATA_TABLE_ENTRY Module; + PRTL_PROCESS_MODULE_INFORMATION ModulePtr = NULL; + NTSTATUS Status = STATUS_SUCCESS; + ULONG UsedSize = sizeof(ULONG); + ANSI_STRING AnsiString; + PCHAR p; - DPRINT("LdrQueryProcessModuleInformation() called\n"); - // FIXME: This code is ultra-duplicated. see lib\rtl\dbgbuffer.c - RtlEnterCriticalSection (NtCurrentPeb()->LoaderLock); + DPRINT("LdrQueryProcessModuleInformation() called\n"); +// FIXME: This code is ultra-duplicated. see lib\rtl\dbgbuffer.c + RtlEnterCriticalSection (NtCurrentPeb()->LoaderLock); - if (ModuleInformation == NULL || Size == 0) + if (ModuleInformation == NULL || Size == 0) { - Status = STATUS_INFO_LENGTH_MISMATCH; + Status = STATUS_INFO_LENGTH_MISMATCH; } - else + else { - ModuleInformation->NumberOfModules = 0; - ModulePtr = &ModuleInformation->Modules[0]; - Status = STATUS_SUCCESS; + ModuleInformation->NumberOfModules = 0; + ModulePtr = &ModuleInformation->Modules[0]; + Status = STATUS_SUCCESS; } - ModuleListHead = &NtCurrentPeb()->Ldr->InLoadOrderModuleList; - Entry = ModuleListHead->Flink; + ModuleListHead = &NtCurrentPeb()->Ldr->InLoadOrderModuleList; + Entry = ModuleListHead->Flink; - while (Entry != ModuleListHead) + while (Entry != ModuleListHead) { - Module = CONTAINING_RECORD(Entry, LDR_DATA_TABLE_ENTRY, InLoadOrderLinks); + Module = CONTAINING_RECORD(Entry, LDR_DATA_TABLE_ENTRY, InLoadOrderLinks); - DPRINT(" Module %wZ\n", - &Module->FullDllName); + DPRINT(" Module %wZ\n", + &Module->FullDllName); - if (UsedSize > Size) + if (UsedSize > Size) { - Status = STATUS_INFO_LENGTH_MISMATCH; + Status = STATUS_INFO_LENGTH_MISMATCH; } - else if (ModuleInformation != NULL) + else if (ModuleInformation != NULL) { - ModulePtr->Section = 0; - ModulePtr->MappedBase = NULL; // FIXME: ?? - ModulePtr->ImageBase = Module->DllBase; - ModulePtr->ImageSize = Module->SizeOfImage; - ModulePtr->Flags = Module->Flags; - ModulePtr->LoadOrderIndex = 0; // FIXME: ?? - ModulePtr->InitOrderIndex = 0; // FIXME: ?? - ModulePtr->LoadCount = Module->LoadCount; + ModulePtr->Section = 0; + ModulePtr->MappedBase = NULL; // FIXME: ?? + ModulePtr->ImageBase = Module->DllBase; + ModulePtr->ImageSize = Module->SizeOfImage; + ModulePtr->Flags = Module->Flags; + ModulePtr->LoadOrderIndex = 0; // FIXME: ?? + ModulePtr->InitOrderIndex = 0; // FIXME: ?? + ModulePtr->LoadCount = Module->LoadCount; - AnsiString.Length = 0; - AnsiString.MaximumLength = 256; - AnsiString.Buffer = ModulePtr->FullPathName; - RtlUnicodeStringToAnsiString(&AnsiString, - &Module->FullDllName, - FALSE); + AnsiString.Length = 0; + AnsiString.MaximumLength = 256; + AnsiString.Buffer = ModulePtr->FullPathName; + RtlUnicodeStringToAnsiString(&AnsiString, + &Module->FullDllName, + FALSE); - p = strrchr(ModulePtr->FullPathName, '\\'); - if (p != NULL) - ModulePtr->OffsetToFileName = p - ModulePtr->FullPathName + 1; - else - ModulePtr->OffsetToFileName = 0; + p = strrchr(ModulePtr->FullPathName, '\\'); + if (p != NULL) + ModulePtr->OffsetToFileName = p - ModulePtr->FullPathName + 1; + else + ModulePtr->OffsetToFileName = 0; - ModulePtr++; - ModuleInformation->NumberOfModules++; + ModulePtr++; + ModuleInformation->NumberOfModules++; } - UsedSize += sizeof(RTL_PROCESS_MODULE_INFORMATION); + UsedSize += sizeof(RTL_PROCESS_MODULE_INFORMATION); - Entry = Entry->Flink; + Entry = Entry->Flink; } - RtlLeaveCriticalSection (NtCurrentPeb()->LoaderLock); + RtlLeaveCriticalSection (NtCurrentPeb()->LoaderLock); - if (ReturnedSize != 0) - *ReturnedSize = UsedSize; + if (ReturnedSize != 0) + *ReturnedSize = UsedSize; - DPRINT("LdrQueryProcessModuleInformation() done\n"); + DPRINT("LdrQueryProcessModuleInformation() done\n"); - return(Status); + return(Status); } @@ -3125,69 +3134,69 @@ static BOOLEAN LdrpCheckImageChecksum (IN PVOID BaseAddress, IN ULONG ImageSize) { - PIMAGE_NT_HEADERS Header; - PUSHORT Ptr; - ULONG Sum; - ULONG CalcSum; - ULONG HeaderSum; - ULONG i; + PIMAGE_NT_HEADERS Header; + PUSHORT Ptr; + ULONG Sum; + ULONG CalcSum; + ULONG HeaderSum; + ULONG i; - Header = RtlImageNtHeader (BaseAddress); - if (Header == NULL) - return FALSE; + Header = RtlImageNtHeader (BaseAddress); + if (Header == NULL) + return FALSE; - HeaderSum = Header->OptionalHeader.CheckSum; - if (HeaderSum == 0) - return TRUE; + HeaderSum = Header->OptionalHeader.CheckSum; + if (HeaderSum == 0) + return TRUE; - Sum = 0; - Ptr = (PUSHORT) BaseAddress; - for (i = 0; i < ImageSize / sizeof (USHORT); i++) - { - Sum += (ULONG)*Ptr; - if (HIWORD(Sum) != 0) - { - Sum = LOWORD(Sum) + HIWORD(Sum); - } - Ptr++; - } - - if (ImageSize & 1) + Sum = 0; + Ptr = (PUSHORT) BaseAddress; + for (i = 0; i < ImageSize / sizeof (USHORT); i++) { - Sum += (ULONG)*((PUCHAR)Ptr); - if (HIWORD(Sum) != 0) + Sum += (ULONG)*Ptr; + if (HIWORD(Sum) != 0) { - Sum = LOWORD(Sum) + HIWORD(Sum); + Sum = LOWORD(Sum) + HIWORD(Sum); + } + Ptr++; + } + + if (ImageSize & 1) + { + Sum += (ULONG)*((PUCHAR)Ptr); + if (HIWORD(Sum) != 0) + { + Sum = LOWORD(Sum) + HIWORD(Sum); } } - CalcSum = (USHORT)(LOWORD(Sum) + HIWORD(Sum)); + CalcSum = (USHORT)(LOWORD(Sum) + HIWORD(Sum)); - /* Subtract image checksum from calculated checksum. */ - /* fix low word of checksum */ - if (LOWORD(CalcSum) >= LOWORD(HeaderSum)) + /* Subtract image checksum from calculated checksum. */ + /* fix low word of checksum */ + if (LOWORD(CalcSum) >= LOWORD(HeaderSum)) { - CalcSum -= LOWORD(HeaderSum); + CalcSum -= LOWORD(HeaderSum); } - else + else { - CalcSum = ((LOWORD(CalcSum) - LOWORD(HeaderSum)) & 0xFFFF) - 1; + CalcSum = ((LOWORD(CalcSum) - LOWORD(HeaderSum)) & 0xFFFF) - 1; } - /* fix high word of checksum */ - if (LOWORD(CalcSum) >= HIWORD(HeaderSum)) + /* fix high word of checksum */ + if (LOWORD(CalcSum) >= HIWORD(HeaderSum)) { - CalcSum -= HIWORD(HeaderSum); + CalcSum -= HIWORD(HeaderSum); } - else + else { - CalcSum = ((LOWORD(CalcSum) - HIWORD(HeaderSum)) & 0xFFFF) - 1; + CalcSum = ((LOWORD(CalcSum) - HIWORD(HeaderSum)) & 0xFFFF) - 1; } - /* add file length */ - CalcSum += ImageSize; + /* add file length */ + CalcSum += ImageSize; - return (BOOLEAN)(CalcSum == HeaderSum); + return (BOOLEAN)(CalcSum == HeaderSum); } /* @@ -3197,24 +3206,26 @@ LdrpCheckImageChecksum (IN PVOID BaseAddress, ULONG LdrpGetResidentSize(PIMAGE_NT_HEADERS NTHeaders) { - PIMAGE_SECTION_HEADER SectionHeader; - unsigned SectionIndex; - ULONG ResidentSize; + PIMAGE_SECTION_HEADER SectionHeader; + unsigned SectionIndex; + ULONG ResidentSize; - SectionHeader = (PIMAGE_SECTION_HEADER)((char *) &NTHeaders->OptionalHeader - + NTHeaders->FileHeader.SizeOfOptionalHeader); - ResidentSize = 0; - for (SectionIndex = 0; SectionIndex < NTHeaders->FileHeader.NumberOfSections; SectionIndex++) + SectionHeader = (PIMAGE_SECTION_HEADER)((char *) &NTHeaders->OptionalHeader + + NTHeaders->FileHeader.SizeOfOptionalHeader); + ResidentSize = 0; + for (SectionIndex = 0; + SectionIndex < NTHeaders->FileHeader.NumberOfSections; + SectionIndex++) { - if (0 == (SectionHeader->Characteristics & IMAGE_SCN_LNK_REMOVE) - && ResidentSize < SectionHeader->VirtualAddress + SectionHeader->Misc.VirtualSize) + if (0 == (SectionHeader->Characteristics & IMAGE_SCN_LNK_REMOVE) + && ResidentSize < SectionHeader->VirtualAddress + SectionHeader->Misc.VirtualSize) { - ResidentSize = SectionHeader->VirtualAddress + SectionHeader->Misc.VirtualSize; + ResidentSize = SectionHeader->VirtualAddress + SectionHeader->Misc.VirtualSize; } - SectionHeader++; + SectionHeader++; } - return ResidentSize; + return ResidentSize; } @@ -3240,75 +3251,75 @@ LdrVerifyImageMatchesChecksum (IN HANDLE FileHandle, IN PVOID CallbackContext, OUT PUSHORT ImageCharacterstics) { - FILE_STANDARD_INFORMATION FileInfo; - IO_STATUS_BLOCK IoStatusBlock; - HANDLE SectionHandle; - SIZE_T ViewSize; - PVOID BaseAddress; - BOOLEAN Result; - NTSTATUS Status; + FILE_STANDARD_INFORMATION FileInfo; + IO_STATUS_BLOCK IoStatusBlock; + HANDLE SectionHandle; + SIZE_T ViewSize; + PVOID BaseAddress; + BOOLEAN Result; + NTSTATUS Status; - DPRINT ("LdrVerifyImageMatchesChecksum() called\n"); + DPRINT ("LdrVerifyImageMatchesChecksum() called\n"); - Status = NtCreateSection (&SectionHandle, - SECTION_MAP_READ, - NULL, - NULL, - PAGE_READONLY, - SEC_COMMIT, - FileHandle); - if (!NT_SUCCESS(Status)) + Status = NtCreateSection (&SectionHandle, + SECTION_MAP_READ, + NULL, + NULL, + PAGE_READONLY, + SEC_COMMIT, + FileHandle); + if (!NT_SUCCESS(Status)) { - DPRINT1 ("NtCreateSection() failed (Status %lx)\n", Status); - return Status; + DPRINT1 ("NtCreateSection() failed (Status %lx)\n", Status); + return Status; } - ViewSize = 0; - BaseAddress = NULL; - Status = NtMapViewOfSection (SectionHandle, - NtCurrentProcess (), - &BaseAddress, - 0, - 0, - NULL, - &ViewSize, - ViewShare, - 0, - PAGE_READONLY); - if (!NT_SUCCESS(Status)) + ViewSize = 0; + BaseAddress = NULL; + Status = NtMapViewOfSection (SectionHandle, + NtCurrentProcess (), + &BaseAddress, + 0, + 0, + NULL, + &ViewSize, + ViewShare, + 0, + PAGE_READONLY); + if (!NT_SUCCESS(Status)) { - DPRINT1 ("NtMapViewOfSection() failed (Status %lx)\n", Status); - NtClose (SectionHandle); - return Status; + DPRINT1 ("NtMapViewOfSection() failed (Status %lx)\n", Status); + NtClose (SectionHandle); + return Status; } - Status = NtQueryInformationFile (FileHandle, - &IoStatusBlock, - &FileInfo, - sizeof (FILE_STANDARD_INFORMATION), - FileStandardInformation); - if (!NT_SUCCESS(Status)) + Status = NtQueryInformationFile(FileHandle, + &IoStatusBlock, + &FileInfo, + sizeof (FILE_STANDARD_INFORMATION), + FileStandardInformation); + if (!NT_SUCCESS(Status)) { - DPRINT1 ("NtMapViewOfSection() failed (Status %lx)\n", Status); - NtUnmapViewOfSection (NtCurrentProcess (), - BaseAddress); - NtClose (SectionHandle); - return Status; + DPRINT1 ("NtMapViewOfSection() failed (Status %lx)\n", Status); + NtUnmapViewOfSection (NtCurrentProcess(), + BaseAddress); + NtClose (SectionHandle); + return Status; } - Result = LdrpCheckImageChecksum (BaseAddress, - FileInfo.EndOfFile.u.LowPart); - if (Result == FALSE) + Result = LdrpCheckImageChecksum(BaseAddress, + FileInfo.EndOfFile.u.LowPart); + if (Result == FALSE) { - Status = STATUS_IMAGE_CHECKSUM_MISMATCH; + Status = STATUS_IMAGE_CHECKSUM_MISMATCH; } - NtUnmapViewOfSection (NtCurrentProcess (), - BaseAddress); + NtUnmapViewOfSection (NtCurrentProcess(), + BaseAddress); - NtClose (SectionHandle); + NtClose(SectionHandle); - return Status; + return Status; } @@ -3329,141 +3340,141 @@ LdrVerifyImageMatchesChecksum (IN HANDLE FileHandle, * @implemented */ NTSTATUS NTAPI -LdrQueryImageFileExecutionOptions (IN PUNICODE_STRING SubKey, - IN PCWSTR ValueName, - IN ULONG Type, - OUT PVOID Buffer, - IN ULONG BufferSize, - OUT PULONG ReturnedLength OPTIONAL) +LdrQueryImageFileExecutionOptions(IN PUNICODE_STRING SubKey, + IN PCWSTR ValueName, + IN ULONG Type, + OUT PVOID Buffer, + IN ULONG BufferSize, + OUT PULONG ReturnedLength OPTIONAL) { - PKEY_VALUE_PARTIAL_INFORMATION KeyInfo; - CHAR KeyInfoBuffer[sizeof(KEY_VALUE_PARTIAL_INFORMATION) + 32]; - OBJECT_ATTRIBUTES ObjectAttributes; - UNICODE_STRING ValueNameString; - UNICODE_STRING KeyName; - WCHAR NameBuffer[256]; - HANDLE KeyHandle; - ULONG KeyInfoSize; - ULONG ResultSize; - PWCHAR Ptr; - NTSTATUS Status; + PKEY_VALUE_PARTIAL_INFORMATION KeyInfo; + CHAR KeyInfoBuffer[sizeof(KEY_VALUE_PARTIAL_INFORMATION) + 32]; + OBJECT_ATTRIBUTES ObjectAttributes; + UNICODE_STRING ValueNameString; + UNICODE_STRING KeyName; + WCHAR NameBuffer[256]; + HANDLE KeyHandle; + ULONG KeyInfoSize; + ULONG ResultSize; + PWCHAR Ptr; + NTSTATUS Status; - wcscpy (NameBuffer, - L"\\Registry\\Machine\\Software\\Microsoft\\Windows NT\\CurrentVersion\\Image File Execution Options\\"); - Ptr = wcsrchr (SubKey->Buffer, L'\\'); - if (Ptr == NULL) + wcscpy (NameBuffer, + L"\\Registry\\Machine\\Software\\Microsoft\\Windows NT\\CurrentVersion\\Image File Execution Options\\"); + Ptr = wcsrchr (SubKey->Buffer, L'\\'); + if (Ptr == NULL) { - Ptr = SubKey->Buffer; + Ptr = SubKey->Buffer; } - else + else { - Ptr++; + Ptr++; } - wcscat (NameBuffer, Ptr); - RtlInitUnicodeString (&KeyName, - NameBuffer); + wcscat (NameBuffer, Ptr); + RtlInitUnicodeString (&KeyName, + NameBuffer); - InitializeObjectAttributes (&ObjectAttributes, - &KeyName, - OBJ_CASE_INSENSITIVE, - NULL, - NULL); + InitializeObjectAttributes(&ObjectAttributes, + &KeyName, + OBJ_CASE_INSENSITIVE, + NULL, + NULL); - Status = NtOpenKey (&KeyHandle, - KEY_READ, - &ObjectAttributes); - if (!NT_SUCCESS(Status)) + Status = NtOpenKey(&KeyHandle, + KEY_READ, + &ObjectAttributes); + if (!NT_SUCCESS(Status)) { - DPRINT ("NtOpenKey() failed (Status %lx)\n", Status); - return Status; + DPRINT ("NtOpenKey() failed (Status %lx)\n", Status); + return Status; } - KeyInfoSize = sizeof(KeyInfoBuffer); - KeyInfo = (PKEY_VALUE_PARTIAL_INFORMATION)KeyInfoBuffer; + KeyInfoSize = sizeof(KeyInfoBuffer); + KeyInfo = (PKEY_VALUE_PARTIAL_INFORMATION)KeyInfoBuffer; - RtlInitUnicodeString (&ValueNameString, - (PWSTR)ValueName); - Status = NtQueryValueKey (KeyHandle, - &ValueNameString, - KeyValuePartialInformation, - KeyInfo, - KeyInfoSize, - &ResultSize); - if (Status == STATUS_BUFFER_OVERFLOW) + RtlInitUnicodeString(&ValueNameString, + (PWSTR)ValueName); + Status = NtQueryValueKey(KeyHandle, + &ValueNameString, + KeyValuePartialInformation, + KeyInfo, + KeyInfoSize, + &ResultSize); + if (Status == STATUS_BUFFER_OVERFLOW) { /* We can allocate only if there is a process heap already */ if (!RtlGetProcessHeap()) - { - NtClose (KeyHandle); - return STATUS_NO_MEMORY; - } - KeyInfoSize = sizeof(KEY_VALUE_PARTIAL_INFORMATION) + KeyInfo->DataLength; - KeyInfo = RtlAllocateHeap (RtlGetProcessHeap(), - HEAP_ZERO_MEMORY, - KeyInfoSize); - if (KeyInfo == NULL) { - NtClose (KeyHandle); - return STATUS_INSUFFICIENT_RESOURCES; + NtClose (KeyHandle); + return STATUS_NO_MEMORY; + } + KeyInfoSize = sizeof(KEY_VALUE_PARTIAL_INFORMATION) + KeyInfo->DataLength; + KeyInfo = RtlAllocateHeap (RtlGetProcessHeap(), + HEAP_ZERO_MEMORY, + KeyInfoSize); + if (KeyInfo == NULL) + { + NtClose (KeyHandle); + return STATUS_INSUFFICIENT_RESOURCES; } - Status = NtQueryValueKey (KeyHandle, - &ValueNameString, - KeyValuePartialInformation, - KeyInfo, - KeyInfoSize, - &ResultSize); + Status = NtQueryValueKey (KeyHandle, + &ValueNameString, + KeyValuePartialInformation, + KeyInfo, + KeyInfoSize, + &ResultSize); } - NtClose (KeyHandle); + NtClose (KeyHandle); - if (!NT_SUCCESS(Status)) + if (!NT_SUCCESS(Status)) { - if ((PCHAR)KeyInfo != KeyInfoBuffer) + if ((PCHAR)KeyInfo != KeyInfoBuffer) { - RtlFreeHeap (RtlGetProcessHeap(), - 0, - KeyInfo); + RtlFreeHeap (RtlGetProcessHeap(), + 0, + KeyInfo); } - return Status; + return Status; } - if (KeyInfo->Type != Type) + if (KeyInfo->Type != Type) { - if ((PCHAR)KeyInfo != KeyInfoBuffer) + if ((PCHAR)KeyInfo != KeyInfoBuffer) { - RtlFreeHeap (RtlGetProcessHeap(), - 0, - KeyInfo); + RtlFreeHeap (RtlGetProcessHeap(), + 0, + KeyInfo); } - return STATUS_OBJECT_TYPE_MISMATCH; + return STATUS_OBJECT_TYPE_MISMATCH; } - ResultSize = BufferSize; - if (ResultSize < KeyInfo->DataLength) + ResultSize = BufferSize; + if (ResultSize < KeyInfo->DataLength) { - Status = STATUS_BUFFER_OVERFLOW; + Status = STATUS_BUFFER_OVERFLOW; } - else + else { - ResultSize = KeyInfo->DataLength; + ResultSize = KeyInfo->DataLength; } - RtlCopyMemory (Buffer, - &KeyInfo->Data, - ResultSize); + RtlCopyMemory (Buffer, + &KeyInfo->Data, + ResultSize); - if ((PCHAR)KeyInfo != KeyInfoBuffer) - { - RtlFreeHeap (RtlGetProcessHeap(), - 0, - KeyInfo); - } - - if (ReturnedLength != NULL) + if ((PCHAR)KeyInfo != KeyInfoBuffer) { - *ReturnedLength = ResultSize; + RtlFreeHeap (RtlGetProcessHeap(), + 0, + KeyInfo); } - return Status; + if (ReturnedLength != NULL) + { + *ReturnedLength = ResultSize; + } + + return Status; } From 1f982b14793af94084a7d4556b9234bd3a4bcbde Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Wed, 22 Dec 2010 13:07:04 +0000 Subject: [PATCH 087/181] [NTDLL] Move RtlPcToFileHeader to rtl/libsupp.c svn path=/trunk/; revision=50092 --- reactos/dll/ntdll/ldr/utils.c | 33 --------------------------------- reactos/dll/ntdll/rtl/libsupp.c | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 33 deletions(-) diff --git a/reactos/dll/ntdll/ldr/utils.c b/reactos/dll/ntdll/ldr/utils.c index 828b0066809..4482f93fdf4 100644 --- a/reactos/dll/ntdll/ldr/utils.c +++ b/reactos/dll/ntdll/ldr/utils.c @@ -2662,39 +2662,6 @@ LdrAddRefDll(IN ULONG Flags, return Status; } -/* - * @implemented - */ -PVOID NTAPI -RtlPcToFileHeader(IN PVOID PcValue, - PVOID* BaseOfImage) -{ - PLIST_ENTRY ModuleListHead; - PLIST_ENTRY Entry; - PLDR_DATA_TABLE_ENTRY Module; - PVOID ImageBase = NULL; - - RtlEnterCriticalSection (NtCurrentPeb()->LoaderLock); - ModuleListHead = &NtCurrentPeb()->Ldr->InLoadOrderModuleList; - Entry = ModuleListHead->Flink; - while (Entry != ModuleListHead) - { - Module = CONTAINING_RECORD(Entry, LDR_DATA_TABLE_ENTRY, InLoadOrderLinks); - - if ((ULONG_PTR)PcValue >= (ULONG_PTR)Module->DllBase && - (ULONG_PTR)PcValue < (ULONG_PTR)Module->DllBase + Module->SizeOfImage) - { - ImageBase = Module->DllBase; - break; - } - Entry = Entry->Flink; - } - RtlLeaveCriticalSection (NtCurrentPeb()->LoaderLock); - - *BaseOfImage = ImageBase; - return ImageBase; -} - /* * @implemented */ diff --git a/reactos/dll/ntdll/rtl/libsupp.c b/reactos/dll/ntdll/rtl/libsupp.c index 5237098df27..4239183c436 100644 --- a/reactos/dll/ntdll/rtl/libsupp.c +++ b/reactos/dll/ntdll/rtl/libsupp.c @@ -486,3 +486,36 @@ done: *ret = resdirptr; return STATUS_SUCCESS; } + +/* + * @implemented + */ +PVOID NTAPI +RtlPcToFileHeader(IN PVOID PcValue, + PVOID* BaseOfImage) +{ + PLIST_ENTRY ModuleListHead; + PLIST_ENTRY Entry; + PLDR_DATA_TABLE_ENTRY Module; + PVOID ImageBase = NULL; + + RtlEnterCriticalSection (NtCurrentPeb()->LoaderLock); + ModuleListHead = &NtCurrentPeb()->Ldr->InLoadOrderModuleList; + Entry = ModuleListHead->Flink; + while (Entry != ModuleListHead) + { + Module = CONTAINING_RECORD(Entry, LDR_DATA_TABLE_ENTRY, InLoadOrderLinks); + + if ((ULONG_PTR)PcValue >= (ULONG_PTR)Module->DllBase && + (ULONG_PTR)PcValue < (ULONG_PTR)Module->DllBase + Module->SizeOfImage) + { + ImageBase = Module->DllBase; + break; + } + Entry = Entry->Flink; + } + RtlLeaveCriticalSection (NtCurrentPeb()->LoaderLock); + + *BaseOfImage = ImageBase; + return ImageBase; +} From 2342366fe3f31fee603a4fc93e7b88277e17e623 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Wed, 22 Dec 2010 13:33:09 +0000 Subject: [PATCH 088/181] [FORMATTING] Apply indentation of 4 spaces. svn path=/trunk/; revision=50093 --- reactos/lib/rtl/image.c | 189 ++++++++++++++++++++-------------------- 1 file changed, 94 insertions(+), 95 deletions(-) diff --git a/reactos/lib/rtl/image.c b/reactos/lib/rtl/image.c index 844fbca67f5..3886fb5ac5e 100644 --- a/reactos/lib/rtl/image.c +++ b/reactos/lib/rtl/image.c @@ -22,9 +22,10 @@ BOOLEAN NTAPI -LdrVerifyMappedImageMatchesChecksum(IN PVOID BaseAddress, - IN ULONG NumberOfBytes, - IN ULONG FileLength) +LdrVerifyMappedImageMatchesChecksum( + IN PVOID BaseAddress, + IN ULONG NumberOfBytes, + IN ULONG FileLength) { /* FIXME: TODO */ return TRUE; @@ -33,26 +34,26 @@ LdrVerifyMappedImageMatchesChecksum(IN PVOID BaseAddress, /* * @implemented */ -PIMAGE_NT_HEADERS NTAPI -RtlImageNtHeader (IN PVOID BaseAddress) +PIMAGE_NT_HEADERS +NTAPI +RtlImageNtHeader(IN PVOID BaseAddress) { - PIMAGE_NT_HEADERS NtHeader; - PIMAGE_DOS_HEADER DosHeader = (PIMAGE_DOS_HEADER)BaseAddress; + PIMAGE_NT_HEADERS NtHeader; + PIMAGE_DOS_HEADER DosHeader = (PIMAGE_DOS_HEADER)BaseAddress; - if (DosHeader && SWAPW(DosHeader->e_magic) != IMAGE_DOS_SIGNATURE) + if (DosHeader && SWAPW(DosHeader->e_magic) != IMAGE_DOS_SIGNATURE) { - DPRINT1("DosHeader->e_magic %x\n", SWAPW(DosHeader->e_magic)); - DPRINT1("NtHeader 0x%lx\n", ((ULONG_PTR)BaseAddress + SWAPD(DosHeader->e_lfanew))); + DPRINT1("DosHeader->e_magic %x\n", SWAPW(DosHeader->e_magic)); + DPRINT1("NtHeader 0x%lx\n", ((ULONG_PTR)BaseAddress + SWAPD(DosHeader->e_lfanew))); + } + else + { + NtHeader = (PIMAGE_NT_HEADERS)((ULONG_PTR)BaseAddress + SWAPD(DosHeader->e_lfanew)); + if (SWAPD(NtHeader->Signature) == IMAGE_NT_SIGNATURE) + return NtHeader; } - if (DosHeader && SWAPW(DosHeader->e_magic) == IMAGE_DOS_SIGNATURE) - { - NtHeader = (PIMAGE_NT_HEADERS)((ULONG_PTR)BaseAddress + SWAPD(DosHeader->e_lfanew)); - if (SWAPD(NtHeader->Signature) == IMAGE_NT_SIGNATURE) - return NtHeader; - } - - return NULL; + return NULL; } @@ -61,40 +62,41 @@ RtlImageNtHeader (IN PVOID BaseAddress) */ PVOID NTAPI -RtlImageDirectoryEntryToData(PVOID BaseAddress, - BOOLEAN MappedAsImage, - USHORT Directory, - PULONG Size) +RtlImageDirectoryEntryToData( + PVOID BaseAddress, + BOOLEAN MappedAsImage, + USHORT Directory, + PULONG Size) { - PIMAGE_NT_HEADERS NtHeader; - ULONG Va; + PIMAGE_NT_HEADERS NtHeader; + ULONG Va; - /* Magic flag for non-mapped images. */ - if ((ULONG_PTR)BaseAddress & 1) - { - BaseAddress = (PVOID)((ULONG_PTR)BaseAddress & ~1); - MappedAsImage = FALSE; - } + /* Magic flag for non-mapped images. */ + if ((ULONG_PTR)BaseAddress & 1) + { + BaseAddress = (PVOID)((ULONG_PTR)BaseAddress & ~1); + MappedAsImage = FALSE; + } - NtHeader = RtlImageNtHeader (BaseAddress); - if (NtHeader == NULL) - return NULL; + NtHeader = RtlImageNtHeader (BaseAddress); + if (NtHeader == NULL) + return NULL; - if (Directory >= SWAPD(NtHeader->OptionalHeader.NumberOfRvaAndSizes)) - return NULL; + if (Directory >= SWAPD(NtHeader->OptionalHeader.NumberOfRvaAndSizes)) + return NULL; - Va = SWAPD(NtHeader->OptionalHeader.DataDirectory[Directory].VirtualAddress); - if (Va == 0) - return NULL; + Va = SWAPD(NtHeader->OptionalHeader.DataDirectory[Directory].VirtualAddress); + if (Va == 0) + return NULL; - *Size = SWAPD(NtHeader->OptionalHeader.DataDirectory[Directory].Size); + *Size = SWAPD(NtHeader->OptionalHeader.DataDirectory[Directory].Size); - if (MappedAsImage || Va < SWAPD(NtHeader->OptionalHeader.SizeOfHeaders)) - return (PVOID)((ULONG_PTR)BaseAddress + Va); + if (MappedAsImage || Va < SWAPD(NtHeader->OptionalHeader.SizeOfHeaders)) + return (PVOID)((ULONG_PTR)BaseAddress + Va); - /* image mapped as ordinary file, we must find raw pointer */ - return RtlImageRvaToVa (NtHeader, BaseAddress, Va, NULL); + /* image mapped as ordinary file, we must find raw pointer */ + return RtlImageRvaToVa (NtHeader, BaseAddress, Va, NULL); } @@ -103,28 +105,27 @@ RtlImageDirectoryEntryToData(PVOID BaseAddress, */ PIMAGE_SECTION_HEADER NTAPI -RtlImageRvaToSection ( - PIMAGE_NT_HEADERS NtHeader, - PVOID BaseAddress, - ULONG Rva - ) +RtlImageRvaToSection( + PIMAGE_NT_HEADERS NtHeader, + PVOID BaseAddress, + ULONG Rva) { - PIMAGE_SECTION_HEADER Section; - ULONG Va; - ULONG Count; + PIMAGE_SECTION_HEADER Section; + ULONG Va; + ULONG Count; - Count = SWAPW(NtHeader->FileHeader.NumberOfSections); - Section = IMAGE_FIRST_SECTION(NtHeader); + Count = SWAPW(NtHeader->FileHeader.NumberOfSections); + Section = IMAGE_FIRST_SECTION(NtHeader); - while (Count--) - { - Va = SWAPD(Section->VirtualAddress); - if ((Va <= Rva) && - (Rva < Va + SWAPD(Section->Misc.VirtualSize))) - return Section; - Section++; - } - return NULL; + while (Count--) + { + Va = SWAPD(Section->VirtualAddress); + if ((Va <= Rva) && + (Rva < Va + SWAPD(Section->Misc.VirtualSize))) + return Section; + Section++; + } + return NULL; } @@ -133,34 +134,33 @@ RtlImageRvaToSection ( */ PVOID NTAPI -RtlImageRvaToVa ( - PIMAGE_NT_HEADERS NtHeader, - PVOID BaseAddress, - ULONG Rva, - PIMAGE_SECTION_HEADER *SectionHeader - ) +RtlImageRvaToVa( + PIMAGE_NT_HEADERS NtHeader, + PVOID BaseAddress, + ULONG Rva, + PIMAGE_SECTION_HEADER *SectionHeader) { - PIMAGE_SECTION_HEADER Section = NULL; + PIMAGE_SECTION_HEADER Section = NULL; - if (SectionHeader) - Section = *SectionHeader; + if (SectionHeader) + Section = *SectionHeader; - if (Section == NULL || - Rva < SWAPD(Section->VirtualAddress) || - Rva >= SWAPD(Section->VirtualAddress) + SWAPD(Section->Misc.VirtualSize)) - { - Section = RtlImageRvaToSection (NtHeader, BaseAddress, Rva); - if (Section == NULL) - return 0; + if (Section == NULL || + Rva < SWAPD(Section->VirtualAddress) || + Rva >= SWAPD(Section->VirtualAddress) + SWAPD(Section->Misc.VirtualSize)) + { + Section = RtlImageRvaToSection (NtHeader, BaseAddress, Rva); + if (Section == NULL) + return 0; - if (SectionHeader) - *SectionHeader = Section; - } + if (SectionHeader) + *SectionHeader = Section; + } - return (PVOID)((ULONG_PTR)BaseAddress + - Rva + - SWAPD(Section->PointerToRawData) - - (ULONG_PTR)SWAPD(Section->VirtualAddress)); + return (PVOID)((ULONG_PTR)BaseAddress + + Rva + + SWAPD(Section->PointerToRawData) - + (ULONG_PTR)SWAPD(Section->VirtualAddress)); } PIMAGE_BASE_RELOCATION @@ -169,8 +169,7 @@ LdrProcessRelocationBlockLongLong( IN ULONG_PTR Address, IN ULONG Count, IN PUSHORT TypeOffset, - IN LONGLONG Delta - ) + IN LONGLONG Delta) { SHORT Offset; USHORT Type; @@ -197,8 +196,8 @@ LdrProcessRelocationBlockLongLong( {*/ switch (Type) { - /* case IMAGE_REL_BASED_SECTION : */ - /* case IMAGE_REL_BASED_REL32 : */ + /* case IMAGE_REL_BASED_SECTION : */ + /* case IMAGE_REL_BASED_REL32 : */ case IMAGE_REL_BASED_ABSOLUTE: break; @@ -242,8 +241,7 @@ LdrRelocateImageWithBias( IN PCCH LoaderName, IN ULONG Success, IN ULONG Conflict, - IN ULONG Invalid - ) + IN ULONG Invalid) { PIMAGE_NT_HEADERS NtHeaders; PIMAGE_DATA_DIRECTORY RelocationDDir; @@ -275,16 +273,16 @@ LdrRelocateImageWithBias( RelocationEnd = (PIMAGE_BASE_RELOCATION)((ULONG_PTR)RelocationDir + SWAPD(RelocationDDir->Size)); while (RelocationDir < RelocationEnd && - SWAPW(RelocationDir->SizeOfBlock) > 0) + SWAPW(RelocationDir->SizeOfBlock) > 0) { Count = (SWAPW(RelocationDir->SizeOfBlock) - sizeof(IMAGE_BASE_RELOCATION)) / sizeof(USHORT); Address = (ULONG_PTR)RVA(BaseAddress, SWAPD(RelocationDir->VirtualAddress)); TypeOffset = (PUSHORT)(RelocationDir + 1); RelocationDir = LdrProcessRelocationBlockLongLong(Address, - Count, - TypeOffset, - Delta); + Count, + TypeOffset, + Delta); if (RelocationDir == NULL) { @@ -295,4 +293,5 @@ LdrRelocateImageWithBias( return Success; } + /* EOF */ From fc17a969381c2d75578bab7f6d7f73080112bcdf Mon Sep 17 00:00:00 2001 From: Aleksey Bragin Date: Wed, 22 Dec 2010 14:26:36 +0000 Subject: [PATCH 089/181] [NTOS] - Always initialize TrapFrame segment selectors in KiEnterTrap, because further C code relies on at least TrapFrame->SegFs being correct. Running Arwinss on VirtualBox exposed this bug. I wouldn't find solution for this bug without Timo's great help! svn path=/trunk/; revision=50095 --- reactos/ntoskrnl/include/internal/i386/asmmacro.S | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/reactos/ntoskrnl/include/internal/i386/asmmacro.S b/reactos/ntoskrnl/include/internal/i386/asmmacro.S index 2a64a938320..d84872a7b7a 100644 --- a/reactos/ntoskrnl/include/internal/i386/asmmacro.S +++ b/reactos/ntoskrnl/include/internal/i386/asmmacro.S @@ -135,7 +135,17 @@ MACRO(KiEnterTrap, Flags) endif /* Save segment registers? */ - if (NOT (Flags AND KI_DONT_SAVE_SEGS)) + if (Flags AND KI_DONT_SAVE_SEGS) + + /* Initialize TrapFrame segment registers with sane values */ + mov eax, 0x23 + mov ecx, fs + mov [esp - FrameSize + KTRAP_FRAME_DS], eax + mov [esp - FrameSize + KTRAP_FRAME_ES], eax + mov [esp - FrameSize + KTRAP_FRAME_FS], ecx + mov dword ptr [esp - FrameSize + KTRAP_FRAME_GS], 0 + + else /* Check for V86 mode */ test byte ptr [esp + KTRAP_FRAME_EFLAGS + 2], (EFLAGS_V86_MASK / HEX(10000)) From 76ff797dcb3e8c58402d4342235db9a92152b1e0 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Wed, 22 Dec 2010 14:31:39 +0000 Subject: [PATCH 090/181] [HAL] Convert while (TRUE); to ASSERT(FALSE); on unimplemented pathes. svn path=/trunk/; revision=50096 --- reactos/hal/halx86/generic/timer.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/reactos/hal/halx86/generic/timer.c b/reactos/hal/halx86/generic/timer.c index 89d66279574..ec64e59ad2a 100644 --- a/reactos/hal/halx86/generic/timer.c +++ b/reactos/hal/halx86/generic/timer.c @@ -72,7 +72,7 @@ HalpInitializeClock(VOID) /* Disable interrupts */ Flags = __readeflags(); _disable(); - + /* Program the PIT for binary mode */ TimerControl.BcdMode = FALSE; @@ -85,13 +85,13 @@ HalpInitializeClock(VOID) */ TimerControl.OperatingMode = PitOperatingMode2; TimerControl.Channel = PitChannel0; - + /* Set the access mode that we'll use to program the reload value */ TimerControl.AccessMode = PitAccessModeLowHigh; - + /* Now write the programming bits */ __outbyte(TIMER_CONTROL_PORT, TimerControl.Bits); - + /* Next we write the reload value for channel 0 */ __outbyte(TIMER_CHANNEL0_DATA_PORT, RollOver & 0xFF); __outbyte(TIMER_CHANNEL0_DATA_PORT, RollOver >> 8); @@ -110,29 +110,29 @@ FASTCALL HalpClockInterruptHandler(IN PKTRAP_FRAME TrapFrame) { KIRQL Irql; - + /* Enter trap */ KiEnterInterruptTrap(TrapFrame); - + /* Start the interrupt */ if (HalBeginSystemInterrupt(CLOCK2_LEVEL, PRIMARY_VECTOR_BASE, &Irql)) { /* Update the performance counter */ HalpPerfCounter.QuadPart += HalpCurrentRollOver; HalpPerfCounterCutoff = KiEnableTimerWatchdog; - + /* Check if someone changed the time rate */ if (HalpClockSetMSRate) { /* Not yet supported */ UNIMPLEMENTED; - while (TRUE); + ASSERT(FALSE); } - + /* Update the system time -- the kernel will exit this trap */ KeUpdateSystemTime(TrapFrame, HalpCurrentTimeIncrement, Irql); } - + /* Spurious, just end the interrupt */ KiEoiHelper(TrapFrame); } @@ -142,18 +142,18 @@ FASTCALL HalpProfileInterruptHandler(IN PKTRAP_FRAME TrapFrame) { KIRQL Irql; - + /* Enter trap */ KiEnterInterruptTrap(TrapFrame); - + /* Start the interrupt */ if (HalBeginSystemInterrupt(PROFILE_LEVEL, PRIMARY_VECTOR_BASE + 8, &Irql)) { /* Profiling isn't yet enabled */ UNIMPLEMENTED; - while (TRUE); + ASSERT(FALSE); } - + /* Spurious, just end the interrupt */ KiEoiHelper(TrapFrame); } From b1730a09db39bd0302505a68c0b43e982b839129 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Wed, 22 Dec 2010 16:14:58 +0000 Subject: [PATCH 091/181] [NDK] Add IMAGE_FILE_MACHINE_NATIVE [NTOS] Remove IMAGE_FILE_MACHINE_NATIVE and IMAGE_FILE_MACHINE_ARCHITECTURE definitions, use only the former svn path=/trunk/; revision=50098 --- reactos/include/ndk/rtltypes.h | 13 +++ reactos/ntoskrnl/ex/init.c | 4 +- reactos/ntoskrnl/include/internal/amd64/ke.h | 8 +- reactos/ntoskrnl/include/internal/arm/ke.h | 4 +- reactos/ntoskrnl/include/internal/i386/ke.h | 20 ++--- .../ntoskrnl/include/internal/powerpc/ke.h | 2 - reactos/ntoskrnl/kd64/kddata.c | 2 +- reactos/ntoskrnl/mm/ARM3/miarm.h | 84 ++++++++----------- 8 files changed, 66 insertions(+), 71 deletions(-) diff --git a/reactos/include/ndk/rtltypes.h b/reactos/include/ndk/rtltypes.h index 45ccf9af7f0..6d393c2b1e0 100644 --- a/reactos/include/ndk/rtltypes.h +++ b/reactos/include/ndk/rtltypes.h @@ -143,6 +143,19 @@ Author: C_ASSERT(HEAP_CREATE_VALID_MASK == 0x0007F0FF); #endif +// +// Native image architecture +// +#if defined(_M_IX86) +#define IMAGE_FILE_MACHINE_NATIVE IMAGE_FILE_MACHINE_I386 +#elif defined(_M_ARM) +#define IMAGE_FILE_MACHINE_NATIVE IMAGE_FILE_MACHINE_ARM +#elif defined(_M_AMD64) +#define IMAGE_FILE_MACHINE_NATIVE IMAGE_FILE_MACHINE_AMD64 +#else +#error Define these please! +#endif + // // Registry Keys // diff --git a/reactos/ntoskrnl/ex/init.c b/reactos/ntoskrnl/ex/init.c index ee7cc3c2f55..b3039cb2593 100644 --- a/reactos/ntoskrnl/ex/init.c +++ b/reactos/ntoskrnl/ex/init.c @@ -1286,8 +1286,8 @@ ExpInitializeExecutive(IN ULONG Cpu, SharedUserData->NtMinorVersion = NtMinorVersion; /* Set the machine type */ - SharedUserData->ImageNumberLow = IMAGE_FILE_MACHINE_ARCHITECTURE; - SharedUserData->ImageNumberHigh = IMAGE_FILE_MACHINE_ARCHITECTURE; + SharedUserData->ImageNumberLow = IMAGE_FILE_MACHINE_NATIVE; + SharedUserData->ImageNumberHigh = IMAGE_FILE_MACHINE_NATIVE; } VOID diff --git a/reactos/ntoskrnl/include/internal/amd64/ke.h b/reactos/ntoskrnl/include/internal/amd64/ke.h index fc4fe24b494..ffb3f15c4b6 100644 --- a/reactos/ntoskrnl/include/internal/amd64/ke.h +++ b/reactos/ntoskrnl/include/internal/amd64/ke.h @@ -75,8 +75,6 @@ extern ULONG KeI386FxsrPresent; extern ULONG KeI386CpuType; extern ULONG KeI386CpuStep; -#define IMAGE_FILE_MACHINE_ARCHITECTURE IMAGE_FILE_MACHINE_AMD64 - // // INT3 is 1 byte long // @@ -171,7 +169,7 @@ FORCEINLINE VOID KeRegisterInterruptHandler(IN ULONG Vector, IN PVOID Handler) -{ +{ UCHAR Entry; PKIDTENTRY64 Idt; @@ -207,8 +205,8 @@ KeQueryInterruptHandler(IN ULONG Vector) Idt = &KeGetPcr()->IdtBase[Entry]; /* Return the address */ - return (PVOID)((ULONG64)Idt->OffsetHigh << 32 | - (ULONG64)Idt->OffsetMiddle << 16 | + return (PVOID)((ULONG64)Idt->OffsetHigh << 32 | + (ULONG64)Idt->OffsetMiddle << 16 | (ULONG64)Idt->OffsetLow); } diff --git a/reactos/ntoskrnl/include/internal/arm/ke.h b/reactos/ntoskrnl/include/internal/arm/ke.h index b5b8fe7f5d3..3fbe4eb3ad9 100644 --- a/reactos/ntoskrnl/include/internal/arm/ke.h +++ b/reactos/ntoskrnl/include/internal/arm/ke.h @@ -10,8 +10,6 @@ #define PCR_ENTRY 0 #define PDR_ENTRY 2 -#define IMAGE_FILE_MACHINE_ARCHITECTURE IMAGE_FILE_MACHINE_ARM - // // BKPT is 4 bytes long // @@ -104,7 +102,7 @@ KiSystemService(IN PKTHREAD Thread, VOID KiApcInterrupt( - VOID + VOID ); #include "mm.h" diff --git a/reactos/ntoskrnl/include/internal/i386/ke.h b/reactos/ntoskrnl/include/internal/i386/ke.h index bd30dfa8d74..7aa98846ca5 100644 --- a/reactos/ntoskrnl/include/internal/i386/ke.h +++ b/reactos/ntoskrnl/include/internal/i386/ke.h @@ -10,8 +10,6 @@ #define DR_MASK(x) (1 << (x)) #define DR_REG_MASK 0x4F -#define IMAGE_FILE_MACHINE_ARCHITECTURE IMAGE_FILE_MACHINE_I386 - // // INT3 is 1 byte long // @@ -33,7 +31,7 @@ #define KiGetLinkedTrapFrame(x) \ (PKTRAP_FRAME)((x)->Edx) - + #define KeGetContextReturnRegister(Context) \ ((Context)->Eax) @@ -77,7 +75,7 @@ #define KTE_SKIP_PM_BIT (((KTRAP_EXIT_SKIP_BITS) { { .SkipPreviousMode = TRUE } }).Bits) #define KTE_SKIP_SEG_BIT (((KTRAP_EXIT_SKIP_BITS) { { .SkipSegments = TRUE } }).Bits) #define KTE_SKIP_VOL_BIT (((KTRAP_EXIT_SKIP_BITS) { { .SkipVolatiles = TRUE } }).Bits) - + typedef union _KTRAP_EXIT_SKIP_BITS { struct @@ -165,7 +163,7 @@ typedef struct _KV8086_STACK_FRAME FX_SAVE_AREA NpxArea; KV86_FRAME V86Frame; } KV8086_STACK_FRAME, *PKV8086_STACK_FRAME; - + // // Registers an interrupt handler with an IDT vector // @@ -173,7 +171,7 @@ FORCEINLINE VOID KeRegisterInterruptHandler(IN ULONG Vector, IN PVOID Handler) -{ +{ UCHAR Entry; ULONG_PTR Address; PKIPCR Pcr = (PKIPCR)KeGetPcr(); @@ -388,7 +386,7 @@ NTAPI VdmDispatchBop( IN PKTRAP_FRAME TrapFrame ); - + BOOLEAN FASTCALL KiVdmOpcodePrefix( @@ -609,7 +607,7 @@ KiSystemCallTrampoline(IN PVOID Handler, IN ULONG StackBytes) { NTSTATUS Result; - + /* * This sequence does a RtlCopyMemory(Stack - StackBytes, Arguments, StackBytes) * and then calls the function associated with the system call. @@ -705,7 +703,7 @@ NTSTATUS FORCEINLINE KiConvertToGuiThread(VOID) { - NTSTATUS Result; + NTSTATUS Result; PVOID StackFrame; /* @@ -769,7 +767,7 @@ KiSwitchToBootStack(IN ULONG_PTR InitialStack) "subl %1, %%esp\n" "pushl %2\n" "jmp _KiSystemStartupBootStack@0\n" - : + : : "c"(InitialStack), "i"(NPX_FRAME_LENGTH + KTRAP_FRAME_ALIGN + KTRAP_FRAME_LENGTH), "i"(CR0_EM | CR0_TS | CR0_MP) @@ -825,7 +823,7 @@ KiEndInterrupt(IN KIRQL Irql, /* Disable interrupts and end the interrupt */ _disable(); HalEndSystemInterrupt(Irql, TrapFrame); - + /* Exit the interrupt */ KiEoiHelper(TrapFrame); } diff --git a/reactos/ntoskrnl/include/internal/powerpc/ke.h b/reactos/ntoskrnl/include/internal/powerpc/ke.h index ec19a3f1332..4edfbf4ce94 100644 --- a/reactos/ntoskrnl/include/internal/powerpc/ke.h +++ b/reactos/ntoskrnl/include/internal/powerpc/ke.h @@ -35,8 +35,6 @@ typedef struct _KIRQ_TRAPFRAME extern ULONG KePPCCacheAlignment; -#define IMAGE_FILE_MACHINE_ARCHITECTURE IMAGE_FILE_MACHINE_POWERPC - //#define KD_BREAKPOINT_TYPE //#define KD_BREAKPOINT_SIZE //#define KD_BREAKPOINT_VALUE diff --git a/reactos/ntoskrnl/kd64/kddata.c b/reactos/ntoskrnl/kd64/kddata.c index 895753a98d2..3d2be608f59 100644 --- a/reactos/ntoskrnl/kd64/kddata.c +++ b/reactos/ntoskrnl/kd64/kddata.c @@ -378,7 +378,7 @@ DBGKD_GET_VERSION64 KdVersionBlock = #else DBGKD_VERS_FLAG_DATA, #endif - IMAGE_FILE_MACHINE_ARCHITECTURE, + IMAGE_FILE_MACHINE_NATIVE, PACKET_TYPE_MAX, 0, 0, diff --git a/reactos/ntoskrnl/mm/ARM3/miarm.h b/reactos/ntoskrnl/mm/ARM3/miarm.h index cfa99d77330..4c17cd27973 100644 --- a/reactos/ntoskrnl/mm/ARM3/miarm.h +++ b/reactos/ntoskrnl/mm/ARM3/miarm.h @@ -85,31 +85,21 @@ C_ASSERT(SYSTEM_PD_SIZE == PAGE_SIZE); #define PTE_COUNT PTE_PER_PAGE #endif -#ifdef _M_IX86 -#define IMAGE_FILE_MACHINE_NATIVE IMAGE_FILE_MACHINE_I386 -#elif _M_ARM -#define IMAGE_FILE_MACHINE_NATIVE IMAGE_FILE_MACHINE_ARM -#elif _M_AMD64 -#define IMAGE_FILE_MACHINE_NATIVE IMAGE_FILE_MACHINE_AMD64 -#else -#error Define these please! -#endif - // // Protection Bits part of the internal memory manager Protection Mask // Taken from http://www.reactos.org/wiki/Techwiki:Memory_management_in_the_Windows_XP_kernel // and public assertions. // #define MM_ZERO_ACCESS 0 -#define MM_READONLY 1 -#define MM_EXECUTE 2 -#define MM_EXECUTE_READ 3 +#define MM_READONLY 1 +#define MM_EXECUTE 2 +#define MM_EXECUTE_READ 3 #define MM_READWRITE 4 -#define MM_WRITECOPY 5 -#define MM_EXECUTE_READWRITE 6 -#define MM_EXECUTE_WRITECOPY 7 -#define MM_NOCACHE 8 -#define MM_DECOMMIT 0x10 +#define MM_WRITECOPY 5 +#define MM_EXECUTE_READWRITE 6 +#define MM_EXECUTE_WRITECOPY 7 +#define MM_NOCACHE 8 +#define MM_DECOMMIT 0x10 #define MM_NOACCESS (MM_DECOMMIT | MM_NOCACHE) #define MM_INVALID_PROTECTION 0xFFFFFFFF @@ -122,7 +112,7 @@ C_ASSERT(SYSTEM_PD_SIZE == PAGE_SIZE); // // For example, in the logical attributes, we want to express read-only as a flag // but on x86, it is writability that must be set. On the other hand, on x86, just -// like in the kernel, it is disabling the caches that requires a special flag, +// like in the kernel, it is disabling the caches that requires a special flag, // while on certain architectures such as ARM, it is enabling the cache which // requires a flag. // @@ -171,10 +161,10 @@ extern const ULONG MmProtectToValue[32]; // #define MI_IS_SESSION_IMAGE_ADDRESS(Address) \ (((Address) >= MiSessionImageStart) && ((Address) < MiSessionImageEnd)) - + #define MI_IS_SESSION_ADDRESS(Address) \ (((Address) >= MmSessionBase) && ((Address) < MiSessionSpaceEnd)) - + #define MI_IS_SESSION_PTE(Pte) \ ((((PMMPTE)Pte) >= MiSessionBasePte) && (((PMMPTE)Pte) < MiSessionLastPte)) @@ -186,7 +176,7 @@ extern const ULONG MmProtectToValue[32]; #define MI_IS_PAGE_TABLE_OR_HYPER_ADDRESS(Address) \ (((PVOID)(Address) >= (PVOID)PTE_BASE) && ((PVOID)(Address) <= (PVOID)MmHyperSpaceEnd)) - + // // Corresponds to MMPTE_SOFTWARE.Protection // @@ -537,14 +527,14 @@ FORCEINLINE MiDetermineUserGlobalPteMask(IN PVOID PointerPte) { MMPTE TempPte; - + /* Start fresh */ TempPte.u.Long = 0; - + /* Make it valid and accessed */ TempPte.u.Hard.Valid = TRUE; MI_MAKE_ACCESSED_PAGE(&TempPte); - + /* Is this for user-mode? */ if ((PointerPte <= (PVOID)MiHighestUserPte) || ((PointerPte >= (PVOID)MiAddressToPde(NULL)) && @@ -553,9 +543,9 @@ MiDetermineUserGlobalPteMask(IN PVOID PointerPte) /* Set the owner bit */ MI_MAKE_OWNER_PAGE(&TempPte); } - + /* FIXME: We should also set the global bit */ - + /* Return the protection */ return TempPte.u.Long; } @@ -574,10 +564,10 @@ MI_MAKE_HARDWARE_PTE_KERNEL(IN PMMPTE NewPte, ASSERT(MappingPte > MiHighestUserPte); ASSERT(!MI_IS_SESSION_PTE(MappingPte)); ASSERT((MappingPte < (PMMPTE)PDE_BASE) || (MappingPte > (PMMPTE)PDE_TOP)); - + /* Start fresh */ *NewPte = ValidKernelPte; - + /* Set the protection and page */ NewPte->u.Hard.PageFrameNumber = PageFrameNumber; NewPte->u.Long |= MmProtectToPteMask[ProtectionMask]; @@ -611,10 +601,10 @@ MI_MAKE_HARDWARE_PTE_USER(IN PMMPTE NewPte, { /* Only valid for kernel, non-session PTEs */ ASSERT(MappingPte <= MiHighestUserPte); - + /* Start fresh */ *NewPte = ValidKernelPte; - + /* Set the protection and page */ NewPte->u.Hard.Owner = TRUE; NewPte->u.Hard.PageFrameNumber = PageFrameNumber; @@ -635,7 +625,7 @@ MI_MAKE_PROTOTYPE_PTE(IN PMMPTE NewPte, /* Mark this as a prototype */ NewPte->u.Long = 0; NewPte->u.Proto.Prototype = 1; - + /* * Prototype PTEs are only valid in paged pool by design, this little trick * lets us only use 28 bits for the adress of the PTE @@ -658,7 +648,7 @@ BOOLEAN MI_IS_PHYSICAL_ADDRESS(IN PVOID Address) { PMMPDE PointerPde; - + /* Large pages are never paged out, always physically resident */ PointerPde = MiAddressToPde(Address); return ((PointerPde->u.Hard.LargePage) && (PointerPde->u.Hard.Valid)); @@ -785,11 +775,11 @@ MiUnlockProcessWorkingSet(IN PEPROCESS Process, ASSERT(MI_WS_OWNER(Process)); /* This can't be checked because Vm is used by MAREAs) */ //ASSERT(Process->Vm.Flags.AcquiredUnsafe == 0); - + /* The thread doesn't own it anymore */ ASSERT(Thread->OwnsProcessWorkingSetExclusive == TRUE); Thread->OwnsProcessWorkingSetExclusive = FALSE; - + /* FIXME: Actually release it (we can't because Vm is used by MAREAs) */ /* Unblock APCs */ @@ -806,15 +796,15 @@ MiLockWorkingSet(IN PETHREAD Thread, { /* Block APCs */ KeEnterGuardedRegion(); - + /* Working set should be in global memory */ ASSERT(MI_IS_SESSION_ADDRESS((PVOID)WorkingSet) == FALSE); - + /* Thread shouldn't already be owning something */ ASSERT(!MM_ANY_WS_LOCK_HELD(Thread)); - + /* FIXME: Actually lock it (we can't because Vm is used by MAREAs) */ - + /* Which working set is this? */ if (WorkingSet == &MmSystemCacheWs) { @@ -848,7 +838,7 @@ MiUnlockWorkingSet(IN PETHREAD Thread, { /* Working set should be in global memory */ ASSERT(MI_IS_SESSION_ADDRESS((PVOID)WorkingSet) == FALSE); - + /* Which working set is this? */ if (WorkingSet == &MmSystemCacheWs) { @@ -870,7 +860,7 @@ MiUnlockWorkingSet(IN PETHREAD Thread, (Thread->OwnsProcessWorkingSetShared)); Thread->OwnsProcessWorkingSetExclusive = FALSE; } - + /* FIXME: Actually release it (we can't because Vm is used by MAREAs) */ /* Unblock APCs */ @@ -947,7 +937,7 @@ NTAPI MiInitializeMemoryEvents( VOID ); - + PFN_NUMBER NTAPI MxGetNextPage( @@ -960,21 +950,21 @@ MmInitializeMemoryLimits( IN PLOADER_PARAMETER_BLOCK LoaderBlock, IN PBOOLEAN IncludeType ); - + PFN_NUMBER NTAPI MiPagesInLoaderBlock( IN PLOADER_PARAMETER_BLOCK LoaderBlock, IN PBOOLEAN IncludeType ); - + VOID FASTCALL MiSyncARM3WithROS( IN PVOID AddressStart, IN PVOID AddressEnd ); - + NTSTATUS NTAPI MmArmAccessFault( @@ -1170,7 +1160,7 @@ MiDeleteSystemPageableVm( IN ULONG Flags, OUT PPFN_NUMBER ValidPages ); - + PLDR_DATA_TABLE_ENTRY NTAPI MiLookupDataTableEntry( @@ -1318,7 +1308,7 @@ MiLocateSubsection( IN PMMVAD Vad, IN ULONG_PTR Vpn ); - + // // MiRemoveZeroPage will use inline code to zero out the page manually if only // free pages are available. In some scenarios, we don't/can't run that piece of From 7f1fb180318cea4c19892ad380badd161442f6b5 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Wed, 22 Dec 2010 16:19:40 +0000 Subject: [PATCH 092/181] [NTDLL] Raise harderror and terminate process when the image is of a foreign architecture. svn path=/trunk/; revision=50099 --- reactos/dll/ntdll/ldr/startup.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/reactos/dll/ntdll/ldr/startup.c b/reactos/dll/ntdll/ldr/startup.c index 83cea3032f8..49f132ef914 100644 --- a/reactos/dll/ntdll/ldr/startup.c +++ b/reactos/dll/ntdll/ldr/startup.c @@ -330,6 +330,7 @@ LdrpInit2(PCONTEXT Context, SYSTEM_BASIC_INFORMATION SystemInformation; NTSTATUS Status; PVOID BaseAddress = SystemArgument1; + ULONG ErrorResponse; DPRINT("LdrpInit()\n"); DPRINT("Peb %p\n", Peb); @@ -344,16 +345,25 @@ LdrpInit2(PCONTEXT Context, /* If MZ header exists */ PEDosHeader = (PIMAGE_DOS_HEADER) ImageBase; + NTHeaders = (PIMAGE_NT_HEADERS)((ULONG_PTR)ImageBase + PEDosHeader->e_lfanew); DPRINT("PEDosHeader %p\n", PEDosHeader); if (PEDosHeader->e_magic != IMAGE_DOS_SIGNATURE || PEDosHeader->e_lfanew == 0L || - *(PULONG)((PUCHAR)ImageBase + PEDosHeader->e_lfanew) != IMAGE_NT_SIGNATURE) + NTHeaders->Signature != IMAGE_NT_SIGNATURE) { DPRINT1("Image has bad header\n"); ZwTerminateProcess(NtCurrentProcess(), STATUS_INVALID_IMAGE_FORMAT); } + if (NTHeaders->FileHeader.Machine != IMAGE_FILE_MACHINE_NATIVE) + { + DPRINT1("Image is for a foreign architecture (0x%x).\n", + NTHeaders->FileHeader.Machine); + NtRaiseHardError(STATUS_IMAGE_MACHINE_TYPE_MISMATCH, 0, 0, NULL, OptionOk, &ErrorResponse); + ZwTerminateProcess(NtCurrentProcess(), STATUS_IMAGE_MACHINE_TYPE_MISMATCH); + } + /* normalize process parameters */ RtlNormalizeProcessParams(Peb->ProcessParameters); @@ -364,8 +374,6 @@ LdrpInit2(PCONTEXT Context, &NlsTable); RtlResetRtlTranslations(&NlsTable); - NTHeaders = (PIMAGE_NT_HEADERS)((ULONG_PTR)ImageBase + PEDosHeader->e_lfanew); - /* Get number of processors */ DPRINT("Here\n"); Status = ZwQuerySystemInformation(SystemBasicInformation, From f5ce6995175d3a3303270202a0c1f7b6f73466ef Mon Sep 17 00:00:00 2001 From: Amine Khaldi Date: Wed, 22 Dec 2010 16:33:37 +0000 Subject: [PATCH 093/181] [CMAKE] - Add the apitests to build. - Improve some winetests. svn path=/trunk/; revision=50100 --- rostests/CMakeLists.txt | 2 +- rostests/apitests/CMakeLists.txt | 14 ++++++ rostests/apitests/dciman32/CMakeLists.txt | 7 +++ rostests/apitests/gdi32/CMakeLists.txt | 49 +++++++++++++++++++ rostests/apitests/ntdll/CMakeLists.txt | 18 +++++++ rostests/apitests/user32/CMakeLists.txt | 15 ++++++ rostests/apitests/w32kdll/CMakeLists.txt | 6 +++ .../w32kdll/w32kdll_2k3sp2/CMakeLists.txt | 6 +++ .../w32kdll/w32kdll_2ksp4/CMakeLists.txt | 6 +++ .../w32kdll/w32kdll_ros/CMakeLists.txt | 11 +++++ .../w32kdll/w32kdll_vista/CMakeLists.txt | 6 +++ .../w32kdll/w32kdll_xpsp2/CMakeLists.txt | 6 +++ rostests/apitests/w32knapi/CMakeLists.txt | 13 +++++ rostests/apitests/ws2_32/CMakeLists.txt | 13 +++++ rostests/winetests/amstream/CMakeLists.txt | 1 + rostests/winetests/powrprof/CMakeLists.txt | 2 +- 16 files changed, 173 insertions(+), 2 deletions(-) create mode 100644 rostests/apitests/CMakeLists.txt create mode 100644 rostests/apitests/dciman32/CMakeLists.txt create mode 100644 rostests/apitests/gdi32/CMakeLists.txt create mode 100644 rostests/apitests/ntdll/CMakeLists.txt create mode 100644 rostests/apitests/user32/CMakeLists.txt create mode 100644 rostests/apitests/w32kdll/CMakeLists.txt create mode 100644 rostests/apitests/w32kdll/w32kdll_2k3sp2/CMakeLists.txt create mode 100644 rostests/apitests/w32kdll/w32kdll_2ksp4/CMakeLists.txt create mode 100644 rostests/apitests/w32kdll/w32kdll_ros/CMakeLists.txt create mode 100644 rostests/apitests/w32kdll/w32kdll_vista/CMakeLists.txt create mode 100644 rostests/apitests/w32kdll/w32kdll_xpsp2/CMakeLists.txt create mode 100644 rostests/apitests/w32knapi/CMakeLists.txt create mode 100644 rostests/apitests/ws2_32/CMakeLists.txt diff --git a/rostests/CMakeLists.txt b/rostests/CMakeLists.txt index b926010d908..8ce0db3ba37 100644 --- a/rostests/CMakeLists.txt +++ b/rostests/CMakeLists.txt @@ -1,5 +1,5 @@ -#add_subdirectory(apitests) +add_subdirectory(apitests) #add_subdirectory(dibtests) #add_subdirectory(dxtest) #add_subdirectory(regtests) diff --git a/rostests/apitests/CMakeLists.txt b/rostests/apitests/CMakeLists.txt new file mode 100644 index 00000000000..6b0ac2d0bc2 --- /dev/null +++ b/rostests/apitests/CMakeLists.txt @@ -0,0 +1,14 @@ + +add_library(apitest apitest.c) + +add_subdirectory(dciman32) +add_subdirectory(gdi32) +#add_subdirectory(ntdll) The asm file needs to be fixed. +add_subdirectory(user32) + +if(ARCH MATCHES i386) +add_subdirectory(w32kdll) +add_subdirectory(w32knapi) +endif() + +add_subdirectory(ws2_32) diff --git a/rostests/apitests/dciman32/CMakeLists.txt b/rostests/apitests/dciman32/CMakeLists.txt new file mode 100644 index 00000000000..552e51d5e8b --- /dev/null +++ b/rostests/apitests/dciman32/CMakeLists.txt @@ -0,0 +1,7 @@ + +add_definitions(-D_DLL -D__USE_CRTIMP) + +add_executable(dciman32_apitest DCICreatePrimary.c testlist.c) +target_link_libraries(dciman32_apitest wine) +set_module_type(dciman32_apitest win32cui) +add_importlibs(dciman32_apitest msvcrt kernel32 ntdll) diff --git a/rostests/apitests/gdi32/CMakeLists.txt b/rostests/apitests/gdi32/CMakeLists.txt new file mode 100644 index 00000000000..969eba3cd39 --- /dev/null +++ b/rostests/apitests/gdi32/CMakeLists.txt @@ -0,0 +1,49 @@ + +add_definitions(-D_DLL -D__USE_CRTIMP) + +list(APPEND SOURCE + AddFontResource.c + AddFontResourceEx.c + BeginPath.c + CreateBitmapIndirect.c + CreateCompatibleDC.c + CreateFont.c + CreateFontIndirect.c + CreatePen.c + CreateRectRgn.c + EngAcquireSemaphore.c + EngCreateSemaphore.c + EngDeleteSemaphore.c + EngReleaseSemaphore.c + ExtCreatePen.c + GdiConvertBitmap.c + GdiConvertBrush.c + GdiConvertDC.c + GdiConvertFont.c + GdiConvertPalette.c + GdiConvertRegion.c + GdiDeleteLocalDC.c + GdiGetCharDimensions.c + GdiGetLocalBrush.c + GdiGetLocalDC.c + GdiReleaseLocalDC.c + GdiSetAttrs.c + GetClipRgn.c + GetCurrentObject.c + GetDIBits.c + GetObject.c + GetStockObject.c + GetTextExtentExPoint.c + GetTextFace.c + SelectObject.c + SetDCPenColor.c + SetMapMode.c + SetSysColors.c + SetWindowExtEx.c + SetWorldTransform.c + testlist.c) + +add_executable(gdi32_apitest ${SOURCE}) +target_link_libraries(gdi32_apitest wine ${PSEH_LIB}) +set_module_type(gdi32_apitest win32cui) +add_importlibs(gdi32_apitest gdi32 user32 msvcrt kernel32 ntdll) diff --git a/rostests/apitests/ntdll/CMakeLists.txt b/rostests/apitests/ntdll/CMakeLists.txt new file mode 100644 index 00000000000..2b6d4934e48 --- /dev/null +++ b/rostests/apitests/ntdll/CMakeLists.txt @@ -0,0 +1,18 @@ + +#add_definitions(-D_DLL -D__USE_CRTIMP) + +list(APPEND SOURCE + RtlInitializeBitMap.c + ZwContinue.c + testlist.c) + +if(ARCH MATCHES i386) +list(APPEND SOURCE i386/ZwContinue.asm) +endif() + +add_executable(ntdll_apitest ${SOURCE}) +target_link_libraries(ntdll_apitest wine + #${PSEH_LIB} + ) +set_module_type(ntdll_apitest win32cui) +add_importlibs(ntdll_apitest ntdll) diff --git a/rostests/apitests/user32/CMakeLists.txt b/rostests/apitests/user32/CMakeLists.txt new file mode 100644 index 00000000000..2ae9ea1c144 --- /dev/null +++ b/rostests/apitests/user32/CMakeLists.txt @@ -0,0 +1,15 @@ + +add_definitions(-D_DLL -D__USE_CRTIMP) + +list(APPEND SOURCE + InitializeLpkHooks.c + RealGetWindowClass.c + ScrollDC.c + ScrollWindowEx.c + GetSystemMetrics.c + testlist.c) + +add_executable(user32_apitest ${SOURCE}) +target_link_libraries(user32_apitest wine) +set_module_type(user32_apitest win32cui) +add_importlibs(user32_apitest gdi32 user32 msvcrt kernel32 ntdll) diff --git a/rostests/apitests/w32kdll/CMakeLists.txt b/rostests/apitests/w32kdll/CMakeLists.txt new file mode 100644 index 00000000000..a2c1b14f249 --- /dev/null +++ b/rostests/apitests/w32kdll/CMakeLists.txt @@ -0,0 +1,6 @@ + +add_subdirectory(w32kdll_ros) +add_subdirectory(w32kdll_xpsp2) +add_subdirectory(w32kdll_2ksp4) +add_subdirectory(w32kdll_2k3sp2) +add_subdirectory(w32kdll_vista) diff --git a/rostests/apitests/w32kdll/w32kdll_2k3sp2/CMakeLists.txt b/rostests/apitests/w32kdll/w32kdll_2k3sp2/CMakeLists.txt new file mode 100644 index 00000000000..ead3b82f1bf --- /dev/null +++ b/rostests/apitests/w32kdll/w32kdll_2k3sp2/CMakeLists.txt @@ -0,0 +1,6 @@ + +add_library(w32kdll_2k3sp2 SHARED main.c w32kdll_2k3sp2.S) +set_entrypoint(w32kdll_2k3sp2 0) +target_link_libraries(w32kdll_2k3sp2 ${CMAKE_CURRENT_SOURCE_DIR}/w32kdll_2k3sp2.def) +add_dependencies(w32kdll_2k3sp2 psdk buildno_header) +add_importlib_target(w32kdll_2k3sp2.def) diff --git a/rostests/apitests/w32kdll/w32kdll_2ksp4/CMakeLists.txt b/rostests/apitests/w32kdll/w32kdll_2ksp4/CMakeLists.txt new file mode 100644 index 00000000000..efc4ec0ad68 --- /dev/null +++ b/rostests/apitests/w32kdll/w32kdll_2ksp4/CMakeLists.txt @@ -0,0 +1,6 @@ + +add_library(w32kdll_2ksp4 SHARED main.c w32kdll_2ksp4.S) +set_entrypoint(w32kdll_2ksp4 0) +target_link_libraries(w32kdll_2ksp4 ${CMAKE_CURRENT_SOURCE_DIR}/w32kdll_2ksp4.def) +add_dependencies(w32kdll_2ksp4 psdk buildno_header) +add_importlib_target(w32kdll_2ksp4.def) diff --git a/rostests/apitests/w32kdll/w32kdll_ros/CMakeLists.txt b/rostests/apitests/w32kdll/w32kdll_ros/CMakeLists.txt new file mode 100644 index 00000000000..ad143fee275 --- /dev/null +++ b/rostests/apitests/w32kdll/w32kdll_ros/CMakeLists.txt @@ -0,0 +1,11 @@ + +add_library(w32kdll SHARED main.c) + +set_entrypoint(w32kdll 0) + +target_link_libraries(w32kdll + ${CMAKE_CURRENT_SOURCE_DIR}/w32kdll_ros.def + win32ksys) + +add_dependencies(w32kdll psdk buildno_header) +add_importlib_target(w32kdll_ros.def) diff --git a/rostests/apitests/w32kdll/w32kdll_vista/CMakeLists.txt b/rostests/apitests/w32kdll/w32kdll_vista/CMakeLists.txt new file mode 100644 index 00000000000..5c387435e80 --- /dev/null +++ b/rostests/apitests/w32kdll/w32kdll_vista/CMakeLists.txt @@ -0,0 +1,6 @@ + +add_library(w32kdll_vista SHARED main.c w32kdll_vista.S) +set_entrypoint(w32kdll_vista 0) +target_link_libraries(w32kdll_vista ${CMAKE_CURRENT_SOURCE_DIR}/w32kdll_vista.def) +add_dependencies(w32kdll_vista psdk buildno_header) +add_importlib_target(w32kdll_vista.def) diff --git a/rostests/apitests/w32kdll/w32kdll_xpsp2/CMakeLists.txt b/rostests/apitests/w32kdll/w32kdll_xpsp2/CMakeLists.txt new file mode 100644 index 00000000000..3f86810f2c6 --- /dev/null +++ b/rostests/apitests/w32kdll/w32kdll_xpsp2/CMakeLists.txt @@ -0,0 +1,6 @@ + +add_library(w32kdll_xpsp2 SHARED main.c w32kdll_xpsp2.S) +set_entrypoint(w32kdll_xpsp2 0) +target_link_libraries(w32kdll_xpsp2 ${CMAKE_CURRENT_SOURCE_DIR}/w32kdll_xpsp2.def) +add_dependencies(w32kdll_xpsp2 psdk buildno_header) +add_importlib_target(w32kdll_xpsp2.def) diff --git a/rostests/apitests/w32knapi/CMakeLists.txt b/rostests/apitests/w32knapi/CMakeLists.txt new file mode 100644 index 00000000000..21e1e5fd0c1 --- /dev/null +++ b/rostests/apitests/w32knapi/CMakeLists.txt @@ -0,0 +1,13 @@ + +add_definitions(-D_DLL -D__USE_CRTIMP) + +list(APPEND SOURCE + osver.c + testlist.c + w32knapi.c + w32knapi.rc) + +add_executable(w32knapi ${SOURCE}) +target_link_libraries(w32knapi apitest) +set_module_type(w32knapi win32cui) +add_importlibs(w32knapi w32kdll_ros gdi32 user32 shell32 advapi32 msvcrt kernel32 ntdll) diff --git a/rostests/apitests/ws2_32/CMakeLists.txt b/rostests/apitests/ws2_32/CMakeLists.txt new file mode 100644 index 00000000000..ba9da9c84c0 --- /dev/null +++ b/rostests/apitests/ws2_32/CMakeLists.txt @@ -0,0 +1,13 @@ + +add_definitions(-D_DLL -D__USE_CRTIMP) + +list(APPEND SOURCE + helpers.c + ioctlsocket.c + recv.c + testlist.c) + +add_executable(ws2_32_apitest ${SOURCE}) +target_link_libraries(ws2_32_apitest wine) +set_module_type(ws2_32_apitest win32cui) +add_importlibs(ws2_32_apitest ws2_32 msvcrt kernel32 ntdll) diff --git a/rostests/winetests/amstream/CMakeLists.txt b/rostests/winetests/amstream/CMakeLists.txt index e861c17aa1b..a23adfa6c8f 100644 --- a/rostests/winetests/amstream/CMakeLists.txt +++ b/rostests/winetests/amstream/CMakeLists.txt @@ -4,3 +4,4 @@ add_executable(amstream_winetest amstream.c testlist.c) target_link_libraries(amstream_winetest wine uuid) set_module_type(amstream_winetest win32cui) add_importlibs(amstream_winetest ole32 user32 ddraw msvcrt kernel32 ntdll) +add_dependencies(amstream_winetest dxsdk) \ No newline at end of file diff --git a/rostests/winetests/powrprof/CMakeLists.txt b/rostests/winetests/powrprof/CMakeLists.txt index fec0f4ac793..462da098510 100644 --- a/rostests/winetests/powrprof/CMakeLists.txt +++ b/rostests/winetests/powrprof/CMakeLists.txt @@ -6,4 +6,4 @@ add_definitions( add_executable(powrprof_winetest pwrprof.c testlist.c) set_module_type(powrprof_winetest win32cui) -add_importlibs(powrprof_winetest advapi32 pwrprof msvcrt kernel32 ntdll) +add_importlibs(powrprof_winetest advapi32 powrprof msvcrt kernel32 ntdll) From ccc082914c34866d9e3a3bf093e6859d8f965c79 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Wed, 22 Dec 2010 18:30:59 +0000 Subject: [PATCH 094/181] [WIN32K] Silence 3 DPRINTs svn path=/trunk/; revision=50103 --- reactos/subsystems/win32/win32k/ntuser/input.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/reactos/subsystems/win32/win32k/ntuser/input.c b/reactos/subsystems/win32/win32k/ntuser/input.c index a8d6d83bb76..13d9fc02e02 100644 --- a/reactos/subsystems/win32/win32k/ntuser/input.c +++ b/reactos/subsystems/win32/win32k/ntuser/input.c @@ -239,7 +239,7 @@ MouseThreadMain(PVOID StartContext) ptiMouse = PsGetCurrentThreadWin32Thread(); ptiMouse->TIF_flags |= TIF_SYSTEMTHREAD; - DPRINT1("\nMouse Thread 0x%x \n", ptiMouse); + DPRINT("Mouse Thread 0x%x \n", ptiMouse); KeSetPriorityThread(&PsGetCurrentThread()->Tcb, LOW_REALTIME_PRIORITY + 3); @@ -539,7 +539,7 @@ KeyboardThreadMain(PVOID StartContext) ptiKeyboard = PsGetCurrentThreadWin32Thread(); ptiKeyboard->TIF_flags |= TIF_SYSTEMTHREAD; - DPRINT1("\nKeyboard Thread 0x%x \n", ptiKeyboard); + DPRINT("Keyboard Thread 0x%x \n", ptiKeyboard); KeSetPriorityThread(&PsGetCurrentThread()->Tcb, LOW_REALTIME_PRIORITY + 3); @@ -902,7 +902,7 @@ RawInputThreadMain(PVOID StartContext) ptiRawInput = PsGetCurrentThreadWin32Thread(); ptiRawInput->TIF_flags |= TIF_SYSTEMTHREAD; - DPRINT1("\nRaw Input Thread 0x%x \n", ptiRawInput); + DPRINT("Raw Input Thread 0x%x \n", ptiRawInput); KeSetPriorityThread(&PsGetCurrentThread()->Tcb, LOW_REALTIME_PRIORITY + 3); @@ -1342,7 +1342,7 @@ IntKeyboardInput(KEYBDINPUT *ki) /* All messages have to contain the cursor point. */ Msg.pt = gpsi->ptCursor; - + KbdHookData.vkCode = vk_hook; KbdHookData.scanCode = ki->wScan; KbdHookData.flags = flags >> 8; From 96d2fe3970e1c9a80285de5670ebf8c9b2825459 Mon Sep 17 00:00:00 2001 From: Roel Messiant Date: Wed, 22 Dec 2010 19:09:25 +0000 Subject: [PATCH 095/181] [I8042PRT] - Calculate packet type according to PS/2++ spec (CID 1810). - Fix technical detail in comment to match spec. svn path=/trunk/; revision=50105 --- reactos/drivers/input/i8042prt/ps2pp.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/reactos/drivers/input/i8042prt/ps2pp.c b/reactos/drivers/input/i8042prt/ps2pp.c index 3b3ffc679c1..bab65b315ed 100644 --- a/reactos/drivers/input/i8042prt/ps2pp.c +++ b/reactos/drivers/input/i8042prt/ps2pp.c @@ -31,7 +31,7 @@ i8042MouHandlePs2pp( * a normal packet. * * Otherwise, the packet is different, like this: - * 1: E 1 b3 b2 x x x x + * 1: E 1 b3 b2 1 x x x * 2: x x b1 b0 x1 x0 1 0 * 3: x x x x x x x1 x0 * @@ -93,8 +93,8 @@ i8042MouHandlePs2pp( } /* Now get the packet type */ - PktType = ((DeviceExtension->MouseLogiBuffer[0] & 0x30) >> 4) & - ((DeviceExtension->MouseLogiBuffer[1] & 0x30) >> 6); + PktType = ((DeviceExtension->MouseLogiBuffer[0] & 0x30) >> 2) | + ((DeviceExtension->MouseLogiBuffer[1] & 0x30) >> 4); switch (PktType) { From 27a2217c5ba5f5e8e0e293c2bbeb9e5061722f72 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Wed, 22 Dec 2010 20:20:52 +0000 Subject: [PATCH 096/181] [NTDLL] Fix harderror status on machine type mismatch and pass file name. svn path=/trunk/; revision=50106 --- reactos/dll/ntdll/ldr/startup.c | 50 +++++++++++++++++++++++++++------ 1 file changed, 41 insertions(+), 9 deletions(-) diff --git a/reactos/dll/ntdll/ldr/startup.c b/reactos/dll/ntdll/ldr/startup.c index 49f132ef914..2b5ae0140a9 100644 --- a/reactos/dll/ntdll/ldr/startup.c +++ b/reactos/dll/ntdll/ldr/startup.c @@ -330,7 +330,6 @@ LdrpInit2(PCONTEXT Context, SYSTEM_BASIC_INFORMATION SystemInformation; NTSTATUS Status; PVOID BaseAddress = SystemArgument1; - ULONG ErrorResponse; DPRINT("LdrpInit()\n"); DPRINT("Peb %p\n", Peb); @@ -356,14 +355,6 @@ LdrpInit2(PCONTEXT Context, ZwTerminateProcess(NtCurrentProcess(), STATUS_INVALID_IMAGE_FORMAT); } - if (NTHeaders->FileHeader.Machine != IMAGE_FILE_MACHINE_NATIVE) - { - DPRINT1("Image is for a foreign architecture (0x%x).\n", - NTHeaders->FileHeader.Machine); - NtRaiseHardError(STATUS_IMAGE_MACHINE_TYPE_MISMATCH, 0, 0, NULL, OptionOk, &ErrorResponse); - ZwTerminateProcess(NtCurrentProcess(), STATUS_IMAGE_MACHINE_TYPE_MISMATCH); - } - /* normalize process parameters */ RtlNormalizeProcessParams(Peb->ProcessParameters); @@ -408,6 +399,47 @@ LdrpInit2(PCONTEXT Context, ZwTerminateProcess(NtCurrentProcess(), STATUS_INSUFFICIENT_RESOURCES); } + /* Check for correct machine type */ + if (NTHeaders->FileHeader.Machine != IMAGE_FILE_MACHINE_NATIVE) + { + ULONG_PTR HardErrorParameters[1]; + UNICODE_STRING ImageNameU; + ANSI_STRING ImageNameA; + WCHAR *Ptr; + ULONG ErrorResponse; + + DPRINT1("Image %wZ is for a foreign architecture (0x%x).\n", + &Peb->ProcessParameters->ImagePathName, NTHeaders->FileHeader.Machine); + + /* Get the full image path name */ + ImageNameU = Peb->ProcessParameters->ImagePathName; + + /* Get the file name */ + Ptr = Peb->ProcessParameters->ImagePathName.Buffer + + (Peb->ProcessParameters->ImagePathName.Length / sizeof(WCHAR)) -1; + while ((Ptr >= Peb->ProcessParameters->ImagePathName.Buffer) && + (*Ptr != L'\\')) Ptr--; + ImageNameU.Buffer = Ptr + 1; + ImageNameU.Length = Peb->ProcessParameters->ImagePathName.Length - + (ImageNameU.Buffer - Peb->ProcessParameters->ImagePathName.Buffer) * sizeof(WCHAR); + ImageNameU.MaximumLength = ImageNameU.Length; + + /*`Convert to ANSI, harderror message needs that */ + RtlUnicodeStringToAnsiString(&ImageNameA, &ImageNameU, TRUE); + + /* Raise harderror */ + HardErrorParameters[0] = (ULONG_PTR)&ImageNameA; + NtRaiseHardError(STATUS_IMAGE_MACHINE_TYPE_MISMATCH_EXE, + 1, + 1, + HardErrorParameters, + OptionOk, + &ErrorResponse); + + RtlFreeAnsiString(&ImageNameA); + ZwTerminateProcess(NtCurrentProcess(), STATUS_IMAGE_MACHINE_TYPE_MISMATCH_EXE); + } + /* initialized vectored exception handling */ RtlpInitializeVectoredExceptionHandling(); From 70f0698953c4af118ad01a7e4df32b2ade3a1155 Mon Sep 17 00:00:00 2001 From: Aleksey Bragin Date: Wed, 22 Dec 2010 21:27:31 +0000 Subject: [PATCH 097/181] [NTOS] - Fix incompatibility with newer KiEnterTrap implementation. Should fix spontaneous issues I possibly introduced with my previous commit, and finally fixes that VirtualBox issue. svn path=/trunk/; revision=50107 --- reactos/ntoskrnl/include/internal/i386/asmmacro.S | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/reactos/ntoskrnl/include/internal/i386/asmmacro.S b/reactos/ntoskrnl/include/internal/i386/asmmacro.S index d84872a7b7a..f5cfe2ee3b5 100644 --- a/reactos/ntoskrnl/include/internal/i386/asmmacro.S +++ b/reactos/ntoskrnl/include/internal/i386/asmmacro.S @@ -140,10 +140,10 @@ MACRO(KiEnterTrap, Flags) /* Initialize TrapFrame segment registers with sane values */ mov eax, 0x23 mov ecx, fs - mov [esp - FrameSize + KTRAP_FRAME_DS], eax - mov [esp - FrameSize + KTRAP_FRAME_ES], eax - mov [esp - FrameSize + KTRAP_FRAME_FS], ecx - mov dword ptr [esp - FrameSize + KTRAP_FRAME_GS], 0 + mov [esp + KTRAP_FRAME_DS], eax + mov [esp + KTRAP_FRAME_ES], eax + mov [esp + KTRAP_FRAME_FS], ecx + mov dword ptr [esp + KTRAP_FRAME_GS], 0 else From d1d18942316895d74f312b1889ead8a92e7b01f2 Mon Sep 17 00:00:00 2001 From: Aleksey Bragin Date: Wed, 22 Dec 2010 21:59:27 +0000 Subject: [PATCH 098/181] [NTOS] - Fix memory region size calculation in MemoryBasicInformation in certain cases. Spotted by Michael Martin. svn path=/trunk/; revision=50108 --- reactos/ntoskrnl/mm/ARM3/virtual.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/reactos/ntoskrnl/mm/ARM3/virtual.c b/reactos/ntoskrnl/mm/ARM3/virtual.c index 508db86b1e2..b576119264f 100644 --- a/reactos/ntoskrnl/mm/ARM3/virtual.c +++ b/reactos/ntoskrnl/mm/ARM3/virtual.c @@ -2446,6 +2446,9 @@ MiQueryMemoryBasicInformation(IN HANDLE ProcessHandle, /* Check if this VAD is too high */ if (BaseVpn < Vad->StartingVpn) { + /* Stop if there is no left child */ + if (!Vad->LeftChild) break; + /* Search on the left next */ Vad = Vad->LeftChild; } @@ -2453,6 +2456,11 @@ MiQueryMemoryBasicInformation(IN HANDLE ProcessHandle, { /* Then this VAD is too low, keep searching on the right */ ASSERT(BaseVpn > Vad->EndingVpn); + + /* Stop if there is no right child */ + if (!Vad->LeftChild) break; + + /* Search on the right next */ Vad = Vad->RightChild; } } From ad1b414a31641bdc1264bc18508af93c86602b2a Mon Sep 17 00:00:00 2001 From: Aleksey Bragin Date: Wed, 22 Dec 2010 22:18:32 +0000 Subject: [PATCH 099/181] [NTOS] - Fix a typo in region size calculation of special memory areas, which unbreaks OllyDbg & co. Thanks Michael Martin for the hint. See issue #5692 for more details. svn path=/trunk/; revision=50109 --- reactos/ntoskrnl/mm/ARM3/virtual.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reactos/ntoskrnl/mm/ARM3/virtual.c b/reactos/ntoskrnl/mm/ARM3/virtual.c index b576119264f..2feff792feb 100644 --- a/reactos/ntoskrnl/mm/ARM3/virtual.c +++ b/reactos/ntoskrnl/mm/ARM3/virtual.c @@ -2379,7 +2379,7 @@ MiQueryMemoryBasicInformation(IN HANDLE ProcessHandle, MemoryInfo.AllocationBase = (PCHAR)MM_HIGHEST_VAD_ADDRESS + 1; MemoryInfo.State = MEM_RESERVE; MemoryInfo.Protect = PAGE_NOACCESS; - MemoryInfo.RegionSize = (ULONG_PTR)MemoryInfo.AllocationBase - (ULONG_PTR)Address; + MemoryInfo.RegionSize = (ULONG_PTR)MM_HIGHEST_USER_ADDRESS + 1 - (ULONG_PTR)Address; } /* Return the data, NtQueryInformation already probed it*/ From d758597cd4f5c758d8ba418e5ea7453d93e8d7a2 Mon Sep 17 00:00:00 2001 From: Art Yerkes Date: Thu, 23 Dec 2010 08:42:51 +0000 Subject: [PATCH 100/181] Do the required flush when the last reference to a cache stripe is released. The installer now completes given enough ram in NEWCC=1, and writes an understandable FS. There's at least one more problem preventing the resulting installation from booting however. Fix a bug in rmap where we were checking the next (unfortunately named current) rmap for a segment membership. Fix a mistake in cache trim. #ifdef detection of DirectMapping in section in NEWCC mode in page out. svn path=/trunk/; revision=50110 --- reactos/ntoskrnl/cache/cachesub.c | 4 ++-- reactos/ntoskrnl/cache/fssup.c | 8 ++++---- reactos/ntoskrnl/cache/newcc.h | 4 ++-- reactos/ntoskrnl/cache/pinsup.c | 21 +++++++++++++++++---- reactos/ntoskrnl/mm/rmap.c | 2 +- reactos/ntoskrnl/mm/section.c | 4 ++++ 6 files changed, 30 insertions(+), 13 deletions(-) diff --git a/reactos/ntoskrnl/cache/cachesub.c b/reactos/ntoskrnl/cache/cachesub.c index fb9d9e31eb9..6f816cba0dd 100644 --- a/reactos/ntoskrnl/cache/cachesub.c +++ b/reactos/ntoskrnl/cache/cachesub.c @@ -189,12 +189,12 @@ _CcpFlushCache(IN PNOCC_CACHE_MAP Map, CcpDereferenceCache(Bcb - CcCacheSections, FALSE); } else - CcpUnpinData(Bcb); + CcpUnpinData(Bcb, TRUE); } else { ListEntry = ListEntry->Flink; - CcpUnpinData(Bcb); + CcpUnpinData(Bcb, TRUE); } DPRINT("End loop\n"); diff --git a/reactos/ntoskrnl/cache/fssup.c b/reactos/ntoskrnl/cache/fssup.c index 8646513e3b0..f436e744b1e 100644 --- a/reactos/ntoskrnl/cache/fssup.c +++ b/reactos/ntoskrnl/cache/fssup.c @@ -53,7 +53,7 @@ CcRosTrimCache(ULONG Target, ULONG Priority, PULONG NrFreed) // Reference a cache stripe so it won't go away CcpLock(); if (CcCacheSections[BcbHead].BaseAddress) { - CcpReferenceCache(i); + CcpReferenceCache(BcbHead); CcpUnlock(); } else { CcpUnlock(); @@ -68,7 +68,7 @@ CcRosTrimCache(ULONG Target, ULONG Priority, PULONG NrFreed) *NrFreed += Freed; CcpLock(); - CcpDereferenceCache(BcbHead, FALSE); + CcpUnpinData(&CcCacheSections[BcbHead], TRUE); CcpUnlock(); } @@ -474,10 +474,10 @@ CcZeroData(IN PFILE_OBJECT FileObject, CcpLock(); ListEntry = ListEntry->Flink; // Return from pin state - CcpUnpinData(PinnedBcb); + CcpUnpinData(PinnedBcb, TRUE); } - CcpUnpinData(Bcb); + CcpUnpinData(Bcb, TRUE); } CcpUnlock(); diff --git a/reactos/ntoskrnl/cache/newcc.h b/reactos/ntoskrnl/cache/newcc.h index 5e0bd2608eb..ab93976f724 100644 --- a/reactos/ntoskrnl/cache/newcc.h +++ b/reactos/ntoskrnl/cache/newcc.h @@ -65,9 +65,9 @@ VOID NTAPI CcInitView(VOID); -VOID +BOOLEAN NTAPI -CcpUnpinData(PNOCC_BCB Bcb); +CcpUnpinData(PNOCC_BCB Bcb, BOOLEAN ActuallyRelease); BOOLEAN NTAPI diff --git a/reactos/ntoskrnl/cache/pinsup.c b/reactos/ntoskrnl/cache/pinsup.c index 5531bbb9720..c2a46398306 100644 --- a/reactos/ntoskrnl/cache/pinsup.c +++ b/reactos/ntoskrnl/cache/pinsup.c @@ -707,9 +707,9 @@ CcPreparePinWrite(IN PFILE_OBJECT FileObject, return Result; } -VOID +BOOLEAN NTAPI -CcpUnpinData(IN PNOCC_BCB RealBcb) +CcpUnpinData(IN PNOCC_BCB RealBcb, BOOLEAN ReleaseBit) { if (RealBcb->RefCount <= 2) { @@ -718,9 +718,11 @@ CcpUnpinData(IN PNOCC_BCB RealBcb) { DPRINT("Triggering exclusive waiter\n"); KeSetEvent(&RealBcb->ExclusiveWait, IO_NO_INCREMENT, FALSE); - return; + return TRUE; } } + if (RealBcb->RefCount == 2 && !ReleaseBit) + return FALSE; if (RealBcb->RefCount > 1) { DPRINT("Removing one reference #%x\n", RealBcb - CcCacheSections); @@ -730,6 +732,7 @@ CcpUnpinData(IN PNOCC_BCB RealBcb) if (RealBcb->RefCount == 1) { DPRINT("Clearing allocation bit #%x\n", RealBcb - CcCacheSections); + RtlClearBit(CcCacheBitmap, RealBcb - CcCacheSections); #ifdef PIN_WRITE_ONLY @@ -745,6 +748,8 @@ CcpUnpinData(IN PNOCC_BCB RealBcb) &OldProtect); #endif } + + return TRUE; } VOID @@ -753,13 +758,21 @@ CcUnpinData(IN PVOID Bcb) { PNOCC_BCB RealBcb = (PNOCC_BCB)Bcb; ULONG Selected = RealBcb - CcCacheSections; + BOOLEAN Released; ASSERT(RealBcb >= CcCacheSections && RealBcb - CcCacheSections < CACHE_NUM_SECTIONS); DPRINT("CcUnpinData Bcb #%x (RefCount %d)\n", Selected, RealBcb->RefCount); CcpLock(); - CcpUnpinData(RealBcb); + Released = CcpUnpinData(RealBcb, FALSE); CcpUnlock(); + + if (!Released) { + MiFlushMappedSection(RealBcb->BaseAddress, &RealBcb->FileOffset, &RealBcb->Map->FileSizes.FileSize, RealBcb->Dirty); + CcpLock(); + CcpUnpinData(RealBcb, TRUE); + CcpUnlock(); + } } VOID diff --git a/reactos/ntoskrnl/mm/rmap.c b/reactos/ntoskrnl/mm/rmap.c index 8d6867e50cc..a4753349d9e 100644 --- a/reactos/ntoskrnl/mm/rmap.c +++ b/reactos/ntoskrnl/mm/rmap.c @@ -365,7 +365,7 @@ MmDeleteAllRmaps(PFN_NUMBER Page, PVOID Context, previous_entry = current_entry; current_entry = current_entry->Next; #ifdef NEWCC - if (!RMAP_IS_SEGMENT(current_entry->Address)) + if (!RMAP_IS_SEGMENT(previous_entry->Address)) #endif { if (DeleteMapping) diff --git a/reactos/ntoskrnl/mm/section.c b/reactos/ntoskrnl/mm/section.c index bef77f4cad5..6be64326ac7 100644 --- a/reactos/ntoskrnl/mm/section.c +++ b/reactos/ntoskrnl/mm/section.c @@ -2039,7 +2039,9 @@ MmPageOutSectionView(PMMSUPPORT AddressSpace, ULONG FileOffset; NTSTATUS Status; PFILE_OBJECT FileObject; +#ifndef NEWCC PBCB Bcb = NULL; +#endif BOOLEAN DirectMapped; BOOLEAN IsImageSection; PEPROCESS Process = MmGetAddressSpaceOwner(AddressSpace); @@ -2061,6 +2063,7 @@ MmPageOutSectionView(PMMSUPPORT AddressSpace, FileObject = Context.Section->FileObject; DirectMapped = FALSE; +#ifndef NEWCC if (FileObject != NULL && !(Context.Segment->Characteristics & IMAGE_SCN_MEM_SHARED)) { @@ -2077,6 +2080,7 @@ MmPageOutSectionView(PMMSUPPORT AddressSpace, DirectMapped = TRUE; } } +#endif /* From 7ea8c55b57a583a2816f53eb054129f89ca93270 Mon Sep 17 00:00:00 2001 From: Aleksey Bragin Date: Thu, 23 Dec 2010 09:14:42 +0000 Subject: [PATCH 101/181] [NTOS] - Fix copypasta, thanks Victor! svn path=/trunk/; revision=50111 --- reactos/ntoskrnl/mm/ARM3/virtual.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reactos/ntoskrnl/mm/ARM3/virtual.c b/reactos/ntoskrnl/mm/ARM3/virtual.c index 2feff792feb..466bccf7c01 100644 --- a/reactos/ntoskrnl/mm/ARM3/virtual.c +++ b/reactos/ntoskrnl/mm/ARM3/virtual.c @@ -2458,7 +2458,7 @@ MiQueryMemoryBasicInformation(IN HANDLE ProcessHandle, ASSERT(BaseVpn > Vad->EndingVpn); /* Stop if there is no right child */ - if (!Vad->LeftChild) break; + if (!Vad->RightChild) break; /* Search on the right next */ Vad = Vad->RightChild; From ac56cac80c8a00df9a23162ff8a5a51618fd9842 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Thu, 23 Dec 2010 12:11:19 +0000 Subject: [PATCH 102/181] [VBEMP] Fix rounding error when calculating display size Loosely based on patch by neoman. Fixes gdi32_winetest:mapping See issue #5790 for more details. svn path=/trunk/; revision=50112 --- reactos/drivers/video/miniport/vbe/vbemp.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/reactos/drivers/video/miniport/vbe/vbemp.c b/reactos/drivers/video/miniport/vbe/vbemp.c index b8ee6e18eac..dc251daaac5 100644 --- a/reactos/drivers/video/miniport/vbe/vbemp.c +++ b/reactos/drivers/video/miniport/vbe/vbemp.c @@ -847,6 +847,7 @@ VBEQueryMode( ULONG VideoModeId) { PVBE_MODEINFO VBEMode = &DeviceExtension->ModeInfo[VideoModeId]; + ULONG dpi; VideoMode->Length = sizeof(VIDEO_MODE_INFORMATION); VideoMode->ModeIndex = VideoModeId; @@ -860,9 +861,10 @@ VBEQueryMode( VideoMode->BitsPerPlane = VBEMode->BitsPerPixel / VBEMode->NumberOfPlanes; VideoMode->Frequency = 1; - /* Assume 96DPI and 25.4 millimeters per inch */ - VideoMode->XMillimeter = VBEMode->XResolution * 254 / 960; - VideoMode->YMillimeter = VBEMode->YResolution * 254 / 960; + /* Assume 96DPI and 25.4 millimeters per inch, round to nearest */ + dpi = 96; + VideoMode->XMillimeter = ((ULONGLONG)VBEMode->XResolution * 254 + (dpi * 5)) / (dpi * 10); + VideoMode->YMillimeter = ((ULONGLONG)VBEMode->YResolution * 254 + (dpi * 5)) / (dpi * 10); if (VBEMode->BitsPerPixel > 8) { From aa62a1a2a63d843ba0de53e72d1d30c15651758c Mon Sep 17 00:00:00 2001 From: Roel Messiant Date: Thu, 23 Dec 2010 14:10:59 +0000 Subject: [PATCH 103/181] [WIN32K] - NtGdiGetDIBitsInternal: Copy the requested amount of scanlines into the return buffer, not the whole bitmap. Should fix bug #5766. svn path=/trunk/; revision=50113 --- reactos/subsystems/win32/win32k/objects/dibobj.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reactos/subsystems/win32/win32k/objects/dibobj.c b/reactos/subsystems/win32/win32k/objects/dibobj.c index 116aebf93f8..cbc8ea5cd69 100644 --- a/reactos/subsystems/win32/win32k/objects/dibobj.c +++ b/reactos/subsystems/win32/win32k/objects/dibobj.c @@ -971,7 +971,7 @@ NtGdiGetDIBitsInternal( Status = STATUS_SUCCESS; _SEH2_TRY { - RtlCopyMemory(Bits, pDIBits, DIB_GetDIBImageBytes (width, height, bpp)); + RtlCopyMemory(Bits, pDIBits, DIB_GetDIBImageBytes (width, ScanLines, bpp)); } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { From 3bb6178e68d8483de9b838947f59b82c71baf69d Mon Sep 17 00:00:00 2001 From: Roel Messiant Date: Thu, 23 Dec 2010 15:38:14 +0000 Subject: [PATCH 104/181] [SHELL32] - Add NULL checks in IShellView and IDropTarget implementations. Should fix bug #5780. svn path=/trunk/; revision=50114 --- reactos/dll/win32/shell32/shlview.c | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/reactos/dll/win32/shell32/shlview.c b/reactos/dll/win32/shell32/shlview.c index c4c6a07a079..f3cd5507c13 100644 --- a/reactos/dll/win32/shell32/shlview.c +++ b/reactos/dll/win32/shell32/shlview.c @@ -2072,7 +2072,14 @@ static HRESULT WINAPI IShellView_fnCreateViewWindow( TRACE("(%p)->(shlview=%p set=%p shlbrs=%p rec=%p hwnd=%p) incomplete\n",This, lpPrevView,lpfs, psb, prcView, phWnd); - TRACE("-- vmode=%x flags=%x left=%i top=%i right=%i bottom=%i\n",lpfs->ViewMode, lpfs->fFlags ,prcView->left,prcView->top, prcView->right, prcView->bottom); + if (lpfs != NULL) + TRACE("-- vmode=%x flags=%x\n", lpfs->ViewMode, lpfs->fFlags); + if (prcView != NULL) + TRACE("-- left=%i top=%i right=%i bottom=%i\n", prcView->left, prcView->top, prcView->right, prcView->bottom); + + /* Validate the Shell Browser */ + if (psb == NULL) + return E_UNEXPECTED; /*set up the member variables*/ This->pShellBrowser = psb; @@ -2534,8 +2541,13 @@ static HRESULT WINAPI ISVDropTarget_DragLeave(IDropTarget *iface) { IDropTarget_Release(This->pCurDropTarget); This->pCurDropTarget = NULL; } - IDataObject_Release(This->pCurDataObject); - This->pCurDataObject = NULL; + + if (This->pCurDataObject != NULL) + { + IDataObject_Release(This->pCurDataObject); + This->pCurDataObject = NULL; + } + This->iDragOverItem = 0; return S_OK; @@ -2553,8 +2565,12 @@ static HRESULT WINAPI ISVDropTarget_Drop(IDropTarget *iface, IDataObject* pDataO This->pCurDropTarget = NULL; } - IDataObject_Release(This->pCurDataObject); - This->pCurDataObject = NULL; + if (This->pCurDataObject != NULL) + { + IDataObject_Release(This->pCurDataObject); + This->pCurDataObject = NULL; + } + This->iDragOverItem = 0; return S_OK; From c884962fb3b2eedd0cdba0fc3259bac6f33ea1c8 Mon Sep 17 00:00:00 2001 From: Aleksey Bragin Date: Thu, 23 Dec 2010 16:59:55 +0000 Subject: [PATCH 105/181] [UNIATA] - Update uniata to 0.40a1. Prepared by Samuel Serapion, edited by me. See issue #5762 for more details. svn path=/trunk/; revision=50115 --- reactos/drivers/storage/ide/uniata/atapi.h | 2 +- reactos/drivers/storage/ide/uniata/bm_devs.h | 329 +++++++++++--- reactos/drivers/storage/ide/uniata/bsmaster.h | 36 +- reactos/drivers/storage/ide/uniata/config.h | 32 +- reactos/drivers/storage/ide/uniata/id_ata.cpp | 202 +++++---- reactos/drivers/storage/ide/uniata/id_dma.cpp | 163 ++++++- .../drivers/storage/ide/uniata/id_init.cpp | 405 +++++++++++++----- .../drivers/storage/ide/uniata/id_probe.cpp | 66 ++- .../drivers/storage/ide/uniata/id_queue.cpp | 33 ++ .../drivers/storage/ide/uniata/id_sata.cpp | 218 ++++++++-- reactos/drivers/storage/ide/uniata/id_sata.h | 32 +- reactos/drivers/storage/ide/uniata/idedma.rc | 4 +- .../drivers/storage/ide/uniata/inc/CrossNt.h | 3 + reactos/drivers/storage/ide/uniata/scsi.h | 52 +-- reactos/drivers/storage/ide/uniata/srb.h | 22 +- reactos/drivers/storage/ide/uniata/todo.txt | 254 +++++++++++ .../drivers/storage/ide/uniata/uniata_ver.h | 12 +- 17 files changed, 1517 insertions(+), 348 deletions(-) create mode 100644 reactos/drivers/storage/ide/uniata/todo.txt diff --git a/reactos/drivers/storage/ide/uniata/atapi.h b/reactos/drivers/storage/ide/uniata/atapi.h index 2648d4b0b55..1252df9209b 100644 --- a/reactos/drivers/storage/ide/uniata/atapi.h +++ b/reactos/drivers/storage/ide/uniata/atapi.h @@ -952,7 +952,7 @@ AtapiSoftReset( AtapiWritePort1(&BaseIoAddress->AltStatus,IDE_DC_DISABLE_INTERRUPTS | IDE_DC_RESET_CONTROLLER );\ ScsiPortStallExecution(50 * 1000);\ AtapiWritePort1(&BaseIoAddress->AltStatus,IDE_DC_REENABLE_CONTROLLER);\ - 5 seconds for reset \ + // 5 seconds for reset \ for (i = 0; i < 1000 * (1+11); i++) {\ statusByte = AtapiReadPort1(&BaseIoAddress->AltStatus);\ if (statusByte != IDE_STATUS_IDLE && statusByte != IDE_STATUS_SUCCESS) {\ diff --git a/reactos/drivers/storage/ide/uniata/bm_devs.h b/reactos/drivers/storage/ide/uniata/bm_devs.h index a001ef00211..dbcbfa91adc 100644 --- a/reactos/drivers/storage/ide/uniata/bm_devs.h +++ b/reactos/drivers/storage/ide/uniata/bm_devs.h @@ -1,6 +1,6 @@ /*++ -Copyright (c) 2002-2005 Alexandr A. Telyatnikov (Alter) +Copyright (c) 2002-2010 Alexandr A. Telyatnikov (Alter) Module Name: bm_devs.h @@ -74,6 +74,7 @@ Revision History: #define ATA_SA150 0x47 /*0x80*/ #define ATA_SA300 0x48 /*0x81*/ +#define ATA_SA600 0x49 /*0x82*/ // define PIO timings in nanoseconds #define PIO0_TIMING 600 @@ -136,6 +137,7 @@ typedef struct _BUSMASTER_CONTROLLER_INFORMATION { #define ATA_ACER_LABS_ID 0x10b9 #define ATA_ALI_1533 0x153310b9 +#define ATA_ALI_5228 0x522810b9 #define ATA_ALI_5229 0x522910b9 #define ATA_ALI_5281 0x528110b9 #define ATA_ALI_5287 0x528710b9 @@ -153,6 +155,11 @@ typedef struct _BUSMASTER_CONTROLLER_INFORMATION { #define ATA_ATI_IXP600_S1 0x43801002 #define ATA_ATI_IXP700 0x439c1002 #define ATA_ATI_IXP700_S1 0x43901002 +#define ATA_ATI_IXP700_S2 0x43911002 +#define ATA_ATI_IXP700_S3 0x43921002 +#define ATA_ATI_IXP700_S4 0x43931002 +#define ATA_ATI_IXP800_S1 0x43941002 +#define ATA_ATI_IXP800_S2 0x43951002 #define ATA_CENATEK_ID 0x16ca #define ATA_CENATEK_ROCKET 0x000116ca @@ -190,11 +197,11 @@ typedef struct _BUSMASTER_CONTROLLER_INFORMATION { #define ATA_I82801DB 0x24cb8086 #define ATA_I82801DB_1 0x24ca8086 #define ATA_I82801EB 0x24db8086 -#define ATA_I82801EB_1 0x24d18086 -#define ATA_I82801EB_2 0x24df8086 -#define ATA_I6300ESB 0x25a28086 -#define ATA_I6300ESB_1 0x25a38086 -#define ATA_I6300ESB_2 0x25b08086 +#define ATA_I82801EB_S1 0x24d18086 +#define ATA_I82801EB_R1 0x24df8086 +#define ATA_I6300ESB 0x25a28086 +#define ATA_I6300ESB_S1 0x25a38086 +#define ATA_I6300ESB_R1 0x25b08086 #define ATA_I63XXESB2 0x269e8086 #define ATA_I63XXESB2_S1 0x26808086 #define ATA_I63XXESB2_S2 0x26818086 @@ -206,9 +213,71 @@ typedef struct _BUSMASTER_CONTROLLER_INFORMATION { #define ATA_I82801FB_M 0x26538086 #define ATA_I82801GB 0x27df8086 #define ATA_I82801GB_S1 0x27c08086 -#define ATA_I82801GB_R1 0x27c38086 #define ATA_I82801GB_AH 0x27c18086 -#define ATA_I82801GB_M 0x27c58086 +#define ATA_I82801GB_R1 0x27c38086 +#define ATA_I82801GBM_S1 0x27c48086 +#define ATA_I82801GBM_AH 0x27c58086 +#define ATA_I82801GBM_R1 0x27c68086 +#define ATA_I82801HB_S1 0x28208086 +#define ATA_I82801HB_AH6 0x28218086 +#define ATA_I82801HB_R1 0x28228086 +#define ATA_I82801HB_AH4 0x28248086 +#define ATA_I82801HB_S2 0x28258086 +#define ATA_I82801HBM 0x28508086 +#define ATA_I82801HBM_S1 0x28288086 +#define ATA_I82801HBM_S2 0x28298086 +#define ATA_I82801HBM_S3 0x282a8086 +#define ATA_I82801IB_S1 0x29208086 +#define ATA_I82801IB_AH2 0x29218086 +#define ATA_I82801IB_AH6 0x29228086 +#define ATA_I82801IB_AH4 0x29238086 +#define ATA_I82801IB_R1 0x29258086 +#define ATA_I82801IB_S2 0x29268086 +#define ATA_I82801JIB_S1 0x3a208086 +#define ATA_I82801JIB_AH 0x3a228086 +#define ATA_I82801JIB_R1 0x3a258086 +#define ATA_I82801JIB_S2 0x3a268086 +#define ATA_I82801JD_S1 0x3a008086 +#define ATA_I82801JD_AH 0x3a028086 +#define ATA_I82801JD_R1 0x3a058086 +#define ATA_I82801JD_S2 0x3a068086 +#define ATA_I82801JI_S1 0x3a208086 +#define ATA_I82801JI_AH 0x3a228086 +#define ATA_I82801JI_R1 0x3a258086 +#define ATA_I82801JI_S2 0x3a268086 + +#define ATA_5Series_S1 0x3b208086 +#define ATA_5Series_S2 0x3b218086 +#define ATA_5Series_AH1 0x3b228086 +#define ATA_5Series_AH2 0x3b238086 +#define ATA_5Series_R1 0x3b258086 +#define ATA_5Series_S3 0x3b268086 +#define ATA_5Series_S4 0x3b288086 +#define ATA_5Series_AH3 0x3b298086 +#define ATA_5Series_R2 0x3b2c8086 +#define ATA_5Series_S5 0x3b2d8086 +#define ATA_5Series_S6 0x3b2e8086 +#define ATA_5Series_AH4 0x3b2f8086 + +#define ATA_CPT_S1 0x1c008086 +#define ATA_CPT_S2 0x1c018086 +#define ATA_CPT_AH1 0x1c028086 +#define ATA_CPT_AH2 0x1c038086 +#define ATA_CPT_R1 0x1c048086 +#define ATA_CPT_R2 0x1c058086 +#define ATA_CPT_S3 0x1c088086 +#define ATA_CPT_S4 0x1c098086 + +#define ATA_I31244 0x32008086 +#define ATA_ISCH 0x811a8086 + +#define ATA_JMICRON_ID 0x197b +#define ATA_JMB360 0x2360197b +#define ATA_JMB361 0x2361197b +#define ATA_JMB363 0x2363197b +#define ATA_JMB365 0x2365197b +#define ATA_JMB366 0x2366197b +#define ATA_JMB368 0x2368197b #define ATA_MARVELL_ID 0x11ab #define ATA_M88SX5040 0x504011ab @@ -216,9 +285,16 @@ typedef struct _BUSMASTER_CONTROLLER_INFORMATION { #define ATA_M88SX5080 0x508011ab #define ATA_M88SX5081 0x508111ab #define ATA_M88SX6041 0x604111ab +#define ATA_M88SX6042 0x604211ab #define ATA_M88SX6081 0x608111ab +#define ATA_M88SX7042 0x704211ab #define ATA_M88SX6101 0x610111ab +#define ATA_M88SX6102 0x610211ab +#define ATA_M88SX6111 0x611111ab +#define ATA_M88SX6121 0x612111ab +#define ATA_M88SX6141 0x614111ab #define ATA_M88SX6145 0x614511ab +#define ATA_MARVELL2_ID 0x1b4b #define ATA_MICRON_ID 0x1042 #define ATA_MICRON_RZ1000 0x10001042 @@ -256,9 +332,78 @@ typedef struct _BUSMASTER_CONTROLLER_INFORMATION { #define ATA_NFORCE_MCP61_S2 0x03f610de #define ATA_NFORCE_MCP61_S3 0x03f710de #define ATA_NFORCE_MCP65 0x044810de +#define ATA_NFORCE_MCP65_A0 0x044c10de +#define ATA_NFORCE_MCP65_A1 0x044d10de +#define ATA_NFORCE_MCP65_A2 0x044e10de +#define ATA_NFORCE_MCP65_A3 0x044f10de +#define ATA_NFORCE_MCP65_A4 0x045c10de +#define ATA_NFORCE_MCP65_A5 0x045d10de +#define ATA_NFORCE_MCP65_A6 0x045e10de +#define ATA_NFORCE_MCP65_A7 0x045f10de #define ATA_NFORCE_MCP67 0x056010de +#define ATA_NFORCE_MCP67_A0 0x055010de +#define ATA_NFORCE_MCP67_A1 0x055110de +#define ATA_NFORCE_MCP67_A2 0x055210de +#define ATA_NFORCE_MCP67_A3 0x055310de +#define ATA_NFORCE_MCP67_A4 0x055410de +#define ATA_NFORCE_MCP67_A5 0x055510de +#define ATA_NFORCE_MCP67_A6 0x055610de +#define ATA_NFORCE_MCP67_A7 0x055710de +#define ATA_NFORCE_MCP67_A8 0x055810de +#define ATA_NFORCE_MCP67_A9 0x055910de +#define ATA_NFORCE_MCP67_AA 0x055A10de +#define ATA_NFORCE_MCP67_AB 0x055B10de +#define ATA_NFORCE_MCP67_AC 0x058410de #define ATA_NFORCE_MCP73 0x056c10de +#define ATA_NFORCE_MCP73_A0 0x07f010de +#define ATA_NFORCE_MCP73_A1 0x07f110de +#define ATA_NFORCE_MCP73_A2 0x07f210de +#define ATA_NFORCE_MCP73_A3 0x07f310de +#define ATA_NFORCE_MCP73_A4 0x07f410de +#define ATA_NFORCE_MCP73_A5 0x07f510de +#define ATA_NFORCE_MCP73_A6 0x07f610de +#define ATA_NFORCE_MCP73_A7 0x07f710de +#define ATA_NFORCE_MCP73_A8 0x07f810de +#define ATA_NFORCE_MCP73_A9 0x07f910de +#define ATA_NFORCE_MCP73_AA 0x07fa10de +#define ATA_NFORCE_MCP73_AB 0x07fb10de #define ATA_NFORCE_MCP77 0x075910de +#define ATA_NFORCE_MCP77_A0 0x0ad010de +#define ATA_NFORCE_MCP77_A1 0x0ad110de +#define ATA_NFORCE_MCP77_A2 0x0ad210de +#define ATA_NFORCE_MCP77_A3 0x0ad310de +#define ATA_NFORCE_MCP77_A4 0x0ad410de +#define ATA_NFORCE_MCP77_A5 0x0ad510de +#define ATA_NFORCE_MCP77_A6 0x0ad610de +#define ATA_NFORCE_MCP77_A7 0x0ad710de +#define ATA_NFORCE_MCP77_A8 0x0ad810de +#define ATA_NFORCE_MCP77_A9 0x0ad910de +#define ATA_NFORCE_MCP77_AA 0x0ada10de +#define ATA_NFORCE_MCP77_AB 0x0adb10de +#define ATA_NFORCE_MCP79_A0 0x0ab410de +#define ATA_NFORCE_MCP79_A1 0x0ab510de +#define ATA_NFORCE_MCP79_A2 0x0ab610de +#define ATA_NFORCE_MCP79_A3 0x0ab710de +#define ATA_NFORCE_MCP79_A4 0x0ab810de +#define ATA_NFORCE_MCP79_A5 0x0ab910de +#define ATA_NFORCE_MCP79_A6 0x0aba10de +#define ATA_NFORCE_MCP79_A7 0x0abb10de +#define ATA_NFORCE_MCP79_A8 0x0abc10de +#define ATA_NFORCE_MCP79_A9 0x0abd10de +#define ATA_NFORCE_MCP79_AA 0x0abe10de +#define ATA_NFORCE_MCP79_AB 0x0abf10de +#define ATA_NFORCE_MCP89_A0 0x0d8410de +#define ATA_NFORCE_MCP89_A1 0x0d8510de +#define ATA_NFORCE_MCP89_A2 0x0d8610de +#define ATA_NFORCE_MCP89_A3 0x0d8710de +#define ATA_NFORCE_MCP89_A4 0x0d8810de +#define ATA_NFORCE_MCP89_A5 0x0d8910de +#define ATA_NFORCE_MCP89_A6 0x0d8a10de +#define ATA_NFORCE_MCP89_A7 0x0d8b10de +#define ATA_NFORCE_MCP89_A8 0x0d8c10de +#define ATA_NFORCE_MCP89_A9 0x0d8d10de +#define ATA_NFORCE_MCP89_AA 0x0d8e10de +#define ATA_NFORCE_MCP89_AB 0x0d8f10de #define ATA_PROMISE_ID 0x105a #define ATA_PDC20246 0x4d33105a @@ -281,12 +426,24 @@ typedef struct _BUSMASTER_CONTROLLER_INFORMATION { #define ATA_PDC20377 0x3377105a #define ATA_PDC20378 0x3373105a #define ATA_PDC20379 0x3372105a +#define ATA_PDC20571 0x3571105a +#define ATA_PDC20575 0x3d75105a +#define ATA_PDC20579 0x3574105a +#define ATA_PDC20771 0x3570105a +#define ATA_PDC40518 0x3d18105a +#define ATA_PDC40519 0x3519105a +#define ATA_PDC40718 0x3d17105a +#define ATA_PDC40719 0x3515105a +#define ATA_PDC40775 0x3d73105a +#define ATA_PDC40779 0x3577105a #define ATA_PDC20617 0x6617105a #define ATA_PDC20618 0x6626105a #define ATA_PDC20619 0x6629105a #define ATA_PDC20620 0x6620105a #define ATA_PDC20621 0x6621105a #define ATA_PDC20622 0x6622105a +#define ATA_PDC20624 0x6624105a +#define ATA_PDC81518 0x8002105a #define ATA_SERVERWORKS_ID 0x1166 #define ATA_ROSB4_ISA 0x02001166 @@ -306,6 +463,10 @@ typedef struct _BUSMASTER_CONTROLLER_INFORMATION { #define ATA_SII3512 0x35121095 #define ATA_SII3112 0x31121095 #define ATA_SII3112_1 0x02401095 +#define ATA_SII3124 0x31241095 +#define ATA_SII3132 0x31321095 +#define ATA_SII3132_1 0x02421095 +#define ATA_SII3132_2 0x02441095 #define ATA_SII0680 0x06801095 #define ATA_CMD646 0x06461095 #define ATA_CMD648 0x06481095 @@ -355,7 +516,11 @@ typedef struct _BUSMASTER_CONTROLLER_INFORMATION { #define ATA_SIS962 0x09621039 #define ATA_SIS963 0x09631039 #define ATA_SIS964 0x09641039 +#define ATA_SIS965 0x09651039 #define ATA_SIS964_1 0x01801039 +#define ATA_SIS180 0x01801039 +#define ATA_SIS181 0x01811039 +#define ATA_SIS182 0x01821039 #define ATA_VIA_ID 0x1106 #define ATA_VIA82C571 0x05711106 @@ -370,6 +535,8 @@ typedef struct _BUSMASTER_CONTROLLER_INFORMATION { #define ATA_VIA8237 0x32271106 #define ATA_VIA8237A 0x05911106 #define ATA_VIA8237S 0x53371106 +#define ATA_VIA8237_5372 0x53721106 +#define ATA_VIA8237_7372 0x73721106 #define ATA_VIA8251 0x33491106 #define ATA_VIA8361 0x31121106 #define ATA_VIA8363 0x03051106 @@ -379,9 +546,17 @@ typedef struct _BUSMASTER_CONTROLLER_INFORMATION { #define ATA_VIA6420 0x31491106 #define ATA_VIA6421 0x32491106 +#define ATA_VIACX700IDE 0x05811106 +#define ATA_VIACX700 0x83241106 +#define ATA_VIASATAIDE 0x53241106 +#define ATA_VIAVX800 0x83531106 +#define ATA_VIAVX855 0x84091106 + #define ATA_ITE_ID 0x1283 #define ATA_IT8172G 0x81721283 -#define ATA_IT8212F 0x82121283 +#define ATA_IT8211F 0x82111283 +#define ATA_IT8212F 0x82121283 +#define ATA_IT8213F 0x82131283 #define ATA_OPTI_ID 0x1045 #define ATA_OPTI82C621 0xc6211045 @@ -455,7 +630,14 @@ typedef struct _BUSMASTER_CONTROLLER_INFORMATION { #define SIS_BASE 0x0100 #define SIS_SOUTH 0x0200 +#define INTEL_STD 0 +#define INTEL_IDX 1 + #define ICH4_FIX 0x0100 +#define ICH5 0x0200 +#define I6CH 0x0400 +#define I6CH2 0x0800 +#define I1CH 0x1000 #define NV4OFF 0x0100 #define NVQ 0x0200 @@ -473,9 +655,11 @@ typedef struct _BUSMASTER_CONTROLLER_INFORMATION { #define VIASOUTH 0x2000 #define VIAAST 0x4000 #define VIAPRQ 0x8000 +#define VIASATA 0x10000 #define ITE_33 0 #define ITE_133 1 +#define ITE_133_NEW 2 #ifdef USER_MODE #define PCI_DEV_HW_SPEC_BM(idhi, idlo, rev, mode, name, flags) \ @@ -499,6 +683,7 @@ BUSMASTER_CONTROLLER_INFORMATION const BusMasterAdapters[] = { PCI_DEV_HW_SPEC_BM( 5288, 10b9, 0x00, ATA_SA300, "ALI M5288" , UNIATA_SATA | UNIATA_NO_SLAVE ), PCI_DEV_HW_SPEC_BM( 5287, 10b9, 0x00, ATA_SA150, "ALI M5287" , UNIATA_SATA | UNIATA_NO_SLAVE ), PCI_DEV_HW_SPEC_BM( 5281, 10b9, 0x00, ATA_SA150, "ALI M5281" , UNIATA_SATA | UNIATA_NO_SLAVE ), + PCI_DEV_HW_SPEC_BM( 5228, 10b9, 0xc5, ATA_UDMA6, "ALI M5228 UDMA6" , ALINEW ), PCI_DEV_HW_SPEC_BM( 5229, 10b9, 0xc5, ATA_UDMA6, "ALI M5229 UDMA6" , ALINEW ), PCI_DEV_HW_SPEC_BM( 5229, 10b9, 0xc4, ATA_UDMA5, "ALI M5229 UDMA5" , ALINEW ), PCI_DEV_HW_SPEC_BM( 5229, 10b9, 0xc2, ATA_UDMA4, "ALI M5229 UDMA4" , ALINEW ), @@ -521,8 +706,7 @@ BUSMASTER_CONTROLLER_INFORMATION const BusMasterAdapters[] = { PCI_DEV_HW_SPEC_BM( 438c, 1002, 0x00, ATA_UDMA6, "ATI IXP600" , 0 ), PCI_DEV_HW_SPEC_BM( 4380, 1002, 0x00, ATA_SA150, "ATI IXP600" , UNIATA_SATA | UNIATA_AHCI ), PCI_DEV_HW_SPEC_BM( 439c, 1002, 0x00, ATA_UDMA6, "ATI IXP700" , 0 ), - PCI_DEV_HW_SPEC_BM( 4390, 1002, 0x00, ATA_UDMA6, "ATI IXP700" , 0 ), - PCI_DEV_HW_SPEC_BM( 4391, 1002, 0x00, ATA_SA150, "ATI IXP700" , UNIATA_SATA | UNIATA_AHCI ), + PCI_DEV_HW_SPEC_BM( 4390, 1002, 0x00, ATA_SA150, "ATI IXP700" , UNIATA_SATA | UNIATA_AHCI ), PCI_DEV_HW_SPEC_BM( 0004, 1103, 0x05, ATA_UDMA6, "HighPoint HPT372" , HPT372 | 0x00 | UNIATA_RAID_CONTROLLER), PCI_DEV_HW_SPEC_BM( 0004, 1103, 0x03, ATA_UDMA5, "HighPoint HPT370" , HPT370 | 0x00 | UNIATA_RAID_CONTROLLER), @@ -540,78 +724,111 @@ BUSMASTER_CONTROLLER_INFORMATION const BusMasterAdapters[] = { PCI_DEV_HW_SPEC_BM( 7199, 8086, 0x00, ATA_UDMA2, "Intel PIIX4" , 0 ), PCI_DEV_HW_SPEC_BM( 84ca, 8086, 0x00, ATA_UDMA2, "Intel PIIX4" , 0 ), PCI_DEV_HW_SPEC_BM( 7601, 8086, 0x00, ATA_UDMA2, "Intel ICH0" , 0 ), + PCI_DEV_HW_SPEC_BM( 2421, 8086, 0x00, ATA_UDMA4, "Intel ICH" , 0 ), PCI_DEV_HW_SPEC_BM( 2411, 8086, 0x00, ATA_UDMA4, "Intel ICH" , 0 ), + PCI_DEV_HW_SPEC_BM( 244a, 8086, 0x00, ATA_UDMA5, "Intel ICH2" , 0 ), PCI_DEV_HW_SPEC_BM( 244b, 8086, 0x00, ATA_UDMA5, "Intel ICH2" , 0 ), + PCI_DEV_HW_SPEC_BM( 248a, 8086, 0x00, ATA_UDMA5, "Intel ICH3" , 0 ), PCI_DEV_HW_SPEC_BM( 248b, 8086, 0x00, ATA_UDMA5, "Intel ICH3" , 0 ), + PCI_DEV_HW_SPEC_BM( 24cb, 8086, 0x00, ATA_UDMA5, "Intel ICH4" , ICH4_FIX | UNIATA_NO_DPC ), PCI_DEV_HW_SPEC_BM( 24ca, 8086, 0x00, ATA_UDMA5, "Intel ICH4" , ICH4_FIX | UNIATA_NO_DPC ), + PCI_DEV_HW_SPEC_BM( 24db, 8086, 0x00, ATA_UDMA5, "Intel ICH5 EB" , 0 ), - PCI_DEV_HW_SPEC_BM( 24d1, 8086, 0x00, ATA_SA150, "Intel ICH5 EB1" , UNIATA_SATA ), - PCI_DEV_HW_SPEC_BM( 24df, 8086, 0x00, ATA_SA150, "Intel ICH5 EB2" , UNIATA_SATA ), + PCI_DEV_HW_SPEC_BM( 24d1, 8086, 0x00, ATA_SA150, "Intel ICH5 EB1" , ICH5 | UNIATA_SATA ), + PCI_DEV_HW_SPEC_BM( 24df, 8086, 0x00, ATA_SA150, "Intel ICH5 EB2" , ICH5 | UNIATA_SATA ), + PCI_DEV_HW_SPEC_BM( 25a2, 8086, 0x00, ATA_UDMA5, "Intel 6300ESB" , 0 ), - PCI_DEV_HW_SPEC_BM( 25a3, 8086, 0x00, ATA_SA150, "Intel 6300ESB1" , UNIATA_SATA ), - PCI_DEV_HW_SPEC_BM( 25b0, 8086, 0x00, ATA_SA150, "Intel 6300ESB2" , UNIATA_SATA ), + PCI_DEV_HW_SPEC_BM( 25a3, 8086, 0x00, ATA_SA150, "Intel 6300ESB1" , ICH5 | UNIATA_SATA ), + PCI_DEV_HW_SPEC_BM( 25b0, 8086, 0x00, ATA_SA150, "Intel 6300ESB2" , ICH5 | UNIATA_SATA ), + PCI_DEV_HW_SPEC_BM( 266f, 8086, 0x00, ATA_UDMA5, "Intel ICH6" , 0 ), PCI_DEV_HW_SPEC_BM( 2651, 8086, 0x00, ATA_SA150, "Intel ICH6" , UNIATA_SATA | UNIATA_AHCI ), PCI_DEV_HW_SPEC_BM( 2652, 8086, 0x00, ATA_SA150, "Intel ICH6" , UNIATA_SATA | UNIATA_AHCI ), PCI_DEV_HW_SPEC_BM( 2653, 8086, 0x00, ATA_SA150, "Intel ICH6M" , UNIATA_SATA | UNIATA_AHCI ), - PCI_DEV_HW_SPEC_BM( 27c0, 8086, 0x00, ATA_SA300, "Intel ICH7" , UNIATA_SATA | UNIATA_AHCI ), + + PCI_DEV_HW_SPEC_BM( 27df, 8086, 0x00, ATA_UDMA5, "Intel ICH7" , I1CH ), + PCI_DEV_HW_SPEC_BM( 27c0, 8086, 0x00, ATA_SA300, "Intel ICH7 S1" , UNIATA_SATA ), PCI_DEV_HW_SPEC_BM( 27c1, 8086, 0x00, ATA_SA300, "Intel ICH7" , UNIATA_SATA | UNIATA_AHCI ), - PCI_DEV_HW_SPEC_BM( 27c3, 8086, 0x00, ATA_SA300, "Intel ICH7" , UNIATA_SATA | UNIATA_AHCI ), - PCI_DEV_HW_SPEC_BM( 27c4, 8086, 0x00, ATA_SA300, "Intel ICH7M" , UNIATA_SATA | UNIATA_AHCI ), - PCI_DEV_HW_SPEC_BM( 27c5, 8086, 0x00, ATA_SA300, "Intel ICH7M" , UNIATA_SATA | UNIATA_AHCI ), - PCI_DEV_HW_SPEC_BM( 27c6, 8086, 0x00, ATA_SA300, "Intel ICH7M" , UNIATA_SATA | UNIATA_AHCI ), - PCI_DEV_HW_SPEC_BM( 27df, 8086, 0x00, ATA_UDMA5, "Intel ICH7" , 0 ), - PCI_DEV_HW_SPEC_BM( 269e, 8086, 0x00, ATA_UDMA5, "Intel 63XXESB2" , 0 ), - PCI_DEV_HW_SPEC_BM( 2680, 8086, 0x00, ATA_SA300, "Intel 63XXESB2" , UNIATA_SATA | UNIATA_AHCI ), + PCI_DEV_HW_SPEC_BM( 27c3, 8086, 0x00, ATA_SA300, "Intel ICH7" , UNIATA_SATA ), + PCI_DEV_HW_SPEC_BM( 27c4, 8086, 0x00, ATA_SA150, "Intel ICH7M R1" , UNIATA_SATA ), + PCI_DEV_HW_SPEC_BM( 27c5, 8086, 0x00, ATA_SA150, "Intel ICH7M" , UNIATA_SATA | UNIATA_AHCI ), + PCI_DEV_HW_SPEC_BM( 27c6, 8086, 0x00, ATA_SA150, "Intel ICH7M" , UNIATA_SATA ), + + PCI_DEV_HW_SPEC_BM( 269e, 8086, 0x00, ATA_UDMA5, "Intel 63XXESB2" , I1CH ), + PCI_DEV_HW_SPEC_BM( 2680, 8086, 0x00, ATA_SA300, "Intel 63XXESB2" , UNIATA_SATA ), PCI_DEV_HW_SPEC_BM( 2681, 8086, 0x00, ATA_SA300, "Intel 63XXESB2" , UNIATA_SATA | UNIATA_AHCI ), PCI_DEV_HW_SPEC_BM( 2682, 8086, 0x00, ATA_SA300, "Intel 63XXESB2" , UNIATA_SATA | UNIATA_AHCI ), PCI_DEV_HW_SPEC_BM( 2683, 8086, 0x00, ATA_SA300, "Intel 63XXESB2" , UNIATA_SATA | UNIATA_AHCI ), - PCI_DEV_HW_SPEC_BM( 2820, 8086, 0x00, ATA_UDMA5, "Intel ICH8" , 0 ), + PCI_DEV_HW_SPEC_BM( 2820, 8086, 0x00, ATA_SA300, "Intel ICH8" , I6CH ), PCI_DEV_HW_SPEC_BM( 2821, 8086, 0x00, ATA_SA300, "Intel ICH8" , UNIATA_SATA | UNIATA_AHCI ), PCI_DEV_HW_SPEC_BM( 2822, 8086, 0x00, ATA_SA300, "Intel ICH8" , UNIATA_SATA | UNIATA_AHCI ), PCI_DEV_HW_SPEC_BM( 2824, 8086, 0x00, ATA_SA300, "Intel ICH8" , UNIATA_SATA | UNIATA_AHCI ), - PCI_DEV_HW_SPEC_BM( 2825, 8086, 0x00, ATA_UDMA5, "Intel ICH8" , 0 ), - PCI_DEV_HW_SPEC_BM( 2828, 8086, 0x00, ATA_UDMA5, "Intel ICH8M" , 0 ), + PCI_DEV_HW_SPEC_BM( 2825, 8086, 0x00, ATA_SA300, "Intel ICH8" , I6CH2 | UNIATA_SATA ), + PCI_DEV_HW_SPEC_BM( 2828, 8086, 0x00, ATA_SA300, "Intel ICH8M" , I6CH | UNIATA_SATA ), PCI_DEV_HW_SPEC_BM( 2829, 8086, 0x00, ATA_SA300, "Intel ICH8M" , UNIATA_SATA | UNIATA_AHCI ), PCI_DEV_HW_SPEC_BM( 282a, 8086, 0x00, ATA_SA300, "Intel ICH8M" , UNIATA_SATA | UNIATA_AHCI ), - PCI_DEV_HW_SPEC_BM( 2850, 8086, 0x00, ATA_UDMA5, "Intel ICH8M" , 0 ), + PCI_DEV_HW_SPEC_BM( 2850, 8086, 0x00, ATA_UDMA5, "Intel ICH8M" , I1CH ), - PCI_DEV_HW_SPEC_BM( 2920, 8086, 0x00, ATA_UDMA5, "Intel ICH9R/DO/DH", 0 ), - PCI_DEV_HW_SPEC_BM( 2921, 8086, 0x00, ATA_UDMA5, "Intel ICH9" , 0 ), + PCI_DEV_HW_SPEC_BM( 2920, 8086, 0x00, ATA_SA300, "Intel ICH9" , I6CH | UNIATA_SATA ), + PCI_DEV_HW_SPEC_BM( 2926, 8086, 0x00, ATA_SA300, "Intel ICH9" , I6CH2 | UNIATA_SATA ), + PCI_DEV_HW_SPEC_BM( 2921, 8086, 0x00, ATA_SA300, "Intel ICH9" , UNIATA_SATA | UNIATA_AHCI ), PCI_DEV_HW_SPEC_BM( 2922, 8086, 0x00, ATA_SA300, "Intel ICH9" , UNIATA_SATA | UNIATA_AHCI ), PCI_DEV_HW_SPEC_BM( 2923, 8086, 0x00, ATA_SA300, "Intel ICH9" , UNIATA_SATA | UNIATA_AHCI ), - PCI_DEV_HW_SPEC_BM( 2926, 8086, 0x00, ATA_SA300, "Intel ICH9" , UNIATA_SATA | UNIATA_AHCI ), - PCI_DEV_HW_SPEC_BM( 2928, 8086, 0x00, ATA_UDMA5, "Intel ICH9M/M-E" , 0 ), - PCI_DEV_HW_SPEC_BM( 2929, 8086, 0x00, ATA_SA300, "Intel ICH9M/M-E" , UNIATA_SATA | UNIATA_AHCI ), - PCI_DEV_HW_SPEC_BM( 292d, 8086, 0x00, ATA_UDMA5, "Intel ICH9M/M-E" , 0 ), - PCI_DEV_HW_SPEC_BM( 292e, 8086, 0x00, ATA_UDMA5, "Intel ICH9M/M-E" , 0 ), + PCI_DEV_HW_SPEC_BM( 2925, 8086, 0x00, ATA_SA300, "Intel ICH9" , UNIATA_SATA | UNIATA_AHCI ), - PCI_DEV_HW_SPEC_BM( 3a00, 8086, 0x00, ATA_UDMA5, "Intel ICH10" , 0 ), - PCI_DEV_HW_SPEC_BM( 3a02, 8086, 0x00, ATA_SA300, "Intel ICH10" , UNIATA_SATA | UNIATA_AHCI ), - PCI_DEV_HW_SPEC_BM( 3a03, 8086, 0x00, ATA_SA300, "Intel ICH10" , UNIATA_SATA | UNIATA_AHCI ), - PCI_DEV_HW_SPEC_BM( 3a06, 8086, 0x00, ATA_UDMA5, "Intel ICH10" , 0 ), - PCI_DEV_HW_SPEC_BM( 3a20, 8086, 0x00, ATA_UDMA5, "Intel ICH10" , 0 ), - PCI_DEV_HW_SPEC_BM( 3a22, 8086, 0x00, ATA_SA300, "Intel ICH10" , UNIATA_SATA | UNIATA_AHCI ), - PCI_DEV_HW_SPEC_BM( 3a23, 8086, 0x00, ATA_SA300, "Intel ICH10" , UNIATA_SATA | UNIATA_AHCI ), - PCI_DEV_HW_SPEC_BM( 3a26, 8086, 0x00, ATA_UDMA5, "Intel ICH10" , 0 ), + PCI_DEV_HW_SPEC_BM( 3a20, 8086, 0x00, ATA_SA300, "Intel ICH10" , I6CH | UNIATA_SATA ), + PCI_DEV_HW_SPEC_BM( 3a26, 8086, 0x00, ATA_SA300, "Intel ICH10" , I6CH2 | UNIATA_SATA ), + PCI_DEV_HW_SPEC_BM( 3a22, 8086, 0x00, ATA_SA300, "Intel ICH10" , UNIATA_SATA | UNIATA_AHCI ), + PCI_DEV_HW_SPEC_BM( 3a25, 8086, 0x00, ATA_SA300, "Intel ICH10" , UNIATA_SATA | UNIATA_AHCI ), - PCI_DEV_HW_SPEC_BM( 3b20, 8086, 0x00, ATA_UDMA5, "Intel PCH" , 0 ), - PCI_DEV_HW_SPEC_BM( 3b21, 8086, 0x00, ATA_UDMA5, "Intel PCH" , 0 ), - PCI_DEV_HW_SPEC_BM( 3b22, 8086, 0x00, ATA_SA300, "Intel PCH" , UNIATA_SATA | UNIATA_AHCI ), - PCI_DEV_HW_SPEC_BM( 3b23, 8086, 0x00, ATA_SA300, "Intel PCH" , UNIATA_SATA | UNIATA_AHCI ), - PCI_DEV_HW_SPEC_BM( 3b26, 8086, 0x00, ATA_UDMA5, "Intel PCH" , 0 ), - PCI_DEV_HW_SPEC_BM( 3b28, 8086, 0x00, ATA_UDMA5, "Intel PCH" , 0 ), - PCI_DEV_HW_SPEC_BM( 3b29, 8086, 0x00, ATA_SA300, "Intel PCH" , UNIATA_SATA | UNIATA_AHCI ), - PCI_DEV_HW_SPEC_BM( 3b2D, 8086, 0x00, ATA_UDMA5, "Intel PCH" , 0 ), - PCI_DEV_HW_SPEC_BM( 3b2E, 8086, 0x00, ATA_UDMA5, "Intel PCH" , 0 ), - PCI_DEV_HW_SPEC_BM( 3b2F, 8086, 0x00, ATA_SA300, "Intel PCH" , UNIATA_SATA | UNIATA_AHCI ), + PCI_DEV_HW_SPEC_BM( 3a00, 8086, 0x00, ATA_SA300, "Intel ICH10" , I6CH | UNIATA_SATA ), + PCI_DEV_HW_SPEC_BM( 3a06, 8086, 0x00, ATA_SA300, "Intel ICH10" , I6CH2 | UNIATA_SATA ), + PCI_DEV_HW_SPEC_BM( 3a02, 8086, 0x00, ATA_SA300, "Intel ICH10" , UNIATA_SATA | UNIATA_AHCI ), + PCI_DEV_HW_SPEC_BM( 3a05, 8086, 0x00, ATA_SA300, "Intel ICH10" , UNIATA_SATA | UNIATA_AHCI ), +/* + PCI_DEV_HW_SPEC_BM( ????, 8086, 0x00, ATA_SA300, "Intel ICH10" , I6CH | UNIATA_SATA ), + PCI_DEV_HW_SPEC_BM( ????, 8086, 0x00, ATA_SA300, "Intel ICH10" , I6CH2 | UNIATA_SATA ), + PCI_DEV_HW_SPEC_BM( ????, 8086, 0x00, ATA_SA300, "Intel ICH10" , UNIATA_SATA | UNIATA_AHCI ), + PCI_DEV_HW_SPEC_BM( ????, 8086, 0x00, ATA_SA300, "Intel ICH10" , UNIATA_SATA | UNIATA_AHCI ), +*/ + PCI_DEV_HW_SPEC_BM( 3b20, 8086, 0x00, ATA_SA300, "Intel 5 Series/3400" , I6CH | UNIATA_SATA ), + PCI_DEV_HW_SPEC_BM( 3b21, 8086, 0x00, ATA_SA300, "Intel 5 Series/3400" , I6CH2 | UNIATA_SATA ), + PCI_DEV_HW_SPEC_BM( 3b22, 8086, 0x00, ATA_SA300, "Intel 5 Series/3400" , UNIATA_SATA | UNIATA_AHCI ), + PCI_DEV_HW_SPEC_BM( 3b23, 8086, 0x00, ATA_SA300, "Intel 5 Series/3400" , UNIATA_SATA | UNIATA_AHCI ), + PCI_DEV_HW_SPEC_BM( 3b25, 8086, 0x00, ATA_SA300, "Intel 5 Series/3400" , UNIATA_SATA | UNIATA_AHCI ), + PCI_DEV_HW_SPEC_BM( 3b26, 8086, 0x00, ATA_SA300, "Intel 5 Series/3400" , I6CH2 | UNIATA_SATA ), + PCI_DEV_HW_SPEC_BM( 3b28, 8086, 0x00, ATA_SA300, "Intel 5 Series/3400" , I6CH | UNIATA_SATA ), + PCI_DEV_HW_SPEC_BM( 3b29, 8086, 0x00, ATA_SA300, "Intel 5 Series/3400" , UNIATA_SATA | UNIATA_AHCI ), + PCI_DEV_HW_SPEC_BM( 3b2c, 8086, 0x00, ATA_SA300, "Intel 5 Series/3400" , UNIATA_SATA | UNIATA_AHCI ), + PCI_DEV_HW_SPEC_BM( 3b2d, 8086, 0x00, ATA_SA300, "Intel 5 Series/3400" , I6CH2 | UNIATA_SATA ), + PCI_DEV_HW_SPEC_BM( 3b2e, 8086, 0x00, ATA_SA300, "Intel 5 Series/3400" , I6CH | UNIATA_SATA ), + PCI_DEV_HW_SPEC_BM( 3b2f, 8086, 0x00, ATA_SA300, "Intel 5 Series/3400" , UNIATA_SATA | UNIATA_AHCI ), + + PCI_DEV_HW_SPEC_BM( 1c00, 8086, 0x00, ATA_SA300, "Intel Cougar Point" , I6CH | UNIATA_SATA ), + PCI_DEV_HW_SPEC_BM( 1c01, 8086, 0x00, ATA_SA300, "Intel Cougar Point" , I6CH | UNIATA_SATA ), + PCI_DEV_HW_SPEC_BM( 1c02, 8086, 0x00, ATA_SA300, "Intel Cougar Point" , UNIATA_SATA | UNIATA_AHCI ), + PCI_DEV_HW_SPEC_BM( 1c03, 8086, 0x00, ATA_SA300, "Intel Cougar Point" , UNIATA_SATA | UNIATA_AHCI ), + PCI_DEV_HW_SPEC_BM( 1c04, 8086, 0x00, ATA_SA300, "Intel Cougar Point" , UNIATA_SATA | UNIATA_AHCI ), + PCI_DEV_HW_SPEC_BM( 1c05, 8086, 0x00, ATA_SA300, "Intel Cougar Point" , UNIATA_SATA | UNIATA_AHCI ), + PCI_DEV_HW_SPEC_BM( 1c08, 8086, 0x00, ATA_SA300, "Intel Cougar Point" , I6CH2 | UNIATA_SATA ), + PCI_DEV_HW_SPEC_BM( 1c09, 8086, 0x00, ATA_SA300, "Intel Cougar Point" , I6CH2 | UNIATA_SATA ), // PCI_DEV_HW_SPEC_BM( 3200, 8086, 0x00, ATA_SA150, "Intel 31244" , UNIATA_SATA ), + PCI_DEV_HW_SPEC_BM( 3200, 8086, 0x00, ATA_UDMA5, "Intel SCH" , I1CH ), + +/* + PCI_DEV_HW_SPEC_BM( 2360, 197b, 0x00, ATA_SA300, "JMB360" , 0 ), + PCI_DEV_HW_SPEC_BM( 2361, 197b, 0x00, ATA_SA300, "JMB361" , 0 ), + PCI_DEV_HW_SPEC_BM( 2363, 197b, 0x00, ATA_SA300, "JMB363" , 0 ), + PCI_DEV_HW_SPEC_BM( 2365, 197b, 0x00, ATA_SA300, "JMB365" , 0 ), + PCI_DEV_HW_SPEC_BM( 2366, 197b, 0x00, ATA_SA300, "JMB366" , 0 ), + PCI_DEV_HW_SPEC_BM( 2368, 197b, 0x00, ATA_UDMA6, "JMB368" , 0 ), +*/ /* PCI_DEV_HW_SPEC_BM( 5040, 11ab, 0x00, ATA_SA150, "Marvell 88SX5040" , UNIATA_SATA ), PCI_DEV_HW_SPEC_BM( 5041, 11ab, 0x00, ATA_SA150, "Marvell 88SX5041" , UNIATA_SATA ), @@ -620,6 +837,7 @@ BUSMASTER_CONTROLLER_INFORMATION const BusMasterAdapters[] = { PCI_DEV_HW_SPEC_BM( 6041, 11ab, 0x00, ATA_SA300, "Marvell 88SX6041" , UNIATA_SATA ), PCI_DEV_HW_SPEC_BM( 6081, 11ab, 0x00, ATA_SA300, "Marvell 88SX6081" , UNIATA_SATA ),*/ PCI_DEV_HW_SPEC_BM( 6101, 11ab, 0x00, ATA_UDMA6, "Marvell 88SX6101" , 0 ), + PCI_DEV_HW_SPEC_BM( 6121, 11ab, 0x00, ATA_UDMA6, "Marvell 88SX6121" , 0 ), PCI_DEV_HW_SPEC_BM( 6145, 11ab, 0x00, ATA_UDMA6, "Marvell 88SX6145" , 0 ), PCI_DEV_HW_SPEC_BM( 01bc, 10de, 0x00, ATA_UDMA5, "nVidia nForce" , AMDNVIDIA ), @@ -760,11 +978,16 @@ BUSMASTER_CONTROLLER_INFORMATION const BusMasterAdapters[] = { PCI_DEV_HW_SPEC_BM( 3177, 1106, 0x00, ATA_UDMA6, "VIA 8235" , VIA133 | VIAAST ), */ PCI_DEV_HW_SPEC_BM( 0571, 1106, 0x00, ATA_UDMA2, "VIA ATA-xxx" , 0 ), + PCI_DEV_HW_SPEC_BM( 0581, 1106, 0x00, ATA_UDMA6, "VIA UATA-xxx" , 0 ), + /* has no SATA registers, all mapped to PATA-style regs */ + PCI_DEV_HW_SPEC_BM( 5324, 1106, 0x00, ATA_SA150, "VIA SATA-xxx" , 0 ), PCI_DEV_HW_SPEC_BM( 3164, 1106, 0x00, ATA_UDMA6, "VIA 6410" , 0 ), PCI_DEV_HW_SPEC_BM( 3149, 1106, 0x00, ATA_SA150, "VIA 6420" , 0 | UNIATA_SATA ), PCI_DEV_HW_SPEC_BM( 3249, 1106, 0x00, ATA_SA150, "VIA 6421" , VIABAR | UNIATA_SATA ), PCI_DEV_HW_SPEC_BM( 0591, 1106, 0x00, ATA_SA150, "VIA 8237A" , 0 | UNIATA_SATA ), PCI_DEV_HW_SPEC_BM( 5337, 1106, 0x00, ATA_SA150, "VIA 8237S" , 0 | UNIATA_SATA ), + PCI_DEV_HW_SPEC_BM( 5372, 1106, 0x00, ATA_SA300, "VIA 8237" , 0 | UNIATA_SATA ), + PCI_DEV_HW_SPEC_BM( 7372, 1106, 0x00, ATA_SA300, "VIA 8237" , 0 | UNIATA_SATA ), //PCI_DEV_HW_SPEC_BM( 3349, 1106, 0x00, ATA_SA150, "VIA 8251" , VIAAHCI| UNIATA_SATA ), PCI_DEV_HW_SPEC_BM( c693, 1080, 0x00, ATA_WDMA2, "Cypress 82C693" ,0 ), @@ -797,7 +1020,9 @@ BUSMASTER_CONTROLLER_INFORMATION const BusMasterAdapters[] = { PCI_DEV_HW_SPEC_BM( 0102, 1042, 0x00, ATA_PIO4, "RZ 100x" , 0 ), PCI_DEV_HW_SPEC_BM( 8172, 1283, 0x00, ATA_UDMA2, "IT8172" , 0 ), + PCI_DEV_HW_SPEC_BM( 8213, 1283, 0x00, ATA_UDMA6, "IT8213F" , ITE_133_NEW ), PCI_DEV_HW_SPEC_BM( 8212, 1283, 0x00, ATA_UDMA6, "IT8212F" , ITE_133 ), + PCI_DEV_HW_SPEC_BM( 8211, 1283, 0x00, ATA_UDMA6, "IT8211F" , ITE_133 ), PCI_DEV_HW_SPEC_BM( 0044, 169c, 0x00, ATA_UDMA2, "Netcell SR3000/5000", 0 ), diff --git a/reactos/drivers/storage/ide/uniata/bsmaster.h b/reactos/drivers/storage/ide/uniata/bsmaster.h index c0bcc22a6c5..365f076d669 100644 --- a/reactos/drivers/storage/ide/uniata/bsmaster.h +++ b/reactos/drivers/storage/ide/uniata/bsmaster.h @@ -1,6 +1,6 @@ /*++ -Copyright (c) 2002-2008 Alexandr A. Telyatnikov (Alter) +Copyright (c) 2002-2010 Alexandr A. Telyatnikov (Alter) Module Name: bsmaster.h @@ -188,6 +188,7 @@ typedef struct _IDE_AHCI_REGISTERS { ULONG AE:1; // AHCI enable } GHC; +#define AHCI_GHC 0x04 #define AHCI_GHC_HR 0x00000001 #define AHCI_GHC_IE 0x00000002 #define AHCI_GHC_AE 0x80000000 @@ -347,7 +348,14 @@ typedef struct _IDE_SATA_REGISTERS { #define IDX_SATA_SActive (3+IDX_SATA_IO) #define IDX_SATA_SNTF_PMN (4+IDX_SATA_IO) -#define IDX_MAX_REG (IDX_SATA_IO+IDX_SATA_IO_SZ) +#define IDX_INDEXED_IO (IDX_SATA_IO+IDX_SATA_IO_SZ) +#define IDX_INDEXED_IO_SZ 2 + +#define IDX_INDEXED_ADDR (0+IDX_INDEXED_IO) +#define IDX_INDEXED_DATA (1+IDX_INDEXED_IO) + +#define IDX_MAX_REG (IDX_INDEXED_IO+IDX_INDEXED_IO_SZ) + typedef union _AHCI_IS_REG { struct { @@ -712,9 +720,10 @@ struct _HW_DEVICE_EXTENSION; struct _HW_LU_EXTENSION; typedef struct _IORES { - ULONG Addr; - ULONG MemIo:1; - ULONG Reserved:31; + ULONG Addr; /* Base address*/ + ULONG MemIo:1; /* Memory mapping (1) vs IO ports (0) */ + ULONG Proc:1; /* Need special process via IO_Proc */ + ULONG Reserved:30; } IORES, *PIORES; // Channel extension @@ -825,6 +834,9 @@ typedef struct _HW_CHANNEL { #define CTRFLAGS_LBA48 0x0040 #define CTRFLAGS_DSC_BSY 0x0080 #define CTRFLAGS_NO_SLAVE 0x0100 +//#define CTRFLAGS_PATA 0x0200 + +#define CTRFLAGS_PERMANENT (CTRFLAGS_DMA_RO | CTRFLAGS_NO_SLAVE) #define GEOM_AUTO 0xffffffff #define GEOM_STD 0x0000 @@ -883,6 +895,13 @@ typedef struct _HW_LU_EXTENSION { struct _SBadBlockRange* arrBadBlocks; ULONG nBadBlocks; + // Controller-specific LUN options + union { + /* for tricky controllers, those can change Logical-to-Physical LUN mapping. + mainly for mapping SATA ports to compatible PATA registers */ + ULONG SATA_lun_map; + }; + struct _HW_DEVICE_EXTENSION* DeviceExtension; #ifdef IO_STATISTICS @@ -989,6 +1008,11 @@ typedef struct _HW_DEVICE_EXTENSION { PCCH FullDevName; + // Controller specific state/options + union { + ULONG HwCfg; + }; + } HW_DEVICE_EXTENSION, *PHW_DEVICE_EXTENSION; typedef struct _ISR2_DEVICE_EXTENSION { @@ -1210,7 +1234,7 @@ UniataChipDetectChannels( IN PPORT_CONFIGURATION_INFORMATION ConfigInfo ); -extern BOOLEAN +extern NTSTATUS NTAPI UniataChipDetect( IN PVOID HwDeviceExtension, diff --git a/reactos/drivers/storage/ide/uniata/config.h b/reactos/drivers/storage/ide/uniata/config.h index c0b9f4f88ad..17768e42a20 100644 --- a/reactos/drivers/storage/ide/uniata/config.h +++ b/reactos/drivers/storage/ide/uniata/config.h @@ -86,19 +86,47 @@ /* Compiler dependencies */ /***************************************************/ -#define DDKFASTAPI __fastcall +/* ReactOS-specific defines */ +#ifdef DDKAPI + #define USE_REACTOS_DDK +#endif //DDKAPI /* Are we under GNU C (mingw) ??? */ -#ifdef __GNUC__ +#if __GNUC__ >=3 #define DEF_U64(x) (x##ULL) #define DEF_I64(x) (x##LL) + /* ReactOS-specific defines */ + #ifdef USE_REACTOS_DDK + #define DDKFASTAPI __attribute__((fastcall)) + #else //USE_REACTOS_DDK + + #define DDKAPI __attribute__((stdcall)) + #define DDKFASTAPI __attribute__((fastcall)) + #define DDKCDECLAPI __attribute__((cdecl)) + + #endif //DDKAPI + + #define DECLSPEC_NAKED __attribute__((naked)) + #else // !__GNUC__ => MSVC/Intel #define DEF_U64(x) (x##UI64) #define DEF_I64(x) (x##I64) + /* ReactOS-specific defines */ + #ifdef USE_REACTOS_DDK + #else //USE_REACTOS_DDK + + #define DDKAPI __stdcall + #define DDKFASTAPI __fastcall + #define DDKCDECLAPI _cdecl + + #endif //DDKAPI + + #define DECLSPEC_NAKED __declspec(naked) + #endif //__GNUC__ diff --git a/reactos/drivers/storage/ide/uniata/id_ata.cpp b/reactos/drivers/storage/ide/uniata/id_ata.cpp index 1d141b57bbb..70aaed34e67 100644 --- a/reactos/drivers/storage/ide/uniata/id_ata.cpp +++ b/reactos/drivers/storage/ide/uniata/id_ata.cpp @@ -1,6 +1,6 @@ /*++ -Copyright (c) 2002-2008 Alexandr A. Telyatnikov (Alter) +Copyright (c) 2002-2010 Alexandr A. Telyatnikov (Alter) Module Name: id_ata.cpp @@ -88,6 +88,7 @@ BOOLEAN InDriverEntry = TRUE; BOOLEAN g_opt_Verbose = 0; BOOLEAN WinVer_WDM_Model = FALSE; + //UCHAR EnableDma = FALSE; //UCHAR EnableReorder = FALSE; @@ -234,7 +235,6 @@ UniataNanoSleep( } while(t); } // end UniataNanoSleep() - #define AtapiWritePortN_template(_type, _Type, sz) \ VOID \ DDKFASTAPI \ @@ -254,6 +254,8 @@ AtapiWritePort##sz( \ KdPrint(("invalid io write request @ ch %x, res* %x\n", chan, _port)); \ return; \ } \ + if(res->Proc) { \ + } else \ if(!res->MemIo) { \ ScsiPortWritePort##_Type((_type*)(res->Addr), data); \ } else { \ @@ -287,6 +289,8 @@ AtapiWritePortEx##sz( \ KdPrint(("invalid io write request @ ch %x, res* %x, offs %x\n", chan, _port, offs)); \ return; \ } \ + if(res->Proc) { \ + } else \ if(!res->MemIo) { \ ScsiPortWritePort##_Type((_type*)(res->Addr+offs), data); \ } else { \ @@ -318,6 +322,9 @@ AtapiReadPort##sz( \ KdPrint(("invalid io read request @ ch %x, res* %x\n", chan, _port)); \ return (_type)(-1); \ } \ + if(res->Proc) { \ + return 0; \ + } else \ if(!res->MemIo) { \ /*KdPrint(("r_io @ (%x) %x\n", _port, res->Addr));*/ \ return ScsiPortReadPort##_Type((_type*)(res->Addr)); \ @@ -350,6 +357,9 @@ AtapiReadPortEx##sz( \ KdPrint(("invalid io read request @ ch %x, res* %x, offs %x\n", chan, _port, offs)); \ return (_type)(-1); \ } \ + if(res->Proc) { \ + return 0; \ + } else \ if(!res->MemIo) { \ return ScsiPortReadPort##_Type((_type*)(res->Addr+offs)); \ } else { \ @@ -719,7 +729,10 @@ AtapiSoftReset( GetBaseStatus(chan, statusByte2); } if(chan->DeviceExtension->HwFlags & UNIATA_SATA) { - UniataSataClearErr(chan->DeviceExtension, chan->lChannel, UNIATA_SATA_IGNORE_CONNECT); + UniataSataClearErr(chan->DeviceExtension, chan->lChannel, UNIATA_SATA_IGNORE_CONNECT, DeviceNumber); +/* if(!(chan->ChannelCtrlFlags & CTRFLAGS_NO_SLAVE)) { + UniataSataClearErr(chan->DeviceExtension, chan->lChannel, UNIATA_SATA_IGNORE_CONNECT, 1); + }*/ } return; @@ -1319,14 +1332,16 @@ IssueIdentify( KdPrint2((PRINT_PREFIX "IssueIdentify: IDE_STATUS_DRQ (%#x)\n", statusByte)); GetBaseStatus(chan, statusByte); // One last check for Atapi. - signatureLow = AtapiReadPort1(chan, IDX_IO1_i_CylinderLow); - signatureHigh = AtapiReadPort1(chan, IDX_IO1_i_CylinderHigh); + if (Command == IDE_COMMAND_IDENTIFY) { + signatureLow = AtapiReadPort1(chan, IDX_IO1_i_CylinderLow); + signatureHigh = AtapiReadPort1(chan, IDX_IO1_i_CylinderHigh); - if (signatureLow == ATAPI_MAGIC_LSB && - signatureHigh == ATAPI_MAGIC_MSB) { - KdPrint2((PRINT_PREFIX "IssueIdentify: this is ATAPI (3) (ldev %d)\n", ldev)); - // Device is Atapi. - return FALSE; + if (signatureLow == ATAPI_MAGIC_LSB && + signatureHigh == ATAPI_MAGIC_MSB) { + KdPrint2((PRINT_PREFIX "IssueIdentify: this is ATAPI (3) (ldev %d)\n", ldev)); + // Device is Atapi. + return FALSE; + } } break; } else { @@ -1342,6 +1357,11 @@ IssueIdentify( KdPrint2((PRINT_PREFIX "IssueIdentify: this is ATAPI (4) (ldev %d)\n", ldev)); return FALSE; } + } else { + if(!(statusByte & IDE_STATUS_ERROR) && (statusByte & IDE_STATUS_BUSY)) { + KdPrint2((PRINT_PREFIX "IssueIdentify: DRQ not asserted immediately, BUSY -> WaitForDrq\n")); + break; + } } // Device didn't respond correctly. It will be given one more chances. KdPrint2((PRINT_PREFIX "IssueIdentify: DRQ never asserted (%#x). Error reg (%#x)\n", @@ -1388,20 +1408,20 @@ IssueIdentify( // ATI/SII chipsets with memory-mapped IO hangs when // I call ReadBuffer(), probably due to PCI burst/prefetch enabled // Unfortunately, I don't know yet how to workaround it except the way you see below. - KdPrint2((PRINT_PREFIX + KdPrint2((PRINT_PREFIX " IO_%#x (%#x), %s:\n", IDX_IO1_i_Data, chan->RegTranslation[IDX_IO1_i_Data].Addr, chan->RegTranslation[IDX_IO1_i_Data].MemIo ? "Mem" : "IO")); for(i=0; i<256; i++) { /* - KdPrint2((PRINT_PREFIX + KdPrint2((PRINT_PREFIX " IO_%#x (%#x):\n", IDX_IO1_i_Data, chan->RegTranslation[IDX_IO1_i_Data].Addr)); */ w = AtapiReadPort2(chan, IDX_IO1_i_Data); - KdPrint2((PRINT_PREFIX + KdPrint2((PRINT_PREFIX " %x\n", w)); AtapiStallExecution(1); ((PUSHORT)&deviceExtension->FullIdentifyData)[i] = w; @@ -1464,7 +1484,7 @@ IssueIdentify( ULONGLONG cylinders=0; ULONGLONG tmp_cylinders=0; // Read very-old-style drive geometry - KdPrint2((PRINT_PREFIX "CHS %#x:%#x:%#x\n", + KdPrint2((PRINT_PREFIX "CHS %#x:%#x:%#x\n", deviceExtension->FullIdentifyData.NumberOfCylinders, deviceExtension->FullIdentifyData.NumberOfHeads, deviceExtension->FullIdentifyData.SectorsPerTrack @@ -1478,7 +1498,7 @@ IssueIdentify( /* (deviceExtension->FullIdentifyData.TranslationFieldsValid) &&*/ (NumOfSectors < deviceExtension->FullIdentifyData.UserAddressableSectors)) { KdPrint2((PRINT_PREFIX "NumberOfCylinders == 0x3fff\n")); - cylinders = + cylinders = (deviceExtension->FullIdentifyData.UserAddressableSectors / (deviceExtension->FullIdentifyData.NumberOfHeads * deviceExtension->FullIdentifyData.SectorsPerTrack)); @@ -1516,13 +1536,13 @@ IssueIdentify( (deviceExtension->FullIdentifyData.UserAddressableSectors48 > NumOfSectors) ) { KdPrint2((PRINT_PREFIX "LBA48\n")); - cylinders = + cylinders = (deviceExtension->FullIdentifyData.UserAddressableSectors48 / (deviceExtension->FullIdentifyData.NumberOfHeads * deviceExtension->FullIdentifyData.SectorsPerTrack)); KdPrint2((PRINT_PREFIX "cylinders %#I64x\n", cylinders)); - + NativeNumOfSectors = cylinders * deviceExtension->FullIdentifyData.NumberOfHeads * deviceExtension->FullIdentifyData.SectorsPerTrack; @@ -1554,7 +1574,7 @@ IssueIdentify( KdPrint2((PRINT_PREFIX "Read high order bytes\n")); NativeNumOfSectors |= ((ULONG)AtapiReadPort1(chan, IDX_IO1_i_BlockNumber) << 24 ); - hNativeNumOfSectors= + hNativeNumOfSectors= (ULONG)AtapiReadPort1(chan, IDX_IO1_i_CylinderLow) | ((ULONG)AtapiReadPort1(chan, IDX_IO1_i_CylinderHigh) << 8) ; ((PULONG)&NativeNumOfSectors)[1] = hNativeNumOfSectors; @@ -1577,7 +1597,7 @@ IssueIdentify( ((ULONGLONG)AtapiReadPort1(chan, IDX_IO1_i_CylinderLow) << 8 ) | ((ULONGLONG)AtapiReadPort1(chan, IDX_IO1_i_CylinderLow) << 32) | ((ULONGLONG)AtapiReadPort1(chan, IDX_IO1_i_CylinderHigh) << 16) | - ((ULONGLONG)AtapiReadPort1(chan, IDX_IO1_i_CylinderHigh) << 40) + ((ULONGLONG)AtapiReadPort1(chan, IDX_IO1_i_CylinderHigh) << 40) ; } @@ -1601,7 +1621,7 @@ IssueIdentify( } } } - + if(NumOfSectors < 0x2100000 /*&& NumOfSectors > 31*1000*1000*/) { // check for native LBA size // some drives report ~32Gb in Identify Block @@ -1893,7 +1913,7 @@ AtapiResetController__( #endif //ULONG RevID = deviceExtension->RevID; ULONG ChipFlags = deviceExtension->HwFlags & CHIPFLAG_MASK; - UCHAR tmp8; + //UCHAR tmp8; UCHAR tmp16; KdPrint2((PRINT_PREFIX "AtapiResetController: Reset IDE %#x/%#x @ %#x\n", VendorID, DeviceID, slotNumber)); @@ -1975,7 +1995,7 @@ AtapiResetController__( // Indicate ready for next request. ScsiPortNotification(NextLuRequest, - deviceExtension, + deviceExtension, PathId, TargetId, Lun); @@ -1994,7 +2014,7 @@ AtapiResetController__( chan->ChannelCtrlFlags = 0; InterlockedExchange(&(chan->CheckIntr), CHECK_INTR_IDLE); - + // Reset controller KdPrint2((PRINT_PREFIX " disable intr (0)\n")); AtapiDisableInterrupts(deviceExtension, j); @@ -2009,6 +2029,7 @@ AtapiResetController__( goto default_reset; } +#if 0 /* ICH6 & ICH7 in compat mode has 4 SATA ports as master/slave on 2 ch's */ if(ChipFlags & UNIATA_AHCI) { mask = 0x0005 << j; @@ -2021,14 +2042,27 @@ AtapiResetController__( mask = 0x0001 << j; } } +#else + mask = 1 << chan->lun[0]->SATA_lun_map; + if (max_ldev > 1) { + mask |= (1 << chan->lun[1]->SATA_lun_map); + } +#endif ChangePciConfig2(0x92, a & ~mask); AtapiStallExecution(10); ChangePciConfig2(0x92, a | mask); timeout = 100; + + /* Wait up to 1 sec for "connect well". */ + if (ChipFlags & (I6CH | I6CH2)) + mask = mask << 8; + else + mask = mask << 4; + while (timeout--) { AtapiStallExecution(10000); GetPciConfig2(0x92, tmp16); - if ((tmp16 & (mask << 4)) == (mask << 4)) { + if ((tmp16 & mask) == mask) { AtapiStallExecution(10000); break; } @@ -2065,7 +2099,7 @@ AtapiResetController__( default: if(ChipFlags & UNIATA_SATA) { KdPrint2((PRINT_PREFIX " SATA generic reset\n")); - UniataSataClearErr(HwDeviceExtension, j, UNIATA_SATA_IGNORE_CONNECT); + UniataSataClearErr(HwDeviceExtension, j, UNIATA_SATA_IGNORE_CONNECT, 0); } default_reset: KdPrint2((PRINT_PREFIX " send reset\n")); @@ -2084,7 +2118,7 @@ default_reset: KdPrint2((PRINT_PREFIX " done\n")); break; - } + } // end switch() //if(!(ChipFlags & UNIATA_SATA)) { if(!UniataIsSATARangeAvailable(deviceExtension, j)) { @@ -2129,7 +2163,7 @@ default_reset: statusByte = WaitOnBusyLong(chan); statusByte = UniataIsIdle(deviceExtension, statusByte); if(statusByte == 0xff) { - KdPrint2((PRINT_PREFIX + KdPrint2((PRINT_PREFIX "no drive, status %#x\n", statusByte)); UniataForgetDevice(&(deviceExtension->lun[i + (j * 2)])); @@ -2154,7 +2188,7 @@ default_reset: IDE_COMMAND_ATAPI_IDENTIFY, FALSE); } else { - KdPrint2((PRINT_PREFIX + KdPrint2((PRINT_PREFIX "AtapiResetController: Status after soft reset %#x\n", statusByte)); } @@ -2235,7 +2269,7 @@ MapError( // Read the error register. errorByte = AtapiReadPort1(chan, IDX_IO1_i_Error); - KdPrint2((PRINT_PREFIX + KdPrint2((PRINT_PREFIX "MapError: Error register is %#x\n", errorByte)); @@ -2244,7 +2278,7 @@ MapError( switch (errorByte >> 4) { case SCSI_SENSE_NO_SENSE: - KdPrint2((PRINT_PREFIX + KdPrint2((PRINT_PREFIX "ATAPI: No sense information\n")); scsiStatus = SCSISTAT_CHECK_CONDITION; srbStatus = SRB_STATUS_ERROR; @@ -2252,7 +2286,7 @@ MapError( case SCSI_SENSE_RECOVERED_ERROR: - KdPrint2((PRINT_PREFIX + KdPrint2((PRINT_PREFIX "ATAPI: Recovered error\n")); scsiStatus = 0; srbStatus = SRB_STATUS_SUCCESS; @@ -2260,7 +2294,7 @@ MapError( case SCSI_SENSE_NOT_READY: - KdPrint2((PRINT_PREFIX + KdPrint2((PRINT_PREFIX "ATAPI: Device not ready\n")); scsiStatus = SCSISTAT_CHECK_CONDITION; srbStatus = SRB_STATUS_ERROR; @@ -2268,7 +2302,7 @@ MapError( case SCSI_SENSE_MEDIUM_ERROR: - KdPrint2((PRINT_PREFIX + KdPrint2((PRINT_PREFIX "ATAPI: Media error\n")); scsiStatus = SCSISTAT_CHECK_CONDITION; srbStatus = SRB_STATUS_ERROR; @@ -2276,7 +2310,7 @@ MapError( case SCSI_SENSE_HARDWARE_ERROR: - KdPrint2((PRINT_PREFIX + KdPrint2((PRINT_PREFIX "ATAPI: Hardware error\n")); scsiStatus = SCSISTAT_CHECK_CONDITION; srbStatus = SRB_STATUS_ERROR; @@ -2284,7 +2318,7 @@ MapError( case SCSI_SENSE_ILLEGAL_REQUEST: - KdPrint2((PRINT_PREFIX + KdPrint2((PRINT_PREFIX "ATAPI: Illegal request\n")); scsiStatus = SCSISTAT_CHECK_CONDITION; srbStatus = SRB_STATUS_ERROR; @@ -2292,7 +2326,7 @@ MapError( case SCSI_SENSE_UNIT_ATTENTION: - KdPrint2((PRINT_PREFIX + KdPrint2((PRINT_PREFIX "ATAPI: Unit attention\n")); scsiStatus = SCSISTAT_CHECK_CONDITION; srbStatus = SRB_STATUS_ERROR; @@ -2300,7 +2334,7 @@ MapError( case SCSI_SENSE_DATA_PROTECT: - KdPrint2((PRINT_PREFIX + KdPrint2((PRINT_PREFIX "ATAPI: Data protect\n")); scsiStatus = SCSISTAT_CHECK_CONDITION; srbStatus = SRB_STATUS_ERROR; @@ -2308,14 +2342,14 @@ MapError( case SCSI_SENSE_BLANK_CHECK: - KdPrint2((PRINT_PREFIX + KdPrint2((PRINT_PREFIX "ATAPI: Blank check\n")); scsiStatus = SCSISTAT_CHECK_CONDITION; srbStatus = SRB_STATUS_ERROR; break; case SCSI_SENSE_ABORTED_COMMAND: - KdPrint2((PRINT_PREFIX + KdPrint2((PRINT_PREFIX "Atapi: Command Aborted\n")); scsiStatus = SCSISTAT_CHECK_CONDITION; srbStatus = SRB_STATUS_ERROR; @@ -2323,7 +2357,7 @@ MapError( default: - KdPrint2((PRINT_PREFIX + KdPrint2((PRINT_PREFIX "ATAPI: Invalid sense information\n")); scsiStatus = 0; srbStatus = SRB_STATUS_ERROR; @@ -2338,7 +2372,7 @@ MapError( chan->ReturningMediaStatus = errorByte; if (errorByte & IDE_ERROR_MEDIA_CHANGE_REQ) { - KdPrint2((PRINT_PREFIX + KdPrint2((PRINT_PREFIX "IDE: Media change\n")); scsiStatus = SCSISTAT_CHECK_CONDITION; srbStatus = SRB_STATUS_ERROR; @@ -2358,7 +2392,7 @@ MapError( } } else if (errorByte & IDE_ERROR_COMMAND_ABORTED) { - KdPrint2((PRINT_PREFIX + KdPrint2((PRINT_PREFIX "IDE: Command abort\n")); srbStatus = SRB_STATUS_ABORTED; scsiStatus = SCSISTAT_CHECK_CONDITION; @@ -2381,7 +2415,7 @@ MapError( } else if (errorByte & IDE_ERROR_END_OF_MEDIA) { - KdPrint2((PRINT_PREFIX + KdPrint2((PRINT_PREFIX "IDE: End of media\n")); scsiStatus = SCSISTAT_CHECK_CONDITION; srbStatus = SRB_STATUS_ERROR; @@ -2407,7 +2441,7 @@ MapError( } else if (errorByte & IDE_ERROR_ILLEGAL_LENGTH) { - KdPrint2((PRINT_PREFIX + KdPrint2((PRINT_PREFIX "IDE: Illegal length\n")); srbStatus = SRB_STATUS_INVALID_REQUEST; @@ -2428,7 +2462,7 @@ MapError( } else if (errorByte & IDE_ERROR_BAD_BLOCK) { - KdPrint2((PRINT_PREFIX + KdPrint2((PRINT_PREFIX "IDE: Bad block\n")); srbStatus = SRB_STATUS_ERROR; scsiStatus = SCSISTAT_CHECK_CONDITION; @@ -2448,7 +2482,7 @@ MapError( } else if (errorByte & IDE_ERROR_ID_NOT_FOUND) { - KdPrint2((PRINT_PREFIX + KdPrint2((PRINT_PREFIX "IDE: Id not found\n")); srbStatus = SRB_STATUS_ERROR; scsiStatus = SCSISTAT_CHECK_CONDITION; @@ -2471,7 +2505,7 @@ MapError( } else if (errorByte & IDE_ERROR_MEDIA_CHANGE) { - KdPrint2((PRINT_PREFIX + KdPrint2((PRINT_PREFIX "IDE: Media change\n")); scsiStatus = SCSISTAT_CHECK_CONDITION; srbStatus = SRB_STATUS_ERROR; @@ -2492,7 +2526,7 @@ MapError( } else if (errorByte & IDE_ERROR_DATA_ERROR) { - KdPrint2((PRINT_PREFIX + KdPrint2((PRINT_PREFIX "IDE: Data error\n")); scsiStatus = SCSISTAT_CHECK_CONDITION; srbStatus = SRB_STATUS_ERROR; @@ -2520,18 +2554,18 @@ MapError( if (deviceExtension->lun[ldev].ErrorCount >= MAX_ERRORS) { // deviceExtension->DWordIO = FALSE; - KdPrint2((PRINT_PREFIX + KdPrint2((PRINT_PREFIX "MapError: ErrorCount >= MAX_ERRORS\n")); deviceExtension->lun[ldev].DeviceFlags &= ~DFLAGS_DWORDIO_ENABLED; deviceExtension->lun[ldev].MaximumBlockXfer = 0; BrutePoint(); - KdPrint2((PRINT_PREFIX + KdPrint2((PRINT_PREFIX "MapError: Disabling 32-bit PIO and Multi-sector IOs\n")); // Log the error. - KdPrint2((PRINT_PREFIX + KdPrint2((PRINT_PREFIX "ScsiPortLogError: devExt %#x, Srb %#x, P:T:D=%d:%d:%d, MsgId %#x (%d)\n", HwDeviceExtension, Srb, @@ -2703,7 +2737,7 @@ AtapiHwInitialize__( } if(LunExt->IdentifyData.MajorRevision) { - + if(LunExt->opt_ReadCacheEnable) { KdPrint2((PRINT_PREFIX " Try Enable Read Cache\n")); // If supported, setup read/write cacheing @@ -2713,7 +2747,7 @@ AtapiHwInitialize__( // Check for errors. if (statusByte & IDE_STATUS_ERROR) { - KdPrint2((PRINT_PREFIX + KdPrint2((PRINT_PREFIX "AtapiHwInitialize: Enable read/write cacheing on Device %d failed\n", i)); LunExt->DeviceFlags &= ~DFLAGS_RCACHE_ENABLED; @@ -2735,7 +2769,7 @@ AtapiHwInitialize__( 0, ATA_C_F_ENAB_WCACHE, ATA_WAIT_BASE_READY); // Check for errors. if (statusByte & IDE_STATUS_ERROR) { - KdPrint2((PRINT_PREFIX + KdPrint2((PRINT_PREFIX "AtapiHwInitialize: Enable write cacheing on Device %d failed\n", i)); LunExt->DeviceFlags &= ~DFLAGS_WCACHE_ENABLED; @@ -3085,7 +3119,7 @@ AtapiCallBack__( goto ReturnCallback; } -#if DBG +#ifdef DBG if (!IS_RDP((srb->Cdb[0]))) { KdPrint2((PRINT_PREFIX "AtapiCallBack: Invalid CDB marked as RDP - %#x\n", srb->Cdb[0])); } @@ -3114,7 +3148,7 @@ AtapiCallBack__( // Ask for next request. ScsiPortNotification(NextLuRequest, - deviceExtension, + deviceExtension, PathId, TargetId, Lun); @@ -3228,7 +3262,7 @@ AtapiInterrupt( for(_c=0; _cNumberChannels; _c++) { checked[_c] = FALSE; } -// fc = +// fc = // atapiDev = (deviceExtension->lun[ldev].DeviceFlags & DFLAGS_ATAPI_DEVICE) ? TRUE : FALSE; for(pass=0; pass<2; pass++) { for(_c=0; _cNumberChannels; _c++) { @@ -3418,7 +3452,7 @@ AtapiInterruptDpc( CHECK_INTR_DETECTED) != CHECK_INTR_DETECTED) { continue; } - + } else { deviceExtension->chan[c].ChannelCtrlFlags &= ~CTRFLAGS_DPC_REQ; } @@ -3604,7 +3638,7 @@ AtapiCheckInterrupt__( if((ChipFlags & UNIATA_AHCI) && UniataIsSATARangeAvailable(deviceExtension, lChannel)) { - OurInterrupt = UniataAhciStatus(HwDeviceExtension, lChannel); + OurInterrupt = UniataAhciStatus(HwDeviceExtension, lChannel, -1); return OurInterrupt; } @@ -3622,7 +3656,7 @@ AtapiCheckInterrupt__( status = AtapiReadPortEx4(chan, (ULONG_PTR)&deviceExtension->BaseIoAddressBM_0,0x1c); if (!DmaTransfer) break; - if (!(status & + if (!(status & ((Channel) ? 0x00004000 : 0x00000400))) { KdPrint2((PRINT_PREFIX " Promise old/new unexpected\n")); return FALSE; @@ -3678,18 +3712,18 @@ AtapiCheckInterrupt__( /* check for and handle connect events */ if(((pr_status & (0x0cUL << shift)) == (0x04UL << shift)) ) { - UniataSataEvent(deviceExtension, lChannel, UNIATA_SATA_EVENT_ATTACH); + UniataSataEvent(deviceExtension, lChannel, UNIATA_SATA_EVENT_ATTACH, 0); } /* check for and handle disconnect events */ if((pr_status & (0x08UL << shift)) && !((pr_status & (0x04UL << shift) && - AtapiReadPort4(chan, IDX_SATA_SStatus))) ) { - UniataSataEvent(deviceExtension, lChannel, UNIATA_SATA_EVENT_DETACH); + UniataSataReadPort4(chan, IDX_SATA_SStatus, 0))) ) { + UniataSataEvent(deviceExtension, lChannel, UNIATA_SATA_EVENT_DETACH, 0); } /* do we have any device action ? */ if(!(pr_status & (0x01UL << shift))) { KdPrint2((PRINT_PREFIX " nVidia unexpected\n")); - if(UniataSataClearErr(HwDeviceExtension, c, UNIATA_SATA_DO_CONNECT)) { + if(UniataSataClearErr(HwDeviceExtension, c, UNIATA_SATA_DO_CONNECT, 0)) { OurInterrupt = 2; } else { return FALSE; @@ -3726,7 +3760,7 @@ AtapiCheckInterrupt__( * controllers continue to assert IRQ as long as * SError bits are pending. Clear SError immediately. */ - if(UniataSataClearErr(HwDeviceExtension, c, UNIATA_SATA_DO_CONNECT)) { + if(UniataSataClearErr(HwDeviceExtension, c, UNIATA_SATA_DO_CONNECT, 0)) { OurInterrupt = 2; } } @@ -3771,13 +3805,30 @@ AtapiCheckInterrupt__( AtapiWritePort1(chan, IDX_BM_Command, AtapiReadPort1(chan, IDX_BM_Command) & ~BM_COMMAND_START_STOP); goto skip_dma_stat_check; + case ATA_INTEL_ID: + if(UniataIsSATARangeAvailable(deviceExtension, lChannel)) { + if(ChipFlags & UNIATA_AHCI) { + // Do nothing here + } else + if(ChipFlags & UNIATA_SATA) { + if(UniataSataClearErr(HwDeviceExtension, c, UNIATA_SATA_DO_CONNECT, 0)) { + OurInterrupt = 2; + } + if(!(chan->ChannelCtrlFlags & CTRFLAGS_NO_SLAVE)) { + if(UniataSataClearErr(chan->DeviceExtension, chan->lChannel, UNIATA_SATA_IGNORE_CONNECT, 1)) { + OurInterrupt = 2; + } + } + } + } + break; default: if(UniataIsSATARangeAvailable(deviceExtension, lChannel)) { if(ChipFlags & UNIATA_AHCI) { // Do nothing here } else if(ChipFlags & UNIATA_SATA) { - if(UniataSataClearErr(HwDeviceExtension, c, UNIATA_SATA_DO_CONNECT)) { + if(UniataSataClearErr(HwDeviceExtension, c, UNIATA_SATA_DO_CONNECT, 0)) { OurInterrupt = 2; } } @@ -3882,7 +3933,7 @@ skip_dma_stat_check: KdPrint2((PRINT_PREFIX " base status %#x\n", statusByte)); if (statusByte == 0xff) { // interrupt from empty controller ? - } else + } else if(!(statusByte & (IDE_STATUS_DRQ | IDE_STATUS_DRDY))) { KdPrint2((PRINT_PREFIX " no DRQ/DRDY set\n")); return OurInterrupt; @@ -4545,12 +4596,9 @@ IntrPrepareResetController: // IDE path. Check if words left is at least DEV_BSIZE/2 = 256. if (AtaReq->WordsLeft < wordsThisInterrupt) { - // Transfer only words requested. wordCount = AtaReq->WordsLeft; - } else { - // Transfer next block. wordCount = wordsThisInterrupt; } @@ -4637,12 +4685,9 @@ IntrPrepareResetController: // Check if words left is at least 256. if (AtaReq->WordsLeft < wordsThisInterrupt) { - // Transfer only words requested. wordCount = AtaReq->WordsLeft; - } else { - // Transfer next block. wordCount = wordsThisInterrupt; } @@ -8388,7 +8433,6 @@ DriverEntry( } while(t0.QuadPart == t1.QuadPart); g_PerfDt = (ULONG)((t1.QuadPart - t0.QuadPart)/10); KdPrint(("Performance calibration: dt=%d, counter=%I64d\n", g_PerfDt, g_Perf )); - } else { KdPrint(("UniATA Init: ReEnter\n")); ReEnter = TRUE; @@ -8544,7 +8588,7 @@ DriverEntry( Argument2, &hwInitializationData.comm, (PVOID)(i | (alt ? 0x80000000 : 0))); - KdPrint2((PRINT_PREFIX "Status %#x\n", newStatus)); + KdPrint2((PRINT_PREFIX "ScsiPortInitialize Status %#x\n", newStatus)); if (newStatus < statusToReturn) { statusToReturn = newStatus; } @@ -8592,7 +8636,7 @@ DriverEntry( Argument2, &hwInitializationData.comm, (PVOID)i); - KdPrint2((PRINT_PREFIX "Status %#x\n", newStatus)); + KdPrint2((PRINT_PREFIX "ScsiPortInitialize Status %#x\n", newStatus)); } #endif //0 if(g_opt_Verbose) { @@ -8646,6 +8690,7 @@ DriverEntry( Argument2, &hwInitializationData.comm, (PVOID)i); + KdPrint2((PRINT_PREFIX "ScsiPortInitialize Status %#x\n", newStatus)); if (newStatus < statusToReturn) statusToReturn = newStatus; @@ -8689,6 +8734,7 @@ DriverEntry( Argument2, &hwInitializationData.comm, &adapterCount); + KdPrint2((PRINT_PREFIX "ScsiPortInitialize Status %#x\n", newStatus)); if (newStatus < statusToReturn) statusToReturn = newStatus; } @@ -8702,12 +8748,13 @@ DriverEntry( Argument2, &hwInitializationData.comm, &adapterCount); + KdPrint2((PRINT_PREFIX "ScsiPortInitialize Status %#x\n", newStatus)); if (newStatus < statusToReturn) statusToReturn = newStatus; } InDriverEntry = FALSE; - KdPrint2((PRINT_PREFIX "\n\nLeave ATAPI IDE MiniPort DriverEntry with status %#x\n", statusToReturn)); + KdPrint2((PRINT_PREFIX "\n\nLeave UNIATA MiniPort DriverEntry with status %#x\n", statusToReturn)); return statusToReturn; @@ -9181,4 +9228,3 @@ _PrintNtConsole( } // end PrintNtConsole() - diff --git a/reactos/drivers/storage/ide/uniata/id_dma.cpp b/reactos/drivers/storage/ide/uniata/id_dma.cpp index d52fef2edc6..64d8d0be71e 100644 --- a/reactos/drivers/storage/ide/uniata/id_dma.cpp +++ b/reactos/drivers/storage/ide/uniata/id_dma.cpp @@ -1,6 +1,6 @@ /*++ -Copyright (c) 2002-2008 Alexander A. Telyatnikov (Alter) +Copyright (c) 2002-2010 Alexander A. Telyatnikov (Alter) Module Name: id_dma.cpp @@ -182,7 +182,7 @@ err_1: } } } -#endif //USE_OWN_DMA + if(deviceExtension->HwFlags & UNIATA_AHCI) { if(chan->AHCI_CL) { @@ -206,7 +206,7 @@ err_1: } } } - + #endif //USE_OWN_DMA return; } // end AtapiDmaAlloc() @@ -289,7 +289,7 @@ retry_DB_IO: if(!dma_count || ((LONG)(dma_base) == -1)) { KdPrint2((PRINT_PREFIX "AtapiDmaSetup: No 1st block\n" )); //AtaReq->dma_base = NULL; - AtaReq->ahci_base64 = 0; + AtaReq->ahci_base64 = NULL; return FALSE; } @@ -311,7 +311,7 @@ retry_DB_IO: if (i >= max_entries) { KdPrint2((PRINT_PREFIX "too many segments in DMA table\n" )); //AtaReq->dma_base = NULL; - AtaReq->ahci_base64 = 0; + AtaReq->ahci_base64 = NULL; return FALSE; } KdPrint2((PRINT_PREFIX " get Phys(data[n]=%x)\n", data )); @@ -1028,6 +1028,13 @@ set_new_acard: /********************/ /* AMD, nVidia, VIA */ /********************/ + if((VendorID == ATA_VIA_ID) && + (ChipFlags & VIASATA) && + (Channel == 0)) { + AtaSetTransferMode(deviceExtension, DeviceNumber, lChannel, LunExt, ATA_SA150); + return; + } + static const UCHAR via_modes[5][7] = { { 0xc2, 0xc1, 0xc0, 0x00, 0x00, 0x00, 0x00 }, /* ATA33 and New Chips */ { 0xee, 0xec, 0xea, 0xe9, 0xe8, 0x00, 0x00 }, /* ATA66 */ @@ -1052,11 +1059,14 @@ set_new_acard: return; } } - for(i = wdmamode; i>=0; i--) { - SetPciConfig1(reg-0x08, via_pio[5+i]); - if(AtaSetTransferMode(deviceExtension, DeviceNumber, lChannel, LunExt, ATA_WDMA0 + i)) { - SetPciConfig1(reg, 0x8b); - return; + if(!(ChipFlags & VIABAR)) { + /* This chip can't do WDMA. */ + for(i = wdmamode; i>=0; i--) { + SetPciConfig1(reg-0x08, via_pio[5+i]); + if(AtaSetTransferMode(deviceExtension, DeviceNumber, lChannel, LunExt, ATA_WDMA0 + i)) { + SetPciConfig1(reg, 0x8b); + return; + } } } /* set PIO mode timings */ @@ -1247,6 +1257,48 @@ set_new_acard: break; } + if(deviceExtension->DevID == ATA_ISCH) { + ULONG tim; + GetPciConfig4(0x80 + dev*4, tim); + + for(i=udmamode; i>=0; i--) { + if(AtaSetTransferMode(deviceExtension, DeviceNumber, lChannel, LunExt, ATA_UDMA0 + i)) { + tim |= (0x1 << 31); + tim &= ~(0x7 << 16); + tim |= (i << 16); + + idx = i+8; + udma_ok = TRUE; + apiomode = ATA_PIO4; + break; + } + } + if(!udma_ok) { + for(i=wdmamode; i>=0; i--) { + if(AtaSetTransferMode(deviceExtension, DeviceNumber, lChannel, LunExt, ATA_WDMA0 + i)) { + tim &= ~(0x1 << 31); + tim &= ~(0x3 << 8); + tim |= (i << 8); + + idx = i+5; + udma_ok = TRUE; + apiomode = (i == 0) ? ATA_PIO0 : + (i == 1) ? ATA_PIO3 : ATA_PIO4; + break; + } + } + } + if(!udma_ok) { + AtaSetTransferMode(deviceExtension, DeviceNumber, lChannel, LunExt, ATA_PIO0 + apiomode); + idx = apiomode; + } + tim &= ~(0x7); + tim |= (apiomode & 0x7); + SetPciConfig4(0x80 + dev*4, tim); + + break; + } + GetPciConfig2(0x48, reg48); if(!(ChipFlags & ICH4_FIX)) { GetPciConfig2(0x4a, reg4a); @@ -1751,6 +1803,94 @@ setup_drive_ite: SetPciConfig1(0x54 + offset, chtiming[apiomode]); } return; + } else + if(ChipType == ITE_133_NEW) { + //static const USHORT reg54_timings[] = { 0x0000, 0x0000, 0x0001, 0x0001, 0x0001, 0x1001, 0x1001 }; + static const UCHAR udmatiming[] = + { 0x00, 0x01, 0x10, 0x01, 0x10, 0x01, 0x10 }; + static const UCHAR timings[] = + { 0x00, 0x00, 0x10, 0x21, 0x23, 0x10, 0x21, 0x23, + 0x23, 0x23, 0x23, 0x23, 0x23, 0x02, 0x02 }; + BOOLEAN udma_ok = FALSE; + BOOLEAN ok = FALSE; + UCHAR timing = 0; + + WCHAR reg40; + UCHAR reg44; + USHORT reg4a; + USHORT reg54; + USHORT mask40=0, new40=0; + UCHAR mask44=0, new44=0; + + GetPciConfig2(0x40, reg40); + GetPciConfig1(0x44, reg44); + GetPciConfig2(0x4a, reg4a); + GetPciConfig2(0x54, reg54); + + if(!(reg54 & (0x10 << dev))) { + // 80-pin check + udmamode = min(udmamode, 2); + } + + for(i=udmamode; i>=0; i--) { + if(AtaSetTransferMode(deviceExtension, DeviceNumber, lChannel, LunExt, ATA_UDMA0 + i)) { + ChangePciConfig1(0x48, a | (1 << dev) ); + ChangePciConfig2(0x4a, + (a & ~(0x3 << (dev*4))) | + (udmatiming[i] << (dev*4)) ); + ok=TRUE; + udma_ok=TRUE; + timing = timings[i+8]; + break; + } + } + + for(i=wdmamode; !ok && i>=0; i--) { + if(AtaSetTransferMode(deviceExtension, DeviceNumber, lChannel, LunExt, ATA_WDMA0 + i)) { + + ok=TRUE; + timing = timings[i+5]; + break; + } + } + + if(!ok) { + AtaSetTransferMode(deviceExtension, DeviceNumber, lChannel, LunExt, ATA_PIO0 + apiomode); + timing = timings[apiomode]; + } + + if(!udma_ok) { + ChangePciConfig1(0x48, a & ~(1 << dev) ); + ChangePciConfig2(0x4a, a & ~(0x3 << (dev << 2)) ); + } + if (udma_ok && udmamode >= ATA_UDMA2) { + reg54 |= (0x1 << dev); + } else { + reg54 &= ~(0x1 << dev); + } + if (udma_ok && udmamode >= ATA_UDMA5) { + reg54 |= (0x1000 << dev); + } else { + reg54 &= ~(0x1000 << dev); + } + SetPciConfig2(0x54, reg54 ); + + reg40 &= 0xff00; + reg40 |= 0x4033; + + if(!(ldev & 1)) { + reg40 |= (ATAPI_DEVICE(deviceExtension, ldev) ? 0x04 : 0x00); + mask40 = 0x3300; + new40 = timing << 8; + } else { + reg40 |= (ATAPI_DEVICE(deviceExtension, ldev) ? 0x40 : 0x00); + mask44 = 0x0f; + new44 = ((timing & 0x30) >> 2) | + (timing & 0x03); + } + SetPciConfig2(0x40, (reg40 & ~mask40) | new40); + SetPciConfig1(0x44, (reg44 & ~mask44) | new44); + return; } return; @@ -2092,7 +2232,8 @@ via82c_timing( } // Newer chips dislike this: - if(!(deviceExtension->HwFlags & VIAAST)) { + if(/*!(deviceExtension->HwFlags & VIAAST)*/ + deviceExtension->MaxTransferMode < ATA_UDMA6) { /* PIO address setup */ GetPciConfig1(0x4c, t); t = (t & ~(3 << ((3 - dev) << 1))) | (FIT(setup - 1, 0, 3) << ((3 - dev) << 1)); diff --git a/reactos/drivers/storage/ide/uniata/id_init.cpp b/reactos/drivers/storage/ide/uniata/id_init.cpp index a426991537f..6dce17cfdb5 100644 --- a/reactos/drivers/storage/ide/uniata/id_init.cpp +++ b/reactos/drivers/storage/ide/uniata/id_init.cpp @@ -1,6 +1,6 @@ /*++ -Copyright (c) 2004-2008 Alexandr A. Telyatnikov (Alter) +Copyright (c) 2004-2010 Alexandr A. Telyatnikov (Alter) Module Name: id_init.cpp @@ -62,6 +62,12 @@ UniataChipDetectChannels( ULONG ChipFlags= deviceExtension->HwFlags & CHIPFLAG_MASK; KdPrint2((PRINT_PREFIX "UniataChipDetectChannels:\n" )); + + if(deviceExtension->MasterDev) { + KdPrint2((PRINT_PREFIX "MasterDev -> 1 chan\n")); + deviceExtension->NumberChannels = 1; + } + switch(VendorID) { case ATA_ACER_LABS_ID: switch(deviceExtension->DevID) { @@ -96,8 +102,8 @@ UniataChipDetectChannels( case ATA_ATI_ID: KdPrint2((PRINT_PREFIX "ATI\n")); switch(deviceExtension->DevID) { - case ATA_ATI_IXP600: - case ATA_ATI_IXP700: + case 0x438c1002: + case 0x439c1002: /* IXP600 & IXP700 only have 1 PATA channel */ if(BMList[deviceExtension->DevIndex].channel) { KdPrint2((PRINT_PREFIX "New ATI no 2nd PATA chan\n")); @@ -129,18 +135,57 @@ UniataChipDetectChannels( } break; case ATA_VIA_ID: - if((deviceExtension->DevID == 0x32491106) && - ScsiPortConvertPhysicalAddressToUlong((*ConfigInfo->AccessRanges)[5].RangeStart)) { + if(/*(deviceExtension->DevID == 0x32491106) && + ScsiPortConvertPhysicalAddressToUlong((*ConfigInfo->AccessRanges)[5].RangeStart)*/ + deviceExtension->HwFlags & VIABAR) { deviceExtension->NumberChannels = 3; KdPrint2((PRINT_PREFIX "VIA 3 chan\n")); } break; + case ATA_ITE_ID: + /* ITE ATA133 controller */ + if(deviceExtension->DevID == 0x82131283) { + if(BMList[deviceExtension->DevIndex].channel) { + KdPrint2((PRINT_PREFIX "New ITE has no 2nd PATA chan\n")); + return FALSE; + } + deviceExtension->NumberChannels = 1; + KdPrint2((PRINT_PREFIX "New ITE PATA 1 chan\n")); + } + break; + case ATA_INTEL_ID: + /* New Intel PATA controllers */ + if(/*deviceExtension->DevID == 0x27df8086 || + deviceExtension->DevID == 0x269e8086 || + deviceExtension->DevID == ATA_I82801HBM*/ + ChipFlags & I1CH) { + if(BMList[deviceExtension->DevIndex].channel) { + KdPrint2((PRINT_PREFIX "New Intel PATA has no 2nd chan\n")); + return FALSE; + } + deviceExtension->NumberChannels = 1; + KdPrint2((PRINT_PREFIX "New Intel PATA 1 chan\n")); + } + break; + case ATA_JMICRON_ID: + /* New JMicron PATA controllers */ + if(deviceExtension->DevID == ATA_JMB361 || + deviceExtension->DevID == ATA_JMB363 || + deviceExtension->DevID == ATA_JMB368) { + if(BMList[deviceExtension->DevIndex].channel) { + KdPrint2((PRINT_PREFIX "New JMicron has no 2nd chan\n")); + return FALSE; + } + deviceExtension->NumberChannels = 1; + KdPrint2((PRINT_PREFIX "New JMicron PATA 1 chan\n")); + } + break; } // end switch(VendorID) return TRUE; } // end UniataChipDetectChannels() -BOOLEAN +NTSTATUS NTAPI UniataChipDetect( IN PVOID HwDeviceExtension, @@ -189,18 +234,19 @@ UniataChipDetect( if(i != BMLIST_TERMINATOR) { DevTypeInfo = (PBUSMASTER_CONTROLLER_INFORMATION)&BusMasterAdapters[i]; } else { +unknown_dev: KdPrint2((PRINT_PREFIX " unknown dev, BM addr %#x", BaseIoAddressBM)); DevTypeInfo = NULL; KdPrint2((PRINT_PREFIX " MaxTransferMode %#x\n", deviceExtension->MaxTransferMode)); if(!UniataChipDetectChannels(HwDeviceExtension, pciData, DeviceNumber, ConfigInfo)) { - return FALSE; + return STATUS_UNSUCCESSFUL; } if(!UniataAllocateLunExt(deviceExtension, UNIATA_ALLOCATE_NEW_LUNS)) { - return FALSE; + return STATUS_UNSUCCESSFUL; } - return FALSE; + return STATUS_NOT_FOUND; } static BUSMASTER_CONTROLLER_INFORMATION const SiSAdapters[] = { @@ -254,11 +300,18 @@ UniataChipDetect( PCI_DEV_HW_SPEC_BM( 8231, 1106, 0x00, ATA_UDMA5, "VIA 8231" , VIA100 | VIABUG ), PCI_DEV_HW_SPEC_BM( 3074, 1106, 0x00, ATA_UDMA5, "VIA 8233" , VIA100 | 0x00 ), PCI_DEV_HW_SPEC_BM( 3109, 1106, 0x00, ATA_UDMA5, "VIA 8233C" , VIA100 | 0x00 ), - PCI_DEV_HW_SPEC_BM( 3147, 1106, 0x00, ATA_UDMA6, "VIA 8233A" , VIA133 | VIAAST ), - PCI_DEV_HW_SPEC_BM( 3177, 1106, 0x00, ATA_UDMA6, "VIA 8235" , VIA133 | VIAAST ), - PCI_DEV_HW_SPEC_BM( 3227, 1106, 0x00, ATA_UDMA6, "VIA 8237" , VIA133 | VIAAST ), - PCI_DEV_HW_SPEC_BM( 0591, 1106, 0x00, ATA_UDMA6, "VIA 8237A" , VIA133 | VIAAST ), - PCI_DEV_HW_SPEC_BM( 3349, 1106, 0x00, ATA_UDMA6, "VIA 8251" , VIA133 | VIAAST ), + PCI_DEV_HW_SPEC_BM( 3147, 1106, 0x00, ATA_UDMA6, "VIA 8233A" , VIA133 | 0x00 ), + PCI_DEV_HW_SPEC_BM( 3177, 1106, 0x00, ATA_UDMA6, "VIA 8235" , VIA133 | 0x00 ), + PCI_DEV_HW_SPEC_BM( 3227, 1106, 0x00, ATA_UDMA6, "VIA 8237" , VIA133 | 0x00 ), + PCI_DEV_HW_SPEC_BM( 0591, 1106, 0x00, ATA_UDMA6, "VIA 8237A" , VIA133 | 0x00 ), + // presence of AHCI controller means something about isa-mapped part + PCI_DEV_HW_SPEC_BM( 5337, 1106, 0x00, ATA_UDMA6, "VIA 8237S" , VIA133 | 0x00 ), + PCI_DEV_HW_SPEC_BM( 5372, 1106, 0x00, ATA_UDMA6, "VIA 8237" , VIA133 | 0x00 ), + PCI_DEV_HW_SPEC_BM( 7372, 1106, 0x00, ATA_UDMA6, "VIA 8237" , VIA133 | 0x00 ), + PCI_DEV_HW_SPEC_BM( 3349, 1106, 0x00, ATA_UDMA6, "VIA 8251" , VIA133 | 0x00 ), + PCI_DEV_HW_SPEC_BM( 8324, 1106, 0x00, ATA_SA150, "VIA CX700" , VIA133 | VIASATA), + PCI_DEV_HW_SPEC_BM( 8353, 1106, 0x00, ATA_SA150, "VIA VX800" , VIA133 | VIASATA), + PCI_DEV_HW_SPEC_BM( 8409, 1106, 0x00, ATA_UDMA6, "VIA VX855" , VIA133 | 0x00 ), PCI_DEV_HW_SPEC_BM( ffff, ffff, 0xff, BMLIST_TERMINATOR , NULL , BMLIST_TERMINATOR ) }; @@ -286,20 +339,30 @@ UniataChipDetect( case ATA_VIA_ID: KdPrint2((PRINT_PREFIX "ATA_VIA_ID\n")); // New chips have own DeviceId - if(deviceExtension->DevID != ATA_VIA82C571) + if(deviceExtension->DevID != ATA_VIA82C571 && + deviceExtension->DevID != ATA_VIACX700IDE && + deviceExtension->DevID != ATA_VIASATAIDE) { + KdPrint2((PRINT_PREFIX "Via new\n")); break; - // Old chips have same DeviceId, we can distinguish between them - // only by SouthBridge DeviceId + } + KdPrint2((PRINT_PREFIX "Via-old-style %x\n", deviceExtension->DevID)); + // Traditionally, chips have same DeviceId, we can distinguish between them + // only by ISA Bridge DeviceId DevTypeInfo = (BUSMASTER_CONTROLLER_INFORMATION*)&ViaSouthAdapters[0]; - i = AtapiFindListedDev(DevTypeInfo, -1, HwDeviceExtension, SystemIoBusNumber, slotNumber, NULL); + i = AtapiFindListedDev(DevTypeInfo, -1, HwDeviceExtension, SystemIoBusNumber, + PCISLOTNUM_NOT_SPECIFIED/*slotNumber*/, NULL); +/* if(i == BMLIST_TERMINATOR) { + i = AtapiFindListedDev(DevTypeInfo, -1, HwDeviceExtension, SystemIoBusNumber, PCISLOTNUM_NOT_SPECIFIED, NULL); + }*/ if(i != BMLIST_TERMINATOR) { KdPrint2((PRINT_PREFIX "VIASOUTH\n")); deviceExtension->HwFlags |= VIASOUTH; } DevTypeInfo = (BUSMASTER_CONTROLLER_INFORMATION*)&ViaAdapters[0]; - i = AtapiFindListedDev(DevTypeInfo, -1, HwDeviceExtension, SystemIoBusNumber, slotNumber, NULL); + i = AtapiFindListedDev(DevTypeInfo, -1, HwDeviceExtension, SystemIoBusNumber, + PCISLOTNUM_NOT_SPECIFIED/*slotNumber*/, NULL); if(i != BMLIST_TERMINATOR) { - deviceExtension->FullDevName = SiSAdapters[i].FullDevName; + deviceExtension->FullDevName = ViaAdapters[i].FullDevName; } goto for_ugly_chips; @@ -351,13 +414,13 @@ UniataChipDetect( case 0x81721283: /* IT8172 IDE controller */ deviceExtension->MaxTransferMode = ATA_UDMA2; - *simplexOnly = TRUE; + *simplexOnly = TRUE; break; default: - return FALSE; + return STATUS_NOT_FOUND; } - return TRUE; + return STATUS_SUCCESS; #endif } @@ -365,7 +428,8 @@ UniataChipDetect( for_ugly_chips: KdPrint2((PRINT_PREFIX "i: %#x\n", i)); if(i == BMLIST_TERMINATOR) { - return FALSE; + goto unknown_dev; + //return STATUS_NOT_FOUND; } deviceExtension->MaxTransferMode = DevTypeInfo[i].MaxTransferMode; deviceExtension->HwFlags |= DevTypeInfo[i].RaidFlags; @@ -404,10 +468,10 @@ for_ugly_chips: ChipFlags = deviceExtension->HwFlags & CHIPFLAG_MASK; if(!UniataChipDetectChannels(HwDeviceExtension, pciData, DeviceNumber, ConfigInfo)) { - return FALSE; + return STATUS_UNSUCCESSFUL; } if(!UniataAllocateLunExt(deviceExtension, UNIATA_ALLOCATE_NEW_LUNS)) { - return FALSE; + return STATUS_UNSUCCESSFUL; } switch(VendorID) { @@ -733,6 +797,12 @@ for_ugly_chips: case ATA_VIA_ID: { + if(ChipFlags & VIASATA) { + /* 2 SATA without SATA registers on first channel + 1 PATA on second */ + // do nothing, generic PATA INIT + KdPrint2((PRINT_PREFIX "VIA SATA without SATA regs\n")); + break; + } if(ChipFlags & UNIATA_SATA) { ULONG IoSize = 0; @@ -752,7 +822,7 @@ for_ugly_chips: KdPrint2((PRINT_PREFIX "IoSize %x\n", IoSize)); /*deviceExtension->*/BaseMemAddress = AtapiGetIoRange(HwDeviceExtension, ConfigInfo, pciData, SystemIoBusNumber, 5, 0, IoSize * deviceExtension->NumberChannels); - if((*ConfigInfo->AccessRanges)[5].RangeInMemory) { + if(BaseMemAddress && (*ConfigInfo->AccessRanges)[5].RangeInMemory) { KdPrint2((PRINT_PREFIX "MemIo\n")); MemIo = TRUE; } @@ -775,36 +845,46 @@ for_ugly_chips: chan = &deviceExtension->chan[c]; - BaseIo = AtapiGetIoRange(HwDeviceExtension, ConfigInfo, pciData, SystemIoBusNumber, c, 0, 0x80); + BaseIo = AtapiGetIoRange(HwDeviceExtension, ConfigInfo, pciData, SystemIoBusNumber, c, 0, /*0x80*/ sizeof(IDE_REGISTERS_1) + sizeof(IDE_REGISTERS_2)*2); for (i=0; i<=IDX_IO1_SZ; i++) { chan->RegTranslation[IDX_IO1+i].Addr = BaseIo + i; } - chan->RegTranslation[IDX_IO2_AltStatus].Addr = BaseIo + sizeof(IDE_REGISTERS_1) + 2 + FIELD_OFFSET(IDE_REGISTERS_2, AltStatus ); + chan->RegTranslation[IDX_IO2_AltStatus].Addr = BaseIo + sizeof(IDE_REGISTERS_1) + 2; UniataInitSyncBaseIO(chan); for (i=0; i<=IDX_BM_IO_SZ; i++) { chan->RegTranslation[IDX_BM_IO+i].Addr = BaseIoAddressBM_0 + sizeof(IDE_BUSMASTER_REGISTERS)*c + i; } - if(c < 2) { - // Do not setup SATA registers for PATA part - chan->RegTranslation[IDX_SATA_SStatus].Addr = BaseMemAddress + (c * IoSize); - chan->RegTranslation[IDX_SATA_SStatus].MemIo = MemIo; - chan->RegTranslation[IDX_SATA_SError].Addr = BaseMemAddress + 4 + (c * IoSize); - chan->RegTranslation[IDX_SATA_SError].MemIo = MemIo; - chan->RegTranslation[IDX_SATA_SControl].Addr = BaseMemAddress + 8 + (c * IoSize); - chan->RegTranslation[IDX_SATA_SControl].MemIo = MemIo; - - chan->ChannelCtrlFlags |= CTRFLAGS_NO_SLAVE; - } } } + for(c=0; cNumberChannels; c++) { + chan = &deviceExtension->chan[c]; + if((ChipFlags & VIABAR) && (c==2)) { + // Do not setup SATA registers for PATA part + for (i=0; i<=IDX_SATA_IO_SZ; i++) { + chan->RegTranslation[IDX_SATA_IO+i].Addr = 0; + chan->RegTranslation[IDX_SATA_IO+i].MemIo = 0; + } + break; + } + chan->RegTranslation[IDX_SATA_SStatus].Addr = BaseMemAddress + (c * IoSize); + chan->RegTranslation[IDX_SATA_SStatus].MemIo = MemIo; + chan->RegTranslation[IDX_SATA_SError].Addr = BaseMemAddress + 4 + (c * IoSize); + chan->RegTranslation[IDX_SATA_SError].MemIo = MemIo; + chan->RegTranslation[IDX_SATA_SControl].Addr = BaseMemAddress + 8 + (c * IoSize); + chan->RegTranslation[IDX_SATA_SControl].MemIo = MemIo; + + chan->ChannelCtrlFlags |= CTRFLAGS_NO_SLAVE; + } + } } break; } case ATA_INTEL_ID: { + BOOLEAN IsPata; if(!(ChipFlags & UNIATA_SATA)) { break; } @@ -870,45 +950,144 @@ for_ugly_chips: break; } - /* SATA parts can be either compat or AHCI */ - if(ChipFlags & UNIATA_AHCI) { - + if(deviceExtension->MaxTransferMode >= ATA_SA150) { GetPciConfig1(0x90, tmp8); - if(tmp8 & 0xc0) { - KdPrint2((PRINT_PREFIX "AHCI not supported yet\n")); - return FALSE; + /* SATA parts can be either compat or AHCI */ + if(ChipFlags & UNIATA_AHCI) { + + if(tmp8 & 0xc0) { + //KdPrint2((PRINT_PREFIX "AHCI not supported yet\n")); + //return FALSE; + KdPrint2((PRINT_PREFIX "try run AHCI\n")); + break; + } + KdPrint2((PRINT_PREFIX "Compatible mode\n")); } deviceExtension->HwFlags &= ~UNIATA_AHCI; - } -#if 0 - if(ChipFlags & UNIATA_SATA) { - //BaseMemAddress = AtapiGetIoRange(HwDeviceExtension, ConfigInfo, pciData, SystemIoBusNumber, - // 0, 0, 0x0c00); - BaseMemAddress = NULL; // HACK-HACK - if(!BaseMemAddress) { - KdPrint2((PRINT_PREFIX "Intel: no SATA I/O space, operate in PATA Compatible mode\n")); - deviceExtension->HwFlags &= ~UNIATA_SATA; - break; - } - if((*ConfigInfo->AccessRanges)[0].RangeInMemory) { + + /* if BAR(5) is IO it should point to SATA interface registers */ + BaseMemAddress = AtapiGetIoRange(HwDeviceExtension, ConfigInfo, pciData, SystemIoBusNumber, + 5, 0, 0x10); + if(BaseMemAddress && (*ConfigInfo->AccessRanges)[5].RangeInMemory) { KdPrint2((PRINT_PREFIX "MemIo\n")); MemIo = TRUE; } deviceExtension->BaseIoAddressSATA_0.Addr = BaseMemAddress; deviceExtension->BaseIoAddressSATA_0.MemIo = MemIo; - } -#endif + + for(c=0; cNumberChannels; c++) { + chan = &deviceExtension->chan[c]; + IsPata = FALSE; + if(ChipFlags & ICH5) { + if ((tmp8 & 0x04) == 0) { + //ch->flags |= ATA_SATA; + //ch->flags |= ATA_NO_SLAVE; + //smap[0] = (map & 0x01) ^ ch->unit; + //smap[1] = 0; + chan->ChannelCtrlFlags |= CTRFLAGS_NO_SLAVE; + chan->lun[0]->SATA_lun_map = (tmp8 & 0x01) ^ c; + chan->lun[1]->SATA_lun_map = 0; + } else if ((tmp8 & 0x02) == 0) { + //ch->flags |= ATA_SATA; + //smap[0] = (map & 0x01) ? 1 : 0; + //smap[1] = (map & 0x01) ? 0 : 1; + if(c == 0) { + chan->lun[0]->SATA_lun_map = (tmp8 & 0x01) ? 1 : 0; + chan->lun[1]->SATA_lun_map = (tmp8 & 0x01) ? 0 : 1; + } else { + IsPata = TRUE; + //chan->ChannelCtrlFlags |= CTRFLAGS_PATA; + } + } else if ((tmp8 & 0x02) != 0) { + //ch->flags |= ATA_SATA; + //smap[0] = (map & 0x01) ? 1 : 0; + //smap[1] = (map & 0x01) ? 0 : 1; + if(c == 1) { + chan->lun[0]->SATA_lun_map = (tmp8 & 0x01) ? 1 : 0; + chan->lun[1]->SATA_lun_map = (tmp8 & 0x01) ? 0 : 1; + } else { + IsPata = TRUE; + //chan->ChannelCtrlFlags |= CTRFLAGS_PATA; + } + } + } else + if(ChipFlags & I6CH2) { + chan->ChannelCtrlFlags |= CTRFLAGS_NO_SLAVE; + chan->lun[0]->SATA_lun_map = c ? 4 : 5; + chan->lun[1]->SATA_lun_map = 0; + } else { + switch(tmp8 & 0x03) { + case 0: + chan->lun[0]->SATA_lun_map = 0+c; + chan->lun[1]->SATA_lun_map = 2+c; + break; + case 2: + if(c==0) { + chan->lun[0]->SATA_lun_map = 0; + chan->lun[1]->SATA_lun_map = 2; + } else { + // PATA + IsPata = TRUE; + } + break; + case 1: + if(c==1) { + chan->lun[0]->SATA_lun_map = 1; + chan->lun[1]->SATA_lun_map = 3; + } else { + // PATA + IsPata = TRUE; + } + break; + } + } + + if(IsPata) { + chan->MaxTransferMode = min(deviceExtension->MaxTransferMode, ATA_UDMA5); + } else { + + if((ChipFlags & ICH5) && BaseMemAddress) { + chan->RegTranslation[IDX_INDEXED_ADDR].Addr = BaseMemAddress + 0; + chan->RegTranslation[IDX_INDEXED_ADDR].MemIo = MemIo; + chan->RegTranslation[IDX_INDEXED_DATA].Addr = BaseMemAddress + 4; + chan->RegTranslation[IDX_INDEXED_DATA].MemIo = MemIo; + } + if((ChipFlags & ICH5) || BaseMemAddress) { + + // Rather interesting way of register access... + ChipType = INTEL_IDX; + deviceExtension->HwFlags &= ~CHIPTYPE_MASK; + deviceExtension->HwFlags |= ChipType; + + chan->RegTranslation[IDX_SATA_SStatus].Addr = 0x200*c + 0; + chan->RegTranslation[IDX_SATA_SStatus].Proc = 1; + chan->RegTranslation[IDX_SATA_SError].Addr = 0x200*c + 2; + chan->RegTranslation[IDX_SATA_SError].Proc = 1; + chan->RegTranslation[IDX_SATA_SControl].Addr = 0x200*c + 1; + chan->RegTranslation[IDX_SATA_SControl].Proc = 1; + } + } + + } // end for() + + // rest of INIT staff is in AtapiChipInit() + + } // ATA_SA150 break; } - case 0x1078: + case ATA_CYRIX_ID: /* Cyrix 5530 ATA33 controller */ - if(deviceExtension->DevID == 0x01021078) { + if(deviceExtension->DevID == 0x01021078) { ConfigInfo->AlignmentMask = 0x0f; deviceExtension->MaximumDmaTransferLength = 63*1024; } break; } - return TRUE; + if(ChipFlags & UNIATA_AHCI) { + return UniataAhciInit(HwDeviceExtension) ? STATUS_SUCCESS : STATUS_UNSUCCESSFUL; + } + + return STATUS_SUCCESS; } // end UniataChipDetect() @@ -1023,7 +1202,7 @@ AtapiRosbSouthBridgeFixup( DeviceID = pciData.DeviceID; dev_id = (VendorID | (DeviceID << 16)); - if (dev_id == ATA_ROSB4_ISA) { /* VIA VT8361 */ + if (dev_id == ATA_ROSB4_ISA) { /* */ ChangePciConfig4(0x64, ((a & ~0x00002000) | 0x00004000)); break; } @@ -1404,11 +1583,13 @@ AtapiChipInit( if(c == CHAN_NOT_SPECIFIED) { /* use device interrupt as byte count end */ ChangePciConfig1(0x4a, (a | 0x20)); - /* enable cable detection and UDMA support on newer chips */ - ChangePciConfig1(0x4b, (a | 0x09)); + /* enable cable detection and UDMA support on newer chips, rev < 0xc7 */ + if(RevID < 0xc7) { + ChangePciConfig1(0x4b, (a | 0x09)); + } /* enable ATAPI UDMA mode */ - ChangePciConfig1(0x53, (a | 0x01)); + ChangePciConfig1(0x53, (a | (RevID >= 0xc7 ? 0x03 : 0x01))); } else { // check 80-pin cable @@ -1476,32 +1657,26 @@ AtapiChipInit( case ATA_INTEL_ID: { USHORT reg54; if(ChipFlags & UNIATA_SATA) { - if(c != CHAN_NOT_SPECIFIED) - break; -#if 0 - /* force all ports active "the legacy way" */ - ChangePciConfig2(0x92, (a | 0x0f)); - /* enable PCI interrupt */ - ChangePciConfig2(/*PCIR_COMMAND*/0x04, (a & ~0x0400)); - if(!(ChipFlags & UNIATA_AHCI)) { - /* ICH5 in compat mode has SATA ports as master/slave on 1 channel */ - GetPciConfig1(0x90, tmp8); - if(!(tmp8 & 0x04)) { - /* XXX SOS should be in intel_allocate if we grow it */ - if(c == CHAN_NOT_SPECIFIED) { - for(c=0; cNumberChannels; c++) { - deviceExtension->chan[c].ChannelCtrlFlags |= CTRFLAGS_NO_SLAVE; + if(ChipFlags & UNIATA_AHCI) + break; + if(c == CHAN_NOT_SPECIFIED) { + /* force all ports active "the legacy way" */ + ChangePciConfig2(0x92, (a | 0x0f)); + /* enable PCI interrupt */ + ChangePciConfig2(/*PCIR_COMMAND*/0x04, (a & ~0x0400)); + } else { + if(ChipType == INTEL_IDX) { + for(c=0; cNumberChannels; c++) { + chan = &deviceExtension->chan[c]; + UniataSataWritePort4(chan, IDX_SATA_SError, 0xffffffff, 0); + if(!(chan->ChannelCtrlFlags & CTRFLAGS_NO_SLAVE)) { + UniataSataWritePort4(chan, IDX_SATA_SError, 0xffffffff, 1); } - } else { - deviceExtension->chan[c].ChannelCtrlFlags |= CTRFLAGS_NO_SLAVE; } } } -#else - /* enable PCI interrupt */ - ChangePciConfig2(/*PCIR_COMMAND*/0x04, (a & ~0x0400)); -#endif + break; } if(deviceExtension->MaxTransferMode < ATA_UDMA2) @@ -1523,6 +1698,8 @@ AtapiChipInit( ULONG offs = (ChipFlags & NV4OFF) ? 0x0440 : 0x0010; /* enable control access */ ChangePciConfig1(0x50, (a | 0x04)); + /* MCP55 seems to need some time to allow r_res2 read. */ + AtapiStallExecution(10); KdPrint2((PRINT_PREFIX "BaseIoAddressSATA_0=%x\n", deviceExtension->BaseIoAddressSATA_0.Addr)); if(ChipFlags & NVQ) { /* clear interrupt status */ @@ -1803,13 +1980,16 @@ AtapiChipInit( break; case ATA_VIA_ID: +/* if(ChipFlags & (UNIATA_SATA | UNIATA_AHCI | VIASATA) { + break; + }*/ if(c == CHAN_NOT_SPECIFIED) { /* prepare for ATA-66 on the 82C686a and 82C596b */ if(ChipFlags & VIACLK) { ChangePciConfig4(0x50, (a | 0x030b030b)); } // no init for SATA - if(ChipFlags & UNIATA_SATA) { + if(ChipFlags & (UNIATA_SATA | VIASATA)) { /* enable PCI interrupt */ ChangePciConfig2(/*PCIR_COMMAND*/0x04, (a & ~0x0400)); break; @@ -1838,8 +2018,18 @@ AtapiChipInit( SetPciConfig2(0x60, DEV_BSIZE); SetPciConfig2(0x68, DEV_BSIZE); } else { - // check 80-pin cable + chan = &deviceExtension->chan[c]; + // no init for SATA + if(ChipFlags & (UNIATA_SATA | VIASATA)) { + if((ChipFlags & VIABAR) && (c >= 2)) { + break; + } + UniataSataWritePort4(chan, IDX_SATA_SError, 0xffffffff, 0); + break; + } + + // check 80-pin cable if(!via_cable80(deviceExtension, channel)) { chan->MaxTransferMode = min(deviceExtension->MaxTransferMode, ATA_UDMA2); } @@ -1848,25 +2038,28 @@ AtapiChipInit( break; case ATA_ITE_ID: - // Old chip - if(ChipType == ITE_33) + if(ChipType == ITE_33 || ChipType == ITE_133_NEW) { break; - if(c == CHAN_NOT_SPECIFIED) { - /* set PCI mode and 66Mhz reference clock */ - ChangePciConfig1(0x50, a & ~0x83); - - /* set default active & recover timings */ - SetPciConfig1(0x54, 0x31); - SetPciConfig1(0x56, 0x31); - } else { - // check 80-pin cable - GetPciConfig2(0x40, tmp16); - chan = &deviceExtension->chan[c]; - if(!(tmp16 & (channel ? 0x08 : 0x04))) { - chan->MaxTransferMode = min(deviceExtension->MaxTransferMode, ATA_UDMA2); - } } + if(ChipType == ITE_133) { + if(c == CHAN_NOT_SPECIFIED) { + /* set PCI mode and 66Mhz reference clock */ + ChangePciConfig1(0x50, a & ~0x83); + /* set default active & recover timings */ + SetPciConfig1(0x54, 0x31); + SetPciConfig1(0x56, 0x31); + } else { + // check 80-pin cable + GetPciConfig2(0x40, tmp16); + chan = &deviceExtension->chan[c]; + if(!(tmp16 & (channel ? 0x08 : 0x04))) { + chan->MaxTransferMode = min(deviceExtension->MaxTransferMode, ATA_UDMA2); + } + } + } else + if(ChipType == ITE_133_NEW) { + } break; default: if(c != CHAN_NOT_SPECIFIED) { diff --git a/reactos/drivers/storage/ide/uniata/id_probe.cpp b/reactos/drivers/storage/ide/uniata/id_probe.cpp index f254236e05d..2752b2a6747 100644 --- a/reactos/drivers/storage/ide/uniata/id_probe.cpp +++ b/reactos/drivers/storage/ide/uniata/id_probe.cpp @@ -1,6 +1,6 @@ /*++ -Copyright (c) 2002-2008 Alexandr A. Telyatnikov (Alter) +Copyright (c) 2002-2010 Alexandr A. Telyatnikov (Alter) Module Name: id_probe.cpp @@ -628,6 +628,8 @@ AtapiFindListedDev( ULONG i; + KdPrint2((PRINT_PREFIX "AtapiFindListedDev: lim=%x, Bus=%x, Slot=%x\n", lim, BusNumber, SlotNumber)); + // set start/end bus if(BusNumber == PCIBUSNUM_NOT_SPECIFIED) { busNumber = 0; @@ -646,6 +648,8 @@ AtapiFindListedDev( } slotData.u.AsULONG = 0; + KdPrint2((PRINT_PREFIX " scanning range Bus %x-%x, Slot %x-%x\n", busNumber, busNumber2-1, slotNumber, slotNumber2-1)); + for( ; busNumber < busNumber2 ; busNumber++ ) { for( ; slotNumber < slotNumber2 ; slotNumber++) { for(funcNumber=0; funcNumber < PCI_MAX_FUNCTION ; funcNumber++) { @@ -653,9 +657,9 @@ AtapiFindListedDev( slotData.u.bits.DeviceNumber = slotNumber; slotData.u.bits.FunctionNumber = funcNumber; - busDataRead = HalGetBusData( + busDataRead = HalGetBusData( //ScsiPortGetBusData(HwDeviceExtension, - PCIConfiguration, busNumber, slotData.u.AsULONG, + PCIConfiguration, busNumber, slotData.u.AsULONG, &pciData, PCI_COMMON_HDR_LENGTH); // no more buses (this should not happen) if(!busDataRead) { @@ -667,11 +671,19 @@ AtapiFindListedDev( if(busDataRead < (ULONG)PCI_COMMON_HDR_LENGTH) continue; - +/* + KdPrint2((PRINT_PREFIX "AtapiFindListedDev: b:s:f(%x:%x:%x) %4.4x/%4.4x/%2.2x\n", + busNumber, slotNumber, funcNumber, + pciData.VendorID, pciData.DeviceID, pciData.RevisionID)); + */ i = Ata_is_dev_listed(BusMasterAdapters, pciData.VendorID, pciData.DeviceID, pciData.RevisionID, lim); if(i != BMLIST_TERMINATOR) { if(_slotData) *_slotData = slotData; + KdPrint2((PRINT_PREFIX "AtapiFindListedDev: found\n")); + KdPrint2((PRINT_PREFIX "AtapiFindListedDev: b:s:f(%x:%x:%x) %4.4x/%4.4x/%2.2x\n", + busNumber, slotNumber, funcNumber, + pciData.VendorID, pciData.DeviceID, pciData.RevisionID)); return i; } @@ -809,6 +821,8 @@ UniataAllocateLunExt( deviceExtension->chan = (PHW_CHANNEL)ExAllocatePool(NonPagedPool, sizeof(HW_CHANNEL) * (deviceExtension->NumberChannels+1)); if (!deviceExtension->chan) { + ExFreePool(deviceExtension->lun); + deviceExtension->lun = NULL; KdPrint2((PRINT_PREFIX "!deviceExtension->chan => SP_RETURN_ERROR\n")); return FALSE; } @@ -963,7 +977,6 @@ UniataFindBusMasterController( KdPrint2((PRINT_PREFIX "!deviceExtension => SP_RETURN_ERROR\n")); return SP_RETURN_ERROR; } - RtlZeroMemory(deviceExtension, sizeof(HW_DEVICE_EXTENSION)); vendorStrPtr = vendorString; @@ -1044,10 +1057,21 @@ UniataFindBusMasterController( if(MasterDev) { KdPrint2((PRINT_PREFIX "MasterDev (1)\n")); - deviceExtension->NumberChannels = 1; + deviceExtension->MasterDev = TRUE; } - found = UniataChipDetect(HwDeviceExtension, &pciData, i, ConfigInfo, &simplexOnly); + status = UniataChipDetect(HwDeviceExtension, &pciData, i, ConfigInfo, &simplexOnly); + switch(status) { + case STATUS_SUCCESS: + found = TRUE; + break; + case STATUS_NOT_FOUND: + found = FALSE; + break; + default: + KdPrint2((PRINT_PREFIX "FAILED => SP_RETURN_ERROR\n")); + goto exit_error; + } KdPrint2((PRINT_PREFIX "ForceSimplex = %d\n", simplexOnly)); KdPrint2((PRINT_PREFIX "HwFlags = %x\n (0)", deviceExtension->HwFlags)); switch(dev_id) { @@ -1241,7 +1265,7 @@ UniataFindBusMasterController( deviceExtension->UseDpc = FALSE; } - if(simplexOnly && MasterDev /*|| (WinVer_Id() > WinVer_NT)*/) { + if(simplexOnly && MasterDev) { if(deviceExtension->NumberChannels < 2) { KdPrint2((PRINT_PREFIX "set NumberChannels = 2\n")); deviceExtension->NumberChannels = 2; @@ -1764,7 +1788,7 @@ UniataFindFakeBusMasterController( PIDE_BUSMASTER_REGISTERS BaseIoAddressBM_0 = NULL; -// NTSTATUS status; + NTSTATUS status; PPORT_CONFIGURATION_INFORMATION_COMMON _ConfigInfo = (PPORT_CONFIGURATION_INFORMATION_COMMON)ConfigInfo; @@ -1791,7 +1815,6 @@ UniataFindFakeBusMasterController( KdPrint2((PRINT_PREFIX "!deviceExtension => SP_RETURN_ERROR\n")); return SP_RETURN_ERROR; } - RtlZeroMemory(deviceExtension, sizeof(HW_DEVICE_EXTENSION)); vendorStrPtr = vendorString; @@ -1813,7 +1836,7 @@ UniataFindFakeBusMasterController( &pciData, PCI_COMMON_HDR_LENGTH); - if (busDataRead < (ULONG)PCI_COMMON_HDR_LENGTH) { + if (busDataRead < PCI_COMMON_HDR_LENGTH) { KdPrint2((PRINT_PREFIX "busDataRead < PCI_COMMON_HDR_LENGTH => SP_RETURN_ERROR\n")); goto exit_error; } @@ -1877,7 +1900,18 @@ UniataFindFakeBusMasterController( ConfigInfo->AlignmentMask = 0x00000003; - found = UniataChipDetect(HwDeviceExtension, &pciData, i, ConfigInfo, &simplexOnly); + status = UniataChipDetect(HwDeviceExtension, &pciData, i, ConfigInfo, &simplexOnly); + switch(status) { + case STATUS_SUCCESS: + found = TRUE; + break; + case STATUS_NOT_FOUND: + found = FALSE; + break; + default: + KdPrint2((PRINT_PREFIX "FAILED => SP_RETURN_ERROR\n")); + goto exit_error; + } KdPrint2((PRINT_PREFIX "ForceSimplex = %d\n", simplexOnly)); KdPrint2((PRINT_PREFIX "HwFlags = %x\n (0)", deviceExtension->HwFlags)); switch(dev_id) { @@ -2091,7 +2125,7 @@ UniataConnectIntr2( KdPrint2((PRINT_PREFIX "Create DO\n")); - devname.Length = + devname.Length = _snwprintf(devname_str, sizeof(devname_str)/sizeof(WCHAR), L"\\Device\\uniata%d_2ch", i); devname.Length *= sizeof(WCHAR); @@ -2686,7 +2720,7 @@ UniataAnybodyHome( } } else { - SStatus.Reg = AtapiReadPort4(chan, IDX_SATA_SStatus); + SStatus.Reg = UniataSataReadPort4(chan, IDX_SATA_SStatus, deviceNumber); KdPrint2((PRINT_PREFIX "SStatus %x\n", SStatus.Reg)); if(SStatus.DET <= SStatus_DET_Dev_NoPhy) { KdPrint2((PRINT_PREFIX " SATA DET <= SStatus_DET_Dev_NoPhy\n")); @@ -2772,7 +2806,7 @@ CheckDevice( //if(deviceExtension->HwFlags & UNIATA_SATA) { KdPrint2((PRINT_PREFIX "CheckDevice: try enable SATA Phy\n")); - statusByte = UniataSataPhyEnable(HwDeviceExtension, lChannel); + statusByte = UniataSataPhyEnable(HwDeviceExtension, lChannel, deviceNumber); if(statusByte == 0xff) { KdPrint2((PRINT_PREFIX "CheckDevice: status %#x (no dev)\n", statusByte)); UniataForgetDevice(LunExt); @@ -2791,7 +2825,7 @@ CheckDevice( GetBaseStatus(chan, statusByte); if(deviceExtension->HwFlags & UNIATA_SATA) { - UniataSataClearErr(HwDeviceExtension, lChannel, UNIATA_SATA_IGNORE_CONNECT); + UniataSataClearErr(HwDeviceExtension, lChannel, UNIATA_SATA_IGNORE_CONNECT, deviceNumber); } KdPrint2((PRINT_PREFIX "CheckDevice: status %#x\n", statusByte)); diff --git a/reactos/drivers/storage/ide/uniata/id_queue.cpp b/reactos/drivers/storage/ide/uniata/id_queue.cpp index 1f791e79328..4753eb321cd 100644 --- a/reactos/drivers/storage/ide/uniata/id_queue.cpp +++ b/reactos/drivers/storage/ide/uniata/id_queue.cpp @@ -1,3 +1,36 @@ +/*++ + +Copyright (c) 2008-2010 Alexandr A. Telyatnikov (Alter) + +Module Name: + id_probe.cpp + +Abstract: + This module handles comamnd queue reordering and channel load balance + +Author: + Alexander A. Telyatnikov (Alter) + +Environment: + kernel mode only + +Notes: + + THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Revision History: + +--*/ + #include "stdafx.h" /* diff --git a/reactos/drivers/storage/ide/uniata/id_sata.cpp b/reactos/drivers/storage/ide/uniata/id_sata.cpp index b0679617662..c6dd47df6d0 100644 --- a/reactos/drivers/storage/ide/uniata/id_sata.cpp +++ b/reactos/drivers/storage/ide/uniata/id_sata.cpp @@ -1,10 +1,44 @@ +/*++ + +Copyright (c) 2008-2010 Alexandr A. Telyatnikov (Alter) + +Module Name: + id_probe.cpp + +Abstract: + This module handles SATA-related staff + +Author: + Alexander A. Telyatnikov (Alter) + +Environment: + kernel mode only + +Notes: + + THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Revision History: + +--*/ + #include "stdafx.h" UCHAR NTAPI UniataSataConnect( IN PVOID HwDeviceExtension, - IN ULONG lChannel // logical channel + IN ULONG lChannel, // logical channel + IN ULONG pm_port /* for port multipliers */ ) { PHW_DEVICE_EXTENSION deviceExtension = (PHW_DEVICE_EXTENSION)HwDeviceExtension; @@ -26,11 +60,11 @@ UniataSataConnect( } /* clear SATA error register, some controllers need this */ - AtapiWritePort4(chan, IDX_SATA_SError, - AtapiReadPort4(chan, IDX_SATA_SError)); + UniataSataWritePort4(chan, IDX_SATA_SError, + UniataSataReadPort4(chan, IDX_SATA_SError, pm_port), pm_port); /* wait up to 1 second for "connect well" */ for(i=0; i<100; i++) { - SStatus.Reg = AtapiReadPort4(chan, IDX_SATA_SStatus); + SStatus.Reg = UniataSataReadPort4(chan, IDX_SATA_SStatus, pm_port); if(SStatus.SPD == SStatus_SPD_Gen1 || SStatus.SPD == SStatus_SPD_Gen2) { deviceExtension->lun[lChannel*2].TransferMode = ATA_SA150 + (UCHAR)(SStatus.SPD - 1); @@ -43,8 +77,8 @@ UniataSataConnect( return 0xff; } /* clear SATA error register */ - AtapiWritePort4(chan, IDX_SATA_SError, - AtapiReadPort4(chan, IDX_SATA_SError)); + UniataSataWritePort4(chan, IDX_SATA_SError, + UniataSataReadPort4(chan, IDX_SATA_SError, pm_port), pm_port); Status = WaitOnBaseBusyLong(chan); if(Status & IDE_STATUS_BUSY) { @@ -65,7 +99,8 @@ UCHAR NTAPI UniataSataPhyEnable( IN PVOID HwDeviceExtension, - IN ULONG lChannel // logical channel + IN ULONG lChannel, // logical channel + IN ULONG pm_port /* for port multipliers */ ) { PHW_DEVICE_EXTENSION deviceExtension = (PHW_DEVICE_EXTENSION)HwDeviceExtension; @@ -80,10 +115,10 @@ UniataSataPhyEnable( return IDE_STATUS_IDLE; } - SControl.Reg = AtapiReadPort4(chan, IDX_SATA_SControl); + SControl.Reg = UniataSataReadPort4(chan, IDX_SATA_SControl, pm_port); KdPrint2((PRINT_PREFIX "SControl %x\n", SControl.Reg)); if(SControl.DET == SControl_DET_Idle) { - return UniataSataConnect(HwDeviceExtension, lChannel); + return UniataSataConnect(HwDeviceExtension, lChannel, pm_port); } for (retry = 0; retry < 10; retry++) { @@ -91,9 +126,9 @@ UniataSataPhyEnable( for (loop = 0; loop < 10; loop++) { SControl.Reg = 0; SControl.DET = SControl_DET_Init; - AtapiWritePort4(chan, IDX_SATA_SControl, SControl.Reg); + UniataSataWritePort4(chan, IDX_SATA_SControl, SControl.Reg, pm_port); AtapiStallExecution(100); - SControl.Reg = AtapiReadPort4(chan, IDX_SATA_SControl); + SControl.Reg = UniataSataReadPort4(chan, IDX_SATA_SControl, pm_port); KdPrint2((PRINT_PREFIX " SControl %8.8%x\n", SControl.Reg)); if(SControl.DET == SControl_DET_Init) { break; @@ -105,12 +140,12 @@ UniataSataPhyEnable( SControl.Reg = 0; SControl.DET = SControl_DET_DoNothing; SControl.IPM = SControl_IPM_NoPartialSlumber; - AtapiWritePort4(chan, IDX_SATA_SControl, SControl.Reg); + UniataSataWritePort4(chan, IDX_SATA_SControl, SControl.Reg, pm_port); AtapiStallExecution(100); - SControl.Reg = AtapiReadPort4(chan, IDX_SATA_SControl); + SControl.Reg = UniataSataReadPort4(chan, IDX_SATA_SControl, pm_port); KdPrint2((PRINT_PREFIX " SControl %8.8%x\n", SControl.Reg)); if(SControl.DET == SControl_DET_Idle) { - return UniataSataConnect(HwDeviceExtension, lChannel); + return UniataSataConnect(HwDeviceExtension, lChannel, pm_port); } } } @@ -124,7 +159,8 @@ NTAPI UniataSataClearErr( IN PVOID HwDeviceExtension, IN ULONG lChannel, // logical channel - IN BOOLEAN do_connect + IN BOOLEAN do_connect, + IN ULONG pm_port /* for port multipliers */ ) { PHW_DEVICE_EXTENSION deviceExtension = (PHW_DEVICE_EXTENSION)HwDeviceExtension; @@ -136,8 +172,8 @@ UniataSataClearErr( if(UniataIsSATARangeAvailable(deviceExtension, lChannel)) { //if(ChipFlags & UNIATA_SATA) { - SStatus.Reg = AtapiReadPort4(chan, IDX_SATA_SStatus); - SError.Reg = AtapiReadPort4(chan, IDX_SATA_SError); + SStatus.Reg = UniataSataReadPort4(chan, IDX_SATA_SStatus, pm_port); + SError.Reg = UniataSataReadPort4(chan, IDX_SATA_SError, pm_port); if(SStatus.Reg) { KdPrint2((PRINT_PREFIX " SStatus %x\n", SStatus.Reg)); @@ -145,16 +181,16 @@ UniataSataClearErr( if(SError.Reg) { KdPrint2((PRINT_PREFIX " SError %x\n", SError.Reg)); /* clear error bits/interrupt */ - AtapiWritePort4(chan, IDX_SATA_SError, SError.Reg); + UniataSataWritePort4(chan, IDX_SATA_SError, SError.Reg, pm_port); if(do_connect) { /* if we have a connection event deal with it */ if(SError.DIAG.N) { KdPrint2((PRINT_PREFIX " catch SATA connect/disconnect\n")); if(SStatus.SPD >= SStatus_SPD_Gen1) { - UniataSataEvent(deviceExtension, lChannel, UNIATA_SATA_EVENT_ATTACH); + UniataSataEvent(deviceExtension, lChannel, UNIATA_SATA_EVENT_ATTACH, pm_port); } else { - UniataSataEvent(deviceExtension, lChannel, UNIATA_SATA_EVENT_DETACH); + UniataSataEvent(deviceExtension, lChannel, UNIATA_SATA_EVENT_DETACH, pm_port); } return TRUE; } @@ -169,12 +205,13 @@ NTAPI UniataSataEvent( IN PVOID HwDeviceExtension, IN ULONG lChannel, // logical channel - IN ULONG Action + IN ULONG Action, + IN ULONG pm_port /* for port multipliers */ ) { PHW_DEVICE_EXTENSION deviceExtension = (PHW_DEVICE_EXTENSION)HwDeviceExtension; UCHAR Status; - ULONG ldev = lChannel*2; + ULONG ldev = lChannel*2 + (pm_port ? 1 : 0); if(!UniataIsSATARangeAvailable(deviceExtension, lChannel)) { return FALSE; @@ -183,12 +220,12 @@ UniataSataEvent( switch(Action) { case UNIATA_SATA_EVENT_ATTACH: KdPrint2((PRINT_PREFIX " CONNECTED\n")); - Status = UniataSataConnect(HwDeviceExtension, lChannel); + Status = UniataSataConnect(HwDeviceExtension, lChannel, pm_port); KdPrint2((PRINT_PREFIX " Status %x\n", Status)); if(Status != IDE_STATUS_IDLE) { return FALSE; } - CheckDevice(HwDeviceExtension, lChannel, 0 /*dev*/, FALSE); + CheckDevice(HwDeviceExtension, lChannel, pm_port ? 1 : 0 /*dev*/, FALSE); return TRUE; break; case UNIATA_SATA_EVENT_DETACH: @@ -200,6 +237,135 @@ UniataSataEvent( return FALSE; } // end UniataSataEvent() +ULONG +UniataSataReadPort4( + IN PHW_CHANNEL chan, + IN ULONG io_port_ndx, + IN ULONG pm_port /* for port multipliers */ + ) +{ + if(chan && (io_port_ndx < IDX_MAX_REG) && + chan->RegTranslation[io_port_ndx].Proc) { + + PHW_DEVICE_EXTENSION deviceExtension = chan->DeviceExtension; + PVOID HwDeviceExtension = (PVOID)deviceExtension; + ULONG slotNumber = deviceExtension->slotNumber; + ULONG SystemIoBusNumber = deviceExtension->SystemIoBusNumber; + ULONG VendorID = deviceExtension->DevID & 0xffff; + ULONG offs; + ULONG p; + + switch(VendorID) { + case ATA_INTEL_ID: { + p = pm_port ? 1 : 0; + if(deviceExtension->HwFlags & ICH5) { + offs = 0x50+chan->lun[p]->SATA_lun_map*0x10; + switch(io_port_ndx) { + case IDX_SATA_SStatus: + offs += 0; + break; + case IDX_SATA_SError: + offs += 1*4; + break; + case IDX_SATA_SControl: + offs += 2*4; + break; + default: + return -1; + } + SetPciConfig4(0xa0, offs); + GetPciConfig4(0xa4, offs); + return offs; + } else { + offs = ((deviceExtension->Channel+chan->lChannel)*2+p) * 0x100; + switch(io_port_ndx) { + case IDX_SATA_SStatus: + offs += 0; + break; + case IDX_SATA_SControl: + offs += 1; + break; + case IDX_SATA_SError: + offs += 2; + break; + default: + return -1; + } + AtapiWritePort4(chan, IDX_INDEXED_ADDR, offs); + return AtapiReadPort4(chan, IDX_INDEXED_DATA); + } + } // ATA_INTEL_ID + } // end switch(VendorID) + return -1; + } + return AtapiReadPort4(chan, io_port_ndx); +} // end UniataSataReadPort4() + +VOID +UniataSataWritePort4( + IN PHW_CHANNEL chan, + IN ULONG io_port_ndx, + IN ULONG data, + IN ULONG pm_port /* for port multipliers */ + ) +{ + if(chan && (io_port_ndx < IDX_MAX_REG) && + chan->RegTranslation[io_port_ndx].Proc) { + + PHW_DEVICE_EXTENSION deviceExtension = chan->DeviceExtension; + PVOID HwDeviceExtension = (PVOID)deviceExtension; + ULONG slotNumber = deviceExtension->slotNumber; + ULONG SystemIoBusNumber = deviceExtension->SystemIoBusNumber; + ULONG VendorID = deviceExtension->DevID & 0xffff; + ULONG offs; + ULONG p; + + switch(VendorID) { + case ATA_INTEL_ID: { + p = pm_port ? 1 : 0; + if(deviceExtension->HwFlags & ICH5) { + offs = 0x50+chan->lun[p]->SATA_lun_map*0x10; + switch(io_port_ndx) { + case IDX_SATA_SStatus: + offs += 0; + break; + case IDX_SATA_SError: + offs += 1*4; + break; + case IDX_SATA_SControl: + offs += 2*4; + break; + default: + return; + } + SetPciConfig4(0xa0, offs); + SetPciConfig4(0xa4, data); + return; + } else { + offs = ((deviceExtension->Channel+chan->lChannel)*2+p) * 0x100; + switch(io_port_ndx) { + case IDX_SATA_SStatus: + offs += 0; + break; + case IDX_SATA_SControl: + offs += 1; + break; + case IDX_SATA_SError: + offs += 2; + break; + default: + return; + } + AtapiWritePort4(chan, IDX_INDEXED_ADDR, offs); + AtapiWritePort4(chan, IDX_INDEXED_DATA, data); + } + } // ATA_INTEL_ID + } // end switch(VendorID) + return; + } + AtapiWritePort4(chan, io_port_ndx, data); +} // end UniataSataWritePort4() + BOOLEAN NTAPI UniataAhciInit( @@ -316,7 +482,8 @@ UCHAR NTAPI UniataAhciStatus( IN PVOID HwDeviceExtension, - IN ULONG lChannel + IN ULONG lChannel, + IN ULONG DeviceNumber ) { PHW_DEVICE_EXTENSION deviceExtension = (PHW_DEVICE_EXTENSION)HwDeviceExtension; @@ -451,4 +618,3 @@ UniataAhciSetupFIS( fis[19] = 0x00; return 20; } // end UniataAhciSetupFIS() - diff --git a/reactos/drivers/storage/ide/uniata/id_sata.h b/reactos/drivers/storage/ide/uniata/id_sata.h index 047160475ae..a53fee91bdb 100644 --- a/reactos/drivers/storage/ide/uniata/id_sata.h +++ b/reactos/drivers/storage/ide/uniata/id_sata.h @@ -5,14 +5,16 @@ UCHAR NTAPI UniataSataConnect( IN PVOID HwDeviceExtension, - IN ULONG lChannel // logical channel + IN ULONG lChannel, // logical channel + IN ULONG pm_port = 0 /* for port multipliers */ ); UCHAR NTAPI UniataSataPhyEnable( IN PVOID HwDeviceExtension, - IN ULONG lChannel // logical channel + IN ULONG lChannel, // logical channel + IN ULONG pm_port = 0 /* for port multipliers */ ); #define UNIATA_SATA_DO_CONNECT TRUE @@ -23,7 +25,8 @@ NTAPI UniataSataClearErr( IN PVOID HwDeviceExtension, IN ULONG lChannel, // logical channel - IN BOOLEAN do_connect + IN BOOLEAN do_connect, + IN ULONG pm_port = 0 /* for port multipliers */ ); #define UNIATA_SATA_EVENT_ATTACH 0x01 @@ -34,7 +37,8 @@ NTAPI UniataSataEvent( IN PVOID HwDeviceExtension, IN ULONG lChannel, // logical channel - IN ULONG Action + IN ULONG Action, + IN ULONG pm_port = 0 /* for port multipliers */ ); #define UniataIsSATARangeAvailable(deviceExtension, lChannel) \ @@ -42,6 +46,23 @@ UniataSataEvent( deviceExtension->BaseIoAHCI_0.Addr) && \ (deviceExtension->chan[lChannel].RegTranslation[IDX_SATA_SStatus].Addr)) +ULONG +NTAPI +UniataSataReadPort4( + IN PHW_CHANNEL chan, + IN ULONG io_port_ndx, + IN ULONG pm_port=0 /* for port multipliers */ + ); + +VOID +NTAPI +UniataSataWritePort4( + IN PHW_CHANNEL chan, + IN ULONG io_port_ndx, + IN ULONG data, + IN ULONG pm_port=0 /* for port multipliers */ + ); + BOOLEAN NTAPI UniataAhciInit( @@ -52,7 +73,8 @@ UCHAR NTAPI UniataAhciStatus( IN PVOID HwDeviceExtension, - IN ULONG lChannel + IN ULONG lChannel, + IN ULONG DeviceNumber ); ULONG diff --git a/reactos/drivers/storage/ide/uniata/idedma.rc b/reactos/drivers/storage/ide/uniata/idedma.rc index 8553f0fd19c..06297f2bec5 100644 --- a/reactos/drivers/storage/ide/uniata/idedma.rc +++ b/reactos/drivers/storage/ide/uniata/idedma.rc @@ -1,6 +1,6 @@ #include "uniata_ver.h" -#define VERSION 0,39,6,0 +#define VERSION UNIATA_VER_DOT_COMMA #define VERSION_STR "0." UNIATA_VER_STR #define REACTOS_FILETYPE VFT_DRV @@ -12,7 +12,7 @@ #define REACTOS_STR_FILE_VERSION VERSION_STR #define REACTOS_STR_INTERNAL_NAME "uniata.sys" #define REACTOS_STR_ORIGINAL_FILENAME "uniata.sys" -#define REACTOS_STR_LEGAL_COPYRIGHT "Copyright 1999-2008 AlterWare, Copyright 2007 ReactOS Team" +#define REACTOS_STR_LEGAL_COPYRIGHT "Copyright 1999-" UNIATA_VER_YEAR_STR " AlterWare, Copyright 2010 ReactOS Team" #define REACTOS_STR_PRODUCT_NAME "UniATA Driver for ReactOS" #define REACTOS_STR_PRODUCT_VERSION VERSION_STR diff --git a/reactos/drivers/storage/ide/uniata/inc/CrossNt.h b/reactos/drivers/storage/ide/uniata/inc/CrossNt.h index e17f576b066..eeab727cae6 100644 --- a/reactos/drivers/storage/ide/uniata/inc/CrossNt.h +++ b/reactos/drivers/storage/ide/uniata/inc/CrossNt.h @@ -123,6 +123,9 @@ int __cdecl CrNtstrcmp ( const char * dst ); +#define strlen CrNtstrlen +#define strcmp CrNtstrcmp + #endif //_DEBUG #define CROSSNT_DECL_API diff --git a/reactos/drivers/storage/ide/uniata/scsi.h b/reactos/drivers/storage/ide/uniata/scsi.h index 6d231b4298e..b6d639554af 100644 --- a/reactos/drivers/storage/ide/uniata/scsi.h +++ b/reactos/drivers/storage/ide/uniata/scsi.h @@ -170,9 +170,9 @@ typedef union _CDB { UCHAR Reserved : 4; } Fields; } Byte2; - + UCHAR Reserved2[3]; - UCHAR Start_TrackSes; + UCHAR Start_TrackSes;; UCHAR AllocationLength[2]; UCHAR Control : 6; UCHAR Format : 2; @@ -531,7 +531,7 @@ typedef union _CDB { } Byte2; UCHAR Reserved1 [2]; UCHAR TrackNum; - UCHAR Reserved2 [6]; + UCHAR Reserved2 [6]; } CLOSE_TRACK_SESSION, *PCLOSE_TRACK_SESSION; @@ -1519,7 +1519,7 @@ typedef PREAD_TOC_FULL_TOC PREAD_TOC_PMA; typedef struct _READ_TOC_ATIP { UCHAR Length[2]; UCHAR Reserved[2]; - + #define ATIP_SpeedRef_Mask 0x07 #define ATIP_SpeedRef_2X 0x01 #define ATIP_WritingPower_Mask 0x07 @@ -1930,8 +1930,8 @@ typedef struct _EVENT_STAT_DEV_BUSY_BLOCK { // Define mode disc info block. -typedef struct _DISC_INFO_BLOCK { // - UCHAR DataLength [2]; +typedef struct _DISC_INFO_BLOCK { // + UCHAR DataLength [2]; #define DiscInfo_Disk_Mask 0x03 #define DiscInfo_Disk_Empty 0x00 @@ -1994,7 +1994,7 @@ typedef struct _DISC_INFO_BLOCK { // // Define track info block. typedef struct _TRACK_INFO_BLOCK { - UCHAR DataLength [2]; + UCHAR DataLength [2]; UCHAR TrackNum; UCHAR SesNum; UCHAR Reserved0; @@ -2264,7 +2264,7 @@ typedef struct _MODE_WRITE_PARAMS_PAGE { // 0x05 } Byte4; UCHAR LinkSize; - UCHAR Reserved3; + UCHAR Reserved3; union { UCHAR Flags; @@ -2370,7 +2370,7 @@ typedef struct _MODE_CD_PARAMS_PAGE { // 0x0D UCHAR PageCode : 6; UCHAR Reserved : 1; UCHAR PageSavable : 1; - + UCHAR PageLength; // 0x06 UCHAR Reserved1; @@ -2409,7 +2409,7 @@ typedef struct _MODE_CD_AUDIO_CONTROL_PAGE { // 0x0E UCHAR PageCode : 6; UCHAR Reserved1: 1; UCHAR PageSavable : 1; - + UCHAR PageLength; // 0x0E #define CdAudio_SOTC 0x02 @@ -2438,7 +2438,7 @@ typedef struct _MODE_POWER_CONDITION_PAGE { // 0x1A UCHAR PageCode : 6; UCHAR Reserved1: 1; UCHAR PageSavable : 1; - + UCHAR PageLength; // 0x0A UCHAR Reserved2; @@ -2465,7 +2465,7 @@ typedef struct _MODE_FAIL_REPORT_PAGE { // 0x1C UCHAR PageCode : 6; UCHAR Reserved1: 1; UCHAR PageSavable : 1; - + UCHAR PageLength; // 0x0A #define FailReport_LogErr 0x01 @@ -2504,7 +2504,7 @@ typedef struct _MODE_TIMEOUT_AND_PROTECT_PAGE { // 0x1D UCHAR PageCode : 6; UCHAR Reserved1: 1; UCHAR PageSavable : 1; - + UCHAR PageLength; // 0x08 UCHAR Reserved2[2]; @@ -2567,31 +2567,31 @@ typedef struct _MODE_CAPABILITIES_PAGE2 { // 0x2A UCHAR PageLength; -#define DevCap_read_cd_r 0x01 // reserved in 1.2 -#define DevCap_read_cd_rw 0x02 // reserved in 1.2 +#define DevCap_read_cd_r 0x01 // reserved in 1.2 +#define DevCap_read_cd_rw 0x02 // reserved in 1.2 #define DevCap_method2 0x04 #define DevCap_read_dvd_rom 0x08 #define DevCap_read_dvd_r 0x10 #define DevCap_read_dvd_ram 0x20 UCHAR ReadCap; // DevCap_*_read -/* UCHAR cd_r_read : 1; // reserved in 1.2 - UCHAR cd_rw_read : 1; // reserved in 1.2 +/* UCHAR cd_r_read : 1; // reserved in 1.2 + UCHAR cd_rw_read : 1; // reserved in 1.2 UCHAR method2 : 1; UCHAR dvd_rom : 1; UCHAR dvd_r_read : 1; UCHAR dvd_ram_read : 1; UCHAR Reserved2 : 2;*/ -#define DevCap_write_cd_r 0x01 // reserved in 1.2 -#define DevCap_write_cd_rw 0x02 // reserved in 1.2 +#define DevCap_write_cd_r 0x01 // reserved in 1.2 +#define DevCap_write_cd_rw 0x02 // reserved in 1.2 #define DevCap_test_write 0x04 #define DevCap_write_dvd_r 0x10 #define DevCap_write_dvd_ram 0x20 UCHAR WriteCap; // DevCap_*_write -/* UCHAR cd_r_write : 1; // reserved in 1.2 - UCHAR cd_rw_write : 1; // reserved in 1.2 +/* UCHAR cd_r_write : 1; // reserved in 1.2 + UCHAR cd_rw_write : 1; // reserved in 1.2 UCHAR test_write : 1; UCHAR reserved3a : 1; UCHAR dvd_r_write : 1; @@ -2656,16 +2656,16 @@ typedef struct _MODE_CAPABILITIES_PAGE2 { // 0x2A #define DevCap_separate_volume 0x01 #define DevCap_separate_mute 0x02 -#define DevCap_disc_present 0x04 // reserved in 1.2 -#define DevCap_sw_slot_select 0x08 // reserved in 1.2 -#define DevCap_change_side_cap 0x10 +#define DevCap_disc_present 0x04 // reserved in 1.2 +#define DevCap_sw_slot_select 0x08 // reserved in 1.2 +#define DevCap_change_side_cap 0x10 #define DevCap_rw_leadin_read 0x20 UCHAR Capabilities3; /* UCHAR separate_volume : 1; UCHAR separate_mute : 1; - UCHAR disc_present : 1; // reserved in 1.2 - UCHAR sss : 1; // reserved in 1.2 + UCHAR disc_present : 1; // reserved in 1.2 + UCHAR sss : 1; // reserved in 1.2 UCHAR Reserved7 : 4;*/ UCHAR MaximumSpeedSupported[2]; diff --git a/reactos/drivers/storage/ide/uniata/srb.h b/reactos/drivers/storage/ide/uniata/srb.h index 0932284fed2..9c3e46f4c6f 100644 --- a/reactos/drivers/storage/ide/uniata/srb.h +++ b/reactos/drivers/storage/ide/uniata/srb.h @@ -56,7 +56,7 @@ typedef struct _PORT_CONFIGURATION_INFORMATION { // well as level, such as internal buses. ULONG BusInterruptVector; KINTERRUPT_MODE InterruptMode; // Interrupt mode (level-sensitive or edge-triggered) - + ULONG MaximumTransferLength; // Max bytes that can be transferred in a single SRB ULONG NumberOfPhysicalBreaks; // Number of contiguous blocks of physical memory ULONG DmaChannel; // DMA channel for devices using system DMA @@ -84,8 +84,8 @@ typedef struct _PORT_CONFIGURATION_INFORMATION { BOOLEAN MultipleRequestPerLu; // Supports multiple requests per logical unit. BOOLEAN ReceiveEvent; // Support receive event function. BOOLEAN RealModeInitialized; // Indicates the real-mode driver has initialized the card. - - BOOLEAN BufferAccessScsiPortControlled; // Indicate that the miniport will not touch + + BOOLEAN BufferAccessScsiPortControlled; // Indicate that the miniport will not touch // the data buffers directly. UCHAR MaximumNumberOfTargets; // Indicator for wide scsi. UCHAR ReservedUchars[2]; // Ensure quadword alignment. @@ -110,7 +110,7 @@ typedef struct _PORT_CONFIGURATION_INFORMATION_NT { } PORT_CONFIGURATION_INFORMATION_NT, *PPORT_CONFIGURATION_INFORMATION_NT; typedef struct _PORT_CONFIGURATION_INFORMATION_2K { - // Used to determine whether the system and/or the miniport support + // Used to determine whether the system and/or the miniport support // 64-bit physical addresses. See SCSI_DMA64_* flags below. UCHAR Dma64BitAddresses; // Indicates that the miniport can accept a SRB_FUNCTION_RESET_DEVICE @@ -141,9 +141,9 @@ typedef struct _PORT_CONFIGURATION_INFORMATION_COMMON { // // -// Set by scsiport on entering HwFindAdapter if the system can support 64-bit -// physical addresses. The miniport can use this information before calling -// ScsiPortGetUncachedExtension to modify the DeviceExtensionSize, +// Set by scsiport on entering HwFindAdapter if the system can support 64-bit +// physical addresses. The miniport can use this information before calling +// ScsiPortGetUncachedExtension to modify the DeviceExtensionSize, // SpecificLuExtensionSize & SrbExtensionSize fields to account for the extra // size of the scatter gather list. // @@ -152,7 +152,7 @@ typedef struct _PORT_CONFIGURATION_INFORMATION_COMMON { // // Set by the miniport before calling ScsiPortGetUncachedExtension to indicate -// that scsiport should provide it with 64-bit physical addresses. If the +// that scsiport should provide it with 64-bit physical addresses. If the // system does not support 64-bit PA's then this bit will be ignored. // @@ -363,9 +363,9 @@ typedef struct _SCSI_WMI_REQUEST_BLOCK { #define SRB_STATUS_INTERNAL_ERROR 0x30 // -// Srb status values 0x38 through 0x3f are reserved for internal port driver +// Srb status values 0x38 through 0x3f are reserved for internal port driver // use. -// +// @@ -566,7 +566,7 @@ typedef struct _HW_INITIALIZATION_DATA { ULONG SrbExtensionSize; ULONG NumberOfAccessRanges; PVOID Reserved; - + BOOLEAN MapBuffers; // Data buffers must be mapped into virtual address space. BOOLEAN NeedPhysicalAddresses; // We need to tranlate virtual to physical addresses. BOOLEAN TaggedQueuing; // Supports tagged queuing diff --git a/reactos/drivers/storage/ide/uniata/todo.txt b/reactos/drivers/storage/ide/uniata/todo.txt new file mode 100644 index 00000000000..1674c2f7885 --- /dev/null +++ b/reactos/drivers/storage/ide/uniata/todo.txt @@ -0,0 +1,254 @@ +1. use ScsiPortGetBusData() instead of HalGetBusData() to enumerate ... + PCI devices (8b ) +2. create 2 channels on non-primary HBA (9 ) +3. add BusMaster detection to ISA & ISA/PCI FindController() routines ... + I've decided to modify AtapiFindBusMasterController() for this ... + purpose (9 ) +4. beautify sources ;) +5. add LBA support (8 ) +6. return modified Cylinders in IDENTYFY_DATA to handle HDDs > 8Gb ... + properly (8 ) +7. return good HDD size value for ... + a) IdeVerify() (8 ) + b) SCSIOP_READ_CAPACITY (8 ) +8. use READ_NATIVE_SIZE command to determine actual drive capacity (8a ) +9. send FLUSH command to device (9 ) +10. check (IO_WDx - 0x08) ports in AtapiFindBusMasterController() (+++) +11. use SelectDrive() instead of ScsiPortWritePortXXX() (9a ) +12. remove obsolete AtapiFindPCIController() (9a ) +13. make a separate routine AtapiInitController() for HBA ... + initialization (move there some parts of code from ... + AtapiFindBusMasterController() (---) +14. add feature enabling code to drive (re)init routine IdeHardReset() ... + AtapiHwInitialize() does all necessary staff (10+) +15, use AtapiInitController() in AtapiHwInitialize() (---) +16. remove obsolete FindBrokenController() and ... + AtapiFindNativeModeController() (10 ) +17. move FindDevices() to id_probe.cpp (10 ) +18. set HDD PIO modes if no DMA available (10 ) +19. implement AtaCommand() (10 ) +20. implement AtaPioMode() & AtaPio2Mode() (10 ) +21. add some new ChipSets support from FBSD 4.5 (10a) +22. set Controller PIO timigs ... + a) via (11 ) ?? + b) intel (+++) + c) AcerLabs Aladdin IV/V (23 ) +23. update Identify block (11 ) +24. add LBA-48 support (11 ) +25. use AtapiCommand()/AtapiCommand48() instead of direct port I/O ... + a) for Read/Write/Identify (11 ) + b) Set features, Smart, Set drive params (11c) +26. port/implement AtapiDmaInit() for well-known controllers (11 ) +27. Beautify IdeReadWrite() (11c) +28. port/implement DMA-specific parts of interrupt handlers (12 ) +29. request queueing (16b) +30. port/implement DMA-start routine (12 ) +31. remove MODE_SENSE/SELECT 6<->10 translation. It'll improve ... + performance. (11a) +32. move InterruptService to DPC (via ScsiPortNotification()) (17 ) +33. implement ATA_WAIT_INTR branch in AtapiCommand()/AtapiCommand48() (11b) +34. fix bugs in Identify structure (11b) +35. use normal Lba detection in IssueIdentify() (11b) +36. fix bug with default structure elements alignment ... + use pragma pack (1) (11c) +37. use ATA_WAIT_INTR in IdeReadWrite() for Write branch and ... + ATA_IMMEDIATE for Read one (11c) +38. update Identify dtructure (11c) +39. fix some size detection bugs in IssueIdentify() (11c) +40. don't forget setting ExpectingInterrupt flag before WriteBuffer() ... + on PIO transfer (12g) +41. try generic DMA for old devices instead of PIO default (12g) +42. clear 4 lower bits of AccessRange (12g) +43. reconstruct _Original_ ConfigInfo (not temporary) on Detect ... + phase (13 ) +44. set 32-bit addressing for all bus types (13 ) +45. handle invalid address value (-1) in AtapiDmaSetup() (13 ) +46. add some new ChipSets support from FBSD 4.6 (13c) +47. add 'offset' parameter to AtapiGetIoRange() to allow claiming ... + different io-regions of the same PCI device by different ... + DeviceObjects (representing different channels of this device (13a) +48. claim both BusMaster io-regions on SimplexOnly controllers (+++) +49. add ATAPI DMA support (19 ) +50. read 'PSS ID Number: Q133706' in NT DDK & implement Registry- ... + supplied params. Use a small hack instead: Argument2 is the ... + pointer to UNICODE_STRING we need (18a) +51. implement Reinitialize functionality (+++) +52. optimize DMA init (move similar parts of code to loops/functions ... + a) VIA/AMD/nVidia (13c) + b) Promise TX2 (13c) + c) Promise Ultra (23 ) + d) ServerWorks (23 ) + e) CMD 64x (+++) + f) SiS (+++) + g) AcerLabs Aladdin IV/V (+++) + h) Intel (+++) + i) Sil (23 ) + j) HPT (23 ) +53. use LogicalUnitExtension instead of xxx[Srb->TargetId] (14 ) +54. use SrbExtension to manage queue (16b) +55. IdeReadWrite() should support non-zero initial offset in DataBuffer ... + to allow scatter/gather simulation, queueing & retries +56. keep 'dma_tab' in SrbExtension (16b) +57. never set SpecificLuExtensionSize to 0 (14a) +58. never call ScsiPortGetUncachedExtension() twice for the same HBA, ... + even if the 1st call failed. Use deviceExtension->HbaCtrlFlags & ... + HBAFLAGS_DMA_DISABLED to indicate such case (16 ) +59. set deviceExtension->BaseIoAddressBM[1] properly for dual-channel ... + HBAs (it was equal to BaseIoAddressBM[0]) (16 ) +60. set Channel properly in AtapiInterrupt__() for dual-channel HBAs ... + (lChannel was ignored) (16 ) +61. initialize ConfigINfo members required by ... + ScsiPortGetUncachedExtension() _before_ call to AtapiDmaAlloc() (16 ) +62. move SCSI-address-2-Channel/Device translation to macros. This ... + makes code more readable & flexible. (16 ) +63. implement SCSI-bus - IDE-channel and ... + SCSI-TargetId - IDE-master/slave correspondance (using p.62) (16 ) +64. set AutoRequestSense to TRUE (16a) +65. set inquiryData->CommandQueue to 1 (16a) +66. fill SenseInfoBufer in ... + a) IDE MapError() (16a) + b) IDE/ATAPI success (20d) +67. use AtaReq->ReqState to indicate request processing state (16b) +68. fill AtaReq->ReqState in all necessary places to reflect actual ... + request state (for optimizer) (18+) +69. fix bug with unconditional returning FALSE in AtapiInterrupt() (16c) +70. copy pointer to original AtaReq from Srb to InternalSrb (16c) +71. check input Srb value for NULL in AtapiRemoveRequest() (16c) +72. return from IssueIdentify loop if no error occured. Previous ... + versions have a bug: SUCCESS status was ignored & this caused ... + obsolet retries (16c) +73. clear CTRFLAGS_INTR_DISABLED flag in AtapiEnableInterrupts_Xxx() (17a) +74. use Sync Object to manage access to request queue (---) +75. remove AtapiEnableInterrupts_Xxx()-related code duplicates from ... + AtapiInterrupt__() (17a) +76. check calls to AtapiResetController() & related routines. ... + See p. 80, 81 (+++) +77. use ScsiPortNotification() with RequestTimerCall instead of ... + CallDis(En)ableInterrupts to allow servicing 2 channels in ... + parallel. See p.87 (---) +78. do not use DPC ISR for fast operations, like ... + a) DMA-completion (18 ) + b) sending CDB to ATAPI devices (18a) + c) short ATAPI transfers (18a) +79. call both AtapiEnableInterrupts_X() & AtapiCallBack_X() on DSC ... + restrictive commands completion (18 ) +80. invoke AtapiStartIo__() from ISR as callback to parform it's ... + execution at lower IRQL (19x) +81. invoke AtapiResetController() from ISR as callback to parform it's ... + execution at lower IRQL (19x) +82. do not use ScsiPortCompleteRequest() in AtapiResetController() ... + Use standard completion way with setting SenseData instead (18a) +83. reset single channel on normal (non-simplex-only) controllers in ... + AtapiResetController() (18a) +84. sort records in BMList on enumeration phase & simplify init loops ... + in DriverEntry() (18a) +85. fix bug with wrong numberChannels init for 2nd channel in ... + AtapiResetController() (18b) +86. implement channel-sensetive AtapiHwInitialize__() and use in in ... + AtapiResetController() & AtapiHwInitialize() (18+) +87. Due to SCSI-port restrictions we should Enable/Disable interruptys ... + for BOTH channels :((((. Implement this.... (19 ) +88. Deprecate p.87. ;) It doesn't work. Solution: connect manually ... + created DeviceObject to the same interrupt & check in its ISR if ... + our device interrupted while original ISR/DPC processing ... + another channel's interrupt. (20 ) +90. add error handling on additional DevObj init (20a) +91. deprecate p.80,81. We should acquire QueueSpinLock at DIRQL (+/-) +92. perform all possible request init on queueing stage even if we ... + can't send it to device immediately (use CMD_ACTION_XXX) ... + a) for IDE branch (20c) + b) for ATAPI branch (21a) +93. complete the following commands immediately: ... + SCSIOP_INQUIRY, SCSIOP_READ_CAPACITY, SCSIOP_REQUEST_SENSE (20c) +94. implement ABORT_COMMAND functionality (20d) +95. reorder incoming requests in AtapiQueueRequest() (21c) +96. make 2 modes for ResetController(): complete current & complete ... + all for p.94. (20d) +97. store queue size statistics in HW_CHANNEL (20d) +98. remove obsolete DPC code from AtapiInterrupt__() (20e) +99. store error rate in HW_CHANNEL (20e) +100.try falling back to PIO when DMA error occured (20e) +101.use Dma & Pio error rates to distinguish between BadBlock & ... + BadCable conditions, See also p.127, 128 (+++) +102.don't use HDD's algorithm of falling back to PIO for ATAPI (21 ) +103.clear REQ_FLAG_DMA_OPERATION when falling back to PIO (21 ) +104.set REQ_FLAG_REORDERABLE_CMD in IdeReadWrite() (21 ) +105.store bcount along with lba in ATA_REQ on CMD_ACTION_PREPARE stage (21 ) +106.do like p.105,104 in AtapiSendCommand for read/write ops (21 ) +107.set operation type flag (Read/Write) in AtaReq on ... + CMD_ACTION_PREPARE stage (21b) +108.send comamnds to queue _after_ CMD_ACTION_PREPARE stage (21a) +109.fix bug (incorrect queue_size check) in p.108 (21b) +110.handle SRB_FLAGS_DISABLE_AUTOSENSE +111.handle Srb->QueueAction (21d) +112.check SRB_STATUS_AUTOSENSE_VALID usage policy (+++) +113.add support for hardware queueing/overlapped commands +114.handle immediate commands properly: don't initiate bus reset ... + while formatting CDRW (+++) +115.add hardware IDE RAID support +116.fix bug with data type missmatch in AtapiDmaInit(), ... + some VIA branches. This bug caused array boundary cross, leading ... + to system crash (22 ) +117.default udmamode to 0 if there are no well-known devices found ... + in AtapiDmaInit(), VIA branch. (22 ) +118.do not check RevID in AtapiFindDev if RevID == -1 (22 ) +119.use best settings for newer RevIDs +120.fix signed/unsigned missmatch (i vs udmamode) in AtapiDmaInit(), ... + VIA branch (22 ) +121.fix bug with incorrect UDMA init in VIA branch. use UDMA0+i ... + instead of UDMA0+udmamode (22a) +122.fall back to WDMA mode before PIO (22a) +123.use transfer speed slowdown algorithm when high error rate ... + detected (22a) +124.don't forget updating AtaReq->retry on R/W error (non-DMA) (22a) +125.fill AtaReq with ZEROs on TopLevel condition (22a) +126.fix bug in IdeVerify() with sending SectorCount to device before ... + call to AtaCommand48() and using 0 SectorCount in that call (22a) +127.store Error/Recover rate statistics in LunExtension (22a) +128.use p.127 for smart slowdown algorithm (22b) +129.use lChannel instead of phChannel for indexing in find-channel ... + loop in AtapiFindBusMasterController() (22b) +130.programm controller for lower speed in Ide/AtapiSendCommand(), not ... + in AtapiInterrupt__() (22b) +131.use AtapiDmaReinit() routine for p.131 (22b) +132.implement per-device queueing (23 ) +134.add Sil, ICH4, Some HPT, PromiseTX2(133) support from 4.7 (23 ) +135.fix wrong bit-shift bug in lba48 branch (23 ) +136.update and sort BusMasterAdapters[] (23a) +137.fix bugs in AtapiTimerDpc() that caused incorrect handling of ... + DSC restrictive commands ... + a) call ScsiPortNotification(RequestTimerCall, ...) when we had ... + a 2nd request on entry only (23c) + b) check HwScsiTimer1 first to decide whether we have to go to ... + GetNextDpc (23c) + c) wrong condition check 'time <= DpcTime1' instead of ... + 'time >= DpcTime1' (23c) + d) remove request from queue _before_ call to HwScsiTimer() (23c) +138.add support for Acard controllers (25 ) +139.use some additional code for HP/Promise Dma Star/Stop (25 ) +140.assign queueing priority for each device +141.assign BusMaster io-range to 1st channel only. (26e) +142.do not change bus type to PCI for legacy ISA-PCI controllers under ... + NT4 (28 ) +143.implement Device/Vendor/Rev. filtering via registry keys (30+) +144.implement transfer mode control IOCTLs (28 ) +145.set max. transfer length > 64k. +146.implement fix for miss-aligned user buffer +147.set chip-specific init/operation flags only once during ... + initialization and use them in future. Do not perform multiple ... + bus scans and other detections. (29a) +148.fix bug with miss-functioning Enable/Disable interrupt for (+++) + secondary channel (28 ) +149.add serial-ATA support (29a) +150.add support for new controllers (SiS, Promise) (29a) +151.fix detection/init algorithms in order to avoid usage of ... + non-generic code for unknown chips (29a) +152.add support for >2 channels (29a) +153.improve Intr-detection loop. Start each time from next channel ... + for load-balance (29a) +154.add support for machines with >4G physical memory (38 ) +155.add FreeBSD software RAID support +156.use http://www.winimage.com/readfi15.zip for performance checks +157.use IOCTL_SCSI_MINIPORT_IDENTIFY in atactl.exe to determine ... + PIO/DMA when no uniata.sys is installed (+++) +158. diff --git a/reactos/drivers/storage/ide/uniata/uniata_ver.h b/reactos/drivers/storage/ide/uniata/uniata_ver.h index 8c55047f27c..5cfcf462cc9 100644 --- a/reactos/drivers/storage/ide/uniata/uniata_ver.h +++ b/reactos/drivers/storage/ide/uniata/uniata_ver.h @@ -1,6 +1,6 @@ -#define UNIATA_VER_STR "39j" -#define UNIATA_VER_DOT 0.39.10.0 -#define UNIATA_VER_DOT_COMMA 0,39,10,0 -#define UNIATA_VER_DOT_STR "0.39.10.0" -#define UNIATA_VER_YEAR 2008 -#define UNIATA_VER_YEAR_STR "2008" +#define UNIATA_VER_STR "40a1" +#define UNIATA_VER_DOT 0.40.1.1 +#define UNIATA_VER_DOT_COMMA 0,40,1,1 +#define UNIATA_VER_DOT_STR "0.40.1.1" +#define UNIATA_VER_YEAR 2010 +#define UNIATA_VER_YEAR_STR "2010" From e7f8fba71068ffdeaecb011d42031719207a37fe Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Thu, 23 Dec 2010 19:11:19 +0000 Subject: [PATCH 106/181] [RTL} Replace RtlMoveMemory x86 asm code with the code from CRT's memmove, which is better. Now we can close bug #1941 svn path=/trunk/; revision=50116 --- reactos/lib/rtl/i386/rtlmem.s | 150 +++++++++++++++++++++++----------- 1 file changed, 102 insertions(+), 48 deletions(-) diff --git a/reactos/lib/rtl/i386/rtlmem.s b/reactos/lib/rtl/i386/rtlmem.s index d26f5b4ec52..0925b966042 100644 --- a/reactos/lib/rtl/i386/rtlmem.s +++ b/reactos/lib/rtl/i386/rtlmem.s @@ -210,70 +210,124 @@ ByteZero: _RtlMoveMemory@12: + push ebp + mov ebp, esp - /* Save volatiles */ + /* Save non-volatiles */ push esi push edi /* Get pointers and size */ - mov esi, [esp+16] - mov edi, [esp+12] - mov ecx, [esp+20] - cld + mov edi, [ebp + 8] + mov esi, [ebp + 12] + mov ecx, [ebp + 16] - /* Check if the destination is higher (or equal) */ - cmp esi, edi - jbe Overlap + /* Use downward copy if source < dest and overlapping */ + cmp edi, esi + jbe .CopyUp + mov eax, ecx + add eax, esi + cmp edi, eax + jb .CopyDown - /* Set ULONG size and UCHAR remainder */ -DoMove: - mov edx, ecx - and edx, 3 - shr ecx, 2 +.CopyUp: + cld - /* Do the move */ - rep movsd - or ecx, edx - jnz ByteMove + /* Check for small moves */ + cmp ecx, 16 + jb .CopyUpBytes - /* Return */ - pop edi - pop esi - ret 12 + /* Check if its already aligned */ + mov edx, ecx + test edi, 3 + je .CopyUpDwords -ByteMove: - /* Move what's left */ - rep movsb + /* Make the destination dword aligned */ + mov ecx, edi + and ecx, 3 + sub ecx, 5 + not ecx + sub edx, ecx + rep movsb + mov ecx, edx -DoneMove: - /* Restore volatiles */ - pop edi - pop esi - ret 12 +.CopyUpDwords: + shr ecx, 2 + rep movsd + mov ecx, edx + and ecx, 3 -Overlap: - /* Don't copy if they're equal */ - jz DoneMove +.CopyUpBytes: + test ecx, ecx + je .CopyUpEnd + rep movsb - /* Compare pointer distance with given length and check for overlap */ - mov eax, edi - sub eax, esi - cmp ecx, eax - jbe DoMove +.CopyUpEnd: + mov eax, [ebp + 8] + pop edi + pop esi + pop ebp + ret 12 - /* Set direction flag for backward move */ - std +.CopyDown: + std - /* Copy byte-by-byte the non-overlapping distance */ - add esi, ecx - add edi, ecx - dec esi - dec edi + /* Go to the end of the region */ + add edi, ecx + add esi, ecx + + /* Check for small moves */ + cmp ecx, 16 + jb .CopyDownSmall + + /* Check if its already aligned */ + mov edx, ecx + test edi, 3 + je .CopyDownAligned + + /* Make the destination dword aligned */ + mov ecx, edi + and ecx, 3 + sub edx, ecx + dec esi + dec edi + rep movsb + mov ecx, edx + sub esi, 3 + sub edi, 3 + +.CopyDownDwords: + shr ecx, 2 + rep movsd + mov ecx, edx + and ecx, 3 + je .CopyDownEnd + add esi, 3 + add edi, 3 + +.CopyDownBytes: + rep movsb + +.CopyDownEnd: + cld + mov eax, [ebp + 8] + pop edi + pop esi + pop ebp + ret 12 + +.CopyDownAligned: + sub edi, 4 + sub esi, 4 + jmp .CopyDownDwords + +.CopyDownSmall: + test ecx, ecx + je .CopyDownEnd + dec esi + dec edi + jmp .CopyDownBytes - /* Do the move, reset flag and return */ - rep movsb - cld - jmp DoneMove @RtlPrefetchMemoryNonTemporal@8: From f8d20cdb330042eb95eb834a6b22a57b3b817c0e Mon Sep 17 00:00:00 2001 From: Dmitry Gorbachev Date: Fri, 24 Dec 2010 01:59:13 +0000 Subject: [PATCH 107/181] Marco Radossevich , a.k.a. forart: "Just two important examples that involved my contributions: UniATA & FullFAT." No code changes. See thread for more details. svn path=/trunk/; revision=50117 --- reactos/drivers/filesystems/fastfat_new/fatstruc.h | 2 +- reactos/drivers/filesystems/fastfat_new/rw.c | 2 +- reactos/drivers/storage/ide/uniata/inc/PostDbgMesg.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/reactos/drivers/filesystems/fastfat_new/fatstruc.h b/reactos/drivers/filesystems/fastfat_new/fatstruc.h index 2ca2f54b8da..9ad1f50b02f 100644 --- a/reactos/drivers/filesystems/fastfat_new/fatstruc.h +++ b/reactos/drivers/filesystems/fastfat_new/fatstruc.h @@ -80,7 +80,7 @@ typedef struct _FAT_PAGE_CONTEXT CcUnpinData((xContext)->Bcb); \ (xContext)->Bcb = NULL; \ } \ - + #define FatPinEndOfPage(xContext, xType) \ Add2Ptr((xContext)->Buffer, (xContext)->ValidLength, xType) diff --git a/reactos/drivers/filesystems/fastfat_new/rw.c b/reactos/drivers/filesystems/fastfat_new/rw.c index cdaea2b52a3..1508b0f6239 100644 --- a/reactos/drivers/filesystems/fastfat_new/rw.c +++ b/reactos/drivers/filesystems/fastfat_new/rw.c @@ -36,7 +36,7 @@ FatiRead(PFAT_IRP_CONTEXT IrpContext) FatCompleteRequest(IrpContext, IrpContext->Irp, STATUS_SUCCESS); return STATUS_SUCCESS; } - + OpenType = FatDecodeFileObject(FileObject, &Vcb, &Fcb, &Ccb); DPRINT("FatiRead() Fcb %p, Name %wZ, Offset %d, Length %d, Handle %p\n", diff --git a/reactos/drivers/storage/ide/uniata/inc/PostDbgMesg.h b/reactos/drivers/storage/ide/uniata/inc/PostDbgMesg.h index 221cb159600..964de7ea3f9 100644 --- a/reactos/drivers/storage/ide/uniata/inc/PostDbgMesg.h +++ b/reactos/drivers/storage/ide/uniata/inc/PostDbgMesg.h @@ -43,4 +43,4 @@ DbgDump_SetAutoReconnect( }; #endif //__cplusplus -#endif //__DBG_DUMP_TOOLS__H__ \ No newline at end of file +#endif //__DBG_DUMP_TOOLS__H__ From 91f7232df76152b71d18e73c42dae2ecec1924be Mon Sep 17 00:00:00 2001 From: Amine Khaldi Date: Fri, 24 Dec 2010 12:09:01 +0000 Subject: [PATCH 108/181] [CMAKE] - Add the remaining winetests to build. We compile them all now. svn path=/trunk/; revision=50120 --- rostests/winetests/CMakeLists.txt | 4 +-- rostests/winetests/oleaut32/CMakeLists.txt | 33 ++++++++++++++++++++++ rostests/winetests/rpcrt4/CMakeLists.txt | 30 ++++++++++++++++++++ 3 files changed, 65 insertions(+), 2 deletions(-) create mode 100644 rostests/winetests/oleaut32/CMakeLists.txt create mode 100644 rostests/winetests/rpcrt4/CMakeLists.txt diff --git a/rostests/winetests/CMakeLists.txt b/rostests/winetests/CMakeLists.txt index 0ae0e8d6503..195194d96f6 100644 --- a/rostests/winetests/CMakeLists.txt +++ b/rostests/winetests/CMakeLists.txt @@ -49,7 +49,7 @@ add_subdirectory(ntprint) add_subdirectory(odbccp32) add_subdirectory(ole32) add_subdirectory(oleacc) -#add_subdirectory(oleaut32) +add_subdirectory(oleaut32) add_subdirectory(opengl32) add_subdirectory(pdh) add_subdirectory(powrprof) @@ -59,7 +59,7 @@ add_subdirectory(quartz) add_subdirectory(rasapi32) add_subdirectory(riched20) add_subdirectory(riched32) -#add_subdirectory(rpcrt4) +add_subdirectory(rpcrt4) add_subdirectory(rsabase) add_subdirectory(rsaenh) add_subdirectory(schannel) diff --git a/rostests/winetests/oleaut32/CMakeLists.txt b/rostests/winetests/oleaut32/CMakeLists.txt new file mode 100644 index 00000000000..8174f11ef98 --- /dev/null +++ b/rostests/winetests/oleaut32/CMakeLists.txt @@ -0,0 +1,33 @@ + +add_definitions( + -D__ROS_LONG64__ + -D_DLL -D__USE_CRTIMP) + +include_directories(${REACTOS_SOURCE_DIR}/include/reactos/wine) + +ADD_TYPELIB(oleaut32_typelibs test_reg.idl test_tlb.idl tmarshal.idl) +add_dependencies(oleaut32_typelibs stdole2) + +ADD_INTERFACE_DEFINITIONS(oleaut32_idlheaders test_reg.idl tmarshal.idl) +add_idl_interface(tmarshal.idl) + +list(APPEND SOURCE + dispatch.c + olefont.c + olepicture.c + safearray.c + testlist.c + tmarshal.c + tmarshal.rc + typelib.c + usrmarshal.c + varformat.c + vartest.c + vartype.c + ${CMAKE_CURRENT_BINARY_DIR}/tmarshal_i.c) + +add_executable(oleaut32_winetest ${SOURCE}) +target_link_libraries(oleaut32_winetest uuid wine) +set_module_type(oleaut32_winetest win32cui) +add_importlibs(oleaut32_winetest oleaut32 ole32 rpcrt4 user32 gdi32 advapi32 msvcrt kernel32 ntdll) +add_dependencies(oleaut32_winetest oleaut32_typelibs oleaut32_idlheaders) diff --git a/rostests/winetests/rpcrt4/CMakeLists.txt b/rostests/winetests/rpcrt4/CMakeLists.txt new file mode 100644 index 00000000000..b8f7a1640fe --- /dev/null +++ b/rostests/winetests/rpcrt4/CMakeLists.txt @@ -0,0 +1,30 @@ + +remove_definitions(-D_WIN32_WINNT=0x502) +add_definitions(-D_WIN32_WINNT=0x500) + +add_definitions( + -D__ROS_LONG64__ + -D_DLL -D__USE_CRTIMP) + +MACRO_IDL_FILES(server.idl) + +list(APPEND SOURCE + cstub.c + generated.c + ndr_marshall.c + rpc.c + rpc_async.c + rpc_protseq.c + server.c + testlist.c) + +add_executable(rpcrt4_winetest ${SOURCE}) +target_link_libraries(rpcrt4_winetest + uuid + wine + server_server + server_client + ${PSEH_LIB}) + +set_module_type(rpcrt4_winetest win32cui) +add_importlibs(rpcrt4_winetest ole32 rpcrt4 msvcrt kernel32 ntdll) From 23499a2d4d133f5f006d8c190945f2db98b6e259 Mon Sep 17 00:00:00 2001 From: Giannis Adamopoulos Date: Fri, 24 Dec 2010 12:11:10 +0000 Subject: [PATCH 109/181] [win32k] - Remove co_IntPostOrSendMessage and use co_IntSendMessageNoWait where possible svn path=/trunk/; revision=50121 --- .../win32/win32k/include/msgqueue.h | 5 --- .../subsystems/win32/win32k/ntuser/desktop.c | 6 +-- .../subsystems/win32/win32k/ntuser/focus.c | 8 ++-- .../subsystems/win32/win32k/ntuser/message.c | 41 ------------------- 4 files changed, 5 insertions(+), 55 deletions(-) diff --git a/reactos/subsystems/win32/win32k/include/msgqueue.h b/reactos/subsystems/win32/win32k/include/msgqueue.h index 7c84ed0d4ae..f153314c421 100644 --- a/reactos/subsystems/win32/win32k/include/msgqueue.h +++ b/reactos/subsystems/win32/win32k/include/msgqueue.h @@ -180,11 +180,6 @@ co_IntSendMessage(HWND hWnd, WPARAM wParam, LPARAM lParam); LRESULT FASTCALL -co_IntPostOrSendMessage(HWND hWnd, - UINT Msg, - WPARAM wParam, - LPARAM lParam); -LRESULT FASTCALL co_IntSendMessageTimeout(HWND hWnd, UINT Msg, WPARAM wParam, diff --git a/reactos/subsystems/win32/win32k/ntuser/desktop.c b/reactos/subsystems/win32/win32k/ntuser/desktop.c index b4a4e20fb39..336f48d28ae 100644 --- a/reactos/subsystems/win32/win32k/ntuser/desktop.c +++ b/reactos/subsystems/win32/win32k/ntuser/desktop.c @@ -740,11 +740,7 @@ VOID co_IntShellHookNotify(WPARAM Message, LPARAM lParam) for (; *cursor; cursor++) { - DPRINT("Sending notify\n"); - co_IntPostOrSendMessage(*cursor, - MsgType, - Message, - lParam); + co_IntSendMessageNoWait(*cursor, MsgType, Message, lParam); } ExFreePool(HwndList); diff --git a/reactos/subsystems/win32/win32k/ntuser/focus.c b/reactos/subsystems/win32/win32k/ntuser/focus.c index 414b1523bf7..21d4f73d6a8 100644 --- a/reactos/subsystems/win32/win32k/ntuser/focus.c +++ b/reactos/subsystems/win32/win32k/ntuser/focus.c @@ -77,7 +77,7 @@ co_IntSendActivateMessages(HWND hWndPrev, HWND hWnd, BOOL MouseActivate) if (WindowPrev) UserRefObjectCo(WindowPrev, &RefPrev); /* Send palette messages */ - if (co_IntPostOrSendMessage(hWnd, WM_QUERYNEWPALETTE, 0, 0)) + if (co_IntSendMessage(hWnd, WM_QUERYNEWPALETTE, 0, 0)) { UserPostMessage( HWND_BROADCAST, WM_PALETTEISCHANGING, @@ -166,7 +166,7 @@ co_IntSendKillFocusMessages(HWND hWndPrev, HWND hWnd) if (hWndPrev) { IntNotifyWinEvent(EVENT_OBJECT_FOCUS, NULL, OBJID_CLIENT, CHILDID_SELF, 0); - co_IntPostOrSendMessage(hWndPrev, WM_KILLFOCUS, (WPARAM)hWnd, 0); + co_IntSendMessageNoWait(hWndPrev, WM_KILLFOCUS, (WPARAM)hWnd, 0); } } @@ -177,7 +177,7 @@ co_IntSendSetFocusMessages(HWND hWndPrev, HWND hWnd) { PWND pWnd = UserGetWindowObject(hWnd); IntNotifyWinEvent(EVENT_OBJECT_FOCUS, pWnd, OBJID_CLIENT, CHILDID_SELF, 0); - co_IntPostOrSendMessage(hWnd, WM_SETFOCUS, (WPARAM)hWndPrev, 0); + co_IntSendMessageNoWait(hWnd, WM_SETFOCUS, (WPARAM)hWndPrev, 0); } } @@ -579,7 +579,7 @@ NtUserSetCapture(HWND hWnd) if (Window) IntNotifyWinEvent(EVENT_SYSTEM_CAPTURESTART, Window, OBJID_WINDOW, CHILDID_SELF, WEF_SETBYWNDPTI); - co_IntPostOrSendMessage(hWndPrev, WM_CAPTURECHANGED, 0, (LPARAM)hWnd); + co_IntSendMessageNoWait(hWndPrev, WM_CAPTURECHANGED, 0, (LPARAM)hWnd); ThreadQueue->CaptureWindow = hWnd; RETURN( hWndPrev); diff --git a/reactos/subsystems/win32/win32k/ntuser/message.c b/reactos/subsystems/win32/win32k/ntuser/message.c index 1de7a949d54..8f8eec23cd3 100644 --- a/reactos/subsystems/win32/win32k/ntuser/message.c +++ b/reactos/subsystems/win32/win32k/ntuser/message.c @@ -1404,47 +1404,6 @@ CLEANUP: END_CLEANUP; } -/* This function posts a message if the destination's message queue belongs to -another thread, otherwise it sends the message. It does not support broadcast -messages! */ -LRESULT FASTCALL -co_IntPostOrSendMessage( HWND hWnd, - UINT Msg, - WPARAM wParam, - LPARAM lParam ) -{ - ULONG_PTR Result; - PTHREADINFO pti; - PWND Window; - - if ( hWnd == HWND_BROADCAST ) - { - return 0; - } - - if(!(Window = UserGetWindowObject(hWnd))) - { - return 0; - } - - pti = PsGetCurrentThreadWin32Thread(); - - if ( Window->head.pti->MessageQueue != pti->MessageQueue && - FindMsgMemory(Msg) == 0 ) - { - Result = UserPostMessage(hWnd, Msg, wParam, lParam); - } - else - { - if ( !co_IntSendMessageTimeoutSingle(hWnd, Msg, wParam, lParam, SMTO_NORMAL, 0, &Result) ) - { - Result = 0; - } - } - - return (LRESULT)Result; -} - LRESULT FASTCALL co_IntDoSendMessage( HWND hWnd, UINT Msg, From 15137418453950af369f56caced02375b5bb3f4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Gardou?= Date: Fri, 24 Dec 2010 20:29:25 +0000 Subject: [PATCH 110/181] [GDI32] - remove useless memory reallocation : the buffer size must be dword aligned, we have no way to guarantee the buffer location will be. - pass BITMAPINFO pointer size to NtGdiGetDIBitsInternal [WIN32K] - Improve "not enough memory" check when creating a bitmap - use correct function to set the last error. svn path=/trunk/; revision=50133 --- reactos/dll/win32/gdi32/objects/bitmap.c | 91 +++++++++++-------- .../subsystems/win32/win32k/objects/bitmaps.c | 11 ++- 2 files changed, 60 insertions(+), 42 deletions(-) diff --git a/reactos/dll/win32/gdi32/objects/bitmap.c b/reactos/dll/win32/gdi32/objects/bitmap.c index 8d93036c7d9..18db05f2a61 100644 --- a/reactos/dll/win32/gdi32/objects/bitmap.c +++ b/reactos/dll/win32/gdi32/objects/bitmap.c @@ -3,6 +3,36 @@ #define NDEBUG #include +/* + * DIB_BitmapInfoSize + * + * Return the size of the bitmap info structure including color table. + * 11/16/1999 (RJJ) lifted from wine + */ + +INT FASTCALL DIB_BitmapInfoSize(const BITMAPINFO * info, WORD coloruse) +{ + unsigned int colors, size, masks = 0; + + if (info->bmiHeader.biSize == sizeof(BITMAPCOREHEADER)) + { + const BITMAPCOREHEADER *core = (const BITMAPCOREHEADER *)info; + colors = (core->bcBitCount <= 8) ? 1 << core->bcBitCount : 0; + return sizeof(BITMAPCOREHEADER) + colors * + ((coloruse == DIB_RGB_COLORS) ? sizeof(RGBTRIPLE) : sizeof(WORD)); + } + else /* assume BITMAPINFOHEADER */ + { + colors = info->bmiHeader.biClrUsed; + if (colors > 256) colors = 256; + if (!colors && (info->bmiHeader.biBitCount <= 8)) + colors = 1 << info->bmiHeader.biBitCount; + if (info->bmiHeader.biCompression == BI_BITFIELDS) masks = 3; + size = max( info->bmiHeader.biSize, sizeof(BITMAPINFOHEADER) + masks * sizeof(DWORD) ); + return size + colors * ((coloruse == DIB_RGB_COLORS) ? sizeof(RGBQUAD) : sizeof(WORD)); + } +} + /* * Return the full scan size for a bitmap. * @@ -391,59 +421,40 @@ GetDIBits( LPBITMAPINFO lpbmi, UINT uUsage) { - INT Ret = 0; - UINT cjBmpScanSize; - PVOID pvSafeBits = lpvBits; + UINT cjBmpScanSize; + UINT cjInfoSize; - if (!hDC || !GdiIsHandleValid((HGDIOBJ)hDC)) - { - GdiSetLastError(ERROR_INVALID_PARAMETER); - return Ret; - } + if (!hDC || !GdiIsHandleValid((HGDIOBJ)hDC) || !lpbmi) + { + GdiSetLastError(ERROR_INVALID_PARAMETER); + return 0; + } - cjBmpScanSize = DIB_BitmapMaxBitsSize(lpbmi, cScanLines); + cjBmpScanSize = DIB_BitmapMaxBitsSize(lpbmi, cScanLines); + cjInfoSize = DIB_BitmapInfoSize(lpbmi, uUsage); - if ( lpvBits ) - { - if ( lpbmi ) - { + if ( lpvBits ) + { if ( lpbmi->bmiHeader.biSize >= sizeof(BITMAPINFOHEADER) ) { - if ( lpbmi->bmiHeader.biCompression == BI_JPEG || - lpbmi->bmiHeader.biCompression == BI_PNG ) - { - SetLastError(ERROR_INVALID_PARAMETER); - return Ret; - } + if ( lpbmi->bmiHeader.biCompression == BI_JPEG || + lpbmi->bmiHeader.biCompression == BI_PNG ) + { + SetLastError(ERROR_INVALID_PARAMETER); + return 0; + } } - } + } - if ((ULONG)lpvBits & (sizeof(DWORD) - 1)) - { - pvSafeBits = RtlAllocateHeap(RtlGetProcessHeap(), 0, cjBmpScanSize); - if (!pvSafeBits) - return Ret; - } - } - - Ret = NtGdiGetDIBitsInternal(hDC, + return NtGdiGetDIBitsInternal(hDC, hbmp, uStartScan, cScanLines, - pvSafeBits, + lpvBits, lpbmi, uUsage, cjBmpScanSize, - 0); - if (lpvBits != pvSafeBits) - { - if (Ret) - { - RtlCopyMemory(lpvBits, pvSafeBits, cjBmpScanSize); - } - RtlFreeHeap(RtlGetProcessHeap(), 0, pvSafeBits); - } - return Ret; + cjInfoSize); } /* diff --git a/reactos/subsystems/win32/win32k/objects/bitmaps.c b/reactos/subsystems/win32/win32k/objects/bitmaps.c index c3b7e8f148b..8f75277ebcc 100644 --- a/reactos/subsystems/win32/win32k/objects/bitmaps.c +++ b/reactos/subsystems/win32/win32k/objects/bitmaps.c @@ -170,11 +170,18 @@ NtGdiCreateBitmap( iFormat = BitmapFormat(cBitsPixel, BI_RGB); /* Check parameters */ - if (iFormat == 0 || nWidth <= 0 || nWidth >= 0x8000000 || nHeight <= 0) + if (iFormat == 0 || nWidth <= 0 || nHeight <= 0) { DPRINT1("Width = %d, Height = %d BitsPixel = %d\n", nWidth, nHeight, cBitsPixel); - EngSetLastError(ERROR_INVALID_PARAMETER); + SetLastWin32Error(ERROR_INVALID_PARAMETER); + return NULL; + } + + if(WIDTH_BYTES_ALIGN16(nWidth, cBitsPixel)*nHeight >= 0x8000000) + { + /* I just can't get enough, I just can't get enough */ + SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY); return NULL; } From 9e8a4109b0218b3068f3ed8113b47ddf097a641b Mon Sep 17 00:00:00 2001 From: Art Yerkes Date: Fri, 24 Dec 2010 22:54:24 +0000 Subject: [PATCH 111/181] Make sure to initialize our page operation mutex. Scan the whole range of the MemoryArea for pages to evict. This fixes cache section page eviction. svn path=/trunk/; revision=50134 --- reactos/ntoskrnl/cache/fssup.c | 2 ++ reactos/ntoskrnl/cache/section/swapout.c | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/reactos/ntoskrnl/cache/fssup.c b/reactos/ntoskrnl/cache/fssup.c index f436e744b1e..4af45ec85f1 100644 --- a/reactos/ntoskrnl/cache/fssup.c +++ b/reactos/ntoskrnl/cache/fssup.c @@ -25,6 +25,7 @@ extern VOID NTAPI CcpUnmapThread(PVOID Unused); extern VOID NTAPI CcpLazyWriteThread(PVOID Unused); HANDLE CcUnmapThreadHandle, CcLazyWriteThreadHandle; CLIENT_ID CcUnmapThreadId, CcLazyWriteThreadId; +FAST_MUTEX GlobalPageOperation; typedef struct _NOCC_PRIVATE_CACHE_MAP { @@ -98,6 +99,7 @@ CcInitializeCacheManager(VOID) CcCacheBitmap->SizeOfBitMap = ROUND_UP(CACHE_NUM_SECTIONS, 32); DPRINT("Cache has %d entries\n", CcCacheBitmap->SizeOfBitMap); ExInitializeFastMutex(&CcMutex); + ExInitializeFastMutex(&GlobalPageOperation); // MM stub KeInitializeEvent(&MmWaitPageEvent, SynchronizationEvent, FALSE); diff --git a/reactos/ntoskrnl/cache/section/swapout.c b/reactos/ntoskrnl/cache/section/swapout.c index 685104e3d64..691635dc58d 100644 --- a/reactos/ntoskrnl/cache/section/swapout.c +++ b/reactos/ntoskrnl/cache/section/swapout.c @@ -480,8 +480,8 @@ MiCacheEvictPages(PVOID BaseAddress, ULONG Target) MmLockCacheSectionSegment(Segment); for (i = 0; - i < Segment->Length.QuadPart - - MemoryArea->Data.CacheData.ViewOffset.QuadPart && + i < ((ULONG_PTR)MemoryArea->EndingAddress) - + ((ULONG_PTR)MemoryArea->StartingAddress) && Result < Target; i += PAGE_SIZE) { Offset.QuadPart = MemoryArea->Data.CacheData.ViewOffset.QuadPart + i; From cbd14f3708b864c7bc50d0cedc9d19edde8b8bdd Mon Sep 17 00:00:00 2001 From: Roel Messiant Date: Sat, 25 Dec 2010 05:27:01 +0000 Subject: [PATCH 112/181] [WIN32K] - IntCreateWindow: Fill out MaximumLength field of the window name. Fixes potential buffer overflow in at least NtUserDefSetText. svn path=/trunk/; revision=50135 --- reactos/subsystems/win32/win32k/ntuser/window.c | 1 + 1 file changed, 1 insertion(+) diff --git a/reactos/subsystems/win32/win32k/ntuser/window.c b/reactos/subsystems/win32/win32k/ntuser/window.c index 73b6d9af7cf..47636714673 100644 --- a/reactos/subsystems/win32/win32k/ntuser/window.c +++ b/reactos/subsystems/win32/win32k/ntuser/window.c @@ -1759,6 +1759,7 @@ PWND FASTCALL IntCreateWindow(CREATESTRUCTW* Cs, RtlCopyMemory(pWnd->strName.Buffer, WindowName->Buffer, WindowName->Length); pWnd->strName.Buffer[WindowName->Length / sizeof(WCHAR)] = L'\0'; pWnd->strName.Length = WindowName->Length; + pWnd->strName.MaximumLength = WindowName->Length + sizeof(UNICODE_NULL); } /* Correct the window style. */ From 184b70c1ded974c70e4a9dea580d91c06aa9fe2d Mon Sep 17 00:00:00 2001 From: Johannes Anderwald Date: Sat, 25 Dec 2010 09:08:44 +0000 Subject: [PATCH 113/181] [INF] - Fix PCI group key svn path=/trunk/; revision=50136 --- reactos/boot/bootdata/hivesys_i386.inf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reactos/boot/bootdata/hivesys_i386.inf b/reactos/boot/bootdata/hivesys_i386.inf index a622feeb74c..c7447cda8dc 100644 --- a/reactos/boot/bootdata/hivesys_i386.inf +++ b/reactos/boot/bootdata/hivesys_i386.inf @@ -1257,7 +1257,7 @@ HKLM,"SYSTEM\CurrentControlSet\Services\Packet","Type",0x00010001,0x00000001 ; PCI Bus driver HKLM,"SYSTEM\CurrentControlSet\Services\Pci","ErrorControl",0x00010001,0x00000001 -HKLM,"SYSTEM\CurrentControlSet\Services\Pci","Group",0x00000000,"Boot Bus +HKLM,"SYSTEM\CurrentControlSet\Services\Pci","Group",0x00000000,"Boot Bus " HKLM,"SYSTEM\CurrentControlSet\Services\Pci","Tag",0x00010001,0x00000002 HKLM,"SYSTEM\CurrentControlSet\Services\Pci\Parameters","1045C621",0x00030003,04,00,00,00,00,00,00,00 HKLM,"SYSTEM\CurrentControlSet\Services\Pci\Parameters","10950640",0x00030003,04,00,00,00,00,00,00,00 From 54ee99abdb9caae9878322edfe556a0cb0bf802c Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Sat, 25 Dec 2010 10:37:55 +0000 Subject: [PATCH 114/181] [WIN32K] Fix EngGetLastError and EngSetLastError svn path=/trunk/; revision=50138 --- reactos/subsystems/win32/win32k/eng/error.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/reactos/subsystems/win32/win32k/eng/error.c b/reactos/subsystems/win32/win32k/eng/error.c index d78da06d545..54a78bb49e7 100644 --- a/reactos/subsystems/win32/win32k/eng/error.c +++ b/reactos/subsystems/win32/win32k/eng/error.c @@ -5,22 +5,28 @@ /* * @implemented + * http://msdn.microsoft.com/en-us/library/ff564940%28VS.85%29.aspx */ ULONG APIENTRY -EngGetLastError ( VOID ) +EngGetLastError(VOID) { - // www.osr.com/ddk/graphics/gdifncs_3non.htm - return GetLastNtError(); + PTEB pTeb = NtCurrentTeb(); + if (pTeb) + return NtCurrentTeb()->LastErrorValue; + else + return ERROR_SUCCESS; } /* * @implemented + * http://msdn.microsoft.com/en-us/library/ff565015%28VS.85%29.aspx */ VOID APIENTRY -EngSetLastError ( IN ULONG iError ) +EngSetLastError(IN ULONG iError) { - // www.osr.com/ddk/graphics/gdifncs_95m0.htm - SetLastNtError ( iError ); + PTEB pTeb = NtCurrentTeb(); + if (pTeb) + pTeb->LastErrorValue = iError; } From 4d40fbf685243e603ab28e59f2f1b1a9967127b1 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Sat, 25 Dec 2010 11:01:14 +0000 Subject: [PATCH 115/181] [WIN32K] Remove SetLastWin32Error and use EngSetLastError instead svn path=/trunk/; revision=50139 --- .../subsystems/win32/win32k/eng/alphablend.c | 2 +- reactos/subsystems/win32/win32k/eng/error.c | 7 ++ reactos/subsystems/win32/win32k/eng/pdevobj.c | 4 +- .../subsystems/win32/win32k/include/error.h | 14 ---- .../subsystems/win32/win32k/include/misc.h | 4 ++ .../subsystems/win32/win32k/include/win32kp.h | 1 - reactos/subsystems/win32/win32k/misc/err.c | 64 ----------------- .../win32/win32k/ntuser/accelerator.c | 4 +- .../subsystems/win32/win32k/ntuser/caret.c | 12 ++-- .../subsystems/win32/win32k/ntuser/class.c | 54 +++++++------- .../win32/win32k/ntuser/clipboard.c | 14 ++-- .../win32/win32k/ntuser/cursoricon.c | 14 ++-- .../subsystems/win32/win32k/ntuser/desktop.c | 14 ++-- .../subsystems/win32/win32k/ntuser/display.c | 2 +- .../subsystems/win32/win32k/ntuser/event.c | 10 +-- .../subsystems/win32/win32k/ntuser/focus.c | 4 +- reactos/subsystems/win32/win32k/ntuser/hook.c | 26 +++---- .../subsystems/win32/win32k/ntuser/input.c | 10 +-- .../win32/win32k/ntuser/kbdlayout.c | 2 +- reactos/subsystems/win32/win32k/ntuser/menu.c | 38 +++++----- .../subsystems/win32/win32k/ntuser/message.c | 24 +++---- reactos/subsystems/win32/win32k/ntuser/misc.c | 10 +-- .../subsystems/win32/win32k/ntuser/monitor.c | 12 ++-- .../subsystems/win32/win32k/ntuser/ntstubs.c | 10 +-- .../subsystems/win32/win32k/ntuser/object.c | 2 +- .../subsystems/win32/win32k/ntuser/painting.c | 8 +-- .../win32/win32k/ntuser/scrollbar.c | 18 ++--- .../win32/win32k/ntuser/simplecall.c | 14 ++-- .../win32/win32k/ntuser/sysparams.c | 4 +- .../subsystems/win32/win32k/ntuser/timer.c | 4 +- .../subsystems/win32/win32k/ntuser/window.c | 56 +++++++-------- .../subsystems/win32/win32k/ntuser/winpos.c | 8 +-- .../subsystems/win32/win32k/ntuser/winsta.c | 8 +-- reactos/subsystems/win32/win32k/objects/arc.c | 8 +-- .../subsystems/win32/win32k/objects/bitblt.c | 16 ++--- .../subsystems/win32/win32k/objects/bitmaps.c | 20 +++--- .../subsystems/win32/win32k/objects/brush.c | 22 +++--- .../subsystems/win32/win32k/objects/cliprgn.c | 20 +++--- .../subsystems/win32/win32k/objects/coord.c | 38 +++++----- .../subsystems/win32/win32k/objects/dclife.c | 4 +- .../subsystems/win32/win32k/objects/dcobjs.c | 8 +-- .../subsystems/win32/win32k/objects/dcstate.c | 6 +- .../subsystems/win32/win32k/objects/dcutil.c | 28 ++++---- .../subsystems/win32/win32k/objects/dibobj.c | 44 ++++++------ .../subsystems/win32/win32k/objects/drawing.c | 4 +- .../win32/win32k/objects/fillshap.c | 38 +++++----- .../subsystems/win32/win32k/objects/font.c | 54 +++++++------- .../win32/win32k/objects/freetype.c | 72 +++++++++---------- .../subsystems/win32/win32k/objects/gdiobj.c | 2 +- reactos/subsystems/win32/win32k/objects/icm.c | 14 ++-- .../subsystems/win32/win32k/objects/line.c | 4 +- .../win32/win32k/objects/metafile.c | 12 ++-- .../subsystems/win32/win32k/objects/palette.c | 8 +-- .../subsystems/win32/win32k/objects/path.c | 54 +++++++------- reactos/subsystems/win32/win32k/objects/pen.c | 8 +-- .../subsystems/win32/win32k/objects/print.c | 8 +-- .../subsystems/win32/win32k/objects/region.c | 24 +++---- .../subsystems/win32/win32k/objects/text.c | 20 +++--- .../subsystems/win32/win32k/objects/wingl.c | 12 ++-- reactos/subsystems/win32/win32k/win32k.rbuild | 1 - 60 files changed, 479 insertions(+), 548 deletions(-) delete mode 100644 reactos/subsystems/win32/win32k/include/error.h delete mode 100644 reactos/subsystems/win32/win32k/misc/err.c diff --git a/reactos/subsystems/win32/win32k/eng/alphablend.c b/reactos/subsystems/win32/win32k/eng/alphablend.c index afd1b5e5f54..46d78fb73cb 100644 --- a/reactos/subsystems/win32/win32k/eng/alphablend.c +++ b/reactos/subsystems/win32/win32k/eng/alphablend.c @@ -69,7 +69,7 @@ EngAlphaBlend(IN SURFOBJ *psoDest, InputRect.right > psoSource->sizlBitmap.cx || InputRect.bottom > psoSource->sizlBitmap.cy ) { - SetLastWin32Error(ERROR_INVALID_PARAMETER); + EngSetLastError(ERROR_INVALID_PARAMETER); return FALSE; } diff --git a/reactos/subsystems/win32/win32k/eng/error.c b/reactos/subsystems/win32/win32k/eng/error.c index 54a78bb49e7..a844c70fea1 100644 --- a/reactos/subsystems/win32/win32k/eng/error.c +++ b/reactos/subsystems/win32/win32k/eng/error.c @@ -30,3 +30,10 @@ EngSetLastError(IN ULONG iError) if (pTeb) pTeb->LastErrorValue = iError; } + +VOID +FASTCALL +SetLastNtError(NTSTATUS Status) +{ + EngSetLastError(RtlNtStatusToDosError(Status)); +} diff --git a/reactos/subsystems/win32/win32k/eng/pdevobj.c b/reactos/subsystems/win32/win32k/eng/pdevobj.c index faff16e4aa0..1acb8a55ec8 100644 --- a/reactos/subsystems/win32/win32k/eng/pdevobj.c +++ b/reactos/subsystems/win32/win32k/eng/pdevobj.c @@ -619,7 +619,7 @@ NtGdiGetDeviceCaps( pdc = DC_LockDc(hdc); if (!pdc) { - SetLastWin32Error(ERROR_INVALID_HANDLE); + EngSetLastError(ERROR_INVALID_HANDLE); return 0; } @@ -769,7 +769,7 @@ NtGdiGetDeviceCapsAll( pdc = DC_LockDc(hDC); if (!pdc) { - SetLastWin32Error(ERROR_INVALID_HANDLE); + EngSetLastError(ERROR_INVALID_HANDLE); return FALSE; } diff --git a/reactos/subsystems/win32/win32k/include/error.h b/reactos/subsystems/win32/win32k/include/error.h deleted file mode 100644 index 92a1cbf92a8..00000000000 --- a/reactos/subsystems/win32/win32k/include/error.h +++ /dev/null @@ -1,14 +0,0 @@ -#pragma once - -VOID FASTCALL -SetLastNtError( - NTSTATUS Status); - -VOID FASTCALL -SetLastWin32Error( - DWORD Status); - -NTSTATUS FASTCALL -GetLastNtError(VOID); - -/* EOF */ diff --git a/reactos/subsystems/win32/win32k/include/misc.h b/reactos/subsystems/win32/win32k/include/misc.h index 340e9ef252d..26a35d4925a 100644 --- a/reactos/subsystems/win32/win32k/include/misc.h +++ b/reactos/subsystems/win32/win32k/include/misc.h @@ -73,3 +73,7 @@ RegWriteUserSetting( IN ULONG ulType, OUT PVOID pvData, IN ULONG cbDataSize); + +VOID FASTCALL +SetLastNtError( + NTSTATUS Status); diff --git a/reactos/subsystems/win32/win32k/include/win32kp.h b/reactos/subsystems/win32/win32k/include/win32kp.h index b84a319947f..7842bb276d9 100644 --- a/reactos/subsystems/win32/win32k/include/win32kp.h +++ b/reactos/subsystems/win32/win32k/include/win32kp.h @@ -36,7 +36,6 @@ #include #include #include -#include #include #include #include diff --git a/reactos/subsystems/win32/win32k/misc/err.c b/reactos/subsystems/win32/win32k/misc/err.c deleted file mode 100644 index b7fcb2cde31..00000000000 --- a/reactos/subsystems/win32/win32k/misc/err.c +++ /dev/null @@ -1,64 +0,0 @@ -/* - * ReactOS W32 Subsystem - * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 ReactOS Team - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ -/* $Id$ - * - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS kernel - * PURPOSE: Errors - * FILE: subsys/win32k/misc/error.c - * PROGRAMER: Casper S. Hornstrup (chorns@users.sourceforge.net) - * REVISION HISTORY: - * 06-06-2001 CSH Created - */ - -#include - -#define NDEBUG -#include - -VOID FASTCALL -SetLastNtError(NTSTATUS Status) -{ - SetLastWin32Error(RtlNtStatusToDosError(Status)); -} - -VOID FASTCALL -SetLastWin32Error(DWORD Status) -{ - PTEB Teb = PsGetCurrentThread()->Tcb.Teb; - - if (NULL != Teb) - { - Teb->LastErrorValue = Status; - } -} - -NTSTATUS FASTCALL -GetLastNtError(VOID) -{ - PTEB Teb = PsGetCurrentThread()->Tcb.Teb; - - if ( NULL != Teb ) - { - return Teb->LastStatusValue; - } - return 0; -} - -/* EOF */ diff --git a/reactos/subsystems/win32/win32k/ntuser/accelerator.c b/reactos/subsystems/win32/win32k/ntuser/accelerator.c index cb0eca60d00..94b52d05af4 100644 --- a/reactos/subsystems/win32/win32k/ntuser/accelerator.c +++ b/reactos/subsystems/win32/win32k/ntuser/accelerator.c @@ -77,14 +77,14 @@ PACCELERATOR_TABLE FASTCALL UserGetAccelObject(HACCEL hAccel) if (!hAccel) { - SetLastWin32Error(ERROR_INVALID_ACCEL_HANDLE); + EngSetLastError(ERROR_INVALID_ACCEL_HANDLE); return NULL; } Accel= UserGetObject(gHandleTable, hAccel, otAccel); if (!Accel) { - SetLastWin32Error(ERROR_INVALID_ACCEL_HANDLE); + EngSetLastError(ERROR_INVALID_ACCEL_HANDLE); return NULL; } diff --git a/reactos/subsystems/win32/win32k/ntuser/caret.c b/reactos/subsystems/win32/win32k/ntuser/caret.c index 76d58a7120b..773d7d31428 100644 --- a/reactos/subsystems/win32/win32k/ntuser/caret.c +++ b/reactos/subsystems/win32/win32k/ntuser/caret.c @@ -73,7 +73,7 @@ IntSetCaretBlinkTime(UINT uMSeconds) /* windows doesn't do this check */ if((uMSeconds < MIN_CARETBLINKRATE) || (uMSeconds > MAX_CARETBLINKRATE)) { - SetLastWin32Error(ERROR_INVALID_PARAMETER); + EngSetLastError(ERROR_INVALID_PARAMETER); ObDereferenceObject(WinStaObject); return FALSE; } @@ -257,7 +257,7 @@ BOOL FASTCALL co_UserHideCaret(PWND Window OPTIONAL) if(Window && Window->head.pti->pEThread != PsGetCurrentThread()) { - SetLastWin32Error(ERROR_ACCESS_DENIED); + EngSetLastError(ERROR_ACCESS_DENIED); return FALSE; } @@ -266,7 +266,7 @@ BOOL FASTCALL co_UserHideCaret(PWND Window OPTIONAL) if(Window && ThreadQueue->CaretInfo->hWnd != Window->head.h) { - SetLastWin32Error(ERROR_ACCESS_DENIED); + EngSetLastError(ERROR_ACCESS_DENIED); return FALSE; } @@ -293,7 +293,7 @@ BOOL FASTCALL co_UserShowCaret(PWND Window OPTIONAL) if(Window && Window->head.pti->pEThread != PsGetCurrentThread()) { - SetLastWin32Error(ERROR_ACCESS_DENIED); + EngSetLastError(ERROR_ACCESS_DENIED); return FALSE; } @@ -302,7 +302,7 @@ BOOL FASTCALL co_UserShowCaret(PWND Window OPTIONAL) if(Window && ThreadQueue->CaretInfo->hWnd != Window->head.h) { - SetLastWin32Error(ERROR_ACCESS_DENIED); + EngSetLastError(ERROR_ACCESS_DENIED); return FALSE; } @@ -346,7 +346,7 @@ NtUserCreateCaret( if(Window->head.pti->pEThread != PsGetCurrentThread()) { - SetLastWin32Error(ERROR_ACCESS_DENIED); + EngSetLastError(ERROR_ACCESS_DENIED); RETURN(FALSE); } diff --git a/reactos/subsystems/win32/win32k/ntuser/class.c b/reactos/subsystems/win32/win32k/ntuser/class.c index 31c2970d1c3..cc9da7f886b 100644 --- a/reactos/subsystems/win32/win32k/ntuser/class.c +++ b/reactos/subsystems/win32/win32k/ntuser/class.c @@ -228,7 +228,7 @@ IntRegisterClassAtom(IN PUNICODE_STRING ClassName, /* FIXME - Don't limit to 64 characters! use SEH when allocating memory! */ if (ClassName->Length / sizeof(WCHAR) >= sizeof(szBuf) / sizeof(szBuf[0])) { - SetLastWin32Error(ERROR_INVALID_PARAMETER); + EngSetLastError(ERROR_INVALID_PARAMETER); return (RTL_ATOM)0; } @@ -557,7 +557,7 @@ IntGetClassForDesktop(IN OUT PCLS BaseClass, } else { - SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY); + EngSetLastError(ERROR_NOT_ENOUGH_MEMORY); } } return Class; @@ -832,7 +832,7 @@ IntCheckProcessDesktopClasses(IN PDESKTOP Desktop, if (!Ret) { DPRINT1("Failed to move process classes from desktop 0x%p to the shared heap!\n", Desktop); - SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY); + EngSetLastError(ERROR_NOT_ENOUGH_MEMORY); } return Ret; @@ -1034,7 +1034,7 @@ NoMem: IntDeregisterClassAtom(Atom); - SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY); + EngSetLastError(ERROR_NOT_ENOUGH_MEMORY); } return Class; @@ -1088,7 +1088,7 @@ IntGetAtomFromStringOrAtom(IN PUNICODE_STRING ClassName, /* FIXME - Don't limit to 64 characters! use SEH when allocating memory! */ if (ClassName->Length / sizeof(WCHAR) >= sizeof(szBuf) / sizeof(szBuf[0])) { - SetLastWin32Error(ERROR_INVALID_PARAMETER); + EngSetLastError(ERROR_INVALID_PARAMETER); return (RTL_ATOM)0; } @@ -1117,7 +1117,7 @@ IntGetAtomFromStringOrAtom(IN PUNICODE_STRING ClassName, { if (Status == STATUS_OBJECT_NAME_NOT_FOUND) { - SetLastWin32Error(ERROR_CLASS_DOES_NOT_EXIST); + EngSetLastError(ERROR_CLASS_DOES_NOT_EXIST); } else { @@ -1194,7 +1194,7 @@ IntGetClassAtom(IN PUNICODE_STRING ClassName, Link); if (Class == NULL) { - SetLastWin32Error(ERROR_CLASS_DOES_NOT_EXIST); + EngSetLastError(ERROR_CLASS_DOES_NOT_EXIST); return (RTL_ATOM)0; }else{DPRINT("Step 4: 0x%x\n",Class );} @@ -1240,7 +1240,7 @@ IntGetAndReferenceClass(PUNICODE_STRING ClassName, HINSTANCE hInstance) DPRINT1("Class \"%wZ\" not found\n", ClassName); } - SetLastWin32Error(ERROR_CANNOT_FIND_WND_CLASS); + EngSetLastError(ERROR_CANNOT_FIND_WND_CLASS); return NULL; } DPRINT("ClassAtom %x\n", ClassAtom); @@ -1289,7 +1289,7 @@ UserRegisterClass(IN CONST WNDCLASSEXW* lpwcx, { // local class already exists DPRINT("Local Class 0x%p does already exist!\n", ClassAtom); - SetLastWin32Error(ERROR_CLASS_ALREADY_EXISTS); + EngSetLastError(ERROR_CLASS_ALREADY_EXISTS); return (RTL_ATOM)0; } @@ -1303,7 +1303,7 @@ UserRegisterClass(IN CONST WNDCLASSEXW* lpwcx, if (Class != NULL && Class->Global) { DPRINT("Global Class 0x%p does already exist!\n", ClassAtom); - SetLastWin32Error(ERROR_CLASS_ALREADY_EXISTS); + EngSetLastError(ERROR_CLASS_ALREADY_EXISTS); return (RTL_ATOM)0; } } @@ -1373,7 +1373,7 @@ UserUnregisterClass(IN PUNICODE_STRING ClassName, Class->pclsClone != NULL) { DPRINT("UserUnregisterClass: Class has a Window. Ct %d : Clone 0x%x\n", Class->cWndReferenceCount, Class->pclsClone); - SetLastWin32Error(ERROR_CLASS_HAS_WINDOWS); + EngSetLastError(ERROR_CLASS_HAS_WINDOWS); return FALSE; } @@ -1445,7 +1445,7 @@ UserGetClassName(IN PCLS Class, USERTAG_CLASS); if (szTemp == NULL) { - SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY); + EngSetLastError(ERROR_NOT_ENOUGH_MEMORY); _SEH2_LEAVE; } @@ -1589,7 +1589,7 @@ IntSetClassMenuName(IN PCLS Class, } } else - SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY); + EngSetLastError(ERROR_NOT_ENOUGH_MEMORY); } else { @@ -1640,7 +1640,7 @@ UserSetClassLongPtr(IN PCLS Class, if (Index + sizeof(ULONG_PTR) < Index || Index + sizeof(ULONG_PTR) > Class->cbclsExtra) { - SetLastWin32Error(ERROR_INVALID_PARAMETER); + EngSetLastError(ERROR_INVALID_PARAMETER); return 0; } @@ -1680,7 +1680,7 @@ UserSetClassLongPtr(IN PCLS Class, break; case GCL_CBCLSEXTRA: - SetLastWin32Error(ERROR_INVALID_PARAMETER); + EngSetLastError(ERROR_INVALID_PARAMETER); break; case GCLP_HBRBACKGROUND: @@ -1803,7 +1803,7 @@ UserSetClassLongPtr(IN PCLS Class, } default: - SetLastWin32Error(ERROR_INVALID_INDEX); + EngSetLastError(ERROR_INVALID_INDEX); break; } @@ -1982,7 +1982,7 @@ NtUserRegisterClassExWOW( if (Flags & ~(CSF_ANSIPROC)) { DPRINT1("NtUserRegisterClassExWOW Bad Flags!\n"); - SetLastWin32Error(ERROR_INVALID_FLAGS); + EngSetLastError(ERROR_INVALID_FLAGS); return Ret; } @@ -2059,7 +2059,7 @@ NtUserRegisterClassExWOW( { DPRINT1("NtUserRegisterClassExWOW MenuName Error!\n"); InvalidParameter: - SetLastWin32Error(ERROR_INVALID_PARAMETER); + EngSetLastError(ERROR_INVALID_PARAMETER); _SEH2_LEAVE; } @@ -2114,7 +2114,7 @@ NtUserSetClassLong(HWND hWnd, { if (Window->head.pti->ppi != pi) { - SetLastWin32Error(ERROR_ACCESS_DENIED); + EngSetLastError(ERROR_ACCESS_DENIED); goto Cleanup; } @@ -2146,7 +2146,7 @@ NtUserSetClassLong(HWND hWnd, else if (Offset == GCLP_MENUNAME && !IS_INTRESOURCE(Value.Buffer)) { InvalidParameter: - SetLastWin32Error(ERROR_INVALID_PARAMETER); + EngSetLastError(ERROR_INVALID_PARAMETER); _SEH2_LEAVE; } } @@ -2215,7 +2215,7 @@ NtUserUnregisterClass(IN PUNICODE_STRING ClassNameOrAtom, if (!IS_ATOM(CapturedClassName.Buffer)) { InvalidParameter: - SetLastWin32Error(ERROR_INVALID_PARAMETER); + EngSetLastError(ERROR_INVALID_PARAMETER); _SEH2_LEAVE; } } @@ -2274,7 +2274,7 @@ NtUserGetClassInfo( if (CapturedClassName.Length & 1) { - SetLastWin32Error(ERROR_INVALID_PARAMETER); + EngSetLastError(ERROR_INVALID_PARAMETER); Ret = FALSE; _SEH2_LEAVE; } @@ -2299,7 +2299,7 @@ NtUserGetClassInfo( if (!IS_ATOM(CapturedClassName.Buffer)) { ERR("NtUserGetClassInfo() got ClassName instead of Atom!\n"); - SetLastWin32Error(ERROR_INVALID_PARAMETER); + EngSetLastError(ERROR_INVALID_PARAMETER); Ret = FALSE; _SEH2_LEAVE; } @@ -2342,7 +2342,7 @@ NtUserGetClassInfo( } else { - SetLastWin32Error(ERROR_CLASS_DOES_NOT_EXIST); + EngSetLastError(ERROR_CLASS_DOES_NOT_EXIST); Ret = FALSE; } } @@ -2363,7 +2363,7 @@ NtUserGetClassInfo( } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { - SetLastWin32Error(ERROR_CLASS_DOES_NOT_EXIST); + EngSetLastError(ERROR_CLASS_DOES_NOT_EXIST); Ret = FALSE; } _SEH2_END; @@ -2465,7 +2465,7 @@ NtUserGetWOWClass(HINSTANCE hInstance, } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { - SetLastWin32Error(ERROR_CLASS_DOES_NOT_EXIST); + EngSetLastError(ERROR_CLASS_DOES_NOT_EXIST); Hit = TRUE; } _SEH2_END; @@ -2479,7 +2479,7 @@ NtUserGetWOWClass(HINSTANCE hInstance, NULL); if (!ClassAtom) { - SetLastWin32Error(ERROR_CLASS_DOES_NOT_EXIST); + EngSetLastError(ERROR_CLASS_DOES_NOT_EXIST); } } diff --git a/reactos/subsystems/win32/win32k/ntuser/clipboard.c b/reactos/subsystems/win32/win32k/ntuser/clipboard.c index eca0d4d9f8c..b75cb2da3f5 100644 --- a/reactos/subsystems/win32/win32k/ntuser/clipboard.c +++ b/reactos/subsystems/win32/win32k/ntuser/clipboard.c @@ -78,7 +78,7 @@ IntAddWindowToChain(PWND window) wce = ExAllocatePoolWithTag(PagedPool, sizeof(CLIPBOARDCHAINELEMENT), USERTAG_CLIPBOARD); if (wce == NULL) { - SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY); + EngSetLastError(ERROR_NOT_ENOUGH_MEMORY); goto exit_addChain; } @@ -170,7 +170,7 @@ intAddFormatedData(UINT format, HANDLE hData, DWORD size) ce = ExAllocatePoolWithTag(PagedPool, sizeof(CLIPBOARDELEMENT), USERTAG_CLIPBOARD); if (ce == NULL) { - SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY); + EngSetLastError(ERROR_NOT_ENOUGH_MEMORY); } else { @@ -483,7 +483,7 @@ NtUserCloseClipboard(VOID) } else { - SetLastWin32Error(ERROR_CLIPBOARD_NOT_OPEN); + EngSetLastError(ERROR_CLIPBOARD_NOT_OPEN); } recentlySetClipboard = FALSE; @@ -595,7 +595,7 @@ NtUserEmptyClipboard(VOID) } else { - SetLastWin32Error(ERROR_CLIPBOARD_NOT_OPEN); + EngSetLastError(ERROR_CLIPBOARD_NOT_OPEN); } if (ret && ClipboardOwnerWindow) @@ -718,7 +718,7 @@ NtUserGetClipboardData(UINT uFormat, PVOID pBuffer) } else { - SetLastWin32Error(ERROR_CLIPBOARD_NOT_OPEN); + EngSetLastError(ERROR_CLIPBOARD_NOT_OPEN); } UserLeave(); @@ -742,7 +742,7 @@ NtUserGetClipboardFormatName(UINT format, PUNICODE_STRING FormatName, if((cchMaxCount < 1) || !FormatName) { - SetLastWin32Error(ERROR_INVALID_PARAMETER); + EngSetLastError(ERROR_INVALID_PARAMETER); return 0; } @@ -1143,7 +1143,7 @@ IntEnumClipboardFormats(UINT uFormat) } else { - SetLastWin32Error(ERROR_CLIPBOARD_NOT_OPEN); + EngSetLastError(ERROR_CLIPBOARD_NOT_OPEN); } return ret; diff --git a/reactos/subsystems/win32/win32k/ntuser/cursoricon.c b/reactos/subsystems/win32/win32k/ntuser/cursoricon.c index ce738a7093b..a2ee81234a8 100644 --- a/reactos/subsystems/win32/win32k/ntuser/cursoricon.c +++ b/reactos/subsystems/win32/win32k/ntuser/cursoricon.c @@ -83,7 +83,7 @@ PCURICON_OBJECT FASTCALL UserGetCurIconObject(HCURSOR hCurIcon) if (!hCurIcon) { - SetLastWin32Error(ERROR_INVALID_CURSOR_HANDLE); + EngSetLastError(ERROR_INVALID_CURSOR_HANDLE); return NULL; } @@ -91,7 +91,7 @@ PCURICON_OBJECT FASTCALL UserGetCurIconObject(HCURSOR hCurIcon) if (!CurIcon) { /* we never set ERROR_INVALID_ICON_HANDLE. lets hope noone ever checks for it */ - SetLastWin32Error(ERROR_INVALID_CURSOR_HANDLE); + EngSetLastError(ERROR_INVALID_CURSOR_HANDLE); return NULL; } @@ -347,7 +347,7 @@ IntCreateCurIconHandle() if (!CurIcon) { - SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY); + EngSetLastError(ERROR_NOT_ENOUGH_MEMORY); return FALSE; } @@ -508,7 +508,7 @@ NtUserGetIconInfo( if (!IconInfo) { - SetLastWin32Error(ERROR_INVALID_PARAMETER); + EngSetLastError(ERROR_INVALID_PARAMETER); goto leave; } @@ -655,7 +655,7 @@ NtUserGetCursorInfo( } else { - SetLastWin32Error(ERROR_INVALID_PARAMETER); + EngSetLastError(ERROR_INVALID_PARAMETER); } } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) @@ -727,7 +727,7 @@ NtUserClipCursor( } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { - SetLastWin32Error(ERROR_INVALID_PARAMETER); + EngSetLastError(ERROR_INVALID_PARAMETER); _SEH2_YIELD(return FALSE;) } _SEH2_END @@ -806,7 +806,7 @@ NtUserFindExistingCursorIcon( RETURN(Ret); } - SetLastWin32Error(ERROR_INVALID_CURSOR_HANDLE); + EngSetLastError(ERROR_INVALID_CURSOR_HANDLE); RETURN((HANDLE)0); CLEANUP: diff --git a/reactos/subsystems/win32/win32k/ntuser/desktop.c b/reactos/subsystems/win32/win32k/ntuser/desktop.c index 336f48d28ae..d279995599e 100644 --- a/reactos/subsystems/win32/win32k/ntuser/desktop.c +++ b/reactos/subsystems/win32/win32k/ntuser/desktop.c @@ -532,7 +532,7 @@ PWND FASTCALL UserGetDesktopWindow(VOID) HWND FASTCALL IntGetMessageWindow(VOID) { PDESKTOP pdo = IntGetActiveDesktop(); - + if (!pdo) { DPRINT("No active desktop\n"); @@ -598,7 +598,7 @@ UserGetDesktopDC(ULONG DcType, BOOL EmptyDC, BOOL ValidatehWnd) HDC DesktopHDC = 0; if (DcType == DC_TYPE_DIRECT) - { + { DesktopObject = UserGetDesktopWindow(); DesktopHDC = (HDC)UserGetWindowDC(DesktopObject); } @@ -724,7 +724,7 @@ VOID co_IntShellHookNotify(WPARAM Message, LPARAM lParam) DPRINT("MsgType = %x\n", MsgType); if (!MsgType) - DPRINT1("LastError: %x\n", GetLastNtError()); + DPRINT1("LastError: %x\n", EngGetLastError()); } if (!Desktop) @@ -1703,14 +1703,14 @@ NtUserGetThreadDesktop(DWORD dwThreadId, DWORD Unknown1) if(!dwThreadId) { - SetLastWin32Error(ERROR_INVALID_PARAMETER); + EngSetLastError(ERROR_INVALID_PARAMETER); RETURN(0); } Status = PsLookupThreadByThreadId((HANDLE)(DWORD_PTR)dwThreadId, &Thread); if(!NT_SUCCESS(Status)) { - SetLastWin32Error(ERROR_INVALID_PARAMETER); + EngSetLastError(ERROR_INVALID_PARAMETER); RETURN(0); } @@ -1903,7 +1903,7 @@ IntSetThreadDesktop(IN PDESKTOP DesktopObject, if (!IsListEmpty(&W32Thread->WindowListHead)) { DPRINT1("Attempted to change thread desktop although the thread has windows!\n"); - SetLastWin32Error(ERROR_BUSY); + EngSetLastError(ERROR_BUSY); return FALSE; } @@ -1931,7 +1931,7 @@ IntSetThreadDesktop(IN PDESKTOP DesktopObject, } if (!W32Thread->pcti && DesktopObject && NtCurrentTeb()) - { + { DPRINT("Allocate ClientThreadInfo\n"); W32Thread->pcti = DesktopHeapAlloc( DesktopObject, sizeof(CLIENTTHREADINFO)); diff --git a/reactos/subsystems/win32/win32k/ntuser/display.c b/reactos/subsystems/win32/win32k/ntuser/display.c index 5e8f50d0c51..e50b0032d8e 100644 --- a/reactos/subsystems/win32/win32k/ntuser/display.c +++ b/reactos/subsystems/win32/win32k/ntuser/display.c @@ -809,7 +809,7 @@ NtUserChangeDisplaySettings( if ((dwflags != CDS_VIDEOPARAMETERS && lParam != NULL) || (hwnd != NULL)) { - SetLastWin32Error(ERROR_INVALID_PARAMETER); + EngSetLastError(ERROR_INVALID_PARAMETER); return DISP_CHANGE_BADPARAM; } diff --git a/reactos/subsystems/win32/win32k/ntuser/event.c b/reactos/subsystems/win32/win32k/ntuser/event.c index cdc2092439a..18bde4ca040 100644 --- a/reactos/subsystems/win32/win32k/ntuser/event.c +++ b/reactos/subsystems/win32/win32k/ntuser/event.c @@ -345,7 +345,7 @@ NtUserSetWinEventHook( GlobalEvents = ExAllocatePoolWithTag(PagedPool, sizeof(EVENTTABLE), TAG_HOOK); if (GlobalEvents == NULL) { - SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY); + EngSetLastError(ERROR_NOT_ENOUGH_MEMORY); goto SetEventExit; } GlobalEvents->Counts = 0; @@ -354,19 +354,19 @@ NtUserSetWinEventHook( if (eventMin > eventMax) { - SetLastWin32Error(ERROR_INVALID_HOOK_FILTER); + EngSetLastError(ERROR_INVALID_HOOK_FILTER); goto SetEventExit; } if (!lpfnWinEventProc) { - SetLastWin32Error(ERROR_INVALID_FILTER_PROC); + EngSetLastError(ERROR_INVALID_FILTER_PROC); goto SetEventExit; } if ((dwflags & WINEVENT_INCONTEXT) && !hmodWinEventProc) { - SetLastWin32Error(ERROR_HOOK_NEEDS_HMOD); + EngSetLastError(ERROR_HOOK_NEEDS_HMOD); goto SetEventExit; } @@ -375,7 +375,7 @@ NtUserSetWinEventHook( Status = PsLookupThreadByThreadId((HANDLE)(DWORD_PTR)idThread, &Thread); if (!NT_SUCCESS(Status)) { - SetLastWin32Error(ERROR_INVALID_THREAD_ID); + EngSetLastError(ERROR_INVALID_THREAD_ID); goto SetEventExit; } } diff --git a/reactos/subsystems/win32/win32k/ntuser/focus.c b/reactos/subsystems/win32/win32k/ntuser/focus.c index 21d4f73d6a8..67273cc4480 100644 --- a/reactos/subsystems/win32/win32k/ntuser/focus.c +++ b/reactos/subsystems/win32/win32k/ntuser/focus.c @@ -492,7 +492,7 @@ NtUserSetActiveWindow(HWND hWnd) if (Window->head.pti->MessageQueue != ThreadQueue) { - SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE); + EngSetLastError(ERROR_INVALID_WINDOW_HANDLE); RETURN( 0); } @@ -614,7 +614,7 @@ HWND FASTCALL co_UserSetFocus(PWND Wnd OPTIONAL) if (Wnd->head.pti->MessageQueue != ThreadQueue) { - SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE); + EngSetLastError(ERROR_INVALID_WINDOW_HANDLE); return( 0); } diff --git a/reactos/subsystems/win32/win32k/ntuser/hook.c b/reactos/subsystems/win32/win32k/ntuser/hook.c index f41d7bad0ce..41e9d476bf9 100644 --- a/reactos/subsystems/win32/win32k/ntuser/hook.c +++ b/reactos/subsystems/win32/win32k/ntuser/hook.c @@ -725,14 +725,14 @@ IntGetHookObject(HHOOK hHook) if (!hHook) { - SetLastWin32Error(ERROR_INVALID_HOOK_HANDLE); + EngSetLastError(ERROR_INVALID_HOOK_HANDLE); return NULL; } Hook = (PHOOK)UserGetObject(gHandleTable, hHook, otHook); if (!Hook) { - SetLastWin32Error(ERROR_INVALID_HOOK_HANDLE); + EngSetLastError(ERROR_INVALID_HOOK_HANDLE); return NULL; } @@ -1120,7 +1120,7 @@ IntUnhookWindowsHook(int HookId, HOOKPROC pfnFilterProc) if (HookId < WH_MINHOOK || WH_MAXHOOK < HookId ) { - SetLastWin32Error(ERROR_INVALID_HOOK_FILTER); + EngSetLastError(ERROR_INVALID_HOOK_FILTER); return FALSE; } @@ -1145,7 +1145,7 @@ IntUnhookWindowsHook(int HookId, HOOKPROC pfnFilterProc) } else { - SetLastWin32Error(ERROR_ACCESS_DENIED); + EngSetLastError(ERROR_ACCESS_DENIED); return FALSE; } } @@ -1260,13 +1260,13 @@ NtUserSetWindowsHookEx( HINSTANCE Mod, if (HookId < WH_MINHOOK || WH_MAXHOOK < HookId ) { - SetLastWin32Error(ERROR_INVALID_HOOK_FILTER); + EngSetLastError(ERROR_INVALID_HOOK_FILTER); RETURN( NULL); } if (!HookProc) { - SetLastWin32Error(ERROR_INVALID_FILTER_PROC); + EngSetLastError(ERROR_INVALID_FILTER_PROC); RETURN( NULL); } @@ -1280,14 +1280,14 @@ NtUserSetWindowsHookEx( HINSTANCE Mod, { DPRINT1("Local hook installing Global HookId: %d\n",HookId); /* these can only be global */ - SetLastWin32Error(ERROR_GLOBAL_ONLY_HOOK); + EngSetLastError(ERROR_GLOBAL_ONLY_HOOK); RETURN( NULL); } if (!NT_SUCCESS(PsLookupThreadByThreadId((HANDLE)(DWORD_PTR) ThreadId, &Thread))) { DPRINT1("Invalid thread id 0x%x\n", ThreadId); - SetLastWin32Error(ERROR_INVALID_PARAMETER); + EngSetLastError(ERROR_INVALID_PARAMETER); RETURN( NULL); } @@ -1298,7 +1298,7 @@ NtUserSetWindowsHookEx( HINSTANCE Mod, if ( pti->rpdesk != ptiCurrent->rpdesk) // gptiCurrent->rpdesk) { DPRINT1("Local hook wrong desktop HookId: %d\n",HookId); - SetLastWin32Error(ERROR_ACCESS_DENIED); + EngSetLastError(ERROR_ACCESS_DENIED); RETURN( NULL); } @@ -1315,7 +1315,7 @@ NtUserSetWindowsHookEx( HINSTANCE Mod, HookId == WH_CALLWNDPROCRET) ) { DPRINT1("Local hook needs hMod HookId: %d\n",HookId); - SetLastWin32Error(ERROR_HOOK_NEEDS_HMOD); + EngSetLastError(ERROR_HOOK_NEEDS_HMOD); RETURN( NULL); } @@ -1329,7 +1329,7 @@ NtUserSetWindowsHookEx( HINSTANCE Mod, HookId == WH_FOREGROUNDIDLE || HookId == WH_CALLWNDPROCRET) ) { - SetLastWin32Error(ERROR_HOOK_TYPE_NOT_ALLOWED); + EngSetLastError(ERROR_HOOK_TYPE_NOT_ALLOWED); RETURN( NULL); } } @@ -1349,7 +1349,7 @@ NtUserSetWindowsHookEx( HINSTANCE Mod, HookId == WH_CALLWNDPROCRET) ) { DPRINT1("Global hook needs hMod HookId: %d\n",HookId); - SetLastWin32Error(ERROR_HOOK_NEEDS_HMOD); + EngSetLastError(ERROR_HOOK_NEEDS_HMOD); RETURN( NULL); } } @@ -1460,7 +1460,7 @@ NtUserSetWindowsHookEx( HINSTANCE Mod, if (NULL == Hook->ModuleName.Buffer) { IntRemoveHook(Hook); - SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY); + EngSetLastError(ERROR_NOT_ENOUGH_MEMORY); RETURN( NULL); } diff --git a/reactos/subsystems/win32/win32k/ntuser/input.c b/reactos/subsystems/win32/win32k/ntuser/input.c index 13d9fc02e02..e431ba7694a 100644 --- a/reactos/subsystems/win32/win32k/ntuser/input.c +++ b/reactos/subsystems/win32/win32k/ntuser/input.c @@ -81,7 +81,7 @@ NtUserGetLastInputInfo(PLASTINPUTINFO plii) { if (ProbeForReadUint(&plii->cbSize) != sizeof(LASTINPUTINFO)) { - SetLastWin32Error(ERROR_INVALID_PARAMETER); + EngSetLastError(ERROR_INVALID_PARAMETER); ret = FALSE; _SEH2_LEAVE; } @@ -1027,7 +1027,7 @@ IntBlockInput(PTHREADINFO W32Thread, BOOL BlockIt) if(!ThreadHasInputAccess(W32Thread) || !IntIsActiveDesktop(W32Thread->rpdesk)) { - SetLastWin32Error(ERROR_ACCESS_DENIED); + EngSetLastError(ERROR_ACCESS_DENIED); return FALSE; } @@ -1037,7 +1037,7 @@ IntBlockInput(PTHREADINFO W32Thread, BOOL BlockIt) { if(OldBlock != W32Thread) { - SetLastWin32Error(ERROR_ACCESS_DENIED); + EngSetLastError(ERROR_ACCESS_DENIED); return FALSE; } W32Thread->rpdesk->BlockInputThread = (BlockIt ? W32Thread : NULL); @@ -1481,7 +1481,7 @@ NtUserSendInput( if(!nInputs || !pInput || (cbSize != sizeof(INPUT))) { - SetLastWin32Error(ERROR_INVALID_PARAMETER); + EngSetLastError(ERROR_INVALID_PARAMETER); RETURN( 0); } @@ -1492,7 +1492,7 @@ NtUserSendInput( if(!ThreadHasInputAccess(W32Thread) || !IntIsActiveDesktop(W32Thread->rpdesk)) { - SetLastWin32Error(ERROR_ACCESS_DENIED); + EngSetLastError(ERROR_ACCESS_DENIED); RETURN( 0); } diff --git a/reactos/subsystems/win32/win32k/ntuser/kbdlayout.c b/reactos/subsystems/win32/win32k/ntuser/kbdlayout.c index a6ac6e68bfb..dc5c1393b53 100644 --- a/reactos/subsystems/win32/win32k/ntuser/kbdlayout.c +++ b/reactos/subsystems/win32/win32k/ntuser/kbdlayout.c @@ -453,7 +453,7 @@ UserGetKeyboardLayout( Status = PsLookupThreadByThreadId((HANDLE)(DWORD_PTR)dwThreadId, &Thread); if(!NT_SUCCESS(Status)) { - SetLastWin32Error(ERROR_INVALID_PARAMETER); + EngSetLastError(ERROR_INVALID_PARAMETER); return NULL; } diff --git a/reactos/subsystems/win32/win32k/ntuser/menu.c b/reactos/subsystems/win32/win32k/ntuser/menu.c index 08700461f6f..b205fd62ef3 100644 --- a/reactos/subsystems/win32/win32k/ntuser/menu.c +++ b/reactos/subsystems/win32/win32k/ntuser/menu.c @@ -106,14 +106,14 @@ PMENU_OBJECT FASTCALL UserGetMenuObject(HMENU hMenu) if (!hMenu) { - SetLastWin32Error(ERROR_INVALID_MENU_HANDLE); + EngSetLastError(ERROR_INVALID_MENU_HANDLE); return NULL; } Menu = (PMENU_OBJECT)UserGetObject(gHandleTable, hMenu, otMenu); if (!Menu) { - SetLastWin32Error(ERROR_INVALID_MENU_HANDLE); + EngSetLastError(ERROR_INVALID_MENU_HANDLE); return NULL; } @@ -861,7 +861,7 @@ IntInsertMenuItem(PMENU_OBJECT MenuObject, UINT uItem, BOOL fByPosition, if (MAX_MENU_ITEMS <= MenuObject->MenuInfo.MenuItemCount) { - SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY); + EngSetLastError(ERROR_NOT_ENOUGH_MEMORY); return FALSE; } @@ -894,7 +894,7 @@ IntInsertMenuItem(PMENU_OBJECT MenuObject, UINT uItem, BOOL fByPosition, MenuItem = ExAllocatePoolWithTag(PagedPool, sizeof(MENU_ITEM), TAG_MENUITEM); if (NULL == MenuItem) { - SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY); + EngSetLastError(ERROR_NOT_ENOUGH_MEMORY); return FALSE; } @@ -1420,7 +1420,7 @@ intGetTitleBarInfo(PWND pWindowObject, PTITLEBARINFO bti) } else { - SetLastWin32Error(ERROR_INVALID_PARAMETER); + EngSetLastError(ERROR_INVALID_PARAMETER); retValue = FALSE; } @@ -1444,7 +1444,7 @@ UserInsertMenuItem( if (sizeof(MENUITEMINFOW) != ItemInfo.cbSize && FIELD_OFFSET(MENUITEMINFOW, hbmpItem) != ItemInfo.cbSize) { - SetLastWin32Error(ERROR_INVALID_PARAMETER); + EngSetLastError(ERROR_INVALID_PARAMETER); return FALSE; } return IntInsertMenuItem(Menu, uItem, fByPosition, &ItemInfo); @@ -1456,7 +1456,7 @@ UserInsertMenuItem( { if (FIELD_OFFSET(MENUITEMINFOW, hbmpItem) != ItemInfo.cbSize) { - SetLastWin32Error(ERROR_INVALID_PARAMETER); + EngSetLastError(ERROR_INVALID_PARAMETER); return FALSE; } ItemInfo.hbmpItem = (HBITMAP)0; @@ -1584,7 +1584,7 @@ NtUserGetTitleBarInfo( /* Vaildate the windows handle */ if (!(WindowObject = UserGetWindowObject(hwnd))) { - SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE); + EngSetLastError(ERROR_INVALID_WINDOW_HANDLE); retValue = FALSE; } @@ -1597,7 +1597,7 @@ NtUserGetTitleBarInfo( _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { /* Fail copy the data */ - SetLastWin32Error(ERROR_INVALID_PARAMETER); + EngSetLastError(ERROR_INVALID_PARAMETER); retValue = FALSE; } _SEH2_END @@ -1617,7 +1617,7 @@ NtUserGetTitleBarInfo( _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { /* Fail copy the data */ - SetLastWin32Error(ERROR_INVALID_PARAMETER); + EngSetLastError(ERROR_INVALID_PARAMETER); retValue = FALSE; } _SEH2_END @@ -1646,7 +1646,7 @@ BOOL FASTCALL UserDestroyMenu(HMENU hMenu) if(Menu->Process != PsGetCurrentProcess()) { - SetLastWin32Error(ERROR_ACCESS_DENIED); + EngSetLastError(ERROR_ACCESS_DENIED); return FALSE; } @@ -1673,7 +1673,7 @@ NtUserDestroyMenu( if(Menu->Process != PsGetCurrentProcess()) { - SetLastWin32Error(ERROR_ACCESS_DENIED); + EngSetLastError(ERROR_ACCESS_DENIED); RETURN( FALSE); } @@ -1738,7 +1738,7 @@ NtUserGetMenuBarInfo( if (!(WindowObject = UserGetWindowObject(hwnd))) { - SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE); + EngSetLastError(ERROR_INVALID_WINDOW_HANDLE); RETURN(FALSE); } @@ -1746,13 +1746,13 @@ NtUserGetMenuBarInfo( if (!(MenuObject = UserGetMenuObject(hMenu))) { - SetLastWin32Error(ERROR_INVALID_MENU_HANDLE); + EngSetLastError(ERROR_INVALID_MENU_HANDLE); RETURN(FALSE); } if (pmbi->cbSize != sizeof(MENUBARINFO)) { - SetLastWin32Error(ERROR_INVALID_PARAMETER); + EngSetLastError(ERROR_INVALID_PARAMETER); RETURN(FALSE); } @@ -2097,7 +2097,7 @@ UserMenuInfo( } if(Size < sizeof(MENUINFO) || sizeof(ROSMENUINFO) < Size) { - SetLastWin32Error(ERROR_INVALID_PARAMETER); + EngSetLastError(ERROR_INVALID_PARAMETER); return( FALSE); } Status = MmCopyFromCaller(&MenuInfo, UnsafeMenuInfo, Size); @@ -2205,7 +2205,7 @@ UserMenuItemInfo( && FIELD_OFFSET(MENUITEMINFOW, hbmpItem) != Size && sizeof(ROSMENUITEMINFO) != Size) { - SetLastWin32Error(ERROR_INVALID_PARAMETER); + EngSetLastError(ERROR_INVALID_PARAMETER); return( FALSE); } Status = MmCopyFromCaller(&ItemInfo, UnsafeItemInfo, Size); @@ -2219,7 +2219,7 @@ UserMenuItemInfo( if (FIELD_OFFSET(MENUITEMINFOW, hbmpItem) == Size && 0 != (ItemInfo.fMask & MIIM_BITMAP)) { - SetLastWin32Error(ERROR_INVALID_PARAMETER); + EngSetLastError(ERROR_INVALID_PARAMETER); return( FALSE); } @@ -2227,7 +2227,7 @@ UserMenuItemInfo( (ByPosition ? MF_BYPOSITION : MF_BYCOMMAND), NULL, &MenuItem, NULL) < 0) { - SetLastWin32Error(ERROR_INVALID_PARAMETER); + EngSetLastError(ERROR_INVALID_PARAMETER); return( FALSE); } diff --git a/reactos/subsystems/win32/win32k/ntuser/message.c b/reactos/subsystems/win32/win32k/ntuser/message.c index 8f8eec23cd3..56cfc304f4e 100644 --- a/reactos/subsystems/win32/win32k/ntuser/message.c +++ b/reactos/subsystems/win32/win32k/ntuser/message.c @@ -529,7 +529,7 @@ IntDispatchMessage(PMSG pMsg) if ( Window->head.pti != pti) { - SetLastWin32Error( ERROR_MESSAGE_SYNC_ONLY ); + EngSetLastError( ERROR_MESSAGE_SYNC_ONLY ); return 0; } @@ -912,7 +912,7 @@ UserPostThreadMessage( DWORD idThread, if (FindMsgMemory(Msg) != 0) { - SetLastWin32Error(ERROR_MESSAGE_SYNC_ONLY ); + EngSetLastError(ERROR_MESSAGE_SYNC_ONLY ); return FALSE; } @@ -976,7 +976,7 @@ UserPostMessage( HWND Wnd, Status = CopyMsgToKernelMem(&KernelModeMsg, &Message, MsgMemoryEntry); if (! NT_SUCCESS(Status)) { - SetLastWin32Error(ERROR_INVALID_PARAMETER); + EngSetLastError(ERROR_INVALID_PARAMETER); return FALSE; } co_IntSendMessageNoWait(KernelModeMsg.hwnd, @@ -992,7 +992,7 @@ UserPostMessage( HWND Wnd, if (MsgMemoryEntry) { - SetLastWin32Error(ERROR_MESSAGE_SYNC_ONLY ); + EngSetLastError(ERROR_MESSAGE_SYNC_ONLY ); return FALSE; } @@ -1196,7 +1196,7 @@ MSDN says: To get extended error information, call GetLastError. If GetLastError returns ERROR_TIMEOUT, then the function timed out. */ - SetLastWin32Error(ERROR_TIMEOUT); + EngSetLastError(ERROR_TIMEOUT); RETURN( FALSE); } else if (! NT_SUCCESS(Status)) @@ -1233,7 +1233,7 @@ co_IntSendMessageTimeout( HWND hWnd, DesktopWindow = UserGetWindowObject(IntGetDesktopWindow()); if (NULL == DesktopWindow) { - SetLastWin32Error(ERROR_INTERNAL_ERROR); + EngSetLastError(ERROR_INTERNAL_ERROR); return 0; } @@ -1446,7 +1446,7 @@ co_IntDoSendMessage( HWND hWnd, Status = CopyMsgToKernelMem(&KernelModeMsg, &UserModeMsg, MsgMemoryEntry); if (! NT_SUCCESS(Status)) { - SetLastWin32Error(ERROR_INVALID_PARAMETER); + EngSetLastError(ERROR_INVALID_PARAMETER); return (dsm ? 0 : -1); } @@ -1471,7 +1471,7 @@ co_IntDoSendMessage( HWND hWnd, Status = CopyMsgToUserMem(&UserModeMsg, &KernelModeMsg); if (! NT_SUCCESS(Status)) { - SetLastWin32Error(ERROR_INVALID_PARAMETER); + EngSetLastError(ERROR_INVALID_PARAMETER); return(dsm ? 0 : -1); } @@ -1488,7 +1488,7 @@ UserSendNotifyMessage( HWND hWnd, if (FindMsgMemory(Msg) != 0) { - SetLastWin32Error(ERROR_MESSAGE_SYNC_ONLY ); + EngSetLastError(ERROR_MESSAGE_SYNC_ONLY ); return FALSE; } @@ -1646,7 +1646,7 @@ NtUserGetMessage(PMSG pMsg, if ( (MsgFilterMin|MsgFilterMax) & ~WM_MAXIMUM ) { - SetLastWin32Error(ERROR_INVALID_PARAMETER); + EngSetLastError(ERROR_INVALID_PARAMETER); return FALSE; } @@ -1688,7 +1688,7 @@ NtUserPeekMessage( PMSG pMsg, if ( RemoveMsg & PM_BADMSGFLAGS ) { - SetLastWin32Error(ERROR_INVALID_FLAGS); + EngSetLastError(ERROR_INVALID_FLAGS); return FALSE; } @@ -2145,7 +2145,7 @@ NtUserWaitForInputIdle( IN HANDLE hProcess, { ObDereferenceObject(Process); UserLeave(); - SetLastWin32Error(ERROR_INVALID_PARAMETER); + EngSetLastError(ERROR_INVALID_PARAMETER); return WAIT_FAILED; } diff --git a/reactos/subsystems/win32/win32k/ntuser/misc.c b/reactos/subsystems/win32/win32k/ntuser/misc.c index eb6a066bd55..3a6b0e3f9d3 100644 --- a/reactos/subsystems/win32/win32k/ntuser/misc.c +++ b/reactos/subsystems/win32/win32k/ntuser/misc.c @@ -194,7 +194,7 @@ NtUserGetGUIThreadInfo( if(SafeGui.cbSize != sizeof(GUITHREADINFO)) { - SetLastWin32Error(ERROR_INVALID_PARAMETER); + EngSetLastError(ERROR_INVALID_PARAMETER); RETURN( FALSE); } @@ -203,7 +203,7 @@ NtUserGetGUIThreadInfo( Status = PsLookupThreadByThreadId((HANDLE)(DWORD_PTR)idThread, &Thread); if(!NT_SUCCESS(Status)) { - SetLastWin32Error(ERROR_ACCESS_DENIED); + EngSetLastError(ERROR_ACCESS_DENIED); RETURN( FALSE); } Desktop = ((PTHREADINFO)Thread->Tcb.Win32Thread)->rpdesk; @@ -227,7 +227,7 @@ NtUserGetGUIThreadInfo( { if(idThread && Thread) ObDereferenceObject(Thread); - SetLastWin32Error(ERROR_ACCESS_DENIED); + EngSetLastError(ERROR_ACCESS_DENIED); RETURN( FALSE); } @@ -305,7 +305,7 @@ NtUserGetGuiResources( if(!W32Process) { ObDereferenceObject(Process); - SetLastWin32Error(ERROR_INVALID_PARAMETER); + EngSetLastError(ERROR_INVALID_PARAMETER); RETURN( 0); } @@ -323,7 +323,7 @@ NtUserGetGuiResources( } default: { - SetLastWin32Error(ERROR_INVALID_PARAMETER); + EngSetLastError(ERROR_INVALID_PARAMETER); break; } } diff --git a/reactos/subsystems/win32/win32k/ntuser/monitor.c b/reactos/subsystems/win32/win32k/ntuser/monitor.c index b766e951da9..9dd49ef08b8 100644 --- a/reactos/subsystems/win32/win32k/ntuser/monitor.c +++ b/reactos/subsystems/win32/win32k/ntuser/monitor.c @@ -101,14 +101,14 @@ UserGetMonitorObject(IN HMONITOR hMonitor) if (!hMonitor) { - SetLastWin32Error(ERROR_INVALID_MONITOR_HANDLE); + EngSetLastError(ERROR_INVALID_MONITOR_HANDLE); return NULL; } Monitor = (PMONITOR)UserGetObject(gHandleTable, hMonitor, otMonitor); if (!Monitor) { - SetLastWin32Error(ERROR_INVALID_MONITOR_HANDLE); + EngSetLastError(ERROR_INVALID_MONITOR_HANDLE); return NULL; } @@ -523,7 +523,7 @@ NtUserEnumDisplayMonitors( safeHMonitorList = ExAllocatePoolWithTag(PagedPool, sizeof (HMONITOR) * listSize, USERTAG_MONITORRECTS); if (safeHMonitorList == NULL) { - /* FIXME: SetLastWin32Error? */ + /* FIXME: EngSetLastError? */ return -1; } } @@ -533,7 +533,7 @@ NtUserEnumDisplayMonitors( if (safeRectList == NULL) { ExFreePoolWithTag(safeHMonitorList, USERTAG_MONITORRECTS); - /* FIXME: SetLastWin32Error? */ + /* FIXME: EngSetLastError? */ return -1; } } @@ -773,7 +773,7 @@ NtUserMonitorFromRect( USERTAG_MONITORRECTS); if (hMonitorList == NULL) { - /* FIXME: SetLastWin32Error? */ + /* FIXME: EngSetLastError? */ return (HMONITOR)NULL; } @@ -783,7 +783,7 @@ NtUserMonitorFromRect( if (rectList == NULL) { ExFreePoolWithTag(hMonitorList, USERTAG_MONITORRECTS); - /* FIXME: SetLastWin32Error? */ + /* FIXME: EngSetLastError? */ return (HMONITOR)NULL; } diff --git a/reactos/subsystems/win32/win32k/ntuser/ntstubs.c b/reactos/subsystems/win32/win32k/ntuser/ntstubs.c index 401af3de778..445bdd500f7 100644 --- a/reactos/subsystems/win32/win32k/ntuser/ntstubs.c +++ b/reactos/subsystems/win32/win32k/ntuser/ntstubs.c @@ -40,13 +40,13 @@ NtUserAttachThreadInput( Status = PsLookupThreadByThreadId((HANDLE)idAttach, &Thread); if (!NT_SUCCESS(Status)) { - SetLastWin32Error(ERROR_INVALID_PARAMETER); + EngSetLastError(ERROR_INVALID_PARAMETER); goto Exit; } Status = PsLookupThreadByThreadId((HANDLE)idAttachTo, &ThreadTo); if (!NT_SUCCESS(Status)) { - SetLastWin32Error(ERROR_INVALID_PARAMETER); + EngSetLastError(ERROR_INVALID_PARAMETER); ObDereferenceObject(Thread); goto Exit; } @@ -292,7 +292,7 @@ NtUserGetMouseMovePointsEx( if ((cbSize != sizeof(MOUSEMOVEPOINT)) || (nBufPoints < 0) || (nBufPoints > 64)) { UserLeave(); - SetLastWin32Error(ERROR_INVALID_PARAMETER); + EngSetLastError(ERROR_INVALID_PARAMETER); return -1; } @@ -304,7 +304,7 @@ NtUserGetMouseMovePointsEx( _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { SetLastNtError(_SEH2_GetExceptionCode()); - SetLastWin32Error(ERROR_NOACCESS); + EngSetLastError(ERROR_NOACCESS); } _SEH2_END; @@ -316,7 +316,7 @@ NtUserGetMouseMovePointsEx( case GMMP_USE_HIGH_RESOLUTION_POINTS: break; default: - SetLastWin32Error(GMMP_ERR_POINT_NOT_FOUND); + EngSetLastError(GMMP_ERR_POINT_NOT_FOUND); return GMMP_ERR_POINT_NOT_FOUND; } */ diff --git a/reactos/subsystems/win32/win32k/ntuser/object.c b/reactos/subsystems/win32/win32k/ntuser/object.c index 222b36cb6b8..8376f0bfd84 100644 --- a/reactos/subsystems/win32/win32k/ntuser/object.c +++ b/reactos/subsystems/win32/win32k/ntuser/object.c @@ -220,7 +220,7 @@ PVOID UserGetObject(PUSER_HANDLE_TABLE ht, HANDLE handle, USER_OBJECT_TYPE type if (!(entry = handle_to_entry(ht, handle )) || entry->type != type) { - SetLastWin32Error(ERROR_INVALID_HANDLE); + EngSetLastError(ERROR_INVALID_HANDLE); return NULL; } return entry->ptr; diff --git a/reactos/subsystems/win32/win32k/ntuser/painting.c b/reactos/subsystems/win32/win32k/ntuser/painting.c index 6cc9b5a15bd..e78a0442a45 100644 --- a/reactos/subsystems/win32/win32k/ntuser/painting.c +++ b/reactos/subsystems/win32/win32k/ntuser/painting.c @@ -1083,7 +1083,7 @@ NtUserGetUpdateRect(HWND hWnd, LPRECT UnsafeRect, BOOL bErase) Status = MmCopyToCaller(UnsafeRect, &Rect, sizeof(RECTL)); if (!NT_SUCCESS(Status)) { - SetLastWin32Error(ERROR_INVALID_PARAMETER); + EngSetLastError(ERROR_INVALID_PARAMETER); RETURN(FALSE); } } @@ -1139,7 +1139,7 @@ NtUserRedrawWindow( _SEH2_END if (!NT_SUCCESS(Status)) { - SetLastWin32Error(RtlNtStatusToDosError(Status)); + EngSetLastError(RtlNtStatusToDosError(Status)); RETURN( FALSE); } } @@ -1149,7 +1149,7 @@ NtUserRedrawWindow( RDW_ERASENOW|RDW_UPDATENOW|RDW_ALLCHILDREN|RDW_NOCHILDREN) ) { /* RedrawWindow fails only in case that flags are invalid */ - SetLastWin32Error(ERROR_INVALID_FLAGS); + EngSetLastError(ERROR_INVALID_FLAGS); RETURN( FALSE); } @@ -2075,7 +2075,7 @@ NtUserPrintWindow( if ( (nFlags & PW_CLIENTONLY) == nFlags) Ret = IntPrintWindow( Window, hdcBlt, nFlags); else - SetLastWin32Error(ERROR_INVALID_PARAMETER); + EngSetLastError(ERROR_INVALID_PARAMETER); } } diff --git a/reactos/subsystems/win32/win32k/ntuser/scrollbar.c b/reactos/subsystems/win32/win32k/ntuser/scrollbar.c index 84ed568c9ed..cc6c9d0c912 100644 --- a/reactos/subsystems/win32/win32k/ntuser/scrollbar.c +++ b/reactos/subsystems/win32/win32k/ntuser/scrollbar.c @@ -183,7 +183,7 @@ co_IntGetScrollInfo(PWND Window, INT nBar, LPSCROLLINFO lpsi) if(!SBID_IS_VALID(nBar)) { - SetLastWin32Error(ERROR_INVALID_PARAMETER); + EngSetLastError(ERROR_INVALID_PARAMETER); DPRINT1("Trying to get scrollinfo for unknown scrollbar type %d\n", nBar); return FALSE; } @@ -240,7 +240,7 @@ NEWco_IntGetScrollInfo( if (!SBID_IS_VALID(nBar)) { - SetLastWin32Error(ERROR_INVALID_PARAMETER); + EngSetLastError(ERROR_INVALID_PARAMETER); DPRINT1("Trying to get scrollinfo for unknown scrollbar type %d\n", nBar); return FALSE; } @@ -292,7 +292,7 @@ co_IntSetScrollInfo(PWND Window, INT nBar, LPCSCROLLINFO lpsi, BOOL bRedraw) if(!SBID_IS_VALID(nBar)) { - SetLastWin32Error(ERROR_INVALID_PARAMETER); + EngSetLastError(ERROR_INVALID_PARAMETER); DPRINT1("Trying to set scrollinfo for unknown scrollbar type %d", nBar); return FALSE; } @@ -305,12 +305,12 @@ co_IntSetScrollInfo(PWND Window, INT nBar, LPCSCROLLINFO lpsi, BOOL bRedraw) if (lpsi->cbSize != sizeof(SCROLLINFO) && lpsi->cbSize != (sizeof(SCROLLINFO) - sizeof(lpsi->nTrackPos))) { - SetLastWin32Error(ERROR_INVALID_PARAMETER); + EngSetLastError(ERROR_INVALID_PARAMETER); return 0; } if (lpsi->fMask & ~(SIF_ALL | SIF_DISABLENOSCROLL)) { - SetLastWin32Error(ERROR_INVALID_PARAMETER); + EngSetLastError(ERROR_INVALID_PARAMETER); return 0; } @@ -442,7 +442,7 @@ co_IntGetScrollBarInfo(PWND Window, LONG idObject, PSCROLLBARINFO psbi) if(!SBID_IS_VALID(Bar)) { - SetLastWin32Error(ERROR_INVALID_PARAMETER); + EngSetLastError(ERROR_INVALID_PARAMETER); DPRINT1("Trying to get scrollinfo for unknown scrollbar type %d\n", Bar); return FALSE; } @@ -703,7 +703,7 @@ NtUserEnableScrollBar( if(wSBflags != SB_BOTH && !SBID_IS_VALID(wSBflags)) { - SetLastWin32Error(ERROR_INVALID_PARAMETER); + EngSetLastError(ERROR_INVALID_PARAMETER); DPRINT1("Trying to set scrollinfo for unknown scrollbar type %d", wSBflags); RETURN(FALSE); } @@ -776,7 +776,7 @@ NtUserSetScrollBarInfo( Obj = SBOBJ_TO_SBID(idObject); if(!SBID_IS_VALID(Obj)) { - SetLastWin32Error(ERROR_INVALID_PARAMETER); + EngSetLastError(ERROR_INVALID_PARAMETER); DPRINT1("Trying to set scrollinfo for unknown scrollbar type %d\n", Obj); RETURN( FALSE); } @@ -876,7 +876,7 @@ co_UserShowScrollBar(PWND Wnd, int wBar, DWORD bShow) Style = 0; break; default: - SetLastWin32Error(ERROR_INVALID_PARAMETER); + EngSetLastError(ERROR_INVALID_PARAMETER); return( FALSE); } diff --git a/reactos/subsystems/win32/win32k/ntuser/simplecall.c b/reactos/subsystems/win32/win32k/ntuser/simplecall.c index d1c5e0bec90..941d31a4f63 100644 --- a/reactos/subsystems/win32/win32k/ntuser/simplecall.c +++ b/reactos/subsystems/win32/win32k/ntuser/simplecall.c @@ -28,7 +28,7 @@ co_IntRegisterLogonProcess(HANDLE ProcessId, BOOL Register) &Process); if (!NT_SUCCESS(Status)) { - SetLastWin32Error(RtlNtStatusToDosError(Status)); + EngSetLastError(RtlNtStatusToDosError(Status)); return FALSE; } @@ -121,7 +121,7 @@ NtUserCallNoParam(DWORD Routine) default: DPRINT1("Calling invalid routine number 0x%x in NtUserCallNoParam\n", Routine); - SetLastWin32Error(ERROR_INVALID_PARAMETER); + EngSetLastError(ERROR_INVALID_PARAMETER); break; } RETURN(Result); @@ -205,7 +205,7 @@ NtUserCallOneParam( if (!(CurIcon = IntCreateCurIconHandle())) { - SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY); + EngSetLastError(ERROR_NOT_ENOUGH_MEMORY); RETURN(0); } @@ -312,7 +312,7 @@ NtUserCallOneParam( ppi->dwLayout = Param; RETURN(TRUE); } - SetLastWin32Error(ERROR_INVALID_PARAMETER); + EngSetLastError(ERROR_INVALID_PARAMETER); RETURN(FALSE); } case ONEPARAM_ROUTINE_GETPROCDEFLAYOUT: @@ -322,7 +322,7 @@ NtUserCallOneParam( PDWORD pdwLayout; if ( PsGetCurrentProcess() == CsrProcess) { - SetLastWin32Error(ERROR_INVALID_ACCESS); + EngSetLastError(ERROR_INVALID_ACCESS); RETURN(FALSE); } ppi = PsGetCurrentProcessWin32Process(); @@ -344,7 +344,7 @@ NtUserCallOneParam( } DPRINT1("Calling invalid routine number 0x%x in NtUserCallOneParam(), Param=0x%x\n", Routine, Param); - SetLastWin32Error(ERROR_INVALID_PARAMETER); + EngSetLastError(ERROR_INVALID_PARAMETER); RETURN( 0); CLEANUP: @@ -466,7 +466,7 @@ NtUserCallTwoParam( } DPRINT1("Calling invalid routine number 0x%x in NtUserCallTwoParam(), Param1=0x%x Parm2=0x%x\n", Routine, Param1, Param2); - SetLastWin32Error(ERROR_INVALID_PARAMETER); + EngSetLastError(ERROR_INVALID_PARAMETER); RETURN( 0); CLEANUP: diff --git a/reactos/subsystems/win32/win32k/ntuser/sysparams.c b/reactos/subsystems/win32/win32k/ntuser/sysparams.c index 6fa98f9563b..f4f6dfbb688 100644 --- a/reactos/subsystems/win32/win32k/ntuser/sysparams.c +++ b/reactos/subsystems/win32/win32k/ntuser/sysparams.c @@ -36,7 +36,7 @@ PWINSTATION_OBJECT gpwinstaCurrent = NULL; #define REQ_INTERACTIVE_WINSTA(err) \ if (gpwinstaCurrent != InputWindowStation) \ { \ - SetLastWin32Error(err); \ + EngSetLastError(err); \ return 0; \ } @@ -1466,7 +1466,7 @@ SpiGetSet(UINT uiAction, UINT uiParam, PVOID pvParam, FLONG fl) default: DPRINT1("Invalid SPI value: %d\n", uiAction); - SetLastWin32Error(ERROR_INVALID_PARAMETER); + EngSetLastError(ERROR_INVALID_PARAMETER); return 0; } diff --git a/reactos/subsystems/win32/win32k/ntuser/timer.c b/reactos/subsystems/win32/win32k/ntuser/timer.c index ee316aab8c2..b99c918b566 100644 --- a/reactos/subsystems/win32/win32k/ntuser/timer.c +++ b/reactos/subsystems/win32/win32k/ntuser/timer.c @@ -245,7 +245,7 @@ IntSetTimer( PWND Window, { IntUnlockWindowlessTimerBitmap(); DPRINT1("Unable to find a free window-less timer id\n"); - SetLastWin32Error(ERROR_NO_SYSTEM_RESOURCES); + EngSetLastError(ERROR_NO_SYSTEM_RESOURCES); ASSERT(FALSE); return 0; } @@ -323,7 +323,7 @@ SystemTimerSet( PWND Window, { if (Window && Window->head.pti->pEThread->ThreadsProcess != PsGetCurrentProcess()) { - SetLastWin32Error(ERROR_ACCESS_DENIED); + EngSetLastError(ERROR_ACCESS_DENIED); DPRINT("SysemTimerSet: Access Denied!\n"); return 0; } diff --git a/reactos/subsystems/win32/win32k/ntuser/window.c b/reactos/subsystems/win32/win32k/ntuser/window.c index 47636714673..95a43d6ff37 100644 --- a/reactos/subsystems/win32/win32k/ntuser/window.c +++ b/reactos/subsystems/win32/win32k/ntuser/window.c @@ -57,14 +57,14 @@ BOOL FASTCALL UserUpdateUiState(PWND Wnd, WPARAM wParam) if (Flags & ~(UISF_HIDEFOCUS | UISF_HIDEACCEL | UISF_ACTIVE)) { - SetLastWin32Error(ERROR_INVALID_PARAMETER); + EngSetLastError(ERROR_INVALID_PARAMETER); return FALSE; } switch (Action) { case UIS_INITIALIZE: - SetLastWin32Error(ERROR_INVALID_PARAMETER); + EngSetLastError(ERROR_INVALID_PARAMETER); return FALSE; case UIS_SET: @@ -112,21 +112,21 @@ PWND FASTCALL UserGetWindowObject(HWND hWnd) ti = GetW32ThreadInfo(); if (ti == NULL) { - SetLastWin32Error(ERROR_ACCESS_DENIED); + EngSetLastError(ERROR_ACCESS_DENIED); return NULL; } } if (!hWnd) { - SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE); + EngSetLastError(ERROR_INVALID_WINDOW_HANDLE); return NULL; } Window = (PWND)UserGetObject(gHandleTable, hWnd, otWindow); if (!Window || 0 != (Window->state & WNDS_DESTROYED)) { - SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE); + EngSetLastError(ERROR_INVALID_WINDOW_HANDLE); return NULL; } @@ -205,7 +205,7 @@ IntWinListChildren(PWND Window) if(!List) { DPRINT1("Failed to allocate memory for children array\n"); - SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY); + EngSetLastError(ERROR_NOT_ENOUGH_MEMORY); return NULL; } for (Child = Window->spwndChild, Index = 0; @@ -666,7 +666,7 @@ IntSetMenu( if ((Wnd->style & (WS_CHILD | WS_POPUP)) == WS_CHILD) { - SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE); + EngSetLastError(ERROR_INVALID_WINDOW_HANDLE); return FALSE; } @@ -695,7 +695,7 @@ IntSetMenu( { IntReleaseMenuObject(OldMenu); } - SetLastWin32Error(ERROR_INVALID_MENU_HANDLE); + EngSetLastError(ERROR_INVALID_MENU_HANDLE); return FALSE; } if (NULL != NewMenu->MenuInfo.Wnd) @@ -705,7 +705,7 @@ IntSetMenu( { IntReleaseMenuObject(OldMenu); } - SetLastWin32Error(ERROR_INVALID_MENU_HANDLE); + EngSetLastError(ERROR_INVALID_MENU_HANDLE); return FALSE; } @@ -1101,7 +1101,7 @@ co_IntSetParent(PWND Wnd, PWND WndNewParent) /* Some applications try to set a child as a parent */ if (IntIsChildWindow(Wnd, WndNewParent)) { - SetLastWin32Error( ERROR_INVALID_PARAMETER ); + EngSetLastError( ERROR_INVALID_PARAMETER ); return NULL; } @@ -1736,7 +1736,7 @@ PWND FASTCALL IntCreateWindow(CREATESTRUCTW* Cs, if (!CallProc) { - SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY); + EngSetLastError(ERROR_NOT_ENOUGH_MEMORY); DPRINT1("Warning: Unable to create CallProc for edit control. Control may not operate correctly! hwnd %x\n",hWnd); } else @@ -1903,7 +1903,7 @@ co_UserCreateWindowEx(CREATESTRUCTW* Cs, else if ((Cs->style & (WS_CHILD|WS_POPUP)) == WS_CHILD) { DPRINT1("Cannot create a child window without a parrent!\n"); - SetLastWin32Error(ERROR_TLW_WITH_WSCHILD); + EngSetLastError(ERROR_TLW_WITH_WSCHILD); RETURN(NULL); /* WS_CHILD needs a parent, but WS_POPUP doesn't */ } @@ -2373,7 +2373,7 @@ BOOLEAN FASTCALL co_UserDestroyWindow(PWND Window) if ( (Window->head.pti->pEThread != PsGetCurrentThread()) || Window->head.pti != PsGetCurrentThreadWin32Thread() ) { - SetLastWin32Error(ERROR_ACCESS_DENIED); + EngSetLastError(ERROR_ACCESS_DENIED); return FALSE; } @@ -2652,7 +2652,7 @@ NtUserFindWindowEx(HWND hwndParent, } else if (!IS_ATOM(ClassName.Buffer)) { - SetLastWin32Error(ERROR_INVALID_PARAMETER); + EngSetLastError(ERROR_INVALID_PARAMETER); _SEH2_LEAVE; } @@ -2686,7 +2686,7 @@ NtUserFindWindowEx(HWND hwndParent, if (ClassName.Length == 0 && ClassName.Buffer != NULL && !IS_ATOM(ClassName.Buffer)) { - SetLastWin32Error(ERROR_INVALID_PARAMETER); + EngSetLastError(ERROR_INVALID_PARAMETER); RETURN(NULL); } else if (ClassAtom == (RTL_ATOM)0) @@ -3067,13 +3067,13 @@ co_UserSetParent(HWND hWndChild, HWND hWndNewParent) if (IntIsBroadcastHwnd(hWndChild) || IntIsBroadcastHwnd(hWndNewParent)) { - SetLastWin32Error(ERROR_INVALID_PARAMETER); + EngSetLastError(ERROR_INVALID_PARAMETER); return( NULL); } if (hWndChild == IntGetDesktopWindow()) { - SetLastWin32Error(ERROR_ACCESS_DENIED); + EngSetLastError(ERROR_ACCESS_DENIED); return( NULL); } @@ -3396,7 +3396,7 @@ co_UserSetWindowLong(HWND hWnd, DWORD Index, LONG NewValue, BOOL Ansi) if (hWnd == IntGetDesktopWindow()) { - SetLastWin32Error(STATUS_ACCESS_DENIED); + EngSetLastError(STATUS_ACCESS_DENIED); return( 0); } @@ -3409,7 +3409,7 @@ co_UserSetWindowLong(HWND hWnd, DWORD Index, LONG NewValue, BOOL Ansi) { if ((Index + sizeof(LONG)) > Window->cbwndExtra) { - SetLastWin32Error(ERROR_INVALID_INDEX); + EngSetLastError(ERROR_INVALID_INDEX); return( 0); } @@ -3463,7 +3463,7 @@ co_UserSetWindowLong(HWND hWnd, DWORD Index, LONG NewValue, BOOL Ansi) if ( Window->head.pti->ppi != PsGetCurrentProcessWin32Process() || Window->fnid & FNID_FREED) { - SetLastWin32Error(ERROR_ACCESS_DENIED); + EngSetLastError(ERROR_ACCESS_DENIED); return( 0); } OldValue = (LONG)IntSetWindowProc(Window, @@ -3497,7 +3497,7 @@ co_UserSetWindowLong(HWND hWnd, DWORD Index, LONG NewValue, BOOL Ansi) default: DPRINT1("NtUserSetWindowLong(): Unsupported index %d\n", Index); - SetLastWin32Error(ERROR_INVALID_INDEX); + EngSetLastError(ERROR_INVALID_INDEX); OldValue = 0; break; } @@ -3566,14 +3566,14 @@ NtUserSetWindowWord(HWND hWnd, INT Index, WORD NewValue) default: if (Index < 0) { - SetLastWin32Error(ERROR_INVALID_INDEX); + EngSetLastError(ERROR_INVALID_INDEX); RETURN( 0); } } if (Index > Window->cbwndExtra - sizeof(WORD)) { - SetLastWin32Error(ERROR_INVALID_PARAMETER); + EngSetLastError(ERROR_INVALID_PARAMETER); RETURN( 0); } @@ -3768,7 +3768,7 @@ NtUserRegisterWindowMessage(PUNICODE_STRING MessageNameUnsafe) if(MessageNameUnsafe == NULL) { - SetLastWin32Error(ERROR_INVALID_PARAMETER); + EngSetLastError(ERROR_INVALID_PARAMETER); RETURN( 0); } @@ -4328,7 +4328,7 @@ NtUserDefSetText(HWND hWnd, PLARGE_STRING WindowText) } else { - SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY); + EngSetLastError(ERROR_NOT_ENOUGH_MEMORY); Ret = FALSE; goto Exit; } @@ -4378,7 +4378,7 @@ NtUserInternalGetWindowText(HWND hWnd, LPWSTR lpString, INT nMaxCount) if(lpString && (nMaxCount <= 1)) { - SetLastWin32Error(ERROR_INVALID_PARAMETER); + EngSetLastError(ERROR_INVALID_PARAMETER); RETURN( 0); } @@ -4499,7 +4499,7 @@ NtUserValidateHandleSecure( PUSER_HANDLE_ENTRY entry; if (!(entry = handle_to_entry(gHandleTable, handle ))) { - SetLastWin32Error(ERROR_INVALID_HANDLE); + EngSetLastError(ERROR_INVALID_HANDLE); return FALSE; } uType = entry->type; @@ -4548,7 +4548,7 @@ NtUserValidateHandleSecure( return UserGetCallProcInfo( handle, &Proc ); } default: - SetLastWin32Error(ERROR_INVALID_HANDLE); + EngSetLastError(ERROR_INVALID_HANDLE); } } else diff --git a/reactos/subsystems/win32/win32k/ntuser/winpos.c b/reactos/subsystems/win32/win32k/ntuser/winpos.c index b80c9db2e18..3099bee17ef 100644 --- a/reactos/subsystems/win32/win32k/ntuser/winpos.c +++ b/reactos/subsystems/win32/win32k/ntuser/winpos.c @@ -78,7 +78,7 @@ UserGetClientOrigin(PWND Window, LPPOINT Point) if(!Point) { - SetLastWin32Error(ERROR_INVALID_PARAMETER); + EngSetLastError(ERROR_INVALID_PARAMETER); return FALSE; } @@ -86,7 +86,7 @@ UserGetClientOrigin(PWND Window, LPPOINT Point) if(!Ret) { - SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE); + EngSetLastError(ERROR_INVALID_WINDOW_HANDLE); return FALSE; } @@ -1011,14 +1011,14 @@ co_WinPosSetWindowPos( /* Fix up the flags. */ if (!WinPosFixupFlags(&WinPos, Window)) { - SetLastWin32Error(ERROR_INVALID_PARAMETER); + EngSetLastError(ERROR_INVALID_PARAMETER); return FALSE; } /* Does the window still exist? */ if (!IntIsWindow(WinPos.hwnd)) { - SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE); + EngSetLastError(ERROR_INVALID_WINDOW_HANDLE); return FALSE; } diff --git a/reactos/subsystems/win32/win32k/ntuser/winsta.c b/reactos/subsystems/win32/win32k/ntuser/winsta.c index 855ce9a26c3..d6e5a0fe446 100644 --- a/reactos/subsystems/win32/win32k/ntuser/winsta.c +++ b/reactos/subsystems/win32/win32k/ntuser/winsta.c @@ -260,7 +260,7 @@ IntValidateWindowStationHandle( if (WindowStation == NULL) { // DPRINT1("Invalid window station handle\n"); - SetLastWin32Error(ERROR_INVALID_HANDLE); + EngSetLastError(ERROR_INVALID_HANDLE); return STATUS_INVALID_HANDLE; } @@ -1006,7 +1006,7 @@ NtUserSetProcessWindowStation(HWINSTA hWindowStation) if(PsGetCurrentProcess() == CsrProcess) { DPRINT1("CSRSS is not allowed to change it's window station!!!\n"); - SetLastWin32Error(ERROR_ACCESS_DENIED); + EngSetLastError(ERROR_ACCESS_DENIED); return FALSE; } @@ -1058,7 +1058,7 @@ NtUserLockWindowStation(HWINSTA hWindowStation) if(PsGetCurrentProcessWin32Process() != LogonProcess) { DPRINT1("Unauthorized process attempted to lock the window station!\n"); - SetLastWin32Error(ERROR_ACCESS_DENIED); + EngSetLastError(ERROR_ACCESS_DENIED); return FALSE; } @@ -1103,7 +1103,7 @@ NtUserUnlockWindowStation(HWINSTA hWindowStation) if(PsGetCurrentProcessWin32Process() != LogonProcess) { DPRINT1("Unauthorized process attempted to unlock the window station!\n"); - SetLastWin32Error(ERROR_ACCESS_DENIED); + EngSetLastError(ERROR_ACCESS_DENIED); return FALSE; } diff --git a/reactos/subsystems/win32/win32k/objects/arc.c b/reactos/subsystems/win32/win32k/objects/arc.c index e2ffeb50fdc..4cb7a55cf83 100644 --- a/reactos/subsystems/win32/win32k/objects/arc.c +++ b/reactos/subsystems/win32/win32k/objects/arc.c @@ -73,7 +73,7 @@ IntArc( DC *dc, if (!pbrushPen) { DPRINT1("Arc Fail 1\n"); - SetLastWin32Error(ERROR_INTERNAL_ERROR); + EngSetLastError(ERROR_INTERNAL_ERROR); return FALSE; } @@ -161,7 +161,7 @@ IntArc( DC *dc, { DPRINT1("Arc Fail 2\n"); PEN_UnlockPen(pbrushPen); - SetLastWin32Error(ERROR_INTERNAL_ERROR); + EngSetLastError(ERROR_INTERNAL_ERROR); return FALSE; } @@ -312,7 +312,7 @@ NtGdiAngleArc( pDC = DC_LockDc (hDC); if(!pDC) { - SetLastWin32Error(ERROR_INVALID_HANDLE); + EngSetLastError(ERROR_INVALID_HANDLE); return FALSE; } if (pDC->dctype == DC_TYPE_INFO) @@ -355,7 +355,7 @@ NtGdiArcInternal( dc = DC_LockDc (hDC); if(!dc) { - SetLastWin32Error(ERROR_INVALID_HANDLE); + EngSetLastError(ERROR_INVALID_HANDLE); return FALSE; } if (dc->dctype == DC_TYPE_INFO) diff --git a/reactos/subsystems/win32/win32k/objects/bitblt.c b/reactos/subsystems/win32/win32k/objects/bitblt.c index 5854743cdc6..f84533d63e5 100644 --- a/reactos/subsystems/win32/win32k/objects/bitblt.c +++ b/reactos/subsystems/win32/win32k/objects/bitblt.c @@ -53,7 +53,7 @@ NtGdiAlphaBlend( if (WidthDest < 0 || HeightDest < 0 || WidthSrc < 0 || HeightSrc < 0) { - SetLastWin32Error(ERROR_INVALID_PARAMETER); + EngSetLastError(ERROR_INVALID_PARAMETER); return FALSE; } @@ -67,7 +67,7 @@ NtGdiAlphaBlend( if ((NULL == DCDest) || (NULL == DCSrc)) { DPRINT1("Invalid dc handle (dest=0x%08x, src=0x%08x) passed to NtGdiAlphaBlend\n", hDCDest, hDCSrc); - SetLastWin32Error(ERROR_INVALID_HANDLE); + EngSetLastError(ERROR_INVALID_HANDLE); if(DCSrc) GDIOBJ_UnlockObjByPtr(&DCSrc->BaseObject); if(DCDest) GDIOBJ_UnlockObjByPtr(&DCDest->BaseObject); return FALSE; @@ -342,7 +342,7 @@ NtGdiTransparentBlt( if ((NULL == DCDest) || (NULL == DCSrc)) { DPRINT1("Invalid dc handle (dest=0x%08x, src=0x%08x) passed to NtGdiAlphaBlend\n", hdcDst, hdcSrc); - SetLastWin32Error(ERROR_INVALID_HANDLE); + EngSetLastError(ERROR_INVALID_HANDLE); if(DCSrc) GDIOBJ_UnlockObjByPtr(&DCSrc->BaseObject); if(DCDest) GDIOBJ_UnlockObjByPtr(&DCDest->BaseObject); return FALSE; @@ -659,7 +659,7 @@ GreStretchBltMask( if (0 == WidthDest || 0 == HeightDest || 0 == WidthSrc || 0 == HeightSrc) { - SetLastWin32Error(ERROR_INVALID_PARAMETER); + EngSetLastError(ERROR_INVALID_PARAMETER); return FALSE; } @@ -958,7 +958,7 @@ IntGdiPolyPatBlt( pdc = DC_LockDc(hDC); if (!pdc) { - SetLastWin32Error(ERROR_INVALID_HANDLE); + EngSetLastError(ERROR_INVALID_HANDLE); return FALSE; } @@ -1017,7 +1017,7 @@ NtGdiPatBlt( dc = DC_LockDc(hDC); if (dc == NULL) { - SetLastWin32Error(ERROR_INVALID_HANDLE); + EngSetLastError(ERROR_INVALID_HANDLE); return FALSE; } if (dc->dctype == DC_TYPE_INFO) @@ -1035,7 +1035,7 @@ NtGdiPatBlt( pbrush = BRUSH_LockBrush(pdcattr->hbrush); if (pbrush == NULL) { - SetLastWin32Error(ERROR_INVALID_HANDLE); + EngSetLastError(ERROR_INVALID_HANDLE); DC_UnlockDc(dc); return FALSE; } @@ -1065,7 +1065,7 @@ NtGdiPolyPatBlt( rb = ExAllocatePoolWithTag(PagedPool, sizeof(PATRECT) * cRects, TAG_PATBLT); if (!rb) { - SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY); + EngSetLastError(ERROR_NOT_ENOUGH_MEMORY); return FALSE; } _SEH2_TRY diff --git a/reactos/subsystems/win32/win32k/objects/bitmaps.c b/reactos/subsystems/win32/win32k/objects/bitmaps.c index 8f75277ebcc..573101fcf5e 100644 --- a/reactos/subsystems/win32/win32k/objects/bitmaps.c +++ b/reactos/subsystems/win32/win32k/objects/bitmaps.c @@ -174,14 +174,14 @@ NtGdiCreateBitmap( { DPRINT1("Width = %d, Height = %d BitsPixel = %d\n", nWidth, nHeight, cBitsPixel); - SetLastWin32Error(ERROR_INVALID_PARAMETER); + EngSetLastError(ERROR_INVALID_PARAMETER); return NULL; } if(WIDTH_BYTES_ALIGN16(nWidth, cBitsPixel)*nHeight >= 0x8000000) { /* I just can't get enough, I just can't get enough */ - SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY); + EngSetLastError(ERROR_NOT_ENOUGH_MEMORY); return NULL; } @@ -314,7 +314,7 @@ IntCreateCompatibleBitmap( if (!psurf->ppal) { - SetLastWin32Error(ERROR_INVALID_HANDLE); + EngSetLastError(ERROR_INVALID_HANDLE); return 0; } @@ -358,7 +358,7 @@ NtGdiCreateCompatibleBitmap( if (Width <= 0 || Height <= 0 || (Width * Height) > 0x3FFFFFFF) { - SetLastWin32Error(ERROR_INVALID_PARAMETER); + EngSetLastError(ERROR_INVALID_PARAMETER); return NULL; } @@ -372,7 +372,7 @@ NtGdiCreateCompatibleBitmap( if (NULL == Dc) { - SetLastWin32Error(ERROR_INVALID_HANDLE); + EngSetLastError(ERROR_INVALID_HANDLE); return NULL; } @@ -397,7 +397,7 @@ NtGdiGetBitmapDimension( psurfBmp = SURFACE_LockSurface(hBitmap); if (psurfBmp == NULL) { - SetLastWin32Error(ERROR_INVALID_HANDLE); + EngSetLastError(ERROR_INVALID_HANDLE); return FALSE; } @@ -432,7 +432,7 @@ NtGdiGetPixel(HDC hDC, INT XPos, INT YPos) if (!dc) { - SetLastWin32Error(ERROR_INVALID_HANDLE); + EngSetLastError(ERROR_INVALID_HANDLE); return Result; } @@ -604,7 +604,7 @@ NtGdiGetBitmapBits( psurf = SURFACE_LockSurface(hBitmap); if (!psurf) { - SetLastWin32Error(ERROR_INVALID_HANDLE); + EngSetLastError(ERROR_INVALID_HANDLE); return 0; } @@ -658,7 +658,7 @@ NtGdiSetBitmapBits( psurf = SURFACE_LockSurface(hBitmap); if (psurf == NULL) { - SetLastWin32Error(ERROR_INVALID_HANDLE); + EngSetLastError(ERROR_INVALID_HANDLE); return 0; } @@ -695,7 +695,7 @@ NtGdiSetBitmapDimension( psurf = SURFACE_LockSurface(hBitmap); if (psurf == NULL) { - SetLastWin32Error(ERROR_INVALID_HANDLE); + EngSetLastError(ERROR_INVALID_HANDLE); return FALSE; } diff --git a/reactos/subsystems/win32/win32k/objects/brush.c b/reactos/subsystems/win32/win32k/objects/brush.c index d1f8175d62a..aa1c3480737 100644 --- a/reactos/subsystems/win32/win32k/objects/brush.c +++ b/reactos/subsystems/win32/win32k/objects/brush.c @@ -260,7 +260,7 @@ IntGdiCreateDIBBrush( if (BitmapInfo->bmiHeader.biSize < sizeof(BITMAPINFOHEADER)) { - SetLastWin32Error(ERROR_INVALID_PARAMETER); + EngSetLastError(ERROR_INVALID_PARAMETER); return NULL; } @@ -269,7 +269,7 @@ IntGdiCreateDIBBrush( hPattern = DIB_CreateDIBSection(NULL, BitmapInfo, ColorSpec, &pvDIBits, NULL, 0, 0); if (hPattern == NULL) { - SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY); + EngSetLastError(ERROR_NOT_ENOUGH_MEMORY); return NULL; } RtlCopyMemory(pvDIBits, @@ -282,7 +282,7 @@ IntGdiCreateDIBBrush( if (pbrush == NULL) { GreDeleteObject(hPattern); - SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY); + EngSetLastError(ERROR_NOT_ENOUGH_MEMORY); return NULL; } hBrush = pbrush->BaseObject.hHmgr; @@ -316,7 +316,7 @@ IntGdiCreateHatchBrush( hPattern = GreCreateBitmap(8, 8, 1, 1, (LPBYTE)HatchBrushes[Style]); if (hPattern == NULL) { - SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY); + EngSetLastError(ERROR_NOT_ENOUGH_MEMORY); return NULL; } @@ -324,7 +324,7 @@ IntGdiCreateHatchBrush( if (pbrush == NULL) { GreDeleteObject(hPattern); - SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY); + EngSetLastError(ERROR_NOT_ENOUGH_MEMORY); return NULL; } hBrush = pbrush->BaseObject.hHmgr; @@ -352,7 +352,7 @@ IntGdiCreatePatternBrush( hPattern = BITMAP_CopyBitmap(hBitmap); if (hPattern == NULL) { - SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY); + EngSetLastError(ERROR_NOT_ENOUGH_MEMORY); return NULL; } @@ -360,7 +360,7 @@ IntGdiCreatePatternBrush( if (pbrush == NULL) { GreDeleteObject(hPattern); - SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY); + EngSetLastError(ERROR_NOT_ENOUGH_MEMORY); return NULL; } hBrush = pbrush->BaseObject.hHmgr; @@ -387,7 +387,7 @@ IntGdiCreateSolidBrush( pbrush = BRUSH_AllocBrushWithHandle(); if (pbrush == NULL) { - SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY); + EngSetLastError(ERROR_NOT_ENOUGH_MEMORY); return NULL; } hBrush = pbrush->BaseObject.hHmgr; @@ -412,7 +412,7 @@ IntGdiCreateNullBrush(VOID) pbrush = BRUSH_AllocBrushWithHandle(); if (pbrush == NULL) { - SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY); + EngSetLastError(ERROR_NOT_ENOUGH_MEMORY); return NULL; } hBrush = pbrush->BaseObject.hHmgr; @@ -457,7 +457,7 @@ NtGdiCreateDIBBrush( SafeBitmapInfoAndData = EngAllocMem(FL_ZERO_MEMORY, BitmapInfoSize, TAG_DIB); if (SafeBitmapInfoAndData == NULL) { - SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY); + EngSetLastError(ERROR_NOT_ENOUGH_MEMORY); return NULL; } @@ -535,7 +535,7 @@ NtGdiSetBrushOrg(HDC hDC, INT XOrg, INT YOrg, LPPOINT Point) dc = DC_LockDc(hDC); if (dc == NULL) { - SetLastWin32Error(ERROR_INVALID_HANDLE); + EngSetLastError(ERROR_INVALID_HANDLE); return FALSE; } pdcattr = dc->pdcattr; diff --git a/reactos/subsystems/win32/win32k/objects/cliprgn.c b/reactos/subsystems/win32/win32k/objects/cliprgn.c index 8698bb3ee98..264f68ec1a3 100644 --- a/reactos/subsystems/win32/win32k/objects/cliprgn.c +++ b/reactos/subsystems/win32/win32k/objects/cliprgn.c @@ -84,12 +84,12 @@ GdiSelectVisRgn(HDC hdc, HRGN hrgn) if (!hrgn) { - SetLastWin32Error(ERROR_INVALID_PARAMETER); + EngSetLastError(ERROR_INVALID_PARAMETER); return ERROR; } if (!(dc = DC_LockDc(hdc))) { - SetLastWin32Error(ERROR_INVALID_HANDLE); + EngSetLastError(ERROR_INVALID_HANDLE); return ERROR; } @@ -127,7 +127,7 @@ int FASTCALL GdiExtSelectClipRgn(PDC dc, } else { - SetLastWin32Error(ERROR_INVALID_PARAMETER); + EngSetLastError(ERROR_INVALID_PARAMETER); return ERROR; } } @@ -167,7 +167,7 @@ int APIENTRY NtGdiExtSelectClipRgn(HDC hDC, if (!(dc = DC_LockDc(hDC))) { - SetLastWin32Error(ERROR_INVALID_HANDLE); + EngSetLastError(ERROR_INVALID_HANDLE); return ERROR; } @@ -278,7 +278,7 @@ int APIENTRY NtGdiExcludeClipRect(HDC hDC, if (!dc) { - SetLastWin32Error(ERROR_INVALID_HANDLE); + EngSetLastError(ERROR_INVALID_HANDLE); return ERROR; } @@ -332,7 +332,7 @@ int APIENTRY NtGdiIntersectClipRect(HDC hDC, if (!dc) { - SetLastWin32Error(ERROR_INVALID_HANDLE); + EngSetLastError(ERROR_INVALID_HANDLE); return ERROR; } @@ -375,7 +375,7 @@ int APIENTRY NtGdiOffsetClipRgn(HDC hDC, if(!(dc = DC_LockDc(hDC))) { - SetLastWin32Error(ERROR_INVALID_HANDLE); + EngSetLastError(ERROR_INVALID_HANDLE); return ERROR; } @@ -404,7 +404,7 @@ BOOL APIENTRY NtGdiPtVisible(HDC hDC, if(!(dc = DC_LockDc(hDC))) { - SetLastWin32Error(ERROR_INVALID_HANDLE); + EngSetLastError(ERROR_INVALID_HANDLE); return FALSE; } @@ -425,7 +425,7 @@ BOOL APIENTRY NtGdiRectVisible(HDC hDC, if (!dc) { - SetLastWin32Error(ERROR_INVALID_HANDLE); + EngSetLastError(ERROR_INVALID_HANDLE); return FALSE; } @@ -526,7 +526,7 @@ int APIENTRY NtGdiSetMetaRgn(HDC hDC) if (!pDC) { - SetLastWin32Error(ERROR_INVALID_PARAMETER); + EngSetLastError(ERROR_INVALID_PARAMETER); return ERROR; } Ret = IntGdiSetMetaRgn(pDC); diff --git a/reactos/subsystems/win32/win32k/objects/coord.c b/reactos/subsystems/win32/win32k/objects/coord.c index 12cb42a024b..6e9ceafb736 100644 --- a/reactos/subsystems/win32/win32k/objects/coord.c +++ b/reactos/subsystems/win32/win32k/objects/coord.c @@ -194,13 +194,13 @@ NtGdiGetTransform( dc = DC_LockDc(hDC); if (!dc) { - SetLastWin32Error(ERROR_INVALID_HANDLE); + EngSetLastError(ERROR_INVALID_HANDLE); return FALSE; } if (!XForm) { DC_UnlockDc(dc); - SetLastWin32Error(ERROR_INVALID_PARAMETER); + EngSetLastError(ERROR_INVALID_PARAMETER); return FALSE; } @@ -267,14 +267,14 @@ NtGdiTransformPoints( dc = DC_LockDc(hDC); if (!dc) { - SetLastWin32Error(ERROR_INVALID_HANDLE); + EngSetLastError(ERROR_INVALID_HANDLE); return FALSE; } if (!UnsafePtsIn || !UnsafePtOut || Count <= 0) { DC_UnlockDc(dc); - SetLastWin32Error(ERROR_INVALID_PARAMETER); + EngSetLastError(ERROR_INVALID_PARAMETER); return FALSE; } @@ -285,7 +285,7 @@ NtGdiTransformPoints( if (!Points) { DC_UnlockDc(dc); - SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY); + EngSetLastError(ERROR_NOT_ENOUGH_MEMORY); return FALSE; } @@ -324,7 +324,7 @@ NtGdiTransformPoints( { DC_UnlockDc(dc); ExFreePoolWithTag(Points, TAG_COORD); - SetLastWin32Error(ERROR_INVALID_PARAMETER); + EngSetLastError(ERROR_INVALID_PARAMETER); return FALSE; } } @@ -369,7 +369,7 @@ NtGdiModifyWorldTransform( dc = DC_LockDc(hDC); if (!dc) { - SetLastWin32Error(ERROR_INVALID_HANDLE); + EngSetLastError(ERROR_INVALID_HANDLE); return FALSE; } @@ -410,7 +410,7 @@ NtGdiOffsetViewportOrgEx( dc = DC_LockDc(hDC); if (!dc) { - SetLastWin32Error(ERROR_INVALID_HANDLE); + EngSetLastError(ERROR_INVALID_HANDLE); return FALSE; } pdcattr = dc->pdcattr; @@ -467,7 +467,7 @@ NtGdiOffsetWindowOrgEx( dc = DC_LockDc(hDC); if (!dc) { - SetLastWin32Error(ERROR_INVALID_HANDLE); + EngSetLastError(ERROR_INVALID_HANDLE); return FALSE; } pdcattr = dc->pdcattr; @@ -523,7 +523,7 @@ NtGdiScaleViewportExtEx( pDC = DC_LockDc(hDC); if (!pDC) { - SetLastWin32Error(ERROR_INVALID_HANDLE); + EngSetLastError(ERROR_INVALID_HANDLE); return FALSE; } pdcattr = pDC->pdcattr; @@ -608,7 +608,7 @@ NtGdiScaleWindowExtEx( pDC = DC_LockDc(hDC); if (!pDC) { - SetLastWin32Error(ERROR_INVALID_HANDLE); + EngSetLastError(ERROR_INVALID_HANDLE); return FALSE; } pdcattr = pDC->pdcattr; @@ -766,7 +766,7 @@ NtGdiSetViewportOrgEx( dc = DC_LockDc(hDC); if (!dc) { - SetLastWin32Error(ERROR_INVALID_HANDLE); + EngSetLastError(ERROR_INVALID_HANDLE); return FALSE; } pdcattr = dc->pdcattr; @@ -818,7 +818,7 @@ NtGdiSetWindowOrgEx( dc = DC_LockDc(hDC); if (!dc) { - SetLastWin32Error(ERROR_INVALID_HANDLE); + EngSetLastError(ERROR_INVALID_HANDLE); return FALSE; } pdcattr = dc->pdcattr; @@ -948,7 +948,7 @@ NtGdiSetLayout( pdc = DC_LockDc(hdc); if (!pdc) { - SetLastWin32Error(ERROR_INVALID_HANDLE); + EngSetLastError(ERROR_INVALID_HANDLE); return GDI_ERROR; } pdcattr = pdc->pdcattr; @@ -973,7 +973,7 @@ NtGdiGetDeviceWidth( dc = DC_LockDc(hdc); if (!dc) { - SetLastWin32Error(ERROR_INVALID_HANDLE); + EngSetLastError(ERROR_INVALID_HANDLE); return 0; } Ret = dc->erclWindow.right - dc->erclWindow.left; @@ -993,7 +993,7 @@ NtGdiMirrorWindowOrg( dc = DC_LockDc(hdc); if (!dc) { - SetLastWin32Error(ERROR_INVALID_HANDLE); + EngSetLastError(ERROR_INVALID_HANDLE); return FALSE; } IntMirrorWindowOrg(dc); @@ -1250,14 +1250,14 @@ NtGdiGetDCPoint( if (!Point) { - SetLastWin32Error(ERROR_INVALID_PARAMETER); + EngSetLastError(ERROR_INVALID_PARAMETER); return FALSE; } pdc = DC_LockDc(hDC); if (!pdc) { - SetLastWin32Error(ERROR_INVALID_HANDLE); + EngSetLastError(ERROR_INVALID_HANDLE); return FALSE; } @@ -1293,7 +1293,7 @@ NtGdiGetDCPoint( break; default: - SetLastWin32Error(ERROR_INVALID_PARAMETER); + EngSetLastError(ERROR_INVALID_PARAMETER); Ret = FALSE; break; } diff --git a/reactos/subsystems/win32/win32k/objects/dclife.c b/reactos/subsystems/win32/win32k/objects/dclife.c index 589e92c594f..108762e1ff2 100644 --- a/reactos/subsystems/win32/win32k/objects/dclife.c +++ b/reactos/subsystems/win32/win32k/objects/dclife.c @@ -782,7 +782,7 @@ IntGdiDeleteDC(HDC hDC, BOOL Force) if (DCToDelete == NULL) { - SetLastWin32Error(ERROR_INVALID_HANDLE); + EngSetLastError(ERROR_INVALID_HANDLE); return FALSE; } @@ -846,7 +846,7 @@ NtGdiDeleteObjectApp(HANDLE DCHandle) if (!GDIOBJ_OwnedByCurrentProcess(DCHandle)) { - SetLastWin32Error(ERROR_INVALID_HANDLE); + EngSetLastError(ERROR_INVALID_HANDLE); return FALSE; } diff --git a/reactos/subsystems/win32/win32k/objects/dcobjs.c b/reactos/subsystems/win32/win32k/objects/dcobjs.c index bba8441435d..e4bc928b935 100644 --- a/reactos/subsystems/win32/win32k/objects/dcobjs.c +++ b/reactos/subsystems/win32/win32k/objects/dcobjs.c @@ -352,7 +352,7 @@ NtGdiSelectClipPath( pdc = DC_LockDc(hDC); if (!pdc) { - SetLastWin32Error(ERROR_INVALID_PARAMETER); + EngSetLastError(ERROR_INVALID_PARAMETER); return FALSE; } pdcattr = pdc->pdcattr; @@ -367,7 +367,7 @@ NtGdiSelectClipPath( /* Check that path is closed */ if (pPath->state != PATH_Closed) { - SetLastWin32Error(ERROR_CAN_NOT_COMPLETE); + EngSetLastError(ERROR_CAN_NOT_COMPLETE); DC_UnlockDc(pdc); return FALSE; } @@ -404,7 +404,7 @@ NtGdiGetDCObject(HDC hDC, INT ObjectType) if(!(pdc = DC_LockDc(hDC))) { - SetLastWin32Error(ERROR_INVALID_HANDLE); + EngSetLastError(ERROR_INVALID_HANDLE); return NULL; } pdcattr = pdc->pdcattr; @@ -449,7 +449,7 @@ NtGdiGetDCObject(HDC hDC, INT ObjectType) default: SelObject = NULL; - SetLastWin32Error(ERROR_INVALID_PARAMETER); + EngSetLastError(ERROR_INVALID_PARAMETER); break; } diff --git a/reactos/subsystems/win32/win32k/objects/dcstate.c b/reactos/subsystems/win32/win32k/objects/dcstate.c index 889a8733087..9491db2ce6b 100644 --- a/reactos/subsystems/win32/win32k/objects/dcstate.c +++ b/reactos/subsystems/win32/win32k/objects/dcstate.c @@ -190,7 +190,7 @@ NtGdiRestoreDC( pdc = DC_LockDc(hdc); if (!pdc) { - SetLastWin32Error(ERROR_INVALID_HANDLE); + EngSetLastError(ERROR_INVALID_HANDLE); return FALSE; } @@ -206,7 +206,7 @@ NtGdiRestoreDC( DPRINT("Illegal save level, requested: %ld, current: %ld\n", iSaveLevel, pdc->dclevel.lSaveDepth); DC_UnlockDc(pdc); - SetLastWin32Error(ERROR_INVALID_PARAMETER); + EngSetLastError(ERROR_INVALID_PARAMETER); return FALSE; } @@ -236,7 +236,7 @@ NtGdiSaveDC( if (pdc == NULL) { DPRINT("Could not lock DC\n"); - SetLastWin32Error(ERROR_INVALID_HANDLE); + EngSetLastError(ERROR_INVALID_HANDLE); return 0; } diff --git a/reactos/subsystems/win32/win32k/objects/dcutil.c b/reactos/subsystems/win32/win32k/objects/dcutil.c index 0471c7dc9d2..83a490b651b 100644 --- a/reactos/subsystems/win32/win32k/objects/dcutil.c +++ b/reactos/subsystems/win32/win32k/objects/dcutil.c @@ -14,7 +14,7 @@ IntGdiSetBkColor(HDC hDC, COLORREF color) if (!(dc = DC_LockDc(hDC))) { - SetLastWin32Error(ERROR_INVALID_HANDLE); + EngSetLastError(ERROR_INVALID_HANDLE); return CLR_INVALID; } pdcattr = dc->pdcattr; @@ -37,7 +37,7 @@ IntGdiSetBkMode(HDC hDC, INT Mode) if (!(dc = DC_LockDc(hDC))) { - SetLastWin32Error(ERROR_INVALID_HANDLE); + EngSetLastError(ERROR_INVALID_HANDLE); return CLR_INVALID; } pdcattr = dc->pdcattr; @@ -60,7 +60,7 @@ IntGdiSetTextAlign(HDC hDC, dc = DC_LockDc(hDC); if (!dc) { - SetLastWin32Error(ERROR_INVALID_HANDLE); + EngSetLastError(ERROR_INVALID_HANDLE); return GDI_ERROR; } pdcattr = dc->pdcattr; @@ -82,7 +82,7 @@ IntGdiSetTextColor(HDC hDC, pdc = DC_LockDc(hDC); if (!pdc) { - SetLastWin32Error(ERROR_INVALID_HANDLE); + EngSetLastError(ERROR_INVALID_HANDLE); return CLR_INVALID; } pdcattr = pdc->pdcattr; @@ -104,7 +104,7 @@ DCU_SetDcUndeletable(HDC hDC) PDC dc = DC_LockDc(hDC); if (!dc) { - SetLastWin32Error(ERROR_INVALID_HANDLE); + EngSetLastError(ERROR_INVALID_HANDLE); return; } @@ -207,7 +207,7 @@ IntGdiSetHookFlags(HDC hDC, WORD Flags) if (NULL == dc) { - SetLastWin32Error(ERROR_INVALID_HANDLE); + EngSetLastError(ERROR_INVALID_HANDLE); return 0; } @@ -250,14 +250,14 @@ NtGdiGetDCDword( if (!Result) { - SetLastWin32Error(ERROR_INVALID_PARAMETER); + EngSetLastError(ERROR_INVALID_PARAMETER); return FALSE; } pdc = DC_LockDc(hDC); if (!pdc) { - SetLastWin32Error(ERROR_INVALID_HANDLE); + EngSetLastError(ERROR_INVALID_HANDLE); return FALSE; } pdcattr = pdc->pdcattr; @@ -306,7 +306,7 @@ NtGdiGetDCDword( break; default: - SetLastWin32Error(ERROR_INVALID_PARAMETER); + EngSetLastError(ERROR_INVALID_PARAMETER); Ret = FALSE; break; } @@ -352,14 +352,14 @@ NtGdiGetAndSetDCDword( if (!Result) { - SetLastWin32Error(ERROR_INVALID_PARAMETER); + EngSetLastError(ERROR_INVALID_PARAMETER); return FALSE; } pdc = DC_LockDc(hDC); if (!pdc) { - SetLastWin32Error(ERROR_INVALID_HANDLE); + EngSetLastError(ERROR_INVALID_HANDLE); return FALSE; } pdcattr = pdc->pdcattr; @@ -393,7 +393,7 @@ NtGdiGetAndSetDCDword( case GdiGetSetMapperFlagsInternal: if (dwIn & ~1) { - SetLastWin32Error(ERROR_INVALID_PARAMETER); + EngSetLastError(ERROR_INVALID_PARAMETER); Ret = FALSE; break; } @@ -408,7 +408,7 @@ NtGdiGetAndSetDCDword( case GdiGetSetArcDirection: if (dwIn != AD_COUNTERCLOCKWISE && dwIn != AD_CLOCKWISE) { - SetLastWin32Error(ERROR_INVALID_PARAMETER); + EngSetLastError(ERROR_INVALID_PARAMETER); Ret = FALSE; break; } @@ -436,7 +436,7 @@ NtGdiGetAndSetDCDword( break; default: - SetLastWin32Error(ERROR_INVALID_PARAMETER); + EngSetLastError(ERROR_INVALID_PARAMETER); Ret = FALSE; break; } diff --git a/reactos/subsystems/win32/win32k/objects/dibobj.c b/reactos/subsystems/win32/win32k/objects/dibobj.c index cbc8ea5cd69..0a28887e85b 100644 --- a/reactos/subsystems/win32/win32k/objects/dibobj.c +++ b/reactos/subsystems/win32/win32k/objects/dibobj.c @@ -136,14 +136,14 @@ IntSetDIBColorTable( if (psurf == NULL) { DC_UnlockDc(dc); - SetLastWin32Error(ERROR_INVALID_PARAMETER); + EngSetLastError(ERROR_INVALID_PARAMETER); return 0; } if (psurf->hSecure == NULL) { DC_UnlockDc(dc); - SetLastWin32Error(ERROR_INVALID_PARAMETER); + EngSetLastError(ERROR_INVALID_PARAMETER); return 0; } @@ -156,7 +156,7 @@ IntSetDIBColorTable( if (psurf->ppal == NULL) { DC_UnlockDc(dc); - SetLastWin32Error(ERROR_INVALID_HANDLE); + EngSetLastError(ERROR_INVALID_HANDLE); return 0; } @@ -208,14 +208,14 @@ IntGetDIBColorTable( if (psurf == NULL) { DC_UnlockDc(dc); - SetLastWin32Error(ERROR_INVALID_PARAMETER); + EngSetLastError(ERROR_INVALID_PARAMETER); return 0; } if (psurf->hSecure == NULL) { DC_UnlockDc(dc); - SetLastWin32Error(ERROR_INVALID_PARAMETER); + EngSetLastError(ERROR_INVALID_PARAMETER); return 0; } @@ -229,7 +229,7 @@ IntGetDIBColorTable( if (psurf->ppal == NULL) { DC_UnlockDc(dc); - SetLastWin32Error(ERROR_INVALID_HANDLE); + EngSetLastError(ERROR_INVALID_HANDLE); return 0; } @@ -277,7 +277,7 @@ IntSetDIBits( if (0 == SourceBitmap) { DPRINT1("Error : Could not create a DIBSection.\n"); - SetLastWin32Error(ERROR_NO_SYSTEM_RESOURCES); + EngSetLastError(ERROR_NO_SYSTEM_RESOURCES); return 0; } @@ -375,7 +375,7 @@ NtGdiSetDIBits( Dc = DC_LockDc(hDC); if (NULL == Dc) { - SetLastWin32Error(ERROR_INVALID_HANDLE); + EngSetLastError(ERROR_INVALID_HANDLE); return 0; } if (Dc->dctype == DC_TYPE_INFO) @@ -447,7 +447,7 @@ NtGdiSetDIBitsToDeviceInternal( pDC = DC_LockDc(hDC); if (!pDC) { - SetLastWin32Error(ERROR_INVALID_HANDLE); + EngSetLastError(ERROR_INVALID_HANDLE); return 0; } if (pDC->dctype == DC_TYPE_INFO) @@ -490,7 +490,7 @@ NtGdiSetDIBitsToDeviceInternal( (PVOID) Bits); if (!hSourceBitmap) { - SetLastWin32Error(ERROR_NO_SYSTEM_RESOURCES); + EngSetLastError(ERROR_NO_SYSTEM_RESOURCES); Status = STATUS_NO_MEMORY; goto Exit; } @@ -508,7 +508,7 @@ NtGdiSetDIBitsToDeviceInternal( hpalDIB = BuildDIBPalette(bmi); if (!hpalDIB) { - SetLastWin32Error(ERROR_NO_SYSTEM_RESOURCES); + EngSetLastError(ERROR_NO_SYSTEM_RESOURCES); Status = STATUS_NO_MEMORY; goto Exit; } @@ -517,7 +517,7 @@ NtGdiSetDIBitsToDeviceInternal( ppalDIB = PALETTE_LockPalette(hpalDIB); if (!ppalDIB) { - SetLastWin32Error(ERROR_INVALID_HANDLE); + EngSetLastError(ERROR_INVALID_HANDLE); Status = STATUS_UNSUCCESSFUL; goto Exit; } @@ -624,7 +624,7 @@ NtGdiGetDIBitsInternal( if(bitmap_type == -1) { DPRINT("Wrong bitmap format\n"); - SetLastWin32Error(ERROR_INVALID_PARAMETER); + EngSetLastError(ERROR_INVALID_PARAMETER); return 0; } else if(bitmap_type == 0) @@ -939,7 +939,7 @@ NtGdiGetDIBitsInternal( if(!hBmpDest) { DPRINT1("Unable to create a DIB Section!\n"); - SetLastWin32Error(ERROR_INVALID_PARAMETER); + EngSetLastError(ERROR_INVALID_PARAMETER); ScanLines = 0; goto done ; } @@ -1038,14 +1038,14 @@ NtGdiStretchDIBitsInternal( safeBits = ExAllocatePoolWithTag(PagedPool, cjMaxBits, TAG_DIB); if(!safeBits) { - SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY); + EngSetLastError(ERROR_NOT_ENOUGH_MEMORY); return 0; } if (!(pdc = DC_LockDc(hDC))) { ExFreePoolWithTag(safeBits, TAG_DIB); - SetLastWin32Error(ERROR_INVALID_HANDLE); + EngSetLastError(ERROR_INVALID_HANDLE); return 0; } @@ -1227,7 +1227,7 @@ NtGdiCreateDIBitmapInternal( safeBits = ExAllocatePoolWithTag(PagedPool, cjMaxBits, TAG_DIB); if(!safeBits) { - SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY); + EngSetLastError(ERROR_NOT_ENOUGH_MEMORY); return NULL; } } @@ -1302,7 +1302,7 @@ GreCreateDIBitmapInternal( Dc = DC_LockDc(hdcDest); if (!Dc) { - SetLastWin32Error(ERROR_INVALID_HANDLE); + EngSetLastError(ERROR_INVALID_HANDLE); return NULL; } /* It's OK to set bpp=0 here, as IntCreateDIBitmap will create a compatible Bitmap @@ -1380,7 +1380,7 @@ NtGdiCreateDIBSection( } else { - SetLastWin32Error(ERROR_INVALID_HANDLE); + EngSetLastError(ERROR_INVALID_HANDLE); } if (bDesktopDC) @@ -1473,7 +1473,7 @@ DIB_CreateDIBSection( PAGE_READWRITE); if (!NT_SUCCESS(Status)) { - SetLastWin32Error(ERROR_INVALID_PARAMETER); + EngSetLastError(ERROR_INVALID_PARAMETER); return NULL; } @@ -1533,13 +1533,13 @@ DIB_CreateDIBSection( 0); if (!res) { - SetLastWin32Error(ERROR_NO_SYSTEM_RESOURCES); + EngSetLastError(ERROR_NO_SYSTEM_RESOURCES); goto cleanup; } bmp = SURFACE_LockSurface(res); if (NULL == bmp) { - SetLastWin32Error(ERROR_INVALID_HANDLE); + EngSetLastError(ERROR_INVALID_HANDLE); goto cleanup; } diff --git a/reactos/subsystems/win32/win32k/objects/drawing.c b/reactos/subsystems/win32/win32k/objects/drawing.c index adc6e9ccf29..8b794938446 100755 --- a/reactos/subsystems/win32/win32k/objects/drawing.c +++ b/reactos/subsystems/win32/win32k/objects/drawing.c @@ -1202,7 +1202,7 @@ IntFillRect( DC *dc, psurf = dc->dclevel.pSurface; if (psurf == NULL) { - SetLastWin32Error(ERROR_INVALID_HANDLE); + EngSetLastError(ERROR_INVALID_HANDLE); return 0; } @@ -1276,7 +1276,7 @@ IntFillArc( PDC dc, if (!pbrush) { DPRINT1("FillArc Fail\n"); - SetLastWin32Error(ERROR_INTERNAL_ERROR); + EngSetLastError(ERROR_INTERNAL_ERROR); return FALSE; } // Sort out alignment here. diff --git a/reactos/subsystems/win32/win32k/objects/fillshap.c b/reactos/subsystems/win32/win32k/objects/fillshap.c index 7779de4313f..d5d6469ff6e 100644 --- a/reactos/subsystems/win32/win32k/objects/fillshap.c +++ b/reactos/subsystems/win32/win32k/objects/fillshap.c @@ -49,7 +49,7 @@ IntGdiPolygon(PDC dc, if (!Points || Count < 2 ) { - SetLastWin32Error(ERROR_INVALID_PARAMETER); + EngSetLastError(ERROR_INVALID_PARAMETER); return FALSE; } @@ -214,7 +214,7 @@ NtGdiEllipse( dc = DC_LockDc(hDC); if (dc == NULL) { - SetLastWin32Error(ERROR_INVALID_HANDLE); + EngSetLastError(ERROR_INVALID_HANDLE); return FALSE; } if (dc->dctype == DC_TYPE_INFO) @@ -253,7 +253,7 @@ NtGdiEllipse( { DPRINT1("Ellipse Fail 1\n"); DC_UnlockDc(dc); - SetLastWin32Error(ERROR_INTERNAL_ERROR); + EngSetLastError(ERROR_INTERNAL_ERROR); return FALSE; } @@ -301,7 +301,7 @@ NtGdiEllipse( if (NULL == pFillBrushObj) { DPRINT1("FillEllipse Fail\n"); - SetLastWin32Error(ERROR_INTERNAL_ERROR); + EngSetLastError(ERROR_INTERNAL_ERROR); ret = FALSE; } else @@ -418,7 +418,7 @@ NtGdiPolyPolyDraw( IN HDC hDC, if (nInvalid != 0) { /* If at least one poly count is 0 or 1, fail */ - SetLastWin32Error(ERROR_INVALID_PARAMETER); + EngSetLastError(ERROR_INVALID_PARAMETER); return FALSE; } @@ -428,7 +428,7 @@ NtGdiPolyPolyDraw( IN HDC hDC, TAG_SHAPE); if (!pTemp) { - SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY); + EngSetLastError(ERROR_NOT_ENOUGH_MEMORY); return FALSE; } @@ -465,7 +465,7 @@ NtGdiPolyPolyDraw( IN HDC hDC, dc = DC_LockDc(hDC); if (!dc) { - SetLastWin32Error(ERROR_INVALID_HANDLE); + EngSetLastError(ERROR_INVALID_HANDLE); ExFreePool(pTemp); return FALSE; } @@ -506,7 +506,7 @@ NtGdiPolyPolyDraw( IN HDC hDC, Ret = IntGdiPolyBezierTo(dc, SafePoints, *SafeCounts); break; default: - SetLastWin32Error(ERROR_INVALID_PARAMETER); + EngSetLastError(ERROR_INVALID_PARAMETER); Ret = FALSE; } @@ -667,7 +667,7 @@ NtGdiRectangle(HDC hDC, dc = DC_LockDc(hDC); if (!dc) { - SetLastWin32Error(ERROR_INVALID_HANDLE); + EngSetLastError(ERROR_INVALID_HANDLE); return FALSE; } if (dc->dctype == DC_TYPE_INFO) @@ -751,7 +751,7 @@ IntRoundRect( if (!pbrushLine) { /* Nothing to do, as we don't have a bitmap */ - SetLastWin32Error(ERROR_INTERNAL_ERROR); + EngSetLastError(ERROR_INTERNAL_ERROR); return FALSE; } @@ -787,7 +787,7 @@ IntRoundRect( if (NULL == pbrushFill) { DPRINT1("FillRound Fail\n"); - SetLastWin32Error(ERROR_INTERNAL_ERROR); + EngSetLastError(ERROR_INTERNAL_ERROR); ret = FALSE; } else @@ -839,7 +839,7 @@ NtGdiRoundRect( if ( !dc ) { DPRINT1("NtGdiRoundRect() - hDC is invalid\n"); - SetLastWin32Error(ERROR_INVALID_HANDLE); + EngSetLastError(ERROR_INVALID_HANDLE); } else if (dc->dctype == DC_TYPE_INFO) { @@ -885,7 +885,7 @@ GreGradientFill( pTriangle->Vertex2 >= nVertex || pTriangle->Vertex3 >= nVertex) { - SetLastWin32Error(ERROR_INVALID_PARAMETER); + EngSetLastError(ERROR_INVALID_PARAMETER); return FALSE; } } @@ -897,7 +897,7 @@ GreGradientFill( { if (pRect->UpperLeft >= nVertex || pRect->LowerRight >= nVertex) { - SetLastWin32Error(ERROR_INVALID_PARAMETER); + EngSetLastError(ERROR_INVALID_PARAMETER); return FALSE; } } @@ -907,7 +907,7 @@ GreGradientFill( pdc = DC_LockDc(hdc); if(!pdc) { - SetLastWin32Error(ERROR_INVALID_HANDLE); + EngSetLastError(ERROR_INVALID_HANDLE); return FALSE; } @@ -991,7 +991,7 @@ NtGdiGradientFill( /* Validate parameters */ if (!pVertex || !nVertex || !pMesh || !nMesh) { - SetLastWin32Error(ERROR_INVALID_PARAMETER); + EngSetLastError(ERROR_INVALID_PARAMETER); return FALSE; } @@ -1005,7 +1005,7 @@ NtGdiGradientFill( cbMesh = nMesh * sizeof(GRADIENT_TRIANGLE); break; default: - SetLastWin32Error(ERROR_INVALID_PARAMETER); + EngSetLastError(ERROR_INVALID_PARAMETER); return FALSE; } @@ -1020,7 +1020,7 @@ NtGdiGradientFill( SafeVertex = ExAllocatePoolWithTag(PagedPool, cbVertex + cbMesh, TAG_SHAPE); if(!SafeVertex) { - SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY); + EngSetLastError(ERROR_NOT_ENOUGH_MEMORY); return FALSE; } @@ -1070,7 +1070,7 @@ NtGdiExtFloodFill( dc = DC_LockDc(hDC); if (!dc) { - SetLastWin32Error(ERROR_INVALID_HANDLE); + EngSetLastError(ERROR_INVALID_HANDLE); return FALSE; } if (dc->dctype == DC_TYPE_INFO) diff --git a/reactos/subsystems/win32/win32k/objects/font.c b/reactos/subsystems/win32/win32k/objects/font.c index 520f256b312..11209049ec6 100644 --- a/reactos/subsystems/win32/win32k/objects/font.c +++ b/reactos/subsystems/win32/win32k/objects/font.c @@ -34,7 +34,7 @@ GreGetKerningPairs( dc = DC_LockDc(hDC); if (!dc) { - SetLastWin32Error(ERROR_INVALID_HANDLE); + EngSetLastError(ERROR_INVALID_HANDLE); return 0; } @@ -44,7 +44,7 @@ GreGetKerningPairs( if (!TextObj) { - SetLastWin32Error(ERROR_INVALID_HANDLE); + EngSetLastError(ERROR_INVALID_HANDLE); return 0; } @@ -57,13 +57,13 @@ GreGetKerningPairs( { if (Count > NumPairs) { - SetLastWin32Error(ERROR_INSUFFICIENT_BUFFER); + EngSetLastError(ERROR_INSUFFICIENT_BUFFER); return 0; } pKP = ExAllocatePoolWithTag(PagedPool, Count * sizeof(KERNINGPAIR), TAG_GDITEXT); if (!pKP) { - SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY); + EngSetLastError(ERROR_NOT_ENOUGH_MEMORY); return 0; } ftGdiGetKerningPairs(FontGDI,Count,pKP); @@ -132,7 +132,7 @@ FontGetObject(PTEXTOBJ TFont, INT Count, PVOID Buffer) break; default: - SetLastWin32Error(ERROR_BUFFER_OVERFLOW); + EngSetLastError(ERROR_BUFFER_OVERFLOW); return 0; } return Count; @@ -323,7 +323,7 @@ NtGdiAddFontResourceW( SafeFileName.Buffer = (PWSTR)ExAllocatePoolWithTag(PagedPool, SafeFileName.MaximumLength, TAG_STRING); if(!SafeFileName.Buffer) { - SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY); + EngSetLastError(ERROR_NOT_ENOUGH_MEMORY); return 0; } @@ -396,7 +396,7 @@ NtGdiGetFontData( Dc = DC_LockDc(hDC); if (Dc == NULL) { - SetLastWin32Error(ERROR_INVALID_HANDLE); + EngSetLastError(ERROR_INVALID_HANDLE); return GDI_ERROR; } pdcattr = Dc->pdcattr; @@ -407,7 +407,7 @@ NtGdiGetFontData( if (TextObj == NULL) { - SetLastWin32Error(ERROR_INVALID_HANDLE); + EngSetLastError(ERROR_INVALID_HANDLE); return GDI_ERROR; } @@ -441,7 +441,7 @@ NtGdiGetFontUnicodeRanges( pDc = DC_LockDc(hdc); if (!pDc) { - SetLastWin32Error(ERROR_INVALID_HANDLE); + EngSetLastError(ERROR_INVALID_HANDLE); return 0; } @@ -452,7 +452,7 @@ NtGdiGetFontUnicodeRanges( if ( TextObj == NULL) { - SetLastWin32Error(ERROR_INVALID_HANDLE); + EngSetLastError(ERROR_INVALID_HANDLE); goto Exit; } FontGdi = ObjToGDI(TextObj->Font, FONT); @@ -464,7 +464,7 @@ NtGdiGetFontUnicodeRanges( pgsSafe = ExAllocatePoolWithTag(PagedPool, Size, TAG_GDITEXT); if (!pgsSafe) { - SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY); + EngSetLastError(ERROR_NOT_ENOUGH_MEMORY); Size = 0; goto Exit; } @@ -515,7 +515,7 @@ NtGdiGetGlyphOutline( dc = DC_LockDc(hdc); if (!dc) { - SetLastWin32Error(ERROR_INVALID_HANDLE); + EngSetLastError(ERROR_INVALID_HANDLE); return GDI_ERROR; } @@ -524,7 +524,7 @@ NtGdiGetGlyphOutline( pvBuf = ExAllocatePoolWithTag(PagedPool, cjBuf, TAG_GDITEXT); if (!pvBuf) { - SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY); + EngSetLastError(ERROR_NOT_ENOUGH_MEMORY); goto Exit; } } @@ -570,7 +570,7 @@ NtGdiGetGlyphOutline( if (! NT_SUCCESS(Status)) { - SetLastWin32Error(ERROR_INVALID_PARAMETER); + EngSetLastError(ERROR_INVALID_PARAMETER); Ret = GDI_ERROR; } @@ -596,7 +596,7 @@ NtGdiGetKerningPairs(HDC hDC, dc = DC_LockDc(hDC); if (!dc) { - SetLastWin32Error(ERROR_INVALID_HANDLE); + EngSetLastError(ERROR_INVALID_HANDLE); return 0; } @@ -606,7 +606,7 @@ NtGdiGetKerningPairs(HDC hDC, if (!TextObj) { - SetLastWin32Error(ERROR_INVALID_HANDLE); + EngSetLastError(ERROR_INVALID_HANDLE); return 0; } @@ -619,13 +619,13 @@ NtGdiGetKerningPairs(HDC hDC, { if (Count > NumPairs) { - SetLastWin32Error(ERROR_INSUFFICIENT_BUFFER); + EngSetLastError(ERROR_INSUFFICIENT_BUFFER); return 0; } pKP = ExAllocatePoolWithTag(PagedPool, Count * sizeof(KERNINGPAIR), TAG_GDITEXT); if (!pKP) { - SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY); + EngSetLastError(ERROR_NOT_ENOUGH_MEMORY); return 0; } ftGdiGetKerningPairs(FontGDI,Count,pKP); @@ -641,7 +641,7 @@ NtGdiGetKerningPairs(HDC hDC, _SEH2_END if (!NT_SUCCESS(Status)) { - SetLastWin32Error(ERROR_INVALID_PARAMETER); + EngSetLastError(ERROR_INVALID_PARAMETER); Count = 0; } ExFreePoolWithTag(pKP,TAG_GDITEXT); @@ -672,7 +672,7 @@ NtGdiGetOutlineTextMetricsInternalW (HDC hDC, dc = DC_LockDc(hDC); if (!dc) { - SetLastWin32Error(ERROR_INVALID_HANDLE); + EngSetLastError(ERROR_INVALID_HANDLE); return 0; } pdcattr = dc->pdcattr; @@ -681,7 +681,7 @@ NtGdiGetOutlineTextMetricsInternalW (HDC hDC, DC_UnlockDc(dc); if (!TextObj) { - SetLastWin32Error(ERROR_INVALID_HANDLE); + EngSetLastError(ERROR_INVALID_HANDLE); return 0; } FontGDI = ObjToGDI(TextObj->Font, FONT); @@ -690,13 +690,13 @@ NtGdiGetOutlineTextMetricsInternalW (HDC hDC, if (!otm) return Size; if (Size > Data) { - SetLastWin32Error(ERROR_INSUFFICIENT_BUFFER); + EngSetLastError(ERROR_INSUFFICIENT_BUFFER); return 0; } potm = ExAllocatePoolWithTag(PagedPool, Size, TAG_GDITEXT); if (!potm) { - SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY); + EngSetLastError(ERROR_NOT_ENOUGH_MEMORY); return 0; } IntGetOutlineTextMetrics(FontGDI, Size, potm); @@ -715,7 +715,7 @@ NtGdiGetOutlineTextMetricsInternalW (HDC hDC, if (!NT_SUCCESS(Status)) { - SetLastWin32Error(ERROR_INVALID_PARAMETER); + EngSetLastError(ERROR_INVALID_PARAMETER); Size = 0; } } @@ -753,7 +753,7 @@ NtGdiGetFontResourceInfoInternalW( dwType == 4 seems to be handled by gdi32 only */ if (dwType == 4 || dwType > 5) { - SetLastWin32Error(ERROR_INVALID_PARAMETER); + EngSetLastError(ERROR_INVALID_PARAMETER); return FALSE; } @@ -765,7 +765,7 @@ NtGdiGetFontResourceInfoInternalW( 'RTSU'); if (!SafeFileNames.Buffer) { - SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY); + EngSetLastError(ERROR_NOT_ENOUGH_MEMORY); return FALSE; } @@ -845,7 +845,7 @@ NtGdiGetRealizationInfo( pDc = DC_LockDc(hdc); if (!pDc) { - SetLastWin32Error(ERROR_INVALID_HANDLE); + EngSetLastError(ERROR_INVALID_HANDLE); return 0; } pdcattr = pDc->pdcattr; diff --git a/reactos/subsystems/win32/win32k/objects/freetype.c b/reactos/subsystems/win32/win32k/objects/freetype.c index f4d17cc5f8c..376d1178d8e 100644 --- a/reactos/subsystems/win32/win32k/objects/freetype.c +++ b/reactos/subsystems/win32/win32k/objects/freetype.c @@ -368,7 +368,7 @@ IntGdiAddFontResource(PUNICODE_STRING FileName, DWORD Characteristics) { FT_Done_Face(Face); ObDereferenceObject(SectionObject); - SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY); + EngSetLastError(ERROR_NOT_ENOUGH_MEMORY); return 0; } @@ -378,7 +378,7 @@ IntGdiAddFontResource(PUNICODE_STRING FileName, DWORD Characteristics) FT_Done_Face(Face); ObDereferenceObject(SectionObject); ExFreePoolWithTag(Entry, TAG_FONT); - SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY); + EngSetLastError(ERROR_NOT_ENOUGH_MEMORY); return 0; } @@ -389,7 +389,7 @@ IntGdiAddFontResource(PUNICODE_STRING FileName, DWORD Characteristics) FT_Done_Face(Face); ObDereferenceObject(SectionObject); ExFreePoolWithTag(Entry, TAG_FONT); - SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY); + EngSetLastError(ERROR_NOT_ENOUGH_MEMORY); return 0; } RtlCopyMemory(FontGDI->Filename, FileName->Buffer, FileName->Length); @@ -1347,7 +1347,7 @@ ftGdiGetRasterizerCaps(LPRASTERIZER_STATUS lprs) lprs->nLanguageID = gusLanguageID; return TRUE; } - SetLastWin32Error(ERROR_INVALID_PARAMETER); + EngSetLastError(ERROR_INVALID_PARAMETER); return FALSE; } @@ -1538,7 +1538,7 @@ ftGdiGetGlyphOutline( if (!TextObj) { - SetLastWin32Error(ERROR_INVALID_HANDLE); + EngSetLastError(ERROR_INVALID_HANDLE); return GDI_ERROR; } FontGDI = ObjToGDI(TextObj->Font, FONT); @@ -1551,7 +1551,7 @@ ftGdiGetGlyphOutline( potm = ExAllocatePoolWithTag(PagedPool, Size, TAG_GDITEXT); if (!potm) { - SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY); + EngSetLastError(ERROR_NOT_ENOUGH_MEMORY); TEXTOBJ_UnlockText(TextObj); return GDI_ERROR; } @@ -2280,7 +2280,7 @@ ftGdiGetTextCharsetInfo( if (!TextObj) { - SetLastWin32Error(ERROR_INVALID_HANDLE); + EngSetLastError(ERROR_INVALID_HANDLE); return Ret; } FontGdi = ObjToGDI(TextObj->Font, FONT); @@ -2452,13 +2452,13 @@ ftGdiGetTextMetricsW( if (!ptmwi) { - SetLastWin32Error(STATUS_INVALID_PARAMETER); + EngSetLastError(STATUS_INVALID_PARAMETER); return FALSE; } if (!(dc = DC_LockDc(hDC))) { - SetLastWin32Error(ERROR_INVALID_HANDLE); + EngSetLastError(ERROR_INVALID_HANDLE); return FALSE; } pdcattr = dc->pdcattr; @@ -2890,7 +2890,7 @@ IntGdiGetFontResourceInfo( NameInfo1 = ExAllocatePoolWithTag(PagedPool, Size, TAG_FINF); if (!NameInfo1) { - SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY); + EngSetLastError(ERROR_NOT_ENOUGH_MEMORY); return FALSE; } @@ -2906,7 +2906,7 @@ IntGdiGetFontResourceInfo( if (!NameInfo2) { ExFreePool(NameInfo1); - SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY); + EngSetLastError(ERROR_NOT_ENOUGH_MEMORY); return FALSE; } @@ -3070,7 +3070,7 @@ NtGdiGetFontFamilyInfo(HDC Dc, Status = MmCopyFromCaller(&LogFont, UnsafeLogFont, sizeof(LOGFONTW)); if (! NT_SUCCESS(Status)) { - SetLastWin32Error(ERROR_INVALID_PARAMETER); + EngSetLastError(ERROR_INVALID_PARAMETER); return -1; } @@ -3078,7 +3078,7 @@ NtGdiGetFontFamilyInfo(HDC Dc, Info = ExAllocatePoolWithTag(PagedPool, Size * sizeof(FONTFAMILYINFO), TAG_GDITEXT); if (NULL == Info) { - SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY); + EngSetLastError(ERROR_NOT_ENOUGH_MEMORY); return -1; } @@ -3120,7 +3120,7 @@ NtGdiGetFontFamilyInfo(HDC Dc, if (! NT_SUCCESS(Status)) { ExFreePool(Info); - SetLastWin32Error(ERROR_INVALID_PARAMETER); + EngSetLastError(ERROR_INVALID_PARAMETER); return -1; } } @@ -3182,7 +3182,7 @@ GreExtTextOutW( dc = DC_LockDc(hDC); if (!dc) { - SetLastWin32Error(ERROR_INVALID_HANDLE); + EngSetLastError(ERROR_INVALID_HANDLE); return FALSE; } if (dc->dctype == DC_TYPE_INFO) @@ -3203,7 +3203,7 @@ GreExtTextOutW( /* Check if String is valid */ if ((Count > 0xFFFF) || (Count > 0 && String == NULL)) { - SetLastWin32Error(ERROR_INVALID_PARAMETER); + EngSetLastError(ERROR_INVALID_PARAMETER); goto fail; } @@ -3663,7 +3663,7 @@ NtGdiExtTextOutW( /* Check if String is valid */ if ((Count > 0xFFFF) || (Count > 0 && UnsafeString == NULL)) { - SetLastWin32Error(ERROR_INVALID_PARAMETER); + EngSetLastError(ERROR_INVALID_PARAMETER); return FALSE; } @@ -3801,13 +3801,13 @@ NtGdiGetCharABCWidthsW( } if (!NT_SUCCESS(Status)) { - SetLastWin32Error(Status); + EngSetLastError(Status); return FALSE; } if (!Buffer) { - SetLastWin32Error(ERROR_INVALID_PARAMETER); + EngSetLastError(ERROR_INVALID_PARAMETER); return FALSE; } @@ -3816,7 +3816,7 @@ NtGdiGetCharABCWidthsW( if (!fl) SafeBuffF = (LPABCFLOAT) SafeBuff; if (SafeBuff == NULL) { - SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY); + EngSetLastError(ERROR_NOT_ENOUGH_MEMORY); return FALSE; } @@ -3824,7 +3824,7 @@ NtGdiGetCharABCWidthsW( if (dc == NULL) { ExFreePool(SafeBuff); - SetLastWin32Error(ERROR_INVALID_HANDLE); + EngSetLastError(ERROR_INVALID_HANDLE); return FALSE; } pdcattr = dc->pdcattr; @@ -3835,7 +3835,7 @@ NtGdiGetCharABCWidthsW( if (TextObj == NULL) { ExFreePool(SafeBuff); - SetLastWin32Error(ERROR_INVALID_HANDLE); + EngSetLastError(ERROR_INVALID_HANDLE); return FALSE; } @@ -3858,7 +3858,7 @@ NtGdiGetCharABCWidthsW( { DPRINT1("WARNING: Could not find desired charmap!\n"); ExFreePool(SafeBuff); - SetLastWin32Error(ERROR_INVALID_HANDLE); + EngSetLastError(ERROR_INVALID_HANDLE); return FALSE; } @@ -3974,7 +3974,7 @@ NtGdiGetCharWidthW( } if (!NT_SUCCESS(Status)) { - SetLastWin32Error(Status); + EngSetLastError(Status); return FALSE; } @@ -3983,7 +3983,7 @@ NtGdiGetCharWidthW( if (!fl) SafeBuffF = (PFLOAT) SafeBuff; if (SafeBuff == NULL) { - SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY); + EngSetLastError(ERROR_NOT_ENOUGH_MEMORY); return FALSE; } @@ -3991,7 +3991,7 @@ NtGdiGetCharWidthW( if (dc == NULL) { ExFreePool(SafeBuff); - SetLastWin32Error(ERROR_INVALID_HANDLE); + EngSetLastError(ERROR_INVALID_HANDLE); return FALSE; } pdcattr = dc->pdcattr; @@ -4002,7 +4002,7 @@ NtGdiGetCharWidthW( if (TextObj == NULL) { ExFreePool(SafeBuff); - SetLastWin32Error(ERROR_INVALID_HANDLE); + EngSetLastError(ERROR_INVALID_HANDLE); return FALSE; } @@ -4025,7 +4025,7 @@ NtGdiGetCharWidthW( { DPRINT1("WARNING: Could not find desired charmap!\n"); ExFreePool(SafeBuff); - SetLastWin32Error(ERROR_INVALID_HANDLE); + EngSetLastError(ERROR_INVALID_HANDLE); return FALSE; } @@ -4098,7 +4098,7 @@ GreGetGlyphIndicesW( dc = DC_LockDc(hdc); if (!dc) { - SetLastWin32Error(ERROR_INVALID_HANDLE); + EngSetLastError(ERROR_INVALID_HANDLE); return GDI_ERROR; } pdcattr = dc->pdcattr; @@ -4107,7 +4107,7 @@ GreGetGlyphIndicesW( DC_UnlockDc(dc); if (!TextObj) { - SetLastWin32Error(ERROR_INVALID_HANDLE); + EngSetLastError(ERROR_INVALID_HANDLE); return GDI_ERROR; } @@ -4117,7 +4117,7 @@ GreGetGlyphIndicesW( Buffer = ExAllocatePoolWithTag(PagedPool, cwc*sizeof(WORD), TAG_GDITEXT); if (!Buffer) { - SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY); + EngSetLastError(ERROR_NOT_ENOUGH_MEMORY); return GDI_ERROR; } @@ -4128,7 +4128,7 @@ GreGetGlyphIndicesW( potm = ExAllocatePoolWithTag(PagedPool, Size, TAG_GDITEXT); if (!potm) { - SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY); + EngSetLastError(ERROR_NOT_ENOUGH_MEMORY); cwc = GDI_ERROR; goto ErrorRet; } @@ -4194,7 +4194,7 @@ NtGdiGetGlyphIndicesW( dc = DC_LockDc(hdc); if (!dc) { - SetLastWin32Error(ERROR_INVALID_HANDLE); + EngSetLastError(ERROR_INVALID_HANDLE); return GDI_ERROR; } pdcattr = dc->pdcattr; @@ -4203,7 +4203,7 @@ NtGdiGetGlyphIndicesW( DC_UnlockDc(dc); if (!TextObj) { - SetLastWin32Error(ERROR_INVALID_HANDLE); + EngSetLastError(ERROR_INVALID_HANDLE); return GDI_ERROR; } @@ -4213,7 +4213,7 @@ NtGdiGetGlyphIndicesW( Buffer = ExAllocatePoolWithTag(PagedPool, cwc*sizeof(WORD), TAG_GDITEXT); if (!Buffer) { - SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY); + EngSetLastError(ERROR_NOT_ENOUGH_MEMORY); return GDI_ERROR; } @@ -4284,7 +4284,7 @@ NtGdiGetGlyphIndicesW( ErrorRet: ExFreePoolWithTag(Buffer, TAG_GDITEXT); if (NT_SUCCESS(Status)) return cwc; - SetLastWin32Error(Status); + EngSetLastError(Status); return GDI_ERROR; } diff --git a/reactos/subsystems/win32/win32k/objects/gdiobj.c b/reactos/subsystems/win32/win32k/objects/gdiobj.c index 5eb43dd6feb..55a805b6dfc 100644 --- a/reactos/subsystems/win32/win32k/objects/gdiobj.c +++ b/reactos/subsystems/win32/win32k/objects/gdiobj.c @@ -1904,7 +1904,7 @@ IntGdiGetObject(IN HANDLE Handle, pGdiObject = GDIOBJ_LockObj(Handle, GDI_OBJECT_TYPE_DONTCARE); if (!pGdiObject) { - SetLastWin32Error(ERROR_INVALID_HANDLE); + EngSetLastError(ERROR_INVALID_HANDLE); return 0; } diff --git a/reactos/subsystems/win32/win32k/objects/icm.c b/reactos/subsystems/win32/win32k/objects/icm.c index 3dfe7d01d18..a3effb060b7 100644 --- a/reactos/subsystems/win32/win32k/objects/icm.c +++ b/reactos/subsystems/win32/win32k/objects/icm.c @@ -53,7 +53,7 @@ IntGdiDeleteColorSpace( if ( hColorSpace != hStockColorSpace ) { Ret = COLORSPACEOBJ_FreeCSByHandle(hColorSpace); - if ( !Ret ) SetLastWin32Error(ERROR_INVALID_PARAMETER); + if ( !Ret ) EngSetLastError(ERROR_INVALID_PARAMETER); } return Ret; } @@ -142,7 +142,7 @@ NtGdiGetDeviceGammaRamp(HDC hDC, dc = DC_LockDc(hDC); if (!dc) { - SetLastWin32Error(ERROR_INVALID_HANDLE); + EngSetLastError(ERROR_INVALID_HANDLE); return FALSE; } @@ -150,7 +150,7 @@ NtGdiGetDeviceGammaRamp(HDC hDC, if (!SafeRamp) { DC_UnlockDc(dc); - SetLastWin32Error(STATUS_NO_MEMORY); + EngSetLastError(STATUS_NO_MEMORY); return FALSE; } @@ -196,7 +196,7 @@ NtGdiSetColorSpace(IN HDC hdc, pDC = DC_LockDc(hdc); if (!pDC) { - SetLastWin32Error(ERROR_INVALID_HANDLE); + EngSetLastError(ERROR_INVALID_HANDLE); return FALSE; } pdcattr = pDC->pdcattr; @@ -210,7 +210,7 @@ NtGdiSetColorSpace(IN HDC hdc, pCS = COLORSPACEOBJ_LockCS(hColorSpace); if (!pCS) { - SetLastWin32Error(ERROR_INVALID_HANDLE); + EngSetLastError(ERROR_INVALID_HANDLE); return FALSE; } @@ -373,7 +373,7 @@ NtGdiSetDeviceGammaRamp(HDC hDC, dc = DC_LockDc(hDC); if (!dc) { - SetLastWin32Error(ERROR_INVALID_HANDLE); + EngSetLastError(ERROR_INVALID_HANDLE); return FALSE; } @@ -381,7 +381,7 @@ NtGdiSetDeviceGammaRamp(HDC hDC, if (!SafeRamp) { DC_UnlockDc(dc); - SetLastWin32Error(STATUS_NO_MEMORY); + EngSetLastError(STATUS_NO_MEMORY); return FALSE; } _SEH2_TRY diff --git a/reactos/subsystems/win32/win32k/objects/line.c b/reactos/subsystems/win32/win32k/objects/line.c index 28ff28ae049..79445d7c680 100644 --- a/reactos/subsystems/win32/win32k/objects/line.c +++ b/reactos/subsystems/win32/win32k/objects/line.c @@ -116,7 +116,7 @@ IntGdiLineTo(DC *dc, psurf = dc->dclevel.pSurface; if (NULL == psurf) { - SetLastWin32Error(ERROR_INVALID_HANDLE); + EngSetLastError(ERROR_INVALID_HANDLE); return FALSE; } @@ -383,7 +383,7 @@ NtGdiLineTo(HDC hDC, dc = DC_LockDc(hDC); if (!dc) { - SetLastWin32Error(ERROR_INVALID_HANDLE); + EngSetLastError(ERROR_INVALID_HANDLE); return FALSE; } if (dc->dctype == DC_TYPE_INFO) diff --git a/reactos/subsystems/win32/win32k/objects/metafile.c b/reactos/subsystems/win32/win32k/objects/metafile.c index dbc62840154..6ef6d716e5e 100644 --- a/reactos/subsystems/win32/win32k/objects/metafile.c +++ b/reactos/subsystems/win32/win32k/objects/metafile.c @@ -75,7 +75,7 @@ NtGdiCreateMetafileDC(IN HDC hdc) { NtGdiDeleteObjectApp(tempHDC); } - SetLastWin32Error(ERROR_INVALID_HANDLE); + EngSetLastError(ERROR_INVALID_HANDLE); return NULL; } @@ -96,7 +96,7 @@ NtGdiCreateMetafileDC(IN HDC hdc) { NtGdiDeleteObjectApp(tempHDC); } - SetLastWin32Error(ERROR_INVALID_HANDLE); + EngSetLastError(ERROR_INVALID_HANDLE); return NULL; } @@ -173,7 +173,7 @@ NtGdiCreateMetafileDC(IN HDC hdc) NtGdiDeleteObjectApp(tempHDC); } DPRINT1("Can not Create EnhMetaFile\n"); - SetLastWin32Error(ERROR_PATH_NOT_FOUND); + EngSetLastError(ERROR_PATH_NOT_FOUND); return NULL; } @@ -194,11 +194,11 @@ NtGdiCreateMetafileDC(IN HDC hdc) NtGdiDeleteObjectApp(tempHDC); } DPRINT1("Create EnhMetaFile fail\n"); - SetLastWin32Error(ERROR_INVALID_HANDLE); + EngSetLastError(ERROR_INVALID_HANDLE); return NULL; } - SetLastWin32Error(IoStatusBlock.Information == FILE_OVERWRITTEN ? ERROR_ALREADY_EXISTS : 0); + EngSetLastError(IoStatusBlock.Information == FILE_OVERWRITTEN ? ERROR_ALREADY_EXISTS : 0); Status = NtWriteFile(Dc->hFile, NULL, NULL, NULL, &Iosb, (PVOID)&Dc->emh, Dc->emh->nSize, NULL, NULL); if (Status == STATUS_PENDING) @@ -219,7 +219,7 @@ NtGdiCreateMetafileDC(IN HDC hdc) { Dc->hFile = NULL; DPRINT1("Write to EnhMetaFile fail\n"); - SetLastWin32Error(ERROR_CAN_NOT_COMPLETE); + EngSetLastError(ERROR_CAN_NOT_COMPLETE); ret = NULL; DC_UnlockDc(Dc); if (hDCRef == NULL) diff --git a/reactos/subsystems/win32/win32k/objects/palette.c b/reactos/subsystems/win32/win32k/objects/palette.c index e930bc116f9..860813ce8f1 100644 --- a/reactos/subsystems/win32/win32k/objects/palette.c +++ b/reactos/subsystems/win32/win32k/objects/palette.c @@ -890,7 +890,7 @@ IntGetSystemPaletteEntries(HDC hDC, if (Entries == 0) { - SetLastWin32Error(ERROR_INVALID_PARAMETER); + EngSetLastError(ERROR_INVALID_PARAMETER); return 0; } @@ -900,14 +900,14 @@ IntGetSystemPaletteEntries(HDC hDC, if (Entries != EntriesSize / sizeof(pe[0])) { /* Integer overflow! */ - SetLastWin32Error(ERROR_INVALID_PARAMETER); + EngSetLastError(ERROR_INVALID_PARAMETER); return 0; } } if (!(dc = DC_LockDc(hDC))) { - SetLastWin32Error(ERROR_INVALID_HANDLE); + EngSetLastError(ERROR_INVALID_HANDLE); return 0; } @@ -1123,7 +1123,7 @@ NtGdiUpdateColors(HDC hDC) Wnd = UserGetWindowObject(IntWindowFromDC(hDC)); if (Wnd == NULL) { - SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE); + EngSetLastError(ERROR_INVALID_WINDOW_HANDLE); if (!calledFromUser){ UserLeave(); diff --git a/reactos/subsystems/win32/win32k/objects/path.c b/reactos/subsystems/win32/win32k/objects/path.c index da4e31fa572..f96580a0ae2 100644 --- a/reactos/subsystems/win32/win32k/objects/path.c +++ b/reactos/subsystems/win32/win32k/objects/path.c @@ -107,7 +107,7 @@ PATH_FillPath( PDC dc, PPATH pPath ) if( pPath->state != PATH_Closed ) { - SetLastWin32Error(ERROR_CAN_NOT_COMPLETE); + EngSetLastError(ERROR_CAN_NOT_COMPLETE); return FALSE; } @@ -1078,7 +1078,7 @@ PATH_PathToRegion ( PPATH pPath, INT nPolyFillMode, HRGN *pHrgn ) pNumPointsInStroke = ExAllocatePoolWithTag(PagedPool, sizeof(ULONG) * numStrokes, TAG_PATH); if(!pNumPointsInStroke) { - SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY); + EngSetLastError(ERROR_NOT_ENOUGH_MEMORY); return FALSE; } @@ -1103,7 +1103,7 @@ PATH_PathToRegion ( PPATH pPath, INT nPolyFillMode, HRGN *pHrgn ) nPolyFillMode); if(hrgn==(HRGN)0) { - SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY); + EngSetLastError(ERROR_NOT_ENOUGH_MEMORY); return FALSE; } @@ -1375,7 +1375,7 @@ BOOL FASTCALL PATH_StrokePath(DC *dc, PPATH pPath) if(!pLinePts) { DPRINT1("Can't allocate pool!\n"); - SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY); + EngSetLastError(ERROR_NOT_ENOUGH_MEMORY); goto end; } nLinePts = 0; @@ -1520,7 +1520,7 @@ PATH_WidenPath(DC *dc) if(pPath->state == PATH_Open) { PATH_UnlockPath( pPath ); - SetLastWin32Error(ERROR_CAN_NOT_COMPLETE); + EngSetLastError(ERROR_CAN_NOT_COMPLETE); return FALSE; } @@ -1530,7 +1530,7 @@ PATH_WidenPath(DC *dc) if (!size) { PATH_UnlockPath( pPath ); - SetLastWin32Error(ERROR_CAN_NOT_COMPLETE); + EngSetLastError(ERROR_CAN_NOT_COMPLETE); return FALSE; } @@ -1548,7 +1548,7 @@ PATH_WidenPath(DC *dc) } else { - SetLastWin32Error(ERROR_CAN_NOT_COMPLETE); + EngSetLastError(ERROR_CAN_NOT_COMPLETE); ExFreePoolWithTag(elp, TAG_PATH); PATH_UnlockPath( pPath ); return FALSE; @@ -1565,7 +1565,7 @@ PATH_WidenPath(DC *dc) if(obj_type == GDI_OBJECT_TYPE_EXTPEN && penType == PS_COSMETIC) { PATH_UnlockPath( pPath ); - SetLastWin32Error(ERROR_CAN_NOT_COMPLETE); + EngSetLastError(ERROR_CAN_NOT_COMPLETE); return FALSE; } @@ -2113,7 +2113,7 @@ NtGdiAbortPath(HDC hDC) PDC dc = DC_LockDc ( hDC ); if ( !dc ) { - SetLastWin32Error(ERROR_INVALID_HANDLE); + EngSetLastError(ERROR_INVALID_HANDLE); return FALSE; } @@ -2140,7 +2140,7 @@ NtGdiBeginPath( HDC hDC ) dc = DC_LockDc ( hDC ); if ( !dc ) { - SetLastWin32Error(ERROR_INVALID_HANDLE); + EngSetLastError(ERROR_INVALID_HANDLE); return FALSE; } @@ -2171,7 +2171,7 @@ NtGdiBeginPath( HDC hDC ) pPath = PATH_AllocPathWithHandle(); if (!pPath) { - SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY); + EngSetLastError(ERROR_NOT_ENOUGH_MEMORY); return FALSE; } dc->dclevel.flPath |= DCPATH_ACTIVE; // Set active ASAP! @@ -2208,7 +2208,7 @@ NtGdiCloseFigure(HDC hDC) pDc = DC_LockDc(hDC); if (!pDc) { - SetLastWin32Error(ERROR_INVALID_PARAMETER); + EngSetLastError(ERROR_INVALID_PARAMETER); return FALSE; } pPath = PATH_LockPath( pDc->dclevel.hPath ); @@ -2226,7 +2226,7 @@ NtGdiCloseFigure(HDC hDC) else { // FIXME: check if lasterror is set correctly - SetLastWin32Error(ERROR_CAN_NOT_COMPLETE); + EngSetLastError(ERROR_CAN_NOT_COMPLETE); } PATH_UnlockPath( pPath ); @@ -2244,7 +2244,7 @@ NtGdiEndPath(HDC hDC) if ( !dc ) { - SetLastWin32Error(ERROR_INVALID_HANDLE); + EngSetLastError(ERROR_INVALID_HANDLE); return FALSE; } @@ -2258,7 +2258,7 @@ NtGdiEndPath(HDC hDC) if ( (pPath->state != PATH_Open) || !(dc->dclevel.flPath & DCPATH_ACTIVE) ) { DPRINT1("EndPath ERROR! 0x%x\n", dc->dclevel.hPath); - SetLastWin32Error(ERROR_CAN_NOT_COMPLETE); + EngSetLastError(ERROR_CAN_NOT_COMPLETE); ret = FALSE; } /* Set flag to indicate that path is finished */ @@ -2284,7 +2284,7 @@ NtGdiFillPath(HDC hDC) if ( !dc ) { - SetLastWin32Error(ERROR_INVALID_PARAMETER); + EngSetLastError(ERROR_INVALID_PARAMETER); return FALSE; } pPath = PATH_LockPath( dc->dclevel.hPath ); @@ -2332,7 +2332,7 @@ NtGdiFlattenPath(HDC hDC) pDc = DC_LockDc(hDC); if (!pDc) { - SetLastWin32Error(ERROR_INVALID_HANDLE); + EngSetLastError(ERROR_INVALID_HANDLE); return FALSE; } @@ -2363,7 +2363,7 @@ NtGdiGetMiterLimit( if (!(pDc = DC_LockDc(hdc))) { - SetLastWin32Error(ERROR_INVALID_PARAMETER); + EngSetLastError(ERROR_INVALID_PARAMETER); return FALSE; } @@ -2411,7 +2411,7 @@ NtGdiGetPath( if (!dc) { DPRINT1("Can't lock dc!\n"); - SetLastWin32Error(ERROR_INVALID_PARAMETER); + EngSetLastError(ERROR_INVALID_PARAMETER); return -1; } @@ -2424,7 +2424,7 @@ NtGdiGetPath( if (pPath->state != PATH_Closed) { - SetLastWin32Error(ERROR_CAN_NOT_COMPLETE); + EngSetLastError(ERROR_CAN_NOT_COMPLETE); goto done; } @@ -2434,7 +2434,7 @@ NtGdiGetPath( } else if(nSizenumEntriesUsed) { - SetLastWin32Error(ERROR_INVALID_PARAMETER); + EngSetLastError(ERROR_INVALID_PARAMETER); goto done; } else @@ -2476,7 +2476,7 @@ NtGdiPathToRegion(HDC hDC) pDc = DC_LockDc(hDC); if (!pDc) { - SetLastWin32Error(ERROR_INVALID_PARAMETER); + EngSetLastError(ERROR_INVALID_PARAMETER); return NULL; } @@ -2492,7 +2492,7 @@ NtGdiPathToRegion(HDC hDC) if (pPath->state!=PATH_Closed) { //FIXME: check that setlasterror is being called correctly - SetLastWin32Error(ERROR_CAN_NOT_COMPLETE); + EngSetLastError(ERROR_CAN_NOT_COMPLETE); } else { @@ -2519,7 +2519,7 @@ NtGdiSetMiterLimit( if (!(pDc = DC_LockDc(hdc))) { - SetLastWin32Error(ERROR_INVALID_PARAMETER); + EngSetLastError(ERROR_INVALID_PARAMETER); return FALSE; } @@ -2566,7 +2566,7 @@ NtGdiStrokeAndFillPath(HDC hDC) if (!(pDc = DC_LockDc(hDC))) { - SetLastWin32Error(ERROR_INVALID_PARAMETER); + EngSetLastError(ERROR_INVALID_PARAMETER); return FALSE; } pPath = PATH_LockPath( pDc->dclevel.hPath ); @@ -2610,7 +2610,7 @@ NtGdiStrokePath(HDC hDC) if (!(pDc = DC_LockDc(hDC))) { - SetLastWin32Error(ERROR_INVALID_PARAMETER); + EngSetLastError(ERROR_INVALID_PARAMETER); return FALSE; } pPath = PATH_LockPath( pDc->dclevel.hPath ); @@ -2646,7 +2646,7 @@ NtGdiWidenPath(HDC hDC) PDC pdc = DC_LockDc ( hDC ); if ( !pdc ) { - SetLastWin32Error(ERROR_INVALID_PARAMETER); + EngSetLastError(ERROR_INVALID_PARAMETER); return FALSE; } Ret = PATH_WidenPath(pdc); diff --git a/reactos/subsystems/win32/win32k/objects/pen.c b/reactos/subsystems/win32/win32k/objects/pen.c index 5884945c285..953fdff6eec 100644 --- a/reactos/subsystems/win32/win32k/objects/pen.c +++ b/reactos/subsystems/win32/win32k/objects/pen.c @@ -87,7 +87,7 @@ IntGdiExtCreatePen( if (!pbrushPen) { - SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY); + EngSetLastError(ERROR_NOT_ENOUGH_MEMORY); DPRINT("Can't allocate pen\n"); return 0; } @@ -187,7 +187,7 @@ IntGdiExtCreatePen( return hPen; ExitCleanup: - SetLastWin32Error(ERROR_INVALID_PARAMETER); + EngSetLastError(ERROR_INVALID_PARAMETER); pbrushPen->pStyle = NULL; PEN_UnlockPen(pbrushPen); if (bOldStylePen) @@ -287,7 +287,7 @@ NtGdiCreatePen( { if ( PenStyle < PS_SOLID || PenStyle > PS_INSIDEFRAME ) { - SetLastWin32Error(ERROR_INVALID_PARAMETER); + EngSetLastError(ERROR_INVALID_PARAMETER); return NULL; } @@ -325,7 +325,7 @@ NtGdiExtCreatePen( if ((int)dwStyleCount < 0) return 0; if (dwStyleCount > 16) { - SetLastWin32Error(ERROR_INVALID_PARAMETER); + EngSetLastError(ERROR_INVALID_PARAMETER); return 0; } diff --git a/reactos/subsystems/win32/win32k/objects/print.c b/reactos/subsystems/win32/win32k/objects/print.c index 6377c5e9cae..b9592e09fc2 100644 --- a/reactos/subsystems/win32/win32k/objects/print.c +++ b/reactos/subsystems/win32/win32k/objects/print.c @@ -76,7 +76,7 @@ NtGdiEscape(HDC hDC, dc = DC_LockDc(hDC); if (dc == NULL) { - SetLastWin32Error(ERROR_INVALID_HANDLE); + EngSetLastError(ERROR_INVALID_HANDLE); return SP_ERROR; } @@ -144,7 +144,7 @@ NtGdiExtEscape( pDC = DC_LockDc(hDC); if ( pDC == NULL ) { - SetLastWin32Error(ERROR_INVALID_HANDLE); + EngSetLastError(ERROR_INVALID_HANDLE); return -1; } if ( pDC->dctype == DC_TYPE_INFO) @@ -178,7 +178,7 @@ NtGdiExtEscape( if ( !SafeInData ) { DC_UnlockDc(pDC); - SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY); + EngSetLastError(ERROR_NOT_ENOUGH_MEMORY); return -1; } @@ -227,7 +227,7 @@ NtGdiExtEscape( SafeOutData = ExAllocatePoolWithTag ( PagedPool, OutSize, TAG_PRINT ); if ( !SafeOutData ) { - SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY); + EngSetLastError(ERROR_NOT_ENOUGH_MEMORY); freeout: if ( SafeInData ) ExFreePoolWithTag ( SafeInData, TAG_PRINT ); diff --git a/reactos/subsystems/win32/win32k/objects/region.c b/reactos/subsystems/win32/win32k/objects/region.c index 9a73ace548e..ca52b082d2f 100644 --- a/reactos/subsystems/win32/win32k/objects/region.c +++ b/reactos/subsystems/win32/win32k/objects/region.c @@ -2336,20 +2336,20 @@ IntGdiCombineRgn(PROSRGNDATA destRgn, else if (src2Rgn == NULL) { DPRINT1("IntGdiCombineRgn requires hSrc2 != NULL for combine mode %d!\n", CombineMode); - SetLastWin32Error(ERROR_INVALID_HANDLE); + EngSetLastError(ERROR_INVALID_HANDLE); } } } else { DPRINT("IntGdiCombineRgn: hSrc1 unavailable\n"); - SetLastWin32Error(ERROR_INVALID_HANDLE); + EngSetLastError(ERROR_INVALID_HANDLE); } } else { DPRINT("IntGdiCombineRgn: hDest unavailable\n"); - SetLastWin32Error(ERROR_INVALID_HANDLE); + EngSetLastError(ERROR_INVALID_HANDLE); } return result; } @@ -3231,14 +3231,14 @@ NtGdiCombineRgn(HRGN hDest, if ( CombineMode > RGN_COPY && CombineMode < RGN_AND) { - SetLastWin32Error(ERROR_INVALID_PARAMETER); + EngSetLastError(ERROR_INVALID_PARAMETER); return ERROR; } destRgn = RGNOBJAPI_Lock(hDest, NULL); if (!destRgn) { - SetLastWin32Error(ERROR_INVALID_HANDLE); + EngSetLastError(ERROR_INVALID_HANDLE); return ERROR; } @@ -3246,7 +3246,7 @@ NtGdiCombineRgn(HRGN hDest, if (!src1Rgn) { RGNOBJAPI_Unlock(destRgn); - SetLastWin32Error(ERROR_INVALID_HANDLE); + EngSetLastError(ERROR_INVALID_HANDLE); return ERROR; } @@ -3285,7 +3285,7 @@ NtGdiCreateRectRgn(INT LeftRect, INT TopRect, INT RightRect, INT BottomRect) /* Allocate region data structure with space for 1 RECTL */ if (!(pRgn = REGION_AllocUserRgnWithHandle(1))) { - SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY); + EngSetLastError(ERROR_NOT_ENOUGH_MEMORY); return NULL; } hRgn = pRgn->BaseObject.hHmgr; @@ -3518,7 +3518,7 @@ NtGdiExtCreateRegion( if (Region == NULL) { - SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY); + EngSetLastError(ERROR_NOT_ENOUGH_MEMORY); return FALSE; } hRgn = Region->BaseObject.hHmgr; @@ -3562,7 +3562,7 @@ NtGdiExtCreateRegion( _SEH2_END; if (!NT_SUCCESS(Status)) { - SetLastWin32Error(ERROR_INVALID_PARAMETER); + EngSetLastError(ERROR_INVALID_PARAMETER); RGNOBJAPI_Unlock(Region); GreDeleteObject(hRgn); return NULL; @@ -3667,7 +3667,7 @@ NtGdiGetRandomRgn( pDC = DC_LockDc(hDC); if (pDC == NULL) { - SetLastWin32Error(ERROR_INVALID_HANDLE); + EngSetLastError(ERROR_INVALID_HANDLE); return -1; } @@ -3768,7 +3768,7 @@ NtGdiInvertRgn( if (!(RgnData = RGNOBJAPI_Lock(hRgn, NULL))) { - SetLastWin32Error(ERROR_INVALID_HANDLE); + EngSetLastError(ERROR_INVALID_HANDLE); return FALSE; } @@ -3921,7 +3921,7 @@ NtGdiUnionRectWithRgn( if (!(Rgn = RGNOBJAPI_Lock(hDest, NULL))) { - SetLastWin32Error(ERROR_INVALID_HANDLE); + EngSetLastError(ERROR_INVALID_HANDLE); return NULL; } diff --git a/reactos/subsystems/win32/win32k/objects/text.c b/reactos/subsystems/win32/win32k/objects/text.c index b39ee850b39..bc5f45dae6d 100644 --- a/reactos/subsystems/win32/win32k/objects/text.c +++ b/reactos/subsystems/win32/win32k/objects/text.c @@ -45,7 +45,7 @@ GreGetTextExtentW( pdc = DC_LockDc(hDC); if (!pdc) { - SetLastWin32Error(ERROR_INVALID_HANDLE); + EngSetLastError(ERROR_INVALID_HANDLE); return FALSE; } @@ -97,7 +97,7 @@ GreGetTextExtentExW( if ( (!String && Count ) || !pSize ) { - SetLastWin32Error(ERROR_INVALID_PARAMETER); + EngSetLastError(ERROR_INVALID_PARAMETER); return FALSE; } @@ -110,7 +110,7 @@ GreGetTextExtentExW( pdc = DC_LockDc(hDC); if (NULL == pdc) { - SetLastWin32Error(ERROR_INVALID_HANDLE); + EngSetLastError(ERROR_INVALID_HANDLE); return FALSE; } pdcattr = pdc->pdcattr; @@ -148,7 +148,7 @@ NtGdiGetCharSet(HDC hDC) Dc = DC_LockDc(hDC); if (!Dc) { - SetLastWin32Error(ERROR_INVALID_HANDLE); + EngSetLastError(ERROR_INVALID_HANDLE); return 0; } cscp = ftGdiGetTextCharsetInfo(Dc,NULL,0); @@ -214,7 +214,7 @@ NtGdiGetTextCharsetInfo( Dc = DC_LockDc(hdc); if (!Dc) { - SetLastWin32Error(ERROR_INVALID_HANDLE); + EngSetLastError(ERROR_INVALID_HANDLE); return DEFAULT_CHARSET; } @@ -298,7 +298,7 @@ NtGdiGetTextExtentExW( String = ExAllocatePoolWithTag(PagedPool, Count * sizeof(WCHAR), TAG_GDITEXT); if (NULL == String) { - SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY); + EngSetLastError(ERROR_NOT_ENOUGH_MEMORY); return FALSE; } @@ -308,7 +308,7 @@ NtGdiGetTextExtentExW( if (NULL == Dx) { ExFreePoolWithTag(String, TAG_GDITEXT); - SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY); + EngSetLastError(ERROR_NOT_ENOUGH_MEMORY); return FALSE; } } @@ -337,7 +337,7 @@ NtGdiGetTextExtentExW( ExFreePoolWithTag(Dx, TAG_GDITEXT); } ExFreePoolWithTag(String, TAG_GDITEXT); - SetLastWin32Error(ERROR_INVALID_HANDLE); + EngSetLastError(ERROR_INVALID_HANDLE); return FALSE; } pdcattr = dc->pdcattr; @@ -440,7 +440,7 @@ NtGdiSetTextJustification(HDC hDC, pDc = DC_LockDc(hDC); if (!pDc) { - SetLastWin32Error(ERROR_INVALID_HANDLE); + EngSetLastError(ERROR_INVALID_HANDLE); return FALSE; } @@ -476,7 +476,7 @@ NtGdiGetTextFaceW( Dc = DC_LockDc(hDC); if (Dc == NULL) { - SetLastWin32Error(ERROR_INVALID_HANDLE); + EngSetLastError(ERROR_INVALID_HANDLE); return FALSE; } pdcattr = Dc->pdcattr; diff --git a/reactos/subsystems/win32/win32k/objects/wingl.c b/reactos/subsystems/win32/win32k/objects/wingl.c index 72add55b52b..6be90d72e98 100644 --- a/reactos/subsystems/win32/win32k/objects/wingl.c +++ b/reactos/subsystems/win32/win32k/objects/wingl.c @@ -69,7 +69,7 @@ NtGdiDescribePixelFormat(HDC hDC, pdc = DC_LockDc(hDC); if (!pdc) { - SetLastWin32Error(ERROR_INVALID_HANDLE); + EngSetLastError(ERROR_INVALID_HANDLE); return 0; } @@ -79,7 +79,7 @@ NtGdiDescribePixelFormat(HDC hDC, PixelFormat < 1 || PixelFormat > pdc->ipfdDevMax ) { - SetLastWin32Error(ERROR_INVALID_PARAMETER); + EngSetLastError(ERROR_INVALID_PARAMETER); goto Exit; } @@ -137,7 +137,7 @@ NtGdiSetPixelFormat( pdc = DC_LockDc(hdc); if (!pdc) { - SetLastWin32Error(ERROR_INVALID_HANDLE); + EngSetLastError(ERROR_INVALID_HANDLE); return FALSE; } @@ -146,7 +146,7 @@ NtGdiSetPixelFormat( if ( ipfd < 1 || ipfd > pdc->ipfdDevMax ) { - SetLastWin32Error(ERROR_INVALID_PARAMETER); + EngSetLastError(ERROR_INVALID_PARAMETER); goto Exit; } @@ -156,7 +156,7 @@ NtGdiSetPixelFormat( if (!hWnd) { - SetLastWin32Error(ERROR_INVALID_WINDOW_STYLE); + EngSetLastError(ERROR_INVALID_WINDOW_STYLE); goto Exit; } @@ -168,7 +168,7 @@ NtGdiSetPixelFormat( if (pWndObj) pso = pWndObj->psoOwner; else { - SetLastWin32Error(ERROR_INVALID_PIXEL_FORMAT); + EngSetLastError(ERROR_INVALID_PIXEL_FORMAT); goto Exit; } diff --git a/reactos/subsystems/win32/win32k/win32k.rbuild b/reactos/subsystems/win32/win32k/win32k.rbuild index 0950f08d5ed..a18cb1ce625 100644 --- a/reactos/subsystems/win32/win32k/win32k.rbuild +++ b/reactos/subsystems/win32/win32k/win32k.rbuild @@ -94,7 +94,6 @@ driver.c - err.c file.c math.c rtlstr.c From 866846bf8cd5ef49ca67c7162137d689fe6d1a8f Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Sun, 26 Dec 2010 09:39:31 +0000 Subject: [PATCH 116/181] [CALC] Initialize next field. Fixes CID 11063 svn path=/trunk/; revision=50140 --- reactos/base/applications/calc/rpn.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/reactos/base/applications/calc/rpn.c b/reactos/base/applications/calc/rpn.c index e757434b6ef..ccbf171ba77 100644 --- a/reactos/base/applications/calc/rpn.c +++ b/reactos/base/applications/calc/rpn.c @@ -351,7 +351,7 @@ static void evalStack(calc_number_t *number) } else { push(op); break; - } + } } if(ip.node.operation != RPN_OPERATOR_EQUAL && ip.node.operation != RPN_OPERATOR_PERCENT) @@ -380,6 +380,7 @@ int exec_infix2postfix(calc_number_t *number, unsigned int func) tmp.node.number = *number; tmp.node.base = calc.base; tmp.node.operation = func; + tmp.next = NULL; push(&tmp); @@ -446,7 +447,7 @@ void flush_postfix() while (!is_stack_empty()) pop(); /* clear prev and last typed operators */ - calc.prev_operator = + calc.prev_operator = calc.last_operator = 0; } From 2062df62caff557fcd9963f8e934b26d355b96a1 Mon Sep 17 00:00:00 2001 From: James Tabor Date: Sun, 26 Dec 2010 11:11:27 +0000 Subject: [PATCH 117/181] [Win32k] - Fixes bug 5792 and Get/PeekMessage tests. I noticed co_IntPostOrSendMessage to co_IntSendMessageNoWait changes when it should have been changed to co_IntSendMessage. Same as co_IntSendMessage to co_IntSendMessageNoWait when it should have not changed.... I'm sorting it out. ATM win test locks up and the system shutdown box is not present only the text message. svn path=/trunk/; revision=50141 --- reactos/subsystems/win32/win32k/ntuser/desktop.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/reactos/subsystems/win32/win32k/ntuser/desktop.c b/reactos/subsystems/win32/win32k/ntuser/desktop.c index d279995599e..95c07af381e 100644 --- a/reactos/subsystems/win32/win32k/ntuser/desktop.c +++ b/reactos/subsystems/win32/win32k/ntuser/desktop.c @@ -708,22 +708,20 @@ VOID co_IntShellHookNotify(WPARAM Message, LPARAM lParam) PDESKTOP Desktop = IntGetActiveDesktop(); HWND* HwndList; - static UINT MsgType = 0; - - if (!MsgType) + if (!gpsi->uiShellMsg) { /* Too bad, this doesn't work.*/ #if 0 UNICODE_STRING Str; RtlInitUnicodeString(&Str, L"SHELLHOOK"); - MsgType = UserRegisterWindowMessage(&Str); + gpsi->uiShellMsg = UserRegisterWindowMessage(&Str); #endif - MsgType = IntAddAtom(L"SHELLHOOK"); + gpsi->uiShellMsg = IntAddAtom(L"SHELLHOOK"); - DPRINT("MsgType = %x\n", MsgType); - if (!MsgType) + DPRINT("MsgType = %x\n", gpsi->uiShellMsg); + if (!gpsi->uiShellMsg) DPRINT1("LastError: %x\n", EngGetLastError()); } @@ -740,7 +738,7 @@ VOID co_IntShellHookNotify(WPARAM Message, LPARAM lParam) for (; *cursor; cursor++) { - co_IntSendMessageNoWait(*cursor, MsgType, Message, lParam); + UserPostMessage(*cursor, gpsi->uiShellMsg, Message, lParam); } ExFreePool(HwndList); From eee450c6e0c9725b1dd849942296cea53f799b04 Mon Sep 17 00:00:00 2001 From: Aleksey Bragin Date: Sun, 26 Dec 2010 12:56:51 +0000 Subject: [PATCH 118/181] [PSDK] - Oleg Baikalow: Don't call TDIEntityID structure and type with the same name. svn path=/trunk/; revision=50143 --- reactos/include/psdk/tdiinfo.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reactos/include/psdk/tdiinfo.h b/reactos/include/psdk/tdiinfo.h index dd9d62fb452..589300d2fb5 100644 --- a/reactos/include/psdk/tdiinfo.h +++ b/reactos/include/psdk/tdiinfo.h @@ -27,7 +27,7 @@ extern "C" { #endif -typedef struct TDIEntityID { +typedef struct _TDIEntityID { ULONG tei_entity; ULONG tei_instance; } TDIEntityID; From f75ed5ac15b250ea4b82e693bff2e63705e66f65 Mon Sep 17 00:00:00 2001 From: Daniel Reimer Date: Sun, 26 Dec 2010 13:28:51 +0000 Subject: [PATCH 119/181] Bug 5756: TRANSLATION: multiple modules: Bulgarian by CCTAHEB Bug 5761: TRANSLATION: Czech translation update by Radek Liska svn path=/trunk/; revision=50144 --- reactos/base/applications/calc/lang/bg-BG.rc | 1 + reactos/base/applications/calc/lang/cs-CZ.rc | 4 +- reactos/base/applications/cmdutils/reg/Bg.rc | 40 +++ .../base/applications/cmdutils/reg/rsrc.rc | 1 + .../applications/games/winmine/lang/bg-BG.rc | 94 ++++++ .../base/applications/games/winmine/rsrc.rc | 1 + .../mscutils/eventvwr/lang/bg-BG.rc | 18 +- .../mscutils/servman/lang/bg-BG.rc | 13 +- reactos/base/applications/rapps/lang/cs-CZ.rc | 198 +++++++++++++ .../rapps/rapps/ac97forvirtualbox.txt | 6 + .../applications/rapps/rapps/firefox2.txt | 6 + .../applications/rapps/rapps/firefox3.txt | 6 + .../applications/rapps/rapps/offbyone.txt | 3 + .../base/applications/rapps/rapps/opera.txt | 3 + .../base/applications/rapps/rapps/rosbe.txt | 3 + .../applications/rapps/rapps/rosbeamd64.txt | 3 + .../applications/rapps/rapps/sdl_mixer.txt | 3 + .../applications/rapps/rapps/tuxpaint.txt | 3 + reactos/base/applications/rapps/rsrc.rc | 1 + .../base/applications/regedit/lang/bg-BG.rc | 23 +- .../base/applications/taskmgr/lang/bg-BG.rc | 8 +- reactos/base/setup/usetup/lang/bg-BG.h | 4 +- reactos/base/setup/usetup/lang/cs-CZ.h | 6 +- reactos/base/shell/explorer-new/lang/bg-BG.rc | 6 +- reactos/base/shell/explorer-new/lang/cs-CZ.rc | 4 +- reactos/dll/cpl/console/lang/bg-BG.rc | 149 ++++++++++ reactos/dll/cpl/console/rsrc.rc | 1 + reactos/dll/cpl/input/lang/cs-CZ.rc | 246 ++++++++++++++++ reactos/dll/cpl/input/rsrc.rc | 1 + reactos/dll/cpl/intl/lang/bg-BG.rc | 8 +- reactos/dll/cpl/sysdm/lang/bg-BG.rc | 3 +- reactos/dll/cpl/sysdm/lang/cs-CZ.rc | 8 +- reactos/dll/cpl/timedate/lang/bg-BG.rc | 2 +- reactos/dll/win32/avifil32/avifile_Bg.rc | 55 ++++ reactos/dll/win32/avifil32/rsrc.rc | 1 + reactos/dll/win32/browseui/browseui.rc | 4 +- reactos/dll/win32/browseui/lang/Bg-bg.rc | 276 ++++++++++++++++++ reactos/dll/win32/devmgr/lang/bg-BG.rc | 20 +- reactos/dll/win32/netid/lang/bg-BG.rc | 8 +- reactos/dll/win32/netid/lang/en-US.rc | 1 + reactos/dll/win32/shell32/lang/bg-BG.rc | 8 +- reactos/dll/win32/syssetup/lang/bg-BG.rc | 12 +- 42 files changed, 1186 insertions(+), 75 deletions(-) create mode 100644 reactos/base/applications/cmdutils/reg/Bg.rc create mode 100644 reactos/base/applications/games/winmine/lang/bg-BG.rc create mode 100644 reactos/base/applications/rapps/lang/cs-CZ.rc create mode 100644 reactos/dll/cpl/console/lang/bg-BG.rc create mode 100644 reactos/dll/cpl/input/lang/cs-CZ.rc create mode 100644 reactos/dll/win32/avifil32/avifile_Bg.rc create mode 100644 reactos/dll/win32/browseui/lang/Bg-bg.rc diff --git a/reactos/base/applications/calc/lang/bg-BG.rc b/reactos/base/applications/calc/lang/bg-BG.rc index 19f411df033..9fe90352987 100644 --- a/reactos/base/applications/calc/lang/bg-BG.rc +++ b/reactos/base/applications/calc/lang/bg-BG.rc @@ -1,3 +1,4 @@ +//Íåäîâúðøåí LANGUAGE LANG_BULGARIAN, SUBLANG_DEFAULT // Dialog diff --git a/reactos/base/applications/calc/lang/cs-CZ.rc b/reactos/base/applications/calc/lang/cs-CZ.rc index c1f842282de..a062074f93b 100644 --- a/reactos/base/applications/calc/lang/cs-CZ.rc +++ b/reactos/base/applications/calc/lang/cs-CZ.rc @@ -1,6 +1,6 @@ /* FILE: base/applications/calc/lang/cs-CZ.rc * TRANSLATOR: Radek Liska aka Black_Fox (radekliska at gmail dot com) - * UPDATED: 2009-01-25 + * UPDATED: 2010-05-30 */ LANGUAGE LANG_CZECH, SUBLANG_DEFAULT @@ -644,7 +644,7 @@ STRINGTABLE DISCARDABLE BEGIN IDS_TIME_DAYS "Dny" IDS_TIME_HOURS "Hodiny" - IDS_TIME_NANOSECONDS "Nanoseconds" + IDS_TIME_NANOSECONDS "Nanosekundy" IDS_TIME_MICROSECONDS "Mikrosekundy" IDS_TIME_MILLISECONDS "Milisekundy" IDS_TIME_MINUTES "Minuty" diff --git a/reactos/base/applications/cmdutils/reg/Bg.rc b/reactos/base/applications/cmdutils/reg/Bg.rc new file mode 100644 index 00000000000..1672d265b92 --- /dev/null +++ b/reactos/base/applications/cmdutils/reg/Bg.rc @@ -0,0 +1,40 @@ +/* + * REG.EXE - Wine-compatible reg program. + * Bulgarian language support + * + * Copyright 2008 Andrew Riedi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "reg.h" + +/* UTF-8 */ +#pragma code_page(65001) + +LANGUAGE LANG_BULGARIAN, SUBLANG_DEFAULT + +STRINGTABLE +{ + STRING_USAGE, "СинтакÑиÑÑŠÑ‚ на командата е:\n\nREG [ ADD | DELETE | QUERY ]\nREG команда /?\n" + STRING_ADD_USAGE, "REG ADD ключ_име [/v ÑтойноÑÑ‚_име | /ve] [/t вид] [/s разделител] [/d данни] [/f]\n" + STRING_DELETE_USAGE, "REG DELETE ключ_име [/v ÑтойноÑÑ‚_име | /ve | /va] [/f]\n" + STRING_QUERY_USAGE, "REG QUERY ключ_име [/v ÑтойноÑÑ‚_име | /ve] [/s]\n" + STRING_SUCCESS, "ДеÑйÑтвието е приключено уÑпешно\n" + STRING_INVALID_KEY, "Грешка: ÐедопуÑтимо име за ключ\n" + STRING_INVALID_CMDLINE, "Грешка: Ðеправилни параметри на ÐºÐ¾Ð¼Ð°Ð½Ð´Ð¸Ñ Ñ€ÐµÐ´\n" + STRING_NO_REMOTE, "Грешка: ÐеуÑпешно добавÑне на ключове в отдалечената машина\n" + STRING_CANNOT_FIND, "Грешка: Уредбата не откри ÑƒÐºÐ°Ð·Ð°Ð½Ð¸Ñ Ñ€ÐµÐ³Ð¸Ñтърен ключ или ÑтойноÑÑ‚\n" +} diff --git a/reactos/base/applications/cmdutils/reg/rsrc.rc b/reactos/base/applications/cmdutils/reg/rsrc.rc index 9ff5e373f44..d49a7957b49 100644 --- a/reactos/base/applications/cmdutils/reg/rsrc.rc +++ b/reactos/base/applications/cmdutils/reg/rsrc.rc @@ -4,6 +4,7 @@ #include "Pl.rc" /* UTF-8 */ +#include "Bg.rc" #include "Da.rc" #include "De.rc" #include "Es.rc" diff --git a/reactos/base/applications/games/winmine/lang/bg-BG.rc b/reactos/base/applications/games/winmine/lang/bg-BG.rc new file mode 100644 index 00000000000..bceaa5517bb --- /dev/null +++ b/reactos/base/applications/games/winmine/lang/bg-BG.rc @@ -0,0 +1,94 @@ +/* + * WineMine + * Bulgarian Language Support + * + * Copyright 2000 Joshua Thielen + * Copyright 2003 Marcelo Duarte + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "resource.h" + +LANGUAGE LANG_BULGARIAN, SUBLANG_DEFAULT + +STRINGTABLE BEGIN + IDS_APPNAME, "Ìèíè÷êè" + IDS_NOBODY, "Íèêîé" + IDS_ABOUT, "Copyright 2000 Joshua Thielen" +END + +MENU_WINEMINE MENU +BEGIN + POPUP "Íà&ñòðîéêè" BEGIN + MENUITEM "&Íîâ\tF2", IDM_NEW + MENUITEM SEPARATOR + MENUITEM "Ñëàãàíå íà &ïèòàíêà", IDM_MARKQ + MENUITEM SEPARATOR + MENUITEM "Íà&÷èíàåù", IDM_BEGINNER + MENUITEM "&Íàïðåäíàë", IDM_ADVANCED + MENUITEM "&Âåù", IDM_EXPERT + MENUITEM "&Íàãàæäàíå...", IDM_CUSTOM + MENUITEM SEPARATOR + MENUITEM "Èç&õîä\tAlt+X", IDM_EXIT + END + POPUP "&Ñâåäåíèÿ" BEGIN + MENUITEM "Íàé-&áúðçè...", IDM_TIMES + MENUITEM "&Çà", IDM_ABOUT + END +END + +DLG_TIMES DIALOGEX 0, 0, 160, 80 +STYLE DS_MODALFRAME | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | WS_POPUP | DS_SHELLFONT +CAPTION "Íàé-áúðçè" +FONT 8, "MS Shell Dlg" +BEGIN + GROUPBOX "Íàé-áúðçè", -1, 10, 10, 140, 45 + LTEXT "Íà÷èíàåù", -1, 20, 20, 40, 8 + LTEXT "Ðàçøèðåíè", -1, 20, 30, 40, 8 + LTEXT "Ðàçáèðà÷", -1, 20, 40, 40, 8 + LTEXT "999", IDC_TIME1, 70, 20, 15, 8 + LTEXT "999", IDC_TIME2, 70, 30, 15, 8 + LTEXT "999", IDC_TIME3, 70, 40, 15, 8 + LTEXT "", IDC_NAME1, 90, 20, 55, 8 + LTEXT "", IDC_NAME2, 90, 30, 55, 8 + LTEXT "", IDC_NAME3, 90, 40, 55, 8 + DEFPUSHBUTTON "Äîáðå", IDOK, 55, 60, 50, 15 +END + +DLG_CONGRATS DIALOGEX 0, 0, 160, 60 +STYLE DS_MODALFRAME | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | WS_POPUP | DS_SHELLFONT +CAPTION "Ïîçäðàâëåíèÿ!" +FONT 8, "MS Shell Dlg" +BEGIN + LTEXT "Âúâåäåòå èìåòî ñè", -1, 10, 10, 150, 10 + EDITTEXT IDC_EDITNAME, 25, 20, 110, 12 + DEFPUSHBUTTON "Äîáðå", IDOK, 60, 40, 40, 15 +END + +DLG_CUSTOM DIALOGEX 0, 0, 100, 110 +STYLE DS_MODALFRAME | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | WS_POPUP | DS_SHELLFONT +CAPTION "Íàãîäåíà èãðà" +FONT 8, "MS Shell Dlg" +BEGIN + LTEXT "Ðåäîâå", -1, 5, 5, 30, 10 + LTEXT "Ñòúëáîâå", -1, 5, 35, 30, 10 + LTEXT "Ìèíè", -1, 5, 65, 30, 10 + EDITTEXT IDC_EDITROWS, 5, 15, 20, 12, ES_NUMBER + EDITTEXT IDC_EDITCOLS, 5, 45, 20, 12, ES_NUMBER + EDITTEXT IDC_EDITMINES, 5, 75, 20, 12, ES_NUMBER + DEFPUSHBUTTON "Äîáðå", IDOK, 50, 30, 50, 15 + PUSHBUTTON "Îòêàç", IDCANCEL, 50, 50, 50, 15 +END diff --git a/reactos/base/applications/games/winmine/rsrc.rc b/reactos/base/applications/games/winmine/rsrc.rc index ecdaa8ed17e..e4e38e53e51 100644 --- a/reactos/base/applications/games/winmine/rsrc.rc +++ b/reactos/base/applications/games/winmine/rsrc.rc @@ -42,6 +42,7 @@ LEDS BITMAP rc/leds.bmp MINES BITMAP rc/mines.bmp /* include localised resources */ +#include "lang/bg-BG.rc" #include "lang/cs-CZ.rc" #include "lang/da-DK.rc" #include "lang/en-US.rc" diff --git a/reactos/base/applications/mscutils/eventvwr/lang/bg-BG.rc b/reactos/base/applications/mscutils/eventvwr/lang/bg-BG.rc index e861fac3785..64fcd4c3293 100644 --- a/reactos/base/applications/mscutils/eventvwr/lang/bg-BG.rc +++ b/reactos/base/applications/mscutils/eventvwr/lang/bg-BG.rc @@ -91,13 +91,13 @@ END STRINGTABLE BEGIN - IDS_COLUMNTYPE "Type" - IDS_COLUMNDATE "Date" - IDS_COLUMNTIME "Time" - IDS_COLUMNSOURCE "Source" - IDS_COLUMNCATEGORY "Category" - IDS_COLUMNEVENT "Event" - IDS_COLUMNUSER "User" - IDS_COLUMNCOMPUTER "Computer" - IDS_COLUMNEVENTDATA "Event Data" + IDS_COLUMNTYPE "Âèä" + IDS_COLUMNDATE "Äàòà" + IDS_COLUMNTIME "Âðåìå" + IDS_COLUMNSOURCE "Èçòî÷íèê" + IDS_COLUMNCATEGORY "Ðàçðÿä" + IDS_COLUMNEVENT "Ñúáèòèå" + IDS_COLUMNUSER "Ïîòðåáèòåë" + IDS_COLUMNCOMPUTER "Êîìïþòúð" + IDS_COLUMNEVENTDATA "Äàííè çà ñúáèòèåòî" END diff --git a/reactos/base/applications/mscutils/servman/lang/bg-BG.rc b/reactos/base/applications/mscutils/servman/lang/bg-BG.rc index 46bb5730775..f38c64fc5f3 100644 --- a/reactos/base/applications/mscutils/servman/lang/bg-BG.rc +++ b/reactos/base/applications/mscutils/servman/lang/bg-BG.rc @@ -4,7 +4,7 @@ IDR_MAINMENU MENU BEGIN POPUP "&Ôàéë" BEGIN - MENUITEM "Èçíîñ...", ID_EXPORT + MENUITEM "Èçíàñÿíå...", ID_EXPORT MENUITEM SEPARATOR MENUITEM "Èç&õîä", ID_EXIT END @@ -194,8 +194,8 @@ STRINGTABLE DISCARDABLE BEGIN /* IDS_NUM_SERVICES "Num Services: %d" */ IDS_NUM_SERVICES "Áðîé óñëóãè: %d" - IDS_STOP_DEPENDS "When %s stops, these other services will also stop" - IDS_NO_DEPENDS "" + IDS_STOP_DEPENDS "Ïðè ñïèðàíåòî íà %s, ùå ñïðàò è ñëåäíèòå óñëóãè" + IDS_NO_DEPENDS "<Áåç çàâèñèìîñòè>" IDS_LICENSE "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.\r\n\r\nThis 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.\r\n\r\nYou should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA." END @@ -226,7 +226,8 @@ END STRINGTABLE DISCARDABLE BEGIN - IDS_HELP_OPTIONS "CREATE OPTIONS:\r\nNOTE: The option name includes the equal sign.\r\n type= \r\n (default = own)\r\n start= \r\n (default = demand) \r\n error= \r\n (default = normal)\r\n group= \r\n tag= \r\n depend= \r\n obj= \r\n (default = LocalSystem)\r\n password= \r\n" + /*IDS_HELP_OPTIONS "CREATE OPTIONS:\r\nNOTE: The option name includes the equal sign.\r\n type= \r\n (default = own)\r\n start= \r\n (default = demand) \r\n error= \r\n (default = normal)\r\n group= \r\n tag= \r\n depend= \r\n obj= \r\n (default = LocalSystem)\r\n password= \r\n" */ + IDS_HELP_OPTIONS "ÑÚÇÄÀÂÀÍÅ ÍÀ ÂÚÇÌÎÆÍÎÑÒ:\r\nÁÅËÅÆÊÀ: Èìåòî íà âúçìîæíîñòòà âêëþ÷âà çíàêà çà ðàâåíñòâî.\r\n type= \r\n (ïîäðàçáèðàíî = own)\r\n start= \r\n (ïîäðàçáèðàíî = demand) \r\n error= \r\n (ïîäðàçáèðàíî = normal)\r\n group= \r\n tag= \r\n depend= \r\n obj= \r\n (ïîäðàçáèðàíî = LocalSystem)\r\n password= \r\n" END /* Hints */ @@ -239,7 +240,7 @@ BEGIN IDS_HINT_CONNECT " Óïðàâëåíèå íà ðàçëè÷åí êîìïþòúð." IDS_HINT_START " Ïóñêàíå íà èçáðàíàòà óñëóãà." IDS_HINT_STOP " Ñïèðàíå íà èçáðàíàòà óñëóãà." - IDS_HINT_PAUSE " Çàäúðæàíå (pause) íà èçáðàíàòà óñëóãà." + IDS_HINT_PAUSE " Çàäúðæàíå íà èçáðàíàòà óñëóãà." IDS_HINT_RESUME " Ïðîäúëæàâàíå íà èíáðàíàòà óñëóãà." IDS_HINT_RESTART " Ñïèðàíå è ïóñêàíå íà èçáðàíàòà óñëóãà" IDS_HINT_REFRESH " Îïðåñíÿâàíå íà ñïèñúêà ñ óñëóãèòå." @@ -255,7 +256,7 @@ BEGIN IDS_HINT_CUST " Íàãàæäàíå íà èçãëåäà." IDS_HINT_HELP " Ïîêàçâà ïîìîùåí ïðîçîðåö." - IDS_HINT_ABOUT " Çà óïðàâèòåëÿ íà óñòðéñòâàòà íà ÐåàêòÎÑ." + IDS_HINT_ABOUT " Çà óïðàâèòåëÿ íà óñòðîéñòâàòà íà ÐåàêòÎÑ." IDS_HINT_SYS_RESTORE " Âúçñòàíîâÿâà ïðîçîðåöà äî îáè÷àéíèÿ ìó ðàìåð." IDS_HINT_SYS_MOVE " Ïðåìåñòâà ïðîçîðåöà." diff --git a/reactos/base/applications/rapps/lang/cs-CZ.rc b/reactos/base/applications/rapps/lang/cs-CZ.rc new file mode 100644 index 00000000000..d82216538d4 --- /dev/null +++ b/reactos/base/applications/rapps/lang/cs-CZ.rc @@ -0,0 +1,198 @@ +/* FILE: applications/rapps/lang/cs-CZ.rc + * TRANSLATOR: Radek Liska aka Black_Fox (radekliska at gmail dot com) + * UPDATED: 2010-12-12 + */ + +LANGUAGE LANG_CZECH, SUBLANG_DEFAULT + +IDR_MAINMENU MENU +BEGIN + POPUP "&Soubor" + BEGIN + MENUITEM "&Nastavení", ID_SETTINGS + MENUITEM SEPARATOR + MENUITEM "&Konec", ID_EXIT + END + POPUP "&Programy" + BEGIN + MENUITEM "&Instalovat", ID_INSTALL + MENUITEM "&Odinstalovat",ID_UNINSTALL + MENUITEM "&Zmìnit", ID_MODIFY + MENUITEM SEPARATOR + MENUITEM "Odstranit z ®istru", ID_REGREMOVE + MENUITEM SEPARATOR + MENUITEM "&Obnovit", ID_REFRESH + END + POPUP "Nápovìda" + BEGIN + MENUITEM "Nápovìda", ID_HELP, GRAYED + MENUITEM "O programu...", ID_ABOUT + END +END + +IDR_LINKMENU MENU +BEGIN + POPUP "popup" + BEGIN + MENUITEM "&Otevøít odkaz v prohlížeèi", ID_OPEN_LINK + MENUITEM "&Kopírovat odkaz do schránky", ID_COPY_LINK + END +END + +IDR_APPLICATIONMENU MENU +BEGIN + POPUP "popup" + BEGIN + MENUITEM "&Instalovat", ID_INSTALL + MENUITEM "&Odinstalovat", ID_UNINSTALL + MENUITEM "&Zmìnit", ID_MODIFY + MENUITEM SEPARATOR + MENUITEM "Odebrat z ®istru", ID_REGREMOVE + MENUITEM SEPARATOR + MENUITEM "&Obnovit", ID_REFRESH + END +END + +IDD_SETTINGS_DIALOG DIALOGEX DISCARDABLE 0, 0, 250, 144 +STYLE DS_SHELLFONT | DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU +CAPTION "Nastavení" +FONT 8, "MS Shell Dlg" +BEGIN + GROUPBOX "Obecné", -1, 4, 2, 240, 61 + AUTOCHECKBOX "&Uložit pozici okna", IDC_SAVE_WINDOW_POS, 15, 12, 219, 12 + AUTOCHECKBOX "&Aktualizovat seznam dostupných programù pøi startu programu", IDC_UPDATE_AVLIST, 15, 29, 219, 12 + AUTOCHECKBOX "Ukládat &záznam instalací a odstranìní programù", IDC_LOG_ENABLED, 15, 46, 219, 12 + + GROUPBOX "Stahování", -1, 4, 65, 240, 51 + LTEXT "Složka se staženými soubory:", -1, 16, 75, 100, 9 + EDITTEXT IDC_DOWNLOAD_DIR_EDIT, 15, 86, 166, 12, WS_CHILD | WS_VISIBLE | WS_GROUP + PUSHBUTTON "&Procházet...", IDC_CHOOSE, 187, 85, 50, 14 + AUTOCHECKBOX "&Smazat instalátor programu po dokonèení instalace", IDC_DEL_AFTER_INSTALL, 16, 100, 218, 12 + + PUSHBUTTON "Výchozí", IDC_DEFAULT_SETTINGS, 8, 124, 60, 14 + PUSHBUTTON "OK", IDOK, 116, 124, 60, 14 + PUSHBUTTON "Storno", IDCANCEL, 181, 124, 60, 14 +END + +IDD_INSTALL_DIALOG DIALOGEX DISCARDABLE 0, 0, 216, 97 +STYLE DS_SHELLFONT | DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU +CAPTION "Instalace programu" +FONT 8, "MS Shell Dlg" +BEGIN + LTEXT "...", IDC_INSTALL_TEXT, 4, 5, 209, 35 + + AUTORADIOBUTTON "&Instalovat z média (CD nebo DVD)", IDC_CD_INSTALL, 10, 46, 197, 11, WS_GROUP + AUTORADIOBUTTON "&Stáhnout a instalovat", IDC_DOWNLOAD_INSTALL, 10, 59, 197, 11, NOT WS_TABSTOP + + PUSHBUTTON "OK", IDOK, 86, 78, 60, 14 + PUSHBUTTON "Storno", IDCANCEL, 150, 78, 60, 14 +END + +IDD_DOWNLOAD_DIALOG DIALOGEX LOADONCALL MOVEABLE DISCARDABLE 0, 0, 220, 76 +STYLE DS_SHELLFONT | DS_CENTER | WS_BORDER | WS_CAPTION | WS_POPUP | WS_SYSMENU | WS_VISIBLE +CAPTION "Stahování..." +FONT 8, "MS Shell Dlg" +BEGIN + CONTROL "Progress1", IDC_DOWNLOAD_PROGRESS, "msctls_progress32", WS_BORDER | PBS_SMOOTH, 10, 10, 200, 12 + LTEXT "", IDC_DOWNLOAD_STATUS, 10, 30, 200, 10, SS_CENTER + PUSHBUTTON "Storno", IDCANCEL, 85, 58, 50, 15, WS_GROUP | WS_TABSTOP +END + +IDD_ABOUT_DIALOG DIALOGEX 22, 16, 190, 66 +STYLE DS_SHELLFONT | WS_BORDER | WS_DLGFRAME | WS_SYSMENU | DS_MODALFRAME +CAPTION "O programu" +FONT 8, "MS Shell Dlg" +BEGIN + LTEXT "ReactOS Manažer aplikací\nCopyright (C) 2009\nby Dmitry Chapyshev (dmitry@reactos.org)", IDC_STATIC, 48, 7, 130, 39 + PUSHBUTTON "Zavøít", IDOK, 133, 46, 50, 14 + ICON IDI_MAIN, IDC_STATIC, 10, 10, 7, 30 +END + +STRINGTABLE DISCARDABLE +BEGIN + IDS_TOOLTIP_INSTALL "Instalovat" + IDS_TOOLTIP_UNINSTALL "Odinstalovat" + IDS_TOOLTIP_MODIFY "Zmìnit" + IDS_TOOLTIP_SETTINGS "Nastavení" + IDS_TOOLTIP_REFRESH "Obnovit" + IDS_TOOLTIP_EXIT "Konec" +END + +STRINGTABLE DISCARDABLE +BEGIN + IDS_APP_NAME "Název" + IDS_APP_INST_VERSION "Verze" + IDS_APP_DESCRIPTION "Popis" +END + +STRINGTABLE DISCARDABLE +BEGIN + IDS_INFO_VERSION "\nVerze: " + IDS_INFO_DESCRIPTION "\nPopis: " + IDS_INFO_PUBLISHER "\nVydavatel: " + IDS_INFO_HELPLINK "\nInternetová pomoc: " + IDS_INFO_HELPPHONE "\nTelefonní pomoc: " + IDS_INFO_README "\nReadme: " + IDS_INFO_REGOWNER "\nRegistrovaný vlastník: " + IDS_INFO_PRODUCTID "\nID produktu: " + IDS_INFO_CONTACT "\nKontakt: " + IDS_INFO_UPDATEINFO "\nInformace o aktualizacích: " + IDS_INFO_INFOABOUT "\nInformace o: " + IDS_INFO_COMMENTS "\nKomentáøe: " + IDS_INFO_INSTLOCATION "\nUmístìní instalace: " + IDS_INFO_INSTALLSRC "\nZdroj instalace: " + IDS_INFO_UNINSTALLSTR "\nOdinstalaèní øetìzec: " + IDS_INFO_MODIFYPATH "\nCesta úpravy: " + IDS_INFO_INSTALLDATE "\nDatum instalace: " +END + +STRINGTABLE DISCARDABLE +BEGIN + IDS_AINFO_VERSION "\nVerze: " + IDS_AINFO_DESCRIPTION "\nPopis: " + IDS_AINFO_SIZE "\nVelikost: " + IDS_AINFO_URLSITE "\nDomovská stránka: " + IDS_AINFO_LICENCE "\nLicence: " +END + +STRINGTABLE DISCARDABLE +BEGIN + IDS_CAT_AUDIO "Audio" + IDS_CAT_DEVEL "Vývoj" + IDS_CAT_DRIVERS "Ovladaèe" + IDS_CAT_EDU "Škola hrou" + IDS_CAT_ENGINEER "Strojírenství" + IDS_CAT_FINANCE "Finance" + IDS_CAT_GAMES "Hry a zábava" + IDS_CAT_GRAPHICS "Grafika" + IDS_CAT_INTERNET "Internet a sítì" + IDS_CAT_LIBS "Knihovny" + IDS_CAT_OFFICE "Kanceláø" + IDS_CAT_OTHER "Jiné" + IDS_CAT_SCIENCE "Vìda" + IDS_CAT_TOOLS "Nástroje" + IDS_CAT_VIDEO "Video" +END + +STRINGTABLE DISCARDABLE +BEGIN + IDS_APPTITLE "ReactOS Manažer aplikací" + IDS_SEARCH_TEXT "Hledat..." + IDS_INSTALL "Instalovat" + IDS_UNINSTALL "Odinstalovat" + IDS_MODIFY "Zmìnit" + IDS_APPS_COUNT "Poèet aplikací: %d" + IDS_WELCOME_TITLE "Vítejte v ReactOS Manažeru aplikací!\n\n" + IDS_WELCOME_TEXT "Na levé stranì zvolte kategorii, pak vpravo zvolte aplikaci, která bude nainstalována nebo odinstalována.\nWebová stránka ReactOS: " + IDS_WELCOME_URL "http://www.reactos.org" + IDS_INSTALLED "Nainstalováno" + IDS_AVAILABLEFORINST "Dostupné k instalaci" + IDS_UPDATES "Aktualizace" + IDS_APPLICATIONS "Aplikace" + IDS_CHOOSE_FOLDER_TEXT "Zvolte složku, do které se budou ukládat stažené soubory:" + IDS_CHOOSE_FOLDER_ERROR "Zvolená složka neexistuje. Vytvoøit?" + IDS_USER_NOT_ADMIN "Ke spuštìní ""ReactOS Manažera aplikací"" je tøeba být administrátor!" + IDS_APP_REG_REMOVE "Urèitì odstranit data instalovaného programu z registru?" + IDS_INFORMATION "Informace" + IDS_UNABLE_TO_REMOVE "Nepodaøilo se odstranit data programu z registru!" +END diff --git a/reactos/base/applications/rapps/rapps/ac97forvirtualbox.txt b/reactos/base/applications/rapps/rapps/ac97forvirtualbox.txt index 3f76d084dd9..8454b861282 100644 --- a/reactos/base/applications/rapps/rapps/ac97forvirtualbox.txt +++ b/reactos/base/applications/rapps/rapps/ac97forvirtualbox.txt @@ -11,6 +11,12 @@ URLSite = Unknown URLDownload = http://svn.reactos.org/packages/ac97_vbox.exe CDPath = none +[Section.0405] +Name = OvladaÄ AC97 pro VirtualBox +Licence = Neznámá +Description = Rozbalte do složky "ReactOS" a pak ReactOS dvakrát restartujte. +URLSite = Neznámá + [Section.0407] Name = AC97 Treiber für VirtualBox Licence = Unbekannt diff --git a/reactos/base/applications/rapps/rapps/firefox2.txt b/reactos/base/applications/rapps/rapps/firefox2.txt index cc22a762b8c..ddb07405697 100644 --- a/reactos/base/applications/rapps/rapps/firefox2.txt +++ b/reactos/base/applications/rapps/rapps/firefox2.txt @@ -11,6 +11,12 @@ URLSite = http://www.mozilla.com/en-US/ URLDownload = http://svn.reactos.org/packages/Firefox%20Setup%202.0.0.20.exe CDPath = none +[Section.0405] +Description = NejpopulárnÄ›jší a jeden z nejlepších svobodných webových prohlížeÄů. +Size = 5.5M +URLSite = http://www.mozilla-europe.org/cs/ +URLDownload = http://194.71.11.70/pub/www/clients/mozilla.org/firefox/releases/2.0.0.20/win32/cs/Firefox%20Setup%202.0.0.20.exe + [Section.0407] Description = Der populärste und einer der besten freien Webbrowser. diff --git a/reactos/base/applications/rapps/rapps/firefox3.txt b/reactos/base/applications/rapps/rapps/firefox3.txt index f9978c34ba4..9db19037cf9 100644 --- a/reactos/base/applications/rapps/rapps/firefox3.txt +++ b/reactos/base/applications/rapps/rapps/firefox3.txt @@ -11,6 +11,12 @@ URLSite = http://www.mozilla.com/en-US/ URLDownload = http://releases.mozilla.org/pub/mozilla.org/firefox/releases/3.0.19-real-real/win32/en-US/Firefox%20Setup%203.0.19.exe CDPath = none +[Section.0405] +Description = NejpopulárnÄ›jší a jeden z nejlepších svobodných webových prohlížeÄů. +Size = 7.0M +URLSite = http://www.mozilla-europe.org/cs/ +URLDownload = http://releases.mozilla.org/pub/mozilla.org/firefox/releases/3.0.19-real-real/win32/cs/Firefox%20Setup%203.0.19.exe + [Section.0407] Description = Der populärste und einer der besten freien Webbrowser. Size = 7.0M diff --git a/reactos/base/applications/rapps/rapps/offbyone.txt b/reactos/base/applications/rapps/rapps/offbyone.txt index 16ce1967277..733e710fa9b 100644 --- a/reactos/base/applications/rapps/rapps/offbyone.txt +++ b/reactos/base/applications/rapps/rapps/offbyone.txt @@ -11,6 +11,9 @@ URLSite = http://offbyone.com/ URLDownload = http://offbyone.com/offbyone/images/OffByOneSetup.exe CDPath = none +[Section.0405] +Description = Off-By-One-Browser je velmi malý a rychlý webový prohlížeÄ s plnou podporou HTML 3.2. + [Section.0407] Description = Der Off-By-One-Browser ist ein sehr kleiner und schneller Webbrowser mit voller HTML 3.2 Unterstützung. diff --git a/reactos/base/applications/rapps/rapps/opera.txt b/reactos/base/applications/rapps/rapps/opera.txt index f16c517559b..b6493f55ed4 100644 --- a/reactos/base/applications/rapps/rapps/opera.txt +++ b/reactos/base/applications/rapps/rapps/opera.txt @@ -11,6 +11,9 @@ URLSite = http://www.opera.com/ URLDownload = http://get4.opera.com/pub/opera/win/1063/int/Opera_1063_int_Setup.exe CDPath = none +[Section.0405] +Description = Populární prohlížeÄ Opera s mnoha pokroÄilými vlastnostmi, vÄetnÄ› vestavené podpory pro e-mail a BitTorrent. + [Section.0407] Description = Der populäre Opera Browser mit vielen fortschrittlichen Eigenschaften, enthält einen Mail und BitTorrent Client. diff --git a/reactos/base/applications/rapps/rapps/rosbe.txt b/reactos/base/applications/rapps/rapps/rosbe.txt index f729ed350db..c8a6990a752 100644 --- a/reactos/base/applications/rapps/rapps/rosbe.txt +++ b/reactos/base/applications/rapps/rapps/rosbe.txt @@ -11,6 +11,9 @@ URLSite = http://reactos.org/wiki/Build_Environment URLDownload = http://ovh.dl.sourceforge.net/project/reactos/RosBE-Windows/i386/1.5.1/RosBE-1.5.1.1.exe CDPath = none +[Section.0405] +Description = Dovoluje zkompilovat zdrojový kód systému ReactOS. Pro další detaily viz. ReactOS wiki. + [Section.0407] Description = Erlaubt es Ihnen den ReactOS Source Code zu kompilieren. Im ReactOS-Wiki finden Sie dazu nähere Anweisungen. diff --git a/reactos/base/applications/rapps/rapps/rosbeamd64.txt b/reactos/base/applications/rapps/rapps/rosbeamd64.txt index 88b8d6b9707..989cd3bcd19 100644 --- a/reactos/base/applications/rapps/rapps/rosbeamd64.txt +++ b/reactos/base/applications/rapps/rapps/rosbeamd64.txt @@ -11,6 +11,9 @@ URLSite = http://reactos.org/wiki/Build_Environment/ URLDownload = http://dreimer.bplaced.net/rosbe/RosBE64-1.4b.exe CDPath = none +[Section.0405] +Description = Dovoluje zkompilovat zdrojový kód systému ReactOS AMD64. Pro další detaily viz. ReactOS wiki. + [Section.0407] Description = Erlaubt es Ihnen den ReactOS AMD64 Source Code zu kompilieren. Im ReactOS-Wiki finden Sie dazu nähere Anweisungen. diff --git a/reactos/base/applications/rapps/rapps/sdl_mixer.txt b/reactos/base/applications/rapps/rapps/sdl_mixer.txt index e667274e497..5f74ea6be10 100644 --- a/reactos/base/applications/rapps/rapps/sdl_mixer.txt +++ b/reactos/base/applications/rapps/rapps/sdl_mixer.txt @@ -11,6 +11,9 @@ URLSite = http://www.libsdl.org/projects/SDL_mixer/ URLDownload = http://www.libsdl.org/projects/SDL_mixer/release/SDL_mixer-1.2.11-win32.zip CDPath = none +[Section.0405] +Description = Nutný pro spuÅ¡tÄ›ní nÄ›kterých open source her. K rozbalení je nutný 7-zip nebo podobný nástroj. + [Section.0407] Description = Erforderlich um einige Open Source Spiele auszuführen. Sie brauchen 7-Zip oder einen ähnlichen Entpacker um es zu entpacken. diff --git a/reactos/base/applications/rapps/rapps/tuxpaint.txt b/reactos/base/applications/rapps/rapps/tuxpaint.txt index a36cfda4a97..f32859f8491 100644 --- a/reactos/base/applications/rapps/rapps/tuxpaint.txt +++ b/reactos/base/applications/rapps/rapps/tuxpaint.txt @@ -11,6 +11,9 @@ URLSite = http://tuxpaint.org/ URLDownload = http://ovh.dl.sourceforge.net/project/tuxpaint/tuxpaint/0.9.21/tuxpaint-0.9.21-win32-installer.exe CDPath = none +[Section.0405] +Description = Open source bitmapový editor urÄený dÄ›tem. + [Section.0407] Description = Ein Open Source Bitmap Zeichenprogramm für kleine Kinder. diff --git a/reactos/base/applications/rapps/rsrc.rc b/reactos/base/applications/rapps/rsrc.rc index c09097f28cd..17c16983f73 100644 --- a/reactos/base/applications/rapps/rsrc.rc +++ b/reactos/base/applications/rapps/rsrc.rc @@ -1,4 +1,5 @@ #include "lang/bg-BG.rc" +#include "lang/cs-CZ.rc" #include "lang/de-DE.rc" #include "lang/en-US.rc" #include "lang/es-ES.rc" diff --git a/reactos/base/applications/regedit/lang/bg-BG.rc b/reactos/base/applications/regedit/lang/bg-BG.rc index da8521bc924..8603663ce1e 100644 --- a/reactos/base/applications/regedit/lang/bg-BG.rc +++ b/reactos/base/applications/regedit/lang/bg-BG.rc @@ -1,3 +1,4 @@ +//Íåäîâúðøåí /* * Regedit resources * @@ -135,8 +136,8 @@ BEGIN MENUITEM "&Íèçîâà ñòîéíîñò", ID_EDIT_NEW_STRINGVALUE MENUITEM "&Äâîè÷íà ñòîéíîñò", ID_EDIT_NEW_BINARYVALUE MENUITEM "&Ñòîéíîñò íà äâîéíà äóìà", ID_EDIT_NEW_DWORDVALUE - MENUITEM "&Multi-String Value", ID_EDIT_NEW_MULTISTRINGVALUE - MENUITEM "&Expandable String Value", ID_EDIT_NEW_EXPANDABLESTRINGVALUE + MENUITEM "&Ìíîãîíèçîâà ñòîéíîñò", ID_EDIT_NEW_MULTISTRINGVALUE + MENUITEM "&Ðàçøèðèìà ìíîãîíèçîâà ñòîéíîñò", ID_EDIT_NEW_EXPANDABLESTRINGVALUE END END POPUP "" @@ -149,8 +150,8 @@ BEGIN MENUITEM "&Íèçîâà ñòîéíîñò", ID_EDIT_NEW_STRINGVALUE MENUITEM "&Äâîè÷íà ñòîéíîñò", ID_EDIT_NEW_BINARYVALUE MENUITEM "&Ñòîéíîñò íà äâîéíà äóìà", ID_EDIT_NEW_DWORDVALUE - MENUITEM "&Multi-String Value", ID_EDIT_NEW_MULTISTRINGVALUE - MENUITEM "&Expandable String Value", ID_EDIT_NEW_EXPANDABLESTRINGVALUE + MENUITEM "&Ìíîãîíèçîâà ñòîéíîñò", ID_EDIT_NEW_MULTISTRINGVALUE + MENUITEM "&Ðàçøèðèìà ìíîãîíèçîâà ñòîéíîñò", ID_EDIT_NEW_EXPANDABLESTRINGVALUE END MENUITEM "&Òúðñåíå", ID_EDIT_FIND MENUITEM SEPARATOR @@ -165,11 +166,11 @@ BEGIN POPUP "" BEGIN MENUITEM "C&ut", ID_HEXEDIT_CUT - MENUITEM "&Copy", ID_HEXEDIT_COPY - MENUITEM "&Paste", ID_HEXEDIT_PASTE - MENUITEM "&Delete", ID_HEXEDIT_DELETE + MENUITEM "Çà&ïîìíÿíå", ID_HEXEDIT_COPY + MENUITEM "&Ïîñòàâÿíå", ID_HEXEDIT_PASTE + MENUITEM "Èç&òðèâàíå", ID_HEXEDIT_DELETE MENUITEM SEPARATOR - MENUITEM "Select &All", ID_HEXEDIT_SELECT_ALL + MENUITEM "Èçáîð íà âñè&÷êè", ID_HEXEDIT_SELECT_ALL END END @@ -182,10 +183,10 @@ STYLE DS_SHELLFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU CAPTION "Load Hive" FONT 8, "Ms Shell Dlg" { - LTEXT "&Key:", IDC_STATIC, 4, 4, 15, 8, SS_LEFT + LTEXT "&Êëàâèø:", IDC_STATIC, 4, 4, 15, 8, SS_LEFT EDITTEXT IDC_EDIT_KEY, 23, 2, 167, 13 - DEFPUSHBUTTON "OK", IDOK, 140, 17, 50, 14 - PUSHBUTTON "Cancel", IDCANCEL, 89, 17, 50, 14 + DEFPUSHBUTTON "Äîáðå", IDOK, 140, 17, 50, 14 + PUSHBUTTON "Îòêàç", IDCANCEL, 89, 17, 50, 14 } IDD_EDIT_STRING DIALOGEX 32, 24, 252, 84 diff --git a/reactos/base/applications/taskmgr/lang/bg-BG.rc b/reactos/base/applications/taskmgr/lang/bg-BG.rc index aec05a5ab43..86fa40655d3 100644 --- a/reactos/base/applications/taskmgr/lang/bg-BG.rc +++ b/reactos/base/applications/taskmgr/lang/bg-BG.rc @@ -392,13 +392,13 @@ BEGIN WS_TABSTOP,125,94,115,10 CONTROL "GDI Objects",IDC_GDIOBJECTS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,125,105,115,10 - CONTROL "I/O Writes",IDC_IOWRITES,"Button",BS_AUTOCHECKBOX | + CONTROL "Â/È ïèñàíåòà",IDC_IOWRITES,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,125,116,115,10 - CONTROL "I/O Write Bytes",IDC_IOWRITEBYTES,"Button", + CONTROL "Â/È áàéòîâå çà ïèñàíå",IDC_IOWRITEBYTES,"Button", BS_AUTOCHECKBOX | WS_TABSTOP,125,127,65,10 - CONTROL "I/O Other",IDC_IOOTHER,"Button",BS_AUTOCHECKBOX | + CONTROL "Äðóãè Â/È",IDC_IOOTHER,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,125,138,115,10 - CONTROL "I/O Other Bytes",IDC_IOOTHERBYTES,"Button", + CONTROL "Äðóãè Â/È áàéòîâå",IDC_IOOTHERBYTES,"Button", BS_AUTOCHECKBOX | WS_TABSTOP,125,149,115,10 END diff --git a/reactos/base/setup/usetup/lang/bg-BG.h b/reactos/base/setup/usetup/lang/bg-BG.h index 9e8de240a6a..0bb6cad0638 100644 --- a/reactos/base/setup/usetup/lang/bg-BG.h +++ b/reactos/base/setup/usetup/lang/bg-BG.h @@ -1496,7 +1496,7 @@ MUI_ERROR bgBGErrorEntries[] = }, { //ERROR_INSUFFICIENT_DISKSPACE, - "Not enough free space in the selected partition.\n" + "  ¨§¡à ­¨ï ¤ï« ­ï¬  ¤®áâ âêç­® ᢮¡®¤­® ¯à®áâà ­á⢮.\n" " *  â¨á­¥â¥ ª« ¢¨è, §  ¤  ¯à®¤ê«¦¨â¥.", NULL }, @@ -1640,7 +1640,7 @@ MUI_STRING bgBGStrings[] = {STRING_COPYING, " ‡ ¯¨á ­  ä ©«: %S"}, {STRING_SETUPCOPYINGFILES, - "’¥ç¥ § ¯¨á¢ ­¥ ­  ä ©«®¢¥â¥..."}, + "” ©«®¢¥â¥ ᥠ§ ¯¨á¢ â..."}, {STRING_REGHIVEUPDATE, " Žáê¢à¥¬¥­ï¢ ­¥ ­  ॣ¨áâê୨⥠஥¢¥..."}, {STRING_IMPORTFILE, diff --git a/reactos/base/setup/usetup/lang/cs-CZ.h b/reactos/base/setup/usetup/lang/cs-CZ.h index 523cca70c2d..eff2fa1665e 100644 --- a/reactos/base/setup/usetup/lang/cs-CZ.h +++ b/reactos/base/setup/usetup/lang/cs-CZ.h @@ -1,7 +1,7 @@ /* FILE: setup/usetup/lang/cs-CZ.rc * TRANSLATOR: Radek Liska aka Black_Fox (radekliska at gmail dot com) * THANKS TO: preston - * UPDATED: 2010-05-25 + * UPDATED: 2010-12-12 */ #pragma once @@ -993,13 +993,13 @@ static MUI_ENTRY csCZBootLoaderEntries[] = { 8, 12, - "Install bootloader on the harddisk (MBR and VBR).", + "Nainstalovat zavadØŸ na pevnì disk (MBR a VBR).", TEXT_STYLE_NORMAL }, { 8, 13, - "Install bootloader on the harddisk (VBR only).", + "Nainstalovat zavadØŸ na pevnì disk (pouze VBR).", TEXT_STYLE_NORMAL }, { diff --git a/reactos/base/shell/explorer-new/lang/bg-BG.rc b/reactos/base/shell/explorer-new/lang/bg-BG.rc index f4c08db2f04..33cbf41db4d 100644 --- a/reactos/base/shell/explorer-new/lang/bg-BG.rc +++ b/reactos/base/shell/explorer-new/lang/bg-BG.rc @@ -1,3 +1,4 @@ + LANGUAGE LANG_BULGARIAN, SUBLANG_DEFAULT IDM_TRAYWND MENU DISCARDABLE @@ -36,7 +37,7 @@ BEGIN MENUITEM "&Ñèãóðíîñò...", IDM_SECURITY, MFT_STRING, MFS_ENABLED MENUITEM "&Ìðåæîâè âðúçêè", IDM_NETWORKCONNECTIONS, MFT_STRING, MFS_ENABLED MENUITEM "&Ïå÷àòà÷è è ôàêñîâå", IDM_PRINTERSANDFAXES, MFT_STRING, MFS_ENABLED - MENUITEM "&Taskbar and Start Menu", IDM_TASKBARANDSTARTMENU, MFT_STRING, MFS_ENABLED + MENUITEM "&Çàäà÷íà ëåíòà è èçáîðíèê „Ïóñê“", IDM_TASKBARANDSTARTMENU, MFT_STRING, MFS_ENABLED END POPUP "&Òúðñåíå", IDM_SEARCH BEGIN @@ -49,6 +50,7 @@ BEGIN MENUITEM "&Èçõîä %s...", IDM_LOGOFF, MFT_STRING, MFS_ENABLED MENUITEM "&Îòêà÷âàíå...", IDM_DISCONNECT, MFT_STRING, MFS_ENABLED /* undock computer*/ +/* íåÿñíî */ MENUITEM "Îò&ãíåçäâàíå íà êîìïþòúðà", IDM_UNDOCKCOMPUTER, MFT_STRING, MFS_ENABLED MENUITEM "&Èçêëþ÷âàíå...", IDM_SHUTDOWN, MFT_STRING, MFS_ENABLED END @@ -121,7 +123,7 @@ BEGIN IDS_PROPERTIES "&Ñâîéñòâà" IDS_OPEN_ALL_USERS "&Îòâàðÿíå íà âñè÷êè ïîòðåáèòåëè" IDS_EXPLORE_ALL_USERS "&Ðàçëèñòâàíå íà âñè÷êè ïîòðåáèòåëè" - IDS_STARTUP_ERROR "The system cannot start explorer because the registry is corrupted or unavailable." + IDS_STARTUP_ERROR "Óðåäáàòà íå ìîæå äà ïóñíå èçñëåäîâàòåëÿ, ïîíåæå ïîíåæå ðåãèñòúðúò å óâðåäåí èëè íåäîñòúïåí." END STRINGTABLE DISCARDABLE diff --git a/reactos/base/shell/explorer-new/lang/cs-CZ.rc b/reactos/base/shell/explorer-new/lang/cs-CZ.rc index 5273c548ff1..a6bdc222ea6 100644 --- a/reactos/base/shell/explorer-new/lang/cs-CZ.rc +++ b/reactos/base/shell/explorer-new/lang/cs-CZ.rc @@ -1,7 +1,7 @@ /* * FILE: base/shell/explorer-new/lang/cs-CZ.rc * TRANSLATOR: Radek Liska aka Black_Fox (radekliska at gmail dot com) - * UPDATED: 2009-07-15 + * UPDATED: 2010-05-31 */ LANGUAGE LANG_CZECH, SUBLANG_DEFAULT @@ -126,7 +126,7 @@ BEGIN IDS_PROPERTIES "Vl&astnosti" IDS_OPEN_ALL_USERS "Ote&vøít složku All Users" IDS_EXPLORE_ALL_USERS "Pro&cházet složku All Users" - IDS_STARTUP_ERROR "The system cannot start explorer because the registry is corrupted or unavailable." + IDS_STARTUP_ERROR "Systém nemohl spustit proces Explorer, protože registry jsou poškozené nebo nedostupné." END STRINGTABLE DISCARDABLE diff --git a/reactos/dll/cpl/console/lang/bg-BG.rc b/reactos/dll/cpl/console/lang/bg-BG.rc new file mode 100644 index 00000000000..0ed6ad37273 --- /dev/null +++ b/reactos/dll/cpl/console/lang/bg-BG.rc @@ -0,0 +1,149 @@ +/* $Id: en-US.rc 49139 2010-10-13 21:23:48Z dreimer $ + * + * PROJECT: ReactOS Console Configuration DLL + * LICENSE: GPL - See COPYING in the top level directory + * FILE: dll/cpl/console/lang/en-US.rc + * PURPOSE: English resource file + * PROGRAMMERS: Johannes Anderwald (johannes.anderwald@student.tugraz.at) + */ + +#include + +LANGUAGE LANG_BULGARIAN, SUBLANG_DEFAULT + +IDD_PROPPAGEOPTIONS DIALOGEX 0, 0, 283, 220 +STYLE DS_SHELLFONT | WS_CHILD | WS_CAPTION +CAPTION "Íàñòðîéêè" +FONT 8, "MS Shell Dlg" +BEGIN + GROUPBOX "Ðàçìåð íà ïîêàçàëåöà", -1, 7, 7, 130, 70, WS_CHILD | WS_VISIBLE | WS_GROUP + CONTROL "&Ìàëúê", IDC_RADIO_SMALL_CURSOR, "Button", BS_AUTORADIOBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 15, 20, 90, 10 + CONTROL "&Ñðåäåí", IDC_RADIO_MEDIUM_CURSOR, "Button", BS_AUTORADIOBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 15, 40, 90, 10 + CONTROL "&Ãîëÿì", IDC_RADIO_LARGE_CURSOR, "Button", BS_AUTORADIOBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 15, 60, 90, 10 + GROUPBOX "Íàñòðîéêè íà åêðàíà", -1, 143, 7, 130, 70, WS_CHILD | WS_VISIBLE | WS_GROUP + CONTROL "&Ïðîçîðåö", IDC_RADIO_DISPLAY_WINDOW, "Button", BS_AUTORADIOBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 152, 20, 70, 10 + CONTROL "&Öÿë åêðàí", IDC_RADIO_DISPLAY_FULL, "Button", BS_AUTORADIOBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 152, 40, 70, 10 + GROUPBOX "Äíåâíèê íà çàïîâåäèòå", -1, 7, 84, 130, 77, WS_CHILD | WS_VISIBLE | WS_GROUP + LTEXT "Ðàçìåð íà &áóôåðà", -1, 14, 101, 70, 12 + EDITTEXT IDC_EDIT_BUFFER_SIZE, 90, 97, 30, 15, ES_RIGHT | WS_GROUP + CONTROL "", IDC_UPDOWN_BUFFER_SIZE, UPDOWN_CLASS, UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | WS_BORDER | WS_GROUP, 119, 97, 12, 15 + LTEXT "&Áðîé áóôåðè", -1, 14, 124, 70, 12 + EDITTEXT IDC_EDIT_NUM_BUFFER, 90, 120, 30, 15, ES_RIGHT | WS_GROUP + CONTROL "", IDC_UPDOWN_NUM_BUFFER, UPDOWN_CLASS, UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | WS_BORDER | WS_GROUP, 119, 120, 12, 15 + CHECKBOX "Ïðå&ìàõâàíå íà ñòàðèòå áðîéêè", IDC_CHECK_DISCARD_DUPLICATES, 12, 140, 120, 15 + GROUPBOX "Ïðîìÿíà íà íàñòðîéêèòå", -1, 143, 85, 130, 77, BS_GROUPBOX | WS_CHILD | WS_VISIBLE | WS_GROUP + CHECKBOX "Ðåæèì &áúðçà îáðàáîòêà", IDC_CHECK_QUICK_EDIT, 150, 97, 102, 15, WS_CHILD | WS_VISIBLE | WS_TABSTOP + CHECKBOX "Ðåæèì &âìúêâàíå", IDC_CHECK_INSERT_MODE, 150, 113, 76, 15, WS_CHILD | WS_VISIBLE | WS_TABSTOP +END + +IDD_PROPPAGEFONT DIALOGEX 0, 0, 253, 220 +STYLE DS_SHELLFONT | WS_CHILD | WS_CAPTION +CAPTION "Øðèôò" +FONT 8, "MS Shell Dlg" +BEGIN + LTEXT "Ïðîçîðå÷åí ïðåãëåä:", -1, 10, 10, 94, 10 + LTEXT "Ðàçìåð:", -1, 180, 10, 36, 10 + CONTROL "", IDC_STATIC_FONT_WINDOW_PREVIEW, "Static", SS_OWNERDRAW | SS_SUNKEN, 10, 20, 163, 74 + LISTBOX IDC_LBOX_FONTS, 181, 20, 55, 80, LBS_DISABLENOSCROLL | WS_VSCROLL + LTEXT "&Øðèôò:", -1, 10, 105, 33, 10 + CHECKBOX "&Ïîëó÷åðè øðèôòîâå", IDC_CHECK_BOLD_FONTS, 38, 105, 85, 10 + LISTBOX IDC_LBOX_TYPE, 10, 120, 110, 40, LBS_DISABLENOSCROLL | WS_VSCROLL + GROUPBOX "", IDC_GROUPBOX_FONT_NAME, 6, 156, 241, 50 + CONTROL "", IDC_STATIC_SELECT_FONT_PREVIEW, "Static", SS_OWNERDRAW | SS_SUNKEN, 16, 165, 95, 35 + LTEXT "Âñåêè çíàê å:", -1, 124, 166, 75, 10 + LTEXT "screen pixel wide\nscreen pixel high", -1, 136, 180, 101, 20 /* íåÿñíî */ + LTEXT "", IDC_FONT_SIZE_X, 120, 180, 10, 10 + LTEXT "", IDC_FONT_SIZE_Y, 120, 188, 10, 10 +END + +IDD_PROPPAGELAYOUT DIALOGEX 0, 0, 273, 230 +STYLE DS_SHELLFONT | WS_CHILD | WS_CAPTION +CAPTION "Ïîäðåäáà" +FONT 8, "MS Shell Dlg" +BEGIN + LTEXT "Ïðîçîðå÷åí ïðåãëåä", -1, 8, 6, 105, 10 + CONTROL "", IDC_STATIC_LAYOUT_WINDOW_PREVIEW, "Static", SS_SUNKEN | SS_OWNERDRAW, 8, 16, 115, 70 + GROUPBOX "Ðàçìåð íà åêðàííèÿ áóôåð", -1, 130, 12, 135, 50 + LTEXT "&Øèðèíà:", -1, 140, 28, 40, 10 + LTEXT "&Âèñî÷èíà:", -1, 140, 46, 39, 10 + EDITTEXT IDC_EDIT_SCREEN_BUFFER_WIDTH, 203, 25, 35, 14, ES_RIGHT | WS_GROUP + CONTROL "", IDC_UPDOWN_SCREEN_BUFFER_WIDTH, UPDOWN_CLASS, UDS_NOTHOUSANDS | UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | WS_BORDER | WS_GROUP, 238, 25, 13, 14 + EDITTEXT IDC_EDIT_SCREEN_BUFFER_HEIGHT, 203, 42, 35, 14, ES_RIGHT | WS_GROUP + CONTROL "", IDC_UPDOWN_SCREEN_BUFFER_HEIGHT, UPDOWN_CLASS, UDS_NOTHOUSANDS | UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | WS_BORDER | WS_GROUP, 238, 42, 13, 14 + GROUPBOX "Ðàçìåð íà ïðîçîðåöà", -1, 130, 65, 135, 47 + LTEXT "&Ø&èðèíà:", -1, 140, 78, 39, 10 + LTEXT "&Âè&ñî÷èíà:", -1, 140, 95, 37, 10 + EDITTEXT IDC_EDIT_WINDOW_SIZE_WIDTH, 203, 75, 35, 14, ES_RIGHT | WS_GROUP + CONTROL "", IDC_UPDOWN_WINDOW_SIZE_WIDTH, UPDOWN_CLASS, UDS_NOTHOUSANDS | UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | WS_BORDER | WS_GROUP, 238, 75, 13, 14 + EDITTEXT IDC_EDIT_WINDOW_SIZE_HEIGHT, 203, 92, 35, 14, ES_RIGHT | WS_GROUP + CONTROL "", IDC_UPDOWN_WINDOW_SIZE_HEIGHT, UPDOWN_CLASS, UDS_NOTHOUSANDS | UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | WS_BORDER | WS_GROUP, 238, 92, 13, 14 + GROUPBOX "Ïîëîæåíèå íà ïðîçîðåöà", -1, 130, 116, 135, 64 + LTEXT "Îò&ëÿâî:", -1, 140, 132, 38, 10 + LTEXT "Îò&ãîðå:", -1, 140, 149, 40, 10 + EDITTEXT IDC_EDIT_WINDOW_POS_LEFT, 203, 128, 35, 14, ES_RIGHT | WS_GROUP + CONTROL "", IDC_UPDOWN_WINDOW_POS_LEFT, UPDOWN_CLASS, UDS_NOTHOUSANDS | UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | WS_BORDER | WS_GROUP, 238, 128, 13, 14 + EDITTEXT IDC_EDIT_WINDOW_POS_TOP, 203, 146, 35, 14, ES_RIGHT | WS_GROUP + CONTROL "", IDC_UPDOWN_WINDOW_POS_TOP, UPDOWN_CLASS, UDS_NOTHOUSANDS | UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | WS_BORDER | WS_GROUP, 238, 146, 13, 14 + CHECKBOX "Óðåäáàòà íà&ìåñòâà ïðîçîðåöà", IDC_CHECK_SYSTEM_POS_WINDOW, 137, 165, 118, 10 +END + +IDD_PROPPAGECOLORS DIALOGEX 0, 0, 253, 220 +STYLE DS_SHELLFONT | WS_CHILD | WS_CAPTION +CAPTION "Öâåòîâå" +FONT 8, "MS Shell Dlg" +BEGIN + CONTROL "Åêðàíåí &òåêñò", IDC_RADIO_SCREEN_TEXT, "Button", BS_AUTORADIOBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 10, 12, 112, 10 + CONTROL "Åêðàííà ïîä&öâåòêà", IDC_RADIO_SCREEN_BACKGROUND, "Button", BS_AUTORADIOBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 10, 30, 112, 10 + CONTROL "Èç&ñêà÷àù òåêñò", IDC_RADIO_POPUP_TEXT, "Button", BS_AUTORADIOBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 10, 48, 112, 10 + CONTROL "Èçñêà÷àùà ïîä&öâåòêà", IDC_RADIO_POPUP_BACKGROUND, "Button", BS_AUTORADIOBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 10, 67, 112, 10 + GROUPBOX "Èçáðàíè öâåòîâè ñòîéíîñòè", -1, 129, 7, 118, 73 + LTEXT "&×åðâåíî:", -1, 140, 25, 48, 10 + EDITTEXT IDC_EDIT_COLOR_RED, 210, 22, 30, 14, ES_RIGHT | WS_GROUP + CONTROL "", IDC_UPDOWN_COLOR_RED, UPDOWN_CLASS, UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | WS_BORDER | WS_GROUP, 240, 22, 12, 14 + LTEXT "&Çåëåíî:", -1, 140, 42, 48, 10 + EDITTEXT IDC_EDIT_COLOR_GREEN, 210, 39, 30, 14, ES_RIGHT | WS_GROUP + CONTROL "", IDC_UPDOWN_COLOR_GREEN, UPDOWN_CLASS, UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | WS_BORDER | WS_GROUP, 240, 39, 12, 14 + LTEXT "&Ñèíüî:", -1, 140, 60, 48, 10 + EDITTEXT IDC_EDIT_COLOR_BLUE, 210, 56, 30, 14, ES_RIGHT | WS_GROUP + CONTROL "", IDC_UPDOWN_COLOR_BLUE, UPDOWN_CLASS, UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | WS_BORDER | WS_GROUP, 240, 56, 12, 14 + CONTROL "", IDC_STATIC_COLOR1, "Static", SS_NOTIFY | SS_SUNKEN | SS_OWNERDRAW, 17, 90, 12, 12 + CONTROL "", IDC_STATIC_COLOR2, "Static", SS_NOTIFY | SS_SUNKEN | SS_OWNERDRAW, 31, 90, 12, 12 + CONTROL "", IDC_STATIC_COLOR3, "Static", SS_NOTIFY | SS_SUNKEN | SS_OWNERDRAW, 45, 90, 12, 12 + CONTROL "", IDC_STATIC_COLOR4, "Static", SS_NOTIFY | SS_SUNKEN | SS_OWNERDRAW, 59, 90, 12, 12 + CONTROL "", IDC_STATIC_COLOR5, "Static", SS_NOTIFY | SS_SUNKEN | SS_OWNERDRAW, 73, 90, 12, 12 + CONTROL "", IDC_STATIC_COLOR6, "Static", SS_NOTIFY | SS_SUNKEN | SS_OWNERDRAW, 87, 90, 12, 12 + CONTROL "", IDC_STATIC_COLOR7, "Static", SS_NOTIFY | SS_SUNKEN | SS_OWNERDRAW, 101, 90, 12, 12 + CONTROL "", IDC_STATIC_COLOR8, "Static", SS_NOTIFY | SS_SUNKEN | SS_OWNERDRAW, 115, 90, 12, 12 + CONTROL "", IDC_STATIC_COLOR9, "Static", SS_NOTIFY | SS_SUNKEN | SS_OWNERDRAW, 129, 90, 12, 12 + CONTROL "", IDC_STATIC_COLOR10, "Static", SS_NOTIFY | SS_SUNKEN | SS_OWNERDRAW, 143, 90, 12, 12 + CONTROL "", IDC_STATIC_COLOR11, "Static", SS_NOTIFY | SS_SUNKEN | SS_OWNERDRAW, 157, 90, 12, 12 + CONTROL "", IDC_STATIC_COLOR12, "Static", SS_NOTIFY | SS_SUNKEN | SS_OWNERDRAW, 171, 90, 12, 12 + CONTROL "", IDC_STATIC_COLOR13, "Static", SS_NOTIFY | SS_SUNKEN | SS_OWNERDRAW, 185, 90, 12, 12 + CONTROL "", IDC_STATIC_COLOR14, "Static", SS_NOTIFY | SS_SUNKEN | SS_OWNERDRAW, 199, 90, 12, 12 + CONTROL "", IDC_STATIC_COLOR15, "Static", SS_NOTIFY | SS_SUNKEN | SS_OWNERDRAW, 213, 90, 12, 12 + CONTROL "", IDC_STATIC_COLOR16, "Static", SS_NOTIFY | SS_SUNKEN | SS_OWNERDRAW, 227, 90, 12, 12 + GROUPBOX "Èçáðàíè åêðàííè öâåòîâå:", -1, 7, 111, 240, 40 + CONTROL "", IDC_STATIC_SCREEN_COLOR, "Static", SS_OWNERDRAW | SS_SUNKEN, 15, 124, 224, 20 + GROUPBOX "Èçáðàíè èçñêà÷àùè öâåòîâå:", -1, 7, 162, 240, 40 + CONTROL "", IDC_STATIC_POPUP_COLOR, "Static", SS_OWNERDRAW | SS_SUNKEN, 15, 176, 224, 20 +END + +IDD_APPLYOPTIONS DIALOGEX 0, 0, 265, 79 +STYLE DS_SHELLFONT | WS_POPUP | WS_CAPTION +CAPTION "Ïðèëàãàíå íà ñâîéñòâàòà" +FONT 8, "MS Shell Dlg" +BEGIN + CONTROL "Ïðèëàãàíå íà ñâîéñòâàòà ñàìî çà &òåêóùèÿ ïðîçîðåö", IDC_RADIO_APPLY_CURRENT, "Button", BS_AUTORADIOBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 12, 12, 207, 10 + CONTROL "Ïðèëàãàíå íà ñâîéñòâàòà çà áúäåùè ïðîçîðöè ñúñ ñúùîòî çàãëàâèå", IDC_RADIO_APPLY_ALL, "Button", BS_AUTORADIOBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 12, 31, 247, 10 + PUSHBUTTON "Äîáðå", IDOK, 58, 58, 50, 14, WS_VISIBLE + PUSHBUTTON "Îòêàç", IDCANCEL, 114, 58, 50, 14, WS_VISIBLE +END + +STRINGTABLE +BEGIN + IDS_CPLNAME "Êîíçîëà" + IDS_CPLDESCRIPTION "Íàñòðîéêà íà êîíçîëàòà." + IDS_APPLY_SHORTCUT_ALL "Ïðîìÿíà íà &ïðåïðàòêàòà, çàïóñíàëà òîçè ïðîçîðåö" + IDS_SCREEN_TEXT "C:\\ReactOS> dir\nSYSTEM 10-01-99 5:00\nSYSTEM32 10-01-99 5:00" + IDS_RASTERFONTS "Ðåøåòú÷íè øðèôòîâå" +END diff --git a/reactos/dll/cpl/console/rsrc.rc b/reactos/dll/cpl/console/rsrc.rc index b2e02dcd9a7..f711388e3a9 100644 --- a/reactos/dll/cpl/console/rsrc.rc +++ b/reactos/dll/cpl/console/rsrc.rc @@ -3,6 +3,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL +#include "lang/bg-BG.rc" #include "lang/cs-CZ.rc" #include "lang/de-DE.rc" #include "lang/en-US.rc" diff --git a/reactos/dll/cpl/input/lang/cs-CZ.rc b/reactos/dll/cpl/input/lang/cs-CZ.rc new file mode 100644 index 00000000000..886a181f52f --- /dev/null +++ b/reactos/dll/cpl/input/lang/cs-CZ.rc @@ -0,0 +1,246 @@ +/* FILE: dll/cpl/input/lang/cs-CZ.rc + * TRANSLATOR: Radek Liska aka Black_Fox (radekliska at gmail dot com) + * UPDATED: 2010-06-02 + */ + +LANGUAGE LANG_CZECH, SUBLANG_DEFAULT + +IDD_PROPPAGESETTINGS DIALOGEX 0, 0, 254, 228 +STYLE DS_SHELLFONT | WS_CHILD | WS_DISABLED | WS_CAPTION +CAPTION "Nastavení" +FONT 8, "MS Shell Dlg" +BEGIN + LTEXT "Zvolte služby pro každý vstupní jazyk v seznamu.\nSeznam lze mìnit pomocí tlaèítek Pøidat a Odebrat.", -1, 9, 6, 238, 25 + CONTROL "TEXT", IDC_KEYLAYOUT_LIST, "SYSLISTVIEW32", WS_BORDER | WS_VSCROLL | WS_TABSTOP | LVS_SORTASCENDING | LVS_REPORT | 0x0000808D, 8, 36, 237, 101 + PUSHBUTTON "Nas&tavit výchozí", IDC_SET_DEFAULT, 101, 159, 144, 14 + PUSHBUTTON "&Pøidat...", IDC_ADD_BUTTON, 27, 142, 70, 14 + PUSHBUTTON "&Odebrat...", IDC_REMOVE_BUTTON, 101, 142, 70, 14 + PUSHBUTTON "&Vlastnosti...", IDC_PROP_BUTTON, 175, 142, 70, 14 + GROUPBOX "Pøedvolby", -1, 7, 185, 240, 36 + PUSHBUTTON "&Nastavení kláves...", IDC_KEY_SET_BTN, 14, 198, 110, 14 +END + +IDD_KEYSETTINGS DIALOGEX 0, 0, 272, 163 +STYLE DS_SHELLFONT | DS_MODALFRAME | DS_NOIDLEMSG | DS_CONTEXTHELP | WS_POPUPWINDOW | WS_VISIBLE | WS_CAPTION +CAPTION "Pokroèilé nastavení kláves" +FONT 8, "MS Shell Dlg" +BEGIN + GROUPBOX "Caps Lock vypnout", -1, 7, 7, 258, 26 + AUTORADIOBUTTON "Stisknutím klávesy &CAPS LOCK", IDC_PRESS_CL_KEY_RB, 14, 17, 120, 11, WS_GROUP + AUTORADIOBUTTON "Stisknutím klávesy &SHIFT", IDC_PRESS_SHIFT_KEY_RB, 144, 17, 120, 11, NOT WS_TABSTOP + GROUPBOX "Klávesové zkratky pro vstupní jazyky", -1, 7, 37, 258, 95 + LTEXT "Akce", -1, 14, 47, 60, 9 + RTEXT "&Posloupnost kláves", -1, 177, 47, 79, 9 + CONTROL "", IDC_KEY_LISTVIEW, "SysListView32", LVS_REPORT | LVS_NOCOLUMNHEADER | LVS_AUTOARRANGE | LVS_SINGLESEL, 14, 57, 244, 52, WS_EX_CLIENTEDGE + PUSHBUTTON "&Zmìnit posloupnost kláves...", IDC_CHANGE_KEY_SEQ_BTN, 152, 113, 106, 14, WS_GROUP + DEFPUSHBUTTON "OK", IDOK, 66, 140, 70, 14 + PUSHBUTTON "Storno", IDCANCEL, 146, 140, 70, 14 +END + +IDD_ADD DIALOGEX 20, 20, 227, 90 +STYLE DS_SHELLFONT | DS_MODALFRAME | DS_NOIDLEMSG | DS_CONTEXTHELP | WS_POPUPWINDOW | WS_VISIBLE | WS_CAPTION +CAPTION "Pøidat vstupní jazyk" +FONT 8, "MS Shell Dlg" +BEGIN + LTEXT "&Vstupní jazyk:", -1, 7, 7, 61, 10 + COMBOBOX IDC_INPUT_LANG_COMBO, 7, 17, 212, 150, CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL + LTEXT "&Rozložení kláves/IME:", -1, 7, 36, 110, 10 + COMBOBOX IDC_KEYBOARD_LO_COMBO, 7, 47, 212, 150, CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL + DEFPUSHBUTTON "OK", IDOK, 116, 68, 50, 14 + PUSHBUTTON "Storno", IDCANCEL, 169, 68, 50, 14 +END + +IDD_CHANGE_KEY_SEQ DIALOGEX 5, 100, 230, 125 +STYLE DS_SHELLFONT | DS_MODALFRAME | DS_NOIDLEMSG | DS_CONTEXTHELP | WS_POPUPWINDOW | WS_VISIBLE | WS_CAPTION +CAPTION "Zmìnit posloupnost kláves" +FONT 8, "MS Shell Dlg" +BEGIN + GROUPBOX "", -1, 9, 5, 155, 110 + AUTOCHECKBOX "&Pøepnout vstupní jazyky", IDC_SWITCH_INPUT_LANG_CB, 15, 15, 105, 12 + LTEXT "Shift", -1, 73, 37, 27, 12 + CTEXT "+", -1, 62, 37, 8, 9 + AUTORADIOBUTTON "&CTRL", IDC_CTRL_LANG, 29, 31, 30, 11 + AUTORADIOBUTTON "Levý &ALT", IDC_LEFT_ALT_LANG, 29, 45, 46, 12 + AUTOCHECKBOX "Pøepnout &rozložení kláves", IDC_SWITCH_KBLAYOUTS_CB, 16, 65, 141, 12 + LTEXT "Shift", -1, 74, 87, 27, 12 + CTEXT "+", -1, 63, 87, 8, 9 + AUTORADIOBUTTON "C&TRL", IDC_CTRL_LAYOUT, 30, 81, 30, 11 + AUTORADIOBUTTON "Levý A<", IDC_LEFT_ALT_LAYOUT, 30, 95, 44, 12 + DEFPUSHBUTTON "OK", IDOK, 172, 9, 50, 14 + PUSHBUTTON "Storno", IDCANCEL, 172, 27, 50, 14 +END + +IDD_INPUT_LANG_PROP DIALOGEX 20, 20, 227, 75 +STYLE DS_SHELLFONT | DS_MODALFRAME | DS_NOIDLEMSG | DS_CONTEXTHELP | WS_POPUPWINDOW | WS_VISIBLE | WS_CAPTION +CAPTION "Vlastnosti vstupních jazykù" +FONT 8, "MS Shell Dlg" +BEGIN + LTEXT "Vstupní jazyk:", -1, 7, 7, 61, 8 + LTEXT "", IDC_INPUT_LANG_STR, 73, 7, 129, 8 + LTEXT "&Rozložení kláves/IME:", -1, 7, 21, 110, 10 + COMBOBOX IDC_KB_LAYOUT_IME_COMBO, 7, 32, 212, 150, CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL + DEFPUSHBUTTON "OK", IDOK, 116, 53, 52, 14 + PUSHBUTTON "Storno", IDCANCEL, 169, 53, 52, 14 +END + +STRINGTABLE +BEGIN + IDS_CPLSYSTEMNAME "Služby textu a vstupní jazyky" + IDS_CPLSYSTEMDESCRIPTION "Upravuje nastavení pro textový vstup jazykù." + IDS_KEYBOARD "Klávesnice" + IDS_NONE "(Žádné)" + IDS_UNKNOWN "(Neznámé)" + IDS_RESTART "Restartovat poèítaè nyní?" + IDS_WHATS_THIS "Co je tohle?" + IDS_LANGUAGE "Jazyk" + IDS_LAYOUT "Rozložení kláves" + IDS_REM_QUESTION "Odebrat zvolené rozložení kláves?" + IDS_CONFIRMATION "Potvrzení" + IDS_LAYOUT_EXISTS "Toto rozložení již existuje." + IDS_LAYOUT_EXISTS2 "Toto rozložení již existuje a nemùže být pøidáno." + IDS_CTRL_SHIFT "Ctrl+Shift" + IDS_LEFT_ALT_SHIFT "Levý Alt+Shift" + IDS_SWITCH_BET_INLANG "Pøepnout mezi vstupními jazyky" +END + +STRINGTABLE +BEGIN + IDS_ALBANIAN_LAYOUT, "Albánština" + IDS_ARABIC_101_LAYOUT, "Arabština (101)" + IDS_ARABIC_102_LAYOUT, "Arabština (102)" + IDS_ARABIC_102_AZERTY_LAYOUT, "Arabština (102) AZERTY" + IDS_ARMENIAN_EASTERN_LAYOUT, "Arménština (Východní)" + IDS_ARMENIAN_WESTERN_LAYOUT, "Arménština (Západní)" + IDS_ASSAMESE_LAYOUT, "Ásámština" + IDS_AZERI_CYRILLIC_LAYOUT, "Azerština (Cyrilice)" + IDS_AZERI_LATIN_LAYOUT, "Azerština (Latinka)" + IDS_BELARUSIAN_LAYOUT, "Bìloruština" + IDS_BELGIAN_COMMA_LAYOUT, "Belgická (Èárka)" + IDS_BELGIAN_FRENCH_LAYOUT, "Belgická (Francouzština)" + IDS_BELGIAN_LAYOUT, "Belgická (Teèka)" + IDS_BENGALI_LAYOUT, "Bengálština" + IDS_BULGARIAN_LAYOUT, "Bulharština" + IDS_BULGARIAN_BDS_LAYOUT, "Bulharština (BDS 5237-1978)" + IDS_BULGARIAN_LATIN_LAYOUT, "Bulharština (Latinka)" + IDS_BULGARIAN_PHONETIC_BDS_LAYOUT, "Bulharština (Fonetická) (BDS 5237-1978)" + IDS_BULGARIAN_PHONETIC_CLASSIC_LAYOUT, "Bulharština (Fonetická) (Klasická)" + IDS_BURMESE_LAYOUT, "Barmština" + IDS_CANADIAN_FRENCH_LAYOUT, "Kanadské (Francouzština)" + IDS_CANADIAN_FRENCH_LEGACY_LAYOUT, "Kanadské (Francouzština) (Staré)" + IDS_CANADIAN_MULTILINGUAL_STD_LAYOUT, "Kanadské (Vícejazyèné standardní)" + IDS_CANTONESE_PHONETIC_LAYOUT, "Kantonština (Fonetická)" + IDS_CHINESE_SIMPLIFIED_MSPINYINIME30_LAYOUT, "Èínština (Zjednodušená) - Microsoft Pinyin IME 3.0" + IDS_CHINESE_SIMPLIFIED_NEIMA_LAYOUT, "Èínština (Zjednodušená) - NeiMa" + IDS_CHINESE_SIMPLIFIED_QUANPIN_LAYOUT, "Èínština (Zjednodušená) - QuanPin" + IDS_CHINESE_SIMPLIFIED_SHUANGPIN_LAYOUT, "Èínština (Zjednodušená) - ShuangPin" + IDS_CHINESE_SIMPLIFIED_USKEYBOARD_LAYOUT, "Èínština (Zjednodušená) - US klávesnice" + IDS_CHINESE_SIMPLIFIED_ZHENGMA_LAYOUT, "Èínština (Zjednodušená) - ZhengMa" + IDS_CHINESE_TRADITIONAL_ALPHANUMERIC_LAYOUT, "Èínština (Tradièní) - Alfanumerická" + IDS_CHINESE_TRADITIONAL_ARRAY_LAYOUT, "Èínština (Tradièní) - Array" + IDS_CHINESE_TRADITIONAL_BIG5CODE_LAYOUT, "Èínština (Tradièní) - Big5 Code" + IDS_CHINESE_TRADITIONAL_CHANGJIE_LAYOUT, "Èínština (Tradièní) - ChangJie" + IDS_CHINESE_TRADITIONAL_DAYI_LAYOUT, "Èínština (Tradièní) - DaYi" + IDS_CHINESE_TRADITIONAL_NEWCHANGJIE_LAYOUT, "Èínština (Tradièní) - Nová ChangJie" + IDS_CHINESE_TRADITIONAL_NEWPHONETIC_LAYOUT, "Èínština (Tradièní) - Nová fonetická" + IDS_CHINESE_TRADITIONAL_PHONETIC_LAYOUT, "Èínština (Tradièní) - Fonetická" + IDS_CHINESE_TRADITIONAL_QUICK_LAYOUT, "Èínština (Tradièní) - Rychlá" + IDS_CHINESE_TRADITIONAL_UNICODE_LAYOUT, "Èínština (Tradièní) - Unicode" + IDS_CHINESE_TRADITIONAL_USKEYBOARD_LAYOUT, "Èínština (Tradièní) - US Klávesnice" + IDS_CROATIAN_LAYOUT, "Chorvatština" + IDS_CZECH_LAYOUT, "Èeština" + IDS_CZECH_PROGRAMMERS_LAYOUT, "Èeština (Programátorská)" + IDS_CZECH_QWERTY_LAYOUT, "Èeština (QWERTY)" + IDS_DANISH_LAYOUT, "Dánština" + IDS_DEVANAGARI_INSCRIPT_LAYOUT, "Dévanágarí - INSCRIPT" + IDS_DIVEHI_PHONETIC_LAYOUT, "Divehština (Fonetická)" + IDS_DIVEHI_TYPEWRITER_LAYOUT, "Divehština (Psací stroj)" + IDS_DUTCH_LAYOUT, "Holandština" + IDS_ESTONIAN_LAYOUT, "Estonština" + IDS_FAEROESE_LAYOUT, "Faerština" + IDS_FARSI_LAYOUT, "Fársí" + IDS_FINNISH_LAYOUT, "Finština" + IDS_FRENCH_LAYOUT, "Francouzština" + IDS_GAELIC_LAYOUT, "Galicijština" + IDS_GEORGIAN_LAYOUT, "Gruzínština" + IDS_GERMAN_LAYOUT, "Nìmèima" + IDS_GERMAN_DE_ERGO_LAYOUT, "Nìmèima (de_ergo)" + IDS_GERMAN_IBM_LAYOUT, "Nìmèima (IBM)" + IDS_GERMAN_NEO_11_LAYOUT, "Nìmèima (NEO-1.1)" + IDS_GERMAN_RISTOME_LAYOUT, "Nìmèima (RISTOME)" + IDS_GREEK_LAYOUT, "Øeètina" + IDS_GREEK_220_LAYOUT, "Øeètina (220)" + IDS_GREEK_220_LATIN_LAYOUT, "Øeètina (220) (Latinka)" + IDS_GREEK_319_LAYOUT, "Øeètina (319)" + IDS_GREEK_319_LATIN_LAYOUT, "Øeètina (319) (Latinka)" + IDS_GREEK_LATIN_LAYOUT, "Øeètina (Latinka)" + IDS_GREEK_POLYTONIC_LAYOUT, "Øeètina (Polytonická)" + IDS_GUJARATI_LAYOUT, "Gudžarátština" + IDS_HEBREW_LAYOUT, "Hebrejština" + IDS_HINDI_TRADITIONAL_LAYOUT, "Hindština (Tradièní)" + IDS_HUNGARIAN_LAYOUT, "Maïarština" + IDS_HUNGARIAN_101_KEY_LAYOUT, "Maïarština (101 kláves)" + IDS_ICELANDIC_LAYOUT, "Islandština" + IDS_IRISH_LAYOUT, "Irština" + IDS_ITALIAN_LAYOUT, "Italština" + IDS_ITALIAN_142_LAYOUT, "Italština (142)" + IDS_JAPANESE_LAYOUT, "Japonština" + IDS_JAPANESE_INPUT_SYSTEM_MSIME2002_LAYOUT, "Japonský vstupní systém (MS-IME2002)" + IDS_KANNADA_LAYOUT, "Kannadština" + IDS_KAZAKH_LAYOUT, "Kazaština" + IDS_KOREAN_LAYOUT, "Korejština" + IDS_KOREAN_INPUT_SYSTEM_MSIME2002_LAYOUT, "Korjský vstupní systém (MS-IME2002)" + IDS_KYRGYZ_CYRILLIC_LAYOUT, "Kyrgyzština (Cyrilice)" + IDS_LATIN_AMERICAN_LAYOUT, "Latinská Amerika" + IDS_LATVIAN_LAYOUT, "Lotyština" + IDS_LATVIAN_QWERTY_LAYOUT, "Lotyština (QWERTY)" + IDS_LITHUANIAN_LAYOUT, "Litevština" + IDS_LITHUANIAN_IBM_LAYOUT, "Litevština (IBM)" + IDS_FYRO_MACEDONIAN_LAYOUT, "FYRO Makedonština" + IDS_MALAYALAM_LAYOUT, "Malajámština" + IDS_MARATHI_LAYOUT, "Maráthština" + IDS_MONGOLIAN_CYRILLIC_LAYOUT, "Mongolština (Cyrilice)" + IDS_NORWEGIAN_LAYOUT, "Norština" + IDS_ORIYA_LAYOUT, "Orijština" + IDS_POLISH_214_LAYOUT, "Polština (214)" + IDS_POLISH_LAYOUT, "Polština (Programátorská)" + IDS_PORTUGUESE_LAYOUT, "Portugalština" + IDS_PORTUGUESE_BRAZILIAN_ABNT_LAYOUT, "Portugalština (Brazilská ABNT)" + IDS_PORTUGUESE_BRAZIL_ABNT2_LAYOUT, "Portugalština (Brazilská ABNT2)" + IDS_PUNJABI_LAYOUT, "Paòdžábština" + IDS_ROMANIAN_LAYOUT, "Rumunština" + IDS_RUSSIAN_LAYOUT, "Ruština" + IDS_RUSSIAN_TYPEWRITER_LAYOUT, "Ruština (Psací stroj)" + IDS_SERBIAN_CYRILLIC_LAYOUT, "Srbština (Cyrilice)" + IDS_SERBIAN_LATIN_LAYOUT, "Srbština (Latinka)" + IDS_SLOVAK_LAYOUT, "Slovenština" + IDS_SLOVAK_QWERTY_LAYOUT, "Slovenština (QWERTY)" + IDS_SLOVENIAN_LAYOUT, "Slovinština" + IDS_SPANISH_LAYOUT, "Španìlština" + IDS_SPANISH_VARIANTION_LAYOUT, "Španìlština (Variace)" + IDS_SWEDISH_LAYOUT, "Švédština" + IDS_SWISS_FRENCH_LAYOUT, "Švýcarská francouzština" + IDS_SWISS_GERMAN_LAYOUT, "Švýcarská nìmèina" + IDS_SYRIAC_LAYOUT, "Syrština" + IDS_SYRIAC_PHONETIC_LAYOUT, "Syrština (Fonetická)" + IDS_TAMIL_LAYOUT, "Tamilština" + IDS_TATAR_LAYOUT, "Tatarština" + IDS_TELUGU_LAYOUT, "Telugština" + IDS_THAI_KEDMANEE_LAYOUT, "Thajština Kedmanee" + IDS_THAI_KEDMANEE_NONSHIFTLOCK_LAYOUT, "Thajština Kedmanee (non-ShiftLock)" + IDS_THAI_PATTACHOTE_LAYOUT, "Thajština Pattachote" + IDS_THAI_PATTACHOTE_NONSHIFTLOCK_LAYOUT, "Thajština Pattachote (non-ShiftLock)" + IDS_TURKISH_F_LAYOUT, "Tureètina F" + IDS_TURKISH_Q_LAYOUT, "Tureètina Q" + IDS_UKRAINIAN_LAYOUT, "Ukrajinština" + IDS_UKRAINIAN_STUDENT_LAYOUT, "Ukrajinština (Student)" + IDS_UNITED_KINGDOM_LAYOUT, "Spojené království" + IDS_UNITED_STATES_DVIRAK_LAYOUT, "Spojené státy-Dvorak" + IDS_UNITED_STATES_DVORAK_FOR_LEFT_HAND_LAYOUT, "Spojené státy-Dvorak pro levou ruku" + IDS_UNITED_STATES_DVORAK_FOR_RIGHT_HAND_LAYOUT, "Spojené státy-Dvorak pro pravou ruku" + IDS_UNITED_STATES_INTERNATIONAL_LAYOUT, "Spojené státy-Mezinárodní" + IDS_URDU_LAYOUT, "Urdština" + IDS_US_LAYOUT, "US" + IDS_USENG_TABLE_IBM_ARABIC238L_LAYOUT, "US anglická tabulka pro IBM arabštinu 238_L" + IDS_UZBEK_CYRILLIC_LAYOUT, "Uzbeètina (Cyrilice)" + IDS_VIETNAMESE_LAYOUT, "Vietnamština" +END diff --git a/reactos/dll/cpl/input/rsrc.rc b/reactos/dll/cpl/input/rsrc.rc index 51042fbfd9e..2dcb7b7f22a 100644 --- a/reactos/dll/cpl/input/rsrc.rc +++ b/reactos/dll/cpl/input/rsrc.rc @@ -2,6 +2,7 @@ #include "resource.h" #include "lang/bg-BG.rc" +#include "lang/cs-CZ.rc" #include "lang/de-DE.rc" #include "lang/el-GR.rc" #include "lang/en-US.rc" diff --git a/reactos/dll/cpl/intl/lang/bg-BG.rc b/reactos/dll/cpl/intl/lang/bg-BG.rc index 75d62f3391a..559f02adccd 100644 --- a/reactos/dll/cpl/intl/lang/bg-BG.rc +++ b/reactos/dll/cpl/intl/lang/bg-BG.rc @@ -23,7 +23,7 @@ BEGIN EDITTEXT IDC_FULLTIMESAMPLE_EDIT, 89, 146, 140, 12, ES_READONLY | WS_CHILD | WS_VISIBLE | WS_GROUP | NOT WS_TABSTOP GROUPBOX "Ãåîãðàôñêî ïîëîæåíèå", -1, 5, 172, 240, 55 LTEXT "Óêàçâàíå íà ïîëîæåíèåòî âè, çàðàäè óñëóãè, êîèòî áèõà ìîãëè äà âè îñèãóðÿâàò ìåñòíè óñëóãè îò ðîäà íà íîâèíè è äîêëàäè çà âðåìåòî.", -1, 14, 181, 230, 24 - COMBOBOX IDC_LOCATION_COMBO, 14, 207, 270, 160, CBS_DROPDOWNLIST | CBS_AUTOHSCROLL | WS_VSCROLL | WS_TABSTOP | CBS_SORT + COMBOBOX IDC_LOCATION_COMBO, 14, 207, 270, 150, CBS_DROPDOWNLIST | CBS_AUTOHSCROLL | WS_VSCROLL | WS_TABSTOP | CBS_SORT END IDD_LANGUAGESPAGE DIALOGEX 0, 0, 246, 230 @@ -187,9 +187,9 @@ END STRINGTABLE BEGIN IDS_CUSTOMIZE_TITLE "Íàãëàñÿâàíå íà ìåñòíèòå íàñòðîéêè" - IDS_SPAIN "Spanish (Spain)" - IDS_METRIC "Metric" - IDS_IMPERIAL "Imperial" + IDS_SPAIN "Èñïàíñêè (Èñïàíèÿ)" + IDS_METRIC "Ìåòðè÷íè" + IDS_IMPERIAL "Áðèòàíñêè" END STRINGTABLE diff --git a/reactos/dll/cpl/sysdm/lang/bg-BG.rc b/reactos/dll/cpl/sysdm/lang/bg-BG.rc index c358cf4e3e1..c6f7ab8f4b6 100644 --- a/reactos/dll/cpl/sysdm/lang/bg-BG.rc +++ b/reactos/dll/cpl/sysdm/lang/bg-BG.rc @@ -1,4 +1,5 @@ // Location: \dll\cpl\sysdm\lang +// Íåäîâúðøåí LANGUAGE LANG_BULGARIAN, SUBLANG_DEFAULT IDD_PROPPAGEGENERAL DIALOGEX 0, 0, 256, 218 @@ -75,7 +76,7 @@ BEGIN GROUPBOX "Version Info",IDC_STATIC,6,3,210,73 CONTROL "Report as Workstation",IDC_REPORTASWORKSTATION,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,57,88,10 LTEXT "ReactOS is built as a server OS and reports as such. Check this box to change this for applications only.",IDC_STATIC,15,15,183,41 - PUSHBUTTON "OK",IDOK,166,83,50,14 + PUSHBUTTON "Äîáðå",IDOK,166,83,50,14 END diff --git a/reactos/dll/cpl/sysdm/lang/cs-CZ.rc b/reactos/dll/cpl/sysdm/lang/cs-CZ.rc index 2e11444dea1..9e56b142530 100644 --- a/reactos/dll/cpl/sysdm/lang/cs-CZ.rc +++ b/reactos/dll/cpl/sysdm/lang/cs-CZ.rc @@ -1,6 +1,6 @@ /* FILE: dll/cpl/sysdm/lang/cs-CZ.rc * TRANSLATOR: Radek Liska aka Black_Fox (radekliska at gmail dot com) - * UPDATED: 2010-03-04 + * UPDATED: 2010-06-03 */ LANGUAGE LANG_CZECH, SUBLANG_DEFAULT @@ -289,9 +289,9 @@ BEGIN IDS_USERPROFILE_TYPE "Typ" IDS_USERPROFILE_STATUS "Status" IDS_USERPROFILE_MODIFIED "Upraveno" - IDS_MESSAGEBOXTITLE "System control panel applet" - IDS_WARNINITIALSIZE "Enter a numeric value for the initial size of the paging file." - IDS_WARNMAXIMUMSIZE "Enter a numeric value for the maximum size of the paging file." + IDS_MESSAGEBOXTITLE "Systémový aplet kontrolních panelù" + IDS_WARNINITIALSIZE "Zadejte èíselnou hodnotu pro úvodní velikost stránkovacího souboru." + IDS_WARNMAXIMUMSIZE "Zadejte èíselnou hodnotu pro maximální velikost stránkovacího souboru." IDS_WARNINITIALRANGE "The initial size of the paging file must not be smaller than 2 MB and must not exceed the available space on the selected drive." IDS_WARNMAXIMUMRANGE "The maximum size of the paging file must not be smaller than its initial size and must not exceed the available space on the selected drive." END diff --git a/reactos/dll/cpl/timedate/lang/bg-BG.rc b/reactos/dll/cpl/timedate/lang/bg-BG.rc index 659a60ea134..6de6e78681e 100644 --- a/reactos/dll/cpl/timedate/lang/bg-BG.rc +++ b/reactos/dll/cpl/timedate/lang/bg-BG.rc @@ -64,5 +64,5 @@ BEGIN IDS_INETTIMESUCSYNC "Âðåìåòî áå óñïåøíî ñâåðåíî ñ %s íà %s â %s" IDS_INETTIMENEXTSYNC "Ñëåäâàùî ñâåðÿâàíå: %s at %s" IDS_INETTIMESYNCING "Ïî÷àêàéòå, äîêàòî ÐåàêòÎÑ ñâåðÿâà âðåìåòî ñ %s" - IDS_INETTIMEERROR "Âúçíèêíà ãðåøêà, ïðè ñâåðÿâàíå íà âðåìåòî %s" + IDS_INETTIMEERROR "Âúçíèêíà ãðåøêà ïðè ñâåðÿâàíå íà âðåìåòî %s" END diff --git a/reactos/dll/win32/avifil32/avifile_Bg.rc b/reactos/dll/win32/avifil32/avifile_Bg.rc new file mode 100644 index 00000000000..91372aa41a0 --- /dev/null +++ b/reactos/dll/win32/avifil32/avifile_Bg.rc @@ -0,0 +1,55 @@ +/* + * Copyright 2002 Michael GГјnnewig + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "avifile_private.h" + +/* UTF-8 */ +#pragma code_page(65001) + +LANGUAGE LANG_BULGARIAN, SUBLANG_DEFAULT + +IDD_SAVEOPTIONS DIALOG 43, 37, 236, 82 +STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU +CAPTION "ВъзможноÑти на уплътнÑването" +FONT 8, "MS Shell Dlg" +BEGIN + LTEXT "&Избер на поток:",-1,2,5,154,10 + COMBOBOX IDC_STREAM,2,18,154,61,CBS_DROPDOWNLIST | WS_VSCROLL | + WS_TABSTOP + PUSHBUTTON "Въз&можноÑти...",IDC_OPTIONS,170,17,60,14 + AUTOCHECKBOX "&разÑлоÑване през",IDC_INTERLEAVE,3,42,85,11,WS_TABSTOP + EDITTEXT IDC_INTERLEAVEEVERY,91,41,32,12,ES_AUTOHSCROLL + LTEXT "кадъра",-1,129,43,36,9 + LTEXT "Текущ формат:",-1,3,56,73,9 + LTEXT "This space for rent",IDC_FORMATTEXT,75,56,90,26 /*Ðеразбираем низ*/ + DEFPUSHBUTTON "Добре",IDOK,170,42,60,14 + PUSHBUTTON "Отказ",IDCANCEL,170,61,60,14 +END + +STRINGTABLE +{ + IDS_WAVESTREAMFORMAT "Вълнoва крива: %s" + IDS_WAVEFILETYPE "Вълнова крива" + IDS_ALLMULTIMEDIA "Ð’Ñички мултимедийни файлове" + IDS_ALLFILES "Ð’Ñички файлове (*.*)@*.*" + IDS_VIDEO "видео" + IDS_AUDIO "звук" + IDS_AVISTREAMFORMAT "%s %s #%d" + IDS_AVIFILETYPE "Поздрабираното от Wine приложение за AVI" + IDS_UNCOMPRESSED "неуплътнен" +} diff --git a/reactos/dll/win32/avifil32/rsrc.rc b/reactos/dll/win32/avifil32/rsrc.rc index 71280912ce0..1014aad7de1 100644 --- a/reactos/dll/win32/avifil32/rsrc.rc +++ b/reactos/dll/win32/avifil32/rsrc.rc @@ -47,6 +47,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL #include "avifile_Uk.rc" /* UTF-8 */ +#include "avifile_Bg.rc" #include "avifile_Da.rc" #include "avifile_De.rc" #include "avifile_Fr.rc" diff --git a/reactos/dll/win32/browseui/browseui.rc b/reactos/dll/win32/browseui/browseui.rc index 392035a5919..afb9a0c1d8a 100644 --- a/reactos/dll/win32/browseui/browseui.rc +++ b/reactos/dll/win32/browseui/browseui.rc @@ -47,7 +47,6 @@ IDR_REGTREEOPTIONS REGISTRY "res\\regtreeoptions.rgs" * Everything specific to any language goes * in one of the specific files. */ -//#include "lang/bg-BG.rc" //#include "lang/ca-ES.rc" //#include "lang/cs-CZ.rc" //#include "lang/da-DK.rc" @@ -76,3 +75,6 @@ IDR_REGTREEOPTIONS REGISTRY "res\\regtreeoptions.rgs" #include "lang/uk-UA.rc" //#include "lang/zh-CN.rc" //#include "lang/zh-TW.rc" + +/* UTF-8 */ +#include "lang/bg-BG.rc" diff --git a/reactos/dll/win32/browseui/lang/Bg-bg.rc b/reactos/dll/win32/browseui/lang/Bg-bg.rc new file mode 100644 index 00000000000..ba762f9a089 --- /dev/null +++ b/reactos/dll/win32/browseui/lang/Bg-bg.rc @@ -0,0 +1,276 @@ +/* + * Copyright 2009 Andrew Hill + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +/* UTF-8 */ +#pragma code_page(65001) + +LANGUAGE LANG_BULGARIAN, SUBLANG_DEFAULT + +///////////////////////////////////////////////////////////////////////////// +// +// Menus +// + +IDM_CABINET_CONTEXTMENU MENUEX +BEGIN + POPUP "", 264,MFT_STRING,MFS_ENABLED + BEGIN + MENUITEM "&Обичайни бутони", IDM_TOOLBARS_STANDARDBUTTONS,MFT_STRING,MFS_ENABLED + MENUITEM "&ÐдреÑна лента", IDM_TOOLBARS_ADDRESSBAR,MFT_STRING,MFS_ENABLED + MENUITEM "&Връзки", IDM_TOOLBARS_LINKSBAR,MFT_STRING,MFS_ENABLED + MENUITEM SEPARATOR + MENUITEM "Заключване на лентите Ñ &поÑобиÑ", IDM_TOOLBARS_LOCKTOOLBARS,MFT_STRING,MFS_ENABLED + MENUITEM "&ÐаглаÑÑване...", IDM_TOOLBARS_CUSTOMIZE,MFT_STRING,MFS_ENABLED + MENUITEM "&ТекÑтови етикети", IDM_TOOLBARS_TEXTLABELS,MFT_STRING,MFS_ENABLED + MENUITEM "Бутон „&Отиване“", IDM_TOOLBARS_GOBUTTON,MFT_STRING,MFS_ENABLED + END +END + +IDM_CABINET_MAINMENU MENUEX +BEGIN + POPUP "&Файл", FCIDM_MENU_FILE + BEGIN + MENUITEM "", -1, MFT_SEPARATOR + MENUITEM "&ЗатварÑне", IDM_FILE_CLOSE + END + POPUP "&Обработка", FCIDM_MENU_EDIT + BEGIN + MENUITEM "", -1, MFT_SEPARATOR + END + POPUP "Из&глед", FCIDM_MENU_VIEW + BEGIN + POPUP "Ленти Ñ &поÑобиÑ", IDM_VIEW_TOOLBARS + BEGIN + MENUITEM "", -1, MFT_SEPARATOR + END + MENUITEM "Лента на &ÑÑŠÑтоÑнието", IDM_VIEW_STATUSBAR + POPUP "Лента на &изÑледователÑ", IDM_VIEW_EXPLORERBAR + BEGIN + MENUITEM "&ТърÑене\tCtrl+E", IDM_EXPLORERBAR_SEARCH + MENUITEM "&Любимки\tCtrl+I", IDM_EXPLORERBAR_FAVORITES + MENUITEM "&ÐоÑители" /* неÑÑно */, IDM_EXPLORERBAR_MEDIA + MENUITEM "&Дневник\tCtrl+H", IDM_EXPLORERBAR_HISTORY + MENUITEM "&Папки", IDM_EXPLORERBAR_FOLDERS + MENUITEM "", IDM_EXPLORERBAR_SEPARATOR + END + MENUITEM "", FCIDM_MENU_VIEW_SEP_OPTIONS, MFT_SEPARATOR + POPUP "&Отиване в", FCIDM_MENU_EXPLORE + BEGIN + MENUITEM "Ðа&зад\tAlt+Left Arrow", IDM_GOTO_BACK + MENUITEM "Ðа&пред\tAlt+Right Arrow", IDM_GOTO_FORWARD + MENUITEM "Равнище нагоре", IDM_GOTO_UPONELEVEL + MENUITEM "", -1, MFT_SEPARATOR + MENUITEM "&Ðачална Ñтраница\tAlt+Home", IDM_GOTO_HOMEPAGE + END + MENUITEM "О&преÑнÑване", IDM_VIEW_REFRESH + END + POPUP "&Любимки", FCIDM_MENU_FAVORITES + BEGIN + MENUITEM "ДобавÑне към &любимките...", IDM_FAVORITES_ADDTOFAVORITES + MENUITEM "&Подреждане на любимките", IDM_FAVORITES_ORGANIZEFAVORITES + MENUITEM "", -1, MFT_SEPARATOR + MENUITEM "(Празно)", IDM_FAVORITES_EMPTY + END + POPUP "&ПоÑобиÑ", FCIDM_MENU_TOOLS + BEGIN + MENUITEM "Ðазначаване на &мрежово уÑтройÑтво", IDM_TOOLS_MAPNETWORKDRIVE + MENUITEM "&Разкачане на мрежово уÑтройÑтво", IDM_TOOLS_DISCONNECTNETWORKDRIVE + MENUITEM "&СъглаÑуване", IDM_TOOLS_SYNCHRONIZE + MENUITEM "", -1, MFT_SEPARATOR + MENUITEM "&ÐаÑтройки на папките", IDM_TOOLS_FOLDEROPTIONS + END + POPUP "Помо&щ", FCIDM_MENU_HELP + BEGIN + MENUITEM "Законен ли е този брой на РеактОС?", IDM_HELP_ISTHISCOPYLEGAL + MENUITEM "&За РеактОС", IDM_HELP_ABOUT + END +END + + +///////////////////////////////////////////////////////////////////////////// +// +// Dialogs +// + +IDD_CUSTOMIZETOOLBAREX DIALOGEX 0, 0, 357, 36 +STYLE DS_SETFONT | DS_3DLOOK | DS_FIXEDSYS | DS_CONTROL | WS_CHILD | WS_VISIBLE | WS_CAPTION +FONT 8, "MS Shell Dlg", 0, 0, 0x1 +BEGIN + LTEXT "ÐаÑтройки на &текÑта:",-1,4,2,48,15 + COMBOBOX IDC_TEXTOPTIONS,52,0,123,57,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + LTEXT "ÐаÑтройки на &значетата:",-1,4,20,48,15 + COMBOBOX IDC_ICONOPTIONS,52,18,123,57,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP +END + + +///////////////////////////////////////////////////////////////////////////// +// +// Accelerator +// + +IDR_ACCELERATORS ACCELERATORS +BEGIN + VK_F5, IDM_VIEW_REFRESH, VIRTKEY, NOINVERT + VK_F5, IDM_VIEW_REFRESH, VIRTKEY, CONTROL, NOINVERT + "R", IDM_VIEW_REFRESH, VIRTKEY, CONTROL, NOINVERT + VK_HOME, IDM_GOTO_HOMEPAGE, VIRTKEY, ALT, NOINVERT + "D", IDM_FAVORITES_ADDTOFAVORITES, VIRTKEY, CONTROL, NOINVERT + "B", IDM_FAVORITES_ORGANIZEFAVORITES, VIRTKEY, CONTROL, NOINVERT + VK_LEFT, IDM_GOTO_BACK, VIRTKEY, ALT + VK_RIGHT, IDM_GOTO_FORWARD, VIRTKEY, ALT + "W", IDM_FILE_CLOSE, VIRTKEY, CONTROL, NOINVERT + "E", IDM_EXPLORERBAR_SEARCH, VIRTKEY, CONTROL, NOINVERT + "I", IDM_EXPLORERBAR_FAVORITES, VIRTKEY, CONTROL, NOINVERT + "H", IDM_EXPLORERBAR_HISTORY, VIRTKEY, CONTROL, NOINVERT +END + + +///////////////////////////////////////////////////////////////////////////// +// +// Strings +// + +STRINGTABLE +BEGIN + 800 "Съдържа заповеди за обработка на избраните предмети." +END + +STRINGTABLE +BEGIN + 864 "Съдържа заповеди за обработка." +END + +STRINGTABLE +BEGIN + 928 "Съдържа заповеди за обработка на изгледа." +END + +STRINGTABLE +BEGIN + 992 "Съдържа заповеди за поÑобиÑта." +END + +STRINGTABLE +BEGIN + 1056 "СъÑържа заповеди за показване на помощ." +END + +STRINGTABLE +BEGIN + 9025 "Ð—Ð°Ñ‚Ð²Ð°Ñ€Ñ Ð¿Ñ€Ð¾Ð·Ð¾Ñ€ÐµÑ†Ð°." + 9026 "Отива равнище нагоре." +END + +STRINGTABLE +BEGIN + 9121 "Свърване към мрежово уÑтройÑтво." + 9122 "Разкачане от мрежово уÑтройÑтво." +END + +STRINGTABLE +BEGIN + 9250 "Показва ÑÐ²ÐµÐ´ÐµÐ½Ð¸Ñ Ð·Ð° програмата, верÑÐ¸Ñ Ð¸ възпроизводÑтвени права." + 9252 "Показва ÑÐ²ÐµÐ´ÐµÐ½Ð¸Ñ Ð·Ð° проÑледÑване на недъзи." +END + +STRINGTABLE +BEGIN + 9281 "Отива на предходната Ñтраница." + 9282 "Отива на Ñледващата Ñтраница." + 9283 "ÐŸÐ¾Ð·Ð²Ð¾Ð»Ñ Ð²Ð¸ да промените наÑтройките." + 9285 "Отива в началната ви Ñтраница." +END + +STRINGTABLE +BEGIN + 9362 "ÐžÑ‚Ð²Ð°Ñ€Ñ Ð¿Ð°Ð¿ÐºÐ°Ñ‚Ð° Ñ Ð»ÑŽÐ±Ð¸Ð¼ÐºÐ¸Ñ‚Ðµ." + 9363 "Ð”Ð¾Ð±Ð°Ð²Ñ Ñ‚ÐµÐºÑƒÑ‰Ð°Ñ‚Ð° Ñтраница към ÑпиÑъка Ñ Ð»ÑŽÐ±Ð¸Ð¼ÐºÐ¸Ñ‚Ðµ." +END + +STRINGTABLE +BEGIN + 9505 "Скрива или показва лентите Ñ Ð¿Ð¾ÑобиÑ." + 9506 "Скрива или показва лентата на ÑÑŠÑтоÑнието." + 9508 "Показва лентата Ñ Ð¾Ð±Ð¸Ñ‡Ð°Ð¹Ð½Ð¸Ñ‚Ðµ бутони." /* неÑÑно */ + 9509 "Показва адреÑната лента." + 9510 "Показва лената Ñ Ð±ÑŠÑ€Ð·Ð¸Ñ‚Ðµ връзки." + 9516 "Заключване на размерите и разположението на лентите Ñ Ð¿Ð¾ÑобиÑ." +END + +STRINGTABLE +BEGIN + 9533 "ÐаглаÑÑване на лентата Ñ Ð¿Ð¾ÑобиÑ." +END + +STRINGTABLE +BEGIN + 9552 "Показване или Ñкриване на лентата на изÑледователÑ." + 9553 "Показване на лентата за Ñ‚ÑŠÑ€Ñене." + 9554 "Показване на лентата Ñ Ð»ÑŽÐ±Ð¸Ð¼ÐºÐ¸Ñ‚Ðµ." + 9555 "Показване на лентата на дневника." + 9557 "Показване на лентата Ñ Ð¿Ð°Ð¿ÐºÐ¸Ñ‚Ðµ." + 9559 "Показване на медийната лента." +END + +STRINGTABLE +BEGIN + IDS_SMALLICONS "Малки значета" + IDS_LARGEICONS "Големи значета" + IDS_SHOWTEXTLABELS "Показване на текÑтови етикети" +END + +STRINGTABLE +BEGIN + IDS_NOTEXTLABELS "ЛипÑват текÑтови етикети" + IDS_SELECTIVETEXTONRIGHT "Selective text on right" +END + +STRINGTABLE +BEGIN + IDS_GOBUTTONLABEL "|Отиване||" + IDS_GOBUTTONTIPTEMPLATE "Отиване в""%s""" +END + +STRINGTABLE +BEGIN + IDS_SEARCHLABEL "ТърÑене" + IDS_ADDRESSBANDLABEL "&ÐдреÑ" +END + +STRINGTABLE +BEGIN + IDS_FOLDERSLABEL "Папки" +END + +STRINGTABLE +BEGIN + IDS_HISTORYTEXT "&Дневник\tCtrl+H" +END + +STRINGTABLE +BEGIN + IDS_UP "Ðагоре" +END + +STRINGTABLE +BEGIN + IDS_BACK "Ðазад" + IDS_FORWARD "Ðапред" +END + + diff --git a/reactos/dll/win32/devmgr/lang/bg-BG.rc b/reactos/dll/win32/devmgr/lang/bg-BG.rc index ec278d57810..98624f57d94 100644 --- a/reactos/dll/win32/devmgr/lang/bg-BG.rc +++ b/reactos/dll/win32/devmgr/lang/bg-BG.rc @@ -1,4 +1,4 @@ -// English language resource file (Sebastian Gasiorek, 2005-11-13) +// Bulgarian resource file LANGUAGE LANG_BULGARIAN, SUBLANG_DEFAULT @@ -91,15 +91,17 @@ BEGIN IDS_DEV_SETPROPERTIES_FAILED "ÐåàêòÎÑ íå óñïÿ äà ñìåíè íàñòðîéêèòå íà óñòðîéñòâîòî." END + +/*Íåïðåâåäåí ðàçäåë*/ STRINGTABLE BEGIN IDS_PROP_DEVICEID "Device Instance ID" IDS_PROP_HARDWAREIDS "Hardware IDs" IDS_PROP_COMPATIBLEIDS "Compatible IDs" IDS_PROP_MATCHINGDEVICEID "Matching Device ID" - IDS_PROP_SERVICE "Service" - IDS_PROP_ENUMERATOR "Enumerator" - IDS_PROP_CAPABILITIES "Capabilities" + IDS_PROP_SERVICE "Óñëóãà" + IDS_PROP_ENUMERATOR "Èçáðîèòåë" + IDS_PROP_CAPABILITIES "Ñïîñîáíîñòè" IDS_PROP_DEVNODEFLAGS "Devnode Flags" IDS_PROP_CONFIGFLAGS "Config Flags" IDS_PROP_CSCONFIGFLAGS "CSConfig Flags" @@ -114,8 +116,8 @@ BEGIN IDS_PROP_CLASSCOINSTALLER "Class Coinstallers" IDS_PROP_DEVICECOINSTALLER "Device Coinstallers" IDS_PROP_FIRMWAREREVISION "Firmware Revision" - IDS_PROP_CURRENTPOWERSTATE "Current Power State" - IDS_PROP_POWERCAPABILITIES "Power Capabilities" + IDS_PROP_CURRENTPOWERSTATE "Òåêóùî ñúñòîÿíèå íà çàõðàíâàíåòî" + IDS_PROP_POWERCAPABILITIES "Âúçìîæíîñòè íà çàõðàíâàíåòî" IDS_PROP_POWERSTATEMAPPINGS "Power State Mappings" END @@ -199,7 +201,7 @@ END IDD_DEVICEDETAILS DIALOGEX DISCARDABLE 0, 0, 252, 218 STYLE DS_SHELLFONT | WS_CHILD | WS_DISABLED | WS_CAPTION -CAPTION "Details" +CAPTION "Ïîäðîáíîñòè" FONT 8, "MS Shell Dlg" BEGIN ICON "", IDC_DEVICON, 7, 7, 20, 20 @@ -212,7 +214,7 @@ END IDD_DEVICERESOURCES DIALOGEX DISCARDABLE 0, 0, 252, 218 STYLE DS_SHELLFONT | WS_CHILD | WS_DISABLED | WS_CAPTION -CAPTION "Resources" +CAPTION "Ðåñóðñè" FONT 8, "MS Shell Dlg" BEGIN ICON "", IDC_DEVICON, 7, 7, 20, 20 @@ -221,7 +223,7 @@ END IDD_DEVICEPOWER DIALOGEX DISCARDABLE 0, 0, 252, 218 STYLE DS_SHELLFONT | WS_CHILD | WS_DISABLED | WS_CAPTION -CAPTION "Power" +CAPTION "Çàõðàíâàíå" FONT 8, "MS Shell Dlg" BEGIN ICON "", IDC_DEVICON, 7, 7, 20, 20 diff --git a/reactos/dll/win32/netid/lang/bg-BG.rc b/reactos/dll/win32/netid/lang/bg-BG.rc index 0335e77e69b..fab90537574 100644 --- a/reactos/dll/win32/netid/lang/bg-BG.rc +++ b/reactos/dll/win32/netid/lang/bg-BG.rc @@ -67,12 +67,12 @@ BEGIN 22 "Äîáðå äîøëè â ðàáîòíà ãðóïà %1." 23 "Äîáðå äîøëè â èìåíèå %1." 24 "Òðÿáâà äà ïðåçàïóñíåòå êîìïþòúðà, çà äà âëÿçàò ïðîìåíèòå â äåéñòâèå." - 25 "You can change the name and the membership of this computer. Changes may affect access to network resources." + 25 "Ìîæåòå äà ñìåíèòå èìåòî è ÷ëåíñòâîòî íà êîìïþòúðà. Âúçìîæíî å ïðîìåíèòå ìîãàò äà ïîâëèÿÿò íà äîñòúïà äî ìðåæîâèòå èçòî÷íèöè." 1021 "Çàáåëåæêà: Ñàìî óïðàâíèöèòå ìîãàò äà ïðîìåíÿò îïîçíàâàòåëèòå íà êîìïþòúðà." 1022 "Çàáåëåæêà: Îïîçíàâàòåëÿò íà êîìïþòúðà íå ìîæå äà áúäå ñìåíåí, çàùîòî:" - 1030 "The new computer name ""%s"" contains characters which are not allowed. Characters which are not allowed include ` ~ ! @ # $ %% ^ & * ( ) = + _ [ ] { } \\ | ; : ' "" , . < > / and ?" + 1030 "Íîâîòî èìå íà êîìïþòúðà „%s“ ñúäúðæà íåïîçâîëåíè çíàöè. Íÿêîè îò íåïîçâîëåíèòå çíàöè ñà ` ~ ! @ # $ %% ^ & * ( ) = + _ [ ] { } \\ | ; : ' "" , . < > / è ?" 3210 "&Ïî&äðîáíîñòè >>" 3220 "<< &Ïî&äðîáíîñòè" - 4000 "Information" - 4001 "Can't set new a computer name!" + 4000 "Ñâåäåíèÿ" + 4001 "Ãðåøêà ïðè ñìÿíàòà íà èìåòî íà êîìïþòúðà!" END diff --git a/reactos/dll/win32/netid/lang/en-US.rc b/reactos/dll/win32/netid/lang/en-US.rc index 02855fa54df..fc9064053e6 100644 --- a/reactos/dll/win32/netid/lang/en-US.rc +++ b/reactos/dll/win32/netid/lang/en-US.rc @@ -71,6 +71,7 @@ BEGIN 1021 "Note: Only Administrators can change the identification of this computer." 1022 "Note: The identification of the computer cannot be changed because:" 1030 "The new computer name ""%s"" contains characters which are not allowed. Characters which are not allowed include ` ~ ! @ # $ %% ^ & * ( ) = + _ [ ] { } \\ | ; : ' "" , . < > / and ?" +//Windows allows using these characters, although it displays a warning message. Forbidding the use of these characters means incompatibility with Windows. 3210 "&Details >>" 3220 "<< &Details" 4000 "Information" diff --git a/reactos/dll/win32/shell32/lang/bg-BG.rc b/reactos/dll/win32/shell32/lang/bg-BG.rc index 13a9bdb9f44..6e9b67ad41f 100644 --- a/reactos/dll/win32/shell32/lang/bg-BG.rc +++ b/reactos/dll/win32/shell32/lang/bg-BG.rc @@ -666,8 +666,8 @@ BEGIN IDS_RESTART_PROMPT "Èñêàòå ëè äà ïðåçàïóñíåòå ñèñòåìàòà?" IDS_SHUTDOWN_TITLE "Èçêëþ÷âàíå" IDS_SHUTDOWN_PROMPT "Èñêàòå ëè äà èçêëþ÷èòå êîìïþòúðà?" - IDS_LOGOFF_TITLE "Log Off" - IDS_LOGOFF_PROMPT "Do you want to log off?" + IDS_LOGOFF_TITLE "Èçëèçàíå" + IDS_LOGOFF_PROMPT "Èñêàòå ëè äà èçëåçåòå?" // shell folder path default values IDS_PROGRAMS "Ïóñêîâ èçáîðíèê\\Ïðèëîæåíèÿ" @@ -751,9 +751,9 @@ BEGIN IDS_INSTALLNEWFONT "Ñëàãàíå íà íîâ øðèôò..." IDS_DEFAULT_CLUSTER_SIZE "Ïîäðàçáèðàí ðàçïðåäåëèòåëåí ðàçìåð" - IDS_COPY_OF "Copy of" + IDS_COPY_OF "Ïðåçàïèñ íà" - IDS_SHLEXEC_NOASSOC "There is no Windows program configured to open this type of file." + IDS_SHLEXEC_NOASSOC "Íÿìà ïðèëîæåíèå çà Óèíäîóñ, íàñòðîåíî äà îòâàðÿ òîçè âèä ôàéëîâå." END diff --git a/reactos/dll/win32/syssetup/lang/bg-BG.rc b/reactos/dll/win32/syssetup/lang/bg-BG.rc index d3bbc3f15f3..a07591c578d 100644 --- a/reactos/dll/win32/syssetup/lang/bg-BG.rc +++ b/reactos/dll/win32/syssetup/lang/bg-BG.rc @@ -47,7 +47,7 @@ BEGIN LTEXT "ÐåàêòÎÑ å ëèöåíçèðàí ñïîðåä GPL è àêî èñêàòå äà ãî èçïîëçâàòå èëè ðàçïðîñòðàíÿâàòå "\ "(÷àñòè îò íåãî), òðÿáâà äà ñïàçâàòå GPL.", IDC_STATIC,15,110,227,20 - PUSHBUTTON "&Âèæ GPL...",IDC_VIEWGPL,251,110,50,19 + PUSHBUTTON "&Âèæòå GPL...",IDC_VIEWGPL,251,110,50,19 LTEXT "Íàòèñíåòå „Íàïðåä“ çà ïðîäúëæàâàíå íà íàñòðîéêàòà.",IDC_STATIC,15,136, 195,17 END @@ -226,7 +226,7 @@ BEGIN IDS_GAMES "Èãðè" IDS_CMT_SOLITAIRE "Ïàñèàíñ" IDS_CMT_WINEMINE "Ìèíè÷êè" - IDS_CMT_SPIDER "Spider Solitaire" + IDS_CMT_SPIDER "Ïàñèàíñ „Ïàÿê“" END STRINGTABLE @@ -248,7 +248,7 @@ BEGIN IDS_SYS_ENTERTAINMENT "Çàáàâëåíèå" IDS_CMT_MPLAY32 "Ïóñêàíå íà ìóëòèìåäèéíèÿ âúçïðîèçâîäèòåë" IDS_CMT_SNDVOL32 "Ïóñêàíå íà óïðâëåíèåòî íà ñèëàòà íà çâóêà" - IDS_CMT_SNDREC32 "Launch Sound Recorder" + IDS_CMT_SNDREC32 "Ïóñêàíå íà Çâóêîçàïèñâà÷à" END STRINGTABLE @@ -268,7 +268,7 @@ STRINGTABLE BEGIN IDS_SHORT_CMD "Êîìàíäåí ïðîçîðåö.lnk" IDS_SHORT_EXPLORER "Èçñëåäîâàòåëÿò íà ÐåàêòÎÑ.lnk" - IDS_SHORT_DOWNLOADER "ReactOS Applications Manager.lnk" + IDS_SHORT_DOWNLOADER "Óïðàâèòåë íà ïðèëîæåíèÿòà çà ÐåàêòÎÑ.lnk" IDS_SHORT_SERVICE "Óïðàâèòåë íà óñëóãèòå.lnk" IDS_SHORT_DEVICE "Óïðàâèòåë íà óñòðîéñòâàòà.lnk" IDS_SHORT_MPLAY32 "Ìóëòèìåäèåí âúçïðîèçâîäèòåë.lnk" @@ -286,10 +286,10 @@ BEGIN IDS_SHORT_EVENTVIEW "Ïðåãëåä íà ñúáèòèÿ.lnk" IDS_SHORT_MSCONFIG "Íàñòðîéêà íà óðåäáàòà.lnk" IDS_SHORT_SNDVOL32 "Ñèëà íà çâóêà.lnk" - IDS_SHORT_SNDREC32 "Audiorecorder.lnk" + IDS_SHORT_SNDREC32 "Çâóêîçàïèñâà÷.lnk" IDS_SHORT_DXDIAG "Ïðåãëåæäàíå íà ÐåàêòÕ.lnk" IDS_SHORT_PAINT "Ðèñóíúê.lnk" - IDS_SHORT_SPIDER "Spider Solitaire.lnk" + IDS_SHORT_SPIDER "Ïàñèàíñ „Ïàÿê“.lnk" END From e0da68cf955046dc45901100f47bf9167b572064 Mon Sep 17 00:00:00 2001 From: Daniel Reimer Date: Sun, 26 Dec 2010 13:54:57 +0000 Subject: [PATCH 120/181] Update rapps database. svn path=/trunk/; revision=50145 --- reactos/base/applications/rapps/rapps/fap.txt | 6 +++--- reactos/base/applications/rapps/rapps/irfanview.txt | 4 ++-- reactos/base/applications/rapps/rapps/irfanviewplugins.txt | 4 ++-- reactos/base/applications/rapps/rapps/libreoffice.txt | 6 +++--- reactos/base/applications/rapps/rapps/mirandaim.txt | 4 ++-- reactos/base/applications/rapps/rapps/mirc.txt | 4 ++-- reactos/base/applications/rapps/rapps/opera.txt | 6 +++--- reactos/base/applications/rapps/rapps/scummvm.txt | 6 +++--- reactos/base/applications/rapps/rapps/tuxpaint.txt | 6 +++--- 9 files changed, 23 insertions(+), 23 deletions(-) diff --git a/reactos/base/applications/rapps/rapps/fap.txt b/reactos/base/applications/rapps/rapps/fap.txt index 56a42cb23f8..72910b931ae 100644 --- a/reactos/base/applications/rapps/rapps/fap.txt +++ b/reactos/base/applications/rapps/rapps/fap.txt @@ -2,13 +2,13 @@ [Section] Name = Fox Audio Player -Version = 0.7.2 +Version = 0.8.1 Licence = GPL Description = Simple and lightweight audio player. -Size = 1.84MB +Size = 1.75MB Category = 1 URLSite = http://foxaudioplayer.sourceforge.net/ -URLDownload = http://svn.reactos.org/packages/fap-0.7.2-win32-bin.exe +URLDownload = http://svn.reactos.org/packages/fap-0.8.1-win32-bin.exe CDPath = none [Section.0407] diff --git a/reactos/base/applications/rapps/rapps/irfanview.txt b/reactos/base/applications/rapps/rapps/irfanview.txt index 760c3db69a4..0edc06bfe38 100644 --- a/reactos/base/applications/rapps/rapps/irfanview.txt +++ b/reactos/base/applications/rapps/rapps/irfanview.txt @@ -2,13 +2,13 @@ [Section] Name = IrfanView -Version = 4.27 +Version = 4.28 Licence = Freeware (for personal use) Description = Viewer for all kinds of graphics/audio files/video files. Size = 1.3MB Category = 3 URLSite = http://www.irfanview.com/ -URLDownload = http://irfanview.tuwien.ac.at/iview427_setup.exe +URLDownload = http://irfanview.tuwien.ac.at/iview428_setup.exe CDPath = none [Section.0407] diff --git a/reactos/base/applications/rapps/rapps/irfanviewplugins.txt b/reactos/base/applications/rapps/rapps/irfanviewplugins.txt index eb9c8ffcef5..03686ab053f 100644 --- a/reactos/base/applications/rapps/rapps/irfanviewplugins.txt +++ b/reactos/base/applications/rapps/rapps/irfanviewplugins.txt @@ -2,13 +2,13 @@ [Section] Name = IrfanView Plugins -Version = 4.27 +Version = 4.28 Licence = Freeware (for personal use) Description = Additional Plugins for supporting more file types. Size = 7.8MB Category = 3 URLSite = http://www.irfanview.com/ -URLDownload = http://irfanview.tuwien.ac.at/plugins/irfanview_plugins_427_setup.exe +URLDownload = http://irfanview.tuwien.ac.at/plugins/irfanview_plugins_428_setup.exe CDPath = none [Section.0407] diff --git a/reactos/base/applications/rapps/rapps/libreoffice.txt b/reactos/base/applications/rapps/rapps/libreoffice.txt index d255969a765..2fd0d9df7c9 100644 --- a/reactos/base/applications/rapps/rapps/libreoffice.txt +++ b/reactos/base/applications/rapps/rapps/libreoffice.txt @@ -2,13 +2,13 @@ [Section] Name = LibreOffice -Version = 3.3.0 RC1 +Version = 3.3.0 RC2 Licence = LGPL Description = Former called OpenOffice. Open Source Office Suite. -Size = 343.0MB +Size = 206.0MB Category = 6 URLSite = http://www.documentfoundation.org/ -URLDownload = http://download.documentfoundation.org/libreoffice/testing/3.3.0-rc1/win/x86/LibO_3.3.0rc1_Win_x86_install_multi.exe +URLDownload = http://download.documentfoundation.org/libreoffice/testing/3.3.0-rc2/win/x86/LibO_3.3.0rc2_Win_x86_install_multi.exe CDPath = none [Section.0407] diff --git a/reactos/base/applications/rapps/rapps/mirandaim.txt b/reactos/base/applications/rapps/rapps/mirandaim.txt index 295a197d028..68a2a602090 100644 --- a/reactos/base/applications/rapps/rapps/mirandaim.txt +++ b/reactos/base/applications/rapps/rapps/mirandaim.txt @@ -2,13 +2,13 @@ [Section] Name = Miranda IM -Version = 0.9.12 +Version = 0.9.13 Licence = GPL Description = Open source multiprotocol instant messaging application - May not work completely. Size = 3.0MB Category = 5 URLSite = http://www.miranda-im.org/ -URLDownload = http://miranda.googlecode.com/files/miranda-im-v0.9.12-unicode.exe +URLDownload = http://miranda.googlecode.com/files/miranda-im-v0.9.13-unicode.exe CDPath = none [Section.0407] diff --git a/reactos/base/applications/rapps/rapps/mirc.txt b/reactos/base/applications/rapps/rapps/mirc.txt index 1f7220a9947..754f89ea473 100644 --- a/reactos/base/applications/rapps/rapps/mirc.txt +++ b/reactos/base/applications/rapps/rapps/mirc.txt @@ -2,13 +2,13 @@ [Section] Name = mIRC -Version = 7.15 +Version = 7.17 Licence = Shareware Description = The most popular client for the Internet Relay Chat (IRC). Size = 2.0M Category = 5 URLSite = http://www.mirc.com/ -URLDownload = http://download.mirc.com/mirc715.exe +URLDownload = http://download.mirc.com/mirc717.exe CDPath = none [Section.0407] diff --git a/reactos/base/applications/rapps/rapps/opera.txt b/reactos/base/applications/rapps/rapps/opera.txt index b6493f55ed4..f01bd9d833d 100644 --- a/reactos/base/applications/rapps/rapps/opera.txt +++ b/reactos/base/applications/rapps/rapps/opera.txt @@ -2,13 +2,13 @@ [Section] Name = Opera -Version = 10.63 +Version = 11.00 Licence = Freeware Description = The popular Opera Browser with many advanced features and including a Mail and BitTorrent client. -Size = 12.7M +Size = 8.9M Category = 5 URLSite = http://www.opera.com/ -URLDownload = http://get4.opera.com/pub/opera/win/1063/int/Opera_1063_int_Setup.exe +URLDownload = http://get4.opera.com/pub/opera/win/1100/int/Opera_1100_int_Setup.exe CDPath = none [Section.0405] diff --git a/reactos/base/applications/rapps/rapps/scummvm.txt b/reactos/base/applications/rapps/rapps/scummvm.txt index bc7286ea979..55fd2204af1 100644 --- a/reactos/base/applications/rapps/rapps/scummvm.txt +++ b/reactos/base/applications/rapps/rapps/scummvm.txt @@ -2,13 +2,13 @@ [Section] Name = ScummVM -Version = 1.2.0 +Version = 1.2.1 Licence = GPL Description = Sam and Max, Day of the Tentacle, etc on ReactOS. -Size = 3.5MB +Size = 4.0MB Category = 4 URLSite = http://scummvm.org/ -URLDownload = http://dfn.dl.sourceforge.net/project/scummvm/scummvm/1.2.0/scummvm-1.2.0-win32.exe +URLDownload = http://dfn.dl.sourceforge.net/project/scummvm/scummvm/1.2.1/scummvm-1.2.1-win32.exe CDPath = none [Section.0407] diff --git a/reactos/base/applications/rapps/rapps/tuxpaint.txt b/reactos/base/applications/rapps/rapps/tuxpaint.txt index f32859f8491..e3216ae0233 100644 --- a/reactos/base/applications/rapps/rapps/tuxpaint.txt +++ b/reactos/base/applications/rapps/rapps/tuxpaint.txt @@ -2,13 +2,13 @@ [Section] Name = TuxPaint -Version = 0.9.21 +Version = 0.9.21b Licence = GPL Description = An Open Source bitmap graphics editor geared towards young children. -Size = 10MB +Size = 11MB Category = 3 URLSite = http://tuxpaint.org/ -URLDownload = http://ovh.dl.sourceforge.net/project/tuxpaint/tuxpaint/0.9.21/tuxpaint-0.9.21-win32-installer.exe +URLDownload = http://ovh.dl.sourceforge.net/project/tuxpaint/tuxpaint/0.9.21b/tuxpaint-0.9.21b-win32-installer.exe CDPath = none [Section.0405] From 7e4bfb42f211b812522c9d70ee86e85f0c4249ba Mon Sep 17 00:00:00 2001 From: Daniel Reimer Date: Sun, 26 Dec 2010 14:37:41 +0000 Subject: [PATCH 121/181] Fix for Fox Audio Player. Newest Version and leading to a Setup with libmpg svn path=/trunk/; revision=50146 --- reactos/base/applications/rapps/rapps/fap.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/reactos/base/applications/rapps/rapps/fap.txt b/reactos/base/applications/rapps/rapps/fap.txt index 72910b931ae..0132c7ad621 100644 --- a/reactos/base/applications/rapps/rapps/fap.txt +++ b/reactos/base/applications/rapps/rapps/fap.txt @@ -2,13 +2,13 @@ [Section] Name = Fox Audio Player -Version = 0.8.1 +Version = 0.8.3 Licence = GPL Description = Simple and lightweight audio player. -Size = 1.75MB +Size = 1.85MB Category = 1 URLSite = http://foxaudioplayer.sourceforge.net/ -URLDownload = http://svn.reactos.org/packages/fap-0.8.1-win32-bin.exe +URLDownload = http://svn.reactos.org/packages/fap-0.8.3-win32-bin.exe CDPath = none [Section.0407] From 08d8df3975982e1de3f2e00a8cdcba9f35b796e0 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Sun, 26 Dec 2010 14:54:57 +0000 Subject: [PATCH 122/181] [VGA_NEW] Use strlen() istead of sizeof() to get the string length from a pointer. CID 10403. svn path=/trunk/; revision=50147 --- reactos/drivers/video/miniport/vga_new/vbe.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reactos/drivers/video/miniport/vga_new/vbe.c b/reactos/drivers/video/miniport/vga_new/vbe.c index 1c2308ff75c..f6adf7ef684 100644 --- a/reactos/drivers/video/miniport/vga_new/vbe.c +++ b/reactos/drivers/video/miniport/vga_new/vbe.c @@ -47,7 +47,7 @@ IsVesaBiosOk(IN PVIDEO_PORT_INT10_INTERFACE Interface, VideoPortDebugPrint(0, "Vendor: %s Product: %s Revision: %s (%lx)\n", Vendor, Product, Revision, OemRevision); for (i = 0; i < (sizeof(BrokenVesaBiosList) / sizeof(PCHAR)); i++) { - if (!strncmp(Product, BrokenVesaBiosList[i], sizeof(BrokenVesaBiosList[i]))) return FALSE; + if (!strncmp(Product, BrokenVesaBiosList[i], strlen(BrokenVesaBiosList[i]))) return FALSE; } /* For Brookdale-G (Intel), special hack used */ From 9db755b1435c276b0ed247130439f59a1c41ee23 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Sun, 26 Dec 2010 15:04:02 +0000 Subject: [PATCH 123/181] [VMX_SVGA] Convert a pointer to a WCHAR string to an array of WCHARs to fix sizeof calculation. CID 10404 svn path=/trunk/; revision=50148 --- .../video/miniport/vmx_svga/vmx_svga.c | 34 +++++++++---------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/reactos/drivers/video/miniport/vmx_svga/vmx_svga.c b/reactos/drivers/video/miniport/vmx_svga/vmx_svga.c index 9ed88c9a8ff..00fd72b522a 100644 --- a/reactos/drivers/video/miniport/vmx_svga/vmx_svga.c +++ b/reactos/drivers/video/miniport/vmx_svga/vmx_svga.c @@ -14,7 +14,7 @@ /* GLOBALS ********************************************************************/ PHW_DEVICE_EXTENSION VmxDeviceExtensionArray[SVGA_MAX_DISPLAYS]; -static PWCHAR AdapterString = L"VMware SVGA II"; +static WCHAR AdapterString[] = L"VMware SVGA II"; /* FUNCTIONS ******************************************************************/ @@ -64,17 +64,17 @@ NTAPI VmxIsMultiMon(IN PHW_DEVICE_EXTENSION DeviceExtension) { ULONG Capabilities; - + /* Get the caps */ Capabilities = DeviceExtension->Capabilities; - + /* Check for multi-mon support */ if ((Capabilities & SVGA_CAP_MULTIMON) && (Capabilities & SVGA_CAP_PITCHLOCK)) { /* Query the monitor count */ if (VmxReadUlong(DeviceExtension, SVGA_REG_NUM_DISPLAYS) > 1) return TRUE; } - + /* Either no support, or just one screen */ return FALSE; } @@ -90,10 +90,10 @@ VmxFindAdapter(IN PVOID HwDeviceExtension, VP_STATUS Status; PHW_DEVICE_EXTENSION DeviceExtension = HwDeviceExtension; DPRINT1("VMX searching for adapter\n"); - + /* Zero out the fields */ VideoPortZeroMemory(DeviceExtension, sizeof(HW_DEVICE_EXTENSION)); - + /* Validate the Config Info */ if (ConfigInfo->Length < sizeof(VIDEO_PORT_CONFIG_INFO)) { @@ -101,21 +101,21 @@ VmxFindAdapter(IN PVOID HwDeviceExtension, DPRINT1("Invalid configuration info\n"); return ERROR_INVALID_PARAMETER; } - + /* Initialize the device extension and find the adapter */ Status = VmxInitDevice(DeviceExtension); DPRINT1("Init status: %lx\n", Status); if (Status != NO_ERROR) return ERROR_DEV_NOT_EXIST; - + /* Save this adapter extension */ VmxDeviceExtensionArray[0] = DeviceExtension; - + /* Create the sync event */ VideoPortCreateEvent(DeviceExtension, NOTIFICATION_EVENT, NULL, &DeviceExtension->SyncEvent); - + /* Check for multi-monitor configuration */ if (VmxIsMultiMon(DeviceExtension)) { @@ -123,14 +123,14 @@ VmxFindAdapter(IN PVOID HwDeviceExtension, UNIMPLEMENTED; while (TRUE); } - + /* Zero the frame buffer */ - VideoPortZeroMemory((PVOID)DeviceExtension->FrameBuffer.LowPart, + VideoPortZeroMemory((PVOID)DeviceExtension->FrameBuffer.LowPart, DeviceExtension->VramSize.LowPart); - + /* Initialize the video modes */ VmxInitModes(DeviceExtension); - + /* Setup registry keys */ VideoPortSetRegistryParameters(DeviceExtension, L"HardwareInformation.ChipType", @@ -152,7 +152,7 @@ VmxFindAdapter(IN PVOID HwDeviceExtension, L"HardwareInformation.BiosString", AdapterString, sizeof(AdapterString)); - + /* No VDM support */ ConfigInfo->NumEmulatorAccessEntries = 0; ConfigInfo->EmulatorAccessEntries = 0; @@ -160,7 +160,7 @@ VmxFindAdapter(IN PVOID HwDeviceExtension, ConfigInfo->HardwareStateSize = 0; ConfigInfo->VdmPhysicalVideoMemoryAddress.QuadPart = 0; ConfigInfo->VdmPhysicalVideoMemoryLength = 0; - + /* Write that this is Windows XP or higher */ VmxWriteUlong(DeviceExtension, SVGA_REG_GUEST_ID, 0x5000 | 0x08); return NO_ERROR; @@ -252,7 +252,7 @@ DriverEntry(IN PVOID Context1, DPRINT1("VMX-SVGAII Loading...\n"); VideoPortZeroMemory(VmxDeviceExtensionArray, sizeof(VmxDeviceExtensionArray)); VideoPortZeroMemory(&InitData, sizeof(InitData)); - + /* Setup the initialization structure with VideoPort */ InitData.HwInitDataSize = sizeof(VIDEO_HW_INITIALIZATION_DATA); InitData.HwFindAdapter = VmxFindAdapter; From 07bf61809ee5396154d243d280d9bd750338241d Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Sun, 26 Dec 2010 15:23:03 +0000 Subject: [PATCH 124/181] =?UTF-8?q?[NTOSKRNL]=20Remove=20all=20#line=2015?= =?UTF-8?q?=20"ARM=C2=B3::BLA"=20Reasons:=20-=20It=20doesn't=20provide=20a?= =?UTF-8?q?ny=20benefits,=20its=20only=20purpose=20was=20to=20"look=20cool?= =?UTF-8?q?"=20-=20It=20never=20looked=20cool,=20instead=20a=20character?= =?UTF-8?q?=20mess=20appeared=20-=20It=20makes=20finding=20the=20related?= =?UTF-8?q?=20file=20harder,=20especially=20when=20the=20file=20is=20named?= =?UTF-8?q?=20differently=20then=20the=20description=20or=20when=20multipl?= =?UTF-8?q?e=20files=20have=20the=20same=20tag=20-=20It=20effectively=20br?= =?UTF-8?q?eaks=20Coverity=20scans?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit svn path=/trunk/; revision=50149 --- reactos/ntoskrnl/mm/ARM3/arm/init.c | 1 - reactos/ntoskrnl/mm/ARM3/contmem.c | 123 +++++++------ reactos/ntoskrnl/mm/ARM3/drvmgmt.c | 31 ++-- reactos/ntoskrnl/mm/ARM3/dynamic.c | 13 +- reactos/ntoskrnl/mm/ARM3/expool.c | 103 ++++++----- reactos/ntoskrnl/mm/ARM3/hypermap.c | 21 ++- reactos/ntoskrnl/mm/ARM3/i386/init.c | 145 ++++++++------- reactos/ntoskrnl/mm/ARM3/iosup.c | 51 +++--- reactos/ntoskrnl/mm/ARM3/largepag.c | 7 +- reactos/ntoskrnl/mm/ARM3/mdlsup.c | 239 +++++++++++++------------ reactos/ntoskrnl/mm/ARM3/mmdbg.c | 5 +- reactos/ntoskrnl/mm/ARM3/mminit.c | 253 +++++++++++++------------- reactos/ntoskrnl/mm/ARM3/mmsup.c | 3 +- reactos/ntoskrnl/mm/ARM3/ncache.c | 55 +++--- reactos/ntoskrnl/mm/ARM3/pagfault.c | 191 ++++++++++---------- reactos/ntoskrnl/mm/ARM3/pfnlist.c | 91 +++++----- reactos/ntoskrnl/mm/ARM3/pool.c | 257 +++++++++++++-------------- reactos/ntoskrnl/mm/ARM3/procsup.c | 195 ++++++++++---------- reactos/ntoskrnl/mm/ARM3/section.c | 157 ++++++++-------- reactos/ntoskrnl/mm/ARM3/sysldr.c | 231 ++++++++++++------------ reactos/ntoskrnl/mm/ARM3/syspte.c | 71 ++++---- reactos/ntoskrnl/mm/ARM3/vadnode.c | 39 ++-- reactos/ntoskrnl/mm/ARM3/virtual.c | 239 +++++++++++++------------ reactos/ntoskrnl/mm/ARM3/zeropage.c | 13 +- reactos/ntoskrnl/mm/arm/page.c | 3 +- 25 files changed, 1256 insertions(+), 1281 deletions(-) diff --git a/reactos/ntoskrnl/mm/ARM3/arm/init.c b/reactos/ntoskrnl/mm/ARM3/arm/init.c index 1e44b767d35..3f1d2c2c868 100644 --- a/reactos/ntoskrnl/mm/ARM3/arm/init.c +++ b/reactos/ntoskrnl/mm/ARM3/arm/init.c @@ -12,7 +12,6 @@ #define NDEBUG #include -#line 15 "ARM³::INIT" #define MODULE_INVOLVED_IN_ARM3 #include "../../ARM3/miarm.h" diff --git a/reactos/ntoskrnl/mm/ARM3/contmem.c b/reactos/ntoskrnl/mm/ARM3/contmem.c index 79eacda42a0..8fd906e9897 100644 --- a/reactos/ntoskrnl/mm/ARM3/contmem.c +++ b/reactos/ntoskrnl/mm/ARM3/contmem.c @@ -12,7 +12,6 @@ #define NDEBUG #include -#line 15 "ARM³::CONTMEM" #define MODULE_INVOLVED_IN_ARM3 #include "../ARM3/miarm.h" @@ -32,7 +31,7 @@ MiFindContiguousPages(IN PFN_NUMBER LowestPfn, KIRQL OldIrql; PAGED_CODE(); ASSERT(SizeInPages != 0); - + // // Convert the boundary PFN into an alignment mask // @@ -40,7 +39,7 @@ MiFindContiguousPages(IN PFN_NUMBER LowestPfn, /* Disable APCs */ KeEnterGuardedRegion(); - + // // Loop all the physical memory blocks // @@ -51,23 +50,23 @@ MiFindContiguousPages(IN PFN_NUMBER LowestPfn, // Page = MmPhysicalMemoryBlock->Run[i].BasePage; PageCount = MmPhysicalMemoryBlock->Run[i].PageCount; - + // // Check how far this memory block will go // LastPage = Page + PageCount; - + // // Trim it down to only the PFNs we're actually interested in // if ((LastPage - 1) > HighestPfn) LastPage = HighestPfn + 1; if (Page < LowestPfn) Page = LowestPfn; - + // // Skip this run if it's empty or fails to contain all the pages we need // if (!(PageCount) || ((Page + SizeInPages) > LastPage)) continue; - + // // Now scan all the relevant PFNs in this run // @@ -82,7 +81,7 @@ MiFindContiguousPages(IN PFN_NUMBER LowestPfn, Length = 0; continue; } - + // // If we haven't chosen a start PFN yet and the caller specified an // alignment, make sure the page matches the alignment restriction @@ -95,7 +94,7 @@ MiFindContiguousPages(IN PFN_NUMBER LowestPfn, // continue; } - + // // Increase the number of valid pages, and check if we have enough // @@ -106,7 +105,7 @@ MiFindContiguousPages(IN PFN_NUMBER LowestPfn, // Pfn1 -= (Length - 1); Page -= (Length - 1); - + // // Acquire the PFN lock // @@ -117,7 +116,7 @@ MiFindContiguousPages(IN PFN_NUMBER LowestPfn, // Things might've changed for us. Is the page still free? // if (MiIsPfnInUse(Pfn1)) break; - + // // So far so good. Is this the last confirmed valid page? // @@ -127,7 +126,7 @@ MiFindContiguousPages(IN PFN_NUMBER LowestPfn, // Sanity check that we didn't go out of bounds // ASSERT(i != MmPhysicalMemoryBlock->NumberOfRuns); - + // // Loop until all PFN entries have been processed // @@ -148,43 +147,43 @@ MiFindContiguousPages(IN PFN_NUMBER LowestPfn, Pfn1->u3.e1.PrototypePte = 0; Pfn1->u4.VerifierAllocation = 0; Pfn1->PteAddress = (PVOID)0xBAADF00D; - + // // Check if this is the last PFN, otherwise go on // if (Pfn1 == EndPfn) break; Pfn1--; } while (TRUE); - + // // Mark the first and last PFN so we can find them later // Pfn1->u3.e1.StartOfAllocation = 1; (Pfn1 + SizeInPages - 1)->u3.e1.EndOfAllocation = 1; - + // // Now it's safe to let go of the PFN lock // KeReleaseQueuedSpinLock(LockQueuePfnLock, OldIrql); - + // // Quick sanity check that the last PFN is consistent // EndPfn = Pfn1 + SizeInPages; ASSERT(EndPfn == MI_PFN_ELEMENT(Page + 1)); - + // // Compute the first page, and make sure it's consistent // Page = Page - SizeInPages + 1; ASSERT(Pfn1 == MI_PFN_ELEMENT(Page)); ASSERT(Page != 0); - + /* Enable APCs and return the page */ KeLeaveGuardedRegion(); - return Page; + return Page; } - + // // Keep going. The purpose of this loop is to reconfirm that // after acquiring the PFN lock these pages are still usable @@ -192,7 +191,7 @@ MiFindContiguousPages(IN PFN_NUMBER LowestPfn, Pfn1++; Page++; } while (TRUE); - + // // If we got here, something changed while we hadn't acquired // the PFN lock yet, so we'll have to restart @@ -202,11 +201,11 @@ MiFindContiguousPages(IN PFN_NUMBER LowestPfn, } } } while (++i != MmPhysicalMemoryBlock->NumberOfRuns); - + // // And if we get here, it means no suitable physical memory runs were found // - return 0; + return 0; } PVOID @@ -221,7 +220,7 @@ MiCheckForContiguousMemory(IN PVOID BaseAddress, { PMMPTE StartPte, EndPte; PFN_NUMBER PreviousPage = 0, Page, HighPage, BoundaryMask, Pages = 0; - + // // Okay, first of all check if the PFNs match our restrictions // @@ -229,13 +228,13 @@ MiCheckForContiguousMemory(IN PVOID BaseAddress, if (LowestPfn + SizeInPages <= LowestPfn) return NULL; if (LowestPfn + SizeInPages - 1 > HighestPfn) return NULL; if (BaseAddressPages < SizeInPages) return NULL; - + // // This is the last page we need to get to and the boundary requested // HighPage = HighestPfn + 1 - SizeInPages; BoundaryMask = ~(BoundaryPfn - 1); - + // // And here's the PTEs for this allocation. Let's go scan them. // @@ -248,7 +247,7 @@ MiCheckForContiguousMemory(IN PVOID BaseAddress, // ASSERT (StartPte->u.Hard.Valid == 1); Page = PFN_FROM_PTE(StartPte); - + // // Is this the beginning of our adventure? // @@ -271,7 +270,7 @@ MiCheckForContiguousMemory(IN PVOID BaseAddress, Pages++; } } - + // // Have we found all the pages we need by now? // Incidently, this means you only wanted one page @@ -297,7 +296,7 @@ MiCheckForContiguousMemory(IN PVOID BaseAddress, Pages = 0; continue; } - + // // Otherwise, we're still in the game. Do we have all our pages? // @@ -309,7 +308,7 @@ MiCheckForContiguousMemory(IN PVOID BaseAddress, return MiPteToAddress(StartPte - Pages + 1); } } - + // // Try with the next PTE, remember this PFN // @@ -317,7 +316,7 @@ MiCheckForContiguousMemory(IN PVOID BaseAddress, StartPte++; continue; } - + // // All good returns are within the loop... // @@ -349,14 +348,14 @@ MiFindContiguousMemory(IN PFN_NUMBER LowestPfn, SizeInPages, CacheType); if (!Page) return NULL; - + // // We'll just piggyback on the I/O memory mapper // PhysicalAddress.QuadPart = Page << PAGE_SHIFT; BaseAddress = MmMapIoSpace(PhysicalAddress, SizeInPages << PAGE_SHIFT, CacheType); ASSERT(BaseAddress); - + /* Loop the PFN entries */ Pfn1 = MiGetPfnEntry(Page); EndPfn = Pfn1 + SizeInPages; @@ -367,7 +366,7 @@ MiFindContiguousMemory(IN PFN_NUMBER LowestPfn, Pfn1->PteAddress = PointerPte; Pfn1->u4.PteFrame = PFN_FROM_PTE(MiAddressToPte(PointerPte++)); } while (++Pfn1 < EndPfn); - + /* Return the address */ return BaseAddress; } @@ -389,12 +388,12 @@ MiAllocateContiguousMemory(IN SIZE_T NumberOfBytes, // ASSERT(NumberOfBytes != 0); ASSERT(CacheType <= MmWriteCombined); - + // // Compute size requested // SizeInPages = BYTES_TO_PAGES(NumberOfBytes); - + // // Convert the cache attribute and check for cached requests // @@ -409,7 +408,7 @@ MiAllocateContiguousMemory(IN SIZE_T NumberOfBytes, NumberOfBytes, 'mCmM'); if (BaseAddress) - { + { // // Now make sure it's actually contiguous (if it came from expansion // it might not be). @@ -427,20 +426,20 @@ MiAllocateContiguousMemory(IN SIZE_T NumberOfBytes, // return BaseAddress; } - + // // No such luck // ExFreePool(BaseAddress); } } - + // // According to MSDN, the system won't try anything else if you're higher // than APC level. // if (KeGetCurrentIrql() > APC_LEVEL) return NULL; - + // // Otherwise, we'll go try to find some // @@ -460,7 +459,7 @@ MiFreeContiguousMemory(IN PVOID BaseAddress) PMMPFN Pfn1, StartPfn; PMMPTE PointerPte; PAGED_CODE(); - + // // First, check if the memory came from initial nonpaged pool, or expansion // @@ -476,15 +475,15 @@ MiFreeContiguousMemory(IN PVOID BaseAddress) ExFreePool(BaseAddress); return; } - + /* Get the PTE and frame number for the allocation*/ PointerPte = MiAddressToPte(BaseAddress); PageFrameIndex = PFN_FROM_PTE(PointerPte); - + // // Now get the PFN entry for this, and make sure it's the correct one // - Pfn1 = MiGetPfnEntry(PageFrameIndex); + Pfn1 = MiGetPfnEntry(PageFrameIndex); if ((!Pfn1) || (Pfn1->u3.e1.StartOfAllocation == 0)) { // @@ -496,13 +495,13 @@ MiFreeContiguousMemory(IN PVOID BaseAddress) 0, 0); } - + // // Now this PFN isn't the start of any allocation anymore, it's going out // StartPfn = Pfn1; Pfn1->u3.e1.StartOfAllocation = 0; - + /* Loop the PFNs until we find the one that marks the end of the allocation */ do { @@ -513,35 +512,35 @@ MiFreeContiguousMemory(IN PVOID BaseAddress) ASSERT(Pfn1->u3.e1.PageLocation == ActiveAndValid); ASSERT(Pfn1->u4.VerifierAllocation == 0); ASSERT(Pfn1->u3.e1.PrototypePte == 0); - + /* Set the special pending delete marker */ MI_SET_PFN_DELETED(Pfn1); - + /* Keep going for assertions */ PointerPte++; } while (Pfn1++->u3.e1.EndOfAllocation == 0); - + // // Found it, unmark it // Pfn1--; Pfn1->u3.e1.EndOfAllocation = 0; - + // // Now compute how many pages this represents // PageCount = (ULONG)(Pfn1 - StartPfn + 1); - + // // So we can know how much to unmap (recall we piggyback on I/O mappings) // MmUnmapIoSpace(BaseAddress, PageCount << PAGE_SHIFT); - + // // Lock the PFN database // OldIrql = KeAcquireQueuedSpinLock(LockQueuePfnLock); - + // // Loop all the pages // @@ -552,7 +551,7 @@ MiFreeContiguousMemory(IN PVOID BaseAddress) /* Decrement the share count and move on */ MiDecrementShareCount(Pfn1++, PageFrameIndex++); } while (PageFrameIndex < LastPage); - + // // Release the PFN lock // @@ -579,33 +578,33 @@ MmAllocateContiguousMemorySpecifyCache(IN SIZE_T NumberOfBytes, // ASSERT(NumberOfBytes != 0); ASSERT(CacheType <= MmWriteCombined); - + // // Convert the lowest address into a PFN // LowestPfn = (PFN_NUMBER)(LowestAcceptableAddress.QuadPart >> PAGE_SHIFT); if (BYTE_OFFSET(LowestAcceptableAddress.LowPart)) LowestPfn++; - + // // Convert and validate the boundary address into a PFN // if (BYTE_OFFSET(BoundaryAddressMultiple.LowPart)) return NULL; BoundaryPfn = (PFN_NUMBER)(BoundaryAddressMultiple.QuadPart >> PAGE_SHIFT); - + // // Convert the highest address into a PFN // HighestPfn = (PFN_NUMBER)(HighestAcceptableAddress.QuadPart >> PAGE_SHIFT); if (HighestPfn > MmHighestPhysicalPage) HighestPfn = MmHighestPhysicalPage; - + // // Validate the PFN bounds // if (LowestPfn > HighestPfn) return NULL; - + // // Let the contiguous memory allocator handle it - // + // return MiAllocateContiguousMemory(NumberOfBytes, LowestPfn, HighestPfn, @@ -633,10 +632,10 @@ MmAllocateContiguousMemory(IN SIZE_T NumberOfBytes, // HighestPfn = (PFN_NUMBER)(HighestAcceptableAddress.QuadPart >> PAGE_SHIFT); if (HighestPfn > MmHighestPhysicalPage) HighestPfn = MmHighestPhysicalPage; - + // // Let the contiguous memory allocator handle it - // + // return MiAllocateContiguousMemory(NumberOfBytes, 0, HighestPfn, 0, MmCached); } diff --git a/reactos/ntoskrnl/mm/ARM3/drvmgmt.c b/reactos/ntoskrnl/mm/ARM3/drvmgmt.c index 265a771eee2..aeb3ce44802 100644 --- a/reactos/ntoskrnl/mm/ARM3/drvmgmt.c +++ b/reactos/ntoskrnl/mm/ARM3/drvmgmt.c @@ -12,7 +12,6 @@ #define NDEBUG #include -#line 15 "ARM³::DRVMGMT" #define MODULE_INVOLVED_IN_ARM3 #include "../ARM3/miarm.h" @@ -91,18 +90,18 @@ MmAddVerifierThunks(IN PVOID ThunkBuffer, ULONG i; NTSTATUS Status = STATUS_SUCCESS; PAGED_CODE(); - + // // Make sure the driver verifier is initialized // if (!MiVerifierDriverAddedThunkListHead.Flink) return STATUS_NOT_SUPPORTED; - + // // Get the thunk pairs and count them // ThunkCount = ThunkBufferSize / sizeof(DRIVER_VERIFIER_THUNK_PAIRS); if (!ThunkCount) return STATUS_INVALID_PARAMETER_1; - + // // Now allocate our own thunk table // @@ -112,7 +111,7 @@ MmAddVerifierThunks(IN PVOID ThunkBuffer, sizeof(DRIVER_VERIFIER_THUNK_PAIRS), 'tVmM'); if (!DriverThunks) return STATUS_INSUFFICIENT_RESOURCES; - + // // Now copy the driver-fed part // @@ -120,7 +119,7 @@ MmAddVerifierThunks(IN PVOID ThunkBuffer, RtlCopyMemory(ThunkTable, ThunkBuffer, ThunkCount * sizeof(DRIVER_VERIFIER_THUNK_PAIRS)); - + // // Acquire the system load lock // @@ -130,7 +129,7 @@ MmAddVerifierThunks(IN PVOID ThunkBuffer, KernelMode, FALSE, NULL); - + // // Get the loader entry // @@ -143,13 +142,13 @@ MmAddVerifierThunks(IN PVOID ThunkBuffer, Status = STATUS_INVALID_PARAMETER_2; goto Cleanup; } - + // // Get driver base and end // ModuleBase = LdrEntry->DllBase; ModuleEnd = (PVOID)((ULONG_PTR)LdrEntry->DllBase + LdrEntry->SizeOfImage); - + // // Don't allow hooking the kernel or HAL // @@ -161,7 +160,7 @@ MmAddVerifierThunks(IN PVOID ThunkBuffer, Status = STATUS_INVALID_PARAMETER_2; goto Cleanup; } - + // // Loop all the thunks // @@ -180,7 +179,7 @@ MmAddVerifierThunks(IN PVOID ThunkBuffer, goto Cleanup; } } - + // // Otherwise, add this entry // @@ -190,14 +189,14 @@ MmAddVerifierThunks(IN PVOID ThunkBuffer, InsertTailList(&MiVerifierDriverAddedThunkListHead, &DriverThunks->ListEntry); DriverThunks = NULL; - + Cleanup: // // Release the lock // KeReleaseMutant(&MmSystemLoadLock, 1, FALSE, FALSE); KeLeaveCriticalRegion(); - + // // Free the table if we failed and return status // @@ -213,13 +212,13 @@ NTAPI MmIsDriverVerifying(IN PDRIVER_OBJECT DriverObject) { PLDR_DATA_TABLE_ENTRY LdrEntry; - + // // Get the loader entry // LdrEntry = (PLDR_DATA_TABLE_ENTRY)DriverObject->DriverSection; if (!LdrEntry) return FALSE; - + // // Check if we're verifying or not // @@ -244,7 +243,7 @@ MmIsVerifierEnabled(OUT PULONG VerifierFlags) *VerifierFlags = MmVerifierData.Level; return STATUS_SUCCESS; } - + // // Otherwise, we're disabled // diff --git a/reactos/ntoskrnl/mm/ARM3/dynamic.c b/reactos/ntoskrnl/mm/ARM3/dynamic.c index 3f7cf727e58..e2ff4b53010 100644 --- a/reactos/ntoskrnl/mm/ARM3/dynamic.c +++ b/reactos/ntoskrnl/mm/ARM3/dynamic.c @@ -12,7 +12,6 @@ #define NDEBUG #include -#line 15 "ARM³::DYNAMIC" #define MODULE_INVOLVED_IN_ARM3 #include "../ARM3/miarm.h" @@ -74,7 +73,7 @@ NTAPI MmGetPhysicalMemoryRanges(VOID) { ULONG Size, i; - PPHYSICAL_MEMORY_RANGE Entry, Buffer; + PPHYSICAL_MEMORY_RANGE Entry, Buffer; KIRQL OldIrql; ASSERT(KeGetCurrentIrql() == PASSIVE_LEVEL); @@ -82,7 +81,7 @@ MmGetPhysicalMemoryRanges(VOID) // Calculate how much memory we'll need // Size = sizeof(PHYSICAL_MEMORY_RANGE) * (MmPhysicalMemoryBlock->NumberOfRuns + 1); - + // // Allocate a copy // @@ -93,13 +92,13 @@ MmGetPhysicalMemoryRanges(VOID) // Lock the PFN database // OldIrql = KeAcquireQueuedSpinLock(LockQueuePfnLock); - + // // Make sure it hasn't changed before we had acquired the lock // - ASSERT(Size == (sizeof(PHYSICAL_MEMORY_RANGE) * + ASSERT(Size == (sizeof(PHYSICAL_MEMORY_RANGE) * (MmPhysicalMemoryBlock->NumberOfRuns + 1))); - + // // Now loop our block // @@ -112,7 +111,7 @@ MmGetPhysicalMemoryRanges(VOID) Entry->NumberOfBytes.QuadPart = MmPhysicalMemoryBlock->Run[i].PageCount << PAGE_SHIFT; Entry++; } - + // // Last entry is empty // diff --git a/reactos/ntoskrnl/mm/ARM3/expool.c b/reactos/ntoskrnl/mm/ARM3/expool.c index 120050e6aca..eb5bc01692f 100644 --- a/reactos/ntoskrnl/mm/ARM3/expool.c +++ b/reactos/ntoskrnl/mm/ARM3/expool.c @@ -12,7 +12,6 @@ #define NDEBUG #include -#line 15 "ARM³::EXPOOL" #define MODULE_INVOLVED_IN_ARM3 #include "../ARM3/miarm.h" @@ -53,14 +52,14 @@ PKGUARDED_MUTEX ExpPagedPoolMutex; */ PLIST_ENTRY NTAPI -ExpDecodePoolLink(IN PLIST_ENTRY Link) +ExpDecodePoolLink(IN PLIST_ENTRY Link) { return (PLIST_ENTRY)((ULONG_PTR)Link & ~1); } PLIST_ENTRY NTAPI -ExpEncodePoolLink(IN PLIST_ENTRY Link) +ExpEncodePoolLink(IN PLIST_ENTRY Link) { return (PLIST_ENTRY)((ULONG_PTR)Link | 1); } @@ -104,7 +103,7 @@ ExpRemovePoolEntryList(IN PLIST_ENTRY Entry) Flink->Blink = ExpEncodePoolLink(Blink); Blink->Flink = ExpEncodePoolLink(Flink); } - + PLIST_ENTRY NTAPI ExpRemovePoolHeadList(IN PLIST_ENTRY ListHead) @@ -170,7 +169,7 @@ ExpCheckPoolHeader(IN PPOOL_HEADER Entry) { /* Get it */ PreviousEntry = POOL_PREV_BLOCK(Entry); - + /* The two blocks must be on the same page! */ if (PAGE_ALIGN(Entry) != PAGE_ALIGN(PreviousEntry)) { @@ -251,31 +250,31 @@ ExpCheckPoolBlocks(IN PVOID Block) BOOLEAN FoundBlock = FALSE; SIZE_T Size = 0; PPOOL_HEADER Entry; - + /* Get the first entry for this page, make sure it really is the first */ Entry = PAGE_ALIGN(Block); ASSERT(Entry->PreviousSize == 0); - + /* Now scan each entry */ while (TRUE) { /* When we actually found our block, remember this */ if (Entry == Block) FoundBlock = TRUE; - + /* Now validate this block header */ ExpCheckPoolHeader(Entry); - + /* And go to the next one, keeping track of our size */ Size += Entry->BlockSize; Entry = POOL_NEXT_BLOCK(Entry); - + /* If we hit the last block, stop */ if (Size >= (PAGE_SIZE / POOL_BLOCK_SIZE)) break; - + /* If we hit the end of the page, stop */ if (PAGE_ALIGN(Entry) == Entry) break; } - + /* We must've found our block, and we must have hit the end of the page */ if ((PAGE_ALIGN(Entry) != Entry) || !(FoundBlock)) { @@ -304,7 +303,7 @@ ExInitializePoolDescriptor(IN PPOOL_DESCRIPTOR PoolDescriptor, PoolDescriptor->PoolIndex = PoolIndex; PoolDescriptor->Threshold = Threshold; PoolDescriptor->LockAddress = PoolLock; - + // // Initialize accounting data // @@ -313,18 +312,18 @@ ExInitializePoolDescriptor(IN PPOOL_DESCRIPTOR PoolDescriptor, PoolDescriptor->TotalPages = 0; PoolDescriptor->TotalBytes = 0; PoolDescriptor->TotalBigPages = 0; - + // // Nothing pending for now // PoolDescriptor->PendingFrees = NULL; PoolDescriptor->PendingFreeDepth = 0; - + // // Loop all the descriptor's allocation lists and initialize them // NextEntry = PoolDescriptor->ListHeads; - LastEntry = NextEntry + POOL_LISTS_PER_PAGE; + LastEntry = NextEntry + POOL_LISTS_PER_PAGE; while (NextEntry < LastEntry) { ExpInitializePoolListHead(NextEntry); @@ -339,7 +338,7 @@ InitializePool(IN POOL_TYPE PoolType, IN ULONG Threshold) { PPOOL_DESCRIPTOR Descriptor; - + // // Check what kind of pool this is // @@ -375,7 +374,7 @@ InitializePool(IN POOL_TYPE PoolType, -1, -1); } - + // // Setup the vector and guarded mutex for paged pool // @@ -461,14 +460,14 @@ ExAllocatePoolWithTag(IN POOL_TYPE PoolType, ASSERT(Tag != 0); ASSERT(Tag != ' GIB'); ASSERT(NumberOfBytes != 0); - + // // Get the pool type and its corresponding vector for this request // PoolType = PoolType & BASE_POOL_TYPE_MASK; PoolDesc = PoolVector[PoolType]; ASSERT(PoolDesc != NULL); - + // // Check if this is a big page allocation // @@ -479,13 +478,13 @@ ExAllocatePoolWithTag(IN POOL_TYPE PoolType, // return MiAllocatePoolPages(PoolType, NumberOfBytes); } - + // // Should never request 0 bytes from the pool, but since so many drivers do // it, we'll just assume they want 1 byte, based on NT's similar behavior // if (!NumberOfBytes) NumberOfBytes = 1; - + // // A pool allocation is defined by its data, a linked list to connect it to // the free list (if necessary), and a pool header to store accounting info. @@ -514,7 +513,7 @@ ExAllocatePoolWithTag(IN POOL_TYPE PoolType, // Acquire the pool lock now // OldIrql = ExLockPool(PoolDesc); - + // // And make sure the list still has entries // @@ -530,7 +529,7 @@ ExAllocatePoolWithTag(IN POOL_TYPE PoolType, ListHead++; continue; } - + // // Remove a free entry from the list // Note that due to the way we insert free blocks into multiple lists @@ -543,7 +542,7 @@ ExAllocatePoolWithTag(IN POOL_TYPE PoolType, ExpCheckPoolBlocks(Entry); ASSERT(Entry->BlockSize >= i); ASSERT(Entry->PoolType == 0); - + // // Check if this block is larger that what we need. The block could // not possibly be smaller, due to the reason explained above (and @@ -563,12 +562,12 @@ ExAllocatePoolWithTag(IN POOL_TYPE PoolType, // FragmentEntry = POOL_BLOCK(Entry, i); FragmentEntry->BlockSize = Entry->BlockSize - i; - + // // And make it point back to us // FragmentEntry->PreviousSize = i; - + // // Now get the block that follows the new fragment and check // if it's still on the same page as us (and not at the end) @@ -581,7 +580,7 @@ ExAllocatePoolWithTag(IN POOL_TYPE PoolType, // fragment block // NextEntry->PreviousSize = FragmentEntry->BlockSize; - } + } } else { @@ -590,13 +589,13 @@ ExAllocatePoolWithTag(IN POOL_TYPE PoolType, // so we'll make this entry the fragment instead // FragmentEntry = Entry; - + // // And then we'll remove from it the actual size required. // Now the entry is a leftover free fragment // Entry->BlockSize -= i; - + // // Now let's go to the next entry after the fragment (which // used to point to our original free entry) and make it @@ -607,7 +606,7 @@ ExAllocatePoolWithTag(IN POOL_TYPE PoolType, // Entry = POOL_NEXT_BLOCK(Entry); Entry->PreviousSize = FragmentEntry->BlockSize; - + // // And now let's go to the entry after that one and check if // it's still on the same page, and not at the end @@ -621,12 +620,12 @@ ExAllocatePoolWithTag(IN POOL_TYPE PoolType, NextEntry->PreviousSize = i; } } - + // // Now our (allocation) entry is the right size // Entry->BlockSize = i; - + // // And the next entry is now the free fragment which contains // the remaining difference between how big the original entry @@ -634,10 +633,10 @@ ExAllocatePoolWithTag(IN POOL_TYPE PoolType, // FragmentEntry->PoolType = 0; BlockSize = FragmentEntry->BlockSize; - + // - // Now check if enough free bytes remained for us to have a - // "full" entry, which contains enough bytes for a linked list + // Now check if enough free bytes remained for us to have a + // "full" entry, which contains enough bytes for a linked list // and thus can be used for allocations (up to 8 bytes...) // ExpCheckPoolLinks(&PoolDesc->ListHeads[BlockSize - 1]); @@ -651,7 +650,7 @@ ExAllocatePoolWithTag(IN POOL_TYPE PoolType, ExpCheckPoolLinks(POOL_FREE_BLOCK(FragmentEntry)); } } - + // // We have found an entry for this allocation, so set the pool type // and release the lock since we're done @@ -669,7 +668,7 @@ ExAllocatePoolWithTag(IN POOL_TYPE PoolType, return POOL_FREE_BLOCK(Entry); } } while (++ListHead != &PoolDesc->ListHeads[POOL_LISTS_PER_PAGE]); - + // // There were no free entries left, so we have to allocate a new fresh page // @@ -678,7 +677,7 @@ ExAllocatePoolWithTag(IN POOL_TYPE PoolType, Entry->Ulong1 = 0; Entry->BlockSize = i; Entry->PoolType = PoolType + 1; - + // // This page will have two entries -- one for the allocation (which we just // created above), and one for the remaining free bytes, which we're about @@ -690,7 +689,7 @@ ExAllocatePoolWithTag(IN POOL_TYPE PoolType, FragmentEntry->Ulong1 = 0; FragmentEntry->BlockSize = BlockSize; FragmentEntry->PreviousSize = i; - + // // Now check if enough free bytes remained for us to have a "full" entry, // which contains enough bytes for a linked list and thus can be used for @@ -710,7 +709,7 @@ ExAllocatePoolWithTag(IN POOL_TYPE PoolType, ExpInsertPoolTailList(&PoolDesc->ListHeads[BlockSize - 1], POOL_FREE_BLOCK(FragmentEntry)); ExpCheckPoolLinks(POOL_FREE_BLOCK(FragmentEntry)); - + // // Release the pool lock // @@ -763,14 +762,14 @@ ExFreePoolWithTag(IN PVOID P, MiFreePoolPages(P); return; } - + // // Get the entry for this pool allocation // The pointer math here may look wrong or confusing, but it is quite right // Entry = P; Entry--; - + // // Get the size of the entry, and it's pool type, then load the descriptor // for this pool type @@ -804,7 +803,7 @@ ExFreePoolWithTag(IN PVOID P, // The next block is free, so we'll do a combine // Combined = TRUE; - + // // Make sure there's actual data in the block -- anything smaller // than this means we only have the header, so there's no linked list @@ -821,7 +820,7 @@ ExFreePoolWithTag(IN PVOID P, ExpCheckPoolLinks(ExpDecodePoolLink((POOL_FREE_BLOCK(NextEntry))->Flink)); ExpCheckPoolLinks(ExpDecodePoolLink((POOL_FREE_BLOCK(NextEntry))->Blink)); } - + // // Our entry is now combined with the next entry // @@ -844,7 +843,7 @@ ExFreePoolWithTag(IN PVOID P, // It is, so we can do a combine // Combined = TRUE; - + // // Make sure there's actual data in the block -- anything smaller // than this means we only have the header so there's no linked list @@ -861,20 +860,20 @@ ExFreePoolWithTag(IN PVOID P, ExpCheckPoolLinks(ExpDecodePoolLink((POOL_FREE_BLOCK(NextEntry))->Flink)); ExpCheckPoolLinks(ExpDecodePoolLink((POOL_FREE_BLOCK(NextEntry))->Blink)); } - + // // Combine our original block (which might've already been combined // with the next block), into the previous block // NextEntry->BlockSize = NextEntry->BlockSize + Entry->BlockSize; - + // // And now we'll work with the previous block instead // Entry = NextEntry; } } - + // // By now, it may have been possible for our combined blocks to actually // have made up a full page (if there were only 2-3 allocations on the @@ -897,7 +896,7 @@ ExFreePoolWithTag(IN PVOID P, Entry->PoolType = 0; BlockSize = Entry->BlockSize; ASSERT(BlockSize != 1); - + // // Check if we actually did combine it with anyone // @@ -908,14 +907,14 @@ ExFreePoolWithTag(IN PVOID P, // the one after the original, depending if we combined with the previous) // NextEntry = POOL_NEXT_BLOCK(Entry); - + // // As long as the next block isn't on a page boundary, have it point // back to us // if (PAGE_ALIGN(NextEntry) != NextEntry) NextEntry->PreviousSize = BlockSize; } - + // // Insert this new free block, and release the pool lock // diff --git a/reactos/ntoskrnl/mm/ARM3/hypermap.c b/reactos/ntoskrnl/mm/ARM3/hypermap.c index cb5cb2f1059..d619c2b41b9 100644 --- a/reactos/ntoskrnl/mm/ARM3/hypermap.c +++ b/reactos/ntoskrnl/mm/ARM3/hypermap.c @@ -12,7 +12,6 @@ #define NDEBUG #include -#line 15 "ARM³::HYPERMAP" #define MODULE_INVOLVED_IN_ARM3 #include "../ARM3/miarm.h" @@ -125,7 +124,7 @@ MiMapPagesToZeroInHyperSpace(IN PMMPFN Pfn1, ASSERT(KeGetCurrentIrql() == PASSIVE_LEVEL); ASSERT(NumberOfPages != 0); ASSERT(NumberOfPages <= (MI_ZERO_PTES - 1)); - + // // Pick the first zeroing PTE // @@ -144,39 +143,39 @@ MiMapPagesToZeroInHyperSpace(IN PMMPFN Pfn1, PointerPte->u.Hard.PageFrameNumber = Offset; KeFlushProcessTb(); } - + // // Prepare the next PTE // PointerPte->u.Hard.PageFrameNumber = Offset - NumberOfPages; - + /* Choose the correct PTE to use, and which template */ PointerPte += (Offset + 1); TempPte = ValidKernelPte; MI_MAKE_LOCAL_PAGE(&TempPte); // Hyperspace is local! - + /* Make sure the list isn't empty and loop it */ ASSERT(Pfn1 != (PVOID)LIST_HEAD); while (Pfn1 != (PVOID)LIST_HEAD) { /* Get the page index for this PFN */ PageFrameIndex = MiGetPfnEntryIndex(Pfn1); - + // // Write the PFN // TempPte.u.Hard.PageFrameNumber = PageFrameIndex; - + // // Set the correct PTE to write to, and set its new value // PointerPte--; MI_WRITE_VALID_PTE(PointerPte, TempPte); - + /* Move to the next PFN */ Pfn1 = (PMMPFN)Pfn1->u1.Flink; } - + // // Return the address // @@ -189,14 +188,14 @@ MiUnmapPagesInZeroSpace(IN PVOID VirtualAddress, IN PFN_NUMBER NumberOfPages) { PMMPTE PointerPte; - + // // Sanity checks // ASSERT(KeGetCurrentIrql() == PASSIVE_LEVEL); ASSERT (NumberOfPages != 0); ASSERT (NumberOfPages <= (MI_ZERO_PTES - 1)); - + // // Get the first PTE for the mapped zero VA // diff --git a/reactos/ntoskrnl/mm/ARM3/i386/init.c b/reactos/ntoskrnl/mm/ARM3/i386/init.c index 70707a6e98a..116271c6618 100644 --- a/reactos/ntoskrnl/mm/ARM3/i386/init.c +++ b/reactos/ntoskrnl/mm/ARM3/i386/init.c @@ -12,7 +12,6 @@ #define NDEBUG #include -#line 15 "ARM³::INIT:X86" #define MODULE_INVOLVED_IN_ARM3 #include "../../ARM3/miarm.h" @@ -28,7 +27,7 @@ MMPTE DemandZeroPte = {.u.Long = (MM_READWRITE << MM_PTE_SOFTWARE_PROTECTION_BI /* Template PTE for prototype page */ MMPTE PrototypePte = {.u.Long = (MM_READWRITE << MM_PTE_SOFTWARE_PROTECTION_BITS) | PTE_PROTOTYPE | (MI_PTE_LOOKUP_NEEDED << PAGE_SHIFT)}; - + /* PRIVATE FUNCTIONS **********************************************************/ VOID @@ -37,7 +36,7 @@ INIT_FUNCTION MiComputeNonPagedPoolVa(IN ULONG FreePages) { IN PFN_NUMBER PoolPages; - + /* Check if this is a machine with less than 256MB of RAM, and no overide */ if ((MmNumberOfPhysicalPages <= MI_MIN_PAGES_FOR_NONPAGED_POOL_TUNING) && !(MmSizeOfNonPagedPoolInBytes)) @@ -45,17 +44,17 @@ MiComputeNonPagedPoolVa(IN ULONG FreePages) /* Force the non paged pool to be 2MB so we can reduce RAM usage */ MmSizeOfNonPagedPoolInBytes = 2 * _1MB; } - + /* Hyperspace ends here */ MmHyperSpaceEnd = (PVOID)((ULONG_PTR)MmSystemCacheWorkingSetList - 1); - + /* Check if the user gave a ridicuously large nonpaged pool RAM size */ if ((MmSizeOfNonPagedPoolInBytes >> PAGE_SHIFT) > (FreePages * 7 / 8)) { /* More than 7/8ths of RAM was dedicated to nonpaged pool, ignore! */ MmSizeOfNonPagedPoolInBytes = 0; } - + /* Check if no registry setting was set, or if the setting was too low */ if (MmSizeOfNonPagedPoolInBytes < MmMinimumNonPagedPoolSize) { @@ -63,30 +62,30 @@ MiComputeNonPagedPoolVa(IN ULONG FreePages) MmSizeOfNonPagedPoolInBytes = MmMinimumNonPagedPoolSize; MmSizeOfNonPagedPoolInBytes += (FreePages - 1024) / 256 * MmMinAdditionNonPagedPoolPerMb; } - + /* Check if the registy setting or our dynamic calculation was too high */ if (MmSizeOfNonPagedPoolInBytes > MI_MAX_INIT_NONPAGED_POOL_SIZE) { /* Set it to the maximum */ MmSizeOfNonPagedPoolInBytes = MI_MAX_INIT_NONPAGED_POOL_SIZE; } - + /* Check if a percentage cap was set through the registry */ if (MmMaximumNonPagedPoolPercent) UNIMPLEMENTED; - + /* Page-align the nonpaged pool size */ MmSizeOfNonPagedPoolInBytes &= ~(PAGE_SIZE - 1); - + /* Now, check if there was a registry size for the maximum size */ if (!MmMaximumNonPagedPoolInBytes) { /* Start with the default (1MB) */ MmMaximumNonPagedPoolInBytes = MmDefaultMaximumNonPagedPool; - + /* Add space for PFN database */ MmMaximumNonPagedPoolInBytes += (ULONG) PAGE_ALIGN((MmHighestPhysicalPage + 1) * sizeof(MMPFN)); - + /* Check if the machine has more than 512MB of free RAM */ if (FreePages >= 0x1F000) { @@ -106,7 +105,7 @@ MiComputeNonPagedPoolVa(IN ULONG FreePages) MmMaxAdditionNonPagedPoolPerMb; } } - + /* Make sure there's at least 16 pages + the PFN available for expansion */ PoolPages = MmSizeOfNonPagedPoolInBytes + (PAGE_SIZE * 16) + ((ULONG)PAGE_ALIGN(MmHighestPhysicalPage + 1) * sizeof(MMPFN)); @@ -115,17 +114,17 @@ MiComputeNonPagedPoolVa(IN ULONG FreePages) /* The maximum should be at least high enough to cover all the above */ MmMaximumNonPagedPoolInBytes = PoolPages; } - + /* Systems with 2GB of kernel address space get double the size */ PoolPages = MI_MAX_NONPAGED_POOL_SIZE * 2; - + /* On the other hand, make sure that PFN + nonpaged pool doesn't get too big */ if (MmMaximumNonPagedPoolInBytes > PoolPages) { /* Trim it down to the maximum architectural limit (256MB) */ MmMaximumNonPagedPoolInBytes = PoolPages; } - + /* Check if this is a system with > 128MB of non paged pool */ if (MmMaximumNonPagedPoolInBytes > MI_MAX_NONPAGED_POOL_SIZE) { @@ -134,7 +133,7 @@ MiComputeNonPagedPoolVa(IN ULONG FreePages) MI_MAX_NONPAGED_POOL_SIZE)) { /* FIXME: Should check if the initial pool can be expanded */ - + /* Assume no expansion possible, check ift he maximum is too large */ if (MmMaximumNonPagedPoolInBytes > (MmSizeOfNonPagedPoolInBytes + MI_MAX_NONPAGED_POOL_SIZE)) @@ -142,7 +141,7 @@ MiComputeNonPagedPoolVa(IN ULONG FreePages) /* Set it to the initial value plus the boost */ MmMaximumNonPagedPoolInBytes = MmSizeOfNonPagedPoolInBytes + MI_MAX_NONPAGED_POOL_SIZE; - } + } } } } @@ -162,7 +161,7 @@ MiInitMachineDependent(IN PLOADER_PARAMETER_BLOCK LoaderBlock) KIRQL OldIrql; PMMPFN Pfn1; ULONG Flags; - + /* Check for kernel stack size that's too big */ if (MmLargeStackSize > (KERNEL_LARGE_STACK_SIZE / _1KB)) { @@ -173,18 +172,18 @@ MiInitMachineDependent(IN PLOADER_PARAMETER_BLOCK LoaderBlock) { /* Take the registry setting, and convert it into bytes */ MmLargeStackSize *= _1KB; - + /* Now align it to a page boundary */ MmLargeStackSize = PAGE_ROUND_UP(MmLargeStackSize); - + /* Sanity checks */ ASSERT(MmLargeStackSize <= KERNEL_LARGE_STACK_SIZE); ASSERT((MmLargeStackSize & (PAGE_SIZE - 1)) == 0); - + /* Make sure it's not too low */ if (MmLargeStackSize < KERNEL_STACK_SIZE) MmLargeStackSize = KERNEL_STACK_SIZE; } - + /* Check for global bit */ #if 0 if (KeFeatureBits & KF_GLOBAL_PAGE) @@ -197,21 +196,21 @@ MiInitMachineDependent(IN PLOADER_PARAMETER_BLOCK LoaderBlock) /* Now templates are ready */ TempPte = ValidKernelPte; TempPde = ValidKernelPde; - + // // Set CR3 for the system process // PointerPte = MiAddressToPde(PDE_BASE); PageFrameIndex = PFN_FROM_PTE(PointerPte) << PAGE_SHIFT; PsGetCurrentProcess()->Pcb.DirectoryTableBase[0] = PageFrameIndex; - + // // Blow away user-mode // StartPde = MiAddressToPde(0); EndPde = MiAddressToPde(KSEG0_BASE); RtlZeroMemory(StartPde, (EndPde - StartPde) * sizeof(MMPTE)); - + // // Loop the memory descriptors // @@ -224,7 +223,7 @@ MiInitMachineDependent(IN PLOADER_PARAMETER_BLOCK LoaderBlock) MdBlock = CONTAINING_RECORD(NextEntry, MEMORY_ALLOCATION_DESCRIPTOR, ListEntry); - + // // Skip invisible memory // @@ -243,7 +242,7 @@ MiInitMachineDependent(IN PLOADER_PARAMETER_BLOCK LoaderBlock) // MmNumberOfPhysicalPages += MdBlock->PageCount; } - + // // Check if this is the new lowest page // @@ -254,7 +253,7 @@ MiInitMachineDependent(IN PLOADER_PARAMETER_BLOCK LoaderBlock) // MmLowestPhysicalPage = MdBlock->BasePage; } - + // // Check if this is the new highest page // @@ -266,7 +265,7 @@ MiInitMachineDependent(IN PLOADER_PARAMETER_BLOCK LoaderBlock) // MmHighestPhysicalPage = PageFrameIndex - 1; } - + // // Check if this is free memory // @@ -285,32 +284,32 @@ MiInitMachineDependent(IN PLOADER_PARAMETER_BLOCK LoaderBlock) // MxFreeDescriptor = MdBlock; } - + // // More free pages // FreePages += MdBlock->PageCount; } } - + // // Keep going // NextEntry = MdBlock->ListEntry.Flink; } - + // // Save original values of the free descriptor, since it'll be // altered by early allocations // MxOldFreeDescriptor = *MxFreeDescriptor; - + /* Compute non paged pool limits and size */ MiComputeNonPagedPoolVa(FreePages); - + /* Compute color information (L2 cache-separated paging lists) */ MiComputeColorInformation(); - + // // Calculate the number of bytes for the PFN database // then add the color tables and convert to pages @@ -318,7 +317,7 @@ MiInitMachineDependent(IN PLOADER_PARAMETER_BLOCK LoaderBlock) MxPfnAllocation = (MmHighestPhysicalPage + 1) * sizeof(MMPFN); MxPfnAllocation += (MmSecondaryColors * sizeof(MMCOLOR_TABLES) * 2); MxPfnAllocation >>= PAGE_SHIFT; - + // // We have to add one to the count here, because in the process of // shifting down to the page size, we actually ended up getting the @@ -328,7 +327,7 @@ MiInitMachineDependent(IN PLOADER_PARAMETER_BLOCK LoaderBlock) // 0x60000 bytes. // MxPfnAllocation++; - + // // Now calculate the nonpaged pool expansion VA region // @@ -339,7 +338,7 @@ MiInitMachineDependent(IN PLOADER_PARAMETER_BLOCK LoaderBlock) NonPagedPoolExpansionVa = MmNonPagedPoolStart; DPRINT("NP Pool has been tuned to: %d bytes and %d bytes\n", MmSizeOfNonPagedPoolInBytes, MmMaximumNonPagedPoolInBytes); - + // // Now calculate the nonpaged system VA region, which includes the // nonpaged pool expansion (above) and the system PTEs. Note that it is @@ -349,7 +348,7 @@ MiInitMachineDependent(IN PLOADER_PARAMETER_BLOCK LoaderBlock) (MmNumberOfSystemPtes + 1) * PAGE_SIZE); MmNonPagedSystemStart = (PVOID)((ULONG_PTR)MmNonPagedSystemStart & ~(PDE_MAPPED_VA - 1)); - + // // Don't let it go below the minimum // @@ -359,7 +358,7 @@ MiInitMachineDependent(IN PLOADER_PARAMETER_BLOCK LoaderBlock) // This is a hard-coded limit in the Windows NT address space // MmNonPagedSystemStart = (PVOID)0xEB000000; - + // // Reduce the amount of system PTEs to reach this point // @@ -369,7 +368,7 @@ MiInitMachineDependent(IN PLOADER_PARAMETER_BLOCK LoaderBlock) MmNumberOfSystemPtes--; ASSERT(MmNumberOfSystemPtes > 1000); } - + // // Check if we are in a situation where the size of the paged pool // is so large that it overflows into nonpaged pool @@ -382,7 +381,7 @@ MiInitMachineDependent(IN PLOADER_PARAMETER_BLOCK LoaderBlock) // DPRINT1("Paged pool is too big!\n"); } - + // // Normally, the PFN database should start after the loader images. // This is already the case in ReactOS, but for now we want to co-exist @@ -391,7 +390,7 @@ MiInitMachineDependent(IN PLOADER_PARAMETER_BLOCK LoaderBlock) // MmPfnDatabase = (PVOID)0xB0000000; ASSERT(((ULONG_PTR)MmPfnDatabase & (PDE_MAPPED_VA - 1)) == 0); - + // // Non paged pool comes after the PFN database // @@ -424,13 +423,13 @@ MiInitMachineDependent(IN PLOADER_PARAMETER_BLOCK LoaderBlock) // TempPde.u.Hard.PageFrameNumber = MxGetNextPage(1); MI_WRITE_VALID_PTE(StartPde, TempPde); - + // // Zero out the page table // PointerPte = MiPteToAddress(StartPde); RtlZeroMemory(PointerPte, PAGE_SIZE); - + // // Next // @@ -456,7 +455,7 @@ MiInitMachineDependent(IN PLOADER_PARAMETER_BLOCK LoaderBlock) // PointerPte = MiPteToAddress(StartPde); RtlZeroMemory(PointerPte, PAGE_SIZE); - + // // Next // @@ -482,23 +481,23 @@ MiInitMachineDependent(IN PLOADER_PARAMETER_BLOCK LoaderBlock) TempPte.u.Hard.PageFrameNumber = PageFrameIndex++; MI_WRITE_VALID_PTE(PointerPte++, TempPte); } - + // // Sanity check: make sure we have properly defined the system PTE space // ASSERT(MiAddressToPte(MmNonPagedSystemStart) < MiAddressToPte(MmNonPagedPoolExpansionStart)); - + /* Now go ahead and initialize the nonpaged pool */ MiInitializeNonPagedPool(); MiInitializeNonPagedPoolThresholds(); /* Map the PFN database pages */ MiMapPfnDatabase(LoaderBlock); - + /* Initialize the color tables */ MiInitializeColorTables(); - + /* Build the PFN Database */ MiInitializePfnDatabase(LoaderBlock); MmInitializeBalancer(MmAvailablePages, 0); @@ -507,12 +506,12 @@ MiInitMachineDependent(IN PLOADER_PARAMETER_BLOCK LoaderBlock) // Reset the descriptor back so we can create the correct memory blocks // *MxFreeDescriptor = MxOldFreeDescriptor; - + // // Initialize the nonpaged pool // InitializePool(NonPagedPool, 0); - + // // We PDE-aligned the nonpaged system start VA, so haul some extra PTEs! // @@ -522,18 +521,18 @@ MiInitMachineDependent(IN PLOADER_PARAMETER_BLOCK LoaderBlock) MmNumberOfSystemPtes--; DPRINT("Final System PTE count: %d (%d bytes)\n", MmNumberOfSystemPtes, MmNumberOfSystemPtes * PAGE_SIZE); - + // // Create the system PTE space // MiInitializeSystemPtes(PointerPte, MmNumberOfSystemPtes, SystemPteSpace); - + /* Get the PDE For hyperspace */ StartPde = MiAddressToPde(HYPER_SPACE); - + /* Lock PFN database */ OldIrql = KeAcquireQueuedSpinLock(LockQueuePfnLock); - + /* Allocate a page for hyperspace and create it */ MI_SET_USAGE(MI_USAGE_PAGE_TABLE); MI_SET_PROCESS2("Kernel"); @@ -541,26 +540,26 @@ MiInitMachineDependent(IN PLOADER_PARAMETER_BLOCK LoaderBlock) TempPde.u.Hard.PageFrameNumber = PageFrameIndex; TempPde.u.Hard.Global = FALSE; // Hyperspace is local! MI_WRITE_VALID_PTE(StartPde, TempPde); - + /* Flush the TLB */ KeFlushCurrentTb(); - + /* Release the lock */ KeReleaseQueuedSpinLock(LockQueuePfnLock, OldIrql); - + // // Zero out the page table now // PointerPte = MiAddressToPte(HYPER_SPACE); RtlZeroMemory(PointerPte, PAGE_SIZE); - + // // Setup the mapping PTEs // MmFirstReservedMappingPte = MiAddressToPte(MI_MAPPING_RANGE_START); MmLastReservedMappingPte = MiAddressToPte(MI_MAPPING_RANGE_END); MmFirstReservedMappingPte->u.Hard.PageFrameNumber = MI_HYPERSPACE_PTES; - + /* Set the working set address */ MmWorkingSetList = (PVOID)MI_WORKING_SET_LIST; @@ -570,39 +569,39 @@ MiInitMachineDependent(IN PLOADER_PARAMETER_BLOCK LoaderBlock) MiFirstReservedZeroingPte = MiReserveSystemPtes(MI_ZERO_PTES, SystemPteSpace); RtlZeroMemory(MiFirstReservedZeroingPte, MI_ZERO_PTES * sizeof(MMPTE)); - + // // Set the counter to maximum to boot with // MiFirstReservedZeroingPte->u.Hard.PageFrameNumber = MI_ZERO_PTES - 1; - + /* Lock PFN database */ OldIrql = KeAcquireQueuedSpinLock(LockQueuePfnLock); - + /* Reset the ref/share count so that MmInitializeProcessAddressSpace works */ Pfn1 = MiGetPfnEntry(PFN_FROM_PTE(MiAddressToPde(PDE_BASE))); Pfn1->u2.ShareCount = 0; Pfn1->u3.e2.ReferenceCount = 0; - + /* Get a page for the working set list */ MI_SET_USAGE(MI_USAGE_PAGE_TABLE); MI_SET_PROCESS2("Kernel WS List"); PageFrameIndex = MiRemoveAnyPage(0); TempPte.u.Hard.PageFrameNumber = PageFrameIndex; - + /* Map the working set list */ PointerPte = MiAddressToPte(MmWorkingSetList); MI_WRITE_VALID_PTE(PointerPte, TempPte); - + /* Zero it out, and save the frame index */ RtlZeroMemory(MiPteToAddress(PointerPte), PAGE_SIZE); PsGetCurrentProcess()->WorkingSetPage = PageFrameIndex; - + /* Check for Pentium LOCK errata */ if (KiI386PentiumLockErrataPresent) { /* Mark the 1st IDT page as Write-Through to prevent a lockup - on a F00F instruction. + on a F00F instruction. See http://www.rcollins.org/Errata/Dec97/F00FBug.html */ PointerPte = MiAddressToPte(KeGetPcr()->IDT); PointerPte->u.Hard.WriteThrough = 1; @@ -614,7 +613,7 @@ MiInitMachineDependent(IN PLOADER_PARAMETER_BLOCK LoaderBlock) /* Initialize the bogus address space */ Flags = 0; MmInitializeProcessAddressSpace(PsGetCurrentProcess(), NULL, NULL, &Flags, NULL); - + /* Make sure the color lists are valid */ ASSERT(MmFreePagesByColor[0] < (PMMCOLOR_TABLES)PTE_BASE); StartPde = MiAddressToPde(MmFreePagesByColor[0]); @@ -639,11 +638,11 @@ MiInitMachineDependent(IN PLOADER_PARAMETER_BLOCK LoaderBlock) Pfn1->u3.e1.PageLocation = ActiveAndValid; Pfn1->u3.e1.CacheAttribute = MiCached; } - + /* Keep going */ PointerPte++; } - + /* All done */ return STATUS_SUCCESS; } diff --git a/reactos/ntoskrnl/mm/ARM3/iosup.c b/reactos/ntoskrnl/mm/ARM3/iosup.c index 2d65d1fbcd4..f70269feec5 100644 --- a/reactos/ntoskrnl/mm/ARM3/iosup.c +++ b/reactos/ntoskrnl/mm/ARM3/iosup.c @@ -12,7 +12,6 @@ #define NDEBUG #include -#line 15 "ARM³::IOSUP" #define MODULE_INVOLVED_IN_ARM3 #include "../ARM3/miarm.h" @@ -49,7 +48,7 @@ MmMapIoSpace(IN PHYSICAL_ADDRESS PhysicalAddress, IN SIZE_T NumberOfBytes, IN MEMORY_CACHING_TYPE CacheType) { - + PFN_NUMBER Pfn, PageCount; PMMPTE PointerPte; PVOID BaseAddress; @@ -78,13 +77,13 @@ MmMapIoSpace(IN PHYSICAL_ADDRESS PhysicalAddress, // CacheType &= 0xFF; if (CacheType >= MmMaximumCacheType) return NULL; - + // // Calculate page count // PageCount = ADDRESS_AND_SIZE_TO_SPAN_PAGES(PhysicalAddress.LowPart, NumberOfBytes); - + // // Compute the PFN and check if it's a known I/O mapping // Also translate the cache attribute @@ -93,14 +92,14 @@ MmMapIoSpace(IN PHYSICAL_ADDRESS PhysicalAddress, Pfn1 = MiGetPfnEntry(Pfn); IsIoMapping = (Pfn1 == NULL) ? TRUE : FALSE; CacheAttribute = MiPlatformCacheAttributes[IsIoMapping][CacheType]; - + // // Now allocate system PTEs for the mapping, and get the VA // PointerPte = MiReserveSystemPtes(PageCount, SystemPteSpace); if (!PointerPte) return NULL; BaseAddress = MiPteToAddress(PointerPte); - + // // Check if this is uncached // @@ -112,13 +111,13 @@ MmMapIoSpace(IN PHYSICAL_ADDRESS PhysicalAddress, KeFlushEntireTb(TRUE, TRUE); KeInvalidateAllCaches(); } - + // // Now compute the VA offset // BaseAddress = (PVOID)((ULONG_PTR)BaseAddress + BYTE_OFFSET(PhysicalAddress.LowPart)); - + // // Get the template and configure caching // @@ -126,38 +125,38 @@ MmMapIoSpace(IN PHYSICAL_ADDRESS PhysicalAddress, switch (CacheAttribute) { case MiNonCached: - + // // Disable the cache // MI_PAGE_DISABLE_CACHE(&TempPte); MI_PAGE_WRITE_THROUGH(&TempPte); break; - + case MiCached: - + // // Leave defaults // break; - + case MiWriteCombined: - + // // We don't support write combining yet // ASSERT(FALSE); break; - + default: - + // // Should never happen // ASSERT(FALSE); break; } - + // // Sanity check and re-flush // @@ -165,7 +164,7 @@ MmMapIoSpace(IN PHYSICAL_ADDRESS PhysicalAddress, ASSERT((Pfn1 == MiGetPfnEntry(Pfn)) || (Pfn1 == NULL)); KeFlushEntireTb(TRUE, TRUE); KeInvalidateAllCaches(); - + // // Do the mapping // @@ -177,7 +176,7 @@ MmMapIoSpace(IN PHYSICAL_ADDRESS PhysicalAddress, TempPte.u.Hard.PageFrameNumber = Pfn++; MI_WRITE_VALID_PTE(PointerPte++, TempPte); } while (--PageCount); - + // // We're done! // @@ -191,26 +190,26 @@ VOID NTAPI MmUnmapIoSpace(IN PVOID BaseAddress, IN SIZE_T NumberOfBytes) -{ +{ PFN_NUMBER PageCount, Pfn; PMMPTE PointerPte; - + // // Sanity check // ASSERT(NumberOfBytes != 0); - + // // Get the page count // PageCount = ADDRESS_AND_SIZE_TO_SPAN_PAGES(BaseAddress, NumberOfBytes); - + // // Get the PTE and PFN // PointerPte = MiAddressToPte(BaseAddress); Pfn = PFN_FROM_PTE(PointerPte); - + // // Is this an I/O mapping? // @@ -220,13 +219,13 @@ MmUnmapIoSpace(IN PVOID BaseAddress, // Destroy the PTE // RtlZeroMemory(PointerPte, PageCount * sizeof(MMPTE)); - + // // Blow the TLB // KeFlushEntireTb(TRUE, TRUE); } - + // // Release the PTEs // @@ -243,7 +242,7 @@ MmMapVideoDisplay(IN PHYSICAL_ADDRESS PhysicalAddress, IN MEMORY_CACHING_TYPE CacheType) { PAGED_CODE(); - + // // Call the real function // diff --git a/reactos/ntoskrnl/mm/ARM3/largepag.c b/reactos/ntoskrnl/mm/ARM3/largepag.c index 601542b4005..b53f15a9b8d 100644 --- a/reactos/ntoskrnl/mm/ARM3/largepag.c +++ b/reactos/ntoskrnl/mm/ARM3/largepag.c @@ -12,7 +12,6 @@ #define NDEBUG #include -#line 15 "ARM³::LARGEPAGE" #define MODULE_INVOLVED_IN_ARM3 #include "../ARM3/miarm.h" @@ -46,7 +45,7 @@ MiInitializeLargePageSupport(VOID) /* Initialize the process tracking list, and insert the system process */ InitializeListHead(&MmProcessList); InsertTailList(&MmProcessList, &PsGetCurrentProcess()->MmProcessLinks); -#endif +#endif } VOID @@ -89,7 +88,7 @@ MiInitializeDriverLargePageList(VOID) p++; continue; } - + /* A star means everything */ if (*p == L'*') { @@ -97,7 +96,7 @@ MiInitializeDriverLargePageList(VOID) MiLargePageAllDrivers = TRUE; break; } - + DPRINT1("Large page drivers not supported\n"); ASSERT(FALSE); } diff --git a/reactos/ntoskrnl/mm/ARM3/mdlsup.c b/reactos/ntoskrnl/mm/ARM3/mdlsup.c index f956bb7725d..a5fdd592228 100644 --- a/reactos/ntoskrnl/mm/ARM3/mdlsup.c +++ b/reactos/ntoskrnl/mm/ARM3/mdlsup.c @@ -12,12 +12,11 @@ #define NDEBUG #include -#line 15 "ARM³::MDLSUP" #define MODULE_INVOLVED_IN_ARM3 #include "../ARM3/miarm.h" /* GLOBALS ********************************************************************/ - + BOOLEAN MmTrackPtes; BOOLEAN MmTrackLockedPages; SIZE_T MmSystemLockPagesCount; @@ -34,7 +33,7 @@ MmCreateMdl(IN PMDL Mdl, IN SIZE_T Length) { SIZE_T Size; - + // // Check if we don't have an MDL built // @@ -47,7 +46,7 @@ MmCreateMdl(IN PMDL Mdl, Mdl = ExAllocatePoolWithTag(NonPagedPool, Size, TAG_MDL); if (!Mdl) return NULL; } - + // // Initialize it // @@ -81,7 +80,7 @@ MmBuildMdlForNonPagedPool(IN PMDL Mdl) PFN_NUMBER Pfn, PageCount; PVOID Base; PMMPTE PointerPte; - + // // Sanity checks // @@ -89,19 +88,19 @@ MmBuildMdlForNonPagedPool(IN PMDL Mdl) ASSERT((Mdl->MdlFlags & (MDL_PAGES_LOCKED | MDL_MAPPED_TO_SYSTEM_VA | MDL_SOURCE_IS_NONPAGED_POOL | - MDL_PARTIAL)) == 0); - + MDL_PARTIAL)) == 0); + // // We know the MDL isn't associated to a process now // Mdl->Process = NULL; - + // // Get page and VA information // MdlPages = (PPFN_NUMBER)(Mdl + 1); Base = Mdl->StartVa; - + // // Set the system address and now get the page count // @@ -110,7 +109,7 @@ MmBuildMdlForNonPagedPool(IN PMDL Mdl) Mdl->ByteCount); ASSERT(PageCount != 0); EndPage = MdlPages + PageCount; - + // // Loop the PTEs // @@ -123,12 +122,12 @@ MmBuildMdlForNonPagedPool(IN PMDL Mdl) Pfn = PFN_FROM_PTE(PointerPte++); *MdlPages++ = Pfn; } while (MdlPages < EndPage); - + // // Set the nonpaged pool flag // Mdl->MdlFlags |= MDL_SOURCE_IS_NONPAGED_POOL; - + // // Check if this is an I/O mapping // @@ -169,7 +168,7 @@ MmAllocatePagesForMdlEx(IN PHYSICAL_ADDRESS LowAddress, IN ULONG Flags) { MI_PFN_CACHE_ATTRIBUTE CacheAttribute; - + // // Check for invalid cache type // @@ -187,7 +186,7 @@ MmAllocatePagesForMdlEx(IN PHYSICAL_ADDRESS LowAddress, // CacheAttribute = MiPlatformCacheAttributes[FALSE][CacheType]; } - + // // Only these flags are allowed // @@ -198,7 +197,7 @@ MmAllocatePagesForMdlEx(IN PHYSICAL_ADDRESS LowAddress, // return NULL; } - + // // Call the internal routine // @@ -223,14 +222,14 @@ MmFreePagesFromMdl(IN PMDL Mdl) PMMPFN Pfn1; KIRQL OldIrql; DPRINT("Freeing MDL: %p\n", Mdl); - + // // Sanity checks // ASSERT(KeGetCurrentIrql() <= APC_LEVEL); ASSERT((Mdl->MdlFlags & MDL_IO_SPACE) == 0); ASSERT(((ULONG_PTR)Mdl->StartVa & (PAGE_SIZE - 1)) == 0); - + // // Get address and page information // @@ -260,19 +259,19 @@ MmFreePagesFromMdl(IN PMDL Mdl) ASSERT(Pfn1); ASSERT(Pfn1->u2.ShareCount == 1); ASSERT(MI_IS_PFN_DELETED(Pfn1) == TRUE); - if (Pfn1->u4.PteFrame != 0x1FFEDCB) + if (Pfn1->u4.PteFrame != 0x1FFEDCB) { /* Corrupted PFN entry or invalid free */ KeBugCheckEx(MEMORY_MANAGEMENT, 0x1236, (ULONG_PTR)Mdl, (ULONG_PTR)Pages, *Pages); } - + // // Clear it // Pfn1->u3.e1.StartOfAllocation = 0; Pfn1->u3.e1.EndOfAllocation = 0; Pfn1->u2.ShareCount = 0; - + // // Dereference it // @@ -287,7 +286,7 @@ MmFreePagesFromMdl(IN PMDL Mdl) /* We'll be nuking the whole page */ MiDecrementReferenceCount(Pfn1, *Pages); } - + // // Clear this page and move on // @@ -324,17 +323,17 @@ MmMapLockedPagesSpecifyCache(IN PMDL Mdl, MI_PFN_CACHE_ATTRIBUTE CacheAttribute; PMMPTE PointerPte; MMPTE TempPte; - + // // Sanity check // ASSERT(Mdl->ByteCount != 0); - + // // Get the base // Base = (PVOID)((ULONG_PTR)Mdl->StartVa + Mdl->ByteOffset); - + // // Handle kernel case first // @@ -346,7 +345,7 @@ MmMapLockedPagesSpecifyCache(IN PMDL Mdl, MdlPages = (PPFN_NUMBER)(Mdl + 1); PageCount = ADDRESS_AND_SIZE_TO_SPAN_PAGES(Base, Mdl->ByteCount); LastPage = MdlPages + PageCount; - + // // Sanity checks // @@ -354,13 +353,13 @@ MmMapLockedPagesSpecifyCache(IN PMDL Mdl, MDL_SOURCE_IS_NONPAGED_POOL | MDL_PARTIAL_HAS_BEEN_MAPPED)) == 0); ASSERT((Mdl->MdlFlags & (MDL_PAGES_LOCKED | MDL_PARTIAL)) != 0); - + // // Get the correct cache type // IsIoMapping = (Mdl->MdlFlags & MDL_IO_SPACE) != 0; CacheAttribute = MiPlatformCacheAttributes[IsIoMapping][CacheType]; - + // // Reserve the PTEs // @@ -371,23 +370,23 @@ MmMapLockedPagesSpecifyCache(IN PMDL Mdl, // If it can fail, return NULL // if (Mdl->MdlFlags & MDL_MAPPING_CAN_FAIL) return NULL; - + // // Should we bugcheck? // if (!BugCheckOnFailure) return NULL; - + // // Yes, crash the system // KeBugCheckEx(NO_MORE_SYSTEM_PTES, 0, PageCount, 0, 0); } - + // // Get the mapped address // Base = (PVOID)((ULONG_PTR)MiPteToAddress(PointerPte) + Mdl->ByteOffset); - + // // Get the template // @@ -395,30 +394,30 @@ MmMapLockedPagesSpecifyCache(IN PMDL Mdl, switch (CacheAttribute) { case MiNonCached: - + // // Disable caching // MI_PAGE_DISABLE_CACHE(&TempPte); MI_PAGE_WRITE_THROUGH(&TempPte); break; - + case MiWriteCombined: - + // // Enable write combining // MI_PAGE_DISABLE_CACHE(&TempPte); MI_PAGE_WRITE_COMBINED(&TempPte); break; - + default: // // Nothing to do // break; } - + // // Loop all PTEs // @@ -428,21 +427,21 @@ MmMapLockedPagesSpecifyCache(IN PMDL Mdl, // We're done here // if (*MdlPages == LIST_HEAD) break; - + // // Write the PTE // TempPte.u.Hard.PageFrameNumber = *MdlPages; MI_WRITE_VALID_PTE(PointerPte++, TempPte); } while (++MdlPages < LastPage); - + // // Mark it as mapped // ASSERT((Mdl->MdlFlags & MDL_MAPPED_TO_SYSTEM_VA) == 0); Mdl->MappedSystemVa = Base; Mdl->MdlFlags |= MDL_MAPPED_TO_SYSTEM_VA; - + // // Check if it was partial // @@ -453,13 +452,13 @@ MmMapLockedPagesSpecifyCache(IN PMDL Mdl, // Mdl->MdlFlags |= MDL_PARTIAL_HAS_BEEN_MAPPED; } - + // // Return the mapped address // return Base; } - + UNIMPLEMENTED; return NULL; } @@ -495,12 +494,12 @@ MmUnmapLockedPages(IN PVOID BaseAddress, PFN_NUMBER PageCount; PPFN_NUMBER MdlPages; PMMPTE PointerPte; - + // // Sanity check // ASSERT(Mdl->ByteCount != 0); - + // // Check if this is a kernel request // @@ -511,14 +510,14 @@ MmUnmapLockedPages(IN PVOID BaseAddress, // Base = (PVOID)((ULONG_PTR)Mdl->StartVa + Mdl->ByteOffset); PageCount = ADDRESS_AND_SIZE_TO_SPAN_PAGES(Base, Mdl->ByteCount); - + // // Sanity checks // ASSERT((Mdl->MdlFlags & MDL_PARENT_MAPPED_SYSTEM_VA) == 0); ASSERT(PageCount != 0); ASSERT(Mdl->MdlFlags & MDL_MAPPED_TO_SYSTEM_VA); - + // // Get the PTE // @@ -530,7 +529,7 @@ MmUnmapLockedPages(IN PVOID BaseAddress, ASSERT(PointerPte >= MmSystemPtesStart[SystemPteSpace]); ASSERT(PointerPte <= MmSystemPtesEnd[SystemPteSpace]); ASSERT(PointerPte->u.Hard.Valid == 1); - + // // Check if the caller wants us to free advanced pages // @@ -541,7 +540,7 @@ MmUnmapLockedPages(IN PVOID BaseAddress, // MdlPages = (PPFN_NUMBER)(Mdl + 1); MdlPages += PageCount; - + // // Do the math // @@ -549,21 +548,21 @@ MmUnmapLockedPages(IN PVOID BaseAddress, PointerPte -= *MdlPages; ASSERT(PointerPte >= MmSystemPtesStart[SystemPteSpace]); ASSERT(PointerPte <= MmSystemPtesEnd[SystemPteSpace]); - + // // Get the new base address // BaseAddress = (PVOID)((ULONG_PTR)BaseAddress - ((*MdlPages) << PAGE_SHIFT)); } - + // // Remove flags // Mdl->MdlFlags &= ~(MDL_MAPPED_TO_SYSTEM_VA | MDL_PARTIAL_HAS_BEEN_MAPPED | MDL_FREE_EXTRA_PTES); - + // // Release the system PTEs // @@ -598,7 +597,7 @@ MmProbeAndLockPages(IN PMDL Mdl, USHORT OldRefCount, RefCount; PMMPFN Pfn1; DPRINT("Probing MDL: %p\n", Mdl); - + // // Sanity checks // @@ -610,13 +609,13 @@ MmProbeAndLockPages(IN PMDL Mdl, MDL_SOURCE_IS_NONPAGED_POOL | MDL_PARTIAL | MDL_IO_SPACE)) == 0); - + // // Get page and base information // MdlPages = (PPFN_NUMBER)(Mdl + 1); Base = (PVOID)Mdl->StartVa; - + // // Get the addresses and how many pages we span (and need to lock) // @@ -624,7 +623,7 @@ MmProbeAndLockPages(IN PMDL Mdl, LastAddress = (PVOID)((ULONG_PTR)Address + Mdl->ByteCount); LockPages = ADDRESS_AND_SIZE_TO_SPAN_PAGES(Address, Mdl->ByteCount); ASSERT(LockPages != 0); - + /* Block invalid access */ if ((AccessMode != KernelMode) && ((LastAddress > (PVOID)MM_USER_PROBE_ADDRESS) || (Address >= LastAddress))) @@ -633,7 +632,7 @@ MmProbeAndLockPages(IN PMDL Mdl, *MdlPages = LIST_HEAD; ExRaiseStatus(STATUS_ACCESS_VIOLATION); } - + // // Get the process // @@ -651,16 +650,16 @@ MmProbeAndLockPages(IN PMDL Mdl, // CurrentProcess = NULL; } - + // // Save the number of pages we'll have to lock, and the start address // TotalPages = LockPages; StartAddress = Address; - + /* Large pages not supported */ ASSERT(!MI_IS_PHYSICAL_ADDRESS(Address)); - + // // Now probe them // @@ -676,12 +675,12 @@ MmProbeAndLockPages(IN PMDL Mdl, // Assume failure // *MdlPages = LIST_HEAD; - + // // Read // *(volatile CHAR*)Address; - + // // Check if this is write access (only probe for user-mode) // @@ -693,19 +692,19 @@ MmProbeAndLockPages(IN PMDL Mdl, // ProbeForWriteChar(Address); } - + // // Next address... // Address = PAGE_ALIGN((ULONG_PTR)Address + PAGE_SIZE); - + // // Next page... // LockPages--; MdlPages++; } while (Address < LastAddress); - + // // Reset back to the original page // @@ -720,7 +719,7 @@ MmProbeAndLockPages(IN PMDL Mdl, ProbeStatus = _SEH2_GetExceptionCode(); } _SEH2_END; - + // // So how did that go? // @@ -733,7 +732,7 @@ MmProbeAndLockPages(IN PMDL Mdl, Mdl->Process = NULL; ExRaiseStatus(ProbeStatus); } - + // // Get the PTE and PDE // @@ -743,12 +742,12 @@ MmProbeAndLockPages(IN PMDL Mdl, DPRINT1("PAE/x64 Not Implemented\n"); ASSERT(FALSE); #endif - + // // Sanity check // ASSERT(MdlPages == (PPFN_NUMBER)(Mdl + 1)); - + // // Check what kind of operation this is // @@ -766,12 +765,12 @@ MmProbeAndLockPages(IN PMDL Mdl, // Mdl->MdlFlags &= ~(MDL_WRITE_OPERATION); } - + // // Mark the MDL as locked *now* // Mdl->MdlFlags |= MDL_PAGES_LOCKED; - + // // Check if this came from kernel mode // @@ -782,12 +781,12 @@ MmProbeAndLockPages(IN PMDL Mdl, // ASSERT(CurrentProcess == NULL); Mdl->Process = NULL; - + // // In kernel mode, we don't need to check for write access // Operation = IoReadAccess; - + // // Use the PFN lock // @@ -801,29 +800,29 @@ MmProbeAndLockPages(IN PMDL Mdl, // ASSERT(TotalPages != 0); ASSERT(CurrentProcess == PsGetCurrentProcess()); - + // // Track locked pages // InterlockedExchangeAddSizeT(&CurrentProcess->NumberOfLockedPages, TotalPages); - + // // Save the process // Mdl->Process = CurrentProcess; - + /* Lock the process working set */ MiLockProcessWorkingSet(CurrentProcess, PsGetCurrentThread()); UsePfnLock = FALSE; OldIrql = MM_NOIRQL; } - + // // Get the last PTE // LastPte = MiAddressToPte((PVOID)((ULONG_PTR)LastAddress - 1)); - + // // Loop the pages // @@ -855,7 +854,7 @@ MmProbeAndLockPages(IN PMDL Mdl, /* Release process working set */ MiUnlockProcessWorkingSet(CurrentProcess, PsGetCurrentThread()); } - + // // Access the page // @@ -869,7 +868,7 @@ MmProbeAndLockPages(IN PMDL Mdl, DPRINT1("Access fault failed\n"); goto Cleanup; } - + // // Waht lock should we use? // @@ -886,7 +885,7 @@ MmProbeAndLockPages(IN PMDL Mdl, MiLockProcessWorkingSet(CurrentProcess, PsGetCurrentThread()); } } - + // // Check if this was a write or modify // @@ -923,7 +922,7 @@ MmProbeAndLockPages(IN PMDL Mdl, /* Release process working set */ MiUnlockProcessWorkingSet(CurrentProcess, PsGetCurrentThread()); } - + // // Access the page // @@ -936,7 +935,7 @@ MmProbeAndLockPages(IN PMDL Mdl, DPRINT1("Access fault failed\n"); goto Cleanup; } - + // // Re-acquire the lock // @@ -952,14 +951,14 @@ MmProbeAndLockPages(IN PMDL Mdl, /* Lock the process working set */ MiLockProcessWorkingSet(CurrentProcess, PsGetCurrentThread()); } - + // // Start over // continue; } } - + // // Fail, since we won't allow this // @@ -967,7 +966,7 @@ MmProbeAndLockPages(IN PMDL Mdl, goto CleanupWithLock; } } - + // // Grab the PFN // @@ -977,10 +976,10 @@ MmProbeAndLockPages(IN PMDL Mdl, { /* Either this is for kernel-mode, or the working set is held */ ASSERT((CurrentProcess == NULL) || (UsePfnLock == FALSE)); - + /* No Physical VADs supported yet */ if (CurrentProcess) ASSERT(CurrentProcess->PhysicalVadRoot == NULL); - + /* This address should already exist and be fully valid */ ASSERT(Pfn1->u3.e2.ReferenceCount != 0); if (MI_IS_ROS_PFN(Pfn1)) @@ -992,7 +991,7 @@ MmProbeAndLockPages(IN PMDL Mdl, { /* On ARM3 pages, we should see a valid share count */ ASSERT((Pfn1->u2.ShareCount != 0) && (Pfn1->u3.e1.PageLocation == ActiveAndValid)); - + /* We don't support mapping a prototype page yet */ ASSERT((Pfn1->u3.e1.PrototypePte == 0) && (Pfn1->OriginalPte.u.Soft.Prototype == 0)); } @@ -1014,7 +1013,7 @@ MmProbeAndLockPages(IN PMDL Mdl, OldRefCount); ASSERT(RefCount != 0); } while (OldRefCount != RefCount); - + /* Was this the first lock attempt? */ if (OldRefCount != 1) { @@ -1029,17 +1028,17 @@ MmProbeAndLockPages(IN PMDL Mdl, // Mdl->MdlFlags |= MDL_IO_SPACE; } - + // // Write the page and move on // *MdlPages++ = PageFrameIndex; PointerPte++; - + /* Check if we're on a PDE boundary */ if (!((ULONG_PTR)PointerPte & (PD_SIZE - 1))) PointerPde++; } while (PointerPte <= LastPte); - + // // What kind of lock where we using? // @@ -1055,19 +1054,19 @@ MmProbeAndLockPages(IN PMDL Mdl, /* Release process working set */ MiUnlockProcessWorkingSet(CurrentProcess, PsGetCurrentThread()); } - + // // Sanity check // ASSERT((Mdl->MdlFlags & MDL_DESCRIBES_AWE) == 0); return; - + CleanupWithLock: // // This is the failure path // ASSERT(!NT_SUCCESS(Status)); - + // // What kind of lock where we using? // @@ -1089,7 +1088,7 @@ Cleanup: // ASSERT(Mdl->MdlFlags & MDL_PAGES_LOCKED); MmUnlockPages(Mdl); - + // // Raise the error // @@ -1111,7 +1110,7 @@ MmUnlockPages(IN PMDL Mdl) USHORT RefCount, OldRefCount; PMMPFN Pfn1; DPRINT("Unlocking MDL: %p\n", Mdl); - + // // Sanity checks // @@ -1119,13 +1118,13 @@ MmUnlockPages(IN PMDL Mdl) ASSERT((Mdl->MdlFlags & MDL_SOURCE_IS_NONPAGED_POOL) == 0); ASSERT((Mdl->MdlFlags & MDL_PARTIAL) == 0); ASSERT(Mdl->ByteCount != 0); - + // // Get the process associated and capture the flags which are volatile // Process = Mdl->Process; Flags = Mdl->MdlFlags; - + // // Automagically undo any calls to MmGetSystemAddressForMdl's for this MDL // @@ -1136,7 +1135,7 @@ MmUnlockPages(IN PMDL Mdl) // MmUnmapLockedPages(Mdl->MappedSystemVa, Mdl); } - + // // Get the page count // @@ -1144,22 +1143,22 @@ MmUnlockPages(IN PMDL Mdl) Base = (PVOID)((ULONG_PTR)Mdl->StartVa + Mdl->ByteOffset); PageCount = ADDRESS_AND_SIZE_TO_SPAN_PAGES(Base, Mdl->ByteCount); ASSERT(PageCount != 0); - + // // We don't support AWE // - if (Flags & MDL_DESCRIBES_AWE) ASSERT(FALSE); - + if (Flags & MDL_DESCRIBES_AWE) ASSERT(FALSE); + // // Check if the buffer is mapped I/O space // if (Flags & MDL_IO_SPACE) - { + { // // Acquire PFN lock // OldIrql = KeAcquireQueuedSpinLock(LockQueuePfnLock); - + // // Loop every page // @@ -1170,7 +1169,7 @@ MmUnlockPages(IN PMDL Mdl) // Last page, break out // if (*MdlPages == LIST_HEAD) break; - + // // Check if this page is in the PFN database // @@ -1188,14 +1187,14 @@ MmUnlockPages(IN PMDL Mdl) ASSERT(Pfn1->u3.e2.ReferenceCount == 1); ASSERT(Pfn1->u3.e1.PageLocation != ActiveAndValid); ASSERT(Pfn1->u2.ShareCount == 0); - + /* Not supported yet */ ASSERT(((Pfn1->u3.e1.PrototypePte == 0) && (Pfn1->OriginalPte.u.Soft.Prototype == 0))); /* One less page */ InterlockedExchangeAddSizeT(&MmSystemLockPagesCount, -1); - + /* Do the last dereference, we're done here */ MiDecrementReferenceCount(Pfn1, *MdlPages); } @@ -1236,12 +1235,12 @@ MmUnlockPages(IN PMDL Mdl) } } } while (++MdlPages < LastPage); - + // // Release the lock // KeReleaseQueuedSpinLock(LockQueuePfnLock, OldIrql); - + // // Check if we have a process // @@ -1254,7 +1253,7 @@ MmUnlockPages(IN PMDL Mdl) InterlockedExchangeAddSizeT(&Process->NumberOfLockedPages, -PageCount); } - + // // We're done // @@ -1262,7 +1261,7 @@ MmUnlockPages(IN PMDL Mdl) Mdl->MdlFlags &= ~MDL_PAGES_LOCKED; return; } - + // // Check if we have a process // @@ -1275,7 +1274,7 @@ MmUnlockPages(IN PMDL Mdl) InterlockedExchangeAddSizeT(&Process->NumberOfLockedPages, -PageCount); } - + // // Loop every page // @@ -1298,24 +1297,24 @@ MmUnlockPages(IN PMDL Mdl) Mdl->MdlFlags &= ~MDL_PAGES_LOCKED; return; } - + // // Otherwise, stop here // LastPage = MdlPages; break; } - + /* Save the PFN entry instead for the secondary loop */ *MdlPages = (PFN_NUMBER)MiGetPfnEntry(*MdlPages); ASSERT((*MdlPages) != 0); } while (++MdlPages < LastPage); - + // // Reset pointer // MdlPages = (PPFN_NUMBER)(Mdl + 1); - + // // Now grab the PFN lock for the actual unlock and dereference // @@ -1334,14 +1333,14 @@ MmUnlockPages(IN PMDL Mdl) ASSERT(Pfn1->u3.e2.ReferenceCount == 1); ASSERT(Pfn1->u3.e1.PageLocation != ActiveAndValid); ASSERT(Pfn1->u2.ShareCount == 0); - + /* Not supported yet */ ASSERT(((Pfn1->u3.e1.PrototypePte == 0) && (Pfn1->OriginalPte.u.Soft.Prototype == 0))); /* One less page */ InterlockedExchangeAddSizeT(&MmSystemLockPagesCount, -1); - + /* Do the last dereference, we're done here */ MiDecrementReferenceCount(Pfn1, MiGetPfnEntryIndex(Pfn1)); } @@ -1381,12 +1380,12 @@ MmUnlockPages(IN PMDL Mdl) } } } while (++MdlPages < LastPage); - + // // Release the lock // KeReleaseQueuedSpinLock(LockQueuePfnLock, OldIrql); - + // // We're done // diff --git a/reactos/ntoskrnl/mm/ARM3/mmdbg.c b/reactos/ntoskrnl/mm/ARM3/mmdbg.c index 5d761791940..ae476a78ab2 100644 --- a/reactos/ntoskrnl/mm/ARM3/mmdbg.c +++ b/reactos/ntoskrnl/mm/ARM3/mmdbg.c @@ -12,7 +12,6 @@ #define NDEBUG #include -#line 16 "ARM³::DEBUGSUP" #define MODULE_INVOLVED_IN_ARM3 #include "../ARM3/miarm.h" @@ -47,7 +46,7 @@ MiDbgTranslatePhysicalAddress(IN ULONG64 PhysicalAddress, PVOID MappingBaseAddress; // - // Check if we are called too early + // Check if we are called too early // if (MmDebugPte == NULL) { @@ -133,7 +132,7 @@ MiDbgUnTranslatePhysicalAddress(VOID) // ASSERT(MmIsAddressValid(MappingBaseAddress)); - // + // // Clear the mapping PTE and invalidate its TLB entry // MmDebugPte->u.Long = 0; diff --git a/reactos/ntoskrnl/mm/ARM3/mminit.c b/reactos/ntoskrnl/mm/ARM3/mminit.c index b977a65152a..9b3450af124 100644 --- a/reactos/ntoskrnl/mm/ARM3/mminit.c +++ b/reactos/ntoskrnl/mm/ARM3/mminit.c @@ -12,7 +12,6 @@ #define NDEBUG #include -#line 15 "ARM³::INIT" #define MODULE_INVOLVED_IN_ARM3 #include "miarm.h" @@ -38,7 +37,7 @@ PFN_NUMBER MmMaximumNonPagedPoolInPages; // SIZE_T MmMinimumNonPagedPoolSize = 256 * 1024; ULONG MmMinAdditionNonPagedPoolPerMb = 32 * 1024; -SIZE_T MmDefaultMaximumNonPagedPool = 1024 * 1024; +SIZE_T MmDefaultMaximumNonPagedPool = 1024 * 1024; ULONG MmMaxAdditionNonPagedPoolPerMb = 400 * 1024; // @@ -58,7 +57,7 @@ ULONG MmMaxAdditionNonPagedPoolPerMb = 400 * 1024; // Right now we call this the "ARM³ Nonpaged Pool" and it begins somewhere after // the PFN database (which starts at 0xB0000000). // -// The expansion nonpaged pool, on the other hand, can grow much bigger (400MB +// The expansion nonpaged pool, on the other hand, can grow much bigger (400MB // for a 1GB system). On ARM³ however, it is currently capped at 128MB. // // The address where the initial nonpaged pool starts is aptly named @@ -78,7 +77,7 @@ ULONG MmMaxAdditionNonPagedPoolPerMb = 400 * 1024; // a System PTE, it is always valid, until the System PTE is torn down. // // System PTEs are actually composed of two "spaces", the system space proper, -// and the nonpaged pool expansion space. The latter, as we've already seen, +// and the nonpaged pool expansion space. The latter, as we've already seen, // begins at MmNonPagedPoolExpansionStart. Based on the number of System PTEs // that the system will support, the remaining address space below this address // is used to hold the system space PTEs. This address, in turn, is held in the @@ -116,7 +115,7 @@ PFN_NUMBER MmSizeOfPagedPoolInPages = MI_MIN_INIT_PAGED_POOLSIZE / PAGE_SIZE; // drivers, followed by a 4MB area containing the session's working set. This is // then followed by a 20MB mapped view area and finally by the session's paged // pool, by default 16MB. -// +// // On a normal system, this results in session space occupying the region from // 0xBD000000 to 0xC0000000 // @@ -307,7 +306,7 @@ PFN_NUMBER MiHighNonPagedPoolThreshold; */ PFN_NUMBER MmMinimumFreePages = 26; -/* +/* * This number indicates how many pages we consider to be a low limit of having * "plenty" of free memory. * @@ -369,7 +368,7 @@ INIT_FUNCTION MxGetNextPage(IN PFN_NUMBER PageCount) { PFN_NUMBER Pfn; - + /* Make sure we have enough pages */ if (PageCount > MxFreeDescriptor->PageCount) { @@ -380,7 +379,7 @@ MxGetNextPage(IN PFN_NUMBER PageCount) MxOldFreeDescriptor.PageCount, PageCount); } - + /* Use our lowest usable free pages */ Pfn = MxFreeDescriptor->BasePage; MxFreeDescriptor->BasePage += PageCount; @@ -394,18 +393,18 @@ INIT_FUNCTION MiComputeColorInformation(VOID) { ULONG L2Associativity; - + /* Check if no setting was provided already */ if (!MmSecondaryColors) { /* Get L2 cache information */ L2Associativity = KeGetPcr()->SecondLevelCacheAssociativity; - + /* The number of colors is the number of cache bytes by set/way */ MmSecondaryColors = KeGetPcr()->SecondLevelCacheSize; if (L2Associativity) MmSecondaryColors /= L2Associativity; } - + /* Now convert cache bytes into pages */ MmSecondaryColors >>= PAGE_SHIFT; if (!MmSecondaryColors) @@ -421,14 +420,14 @@ MiComputeColorInformation(VOID) /* Set the maximum */ MmSecondaryColors = MI_MAX_SECONDARY_COLORS; } - + /* Make sure there aren't too little colors */ if (MmSecondaryColors < MI_MIN_SECONDARY_COLORS) { /* Set the default */ MmSecondaryColors = MI_SECONDARY_COLORS; } - + /* Finally make sure the colors are a power of two */ if (MmSecondaryColors & (MmSecondaryColors - 1)) { @@ -436,10 +435,10 @@ MiComputeColorInformation(VOID) MmSecondaryColors = MI_SECONDARY_COLORS; } } - + /* Compute the mask and store it */ MmSecondaryColorMask = MmSecondaryColors - 1; - KeGetCurrentPrcb()->SecondaryColorMask = MmSecondaryColorMask; + KeGetCurrentPrcb()->SecondaryColorMask = MmSecondaryColorMask; } VOID @@ -450,10 +449,10 @@ MiInitializeColorTables(VOID) ULONG i; PMMPTE PointerPte, LastPte; MMPTE TempPte = ValidKernelPte; - + /* The color table starts after the ARM3 PFN database */ MmFreePagesByColor[0] = (PMMCOLOR_TABLES)&MmPfnDatabase[MmHighestPhysicalPage + 1]; - + /* Loop the PTEs. We have two color tables for each secondary color */ PointerPte = MiAddressToPte(&MmFreePagesByColor[0][0]); LastPte = MiAddressToPte((ULONG_PTR)MmFreePagesByColor[0] + @@ -471,14 +470,14 @@ MiInitializeColorTables(VOID) /* Zero out the page */ RtlZeroMemory(MiPteToAddress(PointerPte), PAGE_SIZE); } - + /* Next */ PointerPte++; } - + /* Now set the address of the next list, right after this one */ MmFreePagesByColor[1] = &MmFreePagesByColor[0][MmSecondaryColors]; - + /* Now loop the lists to set them up */ for (i = 0; i < MmSecondaryColors; i++) { @@ -561,12 +560,12 @@ MiMapPfnDatabase(IN PLOADER_PARAMETER_BLOCK LoaderBlock) PMEMORY_ALLOCATION_DESCRIPTOR MdBlock; PMMPTE PointerPte, LastPte; MMPTE TempPte = ValidKernelPte; - + /* Get current page data, since we won't be using MxGetNextPage as it would corrupt our state */ FreePage = MxFreeDescriptor->BasePage; FreePageCount = MxFreeDescriptor->PageCount; PagesLeft = 0; - + /* Loop the memory descriptors */ NextEntry = LoaderBlock->MemoryDescriptorListHead.Flink; while (NextEntry != &LoaderBlock->MemoryDescriptorListHead) @@ -583,7 +582,7 @@ MiMapPfnDatabase(IN PLOADER_PARAMETER_BLOCK LoaderBlock) NextEntry = MdBlock->ListEntry.Flink; continue; } - + /* Next, check if this is our special free descriptor we've found */ if (MdBlock == MxFreeDescriptor) { @@ -597,12 +596,12 @@ MiMapPfnDatabase(IN PLOADER_PARAMETER_BLOCK LoaderBlock) BasePage = MdBlock->BasePage; PageCount = MdBlock->PageCount; } - + /* Get the PTEs for this range */ PointerPte = MiAddressToPte(&MmPfnDatabase[BasePage]); LastPte = MiAddressToPte(((ULONG_PTR)&MmPfnDatabase[BasePage + PageCount]) - 1); DPRINT("MD Type: %lx Base: %lx Count: %lx\n", MdBlock->MemoryType, BasePage, PageCount); - + /* Loop them */ while (PointerPte <= LastPte) { @@ -612,7 +611,7 @@ MiMapPfnDatabase(IN PLOADER_PARAMETER_BLOCK LoaderBlock) /* Use the next free page */ TempPte.u.Hard.PageFrameNumber = FreePage; ASSERT(FreePageCount != 0); - + /* Consume free pages */ FreePage++; FreePageCount--; @@ -625,15 +624,15 @@ MiMapPfnDatabase(IN PLOADER_PARAMETER_BLOCK LoaderBlock) MxOldFreeDescriptor.PageCount, 1); } - + /* Write out this PTE */ PagesLeft++; MI_WRITE_VALID_PTE(PointerPte, TempPte); - + /* Zero this page */ RtlZeroMemory(MiPteToAddress(PointerPte), PAGE_SIZE); } - + /* Next! */ PointerPte++; } @@ -641,7 +640,7 @@ MiMapPfnDatabase(IN PLOADER_PARAMETER_BLOCK LoaderBlock) /* Do the next address range */ NextEntry = MdBlock->ListEntry.Flink; } - + /* Now update the free descriptors to consume the pages we used up during the PFN allocation loop */ MxFreeDescriptor->BasePage = FreePage; MxFreeDescriptor->PageCount = FreePageCount; @@ -658,10 +657,10 @@ MiBuildPfnDatabaseFromPages(IN PLOADER_PARAMETER_BLOCK LoaderBlock) PFN_NUMBER PageFrameIndex, StartupPdIndex, PtePageIndex; PMMPFN Pfn1, Pfn2; ULONG_PTR BaseAddress = 0; - + /* PFN of the startup page directory */ StartupPdIndex = PFN_FROM_PTE(MiAddressToPde(PDE_BASE)); - + /* Start with the first PDE and scan them all */ PointerPde = MiAddressToPde(NULL); Count = PD_COUNT * PDE_COUNT; @@ -672,7 +671,7 @@ MiBuildPfnDatabaseFromPages(IN PLOADER_PARAMETER_BLOCK LoaderBlock) { /* Get the PFN from it */ PageFrameIndex = PFN_FROM_PTE(PointerPde); - + /* Do we want a PFN entry for this page? */ if (MiIsRegularMemory(LoaderBlock, PageFrameIndex)) { @@ -694,7 +693,7 @@ MiBuildPfnDatabaseFromPages(IN PLOADER_PARAMETER_BLOCK LoaderBlock) /* No PFN entry */ Pfn1 = NULL; } - + /* Now get the PTE and scan the pages */ PointerPte = MiAddressToPte(BaseAddress); for (j = 0; j < PTE_COUNT; j++) @@ -705,7 +704,7 @@ MiBuildPfnDatabaseFromPages(IN PLOADER_PARAMETER_BLOCK LoaderBlock) /* Increase the shared count of the PFN entry for the PDE */ ASSERT(Pfn1 != NULL); Pfn1->u2.ShareCount++; - + /* Now check if the PTE is valid memory too */ PtePageIndex = PFN_FROM_PTE(PointerPte); if (MiIsRegularMemory(LoaderBlock, PtePageIndex)) @@ -739,7 +738,7 @@ MiBuildPfnDatabaseFromPages(IN PLOADER_PARAMETER_BLOCK LoaderBlock) } } } - + /* Next PTE */ PointerPte++; BaseAddress += PAGE_SIZE; @@ -750,7 +749,7 @@ MiBuildPfnDatabaseFromPages(IN PLOADER_PARAMETER_BLOCK LoaderBlock) /* Next PDE mapped address */ BaseAddress += PDE_MAPPED_VA; } - + /* Next PTE */ PointerPde++; } @@ -763,7 +762,7 @@ MiBuildPfnDatabaseZeroPage(VOID) { PMMPFN Pfn1; PMMPDE PointerPde; - + /* Grab the lowest page and check if it has no real references */ Pfn1 = MiGetPfnEntry(MmLowestPhysicalPage); if (!(MmLowestPhysicalPage) && !(Pfn1->u3.e2.ReferenceCount)) @@ -776,7 +775,7 @@ MiBuildPfnDatabaseZeroPage(VOID) Pfn1->u3.e2.ReferenceCount = 0xFFF0; Pfn1->u3.e1.PageLocation = ActiveAndValid; Pfn1->u3.e1.CacheAttribute = MiNonCached; - } + } } VOID @@ -792,7 +791,7 @@ MiBuildPfnDatabaseFromLoaderBlock(IN PLOADER_PARAMETER_BLOCK LoaderBlock) PMMPTE PointerPte; PMMPDE PointerPde; KIRQL OldIrql; - + /* Now loop through the descriptors */ NextEntry = LoaderBlock->MemoryDescriptorListHead.Flink; while (NextEntry != &LoaderBlock->MemoryDescriptorListHead) @@ -819,7 +818,7 @@ MiBuildPfnDatabaseFromLoaderBlock(IN PLOADER_PARAMETER_BLOCK LoaderBlock) /* In which case we'll trim the descriptor to go as high as we can */ PageCount = MmHighestPhysicalPage + 1 - PageFrameIndex; MdBlock->PageCount = PageCount; - + /* But if there's nothing left to trim, we got too high, so quit */ if (!PageCount) break; } @@ -829,7 +828,7 @@ MiBuildPfnDatabaseFromLoaderBlock(IN PLOADER_PARAMETER_BLOCK LoaderBlock) { /* Check for bad RAM */ case LoaderBad: - + DPRINT1("You either have specified /BURNMEMORY or damaged RAM modules.\n"); break; @@ -842,7 +841,7 @@ MiBuildPfnDatabaseFromLoaderBlock(IN PLOADER_PARAMETER_BLOCK LoaderBlock) /* Get the last page of this descriptor. Note we loop backwards */ PageFrameIndex += PageCount - 1; Pfn1 = MiGetPfnEntry(PageFrameIndex); - + /* Lock the PFN Database */ OldIrql = KeAcquireQueuedSpinLock(LockQueuePfnLock); while (PageCount--) @@ -859,10 +858,10 @@ MiBuildPfnDatabaseFromLoaderBlock(IN PLOADER_PARAMETER_BLOCK LoaderBlock) Pfn1--; PageFrameIndex--; } - + /* Release PFN database */ KeReleaseQueuedSpinLock(LockQueuePfnLock, OldIrql); - + /* Done with this block */ break; @@ -895,7 +894,7 @@ MiBuildPfnDatabaseFromLoaderBlock(IN PLOADER_PARAMETER_BLOCK LoaderBlock) #if MI_TRACE_PFNS Pfn1->PfnUsage = MI_USAGE_BOOT_DRIVER; #endif - + /* Check for RAM disk page */ if (MdBlock->MemoryType == LoaderXIPRom) { @@ -909,7 +908,7 @@ MiBuildPfnDatabaseFromLoaderBlock(IN PLOADER_PARAMETER_BLOCK LoaderBlock) Pfn1->u3.e1.PrototypePte = 1; } } - + /* Advance page structures */ Pfn1++; PageFrameIndex++; @@ -930,7 +929,7 @@ MiBuildPfnDatabaseSelf(VOID) { PMMPTE PointerPte, LastPte; PMMPFN Pfn1; - + /* Loop the PFN database page */ PointerPte = MiAddressToPte(MiGetPfnEntry(MmLowestPhysicalPage)); LastPte = MiAddressToPte(MiGetPfnEntry(MmHighestPhysicalPage)); @@ -947,7 +946,7 @@ MiBuildPfnDatabaseSelf(VOID) Pfn1->PfnUsage = MI_USAGE_PFN_DATABASE; #endif } - + /* Next */ PointerPte++; } @@ -960,14 +959,14 @@ MiInitializePfnDatabase(IN PLOADER_PARAMETER_BLOCK LoaderBlock) { /* Scan memory and start setting up PFN entries */ MiBuildPfnDatabaseFromPages(LoaderBlock); - + /* Add the zero page */ MiBuildPfnDatabaseZeroPage(); - + /* Scan the loader block and build the rest of the PFN database */ MiBuildPfnDatabaseFromLoaderBlock(LoaderBlock); - - /* Finally add the pages for the PFN database itself */ + + /* Finally add the pages for the PFN database itself */ MiBuildPfnDatabaseSelf(); } @@ -977,7 +976,7 @@ INIT_FUNCTION MiAdjustWorkingSetManagerParameters(IN BOOLEAN Client) { /* This function needs to do more work, for now, we tune page minimums */ - + /* Check for a system with around 64MB RAM or more */ if (MmNumberOfPhysicalPages >= (63 * _1MB) / PAGE_SIZE) { @@ -1044,35 +1043,35 @@ MiCreateMemoryEvent(IN PUNICODE_STRING Name, /* Setup the ACL inside it */ Status = RtlCreateAcl(Dacl, DaclLength, ACL_REVISION); if (!NT_SUCCESS(Status)) goto CleanUp; - + /* Add query rights for everyone */ Status = RtlAddAccessAllowedAce(Dacl, ACL_REVISION, SYNCHRONIZE | EVENT_QUERY_STATE | READ_CONTROL, SeWorldSid); if (!NT_SUCCESS(Status)) goto CleanUp; - + /* Full rights for the admin */ Status = RtlAddAccessAllowedAce(Dacl, ACL_REVISION, EVENT_ALL_ACCESS, SeAliasAdminsSid); if (!NT_SUCCESS(Status)) goto CleanUp; - + /* As well as full rights for the system */ Status = RtlAddAccessAllowedAce(Dacl, ACL_REVISION, EVENT_ALL_ACCESS, SeLocalSystemSid); if (!NT_SUCCESS(Status)) goto CleanUp; - + /* Set this DACL inside the SD */ Status = RtlSetDaclSecurityDescriptor(&SecurityDescriptor, TRUE, Dacl, FALSE); if (!NT_SUCCESS(Status)) goto CleanUp; - + /* Setup the event attributes, making sure it's a permanent one */ InitializeObjectAttributes(&ObjectAttributes, Name, @@ -1100,7 +1099,7 @@ CleanUp: KernelMode, (PVOID*)Event, NULL); - ZwClose (EventHandle); + ZwClose (EventHandle); } /* Return status */ @@ -1297,30 +1296,30 @@ MmDumpArmPfnDatabase(IN BOOLEAN StatusOnly) switch (Pfn1->u3.e1.PageLocation) { case ActiveAndValid: - + Consumer = "Active and Valid"; ActivePages++; break; - + case ZeroedPageList: Consumer = "Zero Page List"; FreePages++; break;//continue; - + case FreePageList: - + Consumer = "Free Page List"; FreePages++; break;//continue; - + default: - + Consumer = "Other (ASSERT!)"; OtherPages++; break; } - + #if MI_TRACE_PFNS /* Add into bucket */ UsageBucket[Pfn1->PfnUsage]++; @@ -1343,7 +1342,7 @@ MmDumpArmPfnDatabase(IN BOOLEAN StatusOnly) "is disabled"); #endif } - + DbgPrint("Active: %5d pages\t[%6d KB]\n", ActivePages, (ActivePages << PAGE_SHIFT) / 1024); DbgPrint("Free: %5d pages\t[%6d KB]\n", FreePages, (FreePages << PAGE_SHIFT) / 1024); DbgPrint("-----------------------------------------\n"); @@ -1380,7 +1379,7 @@ MiPagesInLoaderBlock(IN PLOADER_PARAMETER_BLOCK LoaderBlock, PLIST_ENTRY NextEntry; PFN_NUMBER PageCount = 0; PMEMORY_ALLOCATION_DESCRIPTOR MdBlock; - + // // Now loop through the descriptors // @@ -1401,13 +1400,13 @@ MiPagesInLoaderBlock(IN PLOADER_PARAMETER_BLOCK LoaderBlock, // PageCount += MdBlock->PageCount; } - + // // Try the next descriptor // NextEntry = MdBlock->ListEntry.Flink; } - + // // Return the total // @@ -1425,7 +1424,7 @@ MmInitializeMemoryLimits(IN PLOADER_PARAMETER_BLOCK LoaderBlock, PFN_NUMBER NextPage = -1, PageCount = 0; PPHYSICAL_MEMORY_DESCRIPTOR Buffer, NewBuffer; PMEMORY_ALLOCATION_DESCRIPTOR MdBlock; - + // // Scan the memory descriptors // @@ -1438,7 +1437,7 @@ MmInitializeMemoryLimits(IN PLOADER_PARAMETER_BLOCK LoaderBlock, InitialRuns++; NextEntry = NextEntry->Flink; } - + // // Allocate the maximum we'll ever need // @@ -1453,7 +1452,7 @@ MmInitializeMemoryLimits(IN PLOADER_PARAMETER_BLOCK LoaderBlock, // For now that's how many runs we have // Buffer->NumberOfRuns = InitialRuns; - + // // Now loop through the descriptors again // @@ -1473,10 +1472,10 @@ MmInitializeMemoryLimits(IN PLOADER_PARAMETER_BLOCK LoaderBlock, // Add this to our running total // PageCount += MdBlock->PageCount; - + // // Check if the next page is described by the next descriptor - // + // if (MdBlock->BasePage == NextPage) { // @@ -1494,20 +1493,20 @@ MmInitializeMemoryLimits(IN PLOADER_PARAMETER_BLOCK LoaderBlock, Buffer->Run[Run].BasePage = MdBlock->BasePage; Buffer->Run[Run].PageCount = MdBlock->PageCount; NextPage = Buffer->Run[Run].BasePage + Buffer->Run[Run].PageCount; - + // // And in this case, increase the number of runs // Run++; } } - + // // Try the next descriptor // NextEntry = MdBlock->ListEntry.Flink; } - + // // We should not have been able to go past our initial estimate // @@ -1535,14 +1534,14 @@ MmInitializeMemoryLimits(IN PLOADER_PARAMETER_BLOCK LoaderBlock, Buffer->Run, sizeof(PHYSICAL_MEMORY_RUN) * Run); ExFreePool(Buffer); - + // // Now use the new buffer // Buffer = NewBuffer; } } - + // // Write the final numbers, and return it // @@ -1570,7 +1569,7 @@ MiBuildPagedPool(VOID) PointerPte = MiAddressToPte(PDE_BASE); ASSERT(PD_COUNT == 1); MmSystemPageDirectory[0] = PFN_FROM_PTE(PointerPte); - + // // Allocate a system PTE which will hold a copy of the page directory // @@ -1628,7 +1627,7 @@ MiBuildPagedPool(VOID) // // Let's be really sure this doesn't overflow into nonpaged system VA // - ASSERT((MmSizeOfPagedPoolInBytes + (ULONG_PTR)MmPagedPoolStart) <= + ASSERT((MmSizeOfPagedPoolInBytes + (ULONG_PTR)MmPagedPoolStart) <= (ULONG_PTR)MmNonPagedSystemStart); // @@ -1641,7 +1640,7 @@ MiBuildPagedPool(VOID) // So now get the PDE for paged pool and zero it out // PointerPde = MiAddressToPde(MmPagedPoolStart); - + #if (_MI_PAGING_LEVELS >= 3) /* On these systems, there's no double-mapping, so instead, the PPE and PXEs * are setup to span the entire paged pool area, so there's no need for the @@ -1759,7 +1758,7 @@ MiBuildPagedPool(VOID) MiHighPagedPoolThreshold = (60 * _1MB) >> PAGE_SHIFT; MiHighPagedPoolThreshold = min(MiHighPagedPoolThreshold, (Size * 2) / 5); ASSERT(MiLowPagedPoolThreshold < MiHighPagedPoolThreshold); - + /* Setup the global session space */ MiInitializeSystemSpaceMap(NULL); } @@ -1802,7 +1801,7 @@ MiDbgDumpMemoryDescriptors(VOID) "LoaderReserve ", "LoaderXIPRom " }; - + DPRINT1("Base\t\tLength\t\tType\n"); for (NextEntry = KeLoaderBlock->MemoryDescriptorListHead.Flink; NextEntry != &KeLoaderBlock->MemoryDescriptorListHead; @@ -1827,10 +1826,10 @@ MmArmInitSystem(IN ULONG Phase, PVOID Bitmap; PPHYSICAL_MEMORY_RUN Run; PFN_NUMBER PageCount; - + /* Dump memory descriptors */ if (MiDbgEnableMdDump) MiDbgDumpMemoryDescriptors(); - + // // Instantiate memory that we don't consider RAM/usable // We use the same exclusions that Windows does, in order to try to be @@ -1853,14 +1852,14 @@ MmArmInitSystem(IN ULONG Phase, MiHighPagedPoolEvent = &MiTempEvent; MiLowNonPagedPoolEvent = &MiTempEvent; MiHighNonPagedPoolEvent = &MiTempEvent; - + // // Define the basic user vs. kernel address space separation // MmSystemRangeStart = (PVOID)KSEG0_BASE; MmUserProbeAddress = (ULONG_PTR)MmSystemRangeStart - 0x10000; MmHighestUserAddress = (PVOID)(MmUserProbeAddress - 1); - + /* Highest PTE and PDE based on the addresses above */ MiHighestUserPte = MiAddressToPte(MmHighestUserAddress); MiHighestUserPde = MiAddressToPde(MmHighestUserAddress); @@ -1878,7 +1877,7 @@ MmArmInitSystem(IN ULONG Phase, MmBootImageSize *= PAGE_SIZE; MmBootImageSize = (MmBootImageSize + PDE_MAPPED_VA - 1) & ~(PDE_MAPPED_VA - 1); ASSERT((MmBootImageSize % PDE_MAPPED_VA) == 0); - + // // Set the size of session view, pool, and image // @@ -1886,54 +1885,54 @@ MmArmInitSystem(IN ULONG Phase, MmSessionViewSize = MI_SESSION_VIEW_SIZE; MmSessionPoolSize = MI_SESSION_POOL_SIZE; MmSessionImageSize = MI_SESSION_IMAGE_SIZE; - + // // Set the size of system view // MmSystemViewSize = MI_SYSTEM_VIEW_SIZE; - + // // This is where it all ends // MiSessionImageEnd = (PVOID)PTE_BASE; - + // // This is where we will load Win32k.sys and the video driver // MiSessionImageStart = (PVOID)((ULONG_PTR)MiSessionImageEnd - MmSessionImageSize); - + // // So the view starts right below the session working set (itself below // the image area) // MiSessionViewStart = (PVOID)((ULONG_PTR)MiSessionImageEnd - MmSessionImageSize - - MI_SESSION_WORKING_SET_SIZE - + MI_SESSION_WORKING_SET_SIZE - MmSessionViewSize); - + // // Session pool follows // MiSessionPoolEnd = MiSessionViewStart; MiSessionPoolStart = (PVOID)((ULONG_PTR)MiSessionPoolEnd - MmSessionPoolSize); - + // // And it all begins here // MmSessionBase = MiSessionPoolStart; - + // // Sanity check that our math is correct // ASSERT((ULONG_PTR)MmSessionBase + MmSessionSize == PTE_BASE); - + // // Session space ends wherever image session space ends // MiSessionSpaceEnd = MiSessionImageEnd; - + // // System view space ends at session space, so now that we know where // this is, we can compute the base address of system view space itself. @@ -1946,25 +1945,25 @@ MmArmInitSystem(IN ULONG Phase, MiSessionImagePteEnd = MiAddressToPte(MiSessionImageEnd); MiSessionBasePte = MiAddressToPte(MmSessionBase); MiSessionLastPte = MiAddressToPte(MiSessionSpaceEnd); - + /* Initialize the user mode image list */ InitializeListHead(&MmLoadedUserImageList); - + /* Initialize the paged pool mutex */ KeInitializeGuardedMutex(&MmPagedPoolMutex); - + /* Initialize the Loader Lock */ - KeInitializeMutant(&MmSystemLoadLock, FALSE); + KeInitializeMutant(&MmSystemLoadLock, FALSE); /* Set the zero page event */ KeInitializeEvent(&MmZeroingPageEvent, SynchronizationEvent, FALSE); MmZeroingPageThreadActive = FALSE; - + // // Count physical pages on the system // PageCount = MiPagesInLoaderBlock(LoaderBlock, IncludeType); - + // // Check if this is a machine with less than 19MB of RAM // @@ -1989,17 +1988,17 @@ MmArmInitSystem(IN ULONG Phase, MmNumberOfSystemPtes <<= 1; } } - + DPRINT("System PTE count has been tuned to %d (%d bytes)\n", MmNumberOfSystemPtes, MmNumberOfSystemPtes * PAGE_SIZE); - + /* Initialize the working set lock */ ExInitializePushLock((PULONG_PTR)&MmSystemCacheWs.WorkingSetMutex); - + /* Set commit limit */ MmTotalCommitLimit = 2 * _1GB; MmTotalCommitLimitMaximum = MmTotalCommitLimit; - + /* Has the allocation fragment been setup? */ if (!MmAllocationFragment) { @@ -2021,17 +2020,17 @@ MmArmInitSystem(IN ULONG Phase, /* Convert from 1KB fragments to pages */ MmAllocationFragment *= _1KB; MmAllocationFragment = ROUND_TO_PAGES(MmAllocationFragment); - + /* Don't let it past the maximum */ MmAllocationFragment = min(MmAllocationFragment, MI_MAX_ALLOCATION_FRAGMENT); - + /* Don't let it too small either */ MmAllocationFragment = max(MmAllocationFragment, MI_MIN_ALLOCATION_FRAGMENT); } - - /* Initialize the platform-specific parts */ + + /* Initialize the platform-specific parts */ MiInitMachineDependent(LoaderBlock); // @@ -2039,7 +2038,7 @@ MmArmInitSystem(IN ULONG Phase, // MmPhysicalMemoryBlock = MmInitializeMemoryLimits(LoaderBlock, IncludeType); - + // // Allocate enough buffer for the PFN bitmap // Align it up to a 32-bit boundary @@ -2058,7 +2057,7 @@ MmArmInitSystem(IN ULONG Phase, MmHighestPhysicalPage, 0x101); } - + // // Initialize it and clear all the bits to begin with // @@ -2066,7 +2065,7 @@ MmArmInitSystem(IN ULONG Phase, Bitmap, MmHighestPhysicalPage + 1); RtlClearAllBits(&MiPfnBitMap); - + // // Loop physical memory runs // @@ -2091,7 +2090,7 @@ MmArmInitSystem(IN ULONG Phase, RtlSetBits(&MiPfnBitMap, Run->BasePage, Run->PageCount); } } - + /* Look for large page cache entries that need caching */ MiSyncCachedRanges(); @@ -2130,7 +2129,7 @@ MmArmInitSystem(IN ULONG Phase, MmSystemSize = MmMediumSystem; MmSystemCacheWsMinimum += 400; } - + /* Check for less than 24MB */ if (MmNumberOfPhysicalPages < ((24 * _1MB) / PAGE_SIZE)) { @@ -2157,14 +2156,14 @@ MmArmInitSystem(IN ULONG Phase, } } } - + /* Check for more than 33 MB */ if (MmNumberOfPhysicalPages > ((33 * _1MB) / PAGE_SIZE)) { /* Add another 500 pages to the cache */ MmSystemCacheWsMinimum += 500; } - + /* Now setup the shared user data fields */ ASSERT(SharedUserData->NumberOfPhysicalPages == 0); SharedUserData->NumberOfPhysicalPages = MmNumberOfPhysicalPages; @@ -2209,25 +2208,25 @@ MmArmInitSystem(IN ULONG Phase, DPRINT1("System cache working set too big\n"); return FALSE; } - + /* Initialize the system cache */ //MiInitializeSystemCache(MmSystemCacheWsMinimum, MmAvailablePages); - + /* Update the commit limit */ MmTotalCommitLimit = MmAvailablePages; if (MmTotalCommitLimit > 1024) MmTotalCommitLimit -= 1024; MmTotalCommitLimitMaximum = MmTotalCommitLimit; - + /* Size up paged pool and build the shadow system page directory */ MiBuildPagedPool(); - + /* Debugger physical memory support is now ready to be used */ MmDebugPte = MiAddressToPte(MiDebugMapping); /* Initialize the loaded module list */ MiInitializeLoadedModuleList(LoaderBlock); } - + // // Always return success for now // diff --git a/reactos/ntoskrnl/mm/ARM3/mmsup.c b/reactos/ntoskrnl/mm/ARM3/mmsup.c index 4410a390249..579fd878227 100644 --- a/reactos/ntoskrnl/mm/ARM3/mmsup.c +++ b/reactos/ntoskrnl/mm/ARM3/mmsup.c @@ -12,7 +12,6 @@ #define NDEBUG #include -#line 15 "ARM³::MMSUP" #define MODULE_INVOLVED_IN_ARM3 #include "../ARM3/miarm.h" @@ -122,7 +121,7 @@ NTAPI MmIsRecursiveIoFault(VOID) { PETHREAD Thread = PsGetCurrentThread(); - + // // If any of these is true, this is a recursive fault // diff --git a/reactos/ntoskrnl/mm/ARM3/ncache.c b/reactos/ntoskrnl/mm/ARM3/ncache.c index f120fd307f8..45ebce62f96 100644 --- a/reactos/ntoskrnl/mm/ARM3/ncache.c +++ b/reactos/ntoskrnl/mm/ARM3/ncache.c @@ -12,7 +12,6 @@ #define NDEBUG #include -#line 15 "ARM³::NCACHE" #define MODULE_INVOLVED_IN_ARM3 #include "../ARM3/miarm.h" @@ -29,25 +28,25 @@ MmAllocateNonCachedMemory(IN SIZE_T NumberOfBytes) PHYSICAL_ADDRESS LowAddress, HighAddress, SkipBytes; MI_PFN_CACHE_ATTRIBUTE CacheAttribute; PMDL Mdl; - PVOID BaseAddress; + PVOID BaseAddress; PPFN_NUMBER MdlPages; PMMPTE PointerPte; MMPTE TempPte; - + // // Get the page count // ASSERT(NumberOfBytes != 0); PageCount = BYTES_TO_PAGES(NumberOfBytes); - + // // Use the MDL allocator for simplicity, so setup the parameters // LowAddress.QuadPart = 0; HighAddress.QuadPart = -1; - SkipBytes.QuadPart = 0; + SkipBytes.QuadPart = 0; CacheAttribute = MiPlatformCacheAttributes[0][MmNonCached]; - + // // Now call the MDL allocator // @@ -58,7 +57,7 @@ MmAllocateNonCachedMemory(IN SIZE_T NumberOfBytes) CacheAttribute, 0); if (!Mdl) return NULL; - + // // Get the MDL VA and check how many pages we got (could be partial) // @@ -74,12 +73,12 @@ MmAllocateNonCachedMemory(IN SIZE_T NumberOfBytes) ExFreePool(Mdl); return NULL; } - + // // Allocate system PTEs for the base address // We use an extra page to store the actual MDL pointer for the free later // - PointerPte = MiReserveSystemPtes(PageCount + 1, SystemPteSpace); + PointerPte = MiReserveSystemPtes(PageCount + 1, SystemPteSpace); if (!PointerPte) { // @@ -89,57 +88,57 @@ MmAllocateNonCachedMemory(IN SIZE_T NumberOfBytes) ExFreePool(Mdl); return NULL; } - + // // Store the MDL pointer // *(PMDL*)PointerPte++ = Mdl; - + // // Okay, now see what range we got // BaseAddress = MiPteToAddress(PointerPte); - + // // This is our array of pages // MdlPages = (PPFN_NUMBER)(Mdl + 1); - + // // Setup the template PTE // TempPte = ValidKernelPte; - + // // Now check what kind of caching we should use // switch (CacheAttribute) { case MiNonCached: - + // // Disable caching // MI_PAGE_DISABLE_CACHE(&TempPte); MI_PAGE_WRITE_THROUGH(&TempPte); break; - + case MiWriteCombined: - + // // Enable write combining // MI_PAGE_DISABLE_CACHE(&TempPte); MI_PAGE_WRITE_COMBINED(&TempPte); break; - + default: // // Nothing to do // break; } - + // // Now loop the MDL pages // @@ -149,19 +148,19 @@ MmAllocateNonCachedMemory(IN SIZE_T NumberOfBytes) // Get the PFN // PageFrameIndex = *MdlPages++; - + // // Set the PFN in the page and write it // TempPte.u.Hard.PageFrameNumber = PageFrameIndex; MI_WRITE_VALID_PTE(PointerPte++, TempPte); } while (--PageCount); - + // // Return the base address // return BaseAddress; - + } /* @@ -175,34 +174,34 @@ MmFreeNonCachedMemory(IN PVOID BaseAddress, PMDL Mdl; PMMPTE PointerPte; PFN_NUMBER PageCount; - + // // Sanity checks // ASSERT(NumberOfBytes != 0); ASSERT(PAGE_ALIGN(BaseAddress) == BaseAddress); - + // // Get the page count // PageCount = BYTES_TO_PAGES(NumberOfBytes); - + // // Get the first PTE // PointerPte = MiAddressToPte(BaseAddress); - + // // Remember this is where we store the shadow MDL pointer // Mdl = *(PMDL*)(--PointerPte); - + // // Kill the MDL (and underlying pages) // MmFreePagesFromMdl(Mdl); ExFreePool(Mdl); - + // // Now free the system PTEs for the underlying VA // diff --git a/reactos/ntoskrnl/mm/ARM3/pagfault.c b/reactos/ntoskrnl/mm/ARM3/pagfault.c index 20264a1faf0..789fdeb82b9 100644 --- a/reactos/ntoskrnl/mm/ARM3/pagfault.c +++ b/reactos/ntoskrnl/mm/ARM3/pagfault.c @@ -12,7 +12,6 @@ #define NDEBUG #include -#line 15 "ARM³::PAGFAULT" #define MODULE_INVOLVED_IN_ARM3 #include "../ARM3/miarm.h" @@ -32,10 +31,10 @@ MiCheckVirtualAddress(IN PVOID VirtualAddress, { PMMVAD Vad; PMMPTE PointerPte; - + /* No prototype/section support for now */ *ProtoVad = NULL; - + /* Check if this is a page table address */ if (MI_IS_PAGE_TABLE_ADDRESS(VirtualAddress)) { @@ -47,15 +46,15 @@ MiCheckVirtualAddress(IN PVOID VirtualAddress, *ProtectCode = MM_NOACCESS; return NULL; } - + /* Return full access rights */ *ProtectCode = MM_READWRITE; return NULL; } - + /* Should not be a session address */ ASSERT(MI_IS_SESSION_ADDRESS(VirtualAddress) == FALSE); - + /* Special case for shared data */ if (PAGE_ALIGN(VirtualAddress) == (PVOID)USER_SHARED_DATA) { @@ -63,7 +62,7 @@ MiCheckVirtualAddress(IN PVOID VirtualAddress, *ProtectCode = MM_READONLY; return MmSharedUserDataPte; } - + /* Find the VAD, it might not exist if the address is bogus */ Vad = MiLocateAddress(VirtualAddress); if (!Vad) @@ -75,7 +74,7 @@ MiCheckVirtualAddress(IN PVOID VirtualAddress, /* This must be a VM VAD */ ASSERT(Vad->u.VadFlags.VadType == VadNone); - + /* Check if it's a section, or just an allocation */ if (Vad->u.VadFlags.PrivateMemory == TRUE) { @@ -89,29 +88,29 @@ MiCheckVirtualAddress(IN PVOID VirtualAddress, /* Return the proto VAD */ ASSERT(Vad->u2.VadFlags2.ExtendableFile == 0); *ProtoVad = Vad; - + /* Get the prototype PTE for this page */ PointerPte = (((ULONG_PTR)VirtualAddress >> PAGE_SHIFT) - Vad->StartingVpn) + Vad->FirstPrototypePte; ASSERT(PointerPte <= Vad->LastContiguousPte); ASSERT(PointerPte != NULL); - + /* Return the Prototype PTE and the protection for the page mapping */ *ProtectCode = Vad->u.VadFlags.Protection; return PointerPte; } } - + NTSTATUS FASTCALL MiCheckPdeForPagedPool(IN PVOID Address) { PMMPDE PointerPde; NTSTATUS Status = STATUS_SUCCESS; - + /* No session support in ReactOS yet */ ASSERT(MI_IS_SESSION_ADDRESS(Address) == FALSE); ASSERT(MI_IS_SESSION_PTE(Address) == FALSE); - + // // Check if this is a fault while trying to access the page table itself // @@ -129,7 +128,7 @@ MiCheckPdeForPagedPool(IN PVOID Address) // // This is totally illegal // - return STATUS_ACCESS_VIOLATION; + return STATUS_ACCESS_VIOLATION; } else { @@ -138,7 +137,7 @@ MiCheckPdeForPagedPool(IN PVOID Address) // PointerPde = MiAddressToPde(Address); } - + // // Check if it's not valid // @@ -154,7 +153,7 @@ MiCheckPdeForPagedPool(IN PVOID Address) MmSystemPagePtes[((ULONG_PTR)PointerPde & (SYSTEM_PD_SIZE - 1)) / sizeof(MMPTE)].u.Long); #endif } - + // // Return status // @@ -169,15 +168,15 @@ MiZeroPfn(IN PFN_NUMBER PageFrameNumber) MMPTE TempPte; PMMPFN Pfn1; PVOID ZeroAddress; - + /* Get the PFN for this page */ Pfn1 = MiGetPfnEntry(PageFrameNumber); ASSERT(Pfn1); - + /* Grab a system PTE we can use to zero the page */ ZeroPte = MiReserveSystemPtes(1, SystemPteSpace); ASSERT(ZeroPte); - + /* Initialize the PTE for it */ TempPte = ValidKernelPte; TempPte.u.Hard.PageFrameNumber = PageFrameNumber; @@ -221,7 +220,7 @@ MiResolveDemandZeroFault(IN PVOID Address, DPRINT("ARM3 Demand Zero Page Fault Handler for address: %p in process: %p\n", Address, Process); - + /* Must currently only be called by paging path */ if ((Process) && (OldIrql == MM_NOIRQL)) { @@ -230,11 +229,11 @@ MiResolveDemandZeroFault(IN PVOID Address, /* No forking yet */ ASSERT(Process->ForkInProgress == NULL); - + /* Get process color */ Color = MI_GET_NEXT_PROCESS_COLOR(Process); ASSERT(Color != 0xFFFFFFFF); - + /* We'll need a zero page */ NeedZero = TRUE; } @@ -242,7 +241,7 @@ MiResolveDemandZeroFault(IN PVOID Address, { /* Check if we need a zero page */ NeedZero = (OldIrql != MM_NOIRQL); - + /* Get the next system page color */ Color = MI_GET_NEXT_COLOR(); } @@ -254,10 +253,10 @@ MiResolveDemandZeroFault(IN PVOID Address, OldIrql = KeAcquireQueuedSpinLock(LockQueuePfnLock); HaveLock = TRUE; } - + /* We either manually locked the PFN DB, or already came with it locked */ ASSERT(KeGetCurrentIrql() == DISPATCH_LEVEL); - + /* Do we need a zero page? */ ASSERT(PointerPte->u.Hard.Valid == 0); #if MI_TRACE_PFNS @@ -291,21 +290,21 @@ MiResolveDemandZeroFault(IN PVOID Address, /* System wants a zero page, obtain one */ PageFrameNumber = MiRemoveZeroPage(Color); } - + /* Initialize it */ MiInitializePfn(PageFrameNumber, PointerPte, TRUE); - + /* Release PFN lock if needed */ if (HaveLock) KeReleaseQueuedSpinLock(LockQueuePfnLock, OldIrql); - + // // Increment demand zero faults // InterlockedIncrement(&KeGetCurrentPrcb()->MmDemandZeroCount); - + /* Zero the page if need be */ if (NeedZero) MiZeroPfn(PageFrameNumber); - + /* Build the PTE */ if (PointerPte <= MiHighestUserPte) { @@ -323,10 +322,10 @@ MiResolveDemandZeroFault(IN PVOID Address, PointerPte->u.Soft.Protection, PageFrameNumber); } - + /* Set it dirty if it's a writable page */ if (MI_IS_PAGE_WRITEABLE(&TempPte)) MI_MAKE_DIRTY_PAGE(&TempPte); - + /* Write it */ MI_WRITE_VALID_PTE(PointerPte, TempPte); @@ -350,20 +349,20 @@ MiCompleteProtoPteFault(IN BOOLEAN StoreInstruction, PMMPTE OriginalPte; ULONG Protection; PFN_NUMBER PageFrameIndex; - + /* Must be called with an valid prototype PTE, with the PFN lock held */ ASSERT(KeGetCurrentIrql() == DISPATCH_LEVEL); ASSERT(PointerProtoPte->u.Hard.Valid == 1); - + /* Get the page */ PageFrameIndex = PFN_FROM_PTE(PointerProtoPte); - + /* Get the PFN entry and set it as a prototype PTE */ Pfn1 = MiGetPfnEntry(PageFrameIndex); Pfn1->u3.e1.PrototypePte = 1; - + /* FIXME: Increment the share count for the page table */ - + /* Check where we should be getting the protection information from */ if (PointerPte->u.Soft.PageFileHigh == MI_PTE_LOOKUP_NEEDED) { @@ -379,10 +378,10 @@ MiCompleteProtoPteFault(IN BOOLEAN StoreInstruction, /* Release the PFN lock */ KeReleaseQueuedSpinLock(LockQueuePfnLock, OldIrql); - + /* Remove caching bits */ Protection &= ~(MM_NOCACHE | MM_NOACCESS); - + /* Check if this is a kernel or user address */ if (Address < MmSystemRangeStart) { @@ -394,7 +393,7 @@ MiCompleteProtoPteFault(IN BOOLEAN StoreInstruction, /* Build the kernel PTE */ MI_MAKE_HARDWARE_PTE(&TempPte, PointerPte, Protection, PageFrameIndex); } - + /* Write the PTE */ MI_WRITE_VALID_PTE(PointerPte, TempPte); @@ -419,7 +418,7 @@ MiResolveProtoPteFault(IN BOOLEAN StoreInstruction, PMMPFN Pfn1; PFN_NUMBER PageFrameIndex; NTSTATUS Status; - + /* Must be called with an invalid, prototype PTE, with the PFN lock held */ ASSERT(KeGetCurrentIrql() == DISPATCH_LEVEL); ASSERT(PointerPte->u.Hard.Valid == 0); @@ -433,10 +432,10 @@ MiResolveProtoPteFault(IN BOOLEAN StoreInstruction, PageFrameIndex = PFN_FROM_PTE(&TempPte); Pfn1 = MiGetPfnEntry(PageFrameIndex); Pfn1->u2.ShareCount++; - + /* Call it a transition */ InterlockedIncrement(&KeGetCurrentPrcb()->MmTransitionCount); - + /* Complete the prototype PTE fault -- this will release the PFN lock */ return MiCompleteProtoPteFault(StoreInstruction, Address, @@ -445,7 +444,7 @@ MiResolveProtoPteFault(IN BOOLEAN StoreInstruction, OldIrql, NULL); } - + /* Make sure there's some protection mask */ if (TempPte.u.Long == 0) { @@ -454,7 +453,7 @@ MiResolveProtoPteFault(IN BOOLEAN StoreInstruction, KeReleaseQueuedSpinLock(LockQueuePfnLock, OldIrql); return STATUS_ACCESS_VIOLATION; } - + /* This is the only thing we support right now */ ASSERT(TempPte.u.Soft.PageFileHigh == 0); ASSERT(TempPte.u.Proto.ReadOnly == 0); @@ -465,7 +464,7 @@ MiResolveProtoPteFault(IN BOOLEAN StoreInstruction, /* Resolve the demand zero fault */ Status = MiResolveDemandZeroFault(Address, PointerProtoPte, Process, OldIrql); ASSERT(NT_SUCCESS(Status)); - + /* Complete the prototype PTE fault -- this will release the PFN lock */ ASSERT(PointerPte->u.Hard.Valid == 0); return MiCompleteProtoPteFault(StoreInstruction, @@ -494,32 +493,32 @@ MiDispatchFault(IN BOOLEAN StoreInstruction, DPRINT("ARM3 Page Fault Dispatcher for address: %p in process: %p\n", Address, Process); - + // // Make sure APCs are off and we're not at dispatch // OldIrql = KeGetCurrentIrql(); ASSERT(OldIrql <= APC_LEVEL); ASSERT(KeAreAllApcsDisabled() == TRUE); - + // // Grab a copy of the PTE // TempPte = *PointerPte; - + /* Do we have a prototype PTE? */ if (PointerProtoPte) { /* This should never happen */ ASSERT(!MI_IS_PHYSICAL_ADDRESS(PointerProtoPte)); - + /* Check if this is a kernel-mode address */ SuperProtoPte = MiAddressToPte(PointerProtoPte); if (Address >= MmSystemRangeStart) { /* Lock the PFN database */ LockIrql = KeAcquireQueuedSpinLock(LockQueuePfnLock); - + /* Has the PTE been made valid yet? */ if (!SuperProtoPte->u.Hard.Valid) { @@ -554,10 +553,10 @@ MiDispatchFault(IN BOOLEAN StoreInstruction, /* We currently only handle very limited paths */ ASSERT(PointerPte->u.Soft.Prototype == 1); ASSERT(PointerPte->u.Soft.PageFileHigh == MI_PTE_LOOKUP_NEEDED); - + /* Lock the PFN database */ LockIrql = KeAcquireQueuedSpinLock(LockQueuePfnLock); - + /* For our current usage, this should be true */ ASSERT(SuperProtoPte->u.Hard.Valid == 1); ASSERT(TempPte.u.Hard.Valid == 0); @@ -582,20 +581,20 @@ MiDispatchFault(IN BOOLEAN StoreInstruction, return STATUS_PAGE_FAULT_TRANSITION; } } - + // // The PTE must be invalid, but not totally blank // ASSERT(TempPte.u.Hard.Valid == 0); ASSERT(TempPte.u.Long != 0); - + // // No prototype, transition or page file software PTEs in ARM3 yet // ASSERT(TempPte.u.Soft.Prototype == 0); ASSERT(TempPte.u.Soft.Transition == 0); ASSERT(TempPte.u.Soft.PageFileHigh == 0); - + // // If we got this far, the PTE can only be a demand zero PTE, which is what // we want. Go handle it! @@ -641,7 +640,7 @@ MmArmAccessFault(IN BOOLEAN StoreInstruction, PFN_NUMBER PageFrameIndex; ULONG Color; DPRINT("ARM3 FAULT AT: %p\n", Address); - + // // Get the PTE and PDE // @@ -665,7 +664,7 @@ MmArmAccessFault(IN BOOLEAN StoreInstruction, OldIrql); ASSERT(OldIrql <= APC_LEVEL); } - + // // Check for kernel fault // @@ -675,7 +674,7 @@ MmArmAccessFault(IN BOOLEAN StoreInstruction, // What are you even DOING here? // if (Mode == UserMode) return STATUS_ACCESS_VIOLATION; - + #if (_MI_PAGING_LEVELS >= 3) /* Need to check PXE and PDE validity */ ASSERT(FALSE); @@ -690,7 +689,7 @@ MmArmAccessFault(IN BOOLEAN StoreInstruction, // Debug spew (eww!) // DPRINT("Invalid PDE\n"); -#if (_MI_PAGING_LEVELS == 2) +#if (_MI_PAGING_LEVELS == 2) // // Handle mapping in "Special" PDE directoreis // @@ -704,7 +703,7 @@ MmArmAccessFault(IN BOOLEAN StoreInstruction, // // FIXFIX: Do the S-LIST hack // - + // // Kill the system // @@ -715,7 +714,7 @@ MmArmAccessFault(IN BOOLEAN StoreInstruction, 2); } } - + // // The PDE is valid, so read the PTE // @@ -733,19 +732,19 @@ MmArmAccessFault(IN BOOLEAN StoreInstruction, DPRINT1("Should NEVER happen on ARM3!!!\n"); return STATUS_ACCESS_VIOLATION; } - + // // Otherwise, the PDE was probably invalid, and all is good now // return STATUS_SUCCESS; } - + // // Check for a fault on the page table or hyperspace itself // if (MI_IS_PAGE_TABLE_OR_HYPER_ADDRESS(Address)) { -#if (_MI_PAGING_LEVELS == 2) +#if (_MI_PAGING_LEVELS == 2) /* Could be paged pool access from a new process -- synchronize the page directories */ if (MiCheckPdeForPagedPool(Address) == STATUS_WAIT_1) { @@ -756,15 +755,15 @@ MmArmAccessFault(IN BOOLEAN StoreInstruction, /* Otherwise this could be a commit of a virtual address */ break; } - + /* In this path, we are using the system working set */ CurrentThread = PsGetCurrentThread(); WorkingSet = &MmSystemCacheWs; - + /* Acquire it */ KeRaiseIrql(APC_LEVEL, &LockIrql); MiLockWorkingSet(CurrentThread, WorkingSet); - + // // Re-read PTE now that the IRQL has been raised // @@ -782,17 +781,17 @@ MmArmAccessFault(IN BOOLEAN StoreInstruction, DPRINT1("Should NEVER happen on ARM3!!!\n"); return STATUS_ACCESS_VIOLATION; } - + /* Release the working set */ MiUnlockWorkingSet(CurrentThread, WorkingSet); KeLowerIrql(LockIrql); - + // // Otherwise, the PDE was probably invalid, and all is good now // return STATUS_SUCCESS; } - + /* Check one kind of prototype PTE */ if (TempPte.u.Soft.Prototype) { @@ -811,17 +810,17 @@ MmArmAccessFault(IN BOOLEAN StoreInstruction, Mode, 4); } - + /* Get the prototype PTE! */ ProtoPte = MiProtoPteToPte(&TempPte); } else - { + { // // We don't implement transition PTEs // ASSERT(TempPte.u.Soft.Transition == 0); - + /* Check for no-access PTE */ if (TempPte.u.Soft.Protection == MM_NOACCESS) { @@ -833,7 +832,7 @@ MmArmAccessFault(IN BOOLEAN StoreInstruction, 1); } } - + /* Check for demand page */ if ((StoreInstruction) && !(ProtoPte) && !(TempPte.u.Hard.Valid)) { @@ -848,7 +847,7 @@ MmArmAccessFault(IN BOOLEAN StoreInstruction, 14); } } - + // // Now do the real fault handling // @@ -865,21 +864,21 @@ MmArmAccessFault(IN BOOLEAN StoreInstruction, ASSERT(KeAreAllApcsDisabled() == TRUE); MiUnlockWorkingSet(CurrentThread, WorkingSet); KeLowerIrql(LockIrql); - + // // We are done! // DPRINT("Fault resolved with status: %lx\n", Status); return Status; } - + /* This is a user fault */ CurrentThread = PsGetCurrentThread(); CurrentProcess = PsGetCurrentProcess(); - + /* Lock the working set */ MiLockProcessWorkingSet(CurrentProcess, CurrentThread); - + #if (_MI_PAGING_LEVELS >= 3) /* Need to check/handle PPE and PXE validity too */ ASSERT(FALSE); @@ -894,7 +893,7 @@ MmArmAccessFault(IN BOOLEAN StoreInstruction, /* Check if this address range belongs to a valid allocation (VAD) */ MiCheckVirtualAddress(Address, &ProtectionCode, &Vad); - + /* Right now, we expect a valid protection mask on the VAD */ ASSERT(ProtectionCode != MM_NOACCESS); @@ -928,7 +927,7 @@ MmArmAccessFault(IN BOOLEAN StoreInstruction, /* Now capture the PTE. Ignore virtual faults for now */ TempPte = *PointerPte; ASSERT(TempPte.u.Hard.Valid == 0); - + /* Quick check for demand-zero */ if (TempPte.u.Long == (MM_READWRITE << MM_PTE_SOFTWARE_PROTECTION_BITS)) { @@ -942,19 +941,19 @@ MmArmAccessFault(IN BOOLEAN StoreInstruction, MiUnlockProcessWorkingSet(CurrentProcess, CurrentThread); return STATUS_PAGE_FAULT_DEMAND_ZERO; } - + /* Get protection and check if it's a prototype PTE */ ProtectionCode = TempPte.u.Soft.Protection; ASSERT(TempPte.u.Soft.Prototype == 0); - + /* Check for non-demand zero PTE */ if (TempPte.u.Long != 0) { /* This is a page fault, check for valid protection */ ASSERT(ProtectionCode != 0x100); - + /* FIXME: Run MiAccessCheck */ - + /* Dispatch the fault */ Status = MiDispatchFault(StoreInstruction, Address, @@ -964,7 +963,7 @@ MmArmAccessFault(IN BOOLEAN StoreInstruction, PsGetCurrentProcess(), TrapInformation, NULL); - + /* Return the status */ ASSERT(NT_SUCCESS(Status)); ASSERT(KeGetCurrentIrql() <= APC_LEVEL); @@ -979,14 +978,14 @@ MmArmAccessFault(IN BOOLEAN StoreInstruction, { /* This is a bogus VA */ Status = STATUS_ACCESS_VIOLATION; - + /* Could be a not-yet-mapped paged pool page table */ -#if (_MI_PAGING_LEVELS == 2) +#if (_MI_PAGING_LEVELS == 2) MiCheckPdeForPagedPool(Address); #endif /* See if that fixed it */ if (PointerPte->u.Hard.Valid == 1) Status = STATUS_SUCCESS; - + /* Return the status */ MiUnlockProcessWorkingSet(CurrentProcess, CurrentThread); return Status; @@ -999,7 +998,7 @@ MmArmAccessFault(IN BOOLEAN StoreInstruction, MmWorkingSetList->UsedPageTableEntries[MiGetPdeOffset(Address)]++; ASSERT(MmWorkingSetList->UsedPageTableEntries[MiGetPdeOffset(Address)] <= PTE_COUNT); } - + /* Did we get a prototype PTE back? */ if (!ProtoPte) { @@ -1008,7 +1007,7 @@ MmArmAccessFault(IN BOOLEAN StoreInstruction, /* Lock the PFN database since we're going to grab a page */ OldIrql = KeAcquireQueuedSpinLock(LockQueuePfnLock); - + /* Try to get a zero page */ MI_SET_USAGE(MI_USAGE_PEB_TEB); MI_SET_PROCESS2(CurrentProcess->ImageFileName); @@ -1062,7 +1061,7 @@ MmArmAccessFault(IN BOOLEAN StoreInstruction, /* And now write down the PTE, making the address valid */ MI_WRITE_VALID_PTE(PointerPte, TempPte); - + /* Demand zero */ Status = STATUS_PAGE_FAULT_DEMAND_ZERO; } @@ -1071,12 +1070,12 @@ MmArmAccessFault(IN BOOLEAN StoreInstruction, /* No guard page support yet */ ASSERT((ProtectionCode & MM_DECOMMIT) == 0); ASSERT(ProtectionCode != 0x100); - + /* Write the prototype PTE */ TempPte = PrototypePte; TempPte.u.Soft.Protection = ProtectionCode; MI_WRITE_INVALID_PTE(PointerPte, TempPte); - + /* Handle the fault */ Status = MiDispatchFault(StoreInstruction, Address, @@ -1090,7 +1089,7 @@ MmArmAccessFault(IN BOOLEAN StoreInstruction, ASSERT(PointerPte->u.Hard.Valid == 1); ASSERT(PointerPte->u.Hard.PageFrameNumber != 0); } - + /* Release the working set */ MiUnlockProcessWorkingSet(CurrentProcess, CurrentThread); return Status; diff --git a/reactos/ntoskrnl/mm/ARM3/pfnlist.c b/reactos/ntoskrnl/mm/ARM3/pfnlist.c index 575c179a33d..5e32af39950 100644 --- a/reactos/ntoskrnl/mm/ARM3/pfnlist.c +++ b/reactos/ntoskrnl/mm/ARM3/pfnlist.c @@ -12,7 +12,6 @@ #define NDEBUG #include -#line 15 "ARM³::PFNLIST" #define MODULE_INVOLVED_IN_ARM3 #include "../ARM3/miarm.h" @@ -86,14 +85,14 @@ MiUnlinkFreeOrZeroedPage(IN PMMPFN Entry) ULONG Color; PMMCOLOR_TABLES ColorTable; PMMPFN Pfn1; - + /* Make sure the PFN lock is held */ ASSERT(KeGetCurrentIrql() == DISPATCH_LEVEL); /* Make sure the PFN entry isn't in-use */ ASSERT(Entry->u3.e1.WriteInProgress == 0); ASSERT(Entry->u3.e1.ReadInProgress == 0); - + /* Find the list for this entry, make sure it's the free or zero list */ ListHead = MmPageLocationList[Entry->u3.e1.PageLocation]; ListName = ListHead->ListName; @@ -104,11 +103,11 @@ MiUnlinkFreeOrZeroedPage(IN PMMPFN Entry) /* Remove one count */ ASSERT(ListHead->Total != 0); ListHead->Total--; - + /* Get the forward and back pointers */ OldFlink = Entry->u1.Flink; OldBlink = Entry->u2.Blink; - + /* Check if the next entry is the list head */ if (OldFlink != LIST_HEAD) { @@ -120,7 +119,7 @@ MiUnlinkFreeOrZeroedPage(IN PMMPFN Entry) /* Set the list head's backlink instead */ ListHead->Blink = OldBlink; } - + /* Check if the back entry is the list head */ if (OldBlink != LIST_HEAD) { @@ -183,7 +182,7 @@ MiUnlinkFreeOrZeroedPage(IN PMMPFN Entry) /* One less colored page */ ASSERT(ColorTable->Count >= 1); ColorTable->Count--; - + /* ReactOS Hack */ Entry->OriginalPte.u.Long = 0; @@ -202,13 +201,13 @@ MiUnlinkFreeOrZeroedPage(IN PMMPFN Entry) /* Signal the low memory event */ KeSetEvent(MiLowMemoryEvent, 0, FALSE); } - + /* One less page */ if (--MmAvailablePages < MmMinimumFreePages) { /* FIXME: Should wake up the MPW and working set manager, if we had one */ } - + #if MI_TRACE_PFNS ASSERT(MI_PFN_CURRENT_USAGE != MI_USAGE_NOT_SET); Entry->PfnUsage = MI_PFN_CURRENT_USAGE; @@ -238,7 +237,7 @@ MiRemovePageByColor(IN PFN_NUMBER PageIndex, Pfn1 = MI_PFN_ELEMENT(PageIndex); ASSERT(Pfn1->u3.e1.RemovalRequested == 0); ASSERT(Pfn1->u3.e1.Rom == 0); - + /* Capture data for later */ OldColor = Pfn1->u3.e1.PageColor; OldCache = Pfn1->u3.e1.CacheAttribute; @@ -248,14 +247,14 @@ MiRemovePageByColor(IN PFN_NUMBER PageIndex, ASSERT_LIST_INVARIANT(ListHead); ListName = ListHead->ListName; ASSERT(ListName <= FreePageList); - + /* Remove a page */ ListHead->Total--; /* Get the forward and back pointers */ OldFlink = Pfn1->u1.Flink; OldBlink = Pfn1->u2.Blink; - + /* Check if the next entry is the list head */ if (OldFlink != LIST_HEAD) { @@ -267,7 +266,7 @@ MiRemovePageByColor(IN PFN_NUMBER PageIndex, /* Set the list head's backlink instead */ ListHead->Blink = OldBlink; } - + /* Check if the back entry is the list head */ if (OldBlink != LIST_HEAD) { @@ -279,11 +278,11 @@ MiRemovePageByColor(IN PFN_NUMBER PageIndex, /* Set the list head's backlink instead */ ListHead->Flink = OldFlink; } - + /* We are not on a list anymore */ ASSERT_LIST_INVARIANT(ListHead); Pfn1->u1.Flink = Pfn1->u2.Blink = 0; - + /* Zero flags but restore color and cache */ Pfn1->u3.e2.ShortFlags = 0; Pfn1->u3.e1.PageColor = OldColor; @@ -293,25 +292,25 @@ MiRemovePageByColor(IN PFN_NUMBER PageIndex, ASSERT(Color < MmSecondaryColors); ColorTable = &MmFreePagesByColor[ListName][Color]; ASSERT(ColorTable->Count >= 1); - + /* Set the forward link to whoever we were pointing to */ ColorTable->Flink = Pfn1->OriginalPte.u.Long; - + /* Get the first page on the color list */ if (ColorTable->Flink == LIST_HEAD) { /* This is the beginning of the list, so set the sentinel value */ - ColorTable->Blink = (PVOID)LIST_HEAD; + ColorTable->Blink = (PVOID)LIST_HEAD; } else { /* The list is empty, so we are the first page */ MI_PFN_ELEMENT(ColorTable->Flink)->u4.PteFrame = COLORED_LIST_HEAD; } - + /* One less page */ ColorTable->Count--; - + /* ReactOS Hack */ Pfn1->OriginalPte.u.Long = 0; @@ -326,7 +325,7 @@ MiRemovePageByColor(IN PFN_NUMBER PageIndex, /* Signal the low memory event */ KeSetEvent(MiLowMemoryEvent, 0, FALSE); } - + /* One less page */ if (--MmAvailablePages < MmMinimumFreePages) { @@ -396,7 +395,7 @@ MiRemoveAnyPage(IN ULONG Color) ASSERT(Pfn1->u2.ShareCount == 0); ASSERT_LIST_INVARIANT(&MmFreePageListHead); ASSERT_LIST_INVARIANT(&MmZeroedPageListHead); - + /* Return the page */ return PageIndex; } @@ -457,10 +456,10 @@ MiRemoveZeroPage(IN ULONG Color) /* Remove the page from its list */ PageIndex = MiRemovePageByColor(PageIndex, Color); ASSERT(Pfn1 == MI_PFN_ELEMENT(PageIndex)); - + /* Zero it, if needed */ if (Zero) MiZeroPhysicalPage(PageIndex); - + /* Sanity checks */ ASSERT(Pfn1->u3.e2.ReferenceCount == 0); ASSERT(Pfn1->u2.ShareCount == 0); @@ -562,18 +561,18 @@ MiInsertPageInFreeList(IN PFN_NUMBER PageFrameIndex) { /* Get the previous page */ Blink = (PMMPFN)ColorTable->Blink; - + /* Make it link to us, and link back to it */ Blink->OriginalPte.u.Long = PageFrameIndex; Pfn1->u4.PteFrame = MiGetPfnEntryIndex(Blink); } - + /* Now initialize our own list pointers */ ColorTable->Blink = Pfn1; /* This page is now the last */ Pfn1->OriginalPte.u.Long = LIST_HEAD; - + /* And increase the count in the colored list */ ColorTable->Count++; @@ -584,7 +583,7 @@ MiInsertPageInFreeList(IN PFN_NUMBER PageFrameIndex) MmZeroingPageThreadActive = TRUE; KeSetEvent(&MmZeroingPageEvent, IO_NO_INCREMENT, FALSE); } - + #if MI_TRACE_PFNS Pfn1->PfnUsage = MI_USAGE_FREE_PAGE; RtlZeroMemory(Pfn1->ProcessName, 16); @@ -608,12 +607,12 @@ MiInsertPageInList(IN PMMPFNLIST ListHead, /* Make sure the lock is held */ ASSERT(KeGetCurrentIrql() == DISPATCH_LEVEL); - + /* Make sure the PFN is valid */ ASSERT((PageFrameIndex) && (PageFrameIndex <= MmHighestPhysicalPage) && (PageFrameIndex >= MmLowestPhysicalPage)); - + /* Page should be unused */ Pfn1 = MI_PFN_ELEMENT(PageFrameIndex); ASSERT(Pfn1->u3.e2.ReferenceCount == 0); @@ -653,7 +652,7 @@ MiInsertPageInList(IN PMMPFNLIST ListHead, /* One more page on the system */ MmAvailablePages++; - + /* Check if we've reached the configured low memory threshold */ if (MmAvailablePages == MmLowMemoryThreshold) { @@ -701,7 +700,7 @@ MiInsertPageInList(IN PMMPFNLIST ListHead, /* One more paged on the colored list */ ColorHead->Count++; - + #if MI_TRACE_PFNS //ASSERT(MI_PFN_CURRENT_USAGE == MI_USAGE_NOT_SET); Pfn1->PfnUsage = MI_USAGE_FREE_PAGE; @@ -730,7 +729,7 @@ MiInitializePfn(IN PFN_NUMBER PageFrameIndex, { /* Only valid from MmCreateProcessAddressSpace path */ ASSERT(PsGetCurrentProcess()->Vm.WorkingSetSize == 0); - + /* Make this a demand zero PTE */ MI_MAKE_SOFTWARE_PTE(&Pfn1->OriginalPte, MM_READWRITE); } @@ -788,20 +787,20 @@ MiAllocatePfn(IN PMMPTE PointerPte, /* Sanity check that we aren't passed a valid PTE */ ASSERT(PointerPte->u.Hard.Valid == 0); - + /* Make an empty software PTE */ MI_MAKE_SOFTWARE_PTE(&TempPte, MM_READWRITE); - + /* Lock the PFN database */ OldIrql = KeAcquireQueuedSpinLock(LockQueuePfnLock); - + /* Check if we're running low on pages */ if (MmAvailablePages < 128) { DPRINT1("Warning, running low on memory: %d pages left\n", MmAvailablePages); //MiEnsureAvailablePageOrWait(NULL, OldIrql); } - + /* Grab a page */ ASSERT_LIST_INVARIANT(&MmFreePageListHead); ASSERT_LIST_INVARIANT(&MmZeroedPageListHead); @@ -810,10 +809,10 @@ MiAllocatePfn(IN PMMPTE PointerPte, /* Write the software PTE */ MI_WRITE_INVALID_PTE(PointerPte, TempPte); PointerPte->u.Soft.Protection |= Protection; - + /* Initialize its PFN entry */ MiInitializePfn(PageFrameIndex, PointerPte, TRUE); - + /* Release the PFN lock and return the page */ ASSERT_LIST_INVARIANT(&MmFreePageListHead); ASSERT_LIST_INVARIANT(&MmZeroedPageListHead); @@ -852,10 +851,10 @@ MiDecrementShareCount(IN PMMPFN Pfn1, /* Put the page in transition */ Pfn1->u3.e1.PageLocation = TransitionPage; - + /* PFN lock must be held */ ASSERT(KeGetCurrentIrql() == DISPATCH_LEVEL); - + /* Page should at least have one reference */ ASSERT(Pfn1->u3.e2.ReferenceCount != 0); if (Pfn1->u3.e2.ReferenceCount == 1) @@ -931,14 +930,14 @@ MiInitializePfnForOtherProcess(IN PFN_NUMBER PageFrameIndex, IN PFN_NUMBER PteFrame) { PMMPFN Pfn1; - + /* Setup the PTE */ Pfn1 = MI_PFN_ELEMENT(PageFrameIndex); Pfn1->PteAddress = PointerPte; /* Make this a software PTE */ MI_MAKE_SOFTWARE_PTE(&Pfn1->OriginalPte, MM_READWRITE); - + /* Setup the page */ ASSERT(Pfn1->u3.e2.ReferenceCount == 0); Pfn1->u3.e2.ReferenceCount = 1; @@ -946,14 +945,14 @@ MiInitializePfnForOtherProcess(IN PFN_NUMBER PageFrameIndex, Pfn1->u3.e1.PageLocation = ActiveAndValid; Pfn1->u3.e1.Modified = TRUE; Pfn1->u4.InPageError = FALSE; - + /* Did we get a PFN for the page table */ if (PteFrame) { /* Store it */ Pfn1->u4.PteFrame = PteFrame; - - /* Increase its share count so we don't get rid of it */ + + /* Increase its share count so we don't get rid of it */ Pfn1 = MI_PFN_ELEMENT(PteFrame); Pfn1->u2.ShareCount++; } diff --git a/reactos/ntoskrnl/mm/ARM3/pool.c b/reactos/ntoskrnl/mm/ARM3/pool.c index 1efdbc513a1..76b84db1e40 100644 --- a/reactos/ntoskrnl/mm/ARM3/pool.c +++ b/reactos/ntoskrnl/mm/ARM3/pool.c @@ -12,7 +12,6 @@ #define NDEBUG #include -#line 15 "ARM³::POOL" #define MODULE_INVOLVED_IN_ARM3 #include "../ARM3/miarm.h" @@ -55,7 +54,7 @@ MiProtectFreeNonPagedPool(IN PVOID VirtualAddress, TempPte.u.Soft.Prototype = 1; MI_WRITE_INVALID_PTE(PointerPte, TempPte); } while (++PointerPte < LastPte); - + /* Flush the TLB */ KeFlushEntireTb(TRUE, TRUE); } @@ -71,11 +70,11 @@ MiUnProtectFreeNonPagedPool(IN PVOID VirtualAddress, /* If pool is physical, can't protect PTEs */ if (MI_IS_PHYSICAL_ADDRESS(VirtualAddress)) return FALSE; - + /* Get, and capture the PTE */ PointerPte = MiAddressToPte(VirtualAddress); TempPte = *PointerPte; - + /* Loop protected PTEs */ while ((TempPte.u.Hard.Valid == 0) && (TempPte.u.Soft.Prototype == 1)) { @@ -83,14 +82,14 @@ MiUnProtectFreeNonPagedPool(IN PVOID VirtualAddress, TempPte.u.Hard.Valid = 1; TempPte.u.Soft.Prototype = 0; MI_WRITE_VALID_PTE(PointerPte, TempPte); - + /* One more page */ if (++UnprotectedPages == PageCount) break; - + /* Capture next PTE */ TempPte = *(++PointerPte); } - + /* Return if any pages were unprotected */ return UnprotectedPages ? TRUE : FALSE; } @@ -103,27 +102,27 @@ MiProtectedPoolUnProtectLinks(IN PLIST_ENTRY Links, { BOOLEAN Safe; PVOID PoolVa; - + /* Initialize variables */ *PoolFlink = *PoolBlink = NULL; - + /* Check if the list has entries */ if (IsListEmpty(Links) == FALSE) { /* We are going to need to forward link to do an insert */ PoolVa = Links->Flink; - + /* So make it safe to access */ Safe = MiUnProtectFreeNonPagedPool(PoolVa, 1); if (Safe) PoolFlink = PoolVa; } - + /* Are we going to need a backward link too? */ if (Links != Links->Blink) { /* Get the head's backward link for the insert */ PoolVa = Links->Blink; - + /* Make it safe to access */ Safe = MiUnProtectFreeNonPagedPool(PoolVa, 1); if (Safe) PoolBlink = PoolVa; @@ -147,13 +146,13 @@ MiProtectedPoolInsertList(IN PLIST_ENTRY ListHead, IN BOOLEAN Critical) { PVOID PoolFlink, PoolBlink; - + /* Make the list accessible */ MiProtectedPoolUnProtectLinks(ListHead, &PoolFlink, &PoolBlink); - + /* Now insert in the right position */ Critical ? InsertHeadList(ListHead, Entry) : InsertTailList(ListHead, Entry); - + /* And reprotect the pages containing the free links */ MiProtectedPoolProtectLinks(PoolFlink, PoolBlink); } @@ -163,13 +162,13 @@ NTAPI MiProtectedPoolRemoveEntryList(IN PLIST_ENTRY Entry) { PVOID PoolFlink, PoolBlink; - + /* Make the list accessible */ MiProtectedPoolUnProtectLinks(Entry, &PoolFlink, &PoolBlink); - + /* Now remove */ RemoveEntryList(Entry); - + /* And reprotect the pages containing the free links */ if (PoolFlink) MiProtectFreeNonPagedPool(PoolFlink, 1); if (PoolBlink) MiProtectFreeNonPagedPool(PoolBlink, 1); @@ -294,7 +293,7 @@ MiInitializeNonPagedPool(VOID) // PoolPages = BYTES_TO_PAGES(MmSizeOfNonPagedPoolInBytes); MmNumberOfFreeNonPagedPool = PoolPages; - + // // Initialize the first free entry // @@ -309,7 +308,7 @@ MiInitializeNonPagedPool(VOID) // InsertHeadList(&MmNonPagedPoolFreeListHead[MI_MAX_FREE_PAGE_LISTS - 1], &FreeEntry->List); - + // // Now create free entries for every single other page // @@ -329,37 +328,37 @@ MiInitializeNonPagedPool(VOID) PointerPte = MiAddressToPte(MmNonPagedPoolStart); ASSERT(PointerPte->u.Hard.Valid == 1); MiStartOfInitialPoolFrame = PFN_FROM_PTE(PointerPte); - + // // Keep track of where initial nonpaged pool ends // MmNonPagedPoolEnd0 = (PVOID)((ULONG_PTR)MmNonPagedPoolStart + MmSizeOfNonPagedPoolInBytes); - + // // Validate and remember last allocated pool page // PointerPte = MiAddressToPte((PVOID)((ULONG_PTR)MmNonPagedPoolEnd0 - 1)); ASSERT(PointerPte->u.Hard.Valid == 1); MiEndOfInitialPoolFrame = PFN_FROM_PTE(PointerPte); - + // // Validate the first nonpaged pool expansion page (which is a guard page) // PointerPte = MiAddressToPte(MmNonPagedPoolExpansionStart); ASSERT(PointerPte->u.Hard.Valid == 0); - + // // Calculate the size of the expansion region alone // MiExpansionPoolPagesInitialCharge = BYTES_TO_PAGES(MmMaximumNonPagedPoolInBytes - MmSizeOfNonPagedPoolInBytes); - + // // Remove 2 pages, since there's a guard page on top and on the bottom // MiExpansionPoolPagesInitialCharge -= 2; - + // // Now initialize the nonpaged pool expansion PTE space. Remember there's a // guard page on top so make sure to skip it. The bottom guard page will be @@ -388,12 +387,12 @@ MiAllocatePoolPages(IN POOL_TYPE PoolType, PVOID BaseVa, BaseVaStart; PMMFREE_POOL_ENTRY FreeEntry; PKSPIN_LOCK_QUEUE LockQueue; - + // // Figure out how big the allocation is in pages // SizeInPages = BYTES_TO_PAGES(SizeInBytes); - + // // Handle paged pool // @@ -403,7 +402,7 @@ MiAllocatePoolPages(IN POOL_TYPE PoolType, // Lock the paged pool mutex // KeAcquireGuardedMutex(&MmPagedPoolMutex); - + // // Find some empty allocation space // @@ -417,7 +416,7 @@ MiAllocatePoolPages(IN POOL_TYPE PoolType, // i = ((SizeInPages - 1) / PTE_COUNT) + 1; DPRINT1("Paged pool expansion: %d %x\n", i, SizeInPages); - + // // Check if there is enougn paged pool expansion space left // @@ -431,17 +430,17 @@ MiAllocatePoolPages(IN POOL_TYPE PoolType, KeReleaseGuardedMutex(&MmPagedPoolMutex); return NULL; } - + // // Check if we'll have to expand past the last PTE we have available - // + // if (((i - 1) + MmPagedPoolInfo.NextPdeForPagedPoolExpansion) > (PMMPDE)MiAddressToPte(MmPagedPoolInfo.LastPteForPagedPool)) { // // We can only support this much then // - PageTableCount = (PMMPDE)MiAddressToPte(MmPagedPoolInfo.LastPteForPagedPool) - + PageTableCount = (PMMPDE)MiAddressToPte(MmPagedPoolInfo.LastPteForPagedPool) - MmPagedPoolInfo.NextPdeForPagedPoolExpansion + 1; ASSERT(PageTableCount < i); @@ -454,30 +453,30 @@ MiAllocatePoolPages(IN POOL_TYPE PoolType, // PageTableCount = i; } - + // // Get the template PDE we'll use to expand // TempPde = ValidKernelPde; - + // // Get the first PTE in expansion space // PointerPde = MmPagedPoolInfo.NextPdeForPagedPoolExpansion; BaseVa = MiPdeToAddress(PointerPde); BaseVaStart = BaseVa; - + // // Lock the PFN database and loop pages - // - OldIrql = KeAcquireQueuedSpinLock(LockQueuePfnLock); + // + OldIrql = KeAcquireQueuedSpinLock(LockQueuePfnLock); do { // // It should not already be valid // ASSERT(PointerPde->u.Hard.Valid == 0); - + /* Request a page */ MI_SET_USAGE(MI_USAGE_PAGED_POOL); MI_SET_PROCESS2("Kernel"); @@ -491,15 +490,15 @@ MiAllocatePoolPages(IN POOL_TYPE PoolType, // Save it into our double-buffered system page directory // MmSystemPagePtes[((ULONG_PTR)PointerPde & (SYSTEM_PD_SIZE - 1)) / sizeof(MMPTE)] = TempPde; - + /* Initialize the PFN */ MiInitializePfnForOtherProcess(PageFrameNumber, (PMMPTE)PointerPde, MmSystemPageDirectory[(PointerPde - MiAddressToPde(NULL)) / PDE_COUNT]); - + /* Write the actual PDE now */ MI_WRITE_VALID_PDE(PointerPde, TempPde); -#endif +#endif // // Move on to the next expansion address // @@ -507,12 +506,12 @@ MiAllocatePoolPages(IN POOL_TYPE PoolType, BaseVa = (PVOID)((ULONG_PTR)BaseVa + PAGE_SIZE); i--; } while (i > 0); - + // // Release the PFN database lock - // + // KeReleaseQueuedSpinLock(LockQueuePfnLock, OldIrql); - + // // These pages are now available, clear their availablity bits // @@ -522,24 +521,24 @@ MiAllocatePoolPages(IN POOL_TYPE PoolType, RtlClearBits(MmPagedPoolInfo.PagedPoolAllocationMap, EndAllocation, PageTableCount * PTE_COUNT); - + // // Update the next expansion location // MmPagedPoolInfo.NextPdeForPagedPoolExpansion += PageTableCount; - + // // Zero out the newly available memory // RtlZeroMemory(BaseVaStart, PageTableCount * PAGE_SIZE); - + // // Now try consuming the pages again // i = RtlFindClearBitsAndSet(MmPagedPoolInfo.PagedPoolAllocationMap, SizeInPages, 0); - if (i == 0xFFFFFFFF) + if (i == 0xFFFFFFFF) { // // Out of memory! @@ -549,37 +548,37 @@ MiAllocatePoolPages(IN POOL_TYPE PoolType, return NULL; } } - + // // Update the pool hint if the request was just one page // if (SizeInPages == 1) MmPagedPoolInfo.PagedPoolHint = i + 1; - + // // Update the end bitmap so we know the bounds of this allocation when // the time comes to free it // EndAllocation = i + SizeInPages - 1; RtlSetBit(MmPagedPoolInfo.EndOfPagedPoolBitmap, EndAllocation); - + // // Now we can release the lock (it mainly protects the bitmap) // KeReleaseGuardedMutex(&MmPagedPoolMutex); - + // // Now figure out where this allocation starts // BaseVa = (PVOID)((ULONG_PTR)MmPagedPoolStart + (i << PAGE_SHIFT)); - + // // Flush the TLB // KeFlushEntireTb(TRUE, TRUE); - + /* Setup a demand-zero writable PTE */ MI_MAKE_SOFTWARE_PTE(&TempPte, MM_READWRITE); - + // // Find the first and last PTE, then loop them all // @@ -592,25 +591,25 @@ MiAllocatePoolPages(IN POOL_TYPE PoolType, // MI_WRITE_INVALID_PTE(PointerPte, TempPte); } while (++PointerPte < StartPte); - + // // Return the allocation address to the caller // return BaseVa; - } - + } + // // Allocations of less than 4 pages go into their individual buckets // i = SizeInPages - 1; if (i >= MI_MAX_FREE_PAGE_LISTS) i = MI_MAX_FREE_PAGE_LISTS - 1; - + // // Loop through all the free page lists based on the page index // NextHead = &MmNonPagedPoolFreeListHead[i]; LastHead = &MmNonPagedPoolFreeListHead[MI_MAX_FREE_PAGE_LISTS]; - + // // Acquire the nonpaged pool lock // @@ -629,7 +628,7 @@ MiAllocatePoolPages(IN POOL_TYPE PoolType, /* We need to be able to touch this page, unprotect it */ MiUnProtectFreeNonPagedPool(NextEntry, 0); } - + // // Grab the entry and see if it can handle our allocation // @@ -647,12 +646,12 @@ MiAllocatePoolPages(IN POOL_TYPE PoolType, // BaseVa = (PVOID)((ULONG_PTR)FreeEntry + (FreeEntry->Size << PAGE_SHIFT)); - + /* Remove the item from the list, depending if pool is protected */ MmProtectFreedNonPagedPool ? MiProtectedPoolRemoveEntryList(&FreeEntry->List) : RemoveEntryList(&FreeEntry->List); - + // // However, check if its' still got space left // @@ -666,7 +665,7 @@ MiAllocatePoolPages(IN POOL_TYPE PoolType, MmProtectFreedNonPagedPool ? MiProtectedPoolInsertList(&MmNonPagedPoolFreeListHead[i], &FreeEntry->List, TRUE) : InsertTailList(&MmNonPagedPoolFreeListHead[i], &FreeEntry->List); - + /* Is freed non paged pool protected? */ if (MmProtectFreedNonPagedPool) { @@ -674,28 +673,28 @@ MiAllocatePoolPages(IN POOL_TYPE PoolType, MiProtectFreeNonPagedPool(FreeEntry, FreeEntry->Size); } } - + // // Grab the PTE for this allocation // PointerPte = MiAddressToPte(BaseVa); ASSERT(PointerPte->u.Hard.Valid == 1); - + // // Grab the PFN NextEntry and index // Pfn1 = MiGetPfnEntry(PFN_FROM_PTE(PointerPte)); - + // // Now mark it as the beginning of an allocation // ASSERT(Pfn1->u3.e1.StartOfAllocation == 0); Pfn1->u3.e1.StartOfAllocation = 1; - + /* Mark it as special pool if needed */ ASSERT(Pfn1->u4.VerifierAllocation == 0); if (PoolType & 64) Pfn1->u4.VerifierAllocation = 1; - + // // Check if the allocation is larger than one page // @@ -708,25 +707,25 @@ MiAllocatePoolPages(IN POOL_TYPE PoolType, ASSERT(PointerPte->u.Hard.Valid == 1); Pfn1 = MiGetPfnEntry(PointerPte->u.Hard.PageFrameNumber); } - + // // Mark this PFN as the last (might be the same as the first) // ASSERT(Pfn1->u3.e1.EndOfAllocation == 0); Pfn1->u3.e1.EndOfAllocation = 1; - + // // Release the nonpaged pool lock, and return the allocation // KeReleaseQueuedSpinLock(LockQueueMmNonPagedPoolLock, OldIrql); return BaseVa; } - + // // Try the next free page entry // NextEntry = FreeEntry->List.Flink; - + /* Is freed non paged pool protected? */ if (MmProtectFreedNonPagedPool) { @@ -735,7 +734,7 @@ MiAllocatePoolPages(IN POOL_TYPE PoolType, } } } while (++NextHead < LastHead); - + // // If we got here, we're out of space. // Start by releasing the lock @@ -755,18 +754,18 @@ MiAllocatePoolPages(IN POOL_TYPE PoolType, DPRINT1("Out of NP Expansion Pool\n"); return NULL; } - + // // Acquire the pool lock now // OldIrql = KeAcquireQueuedSpinLock(LockQueueMmNonPagedPoolLock); - + // // Lock the PFN database too // LockQueue = &KeGetCurrentPrcb()->LockQueue[LockQueuePfnLock]; KeAcquireQueuedSpinLockAtDpcLevel(LockQueue); - + // // Loop the pages // @@ -777,7 +776,7 @@ MiAllocatePoolPages(IN POOL_TYPE PoolType, MI_SET_USAGE(MI_USAGE_PAGED_POOL); MI_SET_PROCESS2("Kernel"); PageFrameNumber = MiRemoveAnyPage(MI_GET_NEXT_COLOR()); - + /* Get the PFN entry for it and fill it out */ Pfn1 = MiGetPfnEntry(PageFrameNumber); Pfn1->u3.e2.ReferenceCount = 1; @@ -785,33 +784,33 @@ MiAllocatePoolPages(IN POOL_TYPE PoolType, Pfn1->PteAddress = PointerPte; Pfn1->u3.e1.PageLocation = ActiveAndValid; Pfn1->u4.VerifierAllocation = 0; - + /* Write the PTE for it */ TempPte.u.Hard.PageFrameNumber = PageFrameNumber; MI_WRITE_VALID_PTE(PointerPte++, TempPte); } while (--SizeInPages > 0); - + // // This is the last page // Pfn1->u3.e1.EndOfAllocation = 1; - + // // Get the first page and mark it as such // Pfn1 = MiGetPfnEntry(StartPte->u.Hard.PageFrameNumber); Pfn1->u3.e1.StartOfAllocation = 1; - + /* Mark it as a verifier allocation if needed */ ASSERT(Pfn1->u4.VerifierAllocation == 0); if (PoolType & 64) Pfn1->u4.VerifierAllocation = 1; - + // // Release the PFN and nonpaged pool lock // KeReleaseQueuedSpinLockFromDpcLevel(LockQueue); KeReleaseQueuedSpinLock(LockQueueMmNonPagedPoolLock, OldIrql); - + // // Return the address // @@ -828,7 +827,7 @@ MiFreePoolPages(IN PVOID StartingVa) KIRQL OldIrql; PMMFREE_POOL_ENTRY FreeEntry, NextEntry, LastEntry; ULONG i, End; - + // // Handle paged pool // @@ -840,56 +839,56 @@ MiFreePoolPages(IN PVOID StartingVa) // i = ((ULONG_PTR)StartingVa - (ULONG_PTR)MmPagedPoolStart) >> PAGE_SHIFT; End = i; - + // // Now use the end bitmap to scan until we find a set bit, meaning that // this allocation finishes here // while (!RtlTestBit(MmPagedPoolInfo.EndOfPagedPoolBitmap, End)) End++; - + // // Now calculate the total number of pages this allocation spans // NumberOfPages = End - i + 1; - + /* Delete the actual pages */ PointerPte = MmPagedPoolInfo.FirstPteForPagedPool + i; FreePages = MiDeleteSystemPageableVm(PointerPte, NumberOfPages, 0, NULL); ASSERT(FreePages == NumberOfPages); - + // // Acquire the paged pool lock // KeAcquireGuardedMutex(&MmPagedPoolMutex); - + // // Clear the allocation and free bits // RtlClearBit(MmPagedPoolInfo.EndOfPagedPoolBitmap, i); RtlClearBits(MmPagedPoolInfo.PagedPoolAllocationMap, i, NumberOfPages); - + // // Update the hint if we need to // if (i < MmPagedPoolInfo.PagedPoolHint) MmPagedPoolInfo.PagedPoolHint = i; - + // // Release the lock protecting the bitmaps // KeReleaseGuardedMutex(&MmPagedPoolMutex); - + // // And finally return the number of pages freed // return NumberOfPages; } - + // // Get the first PTE and its corresponding PFN entry // StartPte = PointerPte = MiAddressToPte(StartingVa); StartPfn = Pfn1 = MiGetPfnEntry(PointerPte->u.Hard.PageFrameNumber); - + // // Loop until we find the last PTE // @@ -901,33 +900,33 @@ MiFreePoolPages(IN PVOID StartingVa) PointerPte++; Pfn1 = MiGetPfnEntry(PointerPte->u.Hard.PageFrameNumber); } - + // // Now we know how many pages we have // NumberOfPages = PointerPte - StartPte + 1; - + // // Acquire the nonpaged pool lock // OldIrql = KeAcquireQueuedSpinLock(LockQueueMmNonPagedPoolLock); - + // // Mark the first and last PTEs as not part of an allocation anymore // - StartPfn->u3.e1.StartOfAllocation = 0; + StartPfn->u3.e1.StartOfAllocation = 0; Pfn1->u3.e1.EndOfAllocation = 0; - + // // Assume we will free as many pages as the allocation was // FreePages = NumberOfPages; - + // // Peek one page past the end of the allocation // PointerPte++; - + // // Guard against going past initial nonpaged pool // @@ -942,16 +941,16 @@ MiFreePoolPages(IN PVOID StartingVa) { /* Sanity check */ ASSERT((ULONG_PTR)StartingVa + NumberOfPages <= (ULONG_PTR)MmNonPagedPoolEnd); - + /* Check if protected pool is enabled */ if (MmProtectFreedNonPagedPool) { /* The freed block will be merged, it must be made accessible */ MiUnProtectFreeNonPagedPool(MiPteToAddress(PointerPte), 0); } - + // - // Otherwise, our entire allocation must've fit within the initial non + // Otherwise, our entire allocation must've fit within the initial non // paged pool, or the expansion nonpaged pool, so get the PFN entry of // the next allocation // @@ -960,7 +959,7 @@ MiFreePoolPages(IN PVOID StartingVa) // // It's either expansion or initial: get the PFN entry // - Pfn1 = MiGetPfnEntry(PointerPte->u.Hard.PageFrameNumber); + Pfn1 = MiGetPfnEntry(PointerPte->u.Hard.PageFrameNumber); } else { @@ -970,9 +969,9 @@ MiFreePoolPages(IN PVOID StartingVa) // Pfn1 = NULL; } - + } - + // // Check if this allocation actually exists // @@ -985,21 +984,21 @@ MiFreePoolPages(IN PVOID StartingVa) (NumberOfPages << PAGE_SHIFT)); ASSERT(FreeEntry->Signature == MM_FREE_POOL_SIGNATURE); ASSERT(FreeEntry->Owner == FreeEntry); - + /* Consume this entry's pages */ FreePages += FreeEntry->Size; - + /* Remove the item from the list, depending if pool is protected */ MmProtectFreedNonPagedPool ? MiProtectedPoolRemoveEntryList(&FreeEntry->List) : RemoveEntryList(&FreeEntry->List); } - + // // Now get the official free entry we'll create for the caller's allocation // FreeEntry = StartingVa; - + // // Check if the our allocation is the very first page // @@ -1016,14 +1015,14 @@ MiFreePoolPages(IN PVOID StartingVa) // Otherwise, get the PTE for the page right before our allocation // PointerPte -= NumberOfPages + 1; - + /* Check if protected pool is enabled */ if (MmProtectFreedNonPagedPool) { /* The freed block will be merged, it must be made accessible */ MiUnProtectFreeNonPagedPool(MiPteToAddress(PointerPte), 0); } - + /* Check if this is valid pool, or a guard page */ if (PointerPte->u.Hard.Valid == 1) { @@ -1040,7 +1039,7 @@ MiFreePoolPages(IN PVOID StartingVa) Pfn1 = NULL; } } - + // // Check if there is a valid PFN entry for the page before the allocation // and then check if this page was actually the end of an allocation. @@ -1054,14 +1053,14 @@ MiFreePoolPages(IN PVOID StartingVa) FreeEntry = (PMMFREE_POOL_ENTRY)((ULONG_PTR)StartingVa - PAGE_SIZE); ASSERT(FreeEntry->Signature == MM_FREE_POOL_SIGNATURE); FreeEntry = FreeEntry->Owner; - + /* Check if protected pool is enabled */ if (MmProtectFreedNonPagedPool) { /* The freed block will be merged, it must be made accessible */ MiUnProtectFreeNonPagedPool(FreeEntry, 0); } - + // // Check if the entry is small enough to be indexed on a free list // If it is, we'll want to re-insert it, since we're about to @@ -1073,18 +1072,18 @@ MiFreePoolPages(IN PVOID StartingVa) MmProtectFreedNonPagedPool ? MiProtectedPoolRemoveEntryList(&FreeEntry->List) : RemoveEntryList(&FreeEntry->List); - + // // Update its size // FreeEntry->Size += FreePages; - + // // And now find the new appropriate list to place it in // i = (ULONG)(FreeEntry->Size - 1); if (i >= MI_MAX_FREE_PAGE_LISTS) i = MI_MAX_FREE_PAGE_LISTS - 1; - + /* Insert the entry into the free list head, check for prot. pool */ MmProtectFreedNonPagedPool ? MiProtectedPoolInsertList(&MmNonPagedPoolFreeListHead[i], &FreeEntry->List, TRUE) : @@ -1098,7 +1097,7 @@ MiFreePoolPages(IN PVOID StartingVa) FreeEntry->Size += FreePages; } } - + // // Check if we were unable to do any compaction, and we'll stick with this // @@ -1109,30 +1108,30 @@ MiFreePoolPages(IN PVOID StartingVa) // pages, at best we have our pages plus whatever entry came after us // FreeEntry->Size = FreePages; - + // // Find the appropriate list we should be on // i = FreeEntry->Size - 1; if (i >= MI_MAX_FREE_PAGE_LISTS) i = MI_MAX_FREE_PAGE_LISTS - 1; - + /* Insert the entry into the free list head, check for prot. pool */ MmProtectFreedNonPagedPool ? MiProtectedPoolInsertList(&MmNonPagedPoolFreeListHead[i], &FreeEntry->List, TRUE) : InsertTailList(&MmNonPagedPoolFreeListHead[i], &FreeEntry->List); } - + // // Just a sanity check // ASSERT(FreePages != 0); - + // // Get all the pages between our allocation and its end. These will all now // become free page chunks. // NextEntry = StartingVa; - LastEntry = (PMMFREE_POOL_ENTRY)((ULONG_PTR)NextEntry + (FreePages << PAGE_SHIFT)); + LastEntry = (PMMFREE_POOL_ENTRY)((ULONG_PTR)NextEntry + (FreePages << PAGE_SHIFT)); do { // @@ -1142,14 +1141,14 @@ MiFreePoolPages(IN PVOID StartingVa) NextEntry->Signature = MM_FREE_POOL_SIGNATURE; NextEntry = (PMMFREE_POOL_ENTRY)((ULONG_PTR)NextEntry + PAGE_SIZE); } while (NextEntry != LastEntry); - + /* Is freed non paged pool protected? */ if (MmProtectFreedNonPagedPool) { /* Protect the freed pool! */ MiProtectFreeNonPagedPool(FreeEntry, FreeEntry->Size); } - + // // We're done, release the lock and let the caller know how much we freed // diff --git a/reactos/ntoskrnl/mm/ARM3/procsup.c b/reactos/ntoskrnl/mm/ARM3/procsup.c index afedcc21859..f40e5171256 100644 --- a/reactos/ntoskrnl/mm/ARM3/procsup.c +++ b/reactos/ntoskrnl/mm/ARM3/procsup.c @@ -12,7 +12,6 @@ #define NDEBUG #include -#line 15 "ARM³::PROCSUP" #define MODULE_INVOLVED_IN_ARM3 #include "../ARM3/miarm.h" @@ -60,11 +59,11 @@ MiCreatePebOrTeb(IN PEPROCESS Process, LARGE_INTEGER CurrentTime; TABLE_SEARCH_RESULT Result = TableFoundNode; PMMADDRESS_NODE Parent; - + /* Allocate a VAD */ Vad = ExAllocatePoolWithTag(NonPagedPool, sizeof(MMVAD_LONG), 'ldaV'); if (!Vad) return STATUS_NO_MEMORY; - + /* Setup the primary flags with the size, and make it commited, private, RW */ Vad->u.LongFlags = 0; Vad->u.VadFlags.CommitCharge = BYTES_TO_PAGES(Size); @@ -72,13 +71,13 @@ MiCreatePebOrTeb(IN PEPROCESS Process, Vad->u.VadFlags.PrivateMemory = TRUE; Vad->u.VadFlags.Protection = MM_READWRITE; Vad->u.VadFlags.NoChange = TRUE; - + /* Setup the secondary flags to make it a secured, writable, long VAD */ Vad->u2.LongFlags2 = 0; Vad->u2.VadFlags2.OneSecured = TRUE; Vad->u2.VadFlags2.LongVad = TRUE; Vad->u2.VadFlags2.ReadOnly = FALSE; - + /* Lock the process address space */ KeAcquireGuardedMutex(&Process->AddressCreationLock); @@ -120,23 +119,23 @@ MiCreatePebOrTeb(IN PEPROCESS Process, /* Bail out, if still nothing free was found */ if (Result == TableFoundNode) return STATUS_NO_MEMORY; } - + /* Validate that it came from the VAD ranges */ ASSERT(*Base >= (ULONG_PTR)MI_LOWEST_VAD_ADDRESS); - + /* Build the rest of the VAD now */ Vad->StartingVpn = (*Base) >> PAGE_SHIFT; Vad->EndingVpn = ((*Base) + Size - 1) >> PAGE_SHIFT; Vad->u3.Secured.StartVpn = *Base; Vad->u3.Secured.EndVpn = (Vad->EndingVpn << PAGE_SHIFT) | (PAGE_SIZE - 1); Vad->u1.Parent = NULL; - + /* FIXME: Should setup VAD bitmap */ Status = STATUS_SUCCESS; /* Pretend as if we own the working set */ MiLockProcessWorkingSet(Process, Thread); - + /* Insert the VAD */ ASSERT(Vad->EndingVpn >= Vad->StartingVpn); Process->VadRoot.NodeHint = Vad; @@ -166,20 +165,20 @@ MmDeleteTeb(IN PEPROCESS Process, PMMVAD Vad; PMM_AVL_TABLE VadTree = &Process->VadRoot; DPRINT("Deleting TEB: %p in %16s\n", Teb, Process->ImageFileName); - + /* TEB is one page */ TebEnd = (ULONG_PTR)Teb + ROUND_TO_PAGES(sizeof(TEB)) - 1; - + /* Attach to the process */ KeAttachProcess(&Process->Pcb); - + /* Lock the process address space */ KeAcquireGuardedMutex(&Process->AddressCreationLock); - + /* Find the VAD, make sure it's a TEB VAD */ Vad = MiLocateAddress(Teb); DPRINT("Removing node for VAD: %lx %lx\n", Vad->StartingVpn, Vad->EndingVpn); - ASSERT(Vad != NULL); + ASSERT(Vad != NULL); if (Vad->StartingVpn != ((ULONG_PTR)Teb >> PAGE_SHIFT)) { /* Bug in the AVL code? */ @@ -200,17 +199,17 @@ MmDeleteTeb(IN PEPROCESS Process, /* Remove this VAD from the tree */ ASSERT(VadTree->NumberGenericTableElements >= 1); MiRemoveNode((PMMADDRESS_NODE)Vad, VadTree); - + /* Release the working set */ MiUnlockProcessWorkingSet(Process, Thread); - + /* Remove the VAD */ ExFreePool(Vad); } /* Release the address space lock */ KeReleaseGuardedMutex(&Process->AddressCreationLock); - + /* Detach */ KeDetachProcess(); } @@ -225,22 +224,22 @@ MmDeleteKernelStack(IN PVOID StackBase, PMMPFN Pfn1;//, Pfn2; ULONG i; KIRQL OldIrql; - + // // This should be the guard page, so decrement by one // PointerPte = MiAddressToPte(StackBase); PointerPte--; - + // // Calculate pages used // StackPages = BYTES_TO_PAGES(GuiStack ? KERNEL_LARGE_STACK_SIZE : KERNEL_STACK_SIZE); - + /* Acquire the PFN lock */ OldIrql = KeAcquireQueuedSpinLock(LockQueuePfnLock); - + // // Loop them // @@ -258,28 +257,28 @@ MmDeleteKernelStack(IN PVOID StackBase, /* Now get the page of the page table mapping it */ PageTableFrameNumber = Pfn1->u4.PteFrame; Pfn2 = MiGetPfnEntry(PageTableFrameNumber); - + /* Remove a shared reference, since the page is going away */ MiDecrementShareCount(Pfn2, PageTableFrameNumber); #endif /* Set the special pending delete marker */ MI_SET_PFN_DELETED(Pfn1); - + /* And now delete the actual stack page */ MiDecrementShareCount(Pfn1, PageFrameNumber); } - + // // Next one // PointerPte--; } - + // // We should be at the guard page now // ASSERT(PointerPte->u.Hard.Valid == 0); - + /* Release the PFN lock */ KeReleaseQueuedSpinLock(LockQueuePfnLock, OldIrql); @@ -301,7 +300,7 @@ MmCreateKernelStack(IN BOOLEAN GuiStack, KIRQL OldIrql; PFN_NUMBER PageFrameIndex; ULONG i; - + // // Calculate pages needed // @@ -312,7 +311,7 @@ MmCreateKernelStack(IN BOOLEAN GuiStack, // StackPtes = BYTES_TO_PAGES(KERNEL_LARGE_STACK_SIZE); StackPages = BYTES_TO_PAGES(KERNEL_LARGE_STACK_COMMIT); - + } else { @@ -322,37 +321,37 @@ MmCreateKernelStack(IN BOOLEAN GuiStack, StackPtes = BYTES_TO_PAGES(KERNEL_STACK_SIZE); StackPages = StackPtes; } - + // // Reserve stack pages, plus a guard page // StackPte = MiReserveSystemPtes(StackPtes + 1, SystemPteSpace); if (!StackPte) return NULL; - + // // Get the stack address // BaseAddress = MiPteToAddress(StackPte + StackPtes + 1); - + // // Select the right PTE address where we actually start committing pages // PointerPte = StackPte; if (GuiStack) PointerPte += BYTES_TO_PAGES(KERNEL_LARGE_STACK_SIZE - KERNEL_LARGE_STACK_COMMIT); - + /* Setup the temporary invalid PTE */ MI_MAKE_SOFTWARE_PTE(&InvalidPte, MM_NOACCESS); /* Setup the template stack PTE */ MI_MAKE_HARDWARE_PTE_KERNEL(&TempPte, PointerPte + 1, MM_READWRITE, 0); - + // // Acquire the PFN DB lock // OldIrql = KeAcquireQueuedSpinLock(LockQueuePfnLock); - + // // Loop each stack page // @@ -362,7 +361,7 @@ MmCreateKernelStack(IN BOOLEAN GuiStack, // Next PTE // PointerPte++; - + /* Get a page and write the current invalid PTE */ MI_SET_USAGE(MI_USAGE_KERNEL_STACK); MI_SET_PROCESS2(PsGetCurrentProcess()->ImageFileName); @@ -371,7 +370,7 @@ MmCreateKernelStack(IN BOOLEAN GuiStack, /* Initialize the PFN entry for this page */ MiInitializePfn(PageFrameIndex, PointerPte, 1); - + /* Write the valid PTE */ TempPte.u.Hard.PageFrameNumber = PageFrameIndex; MI_WRITE_VALID_PTE(PointerPte, TempPte); @@ -381,7 +380,7 @@ MmCreateKernelStack(IN BOOLEAN GuiStack, // Release the PFN lock // KeReleaseQueuedSpinLock(LockQueuePfnLock, OldIrql); - + // // Return the stack address // @@ -398,25 +397,25 @@ MmGrowKernelStackEx(IN PVOID StackPointer, KIRQL OldIrql; MMPTE TempPte, InvalidPte; PFN_NUMBER PageFrameIndex; - + // // Make sure the stack did not overflow // ASSERT(((ULONG_PTR)Thread->StackBase - (ULONG_PTR)Thread->StackLimit) <= (KERNEL_LARGE_STACK_SIZE + PAGE_SIZE)); - + // // Get the current stack limit // LimitPte = MiAddressToPte(Thread->StackLimit); ASSERT(LimitPte->u.Hard.Valid == 1); - + // // Get the new one and make sure this isn't a retarded request // NewLimitPte = MiAddressToPte((PVOID)((ULONG_PTR)StackPointer - GrowSize)); if (NewLimitPte == LimitPte) return STATUS_SUCCESS; - + // // Now make sure you're not going past the reserved space // @@ -430,15 +429,15 @@ MmGrowKernelStackEx(IN PVOID StackPointer, DPRINT1("Thread wants too much stack\n"); return STATUS_STACK_OVERFLOW; } - + // // Calculate the number of new pages // LimitPte--; - + /* Setup the temporary invalid PTE */ MI_MAKE_SOFTWARE_PTE(&InvalidPte, MM_NOACCESS); - + // // Acquire the PFN DB lock // @@ -457,19 +456,19 @@ MmGrowKernelStackEx(IN PVOID StackPointer, /* Initialize the PFN entry for this page */ MiInitializePfn(PageFrameIndex, LimitPte, 1); - + /* Setup the template stack PTE */ MI_MAKE_HARDWARE_PTE_KERNEL(&TempPte, LimitPte, MM_READWRITE, PageFrameIndex); - + /* Write the valid PTE */ MI_WRITE_VALID_PTE(LimitPte--, TempPte); } - + // // Release the PFN lock // KeReleaseQueuedSpinLock(LockQueuePfnLock, OldIrql); - + // // Set the new limit // @@ -493,7 +492,7 @@ MmSetMemoryPriorityProcess(IN PEPROCESS Process, IN UCHAR MemoryPriority) { UCHAR OldPriority; - + // // Check if we have less then 16MB of Physical Memory // @@ -505,13 +504,13 @@ MmSetMemoryPriorityProcess(IN PEPROCESS Process, // MemoryPriority = MEMORY_PRIORITY_BACKGROUND; } - + // // Save the old priority and update it // OldPriority = (UCHAR)Process->Vm.Flags.MemoryPriority; Process->Vm.Flags.MemoryPriority = MemoryPriority; - + // // Return the old priority // @@ -524,12 +523,12 @@ MmGetSessionLocaleId(VOID) { PEPROCESS Process; PAGED_CODE(); - + // // Get the current process // Process = PsGetCurrentProcess(); - + // // Check if it's the Session Leader // @@ -548,7 +547,7 @@ MmGetSessionLocaleId(VOID) #endif } } - + // // Not a session leader, return the default // @@ -572,12 +571,12 @@ MmCreatePeb(IN PEPROCESS Process, KAFFINITY ProcessAffinityMask = 0; SectionOffset.QuadPart = (ULONGLONG)0; *BasePeb = NULL; - + // // Attach to Process // KeAttachProcess(&Process->Pcb); - + // // Allocate the PEB // @@ -598,7 +597,7 @@ MmCreatePeb(IN PEPROCESS Process, MEM_TOP_DOWN, PAGE_READONLY); if (!NT_SUCCESS(Status)) return Status; - + // // Use SEH in case we can't load the PEB // @@ -608,7 +607,7 @@ MmCreatePeb(IN PEPROCESS Process, // Initialize the PEB // RtlZeroMemory(Peb, sizeof(PEB)); - + // // Set up data // @@ -616,14 +615,14 @@ MmCreatePeb(IN PEPROCESS Process, Peb->InheritedAddressSpace = InitialPeb->InheritedAddressSpace; Peb->Mutant = InitialPeb->Mutant; Peb->ImageUsesLargePages = InitialPeb->ImageUsesLargePages; - + // // NLS // Peb->AnsiCodePageData = (PCHAR)TableBase + ExpAnsiCodePageDataOffset; Peb->OemCodePageData = (PCHAR)TableBase + ExpOemCodePageDataOffset; Peb->UnicodeCaseTableData = (PCHAR)TableBase + ExpUnicodeCaseTableDataOffset; - + // // Default Version Data (could get changed below) // @@ -632,7 +631,7 @@ MmCreatePeb(IN PEPROCESS Process, Peb->OSBuildNumber = (USHORT)(NtBuildNumber & 0x3FFF); Peb->OSPlatformId = 2; /* VER_PLATFORM_WIN32_NT */ Peb->OSCSDVersion = (USHORT)CmNtCSDVersion; - + // // Heap and Debug Data // @@ -648,7 +647,7 @@ MmCreatePeb(IN PEPROCESS Process, */ Peb->MaximumNumberOfHeaps = (PAGE_SIZE - sizeof(PEB)) / sizeof(PVOID); Peb->ProcessHeaps = (PVOID*)(Peb + 1); - + // // Session ID // @@ -663,7 +662,7 @@ MmCreatePeb(IN PEPROCESS Process, _SEH2_YIELD(return _SEH2_GetExceptionCode()); } _SEH2_END; - + // // Use SEH in case we can't load the image // @@ -684,7 +683,7 @@ MmCreatePeb(IN PEPROCESS Process, _SEH2_YIELD(return STATUS_INVALID_IMAGE_PROTECT); } _SEH2_END; - + // // Parse the headers // @@ -711,7 +710,7 @@ MmCreatePeb(IN PEPROCESS Process, sizeof(IMAGE_LOAD_CONFIG_DIRECTORY), sizeof(ULONG)); } - + // // Write subsystem data // @@ -732,7 +731,7 @@ MmCreatePeb(IN PEPROCESS Process, Peb->OSBuildNumber = (NtHeaders->OptionalHeader.Win32VersionValue >> 16) & 0x3FFF; Peb->OSPlatformId = (NtHeaders->OptionalHeader.Win32VersionValue >> 30) ^ 2; } - + // // Process the image config data overrides if specfied // @@ -748,7 +747,7 @@ MmCreatePeb(IN PEPROCESS Process, // Peb->OSCSDVersion = ImageConfigData->CSDVersion; } - + // // Process affinity mask ovverride // @@ -760,7 +759,7 @@ MmCreatePeb(IN PEPROCESS Process, ProcessAffinityMask = ImageConfigData->ProcessAffinityMask; } } - + // // Check if this is a UP image if (Characteristics & IMAGE_FILE_UP_SYSTEM_ONLY) @@ -788,7 +787,7 @@ MmCreatePeb(IN PEPROCESS Process, } _SEH2_END; } - + // // Detach from the Process // @@ -807,18 +806,18 @@ MmCreateTeb(IN PEPROCESS Process, PTEB Teb; NTSTATUS Status = STATUS_SUCCESS; *BaseTeb = NULL; - + // // Attach to Target // KeAttachProcess(&Process->Pcb); - + // // Allocate the TEB // Status = MiCreatePebOrTeb(Process, sizeof(TEB), (PULONG_PTR)&Teb); ASSERT(NT_SUCCESS(Status)); - + // // Use SEH in case we can't load the TEB // @@ -828,18 +827,18 @@ MmCreateTeb(IN PEPROCESS Process, // Initialize the PEB // RtlZeroMemory(Teb, sizeof(TEB)); - + // // Set TIB Data // Teb->NtTib.ExceptionList = EXCEPTION_CHAIN_END; Teb->NtTib.Self = (PNT_TIB)Teb; - + // // Identify this as an OS/2 V3.0 ("Cruiser") TIB // Teb->NtTib.Version = 30 << 8; - + // // Set TEB Data // @@ -847,7 +846,7 @@ MmCreateTeb(IN PEPROCESS Process, Teb->RealClientId = *ClientId; Teb->ProcessEnvironmentBlock = Process->Peb; Teb->CurrentLocale = PsDefaultThreadLocaleId; - + // // Check if we have a grandparent TEB // @@ -912,7 +911,7 @@ MiInitializeWorkingSetList(IN PEPROCESS CurrentProcess) MmWorkingSetList->FirstDynamic = 2; MmWorkingSetList->NextSlot = 3; MmWorkingSetList->LastInitializedWsle = 4; - + /* The rule is that the owner process is always in the FLINK of the PDE's PFN entry */ Pfn1 = MiGetPfnEntry(MiAddressToPte(PDE_BASE)->u.Hard.PageFrameNumber); ASSERT(Pfn1->u4.PteFrame == MiGetPfnEntryIndex(Pfn1)); @@ -940,14 +939,14 @@ MmInitializeProcessAddressSpace(IN PEPROCESS Process, PCHAR Destination; USHORT Length = 0; MMPTE TempPte; - + /* We should have a PDE */ ASSERT(Process->Pcb.DirectoryTableBase[0] != 0); ASSERT(Process->PdeUpdateNeeded == FALSE); /* Attach to the process */ KeAttachProcess(&Process->Pcb); - + /* The address space should now been in phase 1 or 0 */ ASSERT(Process->AddressSpaceInitialized <= 1); Process->AddressSpaceInitialized = 2; @@ -972,7 +971,7 @@ MmInitializeProcessAddressSpace(IN PEPROCESS Process, PointerPde = MiAddressToPde(HYPER_SPACE); PageFrameNumber = PFN_FROM_PTE(PointerPde); MiInitializePfn(PageFrameNumber, (PMMPTE)PointerPde, TRUE); - + /* Setup the PFN for the PTE for the working set */ PointerPte = MiAddressToPte(MI_WORKING_SET_LIST); MI_MAKE_HARDWARE_PTE(&TempPte, PointerPte, MM_READWRITE, 0); @@ -1057,7 +1056,7 @@ MmInitializeProcessAddressSpace(IN PEPROCESS Process, /* Save the pointer */ Process->SectionBaseAddress = ImageBase; } - + /* Be nice and detach */ KeDetachProcess(); @@ -1092,7 +1091,7 @@ NTAPI INIT_FUNCTION MmInitializeHandBuiltProcess2(IN PEPROCESS Process) { - /* Lock the VAD, ARM3-owned ranges away */ + /* Lock the VAD, ARM3-owned ranges away */ MiRosTakeOverPebTebRanges(Process); return STATUS_SUCCESS; } @@ -1116,13 +1115,13 @@ MmCreateProcessAddressSpace(IN ULONG MinWs, /* Choose a process color */ Process->NextPageColor = RtlRandom(&MmProcessColorSeed); - + /* Setup the hyperspace lock */ KeInitializeSpinLock(&Process->HyperSpaceLock); /* Lock PFN database */ OldIrql = KeAcquireQueuedSpinLock(LockQueuePfnLock); - + /* Get a zero page for the PDE, if possible */ Color = MI_GET_NEXT_PROCESS_COLOR(Process); MI_SET_USAGE(MI_USAGE_PAGE_DIRECTORY); @@ -1131,13 +1130,13 @@ MmCreateProcessAddressSpace(IN ULONG MinWs, { /* No zero pages, grab a free one */ PdeIndex = MiRemoveAnyPage(Color); - + /* Zero it outside the PFN lock */ KeReleaseQueuedSpinLock(LockQueuePfnLock, OldIrql); MiZeroPhysicalPage(PdeIndex); OldIrql = KeAcquireQueuedSpinLock(LockQueuePfnLock); } - + /* Get a zero page for hyperspace, if possible */ MI_SET_USAGE(MI_USAGE_PAGE_DIRECTORY); Color = MI_GET_NEXT_PROCESS_COLOR(Process); @@ -1146,7 +1145,7 @@ MmCreateProcessAddressSpace(IN ULONG MinWs, { /* No zero pages, grab a free one */ HyperIndex = MiRemoveAnyPage(Color); - + /* Zero it outside the PFN lock */ KeReleaseQueuedSpinLock(LockQueuePfnLock, OldIrql); MiZeroPhysicalPage(HyperIndex); @@ -1161,7 +1160,7 @@ MmCreateProcessAddressSpace(IN ULONG MinWs, { /* No zero pages, grab a free one */ WsListIndex = MiRemoveAnyPage(Color); - + /* Zero it outside the PFN lock */ KeReleaseQueuedSpinLock(LockQueuePfnLock, OldIrql); MiZeroPhysicalPage(WsListIndex); @@ -1183,7 +1182,7 @@ MmCreateProcessAddressSpace(IN ULONG MinWs, /* Make sure we don't already have a page directory setup */ ASSERT(Process->Pcb.DirectoryTableBase[0] == 0); - + /* Get a PTE to map hyperspace */ PointerPte = MiReserveSystemPtes(1, SystemPteSpace); ASSERT(PointerPte != NULL); @@ -1268,16 +1267,16 @@ MmCleanProcessAddressSpace(IN PEPROCESS Process) PMMVAD Vad; PMM_AVL_TABLE VadTree; PETHREAD Thread = PsGetCurrentThread(); - + /* Only support this */ ASSERT(Process->AddressSpaceInitialized == 2); - + /* Lock the process address space from changes */ MmLockAddressSpace(&Process->Vm); - + /* VM is deleted now */ Process->VmDeleted = TRUE; - + /* Enumerate the VADs */ VadTree = &Process->VadRoot; while (VadTree->NumberGenericTableElements) @@ -1294,7 +1293,7 @@ MmCleanProcessAddressSpace(IN PEPROCESS Process) /* Only regular VADs supported for now */ ASSERT(Vad->u.VadFlags.VadType == VadNone); - + /* Check if this is a section VAD */ if (!(Vad->u.VadFlags.PrivateMemory) && (Vad->ControlArea)) { @@ -1307,11 +1306,11 @@ MmCleanProcessAddressSpace(IN PEPROCESS Process) MiDeleteVirtualAddresses(Vad->StartingVpn << PAGE_SHIFT, (Vad->EndingVpn << PAGE_SHIFT) | (PAGE_SIZE - 1), Vad); - + /* Release the working set */ MiUnlockProcessWorkingSet(Process, Thread); } - + /* Skip ARM3 fake VADs, they'll be freed by MmDeleteProcessAddresSpace */ if (Vad->u.VadFlags.Spare == 1) { @@ -1319,11 +1318,11 @@ MmCleanProcessAddressSpace(IN PEPROCESS Process) Vad->u.VadFlags.Spare = 2; continue; } - + /* Free the VAD memory */ ExFreePool(Vad); } - + /* Release the address space */ MmUnlockAddressSpace(&Process->Vm); } diff --git a/reactos/ntoskrnl/mm/ARM3/section.c b/reactos/ntoskrnl/mm/ARM3/section.c index 12fd3fdfb0a..eee56cbf783 100644 --- a/reactos/ntoskrnl/mm/ARM3/section.c +++ b/reactos/ntoskrnl/mm/ARM3/section.c @@ -12,7 +12,6 @@ #define NDEBUG #include -#line 15 "ARM³::SECTION" #define MODULE_INVOLVED_IN_ARM3 #include "../ARM3/miarm.h" @@ -82,14 +81,14 @@ MiMakeProtectionMask(IN ULONG Protect) /* PAGE_EXECUTE_WRITECOMBINE is theoretically the maximum */ if (Protect >= (PAGE_WRITECOMBINE * 2)) return MM_INVALID_PROTECTION; - + /* * Windows API protection mask can be understood as two bitfields, differing * by whether or not execute rights are being requested */ Mask1 = Protect & 0xF; Mask2 = (Protect >> 4) & 0xF; - + /* Check which field is there */ if (!Mask1) { @@ -103,10 +102,10 @@ MiMakeProtectionMask(IN ULONG Protect) if (Mask2) return MM_INVALID_PROTECTION; ProtectMask = MmUserProtectionToMask1[Mask1]; } - + /* Make sure the final mask is a valid one */ if (ProtectMask == MM_INVALID_PROTECTION) return MM_INVALID_PROTECTION; - + /* Check for PAGE_GUARD option */ if (Protect & PAGE_GUARD) { @@ -117,41 +116,41 @@ MiMakeProtectionMask(IN ULONG Protect) /* Fail such requests */ return MM_INVALID_PROTECTION; } - + /* This actually turns on guard page in this scenario! */ ProtectMask |= MM_DECOMMIT; } - + /* Check for nocache option */ if (Protect & PAGE_NOCACHE) { /* The earlier check should've eliminated this possibility */ ASSERT((Protect & PAGE_GUARD) == 0); - + /* Check for no-access page or write combine page */ if ((ProtectMask == MM_NOACCESS) || (Protect & PAGE_WRITECOMBINE)) { /* Such a request is invalid */ return MM_INVALID_PROTECTION; } - + /* Add the PTE flag */ ProtectMask |= MM_NOCACHE; } - + /* Check for write combine option */ if (Protect & PAGE_WRITECOMBINE) { /* The two earlier scenarios should've caught this */ ASSERT((Protect & (PAGE_GUARD | PAGE_NOACCESS)) == 0); - + /* Don't allow on no-access pages */ if (ProtectMask == MM_NOACCESS) return MM_INVALID_PROTECTION; - + /* This actually turns on write-combine in this scenario! */ ProtectMask |= MM_NOACCESS; } - + /* Return the final MM PTE protection mask */ return ProtectMask; } @@ -170,7 +169,7 @@ MiInitializeSystemSpaceMap(IN PVOID InputSession OPTIONAL) /* Initialize the system space lock */ Session->SystemSpaceViewLockPointer = &Session->SystemSpaceViewLock; KeInitializeGuardedMutex(Session->SystemSpaceViewLockPointer); - + /* Set the start address */ Session->SystemSpaceViewStart = MiSystemViewStart; @@ -202,7 +201,7 @@ MiInitializeSystemSpaceMap(IN PVOID InputSession OPTIONAL) ' mM'); ASSERT(Session->SystemSpaceViewTable != NULL); RtlZeroMemory(Session->SystemSpaceViewTable, AllocSize); - + /* Success */ return TRUE; } @@ -263,7 +262,7 @@ MiAddMappedPtes(IN PMMPTE FirstPte, ASSERT(ControlArea->u.Flags.GlobalOnlyPerSession == 0); ASSERT(ControlArea->u.Flags.Rom == 0); ASSERT(ControlArea->FilePointer == NULL); - + /* Sanity checks */ ASSERT(PteCount != 0); ASSERT(ControlArea->NumberOfMappedViews >= 1); @@ -292,10 +291,10 @@ MiAddMappedPtes(IN PMMPTE FirstPte, UNIMPLEMENTED; while (TRUE); } - + /* The PTE should be completely clear */ ASSERT(PointerPte->u.Long == 0); - + /* Build the prototype PTE and write it */ MI_MAKE_PROTOTYPE_PTE(&TempPte, ProtoPte); MI_WRITE_INVALID_PTE(PointerPte, TempPte); @@ -327,7 +326,7 @@ MiFillSystemPageDirectory(IN PVOID Base, /* Find the system double-mapped PDE that describes this mapping */ SystemMapPde = &MmSystemPagePtes[((ULONG_PTR)PointerPde & (SYSTEM_PD_SIZE - 1)) / sizeof(MMPTE)]; - + /* Use the PDE template and loop the PDEs */ TempPde = ValidKernelPde; while (PointerPde <= LastPde) @@ -352,7 +351,7 @@ MiFillSystemPageDirectory(IN PVOID Base, /* Make the system PDE entry valid */ MI_WRITE_VALID_PDE(SystemMapPde, TempPde); - + /* The system PDE entry might be the PDE itself, so check for this */ if (PointerPde->u.Hard.Valid == 0) { @@ -375,10 +374,10 @@ MiCheckPurgeAndUpMapCount(IN PCONTROL_AREA ControlArea, IN BOOLEAN FailIfSystemViews) { KIRQL OldIrql; - + /* Flag not yet supported */ ASSERT(FailIfSystemViews == FALSE); - + /* Lock the PFN database */ OldIrql = KeAcquireQueuedSpinLock(LockQueuePfnLock); @@ -412,12 +411,12 @@ MiLocateSubsection(IN PMMVAD Vad, /* Get the subsection */ Subsection = (PSUBSECTION)(ControlArea + 1); - + /* We only support single-subsection segments */ ASSERT(Subsection->SubsectionBase != NULL); ASSERT(Vad->FirstPrototypePte >= Subsection->SubsectionBase); ASSERT(Vad->FirstPrototypePte < &Subsection->SubsectionBase[Subsection->PtesInSubsection]); - + /* Compute the PTE offset */ PteOffset = (ULONG_PTR)Vpn - Vad->StartingVpn; PteOffset += Vad->FirstPrototypePte - Subsection->SubsectionBase; @@ -425,7 +424,7 @@ MiLocateSubsection(IN PMMVAD Vad, /* Again, we only support single-subsection segments */ ASSERT(PteOffset < 0xF0000000); ASSERT(PteOffset < Subsection->PtesInSubsection); - + /* Return the subsection */ return Subsection; } @@ -448,7 +447,7 @@ MiSegmentDelete(IN PSEGMENT Segment) /* Make sure control area is on the right delete path */ ASSERT(ControlArea->u.Flags.BeingDeleted == 1); ASSERT(ControlArea->WritableUserReferences == 0); - + /* These things are not supported yet */ ASSERT(ControlArea->DereferenceList.Flink == NULL); ASSERT(!(ControlArea->u.Flags.Image) & !(ControlArea->u.Flags.File)); @@ -462,7 +461,7 @@ MiSegmentDelete(IN PSEGMENT Segment) /* Lock the PFN database */ OldIrql = KeAcquireQueuedSpinLock(LockQueuePfnLock); - + /* Check if the master PTE is invalid */ PteForProto = MiAddressToPte(PointerPte); if (!PteForProto->u.Hard.Valid) @@ -497,7 +496,7 @@ MiSegmentDelete(IN PSEGMENT Segment) PointerPte->u.Long = 0; PointerPte++; } - + /* Release the PFN lock */ KeReleaseQueuedSpinLock(LockQueuePfnLock, OldIrql); @@ -513,7 +512,7 @@ MiCheckControlArea(IN PCONTROL_AREA ControlArea, { BOOLEAN DeleteSegment = FALSE; ASSERT(KeGetCurrentIrql() == DISPATCH_LEVEL); - + /* Check if this is the last reference or view */ if (!(ControlArea->NumberOfMappedViews) && !(ControlArea->NumberOfSectionReferences)) @@ -531,7 +530,7 @@ MiCheckControlArea(IN PCONTROL_AREA ControlArea, /* Release the PFN lock */ KeReleaseQueuedSpinLock(LockQueuePfnLock, OldIrql); - + /* Delete the segment if needed */ if (DeleteSegment) { @@ -557,7 +556,7 @@ MiRemoveMappedView(IN PEPROCESS CurrentProcess, ASSERT(Vad->u2.VadFlags2.ExtendableFile == FALSE); ASSERT(ControlArea); ASSERT(ControlArea->FilePointer == NULL); - + /* Delete the actual virtual memory pages */ MiDeleteVirtualAddresses(Vad->StartingVpn << PAGE_SHIFT, (Vad->EndingVpn << PAGE_SHIFT) | (PAGE_SIZE - 1), @@ -600,17 +599,17 @@ MiMapViewInSystemSpace(IN PVOID Section, ASSERT(ControlArea->u.Flags.GlobalOnlyPerSession == 0); ASSERT(ControlArea->u.Flags.Rom == 0); ASSERT(ControlArea->u.Flags.WasPurged == 0); - + /* Increase the reference and map count on the control area, no purges yet */ Status = MiCheckPurgeAndUpMapCount(ControlArea, FALSE); ASSERT(NT_SUCCESS(Status)); - + /* Get the section size at creation time */ SectionSize = ((PSECTION)Section)->SizeOfSection.LowPart; /* If the caller didn't specify a view size, assume the whole section */ if (!(*ViewSize)) *ViewSize = SectionSize; - + /* Check if the caller wanted a larger section than the view */ if (*ViewSize > SectionSize) { @@ -622,7 +621,7 @@ MiMapViewInSystemSpace(IN PVOID Section, /* Get the number of 64K buckets required for this mapping */ Buckets = *ViewSize / MI_SYSTEM_VIEW_BUCKET_SIZE; if (*ViewSize & (MI_SYSTEM_VIEW_BUCKET_SIZE - 1)) Buckets++; - + /* Check if the view is more than 4GB large */ if (Buckets >= MI_SYSTEM_VIEW_BUCKET_SIZE) { @@ -645,7 +644,7 @@ MiMapViewInSystemSpace(IN PVOID Section, BYTES_TO_PAGES(*ViewSize), ControlArea); ASSERT(NT_SUCCESS(Status)); - + /* Return the base adress of the mapping and success */ *MappedBase = Base; return STATUS_SUCCESS; @@ -682,10 +681,10 @@ MiMapViewOfDataSection(IN PCONTROL_AREA ControlArea, ASSERT(ControlArea->u.Flags.Rom == 0); ASSERT(ControlArea->FilePointer == NULL); ASSERT(Segment->SegmentFlags.TotalNumberOfPtes4132 == 0); - + /* Based sections not supported */ ASSERT(Section->Address.StartingVpn == 0); - + /* These flags/parameters are not supported */ ASSERT((AllocationType & MEM_DOS_LIM) == 0); ASSERT((AllocationType & MEM_RESERVE) == 0); @@ -708,7 +707,7 @@ MiMapViewOfDataSection(IN PCONTROL_AREA ControlArea, { /* A size was specified, align it to a 64K boundary */ *ViewSize += SectionOffset->LowPart & (_64K - 1); - + /* Align the offset as well to make this an aligned map */ SectionOffset->LowPart &= ~((ULONG)_64K - 1); } @@ -725,11 +724,11 @@ MiMapViewOfDataSection(IN PCONTROL_AREA ControlArea, /* The offset must be in this segment's PTE chunk and it must be valid */ ASSERT(PteOffset < Segment->TotalNumberOfPtes); ASSERT(((SectionOffset->QuadPart + *ViewSize + PAGE_SIZE - 1) >> PAGE_SHIFT) >= PteOffset); - + /* In ARM3, only one subsection is used for now. It must contain these PTEs */ ASSERT(PteOffset < Subsection->PtesInSubsection); ASSERT(Subsection->SubsectionBase != NULL); - + /* In ARM3, only MEM_COMMIT is supported for now. The PTEs must've been committed */ ASSERT(Segment->NumberOfCommittedPages >= Segment->TotalNumberOfPtes); @@ -768,7 +767,7 @@ MiMapViewOfDataSection(IN PCONTROL_AREA ControlArea, /* Get the ending address, which is the last piece we need for the VAD */ EndingAddress = (StartAddress + *ViewSize - 1) | (PAGE_SIZE - 1); - + /* A VAD can now be allocated. Do so and zero it out */ Vad = ExAllocatePoolWithTag(NonPagedPool, sizeof(MMVAD), 'ldaV'); ASSERT(Vad); @@ -796,13 +795,13 @@ MiMapViewOfDataSection(IN PCONTROL_AREA ControlArea, /* Make sure the last PTE is valid and still within the subsection */ ASSERT(PteOffset < Subsection->PtesInSubsection); ASSERT(Vad->FirstPrototypePte <= Vad->LastContiguousPte); - + /* FIXME: Should setup VAD bitmap */ Status = STATUS_SUCCESS; /* Pretend as if we own the working set */ MiLockProcessWorkingSet(Process, Thread); - + /* Insert the VAD */ MiInsertVad(Vad, Process); @@ -836,7 +835,7 @@ MiCreatePagingFileMap(OUT PSEGMENT *Segment, /* No large pages in ARM3 yet */ ASSERT((AllocationAttributes & SEC_LARGE_PAGES) == 0); - + /* Pagefile-backed sections need a known size */ if (!(*MaximumSize)) return STATUS_INVALID_PARAMETER_4; @@ -861,7 +860,7 @@ MiCreatePagingFileMap(OUT PSEGMENT *Segment, 'tSmM'); ASSERT(NewSegment); *Segment = NewSegment; - + /* Now allocate the control area, which has the subsection structure */ ControlArea = ExAllocatePoolWithTag(NonPagedPool, sizeof(CONTROL_AREA) + sizeof(SUBSECTION), @@ -899,14 +898,14 @@ MiCreatePagingFileMap(OUT PSEGMENT *Segment, /* The subsection's base address is the first Prototype PTE in the segment */ Subsection->SubsectionBase = PointerPte; - + /* Start with an empty PTE, unless this is a commit operation */ TempPte.u.Long = 0; if (AllocationAttributes & SEC_COMMIT) { /* In which case, write down the protection mask in the Prototype PTEs */ TempPte.u.Soft.Protection = ProtectionMask; - + /* For accounting, also mark these pages as being committed */ NewSegment->NumberOfCommittedPages = PteCount; } @@ -926,7 +925,7 @@ MmGetFileObjectForSection(IN PVOID SectionObject) PSECTION_OBJECT Section; ASSERT(KeGetCurrentIrql() == PASSIVE_LEVEL); ASSERT(SectionObject != NULL); - + /* Check if it's an ARM3, or ReactOS section */ if ((ULONG_PTR)SectionObject & 1) { @@ -947,7 +946,7 @@ MmGetFileNameForFileObject(IN PFILE_OBJECT FileObject, POBJECT_NAME_INFORMATION ObjectNameInfo; NTSTATUS Status; ULONG ReturnLength; - + /* Allocate memory for our structure */ ObjectNameInfo = ExAllocatePoolWithTag(PagedPool, 1024, ' mM'); if (!ObjectNameInfo) return STATUS_NO_MEMORY; @@ -1038,7 +1037,7 @@ InvalidAddress: /* Unlock address space */ MmUnlockAddressSpace(AddressSpace); - + /* Get the filename of the section */ Status = MmGetFileNameForSection(Section, &ModuleNameInformation); } @@ -1047,7 +1046,7 @@ InvalidAddress: /* Get the VAD */ Vad = MiLocateAddress(Address); if (!Vad) goto InvalidAddress; - + /* Make sure it's not a VM VAD */ if (Vad->u.VadFlags.PrivateMemory == 1) { @@ -1056,22 +1055,22 @@ NotSection: MmUnlockAddressSpace(AddressSpace); return STATUS_SECTION_NOT_IMAGE; } - + /* Get the control area */ ControlArea = Vad->ControlArea; if (!(ControlArea) || !(ControlArea->u.Flags.Image)) goto NotSection; - + /* Get the file object */ FileObject = ControlArea->FilePointer; ASSERT(FileObject != NULL); ObReferenceObject(FileObject); - + /* Unlock address space */ MmUnlockAddressSpace(AddressSpace); - + /* Get the filename of the file object */ Status = MmGetFileNameForFileObject(FileObject, &ModuleNameInformation); - + /* Dereference it */ ObDereferenceObject(FileObject); } @@ -1092,7 +1091,7 @@ NotSection: ExFreePoolWithTag(ModuleNameInformation, ' mM'); DPRINT("Found ModuleName %S by address %p\n", ModuleName->Buffer, Address); } - + /* Return status */ return Status; } @@ -1174,7 +1173,7 @@ MmCreateArm3Section(OUT PVOID *SectionObject, ASSERT(ControlArea->u.Flags.GlobalOnlyPerSession == 0); ASSERT(ControlArea->u.Flags.Rom == 0); ASSERT(ControlArea->u.Flags.WasPurged == 0); - + /* A pagefile-backed mapping only has one subsection, and this is all ARM3 supports */ Subsection = (PSUBSECTION)(ControlArea + 1); ASSERT(Subsection->NextSubsection == NULL); @@ -1228,15 +1227,15 @@ MmMapViewOfArm3Section(IN PVOID SectionObject, /* Get the segment and control area */ Section = (PSECTION)SectionObject; ControlArea = Section->Segment->ControlArea; - + /* These flags/states are not yet supported by ARM3 */ ASSERT(Section->u.Flags.Image == 0); ASSERT(Section->u.Flags.NoCache == 0); ASSERT(Section->u.Flags.WriteCombined == 0); ASSERT((AllocationType & MEM_RESERVE) == 0); ASSERT(ControlArea->u.Flags.PhysicalMemory == 0); - - + + #if 0 /* FIXME: Check if the mapping protection is compatible with the create */ if (!MiIsProtectionCompatible(Section->InitialPageProtection, Protect)) @@ -1296,7 +1295,7 @@ MmMapViewOfArm3Section(IN PVOID SectionObject, DPRINT1("The protection is invalid\n"); return STATUS_INVALID_PAGE_PROTECTION; } - + /* We only handle pagefile-backed sections, which cannot be writecombined */ if (Protect & PAGE_WRITECOMBINE) { @@ -1310,7 +1309,7 @@ MmMapViewOfArm3Section(IN PVOID SectionObject, KeStackAttachProcess(&Process->Pcb, &ApcState); Attached = TRUE; } - + /* Lock the address space and make sure the process is alive */ MmLockAddressSpace(&Process->Vm); if (!Process->VmDeleted) @@ -1334,7 +1333,7 @@ MmMapViewOfArm3Section(IN PVOID SectionObject, DPRINT1("The process is dying\n"); Status = STATUS_PROCESS_IS_TERMINATING; } - + /* Unlock the address space and detatch if needed, then return status */ MmUnlockAddressSpace(&Process->Vm); if (Attached) KeUnstackDetachProcess(&ApcState); @@ -1454,9 +1453,9 @@ NtCreateSection(OUT PHANDLE SectionHandle, FileHandle, NULL); if (!NT_SUCCESS(Status)) return Status; - + /* FIXME: Should zero last page for a file mapping */ - + /* Now insert the object */ Status = ObInsertObject(SectionObject, NULL, @@ -1558,7 +1557,7 @@ NtMapViewOfSection(IN HANDLE SectionHandle, ACCESS_MASK DesiredAccess; ULONG ProtectionMask; KPROCESSOR_MODE PreviousMode = ExGetPreviousMode(); - + /* Check for invalid zero bits */ if (ZeroBits > 21) // per-arch? { @@ -1572,7 +1571,7 @@ NtMapViewOfSection(IN HANDLE SectionHandle, DPRINT1("Invalid inherit disposition\n"); return STATUS_INVALID_PARAMETER_8; } - + /* Allow only valid allocation types */ if ((AllocationType & ~(MEM_TOP_DOWN | MEM_LARGE_PAGES | MEM_DOS_LIM | SEC_NO_CHANGE | MEM_RESERVE))) @@ -1605,7 +1604,7 @@ NtMapViewOfSection(IN HANDLE SectionHandle, ProbeForWritePointer(BaseAddress); ProbeForWriteSize_t(ViewSize); } - + /* Check if a section offset was given */ if (SectionOffset) { @@ -1613,7 +1612,7 @@ NtMapViewOfSection(IN HANDLE SectionHandle, if (PreviousMode != KernelMode) ProbeForWriteLargeInteger(SectionOffset); SafeSectionOffset = *SectionOffset; } - + /* Capture the other parameters */ SafeBaseAddress = *BaseAddress; SafeViewSize = *ViewSize; @@ -1645,7 +1644,7 @@ NtMapViewOfSection(IN HANDLE SectionHandle, DPRINT1("Invalid zero bits\n"); return STATUS_INVALID_PARAMETER_4; } - + /* Reference the process */ Status = ObReferenceObjectByHandle(ProcessHandle, PROCESS_VM_OPERATION, @@ -1667,7 +1666,7 @@ NtMapViewOfSection(IN HANDLE SectionHandle, ObDereferenceObject(Process); return Status; } - + /* Now do the actual mapping */ Status = MmMapViewOfSection(Section, Process, @@ -1692,7 +1691,7 @@ NtMapViewOfSection(IN HANDLE SectionHandle, SafeSectionOffset.LowPart, SafeViewSize); } - + /* Return data only on success */ if (NT_SUCCESS(Status)) { @@ -1744,7 +1743,7 @@ NtUnmapViewOfSection(IN HANDLE ProcessHandle, /* Unmap the view */ Status = MmUnmapViewOfSection(Process, BaseAddress); - + /* Dereference the process and return status */ ObDereferenceObject(Process); return Status; @@ -1782,7 +1781,7 @@ NtExtendSection(IN HANDLE SectionHandle, /* Just read the size directly */ SafeNewMaximumSize = *NewMaximumSize; } - + /* Reference the section */ Status = ObReferenceObjectByHandle(SectionHandle, SECTION_EXTEND_SIZE, @@ -1799,12 +1798,12 @@ NtExtendSection(IN HANDLE SectionHandle, ObDereferenceObject(Section); return STATUS_SECTION_NOT_EXTENDED; } - + /* FIXME: Do the work */ /* Dereference the section */ ObDereferenceObject(Section); - + /* Enter SEH */ _SEH2_TRY { @@ -1816,7 +1815,7 @@ NtExtendSection(IN HANDLE SectionHandle, /* Nothing to do */ } _SEH2_END; - + /* Return the status */ return STATUS_NOT_IMPLEMENTED; } diff --git a/reactos/ntoskrnl/mm/ARM3/sysldr.c b/reactos/ntoskrnl/mm/ARM3/sysldr.c index 673ef30afa1..22d0792cc97 100644 --- a/reactos/ntoskrnl/mm/ARM3/sysldr.c +++ b/reactos/ntoskrnl/mm/ARM3/sysldr.c @@ -13,7 +13,6 @@ #define NDEBUG #include -#line 16 "ARM³::LOADER" #define MODULE_INVOLVED_IN_ARM3 #include "../ARM3/miarm.h" @@ -112,7 +111,7 @@ MiLoadImageSection(IN OUT PVOID *SectionPtr, /* Not session load, shouldn't have an entry */ ASSERT(LdrEntry == NULL); - + /* Attach to the system process */ KeStackAttachProcess(&PsInitialSystemProcess->Pcb, &ApcState); @@ -154,12 +153,12 @@ MiLoadImageSection(IN OUT PVOID *SectionPtr, KeUnstackDetachProcess(&ApcState); return Status; } - + /* Reserve system PTEs needed */ PteCount = ROUND_TO_PAGES(Section->ImageSection->ImageSize) >> PAGE_SHIFT; PointerPte = MiReserveSystemPtes(PteCount, SystemPteSpace); if (!PointerPte) return STATUS_INSUFFICIENT_RESOURCES; - + /* New driver base */ LastPte = PointerPte + PteCount; DriverBase = MiPteToAddress(PointerPte); @@ -182,7 +181,7 @@ MiLoadImageSection(IN OUT PVOID *SectionPtr, pos = wcsrchr(FileName->Buffer, '\\'); len = wcslen(pos) * sizeof(WCHAR); if (pos) snprintf(MI_PFN_CURRENT_PROCESS_NAME, min(16, len), "%S", pos); - } + } #endif TempPte.u.Hard.PageFrameNumber = MiAllocatePfn(PointerPte, MM_EXECUTE); @@ -192,7 +191,7 @@ MiLoadImageSection(IN OUT PVOID *SectionPtr, /* Move on */ PointerPte++; } - + /* Copy the image */ RtlCopyMemory(DriverBase, Base, PteCount << PAGE_SHIFT); @@ -386,14 +385,14 @@ MiDereferenceImports(IN PLOAD_IMPORTS ImportList) /* Then there's nothing to do */ return STATUS_SUCCESS; } - + /* Check for single-entry */ if ((ULONG_PTR)ImportList & MM_SYSLDR_SINGLE_ENTRY) { /* Set it up */ SingleEntry.Count = 1; SingleEntry.Entry[0] = (PVOID)((ULONG_PTR)ImportList &~ MM_SYSLDR_SINGLE_ENTRY); - + /* Use this as the import list */ ImportList = &SingleEntry; } @@ -404,24 +403,24 @@ MiDereferenceImports(IN PLOAD_IMPORTS ImportList) /* Get the entry */ LdrEntry = ImportList->Entry[i]; DPRINT1("%wZ <%wZ>\n", &LdrEntry->FullDllName, &LdrEntry->BaseDllName); - + /* Skip boot loaded images */ if (LdrEntry->LoadedImports == MM_SYSLDR_BOOT_LOADED) continue; - + /* Dereference the entry */ ASSERT(LdrEntry->LoadCount >= 1); if (!--LdrEntry->LoadCount) { /* Save the import data in case unload fails */ CurrentImports = LdrEntry->LoadedImports; - + /* This is the last entry */ LdrEntry->LoadedImports = MM_SYSLDR_NO_IMPORTS; if (MiCallDllUnloadAndUnloadDll(LdrEntry)) { /* Unloading worked, parse this DLL's imports too */ MiDereferenceImports(CurrentImports); - + /* Check if we had valid imports */ if ((CurrentImports != MM_SYSLDR_BOOT_LOADED) || (CurrentImports != MM_SYSLDR_NO_IMPORTS) || @@ -438,7 +437,7 @@ MiDereferenceImports(IN PLOAD_IMPORTS ImportList) } } } - + /* Done */ return STATUS_SUCCESS; } @@ -1454,7 +1453,7 @@ MiReloadBootLoadedDrivers(IN PLOADER_PARAMETER_BLOCK LoaderBlock) /* Remember the original address */ DllBase = LdrEntry->DllBase; - + /* Loop the PTEs */ PointerPte = StartPte; while (PointerPte < LastPte) @@ -1464,11 +1463,11 @@ MiReloadBootLoadedDrivers(IN PLOADER_PARAMETER_BLOCK LoaderBlock) Pfn1 = MiGetPfnEntry(PFN_FROM_PTE(PointerPte)); ASSERT(Pfn1->u3.e1.Rom == 0); Pfn1->u3.e1.Modified = TRUE; - + /* Next */ PointerPte++; } - + /* Now reserve system PTEs for the image */ PointerPte = MiReserveSystemPtes(PteCount, SystemPteSpace); if (!PointerPte) @@ -1477,7 +1476,7 @@ MiReloadBootLoadedDrivers(IN PLOADER_PARAMETER_BLOCK LoaderBlock) DPRINT1("[Mm0]: Couldn't allocate driver section!\n"); while (TRUE); } - + /* This is the new virtual address for the module */ LastPte = PointerPte + PteCount; NewImageAddress = MiPteToAddress(PointerPte); @@ -1485,7 +1484,7 @@ MiReloadBootLoadedDrivers(IN PLOADER_PARAMETER_BLOCK LoaderBlock) /* Sanity check */ DPRINT("[Mm0]: Copying from: %p to: %p\n", DllBase, NewImageAddress); ASSERT(ExpInitializationPhase == 0); - + /* Loop the new driver PTEs */ TempPte = ValidKernelPte; while (PointerPte < LastPte) @@ -1504,7 +1503,7 @@ MiReloadBootLoadedDrivers(IN PLOADER_PARAMETER_BLOCK LoaderBlock) PointerPte++; StartPte++; } - + /* Update position */ PointerPte -= PteCount; @@ -1547,7 +1546,7 @@ MiReloadBootLoadedDrivers(IN PLOADER_PARAMETER_BLOCK LoaderBlock) LdrEntry->EntryPoint = (PVOID)((ULONG_PTR)NewImageAddress + NtHeader->OptionalHeader.AddressOfEntryPoint); LdrEntry->SizeOfImage = PteCount << PAGE_SHIFT; - + /* FIXME: We'll need to fixup the PFN linkage when switching to ARM3 */ } } @@ -1568,7 +1567,7 @@ MiBuildImportsForBootDrivers(VOID) ULONG_PTR DllBase, DllEnd; ULONG Modules = 0, i, j = 0; PIMAGE_IMPORT_DESCRIPTOR ImportDescriptor; - + /* Initialize variables */ KernelEntry = HalEntry = LastEntry = NULL; @@ -1592,7 +1591,7 @@ MiBuildImportsForBootDrivers(VOID) /* Found it */ HalEntry = LdrEntry; } - + /* Check if this is a driver DLL */ if (LdrEntry->Flags & LDRP_DRIVER_DEPENDENT_DLL) { @@ -1611,9 +1610,9 @@ MiBuildImportsForBootDrivers(VOID) else { /* No referencing needed */ - LdrEntry->LoadCount = 0; + LdrEntry->LoadCount = 0; } - + /* Remember this came from the loader */ LdrEntry->LoadedImports = MM_SYSLDR_BOOT_LOADED; @@ -1621,10 +1620,10 @@ MiBuildImportsForBootDrivers(VOID) NextEntry = NextEntry->Flink; Modules++; } - + /* We must have at least found the kernel and HAL */ if (!(HalEntry) || (!KernelEntry)) return STATUS_NOT_FOUND; - + /* Allocate the list */ EntryArray = ExAllocatePoolWithTag(PagedPool, Modules * sizeof(PVOID), 'TDmM'); if (!EntryArray) return STATUS_INSUFFICIENT_RESOURCES; @@ -1643,7 +1642,7 @@ MiBuildImportsForBootDrivers(VOID) TRUE, IMAGE_DIRECTORY_ENTRY_IAT, &ImportSize); - if (!ImageThunk) + if (!ImageThunk) #else /* Get its imports */ ImportDescriptor = RtlImageDirectoryEntryToData(LdrEntry->DllBase, @@ -1658,12 +1657,12 @@ MiBuildImportsForBootDrivers(VOID) NextEntry = NextEntry->Flink; continue; } - + /* Clear the list and count the number of IAT thunks */ RtlZeroMemory(EntryArray, Modules * sizeof(PVOID)); #ifdef _WORKING_LOADER_ ImportSize /= sizeof(ULONG_PTR); - + /* Scan the thunks */ for (i = 0, DllBase = 0, DllEnd = 0; i < ImportSize; i++, ImageThunk++) #else @@ -1689,7 +1688,7 @@ MiBuildImportsForBootDrivers(VOID) continue; } } - + /* Loop the loaded module list to locate this address owner */ j = 0; NextEntry2 = PsLoadedModuleList.Flink; @@ -1699,11 +1698,11 @@ MiBuildImportsForBootDrivers(VOID) LdrEntry2 = CONTAINING_RECORD(NextEntry2, LDR_DATA_TABLE_ENTRY, InLoadOrderLinks); - + /* Get the address range for this module */ DllBase = (ULONG_PTR)LdrEntry2->DllBase; DllEnd = DllBase + LdrEntry2->SizeOfImage; - + /* Check if this IAT entry matches it */ if ((*ImageThunk >= DllBase) && (*ImageThunk < DllEnd)) { @@ -1712,12 +1711,12 @@ MiBuildImportsForBootDrivers(VOID) EntryArray[j] = LdrEntry2; break; } - + /* Keep searching */ NextEntry2 = NextEntry2->Flink; j++; } - + /* Do we have a thunk outside the range? */ if ((*ImageThunk < DllBase) || (*ImageThunk >= DllEnd)) { @@ -1729,19 +1728,19 @@ MiBuildImportsForBootDrivers(VOID) LdrEntry, ImageThunk, *ImageThunk); ASSERT(FALSE); } - + /* Reset if we hit this */ DllBase = 0; } #ifndef _WORKING_LOADER_ ImageThunk++; } - + i++; ImportDescriptor++; #endif } - + /* Now scan how many imports we really have */ for (i = 0, ImportSize = 0; i < Modules; i++) { @@ -1755,7 +1754,7 @@ MiBuildImportsForBootDrivers(VOID) ImportSize++; } } - + /* Do we have any imports after all? */ if (!ImportSize) { @@ -1776,10 +1775,10 @@ MiBuildImportsForBootDrivers(VOID) LoadedImportsSize, 'TDmM'); ASSERT(LoadedImports); - + /* Save the count */ LoadedImports->Count = ImportSize; - + /* Now copy all imports */ for (i = 0, j = 0; i < Modules; i++) { @@ -1795,25 +1794,25 @@ MiBuildImportsForBootDrivers(VOID) j++; } } - + /* Should had as many entries as we expected */ ASSERT(j == ImportSize); LdrEntry->LoadedImports = LoadedImports; } - + /* Next */ NextEntry = NextEntry->Flink; } - + /* Free the initial array */ ExFreePool(EntryArray); - + /* FIXME: Might not need to keep the HAL/Kernel imports around */ - + /* Kernel and HAL are loaded at boot */ KernelEntry->LoadedImports = MM_SYSLDR_BOOT_LOADED; HalEntry->LoadedImports = MM_SYSLDR_BOOT_LOADED; - + /* All worked well */ return STATUS_SUCCESS; } @@ -1827,7 +1826,7 @@ MiLocateKernelSections(IN PLDR_DATA_TABLE_ENTRY LdrEntry) PIMAGE_NT_HEADERS NtHeaders; PIMAGE_SECTION_HEADER SectionHeader; ULONG Sections, Size; - + /* Get the kernel section header */ DllBase = (ULONG_PTR)LdrEntry->DllBase; NtHeaders = RtlImageNtHeader((PVOID)DllBase); @@ -1839,7 +1838,7 @@ MiLocateKernelSections(IN PLDR_DATA_TABLE_ENTRY LdrEntry) { /* Grab the size of the section */ Size = max(SectionHeader->SizeOfRawData, SectionHeader->Misc.VirtualSize); - + /* Check for .RSRC section */ if (*(PULONG)SectionHeader->Name == 'rsr.') { @@ -1862,7 +1861,7 @@ MiLocateKernelSections(IN PLDR_DATA_TABLE_ENTRY LdrEntry) { /* Found Mm* Pool code */ MmPoolCodeStart = DllBase + SectionHeader->VirtualAddress; - MmPoolCodeEnd = ExPoolCodeStart + Size; + MmPoolCodeEnd = ExPoolCodeStart + Size; } } else if ((*(PULONG)SectionHeader->Name == 'YSIM') && @@ -1872,7 +1871,7 @@ MiLocateKernelSections(IN PLDR_DATA_TABLE_ENTRY LdrEntry) MmPteCodeStart = DllBase + SectionHeader->VirtualAddress; MmPteCodeEnd = ExPoolCodeStart + Size; } - + /* Keep going */ Sections--; SectionHeader++; @@ -1900,7 +1899,7 @@ MiInitializeLoadedModuleList(IN PLOADER_PARAMETER_BLOCK LoaderBlock) LDR_DATA_TABLE_ENTRY, InLoadOrderLinks); PsNtosImageBase = (ULONG_PTR)LdrEntry->DllBase; - + /* Locate resource section, pool code, and system pte code */ MiLocateKernelSections(LdrEntry); @@ -2012,11 +2011,11 @@ MiUseLargeDriverPage(IN ULONG NumberOfPtes, /* Keep trying */ NextEntry = NextEntry->Flink; } - + /* If we didn't find the driver, it doesn't need large pages */ if (DriverFound == FALSE) return FALSE; } - + /* Nothing to do yet */ DPRINT1("Large pages not supported!\n"); return FALSE; @@ -2028,13 +2027,13 @@ MiComputeDriverProtection(IN BOOLEAN SessionSpace, IN ULONG SectionProtection) { ULONG Protection = MM_ZERO_ACCESS; - + /* Check if the caller gave anything */ if (SectionProtection) { /* Always turn on execute access */ SectionProtection |= IMAGE_SCN_MEM_EXECUTE; - + /* Check if the registry setting is on or not */ if (!MmEnforceWriteProtection) { @@ -2042,11 +2041,11 @@ MiComputeDriverProtection(IN BOOLEAN SessionSpace, SectionProtection |= (IMAGE_SCN_MEM_WRITE | IMAGE_SCN_MEM_EXECUTE); } } - + /* Convert to internal PTE flags */ if (SectionProtection & IMAGE_SCN_MEM_EXECUTE) Protection |= MM_EXECUTE; if (SectionProtection & IMAGE_SCN_MEM_READ) Protection |= MM_READONLY; - + /* Check for write access */ if (SectionProtection & IMAGE_SCN_MEM_WRITE) { @@ -2062,10 +2061,10 @@ MiComputeDriverProtection(IN BOOLEAN SessionSpace, Protection = (Protection & MM_EXECUTE) ? MM_EXECUTE_READWRITE : MM_READWRITE; } } - + /* If there's no access at all by now, convert to internal no access flag */ if (Protection == MM_ZERO_ACCESS) Protection = MM_NOACCESS; - + /* Return the computed PTE protection */ return Protection; } @@ -2093,14 +2092,14 @@ MiWriteProtectSystemImage(IN PVOID ImageBase) PMMPTE PointerPte, StartPte, LastPte, CurrentPte, ComboPte = NULL; ULONG CurrentMask, CombinedMask = 0; PAGED_CODE(); - + /* No need to write protect physical memory-backed drivers (large pages) */ if (MI_IS_PHYSICAL_ADDRESS(ImageBase)) return; - + /* Get the image headers */ NtHeaders = RtlImageNtHeader(ImageBase); if (!NtHeaders) return; - + /* Check if this is a session driver or not */ if (!MI_IS_SESSION_ADDRESS(ImageBase)) { @@ -2114,13 +2113,13 @@ MiWriteProtectSystemImage(IN PVOID ImageBase) DPRINT1("Session drivers not supported\n"); ASSERT(FALSE); } - + /* These are the only protection masks we care about */ ProtectionMask = IMAGE_SCN_MEM_WRITE | IMAGE_SCN_MEM_READ | IMAGE_SCN_MEM_EXECUTE; - + /* Calculate the number of pages this driver is occupying */ DriverPages = BYTES_TO_PAGES(NtHeaders->OptionalHeader.SizeOfImage); - + /* Get the number of sections and the first section header */ Sections = NtHeaders->FileHeader.NumberOfSections; ASSERT(Sections != 0); @@ -2132,7 +2131,7 @@ MiWriteProtectSystemImage(IN PVOID ImageBase) { /* Get the section size */ Size = max(Section->SizeOfRawData, Section->Misc.VirtualSize); - + /* Get its virtual address */ BaseAddress = (ULONG_PTR)ImageBase + Section->VirtualAddress; if (BaseAddress < CurrentAddress) @@ -2141,24 +2140,24 @@ MiWriteProtectSystemImage(IN PVOID ImageBase) DPRINT1("Badly linked image!\n"); return; } - + /* Remember the current address */ CurrentAddress = BaseAddress + Size - 1; - + /* Next */ Sections--; Section++; } - + /* Get the number of sections and the first section header */ Sections = NtHeaders->FileHeader.NumberOfSections; ASSERT(Sections != 0); Section = IMAGE_FIRST_SECTION(NtHeaders); - + /* Set the address at the end to initialize the loop */ CurrentAddress = (ULONG_PTR)Section + Sections - 1; CurrentProtection = IMAGE_SCN_MEM_WRITE | IMAGE_SCN_MEM_READ; - + /* Set the PTE points for the image, and loop its sections */ StartPte = MiAddressToPte(ImageBase); LastPte = StartPte + DriverPages; @@ -2166,97 +2165,97 @@ MiWriteProtectSystemImage(IN PVOID ImageBase) { /* Get the section size */ Size = max(Section->SizeOfRawData, Section->Misc.VirtualSize); - + /* Get its virtual address and PTE */ BaseAddress = (ULONG_PTR)ImageBase + Section->VirtualAddress; PointerPte = MiAddressToPte(BaseAddress); - + /* Check if we were already protecting a run, and found a new run */ if ((ComboPte) && (PointerPte > ComboPte)) { /* Compute protection */ CombinedMask = MiComputeDriverProtection(FALSE, CombinedProtection); - + /* Set it */ MiSetSystemCodeProtection(ComboPte, ComboPte, CombinedMask); - + /* Check for overlap */ if (ComboPte == StartPte) StartPte++; - + /* One done, reset variables */ ComboPte = NULL; CombinedProtection = 0; } - + /* Break out when needed */ if (PointerPte >= LastPte) break; - + /* Get the requested protection from the image header */ SectionProtection = Section->Characteristics & ProtectionMask; if (SectionProtection == CurrentProtection) { /* Same protection, so merge the request */ CurrentAddress = BaseAddress + Size - 1; - + /* Next */ Sections--; Section++; continue; } - + /* This is now a new section, so close up the old one */ CurrentPte = MiAddressToPte(CurrentAddress); - + /* Check for overlap */ if (CurrentPte == PointerPte) { /* Skip the last PTE, since it overlaps with us */ CurrentPte--; - + /* And set the PTE we will merge with */ ASSERT((ComboPte == NULL) || (ComboPte == PointerPte)); ComboPte = PointerPte; - + /* Get the most flexible protection by merging both */ CombinedMask |= (SectionProtection | CurrentProtection); } - + /* Loop any PTEs left */ if (CurrentPte >= StartPte) { /* Sanity check */ ASSERT(StartPte < LastPte); - + /* Make sure we don't overflow past the last PTE in the driver */ if (CurrentPte >= LastPte) CurrentPte = LastPte - 1; ASSERT(CurrentPte >= StartPte); - + /* Compute the protection and set it */ CurrentMask = MiComputeDriverProtection(FALSE, CurrentProtection); MiSetSystemCodeProtection(StartPte, CurrentPte, CurrentMask); } - + /* Set new state */ StartPte = PointerPte; CurrentAddress = BaseAddress + Size - 1; CurrentProtection = SectionProtection; - + /* Next */ Sections--; Section++; } - + /* Is there a leftover section to merge? */ if (ComboPte) { /* Compute and set the protection */ CombinedMask = MiComputeDriverProtection(FALSE, CombinedProtection); MiSetSystemCodeProtection(ComboPte, ComboPte, CombinedMask); - + /* Handle overlap */ if (ComboPte == StartPte) StartPte++; } - + /* Finally, handle the last section */ CurrentPte = MiAddressToPte(CurrentAddress); if ((StartPte < LastPte) && (CurrentPte >= StartPte)) @@ -2264,7 +2263,7 @@ MiWriteProtectSystemImage(IN PVOID ImageBase) /* Handle overlap */ if (CurrentPte >= LastPte) CurrentPte = LastPte - 1; ASSERT(CurrentPte >= StartPte); - + /* Compute and set the protection */ CurrentMask = MiComputeDriverProtection(FALSE, CurrentProtection); MiSetSystemCodeProtection(StartPte, CurrentPte, CurrentMask); @@ -2281,17 +2280,17 @@ MiSetPagingOfDriver(IN PMMPTE PointerPte, PFN_NUMBER PageCount = 0, PageFrameIndex; PMMPFN Pfn1; PAGED_CODE(); - + /* Get the driver's base address */ ImageBase = MiPteToAddress(PointerPte); ASSERT(MI_IS_SESSION_IMAGE_ADDRESS(ImageBase) == FALSE); - + /* If this is a large page, it's stuck in physical memory */ if (MI_IS_PHYSICAL_ADDRESS(ImageBase)) return; /* Lock the working set */ MiLockWorkingSet(CurrentThread, &MmSystemCacheWs); - + /* Loop the PTEs */ while (PointerPte <= LastPte) { @@ -2301,18 +2300,18 @@ MiSetPagingOfDriver(IN PMMPTE PointerPte, PageFrameIndex = PFN_FROM_PTE(PointerPte); Pfn1 = MiGetPfnEntry(PageFrameIndex); ASSERT(Pfn1->u2.ShareCount == 1); - + /* No working sets in ReactOS yet */ PageCount++; } - + ImageBase = (PVOID)((ULONG_PTR)ImageBase + PAGE_SIZE); PointerPte++; } - + /* Release the working set */ MiUnlockWorkingSet(CurrentThread, &MmSystemCacheWs); - + /* Do we have any driver pages? */ if (PageCount) { @@ -2331,16 +2330,16 @@ MiEnablePagingOfDriver(IN PLDR_DATA_TABLE_ENTRY LdrEntry) PIMAGE_SECTION_HEADER Section; PMMPTE PointerPte = NULL, LastPte = NULL; if (MmDisablePagingExecutive) return; - + /* Get the driver base address and its NT header */ ImageBase = (ULONG_PTR)LdrEntry->DllBase; NtHeaders = RtlImageNtHeader((PVOID)ImageBase); if (!NtHeaders) return; - + /* Get the sections and their alignment */ Sections = NtHeaders->FileHeader.NumberOfSections; Alignment = NtHeaders->OptionalHeader.SectionAlignment - 1; - + /* Loop each section */ Section = IMAGE_FIRST_SECTION(NtHeaders); while (Sections) @@ -2357,10 +2356,10 @@ MiEnablePagingOfDriver(IN PLDR_DATA_TABLE_ENTRY LdrEntry) Section-> VirtualAddress)); } - + /* Compute the size */ Size = max(Section->SizeOfRawData, Section->Misc.VirtualSize); - + /* Find the last PTE that maps this section */ LastPte = MiAddressToPte(ImageBase + Section->VirtualAddress + @@ -2378,12 +2377,12 @@ MiEnablePagingOfDriver(IN PLDR_DATA_TABLE_ENTRY LdrEntry) PointerPte = NULL; } } - + /* Keep searching */ Sections--; Section++; } - + /* Handle the straggler */ if (PointerPte) MiSetPagingOfDriver(PointerPte, LastPte); } @@ -2427,7 +2426,7 @@ MmCheckSystemImage(IN HANDLE ImageHandle, PIMAGE_NT_HEADERS NtHeaders; OBJECT_ATTRIBUTES ObjectAttributes; PAGED_CODE(); - + /* Setup the object attributes */ InitializeObjectAttributes(&ObjectAttributes, NULL, @@ -2485,7 +2484,7 @@ MmCheckSystemImage(IN HANDLE ImageHandle, Status = STATUS_IMAGE_CHECKSUM_MISMATCH; goto Fail; } - + /* Make sure it's a real image */ NtHeaders = RtlImageNtHeader(ViewBase); if (!NtHeaders) @@ -2494,7 +2493,7 @@ MmCheckSystemImage(IN HANDLE ImageHandle, Status = STATUS_IMAGE_CHECKSUM_MISMATCH; goto Fail; } - + /* Make sure it's for the correct architecture */ if ((NtHeaders->FileHeader.Machine != IMAGE_FILE_MACHINE_NATIVE) || (NtHeaders->OptionalHeader.Magic != IMAGE_NT_OPTIONAL_HDR_MAGIC)) @@ -2606,7 +2605,7 @@ MmLoadSystemImage(IN PUNICODE_STRING FileName, /* Check if we already have a name, use it instead */ if (LoadedName) BaseName = *LoadedName; - + /* Check for loader snap debugging */ if (NtGlobalFlag & FLG_SHOW_LDR_SNAPS) { @@ -2799,7 +2798,7 @@ LoaderScan: ObDereferenceObject(Section); Section = NULL; } - + /* Check for failure of the load earlier */ if (!NT_SUCCESS(Status)) goto Quickie; @@ -2812,7 +2811,7 @@ LoaderScan: STATUS_INVALID_IMAGE_FORMAT); if (!NT_SUCCESS(Status)) goto Quickie; - + /* Get the NT Header */ NtHeader = RtlImageNtHeader(ModuleLoadBase); @@ -3016,7 +3015,7 @@ MiLookupDataTableEntry(IN PVOID Address) PLDR_DATA_TABLE_ENTRY LdrEntry, FoundEntry = NULL; PLIST_ENTRY NextEntry; PAGED_CODE(); - + /* Loop entries */ NextEntry = PsLoadedModuleList.Flink; do @@ -3025,7 +3024,7 @@ MiLookupDataTableEntry(IN PVOID Address) LdrEntry = CONTAINING_RECORD(NextEntry, LDR_DATA_TABLE_ENTRY, InLoadOrderLinks); - + /* Check if the address matches */ if ((Address >= LdrEntry->DllBase) && (Address < (PVOID)((ULONG_PTR)LdrEntry->DllBase + @@ -3035,11 +3034,11 @@ MiLookupDataTableEntry(IN PVOID Address) FoundEntry = LdrEntry; break; } - + /* Move on */ NextEntry = NextEntry->Flink; } while(NextEntry != &PsLoadedModuleList); - + /* Return the entry */ return FoundEntry; } diff --git a/reactos/ntoskrnl/mm/ARM3/syspte.c b/reactos/ntoskrnl/mm/ARM3/syspte.c index 401550d8edf..ecb915161fd 100644 --- a/reactos/ntoskrnl/mm/ARM3/syspte.c +++ b/reactos/ntoskrnl/mm/ARM3/syspte.c @@ -12,7 +12,6 @@ #define NDEBUG #include -#line 15 "ARM³::SYSPTE" #define MODULE_INVOLVED_IN_ARM3 #include "../ARM3/miarm.h" @@ -36,22 +35,22 @@ MiReserveAlignedSystemPtes(IN ULONG NumberOfPtes, KIRQL OldIrql; PMMPTE PointerPte, NextPte, PreviousPte; ULONG_PTR ClusterSize; - + // // Sanity check // ASSERT(Alignment <= PAGE_SIZE); - + // // Lock the system PTE space // OldIrql = KeAcquireQueuedSpinLock(LockQueueSystemSpaceLock); - + // // Get the first free cluster and make sure we have PTEs available // PointerPte = &MmFirstFreeSystemPte[SystemPtePoolType]; - if (PointerPte->u.List.NextEntry == ((ULONG)0xFFFFF)) + if (PointerPte->u.List.NextEntry == ((ULONG)0xFFFFF)) { // // Fail @@ -59,13 +58,13 @@ MiReserveAlignedSystemPtes(IN ULONG NumberOfPtes, KeReleaseQueuedSpinLock(LockQueueSystemSpaceLock, OldIrql); return NULL; } - + // // Now move to the first free system PTE cluster // - PreviousPte = PointerPte; + PreviousPte = PointerPte; PointerPte = MmSystemPteBase + PointerPte->u.List.NextEntry; - + // // Loop each cluster // @@ -80,7 +79,7 @@ MiReserveAlignedSystemPtes(IN ULONG NumberOfPtes, // Keep track of the next cluster in case we have to relink // NextPte = PointerPte + 1; - + // // Can this cluster satisfy the request? // @@ -104,7 +103,7 @@ MiReserveAlignedSystemPtes(IN ULONG NumberOfPtes, // NextPte->u.List.NextEntry = ClusterSize - NumberOfPtes; } - + // // Decrement the free count and move to the next starting PTE // @@ -112,7 +111,7 @@ MiReserveAlignedSystemPtes(IN ULONG NumberOfPtes, PointerPte += (ClusterSize - NumberOfPtes); break; } - + // // Did we find exactly what you wanted? // @@ -124,7 +123,7 @@ MiReserveAlignedSystemPtes(IN ULONG NumberOfPtes, PreviousPte->u.List.NextEntry = PointerPte->u.List.NextEntry; MmTotalFreeSystemPtes[SystemPtePoolType] -= NumberOfPtes; break; - } + } } else if (NumberOfPtes == 1) { @@ -135,7 +134,7 @@ MiReserveAlignedSystemPtes(IN ULONG NumberOfPtes, MmTotalFreeSystemPtes[SystemPtePoolType]--; break; } - + // // We couldn't find what you wanted -- is this the last cluster? // @@ -154,8 +153,8 @@ MiReserveAlignedSystemPtes(IN ULONG NumberOfPtes, PreviousPte = PointerPte; PointerPte = MmSystemPteBase + PointerPte->u.List.NextEntry; ASSERT(PointerPte > PreviousPte); - } - + } + // // Release the lock, flush the TLB and return the first PTE // @@ -202,30 +201,30 @@ MiReleaseSystemPtes(IN PMMPTE StartingPte, KIRQL OldIrql; ULONG_PTR ClusterSize, CurrentSize; PMMPTE CurrentPte, NextPte, PointerPte; - + // // Check to make sure the PTE address is within bounds // ASSERT(NumberOfPtes != 0); ASSERT(StartingPte >= MmSystemPtesStart[SystemPtePoolType]); ASSERT(StartingPte <= MmSystemPtesEnd[SystemPtePoolType]); - + // // Zero PTEs // RtlZeroMemory(StartingPte, NumberOfPtes * sizeof(MMPTE)); CurrentSize = (ULONG_PTR)(StartingPte - MmSystemPteBase); - + // // Acquire the system PTE lock // OldIrql = KeAcquireQueuedSpinLock(LockQueueSystemSpaceLock); - + // // Increase availability // MmTotalFreeSystemPtes[SystemPtePoolType] += NumberOfPtes; - + // // Get the free cluster and start going through them // @@ -243,12 +242,12 @@ MiReleaseSystemPtes(IN PMMPTE StartingPte, // ASSERT(((StartingPte + NumberOfPtes) <= PointerPte) || (CurrentPte->u.List.NextEntry == ((ULONG)0xFFFFF))); - + // // Get the next cluster in case it's the one // NextPte = CurrentPte + 1; - + // // Check if this was actually a single-PTE entry // @@ -266,7 +265,7 @@ MiReleaseSystemPtes(IN PMMPTE StartingPte, // ClusterSize = (ULONG_PTR)NextPte->u.List.NextEntry; } - + // // So check if this cluster actually describes the entire mapping // @@ -278,7 +277,7 @@ MiReleaseSystemPtes(IN PMMPTE StartingPte, NumberOfPtes += ClusterSize; NextPte->u.List.NextEntry = NumberOfPtes; CurrentPte->u.List.OneEntry = 0; - + // // Make another pass // @@ -291,7 +290,7 @@ MiReleaseSystemPtes(IN PMMPTE StartingPte, // StartingPte->u.List.NextEntry = CurrentPte->u.List.NextEntry; CurrentPte->u.List.NextEntry = CurrentSize; - + // // Is there just one page left? // @@ -312,7 +311,7 @@ MiReleaseSystemPtes(IN PMMPTE StartingPte, NextPte->u.List.NextEntry = NumberOfPtes; } } - + // // Now check if we've arrived at yet another cluster // @@ -324,7 +323,7 @@ MiReleaseSystemPtes(IN PMMPTE StartingPte, StartingPte->u.List.NextEntry = PointerPte->u.List.NextEntry; StartingPte->u.List.OneEntry = 0; NextPte = StartingPte + 1; - + // // Check if the cluster only had one page // @@ -343,20 +342,20 @@ MiReleaseSystemPtes(IN PMMPTE StartingPte, PointerPte++; ClusterSize = (ULONG_PTR)PointerPte->u.List.NextEntry; } - + // // And create the final combined cluster // NextPte->u.List.NextEntry = NumberOfPtes + ClusterSize; } - + // // We released the PTEs into their cluster (and optimized the list) // KeReleaseQueuedSpinLock(LockQueueSystemSpaceLock, OldIrql); break; } - + // // Try the next cluster of PTEs... // @@ -375,7 +374,7 @@ MiInitializeSystemPtes(IN PMMPTE StartingPte, // Sanity checks // ASSERT(NumberOfPtes >= 1); - + // // Set the starting and ending PTE addresses for this space // @@ -384,12 +383,12 @@ MiInitializeSystemPtes(IN PMMPTE StartingPte, MmSystemPtesEnd[PoolType] = StartingPte + NumberOfPtes - 1; DPRINT("System PTE space for %d starting at: %p and ending at: %p\n", PoolType, MmSystemPtesStart[PoolType], MmSystemPtesEnd[PoolType]); - + // // Clear all the PTEs to start with // RtlZeroMemory(StartingPte, NumberOfPtes * sizeof(MMPTE)); - + // // Make the first entry free and link it // @@ -397,19 +396,19 @@ MiInitializeSystemPtes(IN PMMPTE StartingPte, MmFirstFreeSystemPte[PoolType].u.Long = 0; MmFirstFreeSystemPte[PoolType].u.List.NextEntry = StartingPte - MmSystemPteBase; - + // // The second entry stores the size of this PTE space // StartingPte++; StartingPte->u.Long = 0; StartingPte->u.List.NextEntry = NumberOfPtes; - + // // We also keep a global for it // MmTotalFreeSystemPtes[PoolType] = NumberOfPtes; - + // // Check if this is the system PTE space // diff --git a/reactos/ntoskrnl/mm/ARM3/vadnode.c b/reactos/ntoskrnl/mm/ARM3/vadnode.c index d62a02c8a73..cb6c656a732 100644 --- a/reactos/ntoskrnl/mm/ARM3/vadnode.c +++ b/reactos/ntoskrnl/mm/ARM3/vadnode.c @@ -13,7 +13,6 @@ #define NDEBUG #include -#line 15 "ARM³::VADNODE" #define MODULE_INVOLVED_IN_ARM3 #include "../ARM3/miarm.h" @@ -86,7 +85,7 @@ MiCheckForConflictingNode(IN ULONG_PTR StartVpn, break; } } - + /* Return either the conflicting node, or no node at all */ return CurrentNode; } @@ -147,16 +146,16 @@ MiInsertVad(IN PMMVAD Vad, { TABLE_SEARCH_RESULT Result; PMMADDRESS_NODE Parent = NULL; - + /* Validate the VAD and set it as the current hint */ ASSERT(Vad->EndingVpn >= Vad->StartingVpn); Process->VadRoot.NodeHint = Vad; - + /* Find the parent VAD and where this child should be inserted */ Result = RtlpFindAvlTableNodeOrParent(&Process->VadRoot, (PVOID)Vad->StartingVpn, &Parent); ASSERT(Result != TableFoundNode); ASSERT((Parent != NULL) || (Result == TableEmptyTree)); - + /* Do the actual insert operation */ MiInsertNode(&Process->VadRoot, (PVOID)Vad, Parent, Result); } @@ -168,7 +167,7 @@ MiRemoveNode(IN PMMADDRESS_NODE Node, { /* Call the AVL code */ RtlpDeleteAvlTreeNode(Table, Node); - + /* Decrease element count */ Table->NumberGenericTableElements--; @@ -186,7 +185,7 @@ MiRemoveNode(IN PMMADDRESS_NODE Node, { PMEMORY_AREA MemoryArea; PEPROCESS Process; - + /* Check if this is VM VAD */ if (Vad->ControlArea == NULL) { @@ -198,17 +197,17 @@ MiRemoveNode(IN PMMADDRESS_NODE Node, /* This is a section VAD. We store the ReactOS MEMORY_AREA here */ MemoryArea = (PMEMORY_AREA)Vad->ControlArea->WaitingForDeletion; } - + /* Make sure one actually still exists */ if (MemoryArea) { /* Get the process */ Process = CONTAINING_RECORD(Table, EPROCESS, VadRoot); - + /* We only create fake memory-areas for ARM3 VADs */ ASSERT(MemoryArea->Type == MEMORY_AREA_OWNED_BY_ARM3); ASSERT(MemoryArea->Vad == NULL); - + /* Free it */ MmFreeMemoryArea(&Process->Vm, MemoryArea, NULL, NULL); } @@ -241,12 +240,12 @@ MiGetPreviousNode(IN PMMADDRESS_NODE Node) if (Parent == RtlParentAvl(Parent)) Parent = NULL; return Parent; } - + /* Keep lopping until we find our parent */ Node = Parent; Parent = RtlParentAvl(Node); } - + /* Nothing found */ return NULL; } @@ -276,12 +275,12 @@ MiGetNextNode(IN PMMADDRESS_NODE Node) /* Return it */ return Parent; } - + /* Keep lopping until we find our parent */ Node = Parent; Parent = RtlParentAvl(Node); } - + /* Nothing found */ return NULL; } @@ -328,7 +327,7 @@ FoundAtBottom: { /* The last aligned page number in this entry */ LowVpn = ROUND_UP(Node->EndingVpn + 1, AlignmentVpn); - + /* Keep going as long as there's still a next node */ NextNode = MiGetNextNode(Node); if (!NextNode) break; @@ -340,7 +339,7 @@ FoundAtBottom: Found: /* Yes! Use this VAD to store the allocation */ *PreviousVad = Node; - *Base = ROUND_UP((Node->EndingVpn << PAGE_SHIFT) | (PAGE_SIZE - 1), + *Base = ROUND_UP((Node->EndingVpn << PAGE_SHIFT) | (PAGE_SIZE - 1), Alignment); return STATUS_SUCCESS; } @@ -352,7 +351,7 @@ Found: /* We're down to the last (top) VAD, will this allocation fit inside it? */ HighestVpn = ((ULONG_PTR)MM_HIGHEST_VAD_ADDRESS + 1) >> PAGE_SHIFT; if ((HighestVpn > LowVpn) && (LengthVpn <= HighestVpn - LowVpn)) goto Found; - + /* Nyet, there's no free address space for this allocation, so we'll fail */ return STATUS_NO_MEMORY; } @@ -373,7 +372,7 @@ MiFindEmptyAddressRangeDownTree(IN SIZE_T Length, /* Sanity checks */ ASSERT(BoundaryAddress); ASSERT(BoundaryAddress <= ((ULONG_PTR)MM_HIGHEST_VAD_ADDRESS + 1)); - + /* Compute page length, make sure the boundary address is valid */ Length = ROUND_TO_PAGES(Length); PageCount = Length >> PAGE_SHIFT; @@ -390,10 +389,10 @@ MiFindEmptyAddressRangeDownTree(IN SIZE_T Length, /* Calculate the initial upper margin */ HighVpn = BoundaryAddress >> PAGE_SHIFT; - /* Starting from the root, go down until the right-most child, + /* Starting from the root, go down until the right-most child, trying to stay below the boundary. */ LowestNode = Node = RtlRightChildAvl(&Table->BalancedRoot); - while ( (Child = RtlRightChildAvl(Node)) && + while ( (Child = RtlRightChildAvl(Node)) && Child->EndingVpn < HighVpn ) Node = Child; /* Now loop the Vad nodes */ diff --git a/reactos/ntoskrnl/mm/ARM3/virtual.c b/reactos/ntoskrnl/mm/ARM3/virtual.c index 466bccf7c01..095befef908 100644 --- a/reactos/ntoskrnl/mm/ARM3/virtual.c +++ b/reactos/ntoskrnl/mm/ARM3/virtual.c @@ -12,7 +12,6 @@ #define NDEBUG #include -#line 15 "ARM³::VIRTUAL" #define MODULE_INVOLVED_IN_ARM3 #include "../ARM3/miarm.h" @@ -41,7 +40,7 @@ MiMakeSystemAddressValid(IN PVOID PageTableVirtualAddress, ASSERT(PageTableVirtualAddress > MM_HIGHEST_USER_ADDRESS); ASSERT((PageTableVirtualAddress < MmPagedPoolStart) || (PageTableVirtualAddress > MmPagedPoolEnd)); - + /* Working set lock or PFN lock should be held */ ASSERT(KeAreAllApcsDisabled() == TRUE); @@ -84,7 +83,7 @@ MiMakeSystemAddressValidPfn(IN PVOID VirtualAddress, { /* Release the PFN database */ KeReleaseQueuedSpinLock(LockQueuePfnLock, OldIrql); - + /* Fault it in */ Status = MmAccessFault(FALSE, VirtualAddress, KernelMode, NULL); if (!NT_SUCCESS(Status)) @@ -99,7 +98,7 @@ MiMakeSystemAddressValidPfn(IN PVOID VirtualAddress, /* This flag will be useful later when we do better locking */ LockChange = TRUE; - + /* Lock the PFN database */ OldIrql = KeAcquireQueuedSpinLock(LockQueuePfnLock); } @@ -114,17 +113,17 @@ MiDeleteSystemPageableVm(IN PMMPTE PointerPte, IN PFN_NUMBER PageCount, IN ULONG Flags, OUT PPFN_NUMBER ValidPages) -{ +{ PFN_NUMBER ActualPages = 0; PETHREAD CurrentThread = PsGetCurrentThread(); PMMPFN Pfn1, Pfn2; PFN_NUMBER PageFrameIndex, PageTableIndex; KIRQL OldIrql; ASSERT(KeGetCurrentIrql() <= APC_LEVEL); - + /* Lock the system working set */ MiLockWorkingSet(CurrentThread, &MmSystemCacheWs); - + /* Loop all pages */ while (PageCount) { @@ -134,50 +133,50 @@ MiDeleteSystemPageableVm(IN PMMPTE PointerPte, /* As always, only handle current ARM3 scenarios */ ASSERT(PointerPte->u.Soft.Prototype == 0); ASSERT(PointerPte->u.Soft.Transition == 0); - + /* Normally this is one possibility -- freeing a valid page */ if (PointerPte->u.Hard.Valid) { /* Get the page PFN */ PageFrameIndex = PFN_FROM_PTE(PointerPte); Pfn1 = MiGetPfnEntry(PageFrameIndex); - + /* Should not have any working set data yet */ ASSERT(Pfn1->u1.WsIndex == 0); - + /* Actual valid, legitimate, pages */ if (ValidPages) (*ValidPages)++; - + /* Get the page table entry */ PageTableIndex = Pfn1->u4.PteFrame; Pfn2 = MiGetPfnEntry(PageTableIndex); - + /* Lock the PFN database */ OldIrql = KeAcquireQueuedSpinLock(LockQueuePfnLock); - + /* Delete it the page */ MI_SET_PFN_DELETED(Pfn1); MiDecrementShareCount(Pfn1, PageFrameIndex); - + /* Decrement the page table too */ DPRINT("FIXME: ARM3 should decrement the pool PDE refcount for: %p\n", PageTableIndex); #if 0 // ARM3: Dont't trust this yet MiDecrementShareCount(Pfn2, PageTableIndex); #endif - + /* Release the PFN database */ KeReleaseQueuedSpinLock(LockQueuePfnLock, OldIrql); - + /* Destroy the PTE */ PointerPte->u.Long = 0; } - + /* Actual legitimate pages */ ActualPages++; } else { - /* + /* * The only other ARM3 possibility is a demand zero page, which would * mean freeing some of the paged pool pages that haven't even been * touched yet, as part of a larger allocation. @@ -185,22 +184,22 @@ MiDeleteSystemPageableVm(IN PMMPTE PointerPte, * Right now, we shouldn't expect any page file information in the PTE */ ASSERT(PointerPte->u.Soft.PageFileHigh == 0); - + /* Destroy the PTE */ PointerPte->u.Long = 0; } - + /* Keep going */ PointerPte++; PageCount--; } - + /* Release the working set */ MiUnlockWorkingSet(CurrentThread, &MmSystemCacheWs); - + /* Flush the entire TLB */ KeFlushEntireTb(TRUE, TRUE); - + /* Done */ return ActualPages; } @@ -243,7 +242,7 @@ MiDeletePte(IN PMMPTE PointerPte, PointerPde = MiAddressToPde(PointerPte); if (PointerPde->u.Hard.Valid == 0) { -#if (_MI_PAGING_LEVELS == 2) +#if (_MI_PAGING_LEVELS == 2) /* Could be paged pool access from a new process -- synchronize the page directories */ if (!NT_SUCCESS(MiCheckPdeForPagedPool(VirtualAddress))) { @@ -255,7 +254,7 @@ MiDeletePte(IN PMMPTE PointerPte, PointerPte->u.Long, (ULONG_PTR)VirtualAddress); } -#if (_MI_PAGING_LEVELS == 2) +#if (_MI_PAGING_LEVELS == 2) } #endif /* FIXME: Drop the reference on the page table. For now, leak it until RosMM is gone */ @@ -263,7 +262,7 @@ MiDeletePte(IN PMMPTE PointerPte, /* Drop the share count */ MiDecrementShareCount(Pfn1, PageFrameIndex); - + /* No fork yet */ if (PointerPte <= MiHighestUserPte) ASSERT(PrototypePte == Pfn1->PteAddress); } @@ -274,7 +273,7 @@ MiDeletePte(IN PMMPTE PointerPte, { /* The PFN entry is illegal, or invalid */ KeBugCheckEx(MEMORY_MANAGEMENT, - 0x401, + 0x401, (ULONG_PTR)PointerPte, PointerPte->u.Long, (ULONG_PTR)Pfn1->PteAddress); @@ -282,14 +281,14 @@ MiDeletePte(IN PMMPTE PointerPte, /* There should only be 1 shared reference count */ ASSERT(Pfn1->u2.ShareCount == 1); - + /* FIXME: Drop the reference on the page table. For now, leak it until RosMM is gone */ //MiDecrementShareCount(MiGetPfnEntry(Pfn1->u4.PteFrame), Pfn1->u4.PteFrame); /* Mark the PFN for deletion and dereference what should be the last ref */ MI_SET_PFN_DELETED(Pfn1); MiDecrementShareCount(Pfn1, PageFrameIndex); - + /* We should eventually do this */ //CurrentProcess->NumberOfPrivatePages--; } @@ -348,15 +347,15 @@ MiDeleteVirtualAddresses(IN ULONG_PTR Va, /* Still no valid PDE, try the next 4MB (or whatever) */ PointerPde++; - + /* Update the PTE on this new boundary */ PointerPte = MiPteToAddress(PointerPde); - + /* Check if all the PDEs are invalid, so there's nothing to free */ Va = (ULONG_PTR)MiPteToAddress(PointerPte); if (Va > EndingAddress) return; } - + /* Now check if the PDE is mapped in */ if (!PointerPde->u.Hard.Valid) { @@ -364,17 +363,17 @@ MiDeleteVirtualAddresses(IN ULONG_PTR Va, PointerPte = MiPteToAddress(PointerPde); MiMakeSystemAddressValid(PointerPte, CurrentProcess); } - + /* Now we should have a valid PDE, mapped in, and still have some VA */ ASSERT(PointerPde->u.Hard.Valid == 1); ASSERT(Va <= EndingAddress); - + /* Check if this is a section VAD with gaps in it */ if ((AddressGap) && (LastPrototypePte)) { /* We need to skip to the next correct prototype PTE */ PrototypePte = MI_GET_PROTOTYPE_PTE_FOR_VPN(Vad, Va >> PAGE_SHIFT); - + /* And we need the subsection to skip to the next last prototype PTE */ Subsection = MiLocateSubsection(Vad, Va >> PAGE_SHIFT); if (Subsection) @@ -388,7 +387,7 @@ MiDeleteVirtualAddresses(IN ULONG_PTR Va, PrototypePte = NULL; } } - + /* Lock the PFN Database while we delete the PTEs */ OldIrql = KeAcquireQueuedSpinLock(LockQueuePfnLock); do @@ -405,7 +404,7 @@ MiDeleteVirtualAddresses(IN ULONG_PTR Va, { /* We need to skip to the next correct prototype PTE */ PrototypePte = MI_GET_PROTOTYPE_PTE_FOR_VPN(Vad, Va >> PAGE_SHIFT); - + /* And we need the subsection to skip to the next last prototype PTE */ Subsection = MiLocateSubsection(Vad, Va >> PAGE_SHIFT); if (Subsection) @@ -419,7 +418,7 @@ MiDeleteVirtualAddresses(IN ULONG_PTR Va, PrototypePte = NULL; } } - + /* Check for prototype PTE */ if ((TempPte.u.Hard.Valid == 0) && (TempPte.u.Soft.Prototype == 1)) @@ -431,7 +430,7 @@ MiDeleteVirtualAddresses(IN ULONG_PTR Va, { /* Delete the PTE proper */ MiDeletePte(PointerPte, - (PVOID)Va, + (PVOID)Va, CurrentProcess, PrototypePte); } @@ -447,15 +446,15 @@ MiDeleteVirtualAddresses(IN ULONG_PTR Va, Va += PAGE_SIZE; PointerPte++; PrototypePte++; - + /* Making sure the PDE is still valid */ - ASSERT(PointerPde->u.Hard.Valid == 1); + ASSERT(PointerPde->u.Hard.Valid == 1); } while ((Va & (PDE_MAPPED_VA - 1)) && (Va <= EndingAddress)); /* The PDE should still be valid at this point */ ASSERT(PointerPde->u.Hard.Valid == 1); - + /* Release the lock and get out if we're done */ KeReleaseQueuedSpinLock(LockQueuePfnLock, OldIrql); if (Va > EndingAddress) return; @@ -468,7 +467,7 @@ MiDeleteVirtualAddresses(IN ULONG_PTR Va, LONG MiGetExceptionInfo(IN PEXCEPTION_POINTERS ExceptionInfo, - OUT PBOOLEAN HaveBadAddress, + OUT PBOOLEAN HaveBadAddress, OUT PULONG_PTR BadAddress) { PEXCEPTION_RECORD ExceptionRecord; @@ -666,7 +665,7 @@ MiDoMappedCopy(IN PEPROCESS SourceProcess, // Check if we had locked the pages // if (PagesLocked) MmUnlockPages(Mdl); - + // // Check if we hit working set quota // @@ -1032,7 +1031,7 @@ MmCopyVirtualMemory(IN PEPROCESS SourceProcess, ExReleaseRundownProtection(&Process->RundownProtect); return Status; } - + NTSTATUS NTAPI MmFlushVirtualMemory(IN PEPROCESS Process, @@ -1042,7 +1041,7 @@ MmFlushVirtualMemory(IN PEPROCESS Process, { PAGED_CODE(); UNIMPLEMENTED; - + // // Fake success // @@ -1110,7 +1109,7 @@ MiQueryAddressState(IN PVOID Va, /* Only normal VADs supported */ ASSERT(Vad->u.VadFlags.VadType == VadNone); - + /* Get the PDE and PTE for the address */ PointerPde = MiAddressToPde(Va); PointerPte = MiAddressToPte(Va); @@ -1148,7 +1147,7 @@ MiQueryAddressState(IN PVOID Va, if (ValidPte) { /* FIXME: watch out for large pages */ - + /* Capture the PTE */ TempPte = *PointerPte; if (TempPte.u.Long) @@ -1184,7 +1183,7 @@ MiQueryAddressState(IN PVOID Va, { /* This is committed memory */ State = MEM_COMMIT; - + /* Convert the protection */ Protect = MmProtectToValue[Vad->u.VadFlags.Protection]; } @@ -1285,7 +1284,7 @@ NtReadVirtualMemory(IN HANDLE ProcessHandle, } _SEH2_END; } - + // // Don't do zero-byte transfers // @@ -1312,7 +1311,7 @@ NtReadVirtualMemory(IN HANDLE ProcessHandle, NumberOfBytesToRead, PreviousMode, &BytesRead); - + // // Dereference the process // @@ -1426,7 +1425,7 @@ NtWriteVirtualMemory(IN HANDLE ProcessHandle, NumberOfBytesToWrite, PreviousMode, &BytesWritten); - + // // Dereference the process // @@ -1572,7 +1571,7 @@ NtProtectVirtualMemory(IN HANDLE ProcessHandle, (PVOID*)(&Process), NULL); if (!NT_SUCCESS(Status)) return Status; - + // // Check if we should attach // @@ -1593,7 +1592,7 @@ NtProtectVirtualMemory(IN HANDLE ProcessHandle, &NumberOfBytesToProtect, NewAccessProtection, &OldAccessProtection); - + // // Detach if needed // @@ -1643,7 +1642,7 @@ NtLockVirtualMemory(IN HANDLE ProcessHandle, PVOID CapturedBaseAddress; SIZE_T CapturedBytesToLock; PAGED_CODE(); - + // // Validate flags // @@ -1654,7 +1653,7 @@ NtLockVirtualMemory(IN HANDLE ProcessHandle, // return STATUS_INVALID_PARAMETER; } - + // // At least one flag must be specified // @@ -1665,7 +1664,7 @@ NtLockVirtualMemory(IN HANDLE ProcessHandle, // return STATUS_INVALID_PARAMETER; } - + // // Enter SEH for probing // @@ -1676,7 +1675,7 @@ NtLockVirtualMemory(IN HANDLE ProcessHandle, // ProbeForWritePointer(BaseAddress); ProbeForWriteSize_t(NumberOfBytesToLock); - + // // Capture it // @@ -1691,12 +1690,12 @@ NtLockVirtualMemory(IN HANDLE ProcessHandle, _SEH2_YIELD(return _SEH2_GetExceptionCode()); } _SEH2_END; - + // // Catch illegal base address // if (CapturedBaseAddress > MM_HIGHEST_USER_ADDRESS) return STATUS_INVALID_PARAMETER; - + // // Catch illegal region size // @@ -1707,12 +1706,12 @@ NtLockVirtualMemory(IN HANDLE ProcessHandle, // return STATUS_INVALID_PARAMETER; } - + // // 0 is also illegal // if (!CapturedBytesToLock) return STATUS_INVALID_PARAMETER; - + // // Get a reference to the process // @@ -1723,7 +1722,7 @@ NtLockVirtualMemory(IN HANDLE ProcessHandle, (PVOID*)(&Process), NULL); if (!NT_SUCCESS(Status)) return Status; - + // // Check if this is is system-mapped // @@ -1741,7 +1740,7 @@ NtLockVirtualMemory(IN HANDLE ProcessHandle, return STATUS_PRIVILEGE_NOT_HELD; } } - + // // Check if we should attach // @@ -1753,22 +1752,22 @@ NtLockVirtualMemory(IN HANDLE ProcessHandle, KeStackAttachProcess(&Process->Pcb, &ApcState); Attached = TRUE; } - + // // Oops :( // UNIMPLEMENTED; - + // // Detach if needed // if (Attached) KeUnstackDetachProcess(&ApcState); - + // // Release reference // ObDereferenceObject(Process); - + // // Enter SEH to return data // @@ -1788,7 +1787,7 @@ NtLockVirtualMemory(IN HANDLE ProcessHandle, _SEH2_YIELD(return _SEH2_GetExceptionCode()); } _SEH2_END; - + // // Return status // @@ -1811,7 +1810,7 @@ NtUnlockVirtualMemory(IN HANDLE ProcessHandle, PVOID CapturedBaseAddress; SIZE_T CapturedBytesToUnlock; PAGED_CODE(); - + // // Validate flags // @@ -1822,7 +1821,7 @@ NtUnlockVirtualMemory(IN HANDLE ProcessHandle, // return STATUS_INVALID_PARAMETER; } - + // // At least one flag must be specified // @@ -1833,7 +1832,7 @@ NtUnlockVirtualMemory(IN HANDLE ProcessHandle, // return STATUS_INVALID_PARAMETER; } - + // // Enter SEH for probing // @@ -1844,7 +1843,7 @@ NtUnlockVirtualMemory(IN HANDLE ProcessHandle, // ProbeForWritePointer(BaseAddress); ProbeForWriteSize_t(NumberOfBytesToUnlock); - + // // Capture it // @@ -1859,12 +1858,12 @@ NtUnlockVirtualMemory(IN HANDLE ProcessHandle, _SEH2_YIELD(return _SEH2_GetExceptionCode()); } _SEH2_END; - + // // Catch illegal base address // if (CapturedBaseAddress > MM_HIGHEST_USER_ADDRESS) return STATUS_INVALID_PARAMETER; - + // // Catch illegal region size // @@ -1875,12 +1874,12 @@ NtUnlockVirtualMemory(IN HANDLE ProcessHandle, // return STATUS_INVALID_PARAMETER; } - + // // 0 is also illegal // if (!CapturedBytesToUnlock) return STATUS_INVALID_PARAMETER; - + // // Get a reference to the process // @@ -1891,7 +1890,7 @@ NtUnlockVirtualMemory(IN HANDLE ProcessHandle, (PVOID*)(&Process), NULL); if (!NT_SUCCESS(Status)) return Status; - + // // Check if this is is system-mapped // @@ -1909,7 +1908,7 @@ NtUnlockVirtualMemory(IN HANDLE ProcessHandle, return STATUS_PRIVILEGE_NOT_HELD; } } - + // // Check if we should attach // @@ -1921,22 +1920,22 @@ NtUnlockVirtualMemory(IN HANDLE ProcessHandle, KeStackAttachProcess(&Process->Pcb, &ApcState); Attached = TRUE; } - + // // Oops :( // UNIMPLEMENTED; - + // // Detach if needed // if (Attached) KeUnstackDetachProcess(&ApcState); - + // // Release reference // ObDereferenceObject(Process); - + // // Enter SEH to return data // @@ -1956,7 +1955,7 @@ NtUnlockVirtualMemory(IN HANDLE ProcessHandle, _SEH2_YIELD(return _SEH2_GetExceptionCode()); } _SEH2_END; - + // // Return status // @@ -1977,7 +1976,7 @@ NtFlushVirtualMemory(IN HANDLE ProcessHandle, SIZE_T CapturedBytesToFlush; IO_STATUS_BLOCK LocalStatusBlock; PAGED_CODE(); - + // // Check if we came from user mode // @@ -1994,7 +1993,7 @@ NtFlushVirtualMemory(IN HANDLE ProcessHandle, ProbeForWritePointer(BaseAddress); ProbeForWriteSize_t(NumberOfBytesToFlush); ProbeForWriteIoStatusBlock(IoStatusBlock); - + // // Capture them // @@ -2018,12 +2017,12 @@ NtFlushVirtualMemory(IN HANDLE ProcessHandle, CapturedBaseAddress = *BaseAddress; CapturedBytesToFlush = *NumberOfBytesToFlush; } - + // // Catch illegal base address // if (CapturedBaseAddress > MM_HIGHEST_USER_ADDRESS) return STATUS_INVALID_PARAMETER; - + // // Catch illegal region size // @@ -2034,7 +2033,7 @@ NtFlushVirtualMemory(IN HANDLE ProcessHandle, // return STATUS_INVALID_PARAMETER; } - + // // Get a reference to the process // @@ -2045,7 +2044,7 @@ NtFlushVirtualMemory(IN HANDLE ProcessHandle, (PVOID*)(&Process), NULL); if (!NT_SUCCESS(Status)) return Status; - + // // Do it // @@ -2053,12 +2052,12 @@ NtFlushVirtualMemory(IN HANDLE ProcessHandle, &CapturedBaseAddress, &CapturedBytesToFlush, &LocalStatusBlock); - + // // Release reference // ObDereferenceObject(Process); - + // // Enter SEH to return data // @@ -2075,7 +2074,7 @@ NtFlushVirtualMemory(IN HANDLE ProcessHandle, { } _SEH2_END; - + // // Return status // @@ -2101,7 +2100,7 @@ NtGetWriteWatch(IN HANDLE ProcessHandle, KPROCESSOR_MODE PreviousMode = ExGetPreviousMode(); ULONG_PTR CapturedEntryCount; PAGED_CODE(); - + // // Check if we came from user mode // @@ -2116,7 +2115,7 @@ NtGetWriteWatch(IN HANDLE ProcessHandle, // Catch illegal base address // if (BaseAddress > MM_HIGHEST_USER_ADDRESS) return STATUS_INVALID_PARAMETER_2; - + // // Catch illegal region size // @@ -2127,23 +2126,23 @@ NtGetWriteWatch(IN HANDLE ProcessHandle, // return STATUS_INVALID_PARAMETER_3; } - + // // Validate all data // ProbeForWriteSize_t(EntriesInUserAddressArray); ProbeForWriteUlong(Granularity); - + // // Capture them // CapturedEntryCount = *EntriesInUserAddressArray; - + // // Must have a count // if (CapturedEntryCount == 0) return STATUS_INVALID_PARAMETER_5; - + // // Can't be larger than the maximum // @@ -2154,7 +2153,7 @@ NtGetWriteWatch(IN HANDLE ProcessHandle, // return STATUS_INVALID_PARAMETER_5; } - + // // Probe the actual array // @@ -2179,7 +2178,7 @@ NtGetWriteWatch(IN HANDLE ProcessHandle, CapturedEntryCount = *EntriesInUserAddressArray; ASSERT(CapturedEntryCount != 0); } - + // // Check if this is a local request // @@ -2190,7 +2189,7 @@ NtGetWriteWatch(IN HANDLE ProcessHandle, // Process = PsGetCurrentProcess(); } - else + else { // // Reference the target @@ -2203,7 +2202,7 @@ NtGetWriteWatch(IN HANDLE ProcessHandle, NULL); if (!NT_SUCCESS(Status)) return Status; } - + // // Compute the last address and validate it // @@ -2216,17 +2215,17 @@ NtGetWriteWatch(IN HANDLE ProcessHandle, if (ProcessHandle != NtCurrentProcess()) ObDereferenceObject(Process); return STATUS_INVALID_PARAMETER_4; } - + // // Oops :( // UNIMPLEMENTED; - + // // Dereference if needed // if (ProcessHandle != NtCurrentProcess()) ObDereferenceObject(Process); - + // // Enter SEH to return data // @@ -2246,7 +2245,7 @@ NtGetWriteWatch(IN HANDLE ProcessHandle, Status = _SEH2_GetExceptionCode(); } _SEH2_END; - + // // Return success // @@ -2267,12 +2266,12 @@ NtResetWriteWatch(IN HANDLE ProcessHandle, NTSTATUS Status; KPROCESSOR_MODE PreviousMode = ExGetPreviousMode(); ASSERT (KeGetCurrentIrql() == PASSIVE_LEVEL); - + // // Catch illegal base address // if (BaseAddress > MM_HIGHEST_USER_ADDRESS) return STATUS_INVALID_PARAMETER_2; - + // // Catch illegal region size // @@ -2283,7 +2282,7 @@ NtResetWriteWatch(IN HANDLE ProcessHandle, // return STATUS_INVALID_PARAMETER_3; } - + // // Check if this is a local request // @@ -2294,7 +2293,7 @@ NtResetWriteWatch(IN HANDLE ProcessHandle, // Process = PsGetCurrentProcess(); } - else + else { // // Reference the target @@ -2307,7 +2306,7 @@ NtResetWriteWatch(IN HANDLE ProcessHandle, NULL); if (!NT_SUCCESS(Status)) return Status; } - + // // Compute the last address and validate it // @@ -2320,17 +2319,17 @@ NtResetWriteWatch(IN HANDLE ProcessHandle, if (ProcessHandle != NtCurrentProcess()) ObDereferenceObject(Process); return STATUS_INVALID_PARAMETER_3; } - + // // Oops :( // UNIMPLEMENTED; - + // // Dereference if needed // if (ProcessHandle != NtCurrentProcess()) ObDereferenceObject(Process); - + // // Return success // @@ -2420,7 +2419,7 @@ MiQueryMemoryBasicInformation(IN HANDLE ProcessHandle, (PVOID*)&TargetProcess, NULL); if (!NT_SUCCESS(Status)) return Status; - + /* Attach to it now */ KeStackAttachProcess(&TargetProcess->Pcb, &ApcState); } @@ -2542,14 +2541,14 @@ MiQueryMemoryBasicInformation(IN HANDLE ProcessHandle, /* This must be a VM VAD */ ASSERT(Vad->u.VadFlags.PrivateMemory); - + /* Build the initial information block */ Address = PAGE_ALIGN(BaseAddress); MemoryInfo.BaseAddress = Address; MemoryInfo.AllocationBase = (PVOID)(Vad->StartingVpn << PAGE_SHIFT); MemoryInfo.AllocationProtect = MmProtectToValue[Vad->u.VadFlags.Protection]; MemoryInfo.Type = MEM_PRIVATE; - + /* Find the largest chunk of memory which has the same state and protection mask */ MemoryInfo.State = MiQueryAddressState(Address, Vad, @@ -2722,7 +2721,7 @@ NtQueryVirtualMemory(IN HANDLE ProcessHandle, return STATUS_INFO_LENGTH_MISMATCH; } Status = MiQueryMemoryBasicInformation(ProcessHandle, - BaseAddress, + BaseAddress, MemoryInformation, MemoryInformationLength, ReturnLength); @@ -2736,7 +2735,7 @@ NtQueryVirtualMemory(IN HANDLE ProcessHandle, return STATUS_INFO_LENGTH_MISMATCH; } Status = MiQueryMemorySectionName(ProcessHandle, - BaseAddress, + BaseAddress, MemoryInformation, MemoryInformationLength, ReturnLength); diff --git a/reactos/ntoskrnl/mm/ARM3/zeropage.c b/reactos/ntoskrnl/mm/ARM3/zeropage.c index 5a7aee0d3a6..7a40bf6d747 100644 --- a/reactos/ntoskrnl/mm/ARM3/zeropage.c +++ b/reactos/ntoskrnl/mm/ARM3/zeropage.c @@ -12,7 +12,6 @@ #define NDEBUG #include -#line 15 "ARM³::ZEROPAGE" #define MODULE_INVOLVED_IN_ARM3 #include "../ARM3/miarm.h" @@ -35,7 +34,7 @@ MmZeroPageThread(VOID) PVOID ZeroAddress; PFN_NUMBER PageIndex, FreePage; PMMPFN Pfn1; - + /* FIXME: Get the discardable sections to free them */ // MiFindInitializationCode(&StartAddress, &EndAddress); // if (StartAddress) MiFreeInitializationCode(StartAddress, EndAddress); @@ -44,7 +43,7 @@ MmZeroPageThread(VOID) /* Set our priority to 0 */ Thread->BasePriority = 0; KeSetPriorityThread(Thread, 0); - + /* Setup the wait objects */ WaitObjects[0] = &MmZeroingPageEvent; // WaitObjects[1] = &PoSystemIdleTimer; FIXME: Implement idle timer @@ -75,7 +74,7 @@ MmZeroPageThread(VOID) MI_SET_USAGE(MI_USAGE_ZERO_LOOP); MI_SET_PROCESS2("Kernel 0 Loop"); FreePage = MiRemoveAnyPage(MI_GET_PAGE_COLOR(PageIndex)); - + /* The first global free page should also be the first on its own list */ if (FreePage != PageIndex) { @@ -85,15 +84,15 @@ MmZeroPageThread(VOID) PageIndex, 0); } - + Pfn1->u1.Flink = LIST_HEAD; KeReleaseQueuedSpinLock(LockQueuePfnLock, OldIrql); - + ZeroAddress = MiMapPagesToZeroInHyperSpace(Pfn1, 1); ASSERT(ZeroAddress); RtlZeroMemory(ZeroAddress, PAGE_SIZE); MiUnmapPagesInZeroSpace(ZeroAddress, 1); - + OldIrql = KeAcquireQueuedSpinLock(LockQueuePfnLock); MiInsertPageInList(&MmZeroedPageListHead, PageIndex); diff --git a/reactos/ntoskrnl/mm/arm/page.c b/reactos/ntoskrnl/mm/arm/page.c index 549b65a9613..1820d9101b8 100644 --- a/reactos/ntoskrnl/mm/arm/page.c +++ b/reactos/ntoskrnl/mm/arm/page.c @@ -12,7 +12,6 @@ #define NDEBUG #include -#line 15 "ARM³::ARMPAGE" #define MODULE_INVOLVED_IN_ARM3 #include "../ARM3/miarm.h" @@ -329,7 +328,7 @@ MmInitGlobalKernelPageDirectory(VOID) ULONG i; PULONG CurrentPageDirectory = (PULONG)PDE_BASE; - + /* Loop the 2GB of address space which belong to the kernel */ for (i = MiGetPdeOffset(MmSystemRangeStart); i < 2048; i++) { From 8354381c8be13adbcfe4e2c056e52b985be9df5c Mon Sep 17 00:00:00 2001 From: Daniel Reimer Date: Sun, 26 Dec 2010 16:25:30 +0000 Subject: [PATCH 125/181] Sync xcopy, iexplore, winhlp32, wordpad and write to wine 1.3.10 svn path=/trunk/; revision=50150 --- .../base/applications/cmdutils/xcopy/It.rc | 2 +- .../base/applications/cmdutils/xcopy/Ko.rc | 2 +- .../base/applications/cmdutils/xcopy/Sr.rc | 141 +++++++ .../base/applications/cmdutils/xcopy/rsrc.rc | 1 + .../base/applications/cmdutils/xcopy/xcopy.c | 351 +++++++++++------- .../base/applications/cmdutils/xcopy/xcopy.h | 1 + .../base/applications/iexplore/iexplore.rc | 4 +- reactos/base/applications/winhlp32/Ko.rc | 110 +++--- reactos/base/applications/winhlp32/Zh.rc | 56 ++- reactos/base/applications/winhlp32/rsrc.rc | 2 +- reactos/base/applications/wordpad/Zh.rc | 6 +- reactos/base/applications/wordpad/wordpad.c | 8 +- reactos/base/applications/write/Sr.rc | 38 ++ reactos/base/applications/write/Zh.rc | 31 ++ reactos/base/applications/write/rsrc.rc | 2 + 15 files changed, 550 insertions(+), 205 deletions(-) create mode 100644 reactos/base/applications/cmdutils/xcopy/Sr.rc create mode 100644 reactos/base/applications/write/Sr.rc create mode 100644 reactos/base/applications/write/Zh.rc diff --git a/reactos/base/applications/cmdutils/xcopy/It.rc b/reactos/base/applications/cmdutils/xcopy/It.rc index 2978c0db147..2a1cae94ea5 100644 --- a/reactos/base/applications/cmdutils/xcopy/It.rc +++ b/reactos/base/applications/cmdutils/xcopy/It.rc @@ -34,7 +34,7 @@ STRINGTABLE STRING_SIMCOPY, "%d file saranno copiati\n" STRING_COPY, "%d file copiato/i\n" STRING_QISDIR, "'%s' è il nome di un file o una cartella\n\ - nell'obiettivo?\n\ + nella destinazione?\n\ (F - File, C - Cartella)\n" STRING_SRCPROMPT,"%s? (Sì|No)\n" STRING_OVERWRITE,"Sovrascrivere %s? (Sì|No|Tutti)\n" diff --git a/reactos/base/applications/cmdutils/xcopy/Ko.rc b/reactos/base/applications/cmdutils/xcopy/Ko.rc index bb46a36499a..8a68ebe4fe0 100644 --- a/reactos/base/applications/cmdutils/xcopy/Ko.rc +++ b/reactos/base/applications/cmdutils/xcopy/Ko.rc @@ -56,7 +56,7 @@ XCOPY ì›ë³¸ [대ìƒ] [/I] [/S] [/Q] [/F] [/L] [/W] [/T] [/N] [/U]\n\ \n\ Where:\n\ \n\ -[/I] 만약 대ìƒì´ 존재하지 않는 경우 디렉토리로 가정하고 ë‘개나 ë” ë§Žì€ íŒŒì¼ì„ \n\ +[/I] 만약 대ìƒì´ 존재하지 않는 경우 디렉토리로 가정하고 ë‘개나 ë” ë§Žì€ íŒŒì¼ì„\n\ \t복사\n\ [/S] 디렉토리하고 하위 디렉토리 복사\n\ [/E] 빈 디렉토리를 í¬í•¨í•´ì„œ 디렉토리와 하위 디렉토리 복사\n\ diff --git a/reactos/base/applications/cmdutils/xcopy/Sr.rc b/reactos/base/applications/cmdutils/xcopy/Sr.rc new file mode 100644 index 00000000000..92f7ef3860b --- /dev/null +++ b/reactos/base/applications/cmdutils/xcopy/Sr.rc @@ -0,0 +1,141 @@ +/* + * XCOPY - Wine-compatible xcopy program + * Serbian language support + * + * Copyright (C) 2007 J. Edmeades + * Copyright 2010 ÄorÄ‘e Vasiljević + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "xcopy.h" + +#pragma code_page(65001) + +LANGUAGE LANG_SERBIAN, SUBLANG_SERBIAN_CYRILLIC + +STRINGTABLE +{ + STRING_INVPARMS, "ÐеиÑправан број параметара. КориÑтите xcopy /? за помоћ\n" + STRING_INVPARM, "ÐеиÑправан параметар „%s“. КориÑтите xcopy /? за помоћ\n" + STRING_PAUSE, "ПритиÑните да започнете умножавање\n" + STRING_SIMCOPY, "%d датотека/е ће бити уможено\n" + STRING_COPY, "%d датотека/е је умножено\n" + STRING_QISDIR, "Да ли је „%s“ назив датотеке или фаÑцикла\n\ + на одредишту?\n\ + (Д - датотека, Ф - фаÑцикла)\n" + STRING_SRCPROMPT,"%s? (Да|Ðе)\n" + STRING_OVERWRITE,"Заменити %s? (Да|Ðе|Све)\n" + STRING_COPYFAIL, "Умножавање „%s“ у „%s“ није уÑпело Ñа r/c %d\n" + STRING_OPENFAIL, "Отварање „%s“ датотеке није уÑпело\n" + STRING_READFAIL, "Читање „%s“ датотеке није уÑпело\n" + STRING_YES_CHAR, "Д" + STRING_NO_CHAR, "Ð" + STRING_ALL_CHAR, "С" + STRING_FILE_CHAR,"Д" + STRING_DIR_CHAR, "Ф" + + STRING_HELP, +"XCOPY — умножава изворне датотеке или гране фаÑцикли у одредиште\n\ +\n\ +СинтакÑа:\n\ +XCOPY извор [dest] [/I] [/S] [/Q] [/F] [/L] [/W] [/T] [/N] [/U]\n\ +\t [/R] [/H] [/C] [/P] [/A] [/M] [/E] [/D] [/Y] [/-Y]\n\ +\n\ +Где:\n\ +\n\ +[/I] ПретпоÑтави фаÑциклу када одредиште не поÑтоји и када Ñе умножавају две или\n\ +\tвише датотека\n\ +[/S] Умножи фаÑцикле и потфаÑцикле\n\ +[/E] Умножи фаÑцикле и потфаÑцикле заједно Ñ Ð¿Ñ€Ð°Ð·Ð½Ð¸Ð¼\n\ +[/Q] Ðе приказуј називе током умножавања.\n\ +[/F] Прикажи цео извор и одредиште током умножавања\n\ +[/L] Опонашај радњу приказујући називе који ће бити умножени\n\ +[/W] Питај пре почињања умножавања\n\ +[/T] Прави празну Ñтруктуру фаÑцикле, али не умножава датотеке\n\ +[/Y] ПотиÑни упит при замењивању датотека\n\ +[/-Y] Омогући упит при замењивању датотека\n\ +[/P] Питај за Ñваку изворну датотеку пре умножавања\n\ +[/N] Умножи кориÑтећи кратке називе\n\ +[/U] Умножи Ñамо оне датотеке које поÑтоје у одредишту\n\ +[/R] Замени Ñве датотеке које Ñе Ñамо читају\n\ +[/H] Укључи Ñакривене и ÑиÑтемÑке датотеке у умножавање\n\ +[/C] ÐаÑтави иако дође до грешке у умножавању\n\ +[/A] Умножи Ñамо архивиране датотеке\n\ +[/M] Умножи Ñамо архивиране датотеке и уклони\n\ +\tоÑобине архиве\n\ +[/D | /D:m-d-y] Умножи нове или измењене датотеке након одређеног датума.\n\ +\t\tÐко датум није унеÑен, умножи Ñамо ако је одредиште Ñтарије\n\ +\t\tод извора\n\n" + +} + +LANGUAGE LANG_SERBIAN, SUBLANG_SERBIAN_LATIN + +STRINGTABLE +{ + STRING_INVPARMS, "Neispravan broj parametara. Koristite xcopy /? za pomoć\n" + STRING_INVPARM, "Neispravan parametar „%s“. Koristite xcopy /? za pomoć\n" + STRING_PAUSE, "Pritisnite da zapoÄnete umnožavanje\n" + STRING_SIMCOPY, "%d datoteka/e će biti umoženo\n" + STRING_COPY, "%d datoteka/e je umnoženo\n" + STRING_QISDIR, "Da li je „%s“ naziv datoteke ili fascikla\n\ + na odrediÅ¡tu?\n\ + (D - datoteka, F - fascikla)\n" + STRING_SRCPROMPT,"%s? (Da|Ne)\n" + STRING_OVERWRITE,"Zameniti %s? (Da|Ne|Sve)\n" + STRING_COPYFAIL, "Umnožavanje „%s“ u „%s“ nije uspelo sa r/c %d\n" + STRING_OPENFAIL, "Otvaranje „%s“ datoteke nije uspelo\n" + STRING_READFAIL, "ÄŒitanje „%s“ datoteke nije uspelo\n" + STRING_YES_CHAR, "D" + STRING_NO_CHAR, "N" + STRING_ALL_CHAR, "S" + STRING_FILE_CHAR,"D" + STRING_DIR_CHAR, "F" + + STRING_HELP, +"XCOPY — umnožava izvorne datoteke ili grane fascikli u odrediÅ¡te\n\ +\n\ +Sintaksa:\n\ +XCOPY izvor [dest] [/I] [/S] [/Q] [/F] [/L] [/W] [/T] [/N] [/U]\n\ +\t [/R] [/H] [/C] [/P] [/A] [/M] [/E] [/D] [/Y] [/-Y]\n\ +\n\ +Gde:\n\ +\n\ +[/I] Pretpostavi fasciklu kada odrediÅ¡te ne postoji i kada se umnožavaju dve ili\n\ +\tviÅ¡e datoteka\n\ +[/S] Umnoži fascikle i potfascikle\n\ +[/E] Umnoži fascikle i potfascikle zajedno s praznim\n\ +[/Q] Ne prikazuj nazive tokom umnožavanja.\n\ +[/F] Prikaži ceo izvor i odrediÅ¡te tokom umnožavanja\n\ +[/L] OponaÅ¡aj radnju prikazujući nazive koji će biti umnoženi\n\ +[/W] Pitaj pre poÄinjanja umnožavanja\n\ +[/T] Pravi praznu strukturu fascikle, ali ne umnožava datoteke\n\ +[/Y] Potisni upit pri zamenjivanju datoteka\n\ +[/-Y] Omogući upit pri zamenjivanju datoteka\n\ +[/P] Pitaj za svaku izvornu datoteku pre umnožavanja\n\ +[/N] Umnoži koristeći kratke nazive\n\ +[/U] Umnoži samo one datoteke koje postoje u odrediÅ¡tu\n\ +[/R] Zameni sve datoteke koje se samo Äitaju\n\ +[/H] UkljuÄi sakrivene i sistemske datoteke u umnožavanje\n\ +[/C] Nastavi iako doÄ‘e do greÅ¡ke u umnožavanju\n\ +[/A] Umnoži samo arhivirane datoteke\n\ +[/M] Umnoži samo arhivirane datoteke i ukloni\n\ +\tosobine arhive\n\ +[/D | /D:m-d-y] Umnoži nove ili izmenjene datoteke nakon odreÄ‘enog datuma.\n\ +\t\tAko datum nije unesen, umnoži samo ako je odrediÅ¡te starije\n\ +\t\tod izvora\n\n" + +} diff --git a/reactos/base/applications/cmdutils/xcopy/rsrc.rc b/reactos/base/applications/cmdutils/xcopy/rsrc.rc index 7d4990c5763..ec82d6116f6 100644 --- a/reactos/base/applications/cmdutils/xcopy/rsrc.rc +++ b/reactos/base/applications/cmdutils/xcopy/rsrc.rc @@ -43,5 +43,6 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL #include "Ro.rc" #include "Ru.rc" #include "Si.rc" +#include "Sr.rc" #include "Sv.rc" #include "Uk.rc" diff --git a/reactos/base/applications/cmdutils/xcopy/xcopy.c b/reactos/base/applications/cmdutils/xcopy/xcopy.c index 4572374de9f..daf269b99b7 100644 --- a/reactos/base/applications/cmdutils/xcopy/xcopy.c +++ b/reactos/base/applications/cmdutils/xcopy/xcopy.c @@ -49,6 +49,8 @@ WINE_DEFAULT_DEBUG_CHANNEL(xcopy); /* Prototypes */ +static int XCOPY_ParseCommandLine(WCHAR *suppliedsource, + WCHAR *supplieddestination, DWORD *flags); static int XCOPY_ProcessSourceParm(WCHAR *suppliedsource, WCHAR *stem, WCHAR *spec, DWORD flags); static int XCOPY_ProcessDestParm(WCHAR *supplieddestination, WCHAR *stem, @@ -108,17 +110,6 @@ int wmain (int argc, WCHAR *argvW[]) const WCHAR PROMPTSTR1[] = {'/', 'Y', 0}; const WCHAR PROMPTSTR2[] = {'/', 'y', 0}; const WCHAR COPYCMD[] = {'C', 'O', 'P', 'Y', 'C', 'M', 'D', 0}; - const WCHAR EXCLUDE[] = {'E', 'X', 'C', 'L', 'U', 'D', 'E', ':', 0}; - - /* - * Parse the command line - */ - - /* Confirm at least one parameter */ - if (argc < 2) { - XCOPY_wprintf(XCOPY_LoadMessage(STRING_INVPARMS)); - return RC_INITERROR; - } /* Preinitialize flags based on COPYCMD */ if (GetEnvironmentVariableW(COPYCMD, copyCmd, MAXSTRING)) { @@ -135,126 +126,17 @@ int wmain (int argc, WCHAR *argvW[]) lose */ flags |= OPT_COPYHIDSYS; - /* Skip first arg, which is the program name */ - argvW++; - - while (argc > 1) - { - argc--; - WINE_TRACE("Processing Arg: '%s'\n", wine_dbgstr_w(*argvW)); - - /* First non-switch parameter is source, second is destination */ - if (*argvW[0] != '/') { - if (suppliedsource[0] == 0x00) { - lstrcpyW(suppliedsource, *argvW); - } else if (supplieddestination[0] == 0x00) { - lstrcpyW(supplieddestination, *argvW); - } else { - XCOPY_wprintf(XCOPY_LoadMessage(STRING_INVPARMS)); - return RC_INITERROR; - } - } else { - /* Process all the switch options - Note: Windows docs say /P prompts when dest is created - but tests show it is done for each src file - regardless of the destination */ - switch (toupper(argvW[0][1])) { - case 'I': flags |= OPT_ASSUMEDIR; break; - case 'S': flags |= OPT_RECURSIVE; break; - case 'Q': flags |= OPT_QUIET; break; - case 'F': flags |= OPT_FULL; break; - case 'L': flags |= OPT_SIMULATE; break; - case 'W': flags |= OPT_PAUSE; break; - case 'T': flags |= OPT_NOCOPY | OPT_RECURSIVE; break; - case 'Y': flags |= OPT_NOPROMPT; break; - case 'N': flags |= OPT_SHORTNAME; break; - case 'U': flags |= OPT_MUSTEXIST; break; - case 'R': flags |= OPT_REPLACEREAD; break; - case 'H': flags |= OPT_COPYHIDSYS; break; - case 'C': flags |= OPT_IGNOREERRORS; break; - case 'P': flags |= OPT_SRCPROMPT; break; - case 'A': flags |= OPT_ARCHIVEONLY; break; - case 'M': flags |= OPT_ARCHIVEONLY | - OPT_REMOVEARCH; break; - - /* E can be /E or /EXCLUDE */ - case 'E': if (CompareStringW(LOCALE_USER_DEFAULT, - NORM_IGNORECASE | SORT_STRINGSORT, - &argvW[0][1], 8, - EXCLUDE, -1) == 2) { - if (XCOPY_ProcessExcludeList(&argvW[0][9])) { - XCOPY_FailMessage(ERROR_INVALID_PARAMETER); - return RC_INITERROR; - } else flags |= OPT_EXCLUDELIST; - } else flags |= OPT_EMPTYDIR | OPT_RECURSIVE; - break; - - /* D can be /D or /D: */ - case 'D': if ((argvW[0][2])==':' && isdigit(argvW[0][3])) { - SYSTEMTIME st; - WCHAR *pos = &argvW[0][3]; - BOOL isError = FALSE; - memset(&st, 0x00, sizeof(st)); - - /* Parse the arg : Month */ - st.wMonth = _wtol(pos); - while (*pos && isdigit(*pos)) pos++; - if (*pos++ != '-') isError = TRUE; - - /* Parse the arg : Day */ - if (!isError) { - st.wDay = _wtol(pos); - while (*pos && isdigit(*pos)) pos++; - if (*pos++ != '-') isError = TRUE; - } - - /* Parse the arg : Day */ - if (!isError) { - st.wYear = _wtol(pos); - if (st.wYear < 100) st.wYear+=2000; - } - - if (!isError && SystemTimeToFileTime(&st, &dateRange)) { - SYSTEMTIME st; - WCHAR datestring[32], timestring[32]; - - flags |= OPT_DATERANGE; - - /* Debug info: */ - FileTimeToSystemTime (&dateRange, &st); - GetDateFormatW(0, DATE_SHORTDATE, &st, NULL, datestring, - sizeof(datestring)/sizeof(WCHAR)); - GetTimeFormatW(0, TIME_NOSECONDS, &st, - NULL, timestring, sizeof(timestring)/sizeof(WCHAR)); - - WINE_TRACE("Date being used is: %s %s\n", - wine_dbgstr_w(datestring), wine_dbgstr_w(timestring)); - } else { - XCOPY_FailMessage(ERROR_INVALID_PARAMETER); - return RC_INITERROR; - } - } else { - flags |= OPT_DATENEWER; - } - break; - - case '-': if (toupper(argvW[0][2])=='Y') - flags &= ~OPT_NOPROMPT; break; - case '?': XCOPY_wprintf(XCOPY_LoadMessage(STRING_HELP)); - return RC_OK; - default: - WINE_TRACE("Unhandled parameter '%s'\n", wine_dbgstr_w(*argvW)); - XCOPY_wprintf(XCOPY_LoadMessage(STRING_INVPARM), *argvW); - return RC_INITERROR; - } - } - argvW++; + /* + * Parse the command line + */ + if ((rc = XCOPY_ParseCommandLine(suppliedsource, supplieddestination, + &flags)) != RC_OK) { + if (rc == RC_HELP) + return RC_OK; + else + return rc; } - /* Default the destination if not supplied */ - if (supplieddestination[0] == 0x00) - lstrcpyW(supplieddestination, wchr_dot); - /* Trace out the supplied information */ WINE_TRACE("Supplied parameters:\n"); WINE_TRACE("Source : '%s'\n", wine_dbgstr_w(suppliedsource)); @@ -310,6 +192,211 @@ int wmain (int argc, WCHAR *argvW[]) } +/* ========================================================================= + XCOPY_ParseCommandLine - Parses the command line + ========================================================================= */ +static BOOL is_whitespace(WCHAR c) +{ + return c == ' ' || c == '\t'; +} + +static WCHAR *skip_whitespace(WCHAR *p) +{ + for (; *p && is_whitespace(*p); p++); + return p; +} + +/* Windows XCOPY uses a simplified command line parsing algorithm + that lacks the escaped-quote logic of build_argv(), because + literal double quotes are illegal in any of its arguments. + Example: 'XCOPY "c:\DIR A" "c:DIR B\"' is OK. */ +static int find_end_of_word(const WCHAR *word, WCHAR **end) +{ + BOOL in_quotes = 0; + const WCHAR *ptr = word; + for (;;) { + for (; *ptr != '\0' && *ptr != '"' && + (in_quotes || !is_whitespace(*ptr)); ptr++); + if (*ptr == '"') { + in_quotes = !in_quotes; + ptr++; + } + /* Odd number of double quotes is illegal for XCOPY */ + if (in_quotes && *ptr == '\0') + return RC_INITERROR; + if (*ptr == '\0' || (!in_quotes && is_whitespace(*ptr))) + break; + } + *end = (WCHAR*)ptr; + return RC_OK; +} + +/* Remove all double quotes from a word */ +static void strip_quotes(WCHAR *word, WCHAR **end) +{ + WCHAR *rp, *wp; + for (rp = word, wp = word; *rp != '\0'; rp++) { + if (*rp == '"') + continue; + if (wp < rp) + *wp = *rp; + wp++; + } + *wp = '\0'; + *end = wp; +} + +static int XCOPY_ParseCommandLine(WCHAR *suppliedsource, + WCHAR *supplieddestination, DWORD *pflags) +{ + const WCHAR EXCLUDE[] = {'E', 'X', 'C', 'L', 'U', 'D', 'E', ':', 0}; + DWORD flags = *pflags; + WCHAR *cmdline, *word, *end, *next; + int rc = RC_INITERROR; + + cmdline = _wcsdup(GetCommandLineW()); + if (cmdline == NULL) + return rc; + + /* Skip first arg, which is the program name */ + if ((rc = find_end_of_word(cmdline, &word)) != RC_OK) + goto out; + word = skip_whitespace(word); + + while (*word) + { + WCHAR first; + if ((rc = find_end_of_word(word, &end)) != RC_OK) + goto out; + + next = skip_whitespace(end); + first = word[0]; + *end = '\0'; + strip_quotes(word, &end); + WINE_TRACE("Processing Arg: '%s'\n", wine_dbgstr_w(word)); + + /* First non-switch parameter is source, second is destination */ + if (first != '/') { + if (suppliedsource[0] == 0x00) { + lstrcpyW(suppliedsource, word); + } else if (supplieddestination[0] == 0x00) { + lstrcpyW(supplieddestination, word); + } else { + XCOPY_wprintf(XCOPY_LoadMessage(STRING_INVPARMS)); + goto out; + } + } else { + /* Process all the switch options + Note: Windows docs say /P prompts when dest is created + but tests show it is done for each src file + regardless of the destination */ + switch (toupper(word[1])) { + case 'I': flags |= OPT_ASSUMEDIR; break; + case 'S': flags |= OPT_RECURSIVE; break; + case 'Q': flags |= OPT_QUIET; break; + case 'F': flags |= OPT_FULL; break; + case 'L': flags |= OPT_SIMULATE; break; + case 'W': flags |= OPT_PAUSE; break; + case 'T': flags |= OPT_NOCOPY | OPT_RECURSIVE; break; + case 'Y': flags |= OPT_NOPROMPT; break; + case 'N': flags |= OPT_SHORTNAME; break; + case 'U': flags |= OPT_MUSTEXIST; break; + case 'R': flags |= OPT_REPLACEREAD; break; + case 'H': flags |= OPT_COPYHIDSYS; break; + case 'C': flags |= OPT_IGNOREERRORS; break; + case 'P': flags |= OPT_SRCPROMPT; break; + case 'A': flags |= OPT_ARCHIVEONLY; break; + case 'M': flags |= OPT_ARCHIVEONLY | + OPT_REMOVEARCH; break; + + /* E can be /E or /EXCLUDE */ + case 'E': if (CompareStringW(LOCALE_USER_DEFAULT, + NORM_IGNORECASE | SORT_STRINGSORT, + &word[1], 8, + EXCLUDE, -1) == 2) { + if (XCOPY_ProcessExcludeList(&word[9])) { + XCOPY_FailMessage(ERROR_INVALID_PARAMETER); + goto out; + } else flags |= OPT_EXCLUDELIST; + } else flags |= OPT_EMPTYDIR | OPT_RECURSIVE; + break; + + /* D can be /D or /D: */ + case 'D': if (word[2]==':' && isdigit(word[3])) { + SYSTEMTIME st; + WCHAR *pos = &word[3]; + BOOL isError = FALSE; + memset(&st, 0x00, sizeof(st)); + + /* Parse the arg : Month */ + st.wMonth = _wtol(pos); + while (*pos && isdigit(*pos)) pos++; + if (*pos++ != '-') isError = TRUE; + + /* Parse the arg : Day */ + if (!isError) { + st.wDay = _wtol(pos); + while (*pos && isdigit(*pos)) pos++; + if (*pos++ != '-') isError = TRUE; + } + + /* Parse the arg : Day */ + if (!isError) { + st.wYear = _wtol(pos); + while (*pos && isdigit(*pos)) pos++; + if (st.wYear < 100) st.wYear+=2000; + } + + if (!isError && SystemTimeToFileTime(&st, &dateRange)) { + SYSTEMTIME st; + WCHAR datestring[32], timestring[32]; + + flags |= OPT_DATERANGE; + + /* Debug info: */ + FileTimeToSystemTime (&dateRange, &st); + GetDateFormatW(0, DATE_SHORTDATE, &st, NULL, datestring, + sizeof(datestring)/sizeof(WCHAR)); + GetTimeFormatW(0, TIME_NOSECONDS, &st, + NULL, timestring, sizeof(timestring)/sizeof(WCHAR)); + + WINE_TRACE("Date being used is: %s %s\n", + wine_dbgstr_w(datestring), wine_dbgstr_w(timestring)); + } else { + XCOPY_FailMessage(ERROR_INVALID_PARAMETER); + goto out; + } + } else { + flags |= OPT_DATENEWER; + } + break; + + case '-': if (toupper(word[2])=='Y') + flags &= ~OPT_NOPROMPT; break; + case '?': XCOPY_wprintf(XCOPY_LoadMessage(STRING_HELP)); + rc = RC_HELP; + goto out; + default: + WINE_TRACE("Unhandled parameter '%s'\n", wine_dbgstr_w(word)); + XCOPY_wprintf(XCOPY_LoadMessage(STRING_INVPARM), word); + goto out; + } + } + word = next; + } + + /* Default the destination if not supplied */ + if (supplieddestination[0] == 0x00) + lstrcpyW(supplieddestination, wchr_dot); + + *pflags = flags; + rc = RC_OK; + + out: + free(cmdline); + return rc; +} + /* ========================================================================= XCOPY_ProcessSourceParm - Takes the supplied source parameter, and @@ -432,8 +519,10 @@ static int XCOPY_ProcessDestParm(WCHAR *supplieddestination, WCHAR *stem, WCHAR if (attribs == INVALID_FILE_ATTRIBUTES) { /* If /I supplied and wildcard copy, assume directory */ - if (flags & OPT_ASSUMEDIR && - (wcschr(srcspec, '?') || wcschr(srcspec, '*'))) { + /* Also if destination ends with backslash */ + if ((flags & OPT_ASSUMEDIR && + (wcschr(srcspec, '?') || wcschr(srcspec, '*'))) || + (supplieddestination[lstrlenW(supplieddestination)-1] == '\\')) { isDir = TRUE; diff --git a/reactos/base/applications/cmdutils/xcopy/xcopy.h b/reactos/base/applications/cmdutils/xcopy/xcopy.h index 1c933951284..3e9644efe8c 100644 --- a/reactos/base/applications/cmdutils/xcopy/xcopy.h +++ b/reactos/base/applications/cmdutils/xcopy/xcopy.h @@ -26,6 +26,7 @@ #define RC_CTRLC 2 #define RC_INITERROR 4 #define RC_WRITEERROR 5 +#define RC_HELP 6 #define OPT_ASSUMEDIR 0x00000001 #define OPT_RECURSIVE 0x00000002 diff --git a/reactos/base/applications/iexplore/iexplore.rc b/reactos/base/applications/iexplore/iexplore.rc index f37481a309d..64a976cf4f5 100644 --- a/reactos/base/applications/iexplore/iexplore.rc +++ b/reactos/base/applications/iexplore/iexplore.rc @@ -16,13 +16,13 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#define WINE_OLESELFREGISTER -#define WINE_FILEDESCRIPTION_STR "Wine core exe" +#define WINE_FILEDESCRIPTION_STR "Wine Internet Explorer" #define WINE_FILENAME_STR "iexplore.exe" #define WINE_FILEVERSION 6,0,2900,2180 #define WINE_FILEVERSION_STR "6.0.2900.2180" #define WINE_PRODUCTVERSION 6,0,2900,2180 #define WINE_PRODUCTVERSION_STR "6.0.2900.2180" +#define WINE_EXTRAVALUES VALUE "OLESelfRegister","" #include "wine/wine_common_ver.rc" diff --git a/reactos/base/applications/winhlp32/Ko.rc b/reactos/base/applications/winhlp32/Ko.rc index 32b32b21865..1acc2db701b 100644 --- a/reactos/base/applications/winhlp32/Ko.rc +++ b/reactos/base/applications/winhlp32/Ko.rc @@ -21,49 +21,51 @@ #include "winhelp_res.h" +#pragma code_page(65001) + LANGUAGE LANG_KOREAN, SUBLANG_DEFAULT /* Menu */ MAIN_MENU MENU { - POPUP "ÆÄÀÏ(&F)" { - MENUITEM "¿­±â(&O)...", MNID_FILE_OPEN + POPUP "파ì¼(&F)" { + MENUITEM "열기(&O)...", MNID_FILE_OPEN MENUITEM SEPARATOR - MENUITEM "Àμâ(&P)", MNID_FILE_PRINT - MENUITEM "ÇÁ¸°ÅÍ ¼³Á¤(&S)...", MNID_FILE_SETUP + MENUITEM "ì¸ì‡„(&P)", MNID_FILE_PRINT + MENUITEM "프린터 설정(&S)...", MNID_FILE_SETUP MENUITEM SEPARATOR - MENUITEM "Á¾·á(&E)", MNID_FILE_EXIT + MENUITEM "종료(&E)", MNID_FILE_EXIT } - POPUP "ÆíÁý(&E)" { - MENUITEM "º¹»ç(&C)...", MNID_EDIT_COPYDLG + POPUP "편집(&E)" { + MENUITEM "복사(&C)...", MNID_EDIT_COPYDLG MENUITEM SEPARATOR - MENUITEM "ÁÖ¼®(&A)...", MNID_EDIT_ANNOTATE + MENUITEM "주ì„(&A)...", MNID_EDIT_ANNOTATE } - POPUP "Ã¥°¥ÇÇ(&B)" { - MENUITEM "Á¤ÀÇ(&D)...", MNID_BKMK_DEFINE + POPUP "책갈피(&B)" { + MENUITEM "ì •ì˜(&D)...", MNID_BKMK_DEFINE } - POPUP "¿É¼Ç(&O)" { - POPUP "°¡´ÉÇÑ µµ¿ò¸» º¸À̱â" + POPUP "옵션(&O)" { + POPUP "가능한 ë„ì›€ë§ ë³´ì´ê¸°" BEGIN - MENUITEM "±âº»", MNID_OPTS_HELP_DEFAULT - MENUITEM "º¸À̱â", MNID_OPTS_HELP_VISIBLE - MENUITEM "º¸¿©ÁÖÁö ¾Ê±â", MNID_OPTS_HELP_NONVISIBLE + MENUITEM "기본", MNID_OPTS_HELP_DEFAULT + MENUITEM "ë³´ì´ê¸°", MNID_OPTS_HELP_VISIBLE + MENUITEM "보여주지 않기", MNID_OPTS_HELP_NONVISIBLE END - MENUITEM "±â·Ï", MNID_OPTS_HISTORY - POPUP "±Û²Ã" + MENUITEM "기ë¡", MNID_OPTS_HISTORY + POPUP "글꼴" BEGIN - MENUITEM "ÀÛ°Ô", MNID_OPTS_FONTS_SMALL - MENUITEM "º¸Åë", MNID_OPTS_FONTS_NORMAL - MENUITEM "Å©°Ô", MNID_OPTS_FONTS_LARGE + MENUITEM "작게", MNID_OPTS_FONTS_SMALL + MENUITEM "보통", MNID_OPTS_FONTS_NORMAL + MENUITEM "í¬ê²Œ", MNID_OPTS_FONTS_LARGE END - MENUITEM "½Ã½ºÅÛ »ö»ó »ç¿ë", MNID_OPTS_SYSTEM_COLORS + MENUITEM "시스템 ìƒ‰ìƒ ì‚¬ìš©", MNID_OPTS_SYSTEM_COLORS } - POPUP "µµ¿ò¸»(&H)" { - MENUITEM "µµ¿ò¸» »ç¿ë¹ý(&O)", MNID_HELP_HELPON - MENUITEM "Ç×»ó À§(&T)", MNID_HELP_HELPTOP + POPUP "ë„움ë§(&H)" { + MENUITEM "ë„ì›€ë§ ì‚¬ìš©ë²•(&O)", MNID_HELP_HELPON + MENUITEM "í•­ìƒ ìœ„(&T)", MNID_HELP_HELPTOP MENUITEM SEPARATOR - MENUITEM "Á¤º¸(&I)...", MNID_HELP_ABOUT + MENUITEM "Wine ë„ì›€ë§ ì •ë³´(&I)...", MNID_HELP_ABOUT } } @@ -71,7 +73,7 @@ MAIN_MENU MENU IDD_INDEX DIALOG 0, 0, 200, 190 STYLE DS_MODALFRAME | WS_CAPTION | WS_SYSMENU FONT 9, "MS Shell Dlg" -CAPTION "À妽º" +CAPTION "ì¸ë±ìŠ¤" { LISTBOX IDC_INDEXLIST, 10, 10, 180, 150, LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_BORDER } @@ -79,50 +81,50 @@ CAPTION " IDD_SEARCH DIALOG 0, 0, 200, 190 STYLE DS_MODALFRAME | WS_CAPTION | WS_SYSMENU FONT 9, "MS Shell Dlg" -CAPTION "ã±â" +CAPTION "찾기" { - LTEXT "¾ÆÁ÷ ±¸ÇöµÇÁö ¾ÊÀ½", -1, 10, 10, 180, 150 + LTEXT "ì•„ì§ êµ¬í˜„ë˜ì§€ ì•ŠìŒ", -1, 10, 10, 180, 150 } /* Strings */ STRINGTABLE { -STID_WINE_HELP, "Wine µµ¿ò¸»" -STID_WHERROR, "¿¡·¯" -STID_WARNING, "°æ°í" -STID_INFO, "Á¤º¸" -STID_NOT_IMPLEMENTED, "±¸ÇöµÇÁö ¾Ê¾ÒÀ½" -STID_HLPFILE_ERROR_s, "µµ¿ò¸» ÆÄÀÏ `%s'¸¦ Àд µµÁß ¿À·ù ¹ß»ý" -STID_INDEX, "¸ñÂ÷(&C)" -STID_CONTENTS, "¿ä¾à" -STID_BACK, "µÚ·Î(&B)" -STID_ALL_FILES, "¸ðµç ÆÄÀÏ (*.*)" -STID_HELP_FILES_HLP, "µµ¿ò¸» ÆÄÀÏ (*.hlp)" -STID_FILE_NOT_FOUND_s "%sÀ» ãÀ» ¼ö ¾ø½À´Ï´Ù'. ÀÌ ÆÄÀÏÀ» Á÷Á¢ ã°Ú½À´Ï±î?" -STID_NO_RICHEDIT "richedit ±¸ÇöÀ» ãÀ»¼ö ¾÷½À´Ï´Ù.. Ãë¼ÒÁß" -STID_PSH_INDEX, "µµ¿ò¸» ¸ñÂ÷: " +STID_WINE_HELP, "Wine ë„움ë§" +STID_WHERROR, "ì—러" +STID_WARNING, "경고" +STID_INFO, "ì •ë³´" +STID_NOT_IMPLEMENTED, "구현ë˜ì§€ 않았ìŒ" +STID_HLPFILE_ERROR_s, "ë„ì›€ë§ íŒŒì¼ `%s'를 ì½ëŠ” ë„중 오류 ë°œìƒ" +STID_INDEX, "목차(&C)" +STID_CONTENTS, "요약" +STID_BACK, "뒤로(&B)" +STID_ALL_FILES, "모든 íŒŒì¼ (*.*)" +STID_HELP_FILES_HLP, "ë„ì›€ë§ íŒŒì¼ (*.hlp)" +STID_FILE_NOT_FOUND_s "%sì„ ì°¾ì„ ìˆ˜ 없습니다'. ì´ íŒŒì¼ì„ ì§ì ‘ 찾겠습니까?" +STID_NO_RICHEDIT "richedit êµ¬í˜„ì„ ì°¾ì„수 업습니다.. 취소중" +STID_PSH_INDEX, "ë„ì›€ë§ ëª©ì°¨: " } CONTEXT_MENU MENU BEGIN POPUP "" BEGIN - MENUITEM "ÁÖ¼®...", MNID_CTXT_ANNOTATE - MENUITEM "º¹»ç", MNID_CTXT_COPY - MENUITEM "Àμâ...", MNID_CTXT_PRINT - POPUP "±Û²Ã" + MENUITEM "주ì„...", MNID_CTXT_ANNOTATE + MENUITEM "복사", MNID_CTXT_COPY + MENUITEM "ì¸ì‡„...", MNID_CTXT_PRINT + POPUP "글꼴" BEGIN - MENUITEM "Á¼°Ô", MNID_CTXT_FONTS_SMALL - MENUITEM "º¸Åë", MNID_CTXT_FONTS_NORMAL - MENUITEM "³Ð°Ô", MNID_CTXT_FONTS_LARGE + MENUITEM "ì¢ê²Œ", MNID_CTXT_FONTS_SMALL + MENUITEM "보통", MNID_CTXT_FONTS_NORMAL + MENUITEM "넓게", MNID_CTXT_FONTS_LARGE END - POPUP "µµ¿ò¸» Ç×»ó º¸À̱â" + POPUP "ë„ì›€ë§ í•­ìƒ ë³´ì´ê¸°" BEGIN - MENUITEM "±âº»", MNID_CTXT_HELP_DEFAULT - MENUITEM "º¸À̱â", MNID_CTXT_HELP_VISIBLE - MENUITEM "¾È º¸À̱â", MNID_CTXT_HELP_NONVISIBLE + MENUITEM "기본", MNID_CTXT_HELP_DEFAULT + MENUITEM "ë³´ì´ê¸°", MNID_CTXT_HELP_VISIBLE + MENUITEM "안 ë³´ì´ê¸°", MNID_CTXT_HELP_NONVISIBLE END - MENUITEM "½Ã½ºÅÛ »ö»ó »ç¿ë", MNID_CTXT_SYSTEM_COLORS + MENUITEM "시스템 ìƒ‰ìƒ ì‚¬ìš©", MNID_CTXT_SYSTEM_COLORS END END diff --git a/reactos/base/applications/winhlp32/Zh.rc b/reactos/base/applications/winhlp32/Zh.rc index f9d27461223..2532cb3fa54 100644 --- a/reactos/base/applications/winhlp32/Zh.rc +++ b/reactos/base/applications/winhlp32/Zh.rc @@ -4,6 +4,7 @@ * * Copyright 2002 liuspider * Copyright 2008 Hongbo Ni + * Copyright 2010 Cheer Xiao * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -37,7 +38,7 @@ MAIN_MENU MENU MENUITEM "打å°(&P)", MNID_FILE_PRINT MENUITEM "打å°æœºè®¾ç½®(&S)...", MNID_FILE_SETUP MENUITEM SEPARATOR - MENUITEM "退出(&E)", MNID_FILE_EXIT + MENUITEM "退出(&X)", MNID_FILE_EXIT } POPUP "编辑(&E)" { MENUITEM "å¤åˆ¶(&C)...", MNID_EDIT_COPYDLG @@ -48,7 +49,7 @@ MAIN_MENU MENU MENUITEM "定义(&D)...", MNID_BKMK_DEFINE } POPUP "选项(&O)" { - POPUP "显示帮助" + POPUP "总是显示帮助" BEGIN MENUITEM "默认", MNID_OPTS_HELP_DEFAULT MENUITEM "显示", MNID_OPTS_HELP_VISIBLE @@ -67,10 +68,26 @@ MAIN_MENU MENU MENUITEM "如何使用帮助(&O)", MNID_HELP_HELPON MENUITEM "总是在最å‰é¢(&T)", MNID_HELP_HELPTOP MENUITEM SEPARATOR - MENUITEM "资料信æ¯(&I)...", MNID_HELP_ABOUT + MENUITEM "关于 Wine 帮助(&I)...", MNID_HELP_ABOUT } } +IDD_INDEX DIALOG 0, 0, 200, 190 +STYLE DS_MODALFRAME | WS_CAPTION | WS_SYSMENU +FONT 8, "MS Shell Dlg" +CAPTION "索引" +{ + LISTBOX IDC_INDEXLIST, 10, 10, 180, 150, LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_BORDER +} + +IDD_SEARCH DIALOG 0, 0, 200, 190 +STYLE DS_MODALFRAME | WS_CAPTION | WS_SYSMENU +FONT 8, "MS Shell Dlg" +CAPTION "æœç´¢" +{ + LTEXT "尚未实现", -1, 10, 10, 180, 150 +} + /* Strings */ STRINGTABLE { @@ -79,17 +96,40 @@ STID_WHERROR, "错误" STID_WARNING, "警告" STID_INFO, "ä¿¡æ¯" STID_NOT_IMPLEMENTED, "未实现" -STID_HLPFILE_ERROR_s, "读入帮助文件 ‘%s’ æ—¶å‘生错误" -STID_INDEX, "内容(&C)" +STID_HLPFILE_ERROR_s, "读入帮助文件“%sâ€æ—¶å‘生错误" +STID_INDEX, "索引(&I)" STID_CONTENTS, "概è¦" STID_BACK, "返回(&B)" STID_ALL_FILES, "所有文件 (*.*)" STID_HELP_FILES_HLP, "帮助文件 (*.hlp)" -STID_FILE_NOT_FOUND_s "ä¸èƒ½æ‰“开文件 '%s'. 你想è¦è‡ªå·±æ‰¾è¿™ä¸ªæ–‡ä»¶å—?" -STID_NO_RICHEDIT "找ä¸åˆ° richedit... 终止" -STID_PSH_INDEX, "帮助内容: " +STID_FILE_NOT_FOUND_s "找ä¸åˆ°æ–‡ä»¶â€œ%sâ€ã€‚ 你想è¦è‡ªå·±æ‰¾è¿™ä¸ªæ–‡ä»¶å—?" +STID_NO_RICHEDIT "找ä¸åˆ° richedit 的实现……终止" +STID_PSH_INDEX, "帮助主题:" } +CONTEXT_MENU MENU +BEGIN + POPUP "" + BEGIN + MENUITEM "注释...", MNID_CTXT_ANNOTATE + MENUITEM "å¤åˆ¶", MNID_CTXT_COPY + MENUITEM "打å°...", MNID_CTXT_PRINT + POPUP "字体" + BEGIN + MENUITEM "å°å·", MNID_CTXT_FONTS_SMALL + MENUITEM "中å·", MNID_CTXT_FONTS_NORMAL + MENUITEM "大å·", MNID_CTXT_FONTS_LARGE + END + POPUP "总是显示帮助" + BEGIN + MENUITEM "默认", MNID_CTXT_HELP_DEFAULT + MENUITEM "显示", MNID_CTXT_HELP_VISIBLE + MENUITEM "ä¸æ˜¾ç¤º", MNID_CTXT_HELP_NONVISIBLE + END + MENUITEM "使用系统颜色", MNID_CTXT_SYSTEM_COLORS + END +END + LANGUAGE LANG_CHINESE, SUBLANG_CHINESE_TRADITIONAL /* Menu */ diff --git a/reactos/base/applications/winhlp32/rsrc.rc b/reactos/base/applications/winhlp32/rsrc.rc index 6bf84754f48..303366abf9a 100644 --- a/reactos/base/applications/winhlp32/rsrc.rc +++ b/reactos/base/applications/winhlp32/rsrc.rc @@ -30,7 +30,6 @@ IDI_WINHELP ICON winhelp.ico #include "Es.rc" #include "Fi.rc" #include "Hu.rc" -#include "Ko.rc" #include "No.rc" #include "Pl.rc" #include "Sk.rc" @@ -44,6 +43,7 @@ IDI_WINHELP ICON winhelp.ico #include "He.rc" #include "It.rc" #include "Ja.rc" +#include "Ko.rc" #include "Lt.rc" #include "Nl.rc" #include "Pt.rc" diff --git a/reactos/base/applications/wordpad/Zh.rc b/reactos/base/applications/wordpad/Zh.rc index cd13c719a85..b2689fa72a2 100644 --- a/reactos/base/applications/wordpad/Zh.rc +++ b/reactos/base/applications/wordpad/Zh.rc @@ -61,7 +61,7 @@ BEGIN MENUITEM SEPARATOR POPUP "其他(&X)" BEGIN - MENUITEM "选中信æ¯(&I)", ID_EDIT_SELECTIONINFO + MENUITEM "选中信æ¯(&I)", ID_EDIT_SELECTIONINFO /* 准确性待议 */ MENUITEM "文字格å¼(&F)", ID_EDIT_CHARFORMAT MENUITEM "默认格å¼(&D)", ID_EDIT_DEFCHARFORMAT MENUITEM "段è½æ ¼å¼(&H)", ID_EDIT_PARAFORMAT @@ -118,7 +118,7 @@ BEGIN BEGIN MENUITEM "黑色", ID_COLOR_BLACK /* 未找到“标准译å表†*/ MENUITEM "栗色", ID_COLOR_MAROON - MENUITEM "调和绿", ID_COLOR_GREEN + MENUITEM "绿色", ID_COLOR_GREEN MENUITEM "橄榄色" ID_COLOR_OLIVE MENUITEM "è—é’" ID_COLOR_NAVY MENUITEM "紫色" ID_COLOR_PURPLE @@ -126,7 +126,7 @@ BEGIN MENUITEM "ç°è‰²" ID_COLOR_GRAY MENUITEM "银色" ID_COLOR_SILVER MENUITEM "红色" ID_COLOR_RED - MENUITEM "绿色" ID_COLOR_LIME + MENUITEM "é’柠色" ID_COLOR_LIME MENUITEM "黄色" ID_COLOR_YELLOW MENUITEM "è“色" ID_COLOR_BLUE MENUITEM "洋红" ID_COLOR_FUCHSIA /* =magenta? */ diff --git a/reactos/base/applications/wordpad/wordpad.c b/reactos/base/applications/wordpad/wordpad.c index 187aef09842..db7546bfb1a 100644 --- a/reactos/base/applications/wordpad/wordpad.c +++ b/reactos/base/applications/wordpad/wordpad.c @@ -162,7 +162,7 @@ static void AddButton(HWND hwndToolBar, int nImage, int nCommand) button.iBitmap = nImage; button.idCommand = nCommand; button.fsState = TBSTATE_ENABLED; - button.fsStyle = TBSTYLE_BUTTON; + button.fsStyle = BTNS_BUTTON; button.dwData = 0; button.iString = -1; SendMessageW(hwndToolBar, TB_ADDBUTTONSW, 1, (LPARAM)&button); @@ -176,7 +176,7 @@ static void AddSeparator(HWND hwndToolBar) button.iBitmap = -1; button.idCommand = 0; button.fsState = 0; - button.fsStyle = TBSTYLE_SEP; + button.fsStyle = BTNS_SEP; button.dwData = 0; button.iString = -1; SendMessageW(hwndToolBar, TB_ADDBUTTONSW, 1, (LPARAM)&button); @@ -1818,7 +1818,7 @@ static LRESULT OnCreate( HWND hWnd ) if(!SendMessageW(hReBarWnd, RB_SETBARINFO, 0, (LPARAM)&rbi)) return -1; - hToolBarWnd = CreateToolbarEx(hReBarWnd, CCS_NOPARENTALIGN|CCS_NOMOVEY|WS_VISIBLE|WS_CHILD|TBSTYLE_TOOLTIPS|TBSTYLE_BUTTON, + hToolBarWnd = CreateToolbarEx(hReBarWnd, CCS_NOPARENTALIGN|CCS_NOMOVEY|WS_VISIBLE|WS_CHILD|TBSTYLE_TOOLTIPS|BTNS_BUTTON, IDC_TOOLBAR, 1, hInstance, IDB_TOOLBAR, NULL, 0, @@ -1880,7 +1880,7 @@ static LRESULT OnCreate( HWND hWnd ) SendMessageW(hReBarWnd, RB_INSERTBAND, -1, (LPARAM)&rbb); hFormatBarWnd = CreateToolbarEx(hReBarWnd, - CCS_NOPARENTALIGN | CCS_NOMOVEY | WS_VISIBLE | TBSTYLE_TOOLTIPS | TBSTYLE_BUTTON, + CCS_NOPARENTALIGN | CCS_NOMOVEY | WS_VISIBLE | TBSTYLE_TOOLTIPS | BTNS_BUTTON, IDC_FORMATBAR, 8, hInstance, IDB_FORMATBAR, NULL, 0, 16, 16, 16, 16, sizeof(TBBUTTON)); AddButton(hFormatBarWnd, 0, ID_FORMAT_BOLD); diff --git a/reactos/base/applications/write/Sr.rc b/reactos/base/applications/write/Sr.rc new file mode 100644 index 00000000000..da4dae9fd4f --- /dev/null +++ b/reactos/base/applications/write/Sr.rc @@ -0,0 +1,38 @@ +/* + * Serbian language support + * + * Copyright (C) 2007 Mikolaj Zalewski + * Copyright 2010 ÄorÄ‘e Vasiljević + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "resources.h" + +#pragma code_page(65001) + +LANGUAGE LANG_SERBIAN, SUBLANG_SERBIAN_CYRILLIC + +STRINGTABLE +{ + IDS_FAILED, "Покретање ПиÑанке није уÑпело" +} + +LANGUAGE LANG_SERBIAN, SUBLANG_SERBIAN_LATIN + +STRINGTABLE +{ + IDS_FAILED, "Pokretanje Pisanke nije uspelo" +} diff --git a/reactos/base/applications/write/Zh.rc b/reactos/base/applications/write/Zh.rc new file mode 100644 index 00000000000..1ff92b3360e --- /dev/null +++ b/reactos/base/applications/write/Zh.rc @@ -0,0 +1,31 @@ +/* + * Simplified Chinese language support + * + * Copyright (C) 2010 Cheer Xiao + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "resources.h" + +/* Chinese text is encoded in UTF-8 */ +#pragma code_page(65001) + +LANGUAGE LANG_CHINESE, SUBLANG_CHINESE_SIMPLIFIED + +STRINGTABLE +{ + IDS_FAILED, "å¯åŠ¨å†™å­—æ¿å¤±è´¥" +} diff --git a/reactos/base/applications/write/rsrc.rc b/reactos/base/applications/write/rsrc.rc index 70113567651..b1500b0cc1f 100644 --- a/reactos/base/applications/write/rsrc.rc +++ b/reactos/base/applications/write/rsrc.rc @@ -39,4 +39,6 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL #include "Ro.rc" #include "Ru.rc" #include "Si.rc" +#include "Sr.rc" #include "Uk.rc" +#include "Zh.rc" From 0093430c8111006388bf779d70d734e3b4d5092b Mon Sep 17 00:00:00 2001 From: Daniel Reimer Date: Sun, 26 Dec 2010 16:28:51 +0000 Subject: [PATCH 126/181] Update Winefile to 1.3.10 too svn path=/trunk/; revision=50151 --- rosapps/applications/winfile/It.rc | 88 ++++++++++++------------- rosapps/applications/winfile/winefile.c | 6 +- 2 files changed, 46 insertions(+), 48 deletions(-) diff --git a/rosapps/applications/winfile/It.rc b/rosapps/applications/winfile/It.rc index 22db037a931..606143902d0 100644 --- a/rosapps/applications/winfile/It.rc +++ b/rosapps/applications/winfile/It.rc @@ -38,7 +38,7 @@ IDM_WINEFILE MENU MENUITEM "&Apri\tInvio", ID_ACTIVATE MENUITEM "&Sposta...\tF7", ID_FILE_MOVE MENUITEM "&Copia...\tF8", ID_FILE_COPY - MENUITEM "&Negli Appunti...\tF9", 118 + MENUITEM "&Negli appunti...\tF9", 118 MENUITEM "&Cancella\tDel", ID_FILE_DELETE MENUITEM "Ri&nomina...", 109 MENUITEM "Propri&età...\tAlt+Invio", ID_EDIT_PROPERTIES @@ -50,7 +50,7 @@ IDM_WINEFILE MENU MENUITEM "&Stampa...", 102 MENUITEM "Associa...", 103 MENUITEM SEPARATOR - MENUITEM "Cr&ea Directory...", 111 + MENUITEM "Cr&ea cartella...", 111 MENUITEM "Cerc&a...", 104 MENUITEM "&Seleziona i file...", 116 MENUITEM SEPARATOR @@ -62,65 +62,65 @@ IDM_WINEFILE MENU } POPUP "&Disco" { - MENUITEM "&Copia Disco...", 201 - MENUITEM "&Etichetta Disco...", 202 + MENUITEM "&Copia disco...", 201 + MENUITEM "&Etichetta disco...", 202 MENUITEM SEPARATOR - MENUITEM "&Formatta Disco...", ID_FORMAT_DISK + MENUITEM "&Formatta disco...", ID_FORMAT_DISK #ifdef _WIN95 - MENUITEM "&Crea Disco di Sistema...", -1 /*TODO*/ + MENUITEM "&Crea disco di sistema...", -1 /*TODO*/ #endif MENUITEM SEPARATOR - MENUITEM "Connetti & Drive di Rete", ID_CONNECT_NETWORK_DRIVE - MENUITEM "&Disconnetti Drive di Rete", ID_DISCONNECT_NETWORK_DRIVE + MENUITEM "Connetti unità di rete", ID_CONNECT_NETWORK_DRIVE + MENUITEM "&Disconnetti unità di rete", ID_DISCONNECT_NETWORK_DRIVE MENUITEM SEPARATOR MENUITEM "Condividi come...", 254 MENUITEM "&Rimuovi condivisione...", 255 MENUITEM SEPARATOR - MENUITEM "&Seleziona Drive...", 251 + MENUITEM "&Seleziona unità...", 251 } POPUP "&Directory" { - MENUITEM "&Livello Sucessivo\t+", 301 - MENUITEM "Espandi &Albero\t*", 302 + MENUITEM "&Livello successivo\t+", 301 + MENUITEM "&Espandi albero\t*", 302 MENUITEM "Espandi &tutto\tStrg+*", 303 - MENUITEM "Riduci &Albero\t-", 304 + MENUITEM "&Riduci albero\t-", 304 MENUITEM SEPARATOR MENUITEM "&Seleziona unità", 505 } POPUP "&Visualizza" { - MENUITEM "A&lbero e Directory", 413 - MENUITEM "So&lo Albero", 411 - MENUITEM "&Solo Directory", 412 + MENUITEM "&Albero e cartella", 413 + MENUITEM "Solo &albero", 411 + MENUITEM "Solo &cartella", 412 MENUITEM SEPARATOR MENUITEM "Di&vidi", ID_VIEW_SPLIT MENUITEM SEPARATOR MENUITEM "&Nome", ID_VIEW_NAME MENUITEM "&Mostra tutti i dettagli sui file",ID_VIEW_ALL_ATTRIBUTES, CHECKED - MENUITEM "&Mostra dettagli parziali...",ID_VIEW_SELECTED_ATTRIBUTES + MENUITEM "Mostra dettagli &parziali...",ID_VIEW_SELECTED_ATTRIBUTES MENUITEM SEPARATOR - MENUITEM "&Ordina per Nome", ID_VIEW_SORT_NAME - MENUITEM "&Ordina per Tipo", ID_VIEW_SORT_TYPE - MENUITEM "&Ordina per Dimensione", ID_VIEW_SORT_SIZE - MENUITEM "&Ordina per Data", ID_VIEW_SORT_DATE + MENUITEM "Ordina per n&ome", ID_VIEW_SORT_NAME + MENUITEM "Ordina per &tipo", ID_VIEW_SORT_TYPE + MENUITEM "Ordina per &dimensione", ID_VIEW_SORT_SIZE + MENUITEM "Ordina per d&ata", ID_VIEW_SORT_DATE MENUITEM SEPARATOR MENUITEM "Ordina per &...", ID_VIEW_FILTER } POPUP "&Opzioni" { - MENUITEM "&Confermazione...", 501 - MENUITEM "&Font...", ID_SELECT_FONT + MENUITEM "&Conferma...", 501 + MENUITEM "C&arattere...", ID_SELECT_FONT MENUITEM "&Personalizza barra degli strumenti...", 512 MENUITEM SEPARATOR - MENUITEM "&Barra degli strumenti", ID_VIEW_TOOL_BAR, CHECKED - MENUITEM "&Barra dei Drive", ID_VIEW_DRIVE_BAR, CHECKED - MENUITEM "&Barra di stato", ID_VIEW_STATUSBAR, CHECKED + MENUITEM "Barra degli &strumenti", ID_VIEW_TOOL_BAR, CHECKED + MENUITEM "Barra delle &unità", ID_VIEW_DRIVE_BAR, CHECKED + MENUITEM "Barra di s&tato", ID_VIEW_STATUSBAR, CHECKED #ifndef _NO_EXTENSIONS - MENUITEM "A& tutto schermo\tCtrl+Shift+S",ID_VIEW_FULLSCREEN + MENUITEM "A tutto scher&mo\tCtrl+Shift+S",ID_VIEW_FULLSCREEN #endif MENUITEM SEPARATOR MENUITEM "&Esegui minimizzato", 504 - MENUITEM "&Salva impostazioni all'uscita",511 + MENUITEM "Sa&lva impostazioni all'uscita",511 } @@ -131,14 +131,14 @@ IDM_WINEFILE MENU } POPUP "&Finestra" { - MENUITEM "Nuova &Finestra", ID_WINDOW_NEW + MENUITEM "&Nuova finestra", ID_WINDOW_NEW MENUITEM "Finestre a cascata\tCtrl+F5", ID_WINDOW_CASCADE - MENUITEM "Ordina &Orizontalmente", ID_WINDOW_TILE_HORZ - MENUITEM "Ordina &Verticlmente\tCtrl+F4",ID_WINDOW_TILE_VERT + MENUITEM "Ordina &orizzontalmente", ID_WINDOW_TILE_HORZ + MENUITEM "Ordina &verticalmente\tCtrl+F4",ID_WINDOW_TILE_VERT #ifndef _NO_EXTENSIONS MENUITEM "Disponi automaticamente", ID_WINDOW_AUTOSORT #endif - MENUITEM "Disponi &Simboli", ID_WINDOW_ARRANGE + MENUITEM "Disponi &simboli", ID_WINDOW_ARRANGE MENUITEM "&Aggiorna\tF5", ID_REFRESH } @@ -178,9 +178,9 @@ BEGIN BS_AUTOCHECKBOX | WS_TABSTOP,13,43,70,10 CONTROL "Docu&menti",IDC_VIEW_TYPE_DOCUMENTS,"Button", BS_AUTOCHECKBOX | WS_TABSTOP,13,54,70,10 - CONTROL "&Altri files",IDC_VIEW_TYPE_OTHERS,"Button", + CONTROL "&Altri file",IDC_VIEW_TYPE_OTHERS,"Button", BS_AUTOCHECKBOX | WS_TABSTOP,13,65,70,10 - CONTROL "&Mostra files nascosti/di sistema",IDC_VIEW_TYPE_HIDDEN, + CONTROL "&Mostra file nascosti/di sistema",IDC_VIEW_TYPE_HIDDEN, "Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,81,106,9 DEFPUSHBUTTON "OK",IDOK,104,7,50,14 PUSHBUTTON "Annulla",IDCANCEL,104,24,50,14 @@ -188,7 +188,7 @@ END IDD_DIALOG_PROPERTIES DIALOG 0, 0, 248, 215 STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "Propprietà di %s" +CAPTION "Proprietà di %s" FONT 8, "MS Sans Serif" BEGIN DEFPUSHBUTTON "OK",IDOK,191,7,50,14 @@ -201,7 +201,7 @@ BEGIN EDITTEXT IDC_STATIC_PROP_LASTCHANGE,71,29,120,9,ES_READONLY | NOT WS_BORDER | WS_TABSTOP LTEXT "Versione:",-1,7,40,59,9 EDITTEXT IDC_STATIC_PROP_VERSION,71,40,120,9,ES_READONLY | NOT WS_BORDER | WS_TABSTOP - LTEXT "Cop&yright:",-1,7,51,59,9 + LTEXT "&Copyright:",-1,7,51,59,9 EDITTEXT IDC_STATIC_PROP_COPYRIGHT,71,51,120,9,ES_READONLY | NOT WS_BORDER | WS_TABSTOP LTEXT "Dimensione:",-1,7,62,59,9 EDITTEXT IDC_STATIC_PROP_SIZE,71,62,120,9,ES_READONLY | NOT WS_BORDER | WS_TABSTOP @@ -210,7 +210,7 @@ BEGIN CONTROL "&Nascosto",IDC_CHECK_HIDDEN,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,92,91,68,9 CONTROL "&Archivio",IDC_CHECK_ARCHIVE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,17,101,68,9 CONTROL "&Di sistema",IDC_CHECK_SYSTEM,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,92,101,68,9 - CONTROL "&Compresso",IDC_CHECK_COMPRESSED,"Button", BS_AUTOCHECKBOX | WS_TABSTOP,17,111,68,9 + CONTROL "Co&mpresso",IDC_CHECK_COMPRESSED,"Button", BS_AUTOCHECKBOX | WS_TABSTOP,17,111,68,9 GROUPBOX "&Informazioni sulla versione",-1,7,129,234,79 LISTBOX IDC_LIST_PROP_VERSION_TYPES,13,139,107,63,LBS_SORT | LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP EDITTEXT IDC_LIST_PROP_VERSION_VALUES,123,139,111,63,ES_MULTILINE | ES_READONLY | WS_VSCROLL @@ -225,12 +225,12 @@ STRINGTABLE STRINGTABLE { - IDS_WINEFILE "Wine File Manager" + IDS_WINEFILE "Gestore di file di Wine" IDS_ERROR "Errore" - IDS_ROOT_FS "root fs" - IDS_UNIXFS "unixfs" + IDS_ROOT_FS "radice fs" + IDS_UNIXFS "unix fs" IDS_DESKTOP "Scrivania" - IDS_SHELL "Shell" + IDS_SHELL "Terminale" IDS_TITLEFMT "%s - %s" IDS_NO_IMPL "Non ancora implementato" IDS_WINE_FILE "Wine File" @@ -240,10 +240,10 @@ STRINGTABLE { IDS_COL_NAME "Nome" IDS_COL_SIZE "Dimensione" - IDS_COL_CDATE "CDate" - IDS_COL_ADATE "ADate" - IDS_COL_MDATE "MDate" - IDS_COL_IDX "Index/Inode" + IDS_COL_CDATE "Data di creazione" + IDS_COL_ADATE "Data di ultimo accesso" + IDS_COL_MDATE "Data di ultima modifica" + IDS_COL_IDX "Indice/Inode" IDS_COL_LINKS "Collegamenti" IDS_COL_ATTR "Attributi" IDS_COL_SEC "Sicurezza" diff --git a/rosapps/applications/winfile/winefile.c b/rosapps/applications/winfile/winefile.c index c150c9a79e7..aed4d14f7e9 100644 --- a/rosapps/applications/winfile/winefile.c +++ b/rosapps/applications/winfile/winefile.c @@ -2019,8 +2019,7 @@ static BOOL toggle_fullscreen(HWND hwnd) g_fullscreen.wasZoomed = IsZoomed(hwnd); Frame_CalcFrameClient(hwnd, &rt); - ClientToScreen(hwnd, (LPPOINT)&rt.left); - ClientToScreen(hwnd, (LPPOINT)&rt.right); + MapWindowPoints( hwnd, 0, (POINT *)&rt, 2 ); rt.left = g_fullscreen.orgPos.left-rt.left; rt.top = g_fullscreen.orgPos.top-rt.top; @@ -2046,8 +2045,7 @@ static void fullscreen_move(HWND hwnd) GetWindowRect(hwnd, &pos); Frame_CalcFrameClient(hwnd, &rt); - ClientToScreen(hwnd, (LPPOINT)&rt.left); - ClientToScreen(hwnd, (LPPOINT)&rt.right); + MapWindowPoints( hwnd, 0, (POINT *)&rt, 2 ); rt.left = pos.left-rt.left; rt.top = pos.top-rt.top; From e8fc5482a00a83b84f6fbcd3f75f3dea30e0e9eb Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Sun, 26 Dec 2010 22:25:47 +0000 Subject: [PATCH 127/181] [NTOSKRNL] Make definitions of ExpChangeRundown, ExpChangePushlock and ExpSetRundown 64 bit safe (have one portable definition and use it accordingly) svn path=/trunk/; revision=50152 --- reactos/ntoskrnl/ex/rundown.c | 6 +- reactos/ntoskrnl/include/internal/ex.h | 92 ++++++++++++-------------- 2 files changed, 46 insertions(+), 52 deletions(-) diff --git a/reactos/ntoskrnl/ex/rundown.c b/reactos/ntoskrnl/ex/rundown.c index 13dc7aab33f..fb0b82b5e83 100644 --- a/reactos/ntoskrnl/ex/rundown.c +++ b/reactos/ntoskrnl/ex/rundown.c @@ -145,7 +145,7 @@ ExfReInitializeRundownProtection(IN PEX_RUNDOWN_REF RunRef) ASSERT((RunRef->Count & EX_RUNDOWN_ACTIVE) != 0); /* Reset the count */ - ExpSetRundown(&RunRef->Count, 0); + ExpSetRundown(RunRef, 0); } /*++ @@ -173,7 +173,7 @@ ExfRundownCompleted(IN PEX_RUNDOWN_REF RunRef) ASSERT((RunRef->Count & EX_RUNDOWN_ACTIVE) != 0); /* Mark the counter as active */ - ExpSetRundown(&RunRef->Count, EX_RUNDOWN_ACTIVE); + ExpSetRundown(RunRef, EX_RUNDOWN_ACTIVE); } /*++ @@ -359,7 +359,7 @@ ExfWaitForRundownProtectionRelease(IN PEX_RUNDOWN_REF RunRef) WaitBlock.Count = Count; /* Now set the pointer */ - NewValue = ExpChangeRundown(RunRef, PtrToUlong(WaitBlockPointer), Value); + NewValue = ExpChangeRundown(RunRef, (ULONG_PTR)WaitBlockPointer, Value); if (NewValue == Value) break; /* Loop again */ diff --git a/reactos/ntoskrnl/include/internal/ex.h b/reactos/ntoskrnl/include/internal/ex.h index 1c730359091..3ef21387baa 100644 --- a/reactos/ntoskrnl/include/internal/ex.h +++ b/reactos/ntoskrnl/include/internal/ex.h @@ -95,7 +95,7 @@ typedef struct // Detect old GCC // #if (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__ < 40300) || \ - (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__ == 40303) + (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__ == 40303) #define DEFINE_WAIT_BLOCK(x) \ struct _AlignHack \ @@ -119,15 +119,9 @@ typedef struct #endif -#ifdef _WIN64 -#define ExpChangeRundown(x, y, z) InterlockedCompareExchange64((PLONGLONG)x, y, z) +#define ExpChangeRundown(x, y, z) (ULONG_PTR)InterlockedCompareExchangePointer(&x->Ptr, (PVOID)y, (PVOID)z) #define ExpChangePushlock(x, y, z) InterlockedCompareExchangePointer((PVOID*)x, (PVOID)y, (PVOID)z) -#define ExpSetRundown(x, y) InterlockedExchange64((PLONGLONG)x, y) -#else -#define ExpChangeRundown(x, y, z) PtrToUlong(InterlockedCompareExchange((PLONG)x, PtrToLong(y), PtrToLong(z))) -#define ExpChangePushlock(x, y, z) LongToPtr(InterlockedCompareExchange((PLONG)x, PtrToLong(y), PtrToLong(z))) -#define ExpSetRundown(x, y) InterlockedExchange((PLONG)x, y) -#endif +#define ExpSetRundown(x, y) InterlockedExchangePointer(&x->Ptr, (PVOID)y) /* INITIALIZATION FUNCTIONS *************************************************/ @@ -496,7 +490,7 @@ ExInitializeFastReference(OUT PEX_FAST_REF FastRef, { /* Sanity check */ ASSERT((((ULONG_PTR)Object) & MAX_FAST_REFS) == 0); - + /* Check if an object is being set */ if (!Object) { @@ -515,7 +509,7 @@ EX_FAST_REF ExAcquireFastReference(IN OUT PEX_FAST_REF FastRef) { EX_FAST_REF OldValue, NewValue; - + /* Start reference loop */ for (;;) { @@ -530,11 +524,11 @@ ExAcquireFastReference(IN OUT PEX_FAST_REF FastRef) OldValue.Object); if (NewValue.Object != OldValue.Object) continue; } - + /* We are done */ break; } - + /* Return the old value */ return OldValue; } @@ -545,16 +539,16 @@ ExInsertFastReference(IN OUT PEX_FAST_REF FastRef, IN PVOID Object) { EX_FAST_REF OldValue, NewValue; - + /* Sanity checks */ ASSERT(!(((ULONG_PTR)Object) & MAX_FAST_REFS)); - + /* Start update loop */ for (;;) { /* Get the current reference count */ OldValue = *FastRef; - + /* Check if the current count is too high or if the pointer changed */ if (((OldValue.RefCnt + MAX_FAST_REFS) > MAX_FAST_REFS) || ((OldValue.Value &~ MAX_FAST_REFS) != (ULONG_PTR)Object)) @@ -562,20 +556,20 @@ ExInsertFastReference(IN OUT PEX_FAST_REF FastRef, /* Fail */ return FALSE; } - + /* Update the reference count */ NewValue.Value = OldValue.Value + MAX_FAST_REFS; NewValue.Object = ExpChangePushlock(&FastRef->Object, NewValue.Object, OldValue.Object); if (NewValue.Object != OldValue.Object) continue; - + /* We are done */ break; } - + /* Return success */ - return TRUE; + return TRUE; } FORCEINLINE @@ -584,31 +578,31 @@ ExReleaseFastReference(IN PEX_FAST_REF FastRef, IN PVOID Object) { EX_FAST_REF OldValue, NewValue; - + /* Sanity checks */ ASSERT(Object != NULL); ASSERT(!(((ULONG_PTR)Object) & MAX_FAST_REFS)); - + /* Start reference loop */ for (;;) { /* Get the current reference count */ OldValue = *FastRef; - + /* Check if we're full if if the pointer changed */ if ((OldValue.Value ^ (ULONG_PTR)Object) >= MAX_FAST_REFS) return FALSE; - + /* Decrease the reference count */ NewValue.Value = OldValue.Value + 1; NewValue.Object = ExpChangePushlock(&FastRef->Object, NewValue.Object, OldValue.Object); if (NewValue.Object != OldValue.Object) continue; - + /* We are done */ break; } - + /* Return success */ return TRUE; } @@ -619,10 +613,10 @@ ExSwapFastReference(IN PEX_FAST_REF FastRef, IN PVOID Object) { EX_FAST_REF NewValue, OldValue; - + /* Sanity check */ ASSERT((((ULONG_PTR)Object) & MAX_FAST_REFS) == 0); - + /* Check if an object is being set */ if (!Object) { @@ -634,7 +628,7 @@ ExSwapFastReference(IN PEX_FAST_REF FastRef, /* Otherwise, we assume the object was referenced and is ready */ NewValue.Value = (ULONG_PTR)Object | MAX_FAST_REFS; } - + /* Update the object */ OldValue.Object = InterlockedExchangePointer(&FastRef->Object, NewValue.Object); return OldValue; @@ -647,17 +641,17 @@ ExCompareSwapFastReference(IN PEX_FAST_REF FastRef, IN PVOID OldObject) { EX_FAST_REF OldValue, NewValue; - + /* Sanity check and start swap loop */ ASSERT(!(((ULONG_PTR)Object) & MAX_FAST_REFS)); for (;;) { /* Get the current value */ OldValue = *FastRef; - + /* Make sure there's enough references to swap */ if (!((OldValue.Value ^ (ULONG_PTR)OldObject) <= MAX_FAST_REFS)) break; - + /* Check if we have an object to swap */ if (Object) { @@ -669,17 +663,17 @@ ExCompareSwapFastReference(IN PEX_FAST_REF FastRef, /* Write the object address itself (which is empty) */ NewValue.Value = (ULONG_PTR)Object; } - + /* Do the actual compare exchange */ NewValue.Object = ExpChangePushlock(&FastRef->Object, NewValue.Object, OldValue.Object); if (NewValue.Object != OldValue.Object) continue; - + /* All done */ break; } - + /* Return the old value */ return OldValue; } @@ -849,7 +843,7 @@ _ExRundownCompleted(IN PEX_RUNDOWN_REF RunRef) ASSERT((RunRef->Count & EX_RUNDOWN_ACTIVE) != 0); /* Mark the counter as active */ - ExpSetRundown(&RunRef->Count, EX_RUNDOWN_ACTIVE); + ExpSetRundown(RunRef, EX_RUNDOWN_ACTIVE); } /* PUSHLOCKS *****************************************************************/ @@ -1221,21 +1215,21 @@ VOID _ExAcquireFastMutexUnsafe(IN PFAST_MUTEX FastMutex) { PKTHREAD Thread = KeGetCurrentThread(); - + /* Sanity check */ ASSERT((KeGetCurrentIrql() == APC_LEVEL) || (Thread->CombinedApcDisable != 0) || (Thread->Teb == NULL) || (Thread->Teb >= (PTEB)MM_SYSTEM_RANGE_START)); ASSERT(FastMutex->Owner != Thread); - + /* Decrease the count */ if (InterlockedDecrement(&FastMutex->Count)) { /* Someone is still holding it, use slow path */ KiAcquireFastMutex(FastMutex); } - + /* Set the owner */ FastMutex->Owner = Thread; } @@ -1249,10 +1243,10 @@ _ExReleaseFastMutexUnsafe(IN OUT PFAST_MUTEX FastMutex) (KeGetCurrentThread()->Teb == NULL) || (KeGetCurrentThread()->Teb >= (PTEB)MM_SYSTEM_RANGE_START)); ASSERT(FastMutex->Owner == KeGetCurrentThread()); - + /* Erase the owner */ FastMutex->Owner = NULL; - + /* Increase the count */ if (InterlockedIncrement(&FastMutex->Count) <= 0) { @@ -1267,17 +1261,17 @@ _ExAcquireFastMutex(IN PFAST_MUTEX FastMutex) { KIRQL OldIrql; ASSERT(KeGetCurrentIrql() <= APC_LEVEL); - + /* Raise IRQL to APC */ KeRaiseIrql(APC_LEVEL, &OldIrql); - + /* Decrease the count */ if (InterlockedDecrement(&FastMutex->Count)) { /* Someone is still holding it, use slow path */ KiAcquireFastMutex(FastMutex); } - + /* Set the owner and IRQL */ FastMutex->Owner = KeGetCurrentThread(); FastMutex->OldIrql = OldIrql; @@ -1289,18 +1283,18 @@ _ExReleaseFastMutex(IN OUT PFAST_MUTEX FastMutex) { KIRQL OldIrql; ASSERT(KeGetCurrentIrql() == APC_LEVEL); - + /* Erase the owner */ FastMutex->Owner = NULL; OldIrql = (KIRQL)FastMutex->OldIrql; - + /* Increase the count */ if (InterlockedIncrement(&FastMutex->Count) <= 0) { /* Someone was waiting for it, signal the waiter */ KeSetEventBoostPriority(&FastMutex->Event, NULL); } - + /* Lower IRQL back */ KeLowerIrql(OldIrql); } @@ -1311,10 +1305,10 @@ _ExTryToAcquireFastMutex(IN OUT PFAST_MUTEX FastMutex) { KIRQL OldIrql; ASSERT(KeGetCurrentIrql() <= APC_LEVEL); - + /* Raise to APC_LEVEL */ KeRaiseIrql(APC_LEVEL, &OldIrql); - + /* Check if we can quickly acquire it */ if (InterlockedCompareExchange(&FastMutex->Count, 0, 1) == 1) { From 7785b6ca52c018607e9c50d866280641de0dac77 Mon Sep 17 00:00:00 2001 From: Christoph von Wittich Date: Mon, 27 Dec 2010 09:07:27 +0000 Subject: [PATCH 128/181] [CRT] import MSVCRT_I10_OUTPUT from wine svn path=/trunk/; revision=50153 --- reactos/lib/sdk/crt/crt.rbuild | 1 + reactos/lib/sdk/crt/misc/i10output.c | 99 ++++++++++++++++++++++++++++ reactos/lib/sdk/crt/misc/stubs.c | 9 --- 3 files changed, 100 insertions(+), 9 deletions(-) create mode 100644 reactos/lib/sdk/crt/misc/i10output.c diff --git a/reactos/lib/sdk/crt/crt.rbuild b/reactos/lib/sdk/crt/crt.rbuild index d9e31fa3ab0..de4b1748363 100644 --- a/reactos/lib/sdk/crt/crt.rbuild +++ b/reactos/lib/sdk/crt/crt.rbuild @@ -314,6 +314,7 @@ assert.c environ.c getargs.c + i10output.c initterm.c lock.c purecall.c diff --git a/reactos/lib/sdk/crt/misc/i10output.c b/reactos/lib/sdk/crt/misc/i10output.c new file mode 100644 index 00000000000..779e2ab4cb0 --- /dev/null +++ b/reactos/lib/sdk/crt/misc/i10output.c @@ -0,0 +1,99 @@ +#include + +#define I10_OUTPUT_MAX_PREC 21 +/* Internal structure used by $I10_OUTPUT */ +struct _I10_OUTPUT_DATA { + short pos; + char sign; + BYTE len; + char str[I10_OUTPUT_MAX_PREC+1]; /* add space for '\0' */ +}; + +/********************************************************************* + * $I10_OUTPUT (MSVCRT.@) + * ld - long double to be printed to data + * prec - precision of part, we're interested in + * flag - 0 for first prec digits, 1 for fractional part + * data - data to be populated + * + * return value + * 0 if given double is NaN or INF + * 1 otherwise + * + * FIXME + * Native sets last byte of data->str to '0' or '9', I don't know what + * it means. Current implementation sets it always to '0'. + */ +int CDECL MSVCRT_I10_OUTPUT(long double ld, int prec, int flag, struct _I10_OUTPUT_DATA *data) +{ + static const char inf_str[] = "1#INF"; + static const char nan_str[] = "1#QNAN"; + + double d = ld; + char format[8]; + char buf[I10_OUTPUT_MAX_PREC+9]; /* 9 = strlen("0.e+0000") + '\0' */ + char *p; + + TRACE("(%lf %d %x %p)\n", d, prec, flag, data); + + if(d<0) { + data->sign = '-'; + d = -d; + } else + data->sign = ' '; + + if(isinf(d)) { + data->pos = 1; + data->len = 5; + memcpy(data->str, inf_str, sizeof(inf_str)); + + return 0; + } + + if(isnan(d)) { + data->pos = 1; + data->len = 6; + memcpy(data->str, nan_str, sizeof(nan_str)); + + return 0; + } + + if(flag&1) { + int exp = 1+floor(log10(d)); + + prec += exp; + if(exp < 0) + prec--; + } + prec--; + + if(prec+1 > I10_OUTPUT_MAX_PREC) + prec = I10_OUTPUT_MAX_PREC-1; + else if(prec < 0) { + d = 0.0; + prec = 0; + } + + sprintf(format, "%%.%dle", prec); + sprintf(buf, format, d); + + buf[1] = buf[0]; + data->pos = atoi(buf+prec+3); + if(buf[1] != '0') + data->pos++; + + for(p = buf+prec+1; p>buf+1 && *p=='0'; p--); + data->len = p-buf; + + memcpy(data->str, buf+1, data->len); + data->str[data->len] = '\0'; + + if(buf[1]!='0' && prec-data->len+1>0) + memcpy(data->str+data->len+1, buf+data->len+1, prec-data->len+1); + + return 1; +} +#undef I10_OUTPUT_MAX_PREC + + + diff --git a/reactos/lib/sdk/crt/misc/stubs.c b/reactos/lib/sdk/crt/misc/stubs.c index 7eac2b0fef9..98641dc83a1 100644 --- a/reactos/lib/sdk/crt/misc/stubs.c +++ b/reactos/lib/sdk/crt/misc/stubs.c @@ -6,15 +6,6 @@ int __STRINGTOLD( long double *value, char **endptr, const char *str, int flags return 0; } -/********************************************************************* - * $I10_OUTPUT (MSVCRT.@) - * Function not really understood but needed to make the DLL work - */ -void MSVCRT_I10_OUTPUT(void) -{ - /* FIXME: This is probably data, not a function */ -} - void __fileinfo(void) { FIXME("__fileinfo stub\n"); From 9f634e70cf9e55a97daab8a09abd672bf7af7659 Mon Sep 17 00:00:00 2001 From: James Tabor Date: Mon, 27 Dec 2010 09:08:01 +0000 Subject: [PATCH 129/181] [Win32k] - Use SendNotifyMessage for broadcasting these messages and SendMessageNoWait when not broadcasting. svn path=/trunk/; revision=50154 --- reactos/subsystems/win32/win32k/include/msgqueue.h | 2 +- reactos/subsystems/win32/win32k/ntuser/clipboard.c | 2 +- reactos/subsystems/win32/win32k/ntuser/focus.c | 8 ++++---- reactos/subsystems/win32/win32k/ntuser/ntstubs.c | 2 +- reactos/subsystems/win32/win32k/ntuser/painting.c | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/reactos/subsystems/win32/win32k/include/msgqueue.h b/reactos/subsystems/win32/win32k/include/msgqueue.h index f153314c421..f359f600011 100644 --- a/reactos/subsystems/win32/win32k/include/msgqueue.h +++ b/reactos/subsystems/win32/win32k/include/msgqueue.h @@ -187,7 +187,7 @@ co_IntSendMessageTimeout(HWND hWnd, UINT uFlags, UINT uTimeout, ULONG_PTR *uResult); - +BOOL FASTCALL UserSendNotifyMessage( HWND hWnd,UINT Msg,WPARAM wParam,LPARAM lParam ); LRESULT FASTCALL co_IntSendMessageNoWait(HWND hWnd, UINT Msg, WPARAM wParam, diff --git a/reactos/subsystems/win32/win32k/ntuser/clipboard.c b/reactos/subsystems/win32/win32k/ntuser/clipboard.c index b75cb2da3f5..121d7af06ae 100644 --- a/reactos/subsystems/win32/win32k/ntuser/clipboard.c +++ b/reactos/subsystems/win32/win32k/ntuser/clipboard.c @@ -601,7 +601,7 @@ NtUserEmptyClipboard(VOID) if (ret && ClipboardOwnerWindow) { DPRINT("Clipboard: WM_DESTROYCLIPBOARD to %p", ClipboardOwnerWindow->head.h); - co_IntSendMessage( ClipboardOwnerWindow->head.h, WM_DESTROYCLIPBOARD, 0, 0); + co_IntSendMessageNoWait( ClipboardOwnerWindow->head.h, WM_DESTROYCLIPBOARD, 0, 0); } UserLeave(); diff --git a/reactos/subsystems/win32/win32k/ntuser/focus.c b/reactos/subsystems/win32/win32k/ntuser/focus.c index 67273cc4480..6b1428c45e4 100644 --- a/reactos/subsystems/win32/win32k/ntuser/focus.c +++ b/reactos/subsystems/win32/win32k/ntuser/focus.c @@ -79,10 +79,10 @@ co_IntSendActivateMessages(HWND hWndPrev, HWND hWnd, BOOL MouseActivate) /* Send palette messages */ if (co_IntSendMessage(hWnd, WM_QUERYNEWPALETTE, 0, 0)) { - UserPostMessage( HWND_BROADCAST, - WM_PALETTEISCHANGING, - (WPARAM)hWnd, - 0); + UserSendNotifyMessage( HWND_BROADCAST, + WM_PALETTEISCHANGING, + (WPARAM)hWnd, + 0); } if (Window->spwndPrev != NULL) diff --git a/reactos/subsystems/win32/win32k/ntuser/ntstubs.c b/reactos/subsystems/win32/win32k/ntuser/ntstubs.c index 445bdd500f7..5045718de8a 100644 --- a/reactos/subsystems/win32/win32k/ntuser/ntstubs.c +++ b/reactos/subsystems/win32/win32k/ntuser/ntstubs.c @@ -564,7 +564,7 @@ NtUserSetSysColors( } if (Ret) { - UserPostMessage(HWND_BROADCAST, WM_SYSCOLORCHANGE, 0, 0); + UserSendNotifyMessage(HWND_BROADCAST, WM_SYSCOLORCHANGE, 0, 0); } UserLeave(); return Ret; diff --git a/reactos/subsystems/win32/win32k/ntuser/painting.c b/reactos/subsystems/win32/win32k/ntuser/painting.c index e78a0442a45..53f7b41d1ee 100644 --- a/reactos/subsystems/win32/win32k/ntuser/painting.c +++ b/reactos/subsystems/win32/win32k/ntuser/painting.c @@ -1952,7 +1952,7 @@ UserRealizePalette(HDC hdc) hWnd = IntWindowFromDC(hdc); if (hWnd) // Send broadcast if dc is associated with a window. { // FYI: Thread locked in CallOneParam. - co_IntSendMessage((HWND)HWND_BROADCAST, WM_PALETTECHANGED, (WPARAM)hWnd, 0); + UserSendNotifyMessage((HWND)HWND_BROADCAST, WM_PALETTECHANGED, (WPARAM)hWnd, 0); } } return Ret; From 4c3e53b5a24cb8d851711d0bd774b805d194eca6 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Mon, 27 Dec 2010 09:18:00 +0000 Subject: [PATCH 130/181] [NSLOOKUP] Use memcpy with sizeof instead of strncpy with strlen to make sure the destination string will be zero terminated. CID 1649 svn path=/trunk/; revision=50155 --- reactos/base/applications/network/nslookup/nslookup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reactos/base/applications/network/nslookup/nslookup.c b/reactos/base/applications/network/nslookup/nslookup.c index 3e7ce484fd9..11b1e91040b 100644 --- a/reactos/base/applications/network/nslookup/nslookup.c +++ b/reactos/base/applications/network/nslookup/nslookup.c @@ -791,7 +791,7 @@ int main( int argc, char* argv[] ) RtlZeroMemory( State.DefaultServer, 256 ); RtlZeroMemory( State.DefaultServerAddress, 16 ); - strncpy( State.root, DEFAULT_ROOT, strlen( DEFAULT_ROOT ) ); + memcpy( State.root, DEFAULT_ROOT, sizeof(DEFAULT_ROOT) ); /* We don't know how long of a buffer it will want to return. So we'll pass an empty one now and let it fail only once, instead of guessing. */ From 9e86562b37f3151e780a002fda62bd295cd88c06 Mon Sep 17 00:00:00 2001 From: Christoph von Wittich Date: Mon, 27 Dec 2010 09:50:02 +0000 Subject: [PATCH 131/181] [FUSION] sync to wine 1.3.10 svn path=/trunk/; revision=50156 --- reactos/dll/win32/fusion/asmcache.c | 32 ++++++++++----- reactos/dll/win32/fusion/asmenum.c | 42 +++++++++++++------- reactos/dll/win32/fusion/asmname.c | 55 ++++++++++++++++++++++++-- reactos/dll/win32/fusion/assembly.c | 8 ++-- reactos/dll/win32/fusion/fusion.rbuild | 1 + reactos/dll/win32/fusion/fusionpriv.h | 5 ++- 6 files changed, 111 insertions(+), 32 deletions(-) diff --git a/reactos/dll/win32/fusion/asmcache.c b/reactos/dll/win32/fusion/asmcache.c index 7334e5d793e..fe4e12a49a9 100644 --- a/reactos/dll/win32/fusion/asmcache.c +++ b/reactos/dll/win32/fusion/asmcache.c @@ -123,15 +123,20 @@ static BOOL get_assembly_directory(LPWSTR dir, DWORD size, BYTE architecture) /* IAssemblyCache */ typedef struct { - const IAssemblyCacheVtbl *lpIAssemblyCacheVtbl; + IAssemblyCache IAssemblyCache_iface; LONG ref; } IAssemblyCacheImpl; +static inline IAssemblyCacheImpl *impl_from_IAssemblyCache(IAssemblyCache *iface) +{ + return CONTAINING_RECORD(iface, IAssemblyCacheImpl, IAssemblyCache_iface); +} + static HRESULT WINAPI IAssemblyCacheImpl_QueryInterface(IAssemblyCache *iface, REFIID riid, LPVOID *ppobj) { - IAssemblyCacheImpl *This = (IAssemblyCacheImpl *)iface; + IAssemblyCacheImpl *This = impl_from_IAssemblyCache(iface); TRACE("(%p, %s, %p)\n", This, debugstr_guid(riid), ppobj); @@ -151,7 +156,7 @@ static HRESULT WINAPI IAssemblyCacheImpl_QueryInterface(IAssemblyCache *iface, static ULONG WINAPI IAssemblyCacheImpl_AddRef(IAssemblyCache *iface) { - IAssemblyCacheImpl *This = (IAssemblyCacheImpl *)iface; + IAssemblyCacheImpl *This = impl_from_IAssemblyCache(iface); ULONG refCount = InterlockedIncrement(&This->ref); TRACE("(%p)->(ref before = %u)\n", This, refCount - 1); @@ -161,7 +166,7 @@ static ULONG WINAPI IAssemblyCacheImpl_AddRef(IAssemblyCache *iface) static ULONG WINAPI IAssemblyCacheImpl_Release(IAssemblyCache *iface) { - IAssemblyCacheImpl *This = (IAssemblyCacheImpl *)iface; + IAssemblyCacheImpl *This = impl_from_IAssemblyCache(iface); ULONG refCount = InterlockedDecrement(&This->ref); TRACE("(%p)->(ref before = %u)\n", This, refCount + 1); @@ -223,6 +228,8 @@ static HRESULT WINAPI IAssemblyCacheImpl_QueryAssemblyInfo(IAssemblyCache *iface if (!pAsmInfo) goto done; + hr = IAssemblyName_GetPath(next, pAsmInfo->pszCurrentAssemblyPathBuf, &pAsmInfo->cchBuf); + pAsmInfo->dwAssemblyFlags = ASSEMBLYINFO_FLAG_INSTALLED; done: @@ -362,10 +369,10 @@ HRESULT WINAPI CreateAssemblyCache(IAssemblyCache **ppAsmCache, DWORD dwReserved if (!cache) return E_OUTOFMEMORY; - cache->lpIAssemblyCacheVtbl = &AssemblyCacheVtbl; + cache->IAssemblyCache_iface.lpVtbl = &AssemblyCacheVtbl; cache->ref = 1; - *ppAsmCache = (IAssemblyCache *)cache; + *ppAsmCache = &cache->IAssemblyCache_iface; return S_OK; } @@ -373,15 +380,20 @@ HRESULT WINAPI CreateAssemblyCache(IAssemblyCache **ppAsmCache, DWORD dwReserved /* IAssemblyCacheItem */ typedef struct { - const IAssemblyCacheItemVtbl *lpIAssemblyCacheItemVtbl; + IAssemblyCacheItem IAssemblyCacheItem_iface; LONG ref; } IAssemblyCacheItemImpl; +static inline IAssemblyCacheItemImpl *impl_from_IAssemblyCacheItem(IAssemblyCacheItem *iface) +{ + return CONTAINING_RECORD(iface, IAssemblyCacheItemImpl, IAssemblyCacheItem_iface); +} + static HRESULT WINAPI IAssemblyCacheItemImpl_QueryInterface(IAssemblyCacheItem *iface, REFIID riid, LPVOID *ppobj) { - IAssemblyCacheItemImpl *This = (IAssemblyCacheItemImpl *)iface; + IAssemblyCacheItemImpl *This = impl_from_IAssemblyCacheItem(iface); TRACE("(%p, %s, %p)\n", This, debugstr_guid(riid), ppobj); @@ -401,7 +413,7 @@ static HRESULT WINAPI IAssemblyCacheItemImpl_QueryInterface(IAssemblyCacheItem * static ULONG WINAPI IAssemblyCacheItemImpl_AddRef(IAssemblyCacheItem *iface) { - IAssemblyCacheItemImpl *This = (IAssemblyCacheItemImpl *)iface; + IAssemblyCacheItemImpl *This = impl_from_IAssemblyCacheItem(iface); ULONG refCount = InterlockedIncrement(&This->ref); TRACE("(%p)->(ref before = %u)\n", This, refCount - 1); @@ -411,7 +423,7 @@ static ULONG WINAPI IAssemblyCacheItemImpl_AddRef(IAssemblyCacheItem *iface) static ULONG WINAPI IAssemblyCacheItemImpl_Release(IAssemblyCacheItem *iface) { - IAssemblyCacheItemImpl *This = (IAssemblyCacheItemImpl *)iface; + IAssemblyCacheItemImpl *This = impl_from_IAssemblyCacheItem(iface); ULONG refCount = InterlockedDecrement(&This->ref); TRACE("(%p)->(ref before = %u)\n", This, refCount + 1); diff --git a/reactos/dll/win32/fusion/asmenum.c b/reactos/dll/win32/fusion/asmenum.c index 3706f07f511..99462ed2c5d 100644 --- a/reactos/dll/win32/fusion/asmenum.c +++ b/reactos/dll/win32/fusion/asmenum.c @@ -45,17 +45,22 @@ typedef struct _tagASMNAME typedef struct { - const IAssemblyEnumVtbl *lpIAssemblyEnumVtbl; + IAssemblyEnum IAssemblyEnum_iface; struct list assemblies; struct list *iter; LONG ref; } IAssemblyEnumImpl; +static inline IAssemblyEnumImpl *impl_from_IAssemblyEnum(IAssemblyEnum *iface) +{ + return CONTAINING_RECORD(iface, IAssemblyEnumImpl, IAssemblyEnum_iface); +} + static HRESULT WINAPI IAssemblyEnumImpl_QueryInterface(IAssemblyEnum *iface, REFIID riid, LPVOID *ppobj) { - IAssemblyEnumImpl *This = (IAssemblyEnumImpl *)iface; + IAssemblyEnumImpl *This = impl_from_IAssemblyEnum(iface); TRACE("(%p, %s, %p)\n", This, debugstr_guid(riid), ppobj); @@ -75,7 +80,7 @@ static HRESULT WINAPI IAssemblyEnumImpl_QueryInterface(IAssemblyEnum *iface, static ULONG WINAPI IAssemblyEnumImpl_AddRef(IAssemblyEnum *iface) { - IAssemblyEnumImpl *This = (IAssemblyEnumImpl *)iface; + IAssemblyEnumImpl *This = impl_from_IAssemblyEnum(iface); ULONG refCount = InterlockedIncrement(&This->ref); TRACE("(%p)->(ref before = %u)\n", This, refCount - 1); @@ -85,7 +90,7 @@ static ULONG WINAPI IAssemblyEnumImpl_AddRef(IAssemblyEnum *iface) static ULONG WINAPI IAssemblyEnumImpl_Release(IAssemblyEnum *iface) { - IAssemblyEnumImpl *This = (IAssemblyEnumImpl *)iface; + IAssemblyEnumImpl *This = impl_from_IAssemblyEnum(iface); ULONG refCount = InterlockedDecrement(&This->ref); struct list *item, *cursor; @@ -113,7 +118,7 @@ static HRESULT WINAPI IAssemblyEnumImpl_GetNextAssembly(IAssemblyEnum *iface, IAssemblyName **ppName, DWORD dwFlags) { - IAssemblyEnumImpl *asmenum = (IAssemblyEnumImpl *)iface; + IAssemblyEnumImpl *asmenum = impl_from_IAssemblyEnum(iface); ASMNAME *asmname; TRACE("(%p, %p, %p, %d)\n", iface, pvReserved, ppName, dwFlags); @@ -135,7 +140,7 @@ static HRESULT WINAPI IAssemblyEnumImpl_GetNextAssembly(IAssemblyEnum *iface, static HRESULT WINAPI IAssemblyEnumImpl_Reset(IAssemblyEnum *iface) { - IAssemblyEnumImpl *asmenum = (IAssemblyEnumImpl *)iface; + IAssemblyEnumImpl *asmenum = impl_from_IAssemblyEnum(iface); TRACE("(%p)\n", iface); @@ -287,6 +292,7 @@ static HRESULT enum_gac_assemblies(struct list *assemblies, IAssemblyName *name, WIN32_FIND_DATAW ffd; WCHAR buf[MAX_PATH]; WCHAR disp[MAX_PATH]; + WCHAR asmpath[MAX_PATH]; ASMNAME *asmname; HANDLE hfind; LPWSTR ptr; @@ -297,9 +303,9 @@ static HRESULT enum_gac_assemblies(struct list *assemblies, IAssemblyName *name, static const WCHAR dot[] = {'.',0}; static const WCHAR dotdot[] = {'.','.',0}; static const WCHAR search_fmt[] = {'%','s','\\','*',0}; - static const WCHAR parent_fmt[] = {'%','s',',',' ',0}; static const WCHAR dblunder[] = {'_','_',0}; - static const WCHAR fmt[] = {'V','e','r','s','i','o','n','=','%','s',',',' ', + static const WCHAR path_fmt[] = {'%','s','\\','%','s','\\','%','s','.','d','l','l',0}; + static const WCHAR fmt[] = {'%','s',',',' ','V','e','r','s','i','o','n','=','%','s',',',' ', 'C','u','l','t','u','r','e','=','n','e','u','t','r','a','l',',',' ', 'P','u','b','l','i','c','K','e','y','T','o','k','e','n','=','%','s',0}; static const WCHAR ss_fmt[] = {'%','s','\\','%','s',0}; @@ -325,17 +331,17 @@ static HRESULT enum_gac_assemblies(struct list *assemblies, IAssemblyName *name, else ptr = ffd.cFileName; - sprintfW(parent, parent_fmt, ptr); + lstrcpyW(parent, ptr); } else if (depth == 1) { + sprintfW(asmpath, path_fmt, path, ffd.cFileName, parent); + ptr = strstrW(ffd.cFileName, dblunder); *ptr = '\0'; ptr += 2; - sprintfW(buf, fmt, ffd.cFileName, ptr); - lstrcpyW(disp, parent); - lstrcatW(disp, buf); + sprintfW(disp, fmt, parent, ffd.cFileName, ptr); asmname = HeapAlloc(GetProcessHeap(), 0, sizeof(ASMNAME)); if (!asmname) @@ -352,6 +358,14 @@ static HRESULT enum_gac_assemblies(struct list *assemblies, IAssemblyName *name, break; } + hr = IAssemblyName_SetPath(asmname->name, asmpath); + if (FAILED(hr)) + { + IAssemblyName_Release(asmname->name); + HeapFree(GetProcessHeap(), 0, asmname); + break; + } + insert_assembly(assemblies, asmname); continue; } @@ -422,7 +436,7 @@ HRESULT WINAPI CreateAssemblyEnum(IAssemblyEnum **pEnum, IUnknown *pUnkReserved, if (!asmenum) return E_OUTOFMEMORY; - asmenum->lpIAssemblyEnumVtbl = &AssemblyEnumVtbl; + asmenum->IAssemblyEnum_iface.lpVtbl = &AssemblyEnumVtbl; asmenum->ref = 1; list_init(&asmenum->assemblies); @@ -437,7 +451,7 @@ HRESULT WINAPI CreateAssemblyEnum(IAssemblyEnum **pEnum, IUnknown *pUnkReserved, } asmenum->iter = list_head(&asmenum->assemblies); - *pEnum = (IAssemblyEnum *)asmenum; + *pEnum = &asmenum->IAssemblyEnum_iface; return S_OK; } diff --git a/reactos/dll/win32/fusion/asmname.c b/reactos/dll/win32/fusion/asmname.c index bcf49a7f214..34f05559ae4 100644 --- a/reactos/dll/win32/fusion/asmname.c +++ b/reactos/dll/win32/fusion/asmname.c @@ -19,6 +19,7 @@ */ #include +#include #define COBJMACROS #define INITGUID @@ -40,6 +41,8 @@ WINE_DEFAULT_DEBUG_CHANNEL(fusion); typedef struct { const IAssemblyNameVtbl *lpIAssemblyNameVtbl; + LPWSTR path; + LPWSTR displayname; LPWSTR name; LPWSTR culture; @@ -104,6 +107,7 @@ static ULONG WINAPI IAssemblyNameImpl_Release(IAssemblyName *iface) if (!refCount) { + HeapFree(GetProcessHeap(), 0, This->path); HeapFree(GetProcessHeap(), 0, This->displayname); HeapFree(GetProcessHeap(), 0, This->name); HeapFree(GetProcessHeap(), 0, This->culture); @@ -425,6 +429,43 @@ static const IAssemblyNameVtbl AssemblyNameVtbl = { IAssemblyNameImpl_Clone }; +/* Internal methods */ +HRESULT IAssemblyName_SetPath(IAssemblyName *iface, LPCWSTR path) +{ + IAssemblyNameImpl *name = (IAssemblyNameImpl *)iface; + + assert(name->lpIAssemblyNameVtbl == &AssemblyNameVtbl); + + name->path = strdupW(path); + if (!name->path) + return E_OUTOFMEMORY; + + return S_OK; +} + +HRESULT IAssemblyName_GetPath(IAssemblyName *iface, LPWSTR buf, ULONG *len) +{ + ULONG buffer_size = *len; + IAssemblyNameImpl *name = (IAssemblyNameImpl *)iface; + + assert(name->lpIAssemblyNameVtbl == &AssemblyNameVtbl); + + if (!name->path) + return S_OK; + + if (!buf) + buffer_size = 0; + + *len = lstrlenW(name->path) + 1; + + if (*len <= buffer_size) + lstrcpyW(buf, name->path); + else + return HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER); + + return S_OK; +} + static HRESULT parse_version(IAssemblyNameImpl *name, LPWSTR version) { LPWSTR beg, end; @@ -450,7 +491,7 @@ static HRESULT parse_version(IAssemblyNameImpl *name, LPWSTR version) return S_OK; } -static HRESULT parse_culture(IAssemblyNameImpl *name, LPWSTR culture) +static HRESULT parse_culture(IAssemblyNameImpl *name, LPCWSTR culture) { static const WCHAR empty[] = {0}; @@ -480,7 +521,7 @@ static BYTE hextobyte(WCHAR c) return 0; } -static HRESULT parse_pubkey(IAssemblyNameImpl *name, LPWSTR pubkey) +static HRESULT parse_pubkey(IAssemblyNameImpl *name, LPCWSTR pubkey) { int i; BYTE val; @@ -522,8 +563,16 @@ static HRESULT parse_display_name(IAssemblyNameImpl *name, LPCWSTR szAssemblyNam if (!str) return E_OUTOFMEMORY; - ptr = strstrW(str, separator); + ptr = strchrW(str, ','); if (ptr) *ptr = '\0'; + + /* no ',' but ' ' only */ + if( !ptr && strchrW(str, ' ') ) + { + hr = FUSION_E_INVALID_NAME; + goto done; + } + name->name = strdupW(str); if (!name->name) return E_OUTOFMEMORY; diff --git a/reactos/dll/win32/fusion/assembly.c b/reactos/dll/win32/fusion/assembly.c index 328b2792c9c..a3abc4e98d8 100644 --- a/reactos/dll/win32/fusion/assembly.c +++ b/reactos/dll/win32/fusion/assembly.c @@ -146,7 +146,7 @@ static VOID *assembly_data_offset(ASSEMBLY *assembly, ULONG offset) #define MAX_TABLES_3BIT_ENCODE 8191 #define MAX_TABLES_5BIT_ENCODE 2047 -static inline ULONG get_table_size(ASSEMBLY *assembly, DWORD index) +static inline ULONG get_table_size(const ASSEMBLY *assembly, DWORD index) { DWORD size; INT tables; @@ -731,11 +731,11 @@ HRESULT assembly_release(ASSEMBLY *assembly) return S_OK; } -static LPWSTR assembly_dup_str(ASSEMBLY *assembly, DWORD index) +static LPWSTR assembly_dup_str(const ASSEMBLY *assembly, DWORD index) { int len; LPWSTR cpy; - LPSTR str = (LPSTR)&assembly->strings[index]; + LPCSTR str = (LPCSTR)&assembly->strings[index]; len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0); @@ -772,7 +772,7 @@ HRESULT assembly_get_name(ASSEMBLY *assembly, LPWSTR *name) return S_OK; } -HRESULT assembly_get_path(ASSEMBLY *assembly, LPWSTR *path) +HRESULT assembly_get_path(const ASSEMBLY *assembly, LPWSTR *path) { LPWSTR cpy = HeapAlloc(GetProcessHeap(), 0, (strlenW(assembly->path) + 1) * sizeof(WCHAR)); *path = cpy; diff --git a/reactos/dll/win32/fusion/fusion.rbuild b/reactos/dll/win32/fusion/fusion.rbuild index f95cee92880..b1732dac348 100644 --- a/reactos/dll/win32/fusion/fusion.rbuild +++ b/reactos/dll/win32/fusion/fusion.rbuild @@ -8,6 +8,7 @@ shlwapi advapi32 dbghelp + msvcrt user32 asmcache.c asmenum.c diff --git a/reactos/dll/win32/fusion/fusionpriv.h b/reactos/dll/win32/fusion/fusionpriv.h index 6f4b28dc793..c114cd4b6bc 100644 --- a/reactos/dll/win32/fusion/fusionpriv.h +++ b/reactos/dll/win32/fusion/fusionpriv.h @@ -431,11 +431,14 @@ typedef struct tagASSEMBLY ASSEMBLY; HRESULT assembly_create(ASSEMBLY **out, LPCWSTR file); HRESULT assembly_release(ASSEMBLY *assembly); HRESULT assembly_get_name(ASSEMBLY *assembly, LPWSTR *name); -HRESULT assembly_get_path(ASSEMBLY *assembly, LPWSTR *path); +HRESULT assembly_get_path(const ASSEMBLY *assembly, LPWSTR *path); HRESULT assembly_get_version(ASSEMBLY *assembly, LPWSTR *version); BYTE assembly_get_architecture(ASSEMBLY *assembly); HRESULT assembly_get_pubkey_token(ASSEMBLY *assembly, LPWSTR *token); +extern HRESULT IAssemblyName_SetPath(IAssemblyName *iface, LPCWSTR path); +extern HRESULT IAssemblyName_GetPath(IAssemblyName *iface, LPWSTR buf, ULONG *len); + static inline LPWSTR strdupW(LPCWSTR src) { LPWSTR dest; From 17d7d4c15e3dff356ab67c091559a4d01fc56dc5 Mon Sep 17 00:00:00 2001 From: Christoph von Wittich Date: Mon, 27 Dec 2010 09:54:01 +0000 Subject: [PATCH 132/181] [FUSION] use crt="msvcrt" instead of msvcrt svn path=/trunk/; revision=50157 --- reactos/dll/win32/fusion/fusion.rbuild | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/reactos/dll/win32/fusion/fusion.rbuild b/reactos/dll/win32/fusion/fusion.rbuild index b1732dac348..6c3caa22787 100644 --- a/reactos/dll/win32/fusion/fusion.rbuild +++ b/reactos/dll/win32/fusion/fusion.rbuild @@ -1,4 +1,4 @@ - + . include/reactos/wine @@ -8,7 +8,6 @@ shlwapi advapi32 dbghelp - msvcrt user32 asmcache.c asmenum.c From cd7f6a4a364313c5121866a2509076230fd036c1 Mon Sep 17 00:00:00 2001 From: Roel Messiant Date: Mon, 27 Dec 2010 10:15:36 +0000 Subject: [PATCH 133/181] [SCSIPORT] - ScsiPortDeviceControl: Slight improvement to buffer length validation. Return failure status on a handful of failure cases. Prevents buffer overruns in user code. svn path=/trunk/; revision=50158 --- reactos/drivers/storage/scsiport/scsiport.c | 34 +++++++++++++-------- 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/reactos/drivers/storage/scsiport/scsiport.c b/reactos/drivers/storage/scsiport/scsiport.c index 817d9de3866..566df4fdc8b 100644 --- a/reactos/drivers/storage/scsiport/scsiport.c +++ b/reactos/drivers/storage/scsiport/scsiport.c @@ -2809,7 +2809,8 @@ ScsiPortDeviceControl(IN PDEVICE_OBJECT DeviceObject, { PIO_STACK_LOCATION Stack; PSCSI_PORT_DEVICE_EXTENSION DeviceExtension; - NTSTATUS Status = STATUS_SUCCESS; + PDUMP_POINTERS DumpPointers; + NTSTATUS Status; DPRINT("ScsiPortDeviceControl()\n"); @@ -2821,15 +2822,22 @@ ScsiPortDeviceControl(IN PDEVICE_OBJECT DeviceObject, switch (Stack->Parameters.DeviceIoControl.IoControlCode) { case IOCTL_SCSI_GET_DUMP_POINTERS: - { - PDUMP_POINTERS DumpPointers; - DPRINT(" IOCTL_SCSI_GET_DUMP_POINTERS\n"); - DumpPointers = (PDUMP_POINTERS)Irp->AssociatedIrp.SystemBuffer; - DumpPointers->DeviceObject = DeviceObject; + DPRINT(" IOCTL_SCSI_GET_DUMP_POINTERS\n"); - Irp->IoStatus.Information = sizeof(DUMP_POINTERS); - } - break; + if (Stack->Parameters.DeviceIoControl.OutputBufferLength < sizeof(DUMP_POINTERS)) + { + Status = STATUS_BUFFER_OVERFLOW; + Irp->IoStatus.Information = sizeof(DUMP_POINTERS); + break; + } + + DumpPointers = Irp->AssociatedIrp.SystemBuffer; + DumpPointers->DeviceObject = DeviceObject; + /* More data.. ? */ + + Status = STATUS_SUCCESS; + Irp->IoStatus.Information = sizeof(DUMP_POINTERS); + break; case IOCTL_SCSI_GET_CAPABILITIES: DPRINT(" IOCTL_SCSI_GET_CAPABILITIES\n"); @@ -2865,16 +2873,18 @@ ScsiPortDeviceControl(IN PDEVICE_OBJECT DeviceObject, case IOCTL_SCSI_MINIPORT: DPRINT1("IOCTL_SCSI_MINIPORT unimplemented!\n"); + Status = STATUS_NOT_IMPLEMENTED; break; case IOCTL_SCSI_PASS_THROUGH: DPRINT1("IOCTL_SCSI_PASS_THROUGH unimplemented!\n"); + Status = STATUS_NOT_IMPLEMENTED; break; default: - DPRINT1(" unknown ioctl code: 0x%lX\n", - Stack->Parameters.DeviceIoControl.IoControlCode); - break; + DPRINT1(" unknown ioctl code: 0x%lX\n", Stack->Parameters.DeviceIoControl.IoControlCode); + Status = STATUS_NOT_IMPLEMENTED; + break; } /* Complete the request with the given status */ From fdea91b64cdc963bf857f5e5943d4eb8a917e7ee Mon Sep 17 00:00:00 2001 From: Christoph von Wittich Date: Mon, 27 Dec 2010 12:45:03 +0000 Subject: [PATCH 134/181] [CRT] import strtoi64 from wine 1.3.10 svn path=/trunk/; revision=50159 --- reactos/lib/sdk/crt/string/strtoi64.c | 58 ++++++++++++++++++++++++++- 1 file changed, 56 insertions(+), 2 deletions(-) diff --git a/reactos/lib/sdk/crt/string/strtoi64.c b/reactos/lib/sdk/crt/string/strtoi64.c index 96260b6efbb..59e8c29a45c 100644 --- a/reactos/lib/sdk/crt/string/strtoi64.c +++ b/reactos/lib/sdk/crt/string/strtoi64.c @@ -4,8 +4,62 @@ __int64 _strtoi64(const char *nptr, char **endptr, int base) { - TRACE("_strtoi64 is UNIMPLEMENTED\n"); - return 0; + BOOL negative = FALSE; + __int64 ret = 0; + + while(isspace(*nptr)) nptr++; + + if(*nptr == '-') { + negative = TRUE; + nptr++; + } else if(*nptr == '+') + nptr++; + + if((base==0 || base==16) && *nptr=='0' && tolower(*(nptr+1))=='x') { + base = 16; + nptr += 2; + } + + if(base == 0) { + if(*nptr=='0') + base = 8; + else + base = 10; + } + + while(*nptr) { + char cur = tolower(*nptr); + int v; + + if(isdigit(cur)) { + if(cur >= '0'+base) + break; + v = cur-'0'; + } else { + if(cur<'a' || cur>='a'+base-10) + break; + v = cur-'a'+10; + } + + if(negative) + v = -v; + + nptr++; + + if(!negative && (ret>_I64_MAX/base || ret*base>_I64_MAX-v)) { + ret = _I64_MAX; + *_errno() = ERANGE; + } else if(negative && (ret<_I64_MIN/base || ret*base<_I64_MIN-v)) { + ret = _I64_MIN; + *_errno() = ERANGE; + } else + ret = ret*base + v; + } + + if(endptr) + *endptr = (char*)nptr; + + return ret; } From f7ab02f22e096d7f4c3e6c1ff5eb2469bad69db6 Mon Sep 17 00:00:00 2001 From: Aleksey Bragin Date: Mon, 27 Dec 2010 15:32:47 +0000 Subject: [PATCH 135/181] [PSDK] - Add missing definitions. svn path=/trunk/; revision=50161 --- reactos/include/psdk/shellapi.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/reactos/include/psdk/shellapi.h b/reactos/include/psdk/shellapi.h index 3a42ce5540f..a9b4f2f32ae 100644 --- a/reactos/include/psdk/shellapi.h +++ b/reactos/include/psdk/shellapi.h @@ -70,7 +70,8 @@ extern "C" { #define NIIF_NONE 0 #define NIIF_INFO 1 #define NIIF_WARNING 2 -#define NIIF_ERROR 3 +#define NIIF_ERROR 3 +#define NIIF_USER 4 #if _WIN32_IE >= 0x0600 #define NIIF_ICON_MASK 0xf #define NIIF_NOSOUND 0x10 From c7c2a79d5b2dc129891bece4638e66bab3a2bd7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Gardou?= Date: Mon, 27 Dec 2010 16:23:59 +0000 Subject: [PATCH 136/181] [GDI32] - Consistent formatting, no code change. svn path=/trunk/; revision=50163 --- reactos/dll/win32/gdi32/include/gdi32p.h | 170 +- reactos/dll/win32/gdi32/main/dllmain.c | 28 +- reactos/dll/win32/gdi32/misc/gdientry.c | 805 ++++----- reactos/dll/win32/gdi32/misc/heap.c | 36 +- reactos/dll/win32/gdi32/misc/misc.c | 258 +-- reactos/dll/win32/gdi32/misc/stubs.c | 1001 +++++------ reactos/dll/win32/gdi32/misc/stubsa.c | 82 +- reactos/dll/win32/gdi32/misc/stubsw.c | 127 +- reactos/dll/win32/gdi32/misc/wingl.c | 82 +- reactos/dll/win32/gdi32/objects/arc.c | 326 ++-- reactos/dll/win32/gdi32/objects/bitmap.c | 1071 ++++++------ reactos/dll/win32/gdi32/objects/brush.c | 500 +++--- reactos/dll/win32/gdi32/objects/coord.c | 978 +++++------ reactos/dll/win32/gdi32/objects/dc.c | 1792 ++++++++++---------- reactos/dll/win32/gdi32/objects/eng.c | 62 +- reactos/dll/win32/gdi32/objects/enhmfile.c | 592 +++---- reactos/dll/win32/gdi32/objects/font.c | 1391 +++++++-------- reactos/dll/win32/gdi32/objects/icm.c | 142 +- reactos/dll/win32/gdi32/objects/linedda.c | 10 +- reactos/dll/win32/gdi32/objects/metafile.c | 268 +-- reactos/dll/win32/gdi32/objects/painting.c | 858 +++++----- reactos/dll/win32/gdi32/objects/palette.c | 50 +- reactos/dll/win32/gdi32/objects/path.c | 88 +- reactos/dll/win32/gdi32/objects/pen.c | 4 +- reactos/dll/win32/gdi32/objects/printdrv.c | 776 ++++----- reactos/dll/win32/gdi32/objects/region.c | 1252 +++++++------- reactos/dll/win32/gdi32/objects/text.c | 575 +++---- reactos/dll/win32/gdi32/objects/utils.c | 460 ++--- 28 files changed, 6911 insertions(+), 6873 deletions(-) diff --git a/reactos/dll/win32/gdi32/include/gdi32p.h b/reactos/dll/win32/gdi32/include/gdi32p.h index e8b5e63952d..d76f21a534d 100644 --- a/reactos/dll/win32/gdi32/include/gdi32p.h +++ b/reactos/dll/win32/gdi32/include/gdi32p.h @@ -44,55 +44,55 @@ typedef INT // Based on wmfapi.h and Wine. typedef struct tagMETAFILEDC { - PVOID pvMetaBuffer; - HANDLE hFile; - DWORD Size; - DWORD dwWritten; - METAHEADER mh; - WORD reserved; - HLOCAL MFObjList; - HPEN hPen; - HBRUSH hBrush; - HDC hDc; - HGDIOBJ hMetaDc; - HPALETTE hPalette; - HFONT hFont; - HBITMAP hBitmap; - HRGN hRegion; - HGDIOBJ hMetafile; - HGDIOBJ hMemDc; - HPEN hExtPen; - HGDIOBJ hEnhMetaDc; - HGDIOBJ hEnhMetaFile; - HCOLORSPACE hColorSpace; - WCHAR Filename[MAX_PATH+2]; + PVOID pvMetaBuffer; + HANDLE hFile; + DWORD Size; + DWORD dwWritten; + METAHEADER mh; + WORD reserved; + HLOCAL MFObjList; + HPEN hPen; + HBRUSH hBrush; + HDC hDc; + HGDIOBJ hMetaDc; + HPALETTE hPalette; + HFONT hFont; + HBITMAP hBitmap; + HRGN hRegion; + HGDIOBJ hMetafile; + HGDIOBJ hMemDc; + HPEN hExtPen; + HGDIOBJ hEnhMetaDc; + HGDIOBJ hEnhMetaFile; + HCOLORSPACE hColorSpace; + WCHAR Filename[MAX_PATH+2]; } METAFILEDC,*PMETAFILEDC; // Metafile Entry handle typedef struct tagMF_ENTRY { - LIST_ENTRY List; - HGDIOBJ hmDC; // Handle return from NtGdiCreateClientObj. - PMETAFILEDC pmfDC; + LIST_ENTRY List; + HGDIOBJ hmDC; // Handle return from NtGdiCreateClientObj. + PMETAFILEDC pmfDC; } MF_ENTRY, *PMF_ENTRY; typedef struct tagENHMETAFILE { - PVOID pvMetaBuffer; - HANDLE hFile; /* Handle for disk based MetaFile */ - DWORD Size; - INT iType; - PENHMETAHEADER emf; - UINT handles_size, cur_handles; - HGDIOBJ *handles; - INT horzres, vertres; - INT horzsize, vertsize; - INT logpixelsx, logpixelsy; - INT bitspixel; - INT textcaps; - INT rastercaps; - INT technology; - INT planes; + PVOID pvMetaBuffer; + HANDLE hFile; /* Handle for disk based MetaFile */ + DWORD Size; + INT iType; + PENHMETAHEADER emf; + UINT handles_size, cur_handles; + HGDIOBJ *handles; + INT horzres, vertres; + INT horzsize, vertsize; + INT logpixelsx, logpixelsy; + INT bitspixel; + INT textcaps; + INT rastercaps; + INT technology; + INT planes; } ENHMETAFILE,*PENHMETAFILE; @@ -102,26 +102,26 @@ typedef struct tagENHMETAFILE #define UMPDEV_SUPPORT_ESCAPE 0x0004 typedef struct _UMPDEV { - DWORD Sig; // Init with PDEV_UMPD_ID - struct _UMPDEV *pumpdNext; - PDRIVER_INFO_5W pdi5Info; - HMODULE hModule; - DWORD dwFlags; - DWORD dwDriverAttributes; - DWORD dwConfigVersion; // Number of times the configuration - // file for this driver has been upgraded - // or downgraded since the last spooler restart. - DWORD dwDriverCount; // After init should be 2 - DWORD WOW64_UMPDev; - DWORD WOW64_hMod; - DWORD Unknown; - PVOID apfn[INDEX_LAST]; // Print Driver pfn + DWORD Sig; // Init with PDEV_UMPD_ID + struct _UMPDEV *pumpdNext; + PDRIVER_INFO_5W pdi5Info; + HMODULE hModule; + DWORD dwFlags; + DWORD dwDriverAttributes; + DWORD dwConfigVersion; // Number of times the configuration + // file for this driver has been upgraded + // or downgraded since the last spooler restart. + DWORD dwDriverCount; // After init should be 2 + DWORD WOW64_UMPDev; + DWORD WOW64_hMod; + DWORD Unknown; + PVOID apfn[INDEX_LAST]; // Print Driver pfn } UMPDEV, *PUMPDEV; #define LOCALFONT_COUNT 10 typedef struct _LOCALFONT { - FONT_ATTR lfa[LOCALFONT_COUNT]; + FONT_ATTR lfa[LOCALFONT_COUNT]; } LOCALFONT, *PLOCALFONT; // sdk/winspool.h @@ -322,35 +322,35 @@ GdiAllocBatchCommand( /* Get the size of the entry */ switch(Cmd) { - case GdiBCPatBlt: - ulSize = 0; - break; - case GdiBCPolyPatBlt: - ulSize = 0; - break; - case GdiBCTextOut: - ulSize = 0; - break; - case GdiBCExtTextOut: - ulSize = 0; - break; - case GdiBCSetBrushOrg: - ulSize = 0; - break; - case GdiBCExtSelClipRgn: - ulSize = 0; - break; - case GdiBCSelObj: - ulSize = sizeof(GDIBSOBJECT); - break; - case GdiBCDelRgn: - ulSize = sizeof(GDIBSOBJECT); - break; - case GdiBCDelObj: - ulSize = sizeof(GDIBSOBJECT); - break; - default: - return NULL; + case GdiBCPatBlt: + ulSize = 0; + break; + case GdiBCPolyPatBlt: + ulSize = 0; + break; + case GdiBCTextOut: + ulSize = 0; + break; + case GdiBCExtTextOut: + ulSize = 0; + break; + case GdiBCSetBrushOrg: + ulSize = 0; + break; + case GdiBCExtSelClipRgn: + ulSize = 0; + break; + case GdiBCSelObj: + ulSize = sizeof(GDIBSOBJECT); + break; + case GdiBCDelRgn: + ulSize = sizeof(GDIBSOBJECT); + break; + case GdiBCDelObj: + ulSize = sizeof(GDIBSOBJECT); + break; + default: + return NULL; } /* Unsupported operation */ @@ -358,7 +358,7 @@ GdiAllocBatchCommand( /* Check if the buffer is full */ if ((pTeb->GdiBatchCount >= GDI_BatchLimit) || - ((pTeb->GdiTebBatch.Offset + ulSize) > GDIBATCHBUFSIZE)) + ((pTeb->GdiTebBatch.Offset + ulSize) > GDIBATCHBUFSIZE)) { /* Call win32k, the kernel will call NtGdiFlushUserBatch to flush the current batch */ diff --git a/reactos/dll/win32/gdi32/main/dllmain.c b/reactos/dll/win32/gdi32/main/dllmain.c index 5dedf6ef4c3..9936c9521bb 100644 --- a/reactos/dll/win32/gdi32/main/dllmain.c +++ b/reactos/dll/win32/gdi32/main/dllmain.c @@ -29,12 +29,12 @@ DllMain ( { switch (dwReason) { - case DLL_PROCESS_ATTACH : - DisableThreadLibraryCalls(hDll); - break; + case DLL_PROCESS_ATTACH : + DisableThreadLibraryCalls(hDll); + break; - default: - break; + default: + break; } return TRUE; } @@ -69,17 +69,17 @@ GdiDllInitialize ( { switch (dwReason) { - case DLL_PROCESS_ATTACH: - GdiProcessSetup (); - break; + case DLL_PROCESS_ATTACH: + GdiProcessSetup (); + break; - case DLL_THREAD_ATTACH: - NtCurrentTeb()->GdiTebBatch.Offset = 0; - NtCurrentTeb()->GdiBatchCount = 0; - break; + case DLL_THREAD_ATTACH: + NtCurrentTeb()->GdiTebBatch.Offset = 0; + NtCurrentTeb()->GdiBatchCount = 0; + break; - default: - return FALSE; + default: + return FALSE; } // Very simple, the list will fill itself as it is needed. diff --git a/reactos/dll/win32/gdi32/misc/gdientry.c b/reactos/dll/win32/gdi32/misc/gdientry.c index eb510654ecc..6e51ea19d17 100644 --- a/reactos/dll/win32/gdi32/misc/gdientry.c +++ b/reactos/dll/win32/gdi32/misc/gdientry.c @@ -39,8 +39,8 @@ DdAddAttachedSurface(LPDDHAL_ADDATTACHEDSURFACEDATA Attach) { /* Call win32k */ return NtGdiDdAddAttachedSurface((HANDLE)Attach->lpDDSurface->hDDSurface, - (HANDLE)Attach->lpSurfAttached->hDDSurface, - (PDD_ADDATTACHEDSURFACEDATA)Attach); + (HANDLE)Attach->lpSurfAttached->hDDSurface, + (PDD_ADDATTACHEDSURFACEDATA)Attach); } /* @@ -55,7 +55,7 @@ DdBlt(LPDDHAL_BLTDATA Blt) HANDLE Surface = 0; /* Use the right surface */ - if (Blt->lpDDSrcSurface) + if (Blt->lpDDSrcSurface) { Surface = (HANDLE)Blt->lpDDSrcSurface->hDDSurface; } @@ -79,10 +79,10 @@ DdDestroySurface(LPDDHAL_DESTROYSURFACEDATA pDestroySurface) if (pDestroySurface->lpDDSurface->hDDSurface) { /* Check if we shoudl really destroy it */ - RealDestroy = !(pDestroySurface->lpDDSurface->dwFlags & DDRAWISURF_DRIVERMANAGED) || - !(pDestroySurface->lpDDSurface->dwFlags & DDRAWISURF_INVALID); + RealDestroy = !(pDestroySurface->lpDDSurface->dwFlags & DDRAWISURF_DRIVERMANAGED) || + !(pDestroySurface->lpDDSurface->dwFlags & DDRAWISURF_INVALID); - /* Call win32k */ + /* Call win32k */ Return = NtGdiDdDestroySurface((HANDLE)pDestroySurface->lpDDSurface->hDDSurface, RealDestroy); } @@ -100,17 +100,17 @@ DdFlip(LPDDHAL_FLIPDATA Flip) { /* Note : * See http://msdn2.microsoft.com/en-us/library/ms794213.aspx and - * http://msdn2.microsoft.com/en-us/library/ms792675.aspx + * http://msdn2.microsoft.com/en-us/library/ms792675.aspx */ HANDLE hSurfaceCurrentLeft = NULL; HANDLE hSurfaceTargetLeft = NULL; - + /* Auto flip off or on */ if (Flip->dwFlags & DDFLIP_STEREO ) { if ( (Flip->lpSurfTargLeft) && - (Flip->lpSurfCurrLeft)) + (Flip->lpSurfCurrLeft)) { /* Auto flip on */ hSurfaceTargetLeft = (HANDLE) Flip->lpSurfTargLeft->hDDSurface; @@ -138,8 +138,8 @@ DdLock(LPDDHAL_LOCKDATA Lock) /* Call win32k */ return NtGdiDdLock((HANDLE)Lock->lpDDSurface->hDDSurface, - (PDD_LOCKDATA)Lock, - (HANDLE)Lock->lpDDSurface->hDC); + (PDD_LOCKDATA)Lock, + (HANDLE)Lock->lpDDSurface->hDC); } /* @@ -153,7 +153,7 @@ DdUnlock(LPDDHAL_UNLOCKDATA Unlock) { /* Call win32k */ return NtGdiDdUnlock((HANDLE)Unlock->lpDDSurface->hDDSurface, - (PDD_UNLOCKDATA)Unlock); + (PDD_UNLOCKDATA)Unlock); } /* @@ -167,7 +167,7 @@ DdGetBltStatus(LPDDHAL_GETBLTSTATUSDATA GetBltStatus) { /* Call win32k */ return NtGdiDdGetBltStatus((HANDLE)GetBltStatus->lpDDSurface->hDDSurface, - (PDD_GETBLTSTATUSDATA)GetBltStatus); + (PDD_GETBLTSTATUSDATA)GetBltStatus); } /* @@ -181,7 +181,7 @@ DdGetFlipStatus(LPDDHAL_GETFLIPSTATUSDATA GetFlipStatus) { /* Call win32k */ return NtGdiDdGetFlipStatus((HANDLE)GetFlipStatus->lpDDSurface->hDDSurface, - (PDD_GETFLIPSTATUSDATA)GetFlipStatus); + (PDD_GETFLIPSTATUSDATA)GetFlipStatus); } /* @@ -218,8 +218,8 @@ DdUpdateOverlay(LPDDHAL_UPDATEOVERLAYDATA UpdateOverlay) /* Call win32k */ return NtGdiDdUpdateOverlay((HANDLE)UpdateOverlay->lpDDDestSurface->hDDSurface, - (HANDLE)UpdateOverlay->lpDDSrcSurface->hDDSurface, - (PDD_UPDATEOVERLAYDATA)UpdateOverlay); + (HANDLE)UpdateOverlay->lpDDSrcSurface->hDDSurface, + (PDD_UPDATEOVERLAYDATA)UpdateOverlay); } /* @@ -248,7 +248,7 @@ DdWaitForVerticalBlank(LPDDHAL_WAITFORVERTICALBLANKDATA WaitForVerticalBlank) { /* Call win32k */ return NtGdiDdWaitForVerticalBlank(GetDdHandle( - WaitForVerticalBlank->lpDD->hDD), + WaitForVerticalBlank->lpDD->hDD), (PDD_WAITFORVERTICALBLANKDATA) WaitForVerticalBlank); } @@ -262,11 +262,11 @@ DWORD WINAPI DdCanCreateSurface(LPDDHAL_CANCREATESURFACEDATA CanCreateSurface) { - /* - * Note : This functions are basic same, in win32k - * NtGdiDdCanCreateD3DBuffer and NtGdiDdCanCreateSurface are mergs - * toghter in win32k at end and retrurn same data, it is still sepreated - * at user mode but in kmode it is not. + /* + * Note : This functions are basic same, in win32k + * NtGdiDdCanCreateD3DBuffer and NtGdiDdCanCreateSurface are mergs + * toghter in win32k at end and retrurn same data, it is still sepreated + * at user mode but in kmode it is not. */ /* Call win32k */ @@ -303,18 +303,19 @@ DdCreateSurface(LPDDHAL_CREATESURFACEDATA pCreateSurface) LPDDSURFACEDESC pSurfaceDesc = NULL; /* TODO: Optimize speed. Most games/dx apps/programs do not want one surface, they want at least two. - * So we need increase the stack to contain two surfaces instead of one. This will increase + * So we need increase the stack to contain two surfaces instead of one. This will increase * the speed of the apps when allocating buffers. How to increase the surface stack space: * we need to create a struct for DD_SURFACE_LOCAL DdSurfaceLocal, DD_SURFACE_MORE DdSurfaceMore * DD_SURFACE_GLOBAL DdSurfaceGlobal, HANDLE hPrevSurface, hSurface like * struct { DD_SURFACE_LOCAL DdSurfaceLocal1, DD_SURFACE_LOCAL DdSurfaceLocal2 } - * in a way that it may contain two surfaces, maybe even four. We need to watch what is most common before + * in a way that it may contain two surfaces, maybe even four. We need to watch what is most common before * we create the size. Activate this IF when you start doing the optimze and please also * take reports from users which value they got here. - */ + */ #if 1 { - char buffer[1024]; \ + char buffer[1024]; + \ sprintf ( buffer, "Function %s : Optimze max to %d Surface ? (%s:%d)\n", __FUNCTION__, (int)SurfaceCount,__FILE__,__LINE__ ); OutputDebugStringA(buffer); } @@ -396,10 +397,10 @@ DdCreateSurface(LPDDHAL_CREATESURFACEDATA pCreateSurface) ptmpDdSurfaceLocal->ddsCaps.dwCaps = lcl->ddsCaps.dwCaps; ptmpDdSurfaceLocal->dwFlags = (ptmpDdSurfaceLocal->dwFlags & - (0xB0000000 | DDRAWISURF_INMASTERSPRITELIST | - DDRAWISURF_HELCB | DDRAWISURF_FRONTBUFFER | - DDRAWISURF_BACKBUFFER | DDRAWISURF_INVALID | - DDRAWISURF_DCIBUSY | DDRAWISURF_DCILOCK)) | + (0xB0000000 | DDRAWISURF_INMASTERSPRITELIST | + DDRAWISURF_HELCB | DDRAWISURF_FRONTBUFFER | + DDRAWISURF_BACKBUFFER | DDRAWISURF_INVALID | + DDRAWISURF_DCIBUSY | DDRAWISURF_DCILOCK)) | (lcl->dwFlags & DDRAWISURF_DRIVERMANAGED); ptmpDdSurfaceGlobal->wWidth = gpl->wWidth; @@ -424,9 +425,9 @@ DdCreateSurface(LPDDHAL_CREATESURFACEDATA pCreateSurface) sizeof(DDPIXELFORMAT)); } - /* Note if lcl->lpSurfMore is NULL zero out + /* Note if lcl->lpSurfMore is NULL zero out * ptmpDdSurfaceMore->ddsCapsEx.dwCaps2, - * dwCaps3, dwCaps4, ptmpDdSurfaceMore->dwSurfaceHandle + * dwCaps3, dwCaps4, ptmpDdSurfaceMore->dwSurfaceHandle */ if (lcl->lpSurfMore) { @@ -448,13 +449,13 @@ DdCreateSurface(LPDDHAL_CREATESURFACEDATA pCreateSurface) pCreateSurface->ddRVal = DDERR_GENERIC; Return = NtGdiDdCreateSurface(GetDdHandle(pCreateSurface->lpDD->hDD), - (HANDLE *)phSurface, - pSurfaceDesc, - pDdSurfaceGlobal, - pDdSurfaceLocal, - pDdSurfaceMore, - (PDD_CREATESURFACEDATA)pCreateSurface, - puhSurface); + (HANDLE *)phSurface, + pSurfaceDesc, + pDdSurfaceGlobal, + pDdSurfaceLocal, + pDdSurfaceMore, + (PDD_CREATESURFACEDATA)pCreateSurface, + puhSurface); if (SurfaceCount == 0) { @@ -466,7 +467,7 @@ DdCreateSurface(LPDDHAL_CREATESURFACEDATA pCreateSurface) ptmpDdSurfaceGlobal = pDdSurfaceGlobal; ptmpDdSurfaceLocal = pDdSurfaceLocal; - for (i=0;ilplpSList[i]; LPDDRAWI_DDRAWSURFACE_GBL gpl = pCreateSurface->lplpSList[i]->lpGbl; @@ -555,7 +556,7 @@ DdSetColorKey(LPDDHAL_SETCOLORKEYDATA pSetColorKey) { /* Call win32k */ return NtGdiDdSetColorKey((HANDLE)pSetColorKey->lpDDSurface->hDDSurface, - (PDD_SETCOLORKEYDATA)pSetColorKey); + (PDD_SETCOLORKEYDATA)pSetColorKey); } /* @@ -569,7 +570,7 @@ DdGetScanLine(LPDDHAL_GETSCANLINEDATA pGetScanLine) { /* Call win32k */ return NtGdiDdGetScanLine(GetDdHandle(pGetScanLine->lpDD->hDD), - (PDD_GETSCANLINEDATA)pGetScanLine); + (PDD_GETSCANLINEDATA)pGetScanLine); } @@ -581,11 +582,11 @@ DdGetScanLine(LPDDHAL_GETSCANLINEDATA pGetScanLine) BOOL WINAPI DvpCreateVideoPort(LPDDHAL_CREATEVPORTDATA pDvdCreatePort) -{ - pDvdCreatePort->lpVideoPort->hDDVideoPort = - NtGdiDvpCreateVideoPort(GetDdHandle(pDvdCreatePort->lpDD->lpGbl->hDD), - (PDD_CREATEVPORTDATA) pDvdCreatePort); - +{ + pDvdCreatePort->lpVideoPort->hDDVideoPort = + NtGdiDvpCreateVideoPort(GetDdHandle(pDvdCreatePort->lpDD->lpGbl->hDD), + (PDD_CREATEVPORTDATA) pDvdCreatePort); + return TRUE; } @@ -598,7 +599,7 @@ DWORD WINAPI DvpDestroyVideoPort(LPDDHAL_DESTROYVPORTDATA pDvdDestoryPort) { - return NtGdiDvpDestroyVideoPort(pDvdDestoryPort->lpVideoPort->hDDVideoPort, (PDD_DESTROYVPORTDATA)pDvdDestoryPort); + return NtGdiDvpDestroyVideoPort(pDvdDestoryPort->lpVideoPort->hDDVideoPort, (PDD_DESTROYVPORTDATA)pDvdDestoryPort); } /* @@ -698,8 +699,8 @@ WINAPI DvpUpdateVideoPort(LPDDHAL_UPDATEVPORTDATA pDvdUpdateVideoPort) { /* - * Windows XP limit to max 10 handles of videoport surface and Vbi - * ReactOS doing same to keep compatible, if it is more that 10 + * Windows XP limit to max 10 handles of videoport surface and Vbi + * ReactOS doing same to keep compatible, if it is more that 10 * videoport surface or vbi the stack will be curpted in windows xp * ReactOS safe guard againts that * @@ -707,7 +708,7 @@ DvpUpdateVideoPort(LPDDHAL_UPDATEVPORTDATA pDvdUpdateVideoPort) HANDLE phSurfaceVideo[10]; HANDLE phSurfaceVbi[10]; - + if (pDvdUpdateVideoPort->dwFlags != DDRAWI_VPORTSTOP) { DWORD dwNumAutoflip; @@ -716,28 +717,28 @@ DvpUpdateVideoPort(LPDDHAL_UPDATEVPORTDATA pDvdUpdateVideoPort) /* Take copy of lplpDDSurface for the handle value will be modify in dxg */ dwNumAutoflip = pDvdUpdateVideoPort->dwNumAutoflip; if ((dwNumAutoflip == 0) && - (pDvdUpdateVideoPort->lplpDDSurface == 0)) - { - dwNumAutoflip++; + (pDvdUpdateVideoPort->lplpDDSurface == 0)) + { + dwNumAutoflip++; } - + if (dwNumAutoflip != 0) - { + { if (dwNumAutoflip>10) { dwNumAutoflip = 10; } - memcpy(phSurfaceVideo,pDvdUpdateVideoPort->lplpDDSurface,dwNumAutoflip*sizeof(HANDLE)); + memcpy(phSurfaceVideo,pDvdUpdateVideoPort->lplpDDSurface,dwNumAutoflip*sizeof(HANDLE)); } - + /* Take copy of lplpDDVBISurface for the handle value will be modify in dxg */ - dwNumVBIAutoflip = pDvdUpdateVideoPort->dwNumVBIAutoflip; + dwNumVBIAutoflip = pDvdUpdateVideoPort->dwNumVBIAutoflip; if ( (dwNumVBIAutoflip == 0) && - (pDvdUpdateVideoPort->lplpDDVBISurface == 0) ) + (pDvdUpdateVideoPort->lplpDDVBISurface == 0) ) { dwNumVBIAutoflip++; } - + if (dwNumVBIAutoflip != 0) { if (dwNumVBIAutoflip>10) @@ -745,7 +746,7 @@ DvpUpdateVideoPort(LPDDHAL_UPDATEVPORTDATA pDvdUpdateVideoPort) dwNumVBIAutoflip = 10; } memcpy(phSurfaceVbi,pDvdUpdateVideoPort->lplpDDVBISurface,dwNumVBIAutoflip*sizeof(HANDLE)); - } + } } /* Call Win32k */ @@ -821,7 +822,7 @@ DWORD WINAPI DdGetAvailDriverMemory(LPDDHAL_GETAVAILDRIVERMEMORYDATA pDdGetAvailDriverMemory) { - return NtGdiDdGetAvailDriverMemory(GetDdHandle( pDdGetAvailDriverMemory->lpDD->hDD), (PDD_GETAVAILDRIVERMEMORYDATA) pDdGetAvailDriverMemory); + return NtGdiDdGetAvailDriverMemory(GetDdHandle( pDdGetAvailDriverMemory->lpDD->hDD), (PDD_GETAVAILDRIVERMEMORYDATA) pDdGetAvailDriverMemory); } /* @@ -833,13 +834,13 @@ DWORD WINAPI DdAlphaBlt(LPDDHAL_BLTDATA pDdAlphaBlt) { - HANDLE hDDSrcSurface = 0; + HANDLE hDDSrcSurface = 0; if (pDdAlphaBlt->lpDDSrcSurface != 0) { hDDSrcSurface = (HANDLE) pDdAlphaBlt->lpDDSrcSurface->hDDSurface; } - + return NtGdiDdAlphaBlt((HANDLE)pDdAlphaBlt->lpDDDestSurface->hDDSurface, hDDSrcSurface, (PDD_BLTDATA)&pDdAlphaBlt); } @@ -853,8 +854,8 @@ WINAPI DdCreateSurfaceEx(LPDDHAL_CREATESURFACEEXDATA pDdCreateSurfaceEx) { pDdCreateSurfaceEx->ddRVal = NtGdiDdCreateSurfaceEx( GetDdHandle(pDdCreateSurfaceEx->lpDDLcl->lpGbl->hDD), - (HANDLE)pDdCreateSurfaceEx->lpDDSLcl->hDDSurface, - pDdCreateSurfaceEx->lpDDSLcl->lpSurfMore->dwSurfaceHandle); + (HANDLE)pDdCreateSurfaceEx->lpDDSLcl->hDDSurface, + pDdCreateSurfaceEx->lpDDSLcl->lpSurfMore->dwSurfaceHandle); return TRUE; } @@ -898,330 +899,330 @@ DdFlipToGDISurface(LPDDHAL_FLIPTOGDISURFACEDATA pDdFlipToGDISurface) DWORD WINAPI DdGetDriverInfo(LPDDHAL_GETDRIVERINFODATA pData) -{ +{ DDHAL_GETDRIVERINFODATA pDrvInfoData; DWORD retValue = DDHAL_DRIVER_NOTHANDLED; HANDLE hDD; /* FIXME add SEH around this functions */ - RtlZeroMemory(&pDrvInfoData, sizeof (DDHAL_GETDRIVERINFODATA)); - RtlCopyMemory(&pDrvInfoData.guidInfo, &pData->guidInfo, sizeof(GUID)); - - hDD = GetDdHandle(pData->dwContext); + RtlZeroMemory(&pDrvInfoData, sizeof (DDHAL_GETDRIVERINFODATA)); + RtlCopyMemory(&pDrvInfoData.guidInfo, &pData->guidInfo, sizeof(GUID)); - pDrvInfoData.dwSize = sizeof (DDHAL_GETDRIVERINFODATA); - pDrvInfoData.ddRVal = DDERR_GENERIC; - pDrvInfoData.dwContext = (ULONG_PTR)hDD; - - - /* Videoport Callbacks check and setup for DirectX/ ReactX */ - if (IsEqualGUID(&pData->guidInfo, &GUID_VideoPortCallbacks)) - { - DDHAL_DDVIDEOPORTCALLBACKS pDvdPort; - DDHAL_DDVIDEOPORTCALLBACKS* pUserDvdPort = (DDHAL_DDVIDEOPORTCALLBACKS *)pData->lpvData; + hDD = GetDdHandle(pData->dwContext); - /* Clear internal out buffer and set it up*/ - RtlZeroMemory(&pDvdPort, DDVIDEOPORTCALLBACKSSIZE); - pDvdPort.dwSize = DDVIDEOPORTCALLBACKSSIZE; + pDrvInfoData.dwSize = sizeof (DDHAL_GETDRIVERINFODATA); + pDrvInfoData.ddRVal = DDERR_GENERIC; + pDrvInfoData.dwContext = (ULONG_PTR)hDD; - /* set up internal buffer */ - pDrvInfoData.lpvData = (PVOID)&pDvdPort; - pDrvInfoData.dwExpectedSize = DDVIDEOPORTCALLBACKSSIZE ; - - /* Call win32k */ - retValue = NtGdiDdGetDriverInfo(hDD, (PDD_GETDRIVERINFODATA)&pDrvInfoData); - /* Setup user out buffer and convert kmode callbacks to user mode */ - pUserDvdPort->dwSize = DDVIDEOPORTCALLBACKSSIZE; - pUserDvdPort->dwFlags = pDrvInfoData.dwFlags = 0; - - pUserDvdPort->dwFlags = (pDrvInfoData.dwFlags & ~(DDHAL_VPORT32_CREATEVIDEOPORT | DDHAL_VPORT32_FLIP | - DDHAL_VPORT32_DESTROY | DDHAL_VPORT32_UPDATE | DDHAL_VPORT32_WAITFORSYNC)) | - (DDHAL_VPORT32_CREATEVIDEOPORT | DDHAL_VPORT32_FLIP | - DDHAL_VPORT32_DESTROY | DDHAL_VPORT32_UPDATE); + /* Videoport Callbacks check and setup for DirectX/ ReactX */ + if (IsEqualGUID(&pData->guidInfo, &GUID_VideoPortCallbacks)) + { + DDHAL_DDVIDEOPORTCALLBACKS pDvdPort; + DDHAL_DDVIDEOPORTCALLBACKS* pUserDvdPort = (DDHAL_DDVIDEOPORTCALLBACKS *)pData->lpvData; - pData->dwActualSize = DDVIDEOPORTCALLBACKSSIZE; - pUserDvdPort->CreateVideoPort = (LPDDHALVPORTCB_CREATEVIDEOPORT) DvpCreateVideoPort; - pUserDvdPort->FlipVideoPort = (LPDDHALVPORTCB_FLIP) DvpFlipVideoPort; - pUserDvdPort->DestroyVideoPort = (LPDDHALVPORTCB_DESTROYVPORT) DvpDestroyVideoPort; - pUserDvdPort->UpdateVideoPort = (LPDDHALVPORTCB_UPDATE) DvpUpdateVideoPort; + /* Clear internal out buffer and set it up*/ + RtlZeroMemory(&pDvdPort, DDVIDEOPORTCALLBACKSSIZE); + pDvdPort.dwSize = DDVIDEOPORTCALLBACKSSIZE; - if (pDvdPort.CanCreateVideoPort) - { - pUserDvdPort->CanCreateVideoPort = (LPDDHALVPORTCB_CANCREATEVIDEOPORT) DvpCanCreateVideoPort; - } + /* set up internal buffer */ + pDrvInfoData.lpvData = (PVOID)&pDvdPort; + pDrvInfoData.dwExpectedSize = DDVIDEOPORTCALLBACKSSIZE ; - if (pDvdPort.GetVideoPortBandwidth) - { - pUserDvdPort->GetVideoPortBandwidth = (LPDDHALVPORTCB_GETBANDWIDTH) DvpGetVideoPortBandwidth; - } + /* Call win32k */ + retValue = NtGdiDdGetDriverInfo(hDD, (PDD_GETDRIVERINFODATA)&pDrvInfoData); - if (pDvdPort.GetVideoPortInputFormats) - { - pUserDvdPort->GetVideoPortInputFormats = (LPDDHALVPORTCB_GETINPUTFORMATS) DvpGetVideoPortInputFormats; - } + /* Setup user out buffer and convert kmode callbacks to user mode */ + pUserDvdPort->dwSize = DDVIDEOPORTCALLBACKSSIZE; + pUserDvdPort->dwFlags = pDrvInfoData.dwFlags = 0; - if (pDvdPort.GetVideoPortOutputFormats) - { - pUserDvdPort->GetVideoPortOutputFormats = (LPDDHALVPORTCB_GETOUTPUTFORMATS) DvpGetVideoPortOutputFormats; - } + pUserDvdPort->dwFlags = (pDrvInfoData.dwFlags & ~(DDHAL_VPORT32_CREATEVIDEOPORT | DDHAL_VPORT32_FLIP | + DDHAL_VPORT32_DESTROY | DDHAL_VPORT32_UPDATE | DDHAL_VPORT32_WAITFORSYNC)) | + (DDHAL_VPORT32_CREATEVIDEOPORT | DDHAL_VPORT32_FLIP | + DDHAL_VPORT32_DESTROY | DDHAL_VPORT32_UPDATE); - if (pDvdPort.GetVideoPortField) - { - pUserDvdPort->GetVideoPortField = (LPDDHALVPORTCB_GETFIELD) DvpGetVideoPortField; - } + pData->dwActualSize = DDVIDEOPORTCALLBACKSSIZE; + pUserDvdPort->CreateVideoPort = (LPDDHALVPORTCB_CREATEVIDEOPORT) DvpCreateVideoPort; + pUserDvdPort->FlipVideoPort = (LPDDHALVPORTCB_FLIP) DvpFlipVideoPort; + pUserDvdPort->DestroyVideoPort = (LPDDHALVPORTCB_DESTROYVPORT) DvpDestroyVideoPort; + pUserDvdPort->UpdateVideoPort = (LPDDHALVPORTCB_UPDATE) DvpUpdateVideoPort; - if (pDvdPort.GetVideoPortLine) - { - pUserDvdPort->GetVideoPortLine = (LPDDHALVPORTCB_GETLINE) DvpGetVideoPortLine; - } - - if (pDvdPort.GetVideoPortConnectInfo) - { - pUserDvdPort->GetVideoPortConnectInfo = (LPDDHALVPORTCB_GETVPORTCONNECT) DvpGetVideoPortConnectInfo; - } - - if (pDvdPort.GetVideoPortFlipStatus) - { - pUserDvdPort->GetVideoPortFlipStatus = (LPDDHALVPORTCB_GETFLIPSTATUS) DvpGetVideoPortFlipStatus; - } - - if (pDvdPort.WaitForVideoPortSync) - { - pUserDvdPort->WaitForVideoPortSync = (LPDDHALVPORTCB_WAITFORSYNC) DvpWaitForVideoPortSync; - } - - if (pDvdPort.GetVideoSignalStatus) - { - pUserDvdPort->GetVideoSignalStatus = (LPDDHALVPORTCB_GETSIGNALSTATUS) DvpGetVideoSignalStatus; - } - - if (pDvdPort.ColorControl) - { - pUserDvdPort->ColorControl = (LPDDHALVPORTCB_COLORCONTROL) DvpColorControl; - } - - /* Windows XP never repot back the true return value, - * it only report back if we have a driver or not - * ReactOS keep this behoir to be compatible with - * Windows XP - */ - pData->ddRVal = retValue; - } - - /* Color Control Callbacks check and setup for DirectX/ ReactX */ - if (IsEqualGUID(&pData->guidInfo, &GUID_ColorControlCallbacks)) + if (pDvdPort.CanCreateVideoPort) { - DDHAL_DDCOLORCONTROLCALLBACKS pColorControl; - DDHAL_DDCOLORCONTROLCALLBACKS* pUserColorControl = (DDHAL_DDCOLORCONTROLCALLBACKS *)pData->lpvData; - - /* Clear internal out buffer and set it up*/ - RtlZeroMemory(&pColorControl, DDCOLORCONTROLCALLBACKSSIZE); - pColorControl.dwSize = DDCOLORCONTROLCALLBACKSSIZE; - - /* set up internal buffer */ - pDrvInfoData.lpvData = (PVOID)&pColorControl; - pDrvInfoData.dwExpectedSize = DDCOLORCONTROLCALLBACKSSIZE ; - - /* Call win32k */ - retValue = NtGdiDdGetDriverInfo(hDD, (PDD_GETDRIVERINFODATA)&pDrvInfoData); - - pData->dwActualSize = DDCOLORCONTROLCALLBACKSSIZE; - pData->dwFlags = pDrvInfoData.dwFlags; - - pUserColorControl->dwSize = DDCOLORCONTROLCALLBACKSSIZE; - pUserColorControl->dwFlags = pUserColorControl->dwFlags; - - if (pColorControl.ColorControl != NULL) - { - pUserColorControl->ColorControl = (LPDDHALCOLORCB_COLORCONTROL) DdColorControl; - } - - /* Windows XP never repot back the true return value, - * it only report back if we have a driver or not - * ReactOS keep this behoir to be compatible with - * Windows XP - */ - pData->ddRVal = retValue; + pUserDvdPort->CanCreateVideoPort = (LPDDHALVPORTCB_CANCREATEVIDEOPORT) DvpCanCreateVideoPort; } - /* Misc Callbacks check and setup for DirectX/ ReactX */ - else if (IsEqualGUID(&pData->guidInfo, &GUID_MiscellaneousCallbacks)) + if (pDvdPort.GetVideoPortBandwidth) { - DDHAL_DDMISCELLANEOUSCALLBACKS pMisc; - DDHAL_DDMISCELLANEOUSCALLBACKS* pUserMisc = (DDHAL_DDMISCELLANEOUSCALLBACKS *)pData->lpvData; - - /* Clear internal out buffer and set it up*/ - RtlZeroMemory(&pMisc, DDMISCELLANEOUSCALLBACKSSIZE); - pMisc.dwSize = DDMISCELLANEOUSCALLBACKSSIZE; - - /* set up internal buffer */ - pDrvInfoData.lpvData = (PVOID)&pMisc; - pDrvInfoData.dwExpectedSize = DDMISCELLANEOUSCALLBACKSSIZE ; - - /* Call win32k */ - retValue = NtGdiDdGetDriverInfo(hDD, (PDD_GETDRIVERINFODATA)&pDrvInfoData); - - pData->dwActualSize = DDMISCELLANEOUSCALLBACKSSIZE; - - /* Only one callbacks are supported */ - pUserMisc->dwFlags = pMisc.dwFlags & DDHAL_MISCCB32_GETAVAILDRIVERMEMORY; - pUserMisc->GetAvailDriverMemory = (LPDDHAL_GETAVAILDRIVERMEMORY) DdGetAvailDriverMemory; - - /* This callbacks are only for win9x and theirfor it is not longer use in NT or ReactOS - * pUserMisc->UpdateNonLocalHeap; - * pUserMisc->GetHeapAlignment; - * pUserMisc->GetSysmemBltStatus; */ - - /* Windows XP never repot back the true return value, - * it only report back if we have a driver or not - * ReactOS keep this behoir to be compatible with - * Windows XP - */ - pData->ddRVal = retValue; + pUserDvdPort->GetVideoPortBandwidth = (LPDDHALVPORTCB_GETBANDWIDTH) DvpGetVideoPortBandwidth; } - /* Misc 2 Callbacks check and setup for DirectX/ ReactX */ - else if (IsEqualGUID(&pData->guidInfo, &GUID_Miscellaneous2Callbacks)) + if (pDvdPort.GetVideoPortInputFormats) { - DDHAL_DDMISCELLANEOUS2CALLBACKS pMisc; - DDHAL_DDMISCELLANEOUS2CALLBACKS* pUserMisc = (DDHAL_DDMISCELLANEOUS2CALLBACKS *)pData->lpvData; - - /* Clear internal out buffer and set it up*/ - RtlZeroMemory(&pMisc, DDMISCELLANEOUS2CALLBACKSSIZE); - pMisc.dwSize = DDMISCELLANEOUS2CALLBACKSSIZE; - - /* set up internal buffer */ - pDrvInfoData.lpvData = (PVOID)&pMisc; - pDrvInfoData.dwExpectedSize = DDMISCELLANEOUS2CALLBACKSSIZE ; - - /* Call win32k */ - retValue = NtGdiDdGetDriverInfo(hDD, (PDD_GETDRIVERINFODATA)&pDrvInfoData); - - pData->dwActualSize = DDMISCELLANEOUS2CALLBACKSSIZE; - - pUserMisc->dwFlags = pMisc.dwFlags; - - /* This functions are not documneted in MSDN for this struct, here is directx/reactx alpha blend */ - if ( pMisc.Reserved ) - { - pUserMisc->Reserved = (LPVOID) DdAlphaBlt; - } - - if ( pMisc.CreateSurfaceEx ) - { - pUserMisc->CreateSurfaceEx = (LPDDHAL_CREATESURFACEEX) DdCreateSurfaceEx; - } - - if ( pMisc.GetDriverState ) - { - pUserMisc->GetDriverState = (LPDDHAL_GETDRIVERSTATE) NtGdiDdGetDriverState; - } - - /* NOTE : pUserMisc->DestroyDDLocal is outdated and are not beign tuch */ - - /* Windows XP never repot back the true return value, - * it only report back if we have a driver or not - * ReactOS keep this behoir to be compatible with - * Windows XP - */ - pData->ddRVal = retValue; + pUserDvdPort->GetVideoPortInputFormats = (LPDDHALVPORTCB_GETINPUTFORMATS) DvpGetVideoPortInputFormats; } - /* NT Callbacks check and setup for DirectX/ ReactX */ - else if (IsEqualGUID(&pData->guidInfo, &GUID_NTCallbacks)) + if (pDvdPort.GetVideoPortOutputFormats) { - /* MS does not have DHAL_* version of this callbacks - * so we are force using PDD_* callbacks here - */ - DD_NTCALLBACKS pNtKernel; - PDD_NTCALLBACKS pUserNtKernel = (PDD_NTCALLBACKS)pData->lpvData; - - /* Clear internal out buffer and set it up*/ - RtlZeroMemory(&pNtKernel, sizeof(DD_NTCALLBACKS)); - pNtKernel.dwSize = sizeof(DD_NTCALLBACKS); - - /* set up internal buffer */ - pDrvInfoData.lpvData = (PVOID)&pNtKernel; - pDrvInfoData.dwExpectedSize = sizeof(DD_NTCALLBACKS) ; - - /* Call win32k */ - retValue = NtGdiDdGetDriverInfo(hDD, (PDD_GETDRIVERINFODATA)&pDrvInfoData); - - pData->dwActualSize = sizeof(DD_NTCALLBACKS); - - pUserNtKernel->dwSize = sizeof(DD_NTCALLBACKS); - pUserNtKernel->dwFlags = pNtKernel.dwFlags; - pUserNtKernel->FreeDriverMemory = 0; - - if (pNtKernel.SetExclusiveMode) - { - pUserNtKernel->SetExclusiveMode = (PDD_SETEXCLUSIVEMODE) DdSetExclusiveMode; - } - - if (pNtKernel.FlipToGDISurface) - { - pUserNtKernel->FlipToGDISurface = (PDD_FLIPTOGDISURFACE) DdFlipToGDISurface; - } - - /* Windows XP never repot back the true return value, - * it only report back if we have a driver or not - * ReactOS keep this behoir to be compatible with - * Windows XP - */ - pData->ddRVal = retValue; + pUserDvdPort->GetVideoPortOutputFormats = (LPDDHALVPORTCB_GETOUTPUTFORMATS) DvpGetVideoPortOutputFormats; } - /* D3D Callbacks version 2 check and setup for DirectX/ ReactX */ - else if (IsEqualGUID(&pData->guidInfo, &GUID_D3DCallbacks2)) + if (pDvdPort.GetVideoPortField) { - // FIXME GUID_D3DCallbacks2 + pUserDvdPort->GetVideoPortField = (LPDDHALVPORTCB_GETFIELD) DvpGetVideoPortField; } - /* D3D Callbacks version 3 check and setup for DirectX/ ReactX */ - else if (IsEqualGUID(&pData->guidInfo, &GUID_D3DCallbacks3)) + if (pDvdPort.GetVideoPortLine) { - // FIXME GUID_D3DCallbacks3 + pUserDvdPort->GetVideoPortLine = (LPDDHALVPORTCB_GETLINE) DvpGetVideoPortLine; } - /* D3DParseUnknownCommand Callbacks check and setup for DirectX/ ReactX */ - else if (IsEqualGUID(&pData->guidInfo, &GUID_D3DParseUnknownCommandCallback)) + if (pDvdPort.GetVideoPortConnectInfo) { - // FIXME GUID_D3DParseUnknownCommandCallback + pUserDvdPort->GetVideoPortConnectInfo = (LPDDHALVPORTCB_GETVPORTCONNECT) DvpGetVideoPortConnectInfo; } - /* MotionComp Callbacks check and setup for DirectX/ ReactX */ - else if (IsEqualGUID(&pData->guidInfo, &GUID_MotionCompCallbacks)) + if (pDvdPort.GetVideoPortFlipStatus) { - // FIXME GUID_MotionCompCallbacks + pUserDvdPort->GetVideoPortFlipStatus = (LPDDHALVPORTCB_GETFLIPSTATUS) DvpGetVideoPortFlipStatus; } - /* FIXME VPE2 Callbacks check and setup for DirectX/ ReactX */ - //else if (IsEqualGUID(&pData->guidInfo, &GUID_VPE2Callbacks)) - //{ - // FIXME GUID_VPE2Callbacks - //} - else + if (pDvdPort.WaitForVideoPortSync) { - /* set up internal buffer */ - pDrvInfoData.dwExpectedSize = pData->dwExpectedSize; - pDrvInfoData.lpvData = pData->lpvData; - - /* We do not cover all callbacks for user mode, they are only cover by kmode */ - retValue = NtGdiDdGetDriverInfo(hDD, (PDD_GETDRIVERINFODATA)&pDrvInfoData); - - /* Setup return data */ - pData->dwActualSize = pDrvInfoData.dwActualSize; - pData->lpvData = pDrvInfoData.lpvData; - /* Windows XP never repot back the true return value, - * it only report back if we have a driver or not - * ReactOS keep this behoir to be compatible with - * Windows XP - */ - pData->ddRVal = retValue; + pUserDvdPort->WaitForVideoPortSync = (LPDDHALVPORTCB_WAITFORSYNC) DvpWaitForVideoPortSync; } + if (pDvdPort.GetVideoSignalStatus) + { + pUserDvdPort->GetVideoSignalStatus = (LPDDHALVPORTCB_GETSIGNALSTATUS) DvpGetVideoSignalStatus; + } + + if (pDvdPort.ColorControl) + { + pUserDvdPort->ColorControl = (LPDDHALVPORTCB_COLORCONTROL) DvpColorControl; + } + + /* Windows XP never repot back the true return value, + * it only report back if we have a driver or not + * ReactOS keep this behoir to be compatible with + * Windows XP + */ + pData->ddRVal = retValue; + } + + /* Color Control Callbacks check and setup for DirectX/ ReactX */ + if (IsEqualGUID(&pData->guidInfo, &GUID_ColorControlCallbacks)) + { + DDHAL_DDCOLORCONTROLCALLBACKS pColorControl; + DDHAL_DDCOLORCONTROLCALLBACKS* pUserColorControl = (DDHAL_DDCOLORCONTROLCALLBACKS *)pData->lpvData; + + /* Clear internal out buffer and set it up*/ + RtlZeroMemory(&pColorControl, DDCOLORCONTROLCALLBACKSSIZE); + pColorControl.dwSize = DDCOLORCONTROLCALLBACKSSIZE; + + /* set up internal buffer */ + pDrvInfoData.lpvData = (PVOID)&pColorControl; + pDrvInfoData.dwExpectedSize = DDCOLORCONTROLCALLBACKSSIZE ; + + /* Call win32k */ + retValue = NtGdiDdGetDriverInfo(hDD, (PDD_GETDRIVERINFODATA)&pDrvInfoData); + + pData->dwActualSize = DDCOLORCONTROLCALLBACKSSIZE; + pData->dwFlags = pDrvInfoData.dwFlags; + + pUserColorControl->dwSize = DDCOLORCONTROLCALLBACKSSIZE; + pUserColorControl->dwFlags = pUserColorControl->dwFlags; + + if (pColorControl.ColorControl != NULL) + { + pUserColorControl->ColorControl = (LPDDHALCOLORCB_COLORCONTROL) DdColorControl; + } + + /* Windows XP never repot back the true return value, + * it only report back if we have a driver or not + * ReactOS keep this behoir to be compatible with + * Windows XP + */ + pData->ddRVal = retValue; + } + + /* Misc Callbacks check and setup for DirectX/ ReactX */ + else if (IsEqualGUID(&pData->guidInfo, &GUID_MiscellaneousCallbacks)) + { + DDHAL_DDMISCELLANEOUSCALLBACKS pMisc; + DDHAL_DDMISCELLANEOUSCALLBACKS* pUserMisc = (DDHAL_DDMISCELLANEOUSCALLBACKS *)pData->lpvData; + + /* Clear internal out buffer and set it up*/ + RtlZeroMemory(&pMisc, DDMISCELLANEOUSCALLBACKSSIZE); + pMisc.dwSize = DDMISCELLANEOUSCALLBACKSSIZE; + + /* set up internal buffer */ + pDrvInfoData.lpvData = (PVOID)&pMisc; + pDrvInfoData.dwExpectedSize = DDMISCELLANEOUSCALLBACKSSIZE ; + + /* Call win32k */ + retValue = NtGdiDdGetDriverInfo(hDD, (PDD_GETDRIVERINFODATA)&pDrvInfoData); + + pData->dwActualSize = DDMISCELLANEOUSCALLBACKSSIZE; + + /* Only one callbacks are supported */ + pUserMisc->dwFlags = pMisc.dwFlags & DDHAL_MISCCB32_GETAVAILDRIVERMEMORY; + pUserMisc->GetAvailDriverMemory = (LPDDHAL_GETAVAILDRIVERMEMORY) DdGetAvailDriverMemory; + + /* This callbacks are only for win9x and theirfor it is not longer use in NT or ReactOS + * pUserMisc->UpdateNonLocalHeap; + * pUserMisc->GetHeapAlignment; + * pUserMisc->GetSysmemBltStatus; */ + + /* Windows XP never repot back the true return value, + * it only report back if we have a driver or not + * ReactOS keep this behoir to be compatible with + * Windows XP + */ + pData->ddRVal = retValue; + } + + /* Misc 2 Callbacks check and setup for DirectX/ ReactX */ + else if (IsEqualGUID(&pData->guidInfo, &GUID_Miscellaneous2Callbacks)) + { + DDHAL_DDMISCELLANEOUS2CALLBACKS pMisc; + DDHAL_DDMISCELLANEOUS2CALLBACKS* pUserMisc = (DDHAL_DDMISCELLANEOUS2CALLBACKS *)pData->lpvData; + + /* Clear internal out buffer and set it up*/ + RtlZeroMemory(&pMisc, DDMISCELLANEOUS2CALLBACKSSIZE); + pMisc.dwSize = DDMISCELLANEOUS2CALLBACKSSIZE; + + /* set up internal buffer */ + pDrvInfoData.lpvData = (PVOID)&pMisc; + pDrvInfoData.dwExpectedSize = DDMISCELLANEOUS2CALLBACKSSIZE ; + + /* Call win32k */ + retValue = NtGdiDdGetDriverInfo(hDD, (PDD_GETDRIVERINFODATA)&pDrvInfoData); + + pData->dwActualSize = DDMISCELLANEOUS2CALLBACKSSIZE; + + pUserMisc->dwFlags = pMisc.dwFlags; + + /* This functions are not documneted in MSDN for this struct, here is directx/reactx alpha blend */ + if ( pMisc.Reserved ) + { + pUserMisc->Reserved = (LPVOID) DdAlphaBlt; + } + + if ( pMisc.CreateSurfaceEx ) + { + pUserMisc->CreateSurfaceEx = (LPDDHAL_CREATESURFACEEX) DdCreateSurfaceEx; + } + + if ( pMisc.GetDriverState ) + { + pUserMisc->GetDriverState = (LPDDHAL_GETDRIVERSTATE) NtGdiDdGetDriverState; + } + + /* NOTE : pUserMisc->DestroyDDLocal is outdated and are not beign tuch */ + + /* Windows XP never repot back the true return value, + * it only report back if we have a driver or not + * ReactOS keep this behoir to be compatible with + * Windows XP + */ + pData->ddRVal = retValue; + } + + /* NT Callbacks check and setup for DirectX/ ReactX */ + else if (IsEqualGUID(&pData->guidInfo, &GUID_NTCallbacks)) + { + /* MS does not have DHAL_* version of this callbacks + * so we are force using PDD_* callbacks here + */ + DD_NTCALLBACKS pNtKernel; + PDD_NTCALLBACKS pUserNtKernel = (PDD_NTCALLBACKS)pData->lpvData; + + /* Clear internal out buffer and set it up*/ + RtlZeroMemory(&pNtKernel, sizeof(DD_NTCALLBACKS)); + pNtKernel.dwSize = sizeof(DD_NTCALLBACKS); + + /* set up internal buffer */ + pDrvInfoData.lpvData = (PVOID)&pNtKernel; + pDrvInfoData.dwExpectedSize = sizeof(DD_NTCALLBACKS) ; + + /* Call win32k */ + retValue = NtGdiDdGetDriverInfo(hDD, (PDD_GETDRIVERINFODATA)&pDrvInfoData); + + pData->dwActualSize = sizeof(DD_NTCALLBACKS); + + pUserNtKernel->dwSize = sizeof(DD_NTCALLBACKS); + pUserNtKernel->dwFlags = pNtKernel.dwFlags; + pUserNtKernel->FreeDriverMemory = 0; + + if (pNtKernel.SetExclusiveMode) + { + pUserNtKernel->SetExclusiveMode = (PDD_SETEXCLUSIVEMODE) DdSetExclusiveMode; + } + + if (pNtKernel.FlipToGDISurface) + { + pUserNtKernel->FlipToGDISurface = (PDD_FLIPTOGDISURFACE) DdFlipToGDISurface; + } + + /* Windows XP never repot back the true return value, + * it only report back if we have a driver or not + * ReactOS keep this behoir to be compatible with + * Windows XP + */ + pData->ddRVal = retValue; + } + + /* D3D Callbacks version 2 check and setup for DirectX/ ReactX */ + else if (IsEqualGUID(&pData->guidInfo, &GUID_D3DCallbacks2)) + { + // FIXME GUID_D3DCallbacks2 + } + + /* D3D Callbacks version 3 check and setup for DirectX/ ReactX */ + else if (IsEqualGUID(&pData->guidInfo, &GUID_D3DCallbacks3)) + { + // FIXME GUID_D3DCallbacks3 + } + + /* D3DParseUnknownCommand Callbacks check and setup for DirectX/ ReactX */ + else if (IsEqualGUID(&pData->guidInfo, &GUID_D3DParseUnknownCommandCallback)) + { + // FIXME GUID_D3DParseUnknownCommandCallback + } + + /* MotionComp Callbacks check and setup for DirectX/ ReactX */ + else if (IsEqualGUID(&pData->guidInfo, &GUID_MotionCompCallbacks)) + { + // FIXME GUID_MotionCompCallbacks + } + + /* FIXME VPE2 Callbacks check and setup for DirectX/ ReactX */ + //else if (IsEqualGUID(&pData->guidInfo, &GUID_VPE2Callbacks)) + //{ + // FIXME GUID_VPE2Callbacks + //} + else + { + /* set up internal buffer */ + pDrvInfoData.dwExpectedSize = pData->dwExpectedSize; + pDrvInfoData.lpvData = pData->lpvData; + + /* We do not cover all callbacks for user mode, they are only cover by kmode */ + retValue = NtGdiDdGetDriverInfo(hDD, (PDD_GETDRIVERINFODATA)&pDrvInfoData); + + /* Setup return data */ + pData->dwActualSize = pDrvInfoData.dwActualSize; + pData->lpvData = pDrvInfoData.lpvData; + /* Windows XP never repot back the true return value, + * it only report back if we have a driver or not + * ReactOS keep this behoir to be compatible with + * Windows XP + */ + pData->ddRVal = retValue; + } + return retValue; } @@ -1231,8 +1232,8 @@ DdGetDriverInfo(LPDDHAL_GETDRIVERINFODATA pData) * * D3dContextCreate */ -BOOL -WINAPI +BOOL +WINAPI D3dContextCreate(LPD3DHAL_CONTEXTCREATEDATA pdcci) { HANDLE hSurfZ = NULL; @@ -1241,8 +1242,8 @@ D3dContextCreate(LPD3DHAL_CONTEXTCREATEDATA pdcci) { hSurfZ = (HANDLE)pdcci->lpDDSZLcl->hDDSurface; } - - return NtGdiD3dContextCreate(GetDdHandle(pdcci->lpDDLcl->hDD), + + return NtGdiD3dContextCreate(GetDdHandle(pdcci->lpDDLcl->hDD), (HANDLE)pdcci->lpDDSLcl->hDDSurface, hSurfZ, (D3DNTHAL_CONTEXTCREATEI *)pdcci); @@ -1257,16 +1258,16 @@ DWORD WINAPI DdCanCreateD3DBuffer(LPDDHAL_CANCREATESURFACEDATA CanCreateD3DBuffer) { - /* - * Note : This functions are basic same, in win32k - * NtGdiDdCanCreateD3DBuffer and NtGdiDdCanCreateSurface are mergs - * toghter in win32k at end and retrurn same data, it is still sepreated - * at user mode but in kmode it is not. + /* + * Note : This functions are basic same, in win32k + * NtGdiDdCanCreateD3DBuffer and NtGdiDdCanCreateSurface are mergs + * toghter in win32k at end and retrurn same data, it is still sepreated + * at user mode but in kmode it is not. */ /* Call win32k */ return NtGdiDdCanCreateD3DBuffer(GetDdHandle(CanCreateD3DBuffer->lpDD->hDD), - (PDD_CANCREATESURFACEDATA)CanCreateD3DBuffer); + (PDD_CANCREATESURFACEDATA)CanCreateD3DBuffer); } @@ -1383,7 +1384,7 @@ DdUnlockD3D(LPDDHAL_UNLOCKDATA Unlock) { /* Call win32k */ return NtGdiDdUnlock((HANDLE)Unlock->lpDDSurface->hDDSurface, - (PDD_UNLOCKDATA)Unlock); + (PDD_UNLOCKDATA)Unlock); } @@ -1434,11 +1435,11 @@ bDDCreateSurface(LPDDRAWI_DDRAWSURFACE_LCL pSurface, /* Create the object */ pSurface->hDDSurface = (DWORD)NtGdiDdCreateSurfaceObject(GetDdHandle(pSurface->lpGbl->lpDD->hDD), - (HANDLE)pSurface->hDDSurface, - &SurfaceLocal, - &SurfaceMore, - &SurfaceGlobal, - bComplete); + (HANDLE)pSurface->hDDSurface, + &SurfaceLocal, + &SurfaceMore, + &SurfaceGlobal, + bComplete); /* Return status */ if (pSurface->hDDSurface) return TRUE; @@ -1490,7 +1491,7 @@ DdCreateDirectDrawObject(LPDDRAWI_DIRECTDRAW_GBL pDirectDrawGlobal, else { /* Using the per-process object, so create it */ - pDirectDrawGlobal->hDD = (ULONG_PTR)NtGdiDdCreateDirectDrawObject(hdc); + pDirectDrawGlobal->hDD = (ULONG_PTR)NtGdiDdCreateDirectDrawObject(hdc); /* Set the return value */ Return = pDirectDrawGlobal->hDD ? TRUE : FALSE; @@ -1518,7 +1519,7 @@ DdQueryDirectDrawObject(LPDDRAWI_DIRECTDRAW_GBL pDirectDrawGlobal, LPDDSURFACEDESC pD3dTextureFormats, LPDWORD pdwFourCC, LPVIDMEM pvmList) - { +{ PVIDEOMEMORY VidMemList = NULL; DD_HALINFO HalInfo; D3DNTHAL_CALLBACKS D3dCallbacks; @@ -1538,9 +1539,9 @@ DdQueryDirectDrawObject(LPDDRAWI_DIRECTDRAW_GBL pDirectDrawGlobal, /* Note : XP always alloc 24*sizeof(VIDEOMEMORY) of pvmlist so we change it to it */ if ( (pvmList != NULL) && - (pHalInfo->vmiData.dwNumHeaps != 0) ) + (pHalInfo->vmiData.dwNumHeaps != 0) ) { - VidMemList = (PVIDEOMEMORY) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, (sizeof(VIDEOMEMORY) * 24 ) * pHalInfo->vmiData.dwNumHeaps); + VidMemList = (PVIDEOMEMORY) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, (sizeof(VIDEOMEMORY) * 24 ) * pHalInfo->vmiData.dwNumHeaps); } @@ -1573,7 +1574,7 @@ DdQueryDirectDrawObject(LPDDRAWI_DIRECTDRAW_GBL pDirectDrawGlobal, /* Check for NT5+ D3D Data */ if ( (D3dCallbacks.dwSize != 0) && - (D3dDriverData.dwSize != 0) ) + (D3dDriverData.dwSize != 0) ) { /* Write these down */ pHalInfo->lpD3DGlobalDriverData = (ULONG_PTR)pD3dDriverData; @@ -1601,30 +1602,30 @@ DdQueryDirectDrawObject(LPDDRAWI_DIRECTDRAW_GBL pDirectDrawGlobal, pHalInfo->vmiData.dwOffscreenAlign = HalInfo.vmiData.dwOffscreenAlign; pHalInfo->vmiData.dwOverlayAlign = HalInfo.vmiData.dwOverlayAlign; pHalInfo->vmiData.dwTextureAlign = HalInfo.vmiData.dwTextureAlign; - pHalInfo->vmiData.dwZBufferAlign = HalInfo.vmiData.dwZBufferAlign; + pHalInfo->vmiData.dwZBufferAlign = HalInfo.vmiData.dwZBufferAlign; pHalInfo->vmiData.dwAlphaAlign = HalInfo.vmiData.dwAlphaAlign; pHalInfo->vmiData.dwNumHeaps = dwNumHeaps; pHalInfo->vmiData.pvmList = pvmList; - RtlCopyMemory( &pHalInfo->ddCaps, + RtlCopyMemory( &pHalInfo->ddCaps, &HalInfo.ddCaps, sizeof(DDCORECAPS )); pHalInfo->ddCaps.dwNumFourCCCodes = FourCCs; pHalInfo->lpdwFourCC = pdwFourCC; - - /* always force rope 0x1000 for hal it mean only source copy is supported */ - pHalInfo->ddCaps.dwRops[6] = 0x1000; - /* Set the HAL flags what ReactX got from the driver - * Windows XP force setting DDHALINFO_GETDRIVERINFOSET if the driver does not set it - * and ReactX doing same to keep compatible with drivers, but the driver are - * force support DdGetDriverInfo acoriding MSDN but it seam some driver do not set + /* always force rope 0x1000 for hal it mean only source copy is supported */ + pHalInfo->ddCaps.dwRops[6] = 0x1000; + + /* Set the HAL flags what ReactX got from the driver + * Windows XP force setting DDHALINFO_GETDRIVERINFOSET if the driver does not set it + * and ReactX doing same to keep compatible with drivers, but the driver are + * force support DdGetDriverInfo acoriding MSDN but it seam some driver do not set * this flag even it is being supported. that is mean. It is small hack to keep * bad driver working, that trust this is always being setting by it self at end */ - pHalInfo->dwFlags = (HalInfo.dwFlags & ~DDHALINFO_GETDRIVERINFOSET) | DDHALINFO_GETDRIVERINFOSET; + pHalInfo->dwFlags = (HalInfo.dwFlags & ~DDHALINFO_GETDRIVERINFOSET) | DDHALINFO_GETDRIVERINFOSET; pHalInfo->GetDriverInfo = (LPDDHAL_GETDRIVERINFO) DdGetDriverInfo; /* Now check if we got any DD callbacks */ @@ -1634,16 +1635,16 @@ DdQueryDirectDrawObject(LPDDRAWI_DIRECTDRAW_GBL pDirectDrawGlobal, RtlZeroMemory(pDDCallbacks, sizeof(DDHAL_DDCALLBACKS)); pDDCallbacks->dwSize = sizeof(DDHAL_DDCALLBACKS); - /* Set the flags for this structure - * Windows XP force setting DDHAL_CB32_CREATESURFACE if the driver does not set it - * and ReactX doing same to keep compatible with drivers, but the driver are - * force support pDDCallbacks acoriding MSDN but it seam some driver do not set + /* Set the flags for this structure + * Windows XP force setting DDHAL_CB32_CREATESURFACE if the driver does not set it + * and ReactX doing same to keep compatible with drivers, but the driver are + * force support pDDCallbacks acoriding MSDN but it seam some driver do not set * this flag even it is being supported. that is mean. It is small hack to keep * bad driver working, that trust this is always being setting by it self at end */ Flags = (CallbackFlags[0] & ~DDHAL_CB32_CREATESURFACE) | DDHAL_CB32_CREATESURFACE; pDDCallbacks->dwFlags = Flags; - + /* Write the always-on functions */ pDDCallbacks->CreateSurface = DdCreateSurface; @@ -1663,29 +1664,29 @@ DdQueryDirectDrawObject(LPDDRAWI_DIRECTDRAW_GBL pDirectDrawGlobal, } /* Check for DD Surface Callbacks */ - if (pDDSurfaceCallbacks) + if (pDDSurfaceCallbacks) { /* Zero the structures */ RtlZeroMemory(pDDSurfaceCallbacks, sizeof(DDHAL_DDSURFACECALLBACKS)); pDDSurfaceCallbacks->dwSize = sizeof(DDHAL_DDSURFACECALLBACKS); - /* Set the flags for this structure - * Windows XP force setting DDHAL_SURFCB32_LOCK, DDHAL_SURFCB32_UNLOCK, - * DDHAL_SURFCB32_SETCOLORKEY, DDHAL_SURFCB32_DESTROYSURFACE if the driver - * does not set it and ReactX doing same to keep compatible with drivers, - * but the driver are force support pDDSurfaceCallbacks acoriding MSDN but it seam - * some driver do not set this flag even it is being supported. that is mean. - * It is small hack to keep bad driver working, that trust this is always being + /* Set the flags for this structure + * Windows XP force setting DDHAL_SURFCB32_LOCK, DDHAL_SURFCB32_UNLOCK, + * DDHAL_SURFCB32_SETCOLORKEY, DDHAL_SURFCB32_DESTROYSURFACE if the driver + * does not set it and ReactX doing same to keep compatible with drivers, + * but the driver are force support pDDSurfaceCallbacks acoriding MSDN but it seam + * some driver do not set this flag even it is being supported. that is mean. + * It is small hack to keep bad driver working, that trust this is always being * setting by it self at end */ Flags = (CallbackFlags[1] & ~(DDHAL_SURFCB32_LOCK | DDHAL_SURFCB32_UNLOCK | DDHAL_SURFCB32_SETCOLORKEY | DDHAL_SURFCB32_DESTROYSURFACE)) | - (DDHAL_SURFCB32_LOCK | DDHAL_SURFCB32_UNLOCK | - DDHAL_SURFCB32_SETCOLORKEY | DDHAL_SURFCB32_DESTROYSURFACE); - + (DDHAL_SURFCB32_LOCK | DDHAL_SURFCB32_UNLOCK | + DDHAL_SURFCB32_SETCOLORKEY | DDHAL_SURFCB32_DESTROYSURFACE); + pDDSurfaceCallbacks->dwFlags = Flags; - + /* Write the always-on functions */ pDDSurfaceCallbacks->Lock = DdLock; pDDSurfaceCallbacks->Unlock = DdUnlock; @@ -1723,8 +1724,8 @@ DdQueryDirectDrawObject(LPDDRAWI_DIRECTDRAW_GBL pDirectDrawGlobal, } } - /* Check for DD Palette Callbacks, This interface are dead for user mode, - * only what it can support are being report back. + /* Check for DD Palette Callbacks, This interface are dead for user mode, + * only what it can support are being report back. */ if (pDDPaletteCallbacks) { @@ -1778,7 +1779,7 @@ DdQueryDirectDrawObject(LPDDRAWI_DIRECTDRAW_GBL pDirectDrawGlobal, { /* Zero the struct */ RtlZeroMemory(pD3dBufferCallbacks, sizeof(DDHAL_DDEXEBUFCALLBACKS)); - + if ( D3dBufferCallbacks.dwSize) { pD3dBufferCallbacks->dwSize = D3dBufferCallbacks.dwSize; @@ -1808,8 +1809,8 @@ DdQueryDirectDrawObject(LPDDRAWI_DIRECTDRAW_GBL pDirectDrawGlobal, { pD3dBufferCallbacks->UnlockExecuteBuffer = (LPDDHALEXEBUFCB_UNLOCKEXEBUF) DdUnlockD3D; } - - } + + } } /* FIXME VidMemList */ @@ -1820,7 +1821,7 @@ cleanup: HeapFree(GetProcessHeap(), 0, VidMemList); } - return retVal; + return retVal; } /* @@ -2032,7 +2033,7 @@ ULONG WINAPI DdQueryDisplaySettingsUniqueness() { - return GdiSharedHandleTable->flDeviceUniq; + return GdiSharedHandleTable->flDeviceUniq; } /* diff --git a/reactos/dll/win32/gdi32/misc/heap.c b/reactos/dll/win32/gdi32/misc/heap.c index 14c10fc94ca..5c2f7bb3d19 100644 --- a/reactos/dll/win32/gdi32/misc/heap.c +++ b/reactos/dll/win32/gdi32/misc/heap.c @@ -35,36 +35,36 @@ HANDLE hProcessHeap = NULL; PVOID HEAP_alloc ( DWORD len ) { - /* make sure hProcessHeap gets initialized by GdiProcessSetup before we get here */ - assert(hProcessHeap); - return RtlAllocateHeap ( hProcessHeap, 0, len ); + /* make sure hProcessHeap gets initialized by GdiProcessSetup before we get here */ + assert(hProcessHeap); + return RtlAllocateHeap ( hProcessHeap, 0, len ); } NTSTATUS HEAP_strdupA2W ( LPWSTR* ppszW, LPCSTR lpszA ) { - ULONG len; - NTSTATUS Status; + ULONG len; + NTSTATUS Status; - *ppszW = NULL; - if ( !lpszA ) - return STATUS_SUCCESS; - len = lstrlenA(lpszA); + *ppszW = NULL; + if ( !lpszA ) + return STATUS_SUCCESS; + len = lstrlenA(lpszA); - *ppszW = HEAP_alloc ( (len+1) * sizeof(WCHAR) ); - if ( !*ppszW ) - return STATUS_NO_MEMORY; - Status = RtlMultiByteToUnicodeN ( *ppszW, len*sizeof(WCHAR), NULL, (PCHAR)lpszA, len ); - (*ppszW)[len] = L'\0'; - return Status; + *ppszW = HEAP_alloc ( (len+1) * sizeof(WCHAR) ); + if ( !*ppszW ) + return STATUS_NO_MEMORY; + Status = RtlMultiByteToUnicodeN ( *ppszW, len*sizeof(WCHAR), NULL, (PCHAR)lpszA, len ); + (*ppszW)[len] = L'\0'; + return Status; } VOID HEAP_free ( LPVOID memory ) { - /* make sure hProcessHeap gets initialized by GdiProcessSetup before we get here */ - assert(hProcessHeap); + /* make sure hProcessHeap gets initialized by GdiProcessSetup before we get here */ + assert(hProcessHeap); - RtlFreeHeap ( hProcessHeap, 0, memory ); + RtlFreeHeap ( hProcessHeap, 0, memory ); } diff --git a/reactos/dll/win32/gdi32/misc/misc.c b/reactos/dll/win32/gdi32/misc/misc.c index 3a3ce0ac584..408a658d72e 100644 --- a/reactos/dll/win32/gdi32/misc/misc.c +++ b/reactos/dll/win32/gdi32/misc/misc.c @@ -39,36 +39,36 @@ DWORD GDI_BatchLimit = 1; BOOL WINAPI GdiAlphaBlend( - HDC hDCDst, - int DstX, - int DstY, - int DstCx, - int DstCy, - HDC hDCSrc, - int SrcX, - int SrcY, - int SrcCx, - int SrcCy, - BLENDFUNCTION BlendFunction - ) + HDC hDCDst, + int DstX, + int DstY, + int DstCx, + int DstCy, + HDC hDCSrc, + int SrcX, + int SrcY, + int SrcCx, + int SrcCy, + BLENDFUNCTION BlendFunction +) { - if ( hDCSrc == NULL ) return FALSE; + if ( hDCSrc == NULL ) return FALSE; - if (GDI_HANDLE_GET_TYPE(hDCSrc) == GDI_OBJECT_TYPE_METADC) return FALSE; + if (GDI_HANDLE_GET_TYPE(hDCSrc) == GDI_OBJECT_TYPE_METADC) return FALSE; - return NtGdiAlphaBlend( - hDCDst, - DstX, - DstY, - DstCx, - DstCy, - hDCSrc, - SrcX, - SrcY, - SrcCx, - SrcCy, + return NtGdiAlphaBlend( + hDCDst, + DstX, + DstY, + DstCx, + DstCy, + hDCSrc, + SrcX, + SrcY, + SrcCx, + SrcCy, BlendFunction, - 0 ); + 0 ); } /* @@ -89,7 +89,7 @@ GdiFixUpHandle(HGDIOBJ hGdiObj) Entry = GdiHandleTable + GDI_HANDLE_GET_INDEX(hGdiObj); - /* Rebuild handle for Object */ + /* Rebuild handle for Object */ return hGdiObj = (HGDIOBJ)(((LONG_PTR)(hGdiObj)) | (Entry->Type << GDI_ENTRY_UPPER_SHIFT)); } @@ -100,99 +100,99 @@ PVOID WINAPI GdiQueryTable(VOID) { - return (PVOID)GdiHandleTable; + return (PVOID)GdiHandleTable; } BOOL GdiIsHandleValid(HGDIOBJ hGdiObj) { - PGDI_TABLE_ENTRY Entry = GdiHandleTable + GDI_HANDLE_GET_INDEX(hGdiObj); + PGDI_TABLE_ENTRY Entry = GdiHandleTable + GDI_HANDLE_GET_INDEX(hGdiObj); // We are only looking for TYPE not the rest here, and why is FullUnique filled up with CRAP!? // DPRINT1("FullUnique -> %x\n", Entry->FullUnique); - if((Entry->Type & GDI_ENTRY_BASETYPE_MASK) != 0 && - ( (Entry->Type << GDI_ENTRY_UPPER_SHIFT) & GDI_HANDLE_TYPE_MASK ) == - GDI_HANDLE_GET_TYPE(hGdiObj)) - { - HANDLE pid = (HANDLE)((ULONG_PTR)Entry->ProcessId & ~0x1); - if(pid == NULL || pid == CurrentProcessId) + if((Entry->Type & GDI_ENTRY_BASETYPE_MASK) != 0 && + ( (Entry->Type << GDI_ENTRY_UPPER_SHIFT) & GDI_HANDLE_TYPE_MASK ) == + GDI_HANDLE_GET_TYPE(hGdiObj)) { - return TRUE; + HANDLE pid = (HANDLE)((ULONG_PTR)Entry->ProcessId & ~0x1); + if(pid == NULL || pid == CurrentProcessId) + { + return TRUE; + } } - } - return FALSE; + return FALSE; } BOOL GdiGetHandleUserData(HGDIOBJ hGdiObj, DWORD ObjectType, PVOID *UserData) { - PGDI_TABLE_ENTRY Entry = GdiHandleTable + GDI_HANDLE_GET_INDEX(hGdiObj); - if((Entry->Type & GDI_ENTRY_BASETYPE_MASK) == ObjectType && - ( (Entry->Type << GDI_ENTRY_UPPER_SHIFT) & GDI_HANDLE_TYPE_MASK ) == - GDI_HANDLE_GET_TYPE(hGdiObj)) - { - HANDLE pid = (HANDLE)((ULONG_PTR)Entry->ProcessId & ~0x1); - if(pid == NULL || pid == CurrentProcessId) + PGDI_TABLE_ENTRY Entry = GdiHandleTable + GDI_HANDLE_GET_INDEX(hGdiObj); + if((Entry->Type & GDI_ENTRY_BASETYPE_MASK) == ObjectType && + ( (Entry->Type << GDI_ENTRY_UPPER_SHIFT) & GDI_HANDLE_TYPE_MASK ) == + GDI_HANDLE_GET_TYPE(hGdiObj)) { - // - // Need to test if we have Read & Write access to the VM address space. - // - BOOL Result = TRUE; - if(Entry->UserData) - { - volatile CHAR *Current = (volatile CHAR*)Entry->UserData; - _SEH2_TRY - { - *Current = *Current; - } - _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) - { - Result = FALSE; - } - _SEH2_END - } - else - Result = FALSE; // Can not be zero. - if (Result) *UserData = Entry->UserData; - return Result; + HANDLE pid = (HANDLE)((ULONG_PTR)Entry->ProcessId & ~0x1); + if(pid == NULL || pid == CurrentProcessId) + { + // + // Need to test if we have Read & Write access to the VM address space. + // + BOOL Result = TRUE; + if(Entry->UserData) + { + volatile CHAR *Current = (volatile CHAR*)Entry->UserData; + _SEH2_TRY + { + *Current = *Current; + } + _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) + { + Result = FALSE; + } + _SEH2_END + } + else + Result = FALSE; // Can not be zero. + if (Result) *UserData = Entry->UserData; + return Result; + } } - } - SetLastError(ERROR_INVALID_PARAMETER); - return FALSE; + SetLastError(ERROR_INVALID_PARAMETER); + return FALSE; } PLDC FASTCALL GdiGetLDC(HDC hDC) { - PDC_ATTR Dc_Attr; - PGDI_TABLE_ENTRY Entry = GdiHandleTable + GDI_HANDLE_GET_INDEX((HGDIOBJ) hDC); - HANDLE pid = (HANDLE)((ULONG_PTR)Entry->ProcessId & ~0x1); - // Don't check the mask, just the object type. - if ( Entry->ObjectType == GDIObjType_DC_TYPE && - (pid == NULL || pid == CurrentProcessId) ) - { - BOOL Result = TRUE; - if (Entry->UserData) - { - volatile CHAR *Current = (volatile CHAR*)Entry->UserData; - _SEH2_TRY + PDC_ATTR Dc_Attr; + PGDI_TABLE_ENTRY Entry = GdiHandleTable + GDI_HANDLE_GET_INDEX((HGDIOBJ) hDC); + HANDLE pid = (HANDLE)((ULONG_PTR)Entry->ProcessId & ~0x1); + // Don't check the mask, just the object type. + if ( Entry->ObjectType == GDIObjType_DC_TYPE && + (pid == NULL || pid == CurrentProcessId) ) + { + BOOL Result = TRUE; + if (Entry->UserData) { - *Current = *Current; + volatile CHAR *Current = (volatile CHAR*)Entry->UserData; + _SEH2_TRY + { + *Current = *Current; + } + _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) + { + Result = FALSE; + } + _SEH2_END } - _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) - { - Result = FALSE; - } - _SEH2_END - } - else - Result = FALSE; + else + Result = FALSE; - if (Result) - { - Dc_Attr = (PDC_ATTR)Entry->UserData; - return Dc_Attr->pvLDC; - } - } - return NULL; + if (Result) + { + Dc_Attr = (PDC_ATTR)Entry->UserData; + return Dc_Attr->pvLDC; + } + } + return NULL; } VOID GdiSAPCallback(PLDC pldc) @@ -207,8 +207,8 @@ VOID GdiSAPCallback(PLDC pldc) if ( !pldc->pAbortProc(pldc->hDC, 0) ) { - CancelDC(pldc->hDC); - AbortDoc(pldc->hDC); + CancelDC(pldc->hDC); + AbortDoc(pldc->hDC); } } @@ -222,7 +222,7 @@ GdiSetBatchLimit(DWORD Limit) DWORD OldLimit = GDI_BatchLimit; if ( (!Limit) || - (Limit >= GDI_BATCH_LIMIT)) + (Limit >= GDI_BATCH_LIMIT)) { return Limit; } @@ -289,40 +289,40 @@ HGDIOBJ FASTCALL hGetPEBHandle(HANDLECACHETYPE Type, COLORREF cr) { - int Number; - HANDLE Lock; - HGDIOBJ Handle = NULL; + int Number; + HANDLE Lock; + HGDIOBJ Handle = NULL; - Lock = InterlockedCompareExchangePointer( (PVOID*)&GdiHandleCache->ulLock, - NtCurrentTeb(), - NULL ); - - if (Lock) return Handle; + Lock = InterlockedCompareExchangePointer( (PVOID*)&GdiHandleCache->ulLock, + NtCurrentTeb(), + NULL ); - Number = GdiHandleCache->ulNumHandles[Type]; + if (Lock) return Handle; - if ( Number && Number <= CACHE_REGION_ENTRIES ) - { - if ( Type == hctRegionHandle) - { - PRGN_ATTR pRgn_Attr; - HGDIOBJ *hPtr; - hPtr = GdiHandleCache->Handle + CACHE_BRUSH_ENTRIES+CACHE_PEN_ENTRIES; - Handle = hPtr[Number - 1]; + Number = GdiHandleCache->ulNumHandles[Type]; - if (GdiGetHandleUserData( Handle, GDI_OBJECT_TYPE_REGION, (PVOID) &pRgn_Attr)) - { - if (pRgn_Attr->AttrFlags & ATTR_CACHED) + if ( Number && Number <= CACHE_REGION_ENTRIES ) + { + if ( Type == hctRegionHandle) + { + PRGN_ATTR pRgn_Attr; + HGDIOBJ *hPtr; + hPtr = GdiHandleCache->Handle + CACHE_BRUSH_ENTRIES+CACHE_PEN_ENTRIES; + Handle = hPtr[Number - 1]; + + if (GdiGetHandleUserData( Handle, GDI_OBJECT_TYPE_REGION, (PVOID) &pRgn_Attr)) { - DPRINT("Get Handle! Count %d PEB 0x%x\n", GdiHandleCache->ulNumHandles[Type], NtCurrentTeb()->ProcessEnvironmentBlock); - pRgn_Attr->AttrFlags &= ~ATTR_CACHED; - hPtr[Number - 1] = NULL; - GdiHandleCache->ulNumHandles[Type]--; + if (pRgn_Attr->AttrFlags & ATTR_CACHED) + { + DPRINT("Get Handle! Count %d PEB 0x%x\n", GdiHandleCache->ulNumHandles[Type], NtCurrentTeb()->ProcessEnvironmentBlock); + pRgn_Attr->AttrFlags &= ~ATTR_CACHED; + hPtr[Number - 1] = NULL; + GdiHandleCache->ulNumHandles[Type]--; + } } - } - } - } - (void)InterlockedExchangePointer((PVOID*)&GdiHandleCache->ulLock, Lock); - return Handle; + } + } + (void)InterlockedExchangePointer((PVOID*)&GdiHandleCache->ulLock, Lock); + return Handle; } diff --git a/reactos/dll/win32/gdi32/misc/stubs.c b/reactos/dll/win32/gdi32/misc/stubs.c index 5dc10b33284..42a3415d22f 100644 --- a/reactos/dll/win32/gdi32/misc/stubs.c +++ b/reactos/dll/win32/gdi32/misc/stubs.c @@ -48,30 +48,30 @@ BOOL WINAPI CancelDC(HDC hDC) { - PDC_ATTR pDc_Attr; + PDC_ATTR pDc_Attr; - if (GDI_HANDLE_GET_TYPE(hDC) != GDI_OBJECT_TYPE_DC && - GDI_HANDLE_GET_TYPE(hDC) != GDI_OBJECT_TYPE_METADC ) - { - PLDC pLDC = GdiGetLDC(hDC); - if ( !pLDC ) - { - SetLastError(ERROR_INVALID_HANDLE); - return FALSE; - } - /* If a document has started set it to die. */ - if (pLDC->Flags & LDC_INIT_DOCUMENT) pLDC->Flags |= LDC_KILL_DOCUMENT; + if (GDI_HANDLE_GET_TYPE(hDC) != GDI_OBJECT_TYPE_DC && + GDI_HANDLE_GET_TYPE(hDC) != GDI_OBJECT_TYPE_METADC ) + { + PLDC pLDC = GdiGetLDC(hDC); + if ( !pLDC ) + { + SetLastError(ERROR_INVALID_HANDLE); + return FALSE; + } + /* If a document has started set it to die. */ + if (pLDC->Flags & LDC_INIT_DOCUMENT) pLDC->Flags |= LDC_KILL_DOCUMENT; - return NtGdiCancelDC(hDC); - } + return NtGdiCancelDC(hDC); + } - if (GdiGetHandleUserData((HGDIOBJ) hDC, GDI_OBJECT_TYPE_DC, (PVOID) &pDc_Attr)) - { - pDc_Attr->ulDirty_ &= ~DC_PLAYMETAFILE; - return TRUE; - } + if (GdiGetHandleUserData((HGDIOBJ) hDC, GDI_OBJECT_TYPE_DC, (PVOID) &pDc_Attr)) + { + pDc_Attr->ulDirty_ &= ~DC_PLAYMETAFILE; + return TRUE; + } - return FALSE; + return FALSE; } @@ -85,25 +85,25 @@ DrawEscape(HDC hDC, INT cbInput, LPCSTR lpszInData) { - if (GDI_HANDLE_GET_TYPE(hDC) == GDI_OBJECT_TYPE_DC) - return NtGdiDrawEscape(hDC, nEscape, cbInput, (LPSTR) lpszInData); + if (GDI_HANDLE_GET_TYPE(hDC) == GDI_OBJECT_TYPE_DC) + return NtGdiDrawEscape(hDC, nEscape, cbInput, (LPSTR) lpszInData); - if (GDI_HANDLE_GET_TYPE(hDC) != GDI_OBJECT_TYPE_METADC) - { - PLDC pLDC = GdiGetLDC(hDC); - if ( pLDC ) - { - if (pLDC->Flags & LDC_META_PRINT) + if (GDI_HANDLE_GET_TYPE(hDC) != GDI_OBJECT_TYPE_METADC) + { + PLDC pLDC = GdiGetLDC(hDC); + if ( pLDC ) { + if (pLDC->Flags & LDC_META_PRINT) + { // if (nEscape != QUERYESCSUPPORT) // return EMFDRV_WriteEscape(hDC, nEscape, cbInput, lpszInData, EMR_DRAWESCAPE); - return NtGdiDrawEscape(hDC, nEscape, cbInput, (LPSTR) lpszInData); + return NtGdiDrawEscape(hDC, nEscape, cbInput, (LPSTR) lpszInData); + } } - } - SetLastError(ERROR_INVALID_HANDLE); - } - return 0; + SetLastError(ERROR_INVALID_HANDLE); + } + return 0; } @@ -125,17 +125,17 @@ EnumObjects(HDC hdc, switch (nObjectType) { - case OBJ_BRUSH: - Size = sizeof(LOGBRUSH); - break; + case OBJ_BRUSH: + Size = sizeof(LOGBRUSH); + break; - case OBJ_PEN: - Size = sizeof(LOGPEN); - break; + case OBJ_PEN: + Size = sizeof(LOGPEN); + break; - default: - SetLastError(ERROR_INVALID_PARAMETER); - return 0; + default: + SetLastError(ERROR_INVALID_PARAMETER); + return 0; } ObjectsCount = NtGdiEnumObjects(hdc, nObjectType, 0, NULL); @@ -172,10 +172,10 @@ EnumObjects(HDC hdc, UINT WINAPI GetBoundsRect( - HDC hdc, - LPRECT lprcBounds, - UINT flags - ) + HDC hdc, + LPRECT lprcBounds, + UINT flags +) { return NtGdiGetBoundsRect(hdc,lprcBounds,flags & DCB_RESET); } @@ -186,14 +186,14 @@ GetBoundsRect( UINT WINAPI GetMetaFileBitsEx( - HMETAFILE a0, - UINT a1, - LPVOID a2 - ) + HMETAFILE a0, + UINT a1, + LPVOID a2 +) { - UNIMPLEMENTED; - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return 0; + UNIMPLEMENTED; + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return 0; } /* @@ -202,13 +202,13 @@ GetMetaFileBitsEx( BOOL WINAPI PlayMetaFile( - HDC a0, - HMETAFILE a1 - ) + HDC a0, + HMETAFILE a1 +) { - UNIMPLEMENTED; - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return FALSE; + UNIMPLEMENTED; + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return FALSE; } /* @@ -230,24 +230,24 @@ SetBoundsRect(HDC hdc, HMETAFILE WINAPI SetMetaFileBitsEx( - UINT size, - CONST BYTE *lpData - ) + UINT size, + CONST BYTE *lpData +) { const METAHEADER *mh_in = (const METAHEADER *)lpData; if (size & 1) return 0; if (!size || mh_in->mtType != METAFILE_MEMORY || mh_in->mtVersion != 0x300 || - mh_in->mtHeaderSize != sizeof(METAHEADER) / 2) + mh_in->mtHeaderSize != sizeof(METAHEADER) / 2) { SetLastError(ERROR_INVALID_DATA); return 0; } - UNIMPLEMENTED; - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return 0; + UNIMPLEMENTED; + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return 0; } /* @@ -256,15 +256,15 @@ SetMetaFileBitsEx( BOOL WINAPI PlayMetaFileRecord( - HDC a0, - LPHANDLETABLE a1, - LPMETARECORD a2, - UINT a3 - ) + HDC a0, + LPHANDLETABLE a1, + LPMETARECORD a2, + UINT a3 +) { - UNIMPLEMENTED; - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return FALSE; + UNIMPLEMENTED; + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return FALSE; } @@ -274,15 +274,15 @@ PlayMetaFileRecord( BOOL WINAPI EnumMetaFile( - HDC a0, - HMETAFILE a1, - MFENUMPROC a2, - LPARAM a3 - ) + HDC a0, + HMETAFILE a1, + MFENUMPROC a2, + LPARAM a3 +) { - UNIMPLEMENTED; - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return FALSE; + UNIMPLEMENTED; + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return FALSE; } /* @@ -291,12 +291,12 @@ EnumMetaFile( BOOL WINAPI DeleteEnhMetaFile( - HENHMETAFILE a0 - ) + HENHMETAFILE a0 +) { - UNIMPLEMENTED; - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return FALSE; + UNIMPLEMENTED; + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return FALSE; } /* @@ -305,12 +305,12 @@ DeleteEnhMetaFile( BOOL WINAPI EnumEnhMetaFile( - HDC hdc, - HENHMETAFILE hmf, - ENHMFENUMPROC callback, - LPVOID data, - CONST RECT *lpRect - ) + HDC hdc, + HENHMETAFILE hmf, + ENHMFENUMPROC callback, + LPVOID data, + CONST RECT *lpRect +) { if(!lpRect && hdc) { @@ -318,9 +318,9 @@ EnumEnhMetaFile( return FALSE; } - UNIMPLEMENTED; - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return FALSE; + UNIMPLEMENTED; + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return FALSE; } /* @@ -329,14 +329,14 @@ EnumEnhMetaFile( UINT WINAPI GetEnhMetaFileBits( - HENHMETAFILE a0, - UINT a1, - LPBYTE a2 - ) + HENHMETAFILE a0, + UINT a1, + LPBYTE a2 +) { - UNIMPLEMENTED; - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return 0; + UNIMPLEMENTED; + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return 0; } @@ -346,14 +346,14 @@ GetEnhMetaFileBits( UINT WINAPI GetEnhMetaFileHeader( - HENHMETAFILE a0, - UINT a1, - LPENHMETAHEADER a2 - ) + HENHMETAFILE a0, + UINT a1, + LPENHMETAHEADER a2 +) { - UNIMPLEMENTED; - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return 0; + UNIMPLEMENTED; + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return 0; } /* @@ -362,14 +362,14 @@ GetEnhMetaFileHeader( UINT WINAPI GetEnhMetaFilePaletteEntries( - HENHMETAFILE a0, - UINT a1, - LPPALETTEENTRY a2 - ) + HENHMETAFILE a0, + UINT a1, + LPPALETTEENTRY a2 +) { - UNIMPLEMENTED; - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return 0; + UNIMPLEMENTED; + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return 0; } /* @@ -378,16 +378,16 @@ GetEnhMetaFilePaletteEntries( UINT WINAPI GetWinMetaFileBits( - HENHMETAFILE a0, - UINT a1, - LPBYTE a2, - INT a3, - HDC a4 - ) + HENHMETAFILE a0, + UINT a1, + LPBYTE a2, + INT a3, + HDC a4 +) { - UNIMPLEMENTED; - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return 0; + UNIMPLEMENTED; + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return 0; } @@ -397,14 +397,14 @@ GetWinMetaFileBits( BOOL WINAPI PlayEnhMetaFile( - HDC a0, - HENHMETAFILE a1, - CONST RECT *a2 - ) + HDC a0, + HENHMETAFILE a1, + CONST RECT *a2 +) { - UNIMPLEMENTED; - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return FALSE; + UNIMPLEMENTED; + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return FALSE; } @@ -414,15 +414,15 @@ PlayEnhMetaFile( BOOL WINAPI PlayEnhMetaFileRecord( - HDC a0, - LPHANDLETABLE a1, - CONST ENHMETARECORD *a2, - UINT a3 - ) + HDC a0, + LPHANDLETABLE a1, + CONST ENHMETARECORD *a2, + UINT a3 +) { - UNIMPLEMENTED; - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return FALSE; + UNIMPLEMENTED; + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return FALSE; } @@ -432,13 +432,13 @@ PlayEnhMetaFileRecord( HENHMETAFILE WINAPI SetEnhMetaFileBits( - UINT a0, - CONST BYTE *a1 - ) + UINT a0, + CONST BYTE *a1 +) { - UNIMPLEMENTED; - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return 0; + UNIMPLEMENTED; + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return 0; } @@ -448,14 +448,14 @@ SetEnhMetaFileBits( HENHMETAFILE WINAPI SetWinMetaFileBits( - UINT a0, - CONST BYTE *a1, - HDC a2, - CONST METAFILEPICT *a3) + UINT a0, + CONST BYTE *a1, + HDC a2, + CONST METAFILEPICT *a3) { - UNIMPLEMENTED; - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return 0; + UNIMPLEMENTED; + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return 0; } @@ -465,27 +465,28 @@ SetWinMetaFileBits( BOOL WINAPI GdiComment( - HDC hDC, - UINT bytes, - CONST BYTE *buffer - ) + HDC hDC, + UINT bytes, + CONST BYTE *buffer +) { #if 0 - if (GDI_HANDLE_GET_TYPE(hDC) == GDI_OBJECT_TYPE_EMF) - { - PLDC pLDC = GdiGetLDC(hDC); - if ( !pLDC ) - { - SetLastError(ERROR_INVALID_HANDLE); - return FALSE; - } - if (pLDC->iType == LDC_EMFLDC) - { // Wine port - return EMFDRV_GdiComment( hDC, bytes, buffer ); - } - } + if (GDI_HANDLE_GET_TYPE(hDC) == GDI_OBJECT_TYPE_EMF) + { + PLDC pLDC = GdiGetLDC(hDC); + if ( !pLDC ) + { + SetLastError(ERROR_INVALID_HANDLE); + return FALSE; + } + if (pLDC->iType == LDC_EMFLDC) + { + // Wine port + return EMFDRV_GdiComment( hDC, bytes, buffer ); + } + } #endif - return FALSE; + return FALSE; } @@ -495,13 +496,13 @@ GdiComment( BOOL WINAPI SetColorAdjustment( - HDC hdc, - CONST COLORADJUSTMENT *a1 - ) + HDC hdc, + CONST COLORADJUSTMENT *a1 +) { - UNIMPLEMENTED; - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return FALSE; + UNIMPLEMENTED; + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return FALSE; } /* @@ -512,19 +513,19 @@ WINAPI UnrealizeObject(HGDIOBJ hgdiobj) { BOOL retValue = TRUE; -/* - Win 2k Graphics API, Black Book. by coriolis.com - Page 62, Note that Steps 3, 5, and 6 are not required for Windows NT(tm) - and Windows 2000(tm). + /* + Win 2k Graphics API, Black Book. by coriolis.com + Page 62, Note that Steps 3, 5, and 6 are not required for Windows NT(tm) + and Windows 2000(tm). - Step 5. UnrealizeObject(hTrackBrush); - */ -/* - msdn.microsoft.com, - "Windows 2000/XP: If hgdiobj is a brush, UnrealizeObject does nothing, - and the function returns TRUE. Use SetBrushOrgEx to set the origin of - a brush." - */ + Step 5. UnrealizeObject(hTrackBrush); + */ + /* + msdn.microsoft.com, + "Windows 2000/XP: If hgdiobj is a brush, UnrealizeObject does nothing, + and the function returns TRUE. Use SetBrushOrgEx to set the origin of + a brush." + */ if (GDI_HANDLE_GET_TYPE(hgdiobj) != GDI_OBJECT_TYPE_BRUSH) { retValue = NtGdiUnrealizeObject(hgdiobj); @@ -552,18 +553,18 @@ GdiFlush() int WINAPI SetICMMode( - HDC hdc, - int iEnableICM - ) + HDC hdc, + int iEnableICM +) { /*FIXME: Assume that ICM is always off, and cannot be turned on */ if (iEnableICM == ICM_OFF) return ICM_OFF; if (iEnableICM == ICM_ON) return 0; if (iEnableICM == ICM_QUERY) return ICM_OFF; - UNIMPLEMENTED; - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return 0; + UNIMPLEMENTED; + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return 0; } @@ -573,15 +574,15 @@ SetICMMode( BOOL WINAPI CheckColorsInGamut( - HDC a0, - LPVOID a1, - LPVOID a2, - DWORD a3 - ) + HDC a0, + LPVOID a1, + LPVOID a2, + DWORD a3 +) { - UNIMPLEMENTED; - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return FALSE; + UNIMPLEMENTED; + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return FALSE; } @@ -635,14 +636,14 @@ SetDeviceGammaRamp(HDC hdc, BOOL WINAPI ColorMatchToTarget( - HDC a0, - HDC a1, - DWORD a2 - ) + HDC a0, + HDC a1, + DWORD a2 +) { - UNIMPLEMENTED; - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return FALSE; + UNIMPLEMENTED; + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return FALSE; } /* === AFTER THIS POINT I GUESS... ========= @@ -656,13 +657,13 @@ ColorMatchToTarget( DWORD WINAPI IsValidEnhMetaRecord( - DWORD a0, - DWORD a1 - ) + DWORD a0, + DWORD a1 +) { - UNIMPLEMENTED; - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return 0; + UNIMPLEMENTED; + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return 0; } @@ -672,15 +673,15 @@ IsValidEnhMetaRecord( DWORD WINAPI IsValidEnhMetaRecordOffExt( - DWORD a0, - DWORD a1, - DWORD a2, - DWORD a3 - ) + DWORD a0, + DWORD a1, + DWORD a2, + DWORD a3 +) { - UNIMPLEMENTED; - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return 0; + UNIMPLEMENTED; + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return 0; } @@ -690,18 +691,18 @@ IsValidEnhMetaRecordOffExt( DWORD WINAPI GetGlyphOutlineWow( - DWORD a0, - DWORD a1, - DWORD a2, - DWORD a3, - DWORD a4, - DWORD a5, - DWORD a6 - ) + DWORD a0, + DWORD a1, + DWORD a2, + DWORD a3, + DWORD a4, + DWORD a5, + DWORD a6 +) { - UNIMPLEMENTED; - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return 0; + UNIMPLEMENTED; + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return 0; } /* @@ -710,17 +711,17 @@ GetGlyphOutlineWow( DWORD WINAPI gdiPlaySpoolStream( - DWORD a0, - DWORD a1, - DWORD a2, - DWORD a3, - DWORD a4, - DWORD a5 - ) + DWORD a0, + DWORD a1, + DWORD a2, + DWORD a3, + DWORD a4, + DWORD a5 +) { - UNIMPLEMENTED; - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return 0; + UNIMPLEMENTED; + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return 0; } /* @@ -729,18 +730,18 @@ gdiPlaySpoolStream( HANDLE WINAPI AddFontMemResourceEx( - PVOID pbFont, - DWORD cbFont, - PVOID pdv, - DWORD *pcFonts + PVOID pbFont, + DWORD cbFont, + PVOID pdv, + DWORD *pcFonts ) { - if ( pbFont && cbFont && pcFonts) - { - return NtGdiAddFontMemResourceEx(pbFont, cbFont, NULL, 0, pcFonts); - } - SetLastError(ERROR_INVALID_PARAMETER); - return NULL; + if ( pbFont && cbFont && pcFonts) + { + return NtGdiAddFontMemResourceEx(pbFont, cbFont, NULL, 0, pcFonts); + } + SetLastError(ERROR_INVALID_PARAMETER); + return NULL; } /* @@ -749,13 +750,13 @@ AddFontMemResourceEx( int WINAPI AddFontResourceTracking( - LPCSTR lpString, - int unknown + LPCSTR lpString, + int unknown ) { - UNIMPLEMENTED; - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return 0; + UNIMPLEMENTED; + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return 0; } @@ -767,9 +768,9 @@ HBITMAP WINAPI ClearBitmapAttributes(HBITMAP hbm, DWORD dwFlags) { - UNIMPLEMENTED; - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return 0; + UNIMPLEMENTED; + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return 0; } /* @@ -779,9 +780,9 @@ HBRUSH WINAPI ClearBrushAttributes(HBRUSH hbm, DWORD dwFlags) { - UNIMPLEMENTED; - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return 0; + UNIMPLEMENTED; + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return 0; } /* @@ -791,9 +792,9 @@ BOOL WINAPI ColorCorrectPalette(HDC hDC,HPALETTE hPalette,DWORD dwFirstEntry,DWORD dwNumOfEntries) { - UNIMPLEMENTED; - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return 0; + UNIMPLEMENTED; + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return 0; } /* @@ -803,9 +804,9 @@ BOOL WINAPI GdiArtificialDecrementDriver(LPWSTR pDriverName,BOOL unknown) { - UNIMPLEMENTED; - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return 0; + UNIMPLEMENTED; + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return 0; } /* @@ -815,10 +816,10 @@ BOOL WINAPI GdiCleanCacheDC(HDC hdc) { - if (GDI_HANDLE_GET_TYPE(hdc) == GDILoObjType_LO_DC_TYPE) - return TRUE; - SetLastError(ERROR_INVALID_HANDLE); - return FALSE; + if (GDI_HANDLE_GET_TYPE(hdc) == GDILoObjType_LO_DC_TYPE) + return TRUE; + SetLastError(ERROR_INVALID_HANDLE); + return FALSE; } /* @@ -828,20 +829,20 @@ HDC WINAPI GdiConvertAndCheckDC(HDC hdc) { - PLDC pldc; - ULONG hType = GDI_HANDLE_GET_TYPE(hdc); - if (hType == GDILoObjType_LO_DC_TYPE || hType == GDILoObjType_LO_METADC16_TYPE) - return hdc; - pldc = GdiGetLDC(hdc); - if (pldc) - { - if (pldc->Flags & LDC_SAPCALLBACK) GdiSAPCallback(pldc); - if (pldc->Flags & LDC_KILL_DOCUMENT) return NULL; - if (pldc->Flags & LDC_STARTPAGE) StartPage(hdc); - return hdc; - } - SetLastError(ERROR_INVALID_HANDLE); - return NULL; + PLDC pldc; + ULONG hType = GDI_HANDLE_GET_TYPE(hdc); + if (hType == GDILoObjType_LO_DC_TYPE || hType == GDILoObjType_LO_METADC16_TYPE) + return hdc; + pldc = GdiGetLDC(hdc); + if (pldc) + { + if (pldc->Flags & LDC_SAPCALLBACK) GdiSAPCallback(pldc); + if (pldc->Flags & LDC_KILL_DOCUMENT) return NULL; + if (pldc->Flags & LDC_STARTPAGE) StartPage(hdc); + return hdc; + } + SetLastError(ERROR_INVALID_HANDLE); + return NULL; } /* @@ -875,22 +876,22 @@ BOOL WINAPI GdiIsMetaFileDC(HDC hDC) { - if (GDI_HANDLE_GET_TYPE(hDC) != GDI_OBJECT_TYPE_DC) - { - if (GDI_HANDLE_GET_TYPE(hDC) == GDI_OBJECT_TYPE_METADC) - return TRUE; - else - { - PLDC pLDC = GdiGetLDC(hDC); - if ( !pLDC ) + if (GDI_HANDLE_GET_TYPE(hDC) != GDI_OBJECT_TYPE_DC) + { + if (GDI_HANDLE_GET_TYPE(hDC) == GDI_OBJECT_TYPE_METADC) + return TRUE; + else { - SetLastError(ERROR_INVALID_HANDLE); - return FALSE; + PLDC pLDC = GdiGetLDC(hDC); + if ( !pLDC ) + { + SetLastError(ERROR_INVALID_HANDLE); + return FALSE; + } + if ( pLDC->iType == LDC_EMFLDC) return TRUE; } - if ( pLDC->iType == LDC_EMFLDC) return TRUE; - } - } - return FALSE; + } + return FALSE; } /* @@ -901,22 +902,22 @@ WINAPI GdiIsMetaPrintDC(HDC hDC) { - if (GDI_HANDLE_GET_TYPE(hDC) != GDI_OBJECT_TYPE_DC) - { - if (GDI_HANDLE_GET_TYPE(hDC) == GDI_OBJECT_TYPE_METADC) - return FALSE; - else - { - PLDC pLDC = GdiGetLDC(hDC); - if ( !pLDC ) + if (GDI_HANDLE_GET_TYPE(hDC) != GDI_OBJECT_TYPE_DC) + { + if (GDI_HANDLE_GET_TYPE(hDC) == GDI_OBJECT_TYPE_METADC) + return FALSE; + else { - SetLastError(ERROR_INVALID_HANDLE); - return FALSE; + PLDC pLDC = GdiGetLDC(hDC); + if ( !pLDC ) + { + SetLastError(ERROR_INVALID_HANDLE); + return FALSE; + } + if ( pLDC->Flags & LDC_META_PRINT) return TRUE; } - if ( pLDC->Flags & LDC_META_PRINT) return TRUE; - } - } - return FALSE; + } + return FALSE; } /* @@ -926,12 +927,12 @@ BOOL WINAPI GdiIsPlayMetafileDC(HDC hDC) { - PLDC pLDC = GdiGetLDC(hDC); - if ( pLDC ) - { - if ( pLDC->Flags & LDC_PLAY_MFDC ) return TRUE; - } - return FALSE; + PLDC pLDC = GdiGetLDC(hDC); + if ( pLDC ) + { + if ( pLDC->Flags & LDC_PLAY_MFDC ) return TRUE; + } + return FALSE; } /* @@ -941,18 +942,18 @@ BOOL WINAPI GdiValidateHandle(HGDIOBJ hobj) { - PGDI_TABLE_ENTRY Entry = GdiHandleTable + GDI_HANDLE_GET_INDEX(hobj); - if ( (Entry->Type & GDI_ENTRY_BASETYPE_MASK) != 0 && - ( (Entry->Type << GDI_ENTRY_UPPER_SHIFT) & GDI_HANDLE_TYPE_MASK ) == - GDI_HANDLE_GET_TYPE(hobj) ) - { - HANDLE pid = (HANDLE)((ULONG_PTR)Entry->ProcessId & ~0x1); - if(pid == NULL || pid == CurrentProcessId) + PGDI_TABLE_ENTRY Entry = GdiHandleTable + GDI_HANDLE_GET_INDEX(hobj); + if ( (Entry->Type & GDI_ENTRY_BASETYPE_MASK) != 0 && + ( (Entry->Type << GDI_ENTRY_UPPER_SHIFT) & GDI_HANDLE_TYPE_MASK ) == + GDI_HANDLE_GET_TYPE(hobj) ) { - return TRUE; + HANDLE pid = (HANDLE)((ULONG_PTR)Entry->ProcessId & ~0x1); + if(pid == NULL || pid == CurrentProcessId) + { + return TRUE; + } } - } - return FALSE; + return FALSE; } @@ -1042,12 +1043,12 @@ BOOL WINAPI RemoveFontMemResourceEx(HANDLE fh) { - if (fh) - { - return NtGdiRemoveFontMemResourceEx(fh); - } - SetLastError(ERROR_INVALID_PARAMETER); - return FALSE; + if (fh) + { + return NtGdiRemoveFontMemResourceEx(fh); + } + SetLastError(ERROR_INVALID_PARAMETER); + return FALSE; } /* @@ -1057,9 +1058,9 @@ int WINAPI RemoveFontResourceTracking(LPCSTR lpString,int unknown) { - UNIMPLEMENTED; - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return 0; + UNIMPLEMENTED; + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return 0; } /* @@ -1069,9 +1070,9 @@ HBITMAP WINAPI SetBitmapAttributes(HBITMAP hbm, DWORD dwFlags) { - UNIMPLEMENTED; - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return 0; + UNIMPLEMENTED; + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return 0; } /* @@ -1081,9 +1082,9 @@ HBRUSH WINAPI SetBrushAttributes(HBRUSH hbm, DWORD dwFlags) { - UNIMPLEMENTED; - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return 0; + UNIMPLEMENTED; + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return 0; } /* @@ -1127,12 +1128,12 @@ WINAPI GetETM(HDC hdc, EXTTEXTMETRIC *petm) { - BOOL Ret = NtGdiGetETM(hdc, petm); + BOOL Ret = NtGdiGetETM(hdc, petm); - if (Ret && petm) - petm->emKernPairs = GetKerningPairsA(hdc, 0, 0); + if (Ret && petm) + petm->emKernPairs = GetKerningPairsA(hdc, 0, 0); - return Ret; + return Ret; } /* @@ -1142,7 +1143,7 @@ int WINAPI Escape(HDC hdc, INT nEscape, INT cbInput, LPCSTR lpvInData, LPVOID lpvOutData) { - int retValue = SP_ERROR; + int retValue = SP_ERROR; HGDIOBJ hObject = hdc; UINT Type = 0; LPVOID pUserData = NULL; @@ -1159,165 +1160,165 @@ Escape(HDC hdc, INT nEscape, INT cbInput, LPCSTR lpvInData, LPVOID lpvOutData) { switch (nEscape) { - case ABORTDOC: - /* Note Winodws check see if the handle have any user data for ABORTDOC command - * ReactOS copy this behavior to be compatible with windows 2003 - */ - if ( (!GdiGetHandleUserData(hObject, (DWORD)Type, (PVOID) &pUserData)) || - (pUserData == NULL) ) - { - GdiSetLastError(ERROR_INVALID_HANDLE); - retValue = FALSE; - } - else - { - retValue = AbortDoc(hdc); - } - break; - - case DRAFTMODE: - case FLUSHOUTPUT: - case SETCOLORTABLE: - /* Note 1: DRAFTMODE, FLUSHOUTPUT, SETCOLORTABLE is outdated and been replace with other api */ - /* Note 2: Winodws check see if the handle have any user data for DRAFTMODE, FLUSHOUTPUT, SETCOLORTABLE command - * ReactOS copy this behavior to be compatible with windows 2003 - */ - if ( (!GdiGetHandleUserData(hObject, (DWORD)Type, (PVOID) &pUserData)) || - (pUserData == NULL) ) - { - GdiSetLastError(ERROR_INVALID_HANDLE); - } + case ABORTDOC: + /* Note Winodws check see if the handle have any user data for ABORTDOC command + * ReactOS copy this behavior to be compatible with windows 2003 + */ + if ( (!GdiGetHandleUserData(hObject, (DWORD)Type, (PVOID) &pUserData)) || + (pUserData == NULL) ) + { + GdiSetLastError(ERROR_INVALID_HANDLE); retValue = FALSE; - break; + } + else + { + retValue = AbortDoc(hdc); + } + break; - case SETABORTPROC: - /* Note : Winodws check see if the handle have any user data for DRAFTMODE, FLUSHOUTPUT, SETCOLORTABLE command - * ReactOS copy this behavior to be compatible with windows 2003 - */ - if ( (!GdiGetHandleUserData(hObject, (DWORD)Type, (PVOID) &pUserData)) || - (pUserData == NULL) ) - { - GdiSetLastError(ERROR_INVALID_HANDLE); - retValue = FALSE; - } - retValue = SetAbortProc(hdc, (ABORTPROC)lpvInData); - break; + case DRAFTMODE: + case FLUSHOUTPUT: + case SETCOLORTABLE: + /* Note 1: DRAFTMODE, FLUSHOUTPUT, SETCOLORTABLE is outdated and been replace with other api */ + /* Note 2: Winodws check see if the handle have any user data for DRAFTMODE, FLUSHOUTPUT, SETCOLORTABLE command + * ReactOS copy this behavior to be compatible with windows 2003 + */ + if ( (!GdiGetHandleUserData(hObject, (DWORD)Type, (PVOID) &pUserData)) || + (pUserData == NULL) ) + { + GdiSetLastError(ERROR_INVALID_HANDLE); + } + retValue = FALSE; + break; - case GETCOLORTABLE: - retValue = GetSystemPaletteEntries(hdc, (UINT)*lpvInData, 1, (LPPALETTEENTRY)lpvOutData); - if ( !retValue ) - { - retValue = SP_ERROR; - } - break; - - case ENDDOC: - /* Note : Winodws check see if the handle have any user data for DRAFTMODE, FLUSHOUTPUT, SETCOLORTABLE command - * ReactOS copy this behavior to be compatible with windows 2003 - */ - if ( (!GdiGetHandleUserData(hObject, (DWORD)Type, (PVOID) &pUserData)) || - (pUserData == NULL) ) - { - GdiSetLastError(ERROR_INVALID_HANDLE); - retValue = FALSE; - } - retValue = EndDoc(hdc); - break; - - - case GETSCALINGFACTOR: - /* Note GETSCALINGFACTOR is outdated have been replace by GetDeviceCaps */ - if ( Type == GDI_OBJECT_TYPE_DC ) - { - if ( lpvOutData ) - { - PPOINT ptr = (PPOINT) lpvOutData; - ptr->x = 0; - ptr->y = 0; - } - } + case SETABORTPROC: + /* Note : Winodws check see if the handle have any user data for DRAFTMODE, FLUSHOUTPUT, SETCOLORTABLE command + * ReactOS copy this behavior to be compatible with windows 2003 + */ + if ( (!GdiGetHandleUserData(hObject, (DWORD)Type, (PVOID) &pUserData)) || + (pUserData == NULL) ) + { + GdiSetLastError(ERROR_INVALID_HANDLE); retValue = FALSE; - break; + } + retValue = SetAbortProc(hdc, (ABORTPROC)lpvInData); + break; - case GETEXTENDEDTEXTMETRICS: - retValue = (int) GetETM( hdc, (EXTTEXTMETRIC *) lpvOutData) != 0; - break; + case GETCOLORTABLE: + retValue = GetSystemPaletteEntries(hdc, (UINT)*lpvInData, 1, (LPPALETTEENTRY)lpvOutData); + if ( !retValue ) + { + retValue = SP_ERROR; + } + break; - case STARTDOC: + case ENDDOC: + /* Note : Winodws check see if the handle have any user data for DRAFTMODE, FLUSHOUTPUT, SETCOLORTABLE command + * ReactOS copy this behavior to be compatible with windows 2003 + */ + if ( (!GdiGetHandleUserData(hObject, (DWORD)Type, (PVOID) &pUserData)) || + (pUserData == NULL) ) + { + GdiSetLastError(ERROR_INVALID_HANDLE); + retValue = FALSE; + } + retValue = EndDoc(hdc); + break; + + + case GETSCALINGFACTOR: + /* Note GETSCALINGFACTOR is outdated have been replace by GetDeviceCaps */ + if ( Type == GDI_OBJECT_TYPE_DC ) + { + if ( lpvOutData ) { - DOCINFOA *pUserDatalpdi; - DOCINFOA lpdi; + PPOINT ptr = (PPOINT) lpvOutData; + ptr->x = 0; + ptr->y = 0; + } + } + retValue = FALSE; + break; - /* Note : Winodws check see if the handle have any user data for STARTDOC command - * ReactOS copy this behavior to be compatible with windows 2003 + case GETEXTENDEDTEXTMETRICS: + retValue = (int) GetETM( hdc, (EXTTEXTMETRIC *) lpvOutData) != 0; + break; + + case STARTDOC: + { + DOCINFOA *pUserDatalpdi; + DOCINFOA lpdi; + + /* Note : Winodws check see if the handle have any user data for STARTDOC command + * ReactOS copy this behavior to be compatible with windows 2003 + */ + if ( (!GdiGetHandleUserData(hObject, (DWORD)Type, (PVOID) &pUserDatalpdi)) || + (pUserData == NULL) ) + { + GdiSetLastError(ERROR_INVALID_HANDLE); + retValue = FALSE; + } + + lpdi.cbSize = sizeof(DOCINFOA); + + /* NOTE lpszOutput will be store in handle userdata */ + lpdi.lpszOutput = 0; + + lpdi.lpszDatatype = 0; + lpdi.fwType = 0; + lpdi.lpszDocName = lpvInData; + + /* NOTE : doc for StartDocA/W at msdn http://msdn2.microsoft.com/en-us/library/ms535793(VS.85).aspx */ + retValue = StartDocA(hdc, &lpdi); + + /* StartDocA fail */ + if (retValue < 0) + { + /* check see if outbuffer contain any data, if it does abort */ + if ( (pUserDatalpdi->lpszOutput != 0) && + ( (*(WCHAR *)pUserDatalpdi->lpszOutput) != UNICODE_NULL) ) + { + retValue = SP_APPABORT; + } + else + { + retValue = GetLastError(); + + /* Translate StartDocA error code to STARTDOC error code + * see msdn http://msdn2.microsoft.com/en-us/library/ms535472.aspx */ - if ( (!GdiGetHandleUserData(hObject, (DWORD)Type, (PVOID) &pUserDatalpdi)) || - (pUserData == NULL) ) + switch(retValue) { - GdiSetLastError(ERROR_INVALID_HANDLE); - retValue = FALSE; - } + case ERROR_NOT_ENOUGH_MEMORY: + retValue = SP_OUTOFMEMORY; + break; - lpdi.cbSize = sizeof(DOCINFOA); + case ERROR_PRINT_CANCELLED: + retValue = SP_USERABORT; + break; - /* NOTE lpszOutput will be store in handle userdata */ - lpdi.lpszOutput = 0; + case ERROR_DISK_FULL: + retValue = SP_OUTOFDISK; + break; - lpdi.lpszDatatype = 0; - lpdi.fwType = 0; - lpdi.lpszDocName = lpvInData; - - /* NOTE : doc for StartDocA/W at msdn http://msdn2.microsoft.com/en-us/library/ms535793(VS.85).aspx */ - retValue = StartDocA(hdc, &lpdi); - - /* StartDocA fail */ - if (retValue < 0) - { - /* check see if outbuffer contain any data, if it does abort */ - if ( (pUserDatalpdi->lpszOutput != 0) && - ( (*(WCHAR *)pUserDatalpdi->lpszOutput) != UNICODE_NULL) ) - { - retValue = SP_APPABORT; - } - else - { - retValue = GetLastError(); - - /* Translate StartDocA error code to STARTDOC error code - * see msdn http://msdn2.microsoft.com/en-us/library/ms535472.aspx - */ - switch(retValue) - { - case ERROR_NOT_ENOUGH_MEMORY: - retValue = SP_OUTOFMEMORY; - break; - - case ERROR_PRINT_CANCELLED: - retValue = SP_USERABORT; - break; - - case ERROR_DISK_FULL: - retValue = SP_OUTOFDISK; - break; - - default: - retValue = SP_ERROR; - break; - } - } + default: + retValue = SP_ERROR; + break; } } - break; - - + } + } + break; - default: - UNIMPLEMENTED; - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + + + default: + UNIMPLEMENTED; + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); } } - + return retValue; } @@ -1375,14 +1376,14 @@ GdiConvertToDevmodeW(const DEVMODEA *dmA) if (!dmW) return NULL; MultiByteToWideChar(CP_ACP, 0, (const char*) dmA->dmDeviceName, CCHDEVICENAME, - dmW->dmDeviceName, CCHDEVICENAME); + dmW->dmDeviceName, CCHDEVICENAME); /* copy slightly more, to avoid long computations */ memcpy(&dmW->dmSpecVersion, &dmA->dmSpecVersion, dmA_size - CCHDEVICENAME); if (dmA_size >= FIELD_OFFSET(DEVMODEA, dmFormName) + CCHFORMNAME) { MultiByteToWideChar(CP_ACP, 0, (const char*) dmA->dmFormName, CCHFORMNAME, - dmW->dmFormName, CCHFORMNAME); + dmW->dmFormName, CCHFORMNAME); if (dmA_size > FIELD_OFFSET(DEVMODEA, dmLogPixels)) memcpy(&dmW->dmLogPixels, &dmA->dmLogPixels, dmA_size - FIELD_OFFSET(DEVMODEA, dmLogPixels)); } @@ -1559,7 +1560,7 @@ GdiPlayEMF(LPWSTR pwszPrinterName, LPWSTR pwszDocName, EMFPLAYPROC pfnEMFPlayFn, HANDLE hPageQuery -) + ) { UNIMPLEMENTED; SetLastError(ERROR_CALL_NOT_IMPLEMENTED); @@ -1622,7 +1623,7 @@ GdiTransparentBlt(IN HDC hdcDst, IN INT cxSrc, IN INT cySrc, IN COLORREF TransColor -) + ) { /* FIXME some part need be done in user mode */ return NtGdiTransparentBlt(hdcDst, xDst, yDst, cxDst, cyDst, hdcSrc, xSrc, ySrc, cxSrc, cySrc, TransColor); @@ -1695,7 +1696,7 @@ GetFontData(HDC hdc, { if (!lpvBuffer) { - cbData = 0; + cbData = 0; } return NtGdiGetFontData(hdc, dwTable, dwOffset, lpvBuffer, cbData); } diff --git a/reactos/dll/win32/gdi32/misc/stubsa.c b/reactos/dll/win32/gdi32/misc/stubsa.c index 9f11cedb38c..5a3727e093f 100644 --- a/reactos/dll/win32/gdi32/misc/stubsa.c +++ b/reactos/dll/win32/gdi32/misc/stubsa.c @@ -31,14 +31,14 @@ PolyTextOutA( HDC hdc, const POLYTEXTA *pptxt, INT cStrings ) BOOL WINAPI GetLogColorSpaceA( - HCOLORSPACE a0, - LPLOGCOLORSPACEA a1, - DWORD a2 - ) + HCOLORSPACE a0, + LPLOGCOLORSPACEA a1, + DWORD a2 +) { - UNIMPLEMENTED; - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return FALSE; + UNIMPLEMENTED; + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return FALSE; } @@ -48,10 +48,10 @@ GetLogColorSpaceA( BOOL WINAPI GetICMProfileA( - HDC hdc, - LPDWORD pBufSize, - LPSTR pszFilename - ) + HDC hdc, + LPDWORD pBufSize, + LPSTR pszFilename +) { WCHAR filenameW[MAX_PATH]; DWORD buflen = MAX_PATH; @@ -81,13 +81,13 @@ GetICMProfileA( BOOL WINAPI SetICMProfileA( - HDC a0, - LPSTR a1 - ) + HDC a0, + LPSTR a1 +) { - UNIMPLEMENTED; - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return FALSE; + UNIMPLEMENTED; + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return FALSE; } @@ -97,24 +97,24 @@ SetICMProfileA( int WINAPI EnumICMProfilesA( - HDC a0, - ICMENUMPROCA a1, - LPARAM a2 - ) + HDC a0, + ICMENUMPROCA a1, + LPARAM a2 +) { - /* - * FIXME - call NtGdiEnumICMProfiles with NULL for lpstrBuffer - * to find out how big a buffer we need. Then allocate that buffer - * and call NtGdiEnumICMProfiles again to have the buffer filled. - * - * Finally, step through the buffer ( MULTI-SZ recommended for format ), - * and convert each string to ANSI, calling the user's callback function - * until we run out of strings or the user returns FALSE - */ + /* + * FIXME - call NtGdiEnumICMProfiles with NULL for lpstrBuffer + * to find out how big a buffer we need. Then allocate that buffer + * and call NtGdiEnumICMProfiles again to have the buffer filled. + * + * Finally, step through the buffer ( MULTI-SZ recommended for format ), + * and convert each string to ANSI, calling the user's callback function + * until we run out of strings or the user returns FALSE + */ - UNIMPLEMENTED; - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return 0; + UNIMPLEMENTED; + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return 0; } @@ -124,15 +124,15 @@ EnumICMProfilesA( BOOL WINAPI UpdateICMRegKeyA( - DWORD a0, - LPSTR a1, - LPSTR a2, - UINT a3 - ) + DWORD a0, + LPSTR a1, + LPSTR a2, + UINT a3 +) { - UNIMPLEMENTED; - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return FALSE; + UNIMPLEMENTED; + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return FALSE; } /* diff --git a/reactos/dll/win32/gdi32/misc/stubsw.c b/reactos/dll/win32/gdi32/misc/stubsw.c index cebf72d63ef..29b7406ff7c 100644 --- a/reactos/dll/win32/gdi32/misc/stubsw.c +++ b/reactos/dll/win32/gdi32/misc/stubsw.c @@ -31,14 +31,14 @@ PolyTextOutW( HDC hdc, const POLYTEXTW *pptxt, INT cStrings ) BOOL WINAPI GetLogColorSpaceW( - HCOLORSPACE a0, - LPLOGCOLORSPACEW a1, - DWORD a2 - ) + HCOLORSPACE a0, + LPLOGCOLORSPACEW a1, + DWORD a2 +) { - UNIMPLEMENTED; - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return FALSE; + UNIMPLEMENTED; + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return FALSE; } @@ -48,16 +48,16 @@ GetLogColorSpaceW( BOOL WINAPI GetICMProfileW( - HDC hdc, - LPDWORD size, - LPWSTR filename - ) + HDC hdc, + LPDWORD size, + LPWSTR filename +) { if (!hdc || !size || !filename) return FALSE; - UNIMPLEMENTED; - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return FALSE; + UNIMPLEMENTED; + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return FALSE; } @@ -67,13 +67,13 @@ GetICMProfileW( BOOL WINAPI SetICMProfileW( - HDC a0, - LPWSTR a1 - ) + HDC a0, + LPWSTR a1 +) { - UNIMPLEMENTED; - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return FALSE; + UNIMPLEMENTED; + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return FALSE; } @@ -83,23 +83,23 @@ SetICMProfileW( int WINAPI EnumICMProfilesW( - HDC hDC, - ICMENUMPROCW lpEnumICMProfilesFunc, - LPARAM lParam - ) + HDC hDC, + ICMENUMPROCW lpEnumICMProfilesFunc, + LPARAM lParam +) { - /* - * FIXME - call NtGdiEnumICMProfiles with NULL for lpstrBuffer - * to find out how big a buffer we need. Then allocate that buffer - * and call NtGdiEnumICMProfiles again to have the buffer filled. - * - * Finally, step through the buffer ( MULTI-SZ recommended for format ), - * and call the user's callback function until we run out of strings or - * the user returns FALSE - */ - UNIMPLEMENTED; - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return 0; + /* + * FIXME - call NtGdiEnumICMProfiles with NULL for lpstrBuffer + * to find out how big a buffer we need. Then allocate that buffer + * and call NtGdiEnumICMProfiles again to have the buffer filled. + * + * Finally, step through the buffer ( MULTI-SZ recommended for format ), + * and call the user's callback function until we run out of strings or + * the user returns FALSE + */ + UNIMPLEMENTED; + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return 0; } @@ -109,15 +109,15 @@ EnumICMProfilesW( BOOL WINAPI UpdateICMRegKeyW( - DWORD a0, - LPWSTR a1, - LPWSTR a2, - UINT a3 - ) + DWORD a0, + LPWSTR a1, + LPWSTR a2, + UINT a3 +) { - UNIMPLEMENTED; - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return FALSE; + UNIMPLEMENTED; + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return FALSE; } @@ -134,9 +134,9 @@ BOOL WINAPI EudcLoadLinkW(LPCWSTR pBaseFaceName,LPCWSTR pEudcFontPath,INT iPriority,INT iFontLinkType) { - UNIMPLEMENTED; - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return 0; + UNIMPLEMENTED; + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return 0; } /* @@ -146,9 +146,9 @@ BOOL WINAPI EudcUnloadLinkW(LPCWSTR pBaseFaceName,LPCWSTR pEudcFontPath) { - UNIMPLEMENTED; - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return 0; + UNIMPLEMENTED; + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return 0; } /* @@ -194,9 +194,9 @@ BOOL WINAPI bInitSystemAndFontsDirectoriesW(LPWSTR *SystemDir,LPWSTR *FontsDir) { - UNIMPLEMENTED; - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return 0; + UNIMPLEMENTED; + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return 0; } /* @@ -206,9 +206,9 @@ BOOL WINAPI bMakePathNameW(LPWSTR lpBuffer,LPCWSTR lpFileName,LPWSTR *lpFilePart,DWORD unknown) { - UNIMPLEMENTED; - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return 0; + UNIMPLEMENTED; + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return 0; } /* @@ -237,11 +237,11 @@ GetStringBitmapW(HDC hdc, BOOL WINAPI CreateScalableFontResourceW( - DWORD fdwHidden, - LPCWSTR lpszFontRes, - LPCWSTR lpszFontFile, - LPCWSTR lpszCurrentPath - ) + DWORD fdwHidden, + LPCWSTR lpszFontRes, + LPCWSTR lpszFontFile, + LPCWSTR lpszCurrentPath +) { HANDLE f; @@ -253,13 +253,14 @@ CreateScalableFontResourceW( */ /* If the output file already exists, return the ERROR_FILE_EXISTS error as specified in MSDN */ - if ((f = CreateFileW(lpszFontRes, 0, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0)) != INVALID_HANDLE_VALUE) { + if ((f = CreateFileW(lpszFontRes, 0, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0)) != INVALID_HANDLE_VALUE) + { CloseHandle(f); SetLastError(ERROR_FILE_EXISTS); return FALSE; } return FALSE; /* create failed */ } - + /* EOF */ diff --git a/reactos/dll/win32/gdi32/misc/wingl.c b/reactos/dll/win32/gdi32/misc/wingl.c index b20ac7ee9d2..2a00f9bfc91 100644 --- a/reactos/dll/win32/gdi32/misc/wingl.c +++ b/reactos/dll/win32/gdi32/misc/wingl.c @@ -113,11 +113,11 @@ WINAPI ChoosePixelFormat(HDC hdc, CONST PIXELFORMATDESCRIPTOR * ppfd) { - if (glChoosePixelFormat == NULL) - if (OpenGLEnable() == FALSE) - return(0); + if (glChoosePixelFormat == NULL) + if (OpenGLEnable() == FALSE) + return(0); - return(glChoosePixelFormat(hdc, ppfd)); + return(glChoosePixelFormat(hdc, ppfd)); } @@ -132,11 +132,11 @@ DescribePixelFormat(HDC hdc, UINT nBytes, LPPIXELFORMATDESCRIPTOR ppfd) { - if (glDescribePixelFormat == NULL) - if (OpenGLEnable() == FALSE) - return(0); + if (glDescribePixelFormat == NULL) + if (OpenGLEnable() == FALSE) + return(0); - return(glDescribePixelFormat(hdc, iPixelFormat, nBytes, ppfd)); + return(glDescribePixelFormat(hdc, iPixelFormat, nBytes, ppfd)); } @@ -148,11 +148,11 @@ INT WINAPI GetPixelFormat(HDC hdc) { - if (glGetPixelFormat == NULL) - if (OpenGLEnable() == FALSE) - return(0); + if (glGetPixelFormat == NULL) + if (OpenGLEnable() == FALSE) + return(0); - return(glGetPixelFormat(hdc)); + return(glGetPixelFormat(hdc)); } @@ -166,15 +166,15 @@ SetPixelFormat(HDC hdc, INT iPixelFormat, CONST PIXELFORMATDESCRIPTOR * ppfd) { - /* Can only be set once */ - INT current = GetPixelFormat(hdc); - if(current) return current == iPixelFormat ; - - if (glSetPixelFormat == NULL) - if (OpenGLEnable() == FALSE) - return(0); + /* Can only be set once */ + INT current = GetPixelFormat(hdc); + if(current) return current == iPixelFormat ; - return(glSetPixelFormat(hdc, iPixelFormat, ppfd)); + if (glSetPixelFormat == NULL) + if (OpenGLEnable() == FALSE) + return(0); + + return(glSetPixelFormat(hdc, iPixelFormat, ppfd)); } @@ -186,12 +186,12 @@ BOOL WINAPI SwapBuffers(HDC hdc) { - if (glSwapBuffers == NULL) - if (OpenGLEnable() == FALSE) - return(0); + if (glSwapBuffers == NULL) + if (OpenGLEnable() == FALSE) + return(0); - return(glSwapBuffers(hdc)); + return(glSwapBuffers(hdc)); } @@ -205,25 +205,25 @@ SwapBuffers(HDC hdc) UINT WINAPI GetEnhMetaFilePixelFormat( - HENHMETAFILE hemf, - UINT cbBuffer, - PIXELFORMATDESCRIPTOR *ppfd - ) + HENHMETAFILE hemf, + UINT cbBuffer, + PIXELFORMATDESCRIPTOR *ppfd +) { - ENHMETAHEADER pemh; + ENHMETAHEADER pemh; - if(GetEnhMetaFileHeader(hemf, sizeof(ENHMETAHEADER), &pemh)) - { - if(pemh.bOpenGL) - { - if(pemh.cbPixelFormat) - { - memcpy((void*)ppfd, UlongToPtr(pemh.offPixelFormat), cbBuffer ); - return(pemh.cbPixelFormat); - } - } - } - return(0); + if(GetEnhMetaFileHeader(hemf, sizeof(ENHMETAHEADER), &pemh)) + { + if(pemh.bOpenGL) + { + if(pemh.cbPixelFormat) + { + memcpy((void*)ppfd, UlongToPtr(pemh.offPixelFormat), cbBuffer ); + return(pemh.cbPixelFormat); + } + } + } + return(0); } /* EOF */ diff --git a/reactos/dll/win32/gdi32/objects/arc.c b/reactos/dll/win32/gdi32/objects/arc.c index ba5047c63ab..de2a291a98a 100644 --- a/reactos/dll/win32/gdi32/objects/arc.c +++ b/reactos/dll/win32/gdi32/objects/arc.c @@ -3,52 +3,52 @@ BOOL WINAPI Arc( - HDC hDC, - int nLeftRect, - int nTopRect, - int nRightRect, - int nBottomRect, - int nXStartArc, - int nYStartArc, - int nXEndArc, - int nYEndArc + HDC hDC, + int nLeftRect, + int nTopRect, + int nRightRect, + int nBottomRect, + int nXStartArc, + int nYStartArc, + int nXEndArc, + int nYEndArc ) { #if 0 // Handle something other than a normal dc object. - if (GDI_HANDLE_GET_TYPE(hDC) != GDI_OBJECT_TYPE_DC) - { - if (GDI_HANDLE_GET_TYPE(hDC) == GDI_OBJECT_TYPE_METADC) -// Call Wine (rewrite of) MFDRV_MetaParam8 - return MFDRV_MetaParam8( hDC, META_ARC, a1, a2, a3, a4, a5, a6, a7, a8) - else + if (GDI_HANDLE_GET_TYPE(hDC) != GDI_OBJECT_TYPE_DC) { - PLDC pLDC = GdiGetLDC(hDC); - if ( !pLDC ) - { - SetLastError(ERROR_INVALID_HANDLE); - return FALSE; - } - if (pLDC->iType == LDC_EMFLDC) - { + if (GDI_HANDLE_GET_TYPE(hDC) == GDI_OBJECT_TYPE_METADC) +// Call Wine (rewrite of) MFDRV_MetaParam8 + return MFDRV_MetaParam8( hDC, META_ARC, a1, a2, a3, a4, a5, a6, a7, a8) + else + { + PLDC pLDC = GdiGetLDC(hDC); + if ( !pLDC ) + { + SetLastError(ERROR_INVALID_HANDLE); + return FALSE; + } + if (pLDC->iType == LDC_EMFLDC) + { // Call Wine (rewrite of) EMFDRV_ArcChordPie - BOOL Ret = EMFDRV_ArcChordPie( hDC, a1, a2, a3, a4, a5, a6, a7, a8, EMR_ARC); - return Ret; - } - return FALSE; + BOOL Ret = EMFDRV_ArcChordPie( hDC, a1, a2, a3, a4, a5, a6, a7, a8, EMR_ARC); + return Ret; + } + return FALSE; + } } - } #endif - return NtGdiArcInternal(GdiTypeArc, - hDC, - nLeftRect, - nTopRect, - nRightRect, - nBottomRect, - nXStartArc, - nYStartArc, - nXEndArc, - nYEndArc); + return NtGdiArcInternal(GdiTypeArc, + hDC, + nLeftRect, + nTopRect, + nRightRect, + nBottomRect, + nXStartArc, + nYStartArc, + nXEndArc, + nYEndArc); } @@ -64,131 +64,131 @@ AngleArc(HDC hDC, FLOAT StartAngle, FLOAT SweepAngle) { - gxf_long worker, worker1; + gxf_long worker, worker1; - worker.f = StartAngle; - worker1.f = SweepAngle; + worker.f = StartAngle; + worker1.f = SweepAngle; #if 0 // Handle something other than a normal dc object. - if (GDI_HANDLE_GET_TYPE(hDC) != GDI_OBJECT_TYPE_DC) - { - if (GDI_HANDLE_GET_TYPE(hDC) == GDI_OBJECT_TYPE_METADC) - return FALSE; //No meta support for AngleArc - else + if (GDI_HANDLE_GET_TYPE(hDC) != GDI_OBJECT_TYPE_DC) { - PLDC pLDC = GdiGetLDC(hDC); - if ( !pLDC ) - { - SetLastError(ERROR_INVALID_HANDLE); - return FALSE; - } - if (pLDC->iType == LDC_EMFLDC) - { - BOOL Ret = EMFDRV_AngleArc( hDC, X, Y, Radius, StartAngle, SweepAngle); - return Ret; - } - return FALSE; + if (GDI_HANDLE_GET_TYPE(hDC) == GDI_OBJECT_TYPE_METADC) + return FALSE; //No meta support for AngleArc + else + { + PLDC pLDC = GdiGetLDC(hDC); + if ( !pLDC ) + { + SetLastError(ERROR_INVALID_HANDLE); + return FALSE; + } + if (pLDC->iType == LDC_EMFLDC) + { + BOOL Ret = EMFDRV_AngleArc( hDC, X, Y, Radius, StartAngle, SweepAngle); + return Ret; + } + return FALSE; + } } - } #endif - return NtGdiAngleArc(hDC, X, Y, Radius, (DWORD)worker.l, (DWORD)worker1.l); + return NtGdiAngleArc(hDC, X, Y, Radius, (DWORD)worker.l, (DWORD)worker1.l); } BOOL WINAPI ArcTo( - HDC hDC, - int nLeftRect, - int nTopRect, - int nRightRect, - int nBottomRect, - int nXRadial1, - int nYRadial1, - int nXRadial2, - int nYRadial2) + HDC hDC, + int nLeftRect, + int nTopRect, + int nRightRect, + int nBottomRect, + int nXRadial1, + int nYRadial1, + int nXRadial2, + int nYRadial2) { #if 0 // Handle something other than a normal dc object. - if (GDI_HANDLE_GET_TYPE(hDC) != GDI_OBJECT_TYPE_DC) - { - if (GDI_HANDLE_GET_TYPE(hDC) == GDI_OBJECT_TYPE_METADC) - return FALSE; //No meta support for ArcTo - else + if (GDI_HANDLE_GET_TYPE(hDC) != GDI_OBJECT_TYPE_DC) { - PLDC pLDC = GdiGetLDC(hDC); - if ( !pLDC ) - { - SetLastError(ERROR_INVALID_HANDLE); - return FALSE; - } - if (pLDC->iType == LDC_EMFLDC) - { - BOOL Ret = EMFDRV_ArcChordPie( hDC, a1, a2, a3, a4, a5, a6, a7, a8, EMR_ARCTO); - return Ret; - } - return FALSE; + if (GDI_HANDLE_GET_TYPE(hDC) == GDI_OBJECT_TYPE_METADC) + return FALSE; //No meta support for ArcTo + else + { + PLDC pLDC = GdiGetLDC(hDC); + if ( !pLDC ) + { + SetLastError(ERROR_INVALID_HANDLE); + return FALSE; + } + if (pLDC->iType == LDC_EMFLDC) + { + BOOL Ret = EMFDRV_ArcChordPie( hDC, a1, a2, a3, a4, a5, a6, a7, a8, EMR_ARCTO); + return Ret; + } + return FALSE; + } } - } #endif - return NtGdiArcInternal(GdiTypeArcTo, - hDC, - nLeftRect, - nTopRect, - nRightRect, - nBottomRect, - nXRadial1, - nYRadial1, - nXRadial2, - nYRadial2); + return NtGdiArcInternal(GdiTypeArcTo, + hDC, + nLeftRect, + nTopRect, + nRightRect, + nBottomRect, + nXRadial1, + nYRadial1, + nXRadial2, + nYRadial2); } BOOL WINAPI Chord( - HDC hDC, - int nLeftRect, - int nTopRect, - int nRightRect, - int nBottomRect, - int nXRadial1, - int nYRadial1, - int nXRadial2, - int nYRadial2) + HDC hDC, + int nLeftRect, + int nTopRect, + int nRightRect, + int nBottomRect, + int nXRadial1, + int nYRadial1, + int nXRadial2, + int nYRadial2) { #if 0 // Handle something other than a normal dc object. - if (GDI_HANDLE_GET_TYPE(hDC) != GDI_OBJECT_TYPE_DC) - { - if (GDI_HANDLE_GET_TYPE(hDC) == GDI_OBJECT_TYPE_METADC) - return MFDRV_MetaParam8( hDC, META_CHORD, a1, a2, a3, a4, a5, a6, a7, a8) - else + if (GDI_HANDLE_GET_TYPE(hDC) != GDI_OBJECT_TYPE_DC) { - PLDC pLDC = GdiGetLDC(hDC); - if ( !pLDC ) - { - SetLastError(ERROR_INVALID_HANDLE); - return FALSE; - } - if (pLDC->iType == LDC_EMFLDC) - { - BOOL Ret = EMFDRV_ArcChordPie( hDC, a1, a2, a3, a4, a5, a6, a7, a8, EMR_CHORD); - return Ret; - } - return FALSE; + if (GDI_HANDLE_GET_TYPE(hDC) == GDI_OBJECT_TYPE_METADC) + return MFDRV_MetaParam8( hDC, META_CHORD, a1, a2, a3, a4, a5, a6, a7, a8) + else + { + PLDC pLDC = GdiGetLDC(hDC); + if ( !pLDC ) + { + SetLastError(ERROR_INVALID_HANDLE); + return FALSE; + } + if (pLDC->iType == LDC_EMFLDC) + { + BOOL Ret = EMFDRV_ArcChordPie( hDC, a1, a2, a3, a4, a5, a6, a7, a8, EMR_CHORD); + return Ret; + } + return FALSE; + } } - } #endif - return NtGdiArcInternal(GdiTypeChord, - hDC, - nLeftRect, - nTopRect, - nRightRect, - nBottomRect, - nXRadial1, - nYRadial1, - nXRadial2, - nYRadial2); + return NtGdiArcInternal(GdiTypeChord, + hDC, + nLeftRect, + nTopRect, + nRightRect, + nBottomRect, + nXRadial1, + nYRadial1, + nXRadial2, + nYRadial2); } @@ -198,41 +198,41 @@ Chord( BOOL WINAPI Pie( - HDC hDC, - int a1, - int a2, - int a3, - int a4, - int a5, - int a6, - int a7, - int a8 - ) + HDC hDC, + int a1, + int a2, + int a3, + int a4, + int a5, + int a6, + int a7, + int a8 +) { #if 0 // Handle something other than a normal dc object. - if (GDI_HANDLE_GET_TYPE(hDC) != GDI_OBJECT_TYPE_DC) - { - if (GDI_HANDLE_GET_TYPE(hDC) == GDI_OBJECT_TYPE_METADC) - return MFDRV_MetaParam8( hDC, META_PIE, a1, a2, a3, a4, a5, a6, a7, a8) - else + if (GDI_HANDLE_GET_TYPE(hDC) != GDI_OBJECT_TYPE_DC) { - PLDC pLDC = GdiGetLDC(hDC); - if ( !pLDC ) - { - SetLastError(ERROR_INVALID_HANDLE); - return FALSE; - } - if (pLDC->iType == LDC_EMFLDC) - { - BOOL Ret = EMFDRV_ArcChordPie( hDC, a1, a2, a3, a4, a5, a6, a7, a8, EMR_PIE); - return Ret; - } - return FALSE; + if (GDI_HANDLE_GET_TYPE(hDC) == GDI_OBJECT_TYPE_METADC) + return MFDRV_MetaParam8( hDC, META_PIE, a1, a2, a3, a4, a5, a6, a7, a8) + else + { + PLDC pLDC = GdiGetLDC(hDC); + if ( !pLDC ) + { + SetLastError(ERROR_INVALID_HANDLE); + return FALSE; + } + if (pLDC->iType == LDC_EMFLDC) + { + BOOL Ret = EMFDRV_ArcChordPie( hDC, a1, a2, a3, a4, a5, a6, a7, a8, EMR_PIE); + return Ret; + } + return FALSE; + } } - } #endif - return NtGdiArcInternal(GdiTypePie, hDC, a1, a2, a3, a4, a5, a6, a7, a8); + return NtGdiArcInternal(GdiTypePie, hDC, a1, a2, a3, a4, a5, a6, a7, a8); } diff --git a/reactos/dll/win32/gdi32/objects/bitmap.c b/reactos/dll/win32/gdi32/objects/bitmap.c index 18db05f2a61..969beb6ad44 100644 --- a/reactos/dll/win32/gdi32/objects/bitmap.c +++ b/reactos/dll/win32/gdi32/objects/bitmap.c @@ -19,7 +19,7 @@ INT FASTCALL DIB_BitmapInfoSize(const BITMAPINFO * info, WORD coloruse) const BITMAPCOREHEADER *core = (const BITMAPCOREHEADER *)info; colors = (core->bcBitCount <= 8) ? 1 << core->bcBitCount : 0; return sizeof(BITMAPCOREHEADER) + colors * - ((coloruse == DIB_RGB_COLORS) ? sizeof(RGBTRIPLE) : sizeof(WORD)); + ((coloruse == DIB_RGB_COLORS) ? sizeof(RGBTRIPLE) : sizeof(WORD)); } else /* assume BITMAPINFOHEADER */ { @@ -48,15 +48,15 @@ DIB_BitmapMaxBitsSize( PBITMAPINFO Info, UINT ScanLines ) if (Info->bmiHeader.biSize == sizeof(BITMAPCOREHEADER)) { - PBITMAPCOREHEADER Core = (PBITMAPCOREHEADER)Info; - MaxBits = Core->bcBitCount * Core->bcPlanes * Core->bcWidth; + PBITMAPCOREHEADER Core = (PBITMAPCOREHEADER)Info; + MaxBits = Core->bcBitCount * Core->bcPlanes * Core->bcWidth; } else /* assume BITMAPINFOHEADER */ { - if ((Info->bmiHeader.biCompression) && (Info->bmiHeader.biCompression != BI_BITFIELDS)) - return Info->bmiHeader.biSizeImage; - // Planes are over looked by Yuan. I guess assumed always 1. - MaxBits = Info->bmiHeader.biBitCount * Info->bmiHeader.biPlanes * Info->bmiHeader.biWidth; + if ((Info->bmiHeader.biCompression) && (Info->bmiHeader.biCompression != BI_BITFIELDS)) + return Info->bmiHeader.biSizeImage; + // Planes are over looked by Yuan. I guess assumed always 1. + MaxBits = Info->bmiHeader.biBitCount * Info->bmiHeader.biPlanes * Info->bmiHeader.biWidth; } MaxBits = ((MaxBits + 31) & ~31 ) / 8; // From Yuan, ScanLineSize = (Width * bitcount + 31)/32 return (MaxBits * ScanLines); // ret the full Size. @@ -66,26 +66,26 @@ UINT FASTCALL DIB_BitmapBitsSize( CONST BITMAPINFO* Info ) { - UINT Ret; + UINT Ret; - if (!Info) return 0; + if (!Info) return 0; - if ( Info->bmiHeader.biSize == sizeof(BITMAPCOREHEADER)) - { - PBITMAPCOREHEADER Core = (PBITMAPCOREHEADER)Info; - Ret = Core->bcHeight * - ((Core->bcWidth * Core->bcPlanes * Core->bcBitCount + 31) & ~31 ) / 8; - } - else /* assume BITMAPINFOHEADER */ - { - if ((Info->bmiHeader.biCompression) && - (Info->bmiHeader.biCompression != BI_BITFIELDS)) - return Info->bmiHeader.biSizeImage; + if ( Info->bmiHeader.biSize == sizeof(BITMAPCOREHEADER)) + { + PBITMAPCOREHEADER Core = (PBITMAPCOREHEADER)Info; + Ret = Core->bcHeight * + ((Core->bcWidth * Core->bcPlanes * Core->bcBitCount + 31) & ~31 ) / 8; + } + else /* assume BITMAPINFOHEADER */ + { + if ((Info->bmiHeader.biCompression) && + (Info->bmiHeader.biCompression != BI_BITFIELDS)) + return Info->bmiHeader.biSizeImage; // Make Height positive always.... - Ret = abs(Info->bmiHeader.biHeight) * - ((Info->bmiHeader.biWidth * Info->bmiHeader.biPlanes * Info->bmiHeader.biBitCount + 31) & ~31 ) / 8; - } - return Ret; + Ret = abs(Info->bmiHeader.biHeight) * + ((Info->bmiHeader.biWidth * Info->bmiHeader.biPlanes * Info->bmiHeader.biBitCount + 31) & ~31 ) / 8; + } + return Ret; } @@ -104,54 +104,54 @@ DIB_GetBitmapInfo(const BITMAPINFOHEADER *header, PLONG compr, PLONG size ) { - if (header->biSize == sizeof(BITMAPCOREHEADER)) - { - BITMAPCOREHEADER *core = (BITMAPCOREHEADER *)header; - *width = core->bcWidth; - *height = core->bcHeight; - *planes = core->bcPlanes; - *bpp = core->bcBitCount; - *compr = 0; - *size = 0; - return 0; - } + if (header->biSize == sizeof(BITMAPCOREHEADER)) + { + BITMAPCOREHEADER *core = (BITMAPCOREHEADER *)header; + *width = core->bcWidth; + *height = core->bcHeight; + *planes = core->bcPlanes; + *bpp = core->bcBitCount; + *compr = 0; + *size = 0; + return 0; + } - if (header->biSize == sizeof(BITMAPINFOHEADER)) - { - *width = header->biWidth; - *height = header->biHeight; - *planes = header->biPlanes; - *bpp = header->biBitCount; - *compr = header->biCompression; - *size = header->biSizeImage; - return 1; - } + if (header->biSize == sizeof(BITMAPINFOHEADER)) + { + *width = header->biWidth; + *height = header->biHeight; + *planes = header->biPlanes; + *bpp = header->biBitCount; + *compr = header->biCompression; + *size = header->biSizeImage; + return 1; + } - if (header->biSize == sizeof(BITMAPV4HEADER)) - { - BITMAPV4HEADER *v4hdr = (BITMAPV4HEADER *)header; - *width = v4hdr->bV4Width; - *height = v4hdr->bV4Height; - *planes = v4hdr->bV4Planes; - *bpp = v4hdr->bV4BitCount; - *compr = v4hdr->bV4V4Compression; - *size = v4hdr->bV4SizeImage; - return 4; - } + if (header->biSize == sizeof(BITMAPV4HEADER)) + { + BITMAPV4HEADER *v4hdr = (BITMAPV4HEADER *)header; + *width = v4hdr->bV4Width; + *height = v4hdr->bV4Height; + *planes = v4hdr->bV4Planes; + *bpp = v4hdr->bV4BitCount; + *compr = v4hdr->bV4V4Compression; + *size = v4hdr->bV4SizeImage; + return 4; + } - if (header->biSize == sizeof(BITMAPV5HEADER)) - { - BITMAPV5HEADER *v5hdr = (BITMAPV5HEADER *)header; - *width = v5hdr->bV5Width; - *height = v5hdr->bV5Height; - *planes = v5hdr->bV5Planes; - *bpp = v5hdr->bV5BitCount; - *compr = v5hdr->bV5Compression; - *size = v5hdr->bV5SizeImage; - return 5; - } - DPRINT("(%ld): wrong size for header\n", header->biSize ); - return -1; + if (header->biSize == sizeof(BITMAPV5HEADER)) + { + BITMAPV5HEADER *v5hdr = (BITMAPV5HEADER *)header; + *width = v5hdr->bV5Width; + *height = v5hdr->bV5Height; + *planes = v5hdr->bV5Planes; + *bpp = v5hdr->bV5BitCount; + *compr = v5hdr->bV5Compression; + *size = v5hdr->bV5SizeImage; + return 5; + } + DPRINT("(%ld): wrong size for header\n", header->biSize ); + return -1; } /* @@ -173,13 +173,13 @@ GdiGetBitmapBitsSize(BITMAPINFO *lpbmi) else { if ( (lpbmi->bmiHeader.biCompression == BI_BITFIELDS) || - (lpbmi->bmiHeader.biCompression == BI_RGB)) + (lpbmi->bmiHeader.biCompression == BI_RGB)) { if (lpbmi->bmiHeader.biHeight >=0 ) { /* Calc the bits Size and align it*/ retSize = lpbmi->bmiHeader.biHeight * ((lpbmi->bmiHeader.biWidth * - lpbmi->bmiHeader.biPlanes * lpbmi->bmiHeader.biBitCount + 31) & -32) / 8; + lpbmi->bmiHeader.biPlanes * lpbmi->bmiHeader.biBitCount + 31) & -32) / 8; } else { @@ -201,53 +201,54 @@ GdiGetBitmapBitsSize(BITMAPINFO *lpbmi) */ HBITMAP WINAPI CreateDIBSection( - HDC hDC, - CONST BITMAPINFO *BitmapInfo, - UINT Usage, - VOID **Bits, - HANDLE hSection, - DWORD dwOffset) + HDC hDC, + CONST BITMAPINFO *BitmapInfo, + UINT Usage, + VOID **Bits, + HANDLE hSection, + DWORD dwOffset) { - PBITMAPINFO pConvertedInfo; - UINT ConvertedInfoSize; - HBITMAP hBitmap = NULL; - PVOID bmBits = NULL; + PBITMAPINFO pConvertedInfo; + UINT ConvertedInfoSize; + HBITMAP hBitmap = NULL; + PVOID bmBits = NULL; - pConvertedInfo = ConvertBitmapInfo(BitmapInfo, Usage, - &ConvertedInfoSize, FALSE); - if (pConvertedInfo) - { // Verify header due to converted may == info. - if ( pConvertedInfo->bmiHeader.biSize >= sizeof(BITMAPINFOHEADER) ) - { - if ( pConvertedInfo->bmiHeader.biCompression == BI_JPEG || - pConvertedInfo->bmiHeader.biCompression == BI_PNG ) - { - SetLastError(ERROR_INVALID_PARAMETER); - return NULL; - } - } - bmBits = Bits; - hBitmap = NtGdiCreateDIBSection( hDC, - hSection, - dwOffset, - pConvertedInfo, - Usage, - 0, - 0, - 0, - &bmBits); - if (BitmapInfo != pConvertedInfo) - RtlFreeHeap(RtlGetProcessHeap(), 0, pConvertedInfo); + pConvertedInfo = ConvertBitmapInfo(BitmapInfo, Usage, + &ConvertedInfoSize, FALSE); + if (pConvertedInfo) + { + // Verify header due to converted may == info. + if ( pConvertedInfo->bmiHeader.biSize >= sizeof(BITMAPINFOHEADER) ) + { + if ( pConvertedInfo->bmiHeader.biCompression == BI_JPEG || + pConvertedInfo->bmiHeader.biCompression == BI_PNG ) + { + SetLastError(ERROR_INVALID_PARAMETER); + return NULL; + } + } + bmBits = Bits; + hBitmap = NtGdiCreateDIBSection( hDC, + hSection, + dwOffset, + pConvertedInfo, + Usage, + 0, + 0, + 0, + &bmBits); + if (BitmapInfo != pConvertedInfo) + RtlFreeHeap(RtlGetProcessHeap(), 0, pConvertedInfo); - if (!hBitmap) - { - bmBits = NULL; - } - } + if (!hBitmap) + { + bmBits = NULL; + } + } - if (Bits) *Bits = bmBits; + if (Bits) *Bits = bmBits; - return hBitmap; + return hBitmap; } @@ -269,7 +270,7 @@ BitBlt(HDC hdcDest, /* handle to destination DC */ /* use patBlt for no source blt Like windows does */ if (!ROP_USES_SOURCE(dwRop)) { - return PatBlt(hdcDest, nXOriginDest, nYOriginDest, nWidthDest, nHeightDest, dwRop); + return PatBlt(hdcDest, nXOriginDest, nYOriginDest, nWidthDest, nHeightDest, dwRop); } return NtGdiBitBlt(hdcDest, @@ -290,28 +291,28 @@ BitBlt(HDC hdcDest, /* handle to destination DC */ */ BOOL WINAPI StretchBlt( - HDC hdcDest, /* handle to destination DC */ - int nXOriginDest, /* x-coord of destination upper-left corner */ - int nYOriginDest, /* y-coord of destination upper-left corner */ - int nWidthDest, /* width of destination rectangle */ - int nHeightDest, /* height of destination rectangle */ - HDC hdcSrc, /* handle to source DC */ - int nXOriginSrc, /* x-coord of source upper-left corner */ - int nYOriginSrc, /* y-coord of source upper-left corner */ - int nWidthSrc, /* width of source rectangle */ - int nHeightSrc, /* height of source rectangle */ - DWORD dwRop) /* raster operation code */ + HDC hdcDest, /* handle to destination DC */ + int nXOriginDest, /* x-coord of destination upper-left corner */ + int nYOriginDest, /* y-coord of destination upper-left corner */ + int nWidthDest, /* width of destination rectangle */ + int nHeightDest, /* height of destination rectangle */ + HDC hdcSrc, /* handle to source DC */ + int nXOriginSrc, /* x-coord of source upper-left corner */ + int nYOriginSrc, /* y-coord of source upper-left corner */ + int nWidthSrc, /* width of source rectangle */ + int nHeightSrc, /* height of source rectangle */ + DWORD dwRop) /* raster operation code */ { - if ((nWidthDest != nWidthSrc) || (nHeightDest != nHeightSrc)) - { - return NtGdiStretchBlt(hdcDest, nXOriginDest, nYOriginDest, nWidthDest, - nHeightDest, hdcSrc, nXOriginSrc, nYOriginSrc, - nWidthSrc, nHeightSrc, dwRop, 0); - } + if ((nWidthDest != nWidthSrc) || (nHeightDest != nHeightSrc)) + { + return NtGdiStretchBlt(hdcDest, nXOriginDest, nYOriginDest, nWidthDest, + nHeightDest, hdcSrc, nXOriginSrc, nYOriginSrc, + nWidthSrc, nHeightSrc, dwRop, 0); + } - return NtGdiBitBlt(hdcDest, nXOriginDest, nYOriginDest, nWidthDest, - nHeightDest, hdcSrc, nXOriginSrc, nYOriginSrc, dwRop, 0, 0); + return NtGdiBitBlt(hdcDest, nXOriginDest, nYOriginDest, nWidthDest, + nHeightDest, hdcSrc, nXOriginSrc, nYOriginSrc, dwRop, 0, 0); } /* @@ -342,71 +343,71 @@ CreateBitmap(INT Width, HBITMAP WINAPI CreateBitmapIndirect(const BITMAP *pbm) { - HBITMAP bitmap = NULL; + HBITMAP bitmap = NULL; - /* Note windows xp/2003 does not check if pbm is NULL or not */ - if ( (pbm->bmWidthBytes != 0) && - (!(pbm->bmWidthBytes & 1)) ) + /* Note windows xp/2003 does not check if pbm is NULL or not */ + if ( (pbm->bmWidthBytes != 0) && + (!(pbm->bmWidthBytes & 1)) ) - { + { - bitmap = CreateBitmap(pbm->bmWidth, - pbm->bmHeight, - pbm->bmPlanes, - pbm->bmBitsPixel, - pbm->bmBits); - } - else - { - SetLastError(ERROR_INVALID_PARAMETER); - } + bitmap = CreateBitmap(pbm->bmWidth, + pbm->bmHeight, + pbm->bmPlanes, + pbm->bmBitsPixel, + pbm->bmBits); + } + else + { + SetLastError(ERROR_INVALID_PARAMETER); + } - return bitmap; + return bitmap; } HBITMAP WINAPI CreateDiscardableBitmap( - HDC hDC, - INT Width, - INT Height) + HDC hDC, + INT Width, + INT Height) { - return CreateCompatibleBitmap(hDC, Width, Height); + return CreateCompatibleBitmap(hDC, Width, Height); } HBITMAP WINAPI CreateCompatibleBitmap( - HDC hDC, - INT Width, - INT Height) + HDC hDC, + INT Width, + INT Height) { - PDC_ATTR pDc_Attr; - HBITMAP hBmp = NULL; - DIBSECTION dibs; + PDC_ATTR pDc_Attr; + HBITMAP hBmp = NULL; + DIBSECTION dibs; - if (!GdiGetHandleUserData(hDC, GDI_OBJECT_TYPE_DC, (PVOID)&pDc_Attr)) - return NULL; + if (!GdiGetHandleUserData(hDC, GDI_OBJECT_TYPE_DC, (PVOID)&pDc_Attr)) + return NULL; - if ( !Width || !Height ) - return GetStockObject(DEFAULT_BITMAP); + if ( !Width || !Height ) + return GetStockObject(DEFAULT_BITMAP); - if (!(pDc_Attr->ulDirty_ & DC_DIBSECTION)) - { - return NtGdiCreateCompatibleBitmap(hDC, Width, Height); - } + if (!(pDc_Attr->ulDirty_ & DC_DIBSECTION)) + { + return NtGdiCreateCompatibleBitmap(hDC, Width, Height); + } - hBmp = NtGdiGetDCObject(hDC, GDI_OBJECT_TYPE_BITMAP); + hBmp = NtGdiGetDCObject(hDC, GDI_OBJECT_TYPE_BITMAP); - if ( GetObjectA(hBmp, sizeof(DIBSECTION), &dibs) != sizeof(DIBSECTION) ) - return NULL; + if ( GetObjectA(hBmp, sizeof(DIBSECTION), &dibs) != sizeof(DIBSECTION) ) + return NULL; - if ( dibs.dsBm.bmBitsPixel <= 8 ) - GetDIBColorTable(hDC, 0, 256, (RGBQUAD *)&dibs.dsBitfields); + if ( dibs.dsBm.bmBitsPixel <= 8 ) + GetDIBColorTable(hDC, 0, 256, (RGBQUAD *)&dibs.dsBitfields); - dibs.dsBmih.biWidth = Width; - dibs.dsBmih.biHeight = Height; + dibs.dsBmih.biWidth = Width; + dibs.dsBmih.biHeight = Height; - return CreateDIBSection(hDC, (CONST BITMAPINFO *)&dibs.dsBmih, 0, NULL, NULL, 0); + return CreateDIBSection(hDC, (CONST BITMAPINFO *)&dibs.dsBmih, 0, NULL, NULL, 0); } @@ -438,7 +439,7 @@ GetDIBits( if ( lpbmi->bmiHeader.biSize >= sizeof(BITMAPINFOHEADER) ) { if ( lpbmi->bmiHeader.biCompression == BI_JPEG || - lpbmi->bmiHeader.biCompression == BI_PNG ) + lpbmi->bmiHeader.biCompression == BI_PNG ) { SetLastError(ERROR_INVALID_PARAMETER); return 0; @@ -446,15 +447,15 @@ GetDIBits( } } - return NtGdiGetDIBitsInternal(hDC, - hbmp, - uStartScan, - cScanLines, - lpvBits, - lpbmi, - uUsage, - cjBmpScanSize, - cjInfoSize); + return NtGdiGetDIBitsInternal(hDC, + hbmp, + uStartScan, + cScanLines, + lpvBits, + lpbmi, + uUsage, + cjBmpScanSize, + cjInfoSize); } /* @@ -469,65 +470,65 @@ CreateDIBitmap( HDC hDC, const BITMAPINFO *Data, UINT ColorUse) { - LONG width, height, compr, dibsize; - WORD planes, bpp; + LONG width, height, compr, dibsize; + WORD planes, bpp; // PDC_ATTR pDc_Attr; - UINT InfoSize = 0; - UINT cjBmpScanSize = 0; - HBITMAP hBmp; - NTSTATUS Status = STATUS_SUCCESS; + UINT InfoSize = 0; + UINT cjBmpScanSize = 0; + HBITMAP hBmp; + NTSTATUS Status = STATUS_SUCCESS; - if (!Header) return 0; + if (!Header) return 0; - if (DIB_GetBitmapInfo(Header, &width, &height, &planes, &bpp, &compr, &dibsize) == -1) - { - GdiSetLastError(ERROR_INVALID_PARAMETER); - return NULL; - } + if (DIB_GetBitmapInfo(Header, &width, &height, &planes, &bpp, &compr, &dibsize) == -1) + { + GdiSetLastError(ERROR_INVALID_PARAMETER); + return NULL; + } // For Icm support. // GdiGetHandleUserData(hdc, GDI_OBJECT_TYPE_DC, (PVOID)&pDc_Attr)) - if(Data) - { - _SEH2_TRY - { - cjBmpScanSize = DIB_BitmapBitsSize(Data); - CalculateColorTableSize(&Data->bmiHeader, &ColorUse, &InfoSize); - InfoSize += Data->bmiHeader.biSize; - } - _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) - { + if(Data) + { + _SEH2_TRY + { + cjBmpScanSize = DIB_BitmapBitsSize(Data); + CalculateColorTableSize(&Data->bmiHeader, &ColorUse, &InfoSize); + InfoSize += Data->bmiHeader.biSize; + } + _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) + { Status = _SEH2_GetExceptionCode(); - } - _SEH2_END - } + } + _SEH2_END + } - if(!NT_SUCCESS(Status)) - { - GdiSetLastError(ERROR_INVALID_PARAMETER); - return NULL; - } + if(!NT_SUCCESS(Status)) + { + GdiSetLastError(ERROR_INVALID_PARAMETER); + return NULL; + } - DPRINT("pBMI %x, Size bpp %d, dibsize %d, Conv %d, BSS %d\n", Data,bpp,dibsize,InfoSize,cjBmpScanSize); + DPRINT("pBMI %x, Size bpp %d, dibsize %d, Conv %d, BSS %d\n", Data,bpp,dibsize,InfoSize,cjBmpScanSize); - if ( !width || !height ) - hBmp = GetStockObject(DEFAULT_BITMAP); - else - { - hBmp = NtGdiCreateDIBitmapInternal(hDC, - width, - height, - Init, - (LPBYTE)Bits, - (LPBITMAPINFO)Data, - ColorUse, - InfoSize, - cjBmpScanSize, - 0, - 0); - } - return hBmp; + if ( !width || !height ) + hBmp = GetStockObject(DEFAULT_BITMAP); + else + { + hBmp = NtGdiCreateDIBitmapInternal(hDC, + width, + height, + Init, + (LPBYTE)Bits, + (LPBITMAPINFO)Data, + ColorUse, + InfoSize, + cjBmpScanSize, + 0, + 0); + } + return hBmp; } #if 0 // FIXME!!! This is a victim of the Win32k Initialization BUG!!!!! @@ -544,83 +545,83 @@ SetDIBits(HDC hDC, CONST BITMAPINFO *lpbmi, UINT fuColorUse) { - HDC hDCc, SavehDC, nhDC; - DWORD dwWidth, dwHeight; - HGDIOBJ hOldBitmap; - HPALETTE hPal = NULL; - INT LinesCopied = 0; - BOOL newDC = FALSE; + HDC hDCc, SavehDC, nhDC; + DWORD dwWidth, dwHeight; + HGDIOBJ hOldBitmap; + HPALETTE hPal = NULL; + INT LinesCopied = 0; + BOOL newDC = FALSE; - if ( !lpvBits || (GDI_HANDLE_GET_TYPE(hBitmap) != GDI_OBJECT_TYPE_BITMAP) ) - return 0; - - if ( lpbmi ) - { - if ( lpbmi->bmiHeader.biSize >= sizeof(BITMAPINFOHEADER) ) - { - if ( lpbmi->bmiHeader.biCompression == BI_JPEG || lpbmi->bmiHeader.biCompression == BI_PNG ) - { - SetLastError(ERROR_INVALID_PARAMETER); + if ( !lpvBits || (GDI_HANDLE_GET_TYPE(hBitmap) != GDI_OBJECT_TYPE_BITMAP) ) return 0; - } - } - } - hDCc = NtGdiGetDCforBitmap(hBitmap); - SavehDC = hDCc; - if ( !hDCc ) - { - nhDC = CreateCompatibleDC(hDC); - if ( !nhDC ) return 0; - newDC = TRUE; - SavehDC = nhDC; - } - else if ( !SaveDC(hDCc) ) - return 0; - - hOldBitmap = SelectObject(SavehDC, hBitmap); - - if ( hOldBitmap ) - { - if ( hDC ) - hPal = SelectPalette(SavehDC, (HPALETTE)GetDCObject(hDC, GDI_OBJECT_TYPE_PALETTE), FALSE); - - if ( lpbmi->bmiHeader.biSize < sizeof(BITMAPINFOHEADER)) + if ( lpbmi ) { - PBITMAPCOREINFO pbci = (PBITMAPCOREINFO) lpbmi; - dwWidth = pbci->bmciHeader.bcWidth; - dwHeight = pbci->bmciHeader.bcHeight; + if ( lpbmi->bmiHeader.biSize >= sizeof(BITMAPINFOHEADER) ) + { + if ( lpbmi->bmiHeader.biCompression == BI_JPEG || lpbmi->bmiHeader.biCompression == BI_PNG ) + { + SetLastError(ERROR_INVALID_PARAMETER); + return 0; + } + } } + + hDCc = NtGdiGetDCforBitmap(hBitmap); + SavehDC = hDCc; + if ( !hDCc ) + { + nhDC = CreateCompatibleDC(hDC); + if ( !nhDC ) return 0; + newDC = TRUE; + SavehDC = nhDC; + } + else if ( !SaveDC(hDCc) ) + return 0; + + hOldBitmap = SelectObject(SavehDC, hBitmap); + + if ( hOldBitmap ) + { + if ( hDC ) + hPal = SelectPalette(SavehDC, (HPALETTE)GetDCObject(hDC, GDI_OBJECT_TYPE_PALETTE), FALSE); + + if ( lpbmi->bmiHeader.biSize < sizeof(BITMAPINFOHEADER)) + { + PBITMAPCOREINFO pbci = (PBITMAPCOREINFO) lpbmi; + dwWidth = pbci->bmciHeader.bcWidth; + dwHeight = pbci->bmciHeader.bcHeight; + } + else + { + dwWidth = lpbmi->bmiHeader.biWidth; + dwHeight = abs(lpbmi->bmiHeader.biHeight); + } + + LinesCopied = SetDIBitsToDevice(SavehDC, + 0, + 0, + dwWidth, + dwHeight, + 0, + 0, + uStartScan, + cScanLines, + (void *)lpvBits, + (LPBITMAPINFO)lpbmi, + fuColorUse); + + if ( hDC ) SelectPalette(SavehDC, hPal, FALSE); + + SelectObject(SavehDC, hOldBitmap); + } + + if ( newDC ) + DeleteDC(SavehDC); else - { - dwWidth = lpbmi->bmiHeader.biWidth; - dwHeight = abs(lpbmi->bmiHeader.biHeight); - } + RestoreDC(SavehDC, -1); - LinesCopied = SetDIBitsToDevice(SavehDC, - 0, - 0, - dwWidth, - dwHeight, - 0, - 0, - uStartScan, - cScanLines, - (void *)lpvBits, - (LPBITMAPINFO)lpbmi, - fuColorUse); - - if ( hDC ) SelectPalette(SavehDC, hPal, FALSE); - - SelectObject(SavehDC, hOldBitmap); - } - - if ( newDC ) - DeleteDC(SavehDC); - else - RestoreDC(SavehDC, -1); - - return LinesCopied; + return LinesCopied; } #endif @@ -634,47 +635,47 @@ SetDIBits(HDC hdc, CONST BITMAPINFO *lpbmi, UINT fuColorUse) { - PBITMAPINFO pConvertedInfo; - UINT ConvertedInfoSize; - INT LinesCopied = 0; - UINT cjBmpScanSize = 0; - PVOID pvSafeBits = (PVOID)lpvBits; + PBITMAPINFO pConvertedInfo; + UINT ConvertedInfoSize; + INT LinesCopied = 0; + UINT cjBmpScanSize = 0; + PVOID pvSafeBits = (PVOID)lpvBits; // This needs to be almost the sames as SetDIBitsToDevice - if ( !cScanLines || !lpbmi || !lpvBits || (GDI_HANDLE_GET_TYPE(hbmp) != GDI_OBJECT_TYPE_BITMAP)) - return 0; + if ( !cScanLines || !lpbmi || !lpvBits || (GDI_HANDLE_GET_TYPE(hbmp) != GDI_OBJECT_TYPE_BITMAP)) + return 0; - if ( fuColorUse && fuColorUse != DIB_PAL_COLORS && fuColorUse != DIB_PAL_COLORS+1 ) - return 0; + if ( fuColorUse && fuColorUse != DIB_PAL_COLORS && fuColorUse != DIB_PAL_COLORS+1 ) + return 0; - pConvertedInfo = ConvertBitmapInfo(lpbmi, fuColorUse, - &ConvertedInfoSize, FALSE); - if (!pConvertedInfo) - return 0; + pConvertedInfo = ConvertBitmapInfo(lpbmi, fuColorUse, + &ConvertedInfoSize, FALSE); + if (!pConvertedInfo) + return 0; - cjBmpScanSize = DIB_BitmapMaxBitsSize((LPBITMAPINFO)lpbmi, cScanLines); + cjBmpScanSize = DIB_BitmapMaxBitsSize((LPBITMAPINFO)lpbmi, cScanLines); - if ( lpvBits ) - { - pvSafeBits = RtlAllocateHeap(GetProcessHeap(), 0, cjBmpScanSize); - if (pvSafeBits) - RtlCopyMemory( pvSafeBits, lpvBits, cjBmpScanSize); - } + if ( lpvBits ) + { + pvSafeBits = RtlAllocateHeap(GetProcessHeap(), 0, cjBmpScanSize); + if (pvSafeBits) + RtlCopyMemory( pvSafeBits, lpvBits, cjBmpScanSize); + } - LinesCopied = NtGdiSetDIBits( hdc, - hbmp, - uStartScan, - cScanLines, - pvSafeBits, - pConvertedInfo, - fuColorUse); + LinesCopied = NtGdiSetDIBits( hdc, + hbmp, + uStartScan, + cScanLines, + pvSafeBits, + pConvertedInfo, + fuColorUse); - if ( lpvBits != pvSafeBits) - RtlFreeHeap(RtlGetProcessHeap(), 0, pvSafeBits); - if (lpbmi != pConvertedInfo) - RtlFreeHeap(RtlGetProcessHeap(), 0, pConvertedInfo); - return LinesCopied; + if ( lpvBits != pvSafeBits) + RtlFreeHeap(RtlGetProcessHeap(), 0, pvSafeBits); + if (lpbmi != pConvertedInfo) + RtlFreeHeap(RtlGetProcessHeap(), 0, pConvertedInfo); + return LinesCopied; } /* @@ -697,111 +698,111 @@ SetDIBitsToDevice( CONST BITMAPINFO *lpbmi, UINT ColorUse) { - PDC_ATTR pDc_Attr; - PBITMAPINFO pConvertedInfo; - UINT ConvertedInfoSize; - INT LinesCopied = 0; - UINT cjBmpScanSize = 0; - PVOID pvSafeBits = (PVOID)Bits; + PDC_ATTR pDc_Attr; + PBITMAPINFO pConvertedInfo; + UINT ConvertedInfoSize; + INT LinesCopied = 0; + UINT cjBmpScanSize = 0; + PVOID pvSafeBits = (PVOID)Bits; - if ( !ScanLines || !lpbmi || !Bits ) - return 0; + if ( !ScanLines || !lpbmi || !Bits ) + return 0; - if ( ColorUse && ColorUse != DIB_PAL_COLORS && ColorUse != DIB_PAL_COLORS+1 ) - return 0; + if ( ColorUse && ColorUse != DIB_PAL_COLORS && ColorUse != DIB_PAL_COLORS+1 ) + return 0; - pConvertedInfo = ConvertBitmapInfo(lpbmi, ColorUse, - &ConvertedInfoSize, FALSE); - if (!pConvertedInfo) - return 0; + pConvertedInfo = ConvertBitmapInfo(lpbmi, ColorUse, + &ConvertedInfoSize, FALSE); + if (!pConvertedInfo) + return 0; #if 0 // Handle something other than a normal dc object. - if (GDI_HANDLE_GET_TYPE(hdc) != GDI_OBJECT_TYPE_DC) - { - if (GDI_HANDLE_GET_TYPE(hdc) == GDI_OBJECT_TYPE_METADC) - return MFDRV_SetDIBitsToDevice( hdc, - XDest, - YDest, - Width, - Height, - XSrc, - YSrc, - StartScan, - ScanLines, - Bits, - lpbmi, - ColorUse); - else - { - PLDC pLDC = GdiGetLDC(hdc); - if ( !pLDC ) - { - SetLastError(ERROR_INVALID_HANDLE); - return 0; - } - if (pLDC->iType == LDC_EMFLDC) - { - return EMFDRV_SetDIBitsToDevice(hdc, - XDest, - YDest, - Width, - Height, - XSrc, - YSrc, - StartScan, - ScanLines, - Bits, - lpbmi, - ColorUse); - } - return 0; - } - } -#endif - cjBmpScanSize = DIB_BitmapMaxBitsSize((LPBITMAPINFO)lpbmi, ScanLines); - - if ( Bits ) - { - pvSafeBits = RtlAllocateHeap(GetProcessHeap(), 0, cjBmpScanSize); - if (pvSafeBits) - RtlCopyMemory( pvSafeBits, Bits, cjBmpScanSize); - } - - if (!GdiGetHandleUserData(hdc, GDI_OBJECT_TYPE_DC, (PVOID)&pDc_Attr)) - { - SetLastError(ERROR_INVALID_PARAMETER); - return 0; - } -/* - if ( !pDc_Attr || - ((pConvertedInfo->bmiHeader.biSize >= sizeof(BITMAPINFOHEADER)) && - (pConvertedInfo->bmiHeader.biCompression == BI_JPEG || - pConvertedInfo->bmiHeader.biCompression == BI_PNG )) )*/ - { - LinesCopied = NtGdiSetDIBitsToDeviceInternal( hdc, + if (GDI_HANDLE_GET_TYPE(hdc) != GDI_OBJECT_TYPE_DC) + { + if (GDI_HANDLE_GET_TYPE(hdc) == GDI_OBJECT_TYPE_METADC) + return MFDRV_SetDIBitsToDevice( hdc, + XDest, + YDest, + Width, + Height, + XSrc, + YSrc, + StartScan, + ScanLines, + Bits, + lpbmi, + ColorUse); + else + { + PLDC pLDC = GdiGetLDC(hdc); + if ( !pLDC ) + { + SetLastError(ERROR_INVALID_HANDLE); + return 0; + } + if (pLDC->iType == LDC_EMFLDC) + { + return EMFDRV_SetDIBitsToDevice(hdc, XDest, YDest, Width, - Height, - XSrc, - YSrc, - StartScan, - ScanLines, - (LPBYTE)pvSafeBits, - (LPBITMAPINFO)pConvertedInfo, - ColorUse, - cjBmpScanSize, - ConvertedInfoSize, - TRUE, - NULL); - } - if ( Bits != pvSafeBits) - RtlFreeHeap(RtlGetProcessHeap(), 0, pvSafeBits); - if (lpbmi != pConvertedInfo) - RtlFreeHeap(RtlGetProcessHeap(), 0, pConvertedInfo); + Height, + XSrc, + YSrc, + StartScan, + ScanLines, + Bits, + lpbmi, + ColorUse); + } + return 0; + } + } +#endif + cjBmpScanSize = DIB_BitmapMaxBitsSize((LPBITMAPINFO)lpbmi, ScanLines); - return LinesCopied; + if ( Bits ) + { + pvSafeBits = RtlAllocateHeap(GetProcessHeap(), 0, cjBmpScanSize); + if (pvSafeBits) + RtlCopyMemory( pvSafeBits, Bits, cjBmpScanSize); + } + + if (!GdiGetHandleUserData(hdc, GDI_OBJECT_TYPE_DC, (PVOID)&pDc_Attr)) + { + SetLastError(ERROR_INVALID_PARAMETER); + return 0; + } + /* + if ( !pDc_Attr || + ((pConvertedInfo->bmiHeader.biSize >= sizeof(BITMAPINFOHEADER)) && + (pConvertedInfo->bmiHeader.biCompression == BI_JPEG || + pConvertedInfo->bmiHeader.biCompression == BI_PNG )) )*/ + { + LinesCopied = NtGdiSetDIBitsToDeviceInternal( hdc, + XDest, + YDest, + Width, + Height, + XSrc, + YSrc, + StartScan, + ScanLines, + (LPBYTE)pvSafeBits, + (LPBITMAPINFO)pConvertedInfo, + ColorUse, + cjBmpScanSize, + ConvertedInfoSize, + TRUE, + NULL); + } + if ( Bits != pvSafeBits) + RtlFreeHeap(RtlGetProcessHeap(), 0, pvSafeBits); + if (lpbmi != pConvertedInfo) + RtlFreeHeap(RtlGetProcessHeap(), 0, pConvertedInfo); + + return LinesCopied; } @@ -825,128 +826,128 @@ StretchDIBits(HDC hdc, DWORD dwRop) { - PDC_ATTR pDc_Attr; - PBITMAPINFO pConvertedInfo = NULL; - UINT ConvertedInfoSize = 0; - INT LinesCopied = 0; - UINT cjBmpScanSize = 0; - PVOID pvSafeBits = NULL; - BOOL Hit = FALSE; + PDC_ATTR pDc_Attr; + PBITMAPINFO pConvertedInfo = NULL; + UINT ConvertedInfoSize = 0; + INT LinesCopied = 0; + UINT cjBmpScanSize = 0; + PVOID pvSafeBits = NULL; + BOOL Hit = FALSE; - DPRINT("StretchDIBits %x : %x : %d\n", lpBits, lpBitsInfo, iUsage); + DPRINT("StretchDIBits %x : %x : %d\n", lpBits, lpBitsInfo, iUsage); #if 0 // Handle something other than a normal dc object. - if (GDI_HANDLE_GET_TYPE(hdc) != GDI_OBJECT_TYPE_DC) - { - if (GDI_HANDLE_GET_TYPE(hdc) == GDI_OBJECT_TYPE_METADC) - return MFDRV_StretchBlt( hdc, - XDest, - YDest, - nDestWidth, - nDestHeight, - XSrc, - YSrc, - nSrcWidth, - nSrcHeight, - lpBits, - lpBitsInfo, - iUsage, - dwRop); - else + if (GDI_HANDLE_GET_TYPE(hdc) != GDI_OBJECT_TYPE_DC) { - PLDC pLDC = GdiGetLDC(hdc); - if ( !pLDC ) - { - SetLastError(ERROR_INVALID_HANDLE); - return 0; - } - if (pLDC->iType == LDC_EMFLDC) - { - return EMFDRV_StretchBlt(hdc, - XDest, - YDest, - nDestWidth, - nDestHeight, - XSrc, - YSrc, - nSrcWidth, - nSrcHeight, - lpBits, - lpBitsInfo, - iUsage, - dwRop); - } - return 0; + if (GDI_HANDLE_GET_TYPE(hdc) == GDI_OBJECT_TYPE_METADC) + return MFDRV_StretchBlt( hdc, + XDest, + YDest, + nDestWidth, + nDestHeight, + XSrc, + YSrc, + nSrcWidth, + nSrcHeight, + lpBits, + lpBitsInfo, + iUsage, + dwRop); + else + { + PLDC pLDC = GdiGetLDC(hdc); + if ( !pLDC ) + { + SetLastError(ERROR_INVALID_HANDLE); + return 0; + } + if (pLDC->iType == LDC_EMFLDC) + { + return EMFDRV_StretchBlt(hdc, + XDest, + YDest, + nDestWidth, + nDestHeight, + XSrc, + YSrc, + nSrcWidth, + nSrcHeight, + lpBits, + lpBitsInfo, + iUsage, + dwRop); + } + return 0; + } } - } #endif pConvertedInfo = ConvertBitmapInfo(lpBitsInfo, iUsage, - &ConvertedInfoSize, FALSE); + &ConvertedInfoSize, FALSE); if (!pConvertedInfo) { return 0; } - cjBmpScanSize = DIB_BitmapBitsSize((LPBITMAPINFO)pConvertedInfo); + cjBmpScanSize = DIB_BitmapBitsSize((LPBITMAPINFO)pConvertedInfo); - if ( lpBits ) - { - pvSafeBits = RtlAllocateHeap(GetProcessHeap(), 0, cjBmpScanSize); - if (pvSafeBits) - { - _SEH2_TRY + if ( lpBits ) + { + pvSafeBits = RtlAllocateHeap(GetProcessHeap(), 0, cjBmpScanSize); + if (pvSafeBits) { - RtlCopyMemory( pvSafeBits, lpBits, cjBmpScanSize ); - } - _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) - { - Hit = TRUE; - } - _SEH2_END + _SEH2_TRY + { + RtlCopyMemory( pvSafeBits, lpBits, cjBmpScanSize ); + } + _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) + { + Hit = TRUE; + } + _SEH2_END - if (Hit) - { - // We don't die, we continue on with a allocated safe pointer to kernel - // space..... - DPRINT1("StretchDIBits fail to read BitMapInfo: %x or Bits: %x & Size: %d\n",pConvertedInfo,lpBits,cjBmpScanSize); + if (Hit) + { + // We don't die, we continue on with a allocated safe pointer to kernel + // space..... + DPRINT1("StretchDIBits fail to read BitMapInfo: %x or Bits: %x & Size: %d\n",pConvertedInfo,lpBits,cjBmpScanSize); + } + DPRINT("StretchDIBits Allocate Bits %d!!!\n", cjBmpScanSize); } - DPRINT("StretchDIBits Allocate Bits %d!!!\n", cjBmpScanSize); - } - } + } - if (!GdiGetHandleUserData(hdc, GDI_OBJECT_TYPE_DC, (PVOID)&pDc_Attr)) - { - SetLastError(ERROR_INVALID_PARAMETER); - return 0; - } -/* - if ( !pDc_Attr || - ((pConvertedInfo->bmiHeader.biSize >= sizeof(BITMAPINFOHEADER)) && - (pConvertedInfo->bmiHeader.biCompression == BI_JPEG || - pConvertedInfo->bmiHeader.biCompression == BI_PNG )) )*/ - { - LinesCopied = NtGdiStretchDIBitsInternal( hdc, - XDest, - YDest, - nDestWidth, - nDestHeight, - XSrc, - YSrc, - nSrcWidth, - nSrcHeight, - pvSafeBits, - pConvertedInfo, - (DWORD)iUsage, - dwRop, - ConvertedInfoSize, - cjBmpScanSize, - NULL); - } - if ( pvSafeBits ) - RtlFreeHeap(RtlGetProcessHeap(), 0, pvSafeBits); - if (lpBitsInfo != pConvertedInfo) - RtlFreeHeap(RtlGetProcessHeap(), 0, pConvertedInfo); + if (!GdiGetHandleUserData(hdc, GDI_OBJECT_TYPE_DC, (PVOID)&pDc_Attr)) + { + SetLastError(ERROR_INVALID_PARAMETER); + return 0; + } + /* + if ( !pDc_Attr || + ((pConvertedInfo->bmiHeader.biSize >= sizeof(BITMAPINFOHEADER)) && + (pConvertedInfo->bmiHeader.biCompression == BI_JPEG || + pConvertedInfo->bmiHeader.biCompression == BI_PNG )) )*/ + { + LinesCopied = NtGdiStretchDIBitsInternal( hdc, + XDest, + YDest, + nDestWidth, + nDestHeight, + XSrc, + YSrc, + nSrcWidth, + nSrcHeight, + pvSafeBits, + pConvertedInfo, + (DWORD)iUsage, + dwRop, + ConvertedInfoSize, + cjBmpScanSize, + NULL); + } + if ( pvSafeBits ) + RtlFreeHeap(RtlGetProcessHeap(), 0, pvSafeBits); + if (lpBitsInfo != pConvertedInfo) + RtlFreeHeap(RtlGetProcessHeap(), 0, pConvertedInfo); - return LinesCopied; + return LinesCopied; } diff --git a/reactos/dll/win32/gdi32/objects/brush.c b/reactos/dll/win32/gdi32/objects/brush.c index dd4d305b0e8..185bed6c3fb 100644 --- a/reactos/dll/win32/gdi32/objects/brush.c +++ b/reactos/dll/win32/gdi32/objects/brush.c @@ -16,95 +16,95 @@ ExtCreatePen(DWORD dwPenStyle, DWORD dwStyleCount, CONST DWORD *lpStyle) { - PVOID lpPackedDIB = NULL; - HPEN hPen = NULL; - PBITMAPINFO pConvertedInfo = NULL; - UINT ConvertedInfoSize = 0, lbStyle; - BOOL Hit = FALSE; + PVOID lpPackedDIB = NULL; + HPEN hPen = NULL; + PBITMAPINFO pConvertedInfo = NULL; + UINT ConvertedInfoSize = 0, lbStyle; + BOOL Hit = FALSE; - if ((dwPenStyle & PS_STYLE_MASK) == PS_USERSTYLE) - { - if(!lpStyle) - { - SetLastError(ERROR_INVALID_PARAMETER); - return 0; - } - } // This is an enhancement and prevents a call to kernel space. - else if ((dwPenStyle & PS_STYLE_MASK) == PS_INSIDEFRAME && - (dwPenStyle & PS_TYPE_MASK) != PS_GEOMETRIC) - { - SetLastError(ERROR_INVALID_PARAMETER); - return 0; - } - else if ((dwPenStyle & PS_STYLE_MASK) == PS_ALTERNATE && - (dwPenStyle & PS_TYPE_MASK) != PS_COSMETIC) - { - SetLastError(ERROR_INVALID_PARAMETER); - return 0; - } - else - { - if (dwStyleCount || lpStyle) - { - SetLastError(ERROR_INVALID_PARAMETER); - return 0; - } - } + if ((dwPenStyle & PS_STYLE_MASK) == PS_USERSTYLE) + { + if(!lpStyle) + { + SetLastError(ERROR_INVALID_PARAMETER); + return 0; + } + } // This is an enhancement and prevents a call to kernel space. + else if ((dwPenStyle & PS_STYLE_MASK) == PS_INSIDEFRAME && + (dwPenStyle & PS_TYPE_MASK) != PS_GEOMETRIC) + { + SetLastError(ERROR_INVALID_PARAMETER); + return 0; + } + else if ((dwPenStyle & PS_STYLE_MASK) == PS_ALTERNATE && + (dwPenStyle & PS_TYPE_MASK) != PS_COSMETIC) + { + SetLastError(ERROR_INVALID_PARAMETER); + return 0; + } + else + { + if (dwStyleCount || lpStyle) + { + SetLastError(ERROR_INVALID_PARAMETER); + return 0; + } + } - lbStyle = lplb->lbStyle; + lbStyle = lplb->lbStyle; - if (lplb->lbStyle > BS_HATCHED) - { - if (lplb->lbStyle == BS_PATTERN) - { - pConvertedInfo = (PBITMAPINFO)lplb->lbHatch; - if (!pConvertedInfo) return 0; - } - else - { - if ((lplb->lbStyle == BS_DIBPATTERN) || (lplb->lbStyle == BS_DIBPATTERNPT)) - { - if (lplb->lbStyle == BS_DIBPATTERN) + if (lplb->lbStyle > BS_HATCHED) + { + if (lplb->lbStyle == BS_PATTERN) + { + pConvertedInfo = (PBITMAPINFO)lplb->lbHatch; + if (!pConvertedInfo) return 0; + } + else + { + if ((lplb->lbStyle == BS_DIBPATTERN) || (lplb->lbStyle == BS_DIBPATTERNPT)) { - lbStyle = BS_DIBPATTERNPT; - lpPackedDIB = GlobalLock((HGLOBAL)lplb->lbHatch); - if (lpPackedDIB == NULL) return 0; + if (lplb->lbStyle == BS_DIBPATTERN) + { + lbStyle = BS_DIBPATTERNPT; + lpPackedDIB = GlobalLock((HGLOBAL)lplb->lbHatch); + if (lpPackedDIB == NULL) return 0; + } + pConvertedInfo = ConvertBitmapInfo((PBITMAPINFO)lpPackedDIB, + lplb->lbColor, + &ConvertedInfoSize, + TRUE); + Hit = TRUE; // We converted DIB. } - pConvertedInfo = ConvertBitmapInfo((PBITMAPINFO)lpPackedDIB, - lplb->lbColor, - &ConvertedInfoSize, - TRUE); - Hit = TRUE; // We converted DIB. - } - else - pConvertedInfo = (PBITMAPINFO)lpStyle; - } - } - else - pConvertedInfo = (PBITMAPINFO)lplb->lbHatch; - - - hPen = NtGdiExtCreatePen(dwPenStyle, - dwWidth, - lbStyle, - lplb->lbColor, - lplb->lbHatch, - (ULONG_PTR)pConvertedInfo, - dwStyleCount, - (PULONG)lpStyle, - ConvertedInfoSize, - FALSE, - NULL); + else + pConvertedInfo = (PBITMAPINFO)lpStyle; + } + } + else + pConvertedInfo = (PBITMAPINFO)lplb->lbHatch; - if (lplb->lbStyle == BS_DIBPATTERN) GlobalUnlock((HGLOBAL)lplb->lbHatch); + hPen = NtGdiExtCreatePen(dwPenStyle, + dwWidth, + lbStyle, + lplb->lbColor, + lplb->lbHatch, + (ULONG_PTR)pConvertedInfo, + dwStyleCount, + (PULONG)lpStyle, + ConvertedInfoSize, + FALSE, + NULL); - if (Hit) - { - if ((PBITMAPINFO)lpPackedDIB != pConvertedInfo) - RtlFreeHeap(RtlGetProcessHeap(), 0, pConvertedInfo); - } - return hPen; + + if (lplb->lbStyle == BS_DIBPATTERN) GlobalUnlock((HGLOBAL)lplb->lbHatch); + + if (Hit) + { + if ((PBITMAPINFO)lpPackedDIB != pConvertedInfo) + RtlFreeHeap(RtlGetProcessHeap(), 0, pConvertedInfo); + } + return hPen; } /* @@ -112,31 +112,31 @@ ExtCreatePen(DWORD dwPenStyle, */ HBRUSH WINAPI CreateDIBPatternBrush( - HGLOBAL hglbDIBPacked, - UINT fuColorSpec) + HGLOBAL hglbDIBPacked, + UINT fuColorSpec) { - PVOID lpPackedDIB; - HBRUSH hBrush = NULL; - PBITMAPINFO pConvertedInfo; - UINT ConvertedInfoSize; + PVOID lpPackedDIB; + HBRUSH hBrush = NULL; + PBITMAPINFO pConvertedInfo; + UINT ConvertedInfoSize; - lpPackedDIB = GlobalLock(hglbDIBPacked); - if (lpPackedDIB == NULL) - return 0; + lpPackedDIB = GlobalLock(hglbDIBPacked); + if (lpPackedDIB == NULL) + return 0; - pConvertedInfo = ConvertBitmapInfo((PBITMAPINFO)lpPackedDIB, fuColorSpec, - &ConvertedInfoSize, TRUE); - if (pConvertedInfo) - { - hBrush = NtGdiCreateDIBBrush(pConvertedInfo, fuColorSpec, - ConvertedInfoSize, FALSE, FALSE, lpPackedDIB); - if ((PBITMAPINFO)lpPackedDIB != pConvertedInfo) - RtlFreeHeap(RtlGetProcessHeap(), 0, pConvertedInfo); - } + pConvertedInfo = ConvertBitmapInfo((PBITMAPINFO)lpPackedDIB, fuColorSpec, + &ConvertedInfoSize, TRUE); + if (pConvertedInfo) + { + hBrush = NtGdiCreateDIBBrush(pConvertedInfo, fuColorSpec, + ConvertedInfoSize, FALSE, FALSE, lpPackedDIB); + if ((PBITMAPINFO)lpPackedDIB != pConvertedInfo) + RtlFreeHeap(RtlGetProcessHeap(), 0, pConvertedInfo); + } - GlobalUnlock(hglbDIBPacked); + GlobalUnlock(hglbDIBPacked); - return hBrush; + return hBrush; } /* @@ -144,27 +144,27 @@ CreateDIBPatternBrush( */ HBRUSH WINAPI CreateDIBPatternBrushPt( - CONST VOID *lpPackedDIB, - UINT fuColorSpec) + CONST VOID *lpPackedDIB, + UINT fuColorSpec) { - HBRUSH hBrush = NULL; - PBITMAPINFO pConvertedInfo; - UINT ConvertedInfoSize; + HBRUSH hBrush = NULL; + PBITMAPINFO pConvertedInfo; + UINT ConvertedInfoSize; - if (lpPackedDIB == NULL) - return 0; + if (lpPackedDIB == NULL) + return 0; - pConvertedInfo = ConvertBitmapInfo((PBITMAPINFO)lpPackedDIB, fuColorSpec, - &ConvertedInfoSize, TRUE); - if (pConvertedInfo) - { - hBrush = NtGdiCreateDIBBrush(pConvertedInfo, fuColorSpec, - ConvertedInfoSize, FALSE, FALSE, (PVOID)lpPackedDIB); - if ((PBITMAPINFO)lpPackedDIB != pConvertedInfo) - RtlFreeHeap(RtlGetProcessHeap(), 0, pConvertedInfo); - } + pConvertedInfo = ConvertBitmapInfo((PBITMAPINFO)lpPackedDIB, fuColorSpec, + &ConvertedInfoSize, TRUE); + if (pConvertedInfo) + { + hBrush = NtGdiCreateDIBBrush(pConvertedInfo, fuColorSpec, + ConvertedInfoSize, FALSE, FALSE, (PVOID)lpPackedDIB); + if ((PBITMAPINFO)lpPackedDIB != pConvertedInfo) + RtlFreeHeap(RtlGetProcessHeap(), 0, pConvertedInfo); + } - return hBrush; + return hBrush; } /* @@ -204,56 +204,56 @@ CreateSolidBrush(IN COLORREF crColor) */ HBRUSH WINAPI CreateBrushIndirect( - CONST LOGBRUSH *LogBrush) + CONST LOGBRUSH *LogBrush) { - HBRUSH hBrush; + HBRUSH hBrush; - switch (LogBrush->lbStyle) - { - case BS_DIBPATTERN8X8: - case BS_DIBPATTERN: - hBrush = CreateDIBPatternBrush((HGLOBAL)LogBrush->lbHatch, - LogBrush->lbColor); - break; + switch (LogBrush->lbStyle) + { + case BS_DIBPATTERN8X8: + case BS_DIBPATTERN: + hBrush = CreateDIBPatternBrush((HGLOBAL)LogBrush->lbHatch, + LogBrush->lbColor); + break; - case BS_DIBPATTERNPT: - hBrush = CreateDIBPatternBrushPt((PVOID)LogBrush->lbHatch, - LogBrush->lbColor); - break; + case BS_DIBPATTERNPT: + hBrush = CreateDIBPatternBrushPt((PVOID)LogBrush->lbHatch, + LogBrush->lbColor); + break; - case BS_PATTERN: - hBrush = NtGdiCreatePatternBrushInternal((HBITMAP)LogBrush->lbHatch, - FALSE, - FALSE); - break; + case BS_PATTERN: + hBrush = NtGdiCreatePatternBrushInternal((HBITMAP)LogBrush->lbHatch, + FALSE, + FALSE); + break; - case BS_PATTERN8X8: - hBrush = NtGdiCreatePatternBrushInternal((HBITMAP)LogBrush->lbHatch, - FALSE, - TRUE); - break; + case BS_PATTERN8X8: + hBrush = NtGdiCreatePatternBrushInternal((HBITMAP)LogBrush->lbHatch, + FALSE, + TRUE); + break; - case BS_SOLID: - hBrush = NtGdiCreateSolidBrush(LogBrush->lbColor, 0); - break; + case BS_SOLID: + hBrush = NtGdiCreateSolidBrush(LogBrush->lbColor, 0); + break; - case BS_HATCHED: - hBrush = NtGdiCreateHatchBrushInternal(LogBrush->lbHatch, - LogBrush->lbColor, - FALSE); - break; + case BS_HATCHED: + hBrush = NtGdiCreateHatchBrushInternal(LogBrush->lbHatch, + LogBrush->lbColor, + FALSE); + break; - case BS_NULL: - hBrush = NtGdiGetStockObject(NULL_BRUSH); - break; + case BS_NULL: + hBrush = NtGdiGetStockObject(NULL_BRUSH); + break; - default: - SetLastError(ERROR_INVALID_PARAMETER); - hBrush = NULL; - break; - } + default: + SetLastError(ERROR_INVALID_PARAMETER); + hBrush = NULL; + break; + } - return hBrush; + return hBrush; } BOOL @@ -289,9 +289,9 @@ int WINAPI GetROP2(HDC hdc) { - PDC_ATTR Dc_Attr; - if (!GdiGetHandleUserData((HGDIOBJ) hdc, GDI_OBJECT_TYPE_DC, (PVOID) &Dc_Attr)) return 0; - return Dc_Attr->jROP2; + PDC_ATTR Dc_Attr; + if (!GdiGetHandleUserData((HGDIOBJ) hdc, GDI_OBJECT_TYPE_DC, (PVOID) &Dc_Attr)) return 0; + return Dc_Attr->jROP2; } /* @@ -302,46 +302,46 @@ WINAPI SetROP2(HDC hdc, int fnDrawMode) { - PDC_ATTR Dc_Attr; - INT Old_ROP2; - + PDC_ATTR Dc_Attr; + INT Old_ROP2; + #if 0 // Handle something other than a normal dc object. - if (GDI_HANDLE_GET_TYPE(hdc) != GDI_OBJECT_TYPE_DC) - { - if (GDI_HANDLE_GET_TYPE(hdc) == GDI_OBJECT_TYPE_METADC) - return MFDRV_SetROP2( hdc, fnDrawMode); - else + if (GDI_HANDLE_GET_TYPE(hdc) != GDI_OBJECT_TYPE_DC) { - PLDC pLDC = GdiGetLDC(hdc); - if ( !pLDC ) - { - SetLastError(ERROR_INVALID_HANDLE); - return FALSE; - } - if (pLDC->iType == LDC_EMFLDC) - { - return EMFDRV_SetROP2(( hdc, fnDrawMode); - } - return FALSE; + if (GDI_HANDLE_GET_TYPE(hdc) == GDI_OBJECT_TYPE_METADC) + return MFDRV_SetROP2( hdc, fnDrawMode); + else + { + PLDC pLDC = GdiGetLDC(hdc); + if ( !pLDC ) + { + SetLastError(ERROR_INVALID_HANDLE); + return FALSE; + } + if (pLDC->iType == LDC_EMFLDC) + { + return EMFDRV_SetROP2(( hdc, fnDrawMode); + } + return FALSE; + } } - } #endif - if (!GdiGetHandleUserData((HGDIOBJ) hdc, GDI_OBJECT_TYPE_DC, (PVOID) &Dc_Attr)) return FALSE; + if (!GdiGetHandleUserData((HGDIOBJ) hdc, GDI_OBJECT_TYPE_DC, (PVOID) &Dc_Attr)) return FALSE; - if (NtCurrentTeb()->GdiTebBatch.HDC == hdc) - { - if (Dc_Attr->ulDirty_ & DC_MODE_DIRTY) + if (NtCurrentTeb()->GdiTebBatch.HDC == hdc) { - NtGdiFlush(); - Dc_Attr->ulDirty_ &= ~DC_MODE_DIRTY; + if (Dc_Attr->ulDirty_ & DC_MODE_DIRTY) + { + NtGdiFlush(); + Dc_Attr->ulDirty_ &= ~DC_MODE_DIRTY; + } } - } - Old_ROP2 = Dc_Attr->jROP2; - Dc_Attr->jROP2 = fnDrawMode; + Old_ROP2 = Dc_Attr->jROP2; + Dc_Attr->jROP2 = fnDrawMode; - return Old_ROP2; + return Old_ROP2; } /* @@ -352,15 +352,15 @@ BOOL WINAPI GetBrushOrgEx(HDC hdc,LPPOINT pt) { - PDC_ATTR Dc_Attr; + PDC_ATTR Dc_Attr; - if (!GdiGetHandleUserData((HGDIOBJ) hdc, GDI_OBJECT_TYPE_DC, (PVOID) &Dc_Attr)) return FALSE; - if (pt) - { - pt->x = Dc_Attr->ptlBrushOrigin.x; - pt->y = Dc_Attr->ptlBrushOrigin.y; - } - return TRUE; + if (!GdiGetHandleUserData((HGDIOBJ) hdc, GDI_OBJECT_TYPE_DC, (PVOID) &Dc_Attr)) return FALSE; + if (pt) + { + pt->x = Dc_Attr->ptlBrushOrigin.x; + pt->y = Dc_Attr->ptlBrushOrigin.y; + } + return TRUE; } /* @@ -373,62 +373,62 @@ SetBrushOrgEx(HDC hdc, int nYOrg, LPPOINT lppt) { - PDC_ATTR Dc_Attr; + PDC_ATTR Dc_Attr; #if 0 // Handle something other than a normal dc object. - if (GDI_HANDLE_GET_TYPE(hdc) != GDI_OBJECT_TYPE_DC) - { - PLDC pLDC = GdiGetLDC(hdc); - if ( (pLDC == NULL) || (GDI_HANDLE_GET_TYPE(hdc) == GDI_OBJECT_TYPE_METADC)) + if (GDI_HANDLE_GET_TYPE(hdc) != GDI_OBJECT_TYPE_DC) { - SetLastError(ERROR_INVALID_HANDLE); - return FALSE; + PLDC pLDC = GdiGetLDC(hdc); + if ( (pLDC == NULL) || (GDI_HANDLE_GET_TYPE(hdc) == GDI_OBJECT_TYPE_METADC)) + { + SetLastError(ERROR_INVALID_HANDLE); + return FALSE; + } + if (pLDC->iType == LDC_EMFLDC) + { + return EMFDRV_SetBrushOrg(hdc, nXOrg, nYOrg); // ReactOS only. + } + return FALSE; } - if (pLDC->iType == LDC_EMFLDC) - { - return EMFDRV_SetBrushOrg(hdc, nXOrg, nYOrg); // ReactOS only. - } - return FALSE; - } #endif - if (GdiGetHandleUserData((HGDIOBJ) hdc, GDI_OBJECT_TYPE_DC, (PVOID) &Dc_Attr)) - { - PTEB pTeb = NtCurrentTeb(); - if (lppt) + if (GdiGetHandleUserData((HGDIOBJ) hdc, GDI_OBJECT_TYPE_DC, (PVOID) &Dc_Attr)) { - lppt->x = Dc_Attr->ptlBrushOrigin.x; - lppt->y = Dc_Attr->ptlBrushOrigin.y; + PTEB pTeb = NtCurrentTeb(); + if (lppt) + { + lppt->x = Dc_Attr->ptlBrushOrigin.x; + lppt->y = Dc_Attr->ptlBrushOrigin.y; + } + if ((nXOrg == Dc_Attr->ptlBrushOrigin.x) && (nYOrg == Dc_Attr->ptlBrushOrigin.y)) + return TRUE; + + if(((pTeb->GdiTebBatch.HDC == NULL) || (pTeb->GdiTebBatch.HDC == hdc)) && + ((pTeb->GdiTebBatch.Offset + sizeof(GDIBSSETBRHORG)) <= GDIBATCHBUFSIZE) && + (!(Dc_Attr->ulDirty_ & DC_DIBSECTION)) ) + { + PGDIBSSETBRHORG pgSBO = (PGDIBSSETBRHORG)(&pTeb->GdiTebBatch.Buffer[0] + + pTeb->GdiTebBatch.Offset); + + Dc_Attr->ptlBrushOrigin.x = nXOrg; + Dc_Attr->ptlBrushOrigin.y = nYOrg; + + pgSBO->gbHdr.Cmd = GdiBCSetBrushOrg; + pgSBO->gbHdr.Size = sizeof(GDIBSSETBRHORG); + pgSBO->ptlBrushOrigin = Dc_Attr->ptlBrushOrigin; + + pTeb->GdiTebBatch.Offset += sizeof(GDIBSSETBRHORG); + pTeb->GdiTebBatch.HDC = hdc; + pTeb->GdiBatchCount++; + DPRINT("Loading the Flush!! COUNT-> %d\n", pTeb->GdiBatchCount); + + if (pTeb->GdiBatchCount >= GDI_BatchLimit) + { + DPRINT("Call GdiFlush!!\n"); + NtGdiFlush(); + DPRINT("Exit GdiFlush!!\n"); + } + return TRUE; + } } - if ((nXOrg == Dc_Attr->ptlBrushOrigin.x) && (nYOrg == Dc_Attr->ptlBrushOrigin.y)) - return TRUE; - - if(((pTeb->GdiTebBatch.HDC == NULL) || (pTeb->GdiTebBatch.HDC == hdc)) && - ((pTeb->GdiTebBatch.Offset + sizeof(GDIBSSETBRHORG)) <= GDIBATCHBUFSIZE) && - (!(Dc_Attr->ulDirty_ & DC_DIBSECTION)) ) - { - PGDIBSSETBRHORG pgSBO = (PGDIBSSETBRHORG)(&pTeb->GdiTebBatch.Buffer[0] + - pTeb->GdiTebBatch.Offset); - - Dc_Attr->ptlBrushOrigin.x = nXOrg; - Dc_Attr->ptlBrushOrigin.y = nYOrg; - - pgSBO->gbHdr.Cmd = GdiBCSetBrushOrg; - pgSBO->gbHdr.Size = sizeof(GDIBSSETBRHORG); - pgSBO->ptlBrushOrigin = Dc_Attr->ptlBrushOrigin; - - pTeb->GdiTebBatch.Offset += sizeof(GDIBSSETBRHORG); - pTeb->GdiTebBatch.HDC = hdc; - pTeb->GdiBatchCount++; - DPRINT("Loading the Flush!! COUNT-> %d\n", pTeb->GdiBatchCount); - - if (pTeb->GdiBatchCount >= GDI_BatchLimit) - { - DPRINT("Call GdiFlush!!\n"); - NtGdiFlush(); - DPRINT("Exit GdiFlush!!\n"); - } - return TRUE; - } - } - return NtGdiSetBrushOrg(hdc,nXOrg,nYOrg,lppt); + return NtGdiSetBrushOrg(hdc,nXOrg,nYOrg,lppt); } diff --git a/reactos/dll/win32/gdi32/objects/coord.c b/reactos/dll/win32/gdi32/objects/coord.c index 866108530b9..9f89ae1c89a 100644 --- a/reactos/dll/win32/gdi32/objects/coord.c +++ b/reactos/dll/win32/gdi32/objects/coord.c @@ -22,71 +22,71 @@ LONG FASTCALL EFtoF( EFLOAT_S * efp) { - long Mant, Exp, Sign = 0; + long Mant, Exp, Sign = 0; - if (!efp->lMant) return 0; + if (!efp->lMant) return 0; - Mant = efp->lMant; - Exp = efp->lExp; - Sign = SIGN(Mant); + Mant = efp->lMant; + Exp = efp->lExp; + Sign = SIGN(Mant); //// M$ storage emulation - if( Sign ) Mant = -Mant; - Mant = ((Mant & 0x3fffffff) >> 7); - Exp += (EXCESS-1); + if( Sign ) Mant = -Mant; + Mant = ((Mant & 0x3fffffff) >> 7); + Exp += (EXCESS-1); //// - Mant = MANT(Mant); - return PACK(Sign, Exp, Mant); + Mant = MANT(Mant); + return PACK(Sign, Exp, Mant); } VOID FASTCALL FtoEF( EFLOAT_S * efp, FLOATL f) { - long Mant, Exp, Sign = 0; - gxf_long worker; + long Mant, Exp, Sign = 0; + gxf_long worker; #ifdef _X86_ - worker.l = f; // It's a float stored in a long. + worker.l = f; // It's a float stored in a long. #else - worker.f = f; + worker.f = f; #endif - Exp = EXP(worker.l); - Mant = MANT(worker.l); - if (SIGN(worker.l)) Sign = -1; + Exp = EXP(worker.l); + Mant = MANT(worker.l); + if (SIGN(worker.l)) Sign = -1; //// M$ storage emulation - Mant = ((Mant << 7) | 0x40000000); - Mant ^= Sign; - Mant -= Sign; - Exp -= (EXCESS-1); + Mant = ((Mant << 7) | 0x40000000); + Mant ^= Sign; + Mant -= Sign; + Exp -= (EXCESS-1); //// - efp->lMant = Mant; - efp->lExp = Exp; + efp->lMant = Mant; + efp->lExp = Exp; } VOID FASTCALL CoordCnvP(MATRIX_S * mx, LPPOINT Point) { - FLOAT x, y; - gxf_long a, b, c; + FLOAT x, y; + gxf_long a, b, c; - x = (FLOAT)Point->x; - y = (FLOAT)Point->y; + x = (FLOAT)Point->x; + y = (FLOAT)Point->y; - a.l = EFtoF( &mx->efM11 ); - b.l = EFtoF( &mx->efM21 ); - c.l = EFtoF( &mx->efDx ); - x = x * a.f + y * b.f + c.f; + a.l = EFtoF( &mx->efM11 ); + b.l = EFtoF( &mx->efM21 ); + c.l = EFtoF( &mx->efDx ); + x = x * a.f + y * b.f + c.f; - a.l = EFtoF( &mx->efM12 ); - b.l = EFtoF( &mx->efM22 ); - c.l = EFtoF( &mx->efDy ); - y = x * a.f + y * b.f + c.f; + a.l = EFtoF( &mx->efM12 ); + b.l = EFtoF( &mx->efM22 ); + c.l = EFtoF( &mx->efDy ); + y = x * a.f + y * b.f + c.f; - FLOAT_TO_INT(x, Point->x ); - FLOAT_TO_INT(y, Point->y ); + FLOAT_TO_INT(x, Point->x ); + FLOAT_TO_INT(y, Point->y ); } @@ -95,24 +95,24 @@ WINAPI DPtoLP ( HDC hDC, LPPOINT Points, INT Count ) { #if 0 - INT i; - PDC_ATTR Dc_Attr; + INT i; + PDC_ATTR Dc_Attr; - if (!GdiGetHandleUserData((HGDIOBJ) hDC, GDI_OBJECT_TYPE_DC, (PVOID) &Dc_Attr)) return FALSE; + if (!GdiGetHandleUserData((HGDIOBJ) hDC, GDI_OBJECT_TYPE_DC, (PVOID) &Dc_Attr)) return FALSE; - if (Dc_Attr->flXform & ( DEVICE_TO_WORLD_INVALID | // Force a full recalibration! - PAGE_XLATE_CHANGED | // Changes or Updates have been made, - PAGE_EXTENTS_CHANGED | // do processing in kernel space. - WORLD_XFORM_CHANGED )) + if (Dc_Attr->flXform & ( DEVICE_TO_WORLD_INVALID | // Force a full recalibration! + PAGE_XLATE_CHANGED | // Changes or Updates have been made, + PAGE_EXTENTS_CHANGED | // do processing in kernel space. + WORLD_XFORM_CHANGED )) #endif - return NtGdiTransformPoints( hDC, Points, Points, Count, GdiDpToLp); // DPtoLP mode. + return NtGdiTransformPoints( hDC, Points, Points, Count, GdiDpToLp); // DPtoLP mode. #if 0 - else - { - for ( i = 0; i < Count; i++ ) - CoordCnvP ( &Dc_Attr->mxDeviceToWorld, &Points[i] ); - } - return TRUE; + else + { + for ( i = 0; i < Count; i++ ) + CoordCnvP ( &Dc_Attr->mxDeviceToWorld, &Points[i] ); + } + return TRUE; #endif } @@ -122,23 +122,23 @@ WINAPI LPtoDP ( HDC hDC, LPPOINT Points, INT Count ) { #if 0 - INT i; - PDC_ATTR Dc_Attr; + INT i; + PDC_ATTR Dc_Attr; - if (!GdiGetHandleUserData((HGDIOBJ) hDC, GDI_OBJECT_TYPE_DC, (PVOID) &Dc_Attr)) return FALSE; + if (!GdiGetHandleUserData((HGDIOBJ) hDC, GDI_OBJECT_TYPE_DC, (PVOID) &Dc_Attr)) return FALSE; - if (Dc_Attr->flXform & ( PAGE_XLATE_CHANGED | // Check for Changes and Updates - PAGE_EXTENTS_CHANGED | - WORLD_XFORM_CHANGED )) + if (Dc_Attr->flXform & ( PAGE_XLATE_CHANGED | // Check for Changes and Updates + PAGE_EXTENTS_CHANGED | + WORLD_XFORM_CHANGED )) #endif - return NtGdiTransformPoints( hDC, Points, Points, Count, GdiLpToDp); // LPtoDP mode + return NtGdiTransformPoints( hDC, Points, Points, Count, GdiLpToDp); // LPtoDP mode #if 0 - else - { - for ( i = 0; i < Count; i++ ) - CoordCnvP ( &Dc_Attr->mxWorldToDevice, &Points[i] ); - } - return TRUE; + else + { + for ( i = 0; i < Count; i++ ) + CoordCnvP ( &Dc_Attr->mxWorldToDevice, &Points[i] ); + } + return TRUE; #endif } @@ -151,33 +151,33 @@ WINAPI GetCurrentPositionEx(HDC hdc, LPPOINT lpPoint) { - PDC_ATTR Dc_Attr; + PDC_ATTR Dc_Attr; - if (!GdiGetHandleUserData((HGDIOBJ) hdc, GDI_OBJECT_TYPE_DC, (PVOID) &Dc_Attr)) return FALSE; + if (!GdiGetHandleUserData((HGDIOBJ) hdc, GDI_OBJECT_TYPE_DC, (PVOID) &Dc_Attr)) return FALSE; - if ( lpPoint ) - { - if ( Dc_Attr->ulDirty_ & DIRTY_PTLCURRENT ) // have a hit! + if ( lpPoint ) { - lpPoint->x = Dc_Attr->ptfxCurrent.x; - lpPoint->y = Dc_Attr->ptfxCurrent.y; - DPtoLP ( hdc, lpPoint, 1); // reconvert back. - Dc_Attr->ptlCurrent.x = lpPoint->x; // save it - Dc_Attr->ptlCurrent.y = lpPoint->y; - Dc_Attr->ulDirty_ &= ~DIRTY_PTLCURRENT; // clear bit - } + if ( Dc_Attr->ulDirty_ & DIRTY_PTLCURRENT ) // have a hit! + { + lpPoint->x = Dc_Attr->ptfxCurrent.x; + lpPoint->y = Dc_Attr->ptfxCurrent.y; + DPtoLP ( hdc, lpPoint, 1); // reconvert back. + Dc_Attr->ptlCurrent.x = lpPoint->x; // save it + Dc_Attr->ptlCurrent.y = lpPoint->y; + Dc_Attr->ulDirty_ &= ~DIRTY_PTLCURRENT; // clear bit + } + else + { + lpPoint->x = Dc_Attr->ptlCurrent.x; + lpPoint->y = Dc_Attr->ptlCurrent.y; + } + } else { - lpPoint->x = Dc_Attr->ptlCurrent.x; - lpPoint->y = Dc_Attr->ptlCurrent.y; + SetLastError(ERROR_INVALID_PARAMETER); + return FALSE; } - } - else - { - SetLastError(ERROR_INVALID_PARAMETER); - return FALSE; - } - return TRUE; + return TRUE; } /* @@ -187,7 +187,7 @@ BOOL WINAPI GetWorldTransform( HDC hDC, LPXFORM lpXform ) { - return NtGdiGetTransform( hDC, GdiWorldSpaceToPageSpace, lpXform); + return NtGdiGetTransform( hDC, GdiWorldSpaceToPageSpace, lpXform); } @@ -195,126 +195,126 @@ BOOL WINAPI SetWorldTransform( HDC hDC, CONST XFORM *Xform ) { - /* FIXME shall we add undoc #define MWT_SETXFORM 4 ?? */ - return ModifyWorldTransform( hDC, Xform, MWT_MAX+1); + /* FIXME shall we add undoc #define MWT_SETXFORM 4 ?? */ + return ModifyWorldTransform( hDC, Xform, MWT_MAX+1); } BOOL WINAPI ModifyWorldTransform( - HDC hDC, - CONST XFORM *Xform, - DWORD iMode - ) + HDC hDC, + CONST XFORM *Xform, + DWORD iMode +) { #if 0 // Handle something other than a normal dc object. - if (GDI_HANDLE_GET_TYPE(hDC) != GDI_OBJECT_TYPE_DC) - { - if (GDI_HANDLE_GET_TYPE(hDC) == GDI_OBJECT_TYPE_METADC) - return FALSE; - else + if (GDI_HANDLE_GET_TYPE(hDC) != GDI_OBJECT_TYPE_DC) { - PLDC pLDC = GdiGetLDC(hDC); - if ( !pLDC ) - { - SetLastError(ERROR_INVALID_HANDLE); - return FALSE; - } - if (pLDC->iType == LDC_EMFLDC) - { - if (iMode == MWT_MAX+1) - if (!EMFDRV_SetWorldTransform( hDC, Xform) ) return FALSE; - return EMFDRV_ModifyWorldTransform( hDC, Xform, iMode); // Ported from wine. - } - return FALSE; + if (GDI_HANDLE_GET_TYPE(hDC) == GDI_OBJECT_TYPE_METADC) + return FALSE; + else + { + PLDC pLDC = GdiGetLDC(hDC); + if ( !pLDC ) + { + SetLastError(ERROR_INVALID_HANDLE); + return FALSE; + } + if (pLDC->iType == LDC_EMFLDC) + { + if (iMode == MWT_MAX+1) + if (!EMFDRV_SetWorldTransform( hDC, Xform) ) return FALSE; + return EMFDRV_ModifyWorldTransform( hDC, Xform, iMode); // Ported from wine. + } + return FALSE; + } } - } #endif - PDC_ATTR Dc_Attr; + PDC_ATTR Dc_Attr; - if (!GdiGetHandleUserData((HGDIOBJ) hDC, GDI_OBJECT_TYPE_DC, (PVOID) &Dc_Attr)) return FALSE; + if (!GdiGetHandleUserData((HGDIOBJ) hDC, GDI_OBJECT_TYPE_DC, (PVOID) &Dc_Attr)) return FALSE; - /* Check that graphics mode is GM_ADVANCED */ - if ( Dc_Attr->iGraphicsMode != GM_ADVANCED ) return FALSE; + /* Check that graphics mode is GM_ADVANCED */ + if ( Dc_Attr->iGraphicsMode != GM_ADVANCED ) return FALSE; - return NtGdiModifyWorldTransform(hDC, (CONST LPXFORM) Xform, iMode); + return NtGdiModifyWorldTransform(hDC, (CONST LPXFORM) Xform, iMode); } BOOL WINAPI GetViewportExtEx( - HDC hdc, - LPSIZE lpSize - ) + HDC hdc, + LPSIZE lpSize +) { - PDC_ATTR Dc_Attr; + PDC_ATTR Dc_Attr; - if (!GdiGetHandleUserData((HGDIOBJ) hdc, GDI_OBJECT_TYPE_DC, (PVOID) &Dc_Attr)) return FALSE; + if (!GdiGetHandleUserData((HGDIOBJ) hdc, GDI_OBJECT_TYPE_DC, (PVOID) &Dc_Attr)) return FALSE; - if ((Dc_Attr->flXform & PAGE_EXTENTS_CHANGED) && (Dc_Attr->iMapMode == MM_ISOTROPIC)) - // Something was updated, go to kernel. - return NtGdiGetDCPoint( hdc, GdiGetViewPortExt, (PPOINTL) lpSize ); - else - { - lpSize->cx = Dc_Attr->szlViewportExt.cx; - lpSize->cy = Dc_Attr->szlViewportExt.cy; - } - return TRUE; + if ((Dc_Attr->flXform & PAGE_EXTENTS_CHANGED) && (Dc_Attr->iMapMode == MM_ISOTROPIC)) + // Something was updated, go to kernel. + return NtGdiGetDCPoint( hdc, GdiGetViewPortExt, (PPOINTL) lpSize ); + else + { + lpSize->cx = Dc_Attr->szlViewportExt.cx; + lpSize->cy = Dc_Attr->szlViewportExt.cy; + } + return TRUE; } BOOL WINAPI GetViewportOrgEx( - HDC hdc, - LPPOINT lpPoint - ) + HDC hdc, + LPPOINT lpPoint +) { - PDC_ATTR Dc_Attr; + PDC_ATTR Dc_Attr; - if (!GdiGetHandleUserData((HGDIOBJ) hdc, GDI_OBJECT_TYPE_DC, (PVOID) &Dc_Attr)) return FALSE; - lpPoint->x = Dc_Attr->ptlViewportOrg.x; - lpPoint->y = Dc_Attr->ptlViewportOrg.y; - if (Dc_Attr->dwLayout & LAYOUT_RTL) lpPoint->x = -lpPoint->x; - return TRUE; - // return NtGdiGetDCPoint( hdc, GdiGetViewPortOrg, lpPoint ); + if (!GdiGetHandleUserData((HGDIOBJ) hdc, GDI_OBJECT_TYPE_DC, (PVOID) &Dc_Attr)) return FALSE; + lpPoint->x = Dc_Attr->ptlViewportOrg.x; + lpPoint->y = Dc_Attr->ptlViewportOrg.y; + if (Dc_Attr->dwLayout & LAYOUT_RTL) lpPoint->x = -lpPoint->x; + return TRUE; + // return NtGdiGetDCPoint( hdc, GdiGetViewPortOrg, lpPoint ); } BOOL WINAPI GetWindowExtEx( - HDC hdc, - LPSIZE lpSize - ) + HDC hdc, + LPSIZE lpSize +) { - PDC_ATTR Dc_Attr; + PDC_ATTR Dc_Attr; - if (!GdiGetHandleUserData((HGDIOBJ) hdc, GDI_OBJECT_TYPE_DC, (PVOID) &Dc_Attr)) return FALSE; - lpSize->cx = Dc_Attr->szlWindowExt.cx; - lpSize->cy = Dc_Attr->szlWindowExt.cy; - if (Dc_Attr->dwLayout & LAYOUT_RTL) lpSize->cx = -lpSize->cx; - return TRUE; - // return NtGdiGetDCPoint( hdc, GdiGetWindowExt, (LPPOINT) lpSize ); + if (!GdiGetHandleUserData((HGDIOBJ) hdc, GDI_OBJECT_TYPE_DC, (PVOID) &Dc_Attr)) return FALSE; + lpSize->cx = Dc_Attr->szlWindowExt.cx; + lpSize->cy = Dc_Attr->szlWindowExt.cy; + if (Dc_Attr->dwLayout & LAYOUT_RTL) lpSize->cx = -lpSize->cx; + return TRUE; + // return NtGdiGetDCPoint( hdc, GdiGetWindowExt, (LPPOINT) lpSize ); } BOOL WINAPI GetWindowOrgEx( - HDC hdc, - LPPOINT lpPoint - ) + HDC hdc, + LPPOINT lpPoint +) { - PDC_ATTR Dc_Attr; + PDC_ATTR Dc_Attr; - if (!GdiGetHandleUserData((HGDIOBJ) hdc, GDI_OBJECT_TYPE_DC, (PVOID) &Dc_Attr)) return FALSE; - lpPoint->x = Dc_Attr->ptlWindowOrg.x; - lpPoint->y = Dc_Attr->ptlWindowOrg.y; - return TRUE; - //return NtGdiGetDCPoint( hdc, GdiGetWindowOrg, lpPoint ); + if (!GdiGetHandleUserData((HGDIOBJ) hdc, GDI_OBJECT_TYPE_DC, (PVOID) &Dc_Attr)) return FALSE; + lpPoint->x = Dc_Attr->ptlWindowOrg.x; + lpPoint->y = Dc_Attr->ptlWindowOrg.y; + return TRUE; + //return NtGdiGetDCPoint( hdc, GdiGetWindowOrg, lpPoint ); } /* @@ -327,57 +327,57 @@ SetViewportExtEx(HDC hdc, int nYExtent, LPSIZE lpSize) { - PDC_ATTR Dc_Attr; + PDC_ATTR Dc_Attr; #if 0 - if (GDI_HANDLE_GET_TYPE(hdc) != GDI_OBJECT_TYPE_DC) - { - if (GDI_HANDLE_GET_TYPE(hdc) == GDI_OBJECT_TYPE_METADC) - return MFDRV_SetViewportExtEx(); - else + if (GDI_HANDLE_GET_TYPE(hdc) != GDI_OBJECT_TYPE_DC) { - PLDC pLDC = GdiGetLDC(hdc); - if ( !pLDC ) - { - SetLastError(ERROR_INVALID_HANDLE); - return FALSE; - } - if (pLDC->iType == LDC_EMFLDC) - { - return EMFDRV_SetViewportExtEx(); - } - } - } -#endif - if (!GdiGetHandleUserData((HGDIOBJ) hdc, GDI_OBJECT_TYPE_DC, (PVOID) &Dc_Attr)) - { - return FALSE; - } - - if (lpSize) - { - lpSize->cx = Dc_Attr->szlViewportExt.cx; - lpSize->cy = Dc_Attr->szlViewportExt.cy; - } - - if ((Dc_Attr->szlViewportExt.cx == nXExtent) && (Dc_Attr->szlViewportExt.cy == nYExtent)) - return TRUE; - - if ((Dc_Attr->iMapMode == MM_ISOTROPIC) || (Dc_Attr->iMapMode == MM_ANISOTROPIC)) - { - if (NtCurrentTeb()->GdiTebBatch.HDC == hdc) - { - if (Dc_Attr->ulDirty_ & DC_FONTTEXT_DIRTY) + if (GDI_HANDLE_GET_TYPE(hdc) == GDI_OBJECT_TYPE_METADC) + return MFDRV_SetViewportExtEx(); + else { - NtGdiFlush(); // Sync up Dc_Attr from Kernel space. - Dc_Attr->ulDirty_ &= ~(DC_MODE_DIRTY|DC_FONTTEXT_DIRTY); + PLDC pLDC = GdiGetLDC(hdc); + if ( !pLDC ) + { + SetLastError(ERROR_INVALID_HANDLE); + return FALSE; + } + if (pLDC->iType == LDC_EMFLDC) + { + return EMFDRV_SetViewportExtEx(); + } } - } - Dc_Attr->szlViewportExt.cx = nXExtent; - Dc_Attr->szlViewportExt.cy = nYExtent; - if (Dc_Attr->dwLayout & LAYOUT_RTL) NtGdiMirrorWindowOrg(hdc); - Dc_Attr->flXform |= (PAGE_EXTENTS_CHANGED|INVALIDATE_ATTRIBUTES|DEVICE_TO_WORLD_INVALID); - } - return TRUE; + } +#endif + if (!GdiGetHandleUserData((HGDIOBJ) hdc, GDI_OBJECT_TYPE_DC, (PVOID) &Dc_Attr)) + { + return FALSE; + } + + if (lpSize) + { + lpSize->cx = Dc_Attr->szlViewportExt.cx; + lpSize->cy = Dc_Attr->szlViewportExt.cy; + } + + if ((Dc_Attr->szlViewportExt.cx == nXExtent) && (Dc_Attr->szlViewportExt.cy == nYExtent)) + return TRUE; + + if ((Dc_Attr->iMapMode == MM_ISOTROPIC) || (Dc_Attr->iMapMode == MM_ANISOTROPIC)) + { + if (NtCurrentTeb()->GdiTebBatch.HDC == hdc) + { + if (Dc_Attr->ulDirty_ & DC_FONTTEXT_DIRTY) + { + NtGdiFlush(); // Sync up Dc_Attr from Kernel space. + Dc_Attr->ulDirty_ &= ~(DC_MODE_DIRTY|DC_FONTTEXT_DIRTY); + } + } + Dc_Attr->szlViewportExt.cx = nXExtent; + Dc_Attr->szlViewportExt.cy = nYExtent; + if (Dc_Attr->dwLayout & LAYOUT_RTL) NtGdiMirrorWindowOrg(hdc); + Dc_Attr->flXform |= (PAGE_EXTENTS_CHANGED|INVALIDATE_ATTRIBUTES|DEVICE_TO_WORLD_INVALID); + } + return TRUE; } /* @@ -391,55 +391,55 @@ SetWindowOrgEx(HDC hdc, LPPOINT lpPoint) { #if 0 - PDC_ATTR Dc_Attr; + PDC_ATTR Dc_Attr; #if 0 - if (GDI_HANDLE_GET_TYPE(hdc) != GDI_OBJECT_TYPE_DC) - { - if (GDI_HANDLE_GET_TYPE(hdc) == GDI_OBJECT_TYPE_METADC) - return MFDRV_SetWindowOrgEx(); - else + if (GDI_HANDLE_GET_TYPE(hdc) != GDI_OBJECT_TYPE_DC) { - PLDC pLDC = GdiGetLDC(hdc); - if ( !pLDC ) - { - SetLastError(ERROR_INVALID_HANDLE); - return FALSE; - } - if (pLDC->iType == LDC_EMFLDC) - { - return EMFDRV_SetWindowOrgEx(); - } + if (GDI_HANDLE_GET_TYPE(hdc) == GDI_OBJECT_TYPE_METADC) + return MFDRV_SetWindowOrgEx(); + else + { + PLDC pLDC = GdiGetLDC(hdc); + if ( !pLDC ) + { + SetLastError(ERROR_INVALID_HANDLE); + return FALSE; + } + if (pLDC->iType == LDC_EMFLDC) + { + return EMFDRV_SetWindowOrgEx(); + } + } } - } #endif - if (!GdiGetHandleUserData((HGDIOBJ) hdc, GDI_OBJECT_TYPE_DC, (PVOID) &Dc_Attr)) return FALSE; + if (!GdiGetHandleUserData((HGDIOBJ) hdc, GDI_OBJECT_TYPE_DC, (PVOID) &Dc_Attr)) return FALSE; - if (lpPoint) - { - lpPoint->x = Dc_Attr->ptlWindowOrg.x; - lpPoint->y = Dc_Attr->ptlWindowOrg.y; - } + if (lpPoint) + { + lpPoint->x = Dc_Attr->ptlWindowOrg.x; + lpPoint->y = Dc_Attr->ptlWindowOrg.y; + } - if ((Dc_Attr->ptlWindowOrg.x == X) && (Dc_Attr->ptlWindowOrg.y == Y)) - return TRUE; + if ((Dc_Attr->ptlWindowOrg.x == X) && (Dc_Attr->ptlWindowOrg.y == Y)) + return TRUE; - if (NtCurrentTeb()->GdiTebBatch.HDC == (ULONG)hdc) - { - if (Dc_Attr->ulDirty_ & DC_FONTTEXT_DIRTY) - { - NtGdiFlush(); // Sync up Dc_Attr from Kernel space. - Dc_Attr->ulDirty_ &= ~(DC_MODE_DIRTY|DC_FONTTEXT_DIRTY); - } - } - - Dc_Attr->ptlWindowOrg.x = X; - Dc_Attr->lWindowOrgx = X; - Dc_Attr->ptlWindowOrg.y = Y; - if (Dc_Attr->dwLayout & LAYOUT_RTL) NtGdiMirrorWindowOrg(hdc); - Dc_Attr->flXform |= (PAGE_XLATE_CHANGED|DEVICE_TO_WORLD_INVALID); - return TRUE; + if (NtCurrentTeb()->GdiTebBatch.HDC == (ULONG)hdc) + { + if (Dc_Attr->ulDirty_ & DC_FONTTEXT_DIRTY) + { + NtGdiFlush(); // Sync up Dc_Attr from Kernel space. + Dc_Attr->ulDirty_ &= ~(DC_MODE_DIRTY|DC_FONTTEXT_DIRTY); + } + } + + Dc_Attr->ptlWindowOrg.x = X; + Dc_Attr->lWindowOrgx = X; + Dc_Attr->ptlWindowOrg.y = Y; + if (Dc_Attr->dwLayout & LAYOUT_RTL) NtGdiMirrorWindowOrg(hdc); + Dc_Attr->flXform |= (PAGE_XLATE_CHANGED|DEVICE_TO_WORLD_INVALID); + return TRUE; #endif - return NtGdiSetWindowOrgEx(hdc,X,Y,lpPoint); + return NtGdiSetWindowOrgEx(hdc,X,Y,lpPoint); } /* @@ -452,62 +452,62 @@ SetWindowExtEx(HDC hdc, int nYExtent, LPSIZE lpSize) { - PDC_ATTR Dc_Attr; + PDC_ATTR Dc_Attr; #if 0 - if (GDI_HANDLE_GET_TYPE(hdc) != GDI_OBJECT_TYPE_DC) - { - if (GDI_HANDLE_GET_TYPE(hdc) == GDI_OBJECT_TYPE_METADC) - return MFDRV_SetWindowExtEx(); - else + if (GDI_HANDLE_GET_TYPE(hdc) != GDI_OBJECT_TYPE_DC) { - PLDC pLDC = GdiGetLDC(hdc); - if ( !pLDC ) - { - SetLastError(ERROR_INVALID_HANDLE); - return FALSE; - } - if (pLDC->iType == LDC_EMFLDC) - { - return EMFDRV_SetWindowExtEx(); - } - } - } -#endif - if (!GdiGetHandleUserData((HGDIOBJ) hdc, GDI_OBJECT_TYPE_DC, (PVOID) &Dc_Attr)) return FALSE; - - if (lpSize) - { - lpSize->cx = Dc_Attr->szlWindowExt.cx; - lpSize->cy = Dc_Attr->szlWindowExt.cy; - if (Dc_Attr->dwLayout & LAYOUT_RTL) lpSize->cx = -lpSize->cx; - } - - if (Dc_Attr->dwLayout & LAYOUT_RTL) - { - NtGdiMirrorWindowOrg(hdc); - Dc_Attr->flXform |= (PAGE_EXTENTS_CHANGED|INVALIDATE_ATTRIBUTES|DEVICE_TO_WORLD_INVALID); - } - else if ((Dc_Attr->iMapMode == MM_ISOTROPIC) || (Dc_Attr->iMapMode == MM_ANISOTROPIC)) - { - if ((Dc_Attr->szlWindowExt.cx == nXExtent) && (Dc_Attr->szlWindowExt.cy == nYExtent)) - return TRUE; - - if ((!nXExtent) || (!nYExtent)) return FALSE; - - if (NtCurrentTeb()->GdiTebBatch.HDC == hdc) - { - if (Dc_Attr->ulDirty_ & DC_FONTTEXT_DIRTY) + if (GDI_HANDLE_GET_TYPE(hdc) == GDI_OBJECT_TYPE_METADC) + return MFDRV_SetWindowExtEx(); + else { - NtGdiFlush(); // Sync up Dc_Attr from Kernel space. - Dc_Attr->ulDirty_ &= ~(DC_MODE_DIRTY|DC_FONTTEXT_DIRTY); + PLDC pLDC = GdiGetLDC(hdc); + if ( !pLDC ) + { + SetLastError(ERROR_INVALID_HANDLE); + return FALSE; + } + if (pLDC->iType == LDC_EMFLDC) + { + return EMFDRV_SetWindowExtEx(); + } } - } - Dc_Attr->szlWindowExt.cx = nXExtent; - Dc_Attr->szlWindowExt.cy = nYExtent; - if (Dc_Attr->dwLayout & LAYOUT_RTL) NtGdiMirrorWindowOrg(hdc); - Dc_Attr->flXform |= (PAGE_EXTENTS_CHANGED|INVALIDATE_ATTRIBUTES|DEVICE_TO_WORLD_INVALID); - } - return TRUE; // Return TRUE. + } +#endif + if (!GdiGetHandleUserData((HGDIOBJ) hdc, GDI_OBJECT_TYPE_DC, (PVOID) &Dc_Attr)) return FALSE; + + if (lpSize) + { + lpSize->cx = Dc_Attr->szlWindowExt.cx; + lpSize->cy = Dc_Attr->szlWindowExt.cy; + if (Dc_Attr->dwLayout & LAYOUT_RTL) lpSize->cx = -lpSize->cx; + } + + if (Dc_Attr->dwLayout & LAYOUT_RTL) + { + NtGdiMirrorWindowOrg(hdc); + Dc_Attr->flXform |= (PAGE_EXTENTS_CHANGED|INVALIDATE_ATTRIBUTES|DEVICE_TO_WORLD_INVALID); + } + else if ((Dc_Attr->iMapMode == MM_ISOTROPIC) || (Dc_Attr->iMapMode == MM_ANISOTROPIC)) + { + if ((Dc_Attr->szlWindowExt.cx == nXExtent) && (Dc_Attr->szlWindowExt.cy == nYExtent)) + return TRUE; + + if ((!nXExtent) || (!nYExtent)) return FALSE; + + if (NtCurrentTeb()->GdiTebBatch.HDC == hdc) + { + if (Dc_Attr->ulDirty_ & DC_FONTTEXT_DIRTY) + { + NtGdiFlush(); // Sync up Dc_Attr from Kernel space. + Dc_Attr->ulDirty_ &= ~(DC_MODE_DIRTY|DC_FONTTEXT_DIRTY); + } + } + Dc_Attr->szlWindowExt.cx = nXExtent; + Dc_Attr->szlWindowExt.cy = nYExtent; + if (Dc_Attr->dwLayout & LAYOUT_RTL) NtGdiMirrorWindowOrg(hdc); + Dc_Attr->flXform |= (PAGE_EXTENTS_CHANGED|INVALIDATE_ATTRIBUTES|DEVICE_TO_WORLD_INVALID); + } + return TRUE; // Return TRUE. } /* @@ -521,42 +521,42 @@ SetViewportOrgEx(HDC hdc, LPPOINT lpPoint) { #if 0 - PDC_ATTR Dc_Attr; + PDC_ATTR Dc_Attr; #if 0 - if (GDI_HANDLE_GET_TYPE(hdc) != GDI_OBJECT_TYPE_DC) - { - if (GDI_HANDLE_GET_TYPE(hdc) == GDI_OBJECT_TYPE_METADC) - return MFDRV_SetViewportOrgEx(); - else + if (GDI_HANDLE_GET_TYPE(hdc) != GDI_OBJECT_TYPE_DC) { - PLDC pLDC = GdiGetLDC(hdc); - if ( !pLDC ) - { - SetLastError(ERROR_INVALID_HANDLE); - return FALSE; - } - if (pLDC->iType == LDC_EMFLDC) - { - return EMFDRV_SetViewportOrgEx(); - } + if (GDI_HANDLE_GET_TYPE(hdc) == GDI_OBJECT_TYPE_METADC) + return MFDRV_SetViewportOrgEx(); + else + { + PLDC pLDC = GdiGetLDC(hdc); + if ( !pLDC ) + { + SetLastError(ERROR_INVALID_HANDLE); + return FALSE; + } + if (pLDC->iType == LDC_EMFLDC) + { + return EMFDRV_SetViewportOrgEx(); + } + } } - } #endif - if (!GdiGetHandleUserData((HGDIOBJ) hdc, GDI_OBJECT_TYPE_DC, (PVOID) &Dc_Attr)) return FALSE; + if (!GdiGetHandleUserData((HGDIOBJ) hdc, GDI_OBJECT_TYPE_DC, (PVOID) &Dc_Attr)) return FALSE; - if (lpPoint) - { - lpPoint->x = Dc_Attr->ptlViewportOrg.x; - lpPoint->y = Dc_Attr->ptlViewportOrg.y; - if (Dc_Attr->dwLayout & LAYOUT_RTL) lpPoint->x = -lpPoint->x; - } - Dc_Attr->flXform |= (PAGE_XLATE_CHANGED|DEVICE_TO_WORLD_INVALID); - if (Dc_Attr->dwLayout & LAYOUT_RTL) X = -X; - Dc_Attr->ptlViewportOrg.x = X; - Dc_Attr->ptlViewportOrg.y = Y; - return TRUE; + if (lpPoint) + { + lpPoint->x = Dc_Attr->ptlViewportOrg.x; + lpPoint->y = Dc_Attr->ptlViewportOrg.y; + if (Dc_Attr->dwLayout & LAYOUT_RTL) lpPoint->x = -lpPoint->x; + } + Dc_Attr->flXform |= (PAGE_XLATE_CHANGED|DEVICE_TO_WORLD_INVALID); + if (Dc_Attr->dwLayout & LAYOUT_RTL) X = -X; + Dc_Attr->ptlViewportOrg.x = X; + Dc_Attr->ptlViewportOrg.y = Y; + return TRUE; #endif - return NtGdiSetViewportOrgEx(hdc,X,Y,lpPoint); + return NtGdiSetViewportOrgEx(hdc,X,Y,lpPoint); } /* @@ -565,38 +565,38 @@ SetViewportOrgEx(HDC hdc, BOOL WINAPI ScaleViewportExtEx( - HDC a0, - int a1, - int a2, - int a3, - int a4, - LPSIZE a5 - ) + HDC a0, + int a1, + int a2, + int a3, + int a4, + LPSIZE a5 +) { #if 0 - if (GDI_HANDLE_GET_TYPE(a0) != GDI_OBJECT_TYPE_DC) - { - if (GDI_HANDLE_GET_TYPE(a0) == GDI_OBJECT_TYPE_METADC) - return MFDRV_; - else + if (GDI_HANDLE_GET_TYPE(a0) != GDI_OBJECT_TYPE_DC) { - PLDC pLDC = GdiGetLDC(a0); - if ( !pLDC ) - { - SetLastError(ERROR_INVALID_HANDLE); - return FALSE; - } - if (pLDC->iType == LDC_EMFLDC) - { - return EMFDRV_; - } + if (GDI_HANDLE_GET_TYPE(a0) == GDI_OBJECT_TYPE_METADC) + return MFDRV_; + else + { + PLDC pLDC = GdiGetLDC(a0); + if ( !pLDC ) + { + SetLastError(ERROR_INVALID_HANDLE); + return FALSE; + } + if (pLDC->iType == LDC_EMFLDC) + { + return EMFDRV_; + } + } } - } #endif - if (!GdiIsHandleValid((HGDIOBJ) a0) || - (GDI_HANDLE_GET_TYPE(a0) != GDI_OBJECT_TYPE_DC)) return FALSE; + if (!GdiIsHandleValid((HGDIOBJ) a0) || + (GDI_HANDLE_GET_TYPE(a0) != GDI_OBJECT_TYPE_DC)) return FALSE; - return NtGdiScaleViewportExtEx(a0, a1, a2, a3, a4, a5); + return NtGdiScaleViewportExtEx(a0, a1, a2, a3, a4, a5); } /* @@ -605,38 +605,38 @@ ScaleViewportExtEx( BOOL WINAPI ScaleWindowExtEx( - HDC a0, - int a1, - int a2, - int a3, - int a4, - LPSIZE a5 - ) + HDC a0, + int a1, + int a2, + int a3, + int a4, + LPSIZE a5 +) { #if 0 - if (GDI_HANDLE_GET_TYPE(a0) != GDI_OBJECT_TYPE_DC) - { - if (GDI_HANDLE_GET_TYPE(a0) == GDI_OBJECT_TYPE_METADC) - return MFDRV_; - else + if (GDI_HANDLE_GET_TYPE(a0) != GDI_OBJECT_TYPE_DC) { - PLDC pLDC = GdiGetLDC(a0); - if ( !pLDC ) - { - SetLastError(ERROR_INVALID_HANDLE); - return FALSE; - } - if (pLDC->iType == LDC_EMFLDC) - { - return EMFDRV_; - } + if (GDI_HANDLE_GET_TYPE(a0) == GDI_OBJECT_TYPE_METADC) + return MFDRV_; + else + { + PLDC pLDC = GdiGetLDC(a0); + if ( !pLDC ) + { + SetLastError(ERROR_INVALID_HANDLE); + return FALSE; + } + if (pLDC->iType == LDC_EMFLDC) + { + return EMFDRV_; + } + } } - } #endif - if (!GdiIsHandleValid((HGDIOBJ) a0) || - (GDI_HANDLE_GET_TYPE(a0) != GDI_OBJECT_TYPE_DC)) return FALSE; + if (!GdiIsHandleValid((HGDIOBJ) a0) || + (GDI_HANDLE_GET_TYPE(a0) != GDI_OBJECT_TYPE_DC)) return FALSE; - return NtGdiScaleWindowExtEx(a0, a1, a2, a3, a4, a5); + return NtGdiScaleWindowExtEx(a0, a1, a2, a3, a4, a5); } /* @@ -645,11 +645,11 @@ ScaleWindowExtEx( DWORD WINAPI GetLayout(HDC hdc -) + ) { - PDC_ATTR Dc_Attr; - if (!GdiGetHandleUserData((HGDIOBJ) hdc, GDI_OBJECT_TYPE_DC, (PVOID) &Dc_Attr)) return GDI_ERROR; - return Dc_Attr->dwLayout; + PDC_ATTR Dc_Attr; + if (!GdiGetHandleUserData((HGDIOBJ) hdc, GDI_OBJECT_TYPE_DC, (PVOID) &Dc_Attr)) return GDI_ERROR; + return Dc_Attr->dwLayout; } @@ -662,28 +662,28 @@ SetLayout(HDC hdc, DWORD dwLayout) { #if 0 - if (GDI_HANDLE_GET_TYPE(hdc) != GDI_OBJECT_TYPE_DC) - { - if (GDI_HANDLE_GET_TYPE(hdc) == GDI_OBJECT_TYPE_METADC) - return MFDRV_SetLayout( hdc, dwLayout); - else + if (GDI_HANDLE_GET_TYPE(hdc) != GDI_OBJECT_TYPE_DC) { - PLDC pLDC = GdiGetLDC(hdc); - if ( !pLDC ) - { - SetLastError(ERROR_INVALID_HANDLE); - return 0; - } - if (pLDC->iType == LDC_EMFLDC) - { - return EMFDRV_SetLayout( hdc, dwLayout); - } + if (GDI_HANDLE_GET_TYPE(hdc) == GDI_OBJECT_TYPE_METADC) + return MFDRV_SetLayout( hdc, dwLayout); + else + { + PLDC pLDC = GdiGetLDC(hdc); + if ( !pLDC ) + { + SetLastError(ERROR_INVALID_HANDLE); + return 0; + } + if (pLDC->iType == LDC_EMFLDC) + { + return EMFDRV_SetLayout( hdc, dwLayout); + } + } } - } #endif - if (!GdiIsHandleValid((HGDIOBJ) hdc) || - (GDI_HANDLE_GET_TYPE(hdc) != GDI_OBJECT_TYPE_DC)) return GDI_ERROR; - return NtGdiSetLayout( hdc, -1, dwLayout); + if (!GdiIsHandleValid((HGDIOBJ) hdc) || + (GDI_HANDLE_GET_TYPE(hdc) != GDI_OBJECT_TYPE_DC)) return GDI_ERROR; + return NtGdiSetLayout( hdc, -1, dwLayout); } /* @@ -693,9 +693,9 @@ DWORD WINAPI SetLayoutWidth(HDC hdc,LONG wox,DWORD dwLayout) { - if (!GdiIsHandleValid((HGDIOBJ) hdc) || - (GDI_HANDLE_GET_TYPE(hdc) != GDI_OBJECT_TYPE_DC)) return GDI_ERROR; - return NtGdiSetLayout( hdc, wox, dwLayout); + if (!GdiIsHandleValid((HGDIOBJ) hdc) || + (GDI_HANDLE_GET_TYPE(hdc) != GDI_OBJECT_TYPE_DC)) return GDI_ERROR; + return NtGdiSetLayout( hdc, wox, dwLayout); } /* @@ -710,51 +710,51 @@ OffsetViewportOrgEx(HDC hdc, LPPOINT lpPoint) { #if 0 - PDC_ATTR Dc_Attr; + PDC_ATTR Dc_Attr; #if 0 - if (GDI_HANDLE_GET_TYPE(hdc) != GDI_OBJECT_TYPE_DC) - { - if (GDI_HANDLE_GET_TYPE(hdc) == GDI_OBJECT_TYPE_METADC) - return MFDRV_OffsetViewportOrgEx(hdc, nXOffset, nYOffset, lpPoint); - else + if (GDI_HANDLE_GET_TYPE(hdc) != GDI_OBJECT_TYPE_DC) { - PLDC pLDC = GdiGetLDC(hdc); - if ( !pLDC ) - { - SetLastError(ERROR_INVALID_HANDLE); - return FALSE; - } - if (pLDC->iType == LDC_EMFLDC) - { - return EMFDRV_OffsetWindowOrgEx(hdc, nXOffset, nYOffset, lpPoint); - } - } - } -#endif - if (!GdiGetHandleUserData((HGDIOBJ) hdc, GDI_OBJECT_TYPE_DC, (PVOID) &Dc_Attr)) return FALSE; - - if ( lpPoint ) - { - *lpPoint = (POINT)Dc_Attr->ptlViewportOrg; - if ( Dc_Attr->dwLayout & LAYOUT_RTL) lpPoint->x = -lpPoint->x; - } - - if ( nXOffset || nYOffset != nXOffset ) - { - if (NtCurrentTeb()->GdiTebBatch.HDC == (ULONG)hdc) - { - if (Dc_Attr->ulDirty_ & DC_MODE_DIRTY) + if (GDI_HANDLE_GET_TYPE(hdc) == GDI_OBJECT_TYPE_METADC) + return MFDRV_OffsetViewportOrgEx(hdc, nXOffset, nYOffset, lpPoint); + else { - NtGdiFlush(); - Dc_Attr->ulDirty_ &= ~DC_MODE_DIRTY; + PLDC pLDC = GdiGetLDC(hdc); + if ( !pLDC ) + { + SetLastError(ERROR_INVALID_HANDLE); + return FALSE; + } + if (pLDC->iType == LDC_EMFLDC) + { + return EMFDRV_OffsetWindowOrgEx(hdc, nXOffset, nYOffset, lpPoint); + } } - } - Dc_Attr->flXform |= (PAGE_XLATE_CHANGED|DEVICE_TO_WORLD_INVALID); - if ( Dc_Attr->dwLayout & LAYOUT_RTL) nXOffset = -nXOffset; - Dc_Attr->ptlViewportOrg.x += nXOffset; - Dc_Attr->ptlViewportOrg.y += nYOffset; - } - return TRUE; + } +#endif + if (!GdiGetHandleUserData((HGDIOBJ) hdc, GDI_OBJECT_TYPE_DC, (PVOID) &Dc_Attr)) return FALSE; + + if ( lpPoint ) + { + *lpPoint = (POINT)Dc_Attr->ptlViewportOrg; + if ( Dc_Attr->dwLayout & LAYOUT_RTL) lpPoint->x = -lpPoint->x; + } + + if ( nXOffset || nYOffset != nXOffset ) + { + if (NtCurrentTeb()->GdiTebBatch.HDC == (ULONG)hdc) + { + if (Dc_Attr->ulDirty_ & DC_MODE_DIRTY) + { + NtGdiFlush(); + Dc_Attr->ulDirty_ &= ~DC_MODE_DIRTY; + } + } + Dc_Attr->flXform |= (PAGE_XLATE_CHANGED|DEVICE_TO_WORLD_INVALID); + if ( Dc_Attr->dwLayout & LAYOUT_RTL) nXOffset = -nXOffset; + Dc_Attr->ptlViewportOrg.x += nXOffset; + Dc_Attr->ptlViewportOrg.y += nYOffset; + } + return TRUE; #endif return NtGdiOffsetViewportOrgEx(hdc, nXOffset, nYOffset, lpPoint); } @@ -771,51 +771,51 @@ OffsetWindowOrgEx(HDC hdc, LPPOINT lpPoint) { #if 0 - PDC_ATTR Dc_Attr; + PDC_ATTR Dc_Attr; #if 0 - if (GDI_HANDLE_GET_TYPE(hdc) != GDI_OBJECT_TYPE_DC) - { - if (GDI_HANDLE_GET_TYPE(hdc) == GDI_OBJECT_TYPE_METADC) - return MFDRV_OffsetWindowOrgEx(hdc, nXOffset, nYOffset, lpPoint); - else + if (GDI_HANDLE_GET_TYPE(hdc) != GDI_OBJECT_TYPE_DC) { - PLDC pLDC = GdiGetLDC(hdc); - if ( !pLDC ) - { - SetLastError(ERROR_INVALID_HANDLE); - return FALSE; - } - if (pLDC->iType == LDC_EMFLDC) - { - return EMFDRV_OffsetWindowOrgEx(hdc, nXOffset, nYOffset, lpPoint); - } - } - } -#endif - if (!GdiGetHandleUserData((HGDIOBJ) hdc, GDI_OBJECT_TYPE_DC, (PVOID) &Dc_Attr)) return FALSE; - - if ( lpPoint ) - { - *lpPoint = (POINT)Dc_Attr->ptlWindowOrg; - lpPoint->x = Dc_Attr->lWindowOrgx; - } - - if ( nXOffset || nYOffset != nXOffset ) - { - if (NtCurrentTeb()->GdiTebBatch.HDC == (ULONG)hdc) - { - if (Dc_Attr->ulDirty_ & DC_MODE_DIRTY) + if (GDI_HANDLE_GET_TYPE(hdc) == GDI_OBJECT_TYPE_METADC) + return MFDRV_OffsetWindowOrgEx(hdc, nXOffset, nYOffset, lpPoint); + else { - NtGdiFlush(); - Dc_Attr->ulDirty_ &= ~DC_MODE_DIRTY; + PLDC pLDC = GdiGetLDC(hdc); + if ( !pLDC ) + { + SetLastError(ERROR_INVALID_HANDLE); + return FALSE; + } + if (pLDC->iType == LDC_EMFLDC) + { + return EMFDRV_OffsetWindowOrgEx(hdc, nXOffset, nYOffset, lpPoint); + } } - } - Dc_Attr->flXform |= (PAGE_XLATE_CHANGED|DEVICE_TO_WORLD_INVALID); - Dc_Attr->ptlWindowOrg.x += nXOffset; - Dc_Attr->ptlWindowOrg.y += nYOffset; - Dc_Attr->lWindowOrgx += nXOffset; - } - return TRUE; + } +#endif + if (!GdiGetHandleUserData((HGDIOBJ) hdc, GDI_OBJECT_TYPE_DC, (PVOID) &Dc_Attr)) return FALSE; + + if ( lpPoint ) + { + *lpPoint = (POINT)Dc_Attr->ptlWindowOrg; + lpPoint->x = Dc_Attr->lWindowOrgx; + } + + if ( nXOffset || nYOffset != nXOffset ) + { + if (NtCurrentTeb()->GdiTebBatch.HDC == (ULONG)hdc) + { + if (Dc_Attr->ulDirty_ & DC_MODE_DIRTY) + { + NtGdiFlush(); + Dc_Attr->ulDirty_ &= ~DC_MODE_DIRTY; + } + } + Dc_Attr->flXform |= (PAGE_XLATE_CHANGED|DEVICE_TO_WORLD_INVALID); + Dc_Attr->ptlWindowOrg.x += nXOffset; + Dc_Attr->ptlWindowOrg.y += nYOffset; + Dc_Attr->lWindowOrgx += nXOffset; + } + return TRUE; #endif return NtGdiOffsetWindowOrgEx(hdc, nXOffset, nYOffset, lpPoint); } diff --git a/reactos/dll/win32/gdi32/objects/dc.c b/reactos/dll/win32/gdi32/objects/dc.c index 7693dcc9592..af8a49cf0dd 100644 --- a/reactos/dll/win32/gdi32/objects/dc.c +++ b/reactos/dll/win32/gdi32/objects/dc.c @@ -13,79 +13,79 @@ IntCreateDICW ( LPCWSTR lpwszDriver, PDEVMODEW lpInitData, ULONG iType ) { - UNICODE_STRING Device, Output; - HDC hDC = NULL; - BOOL Display = FALSE, Default = FALSE; - ULONG UMdhpdev = 0; + UNICODE_STRING Device, Output; + HDC hDC = NULL; + BOOL Display = FALSE, Default = FALSE; + ULONG UMdhpdev = 0; - HANDLE hspool = NULL; + HANDLE hspool = NULL; - if ( !ghSpooler && !LoadTheSpoolerDrv()) - { - DPRINT1("WinSpooler.Drv Did not load!\n"); - } - else - { - DPRINT("WinSpooler.Drv Loaded! hMod -> 0x%x\n", ghSpooler); - } - - if ((!lpwszDevice) && (!lpwszDriver)) - { - Default = TRUE; // Ask Win32k to set Default device. - Display = TRUE; // Most likely to be DISPLAY. - } - else - { - if ((lpwszDevice) && (wcslen(lpwszDevice) != 0)) // First + if ( !ghSpooler && !LoadTheSpoolerDrv()) { - if (!_wcsnicmp(lpwszDevice, L"\\\\.\\DISPLAY",11)) Display = TRUE; - RtlInitUnicodeString(&Device, lpwszDevice); + DPRINT1("WinSpooler.Drv Did not load!\n"); } else { - if (lpwszDriver) // Second - { - if ((!_wcsnicmp(lpwszDriver, L"DISPLAY",7)) || - (!_wcsnicmp(lpwszDriver, L"\\\\.\\DISPLAY",11))) Display = TRUE; - RtlInitUnicodeString(&Device, lpwszDriver); - } + DPRINT("WinSpooler.Drv Loaded! hMod -> 0x%x\n", ghSpooler); } - } - if (lpwszOutput) RtlInitUnicodeString(&Output, lpwszOutput); + if ((!lpwszDevice) && (!lpwszDriver)) + { + Default = TRUE; // Ask Win32k to set Default device. + Display = TRUE; // Most likely to be DISPLAY. + } + else + { + if ((lpwszDevice) && (wcslen(lpwszDevice) != 0)) // First + { + if (!_wcsnicmp(lpwszDevice, L"\\\\.\\DISPLAY",11)) Display = TRUE; + RtlInitUnicodeString(&Device, lpwszDevice); + } + else + { + if (lpwszDriver) // Second + { + if ((!_wcsnicmp(lpwszDriver, L"DISPLAY",7)) || + (!_wcsnicmp(lpwszDriver, L"\\\\.\\DISPLAY",11))) Display = TRUE; + RtlInitUnicodeString(&Device, lpwszDriver); + } + } + } - if (!Display) - { - //Handle Print device or something else. - DPRINT1("Not a DISPLAY device! %wZ\n", &Device); - } + if (lpwszOutput) RtlInitUnicodeString(&Output, lpwszOutput); - hDC = NtGdiOpenDCW( (Default ? NULL : &Device), - (PDEVMODEW) lpInitData, - (lpwszOutput ? &Output : NULL), - iType, // DCW 0 and ICW 1. - Display, - hspool, - (PVOID) NULL, // NULL for now. - (PVOID) &UMdhpdev ); + if (!Display) + { + //Handle Print device or something else. + DPRINT1("Not a DISPLAY device! %wZ\n", &Device); + } + + hDC = NtGdiOpenDCW( (Default ? NULL : &Device), + (PDEVMODEW) lpInitData, + (lpwszOutput ? &Output : NULL), + iType, // DCW 0 and ICW 1. + Display, + hspool, + (PVOID) NULL, // NULL for now. + (PVOID) &UMdhpdev ); #if 0 // Handle something other than a normal dc object. - if (GDI_HANDLE_GET_TYPE(hDC) != GDI_OBJECT_TYPE_DC) - { - PDC_ATTR Dc_Attr; - PLDC pLDC; + if (GDI_HANDLE_GET_TYPE(hDC) != GDI_OBJECT_TYPE_DC) + { + PDC_ATTR Dc_Attr; + PLDC pLDC; - GdiGetHandleUserData((HGDIOBJ) hDC, GDI_OBJECT_TYPE_DC, (PVOID) &Dc_Attr); + GdiGetHandleUserData((HGDIOBJ) hDC, GDI_OBJECT_TYPE_DC, (PVOID) &Dc_Attr); - pLDC = LocalAlloc(LMEM_ZEROINIT, sizeof(LDC)); + pLDC = LocalAlloc(LMEM_ZEROINIT, sizeof(LDC)); - Dc_Attr->pvLDC = pLDC; - pLDC->hDC = hDC; - pLDC->iType = LDC_LDC; // 1 (init) local DC, 2 EMF LDC - DbgPrint("DC_ATTR Allocated -> 0x%x\n",Dc_Attr); - } + Dc_Attr->pvLDC = pLDC; + pLDC->hDC = hDC; + pLDC->iType = LDC_LDC; // 1 (init) local DC, 2 EMF LDC + DbgPrint("DC_ATTR Allocated -> 0x%x\n",Dc_Attr); + } #endif - return hDC; + return hDC; } @@ -96,20 +96,20 @@ HDC WINAPI CreateCompatibleDC ( HDC hdc) { - HDC rhDC; + HDC rhDC; // PDC_ATTR Dc_Attr; - rhDC = NtGdiCreateCompatibleDC(hdc); + rhDC = NtGdiCreateCompatibleDC(hdc); #if 0 - if ( hdc && rhDC) - { - if (GdiGetHandleUserData((HGDIOBJ) hdc, GDI_OBJECT_TYPE_DC, (PVOID) &Dc_Attr)) + if ( hdc && rhDC) { - if ( Dc_Attr->pvLIcm ) IcmCompatibleDC(rhDC, hdc, Dc_Attr); + if (GdiGetHandleUserData((HGDIOBJ) hdc, GDI_OBJECT_TYPE_DC, (PVOID) &Dc_Attr)) + { + if ( Dc_Attr->pvLIcm ) IcmCompatibleDC(rhDC, hdc, Dc_Attr); + } } - } #endif - return rhDC; + return rhDC; } /* @@ -118,61 +118,64 @@ CreateCompatibleDC ( HDC hdc) HDC WINAPI CreateDCA ( - LPCSTR lpszDriver, - LPCSTR lpszDevice, - LPCSTR lpszOutput, - CONST DEVMODEA * lpdvmInit - ) + LPCSTR lpszDriver, + LPCSTR lpszDevice, + LPCSTR lpszOutput, + CONST DEVMODEA * lpdvmInit +) { - ANSI_STRING DriverA, DeviceA, OutputA; - UNICODE_STRING DriverU, DeviceU, OutputU; - LPDEVMODEW dvmInitW = NULL; - HDC hDC; + ANSI_STRING DriverA, DeviceA, OutputA; + UNICODE_STRING DriverU, DeviceU, OutputU; + LPDEVMODEW dvmInitW = NULL; + HDC hDC; -/* - * If needed, convert to Unicode - * any string parameter. - */ + /* + * If needed, convert to Unicode + * any string parameter. + */ - if (NULL != lpszDriver) - { - RtlInitAnsiString(&DriverA, (LPSTR)lpszDriver); - RtlAnsiStringToUnicodeString(&DriverU, &DriverA, TRUE); - } else - DriverU.Buffer = NULL; - if (NULL != lpszDevice) - { - RtlInitAnsiString(&DeviceA, (LPSTR)lpszDevice); - RtlAnsiStringToUnicodeString(&DeviceU, &DeviceA, TRUE); - } else - DeviceU.Buffer = NULL; - if (NULL != lpszOutput) - { - RtlInitAnsiString(&OutputA, (LPSTR)lpszOutput); - RtlAnsiStringToUnicodeString(&OutputU, &OutputA, TRUE); - } else - OutputU.Buffer = NULL; + if (NULL != lpszDriver) + { + RtlInitAnsiString(&DriverA, (LPSTR)lpszDriver); + RtlAnsiStringToUnicodeString(&DriverU, &DriverA, TRUE); + } + else + DriverU.Buffer = NULL; + if (NULL != lpszDevice) + { + RtlInitAnsiString(&DeviceA, (LPSTR)lpszDevice); + RtlAnsiStringToUnicodeString(&DeviceU, &DeviceA, TRUE); + } + else + DeviceU.Buffer = NULL; + if (NULL != lpszOutput) + { + RtlInitAnsiString(&OutputA, (LPSTR)lpszOutput); + RtlAnsiStringToUnicodeString(&OutputU, &OutputA, TRUE); + } + else + OutputU.Buffer = NULL; - if ( lpdvmInit ) - dvmInitW = GdiConvertToDevmodeW((LPDEVMODEA)lpdvmInit); + if ( lpdvmInit ) + dvmInitW = GdiConvertToDevmodeW((LPDEVMODEA)lpdvmInit); - hDC = IntCreateDICW ( DriverU.Buffer, - DeviceU.Buffer, - OutputU.Buffer, - lpdvmInit ? dvmInitW : NULL, - 0 ); - HEAP_free (dvmInitW); -/* - * Free Unicode parameters. - */ - RtlFreeUnicodeString(&DriverU); - RtlFreeUnicodeString(&DeviceU); - RtlFreeUnicodeString(&OutputU); + hDC = IntCreateDICW ( DriverU.Buffer, + DeviceU.Buffer, + OutputU.Buffer, + lpdvmInit ? dvmInitW : NULL, + 0 ); + HEAP_free (dvmInitW); + /* + * Free Unicode parameters. + */ + RtlFreeUnicodeString(&DriverU); + RtlFreeUnicodeString(&DeviceU); + RtlFreeUnicodeString(&OutputU); -/* - * Return the possible DC handle. - */ - return hDC; + /* + * Return the possible DC handle. + */ + return hDC; } @@ -182,18 +185,18 @@ CreateDCA ( HDC WINAPI CreateDCW ( - LPCWSTR lpwszDriver, - LPCWSTR lpwszDevice, - LPCWSTR lpwszOutput, - CONST DEVMODEW *lpInitData - ) + LPCWSTR lpwszDriver, + LPCWSTR lpwszDevice, + LPCWSTR lpwszOutput, + CONST DEVMODEW *lpInitData +) { - return IntCreateDICW ( lpwszDriver, - lpwszDevice, - lpwszOutput, - (PDEVMODEW) lpInitData, - 0 ); + return IntCreateDICW ( lpwszDriver, + lpwszDevice, + lpwszOutput, + (PDEVMODEW) lpInitData, + 0 ); } @@ -203,17 +206,17 @@ CreateDCW ( HDC WINAPI CreateICW( - LPCWSTR lpszDriver, - LPCWSTR lpszDevice, - LPCWSTR lpszOutput, - CONST DEVMODEW *lpdvmInit - ) + LPCWSTR lpszDriver, + LPCWSTR lpszDevice, + LPCWSTR lpszOutput, + CONST DEVMODEW *lpdvmInit +) { - return IntCreateDICW ( lpszDriver, - lpszDevice, - lpszOutput, - (PDEVMODEW) lpdvmInit, - 1 ); + return IntCreateDICW ( lpszDriver, + lpszDevice, + lpszOutput, + (PDEVMODEW) lpdvmInit, + 1 ); } @@ -223,48 +226,48 @@ CreateICW( HDC WINAPI CreateICA( - LPCSTR lpszDriver, - LPCSTR lpszDevice, - LPCSTR lpszOutput, - CONST DEVMODEA *lpdvmInit - ) + LPCSTR lpszDriver, + LPCSTR lpszDevice, + LPCSTR lpszOutput, + CONST DEVMODEA *lpdvmInit +) { - NTSTATUS Status; - LPWSTR lpszDriverW, lpszDeviceW, lpszOutputW; - LPDEVMODEW dvmInitW = NULL; - HDC rc = 0; + NTSTATUS Status; + LPWSTR lpszDriverW, lpszDeviceW, lpszOutputW; + LPDEVMODEW dvmInitW = NULL; + HDC rc = 0; - Status = HEAP_strdupA2W ( &lpszDriverW, lpszDriver ); - if (!NT_SUCCESS (Status)) - SetLastError (RtlNtStatusToDosError(Status)); - else - { - Status = HEAP_strdupA2W ( &lpszDeviceW, lpszDevice ); + Status = HEAP_strdupA2W ( &lpszDriverW, lpszDriver ); if (!NT_SUCCESS (Status)) - SetLastError (RtlNtStatusToDosError(Status)); + SetLastError (RtlNtStatusToDosError(Status)); else - { - Status = HEAP_strdupA2W ( &lpszOutputW, lpszOutput ); - if (!NT_SUCCESS (Status)) - SetLastError (RtlNtStatusToDosError(Status)); - else - { - if ( lpdvmInit ) - dvmInitW = GdiConvertToDevmodeW((LPDEVMODEA)lpdvmInit); + { + Status = HEAP_strdupA2W ( &lpszDeviceW, lpszDevice ); + if (!NT_SUCCESS (Status)) + SetLastError (RtlNtStatusToDosError(Status)); + else + { + Status = HEAP_strdupA2W ( &lpszOutputW, lpszOutput ); + if (!NT_SUCCESS (Status)) + SetLastError (RtlNtStatusToDosError(Status)); + else + { + if ( lpdvmInit ) + dvmInitW = GdiConvertToDevmodeW((LPDEVMODEA)lpdvmInit); - rc = IntCreateDICW ( lpszDriverW, - lpszDeviceW, - lpszOutputW, - lpdvmInit ? dvmInitW : NULL, - 1 ); - HEAP_free (dvmInitW); - HEAP_free ( lpszOutputW ); - } - HEAP_free ( lpszDeviceW ); - } - HEAP_free ( lpszDriverW ); - } - return rc; + rc = IntCreateDICW ( lpszDriverW, + lpszDeviceW, + lpszOutputW, + lpdvmInit ? dvmInitW : NULL, + 1 ); + HEAP_free (dvmInitW); + HEAP_free ( lpszOutputW ); + } + HEAP_free ( lpszDeviceW ); + } + HEAP_free ( lpszDriverW ); + } + return rc; } @@ -275,39 +278,39 @@ BOOL WINAPI DeleteDC(HDC hDC) { - BOOL Ret = TRUE; - PLDC pLDC = NULL; - HANDLE hPrinter = NULL; - ULONG hType = GDI_HANDLE_GET_TYPE(hDC); + BOOL Ret = TRUE; + PLDC pLDC = NULL; + HANDLE hPrinter = NULL; + ULONG hType = GDI_HANDLE_GET_TYPE(hDC); - pLDC = GdiGetLDC(hDC); + pLDC = GdiGetLDC(hDC); - if (hType != GDILoObjType_LO_DC_TYPE) - { + if (hType != GDILoObjType_LO_DC_TYPE) + { - if ( !pLDC || hType == GDILoObjType_LO_METADC16_TYPE) - { - SetLastError(ERROR_INVALID_HANDLE); - return FALSE; - } - if (pLDC->Flags & LDC_INIT_DOCUMENT) AbortDoc(hDC); - if (pLDC->hPrinter) - { - DocumentEventEx(NULL, pLDC->hPrinter, hDC, DOCUMENTEVENT_DELETEDC, 0, NULL, 0, NULL); - hPrinter = pLDC->hPrinter; - pLDC->hPrinter = NULL; - } - } + if ( !pLDC || hType == GDILoObjType_LO_METADC16_TYPE) + { + SetLastError(ERROR_INVALID_HANDLE); + return FALSE; + } + if (pLDC->Flags & LDC_INIT_DOCUMENT) AbortDoc(hDC); + if (pLDC->hPrinter) + { + DocumentEventEx(NULL, pLDC->hPrinter, hDC, DOCUMENTEVENT_DELETEDC, 0, NULL, 0, NULL); + hPrinter = pLDC->hPrinter; + pLDC->hPrinter = NULL; + } + } - Ret = NtGdiDeleteObjectApp(hDC); + Ret = NtGdiDeleteObjectApp(hDC); - if (Ret && pLDC ) - { - DPRINT1("Delete the Local DC structure\n"); - LocalFree( pLDC ); - } - if (hPrinter) fpClosePrinter(hPrinter); - return Ret; + if (Ret && pLDC ) + { + DPRINT1("Delete the Local DC structure\n"); + LocalFree( pLDC ); + } + if (hPrinter) fpClosePrinter(hPrinter); + return Ret; } /* @@ -317,87 +320,88 @@ BOOL WINAPI DeleteObject(HGDIOBJ hObject) { - UINT Type = 0; + UINT Type = 0; - /* From Wine: DeleteObject does not SetLastError() on a null object */ - if(!hObject) return FALSE; + /* From Wine: DeleteObject does not SetLastError() on a null object */ + if(!hObject) return FALSE; - if (0 != ((DWORD) hObject & GDI_HANDLE_STOCK_MASK)) - { // Relax! This is a normal return! - DPRINT("Trying to delete system object 0x%x\n", hObject); - return TRUE; - } - // If you dont own it?! Get OUT! - if(!GdiIsHandleValid(hObject)) return FALSE; + if (0 != ((DWORD) hObject & GDI_HANDLE_STOCK_MASK)) + { + // Relax! This is a normal return! + DPRINT("Trying to delete system object 0x%x\n", hObject); + return TRUE; + } + // If you dont own it?! Get OUT! + if(!GdiIsHandleValid(hObject)) return FALSE; - Type = GDI_HANDLE_GET_TYPE(hObject); + Type = GDI_HANDLE_GET_TYPE(hObject); - if ((Type == GDI_OBJECT_TYPE_METAFILE) || - (Type == GDI_OBJECT_TYPE_ENHMETAFILE)) - return FALSE; + if ((Type == GDI_OBJECT_TYPE_METAFILE) || + (Type == GDI_OBJECT_TYPE_ENHMETAFILE)) + return FALSE; - switch (Type) - { - case GDI_OBJECT_TYPE_DC: - return DeleteDC((HDC) hObject); - case GDI_OBJECT_TYPE_COLORSPACE: - return NtGdiDeleteColorSpace((HCOLORSPACE) hObject); - case GDI_OBJECT_TYPE_REGION: - return DeleteRegion((HRGN) hObject); + switch (Type) + { + case GDI_OBJECT_TYPE_DC: + return DeleteDC((HDC) hObject); + case GDI_OBJECT_TYPE_COLORSPACE: + return NtGdiDeleteColorSpace((HCOLORSPACE) hObject); + case GDI_OBJECT_TYPE_REGION: + return DeleteRegion((HRGN) hObject); #if 0 - case GDI_OBJECT_TYPE_METADC: - return MFDRV_DeleteObject( hObject ); - case GDI_OBJECT_TYPE_EMF: - { - PLDC pLDC = GdiGetLDC(hObject); - if ( !pLDC ) return FALSE; - return EMFDRV_DeleteObject( hObject ); - } + case GDI_OBJECT_TYPE_METADC: + return MFDRV_DeleteObject( hObject ); + case GDI_OBJECT_TYPE_EMF: + { + PLDC pLDC = GdiGetLDC(hObject); + if ( !pLDC ) return FALSE; + return EMFDRV_DeleteObject( hObject ); + } #endif - case GDI_OBJECT_TYPE_FONT: - break; + case GDI_OBJECT_TYPE_FONT: + break; - case GDI_OBJECT_TYPE_BRUSH: - case GDI_OBJECT_TYPE_EXTPEN: - case GDI_OBJECT_TYPE_PEN: - { - PBRUSH_ATTR Brh_Attr; - PTEB pTeb; + case GDI_OBJECT_TYPE_BRUSH: + case GDI_OBJECT_TYPE_EXTPEN: + case GDI_OBJECT_TYPE_PEN: + { + PBRUSH_ATTR Brh_Attr; + PTEB pTeb; - if ((!GdiGetHandleUserData(hObject, (DWORD)Type, (PVOID) &Brh_Attr)) || - (Brh_Attr == NULL) ) break; + if ((!GdiGetHandleUserData(hObject, (DWORD)Type, (PVOID) &Brh_Attr)) || + (Brh_Attr == NULL) ) break; - pTeb = NtCurrentTeb(); + pTeb = NtCurrentTeb(); - if (pTeb->Win32ThreadInfo == NULL) break; + if (pTeb->Win32ThreadInfo == NULL) break; - if ((pTeb->GdiTebBatch.Offset + sizeof(GDIBSOBJECT)) <= GDIBATCHBUFSIZE) - { - PGDIBSOBJECT pgO = (PGDIBSOBJECT)(&pTeb->GdiTebBatch.Buffer[0] + - pTeb->GdiTebBatch.Offset); - pgO->gbHdr.Cmd = GdiBCDelObj; - pgO->gbHdr.Size = sizeof(GDIBSOBJECT); - pgO->hgdiobj = hObject; + if ((pTeb->GdiTebBatch.Offset + sizeof(GDIBSOBJECT)) <= GDIBATCHBUFSIZE) + { + PGDIBSOBJECT pgO = (PGDIBSOBJECT)(&pTeb->GdiTebBatch.Buffer[0] + + pTeb->GdiTebBatch.Offset); + pgO->gbHdr.Cmd = GdiBCDelObj; + pgO->gbHdr.Size = sizeof(GDIBSOBJECT); + pgO->hgdiobj = hObject; - pTeb->GdiTebBatch.Offset += sizeof(GDIBSOBJECT); - pTeb->GdiBatchCount++; - if (pTeb->GdiBatchCount >= GDI_BatchLimit) NtGdiFlush(); - return TRUE; - } - break; - } - case GDI_OBJECT_TYPE_BITMAP: - default: - break; - } - return NtGdiDeleteObjectApp(hObject); + pTeb->GdiTebBatch.Offset += sizeof(GDIBSOBJECT); + pTeb->GdiBatchCount++; + if (pTeb->GdiBatchCount >= GDI_BatchLimit) NtGdiFlush(); + return TRUE; + } + break; + } + case GDI_OBJECT_TYPE_BITMAP: + default: + break; + } + return NtGdiDeleteObjectApp(hObject); } INT WINAPI GetArcDirection( HDC hdc ) { - return GetDCDWord( hdc, GdiGetArcDirection, 0); + return GetDCDWord( hdc, GdiGetArcDirection, 0); } @@ -405,7 +409,7 @@ INT WINAPI SetArcDirection( HDC hdc, INT nDirection ) { - return GetAndSetDCDWord( hdc, GdiGetSetArcDirection, nDirection, 0, 0, 0 ); + return GetAndSetDCDWord( hdc, GdiGetSetArcDirection, nDirection, 0, 0, 0 ); } @@ -413,36 +417,36 @@ HGDIOBJ WINAPI GetDCObject( HDC hDC, INT iType) { - if((iType == GDI_OBJECT_TYPE_BRUSH) || - (iType == GDI_OBJECT_TYPE_EXTPEN)|| - (iType == GDI_OBJECT_TYPE_PEN) || - (iType == GDI_OBJECT_TYPE_COLORSPACE)) - { - HGDIOBJ hGO = NULL; - PDC_ATTR Dc_Attr; + if((iType == GDI_OBJECT_TYPE_BRUSH) || + (iType == GDI_OBJECT_TYPE_EXTPEN)|| + (iType == GDI_OBJECT_TYPE_PEN) || + (iType == GDI_OBJECT_TYPE_COLORSPACE)) + { + HGDIOBJ hGO = NULL; + PDC_ATTR Dc_Attr; - if (!hDC) return hGO; + if (!hDC) return hGO; - if (!GdiGetHandleUserData((HGDIOBJ) hDC, GDI_OBJECT_TYPE_DC, (PVOID) &Dc_Attr)) return NULL; + if (!GdiGetHandleUserData((HGDIOBJ) hDC, GDI_OBJECT_TYPE_DC, (PVOID) &Dc_Attr)) return NULL; - switch (iType) - { - case GDI_OBJECT_TYPE_BRUSH: - hGO = Dc_Attr->hbrush; - break; + switch (iType) + { + case GDI_OBJECT_TYPE_BRUSH: + hGO = Dc_Attr->hbrush; + break; - case GDI_OBJECT_TYPE_EXTPEN: - case GDI_OBJECT_TYPE_PEN: - hGO = Dc_Attr->hpen; - break; + case GDI_OBJECT_TYPE_EXTPEN: + case GDI_OBJECT_TYPE_PEN: + hGO = Dc_Attr->hpen; + break; - case GDI_OBJECT_TYPE_COLORSPACE: - hGO = Dc_Attr->hColorSpace; - break; - } - return hGO; - } - return NtGdiGetDCObject( hDC, iType ); + case GDI_OBJECT_TYPE_COLORSPACE: + hGO = Dc_Attr->hColorSpace; + break; + } + return hGO; + } + return NtGdiGetDCObject( hDC, iType ); } @@ -457,30 +461,30 @@ GetCurrentObject(HDC hdc, { switch(uObjectType) { - case OBJ_EXTPEN: - case OBJ_PEN: + case OBJ_EXTPEN: + case OBJ_PEN: uObjectType = GDI_OBJECT_TYPE_PEN; break; - case OBJ_BRUSH: + case OBJ_BRUSH: uObjectType = GDI_OBJECT_TYPE_BRUSH; break; - case OBJ_PAL: + case OBJ_PAL: uObjectType = GDI_OBJECT_TYPE_PALETTE; break; - case OBJ_FONT: + case OBJ_FONT: uObjectType = GDI_OBJECT_TYPE_FONT; break; - case OBJ_BITMAP: + case OBJ_BITMAP: uObjectType = GDI_OBJECT_TYPE_BITMAP; break; - case OBJ_COLORSPACE: + case OBJ_COLORSPACE: uObjectType = GDI_OBJECT_TYPE_COLORSPACE; break; - /* tests show that OBJ_REGION is explicitly ignored */ - case OBJ_REGION: + /* tests show that OBJ_REGION is explicitly ignored */ + case OBJ_REGION: return NULL; - /* the SDK only mentions those above */ - default: + /* the SDK only mentions those above */ + default: SetLastError(ERROR_INVALID_PARAMETER); return NULL; } @@ -496,164 +500,164 @@ WINAPI GetDeviceCaps(HDC hDC, int i) { - PDC_ATTR Dc_Attr; - PLDC pLDC; - PDEVCAPS pDevCaps = GdiDevCaps; // Primary display device capabilities. - DPRINT("Device CAPS1\n"); + PDC_ATTR Dc_Attr; + PLDC pLDC; + PDEVCAPS pDevCaps = GdiDevCaps; // Primary display device capabilities. + DPRINT("Device CAPS1\n"); - if (GDI_HANDLE_GET_TYPE(hDC) != GDI_OBJECT_TYPE_DC) - { - if (GDI_HANDLE_GET_TYPE(hDC) == GDI_OBJECT_TYPE_METADC) - { - if ( i == TECHNOLOGY) return DT_METAFILE; - return 0; - } - else - { - pLDC = GdiGetLDC(hDC); - if ( !pLDC ) + if (GDI_HANDLE_GET_TYPE(hDC) != GDI_OBJECT_TYPE_DC) + { + if (GDI_HANDLE_GET_TYPE(hDC) == GDI_OBJECT_TYPE_METADC) { - SetLastError(ERROR_INVALID_HANDLE); - return 0; + if ( i == TECHNOLOGY) return DT_METAFILE; + return 0; } - if (!(pLDC->Flags & LDC_DEVCAPS)) + else { - if (!NtGdiGetDeviceCapsAll(hDC, &pLDC->DevCaps)) - SetLastError(ERROR_INVALID_PARAMETER); - pLDC->Flags |= LDC_DEVCAPS; + pLDC = GdiGetLDC(hDC); + if ( !pLDC ) + { + SetLastError(ERROR_INVALID_HANDLE); + return 0; + } + if (!(pLDC->Flags & LDC_DEVCAPS)) + { + if (!NtGdiGetDeviceCapsAll(hDC, &pLDC->DevCaps)) + SetLastError(ERROR_INVALID_PARAMETER); + pLDC->Flags |= LDC_DEVCAPS; + } + pDevCaps = &pLDC->DevCaps; } - pDevCaps = &pLDC->DevCaps; - } - } - else - { - if (!GdiGetHandleUserData((HGDIOBJ) hDC, GDI_OBJECT_TYPE_DC, (PVOID) &Dc_Attr)) - return 0; - if (!(Dc_Attr->ulDirty_ & DC_PRIMARY_DISPLAY) ) - return NtGdiGetDeviceCaps(hDC,i); - } - DPRINT("Device CAPS2\n"); + } + else + { + if (!GdiGetHandleUserData((HGDIOBJ) hDC, GDI_OBJECT_TYPE_DC, (PVOID) &Dc_Attr)) + return 0; + if (!(Dc_Attr->ulDirty_ & DC_PRIMARY_DISPLAY) ) + return NtGdiGetDeviceCaps(hDC,i); + } + DPRINT("Device CAPS2\n"); - switch (i) - { + switch (i) + { case DRIVERVERSION: - return pDevCaps->ulVersion; + return pDevCaps->ulVersion; case TECHNOLOGY: - return pDevCaps->ulTechnology; + return pDevCaps->ulTechnology; case HORZSIZE: - return pDevCaps->ulHorzSize; + return pDevCaps->ulHorzSize; case VERTSIZE: - return pDevCaps->ulVertSize; + return pDevCaps->ulVertSize; case HORZRES: - return pDevCaps->ulHorzRes; + return pDevCaps->ulHorzRes; case VERTRES: - return pDevCaps->ulVertRes; + return pDevCaps->ulVertRes; case LOGPIXELSX: - return pDevCaps->ulLogPixelsX; + return pDevCaps->ulLogPixelsX; case LOGPIXELSY: - return pDevCaps->ulLogPixelsY; + return pDevCaps->ulLogPixelsY; case BITSPIXEL: - return pDevCaps->ulBitsPixel; + return pDevCaps->ulBitsPixel; case PLANES: - return pDevCaps->ulPlanes; + return pDevCaps->ulPlanes; case NUMBRUSHES: - return -1; + return -1; case NUMPENS: - return pDevCaps->ulNumPens; + return pDevCaps->ulNumPens; case NUMFONTS: - return pDevCaps->ulNumFonts; + return pDevCaps->ulNumFonts; case NUMCOLORS: - return pDevCaps->ulNumColors; + return pDevCaps->ulNumColors; case ASPECTX: - return pDevCaps->ulAspectX; + return pDevCaps->ulAspectX; case ASPECTY: - return pDevCaps->ulAspectY; + return pDevCaps->ulAspectY; case ASPECTXY: - return pDevCaps->ulAspectXY; + return pDevCaps->ulAspectXY; case CLIPCAPS: - return CP_RECTANGLE; + return CP_RECTANGLE; case SIZEPALETTE: - return pDevCaps->ulSizePalette; + return pDevCaps->ulSizePalette; case NUMRESERVED: - return 20; + return 20; case COLORRES: - return pDevCaps->ulColorRes; + return pDevCaps->ulColorRes; case DESKTOPVERTRES: - return pDevCaps->ulVertRes; + return pDevCaps->ulVertRes; case DESKTOPHORZRES: - return pDevCaps->ulHorzRes; + return pDevCaps->ulHorzRes; case BLTALIGNMENT: - return pDevCaps->ulBltAlignment; + return pDevCaps->ulBltAlignment; case SHADEBLENDCAPS: - return pDevCaps->ulShadeBlend; + return pDevCaps->ulShadeBlend; case COLORMGMTCAPS: - return pDevCaps->ulColorMgmtCaps; + return pDevCaps->ulColorMgmtCaps; case PHYSICALWIDTH: - return pDevCaps->ulPhysicalWidth; + return pDevCaps->ulPhysicalWidth; case PHYSICALHEIGHT: - return pDevCaps->ulPhysicalHeight; + return pDevCaps->ulPhysicalHeight; case PHYSICALOFFSETX: - return pDevCaps->ulPhysicalOffsetX; + return pDevCaps->ulPhysicalOffsetX; case PHYSICALOFFSETY: - return pDevCaps->ulPhysicalOffsetY; + return pDevCaps->ulPhysicalOffsetY; case VREFRESH: - return pDevCaps->ulVRefresh; + return pDevCaps->ulVRefresh; case RASTERCAPS: - return pDevCaps->ulRasterCaps; + return pDevCaps->ulRasterCaps; case CURVECAPS: - return (CC_CIRCLES | CC_PIE | CC_CHORD | CC_ELLIPSES | CC_WIDE | - CC_STYLED | CC_WIDESTYLED | CC_INTERIORS | CC_ROUNDRECT); + return (CC_CIRCLES | CC_PIE | CC_CHORD | CC_ELLIPSES | CC_WIDE | + CC_STYLED | CC_WIDESTYLED | CC_INTERIORS | CC_ROUNDRECT); case LINECAPS: - return (LC_POLYLINE | LC_MARKER | LC_POLYMARKER | LC_WIDE | - LC_STYLED | LC_WIDESTYLED | LC_INTERIORS); + return (LC_POLYLINE | LC_MARKER | LC_POLYMARKER | LC_WIDE | + LC_STYLED | LC_WIDESTYLED | LC_INTERIORS); case POLYGONALCAPS: - return (PC_POLYGON | PC_RECTANGLE | PC_WINDPOLYGON | PC_SCANLINE | - PC_WIDE | PC_STYLED | PC_WIDESTYLED | PC_INTERIORS); + return (PC_POLYGON | PC_RECTANGLE | PC_WINDPOLYGON | PC_SCANLINE | + PC_WIDE | PC_STYLED | PC_WIDESTYLED | PC_INTERIORS); case TEXTCAPS: - return pDevCaps->ulTextCaps; + return pDevCaps->ulTextCaps; case PDEVICESIZE: case SCALINGFACTORX: case SCALINGFACTORY: default: - return 0; - } - return 0; + return 0; + } + return 0; } /* @@ -662,11 +666,11 @@ GetDeviceCaps(HDC hDC, DWORD WINAPI GetRelAbs( - HDC hdc, - DWORD dwIgnore - ) + HDC hdc, + DWORD dwIgnore +) { - return GetDCDWord( hdc, GdiGetRelAbs, 0); + return GetDCDWord( hdc, GdiGetRelAbs, 0); } @@ -676,11 +680,11 @@ GetRelAbs( INT WINAPI SetRelAbs( - HDC hdc, - INT Mode - ) + HDC hdc, + INT Mode +) { - return GetAndSetDCDWord( hdc, GdiGetSetRelAbs, Mode, 0, 0, 0 ); + return GetAndSetDCDWord( hdc, GdiGetSetRelAbs, Mode, 0, 0, 0 ); } @@ -691,35 +695,35 @@ DWORD WINAPI GetAndSetDCDWord( HDC hDC, INT u, DWORD dwIn, DWORD Unk1, DWORD Unk2, DWORD Unk3 ) { - BOOL Ret = TRUE; + BOOL Ret = TRUE; // Handle something other than a normal dc object. - if (GDI_HANDLE_GET_TYPE(hDC) != GDI_OBJECT_TYPE_DC) - { - if (GDI_HANDLE_GET_TYPE(hDC) == GDI_OBJECT_TYPE_METADC) - return 0; //call MFDRV - else + if (GDI_HANDLE_GET_TYPE(hDC) != GDI_OBJECT_TYPE_DC) { - PLDC pLDC = GdiGetLDC(hDC); - if ( !pLDC ) - { - SetLastError(ERROR_INVALID_HANDLE); - return 0; - } - if (pLDC->iType == LDC_EMFLDC) - { - Ret = TRUE; //call EMFDRV - if (Ret) - return u; - return 0; - } + if (GDI_HANDLE_GET_TYPE(hDC) == GDI_OBJECT_TYPE_METADC) + return 0; //call MFDRV + else + { + PLDC pLDC = GdiGetLDC(hDC); + if ( !pLDC ) + { + SetLastError(ERROR_INVALID_HANDLE); + return 0; + } + if (pLDC->iType == LDC_EMFLDC) + { + Ret = TRUE; //call EMFDRV + if (Ret) + return u; + return 0; + } + } } - } - Ret = NtGdiGetAndSetDCDword( hDC, u, dwIn, (DWORD*) &u ); - if (Ret) - return u; - else - SetLastError(ERROR_INVALID_HANDLE); - return 0; + Ret = NtGdiGetAndSetDCDword( hDC, u, dwIn, (DWORD*) &u ); + if (Ret) + return u; + else + SetLastError(ERROR_INVALID_HANDLE); + return 0; } @@ -730,9 +734,9 @@ DWORD WINAPI GetDCDWord( HDC hDC, INT u, DWORD Result ) { - BOOL Ret = NtGdiGetDCDword( hDC, u, (DWORD*) &u ); - if (!Ret) return Result; - else return u; + BOOL Ret = NtGdiGetDCDword( hDC, u, (DWORD*) &u ); + if (!Ret) return Result; + else return u; } @@ -742,11 +746,11 @@ GetDCDWord( HDC hDC, INT u, DWORD Result ) BOOL WINAPI GetAspectRatioFilterEx( - HDC hdc, - LPSIZE lpAspectRatio - ) + HDC hdc, + LPSIZE lpAspectRatio +) { - return NtGdiGetDCPoint( hdc, GdiGetAspectRatioFilter, (PPOINTL) lpAspectRatio ); + return NtGdiGetDCPoint( hdc, GdiGetAspectRatioFilter, (PPOINTL) lpAspectRatio ); } @@ -758,9 +762,9 @@ WINAPI GetDCOrgEx( HDC hdc, LPPOINT lpPoint - ) +) { - return NtGdiGetDCPoint( hdc, GdiGetDCOrg, (PPOINTL)lpPoint ); + return NtGdiGetDCPoint( hdc, GdiGetDCOrg, (PPOINTL)lpPoint ); } @@ -771,58 +775,58 @@ LONG WINAPI GetDCOrg( HDC hdc - ) +) { - // Officially obsolete by Microsoft - POINT Pt; - if (!GetDCOrgEx(hdc, &Pt)) - return 0; - return(MAKELONG(Pt.x, Pt.y)); + // Officially obsolete by Microsoft + POINT Pt; + if (!GetDCOrgEx(hdc, &Pt)) + return 0; + return(MAKELONG(Pt.x, Pt.y)); } int GetNonFontObject(HGDIOBJ hGdiObj, int cbSize, LPVOID lpBuffer) { - INT dwType; + INT dwType; - hGdiObj = (HANDLE)GdiFixUpHandle(hGdiObj); - dwType = GDI_HANDLE_GET_TYPE(hGdiObj); + hGdiObj = (HANDLE)GdiFixUpHandle(hGdiObj); + dwType = GDI_HANDLE_GET_TYPE(hGdiObj); + + if (!lpBuffer) // Should pass it all to Win32k and let god sort it out. ;^) + { + switch(dwType) + { + case GDI_OBJECT_TYPE_PEN: + return sizeof(LOGPEN); + case GDI_OBJECT_TYPE_BRUSH: + return sizeof(LOGBRUSH); + case GDI_OBJECT_TYPE_BITMAP: + return sizeof(BITMAP); + case GDI_OBJECT_TYPE_PALETTE: + return sizeof(WORD); + case GDI_OBJECT_TYPE_EXTPEN: /* we don't know the size, ask win32k */ + break; + } + } - if (!lpBuffer) // Should pass it all to Win32k and let god sort it out. ;^) - { switch(dwType) { - case GDI_OBJECT_TYPE_PEN: - return sizeof(LOGPEN); - case GDI_OBJECT_TYPE_BRUSH: - return sizeof(LOGBRUSH); - case GDI_OBJECT_TYPE_BITMAP: - return sizeof(BITMAP); - case GDI_OBJECT_TYPE_PALETTE: - return sizeof(WORD); - case GDI_OBJECT_TYPE_EXTPEN: /* we don't know the size, ask win32k */ - break; - } - } - - switch(dwType) - { case GDI_OBJECT_TYPE_PEN: //Check the structures and see if A & W are the same. case GDI_OBJECT_TYPE_EXTPEN: case GDI_OBJECT_TYPE_BRUSH: // Mixing Apples and Oranges? case GDI_OBJECT_TYPE_BITMAP: case GDI_OBJECT_TYPE_PALETTE: - return NtGdiExtGetObjectW(hGdiObj, cbSize, lpBuffer); + return NtGdiExtGetObjectW(hGdiObj, cbSize, lpBuffer); case GDI_OBJECT_TYPE_DC: case GDI_OBJECT_TYPE_REGION: case GDI_OBJECT_TYPE_METAFILE: case GDI_OBJECT_TYPE_ENHMETAFILE: case GDI_OBJECT_TYPE_EMF: - SetLastError(ERROR_INVALID_HANDLE); - } - return 0; + SetLastError(ERROR_INVALID_HANDLE); + } + return 0; } @@ -833,62 +837,62 @@ int WINAPI GetObjectA(HGDIOBJ hGdiObj, int cbSize, LPVOID lpBuffer) { - ENUMLOGFONTEXDVW LogFont; - DWORD dwType; - INT Result = 0; + ENUMLOGFONTEXDVW LogFont; + DWORD dwType; + INT Result = 0; - dwType = GDI_HANDLE_GET_TYPE(hGdiObj); + dwType = GDI_HANDLE_GET_TYPE(hGdiObj); - if(dwType == GDI_OBJECT_TYPE_COLORSPACE) //Stays here, processes struct A - { - SetLastError(ERROR_NOT_SUPPORTED); - return 0; - } - - if (dwType == GDI_OBJECT_TYPE_FONT) - { - if (!lpBuffer) + if(dwType == GDI_OBJECT_TYPE_COLORSPACE) //Stays here, processes struct A { - return sizeof(LOGFONTA); - } - if (cbSize == 0) - { - /* Windows does not SetLastError() */ - return 0; - } - // ENUMLOGFONTEXDVW is the default size and should be the structure for - // Entry->KernelData for Font objects. - Result = NtGdiExtGetObjectW(hGdiObj, sizeof(ENUMLOGFONTEXDVW), &LogFont); - - if (0 == Result) - { - return 0; + SetLastError(ERROR_NOT_SUPPORTED); + return 0; } - switch (cbSize) - { - case sizeof(ENUMLOGFONTEXDVA): - // need to move more here. - case sizeof(ENUMLOGFONTEXA): + if (dwType == GDI_OBJECT_TYPE_FONT) + { + if (!lpBuffer) + { + return sizeof(LOGFONTA); + } + if (cbSize == 0) + { + /* Windows does not SetLastError() */ + return 0; + } + // ENUMLOGFONTEXDVW is the default size and should be the structure for + // Entry->KernelData for Font objects. + Result = NtGdiExtGetObjectW(hGdiObj, sizeof(ENUMLOGFONTEXDVW), &LogFont); + + if (0 == Result) + { + return 0; + } + + switch (cbSize) + { + case sizeof(ENUMLOGFONTEXDVA): + // need to move more here. + case sizeof(ENUMLOGFONTEXA): EnumLogFontExW2A( (LPENUMLOGFONTEXA) lpBuffer, &LogFont.elfEnumLogfontEx ); break; - case sizeof(ENUMLOGFONTA): - // Same here, maybe? Check the structures. - case sizeof(EXTLOGFONTA): - // Same here - case sizeof(LOGFONTA): + case sizeof(ENUMLOGFONTA): + // Same here, maybe? Check the structures. + case sizeof(EXTLOGFONTA): + // Same here + case sizeof(LOGFONTA): LogFontW2A((LPLOGFONTA) lpBuffer, &LogFont.elfEnumLogfontEx.elfLogFont); break; - default: + default: SetLastError(ERROR_BUFFER_OVERFLOW); return 0; - } - return cbSize; - } + } + return cbSize; + } - return GetNonFontObject(hGdiObj, cbSize, lpBuffer); + return GetNonFontObject(hGdiObj, cbSize, lpBuffer); } @@ -899,47 +903,47 @@ int WINAPI GetObjectW(HGDIOBJ hGdiObj, int cbSize, LPVOID lpBuffer) { - DWORD dwType = GDI_HANDLE_GET_TYPE(hGdiObj); - INT Result = 0; + DWORD dwType = GDI_HANDLE_GET_TYPE(hGdiObj); + INT Result = 0; -/* - Check List: - MSDN, "This can be a handle to one of the following: logical bitmap, a brush, - a font, a palette, a pen, or a device independent bitmap created by calling - the CreateDIBSection function." - */ - if(dwType == GDI_OBJECT_TYPE_COLORSPACE) //Stays here, processes struct W - { - SetLastError(ERROR_NOT_SUPPORTED); // Not supported yet. - return 0; - } - - if (dwType == GDI_OBJECT_TYPE_FONT) - { - if (!lpBuffer) + /* + Check List: + MSDN, "This can be a handle to one of the following: logical bitmap, a brush, + a font, a palette, a pen, or a device independent bitmap created by calling + the CreateDIBSection function." + */ + if(dwType == GDI_OBJECT_TYPE_COLORSPACE) //Stays here, processes struct W { - return sizeof(LOGFONTW); + SetLastError(ERROR_NOT_SUPPORTED); // Not supported yet. + return 0; } - if (cbSize == 0) + if (dwType == GDI_OBJECT_TYPE_FONT) { - /* Windows does not SetLastError() */ - return 0; + if (!lpBuffer) + { + return sizeof(LOGFONTW); + } + + if (cbSize == 0) + { + /* Windows does not SetLastError() */ + return 0; + } + // Poorly written apps are not ReactOS problem! + // We fix it here if the size is larger than the default size. + if( cbSize > (int)sizeof(ENUMLOGFONTEXDVW) ) cbSize = sizeof(ENUMLOGFONTEXDVW); + + Result = NtGdiExtGetObjectW(hGdiObj, cbSize, lpBuffer); // Should handle the copy. + + if (0 == Result) + { + return 0; + } + return cbSize; } - // Poorly written apps are not ReactOS problem! - // We fix it here if the size is larger than the default size. - if( cbSize > (int)sizeof(ENUMLOGFONTEXDVW) ) cbSize = sizeof(ENUMLOGFONTEXDVW); - Result = NtGdiExtGetObjectW(hGdiObj, cbSize, lpBuffer); // Should handle the copy. - - if (0 == Result) - { - return 0; - } - return cbSize; - } - - return GetNonFontObject(hGdiObj, cbSize, lpBuffer); + return GetNonFontObject(hGdiObj, cbSize, lpBuffer); } @@ -949,13 +953,13 @@ GetObjectW(HGDIOBJ hGdiObj, int cbSize, LPVOID lpBuffer) COLORREF WINAPI GetDCBrushColor( - HDC hdc + HDC hdc ) { - PDC_ATTR Dc_Attr; + PDC_ATTR Dc_Attr; - if (!GdiGetHandleUserData((HGDIOBJ) hdc, GDI_OBJECT_TYPE_DC, (PVOID) &Dc_Attr)) return CLR_INVALID; - return (COLORREF) Dc_Attr->ulBrushClr; + if (!GdiGetHandleUserData((HGDIOBJ) hdc, GDI_OBJECT_TYPE_DC, (PVOID) &Dc_Attr)) return CLR_INVALID; + return (COLORREF) Dc_Attr->ulBrushClr; } /* @@ -964,13 +968,13 @@ GetDCBrushColor( COLORREF WINAPI GetDCPenColor( - HDC hdc + HDC hdc ) { - PDC_ATTR Dc_Attr; + PDC_ATTR Dc_Attr; - if (!GdiGetHandleUserData((HGDIOBJ) hdc, GDI_OBJECT_TYPE_DC, (PVOID) &Dc_Attr)) return CLR_INVALID; - return (COLORREF) Dc_Attr->ulPenClr; + if (!GdiGetHandleUserData((HGDIOBJ) hdc, GDI_OBJECT_TYPE_DC, (PVOID) &Dc_Attr)) return CLR_INVALID; + return (COLORREF) Dc_Attr->ulPenClr; } /* @@ -979,26 +983,26 @@ GetDCPenColor( COLORREF WINAPI SetDCBrushColor( - HDC hdc, - COLORREF crColor + HDC hdc, + COLORREF crColor ) { - PDC_ATTR Dc_Attr; - COLORREF OldColor = CLR_INVALID; + PDC_ATTR Dc_Attr; + COLORREF OldColor = CLR_INVALID; - if (!GdiGetHandleUserData((HGDIOBJ) hdc, GDI_OBJECT_TYPE_DC, (PVOID) &Dc_Attr)) return OldColor; - else - { - OldColor = (COLORREF) Dc_Attr->ulBrushClr; - Dc_Attr->ulBrushClr = (ULONG) crColor; - - if ( Dc_Attr->crBrushClr != crColor ) // if same, don't force a copy. + if (!GdiGetHandleUserData((HGDIOBJ) hdc, GDI_OBJECT_TYPE_DC, (PVOID) &Dc_Attr)) return OldColor; + else { - Dc_Attr->ulDirty_ |= DIRTY_FILL; - Dc_Attr->crBrushClr = crColor; + OldColor = (COLORREF) Dc_Attr->ulBrushClr; + Dc_Attr->ulBrushClr = (ULONG) crColor; + + if ( Dc_Attr->crBrushClr != crColor ) // if same, don't force a copy. + { + Dc_Attr->ulDirty_ |= DIRTY_FILL; + Dc_Attr->crBrushClr = crColor; + } } - } - return OldColor; + return OldColor; } /* @@ -1007,26 +1011,26 @@ SetDCBrushColor( COLORREF WINAPI SetDCPenColor( - HDC hdc, - COLORREF crColor + HDC hdc, + COLORREF crColor ) { - PDC_ATTR Dc_Attr; - COLORREF OldColor = CLR_INVALID; + PDC_ATTR Dc_Attr; + COLORREF OldColor = CLR_INVALID; - if (!GdiGetHandleUserData((HGDIOBJ) hdc, GDI_OBJECT_TYPE_DC, (PVOID) &Dc_Attr)) return OldColor; - else - { - OldColor = (COLORREF) Dc_Attr->ulPenClr; - Dc_Attr->ulPenClr = (ULONG) crColor; - - if ( Dc_Attr->crPenClr != crColor ) + if (!GdiGetHandleUserData((HGDIOBJ) hdc, GDI_OBJECT_TYPE_DC, (PVOID) &Dc_Attr)) return OldColor; + else { - Dc_Attr->ulDirty_ |= DIRTY_LINE; - Dc_Attr->crPenClr = crColor; + OldColor = (COLORREF) Dc_Attr->ulPenClr; + Dc_Attr->ulPenClr = (ULONG) crColor; + + if ( Dc_Attr->crPenClr != crColor ) + { + Dc_Attr->ulDirty_ |= DIRTY_LINE; + Dc_Attr->crPenClr = crColor; + } } - } - return OldColor; + return OldColor; } /* @@ -1037,9 +1041,9 @@ COLORREF WINAPI GetBkColor(HDC hdc) { - PDC_ATTR Dc_Attr; - if (!GdiGetHandleUserData((HGDIOBJ) hdc, GDI_OBJECT_TYPE_DC, (PVOID) &Dc_Attr)) return 0; - return Dc_Attr->ulBackgroundClr; + PDC_ATTR Dc_Attr; + if (!GdiGetHandleUserData((HGDIOBJ) hdc, GDI_OBJECT_TYPE_DC, (PVOID) &Dc_Attr)) return 0; + return Dc_Attr->ulBackgroundClr; } /* @@ -1048,43 +1052,43 @@ GetBkColor(HDC hdc) COLORREF WINAPI SetBkColor( - HDC hdc, - COLORREF crColor + HDC hdc, + COLORREF crColor ) { - PDC_ATTR Dc_Attr; - COLORREF OldColor = CLR_INVALID; + PDC_ATTR Dc_Attr; + COLORREF OldColor = CLR_INVALID; - if (!GdiGetHandleUserData((HGDIOBJ) hdc, GDI_OBJECT_TYPE_DC, (PVOID) &Dc_Attr)) return OldColor; + if (!GdiGetHandleUserData((HGDIOBJ) hdc, GDI_OBJECT_TYPE_DC, (PVOID) &Dc_Attr)) return OldColor; #if 0 - if (GDI_HANDLE_GET_TYPE(hDC) != GDI_OBJECT_TYPE_DC) - { - if (GDI_HANDLE_GET_TYPE(hDC) == GDI_OBJECT_TYPE_METADC) - return MFDRV_SetBkColor( hDC, crColor ); - else + if (GDI_HANDLE_GET_TYPE(hDC) != GDI_OBJECT_TYPE_DC) { - PLDC pLDC = Dc_Attr->pvLDC; - if ( !pLDC ) - { - SetLastError(ERROR_INVALID_HANDLE); - return FALSE; - } - if (pLDC->iType == LDC_EMFLDC) - { - return EMFDRV_SetBkColor( hDC, crColor ); - } + if (GDI_HANDLE_GET_TYPE(hDC) == GDI_OBJECT_TYPE_METADC) + return MFDRV_SetBkColor( hDC, crColor ); + else + { + PLDC pLDC = Dc_Attr->pvLDC; + if ( !pLDC ) + { + SetLastError(ERROR_INVALID_HANDLE); + return FALSE; + } + if (pLDC->iType == LDC_EMFLDC) + { + return EMFDRV_SetBkColor( hDC, crColor ); + } + } } - } #endif - OldColor = (COLORREF) Dc_Attr->ulBackgroundClr; - Dc_Attr->ulBackgroundClr = (ULONG) crColor; + OldColor = (COLORREF) Dc_Attr->ulBackgroundClr; + Dc_Attr->ulBackgroundClr = (ULONG) crColor; - if ( Dc_Attr->crBackgroundClr != crColor ) - { - Dc_Attr->ulDirty_ |= (DIRTY_BACKGROUND|DIRTY_LINE|DIRTY_FILL); - Dc_Attr->crBackgroundClr = crColor; - } - return OldColor; + if ( Dc_Attr->crBackgroundClr != crColor ) + { + Dc_Attr->ulDirty_ |= (DIRTY_BACKGROUND|DIRTY_LINE|DIRTY_FILL); + Dc_Attr->crBackgroundClr = crColor; + } + return OldColor; } /* @@ -1095,9 +1099,9 @@ int WINAPI GetBkMode(HDC hdc) { - PDC_ATTR Dc_Attr; - if (!GdiGetHandleUserData((HGDIOBJ) hdc, GDI_OBJECT_TYPE_DC, (PVOID) &Dc_Attr)) return 0; - return Dc_Attr->lBkMode; + PDC_ATTR Dc_Attr; + if (!GdiGetHandleUserData((HGDIOBJ) hdc, GDI_OBJECT_TYPE_DC, (PVOID) &Dc_Attr)) return 0; + return Dc_Attr->lBkMode; } /* @@ -1107,36 +1111,36 @@ GetBkMode(HDC hdc) int WINAPI SetBkMode(HDC hdc, - int iBkMode) + int iBkMode) { - PDC_ATTR Dc_Attr; - INT OldMode = 0; + PDC_ATTR Dc_Attr; + INT OldMode = 0; - if (!GdiGetHandleUserData((HGDIOBJ) hdc, GDI_OBJECT_TYPE_DC, (PVOID) &Dc_Attr)) return OldMode; + if (!GdiGetHandleUserData((HGDIOBJ) hdc, GDI_OBJECT_TYPE_DC, (PVOID) &Dc_Attr)) return OldMode; #if 0 - if (GDI_HANDLE_GET_TYPE(hdc) != GDI_OBJECT_TYPE_DC) - { - if (GDI_HANDLE_GET_TYPE(hdc) == GDI_OBJECT_TYPE_METADC) - return MFDRV_SetBkMode( hdc, iBkMode ) - else + if (GDI_HANDLE_GET_TYPE(hdc) != GDI_OBJECT_TYPE_DC) { - PLDC pLDC = Dc_Attr->pvLDC; - if ( !pLDC ) - { - SetLastError(ERROR_INVALID_HANDLE); - return FALSE; - } - if (pLDC->iType == LDC_EMFLDC) - { - return EMFDRV_SetBkMode( hdc, iBkMode ) - } - } - } + if (GDI_HANDLE_GET_TYPE(hdc) == GDI_OBJECT_TYPE_METADC) + return MFDRV_SetBkMode( hdc, iBkMode ) + else + { + PLDC pLDC = Dc_Attr->pvLDC; + if ( !pLDC ) + { + SetLastError(ERROR_INVALID_HANDLE); + return FALSE; + } + if (pLDC->iType == LDC_EMFLDC) + { + return EMFDRV_SetBkMode( hdc, iBkMode ) + } + } + } #endif - OldMode = Dc_Attr->lBkMode; - Dc_Attr->jBkMode = iBkMode; // Processed - Dc_Attr->lBkMode = iBkMode; // Raw - return OldMode; + OldMode = Dc_Attr->lBkMode; + Dc_Attr->jBkMode = iBkMode; // Processed + Dc_Attr->lBkMode = iBkMode; // Raw + return OldMode; } /* @@ -1147,9 +1151,9 @@ int WINAPI GetPolyFillMode(HDC hdc) { - PDC_ATTR Dc_Attr; - if (!GdiGetHandleUserData((HGDIOBJ) hdc, GDI_OBJECT_TYPE_DC, (PVOID) &Dc_Attr)) return 0; - return Dc_Attr->lFillMode; + PDC_ATTR Dc_Attr; + if (!GdiGetHandleUserData((HGDIOBJ) hdc, GDI_OBJECT_TYPE_DC, (PVOID) &Dc_Attr)) return 0; + return Dc_Attr->lFillMode; } /* @@ -1160,43 +1164,43 @@ WINAPI SetPolyFillMode(HDC hdc, int iPolyFillMode) { - INT fmode; - PDC_ATTR Dc_Attr; + INT fmode; + PDC_ATTR Dc_Attr; #if 0 - if (GDI_HANDLE_GET_TYPE(hdc) != GDI_OBJECT_TYPE_DC) - { - if (GDI_HANDLE_GET_TYPE(hdc) == GDI_OBJECT_TYPE_METADC) - return MFDRV_SetPolyFillMode( hdc, iPolyFillMode ) - else + if (GDI_HANDLE_GET_TYPE(hdc) != GDI_OBJECT_TYPE_DC) { - PLDC pLDC = GdiGetLDC(hdc); - if ( !pLDC ) - { - SetLastError(ERROR_INVALID_HANDLE); - return FALSE; - } - if (pLDC->iType == LDC_EMFLDC) - { - return EMFDRV_SetPolyFillMode( hdc, iPolyFillMode ) - } - } - } + if (GDI_HANDLE_GET_TYPE(hdc) == GDI_OBJECT_TYPE_METADC) + return MFDRV_SetPolyFillMode( hdc, iPolyFillMode ) + else + { + PLDC pLDC = GdiGetLDC(hdc); + if ( !pLDC ) + { + SetLastError(ERROR_INVALID_HANDLE); + return FALSE; + } + if (pLDC->iType == LDC_EMFLDC) + { + return EMFDRV_SetPolyFillMode( hdc, iPolyFillMode ) + } + } + } #endif - if (!GdiGetHandleUserData((HGDIOBJ) hdc, GDI_OBJECT_TYPE_DC, (PVOID) &Dc_Attr)) return 0; + if (!GdiGetHandleUserData((HGDIOBJ) hdc, GDI_OBJECT_TYPE_DC, (PVOID) &Dc_Attr)) return 0; - if (NtCurrentTeb()->GdiTebBatch.HDC == hdc) - { - if (Dc_Attr->ulDirty_ & DC_MODE_DIRTY) - { - NtGdiFlush(); // Sync up Dc_Attr from Kernel space. - Dc_Attr->ulDirty_ &= ~(DC_MODE_DIRTY|DC_FONTTEXT_DIRTY); - } - } + if (NtCurrentTeb()->GdiTebBatch.HDC == hdc) + { + if (Dc_Attr->ulDirty_ & DC_MODE_DIRTY) + { + NtGdiFlush(); // Sync up Dc_Attr from Kernel space. + Dc_Attr->ulDirty_ &= ~(DC_MODE_DIRTY|DC_FONTTEXT_DIRTY); + } + } - fmode = Dc_Attr->lFillMode; - Dc_Attr->lFillMode = iPolyFillMode; + fmode = Dc_Attr->lFillMode; + Dc_Attr->lFillMode = iPolyFillMode; - return fmode; + return fmode; } /* @@ -1207,9 +1211,9 @@ int WINAPI GetGraphicsMode(HDC hdc) { - PDC_ATTR Dc_Attr; - if (!GdiGetHandleUserData((HGDIOBJ) hdc, GDI_OBJECT_TYPE_DC, (PVOID) &Dc_Attr)) return 0; - return Dc_Attr->iGraphicsMode; + PDC_ATTR Dc_Attr; + if (!GdiGetHandleUserData((HGDIOBJ) hdc, GDI_OBJECT_TYPE_DC, (PVOID) &Dc_Attr)) return 0; + return Dc_Attr->iGraphicsMode; } /* @@ -1220,34 +1224,34 @@ WINAPI SetGraphicsMode(HDC hdc, int iMode) { - INT oMode; - PDC_ATTR Dc_Attr; - if ((iMode < GM_COMPATIBLE) || (iMode > GM_ADVANCED)) - { - SetLastError(ERROR_INVALID_PARAMETER); - return 0; - } - if (!GdiGetHandleUserData((HGDIOBJ) hdc, GDI_OBJECT_TYPE_DC, (PVOID) &Dc_Attr)) return 0; + INT oMode; + PDC_ATTR Dc_Attr; + if ((iMode < GM_COMPATIBLE) || (iMode > GM_ADVANCED)) + { + SetLastError(ERROR_INVALID_PARAMETER); + return 0; + } + if (!GdiGetHandleUserData((HGDIOBJ) hdc, GDI_OBJECT_TYPE_DC, (PVOID) &Dc_Attr)) return 0; - if (iMode == Dc_Attr->iGraphicsMode) return iMode; + if (iMode == Dc_Attr->iGraphicsMode) return iMode; - if (NtCurrentTeb()->GdiTebBatch.HDC == hdc) - { - if (Dc_Attr->ulDirty_ & DC_MODE_DIRTY) - { - NtGdiFlush(); // Sync up Dc_Attr from Kernel space. - Dc_Attr->ulDirty_ &= ~(DC_MODE_DIRTY|DC_FONTTEXT_DIRTY); - } - } -/* One would think that setting the graphics mode to GM_COMPATIBLE - * would also reset the world transformation matrix to the unity - * matrix. However, in Windows, this is not the case. This doesn't - * make a lot of sense to me, but that's the way it is. - */ - oMode = Dc_Attr->iGraphicsMode; - Dc_Attr->iGraphicsMode = iMode; + if (NtCurrentTeb()->GdiTebBatch.HDC == hdc) + { + if (Dc_Attr->ulDirty_ & DC_MODE_DIRTY) + { + NtGdiFlush(); // Sync up Dc_Attr from Kernel space. + Dc_Attr->ulDirty_ &= ~(DC_MODE_DIRTY|DC_FONTTEXT_DIRTY); + } + } + /* One would think that setting the graphics mode to GM_COMPATIBLE + * would also reset the world transformation matrix to the unity + * matrix. However, in Windows, this is not the case. This doesn't + * make a lot of sense to me, but that's the way it is. + */ + oMode = Dc_Attr->iGraphicsMode; + Dc_Attr->iGraphicsMode = iMode; - return oMode; + return oMode; } /* @@ -1256,12 +1260,12 @@ SetGraphicsMode(HDC hdc, HDC WINAPI ResetDCW( - HDC hdc, - CONST DEVMODEW *lpInitData - ) + HDC hdc, + CONST DEVMODEW *lpInitData +) { - NtGdiResetDC ( hdc, (PDEVMODEW)lpInitData, NULL, NULL, NULL); - return hdc; + NtGdiResetDC ( hdc, (PDEVMODEW)lpInitData, NULL, NULL, NULL); + return hdc; } @@ -1271,17 +1275,17 @@ ResetDCW( HDC WINAPI ResetDCA( - HDC hdc, - CONST DEVMODEA *lpInitData - ) + HDC hdc, + CONST DEVMODEA *lpInitData +) { - LPDEVMODEW InitDataW; + LPDEVMODEW InitDataW; - InitDataW = GdiConvertToDevmodeW((LPDEVMODEA)lpInitData); + InitDataW = GdiConvertToDevmodeW((LPDEVMODEA)lpInitData); - NtGdiResetDC ( hdc, InitDataW, NULL, NULL, NULL); - HEAP_free(InitDataW); - return hdc; + NtGdiResetDC ( hdc, InitDataW, NULL, NULL, NULL); + HEAP_free(InitDataW); + return hdc; } @@ -1291,67 +1295,67 @@ ResetDCA( DWORD WINAPI GetObjectType( - HGDIOBJ h - ) + HGDIOBJ h +) { - DWORD Ret = 0; + DWORD Ret = 0; - if(GdiIsHandleValid(h)) - { - LONG Type = GDI_HANDLE_GET_TYPE(h); - switch(Type) + if(GdiIsHandleValid(h)) { - case GDI_OBJECT_TYPE_PEN: - Ret = OBJ_PEN; - break; - case GDI_OBJECT_TYPE_BRUSH: - Ret = OBJ_BRUSH; - break; - case GDI_OBJECT_TYPE_BITMAP: - Ret = OBJ_BITMAP; - break; - case GDI_OBJECT_TYPE_FONT: - Ret = OBJ_FONT; - break; - case GDI_OBJECT_TYPE_PALETTE: - Ret = OBJ_PAL; - break; - case GDI_OBJECT_TYPE_REGION: - Ret = OBJ_REGION; - break; - case GDI_OBJECT_TYPE_DC: - if ( GetDCDWord( h, GdiGetIsMemDc, 0)) + LONG Type = GDI_HANDLE_GET_TYPE(h); + switch(Type) { - Ret = OBJ_MEMDC; - } - else - Ret = OBJ_DC; - break; - case GDI_OBJECT_TYPE_COLORSPACE: - Ret = OBJ_COLORSPACE; - break; - case GDI_OBJECT_TYPE_METAFILE: - Ret = OBJ_METAFILE; - break; - case GDI_OBJECT_TYPE_ENHMETAFILE: - Ret = OBJ_ENHMETAFILE; - break; - case GDI_OBJECT_TYPE_METADC: - Ret = OBJ_METADC; - break; - case GDI_OBJECT_TYPE_EXTPEN: - Ret = OBJ_EXTPEN; - break; + case GDI_OBJECT_TYPE_PEN: + Ret = OBJ_PEN; + break; + case GDI_OBJECT_TYPE_BRUSH: + Ret = OBJ_BRUSH; + break; + case GDI_OBJECT_TYPE_BITMAP: + Ret = OBJ_BITMAP; + break; + case GDI_OBJECT_TYPE_FONT: + Ret = OBJ_FONT; + break; + case GDI_OBJECT_TYPE_PALETTE: + Ret = OBJ_PAL; + break; + case GDI_OBJECT_TYPE_REGION: + Ret = OBJ_REGION; + break; + case GDI_OBJECT_TYPE_DC: + if ( GetDCDWord( h, GdiGetIsMemDc, 0)) + { + Ret = OBJ_MEMDC; + } + else + Ret = OBJ_DC; + break; + case GDI_OBJECT_TYPE_COLORSPACE: + Ret = OBJ_COLORSPACE; + break; + case GDI_OBJECT_TYPE_METAFILE: + Ret = OBJ_METAFILE; + break; + case GDI_OBJECT_TYPE_ENHMETAFILE: + Ret = OBJ_ENHMETAFILE; + break; + case GDI_OBJECT_TYPE_METADC: + Ret = OBJ_METADC; + break; + case GDI_OBJECT_TYPE_EXTPEN: + Ret = OBJ_EXTPEN; + break; - default: - DPRINT1("GetObjectType: Magic 0x%08x not implemented\n", Type); - break; + default: + DPRINT1("GetObjectType: Magic 0x%08x not implemented\n", Type); + break; + } } - } - else - /* From Wine: GetObjectType does SetLastError() on a null object */ - SetLastError(ERROR_INVALID_HANDLE); - return Ret; + else + /* From Wine: GetObjectType does SetLastError() on a null object */ + SetLastError(ERROR_INVALID_HANDLE); + return Ret; } @@ -1361,29 +1365,29 @@ GetObjectType( HGDIOBJ WINAPI GetStockObject( - INT h - ) + INT h +) { - HGDIOBJ Ret = NULL; - if ((h < 0) || (h >= NB_STOCK_OBJECTS)) return Ret; - Ret = stock_objects[h]; - if (!Ret) - { - HGDIOBJ Obj = NtGdiGetStockObject( h ); + HGDIOBJ Ret = NULL; + if ((h < 0) || (h >= NB_STOCK_OBJECTS)) return Ret; + Ret = stock_objects[h]; + if (!Ret) + { + HGDIOBJ Obj = NtGdiGetStockObject( h ); - if (GdiIsHandleValid(Obj)) - { - stock_objects[h] = Obj; - return Obj; - }// Returns Null anyway. - } - return Ret; + if (GdiIsHandleValid(Obj)) + { + stock_objects[h] = Obj; + return Obj; + }// Returns Null anyway. + } + return Ret; } /* FIXME: include correct header */ HPALETTE WINAPI NtUserSelectPalette(HDC hDC, - HPALETTE hpal, - BOOL ForceBackground); + HPALETTE hpal, + BOOL ForceBackground); HPALETTE WINAPI @@ -1393,24 +1397,24 @@ SelectPalette( BOOL bForceBackground) { #if 0 - if (GDI_HANDLE_GET_TYPE(hDC) != GDI_OBJECT_TYPE_DC) - { - if (GDI_HANDLE_GET_TYPE(hDC) == GDI_OBJECT_TYPE_METADC) - return MFDRV_SelectPalette( hDC, hPal, bForceBackground); - else + if (GDI_HANDLE_GET_TYPE(hDC) != GDI_OBJECT_TYPE_DC) { - PLDC pLDC = GdiGetLDC(hDC); - if ( !pLDC ) - { - SetLastError(ERROR_INVALID_HANDLE); - return NULL; - } - if (pLDC->iType == LDC_EMFLDC) - { - if return EMFDRV_SelectPalette( hDC, hPal, bForceBackground); - } + if (GDI_HANDLE_GET_TYPE(hDC) == GDI_OBJECT_TYPE_METADC) + return MFDRV_SelectPalette( hDC, hPal, bForceBackground); + else + { + PLDC pLDC = GdiGetLDC(hDC); + if ( !pLDC ) + { + SetLastError(ERROR_INVALID_HANDLE); + return NULL; + } + if (pLDC->iType == LDC_EMFLDC) + { + if return EMFDRV_SelectPalette( hDC, hPal, bForceBackground); + } + } } - } #endif return NtUserSelectPalette(hDC, hPal, bForceBackground); } @@ -1423,9 +1427,9 @@ int WINAPI GetMapMode(HDC hdc) { - PDC_ATTR Dc_Attr; - if (!GdiGetHandleUserData((HGDIOBJ) hdc, GDI_OBJECT_TYPE_DC, (PVOID) &Dc_Attr)) return 0; - return Dc_Attr->iMapMode; + PDC_ATTR Dc_Attr; + if (!GdiGetHandleUserData((HGDIOBJ) hdc, GDI_OBJECT_TYPE_DC, (PVOID) &Dc_Attr)) return 0; + return Dc_Attr->iMapMode; } /* @@ -1434,129 +1438,129 @@ GetMapMode(HDC hdc) INT WINAPI SetMapMode( - HDC hdc, - INT Mode - ) + HDC hdc, + INT Mode +) { - PDC_ATTR Dc_Attr; - if (!GdiGetHandleUserData((HGDIOBJ) hdc, GDI_OBJECT_TYPE_DC, (PVOID) &Dc_Attr)) return 0; + PDC_ATTR Dc_Attr; + if (!GdiGetHandleUserData((HGDIOBJ) hdc, GDI_OBJECT_TYPE_DC, (PVOID) &Dc_Attr)) return 0; #if 0 - if (GDI_HANDLE_GET_TYPE(hDC) != GDI_OBJECT_TYPE_DC) - { - if (GDI_HANDLE_GET_TYPE(hDC) == GDI_OBJECT_TYPE_METADC) - return MFDRV_SetMapMode(hdc, Mode); - else + if (GDI_HANDLE_GET_TYPE(hDC) != GDI_OBJECT_TYPE_DC) { - SetLastError(ERROR_INVALID_HANDLE); - return 0; - } + if (GDI_HANDLE_GET_TYPE(hDC) == GDI_OBJECT_TYPE_METADC) + return MFDRV_SetMapMode(hdc, Mode); + else + { + SetLastError(ERROR_INVALID_HANDLE); + return 0; + } #endif - // Force change if Isotropic is set for recompute. - if ((Mode != Dc_Attr->iMapMode) || (Mode == MM_ISOTROPIC)) - { - Dc_Attr->ulDirty_ &= ~SLOW_WIDTHS; - return GetAndSetDCDWord( hdc, GdiGetSetMapMode, Mode, 0, 0, 0 ); - } - return Dc_Attr->iMapMode; -} + // Force change if Isotropic is set for recompute. + if ((Mode != Dc_Attr->iMapMode) || (Mode == MM_ISOTROPIC)) + { + Dc_Attr->ulDirty_ &= ~SLOW_WIDTHS; + return GetAndSetDCDWord( hdc, GdiGetSetMapMode, Mode, 0, 0, 0 ); + } + return Dc_Attr->iMapMode; + } -/* - * @implemented - * - */ -int -WINAPI -GetStretchBltMode(HDC hdc) -{ - PDC_ATTR Dc_Attr; - if (!GdiGetHandleUserData((HGDIOBJ) hdc, GDI_OBJECT_TYPE_DC, (PVOID) &Dc_Attr)) return 0; - return Dc_Attr->lStretchBltMode; -} + /* + * @implemented + * + */ + int + WINAPI + GetStretchBltMode(HDC hdc) + { + PDC_ATTR Dc_Attr; + if (!GdiGetHandleUserData((HGDIOBJ) hdc, GDI_OBJECT_TYPE_DC, (PVOID) &Dc_Attr)) return 0; + return Dc_Attr->lStretchBltMode; + } -/* - * @implemented - */ -int -WINAPI -SetStretchBltMode(HDC hdc, int iStretchMode) -{ - INT oSMode; - PDC_ATTR Dc_Attr; + /* + * @implemented + */ + int + WINAPI + SetStretchBltMode(HDC hdc, int iStretchMode) + { + INT oSMode; + PDC_ATTR Dc_Attr; #if 0 - if (GDI_HANDLE_GET_TYPE(hdc) != GDI_OBJECT_TYPE_DC) - { - if (GDI_HANDLE_GET_TYPE(hdc) == GDI_OBJECT_TYPE_METADC) - return MFDRV_SetStretchBltMode( hdc, iStretchMode); - else - { - PLDC pLDC = GdiGetLDC(hdc); - if ( !pLDC ) - { - SetLastError(ERROR_INVALID_HANDLE); - return 0; - } - if (pLDC->iType == LDC_EMFLDC) - { - return EMFDRV_SetStretchBltMode( hdc, iStretchMode); - } - } - } + if (GDI_HANDLE_GET_TYPE(hdc) != GDI_OBJECT_TYPE_DC) + { + if (GDI_HANDLE_GET_TYPE(hdc) == GDI_OBJECT_TYPE_METADC) + return MFDRV_SetStretchBltMode( hdc, iStretchMode); + else + { + PLDC pLDC = GdiGetLDC(hdc); + if ( !pLDC ) + { + SetLastError(ERROR_INVALID_HANDLE); + return 0; + } + if (pLDC->iType == LDC_EMFLDC) + { + return EMFDRV_SetStretchBltMode( hdc, iStretchMode); + } + } + } #endif - if (!GdiGetHandleUserData((HGDIOBJ) hdc, GDI_OBJECT_TYPE_DC, (PVOID) &Dc_Attr)) return 0; + if (!GdiGetHandleUserData((HGDIOBJ) hdc, GDI_OBJECT_TYPE_DC, (PVOID) &Dc_Attr)) return 0; - oSMode = Dc_Attr->lStretchBltMode; - Dc_Attr->lStretchBltMode = iStretchMode; + oSMode = Dc_Attr->lStretchBltMode; + Dc_Attr->lStretchBltMode = iStretchMode; - // Wine returns an error here. We set the default. - if ((iStretchMode <= 0) || (iStretchMode > MAXSTRETCHBLTMODE)) iStretchMode = WHITEONBLACK; + // Wine returns an error here. We set the default. + if ((iStretchMode <= 0) || (iStretchMode > MAXSTRETCHBLTMODE)) iStretchMode = WHITEONBLACK; - Dc_Attr->jStretchBltMode = iStretchMode; + Dc_Attr->jStretchBltMode = iStretchMode; - return oSMode; -} - -/* - * @implemented - */ -HFONT -WINAPI -GetHFONT(HDC hdc) -{ - PDC_ATTR Dc_Attr; - if (!GdiGetHandleUserData((HGDIOBJ) hdc, GDI_OBJECT_TYPE_DC, (PVOID) &Dc_Attr)) return NULL; - return Dc_Attr->hlfntNew; -} - - -/* - * @implemented - * - */ -HGDIOBJ -WINAPI -SelectObject(HDC hDC, - HGDIOBJ hGdiObj) -{ - PDC_ATTR pDc_Attr; - HGDIOBJ hOldObj = NULL; - UINT uType; - - if(!GdiGetHandleUserData(hDC, GDI_OBJECT_TYPE_DC, (PVOID)&pDc_Attr)) - { - SetLastError(ERROR_INVALID_HANDLE); - return NULL; + return oSMode; } - hGdiObj = GdiFixUpHandle(hGdiObj); - if (!GdiIsHandleValid(hGdiObj)) + /* + * @implemented + */ + HFONT + WINAPI + GetHFONT(HDC hdc) { - return NULL; + PDC_ATTR Dc_Attr; + if (!GdiGetHandleUserData((HGDIOBJ) hdc, GDI_OBJECT_TYPE_DC, (PVOID) &Dc_Attr)) return NULL; + return Dc_Attr->hlfntNew; } - uType = GDI_HANDLE_GET_TYPE(hGdiObj); - switch (uType) + /* + * @implemented + * + */ + HGDIOBJ + WINAPI + SelectObject(HDC hDC, + HGDIOBJ hGdiObj) { + PDC_ATTR pDc_Attr; + HGDIOBJ hOldObj = NULL; + UINT uType; + + if(!GdiGetHandleUserData(hDC, GDI_OBJECT_TYPE_DC, (PVOID)&pDc_Attr)) + { + SetLastError(ERROR_INVALID_HANDLE); + return NULL; + } + + hGdiObj = GdiFixUpHandle(hGdiObj); + if (!GdiIsHandleValid(hGdiObj)) + { + return NULL; + } + + uType = GDI_HANDLE_GET_TYPE(hGdiObj); + + switch (uType) + { case GDI_OBJECT_TYPE_REGION: return (HGDIOBJ)ExtSelectClipRgn(hDC, hGdiObj, RGN_COPY); @@ -1617,7 +1621,7 @@ SelectObject(HDC hDC, default: SetLastError(ERROR_INVALID_FUNCTION); return NULL; - } + } - return NULL; -} + return NULL; + } diff --git a/reactos/dll/win32/gdi32/objects/eng.c b/reactos/dll/win32/gdi32/objects/eng.c index d29adf08a08..51144b233a0 100644 --- a/reactos/dll/win32/gdi32/objects/eng.c +++ b/reactos/dll/win32/gdi32/objects/eng.c @@ -156,16 +156,16 @@ EngGetCurrentCodePage( OUT PUSHORT OemCodePage, LPWSTR WINAPI EngGetDriverName(HDEV hdev) { - // DHPDEV from NtGdiGetDhpdev must be from print driver. - PUMPDEV pPDev = (PUMPDEV)NtGdiGetDhpdev(hdev); + // DHPDEV from NtGdiGetDhpdev must be from print driver. + PUMPDEV pPDev = (PUMPDEV)NtGdiGetDhpdev(hdev); - if (!pPDev) return NULL; - - if (pPDev->Sig != PDEV_UMPD_ID) - { - pPDev = (PUMPDEV)pPDev->Sig; - } - return pPDev->pdi5Info->pDriverPath; + if (!pPDev) return NULL; + + if (pPDev->Sig != PDEV_UMPD_ID) + { + pPDev = (PUMPDEV)pPDev->Sig; + } + return pPDev->pdi5Info->pDriverPath; } /* @@ -174,15 +174,15 @@ EngGetDriverName(HDEV hdev) LPWSTR WINAPI EngGetPrinterDataFileName(HDEV hdev) { - PUMPDEV pPDev = (PUMPDEV)NtGdiGetDhpdev(hdev); + PUMPDEV pPDev = (PUMPDEV)NtGdiGetDhpdev(hdev); - if (!pPDev) return NULL; + if (!pPDev) return NULL; - if (pPDev->Sig != PDEV_UMPD_ID) - { - pPDev = (PUMPDEV)pPDev->Sig; - } - return pPDev->pdi5Info->pDataFile; + if (pPDev->Sig != PDEV_UMPD_ID) + { + pPDev = (PUMPDEV)pPDev->Sig; + } + return pPDev->pdi5Info->pDataFile; } /* @@ -191,7 +191,7 @@ EngGetPrinterDataFileName(HDEV hdev) HANDLE WINAPI EngLoadModule(LPWSTR pwsz) { - return LoadLibraryExW ( pwsz, NULL, LOAD_LIBRARY_AS_DATAFILE); + return LoadLibraryExW ( pwsz, NULL, LOAD_LIBRARY_AS_DATAFILE); } /* @@ -204,7 +204,7 @@ EngMultiByteToWideChar(UINT CodePage, LPSTR MultiByteString, INT BytesInMultiByteString) { - return MultiByteToWideChar(CodePage,0,MultiByteString,BytesInMultiByteString,WideCharString,BytesInWideCharString / sizeof(WCHAR)); + return MultiByteToWideChar(CodePage,0,MultiByteString,BytesInMultiByteString,WideCharString,BytesInWideCharString / sizeof(WCHAR)); } /* @@ -213,16 +213,16 @@ EngMultiByteToWideChar(UINT CodePage, VOID WINAPI EngQueryLocalTime(PENG_TIME_FIELDS etf) { - SYSTEMTIME SystemTime; - GetLocalTime( &SystemTime ); - etf->usYear = SystemTime.wYear; - etf->usMonth = SystemTime.wMonth; - etf->usWeekday = SystemTime.wDayOfWeek; - etf->usDay = SystemTime.wDay; - etf->usHour = SystemTime.wHour; - etf->usMinute = SystemTime.wMinute; - etf->usSecond = SystemTime.wSecond; - etf->usMilliseconds = SystemTime.wMilliseconds; + SYSTEMTIME SystemTime; + GetLocalTime( &SystemTime ); + etf->usYear = SystemTime.wYear; + etf->usMonth = SystemTime.wMonth; + etf->usWeekday = SystemTime.wDayOfWeek; + etf->usDay = SystemTime.wDay; + etf->usHour = SystemTime.wHour; + etf->usMinute = SystemTime.wMinute; + etf->usSecond = SystemTime.wSecond; + etf->usMilliseconds = SystemTime.wMilliseconds; } /* @@ -232,7 +232,7 @@ VOID WINAPI EngReleaseSemaphore ( IN HSEMAPHORE hsem ) { - RtlLeaveCriticalSection( (PRTL_CRITICAL_SECTION) hsem); + RtlLeaveCriticalSection( (PRTL_CRITICAL_SECTION) hsem); } @@ -249,6 +249,6 @@ EngWideCharToMultiByte( UINT CodePage, LPSTR MultiByteString, INT BytesInMultiByteString) { - return WideCharToMultiByte(CodePage, 0, WideCharString, (BytesInWideCharString/sizeof(WCHAR)), - MultiByteString, BytesInMultiByteString, NULL, NULL); + return WideCharToMultiByte(CodePage, 0, WideCharString, (BytesInWideCharString/sizeof(WCHAR)), + MultiByteString, BytesInMultiByteString, NULL, NULL); } diff --git a/reactos/dll/win32/gdi32/objects/enhmfile.c b/reactos/dll/win32/gdi32/objects/enhmfile.c index 43d1f1f7d19..ec68f24c63a 100644 --- a/reactos/dll/win32/gdi32/objects/enhmfile.c +++ b/reactos/dll/win32/gdi32/objects/enhmfile.c @@ -6,15 +6,15 @@ /* - * @unimplemented + * @unimplemented */ HENHMETAFILE WINAPI CloseEnhMetaFile( - HDC hdc) + HDC hdc) { - UNIMPLEMENTED; - return 0; + UNIMPLEMENTED; + return 0; } @@ -26,7 +26,7 @@ CreateEnhMetaFileW( LPCWSTR filename, /* [in] optional filename for disk metafiles */ const RECT* rect, /* [in] optional bounding rectangle */ LPCWSTR description /* [in] optional description */ - ) +) { HDC mDC; PDC_ATTR Dc_Attr; @@ -40,8 +40,8 @@ CreateEnhMetaFileW( if ( !GdiGetHandleUserData((HGDIOBJ) mDC, GDI_OBJECT_TYPE_DC, (PVOID) &Dc_Attr)) { - SetLastError (ERROR_INVALID_PARAMETER); - return NULL; // need to delete the handle? + SetLastError (ERROR_INVALID_PARAMETER); + return NULL; // need to delete the handle? } pLDC = LocalAlloc(LMEM_ZEROINIT, sizeof(LDC)); @@ -51,8 +51,9 @@ CreateEnhMetaFileW( pLDC->iType = LDC_EMFDC - if (description) - { /* App name\0Title\0\0 */ + if (description) + { + /* App name\0Title\0\0 */ length = lstrlenW(description); length += lstrlenW(description + length + 1); length += 3; @@ -96,7 +97,8 @@ CreateEnhMetaFileW( EmfDC->emf->rclFrame.bottom = rect->bottom; } else - { /* Set this to {0,0 - -1,-1} and update it at the end */ + { + /* Set this to {0,0 - -1,-1} and update it at the end */ EmfDC->emf->rclFrame.left = EmfDC->emf->rclFrame.top = 0; EmfDC->emf->rclFrame.right = EmfDC->emf->rclFrame.bottom = -1; } @@ -131,7 +133,7 @@ CreateEnhMetaFileW( if (filename) /* disk based metafile */ { if ((hFile = CreateFileW(filename, GENERIC_WRITE | GENERIC_READ, 0, - NULL, CREATE_ALWAYS, 0, 0)) == INVALID_HANDLE_VALUE) + NULL, CREATE_ALWAYS, 0, 0)) == INVALID_HANDLE_VALUE) { EMFDRV_DeleteDC( EmfDC ); return NULL; @@ -140,9 +142,9 @@ CreateEnhMetaFileW( { EMFDRV_DeleteDC( EmfDC ); return NULL; - } - EmfDC.hFile = hFile; - EmfDC.iType = METAFILE_DISK; + } + EmfDC.hFile = hFile; + EmfDC.iType = METAFILE_DISK; } else EmfDC.iType = METAFILE_MEMORY; @@ -158,23 +160,23 @@ CreateEnhMetaFileW( HENHMETAFILE WINAPI CopyEnhMetaFileA( - HENHMETAFILE hemfSrc, - LPCSTR lpszFile) + HENHMETAFILE hemfSrc, + LPCSTR lpszFile) { - NTSTATUS Status; - LPWSTR lpszFileW; - HENHMETAFILE rc = 0; + NTSTATUS Status; + LPWSTR lpszFileW; + HENHMETAFILE rc = 0; - Status = HEAP_strdupA2W ( &lpszFileW, lpszFile ); - if (!NT_SUCCESS (Status)) - SetLastError (RtlNtStatusToDosError(Status)); - else + Status = HEAP_strdupA2W ( &lpszFileW, lpszFile ); + if (!NT_SUCCESS (Status)) + SetLastError (RtlNtStatusToDosError(Status)); + else { - rc = NULL; + rc = NULL; - HEAP_free ( lpszFileW ); + HEAP_free ( lpszFileW ); } - return rc; + return rc; } @@ -184,44 +186,44 @@ CopyEnhMetaFileA( HDC WINAPI CreateEnhMetaFileA( - HDC hdcRef, - LPCSTR lpFileName, - CONST RECT *lpRect, - LPCSTR lpDescription) + HDC hdcRef, + LPCSTR lpFileName, + CONST RECT *lpRect, + LPCSTR lpDescription) { - NTSTATUS Status; - LPWSTR lpFileNameW, lpDescriptionW; - HDC rc = 0; + NTSTATUS Status; + LPWSTR lpFileNameW, lpDescriptionW; + HDC rc = 0; - lpFileNameW = NULL; - if (lpFileName != NULL) - { - Status = HEAP_strdupA2W ( &lpFileNameW, lpFileName ); - if (!NT_SUCCESS (Status)) - SetLastError (RtlNtStatusToDosError(Status)); + lpFileNameW = NULL; + if (lpFileName != NULL) + { + Status = HEAP_strdupA2W ( &lpFileNameW, lpFileName ); + if (!NT_SUCCESS (Status)) + SetLastError (RtlNtStatusToDosError(Status)); - return rc; - } + return rc; + } - lpDescriptionW = NULL; - if (lpDescription != NULL) - { - Status = HEAP_strdupA2W ( &lpDescriptionW, lpDescription ); - if (!NT_SUCCESS (Status)) - SetLastError (RtlNtStatusToDosError(Status)); + lpDescriptionW = NULL; + if (lpDescription != NULL) + { + Status = HEAP_strdupA2W ( &lpDescriptionW, lpDescription ); + if (!NT_SUCCESS (Status)) + SetLastError (RtlNtStatusToDosError(Status)); - return rc; - } + return rc; + } - rc = NULL; + rc = NULL; - if (lpDescriptionW != NULL) - HEAP_free ( lpDescriptionW ); + if (lpDescriptionW != NULL) + HEAP_free ( lpDescriptionW ); - if (lpFileNameW != NULL) - HEAP_free ( lpFileNameW ); + if (lpFileNameW != NULL) + HEAP_free ( lpFileNameW ); - return rc; + return rc; } #if 0 @@ -229,201 +231,201 @@ CreateEnhMetaFileA( HDC WINAPI NtGdiCreateEnhMetaFile(HDC hDCRef, - LPCWSTR File, - CONST LPRECT Rect, - LPCWSTR Description) + LPCWSTR File, + CONST LPRECT Rect, + LPCWSTR Description) { - PDC Dc; - HDC ret = NULL; - DWORD length = 0; - HDC tempHDC; - DWORD MemSize; - DWORD dwDesiredAccess; + PDC Dc; + HDC ret = NULL; + DWORD length = 0; + HDC tempHDC; + DWORD MemSize; + DWORD dwDesiredAccess; - tempHDC = hDCRef; - if (hDCRef == NULL) - { - /* FIXME ?? - * Shall we create hdc NtGdiHdcCompatible hdc ?? - */ - UNICODE_STRING DriverName; - RtlInitUnicodeString(&DriverName, L"DISPLAY"); - //IntGdiCreateDC(&DriverName, NULL, NULL, NULL, FALSE); - tempHDC = NtGdiOpenDCW( &DriverName, - NULL, - NULL, - 0, // DCW 0 and ICW 1. - NULL, - (PVOID) NULL, - (PVOID) NULL ); - } + tempHDC = hDCRef; + if (hDCRef == NULL) + { + /* FIXME ?? + * Shall we create hdc NtGdiHdcCompatible hdc ?? + */ + UNICODE_STRING DriverName; + RtlInitUnicodeString(&DriverName, L"DISPLAY"); + //IntGdiCreateDC(&DriverName, NULL, NULL, NULL, FALSE); + tempHDC = NtGdiOpenDCW( &DriverName, + NULL, + NULL, + 0, // DCW 0 and ICW 1. + NULL, + (PVOID) NULL, + (PVOID) NULL ); + } - GDIOBJ_SetOwnership(GdiHandleTable, tempHDC, PsGetCurrentProcess()); - DC_SetOwnership(tempHDC, PsGetCurrentProcess()); + GDIOBJ_SetOwnership(GdiHandleTable, tempHDC, PsGetCurrentProcess()); + DC_SetOwnership(tempHDC, PsGetCurrentProcess()); - Dc = DC_LockDc(tempHDC); - if (Dc == NULL) - { - if (hDCRef == NULL) - { - NtGdiDeleteObjectApp(tempHDC); - } - SetLastWin32Error(ERROR_INVALID_HANDLE); - return NULL; - } + Dc = DC_LockDc(tempHDC); + if (Dc == NULL) + { + if (hDCRef == NULL) + { + NtGdiDeleteObjectApp(tempHDC); + } + SetLastWin32Error(ERROR_INVALID_HANDLE); + return NULL; + } - if(Description) - { - length = wcslen(Description); - length += wcslen(Description + length + 1); - length += 3; - length *= 2; - } + if(Description) + { + length = wcslen(Description); + length += wcslen(Description + length + 1); + length += 3; + length *= 2; + } - MemSize = sizeof(ENHMETAHEADER) + (length + 3) / 4 * 4; + MemSize = sizeof(ENHMETAHEADER) + (length + 3) / 4 * 4; - if (!(Dc->emh = EngAllocMem(FL_ZERO_MEMORY, MemSize, 0))) - { - DC_UnlockDc(Dc); - if (hDCRef == NULL) - { - NtGdiDeleteObjectApp(tempHDC); - } - SetLastWin32Error(ERROR_INVALID_HANDLE); - return NULL; - } + if (!(Dc->emh = EngAllocMem(FL_ZERO_MEMORY, MemSize, 0))) + { + DC_UnlockDc(Dc); + if (hDCRef == NULL) + { + NtGdiDeleteObjectApp(tempHDC); + } + SetLastWin32Error(ERROR_INVALID_HANDLE); + return NULL; + } - Dc->emh->iType = EMR_HEADER; - Dc->emh->nSize = MemSize; + Dc->emh->iType = EMR_HEADER; + Dc->emh->nSize = MemSize; - Dc->emh->rclBounds.left = Dc->emh->rclBounds.top = 0; - Dc->emh->rclBounds.right = Dc->emh->rclBounds.bottom = -1; + Dc->emh->rclBounds.left = Dc->emh->rclBounds.top = 0; + Dc->emh->rclBounds.right = Dc->emh->rclBounds.bottom = -1; - if(Rect) - { - Dc->emh->rclFrame.left = Rect->left; - Dc->emh->rclFrame.top = Rect->top; - Dc->emh->rclFrame.right = Rect->right; - Dc->emh->rclFrame.bottom = Rect->bottom; - } - else - { - /* Set this to {0,0 - -1,-1} and update it at the end */ - Dc->emh->rclFrame.left = Dc->emh->rclFrame.top = 0; - Dc->emh->rclFrame.right = Dc->emh->rclFrame.bottom = -1; - } - - Dc->emh->dSignature = ENHMETA_SIGNATURE; - Dc->emh->nVersion = 0x10000; - Dc->emh->nBytes = Dc->emh->nSize; - Dc->emh->nRecords = 1; - Dc->emh->nHandles = 1; - - Dc->emh->sReserved = 0; /* According to docs, this is reserved and must be 0 */ - Dc->emh->nDescription = length / 2; - - Dc->emh->offDescription = length ? sizeof(ENHMETAHEADER) : 0; - - Dc->emh->nPalEntries = 0; /* I guess this should start at 0 */ - - /* Size in pixels */ - Dc->emh->szlDevice.cx = NtGdiGetDeviceCaps(tempHDC, HORZRES); - Dc->emh->szlDevice.cy = NtGdiGetDeviceCaps(tempHDC, VERTRES); - - /* Size in millimeters */ - Dc->emh->szlMillimeters.cx = NtGdiGetDeviceCaps(tempHDC, HORZSIZE); - Dc->emh->szlMillimeters.cy = NtGdiGetDeviceCaps(tempHDC, VERTSIZE); - - /* Size in micrometers */ - Dc->emh->szlMicrometers.cx = Dc->emh->szlMillimeters.cx * 1000; - Dc->emh->szlMicrometers.cy = Dc->emh->szlMillimeters.cy * 1000; - - if(Description) - { - memcpy((char *)Dc->emh + sizeof(ENHMETAHEADER), Description, length); - } - - ret = tempHDC; - if (File) - { - OBJECT_ATTRIBUTES ObjectAttributes; - IO_STATUS_BLOCK IoStatusBlock; - IO_STATUS_BLOCK Iosb; - UNICODE_STRING NtPathU; - NTSTATUS Status; - ULONG FileAttributes = (FILE_ATTRIBUTE_VALID_FLAGS & ~FILE_ATTRIBUTE_DIRECTORY); - - DPRINT1("Trying Create EnhMetaFile\n"); - - /* disk based metafile */ - dwDesiredAccess = GENERIC_WRITE | GENERIC_READ | SYNCHRONIZE | FILE_READ_ATTRIBUTES; - - if (!RtlDosPathNameToNtPathName_U (File, &NtPathU, NULL, NULL)) - { - DC_UnlockDc(Dc); - if (hDCRef == NULL) - { - NtGdiDeleteObjectApp(tempHDC); - } - DPRINT1("Can not Create EnhMetaFile\n"); - SetLastWin32Error(ERROR_PATH_NOT_FOUND); - return NULL; - } - - InitializeObjectAttributes(&ObjectAttributes, &NtPathU, 0, NULL, NULL); - - Status = NtCreateFile (&Dc->hFile, dwDesiredAccess, &ObjectAttributes, &IoStatusBlock, - NULL, FileAttributes, 0, FILE_OVERWRITE_IF, FILE_NON_DIRECTORY_FILE, - NULL, 0); - - RtlFreeHeap(RtlGetProcessHeap(), 0, NtPathU.Buffer); - - if (!NT_SUCCESS(Status)) - { - Dc->hFile = NULL; - DC_UnlockDc(Dc); - if (hDCRef == NULL) - { - NtGdiDeleteObjectApp(tempHDC); - } - DPRINT1("Create EnhMetaFile fail\n"); - SetLastWin32Error(ERROR_INVALID_HANDLE); - return NULL; - } - - SetLastWin32Error(IoStatusBlock.Information == FILE_OVERWRITTEN ? ERROR_ALREADY_EXISTS : 0); - - Status = NtWriteFile(Dc->hFile, NULL, NULL, NULL, &Iosb, (PVOID)&Dc->emh, Dc->emh->nSize, NULL, NULL); - if (Status == STATUS_PENDING) - { - Status = NtWaitForSingleObject(Dc->hFile,FALSE,NULL); - if (NT_SUCCESS(Status)) - { - Status = Iosb.Status; - } - } - - if (NT_SUCCESS(Status)) - { - ret = tempHDC; - DC_UnlockDc(Dc); - } - else - { - Dc->hFile = NULL; - DPRINT1("Write to EnhMetaFile fail\n"); - SetLastWin32Error(ERROR_CAN_NOT_COMPLETE); - ret = NULL; - DC_UnlockDc(Dc); - if (hDCRef == NULL) - { - NtGdiDeleteObjectApp(tempHDC); - } - } + if(Rect) + { + Dc->emh->rclFrame.left = Rect->left; + Dc->emh->rclFrame.top = Rect->top; + Dc->emh->rclFrame.right = Rect->right; + Dc->emh->rclFrame.bottom = Rect->bottom; } else { - DC_UnlockDc(Dc); + /* Set this to {0,0 - -1,-1} and update it at the end */ + Dc->emh->rclFrame.left = Dc->emh->rclFrame.top = 0; + Dc->emh->rclFrame.right = Dc->emh->rclFrame.bottom = -1; + } + + Dc->emh->dSignature = ENHMETA_SIGNATURE; + Dc->emh->nVersion = 0x10000; + Dc->emh->nBytes = Dc->emh->nSize; + Dc->emh->nRecords = 1; + Dc->emh->nHandles = 1; + + Dc->emh->sReserved = 0; /* According to docs, this is reserved and must be 0 */ + Dc->emh->nDescription = length / 2; + + Dc->emh->offDescription = length ? sizeof(ENHMETAHEADER) : 0; + + Dc->emh->nPalEntries = 0; /* I guess this should start at 0 */ + + /* Size in pixels */ + Dc->emh->szlDevice.cx = NtGdiGetDeviceCaps(tempHDC, HORZRES); + Dc->emh->szlDevice.cy = NtGdiGetDeviceCaps(tempHDC, VERTRES); + + /* Size in millimeters */ + Dc->emh->szlMillimeters.cx = NtGdiGetDeviceCaps(tempHDC, HORZSIZE); + Dc->emh->szlMillimeters.cy = NtGdiGetDeviceCaps(tempHDC, VERTSIZE); + + /* Size in micrometers */ + Dc->emh->szlMicrometers.cx = Dc->emh->szlMillimeters.cx * 1000; + Dc->emh->szlMicrometers.cy = Dc->emh->szlMillimeters.cy * 1000; + + if(Description) + { + memcpy((char *)Dc->emh + sizeof(ENHMETAHEADER), Description, length); + } + + ret = tempHDC; + if (File) + { + OBJECT_ATTRIBUTES ObjectAttributes; + IO_STATUS_BLOCK IoStatusBlock; + IO_STATUS_BLOCK Iosb; + UNICODE_STRING NtPathU; + NTSTATUS Status; + ULONG FileAttributes = (FILE_ATTRIBUTE_VALID_FLAGS & ~FILE_ATTRIBUTE_DIRECTORY); + + DPRINT1("Trying Create EnhMetaFile\n"); + + /* disk based metafile */ + dwDesiredAccess = GENERIC_WRITE | GENERIC_READ | SYNCHRONIZE | FILE_READ_ATTRIBUTES; + + if (!RtlDosPathNameToNtPathName_U (File, &NtPathU, NULL, NULL)) + { + DC_UnlockDc(Dc); + if (hDCRef == NULL) + { + NtGdiDeleteObjectApp(tempHDC); + } + DPRINT1("Can not Create EnhMetaFile\n"); + SetLastWin32Error(ERROR_PATH_NOT_FOUND); + return NULL; + } + + InitializeObjectAttributes(&ObjectAttributes, &NtPathU, 0, NULL, NULL); + + Status = NtCreateFile (&Dc->hFile, dwDesiredAccess, &ObjectAttributes, &IoStatusBlock, + NULL, FileAttributes, 0, FILE_OVERWRITE_IF, FILE_NON_DIRECTORY_FILE, + NULL, 0); + + RtlFreeHeap(RtlGetProcessHeap(), 0, NtPathU.Buffer); + + if (!NT_SUCCESS(Status)) + { + Dc->hFile = NULL; + DC_UnlockDc(Dc); + if (hDCRef == NULL) + { + NtGdiDeleteObjectApp(tempHDC); + } + DPRINT1("Create EnhMetaFile fail\n"); + SetLastWin32Error(ERROR_INVALID_HANDLE); + return NULL; + } + + SetLastWin32Error(IoStatusBlock.Information == FILE_OVERWRITTEN ? ERROR_ALREADY_EXISTS : 0); + + Status = NtWriteFile(Dc->hFile, NULL, NULL, NULL, &Iosb, (PVOID)&Dc->emh, Dc->emh->nSize, NULL, NULL); + if (Status == STATUS_PENDING) + { + Status = NtWaitForSingleObject(Dc->hFile,FALSE,NULL); + if (NT_SUCCESS(Status)) + { + Status = Iosb.Status; + } + } + + if (NT_SUCCESS(Status)) + { + ret = tempHDC; + DC_UnlockDc(Dc); + } + else + { + Dc->hFile = NULL; + DPRINT1("Write to EnhMetaFile fail\n"); + SetLastWin32Error(ERROR_CAN_NOT_COMPLETE); + ret = NULL; + DC_UnlockDc(Dc); + if (hDCRef == NULL) + { + NtGdiDeleteObjectApp(tempHDC); + } + } + } + else + { + DC_UnlockDc(Dc); } return ret; @@ -438,23 +440,23 @@ NtGdiCreateEnhMetaFile(HDC hDCRef, HENHMETAFILE WINAPI GetEnhMetaFileA( - LPCSTR lpszMetaFile) + LPCSTR lpszMetaFile) { - NTSTATUS Status; - LPWSTR lpszMetaFileW; - HENHMETAFILE rc = 0; + NTSTATUS Status; + LPWSTR lpszMetaFileW; + HENHMETAFILE rc = 0; - Status = HEAP_strdupA2W ( &lpszMetaFileW, lpszMetaFile ); - if (!NT_SUCCESS (Status)) - SetLastError (RtlNtStatusToDosError(Status)); - else - { - rc = NULL; + Status = HEAP_strdupA2W ( &lpszMetaFileW, lpszMetaFile ); + if (!NT_SUCCESS (Status)) + SetLastError (RtlNtStatusToDosError(Status)); + else + { + rc = NULL; - HEAP_free ( lpszMetaFileW ); - } + HEAP_free ( lpszMetaFileW ); + } - return rc; + return rc; } @@ -464,41 +466,41 @@ GetEnhMetaFileA( UINT WINAPI GetEnhMetaFileDescriptionA( - HENHMETAFILE hemf, - UINT cchBuffer, - LPSTR lpszDescription) + HENHMETAFILE hemf, + UINT cchBuffer, + LPSTR lpszDescription) { - NTSTATUS Status; - LPWSTR lpszDescriptionW; + NTSTATUS Status; + LPWSTR lpszDescriptionW; - if ( lpszDescription && cchBuffer ) + if ( lpszDescription && cchBuffer ) { - lpszDescriptionW = (LPWSTR)HEAP_alloc ( cchBuffer*sizeof(WCHAR) ); - if ( !lpszDescriptionW ) - { - SetLastError (RtlNtStatusToDosError(STATUS_NO_MEMORY)); - return 0; - } + lpszDescriptionW = (LPWSTR)HEAP_alloc ( cchBuffer*sizeof(WCHAR) ); + if ( !lpszDescriptionW ) + { + SetLastError (RtlNtStatusToDosError(STATUS_NO_MEMORY)); + return 0; + } } - else - lpszDescriptionW = NULL; + else + lpszDescriptionW = NULL; - if ( lpszDescription && cchBuffer ) + if ( lpszDescription && cchBuffer ) { - Status = RtlUnicodeToMultiByteN ( lpszDescription, - cchBuffer, - NULL, - lpszDescriptionW, - cchBuffer ); - HEAP_free ( lpszDescriptionW ); - if ( !NT_SUCCESS(Status) ) - { - SetLastError (RtlNtStatusToDosError(Status)); - return 0; - } + Status = RtlUnicodeToMultiByteN ( lpszDescription, + cchBuffer, + NULL, + lpszDescriptionW, + cchBuffer ); + HEAP_free ( lpszDescriptionW ); + if ( !NT_SUCCESS(Status) ) + { + SetLastError (RtlNtStatusToDosError(Status)); + return 0; + } } - return 0; + return 0; } @@ -508,44 +510,44 @@ GetEnhMetaFileDescriptionA( HENHMETAFILE WINAPI CopyEnhMetaFileW( - HENHMETAFILE hemfSrc, - LPCWSTR lpszFile) + HENHMETAFILE hemfSrc, + LPCWSTR lpszFile) { - UNIMPLEMENTED; - return 0; + UNIMPLEMENTED; + return 0; } HENHMETAFILE WINAPI GetEnhMetaFileW( - LPCWSTR lpszMetaFile) + LPCWSTR lpszMetaFile) { - UNIMPLEMENTED; - return 0; + UNIMPLEMENTED; + return 0; } UINT WINAPI GetEnhMetaFileDescriptionW( - HENHMETAFILE hemf, - UINT cchBuffer, - LPWSTR lpszDescription) + HENHMETAFILE hemf, + UINT cchBuffer, + LPWSTR lpszDescription) { - UNIMPLEMENTED; - return 0; + UNIMPLEMENTED; + return 0; } HDC WINAPI CreateEnhMetaFileW( - HDC hdcRef, - LPCWSTR lpFileName, - LPCRECT lpRect, - LPCWSTR lpDescription) + HDC hdcRef, + LPCWSTR lpFileName, + LPCRECT lpRect, + LPCWSTR lpDescription) { - UNIMPLEMENTED; - return 0; + UNIMPLEMENTED; + return 0; } diff --git a/reactos/dll/win32/gdi32/objects/font.c b/reactos/dll/win32/gdi32/objects/font.c index 2090b9ad1a8..d8e54607be1 100644 --- a/reactos/dll/win32/gdi32/objects/font.c +++ b/reactos/dll/win32/gdi32/objects/font.c @@ -16,44 +16,45 @@ * For TranslateCharsetInfo */ #define MAXTCIINDEX 32 -static const CHARSETINFO FONT_tci[MAXTCIINDEX] = { - /* ANSI */ - { ANSI_CHARSET, 1252, {{0,0,0,0},{FS_LATIN1,0}} }, - { EASTEUROPE_CHARSET, 1250, {{0,0,0,0},{FS_LATIN2,0}} }, - { RUSSIAN_CHARSET, 1251, {{0,0,0,0},{FS_CYRILLIC,0}} }, - { GREEK_CHARSET, 1253, {{0,0,0,0},{FS_GREEK,0}} }, - { TURKISH_CHARSET, 1254, {{0,0,0,0},{FS_TURKISH,0}} }, - { HEBREW_CHARSET, 1255, {{0,0,0,0},{FS_HEBREW,0}} }, - { ARABIC_CHARSET, 1256, {{0,0,0,0},{FS_ARABIC,0}} }, - { BALTIC_CHARSET, 1257, {{0,0,0,0},{FS_BALTIC,0}} }, - { VIETNAMESE_CHARSET, 1258, {{0,0,0,0},{FS_VIETNAMESE,0}} }, - /* reserved by ANSI */ - { DEFAULT_CHARSET, 0, {{0,0,0,0},{FS_LATIN1,0}} }, - { DEFAULT_CHARSET, 0, {{0,0,0,0},{FS_LATIN1,0}} }, - { DEFAULT_CHARSET, 0, {{0,0,0,0},{FS_LATIN1,0}} }, - { DEFAULT_CHARSET, 0, {{0,0,0,0},{FS_LATIN1,0}} }, - { DEFAULT_CHARSET, 0, {{0,0,0,0},{FS_LATIN1,0}} }, - { DEFAULT_CHARSET, 0, {{0,0,0,0},{FS_LATIN1,0}} }, - { DEFAULT_CHARSET, 0, {{0,0,0,0},{FS_LATIN1,0}} }, - /* ANSI and OEM */ - { THAI_CHARSET, 874, {{0,0,0,0},{FS_THAI,0}} }, - { SHIFTJIS_CHARSET, 932, {{0,0,0,0},{FS_JISJAPAN,0}} }, - { GB2312_CHARSET, 936, {{0,0,0,0},{FS_CHINESESIMP,0}} }, - { HANGEUL_CHARSET, 949, {{0,0,0,0},{FS_WANSUNG,0}} }, - { CHINESEBIG5_CHARSET, 950, {{0,0,0,0},{FS_CHINESETRAD,0}} }, - { JOHAB_CHARSET, 1361, {{0,0,0,0},{FS_JOHAB,0}} }, - /* reserved for alternate ANSI and OEM */ - { DEFAULT_CHARSET, 0, {{0,0,0,0},{FS_LATIN1,0}} }, - { DEFAULT_CHARSET, 0, {{0,0,0,0},{FS_LATIN1,0}} }, - { DEFAULT_CHARSET, 0, {{0,0,0,0},{FS_LATIN1,0}} }, - { DEFAULT_CHARSET, 0, {{0,0,0,0},{FS_LATIN1,0}} }, - { DEFAULT_CHARSET, 0, {{0,0,0,0},{FS_LATIN1,0}} }, - { DEFAULT_CHARSET, 0, {{0,0,0,0},{FS_LATIN1,0}} }, - { DEFAULT_CHARSET, 0, {{0,0,0,0},{FS_LATIN1,0}} }, - { DEFAULT_CHARSET, 0, {{0,0,0,0},{FS_LATIN1,0}} }, - /* reserved for system */ - { DEFAULT_CHARSET, 0, {{0,0,0,0},{FS_LATIN1,0}} }, - { SYMBOL_CHARSET, CP_SYMBOL, {{0,0,0,0},{FS_SYMBOL,0}} } +static const CHARSETINFO FONT_tci[MAXTCIINDEX] = +{ + /* ANSI */ + { ANSI_CHARSET, 1252, {{0,0,0,0},{FS_LATIN1,0}} }, + { EASTEUROPE_CHARSET, 1250, {{0,0,0,0},{FS_LATIN2,0}} }, + { RUSSIAN_CHARSET, 1251, {{0,0,0,0},{FS_CYRILLIC,0}} }, + { GREEK_CHARSET, 1253, {{0,0,0,0},{FS_GREEK,0}} }, + { TURKISH_CHARSET, 1254, {{0,0,0,0},{FS_TURKISH,0}} }, + { HEBREW_CHARSET, 1255, {{0,0,0,0},{FS_HEBREW,0}} }, + { ARABIC_CHARSET, 1256, {{0,0,0,0},{FS_ARABIC,0}} }, + { BALTIC_CHARSET, 1257, {{0,0,0,0},{FS_BALTIC,0}} }, + { VIETNAMESE_CHARSET, 1258, {{0,0,0,0},{FS_VIETNAMESE,0}} }, + /* reserved by ANSI */ + { DEFAULT_CHARSET, 0, {{0,0,0,0},{FS_LATIN1,0}} }, + { DEFAULT_CHARSET, 0, {{0,0,0,0},{FS_LATIN1,0}} }, + { DEFAULT_CHARSET, 0, {{0,0,0,0},{FS_LATIN1,0}} }, + { DEFAULT_CHARSET, 0, {{0,0,0,0},{FS_LATIN1,0}} }, + { DEFAULT_CHARSET, 0, {{0,0,0,0},{FS_LATIN1,0}} }, + { DEFAULT_CHARSET, 0, {{0,0,0,0},{FS_LATIN1,0}} }, + { DEFAULT_CHARSET, 0, {{0,0,0,0},{FS_LATIN1,0}} }, + /* ANSI and OEM */ + { THAI_CHARSET, 874, {{0,0,0,0},{FS_THAI,0}} }, + { SHIFTJIS_CHARSET, 932, {{0,0,0,0},{FS_JISJAPAN,0}} }, + { GB2312_CHARSET, 936, {{0,0,0,0},{FS_CHINESESIMP,0}} }, + { HANGEUL_CHARSET, 949, {{0,0,0,0},{FS_WANSUNG,0}} }, + { CHINESEBIG5_CHARSET, 950, {{0,0,0,0},{FS_CHINESETRAD,0}} }, + { JOHAB_CHARSET, 1361, {{0,0,0,0},{FS_JOHAB,0}} }, + /* reserved for alternate ANSI and OEM */ + { DEFAULT_CHARSET, 0, {{0,0,0,0},{FS_LATIN1,0}} }, + { DEFAULT_CHARSET, 0, {{0,0,0,0},{FS_LATIN1,0}} }, + { DEFAULT_CHARSET, 0, {{0,0,0,0},{FS_LATIN1,0}} }, + { DEFAULT_CHARSET, 0, {{0,0,0,0},{FS_LATIN1,0}} }, + { DEFAULT_CHARSET, 0, {{0,0,0,0},{FS_LATIN1,0}} }, + { DEFAULT_CHARSET, 0, {{0,0,0,0},{FS_LATIN1,0}} }, + { DEFAULT_CHARSET, 0, {{0,0,0,0},{FS_LATIN1,0}} }, + { DEFAULT_CHARSET, 0, {{0,0,0,0},{FS_LATIN1,0}} }, + /* reserved for system */ + { DEFAULT_CHARSET, 0, {{0,0,0,0},{FS_LATIN1,0}} }, + { SYMBOL_CHARSET, CP_SYMBOL, {{0,0,0,0},{FS_SYMBOL,0}} } }; #define INITIAL_FAMILY_COUNT 64 @@ -129,41 +130,41 @@ static LPWSTR FONT_mbtowc(HDC hdc, LPCSTR str, INT count, INT *plenW, UINT *pCP) VOID FASTCALL NewTextMetricW2A(NEWTEXTMETRICA *tma, NEWTEXTMETRICW *tmw) { - FONT_TextMetricWToA((TEXTMETRICW *) tmw, (TEXTMETRICA *) tma); - tma->ntmFlags = tmw->ntmFlags; - tma->ntmSizeEM = tmw->ntmSizeEM; - tma->ntmCellHeight = tmw->ntmCellHeight; - tma->ntmAvgWidth = tmw->ntmAvgWidth; + FONT_TextMetricWToA((TEXTMETRICW *) tmw, (TEXTMETRICA *) tma); + tma->ntmFlags = tmw->ntmFlags; + tma->ntmSizeEM = tmw->ntmSizeEM; + tma->ntmCellHeight = tmw->ntmCellHeight; + tma->ntmAvgWidth = tmw->ntmAvgWidth; } VOID FASTCALL NewTextMetricExW2A(NEWTEXTMETRICEXA *tma, NEWTEXTMETRICEXW *tmw) { - NewTextMetricW2A(&tma->ntmTm, &tmw->ntmTm); - tma->ntmFontSig = tmw->ntmFontSig; + NewTextMetricW2A(&tma->ntmTm, &tmw->ntmTm); + tma->ntmFontSig = tmw->ntmFontSig; } static int FASTCALL IntEnumFontFamilies(HDC Dc, LPLOGFONTW LogFont, PVOID EnumProc, LPARAM lParam, BOOL Unicode) { - int FontFamilyCount; - int FontFamilySize; - PFONTFAMILYINFO Info; - int Ret = 0; - int i; - ENUMLOGFONTEXA EnumLogFontExA; - NEWTEXTMETRICEXA NewTextMetricExA; - LOGFONTW lfW; + int FontFamilyCount; + int FontFamilySize; + PFONTFAMILYINFO Info; + int Ret = 0; + int i; + ENUMLOGFONTEXA EnumLogFontExA; + NEWTEXTMETRICEXA NewTextMetricExA; + LOGFONTW lfW; - Info = RtlAllocateHeap(GetProcessHeap(), 0, - INITIAL_FAMILY_COUNT * sizeof(FONTFAMILYINFO)); - if (NULL == Info) + Info = RtlAllocateHeap(GetProcessHeap(), 0, + INITIAL_FAMILY_COUNT * sizeof(FONTFAMILYINFO)); + if (NULL == Info) { - return 0; + return 0; } - if (!LogFont) + if (!LogFont) { lfW.lfCharSet = DEFAULT_CHARSET; lfW.lfPitchAndFamily = 0; @@ -171,60 +172,61 @@ IntEnumFontFamilies(HDC Dc, LPLOGFONTW LogFont, PVOID EnumProc, LPARAM lParam, LogFont = &lfW; } - FontFamilyCount = NtGdiGetFontFamilyInfo(Dc, LogFont, Info, INITIAL_FAMILY_COUNT); - if (FontFamilyCount < 0) + FontFamilyCount = NtGdiGetFontFamilyInfo(Dc, LogFont, Info, INITIAL_FAMILY_COUNT); + if (FontFamilyCount < 0) { - RtlFreeHeap(GetProcessHeap(), 0, Info); - return 0; + RtlFreeHeap(GetProcessHeap(), 0, Info); + return 0; } - if (INITIAL_FAMILY_COUNT < FontFamilyCount) + if (INITIAL_FAMILY_COUNT < FontFamilyCount) { - FontFamilySize = FontFamilyCount; - RtlFreeHeap(GetProcessHeap(), 0, Info); - Info = RtlAllocateHeap(GetProcessHeap(), 0, - FontFamilyCount * sizeof(FONTFAMILYINFO)); - if (NULL == Info) + FontFamilySize = FontFamilyCount; + RtlFreeHeap(GetProcessHeap(), 0, Info); + Info = RtlAllocateHeap(GetProcessHeap(), 0, + FontFamilyCount * sizeof(FONTFAMILYINFO)); + if (NULL == Info) { - return 0; + return 0; } - FontFamilyCount = NtGdiGetFontFamilyInfo(Dc, LogFont, Info, FontFamilySize); - if (FontFamilyCount < 0 || FontFamilySize < FontFamilyCount) + FontFamilyCount = NtGdiGetFontFamilyInfo(Dc, LogFont, Info, FontFamilySize); + if (FontFamilyCount < 0 || FontFamilySize < FontFamilyCount) { - RtlFreeHeap(GetProcessHeap(), 0, Info); - return 0; + RtlFreeHeap(GetProcessHeap(), 0, Info); + return 0; } } - for (i = 0; i < FontFamilyCount; i++) + for (i = 0; i < FontFamilyCount; i++) { - if (Unicode) + if (Unicode) { - Ret = ((FONTENUMPROCW) EnumProc)( - (VOID*)&Info[i].EnumLogFontEx, - (VOID*)&Info[i].NewTextMetricEx, - Info[i].FontType, lParam); + Ret = ((FONTENUMPROCW) EnumProc)( + (VOID*)&Info[i].EnumLogFontEx, + (VOID*)&Info[i].NewTextMetricEx, + Info[i].FontType, lParam); } - else - { // Could use EnumLogFontExW2A here? - LogFontW2A(&EnumLogFontExA.elfLogFont, &Info[i].EnumLogFontEx.elfLogFont); - WideCharToMultiByte(CP_THREAD_ACP, 0, Info[i].EnumLogFontEx.elfFullName, -1, - (LPSTR)EnumLogFontExA.elfFullName, LF_FULLFACESIZE, NULL, NULL); - WideCharToMultiByte(CP_THREAD_ACP, 0, Info[i].EnumLogFontEx.elfStyle, -1, - (LPSTR)EnumLogFontExA.elfStyle, LF_FACESIZE, NULL, NULL); - WideCharToMultiByte(CP_THREAD_ACP, 0, Info[i].EnumLogFontEx.elfScript, -1, - (LPSTR)EnumLogFontExA.elfScript, LF_FACESIZE, NULL, NULL); - NewTextMetricExW2A(&NewTextMetricExA, - &Info[i].NewTextMetricEx); - Ret = ((FONTENUMPROCA) EnumProc)( - (VOID*)&EnumLogFontExA, - (VOID*)&NewTextMetricExA, - Info[i].FontType, lParam); + else + { + // Could use EnumLogFontExW2A here? + LogFontW2A(&EnumLogFontExA.elfLogFont, &Info[i].EnumLogFontEx.elfLogFont); + WideCharToMultiByte(CP_THREAD_ACP, 0, Info[i].EnumLogFontEx.elfFullName, -1, + (LPSTR)EnumLogFontExA.elfFullName, LF_FULLFACESIZE, NULL, NULL); + WideCharToMultiByte(CP_THREAD_ACP, 0, Info[i].EnumLogFontEx.elfStyle, -1, + (LPSTR)EnumLogFontExA.elfStyle, LF_FACESIZE, NULL, NULL); + WideCharToMultiByte(CP_THREAD_ACP, 0, Info[i].EnumLogFontEx.elfScript, -1, + (LPSTR)EnumLogFontExA.elfScript, LF_FACESIZE, NULL, NULL); + NewTextMetricExW2A(&NewTextMetricExA, + &Info[i].NewTextMetricEx); + Ret = ((FONTENUMPROCA) EnumProc)( + (VOID*)&EnumLogFontExA, + (VOID*)&NewTextMetricExA, + Info[i].FontType, lParam); } } - RtlFreeHeap(GetProcessHeap(), 0, Info); + RtlFreeHeap(GetProcessHeap(), 0, Info); - return Ret; + return Ret; } /* @@ -234,7 +236,7 @@ int WINAPI EnumFontFamiliesExW(HDC hdc, LPLOGFONTW lpLogfont, FONTENUMPROCW lpEnumFontFamExProc, LPARAM lParam, DWORD dwFlags) { - return IntEnumFontFamilies(hdc, lpLogfont, lpEnumFontFamExProc, lParam, TRUE); + return IntEnumFontFamilies(hdc, lpLogfont, lpEnumFontFamExProc, lParam, TRUE); } @@ -245,17 +247,17 @@ int WINAPI EnumFontFamiliesW(HDC hdc, LPCWSTR lpszFamily, FONTENUMPROCW lpEnumFontFamProc, LPARAM lParam) { - LOGFONTW LogFont; + LOGFONTW LogFont; - ZeroMemory(&LogFont, sizeof(LOGFONTW)); - LogFont.lfCharSet = DEFAULT_CHARSET; - if (NULL != lpszFamily) + ZeroMemory(&LogFont, sizeof(LOGFONTW)); + LogFont.lfCharSet = DEFAULT_CHARSET; + if (NULL != lpszFamily) { - if (!*lpszFamily) return 1; - lstrcpynW(LogFont.lfFaceName, lpszFamily, LF_FACESIZE); + if (!*lpszFamily) return 1; + lstrcpynW(LogFont.lfFaceName, lpszFamily, LF_FACESIZE); } - return IntEnumFontFamilies(hdc, &LogFont, lpEnumFontFamProc, lParam, TRUE); + return IntEnumFontFamilies(hdc, &LogFont, lpEnumFontFamProc, lParam, TRUE); } @@ -266,17 +268,17 @@ int WINAPI EnumFontFamiliesExA (HDC hdc, LPLOGFONTA lpLogfont, FONTENUMPROCA lpEnumFontFamExProc, LPARAM lParam, DWORD dwFlags) { - LOGFONTW LogFontW, *pLogFontW; + LOGFONTW LogFontW, *pLogFontW; - if (lpLogfont) - { - LogFontA2W(&LogFontW,lpLogfont); - pLogFontW = &LogFontW; - } - else pLogFontW = NULL; + if (lpLogfont) + { + LogFontA2W(&LogFontW,lpLogfont); + pLogFontW = &LogFontW; + } + else pLogFontW = NULL; - /* no need to convert LogFontW back to lpLogFont b/c it's an [in] parameter only */ - return IntEnumFontFamilies(hdc, pLogFontW, lpEnumFontFamExProc, lParam, FALSE); + /* no need to convert LogFontW back to lpLogFont b/c it's an [in] parameter only */ + return IntEnumFontFamilies(hdc, pLogFontW, lpEnumFontFamExProc, lParam, FALSE); } @@ -287,17 +289,17 @@ int WINAPI EnumFontFamiliesA(HDC hdc, LPCSTR lpszFamily, FONTENUMPROCA lpEnumFontFamProc, LPARAM lParam) { - LOGFONTW LogFont; + LOGFONTW LogFont; - ZeroMemory(&LogFont, sizeof(LOGFONTW)); - LogFont.lfCharSet = DEFAULT_CHARSET; - if (NULL != lpszFamily) + ZeroMemory(&LogFont, sizeof(LOGFONTW)); + LogFont.lfCharSet = DEFAULT_CHARSET; + if (NULL != lpszFamily) { - if (!*lpszFamily) return 1; - MultiByteToWideChar(CP_THREAD_ACP, 0, lpszFamily, -1, LogFont.lfFaceName, LF_FACESIZE); + if (!*lpszFamily) return 1; + MultiByteToWideChar(CP_THREAD_ACP, 0, lpszFamily, -1, LogFont.lfFaceName, LF_FACESIZE); } - return IntEnumFontFamilies(hdc, &LogFont, lpEnumFontFamProc, lParam, FALSE); + return IntEnumFontFamilies(hdc, &LogFont, lpEnumFontFamProc, lParam, FALSE); } @@ -307,12 +309,12 @@ EnumFontFamiliesA(HDC hdc, LPCSTR lpszFamily, FONTENUMPROCA lpEnumFontFamProc, DWORD WINAPI GetCharacterPlacementA( - HDC hdc, - LPCSTR lpString, - INT uCount, - INT nMaxExtent, - GCP_RESULTSA *lpResults, - DWORD dwFlags) + HDC hdc, + LPCSTR lpString, + INT uCount, + INT nMaxExtent, + GCP_RESULTSA *lpResults, + DWORD dwFlags) { WCHAR *lpStringW; INT uCountW; @@ -322,12 +324,12 @@ GetCharacterPlacementA( if ( !lpString || uCount <= 0 || (nMaxExtent < 0 && nMaxExtent != -1 ) ) { - SetLastError(ERROR_INVALID_PARAMETER); - return 0; + SetLastError(ERROR_INVALID_PARAMETER); + return 0; } -/* TRACE("%s, %d, %d, 0x%08x\n", - debugstr_an(lpString, uCount), uCount, nMaxExtent, dwFlags); -*/ + /* TRACE("%s, %d, %d, 0x%08x\n", + debugstr_an(lpString, uCount), uCount, nMaxExtent, dwFlags); + */ /* both structs are equal in size */ memcpy(&resultsW, lpResults, sizeof(resultsW)); @@ -351,7 +353,8 @@ GetCharacterPlacementA( lpResults->nGlyphs = resultsW.nGlyphs; lpResults->nMaxFit = resultsW.nMaxFit; - if(lpResults->lpOutString) { + if(lpResults->lpOutString) + { WideCharToMultiByte(font_cp, 0, resultsW.lpOutString, uCountW, lpResults->lpOutString, uCount, NULL, NULL ); } @@ -369,121 +372,121 @@ GetCharacterPlacementA( DWORD WINAPI GetCharacterPlacementW( - HDC hdc, - LPCWSTR lpString, - INT uCount, - INT nMaxExtent, - GCP_RESULTSW *lpResults, - DWORD dwFlags - ) + HDC hdc, + LPCWSTR lpString, + INT uCount, + INT nMaxExtent, + GCP_RESULTSW *lpResults, + DWORD dwFlags +) { - DWORD ret=0; - SIZE size; - UINT i, nSet; - DPRINT("GetCharacterPlacementW\n"); + DWORD ret=0; + SIZE size; + UINT i, nSet; + DPRINT("GetCharacterPlacementW\n"); - if(dwFlags&(~GCP_REORDER)) DPRINT("flags 0x%08lx ignored\n", dwFlags); - if(lpResults->lpClass) DPRINT("classes not implemented\n"); - if (lpResults->lpCaretPos && (dwFlags & GCP_REORDER)) - DPRINT("Caret positions for complex scripts not implemented\n"); + if(dwFlags&(~GCP_REORDER)) DPRINT("flags 0x%08lx ignored\n", dwFlags); + if(lpResults->lpClass) DPRINT("classes not implemented\n"); + if (lpResults->lpCaretPos && (dwFlags & GCP_REORDER)) + DPRINT("Caret positions for complex scripts not implemented\n"); - nSet = (UINT)uCount; - if(nSet > lpResults->nGlyphs) - nSet = lpResults->nGlyphs; + nSet = (UINT)uCount; + if(nSet > lpResults->nGlyphs) + nSet = lpResults->nGlyphs; - /* return number of initialized fields */ - lpResults->nGlyphs = nSet; + /* return number of initialized fields */ + lpResults->nGlyphs = nSet; -/*if((dwFlags&GCP_REORDER)==0 || !BidiAvail) - {*/ + /*if((dwFlags&GCP_REORDER)==0 || !BidiAvail) + {*/ /* Treat the case where no special handling was requested in a fastpath way */ /* copy will do if the GCP_REORDER flag is not set */ if(lpResults->lpOutString) - lstrcpynW( lpResults->lpOutString, lpString, nSet ); + lstrcpynW( lpResults->lpOutString, lpString, nSet ); if(lpResults->lpGlyphs) - lstrcpynW( lpResults->lpGlyphs, lpString, nSet ); + lstrcpynW( lpResults->lpGlyphs, lpString, nSet ); if(lpResults->lpOrder) { - for(i = 0; i < nSet; i++) - lpResults->lpOrder[i] = i; + for(i = 0; i < nSet; i++) + lpResults->lpOrder[i] = i; } -/*} else - { - BIDI_Reorder( lpString, uCount, dwFlags, WINE_GCPW_FORCE_LTR, lpResults->lpOutString, - nSet, lpResults->lpOrder ); - }*/ + /*} else + { + BIDI_Reorder( lpString, uCount, dwFlags, WINE_GCPW_FORCE_LTR, lpResults->lpOutString, + nSet, lpResults->lpOrder ); + }*/ - /* FIXME: Will use the placement chars */ - if (lpResults->lpDx) - { - int c; - for (i = 0; i < nSet; i++) + /* FIXME: Will use the placement chars */ + if (lpResults->lpDx) { - if (GetCharWidth32W(hdc, lpString[i], lpString[i], &c)) - lpResults->lpDx[i]= c; + int c; + for (i = 0; i < nSet; i++) + { + if (GetCharWidth32W(hdc, lpString[i], lpString[i], &c)) + lpResults->lpDx[i]= c; + } } - } - if (lpResults->lpCaretPos && !(dwFlags & GCP_REORDER)) - { - int pos = 0; + if (lpResults->lpCaretPos && !(dwFlags & GCP_REORDER)) + { + int pos = 0; - lpResults->lpCaretPos[0] = 0; - for (i = 1; i < nSet; i++) - if (GetTextExtentPoint32W(hdc, &(lpString[i - 1]), 1, &size)) - lpResults->lpCaretPos[i] = (pos += size.cx); - } + lpResults->lpCaretPos[0] = 0; + for (i = 1; i < nSet; i++) + if (GetTextExtentPoint32W(hdc, &(lpString[i - 1]), 1, &size)) + lpResults->lpCaretPos[i] = (pos += size.cx); + } - /*if(lpResults->lpGlyphs) - NtGdiGetGlyphIndicesW(hdc, lpString, nSet, lpResults->lpGlyphs, 0);*/ + /*if(lpResults->lpGlyphs) + NtGdiGetGlyphIndicesW(hdc, lpString, nSet, lpResults->lpGlyphs, 0);*/ - if (GetTextExtentPoint32W(hdc, lpString, uCount, &size)) - ret = MAKELONG(size.cx, size.cy); + if (GetTextExtentPoint32W(hdc, lpString, uCount, &size)) + ret = MAKELONG(size.cx, size.cy); - return ret; + return ret; } DWORD WINAPI NewGetCharacterPlacementW( - HDC hdc, - LPCWSTR lpString, - INT uCount, - INT nMaxExtent, - GCP_RESULTSW *lpResults, - DWORD dwFlags - ) + HDC hdc, + LPCWSTR lpString, + INT uCount, + INT nMaxExtent, + GCP_RESULTSW *lpResults, + DWORD dwFlags +) { - INT nSet; - SIZE Size = {0,0}; + INT nSet; + SIZE Size = {0,0}; - if ( !lpString || uCount <= 0 || (nMaxExtent < 0 && nMaxExtent != -1 ) ) - { - SetLastError(ERROR_INVALID_PARAMETER); - return 0; - } + if ( !lpString || uCount <= 0 || (nMaxExtent < 0 && nMaxExtent != -1 ) ) + { + SetLastError(ERROR_INVALID_PARAMETER); + return 0; + } - if ( !lpResults ) - { - if ( GetTextExtentPointW(hdc, lpString, uCount, &Size) ) - { - return MAKELONG(Size.cx, Size.cy); - } - return 0; - } + if ( !lpResults ) + { + if ( GetTextExtentPointW(hdc, lpString, uCount, &Size) ) + { + return MAKELONG(Size.cx, Size.cy); + } + return 0; + } - nSet = uCount; - if ( nSet > lpResults->nGlyphs ) - nSet = lpResults->nGlyphs; + nSet = uCount; + if ( nSet > lpResults->nGlyphs ) + nSet = lpResults->nGlyphs; - return NtGdiGetCharacterPlacementW( hdc, - (LPWSTR)lpString, - nSet, - nMaxExtent, - lpResults, - dwFlags); + return NtGdiGetCharacterPlacementW( hdc, + (LPWSTR)lpString, + nSet, + nMaxExtent, + lpResults, + dwFlags); } /* @@ -497,18 +500,18 @@ GetCharABCWidthsFloatW(HDC hdc, UINT LastChar, LPABCFLOAT abcF) { - DPRINT("GetCharABCWidthsFloatW\n"); - if ((!abcF) || (FirstChar > LastChar)) - { - SetLastError(ERROR_INVALID_PARAMETER); - return FALSE; - } - return NtGdiGetCharABCWidthsW( hdc, - FirstChar, - (ULONG)(LastChar - FirstChar + 1), - (PWCHAR) NULL, - 0, - (PVOID)abcF); + DPRINT("GetCharABCWidthsFloatW\n"); + if ((!abcF) || (FirstChar > LastChar)) + { + SetLastError(ERROR_INVALID_PARAMETER); + return FALSE; + } + return NtGdiGetCharABCWidthsW( hdc, + FirstChar, + (ULONG)(LastChar - FirstChar + 1), + (PWCHAR) NULL, + 0, + (PVOID)abcF); } /* @@ -522,18 +525,18 @@ GetCharWidthFloatW(HDC hdc, UINT iLastChar, PFLOAT pxBuffer) { - DPRINT("GetCharWidthsFloatW\n"); - if ((!pxBuffer) || (iFirstChar > iLastChar)) - { - SetLastError(ERROR_INVALID_PARAMETER); - return FALSE; - } - return NtGdiGetCharWidthW( hdc, - iFirstChar, - (ULONG)(iLastChar - iFirstChar + 1), - (PWCHAR) NULL, - 0, - (PVOID) pxBuffer); + DPRINT("GetCharWidthsFloatW\n"); + if ((!pxBuffer) || (iFirstChar > iLastChar)) + { + SetLastError(ERROR_INVALID_PARAMETER); + return FALSE; + } + return NtGdiGetCharWidthW( hdc, + iFirstChar, + (ULONG)(iLastChar - iFirstChar + 1), + (PWCHAR) NULL, + 0, + (PVOID) pxBuffer); } /* @@ -547,18 +550,18 @@ GetCharWidthW(HDC hdc, UINT iLastChar, LPINT lpBuffer) { - DPRINT("GetCharWidthsW\n"); - if ((!lpBuffer) || (iFirstChar > iLastChar)) - { - SetLastError(ERROR_INVALID_PARAMETER); - return FALSE; - } - return NtGdiGetCharWidthW( hdc, - iFirstChar, - (ULONG)(iLastChar - iFirstChar + 1), - (PWCHAR) NULL, - GCW_NOFLOAT, - (PVOID) lpBuffer); + DPRINT("GetCharWidthsW\n"); + if ((!lpBuffer) || (iFirstChar > iLastChar)) + { + SetLastError(ERROR_INVALID_PARAMETER); + return FALSE; + } + return NtGdiGetCharWidthW( hdc, + iFirstChar, + (ULONG)(iLastChar - iFirstChar + 1), + (PWCHAR) NULL, + GCW_NOFLOAT, + (PVOID) lpBuffer); } /* @@ -568,22 +571,22 @@ GetCharWidthW(HDC hdc, BOOL WINAPI GetCharWidth32W(HDC hdc, - UINT iFirstChar, - UINT iLastChar, - LPINT lpBuffer) + UINT iFirstChar, + UINT iLastChar, + LPINT lpBuffer) { - DPRINT("GetCharWidths32W\n"); - if ((!lpBuffer) || (iFirstChar > iLastChar)) - { - SetLastError(ERROR_INVALID_PARAMETER); - return FALSE; - } - return NtGdiGetCharWidthW( hdc, - iFirstChar, - (ULONG)(iLastChar - iFirstChar + 1), - (PWCHAR) NULL, - GCW_NOFLOAT|GCW_WIN32, - (PVOID) lpBuffer); + DPRINT("GetCharWidths32W\n"); + if ((!lpBuffer) || (iFirstChar > iLastChar)) + { + SetLastError(ERROR_INVALID_PARAMETER); + return FALSE; + } + return NtGdiGetCharWidthW( hdc, + iFirstChar, + (ULONG)(iLastChar - iFirstChar + 1), + (PWCHAR) NULL, + GCW_NOFLOAT|GCW_WIN32, + (PVOID) lpBuffer); } @@ -598,18 +601,18 @@ GetCharABCWidthsW(HDC hdc, UINT LastChar, LPABC lpabc) { - DPRINT("GetCharABCWidthsW\n"); - if ((!lpabc) || (FirstChar > LastChar)) - { - SetLastError(ERROR_INVALID_PARAMETER); - return FALSE; - } - return NtGdiGetCharABCWidthsW( hdc, - FirstChar, - (ULONG)(LastChar - FirstChar + 1), - (PWCHAR) NULL, - GCABCW_NOFLOAT, - (PVOID)lpabc); + DPRINT("GetCharABCWidthsW\n"); + if ((!lpabc) || (FirstChar > LastChar)) + { + SetLastError(ERROR_INVALID_PARAMETER); + return FALSE; + } + return NtGdiGetCharABCWidthsW( hdc, + FirstChar, + (ULONG)(LastChar - FirstChar + 1), + (PWCHAR) NULL, + GCABCW_NOFLOAT, + (PVOID)lpabc); } /* @@ -618,11 +621,11 @@ GetCharABCWidthsW(HDC hdc, BOOL WINAPI GetCharWidthA( - HDC hdc, - UINT iFirstChar, - UINT iLastChar, - LPINT lpBuffer - ) + HDC hdc, + UINT iFirstChar, + UINT iLastChar, + LPINT lpBuffer +) { INT i, wlen, count = (INT)(iLastChar - iFirstChar + 1); LPSTR str; @@ -648,11 +651,11 @@ GetCharWidthA( } ret = NtGdiGetCharWidthW( hdc, - wstr[0], - (ULONG) count, - (PWCHAR) wstr, - GCW_NOFLOAT, - (PVOID) lpBuffer); + wstr[0], + (ULONG) count, + (PWCHAR) wstr, + GCW_NOFLOAT, + (PVOID) lpBuffer); HeapFree(GetProcessHeap(), 0, str); HeapFree(GetProcessHeap(), 0, wstr); @@ -666,11 +669,11 @@ GetCharWidthA( BOOL WINAPI GetCharWidth32A( - HDC hdc, - UINT iFirstChar, - UINT iLastChar, - LPINT lpBuffer - ) + HDC hdc, + UINT iFirstChar, + UINT iLastChar, + LPINT lpBuffer +) { INT i, wlen, count = (INT)(iLastChar - iFirstChar + 1); LPSTR str; @@ -695,11 +698,11 @@ GetCharWidth32A( } ret = NtGdiGetCharWidthW( hdc, - wstr[0], - (ULONG) count, - (PWCHAR) wstr, - GCW_NOFLOAT|GCW_WIN32, - (PVOID) lpBuffer); + wstr[0], + (ULONG) count, + (PWCHAR) wstr, + GCW_NOFLOAT|GCW_WIN32, + (PVOID) lpBuffer); HeapFree(GetProcessHeap(), 0, str); HeapFree(GetProcessHeap(), 0, wstr); @@ -713,11 +716,11 @@ GetCharWidth32A( BOOL APIENTRY GetCharWidthFloatA( - HDC hdc, - UINT iFirstChar, - UINT iLastChar, - PFLOAT pxBuffer - ) + HDC hdc, + UINT iFirstChar, + UINT iLastChar, + PFLOAT pxBuffer +) { INT i, wlen, count = (INT)(iLastChar - iFirstChar + 1); LPSTR str; @@ -754,11 +757,11 @@ GetCharWidthFloatA( BOOL APIENTRY GetCharABCWidthsA( - HDC hdc, - UINT uFirstChar, - UINT uLastChar, - LPABC lpabc - ) + HDC hdc, + UINT uFirstChar, + UINT uLastChar, + LPABC lpabc +) { INT i, wlen, count = (INT)(uLastChar - uFirstChar + 1); LPSTR str; @@ -783,11 +786,11 @@ GetCharABCWidthsA( } ret = NtGdiGetCharABCWidthsW( hdc, - wstr[0], - (ULONG)count, - (PWCHAR)wstr, - GCABCW_NOFLOAT, - (PVOID)lpabc); + wstr[0], + (ULONG)count, + (PWCHAR)wstr, + GCABCW_NOFLOAT, + (PVOID)lpabc); HeapFree(GetProcessHeap(), 0, str); HeapFree(GetProcessHeap(), 0, wstr); @@ -801,11 +804,11 @@ GetCharABCWidthsA( BOOL APIENTRY GetCharABCWidthsFloatA( - HDC hdc, - UINT iFirstChar, - UINT iLastChar, - LPABCFLOAT lpABCF - ) + HDC hdc, + UINT iFirstChar, + UINT iLastChar, + LPABCFLOAT lpABCF +) { INT i, wlen, count = (INT)(iLastChar - iFirstChar + 1); LPSTR str; @@ -848,13 +851,13 @@ GetCharABCWidthsI(HDC hdc, LPWORD pgi, LPABC lpabc) { - DPRINT("GetCharABCWidthsI\n"); - return NtGdiGetCharABCWidthsW( hdc, - giFirst, - (ULONG) cgi, - (PWCHAR) pgi, - GCABCW_NOFLOAT|GCABCW_INDICES, - (PVOID)lpabc); + DPRINT("GetCharABCWidthsI\n"); + return NtGdiGetCharABCWidthsW( hdc, + giFirst, + (ULONG) cgi, + (PWCHAR) pgi, + GCABCW_NOFLOAT|GCABCW_INDICES, + (PVOID)lpabc); } /* @@ -867,21 +870,21 @@ GetCharWidthI(HDC hdc, UINT cgi, LPWORD pgi, LPINT lpBuffer -) + ) { - DPRINT("GetCharWidthsI\n"); - if (!lpBuffer || (!pgi && (giFirst == MAXUSHORT))) // Cannot be at max. - { - SetLastError(ERROR_INVALID_PARAMETER); - return FALSE; - } - if (!cgi) return TRUE; - return NtGdiGetCharWidthW( hdc, - giFirst, - cgi, - (PWCHAR) pgi, - GCW_INDICES|GCW_NOFLOAT|GCW_WIN32, - (PVOID) lpBuffer ); + DPRINT("GetCharWidthsI\n"); + if (!lpBuffer || (!pgi && (giFirst == MAXUSHORT))) // Cannot be at max. + { + SetLastError(ERROR_INVALID_PARAMETER); + return FALSE; + } + if (!cgi) return TRUE; + return NtGdiGetCharWidthW( hdc, + giFirst, + cgi, + (PWCHAR) pgi, + GCW_INDICES|GCW_NOFLOAT|GCW_WIN32, + (PVOID) lpBuffer ); } /* @@ -890,22 +893,22 @@ GetCharWidthI(HDC hdc, DWORD WINAPI GetFontLanguageInfo( - HDC hDc - ) + HDC hDc +) { - DWORD Gcp = 0, Ret = 0; - if (gbLpk) - { - Ret = NtGdiGetTextCharsetInfo(hDc, NULL, 0); - if ((Ret == ARABIC_CHARSET) || (Ret == HEBREW_CHARSET)) - Ret = (GCP_KASHIDA|GCP_DIACRITIC|GCP_LIGATE|GCP_GLYPHSHAPE|GCP_REORDER); - } - Gcp = GetDCDWord(hDc, GdiGetFontLanguageInfo, GCP_ERROR); - if ( Gcp == GCP_ERROR) - return Gcp; - else - Ret = Gcp | Ret; - return Ret; + DWORD Gcp = 0, Ret = 0; + if (gbLpk) + { + Ret = NtGdiGetTextCharsetInfo(hDc, NULL, 0); + if ((Ret == ARABIC_CHARSET) || (Ret == HEBREW_CHARSET)) + Ret = (GCP_KASHIDA|GCP_DIACRITIC|GCP_LIGATE|GCP_GLYPHSHAPE|GCP_REORDER); + } + Gcp = GetDCDWord(hDc, GdiGetFontLanguageInfo, GCP_ERROR); + if ( Gcp == GCP_ERROR) + return Gcp; + else + Ret = Gcp | Ret; + return Ret; } /* @@ -914,12 +917,12 @@ GetFontLanguageInfo( DWORD WINAPI GetGlyphIndicesA( - HDC hdc, - LPCSTR lpstr, - INT count, - LPWORD pgi, - DWORD flags - ) + HDC hdc, + LPCSTR lpstr, + INT count, + LPWORD pgi, + DWORD flags +) { DWORD Ret; WCHAR *lpstrW; @@ -941,14 +944,14 @@ GetGlyphIndicesA( DWORD WINAPI GetGlyphOutlineA( - HDC hdc, - UINT uChar, - UINT uFormat, - LPGLYPHMETRICS lpgm, - DWORD cbBuffer, - LPVOID lpvBuffer, - CONST MAT2 *lpmat2 - ) + HDC hdc, + UINT uChar, + UINT uFormat, + LPGLYPHMETRICS lpgm, + DWORD cbBuffer, + LPVOID lpvBuffer, + CONST MAT2 *lpmat2 +) { LPWSTR p = NULL; @@ -956,20 +959,25 @@ GetGlyphOutlineA( UINT c; DPRINT("GetGlyphOutlineA uChar %x\n", uChar); if (!lpgm || !lpmat2) return GDI_ERROR; - if(!(uFormat & GGO_GLYPH_INDEX)) { + if(!(uFormat & GGO_GLYPH_INDEX)) + { int len; char mbchs[2]; - if(uChar > 0xff) { /* but, 2 bytes character only */ + if(uChar > 0xff) /* but, 2 bytes character only */ + { len = 2; mbchs[0] = (uChar & 0xff00) >> 8; mbchs[1] = (uChar & 0xff); - } else { + } + else + { len = 1; mbchs[0] = (uChar & 0xff); } p = FONT_mbtowc(hdc, mbchs, len, NULL, NULL); c = p[0]; - } else + } + else c = uChar; ret = NtGdiGetGlyphOutline(hdc, c, uFormat, lpgm, cbBuffer, lpvBuffer, (CONST LPMAT2)lpmat2, TRUE); HeapFree(GetProcessHeap(), 0, p); @@ -983,19 +991,19 @@ GetGlyphOutlineA( DWORD WINAPI GetGlyphOutlineW( - HDC hdc, - UINT uChar, - UINT uFormat, - LPGLYPHMETRICS lpgm, - DWORD cbBuffer, - LPVOID lpvBuffer, - CONST MAT2 *lpmat2 - ) + HDC hdc, + UINT uChar, + UINT uFormat, + LPGLYPHMETRICS lpgm, + DWORD cbBuffer, + LPVOID lpvBuffer, + CONST MAT2 *lpmat2 +) { - DPRINT("GetGlyphOutlineW uChar %x\n", uChar); - if (!lpgm || !lpmat2) return GDI_ERROR; - if (!lpvBuffer) cbBuffer = 0; - return NtGdiGetGlyphOutline ( hdc, uChar, uFormat, lpgm, cbBuffer, lpvBuffer, (CONST LPMAT2)lpmat2, TRUE); + DPRINT("GetGlyphOutlineW uChar %x\n", uChar); + if (!lpgm || !lpmat2) return GDI_ERROR; + if (!lpvBuffer) cbBuffer = 0; + return NtGdiGetGlyphOutline ( hdc, uChar, uFormat, lpgm, cbBuffer, lpvBuffer, (CONST LPMAT2)lpmat2, TRUE); } @@ -1005,10 +1013,10 @@ GetGlyphOutlineW( UINT APIENTRY GetOutlineTextMetricsA( - HDC hdc, - UINT cbData, - LPOUTLINETEXTMETRICA lpOTM - ) + HDC hdc, + UINT cbData, + LPOUTLINETEXTMETRICA lpOTM +) { char buf[512], *ptr; UINT ret, needed; @@ -1031,24 +1039,25 @@ GetOutlineTextMetricsA( needed = sizeof(OUTLINETEXTMETRICA); if(lpOTMW->otmpFamilyName) needed += WideCharToMultiByte(CP_ACP, 0, - (WCHAR*)((char*)lpOTMW + (int)lpOTMW->otmpFamilyName), -1, - NULL, 0, NULL, NULL); + (WCHAR*)((char*)lpOTMW + (int)lpOTMW->otmpFamilyName), -1, + NULL, 0, NULL, NULL); if(lpOTMW->otmpFaceName) needed += WideCharToMultiByte(CP_ACP, 0, - (WCHAR*)((char*)lpOTMW + (int)lpOTMW->otmpFaceName), -1, - NULL, 0, NULL, NULL); + (WCHAR*)((char*)lpOTMW + (int)lpOTMW->otmpFaceName), -1, + NULL, 0, NULL, NULL); if(lpOTMW->otmpStyleName) needed += WideCharToMultiByte(CP_ACP, 0, - (WCHAR*)((char*)lpOTMW + (int)lpOTMW->otmpStyleName), -1, - NULL, 0, NULL, NULL); + (WCHAR*)((char*)lpOTMW + (int)lpOTMW->otmpStyleName), -1, + NULL, 0, NULL, NULL); if(lpOTMW->otmpFullName) needed += WideCharToMultiByte(CP_ACP, 0, - (WCHAR*)((char*)lpOTMW + (int)lpOTMW->otmpFullName), -1, - NULL, 0, NULL, NULL); + (WCHAR*)((char*)lpOTMW + (int)lpOTMW->otmpFullName), -1, + NULL, 0, NULL, NULL); - if(!lpOTM) { + if(!lpOTM) + { ret = needed; - goto end; + goto end; } DPRINT("needed = %d\n", needed); @@ -1097,48 +1106,57 @@ GetOutlineTextMetricsA( ptr = (char*)(output + 1); left = needed - sizeof(*output); - if(lpOTMW->otmpFamilyName) { + if(lpOTMW->otmpFamilyName) + { output->otmpFamilyName = (LPSTR)(ptr - (char*)output); - len = WideCharToMultiByte(CP_ACP, 0, - (WCHAR*)((char*)lpOTMW + (int)lpOTMW->otmpFamilyName), -1, - ptr, left, NULL, NULL); - left -= len; - ptr += len; - } else + len = WideCharToMultiByte(CP_ACP, 0, + (WCHAR*)((char*)lpOTMW + (int)lpOTMW->otmpFamilyName), -1, + ptr, left, NULL, NULL); + left -= len; + ptr += len; + } + else output->otmpFamilyName = 0; - if(lpOTMW->otmpFaceName) { + if(lpOTMW->otmpFaceName) + { output->otmpFaceName = (LPSTR)(ptr - (char*)output); - len = WideCharToMultiByte(CP_ACP, 0, - (WCHAR*)((char*)lpOTMW + (int)lpOTMW->otmpFaceName), -1, - ptr, left, NULL, NULL); - left -= len; - ptr += len; - } else + len = WideCharToMultiByte(CP_ACP, 0, + (WCHAR*)((char*)lpOTMW + (int)lpOTMW->otmpFaceName), -1, + ptr, left, NULL, NULL); + left -= len; + ptr += len; + } + else output->otmpFaceName = 0; - if(lpOTMW->otmpStyleName) { + if(lpOTMW->otmpStyleName) + { output->otmpStyleName = (LPSTR)(ptr - (char*)output); - len = WideCharToMultiByte(CP_ACP, 0, - (WCHAR*)((char*)lpOTMW + (int)lpOTMW->otmpStyleName), -1, - ptr, left, NULL, NULL); - left -= len; - ptr += len; - } else + len = WideCharToMultiByte(CP_ACP, 0, + (WCHAR*)((char*)lpOTMW + (int)lpOTMW->otmpStyleName), -1, + ptr, left, NULL, NULL); + left -= len; + ptr += len; + } + else output->otmpStyleName = 0; - if(lpOTMW->otmpFullName) { + if(lpOTMW->otmpFullName) + { output->otmpFullName = (LPSTR)(ptr - (char*)output); - len = WideCharToMultiByte(CP_ACP, 0, - (WCHAR*)((char*)lpOTMW + (int)lpOTMW->otmpFullName), -1, - ptr, left, NULL, NULL); - left -= len; - } else + len = WideCharToMultiByte(CP_ACP, 0, + (WCHAR*)((char*)lpOTMW + (int)lpOTMW->otmpFullName), -1, + ptr, left, NULL, NULL); + left -= len; + } + else output->otmpFullName = 0; assert(left == 0); - if(output != lpOTM) { + if(output != lpOTM) + { memcpy(lpOTM, output, cbData); HeapFree(GetProcessHeap(), 0, output); @@ -1171,14 +1189,14 @@ end: UINT APIENTRY GetOutlineTextMetricsW( - HDC hdc, - UINT cbData, - LPOUTLINETEXTMETRICW lpOTM - ) + HDC hdc, + UINT cbData, + LPOUTLINETEXTMETRICW lpOTM +) { - TMDIFF Tmd; // Should not be zero. + TMDIFF Tmd; // Should not be zero. - return NtGdiGetOutlineTextMetricsInternalW(hdc, cbData, lpOTM, &Tmd); + return NtGdiGetOutlineTextMetricsInternalW(hdc, cbData, lpOTM, &Tmd); } /* @@ -1207,8 +1225,8 @@ GetKerningPairsW(HDC hdc, DWORD WINAPI GetKerningPairsA( HDC hDC, - DWORD cPairs, - LPKERNINGPAIR kern_pairA ) + DWORD cPairs, + LPKERNINGPAIR kern_pairA ) { INT charset; CHARSETINFO csi; @@ -1290,20 +1308,20 @@ HFONT WINAPI CreateFontIndirectExA(const ENUMLOGFONTEXDVA *elfexd) { - if (elfexd) - { - ENUMLOGFONTEXDVW Logfont; + if (elfexd) + { + ENUMLOGFONTEXDVW Logfont; - EnumLogFontExW2A( (LPENUMLOGFONTEXA) elfexd, - &Logfont.elfEnumLogfontEx ); + EnumLogFontExW2A( (LPENUMLOGFONTEXA) elfexd, + &Logfont.elfEnumLogfontEx ); - RtlCopyMemory( &Logfont.elfDesignVector, - (PVOID) &elfexd->elfDesignVector, - sizeof(DESIGNVECTOR)); + RtlCopyMemory( &Logfont.elfDesignVector, + (PVOID) &elfexd->elfDesignVector, + sizeof(DESIGNVECTOR)); - return NtGdiHfontCreate( &Logfont, 0, 0, 0, NULL); - } - else return NULL; + return NtGdiHfontCreate( &Logfont, 0, 0, 0, NULL); + } + else return NULL; } @@ -1314,14 +1332,14 @@ HFONT WINAPI CreateFontIndirectExW(const ENUMLOGFONTEXDVW *elfexd) { - /* Msdn: Note, this function ignores the elfDesignVector member in - ENUMLOGFONTEXDV. - */ - if ( elfexd ) - { - return NtGdiHfontCreate((PENUMLOGFONTEXDVW) elfexd, 0, 0, 0, NULL ); - } - else return NULL; + /* Msdn: Note, this function ignores the elfDesignVector member in + ENUMLOGFONTEXDV. + */ + if ( elfexd ) + { + return NtGdiHfontCreate((PENUMLOGFONTEXDVW) elfexd, 0, 0, 0, NULL ); + } + else return NULL; } @@ -1331,17 +1349,17 @@ CreateFontIndirectExW(const ENUMLOGFONTEXDVW *elfexd) HFONT WINAPI CreateFontIndirectA( - CONST LOGFONTA *lplf - ) + CONST LOGFONTA *lplf +) { - if (lplf) + if (lplf) { - LOGFONTW tlf; + LOGFONTW tlf; - LogFontA2W(&tlf, lplf); - return CreateFontIndirectW(&tlf); + LogFontA2W(&tlf, lplf); + return CreateFontIndirectW(&tlf); } - else return NULL; + else return NULL; } @@ -1351,30 +1369,30 @@ CreateFontIndirectA( HFONT WINAPI CreateFontIndirectW( - CONST LOGFONTW *lplf - ) + CONST LOGFONTW *lplf +) { - if (lplf) - { - ENUMLOGFONTEXDVW Logfont; + if (lplf) + { + ENUMLOGFONTEXDVW Logfont; - RtlCopyMemory( &Logfont.elfEnumLogfontEx.elfLogFont, lplf, sizeof(LOGFONTW)); - // Need something other than just cleaning memory here. - // Guess? Use caller data to determine the rest. - RtlZeroMemory( &Logfont.elfEnumLogfontEx.elfFullName, - sizeof(Logfont.elfEnumLogfontEx.elfFullName)); - RtlZeroMemory( &Logfont.elfEnumLogfontEx.elfStyle, - sizeof(Logfont.elfEnumLogfontEx.elfStyle)); - RtlZeroMemory( &Logfont.elfEnumLogfontEx.elfScript, - sizeof(Logfont.elfEnumLogfontEx.elfScript)); + RtlCopyMemory( &Logfont.elfEnumLogfontEx.elfLogFont, lplf, sizeof(LOGFONTW)); + // Need something other than just cleaning memory here. + // Guess? Use caller data to determine the rest. + RtlZeroMemory( &Logfont.elfEnumLogfontEx.elfFullName, + sizeof(Logfont.elfEnumLogfontEx.elfFullName)); + RtlZeroMemory( &Logfont.elfEnumLogfontEx.elfStyle, + sizeof(Logfont.elfEnumLogfontEx.elfStyle)); + RtlZeroMemory( &Logfont.elfEnumLogfontEx.elfScript, + sizeof(Logfont.elfEnumLogfontEx.elfScript)); - Logfont.elfDesignVector.dvNumAxes = 0; // No more than MM_MAX_NUMAXES + Logfont.elfDesignVector.dvNumAxes = 0; // No more than MM_MAX_NUMAXES - RtlZeroMemory( &Logfont.elfDesignVector, sizeof(DESIGNVECTOR)); + RtlZeroMemory( &Logfont.elfDesignVector, sizeof(DESIGNVECTOR)); - return CreateFontIndirectExW(&Logfont); - } - else return NULL; + return CreateFontIndirectExW(&Logfont); + } + else return NULL; } @@ -1384,47 +1402,47 @@ CreateFontIndirectW( HFONT WINAPI CreateFontA( - int nHeight, - int nWidth, - int nEscapement, - int nOrientation, - int fnWeight, - DWORD fdwItalic, - DWORD fdwUnderline, - DWORD fdwStrikeOut, - DWORD fdwCharSet, - DWORD fdwOutputPrecision, - DWORD fdwClipPrecision, - DWORD fdwQuality, - DWORD fdwPitchAndFamily, - LPCSTR lpszFace - ) + int nHeight, + int nWidth, + int nEscapement, + int nOrientation, + int fnWeight, + DWORD fdwItalic, + DWORD fdwUnderline, + DWORD fdwStrikeOut, + DWORD fdwCharSet, + DWORD fdwOutputPrecision, + DWORD fdwClipPrecision, + DWORD fdwQuality, + DWORD fdwPitchAndFamily, + LPCSTR lpszFace +) { - ANSI_STRING StringA; - UNICODE_STRING StringU; - HFONT ret; + ANSI_STRING StringA; + UNICODE_STRING StringU; + HFONT ret; - RtlInitAnsiString(&StringA, (LPSTR)lpszFace); - RtlAnsiStringToUnicodeString(&StringU, &StringA, TRUE); + RtlInitAnsiString(&StringA, (LPSTR)lpszFace); + RtlAnsiStringToUnicodeString(&StringU, &StringA, TRUE); - ret = CreateFontW(nHeight, - nWidth, + ret = CreateFontW(nHeight, + nWidth, nEscapement, - nOrientation, - fnWeight, - fdwItalic, - fdwUnderline, - fdwStrikeOut, - fdwCharSet, - fdwOutputPrecision, - fdwClipPrecision, - fdwQuality, - fdwPitchAndFamily, - StringU.Buffer); + nOrientation, + fnWeight, + fdwItalic, + fdwUnderline, + fdwStrikeOut, + fdwCharSet, + fdwOutputPrecision, + fdwClipPrecision, + fdwQuality, + fdwPitchAndFamily, + StringU.Buffer); - RtlFreeUnicodeString(&StringU); + RtlFreeUnicodeString(&StringU); - return ret; + return ret; } @@ -1434,51 +1452,51 @@ CreateFontA( HFONT WINAPI CreateFontW( - int nHeight, - int nWidth, - int nEscapement, - int nOrientation, - int nWeight, - DWORD fnItalic, - DWORD fdwUnderline, - DWORD fdwStrikeOut, - DWORD fdwCharSet, - DWORD fdwOutputPrecision, - DWORD fdwClipPrecision, - DWORD fdwQuality, - DWORD fdwPitchAndFamily, - LPCWSTR lpszFace - ) + int nHeight, + int nWidth, + int nEscapement, + int nOrientation, + int nWeight, + DWORD fnItalic, + DWORD fdwUnderline, + DWORD fdwStrikeOut, + DWORD fdwCharSet, + DWORD fdwOutputPrecision, + DWORD fdwClipPrecision, + DWORD fdwQuality, + DWORD fdwPitchAndFamily, + LPCWSTR lpszFace +) { - LOGFONTW logfont; + LOGFONTW logfont; - logfont.lfHeight = nHeight; - logfont.lfWidth = nWidth; - logfont.lfEscapement = nEscapement; - logfont.lfOrientation = nOrientation; - logfont.lfWeight = nWeight; - logfont.lfItalic = fnItalic; - logfont.lfUnderline = fdwUnderline; - logfont.lfStrikeOut = fdwStrikeOut; - logfont.lfCharSet = fdwCharSet; - logfont.lfOutPrecision = fdwOutputPrecision; - logfont.lfClipPrecision = fdwClipPrecision; - logfont.lfQuality = fdwQuality; - logfont.lfPitchAndFamily = fdwPitchAndFamily; + logfont.lfHeight = nHeight; + logfont.lfWidth = nWidth; + logfont.lfEscapement = nEscapement; + logfont.lfOrientation = nOrientation; + logfont.lfWeight = nWeight; + logfont.lfItalic = fnItalic; + logfont.lfUnderline = fdwUnderline; + logfont.lfStrikeOut = fdwStrikeOut; + logfont.lfCharSet = fdwCharSet; + logfont.lfOutPrecision = fdwOutputPrecision; + logfont.lfClipPrecision = fdwClipPrecision; + logfont.lfQuality = fdwQuality; + logfont.lfPitchAndFamily = fdwPitchAndFamily; - if (NULL != lpszFace) - { - int Size = sizeof(logfont.lfFaceName) / sizeof(WCHAR); - wcsncpy((wchar_t *)logfont.lfFaceName, lpszFace, Size - 1); - /* Be 101% sure to have '\0' at end of string */ - logfont.lfFaceName[Size - 1] = '\0'; - } - else - { - logfont.lfFaceName[0] = L'\0'; - } + if (NULL != lpszFace) + { + int Size = sizeof(logfont.lfFaceName) / sizeof(WCHAR); + wcsncpy((wchar_t *)logfont.lfFaceName, lpszFace, Size - 1); + /* Be 101% sure to have '\0' at end of string */ + logfont.lfFaceName[Size - 1] = '\0'; + } + else + { + logfont.lfFaceName[0] = L'\0'; + } - return CreateFontIndirectW(&logfont); + return CreateFontIndirectW(&logfont); } @@ -1488,13 +1506,13 @@ CreateFontW( BOOL WINAPI CreateScalableFontResourceA( - DWORD fdwHidden, - LPCSTR lpszFontRes, - LPCSTR lpszFontFile, - LPCSTR lpszCurrentPath - ) + DWORD fdwHidden, + LPCSTR lpszFontRes, + LPCSTR lpszFontFile, + LPCSTR lpszCurrentPath +) { - return FALSE; + return FALSE; } @@ -1563,9 +1581,9 @@ AddFontResourceA ( LPCSTR lpszFilename ) } else { - rc = GdiAddFontResourceW ( FilenameW, 0, 0); + rc = GdiAddFontResourceW ( FilenameW, 0, 0); - HEAP_free ( FilenameW ); + HEAP_free ( FilenameW ); } return rc; } @@ -1611,7 +1629,7 @@ WINAPI RemoveFontResourceExA(LPCSTR lpFileName, DWORD fl, PVOID pdv -) + ) { NTSTATUS Status; LPWSTR lpFileNameW; @@ -1622,14 +1640,14 @@ RemoveFontResourceExA(LPCSTR lpFileName, Status = HEAP_strdupA2W ( &lpFileNameW, lpFileName ); if (!NT_SUCCESS (Status)) - SetLastError (RtlNtStatusToDosError(Status)); + SetLastError (RtlNtStatusToDosError(Status)); else { HEAP_free ( lpFileNameW ); } - return 0; + return 0; } /* @@ -1687,10 +1705,12 @@ GdiGetCharDimensions(HDC hdc, LPTEXTMETRICW lptm, LONG *height) { SIZE sz; TEXTMETRICW tm; - static const WCHAR alphabet[] = { + static const WCHAR alphabet[] = + { 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q', 'r','s','t','u','v','w','x','y','z','A','B','C','D','E','F','G','H', - 'I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z',0}; + 'I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z',0 + }; if(!GetTextMetricsW(hdc, &tm)) return 0; @@ -1723,27 +1743,28 @@ GdiGetCharDimensions(HDC hdc, LPTEXTMETRICW lptm, LONG *height) BOOL WINAPI TranslateCharsetInfo( - LPDWORD lpSrc, /* [in] + LPDWORD lpSrc, /* [in] if flags == TCI_SRCFONTSIG: pointer to fsCsb of a FONTSIGNATURE if flags == TCI_SRCCHARSET: a character set value if flags == TCI_SRCCODEPAGE: a code page value */ - LPCHARSETINFO lpCs, /* [out] structure to receive charset information */ - DWORD flags /* [in] determines interpretation of lpSrc */) + LPCHARSETINFO lpCs, /* [out] structure to receive charset information */ + DWORD flags /* [in] determines interpretation of lpSrc */) { int index = 0; - switch (flags) { + switch (flags) + { case TCI_SRCFONTSIG: - while (index < MAXTCIINDEX && !(*lpSrc>>index & 0x0001)) index++; - break; + while (index < MAXTCIINDEX && !(*lpSrc>>index & 0x0001)) index++; + break; case TCI_SRCCODEPAGE: - while (index < MAXTCIINDEX && PtrToUlong(lpSrc) != FONT_tci[index].ciACP) index++; - break; + while (index < MAXTCIINDEX && PtrToUlong(lpSrc) != FONT_tci[index].ciACP) index++; + break; case TCI_SRCCHARSET: - while (index < MAXTCIINDEX && PtrToUlong(lpSrc) != FONT_tci[index].ciCharset) index++; - break; + while (index < MAXTCIINDEX && PtrToUlong(lpSrc) != FONT_tci[index].ciCharset) index++; + break; default: - return FALSE; + return FALSE; } if (index >= MAXTCIINDEX || FONT_tci[index].ciCharset == DEFAULT_CHARSET) return FALSE; memcpy(lpCs, &FONT_tci[index], sizeof(CHARSETINFO)); @@ -1757,51 +1778,51 @@ TranslateCharsetInfo( DWORD WINAPI SetMapperFlags( - HDC hDC, - DWORD flags - ) + HDC hDC, + DWORD flags +) { - DWORD Ret = GDI_ERROR; - PDC_ATTR Dc_Attr; + DWORD Ret = GDI_ERROR; + PDC_ATTR Dc_Attr; #if 0 - if (GDI_HANDLE_GET_TYPE(hDC) != GDI_OBJECT_TYPE_DC) - { - if (GDI_HANDLE_GET_TYPE(hDC) == GDI_OBJECT_TYPE_METADC) - return MFDRV_SetMapperFlags( hDC, flags); + if (GDI_HANDLE_GET_TYPE(hDC) != GDI_OBJECT_TYPE_DC) + { + if (GDI_HANDLE_GET_TYPE(hDC) == GDI_OBJECT_TYPE_METADC) + return MFDRV_SetMapperFlags( hDC, flags); + else + { + PLDC pLDC = Dc_Attr->pvLDC; + if ( !pLDC ) + { + SetLastError(ERROR_INVALID_HANDLE); + return GDI_ERROR; + } + if (pLDC->iType == LDC_EMFLDC) + { + return EMFDRV_SetMapperFlags( hDC, flags); + } + } + } +#endif + if (!GdiGetHandleUserData((HGDIOBJ) hDC, GDI_OBJECT_TYPE_DC, (PVOID) &Dc_Attr)) return GDI_ERROR; + + if (NtCurrentTeb()->GdiTebBatch.HDC == hDC) + { + if (Dc_Attr->ulDirty_ & DC_FONTTEXT_DIRTY) + { + NtGdiFlush(); + Dc_Attr->ulDirty_ &= ~(DC_MODE_DIRTY|DC_FONTTEXT_DIRTY); + } + } + + if ( flags & ~1 ) + SetLastError(ERROR_INVALID_PARAMETER); else { - PLDC pLDC = Dc_Attr->pvLDC; - if ( !pLDC ) - { - SetLastError(ERROR_INVALID_HANDLE); - return GDI_ERROR; - } - if (pLDC->iType == LDC_EMFLDC) - { - return EMFDRV_SetMapperFlags( hDC, flags); - } + Ret = Dc_Attr->flFontMapper; + Dc_Attr->flFontMapper = flags; } - } -#endif - if (!GdiGetHandleUserData((HGDIOBJ) hDC, GDI_OBJECT_TYPE_DC, (PVOID) &Dc_Attr)) return GDI_ERROR; - - if (NtCurrentTeb()->GdiTebBatch.HDC == hDC) - { - if (Dc_Attr->ulDirty_ & DC_FONTTEXT_DIRTY) - { - NtGdiFlush(); - Dc_Attr->ulDirty_ &= ~(DC_MODE_DIRTY|DC_FONTTEXT_DIRTY); - } - } - - if ( flags & ~1 ) - SetLastError(ERROR_INVALID_PARAMETER); - else - { - Ret = Dc_Attr->flFontMapper; - Dc_Attr->flFontMapper = flags; - } - return Ret; + return Ret; } @@ -1811,16 +1832,16 @@ SetMapperFlags( int WINAPI EnumFontsW( - HDC hDC, - LPCWSTR lpFaceName, - FONTENUMPROCW FontFunc, - LPARAM lParam - ) + HDC hDC, + LPCWSTR lpFaceName, + FONTENUMPROCW FontFunc, + LPARAM lParam +) { #if 0 - return NtGdiEnumFonts ( hDC, lpFaceName, FontFunc, lParam ); + return NtGdiEnumFonts ( hDC, lpFaceName, FontFunc, lParam ); #else - return EnumFontFamiliesW( hDC, lpFaceName, FontFunc, lParam ); + return EnumFontFamiliesW( hDC, lpFaceName, FontFunc, lParam ); #endif } @@ -1830,29 +1851,29 @@ EnumFontsW( int WINAPI EnumFontsA ( - HDC hDC, - LPCSTR lpFaceName, - FONTENUMPROCA FontFunc, - LPARAM lParam - ) + HDC hDC, + LPCSTR lpFaceName, + FONTENUMPROCA FontFunc, + LPARAM lParam +) { #if 0 - NTSTATUS Status; - LPWSTR lpFaceNameW; - int rc = 0; + NTSTATUS Status; + LPWSTR lpFaceNameW; + int rc = 0; - Status = HEAP_strdupA2W ( &lpFaceNameW, lpFaceName ); - if (!NT_SUCCESS (Status)) - SetLastError (RtlNtStatusToDosError(Status)); - else + Status = HEAP_strdupA2W ( &lpFaceNameW, lpFaceName ); + if (!NT_SUCCESS (Status)) + SetLastError (RtlNtStatusToDosError(Status)); + else { - rc = NtGdiEnumFonts ( hDC, lpFaceNameW, FontFunc, lParam ); + rc = NtGdiEnumFonts ( hDC, lpFaceNameW, FontFunc, lParam ); - HEAP_free ( lpFaceNameW ); + HEAP_free ( lpFaceNameW ); } - return rc; + return rc; #else - return EnumFontFamiliesA( hDC, lpFaceName, FontFunc, lParam ); + return EnumFontFamiliesA( hDC, lpFaceName, FontFunc, lParam ); #endif } @@ -1867,50 +1888,50 @@ NewEnumFontFamiliesExW( LPARAM lParam, DWORD dwFlags) { - ULONG_PTR idEnum, cbDataSize, cbRetSize; - PENUMFONTDATAW pEfdw; - PBYTE pBuffer; - PBYTE pMax; - INT ret = 1; + ULONG_PTR idEnum, cbDataSize, cbRetSize; + PENUMFONTDATAW pEfdw; + PBYTE pBuffer; + PBYTE pMax; + INT ret = 1; - /* Open enumeration handle and find out how much memory we need */ - idEnum = NtGdiEnumFontOpen(hDC, - EfdFontFamilies, - 0, - LF_FACESIZE, - (lpLogfont && lpLogfont->lfFaceName[0])? lpLogfont->lfFaceName : NULL, - lpLogfont? lpLogfont->lfCharSet : DEFAULT_CHARSET, - &cbDataSize); - if (idEnum == 0) - { - return 0; - } - if (cbDataSize == 0) - { - NtGdiEnumFontClose(idEnum); - return 0; - } + /* Open enumeration handle and find out how much memory we need */ + idEnum = NtGdiEnumFontOpen(hDC, + EfdFontFamilies, + 0, + LF_FACESIZE, + (lpLogfont && lpLogfont->lfFaceName[0])? lpLogfont->lfFaceName : NULL, + lpLogfont? lpLogfont->lfCharSet : DEFAULT_CHARSET, + &cbDataSize); + if (idEnum == 0) + { + return 0; + } + if (cbDataSize == 0) + { + NtGdiEnumFontClose(idEnum); + return 0; + } - /* Allocate memory */ - pBuffer = HeapAlloc(GetProcessHeap(), 0, cbDataSize); - if (pBuffer == NULL) - { - SetLastError(ERROR_NOT_ENOUGH_MEMORY); - NtGdiEnumFontClose(idEnum); - return 0; - } + /* Allocate memory */ + pBuffer = HeapAlloc(GetProcessHeap(), 0, cbDataSize); + if (pBuffer == NULL) + { + SetLastError(ERROR_NOT_ENOUGH_MEMORY); + NtGdiEnumFontClose(idEnum); + return 0; + } - /* Do the enumeration */ - if (!NtGdiEnumFontChunk(hDC, idEnum, cbDataSize, &cbRetSize, (PVOID)pBuffer)) - { - HeapFree(GetProcessHeap(), 0, pBuffer); - NtGdiEnumFontClose(idEnum); - return 0; - } + /* Do the enumeration */ + if (!NtGdiEnumFontChunk(hDC, idEnum, cbDataSize, &cbRetSize, (PVOID)pBuffer)) + { + HeapFree(GetProcessHeap(), 0, pBuffer); + NtGdiEnumFontClose(idEnum); + return 0; + } /* Get start and end address */ pEfdw = (PENUMFONTDATAW)pBuffer; - pMax = pBuffer + cbDataSize; + pMax = pBuffer + cbDataSize; /* Iterate through the structures */ while ((PBYTE)pEfdw < pMax && ret) @@ -1923,11 +1944,11 @@ NewEnumFontFamiliesExW( lParam); pEfdw = (PENUMFONTDATAW)((ULONG_PTR)pEfdw + pEfdw->cbSize); - } + } - /* Release the memory and close handle */ - HeapFree(GetProcessHeap(), 0, pBuffer); - NtGdiEnumFontClose(idEnum); + /* Release the memory and close handle */ + HeapFree(GetProcessHeap(), 0, pBuffer); + NtGdiEnumFontClose(idEnum); - return ret; + return ret; } diff --git a/reactos/dll/win32/gdi32/objects/icm.c b/reactos/dll/win32/gdi32/objects/icm.c index acbc4b476a4..02e05cb5db7 100644 --- a/reactos/dll/win32/gdi32/objects/icm.c +++ b/reactos/dll/win32/gdi32/objects/icm.c @@ -7,22 +7,22 @@ HCOLORSPACE FASTCALL IntCreateColorSpaceW( - LPLOGCOLORSPACEW lplcpw, - BOOL Ascii - ) + LPLOGCOLORSPACEW lplcpw, + BOOL Ascii +) { - LOGCOLORSPACEEXW lcpeexw; + LOGCOLORSPACEEXW lcpeexw; - if ((lplcpw->lcsSignature != LCS_SIGNATURE) || - (lplcpw->lcsVersion != 0x400) || - (lplcpw->lcsSize != sizeof(LOGCOLORSPACEW))) - { - SetLastError(ERROR_INVALID_COLORSPACE); - return NULL; - } - RtlCopyMemory(&lcpeexw.lcsColorSpace, lplcpw, sizeof(LOGCOLORSPACEW)); - - return NtGdiCreateColorSpace(&lcpeexw); + if ((lplcpw->lcsSignature != LCS_SIGNATURE) || + (lplcpw->lcsVersion != 0x400) || + (lplcpw->lcsSize != sizeof(LOGCOLORSPACEW))) + { + SetLastError(ERROR_INVALID_COLORSPACE); + return NULL; + } + RtlCopyMemory(&lcpeexw.lcsColorSpace, lplcpw, sizeof(LOGCOLORSPACEW)); + + return NtGdiCreateColorSpace(&lcpeexw); } /* @@ -31,10 +31,10 @@ IntCreateColorSpaceW( HCOLORSPACE WINAPI CreateColorSpaceW( - LPLOGCOLORSPACEW lplcpw - ) + LPLOGCOLORSPACEW lplcpw +) { - return IntCreateColorSpaceW(lplcpw, FALSE); + return IntCreateColorSpaceW(lplcpw, FALSE); } @@ -44,36 +44,36 @@ CreateColorSpaceW( HCOLORSPACE WINAPI CreateColorSpaceA( - LPLOGCOLORSPACEA lplcpa - ) + LPLOGCOLORSPACEA lplcpa +) { - LOGCOLORSPACEW lcpw; + LOGCOLORSPACEW lcpw; - if ((lplcpa->lcsSignature != LCS_SIGNATURE) || - (lplcpa->lcsVersion != 0x400) || - (lplcpa->lcsSize != sizeof(LOGCOLORSPACEA))) - { - SetLastError(ERROR_INVALID_COLORSPACE); - return NULL; - } + if ((lplcpa->lcsSignature != LCS_SIGNATURE) || + (lplcpa->lcsVersion != 0x400) || + (lplcpa->lcsSize != sizeof(LOGCOLORSPACEA))) + { + SetLastError(ERROR_INVALID_COLORSPACE); + return NULL; + } - lcpw.lcsSignature = lplcpa->lcsSignature; - lcpw.lcsVersion = lplcpa->lcsVersion; - lcpw.lcsSize = sizeof(LOGCOLORSPACEW); - lcpw.lcsCSType = lplcpa->lcsCSType; - lcpw.lcsIntent = lplcpa->lcsIntent; - lcpw.lcsEndpoints = lplcpa->lcsEndpoints; - lcpw.lcsGammaRed = lplcpa->lcsGammaRed; - lcpw.lcsGammaGreen = lplcpa->lcsGammaGreen; - lcpw.lcsGammaBlue = lplcpa->lcsGammaBlue; + lcpw.lcsSignature = lplcpa->lcsSignature; + lcpw.lcsVersion = lplcpa->lcsVersion; + lcpw.lcsSize = sizeof(LOGCOLORSPACEW); + lcpw.lcsCSType = lplcpa->lcsCSType; + lcpw.lcsIntent = lplcpa->lcsIntent; + lcpw.lcsEndpoints = lplcpa->lcsEndpoints; + lcpw.lcsGammaRed = lplcpa->lcsGammaRed; + lcpw.lcsGammaGreen = lplcpa->lcsGammaGreen; + lcpw.lcsGammaBlue = lplcpa->lcsGammaBlue; - RtlMultiByteToUnicodeN( lcpw.lcsFilename, - MAX_PATH, - NULL, - lplcpa->lcsFilename, - strlen(lplcpa->lcsFilename) + 1); + RtlMultiByteToUnicodeN( lcpw.lcsFilename, + MAX_PATH, + NULL, + lplcpa->lcsFilename, + strlen(lplcpa->lcsFilename) + 1); - return IntCreateColorSpaceW(&lcpw, FALSE); + return IntCreateColorSpaceW(&lcpw, FALSE); } /* @@ -83,14 +83,14 @@ HCOLORSPACE WINAPI GetColorSpace(HDC hDC) { - PDC_ATTR pDc_Attr; + PDC_ATTR pDc_Attr; - if (!GdiGetHandleUserData(hDC, GDI_OBJECT_TYPE_DC, (PVOID)&pDc_Attr)) - { - SetLastError(ERROR_INVALID_HANDLE); - return NULL; - } - return pDc_Attr->hColorSpace; + if (!GdiGetHandleUserData(hDC, GDI_OBJECT_TYPE_DC, (PVOID)&pDc_Attr)) + { + SetLastError(ERROR_INVALID_HANDLE); + return NULL; + } + return pDc_Attr->hColorSpace; } @@ -100,31 +100,31 @@ GetColorSpace(HDC hDC) HCOLORSPACE WINAPI SetColorSpace( - HDC hDC, - HCOLORSPACE hCS - ) + HDC hDC, + HCOLORSPACE hCS +) { - HCOLORSPACE rhCS = GetColorSpace(hDC); + HCOLORSPACE rhCS = GetColorSpace(hDC); - if (GDI_HANDLE_GET_TYPE(hDC) == GDI_OBJECT_TYPE_DC) - { - if (NtGdiSetColorSpace(hDC, hCS)) return rhCS; - } + if (GDI_HANDLE_GET_TYPE(hDC) == GDI_OBJECT_TYPE_DC) + { + if (NtGdiSetColorSpace(hDC, hCS)) return rhCS; + } #if 0 - if (GDI_HANDLE_GET_TYPE(hDC) != GDI_OBJECT_TYPE_METADC) - { - PLDC pLDC = GdiGetLDC(hDC); - if ( !pLDC ) - { - SetLastError(ERROR_INVALID_HANDLE); - return NULL; - } - if (pLDC->iType == LDC_EMFLDC) - { - return NULL; - } - } + if (GDI_HANDLE_GET_TYPE(hDC) != GDI_OBJECT_TYPE_METADC) + { + PLDC pLDC = GdiGetLDC(hDC); + if ( !pLDC ) + { + SetLastError(ERROR_INVALID_HANDLE); + return NULL; + } + if (pLDC->iType == LDC_EMFLDC) + { + return NULL; + } + } #endif - return NULL; + return NULL; } diff --git a/reactos/dll/win32/gdi32/objects/linedda.c b/reactos/dll/win32/gdi32/objects/linedda.c index f6312bbdff7..9e6997206be 100644 --- a/reactos/dll/win32/gdi32/objects/linedda.c +++ b/reactos/dll/win32/gdi32/objects/linedda.c @@ -58,8 +58,9 @@ BOOL WINAPI LineDDA(INT nXStart, INT nYStart, INT nXEnd, INT nYEnd, } if (dx > dy) /* line is "more horizontal" */ { - err = 2*dy - dx; erradd = 2*dy - 2*dx; - for(cnt = 0;cnt < dx; cnt++) + err = 2*dy - dx; + erradd = 2*dy - 2*dx; + for(cnt = 0; cnt < dx; cnt++) { callback(nXStart,nYStart,lParam); if (err > 0) @@ -73,8 +74,9 @@ BOOL WINAPI LineDDA(INT nXStart, INT nYStart, INT nXEnd, INT nYEnd, } else /* line is "more vertical" */ { - err = 2*dx - dy; erradd = 2*dx - 2*dy; - for(cnt = 0;cnt < dy; cnt++) + err = 2*dx - dy; + erradd = 2*dx - 2*dy; + for(cnt = 0; cnt < dy; cnt++) { callback(nXStart,nYStart,lParam); if (err > 0) diff --git a/reactos/dll/win32/gdi32/objects/metafile.c b/reactos/dll/win32/gdi32/objects/metafile.c index 61ded65dd7e..cf4e51759eb 100644 --- a/reactos/dll/win32/gdi32/objects/metafile.c +++ b/reactos/dll/win32/gdi32/objects/metafile.c @@ -14,66 +14,66 @@ BOOL MF_CreateMFDC ( HGDIOBJ hMDC, PMETAFILEDC pmfDC ) { - PMF_ENTRY pMFME; + PMF_ENTRY pMFME; - pMFME = LocalAlloc(LMEM_ZEROINIT, sizeof(MF_ENTRY)); - if (!pMFME) - { - return FALSE; - } + pMFME = LocalAlloc(LMEM_ZEROINIT, sizeof(MF_ENTRY)); + if (!pMFME) + { + return FALSE; + } - if (hMF_List == NULL) - { - hMF_List = pMFME; - InitializeListHead(&hMF_List->List); - } - else - InsertTailList(&hMF_List->List, &pMFME->List); + if (hMF_List == NULL) + { + hMF_List = pMFME; + InitializeListHead(&hMF_List->List); + } + else + InsertTailList(&hMF_List->List, &pMFME->List); - pMFME->hmDC = hMDC; - pMFME->pmfDC = pmfDC; + pMFME->hmDC = hMDC; + pMFME->pmfDC = pmfDC; - hMFCount++; - return TRUE; + hMFCount++; + return TRUE; } PMETAFILEDC MF_GetMFDC ( HGDIOBJ hMDC ) { - PMF_ENTRY pMFME = hMF_List; + PMF_ENTRY pMFME = hMF_List; - do - { - if ( pMFME->hmDC == hMDC ) return pMFME->pmfDC; - pMFME = (PMF_ENTRY) pMFME->List.Flink; - } - while ( pMFME != hMF_List ); + do + { + if ( pMFME->hmDC == hMDC ) return pMFME->pmfDC; + pMFME = (PMF_ENTRY) pMFME->List.Flink; + } + while ( pMFME != hMF_List ); - return NULL; + return NULL; } BOOL MF_DeleteMFDC ( HGDIOBJ hMDC ) { - PMF_ENTRY pMFME = hMF_List; + PMF_ENTRY pMFME = hMF_List; - do - { - if ( pMFME->hmDC == hMDC) + do { - RemoveEntryList(&pMFME->List); - LocalFree ( pMFME ); - hMFCount--; - if (!hMFCount) hMF_List = NULL; - return TRUE; + if ( pMFME->hmDC == hMDC) + { + RemoveEntryList(&pMFME->List); + LocalFree ( pMFME ); + hMFCount--; + if (!hMFCount) hMF_List = NULL; + return TRUE; + } + pMFME = (PMF_ENTRY) pMFME->List.Flink; } - pMFME = (PMF_ENTRY) pMFME->List.Flink; - } - while ( pMFME != hMF_List ); + while ( pMFME != hMF_List ); - return FALSE; + return FALSE; } /* FUNCTIONS *****************************************************************/ @@ -84,10 +84,10 @@ MF_DeleteMFDC ( HGDIOBJ hMDC ) HMETAFILE WINAPI CloseMetaFile( - HDC a0 - ) + HDC a0 +) { - return 0; + return 0; } @@ -97,11 +97,11 @@ CloseMetaFile( HMETAFILE WINAPI CopyMetaFileW( - HMETAFILE hmfSrc, - LPCWSTR lpszFile - ) + HMETAFILE hmfSrc, + LPCWSTR lpszFile +) { - return NULL; + return NULL; } @@ -111,24 +111,24 @@ CopyMetaFileW( HMETAFILE WINAPI CopyMetaFileA( - HMETAFILE hmfSrc, - LPCSTR lpszFile - ) + HMETAFILE hmfSrc, + LPCSTR lpszFile +) { - NTSTATUS Status; - PWSTR lpszFileW; - HMETAFILE rc = 0; + NTSTATUS Status; + PWSTR lpszFileW; + HMETAFILE rc = 0; - Status = HEAP_strdupA2W ( &lpszFileW, lpszFile ); - if (!NT_SUCCESS (Status)) - SetLastError (RtlNtStatusToDosError(Status)); - else - { - rc = CopyMetaFileW( hmfSrc, lpszFileW ); - HEAP_free ( lpszFileW ); - } + Status = HEAP_strdupA2W ( &lpszFileW, lpszFile ); + if (!NT_SUCCESS (Status)) + SetLastError (RtlNtStatusToDosError(Status)); + else + { + rc = CopyMetaFileW( hmfSrc, lpszFileW ); + HEAP_free ( lpszFileW ); + } - return rc; + return rc; } @@ -138,59 +138,59 @@ CopyMetaFileA( HDC WINAPI CreateMetaFileW( - LPCWSTR lpszFile - ) + LPCWSTR lpszFile +) { - HANDLE hFile; - HDC hmDC; - PMETAFILEDC pmfDC = LocalAlloc(LMEM_ZEROINIT, sizeof(METAFILEDC)); - if (!pmfDC) return NULL; + HANDLE hFile; + HDC hmDC; + PMETAFILEDC pmfDC = LocalAlloc(LMEM_ZEROINIT, sizeof(METAFILEDC)); + if (!pmfDC) return NULL; - pmfDC->mh.mtHeaderSize = sizeof(METAHEADER) / sizeof(WORD); - pmfDC->mh.mtVersion = 0x0300; - pmfDC->mh.mtSize = pmfDC->mh.mtHeaderSize; + pmfDC->mh.mtHeaderSize = sizeof(METAHEADER) / sizeof(WORD); + pmfDC->mh.mtVersion = 0x0300; + pmfDC->mh.mtSize = pmfDC->mh.mtHeaderSize; - pmfDC->hPen = GetStockObject(BLACK_PEN); - pmfDC->hBrush = GetStockObject(WHITE_BRUSH); - pmfDC->hFont = GetStockObject(DEVICE_DEFAULT_FONT); - pmfDC->hBitmap = GetStockObject(DEFAULT_BITMAP); - pmfDC->hPalette = GetStockObject(DEFAULT_PALETTE); + pmfDC->hPen = GetStockObject(BLACK_PEN); + pmfDC->hBrush = GetStockObject(WHITE_BRUSH); + pmfDC->hFont = GetStockObject(DEVICE_DEFAULT_FONT); + pmfDC->hBitmap = GetStockObject(DEFAULT_BITMAP); + pmfDC->hPalette = GetStockObject(DEFAULT_PALETTE); - if (lpszFile) /* disk based metafile */ - { - pmfDC->mh.mtType = METAFILE_DISK; - - if(!GetFullPathName( lpszFile, - MAX_PATH, - (LPTSTR) &pmfDC->Filename, - (LPTSTR*) &lpszFile)) + if (lpszFile) /* disk based metafile */ { - LocalFree(pmfDC); - return NULL; + pmfDC->mh.mtType = METAFILE_DISK; + + if(!GetFullPathName( lpszFile, + MAX_PATH, + (LPTSTR) &pmfDC->Filename, + (LPTSTR*) &lpszFile)) + { + LocalFree(pmfDC); + return NULL; + } + + if ((hFile = CreateFileW(pmfDC->Filename, GENERIC_WRITE, 0, NULL, + CREATE_ALWAYS, 0, 0)) == INVALID_HANDLE_VALUE) + { + LocalFree(pmfDC); + return NULL; + } + + if (!WriteFile( hFile, &pmfDC->mh, sizeof(pmfDC->mh), &pmfDC->dwWritten, NULL )) + { + LocalFree(pmfDC); + return NULL; + } + pmfDC->hFile = hFile; } + else /* memory based metafile */ + pmfDC->mh.mtType = METAFILE_MEMORY; - if ((hFile = CreateFileW(pmfDC->Filename, GENERIC_WRITE, 0, NULL, - CREATE_ALWAYS, 0, 0)) == INVALID_HANDLE_VALUE) - { - LocalFree(pmfDC); - return NULL; - } + hmDC = NtGdiCreateClientObj ( GDI_OBJECT_TYPE_METADC ); - if (!WriteFile( hFile, &pmfDC->mh, sizeof(pmfDC->mh), &pmfDC->dwWritten, NULL )) - { - LocalFree(pmfDC); - return NULL; - } - pmfDC->hFile = hFile; - } - else /* memory based metafile */ - pmfDC->mh.mtType = METAFILE_MEMORY; + MF_CreateMFDC ( hmDC, pmfDC ); - hmDC = NtGdiCreateClientObj ( GDI_OBJECT_TYPE_METADC ); - - MF_CreateMFDC ( hmDC, pmfDC ); - - return hmDC; + return hmDC; } @@ -200,22 +200,22 @@ CreateMetaFileW( HDC WINAPI CreateMetaFileA( - LPCSTR lpszFile - ) + LPCSTR lpszFile +) { - NTSTATUS Status; - PWSTR lpszFileW; - HDC rc = 0; + NTSTATUS Status; + PWSTR lpszFileW; + HDC rc = 0; - Status = HEAP_strdupA2W ( &lpszFileW, lpszFile ); - if (!NT_SUCCESS (Status)) - SetLastError (RtlNtStatusToDosError(Status)); - else + Status = HEAP_strdupA2W ( &lpszFileW, lpszFile ); + if (!NT_SUCCESS (Status)) + SetLastError (RtlNtStatusToDosError(Status)); + else { - rc = CreateMetaFileW( lpszFileW ); - HEAP_free ( lpszFileW ); + rc = CreateMetaFileW( lpszFileW ); + HEAP_free ( lpszFileW ); } - return rc; + return rc; } @@ -225,10 +225,10 @@ CreateMetaFileA( BOOL WINAPI DeleteMetaFile( - HMETAFILE a0 - ) + HMETAFILE a0 +) { - return FALSE; + return FALSE; } @@ -238,10 +238,10 @@ DeleteMetaFile( HMETAFILE WINAPI GetMetaFileW( - LPCWSTR lpszMetaFile - ) + LPCWSTR lpszMetaFile +) { - return NULL; + return NULL; } @@ -251,23 +251,23 @@ GetMetaFileW( HMETAFILE WINAPI GetMetaFileA( - LPCSTR lpszMetaFile - ) + LPCSTR lpszMetaFile +) { - NTSTATUS Status; - LPWSTR lpszMetaFileW; - HMETAFILE rc = 0; + NTSTATUS Status; + LPWSTR lpszMetaFileW; + HMETAFILE rc = 0; - Status = HEAP_strdupA2W ( &lpszMetaFileW, lpszMetaFile ); - if (!NT_SUCCESS (Status)) - SetLastError (RtlNtStatusToDosError(Status)); - else + Status = HEAP_strdupA2W ( &lpszMetaFileW, lpszMetaFile ); + if (!NT_SUCCESS (Status)) + SetLastError (RtlNtStatusToDosError(Status)); + else { - rc = GetMetaFileW( lpszMetaFileW ); - HEAP_free ( lpszMetaFileW ); + rc = GetMetaFileW( lpszMetaFileW ); + HEAP_free ( lpszMetaFileW ); } - return rc; + return rc; } diff --git a/reactos/dll/win32/gdi32/objects/painting.c b/reactos/dll/win32/gdi32/objects/painting.c index a1bbcbb1abf..c6f3d849a98 100644 --- a/reactos/dll/win32/gdi32/objects/painting.c +++ b/reactos/dll/win32/gdi32/objects/painting.c @@ -10,27 +10,27 @@ LineTo( HDC hDC, INT x, INT y ) { #if 0 // Handle something other than a normal dc object. - if (GDI_HANDLE_GET_TYPE(hDC) != GDI_OBJECT_TYPE_DC) - { - if (GDI_HANDLE_GET_TYPE(hDC) == GDI_OBJECT_TYPE_METADC) - return MFDRV_MetaParam2( hDC, META_LINETO, x, y); - else + if (GDI_HANDLE_GET_TYPE(hDC) != GDI_OBJECT_TYPE_DC) { - PLDC pLDC = GdiGetLDC(hDC); - if ( !pLDC ) - { - SetLastError(ERROR_INVALID_HANDLE); - return FALSE; - } - if (pLDC->iType == LDC_EMFLDC) - { - return MFDRV_LineTo( hDC, x, y ) - } - return FALSE; + if (GDI_HANDLE_GET_TYPE(hDC) == GDI_OBJECT_TYPE_METADC) + return MFDRV_MetaParam2( hDC, META_LINETO, x, y); + else + { + PLDC pLDC = GdiGetLDC(hDC); + if ( !pLDC ) + { + SetLastError(ERROR_INVALID_HANDLE); + return FALSE; + } + if (pLDC->iType == LDC_EMFLDC) + { + return MFDRV_LineTo( hDC, x, y ) + } + return FALSE; + } } - } #endif - return NtGdiLineTo( hDC, x, y); + return NtGdiLineTo( hDC, x, y); } @@ -38,50 +38,50 @@ BOOL WINAPI MoveToEx( HDC hDC, INT x, INT y, LPPOINT Point ) { - PDC_ATTR Dc_Attr; + PDC_ATTR Dc_Attr; #if 0 - if (GDI_HANDLE_GET_TYPE(hDC) != GDI_OBJECT_TYPE_DC) - { - if (GDI_HANDLE_GET_TYPE(hDC) == GDI_OBJECT_TYPE_METADC) - return MFDRV_MetaParam2( hDC, META_MOVETO, x, y); - else + if (GDI_HANDLE_GET_TYPE(hDC) != GDI_OBJECT_TYPE_DC) { - PLDC pLDC = Dc_Attr->pvLDC; - if ( !pLDC ) - { - SetLastError(ERROR_INVALID_HANDLE); - return FALSE; - } - if (pLDC->iType == LDC_EMFLDC) - { - if (!EMFDRV_MoveTo( hDC, x, y)) return FALSE; - } + if (GDI_HANDLE_GET_TYPE(hDC) == GDI_OBJECT_TYPE_METADC) + return MFDRV_MetaParam2( hDC, META_MOVETO, x, y); + else + { + PLDC pLDC = Dc_Attr->pvLDC; + if ( !pLDC ) + { + SetLastError(ERROR_INVALID_HANDLE); + return FALSE; + } + if (pLDC->iType == LDC_EMFLDC) + { + if (!EMFDRV_MoveTo( hDC, x, y)) return FALSE; + } + } } - } #endif - if (!GdiGetHandleUserData((HGDIOBJ) hDC, GDI_OBJECT_TYPE_DC, (PVOID) &Dc_Attr)) return FALSE; + if (!GdiGetHandleUserData((HGDIOBJ) hDC, GDI_OBJECT_TYPE_DC, (PVOID) &Dc_Attr)) return FALSE; - if ( Point ) - { - if ( Dc_Attr->ulDirty_ & DIRTY_PTLCURRENT ) // Double hit! + if ( Point ) { - Point->x = Dc_Attr->ptfxCurrent.x; // ret prev before change. - Point->y = Dc_Attr->ptfxCurrent.y; - DPtoLP ( hDC, Point, 1); // reconvert back. + if ( Dc_Attr->ulDirty_ & DIRTY_PTLCURRENT ) // Double hit! + { + Point->x = Dc_Attr->ptfxCurrent.x; // ret prev before change. + Point->y = Dc_Attr->ptfxCurrent.y; + DPtoLP ( hDC, Point, 1); // reconvert back. + } + else + { + Point->x = Dc_Attr->ptlCurrent.x; + Point->y = Dc_Attr->ptlCurrent.y; + } } - else - { - Point->x = Dc_Attr->ptlCurrent.x; - Point->y = Dc_Attr->ptlCurrent.y; - } - } - Dc_Attr->ptlCurrent.x = x; - Dc_Attr->ptlCurrent.y = y; + Dc_Attr->ptlCurrent.x = x; + Dc_Attr->ptlCurrent.y = y; - Dc_Attr->ulDirty_ &= ~DIRTY_PTLCURRENT; - Dc_Attr->ulDirty_ |= ( DIRTY_PTFXCURRENT|DIRTY_STYLESTATE); // Set dirty - return TRUE; + Dc_Attr->ulDirty_ &= ~DIRTY_PTLCURRENT; + Dc_Attr->ulDirty_ |= ( DIRTY_PTFXCURRENT|DIRTY_STYLESTATE); // Set dirty + return TRUE; } @@ -94,27 +94,27 @@ Ellipse(HDC hDC, INT Left, INT Top, INT Right, INT Bottom) { #if 0 // Handle something other than a normal dc object. - if (GDI_HANDLE_GET_TYPE(hDC) != GDI_OBJECT_TYPE_DC) - { - if (GDI_HANDLE_GET_TYPE(hDC) == GDI_OBJECT_TYPE_METADC) - return MFDRV_MetaParam4(hDC, META_ELLIPSE, Left, Top, Right, Bottom ); - else + if (GDI_HANDLE_GET_TYPE(hDC) != GDI_OBJECT_TYPE_DC) { - PLDC pLDC = GdiGetLDC(hDC); - if ( !pLDC ) - { - SetLastError(ERROR_INVALID_HANDLE); - return FALSE; - } - if (pLDC->iType == LDC_EMFLDC) - { - return EMFDRV_Ellipse( hDC, Left, Top, Right, Bottom ); - } - return FALSE; + if (GDI_HANDLE_GET_TYPE(hDC) == GDI_OBJECT_TYPE_METADC) + return MFDRV_MetaParam4(hDC, META_ELLIPSE, Left, Top, Right, Bottom ); + else + { + PLDC pLDC = GdiGetLDC(hDC); + if ( !pLDC ) + { + SetLastError(ERROR_INVALID_HANDLE); + return FALSE; + } + if (pLDC->iType == LDC_EMFLDC) + { + return EMFDRV_Ellipse( hDC, Left, Top, Right, Bottom ); + } + return FALSE; + } } - } #endif - return NtGdiEllipse( hDC, Left, Top, Right, Bottom); + return NtGdiEllipse( hDC, Left, Top, Right, Bottom); } @@ -127,27 +127,27 @@ Rectangle(HDC hDC, INT Left, INT Top, INT Right, INT Bottom) { #if 0 // Handle something other than a normal dc object. - if (GDI_HANDLE_GET_TYPE(hDC) != GDI_OBJECT_TYPE_DC) - { - if (GDI_HANDLE_GET_TYPE(hDC) == GDI_OBJECT_TYPE_METADC) - return MFDRV_MetaParam4(hDC, META_RECTANGLE, Left, Top, Right, Bottom ); - else + if (GDI_HANDLE_GET_TYPE(hDC) != GDI_OBJECT_TYPE_DC) { - PLDC pLDC = GdiGetLDC(hDC); - if ( !pLDC ) - { - SetLastError(ERROR_INVALID_HANDLE); - return FALSE; - } - if (pLDC->iType == LDC_EMFLDC) - { - return EMFDRV_Rectangle( hDC, Left, Top, Right, Bottom ); - } - return FALSE; + if (GDI_HANDLE_GET_TYPE(hDC) == GDI_OBJECT_TYPE_METADC) + return MFDRV_MetaParam4(hDC, META_RECTANGLE, Left, Top, Right, Bottom ); + else + { + PLDC pLDC = GdiGetLDC(hDC); + if ( !pLDC ) + { + SetLastError(ERROR_INVALID_HANDLE); + return FALSE; + } + if (pLDC->iType == LDC_EMFLDC) + { + return EMFDRV_Rectangle( hDC, Left, Top, Right, Bottom ); + } + return FALSE; + } } - } #endif - return NtGdiRectangle( hDC, Left, Top, Right, Bottom); + return NtGdiRectangle( hDC, Left, Top, Right, Bottom); } @@ -157,33 +157,33 @@ Rectangle(HDC hDC, INT Left, INT Top, INT Right, INT Bottom) BOOL WINAPI RoundRect(HDC hDC, INT Left, INT Top, INT Right, INT Bottom, - INT ell_Width, INT ell_Height) + INT ell_Width, INT ell_Height) { #if 0 // Handle something other than a normal dc object. - if (GDI_HANDLE_GET_TYPE(hDC) != GDI_OBJECT_TYPE_DC) - { - if (GDI_HANDLE_GET_TYPE(hDC) == GDI_OBJECT_TYPE_METADC) - return MFDRV_MetaParam6( hDC, META_ROUNDRECT, Left, Top, Right, Bottom, - ell_Width, ell_Height ); - else + if (GDI_HANDLE_GET_TYPE(hDC) != GDI_OBJECT_TYPE_DC) { - PLDC pLDC = GdiGetLDC(hDC); - if ( !pLDC ) - { - SetLastError(ERROR_INVALID_HANDLE); - return FALSE; - } - if (pLDC->iType == LDC_EMFLDC) - { - return EMFDRV_RoundRect( hDC, Left, Top, Right, Bottom, - ell_Width, ell_Height ); - } - return FALSE; + if (GDI_HANDLE_GET_TYPE(hDC) == GDI_OBJECT_TYPE_METADC) + return MFDRV_MetaParam6( hDC, META_ROUNDRECT, Left, Top, Right, Bottom, + ell_Width, ell_Height ); + else + { + PLDC pLDC = GdiGetLDC(hDC); + if ( !pLDC ) + { + SetLastError(ERROR_INVALID_HANDLE); + return FALSE; + } + if (pLDC->iType == LDC_EMFLDC) + { + return EMFDRV_RoundRect( hDC, Left, Top, Right, Bottom, + ell_Width, ell_Height ); + } + return FALSE; + } } - } #endif - return NtGdiRoundRect( hDC, Left, Top, Right, Bottom, ell_Width, ell_Height); + return NtGdiRoundRect( hDC, Left, Top, Right, Bottom, ell_Width, ell_Height); } @@ -194,9 +194,9 @@ COLORREF WINAPI GetPixel( HDC hDC, INT x, INT y ) { - if (GDI_HANDLE_GET_TYPE(hDC) != GDI_OBJECT_TYPE_DC) return CLR_INVALID; - if (!GdiIsHandleValid((HGDIOBJ) hDC)) return CLR_INVALID; - return NtGdiGetPixel( hDC, x, y); + if (GDI_HANDLE_GET_TYPE(hDC) != GDI_OBJECT_TYPE_DC) return CLR_INVALID; + if (!GdiIsHandleValid((HGDIOBJ) hDC)) return CLR_INVALID; + return NtGdiGetPixel( hDC, x, y); } @@ -209,28 +209,28 @@ SetPixel( HDC hDC, INT x, INT y, COLORREF Color ) { #if 0 // Handle something other than a normal dc object. - if (GDI_HANDLE_GET_TYPE(hDC) != GDI_OBJECT_TYPE_DC) - { - if (GDI_HANDLE_GET_TYPE(hDC) == GDI_OBJECT_TYPE_METADC) - return MFDRV_MetaParam4(hDC, META_SETPIXEL, x, y, HIWORD(Color), - LOWORD(Color)); - else + if (GDI_HANDLE_GET_TYPE(hDC) != GDI_OBJECT_TYPE_DC) { - PLDC pLDC = GdiGetLDC(hDC); - if ( !pLDC ) - { - SetLastError(ERROR_INVALID_HANDLE); - return 0; - } - if (pLDC->iType == LDC_EMFLDC) - { - return EMFDRV_SetPixel( hDC, x, y, Color ); - } - return 0; + if (GDI_HANDLE_GET_TYPE(hDC) == GDI_OBJECT_TYPE_METADC) + return MFDRV_MetaParam4(hDC, META_SETPIXEL, x, y, HIWORD(Color), + LOWORD(Color)); + else + { + PLDC pLDC = GdiGetLDC(hDC); + if ( !pLDC ) + { + SetLastError(ERROR_INVALID_HANDLE); + return 0; + } + if (pLDC->iType == LDC_EMFLDC) + { + return EMFDRV_SetPixel( hDC, x, y, Color ); + } + return 0; + } } - } #endif - return NtGdiSetPixel( hDC, x, y, Color); + return NtGdiSetPixel( hDC, x, y, Color); } @@ -241,9 +241,9 @@ BOOL WINAPI SetPixelV( HDC hDC, INT x, INT y, COLORREF Color ) { - COLORREF Cr = SetPixel( hDC, x, y, Color ); - if (Cr != CLR_INVALID) return TRUE; - return FALSE; + COLORREF Cr = SetPixel( hDC, x, y, Color ); + if (Cr != CLR_INVALID) return TRUE; + return FALSE; } @@ -255,30 +255,30 @@ WINAPI FillRgn( HDC hDC, HRGN hRgn, HBRUSH hBrush ) { - if ( (!hRgn) || (!hBrush) ) return FALSE; + if ( (!hRgn) || (!hBrush) ) return FALSE; #if 0 // Handle something other than a normal dc object. - if (GDI_HANDLE_GET_TYPE(hDC) != GDI_OBJECT_TYPE_DC) - { - if (GDI_HANDLE_GET_TYPE(hDC) == GDI_OBJECT_TYPE_METADC) - return MFDRV_FillRgn( hDC, hRgn, hBrush); - else + if (GDI_HANDLE_GET_TYPE(hDC) != GDI_OBJECT_TYPE_DC) { - PLDC pLDC = GdiGetLDC(hDC); - if ( !pLDC ) - { - SetLastError(ERROR_INVALID_HANDLE); - return FALSE; - } - if (pLDC->iType == LDC_EMFLDC) - { - return EMFDRV_FillRgn(( hDC, hRgn, hBrush); - } - return FALSE; + if (GDI_HANDLE_GET_TYPE(hDC) == GDI_OBJECT_TYPE_METADC) + return MFDRV_FillRgn( hDC, hRgn, hBrush); + else + { + PLDC pLDC = GdiGetLDC(hDC); + if ( !pLDC ) + { + SetLastError(ERROR_INVALID_HANDLE); + return FALSE; + } + if (pLDC->iType == LDC_EMFLDC) + { + return EMFDRV_FillRgn(( hDC, hRgn, hBrush); + } + return FALSE; + } } - } #endif - return NtGdiFillRgn( hDC, hRgn, hBrush); + return NtGdiFillRgn( hDC, hRgn, hBrush); } @@ -290,30 +290,30 @@ WINAPI FrameRgn( HDC hDC, HRGN hRgn, HBRUSH hBrush, INT nWidth, INT nHeight ) { - if ( (!hRgn) || (!hBrush) ) return FALSE; + if ( (!hRgn) || (!hBrush) ) return FALSE; #if 0 // Handle something other than a normal dc object. - if (GDI_HANDLE_GET_TYPE(hDC) != GDI_OBJECT_TYPE_DC) - { - if (GDI_HANDLE_GET_TYPE(hDC) == GDI_OBJECT_TYPE_METADC) - return MFDRV_FrameRgn( hDC, hRgn, hBrush, nWidth, nHeight ); - else + if (GDI_HANDLE_GET_TYPE(hDC) != GDI_OBJECT_TYPE_DC) { - PLDC pLDC = GdiGetLDC(hDC); - if ( !pLDC ) - { - SetLastError(ERROR_INVALID_HANDLE); - return FALSE; - } - if (pLDC->iType == LDC_EMFLDC) - { - return EMFDRV_FrameRgn( hDC, hRgn, hBrush, nWidth, nHeight ); - } - return FALSE; + if (GDI_HANDLE_GET_TYPE(hDC) == GDI_OBJECT_TYPE_METADC) + return MFDRV_FrameRgn( hDC, hRgn, hBrush, nWidth, nHeight ); + else + { + PLDC pLDC = GdiGetLDC(hDC); + if ( !pLDC ) + { + SetLastError(ERROR_INVALID_HANDLE); + return FALSE; + } + if (pLDC->iType == LDC_EMFLDC) + { + return EMFDRV_FrameRgn( hDC, hRgn, hBrush, nWidth, nHeight ); + } + return FALSE; + } } - } #endif - return NtGdiFrameRgn( hDC, hRgn, hBrush, nWidth, nHeight); + return NtGdiFrameRgn( hDC, hRgn, hBrush, nWidth, nHeight); } @@ -325,30 +325,30 @@ WINAPI InvertRgn( HDC hDC, HRGN hRgn ) { - if ( !hRgn ) return FALSE; + if ( !hRgn ) return FALSE; #if 0 // Handle something other than a normal dc object. - if (GDI_HANDLE_GET_TYPE(hDC) != GDI_OBJECT_TYPE_DC) - { - if (GDI_HANDLE_GET_TYPE(hDC) == GDI_OBJECT_TYPE_METADC) - return MFDRV_InvertRgn( hDC, HRGN hRgn ); // Use this instead of MFDRV_MetaParam. - else + if (GDI_HANDLE_GET_TYPE(hDC) != GDI_OBJECT_TYPE_DC) { - PLDC pLDC = GdiGetLDC(hDC); - if ( !pLDC ) - { - SetLastError(ERROR_INVALID_HANDLE); - return FALSE; - } - if (pLDC->iType == LDC_EMFLDC) - { - return EMFDRV_PaintInvertRgn( hDC, hRgn, EMR_INVERTRGN ); - } - return FALSE; + if (GDI_HANDLE_GET_TYPE(hDC) == GDI_OBJECT_TYPE_METADC) + return MFDRV_InvertRgn( hDC, HRGN hRgn ); // Use this instead of MFDRV_MetaParam. + else + { + PLDC pLDC = GdiGetLDC(hDC); + if ( !pLDC ) + { + SetLastError(ERROR_INVALID_HANDLE); + return FALSE; + } + if (pLDC->iType == LDC_EMFLDC) + { + return EMFDRV_PaintInvertRgn( hDC, hRgn, EMR_INVERTRGN ); + } + return FALSE; + } } - } #endif - return NtGdiInvertRgn( hDC, hRgn); + return NtGdiInvertRgn( hDC, hRgn); } @@ -361,30 +361,30 @@ PaintRgn( HDC hDC, HRGN hRgn ) { #if 0 // Handle something other than a normal dc object. - if (GDI_HANDLE_GET_TYPE(hDC) != GDI_OBJECT_TYPE_DC) - { - if (GDI_HANDLE_GET_TYPE(hDC) == GDI_OBJECT_TYPE_METADC) - return MFDRV_PaintRgn( hDC, HRGN hRgn ); // Use this instead of MFDRV_MetaParam. - else + if (GDI_HANDLE_GET_TYPE(hDC) != GDI_OBJECT_TYPE_DC) { - PLDC pLDC = GdiGetLDC(hDC); - if ( !pLDC ) - { - SetLastError(ERROR_INVALID_HANDLE); - return FALSE; - } - if (pLDC->iType == LDC_EMFLDC) - { - return EMFDRV_PaintInvertRgn( hDC, hRgn, EMR_PAINTRGN ); - } - return FALSE; + if (GDI_HANDLE_GET_TYPE(hDC) == GDI_OBJECT_TYPE_METADC) + return MFDRV_PaintRgn( hDC, HRGN hRgn ); // Use this instead of MFDRV_MetaParam. + else + { + PLDC pLDC = GdiGetLDC(hDC); + if ( !pLDC ) + { + SetLastError(ERROR_INVALID_HANDLE); + return FALSE; + } + if (pLDC->iType == LDC_EMFLDC) + { + return EMFDRV_PaintInvertRgn( hDC, hRgn, EMR_PAINTRGN ); + } + return FALSE; + } } - } #endif - // Could just use Dc_Attr->hbrush? No. - HBRUSH hBrush = (HBRUSH) GetDCObject( hDC, GDI_OBJECT_TYPE_BRUSH); +// Could just use Dc_Attr->hbrush? No. + HBRUSH hBrush = (HBRUSH) GetDCObject( hDC, GDI_OBJECT_TYPE_BRUSH); - return NtGdiFillRgn( hDC, hRgn, hBrush); + return NtGdiFillRgn( hDC, hRgn, hBrush); } @@ -397,31 +397,31 @@ PolyBezier(HDC hDC ,const POINT* Point, DWORD cPoints) { #if 0 // Handle something other than a normal dc object. - if (GDI_HANDLE_GET_TYPE(hDC) != GDI_OBJECT_TYPE_DC) - { - if (GDI_HANDLE_GET_TYPE(hDC) == GDI_OBJECT_TYPE_METADC) - /* - * Since MetaFiles don't record Beziers and they don't even record - * approximations to them using lines. - */ - return FALSE; - else + if (GDI_HANDLE_GET_TYPE(hDC) != GDI_OBJECT_TYPE_DC) { - PLDC pLDC = GdiGetLDC(hDC); - if ( !pLDC ) - { - SetLastError(ERROR_INVALID_HANDLE); - return FALSE; - } - if (pLDC->iType == LDC_EMFLDC) - { - return FALSE; // Not supported yet. - } - return FALSE; + if (GDI_HANDLE_GET_TYPE(hDC) == GDI_OBJECT_TYPE_METADC) + /* + * Since MetaFiles don't record Beziers and they don't even record + * approximations to them using lines. + */ + return FALSE; + else + { + PLDC pLDC = GdiGetLDC(hDC); + if ( !pLDC ) + { + SetLastError(ERROR_INVALID_HANDLE); + return FALSE; + } + if (pLDC->iType == LDC_EMFLDC) + { + return FALSE; // Not supported yet. + } + return FALSE; + } } - } #endif - return NtGdiPolyPolyDraw( hDC ,(PPOINT) Point, &cPoints, 1, GdiPolyBezier ); + return NtGdiPolyPolyDraw( hDC ,(PPOINT) Point, &cPoints, 1, GdiPolyBezier ); } @@ -434,27 +434,27 @@ PolyBezierTo(HDC hDC, const POINT* Point ,DWORD cPoints) { #if 0 // Handle something other than a normal dc object. - if (GDI_HANDLE_GET_TYPE(hDC) != GDI_OBJECT_TYPE_DC) - { - if (GDI_HANDLE_GET_TYPE(hDC) == GDI_OBJECT_TYPE_METADC) - return FALSE; - else + if (GDI_HANDLE_GET_TYPE(hDC) != GDI_OBJECT_TYPE_DC) { - PLDC pLDC = GdiGetLDC(hDC); - if ( !pLDC ) - { - SetLastError(ERROR_INVALID_HANDLE); - return FALSE; - } - if (pLDC->iType == LDC_EMFLDC) - { - return FALSE; // Not supported yet. - } - return FALSE; + if (GDI_HANDLE_GET_TYPE(hDC) == GDI_OBJECT_TYPE_METADC) + return FALSE; + else + { + PLDC pLDC = GdiGetLDC(hDC); + if ( !pLDC ) + { + SetLastError(ERROR_INVALID_HANDLE); + return FALSE; + } + if (pLDC->iType == LDC_EMFLDC) + { + return FALSE; // Not supported yet. + } + return FALSE; + } } - } #endif - return NtGdiPolyPolyDraw( hDC , (PPOINT) Point, &cPoints, 1, GdiPolyBezierTo ); + return NtGdiPolyPolyDraw( hDC , (PPOINT) Point, &cPoints, 1, GdiPolyBezierTo ); } @@ -467,27 +467,27 @@ PolyDraw(HDC hDC, const POINT* Point, const BYTE *lpbTypes, int cCount ) { #if 0 // Handle something other than a normal dc object. - if (GDI_HANDLE_GET_TYPE(hDC) != GDI_OBJECT_TYPE_DC) - { - if (GDI_HANDLE_GET_TYPE(hDC) == GDI_OBJECT_TYPE_METADC) - return FALSE; - else + if (GDI_HANDLE_GET_TYPE(hDC) != GDI_OBJECT_TYPE_DC) { - PLDC pLDC = GdiGetLDC(hDC); - if ( !pLDC ) - { - SetLastError(ERROR_INVALID_HANDLE); - return FALSE; - } - if (pLDC->iType == LDC_EMFLDC) - { - return FALSE; // Not supported yet. - } - return FALSE; + if (GDI_HANDLE_GET_TYPE(hDC) == GDI_OBJECT_TYPE_METADC) + return FALSE; + else + { + PLDC pLDC = GdiGetLDC(hDC); + if ( !pLDC ) + { + SetLastError(ERROR_INVALID_HANDLE); + return FALSE; + } + if (pLDC->iType == LDC_EMFLDC) + { + return FALSE; // Not supported yet. + } + return FALSE; + } } - } #endif - return NtGdiPolyDraw( hDC , (PPOINT) Point, (PBYTE)lpbTypes, cCount ); + return NtGdiPolyDraw( hDC , (PPOINT) Point, (PBYTE)lpbTypes, cCount ); } @@ -500,27 +500,27 @@ Polygon(HDC hDC, const POINT *Point, int Count) { #if 0 // Handle something other than a normal dc object. - if (GDI_HANDLE_GET_TYPE(hDC) != GDI_OBJECT_TYPE_DC) - { - if (GDI_HANDLE_GET_TYPE(hDC) == GDI_OBJECT_TYPE_METADC) - return MFDRV_Polygon( hDC, Point, Count ); - else + if (GDI_HANDLE_GET_TYPE(hDC) != GDI_OBJECT_TYPE_DC) { - PLDC pLDC = GdiGetLDC(hDC); - if ( !pLDC ) - { - SetLastError(ERROR_INVALID_HANDLE); - return FALSE; - } - if (pLDC->iType == LDC_EMFLDC) - { - return EMFDRV_Polygon( hDC, Point, Count ); - } - return FALSE; + if (GDI_HANDLE_GET_TYPE(hDC) == GDI_OBJECT_TYPE_METADC) + return MFDRV_Polygon( hDC, Point, Count ); + else + { + PLDC pLDC = GdiGetLDC(hDC); + if ( !pLDC ) + { + SetLastError(ERROR_INVALID_HANDLE); + return FALSE; + } + if (pLDC->iType == LDC_EMFLDC) + { + return EMFDRV_Polygon( hDC, Point, Count ); + } + return FALSE; + } } - } #endif - return NtGdiPolyPolyDraw( hDC , (PPOINT) Point, (PULONG)&Count, 1, GdiPolyPolygon ); + return NtGdiPolyPolyDraw( hDC , (PPOINT) Point, (PULONG)&Count, 1, GdiPolyPolygon ); } @@ -533,27 +533,27 @@ Polyline(HDC hDC, const POINT *Point, int Count) { #if 0 // Handle something other than a normal dc object. - if (GDI_HANDLE_GET_TYPE(hDC) != GDI_OBJECT_TYPE_DC) - { - if (GDI_HANDLE_GET_TYPE(hDC) == GDI_OBJECT_TYPE_METADC) - return MFDRV_Polyline( hDC, Point, Count ); - else + if (GDI_HANDLE_GET_TYPE(hDC) != GDI_OBJECT_TYPE_DC) { - PLDC pLDC = GdiGetLDC(hDC); - if ( !pLDC ) - { - SetLastError(ERROR_INVALID_HANDLE); - return FALSE; - } - if (pLDC->iType == LDC_EMFLDC) - { - return EMFDRV_Polyline( hDC, Point, Count ); - } - return FALSE; + if (GDI_HANDLE_GET_TYPE(hDC) == GDI_OBJECT_TYPE_METADC) + return MFDRV_Polyline( hDC, Point, Count ); + else + { + PLDC pLDC = GdiGetLDC(hDC); + if ( !pLDC ) + { + SetLastError(ERROR_INVALID_HANDLE); + return FALSE; + } + if (pLDC->iType == LDC_EMFLDC) + { + return EMFDRV_Polyline( hDC, Point, Count ); + } + return FALSE; + } } - } #endif - return NtGdiPolyPolyDraw( hDC , (PPOINT) Point, (PULONG)&Count, 1, GdiPolyPolyLine ); + return NtGdiPolyPolyDraw( hDC , (PPOINT) Point, (PULONG)&Count, 1, GdiPolyPolyLine ); } @@ -566,27 +566,27 @@ PolylineTo(HDC hDC, const POINT* Point, DWORD Count) { #if 0 // Handle something other than a normal dc object. - if (GDI_HANDLE_GET_TYPE(hDC) != GDI_OBJECT_TYPE_DC) - { - if (GDI_HANDLE_GET_TYPE(hDC) == GDI_OBJECT_TYPE_METADC) - return FALSE; - else + if (GDI_HANDLE_GET_TYPE(hDC) != GDI_OBJECT_TYPE_DC) { - PLDC pLDC = GdiGetLDC(hDC); - if ( !pLDC ) - { - SetLastError(ERROR_INVALID_HANDLE); - return FALSE; - } - if (pLDC->iType == LDC_EMFLDC) - { - return FALSE; // Not supported yet. - } - return FALSE; + if (GDI_HANDLE_GET_TYPE(hDC) == GDI_OBJECT_TYPE_METADC) + return FALSE; + else + { + PLDC pLDC = GdiGetLDC(hDC); + if ( !pLDC ) + { + SetLastError(ERROR_INVALID_HANDLE); + return FALSE; + } + if (pLDC->iType == LDC_EMFLDC) + { + return FALSE; // Not supported yet. + } + return FALSE; + } } - } #endif - return NtGdiPolyPolyDraw( hDC , (PPOINT) Point, &Count, 1, GdiPolyLineTo ); + return NtGdiPolyPolyDraw( hDC , (PPOINT) Point, &Count, 1, GdiPolyLineTo ); } @@ -599,27 +599,27 @@ PolyPolygon(HDC hDC, const POINT* Point, const INT* Count, int Polys) { #if 0 // Handle something other than a normal dc object. - if (GDI_HANDLE_GET_TYPE(hDC) != GDI_OBJECT_TYPE_DC) - { - if (GDI_HANDLE_GET_TYPE(hDC) == GDI_OBJECT_TYPE_METADC) - return MFDRV_PolyPolygon( hDC, Point, Count, Polys); - else + if (GDI_HANDLE_GET_TYPE(hDC) != GDI_OBJECT_TYPE_DC) { - PLDC pLDC = GdiGetLDC(hDC); - if ( !pLDC ) - { - SetLastError(ERROR_INVALID_HANDLE); - return FALSE; - } - if (pLDC->iType == LDC_EMFLDC) - { - return EMFDRV_PolyPolygon( hDC, Point, Count, Polys ); - } - return FALSE; + if (GDI_HANDLE_GET_TYPE(hDC) == GDI_OBJECT_TYPE_METADC) + return MFDRV_PolyPolygon( hDC, Point, Count, Polys); + else + { + PLDC pLDC = GdiGetLDC(hDC); + if ( !pLDC ) + { + SetLastError(ERROR_INVALID_HANDLE); + return FALSE; + } + if (pLDC->iType == LDC_EMFLDC) + { + return EMFDRV_PolyPolygon( hDC, Point, Count, Polys ); + } + return FALSE; + } } - } #endif - return NtGdiPolyPolyDraw( hDC , (PPOINT)Point, (PULONG)Count, Polys, GdiPolyPolygon ); + return NtGdiPolyPolyDraw( hDC , (PPOINT)Point, (PULONG)Count, Polys, GdiPolyPolygon ); } @@ -632,27 +632,27 @@ PolyPolyline(HDC hDC, const POINT* Point, const DWORD* Counts, DWORD Polys) { #if 0 // Handle something other than a normal dc object. - if (GDI_HANDLE_GET_TYPE(hDC) != GDI_OBJECT_TYPE_DC) - { - if (GDI_HANDLE_GET_TYPE(hDC) == GDI_OBJECT_TYPE_METADC) - return FALSE; - else + if (GDI_HANDLE_GET_TYPE(hDC) != GDI_OBJECT_TYPE_DC) { - PLDC pLDC = GdiGetLDC(hDC); - if ( !pLDC ) - { - SetLastError(ERROR_INVALID_HANDLE); - return FALSE; - } - if (pLDC->iType == LDC_EMFLDC) - { - return EMFDRV_PolyPolyline(hDC, Point, Counts, Polys); - } - return FALSE; + if (GDI_HANDLE_GET_TYPE(hDC) == GDI_OBJECT_TYPE_METADC) + return FALSE; + else + { + PLDC pLDC = GdiGetLDC(hDC); + if ( !pLDC ) + { + SetLastError(ERROR_INVALID_HANDLE); + return FALSE; + } + if (pLDC->iType == LDC_EMFLDC) + { + return EMFDRV_PolyPolyline(hDC, Point, Counts, Polys); + } + return FALSE; + } } - } #endif - return NtGdiPolyPolyDraw( hDC , (PPOINT)Point, (PULONG)Counts, Polys, GdiPolyPolyLine ); + return NtGdiPolyPolyDraw( hDC , (PPOINT)Point, (PULONG)Counts, Polys, GdiPolyPolyLine ); } @@ -662,34 +662,34 @@ PolyPolyline(HDC hDC, const POINT* Point, const DWORD* Counts, DWORD Polys) BOOL WINAPI ExtFloodFill( - HDC hDC, - int nXStart, - int nYStart, - COLORREF crFill, - UINT fuFillType - ) + HDC hDC, + int nXStart, + int nYStart, + COLORREF crFill, + UINT fuFillType +) { #if 0 // Handle something other than a normal dc object. - if (GDI_HANDLE_GET_TYPE(hDC) != GDI_OBJECT_TYPE_DC) - { - if (GDI_HANDLE_GET_TYPE(hDC) == GDI_OBJECT_TYPE_METADC) - return MFDRV_ExtFloodFill( hDC, nXStart, nYStart, crFill, fuFillType ); - else + if (GDI_HANDLE_GET_TYPE(hDC) != GDI_OBJECT_TYPE_DC) { - PLDC pLDC = GdiGetLDC(hDC); - if ( !pLDC ) - { - SetLastError(ERROR_INVALID_HANDLE); - return FALSE; - } - if (pLDC->iType == LDC_EMFLDC) - { - return EMFDRV_ExtFloodFill( hDC, nXStart, nYStart, crFill, fuFillType ); - } - return FALSE; + if (GDI_HANDLE_GET_TYPE(hDC) == GDI_OBJECT_TYPE_METADC) + return MFDRV_ExtFloodFill( hDC, nXStart, nYStart, crFill, fuFillType ); + else + { + PLDC pLDC = GdiGetLDC(hDC); + if ( !pLDC ) + { + SetLastError(ERROR_INVALID_HANDLE); + return FALSE; + } + if (pLDC->iType == LDC_EMFLDC) + { + return EMFDRV_ExtFloodFill( hDC, nXStart, nYStart, crFill, fuFillType ); + } + return FALSE; + } } - } #endif return NtGdiExtFloodFill(hDC, nXStart, nYStart, crFill, fuFillType); } @@ -715,32 +715,32 @@ FloodFill( */ BOOL WINAPI MaskBlt( - HDC hdcDest, - INT nXDest, - INT nYDest, - INT nWidth, - INT nHeight, - HDC hdcSrc, - INT nXSrc, - INT nYSrc, - HBITMAP hbmMask, - INT xMask, - INT yMask, - DWORD dwRop) + HDC hdcDest, + INT nXDest, + INT nYDest, + INT nWidth, + INT nHeight, + HDC hdcSrc, + INT nXSrc, + INT nYSrc, + HBITMAP hbmMask, + INT xMask, + INT yMask, + DWORD dwRop) { - return NtGdiMaskBlt(hdcDest, - nXDest, - nYDest, - nWidth, - nHeight, - hdcSrc, - nXSrc, - nYSrc, - hbmMask, - xMask, - yMask, - dwRop, - GetBkColor(hdcSrc)); + return NtGdiMaskBlt(hdcDest, + nXDest, + nYDest, + nWidth, + nHeight, + hdcSrc, + nXSrc, + nYSrc, + hbmMask, + xMask, + yMask, + dwRop, + GetBkColor(hdcSrc)); } @@ -750,26 +750,26 @@ MaskBlt( BOOL WINAPI PlgBlt( - HDC hdcDest, - const POINT *lpPoint, - HDC hdcSrc, - INT nXSrc, - INT nYSrc, - INT nWidth, - INT nHeight, - HBITMAP hbmMask, - INT xMask, - INT yMask) + HDC hdcDest, + const POINT *lpPoint, + HDC hdcSrc, + INT nXSrc, + INT nYSrc, + INT nWidth, + INT nHeight, + HBITMAP hbmMask, + INT xMask, + INT yMask) { - return NtGdiPlgBlt(hdcDest, - (LPPOINT)lpPoint, - hdcSrc, - nXSrc, - nYSrc, - nWidth, - nHeight, - hbmMask, - xMask, - yMask, - GetBkColor(hdcSrc)); + return NtGdiPlgBlt(hdcDest, + (LPPOINT)lpPoint, + hdcSrc, + nXSrc, + nYSrc, + nWidth, + nHeight, + hbmMask, + xMask, + yMask, + GetBkColor(hdcSrc)); } diff --git a/reactos/dll/win32/gdi32/objects/palette.c b/reactos/dll/win32/gdi32/objects/palette.c index 4301ac605ea..9c7b471b82c 100644 --- a/reactos/dll/win32/gdi32/objects/palette.c +++ b/reactos/dll/win32/gdi32/objects/palette.c @@ -104,10 +104,10 @@ GetSystemPaletteEntries(HDC hDC, RtlCopyMemory(ippe, sys_pal_template, 10 * sizeof(PALETTEENTRY)); RtlCopyMemory(&ippe[246], &sys_pal_template[10], 10 * sizeof(PALETTEENTRY)); RtlZeroMemory(&ippe[10], sizeof(ippe) - 20 * sizeof(PALETTEENTRY)); - + if (iStartIndex < 256) { - RtlCopyMemory(ppe, + RtlCopyMemory(ppe, &ippe[iStartIndex], min(256 - iStartIndex, cEntries) * sizeof(PALETTEENTRY)); @@ -125,9 +125,9 @@ GetDIBColorTable(HDC hDC, UINT cEntries, RGBQUAD *pColors) { - if (cEntries) - return NtGdiDoPalette(hDC, iStartIndex, cEntries, pColors, GdiPalGetColorTable, FALSE); - return 0; + if (cEntries) + return NtGdiDoPalette(hDC, iStartIndex, cEntries, pColors, GdiPalGetColorTable, FALSE); + return 0; } /* @@ -139,21 +139,21 @@ RealizePalette(HDC hDC) /* [in] Handle of device context */ { #if 0 // Handle something other than a normal dc object. - if (GDI_HANDLE_GET_TYPE(hDC) != GDI_OBJECT_TYPE_DC) - { - if (GDI_HANDLE_GET_TYPE(hDC) == GDI_OBJECT_TYPE_METADC) - return MFDRV_(hDC); - else + if (GDI_HANDLE_GET_TYPE(hDC) != GDI_OBJECT_TYPE_DC) { - HPALETTE Pal = GetDCObject(hDC, GDI_OBJECT_TYPE_PALETTE); - PLDC pLDC = GdiGetLDC((HDC) Pal); - if ( !pLDC ) return FALSE; - if (pLDC->iType == LDC_EMFLDC) return EMFDRV_(Pal); - return FALSE; + if (GDI_HANDLE_GET_TYPE(hDC) == GDI_OBJECT_TYPE_METADC) + return MFDRV_(hDC); + else + { + HPALETTE Pal = GetDCObject(hDC, GDI_OBJECT_TYPE_PALETTE); + PLDC pLDC = GdiGetLDC((HDC) Pal); + if ( !pLDC ) return FALSE; + if (pLDC->iType == LDC_EMFLDC) return EMFDRV_(Pal); + return FALSE; + } } - } #endif - return UserRealizePalette(hDC); + return UserRealizePalette(hDC); } /* @@ -162,11 +162,11 @@ RealizePalette(HDC hDC) /* [in] Handle of device context */ BOOL WINAPI ResizePalette( - HPALETTE hPalette, - UINT nEntries - ) + HPALETTE hPalette, + UINT nEntries +) { - return NtGdiResizePalette(hPalette, nEntries); + return NtGdiResizePalette(hPalette, nEntries); } /* @@ -195,11 +195,11 @@ SetDIBColorTable(HDC hDC, BOOL WINAPI UpdateColors( - HDC hdc - ) + HDC hdc +) { - ((PW32CLIENTINFO)NtCurrentTeb()->Win32ClientInfo)->cSpins = 0; - return NtGdiUpdateColors(hdc); + ((PW32CLIENTINFO)NtCurrentTeb()->Win32ClientInfo)->cSpins = 0; + return NtGdiUpdateColors(hdc); } /* EOF */ diff --git a/reactos/dll/win32/gdi32/objects/path.c b/reactos/dll/win32/gdi32/objects/path.c index e3ea862a3f8..8a35a0e1e9f 100644 --- a/reactos/dll/win32/gdi32/objects/path.c +++ b/reactos/dll/win32/gdi32/objects/path.c @@ -17,10 +17,10 @@ BOOL WINAPI AbortPath( - HDC hdc - ) + HDC hdc +) { - return NtGdiAbortPath( hdc ); + return NtGdiAbortPath( hdc ); } @@ -30,10 +30,10 @@ AbortPath( BOOL WINAPI BeginPath( - HDC hdc - ) + HDC hdc +) { - return NtGdiBeginPath( hdc ); + return NtGdiBeginPath( hdc ); } /* @@ -42,10 +42,10 @@ BeginPath( BOOL WINAPI CloseFigure( - HDC hdc - ) + HDC hdc +) { - return NtGdiCloseFigure ( hdc ); + return NtGdiCloseFigure ( hdc ); } @@ -55,10 +55,10 @@ CloseFigure( BOOL WINAPI EndPath( - HDC hdc - ) + HDC hdc +) { - return NtGdiEndPath( hdc ); + return NtGdiEndPath( hdc ); } @@ -68,10 +68,10 @@ EndPath( BOOL WINAPI FillPath( - HDC hdc - ) + HDC hdc +) { - return NtGdiFillPath( hdc ); + return NtGdiFillPath( hdc ); } @@ -81,10 +81,10 @@ FillPath( BOOL WINAPI FlattenPath( - HDC hdc - ) + HDC hdc +) { - return NtGdiFlattenPath ( hdc ); + return NtGdiFlattenPath ( hdc ); } @@ -119,10 +119,10 @@ GetPath(HDC hdc, HRGN WINAPI PathToRegion( - HDC hdc - ) + HDC hdc +) { - return NtGdiPathToRegion ( hdc ); + return NtGdiPathToRegion ( hdc ); } /* @@ -131,18 +131,18 @@ PathToRegion( BOOL WINAPI SetMiterLimit( - HDC hdc, - FLOAT a1, - PFLOAT a2 - ) + HDC hdc, + FLOAT a1, + PFLOAT a2 +) { - BOOL Ret; - gxf_long worker, worker1; + BOOL Ret; + gxf_long worker, worker1; - worker.f = a1; - Ret = NtGdiSetMiterLimit ( hdc, worker.l, a2 ? &worker1.l : NULL ); - if (a2 && Ret) *a2 = worker1.f; - return Ret; + worker.f = a1; + Ret = NtGdiSetMiterLimit ( hdc, worker.l, a2 ? &worker1.l : NULL ); + if (a2 && Ret) *a2 = worker1.f; + return Ret; } @@ -152,10 +152,10 @@ SetMiterLimit( BOOL WINAPI StrokeAndFillPath( - HDC hdc - ) + HDC hdc +) { - return NtGdiStrokeAndFillPath ( hdc ); + return NtGdiStrokeAndFillPath ( hdc ); } @@ -165,10 +165,10 @@ StrokeAndFillPath( BOOL WINAPI StrokePath( - HDC hdc - ) + HDC hdc +) { - return NtGdiStrokePath ( hdc ); + return NtGdiStrokePath ( hdc ); } @@ -178,10 +178,10 @@ StrokePath( BOOL WINAPI WidenPath( - HDC hdc - ) + HDC hdc +) { - return NtGdiWidenPath ( hdc ); + return NtGdiWidenPath ( hdc ); } /* @@ -190,9 +190,9 @@ WidenPath( BOOL WINAPI SelectClipPath( - HDC hdc, - int Mode - ) + HDC hdc, + int Mode +) { - return NtGdiSelectClipPath ( hdc, Mode ); + return NtGdiSelectClipPath ( hdc, Mode ); } diff --git a/reactos/dll/win32/gdi32/objects/pen.c b/reactos/dll/win32/gdi32/objects/pen.c index 32ed648f0d5..0a431c20049 100644 --- a/reactos/dll/win32/gdi32/objects/pen.c +++ b/reactos/dll/win32/gdi32/objects/pen.c @@ -26,8 +26,8 @@ CreatePen( /* FIXME Some part need be done in user mode */ if (nPenStyle > PS_DASHDOTDOT) { - if (nPenStyle == PS_NULL) return GetStockObject(NULL_PEN); - if (nPenStyle != PS_INSIDEFRAME) nPenStyle = PS_SOLID; + if (nPenStyle == PS_NULL) return GetStockObject(NULL_PEN); + if (nPenStyle != PS_INSIDEFRAME) nPenStyle = PS_SOLID; } return NtGdiCreatePen(nPenStyle, nWidth, crColor, NULL); } diff --git a/reactos/dll/win32/gdi32/objects/printdrv.c b/reactos/dll/win32/gdi32/objects/printdrv.c index 379b85e96bb..3c6d0e89917 100644 --- a/reactos/dll/win32/gdi32/objects/printdrv.c +++ b/reactos/dll/win32/gdi32/objects/printdrv.c @@ -71,68 +71,68 @@ static int FASTCALL IntEndPage( - HDC hdc, - BOOL Form - ) + HDC hdc, + BOOL Form +) { - PLDC pldc; - int Ret = SP_ERROR; - ULONG hType = GDI_HANDLE_GET_TYPE(hdc); + PLDC pldc; + int Ret = SP_ERROR; + ULONG hType = GDI_HANDLE_GET_TYPE(hdc); - if (hType == GDILoObjType_LO_DC_TYPE || hType == GDILoObjType_LO_METADC16_TYPE) - { - SetLastError(ERROR_INVALID_HANDLE); - return SP_ERROR; - } + if (hType == GDILoObjType_LO_DC_TYPE || hType == GDILoObjType_LO_METADC16_TYPE) + { + SetLastError(ERROR_INVALID_HANDLE); + return SP_ERROR; + } - pldc = GdiGetLDC(hdc); - if ( !pldc ) - { - SetLastError(ERROR_INVALID_HANDLE); - return SP_ERROR; - } + pldc = GdiGetLDC(hdc); + if ( !pldc ) + { + SetLastError(ERROR_INVALID_HANDLE); + return SP_ERROR; + } - if (pldc->Flags & LDC_ATENDPAGE) return 1; + if (pldc->Flags & LDC_ATENDPAGE) return 1; - if (pldc->Flags & LDC_META_PRINT) - { - if ( Form ) - { - // Do MF EndPageForm - } - else - { - // Do MF EndPage - } - return Ret; - } + if (pldc->Flags & LDC_META_PRINT) + { + if ( Form ) + { + // Do MF EndPageForm + } + else + { + // Do MF EndPage + } + return Ret; + } - if (pldc->Flags & LDC_KILL_DOCUMENT || pldc->Flags & LDC_INIT_PAGE) - { - SetLastError(ERROR_INVALID_PARAMETER); - return SP_ERROR; - } + if (pldc->Flags & LDC_KILL_DOCUMENT || pldc->Flags & LDC_INIT_PAGE) + { + SetLastError(ERROR_INVALID_PARAMETER); + return SP_ERROR; + } - if (pldc->Flags & LDC_SAPCALLBACK) GdiSAPCallback(pldc); + if (pldc->Flags & LDC_SAPCALLBACK) GdiSAPCallback(pldc); - pldc->Flags &= ~LDC_INIT_PAGE; + pldc->Flags &= ~LDC_INIT_PAGE; - DocumentEventEx(NULL, pldc->hPrinter, hdc, DOCUMENTEVENT_ENDPAGE, 0, NULL, 0, NULL); + DocumentEventEx(NULL, pldc->hPrinter, hdc, DOCUMENTEVENT_ENDPAGE, 0, NULL, 0, NULL); - ((PW32CLIENTINFO)NtCurrentTeb()->Win32ClientInfo)->cSpins = 0; + ((PW32CLIENTINFO)NtCurrentTeb()->Win32ClientInfo)->cSpins = 0; - if ( NtGdiEndPage(hdc) ) - { - BOOL Good; + if ( NtGdiEndPage(hdc) ) + { + BOOL Good; // if (pldc->pUMPDev) - Good = EndPagePrinterEx(NULL,pldc->hPrinter); + Good = EndPagePrinterEx(NULL,pldc->hPrinter); - if (Good) pldc->Flags |= LDC_STARTPAGE; - Ret = 1; - } - else - SetLastError(ERROR_INVALID_PARAMETER); - return Ret; + if (Good) pldc->Flags |= LDC_STARTPAGE; + Ret = 1; + } + else + SetLastError(ERROR_INVALID_PARAMETER); + return Ret; } /* FUNCTIONS *****************************************************************/ @@ -140,9 +140,9 @@ IntEndPage( BOOL FASTCALL AbortPrinterEx( - PVOID pvUMPDev, - HANDLE hPrinter - ) + PVOID pvUMPDev, + HANDLE hPrinter +) { return fpAbortPrinter(hPrinter); } @@ -150,15 +150,15 @@ AbortPrinterEx( int FASTCALL DocumentEventEx( - PVOID pvUMPDev, - HANDLE hPrinter, - HDC hdc, - int iEsc, - ULONG cbIn, - PVOID pvIn, - ULONG cbOut, - PVOID pvOut - ) + PVOID pvUMPDev, + HANDLE hPrinter, + HDC hdc, + int iEsc, + ULONG cbIn, + PVOID pvIn, + ULONG cbOut, + PVOID pvOut +) { return fpDocumentEvent(hPrinter,hdc,iEsc,cbIn,pvIn,cbOut,pvOut); } @@ -166,9 +166,9 @@ DocumentEventEx( BOOL FASTCALL EndDocPrinterEx( - PVOID pvUMPDev, - HANDLE hPrinter - ) + PVOID pvUMPDev, + HANDLE hPrinter +) { return fpEndDocPrinter(hPrinter); } @@ -176,91 +176,91 @@ EndDocPrinterEx( BOOL FASTCALL EndPagePrinterEx( - PVOID pvUMPDev, - HANDLE hPrinter - ) + PVOID pvUMPDev, + HANDLE hPrinter +) { return fpEndPagePrinter(hPrinter); } - + BOOL FASTCALL LoadTheSpoolerDrv(VOID) { - HMODULE hModWinSpoolDrv; + HMODULE hModWinSpoolDrv; - if ( !ghSpooler ) - { - RtlEnterCriticalSection(&semLocal); + if ( !ghSpooler ) + { + RtlEnterCriticalSection(&semLocal); - hModWinSpoolDrv = LoadLibraryW(L"WINSPOOL.DRV"); + hModWinSpoolDrv = LoadLibraryW(L"WINSPOOL.DRV"); - if (hModWinSpoolDrv) - { - fpAbortPrinter = (PVOID)GetProcAddress(hModWinSpoolDrv, "AbortPrinter"); - fpClosePrinter = (PVOID)GetProcAddress(hModWinSpoolDrv, "ClosePrinter"); - fpCloseSpoolFileHandle = (PVOID)GetProcAddress(hModWinSpoolDrv, "CloseSpoolFileHandle"); - fpCommitSpoolData = (PVOID)GetProcAddress(hModWinSpoolDrv, "CommitSpoolData"); - // fpConnectToLd64In32Server = (PVOID)GetProcAddress(hModWinSpoolDrv, (LPCSTR)224); - fpDocumentEvent = (PVOID)GetProcAddress(hModWinSpoolDrv,"DocumentEvent"); - fpDocumentPropertiesW = (PVOID)GetProcAddress(hModWinSpoolDrv, "DocumentPropertiesW"); - fpEndDocPrinter = (PVOID)GetProcAddress(hModWinSpoolDrv, "EndDocPrinter"); - fpEndPagePrinter = (PVOID)GetProcAddress(hModWinSpoolDrv, "EndPagePrinter"); - fpGetPrinterW = (PVOID)GetProcAddress( hModWinSpoolDrv,"GetPrinterW"); - fpGetPrinterDriverW = (PVOID)GetProcAddress(hModWinSpoolDrv,"GetPrinterDriverW"); - fpGetSpoolFileHandle = (PVOID)GetProcAddress(hModWinSpoolDrv, "GetSpoolFileHandle"); - fpIsValidDevmodeW = (PVOID)GetProcAddress(hModWinSpoolDrv, "IsValidDevmodeW"); - fpOpenPrinterW = (PVOID)GetProcAddress(hModWinSpoolDrv, "OpenPrinterW"); - fpQueryColorProfile = (PVOID)GetProcAddress(hModWinSpoolDrv,"QueryColorProfile"); - fpQueryRemoteFonts = (PVOID)GetProcAddress(hModWinSpoolDrv, "QueryRemoteFonts"); - fpQuerySpoolMode = (PVOID)GetProcAddress(hModWinSpoolDrv, "QuerySpoolMode"); - fpReadPrinter = (PVOID)GetProcAddress(hModWinSpoolDrv, "ReadPrinter"); - fpResetPrinterW = (PVOID)GetProcAddress(hModWinSpoolDrv, "ResetPrinterW"); - fpSeekPrinter = (PVOID)GetProcAddress(hModWinSpoolDrv, "SeekPrinter"); - fpSplDriverUnloadComplete = (PVOID)GetProcAddress(hModWinSpoolDrv, "SplDriverUnloadComplete"); - fpSplReadPrinter = (PVOID)GetProcAddress(hModWinSpoolDrv, (LPCSTR)205); - fpStartDocDlgW = (PVOID)GetProcAddress(hModWinSpoolDrv, "StartDocDlgW"); - fpStartDocPrinterW = (PVOID)GetProcAddress(hModWinSpoolDrv, "StartDocPrinterW"); - fpStartPagePrinter = (PVOID)GetProcAddress(hModWinSpoolDrv, "StartPagePrinter"); - - if ( !fpAbortPrinter || - !fpClosePrinter || - !fpCloseSpoolFileHandle || - !fpCommitSpoolData || - !fpDocumentEvent || - !fpDocumentPropertiesW || - !fpEndDocPrinter || - !fpEndPagePrinter || - !fpGetPrinterW || - !fpGetPrinterDriverW || - !fpGetSpoolFileHandle || - !fpIsValidDevmodeW || - !fpOpenPrinterW || - !fpQueryColorProfile || - !fpQueryRemoteFonts || - !fpQuerySpoolMode || - !fpReadPrinter || - !fpResetPrinterW || - !fpSeekPrinter || - !fpSplDriverUnloadComplete || - !fpSplReadPrinter || - !fpStartDocDlgW || - !fpStartDocPrinterW || - !fpStartPagePrinter ) + if (hModWinSpoolDrv) { - FreeLibrary(hModWinSpoolDrv); - hModWinSpoolDrv = NULL; + fpAbortPrinter = (PVOID)GetProcAddress(hModWinSpoolDrv, "AbortPrinter"); + fpClosePrinter = (PVOID)GetProcAddress(hModWinSpoolDrv, "ClosePrinter"); + fpCloseSpoolFileHandle = (PVOID)GetProcAddress(hModWinSpoolDrv, "CloseSpoolFileHandle"); + fpCommitSpoolData = (PVOID)GetProcAddress(hModWinSpoolDrv, "CommitSpoolData"); + // fpConnectToLd64In32Server = (PVOID)GetProcAddress(hModWinSpoolDrv, (LPCSTR)224); + fpDocumentEvent = (PVOID)GetProcAddress(hModWinSpoolDrv,"DocumentEvent"); + fpDocumentPropertiesW = (PVOID)GetProcAddress(hModWinSpoolDrv, "DocumentPropertiesW"); + fpEndDocPrinter = (PVOID)GetProcAddress(hModWinSpoolDrv, "EndDocPrinter"); + fpEndPagePrinter = (PVOID)GetProcAddress(hModWinSpoolDrv, "EndPagePrinter"); + fpGetPrinterW = (PVOID)GetProcAddress( hModWinSpoolDrv,"GetPrinterW"); + fpGetPrinterDriverW = (PVOID)GetProcAddress(hModWinSpoolDrv,"GetPrinterDriverW"); + fpGetSpoolFileHandle = (PVOID)GetProcAddress(hModWinSpoolDrv, "GetSpoolFileHandle"); + fpIsValidDevmodeW = (PVOID)GetProcAddress(hModWinSpoolDrv, "IsValidDevmodeW"); + fpOpenPrinterW = (PVOID)GetProcAddress(hModWinSpoolDrv, "OpenPrinterW"); + fpQueryColorProfile = (PVOID)GetProcAddress(hModWinSpoolDrv,"QueryColorProfile"); + fpQueryRemoteFonts = (PVOID)GetProcAddress(hModWinSpoolDrv, "QueryRemoteFonts"); + fpQuerySpoolMode = (PVOID)GetProcAddress(hModWinSpoolDrv, "QuerySpoolMode"); + fpReadPrinter = (PVOID)GetProcAddress(hModWinSpoolDrv, "ReadPrinter"); + fpResetPrinterW = (PVOID)GetProcAddress(hModWinSpoolDrv, "ResetPrinterW"); + fpSeekPrinter = (PVOID)GetProcAddress(hModWinSpoolDrv, "SeekPrinter"); + fpSplDriverUnloadComplete = (PVOID)GetProcAddress(hModWinSpoolDrv, "SplDriverUnloadComplete"); + fpSplReadPrinter = (PVOID)GetProcAddress(hModWinSpoolDrv, (LPCSTR)205); + fpStartDocDlgW = (PVOID)GetProcAddress(hModWinSpoolDrv, "StartDocDlgW"); + fpStartDocPrinterW = (PVOID)GetProcAddress(hModWinSpoolDrv, "StartDocPrinterW"); + fpStartPagePrinter = (PVOID)GetProcAddress(hModWinSpoolDrv, "StartPagePrinter"); + + if ( !fpAbortPrinter || + !fpClosePrinter || + !fpCloseSpoolFileHandle || + !fpCommitSpoolData || + !fpDocumentEvent || + !fpDocumentPropertiesW || + !fpEndDocPrinter || + !fpEndPagePrinter || + !fpGetPrinterW || + !fpGetPrinterDriverW || + !fpGetSpoolFileHandle || + !fpIsValidDevmodeW || + !fpOpenPrinterW || + !fpQueryColorProfile || + !fpQueryRemoteFonts || + !fpQuerySpoolMode || + !fpReadPrinter || + !fpResetPrinterW || + !fpSeekPrinter || + !fpSplDriverUnloadComplete || + !fpSplReadPrinter || + !fpStartDocDlgW || + !fpStartDocPrinterW || + !fpStartPagePrinter ) + { + FreeLibrary(hModWinSpoolDrv); + hModWinSpoolDrv = NULL; + } + ghSpooler = hModWinSpoolDrv; } - ghSpooler = hModWinSpoolDrv; - } - RtlLeaveCriticalSection(&semLocal); - } - else - return TRUE; + RtlLeaveCriticalSection(&semLocal); + } + else + return TRUE; - if ( !ghSpooler ) SetLastError(ERROR_NOT_ENOUGH_MEMORY); + if ( !ghSpooler ) SetLastError(ERROR_NOT_ENOUGH_MEMORY); - return (ghSpooler != NULL); + return (ghSpooler != NULL); } /* @@ -274,16 +274,16 @@ LoadTheSpoolerDrv(VOID) 4. To end each page, call EndPagePrinter. 5. Repeat 2, 3, and 4 for as many pages as necessary. 6. To end the print job, call EndDocPrinter. - + */ DWORD FASTCALL StartDocPrinterWEx( - PVOID pvUMPDev, - HANDLE hPrinter, - DWORD Level, - LPBYTE pDocInfo - ) + PVOID pvUMPDev, + HANDLE hPrinter, + DWORD Level, + LPBYTE pDocInfo +) { return fpStartDocPrinterW(hPrinter,Level,pDocInfo); } @@ -291,9 +291,9 @@ StartDocPrinterWEx( BOOL FASTCALL StartPagePrinterEx( - PVOID pvUMPDev, - HANDLE hPrinter - ) + PVOID pvUMPDev, + HANDLE hPrinter +) { return fpStartPagePrinter(hPrinter); } @@ -306,49 +306,49 @@ StartPagePrinterEx( int WINAPI AbortDoc( - HDC hdc - ) + HDC hdc +) { - PLDC pldc; - int Ret = SP_ERROR; - ULONG hType = GDI_HANDLE_GET_TYPE(hdc); + PLDC pldc; + int Ret = SP_ERROR; + ULONG hType = GDI_HANDLE_GET_TYPE(hdc); - if (hType == GDILoObjType_LO_DC_TYPE || hType == GDILoObjType_LO_METADC16_TYPE) - { - SetLastError(ERROR_INVALID_HANDLE); - return SP_ERROR; - } + if (hType == GDILoObjType_LO_DC_TYPE || hType == GDILoObjType_LO_METADC16_TYPE) + { + SetLastError(ERROR_INVALID_HANDLE); + return SP_ERROR; + } - pldc = GdiGetLDC(hdc); - if ( !pldc ) - { - SetLastError(ERROR_INVALID_HANDLE); - return SP_ERROR; - } + pldc = GdiGetLDC(hdc); + if ( !pldc ) + { + SetLastError(ERROR_INVALID_HANDLE); + return SP_ERROR; + } - if ( !(pldc->Flags & LDC_INIT_DOCUMENT) ) return 1; + if ( !(pldc->Flags & LDC_INIT_DOCUMENT) ) return 1; - DocumentEventEx(NULL, pldc->hPrinter, hdc, DOCUMENTEVENT_ABORTDOC, 0, NULL, 0, NULL); - - ((PW32CLIENTINFO)NtCurrentTeb()->Win32ClientInfo)->cSpins = 0; + DocumentEventEx(NULL, pldc->hPrinter, hdc, DOCUMENTEVENT_ABORTDOC, 0, NULL, 0, NULL); - if ( pldc->Flags & LDC_META_PRINT) - { - UNIMPLEMENTED; - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return Ret; - } + ((PW32CLIENTINFO)NtCurrentTeb()->Win32ClientInfo)->cSpins = 0; - if (NtGdiAbortDoc(hdc)) - { - if (fpAbortPrinter(pldc->hPrinter)) Ret = 1; - } - else - Ret = SP_ERROR; + if ( pldc->Flags & LDC_META_PRINT) + { + UNIMPLEMENTED; + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return Ret; + } - pldc->Flags &= ~(LDC_ATENDPAGE|LDC_META_PRINT|LDC_STARTPAGE|LDC_INIT_PAGE|LDC_INIT_DOCUMENT|LDC_SAPCALLBACK); + if (NtGdiAbortDoc(hdc)) + { + if (fpAbortPrinter(pldc->hPrinter)) Ret = 1; + } + else + Ret = SP_ERROR; - return Ret; + pldc->Flags &= ~(LDC_ATENDPAGE|LDC_META_PRINT|LDC_STARTPAGE|LDC_INIT_PAGE|LDC_INIT_DOCUMENT|LDC_SAPCALLBACK); + + return Ret; } /* @@ -357,55 +357,55 @@ AbortDoc( int WINAPI EndDoc( - HDC hdc - ) + HDC hdc +) { - PLDC pldc; - int Ret = SP_ERROR; - ULONG hType = GDI_HANDLE_GET_TYPE(hdc); + PLDC pldc; + int Ret = SP_ERROR; + ULONG hType = GDI_HANDLE_GET_TYPE(hdc); - if (hType == GDILoObjType_LO_DC_TYPE || hType == GDILoObjType_LO_METADC16_TYPE) - { - SetLastError(ERROR_INVALID_HANDLE); - return SP_ERROR; - } + if (hType == GDILoObjType_LO_DC_TYPE || hType == GDILoObjType_LO_METADC16_TYPE) + { + SetLastError(ERROR_INVALID_HANDLE); + return SP_ERROR; + } - pldc = GdiGetLDC(hdc); - if ( !pldc ) - { - SetLastError(ERROR_INVALID_HANDLE); - return SP_ERROR; - } + pldc = GdiGetLDC(hdc); + if ( !pldc ) + { + SetLastError(ERROR_INVALID_HANDLE); + return SP_ERROR; + } - if (pldc->Flags & LDC_META_PRINT) - { - UNIMPLEMENTED; - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return Ret; - } + if (pldc->Flags & LDC_META_PRINT) + { + UNIMPLEMENTED; + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return Ret; + } - if (pldc->Flags & LDC_INIT_DOCUMENT) - { - BOOL Good; - if (pldc->Flags & LDC_INIT_PAGE) EndPage(hdc); + if (pldc->Flags & LDC_INIT_DOCUMENT) + { + BOOL Good; + if (pldc->Flags & LDC_INIT_PAGE) EndPage(hdc); - DocumentEventEx(NULL, pldc->hPrinter, hdc, DOCUMENTEVENT_ENDDOC, 0, NULL, 0, NULL); - - ((PW32CLIENTINFO)NtCurrentTeb()->Win32ClientInfo)->cSpins = 0; + DocumentEventEx(NULL, pldc->hPrinter, hdc, DOCUMENTEVENT_ENDDOC, 0, NULL, 0, NULL); - Good = NtGdiEndDoc(hdc); + ((PW32CLIENTINFO)NtCurrentTeb()->Win32ClientInfo)->cSpins = 0; + + Good = NtGdiEndDoc(hdc); // if (pldc->pUMPDev) - Good = EndDocPrinterEx(NULL,pldc->hPrinter); + Good = EndDocPrinterEx(NULL,pldc->hPrinter); - if (Good) - { - DocumentEventEx(NULL, pldc->hPrinter, hdc, DOCUMENTEVENT_ENDDOCPOST, 0, NULL, 0, NULL); - Ret = 1; - } - pldc->Flags &= ~(LDC_ATENDPAGE|LDC_STARTPAGE|LDC_INIT_DOCUMENT|LDC_SAPCALLBACK); - } - return Ret; + if (Good) + { + DocumentEventEx(NULL, pldc->hPrinter, hdc, DOCUMENTEVENT_ENDDOCPOST, 0, NULL, 0, NULL); + Ret = 1; + } + pldc->Flags &= ~(LDC_ATENDPAGE|LDC_STARTPAGE|LDC_INIT_DOCUMENT|LDC_SAPCALLBACK); + } + return Ret; } /* @@ -415,7 +415,7 @@ int WINAPI EndFormPage(HDC hdc) { - return IntEndPage(hdc,TRUE); + return IntEndPage(hdc,TRUE); } /* @@ -425,7 +425,7 @@ int WINAPI EndPage(HDC hdc ) { - return IntEndPage(hdc,FALSE); + return IntEndPage(hdc,FALSE); } /* @@ -472,121 +472,121 @@ GdiGetPageCount(HANDLE SpoolFileHandle) int WINAPI StartDocW( - HDC hdc, - CONST DOCINFOW *lpdi - ) + HDC hdc, + CONST DOCINFOW *lpdi +) { - PLDC pldc; - DOCINFOW diW; - DOC_INFO_1W di1W; - LPWSTR lpwstrRet = NULL; - BOOL Banding; - int PrnJobNo, Ret = SP_ERROR; - ULONG hType = GDI_HANDLE_GET_TYPE(hdc); + PLDC pldc; + DOCINFOW diW; + DOC_INFO_1W di1W; + LPWSTR lpwstrRet = NULL; + BOOL Banding; + int PrnJobNo, Ret = SP_ERROR; + ULONG hType = GDI_HANDLE_GET_TYPE(hdc); - if (hType == GDILoObjType_LO_DC_TYPE || hType == GDILoObjType_LO_METADC16_TYPE) - return SP_ERROR; + if (hType == GDILoObjType_LO_DC_TYPE || hType == GDILoObjType_LO_METADC16_TYPE) + return SP_ERROR; - pldc = GdiGetLDC(hdc); - if ( !pldc || pldc->Flags & LDC_ATENDPAGE) - { - SetLastError(ERROR_INVALID_HANDLE); - return SP_ERROR; - } + pldc = GdiGetLDC(hdc); + if ( !pldc || pldc->Flags & LDC_ATENDPAGE) + { + SetLastError(ERROR_INVALID_HANDLE); + return SP_ERROR; + } - if (!pldc->hPrinter) return SP_ERROR; + if (!pldc->hPrinter) return SP_ERROR; - pldc->Flags &= ~LDC_KILL_DOCUMENT; + pldc->Flags &= ~LDC_KILL_DOCUMENT; - if (lpdi) - RtlCopyMemory(&diW, lpdi, sizeof(DOCINFOW)); - else - { - diW.cbSize = sizeof(DOCINFOW); - diW.lpszDocName = NULL; - diW.lpszOutput = NULL; - diW.lpszDatatype = NULL; - diW.fwType = 0; - } + if (lpdi) + RtlCopyMemory(&diW, lpdi, sizeof(DOCINFOW)); + else + { + diW.cbSize = sizeof(DOCINFOW); + diW.lpszDocName = NULL; + diW.lpszOutput = NULL; + diW.lpszDatatype = NULL; + diW.fwType = 0; + } - if (!diW.lpszOutput) - if (pldc->pwszPort) diW.lpszOutput = pldc->pwszPort; + if (!diW.lpszOutput) + if (pldc->pwszPort) diW.lpszOutput = pldc->pwszPort; - lpwstrRet = fpStartDocDlgW(pldc->hPrinter, &diW); - if (lpwstrRet == (LPWSTR)SP_APPABORT) - { - pldc->Flags |= LDC_KILL_DOCUMENT; - return SP_ERROR; - } - if (lpwstrRet == (LPWSTR)SP_ERROR) return SP_ERROR; + lpwstrRet = fpStartDocDlgW(pldc->hPrinter, &diW); + if (lpwstrRet == (LPWSTR)SP_APPABORT) + { + pldc->Flags |= LDC_KILL_DOCUMENT; + return SP_ERROR; + } + if (lpwstrRet == (LPWSTR)SP_ERROR) return SP_ERROR; - if (lpwstrRet != 0) diW.lpszOutput = lpwstrRet; + if (lpwstrRet != 0) diW.lpszOutput = lpwstrRet; - Ret = DocumentEventEx( NULL, - pldc->hPrinter, - hdc, - DOCUMENTEVENT_STARTDOC, - sizeof(ULONG), - &diW, - 0, - NULL); + Ret = DocumentEventEx( NULL, + pldc->hPrinter, + hdc, + DOCUMENTEVENT_STARTDOC, + sizeof(ULONG), + &diW, + 0, + NULL); - if (Ret == SP_APPABORT) - { - pldc->Flags |= LDC_KILL_DOCUMENT; - Ret = SP_ERROR; - } - if (Ret == SP_ERROR) - { - if (lpwstrRet) LocalFree(lpwstrRet); - return Ret; - } + if (Ret == SP_APPABORT) + { + pldc->Flags |= LDC_KILL_DOCUMENT; + Ret = SP_ERROR; + } + if (Ret == SP_ERROR) + { + if (lpwstrRet) LocalFree(lpwstrRet); + return Ret; + } - di1W.pDocName = (LPWSTR)diW.lpszDocName; - di1W.pOutputFile = (LPWSTR)diW.lpszOutput; - di1W.pDatatype = (LPWSTR)diW.lpszDatatype; + di1W.pDocName = (LPWSTR)diW.lpszDocName; + di1W.pOutputFile = (LPWSTR)diW.lpszOutput; + di1W.pDatatype = (LPWSTR)diW.lpszDatatype; - Ret = SP_ERROR; + Ret = SP_ERROR; - PrnJobNo = StartDocPrinterWEx(NULL, pldc->hPrinter, 1, (LPBYTE)&di1W); - if (PrnJobNo <= 0) - { - Ret = NtGdiStartDoc( hdc, &diW, &Banding, PrnJobNo); - if (Ret) - { - if (pldc->pAbortProc) - { - GdiSAPCallback(pldc); - pldc->Flags |= LDC_SAPCALLBACK; - pldc->CallBackTick = GetTickCount(); - } - pldc->Flags |= LDC_INIT_DOCUMENT; - if (!Banding) pldc->Flags |= LDC_STARTPAGE; - } - } - if (Ret == SP_ERROR) - { - //if ( pldc->pUMPDev ) - AbortPrinterEx(NULL, pldc->hPrinter); - DPRINT1("StartDoc Died!!!\n"); - } - else - { - if ( DocumentEventEx( NULL, - pldc->hPrinter, - hdc, - DOCUMENTEVENT_STARTDOCPOST, - sizeof(ULONG), - &Ret, - 0, - NULL) == SP_ERROR) - { - AbortDoc(hdc); - Ret = SP_ERROR; - } - } - if (lpwstrRet) LocalFree(lpwstrRet); - return Ret; + PrnJobNo = StartDocPrinterWEx(NULL, pldc->hPrinter, 1, (LPBYTE)&di1W); + if (PrnJobNo <= 0) + { + Ret = NtGdiStartDoc( hdc, &diW, &Banding, PrnJobNo); + if (Ret) + { + if (pldc->pAbortProc) + { + GdiSAPCallback(pldc); + pldc->Flags |= LDC_SAPCALLBACK; + pldc->CallBackTick = GetTickCount(); + } + pldc->Flags |= LDC_INIT_DOCUMENT; + if (!Banding) pldc->Flags |= LDC_STARTPAGE; + } + } + if (Ret == SP_ERROR) + { + //if ( pldc->pUMPDev ) + AbortPrinterEx(NULL, pldc->hPrinter); + DPRINT1("StartDoc Died!!!\n"); + } + else + { + if ( DocumentEventEx( NULL, + pldc->hPrinter, + hdc, + DOCUMENTEVENT_STARTDOCPOST, + sizeof(ULONG), + &Ret, + 0, + NULL) == SP_ERROR) + { + AbortDoc(hdc); + Ret = SP_ERROR; + } + } + if (lpwstrRet) LocalFree(lpwstrRet); + return Ret; } /* @@ -595,9 +595,9 @@ StartDocW( int WINAPI StartDocA( - HDC hdc, - CONST DOCINFOA *lpdi - ) + HDC hdc, + CONST DOCINFOA *lpdi +) { LPWSTR szDocName = NULL, szOutput = NULL, szDatatype = NULL; DOCINFOW docW; @@ -643,52 +643,52 @@ StartDocA( int WINAPI StartPage( - HDC hdc - ) + HDC hdc +) { - PLDC pldc; - ULONG hType = GDI_HANDLE_GET_TYPE(hdc); + PLDC pldc; + ULONG hType = GDI_HANDLE_GET_TYPE(hdc); - if (hType == GDILoObjType_LO_DC_TYPE || hType == GDILoObjType_LO_METADC16_TYPE) - { - SetLastError(ERROR_INVALID_HANDLE); - return SP_ERROR; - } + if (hType == GDILoObjType_LO_DC_TYPE || hType == GDILoObjType_LO_METADC16_TYPE) + { + SetLastError(ERROR_INVALID_HANDLE); + return SP_ERROR; + } - pldc = GdiGetLDC(hdc); - if ( !pldc ) - { - SetLastError(ERROR_INVALID_HANDLE); - return SP_ERROR; - } + pldc = GdiGetLDC(hdc); + if ( !pldc ) + { + SetLastError(ERROR_INVALID_HANDLE); + return SP_ERROR; + } - if (pldc->Flags & LDC_META_PRINT) - { - UNIMPLEMENTED; - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return SP_ERROR; - } + if (pldc->Flags & LDC_META_PRINT) + { + UNIMPLEMENTED; + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return SP_ERROR; + } - pldc->Flags &= ~(LDC_ATENDPAGE|LDC_STARTPAGE); + pldc->Flags &= ~(LDC_ATENDPAGE|LDC_STARTPAGE); - if (pldc->Flags & LDC_INIT_PAGE) return 1; + if (pldc->Flags & LDC_INIT_PAGE) return 1; - if (DocumentEventEx(NULL, pldc->hPrinter, hdc, DOCUMENTEVENT_STARTPAGE, 0, NULL, 0, NULL) != SP_ERROR) - { - pldc->Flags |= LDC_INIT_PAGE; + if (DocumentEventEx(NULL, pldc->hPrinter, hdc, DOCUMENTEVENT_STARTPAGE, 0, NULL, 0, NULL) != SP_ERROR) + { + pldc->Flags |= LDC_INIT_PAGE; - ((PW32CLIENTINFO)NtCurrentTeb()->Win32ClientInfo)->cSpins = 0; + ((PW32CLIENTINFO)NtCurrentTeb()->Win32ClientInfo)->cSpins = 0; - if (StartPagePrinterEx(NULL, pldc->hPrinter)) - { - if (NtGdiStartPage(hdc)) return 1; - } + if (StartPagePrinterEx(NULL, pldc->hPrinter)) + { + if (NtGdiStartPage(hdc)) return 1; + } - pldc->Flags &= ~(LDC_INIT_PAGE); - EndDoc(hdc); - SetLastError(ERROR_INVALID_HANDLE); - } - return SP_ERROR; + pldc->Flags &= ~(LDC_INIT_PAGE); + EndDoc(hdc); + SetLastError(ERROR_INVALID_HANDLE); + } + return SP_ERROR; } /* @@ -697,37 +697,37 @@ StartPage( int WINAPI SetAbortProc( - HDC hdc, - ABORTPROC lpAbortProc) + HDC hdc, + ABORTPROC lpAbortProc) { - PLDC pldc; - ULONG hType = GDI_HANDLE_GET_TYPE(hdc); + PLDC pldc; + ULONG hType = GDI_HANDLE_GET_TYPE(hdc); - if (hType == GDILoObjType_LO_DC_TYPE || hType == GDILoObjType_LO_METADC16_TYPE) - return SP_ERROR; + if (hType == GDILoObjType_LO_DC_TYPE || hType == GDILoObjType_LO_METADC16_TYPE) + return SP_ERROR; - pldc = GdiGetLDC(hdc); - if ( pldc ) - { - if ( lpAbortProc ) - { - if ( pldc->Flags & LDC_INIT_DOCUMENT ) - { - pldc->Flags |= LDC_SAPCALLBACK; - pldc->CallBackTick = GetTickCount(); - } - } - else - { - pldc->Flags &= ~LDC_SAPCALLBACK; - } - pldc->pAbortProc = lpAbortProc; - return 1; - } - else - { - SetLastError(ERROR_INVALID_HANDLE); - } - return SP_ERROR; + pldc = GdiGetLDC(hdc); + if ( pldc ) + { + if ( lpAbortProc ) + { + if ( pldc->Flags & LDC_INIT_DOCUMENT ) + { + pldc->Flags |= LDC_SAPCALLBACK; + pldc->CallBackTick = GetTickCount(); + } + } + else + { + pldc->Flags &= ~LDC_SAPCALLBACK; + } + pldc->pAbortProc = lpAbortProc; + return 1; + } + else + { + SetLastError(ERROR_INVALID_HANDLE); + } + return SP_ERROR; } diff --git a/reactos/dll/win32/gdi32/objects/region.c b/reactos/dll/win32/gdi32/objects/region.c index eb6395363e4..54140ed071d 100644 --- a/reactos/dll/win32/gdi32/objects/region.c +++ b/reactos/dll/win32/gdi32/objects/region.c @@ -26,38 +26,38 @@ INT FASTCALL ComplexityFromRects( PRECTL prc1, PRECTL prc2) { - if ( prc2->left >= prc1->left ) - { - if ( ( prc1->right >= prc2->right) && - ( prc1->top <= prc2->top ) && - ( prc1->bottom >= prc2->bottom ) ) - return SAME_RGN; + if ( prc2->left >= prc1->left ) + { + if ( ( prc1->right >= prc2->right) && + ( prc1->top <= prc2->top ) && + ( prc1->bottom >= prc2->bottom ) ) + return SAME_RGN; - if ( prc2->left > prc1->left ) - { + if ( prc2->left > prc1->left ) + { + if ( ( prc1->left >= prc2->right ) || + ( prc1->right <= prc2->left ) || + ( prc1->top >= prc2->bottom ) || + ( prc1->bottom <= prc2->top ) ) + return DIFF_RGN; + } + } + + if ( ( prc2->right < prc1->right ) || + ( prc2->top > prc1->top ) || + ( prc2->bottom < prc1->bottom ) ) + { if ( ( prc1->left >= prc2->right ) || - ( prc1->right <= prc2->left ) || - ( prc1->top >= prc2->bottom ) || - ( prc1->bottom <= prc2->top ) ) - return DIFF_RGN; - } - } - - if ( ( prc2->right < prc1->right ) || - ( prc2->top > prc1->top ) || - ( prc2->bottom < prc1->bottom ) ) - { - if ( ( prc1->left >= prc2->right ) || - ( prc1->right <= prc2->left ) || - ( prc1->top >= prc2->bottom ) || - ( prc1->bottom <= prc2->top ) ) - return DIFF_RGN; - } - else - { - return INVERTED_RGN; - } - return OVERLAPPING_RGN; + ( prc1->right <= prc2->left ) || + ( prc1->top >= prc2->bottom ) || + ( prc1->bottom <= prc2->top ) ) + return DIFF_RGN; + } + else + { + return INVERTED_RGN; + } + return OVERLAPPING_RGN; } static @@ -65,36 +65,38 @@ VOID FASTCALL SortRects(PRECT pRect, INT nCount) { - INT i = 0, a = 0, b = 0, c, s; - RECT sRect; + INT i = 0, a = 0, b = 0, c, s; + RECT sRect; - if (nCount > 0) - { - i = 1; // set index point - c = nCount; // set inverse count - do - { - s = i; // set sort count - if ( i < nCount ) + if (nCount > 0) + { + i = 1; // set index point + c = nCount; // set inverse count + do { - a = i - 1; - b = i; - do - { - if(pRect[b].top != pRect[i].bottom) break; - if(pRect[b].left < pRect[a].left) - { - sRect = pRect[a]; - pRect[a] = pRect[b]; - pRect[b] = sRect; - } - ++s; - ++b; - } while ( s < nCount ); + s = i; // set sort count + if ( i < nCount ) + { + a = i - 1; + b = i; + do + { + if(pRect[b].top != pRect[i].bottom) break; + if(pRect[b].left < pRect[a].left) + { + sRect = pRect[a]; + pRect[a] = pRect[b]; + pRect[b] = sRect; + } + ++s; + ++b; + } + while ( s < nCount ); + } + ++i; } - ++i; - } while ( c-- != 1 ); - } + while ( c-- != 1 ); + } } /* @@ -105,82 +107,82 @@ FASTCALL DeleteRegion( HRGN hRgn ) { #if 0 - PRGN_ATTR Rgn_Attr; + PRGN_ATTR Rgn_Attr; - if ((GdiGetHandleUserData((HGDIOBJ) hRgn, GDI_OBJECT_TYPE_REGION, (PVOID) &Rgn_Attr)) && - ( Rgn_Attr != NULL )) - { - PGDIBSOBJECT pgO; - - pgO = GdiAllocBatchCommand(NULL, GdiBCDelRgn); - if (pgO) - { - pgO->hgdiobj = (HGDIOBJ)hRgn; - return TRUE; - } - } + if ((GdiGetHandleUserData((HGDIOBJ) hRgn, GDI_OBJECT_TYPE_REGION, (PVOID) &Rgn_Attr)) && + ( Rgn_Attr != NULL )) + { + PGDIBSOBJECT pgO; + + pgO = GdiAllocBatchCommand(NULL, GdiBCDelRgn); + if (pgO) + { + pgO->hgdiobj = (HGDIOBJ)hRgn; + return TRUE; + } + } #endif - return NtGdiDeleteObjectApp((HGDIOBJ) hRgn); + return NtGdiDeleteObjectApp((HGDIOBJ) hRgn); } INT FASTCALL MirrorRgnByWidth(HRGN hRgn, INT Width, HRGN *phRgn) { - INT cRgnDSize, Ret = 0; - PRGNDATA pRgnData; - - cRgnDSize = NtGdiGetRegionData(hRgn, 0, NULL); + INT cRgnDSize, Ret = 0; + PRGNDATA pRgnData; - if (cRgnDSize) - { - pRgnData = LocalAlloc(LMEM_FIXED, cRgnDSize * sizeof(LONG)); - if (pRgnData) - { - if ( GetRegionData(hRgn, cRgnDSize, pRgnData) ) + cRgnDSize = NtGdiGetRegionData(hRgn, 0, NULL); + + if (cRgnDSize) + { + pRgnData = LocalAlloc(LMEM_FIXED, cRgnDSize * sizeof(LONG)); + if (pRgnData) { - HRGN hRgnex; - UINT i; - INT SaveL = pRgnData->rdh.rcBound.left; - pRgnData->rdh.rcBound.left = Width - pRgnData->rdh.rcBound.right; - pRgnData->rdh.rcBound.right = Width - SaveL; - if (pRgnData->rdh.nCount > 0) - { - PRECT pRect = (PRECT)&pRgnData->Buffer; - for (i = 0; i < pRgnData->rdh.nCount; i++) - { - SaveL = pRect[i].left; - pRect[i].left = Width - pRect[i].right; - pRect[i].right = Width - SaveL; - } - } - SortRects((PRECT)&pRgnData->Buffer, pRgnData->rdh.nCount); - hRgnex = ExtCreateRegion(NULL, cRgnDSize , pRgnData); - if (hRgnex) - { - if (phRgn) phRgn = (HRGN *)hRgnex; - else - { - CombineRgn(hRgn, hRgnex, 0, RGN_COPY); - DeleteObject(hRgnex); - } - Ret = 1; - } + if ( GetRegionData(hRgn, cRgnDSize, pRgnData) ) + { + HRGN hRgnex; + UINT i; + INT SaveL = pRgnData->rdh.rcBound.left; + pRgnData->rdh.rcBound.left = Width - pRgnData->rdh.rcBound.right; + pRgnData->rdh.rcBound.right = Width - SaveL; + if (pRgnData->rdh.nCount > 0) + { + PRECT pRect = (PRECT)&pRgnData->Buffer; + for (i = 0; i < pRgnData->rdh.nCount; i++) + { + SaveL = pRect[i].left; + pRect[i].left = Width - pRect[i].right; + pRect[i].right = Width - SaveL; + } + } + SortRects((PRECT)&pRgnData->Buffer, pRgnData->rdh.nCount); + hRgnex = ExtCreateRegion(NULL, cRgnDSize , pRgnData); + if (hRgnex) + { + if (phRgn) phRgn = (HRGN *)hRgnex; + else + { + CombineRgn(hRgn, hRgnex, 0, RGN_COPY); + DeleteObject(hRgnex); + } + Ret = 1; + } + } + LocalFree(pRgnData); } - LocalFree(pRgnData); - } - } - return Ret; + } + return Ret; } INT WINAPI MirrorRgnDC(HDC hdc, HRGN hRgn, HRGN *phRgn) { - if (!GdiIsHandleValid((HGDIOBJ) hdc) || - (GDI_HANDLE_GET_TYPE(hdc) != GDI_OBJECT_TYPE_DC)) return 0; + if (!GdiIsHandleValid((HGDIOBJ) hdc) || + (GDI_HANDLE_GET_TYPE(hdc) != GDI_OBJECT_TYPE_DC)) return 0; - return MirrorRgnByWidth(hRgn, NtGdiGetDeviceWidth(hdc), phRgn); + return MirrorRgnByWidth(hRgn, NtGdiGetDeviceWidth(hdc), phRgn); } /* FUNCTIONS *****************************************************************/ @@ -195,202 +197,204 @@ CombineRgn(HRGN hDest, HRGN hSrc2, INT CombineMode) { - PRGN_ATTR pRgn_Attr_Dest = NULL; - PRGN_ATTR pRgn_Attr_Src1 = NULL; - PRGN_ATTR pRgn_Attr_Src2 = NULL; - INT Complexity; - BOOL Ret; + PRGN_ATTR pRgn_Attr_Dest = NULL; + PRGN_ATTR pRgn_Attr_Src1 = NULL; + PRGN_ATTR pRgn_Attr_Src2 = NULL; + INT Complexity; + BOOL Ret; // HACK -return NtGdiCombineRgn(hDest, hSrc1, hSrc2, CombineMode); + return NtGdiCombineRgn(hDest, hSrc1, hSrc2, CombineMode); - Ret = GdiGetHandleUserData((HGDIOBJ) hDest, GDI_OBJECT_TYPE_REGION, (PVOID) &pRgn_Attr_Dest); - Ret = GdiGetHandleUserData((HGDIOBJ) hSrc1, GDI_OBJECT_TYPE_REGION, (PVOID) &pRgn_Attr_Src1); + Ret = GdiGetHandleUserData((HGDIOBJ) hDest, GDI_OBJECT_TYPE_REGION, (PVOID) &pRgn_Attr_Dest); + Ret = GdiGetHandleUserData((HGDIOBJ) hSrc1, GDI_OBJECT_TYPE_REGION, (PVOID) &pRgn_Attr_Src1); - if ( !Ret || - !pRgn_Attr_Dest || - !pRgn_Attr_Src1 || - pRgn_Attr_Src1->Flags > SIMPLEREGION ) - return NtGdiCombineRgn(hDest, hSrc1, hSrc2, CombineMode); + if ( !Ret || + !pRgn_Attr_Dest || + !pRgn_Attr_Src1 || + pRgn_Attr_Src1->Flags > SIMPLEREGION ) + return NtGdiCombineRgn(hDest, hSrc1, hSrc2, CombineMode); - /* Handle COPY and use only src1. */ - if ( CombineMode == RGN_COPY ) - { - switch (pRgn_Attr_Src1->Flags) - { + /* Handle COPY and use only src1. */ + if ( CombineMode == RGN_COPY ) + { + switch (pRgn_Attr_Src1->Flags) + { case NULLREGION: - Ret = SetRectRgn( hDest, 0, 0, 0, 0); - if (Ret) + Ret = SetRectRgn( hDest, 0, 0, 0, 0); + if (Ret) return NULLREGION; - goto ERROR_Exit; + goto ERROR_Exit; case SIMPLEREGION: - Ret = SetRectRgn( hDest, - pRgn_Attr_Src1->Rect.left, - pRgn_Attr_Src1->Rect.top, - pRgn_Attr_Src1->Rect.right, - pRgn_Attr_Src1->Rect.bottom ); - if (Ret) + Ret = SetRectRgn( hDest, + pRgn_Attr_Src1->Rect.left, + pRgn_Attr_Src1->Rect.top, + pRgn_Attr_Src1->Rect.right, + pRgn_Attr_Src1->Rect.bottom ); + if (Ret) return SIMPLEREGION; - goto ERROR_Exit; + goto ERROR_Exit; case COMPLEXREGION: default: return NtGdiCombineRgn(hDest, hSrc1, hSrc2, CombineMode); - } - } + } + } - Ret = GdiGetHandleUserData((HGDIOBJ) hSrc2, GDI_OBJECT_TYPE_REGION, (PVOID) &pRgn_Attr_Src2); - if ( !Ret || - !pRgn_Attr_Src2 || - pRgn_Attr_Src2->Flags > SIMPLEREGION ) - return NtGdiCombineRgn(hDest, hSrc1, hSrc2, CombineMode); - - /* All but AND. */ - if ( CombineMode != RGN_AND) - { - if ( CombineMode <= RGN_AND) - { - /* - There might be some type of junk in the call, so go K. - If this becomes a problem, need to setup parameter check at the top. - */ - DPRINT1("Might be junk! CombineMode %d\n",CombineMode); + Ret = GdiGetHandleUserData((HGDIOBJ) hSrc2, GDI_OBJECT_TYPE_REGION, (PVOID) &pRgn_Attr_Src2); + if ( !Ret || + !pRgn_Attr_Src2 || + pRgn_Attr_Src2->Flags > SIMPLEREGION ) return NtGdiCombineRgn(hDest, hSrc1, hSrc2, CombineMode); - } - if ( CombineMode > RGN_XOR) /* Handle DIFF. */ - { - if ( CombineMode != RGN_DIFF) - { /* Filter check! Well, must be junk?, so go K. */ - DPRINT1("RGN_COPY was handled! CombineMode %d\n",CombineMode); - return NtGdiCombineRgn(hDest, hSrc1, hSrc2, CombineMode); - } - /* Now handle DIFF. */ - if ( pRgn_Attr_Src1->Flags == NULLREGION ) + /* All but AND. */ + if ( CombineMode != RGN_AND) + { + if ( CombineMode <= RGN_AND) { - if (SetRectRgn( hDest, 0, 0, 0, 0)) - return NULLREGION; - goto ERROR_Exit; + /* + There might be some type of junk in the call, so go K. + If this becomes a problem, need to setup parameter check at the top. + */ + DPRINT1("Might be junk! CombineMode %d\n",CombineMode); + return NtGdiCombineRgn(hDest, hSrc1, hSrc2, CombineMode); } - if ( pRgn_Attr_Src2->Flags != NULLREGION ) + if ( CombineMode > RGN_XOR) /* Handle DIFF. */ { - Complexity = ComplexityFromRects( &pRgn_Attr_Src1->Rect, &pRgn_Attr_Src2->Rect); + if ( CombineMode != RGN_DIFF) + { + /* Filter check! Well, must be junk?, so go K. */ + DPRINT1("RGN_COPY was handled! CombineMode %d\n",CombineMode); + return NtGdiCombineRgn(hDest, hSrc1, hSrc2, CombineMode); + } + /* Now handle DIFF. */ + if ( pRgn_Attr_Src1->Flags == NULLREGION ) + { + if (SetRectRgn( hDest, 0, 0, 0, 0)) + return NULLREGION; + goto ERROR_Exit; + } - if ( Complexity != DIFF_RGN ) - { - if ( Complexity != INVERTED_RGN) - /* If same or overlapping and norm just go K. */ - return NtGdiCombineRgn(hDest, hSrc1, hSrc2, CombineMode); + if ( pRgn_Attr_Src2->Flags != NULLREGION ) + { + Complexity = ComplexityFromRects( &pRgn_Attr_Src1->Rect, &pRgn_Attr_Src2->Rect); - if (SetRectRgn( hDest, 0, 0, 0, 0)) - return NULLREGION; - goto ERROR_Exit; - } + if ( Complexity != DIFF_RGN ) + { + if ( Complexity != INVERTED_RGN) + /* If same or overlapping and norm just go K. */ + return NtGdiCombineRgn(hDest, hSrc1, hSrc2, CombineMode); + + if (SetRectRgn( hDest, 0, 0, 0, 0)) + return NULLREGION; + goto ERROR_Exit; + } + } } - } - else /* Handle OR or XOR. */ - { - if ( pRgn_Attr_Src1->Flags == NULLREGION ) + else /* Handle OR or XOR. */ { - if ( pRgn_Attr_Src2->Flags != NULLREGION ) - { /* Src1 null and not NULL, set from src2. */ - Ret = SetRectRgn( hDest, - pRgn_Attr_Src2->Rect.left, - pRgn_Attr_Src2->Rect.top, - pRgn_Attr_Src2->Rect.right, - pRgn_Attr_Src2->Rect.bottom ); - if (Ret) - return SIMPLEREGION; - goto ERROR_Exit; - } - /* Both are NULL. */ - if (SetRectRgn( hDest, 0, 0, 0, 0)) - return NULLREGION; - goto ERROR_Exit; + if ( pRgn_Attr_Src1->Flags == NULLREGION ) + { + if ( pRgn_Attr_Src2->Flags != NULLREGION ) + { + /* Src1 null and not NULL, set from src2. */ + Ret = SetRectRgn( hDest, + pRgn_Attr_Src2->Rect.left, + pRgn_Attr_Src2->Rect.top, + pRgn_Attr_Src2->Rect.right, + pRgn_Attr_Src2->Rect.bottom ); + if (Ret) + return SIMPLEREGION; + goto ERROR_Exit; + } + /* Both are NULL. */ + if (SetRectRgn( hDest, 0, 0, 0, 0)) + return NULLREGION; + goto ERROR_Exit; + } + /* Src1 is not NULL. */ + if ( pRgn_Attr_Src2->Flags != NULLREGION ) + { + if ( CombineMode != RGN_OR ) /* Filter XOR, so go K. */ + return NtGdiCombineRgn(hDest, hSrc1, hSrc2, CombineMode); + + Complexity = ComplexityFromRects( &pRgn_Attr_Src1->Rect, &pRgn_Attr_Src2->Rect); + /* If inverted use Src2. */ + if ( Complexity == INVERTED_RGN) + { + Ret = SetRectRgn( hDest, + pRgn_Attr_Src2->Rect.left, + pRgn_Attr_Src2->Rect.top, + pRgn_Attr_Src2->Rect.right, + pRgn_Attr_Src2->Rect.bottom ); + if (Ret) + return SIMPLEREGION; + goto ERROR_Exit; + } + /* Not NULL or overlapping or differentiated, go to K. */ + if ( Complexity != SAME_RGN) + return NtGdiCombineRgn(hDest, hSrc1, hSrc2, CombineMode); + /* If same, just fall through. */ + } } - /* Src1 is not NULL. */ - if ( pRgn_Attr_Src2->Flags != NULLREGION ) - { - if ( CombineMode != RGN_OR ) /* Filter XOR, so go K. */ - return NtGdiCombineRgn(hDest, hSrc1, hSrc2, CombineMode); - - Complexity = ComplexityFromRects( &pRgn_Attr_Src1->Rect, &pRgn_Attr_Src2->Rect); - /* If inverted use Src2. */ - if ( Complexity == INVERTED_RGN) - { - Ret = SetRectRgn( hDest, - pRgn_Attr_Src2->Rect.left, - pRgn_Attr_Src2->Rect.top, - pRgn_Attr_Src2->Rect.right, - pRgn_Attr_Src2->Rect.bottom ); - if (Ret) - return SIMPLEREGION; - goto ERROR_Exit; - } - /* Not NULL or overlapping or differentiated, go to K. */ - if ( Complexity != SAME_RGN) - return NtGdiCombineRgn(hDest, hSrc1, hSrc2, CombineMode); - /* If same, just fall through. */ - } - } - Ret = SetRectRgn( hDest, - pRgn_Attr_Src1->Rect.left, - pRgn_Attr_Src1->Rect.top, - pRgn_Attr_Src1->Rect.right, - pRgn_Attr_Src1->Rect.bottom ); - if (Ret) - return SIMPLEREGION; - goto ERROR_Exit; - } - - /* Handle AND. */ - if ( pRgn_Attr_Src1->Flags != NULLREGION && - pRgn_Attr_Src2->Flags != NULLREGION ) - { - Complexity = ComplexityFromRects( &pRgn_Attr_Src1->Rect, &pRgn_Attr_Src2->Rect); - - if ( Complexity == DIFF_RGN ) /* Differentiated in anyway just NULL rgn. */ - { - if (SetRectRgn( hDest, 0, 0, 0, 0)) - return NULLREGION; - goto ERROR_Exit; - } - - if ( Complexity != INVERTED_RGN) /* Not inverted and overlapping. */ - { - if ( Complexity != SAME_RGN) /* Must be norm and overlapping. */ - return NtGdiCombineRgn(hDest, hSrc1, hSrc2, CombineMode); - /* Merge from src2. */ Ret = SetRectRgn( hDest, - pRgn_Attr_Src2->Rect.left, - pRgn_Attr_Src2->Rect.top, - pRgn_Attr_Src2->Rect.right, - pRgn_Attr_Src2->Rect.bottom ); + pRgn_Attr_Src1->Rect.left, + pRgn_Attr_Src1->Rect.top, + pRgn_Attr_Src1->Rect.right, + pRgn_Attr_Src1->Rect.bottom ); if (Ret) - return SIMPLEREGION; + return SIMPLEREGION; goto ERROR_Exit; - } - /* Inverted so merge from src1. */ - Ret = SetRectRgn( hDest, - pRgn_Attr_Src1->Rect.left, - pRgn_Attr_Src1->Rect.top, - pRgn_Attr_Src1->Rect.right, - pRgn_Attr_Src1->Rect.bottom ); - if (Ret) - return SIMPLEREGION; - goto ERROR_Exit; - } + } - /* It's all NULL! */ - if (SetRectRgn( hDest, 0, 0, 0, 0)) - return NULLREGION; + /* Handle AND. */ + if ( pRgn_Attr_Src1->Flags != NULLREGION && + pRgn_Attr_Src2->Flags != NULLREGION ) + { + Complexity = ComplexityFromRects( &pRgn_Attr_Src1->Rect, &pRgn_Attr_Src2->Rect); + + if ( Complexity == DIFF_RGN ) /* Differentiated in anyway just NULL rgn. */ + { + if (SetRectRgn( hDest, 0, 0, 0, 0)) + return NULLREGION; + goto ERROR_Exit; + } + + if ( Complexity != INVERTED_RGN) /* Not inverted and overlapping. */ + { + if ( Complexity != SAME_RGN) /* Must be norm and overlapping. */ + return NtGdiCombineRgn(hDest, hSrc1, hSrc2, CombineMode); + /* Merge from src2. */ + Ret = SetRectRgn( hDest, + pRgn_Attr_Src2->Rect.left, + pRgn_Attr_Src2->Rect.top, + pRgn_Attr_Src2->Rect.right, + pRgn_Attr_Src2->Rect.bottom ); + if (Ret) + return SIMPLEREGION; + goto ERROR_Exit; + } + /* Inverted so merge from src1. */ + Ret = SetRectRgn( hDest, + pRgn_Attr_Src1->Rect.left, + pRgn_Attr_Src1->Rect.top, + pRgn_Attr_Src1->Rect.right, + pRgn_Attr_Src1->Rect.bottom ); + if (Ret) + return SIMPLEREGION; + goto ERROR_Exit; + } + + /* It's all NULL! */ + if (SetRectRgn( hDest, 0, 0, 0, 0)) + return NULLREGION; ERROR_Exit: - /* Even on error the flag is set dirty and force server side to redraw. */ - pRgn_Attr_Dest->AttrFlags |= ATTR_RGN_DIRTY; - return ERROR; + /* Even on error the flag is set dirty and force server side to redraw. */ + pRgn_Attr_Dest->AttrFlags |= ATTR_RGN_DIRTY; + return ERROR; } /* @@ -399,7 +403,7 @@ ERROR_Exit: HRGN WINAPI CreateEllipticRgnIndirect( - const RECT *prc + const RECT *prc ) { /* Notes if prc is NULL it will crash on All Windows NT I checked 2000/XP/VISTA */ @@ -437,72 +441,72 @@ HRGN WINAPI CreateRectRgn(int x1, int y1, int x2, int y2) { - PRGN_ATTR pRgn_Attr; - HRGN hrgn; - int tmp; + PRGN_ATTR pRgn_Attr; + HRGN hrgn; + int tmp; /// <- //// Remove when Brush/Pen/Rgn Attr is ready! - return NtGdiCreateRectRgn(x1,y1,x2,y2); + return NtGdiCreateRectRgn(x1,y1,x2,y2); //// - /* Normalize points */ - tmp = x1; - if ( x1 > x2 ) - { - x1 = x2; - x2 = tmp; - } + /* Normalize points */ + tmp = x1; + if ( x1 > x2 ) + { + x1 = x2; + x2 = tmp; + } - tmp = y1; - if ( y1 > y2 ) - { - y1 = y2; - y2 = tmp; - } - /* Check outside 24 bit limit for universal set. Chp 9 Areas, pg 560.*/ - if ( x1 < -(1<<27) || - y1 < -(1<<27) || - x2 > (1<<27)-1 || - y2 > (1<<27)-1 ) - { - SetLastError(ERROR_INVALID_PARAMETER); - return NULL; - } + tmp = y1; + if ( y1 > y2 ) + { + y1 = y2; + y2 = tmp; + } + /* Check outside 24 bit limit for universal set. Chp 9 Areas, pg 560.*/ + if ( x1 < -(1<<27) || + y1 < -(1<<27) || + x2 > (1<<27)-1 || + y2 > (1<<27)-1 ) + { + SetLastError(ERROR_INVALID_PARAMETER); + return NULL; + } - hrgn = hGetPEBHandle(hctRegionHandle, 0); + hrgn = hGetPEBHandle(hctRegionHandle, 0); - if (!hrgn) - hrgn = NtGdiCreateRectRgn(0, 0, 1, 1); + if (!hrgn) + hrgn = NtGdiCreateRectRgn(0, 0, 1, 1); - if (!hrgn) - return hrgn; + if (!hrgn) + return hrgn; - if (!GdiGetHandleUserData((HGDIOBJ) hrgn, GDI_OBJECT_TYPE_REGION, (PVOID) &pRgn_Attr)) - { - DPRINT1("No Attr for Region handle!!!\n"); - DeleteRegion(hrgn); - return NULL; - } + if (!GdiGetHandleUserData((HGDIOBJ) hrgn, GDI_OBJECT_TYPE_REGION, (PVOID) &pRgn_Attr)) + { + DPRINT1("No Attr for Region handle!!!\n"); + DeleteRegion(hrgn); + return NULL; + } - if (( x1 == x2) || (y1 == y2)) - { - pRgn_Attr->Flags = NULLREGION; - pRgn_Attr->Rect.left = pRgn_Attr->Rect.top = - pRgn_Attr->Rect.right = pRgn_Attr->Rect.bottom = 0; - } - else - { - pRgn_Attr->Flags = SIMPLEREGION; - pRgn_Attr->Rect.left = x1; - pRgn_Attr->Rect.top = y1; - pRgn_Attr->Rect.right = x2; - pRgn_Attr->Rect.bottom = y2; - } + if (( x1 == x2) || (y1 == y2)) + { + pRgn_Attr->Flags = NULLREGION; + pRgn_Attr->Rect.left = pRgn_Attr->Rect.top = + pRgn_Attr->Rect.right = pRgn_Attr->Rect.bottom = 0; + } + else + { + pRgn_Attr->Flags = SIMPLEREGION; + pRgn_Attr->Rect.left = x1; + pRgn_Attr->Rect.top = y1; + pRgn_Attr->Rect.right = x2; + pRgn_Attr->Rect.bottom = y2; + } - pRgn_Attr->AttrFlags = (ATTR_RGN_DIRTY|ATTR_RGN_VALID); + pRgn_Attr->AttrFlags = (ATTR_RGN_DIRTY|ATTR_RGN_VALID); - return hrgn; + return hrgn; } /* @@ -528,23 +532,23 @@ ExcludeClipRect(IN HDC hdc, IN INT xLeft, IN INT yTop, IN INT xRight, IN INT yBo { #if 0 // Handle something other than a normal dc object. - if (GDI_HANDLE_GET_TYPE(hdc) != GDI_OBJECT_TYPE_DC) - { - if (GDI_HANDLE_GET_TYPE(hdc) == GDI_OBJECT_TYPE_METADC) - return MFDRV_ExcludeClipRect( hdc, xLeft, yTop, xRight, yBottom); - else + if (GDI_HANDLE_GET_TYPE(hdc) != GDI_OBJECT_TYPE_DC) { - PLDC pLDC = GdiGetLDC(hdc); - if ( pLDC ) - { - if (pLDC->iType != LDC_EMFLDC || EMFDRV_ExcludeClipRect( hdc, xLeft, yTop, xRight, yBottom)) - return NtGdiExcludeClipRect(hdc, xLeft, yTop, xRight, yBottom); - } - else - SetLastError(ERROR_INVALID_HANDLE); - return ERROR; + if (GDI_HANDLE_GET_TYPE(hdc) == GDI_OBJECT_TYPE_METADC) + return MFDRV_ExcludeClipRect( hdc, xLeft, yTop, xRight, yBottom); + else + { + PLDC pLDC = GdiGetLDC(hdc); + if ( pLDC ) + { + if (pLDC->iType != LDC_EMFLDC || EMFDRV_ExcludeClipRect( hdc, xLeft, yTop, xRight, yBottom)) + return NtGdiExcludeClipRect(hdc, xLeft, yTop, xRight, yBottom); + } + else + SetLastError(ERROR_INVALID_HANDLE); + return ERROR; + } } - } #endif return NtGdiExcludeClipRect(hdc, xLeft, yTop, xRight, yBottom); } @@ -555,22 +559,22 @@ ExcludeClipRect(IN HDC hdc, IN INT xLeft, IN INT yTop, IN INT xRight, IN INT yBo HRGN WINAPI ExtCreateRegion( - CONST XFORM * lpXform, - DWORD nCount, - CONST RGNDATA * lpRgnData - ) + CONST XFORM * lpXform, + DWORD nCount, + CONST RGNDATA * lpRgnData +) { - if (lpRgnData) - { - if ((!lpXform) && (lpRgnData->rdh.nCount == 1)) - { - PRECT pRect = (PRECT)&lpRgnData->Buffer[0]; - return CreateRectRgn(pRect->left, pRect->top, pRect->right, pRect->bottom); - } - return NtGdiExtCreateRegion((LPXFORM) lpXform, nCount,(LPRGNDATA) lpRgnData); - } - SetLastError(ERROR_INVALID_PARAMETER); - return NULL; + if (lpRgnData) + { + if ((!lpXform) && (lpRgnData->rdh.nCount == 1)) + { + PRECT pRect = (PRECT)&lpRgnData->Buffer[0]; + return CreateRectRgn(pRect->left, pRect->top, pRect->right, pRect->bottom); + } + return NtGdiExtCreateRegion((LPXFORM) lpXform, nCount,(LPRGNDATA) lpRgnData); + } + SetLastError(ERROR_INVALID_PARAMETER); + return NULL; } /* @@ -580,110 +584,110 @@ INT WINAPI ExtSelectClipRgn( IN HDC hdc, IN HRGN hrgn, IN INT iMode) { - INT Ret; - HRGN NewRgn = NULL; + INT Ret; + HRGN NewRgn = NULL; #if 0 // Handle something other than a normal dc object. - if (GDI_HANDLE_GET_TYPE(hdc) != GDI_OBJECT_TYPE_DC) - { - if (GDI_HANDLE_GET_TYPE(hdc) == GDI_OBJECT_TYPE_METADC) - return MFDRV_ExtSelectClipRgn( hdc, ); - else + if (GDI_HANDLE_GET_TYPE(hdc) != GDI_OBJECT_TYPE_DC) { - PLDC pLDC = GdiGetLDC(hdc); - if ( pLDC ) - { - if (pLDC->iType != LDC_EMFLDC || EMFDRV_ExtSelectClipRgn( hdc, )) - return NtGdiExtSelectClipRgn(hdc, ); -} - else - SetLastError(ERROR_INVALID_HANDLE); - return ERROR; + if (GDI_HANDLE_GET_TYPE(hdc) == GDI_OBJECT_TYPE_METADC) + return MFDRV_ExtSelectClipRgn( hdc, ); + else + { + PLDC pLDC = GdiGetLDC(hdc); + if ( pLDC ) + { + if (pLDC->iType != LDC_EMFLDC || EMFDRV_ExtSelectClipRgn( hdc, )) + return NtGdiExtSelectClipRgn(hdc, ); + } + else + SetLastError(ERROR_INVALID_HANDLE); + return ERROR; + } } - } #endif #if 0 - if ( hrgn ) - { - if ( GetLayout(hdc) & LAYOUT_RTL ) - { - if ( MirrorRgnDC(hdc, hrgn, &NewRgn) ) + if ( hrgn ) + { + if ( GetLayout(hdc) & LAYOUT_RTL ) { - if ( NewRgn ) hrgn = NewRgn; + if ( MirrorRgnDC(hdc, hrgn, &NewRgn) ) + { + if ( NewRgn ) hrgn = NewRgn; + } } - } - } + } #endif - /* Batch handles RGN_COPY only! */ - if (iMode == RGN_COPY) - { + /* Batch handles RGN_COPY only! */ + if (iMode == RGN_COPY) + { #if 0 - PDC_ATTR pDc_Attr; - PRGN_ATTR pRgn_Attr = NULL; + PDC_ATTR pDc_Attr; + PRGN_ATTR pRgn_Attr = NULL; - /* hrgn can be NULL unless the RGN_COPY mode is specified. */ - if (hrgn) - GdiGetHandleUserData((HGDIOBJ) hrgn, GDI_OBJECT_TYPE_REGION, (PVOID) &pRgn_Attr); + /* hrgn can be NULL unless the RGN_COPY mode is specified. */ + if (hrgn) + GdiGetHandleUserData((HGDIOBJ) hrgn, GDI_OBJECT_TYPE_REGION, (PVOID) &pRgn_Attr); - if ( GdiGetHandleUserData((HGDIOBJ) hdc, GDI_OBJECT_TYPE_DC, (PVOID) &pDc_Attr) && - pDc_Attr ) - { - PGDI_TABLE_ENTRY pEntry = GdiHandleTable + GDI_HANDLE_GET_INDEX(hdc); - PTEB pTeb = NtCurrentTeb(); - - if ( pTeb->Win32ThreadInfo != NULL && - pTeb->GdiTebBatch.HDC == hdc && - !(pDc_Attr->ulDirty_ & DC_DIBSECTION) && - !(pEntry->Flags & GDI_ENTRY_VALIDATE_VIS) ) + if ( GdiGetHandleUserData((HGDIOBJ) hdc, GDI_OBJECT_TYPE_DC, (PVOID) &pDc_Attr) && + pDc_Attr ) { - if (!hrgn || - (hrgn && pRgn_Attr && pRgn_Attr->Flags <= SIMPLEREGION) ) - { - if ((pTeb->GdiTebBatch.Offset + sizeof(GDIBSEXTSELCLPRGN)) <= GDIBATCHBUFSIZE) - { - PGDIBSEXTSELCLPRGN pgO = (PGDIBSEXTSELCLPRGN)(&pTeb->GdiTebBatch.Buffer[0] + - pTeb->GdiTebBatch.Offset); - pgO->gbHdr.Cmd = GdiBCExtSelClipRgn; - pgO->gbHdr.Size = sizeof(GDIBSEXTSELCLPRGN); - pgO->fnMode = iMode; + PGDI_TABLE_ENTRY pEntry = GdiHandleTable + GDI_HANDLE_GET_INDEX(hdc); + PTEB pTeb = NtCurrentTeb(); - if ( hrgn && pRgn_Attr ) - { - Ret = pRgn_Attr->Flags; + if ( pTeb->Win32ThreadInfo != NULL && + pTeb->GdiTebBatch.HDC == hdc && + !(pDc_Attr->ulDirty_ & DC_DIBSECTION) && + !(pEntry->Flags & GDI_ENTRY_VALIDATE_VIS) ) + { + if (!hrgn || + (hrgn && pRgn_Attr && pRgn_Attr->Flags <= SIMPLEREGION) ) + { + if ((pTeb->GdiTebBatch.Offset + sizeof(GDIBSEXTSELCLPRGN)) <= GDIBATCHBUFSIZE) + { + PGDIBSEXTSELCLPRGN pgO = (PGDIBSEXTSELCLPRGN)(&pTeb->GdiTebBatch.Buffer[0] + + pTeb->GdiTebBatch.Offset); + pgO->gbHdr.Cmd = GdiBCExtSelClipRgn; + pgO->gbHdr.Size = sizeof(GDIBSEXTSELCLPRGN); + pgO->fnMode = iMode; - if ( pDc_Attr->VisRectRegion.Rect.left >= pRgn_Attr->Rect.right || - pDc_Attr->VisRectRegion.Rect.top >= pRgn_Attr->Rect.bottom || - pDc_Attr->VisRectRegion.Rect.right <= pRgn_Attr->Rect.left || - pDc_Attr->VisRectRegion.Rect.bottom <= pRgn_Attr->Rect.top ) - Ret = NULLREGION; + if ( hrgn && pRgn_Attr ) + { + Ret = pRgn_Attr->Flags; - pgO->left = pRgn_Attr->Rect.left; - pgO->top = pRgn_Attr->Rect.top; - pgO->right = pRgn_Attr->Rect.right; - pgO->bottom = pRgn_Attr->Rect.bottom; - } - else - { - Ret = pDc_Attr->VisRectRegion.Flags; - pgO->fnMode |= 0x80000000; // Set no hrgn mode. - } - pTeb->GdiTebBatch.Offset += sizeof(GDIBSEXTSELCLPRGN); - pTeb->GdiBatchCount++; - if (pTeb->GdiBatchCount >= GDI_BatchLimit) NtGdiFlush(); - if ( NewRgn ) DeleteObject(NewRgn); - return Ret; - } - } + if ( pDc_Attr->VisRectRegion.Rect.left >= pRgn_Attr->Rect.right || + pDc_Attr->VisRectRegion.Rect.top >= pRgn_Attr->Rect.bottom || + pDc_Attr->VisRectRegion.Rect.right <= pRgn_Attr->Rect.left || + pDc_Attr->VisRectRegion.Rect.bottom <= pRgn_Attr->Rect.top ) + Ret = NULLREGION; + + pgO->left = pRgn_Attr->Rect.left; + pgO->top = pRgn_Attr->Rect.top; + pgO->right = pRgn_Attr->Rect.right; + pgO->bottom = pRgn_Attr->Rect.bottom; + } + else + { + Ret = pDc_Attr->VisRectRegion.Flags; + pgO->fnMode |= 0x80000000; // Set no hrgn mode. + } + pTeb->GdiTebBatch.Offset += sizeof(GDIBSEXTSELCLPRGN); + pTeb->GdiBatchCount++; + if (pTeb->GdiBatchCount >= GDI_BatchLimit) NtGdiFlush(); + if ( NewRgn ) DeleteObject(NewRgn); + return Ret; + } + } + } } - } #endif - } - Ret = NtGdiExtSelectClipRgn(hdc, hrgn, iMode); + } + Ret = NtGdiExtSelectClipRgn(hdc, hrgn, iMode); - if ( NewRgn ) DeleteObject(NewRgn); + if ( NewRgn ) DeleteObject(NewRgn); - return Ret; + return Ret; } /* @@ -692,16 +696,16 @@ ExtSelectClipRgn( IN HDC hdc, IN HRGN hrgn, IN INT iMode) int WINAPI GetClipRgn( - HDC hdc, - HRGN hrgn - ) + HDC hdc, + HRGN hrgn +) { - INT Ret = NtGdiGetRandomRgn(hdc, hrgn, CLIPRGN); + INT Ret = NtGdiGetRandomRgn(hdc, hrgn, CLIPRGN); // if (Ret) // { // if(GetLayout(hdc) & LAYOUT_RTL) MirrorRgnDC(hdc,(HRGN)Ret, NULL); // } - return Ret; + return Ret; } /* @@ -742,26 +746,26 @@ WINAPI GetRgnBox(HRGN hrgn, LPRECT prcOut) { - PRGN_ATTR Rgn_Attr; + PRGN_ATTR Rgn_Attr; - //if (!GdiGetHandleUserData((HGDIOBJ) hrgn, GDI_OBJECT_TYPE_REGION, (PVOID) &Rgn_Attr)) - return NtGdiGetRgnBox(hrgn, prcOut); + //if (!GdiGetHandleUserData((HGDIOBJ) hrgn, GDI_OBJECT_TYPE_REGION, (PVOID) &Rgn_Attr)) + return NtGdiGetRgnBox(hrgn, prcOut); - if (Rgn_Attr->Flags == NULLREGION) - { - prcOut->left = 0; - prcOut->top = 0; - prcOut->right = 0; - prcOut->bottom = 0; - } - else - { - if (Rgn_Attr->Flags != SIMPLEREGION) - return NtGdiGetRgnBox(hrgn, prcOut); - /* WARNING! prcOut is never checked newbies! */ - RtlCopyMemory( prcOut, &Rgn_Attr->Rect, sizeof(RECT)); - } - return Rgn_Attr->Flags; + if (Rgn_Attr->Flags == NULLREGION) + { + prcOut->left = 0; + prcOut->top = 0; + prcOut->right = 0; + prcOut->bottom = 0; + } + else + { + if (Rgn_Attr->Flags != SIMPLEREGION) + return NtGdiGetRgnBox(hrgn, prcOut); + /* WARNING! prcOut is never checked newbies! */ + RtlCopyMemory( prcOut, &Rgn_Attr->Rect, sizeof(RECT)); + } + return Rgn_Attr->Flags; } /* @@ -777,23 +781,23 @@ IntersectClipRect(HDC hdc, { #if 0 // Handle something other than a normal dc object. - if (GDI_HANDLE_GET_TYPE(hdc) != GDI_OBJECT_TYPE_DC) - { - if (GDI_HANDLE_GET_TYPE(hdc) == GDI_OBJECT_TYPE_METADC) - return MFDRV_IntersectClipRect( hdc, nLeftRect, nTopRect, nRightRect, nBottomRect); - else + if (GDI_HANDLE_GET_TYPE(hdc) != GDI_OBJECT_TYPE_DC) { - PLDC pLDC = GdiGetLDC(hdc); - if ( pLDC ) - { - if (pLDC->iType != LDC_EMFLDC || EMFDRV_IntersectClipRect( hdc, nLeftRect, nTopRect, nRightRect, nBottomRect)) - return NtGdiIntersectClipRect(hdc, nLeftRect, nTopRect, nRightRect, nBottomRect); - } - else - SetLastError(ERROR_INVALID_HANDLE); - return ERROR; + if (GDI_HANDLE_GET_TYPE(hdc) == GDI_OBJECT_TYPE_METADC) + return MFDRV_IntersectClipRect( hdc, nLeftRect, nTopRect, nRightRect, nBottomRect); + else + { + PLDC pLDC = GdiGetLDC(hdc); + if ( pLDC ) + { + if (pLDC->iType != LDC_EMFLDC || EMFDRV_IntersectClipRect( hdc, nLeftRect, nTopRect, nRightRect, nBottomRect)) + return NtGdiIntersectClipRect(hdc, nLeftRect, nTopRect, nRightRect, nBottomRect); + } + else + SetLastError(ERROR_INVALID_HANDLE); + return ERROR; + } } - } #endif return NtGdiIntersectClipRect(hdc, nLeftRect, nTopRect, nRightRect, nBottomRect); } @@ -805,9 +809,9 @@ BOOL WINAPI MirrorRgn(HWND hwnd, HRGN hrgn) { - RECT Rect; - GetWindowRect(hwnd, &Rect); - return MirrorRgnByWidth(hrgn, Rect.right - Rect.left, NULL); + RECT Rect; + GetWindowRect(hwnd, &Rect); + return MirrorRgnByWidth(hrgn, Rect.right - Rect.left, NULL); } /* @@ -821,25 +825,25 @@ OffsetClipRgn(HDC hdc, { #if 0 // Handle something other than a normal dc object. - if (GDI_HANDLE_GET_TYPE(hdc) != GDI_OBJECT_TYPE_DC) - { - if (GDI_HANDLE_GET_TYPE(hdc) == GDI_OBJECT_TYPE_METADC) - return MFDRV_OffsetClipRgn( hdc, nXOffset, nYOffset ); - else + if (GDI_HANDLE_GET_TYPE(hdc) != GDI_OBJECT_TYPE_DC) { - PLDC pLDC = GdiGetLDC(hdc); - if ( !pLDC ) - { - SetLastError(ERROR_INVALID_HANDLE); - return ERROR; - } - if (pLDC->iType == LDC_EMFLDC && !EMFDRV_OffsetClipRgn( hdc, nXOffset, nYOffset )) - return ERROR; - return NtGdiOffsetClipRgn( hdc, nXOffset, nYOffset); + if (GDI_HANDLE_GET_TYPE(hdc) == GDI_OBJECT_TYPE_METADC) + return MFDRV_OffsetClipRgn( hdc, nXOffset, nYOffset ); + else + { + PLDC pLDC = GdiGetLDC(hdc); + if ( !pLDC ) + { + SetLastError(ERROR_INVALID_HANDLE); + return ERROR; + } + if (pLDC->iType == LDC_EMFLDC && !EMFDRV_OffsetClipRgn( hdc, nXOffset, nYOffset )) + return ERROR; + return NtGdiOffsetClipRgn( hdc, nXOffset, nYOffset); + } } - } #endif - return NtGdiOffsetClipRgn( hdc, nXOffset, nYOffset); + return NtGdiOffsetClipRgn( hdc, nXOffset, nYOffset); } /* @@ -849,53 +853,53 @@ OffsetClipRgn(HDC hdc, INT WINAPI OffsetRgn( HRGN hrgn, - int nXOffset, - int nYOffset) + int nXOffset, + int nYOffset) { - PRGN_ATTR pRgn_Attr; - int nLeftRect, nTopRect, nRightRect, nBottomRect; + PRGN_ATTR pRgn_Attr; + int nLeftRect, nTopRect, nRightRect, nBottomRect; // HACKFIX // if (!GdiGetHandleUserData((HGDIOBJ) hrgn, GDI_OBJECT_TYPE_REGION, (PVOID) &pRgn_Attr)) - return NtGdiOffsetRgn(hrgn,nXOffset,nYOffset); + return NtGdiOffsetRgn(hrgn,nXOffset,nYOffset); - if ( pRgn_Attr->Flags == NULLREGION) - return pRgn_Attr->Flags; + if ( pRgn_Attr->Flags == NULLREGION) + return pRgn_Attr->Flags; - if ( pRgn_Attr->Flags != SIMPLEREGION) - return NtGdiOffsetRgn(hrgn,nXOffset,nYOffset); + if ( pRgn_Attr->Flags != SIMPLEREGION) + return NtGdiOffsetRgn(hrgn,nXOffset,nYOffset); - nLeftRect = pRgn_Attr->Rect.left; - nTopRect = pRgn_Attr->Rect.top; - nRightRect = pRgn_Attr->Rect.right; - nBottomRect = pRgn_Attr->Rect.bottom; + nLeftRect = pRgn_Attr->Rect.left; + nTopRect = pRgn_Attr->Rect.top; + nRightRect = pRgn_Attr->Rect.right; + nBottomRect = pRgn_Attr->Rect.bottom; - if (nLeftRect < nRightRect) - { - if (nTopRect < nBottomRect) - { - nLeftRect = nXOffset + nLeftRect; - nTopRect = nYOffset + nTopRect; - nRightRect = nXOffset + nRightRect; - nBottomRect = nYOffset + nBottomRect; - - /* Check 28 bit limit. Chp 9 Areas, pg 560. */ - if ( nLeftRect < -(1<<27) || - nTopRect < -(1<<27) || - nRightRect > (1<<27)-1 || - nBottomRect > (1<<27)-1 ) + if (nLeftRect < nRightRect) + { + if (nTopRect < nBottomRect) { - return ERROR; - } + nLeftRect = nXOffset + nLeftRect; + nTopRect = nYOffset + nTopRect; + nRightRect = nXOffset + nRightRect; + nBottomRect = nYOffset + nBottomRect; - pRgn_Attr->Rect.top = nTopRect; - pRgn_Attr->Rect.left = nLeftRect; - pRgn_Attr->Rect.right = nRightRect; - pRgn_Attr->Rect.bottom = nBottomRect; - pRgn_Attr->AttrFlags |= ATTR_RGN_DIRTY; - } - } - return pRgn_Attr->Flags; + /* Check 28 bit limit. Chp 9 Areas, pg 560. */ + if ( nLeftRect < -(1<<27) || + nTopRect < -(1<<27) || + nRightRect > (1<<27)-1 || + nBottomRect > (1<<27)-1 ) + { + return ERROR; + } + + pRgn_Attr->Rect.top = nTopRect; + pRgn_Attr->Rect.left = nLeftRect; + pRgn_Attr->Rect.right = nRightRect; + pRgn_Attr->Rect.bottom = nBottomRect; + pRgn_Attr->AttrFlags |= ATTR_RGN_DIRTY; + } + } + return pRgn_Attr->Flags; } /* @@ -907,19 +911,19 @@ PtInRegion(IN HRGN hrgn, int x, int y) { - PRGN_ATTR pRgn_Attr; + PRGN_ATTR pRgn_Attr; - // HACKFIX - //if (!GdiGetHandleUserData((HGDIOBJ) hrgn, GDI_OBJECT_TYPE_REGION, (PVOID) &pRgn_Attr)) - return NtGdiPtInRegion(hrgn,x,y); + // HACKFIX + //if (!GdiGetHandleUserData((HGDIOBJ) hrgn, GDI_OBJECT_TYPE_REGION, (PVOID) &pRgn_Attr)) + return NtGdiPtInRegion(hrgn,x,y); - if ( pRgn_Attr->Flags == NULLREGION) - return FALSE; + if ( pRgn_Attr->Flags == NULLREGION) + return FALSE; - if ( pRgn_Attr->Flags != SIMPLEREGION) - return NtGdiPtInRegion(hrgn,x,y); + if ( pRgn_Attr->Flags != SIMPLEREGION) + return NtGdiPtInRegion(hrgn,x,y); - return INRECT( pRgn_Attr->Rect, x, y); + return INRECT( pRgn_Attr->Rect, x, y); } /* @@ -930,46 +934,46 @@ WINAPI RectInRegion(HRGN hrgn, LPCRECT prcl) { - PRGN_ATTR pRgn_Attr; - RECTL rc; + PRGN_ATTR pRgn_Attr; + RECTL rc; - // HACKFIX - //if (!GdiGetHandleUserData((HGDIOBJ) hrgn, GDI_OBJECT_TYPE_REGION, (PVOID) &pRgn_Attr)) - return NtGdiRectInRegion(hrgn, (LPRECT) prcl); + // HACKFIX + //if (!GdiGetHandleUserData((HGDIOBJ) hrgn, GDI_OBJECT_TYPE_REGION, (PVOID) &pRgn_Attr)) + return NtGdiRectInRegion(hrgn, (LPRECT) prcl); - if ( pRgn_Attr->Flags == NULLREGION) - return FALSE; + if ( pRgn_Attr->Flags == NULLREGION) + return FALSE; - if ( pRgn_Attr->Flags != SIMPLEREGION) - return NtGdiRectInRegion(hrgn, (LPRECT) prcl); + if ( pRgn_Attr->Flags != SIMPLEREGION) + return NtGdiRectInRegion(hrgn, (LPRECT) prcl); - /* swap the coordinates to make right >= left and bottom >= top */ - /* (region building rectangles are normalized the same way) */ - if ( prcl->top > prcl->bottom) - { - rc.top = prcl->bottom; - rc.bottom = prcl->top; - } - else - { - rc.top = prcl->top; - rc.bottom = prcl->bottom; - } - if ( prcl->right < prcl->left) - { - rc.right = prcl->left; - rc.left = prcl->right; - } - else - { - rc.right = prcl->right; - rc.left = prcl->left; - } + /* swap the coordinates to make right >= left and bottom >= top */ + /* (region building rectangles are normalized the same way) */ + if ( prcl->top > prcl->bottom) + { + rc.top = prcl->bottom; + rc.bottom = prcl->top; + } + else + { + rc.top = prcl->top; + rc.bottom = prcl->bottom; + } + if ( prcl->right < prcl->left) + { + rc.right = prcl->left; + rc.left = prcl->right; + } + else + { + rc.right = prcl->right; + rc.left = prcl->left; + } - if ( ComplexityFromRects( &pRgn_Attr->Rect, &rc) != DIFF_RGN ) - return TRUE; + if ( ComplexityFromRects( &pRgn_Attr->Rect, &rc) != DIFF_RGN ) + return TRUE; - return FALSE; + return FALSE; } /* @@ -977,8 +981,8 @@ RectInRegion(HRGN hrgn, */ int WINAPI SelectClipRgn( - HDC hdc, - HRGN hrgn + HDC hdc, + HRGN hrgn ) { return ExtSelectClipRgn(hdc, hrgn, RGN_COPY); @@ -995,39 +999,39 @@ SetRectRgn(HRGN hrgn, int nRightRect, int nBottomRect) { - PRGN_ATTR Rgn_Attr; + PRGN_ATTR Rgn_Attr; - //if (!GdiGetHandleUserData((HGDIOBJ) hrgn, GDI_OBJECT_TYPE_REGION, (PVOID) &Rgn_Attr)) - return NtGdiSetRectRgn(hrgn, nLeftRect, nTopRect, nRightRect, nBottomRect); + //if (!GdiGetHandleUserData((HGDIOBJ) hrgn, GDI_OBJECT_TYPE_REGION, (PVOID) &Rgn_Attr)) + return NtGdiSetRectRgn(hrgn, nLeftRect, nTopRect, nRightRect, nBottomRect); - if ((nLeftRect == nRightRect) || (nTopRect == nBottomRect)) - { - Rgn_Attr->AttrFlags |= ATTR_RGN_DIRTY; - Rgn_Attr->Flags = NULLREGION; - Rgn_Attr->Rect.left = Rgn_Attr->Rect.top = - Rgn_Attr->Rect.right = Rgn_Attr->Rect.bottom = 0; - return TRUE; - } + if ((nLeftRect == nRightRect) || (nTopRect == nBottomRect)) + { + Rgn_Attr->AttrFlags |= ATTR_RGN_DIRTY; + Rgn_Attr->Flags = NULLREGION; + Rgn_Attr->Rect.left = Rgn_Attr->Rect.top = + Rgn_Attr->Rect.right = Rgn_Attr->Rect.bottom = 0; + return TRUE; + } - Rgn_Attr->Rect.left = nLeftRect; - Rgn_Attr->Rect.top = nTopRect; - Rgn_Attr->Rect.right = nRightRect; - Rgn_Attr->Rect.bottom = nBottomRect; + Rgn_Attr->Rect.left = nLeftRect; + Rgn_Attr->Rect.top = nTopRect; + Rgn_Attr->Rect.right = nRightRect; + Rgn_Attr->Rect.bottom = nBottomRect; - if(nLeftRect > nRightRect) - { - Rgn_Attr->Rect.left = nRightRect; - Rgn_Attr->Rect.right = nLeftRect; - } - if(nTopRect > nBottomRect) - { - Rgn_Attr->Rect.top = nBottomRect; - Rgn_Attr->Rect.bottom = nTopRect; - } + if(nLeftRect > nRightRect) + { + Rgn_Attr->Rect.left = nRightRect; + Rgn_Attr->Rect.right = nLeftRect; + } + if(nTopRect > nBottomRect) + { + Rgn_Attr->Rect.top = nBottomRect; + Rgn_Attr->Rect.bottom = nTopRect; + } - Rgn_Attr->AttrFlags |= ATTR_RGN_DIRTY ; - Rgn_Attr->Flags = SIMPLEREGION; - return TRUE; + Rgn_Attr->AttrFlags |= ATTR_RGN_DIRTY ; + Rgn_Attr->Flags = SIMPLEREGION; + return TRUE; } /* @@ -1037,20 +1041,20 @@ int WINAPI SetMetaRgn( HDC hDC ) { - if (GDI_HANDLE_GET_TYPE(hDC) == GDI_OBJECT_TYPE_DC) - return NtGdiSetMetaRgn(hDC); + if (GDI_HANDLE_GET_TYPE(hDC) == GDI_OBJECT_TYPE_DC) + return NtGdiSetMetaRgn(hDC); #if 0 - PLDC pLDC = GdiGetLDC(hDC); - if ( pLDC && GDI_HANDLE_GET_TYPE(hDC) != GDI_OBJECT_TYPE_METADC ) - { - if (pLDC->iType == LDC_EMFLDC || EMFDRV_SetMetaRgn(hDC)) + PLDC pLDC = GdiGetLDC(hDC); + if ( pLDC && GDI_HANDLE_GET_TYPE(hDC) != GDI_OBJECT_TYPE_METADC ) { - return NtGdiSetMetaRgn(hDC); + if (pLDC->iType == LDC_EMFLDC || EMFDRV_SetMetaRgn(hDC)) + { + return NtGdiSetMetaRgn(hDC); + } + else + SetLastError(ERROR_INVALID_HANDLE); } - else - SetLastError(ERROR_INVALID_HANDLE); - } #endif - return ERROR; + return ERROR; } diff --git a/reactos/dll/win32/gdi32/objects/text.c b/reactos/dll/win32/gdi32/objects/text.c index b84e948abad..75b79c30b8a 100644 --- a/reactos/dll/win32/gdi32/objects/text.c +++ b/reactos/dll/win32/gdi32/objects/text.c @@ -7,26 +7,27 @@ BOOL WINAPI TextOutA( - HDC hdc, - int nXStart, - int nYStart, - LPCSTR lpString, - int cchString) + HDC hdc, + int nXStart, + int nYStart, + LPCSTR lpString, + int cchString) { - ANSI_STRING StringA; - UNICODE_STRING StringU; - BOOL ret; + ANSI_STRING StringA; + UNICODE_STRING StringU; + BOOL ret; - if (NULL != lpString) - { - RtlInitAnsiString(&StringA, (LPSTR)lpString); - RtlAnsiStringToUnicodeString(&StringU, &StringA, TRUE); - } else - StringU.Buffer = NULL; + if (NULL != lpString) + { + RtlInitAnsiString(&StringA, (LPSTR)lpString); + RtlAnsiStringToUnicodeString(&StringU, &StringA, TRUE); + } + else + StringU.Buffer = NULL; - ret = TextOutW(hdc, nXStart, nYStart, StringU.Buffer, cchString); - RtlFreeUnicodeString(&StringU); - return ret; + ret = TextOutW(hdc, nXStart, nYStart, StringU.Buffer, cchString); + RtlFreeUnicodeString(&StringU); + return ret; } @@ -36,13 +37,13 @@ TextOutA( BOOL WINAPI TextOutW( - HDC hdc, - int nXStart, - int nYStart, - LPCWSTR lpString, - int cchString) + HDC hdc, + int nXStart, + int nYStart, + LPCWSTR lpString, + int cchString) { - return NtGdiExtTextOutW(hdc, nXStart, nYStart, 0, NULL, (LPWSTR)lpString, cchString, NULL, 0); + return NtGdiExtTextOutW(hdc, nXStart, nYStart, 0, NULL, (LPWSTR)lpString, cchString, NULL, 0); } @@ -53,10 +54,10 @@ DWORD WINAPI GdiGetCodePage(HDC hdc) { - PDC_ATTR Dc_Attr; - if (!GdiGetHandleUserData((HGDIOBJ) hdc, GDI_OBJECT_TYPE_DC, (PVOID) &Dc_Attr)) return 0; - if (Dc_Attr->ulDirty_ & DIRTY_CHARSET) return LOWORD(NtGdiGetCharSet(hdc)); - return LOWORD(Dc_Attr->iCS_CP); + PDC_ATTR Dc_Attr; + if (!GdiGetHandleUserData((HGDIOBJ) hdc, GDI_OBJECT_TYPE_DC, (PVOID) &Dc_Attr)) return 0; + if (Dc_Attr->ulDirty_ & DIRTY_CHARSET) return LOWORD(NtGdiGetCharSet(hdc)); + return LOWORD(Dc_Attr->iCS_CP); } @@ -66,13 +67,13 @@ GdiGetCodePage(HDC hdc) int WINAPI GetTextCharacterExtra( - HDC hDc - ) + HDC hDc +) { - PDC_ATTR Dc_Attr; + PDC_ATTR Dc_Attr; - if (!GdiGetHandleUserData((HGDIOBJ) hDc, GDI_OBJECT_TYPE_DC, (PVOID) &Dc_Attr)) return 0; - return Dc_Attr->lTextExtra; + if (!GdiGetHandleUserData((HGDIOBJ) hDc, GDI_OBJECT_TYPE_DC, (PVOID) &Dc_Attr)) return 0; + return Dc_Attr->lTextExtra; // return GetDCDWord( hDc, GdiGetTextCharExtra, 0); } @@ -96,19 +97,19 @@ GetTextCharset(HDC hdc) BOOL WINAPI GetTextMetricsA( - HDC hdc, - LPTEXTMETRICA lptm - ) + HDC hdc, + LPTEXTMETRICA lptm +) { - TMW_INTERNAL tmwi; + TMW_INTERNAL tmwi; - if (! NtGdiGetTextMetricsW(hdc, &tmwi, sizeof(TMW_INTERNAL))) - { - return FALSE; - } + if (! NtGdiGetTextMetricsW(hdc, &tmwi, sizeof(TMW_INTERNAL))) + { + return FALSE; + } - FONT_TextMetricWToA(&tmwi.TextMetric, lptm); - return TRUE; + FONT_TextMetricWToA(&tmwi.TextMetric, lptm); + return TRUE; } @@ -118,19 +119,19 @@ GetTextMetricsA( BOOL WINAPI GetTextMetricsW( - HDC hdc, - LPTEXTMETRICW lptm - ) + HDC hdc, + LPTEXTMETRICW lptm +) { - TMW_INTERNAL tmwi; + TMW_INTERNAL tmwi; - if (! NtGdiGetTextMetricsW(hdc, &tmwi, sizeof(TMW_INTERNAL))) - { - return FALSE; - } + if (! NtGdiGetTextMetricsW(hdc, &tmwi, sizeof(TMW_INTERNAL))) + { + return FALSE; + } - *lptm = tmwi.TextMetric; - return TRUE; + *lptm = tmwi.TextMetric; + return TRUE; } @@ -140,24 +141,24 @@ GetTextMetricsW( BOOL APIENTRY GetTextExtentPointA( - HDC hdc, - LPCSTR lpString, - int cchString, - LPSIZE lpSize - ) + HDC hdc, + LPCSTR lpString, + int cchString, + LPSIZE lpSize +) { - ANSI_STRING StringA; - UNICODE_STRING StringU; - BOOL ret; + ANSI_STRING StringA; + UNICODE_STRING StringU; + BOOL ret; - RtlInitAnsiString(&StringA, (LPSTR)lpString); - RtlAnsiStringToUnicodeString(&StringU, &StringA, TRUE); + RtlInitAnsiString(&StringA, (LPSTR)lpString); + RtlAnsiStringToUnicodeString(&StringU, &StringA, TRUE); - ret = GetTextExtentPointW(hdc, StringU.Buffer, cchString, lpSize); + ret = GetTextExtentPointW(hdc, StringU.Buffer, cchString, lpSize); - RtlFreeUnicodeString(&StringU); + RtlFreeUnicodeString(&StringU); - return ret; + return ret; } @@ -167,13 +168,13 @@ GetTextExtentPointA( BOOL APIENTRY GetTextExtentPointW( - HDC hdc, - LPCWSTR lpString, - int cchString, - LPSIZE lpSize - ) + HDC hdc, + LPCWSTR lpString, + int cchString, + LPSIZE lpSize +) { - return NtGdiGetTextExtent(hdc, (LPWSTR)lpString, cchString, lpSize, 0); + return NtGdiGetTextExtent(hdc, (LPWSTR)lpString, cchString, lpSize, 0); } @@ -183,24 +184,24 @@ GetTextExtentPointW( BOOL APIENTRY GetTextExtentExPointW( - HDC hdc, - LPCWSTR lpszStr, - int cchString, - int nMaxExtent, - LPINT lpnFit, - LPINT alpDx, - LPSIZE lpSize - ) + HDC hdc, + LPCWSTR lpszStr, + int cchString, + int nMaxExtent, + LPINT lpnFit, + LPINT alpDx, + LPSIZE lpSize +) { - if(nMaxExtent < -1) - { - SetLastError(ERROR_INVALID_PARAMETER); - return FALSE; - } + if(nMaxExtent < -1) + { + SetLastError(ERROR_INVALID_PARAMETER); + return FALSE; + } - return NtGdiGetTextExtentExW ( - hdc, (LPWSTR)lpszStr, cchString, nMaxExtent, (PULONG)lpnFit, (PULONG)alpDx, lpSize, 0 ); + return NtGdiGetTextExtentExW ( + hdc, (LPWSTR)lpszStr, cchString, nMaxExtent, (PULONG)lpnFit, (PULONG)alpDx, lpSize, 0 ); } @@ -210,37 +211,37 @@ GetTextExtentExPointW( BOOL APIENTRY GetTextExtentExPointA( - HDC hdc, - LPCSTR lpszStr, - int cchString, - int nMaxExtent, - LPINT lpnFit, - LPINT alpDx, - LPSIZE lpSize - ) + HDC hdc, + LPCSTR lpszStr, + int cchString, + int nMaxExtent, + LPINT lpnFit, + LPINT alpDx, + LPSIZE lpSize +) { - NTSTATUS Status; - LPWSTR lpszStrW; - BOOL rc = 0; + NTSTATUS Status; + LPWSTR lpszStrW; + BOOL rc = 0; - if(nMaxExtent < -1) - { - SetLastError(ERROR_INVALID_PARAMETER); - return FALSE; - } + if(nMaxExtent < -1) + { + SetLastError(ERROR_INVALID_PARAMETER); + return FALSE; + } - Status = HEAP_strdupA2W ( &lpszStrW, lpszStr ); - if (!NT_SUCCESS (Status)) - SetLastError (RtlNtStatusToDosError(Status)); - else - { - rc = NtGdiGetTextExtentExW ( - hdc, lpszStrW, cchString, nMaxExtent, (PULONG)lpnFit, (PULONG)alpDx, lpSize, 0 ); + Status = HEAP_strdupA2W ( &lpszStrW, lpszStr ); + if (!NT_SUCCESS (Status)) + SetLastError (RtlNtStatusToDosError(Status)); + else + { + rc = NtGdiGetTextExtentExW ( + hdc, lpszStrW, cchString, nMaxExtent, (PULONG)lpnFit, (PULONG)alpDx, lpSize, 0 ); - HEAP_free ( lpszStrW ); - } + HEAP_free ( lpszStrW ); + } - return rc; + return rc; } @@ -250,24 +251,24 @@ GetTextExtentExPointA( BOOL APIENTRY GetTextExtentPoint32A( - HDC hdc, - LPCSTR lpString, - int cchString, - LPSIZE lpSize - ) + HDC hdc, + LPCSTR lpString, + int cchString, + LPSIZE lpSize +) { - ANSI_STRING StringA; - UNICODE_STRING StringU; - BOOL ret; + ANSI_STRING StringA; + UNICODE_STRING StringU; + BOOL ret; - RtlInitAnsiString(&StringA, (LPSTR)lpString); - RtlAnsiStringToUnicodeString(&StringU, &StringA, TRUE); + RtlInitAnsiString(&StringA, (LPSTR)lpString); + RtlAnsiStringToUnicodeString(&StringU, &StringA, TRUE); - ret = GetTextExtentPoint32W(hdc, StringU.Buffer, cchString, lpSize); + ret = GetTextExtentPoint32W(hdc, StringU.Buffer, cchString, lpSize); - RtlFreeUnicodeString(&StringU); + RtlFreeUnicodeString(&StringU); - return ret; + return ret; } @@ -277,13 +278,13 @@ GetTextExtentPoint32A( BOOL APIENTRY GetTextExtentPoint32W( - HDC hdc, - LPCWSTR lpString, - int cchString, - LPSIZE lpSize - ) + HDC hdc, + LPCWSTR lpString, + int cchString, + LPSIZE lpSize +) { - return NtGdiGetTextExtent(hdc, (LPWSTR)lpString, cchString, lpSize, 0); + return NtGdiGetTextExtent(hdc, (LPWSTR)lpString, cchString, lpSize, 0); } /* @@ -321,28 +322,28 @@ GetTextExtentPointI(HDC hdc, BOOL WINAPI ExtTextOutA( - HDC hdc, - int X, - int Y, - UINT fuOptions, - CONST RECT *lprc, - LPCSTR lpString, - UINT cchString, - CONST INT *lpDx - ) + HDC hdc, + int X, + int Y, + UINT fuOptions, + CONST RECT *lprc, + LPCSTR lpString, + UINT cchString, + CONST INT *lpDx +) { - ANSI_STRING StringA; - UNICODE_STRING StringU; - BOOL ret; + ANSI_STRING StringA; + UNICODE_STRING StringU; + BOOL ret; - RtlInitAnsiString(&StringA, (LPSTR)lpString); - RtlAnsiStringToUnicodeString(&StringU, &StringA, TRUE); + RtlInitAnsiString(&StringA, (LPSTR)lpString); + RtlAnsiStringToUnicodeString(&StringU, &StringA, TRUE); - ret = ExtTextOutW(hdc, X, Y, fuOptions, lprc, StringU.Buffer, cchString, lpDx); + ret = ExtTextOutW(hdc, X, Y, fuOptions, lprc, StringU.Buffer, cchString, lpDx); - RtlFreeUnicodeString(&StringU); + RtlFreeUnicodeString(&StringU); - return ret; + return ret; } @@ -352,17 +353,17 @@ ExtTextOutA( BOOL WINAPI ExtTextOutW( - HDC hdc, - int X, - int Y, - UINT fuOptions, - CONST RECT *lprc, - LPCWSTR lpString, - UINT cchString, - CONST INT *lpDx - ) + HDC hdc, + int X, + int Y, + UINT fuOptions, + CONST RECT *lprc, + LPCWSTR lpString, + UINT cchString, + CONST INT *lpDx +) { - return NtGdiExtTextOutW(hdc, X, Y, fuOptions, (LPRECT)lprc, (LPWSTR)lpString, cchString, (LPINT)lpDx, 0); + return NtGdiExtTextOutW(hdc, X, Y, fuOptions, (LPRECT)lprc, (LPWSTR)lpString, cchString, (LPINT)lpDx, 0); } @@ -436,12 +437,12 @@ GetTextFaceAliasW(HDC hdc, int cChar, LPWSTR pszOut) { - if ( pszOut && !cChar ) - { - GdiSetLastError(ERROR_INVALID_PARAMETER); - return 0; - } - return NtGdiGetTextFaceW(hdc,cChar,pszOut,TRUE); + if ( pszOut && !cChar ) + { + GdiSetLastError(ERROR_INVALID_PARAMETER); + return 0; + } + return NtGdiGetTextFaceW(hdc,cChar,pszOut,TRUE); } @@ -452,7 +453,7 @@ GetFontResourceInfoW( DWORD *pdwBufSize, void* lpBuffer, DWORD dwType - ) +) { BOOL bRet; UNICODE_STRING NtFileName; @@ -473,13 +474,13 @@ GetFontResourceInfoW( } bRet = NtGdiGetFontResourceInfoInternalW( - NtFileName.Buffer, - (NtFileName.Length / sizeof(WCHAR)) + 1, - 1, - *pdwBufSize, - pdwBufSize, - lpBuffer, - dwType); + NtFileName.Buffer, + (NtFileName.Length / sizeof(WCHAR)) + 1, + 1, + *pdwBufSize, + pdwBufSize, + lpBuffer, + dwType); RtlFreeHeap(RtlGetProcessHeap(), 0, NtFileName.Buffer); @@ -498,37 +499,37 @@ GetFontResourceInfoW( int WINAPI SetTextCharacterExtra( - HDC hDC, - int CharExtra - ) + HDC hDC, + int CharExtra +) { - INT cExtra = 0x80000000; - PDC_ATTR Dc_Attr; + INT cExtra = 0x80000000; + PDC_ATTR Dc_Attr; - if (CharExtra == cExtra) - { - SetLastError(ERROR_INVALID_PARAMETER); - return cExtra; - } + if (CharExtra == cExtra) + { + SetLastError(ERROR_INVALID_PARAMETER); + return cExtra; + } #if 0 - if (GDI_HANDLE_GET_TYPE(hDC) == GDI_OBJECT_TYPE_METADC) - { - return MFDRV_SetTextCharacterExtra( hDC, CharExtra ); // Wine port. - } + if (GDI_HANDLE_GET_TYPE(hDC) == GDI_OBJECT_TYPE_METADC) + { + return MFDRV_SetTextCharacterExtra( hDC, CharExtra ); // Wine port. + } #endif - if (!GdiGetHandleUserData((HGDIOBJ) hDC, GDI_OBJECT_TYPE_DC, (PVOID) &Dc_Attr)) return cExtra; + if (!GdiGetHandleUserData((HGDIOBJ) hDC, GDI_OBJECT_TYPE_DC, (PVOID) &Dc_Attr)) return cExtra; - if (NtCurrentTeb()->GdiTebBatch.HDC == hDC) - { - if (Dc_Attr->ulDirty_ & DC_FONTTEXT_DIRTY) - { - NtGdiFlush(); // Sync up Dc_Attr from Kernel space. - Dc_Attr->ulDirty_ &= ~(DC_MODE_DIRTY|DC_FONTTEXT_DIRTY); - } - } - cExtra = Dc_Attr->lTextExtra; - Dc_Attr->lTextExtra = CharExtra; - return cExtra; + if (NtCurrentTeb()->GdiTebBatch.HDC == hDC) + { + if (Dc_Attr->ulDirty_ & DC_FONTTEXT_DIRTY) + { + NtGdiFlush(); // Sync up Dc_Attr from Kernel space. + Dc_Attr->ulDirty_ &= ~(DC_MODE_DIRTY|DC_FONTTEXT_DIRTY); + } + } + cExtra = Dc_Attr->lTextExtra; + Dc_Attr->lTextExtra = CharExtra; + return cExtra; // return GetAndSetDCDWord( hDC, GdiGetSetTextCharExtra, CharExtra, 0, 0, 0 ); } @@ -540,9 +541,9 @@ UINT WINAPI GetTextAlign(HDC hdc) { - PDC_ATTR Dc_Attr; - if (!GdiGetHandleUserData((HGDIOBJ) hdc, GDI_OBJECT_TYPE_DC, (PVOID) &Dc_Attr)) return 0; - return Dc_Attr->lTextAlign; + PDC_ATTR Dc_Attr; + if (!GdiGetHandleUserData((HGDIOBJ) hdc, GDI_OBJECT_TYPE_DC, (PVOID) &Dc_Attr)) return 0; + return Dc_Attr->lTextAlign; } @@ -554,9 +555,9 @@ COLORREF WINAPI GetTextColor(HDC hdc) { - PDC_ATTR Dc_Attr; - if (!GdiGetHandleUserData((HGDIOBJ) hdc, GDI_OBJECT_TYPE_DC, (PVOID) &Dc_Attr)) return 0; - return Dc_Attr->ulForegroundClr; + PDC_ATTR Dc_Attr; + if (!GdiGetHandleUserData((HGDIOBJ) hdc, GDI_OBJECT_TYPE_DC, (PVOID) &Dc_Attr)) return 0; + return Dc_Attr->ulForegroundClr; } @@ -569,38 +570,38 @@ WINAPI SetTextAlign(HDC hdc, UINT fMode) { - PDC_ATTR Dc_Attr; - INT OldMode = 0; + PDC_ATTR Dc_Attr; + INT OldMode = 0; #if 0 - if (GDI_HANDLE_GET_TYPE(hDC) != GDI_OBJECT_TYPE_DC) - { - if (GDI_HANDLE_GET_TYPE(hDC) == GDI_OBJECT_TYPE_METADC) - return MFDRV_SetTextAlign( hdc, fMode ) - else + if (GDI_HANDLE_GET_TYPE(hDC) != GDI_OBJECT_TYPE_DC) { - PLDC pLDC = Dc_Attr->pvLDC; - if ( !pLDC ) - { - SetLastError(ERROR_INVALID_HANDLE); - return FALSE; - } - if (pLDC->iType == LDC_EMFLDC) - { - if return EMFDRV_SetTextAlign( hdc, fMode ) - } - } - } + if (GDI_HANDLE_GET_TYPE(hDC) == GDI_OBJECT_TYPE_METADC) + return MFDRV_SetTextAlign( hdc, fMode ) + else + { + PLDC pLDC = Dc_Attr->pvLDC; + if ( !pLDC ) + { + SetLastError(ERROR_INVALID_HANDLE); + return FALSE; + } + if (pLDC->iType == LDC_EMFLDC) + { + if return EMFDRV_SetTextAlign( hdc, fMode ) + } + } + } #endif - if (!GdiGetHandleUserData((HGDIOBJ) hdc, GDI_OBJECT_TYPE_DC, (PVOID) &Dc_Attr)) return OldMode; + if (!GdiGetHandleUserData((HGDIOBJ) hdc, GDI_OBJECT_TYPE_DC, (PVOID) &Dc_Attr)) return OldMode; - OldMode = Dc_Attr->lTextAlign; - Dc_Attr->lTextAlign = fMode; // Raw - if (Dc_Attr->dwLayout & LAYOUT_RTL) - { - if(!(fMode & TA_CENTER)) fMode |= TA_RIGHT; - } - Dc_Attr->flTextAlign = fMode & (TA_BASELINE|TA_UPDATECP|TA_CENTER); - return OldMode; + OldMode = Dc_Attr->lTextAlign; + Dc_Attr->lTextAlign = fMode; // Raw + if (Dc_Attr->dwLayout & LAYOUT_RTL) + { + if(!(fMode & TA_CENTER)) fMode |= TA_RIGHT; + } + Dc_Attr->flTextAlign = fMode & (TA_BASELINE|TA_UPDATECP|TA_CENTER); + return OldMode; } @@ -611,43 +612,43 @@ SetTextAlign(HDC hdc, COLORREF WINAPI SetTextColor( - HDC hdc, - COLORREF crColor + HDC hdc, + COLORREF crColor ) { - PDC_ATTR Dc_Attr; - COLORREF OldColor = CLR_INVALID; + PDC_ATTR Dc_Attr; + COLORREF OldColor = CLR_INVALID; #if 0 - if (GDI_HANDLE_GET_TYPE(hDC) != GDI_OBJECT_TYPE_DC) - { - if (GDI_HANDLE_GET_TYPE(hDC) == GDI_OBJECT_TYPE_METADC) - return MFDRV_SetTextColor( hDC, crColor ); - else + if (GDI_HANDLE_GET_TYPE(hDC) != GDI_OBJECT_TYPE_DC) { - PLDC pLDC = Dc_Attr->pvLDC; - if ( !pLDC ) - { - SetLastError(ERROR_INVALID_HANDLE); - return FALSE; - } - if (pLDC->iType == LDC_EMFLDC) - { - if return EMFDRV_SetTextColor( hDC, crColor ); - } + if (GDI_HANDLE_GET_TYPE(hDC) == GDI_OBJECT_TYPE_METADC) + return MFDRV_SetTextColor( hDC, crColor ); + else + { + PLDC pLDC = Dc_Attr->pvLDC; + if ( !pLDC ) + { + SetLastError(ERROR_INVALID_HANDLE); + return FALSE; + } + if (pLDC->iType == LDC_EMFLDC) + { + if return EMFDRV_SetTextColor( hDC, crColor ); + } + } } - } #endif - if (!GdiGetHandleUserData((HGDIOBJ) hdc, GDI_OBJECT_TYPE_DC, (PVOID) &Dc_Attr)) return OldColor; + if (!GdiGetHandleUserData((HGDIOBJ) hdc, GDI_OBJECT_TYPE_DC, (PVOID) &Dc_Attr)) return OldColor; - OldColor = (COLORREF) Dc_Attr->ulForegroundClr; - Dc_Attr->ulForegroundClr = (ULONG) crColor; + OldColor = (COLORREF) Dc_Attr->ulForegroundClr; + Dc_Attr->ulForegroundClr = (ULONG) crColor; - if ( Dc_Attr->crForegroundClr != crColor ) - { - Dc_Attr->ulDirty_ |= (DIRTY_TEXT|DIRTY_LINE|DIRTY_FILL); - Dc_Attr->crForegroundClr = crColor; - } - return OldColor; + if ( Dc_Attr->crForegroundClr != crColor ) + { + Dc_Attr->ulDirty_ |= (DIRTY_TEXT|DIRTY_LINE|DIRTY_FILL); + Dc_Attr->crForegroundClr = crColor; + } + return OldColor; } /* @@ -656,34 +657,34 @@ SetTextColor( BOOL WINAPI SetTextJustification( - HDC hdc, - int extra, - int breaks - ) + HDC hdc, + int extra, + int breaks +) { - PDC_ATTR Dc_Attr; + PDC_ATTR Dc_Attr; #if 0 - if (GDI_HANDLE_GET_TYPE(hDC) != GDI_OBJECT_TYPE_DC) - { - if (GDI_HANDLE_GET_TYPE(hDC) == GDI_OBJECT_TYPE_METADC) - return MFDRV_SetTextJustification( hdc, extra, breaks ) - else + if (GDI_HANDLE_GET_TYPE(hDC) != GDI_OBJECT_TYPE_DC) { - SetLastError(ERROR_INVALID_HANDLE); - return FALSE; - } + if (GDI_HANDLE_GET_TYPE(hDC) == GDI_OBJECT_TYPE_METADC) + return MFDRV_SetTextJustification( hdc, extra, breaks ) + else + { + SetLastError(ERROR_INVALID_HANDLE); + return FALSE; + } #endif - if (!GdiGetHandleUserData((HGDIOBJ) hdc, GDI_OBJECT_TYPE_DC, (PVOID) &Dc_Attr)) return FALSE; + if (!GdiGetHandleUserData((HGDIOBJ) hdc, GDI_OBJECT_TYPE_DC, (PVOID) &Dc_Attr)) return FALSE; - if (NtCurrentTeb()->GdiTebBatch.HDC == hdc) - { - if (Dc_Attr->ulDirty_ & DC_FONTTEXT_DIRTY) - { - NtGdiFlush(); // Sync up Dc_Attr from Kernel space. - Dc_Attr->ulDirty_ &= ~(DC_MODE_DIRTY|DC_FONTTEXT_DIRTY); - } - } - Dc_Attr->cBreak = breaks; - Dc_Attr->lBreakExtra = extra; - return TRUE; -} + if (NtCurrentTeb()->GdiTebBatch.HDC == hdc) + { + if (Dc_Attr->ulDirty_ & DC_FONTTEXT_DIRTY) + { + NtGdiFlush(); // Sync up Dc_Attr from Kernel space. + Dc_Attr->ulDirty_ &= ~(DC_MODE_DIRTY|DC_FONTTEXT_DIRTY); + } + } + Dc_Attr->cBreak = breaks; + Dc_Attr->lBreakExtra = extra; + return TRUE; + } diff --git a/reactos/dll/win32/gdi32/objects/utils.c b/reactos/dll/win32/gdi32/objects/utils.c index fb99ed85491..734d5df54c6 100644 --- a/reactos/dll/win32/gdi32/objects/utils.c +++ b/reactos/dll/win32/gdi32/objects/utils.c @@ -24,107 +24,107 @@ BOOL WINAPI CalculateColorTableSize( - CONST BITMAPINFOHEADER *BitmapInfoHeader, - UINT *ColorSpec, - UINT *ColorTableSize) + CONST BITMAPINFOHEADER *BitmapInfoHeader, + UINT *ColorSpec, + UINT *ColorTableSize) { - WORD BitCount; - DWORD ClrUsed; - DWORD Compression; + WORD BitCount; + DWORD ClrUsed; + DWORD Compression; - /* - * At first get some basic parameters from the passed BitmapInfoHeader - * structure. It can have one of the following formats: - * - BITMAPCOREHEADER (the oldest one with totally different layout - * from the others) - * - BITMAPINFOHEADER (the standard and most common header) - * - BITMAPV4HEADER (extension of BITMAPINFOHEADER) - * - BITMAPV5HEADER (extension of BITMAPV4HEADER) - */ + /* + * At first get some basic parameters from the passed BitmapInfoHeader + * structure. It can have one of the following formats: + * - BITMAPCOREHEADER (the oldest one with totally different layout + * from the others) + * - BITMAPINFOHEADER (the standard and most common header) + * - BITMAPV4HEADER (extension of BITMAPINFOHEADER) + * - BITMAPV5HEADER (extension of BITMAPV4HEADER) + */ - if (BitmapInfoHeader->biSize == sizeof(BITMAPCOREHEADER)) - { - BitCount = ((LPBITMAPCOREHEADER)BitmapInfoHeader)->bcBitCount; - ClrUsed = 0; - Compression = BI_RGB; - } - else - { - BitCount = BitmapInfoHeader->biBitCount; - ClrUsed = BitmapInfoHeader->biClrUsed; - Compression = BitmapInfoHeader->biCompression; - } + if (BitmapInfoHeader->biSize == sizeof(BITMAPCOREHEADER)) + { + BitCount = ((LPBITMAPCOREHEADER)BitmapInfoHeader)->bcBitCount; + ClrUsed = 0; + Compression = BI_RGB; + } + else + { + BitCount = BitmapInfoHeader->biBitCount; + ClrUsed = BitmapInfoHeader->biClrUsed; + Compression = BitmapInfoHeader->biCompression; + } - switch (Compression) - { - case BI_BITFIELDS: - if (*ColorSpec == DIB_PAL_COLORS) + switch (Compression) + { + case BI_BITFIELDS: + if (*ColorSpec == DIB_PAL_COLORS) *ColorSpec = DIB_RGB_COLORS; - if (BitCount != 16 && BitCount != 32) + if (BitCount != 16 && BitCount != 32) return FALSE; - /* - * For BITMAPV4HEADER/BITMAPV5HEADER the masks are included in - * the structure itself (bV4RedMask, bV4GreenMask, and bV4BlueMask). - * For BITMAPINFOHEADER the color masks are stored in the palette. - */ + /* + * For BITMAPV4HEADER/BITMAPV5HEADER the masks are included in + * the structure itself (bV4RedMask, bV4GreenMask, and bV4BlueMask). + * For BITMAPINFOHEADER the color masks are stored in the palette. + */ - if (BitmapInfoHeader->biSize > sizeof(BITMAPINFOHEADER)) + if (BitmapInfoHeader->biSize > sizeof(BITMAPINFOHEADER)) *ColorTableSize = 0; - else + else *ColorTableSize = 3; - return TRUE; + return TRUE; - case BI_RGB: - switch (BitCount) - { - case 1: - *ColorTableSize = ClrUsed ? min(ClrUsed, 2) : 2; - return TRUE; + case BI_RGB: + switch (BitCount) + { + case 1: + *ColorTableSize = ClrUsed ? min(ClrUsed, 2) : 2; + return TRUE; - case 4: - *ColorTableSize = ClrUsed ? min(ClrUsed, 16) : 16; - return TRUE; - - case 8: - *ColorTableSize = ClrUsed ? min(ClrUsed, 256) : 256; - return TRUE; - - default: - if (*ColorSpec == DIB_PAL_COLORS) - *ColorSpec = DIB_RGB_COLORS; - if (BitCount != 16 && BitCount != 24 && BitCount != 32) - return FALSE; - *ColorTableSize = ClrUsed; - return TRUE; - } - - case BI_RLE4: - if (BitCount == 4) - { + case 4: *ColorTableSize = ClrUsed ? min(ClrUsed, 16) : 16; return TRUE; - } - return FALSE; - case BI_RLE8: - if (BitCount == 8) - { + case 8: *ColorTableSize = ClrUsed ? min(ClrUsed, 256) : 256; return TRUE; - } - return FALSE; - case BI_JPEG: - case BI_PNG: - *ColorTableSize = ClrUsed; - return TRUE; + default: + if (*ColorSpec == DIB_PAL_COLORS) + *ColorSpec = DIB_RGB_COLORS; + if (BitCount != 16 && BitCount != 24 && BitCount != 32) + return FALSE; + *ColorTableSize = ClrUsed; + return TRUE; + } - default: - return FALSE; - } + case BI_RLE4: + if (BitCount == 4) + { + *ColorTableSize = ClrUsed ? min(ClrUsed, 16) : 16; + return TRUE; + } + return FALSE; + + case BI_RLE8: + if (BitCount == 8) + { + *ColorTableSize = ClrUsed ? min(ClrUsed, 256) : 256; + return TRUE; + } + return FALSE; + + case BI_JPEG: + case BI_PNG: + *ColorTableSize = ClrUsed; + return TRUE; + + default: + return FALSE; + } } /** @@ -170,142 +170,142 @@ CalculateColorTableSize( LPBITMAPINFO WINAPI ConvertBitmapInfo( - CONST BITMAPINFO *BitmapInfo, - UINT ColorSpec, - UINT *BitmapInfoSize, - BOOL FollowedByData) + CONST BITMAPINFO *BitmapInfo, + UINT ColorSpec, + UINT *BitmapInfoSize, + BOOL FollowedByData) { - LPBITMAPINFO NewBitmapInfo = (LPBITMAPINFO)BitmapInfo; - LPBITMAPCOREINFO CoreBitmapInfo = (LPBITMAPCOREINFO)BitmapInfo; - DWORD Size = 0; - ULONG DataSize = 0; - UINT PaletteEntryCount = 0; + LPBITMAPINFO NewBitmapInfo = (LPBITMAPINFO)BitmapInfo; + LPBITMAPCOREINFO CoreBitmapInfo = (LPBITMAPCOREINFO)BitmapInfo; + DWORD Size = 0; + ULONG DataSize = 0; + UINT PaletteEntryCount = 0; - /* - * At first check if the passed BitmapInfo structure has valid size. It - * can have one of these headers: BITMAPCOREHEADER, BITMAPINFOHEADER, - * BITMAPV4HEADER or BITMAPV5HEADER (see CalculateColorTableSize for - * description). - */ + /* + * At first check if the passed BitmapInfo structure has valid size. It + * can have one of these headers: BITMAPCOREHEADER, BITMAPINFOHEADER, + * BITMAPV4HEADER or BITMAPV5HEADER (see CalculateColorTableSize for + * description). + */ - if ( !BitmapInfo || - (BitmapInfo->bmiHeader.biSize != sizeof(BITMAPCOREHEADER) && - (BitmapInfo->bmiHeader.biSize < sizeof(BITMAPINFOHEADER) || - BitmapInfo->bmiHeader.biSize > sizeof(BITMAPV5HEADER)))) - { - return NULL; - } + if ( !BitmapInfo || + (BitmapInfo->bmiHeader.biSize != sizeof(BITMAPCOREHEADER) && + (BitmapInfo->bmiHeader.biSize < sizeof(BITMAPINFOHEADER) || + BitmapInfo->bmiHeader.biSize > sizeof(BITMAPV5HEADER)))) + { + return NULL; + } - /* - * Now calculate the color table size. Also if the bitmap info contains - * invalid color information it's rejected here. - */ + /* + * Now calculate the color table size. Also if the bitmap info contains + * invalid color information it's rejected here. + */ - if (!CalculateColorTableSize(&BitmapInfo->bmiHeader, &ColorSpec, - &PaletteEntryCount)) - { - return NULL; - } + if (!CalculateColorTableSize(&BitmapInfo->bmiHeader, &ColorSpec, + &PaletteEntryCount)) + { + return NULL; + } - /* - * Calculate the size of image data if applicable. We must be careful - * to do proper aligning on line ends. - */ + /* + * Calculate the size of image data if applicable. We must be careful + * to do proper aligning on line ends. + */ - if (FollowedByData) - { - DataSize = DIB_BitmapBitsSize((PBITMAPINFO)BitmapInfo ); - } + if (FollowedByData) + { + DataSize = DIB_BitmapBitsSize((PBITMAPINFO)BitmapInfo ); + } - /* - * If BitmapInfo was originally BITMAPCOREINFO then we need to convert - * it to the standard BITMAPINFO layout. - */ + /* + * If BitmapInfo was originally BITMAPCOREINFO then we need to convert + * it to the standard BITMAPINFO layout. + */ - if (BitmapInfo->bmiHeader.biSize == sizeof(BITMAPCOREHEADER)) - { - Size = sizeof(BITMAPINFOHEADER); - if (ColorSpec == DIB_RGB_COLORS) - Size += PaletteEntryCount * sizeof(RGBQUAD); - else - Size += PaletteEntryCount * sizeof(USHORT); - Size += DataSize; + if (BitmapInfo->bmiHeader.biSize == sizeof(BITMAPCOREHEADER)) + { + Size = sizeof(BITMAPINFOHEADER); + if (ColorSpec == DIB_RGB_COLORS) + Size += PaletteEntryCount * sizeof(RGBQUAD); + else + Size += PaletteEntryCount * sizeof(USHORT); + Size += DataSize; - NewBitmapInfo = RtlAllocateHeap(RtlGetProcessHeap(), 0, Size); - if (NewBitmapInfo == NULL) - { - return NULL; - } + NewBitmapInfo = RtlAllocateHeap(RtlGetProcessHeap(), 0, Size); + if (NewBitmapInfo == NULL) + { + return NULL; + } - NewBitmapInfo->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); - NewBitmapInfo->bmiHeader.biWidth = CoreBitmapInfo->bmciHeader.bcWidth; - NewBitmapInfo->bmiHeader.biHeight = CoreBitmapInfo->bmciHeader.bcHeight; - NewBitmapInfo->bmiHeader.biPlanes = CoreBitmapInfo->bmciHeader.bcPlanes; - NewBitmapInfo->bmiHeader.biBitCount = CoreBitmapInfo->bmciHeader.bcBitCount; - NewBitmapInfo->bmiHeader.biCompression = BI_RGB; - NewBitmapInfo->bmiHeader.biSizeImage = 0; - NewBitmapInfo->bmiHeader.biXPelsPerMeter = 0; - NewBitmapInfo->bmiHeader.biYPelsPerMeter = 0; - NewBitmapInfo->bmiHeader.biClrUsed = 0; - NewBitmapInfo->bmiHeader.biClrImportant = 0; + NewBitmapInfo->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); + NewBitmapInfo->bmiHeader.biWidth = CoreBitmapInfo->bmciHeader.bcWidth; + NewBitmapInfo->bmiHeader.biHeight = CoreBitmapInfo->bmciHeader.bcHeight; + NewBitmapInfo->bmiHeader.biPlanes = CoreBitmapInfo->bmciHeader.bcPlanes; + NewBitmapInfo->bmiHeader.biBitCount = CoreBitmapInfo->bmciHeader.bcBitCount; + NewBitmapInfo->bmiHeader.biCompression = BI_RGB; + NewBitmapInfo->bmiHeader.biSizeImage = 0; + NewBitmapInfo->bmiHeader.biXPelsPerMeter = 0; + NewBitmapInfo->bmiHeader.biYPelsPerMeter = 0; + NewBitmapInfo->bmiHeader.biClrUsed = 0; + NewBitmapInfo->bmiHeader.biClrImportant = 0; - if (PaletteEntryCount != 0) - { - if (ColorSpec == DIB_RGB_COLORS) - { - ULONG Index; - - for (Index = 0; Index < PaletteEntryCount; Index++) + if (PaletteEntryCount != 0) + { + if (ColorSpec == DIB_RGB_COLORS) { - NewBitmapInfo->bmiColors[Index].rgbRed = - CoreBitmapInfo->bmciColors[Index].rgbtRed; - NewBitmapInfo->bmiColors[Index].rgbGreen = - CoreBitmapInfo->bmciColors[Index].rgbtGreen; - NewBitmapInfo->bmiColors[Index].rgbBlue = - CoreBitmapInfo->bmciColors[Index].rgbtBlue; - NewBitmapInfo->bmiColors[Index].rgbReserved = 0; + ULONG Index; + + for (Index = 0; Index < PaletteEntryCount; Index++) + { + NewBitmapInfo->bmiColors[Index].rgbRed = + CoreBitmapInfo->bmciColors[Index].rgbtRed; + NewBitmapInfo->bmiColors[Index].rgbGreen = + CoreBitmapInfo->bmciColors[Index].rgbtGreen; + NewBitmapInfo->bmiColors[Index].rgbBlue = + CoreBitmapInfo->bmciColors[Index].rgbtBlue; + NewBitmapInfo->bmiColors[Index].rgbReserved = 0; + } } - } - else - { - RtlCopyMemory(NewBitmapInfo->bmiColors, - CoreBitmapInfo->bmciColors, - PaletteEntryCount * sizeof(USHORT)); - } - } + else + { + RtlCopyMemory(NewBitmapInfo->bmiColors, + CoreBitmapInfo->bmciColors, + PaletteEntryCount * sizeof(USHORT)); + } + } - if (FollowedByData) - { - ULONG_PTR NewDataPtr, OldDataPtr; + if (FollowedByData) + { + ULONG_PTR NewDataPtr, OldDataPtr; - if (ColorSpec == DIB_RGB_COLORS) - { - NewDataPtr = (ULONG_PTR)(NewBitmapInfo->bmiColors + - PaletteEntryCount); - OldDataPtr = (ULONG_PTR)(CoreBitmapInfo->bmciColors + - PaletteEntryCount); - } - else - { - NewDataPtr = (ULONG_PTR)(NewBitmapInfo->bmiColors) + - PaletteEntryCount * sizeof(USHORT); - OldDataPtr = (ULONG_PTR)(CoreBitmapInfo->bmciColors) + - PaletteEntryCount * sizeof(USHORT); - } + if (ColorSpec == DIB_RGB_COLORS) + { + NewDataPtr = (ULONG_PTR)(NewBitmapInfo->bmiColors + + PaletteEntryCount); + OldDataPtr = (ULONG_PTR)(CoreBitmapInfo->bmciColors + + PaletteEntryCount); + } + else + { + NewDataPtr = (ULONG_PTR)(NewBitmapInfo->bmiColors) + + PaletteEntryCount * sizeof(USHORT); + OldDataPtr = (ULONG_PTR)(CoreBitmapInfo->bmciColors) + + PaletteEntryCount * sizeof(USHORT); + } - RtlCopyMemory((PVOID)NewDataPtr, (PVOID)OldDataPtr, DataSize); - } - } + RtlCopyMemory((PVOID)NewDataPtr, (PVOID)OldDataPtr, DataSize); + } + } - Size = NewBitmapInfo->bmiHeader.biSize; - if (ColorSpec == DIB_RGB_COLORS) - Size += PaletteEntryCount * sizeof(RGBQUAD); - else - Size += PaletteEntryCount * sizeof(USHORT); - Size += DataSize; - *BitmapInfoSize = Size; + Size = NewBitmapInfo->bmiHeader.biSize; + if (ColorSpec == DIB_RGB_COLORS) + Size += PaletteEntryCount * sizeof(RGBQUAD); + else + Size += PaletteEntryCount * sizeof(USHORT); + Size += DataSize; + *BitmapInfoSize = Size; - return NewBitmapInfo; + return NewBitmapInfo; } VOID @@ -315,21 +315,21 @@ LogFontA2W(LPLOGFONTW pW, CONST LOGFONTA *pA) #define COPYS(f,len) MultiByteToWideChar ( CP_THREAD_ACP, 0, pA->f, len, pW->f, len ) #define COPYN(f) pW->f = pA->f - COPYN(lfHeight); - COPYN(lfWidth); - COPYN(lfEscapement); - COPYN(lfOrientation); - COPYN(lfWeight); - COPYN(lfItalic); - COPYN(lfUnderline); - COPYN(lfStrikeOut); - COPYN(lfCharSet); - COPYN(lfOutPrecision); - COPYN(lfClipPrecision); - COPYN(lfQuality); - COPYN(lfPitchAndFamily); - COPYS(lfFaceName,LF_FACESIZE); - pW->lfFaceName[LF_FACESIZE - 1] = '\0'; + COPYN(lfHeight); + COPYN(lfWidth); + COPYN(lfEscapement); + COPYN(lfOrientation); + COPYN(lfWeight); + COPYN(lfItalic); + COPYN(lfUnderline); + COPYN(lfStrikeOut); + COPYN(lfCharSet); + COPYN(lfOutPrecision); + COPYN(lfClipPrecision); + COPYN(lfQuality); + COPYN(lfPitchAndFamily); + COPYS(lfFaceName,LF_FACESIZE); + pW->lfFaceName[LF_FACESIZE - 1] = '\0'; #undef COPYN #undef COPYS @@ -342,21 +342,21 @@ LogFontW2A(LPLOGFONTA pA, CONST LOGFONTW *pW) #define COPYS(f,len) WideCharToMultiByte ( CP_THREAD_ACP, 0, pW->f, len, pA->f, len, NULL, NULL ) #define COPYN(f) pA->f = pW->f - COPYN(lfHeight); - COPYN(lfWidth); - COPYN(lfEscapement); - COPYN(lfOrientation); - COPYN(lfWeight); - COPYN(lfItalic); - COPYN(lfUnderline); - COPYN(lfStrikeOut); - COPYN(lfCharSet); - COPYN(lfOutPrecision); - COPYN(lfClipPrecision); - COPYN(lfQuality); - COPYN(lfPitchAndFamily); - COPYS(lfFaceName,LF_FACESIZE); - pA->lfFaceName[LF_FACESIZE - 1] = '\0'; + COPYN(lfHeight); + COPYN(lfWidth); + COPYN(lfEscapement); + COPYN(lfOrientation); + COPYN(lfWeight); + COPYN(lfItalic); + COPYN(lfUnderline); + COPYN(lfStrikeOut); + COPYN(lfCharSet); + COPYN(lfOutPrecision); + COPYN(lfClipPrecision); + COPYN(lfQuality); + COPYN(lfPitchAndFamily); + COPYS(lfFaceName,LF_FACESIZE); + pA->lfFaceName[LF_FACESIZE - 1] = '\0'; #undef COPYN #undef COPYS @@ -369,13 +369,13 @@ EnumLogFontExW2A( LPENUMLOGFONTEXA fontA, CONST ENUMLOGFONTEXW *fontW ) LogFontW2A( (LPLOGFONTA)fontA, (CONST LOGFONTW *)fontW ); WideCharToMultiByte( CP_THREAD_ACP, 0, fontW->elfFullName, -1, - (LPSTR) fontA->elfFullName, LF_FULLFACESIZE, NULL, NULL ); + (LPSTR) fontA->elfFullName, LF_FULLFACESIZE, NULL, NULL ); fontA->elfFullName[LF_FULLFACESIZE-1] = '\0'; WideCharToMultiByte( CP_THREAD_ACP, 0, fontW->elfStyle, -1, - (LPSTR) fontA->elfStyle, LF_FACESIZE, NULL, NULL ); + (LPSTR) fontA->elfStyle, LF_FACESIZE, NULL, NULL ); fontA->elfStyle[LF_FACESIZE-1] = '\0'; WideCharToMultiByte( CP_THREAD_ACP, 0, fontW->elfScript, -1, - (LPSTR) fontA->elfScript, LF_FACESIZE, NULL, NULL ); + (LPSTR) fontA->elfScript, LF_FACESIZE, NULL, NULL ); fontA->elfScript[LF_FACESIZE-1] = '\0'; } From 0858e66dd127ef1cb24ad652b05a93ad9c173513 Mon Sep 17 00:00:00 2001 From: Aleksey Bragin Date: Mon, 27 Dec 2010 16:49:21 +0000 Subject: [PATCH 137/181] [FASTFAT_NEW] - Substantially improve FatiCreate routine, to handle previously unhandled cases, fix wrong code structure in some places, add a stub for further implementation of a new file creation branch. - Hackskip setting delay-on-close for a file for now (with a debug print reminder!) svn path=/trunk/; revision=50164 --- .../drivers/filesystems/fastfat_new/cleanup.c | 3 +- .../drivers/filesystems/fastfat_new/create.c | 270 ++++++++++++------ 2 files changed, 185 insertions(+), 88 deletions(-) diff --git a/reactos/drivers/filesystems/fastfat_new/cleanup.c b/reactos/drivers/filesystems/fastfat_new/cleanup.c index dbc1f1b3d96..3414c97a94a 100644 --- a/reactos/drivers/filesystems/fastfat_new/cleanup.c +++ b/reactos/drivers/filesystems/fastfat_new/cleanup.c @@ -221,7 +221,8 @@ FatiCleanup(PFAT_IRP_CONTEXT IrpContext, PIRP Irp) Fcb->Condition == FcbGood) { /* Yes, a delayed one */ - SetFlag(Fcb->State, FCB_STATE_DELAY_CLOSE); + //SetFlag(Fcb->State, FCB_STATE_DELAY_CLOSE); + DPRINT1("Setting a delay on close for some reason for FCB %p, FF handle %p, file name '%wZ'\n", Fcb, Fcb->FatHandle, &Fcb->FullFileName); } /* Unlock all file locks */ diff --git a/reactos/drivers/filesystems/fastfat_new/create.c b/reactos/drivers/filesystems/fastfat_new/create.c index ce8cc90522d..de84dc90b99 100644 --- a/reactos/drivers/filesystems/fastfat_new/create.c +++ b/reactos/drivers/filesystems/fastfat_new/create.c @@ -522,7 +522,7 @@ FatiCreate(IN PFAT_IRP_CONTEXT IrpContext, NTSTATUS Status; IO_STATUS_BLOCK Iosb; PIO_STACK_LOCATION IrpSp; - BOOLEAN EndBackslash = FALSE, OpenedAsDos; + BOOLEAN EndBackslash = FALSE, OpenedAsDos, FirstRun = TRUE; UNICODE_STRING RemainingPart, FirstName, NextName, FileNameUpcased; OEM_STRING AnsiFirstName; FF_ERROR FfError; @@ -592,6 +592,13 @@ FatiCreate(IN PFAT_IRP_CONTEXT IrpContext, if (RelatedFO) FileObject->Vpb = RelatedFO->Vpb; + /* Reject open by id */ + if (Options & FILE_OPEN_BY_FILE_ID) + { + FatCompleteRequest(IrpContext, Irp, STATUS_INVALID_PARAMETER); + return STATUS_INVALID_PARAMETER; + } + /* Prepare file attributes mask */ FileAttributes &= (FILE_ATTRIBUTE_READONLY | FILE_ATTRIBUTE_HIDDEN | @@ -652,12 +659,22 @@ FatiCreate(IN PFAT_IRP_CONTEXT IrpContext, DPRINT1("This volume is locked\n"); Status = STATUS_ACCESS_DENIED; + /* Set volume dismount status */ + if (Vcb->Condition != VcbGood) + Status = STATUS_VOLUME_DISMOUNTED; + /* Cleanup and return */ FatReleaseVcb(IrpContext, Vcb); + FatCompleteRequest(IrpContext, Irp, Status); return Status; } - // TODO: Check if the volume is write protected and disallow DELETE_ON_CLOSE + /* Check if the volume is write protected and disallow DELETE_ON_CLOSE */ + if (DeleteOnClose & FlagOn(Vcb->State, VCB_STATE_FLAG_WRITE_PROTECTED)) + { + ASSERT(FALSE); + return STATUS_NOT_IMPLEMENTED; + } // TODO: Make sure EAs aren't supported on FAT32 @@ -716,18 +733,24 @@ FatiCreate(IN PFAT_IRP_CONTEXT IrpContext, { DPRINT1("Invalid file object!\n"); + Status = STATUS_OBJECT_PATH_NOT_FOUND; + /* Cleanup and return */ FatReleaseVcb(IrpContext, Vcb); - return STATUS_OBJECT_PATH_NOT_FOUND; + FatCompleteRequest(IrpContext, Irp, Status); + return Status; } /* File path must be relative */ if (FileName.Length != 0 && FileName.Buffer[0] == L'\\') { + Status = STATUS_OBJECT_NAME_INVALID; + /* The name is absolute, fail */ FatReleaseVcb(IrpContext, Vcb); - return STATUS_OBJECT_NAME_INVALID; + FatCompleteRequest(IrpContext, Irp, Status); + return Status; } /* Make sure volume is the same */ @@ -751,18 +774,34 @@ FatiCreate(IN PFAT_IRP_CONTEXT IrpContext, if (NonDirectoryFile) { DPRINT1("Trying to open root dir as a file\n"); + Status = STATUS_FILE_IS_A_DIRECTORY; /* Cleanup and return */ FatReleaseVcb(IrpContext, Vcb); - return STATUS_FILE_IS_A_DIRECTORY; + FatCompleteRequest(IrpContext, Irp, Status); + return Status; + } + + /* Check for target directory on a root dir */ + if (OpenTargetDirectory) + { + Status = STATUS_INVALID_PARAMETER; + + /* Cleanup and return */ + FatReleaseVcb(IrpContext, Vcb); + FatCompleteRequest(IrpContext, Irp, Status); + return Status; } /* Check delete on close on a root dir */ if (DeleteOnClose) { + Status = STATUS_CANNOT_DELETE; + /* Cleanup and return */ FatReleaseVcb(IrpContext, Vcb); - return STATUS_CANNOT_DELETE; + FatCompleteRequest(IrpContext, Irp, Status); + return Status; } /* Call root directory open routine */ @@ -777,6 +816,7 @@ FatiCreate(IN PFAT_IRP_CONTEXT IrpContext, /* Cleanup and return */ FatReleaseVcb(IrpContext, Vcb); + FatCompleteRequest(IrpContext, Irp, Iosb.Status); return Iosb.Status; } else @@ -910,6 +950,27 @@ FatiCreate(IN PFAT_IRP_CONTEXT IrpContext, } } + /* Treat page file in a special way */ + if (IsPagingFile) + { + UNIMPLEMENTED; + // FIXME: System file too + } + + /* Make sure there is no pending delete on a higher-level FCB */ + if (Fcb->State & FCB_STATE_DELETE_ON_CLOSE) + { + Iosb.Status = STATUS_DELETE_PENDING; + + /* Cleanup and return */ + FatReleaseVcb(IrpContext, Vcb); + + /* Complete the request */ + FatCompleteRequest(IrpContext, Irp, Iosb.Status); + + return Iosb.Status; + } + /* We have a valid FCB now */ if (!RemainingPart.Length) { @@ -1038,23 +1099,34 @@ FatiCreate(IN PFAT_IRP_CONTEXT IrpContext, ParentDcb = Fcb; while (TRUE) { - FsRtlDissectName(RemainingPart, &FirstName, &RemainingPart); - - /* Check for validity */ - if ((RemainingPart.Length && RemainingPart.Buffer[0] == L'\\') || - (NextName.Length > 255 * sizeof(WCHAR))) + if (FirstRun) { - /* The name is invalid */ - DPRINT1("Invalid name found\n"); - Iosb.Status = STATUS_OBJECT_NAME_INVALID; - ASSERT(FALSE); + RemainingPart = NextName; + if (AnsiFirstName.Length) + Status = STATUS_SUCCESS; + else + Status = STATUS_UNMAPPABLE_CHARACTER; } + else + { + FsRtlDissectName(RemainingPart, &FirstName, &RemainingPart); - /* Convert the name to ANSI */ - AnsiFirstName.Buffer = ExAllocatePool(PagedPool, FirstName.Length); - AnsiFirstName.Length = 0; - AnsiFirstName.MaximumLength = FirstName.Length; - Status = RtlUpcaseUnicodeStringToCountedOemString(&AnsiFirstName, &FirstName, FALSE); + /* Check for validity */ + if ((RemainingPart.Length && RemainingPart.Buffer[0] == L'\\') || + (NextName.Length > 255 * sizeof(WCHAR))) + { + /* The name is invalid */ + DPRINT1("Invalid name found\n"); + Iosb.Status = STATUS_OBJECT_NAME_INVALID; + ASSERT(FALSE); + } + + /* Convert the name to ANSI */ + AnsiFirstName.Buffer = ExAllocatePool(PagedPool, FirstName.Length); + AnsiFirstName.Length = 0; + AnsiFirstName.MaximumLength = FirstName.Length; + Status = RtlUpcaseUnicodeStringToCountedOemString(&AnsiFirstName, &FirstName, FALSE); + } if (!NT_SUCCESS(Status)) { @@ -1087,90 +1159,114 @@ FatiCreate(IN PFAT_IRP_CONTEXT IrpContext, } /* Check, if path is a directory or a file */ - if (FfError == FF_ERR_FILE_OBJECT_IS_A_DIR) + if (FfError == FF_ERR_FILE_OBJECT_IS_A_DIR || + FfError == FF_ERR_NONE) { - if (NonDirectoryFile) + if (FfError == FF_ERR_FILE_OBJECT_IS_A_DIR) { - DPRINT1("Can't open dir as a file\n"); + if (NonDirectoryFile) + { + DPRINT1("Can't open dir as a file\n"); + + /* Unlock VCB */ + FatReleaseVcb(IrpContext, Vcb); + + /* Complete the request */ + Iosb.Status = STATUS_FILE_IS_A_DIRECTORY; + FatCompleteRequest(IrpContext, Irp, Iosb.Status); + return Iosb.Status; + } + + /* Open this directory */ + Iosb = FatiOpenExistingDir(IrpContext, + FileObject, + Vcb, + ParentDcb, + DesiredAccess, + ShareAccess, + AllocationSize, + EaBuffer, + EaLength, + FileAttributes, + CreateDisposition, + DeleteOnClose); + + Irp->IoStatus.Information = Iosb.Information; /* Unlock VCB */ FatReleaseVcb(IrpContext, Vcb); /* Complete the request */ - Iosb.Status = STATUS_FILE_IS_A_DIRECTORY; FatCompleteRequest(IrpContext, Irp, Iosb.Status); + return Iosb.Status; } + else + { + /* This is opening an existing file */ + if (OpenDirectory) + { + /* But caller wanted a dir */ + Status = STATUS_NOT_A_DIRECTORY; - /* Open this directory */ - Iosb = FatiOpenExistingDir(IrpContext, - FileObject, - Vcb, - ParentDcb, - DesiredAccess, - ShareAccess, - AllocationSize, - EaBuffer, - EaLength, - FileAttributes, - CreateDisposition, - DeleteOnClose); + /* Unlock VCB */ + FatReleaseVcb(IrpContext, Vcb); - Irp->IoStatus.Information = Iosb.Information; + /* Complete the request */ + FatCompleteRequest(IrpContext, Irp, Status); - /* Unlock VCB */ - FatReleaseVcb(IrpContext, Vcb); + return Status; + } - /* Complete the request */ - FatCompleteRequest(IrpContext, Irp, Iosb.Status); + /* If end backslash here, then it's definately not permitted, + since we're opening files here */ + if (EndBackslash) + { + /* Unlock VCB */ + FatReleaseVcb(IrpContext, Vcb); - return Iosb.Status; + /* Complete the request */ + Iosb.Status = STATUS_OBJECT_NAME_INVALID; + FatCompleteRequest(IrpContext, Irp, Iosb.Status); + return Iosb.Status; + } + + /* Try to open the file */ + Iosb = FatiOpenExistingFile(IrpContext, + FileObject, + Vcb, + ParentDcb, + DesiredAccess, + ShareAccess, + AllocationSize, + EaBuffer, + EaLength, + FileAttributes, + CreateDisposition, + FALSE, + DeleteOnClose, + OpenedAsDos); + + /* In case of success set cache supported flag */ + if (NT_SUCCESS(Iosb.Status) && !NoIntermediateBuffering) + { + SetFlag(FileObject->Flags, FO_CACHE_SUPPORTED); + } + + Irp->IoStatus.Information = Iosb.Information; + + /* Unlock VCB */ + FatReleaseVcb(IrpContext, Vcb); + + /* Complete the request */ + FatCompleteRequest(IrpContext, Irp, Iosb.Status); + + return Iosb.Status; + } } - /* If end backslash here, then it's definately not permitted, - since we're opening files here */ - if (EndBackslash) - { - /* Unlock VCB */ - FatReleaseVcb(IrpContext, Vcb); - - /* Complete the request */ - Iosb.Status = STATUS_OBJECT_NAME_INVALID; - FatCompleteRequest(IrpContext, Irp, Iosb.Status); - return Iosb.Status; - } - - /* Try to open the file */ - Iosb = FatiOpenExistingFile(IrpContext, - FileObject, - Vcb, - ParentDcb, - DesiredAccess, - ShareAccess, - AllocationSize, - EaBuffer, - EaLength, - FileAttributes, - CreateDisposition, - FALSE, - DeleteOnClose, - OpenedAsDos); - - /* In case of success set cache supported flag */ - if (NT_SUCCESS(Iosb.Status) && !NoIntermediateBuffering) - { - SetFlag(FileObject->Flags, FO_CACHE_SUPPORTED); - } - - Irp->IoStatus.Information = Iosb.Information; - - /* Unlock VCB */ - FatReleaseVcb(IrpContext, Vcb); - - /* Complete the request */ - FatCompleteRequest(IrpContext, Irp, Iosb.Status); - - return Iosb.Status; + /* We come here only in the case when a new file is created */ + ASSERT(FALSE); } NTSTATUS From ce5c1f3bcb507be6756fa47e0ed204bce2b3effd Mon Sep 17 00:00:00 2001 From: Amine Khaldi Date: Mon, 27 Dec 2010 17:51:08 +0000 Subject: [PATCH 138/181] [CRT] - Add missing _A_VOLID definition. svn path=/trunk/; revision=50165 --- reactos/include/crt/dos.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/reactos/include/crt/dos.h b/reactos/include/crt/dos.h index 3b3ac7d8af7..867326ab176 100644 --- a/reactos/include/crt/dos.h +++ b/reactos/include/crt/dos.h @@ -30,8 +30,9 @@ extern "C" { #define _A_RDONLY 0x01 #define _A_HIDDEN 0x02 #define _A_SYSTEM 0x04 +#define _A_VOLID 0x08 #define _A_SUBDIR 0x10 -#define _A_ARCH 0x20 +#define _A_ARCH 0x20 #ifndef _GETDISKFREE_DEFINED #define _GETDISKFREE_DEFINED From f59d1d7987f76b18ecd532bde8589c4250b4a09e Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Mon, 27 Dec 2010 17:55:53 +0000 Subject: [PATCH 139/181] [PSEH] Allow configuration of native SEH vs PSEH vs dummy PSEH with macro definitions (USE_NATIVE_SEH, USE_DUMMY_PSEH) svn path=/trunk/; revision=50166 --- reactos/include/reactos/libs/pseh/pseh2.h | 68 ++++++++++------------- 1 file changed, 29 insertions(+), 39 deletions(-) diff --git a/reactos/include/reactos/libs/pseh/pseh2.h b/reactos/include/reactos/libs/pseh/pseh2.h index 6c473a4c43d..776864aae86 100644 --- a/reactos/include/reactos/libs/pseh/pseh2.h +++ b/reactos/include/reactos/libs/pseh/pseh2.h @@ -19,16 +19,37 @@ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifdef _M_AMD64 -#include "pseh2_64.h" -#else #ifndef KJK_PSEH2_H_ #define KJK_PSEH2_H_ -#if !defined (__arm__) && !defined(__clang__) +#if defined(USE_DUMMY_PSEH) || defined (__arm__) || defined(__clang__) || defined(_M_AMD64) + +#define _SEH2_TRY { +#define _SEH2_FINALLY } { +#define _SEH2_EXCEPT(...) } if (0) { +#define _SEH2_END } +#define _SEH2_GetExceptionInformation() +#define _SEH2_GetExceptionCode() 0 +#define _SEH2_AbnormalTermination() +#define _SEH2_YIELD(STMT_) STMT_ +#define _SEH2_LEAVE + +#elif defined(USE_NATIVE_SEH) || defined(_MSC_VER) + +#include +#define _SEH2_TRY __try +#define _SEH2_FINALLY __finally +#define _SEH2_EXCEPT(...) __except(__VA_ARGS__) +#define _SEH2_END +#define _SEH2_GetExceptionInformation() (GetExceptionInformation()) +#define _SEH2_GetExceptionCode() (GetExceptionCode()) +#define _SEH2_AbnormalTermination() (AbnormalTermination()) +#define _SEH2_YIELD(STMT_) STMT_ +#define _SEH2_LEAVE __leave + +#elif defined(__GNUC__) -#if defined(__GNUC__) struct _EXCEPTION_RECORD; struct _EXCEPTION_POINTERS; struct _CONTEXT; @@ -76,8 +97,7 @@ typedef struct __SEH2HandleTryLevel _SEH2HandleTryLevel_t; #ifdef __cplusplus -extern "C" -{ +extern "C" { #endif extern int __cdecl _SEH2EnterFrameAndTrylevel(_SEH2Frame_t *, volatile _SEH2TryLevel_t *); @@ -369,41 +389,11 @@ extern void __cdecl _SEH2Return(void); __SEH_END_SCOPE_CHAIN; -#else - -#include - -#define _SEH2_TRY __try -#define _SEH2_FINALLY __finally -#define _SEH2_EXCEPT(...) __except(__VA_ARGS__) -#define _SEH2_END - -#define _SEH2_GetExceptionInformation() (GetExceptionInformation()) -#define _SEH2_GetExceptionCode() (GetExceptionCode()) -#define _SEH2_AbnormalTermination() (AbnormalTermination()) - -#define _SEH2_YIELD(STMT_) STMT_ -#define _SEH2_LEAVE __leave - -#endif #else - -#define _SEH2_TRY { -#define _SEH2_FINALLY } { -#define _SEH2_EXCEPT(...) } if (0) { -#define _SEH2_END } - -#define _SEH2_GetExceptionInformation() -#define _SEH2_GetExceptionCode() 0 -#define _SEH2_AbnormalTermination() - -#define _SEH2_YIELD(STMT_) STMT_ -#define _SEH2_LEAVE - +#error no PSEH support #endif -#endif -#endif +#endif /* !KJK_PSEH2_H_ */ /* EOF */ From 18204992eae775c0be1b7908806875d4287274ae Mon Sep 17 00:00:00 2001 From: Pierre Schweitzer Date: Mon, 27 Dec 2010 18:11:35 +0000 Subject: [PATCH 140/181] [FASTFAT] MagicValue--; ThanksTo(James, Amine); /* EOF */ svn path=/trunk/; revision=50167 --- reactos/drivers/filesystems/fastfat/finfo.c | 2 +- reactos/drivers/filesystems/fastfat/vfat.h | 1 + reactos/drivers/filesystems/fastfat/volume.c | 4 ++-- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/reactos/drivers/filesystems/fastfat/finfo.c b/reactos/drivers/filesystems/fastfat/finfo.c index 11618a5d8f6..5b18261d6d9 100644 --- a/reactos/drivers/filesystems/fastfat/finfo.c +++ b/reactos/drivers/filesystems/fastfat/finfo.c @@ -152,7 +152,7 @@ VfatSetBasicInformation(PFILE_OBJECT FileObject, ASSERT(NULL != DeviceExt); ASSERT(NULL != BasicInfo); /* Check volume label bit */ - ASSERT(0 == (*FCB->Attributes & 0x08)); + ASSERT(0 == (*FCB->Attributes & _A_VOLID)); if (FCB->Flags & FCB_IS_FATX_ENTRY) { diff --git a/reactos/drivers/filesystems/fastfat/vfat.h b/reactos/drivers/filesystems/fastfat/vfat.h index 3521d31a36d..a2a9983260d 100644 --- a/reactos/drivers/filesystems/fastfat/vfat.h +++ b/reactos/drivers/filesystems/fastfat/vfat.h @@ -2,6 +2,7 @@ #include #include #include +#include #define USE_ROS_CC_AND_FS diff --git a/reactos/drivers/filesystems/fastfat/volume.c b/reactos/drivers/filesystems/fastfat/volume.c index 6fd04800e5f..3231fbc3cf2 100644 --- a/reactos/drivers/filesystems/fastfat/volume.c +++ b/reactos/drivers/filesystems/fastfat/volume.c @@ -216,7 +216,7 @@ FsdSetFsLabelInformation(PDEVICE_OBJECT DeviceObject, { RtlCopyMemory(VolumeLabelDirEntry.FatX.Filename, cString, LabelLen); memset(&VolumeLabelDirEntry.FatX.Filename[LabelLen], ' ', 42 - LabelLen); - VolumeLabelDirEntry.FatX.Attrib = 0x08; + VolumeLabelDirEntry.FatX.Attrib = _A_VOLID; } else { @@ -230,7 +230,7 @@ FsdSetFsLabelInformation(PDEVICE_OBJECT DeviceObject, { memset(&VolumeLabelDirEntry.Fat.Filename[LabelLen], ' ', sizeof(VolumeLabelDirEntry.Fat.Filename) - LabelLen); } - VolumeLabelDirEntry.Fat.Attrib = 0x08; + VolumeLabelDirEntry.Fat.Attrib = _A_VOLID; } pRootFcb = vfatOpenRootFCB(DeviceExt); From 52891961b64260c82fefc76d2cff60526b230487 Mon Sep 17 00:00:00 2001 From: Aleksey Bragin Date: Mon, 27 Dec 2010 18:14:24 +0000 Subject: [PATCH 141/181] [FASTFAT_NEW] - Some fixes to the previous commit. svn path=/trunk/; revision=50168 --- .../drivers/filesystems/fastfat_new/create.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/reactos/drivers/filesystems/fastfat_new/create.c b/reactos/drivers/filesystems/fastfat_new/create.c index de84dc90b99..6f72a0b0516 100644 --- a/reactos/drivers/filesystems/fastfat_new/create.c +++ b/reactos/drivers/filesystems/fastfat_new/create.c @@ -1106,6 +1106,9 @@ FatiCreate(IN PFAT_IRP_CONTEXT IrpContext, Status = STATUS_SUCCESS; else Status = STATUS_UNMAPPABLE_CHARACTER; + + /* First run init is done */ + FirstRun = FALSE; } else { @@ -1158,8 +1161,9 @@ FatiCreate(IN PFAT_IRP_CONTEXT IrpContext, UNIMPLEMENTED; } - /* Check, if path is a directory or a file */ + /* Check, if path is a existing directory or file */ if (FfError == FF_ERR_FILE_OBJECT_IS_A_DIR || + FfError == FF_ERR_FILE_ALREADY_OPEN || FfError == FF_ERR_NONE) { if (FfError == FF_ERR_FILE_OBJECT_IS_A_DIR) @@ -1266,7 +1270,18 @@ FatiCreate(IN PFAT_IRP_CONTEXT IrpContext, } /* We come here only in the case when a new file is created */ - ASSERT(FALSE); + //ASSERT(FALSE); + DPRINT1("TODO: Create a new file/directory, called '%wZ'\n", &IrpSp->FileObject->FileName); + + Status = STATUS_NOT_IMPLEMENTED; + + /* Unlock VCB */ + FatReleaseVcb(IrpContext, Vcb); + + /* Complete the request */ + FatCompleteRequest(IrpContext, Irp, Status); + + return Status; } NTSTATUS From 9670bc63c4941abdc5d30a36ff8867b772e46d54 Mon Sep 17 00:00:00 2001 From: Pierre Schweitzer Date: Mon, 27 Dec 2010 21:38:40 +0000 Subject: [PATCH 142/181] [FASTFAT] Remove unused vars ~ svn path=/trunk/; revision=50173 --- reactos/drivers/filesystems/fastfat/rw.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/reactos/drivers/filesystems/fastfat/rw.c b/reactos/drivers/filesystems/fastfat/rw.c index 519ef128e32..bbcae945c83 100644 --- a/reactos/drivers/filesystems/fastfat/rw.c +++ b/reactos/drivers/filesystems/fastfat/rw.c @@ -123,7 +123,6 @@ VfatReadFileData (PVFAT_IRP_CONTEXT IrpContext, PDEVICE_EXTENSION DeviceExt; BOOLEAN First = TRUE; PVFATFCB Fcb; - PVFATCCB Ccb; NTSTATUS Status; ULONG BytesDone; ULONG BytesPerSector; @@ -145,7 +144,6 @@ VfatReadFileData (PVFAT_IRP_CONTEXT IrpContext, *LengthRead = 0; - Ccb = (PVFATCCB)IrpContext->FileObject->FsContext2; Fcb = IrpContext->FileObject->FsContext; BytesPerSector = DeviceExt->FatInfo.BytesPerSector; BytesPerCluster = DeviceExt->FatInfo.BytesPerCluster; @@ -328,7 +326,6 @@ VfatWriteFileData(PVFAT_IRP_CONTEXT IrpContext, { PDEVICE_EXTENSION DeviceExt; PVFATFCB Fcb; - PVFATCCB Ccb; ULONG Count; ULONG FirstCluster; ULONG CurrentCluster; @@ -352,7 +349,6 @@ VfatWriteFileData(PVFAT_IRP_CONTEXT IrpContext, ASSERT(IrpContext->FileObject); ASSERT(IrpContext->FileObject->FsContext2 != NULL); - Ccb = (PVFATCCB)IrpContext->FileObject->FsContext2; Fcb = IrpContext->FileObject->FsContext; BytesPerCluster = DeviceExt->FatInfo.BytesPerCluster; BytesPerSector = DeviceExt->FatInfo.BytesPerSector; From 18910c84c69771ec01e409c1534195dde87a64d3 Mon Sep 17 00:00:00 2001 From: Aleksey Bragin Date: Mon, 27 Dec 2010 22:02:11 +0000 Subject: [PATCH 143/181] [FASTFAT_NEW] - Don't use same name for a local boolean var and global enum. Spotted by Pierre. svn path=/trunk/; revision=50175 --- reactos/drivers/filesystems/fastfat_new/create.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/reactos/drivers/filesystems/fastfat_new/create.c b/reactos/drivers/filesystems/fastfat_new/create.c index 6f72a0b0516..3a24010b5b9 100644 --- a/reactos/drivers/filesystems/fastfat_new/create.c +++ b/reactos/drivers/filesystems/fastfat_new/create.c @@ -493,7 +493,7 @@ FatiCreate(IN PFAT_IRP_CONTEXT IrpContext, BOOLEAN OpenDirectory; BOOLEAN IsPagingFile; BOOLEAN OpenTargetDirectory; - BOOLEAN DirectoryFile; + BOOLEAN IsDirectoryFile; BOOLEAN NonDirectoryFile; BOOLEAN NoEaKnowledge; BOOLEAN DeleteOnClose; @@ -609,7 +609,7 @@ FatiCreate(IN PFAT_IRP_CONTEXT IrpContext, Vcb = &((PVOLUME_DEVICE_OBJECT)IrpSp->DeviceObject)->Vcb; /* Get options */ - DirectoryFile = BooleanFlagOn(Options, FILE_DIRECTORY_FILE); + IsDirectoryFile = BooleanFlagOn(Options, FILE_DIRECTORY_FILE); NonDirectoryFile = BooleanFlagOn(Options, FILE_NON_DIRECTORY_FILE); SequentialOnly = BooleanFlagOn(Options, FILE_SEQUENTIAL_ONLY); NoIntermediateBuffering = BooleanFlagOn(Options, FILE_NO_INTERMEDIATE_BUFFERING); @@ -624,17 +624,17 @@ FatiCreate(IN PFAT_IRP_CONTEXT IrpContext, CreateDisposition = (Options >> 24) & 0x000000ff; /* Get Create/Open directory flags based on it */ - CreateDirectory = (BOOLEAN)(DirectoryFile && + CreateDirectory = (BOOLEAN)(IsDirectoryFile && ((CreateDisposition == FILE_CREATE) || (CreateDisposition == FILE_OPEN_IF))); - OpenDirectory = (BOOLEAN)(DirectoryFile && + OpenDirectory = (BOOLEAN)(IsDirectoryFile && ((CreateDisposition == FILE_OPEN) || (CreateDisposition == FILE_OPEN_IF))); /* Validate parameters: directory/nondirectory mismatch and AllocationSize being more than 4GB */ - if ((DirectoryFile && NonDirectoryFile) || + if ((IsDirectoryFile && NonDirectoryFile) || Irp->Overlay.AllocationSize.HighPart != 0) { FatCompleteRequest(IrpContext, Irp, STATUS_INVALID_PARAMETER); @@ -686,9 +686,9 @@ FatiCreate(IN PFAT_IRP_CONTEXT IrpContext, FatDecodeFileObject(RelatedFO, &DecodedVcb, &Fcb, &Ccb) == UserVolumeOpen) { /* Check parameters */ - if (DirectoryFile || OpenTargetDirectory) + if (IsDirectoryFile || OpenTargetDirectory) { - Status = DirectoryFile ? STATUS_NOT_A_DIRECTORY : STATUS_INVALID_PARAMETER; + Status = IsDirectoryFile ? STATUS_NOT_A_DIRECTORY : STATUS_INVALID_PARAMETER; /* Unlock VCB */ FatReleaseVcb(IrpContext, Vcb); From 2bf00ca962f6dfc850b7ba456b83e1b020aec685 Mon Sep 17 00:00:00 2001 From: James Tabor Date: Tue, 28 Dec 2010 07:22:42 +0000 Subject: [PATCH 144/181] [Win32k|User32] - Fix all the user32 wine win test_SetParent tests. svn path=/trunk/; revision=50181 --- reactos/dll/win32/user32/windows/window.c | 5 +- .../subsystems/win32/win32k/ntuser/window.c | 139 ++++++++++-------- 2 files changed, 77 insertions(+), 67 deletions(-) diff --git a/reactos/dll/win32/user32/windows/window.c b/reactos/dll/win32/user32/windows/window.c index 1b1a0894e15..9ad0f2198c3 100644 --- a/reactos/dll/win32/user32/windows/window.c +++ b/reactos/dll/win32/user32/windows/window.c @@ -1450,15 +1450,12 @@ IsChild(HWND hWndParent, _SEH2_TRY { - while (Wnd != NULL) + while (Wnd != NULL && ((Wnd->style & (WS_POPUP|WS_CHILD)) == WS_CHILD)) { if (Wnd->spwndParent != NULL) { Wnd = DesktopPtrToUser(Wnd->spwndParent); - if(Wnd == DesktopWnd) - Wnd = NULL; - if (Wnd == WndParent) { Ret = TRUE; diff --git a/reactos/subsystems/win32/win32k/ntuser/window.c b/reactos/subsystems/win32/win32k/ntuser/window.c index 95a43d6ff37..f1e70cf63c0 100644 --- a/reactos/subsystems/win32/win32k/ntuser/window.c +++ b/reactos/subsystems/win32/win32k/ntuser/window.c @@ -899,16 +899,12 @@ IntIsChildWindow(PWND Parent, PWND BaseWindow) PWND Window; Window = BaseWindow; - while (Window) + while (Window && ((Window->style & (WS_POPUP|WS_CHILD)) == WS_CHILD)) { if (Window == Parent) { return(TRUE); } - if(!(Window->style & WS_CHILD)) - { - break; - } Window = Window->spwndParent; } @@ -1090,7 +1086,7 @@ IntSetOwner(HWND hWnd, HWND hWndNewOwner) PWND FASTCALL co_IntSetParent(PWND Wnd, PWND WndNewParent) { - PWND WndOldParent; + PWND WndOldParent, pWndExam; BOOL WasVisible; ASSERT(Wnd); @@ -1098,6 +1094,12 @@ co_IntSetParent(PWND Wnd, PWND WndNewParent) ASSERT_REFS_CO(Wnd); ASSERT_REFS_CO(WndNewParent); + if (Wnd == Wnd->head.rpdesk->spwndMessage) + { + EngSetLastError(ERROR_ACCESS_DENIED); + return( NULL); + } + /* Some applications try to set a child as a parent */ if (IntIsChildWindow(Wnd, WndNewParent)) { @@ -1105,6 +1107,18 @@ co_IntSetParent(PWND Wnd, PWND WndNewParent) return NULL; } + pWndExam = WndNewParent; // Load parent Window to examine. + // Now test for set parent to parent hit. + while (pWndExam) + { + if (Wnd == pWndExam) + { + EngSetLastError(ERROR_INVALID_PARAMETER); + return NULL; + } + pWndExam = pWndExam->spwndParent; + } + /* * Windows hides the window first, then shows it again * including the WM_SHOWWINDOW messages and all @@ -1150,6 +1164,62 @@ co_IntSetParent(PWND Wnd, PWND WndNewParent) return WndOldParent; } +HWND FASTCALL +co_UserSetParent(HWND hWndChild, HWND hWndNewParent) +{ + PWND Wnd = NULL, WndParent = NULL, WndOldParent; + HWND hWndOldParent = NULL; + USER_REFERENCE_ENTRY Ref, ParentRef; + + if (IntIsBroadcastHwnd(hWndChild) || IntIsBroadcastHwnd(hWndNewParent)) + { + EngSetLastError(ERROR_INVALID_PARAMETER); + return( NULL); + } + + if (hWndChild == IntGetDesktopWindow()) + { + EngSetLastError(ERROR_ACCESS_DENIED); + return( NULL); + } + + if (hWndNewParent) + { + if (!(WndParent = UserGetWindowObject(hWndNewParent))) + { + return( NULL); + } + } + else + { + if (!(WndParent = UserGetWindowObject(IntGetDesktopWindow()))) + { + return( NULL); + } + } + + if (!(Wnd = UserGetWindowObject(hWndChild))) + { + return( NULL); + } + + UserRefObjectCo(Wnd, &Ref); + UserRefObjectCo(WndParent, &ParentRef); + + WndOldParent = co_IntSetParent(Wnd, WndParent); + + UserDerefObjectCo(WndParent); + UserDerefObjectCo(Wnd); + + if (WndOldParent) + { + hWndOldParent = WndOldParent->head.h; + UserDereferenceObject(WndOldParent); + } + + return( hWndOldParent); +} + BOOL FASTCALL IntSetSystemMenu(PWND Window, PMENU_OBJECT Menu) { @@ -3057,63 +3127,6 @@ CLEANUP: END_CLEANUP; } - -HWND FASTCALL -co_UserSetParent(HWND hWndChild, HWND hWndNewParent) -{ - PWND Wnd = NULL, WndParent = NULL, WndOldParent; - HWND hWndOldParent = NULL; - USER_REFERENCE_ENTRY Ref, ParentRef; - - if (IntIsBroadcastHwnd(hWndChild) || IntIsBroadcastHwnd(hWndNewParent)) - { - EngSetLastError(ERROR_INVALID_PARAMETER); - return( NULL); - } - - if (hWndChild == IntGetDesktopWindow()) - { - EngSetLastError(ERROR_ACCESS_DENIED); - return( NULL); - } - - if (hWndNewParent) - { - if (!(WndParent = UserGetWindowObject(hWndNewParent))) - { - return( NULL); - } - } - else - { - if (!(WndParent = UserGetWindowObject(IntGetDesktopWindow()))) - { - return( NULL); - } - } - - if (!(Wnd = UserGetWindowObject(hWndChild))) - { - return( NULL); - } - - UserRefObjectCo(Wnd, &Ref); - UserRefObjectCo(WndParent, &ParentRef); - - WndOldParent = co_IntSetParent(Wnd, WndParent); - - UserDerefObjectCo(WndParent); - UserDerefObjectCo(Wnd); - - if (WndOldParent) - { - hWndOldParent = WndOldParent->head.h; - UserDereferenceObject(WndOldParent); - } - - return( hWndOldParent); -} - /* * NtUserSetParent * From e6a4fb691dbf28353a9c356fe22b2e030b799ddb Mon Sep 17 00:00:00 2001 From: James Tabor Date: Tue, 28 Dec 2010 10:03:07 +0000 Subject: [PATCH 145/181] [User32] - Fix all the user32 wine win test_parent_owner tests. svn path=/trunk/; revision=50183 --- reactos/dll/win32/user32/windows/window.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/reactos/dll/win32/user32/windows/window.c b/reactos/dll/win32/user32/windows/window.c index 9ad0f2198c3..b91392f3635 100644 --- a/reactos/dll/win32/user32/windows/window.c +++ b/reactos/dll/win32/user32/windows/window.c @@ -653,6 +653,14 @@ User32EnumWindows(HDESK hDesktop, return FALSE; } + if (!dwCount) + { + if (!dwThreadId) + return FALSE; + else + return TRUE; + } + /* call the user's callback function until we're done or they tell us to quit */ for ( i = 0; i < dwCount; i++ ) From 527d9e4e177cab20e31aae5f9649715d978203d3 Mon Sep 17 00:00:00 2001 From: James Tabor Date: Tue, 28 Dec 2010 10:38:38 +0000 Subject: [PATCH 146/181] [Win32k] - Fix all the user32 wine win test_CreateWindow tests. svn path=/trunk/; revision=50185 --- reactos/subsystems/win32/win32k/ntuser/window.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/reactos/subsystems/win32/win32k/ntuser/window.c b/reactos/subsystems/win32/win32k/ntuser/window.c index f1e70cf63c0..824f8697599 100644 --- a/reactos/subsystems/win32/win32k/ntuser/window.c +++ b/reactos/subsystems/win32/win32k/ntuser/window.c @@ -437,8 +437,9 @@ static LRESULT co_UserFreeWindow(PWND Window, TIMER_RemoveWindowTimers(Window->head.h); #endif - if (!(Window->style & WS_CHILD) && Window->IDMenu - && (Menu = UserGetMenuObject((HMENU)Window->IDMenu))) + if ( ((Window->style & (WS_CHILD|WS_POPUP)) != WS_CHILD) && + Window->IDMenu && + (Menu = UserGetMenuObject((HMENU)Window->IDMenu))) { IntDestroyMenuObject(Menu, TRUE, TRUE); Window->IDMenu = 0; From 13e99eb88530ccdfb021fc7668ef78a8e5ff7551 Mon Sep 17 00:00:00 2001 From: Pierre Schweitzer Date: Tue, 28 Dec 2010 14:49:53 +0000 Subject: [PATCH 147/181] [NTOSKRNL] Apply consistent formatting to CcMapData svn path=/trunk/; revision=50190 --- reactos/ntoskrnl/cc/pin.c | 124 +++++++++++++++++++------------------- 1 file changed, 62 insertions(+), 62 deletions(-) diff --git a/reactos/ntoskrnl/cc/pin.c b/reactos/ntoskrnl/cc/pin.c index c384d4b0f9e..193de339e4d 100644 --- a/reactos/ntoskrnl/cc/pin.c +++ b/reactos/ntoskrnl/cc/pin.c @@ -22,84 +22,84 @@ extern NPAGED_LOOKASIDE_LIST iBcbLookasideList; /* * @implemented */ -BOOLEAN NTAPI -CcMapData (IN PFILE_OBJECT FileObject, - IN PLARGE_INTEGER FileOffset, - IN ULONG Length, - IN ULONG Flags, - OUT PVOID *pBcb, - OUT PVOID *pBuffer) +BOOLEAN +NTAPI +CcMapData( + IN PFILE_OBJECT FileObject, + IN PLARGE_INTEGER FileOffset, + IN ULONG Length, + IN ULONG Flags, + OUT PVOID *pBcb, + OUT PVOID *pBuffer) { - ULONG ReadOffset; - BOOLEAN Valid; - PBCB Bcb; - PCACHE_SEGMENT CacheSeg; - NTSTATUS Status; - PINTERNAL_BCB iBcb; - ULONG ROffset; + ULONG ReadOffset; + BOOLEAN Valid; + PBCB Bcb; + PCACHE_SEGMENT CacheSeg; + NTSTATUS Status; + PINTERNAL_BCB iBcb; + ULONG ROffset; - DPRINT("CcMapData(FileObject 0x%p, FileOffset %I64x, Length %d, Flags %d," - " pBcb 0x%p, pBuffer 0x%p)\n", FileObject, FileOffset->QuadPart, - Length, Flags, pBcb, pBuffer); + DPRINT("CcMapData(FileObject 0x%p, FileOffset %I64x, Length %d, Flags %d," + " pBcb 0x%p, pBuffer 0x%p)\n", FileObject, FileOffset->QuadPart, + Length, Flags, pBcb, pBuffer); - ReadOffset = (ULONG)FileOffset->QuadPart; + ReadOffset = (ULONG)FileOffset->QuadPart; - ASSERT(FileObject); - ASSERT(FileObject->SectionObjectPointer); - ASSERT(FileObject->SectionObjectPointer->SharedCacheMap); + ASSERT(FileObject); + ASSERT(FileObject->SectionObjectPointer); + ASSERT(FileObject->SectionObjectPointer->SharedCacheMap); - Bcb = FileObject->SectionObjectPointer->SharedCacheMap; - ASSERT(Bcb); + Bcb = FileObject->SectionObjectPointer->SharedCacheMap; + ASSERT(Bcb); - DPRINT("AllocationSize %I64x, FileSize %I64x\n", - Bcb->AllocationSize.QuadPart, - Bcb->FileSize.QuadPart); + DPRINT("AllocationSize %I64x, FileSize %I64x\n", + Bcb->AllocationSize.QuadPart, + Bcb->FileSize.QuadPart); - if (ReadOffset % Bcb->CacheSegmentSize + Length > Bcb->CacheSegmentSize) + if (ReadOffset % Bcb->CacheSegmentSize + Length > Bcb->CacheSegmentSize) { - return(FALSE); + return FALSE; } - ROffset = ROUND_DOWN (ReadOffset, Bcb->CacheSegmentSize); - Status = CcRosRequestCacheSegment(Bcb, - ROffset, - pBuffer, - &Valid, - &CacheSeg); - if (!NT_SUCCESS(Status)) + ROffset = ROUND_DOWN (ReadOffset, Bcb->CacheSegmentSize); + Status = CcRosRequestCacheSegment(Bcb, ROffset, + pBuffer, &Valid, + &CacheSeg); + if (!NT_SUCCESS(Status)) { - return(FALSE); + return FALSE; } - if (!Valid) + if (!Valid) { - if (!(Flags & MAP_WAIT)) - { - CcRosReleaseCacheSegment(Bcb, CacheSeg, FALSE, FALSE, FALSE); - return(FALSE); - } - if (!NT_SUCCESS(ReadCacheSegment(CacheSeg))) - { - CcRosReleaseCacheSegment(Bcb, CacheSeg, FALSE, FALSE, FALSE); - return(FALSE); - } + if (!(Flags & MAP_WAIT)) + { + CcRosReleaseCacheSegment(Bcb, CacheSeg, FALSE, FALSE, FALSE); + return FALSE; + } + if (!NT_SUCCESS(ReadCacheSegment(CacheSeg))) + { + CcRosReleaseCacheSegment(Bcb, CacheSeg, FALSE, FALSE, FALSE); + return FALSE; + } } - *pBuffer = (PVOID)((ULONG_PTR)(*pBuffer) + (ReadOffset % Bcb->CacheSegmentSize)); - iBcb = ExAllocateFromNPagedLookasideList(&iBcbLookasideList); - if (iBcb == NULL) + *pBuffer = (PVOID)((ULONG_PTR)(*pBuffer) + (ReadOffset % Bcb->CacheSegmentSize)); + iBcb = ExAllocateFromNPagedLookasideList(&iBcbLookasideList); + if (iBcb == NULL) { - CcRosReleaseCacheSegment(Bcb, CacheSeg, TRUE, FALSE, FALSE); - return FALSE; + CcRosReleaseCacheSegment(Bcb, CacheSeg, TRUE, FALSE, FALSE); + return FALSE; } - memset(iBcb, 0, sizeof(INTERNAL_BCB)); - iBcb->PFCB.NodeTypeCode = 0xDE45; /* Undocumented (CAPTIVE_PUBLIC_BCB_NODETYPECODE) */ - iBcb->PFCB.NodeByteSize = sizeof(PUBLIC_BCB); - iBcb->PFCB.MappedLength = Length; - iBcb->PFCB.MappedFileOffset = *FileOffset; - iBcb->CacheSegment = CacheSeg; - iBcb->Dirty = FALSE; - iBcb->RefCount = 1; - *pBcb = (PVOID)iBcb; - return(TRUE); + memset(iBcb, 0, sizeof(INTERNAL_BCB)); + iBcb->PFCB.NodeTypeCode = 0xDE45; /* Undocumented (CAPTIVE_PUBLIC_BCB_NODETYPECODE) */ + iBcb->PFCB.NodeByteSize = sizeof(PUBLIC_BCB); + iBcb->PFCB.MappedLength = Length; + iBcb->PFCB.MappedFileOffset = *FileOffset; + iBcb->CacheSegment = CacheSeg; + iBcb->Dirty = FALSE; + iBcb->RefCount = 1; + *pBcb = (PVOID)iBcb; + return TRUE; } /* From a34ed64ca40172a7c222bb28baa5c18907b7add7 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Tue, 28 Dec 2010 18:20:28 +0000 Subject: [PATCH 148/181] [DRIVERS] Add missing breaks. Patch by Samuel Serapion. svn path=/trunk/; revision=50197 --- reactos/drivers/bus/acpi/compbatt/comppnp.c | 2 +- reactos/drivers/network/dd/ne2000/ne2000/8390.c | 4 ++-- reactos/drivers/network/tcpip/datalink/lan.c | 1 + reactos/drivers/storage/class/disk/disk.c | 5 +++-- reactos/drivers/storage/classpnp/class.c | 1 + reactos/drivers/storage/ide/uniata/id_init.cpp | 1 + reactos/drivers/usb/nt4compat/usbdriver/ehci.c | 1 + reactos/drivers/usb/nt4compat/usbdriver/umss.c | 1 + 8 files changed, 11 insertions(+), 5 deletions(-) diff --git a/reactos/drivers/bus/acpi/compbatt/comppnp.c b/reactos/drivers/bus/acpi/compbatt/comppnp.c index 164ea6f6274..250a4761e31 100644 --- a/reactos/drivers/bus/acpi/compbatt/comppnp.c +++ b/reactos/drivers/bus/acpi/compbatt/comppnp.c @@ -436,7 +436,7 @@ CompBattPnpDispatch(IN PDEVICE_OBJECT DeviceObject, DbgPrint("CompBatt: Couldn't register for PnP notification - %x\n", Status); } - + break; case IRP_MN_CANCEL_STOP_DEVICE: /* Explicitly say ok */ diff --git a/reactos/drivers/network/dd/ne2000/ne2000/8390.c b/reactos/drivers/network/dd/ne2000/ne2000/8390.c index d7ceafba106..03adcab94bf 100644 --- a/reactos/drivers/network/dd/ne2000/ne2000/8390.c +++ b/reactos/drivers/network/dd/ne2000/ne2000/8390.c @@ -1361,7 +1361,7 @@ VOID NTAPI MiniportHandleInterrupt( NICUpdateCounters(Adapter); Adapter->ReceiveError = TRUE; - + break; case ISR_PRX: NDIS_DbgPrint(MID_TRACE, ("Receive interrupt.\n")); @@ -1380,7 +1380,7 @@ VOID NTAPI MiniportHandleInterrupt( NICUpdateCounters(Adapter); Adapter->TransmitError = TRUE; - + break; case ISR_PTX: NDIS_DbgPrint(MID_TRACE, ("Transmit interrupt.\n")); diff --git a/reactos/drivers/network/tcpip/datalink/lan.c b/reactos/drivers/network/tcpip/datalink/lan.c index 3883235b6a0..2a252b087f0 100644 --- a/reactos/drivers/network/tcpip/datalink/lan.c +++ b/reactos/drivers/network/tcpip/datalink/lan.c @@ -287,6 +287,7 @@ VOID LanReceiveWorker( PVOID Context ) { case ETYPE_ARP: TI_DbgPrint(MID_TRACE,("Received ARP Packet\n")); ARPReceive(Adapter->Context, &IPPacket); + break; default: IPPacket.Free(&IPPacket); break; diff --git a/reactos/drivers/storage/class/disk/disk.c b/reactos/drivers/storage/class/disk/disk.c index 5d62cfac63a..a2ee02cc155 100644 --- a/reactos/drivers/storage/class/disk/disk.c +++ b/reactos/drivers/storage/class/disk/disk.c @@ -1908,8 +1908,9 @@ Return Value: case EXECUTE_OFFLINE_DIAGS: controlCode = IOCTL_SCSI_MINIPORT_EXECUTE_OFFLINE_DIAGS; - - default: + break; + + default: status = STATUS_INVALID_PARAMETER; break; } diff --git a/reactos/drivers/storage/classpnp/class.c b/reactos/drivers/storage/classpnp/class.c index 0a1c28ea9c5..bf73d776523 100644 --- a/reactos/drivers/storage/classpnp/class.c +++ b/reactos/drivers/storage/classpnp/class.c @@ -3502,6 +3502,7 @@ ClassInterpretSenseInfo( } } + break; } default: { diff --git a/reactos/drivers/storage/ide/uniata/id_init.cpp b/reactos/drivers/storage/ide/uniata/id_init.cpp index 6dce17cfdb5..526a60d2119 100644 --- a/reactos/drivers/storage/ide/uniata/id_init.cpp +++ b/reactos/drivers/storage/ide/uniata/id_init.cpp @@ -113,6 +113,7 @@ UniataChipDetectChannels( KdPrint2((PRINT_PREFIX "New ATI PATA 1 chan\n")); break; } + break; case ATA_SILICON_IMAGE_ID: if(ChipFlags & SIIBUG) { diff --git a/reactos/drivers/usb/nt4compat/usbdriver/ehci.c b/reactos/drivers/usb/nt4compat/usbdriver/ehci.c index 0453fb9727a..0c03e323c07 100644 --- a/reactos/drivers/usb/nt4compat/usbdriver/ehci.c +++ b/reactos/drivers/usb/nt4compat/usbdriver/ehci.c @@ -6006,6 +6006,7 @@ ehci_isr_removing_urb(PEHCI_DEV ehci, PURB purb, BOOLEAN doorbell_rings, ULONG c default: TRAP(); } + break; } case URB_FLAG_STATE_DOORBELL: { diff --git a/reactos/drivers/usb/nt4compat/usbdriver/umss.c b/reactos/drivers/usb/nt4compat/usbdriver/umss.c index 4690fa97ef8..6014606620c 100644 --- a/reactos/drivers/usb/nt4compat/usbdriver/umss.c +++ b/reactos/drivers/usb/nt4compat/usbdriver/umss.c @@ -214,6 +214,7 @@ umss_port_dispatch_routine(PDEVICE_OBJECT pdev_obj, PIRP irp) EXIT_DISPATCH(STATUS_SUCCESS, irp); } } + break; } case IRP_MJ_CREATE: case IRP_MJ_CLOSE: From f5bc202da75bc4c7d84b37be7375391637f972d6 Mon Sep 17 00:00:00 2001 From: Pierre Schweitzer Date: Tue, 28 Dec 2010 20:59:24 +0000 Subject: [PATCH 149/181] [NTOSKRNL] Hoover a bit in CC part 1. Should make MM happier. But MS fastfat driver not yet svn path=/trunk/; revision=50201 --- reactos/ntoskrnl/cc/copy.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/reactos/ntoskrnl/cc/copy.c b/reactos/ntoskrnl/cc/copy.c index 17702665945..f30e128baf3 100644 --- a/reactos/ntoskrnl/cc/copy.c +++ b/reactos/ntoskrnl/cc/copy.c @@ -199,8 +199,7 @@ ReadCacheSegment(PCACHE_SEGMENT CacheSeg) { Size = CacheSeg->Bcb->CacheSegmentSize; } - Mdl = _alloca(MmSizeOfMdl(CacheSeg->BaseAddress, Size)); - MmInitializeMdl(Mdl, CacheSeg->BaseAddress, Size); + Mdl = IoAllocateMdl(CacheSeg->BaseAddress, Size, FALSE, FALSE, NULL); MmBuildMdlForNonPagedPool(Mdl); Mdl->MdlFlags |= MDL_IO_PAGE_READ; KeInitializeEvent(&Event, NotificationEvent, FALSE); @@ -253,8 +252,7 @@ WriteCacheSegment(PCACHE_SEGMENT CacheSeg) MmGetPfnForProcess(NULL, (PVOID)((ULONG_PTR)CacheSeg->BaseAddress + (i << PAGE_SHIFT))); } while (++i < (Size >> PAGE_SHIFT)); } - Mdl = _alloca(MmSizeOfMdl(CacheSeg->BaseAddress, Size)); - MmInitializeMdl(Mdl, CacheSeg->BaseAddress, Size); + Mdl = IoAllocateMdl(CacheSeg->BaseAddress, Size, FALSE, FALSE, NULL); MmBuildMdlForNonPagedPool(Mdl); Mdl->MdlFlags |= MDL_IO_PAGE_READ; KeInitializeEvent(&Event, NotificationEvent, FALSE); From 3ca46a9903a2324aded5c13c0a97d1a0abe588d9 Mon Sep 17 00:00:00 2001 From: Pierre Schweitzer Date: Tue, 28 Dec 2010 21:12:51 +0000 Subject: [PATCH 150/181] [NTOSKRNL] Plumber work part 1. To prevent leaks svn path=/trunk/; revision=50202 --- reactos/ntoskrnl/cc/copy.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/reactos/ntoskrnl/cc/copy.c b/reactos/ntoskrnl/cc/copy.c index f30e128baf3..1c186725360 100644 --- a/reactos/ntoskrnl/cc/copy.c +++ b/reactos/ntoskrnl/cc/copy.c @@ -210,6 +210,8 @@ ReadCacheSegment(PCACHE_SEGMENT CacheSeg) Status = IoStatus.Status; } + IoFreeMdl(Mdl); + if (!NT_SUCCESS(Status) && Status != STATUS_END_OF_FILE) { DPRINT1("IoPageRead failed, Status %x\n", Status); @@ -262,6 +264,7 @@ WriteCacheSegment(PCACHE_SEGMENT CacheSeg) KeWaitForSingleObject(&Event, Executive, KernelMode, FALSE, NULL); Status = IoStatus.Status; } + IoFreeMdl(Mdl); if (!NT_SUCCESS(Status) && (Status != STATUS_END_OF_FILE)) { DPRINT1("IoPageWrite failed, Status %x\n", Status); From eec37f83b14c23062015ed346563014ac6816c49 Mon Sep 17 00:00:00 2001 From: Pierre Schweitzer Date: Tue, 28 Dec 2010 21:34:54 +0000 Subject: [PATCH 151/181] [NTOSKRNL] Hoovering part 2... svn path=/trunk/; revision=50203 --- reactos/ntoskrnl/cc/copy.c | 123 ++++++++++++++++++++----------------- 1 file changed, 68 insertions(+), 55 deletions(-) diff --git a/reactos/ntoskrnl/cc/copy.c b/reactos/ntoskrnl/cc/copy.c index 1c186725360..a381a09b9cd 100644 --- a/reactos/ntoskrnl/cc/copy.c +++ b/reactos/ntoskrnl/cc/copy.c @@ -186,62 +186,69 @@ NTSTATUS NTAPI ReadCacheSegment(PCACHE_SEGMENT CacheSeg) { - ULONG Size; - PMDL Mdl; - NTSTATUS Status; - LARGE_INTEGER SegOffset; - IO_STATUS_BLOCK IoStatus; - KEVENT Event; + ULONG Size; + PMDL Mdl; + NTSTATUS Status; + LARGE_INTEGER SegOffset; + IO_STATUS_BLOCK IoStatus; + KEVENT Event; - SegOffset.QuadPart = CacheSeg->FileOffset; - Size = (ULONG)(CacheSeg->Bcb->AllocationSize.QuadPart - CacheSeg->FileOffset); - if (Size > CacheSeg->Bcb->CacheSegmentSize) + SegOffset.QuadPart = CacheSeg->FileOffset; + Size = (ULONG)(CacheSeg->Bcb->AllocationSize.QuadPart - CacheSeg->FileOffset); + if (Size > CacheSeg->Bcb->CacheSegmentSize) { - Size = CacheSeg->Bcb->CacheSegmentSize; + Size = CacheSeg->Bcb->CacheSegmentSize; } - Mdl = IoAllocateMdl(CacheSeg->BaseAddress, Size, FALSE, FALSE, NULL); - MmBuildMdlForNonPagedPool(Mdl); - Mdl->MdlFlags |= MDL_IO_PAGE_READ; - KeInitializeEvent(&Event, NotificationEvent, FALSE); - Status = IoPageRead(CacheSeg->Bcb->FileObject, Mdl, &SegOffset, & Event, &IoStatus); - if (Status == STATUS_PENDING) - { - KeWaitForSingleObject(&Event, Executive, KernelMode, FALSE, NULL); - Status = IoStatus.Status; - } - IoFreeMdl(Mdl); - - if (!NT_SUCCESS(Status) && Status != STATUS_END_OF_FILE) + Mdl = IoAllocateMdl(CacheSeg->BaseAddress, Size, FALSE, FALSE, NULL); + if (!Mdl) { - DPRINT1("IoPageRead failed, Status %x\n", Status); - return Status; + return STATUS_INSUFFICIANT_RESOURCES; } - if (CacheSeg->Bcb->CacheSegmentSize > Size) + MmBuildMdlForNonPagedPool(Mdl); + Mdl->MdlFlags |= MDL_IO_PAGE_READ; + KeInitializeEvent(&Event, NotificationEvent, FALSE); + Status = IoPageRead(CacheSeg->Bcb->FileObject, Mdl, &SegOffset, &Event, &IoStatus); + if (Status == STATUS_PENDING) { - memset ((char*)CacheSeg->BaseAddress + Size, 0, + KeWaitForSingleObject(&Event, Executive, KernelMode, FALSE, NULL); + Status = IoStatus.Status; + } + + IoFreeMdl(Mdl); + + if (!NT_SUCCESS(Status) && Status != STATUS_END_OF_FILE) + { + DPRINT1("IoPageRead failed, Status %x\n", Status); + return Status; + } + + if (CacheSeg->Bcb->CacheSegmentSize > Size) + { + RtlZeroMemory((char*)CacheSeg->BaseAddress + Size, CacheSeg->Bcb->CacheSegmentSize - Size); } - return STATUS_SUCCESS; + + return STATUS_SUCCESS; } NTSTATUS NTAPI WriteCacheSegment(PCACHE_SEGMENT CacheSeg) { - ULONG Size; - PMDL Mdl; - NTSTATUS Status; - IO_STATUS_BLOCK IoStatus; - LARGE_INTEGER SegOffset; - KEVENT Event; + ULONG Size; + PMDL Mdl; + NTSTATUS Status; + IO_STATUS_BLOCK IoStatus; + LARGE_INTEGER SegOffset; + KEVENT Event; - CacheSeg->Dirty = FALSE; - SegOffset.QuadPart = CacheSeg->FileOffset; - Size = (ULONG)(CacheSeg->Bcb->AllocationSize.QuadPart - CacheSeg->FileOffset); - if (Size > CacheSeg->Bcb->CacheSegmentSize) + CacheSeg->Dirty = FALSE; + SegOffset.QuadPart = CacheSeg->FileOffset; + Size = (ULONG)(CacheSeg->Bcb->AllocationSize.QuadPart - CacheSeg->FileOffset); + if (Size > CacheSeg->Bcb->CacheSegmentSize) { - Size = CacheSeg->Bcb->CacheSegmentSize; + Size = CacheSeg->Bcb->CacheSegmentSize; } // // Nonpaged pool PDEs in ReactOS must actually be synchronized between the @@ -254,24 +261,30 @@ WriteCacheSegment(PCACHE_SEGMENT CacheSeg) MmGetPfnForProcess(NULL, (PVOID)((ULONG_PTR)CacheSeg->BaseAddress + (i << PAGE_SHIFT))); } while (++i < (Size >> PAGE_SHIFT)); } - Mdl = IoAllocateMdl(CacheSeg->BaseAddress, Size, FALSE, FALSE, NULL); - MmBuildMdlForNonPagedPool(Mdl); - Mdl->MdlFlags |= MDL_IO_PAGE_READ; - KeInitializeEvent(&Event, NotificationEvent, FALSE); - Status = IoSynchronousPageWrite(CacheSeg->Bcb->FileObject, Mdl, &SegOffset, &Event, &IoStatus); - if (Status == STATUS_PENDING) - { - KeWaitForSingleObject(&Event, Executive, KernelMode, FALSE, NULL); - Status = IoStatus.Status; - } - IoFreeMdl(Mdl); - if (!NT_SUCCESS(Status) && (Status != STATUS_END_OF_FILE)) + + Mdl = IoAllocateMdl(CacheSeg->BaseAddress, Size, FALSE, FALSE, NULL); + if (!Mdl) { - DPRINT1("IoPageWrite failed, Status %x\n", Status); - CacheSeg->Dirty = TRUE; - return(Status); + return STATUS_INSUFFICIANT_RESOURCES; } - return(STATUS_SUCCESS); + MmBuildMdlForNonPagedPool(Mdl); + Mdl->MdlFlags |= MDL_IO_PAGE_READ; + KeInitializeEvent(&Event, NotificationEvent, FALSE); + Status = IoSynchronousPageWrite(CacheSeg->Bcb->FileObject, Mdl, &SegOffset, &Event, &IoStatus); + if (Status == STATUS_PENDING) + { + KeWaitForSingleObject(&Event, Executive, KernelMode, FALSE, NULL); + Status = IoStatus.Status; + } + IoFreeMdl(Mdl); + if (!NT_SUCCESS(Status) && (Status != STATUS_END_OF_FILE)) + { + DPRINT1("IoPageWrite failed, Status %x\n", Status); + CacheSeg->Dirty = TRUE; + return Status; + } + + return STATUS_SUCCESS; } From 41c9b7cdd46903c08b2f5aef153b3d7613c047ec Mon Sep 17 00:00:00 2001 From: Pierre Schweitzer Date: Tue, 28 Dec 2010 21:40:23 +0000 Subject: [PATCH 152/181] [NTOSKRNL] Fix typo ~ svn path=/trunk/; revision=50204 --- reactos/ntoskrnl/cc/copy.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/reactos/ntoskrnl/cc/copy.c b/reactos/ntoskrnl/cc/copy.c index a381a09b9cd..7e3d401d488 100644 --- a/reactos/ntoskrnl/cc/copy.c +++ b/reactos/ntoskrnl/cc/copy.c @@ -203,7 +203,7 @@ ReadCacheSegment(PCACHE_SEGMENT CacheSeg) Mdl = IoAllocateMdl(CacheSeg->BaseAddress, Size, FALSE, FALSE, NULL); if (!Mdl) { - return STATUS_INSUFFICIANT_RESOURCES; + return STATUS_INSUFFICIENT_RESOURCES; } MmBuildMdlForNonPagedPool(Mdl); Mdl->MdlFlags |= MDL_IO_PAGE_READ; @@ -265,7 +265,7 @@ WriteCacheSegment(PCACHE_SEGMENT CacheSeg) Mdl = IoAllocateMdl(CacheSeg->BaseAddress, Size, FALSE, FALSE, NULL); if (!Mdl) { - return STATUS_INSUFFICIANT_RESOURCES; + return STATUS_INSUFFICIENT_RESOURCES; } MmBuildMdlForNonPagedPool(Mdl); Mdl->MdlFlags |= MDL_IO_PAGE_READ; From 0f8e42980e828f68dd91cea9a05898c86bbde2e3 Mon Sep 17 00:00:00 2001 From: James Tabor Date: Wed, 29 Dec 2010 04:43:51 +0000 Subject: [PATCH 153/181] [Win32k] - Fix all the user32 wine win test_enum_thread_windows tests. svn path=/trunk/; revision=50205 --- .../subsystems/win32/win32k/ntuser/window.c | 43 +++++++++++-------- 1 file changed, 26 insertions(+), 17 deletions(-) diff --git a/reactos/subsystems/win32/win32k/ntuser/window.c b/reactos/subsystems/win32/win32k/ntuser/window.c index 824f8697599..1a946a16374 100644 --- a/reactos/subsystems/win32/win32k/ntuser/window.c +++ b/reactos/subsystems/win32/win32k/ntuser/window.c @@ -1423,7 +1423,7 @@ NtUserBuildHwndList( ObDereferenceObject(Desktop); } } - else + else // Build EnumThreadWindows list! { PETHREAD Thread; PTHREADINFO W32Thread; @@ -1431,37 +1431,46 @@ NtUserBuildHwndList( PWND Window; Status = PsLookupThreadByThreadId((HANDLE)dwThreadId, &Thread); - if(!NT_SUCCESS(Status)) + if (!NT_SUCCESS(Status)) { + DPRINT1("Thread Id is not valid!\n"); return ERROR_INVALID_PARAMETER; } - if(!(W32Thread = (PTHREADINFO)Thread->Tcb.Win32Thread)) + if (!(W32Thread = (PTHREADINFO)Thread->Tcb.Win32Thread)) { ObDereferenceObject(Thread); - DPRINT("Thread is not a GUI Thread!\n"); + DPRINT1("Thread is not initialized!\n"); return ERROR_INVALID_PARAMETER; } Current = W32Thread->WindowListHead.Flink; - while(Current != &(W32Thread->WindowListHead)) + while (Current != &(W32Thread->WindowListHead)) { Window = CONTAINING_RECORD(Current, WND, ThreadListEntry); ASSERT(Window); - if(bChildren || Window->spwndOwner != NULL) + if (dwCount < *pBufSize && pWnd) { - if(dwCount < *pBufSize && pWnd) - { - Status = MmCopyToCaller(pWnd++, &Window->head.h, sizeof(HWND)); - if(!NT_SUCCESS(Status)) - { - SetLastNtError(Status); - break; - } - } - dwCount++; + _SEH2_TRY + { + ProbeForWrite(pWnd, sizeof(HWND), 1); + *pWnd = Window->head.h; + pWnd++; + } + _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) + { + Status = _SEH2_GetExceptionCode(); + } + _SEH2_END + if (!NT_SUCCESS(Status)) + { + DPRINT1("Failure to build window list!\n"); + SetLastNtError(Status); + break; + } } - Current = Current->Flink; + dwCount++; + Current = Window->ThreadListEntry.Flink; } ObDereferenceObject(Thread); From b2a4a3214a48ea84769f26767b846197304acbdb Mon Sep 17 00:00:00 2001 From: James Tabor Date: Wed, 29 Dec 2010 04:52:06 +0000 Subject: [PATCH 154/181] - Update note after 50205. svn path=/trunk/; revision=50206 --- reactos/dll/win32/user32/windows/window.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/reactos/dll/win32/user32/windows/window.c b/reactos/dll/win32/user32/windows/window.c index b91392f3635..21caa9e2806 100644 --- a/reactos/dll/win32/user32/windows/window.c +++ b/reactos/dll/win32/user32/windows/window.c @@ -668,7 +668,8 @@ User32EnumWindows(HDESK hDesktop, /* FIXME I'm only getting NULLs from Thread Enumeration, and it's * probably because I'm not doing it right in NtUserBuildHwndList. * Once that's fixed, we shouldn't have to check for a NULL HWND - * here + * here + * This is now fixed in revision 50205. (jt) */ if (!pHwnd[i]) /* don't enumerate a NULL HWND */ continue; From 6c87e66f80642963650c59d38ef2324c46cc105e Mon Sep 17 00:00:00 2001 From: James Tabor Date: Wed, 29 Dec 2010 08:17:54 +0000 Subject: [PATCH 155/181] [User32] - Fix most of the user32 wine win test_mdi tests. Leaving 30 failures dealing with rect size, Class and Title names. svn path=/trunk/; revision=50208 --- reactos/dll/win32/user32/windows/window.c | 32 +++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/reactos/dll/win32/user32/windows/window.c b/reactos/dll/win32/user32/windows/window.c index 21caa9e2806..8abefe49768 100644 --- a/reactos/dll/win32/user32/windows/window.c +++ b/reactos/dll/win32/user32/windows/window.c @@ -342,6 +342,20 @@ CreateWindowExA(DWORD dwExStyle, POINT mPos[2]; UINT id = 0; HWND top_child; + PWND pWndParent; + PCLS pCls; + + pWndParent = ValidateHwnd(hWndParent); + + if (!pWndParent) return NULL; + + pCls = DesktopPtrToUser(pWndParent->pcls); + + if (pCls->fnid != FNID_MDICLIENT) // wine uses WIN_ISMDICLIENT + { + WARN("WS_EX_MDICHILD, but parent %p is not MDIClient\n", hWndParent); + return NULL; + } /* lpParams of WM_[NC]CREATE is different for MDI children. * MDICREATESTRUCT members have the originally passed values. @@ -358,7 +372,7 @@ CreateWindowExA(DWORD dwExStyle, lpParam = (LPVOID)&mdi; - if (GetWindowLongPtrW(hWndParent, GWL_STYLE) & MDIS_ALLCHILDSTYLES) + if (pWndParent->style & MDIS_ALLCHILDSTYLES) { if (dwStyle & WS_POPUP) { @@ -454,7 +468,21 @@ CreateWindowExW(DWORD dwExStyle, POINT mPos[2]; UINT id = 0; HWND top_child; + PWND pWndParent; + PCLS pCls; + pWndParent = ValidateHwnd(hWndParent); + + if (!pWndParent) return NULL; + + pCls = DesktopPtrToUser(pWndParent->pcls); + + if (pCls->fnid != FNID_MDICLIENT) + { + WARN("WS_EX_MDICHILD, but parent %p is not MDIClient\n", hWndParent); + return NULL; + } + /* lpParams of WM_[NC]CREATE is different for MDI children. * MDICREATESTRUCT members have the originally passed values. */ @@ -470,7 +498,7 @@ CreateWindowExW(DWORD dwExStyle, lpParam = (LPVOID)&mdi; - if (GetWindowLongPtrW(hWndParent, GWL_STYLE) & MDIS_ALLCHILDSTYLES) + if (pWndParent->style & MDIS_ALLCHILDSTYLES) { if (dwStyle & WS_POPUP) { From 0834418ad79bd4f8ce191b2991a7ad0a40aa04fc Mon Sep 17 00:00:00 2001 From: Aleksey Bragin Date: Wed, 29 Dec 2010 11:12:17 +0000 Subject: [PATCH 156/181] [NTOS] - Greatly simplify and fix the incorrect and overcomplicated if condition in IoIsOperationSynchronous(), based on MSDN description. Bug spotted, fix tested by Pierre. svn path=/trunk/; revision=50210 --- reactos/ntoskrnl/io/iomgr/irp.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/reactos/ntoskrnl/io/iomgr/irp.c b/reactos/ntoskrnl/io/iomgr/irp.c index 54179a6d317..a7f3a96ab21 100644 --- a/reactos/ntoskrnl/io/iomgr/irp.c +++ b/reactos/ntoskrnl/io/iomgr/irp.c @@ -1704,12 +1704,21 @@ BOOLEAN NTAPI IoIsOperationSynchronous(IN PIRP Irp) { + BOOLEAN SynchIO; + BOOLEAN ForceAsync; + + /* If the IRP requests synchronous paging I/O, if the file object was opened + for synchronous I/O, if the IRP_SYNCHRONOUS_API flag is set in the IRP + the operation is synchronous */ + SynchIO = (IoGetCurrentIrpStackLocation(Irp)->FileObject->Flags & FO_SYNCHRONOUS_IO) || + (Irp->Flags & IRP_SYNCHRONOUS_API) || (Irp->Flags & IRP_SYNCHRONOUS_PAGING_IO); + + /* If the IRP requests asynchronous paging I/O, the operation is asynchronous, + even if one of the above conditions is true */ + ForceAsync = (Irp->Flags & IRP_PAGING_IO) && !(Irp->Flags & IRP_SYNCHRONOUS_PAGING_IO); + /* Check the flags */ - if (!(Irp->Flags & (IRP_PAGING_IO | IRP_SYNCHRONOUS_PAGING_IO)) && - ((Irp->Flags & IRP_SYNCHRONOUS_PAGING_IO) || - (Irp->Flags & IRP_SYNCHRONOUS_API) || - (IoGetCurrentIrpStackLocation(Irp)->FileObject->Flags & - FO_SYNCHRONOUS_IO))) + if (SynchIO && !ForceAsync) { /* Synch API or Paging I/O is OK, as is Sync File I/O */ return TRUE; From a1d29e94354bb36e33332b41b87356ca22105819 Mon Sep 17 00:00:00 2001 From: Sylvain Petreolle Date: Wed, 29 Dec 2010 16:12:56 +0000 Subject: [PATCH 157/181] [CMAKE] Fix rpcrt4_winetest build. svn path=/trunk/; revision=50214 --- rostests/winetests/rpcrt4/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rostests/winetests/rpcrt4/CMakeLists.txt b/rostests/winetests/rpcrt4/CMakeLists.txt index b8f7a1640fe..10a4f15dcc7 100644 --- a/rostests/winetests/rpcrt4/CMakeLists.txt +++ b/rostests/winetests/rpcrt4/CMakeLists.txt @@ -6,7 +6,7 @@ add_definitions( -D__ROS_LONG64__ -D_DLL -D__USE_CRTIMP) -MACRO_IDL_FILES(server.idl) +idl_files(server.idl) list(APPEND SOURCE cstub.c From c2a558dbb74ab449c0418abbf26208f04c7081bb Mon Sep 17 00:00:00 2001 From: James Tabor Date: Thu, 30 Dec 2010 00:59:10 +0000 Subject: [PATCH 158/181] [Win32k|User32] - Fix mdi class window function Id, now msi message tests do not assert. svn path=/trunk/; revision=50218 --- reactos/dll/win32/user32/windows/mdi.c | 2 ++ reactos/dll/win32/user32/windows/window.c | 10 ++-------- .../subsystems/win32/win32k/ntuser/window.c | 18 +++++++++++++----- 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/reactos/dll/win32/user32/windows/mdi.c b/reactos/dll/win32/user32/windows/mdi.c index cde115d6a14..e7c091aa383 100644 --- a/reactos/dll/win32/user32/windows/mdi.c +++ b/reactos/dll/win32/user32/windows/mdi.c @@ -1111,6 +1111,7 @@ LRESULT WINAPI MDIClientWndProc_common( HWND hwnd, UINT message, WPARAM wParam, return FALSE; SetWindowLongPtrW( hwnd, 0, (LONG_PTR)ci ); ci->hBmpClose = 0; + NtUserSetWindowFNID( hwnd, FNID_MDICLIENT); // wine uses WIN_ISMDICLIENT #else WND *wndPtr = WIN_GetPtr( hwnd ); wndPtr->flags |= WIN_ISMDICLIENT; @@ -1160,6 +1161,7 @@ LRESULT WINAPI MDIClientWndProc_common( HWND hwnd, UINT message, WPARAM wParam, #ifdef __REACTOS__ HeapFree( GetProcessHeap(), 0, ci ); SetWindowLongPtrW( hwnd, 0, 0 ); + NtUserSetWindowFNID(hwnd, FNID_DESTROY); #endif return 0; } diff --git a/reactos/dll/win32/user32/windows/window.c b/reactos/dll/win32/user32/windows/window.c index 8abefe49768..2538acf82cf 100644 --- a/reactos/dll/win32/user32/windows/window.c +++ b/reactos/dll/win32/user32/windows/window.c @@ -343,15 +343,12 @@ CreateWindowExA(DWORD dwExStyle, UINT id = 0; HWND top_child; PWND pWndParent; - PCLS pCls; pWndParent = ValidateHwnd(hWndParent); if (!pWndParent) return NULL; - pCls = DesktopPtrToUser(pWndParent->pcls); - - if (pCls->fnid != FNID_MDICLIENT) // wine uses WIN_ISMDICLIENT + if (pWndParent->fnid != FNID_MDICLIENT) // wine uses WIN_ISMDICLIENT { WARN("WS_EX_MDICHILD, but parent %p is not MDIClient\n", hWndParent); return NULL; @@ -469,15 +466,12 @@ CreateWindowExW(DWORD dwExStyle, UINT id = 0; HWND top_child; PWND pWndParent; - PCLS pCls; pWndParent = ValidateHwnd(hWndParent); if (!pWndParent) return NULL; - pCls = DesktopPtrToUser(pWndParent->pcls); - - if (pCls->fnid != FNID_MDICLIENT) + if (pWndParent->fnid != FNID_MDICLIENT) { WARN("WS_EX_MDICHILD, but parent %p is not MDIClient\n", hWndParent); return NULL; diff --git a/reactos/subsystems/win32/win32k/ntuser/window.c b/reactos/subsystems/win32/win32k/ntuser/window.c index 1a946a16374..e8f98f21b6d 100644 --- a/reactos/subsystems/win32/win32k/ntuser/window.c +++ b/reactos/subsystems/win32/win32k/ntuser/window.c @@ -3878,15 +3878,23 @@ NtUserSetWindowFNID(HWND hWnd, RETURN( FALSE); } - if (Wnd->pcls) - { // From user land we only set these. - if ((fnID != FNID_DESTROY) || ((fnID < FNID_BUTTON) && (fnID > FNID_IME)) ) + if (Wnd->head.pti->ppi != PsGetCurrentProcessWin32Process()) + { + EngSetLastError(ERROR_ACCESS_DENIED); + RETURN( FALSE); + } + + // From user land we only set these. + if (fnID != FNID_DESTROY) + { + if ( ((fnID < FNID_BUTTON) && (fnID > FNID_IME)) || + Wnd->fnid != 0 ) { RETURN( FALSE); } - else - Wnd->pcls->fnid |= fnID; } + + Wnd->fnid |= fnID; RETURN( TRUE); CLEANUP: From a7d5cdfa3b2e37f997945e0483ca1c3e64fbd244 Mon Sep 17 00:00:00 2001 From: James Tabor Date: Thu, 30 Dec 2010 02:32:50 +0000 Subject: [PATCH 159/181] [User32] - Controls: Set fnids for the user client controls. svn path=/trunk/; revision=50219 --- reactos/dll/win32/user32/controls/button.c | 19 +++++++++++++++++++ reactos/dll/win32/user32/controls/combo.c | 15 +++++++++++++++ reactos/dll/win32/user32/controls/edit.c | 15 +++++++++++++++ reactos/dll/win32/user32/controls/listbox.c | 15 +++++++++++++++ reactos/dll/win32/user32/controls/static.c | 15 +++++++++++++++ 5 files changed, 79 insertions(+) diff --git a/reactos/dll/win32/user32/controls/button.c b/reactos/dll/win32/user32/controls/button.c index 8b4003bbe58..3fef42efc56 100644 --- a/reactos/dll/win32/user32/controls/button.c +++ b/reactos/dll/win32/user32/controls/button.c @@ -256,6 +256,18 @@ LRESULT WINAPI ButtonWndProc_common(HWND hWnd, UINT uMsg, UINT btn_type = get_button_type( style ); LONG state; HANDLE oldHbitmap; +#ifdef __REACTOS__ + PWND pWnd; + + pWnd = ValidateHwnd(hWnd); + if (pWnd) + { + if (!pWnd->fnid) + { + NtUserSetWindowFNID(hWnd, FNID_BUTTON); + } + } +#endif pt.x = (short)LOWORD(lParam); pt.y = (short)HIWORD(lParam); @@ -300,6 +312,13 @@ LRESULT WINAPI ButtonWndProc_common(HWND hWnd, UINT uMsg, button_update_uistate( hWnd, unicode ); return 0; +#ifdef __REACTOS__ + case WM_DESTROY: + case WM_NCDESTROY: + NtUserSetWindowFNID(hWnd, FNID_DESTROY); + break; +#endif + case WM_ERASEBKGND: if (btn_type == BS_OWNERDRAW) { diff --git a/reactos/dll/win32/user32/controls/combo.c b/reactos/dll/win32/user32/controls/combo.c index 2a7ab1822b9..de6c646268d 100644 --- a/reactos/dll/win32/user32/controls/combo.c +++ b/reactos/dll/win32/user32/controls/combo.c @@ -1837,6 +1837,18 @@ LRESULT WINAPI ComboWndProc_common( HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam, BOOL unicode ) { LPHEADCOMBO lphc = (LPHEADCOMBO)GetWindowLongPtrW( hwnd, 0 ); +#ifdef __REACTOS__ + PWND pWnd; + + pWnd = ValidateHwnd(hwnd); + if (pWnd) + { + if (!pWnd->fnid) + { + NtUserSetWindowFNID(hwnd, FNID_COMBOBOX); + } + } +#endif TRACE("[%p]: msg %s wp %08lx lp %08lx\n", hwnd, SPY_GetMsgName(message, hwnd), wParam, lParam ); @@ -1855,6 +1867,9 @@ LRESULT WINAPI ComboWndProc_common( HWND hwnd, UINT message, } case WM_NCDESTROY: COMBO_NCDestroy(lphc); +#ifdef __REACTOS__ + NtUserSetWindowFNID(hwnd, FNID_DESTROY); +#endif break;/* -> DefWindowProc */ case WM_CREATE: diff --git a/reactos/dll/win32/user32/controls/edit.c b/reactos/dll/win32/user32/controls/edit.c index 683c9dfe72a..b484c842ea0 100644 --- a/reactos/dll/win32/user32/controls/edit.c +++ b/reactos/dll/win32/user32/controls/edit.c @@ -4476,6 +4476,18 @@ LRESULT WINAPI EditWndProc_common( HWND hwnd, UINT msg, { EDITSTATE *es = (EDITSTATE *)GetWindowLongPtrW( hwnd, 0 ); LRESULT result = 0; +#ifdef __REACTOS__ + PWND pWnd; + + pWnd = ValidateHwnd(hwnd); + if (pWnd) + { + if (!pWnd->fnid) + { + NtUserSetWindowFNID(hwnd, FNID_EDIT); + } + } +#endif TRACE("hwnd=%p msg=%x (%s) wparam=%lx lparam=%lx\n", hwnd, msg, SPY_GetMsgName(msg, hwnd), wParam, lParam); @@ -4723,6 +4735,9 @@ LRESULT WINAPI EditWndProc_common( HWND hwnd, UINT msg, case WM_DESTROY: result = EDIT_WM_Destroy(es); es = NULL; +#ifdef __REACTOS__ + NtUserSetWindowFNID(hwnd, FNID_DESTROY); +#endif break; case WM_GETDLGCODE: diff --git a/reactos/dll/win32/user32/controls/listbox.c b/reactos/dll/win32/user32/controls/listbox.c index 13c679c2d7a..e290860b49b 100644 --- a/reactos/dll/win32/user32/controls/listbox.c +++ b/reactos/dll/win32/user32/controls/listbox.c @@ -2585,6 +2585,18 @@ LRESULT WINAPI ListBoxWndProc_common( HWND hwnd, UINT msg, LB_DESCR *descr = (LB_DESCR *)GetWindowLongPtrW( hwnd, 0 ); LPHEADCOMBO lphc = 0; LRESULT ret; +#ifdef __REACTOS__ + PWND pWnd; + + pWnd = ValidateHwnd(hwnd); + if (pWnd) + { + if (!pWnd->fnid) + { + NtUserSetWindowFNID(hwnd, FNID_LISTBOX); // Could be FNID_COMBOLBOX by class. + } + } +#endif if (!descr) { @@ -2999,6 +3011,9 @@ LRESULT WINAPI ListBoxWndProc_common( HWND hwnd, UINT msg, return 0; case WM_DESTROY: +#ifdef __REACTOS__ + NtUserSetWindowFNID(hwnd, FNID_DESTROY); +#endif return LISTBOX_Destroy( descr ); case WM_ENABLE: diff --git a/reactos/dll/win32/user32/controls/static.c b/reactos/dll/win32/user32/controls/static.c index db0f4408980..6d40bbc8d5f 100644 --- a/reactos/dll/win32/user32/controls/static.c +++ b/reactos/dll/win32/user32/controls/static.c @@ -423,6 +423,18 @@ LRESULT WINAPI StaticWndProc_common( HWND hwnd, UINT uMsg, WPARAM wParam, LRESULT lResult = 0; LONG full_style = GetWindowLongPtrW( hwnd, GWL_STYLE ); LONG style = full_style & SS_TYPEMASK; +#ifdef __REACTOS__ + PWND pWnd; + + pWnd = ValidateHwnd(hwnd); + if (pWnd) + { + if (!pWnd->fnid) + { + NtUserSetWindowFNID(hwnd, FNID_STATIC); + } + } +#endif switch (uMsg) { @@ -437,6 +449,9 @@ LRESULT WINAPI StaticWndProc_common( HWND hwnd, UINT uMsg, WPARAM wParam, break; case WM_NCDESTROY: +#ifdef __REACTOS__ + NtUserSetWindowFNID(hwnd, FNID_DESTROY); +#endif if (style == SS_ICON) { /* * FIXME From 88e4ef1d91987d8eae86a1855aa16033ab0c4f4b Mon Sep 17 00:00:00 2001 From: James Tabor Date: Thu, 30 Dec 2010 03:03:45 +0000 Subject: [PATCH 160/181] [Win32k] - NtUserSetWindowFNID, sets user client side window function Ids, expands to ghost. svn path=/trunk/; revision=50220 --- reactos/subsystems/win32/win32k/ntuser/window.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/reactos/subsystems/win32/win32k/ntuser/window.c b/reactos/subsystems/win32/win32k/ntuser/window.c index e8f98f21b6d..4d978038e3f 100644 --- a/reactos/subsystems/win32/win32k/ntuser/window.c +++ b/reactos/subsystems/win32/win32k/ntuser/window.c @@ -3887,9 +3887,10 @@ NtUserSetWindowFNID(HWND hWnd, // From user land we only set these. if (fnID != FNID_DESTROY) { - if ( ((fnID < FNID_BUTTON) && (fnID > FNID_IME)) || + if ( ((fnID < FNID_BUTTON) && (fnID > FNID_GHOST)) || Wnd->fnid != 0 ) { + EngSetLastError(ERROR_INVALID_PARAMETER); RETURN( FALSE); } } From f888c0c7b1761bfb1ba2c3746e0cb7a0a2f9122b Mon Sep 17 00:00:00 2001 From: James Tabor Date: Thu, 30 Dec 2010 05:52:06 +0000 Subject: [PATCH 161/181] [Win32k|User32] - Fix most of the user32 wine win test_mdi tests. Leaving 6 failures dealing with rect size. Start A2U and U2A support. svn path=/trunk/; revision=50221 --- reactos/dll/win32/user32/windows/message.c | 58 +++++-- .../subsystems/win32/win32k/ntuser/message.c | 151 +++++++++++++++++- 2 files changed, 197 insertions(+), 12 deletions(-) diff --git a/reactos/dll/win32/user32/windows/message.c b/reactos/dll/win32/user32/windows/message.c index c32f0bed68c..df82ac37049 100644 --- a/reactos/dll/win32/user32/windows/message.c +++ b/reactos/dll/win32/user32/windows/message.c @@ -296,6 +296,26 @@ MsgiKMToUMMessage(PMSG KMMsg, PMSG UMMsg) } break; + case WM_MDICREATE: + { + MDICREATESTRUCTW *mCs = (MDICREATESTRUCTW *) KMMsg->lParam; + PCHAR Class; + mCs->szTitle = (LPCWSTR) ((PCHAR) mCs + (DWORD_PTR) mCs->szTitle); + Class = (PCHAR) mCs + (DWORD_PTR) mCs->szClass; + if (L'A' == *((WCHAR *) Class)) + { + Class += sizeof(WCHAR); + mCs->szClass = (LPCWSTR)(DWORD_PTR) (*((ATOM *) Class)); + } + else + { + ASSERT(L'S' == *((WCHAR *) Class)); + Class += sizeof(WCHAR); + mCs->szClass = (LPCWSTR) Class; + } + } + break; + case WM_DDE_ACK: { PKMDDELPARAM DdeLparam = (PKMDDELPARAM) KMMsg->lParam; @@ -383,7 +403,7 @@ MsgiKMToUMReply(PMSG KMMsg, PMSG UMMsg, LRESULT *Result) } static BOOL FASTCALL -MsgiAnsiToUnicodeMessage(LPMSG UnicodeMsg, LPMSG AnsiMsg) +MsgiAnsiToUnicodeMessage(HWND hwnd, LPMSG UnicodeMsg, LPMSG AnsiMsg) { UNICODE_STRING UnicodeString; @@ -457,6 +477,7 @@ MsgiAnsiToUnicodeMessage(LPMSG UnicodeMsg, LPMSG AnsiMsg) case WM_NCCREATE: case WM_CREATE: { + MDICREATESTRUCTW mdi_cs; struct s { CREATESTRUCTW cs; /* new structure */ @@ -480,6 +501,15 @@ MsgiAnsiToUnicodeMessage(LPMSG UnicodeMsg, LPMSG AnsiMsg) RtlCreateUnicodeStringFromAsciiz(&UnicodeString, (LPSTR)xs->cs.lpszClass); xs->lpszClass = xs->cs.lpszClass = UnicodeString.Buffer; } + + if (GetWindowLongW(hwnd, GWL_EXSTYLE) & WS_EX_MDICHILD) + { + mdi_cs = *(MDICREATESTRUCTW *)xs->cs.lpCreateParams; + mdi_cs.szTitle = xs->cs.lpszName; + mdi_cs.szClass = xs->cs.lpszClass; + xs->cs.lpCreateParams = &mdi_cs; + } + UnicodeMsg->lParam = (LPARAM)xs; break; } @@ -648,7 +678,7 @@ MsgiAnsiToUnicodeReply(LPMSG UnicodeMsg, LPMSG AnsiMsg, LRESULT *Result) static BOOL FASTCALL -MsgiUnicodeToAnsiMessage(LPMSG AnsiMsg, LPMSG UnicodeMsg) +MsgiUnicodeToAnsiMessage(HWND hwnd, LPMSG AnsiMsg, LPMSG UnicodeMsg) { ANSI_STRING AnsiString; UNICODE_STRING UnicodeString; @@ -660,6 +690,7 @@ MsgiUnicodeToAnsiMessage(LPMSG AnsiMsg, LPMSG UnicodeMsg) case WM_CREATE: case WM_NCCREATE: { + MDICREATESTRUCTA mdi_cs; CREATESTRUCTA* CsA; CREATESTRUCTW* CsW; NTSTATUS Status; @@ -693,6 +724,15 @@ MsgiUnicodeToAnsiMessage(LPMSG AnsiMsg, LPMSG UnicodeMsg) } CsA->lpszClass = AnsiString.Buffer; } + + if (GetWindowLongW(hwnd, GWL_EXSTYLE) & WS_EX_MDICHILD) + { + mdi_cs = *(MDICREATESTRUCTA *)CsW->lpCreateParams; + mdi_cs.szTitle = CsA->lpszName; + mdi_cs.szClass = CsA->lpszClass; + CsA->lpCreateParams = &mdi_cs; + } + AnsiMsg->lParam = (LPARAM)CsA; break; } @@ -1064,7 +1104,7 @@ IntCallWindowProcW(BOOL IsAnsiProc, UnicodeMsg.message = Msg; UnicodeMsg.wParam = wParam; UnicodeMsg.lParam = lParam; - if (! MsgiUnicodeToAnsiMessage(&AnsiMsg, &UnicodeMsg)) + if (! MsgiUnicodeToAnsiMessage(hWnd, &AnsiMsg, &UnicodeMsg)) { goto Exit; } @@ -1248,7 +1288,7 @@ IntCallWindowProcA(BOOL IsAnsiProc, AnsiMsg.message = Msg; AnsiMsg.wParam = wParam; AnsiMsg.lParam = lParam; - if (! MsgiAnsiToUnicodeMessage(&UnicodeMsg, &AnsiMsg)) + if (! MsgiAnsiToUnicodeMessage(hWnd, &UnicodeMsg, &AnsiMsg)) { goto Exit; } @@ -1512,7 +1552,7 @@ DispatchMessageA(CONST MSG *lpmsg) } else { - if (!MsgiAnsiToUnicodeMessage(&UnicodeMsg, (LPMSG)lpmsg)) + if (!MsgiAnsiToUnicodeMessage(lpmsg->hwnd, &UnicodeMsg, (LPMSG)lpmsg)) { return FALSE; } @@ -1970,7 +2010,7 @@ SendMessageA(HWND Wnd, UINT Msg, WPARAM wParam, LPARAM lParam) AnsiMsg.wParam = wParam; AnsiMsg.lParam = lParam; - if (!MsgiAnsiToUnicodeMessage(&UcMsg, &AnsiMsg)) + if (!MsgiAnsiToUnicodeMessage(Wnd, &UcMsg, &AnsiMsg)) { return FALSE; } @@ -2020,7 +2060,7 @@ SendMessageCallbackA( AnsiMsg.wParam = wParam; AnsiMsg.lParam = lParam; - if (!MsgiAnsiToUnicodeMessage(&UcMsg, &AnsiMsg)) + if (!MsgiAnsiToUnicodeMessage(hWnd, &UcMsg, &AnsiMsg)) { return FALSE; } @@ -2118,7 +2158,7 @@ SendMessageTimeoutA( AnsiMsg.wParam = wParam; AnsiMsg.lParam = lParam; - if (! MsgiAnsiToUnicodeMessage(&UcMsg, &AnsiMsg)) + if (! MsgiAnsiToUnicodeMessage(hWnd, &UcMsg, &AnsiMsg)) { return FALSE; } @@ -2221,7 +2261,7 @@ SendNotifyMessageA( AnsiMsg.message = Msg; AnsiMsg.wParam = wParam; AnsiMsg.lParam = lParam; - if (! MsgiAnsiToUnicodeMessage(&UcMsg, &AnsiMsg)) + if (! MsgiAnsiToUnicodeMessage(hWnd, &UcMsg, &AnsiMsg)) { return FALSE; } diff --git a/reactos/subsystems/win32/win32k/ntuser/message.c b/reactos/subsystems/win32/win32k/ntuser/message.c index 56cfc304f4e..ea0a03e201e 100644 --- a/reactos/subsystems/win32/win32k/ntuser/message.c +++ b/reactos/subsystems/win32/win32k/ntuser/message.c @@ -33,6 +33,81 @@ IntCleanupMessageImpl(VOID) return STATUS_SUCCESS; } +/* From wine: */ +/* flag for messages that contain pointers */ +/* 32 messages per entry, messages 0..31 map to bits 0..31 */ + +#define SET(msg) (1 << ((msg) & 31)) + +static const unsigned int message_pointer_flags[] = +{ + /* 0x00 - 0x1f */ + SET(WM_CREATE) | SET(WM_SETTEXT) | SET(WM_GETTEXT) | + SET(WM_WININICHANGE) | SET(WM_DEVMODECHANGE), + /* 0x20 - 0x3f */ + SET(WM_GETMINMAXINFO) | SET(WM_DRAWITEM) | SET(WM_MEASUREITEM) | SET(WM_DELETEITEM) | + SET(WM_COMPAREITEM), + /* 0x40 - 0x5f */ + SET(WM_WINDOWPOSCHANGING) | SET(WM_WINDOWPOSCHANGED) | SET(WM_COPYDATA) | + SET(WM_COPYGLOBALDATA) | SET(WM_NOTIFY) | SET(WM_HELP), + /* 0x60 - 0x7f */ + SET(WM_STYLECHANGING) | SET(WM_STYLECHANGED), + /* 0x80 - 0x9f */ + SET(WM_NCCREATE) | SET(WM_NCCALCSIZE) | SET(WM_GETDLGCODE), + /* 0xa0 - 0xbf */ + SET(EM_GETSEL) | SET(EM_GETRECT) | SET(EM_SETRECT) | SET(EM_SETRECTNP), + /* 0xc0 - 0xdf */ + SET(EM_REPLACESEL) | SET(EM_GETLINE) | SET(EM_SETTABSTOPS), + /* 0xe0 - 0xff */ + SET(SBM_GETRANGE) | SET(SBM_SETSCROLLINFO) | SET(SBM_GETSCROLLINFO) | SET(SBM_GETSCROLLBARINFO), + /* 0x100 - 0x11f */ + 0, + /* 0x120 - 0x13f */ + 0, + /* 0x140 - 0x15f */ + SET(CB_GETEDITSEL) | SET(CB_ADDSTRING) | SET(CB_DIR) | SET(CB_GETLBTEXT) | + SET(CB_INSERTSTRING) | SET(CB_FINDSTRING) | SET(CB_SELECTSTRING) | + SET(CB_GETDROPPEDCONTROLRECT) | SET(CB_FINDSTRINGEXACT), + /* 0x160 - 0x17f */ + 0, + /* 0x180 - 0x19f */ + SET(LB_ADDSTRING) | SET(LB_INSERTSTRING) | SET(LB_GETTEXT) | SET(LB_SELECTSTRING) | + SET(LB_DIR) | SET(LB_FINDSTRING) | + SET(LB_GETSELITEMS) | SET(LB_SETTABSTOPS) | SET(LB_ADDFILE) | SET(LB_GETITEMRECT), + /* 0x1a0 - 0x1bf */ + SET(LB_FINDSTRINGEXACT), + /* 0x1c0 - 0x1df */ + 0, + /* 0x1e0 - 0x1ff */ + 0, + /* 0x200 - 0x21f */ + SET(WM_NEXTMENU) | SET(WM_SIZING) | SET(WM_MOVING) | SET(WM_DEVICECHANGE), + /* 0x220 - 0x23f */ + SET(WM_MDICREATE) | SET(WM_MDIGETACTIVE) | SET(WM_DROPOBJECT) | + SET(WM_QUERYDROPOBJECT) | SET(WM_DRAGLOOP) | SET(WM_DRAGSELECT) | SET(WM_DRAGMOVE), + /* 0x240 - 0x25f */ + 0, + /* 0x260 - 0x27f */ + 0, + /* 0x280 - 0x29f */ + 0, + /* 0x2a0 - 0x2bf */ + 0, + /* 0x2c0 - 0x2df */ + 0, + /* 0x2e0 - 0x2ff */ + 0, + /* 0x300 - 0x31f */ + SET(WM_ASKCBFORMATNAME) +}; + +/* check whether a given message type includes pointers */ +static inline int is_pointer_message( UINT message ) +{ + if (message >= 8*sizeof(message_pointer_flags)) return FALSE; + return (message_pointer_flags[message / 32] & SET(message)) != 0; +} + #define MMS_SIZE_WPARAM -1 #define MMS_SIZE_WPARAMWCHAR -2 #define MMS_SIZE_LPARAMSZ -3 @@ -64,6 +139,7 @@ static MSGMEMORY MsgMemory[] = { WM_COPYGLOBALDATA, MMS_SIZE_WPARAM, MMS_FLAG_READ }, { WM_WINDOWPOSCHANGED, sizeof(WINDOWPOS), MMS_FLAG_READ }, { WM_WINDOWPOSCHANGING, sizeof(WINDOWPOS), MMS_FLAG_READWRITE }, + { WM_MDICREATE, MMS_SIZE_SPECIAL, MMS_FLAG_READWRITE }, }; static PMSGMEMORY FASTCALL @@ -89,6 +165,7 @@ static UINT FASTCALL MsgMemorySize(PMSGMEMORY MsgMemoryEntry, WPARAM wParam, LPARAM lParam) { CREATESTRUCTW *Cs; + MDICREATESTRUCTW *mCs; PUNICODE_STRING WindowName; PUNICODE_STRING ClassName; UINT Size = 0; @@ -127,6 +204,21 @@ MsgMemorySize(PMSGMEMORY MsgMemoryEntry, WPARAM wParam, LPARAM lParam) } break; + case WM_MDICREATE: + mCs = (MDICREATESTRUCTW *)lParam; + WindowName = (PUNICODE_STRING) mCs->szTitle; + ClassName = (PUNICODE_STRING) mCs->szClass; + Size = sizeof(MDICREATESTRUCTW) + WindowName->Length + sizeof(WCHAR); + if (IS_ATOM(ClassName->Buffer)) + { + Size += sizeof(WCHAR) + sizeof(ATOM); + } + else + { + Size += sizeof(WCHAR) + ClassName->Length + sizeof(WCHAR); + } + break; + case WM_NCCALCSIZE: Size = wParam ? sizeof(NCCALCSIZE_PARAMS) + sizeof(WINDOWPOS) : sizeof(RECT); break; @@ -162,6 +254,7 @@ PackParam(LPARAM *lParamPacked, UINT Msg, WPARAM wParam, LPARAM lParam, BOOL Non NCCALCSIZE_PARAMS *PackedNcCalcsize; CREATESTRUCTW *UnpackedCs; CREATESTRUCTW *PackedCs; + MDICREATESTRUCTW *UnpackedmCs, *PackedmCs; PLARGE_STRING WindowName; PUNICODE_STRING ClassName; POOL_TYPE PoolType; @@ -240,6 +333,53 @@ PackParam(LPARAM *lParamPacked, UINT Msg, WPARAM wParam, LPARAM lParam, BOOL Non ASSERT(CsData == (PCHAR) PackedCs + Size); *lParamPacked = (LPARAM) PackedCs; } + else if (WM_MDICREATE == Msg) + { + UnpackedmCs = (MDICREATESTRUCTW *) lParam; + WindowName = (PLARGE_STRING) UnpackedmCs->szTitle; + ClassName = (PUNICODE_STRING) UnpackedmCs->szClass; + Size = sizeof(MDICREATESTRUCTW) + WindowName->Length + sizeof(WCHAR); + if (IS_ATOM(ClassName->Buffer)) + { + Size += sizeof(WCHAR) + sizeof(ATOM); + } + else + { + Size += sizeof(WCHAR) + ClassName->Length + sizeof(WCHAR); + } + PackedmCs = ExAllocatePoolWithTag(PoolType, Size, TAG_MSG); + if (NULL == PackedmCs) + { + DPRINT1("Not enough memory to pack lParam\n"); + return STATUS_NO_MEMORY; + } + RtlCopyMemory(PackedmCs, UnpackedmCs, sizeof(CREATESTRUCTW)); + CsData = (PCHAR) (PackedmCs + 1); + PackedmCs->szTitle = (LPCWSTR) (CsData - (PCHAR) PackedmCs); + RtlCopyMemory(CsData, WindowName->Buffer, WindowName->Length); + CsData += WindowName->Length; + *((WCHAR *) CsData) = L'\0'; + CsData += sizeof(WCHAR); + PackedmCs->szClass = (LPCWSTR) (CsData - (PCHAR) PackedmCs); + if (IS_ATOM(ClassName->Buffer)) + { + *((WCHAR *) CsData) = L'A'; + CsData += sizeof(WCHAR); + *((ATOM *) CsData) = (ATOM)(DWORD_PTR) ClassName->Buffer; + CsData += sizeof(ATOM); + } + else + { + *((WCHAR *) CsData) = L'S'; + CsData += sizeof(WCHAR); + RtlCopyMemory(CsData, ClassName->Buffer, ClassName->Length); + CsData += ClassName->Length; + *((WCHAR *) CsData) = L'\0'; + CsData += sizeof(WCHAR); + } + ASSERT(CsData == (PCHAR) PackedmCs + Size); + *lParamPacked = (LPARAM) PackedmCs; + } else if (PoolType == NonPagedPool) { PMSGMEMORY MsgMemoryEntry; @@ -290,6 +430,11 @@ UnpackParam(LPARAM lParamPacked, UINT Msg, WPARAM wParam, LPARAM lParam, BOOL No return STATUS_SUCCESS; } + else if (WM_MDICREATE == Msg) + { + ExFreePool((PVOID) lParamPacked); + return STATUS_SUCCESS; + } else if (NonPagedPoolUsed) { PMSGMEMORY MsgMemoryEntry; @@ -910,7 +1055,7 @@ UserPostThreadMessage( DWORD idThread, LARGE_INTEGER LargeTickCount; NTSTATUS Status; - if (FindMsgMemory(Msg) != 0) + if (is_pointer_message(Msg)) { EngSetLastError(ERROR_MESSAGE_SYNC_ONLY ); return FALSE; @@ -990,7 +1135,7 @@ UserPostMessage( HWND Wnd, return TRUE; } - if (MsgMemoryEntry) + if (is_pointer_message(Message.message)) { EngSetLastError(ERROR_MESSAGE_SYNC_ONLY ); return FALSE; @@ -1486,7 +1631,7 @@ UserSendNotifyMessage( HWND hWnd, { BOOL Ret = TRUE; - if (FindMsgMemory(Msg) != 0) + if (is_pointer_message(Msg)) { EngSetLastError(ERROR_MESSAGE_SYNC_ONLY ); return FALSE; From c1d677d16ae759d5d7c834bb3c2ccf7194ced478 Mon Sep 17 00:00:00 2001 From: James Tabor Date: Thu, 30 Dec 2010 05:56:50 +0000 Subject: [PATCH 162/181] - Fix copy paste error, which means this code is not used, should have pop up during testing. svn path=/trunk/; revision=50222 --- reactos/subsystems/win32/win32k/ntuser/message.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reactos/subsystems/win32/win32k/ntuser/message.c b/reactos/subsystems/win32/win32k/ntuser/message.c index ea0a03e201e..97f89a339f6 100644 --- a/reactos/subsystems/win32/win32k/ntuser/message.c +++ b/reactos/subsystems/win32/win32k/ntuser/message.c @@ -353,7 +353,7 @@ PackParam(LPARAM *lParamPacked, UINT Msg, WPARAM wParam, LPARAM lParam, BOOL Non DPRINT1("Not enough memory to pack lParam\n"); return STATUS_NO_MEMORY; } - RtlCopyMemory(PackedmCs, UnpackedmCs, sizeof(CREATESTRUCTW)); + RtlCopyMemory(PackedmCs, UnpackedmCs, sizeof(MDICREATESTRUCTW)); CsData = (PCHAR) (PackedmCs + 1); PackedmCs->szTitle = (LPCWSTR) (CsData - (PCHAR) PackedmCs); RtlCopyMemory(CsData, WindowName->Buffer, WindowName->Length); From 4eef1c1925a255ae0544d7b0ca3ce81a91078ae1 Mon Sep 17 00:00:00 2001 From: Michael Martin Date: Thu, 30 Dec 2010 15:12:46 +0000 Subject: [PATCH 163/181] [usb/usbehci]: - Reorganization code to put hardware related structures and routines in own source files. - Modify ResetPort to correctly reset the port instead of the controller. - Implement allocating chunks of memory from the Common Buffer for use with the rest of source code. svn path=/trunk/; revision=50223 --- reactos/drivers/usb/usbehci/hardware.c | 275 ++++++++++++++++++++++ reactos/drivers/usb/usbehci/hardware.h | 307 +++++++++++++++++++++++++ reactos/drivers/usb/usbehci/physmem.c | 94 ++++++++ reactos/drivers/usb/usbehci/physmem.h | 25 ++ 4 files changed, 701 insertions(+) create mode 100644 reactos/drivers/usb/usbehci/hardware.c create mode 100644 reactos/drivers/usb/usbehci/hardware.h create mode 100644 reactos/drivers/usb/usbehci/physmem.c create mode 100644 reactos/drivers/usb/usbehci/physmem.h diff --git a/reactos/drivers/usb/usbehci/hardware.c b/reactos/drivers/usb/usbehci/hardware.c new file mode 100644 index 00000000000..0adf59e5e3b --- /dev/null +++ b/reactos/drivers/usb/usbehci/hardware.c @@ -0,0 +1,275 @@ +/* + * PROJECT: ReactOS Universal Serial Bus Bulk Enhanced Host Controller Interface + * LICENSE: GPL - See COPYING in the top level directory + * FILE: drivers/usb/usbehci/hardware.c + * PURPOSE: Hardware related routines. + * PROGRAMMERS: + * Michael Martin (michael.martin@reactos.org) + */ + +#include "hardware.h" +#define NDEBUG +#include + +//FORCEINLINE +VOID +SetAsyncListQueueRegister(PEHCI_HOST_CONTROLLER hcd, ULONG PhysicalAddr) +{ + ULONG OpRegisters = hcd->OpRegisters; + WRITE_REGISTER_ULONG((PULONG)(OpRegisters + EHCI_ASYNCLISTBASE), PhysicalAddr); +} + +//FORCEINLINE +ULONG +GetAsyncListQueueRegister(PEHCI_HOST_CONTROLLER hcd) +{ + ULONG OpRegisters = hcd->OpRegisters; + return READ_REGISTER_ULONG((PULONG)(OpRegisters + EHCI_ASYNCLISTBASE)); +} + +//FORCEINLINE +VOID +SetPeriodicFrameListRegister(PEHCI_HOST_CONTROLLER hcd, ULONG PhysicalAddr) +{ + ULONG OpRegisters = hcd->OpRegisters; + WRITE_REGISTER_ULONG((PULONG)(OpRegisters + EHCI_PERIODICLISTBASE), PhysicalAddr); +} + +//FORCEINLINE +ULONG +GetPeriodicFrameListRegister(PEHCI_HOST_CONTROLLER hcd) +{ + ULONG OpRegisters = hcd->OpRegisters; + return READ_REGISTER_ULONG((PULONG) (OpRegisters + EHCI_PERIODICLISTBASE)); +} + +//FORCEINLINE +ULONG +ReadControllerStatus(PEHCI_HOST_CONTROLLER hcd) +{ + ULONG OpRegisters = hcd->OpRegisters; + return READ_REGISTER_ULONG ((PULONG) (OpRegisters + EHCI_USBSTS)); +} + +//FORCEINLINE +VOID +ClearControllerStatus(PEHCI_HOST_CONTROLLER hcd, ULONG Status) +{ + ULONG OpRegisters = hcd->OpRegisters; + WRITE_REGISTER_ULONG((PULONG) (OpRegisters + EHCI_USBSTS), Status); +} + +VOID +ResetPort(PEHCI_HOST_CONTROLLER hcd, UCHAR Port) +{ + ULONG tmp; + ULONG OpRegisters = hcd->OpRegisters; + DPRINT1("Reset Port %x\n", Port); + + tmp = READ_REGISTER_ULONG((PULONG) ((OpRegisters + EHCI_PORTSC) + (4 * Port))); + if (tmp & 0x400) + { + DPRINT1("Non HighSpeed device connected. Releasing ownership.\n"); + WRITE_REGISTER_ULONG((PULONG) ((OpRegisters + EHCI_PORTSC) + (4 * Port)), 0x2000); + } + + /* Get current port state */ + tmp = READ_REGISTER_ULONG((PULONG) ((OpRegisters + EHCI_PORTSC) + (4 * Port))); + + /* Set reset and clear enable */ + tmp |= 0x100; + tmp &= ~0x04; + WRITE_REGISTER_ULONG((PULONG) ((OpRegisters + EHCI_PORTSC) + (4 * Port)), tmp); + + /* USB 2.0 Spec 10.2.8.1, more than 50ms */ + KeStallExecutionProcessor(100); + + /* Clear reset */ + tmp &= ~0x100; + WRITE_REGISTER_ULONG((PULONG) ((OpRegisters + EHCI_PORTSC) + (4 * Port)), tmp); + + KeStallExecutionProcessor(100); + + tmp = READ_REGISTER_ULONG((PULONG) ((OpRegisters + EHCI_PORTSC) + (4 * Port))); + + if (tmp & 0x100) + { + DPRINT1("EHCI ERROR: Port Reset did not complete!\n"); + } +} + +VOID +StopEhci(PEHCI_HOST_CONTROLLER hcd) +{ + ULONG OpRegisters = hcd->OpRegisters; + PEHCI_USBCMD_CONTENT UsbCmd; + PEHCI_USBSTS_CONTEXT UsbSts; + LONG FailSafe; + LONG tmp; + + DPRINT1("Stopping Ehci controller\n"); + + WRITE_REGISTER_ULONG((PULONG) (OpRegisters + EHCI_USBINTR), 0); + + tmp = READ_REGISTER_ULONG((PULONG) (OpRegisters + EHCI_USBCMD)); + UsbCmd = (PEHCI_USBCMD_CONTENT) & tmp; + UsbCmd->Run = FALSE; + WRITE_REGISTER_ULONG((PULONG) (OpRegisters + EHCI_USBCMD), tmp); + + /* Wait for the device to stop */ + for (FailSafe = 100; FailSafe > 1; FailSafe++) + { + KeStallExecutionProcessor(10); + tmp = READ_REGISTER_ULONG((PULONG)(OpRegisters + EHCI_USBSTS)); + UsbSts = (PEHCI_USBSTS_CONTEXT)&tmp; + + if (UsbSts->HCHalted) + { + break; + } + } + if (!UsbSts->HCHalted) + DPRINT1("EHCI ERROR: Controller is not responding to Stop request!\n"); +} + +VOID +StartEhci(PEHCI_HOST_CONTROLLER hcd) +{ + ULONG OpRegisters = hcd->OpRegisters; + PEHCI_USBCMD_CONTENT UsbCmd; + PEHCI_USBSTS_CONTEXT UsbSts; + LONG FailSafe; + LONG tmp; + LONG tmp2; + + DPRINT("Starting Ehci controller\n"); + + tmp = READ_REGISTER_ULONG((PULONG)(OpRegisters + EHCI_USBSTS)); + UsbSts = (PEHCI_USBSTS_CONTEXT)&tmp; + + if (!UsbSts->HCHalted) + { + StopEhci(hcd); + } + + tmp = READ_REGISTER_ULONG ((PULONG)(OpRegisters + EHCI_USBCMD)); + + /* Reset the device */ + UsbCmd = (PEHCI_USBCMD_CONTENT) &tmp; + UsbCmd->HCReset = TRUE; + WRITE_REGISTER_ULONG ((PULONG)(OpRegisters + EHCI_USBCMD), tmp); + + /* Wait for the device to reset */ + for (FailSafe = 100; FailSafe > 1; FailSafe++) + { + KeStallExecutionProcessor(10); + tmp = READ_REGISTER_ULONG((PULONG)(OpRegisters + EHCI_USBCMD)); + UsbCmd = (PEHCI_USBCMD_CONTENT)&tmp; + + if (!UsbCmd->HCReset) + { + break; + } + DPRINT("Waiting for reset, USBCMD: %x\n", READ_REGISTER_ULONG ((PULONG)(OpRegisters + EHCI_USBCMD))); + } + + if (UsbCmd->HCReset) + { + DPRINT1("EHCI ERROR: Controller failed to reset! Will attempt to continue.\n"); + } + + UsbCmd = (PEHCI_USBCMD_CONTENT) &tmp; + + /* Disable Interrupts on the device */ + WRITE_REGISTER_ULONG((PULONG)(OpRegisters + EHCI_USBINTR), 0); + /* Clear the Status */ + WRITE_REGISTER_ULONG((PULONG)(OpRegisters + EHCI_USBSTS), 0x0000001f); + + WRITE_REGISTER_ULONG((PULONG)(OpRegisters + EHCI_CTRLDSSEGMENT), 0); + + SetAsyncListQueueRegister(hcd, hcd->AsyncListQueue->PhysicalAddr | QH_TYPE_QH); + /* Set the ansync and periodic to disable */ + UsbCmd->PeriodicEnable = FALSE; + UsbCmd->AsyncEnable = TRUE; + WRITE_REGISTER_ULONG((PULONG)(OpRegisters + EHCI_USBCMD), tmp); + + /* Set the threshold */ + UsbCmd->IntThreshold = 1; + WRITE_REGISTER_ULONG((PULONG)(OpRegisters + EHCI_USBCMD), tmp); + + /* Turn back on interrupts */ + WRITE_REGISTER_ULONG((PULONG)(OpRegisters + EHCI_USBINTR), + EHCI_USBINTR_ERR | EHCI_USBINTR_ASYNC | EHCI_USBINTR_HSERR + /*| EHCI_USBINTR_FLROVR*/ | EHCI_USBINTR_PC); + WRITE_REGISTER_ULONG((PULONG)(OpRegisters + EHCI_USBINTR), + EHCI_USBINTR_INTE | EHCI_USBINTR_ERR | EHCI_USBINTR_ASYNC | EHCI_USBINTR_HSERR + /*| EHCI_USBINTR_FLROVR*/ | EHCI_USBINTR_PC); + + UsbCmd->Run = TRUE; + WRITE_REGISTER_ULONG((PULONG)(OpRegisters + EHCI_USBCMD), tmp); + + /* Wait for the device to start */ + for (;;) + { + KeStallExecutionProcessor(10); + tmp2 = READ_REGISTER_ULONG((PULONG)(OpRegisters + EHCI_USBSTS)); + UsbSts = (PEHCI_USBSTS_CONTEXT)&tmp2; + + if (!UsbSts->HCHalted) + { + break; + } + DPRINT("Waiting for start, USBSTS: %x\n", READ_REGISTER_ULONG ((PULONG)(OpRegisters + EHCI_USBSTS))); + } + + /* Set all port routing to ECHI controller */ + WRITE_REGISTER_ULONG((PULONG)(OpRegisters + EHCI_CONFIGFLAG), 1); +} + +VOID +GetCapabilities(PEHCI_CAPS PCap, ULONG CapRegister) +{ + PEHCI_HCS_CONTENT PHCS; + LONG i; + + if (!PCap) + return; + + PCap->Length = READ_REGISTER_UCHAR((PUCHAR)CapRegister); + PCap->Reserved = READ_REGISTER_UCHAR((PUCHAR)(CapRegister + 1)); + PCap->HCIVersion = READ_REGISTER_USHORT((PUSHORT)(CapRegister + 2)); + PCap->HCSParamsLong = READ_REGISTER_ULONG((PULONG)(CapRegister + 4)); + PCap->HCCParams = READ_REGISTER_ULONG((PULONG)(CapRegister + 8)); + + DPRINT1("Length %d\n", PCap->Length); + DPRINT1("Reserved %d\n", PCap->Reserved); + DPRINT1("HCIVersion %x\n", PCap->HCIVersion); + DPRINT1("HCSParams %x\n", PCap->HCSParamsLong); + DPRINT1("HCCParams %x\n", PCap->HCCParams); + + if (PCap->HCCParams & 0x02) + DPRINT1("Frame list size is configurable\n"); + + if (PCap->HCCParams & 0x01) + DPRINT1("64bit address mode not supported!\n"); + + DPRINT1("Number of Ports: %d\n", PCap->HCSParams.PortCount); + + if (PCap->HCSParams.PortPowerControl) + DPRINT1("Port Power Control is enabled\n"); + + if (!PCap->HCSParams.CHCCount) + { + DPRINT1("Number of Companion Host controllers %x\n", PCap->HCSParams.CHCCount); + DPRINT1("Number of Ports Per CHC: %d\n", PCap->HCSParams.PortPerCHC); + } + + PHCS = (PEHCI_HCS_CONTENT)&PCap->HCSParams; + if (PHCS->PortRouteRules) + { + for (i = 0; i < PCap->HCSParams.PortCount; i++) + { + PCap->PortRoute[i] = READ_REGISTER_UCHAR((PUCHAR) (CapRegister + 12 + i)); + } + } +} diff --git a/reactos/drivers/usb/usbehci/hardware.h b/reactos/drivers/usb/usbehci/hardware.h new file mode 100644 index 00000000000..bc9d1d3e9f1 --- /dev/null +++ b/reactos/drivers/usb/usbehci/hardware.h @@ -0,0 +1,307 @@ +#pragma once + +#include + +/* USB Command Register */ +#define EHCI_USBCMD 0x00 +#define EHCI_USBSTS 0x04 +#define EHCI_USBINTR 0x08 +#define EHCI_FRINDEX 0x0C +#define EHCI_CTRLDSSEGMENT 0x10 +#define EHCI_PERIODICLISTBASE 0x14 +#define EHCI_ASYNCLISTBASE 0x18 +#define EHCI_CONFIGFLAG 0x40 +#define EHCI_PORTSC 0x44 + +/* USB Interrupt Register Flags 32 Bits */ +#define EHCI_USBINTR_INTE 0x01 +#define EHCI_USBINTR_ERR 0x02 +#define EHCI_USBINTR_PC 0x04 +#define EHCI_USBINTR_FLROVR 0x08 +#define EHCI_USBINTR_HSERR 0x10 +#define EHCI_USBINTR_ASYNC 0x20 +/* Bits 6:31 Reserved */ + +/* Status Register Flags 32 Bits */ +#define EHCI_STS_INT 0x01 +#define EHCI_STS_ERR 0x02 +#define EHCI_STS_PCD 0x04 +#define EHCI_STS_FLR 0x08 +#define EHCI_STS_FATAL 0x10 +#define EHCI_STS_IAA 0x20 +/* Bits 11:6 Reserved */ +#define EHCI_STS_HALT 0x1000 +#define EHCI_STS_RECL 0x2000 +#define EHCI_STS_PSS 0x4000 +#define EHCI_STS_ASS 0x8000 +#define EHCI_ERROR_INT ( EHCI_STS_FATAL | EHCI_STS_ERR ) + + +/* Last bit in QUEUE ELEMENT TRANSFER DESCRIPTOR Next Pointer */ +/* Used for Queue Element Transfer Descriptor Pointers + and Queue Head Horizontal Link Pointers */ +#define TERMINATE_POINTER 0x01 + +/* QUEUE ELEMENT TRANSFER DESCRIPTOR, Token defines and structs */ + +/* PIDCodes for QETD_TOKEN +OR with QUEUE_TRANSFER_DESCRIPTOR Token.PIDCode*/ +#define PID_CODE_OUT_TOKEN 0x00 +#define PID_CODE_IN_TOKEN 0x01 +#define PID_CODE_SETUP_TOKEN 0x02 + +/* Split Transaction States +OR with QUEUE_TRANSFER_DESCRIPTOR Token.SplitTransactionState */ +#define DO_START_SPLIT 0x00 +#define DO_COMPLETE_SPLIT 0x01 + +/* Ping States, OR with QUEUE_TRANSFER_DESCRIPTOR Token. */ +#define PING_STATE_DO_OUT 0x00 +#define PING_STATE_DO_PING 0x01 + +typedef struct _PERIODICFRAMELIST +{ + PULONG VirtualAddr; + PHYSICAL_ADDRESS PhysicalAddr; + ULONG Size; +} PERIODICFRAMELIST, *PPERIODICFRAMELIST; + + +/* QUEUE ELEMENT TRANSFER DESCRIPTOR TOKEN */ +typedef struct _QETD_TOKEN_BITS +{ + ULONG PingState:1; + ULONG SplitTransactionState:1; + ULONG MissedMicroFrame:1; + ULONG TransactionError:1; + ULONG BabbleDetected:1; + ULONG DataBufferError:1; + ULONG Halted:1; + ULONG Active:1; + ULONG PIDCode:2; + ULONG ErrorCounter:2; + ULONG CurrentPage:3; + ULONG InterruptOnComplete:1; + ULONG TotalBytesToTransfer:15; + ULONG DataToggle:1; +} QETD_TOKEN_BITS, *PQETD_TOKEN_BITS; + +/* QUEUE ELEMENT TRANSFER DESCRIPTOR */ +typedef struct _QUEUE_TRANSFER_DESCRIPTOR +{ + //Hardware + ULONG NextPointer; + ULONG AlternateNextPointer; + union + { + QETD_TOKEN_BITS Bits; + ULONG DWord; + } Token; + ULONG BufferPointer[5]; + + //Software + ULONG PhysicalAddr; + struct _QUEUE_TRANSFER_DESCRIPTOR *PreviousDescriptor; + struct _QUEUE_TRANSFER_DESCRIPTOR *NextDescriptor; +} QUEUE_TRANSFER_DESCRIPTOR, *PQUEUE_TRANSFER_DESCRIPTOR; + +/* EndPointSpeeds of END_POINT_CHARACTERISTICS */ +#define QH_ENDPOINT_FULLSPEED 0x00 +#define QH_ENDPOINT_LOWSPEED 0x01 +#define QH_ENDPOINT_HIGHSPEED 0x02 + +typedef struct _END_POINT_CHARACTERISTICS +{ + ULONG DeviceAddress:7; + ULONG InactiveOnNextTransaction:1; + ULONG EndPointNumber:4; + ULONG EndPointSpeed:2; + ULONG QEDTDataToggleControl:1; + ULONG HeadOfReclamation:1; + ULONG MaximumPacketLength:11; + ULONG ControlEndPointFlag:1; + ULONG NakCountReload:4; +} END_POINT_CHARACTERISTICS, *PEND_POINT_CHARACTERISTICS; + +typedef struct _END_POINT_CAPABILITIES +{ + ULONG InterruptScheduleMask:8; + ULONG SplitCompletionMask:8; + ULONG HubAddr:6; + ULONG PortNumber:6; + /* Multi */ + ULONG NumberOfTransactionPerFrame:2; +} END_POINT_CAPABILITIES, *PEND_POINT_CAPABILITIES; + + +/* QUEUE HEAD defines and structs */ + +/* QUEUE HEAD Select Types, OR with QUEUE_HEAD HorizontalLinkPointer */ +#define QH_TYPE_IDT 0x00 +#define QH_TYPE_QH 0x02 +#define QH_TYPE_SITD 0x04 +#define QH_TYPE_FSTN 0x06 + +/* QUEUE HEAD */ +typedef struct _QUEUE_HEAD +{ + //Hardware + ULONG HorizontalLinkPointer; + END_POINT_CHARACTERISTICS EndPointCharacteristics; + END_POINT_CAPABILITIES EndPointCapabilities; + /* TERMINATE_POINTER not valid for this member */ + ULONG CurrentLinkPointer; + /* TERMINATE_POINTER valid */ + ULONG NextPointer; + /* TERMINATE_POINTER valid, bits 1:4 is NAK_COUNTER */ + ULONG AlternateNextPointer; + /* Only DataToggle, InterruptOnComplete, ErrorCounter, PingState valid */ + union + { + QETD_TOKEN_BITS Bits; + ULONG DWord; + } Token; + ULONG BufferPointer[5]; + + //Software + ULONG PhysicalAddr; + struct _QUEUE_HEAD *PreviousQueueHead; + struct _QUEUE_HEAD *NextQueueHead; + PQUEUE_TRANSFER_DESCRIPTOR TransferDescriptor; + PIRP IrpToComplete; + PMDL MdlToFree; + PKEVENT Event; +} QUEUE_HEAD, *PQUEUE_HEAD; + +/* USBCMD register 32 bits */ +typedef struct _EHCI_USBCMD_CONTENT +{ + ULONG Run : 1; + ULONG HCReset : 1; + ULONG FrameListSize : 2; + ULONG PeriodicEnable : 1; + ULONG AsyncEnable : 1; + ULONG DoorBell : 1; + ULONG LightReset : 1; + ULONG AsyncParkCount : 2; + ULONG Reserved : 1; + ULONG AsyncParkEnable : 1; + ULONG Reserved1 : 4; + ULONG IntThreshold : 8; + ULONG Reserved2 : 8; + +} EHCI_USBCMD_CONTENT, *PEHCI_USBCMD_CONTENT; + +typedef struct _EHCI_USBSTS_CONTENT +{ + ULONG USBInterrupt:1; + ULONG ErrorInterrupt:1; + ULONG DetectChangeInterrupt:1; + ULONG FrameListRolloverInterrupt:1; + ULONG HostSystemErrorInterrupt:1; + ULONG AsyncAdvanceInterrupt:1; + ULONG Reserved:6; + ULONG HCHalted:1; + ULONG Reclamation:1; + ULONG PeriodicScheduleStatus:1; + ULONG AsynchronousScheduleStatus:1; +} EHCI_USBSTS_CONTEXT, *PEHCI_USBSTS_CONTEXT; + +typedef struct _EHCI_USBPORTSC_CONTENT +{ + ULONG CurrentConnectStatus:1; + ULONG ConnectStatusChange:1; + ULONG PortEnabled:1; + ULONG PortEnableChanged:1; + ULONG OverCurrentActive:1; + ULONG OverCurrentChange:1; + ULONG ForcePortResume:1; + ULONG Suspend:1; + ULONG PortReset:1; + ULONG Reserved:1; + ULONG LineStatus:2; + ULONG PortPower:1; + ULONG PortOwner:1; +} EHCI_USBPORTSC_CONTENT, *PEHCI_USBPORTSC_CONTENT; + +typedef struct _EHCI_HCS_CONTENT +{ + ULONG PortCount : 4; + ULONG PortPowerControl: 1; + ULONG Reserved : 2; + ULONG PortRouteRules : 1; + ULONG PortPerCHC : 4; + ULONG CHCCount : 4; + ULONG PortIndicator : 1; + ULONG Reserved2 : 3; + ULONG DbgPortNum : 4; + ULONG Reserved3 : 8; + +} EHCI_HCS_CONTENT, *PEHCI_HCS_CONTENT; + +typedef struct _EHCI_HCC_CONTENT +{ + ULONG CurAddrBits : 1; + ULONG VarFrameList : 1; + ULONG ParkMode : 1; + ULONG Reserved : 1; + ULONG IsoSchedThreshold : 4; + ULONG EECPCapable : 8; + ULONG Reserved2 : 16; + +} EHCI_HCC_CONTENT, *PEHCI_HCC_CONTENT; + +typedef struct _EHCI_CAPS { + UCHAR Length; + UCHAR Reserved; + USHORT HCIVersion; + union + { + EHCI_HCS_CONTENT HCSParams; + ULONG HCSParamsLong; + }; + ULONG HCCParams; + UCHAR PortRoute [8]; +} EHCI_CAPS, *PEHCI_CAPS; + +typedef struct _EHCI_HOST_CONTROLLER +{ + ULONG OpRegisters; + EHCI_CAPS ECHICaps; + PVOID CommonBufferVA; + PHYSICAL_ADDRESS CommonBufferPA; + ULONG CommonBufferSize; + PQUEUE_HEAD AsyncListQueue; + KSPIN_LOCK Lock; +} EHCI_HOST_CONTROLLER, *PEHCI_HOST_CONTROLLER; + +ULONG +ReadControllerStatus(PEHCI_HOST_CONTROLLER hcd); + +VOID +ClearControllerStatus(PEHCI_HOST_CONTROLLER hcd, ULONG Status); + +VOID +GetCapabilities(PEHCI_CAPS PCap, ULONG CapRegister); + +VOID +ResetPort(PEHCI_HOST_CONTROLLER hcd, UCHAR Port); + +VOID +StartEhci(PEHCI_HOST_CONTROLLER hcd); + +VOID +StopEhci(PEHCI_HOST_CONTROLLER hcd); + +VOID +SetAsyncListQueueRegister(PEHCI_HOST_CONTROLLER hcd, ULONG PhysicalAddr); + +ULONG +GetAsyncListQueueRegister(PEHCI_HOST_CONTROLLER hcd); + +VOID +SetPeriodicFrameListRegister(PEHCI_HOST_CONTROLLER hcd, ULONG PhysicalAddr); + +ULONG +GetPeriodicFrameListRegister(PEHCI_HOST_CONTROLLER hcd); + diff --git a/reactos/drivers/usb/usbehci/physmem.c b/reactos/drivers/usb/usbehci/physmem.c new file mode 100644 index 00000000000..ac6b4ede83c --- /dev/null +++ b/reactos/drivers/usb/usbehci/physmem.c @@ -0,0 +1,94 @@ +/* + * PROJECT: ReactOS Universal Serial Bus Bulk Enhanced Host Controller Interface + * LICENSE: GPL - See COPYING in the top level directory + * FILE: drivers/usb/usbehci/physmem.c + * PURPOSE: Common Buffer routines. + * PROGRAMMERS: + * Michael Martin (michael.martin@reactos.org) + */ + +#include "physmem.h" +#include "debug.h" + +#define SMALL_ALLOCATION_SIZE 32 + +VOID +DumpPages() +{ + //PMEM_HEADER MemBlock = (PMEM_HEADER)EhciSharedMemory.VirtualAddr; +} + +// Returns Virtual Address of Allocated Memory +ULONG +AllocateMemory(PEHCI_HOST_CONTROLLER hcd, ULONG Size, ULONG *PhysicalAddress) +{ + PMEM_HEADER MemoryPage = (PMEM_HEADER)hcd->CommonBufferVA; + ULONG PageCount = 0; + ULONG NumberOfPages = hcd->CommonBufferSize / PAGE_SIZE; + ULONG BlocksNeeded; + ULONG i,j, freeCount; + ULONG RetAddr = 0; + + Size = ((Size + SMALL_ALLOCATION_SIZE - 1) / SMALL_ALLOCATION_SIZE) * SMALL_ALLOCATION_SIZE; + BlocksNeeded = Size / SMALL_ALLOCATION_SIZE; + + do + { + if (MemoryPage->IsFull) + { + PageCount++; + MemoryPage = (PMEM_HEADER)((ULONG)MemoryPage + PAGE_SIZE); + continue; + } + freeCount = 0; + for (i = 0; i < sizeof(MemoryPage->Entry); i++) + { + if (!MemoryPage->Entry[i].InUse) + { + freeCount++; + } + else + { + freeCount = 0; + } + + if (freeCount == BlocksNeeded) + { + for (j = 0; j < freeCount; j++) + { + MemoryPage->Entry[i-j].InUse = 1; + MemoryPage->Entry[i-j].Blocks = 0; + } + + MemoryPage->Entry[i-freeCount + 1].Blocks = BlocksNeeded; + + RetAddr = (ULONG)MemoryPage + (SMALL_ALLOCATION_SIZE * (i - freeCount + 1)) + sizeof(MEM_HEADER); + + *PhysicalAddress = (ULONG)hcd->CommonBufferPA.LowPart + (RetAddr - (ULONG)hcd->CommonBufferVA); + return RetAddr; + } + } + + PageCount++; + MemoryPage = (PMEM_HEADER)((ULONG)MemoryPage + PAGE_SIZE); + } while (PageCount < NumberOfPages); + + return 0; +} + +VOID +ReleaseMemory(ULONG Address) +{ + PMEM_HEADER MemoryPage; + ULONG Index, i; + + MemoryPage = (PMEM_HEADER)(Address & ~(PAGE_SIZE - 1)); + + Index = (Address - ((ULONG)MemoryPage + sizeof(MEM_HEADER))) / SMALL_ALLOCATION_SIZE; + + for (i = 0; i < MemoryPage->Entry[Index].Blocks; i++) + { + MemoryPage->Entry[Index + i].InUse = 0; + MemoryPage->Entry[Index + i].Blocks = 0; + } +} diff --git a/reactos/drivers/usb/usbehci/physmem.h b/reactos/drivers/usb/usbehci/physmem.h new file mode 100644 index 00000000000..9b9de0b2970 --- /dev/null +++ b/reactos/drivers/usb/usbehci/physmem.h @@ -0,0 +1,25 @@ +#pragma once + +#include "hardware.h" + +typedef struct _MEM_ENTRY +{ + UCHAR InUse:1; + UCHAR Blocks:7; +} MEM_ENTRY, *PMEM_ENTRY; + +typedef struct _MEM_HEADER +{ + UCHAR IsFull; + MEM_ENTRY Entry[127]; +} MEM_HEADER, *PMEM_HEADER; + +VOID +DumpPages(); + +ULONG +AllocateMemory(PEHCI_HOST_CONTROLLER hcd, ULONG Size, ULONG *PhysicalAddress); + +VOID +ReleaseMemory(ULONG Address); + From 078e5c0a311f8a10c7e5a8734589e376cdd07b83 Mon Sep 17 00:00:00 2001 From: Amine Khaldi Date: Thu, 30 Dec 2010 17:55:25 +0000 Subject: [PATCH 164/181] [CMAKE] - Update oleaut32 winetest. - Add rosautotest to build. svn path=/trunk/; revision=50225 --- rostests/CMakeLists.txt | 2 +- rostests/rosautotest/CMakeLists.txt | 27 ++++++++++++++++++++++ rostests/winetests/oleaut32/CMakeLists.txt | 4 ++-- 3 files changed, 30 insertions(+), 3 deletions(-) create mode 100644 rostests/rosautotest/CMakeLists.txt diff --git a/rostests/CMakeLists.txt b/rostests/CMakeLists.txt index 8ce0db3ba37..91c76f36b2e 100644 --- a/rostests/CMakeLists.txt +++ b/rostests/CMakeLists.txt @@ -3,7 +3,7 @@ add_subdirectory(apitests) #add_subdirectory(dibtests) #add_subdirectory(dxtest) #add_subdirectory(regtests) -#add_subdirectory(rosautotest) +add_subdirectory(rosautotest) #add_subdirectory(tests) #add_subdirectory(win32) add_subdirectory(winetests) diff --git a/rostests/rosautotest/CMakeLists.txt b/rostests/rosautotest/CMakeLists.txt new file mode 100644 index 00000000000..4daee7ce75d --- /dev/null +++ b/rostests/rosautotest/CMakeLists.txt @@ -0,0 +1,27 @@ + +set_unicode() +set_cpp() + +list(APPEND SOURCE + CConfiguration.cpp + CFatalException.cpp + CInvalidParameterException.cpp + CJournaledTestList.cpp + CProcess.cpp + CSimpleException.cpp + CTest.cpp + CTestInfo.cpp + CTestList.cpp + CVirtualTestList.cpp + CWebService.cpp + CWineTest.cpp + main.cpp + shutdown.cpp + tools.cpp) + +add_executable(rosautotest ${SOURCE}) + +target_link_libraries(rosautotest wine) + +set_module_type(rosautotest win32cui) +add_importlibs(rosautotest advapi32 shell32 user32 wininet msvcrt kernel32 ntdll) diff --git a/rostests/winetests/oleaut32/CMakeLists.txt b/rostests/winetests/oleaut32/CMakeLists.txt index 8174f11ef98..5ec06a92ba3 100644 --- a/rostests/winetests/oleaut32/CMakeLists.txt +++ b/rostests/winetests/oleaut32/CMakeLists.txt @@ -5,10 +5,10 @@ add_definitions( include_directories(${REACTOS_SOURCE_DIR}/include/reactos/wine) -ADD_TYPELIB(oleaut32_typelibs test_reg.idl test_tlb.idl tmarshal.idl) +add_typelib(oleaut32_typelibs test_reg.idl test_tlb.idl tmarshal.idl) add_dependencies(oleaut32_typelibs stdole2) -ADD_INTERFACE_DEFINITIONS(oleaut32_idlheaders test_reg.idl tmarshal.idl) +add_interface_definitions(oleaut32_idlheaders test_reg.idl tmarshal.idl) add_idl_interface(tmarshal.idl) list(APPEND SOURCE From e26b7f9a6692b4e4584474a7a338845c87384947 Mon Sep 17 00:00:00 2001 From: Amine Khaldi Date: Thu, 30 Dec 2010 17:58:18 +0000 Subject: [PATCH 165/181] [CMAKE] - Wine lib isn't needed for rosautotest. svn path=/trunk/; revision=50226 --- rostests/rosautotest/CMakeLists.txt | 2 -- 1 file changed, 2 deletions(-) diff --git a/rostests/rosautotest/CMakeLists.txt b/rostests/rosautotest/CMakeLists.txt index 4daee7ce75d..9155971f854 100644 --- a/rostests/rosautotest/CMakeLists.txt +++ b/rostests/rosautotest/CMakeLists.txt @@ -21,7 +21,5 @@ list(APPEND SOURCE add_executable(rosautotest ${SOURCE}) -target_link_libraries(rosautotest wine) - set_module_type(rosautotest win32cui) add_importlibs(rosautotest advapi32 shell32 user32 wininet msvcrt kernel32 ntdll) From ab2048a22fa2671da690fa975118c2b195018559 Mon Sep 17 00:00:00 2001 From: Sylvain Petreolle Date: Thu, 30 Dec 2010 21:49:36 +0000 Subject: [PATCH 166/181] [CMAKE] Add rosautotest and kernel32_winetest to bootcdregtest. cmake bootcdregtest lives. svn path=/trunk/; revision=50227 --- rostests/rosautotest/CMakeLists.txt | 7 ++++++- rostests/winetests/kernel32/CMakeLists.txt | 2 ++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/rostests/rosautotest/CMakeLists.txt b/rostests/rosautotest/CMakeLists.txt index 9155971f854..9b12bdce0ed 100644 --- a/rostests/rosautotest/CMakeLists.txt +++ b/rostests/rosautotest/CMakeLists.txt @@ -19,7 +19,12 @@ list(APPEND SOURCE shutdown.cpp tools.cpp) -add_executable(rosautotest ${SOURCE}) +add_executable(rosautotest +#${CMAKE_CURRENT_BINARY_DIR}/rosautotest_precomp.h.gch +${SOURCE}) +#add_pch(rosautotest ${CMAKE_CURRENT_SOURCE_DIR}/precomp.h ${SOURCE}) set_module_type(rosautotest win32cui) add_importlibs(rosautotest advapi32 shell32 user32 wininet msvcrt kernel32 ntdll) + +add_cab_target(rosautotest 1) \ No newline at end of file diff --git a/rostests/winetests/kernel32/CMakeLists.txt b/rostests/winetests/kernel32/CMakeLists.txt index 45634007224..9094a050c45 100644 --- a/rostests/winetests/kernel32/CMakeLists.txt +++ b/rostests/winetests/kernel32/CMakeLists.txt @@ -45,3 +45,5 @@ add_executable(kernel32_winetest ${SOURCE}) target_link_libraries(kernel32_winetest wine) set_module_type(kernel32_winetest win32cui) add_importlibs(kernel32_winetest user32 advapi32 msvcrt kernel32 ntdll) + +add_cab_target(kernel32_winetest 7) \ No newline at end of file From 37fdeb8a467fdc6c7a9c03ca514649ea1f3d083a Mon Sep 17 00:00:00 2001 From: Sylvain Petreolle Date: Thu, 30 Dec 2010 22:17:33 +0000 Subject: [PATCH 167/181] [CMAKE] Add all winetests to bootcd, thanks to unix find :) svn path=/trunk/; revision=50228 --- rostests/winetests/advapi32/CMakeLists.txt | 1 + rostests/winetests/advpack/CMakeLists.txt | 1 + rostests/winetests/amstream/CMakeLists.txt | 3 ++- rostests/winetests/atl/CMakeLists.txt | 1 + rostests/winetests/avifil32/CMakeLists.txt | 1 + rostests/winetests/browseui/CMakeLists.txt | 1 + rostests/winetests/cabinet/CMakeLists.txt | 1 + rostests/winetests/comcat/CMakeLists.txt | 1 + rostests/winetests/comctl32/CMakeLists.txt | 1 + rostests/winetests/comdlg32/CMakeLists.txt | 1 + rostests/winetests/credui/CMakeLists.txt | 1 + rostests/winetests/crypt32/CMakeLists.txt | 1 + rostests/winetests/cryptnet/CMakeLists.txt | 1 + rostests/winetests/cryptui/CMakeLists.txt | 1 + rostests/winetests/dnsapi/CMakeLists.txt | 1 + rostests/winetests/dsound/CMakeLists.txt | 1 + rostests/winetests/fusion/CMakeLists.txt | 1 + rostests/winetests/gdi32/CMakeLists.txt | 1 + rostests/winetests/gdiplus/CMakeLists.txt | 1 + rostests/winetests/hlink/CMakeLists.txt | 1 + rostests/winetests/icmp/CMakeLists.txt | 1 + rostests/winetests/imm32/CMakeLists.txt | 1 + rostests/winetests/inetcomm/CMakeLists.txt | 1 + rostests/winetests/inetmib1/CMakeLists.txt | 1 + rostests/winetests/iphlpapi/CMakeLists.txt | 1 + rostests/winetests/itss/CMakeLists.txt | 1 + rostests/winetests/jscript/CMakeLists.txt | 1 + rostests/winetests/localspl/CMakeLists.txt | 1 + rostests/winetests/localui/CMakeLists.txt | 1 + rostests/winetests/lz32/CMakeLists.txt | 1 + rostests/winetests/mapi32/CMakeLists.txt | 1 + rostests/winetests/mlang/CMakeLists.txt | 1 + rostests/winetests/msacm32/CMakeLists.txt | 1 + rostests/winetests/mscms/CMakeLists.txt | 1 + rostests/winetests/msctf/CMakeLists.txt | 1 + rostests/winetests/mshtml/CMakeLists.txt | 1 + rostests/winetests/msi/CMakeLists.txt | 1 + rostests/winetests/mstask/CMakeLists.txt | 1 + rostests/winetests/msvcrt/CMakeLists.txt | 1 + rostests/winetests/msvcrtd/CMakeLists.txt | 1 + rostests/winetests/msvfw32/CMakeLists.txt | 1 + rostests/winetests/msxml3/CMakeLists.txt | 1 + rostests/winetests/netapi32/CMakeLists.txt | 1 + rostests/winetests/ntdll/CMakeLists.txt | 1 + rostests/winetests/ntdsapi/CMakeLists.txt | 1 + rostests/winetests/ntprint/CMakeLists.txt | 1 + rostests/winetests/odbccp32/CMakeLists.txt | 1 + rostests/winetests/ole32/CMakeLists.txt | 1 + rostests/winetests/oleacc/CMakeLists.txt | 1 + rostests/winetests/oleaut32/CMakeLists.txt | 1 + rostests/winetests/opengl32/CMakeLists.txt | 1 + rostests/winetests/pdh/CMakeLists.txt | 1 + rostests/winetests/powrprof/CMakeLists.txt | 1 + rostests/winetests/psapi/CMakeLists.txt | 1 + rostests/winetests/qmgr/CMakeLists.txt | 1 + rostests/winetests/quartz/CMakeLists.txt | 1 + rostests/winetests/rasapi32/CMakeLists.txt | 1 + rostests/winetests/riched20/CMakeLists.txt | 1 + rostests/winetests/riched32/CMakeLists.txt | 1 + rostests/winetests/rpcrt4/CMakeLists.txt | 1 + rostests/winetests/rsabase/CMakeLists.txt | 1 + rostests/winetests/rsaenh/CMakeLists.txt | 1 + rostests/winetests/schannel/CMakeLists.txt | 1 + rostests/winetests/secur32/CMakeLists.txt | 1 + rostests/winetests/serialui/CMakeLists.txt | 1 + rostests/winetests/setupapi/CMakeLists.txt | 1 + rostests/winetests/shdocvw/CMakeLists.txt | 1 + rostests/winetests/shell32/CMakeLists.txt | 1 + rostests/winetests/shlwapi/CMakeLists.txt | 1 + rostests/winetests/snmpapi/CMakeLists.txt | 1 + rostests/winetests/spoolss/CMakeLists.txt | 1 + rostests/winetests/twain_32/CMakeLists.txt | 1 + rostests/winetests/urlmon/CMakeLists.txt | 1 + rostests/winetests/user32/CMakeLists.txt | 1 + rostests/winetests/userenv/CMakeLists.txt | 1 + rostests/winetests/usp10/CMakeLists.txt | 1 + rostests/winetests/uxtheme/CMakeLists.txt | 1 + rostests/winetests/version/CMakeLists.txt | 1 + rostests/winetests/winhttp/CMakeLists.txt | 1 + rostests/winetests/wininet/CMakeLists.txt | 1 + rostests/winetests/winmm/CMakeLists.txt | 1 + rostests/winetests/wintrust/CMakeLists.txt | 1 + rostests/winetests/wlanapi/CMakeLists.txt | 1 + rostests/winetests/wldap32/CMakeLists.txt | 1 + rostests/winetests/ws2_32/CMakeLists.txt | 1 + rostests/winetests/xmllite/CMakeLists.txt | 1 + 86 files changed, 87 insertions(+), 1 deletion(-) diff --git a/rostests/winetests/advapi32/CMakeLists.txt b/rostests/winetests/advapi32/CMakeLists.txt index d581b7f7cb8..10330459030 100644 --- a/rostests/winetests/advapi32/CMakeLists.txt +++ b/rostests/winetests/advapi32/CMakeLists.txt @@ -23,3 +23,4 @@ target_link_libraries(advapi32_winetest uuid) set_module_type(advapi32_winetest win32cui) add_importlibs(advapi32_winetest advapi32 ole32 msvcrt kernel32 ntdll) +add_cab_target(advapi32_winetest 7) diff --git a/rostests/winetests/advpack/CMakeLists.txt b/rostests/winetests/advpack/CMakeLists.txt index 1976f4ccee5..73563746bd6 100644 --- a/rostests/winetests/advpack/CMakeLists.txt +++ b/rostests/winetests/advpack/CMakeLists.txt @@ -15,3 +15,4 @@ target_link_libraries(advpack_winetest wine) set_module_type(advpack_winetest win32cui) add_importlibs(advpack_winetest cabinet advapi32 msvcrt kernel32 ntdll) +add_cab_target(advpack_winetest 7) diff --git a/rostests/winetests/amstream/CMakeLists.txt b/rostests/winetests/amstream/CMakeLists.txt index a23adfa6c8f..c239618dd1f 100644 --- a/rostests/winetests/amstream/CMakeLists.txt +++ b/rostests/winetests/amstream/CMakeLists.txt @@ -4,4 +4,5 @@ add_executable(amstream_winetest amstream.c testlist.c) target_link_libraries(amstream_winetest wine uuid) set_module_type(amstream_winetest win32cui) add_importlibs(amstream_winetest ole32 user32 ddraw msvcrt kernel32 ntdll) -add_dependencies(amstream_winetest dxsdk) \ No newline at end of file +add_dependencies(amstream_winetest dxsdk) +add_cab_target(amstream_winetest 7) diff --git a/rostests/winetests/atl/CMakeLists.txt b/rostests/winetests/atl/CMakeLists.txt index 02a34167d81..845b6496901 100644 --- a/rostests/winetests/atl/CMakeLists.txt +++ b/rostests/winetests/atl/CMakeLists.txt @@ -12,3 +12,4 @@ target_link_libraries(atl_winetest wine uuid) set_module_type(atl_winetest win32cui) add_importlibs(atl_winetest ole32 user32 atl msvcrt kernel32 ntdll) +add_cab_target(atl_winetest 7) diff --git a/rostests/winetests/avifil32/CMakeLists.txt b/rostests/winetests/avifil32/CMakeLists.txt index cf62f0fd2ff..7bb5d275d2e 100644 --- a/rostests/winetests/avifil32/CMakeLists.txt +++ b/rostests/winetests/avifil32/CMakeLists.txt @@ -4,3 +4,4 @@ add_executable(avifil32_winetest api.c testlist.c) target_link_libraries(avifil32_winetest wine) set_module_type(avifil32_winetest win32cui) add_importlibs(avifil32_winetest avifil32 msvcrt kernel32) +add_cab_target(avifil32_winetest 7) diff --git a/rostests/winetests/browseui/CMakeLists.txt b/rostests/winetests/browseui/CMakeLists.txt index f2a53f68071..077602810a0 100644 --- a/rostests/winetests/browseui/CMakeLists.txt +++ b/rostests/winetests/browseui/CMakeLists.txt @@ -7,3 +7,4 @@ add_executable(browseui_winetest autocomplete.c testlist.c) target_link_libraries(browseui_winetest wine uuid) set_module_type(browseui_winetest win32cui) add_importlibs(browseui_winetest user32 ole32 msvcrt kernel32 ntdll) +add_cab_target(browseui_winetest 7) diff --git a/rostests/winetests/cabinet/CMakeLists.txt b/rostests/winetests/cabinet/CMakeLists.txt index b224689daf8..219fc875c8b 100644 --- a/rostests/winetests/cabinet/CMakeLists.txt +++ b/rostests/winetests/cabinet/CMakeLists.txt @@ -7,3 +7,4 @@ add_executable(cabinet_winetest extract.c fdi.c testlist.c) target_link_libraries(cabinet_winetest wine) set_module_type(cabinet_winetest win32cui) add_importlibs(cabinet_winetest cabinet msvcrt kernel32 ntdll) +add_cab_target(cabinet_winetest 7) diff --git a/rostests/winetests/comcat/CMakeLists.txt b/rostests/winetests/comcat/CMakeLists.txt index 0bc71877792..e5fe5252ffb 100644 --- a/rostests/winetests/comcat/CMakeLists.txt +++ b/rostests/winetests/comcat/CMakeLists.txt @@ -7,3 +7,4 @@ add_executable(comcat_winetest comcat.c testlist.c) target_link_libraries(comcat_winetest wine uuid) set_module_type(comcat_winetest win32cui) add_importlibs(comcat_winetest ole32 advapi32 msvcrt kernel32 ntdll) +add_cab_target(comcat_winetest 7) diff --git a/rostests/winetests/comctl32/CMakeLists.txt b/rostests/winetests/comctl32/CMakeLists.txt index e7ccb4fb549..ff47bca7dc4 100644 --- a/rostests/winetests/comctl32/CMakeLists.txt +++ b/rostests/winetests/comctl32/CMakeLists.txt @@ -38,3 +38,4 @@ add_executable(comctl32_winetest ${SOURCE}) target_link_libraries(comctl32_winetest wine) set_module_type(comctl32_winetest win32cui) add_importlibs(comctl32_winetest comctl32 ole32 user32 gdi32 advapi32 msvcrt kernel32 ntdll) +add_cab_target(comctl32_winetest 7) diff --git a/rostests/winetests/comdlg32/CMakeLists.txt b/rostests/winetests/comdlg32/CMakeLists.txt index 0e9cc2810fd..9c7c04e4013 100644 --- a/rostests/winetests/comdlg32/CMakeLists.txt +++ b/rostests/winetests/comdlg32/CMakeLists.txt @@ -14,3 +14,4 @@ add_executable(comdlg32_winetest ${SOURCE}) target_link_libraries(comdlg32_winetest wine) set_module_type(comdlg32_winetest win32cui) add_importlibs(comdlg32_winetest comdlg32 winspool user32 gdi32 msvcrt kernel32 ntdll) +add_cab_target(comdlg32_winetest 7) diff --git a/rostests/winetests/credui/CMakeLists.txt b/rostests/winetests/credui/CMakeLists.txt index e493c404c99..6fec045ae73 100644 --- a/rostests/winetests/credui/CMakeLists.txt +++ b/rostests/winetests/credui/CMakeLists.txt @@ -7,3 +7,4 @@ add_executable(credui_winetest credui.c testlist.c) target_link_libraries(credui_winetest wine) set_module_type(credui_winetest win32cui) add_importlibs(credui_winetest credui msvcrt kernel32 ntdll) +add_cab_target(credui_winetest 7) diff --git a/rostests/winetests/crypt32/CMakeLists.txt b/rostests/winetests/crypt32/CMakeLists.txt index 6653c07d811..b6bb0e6b889 100644 --- a/rostests/winetests/crypt32/CMakeLists.txt +++ b/rostests/winetests/crypt32/CMakeLists.txt @@ -25,3 +25,4 @@ add_executable(crypt32_winetest ${SOURCE}) target_link_libraries(crypt32_winetest wine) set_module_type(crypt32_winetest win32cui) add_importlibs(crypt32_winetest crypt32 advapi32 msvcrt kernel32 ntdll) +add_cab_target(crypt32_winetest 7) diff --git a/rostests/winetests/cryptnet/CMakeLists.txt b/rostests/winetests/cryptnet/CMakeLists.txt index 9cebff64c00..1d2551779d1 100644 --- a/rostests/winetests/cryptnet/CMakeLists.txt +++ b/rostests/winetests/cryptnet/CMakeLists.txt @@ -7,3 +7,4 @@ add_executable(cryptnet_winetest cryptnet.c testlist.c) target_link_libraries(cryptnet_winetest wine) set_module_type(cryptnet_winetest win32cui) add_importlibs(cryptnet_winetest cryptnet crypt32 msvcrt kernel32 ntdll) +add_cab_target(cryptnet_winetest 7) diff --git a/rostests/winetests/cryptui/CMakeLists.txt b/rostests/winetests/cryptui/CMakeLists.txt index d5b195f641f..99d4b07eb91 100644 --- a/rostests/winetests/cryptui/CMakeLists.txt +++ b/rostests/winetests/cryptui/CMakeLists.txt @@ -7,3 +7,4 @@ add_executable(cryptui_winetest cryptui.c testlist.c) target_link_libraries(cryptui_winetest wine) set_module_type(cryptui_winetest win32cui) add_importlibs(cryptui_winetest cryptui crypt32 user32 msvcrt kernel32 ntdll) +add_cab_target(cryptui_winetest 7) diff --git a/rostests/winetests/dnsapi/CMakeLists.txt b/rostests/winetests/dnsapi/CMakeLists.txt index 81fdcd0f518..ed8c2827cce 100644 --- a/rostests/winetests/dnsapi/CMakeLists.txt +++ b/rostests/winetests/dnsapi/CMakeLists.txt @@ -7,3 +7,4 @@ add_executable(dnsapi_winetest name.c record.c testlist.c) target_link_libraries(dnsapi_winetest wine) set_module_type(dnsapi_winetest win32cui) add_importlibs(dnsapi_winetest dnsapi msvcrt kernel32 ntdll) +add_cab_target(dnsapi_winetest 7) diff --git a/rostests/winetests/dsound/CMakeLists.txt b/rostests/winetests/dsound/CMakeLists.txt index 6007befcfc4..867d0c6d596 100644 --- a/rostests/winetests/dsound/CMakeLists.txt +++ b/rostests/winetests/dsound/CMakeLists.txt @@ -17,3 +17,4 @@ add_executable(dsound_winetest ${SOURCE}) target_link_libraries(dsound_winetest wine uuid dxguid) set_module_type(dsound_winetest win32cui) add_importlibs(dsound_winetest dsound ole32 user32 msvcrt kernel32 ntdll) +add_cab_target(dsound_winetest 7) diff --git a/rostests/winetests/fusion/CMakeLists.txt b/rostests/winetests/fusion/CMakeLists.txt index b333c0bc2fc..cb4bc904bbe 100644 --- a/rostests/winetests/fusion/CMakeLists.txt +++ b/rostests/winetests/fusion/CMakeLists.txt @@ -14,3 +14,4 @@ add_executable(fusion_winetest ${SOURCE}) target_link_libraries(fusion_winetest wine) set_module_type(fusion_winetest win32cui) add_importlibs(fusion_winetest user32 msvcrt kernel32 ntdll) +add_cab_target(fusion_winetest 7) diff --git a/rostests/winetests/gdi32/CMakeLists.txt b/rostests/winetests/gdi32/CMakeLists.txt index d3f2bc3646d..3f021d01f89 100644 --- a/rostests/winetests/gdi32/CMakeLists.txt +++ b/rostests/winetests/gdi32/CMakeLists.txt @@ -22,3 +22,4 @@ list(APPEND SOURCE add_executable(gdi32_winetest ${SOURCE}) set_module_type(gdi32_winetest win32cui) add_importlibs(gdi32_winetest gdi32 user32 advapi32 msvcrt kernel32 ntdll) +add_cab_target(gdi32_winetest 7) diff --git a/rostests/winetests/gdiplus/CMakeLists.txt b/rostests/winetests/gdiplus/CMakeLists.txt index 325f20b2b0d..a2a97857c44 100644 --- a/rostests/winetests/gdiplus/CMakeLists.txt +++ b/rostests/winetests/gdiplus/CMakeLists.txt @@ -21,3 +21,4 @@ add_executable(gdiplus_winetest ${SOURCE}) target_link_libraries(gdiplus_winetest wine) set_module_type(gdiplus_winetest win32cui) add_importlibs(gdiplus_winetest gdiplus user32 gdi32 ole32 msvcrt kernel32 ntdll) +add_cab_target(gdiplus_winetest 7) diff --git a/rostests/winetests/hlink/CMakeLists.txt b/rostests/winetests/hlink/CMakeLists.txt index e8edbfffb1d..ec779936e6c 100644 --- a/rostests/winetests/hlink/CMakeLists.txt +++ b/rostests/winetests/hlink/CMakeLists.txt @@ -12,3 +12,4 @@ add_executable(hlink_winetest ${SOURCE}) target_link_libraries(hlink_winetest wine uuid) set_module_type(hlink_winetest win32cui) add_importlibs(hlink_winetest hlink ole32 msvcrt kernel32 ntdll) +add_cab_target(hlink_winetest 7) diff --git a/rostests/winetests/icmp/CMakeLists.txt b/rostests/winetests/icmp/CMakeLists.txt index dfcd1f3350d..c0eac572dea 100644 --- a/rostests/winetests/icmp/CMakeLists.txt +++ b/rostests/winetests/icmp/CMakeLists.txt @@ -7,3 +7,4 @@ add_executable(icmp_winetest icmp.c testlist.c) target_link_libraries(icmp_winetest wine uuid) set_module_type(icmp_winetest win32cui) add_importlibs(icmp_winetest icmp msvcrt kernel32 ntdll) +add_cab_target(icmp_winetest 7) diff --git a/rostests/winetests/imm32/CMakeLists.txt b/rostests/winetests/imm32/CMakeLists.txt index dbd80fd3c55..85880cb7ff6 100644 --- a/rostests/winetests/imm32/CMakeLists.txt +++ b/rostests/winetests/imm32/CMakeLists.txt @@ -7,3 +7,4 @@ add_executable(imm32_winetest imm32.c testlist.c) target_link_libraries(imm32_winetest wine) set_module_type(imm32_winetest win32cui) add_importlibs(imm32_winetest imm32 user32 msvcrt kernel32 ntdll) +add_cab_target(imm32_winetest 7) diff --git a/rostests/winetests/inetcomm/CMakeLists.txt b/rostests/winetests/inetcomm/CMakeLists.txt index 3f6c28be44f..8309e2c6ff0 100644 --- a/rostests/winetests/inetcomm/CMakeLists.txt +++ b/rostests/winetests/inetcomm/CMakeLists.txt @@ -12,3 +12,4 @@ add_executable(inetcomm_winetest ${SOURCE}) target_link_libraries(inetcomm_winetest wine) set_module_type(inetcomm_winetest win32cui) add_importlibs(inetcomm_winetest inetcomm oleaut32 ole32 msvcrt kernel32 ntdll) +add_cab_target(inetcomm_winetest 7) diff --git a/rostests/winetests/inetmib1/CMakeLists.txt b/rostests/winetests/inetmib1/CMakeLists.txt index fb822b5bc7f..1024e2c13c7 100644 --- a/rostests/winetests/inetmib1/CMakeLists.txt +++ b/rostests/winetests/inetmib1/CMakeLists.txt @@ -7,3 +7,4 @@ add_executable(inetmib1_winetest main.c testlist.c) target_link_libraries(inetmib1_winetest wine) set_module_type(inetmib1_winetest win32cui) add_importlibs(inetmib1_winetest snmpapi msvcrt kernel32 ntdll) +add_cab_target(inetmib1_winetest 7) diff --git a/rostests/winetests/iphlpapi/CMakeLists.txt b/rostests/winetests/iphlpapi/CMakeLists.txt index 1f81d67f3dd..3bf686a60fe 100644 --- a/rostests/winetests/iphlpapi/CMakeLists.txt +++ b/rostests/winetests/iphlpapi/CMakeLists.txt @@ -7,3 +7,4 @@ add_executable(iphlpapi_winetest iphlpapi.c testlist.c) target_link_libraries(iphlpapi_winetest wine) set_module_type(iphlpapi_winetest win32cui) add_importlibs(iphlpapi_winetest msvcrt kernel32 ntdll) +add_cab_target(iphlpapi_winetest 7) diff --git a/rostests/winetests/itss/CMakeLists.txt b/rostests/winetests/itss/CMakeLists.txt index 177663b20a1..10a7130aaa5 100644 --- a/rostests/winetests/itss/CMakeLists.txt +++ b/rostests/winetests/itss/CMakeLists.txt @@ -7,3 +7,4 @@ add_executable(itss_winetest protocol.c testlist.c rsrc.rc) target_link_libraries(itss_winetest wine) set_module_type(itss_winetest win32cui) add_importlibs(itss_winetest ole32 msvcrt kernel32 ntdll) +add_cab_target(itss_winetest 7) diff --git a/rostests/winetests/jscript/CMakeLists.txt b/rostests/winetests/jscript/CMakeLists.txt index ca450f67cbd..347519d5f7d 100644 --- a/rostests/winetests/jscript/CMakeLists.txt +++ b/rostests/winetests/jscript/CMakeLists.txt @@ -14,3 +14,4 @@ add_executable(jscript_winetest ${SOURCE}) target_link_libraries(jscript_winetest wine) set_module_type(jscript_winetest win32cui) add_importlibs(jscript_winetest ole32 oleaut32 advapi32 msvcrt kernel32 ntdll) +add_cab_target(jscript_winetest 7) diff --git a/rostests/winetests/localspl/CMakeLists.txt b/rostests/winetests/localspl/CMakeLists.txt index 81b504860e5..239fe06398a 100644 --- a/rostests/winetests/localspl/CMakeLists.txt +++ b/rostests/winetests/localspl/CMakeLists.txt @@ -8,3 +8,4 @@ add_executable(localspl_winetest localmon.c testlist.c) target_link_libraries(localspl_winetest wine) set_module_type(localspl_winetest win32cui) add_importlibs(localspl_winetest advapi32 msvcrt kernel32 ntdll) +add_cab_target(localspl_winetest 7) diff --git a/rostests/winetests/localui/CMakeLists.txt b/rostests/winetests/localui/CMakeLists.txt index 3609ab3bbd3..f89d2363d44 100644 --- a/rostests/winetests/localui/CMakeLists.txt +++ b/rostests/winetests/localui/CMakeLists.txt @@ -8,3 +8,4 @@ add_executable(localui_winetest localui.c testlist.c) target_link_libraries(localui_winetest wine) set_module_type(localui_winetest win32cui) add_importlibs(localui_winetest winspool msvcrt kernel32 ntdll) +add_cab_target(localui_winetest 7) diff --git a/rostests/winetests/lz32/CMakeLists.txt b/rostests/winetests/lz32/CMakeLists.txt index fcfd2d3bd59..93240783f03 100644 --- a/rostests/winetests/lz32/CMakeLists.txt +++ b/rostests/winetests/lz32/CMakeLists.txt @@ -7,3 +7,4 @@ add_executable(lz32_winetest lzexpand_main.c testlist.c) target_link_libraries(lz32_winetest wine) set_module_type(lz32_winetest win32cui) add_importlibs(lz32_winetest lz32 msvcrt kernel32 ntdll) +add_cab_target(lz32_winetest 7) diff --git a/rostests/winetests/mapi32/CMakeLists.txt b/rostests/winetests/mapi32/CMakeLists.txt index e77f2cad0c0..3025484b43e 100644 --- a/rostests/winetests/mapi32/CMakeLists.txt +++ b/rostests/winetests/mapi32/CMakeLists.txt @@ -13,3 +13,4 @@ add_executable(mapi32_winetest ${SOURCE}) target_link_libraries(mapi32_winetest wine uuid) set_module_type(mapi32_winetest win32cui) add_importlibs(mapi32_winetest advapi32 msvcrt kernel32 ntdll) +add_cab_target(mapi32_winetest 7) diff --git a/rostests/winetests/mlang/CMakeLists.txt b/rostests/winetests/mlang/CMakeLists.txt index beddd20ee4f..883524ad3d1 100644 --- a/rostests/winetests/mlang/CMakeLists.txt +++ b/rostests/winetests/mlang/CMakeLists.txt @@ -7,3 +7,4 @@ add_executable(mlang_winetest mlang.c testlist.c) target_link_libraries(mlang_winetest wine uuid) set_module_type(mlang_winetest win32cui) add_importlibs(mlang_winetest oleaut32 ole32 gdi32 msvcrt kernel32 ntdll) +add_cab_target(mlang_winetest 7) diff --git a/rostests/winetests/msacm32/CMakeLists.txt b/rostests/winetests/msacm32/CMakeLists.txt index 377356cae73..4400da1e160 100644 --- a/rostests/winetests/msacm32/CMakeLists.txt +++ b/rostests/winetests/msacm32/CMakeLists.txt @@ -7,3 +7,4 @@ add_executable(msacm32_winetest msacm.c testlist.c) target_link_libraries(msacm32_winetest wine) set_module_type(msacm32_winetest win32cui) add_importlibs(msacm32_winetest msacm32 msvcrt kernel32 ntdll) +add_cab_target(msacm32_winetest 7) diff --git a/rostests/winetests/mscms/CMakeLists.txt b/rostests/winetests/mscms/CMakeLists.txt index d6f972f4507..7c2a11f6bea 100644 --- a/rostests/winetests/mscms/CMakeLists.txt +++ b/rostests/winetests/mscms/CMakeLists.txt @@ -7,3 +7,4 @@ add_executable(mscms_winetest profile.c testlist.c) target_link_libraries(mscms_winetest wine) set_module_type(mscms_winetest win32cui) add_importlibs(mscms_winetest advapi32 msvcrt kernel32 ntdll) +add_cab_target(mscms_winetest 7) diff --git a/rostests/winetests/msctf/CMakeLists.txt b/rostests/winetests/msctf/CMakeLists.txt index 1ac0ad4a780..f72829ba3d9 100644 --- a/rostests/winetests/msctf/CMakeLists.txt +++ b/rostests/winetests/msctf/CMakeLists.txt @@ -7,3 +7,4 @@ add_executable(msctf_winetest inputprocessor.c testlist.c) target_link_libraries(msctf_winetest wine) set_module_type(msctf_winetest win32cui) add_importlibs(msctf_winetest ole32 user32 msvcrt kernel32 ntdll) +add_cab_target(msctf_winetest 7) diff --git a/rostests/winetests/mshtml/CMakeLists.txt b/rostests/winetests/mshtml/CMakeLists.txt index 7222433f428..bdf2c46d140 100644 --- a/rostests/winetests/mshtml/CMakeLists.txt +++ b/rostests/winetests/mshtml/CMakeLists.txt @@ -18,3 +18,4 @@ add_executable(mshtml_winetest ${SOURCE}) target_link_libraries(mshtml_winetest wine uuid strmiids) set_module_type(mshtml_winetest win32cui) add_importlibs(mshtml_winetest wininet ole32 oleaut32 user32 gdi32 urlmon advapi32 msvcrt kernel32 ntdll) +add_cab_target(mshtml_winetest 7) diff --git a/rostests/winetests/msi/CMakeLists.txt b/rostests/winetests/msi/CMakeLists.txt index 7bcbe3dc69e..518a574b989 100644 --- a/rostests/winetests/msi/CMakeLists.txt +++ b/rostests/winetests/msi/CMakeLists.txt @@ -20,3 +20,4 @@ add_executable(msi_winetest ${SOURCE}) target_link_libraries(msi_winetest wine uuid) set_module_type(msi_winetest win32cui) add_importlibs(msi_winetest cabinet msi shell32 ole32 oleaut32 user32 advapi32 version msvcrt kernel32 ntdll) +add_cab_target(msi_winetest 7) diff --git a/rostests/winetests/mstask/CMakeLists.txt b/rostests/winetests/mstask/CMakeLists.txt index f4832a30775..e69c20ddbbd 100644 --- a/rostests/winetests/mstask/CMakeLists.txt +++ b/rostests/winetests/mstask/CMakeLists.txt @@ -13,3 +13,4 @@ add_executable(mstask_winetest ${SOURCE}) target_link_libraries(mstask_winetest wine) set_module_type(mstask_winetest win32cui) add_importlibs(mstask_winetest ole32 msvcrt kernel32 ntdll) +add_cab_target(mstask_winetest 7) diff --git a/rostests/winetests/msvcrt/CMakeLists.txt b/rostests/winetests/msvcrt/CMakeLists.txt index 2270c89e8ef..e8d7c39abd2 100644 --- a/rostests/winetests/msvcrt/CMakeLists.txt +++ b/rostests/winetests/msvcrt/CMakeLists.txt @@ -24,3 +24,4 @@ list(APPEND SOURCE add_executable(msvcrt_winetest ${SOURCE}) set_module_type(msvcrt_winetest win32cui) add_importlibs(msvcrt_winetest msvcrt kernel32 ntdll) +add_cab_target(msvcrt_winetest 7) diff --git a/rostests/winetests/msvcrtd/CMakeLists.txt b/rostests/winetests/msvcrtd/CMakeLists.txt index 6d3eb3b6cfe..57e5acb3cc1 100644 --- a/rostests/winetests/msvcrtd/CMakeLists.txt +++ b/rostests/winetests/msvcrtd/CMakeLists.txt @@ -7,3 +7,4 @@ add_executable(msvcrtd_winetest debug.c testlist.c) target_link_libraries(msvcrtd_winetest wine) set_module_type(msvcrtd_winetest win32cui) add_importlibs(msvcrtd_winetest msvcrt kernel32 ntdll) +add_cab_target(msvcrtd_winetest 7) diff --git a/rostests/winetests/msvfw32/CMakeLists.txt b/rostests/winetests/msvfw32/CMakeLists.txt index 628dc4e3ad4..6eed2ab5663 100644 --- a/rostests/winetests/msvfw32/CMakeLists.txt +++ b/rostests/winetests/msvfw32/CMakeLists.txt @@ -7,3 +7,4 @@ add_executable(msvfw32_winetest msvfw.c testlist.c) target_link_libraries(msvfw32_winetest wine) set_module_type(msvfw32_winetest win32cui) add_importlibs(msvfw32_winetest msvfw32 msvcrt kernel32 ntdll) +add_cab_target(msvfw32_winetest 7) diff --git a/rostests/winetests/msxml3/CMakeLists.txt b/rostests/winetests/msxml3/CMakeLists.txt index 89ef97e2300..13689a07c66 100644 --- a/rostests/winetests/msxml3/CMakeLists.txt +++ b/rostests/winetests/msxml3/CMakeLists.txt @@ -15,3 +15,4 @@ add_executable(msxml3_winetest ${SOURCE}) target_link_libraries(msxml3_winetest wine) set_module_type(msxml3_winetest win32cui) add_importlibs(msxml3_winetest user32 ole32 oleaut32 msvcrt kernel32 ntdll) +add_cab_target(msxml3_winetest 7) diff --git a/rostests/winetests/netapi32/CMakeLists.txt b/rostests/winetests/netapi32/CMakeLists.txt index 8f8b4da78c7..c83667dbbed 100644 --- a/rostests/winetests/netapi32/CMakeLists.txt +++ b/rostests/winetests/netapi32/CMakeLists.txt @@ -14,3 +14,4 @@ add_executable(netapi32_winetest ${SOURCE}) target_link_libraries(netapi32_winetest wine) set_module_type(netapi32_winetest win32cui) add_importlibs(netapi32_winetest advapi32 msvcrt kernel32 ntdll) +add_cab_target(netapi32_winetest 7) diff --git a/rostests/winetests/ntdll/CMakeLists.txt b/rostests/winetests/ntdll/CMakeLists.txt index adaef0bc064..290e85c1637 100644 --- a/rostests/winetests/ntdll/CMakeLists.txt +++ b/rostests/winetests/ntdll/CMakeLists.txt @@ -28,3 +28,4 @@ list(APPEND SOURCE add_executable(ntdll_winetest ${SOURCE}) set_module_type(ntdll_winetest win32cui) add_importlibs(ntdll_winetest user32 msvcrt kernel32 ntdll) +add_cab_target(ntdll_winetest 7) diff --git a/rostests/winetests/ntdsapi/CMakeLists.txt b/rostests/winetests/ntdsapi/CMakeLists.txt index b99ec986b70..aee95d3cf28 100644 --- a/rostests/winetests/ntdsapi/CMakeLists.txt +++ b/rostests/winetests/ntdsapi/CMakeLists.txt @@ -7,3 +7,4 @@ add_executable(ntdsapi_winetest ntdsapi.c testlist.c) target_link_libraries(ntdsapi_winetest wine) set_module_type(ntdsapi_winetest win32cui) add_importlibs(ntdsapi_winetest ntdsapi msvcrt kernel32 ntdll) +add_cab_target(ntdsapi_winetest 7) diff --git a/rostests/winetests/ntprint/CMakeLists.txt b/rostests/winetests/ntprint/CMakeLists.txt index 192969e2385..6ce7c95a47c 100644 --- a/rostests/winetests/ntprint/CMakeLists.txt +++ b/rostests/winetests/ntprint/CMakeLists.txt @@ -7,3 +7,4 @@ add_executable(ntprint_winetest ntprint.c testlist.c) target_link_libraries(ntprint_winetest wine) set_module_type(ntprint_winetest win32cui) add_importlibs(ntprint_winetest msvcrt kernel32 ntdll) +add_cab_target(ntprint_winetest 7) diff --git a/rostests/winetests/odbccp32/CMakeLists.txt b/rostests/winetests/odbccp32/CMakeLists.txt index b90a6d7aaa2..9e8154273d5 100644 --- a/rostests/winetests/odbccp32/CMakeLists.txt +++ b/rostests/winetests/odbccp32/CMakeLists.txt @@ -7,3 +7,4 @@ add_executable(odbccp32_winetest misc.c testlist.c) target_link_libraries(odbccp32_winetest wine) set_module_type(odbccp32_winetest win32cui) add_importlibs(odbccp32_winetest odbccp32 msvcrt kernel32 ntdll) +add_cab_target(odbccp32_winetest 7) diff --git a/rostests/winetests/ole32/CMakeLists.txt b/rostests/winetests/ole32/CMakeLists.txt index 9f3f03b92d1..9ea896b6660 100644 --- a/rostests/winetests/ole32/CMakeLists.txt +++ b/rostests/winetests/ole32/CMakeLists.txt @@ -23,3 +23,4 @@ add_executable(ole32_winetest ${SOURCE}) target_link_libraries(ole32_winetest wine uuid) set_module_type(ole32_winetest win32cui) add_importlibs(ole32_winetest oleaut32 ole32 user32 gdi32 advapi32 msvcrt kernel32 ntdll) +add_cab_target(ole32_winetest 7) diff --git a/rostests/winetests/oleacc/CMakeLists.txt b/rostests/winetests/oleacc/CMakeLists.txt index ccfc7d2dffc..59292db00d4 100644 --- a/rostests/winetests/oleacc/CMakeLists.txt +++ b/rostests/winetests/oleacc/CMakeLists.txt @@ -7,3 +7,4 @@ add_executable(oleacc_winetest main.c testlist.c) target_link_libraries(oleacc_winetest wine) set_module_type(oleacc_winetest win32cui) add_importlibs(oleacc_winetest oleacc msvcrt kernel32 ntdll) +add_cab_target(oleacc_winetest 7) diff --git a/rostests/winetests/oleaut32/CMakeLists.txt b/rostests/winetests/oleaut32/CMakeLists.txt index 5ec06a92ba3..0a98dfe3dec 100644 --- a/rostests/winetests/oleaut32/CMakeLists.txt +++ b/rostests/winetests/oleaut32/CMakeLists.txt @@ -31,3 +31,4 @@ target_link_libraries(oleaut32_winetest uuid wine) set_module_type(oleaut32_winetest win32cui) add_importlibs(oleaut32_winetest oleaut32 ole32 rpcrt4 user32 gdi32 advapi32 msvcrt kernel32 ntdll) add_dependencies(oleaut32_winetest oleaut32_typelibs oleaut32_idlheaders) +add_cab_target(oleaut32_winetest 7) diff --git a/rostests/winetests/opengl32/CMakeLists.txt b/rostests/winetests/opengl32/CMakeLists.txt index 0e5297b889c..cd94543b140 100644 --- a/rostests/winetests/opengl32/CMakeLists.txt +++ b/rostests/winetests/opengl32/CMakeLists.txt @@ -7,3 +7,4 @@ add_executable(opengl32_winetest opengl.c testlist.c) target_link_libraries(opengl32_winetest wine) set_module_type(opengl32_winetest win32cui) add_importlibs(opengl32_winetest opengl32 gdi32 user32 msvcrt kernel32 ntdll) +add_cab_target(opengl32_winetest 7) diff --git a/rostests/winetests/pdh/CMakeLists.txt b/rostests/winetests/pdh/CMakeLists.txt index decf1dce25a..7d4441bcbb7 100644 --- a/rostests/winetests/pdh/CMakeLists.txt +++ b/rostests/winetests/pdh/CMakeLists.txt @@ -7,3 +7,4 @@ add_executable(pdh_winetest pdh.c testlist.c) target_link_libraries(pdh_winetest wine) set_module_type(pdh_winetest win32cui) add_importlibs(pdh_winetest pdh msvcrt kernel32 ntdll) +add_cab_target(pdh_winetest 7) diff --git a/rostests/winetests/powrprof/CMakeLists.txt b/rostests/winetests/powrprof/CMakeLists.txt index 462da098510..b44d52d9aee 100644 --- a/rostests/winetests/powrprof/CMakeLists.txt +++ b/rostests/winetests/powrprof/CMakeLists.txt @@ -7,3 +7,4 @@ add_definitions( add_executable(powrprof_winetest pwrprof.c testlist.c) set_module_type(powrprof_winetest win32cui) add_importlibs(powrprof_winetest advapi32 powrprof msvcrt kernel32 ntdll) +add_cab_target(powrprof_winetest 7) diff --git a/rostests/winetests/psapi/CMakeLists.txt b/rostests/winetests/psapi/CMakeLists.txt index e7c048d1b6e..db15387dbcc 100644 --- a/rostests/winetests/psapi/CMakeLists.txt +++ b/rostests/winetests/psapi/CMakeLists.txt @@ -7,3 +7,4 @@ add_executable(psapi_winetest psapi_main.c testlist.c) target_link_libraries(psapi_winetest wine) set_module_type(psapi_winetest win32cui) add_importlibs(psapi_winetest psapi msvcrt kernel32 ntdll) +add_cab_target(psapi_winetest 7) diff --git a/rostests/winetests/qmgr/CMakeLists.txt b/rostests/winetests/qmgr/CMakeLists.txt index 4670f334282..3c51a58e020 100644 --- a/rostests/winetests/qmgr/CMakeLists.txt +++ b/rostests/winetests/qmgr/CMakeLists.txt @@ -15,3 +15,4 @@ add_executable(qmgr_winetest ${SOURCE}) target_link_libraries(qmgr_winetest wine) set_module_type(qmgr_winetest win32cui) add_importlibs(qmgr_winetest ole32 shlwapi user32 msvcrt kernel32 ntdll) +add_cab_target(qmgr_winetest 7) diff --git a/rostests/winetests/quartz/CMakeLists.txt b/rostests/winetests/quartz/CMakeLists.txt index b589596bde0..c21b0b6b7b1 100644 --- a/rostests/winetests/quartz/CMakeLists.txt +++ b/rostests/winetests/quartz/CMakeLists.txt @@ -18,3 +18,4 @@ add_executable(quartz_winetest ${SOURCE}) target_link_libraries(quartz_winetest wine) set_module_type(quartz_winetest win32cui) add_importlibs(quartz_winetest ole32 oleaut32 advapi32 msvcrt kernel32 ntdll) +add_cab_target(quartz_winetest 7) diff --git a/rostests/winetests/rasapi32/CMakeLists.txt b/rostests/winetests/rasapi32/CMakeLists.txt index 2e840329061..c32b204191c 100644 --- a/rostests/winetests/rasapi32/CMakeLists.txt +++ b/rostests/winetests/rasapi32/CMakeLists.txt @@ -7,3 +7,4 @@ add_executable(rasapi32_winetest rasapi.c testlist.c) target_link_libraries(rasapi32_winetest wine) set_module_type(rasapi32_winetest win32cui) add_importlibs(rasapi32_winetest msvcrt kernel32 ntdll) +add_cab_target(rasapi32_winetest 7) diff --git a/rostests/winetests/riched20/CMakeLists.txt b/rostests/winetests/riched20/CMakeLists.txt index ff6b867645b..3d27c272036 100644 --- a/rostests/winetests/riched20/CMakeLists.txt +++ b/rostests/winetests/riched20/CMakeLists.txt @@ -13,3 +13,4 @@ add_executable(riched20_winetest ${SOURCE}) target_link_libraries(riched20_winetest wine uuid) set_module_type(riched20_winetest win32cui) add_importlibs(riched20_winetest ole32 oleaut32 user32 gdi32 msvcrt kernel32 ntdll) +add_cab_target(riched20_winetest 7) diff --git a/rostests/winetests/riched32/CMakeLists.txt b/rostests/winetests/riched32/CMakeLists.txt index 3a473ff426e..ce51ed45f3e 100644 --- a/rostests/winetests/riched32/CMakeLists.txt +++ b/rostests/winetests/riched32/CMakeLists.txt @@ -7,3 +7,4 @@ add_executable(riched32_winetest editor.c testlist.c) target_link_libraries(riched32_winetest wine) set_module_type(riched32_winetest win32cui) add_importlibs(riched32_winetest ole32 user32 msvcrt kernel32 ntdll) +add_cab_target(riched32_winetest 7) diff --git a/rostests/winetests/rpcrt4/CMakeLists.txt b/rostests/winetests/rpcrt4/CMakeLists.txt index 10a4f15dcc7..ffbfd7edb90 100644 --- a/rostests/winetests/rpcrt4/CMakeLists.txt +++ b/rostests/winetests/rpcrt4/CMakeLists.txt @@ -28,3 +28,4 @@ target_link_libraries(rpcrt4_winetest set_module_type(rpcrt4_winetest win32cui) add_importlibs(rpcrt4_winetest ole32 rpcrt4 msvcrt kernel32 ntdll) +add_cab_target(rpcrt4_winetest 7) diff --git a/rostests/winetests/rsabase/CMakeLists.txt b/rostests/winetests/rsabase/CMakeLists.txt index 154febdd37a..a399f0eba50 100644 --- a/rostests/winetests/rsabase/CMakeLists.txt +++ b/rostests/winetests/rsabase/CMakeLists.txt @@ -7,3 +7,4 @@ add_executable(rsabase_winetest rsabase.c testlist.c) target_link_libraries(rsabase_winetest wine) set_module_type(rsabase_winetest win32cui) add_importlibs(rsabase_winetest advapi32 msvcrt kernel32 ntdll) +add_cab_target(rsabase_winetest 7) diff --git a/rostests/winetests/rsaenh/CMakeLists.txt b/rostests/winetests/rsaenh/CMakeLists.txt index 9e621c6af21..72b2f7115a2 100644 --- a/rostests/winetests/rsaenh/CMakeLists.txt +++ b/rostests/winetests/rsaenh/CMakeLists.txt @@ -7,3 +7,4 @@ add_executable(rsaenh_winetest rsaenh.c testlist.c) target_link_libraries(rsaenh_winetest wine) set_module_type(rsaenh_winetest win32cui) add_importlibs(rsaenh_winetest advapi32 msvcrt kernel32 ntdll) +add_cab_target(rsaenh_winetest 7) diff --git a/rostests/winetests/schannel/CMakeLists.txt b/rostests/winetests/schannel/CMakeLists.txt index 98ebd0beba5..a9b5a713b46 100644 --- a/rostests/winetests/schannel/CMakeLists.txt +++ b/rostests/winetests/schannel/CMakeLists.txt @@ -7,3 +7,4 @@ add_executable(schannel_winetest main.c testlist.c) target_link_libraries(schannel_winetest wine) set_module_type(schannel_winetest win32cui) add_importlibs(schannel_winetest msvcrt kernel32 ntdll) +add_cab_target(schannel_winetest 7) diff --git a/rostests/winetests/secur32/CMakeLists.txt b/rostests/winetests/secur32/CMakeLists.txt index 3e1b9848db5..8f27b0b5e77 100644 --- a/rostests/winetests/secur32/CMakeLists.txt +++ b/rostests/winetests/secur32/CMakeLists.txt @@ -14,3 +14,4 @@ add_executable(secur32_winetest ${SOURCE}) target_link_libraries(secur32_winetest wine) set_module_type(secur32_winetest win32cui) add_importlibs(secur32_winetest advapi32 msvcrt kernel32 ntdll) +add_cab_target(secur32_winetest 7) diff --git a/rostests/winetests/serialui/CMakeLists.txt b/rostests/winetests/serialui/CMakeLists.txt index dc3e0ab8fdc..8978fc9fb52 100644 --- a/rostests/winetests/serialui/CMakeLists.txt +++ b/rostests/winetests/serialui/CMakeLists.txt @@ -7,3 +7,4 @@ add_executable(serialui_winetest confdlg.c testlist.c) target_link_libraries(serialui_winetest wine) set_module_type(serialui_winetest win32cui) add_importlibs(serialui_winetest msvcrt kernel32 ntdll) +add_cab_target(serialui_winetest 7) diff --git a/rostests/winetests/setupapi/CMakeLists.txt b/rostests/winetests/setupapi/CMakeLists.txt index ea564d73315..041da753e0f 100644 --- a/rostests/winetests/setupapi/CMakeLists.txt +++ b/rostests/winetests/setupapi/CMakeLists.txt @@ -18,3 +18,4 @@ add_executable(setupapi_winetest ${SOURCE}) target_link_libraries(setupapi_winetest wine) set_module_type(setupapi_winetest win32cui) add_importlibs(setupapi_winetest advapi32 setupapi user32 msvcrt kernel32 ntdll) +add_cab_target(setupapi_winetest 7) diff --git a/rostests/winetests/shdocvw/CMakeLists.txt b/rostests/winetests/shdocvw/CMakeLists.txt index c3d56e8a84c..ae6b8f633de 100644 --- a/rostests/winetests/shdocvw/CMakeLists.txt +++ b/rostests/winetests/shdocvw/CMakeLists.txt @@ -14,3 +14,4 @@ add_executable(shdocvw_winetest ${SOURCE}) target_link_libraries(shdocvw_winetest wine) set_module_type(shdocvw_winetest win32cui) add_importlibs(shdocvw_winetest gdi32 shell32 ole32 oleaut32 user32 advapi32 msvcrt kernel32 ntdll) +add_cab_target(shdocvw_winetest 7) diff --git a/rostests/winetests/shell32/CMakeLists.txt b/rostests/winetests/shell32/CMakeLists.txt index dc26726c4c3..d30cfeaeeca 100644 --- a/rostests/winetests/shell32/CMakeLists.txt +++ b/rostests/winetests/shell32/CMakeLists.txt @@ -27,3 +27,4 @@ add_executable(shell32_winetest ${SOURCE}) target_link_libraries(shell32_winetest wine uuid) set_module_type(shell32_winetest win32cui) add_importlibs(shell32_winetest shlwapi gdi32 shell32 ole32 oleaut32 user32 advapi32 msvcrt kernel32 ntdll) +add_cab_target(shell32_winetest 7) diff --git a/rostests/winetests/shlwapi/CMakeLists.txt b/rostests/winetests/shlwapi/CMakeLists.txt index e0f8c65d7f7..717c3927f6a 100644 --- a/rostests/winetests/shlwapi/CMakeLists.txt +++ b/rostests/winetests/shlwapi/CMakeLists.txt @@ -21,3 +21,4 @@ add_executable(shlwapi_winetest ${SOURCE}) target_link_libraries(shlwapi_winetest wine uuid) set_module_type(shlwapi_winetest win32cui) add_importlibs(shlwapi_winetest shlwapi ole32 oleaut32 user32 advapi32 msvcrt kernel32 ntdll) +add_cab_target(shlwapi_winetest 7) diff --git a/rostests/winetests/snmpapi/CMakeLists.txt b/rostests/winetests/snmpapi/CMakeLists.txt index acf5b7b9167..e4432f9fd1e 100644 --- a/rostests/winetests/snmpapi/CMakeLists.txt +++ b/rostests/winetests/snmpapi/CMakeLists.txt @@ -7,3 +7,4 @@ add_executable(snmpapi_winetest util.c testlist.c) target_link_libraries(snmpapi_winetest wine) set_module_type(snmpapi_winetest win32cui) add_importlibs(snmpapi_winetest snmpapi msvcrt kernel32 ntdll) +add_cab_target(snmpapi_winetest 7) diff --git a/rostests/winetests/spoolss/CMakeLists.txt b/rostests/winetests/spoolss/CMakeLists.txt index fb9bd53d0fc..353dc36c0ef 100644 --- a/rostests/winetests/spoolss/CMakeLists.txt +++ b/rostests/winetests/spoolss/CMakeLists.txt @@ -7,3 +7,4 @@ add_executable(spoolss_winetest spoolss.c testlist.c) target_link_libraries(spoolss_winetest wine) set_module_type(spoolss_winetest win32cui) add_importlibs(spoolss_winetest msvcrt kernel32 ntdll) +add_cab_target(spoolss_winetest 7) diff --git a/rostests/winetests/twain_32/CMakeLists.txt b/rostests/winetests/twain_32/CMakeLists.txt index 57820f56d36..2fa4ab824c1 100644 --- a/rostests/winetests/twain_32/CMakeLists.txt +++ b/rostests/winetests/twain_32/CMakeLists.txt @@ -7,3 +7,4 @@ add_executable(twain_32_winetest dsm.c testlist.c) target_link_libraries(twain_32_winetest wine) set_module_type(twain_32_winetest win32cui) add_importlibs(twain_32_winetest user32 gdi32 msvcrt kernel32 ntdll) +add_cab_target(twain_32_winetest 7) diff --git a/rostests/winetests/urlmon/CMakeLists.txt b/rostests/winetests/urlmon/CMakeLists.txt index 39d596ddb92..d114e738ed8 100644 --- a/rostests/winetests/urlmon/CMakeLists.txt +++ b/rostests/winetests/urlmon/CMakeLists.txt @@ -17,3 +17,4 @@ add_executable(urlmon_winetest ${SOURCE}) target_link_libraries(urlmon_winetest wine uuid) set_module_type(urlmon_winetest win32cui) add_importlibs(urlmon_winetest urlmon ole32 oleaut32 user32 advapi32 msvcrt kernel32 ntdll) +add_cab_target(urlmon_winetest 7) diff --git a/rostests/winetests/user32/CMakeLists.txt b/rostests/winetests/user32/CMakeLists.txt index 73059b55c65..6b36fe307b6 100644 --- a/rostests/winetests/user32/CMakeLists.txt +++ b/rostests/winetests/user32/CMakeLists.txt @@ -35,3 +35,4 @@ add_executable(user32_winetest ${SOURCE}) target_link_libraries(user32_winetest wine) set_module_type(user32_winetest win32cui) add_importlibs(user32_winetest user32 gdi32 advapi32 msvcrt kernel32 ntdll) +add_cab_target(user32_winetest 7) diff --git a/rostests/winetests/userenv/CMakeLists.txt b/rostests/winetests/userenv/CMakeLists.txt index a08afc1d055..005100b2089 100644 --- a/rostests/winetests/userenv/CMakeLists.txt +++ b/rostests/winetests/userenv/CMakeLists.txt @@ -7,3 +7,4 @@ add_executable(userenv_winetest userenv.c testlist.c) target_link_libraries(userenv_winetest wine) set_module_type(userenv_winetest win32cui) add_importlibs(userenv_winetest userenv advapi32 msvcrt kernel32 ntdll) +add_cab_target(userenv_winetest 7) diff --git a/rostests/winetests/usp10/CMakeLists.txt b/rostests/winetests/usp10/CMakeLists.txt index c274692767d..5af973502cf 100644 --- a/rostests/winetests/usp10/CMakeLists.txt +++ b/rostests/winetests/usp10/CMakeLists.txt @@ -7,3 +7,4 @@ add_executable(usp10_winetest usp10.c testlist.c) target_link_libraries(usp10_winetest wine) set_module_type(usp10_winetest win32cui) add_importlibs(usp10_winetest usp10 user32 gdi32 msvcrt kernel32 ntdll) +add_cab_target(usp10_winetest 7) diff --git a/rostests/winetests/uxtheme/CMakeLists.txt b/rostests/winetests/uxtheme/CMakeLists.txt index 927816b6858..4b5bd869566 100644 --- a/rostests/winetests/uxtheme/CMakeLists.txt +++ b/rostests/winetests/uxtheme/CMakeLists.txt @@ -7,3 +7,4 @@ add_executable(uxtheme_winetest system.c testlist.c) target_link_libraries(uxtheme_winetest wine) set_module_type(uxtheme_winetest win32cui) add_importlibs(uxtheme_winetest user32 msvcrt kernel32 ntdll) +add_cab_target(uxtheme_winetest 7) diff --git a/rostests/winetests/version/CMakeLists.txt b/rostests/winetests/version/CMakeLists.txt index 7fe89d620e5..e45ba247973 100644 --- a/rostests/winetests/version/CMakeLists.txt +++ b/rostests/winetests/version/CMakeLists.txt @@ -13,3 +13,4 @@ add_executable(version_winetest ${SOURCE}) target_link_libraries(version_winetest wine) set_module_type(version_winetest win32cui) add_importlibs(version_winetest version msvcrt kernel32 ntdll) +add_cab_target(version_winetest 7) diff --git a/rostests/winetests/winhttp/CMakeLists.txt b/rostests/winetests/winhttp/CMakeLists.txt index 10c744496e7..5b8ebb56572 100644 --- a/rostests/winetests/winhttp/CMakeLists.txt +++ b/rostests/winetests/winhttp/CMakeLists.txt @@ -13,3 +13,4 @@ add_executable(winhttp_winetest ${SOURCE}) target_link_libraries(winhttp_winetest wine) set_module_type(winhttp_winetest win32cui) add_importlibs(winhttp_winetest winhttp crypt32 ws2_32 advapi32 msvcrt kernel32 ntdll) +add_cab_target(winhttp_winetest 7) diff --git a/rostests/winetests/wininet/CMakeLists.txt b/rostests/winetests/wininet/CMakeLists.txt index a206c728323..ba122e616dc 100644 --- a/rostests/winetests/wininet/CMakeLists.txt +++ b/rostests/winetests/wininet/CMakeLists.txt @@ -16,3 +16,4 @@ add_executable(wininet_winetest ${SOURCE}) target_link_libraries(wininet_winetest wine) set_module_type(wininet_winetest win32cui) add_importlibs(wininet_winetest wininet ws2_32 advapi32 msvcrt kernel32 ntdll) +add_cab_target(wininet_winetest 7) diff --git a/rostests/winetests/winmm/CMakeLists.txt b/rostests/winetests/winmm/CMakeLists.txt index 49d42ff2dc1..b014c57c393 100644 --- a/rostests/winetests/winmm/CMakeLists.txt +++ b/rostests/winetests/winmm/CMakeLists.txt @@ -16,3 +16,4 @@ add_executable(winmm_winetest ${SOURCE}) target_link_libraries(winmm_winetest wine dxguid) set_module_type(winmm_winetest win32cui) add_importlibs(winmm_winetest winmm user32 msvcrt kernel32 ntdll) +add_cab_target(winmm_winetest 7) diff --git a/rostests/winetests/wintrust/CMakeLists.txt b/rostests/winetests/wintrust/CMakeLists.txt index ff291f384cd..3930146c0a0 100644 --- a/rostests/winetests/wintrust/CMakeLists.txt +++ b/rostests/winetests/wintrust/CMakeLists.txt @@ -14,3 +14,4 @@ add_executable(wintrust_winetest ${SOURCE}) target_link_libraries(wintrust_winetest wine) set_module_type(wintrust_winetest win32cui) add_importlibs(wintrust_winetest wintrust crypt32 advapi32 msvcrt kernel32 ntdll) +add_cab_target(wintrust_winetest 7) diff --git a/rostests/winetests/wlanapi/CMakeLists.txt b/rostests/winetests/wlanapi/CMakeLists.txt index edd97014957..4e8cda209d7 100644 --- a/rostests/winetests/wlanapi/CMakeLists.txt +++ b/rostests/winetests/wlanapi/CMakeLists.txt @@ -7,3 +7,4 @@ add_executable(wlanapi_winetest wlanapi.c testlist.c) target_link_libraries(wlanapi_winetest wine) set_module_type(wlanapi_winetest win32cui) add_importlibs(wlanapi_winetest wlanapi msvcrt kernel32 ntdll) +add_cab_target(wlanapi_winetest 7) diff --git a/rostests/winetests/wldap32/CMakeLists.txt b/rostests/winetests/wldap32/CMakeLists.txt index ff8a85c408e..d6ffa420abf 100644 --- a/rostests/winetests/wldap32/CMakeLists.txt +++ b/rostests/winetests/wldap32/CMakeLists.txt @@ -7,3 +7,4 @@ add_executable(wldap32_winetest parse.c testlist.c) target_link_libraries(wldap32_winetest wine) set_module_type(wldap32_winetest win32cui) add_importlibs(wldap32_winetest wldap32 msvcrt kernel32 ntdll) +add_cab_target(wldap32_winetest 7) diff --git a/rostests/winetests/ws2_32/CMakeLists.txt b/rostests/winetests/ws2_32/CMakeLists.txt index 0f0e71dc7da..a11a908e59a 100644 --- a/rostests/winetests/ws2_32/CMakeLists.txt +++ b/rostests/winetests/ws2_32/CMakeLists.txt @@ -7,3 +7,4 @@ add_executable(ws2_32_winetest protocol.c sock.c testlist.c) target_link_libraries(ws2_32_winetest wine) set_module_type(ws2_32_winetest win32cui) add_importlibs(ws2_32_winetest ws2_32 user32 msvcrt kernel32 ntdll) +add_cab_target(ws2_32_winetest 7) diff --git a/rostests/winetests/xmllite/CMakeLists.txt b/rostests/winetests/xmllite/CMakeLists.txt index 6c9ec265d11..821dfb47af6 100644 --- a/rostests/winetests/xmllite/CMakeLists.txt +++ b/rostests/winetests/xmllite/CMakeLists.txt @@ -7,3 +7,4 @@ add_executable(xmllite_winetest reader.c testlist.c) target_link_libraries(xmllite_winetest wine) set_module_type(xmllite_winetest win32cui) add_importlibs(xmllite_winetest xmllite ole32 msvcrt kernel32 ntdll) +add_cab_target(xmllite_winetest 7) From cb0b5d3b3a673429b584a41fe9466a6c4342eb92 Mon Sep 17 00:00:00 2001 From: James Tabor Date: Fri, 31 Dec 2010 04:43:35 +0000 Subject: [PATCH 168/181] [Win32k|User32] - Add hack to mark desktop window as a desktop window and notes for creating a desktop with tips in win32k. Move user position code from window to winpos. svn path=/trunk/; revision=50229 --- reactos/dll/win32/user32/windows/window.c | 87 ------------------ reactos/dll/win32/user32/windows/winpos.c | 90 ++++++++++++++++++- .../win32/csrss/win32csr/desktopbg.c | 1 + .../subsystems/win32/win32k/ntuser/desktop.c | 42 ++++++++- .../subsystems/win32/win32k/ntuser/window.c | 7 +- 5 files changed, 132 insertions(+), 95 deletions(-) diff --git a/reactos/dll/win32/user32/windows/window.c b/reactos/dll/win32/user32/windows/window.c index 2538acf82cf..be687a64b6f 100644 --- a/reactos/dll/win32/user32/windows/window.c +++ b/reactos/dll/win32/user32/windows/window.c @@ -1831,92 +1831,6 @@ UpdateLayeredWindowIndirect(HWND hwnd, return FALSE; } - -/* - * @implemented - */ -HWND WINAPI -WindowFromPoint(POINT Point) -{ - //TODO: Determine what the actual parameters to - // NtUserWindowFromPoint are. - return NtUserWindowFromPoint(Point.x, Point.y); -} - - -/* - * @implemented - */ -int WINAPI -MapWindowPoints(HWND hWndFrom, HWND hWndTo, LPPOINT lpPoints, UINT cPoints) -{ - PWND FromWnd, ToWnd; - POINT Delta; - UINT i; - - FromWnd = ValidateHwndOrDesk(hWndFrom); - if (!FromWnd) - return 0; - - ToWnd = ValidateHwndOrDesk(hWndTo); - if (!ToWnd) - return 0; - - Delta.x = FromWnd->rcClient.left - ToWnd->rcClient.left; - Delta.y = FromWnd->rcClient.top - ToWnd->rcClient.top; - - for (i = 0; i != cPoints; i++) - { - lpPoints[i].x += Delta.x; - lpPoints[i].y += Delta.y; - } - - return MAKELONG(LOWORD(Delta.x), LOWORD(Delta.y)); -} - - -/* - * @implemented - */ -BOOL WINAPI -ScreenToClient(HWND hWnd, LPPOINT lpPoint) -{ - PWND Wnd, DesktopWnd; - - Wnd = ValidateHwnd(hWnd); - if (!Wnd) - return FALSE; - - DesktopWnd = GetThreadDesktopWnd(); - - lpPoint->x += DesktopWnd->rcClient.left - Wnd->rcClient.left; - lpPoint->y += DesktopWnd->rcClient.top - Wnd->rcClient.top; - - return TRUE; -} - - -/* - * @implemented - */ -BOOL WINAPI -ClientToScreen(HWND hWnd, LPPOINT lpPoint) -{ - PWND Wnd, DesktopWnd; - - Wnd = ValidateHwnd(hWnd); - if (!Wnd) - return FALSE; - - DesktopWnd = GetThreadDesktopWnd(); - - lpPoint->x += Wnd->rcClient.left - DesktopWnd->rcClient.left; - lpPoint->y += Wnd->rcClient.top - DesktopWnd->rcClient.top; - - return TRUE; -} - - /* * @implemented */ @@ -1927,7 +1841,6 @@ SetWindowContextHelpId(HWND hwnd, return NtUserSetWindowContextHelpId(hwnd, dwContextHelpId); } - /* * @implemented */ diff --git a/reactos/dll/win32/user32/windows/winpos.c b/reactos/dll/win32/user32/windows/winpos.c index 9503b96be34..44a3371ff66 100644 --- a/reactos/dll/win32/user32/windows/winpos.c +++ b/reactos/dll/win32/user32/windows/winpos.c @@ -1,8 +1,7 @@ -/* $Id$ - * +/* * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS user32.dll - * FILE: lib/user32/windows/window.c + * FILE: dll/win32/user32/windows/winpos.c * PURPOSE: Window management * PROGRAMMER: Casper S. Hornstrup (chorns@users.sourceforge.net) * UPDATE HISTORY: @@ -111,3 +110,88 @@ ArrangeIconicWindows(HWND hWnd) { return NtUserCallHwndLock( hWnd, HWNDLOCK_ROUTINE_ARRANGEICONICWINDOWS); } + +/* + * @implemented + */ +HWND WINAPI +WindowFromPoint(POINT Point) +{ + //TODO: Determine what the actual parameters to + // NtUserWindowFromPoint are. + return NtUserWindowFromPoint(Point.x, Point.y); +} + + +/* + * @implemented + */ +int WINAPI +MapWindowPoints(HWND hWndFrom, HWND hWndTo, LPPOINT lpPoints, UINT cPoints) +{ + PWND FromWnd, ToWnd; + POINT Delta; + UINT i; + + FromWnd = ValidateHwndOrDesk(hWndFrom); + if (!FromWnd) + return 0; + + ToWnd = ValidateHwndOrDesk(hWndTo); + if (!ToWnd) + return 0; + + Delta.x = FromWnd->rcClient.left - ToWnd->rcClient.left; + Delta.y = FromWnd->rcClient.top - ToWnd->rcClient.top; + + for (i = 0; i != cPoints; i++) + { + lpPoints[i].x += Delta.x; + lpPoints[i].y += Delta.y; + } + + return MAKELONG(LOWORD(Delta.x), LOWORD(Delta.y)); +} + + +/* + * @implemented + */ +BOOL WINAPI +ScreenToClient(HWND hWnd, LPPOINT lpPoint) +{ + PWND Wnd, DesktopWnd; + + Wnd = ValidateHwnd(hWnd); + if (!Wnd) + return FALSE; + + DesktopWnd = GetThreadDesktopWnd(); + + lpPoint->x += DesktopWnd->rcClient.left - Wnd->rcClient.left; + lpPoint->y += DesktopWnd->rcClient.top - Wnd->rcClient.top; + + return TRUE; +} + + +/* + * @implemented + */ +BOOL WINAPI +ClientToScreen(HWND hWnd, LPPOINT lpPoint) +{ + PWND Wnd, DesktopWnd; + + Wnd = ValidateHwnd(hWnd); + if (!Wnd) + return FALSE; + + DesktopWnd = GetThreadDesktopWnd(); + + lpPoint->x += Wnd->rcClient.left - DesktopWnd->rcClient.left; + lpPoint->y += Wnd->rcClient.top - DesktopWnd->rcClient.top; + + return TRUE; +} + diff --git a/reactos/subsystems/win32/csrss/win32csr/desktopbg.c b/reactos/subsystems/win32/csrss/win32csr/desktopbg.c index 14a6155fb00..2c158c57e58 100644 --- a/reactos/subsystems/win32/csrss/win32csr/desktopbg.c +++ b/reactos/subsystems/win32/csrss/win32csr/desktopbg.c @@ -65,6 +65,7 @@ DtbgWindowProc(HWND Wnd, return (LRESULT)TRUE; case WM_CREATE: + NtUserSetWindowFNID(Wnd, FNID_DESKTOP); // Anti-ReactOS hack! case WM_CLOSE: return 0; diff --git a/reactos/subsystems/win32/win32k/ntuser/desktop.c b/reactos/subsystems/win32/win32k/ntuser/desktop.c index 95c07af381e..74da248d3e7 100644 --- a/reactos/subsystems/win32/win32k/ntuser/desktop.c +++ b/reactos/subsystems/win32/win32k/ntuser/desktop.c @@ -1036,12 +1036,16 @@ NtUserCreateDesktop( } ExFreePoolWithTag(DesktopName.Buffer, TAG_STRING); +//// why is this here? +#if 0 if (! NT_SUCCESS(Status)) { DPRINT1("Failed to create desktop handle\n"); SetLastNtError(Status); RETURN( NULL); } +#endif +//// /* * Create a handle for CSRSS and notify CSRSS for Creating Desktop Window. @@ -1072,7 +1076,35 @@ NtUserCreateDesktop( SetLastNtError(Status); RETURN( NULL); } +#if 0 // Turn on when server side proc is ready. + // + // Create desktop window. + // + ClassName.Buffer = ((PWSTR)((ULONG_PTR)(WORD)(gpsi->atomSysClass[ICLS_DESKTOP]))); + ClassName.Length = 0; + RtlZeroMemory(&MenuName, sizeof(MenuName)); + RtlZeroMemory(&WindowName, sizeof(WindowName)); + RtlZeroMemory(&Cs, sizeof(Cs)); + Cs.x = UserGetSystemMetrics(SM_XVIRTUALSCREEN); + Cs.y = UserGetSystemMetrics(SM_YVIRTUALSCREEN); + Cs.cx = UserGetSystemMetrics(SM_CXVIRTUALSCREEN); + Cs.cy = UserGetSystemMetrics(SM_CYVIRTUALSCREEN); + Cs.style = WS_POPUP|WS_CLIPCHILDREN; + Cs.hInstance = hModClient; // Experimental mode... Move csr stuff to User32. hModuleWin; // Server side winproc! + Cs.lpszName = (LPCWSTR) &WindowName; + Cs.lpszClass = (LPCWSTR) &ClassName; + + pWndDesktop = co_UserCreateWindowEx(&Cs, &ClassName, &WindowName); + if (!pWnd) + { + DPRINT1("Failed to create Desktop window handle\n"); + } + else + { + DesktopObject->pDeskInfo->spwnd = pWndDesktop; + } +#endif W32Thread = PsGetCurrentThreadWin32Thread(); if (!W32Thread->rpdesk) IntSetThreadDesktop(DesktopObject,FALSE); @@ -1089,7 +1121,7 @@ NtUserCreateDesktop( RtlZeroMemory(&Cs, sizeof(Cs)); Cs.cx = Cs.cy = 100; Cs.style = WS_POPUP|WS_CLIPCHILDREN; - Cs.hInstance = hModClient; + Cs.hInstance = hModClient; // hModuleWin; // Server side winproc! Leave it to Timo to not pass on notes! Cs.lpszName = (LPCWSTR) &WindowName; Cs.lpszClass = (LPCWSTR) &ClassName; @@ -1103,6 +1135,14 @@ NtUserCreateDesktop( DesktopObject->spwndMessage = pWnd; } + /* Now,,, + if !(WinStaObject->Flags & WSF_NOIO) is (not set) for desktop input output mode (see wiki) + Create Tooltip. Saved in DesktopObject->spwndTooltip. + Tooltip dwExStyle: WS_EX_TOOLWINDOW|WS_EX_TOPMOST + hWndParent are spwndMessage. Use hModuleWin for server side winproc! + The rest is same as message window. + http://msdn.microsoft.com/en-us/library/bb760250(VS.85).aspx + */ RETURN( Desktop); CLEANUP: diff --git a/reactos/subsystems/win32/win32k/ntuser/window.c b/reactos/subsystems/win32/win32k/ntuser/window.c index 4d978038e3f..a231bdb7e17 100644 --- a/reactos/subsystems/win32/win32k/ntuser/window.c +++ b/reactos/subsystems/win32/win32k/ntuser/window.c @@ -2130,7 +2130,6 @@ co_UserCreateWindowEx(CREATESTRUCTW* Cs, } Window->rcClient = Window->rcWindow; - /* Link the window*/ if (NULL != ParentWindow) { @@ -2140,7 +2139,7 @@ co_UserCreateWindowEx(CREATESTRUCTW* Cs, else IntLinkHwnd(Window, hwndInsertAfter); } - + /* Send the NCCREATE message */ Result = co_IntSendMessage(UserHMGetHandle(Window), WM_NCCREATE, 0, (LPARAM) Cs); if (!Result) @@ -3886,8 +3885,8 @@ NtUserSetWindowFNID(HWND hWnd, // From user land we only set these. if (fnID != FNID_DESTROY) - { - if ( ((fnID < FNID_BUTTON) && (fnID > FNID_GHOST)) || + { // Hacked so we can mark desktop~! + if ( (/*(fnID < FNID_BUTTON)*/ (fnID < FNID_FIRST) && (fnID > FNID_GHOST)) || Wnd->fnid != 0 ) { EngSetLastError(ERROR_INVALID_PARAMETER); From 61f99c89a698a237b9e0a8d640c6d138ea2d3e1a Mon Sep 17 00:00:00 2001 From: Michael Martin Date: Fri, 31 Dec 2010 12:01:21 +0000 Subject: [PATCH 169/181] [usb/usbehci]: - Implement creating and deleting Queue Heads and Transfer Descriptors from common buffer. - Implement linking/unlinking QueueHeads to create a linked list for Asynchronous Schedule traversal. - Implement BuildSetupPacketFromURB for creating a setup packet from a URB. - Implement SubmitControlTransfer. svn path=/trunk/; revision=50230 --- reactos/drivers/usb/usbehci/hwiface.c | 175 ++++++++++++++++++++ reactos/drivers/usb/usbehci/hwiface.h | 24 +++ reactos/drivers/usb/usbehci/transfer.c | 217 +++++++++++++++++++++++++ reactos/drivers/usb/usbehci/transfer.h | 20 +++ 4 files changed, 436 insertions(+) create mode 100644 reactos/drivers/usb/usbehci/hwiface.c create mode 100644 reactos/drivers/usb/usbehci/hwiface.h create mode 100644 reactos/drivers/usb/usbehci/transfer.c create mode 100644 reactos/drivers/usb/usbehci/transfer.h diff --git a/reactos/drivers/usb/usbehci/hwiface.c b/reactos/drivers/usb/usbehci/hwiface.c new file mode 100644 index 00000000000..92313ee13aa --- /dev/null +++ b/reactos/drivers/usb/usbehci/hwiface.c @@ -0,0 +1,175 @@ +/* + * PROJECT: ReactOS Universal Serial Bus Bulk Enhanced Host Controller Interface + * LICENSE: GPL - See COPYING in the top level directory + * FILE: drivers/usb/usbehci/hwiface.c + * PURPOSE: EHCI Interface routines: Queue Heads and Queue Element + Transfer Descriptors. + * TODO: Periodic Frame List, Isochronous Transaction Descriptors + and Split-transaction ITD. + * PROGRAMMERS: + * Michael Martin (michael.martin@reactos.org) + */ + +#include "hwiface.h" +#include "physmem.h" +#define NDEBUG +#include + +/* Queue Element Transfer Descriptors */ + +PQUEUE_TRANSFER_DESCRIPTOR +CreateDescriptor(PEHCI_HOST_CONTROLLER hcd, UCHAR PIDCode, ULONG TotalBytesToTransfer) +{ + PQUEUE_TRANSFER_DESCRIPTOR Descriptor; + ULONG PhysicalAddress; + UCHAR i; + KIRQL OldIrql; + + KeAcquireSpinLock(&hcd->Lock, &OldIrql); + + Descriptor = (PQUEUE_TRANSFER_DESCRIPTOR)AllocateMemory(hcd, sizeof(QUEUE_TRANSFER_DESCRIPTOR), &PhysicalAddress); + RtlZeroMemory(Descriptor, sizeof(QUEUE_TRANSFER_DESCRIPTOR)); + Descriptor->NextPointer = TERMINATE_POINTER; + Descriptor->AlternateNextPointer = TERMINATE_POINTER; + Descriptor->Token.Bits.DataToggle = TRUE; + Descriptor->Token.Bits.InterruptOnComplete = TRUE; + Descriptor->Token.Bits.ErrorCounter = 0x03; + Descriptor->Token.Bits.Active = TRUE; + Descriptor->Token.Bits.PIDCode = PIDCode; + Descriptor->Token.Bits.TotalBytesToTransfer = TotalBytesToTransfer; + Descriptor->PhysicalAddr = PhysicalAddress; + for (i=0;i<5;i++) + Descriptor->BufferPointer[i] = 0; + + KeReleaseSpinLock(&hcd->Lock, OldIrql); + + return Descriptor; +} + +VOID +FreeDescriptor(PQUEUE_TRANSFER_DESCRIPTOR Descriptor) +{ + ReleaseMemory((ULONG)Descriptor); +} + +/* Queue Head */ + +VOID +DumpQueueHeadList(PEHCI_HOST_CONTROLLER hcd) +{ + KIRQL OldIrql; + + KeAcquireSpinLock(&hcd->Lock, &OldIrql); + + PQUEUE_HEAD QueueHead = (PQUEUE_HEAD)hcd->CommonBufferVA; + PQUEUE_HEAD FirstQueueHead = QueueHead; + DPRINT1("Dumping QueueHead List!!!!!!!!!!!!!\n"); + while (1) + { + DPRINT1("QueueHead Address %x\n", QueueHead); + DPRINT1("QueueHead->PreviousQueueHead = %x\n", QueueHead->PreviousQueueHead); + DPRINT1("QueueHead->NextQueueHead = %x\n", QueueHead->NextQueueHead); + DPRINT1(" ---> PhysicalAddress %x\n", (ULONG)MmGetPhysicalAddress(QueueHead).LowPart); + DPRINT1("QueueHead->HorizontalLinkPointer %x\n", QueueHead->HorizontalLinkPointer); + QueueHead = QueueHead->NextQueueHead; + DPRINT1("Next QueueHead %x\n", QueueHead); + if (QueueHead == FirstQueueHead) break; + } + DPRINT1("-----------------------------------\n"); + KeReleaseSpinLock(&hcd->Lock, OldIrql); +} + +PQUEUE_HEAD +CreateQueueHead(PEHCI_HOST_CONTROLLER hcd) +{ + PQUEUE_HEAD CurrentQH; + ULONG PhysicalAddress , i; + KIRQL OldIrql; + + KeAcquireSpinLock(&hcd->Lock, &OldIrql); + + CurrentQH = (PQUEUE_HEAD)AllocateMemory(hcd, sizeof(QUEUE_HEAD), &PhysicalAddress); + RtlZeroMemory(CurrentQH, sizeof(QUEUE_HEAD)); + + ASSERT(CurrentQH); + CurrentQH->PhysicalAddr = PhysicalAddress; + CurrentQH->HorizontalLinkPointer = TERMINATE_POINTER; + CurrentQH->CurrentLinkPointer = TERMINATE_POINTER; + CurrentQH->AlternateNextPointer = TERMINATE_POINTER; + CurrentQH->NextPointer = TERMINATE_POINTER; + + /* 1 for non high speed, 0 for high speed device */ + CurrentQH->EndPointCharacteristics.ControlEndPointFlag = 0; + CurrentQH->EndPointCharacteristics.HeadOfReclamation = FALSE; + CurrentQH->EndPointCharacteristics.MaximumPacketLength = 64; + + /* Set NakCountReload to max value possible */ + CurrentQH->EndPointCharacteristics.NakCountReload = 0xF; + + /* Get the Initial Data Toggle from the QEDT */ + CurrentQH->EndPointCharacteristics.QEDTDataToggleControl = TRUE; + + /* High Speed Device */ + CurrentQH->EndPointCharacteristics.EndPointSpeed = QH_ENDPOINT_HIGHSPEED; + + CurrentQH->EndPointCapabilities.NumberOfTransactionPerFrame = 0x03; + + CurrentQH->Token.DWord = 0; + CurrentQH->NextQueueHead = NULL; + CurrentQH->PreviousQueueHead = NULL; + for (i=0; i<5; i++) + CurrentQH->BufferPointer[i] = 0; + + CurrentQH->Token.Bits.InterruptOnComplete = TRUE; + + KeReleaseSpinLock(&hcd->Lock, OldIrql); + return CurrentQH; +} + +VOID +LinkQueueHead(PEHCI_HOST_CONTROLLER hcd, PQUEUE_HEAD QueueHead) +{ + KIRQL OldIrql; + PQUEUE_HEAD CurrentHead = (PQUEUE_HEAD)hcd->AsyncListQueue; + PQUEUE_HEAD PreviousHead = CurrentHead->PreviousQueueHead; + + KeAcquireSpinLock(&hcd->Lock, &OldIrql); + + QueueHead->HorizontalLinkPointer = (CurrentHead->HorizontalLinkPointer | QH_TYPE_QH) & ~TERMINATE_POINTER; + QueueHead->NextQueueHead = CurrentHead; + QueueHead->PreviousQueueHead = PreviousHead; + + CurrentHead->PreviousQueueHead = QueueHead; + if (PreviousHead) + PreviousHead->NextQueueHead = QueueHead; + + CurrentHead->HorizontalLinkPointer = QueueHead->PhysicalAddr | QH_TYPE_QH; + + KeReleaseSpinLock(&hcd->Lock, OldIrql); +} + +VOID +UnlinkQueueHead(PEHCI_HOST_CONTROLLER hcd, PQUEUE_HEAD QueueHead) +{ + KIRQL OldIrql; + PQUEUE_HEAD PreviousHead = QueueHead->PreviousQueueHead; + PQUEUE_HEAD NextHead = QueueHead->NextQueueHead; + KeAcquireSpinLock(&hcd->Lock, &OldIrql); + + if (PreviousHead) + { + PreviousHead->NextQueueHead = NextHead; + PreviousHead->HorizontalLinkPointer = QueueHead->HorizontalLinkPointer; + } + if (NextHead) + NextHead->PreviousQueueHead = PreviousHead; + + KeReleaseSpinLock(&hcd->Lock, OldIrql); +} + +VOID +DeleteQueueHead(PQUEUE_HEAD QueueHead) +{ + ReleaseMemory((ULONG)QueueHead); +} + diff --git a/reactos/drivers/usb/usbehci/hwiface.h b/reactos/drivers/usb/usbehci/hwiface.h new file mode 100644 index 00000000000..4fbf22dea96 --- /dev/null +++ b/reactos/drivers/usb/usbehci/hwiface.h @@ -0,0 +1,24 @@ +#include "hardware.h" +#include + +PQUEUE_TRANSFER_DESCRIPTOR +CreateDescriptor(PEHCI_HOST_CONTROLLER hcd, UCHAR PIDCode, ULONG TotalBytesToTransfer); + +VOID +FreeDescriptor(PQUEUE_TRANSFER_DESCRIPTOR Descriptor); + +VOID +DumpQueueHeadList(PEHCI_HOST_CONTROLLER hcd); + +PQUEUE_HEAD +CreateQueueHead(PEHCI_HOST_CONTROLLER hcd); + +VOID +LinkQueueHead(PEHCI_HOST_CONTROLLER hcd, PQUEUE_HEAD QueueHead); + +VOID +UnlinkQueueHead(PEHCI_HOST_CONTROLLER hcd, PQUEUE_HEAD QueueHead); + +VOID +DeleteQueueHead(PQUEUE_HEAD QueueHead); + diff --git a/reactos/drivers/usb/usbehci/transfer.c b/reactos/drivers/usb/usbehci/transfer.c new file mode 100644 index 00000000000..436bd17ecdb --- /dev/null +++ b/reactos/drivers/usb/usbehci/transfer.c @@ -0,0 +1,217 @@ +/* + * PROJECT: ReactOS Universal Serial Bus Bulk Enhanced Host Controller Interface + * LICENSE: GPL - See COPYING in the top level directory + * FILE: drivers/usb/usbehci/transfer.c + * PURPOSE: Transfers to EHCI. + * PROGRAMMERS: + * Michael Martin (michael.martin@reactos.org) + */ + +#include "transfer.h" +#include + +VOID +BuildSetupPacketFromURB(PEHCI_HOST_CONTROLLER hcd, PURB Urb, PUSB_DEFAULT_PIPE_SETUP_PACKET CtrlSetup) +{ + switch (Urb->UrbHeader.Function) + { + /* CLEAR FEATURE */ + case URB_FUNCTION_CLEAR_FEATURE_TO_DEVICE: + case URB_FUNCTION_CLEAR_FEATURE_TO_INTERFACE: + case URB_FUNCTION_CLEAR_FEATURE_TO_ENDPOINT: + DPRINT1("Not implemented!\n"); + break; + + /* GET CONFIG */ + case URB_FUNCTION_GET_CONFIGURATION: + CtrlSetup->bRequest = USB_REQUEST_GET_CONFIGURATION; + CtrlSetup->bmRequestType.B = 0x80; + CtrlSetup->wLength = 1; + break; + + /* GET DESCRIPTOR */ + case URB_FUNCTION_GET_DESCRIPTOR_FROM_DEVICE: + CtrlSetup->bRequest = USB_REQUEST_GET_DESCRIPTOR; + CtrlSetup->wValue.LowByte = Urb->UrbControlDescriptorRequest.Index; + CtrlSetup->wValue.HiByte = Urb->UrbControlDescriptorRequest.DescriptorType; + CtrlSetup->wIndex.W = Urb->UrbControlDescriptorRequest.LanguageId; + CtrlSetup->wLength = Urb->UrbControlDescriptorRequest.TransferBufferLength; + CtrlSetup->bmRequestType.B = 0x80; + break; + + /* GET INTERFACE */ + case URB_FUNCTION_GET_INTERFACE: + CtrlSetup->bRequest = USB_REQUEST_GET_CONFIGURATION; + CtrlSetup->wIndex.W = Urb->UrbControlGetStatusRequest.Index; + CtrlSetup->bmRequestType.B = 0x80; + CtrlSetup->wLength = 1; + break; + + /* GET STATUS */ + case URB_FUNCTION_GET_STATUS_FROM_DEVICE: + CtrlSetup->bRequest = USB_REQUEST_GET_STATUS; + ASSERT(Urb->UrbControlGetStatusRequest.Index == 0); + CtrlSetup->wIndex.W = Urb->UrbControlGetStatusRequest.Index; + CtrlSetup->bmRequestType.B = 0x80; + CtrlSetup->wLength = 2; + break; + + case URB_FUNCTION_GET_STATUS_FROM_INTERFACE: + CtrlSetup->bRequest = USB_REQUEST_GET_STATUS; + ASSERT(Urb->UrbControlGetStatusRequest.Index != 0); + CtrlSetup->wIndex.W = Urb->UrbControlGetStatusRequest.Index; + CtrlSetup->bmRequestType.B = 0x81; + CtrlSetup->wLength = 2; + break; + + case URB_FUNCTION_GET_STATUS_FROM_ENDPOINT: + CtrlSetup->bRequest = USB_REQUEST_GET_STATUS; + ASSERT(Urb->UrbControlGetStatusRequest.Index != 0); + CtrlSetup->wIndex.W = Urb->UrbControlGetStatusRequest.Index; + CtrlSetup->bmRequestType.B = 0x82; + CtrlSetup->wLength = 2; + break; + + /* SET ADDRESS */ + + /* SET CONFIG */ + case URB_FUNCTION_SELECT_CONFIGURATION: + CtrlSetup->bRequest = USB_REQUEST_SET_CONFIGURATION; + CtrlSetup->bmRequestType.B = 0x00; + break; + + /* SET DESCRIPTOR */ + case URB_FUNCTION_SET_DESCRIPTOR_TO_DEVICE: + case URB_FUNCTION_SET_DESCRIPTOR_TO_INTERFACE: + case URB_FUNCTION_SET_DESCRIPTOR_TO_ENDPOINT: + DPRINT1("Not implemented\n"); + break; + + /* SET FEATURE */ + case URB_FUNCTION_SET_FEATURE_TO_DEVICE: + CtrlSetup->bRequest = USB_REQUEST_SET_FEATURE; + ASSERT(Urb->UrbControlGetStatusRequest.Index == 0); + CtrlSetup->wIndex.W = Urb->UrbControlGetStatusRequest.Index; + CtrlSetup->bmRequestType.B = 0x80; + break; + + case URB_FUNCTION_SET_FEATURE_TO_INTERFACE: + CtrlSetup->bRequest = USB_REQUEST_SET_FEATURE; + ASSERT(Urb->UrbControlGetStatusRequest.Index == 0); + CtrlSetup->wIndex.W = Urb->UrbControlGetStatusRequest.Index; + CtrlSetup->bmRequestType.B = 0x81; + break; + + case URB_FUNCTION_SET_FEATURE_TO_ENDPOINT: + CtrlSetup->bRequest = USB_REQUEST_SET_FEATURE; + ASSERT(Urb->UrbControlGetStatusRequest.Index == 0); + CtrlSetup->wIndex.W = Urb->UrbControlGetStatusRequest.Index; + CtrlSetup->bmRequestType.B = 0x82; + break; + + /* SET INTERFACE*/ + case URB_FUNCTION_SELECT_INTERFACE: + DPRINT1("Not implemented\n"); + break; + + /* SYNC FRAME */ + case URB_FUNCTION_SYNC_RESET_PIPE_AND_CLEAR_STALL: + DPRINT1("Not implemented\n"); + break; + default: + DPRINT1("Unknown USB Request!\n"); + break; + } +} + +BOOLEAN +SubmitControlTransfer(PEHCI_HOST_CONTROLLER hcd, + PUSB_DEFAULT_PIPE_SETUP_PACKET CtrlSetup, + PVOID TransferBuffer, + ULONG TransferBufferLength, + PIRP IrpToComplete) +{ + PQUEUE_HEAD QueueHead; + PQUEUE_TRANSFER_DESCRIPTOR Descriptor[3]; + ULONG MdlPhysicalAddr; + PKEVENT Event = NULL; + PMDL pMdl = NULL; + PUSB_DEFAULT_PIPE_SETUP_PACKET CtrlSetupVA, CtrlPhysicalPA; + + CtrlSetupVA = (PUSB_DEFAULT_PIPE_SETUP_PACKET)AllocateMemory(hcd, + sizeof(USB_DEFAULT_PIPE_SETUP_PACKET), + (ULONG*)&CtrlPhysicalPA); + + RtlCopyMemory(CtrlSetupVA, CtrlSetup, sizeof(USB_DEFAULT_PIPE_SETUP_PACKET)); + /* If no Irp then wait on completion */ + if (IrpToComplete == NULL) + { + Event = ExAllocatePool(NonPagedPool, sizeof(KEVENT)); + KeInitializeEvent(Event, NotificationEvent, FALSE); + } + + /* Allocate Mdl for Buffer */ + pMdl = IoAllocateMdl(TransferBuffer, + TransferBufferLength, + FALSE, + FALSE, + NULL); + + /* Lock Physical Pages */ + MmBuildMdlForNonPagedPool(pMdl); + //MmProbeAndLockPages(pMdl, KernelMode, IoReadAccess); + + MdlPhysicalAddr = MmGetPhysicalAddress((PVOID)TransferBuffer).LowPart; + + QueueHead = CreateQueueHead(hcd); + + Descriptor[0] = CreateDescriptor(hcd, + PID_CODE_SETUP_TOKEN, + sizeof(USB_DEFAULT_PIPE_SETUP_PACKET)); + + Descriptor[0]->Token.Bits.InterruptOnComplete = FALSE; + Descriptor[0]->Token.Bits.DataToggle = FALSE; + + /* Save the first descriptor */ + QueueHead->TransferDescriptor = Descriptor[0]; + + Descriptor[1] = CreateDescriptor(hcd, + PID_CODE_IN_TOKEN, + TransferBufferLength); + + Descriptor[2] = CreateDescriptor(hcd, + PID_CODE_OUT_TOKEN, + 0); + + Descriptor[1]->Token.Bits.InterruptOnComplete = FALSE; + + /* Link the descriptors */ + Descriptor[0]->NextDescriptor = Descriptor[1]; + Descriptor[1]->NextDescriptor = Descriptor[2]; + Descriptor[1]->PreviousDescriptor = Descriptor[0]; + Descriptor[2]->PreviousDescriptor = Descriptor[1]; + + /* Assign the descritors buffers */ + Descriptor[0]->BufferPointer[0] = (ULONG)CtrlPhysicalPA; + Descriptor[1]->BufferPointer[0] = MdlPhysicalAddr; + + Descriptor[0]->NextPointer = Descriptor[1]->PhysicalAddr; + Descriptor[1]->NextPointer = Descriptor[2]->PhysicalAddr; + QueueHead->NextPointer = Descriptor[0]->PhysicalAddr; + + QueueHead->IrpToComplete = IrpToComplete; + QueueHead->MdlToFree = pMdl; + QueueHead->Event = Event; + + /* Link in the QueueHead */ + LinkQueueHead(hcd, QueueHead); + + if (IrpToComplete == NULL) + { + DPRINT1("Waiting For Completion %x!\n", Event); + KeWaitForSingleObject(Event, Suspended, KernelMode, FALSE, NULL); + ExFreePool(Event); + } + + return TRUE; +} diff --git a/reactos/drivers/usb/usbehci/transfer.h b/reactos/drivers/usb/usbehci/transfer.h new file mode 100644 index 00000000000..eebffd921fa --- /dev/null +++ b/reactos/drivers/usb/usbehci/transfer.h @@ -0,0 +1,20 @@ +#pragma once + +#include "hardware.h" +#include "hwiface.h" +#include "physmem.h" +#include +#include + +BOOLEAN +SubmitControlTransfer(PEHCI_HOST_CONTROLLER hcd, + PUSB_DEFAULT_PIPE_SETUP_PACKET CtrlSetup, + PVOID TransferBuffer, + ULONG TransferBufferLength, + PIRP IrpToComplete); + +VOID +BuildSetupPacketFromURB(PEHCI_HOST_CONTROLLER hcd, + PURB Urb, + PUSB_DEFAULT_PIPE_SETUP_PACKET CtrlSetup); + From 0d6bdbec517ee7862d99513b8ca14afe920d7f89 Mon Sep 17 00:00:00 2001 From: Michael Martin Date: Fri, 31 Dec 2010 12:26:12 +0000 Subject: [PATCH 170/181] [usb/usbehci]: - Remove all hardware related structs from usbehci.h as they are now in hardware.h. - Add debugging routines for usb descriptors, queue heads and transfer descriptors. - This will break building usbehci, but not a problem as it is not included in the default build. Will be fixed with later commit. svn path=/trunk/; revision=50231 --- reactos/drivers/usb/usbehci/common.c | 106 ++++++++- reactos/drivers/usb/usbehci/usbehci.h | 302 +++----------------------- 2 files changed, 137 insertions(+), 271 deletions(-) diff --git a/reactos/drivers/usb/usbehci/common.c b/reactos/drivers/usb/usbehci/common.c index 3f6a99401b7..5fb0cc6fe08 100644 --- a/reactos/drivers/usb/usbehci/common.c +++ b/reactos/drivers/usb/usbehci/common.c @@ -2,7 +2,7 @@ * PROJECT: ReactOS Universal Serial Bus Bulk Enhanced Host Controller Interface * LICENSE: GPL - See COPYING in the top level directory * FILE: drivers/usb/usbehci/common.c - * PURPOSE: Common operations in FDO/PDO. + * PURPOSE: Common operations. * PROGRAMMERS: * Michael Martin (michael.martin@reactos.org) */ @@ -12,7 +12,109 @@ #include #include -/* PUBLIC AND PRIVATE FUNCTIONS ***********************************************/ +VOID +DumpDeviceDescriptor(PUSB_DEVICE_DESCRIPTOR DeviceDescriptor) +{ + DPRINT1("Dumping Device Descriptor %x\n", DeviceDescriptor); + DPRINT1("bLength %x\n", DeviceDescriptor->bLength); + DPRINT1("bDescriptorType %x\n", DeviceDescriptor->bDescriptorType); + DPRINT1("bcdUSB %x\n", DeviceDescriptor->bcdUSB); + DPRINT1("bDeviceClass %x\n", DeviceDescriptor->bDeviceClass); + DPRINT1("bDeviceSubClass %x\n", DeviceDescriptor->bDeviceSubClass); + DPRINT1("bDeviceProtocol %x\n", DeviceDescriptor->bDeviceProtocol); + DPRINT1("bMaxPacketSize0 %x\n", DeviceDescriptor->bMaxPacketSize0); + DPRINT1("idVendor %x\n", DeviceDescriptor->idVendor); + DPRINT1("idProduct %x\n", DeviceDescriptor->idProduct); + DPRINT1("bcdDevice %x\n", DeviceDescriptor->bcdDevice); + DPRINT1("iManufacturer %x\n", DeviceDescriptor->iManufacturer); + DPRINT1("iProduct %x\n", DeviceDescriptor->iProduct); + DPRINT1("iSerialNumber %x\n", DeviceDescriptor->iSerialNumber); + DPRINT1("bNumConfigurations %x\n", DeviceDescriptor->bNumConfigurations); +} + +VOID +DumpFullConfigurationDescriptor(PUSB_CONFIGURATION_DESCRIPTOR ConfigurationDescriptor) +{ + PUSB_INTERFACE_DESCRIPTOR InterfaceDescriptor; + PUSB_ENDPOINT_DESCRIPTOR EndpointDescriptor; + LONG i, j; + + DPRINT1("Dumping ConfigurationDescriptor %x\n", ConfigurationDescriptor); + DPRINT1("bLength %x\n", ConfigurationDescriptor->bLength); + DPRINT1("bDescriptorType %x\n", ConfigurationDescriptor->bDescriptorType); + DPRINT1("wTotalLength %x\n", ConfigurationDescriptor->wTotalLength); + DPRINT1("bNumInterfaces %x\n", ConfigurationDescriptor->bNumInterfaces); + DPRINT1("bConfigurationValue %x\n", ConfigurationDescriptor->bConfigurationValue); + DPRINT1("iConfiguration %x\n", ConfigurationDescriptor->iConfiguration); + DPRINT1("bmAttributes %x\n", ConfigurationDescriptor->bmAttributes); + DPRINT1("MaxPower %x\n", ConfigurationDescriptor->MaxPower); + + InterfaceDescriptor = (PUSB_INTERFACE_DESCRIPTOR) ((ULONG_PTR)ConfigurationDescriptor + sizeof(USB_CONFIGURATION_DESCRIPTOR)); + + for (i=0; i < ConfigurationDescriptor->bNumInterfaces; i++) + { + DPRINT1("- Dumping InterfaceDescriptor %x\n", InterfaceDescriptor); + DPRINT1(" bLength %x\n", InterfaceDescriptor->bLength); + DPRINT1(" bDescriptorType %x\n", InterfaceDescriptor->bDescriptorType); + DPRINT1(" bInterfaceNumber %x\n", InterfaceDescriptor->bInterfaceNumber); + DPRINT1(" bAlternateSetting %x\n", InterfaceDescriptor->bAlternateSetting); + DPRINT1(" bNumEndpoints %x\n", InterfaceDescriptor->bNumEndpoints); + DPRINT1(" bInterfaceClass %x\n", InterfaceDescriptor->bInterfaceClass); + DPRINT1(" bInterfaceSubClass %x\n", InterfaceDescriptor->bInterfaceSubClass); + DPRINT1(" bInterfaceProtocol %x\n", InterfaceDescriptor->bInterfaceProtocol); + DPRINT1(" iInterface %x\n", InterfaceDescriptor->iInterface); + + EndpointDescriptor = (PUSB_ENDPOINT_DESCRIPTOR) ((ULONG_PTR)InterfaceDescriptor + sizeof(USB_INTERFACE_DESCRIPTOR)); + + for (j=0; j < InterfaceDescriptor->bNumEndpoints; j++) + { + DPRINT1(" bLength %x\n", EndpointDescriptor->bLength); + DPRINT1(" bDescriptorType %x\n", EndpointDescriptor->bDescriptorType); + DPRINT1(" bEndpointAddress %x\n", EndpointDescriptor->bEndpointAddress); + DPRINT1(" bmAttributes %x\n", EndpointDescriptor->bmAttributes); + DPRINT1(" wMaxPacketSize %x\n", EndpointDescriptor->wMaxPacketSize); + DPRINT1(" bInterval %x\n", EndpointDescriptor->bInterval); + EndpointDescriptor = (PUSB_ENDPOINT_DESCRIPTOR) ((ULONG_PTR)EndpointDescriptor + sizeof(USB_ENDPOINT_DESCRIPTOR)); + } + InterfaceDescriptor = (PUSB_INTERFACE_DESCRIPTOR)(ULONG_PTR)EndpointDescriptor; + } + +} + +VOID +DumpQueueHead(PQUEUE_HEAD QueueHead) +{ + DPRINT1("Dumping QueueHead %x\n", QueueHead); + DPRINT1(" CurrentLinkPointer %x\n", QueueHead->CurrentLinkPointer); + DPRINT1(" NextPointer %x\n", QueueHead->NextPointer); + DPRINT1(" AlternateNextPointer %x\n", QueueHead->AlternateNextPointer); + DPRINT1(" HorizontalLinkPointer %x\n", QueueHead->HorizontalLinkPointer); + DPRINT1(" Active %x\n", QueueHead->Token.Bits.Active); + DPRINT1(" Halted %x\n", QueueHead->Token.Bits.Halted); + DPRINT1(" DataBufferError %x\n", QueueHead->Token.Bits.DataBufferError); + DPRINT1(" BabbleDetected %x\n", QueueHead->Token.Bits.BabbleDetected); + DPRINT1(" TransactionError %x\n", QueueHead->Token.Bits.TransactionError); + DPRINT1(" MissedMicroFrame %x\n", QueueHead->Token.Bits.MissedMicroFrame); + DPRINT1(" PingState %x\n", QueueHead->Token.Bits.PingState); + DPRINT1(" SplitTransactionState %x\n", QueueHead->Token.Bits.SplitTransactionState); + DPRINT1(" ErrorCounter %x\n", QueueHead->Token.Bits.ErrorCounter); + DPRINT1(" First TransferDescriptor %x\n", QueueHead->TransferDescriptor); +} + +VOID +DumpTransferDescriptor(PQUEUE_TRANSFER_DESCRIPTOR TransferDescriptor) +{ + DPRINT1("Dumping Descriptor %x\n", TransferDescriptor); + DPRINT1(" Active %x\n", TransferDescriptor->Token.Bits.Active); + DPRINT1(" Halted %x\n", TransferDescriptor->Token.Bits.Halted); + DPRINT1(" DataBufferError %x\n", TransferDescriptor->Token.Bits.DataBufferError); + DPRINT1(" BabbleDetected %x\n", TransferDescriptor->Token.Bits.BabbleDetected); + DPRINT1(" TransactionError %x\n", TransferDescriptor->Token.Bits.TransactionError); + DPRINT1(" MissedMicroFrame %x\n", TransferDescriptor->Token.Bits.MissedMicroFrame); + DPRINT1(" PingState %x\n", TransferDescriptor->Token.Bits.PingState); + DPRINT1(" SplitTransactionState %x\n", TransferDescriptor->Token.Bits.SplitTransactionState); + DPRINT1(" ErrorCounter %x\n", TransferDescriptor->Token.Bits.ErrorCounter); +} NTSTATUS NTAPI GetBusInterface(PDEVICE_OBJECT DeviceObject, PBUS_INTERFACE_STANDARD busInterface) diff --git a/reactos/drivers/usb/usbehci/usbehci.h b/reactos/drivers/usb/usbehci/usbehci.h index 5e85ad31948..111496ce18d 100644 --- a/reactos/drivers/usb/usbehci/usbehci.h +++ b/reactos/drivers/usb/usbehci/usbehci.h @@ -1,5 +1,6 @@ #pragma once +#include "hardware.h" #include #include #include @@ -15,68 +16,12 @@ #define DEVICESTARTED 0x02 #define DEVICEBUSY 0x04 #define DEVICESTOPPED 0x08 +#define DEVICESTALLED 0x10 #define MAX_USB_DEVICES 127 #define EHCI_MAX_SIZE_TRANSFER 0x100000 -/* USB Command Register */ -#define EHCI_USBCMD 0x00 -#define EHCI_USBSTS 0x04 -#define EHCI_USBINTR 0x08 -#define EHCI_FRINDEX 0x0C -#define EHCI_CTRLDSSEGMENT 0x10 -#define EHCI_PERIODICLISTBASE 0x14 -#define EHCI_ASYNCLISTBASE 0x18 -#define EHCI_CONFIGFLAG 0x40 -#define EHCI_PORTSC 0x44 - -/* USB Interrupt Register Flags 32 Bits */ -#define EHCI_USBINTR_INTE 0x01 -#define EHCI_USBINTR_ERR 0x02 -#define EHCI_USBINTR_PC 0x04 -#define EHCI_USBINTR_FLROVR 0x08 -#define EHCI_USBINTR_HSERR 0x10 -#define EHCI_USBINTR_ASYNC 0x20 -/* Bits 6:31 Reserved */ - -/* Status Register Flags 32 Bits */ -#define EHCI_STS_INT 0x01 -#define EHCI_STS_ERR 0x02 -#define EHCI_STS_PCD 0x04 -#define EHCI_STS_FLR 0x08 -#define EHCI_STS_FATAL 0x10 -#define EHCI_STS_IAA 0x20 -/* Bits 11:6 Reserved */ -#define EHCI_STS_HALT 0x1000 -#define EHCI_STS_RECL 0x2000 -#define EHCI_STS_PSS 0x4000 -#define EHCI_STS_ASS 0x8000 -#define EHCI_ERROR_INT ( EHCI_STS_FATAL | EHCI_STS_ERR ) - - -/* Last bit in QUEUE ELEMENT TRANSFER DESCRIPTOR Next Pointer */ -/* Used for Queue Element Transfer Descriptor Pointers - and Queue Head Horizontal Link Pointers */ -#define TERMINATE_POINTER 0x01 - -/* QUEUE ELEMENT TRANSFER DESCRIPTOR, Token defines and structs */ - -/* PIDCodes for QETD_TOKEN -OR with QUEUE_TRANSFER_DESCRIPTOR Token.PIDCode*/ -#define PID_CODE_OUT_TOKEN 0x00 -#define PID_CODE_IN_TOKEN 0x01 -#define PID_CODE_SETUP_TOKEN 0x02 - -/* Split Transaction States -OR with QUEUE_TRANSFER_DESCRIPTOR Token.SplitTransactionState */ -#define DO_START_SPLIT 0x00 -#define DO_COMPLETE_SPLIT 0x01 - -/* Ping States, OR with QUEUE_TRANSFER_DESCRIPTOR Token. */ -#define PING_STATE_DO_OUT 0x00 -#define PING_STATE_DO_PING 0x01 - #define C_HUB_LOCAL_POWER 0 #define C_HUB_OVER_CURRENT 1 #define PORT_CONNECTION 0 @@ -96,113 +41,6 @@ OR with QUEUE_TRANSFER_DESCRIPTOR Token.SplitTransactionState */ #define PORT_INDICATOR 22 #define USB_PORT_STATUS_CHANGE 0x4000 -/* QUEUE ELEMENT TRANSFER DESCRIPTOR TOKEN */ -typedef struct _QETD_TOKEN_BITS -{ - ULONG PingState:1; - ULONG SplitTransactionState:1; - ULONG MissedMicroFrame:1; - ULONG TransactionError:1; - ULONG BabbelDetected:1; - ULONG DataBufferError:1; - ULONG Halted:1; - ULONG Active:1; - ULONG PIDCode:2; - ULONG ErrorCounter:2; - ULONG CurrentPage:3; - ULONG InterruptOnComplete:1; - ULONG TotalBytesToTransfer:15; - ULONG DataToggle:1; -} QETD_TOKEN_BITS, *PQETD_TOKEN_BITS; - - -/* QUEUE ELEMENT TRANSFER DESCRIPTOR */ -typedef struct _QUEUE_TRANSFER_DESCRIPTOR -{ - ULONG NextPointer; - ULONG AlternateNextPointer; - union - { - QETD_TOKEN_BITS Bits; - ULONG DWord; - } Token; - ULONG BufferPointer[5]; -} QUEUE_TRANSFER_DESCRIPTOR, *PQUEUE_TRANSFER_DESCRIPTOR; - -/* EndPointSpeeds of END_POINT_CAPABILITIES */ -#define QH_ENDPOINT_FULLSPEED 0x00 -#define QH_ENDPOINT_LOWSPEED 0x01 -#define QH_ENDPOINT_HIGHSPEED 0x02 - -typedef struct _END_POINT_CAPABILITIES1 -{ - ULONG DeviceAddress:7; - ULONG InactiveOnNextTransaction:1; - ULONG EndPointNumber:4; - ULONG EndPointSpeed:2; - ULONG QEDTDataToggleControl:1; - ULONG HeadOfReclamation:1; - ULONG MaximumPacketLength:11; - ULONG ControlEndPointFlag:1; - ULONG NakCountReload:4; -} END_POINT_CAPABILITIES1, *PEND_POINT_CAPABILITIES1; - -typedef struct _END_POINT_CAPABILITIES2 -{ - ULONG InterruptScheduleMask:8; - ULONG SplitCompletionMask:8; - ULONG HubAddr:6; - ULONG PortNumber:6; - /* Multi */ - ULONG NumberOfTransactionPerFrame:2; -} END_POINT_CAPABILITIES2, *PEND_POINT_CAPABILITIES2; - - -/* QUEUE HEAD defines and structs */ - -/* QUEUE HEAD Select Types, OR with QUEUE_HEAD HorizontalLinkPointer */ -#define QH_TYPE_IDT 0x00 -#define QH_TYPE_QH 0x02 -#define QH_TYPE_SITD 0x04 -#define QH_TYPE_FSTN 0x06 - -/* QUEUE HEAD */ -typedef struct _QUEUE_HEAD -{ - ULONG HorizontalLinkPointer; - END_POINT_CAPABILITIES1 EndPointCapabilities1; - END_POINT_CAPABILITIES2 EndPointCapabilities2; - /* TERMINATE_POINTER not valid for this member */ - ULONG CurrentLinkPointer; - /* TERMINATE_POINTER valid */ - ULONG QETDPointer; - /* TERMINATE_POINTER valid, bits 1:4 is NAK_COUNTER */ - ULONG AlternateNextPointer; - /* Only DataToggle, InterruptOnComplete, ErrorCounter, PingState valid */ - union - { - QETD_TOKEN_BITS Bits; - ULONG DWord; - } Token; - ULONG BufferPointer[5]; -} QUEUE_HEAD, *PQUEUE_HEAD; - -typedef struct _EHCI_SETUP_FORMAT -{ - UCHAR bmRequestType; - UCHAR bRequest; - USHORT wValue; - USHORT wIndex; - USHORT wLength; -} EHCI_SETUP_FORMAT, *PEHCI_SETUP_FORMAT; - -typedef struct _STRING_DESCRIPTOR -{ - UCHAR bLength; /* Size of this descriptor in bytes */ - UCHAR bDescriptorType; /* STRING Descriptor Type */ - UCHAR bString[0]; /* UNICODE encoded string */ -} STRING_DESCRIPTOR, *PSTRING_DESCRIPTOR; - typedef struct _USB_ENDPOINT { ULONG Flags; @@ -234,102 +72,16 @@ typedef struct _USB_DEVICE USB_DEVICE_SPEED DeviceSpeed; USB_DEVICE_TYPE DeviceType; USB_DEVICE_DESCRIPTOR DeviceDescriptor; + UNICODE_STRING LanguageIDs; + UNICODE_STRING iManufacturer; + UNICODE_STRING iProduct; + UNICODE_STRING iSerialNumber; USB_CONFIGURATION *ActiveConfig; USB_INTERFACE *ActiveInterface; USB_CONFIGURATION **Configs; - } USB_DEVICE, *PUSB_DEVICE; -/* USBCMD register 32 bits */ -typedef struct _EHCI_USBCMD_CONTENT -{ - ULONG Run : 1; - ULONG HCReset : 1; - ULONG FrameListSize : 2; - ULONG PeriodicEnable : 1; - ULONG AsyncEnable : 1; - ULONG DoorBell : 1; - ULONG LightReset : 1; - ULONG AsyncParkCount : 2; - ULONG Reserved : 1; - ULONG AsyncParkEnable : 1; - ULONG Reserved1 : 4; - ULONG IntThreshold : 8; - ULONG Reserved2 : 8; -} EHCI_USBCMD_CONTENT, *PEHCI_USBCMD_CONTENT; - -typedef struct _EHCI_USBSTS_CONTENT -{ - ULONG USBInterrupt:1; - ULONG ErrorInterrupt:1; - ULONG DetectChangeInterrupt:1; - ULONG FrameListRolloverInterrupt:1; - ULONG HostSystemErrorInterrupt:1; - ULONG AsyncAdvanceInterrupt:1; - ULONG Reserved:6; - ULONG HCHalted:1; - ULONG Reclamation:1; - ULONG PeriodicScheduleStatus:1; - ULONG AsynchronousScheduleStatus:1; -} EHCI_USBSTS_CONTEXT, *PEHCI_USBSTS_CONTEXT; - -typedef struct _EHCI_USBPORTSC_CONTENT -{ - ULONG CurrentConnectStatus:1; - ULONG ConnectStatusChange:1; - ULONG PortEnabled:1; - ULONG PortEnableChanged:1; - ULONG OverCurrentActive:1; - ULONG OverCurrentChange:1; - ULONG ForcePortResume:1; - ULONG Suspend:1; - ULONG PortReset:1; - ULONG Reserved:1; - ULONG LineStatus:2; - ULONG PortPower:1; - ULONG PortOwner:1; -} EHCI_USBPORTSC_CONTENT, *PEHCI_USBPORTSC_CONTENT; - -typedef struct _EHCI_HCS_CONTENT -{ - ULONG PortCount : 4; - ULONG PortPowerControl: 1; - ULONG Reserved : 2; - ULONG PortRouteRules : 1; - ULONG PortPerCHC : 4; - ULONG CHCCount : 4; - ULONG PortIndicator : 1; - ULONG Reserved2 : 3; - ULONG DbgPortNum : 4; - ULONG Reserved3 : 8; - -} EHCI_HCS_CONTENT, *PEHCI_HCS_CONTENT; - -typedef struct _EHCI_HCC_CONTENT -{ - ULONG CurAddrBits : 1; - ULONG VarFrameList : 1; - ULONG ParkMode : 1; - ULONG Reserved : 1; - ULONG IsoSchedThreshold : 4; - ULONG EECPCapable : 8; - ULONG Reserved2 : 16; - -} EHCI_HCC_CONTENT, *PEHCI_HCC_CONTENT; - -typedef struct _EHCI_CAPS { - UCHAR Length; - UCHAR Reserved; - USHORT HCIVersion; - union - { - EHCI_HCS_CONTENT HCSParams; - ULONG HCSParamsLong; - }; - ULONG HCCParams; - UCHAR PortRoute [8]; -} EHCI_CAPS, *PEHCI_CAPS; typedef struct _COMMON_DEVICE_EXTENSION { @@ -380,26 +132,21 @@ typedef struct _FDO_DEVICE_EXTENSION BUS_INTERFACE_STANDARD BusInterface; - EHCI_CAPS ECHICaps; - union { - PULONG ResourcePort; - PULONG ResourceMemory; + ULONG ResourcePort; + ULONG ResourceMemory; }; - PULONG PeriodicFramList; - PULONG AsyncListQueueHeadPtr; - PHYSICAL_ADDRESS PeriodicFramListPhysAddr; - PHYSICAL_ADDRESS AsyncListQueueHeadPtrPhysAddr; - - FAST_MUTEX AsyncListMutex; + EHCI_HOST_CONTROLLER hcd; + PERIODICFRAMELIST PeriodicFrameList; + FAST_MUTEX FrameListMutex; BOOLEAN AsyncComplete; - PULONG ResourceBase; - ULONG Size; + //PULONG ResourceBase; + //ULONG Size; } FDO_DEVICE_EXTENSION, *PFDO_DEVICE_EXTENSION; typedef struct _PDO_DEVICE_EXTENSION @@ -425,6 +172,12 @@ typedef struct _PDO_DEVICE_EXTENSION FAST_MUTEX ListLock; } PDO_DEVICE_EXTENSION, *PPDO_DEVICE_EXTENSION; +typedef struct _WORKITEMDATA +{ + WORK_QUEUE_ITEM WorkItem; + PVOID Context; +} WORKITEMDATA, *PWORKITEMDATA; + VOID NTAPI UrbWorkerThread(PVOID Context); @@ -464,7 +217,7 @@ PdoDispatchInternalDeviceControl(PDEVICE_OBJECT DeviceObject, PIRP Irp); NTSTATUS NTAPI FdoDispatchInternalDeviceControl(PDEVICE_OBJECT DeviceObject, PIRP Irp); -BOOLEAN +USBD_STATUS ExecuteControlRequest(PFDO_DEVICE_EXTENSION DeviceExtension, PUSB_DEFAULT_PIPE_SETUP_PACKET SetupPacket, UCHAR Address, ULONG Port, PVOID Buffer, ULONG BufferLength); VOID @@ -485,5 +238,16 @@ HandleUrbRequest(PPDO_DEVICE_EXTENSION DeviceExtension, PIRP Irp); PUSB_DEVICE DeviceHandleToUsbDevice(PPDO_DEVICE_EXTENSION PdoDeviceExtension, PUSB_DEVICE_HANDLE DeviceHandle); -BOOLEAN -ResetPort(PFDO_DEVICE_EXTENSION FdoDeviceExtension, UCHAR Port); \ No newline at end of file +VOID +DumpDeviceDescriptor(PUSB_DEVICE_DESCRIPTOR DeviceDescriptor); + +VOID +DumpFullConfigurationDescriptor(PUSB_CONFIGURATION_DESCRIPTOR ConfigurationDescriptor); + + +VOID +DumpTransferDescriptor(PQUEUE_TRANSFER_DESCRIPTOR TransferDescriptor); + +VOID +DumpQueueHead(PQUEUE_HEAD QueueHead); + From f9a750c9c0b5023ed5cfb71913a285df1e642ed7 Mon Sep 17 00:00:00 2001 From: Roel Messiant Date: Fri, 31 Dec 2010 16:27:01 +0000 Subject: [PATCH 171/181] [UMPNPMGR] - Start using XP- and Vista-compatible pipe names for the RPC endpoint. Kick out the ROS-specific \pipe\umpnpmgr one. - Use only the Vista pipe name for now, using the XP one makes device installation fail.. - Use the correct PNP interface UUID [SETUPAPI] - Bind to the PNP service using the Vista-compatible pipe. svn path=/trunk/; revision=50242 --- reactos/base/services/umpnpmgr/umpnpmgr.c | 25 +++++++++++++++++++---- reactos/dll/win32/setupapi/rpc.c | 2 +- reactos/include/reactos/idl/pnp.idl | 2 +- 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/reactos/base/services/umpnpmgr/umpnpmgr.c b/reactos/base/services/umpnpmgr/umpnpmgr.c index 2352efe703f..dc4463c1949 100644 --- a/reactos/base/services/umpnpmgr/umpnpmgr.c +++ b/reactos/base/services/umpnpmgr/umpnpmgr.c @@ -94,20 +94,37 @@ static DWORD WINAPI RpcServerThread(LPVOID lpParameter) { RPC_STATUS Status; + BOOLEAN RegisteredProtSeq = FALSE; UNREFERENCED_PARAMETER(lpParameter); DPRINT("RpcServerThread() called\n"); +#if 0 + /* XP-compatible protocol sequence/endpoint */ Status = RpcServerUseProtseqEpW(L"ncacn_np", 20, - L"\\pipe\\umpnpmgr", + L"\\pipe\\ntsvcs", NULL); // Security descriptor - if (Status != RPC_S_OK) - { + if (Status == RPC_S_OK) + RegisteredProtSeq = TRUE; + else DPRINT1("RpcServerUseProtseqEpW() failed (Status %lx)\n", Status); +#endif + + /* Vista-compatible protocol sequence/endpoint */ + Status = RpcServerUseProtseqEpW(L"ncacn_np", + 20, + L"\\pipe\\plugplay", + NULL); // Security descriptor + if (Status == RPC_S_OK) + RegisteredProtSeq = TRUE; + else + DPRINT1("RpcServerUseProtseqEpW() failed (Status %lx)\n", Status); + + /* Make sure there's a usable endpoint */ + if (RegisteredProtSeq == FALSE) return 0; - } Status = RpcServerRegisterIf(pnp_v1_0_s_ifspec, NULL, diff --git a/reactos/dll/win32/setupapi/rpc.c b/reactos/dll/win32/setupapi/rpc.c index 3d55315ec6d..b4bce194f10 100644 --- a/reactos/dll/win32/setupapi/rpc.c +++ b/reactos/dll/win32/setupapi/rpc.c @@ -36,7 +36,7 @@ PnpBindRpc(LPCWSTR pszMachine, Status = RpcStringBindingComposeW(NULL, L"ncacn_np", (LPWSTR)pszMachine, - L"\\pipe\\umpnpmgr", + L"\\pipe\\plugplay", NULL, &pszStringBinding); if (Status != RPC_S_OK) diff --git a/reactos/include/reactos/idl/pnp.idl b/reactos/include/reactos/idl/pnp.idl index ff5f5cca14c..daef2a2b235 100644 --- a/reactos/include/reactos/idl/pnp.idl +++ b/reactos/include/reactos/idl/pnp.idl @@ -250,7 +250,7 @@ typedef struct _DEVPROPKEY { } DEVPROPKEY; [ - uuid (809F4e40-A03D-11CE-8F69-08003E30051B), + uuid (8D9F4E40-A03D-11CE-8F69-08003E30051B), version(1.0), pointer_default(unique) #ifndef __midl From 1f1bdb7dd4fed94067199004694ec78311c6f9f4 Mon Sep 17 00:00:00 2001 From: James Tabor Date: Fri, 31 Dec 2010 21:10:29 +0000 Subject: [PATCH 172/181] [User32] - Start creeping in more Left to Right support, readying up for the next wine User32 controls port and test sync. Code is based on wine, credit them for any breakages. 8^P Our positions are off by 103 x 122 in some test cases, anyone having an idea please chime in. svn path=/trunk/; revision=50247 --- reactos/dll/win32/user32/windows/winpos.c | 93 +++++++++++++++++------ 1 file changed, 70 insertions(+), 23 deletions(-) diff --git a/reactos/dll/win32/user32/windows/winpos.c b/reactos/dll/win32/user32/windows/winpos.c index 44a3371ff66..33d45f4b697 100644 --- a/reactos/dll/win32/user32/windows/winpos.c +++ b/reactos/dll/win32/user32/windows/winpos.c @@ -129,25 +129,66 @@ WindowFromPoint(POINT Point) int WINAPI MapWindowPoints(HWND hWndFrom, HWND hWndTo, LPPOINT lpPoints, UINT cPoints) { - PWND FromWnd, ToWnd; + PWND FromWnd = NULL, ToWnd = NULL; + BOOL mirror_from, mirror_to; POINT Delta; UINT i; - FromWnd = ValidateHwndOrDesk(hWndFrom); - if (!FromWnd) - return 0; + if (hWndFrom) + { + FromWnd = ValidateHwnd(hWndFrom); + if (!FromWnd) + return 0; + } + if (hWndTo) + { + ToWnd = ValidateHwnd(hWndTo); + if (!ToWnd) + return 0; + } - ToWnd = ValidateHwndOrDesk(hWndTo); - if (!ToWnd) - return 0; + /* Note: Desktop Top and Left is always 0! */ + Delta.x = Delta.y = 0; + mirror_from = mirror_to = FALSE; - Delta.x = FromWnd->rcClient.left - ToWnd->rcClient.left; - Delta.y = FromWnd->rcClient.top - ToWnd->rcClient.top; + if (FromWnd && FromWnd->fnid != FNID_DESKTOP) + { + if (FromWnd->ExStyle & WS_EX_LAYOUTRTL) + { + mirror_from = TRUE; + Delta.x = FromWnd->rcClient.right - FromWnd->rcClient.left; + } + else + Delta.x = FromWnd->rcClient.left; + Delta.y = FromWnd->rcClient.top; + } + + if (ToWnd && ToWnd->fnid != FNID_DESKTOP) + { + if (ToWnd->ExStyle & WS_EX_LAYOUTRTL) + { + mirror_to = TRUE; + Delta.x -= ToWnd->rcClient.right - ToWnd->rcClient.left; + } + else + Delta.x -= ToWnd->rcClient.left; + Delta.y -= ToWnd->rcClient.top; + } + + if (mirror_from) Delta.x = -Delta.x; for (i = 0; i != cPoints; i++) { lpPoints[i].x += Delta.x; lpPoints[i].y += Delta.y; + if (mirror_from || mirror_to) lpPoints[i].x = -lpPoints[i].x; + } + + if ((mirror_from || mirror_to) && cPoints == 2) /* special case for rectangle */ + { + int tmp = lpPoints[0].x; + lpPoints[0].x = lpPoints[1].x; + lpPoints[1].x = tmp; } return MAKELONG(LOWORD(Delta.x), LOWORD(Delta.y)); @@ -160,17 +201,20 @@ MapWindowPoints(HWND hWndFrom, HWND hWndTo, LPPOINT lpPoints, UINT cPoints) BOOL WINAPI ScreenToClient(HWND hWnd, LPPOINT lpPoint) { - PWND Wnd, DesktopWnd; - + PWND Wnd; + /* Note: Desktop Top and Left is always 0! */ Wnd = ValidateHwnd(hWnd); if (!Wnd) return FALSE; - DesktopWnd = GetThreadDesktopWnd(); - - lpPoint->x += DesktopWnd->rcClient.left - Wnd->rcClient.left; - lpPoint->y += DesktopWnd->rcClient.top - Wnd->rcClient.top; - + if (Wnd->fnid != FNID_DESKTOP) + { + if (Wnd->ExStyle & WS_EX_LAYOUTRTL) + lpPoint->x = Wnd->rcClient.right - lpPoint->x; + else + lpPoint->x -= Wnd->rcClient.left; + lpPoint->y -= Wnd->rcClient.top; + } return TRUE; } @@ -181,17 +225,20 @@ ScreenToClient(HWND hWnd, LPPOINT lpPoint) BOOL WINAPI ClientToScreen(HWND hWnd, LPPOINT lpPoint) { - PWND Wnd, DesktopWnd; - + PWND Wnd; + /* Note: Desktop Top and Left is always 0! */ Wnd = ValidateHwnd(hWnd); if (!Wnd) return FALSE; - DesktopWnd = GetThreadDesktopWnd(); - - lpPoint->x += Wnd->rcClient.left - DesktopWnd->rcClient.left; - lpPoint->y += Wnd->rcClient.top - DesktopWnd->rcClient.top; - + if (Wnd->fnid != FNID_DESKTOP) + { + if (Wnd->ExStyle & WS_EX_LAYOUTRTL) + lpPoint->x = Wnd->rcClient.right - lpPoint->x; + else + lpPoint->x += Wnd->rcClient.left; + lpPoint->y += Wnd->rcClient.top; + } return TRUE; } From 46fe11727acffbcd44d3960374b72d73e305206f Mon Sep 17 00:00:00 2001 From: Aleksey Bragin Date: Fri, 31 Dec 2010 23:06:19 +0000 Subject: [PATCH 173/181] Happy New Year! Dear ReactOS team, you're the best. svn path=/trunk/; revision=50248 --- reactos/media/doc/apc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reactos/media/doc/apc b/reactos/media/doc/apc index 795ae835d25..dd5b39892ae 100644 --- a/reactos/media/doc/apc +++ b/reactos/media/doc/apc @@ -33,4 +33,4 @@ access the virtual address space of the thread/process, and the most efficient way to complete the operation is to be in the calling threads context. - + From 7996ddf5cc56dcc555165d8d707537eb7c2a2d84 Mon Sep 17 00:00:00 2001 From: Michael Martin Date: Sat, 1 Jan 2011 12:20:19 +0000 Subject: [PATCH 174/181] [usb/usbehci]: - Remove all hardware related routines from fdo.c as they are now in hardware.c - Replace ExecuteControlRequest with new SubmitControlTransfer. - For internal control requests (originating from ehci driver) use an event to signal request completion. - When submitting non internal control request save the Irp in the software part of the QueueHead. For these requests check for errors and complete the Irp with the appropriate URB Status when the QueueHead is complete. - Misc code cleanup and dead code removal. - UsbEhci now works as before and should be ready for some forward progress. svn path=/trunk/; revision=50249 --- reactos/drivers/usb/usbehci/fdo.c | 623 ++++++++------------- reactos/drivers/usb/usbehci/irp.c | 146 +++-- reactos/drivers/usb/usbehci/pdo.c | 51 +- reactos/drivers/usb/usbehci/urbreq.c | 216 ------- reactos/drivers/usb/usbehci/usbehci.c | 1 - reactos/drivers/usb/usbehci/usbehci.rbuild | 5 +- reactos/drivers/usb/usbehci/usbiffn.c | 144 ++--- 7 files changed, 432 insertions(+), 754 deletions(-) delete mode 100644 reactos/drivers/usb/usbehci/urbreq.c diff --git a/reactos/drivers/usb/usbehci/fdo.c b/reactos/drivers/usb/usbehci/fdo.c index 29cf7fad77a..1886f4ae119 100644 --- a/reactos/drivers/usb/usbehci/fdo.c +++ b/reactos/drivers/usb/usbehci/fdo.c @@ -7,38 +7,11 @@ * Michael Martin (michael.martin@reactos.org) */ -/* INCLUDES *******************************************************************/ +#include "hwiface.h" #include "usbehci.h" +#include "physmem.h" #include -VOID NTAPI -TimerDefferedRoutine(PKDPC Dpc, PVOID DeferredContext, PVOID SystemArgument1, PVOID SystemArgument2) -{ - PFDO_DEVICE_EXTENSION FdoDeviceExtension; - PPDO_DEVICE_EXTENSION PdoDeviceExtension; - ULONG tmp; - ULONG Base; - LONG i; - - FdoDeviceExtension = (PFDO_DEVICE_EXTENSION) DeferredContext; - PdoDeviceExtension = (PPDO_DEVICE_EXTENSION) FdoDeviceExtension->Pdo->DeviceExtension; - - Base = (ULONG)FdoDeviceExtension->ResourceMemory; - - for (i = 0; i < FdoDeviceExtension->ECHICaps.HCSParams.PortCount; i++) - { - tmp = READ_REGISTER_ULONG((PULONG) ((Base + EHCI_PORTSC) + (4 * i))); - - if ((tmp & 0x04) && (!(PdoDeviceExtension->Ports[i].PortChange & USB_PORT_STATUS_RESET))) - { - DPRINT("Port %x is enabled\n", i); - PdoDeviceExtension->Ports[i].PortChange |= USB_PORT_STATUS_RESET; - CompletePendingURBRequest(PdoDeviceExtension); - } - } - return; -} - VOID NTAPI EhciDefferedRoutine(PKDPC Dpc, PVOID DeferredContext, PVOID SystemArgument1, PVOID SystemArgument2) { @@ -46,7 +19,8 @@ EhciDefferedRoutine(PKDPC Dpc, PVOID DeferredContext, PVOID SystemArgument1, PVO PPDO_DEVICE_EXTENSION PdoDeviceExtension; ULONG CStatus; ULONG tmp; - ULONG Base; + ULONG OpRegisters; + PEHCI_HOST_CONTROLLER hcd; LONG i; FdoDeviceExtension = (PFDO_DEVICE_EXTENSION) DeferredContext; @@ -59,17 +33,122 @@ EhciDefferedRoutine(PKDPC Dpc, PVOID DeferredContext, PVOID SystemArgument1, PVO PdoDeviceExtension = (PPDO_DEVICE_EXTENSION) FdoDeviceExtension->Pdo->DeviceExtension; - Base = (ULONG)FdoDeviceExtension->ResourceMemory; + OpRegisters = (ULONG)FdoDeviceExtension->hcd.OpRegisters; + hcd = &FdoDeviceExtension->hcd; + CStatus = (ULONG) SystemArgument2; + + /* TD retired or Error */ + if (CStatus & (EHCI_STS_INT | EHCI_ERROR_INT)) + { + DPRINT("Asyn Complete!\n"); + ULONG CurrentAddr, OffSet; + PQUEUE_HEAD CompletedQH, NextQH; + PQUEUE_TRANSFER_DESCRIPTOR CompletedTD; + + /* AsyncListAddr Register will have the next QueueHead to execute */ + CurrentAddr = GetAsyncListQueueRegister(hcd); + + /* Calculate the VA for the next QueueHead */ + OffSet = CurrentAddr - (ULONG)FdoDeviceExtension->hcd.CommonBufferPA.LowPart; + NextQH = (PQUEUE_HEAD)((ULONG)FdoDeviceExtension->hcd.CommonBufferVA + OffSet); + + /* Get the previous QueueHead which is the QueueHead just completed */ + CompletedQH = NextQH->PreviousQueueHead; + ASSERT(CompletedQH); + DPRINT("CompletedQH %x\n", CompletedQH); + + //DumpQueueHead(CompletedQH); + + /* Free memory for the Descriptors */ + CompletedTD = CompletedQH->TransferDescriptor; + //DumpTransferDescriptor(CompletedTD); + FreeDescriptor(CompletedTD); + CompletedTD = CompletedTD->NextDescriptor; + //DumpTransferDescriptor(CompletedTD); + FreeDescriptor(CompletedTD); + CompletedTD = CompletedTD->NextDescriptor; + //DumpTransferDescriptor(CompletedTD); + FreeDescriptor(CompletedTD); + + /* If the Event is set then release waiter */ + if (CompletedQH->Event) + { + KeSetEvent(CompletedQH->Event, IO_NO_INCREMENT, FALSE); + } + + /* Free the Mdl */ + ASSERT(CompletedQH->MdlToFree); + IoFreeMdl(CompletedQH->MdlToFree); + + /* Is there an IRP that needs to be completed */ + if (CompletedQH->IrpToComplete) + { + PIRP Irp; + + Irp = CompletedQH->IrpToComplete; + + /* Check for error */ + if (CStatus & EHCI_ERROR_INT) + { + PIO_STACK_LOCATION Stack; + PURB Urb; + + Stack = IoGetCurrentIrpStackLocation(Irp); + ASSERT(Stack); + Urb = (PURB) Stack->Parameters.Others.Argument1; + ASSERT(FALSE); + /* Haled bit should be set */ + if (CompletedQH->Token.Bits.Halted) + { + if (CompletedQH->Token.Bits.DataBufferError) + { + DPRINT1("Data buffer error\n"); + Urb->UrbHeader.Status = USBD_STATUS_DATA_BUFFER_ERROR; + Irp->IoStatus.Status = STATUS_UNSUCCESSFUL; + Irp->IoStatus.Information = 0; + } + else if (CompletedQH->Token.Bits.BabbleDetected) + { + DPRINT1("Babble Detected\n"); + Urb->UrbHeader.Status = USBD_STATUS_BABBLE_DETECTED; + Irp->IoStatus.Status = STATUS_UNSUCCESSFUL; + Irp->IoStatus.Information = 0; + } + else + { + DPRINT1("Stall PID\n"); + Urb->UrbHeader.Status = USBD_STATUS_STALL_PID; + Irp->IoStatus.Status = STATUS_UNSUCCESSFUL; + Irp->IoStatus.Information = 0; + } + } + } + else + { + Irp->IoStatus.Status = STATUS_SUCCESS; + Irp->IoStatus.Information = 0; + DPRINT1("Completing Irp\n"); + + } + IoCompleteRequest(Irp, IO_NO_INCREMENT); + } + + /* Unlink QueueHead */ + UnlinkQueueHead(hcd, CompletedQH); + /* Wait for a complete AsnycList tranversal before deleting? */ + DeleteQueueHead(CompletedQH); + } + /* Port Change */ if (CStatus & EHCI_STS_PCD) { /* Loop through the ports */ - for (i = 0; i < FdoDeviceExtension->ECHICaps.HCSParams.PortCount; i++) + for (i = 0; i < FdoDeviceExtension->hcd.ECHICaps.HCSParams.PortCount; i++) { - tmp = READ_REGISTER_ULONG((PULONG) ((Base + EHCI_PORTSC) + (4 * i))); + tmp = READ_REGISTER_ULONG((PULONG) ((OpRegisters + EHCI_PORTSC) + (4 * i))); /* Check for port change on this port */ if (tmp & 0x02) @@ -80,9 +159,9 @@ EhciDefferedRoutine(PKDPC Dpc, PVOID DeferredContext, PVOID SystemArgument1, PVO DPRINT1("Device connected on port %d\n", i); /* Check if a companion host controller exists */ - if (FdoDeviceExtension->ECHICaps.HCSParams.CHCCount) + if (FdoDeviceExtension->hcd.ECHICaps.HCSParams.CHCCount) { - tmp = READ_REGISTER_ULONG((PULONG)((Base + EHCI_PORTSC) + (4 * i))); + tmp = READ_REGISTER_ULONG((PULONG)((OpRegisters + EHCI_PORTSC) + (4 * i))); /* Port should be in disabled state, as per USB 2.0 specs */ if (tmp & 0x04) @@ -93,9 +172,9 @@ EhciDefferedRoutine(PKDPC Dpc, PVOID DeferredContext, PVOID SystemArgument1, PVO /* Is this non high speed device */ if (tmp & 0x400) { - DPRINT1("Releasing ownership to companion host controller!\n"); + DPRINT1("Non HighSpeed device connected. Releasing ownership.\n"); /* Release ownership to companion host controller */ - WRITE_REGISTER_ULONG((PULONG) ((Base + EHCI_PORTSC) + (4 * i)), 0x4000); + WRITE_REGISTER_ULONG((PULONG) ((OpRegisters + EHCI_PORTSC) + (4 * i)), 0x2000); continue; } } @@ -111,13 +190,14 @@ EhciDefferedRoutine(PKDPC Dpc, PVOID DeferredContext, PVOID SystemArgument1, PVO //KeStallExecutionProcessor(20); - tmp = READ_REGISTER_ULONG((PULONG)((Base + EHCI_PORTSC) + (4 * i))); + tmp = READ_REGISTER_ULONG((PULONG)((OpRegisters + EHCI_PORTSC) + (4 * i))); PdoDeviceExtension->ChildDeviceCount++; PdoDeviceExtension->Ports[i].PortStatus &= ~0x8000; + PdoDeviceExtension->Ports[i].PortStatus |= USB_PORT_STATUS_HIGH_SPEED; PdoDeviceExtension->Ports[i].PortStatus |= USB_PORT_STATUS_CONNECT; PdoDeviceExtension->Ports[i].PortChange |= USB_PORT_STATUS_CONNECT; - + DPRINT1("Completing URB\n"); CompletePendingURBRequest(PdoDeviceExtension); } else @@ -125,13 +205,19 @@ EhciDefferedRoutine(PKDPC Dpc, PVOID DeferredContext, PVOID SystemArgument1, PVO DPRINT1("Device disconnected on port %d\n", i); /* Clear status change */ - tmp = READ_REGISTER_ULONG((PULONG)((Base + EHCI_PORTSC) + (4 * i))); + tmp = READ_REGISTER_ULONG((PULONG)((OpRegisters + EHCI_PORTSC) + (4 * i))); tmp |= 0x02; - WRITE_REGISTER_ULONG((PULONG) ((Base + EHCI_PORTSC) + (4 * i)), tmp); + WRITE_REGISTER_ULONG((PULONG) ((OpRegisters + EHCI_PORTSC) + (4 * i)), tmp); } } } } + + /* Asnyc Advance */ + if (CStatus & EHCI_STS_IAA) + { + DPRINT1("Async Advance!\n"); + } } BOOLEAN NTAPI @@ -139,17 +225,15 @@ InterruptService(PKINTERRUPT Interrupt, PVOID ServiceContext) { PFDO_DEVICE_EXTENSION FdoDeviceExtension; PDEVICE_OBJECT DeviceObject = (PDEVICE_OBJECT) ServiceContext; - ULONG CurrentFrame; - ULONG Base; + PEHCI_HOST_CONTROLLER hcd; ULONG CStatus = 0; FdoDeviceExtension = (PFDO_DEVICE_EXTENSION) DeviceObject->DeviceExtension; - Base = (ULONG)FdoDeviceExtension->ResourceMemory; + hcd = &FdoDeviceExtension->hcd; /* Read device status */ - CStatus = READ_REGISTER_ULONG ((PULONG) (Base + EHCI_USBSTS)); - CurrentFrame = READ_REGISTER_ULONG((PULONG) (Base + EHCI_FRINDEX)); + CStatus = ReadControllerStatus(hcd); CStatus &= (EHCI_ERROR_INT | EHCI_STS_INT | EHCI_STS_IAA | EHCI_STS_PCD | EHCI_STS_FLR); @@ -158,9 +242,9 @@ InterruptService(PKINTERRUPT Interrupt, PVOID ServiceContext) /* This interrupt isnt for us or not ready for it. */ return FALSE; } - + /* Clear status */ - WRITE_REGISTER_ULONG((PULONG) (Base + EHCI_USBSTS), CStatus); + ClearControllerStatus(hcd, CStatus); if (CStatus & EHCI_ERROR_INT) { @@ -179,239 +263,10 @@ InterruptService(PKINTERRUPT Interrupt, PVOID ServiceContext) /* FIXME: Reset the controller */ } - if (CStatus & EHCI_STS_INT) - { - FdoDeviceExtension->AsyncComplete = TRUE; - } - KeInsertQueueDpc(&FdoDeviceExtension->DpcObject, FdoDeviceExtension, (PVOID)CStatus); - return TRUE; } -BOOLEAN -ResetPort(PFDO_DEVICE_EXTENSION FdoDeviceExtension, UCHAR Port) -{ - ULONG Base; - ULONG tmp; - LARGE_INTEGER DueTime; - - DPRINT("Reset Port %x\n", Port); - - Base = (ULONG)FdoDeviceExtension->ResourceMemory; - - tmp = READ_REGISTER_ULONG((PULONG) ((Base + EHCI_PORTSC) + (4 * Port))); - tmp |= 0x100; - WRITE_REGISTER_ULONG((PULONG) ((Base + EHCI_PORTSC) + (4 * Port)), tmp); - - DueTime.QuadPart = -100; - - KeSetTimerEx(&FdoDeviceExtension->UpdateTimer, DueTime, 0, &FdoDeviceExtension->TimerDpcObject); - return TRUE; -} - -VOID -StopEhci(PDEVICE_OBJECT DeviceObject) -{ - PFDO_DEVICE_EXTENSION FdoDeviceExtension; - PEHCI_USBCMD_CONTENT UsbCmd; - ULONG base; - LONG tmp; - - DPRINT("Stopping Ehci controller\n"); - FdoDeviceExtension = (PFDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension; - base = (ULONG)FdoDeviceExtension->ResourceMemory; - - WRITE_REGISTER_ULONG((PULONG) (base + EHCI_USBINTR), 0); - - tmp = READ_REGISTER_ULONG((PULONG) (base + EHCI_USBCMD)); - UsbCmd = (PEHCI_USBCMD_CONTENT) & tmp; - UsbCmd->Run = 0; - WRITE_REGISTER_ULONG((PULONG) (base + EHCI_USBCMD), tmp); -} - -VOID -StartEhci(PDEVICE_OBJECT DeviceObject) -{ - PFDO_DEVICE_EXTENSION FdoDeviceExtension; - PEHCI_USBCMD_CONTENT UsbCmd; - PEHCI_USBSTS_CONTEXT usbsts; - NTSTATUS Status; - LONG tmp; - LONG tmp2; - ULONG base; - - DPRINT("Starting Ehci controller\n"); - FdoDeviceExtension = (PFDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension; - base = (ULONG)FdoDeviceExtension->ResourceMemory; - - tmp = READ_REGISTER_ULONG ((PULONG)(base + EHCI_USBCMD)); - - /* Stop the device */ - UsbCmd = (PEHCI_USBCMD_CONTENT) &tmp; - UsbCmd->Run = 0; - WRITE_REGISTER_ULONG ((PULONG)(base + EHCI_USBCMD), tmp); - - /* Wait for the device to stop */ - for (;;) - { - KeStallExecutionProcessor(10); - tmp = READ_REGISTER_ULONG((PULONG)(base + EHCI_USBSTS)); - usbsts = (PEHCI_USBSTS_CONTEXT)&tmp; - - if (usbsts->HCHalted) - { - break; - } - DPRINT("Waiting for Halt, USBSTS: %x\n", READ_REGISTER_ULONG ((PULONG)(base + EHCI_USBSTS))); - } - - tmp = READ_REGISTER_ULONG ((PULONG)(base + EHCI_USBCMD)); - - /* Reset the device */ - UsbCmd = (PEHCI_USBCMD_CONTENT) &tmp; - UsbCmd->HCReset = TRUE; - WRITE_REGISTER_ULONG ((PULONG)(base + EHCI_USBCMD), tmp); - - /* Wait for the device to reset */ - for (;;) - { - KeStallExecutionProcessor(10); - tmp = READ_REGISTER_ULONG((PULONG)(base + EHCI_USBCMD)); - UsbCmd = (PEHCI_USBCMD_CONTENT)&tmp; - - if (!UsbCmd->HCReset) - { - break; - } - DPRINT("Waiting for reset, USBCMD: %x\n", READ_REGISTER_ULONG ((PULONG)(base + EHCI_USBCMD))); - } - - UsbCmd = (PEHCI_USBCMD_CONTENT) &tmp; - - /* Disable Interrupts on the device */ - WRITE_REGISTER_ULONG((PULONG)(base + EHCI_USBINTR), 0); - /* Clear the Status */ - WRITE_REGISTER_ULONG((PULONG)(base + EHCI_USBSTS), 0x0000001f); - - WRITE_REGISTER_ULONG((PULONG)(base + EHCI_CTRLDSSEGMENT), 0); - - /* Set the Periodic Frame List */ - WRITE_REGISTER_ULONG((PULONG)(base + EHCI_PERIODICLISTBASE), FdoDeviceExtension->PeriodicFramListPhysAddr.LowPart); - /* Set the Async List Queue */ - WRITE_REGISTER_ULONG((PULONG) (base + EHCI_ASYNCLISTBASE), FdoDeviceExtension->AsyncListQueueHeadPtrPhysAddr.LowPart & ~(0x1f)); - - /* Set the ansync and periodic to disable */ - UsbCmd->PeriodicEnable = 0; - UsbCmd->AsyncEnable = 0; - WRITE_REGISTER_ULONG((PULONG)(base + EHCI_USBCMD), tmp); - - /* Set the threshold */ - UsbCmd->IntThreshold = 1; - WRITE_REGISTER_ULONG((PULONG)(base + EHCI_USBCMD), tmp); - - KeInitializeDpc(&FdoDeviceExtension->DpcObject, - EhciDefferedRoutine, - FdoDeviceExtension); - - KeInitializeDpc(&FdoDeviceExtension->TimerDpcObject, - TimerDefferedRoutine, - FdoDeviceExtension); - - - Status = IoConnectInterrupt(&FdoDeviceExtension->EhciInterrupt, - InterruptService, - FdoDeviceExtension->DeviceObject, - NULL, - FdoDeviceExtension->Vector, - FdoDeviceExtension->Irql, - FdoDeviceExtension->Irql, - FdoDeviceExtension->Mode, - FdoDeviceExtension->IrqShared, - FdoDeviceExtension->Affinity, - FALSE); - - /* Turn back on interrupts */ - WRITE_REGISTER_ULONG((PULONG)(base + EHCI_USBINTR), - EHCI_USBINTR_ERR | EHCI_USBINTR_ASYNC | EHCI_USBINTR_HSERR - | EHCI_USBINTR_FLROVR | EHCI_USBINTR_PC); - WRITE_REGISTER_ULONG((PULONG)(base + EHCI_USBINTR), - EHCI_USBINTR_INTE | EHCI_USBINTR_ERR | EHCI_USBINTR_ASYNC | EHCI_USBINTR_HSERR - | EHCI_USBINTR_FLROVR | EHCI_USBINTR_PC); - - UsbCmd->Run = 1; - WRITE_REGISTER_ULONG((PULONG)(base + EHCI_USBCMD), tmp); - - /* Wait for the device to start */ - for (;;) - { - KeStallExecutionProcessor(10); - tmp2 = READ_REGISTER_ULONG((PULONG)(base + EHCI_USBSTS)); - usbsts = (PEHCI_USBSTS_CONTEXT)&tmp2; - - if (!usbsts->HCHalted) - { - break; - } - DPRINT("Waiting for start, USBSTS: %x\n", READ_REGISTER_ULONG ((PULONG)(base + EHCI_USBSTS))); - } - - /* Set all port routing to ECHI controller */ - WRITE_REGISTER_ULONG((PULONG)(base + EHCI_CONFIGFLAG), 1); -} - -VOID -GetCapabilities(PFDO_DEVICE_EXTENSION DeviceExtension, ULONG Base) -{ - PEHCI_CAPS PCap; - PEHCI_HCS_CONTENT PHCS; - LONG i; - - if (!DeviceExtension) - return; - - PCap = &DeviceExtension->ECHICaps; - - PCap->Length = READ_REGISTER_UCHAR((PUCHAR)Base); - PCap->Reserved = READ_REGISTER_UCHAR((PUCHAR)(Base + 1)); - PCap->HCIVersion = READ_REGISTER_USHORT((PUSHORT)(Base + 2)); - PCap->HCSParamsLong = READ_REGISTER_ULONG((PULONG)(Base + 4)); - PCap->HCCParams = READ_REGISTER_ULONG((PULONG)(Base + 8)); - - DPRINT("Length %d\n", PCap->Length); - DPRINT("Reserved %d\n", PCap->Reserved); - DPRINT("HCIVersion %x\n", PCap->HCIVersion); - DPRINT("HCSParams %x\n", PCap->HCSParamsLong); - DPRINT("HCCParams %x\n", PCap->HCCParams); - - if (PCap->HCCParams & 0x02) - DPRINT1("Frame list size is configurable\n"); - - if (PCap->HCCParams & 0x01) - DPRINT1("64bit address mode not supported!\n"); - - DPRINT1("Number of Ports: %d\n", PCap->HCSParams.PortCount); - - if (PCap->HCSParams.PortPowerControl) - DPRINT1("Port Power Control is enabled\n"); - - if (!PCap->HCSParams.CHCCount) - { - DPRINT1("Number of Companion Host controllers %x\n", PCap->HCSParams.CHCCount); - DPRINT1("Number of Ports Per CHC: %d\n", PCap->HCSParams.PortPerCHC); - } - - /* Copied from USBDRIVER in trunk */ - PHCS = (PEHCI_HCS_CONTENT)&DeviceExtension->ECHICaps.HCSParams; - if (PHCS->PortRouteRules) - { - for (i = 0; i < PCap->HCSParams.PortCount; i++) - { - PCap->PortRoute[i] = READ_REGISTER_UCHAR((PUCHAR) (Base + 12 + i)); - } - } -} - NTSTATUS StartDevice(PDEVICE_OBJECT DeviceObject, PCM_PARTIAL_RESOURCE_LIST raw, PCM_PARTIAL_RESOURCE_LIST translated) { @@ -427,62 +282,6 @@ StartDevice(PDEVICE_OBJECT DeviceObject, PCM_PARTIAL_RESOURCE_LIST raw, PCM_PART FdoDeviceExtension = (PFDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension; - RtlZeroMemory(&DeviceDescription, sizeof(DEVICE_DESCRIPTION)); - DeviceDescription.Version = DEVICE_DESCRIPTION_VERSION; - DeviceDescription.Master = TRUE; - DeviceDescription.ScatterGather = TRUE; - DeviceDescription.Dma32BitAddresses = TRUE; - DeviceDescription.DmaWidth = 2; - DeviceDescription.InterfaceType = PCIBus; - DeviceDescription.MaximumLength = EHCI_MAX_SIZE_TRANSFER; - - FdoDeviceExtension->pDmaAdapter = IoGetDmaAdapter(FdoDeviceExtension->LowerDevice, - &DeviceDescription, - &FdoDeviceExtension->MapRegisters); - - if (FdoDeviceExtension->pDmaAdapter == NULL) - { - DPRINT1("IoGetDmaAdapter failed!\n"); - ASSERT(FALSE); - } - - /* Allocate Common Buffer for Periodic Frame List */ - FdoDeviceExtension->PeriodicFramList = - FdoDeviceExtension->pDmaAdapter->DmaOperations->AllocateCommonBuffer(FdoDeviceExtension->pDmaAdapter, - sizeof(ULONG) * 1024, &FdoDeviceExtension->PeriodicFramListPhysAddr, FALSE); - - if (FdoDeviceExtension->PeriodicFramList == NULL) - { - DPRINT1("FdoDeviceExtension->PeriodicFramList is null\n"); - return STATUS_UNSUCCESSFUL; - } - - /* Zeroize it */ - RtlZeroMemory(FdoDeviceExtension->PeriodicFramList, sizeof(ULONG) * 1024); - - ExInitializeFastMutex(&FdoDeviceExtension->FrameListMutex); - - /* Allocate Common Buffer for Async List Head Queue */ - FdoDeviceExtension->AsyncListQueueHeadPtr = - FdoDeviceExtension->pDmaAdapter->DmaOperations->AllocateCommonBuffer(FdoDeviceExtension->pDmaAdapter, - /* FIXME: Memory Size should be calculated using - structures sizes needed for queue head + 20480 (max data transfer */ - 20800, - &FdoDeviceExtension->AsyncListQueueHeadPtrPhysAddr, FALSE); - - if (FdoDeviceExtension->AsyncListQueueHeadPtr == NULL) - { - DPRINT1("Failed to allocate common buffer for AsyncListQueueHeadPtr!\n"); - return STATUS_UNSUCCESSFUL; - } - - /* Zeroize it */ - RtlZeroMemory(FdoDeviceExtension->AsyncListQueueHeadPtr, - /* FIXME: Same as FIXME above */ - 20800); - - ExInitializeFastMutex(&FdoDeviceExtension->AsyncListMutex); - Status = IoGetDeviceProperty(FdoDeviceExtension->LowerDevice, DevicePropertyAddress, sizeof(ULONG), @@ -531,26 +330,21 @@ StartDevice(PDEVICE_OBJECT DeviceObject, PCM_PARTIAL_RESOURCE_LIST raw, PCM_PART } case CmResourceTypeMemory: { - ULONG ResourceBase = 0; - ULONG MemLength; + PVOID ResourceBase = 0; DPRINT("Mem Start: %x\n", resource->u.Memory.Start); DPRINT("Mem Length: %d\n", resource->u.Memory.Length); - ResourceBase = (ULONG) MmMapIoSpace(resource->u.Memory.Start, resource->u.Memory.Length, FALSE); + ResourceBase = MmMapIoSpace(resource->u.Memory.Start, resource->u.Memory.Length, FALSE); DPRINT("ResourceBase %x\n", ResourceBase); - - FdoDeviceExtension->ResourceBase = (PULONG) ResourceBase; - GetCapabilities(FdoDeviceExtension, (ULONG)ResourceBase); - FdoDeviceExtension->ResourceMemory = (PULONG)((ULONG)ResourceBase + FdoDeviceExtension->ECHICaps.Length); - DPRINT("ResourceMemory %x\n", FdoDeviceExtension->ResourceMemory); - if (FdoDeviceExtension->ResourceBase == NULL) + if (ResourceBase == NULL) { DPRINT1("MmMapIoSpace failed!!!!!!!!!\n"); } - MemLength = resource->u.Memory.Length; - FdoDeviceExtension->Size = MemLength; + GetCapabilities(&FdoDeviceExtension->hcd.ECHICaps, (ULONG)ResourceBase); + DPRINT1("hcd.ECHICaps.Length %x\n", FdoDeviceExtension->hcd.ECHICaps.Length); + FdoDeviceExtension->hcd.OpRegisters = (ULONG)((ULONG)ResourceBase + FdoDeviceExtension->hcd.ECHICaps.Length); break; } case CmResourceTypeDma: @@ -573,7 +367,90 @@ StartDevice(PDEVICE_OBJECT DeviceObject, PCM_PARTIAL_RESOURCE_LIST raw, PCM_PART } } - StartEhci(DeviceObject); + KeInitializeDpc(&FdoDeviceExtension->DpcObject, + EhciDefferedRoutine, + FdoDeviceExtension); + + RtlZeroMemory(&DeviceDescription, sizeof(DEVICE_DESCRIPTION)); + DeviceDescription.Version = DEVICE_DESCRIPTION_VERSION; + DeviceDescription.Master = TRUE; + DeviceDescription.ScatterGather = TRUE; + DeviceDescription.Dma32BitAddresses = TRUE; + DeviceDescription.DmaWidth = 2; + DeviceDescription.InterfaceType = PCIBus; + DeviceDescription.MaximumLength = EHCI_MAX_SIZE_TRANSFER; + + FdoDeviceExtension->pDmaAdapter = IoGetDmaAdapter(FdoDeviceExtension->LowerDevice, + &DeviceDescription, + &FdoDeviceExtension->MapRegisters); + + if (FdoDeviceExtension->pDmaAdapter == NULL) + { + DPRINT1("Ehci: IoGetDmaAdapter failed!\n"); + ASSERT(FALSE); + } + + /* Allocate Common Buffer for Periodic Frame List */ + FdoDeviceExtension->PeriodicFrameList.VirtualAddr = + FdoDeviceExtension->pDmaAdapter->DmaOperations->AllocateCommonBuffer(FdoDeviceExtension->pDmaAdapter, + sizeof(ULONG) * 1024, &FdoDeviceExtension->PeriodicFrameList.PhysicalAddr, FALSE); + + if (FdoDeviceExtension->PeriodicFrameList.VirtualAddr == NULL) + { + DPRINT1("Ehci: FdoDeviceExtension->PeriodicFramList is null\n"); + return STATUS_UNSUCCESSFUL; + } + + /* Zeroize it */ + RtlZeroMemory(FdoDeviceExtension->PeriodicFrameList.VirtualAddr, sizeof(ULONG) * 1024); + + ExInitializeFastMutex(&FdoDeviceExtension->FrameListMutex); + + /* Allocate pages for queueheads and descriptors */ + FdoDeviceExtension->hcd.CommonBufferVA = + FdoDeviceExtension->pDmaAdapter->DmaOperations->AllocateCommonBuffer(FdoDeviceExtension->pDmaAdapter, + PAGE_SIZE * 16, + &FdoDeviceExtension->hcd.CommonBufferPA, + FALSE); + + if (FdoDeviceExtension->hcd.CommonBufferVA == 0) + { + DPRINT1("Ehci: Failed to allocate common buffer!\n"); + return STATUS_UNSUCCESSFUL; + } + + FdoDeviceExtension->hcd.CommonBufferSize = PAGE_SIZE * 16; + + /* Zeroize it */ + RtlZeroMemory(FdoDeviceExtension->hcd.CommonBufferVA, + PAGE_SIZE * 16); + + /* Init SpinLock for host controller device lock */ + KeInitializeSpinLock(&FdoDeviceExtension->hcd.Lock); + + /* Reserved a Queue Head that will always be in the AsyncList Address Register */ + FdoDeviceExtension->hcd.AsyncListQueue = CreateQueueHead(&FdoDeviceExtension->hcd); + FdoDeviceExtension->hcd.AsyncListQueue->HorizontalLinkPointer = FdoDeviceExtension->hcd.AsyncListQueue->PhysicalAddr | QH_TYPE_QH; + FdoDeviceExtension->hcd.AsyncListQueue->EndPointCharacteristics.QEDTDataToggleControl = FALSE; + FdoDeviceExtension->hcd.AsyncListQueue->Token.Bits.InterruptOnComplete = FALSE; + + /* Ensure the controller is stopped */ + StopEhci(&FdoDeviceExtension->hcd); + + Status = IoConnectInterrupt(&FdoDeviceExtension->EhciInterrupt, + InterruptService, + FdoDeviceExtension->DeviceObject, + NULL, + FdoDeviceExtension->Vector, + FdoDeviceExtension->Irql, + FdoDeviceExtension->Irql, + FdoDeviceExtension->Mode, + FdoDeviceExtension->IrqShared, + FdoDeviceExtension->Affinity, + FALSE); + + StartEhci(&FdoDeviceExtension->hcd); + DPRINT1("AsycnAddr %x\n", GetAsyncListQueueRegister(&FdoDeviceExtension->hcd)); FdoDeviceExtension->DeviceState = DEVICESTARTED; return STATUS_SUCCESS; @@ -628,7 +505,7 @@ FdoQueryBusRelations( /* Bail on any other error */ if (!NT_SUCCESS(Status)) { - DPRINT1("UsbEhci: Failed to create PDO %wZ, Status %x\n", &DeviceName, Status); + DPRINT1("Ehci: Failed to create PDO %wZ, Status %x\n", &DeviceName, Status); return Status; } } @@ -639,7 +516,7 @@ FdoQueryBusRelations( PdoDeviceExtension->ControllerFdo = DeviceObject; PdoDeviceExtension->DeviceObject = Pdo; - PdoDeviceExtension->NumberOfPorts = DeviceExtension->ECHICaps.HCSParams.PortCount; + PdoDeviceExtension->NumberOfPorts = DeviceExtension->hcd.ECHICaps.HCSParams.PortCount; InitializeListHead(&PdoDeviceExtension->IrpQueue); KeInitializeSpinLock(&PdoDeviceExtension->IrpQueueLock); @@ -683,6 +560,7 @@ FdoDispatchPnp(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp) case IRP_MN_START_DEVICE: { DPRINT1("Ehci: START_DEVICE\n"); + Irp->IoStatus.Status = STATUS_SUCCESS; Status = ForwardAndWait(DeviceObject, Irp); @@ -905,7 +783,7 @@ FdoDispatchInternalDeviceControl(PDEVICE_OBJECT DeviceObject, PIRP Irp) PUSB_DEVICE UsbDevice = NULL; URB *Urb; - /*FIXME: This should never be called by a miniport as the miniport should only be dealing with the pdo */ + /*FIXME: This should never be called by upper drivers as they should only be dealing with the pdo */ FdoDeviceExtension = (PFDO_DEVICE_EXTENSION) DeviceObject->DeviceExtension; PdoDeviceExtension = (PPDO_DEVICE_EXTENSION) FdoDeviceExtension->Pdo->DeviceExtension; @@ -924,7 +802,7 @@ FdoDispatchInternalDeviceControl(PDEVICE_OBJECT DeviceObject, PIRP Irp) if (!UsbDevice) { - DPRINT1("Invalid DeviceHandle or device not connected\n"); + DPRINT1("Ehci: Invalid DeviceHandle or device not connected\n"); return STATUS_DEVICE_NOT_CONNECTED; } switch (Urb->UrbHeader.Function) @@ -946,7 +824,6 @@ FdoDispatchInternalDeviceControl(PDEVICE_OBJECT DeviceObject, PIRP Irp) { case USB_DEVICE_DESCRIPTOR_TYPE: { - /* FIXME: This probably not used for FDO and should be removed? */ DPRINT1("USB DEVICE DESC\n"); break; } @@ -954,55 +831,13 @@ FdoDispatchInternalDeviceControl(PDEVICE_OBJECT DeviceObject, PIRP Irp) DPRINT1("USB CONFIG DESC\n"); //break; case USB_STRING_DESCRIPTOR_TYPE: - DPRINT1("Usb String Descriptor\n"); { - USB_DEFAULT_PIPE_SETUP_PACKET CtrlSetup; - PUSB_STRING_DESCRIPTOR UsbString; - BOOLEAN ResultOk; - - CtrlSetup.bmRequestType._BM.Recipient = BMREQUEST_TO_DEVICE; - CtrlSetup.bmRequestType._BM.Type = BMREQUEST_STANDARD; - CtrlSetup.bmRequestType._BM.Reserved = 0; - CtrlSetup.bmRequestType._BM.Dir = BMREQUEST_DEVICE_TO_HOST; - CtrlSetup.bRequest = USB_REQUEST_GET_DESCRIPTOR; - CtrlSetup.wValue.LowByte = Urb->UrbControlDescriptorRequest.Index; - CtrlSetup.wValue.HiByte = Urb->UrbControlDescriptorRequest.DescriptorType; - - if (Urb->UrbControlDescriptorRequest.DescriptorType == USB_STRING_DESCRIPTOR_TYPE) - { - CtrlSetup.wIndex.W = Urb->UrbControlDescriptorRequest.LanguageId; - RtlZeroMemory(Urb->UrbControlDescriptorRequest.TransferBuffer, Urb->UrbControlDescriptorRequest.TransferBufferLength-1); - } - else - CtrlSetup.wIndex.W = 0; - - CtrlSetup.wLength = Urb->UrbControlDescriptorRequest.TransferBufferLength; - - ResultOk = ExecuteControlRequest(FdoDeviceExtension, &CtrlSetup, UsbDevice->Address, UsbDevice->Port, - Urb->UrbControlDescriptorRequest.TransferBuffer, Urb->UrbControlDescriptorRequest.TransferBufferLength); - - if (Urb->UrbControlDescriptorRequest.DescriptorType == USB_STRING_DESCRIPTOR_TYPE) - { - UsbString = Urb->UrbControlDescriptorRequest.TransferBuffer; - DPRINT1("Index %x\n", Urb->UrbControlDescriptorRequest.Index); - DPRINT1("BufferLength %x\n", Urb->UrbControlDescriptorRequest.TransferBufferLength); - DPRINT1("Length %x\n", UsbString->bLength); - if (Urb->UrbControlDescriptorRequest.Index == 0) - { - DPRINT1("%x\n", (ULONG)Urb->UrbControlDescriptorRequest.TransferBuffer); - } - else - DPRINT1("String %S\n", &UsbString->bString); - } - UsbString = Urb->UrbControlDescriptorRequest.TransferBuffer; - Urb->UrbHeader.Status = USBD_STATUS_SUCCESS; - Status = STATUS_SUCCESS; - Information = UsbString->bLength; + DPRINT1("Usb String Descriptor\n"); break; } default: { - DPRINT1("Descriptor Type %x not supported!\n", Urb->UrbControlDescriptorRequest.DescriptorType); + DPRINT1("Ehci: Descriptor Type %x not supported!\n", Urb->UrbControlDescriptorRequest.DescriptorType); } } break; diff --git a/reactos/drivers/usb/usbehci/irp.c b/reactos/drivers/usb/usbehci/irp.c index 8bd51eaaeef..ead34f69e07 100644 --- a/reactos/drivers/usb/usbehci/irp.c +++ b/reactos/drivers/usb/usbehci/irp.c @@ -8,6 +8,19 @@ */ #include "usbehci.h" +#include "hwiface.h" +#include "physmem.h" +#include "transfer.h" + +VOID NTAPI +WorkerThread(IN PVOID Context) +{ + PWORKITEMDATA WorkItemData = (PWORKITEMDATA)Context; + + CompletePendingURBRequest((PPDO_DEVICE_EXTENSION)WorkItemData->Context); + + ExFreePool(WorkItemData); +} VOID RemoveUrbRequest(PPDO_DEVICE_EXTENSION DeviceExtension, PIRP Irp) @@ -23,7 +36,8 @@ RequestURBCancel (PPDO_DEVICE_EXTENSION PdoDeviceExtension, PIRP Irp) { KIRQL OldIrql = Irp->CancelIrql; IoReleaseCancelSpinLock(DISPATCH_LEVEL); - + DPRINT1("IRP CANCELLED\n"); + ASSERT(FALSE); KeAcquireSpinLockAtDpcLevel(&PdoDeviceExtension->IrpQueueLock); RemoveEntryList(&Irp->Tail.Overlay.ListEntry); @@ -40,7 +54,7 @@ QueueURBRequest(PPDO_DEVICE_EXTENSION DeviceExtension, PIRP Irp) KeAcquireSpinLock(&DeviceExtension->IrpQueueLock, &OldIrql); - if (Irp->Cancel && IoSetCancelRoutine(Irp, NULL)) + if ((Irp->Cancel) && (IoSetCancelRoutine(Irp, RequestURBCancel))) { KeReleaseSpinLock(&DeviceExtension->IrpQueueLock, OldIrql); Irp->IoStatus.Status = STATUS_CANCELLED; @@ -67,7 +81,6 @@ NTSTATUS HandleUrbRequest(PPDO_DEVICE_EXTENSION PdoDeviceExtension, PIRP Irp) ASSERT(Stack); Urb = (PURB) Stack->Parameters.Others.Argument1; - ASSERT(Urb); Information = 0; @@ -92,9 +105,12 @@ NTSTATUS HandleUrbRequest(PPDO_DEVICE_EXTENSION PdoDeviceExtension, PIRP Irp) { case URB_FUNCTION_BULK_OR_INTERRUPT_TRANSFER: { + DPRINT1("URB_FUNCTION_BULK_OR_INTERRUPT_TRANSFER UsbDevice %x\n", UsbDevice); if (&UsbDevice->ActiveInterface->EndPoints[0]->EndPointDescriptor != Urb->UrbBulkOrInterruptTransfer.PipeHandle) { + DPRINT1("Invalid Parameter, Expected EndPointDescriptor of %x, but got %x\n", &UsbDevice->ActiveInterface->EndPoints[0]->EndPointDescriptor, Urb->UrbBulkOrInterruptTransfer.PipeHandle); Status = STATUS_INVALID_PARAMETER; + ASSERT(FALSE); break; } @@ -128,6 +144,7 @@ NTSTATUS HandleUrbRequest(PPDO_DEVICE_EXTENSION PdoDeviceExtension, PIRP Irp) } case URB_FUNCTION_GET_STATUS_FROM_DEVICE: { + DPRINT1("URB_FUNCTION_GET_STATUS_FROM_DEVICE\n"); if (Urb->UrbControlGetStatusRequest.Index == 0) { ASSERT(Urb->UrbBulkOrInterruptTransfer.TransferBuffer != NULL); @@ -143,25 +160,55 @@ NTSTATUS HandleUrbRequest(PPDO_DEVICE_EXTENSION PdoDeviceExtension, PIRP Irp) } case URB_FUNCTION_GET_DESCRIPTOR_FROM_DEVICE: { + USB_DEFAULT_PIPE_SETUP_PACKET CtrlSetup; + + DPRINT1("URB_FUNCTION_GET_DESCRIPTOR_FROM_DEVICE\n"); switch(Urb->UrbControlDescriptorRequest.DescriptorType) { case USB_DEVICE_DESCRIPTOR_TYPE: { + PUCHAR BufPtr; + DPRINT1("Device Descr Type\n"); + if (Urb->UrbControlDescriptorRequest.TransferBufferLength >= sizeof(USB_DEVICE_DESCRIPTOR)) { Urb->UrbControlDescriptorRequest.TransferBufferLength = sizeof(USB_DEVICE_DESCRIPTOR); } + if (UsbDevice == PdoDeviceExtension->UsbDevices[0]) + { + DPRINT1("ROOTHUB!\n"); + BufPtr = (PUCHAR)Urb->UrbControlDescriptorRequest.TransferBuffer; + + DPRINT1("Length %x\n", Urb->UrbControlDescriptorRequest.TransferBufferLength); + + /* Copy the Device Descriptor */ + RtlCopyMemory(BufPtr, &UsbDevice->DeviceDescriptor, sizeof(USB_DEVICE_DESCRIPTOR)); + DumpDeviceDescriptor((PUSB_DEVICE_DESCRIPTOR)Urb->UrbControlDescriptorRequest.TransferBuffer); + break; + } + ASSERT(Urb->UrbControlDescriptorRequest.TransferBuffer != NULL); - RtlCopyMemory(Urb->UrbControlDescriptorRequest.TransferBuffer, - &UsbDevice->DeviceDescriptor, - Urb->UrbControlDescriptorRequest.TransferBufferLength); + + DPRINT("Calling BuildSetUpPacketFromUrb\n"); + BuildSetupPacketFromURB(&FdoDeviceExtension->hcd, Urb, &CtrlSetup); + DPRINT("SubmitControlTransfer\n"); + SubmitControlTransfer(&FdoDeviceExtension->hcd, + &CtrlSetup, + Urb->UrbControlDescriptorRequest.TransferBuffer, + Urb->UrbControlDescriptorRequest.TransferBufferLength, + Irp); + break; } case USB_CONFIGURATION_DESCRIPTOR_TYPE: { PUCHAR BufPtr; LONG i, j; - + DPRINT1("Config Descr Type\n"); + if (UsbDevice == PdoDeviceExtension->UsbDevices[0]) + { + DPRINT1("ROOTHUB!\n"); + } if (Urb->UrbControlDescriptorRequest.TransferBufferLength >= UsbDevice->ActiveConfig->ConfigurationDescriptor.wTotalLength) { Urb->UrbControlDescriptorRequest.TransferBufferLength = UsbDevice->ActiveConfig->ConfigurationDescriptor.wTotalLength; @@ -171,7 +218,7 @@ NTSTATUS HandleUrbRequest(PPDO_DEVICE_EXTENSION PdoDeviceExtension, PIRP Irp) DPRINT1("TransferBufferLenth %x is too small!!!\n", Urb->UrbControlDescriptorRequest.TransferBufferLength); if (Urb->UrbControlDescriptorRequest.TransferBufferLength < sizeof(USB_CONFIGURATION_DESCRIPTOR)) { - DPRINT("Configuration Descriptor cannot fit into given buffer!\n"); + DPRINT1("Configuration Descriptor cannot fit into given buffer!\n"); break; } } @@ -179,6 +226,8 @@ NTSTATUS HandleUrbRequest(PPDO_DEVICE_EXTENSION PdoDeviceExtension, PIRP Irp) ASSERT(Urb->UrbControlDescriptorRequest.TransferBuffer); BufPtr = (PUCHAR)Urb->UrbControlDescriptorRequest.TransferBuffer; + DPRINT1("Length %x\n", Urb->UrbControlDescriptorRequest.TransferBufferLength); + /* Copy the Configuration Descriptor */ RtlCopyMemory(BufPtr, &UsbDevice->ActiveConfig->ConfigurationDescriptor, sizeof(USB_CONFIGURATION_DESCRIPTOR)); @@ -193,31 +242,30 @@ NTSTATUS HandleUrbRequest(PPDO_DEVICE_EXTENSION PdoDeviceExtension, PIRP Irp) for (i = 0; i < UsbDevice->ActiveConfig->ConfigurationDescriptor.bNumInterfaces; i++) { /* Copy the Interface Descriptor */ - RtlCopyMemory(BufPtr, &UsbDevice->ActiveConfig->Interfaces[i]->InterfaceDescriptor, sizeof(USB_INTERFACE_DESCRIPTOR)); + RtlCopyMemory(BufPtr, + &UsbDevice->ActiveConfig->Interfaces[i]->InterfaceDescriptor, + sizeof(USB_INTERFACE_DESCRIPTOR)); BufPtr += sizeof(USB_INTERFACE_DESCRIPTOR); for (j = 0; j < UsbDevice->ActiveConfig->Interfaces[i]->InterfaceDescriptor.bNumEndpoints; j++) { /* Copy the EndPoint Descriptor */ - RtlCopyMemory(BufPtr, &UsbDevice->ActiveConfig->Interfaces[i]->EndPoints[j]->EndPointDescriptor, sizeof(USB_ENDPOINT_DESCRIPTOR)); + RtlCopyMemory(BufPtr, + &UsbDevice->ActiveConfig->Interfaces[i]->EndPoints[j]->EndPointDescriptor, + sizeof(USB_ENDPOINT_DESCRIPTOR)); BufPtr += sizeof(USB_ENDPOINT_DESCRIPTOR); } } - + DumpFullConfigurationDescriptor((PUSB_CONFIGURATION_DESCRIPTOR)Urb->UrbControlDescriptorRequest.TransferBuffer); break; } case USB_STRING_DESCRIPTOR_TYPE: { - USB_DEFAULT_PIPE_SETUP_PACKET CtrlSetup; - PUSB_STRING_DESCRIPTOR StringDesc; - BOOLEAN ResultOk; - - StringDesc = (PUSB_STRING_DESCRIPTOR) Urb->UrbControlDescriptorRequest.TransferBuffer; + DPRINT1("StringDescriptorType\n"); + DPRINT1("Urb->UrbControlDescriptorRequest.Index %x\n", Urb->UrbControlDescriptorRequest.Index); + DPRINT1("Urb->UrbControlDescriptorRequest.LanguageId %x\n", Urb->UrbControlDescriptorRequest.LanguageId); if (Urb->UrbControlDescriptorRequest.Index == 0) - DPRINT("Requesting LANGID's\n"); - - - RtlZeroMemory(Urb->UrbControlDescriptorRequest.TransferBuffer, Urb->UrbControlDescriptorRequest.TransferBufferLength-1); + DPRINT1("Requesting LANGID's\n"); CtrlSetup.bmRequestType._BM.Recipient = BMREQUEST_TO_DEVICE; CtrlSetup.bmRequestType._BM.Type = BMREQUEST_STANDARD; @@ -229,8 +277,14 @@ NTSTATUS HandleUrbRequest(PPDO_DEVICE_EXTENSION PdoDeviceExtension, PIRP Irp) CtrlSetup.wIndex.W = Urb->UrbControlDescriptorRequest.LanguageId; CtrlSetup.wLength = Urb->UrbControlDescriptorRequest.TransferBufferLength; - ResultOk = ExecuteControlRequest(FdoDeviceExtension, &CtrlSetup, UsbDevice->Address, UsbDevice->Port, - Urb->UrbControlDescriptorRequest.TransferBuffer, Urb->UrbControlDescriptorRequest.TransferBufferLength); + SubmitControlTransfer(&FdoDeviceExtension->hcd, + &CtrlSetup, + Urb->UrbControlDescriptorRequest.TransferBuffer, + Urb->UrbControlDescriptorRequest.TransferBufferLength, + Irp); + + IoMarkIrpPending(Irp); + Status = STATUS_PENDING; break; } default: @@ -245,8 +299,8 @@ NTSTATUS HandleUrbRequest(PPDO_DEVICE_EXTENSION PdoDeviceExtension, PIRP Irp) PUSBD_INTERFACE_INFORMATION InterfaceInfo; LONG iCount, pCount; - DPRINT("Selecting Configuration\n"); - DPRINT("Urb->UrbSelectConfiguration.ConfigurationHandle %x\n",Urb->UrbSelectConfiguration.ConfigurationHandle); + DPRINT1("Selecting Configuration\n"); + DPRINT1("ConfigurationHandle %x\n",Urb->UrbSelectConfiguration.ConfigurationHandle); if (Urb->UrbSelectConfiguration.ConfigurationDescriptor) { @@ -254,6 +308,9 @@ NTSTATUS HandleUrbRequest(PPDO_DEVICE_EXTENSION PdoDeviceExtension, PIRP Irp) DPRINT("ConfigHandle %x\n", Urb->UrbSelectConfiguration.ConfigurationHandle); InterfaceInfo = &Urb->UrbSelectConfiguration.Interface; + DPRINT1("Length %x\n", InterfaceInfo->Length); + DPRINT1("NumberOfPipes %x\n", InterfaceInfo->NumberOfPipes); + for (iCount = 0; iCount < Urb->UrbSelectConfiguration.ConfigurationDescriptor->bNumInterfaces; iCount++) { InterfaceInfo->InterfaceHandle = (PVOID)&UsbDevice->ActiveInterface->InterfaceDescriptor; @@ -274,6 +331,7 @@ NTSTATUS HandleUrbRequest(PPDO_DEVICE_EXTENSION PdoDeviceExtension, PIRP Irp) /* InterfaceInfo->Pipes[j].PipeFlags = 0; */ } InterfaceInfo = (PUSBD_INTERFACE_INFORMATION)((PUCHAR)InterfaceInfo + InterfaceInfo->Length); + if (InterfaceInfo->Length == 0) break; } } else @@ -284,6 +342,7 @@ NTSTATUS HandleUrbRequest(PPDO_DEVICE_EXTENSION PdoDeviceExtension, PIRP Irp) } case URB_FUNCTION_CLASS_DEVICE: { + DPRINT1("URB_FUNCTION_CLASS_DEVICE\n"); switch (Urb->UrbControlVendorClassRequest.Request) { case USB_REQUEST_GET_DESCRIPTOR: @@ -353,7 +412,7 @@ NTSTATUS HandleUrbRequest(PPDO_DEVICE_EXTENSION PdoDeviceExtension, PIRP Irp) DPRINT1("USB_DEVICE_CLASS_HUB request\n"); UsbHubDescr->bDescriptorLength = sizeof(USB_HUB_DESCRIPTOR); UsbHubDescr->bDescriptorType = 0x29; - UsbHubDescr->bNumberOfPorts = 0x08; + UsbHubDescr->bNumberOfPorts = PdoDeviceExtension->NumberOfPorts; UsbHubDescr->wHubCharacteristics = 0x0012; UsbHubDescr->bPowerOnToPowerGood = 0x01; UsbHubDescr->bHubControlCurrent = 0x00; @@ -383,6 +442,7 @@ NTSTATUS HandleUrbRequest(PPDO_DEVICE_EXTENSION PdoDeviceExtension, PIRP Irp) { DPRINT1("Unhandled URB request for class device\n"); Urb->UrbHeader.Status = USBD_STATUS_INVALID_URB_FUNCTION; + ASSERT(FALSE); } } break; @@ -390,13 +450,13 @@ NTSTATUS HandleUrbRequest(PPDO_DEVICE_EXTENSION PdoDeviceExtension, PIRP Irp) case URB_FUNCTION_CLASS_OTHER: { DPRINT("URB_FUNCTION_CLASS_OTHER\n"); - /* FIXME: Each one of these needs to make sure that the index value is a valid for the number of ports and return STATUS_UNSUCCESSFUL is not */ + /* FIXME: Each one of these needs to make sure that the index value is a valid for the number of ports and return STATUS_UNSUCCESSFUL if not */ switch (Urb->UrbControlVendorClassRequest.Request) { case USB_REQUEST_GET_STATUS: { - DPRINT("USB_REQUEST_GET_STATUS Port %d\n", Urb->UrbControlVendorClassRequest.Index); + DPRINT1("USB_REQUEST_GET_STATUS Port %d\n", Urb->UrbControlVendorClassRequest.Index); ASSERT(Urb->UrbControlVendorClassRequest.TransferBuffer != 0); DPRINT("PortStatus %x\n", PdoDeviceExtension->Ports[Urb->UrbControlVendorClassRequest.Index-1].PortStatus); @@ -407,20 +467,23 @@ NTSTATUS HandleUrbRequest(PPDO_DEVICE_EXTENSION PdoDeviceExtension, PIRP Irp) } case USB_REQUEST_CLEAR_FEATURE: { - DPRINT("USB_REQUEST_CLEAR_FEATURE Port %d, value %x\n", Urb->UrbControlVendorClassRequest.Index, + DPRINT1("USB_REQUEST_CLEAR_FEATURE Port %d, value %x\n", Urb->UrbControlVendorClassRequest.Index, Urb->UrbControlVendorClassRequest.Value); switch (Urb->UrbControlVendorClassRequest.Value) { case C_PORT_CONNECTION: + DPRINT1("C_PORT_CONNECTION\n"); PdoDeviceExtension->Ports[Urb->UrbControlVendorClassRequest.Index-1].PortChange &= ~USB_PORT_STATUS_CONNECT; break; case C_PORT_RESET: + DPRINT1("C_PORT_RESET\n"); PdoDeviceExtension->Ports[Urb->UrbControlVendorClassRequest.Index-1].PortChange &= ~USB_PORT_STATUS_RESET; break; default: DPRINT1("Unknown Value for Clear Feature %x \n", Urb->UrbControlVendorClassRequest.Value); break; } + CompletePendingURBRequest(PdoDeviceExtension); break; } case USB_REQUEST_SET_FEATURE: @@ -432,32 +495,43 @@ NTSTATUS HandleUrbRequest(PPDO_DEVICE_EXTENSION PdoDeviceExtension, PIRP Irp) { case PORT_RESET: { - PdoDeviceExtension->Ports[Urb->UrbControlVendorClassRequest.Index-1].PortStatus |= USB_PORT_STATUS_ENABLE; - ResetPort(FdoDeviceExtension, Urb->UrbControlVendorClassRequest.Index-1); + //PWORKITEMDATA WorkItemData; + PdoDeviceExtension->Ports[Urb->UrbControlVendorClassRequest.Index-1].PortStatus |= USB_PORT_STATUS_ENABLE; + PdoDeviceExtension->Ports[Urb->UrbControlVendorClassRequest.Index-1].PortChange |= USB_PORT_STATUS_RESET; + + ResetPort(&FdoDeviceExtension->hcd, Urb->UrbControlVendorClassRequest.Index-1); + //WorkItemData = ExAllocatePool(NonPagedPool, sizeof(WORKITEMDATA)); + //WorkItemData->Context = PdoDeviceExtension; + //ExInitializeWorkItem(&WorkItemData->WorkItem, (PWORKER_THREAD_ROUTINE)WorkerThread, (PVOID) WorkItemData) + //ExQueueWorkItem(&WorkItemData->WorkItem, DelayedWorkQueue); + //IoMarkIrpPending(Irp); + //Status = STATUS_PENDING; break; } case PORT_ENABLE: { - DPRINT1("PORT_ENABLE not implemented\n"); + DPRINT("PORT_ENABLE not implemented\n"); break; } case PORT_POWER: { - DPRINT1("PORT_POWER not implemented\n"); + DPRINT("PORT_POWER not implemented\n"); break; } default: { - DPRINT1("Unknown Set Feature!\n"); + DPRINT("Unknown Set Feature!\n"); break; } } + CompletePendingURBRequest(PdoDeviceExtension); break; } case USB_REQUEST_SET_ADDRESS: { DPRINT1("USB_REQUEST_SET_ADDRESS\n"); + ASSERT(FALSE); break; } case USB_REQUEST_GET_DESCRIPTOR: @@ -508,7 +582,6 @@ NTSTATUS HandleUrbRequest(PPDO_DEVICE_EXTENSION PdoDeviceExtension, PIRP Irp) DPRINT1("Unhandled URB %x\n", Urb->UrbHeader.Function); Urb->UrbHeader.Status = USBD_STATUS_INVALID_URB_FUNCTION; } - } Irp->IoStatus.Status = Status; @@ -539,8 +612,11 @@ CompletePendingURBRequest(PPDO_DEVICE_EXTENSION DeviceExtension) Irp = CONTAINING_RECORD(NextIrp, IRP, Tail.Overlay.ListEntry); if (!Irp) + { + DPRINT1("No IRP\n"); break; - + } + IoSetCancelRoutine(Irp, NULL); KeReleaseSpinLock(&DeviceExtension->IrpQueueLock, oldIrql); HandleUrbRequest(DeviceExtension, Irp); IoCompleteRequest(Irp, IO_NO_INCREMENT); diff --git a/reactos/drivers/usb/usbehci/pdo.c b/reactos/drivers/usb/usbehci/pdo.c index f8e83f4fbcd..0254fcc8204 100644 --- a/reactos/drivers/usb/usbehci/pdo.c +++ b/reactos/drivers/usb/usbehci/pdo.c @@ -55,7 +55,7 @@ const UCHAR ROOTHUB2_CONFIGURATION_DESCRIPTOR [] = 0x00 /* MaxPower; */ }; -const UCHAR ROOTHUB2_INTERFACE_DESCRIPTOR [] = +const UCHAR ROOTHUB2_INTERFACE_DESCRIPTOR [] = { /* one interface */ 0x09, /* bLength: Interface; */ @@ -80,31 +80,6 @@ const UCHAR ROOTHUB2_ENDPOINT_DESCRIPTOR [] = 0xFF /* bInterval; (255ms -- usb 2.0 spec) */ }; -/* FIXME: Do something better */ -VOID NTAPI -UrbWorkerThread(PVOID Context) -{ - PPDO_DEVICE_EXTENSION PdoDeviceExtension = (PPDO_DEVICE_EXTENSION)Context; - NTSTATUS Status; - LARGE_INTEGER DueTime; - PVOID PollEvents[] = { (PVOID) &PdoDeviceExtension->QueueDrainedEvent, (PVOID) &PdoDeviceExtension->Timer }; - - DueTime.QuadPart = 0; - KeInitializeTimerEx(&PdoDeviceExtension->Timer, SynchronizationTimer); - KeSetTimerEx(&PdoDeviceExtension->Timer, DueTime, 100, NULL); - - while (TRUE) - { - Status = KeWaitForMultipleObjects(2, PollEvents, WaitAll, Executive, KernelMode, FALSE, NULL, NULL); - - if (!PdoDeviceExtension->HaltQueue) - KeResetEvent(&PdoDeviceExtension->QueueDrainedEvent); - CompletePendingURBRequest(PdoDeviceExtension); - } - - DPRINT1("Thread terminated\n"); -} - NTSTATUS NTAPI PdoDispatchInternalDeviceControl(PDEVICE_OBJECT DeviceObject, PIRP Irp) { @@ -139,7 +114,8 @@ PdoDispatchInternalDeviceControl(PDEVICE_OBJECT DeviceObject, PIRP Irp) if ((Urb->UrbHeader.Function == URB_FUNCTION_BULK_OR_INTERRUPT_TRANSFER) && (UsbDevice == PdoDeviceExtension->UsbDevices[0])) { - if (Urb->UrbBulkOrInterruptTransfer.PipeHandle == &UsbDevice->ActiveInterface->EndPoints[0]->EndPointDescriptor) + DPRINT1("URB_FUNCTION_BULK_OR_INTERRUPT_TRANSFER on SCE\n"); + if (Urb->UrbBulkOrInterruptTransfer.PipeHandle != &UsbDevice->ActiveInterface->EndPoints[0]->EndPointDescriptor) { DPRINT1("PipeHandle doesnt match SCE PipeHandle\n"); } @@ -172,6 +148,10 @@ PdoDispatchInternalDeviceControl(PDEVICE_OBJECT DeviceObject, PIRP Irp) Status = STATUS_PENDING; break; } + else + { + DPRINT1("IOCTL_INTERNAL_USB_SUBMIT_URB send to device %x\n", UsbDevice); + } Status = HandleUrbRequest(PdoDeviceExtension, Irp); @@ -419,10 +399,10 @@ PdoDispatchPnp( for (i = 0; i < PdoDeviceExtension->NumberOfPorts; i++) { - PdoDeviceExtension->Ports[i].PortStatus = USB_PORT_STATUS_HIGH_SPEED | 0x8000; + PdoDeviceExtension->Ports[i].PortStatus = 0x8000; PdoDeviceExtension->Ports[i].PortChange = 0; - if (!FdoDeviceExtension->ECHICaps.HCSParams.PortPowerControl) + if (!FdoDeviceExtension->hcd.ECHICaps.HCSParams.PortPowerControl) PdoDeviceExtension->Ports[i].PortStatus |= USB_PORT_STATUS_POWER; } @@ -470,19 +450,6 @@ PdoDispatchPnp( PdoDeviceExtension->UsbDevices[0] = RootHubDevice; - /* Create a thread to handle the URB's */ -/* - Status = PsCreateSystemThread(&PdoDeviceExtension->ThreadHandle, - THREAD_ALL_ACCESS, - NULL, - NULL, - NULL, - UrbWorkerThread, - (PVOID)PdoDeviceExtension); - - if (!NT_SUCCESS(Status)) - DPRINT1("Failed Thread Creation with Status: %x\n", Status); -*/ Status = IoRegisterDeviceInterface(DeviceObject, &GUID_DEVINTERFACE_USB_HUB, NULL, &InterfaceSymLinkName); if (!NT_SUCCESS(Status)) { diff --git a/reactos/drivers/usb/usbehci/urbreq.c b/reactos/drivers/usb/usbehci/urbreq.c deleted file mode 100644 index 8fdaf8149fb..00000000000 --- a/reactos/drivers/usb/usbehci/urbreq.c +++ /dev/null @@ -1,216 +0,0 @@ -/* - * PROJECT: ReactOS Universal Serial Bus Bulk Enhanced Host Controller Interface - * LICENSE: GPL - See COPYING in the top level directory - * FILE: drivers/usb/usbehci/urbreq.c - * PURPOSE: URB Related Functions. - * PROGRAMMERS: - * Michael Martin (michael.martin@reactos.org) - */ - -#include "usbehci.h" - -/* QueueHead must point to the base address in common buffer */ -PVOID -IntializeHeadQueueForStandardRequest(PQUEUE_HEAD QueueHead, - PQUEUE_TRANSFER_DESCRIPTOR *CtrlTD1, - PQUEUE_TRANSFER_DESCRIPTOR *CtrlTD2, - PQUEUE_TRANSFER_DESCRIPTOR *CtrlTD3, - PUSB_DEFAULT_PIPE_SETUP_PACKET *CtrlSetup, - PVOID *CtrlData, - ULONG Size) -{ - QueueHead->HorizontalLinkPointer = (ULONG)QueueHead | QH_TYPE_QH; - - /* Set NakCountReload to max value possible */ - QueueHead->EndPointCapabilities1.NakCountReload = 0xF; - - /* 1 for non high speed, 0 for high speed device */ - QueueHead->EndPointCapabilities1.ControlEndPointFlag = 0; - - QueueHead->EndPointCapabilities1.HeadOfReclamation = TRUE; - QueueHead->EndPointCapabilities1.MaximumPacketLength = 64; - - /* Get the Initial Data Toggle from the QEDT */ - QueueHead->EndPointCapabilities1.QEDTDataToggleControl = TRUE; - - /* HIGH SPEED DEVICE */ - QueueHead->EndPointCapabilities1.EndPointSpeed = QH_ENDPOINT_HIGHSPEED; - QueueHead->EndPointCapabilities1.EndPointNumber = 0; - - /* Only used for Periodic Schedule and Not High Speed devices. - Setting it to one result in undefined behavior for Async */ - QueueHead->EndPointCapabilities1.InactiveOnNextTransaction = 0; - - QueueHead->EndPointCapabilities1.DeviceAddress = 0; - QueueHead->EndPointCapabilities2.HubAddr = 0; - QueueHead->EndPointCapabilities2.NumberOfTransactionPerFrame = 0x01; - - /* 0 For Async, 1 for periodoc schedule */ - QueueHead->EndPointCapabilities2.InterruptScheduleMask = 0; - - QueueHead->EndPointCapabilities2.PortNumber = 0; - QueueHead->EndPointCapabilities2.SplitCompletionMask = 0; - QueueHead->CurrentLinkPointer = 0; - QueueHead->QETDPointer = TERMINATE_POINTER; - QueueHead->AlternateNextPointer = TERMINATE_POINTER; - QueueHead->Token.Bits.InterruptOnComplete = TRUE; - QueueHead->BufferPointer[0] = 0; - QueueHead->BufferPointer[1] = 0; - QueueHead->BufferPointer[2] = 0; - QueueHead->BufferPointer[3] = 0; - QueueHead->BufferPointer[4] = 0; - /* Queue Head Initialized */ - - /* Queue Transfer Descriptors must be 32 byte aligned and reside in continous physical memory */ - *CtrlTD1 = (PQUEUE_TRANSFER_DESCRIPTOR) (((ULONG)(QueueHead) + sizeof(QUEUE_HEAD) + 0x1F) & ~0x1F); - *CtrlTD2 = (PQUEUE_TRANSFER_DESCRIPTOR) (((ULONG)(*CtrlTD1) + sizeof(QUEUE_TRANSFER_DESCRIPTOR) + 0x1F) & ~0x1F); - *CtrlTD3 = (PQUEUE_TRANSFER_DESCRIPTOR) (((ULONG)(*CtrlTD2) + sizeof(QUEUE_TRANSFER_DESCRIPTOR) + 0x1F) & ~0x1F); - - /* Must be Page aligned */ - *CtrlSetup = (PUSB_DEFAULT_PIPE_SETUP_PACKET) (( (ULONG)(*CtrlTD3) + sizeof(QUEUE_TRANSFER_DESCRIPTOR) + 0xFFF) & ~0xFFF); - *CtrlData = (PVOID) (( (ULONG)(*CtrlSetup) + sizeof(USB_DEFAULT_PIPE_SETUP_PACKET) + 0xFFF) & ~0xFFF); - - (*CtrlTD1)->NextPointer = TERMINATE_POINTER; - (*CtrlTD1)->AlternateNextPointer = TERMINATE_POINTER; - (*CtrlTD1)->BufferPointer[0] = (ULONG)MmGetPhysicalAddress((PVOID) (*CtrlSetup)).LowPart; - (*CtrlTD1)->Token.Bits.DataToggle = FALSE; - (*CtrlTD1)->Token.Bits.InterruptOnComplete = FALSE; - (*CtrlTD1)->Token.Bits.TotalBytesToTransfer = sizeof(USB_DEFAULT_PIPE_SETUP_PACKET); - (*CtrlTD1)->Token.Bits.ErrorCounter = 0x03; - (*CtrlTD1)->Token.Bits.PIDCode = PID_CODE_SETUP_TOKEN; - (*CtrlTD1)->Token.Bits.Active = TRUE; - - (*CtrlTD2)->NextPointer = TERMINATE_POINTER; - (*CtrlTD2)->AlternateNextPointer = TERMINATE_POINTER; - if (Size == 0) - (*CtrlTD2)->BufferPointer[0] = 0; - else - (*CtrlTD2)->BufferPointer[0] = (ULONG)MmGetPhysicalAddress((PVOID) (*CtrlData)).LowPart; - (*CtrlTD2)->Token.Bits.DataToggle = TRUE; - (*CtrlTD2)->Token.Bits.InterruptOnComplete = TRUE; - (*CtrlTD2)->Token.Bits.TotalBytesToTransfer = Size; - (*CtrlTD2)->Token.Bits.ErrorCounter = 0x03; - (*CtrlTD2)->Token.Bits.PIDCode = PID_CODE_IN_TOKEN; - (*CtrlTD2)->Token.Bits.Active = TRUE; - - (*CtrlTD1)->NextPointer = (ULONG)MmGetPhysicalAddress((PVOID)(*CtrlTD2)).LowPart; - - (*CtrlTD3)->NextPointer = TERMINATE_POINTER; - (*CtrlTD3)->AlternateNextPointer = TERMINATE_POINTER; - (*CtrlTD3)->BufferPointer[0] = 0; - (*CtrlTD3)->Token.Bits.Active = TRUE; - (*CtrlTD3)->Token.Bits.PIDCode = PID_CODE_OUT_TOKEN; - (*CtrlTD3)->Token.Bits.InterruptOnComplete = TRUE; - (*CtrlTD3)->Token.Bits.TotalBytesToTransfer = 0; - (*CtrlTD3)->Token.Bits.DataToggle = TRUE; - (*CtrlTD3)->Token.Bits.ErrorCounter = 0x03; - (*CtrlTD2)->NextPointer = (ULONG) MmGetPhysicalAddress((PVOID)(*CtrlTD3)).LowPart; - return NULL; -} - -BOOLEAN -ExecuteControlRequest(PFDO_DEVICE_EXTENSION DeviceExtension, PUSB_DEFAULT_PIPE_SETUP_PACKET SetupPacket, UCHAR Address, ULONG Port, PVOID Buffer, ULONG BufferLength) -{ - PUSB_DEFAULT_PIPE_SETUP_PACKET CtrlSetup = NULL; - PVOID CtrlData = NULL; - PQUEUE_TRANSFER_DESCRIPTOR CtrlTD1 = NULL; - PQUEUE_TRANSFER_DESCRIPTOR CtrlTD2 = NULL; - PQUEUE_TRANSFER_DESCRIPTOR CtrlTD3 = NULL; - - PQUEUE_HEAD QueueHead; - PEHCI_USBCMD_CONTENT UsbCmd; - PEHCI_USBSTS_CONTEXT UsbSts; - LONG Base; - LONG tmp; - - DPRINT1("ExecuteControlRequest: Buffer %x, Length %x\n", Buffer, BufferLength); - - ExAcquireFastMutex(&DeviceExtension->AsyncListMutex); - - Base = (ULONG) DeviceExtension->ResourceMemory; - - /* Set up the QUEUE HEAD in memory */ - QueueHead = (PQUEUE_HEAD) ((ULONG)DeviceExtension->AsyncListQueueHeadPtr); - - /* Initialize the memory pointers */ - IntializeHeadQueueForStandardRequest(QueueHead, - &CtrlTD1, - &CtrlTD2, - &CtrlTD3, - &CtrlSetup, - (PVOID)&CtrlData, - BufferLength); - - QueueHead->EndPointCapabilities2.PortNumber = Port; - QueueHead->EndPointCapabilities1.DeviceAddress = Address; - - CtrlSetup->bmRequestType._BM.Recipient = SetupPacket->bmRequestType._BM.Recipient; - CtrlSetup->bmRequestType._BM.Type = SetupPacket->bmRequestType._BM.Type; - CtrlSetup->bmRequestType._BM.Dir = SetupPacket->bmRequestType._BM.Dir; - CtrlSetup->bRequest = SetupPacket->bRequest; - CtrlSetup->wValue.LowByte = SetupPacket->wValue.LowByte; - CtrlSetup->wValue.HiByte = SetupPacket->wValue.HiByte; - CtrlSetup->wIndex.W = SetupPacket->wIndex.W; - CtrlSetup->wLength = SetupPacket->wLength; - - tmp = READ_REGISTER_ULONG((PULONG) (Base + EHCI_USBCMD)); - UsbCmd = (PEHCI_USBCMD_CONTENT) &tmp; - UsbCmd->Run = FALSE; - WRITE_REGISTER_ULONG((PULONG) (Base + EHCI_USBCMD), tmp); - - /* Wait for the controller to halt */ - for (;;) - { - KeStallExecutionProcessor(10); - tmp = READ_REGISTER_ULONG((PULONG)(Base + EHCI_USBSTS)); - UsbSts = (PEHCI_USBSTS_CONTEXT)&tmp; - DPRINT("Waiting for Halt, USBSTS: %x\n", READ_REGISTER_ULONG ((PULONG)(Base + EHCI_USBSTS))); - if (UsbSts->HCHalted) - { - break; - } - } - - /* Set to TRUE on interrupt for async completion */ - DeviceExtension->AsyncComplete = FALSE; - QueueHead->QETDPointer = (ULONG) MmGetPhysicalAddress((PVOID)(CtrlTD1)).LowPart; - - tmp = READ_REGISTER_ULONG((PULONG) (Base + EHCI_USBCMD)); - UsbCmd = (PEHCI_USBCMD_CONTENT) &tmp; - UsbCmd->AsyncEnable = TRUE; - - WRITE_REGISTER_ULONG((PULONG)(Base + EHCI_USBCMD), tmp); - - tmp = READ_REGISTER_ULONG((PULONG) (Base + EHCI_USBCMD)); - UsbCmd = (PEHCI_USBCMD_CONTENT) &tmp; - - /* Interrupt on Async completion */ - UsbCmd->DoorBell = TRUE; - UsbCmd->Run = TRUE; - WRITE_REGISTER_ULONG((PULONG)(Base + EHCI_USBCMD), tmp); - - for (;;) - { - KeStallExecutionProcessor(100); - DPRINT("Waiting for completion!\n"); - if (DeviceExtension->AsyncComplete == TRUE) - break; - } - - UsbCmd->Run = FALSE; - WRITE_REGISTER_ULONG((PULONG)(Base + EHCI_USBCMD), tmp); - - if (SetupPacket->bmRequestType._BM.Dir == BMREQUEST_DEVICE_TO_HOST) - { - if ((Buffer) && (BufferLength)) - { - RtlCopyMemory(Buffer, CtrlData, BufferLength); - } - else - DPRINT1("Unable to copy data to buffer\n"); - } - - ExReleaseFastMutex(&DeviceExtension->AsyncListMutex); - - return TRUE; -} diff --git a/reactos/drivers/usb/usbehci/usbehci.c b/reactos/drivers/usb/usbehci/usbehci.c index a0cc00858ae..f88cde8b886 100644 --- a/reactos/drivers/usb/usbehci/usbehci.c +++ b/reactos/drivers/usb/usbehci/usbehci.c @@ -88,7 +88,6 @@ DriverEntry(PDRIVER_OBJECT DriverObject, PUNICODE_STRING RegistryPath) DPRINT1("Driver Entry %wZ!\n", RegistryPath); DriverObject->DriverExtension->AddDevice = AddDevice; - DriverObject->MajorFunction[IRP_MJ_CREATE] = UsbEhciCreate; DriverObject->MajorFunction[IRP_MJ_CLOSE] = UsbEhciClose; DriverObject->MajorFunction[IRP_MJ_CLEANUP] = UsbEhciCleanup; diff --git a/reactos/drivers/usb/usbehci/usbehci.rbuild b/reactos/drivers/usb/usbehci/usbehci.rbuild index c5ace344e51..f30b683d498 100644 --- a/reactos/drivers/usb/usbehci/usbehci.rbuild +++ b/reactos/drivers/usb/usbehci/usbehci.rbuild @@ -4,12 +4,15 @@ ntoskrnl hal usbehci.c + hardware.c + physmem.c + hwiface.c + transfer.c fdo.c pdo.c common.c misc.c irp.c usbiffn.c - urbreq.c usbehci.rc diff --git a/reactos/drivers/usb/usbehci/usbiffn.c b/reactos/drivers/usb/usbehci/usbiffn.c index 4e9f4063f5a..9d2efddd31f 100644 --- a/reactos/drivers/usb/usbehci/usbiffn.c +++ b/reactos/drivers/usb/usbehci/usbiffn.c @@ -10,6 +10,7 @@ #include "usbehci.h" #include #include +#include "transfer.h" PVOID InternalCreateUsbDevice(UCHAR DeviceNumber, ULONG Port, PUSB_DEVICE Parent, BOOLEAN Hub) { @@ -30,8 +31,8 @@ PVOID InternalCreateUsbDevice(UCHAR DeviceNumber, ULONG Port, PUSB_DEVICE Parent DPRINT1("This is the root hub\n"); } - UsbDevicePointer->Address = 0;// DeviceNumber; - UsbDevicePointer->Port = Port; + UsbDevicePointer->Address = 0;//DeviceNumber; + UsbDevicePointer->Port = Port - 1; UsbDevicePointer->ParentDevice = Parent; UsbDevicePointer->IsHub = Hub; @@ -55,6 +56,7 @@ InterfaceDereference(PVOID BusContext) /* Bus Interface Hub V5 Functions */ + NTSTATUS USB_BUSIFFN CreateUsbDevice(PVOID BusContext, @@ -65,6 +67,7 @@ CreateUsbDevice(PVOID BusContext, PPDO_DEVICE_EXTENSION PdoDeviceExtension; PUSB_DEVICE UsbDevice; LONG i = 0; + PdoDeviceExtension = (PPDO_DEVICE_EXTENSION)((PDEVICE_OBJECT)BusContext)->DeviceExtension; DPRINT1("Ehci: CreateUsbDevice: HubDeviceHandle %x, PortStatus %x, PortNumber %x\n", HubDeviceHandle, PortStatus, PortNumber); @@ -97,8 +100,6 @@ CreateUsbDevice(PVOID BusContext, return STATUS_SUCCESS; } -/* Called when SCE reports a change */ -/* FIXME: Do something better for memory */ NTSTATUS USB_BUSIFFN InitializeUsbDevice(PVOID BusContext, PUSB_DEVICE_HANDLE DeviceHandle) @@ -110,12 +111,10 @@ InitializeUsbDevice(PVOID BusContext, PUSB_DEVICE_HANDLE DeviceHandle) PUSB_INTERFACE_DESCRIPTOR InterfaceDesc; PUSB_ENDPOINT_DESCRIPTOR EndpointDesc; PUSB_DEVICE UsbDevice; - BOOLEAN ResultOk; PVOID Buffer; PUCHAR Ptr; LONG i, j, k; - DPRINT1("Ehci: InitializeUsbDevice called, device %x\n", DeviceHandle); PdoDeviceExtension = (PPDO_DEVICE_EXTENSION)((PDEVICE_OBJECT)BusContext)->DeviceExtension; FdoDeviceExtension = (PFDO_DEVICE_EXTENSION)PdoDeviceExtension->ControllerFdo->DeviceExtension; @@ -127,59 +126,32 @@ InitializeUsbDevice(PVOID BusContext, PUSB_DEVICE_HANDLE DeviceHandle) return STATUS_DEVICE_NOT_CONNECTED; } - Buffer = ExAllocatePoolWithTag(NonPagedPool, PAGE_SIZE, USB_POOL_TAG); - - if (!Buffer) - { - DPRINT1("Out of memory\n"); - return STATUS_NO_MEMORY; - } - - Ptr = Buffer; - - /* Set the device address */ -/* - CtrlSetup.bmRequestType._BM.Recipient = BMREQUEST_TO_DEVICE; - CtrlSetup.bmRequestType._BM.Type = BMREQUEST_STANDARD; - CtrlSetup.bmRequestType._BM.Reserved = 0; - CtrlSetup.bmRequestType._BM.Dir = BMREQUEST_HOST_TO_DEVICE; - CtrlSetup.bRequest = USB_REQUEST_SET_ADDRESS; - CtrlSetup.wValue.W = UsbDevice->Address; - CtrlSetup.wIndex.W = 0; - CtrlSetup.wLength = 0; - - DPRINT1("Setting Address to %x\n", UsbDevice->Address); - ResultOk = ExecuteControlRequest(FdoDeviceExtension, &CtrlSetup, 0, UsbDevice->Port, NULL, 0); - -*/ - - /* Get the Device Descriptor */ - CtrlSetup.bmRequestType._BM.Recipient = BMREQUEST_TO_DEVICE; - CtrlSetup.bmRequestType._BM.Type = BMREQUEST_STANDARD; - CtrlSetup.bmRequestType._BM.Dir = BMREQUEST_DEVICE_TO_HOST; CtrlSetup.bRequest = USB_REQUEST_GET_DESCRIPTOR; CtrlSetup.wValue.LowByte = 0; CtrlSetup.wValue.HiByte = USB_DEVICE_DESCRIPTOR_TYPE; CtrlSetup.wIndex.W = 0; - CtrlSetup.wLength = sizeof(USB_DEVICE_DESCRIPTOR); - - DPRINT1("Requesting Descriptor\n"); - ResultOk = ExecuteControlRequest(FdoDeviceExtension, &CtrlSetup, UsbDevice->Address, UsbDevice->Port, - &UsbDevice->DeviceDescriptor, sizeof(USB_DEVICE_DESCRIPTOR)); - - - DPRINT1("bLength %x\n", UsbDevice->DeviceDescriptor.bLength); - DPRINT1("bDescriptorType %x\n", UsbDevice->DeviceDescriptor.bDescriptorType); - DPRINT1("idVendor %x\n", UsbDevice->DeviceDescriptor.idVendor); - DPRINT1("idProduct %x\n", UsbDevice->DeviceDescriptor.idProduct); - DPRINT1("bNumDescriptors %x\n", UsbDevice->DeviceDescriptor.bNumConfigurations); - - if (UsbDevice->DeviceDescriptor.bNumConfigurations == 0) + CtrlSetup.wLength = sizeof(USB_DEVICE_DESCRIPTOR); + CtrlSetup.bmRequestType.B = 0x80; + + SubmitControlTransfer(&FdoDeviceExtension->hcd, + &CtrlSetup, + &UsbDevice->DeviceDescriptor, + sizeof(USB_DEVICE_DESCRIPTOR), + NULL); + + //DumpDeviceDescriptor(&UsbDevice->DeviceDescriptor); + + if (UsbDevice->DeviceDescriptor.bLength != 0x12) { - DPRINT1("No Configurations. That cant be good!\n"); + DPRINT1("Failed to get Device Descriptor from device connected on port %d\n", UsbDevice->Port); + return STATUS_DEVICE_DATA_ERROR; + } + + if (UsbDevice->DeviceDescriptor.bNumConfigurations == 0) + { + DPRINT1("Device on port %d has no configurations!\n", UsbDevice->Port); return STATUS_DEVICE_DATA_ERROR; } - UsbDevice->Configs = ExAllocatePoolWithTag(NonPagedPool, sizeof(PVOID) * UsbDevice->DeviceDescriptor.bNumConfigurations, USB_POOL_TAG); @@ -190,22 +162,38 @@ InitializeUsbDevice(PVOID BusContext, PUSB_DEVICE_HANDLE DeviceHandle) return STATUS_NO_MEMORY; } + Buffer = ExAllocatePoolWithTag(NonPagedPool, PAGE_SIZE, USB_POOL_TAG); + + if (!Buffer) + { + DPRINT1("Out of memory\n"); + return STATUS_NO_MEMORY; + } + + Ptr = Buffer; + for (i = 0; i < UsbDevice->DeviceDescriptor.bNumConfigurations; i++) { /* Get the Device Configuration Descriptor */ CtrlSetup.bmRequestType._BM.Recipient = BMREQUEST_TO_DEVICE; CtrlSetup.bmRequestType._BM.Type = BMREQUEST_STANDARD; + CtrlSetup.bmRequestType._BM.Reserved = 0; CtrlSetup.bmRequestType._BM.Dir = BMREQUEST_DEVICE_TO_HOST; CtrlSetup.bRequest = USB_REQUEST_GET_DESCRIPTOR; CtrlSetup.wValue.LowByte = 0; CtrlSetup.wValue.HiByte = USB_CONFIGURATION_DESCRIPTOR_TYPE; CtrlSetup.wIndex.W = 0; CtrlSetup.wLength = PAGE_SIZE; - - ResultOk = ExecuteControlRequest(FdoDeviceExtension, &CtrlSetup, UsbDevice->Address, UsbDevice->Port, Buffer, PAGE_SIZE); + + SubmitControlTransfer(&FdoDeviceExtension->hcd, + &CtrlSetup, + Buffer, + PAGE_SIZE, + NULL); ConfigDesc = (PUSB_CONFIGURATION_DESCRIPTOR)Ptr; + //DumpFullConfigurationDescriptor(ConfigDesc); ASSERT(ConfigDesc->wTotalLength <= PAGE_SIZE); UsbDevice->Configs[i] = ExAllocatePoolWithTag(NonPagedPool, @@ -244,6 +232,26 @@ InitializeUsbDevice(PVOID BusContext, PUSB_DEVICE_HANDLE DeviceHandle) UsbDevice->ActiveInterface = UsbDevice->Configs[0]->Interfaces[0]; return STATUS_SUCCESS; + + /* Set the device address */ + CtrlSetup.bmRequestType._BM.Recipient = BMREQUEST_TO_DEVICE; + CtrlSetup.bmRequestType._BM.Type = BMREQUEST_STANDARD; + CtrlSetup.bmRequestType._BM.Reserved = 0; + CtrlSetup.bmRequestType._BM.Dir = BMREQUEST_HOST_TO_DEVICE; + CtrlSetup.bRequest = USB_REQUEST_SET_ADDRESS; + CtrlSetup.wValue.W = UsbDevice->Address; + CtrlSetup.wIndex.W = 0; + CtrlSetup.wLength = 0; + + DPRINT1("Setting Address to %x\n", UsbDevice->Address); + + SubmitControlTransfer(&FdoDeviceExtension->hcd, + &CtrlSetup, + NULL, + 0, + NULL); + + return STATUS_SUCCESS; } NTSTATUS @@ -256,7 +264,8 @@ GetUsbDescriptors(PVOID BusContext, PULONG ConfigDescriptorBufferLength) { PUSB_DEVICE UsbDevice; - DPRINT1("Ehci: GetUsbDescriptor %x, %x, %x, %x\n", DeviceDescriptorBuffer, *DeviceDescriptorBufferLength, ConfigDescriptorBuffer, *ConfigDescriptorBufferLength); + DPRINT1("Ehci: GetUsbDescriptor %x, %x, %x, %x\n", DeviceDescriptorBuffer, *DeviceDescriptorBufferLength, + ConfigDescriptorBuffer, *ConfigDescriptorBufferLength); UsbDevice = DeviceHandleToUsbDevice(BusContext, DeviceHandle); @@ -345,7 +354,7 @@ NTSTATUS USB_BUSIFFN RestoreUsbDevice(PVOID BusContext, PUSB_DEVICE_HANDLE OldDeviceHandle, PUSB_DEVICE_HANDLE NewDeviceHandle) { - DPRINT1("Ehci: RestoreUsbDevice called\n"); + DPRINT1("Ehci: RestoreUsbDevice not implemented! %x, %x, %x\n", BusContext, OldDeviceHandle, NewDeviceHandle); return STATUS_NOT_SUPPORTED; } @@ -353,7 +362,7 @@ NTSTATUS USB_BUSIFFN GetPortHackFlags(PVOID BusContext, PULONG Flags) { - DPRINT1("Ehci: GetPortHackFlags called\n"); + DPRINT1("Ehci: GetPortHackFlags not implemented. %x, %x\n", BusContext, Flags); return STATUS_NOT_SUPPORTED; } @@ -370,7 +379,8 @@ QueryDeviceInformation(PVOID BusContext, ULONG SizeNeeded; LONG i; - DPRINT1("Ehci: QueryDeviceInformation (%x, %x, %x, %d, %x\n", BusContext, DeviceHandle, DeviceInformationBuffer, DeviceInformationBufferLength, LengthReturned); + DPRINT1("Ehci: QueryDeviceInformation (%x, %x, %x, %d, %x\n", BusContext, DeviceHandle, DeviceInformationBuffer, + DeviceInformationBufferLength, LengthReturned); UsbDevice = DeviceHandleToUsbDevice(BusContext, DeviceHandle); @@ -409,7 +419,9 @@ QueryDeviceInformation(PVOID BusContext, for (i = 0; i < UsbDevice->ActiveInterface->InterfaceDescriptor.bNumEndpoints; i++) { - RtlCopyMemory(&DeviceInfo->PipeList[i].EndpointDescriptor, &UsbDevice->ActiveInterface->EndPoints[i]->EndPointDescriptor, sizeof(USB_ENDPOINT_DESCRIPTOR)); + RtlCopyMemory(&DeviceInfo->PipeList[i].EndpointDescriptor, + &UsbDevice->ActiveInterface->EndPoints[i]->EndPointDescriptor, + sizeof(USB_ENDPOINT_DESCRIPTOR)); } return STATUS_SUCCESS; } @@ -452,7 +464,7 @@ NTSTATUS USB_BUSIFFN ControllerSelectiveSuspend(PVOID BusContext, BOOLEAN Enable) { - DPRINT1("Ehci: ControllerSelectiveSuspend called\n"); + DPRINT1("Ehci: ControllerSelectiveSuspend not implemented\n"); return STATUS_NOT_SUPPORTED; } @@ -469,11 +481,13 @@ GetExtendedHubInformation(PVOID BusContext, PPDO_DEVICE_EXTENSION PdoDeviceExtension = (PPDO_DEVICE_EXTENSION)((PDEVICE_OBJECT)BusContext)->DeviceExtension; PFDO_DEVICE_EXTENSION FdoDeviceExntension = (PFDO_DEVICE_EXTENSION)PdoDeviceExtension->ControllerFdo->DeviceExtension; LONG i; - DPRINT1("Ehci: GetExtendedHubInformation BusContext %x, PDO %x\n", BusContext, HubPhysicalDeviceObject); + DPRINT1("Ehci: GetExtendedHubInformation BusContext %x, PDO %x, InformationBuffer %x\n", + BusContext, HubPhysicalDeviceObject, HubInformationBuffer); + /* Set the default return value */ *LengthReturned = 0; - DPRINT1("InformationLevel %x\n", UsbExtHubInfo->InformationLevel); + DPRINT("InformationLevel %x\n", UsbExtHubInfo->InformationLevel); /* Caller is suppose to have set InformationLevel to 0. However usbehci from MS seems to ignore this */ if (UsbExtHubInfo->InformationLevel != 0) @@ -486,7 +500,7 @@ GetExtendedHubInformation(PVOID BusContext, for (i=0; i < UsbExtHubInfo->NumberOfPorts; i++) { UsbExtHubInfo->Port[i].PhysicalPortNumber = i + 1; - UsbExtHubInfo->Port[i].PortLabelNumber = FdoDeviceExntension->ECHICaps.HCSParams.PortCount; + UsbExtHubInfo->Port[i].PortLabelNumber = FdoDeviceExntension->hcd.ECHICaps.HCSParams.PortCount; UsbExtHubInfo->Port[i].VidOverride = 0; UsbExtHubInfo->Port[i].PidOverride = 0; UsbExtHubInfo->Port[i].PortAttributes = USB_PORTATTR_SHARED_USB2; @@ -536,7 +550,7 @@ NTSTATUS USB_BUSIFFN Initialize20Hub(PVOID BusContext, PUSB_DEVICE_HANDLE HubDeviceHandle, ULONG TtCount) { - DPRINT1("Ehci: Initialize20Hub called, HubDeviceHandle: %x\n", HubDeviceHandle); + DPRINT1("Ehci: Initialize20Hub called, HubDeviceHandle: %x, TtCount %x\n", HubDeviceHandle, TtCount); /* FIXME: */ /* Create the Irp Queue for SCE */ /* Should queue be created for each device or each enpoint??? */ @@ -586,7 +600,7 @@ VOID USB_BUSIFFN SetDeviceHandleData(PVOID BusContext, PVOID DeviceHandle, PDEVICE_OBJECT UsbDevicePdo) { - DPRINT1("Ehci: SetDeviceHandleData called\n"); + DPRINT1("Ehci: SetDeviceHandleData not implemented %x, %x, %x\n", BusContext, DeviceHandle, UsbDevicePdo); } From 90ac7fad2f244f37a1ef2cd2994d4ac0fe68f548 Mon Sep 17 00:00:00 2001 From: Eric Kohl Date: Sat, 1 Jan 2011 12:40:24 +0000 Subject: [PATCH 175/181] [NPFS] - Add NpfsDirectoryControl routine in order to enumerate pipes. - Use NpfsGetFcb and NpfsGetCcb to retrieve the FCB or CCB and use SEH to protect these routines. svn path=/trunk/; revision=50250 --- reactos/drivers/filesystems/npfs/create.c | 7 + reactos/drivers/filesystems/npfs/dirctl.c | 250 +++++++++++++++++++ reactos/drivers/filesystems/npfs/npfs.c | 54 +++- reactos/drivers/filesystems/npfs/npfs.h | 27 ++ reactos/drivers/filesystems/npfs/npfs.rbuild | 2 + 5 files changed, 338 insertions(+), 2 deletions(-) create mode 100644 reactos/drivers/filesystems/npfs/dirctl.c diff --git a/reactos/drivers/filesystems/npfs/create.c b/reactos/drivers/filesystems/npfs/create.c index 8dac8e9f393..fe6834a04ca 100644 --- a/reactos/drivers/filesystems/npfs/create.c +++ b/reactos/drivers/filesystems/npfs/create.c @@ -121,6 +121,8 @@ NpfsOpenFileSystem(PNPFS_FCB Fcb, return; } + RtlZeroMemory(Ccb, sizeof(NPFS_CCB)); + Ccb->Type = CCB_DEVICE; Ccb->Fcb = Fcb; @@ -150,6 +152,8 @@ NpfsOpenRootDirectory(PNPFS_FCB Fcb, return; } + RtlZeroMemory(Ccb, sizeof(NPFS_CCB)); + Ccb->Type = CCB_DIRECTORY; Ccb->Fcb = Fcb; @@ -881,6 +885,9 @@ NpfsClose(PDEVICE_OBJECT DeviceObject, { DPRINT("Closing the root directory!\n"); + if (Ccb->u.Directory.SearchPattern.Buffer != NULL) + ExFreePool(Ccb->u.Directory.SearchPattern.Buffer); + ExFreePool(Ccb); FileObject->FsContext = NULL; FileObject->FsContext2 = NULL; diff --git a/reactos/drivers/filesystems/npfs/dirctl.c b/reactos/drivers/filesystems/npfs/dirctl.c new file mode 100644 index 00000000000..24370e1dbc6 --- /dev/null +++ b/reactos/drivers/filesystems/npfs/dirctl.c @@ -0,0 +1,250 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS kernel + * FILE: drivers/filesastems/npfs/dirctl.c + * PURPOSE: Named pipe filesystem + * PROGRAMMER: Eric Kohl + */ + +/* INCLUDES ******************************************************************/ + +#include "npfs.h" + +#define NDEBUG +#include + +/* FUNCTIONS *****************************************************************/ + +static NTSTATUS +NpfsQueryDirectory(PNPFS_CCB Ccb, + PIRP Irp, + PULONG Size) +{ + PIO_STACK_LOCATION Stack; + LONG BufferLength = 0; + PUNICODE_STRING SearchPattern = NULL; + FILE_INFORMATION_CLASS FileInformationClass; + ULONG FileIndex = 0; + PUCHAR Buffer = NULL; + BOOLEAN First = FALSE; + PLIST_ENTRY CurrentEntry; + PNPFS_VCB Vcb; + PNPFS_FCB PipeFcb; + ULONG PipeIndex; + BOOLEAN Found = FALSE; + NTSTATUS Status = STATUS_SUCCESS; + PFILE_NAMES_INFORMATION NamesBuffer; + PFILE_DIRECTORY_INFORMATION DirectoryBuffer; + + Stack = IoGetCurrentIrpStackLocation(Irp); + + /* Obtain the callers parameters */ + BufferLength = Stack->Parameters.QueryDirectory.Length; + SearchPattern = Stack->Parameters.QueryDirectory.FileName; + FileInformationClass = Stack->Parameters.QueryDirectory.FileInformationClass; + FileIndex = Stack->Parameters.QueryDirectory.FileIndex; + + DPRINT("SearchPattern: %p '%wZ'\n", SearchPattern, SearchPattern); + + /* Determine Buffer for result */ + if (Irp->MdlAddress) + { + Buffer = MmGetSystemAddressForMdl(Irp->MdlAddress); + } + else + { + Buffer = Irp->UserBuffer; + } + + /* Build the search pattern string */ + DPRINT("Ccb->u.Directory.SearchPattern.Buffer: %p\n", Ccb->u.Directory.SearchPattern.Buffer); + if (Ccb->u.Directory.SearchPattern.Buffer == NULL) + { + First = TRUE; + + if (SearchPattern != NULL) + { + Ccb->u.Directory.SearchPattern.Buffer = + ExAllocatePool(NonPagedPool, SearchPattern->Length + sizeof(WCHAR)); + if (Ccb->u.Directory.SearchPattern.Buffer == NULL) + { + return STATUS_INSUFFICIENT_RESOURCES; + } + + Ccb->u.Directory.SearchPattern.Length = SearchPattern->Length; + Ccb->u.Directory.SearchPattern.MaximumLength = SearchPattern->Length + sizeof(WCHAR); + RtlCopyMemory(Ccb->u.Directory.SearchPattern.Buffer, + SearchPattern->Buffer, + SearchPattern->Length); + Ccb->u.Directory.SearchPattern.Buffer[SearchPattern->Length / sizeof(WCHAR)] = 0; + } + else + { + Ccb->u.Directory.SearchPattern.Buffer = + ExAllocatePool(NonPagedPool, 2 * sizeof(WCHAR)); + if (Ccb->u.Directory.SearchPattern.Buffer == NULL) + { + return STATUS_INSUFFICIENT_RESOURCES; + } + + Ccb->u.Directory.SearchPattern.Length = sizeof(WCHAR); + Ccb->u.Directory.SearchPattern.MaximumLength = 2 * sizeof(WCHAR); + Ccb->u.Directory.SearchPattern.Buffer[0] = L'*'; + Ccb->u.Directory.SearchPattern.Buffer[1] = 0; + } + } + DPRINT("Search pattern: '%wZ'\n", &Ccb->u.Directory.SearchPattern); + + /* Determine the file index */ + if (First || (Stack->Flags & SL_RESTART_SCAN)) + { + FileIndex = 0; + } else if ((Stack->Flags & SL_INDEX_SPECIFIED) == 0) + { + FileIndex = Ccb->u.Directory.FileIndex + 1; + } + DPRINT("FileIndex: %lu\n", FileIndex); + + DPRINT("Buffer = %p tofind = %wZ\n", Buffer, &Ccb->u.Directory.SearchPattern); + + PipeIndex = 0; + + Vcb = Ccb->Fcb->Vcb; + CurrentEntry = Vcb->PipeListHead.Flink; + while (CurrentEntry != &Vcb->PipeListHead && Found == FALSE) + { + /* Get the FCB of the next pipe */ + PipeFcb = CONTAINING_RECORD(CurrentEntry, + NPFS_FCB, + PipeListEntry); + + /* Make sure it is a pipe FCB */ + ASSERT(PipeFcb->Type == FCB_PIPE); + + DPRINT("PipeName: %wZ\n", &PipeFcb->PipeName); + + if (FsRtlIsNameInExpression(&Ccb->u.Directory.SearchPattern, + &PipeFcb->PipeName, + TRUE, + NULL)) + { + DPRINT("Found pipe: %wZ\n", &PipeFcb->PipeName); + + if (PipeIndex >= FileIndex) + { + switch (FileInformationClass) + { + case FileDirectoryInformation: + DirectoryBuffer = (PFILE_DIRECTORY_INFORMATION)Buffer; + DirectoryBuffer->NextEntryOffset = 0; + DirectoryBuffer->FileIndex = PipeIndex; + DirectoryBuffer->FileAttributes = FILE_ATTRIBUTE_NORMAL; + DirectoryBuffer->EndOfFile.QuadPart = PipeFcb->CurrentInstances; + DirectoryBuffer->AllocationSize.LowPart = PipeFcb->MaximumInstances; + DirectoryBuffer->FileNameLength = PipeFcb->PipeName.Length; + RtlCopyMemory(DirectoryBuffer->FileName, + PipeFcb->PipeName.Buffer, + PipeFcb->PipeName.Length); + *Size = sizeof(FILE_DIRECTORY_INFORMATION) + PipeFcb->PipeName.Length - 1; + Status = STATUS_SUCCESS; + break; + + case FileNamesInformation: + NamesBuffer = (PFILE_NAMES_INFORMATION)Buffer; + NamesBuffer->NextEntryOffset = 0; + NamesBuffer->FileIndex = PipeIndex; + NamesBuffer->FileNameLength = PipeFcb->PipeName.Length; + RtlCopyMemory(NamesBuffer->FileName, + PipeFcb->PipeName.Buffer, + PipeFcb->PipeName.Length); + *Size = sizeof(FILE_NAMES_INFORMATION) + PipeFcb->PipeName.Length - 1; + Status = STATUS_SUCCESS; + break; + + default: + DPRINT1("Invalid information class: %lu\n", FileInformationClass); + Status = STATUS_INVALID_INFO_CLASS; + break; + } + + Ccb->u.Directory.FileIndex = PipeIndex; + Found = TRUE; + +// if (Stack->Flags & SL_RETURN_SINGLE_ENTRY) +// return STATUS_SUCCESS; + + break; + } + + PipeIndex++; + } + + CurrentEntry = CurrentEntry->Flink; + } + + if (Found == FALSE) + Status = STATUS_NO_MORE_FILES; + + return Status; +} + + +NTSTATUS NTAPI +NpfsDirectoryControl(PDEVICE_OBJECT DeviceObject, + PIRP Irp) +{ + PIO_STACK_LOCATION IoStack; + PFILE_OBJECT FileObject; + PNPFS_CCB Ccb; + PNPFS_FCB Fcb; + NTSTATUS Status; + ULONG Size = 0; + + DPRINT("NpfsDirectoryControl() called\n"); + + IoStack = IoGetCurrentIrpStackLocation(Irp); + + FileObject = IoStack->FileObject; + + if (NpfsGetCcb(FileObject, &Ccb) != CCB_DIRECTORY) + { + Status = STATUS_INVALID_PARAMETER; + + Irp->IoStatus.Status = Status; + Irp->IoStatus.Information = 0; + + IoCompleteRequest(Irp, IO_NO_INCREMENT); + + return Status; + } + + Fcb = Ccb->Fcb; + + switch (IoStack->MinorFunction) + { + case IRP_MN_QUERY_DIRECTORY: + Status = NpfsQueryDirectory(Ccb, + Irp, + &Size); + break; + + case IRP_MN_NOTIFY_CHANGE_DIRECTORY: + DPRINT1("IRP_MN_NOTIFY_CHANGE_DIRECTORY\n"); + Status = STATUS_NOT_IMPLEMENTED; + break; + + default: + DPRINT1("NPFS: MinorFunction %d\n", IoStack->MinorFunction); + Status = STATUS_INVALID_DEVICE_REQUEST; + break; + } + + Irp->IoStatus.Status = Status; + Irp->IoStatus.Information = Size; + + IoCompleteRequest(Irp, IO_NO_INCREMENT); + + return Status; +} + +/* EOF */ diff --git a/reactos/drivers/filesystems/npfs/npfs.c b/reactos/drivers/filesystems/npfs/npfs.c index 74fe99baeb6..dfe4ed9e4b1 100644 --- a/reactos/drivers/filesystems/npfs/npfs.c +++ b/reactos/drivers/filesystems/npfs/npfs.c @@ -44,8 +44,8 @@ DriverEntry(PDRIVER_OBJECT DriverObject, NpfsQueryVolumeInformation; DriverObject->MajorFunction[IRP_MJ_CLEANUP] = NpfsCleanup; DriverObject->MajorFunction[IRP_MJ_FLUSH_BUFFERS] = NpfsFlushBuffers; - // DriverObject->MajorFunction[IRP_MJ_DIRECTORY_CONTROL] = - // NpfsDirectoryControl; + DriverObject->MajorFunction[IRP_MJ_DIRECTORY_CONTROL] = + NpfsDirectoryControl; DriverObject->MajorFunction[IRP_MJ_FILE_SYSTEM_CONTROL] = NpfsFileSystemControl; // DriverObject->MajorFunction[IRP_MJ_QUERY_SECURITY] = @@ -100,4 +100,54 @@ DriverEntry(PDRIVER_OBJECT DriverObject, return STATUS_SUCCESS; } + +FCB_TYPE +NpfsGetFcb(PFILE_OBJECT FileObject, + PNPFS_FCB *Fcb) +{ + PNPFS_FCB LocalFcb = NULL; + FCB_TYPE FcbType = FCB_INVALID; + + _SEH2_TRY + { + LocalFcb = (PNPFS_FCB)FileObject->FsContext; + FcbType = LocalFcb->Type; + } + _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) + { + LocalFcb = NULL; + FcbType = FCB_INVALID; + } + _SEH2_END; + + *Fcb = LocalFcb; + + return FcbType; +} + + +CCB_TYPE +NpfsGetCcb(PFILE_OBJECT FileObject, + PNPFS_CCB *Ccb) +{ + PNPFS_CCB LocalCcb = NULL; + CCB_TYPE CcbType = CCB_INVALID; + + _SEH2_TRY + { + LocalCcb = (PNPFS_CCB)FileObject->FsContext2; + CcbType = LocalCcb->Type; + } + _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) + { + LocalCcb = NULL; + CcbType = CCB_INVALID; + } + _SEH2_END; + + *Ccb = LocalCcb; + + return CcbType; +} + /* EOF */ diff --git a/reactos/drivers/filesystems/npfs/npfs.h b/reactos/drivers/filesystems/npfs/npfs.h index 2e47e6858c4..0049fd3fdac 100644 --- a/reactos/drivers/filesystems/npfs/npfs.h +++ b/reactos/drivers/filesystems/npfs/npfs.h @@ -3,9 +3,11 @@ #include #include +#include typedef enum _FCB_TYPE { + FCB_INVALID, FCB_DEVICE, FCB_DIRECTORY, FCB_PIPE @@ -13,6 +15,7 @@ typedef enum _FCB_TYPE typedef enum _CCB_TYPE { + CCB_INVALID, CCB_DEVICE, CCB_DIRECTORY, CCB_PIPE @@ -55,6 +58,14 @@ typedef struct _NPFS_FCB LARGE_INTEGER TimeOut; } NPFS_FCB, *PNPFS_FCB; + +typedef struct _NPFS_CCB_DIRECTORY_DATA +{ + UNICODE_STRING SearchPattern; + ULONG FileIndex; +} NPFS_CCB_DIRECTORY_DATA, *PNPFS_CCB_DIRECTORY_DATA; + + typedef struct _NPFS_CCB { LIST_ENTRY CcbListEntry; @@ -79,6 +90,12 @@ typedef struct _NPFS_CCB ULONG MaxDataLength; FAST_MUTEX DataListLock; /* Data queue lock */ + + union + { + NPFS_CCB_DIRECTORY_DATA Directory; + } u; + } NPFS_CCB, *PNPFS_CCB; typedef struct _NPFS_CONTEXT @@ -130,6 +147,9 @@ NTSTATUS NTAPI NpfsCleanup(PDEVICE_OBJECT DeviceObject, PIRP Irp); DRIVER_DISPATCH NpfsClose; NTSTATUS NTAPI NpfsClose(PDEVICE_OBJECT DeviceObject, PIRP Irp); +DRIVER_DISPATCH NpfsDirectoryControl; +NTSTATUS NTAPI NpfsDirectoryControl(PDEVICE_OBJECT DeviceObject, PIRP Irp); + DRIVER_DISPATCH NpfsRead; NTSTATUS NTAPI NpfsRead(PDEVICE_OBJECT DeviceObject, PIRP Irp); @@ -159,5 +179,12 @@ PNPFS_FCB NpfsFindPipe(PNPFS_VCB Vcb, PUNICODE_STRING PipeName); +FCB_TYPE +NpfsGetFcb(PFILE_OBJECT FileObject, + PNPFS_FCB *Fcb); + +CCB_TYPE +NpfsGetCcb(PFILE_OBJECT FileObject, + PNPFS_CCB *Ccb); #endif /* __DRIVERS_FS_NP_NPFS_H */ diff --git a/reactos/drivers/filesystems/npfs/npfs.rbuild b/reactos/drivers/filesystems/npfs/npfs.rbuild index a9030bfc8e6..945dd4cb8ce 100644 --- a/reactos/drivers/filesystems/npfs/npfs.rbuild +++ b/reactos/drivers/filesystems/npfs/npfs.rbuild @@ -4,7 +4,9 @@ . ntoskrnl hal + pseh create.c + dirctl.c finfo.c fsctrl.c npfs.c From d50bc6057e83f8d2f08152bcd561d6914adff267 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Sat, 1 Jan 2011 13:50:07 +0000 Subject: [PATCH 176/181] [CRT] Fix bugs in new printf implementation: use buffer size in _snprintf and check for the right failure return value of streamout_char. svn path=/trunk/; revision=50251 --- reactos/lib/sdk/crt/printf/_snprintf.c | 4 ++-- reactos/lib/sdk/crt/printf/streamout.c | 24 ++++++++++++------------ 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/reactos/lib/sdk/crt/printf/_snprintf.c b/reactos/lib/sdk/crt/printf/_snprintf.c index b8bd5370c56..c8af4898015 100644 --- a/reactos/lib/sdk/crt/printf/_snprintf.c +++ b/reactos/lib/sdk/crt/printf/_snprintf.c @@ -23,7 +23,7 @@ _snprintf(char *buffer, size_t count, const char *format, ...) stream._base = buffer; stream._ptr = stream._base; stream._charbuf = 0; - stream._bufsiz = (unsigned long)-1; + stream._bufsiz = count; stream._cnt = stream._bufsiz; stream._flag = 0; stream._tmpfname = 0; @@ -31,7 +31,7 @@ _snprintf(char *buffer, size_t count, const char *format, ...) va_start(argptr, format); result = streamout(&stream, format, argptr); va_end(argptr); - + *stream._ptr = '\0'; return result; } diff --git a/reactos/lib/sdk/crt/printf/streamout.c b/reactos/lib/sdk/crt/printf/streamout.c index 53bfebafc42..ee7755dc626 100644 --- a/reactos/lib/sdk/crt/printf/streamout.c +++ b/reactos/lib/sdk/crt/printf/streamout.c @@ -109,7 +109,7 @@ format_float( digits = digits_u; case _T('g'): if (exponent < -4 || exponent >= precision) goto case_e; - break; + break; case _T('E'): digits = digits_u; @@ -118,7 +118,7 @@ format_float( fpval /= pow(10., exponent); val32 = exponent >= 0 ? exponent : -exponent; - // FIXME: handle length of exponent field: + // FIXME: handle length of exponent field: // http://msdn.microsoft.com/de-de/library/0fatw238%28VS.80%29.aspx num_digits = 3; while (num_digits--) @@ -175,7 +175,7 @@ format_float( { fpval *= pow(10., precision); val64 = (__int64)(fpval + 0.5); - + while (num_digits-- > 0) { *--(*string) = digits[val64 % 10]; @@ -297,11 +297,11 @@ streamout(FILE *stream, const TCHAR *format, va_list argptr) if (chr == _T('\0')) break; /* Check for 'normal' character or double % */ - if ((chr != _T('%')) || + if ((chr != _T('%')) || (chr = *format++) == _T('%')) { /* Write the character to the stream */ - if ((written = streamout_char(stream, chr)) == -1) return -1; + if ((written = streamout_char(stream, chr)) == 0) return -1; written_all += written; continue; } @@ -344,13 +344,13 @@ streamout(FILE *stream, const TCHAR *format, va_list argptr) if (chr == '.') { chr = *format++; - + if (chr == _T('*')) { precision = va_arg(argptr, int); chr = *format++; } - else + else { precision = 0; while (chr >= _T('0') && chr <= _T('9')) @@ -578,7 +578,7 @@ streamout(FILE *stream, const TCHAR *format, va_list argptr) { for (; padding > 0; padding--) { - if ((written = streamout_char(stream, _T(' '))) == -1) return -2; + if ((written = streamout_char(stream, _T(' '))) == 0) return -1; written_all += written; } } @@ -595,7 +595,7 @@ streamout(FILE *stream, const TCHAR *format, va_list argptr) if ((flags & FLAG_ALIGN_LEFT) == 0) precision += padding; while (precision-- > 0) { - if ((written = streamout_char(stream, _T('0'))) == -1) return -4; + if ((written = streamout_char(stream, _T('0'))) == 0) return -1; written_all += written; } @@ -611,7 +611,7 @@ streamout(FILE *stream, const TCHAR *format, va_list argptr) /* Optional right '0' padding */ while (precision-- > 0) { - if ((written = streamout_char(stream, _T('0'))) == -1) return -6; + if ((written = streamout_char(stream, _T('0'))) == 0) return -1; written_all += written; len++; } @@ -622,11 +622,11 @@ streamout(FILE *stream, const TCHAR *format, va_list argptr) { while (padding-- > 0) { - if ((written = streamout_char(stream, _T(' '))) == -1) return -7; + if ((written = streamout_char(stream, _T(' '))) == 0) return -1; written_all += written; } } - + } if (written == -1) return -8; From 05721dae3e376193cba36a623c77502f46031442 Mon Sep 17 00:00:00 2001 From: Colin Finck Date: Sat, 1 Jan 2011 15:54:31 +0000 Subject: [PATCH 177/181] Proper fix for r50248 ;-) Happy New Year from my side as well! svn path=/trunk/; revision=50254 --- reactos/include/reactos/version.h | 2 +- reactos/ntoskrnl/inbv/logo/1.bmp | Bin 20504 -> 21624 bytes 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/reactos/include/reactos/version.h b/reactos/include/reactos/version.h index a6b5e117d9e..20c51ff487f 100644 --- a/reactos/include/reactos/version.h +++ b/reactos/include/reactos/version.h @@ -21,7 +21,7 @@ #define KERNEL_VERSION_MINOR 4 #define KERNEL_VERSION_PATCH_LEVEL 0 -#define COPYRIGHT_YEAR "2010" +#define COPYRIGHT_YEAR "2011" /* KERNEL_VERSION_BUILD_TYPE is L"SVN", L"RC1", L"RC2" or L"" (for the release) */ #define KERNEL_VERSION_BUILD_TYPE L"SVN" diff --git a/reactos/ntoskrnl/inbv/logo/1.bmp b/reactos/ntoskrnl/inbv/logo/1.bmp index d13c48d16c07e2c5fb1d83be380c54637d2ddcf5..c8273826e8d3cf79eed09a86019ded74577c8e96 100644 GIT binary patch literal 21624 zcmeI4e{@^tdEZ}LzP`RfaKHQg_Z{>f*$mG}8RmHd~#tj2%+pQ~plM%2u| zn^gb##c!!UtNeSlT&<|TSgEROKlr|S_rL#*YVhxC;QYV(yF*#6TB$qlSLb|n_QnH`>xui>lW3!c3r)z_B`%91r5Zo zH+QIpTh*g*BRDtQ%~pQfn`%aA>pjoo1s`wH6`A9$Pq!MX0o`|;8&7e?MF;lZRv$NH zMP#l--c9u>UiZtVZfG;0>)cFtkGa-YVRf$`d=KS!OY~Pfz*5-$Q;PDXTUi7-%nmsKZ5oqv=52Q?*!CbzP^dD2<)nBy$$szfo;25)ybhfLuXXDZFA4#f{Ls^ zlHZQCdG_&e;8UG>=N0wM`_)!rD z@zFbY(svCt~;07pJ@yUt=54zgw`~Y zb$0pRRPVh0F88%Qf`>=B>OVnE=~mU@Z-!oY&ux8V^Q%4-oANoW>eHL}u#3fi$2!;j zKZMEwK}`gDyYJUpeml-*@_Ce3LtP9s^@&C+iLsW+uk&s*MhmG!CZPm$@s zPCVZrrk(3p9J_UH65_@hL^M2ybkTYmit$#}>c47UT&3@O72CGr!_KB%e^X==?`fzt zI1%ifn7!eqRrI+48?Rn$xnj)wu4o{n%BV}B#>Q}+(pPk(YK^j~5w)Y~INAARF* z+dhbzePBp#A>xdG!i#S8<>%S!J3sAT@ui5VF1x zi+s^srde;e1F?xv*qbuZ^s{h zZg&1zdNuqsz@tM6(dUy}txt!2rMG(NAhdmj_s$TBkxZ#u&V_wzQ9k!2x84;gEByy9 z?>_33tru^`QuZGIU9ziXM}6xC*ykePY`KDCeU;C?33s6I%|~4B6-;Y3T(+Km^Cpf& zLRt^9{W<@}ab>0J{wv%ck-j4DhSL1D-zI0%zwP0@d%joQdCqV23a>`~c*|^g{#RYq zmR7oKeG8gyxcp+TI#_;bmkysgp}Ox<37tLu4VSy^PJc`2+E=J?{0`siZy7quK1Y|s z9rjoK|0drAbeu1gU+Sge+y#{f&Z`=M2^L@+fH=1<7b#5!qKOmO>nev|){80Hj@~z!ce*Ob=?niUNLCAkc z>bPyy%^CxGj|(0270?m-^8G&e;dsy+78XWXz;>i*Wi8Z15*NC<>he;?P% z%0k(?{FGv~p}+Aba{t$Fl0~d>#cw?0?A$Ne!Q8HP@4p@X<^C_f2!Hl%<(F>qHabJc zA);+TaNcP3#j<}3!6`pr5Psn$LHGjxyQ>Kh?sv#J4HsT@{hdI9S5U#<)`mzU))j6( zHZNI-n0tN~OKc*U!FoloUU*lqZ2xhLB3L$p?b=7K_)uB2EH<`2r^#pY-Md&4pP$4+ za^2Z2L5lc8xBIUMk_ae19oXn*B;i1R*}f&05n<66d{^BcSU7UOuPpx^!P)j@-rp1> zH{(fET3-k6{I#7-B6zL-msA7}xKm#-eQgkFSKv(U5B`e!L(RD6vzs(W&in$HU;E)L zm=1U?#GGUV$A8<6T89sy5Y)EA1i;J3`Zn(8?^Gb zZ$%4}(aFe>pLou1T$DJBSh>3Yy&;K$5QX@M$HWJ=v+uWdvafh+`P-7q%isRXTjabS z|Nj@}90ibYV)ZY~%U$7HYO{Raa{}A;2KOO>^O^EX4^Y*Ae!HrN zp<}4dziA}1T3z4z!EwVK*T>;Xx{daKv(s%r`JbwvFMoIY`Y2iMh8x_0t#6m!haC1r zI-ke4ufcxydfrvPYH<1XBhqKRNS~$jZL`Gei`SsuP+!6ldZ(YWC(6%un||*9exJ;w z!nHytmF4PCLo^1rbe18@wPRN3S9mYK9T&%QxA=C8l&$PoTLKeU2g0#m|b= zXvRzIkN3Ii5ItZlegK$s(VnuFbcH!Z!ArWbUSnEJZ!(ZBwpUe@PZRt5V=_I9hhjbP z#6WIpPPtVTt`sv|&$a4rn%9S`)>4#vX7b7Yp8c*mNWKWg`+Ek`Qz}x`OW~?=iut6= z^>UBh#^-j`nu-+llv7oaVkU8*-@O})#(EAUyh*33E0LmAvAJ(1-xreD(gvlVy+}eu zl3t2SKnWL;{fYhRlgct$9mpBv;pc)uqBQ!H^sojish4MK7uBgmu7) zS#fOPc&S{G`*Z~xDc$GZ0lkoXqX&eBE<#l&to>ZyV<)tS{--LLkjc55%4)McClQI+ zA<%mgUaHA^s8k; zCPN@As-_)k!(KJFs`&9{X{QML6WnWMK{ur_nFxAV|d}27KbU|nJxC)OB zd%yHqg=WQL@O-pDbd$Q9?megC(7ar4tmpgSUC`aoz*OC@Rp%VM8_&n@q6roDhH)O` zV(kVUT~JPTd~{f!Qk|oxeknayHP~no-|NAl@boZIV1uEe)z|$-g_r|fUUo6^`f_cF&<->dPV^+wa{!SC zbTJ#wNVEV%ZC}q1xsqvlMMK`y>;5{i=i#w}Zja@P5@U8HDWa*a?BoTM@P1~Pm>X9} z)iFArOkJ+6Gxw1crb8wIB%&lPGup#fO-v0J>Ax!(BOA2h9l2`5uVfPagtChEU=;#N z?Ebl>(61gTaB_9*Slvi?YTY9-B86e*mR86RMOjRqFtC?;*3vUY4UuP)Uon1IeYud;V?rZC#ze!BVxIVPJBitrl=wSdc`UTu zTf{>Lr>e!O_#r&lZmf-zroyS>WVO!XMRi{EzEUmEFO@GUcJJVogXDGOjuh@V=Bm6UPkiV7G_v znyTbIuw9x4w&{BWJ5JS_DV3Mk4EJ^;pQ6^PpUR~D#>Uc2E?b-|dg;qBT_R47De6#s z;7rw{WIYiQjsvbgJy-Dtsx!x>8+FN|rWoRt4#0J|w%;#c%B!kld37;$1+Gg0*IlPl zmtmT}vSXvYO`S|ulj!jDwock(pN8iFF{q2jP|t7*rL#FbiT!4w5NLjHW2;oXy7oPf z=@mLgC-G9o3*gDbhkJ(=A_ALwX5Y4-V-n7z2^{SekREDV>swB{06&DE+q#}RP(W>hT3B%tNG->6f#6b z2IYOjlO^cb=mu8BN)Dk<3eerwaJBfkx zE)6G^tCG2uBbuUOy6%n~tR=%M$btXYtcJwXM(r){1!RHZRTa5VzEtr}NS@!gRHCZb zSsPih{|Y*Ea#IySMMXxMH%z5JQ_WD%lp_*Bi)w2miioGqmi2;#JW#4THTv*CYj$m8 zS+adJ&&mgz6LUg|Dlkfx%38hj5WCdoF79vY&S^VSF>*~+JVT4T6nKDG$Sp4{i)2!z zbWLQ_7gJKz8nsnrUsdkvpL*hO679M$Efv`&TUn=tn&r(I*$B8kp@wW7p*X(RpE$X6 zx?3{wUZcf8EL5m#9ES+#*z4Xo@dn)xt931}eh+78puowZklL2aMly0?2YGK%daeqw z51oKk8%^8({*x6lF0{6_sI!wurpp&JS`>N>Uw-CKVy{McSECNDCw{1llRAf7)sSc&+d2H2Kzl4|C zTv^QFgC^JKvb|Cx+S}6AR}=ArQ#a`kb3y0RLdTIjBQ-Hg^oySpOwg$}=`=FuY#)n7 z>b1sO-WAEs8!Pjr8Dydt$;GqQ6VT{@#xsd{YU*PDP15w7L33>ftNDJYP)CgaSt5^9 zDoZqpKlpW-h%KJ5eFxw6w=z$PXVk8WJoJ${OogS|vrQ_e`{DAWI+r2;c9MOniN1KMy4d52r{UQh{U@rKzLtc9t4u0vavU*a^c9{hBMnX_ zbZ(?viJi=ILc?j0=-?%KVQu}?iJ1b$*ODnlhvbArUrTy!vB%T^s36I`m^_p?SvlPc zg-(|SWth@}uCTbQ*)!+BHr7y`#7TL!bZM=A%_|a(;<>p9_BQBVburOxtZvW^|Kd*} zyf;JV%zm?2B8?@=3zF3Y{aRW$zkxO2d>@>zTq@1aE!1n7wCNnMgw9Cz#h<2LO}K*J zw}amX{;^QtwcrQq8&d(q)P7wo-N?Kkl=yvCDlytwT_&@(mzJt){##xyJF3U<+1`K# zKI_sg?9%8IKT3qmPl*dB@es1(ujn5QiS}PRDH^(lA4!(B*6E(QL`};z>M|8_41cno z5c~wb)F0|d<5Al(8~}MbsoDmnsPIbGMFgyhlxCM#YhqjDsltEYvBbyT+D4^%6#^HQ z>u-6F>G2@8$FpOU87o6x7hkGCLQ1B|kl5mmwuDrew!|5J;zwS(U}76fh#eLm78&vn zJ3bVM?C<5OWjX7A6#_*#|UnnlCshJWs zAP`Kn4I69QH&S&1TGwq>LYb*c^H7K`)Ycz*EITS)qMaSb++#@bxX>~A(2a@L_BQDp z2s|~Epn~?{O~VC+EhHB3C$Yu(M@5bd^FB=- z4dbsaD}u$ucIVP9H1fTn!~n&gb#yAQ2LU0OBZxJuEw&*8A|XDNKRHkKn^cjxwRLX{ zIz-2qh7S3s%NYE)OJ>J`ckJGDTMS=G%2G9FB$3EyFsH{BXT|F86B%LO#;=Hvt{dJI zO;@qBfG|idRk*1!i%DO zNP=?k`pcL{dayAYe-kQSf{MhZYWiAJnol-;Esg_Z2C~L5c(Z8B*hSw+w~IF$Nt7*q zK^CwxUzCnWxw**;wbzCV*)UX8cj0$HM~404Wav$3ys6YDBts&e*aY_~PR=3*n%R*e zbFM>TvZmszS8H|unpZ-z*nMJlZA-k&5t~Pf&kC$gswf8eN;P>*umk+S=64RvkyJ@9 zQlW@G@E0Xg^!0Qn7MK2^wn1liN3Gt-Q~l@xO|;;_w%DQ|F@oR1sxkOB{#~LRkNxuG zNx`2m{0ANyWRx!Qma)O|YMr_v++*j-+1i#z7pLyRX~&WK0SS#h)k5Dmu)oRsT|vH5 z@nkwb2Jb<270#bDoS*125pJ)leGE6?y2v$`>)%a5gXsgv-1KV$Q+cEGx!+H8H@W8A z0;_O|Z5D`Ozd{THOr*7cwS65_>8xhXG zSe7oZyg=bT!3>W4nww_T!U9tcQcS%%(7nxhXuveFp&sEpE*b$mbI$ZMnHK`i>CRX6 zvT`phEQ`J`*<}@7so^{HWOU@L{s$7&{2s!HUxNHYMUOBrS4=X^x<@j*ama z$I0u`ZpG+2#+cI-DIce<7@lvW_Zgn8jVKJ8wKvnD%(-Tz5Bu+V^Gqa(g5qzwqKV2t zLT10bqEcToy%w`Onf*+Zmj9dszQXOev12 zsh3T!pbNiiu#LL~JR2=LOi|hlwo{t@ehOq$dlnzvi{#V?{qmj8nvnWU)vI>=zG?hN`UWyHL;jleFK`j{< zLB*4{xx#vqqGe%s{Pjt}_LMN@v3> z(y*Cg-M5K0*&|T*}?l!po{qM_}E1LVSj@fFt5Uw{uI@zeMm1@%a?RD!Zb&wETU=g zIbW>ioM%`m8d*%!1L&0T2-z3p#fmy{51`%)jrDoDxyXf#Og052F7-yQE;DVnFD)_6 zShD7+2{r>NlrEi1F!{K_N)lS_)Qn;-jaRsW&Hkm`miUNdtnhTIURyD>u!2fh(4u6$ zhA#BlD$_Ij60>YQ7cN=z?BB1Ld6cYOoXi!pEc%FMa)s10UZ0@K>yA*rJ)X@!0?(z% z5{^;Z07tKqS(%NjQ3v4KUW%3+nL3dPERo;FZXEkn&YS5%N}{5P)*gy|cr53=P+KXn zCW@B4EA@@)CB;sY*eJZb%0Jn!Yw}4=*G!L?o>}biBTCSJ2D;W;%mwM|YD}Nr^9l*H zAynRFpTcdIjFGBu%+E~EOcTis>uUIdQ?;+6;qZm(Qgx1rkuwu9dO(`BCg0Q#(}_Ba z8M5pX^?@dc`$9UKdAPAsnwgl){9AurX1R8C4qalb>Lqr%FR({6XP4Ybhe^~d!ya*r zrdM=bKS{D=?C_e`M>!MB>tt`8MG;FxIi2*3ccpgq!rZJ4V;Ar)(SSf(7wkEW2Ey!! zg4~=f7#)Wj`Yu@Hf~EDaFCPR1NcUl4)F&IfZzj z%yxHWUp$MiVTHBE=|rz^D6g)T%*n>eOd&UU>MT(kEwQIRrR&(IN1n%y})Ipd-+_6zI+6FX)TIXwX; zx?7R?tI64~{r1LcnK4*0A$Vvm5=z`#TbYrnRXp`vgRK&FVJx^}6$+ZXumDp`hq)|Q zg$t9cV&zN=U6G&?J4n5@Dzo{^>kNyGodr3bcoH*nPo&^AHs;ZoTMW-&QRzd*sjp-7 ztJC7^GHKVVQl~*{&n&N&=NFir^@?SAb+sifug_C#e(xl#QWeQu%y2u=oFF-)tdJ?H z5-ldW!Lm0@|I_~3Z-8|{CIEs(oFMPP%a=-U<>tKS*!<0!m7>@)-qakc;PEh>1)qUP ze6K|CH5%6Rs!S2XMOox+=LzsmRF`De&3O=OfUC!3%7G7J1$K*UnQF4%tn{f7eul@g zcpqcY$O4(9i`7kLpOn#07G*q0n-uE8|R;OYXrMzZ#(ik})C9vRK% zz(f0bWi`A)zq6qBt&~}jz4jX`rSnXi@xx{o;?zL3VpbsGQ%`QZj4|OVJGM{O%fjEN zeN;saUYT6F8eJjxbc)=UO3$#vm+TW9GH+B?&+K$be-eJM_Se(nDuOiytKHbcI%*qP z5w*NPqz2Vv0Zm#9PFZy=)ElSDr6=xWtccXjI?=_HshS@i&1TY=MLDC^(eS9OXUv*L z)=cA28MYqOM^$8SlwO6*ORcNndkYrW=wRP`X`$|a_v`aRteF{L?O@A%nD z*-JheHyn?Gsq9lDr<5L1@uPzyM-4DMlV5FOPdNxsmb%q7yXId{&v(Z?8Ncl!qtoPv zk7ggdygm)oh&2j-dUUvJ)E>4@=@I>q9^?~eEH^3qN|onlc?FLzQ|(Hs^FP)b-pkTC zqhZknReo=%2Mr%@8_lHGzW*$Cu?7wDu!@fkk79OSu&qbzhr)v@GBSn_EIX@q*`{ol z4Jvxbk29|k9q*uuhWpg;$iual$44}%^1@c9;F{*@)M%KWM<3J=MF&;%=qQb9St=>+ zI*WrXpyQI-hf(YPn=H_pIu3drGG>qL0;!|ka~pVsKB@;%s-fVFSi?~A^oVuJez1K| zIf6}e5%(%wo+lmSzEGJb8B8)OUi05$W+!_kiSF$Vu&d4NovMLCg^vs#9y|<9B9UBEEa7X8GzOf&6W`c3!SJx&z?-EVJ{@4w5$_H4 z%UqTr&~M;(BhH|8R9<@rBZskDnBbj|T&lvQnaK$g#dpk?3ezQ~x9^MlqTzgx=oc&# zAFSWo5`VNV`W;a=%qs9kItQ)8&Jp{tJ_3hFRr_eR$mv4{qjGBFuKCh*X#&W#b;fy3 zqcyvAW3$t}4BIb%AD!x>VYurUj2y8Jfh9b4jEZlS=c$B6wxsAwn37|+Rn;*kLwgeq z-P>!Ey>W>KSMoz;d~^g4a7JLVeb70qoI^(r9kvfyNAzJU;FHreMtVIjc{7}wL7~c? zQ2Q9BtUM;Up=qfmx1CK(;l(qf&PW(pBSeCn2k`CY)mJeN#|*kBsf`BeWqWyXB9|Ho9L4yOxh;b+JbK%r4r&5_TlKEfCm02 zo*}w0o{=+|pRVQ(vEoW!;Jp%j{bqFuc4vrjX@0*#h(a<9?Ai@jF5>DKg&#cYHMF9j=Svh?2P#qZ8zP&SVHy0>xTcgjYd;l1y}Bn8Pw_Ndf! z^3jMz3|dEAv~uJyb~sAy%uUXql}T$t_P?nMT#Lg@N{vx_abvcMjngb8w`uH^t1@X3Jiuou#9QWQ{(U56Envgde(-y`%k2&i8Vb zgY#3EQue40hp{337W@P}2YMz0jWWw|auc#&k8Z}PvQg?k`wY*^?w=qNL!l0GbgYTo zv7eCdH-===!wTm%iE-par_*Q^z34&r5LUDw8X*fx)uqoPZPG8mH~0*NR$Mu0+ret| z858mO*tRV@V&M0N7_pI-z}KNcJW-F1p>?`NYckL)ar@xl;m9GIZ;eG}lrt^8(x`GN zk?3aQ&m1H$2}<@L^L^X1q|Q+M3=@2;TFr1S+xq)d0%0^eL7KyIMh3j{NZ>WrgAxHK zJ%@^9QNZ_>bPrg7H25W`bg&1^b~e^s>@#vOwd&+tWc5_H)ErNCoNe4(rUN=lPfnE2 z)598z*n{Ci5s{Is$dGTEQ*tBNA)GBOtX-261f6U^R1z-5rgD=EZPYS1j^&ds9O%Qs zqt4Q!Q%l07>B2aFN@gG%=)+V?2Op9Nrp`%c=88w5qo)i$D93wa;`!S;>fnSLn_T!N zlTA*QYrI>JW_2lS>Wa~`{ovpc6((XMLl7f=ay9U ze7_6N?7}zan;oG}POITE(x8AIx$Wp!sk}mG69F4*5>=v&yEVQ7w>EtM_7yM0*H^zU zC$_{3D}6BzCH(7MT=$^inK+TouAc0oF(=*mqzqY1bcOGZqN16ADb={Tt3eW0GH zGCkel_Tb#bWK3MdpgMYVVwTlH1k5I{qJz6XD>lE4`zrbFmx!zY$DK@Nwl%9Z} zO&pB-`*OC8a}D6k?M7z1#C^tu4sb%Iq8!Sg$M?}LfcgtBmld02lm7yIChgzmM z-Yq=||Br+YDyb$8MkOyq4msRUrWXs9UheG{KA=d|xEN$$;iDzTIS@YWlk<-HPS%i8 zn=GjsMi+q;GY=dP>W@_ysYaX--PR~|XeMbIq61PROhwj5=wr>@_?_4lEzErWjwW^7 zgC}9OwGfiytLFYYl+{k(N*|~tGaRx_ZjhCBX_|+CgS#1_RylFFb2on`;lGbFraEM` zgy~SF=iSy?wv^|@zU9KZoPH@tTPuAWFSmn)i&5l+WRzz?5`D2dP&mAU!Tmu7EhOWd zOiHrxA45BWaS>lWwvB-{pP8yoAIE|=r(@aNQ(+G4#ty4a>_+#)9?%Hwug9YXjJU+o z?m+G;82Rmv)eWVl@>7>9Nr@l$kRv8MiXt^VcBmN_(O>Q636}vGmoSg;czi(oSI!z= zzL=)KnZA8fu#1alYE)8lCcA^DPI%O!BC8_lBkWKQ4K~5@**)p1@$+}-Hc%1N0=p<-7 zLohWblxC8G(=U`UbV$-Z+~&UXu8 zqYFKdmQ(Gr0|iD054+@ePT_soNfkQGZs=#0IR#mj3Fe$!Tj2=?bQXg9u$;J|ec@>p zmZXvC*v78v5;Kp$@58isp2r!nyOwla;&qG23uY{<#gtC&iKkxAi9!wxFZ%| z%OSTWHc!I1!mnkXArU8%CnDqoeUF@yvE?Z#?vGxs`R`xczdaL^b7luGH`aM}#pW3m z9tmmMTAl#%m?hv_`NRMx5(8P1iL`h{_Y7zF0TCDM=algz_lIi@%FND`GGyo0)|c#x zicT5lGhDReq%efninj|P^PoU} z|8=y^D@ru;C&#c8AnX2^O_OCF;E~g+pe$uj4D_}mAT3_pe1Zbqhsbk1x*v^3J>e67 z5#;yqmo^^Ksqn0m>uQz<0Pvx^N7V)qnz&dHkN2|#!d9Z`XJdPD9TNOuKS z@8?RMgXCGWmI1iH-)$ZZk|*bgj!zhlx!#5u`3?HzaJ1$KU4+-P7 zI_CBoT1Xq=Xi6H-n!^R;nMXUr(>-j=7z}-6RSn zorQMpvk6n44$|=hJc()dP))RZAL`{94EaPK*w1?+S?(a?^3y?dm*+b_$8$yUo0ELz e^C+r*kQYa_&EG%%zbbw0$9lkD{{Qd;75ZNRNbd*qC z5{mqzTPe~@y4Y0;0*q?ebqfOwkL9F0Dgm-}*R^p>kUKu}#tP)6^jEzm6lt&7ag~$= z=(+PukH+2Sc>z#z&i2RtS^GyKg8(k>`+cAHdA`q&_s7jo|C9EIl>XlZ{vPD@gsIdU zhEj&QOYu>C^Ou!s`LWu|;k&%#f1P_is=D_6BlYo*->ZK4Q=Q6vs7J;B#jmKb-}vY1 zx$$9@|F;wBKfUx#^_Qi8r-TK~l)jR*=?^Kn4Uj^eI>U*0~z0FD;Q&)U- zdFzIL+iZH#{{!XwuPR%qJ)27H@;7aNa&uG3KTD}E9QL1oMX9DM{({==zrw|4b$Jt* zO||8}pdNky7+;MW+gw(Db)c&L6b;mRvNm@ODD{r@wtiE`o^86)t&HazJ!OD<);Rk0emX5=z0b91M!K(l(38kPU90!y`^7}}I!s<))CpOHQqFMZ3MU+Mmn)d3h( z*J7yIe^Q0?*vw5+MrPIJw>Pcp1NHvi0Ec_t;$N-5iCgNw%Ru=3xQy-XTA$7b`;)Ob z>Q;AE{aMXs-OcL!z^;KyD$ugI>j?n>#oWC7M4-lvjQxuG#xb=W-Hz&htl)OH*y1hv z`RS~YR@H$=Y1I5Gf3~|X$wywho@jrXOK&r(Z`Jy_SF~*0_@1);CtzW-zp0J&whGqz z*Ne+C)NKEbQWZ$I$sO}`W2np_X@s=^1&Ub`7CckofW#{<6BujO~r z_8w#wrWts|ZoZ2>s_L(3H>DBe)Bi039OMqh5i$oDsnzU@rK{=zTGW5pWxjwMhME1L z>rLicjxs;qxXPG*e#axX@Jjn#RE;3JeQf|-l2Dh+JtLBKG{e?c^-DeQs=}7A%HOmq zZ_2L$EXk*;`Yuv{d;gCAZ8-@QdcKCc&~!tzj1!{G-2>{p1L64G`e?UOk9IeG^ZssZ z(-|C4>XCs*_`9j!YkFx@rg%ng&CB+vW6cnaJKg}WMiD{HJ>c(px{hkSfO=lo)!Foh zpc=0#wVa4qpbGDLYY5FMx9bIs+W4*+`q{U?FP=$95b6zig`B20WcZ5C-ckm? zZPwm*P&aSO`Z43JCh-xmadX{^ko6F};|iCoXLfJOtNGb43sCGW57JPBWaNS^y}eQLm=Ms%AI2FAc`;is`vs95E@XAXlDrc zSL(i@R70O?7bDiMZWVzIn|G=byVoRC+7}Mh_z6eVp@x-}_4NG%)-#6(jQ<>VB%*W% z2R`z~|H;ZVpV$LNfEThK(iDVwqW#+I3uqpUJyvDAQ+TKNew%-vp`CF2lW0xe{~>47 zAIbOkYaa*|Fk|VNiW>D*pt_iicdBi8)42YI8s(1AkFNhe>fwj=`6Hg!c>dp%*=+hm zHS1CTY009&5C5@Wo$7SRf=!nyeyLl6nOrv>ulVa1$>YAc$*;k?AD=Ex{YEQn{MqT* z=cu?~X$_5xVH>{h*vkAwz&E$eZYmMWybZ7h#g!m9+m6Qh3fI0tTn2?-KJ3tzchj5>6wPOd!?z`3d=wOn z>WaU0Mwy9<{|evQgT9|}jD+vMMeRUR+vWRLyVZd!KE)b+g3H+3o2HAizvifxM6viy zzB_^9OWo>d@!Pk1;Hqs@dmDTQVOOMtK@)_@e`~7Xn3tYKEZQ?T|R1Jxgz5~NQRpOIN-#Q1u#ldr`m7^nF)^Upshf5q?C=)0&oxjXnMA@0U| zd6aZcz4H-dRd(?qaDT!4_HA709TmuEKW6&vd}~5>!8``0 zjAOT!Qbu)8@f!-}I>z)%*rn)z^-=TX4`PW1z6#e7?k0_aPS?g2?YH>5JZWPV%sRD6tz29)A$6pp6_9GlW@co5!;Bav<58y2@D}P7Q?C8M2VrXCwj#aus-maVsWm$x-a z&>y(Re??GaP{Q5aX!lMOIB=KwCF=u`3Hd@V`VQWt?HN4gL(;berNLT0*FE8bX!x9I zehsv%w{~KKpf&rCapNn(j^K@V#hC={h6qyks}QWin%dsCH3i=1LHp_tK7eL})Pz@o z?AZQW+U;-0fRE`IV7_Q>qg9Q!t0)#!kzaUOsk@8CZ$GHk@5FP2uS|{~1H<_Wa$r(o z`VU8~0N&a_tZ_;?U&K{AiZ40k9X!TG77!)Br{nEMum-KH7nwZsPQ0!1v-r;C+Deek z`o%y4_bxmHNkd=%bEUqB)Bs^!$%f2HYcZ$whQAe8O_1ejTD1qr4V^-r@9A98VN0$s zVmC-nOq$3_mV&W(U&t)}iBeyGNfsLFnCOpK`Uba{yU1BYYV)$rW8FHBJsQ%vQ8jCn zFTJc$Y@(-{{?i{q5oW=p`*$*HQ!TSTQOm4`&aBVSk6_vAqs51aPNB~iJC#DJ4@wju z{*q6EKk>X@y(XR%G}9ITI|JIgNRdA{UCZ~P!+VO~l$dEr%mlq?{t3~DzqdV0#&`_v z{pwCOn4WdSH>?hHO`ETqe=7Ddi7~fZVSUS}Y^i~rRzFEk$YPt*#co=WJ*3q=Xyb#e z9)OQKt?Z`a>_Z~KuV4f8^LcYtS_M9kJGm0*I_KkSwRVziKLttU{padgH$XqS*V#Ag z)^mLGdz1|IS^%k}7HIv~^;&>_|Ec=9;JonmRWk;j#5LbgkZnQ@k+$nb-aH4KHH&OCtCUd!@8{He}any18 z3P<(kwgh9Ff^3T36=_$ zGV!ixxEm&iqjar6wHaF~=&DdEH|cpfSNawVr!4_Q)^&qX6^y$>{0u@M8}E(oRfjbK zpIKf@K;+_kf@ciKLO-bKDv> zl!08T14FxRGMQq~umwbU1)bQX>t4yqtNpoLHp%S~7KfDd^>_~445P7n!ieJ#wFEnw z5bQuMC4{ty3gPhHa5RQ?a-alD-ukt;A?WLJf6HXKEZlPPLZNV%=pX=iLhJIEGEoNH zb>wrO6P02;9A!xB0YO;!G-v^97X`sCS4%yDOSTRfEs5)XbzQ;dbFi-C2^3JFTyt-bgu4j6XQ!pJPHd*n@-i)o83-fcP z8;Yu5at9$txtswUR4^}G7`gDd#Eh6rG^xT}*fghT0k5r`icC&=ulv;!z67quZbMw( z%cTNPJC(~ViUt=mkV;uG^^2~X%6a8#Rk}!}Mn^^l2gl-x>*Yl}RjVP|6-~_0#>S-u zBf|Z@zn-Cjlc>oH-fUxz@jN`+vwI|^U%6sr`Es(`DGrzYkY@cYR@JZFqCjKznp zm)BWVsda%{&_f8nO1f@LQ1FYv9QAK0smCF`w57eOUrI)MaYYsCLgRI>cxdq=;cG0N z%g@ZMRjS*`p&Y6jO}Y0i(?>3K;UA;=+ulOVs$oRBqC=B@)x-B>BxDO2iC0+{v0&U0 zCk(m7uHO23CO(+U=L>};Z>>`Pj-68XkESlfp4T0WB`D>lG!9@>6WZZ;RP?71GId83eGf#|2sm_dhsZw6bXU9fHQmJ@! zNHiotHA*aO6}~2x%bu6%sbx8OYn${+*S%z?%#ZeK?-cOLlzVQexVX54Jr3q`>GX5) zFPF>S%h}ZEXeyPACBO~lGI*5Jj?7K?0Q5R-)U!Xhj4S5}qv*BU!98O`xe2dQtzL7# z>=kDhi%VW15BKhM6Xo*FMKSSMDj6Ra-AE9S$~*$Y1?8f%gBwnGrSwc4_kaLAEPYe_{)?j;{1=CTT%v^^I;wX}_pJ z+Xe6D+IL)*bWkU#dkRUn4lBe+YAqmfoP?XXEir7!#$%#ia64fG?w!gNz+GBhE87+I zU>R}OljnWpEf%0f#(kcTvv~=(qoZS|VFPxXSd7Qcd6{rs6RqL%UM3!!MBWg%nhj#M zLUC?>wOqEVs=K_pT3#5cAn(%BY++_f%(uRn&*9?%A+jU<)r^S75_ck}iS|*^1hL`^ z&W^;z;tCR1%H?XgyixwX`=UsEbFR2la?e%i1pQ{Mlr?Im%zs%&E=iuqYMI|)Rm_N7 z@{-Z02rY5wfRtyNY}3Vgk-A!`kdl;B)5gX!p52yV{vfskT>K1Xu zwzr{^mP;ihpDei|`TY_pNCK#2epw4%t%~T^hA?J%)w-!VSO3BlmMrG;*(uSsHA)w$ zi!z^UHQgD|af}{8uSpMIdZXtTFLugor&DW2bUv*WQ)UbPsC2LnN2G_<<<;+CO3}h(8Nbqm+ny;Me+Sp~TtSd%i@pqmMl`4QaDt%`&?|X4UlRDUg9M zRTU_!eRb~4!kyd%K2JAe^l?%8Xd0rA78%8zeOxMC?1@6A9_iz#=xGS5PZw8F6DiZL z@ZT+%<5$3sT*U&_^`$~VSrg>%H2eukh)t)uB_g*H`(KSlj!xd8DGWgmpO7AGb|DP| z)@w@$=gXCf?xC8zA`#{g7s}P|V+ns_g+a(La%s}B`6TFVpg$Xp3{76^y<-Gjm(Wtn zQ7_Xg`1^?igjk%ls9A*ctPm}j=PVyT*za#ApAxDvf?OI?WV5ZQI`YMy$WiZu$mhL_ z-7PUMdq$8uMgJs)!t@-1S1VPSac#RdkULN{ubK(uZ`)X!ot>UdP7rXBT3OlDfW*?a zSlWyChyiX(-fncAFJ<<&L?w(f)7c}sAJr7ax|J%ke=}n~LN5miIp23**K*GiG5>G~ z;R7i%Yp2Y#nI!tP6BE2>Ph`kj=yHTV@bqZ!IWO7MRP!)Ju+eJ4un1oTd&?Yhe6_!t zd|ntzxGBu7tzS5o&$h!!;!~UUsh+09%tDurx!@i(y6(r2M)Z8?VmCpTJAtx` z^Mo0YZKX%8F9B_%1!(fS0tS z;}{(2Zqc#5C3*=C3PloG36X1MG`?UyjO-cnVOB_;YL$X8?G?$cZ8K|?tAnW#@W+@Q znzFwD_T;r_PmM7WBYE}Ks27GS$sQvjYR`+>iR;>P1}j?YTSLTopEc-;RaSO#a%q-6 zcF&jB&pu8cV={tKM(~96q9d3SmRR3i@1?uOMI%bq>VY(a*}D4C{#El)MgS-2ubUB6 z{9A+GbOAAz%L{{2z%c}TC~N+$v0pF4gUiSShcap@KE6gLl6a;nMWX%EMM~7%1`__h``(SPBa2JvBv}%c;FHy6* zsVv?K^>^f7FwbM_3Yqo@OOJ^HC0%ZMZNq(BxFh(4_9sCX3opdF737ac!IjGH-Wo%3 zSxL3`rN_0q61lKvUHD*3hL~Ta$G_ef!Kh@vteLIhdl#cJ3oS)^ z>iCD7V5jRC2V!0>9v{kP^TfxpWDG5TJw|qrM9O7?vj4t2o+qd)r!ZH3)5QdVQMEsn zPCulK7%p^1343Clb@UjTStRX=d%4k+gdK7cH1xNISZ0&kwL-sm*BA7NAOKI)HOf=JwJ<;l`d&#fJE-^p(MGBAf#9a9` z$V1tOUO-zg64Y~2CHjs%p<<*;9zU7jS(&N)> z+d>;}?3?Yz^Ai0D5ws4tfV7_Z6+I`i_vLrQqO7VBeoTrc)tSm>HA#?9+p><_EsAg*p}HWC*JOrrwHUw-(aA~$*yYs}QtEvbCx{!?YZ6 zbKG;i@-3$4f=i2Ek46cF7sFe1sM(Sf}9iFRtFa zNtatLzB!I2{+BCt9oXsIZylXP!Kw?NjNd}Pybjm$g~6N!V8q36{+kciq}|sp5)If!qwd&P`uBbZ^IQ@G^v#}_m<-Az$4r&~FccR<->f%Bu_Xeo0c|&xdI^Y6= zN^e_kQ4zy?r>|GubD3u$YbuwCWzcP%$aU01k!V7aJ-JP8nV4qUcI#Y?2j_Q7RE4@5 z8>=^0Zr&7OzgV1|EzXlW&*cIs)sdcx$>=3)#A<8U;2tt!x)e0JL{dqZYZYosBu$zx zYDxE$%WDjOd2W7LWL;uMS%p^0a3Y^&@kn*#am2lW1%v7iW#-zA;oZ zF}+&e;?SRFtn7T&ZDm8RoA!zdu5kw7%d6HrpDKQGT;^Hr>4~3aO-A$@Jp-afZ9%Va zHhc=j!-CcFRqY3O*zViRYFnOPo?nHwTSIFKriI9%f0IC3y;hJr-PJ9Mg}V*Zx?Y`s z#-d8L@JDOwlyk5&$=l%U)x`K_zCrn_wGD$`C&z@jRtk)6a6kU1GOhtrSEv zMsDtn$hs7fBy)v!0j5LSLkd)z2qohStgWrCtuaqECGIB88+gJ2zv90;#L`nL`+I=a zSX7sDk7zL)ZxPhO^mm8!s){6pg-79gKw>q!9%XAIzzmWeyWeDHC%;#d69km>?=x(1 zc1Q5adffQs5gGQx^ui;)�_zDl2qYX=COOM(}-?Ih=gj{pPtmAW7AP;$wQP7mUM% zw#Cd(2}WU#@|xINsl0Z+Lt+JUrbszZk$P?6DgIPcr;iy53@#%C!KXnGN%Y7v?#Ku; zm}~53%G{lb`UVGW1%p!-y&EbCJBK{eLQ50Q^A<-kgfPiHR6 z^m(oPeRd^~2uW;app33vFwqP;6U;z{i8h1xRr|X`j1o-7$mwN$$aHs0JW(11aH8O{ zgn$oO<&3WOMd!?&u^w}2yBa9lYxsxuXXYC=OsRt2US$fCPU%$HQ^!1jElWd!dG)+s zC7`TodomaF0~K;Y6;^Bn8?2L}h>k?kN2}aK_o}PHr7UFU$t(_Y#&=ylUACAZJiXslD!)l^WfO%c;;c5pU*D+ z1?o|Iumst9dC3E8PPNrm4urPa9`@BMdfbtPL^eC5$680bmn?N3Xzq*E^;xE5Np1va zO~DtNxW6o`wo8jki;J_w=!mR135oQ4VN1`c+UaD=&7~8V+7Z;hlQoFwhet=JhAQP1 zvQVhR(3#K?H_bJ3El}pKtoH<#yt$bf6(}fYRu;3U?kt(n@4-4aH$f+z9eUR7(feMY z?l*d^u~g;}k#wSf#mgJkO> zFV=!TG@5o_EUy$;t8i~rHas$sr#i(N%kt0jw1_f>yxdcm)|pC|ay8BF*=G5Q;D$$L zqbNXQze7}TT2rZ^%EoMdDnFH|R&NI8Y|pw0dT7pD^k!JSvGc)#3NUiCE$c`~+L5^; z6&-Wx6q`kQmlCXQM>IluaWs1nC0GAcia%U)I;v9oDxsJu~Nt?TMJe`B#wh|HKvrWXKbg4Lr?PPK~eWMOV~ ztv=GWh09W{tW_^YyG1H_bu=Zms%ec2h=f3*tcgq>5tY?c}~XN_YI zTLvmvjI(Vkp*dSwKxcKVV9VJn<;5wPC%6?xi}`{Dd(kdfdDhHwHtRNOPc}O>B`d#o z*t0cxePeZHwQ?)kQ%5=+b;}#GRPCAb<#kr{Ccr98F%%=S0@@jE*o+Y5}2GX9E==JqklELqv*Fq{QE$fTzXp5o@EPF)lrbrS$z+YJ+ zUbQx;I(`4O-vnz;Pkn_G_}0D5Tdpq^NOkV>?D0wciRsd;$kjE*oN&w>3yi3s)G~!> z&WEm;E5vH>wi2r>h2>;2)bQ1yEJ`irWWIV5Gswi7Sv|24?Pq~xEl#zwt9W6U0h3}l zZ4sQO-soUPken|Treslc2kijULD}O-Vbi5-N}7x^MDT2(STJRcuuCyAI4lWS#=5Ek zD{BAh{QOFh8t}E>Tq#^-2{hVMk0k8&vLP>3OyI&(8!z)V!m9h|9$wandBGg9PN`50 zYlYAhS|OIU%Q%+`&$0s)*Eqz^-7=qKS0t4>S^nFpvET?3IYevKy0S;iQ`WHBr&Fkq zf;c^2Tv?gN8C1u7rFx-Qc=7-XV~n#N-8)#B@iK!Wsbm5pC_zButr&yRo!%Q+%w zhb|0X7#=>=KYXeV$n0TtMcMOeAAp7FHLB9t&WJ0^M-9Xd(O&#Rr&1@cuTPCA#uxx~ zWKeaCScB>acxTV{_n$g7nx4>0;;XAdJ_Ll*?f;=tbzhcB6fMfA$>F<=F0^>2Wh9wc z`|fk--s}gnogL?q!4a&=%er6=o5R-GK)(tOk7DCxd(|phE1Z1NsEj-_#+rm^vyOUD z>#|1;4nJIed2AS!@gKM$wwVV9FN~0${P? zze)b7DYRZ~9B%58JqC5keSTwV49xyvLAF62Jax()9=@Qgldb*gxM0f4;5>>X%&hRn zTGg8W9t%#gARq0lBcjh4+0u#qOnF80*{>qQfC}na(XMlL_^f;KWdB)EL!#ES>?N?S z2#@v^rdXX?^Q(Z0QqS}>s-jNT_j4>I{1j9g8^OZh2C+1-_DQqfJnQtUz={68{yyok zU3>~giI4@@z8~X{v+Px=LQknRFX|eOs&%)~E9-_Vbo?fK8n*k*Q}Wu~AMC?A58{I3 zz!dTm<2d4MAv*<4%kK*zQDde{#th1Su@3Xtmgpa^PmO5?f->CRZ}!<}9 zL#tG78kii5aD~~z6haaH*IACLTcuG;i&a=(Z;4(1?v!vmfJ|-u!4t|leu6(DTib{* zr^wEroI)t5{drlrU0t1#6=Y5E&N|w`h%np{?=FpvU<&b&)_%KB*~d>D@3W38`$S)# zNZ5JmR84J!xHL(tV2!IiEFi2rE`D9NNFBAkZV^VFAF+o;Li1FxAK|owDk9kYrV(bDG~|S5~I~YmbpM*>8Y_(e5qH@#XxU2Smw*@RfwOB2M`viM+926 ziuC>ceaDZV0KfGFCLlmTb!rP%28h!sb%6D=`PKiTy}no0jt`dSLrh;J9-7`uh8c&r&y8>|#nr=+?UcX;H`v!m+EEkxj;)&N^~OFCzK;n_tjLLFIW@mljHjQ551*Wl3HDbtL!Ukjx4fFR7c+} z8)|3RBoh8f91M(LA;~2DCKf~&&IwV4oNPi|*)y|J=<8rg>w--nS>Nk64zOdfw}Hvt zJZD)jq3nwE1x}eG<_Hx~NV0**3ThAy<80W=NssH@+%ZOUh}6u|_X`>pFEQE(u;GTR zoqKWUUTwTH95e18Mh^CW5o-!P21iD)VLy5Z^!J|~=BH8Ru+%U?()+uD&pGxKPQ&cVt z3fGyQ-}p{5pA!eTU$nl3Uu zJ4>iQNN5u{9z=H43iSBI6c>jXM<7+0U%Mqc%k8X;m!b~2qI8GsEo2`jf|cWP+S=(u z^b}PwxuCT$#i1aP9Zxs=%sw)k16MfQm6i%gKBv*k(;6FuGu>ffc0(_1oD^bH1qQNe z$33CDB>a+V0?Z_53nKJMtrznIQOgmfQ6vg-L~fk;qtzccHM!X@ySP`p=JW@#9bsax zoLxB7FVMswYL{Yx9Yd%haSypgYVff1*ofq7KCuVz4LSSX#y~@=_XA5dmm&^jh`?z1(^}K$Lt;6aXcPBGFIr*;i8(iQwbwyn_Hf~byxNR*4irHW zDI-7*-hFDcP+Xz*XayP@4iBF=VG~u49LF)GvgnZf4TnVH?>cf4MtE213A2U$uWsWy zN43NxLVZu*XMvrUnkFK}hZdQ1h#o|0WDZgaN`w-|JtHTA+JteSUh-Hi+>!R^%(Zw} zsG(8qyGF*RsnlD+tjkJ13>^71p<41*Py+X`R2w1qhQPPXHLY&|= zAZKV=E_u%aviPJSwg4%D6=P%z!j24QV)|QhmW~a~4C$4#X)+ou$Ap)ZGVrvV zfolH{K|;b8){$yJ5c=v7f`IdKr<}kN59>P*Ycx%AP)e!`es5#)D<>Lt6bK%- zYwg7{g_pZKMF!oTgE%`fG^II3z||g3q?rd~=0^RYM?p@gX+n=7|KL99|8Z}DEW^pY zhAzo3`M54__}%_-(gvKhPMnY;PuepA7>p9~59!l%A_3Ikd4Yx&3^`7y5%w#yl}al_ zB?nh=UENx{))db%*5qfQ(c{$EPHVo#8AFepe6tLri9|_-sq0nxZqqTakl~=SJ|QS) zD6&$P)~iXUjUb!G1Zc0FGxO1&@P5%A7~&~}i_ugz9*M@~q$L`Z_SfL?=|+3T^X#NI zbw*gixkZj}_c-Ccc3sm_qzqHNx*W`A;fOn&So$WdGmVPVF@`2Hlh;de&BNLW5jm)@ z!pHH2edz7iIyw3uld{$2khSnt&NyDbmLPrU>XMm&6U!}JDw8Gg{tm<7BtFN`OEPPb zs=zY3`Vwy>5fxce{1%nd`Vmfo=h!1ixQ$u#iI(K~ zitlCJSPam(9JQOA@t`E9kim7jIKG~BF`Ut2#W?LkXPg1$xH9trPaTkFEZjJ|Zt|c2 z2d@`cca@nhFZP{2@w)%MJhUKZ>v>{fh8CaUG(bb*q1<9F9(KY;3p<|rz_>i>!7)Zo z4DOR%6KR=Bb9(!I+0PSPR!*oomO07hv9@Q+^Z^pKe3ynN_7Ck(Fb-B~H(nU$m0tLvQ2w>X0@C&o``E5Yyd zgn-3Fq;OYU;PRYqrl}C67rY5t1+9Dz6)!7o@ACg;6G^~gh=DnJIi(MtKJl#|zz{&q z-fj>HS3-9=*ewt2boKVqz2&k3$ARh0Ua$l&gjexZpRu>Qx_ZNw!?`%<2BAD}G0BL- zQZXDBrSXJ-*WkN>p?Z7eWWFmBVP`>nk67Ho*h)N-A#2)jw{0J!*WxWE_46V44=3;7 zxbPL5#Mz^j`-DP*)1^0>z##Zxi(1dmyyC*@Zg zi_pfbwK}ADJb*(}i^w_whk4FIIMS{6Kcaj?HIp+lo;+p6^9a(e-jX!q=x~Jh5_V_@ zxsOUz Date: Sat, 1 Jan 2011 18:15:25 +0000 Subject: [PATCH 178/181] [VIDEOPRT/WIN32K]: Synchronize and share PEVENT/ENG_EVENT/VIDEO_PORT_EVENT implementation, as these objects are actually the same (and VideoPrt Event* APIs can be used on GRE Event Objects). Use ENG_EVENT structure from ntddvdeo.h instead of re-creating our own. Drivers using these interfaces will no longer explode. [VIDEOPRT]: Add parameter checks to DeleteEvent and WaitForSingleObject. [VIDEOPRT]: Fix WaitForSingleObject. It was waiting on the Object paramter itself -- which is the VideoPrt/ENG Event, not a real object, we have to wait on ->pKEvent instead. [VIDEOPRT]: Fix WaitForSingleObject round two, it was returning the NT_STATUS, while VideoPrt should return VP_STATUS/Win32 error codes. [WIN32K]: Allocate/free GRE events directly from pool, instead of using Eng APIs. Use documented tag for GRE Events (Dfsm), found in pooltag.txt [WIN32K]: Implement EngMapEvent and EngUnmapEvent. svn path=/trunk/; revision=50256 --- reactos/drivers/video/videoprt/event.c | 180 ++++++++++-------- reactos/drivers/video/videoprt/videoprt.h | 4 - .../subsystems/win32/win32k/eng/engevent.c | 124 +++++++----- .../win32/win32k/include/engevent.h | 15 +- 4 files changed, 186 insertions(+), 137 deletions(-) diff --git a/reactos/drivers/video/videoprt/event.c b/reactos/drivers/video/videoprt/event.c index 5d04a75fbd8..c4359755cbd 100644 --- a/reactos/drivers/video/videoprt/event.c +++ b/reactos/drivers/video/videoprt/event.c @@ -1,120 +1,140 @@ /* - * VideoPort driver - * - * Copyright (C) 2002, 2003, 2004 ReactOS Team - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * + * PROJECT: ReactOS Video Port Driver + * LICENSE: BSD - See COPYING.ARM in the top level directory + * FILE: drivers/video/videoprt/event.c + * PURPOSE: Event Support Routines + * PROGRAMMERS: ReactOS Portable Systems Group */ +/* INCLUDES *******************************************************************/ + #include "videoprt.h" +#include "../../subsystems/win32/win32k/include/engevent.h" /* PUBLIC FUNCTIONS ***********************************************************/ /* * @implemented */ - -VP_STATUS NTAPI -VideoPortCreateEvent( - IN PVOID HwDeviceExtension, - IN ULONG EventFlag, - IN PVOID Unused, - OUT PEVENT *Event) +VP_STATUS +NTAPI +VideoPortCreateEvent(IN PVOID HwDeviceExtension, + IN ULONG EventFlag, + IN PVOID Unused, + OUT PEVENT *Event) { - PVIDEO_PORT_EVENT VpEvent; - EVENT_TYPE Type = SynchronizationEvent; + VP_STATUS Result = NO_ERROR; + PVIDEO_PORT_EVENT EngEvent; - /* Allocate storage for the event structure */ - VpEvent = ExAllocatePoolWithTag( - NonPagedPool, - sizeof(VIDEO_PORT_EVENT), - TAG_VIDEO_PORT); + /* Allocate memory for the event structure */ + EngEvent = ExAllocatePoolWithTag(NonPagedPool, + sizeof(VIDEO_PORT_EVENT) + sizeof(KEVENT), + TAG_VIDEO_PORT); + if (EngEvent) + { + /* Set KEVENT pointer */ + EngEvent->pKEvent = EngEvent + 1; + + /* Initialize the kernel event */ + KeInitializeEvent(EngEvent->pKEvent, + (EventFlag & EVENT_TYPE_MASK) ? + NotificationEvent : SynchronizationEvent, + EventFlag & INITIAL_EVENT_STATE_MASK); - /* Fail if not enough memory */ - if (!VpEvent) return ERROR_NOT_ENOUGH_MEMORY; + /* Pass pointer to our structure to the caller */ + *Event = (PEVENT)EngEvent; + DPRINT("VideoPortCreateEvent() created %p\n", EngEvent); + } + else + { + /* Out of memory */ + DPRINT("VideoPortCreateEvent() failed\n"); + Result = ERROR_NOT_ENOUGH_MEMORY; + } - /* Initialize the event structure */ - RtlZeroMemory(VpEvent, sizeof(VIDEO_PORT_EVENT)); - VpEvent->pKEvent = &VpEvent->Event; - - /* Determine the event type */ - if (EventFlag & NOTIFICATION_EVENT) - Type = NotificationEvent; - - /* Initialize kernel event */ - KeInitializeEvent(VpEvent->pKEvent, Type, EventFlag & INITIAL_EVENT_SIGNALED); - - /* Indicate success */ - return NO_ERROR; + /* Return result */ + return Result; } /* * @implemented */ - -VP_STATUS NTAPI -VideoPortDeleteEvent( - IN PVOID HwDeviceExtension, - IN PEVENT Event) +VP_STATUS +NTAPI +VideoPortDeleteEvent(IN PVOID HwDeviceExtension, + IN PEVENT Event) { - /* Free storage */ - ExFreePool(Event); + /* Handle error cases */ + if (!Event) return ERROR_INVALID_PARAMETER; + if (Event->fFlags & ENG_EVENT_USERMAPPED) return ERROR_INVALID_PARAMETER; + if (!Event->pKEvent) return ERROR_INVALID_PARAMETER; - /* Indicate success */ - return NO_ERROR; + /* Free storage */ + ExFreePool(Event); + + /* Indicate success */ + return NO_ERROR; } /* * @implemented */ - -LONG NTAPI -VideoPortSetEvent( - IN PVOID HwDeviceExtension, - IN PEVENT Event) +LONG +NTAPI +VideoPortSetEvent(IN PVOID HwDeviceExtension, + IN PEVENT Event) { - return KeSetEvent(Event->pKEvent, IO_NO_INCREMENT, FALSE); + return KeSetEvent(Event->pKEvent, IO_NO_INCREMENT, FALSE); } /* * @implemented */ - -VOID NTAPI -VideoPortClearEvent( - IN PVOID HwDeviceExtension, - IN PEVENT Event) +VOID +NTAPI +VideoPortClearEvent(IN PVOID HwDeviceExtension, + IN PEVENT Event) { - KeClearEvent(Event->pKEvent); + KeClearEvent(Event->pKEvent); } /* * @implemented */ - -VP_STATUS NTAPI -VideoPortWaitForSingleObject( - IN PVOID HwDeviceExtension, - IN PVOID Object, - IN PLARGE_INTEGER Timeout OPTIONAL) +VP_STATUS +NTAPI +VideoPortWaitForSingleObject(IN PVOID HwDeviceExtension, + IN PVOID Event, + IN PLARGE_INTEGER Timeout OPTIONAL) { - return KeWaitForSingleObject( - Object, - Executive, - KernelMode, - FALSE, - Timeout); + PVIDEO_PORT_EVENT EngEvent = Event; + NTSTATUS Status; + + /* Handle error cases */ + if (!EngEvent) return ERROR_INVALID_PARAMETER; + if (!EngEvent->pKEvent) return ERROR_INVALID_PARAMETER; + if (EngEvent->fFlags & ENG_EVENT_USERMAPPED) return ERROR_INVALID_PARAMETER; + + /* Do the actual wait */ + Status = KeWaitForSingleObject(EngEvent->pKEvent, + Executive, + KernelMode, + FALSE, + Timeout); + if (Status == STATUS_TIMEOUT) + { + /* Convert to wait timeout, otherwise NT_SUCCESS would return NO_ERROR */ + return WAIT_TIMEOUT; + } + else if (NT_SUCCESS(Status)) + { + /* All other success codes are Win32 success */ + return NO_ERROR; + } + + /* Otherwise, return default Win32 failure */ + return ERROR_INVALID_PARAMETER; } + +/* EOF */ + diff --git a/reactos/drivers/video/videoprt/videoprt.h b/reactos/drivers/video/videoprt/videoprt.h index 9a24c2e6e31..eb2b8eee111 100644 --- a/reactos/drivers/video/videoprt/videoprt.h +++ b/reactos/drivers/video/videoprt/videoprt.h @@ -107,11 +107,7 @@ typedef struct _VIDEO_PORT_DEVICE_EXTENSTION typedef struct _VIDEO_PORT_EVENT { - /* Public part */ ENG_EVENT; - - /* Private part */ - KEVENT Event; } VIDEO_PORT_EVENT, *PVIDEO_PORT_EVENT; /* agp.c */ diff --git a/reactos/subsystems/win32/win32k/eng/engevent.c b/reactos/subsystems/win32/win32k/eng/engevent.c index d38c32ae2d1..3773c305029 100644 --- a/reactos/subsystems/win32/win32k/eng/engevent.c +++ b/reactos/subsystems/win32/win32k/eng/engevent.c @@ -1,54 +1,59 @@ /* * PROJECT: ReactOS Win32K - * LICENSE: GPL - See COPYING in the top level directory + * LICENSE: BSD - See COPYING.ARM in the top level directory * FILE: subsystems/win32/win32k/eng/engevent.c * PURPOSE: Event Support Routines * PROGRAMMERS: Aleksey Bragin + * ReactOS Portable Systems Group */ -/* INCLUDES ******************************************************************/ +/* INCLUDES *******************************************************************/ #include +#include #define NDEBUG #include -#define TAG_ENG ' gnE' +/* Dfsm - - Eng event allocation (ENG_KEVENTALLOC,ENG_ALLOC) in ntgdi\gre */ +#define TAG_GRE_EVENT 'msfD' -/* PUBLIC FUNCTIONS **********************************************************/ +/* PUBLIC FUNCTIONS ***********************************************************/ BOOL APIENTRY EngCreateEvent(OUT PEVENT* Event) { + BOOLEAN Result = TRUE; PENG_EVENT EngEvent; /* Allocate memory for the event structure */ - EngEvent = EngAllocMem(FL_NONPAGED_MEMORY | FL_ZERO_MEMORY, - sizeof(ENG_EVENT), - TAG_ENG); - - /* Check if we are out of memory */ - if (!EngEvent) + EngEvent = ExAllocatePoolWithTag(NonPagedPool, + sizeof(ENG_EVENT) + sizeof(KEVENT), + TAG_GRE_EVENT); + if (EngEvent) { - /* We are, fail */ - return FALSE; + /* Set KEVENT pointer */ + EngEvent->fFlags = 0; + EngEvent->pKEvent = EngEvent + 1; + + /* Initialize the kernel event */ + KeInitializeEvent(EngEvent->pKEvent, + SynchronizationEvent, + FALSE); + + /* Pass pointer to our structure to the caller */ + *Event = EngEvent; + DPRINT("EngCreateEvent() created %p\n", EngEvent); + } + else + { + /* Out of memory */ + DPRINT("EngCreateEvent() failed\n"); + Result = FALSE; } - /* Set KEVENT pointer */ - EngEvent->pKEvent = &EngEvent->KEvent; - - /* Initialize the kernel event */ - KeInitializeEvent(EngEvent->pKEvent, - SynchronizationEvent, - FALSE); - - /* Pass pointer to our structure to the caller */ - *Event = EngEvent; - - DPRINT("EngCreateEvent() created %p\n", EngEvent); - - /* Return success */ - return TRUE; + /* Return result */ + return Result; } BOOL @@ -66,7 +71,7 @@ EngDeleteEvent(IN PEVENT Event) } /* Free the allocated memory */ - EngFreeMem(Event); + ExFreePool(Event); /* Return success */ return TRUE; @@ -106,18 +111,57 @@ EngMapEvent(IN HDEV hDev, IN PVOID Reserved2, IN PVOID Reserved3) { - DPRINT("EngMapEvent(%x %x %p %p %p)\n", hDev, hUserObject, Reserved1, Reserved2, Reserved3); - UNIMPLEMENTED; - return NULL; + PENG_EVENT EngEvent; + NTSTATUS Status; + + /* Allocate memory for the event structure */ + EngEvent = ExAllocatePoolWithTag(NonPagedPool, + sizeof(ENG_EVENT), + TAG_GRE_EVENT); + if (!EngEvent) return NULL; + + /* Zero it out */ + EngEvent->fFlags = 0; + EngEvent->pKEvent = NULL; + + /* Create a handle, and have Ob fill out the pKEvent field */ + Status = ObReferenceObjectByHandle(EngEvent, + EVENT_ALL_ACCESS, + ExEventObjectType, + UserMode, + &EngEvent->pKEvent, + NULL); + if (NT_SUCCESS(Status)) + { + /* Pulse the event and set that it's mapped by user */ + KePulseEvent(EngEvent->pKEvent, EVENT_INCREMENT, FALSE); + EngEvent->fFlags |= ENG_EVENT_USERMAPPED; + } + else + { + /* Free the allocation */ + ExFreePool(EngEvent); + EngEvent = NULL; + } + + /* Support legacy interface */ + if (Reserved1) *(PVOID*)Reserved1 = EngEvent; + return EngEvent; } BOOL APIENTRY EngUnmapEvent(IN PEVENT Event) { - DPRINT("EngUnmapEvent(%p)\n", Event); - UNIMPLEMENTED; - return FALSE; + /* Must be a usermapped event */ + if (!(Event->fFlags & ENG_EVENT_USERMAPPED)) return FALSE; + + /* Dereference the object, destroying it */ + ObDereferenceObject(Event->pKEvent); + + /* Free the Eng object */ + ExFreePool(Event); + return TRUE; } BOOL @@ -126,7 +170,6 @@ EngWaitForSingleObject(IN PEVENT Event, IN PLARGE_INTEGER TimeOut) { NTSTATUS Status; - DPRINT("EngWaitForSingleObject(%p %I64d)\n", Event, TimeOut->QuadPart); /* Validate parameters */ @@ -148,12 +191,7 @@ EngWaitForSingleObject(IN PEVENT Event, TimeOut); /* Check if there is a failure or a timeout */ - if (!NT_SUCCESS(Status)) - { - /* Return failure */ - return FALSE; - } - - /* Return success */ - return TRUE; + return NT_SUCCESS(Status); } + +/* EOF */ diff --git a/reactos/subsystems/win32/win32k/include/engevent.h b/reactos/subsystems/win32/win32k/include/engevent.h index a1249f05fe8..be864990d2e 100644 --- a/reactos/subsystems/win32/win32k/include/engevent.h +++ b/reactos/subsystems/win32/win32k/include/engevent.h @@ -1,13 +1,8 @@ #pragma once -#define ENG_EVENT_USERMAPPED 1 +// +// Flags for the fFlags field of ENG_EVENT +// +#define ENG_EVENT_USERMAPPED 0x01 -typedef struct _ENG_EVENT -{ - /* Public part */ - PVOID pKEvent; - ULONG fFlags; - - /* Private part */ - KEVENT KEvent; -} ENG_EVENT, *PENG_EVENT; +/* EOF */ From 3f0d2fffb351145f62087ecf6a1aa29a75bed141 Mon Sep 17 00:00:00 2001 From: Johannes Anderwald Date: Sat, 1 Jan 2011 21:13:07 +0000 Subject: [PATCH 179/181] [IPHLPAPI] - Rewrite name server enumeration routines - Check if static dns entries are present before checking for dynamic dns entries - Fixes static dns entries [NETCFGX] - GetPerAdapterInfo requires IP_PER_ADAPTER_INFO struct - Fix reading static dns entries - Delete static name server key, when changing dns servers to automatic (dhcp) - Don't delete DhcpNameServer key yet, as more interaction is needed with dhcp service when changing from static dns to dynamic dhcp - Should finally fix static dns when dhcp is active svn path=/trunk/; revision=50257 --- reactos/dll/win32/iphlpapi/iphlpapi_main.c | 6 +- reactos/dll/win32/iphlpapi/iphlpapi_private.h | 2 +- reactos/dll/win32/iphlpapi/resinfo_reactos.c | 453 ++++++++++++------ reactos/dll/win32/netcfgx/tcpipconf_notify.c | 21 +- 4 files changed, 320 insertions(+), 162 deletions(-) diff --git a/reactos/dll/win32/iphlpapi/iphlpapi_main.c b/reactos/dll/win32/iphlpapi/iphlpapi_main.c index ebb73ad6017..50f8d614e40 100644 --- a/reactos/dll/win32/iphlpapi/iphlpapi_main.c +++ b/reactos/dll/win32/iphlpapi/iphlpapi_main.c @@ -1622,7 +1622,11 @@ DWORD WINAPI GetPerAdapterInfo(ULONG IfIndex, PIP_PER_ADAPTER_INFO pPerAdapterIn return ERROR_BUFFER_OVERFLOW; } - if(RegQueryValueExW(hkey, L"DHCPNameServer", NULL, NULL, NULL, &dwSize) == ERROR_SUCCESS) + if(RegQueryValueExW(hkey, L"NameServer", NULL, NULL, NULL, &dwSize) == ERROR_SUCCESS) + { + pPerAdapterInfo->AutoconfigActive = FALSE; + } + else { pPerAdapterInfo->AutoconfigActive = TRUE; } diff --git a/reactos/dll/win32/iphlpapi/iphlpapi_private.h b/reactos/dll/win32/iphlpapi/iphlpapi_private.h index 6ba198a301c..de7f05e654e 100644 --- a/reactos/dll/win32/iphlpapi/iphlpapi_private.h +++ b/reactos/dll/win32/iphlpapi/iphlpapi_private.h @@ -147,7 +147,7 @@ BOOL hasArp( HANDLE tcpFile, TDIEntityID *arp_maybe ); typedef VOID (*EnumNameServersFunc)( PWCHAR Interface, PWCHAR NameServer, PVOID Data ); -void EnumNameServers( HANDLE RegHandle, PWCHAR Interface, PVOID Data, EnumNameServersFunc cb ); +LSTATUS EnumNameServers( HKEY RegHandle, LPWSTR Interface, PVOID Data, EnumNameServersFunc cb ); NTSTATUS getIPAddrEntryForIf(HANDLE tcpFile, char *name, DWORD index, diff --git a/reactos/dll/win32/iphlpapi/resinfo_reactos.c b/reactos/dll/win32/iphlpapi/resinfo_reactos.c index 02bcb3b9129..5ee58c1ddb7 100644 --- a/reactos/dll/win32/iphlpapi/resinfo_reactos.c +++ b/reactos/dll/win32/iphlpapi/resinfo_reactos.c @@ -52,197 +52,348 @@ typedef struct _NAME_SERVER_LIST_PRIVATE { IP_ADDR_STRING * pCurrent; } NAME_SERVER_LIST_PRIVATE, *PNAME_SERVER_LIST_PRIVATE; -NTSYSAPI -PVOID -NTAPI -RtlAllocateHeap ( - HANDLE Heap, - ULONG Flags, - SIZE_T Size - ); +typedef VOID (*ENUM_INTERFACE_CALLBACK)( + HKEY ChildKeyHandle, + LPWSTR ChildKeyName, + PVOID CallbackContext); -NTSYSAPI -BOOLEAN -NTAPI -RtlFreeHeap ( - HANDLE Heap, - ULONG Flags, - PVOID Address - ); +LSTATUS +QueryNameServer( + IN HKEY hInterface, + IN LPCWSTR NameServerKey, + OUT LPWSTR * OutNameServer) +{ + DWORD dwLength, dwType; + LPWSTR NameServer; + LSTATUS Status; -NTSYSAPI -NTSTATUS -NTAPI -RtlUnicodeToMultiByteN ( - PCHAR MbString, - ULONG MbSize, - PULONG ResultSize, - PWCHAR UnicodeString, - ULONG UnicodeSize - ); + /* query ns */ + dwLength = 0; + Status = RegQueryValueExW(hInterface, NameServerKey, NULL, &dwType, NULL, &dwLength); - -typedef VOID (*EnumInterfacesFunc)( HKEY ChildKeyHandle, - PWCHAR ChildKeyName, - PVOID Data ); - -/* - * EnumInterfaces - * - * Call the enumeration function for each name server. - */ - -static void EnumInterfaces( PVOID Data, EnumInterfacesFunc cb ) { - HKEY RegHandle; - HKEY ChildKeyHandle = 0; - PWCHAR RegKeyToEnumerate = - L"SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters\\Interfaces"; - PWCHAR ChildKeyName = 0; - DWORD CurrentInterface; - - if (OpenChildKeyRead(HKEY_LOCAL_MACHINE,RegKeyToEnumerate,&RegHandle)) { - return; - } - - for (CurrentInterface = 0; TRUE; CurrentInterface++) { - ChildKeyName = GetNthChildKeyName( RegHandle, CurrentInterface ); - if (!ChildKeyName) break; - if (OpenChildKeyRead(RegHandle,ChildKeyName, - &ChildKeyHandle) == 0) { - cb( ChildKeyHandle, ChildKeyName, Data ); - RegCloseKey( ChildKeyHandle ); - } - ConsumeChildKeyName( ChildKeyName ); - } -} - -/* - * EnumNameServers - */ - -void EnumNameServers( HANDLE RegHandle, PWCHAR Interface, - PVOID Data, EnumNameServersFunc cb ) { - PWCHAR NameServerString = - QueryRegistryValueString(RegHandle, L"DhcpNameServer"); - - if (!NameServerString) - NameServerString = QueryRegistryValueString(RegHandle, L"NameServer"); - - if (NameServerString) { - /* Now, count the non-empty comma separated */ - DWORD ch; - DWORD LastNameStart = 0; - for (ch = 0; NameServerString[ch]; ch++) { - if (NameServerString[ch] == ',') { - if (ch - LastNameStart > 0) { /* Skip empty entries */ - PWCHAR NameServer = - malloc(((ch - LastNameStart) + 1) * sizeof(WCHAR)); - if (NameServer) { - memcpy(NameServer,NameServerString + LastNameStart, - (ch - LastNameStart) * sizeof(WCHAR)); - NameServer[ch - LastNameStart] = 0; - cb( Interface, NameServer, Data ); - free(NameServer); - LastNameStart = ch +1; - } - } - LastNameStart = ch + 1; /* The first one after the comma */ - } - } - if (ch - LastNameStart > 0) { /* A last name? */ - PWCHAR NameServer = malloc(((ch - LastNameStart) + 1) * sizeof(WCHAR)); - if (NameServer) { - memcpy(NameServer,NameServerString + LastNameStart, - (ch - LastNameStart) * sizeof(WCHAR)); - NameServer[ch - LastNameStart] = 0; - cb( Interface, NameServer, Data ); - free(NameServer); - } - } - ConsumeRegValueString(NameServerString); + if (Status != ERROR_SUCCESS) + { + /* failed to retrieve size */ + DbgPrint("Status %x\n", Status); + return Status; } + + /* add terminating null */ + dwLength += sizeof(WCHAR); + + /* allocate name server */ + NameServer = HeapAlloc(GetProcessHeap(), 0, dwLength); + + if (!NameServer) + { + /* no memory */ + return ERROR_OUTOFMEMORY; + } + + /* query ns */ + Status = RegQueryValueExW(hInterface, NameServerKey, NULL, &dwType, (LPBYTE)NameServer, &dwLength); + + if (Status != ERROR_SUCCESS || dwType != REG_SZ) + { + /* failed to retrieve ns */ + HeapFree(GetProcessHeap(), 0, NameServer); + return Status; + } + + /* null terminate it */ + NameServer[dwLength / sizeof(WCHAR)] = L'\0'; + + /* store result */ + *OutNameServer = NameServer; + + return STATUS_SUCCESS; } -static void CreateNameServerListEnumNamesFuncCount( PWCHAR Interface, - PWCHAR Server, - PVOID _Data ) { - PNAME_SERVER_LIST_PRIVATE Data = (PNAME_SERVER_LIST_PRIVATE)_Data; + +LSTATUS +EnumNameServers( + IN HKEY hInterface, + IN LPWSTR InterfaceName, + PVOID ServerCallbackContext, + EnumNameServersFunc CallbackRoutine) +{ + LSTATUS Status; + LPWSTR NameServer; + WCHAR Buffer[50]; + DWORD Length; + LPWSTR Start, Comma; + + /* query static assigned name server */ + Status = QueryNameServer(hInterface, L"NameServer", &NameServer); + if (Status != ERROR_SUCCESS) + { + /* query dynamic assigned name server */ + Status = QueryNameServer(hInterface, L"DhcpNameServer", &NameServer); + + if (Status != ERROR_SUCCESS) + { + /* failed to retrieve name servers */ + return Status; + } + } + + /* enumerate all name servers, terminated by comma */ + Start = NameServer; + + do + { + /* find next terminator */ + Comma = wcschr(Start, L','); + + if (Comma) + { + /* calculate length */ + Length = Comma - Start; + + /* copy name server */ + RtlMoveMemory(Buffer, Start, Length * sizeof(WCHAR)); + + /* null terminate it */ + Buffer[Length] = L'\0'; + + /* perform callback */ + CallbackRoutine(InterfaceName, Buffer, ServerCallbackContext); + + } + else + { + /* perform callback */ + CallbackRoutine(InterfaceName, Start, ServerCallbackContext); + + /* last entry */ + break; + } + + /* increment offset */ + Start = Comma + 1; + + }while(TRUE); + + /* free name server string */ + HeapFree(GetProcessHeap(), 0, NameServer); + + /* done */ + return ERROR_SUCCESS; +} + +LSTATUS +EnumInterfaces( + ENUM_INTERFACE_CALLBACK CallbackRoutine, + PVOID InterfaceCallbackContext) +{ + HKEY hKey, hInterface; + LSTATUS Status; + DWORD NumInterfaces, InterfaceNameLen, Index, Length; + LPWSTR InterfaceName; + + /* first open interface key */ + Status = RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters\\Interfaces", 0, KEY_READ, &hKey); + + /* check for success */ + if (Status != ERROR_SUCCESS) + { + /* failed to open interface key */ + return Status; + } + + /* now get maximum interface name length and number of interfaces */ + Status = RegQueryInfoKeyW(hKey, NULL, NULL, NULL, &NumInterfaces, &InterfaceNameLen, NULL, NULL, NULL, NULL, NULL, NULL); + if (Status != ERROR_SUCCESS) + { + /* failed to get key info */ + RegCloseKey(hKey); + return Status; + } + + /* RegQueryInfoKey does not include terminating null */ + InterfaceNameLen++; + + /* allocate interface name */ + InterfaceName = (LPWSTR) HeapAlloc(GetProcessHeap(), 0, InterfaceNameLen * sizeof(WCHAR)); + + if (!InterfaceName) + { + /* no memory */ + RegCloseKey(hKey); + return ERROR_OUTOFMEMORY; + } + + /* no enumerate all interfaces */ + for(Index = 0; Index < NumInterfaces; Index++) + { + /* query interface name */ + Length = InterfaceNameLen; + Status = RegEnumKeyExW(hKey, Index, InterfaceName, &Length, NULL, NULL, NULL, NULL); + + if (Status == ERROR_SUCCESS) + { + /* make sure it is null terminated */ + InterfaceName[Length] = L'\0'; + + /* now open child key */ + Status = RegOpenKeyExW(hKey, InterfaceName, 0, KEY_READ, &hInterface); + + if (Status == ERROR_SUCCESS) + { + /* perform enumeration callback */ + CallbackRoutine(hInterface, InterfaceName, InterfaceCallbackContext); + + /* close interface key */ + RegCloseKey(hInterface); + } + } + } + + /* free interface name */ + HeapFree(GetProcessHeap(), 0, InterfaceName); + + /* close root interface key */ + RegCloseKey(hKey); + + /* done */ + return Status; +} + +VOID +CountNameServerCallback( + IN LPWSTR InterfaceName, + IN LPWSTR Server, + IN PVOID CallbackContext) +{ + /* get context */ + PNAME_SERVER_LIST_PRIVATE Data = (PNAME_SERVER_LIST_PRIVATE)CallbackContext; + + /* increment server count */ Data->NumServers++; } -static void CreateNameServerListEnumIfFuncCount( HKEY RegHandle, - PWCHAR InterfaceName, - PVOID _Data ) { - PNAME_SERVER_LIST_PRIVATE Data = (PNAME_SERVER_LIST_PRIVATE)_Data; - EnumNameServers(RegHandle,InterfaceName,Data, - CreateNameServerListEnumNamesFuncCount); +VOID +CountServerCallbackTrampoline( + HKEY ChildKeyHandle, + LPWSTR ChildKeyName, + PVOID CallbackContext) +{ + EnumNameServers(ChildKeyHandle, ChildKeyName, CallbackContext, CountNameServerCallback); } -VOID CreateNameServerListEnumNamesFunc( - PWCHAR Interface, - PWCHAR Server, - PVOID _Data ) +LSTATUS +CountNameServers( + IN PNAME_SERVER_LIST_PRIVATE PrivateData ) { - PNAME_SERVER_LIST_PRIVATE Data = (PNAME_SERVER_LIST_PRIVATE)_Data; + return EnumInterfaces(CountServerCallbackTrampoline, (PVOID)PrivateData); +} +VOID +CreateNameServerListCallback( + IN LPWSTR InterfaceName, + IN LPWSTR Server, + IN PVOID CallbackContext) +{ + /* get context */ + PNAME_SERVER_LIST_PRIVATE Data = (PNAME_SERVER_LIST_PRIVATE)CallbackContext; + + /* convert to ansi ns string */ if (WideCharToMultiByte(CP_ACP, 0, Server, -1, Data->pCurrent->IpAddress.String, 16, NULL, NULL)) { - Data->pCurrent->Next = (struct _IP_ADDR_STRING*)(char*)Data->pCurrent + sizeof(IP_ADDR_STRING); + /* store offset to next name server struct */ + Data->pCurrent->Next = (struct _IP_ADDR_STRING*)(Data->pCurrent + 1); + + /* move to next entry */ Data->pCurrent = Data->pCurrent->Next; + + /* increment server count */ Data->NumServers++; } else { + /* failed to convert dns server */ Data->pCurrent->IpAddress.String[0] = '\0'; } } -static void CreateNameServerListEnumIfFunc( HKEY RegHandle, - PWCHAR InterfaceName, - PVOID _Data ) { - PNAME_SERVER_LIST_PRIVATE Data = (PNAME_SERVER_LIST_PRIVATE)_Data; - EnumNameServers(RegHandle,InterfaceName,Data, - CreateNameServerListEnumNamesFunc); +VOID +CreateNameServerListCallbackTrampoline( + HKEY ChildKeyHandle, + LPWSTR ChildKeyName, + PVOID CallbackContext) +{ + EnumNameServers(ChildKeyHandle, ChildKeyName, CallbackContext, CreateNameServerListCallback); } -static int CountNameServers( PNAME_SERVER_LIST_PRIVATE PrivateData ) { - EnumInterfaces(PrivateData,CreateNameServerListEnumIfFuncCount); - return PrivateData->NumServers; +LSTATUS +MakeNameServerList( + PNAME_SERVER_LIST_PRIVATE PrivateData ) +{ + return EnumInterfaces(CreateNameServerListCallbackTrampoline, (PVOID)PrivateData); } -static void MakeNameServerList( PNAME_SERVER_LIST_PRIVATE PrivateData ) { - EnumInterfaces(PrivateData,CreateNameServerListEnumIfFunc); -} - -PIPHLP_RES_INFO getResInfo() { - DWORD ServerCount; +PIPHLP_RES_INFO +getResInfo() +{ NAME_SERVER_LIST_PRIVATE PrivateNSEnum; PIPHLP_RES_INFO ResInfo; - IP_ADDR_STRING * DnsList; + IP_ADDR_STRING * DnsList = NULL; + LSTATUS Status; PrivateNSEnum.NumServers = 0; - ServerCount = CountNameServers( &PrivateNSEnum ); - PrivateNSEnum.NumServers = ServerCount; - DnsList = HeapAlloc(GetProcessHeap(), 0, ServerCount * sizeof(IP_ADDR_STRING)); - if (!DnsList) return NULL; + /* count name servers */ + Status = CountNameServers(&PrivateNSEnum); - ZeroMemory(DnsList, ServerCount * sizeof(IP_ADDR_STRING)); - - ResInfo = (PIPHLP_RES_INFO)RtlAllocateHeap ( GetProcessHeap(), 0, sizeof(IPHLP_RES_INFO)); - if( !ResInfo ) + if (Status != ERROR_SUCCESS) { - HeapFree( GetProcessHeap(), 0, DnsList ); + /* failed to enumerate name servers */ return NULL; } - PrivateNSEnum.NumServers = 0; - PrivateNSEnum.pCurrent = DnsList; + /* are there any servers */ + if (PrivateNSEnum.NumServers) + { + /* allocate dns servers */ + DnsList = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, PrivateNSEnum.NumServers * sizeof(IP_ADDR_STRING)); - MakeNameServerList( &PrivateNSEnum ); - ResInfo->DnsList = DnsList; - ResInfo->riCount = PrivateNSEnum.NumServers; + if (!DnsList) + { + /* no memory */ + return NULL; + } + } + /* allocate private struct */ + ResInfo = (PIPHLP_RES_INFO)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IPHLP_RES_INFO)); + + if(!ResInfo) + { + /* no memory */ + if (DnsList) + { + /* free dns list */ + HeapFree( GetProcessHeap(), 0, DnsList); + } + return NULL; + } + + /* are there any servers */ + if (PrivateNSEnum.NumServers) + { + /* initialize enumeration context */ + PrivateNSEnum.NumServers = 0; + PrivateNSEnum.pCurrent = DnsList; + + /* enumerate servers */ + MakeNameServerList( &PrivateNSEnum ); + + /* store result */ + ResInfo->DnsList = DnsList; + ResInfo->riCount = PrivateNSEnum.NumServers; + } + + /* done */ return ResInfo; } diff --git a/reactos/dll/win32/netcfgx/tcpipconf_notify.c b/reactos/dll/win32/netcfgx/tcpipconf_notify.c index 5238d60c72e..e3f570b4455 100644 --- a/reactos/dll/win32/netcfgx/tcpipconf_notify.c +++ b/reactos/dll/win32/netcfgx/tcpipconf_notify.c @@ -2765,11 +2765,12 @@ LoadFilterSettings( HRESULT Initialize(TcpipConfNotifyImpl * This) { - DWORD dwSize; + DWORD dwSize, Status; WCHAR szBuffer[50]; IP_ADAPTER_INFO * pCurrentAdapter; IP_ADAPTER_INFO * pInfo; PIP_PER_ADAPTER_INFO pPerInfo; + IP_PER_ADAPTER_INFO Info; LPOLESTR pStr; HRESULT hr; BOOL bFound; @@ -2846,13 +2847,17 @@ Initialize(TcpipConfNotifyImpl * This) CopyIpAddrString(&pCurrentAdapter->IpAddressList, &pCurSettings->Ip, SUBMASK, NULL); CopyIpAddrString(&pCurrentAdapter->GatewayList, &pCurSettings->Gw, METRIC, NULL); //FIXME } - uLength = 0; - if (GetPerAdapterInfo(pCurrentAdapter->Index, NULL, &uLength) == ERROR_BUFFER_OVERFLOW) + + uLength = sizeof(IP_PER_ADAPTER_INFO); + ZeroMemory(&Info, sizeof(IP_PER_ADAPTER_INFO)); + + if (GetPerAdapterInfo(pCurrentAdapter->Index, &Info, &uLength) == ERROR_BUFFER_OVERFLOW) { pPerInfo = (PIP_PER_ADAPTER_INFO)CoTaskMemAlloc(uLength); if (pPerInfo) { - if (GetPerAdapterInfo(pCurrentAdapter->Index, pPerInfo, &uLength) == NOERROR) + Status = GetPerAdapterInfo(pCurrentAdapter->Index, pPerInfo, &uLength); + if (Status == NOERROR) { if (!pPerInfo->AutoconfigActive) { @@ -2862,9 +2867,8 @@ Initialize(TcpipConfNotifyImpl * This) } CoTaskMemFree(pPerInfo); } + } - - if (FAILED(LoadFilterSettings(This))) return E_FAIL; @@ -3284,16 +3288,15 @@ INetCfgComponentControl_fnApplyRegistryChanges( if (!pCurrentConfig->Ns || pCurrentConfig->AutoconfigActive) { - RegSetValueExW(hKey, L"NameServer", 0, REG_SZ, (LPBYTE)L"", 1 * sizeof(WCHAR)); + RegDeleteValueW(hKey, L"NameServer"); } else { pStr = CreateMultiSzString(pCurrentConfig->Ns, IPADDR, &dwSize, TRUE); if(pStr) { - RegSetValueExW(hKey, L"NameServer", 0, REG_SZ, (LPBYTE)pStr, dwSize); - RegDeleteValueW(hKey, L"DhcpNameServer"); + //RegDeleteValueW(hKey, L"DhcpNameServer"); CoTaskMemFree(pStr); } } From cbc098ed885dcae25c41c2673b8f97bbf97c14a4 Mon Sep 17 00:00:00 2001 From: Johannes Anderwald Date: Sat, 1 Jan 2011 21:34:17 +0000 Subject: [PATCH 180/181] [NETCFGX] - Fix case where there is only one static dns server set svn path=/trunk/; revision=50258 --- reactos/dll/win32/netcfgx/tcpipconf_notify.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/reactos/dll/win32/netcfgx/tcpipconf_notify.c b/reactos/dll/win32/netcfgx/tcpipconf_notify.c index e3f570b4455..db8ec1b9bc8 100644 --- a/reactos/dll/win32/netcfgx/tcpipconf_notify.c +++ b/reactos/dll/win32/netcfgx/tcpipconf_notify.c @@ -2867,8 +2867,16 @@ Initialize(TcpipConfNotifyImpl * This) } CoTaskMemFree(pPerInfo); } - } + else + { + if (!Info.AutoconfigActive) + { + CopyIpAddrString(&Info.DnsServerList, &pCurSettings->Ns, IPADDR, NULL); + } + pCurSettings->AutoconfigActive = Info.AutoconfigActive; + } + if (FAILED(LoadFilterSettings(This))) return E_FAIL; From ebef3b756cbd7be254be60b35a96a9e2ee7c2b30 Mon Sep 17 00:00:00 2001 From: Aleksey Bragin Date: Sun, 2 Jan 2011 09:30:24 +0000 Subject: [PATCH 181/181] [NTOS] - Temporary bring back the old boot image until I or sir_richard commit a proper fix. svn path=/trunk/; revision=50259 --- reactos/ntoskrnl/inbv/logo/1.bmp | Bin 21624 -> 20504 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/reactos/ntoskrnl/inbv/logo/1.bmp b/reactos/ntoskrnl/inbv/logo/1.bmp index c8273826e8d3cf79eed09a86019ded74577c8e96..d13c48d16c07e2c5fb1d83be380c54637d2ddcf5 100644 GIT binary patch literal 20504 zcmeI4e{@^tdEeiAXNbd*qC z5{mqzTPe~@y4Y0;0*q?ebqfOwkL9F0Dgm-}*R^p>kUKu}#tP)6^jEzm6lt&7ag~$= z=(+PukH+2Sc>z#z&i2RtS^GyKg8(k>`+cAHdA`q&_s7jo|C9EIl>XlZ{vPD@gsIdU zhEj&QOYu>C^Ou!s`LWu|;k&%#f1P_is=D_6BlYo*->ZK4Q=Q6vs7J;B#jmKb-}vY1 zx$$9@|F;wBKfUx#^_Qi8r-TK~l)jR*=?^Kn4Uj^eI>U*0~z0FD;Q&)U- zdFzIL+iZH#{{!XwuPR%qJ)27H@;7aNa&uG3KTD}E9QL1oMX9DM{({==zrw|4b$Jt* zO||8}pdNky7+;MW+gw(Db)c&L6b;mRvNm@ODD{r@wtiE`o^86)t&HazJ!OD<);Rk0emX5=z0b91M!K(l(38kPU90!y`^7}}I!s<))CpOHQqFMZ3MU+Mmn)d3h( z*J7yIe^Q0?*vw5+MrPIJw>Pcp1NHvi0Ec_t;$N-5iCgNw%Ru=3xQy-XTA$7b`;)Ob z>Q;AE{aMXs-OcL!z^;KyD$ugI>j?n>#oWC7M4-lvjQxuG#xb=W-Hz&htl)OH*y1hv z`RS~YR@H$=Y1I5Gf3~|X$wywho@jrXOK&r(Z`Jy_SF~*0_@1);CtzW-zp0J&whGqz z*Ne+C)NKEbQWZ$I$sO}`W2np_X@s=^1&Ub`7CckofW#{<6BujO~r z_8w#wrWts|ZoZ2>s_L(3H>DBe)Bi039OMqh5i$oDsnzU@rK{=zTGW5pWxjwMhME1L z>rLicjxs;qxXPG*e#axX@Jjn#RE;3JeQf|-l2Dh+JtLBKG{e?c^-DeQs=}7A%HOmq zZ_2L$EXk*;`Yuv{d;gCAZ8-@QdcKCc&~!tzj1!{G-2>{p1L64G`e?UOk9IeG^ZssZ z(-|C4>XCs*_`9j!YkFx@rg%ng&CB+vW6cnaJKg}WMiD{HJ>c(px{hkSfO=lo)!Foh zpc=0#wVa4qpbGDLYY5FMx9bIs+W4*+`q{U?FP=$95b6zig`B20WcZ5C-ckm? zZPwm*P&aSO`Z43JCh-xmadX{^ko6F};|iCoXLfJOtNGb43sCGW57JPBWaNS^y}eQLm=Ms%AI2FAc`;is`vs95E@XAXlDrc zSL(i@R70O?7bDiMZWVzIn|G=byVoRC+7}Mh_z6eVp@x-}_4NG%)-#6(jQ<>VB%*W% z2R`z~|H;ZVpV$LNfEThK(iDVwqW#+I3uqpUJyvDAQ+TKNew%-vp`CF2lW0xe{~>47 zAIbOkYaa*|Fk|VNiW>D*pt_iicdBi8)42YI8s(1AkFNhe>fwj=`6Hg!c>dp%*=+hm zHS1CTY009&5C5@Wo$7SRf=!nyeyLl6nOrv>ulVa1$>YAc$*;k?AD=Ex{YEQn{MqT* z=cu?~X$_5xVH>{h*vkAwz&E$eZYmMWybZ7h#g!m9+m6Qh3fI0tTn2?-KJ3tzchj5>6wPOd!?z`3d=wOn z>WaU0Mwy9<{|evQgT9|}jD+vMMeRUR+vWRLyVZd!KE)b+g3H+3o2HAizvifxM6viy zzB_^9OWo>d@!Pk1;Hqs@dmDTQVOOMtK@)_@e`~7Xn3tYKEZQ?T|R1Jxgz5~NQRpOIN-#Q1u#ldr`m7^nF)^Upshf5q?C=)0&oxjXnMA@0U| zd6aZcz4H-dRd(?qaDT!4_HA709TmuEKW6&vd}~5>!8``0 zjAOT!Qbu)8@f!-}I>z)%*rn)z^-=TX4`PW1z6#e7?k0_aPS?g2?YH>5JZWPV%sRD6tz29)A$6pp6_9GlW@co5!;Bav<58y2@D}P7Q?C8M2VrXCwj#aus-maVsWm$x-a z&>y(Re??GaP{Q5aX!lMOIB=KwCF=u`3Hd@V`VQWt?HN4gL(;berNLT0*FE8bX!x9I zehsv%w{~KKpf&rCapNn(j^K@V#hC={h6qyks}QWin%dsCH3i=1LHp_tK7eL})Pz@o z?AZQW+U;-0fRE`IV7_Q>qg9Q!t0)#!kzaUOsk@8CZ$GHk@5FP2uS|{~1H<_Wa$r(o z`VU8~0N&a_tZ_;?U&K{AiZ40k9X!TG77!)Br{nEMum-KH7nwZsPQ0!1v-r;C+Deek z`o%y4_bxmHNkd=%bEUqB)Bs^!$%f2HYcZ$whQAe8O_1ejTD1qr4V^-r@9A98VN0$s zVmC-nOq$3_mV&W(U&t)}iBeyGNfsLFnCOpK`Uba{yU1BYYV)$rW8FHBJsQ%vQ8jCn zFTJc$Y@(-{{?i{q5oW=p`*$*HQ!TSTQOm4`&aBVSk6_vAqs51aPNB~iJC#DJ4@wju z{*q6EKk>X@y(XR%G}9ITI|JIgNRdA{UCZ~P!+VO~l$dEr%mlq?{t3~DzqdV0#&`_v z{pwCOn4WdSH>?hHO`ETqe=7Ddi7~fZVSUS}Y^i~rRzFEk$YPt*#co=WJ*3q=Xyb#e z9)OQKt?Z`a>_Z~KuV4f8^LcYtS_M9kJGm0*I_KkSwRVziKLttU{padgH$XqS*V#Ag z)^mLGdz1|IS^%k}7HIv~^;&>_|Ec=9;JonmRWk;j#5LbgkZnQ@k+$nb-aH4KHH&OCtCUd!@8{He}any18 z3P<(kwgh9Ff^3T36=_$ zGV!ixxEm&iqjar6wHaF~=&DdEH|cpfSNawVr!4_Q)^&qX6^y$>{0u@M8}E(oRfjbK zpIKf@K;+_kf@ciKLO-bKDv> zl!08T14FxRGMQq~umwbU1)bQX>t4yqtNpoLHp%S~7KfDd^>_~445P7n!ieJ#wFEnw z5bQuMC4{ty3gPhHa5RQ?a-alD-ukt;A?WLJf6HXKEZlPPLZNV%=pX=iLhJIEGEoNH zb>wrO6P02;9A!xB0YO;!G-v^97X`sCS4%yDOSTRfEs5)XbzQ;dbFi-C2^3JFTyt-bgu4j6XQ!pJPHd*n@-i)o83-fcP z8;Yu5at9$txtswUR4^}G7`gDd#Eh6rG^xT}*fghT0k5r`icC&=ulv;!z67quZbMw( z%cTNPJC(~ViUt=mkV;uG^^2~X%6a8#Rk}!}Mn^^l2gl-x>*Yl}RjVP|6-~_0#>S-u zBf|Z@zn-Cjlc>oH-fUxz@jN`+vwI|^U%6sr`Es(`DGrzYkY@cYR@JZFqCjKznp zm)BWVsda%{&_f8nO1f@LQ1FYv9QAK0smCF`w57eOUrI)MaYYsCLgRI>cxdq=;cG0N z%g@ZMRjS*`p&Y6jO}Y0i(?>3K;UA;=+ulOVs$oRBqC=B@)x-B>BxDO2iC0+{v0&U0 zCk(m7uHO23CO(+U=L>};Z>>`Pj-68XkESlfp4T0WB`D>lG!9@>6WZZ;RP?71GId83eGf#|2sm_dhsZw6bXU9fHQmJ@! zNHiotHA*aO6}~2x%bu6%sbx8OYn${+*S%z?%#ZeK?-cOLlzVQexVX54Jr3q`>GX5) zFPF>S%h}ZEXeyPACBO~lGI*5Jj?7K?0Q5R-)U!Xhj4S5}qv*BU!98O`xe2dQtzL7# z>=kDhi%VW15BKhM6Xo*FMKSSMDj6Ra-AE9S$~*$Y1?8f%gBwnGrSwc4_kaLAEPYe_{)?j;{1=CTT%v^^I;wX}_pJ z+Xe6D+IL)*bWkU#dkRUn4lBe+YAqmfoP?XXEir7!#$%#ia64fG?w!gNz+GBhE87+I zU>R}OljnWpEf%0f#(kcTvv~=(qoZS|VFPxXSd7Qcd6{rs6RqL%UM3!!MBWg%nhj#M zLUC?>wOqEVs=K_pT3#5cAn(%BY++_f%(uRn&*9?%A+jU<)r^S75_ck}iS|*^1hL`^ z&W^;z;tCR1%H?XgyixwX`=UsEbFR2la?e%i1pQ{Mlr?Im%zs%&E=iuqYMI|)Rm_N7 z@{-Z02rY5wfRtyNY}3Vgk-A!`kdl;B)5gX!p52yV{vfskT>K1Xu zwzr{^mP;ihpDei|`TY_pNCK#2epw4%t%~T^hA?J%)w-!VSO3BlmMrG;*(uSsHA)w$ zi!z^UHQgD|af}{8uSpMIdZXtTFLugor&DW2bUv*WQ)UbPsC2LnN2G_<<<;+CO3}h(8Nbqm+ny;Me+Sp~TtSd%i@pqmMl`4QaDt%`&?|X4UlRDUg9M zRTU_!eRb~4!kyd%K2JAe^l?%8Xd0rA78%8zeOxMC?1@6A9_iz#=xGS5PZw8F6DiZL z@ZT+%<5$3sT*U&_^`$~VSrg>%H2eukh)t)uB_g*H`(KSlj!xd8DGWgmpO7AGb|DP| z)@w@$=gXCf?xC8zA`#{g7s}P|V+ns_g+a(La%s}B`6TFVpg$Xp3{76^y<-Gjm(Wtn zQ7_Xg`1^?igjk%ls9A*ctPm}j=PVyT*za#ApAxDvf?OI?WV5ZQI`YMy$WiZu$mhL_ z-7PUMdq$8uMgJs)!t@-1S1VPSac#RdkULN{ubK(uZ`)X!ot>UdP7rXBT3OlDfW*?a zSlWyChyiX(-fncAFJ<<&L?w(f)7c}sAJr7ax|J%ke=}n~LN5miIp23**K*GiG5>G~ z;R7i%Yp2Y#nI!tP6BE2>Ph`kj=yHTV@bqZ!IWO7MRP!)Ju+eJ4un1oTd&?Yhe6_!t zd|ntzxGBu7tzS5o&$h!!;!~UUsh+09%tDurx!@i(y6(r2M)Z8?VmCpTJAtx` z^Mo0YZKX%8F9B_%1!(fS0tS z;}{(2Zqc#5C3*=C3PloG36X1MG`?UyjO-cnVOB_;YL$X8?G?$cZ8K|?tAnW#@W+@Q znzFwD_T;r_PmM7WBYE}Ks27GS$sQvjYR`+>iR;>P1}j?YTSLTopEc-;RaSO#a%q-6 zcF&jB&pu8cV={tKM(~96q9d3SmRR3i@1?uOMI%bq>VY(a*}D4C{#El)MgS-2ubUB6 z{9A+GbOAAz%L{{2z%c}TC~N+$v0pF4gUiSShcap@KE6gLl6a;nMWX%EMM~7%1`__h``(SPBa2JvBv}%c;FHy6* zsVv?K^>^f7FwbM_3Yqo@OOJ^HC0%ZMZNq(BxFh(4_9sCX3opdF737ac!IjGH-Wo%3 zSxL3`rN_0q61lKvUHD*3hL~Ta$G_ef!Kh@vteLIhdl#cJ3oS)^ z>iCD7V5jRC2V!0>9v{kP^TfxpWDG5TJw|qrM9O7?vj4t2o+qd)r!ZH3)5QdVQMEsn zPCulK7%p^1343Clb@UjTStRX=d%4k+gdK7cH1xNISZ0&kwL-sm*BA7NAOKI)HOf=JwJ<;l`d&#fJE-^p(MGBAf#9a9` z$V1tOUO-zg64Y~2CHjs%p<<*;9zU7jS(&N)> z+d>;}?3?Yz^Ai0D5ws4tfV7_Z6+I`i_vLrQqO7VBeoTrc)tSm>HA#?9+p><_EsAg*p}HWC*JOrrwHUw-(aA~$*yYs}QtEvbCx{!?YZ6 zbKG;i@-3$4f=i2Ek46cF7sFe1sM(Sf}9iFRtFa zNtatLzB!I2{+BCt9oXsIZylXP!Kw?NjNd}Pybjm$g~6N!V8q36{+kciq}|sp5)If!qwd&P`uBbZ^IQ@G^v#}_m<-Az$4r&~FccR<->f%Bu_Xeo0c|&xdI^Y6= zN^e_kQ4zy?r>|GubD3u$YbuwCWzcP%$aU01k!V7aJ-JP8nV4qUcI#Y?2j_Q7RE4@5 z8>=^0Zr&7OzgV1|EzXlW&*cIs)sdcx$>=3)#A<8U;2tt!x)e0JL{dqZYZYosBu$zx zYDxE$%WDjOd2W7LWL;uMS%p^0a3Y^&@kn*#am2lW1%v7iW#-zA;oZ zF}+&e;?SRFtn7T&ZDm8RoA!zdu5kw7%d6HrpDKQGT;^Hr>4~3aO-A$@Jp-afZ9%Va zHhc=j!-CcFRqY3O*zViRYFnOPo?nHwTSIFKriI9%f0IC3y;hJr-PJ9Mg}V*Zx?Y`s z#-d8L@JDOwlyk5&$=l%U)x`K_zCrn_wGD$`C&z@jRtk)6a6kU1GOhtrSEv zMsDtn$hs7fBy)v!0j5LSLkd)z2qohStgWrCtuaqECGIB88+gJ2zv90;#L`nL`+I=a zSX7sDk7zL)ZxPhO^mm8!s){6pg-79gKw>q!9%XAIzzmWeyWeDHC%;#d69km>?=x(1 zc1Q5adffQs5gGQx^ui;)�_zDl2qYX=COOM(}-?Ih=gj{pPtmAW7AP;$wQP7mUM% zw#Cd(2}WU#@|xINsl0Z+Lt+JUrbszZk$P?6DgIPcr;iy53@#%C!KXnGN%Y7v?#Ku; zm}~53%G{lb`UVGW1%p!-y&EbCJBK{eLQ50Q^A<-kgfPiHR6 z^m(oPeRd^~2uW;app33vFwqP;6U;z{i8h1xRr|X`j1o-7$mwN$$aHs0JW(11aH8O{ zgn$oO<&3WOMd!?&u^w}2yBa9lYxsxuXXYC=OsRt2US$fCPU%$HQ^!1jElWd!dG)+s zC7`TodomaF0~K;Y6;^Bn8?2L}h>k?kN2}aK_o}PHr7UFU$t(_Y#&=ylUACAZJiXslD!)l^WfO%c;;c5pU*D+ z1?o|Iumst9dC3E8PPNrm4urPa9`@BMdfbtPL^eC5$680bmn?N3Xzq*E^;xE5Np1va zO~DtNxW6o`wo8jki;J_w=!mR135oQ4VN1`c+UaD=&7~8V+7Z;hlQoFwhet=JhAQP1 zvQVhR(3#K?H_bJ3El}pKtoH<#yt$bf6(}fYRu;3U?kt(n@4-4aH$f+z9eUR7(feMY z?l*d^u~g;}k#wSf#mgJkO> zFV=!TG@5o_EUy$;t8i~rHas$sr#i(N%kt0jw1_f>yxdcm)|pC|ay8BF*=G5Q;D$$L zqbNXQze7}TT2rZ^%EoMdDnFH|R&NI8Y|pw0dT7pD^k!JSvGc)#3NUiCE$c`~+L5^; z6&-Wx6q`kQmlCXQM>IluaWs1nC0GAcia%U)I;v9oDxsJu~Nt?TMJe`B#wh|HKvrWXKbg4Lr?PPK~eWMOV~ ztv=GWh09W{tW_^YyG1H_bu=Zms%ec2h=f3*tcgq>5tY?c}~XN_YI zTLvmvjI(Vkp*dSwKxcKVV9VJn<;5wPC%6?xi}`{Dd(kdfdDhHwHtRNOPc}O>B`d#o z*t0cxePeZHwQ?)kQ%5=+b;}#GRPCAb<#kr{Ccr98F%%=S0@@jE*o+Y5}2GX9E==JqklELqv*Fq{QE$fTzXp5o@EPF)lrbrS$z+YJ+ zUbQx;I(`4O-vnz;Pkn_G_}0D5Tdpq^NOkV>?D0wciRsd;$kjE*oN&w>3yi3s)G~!> z&WEm;E5vH>wi2r>h2>;2)bQ1yEJ`irWWIV5Gswi7Sv|24?Pq~xEl#zwt9W6U0h3}l zZ4sQO-soUPken|Treslc2kijULD}O-Vbi5-N}7x^MDT2(STJRcuuCyAI4lWS#=5Ek zD{BAh{QOFh8t}E>Tq#^-2{hVMk0k8&vLP>3OyI&(8!z)V!m9h|9$wandBGg9PN`50 zYlYAhS|OIU%Q%+`&$0s)*Eqz^-7=qKS0t4>S^nFpvET?3IYevKy0S;iQ`WHBr&Fkq zf;c^2Tv?gN8C1u7rFx-Qc=7-XV~n#N-8)#B@iK!Wsbm5pC_zButr&yRo!%Q+%w zhb|0X7#=>=KYXeV$n0TtMcMOeAAp7FHLB9t&WJ0^M-9Xd(O&#Rr&1@cuTPCA#uxx~ zWKeaCScB>acxTV{_n$g7nx4>0;;XAdJ_Ll*?f;=tbzhcB6fMfA$>F<=F0^>2Wh9wc z`|fk--s}gnogL?q!4a&=%er6=o5R-GK)(tOk7DCxd(|phE1Z1NsEj-_#+rm^vyOUD z>#|1;4nJIed2AS!@gKM$wwVV9FN~0${P? zze)b7DYRZ~9B%58JqC5keSTwV49xyvLAF62Jax()9=@Qgldb*gxM0f4;5>>X%&hRn zTGg8W9t%#gARq0lBcjh4+0u#qOnF80*{>qQfC}na(XMlL_^f;KWdB)EL!#ES>?N?S z2#@v^rdXX?^Q(Z0QqS}>s-jNT_j4>I{1j9g8^OZh2C+1-_DQqfJnQtUz={68{yyok zU3>~giI4@@z8~X{v+Px=LQknRFX|eOs&%)~E9-_Vbo?fK8n*k*Q}Wu~AMC?A58{I3 zz!dTm<2d4MAv*<4%kK*zQDde{#th1Su@3Xtmgpa^PmO5?f->CRZ}!<}9 zL#tG78kii5aD~~z6haaH*IACLTcuG;i&a=(Z;4(1?v!vmfJ|-u!4t|leu6(DTib{* zr^wEroI)t5{drlrU0t1#6=Y5E&N|w`h%np{?=FpvU<&b&)_%KB*~d>D@3W38`$S)# zNZ5JmR84J!xHL(tV2!IiEFi2rE`D9NNFBAkZV^VFAF+o;Li1FxAK|owDk9kYrV(bDG~|S5~I~YmbpM*>8Y_(e5qH@#XxU2Smw*@RfwOB2M`viM+926 ziuC>ceaDZV0KfGFCLlmTb!rP%28h!sb%6D=`PKiTy}no0jt`dSLrh;J9-7`uh8c&r&y8>|#nr=+?UcX;H`v!m+EEkxj;)&N^~OFCzK;n_tjLLFIW@mljHjQ551*Wl3HDbtL!Ukjx4fFR7c+} z8)|3RBoh8f91M(LA;~2DCKf~&&IwV4oNPi|*)y|J=<8rg>w--nS>Nk64zOdfw}Hvt zJZD)jq3nwE1x}eG<_Hx~NV0**3ThAy<80W=NssH@+%ZOUh}6u|_X`>pFEQE(u;GTR zoqKWUUTwTH95e18Mh^CW5o-!P21iD)VLy5Z^!J|~=BH8Ru+%U?()+uD&pGxKPQ&cVt z3fGyQ-}p{5pA!eTU$nl3Uu zJ4>iQNN5u{9z=H43iSBI6c>jXM<7+0U%Mqc%k8X;m!b~2qI8GsEo2`jf|cWP+S=(u z^b}PwxuCT$#i1aP9Zxs=%sw)k16MfQm6i%gKBv*k(;6FuGu>ffc0(_1oD^bH1qQNe z$33CDB>a+V0?Z_53nKJMtrznIQOgmfQ6vg-L~fk;qtzccHM!X@ySP`p=JW@#9bsax zoLxB7FVMswYL{Yx9Yd%haSypgYVff1*ofq7KCuVz4LSSX#y~@=_XA5dmm&^jh`?z1(^}K$Lt;6aXcPBGFIr*;i8(iQwbwyn_Hf~byxNR*4irHW zDI-7*-hFDcP+Xz*XayP@4iBF=VG~u49LF)GvgnZf4TnVH?>cf4MtE213A2U$uWsWy zN43NxLVZu*XMvrUnkFK}hZdQ1h#o|0WDZgaN`w-|JtHTA+JteSUh-Hi+>!R^%(Zw} zsG(8qyGF*RsnlD+tjkJ13>^71p<41*Py+X`R2w1qhQPPXHLY&|= zAZKV=E_u%aviPJSwg4%D6=P%z!j24QV)|QhmW~a~4C$4#X)+ou$Ap)ZGVrvV zfolH{K|;b8){$yJ5c=v7f`IdKr<}kN59>P*Ycx%AP)e!`es5#)D<>Lt6bK%- zYwg7{g_pZKMF!oTgE%`fG^II3z||g3q?rd~=0^RYM?p@gX+n=7|KL99|8Z}DEW^pY zhAzo3`M54__}%_-(gvKhPMnY;PuepA7>p9~59!l%A_3Ikd4Yx&3^`7y5%w#yl}al_ zB?nh=UENx{))db%*5qfQ(c{$EPHVo#8AFepe6tLri9|_-sq0nxZqqTakl~=SJ|QS) zD6&$P)~iXUjUb!G1Zc0FGxO1&@P5%A7~&~}i_ugz9*M@~q$L`Z_SfL?=|+3T^X#NI zbw*gixkZj}_c-Ccc3sm_qzqHNx*W`A;fOn&So$WdGmVPVF@`2Hlh;de&BNLW5jm)@ z!pHH2edz7iIyw3uld{$2khSnt&NyDbmLPrU>XMm&6U!}JDw8Gg{tm<7BtFN`OEPPb zs=zY3`Vwy>5fxce{1%nd`Vmfo=h!1ixQ$u#iI(K~ zitlCJSPam(9JQOA@t`E9kim7jIKG~BF`Ut2#W?LkXPg1$xH9trPaTkFEZjJ|Zt|c2 z2d@`cca@nhFZP{2@w)%MJhUKZ>v>{fh8CaUG(bb*q1<9F9(KY;3p<|rz_>i>!7)Zo z4DOR%6KR=Bb9(!I+0PSPR!*oomO07hv9@Q+^Z^pKe3ynN_7Ck(Fb-B~H(nU$m0tLvQ2w>X0@C&o``E5Yyd zgn-3Fq;OYU;PRYqrl}C67rY5t1+9Dz6)!7o@ACg;6G^~gh=DnJIi(MtKJl#|zz{&q z-fj>HS3-9=*ewt2boKVqz2&k3$ARh0Ua$l&gjexZpRu>Qx_ZNw!?`%<2BAD}G0BL- zQZXDBrSXJ-*WkN>p?Z7eWWFmBVP`>nk67Ho*h)N-A#2)jw{0J!*WxWE_46V44=3;7 zxbPL5#Mz^j`-DP*)1^0>z##Zxi(1dmyyC*@Zg zi_pfbwK}ADJb*(}i^w_whk4FIIMS{6Kcaj?HIp+lo;+p6^9a(e-jX!q=x~Jh5_V_@ zxsOUzQg_Z{>f*$mG}8RmHd~#tj2%+pQ~plM%2u| zn^gb##c!!UtNeSlT&<|TSgEROKlr|S_rL#*YVhxC;QYV(yF*#6TB$qlSLb|n_QnH`>xui>lW3!c3r)z_B`%91r5Zo zH+QIpTh*g*BRDtQ%~pQfn`%aA>pjoo1s`wH6`A9$Pq!MX0o`|;8&7e?MF;lZRv$NH zMP#l--c9u>UiZtVZfG;0>)cFtkGa-YVRf$`d=KS!OY~Pfz*5-$Q;PDXTUi7-%nmsKZ5oqv=52Q?*!CbzP^dD2<)nBy$$szfo;25)ybhfLuXXDZFA4#f{Ls^ zlHZQCdG_&e;8UG>=N0wM`_)!rD z@zFbY(svCt~;07pJ@yUt=54zgw`~Y zb$0pRRPVh0F88%Qf`>=B>OVnE=~mU@Z-!oY&ux8V^Q%4-oANoW>eHL}u#3fi$2!;j zKZMEwK}`gDyYJUpeml-*@_Ce3LtP9s^@&C+iLsW+uk&s*MhmG!CZPm$@s zPCVZrrk(3p9J_UH65_@hL^M2ybkTYmit$#}>c47UT&3@O72CGr!_KB%e^X==?`fzt zI1%ifn7!eqRrI+48?Rn$xnj)wu4o{n%BV}B#>Q}+(pPk(YK^j~5w)Y~INAARF* z+dhbzePBp#A>xdG!i#S8<>%S!J3sAT@ui5VF1x zi+s^srde;e1F?xv*qbuZ^s{h zZg&1zdNuqsz@tM6(dUy}txt!2rMG(NAhdmj_s$TBkxZ#u&V_wzQ9k!2x84;gEByy9 z?>_33tru^`QuZGIU9ziXM}6xC*ykePY`KDCeU;C?33s6I%|~4B6-;Y3T(+Km^Cpf& zLRt^9{W<@}ab>0J{wv%ck-j4DhSL1D-zI0%zwP0@d%joQdCqV23a>`~c*|^g{#RYq zmR7oKeG8gyxcp+TI#_;bmkysgp}Ox<37tLu4VSy^PJc`2+E=J?{0`siZy7quK1Y|s z9rjoK|0drAbeu1gU+Sge+y#{f&Z`=M2^L@+fH=1<7b#5!qKOmO>nev|){80Hj@~z!ce*Ob=?niUNLCAkc z>bPyy%^CxGj|(0270?m-^8G&e;dsy+78XWXz;>i*Wi8Z15*NC<>he;?P% z%0k(?{FGv~p}+Aba{t$Fl0~d>#cw?0?A$Ne!Q8HP@4p@X<^C_f2!Hl%<(F>qHabJc zA);+TaNcP3#j<}3!6`pr5Psn$LHGjxyQ>Kh?sv#J4HsT@{hdI9S5U#<)`mzU))j6( zHZNI-n0tN~OKc*U!FoloUU*lqZ2xhLB3L$p?b=7K_)uB2EH<`2r^#pY-Md&4pP$4+ za^2Z2L5lc8xBIUMk_ae19oXn*B;i1R*}f&05n<66d{^BcSU7UOuPpx^!P)j@-rp1> zH{(fET3-k6{I#7-B6zL-msA7}xKm#-eQgkFSKv(U5B`e!L(RD6vzs(W&in$HU;E)L zm=1U?#GGUV$A8<6T89sy5Y)EA1i;J3`Zn(8?^Gb zZ$%4}(aFe>pLou1T$DJBSh>3Yy&;K$5QX@M$HWJ=v+uWdvafh+`P-7q%isRXTjabS z|Nj@}90ibYV)ZY~%U$7HYO{Raa{}A;2KOO>^O^EX4^Y*Ae!HrN zp<}4dziA}1T3z4z!EwVK*T>;Xx{daKv(s%r`JbwvFMoIY`Y2iMh8x_0t#6m!haC1r zI-ke4ufcxydfrvPYH<1XBhqKRNS~$jZL`Gei`SsuP+!6ldZ(YWC(6%un||*9exJ;w z!nHytmF4PCLo^1rbe18@wPRN3S9mYK9T&%QxA=C8l&$PoTLKeU2g0#m|b= zXvRzIkN3Ii5ItZlegK$s(VnuFbcH!Z!ArWbUSnEJZ!(ZBwpUe@PZRt5V=_I9hhjbP z#6WIpPPtVTt`sv|&$a4rn%9S`)>4#vX7b7Yp8c*mNWKWg`+Ek`Qz}x`OW~?=iut6= z^>UBh#^-j`nu-+llv7oaVkU8*-@O})#(EAUyh*33E0LmAvAJ(1-xreD(gvlVy+}eu zl3t2SKnWL;{fYhRlgct$9mpBv;pc)uqBQ!H^sojish4MK7uBgmu7) zS#fOPc&S{G`*Z~xDc$GZ0lkoXqX&eBE<#l&to>ZyV<)tS{--LLkjc55%4)McClQI+ zA<%mgUaHA^s8k; zCPN@As-_)k!(KJFs`&9{X{QML6WnWMK{ur_nFxAV|d}27KbU|nJxC)OB zd%yHqg=WQL@O-pDbd$Q9?megC(7ar4tmpgSUC`aoz*OC@Rp%VM8_&n@q6roDhH)O` zV(kVUT~JPTd~{f!Qk|oxeknayHP~no-|NAl@boZIV1uEe)z|$-g_r|fUUo6^`f_cF&<->dPV^+wa{!SC zbTJ#wNVEV%ZC}q1xsqvlMMK`y>;5{i=i#w}Zja@P5@U8HDWa*a?BoTM@P1~Pm>X9} z)iFArOkJ+6Gxw1crb8wIB%&lPGup#fO-v0J>Ax!(BOA2h9l2`5uVfPagtChEU=;#N z?Ebl>(61gTaB_9*Slvi?YTY9-B86e*mR86RMOjRqFtC?;*3vUY4UuP)Uon1IeYud;V?rZC#ze!BVxIVPJBitrl=wSdc`UTu zTf{>Lr>e!O_#r&lZmf-zroyS>WVO!XMRi{EzEUmEFO@GUcJJVogXDGOjuh@V=Bm6UPkiV7G_v znyTbIuw9x4w&{BWJ5JS_DV3Mk4EJ^;pQ6^PpUR~D#>Uc2E?b-|dg;qBT_R47De6#s z;7rw{WIYiQjsvbgJy-Dtsx!x>8+FN|rWoRt4#0J|w%;#c%B!kld37;$1+Gg0*IlPl zmtmT}vSXvYO`S|ulj!jDwock(pN8iFF{q2jP|t7*rL#FbiT!4w5NLjHW2;oXy7oPf z=@mLgC-G9o3*gDbhkJ(=A_ALwX5Y4-V-n7z2^{SekREDV>swB{06&DE+q#}RP(W>hT3B%tNG->6f#6b z2IYOjlO^cb=mu8BN)Dk<3eerwaJBfkx zE)6G^tCG2uBbuUOy6%n~tR=%M$btXYtcJwXM(r){1!RHZRTa5VzEtr}NS@!gRHCZb zSsPih{|Y*Ea#IySMMXxMH%z5JQ_WD%lp_*Bi)w2miioGqmi2;#JW#4THTv*CYj$m8 zS+adJ&&mgz6LUg|Dlkfx%38hj5WCdoF79vY&S^VSF>*~+JVT4T6nKDG$Sp4{i)2!z zbWLQ_7gJKz8nsnrUsdkvpL*hO679M$Efv`&TUn=tn&r(I*$B8kp@wW7p*X(RpE$X6 zx?3{wUZcf8EL5m#9ES+#*z4Xo@dn)xt931}eh+78puowZklL2aMly0?2YGK%daeqw z51oKk8%^8({*x6lF0{6_sI!wurpp&JS`>N>Uw-CKVy{McSECNDCw{1llRAf7)sSc&+d2H2Kzl4|C zTv^QFgC^JKvb|Cx+S}6AR}=ArQ#a`kb3y0RLdTIjBQ-Hg^oySpOwg$}=`=FuY#)n7 z>b1sO-WAEs8!Pjr8Dydt$;GqQ6VT{@#xsd{YU*PDP15w7L33>ftNDJYP)CgaSt5^9 zDoZqpKlpW-h%KJ5eFxw6w=z$PXVk8WJoJ${OogS|vrQ_e`{DAWI+r2;c9MOniN1KMy4d52r{UQh{U@rKzLtc9t4u0vavU*a^c9{hBMnX_ zbZ(?viJi=ILc?j0=-?%KVQu}?iJ1b$*ODnlhvbArUrTy!vB%T^s36I`m^_p?SvlPc zg-(|SWth@}uCTbQ*)!+BHr7y`#7TL!bZM=A%_|a(;<>p9_BQBVburOxtZvW^|Kd*} zyf;JV%zm?2B8?@=3zF3Y{aRW$zkxO2d>@>zTq@1aE!1n7wCNnMgw9Cz#h<2LO}K*J zw}amX{;^QtwcrQq8&d(q)P7wo-N?Kkl=yvCDlytwT_&@(mzJt){##xyJF3U<+1`K# zKI_sg?9%8IKT3qmPl*dB@es1(ujn5QiS}PRDH^(lA4!(B*6E(QL`};z>M|8_41cno z5c~wb)F0|d<5Al(8~}MbsoDmnsPIbGMFgyhlxCM#YhqjDsltEYvBbyT+D4^%6#^HQ z>u-6F>G2@8$FpOU87o6x7hkGCLQ1B|kl5mmwuDrew!|5J;zwS(U}76fh#eLm78&vn zJ3bVM?C<5OWjX7A6#_*#|UnnlCshJWs zAP`Kn4I69QH&S&1TGwq>LYb*c^H7K`)Ycz*EITS)qMaSb++#@bxX>~A(2a@L_BQDp z2s|~Epn~?{O~VC+EhHB3C$Yu(M@5bd^FB=- z4dbsaD}u$ucIVP9H1fTn!~n&gb#yAQ2LU0OBZxJuEw&*8A|XDNKRHkKn^cjxwRLX{ zIz-2qh7S3s%NYE)OJ>J`ckJGDTMS=G%2G9FB$3EyFsH{BXT|F86B%LO#;=Hvt{dJI zO;@qBfG|idRk*1!i%DO zNP=?k`pcL{dayAYe-kQSf{MhZYWiAJnol-;Esg_Z2C~L5c(Z8B*hSw+w~IF$Nt7*q zK^CwxUzCnWxw**;wbzCV*)UX8cj0$HM~404Wav$3ys6YDBts&e*aY_~PR=3*n%R*e zbFM>TvZmszS8H|unpZ-z*nMJlZA-k&5t~Pf&kC$gswf8eN;P>*umk+S=64RvkyJ@9 zQlW@G@E0Xg^!0Qn7MK2^wn1liN3Gt-Q~l@xO|;;_w%DQ|F@oR1sxkOB{#~LRkNxuG zNx`2m{0ANyWRx!Qma)O|YMr_v++*j-+1i#z7pLyRX~&WK0SS#h)k5Dmu)oRsT|vH5 z@nkwb2Jb<270#bDoS*125pJ)leGE6?y2v$`>)%a5gXsgv-1KV$Q+cEGx!+H8H@W8A z0;_O|Z5D`Ozd{THOr*7cwS65_>8xhXG zSe7oZyg=bT!3>W4nww_T!U9tcQcS%%(7nxhXuveFp&sEpE*b$mbI$ZMnHK`i>CRX6 zvT`phEQ`J`*<}@7so^{HWOU@L{s$7&{2s!HUxNHYMUOBrS4=X^x<@j*ama z$I0u`ZpG+2#+cI-DIce<7@lvW_Zgn8jVKJ8wKvnD%(-Tz5Bu+V^Gqa(g5qzwqKV2t zLT10bqEcToy%w`Onf*+Zmj9dszQXOev12 zsh3T!pbNiiu#LL~JR2=LOi|hlwo{t@ehOq$dlnzvi{#V?{qmj8nvnWU)vI>=zG?hN`UWyHL;jleFK`j{< zLB*4{xx#vqqGe%s{Pjt}_LMN@v3> z(y*Cg-M5K0*&|T*}?l!po{qM_}E1LVSj@fFt5Uw{uI@zeMm1@%a?RD!Zb&wETU=g zIbW>ioM%`m8d*%!1L&0T2-z3p#fmy{51`%)jrDoDxyXf#Og052F7-yQE;DVnFD)_6 zShD7+2{r>NlrEi1F!{K_N)lS_)Qn;-jaRsW&Hkm`miUNdtnhTIURyD>u!2fh(4u6$ zhA#BlD$_Ij60>YQ7cN=z?BB1Ld6cYOoXi!pEc%FMa)s10UZ0@K>yA*rJ)X@!0?(z% z5{^;Z07tKqS(%NjQ3v4KUW%3+nL3dPERo;FZXEkn&YS5%N}{5P)*gy|cr53=P+KXn zCW@B4EA@@)CB;sY*eJZb%0Jn!Yw}4=*G!L?o>}biBTCSJ2D;W;%mwM|YD}Nr^9l*H zAynRFpTcdIjFGBu%+E~EOcTis>uUIdQ?;+6;qZm(Qgx1rkuwu9dO(`BCg0Q#(}_Ba z8M5pX^?@dc`$9UKdAPAsnwgl){9AurX1R8C4qalb>Lqr%FR({6XP4Ybhe^~d!ya*r zrdM=bKS{D=?C_e`M>!MB>tt`8MG;FxIi2*3ccpgq!rZJ4V;Ar)(SSf(7wkEW2Ey!! zg4~=f7#)Wj`Yu@Hf~EDaFCPR1NcUl4)F&IfZzj z%yxHWUp$MiVTHBE=|rz^D6g)T%*n>eOd&UU>MT(kEwQIRrR&(IN1n%y})Ipd-+_6zI+6FX)TIXwX; zx?7R?tI64~{r1LcnK4*0A$Vvm5=z`#TbYrnRXp`vgRK&FVJx^}6$+ZXumDp`hq)|Q zg$t9cV&zN=U6G&?J4n5@Dzo{^>kNyGodr3bcoH*nPo&^AHs;ZoTMW-&QRzd*sjp-7 ztJC7^GHKVVQl~*{&n&N&=NFir^@?SAb+sifug_C#e(xl#QWeQu%y2u=oFF-)tdJ?H z5-ldW!Lm0@|I_~3Z-8|{CIEs(oFMPP%a=-U<>tKS*!<0!m7>@)-qakc;PEh>1)qUP ze6K|CH5%6Rs!S2XMOox+=LzsmRF`De&3O=OfUC!3%7G7J1$K*UnQF4%tn{f7eul@g zcpqcY$O4(9i`7kLpOn#07G*q0n-uE8|R;OYXrMzZ#(ik})C9vRK% zz(f0bWi`A)zq6qBt&~}jz4jX`rSnXi@xx{o;?zL3VpbsGQ%`QZj4|OVJGM{O%fjEN zeN;saUYT6F8eJjxbc)=UO3$#vm+TW9GH+B?&+K$be-eJM_Se(nDuOiytKHbcI%*qP z5w*NPqz2Vv0Zm#9PFZy=)ElSDr6=xWtccXjI?=_HshS@i&1TY=MLDC^(eS9OXUv*L z)=cA28MYqOM^$8SlwO6*ORcNndkYrW=wRP`X`$|a_v`aRteF{L?O@A%nD z*-JheHyn?Gsq9lDr<5L1@uPzyM-4DMlV5FOPdNxsmb%q7yXId{&v(Z?8Ncl!qtoPv zk7ggdygm)oh&2j-dUUvJ)E>4@=@I>q9^?~eEH^3qN|onlc?FLzQ|(Hs^FP)b-pkTC zqhZknReo=%2Mr%@8_lHGzW*$Cu?7wDu!@fkk79OSu&qbzhr)v@GBSn_EIX@q*`{ol z4Jvxbk29|k9q*uuhWpg;$iual$44}%^1@c9;F{*@)M%KWM<3J=MF&;%=qQb9St=>+ zI*WrXpyQI-hf(YPn=H_pIu3drGG>qL0;!|ka~pVsKB@;%s-fVFSi?~A^oVuJez1K| zIf6}e5%(%wo+lmSzEGJb8B8)OUi05$W+!_kiSF$Vu&d4NovMLCg^vs#9y|<9B9UBEEa7X8GzOf&6W`c3!SJx&z?-EVJ{@4w5$_H4 z%UqTr&~M;(BhH|8R9<@rBZskDnBbj|T&lvQnaK$g#dpk?3ezQ~x9^MlqTzgx=oc&# zAFSWo5`VNV`W;a=%qs9kItQ)8&Jp{tJ_3hFRr_eR$mv4{qjGBFuKCh*X#&W#b;fy3 zqcyvAW3$t}4BIb%AD!x>VYurUj2y8Jfh9b4jEZlS=c$B6wxsAwn37|+Rn;*kLwgeq z-P>!Ey>W>KSMoz;d~^g4a7JLVeb70qoI^(r9kvfyNAzJU;FHreMtVIjc{7}wL7~c? zQ2Q9BtUM;Up=qfmx1CK(;l(qf&PW(pBSeCn2k`CY)mJeN#|*kBsf`BeWqWyXB9|Ho9L4yOxh;b+JbK%r4r&5_TlKEfCm02 zo*}w0o{=+|pRVQ(vEoW!;Jp%j{bqFuc4vrjX@0*#h(a<9?Ai@jF5>DKg&#cYHMF9j=Svh?2P#qZ8zP&SVHy0>xTcgjYd;l1y}Bn8Pw_Ndf! z^3jMz3|dEAv~uJyb~sAy%uUXql}T$t_P?nMT#Lg@N{vx_abvcMjngb8w`uH^t1@X3Jiuou#9QWQ{(U56Envgde(-y`%k2&i8Vb zgY#3EQue40hp{337W@P}2YMz0jWWw|auc#&k8Z}PvQg?k`wY*^?w=qNL!l0GbgYTo zv7eCdH-===!wTm%iE-par_*Q^z34&r5LUDw8X*fx)uqoPZPG8mH~0*NR$Mu0+ret| z858mO*tRV@V&M0N7_pI-z}KNcJW-F1p>?`NYckL)ar@xl;m9GIZ;eG}lrt^8(x`GN zk?3aQ&m1H$2}<@L^L^X1q|Q+M3=@2;TFr1S+xq)d0%0^eL7KyIMh3j{NZ>WrgAxHK zJ%@^9QNZ_>bPrg7H25W`bg&1^b~e^s>@#vOwd&+tWc5_H)ErNCoNe4(rUN=lPfnE2 z)598z*n{Ci5s{Is$dGTEQ*tBNA)GBOtX-261f6U^R1z-5rgD=EZPYS1j^&ds9O%Qs zqt4Q!Q%l07>B2aFN@gG%=)+V?2Op9Nrp`%c=88w5qo)i$D93wa;`!S;>fnSLn_T!N zlTA*QYrI>JW_2lS>Wa~`{ovpc6((XMLl7f=ay9U ze7_6N?7}zan;oG}POITE(x8AIx$Wp!sk}mG69F4*5>=v&yEVQ7w>EtM_7yM0*H^zU zC$_{3D}6BzCH(7MT=$^inK+TouAc0oF(=*mqzqY1bcOGZqN16ADb={Tt3eW0GH zGCkel_Tb#bWK3MdpgMYVVwTlH1k5I{qJz6XD>lE4`zrbFmx!zY$DK@Nwl%9Z} zO&pB-`*OC8a}D6k?M7z1#C^tu4sb%Iq8!Sg$M?}LfcgtBmld02lm7yIChgzmM z-Yq=||Br+YDyb$8MkOyq4msRUrWXs9UheG{KA=d|xEN$$;iDzTIS@YWlk<-HPS%i8 zn=GjsMi+q;GY=dP>W@_ysYaX--PR~|XeMbIq61PROhwj5=wr>@_?_4lEzErWjwW^7 zgC}9OwGfiytLFYYl+{k(N*|~tGaRx_ZjhCBX_|+CgS#1_RylFFb2on`;lGbFraEM` zgy~SF=iSy?wv^|@zU9KZoPH@tTPuAWFSmn)i&5l+WRzz?5`D2dP&mAU!Tmu7EhOWd zOiHrxA45BWaS>lWwvB-{pP8yoAIE|=r(@aNQ(+G4#ty4a>_+#)9?%Hwug9YXjJU+o z?m+G;82Rmv)eWVl@>7>9Nr@l$kRv8MiXt^VcBmN_(O>Q636}vGmoSg;czi(oSI!z= zzL=)KnZA8fu#1alYE)8lCcA^DPI%O!BC8_lBkWKQ4K~5@**)p1@$+}-Hc%1N0=p<-7 zLohWblxC8G(=U`UbV$-Z+~&UXu8 zqYFKdmQ(Gr0|iD054+@ePT_soNfkQGZs=#0IR#mj3Fe$!Tj2=?bQXg9u$;J|ec@>p zmZXvC*v78v5;Kp$@58isp2r!nyOwla;&qG23uY{<#gtC&iKkxAi9!wxFZ%| z%OSTWHc!I1!mnkXArU8%CnDqoeUF@yvE?Z#?vGxs`R`xczdaL^b7luGH`aM}#pW3m z9tmmMTAl#%m?hv_`NRMx5(8P1iL`h{_Y7zF0TCDM=algz_lIi@%FND`GGyo0)|c#x zicT5lGhDReq%efninj|P^PoU} z|8=y^D@ru;C&#c8AnX2^O_OCF;E~g+pe$uj4D_}mAT3_pe1Zbqhsbk1x*v^3J>e67 z5#;yqmo^^Ksqn0m>uQz<0Pvx^N7V)qnz&dHkN2|#!d9Z`XJdPD9TNOuKS z@8?RMgXCGWmI1iH-)$ZZk|*bgj!zhlx!#5u`3?HzaJ1$KU4+-P7 zI_CBoT1Xq=Xi6H-n!^R;nMXUr(>-j=7z}-6RSn zorQMpvk6n44$|=hJc()dP))RZAL`{94EaPK*w1?+S?(a?^3y?dm*+b_$8$yUo0ELz e^C+r*kQYa_&EG%%zbbw0$9lkD{{Qd;75ZNR