From 18cad0ef58d8843b00c7a263ef6d87bf500443b1 Mon Sep 17 00:00:00 2001 From: skulltrail Date: Tue, 15 Feb 2022 19:21:42 -0300 Subject: [PATCH] Fixing ntext compilation, and changing FLS fucntions to adapt to Windows XP/2003. --- wrappers/base/kernelbase_wrapper/dep.c | 83 +- wrappers/base/kernelbase_wrapper/fileinfo.c | 29 +- .../base/kernelbase_wrapper/kernelbase.spec | 12 +- wrappers/base/kernelbase_wrapper/locale.c | 16 +- wrappers/base/kernelbase_wrapper/module.c | 71 +- wrappers/base/kernelbase_wrapper/numa.c | 31 +- wrappers/base/kernelbase_wrapper/sysinfo.c | 36 +- wrappers/base/kernelbase_wrapper/thread.c | 155 +- wrappers/base/ntext_wrapper/main.h | 272 ++- wrappers/base/ntext_wrapper/ntext.spec | 2 +- wrappers/base/ntext_wrapper/rtl/context.c | 4 +- wrappers/base/ntext_wrapper/rtl/locale.c | 10 +- wrappers/base/ntext_wrapper/rtl/path.c | 2 +- wrappers/base/ntext_wrapper/rtl/synch.c | 20 +- wrappers/base/ntext_wrapper/rtl/thread.c | 3 +- wrappers/base/ntext_wrapper/rtl/threadpool.c | 2 +- wrappers/base/user32_wrapper/dib.c | 47 +- wrappers/base/user32_wrapper/display.c | 37 +- wrappers/base/user32_wrapper/dwm.c | 37 +- wrappers/base/user32_wrapper/icon.c | 3 +- wrappers/base/user32_wrapper/input.c | 37 +- wrappers/base/user32_wrapper/magnification.c | 37 +- wrappers/base/user32_wrapper/sysparams.c | 144 ++ wrappers/new-dlls/version_new/CMakeLists.txt | 14 + wrappers/new-dlls/version_new/version_new.c | 1679 +++++++++++++++++ wrappers/new-dlls/version_new/version_new.rc | 26 + .../new-dlls/version_new/version_new.spec | 19 + wrappers/sdk/include/wsdk/ntdllbase.h | 155 +- 28 files changed, 2335 insertions(+), 648 deletions(-) create mode 100644 wrappers/base/user32_wrapper/sysparams.c create mode 100644 wrappers/new-dlls/version_new/CMakeLists.txt create mode 100644 wrappers/new-dlls/version_new/version_new.c create mode 100644 wrappers/new-dlls/version_new/version_new.rc create mode 100644 wrappers/new-dlls/version_new/version_new.spec diff --git a/wrappers/base/kernelbase_wrapper/dep.c b/wrappers/base/kernelbase_wrapper/dep.c index cb35222134b..b8224f3e8c2 100644 --- a/wrappers/base/kernelbase_wrapper/dep.c +++ b/wrappers/base/kernelbase_wrapper/dep.c @@ -22,83 +22,58 @@ Revision History: WINE_DEFAULT_DEBUG_CHANNEL(kernel32); -static BOOL (WINAPI *pGetProcessDEPPolicy)(HANDLE, LPDWORD, PBOOL); -static BOOL (WINAPI *pSetProcessDEPPolicy)(DWORD); -static DEP_SYSTEM_POLICY_TYPE (WINAPI *pGetSystemDEPPolicy)(); - DEP_SYSTEM_POLICY_TYPE WINAPI GetSystemDEPPolicy(void) { - HMODULE hkernel32 = GetModuleHandleA("kernel32.dll"); - - pGetSystemDEPPolicy = (void *)GetProcAddress(hkernel32, "GetSystemDEPPolicy"); - if(pGetSystemDEPPolicy){ - return pGetSystemDEPPolicy(); - }else{ - return SharedUserData->NXSupportPolicy; - } + return SharedUserData->NXSupportPolicy; } BOOL WINAPI GetProcessDEPPolicy(HANDLE ProcessInformation, LPDWORD lpFlags, PBOOL lpPermanent) { - HMODULE hkernel32 = GetModuleHandleA("kernel32.dll"); - NTSTATUS status; - ULONG dep_flags; + NTSTATUS Status; + ULONG depFlags; - pGetProcessDEPPolicy = (void *)GetProcAddress(hkernel32, "GetProcessDEPPolicy"); - if(pGetProcessDEPPolicy){ - return pGetProcessDEPPolicy(ProcessInformation, lpFlags, lpPermanent); - }else{ - - status = NtQueryInformationProcess( GetCurrentProcess(), ProcessExecuteFlags, - &dep_flags, sizeof(dep_flags), NULL ); - if (!status) + Status = NtQueryInformationProcess( GetCurrentProcess(), ProcessExecuteFlags, + &depFlags, sizeof(depFlags), NULL ); + if (!Status) + { + if (lpFlags) { - if (lpFlags) - { - *lpFlags = 0; - if (dep_flags & MEM_EXECUTE_OPTION_DISABLE) - *lpFlags |= PROCESS_DEP_ENABLE; - if (dep_flags & MEM_EXECUTE_OPTION_DISABLE_THUNK_EMULATION) - *lpFlags |= PROCESS_DEP_DISABLE_ATL_THUNK_EMULATION; + *lpFlags = 0; + if (depFlags & MEM_EXECUTE_OPTION_DISABLE) + *lpFlags |= PROCESS_DEP_ENABLE; + if (depFlags & MEM_EXECUTE_OPTION_DISABLE_THUNK_EMULATION) + *lpFlags |= PROCESS_DEP_DISABLE_ATL_THUNK_EMULATION; } if (lpPermanent) - *lpPermanent = (dep_flags & MEM_EXECUTE_OPTION_PERMANENT) != 0; - - } - if (status) SetLastError( RtlNtStatusToDosError(status) ); - return !status; + *lpPermanent = (depFlags & MEM_EXECUTE_OPTION_PERMANENT) != 0; } + if (Status) + SetLastError( RtlNtStatusToDosError(Status) ); + return !Status; } BOOL WINAPI SetProcessDEPPolicy(DWORD dwFlags) { - HMODULE hkernel32 = GetModuleHandleA("kernel32.dll"); - NTSTATUS status; + NTSTATUS Status; ULONG depFlags = 0; - - pSetProcessDEPPolicy = (void *)GetProcAddress(hkernel32, "SetProcessDEPPolicy"); - if(pSetProcessDEPPolicy){ - return pSetProcessDEPPolicy(dwFlags); - }else{ - if (dwFlags & PROCESS_DEP_ENABLE) - depFlags |= MEM_EXECUTE_OPTION_DISABLE | MEM_EXECUTE_OPTION_PERMANENT; - if (dwFlags & PROCESS_DEP_DISABLE_ATL_THUNK_EMULATION) - depFlags |= MEM_EXECUTE_OPTION_DISABLE_THUNK_EMULATION; - status = NtSetInformationProcess( GetCurrentProcess(), ProcessExecuteFlags, - &depFlags, sizeof(depFlags) ); + if (dwFlags & PROCESS_DEP_ENABLE) + depFlags |= MEM_EXECUTE_OPTION_DISABLE | MEM_EXECUTE_OPTION_PERMANENT; + if (dwFlags & PROCESS_DEP_DISABLE_ATL_THUNK_EMULATION) + depFlags |= MEM_EXECUTE_OPTION_DISABLE_THUNK_EMULATION; - if(NT_SUCCESS(status)){ - return TRUE; - }else{ - BaseSetLastNTError(status); - return FALSE; - } + Status = NtSetInformationProcess( GetCurrentProcess(), ProcessExecuteFlags, + &depFlags, sizeof(depFlags) ); + if(NT_SUCCESS(Status)){ + return TRUE; + }else{ + BaseSetLastNTError(Status); + return FALSE; } } \ No newline at end of file diff --git a/wrappers/base/kernelbase_wrapper/fileinfo.c b/wrappers/base/kernelbase_wrapper/fileinfo.c index a800e8d9343..d2656b6e020 100644 --- a/wrappers/base/kernelbase_wrapper/fileinfo.c +++ b/wrappers/base/kernelbase_wrapper/fileinfo.c @@ -61,26 +61,19 @@ FilenameA2W( */ BOOL WINAPI SetFileCompletionNotificationModes( HANDLE handle, UCHAR flags ) { - HMODULE hkernel32 = GetModuleHandleA("kernel32.dll"); NTSTATUS Status; - pSetFileCompletionNotificationModes = (void *)GetProcAddress(hkernel32, "SetFileCompletionNotificationModes"); - - if(pSetFileCompletionNotificationModes){ - return pSetFileCompletionNotificationModes(handle, flags); - }else{ - FILE_IO_COMPLETION_NOTIFICATION_INFORMATION info; - IO_STATUS_BLOCK io; + FILE_IO_COMPLETION_NOTIFICATION_INFORMATION info; + IO_STATUS_BLOCK io; - info.Flags = flags; - Status = NtSetInformationFile( handle, &io, &info, sizeof(info), - FileIoCompletionNotificationInformation ); + info.Flags = flags; + Status = NtSetInformationFile( handle, &io, &info, sizeof(info), + FileIoCompletionNotificationInformation ); - if(NT_SUCCESS(Status)){ - return TRUE; - }else{ - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return FALSE; - } - } + if(NT_SUCCESS(Status)){ + return TRUE; + }else{ + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return FALSE; + } } \ No newline at end of file diff --git a/wrappers/base/kernelbase_wrapper/kernelbase.spec b/wrappers/base/kernelbase_wrapper/kernelbase.spec index 6a07f74dae0..41d3b3b6da7 100644 --- a/wrappers/base/kernelbase_wrapper/kernelbase.spec +++ b/wrappers/base/kernelbase_wrapper/kernelbase.spec @@ -979,7 +979,7 @@ @ stdcall Wow64RevertWow64FsRedirection(ptr) @ stdcall ReOpenFile(ptr long long long) @ stdcall GetNLSVersion(long long ptr) -@ stdcall IsNLSDefinedString(long long ptr long long) kernel32.IsNLSDefinedString +@ stdcall -stub IsNLSDefinedString(long long ptr long long) @ stdcall SetFileCompletionNotificationModes(ptr long) #Missing on XP and 2003 RTM @@ -1007,12 +1007,12 @@ @ stdcall CreateProcessInternalA(ptr str str ptr ptr long long ptr str ptr ptr long) CreateProcessInternalExA @ stdcall CreateProcessInternalW(ptr wstr wstr ptr ptr long long ptr wstr ptr ptr long) CreateProcessInternalExW @ stdcall CreateProcessW(wstr wstr ptr ptr long long ptr wstr ptr ptr) CreateProcessExW -@ stdcall GetModuleHandleA(str) GetModuleHandleInternalA -@ stdcall GetModuleHandleW(wstr) GetModuleHandleInternalW -@ stdcall GetProcAddress(long str) GetProcAddressInternal +@ stdcall GetModuleHandleA(str) +@ stdcall GetModuleHandleW(wstr) +@ stdcall GetProcAddress(long str) @ stdcall IsProcessorFeaturePresent(long) IsProcessorFeaturePresentInternal -@ stdcall LoadLibraryA(str) LoadLibraryInternalA -@ stdcall LoadLibraryW(wstr) LoadLibraryInternalW +@ stdcall LoadLibraryA(str) +@ stdcall LoadLibraryW(wstr) @ stdcall LoadLibraryExA( str long long) LoadLibraryExInternalA @ stdcall LoadLibraryExW(wstr long long) LoadLibraryExInternalW @ stdcall SetFileApisToANSI() SetpFileApisToANSI diff --git a/wrappers/base/kernelbase_wrapper/locale.c b/wrappers/base/kernelbase_wrapper/locale.c index 5971f97f24b..34c442b0c8e 100644 --- a/wrappers/base/kernelbase_wrapper/locale.c +++ b/wrappers/base/kernelbase_wrapper/locale.c @@ -75,11 +75,6 @@ static RTL_CRITICAL_SECTION cache_section; WINE_DEFAULT_DEBUG_CHANNEL(locale); -typedef BOOL (WINAPI *pGetNLSVersion)( - NLS_FUNCTION, - LCID, - LPNLSVERSIONINFO); - struct sortguid { GUID id; /* sort GUID */ @@ -1801,16 +1796,7 @@ GetNLSVersion( LCID lcid, LPNLSVERSIONINFO info) { - pGetNLSVersion nlsVersion; - WCHAR locale[LOCALE_NAME_MAX_LENGTH]; - - nlsVersion = (pGetNLSVersion) GetProcAddress( - GetModuleHandleW(L"kernel32"), - "GetNLSVersion"); - - if(nlsVersion!=NULL){ - return nlsVersion(func, lcid, info); - } + WCHAR locale[LOCALE_NAME_MAX_LENGTH]; if (info->dwNLSVersionInfoSize < offsetof( NLSVERSIONINFO, dwNLSVersionInfoSize )) { diff --git a/wrappers/base/kernelbase_wrapper/module.c b/wrappers/base/kernelbase_wrapper/module.c index 5c9f6c6fa14..d198b611e10 100644 --- a/wrappers/base/kernelbase_wrapper/module.c +++ b/wrappers/base/kernelbase_wrapper/module.c @@ -374,73 +374,16 @@ BOOL WINAPI DECLSPEC_HOTPATCH SetDefaultDllDirectories( DWORD flags ) */ BOOL WINAPI SetSearchPathMode( DWORD flags ) { - HMODULE hkernel32 = GetModuleHandleA("kernel32.dll"); NTSTATUS Status; - pSetSearchPathMode = (void *)GetProcAddress(hkernel32, "SetSearchPathMode"); - if(pSetSearchPathMode){ - return pSetSearchPathMode(flags); - }else{ - Status = RtlSetSearchPathMode( flags ); + Status = RtlSetSearchPathMode( flags ); - if(NT_SUCCESS(Status)){ - return TRUE; - }else{ - SetLastError(Status); - return FALSE; - } - } -} - -FARPROC -WINAPI -GetProcAddressInternal( - _In_ HMODULE hModule, - _In_ LPCSTR lpProcName -) -{ - //DbgPrint("GetProcAddress::Function name: %s\n", lpProcName); - return GetProcAddress(hModule, lpProcName); -} - -HMODULE -WINAPI -GetModuleHandleInternalA( - _In_opt_ LPCTSTR lpModuleName -) -{ - //DbgPrint("GetModuleHandleA::Module name: %s\n", lpModuleName); - return GetModuleHandleA(lpModuleName); -} - -HMODULE -WINAPI -GetModuleHandleInternalW( - _In_opt_ LPCWSTR lpModuleName -) -{ - //DbgPrint("GetModuleHandleW::Module name: %ws\n", lpModuleName); - return GetModuleHandleW(lpModuleName); -} - -HMODULE -WINAPI -LoadLibraryInternalA( - _In_ LPCTSTR lpFileName -) -{ - //DbgPrint("LoadLibraryA::File name: %s\n", lpFileName); - return LoadLibraryA(lpFileName); -} - -HMODULE -WINAPI -LoadLibraryInternalW( - _In_ LPCWSTR lpFileName -) -{ - //DbgPrint("LoadLibraryW::File name: %ws\n", lpFileName); - return LoadLibraryW(lpFileName); + if(NT_SUCCESS(Status)){ + return TRUE; + }else{ + SetLastError(Status); + return FALSE; + } } WCHAR szAppInit[KEY_LENGTH]; diff --git a/wrappers/base/kernelbase_wrapper/numa.c b/wrappers/base/kernelbase_wrapper/numa.c index d7a69ef667c..71400a1c801 100644 --- a/wrappers/base/kernelbase_wrapper/numa.c +++ b/wrappers/base/kernelbase_wrapper/numa.c @@ -34,30 +34,23 @@ GetNumaNodeProcessorMask( NTSTATUS Status; ULONG ReturnedSize; SYSTEM_NUMA_INFORMATION Map; - HMODULE hkernel32 = GetModuleHandleA("kernel32.dll"); - - pGetNumaNodeProcessorMask = (void *)GetProcAddress(hkernel32, "GetNumaNodeProcessorMask"); - if(pGetNumaNodeProcessorMask){ - return pGetNumaNodeProcessorMask(Node, ProcessorMask); - }else{ - Status = NtQuerySystemInformation(SystemNumaProcessorMap, + + Status = NtQuerySystemInformation(SystemNumaProcessorMap, &Map, sizeof(Map), &ReturnedSize); - if (!NT_SUCCESS(Status)) { - - BaseSetLastNTError(Status); - return FALSE; - } + if (!NT_SUCCESS(Status)) { + BaseSetLastNTError(Status); + return FALSE; + } - if (Node > Map.HighestNodeNumber) { - SetLastError(ERROR_INVALID_PARAMETER); - return FALSE; - } + if (Node > Map.HighestNodeNumber) { + SetLastError(ERROR_INVALID_PARAMETER); + return FALSE; + } - *ProcessorMask = Map.ActiveProcessorsAffinityMask[Node]; - return TRUE; - } + *ProcessorMask = Map.ActiveProcessorsAffinityMask[Node]; + return TRUE; } BOOL diff --git a/wrappers/base/kernelbase_wrapper/sysinfo.c b/wrappers/base/kernelbase_wrapper/sysinfo.c index 5ac7bca4773..c825b7a6ebd 100644 --- a/wrappers/base/kernelbase_wrapper/sysinfo.c +++ b/wrappers/base/kernelbase_wrapper/sysinfo.c @@ -80,25 +80,23 @@ SetSystemFileCacheSize( int Flags ) { - HMODULE hkernel32 = GetModuleHandleA("kernel32.dll"); - NTSTATUS status; + NTSTATUS Status; BOOL result; - char SystemInformation; + SYSTEM_FILECACHE_INFORMATION SystemInformation; - pSetSystemFileCacheSize = (void *)GetProcAddress(hkernel32, "SetSystemFileCacheSize"); - if(pSetSystemFileCacheSize){ - return pSetSystemFileCacheSize(MinimumFileCacheSize, MaximumFileCacheSize, Flags); - }else{ - status = NtSetSystemInformation(SystemObjectInformation|0x40, &SystemInformation, 0x24u); - if ( !NT_SUCCESS(status) ) - { - BaseSetLastNTError(status); - result = FALSE; - } - else - { - result = TRUE; - } - return result; - } + SystemInformation.MinimumWorkingSet = MinimumFileCacheSize; + SystemInformation.MaximumWorkingSet = MaximumFileCacheSize; + SystemInformation.Flags = Flags; + + Status = NtSetSystemInformation(SystemFileCacheInformationEx, &SystemInformation, sizeof(SYSTEM_FILECACHE_INFORMATION)); + if ( !NT_SUCCESS(Status) ) + { + BaseSetLastNTError(Status); + result = FALSE; + } + else + { + result = TRUE; + } + return result; } \ No newline at end of file diff --git a/wrappers/base/kernelbase_wrapper/thread.c b/wrappers/base/kernelbase_wrapper/thread.c index 426895bec0f..849469939a0 100644 --- a/wrappers/base/kernelbase_wrapper/thread.c +++ b/wrappers/base/kernelbase_wrapper/thread.c @@ -25,29 +25,10 @@ Revision History: WINE_DEFAULT_DEBUG_CHANNEL(kernel32); WINE_DECLARE_DEBUG_CHANNEL(winedbg); -static BOOL (WINAPI *pSetThreadStackGuarantee)(PULONG); static DWORD (WINAPI *pConsoleIMERoutine)(LPVOID); static DWORD (WINAPI *pCtrlRoutine)(LPVOID); void WINAPI RtlFreeUserStack( void *stack ); -/*********************************************************************** - * Fibers - ***********************************************************************/ - - -struct fiber_data -{ - LPVOID param; /* 00/00 fiber param */ - void *except; /* 04/08 saved exception handlers list */ - void *stack_base; /* 08/10 top of fiber stack */ - void *stack_limit; /* 0c/18 fiber stack low-water mark */ - void *stack_allocation; /* 10/20 base of the fiber stack allocation */ - CONTEXT context; /* 14/30 fiber context */ - DWORD flags; /* fiber flags */ - LPFIBER_START_ROUTINE start; /* start routine */ - void *fls_slots; /* fiber storage slots */ -}; - /******************************************************************* * format_exception_msg */ @@ -347,64 +328,74 @@ static BOOL start_debugger_atomic(PEXCEPTION_POINTERS epointers) return TRUE; } +BOOL isXPOrLower(){ + OSVERSIONINFOW osVersion = {0}; + + GetVersionExW(&osVersion); + + if(osVersion.dwMajorVersion<=5){ + if(osVersion.dwMinorVersion<=1){ + return TRUE; + } + } + + return FALSE; +} + /*********************************************************************** - * FlsAlloc (KERNEL32.@) - For XP support + * FlsAlloc (KERNEL32.@) - For .Net 4.5.1 + Framework Support (native functions not work) */ -DWORD -WINAPI -DECLSPEC_HOTPATCH -FlsAlloc( - PFLS_CALLBACK_FUNCTION lpCallback -) +DWORD WINAPI FlsAlloc( PFLS_CALLBACK_FUNCTION lpCallback ) { - DWORD index; - - if (!set_ntstatus( RtlFlsAlloc( lpCallback, &index ))) return FLS_OUT_OF_INDEXES; - return index; + if(isXPOrLower()){ + return TlsAlloc(); + }else{ + DWORD index; + if (!set_ntstatus( RtlFlsAlloc( lpCallback, &index ))) return FLS_OUT_OF_INDEXES; + return index; + } } /*********************************************************************** - * FlsFree (KERNEL32.@) - For XP support + * FlsFree (KERNEL32.@) - Framework Support (native functions not work) */ -BOOL -WINAPI -FlsFree( - DWORD dwFlsIndex -) -{ - return set_ntstatus( RtlFlsFree( dwFlsIndex )); +BOOL WINAPI FlsFree( DWORD index ) +{ + if(isXPOrLower()){ + return TlsFree(index); + }else{ + return set_ntstatus( RtlFlsFree( index )); + } } /*********************************************************************** - * FlsGetValue (KERNEL32.@) - For XP support + * FlsGetValue (KERNEL32.@) - Framework Support (native functions not work) */ -PVOID -WINAPI -FlsGetValue( - DWORD index -) +PVOID WINAPI FlsGetValue( DWORD index ) { - void *data; + if(isXPOrLower()){ + return TlsGetValue(index); + }else{ + void *data; - if (!set_ntstatus( RtlFlsGetValue( index, &data ))) return NULL; - SetLastError( ERROR_SUCCESS ); - return data; + if (!set_ntstatus( RtlFlsGetValue( index, &data ))) return NULL; + SetLastError( ERROR_SUCCESS ); + return data; + } } /*********************************************************************** - * FlsSetValue (KERNEL32.@) - For XP support + * FlsSetValue (KERNEL32.@) - Framework Support (native functions not work) */ -BOOL -WINAPI -FlsSetValue( - DWORD dwFlsIndex, - PVOID lpFlsData -) +BOOL WINAPI FlsSetValue( DWORD index, PVOID lpFlsData ) { - return set_ntstatus( RtlFlsSetValue( dwFlsIndex, lpFlsData )); + if(isXPOrLower()){ + return TlsSetValue(index, lpFlsData); + }else{ + return set_ntstatus( RtlFlsSetValue( index, lpFlsData )); + } } - /*********************************************************************** * ConvertThreadToFiberEx (KERNEL32.@) - For XP support * @@ -480,26 +471,20 @@ SetThreadStackGuarantee( IN OUT PULONG StackSizeInBytes ) { - HMODULE hkernel32 = GetModuleHandleA("kernel32.dll"); - pSetThreadStackGuarantee = (void *)GetProcAddress(hkernel32, "SetThreadStackGuarantee"); - if(pSetThreadStackGuarantee){ - return pSetThreadStackGuarantee(StackSizeInBytes); - }else{ - ULONG prev_size = NtCurrentTeb()->GuaranteedStackBytes; - ULONG new_size = (*StackSizeInBytes + 4095) & ~4095; + ULONG prev_size = NtCurrentTeb()->GuaranteedStackBytes; + ULONG new_size = (*StackSizeInBytes + 4095) & ~4095; - /* at least 2 pages on 64-bit */ - if (sizeof(void *) > sizeof(int) && new_size) new_size = max( new_size, 8192 ); + /* at least 2 pages on 64-bit */ + if (sizeof(void *) > sizeof(int) && new_size) new_size = max( new_size, 8192 ); - *StackSizeInBytes = prev_size; - if (new_size >= (char *)NtCurrentTeb()->NtTib.StackBase - (char *)NtCurrentTeb()->DeallocationStack) - { - SetLastError( ERROR_INVALID_PARAMETER ); - return FALSE; - } - if (new_size > prev_size) NtCurrentTeb()->GuaranteedStackBytes = (new_size + 4095) & ~4095; - return TRUE; - } + *StackSizeInBytes = prev_size; + if (new_size >= (char *)NtCurrentTeb()->NtTib.StackBase - (char *)NtCurrentTeb()->DeallocationStack) + { + SetLastError( ERROR_INVALID_PARAMETER ); + return FALSE; + } + if (new_size > prev_size) NtCurrentTeb()->GuaranteedStackBytes = (new_size + 4095) & ~4095; + return TRUE; } DWORD @@ -1198,7 +1183,7 @@ CreateThreadpoolIo( TRACE( "%p, %p, %p\n", pfnio, pv, pcbe ); - status = TpAllocIoCompletion( &io, file, pfnio, pv, pcbe ); + status = TpAllocIoCompletion( &io, file, (PTP_IO_CALLBACK)pfnio, pv, pcbe ); if (status) { SetLastError( RtlNtStatusToDosError(status) ); @@ -1304,22 +1289,4 @@ BOOL WINAPI DECLSPEC_HOTPATCH QueryThreadpoolStackInformation( PTP_POOL pool, PT Status = TpQueryPoolStackInformation( pool, stack_info ); return NT_SUCCESS(Status); -} - -/*********************************************************************** - * DeleteFiber (kernelbase.@) - */ -void WINAPI DECLSPEC_HOTPATCH DeleteFiber( LPVOID fiber_ptr ) -{ - struct fiber_data *fiber = fiber_ptr; - - if (!fiber) return; - if (fiber == NtCurrentTeb()->NtTib.FiberData) - { - HeapFree( GetProcessHeap(), 0, fiber ); - RtlExitUserThread( 1 ); - } - RtlFreeUserStack( fiber->stack_allocation ); - RtlProcessFlsData( (void *)fiber->fls_slots, 3 ); - HeapFree( GetProcessHeap(), 0, fiber ); } \ No newline at end of file diff --git a/wrappers/base/ntext_wrapper/main.h b/wrappers/base/ntext_wrapper/main.h index 4dc4dbf994d..497803b8e64 100644 --- a/wrappers/base/ntext_wrapper/main.h +++ b/wrappers/base/ntext_wrapper/main.h @@ -34,6 +34,7 @@ #include #include #include +#include #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) @@ -197,24 +198,22 @@ typedef VOID (*PTP_WAIT_CALLBACK)(PTP_CALLBACK_INSTANCE Instance, PVOID Context, typedef VOID (WINAPI *PBAD_MEMORY_CALLBACK_ROUTINE)(VOID); -typedef VOID (*PTP_IO_CALLBACK)(PTP_CALLBACK_INSTANCE,void*,void*,IO_STATUS_BLOCK*,PTP_IO); - typedef BOOLEAN (*PSECURE_MEMORY_CACHE_CALLBACK)( _In_ PVOID Addr, _In_ SIZE_T Range ); -typedef PVOID (WINAPI *PDELAYLOAD_FAILURE_SYSTEM_ROUTINE)(LPCSTR, LPCSTR); +// typedef PVOID (WINAPI *PDELAYLOAD_FAILURE_SYSTEM_ROUTINE)(LPCSTR, LPCSTR); typedef VOID (CALLBACK *PTP_WIN32_IO_CALLBACK)(PTP_CALLBACK_INSTANCE,PVOID,PVOID,ULONG,ULONG_PTR,PTP_IO); -typedef enum _NORM_FORM { - NormalizationOther = 0, - NormalizationC = 0x1, - NormalizationD = 0x2, - NormalizationKC = 0x5, - NormalizationKD = 0x6 -} NORM_FORM; +// typedef enum _NORM_FORM { + // NormalizationOther = 0, + // NormalizationC = 0x1, + // NormalizationD = 0x2, + // NormalizationKC = 0x5, + // NormalizationKD = 0x6 +// } NORM_FORM; typedef enum _TRANSACTION_INFORMATION_CLASS { TransactionBasicInformation = 0, @@ -223,73 +222,73 @@ typedef enum _TRANSACTION_INFORMATION_CLASS { TransactionSuperiorEnlistmentInformation } TRANSACTION_INFORMATION_CLASS; -typedef struct _WIN32_MEMORY_RANGE_ENTRY { - PVOID VirtualAddress; - SIZE_T NumberOfBytes; -} WIN32_MEMORY_RANGE_ENTRY, *PWIN32_MEMORY_RANGE_ENTRY; - -typedef struct _CLAIM_SECURITY_ATTRIBUTE_OCTET_STRING_VALUE { - PVOID pValue; - DWORD ValueLength; -} CLAIM_SECURITY_ATTRIBUTE_OCTET_STRING_VALUE, *PCLAIM_SECURITY_ATTRIBUTE_OCTET_STRING_VALUE; - -typedef struct _CLAIM_SECURITY_ATTRIBUTE_FQBN_VALUE { - DWORD64 Version; - PWSTR Name; -} CLAIM_SECURITY_ATTRIBUTE_FQBN_VALUE, *PCLAIM_SECURITY_ATTRIBUTE_FQBN_VALUE; - -typedef struct _CLAIM_SECURITY_ATTRIBUTE_V1 { - PWSTR Name; - WORD ValueType; - WORD Reserved; - DWORD Flags; - DWORD ValueCount; - union { - PLONG64 pInt64; - PDWORD64 pUint64; - PWSTR *ppString; - PCLAIM_SECURITY_ATTRIBUTE_FQBN_VALUE pFqbn; - PCLAIM_SECURITY_ATTRIBUTE_OCTET_STRING_VALUE pOctetString; - } Values; -} CLAIM_SECURITY_ATTRIBUTE_V1, *PCLAIM_SECURITY_ATTRIBUTE_V1; - -typedef struct _CLAIM_SECURITY_ATTRIBUTES_INFORMATION { - WORD Version; - WORD Reserved; - DWORD AttributeCount; - union { - PCLAIM_SECURITY_ATTRIBUTE_V1 pAttributeV1; - } Attribute; -} CLAIM_SECURITY_ATTRIBUTES_INFORMATION, *PCLAIM_SECURITY_ATTRIBUTES_INFORMATION; - -typedef struct _TP_POOL_STACK_INFORMATION -{ - SIZE_T StackReserve; - SIZE_T StackCommit; -} TP_POOL_STACK_INFORMATION,*PTP_POOL_STACK_INFORMATION; - -typedef enum { - PMCCounter, - MaxHardwareCounterType -} HARDWARE_COUNTER_TYPE; - -typedef struct _HARDWARE_COUNTER_DATA { - HARDWARE_COUNTER_TYPE Type; - DWORD Reserved; - DWORD64 Value; -} HARDWARE_COUNTER_DATA, *PHARDWARE_COUNTER_DATA; - -typedef struct _PERFORMANCE_DATA { - WORD Size; - BYTE Version; - BYTE HwCountersCount; - DWORD ContextSwitchCount; - DWORD64 WaitReasonBitMap; - DWORD64 CycleTime; - DWORD RetryCount; - DWORD Reserved; - HARDWARE_COUNTER_DATA HwCounters[MAX_HW_COUNTERS]; -} PERFORMANCE_DATA, *PPERFORMANCE_DATA; +// typedef struct _WIN32_MEMORY_RANGE_ENTRY { + // PVOID VirtualAddress; + // SIZE_T NumberOfBytes; +// } WIN32_MEMORY_RANGE_ENTRY, *PWIN32_MEMORY_RANGE_ENTRY; + +// typedef struct _CLAIM_SECURITY_ATTRIBUTE_OCTET_STRING_VALUE { + // PVOID pValue; + // DWORD ValueLength; +// } CLAIM_SECURITY_ATTRIBUTE_OCTET_STRING_VALUE, *PCLAIM_SECURITY_ATTRIBUTE_OCTET_STRING_VALUE; + +// typedef struct _CLAIM_SECURITY_ATTRIBUTE_FQBN_VALUE { + // DWORD64 Version; + // PWSTR Name; +// } CLAIM_SECURITY_ATTRIBUTE_FQBN_VALUE, *PCLAIM_SECURITY_ATTRIBUTE_FQBN_VALUE; + +// typedef struct _CLAIM_SECURITY_ATTRIBUTE_V1 { + // PWSTR Name; + // WORD ValueType; + // WORD Reserved; + // DWORD Flags; + // DWORD ValueCount; + // union { + // PLONG64 pInt64; + // PDWORD64 pUint64; + // PWSTR *ppString; + // PCLAIM_SECURITY_ATTRIBUTE_FQBN_VALUE pFqbn; + // PCLAIM_SECURITY_ATTRIBUTE_OCTET_STRING_VALUE pOctetString; + // } Values; +// } CLAIM_SECURITY_ATTRIBUTE_V1, *PCLAIM_SECURITY_ATTRIBUTE_V1; + +// typedef struct _CLAIM_SECURITY_ATTRIBUTES_INFORMATION { + // WORD Version; + // WORD Reserved; + // DWORD AttributeCount; + // union { + // PCLAIM_SECURITY_ATTRIBUTE_V1 pAttributeV1; + // } Attribute; +// } CLAIM_SECURITY_ATTRIBUTES_INFORMATION, *PCLAIM_SECURITY_ATTRIBUTES_INFORMATION; + +// typedef struct _TP_POOL_STACK_INFORMATION +// { + // SIZE_T StackReserve; + // SIZE_T StackCommit; +// } TP_POOL_STACK_INFORMATION,*PTP_POOL_STACK_INFORMATION; + +// typedef enum { + // PMCCounter, + // MaxHardwareCounterType +// } HARDWARE_COUNTER_TYPE; + +// typedef struct _HARDWARE_COUNTER_DATA { + // HARDWARE_COUNTER_TYPE Type; + // DWORD Reserved; + // DWORD64 Value; +// } HARDWARE_COUNTER_DATA, *PHARDWARE_COUNTER_DATA; + +// typedef struct _PERFORMANCE_DATA { + // WORD Size; + // BYTE Version; + // BYTE HwCountersCount; + // DWORD ContextSwitchCount; + // DWORD64 WaitReasonBitMap; + // DWORD64 CycleTime; + // DWORD RetryCount; + // DWORD Reserved; + // HARDWARE_COUNTER_DATA HwCounters[MAX_HW_COUNTERS]; +// } PERFORMANCE_DATA, *PPERFORMANCE_DATA; typedef struct _ALPC_PORT_ATTRIBUTES { @@ -355,27 +354,27 @@ typedef struct _ALPC_CONTEXT_ATTR ULONG CallbackId; } ALPC_CONTEXT_ATTR, *PALPC_CONTEXT_ATTR; -typedef struct _DELAYLOAD_PROC_DESCRIPTOR -{ - ULONG ImportDescribedByName; - union { - LPCSTR Name; - ULONG Ordinal; - } Description; -} DELAYLOAD_PROC_DESCRIPTOR, *PDELAYLOAD_PROC_DESCRIPTOR; - -typedef struct _DELAYLOAD_INFO -{ - ULONG Size; - PCIMAGE_DELAYLOAD_DESCRIPTOR DelayloadDescriptor; - PIMAGE_THUNK_DATA ThunkAddress; - LPCSTR TargetDllName; - DELAYLOAD_PROC_DESCRIPTOR TargetApiDescriptor; - PVOID TargetModuleBase; - PVOID Unused; - ULONG LastError; -} DELAYLOAD_INFO, *PDELAYLOAD_INFO; -typedef PVOID (WINAPI *PDELAYLOAD_FAILURE_DLL_CALLBACK)(ULONG, PDELAYLOAD_INFO); +// typedef struct _DELAYLOAD_PROC_DESCRIPTOR +// { + // ULONG ImportDescribedByName; + // union { + // LPCSTR Name; + // ULONG Ordinal; + // } Description; +// } DELAYLOAD_PROC_DESCRIPTOR, *PDELAYLOAD_PROC_DESCRIPTOR; + +// typedef struct _DELAYLOAD_INFO +// { + // ULONG Size; + // PCIMAGE_DELAYLOAD_DESCRIPTOR DelayloadDescriptor; + // PIMAGE_THUNK_DATA ThunkAddress; + // LPCSTR TargetDllName; + // DELAYLOAD_PROC_DESCRIPTOR TargetApiDescriptor; + // PVOID TargetModuleBase; + // PVOID Unused; + // ULONG LastError; +// } DELAYLOAD_INFO, *PDELAYLOAD_INFO; +// typedef PVOID (WINAPI *PDELAYLOAD_FAILURE_DLL_CALLBACK)(ULONG, PDELAYLOAD_INFO); // // This structure specifies an offset (from the beginning of CONTEXT_EX @@ -1138,45 +1137,38 @@ RtlRunOnceExecuteOnce( /* Threadpool functions */ -NTSYSAPI NTSTATUS WINAPI TpAllocCleanupGroup(TP_CLEANUP_GROUP **); -NTSYSAPI NTSTATUS WINAPI TpAllocIoCompletion(TP_IO **,HANDLE,PTP_IO_CALLBACK,void *,TP_CALLBACK_ENVIRON *); -NTSYSAPI NTSTATUS WINAPI TpAllocPool(TP_POOL **,PVOID); -NTSYSAPI NTSTATUS WINAPI TpAllocTimer(TP_TIMER **,PTP_TIMER_CALLBACK,PVOID,TP_CALLBACK_ENVIRON *); -NTSYSAPI NTSTATUS WINAPI TpAllocWait(TP_WAIT **,PTP_WAIT_CALLBACK,PVOID,TP_CALLBACK_ENVIRON *); -NTSYSAPI NTSTATUS WINAPI TpAllocWork(TP_WORK **,PTP_WORK_CALLBACK,PVOID,TP_CALLBACK_ENVIRON *); -NTSYSAPI void WINAPI TpCallbackLeaveCriticalSectionOnCompletion(TP_CALLBACK_INSTANCE *,RTL_CRITICAL_SECTION *); -NTSYSAPI NTSTATUS WINAPI TpCallbackMayRunLong(TP_CALLBACK_INSTANCE *); -NTSYSAPI void WINAPI TpCallbackReleaseMutexOnCompletion(TP_CALLBACK_INSTANCE *,HANDLE); -NTSYSAPI void WINAPI TpCallbackReleaseSemaphoreOnCompletion(TP_CALLBACK_INSTANCE *,HANDLE,DWORD); -NTSYSAPI void WINAPI TpCallbackSetEventOnCompletion(TP_CALLBACK_INSTANCE *,HANDLE); -NTSYSAPI void WINAPI TpCallbackUnloadDllOnCompletion(TP_CALLBACK_INSTANCE *,HMODULE); -NTSYSAPI void WINAPI TpCancelAsyncIoOperation(TP_IO *); -NTSYSAPI void WINAPI TpDisassociateCallback(TP_CALLBACK_INSTANCE *); -NTSYSAPI BOOL WINAPI TpIsTimerSet(TP_TIMER *); -NTSYSAPI void WINAPI TpPostWork(TP_WORK *); -NTSYSAPI NTSTATUS WINAPI TpQueryPoolStackInformation(TP_POOL *, TP_POOL_STACK_INFORMATION *stack_info); -NTSYSAPI void WINAPI TpReleaseCleanupGroup(TP_CLEANUP_GROUP *); -NTSYSAPI void WINAPI TpReleaseCleanupGroupMembers(TP_CLEANUP_GROUP *,BOOL,PVOID); -NTSYSAPI void WINAPI TpReleaseIoCompletion(TP_IO *); -NTSYSAPI void WINAPI TpReleasePool(TP_POOL *); -NTSYSAPI void WINAPI TpReleaseTimer(TP_TIMER *); -NTSYSAPI void WINAPI TpReleaseWait(TP_WAIT *); -NTSYSAPI void WINAPI TpReleaseWork(TP_WORK *); -NTSYSAPI void WINAPI TpSetPoolMaxThreads(TP_POOL *,DWORD); -NTSYSAPI BOOL WINAPI TpSetPoolMinThreads(TP_POOL *,DWORD); -NTSYSAPI NTSTATUS WINAPI TpSetPoolStackInformation(TP_POOL *, TP_POOL_STACK_INFORMATION *stack_info); -NTSYSAPI void WINAPI TpSetTimer(TP_TIMER *, LARGE_INTEGER *,LONG,LONG); -NTSYSAPI void WINAPI TpSetWait(TP_WAIT *,HANDLE,LARGE_INTEGER *); -NTSYSAPI NTSTATUS WINAPI TpSimpleTryPost(PTP_SIMPLE_CALLBACK,PVOID,TP_CALLBACK_ENVIRON *); -NTSYSAPI void WINAPI TpStartAsyncIoOperation(TP_IO *); -NTSYSAPI void WINAPI TpWaitForIoCompletion(TP_IO *,BOOL); -NTSYSAPI void WINAPI TpWaitForTimer(TP_TIMER *,BOOL); -NTSYSAPI void WINAPI TpWaitForWait(TP_WAIT *,BOOL); -NTSYSAPI void WINAPI TpWaitForWork(TP_WORK *,BOOL); - -NTSTATUS -NTAPI -RtlDosPathNameToNtPathName_U_WithStatus(IN PCWSTR DosName, - OUT PUNICODE_STRING NtName, - OUT PCWSTR *PartName, - OUT PRTL_RELATIVE_NAME_U RelativeName); \ No newline at end of file +// NTSYSAPI NTSTATUS WINAPI TpAllocCleanupGroup(TP_CLEANUP_GROUP **); +// NTSYSAPI NTSTATUS WINAPI TpAllocIoCompletion(TP_IO **,HANDLE,PTP_IO_CALLBACK,void *,TP_CALLBACK_ENVIRON *); +// NTSYSAPI NTSTATUS WINAPI TpAllocPool(TP_POOL **,PVOID); +// NTSYSAPI NTSTATUS WINAPI TpAllocTimer(TP_TIMER **,PTP_TIMER_CALLBACK,PVOID,TP_CALLBACK_ENVIRON *); +// NTSYSAPI NTSTATUS WINAPI TpAllocWait(TP_WAIT **,PTP_WAIT_CALLBACK,PVOID,TP_CALLBACK_ENVIRON *); +// NTSYSAPI NTSTATUS WINAPI TpAllocWork(TP_WORK **,PTP_WORK_CALLBACK,PVOID,TP_CALLBACK_ENVIRON *); +// NTSYSAPI void WINAPI TpCallbackLeaveCriticalSectionOnCompletion(TP_CALLBACK_INSTANCE *,RTL_CRITICAL_SECTION *); +// NTSYSAPI NTSTATUS WINAPI TpCallbackMayRunLong(TP_CALLBACK_INSTANCE *); +// NTSYSAPI void WINAPI TpCallbackReleaseMutexOnCompletion(TP_CALLBACK_INSTANCE *,HANDLE); +// NTSYSAPI void WINAPI TpCallbackReleaseSemaphoreOnCompletion(TP_CALLBACK_INSTANCE *,HANDLE,DWORD); +// NTSYSAPI void WINAPI TpCallbackSetEventOnCompletion(TP_CALLBACK_INSTANCE *,HANDLE); +// NTSYSAPI void WINAPI TpCallbackUnloadDllOnCompletion(TP_CALLBACK_INSTANCE *,HMODULE); +// NTSYSAPI void WINAPI TpCancelAsyncIoOperation(TP_IO *); +// NTSYSAPI void WINAPI TpDisassociateCallback(TP_CALLBACK_INSTANCE *); +// NTSYSAPI BOOL WINAPI TpIsTimerSet(TP_TIMER *); +// NTSYSAPI void WINAPI TpPostWork(TP_WORK *); +// NTSYSAPI NTSTATUS WINAPI TpQueryPoolStackInformation(TP_POOL *, TP_POOL_STACK_INFORMATION *stack_info); +// NTSYSAPI void WINAPI TpReleaseCleanupGroup(TP_CLEANUP_GROUP *); +// NTSYSAPI void WINAPI TpReleaseCleanupGroupMembers(TP_CLEANUP_GROUP *,BOOL,PVOID); +// NTSYSAPI void WINAPI TpReleaseIoCompletion(TP_IO *); +// NTSYSAPI void WINAPI TpReleasePool(TP_POOL *); +// NTSYSAPI void WINAPI TpReleaseTimer(TP_TIMER *); +// NTSYSAPI void WINAPI TpReleaseWait(TP_WAIT *); +// NTSYSAPI void WINAPI TpReleaseWork(TP_WORK *); +// NTSYSAPI void WINAPI TpSetPoolMaxThreads(TP_POOL *,DWORD); +// NTSYSAPI BOOL WINAPI TpSetPoolMinThreads(TP_POOL *,DWORD); +// NTSYSAPI NTSTATUS WINAPI TpSetPoolStackInformation(TP_POOL *, TP_POOL_STACK_INFORMATION *stack_info); +// NTSYSAPI void WINAPI TpSetTimer(TP_TIMER *, LARGE_INTEGER *,LONG,LONG); +// NTSYSAPI void WINAPI TpSetWait(TP_WAIT *,HANDLE,LARGE_INTEGER *); +// NTSYSAPI NTSTATUS WINAPI TpSimpleTryPost(PTP_SIMPLE_CALLBACK,PVOID,TP_CALLBACK_ENVIRON *); +// NTSYSAPI void WINAPI TpStartAsyncIoOperation(TP_IO *); +// NTSYSAPI void WINAPI TpWaitForIoCompletion(TP_IO *,BOOL); +// NTSYSAPI void WINAPI TpWaitForTimer(TP_TIMER *,BOOL); +// NTSYSAPI void WINAPI TpWaitForWait(TP_WAIT *,BOOL); +// NTSYSAPI void WINAPI TpWaitForWork(TP_WORK *,BOOL); diff --git a/wrappers/base/ntext_wrapper/ntext.spec b/wrappers/base/ntext_wrapper/ntext.spec index 029ec500a18..1d64ab04051 100644 --- a/wrappers/base/ntext_wrapper/ntext.spec +++ b/wrappers/base/ntext_wrapper/ntext.spec @@ -1569,7 +1569,7 @@ @ stdcall RtlLCIDToCultureName(long wstr) ;this functions already have implementation @ stdcall RtlLcidToLocaleName(long ptr long long) @ stdcall RtlNormalizeString(long wstr long ptr ptr) -@ stdcall RtlProcessFlsData(ptr long) +@ stdcall RtlProcessFlsData(ptr) @ stdcall RtlpQueryDefaultUILanguage(long long) @ stdcall RtlpSetCurrentUserUILanguage(long) @ stdcall RtlpSetDefaultUILanguage(long) diff --git a/wrappers/base/ntext_wrapper/rtl/context.c b/wrappers/base/ntext_wrapper/rtl/context.c index 7d4faf7950b..e61c809ddad 100644 --- a/wrappers/base/ntext_wrapper/rtl/context.c +++ b/wrappers/base/ntext_wrapper/rtl/context.c @@ -28,7 +28,7 @@ Module Name: VOID NTAPI RtlSetExtendedFeaturesMask ( - __out PCONTEXT_EX ContextEx, + __out PCONTEXT ContextEx, __in DWORD64 FeatureMask ) { @@ -41,7 +41,7 @@ NTAPI RtlInitializeExtendedContext ( __out PVOID Context, __in DWORD ContextFlags, - __out PCONTEXT_EX* ContextEx + __out PCONTEXT* ContextEx ) { DbgPrint("UNIMPLEMENTED: RtlInitializeExtendedContext"); diff --git a/wrappers/base/ntext_wrapper/rtl/locale.c b/wrappers/base/ntext_wrapper/rtl/locale.c index 47b8110d497..d57efc1d66a 100644 --- a/wrappers/base/ntext_wrapper/rtl/locale.c +++ b/wrappers/base/ntext_wrapper/rtl/locale.c @@ -918,8 +918,14 @@ static NTSTATUS get_dummy_preferred_ui_language( DWORD flags, LANGID lang, ULONG /************************************************************************** * RtlGetUserPreferredUILanguages (NTDLL.@) */ -NTSTATUS WINAPI RtlGetUserPreferredUILanguages( DWORD flags, ULONG unknown, ULONG *count, - WCHAR *buffer, ULONG *size ) +NTSTATUS +NTAPI +RtlGetUserPreferredUILanguages( + DWORD flags, + BOOL verification, + PULONG count, + PZZWSTR buffer, + PULONG size) { LANGID ui_language; diff --git a/wrappers/base/ntext_wrapper/rtl/path.c b/wrappers/base/ntext_wrapper/rtl/path.c index 3d7e9c132cd..19725d3dd51 100644 --- a/wrappers/base/ntext_wrapper/rtl/path.c +++ b/wrappers/base/ntext_wrapper/rtl/path.c @@ -1127,7 +1127,7 @@ NTSTATUS NTAPI RtlDosPathNameToNtPathName_U_WithStatus(IN PCWSTR DosName, OUT PUNICODE_STRING NtName, - OUT PCWSTR *PartName, + OUT PWSTR *PartName, OUT PRTL_RELATIVE_NAME_U RelativeName) { /* Call the internal function */ diff --git a/wrappers/base/ntext_wrapper/rtl/synch.c b/wrappers/base/ntext_wrapper/rtl/synch.c index e87948f42fe..da309a1b2a9 100644 --- a/wrappers/base/ntext_wrapper/rtl/synch.c +++ b/wrappers/base/ntext_wrapper/rtl/synch.c @@ -84,24 +84,6 @@ InternalCmpXChgCondVarRel(IN OUT PRTL_CONDITION_VARIABLE ConditionVariable, (PVOID)Comperand); } -VOID -NTAPI -RtlReleaseSRWLockExclusive(IN OUT PRTL_SRWLOCK SRWLock); - -VOID -NTAPI -RtlAcquireSRWLockExclusive(IN OUT PRTL_SRWLOCK SRWLock); - -VOID -NTAPI -RtlReleaseSRWLockShared(IN OUT PRTL_SRWLOCK SRWLock); - -VOID -NTAPI -RtlAcquireSRWLockShared(IN OUT PRTL_SRWLOCK SRWLock); - - - /* GLOBALS *******************************************************************/ extern HANDLE GlobalKeyedEventHandle; @@ -664,7 +646,7 @@ RtlSleepConditionVariableCS(IN OUT PRTL_CONDITION_VARIABLE ConditionVariable, * the behaviour is undefined if the thread doesn't own the lock. */ NTSTATUS NTAPI RtlSleepConditionVariableSRW( RTL_CONDITION_VARIABLE *variable, RTL_SRWLOCK *lock, - const LARGE_INTEGER *timeout, ULONG flags ) + PLARGE_INTEGER timeout, ULONG flags ) { NTSTATUS status; interlocked_xchg_add( (int *)&variable->Ptr, 1 ); diff --git a/wrappers/base/ntext_wrapper/rtl/thread.c b/wrappers/base/ntext_wrapper/rtl/thread.c index c9d7e41fb2f..a1b18f4ca88 100644 --- a/wrappers/base/ntext_wrapper/rtl/thread.c +++ b/wrappers/base/ntext_wrapper/rtl/thread.c @@ -22,6 +22,8 @@ Revision History: #include +RTL_SRWLOCK RtlpFlsLock=RTL_SRWLOCK_INIT; + typedef struct _FLS_CALLBACK { void *unknown; @@ -275,7 +277,6 @@ NTSTATUS WINAPI DECLSPEC_HOTPATCH RtlFlsGetValue( ULONG index, void **data ) return STATUS_SUCCESS; } - /*********************************************************************** * RtlProcessFlsData (NTDLL.@) */ diff --git a/wrappers/base/ntext_wrapper/rtl/threadpool.c b/wrappers/base/ntext_wrapper/rtl/threadpool.c index 044bd070749..b03f9fef569 100644 --- a/wrappers/base/ntext_wrapper/rtl/threadpool.c +++ b/wrappers/base/ntext_wrapper/rtl/threadpool.c @@ -2254,7 +2254,7 @@ VOID WINAPI TpCallbackReleaseMutexOnCompletion( TP_CALLBACK_INSTANCE *instance, /*********************************************************************** * TpCallbackReleaseSemaphoreOnCompletion (NTDLL.@) */ -VOID WINAPI TpCallbackReleaseSemaphoreOnCompletion( TP_CALLBACK_INSTANCE *instance, HANDLE semaphore, DWORD count ) +VOID WINAPI TpCallbackReleaseSemaphoreOnCompletion( TP_CALLBACK_INSTANCE *instance, HANDLE semaphore, LONG count ) { struct threadpool_instance *this = impl_from_TP_CALLBACK_INSTANCE( instance ); diff --git a/wrappers/base/user32_wrapper/dib.c b/wrappers/base/user32_wrapper/dib.c index de34b3a07bc..6568cfe9da7 100644 --- a/wrappers/base/user32_wrapper/dib.c +++ b/wrappers/base/user32_wrapper/dib.c @@ -1,31 +1,22 @@ -/***************************************************************************\ -* ConvertDIBIcon -* -* Called when a cursor/icon in DIB format is loaded. This converts the -* cursor/icon into the old format and returns the resource handle. IE, -* grabs the DIB bits and transforms them into physical bitmap bits. -* -* -* DIB Formats for icons/cursors 101 -* -* Old Win 3.0 format icons/cursors start with an OLDICON/OLDCURSOR header -* followed by a double high monochrome DIB. The height refered to in the -* header is the icon/cursor height, not the DIB height which is twice as -* high. The XOR mask is in the first-half of the DIB bits. -* -* Old PM format icons/cursors start with a BITMAPCOREHEADER and -* are identical to the current win 3.1/NT format thereafter. -* -* Current NT/Chicago/Win 3.1 format icons/cursors start with -* a BITAMPINFOHEADER. The height of this header refers to the height -* of the first bitmap which may either be color or truely monochrome. -* If its color, it is followed by the monochrome AND mask bits imediately -* after the color bits. If it is truely monochrome, the AND and XOR -* masks are totally contained in the first DIB bits and no more bits -* follow. -* -* 5-Oct-1994 SanfordS Recreated -\***************************************************************************/ +/*++ + +Copyright (c) 2022 Shorthorn Project + +Module Name: + + dib.c + +Abstract: + + Implement DIB functions + +Author: + + Skulltrail 14-February-2022 + +Revision History: + +--*/ // HICON ConvertDIBIcon( // LPBITMAPINFOHEADER lpbih, diff --git a/wrappers/base/user32_wrapper/display.c b/wrappers/base/user32_wrapper/display.c index 400a439db08..b0f9691c963 100644 --- a/wrappers/base/user32_wrapper/display.c +++ b/wrappers/base/user32_wrapper/display.c @@ -1,21 +1,22 @@ -/* - * Copyright 2009 Henri Verbeet 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 - * - */ +/*++ + +Copyright (c) 2022 Shorthorn Project + +Module Name: + + display.c + +Abstract: + + Implement Display Information functions + +Author: + + Skulltrail 14-February-2022 + +Revision History: + +--*/ #include diff --git a/wrappers/base/user32_wrapper/dwm.c b/wrappers/base/user32_wrapper/dwm.c index 460aeca4191..fbaba9d3b3a 100644 --- a/wrappers/base/user32_wrapper/dwm.c +++ b/wrappers/base/user32_wrapper/dwm.c @@ -1,21 +1,22 @@ -/* - * Copyright 2009 Henri Verbeet 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 - * - */ +/*++ + +Copyright (c) 2022 Shorthorn Project + +Module Name: + + dwm.c + +Abstract: + + Implement DWM (Desktop Window Manager) functions + +Author: + + Skulltrail 14-February-2022 + +Revision History: + +--*/ #include diff --git a/wrappers/base/user32_wrapper/icon.c b/wrappers/base/user32_wrapper/icon.c index 6b1f3ddd0b8..1f7a768b518 100644 --- a/wrappers/base/user32_wrapper/icon.c +++ b/wrappers/base/user32_wrapper/icon.c @@ -4,7 +4,7 @@ Copyright (c) 2018 Shorthorn Project Module Name: - cursor.c + icon.c Abstract: @@ -17,6 +17,7 @@ Module Name: Revision History: --*/ + #include WINE_DEFAULT_DEBUG_CHANNEL(user32); diff --git a/wrappers/base/user32_wrapper/input.c b/wrappers/base/user32_wrapper/input.c index dd91497ed88..58733c33c81 100644 --- a/wrappers/base/user32_wrapper/input.c +++ b/wrappers/base/user32_wrapper/input.c @@ -1,21 +1,22 @@ -/* - * Copyright 2009 Henri Verbeet 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 - * - */ +/*++ + +Copyright (c) 2022 Shorthorn Project + +Module Name: + + input.c + +Abstract: + + Implement Input functions + +Author: + + Skulltrail 14-February-2022 + +Revision History: + +--*/ #include diff --git a/wrappers/base/user32_wrapper/magnification.c b/wrappers/base/user32_wrapper/magnification.c index 352ea78fb44..36a017fa414 100644 --- a/wrappers/base/user32_wrapper/magnification.c +++ b/wrappers/base/user32_wrapper/magnification.c @@ -1,21 +1,22 @@ -/* - * Copyright 2009 Henri Verbeet 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 - * - */ +/*++ + +Copyright (c) 2022 Shorthorn Project + +Module Name: + + input.c + +Abstract: + + Implement Input functions + +Author: + + Skulltrail 14-February-2022 + +Revision History: + +--*/ #include diff --git a/wrappers/base/user32_wrapper/sysparams.c b/wrappers/base/user32_wrapper/sysparams.c new file mode 100644 index 00000000000..69271f55f56 --- /dev/null +++ b/wrappers/base/user32_wrapper/sysparams.c @@ -0,0 +1,144 @@ +/*++ + +Copyright (c) 2022 Shorthorn Project + +Module Name: + + syspams.c + +Abstract: + + Implement System parameters functions + +Author: + + Skulltrail 14-February-2022 + +Revision History: + +--*/ + +#include + +WINE_DEFAULT_DEBUG_CHANNEL(user32); + +BOOL WINAPI GetDisplayAutoRotationPreferences( + _Out_ ORIENTATION_PREFERENCE *pOrientation +) +{ + *pOrientation = ORIENTATION_PREFERENCE_NONE; + DbgPrint("GetDisplayAutoRotationPreferences is UNIMPLEMENTED\n"); + return TRUE; +} + +/********************************************************************** + * GetAutoRotationState [USER32.@] + */ +BOOL WINAPI GetAutoRotationState( AR_STATE *state ) +{ + FIXME("(%p): stub\n", state); + *state = AR_NOT_SUPPORTED; + return TRUE; + } + +BOOL WINAPI SetDisplayAutoRotationPreferences( + _In_ ORIENTATION_PREFERENCE pOrientation +) +{ + Orientation = pOrientation; + DbgPrint("SetDisplayAutoRotationPreferences is UNIMPLEMENTED\n"); + return TRUE; +} + +//aqui +LONG WINAPI DisplayConfigGetDeviceInfo( + _Inout_ DISPLAYCONFIG_DEVICE_INFO_HEADER *requestPacket +) +{ + DbgPrint("DisplayConfigGetDeviceInfo is UNIMPLEMENTED\n"); + return ERROR_SUCCESS; +} + +LONG WINAPI DisplayConfigSetDeviceInfo( + _Inout_ DISPLAYCONFIG_DEVICE_INFO_HEADER *setPacket +) +{ + DbgPrint("DisplayConfigSetDeviceInfo is UNIMPLEMENTED\n"); + return ERROR_SUCCESS; +} + +/********************************************************************** + * GetDisplayConfigBufferSizes [USER32.@] + */ +LONG WINAPI GetDisplayConfigBufferSizes(UINT32 flags, UINT32 *num_path_info, UINT32 *num_mode_info) +{ + DbgPrint("(0x%x %p %p): stub\n", flags, num_path_info, num_mode_info); + + if (!num_path_info || !num_mode_info) + return ERROR_INVALID_PARAMETER; + + *num_path_info = 0; + *num_mode_info = 0; + return ERROR_NOT_SUPPORTED; +} + +LONG WINAPI QueryDisplayConfig( + _In_ UINT32 Flags, + _Inout_ UINT32 *pNumPathArrayElements, + _Out_ DISPLAYCONFIG_PATH_INFO *pPathInfoArray, + _Inout_ UINT32 *pNumModeInfoArrayElements, + _Out_ DISPLAYCONFIG_MODE_INFO *pModeInfoArray, + _Out_opt_ DISPLAYCONFIG_TOPOLOGY_ID *pCurrentTopologyId +) +{ + DbgPrint("QueryDisplayConfig is UNIMPLEMENTED\n"); + return ERROR_CALL_NOT_IMPLEMENTED; +} + +LONG +WINAPI +SetDisplayConfig( + _In_ UINT32 numPathArrayElements, + _In_opt_ DISPLAYCONFIG_PATH_INFO *pathArray, + _In_ UINT32 numModeInfoArrayElements, + _In_opt_ DISPLAYCONFIG_MODE_INFO *modeInfoArray, + _In_ UINT32 Flags +) +{ + DbgPrint("SetDisplayConfig is UNIMPLEMENTED\n"); + return ERROR_SUCCESS; +} + +BOOL WINAPI GetWindowDisplayAffinity( + _In_ HWND hWnd, + _Out_ DWORD *dwAffinity +) +{ + DbgPrint("(%p, %p): stub\n", hWnd, dwAffinity); + + if (!hWnd || !dwAffinity) + { + SetLastError(hWnd ? ERROR_NOACCESS : ERROR_INVALID_WINDOW_HANDLE); + return FALSE; + } + + *dwAffinity = WDA_NONE; + return TRUE; +} + +BOOL WINAPI SetWindowDisplayAffinity( + _In_ HWND hWnd, + _In_ DWORD dwAffinity +) +{ + DbgPrint("(%p, %u): stub\n", hWnd, dwAffinity); + + if (!hWnd) + { + SetLastError(ERROR_INVALID_WINDOW_HANDLE); + return FALSE; + } + + SetLastError(ERROR_NOT_ENOUGH_MEMORY); + return FALSE; +} \ No newline at end of file diff --git a/wrappers/new-dlls/version_new/CMakeLists.txt b/wrappers/new-dlls/version_new/CMakeLists.txt new file mode 100644 index 00000000000..c02c5bb4d69 --- /dev/null +++ b/wrappers/new-dlls/version_new/CMakeLists.txt @@ -0,0 +1,14 @@ + +add_definitions(-D__WINESRC__) +include_directories(BEFORE ${REACTOS_SOURCE_DIR}/sdk/include/reactos/wine) +spec2def(version_new.dll version_new.spec) + +list(APPEND SOURCE + version_new.c + ${CMAKE_CURRENT_BINARY_DIR}/version_new.def) + +add_library(version_new MODULE ${SOURCE} version_new.rc) +set_module_type(version_new win32dll) +target_link_libraries(version_new wine) +add_importlibs(version_new msvcrt kernel32 ntdll) +add_cd_file(TARGET version_new DESTINATION reactos/system32 FOR all) diff --git a/wrappers/new-dlls/version_new/version_new.c b/wrappers/new-dlls/version_new/version_new.c new file mode 100644 index 00000000000..0e2f35dd107 --- /dev/null +++ b/wrappers/new-dlls/version_new/version_new.c @@ -0,0 +1,1679 @@ +/* + * Implementation of VERSION.DLL + * + * Copyright 1996,1997 Marcus Meissner + * Copyright 1997 David Cuthbert + * Copyright 1999 Ulrich Weigand + * Copyright 2005 Paul Vriens + * + * 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 +#include +#include + +#include + +#define NONAMELESSUNION +#define NONAMELESSSTRUCT +#include "windef.h" +#include "winbase.h" +#include "winver.h" +#include "winuser.h" +#include "winnls.h" +#include "wine/winternl.h" +#include "lzexpand.h" +#include "winerror.h" +#include "wine/debug.h" + + +WINE_DEFAULT_DEBUG_CHANNEL(ver); + +typedef struct +{ + WORD offset; + WORD length; + WORD flags; + WORD id; + WORD handle; + WORD usage; +} NE_NAMEINFO; + +typedef struct +{ + WORD type_id; + WORD count; + DWORD resloader; +} NE_TYPEINFO; + +/********************************************************************** + * find_entry_by_id + * + * Find an entry by id in a resource directory + * Copied from loader/pe_resource.c + */ +static const IMAGE_RESOURCE_DIRECTORY *find_entry_by_id( const IMAGE_RESOURCE_DIRECTORY *dir, + WORD id, const void *root ) +{ + const IMAGE_RESOURCE_DIRECTORY_ENTRY *entry; + int min, max, pos; + + entry = (const IMAGE_RESOURCE_DIRECTORY_ENTRY *)(dir + 1); + min = dir->NumberOfNamedEntries; + max = min + dir->NumberOfIdEntries - 1; + while (min <= max) + { + pos = (min + max) / 2; + if (entry[pos].u.Id == id) + return (const IMAGE_RESOURCE_DIRECTORY *)((const char *)root + entry[pos].u2.s2.OffsetToDirectory); + if (entry[pos].u.Id > id) max = pos - 1; + else min = pos + 1; + } + return NULL; +} + + +/********************************************************************** + * find_entry_default + * + * Find a default entry in a resource directory + * Copied from loader/pe_resource.c + */ +static const IMAGE_RESOURCE_DIRECTORY *find_entry_default( const IMAGE_RESOURCE_DIRECTORY *dir, + const void *root ) +{ + const IMAGE_RESOURCE_DIRECTORY_ENTRY *entry; + + entry = (const IMAGE_RESOURCE_DIRECTORY_ENTRY *)(dir + 1); + return (const IMAGE_RESOURCE_DIRECTORY *)((const char *)root + entry->u2.s2.OffsetToDirectory); +} + + +/********************************************************************** + * push_language + * + * push a language onto the list of languages to try + */ +static inline int push_language( WORD *list, int pos, WORD lang ) +{ + int i; + for (i = 0; i < pos; i++) if (list[i] == lang) return pos; + list[pos++] = lang; + return pos; +} + + +/********************************************************************** + * find_entry_language + */ +static const IMAGE_RESOURCE_DIRECTORY *find_entry_language( const IMAGE_RESOURCE_DIRECTORY *dir, + const void *root, DWORD flags ) +{ + const IMAGE_RESOURCE_DIRECTORY *ret; + WORD list[9]; + int i, pos = 0; + + if (flags & FILE_VER_GET_LOCALISED) + { + /* cf. LdrFindResource_U */ + pos = push_language( list, pos, MAKELANGID( LANG_NEUTRAL, SUBLANG_NEUTRAL ) ); + pos = push_language( list, pos, LANGIDFROMLCID( NtCurrentTeb()->CurrentLocale ) ); + pos = push_language( list, pos, GetUserDefaultLangID() ); + pos = push_language( list, pos, MAKELANGID( PRIMARYLANGID(GetUserDefaultLangID()), SUBLANG_NEUTRAL )); + pos = push_language( list, pos, MAKELANGID( PRIMARYLANGID(GetUserDefaultLangID()), SUBLANG_DEFAULT )); + pos = push_language( list, pos, GetSystemDefaultLangID() ); + pos = push_language( list, pos, MAKELANGID( PRIMARYLANGID(GetSystemDefaultLangID()), SUBLANG_NEUTRAL )); + pos = push_language( list, pos, MAKELANGID( PRIMARYLANGID(GetSystemDefaultLangID()), SUBLANG_DEFAULT )); + pos = push_language( list, pos, MAKELANGID( LANG_ENGLISH, SUBLANG_DEFAULT ) ); + } + else + { + /* FIXME: resolve LN file here */ + pos = push_language( list, pos, MAKELANGID( LANG_ENGLISH, SUBLANG_DEFAULT ) ); + } + + for (i = 0; i < pos; i++) if ((ret = find_entry_by_id( dir, list[i], root ))) return ret; + return find_entry_default( dir, root ); +} + + +/*********************************************************************** + * read_xx_header [internal] + */ +static int read_xx_header( HFILE lzfd ) +{ + IMAGE_DOS_HEADER mzh; + char magic[3]; + + LZSeek( lzfd, 0, SEEK_SET ); + if ( sizeof(mzh) != LZRead( lzfd, (LPSTR)&mzh, sizeof(mzh) ) ) + return 0; + if ( mzh.e_magic != IMAGE_DOS_SIGNATURE ) + { + if (!memcmp( &mzh, "\177ELF", 4 )) return 1; /* ELF */ + if (*(UINT *)&mzh == 0xfeedface || *(UINT *)&mzh == 0xcefaedfe) return 1; /* Mach-O */ + return 0; + } + + LZSeek( lzfd, mzh.e_lfanew, SEEK_SET ); + if ( 2 != LZRead( lzfd, magic, 2 ) ) + return 0; + + LZSeek( lzfd, mzh.e_lfanew, SEEK_SET ); + + if ( magic[0] == 'N' && magic[1] == 'E' ) + return IMAGE_OS2_SIGNATURE; + if ( magic[0] == 'P' && magic[1] == 'E' ) + return IMAGE_NT_SIGNATURE; + + magic[2] = '\0'; + WARN("Can't handle %s files.\n", magic ); + return 0; +} + +/*********************************************************************** + * find_ne_resource [internal] + */ +static BOOL find_ne_resource( HFILE lzfd, DWORD *resLen, DWORD *resOff ) +{ + const WORD typeid = VS_FILE_INFO | 0x8000; + const WORD resid = VS_VERSION_INFO | 0x8000; + IMAGE_OS2_HEADER nehd; + NE_TYPEINFO *typeInfo; + NE_NAMEINFO *nameInfo; + DWORD nehdoffset; + LPBYTE resTab; + DWORD resTabSize; + int count; + + /* Read in NE header */ + nehdoffset = LZSeek( lzfd, 0, SEEK_CUR ); + if ( sizeof(nehd) != LZRead( lzfd, (LPSTR)&nehd, sizeof(nehd) ) ) return FALSE; + + resTabSize = nehd.ne_restab - nehd.ne_rsrctab; + if ( !resTabSize ) + { + TRACE("No resources in NE dll\n" ); + return FALSE; + } + + /* Read in resource table */ + resTab = HeapAlloc( GetProcessHeap(), 0, resTabSize ); + if ( !resTab ) return FALSE; + + LZSeek( lzfd, nehd.ne_rsrctab + nehdoffset, SEEK_SET ); + if ( resTabSize != LZRead( lzfd, (char*)resTab, resTabSize ) ) + { + HeapFree( GetProcessHeap(), 0, resTab ); + return FALSE; + } + + /* Find resource */ + typeInfo = (NE_TYPEINFO *)(resTab + 2); + while (typeInfo->type_id) + { + if (typeInfo->type_id == typeid) goto found_type; + typeInfo = (NE_TYPEINFO *)((char *)(typeInfo + 1) + + typeInfo->count * sizeof(NE_NAMEINFO)); + } + TRACE("No typeid entry found\n" ); + HeapFree( GetProcessHeap(), 0, resTab ); + return FALSE; + + found_type: + nameInfo = (NE_NAMEINFO *)(typeInfo + 1); + + for (count = typeInfo->count; count > 0; count--, nameInfo++) + if (nameInfo->id == resid) goto found_name; + + TRACE("No resid entry found\n" ); + HeapFree( GetProcessHeap(), 0, resTab ); + return FALSE; + + found_name: + /* Return resource data */ + if ( resLen ) *resLen = nameInfo->length << *(WORD *)resTab; + if ( resOff ) *resOff = nameInfo->offset << *(WORD *)resTab; + + HeapFree( GetProcessHeap(), 0, resTab ); + return TRUE; +} + +/*********************************************************************** + * find_pe_resource [internal] + */ +static BOOL find_pe_resource( HFILE lzfd, DWORD *resLen, DWORD *resOff, DWORD flags ) +{ + union + { + IMAGE_NT_HEADERS32 nt32; + IMAGE_NT_HEADERS64 nt64; + } pehd; + DWORD pehdoffset; + PIMAGE_DATA_DIRECTORY resDataDir; + PIMAGE_SECTION_HEADER sections; + LPBYTE resSection; + DWORD section_size, data_size; + const void *resDir; + const IMAGE_RESOURCE_DIRECTORY *resPtr; + const IMAGE_RESOURCE_DATA_ENTRY *resData; + int i, len, nSections; + BOOL ret = FALSE; + + /* Read in PE header */ + pehdoffset = LZSeek( lzfd, 0, SEEK_CUR ); + len = LZRead( lzfd, (LPSTR)&pehd, sizeof(pehd) ); + if (len < sizeof(pehd.nt32.FileHeader)) return FALSE; + if (len < sizeof(pehd)) memset( (char *)&pehd + len, 0, sizeof(pehd) - len ); + + switch (pehd.nt32.OptionalHeader.Magic) + { + case IMAGE_NT_OPTIONAL_HDR32_MAGIC: + resDataDir = pehd.nt32.OptionalHeader.DataDirectory + IMAGE_DIRECTORY_ENTRY_RESOURCE; + break; + case IMAGE_NT_OPTIONAL_HDR64_MAGIC: + resDataDir = pehd.nt64.OptionalHeader.DataDirectory + IMAGE_DIRECTORY_ENTRY_RESOURCE; + break; + default: + return FALSE; + } + + if ( !resDataDir->Size ) + { + TRACE("No resources in PE dll\n" ); + return FALSE; + } + + /* Read in section table */ + nSections = pehd.nt32.FileHeader.NumberOfSections; + sections = HeapAlloc( GetProcessHeap(), 0, + nSections * sizeof(IMAGE_SECTION_HEADER) ); + if ( !sections ) return FALSE; + + len = FIELD_OFFSET( IMAGE_NT_HEADERS32, OptionalHeader ) + pehd.nt32.FileHeader.SizeOfOptionalHeader; + LZSeek( lzfd, pehdoffset + len, SEEK_SET ); + + if ( nSections * sizeof(IMAGE_SECTION_HEADER) != + LZRead( lzfd, (LPSTR)sections, nSections * sizeof(IMAGE_SECTION_HEADER) ) ) + { + HeapFree( GetProcessHeap(), 0, sections ); + return FALSE; + } + + /* Find resource section */ + for ( i = 0; i < nSections; i++ ) + if ( resDataDir->VirtualAddress >= sections[i].VirtualAddress + && resDataDir->VirtualAddress < sections[i].VirtualAddress + + sections[i].SizeOfRawData ) + break; + + if ( i == nSections ) + { + HeapFree( GetProcessHeap(), 0, sections ); + TRACE("Couldn't find resource section\n" ); + return FALSE; + } + + /* Read in resource section */ + data_size = sections[i].SizeOfRawData; + section_size = max( data_size, sections[i].Misc.VirtualSize ); + resSection = HeapAlloc( GetProcessHeap(), 0, section_size ); + if ( !resSection ) + { + HeapFree( GetProcessHeap(), 0, sections ); + return FALSE; + } + + LZSeek( lzfd, sections[i].PointerToRawData, SEEK_SET ); + if (data_size != LZRead( lzfd, (char*)resSection, data_size )) goto done; + if (data_size < section_size) memset( (char *)resSection + data_size, 0, section_size - data_size ); + + /* Find resource */ + resDir = resSection + (resDataDir->VirtualAddress - sections[i].VirtualAddress); + + resPtr = resDir; + resPtr = find_entry_by_id( resPtr, VS_FILE_INFO, resDir ); + if ( !resPtr ) + { + TRACE("No typeid entry found\n" ); + goto done; + } + resPtr = find_entry_by_id( resPtr, VS_VERSION_INFO, resDir ); + if ( !resPtr ) + { + TRACE("No resid entry found\n" ); + goto done; + } + resPtr = find_entry_language( resPtr, resDir, flags ); + if ( !resPtr ) + { + TRACE("No default language entry found\n" ); + goto done; + } + + /* Find resource data section */ + resData = (const IMAGE_RESOURCE_DATA_ENTRY*)resPtr; + for ( i = 0; i < nSections; i++ ) + if ( resData->OffsetToData >= sections[i].VirtualAddress + && resData->OffsetToData < sections[i].VirtualAddress + + sections[i].SizeOfRawData ) + break; + + if ( i == nSections ) + { + TRACE("Couldn't find resource data section\n" ); + goto done; + } + + /* Return resource data */ + if ( resLen ) *resLen = resData->Size; + if ( resOff ) *resOff = resData->OffsetToData - sections[i].VirtualAddress + + sections[i].PointerToRawData; + ret = TRUE; + + done: + HeapFree( GetProcessHeap(), 0, resSection ); + HeapFree( GetProcessHeap(), 0, sections ); + return ret; +} + + +/*********************************************************************** + * find_version_resource [internal] + */ +static DWORD find_version_resource( HFILE lzfd, DWORD *reslen, DWORD *offset, DWORD flags ) +{ + DWORD magic = read_xx_header( lzfd ); + + switch (magic) + { + case IMAGE_OS2_SIGNATURE: + if (!find_ne_resource( lzfd, reslen, offset )) magic = 0; + break; + case IMAGE_NT_SIGNATURE: + if (!find_pe_resource( lzfd, reslen, offset, flags )) magic = 0; + break; + } + return magic; +} + +/****************************************************************************** + * + * This function will print via standard TRACE, debug info regarding + * the file info structure vffi. + * 15-Feb-1998 Dimitrie Paun (dimi@cs.toronto.edu) + * Added this function to clean up the code. + * + *****************************************************************************/ +static void print_vffi_debug(const VS_FIXEDFILEINFO *vffi) +{ + BOOL versioned_printer = FALSE; + + if((vffi->dwFileType == VFT_DLL) || (vffi->dwFileType == VFT_DRV)) + { + if(vffi->dwFileSubtype == VFT2_DRV_VERSIONED_PRINTER) + /* this is documented for newer w2k Drivers and up */ + versioned_printer = TRUE; + else if( (vffi->dwFileSubtype == VFT2_DRV_PRINTER) && + (vffi->dwFileVersionMS != vffi->dwProductVersionMS) && + (vffi->dwFileVersionMS > 0) && + (vffi->dwFileVersionMS <= 3) ) + /* found this on NT 3.51, NT4.0 and old w2k Drivers */ + versioned_printer = TRUE; + } + + TRACE("structversion=%u.%u, ", + HIWORD(vffi->dwStrucVersion),LOWORD(vffi->dwStrucVersion)); + if(versioned_printer) + { + WORD mode = LOWORD(vffi->dwFileVersionMS); + WORD ver_rev = HIWORD(vffi->dwFileVersionLS); + TRACE("fileversion=%u.%u.%u.%u (%s.major.minor.release), ", + (vffi->dwFileVersionMS), + HIBYTE(ver_rev), LOBYTE(ver_rev), LOWORD(vffi->dwFileVersionLS), + (mode == 3) ? "Usermode" : ((mode <= 2) ? "Kernelmode" : "?") ); + } + else + { + TRACE("fileversion=%u.%u.%u.%u, ", + HIWORD(vffi->dwFileVersionMS),LOWORD(vffi->dwFileVersionMS), + HIWORD(vffi->dwFileVersionLS),LOWORD(vffi->dwFileVersionLS)); + } + TRACE("productversion=%u.%u.%u.%u\n", + HIWORD(vffi->dwProductVersionMS),LOWORD(vffi->dwProductVersionMS), + HIWORD(vffi->dwProductVersionLS),LOWORD(vffi->dwProductVersionLS)); + + TRACE("flagmask=0x%x, flags=0x%x %s%s%s%s%s%s\n", + vffi->dwFileFlagsMask, vffi->dwFileFlags, + (vffi->dwFileFlags & VS_FF_DEBUG) ? "DEBUG," : "", + (vffi->dwFileFlags & VS_FF_PRERELEASE) ? "PRERELEASE," : "", + (vffi->dwFileFlags & VS_FF_PATCHED) ? "PATCHED," : "", + (vffi->dwFileFlags & VS_FF_PRIVATEBUILD) ? "PRIVATEBUILD," : "", + (vffi->dwFileFlags & VS_FF_INFOINFERRED) ? "INFOINFERRED," : "", + (vffi->dwFileFlags & VS_FF_SPECIALBUILD) ? "SPECIALBUILD," : ""); + + TRACE("("); + + TRACE("OS=0x%x.0x%x ", HIWORD(vffi->dwFileOS), LOWORD(vffi->dwFileOS)); + + switch (vffi->dwFileOS&0xFFFF0000) + { + case VOS_DOS:TRACE("DOS,");break; + case VOS_OS216:TRACE("OS/2-16,");break; + case VOS_OS232:TRACE("OS/2-32,");break; + case VOS_NT:TRACE("NT,");break; + case VOS_UNKNOWN: + default: + TRACE("UNKNOWN(0x%x),",vffi->dwFileOS&0xFFFF0000);break; + } + + switch (LOWORD(vffi->dwFileOS)) + { + case VOS__BASE:TRACE("BASE");break; + case VOS__WINDOWS16:TRACE("WIN16");break; + case VOS__WINDOWS32:TRACE("WIN32");break; + case VOS__PM16:TRACE("PM16");break; + case VOS__PM32:TRACE("PM32");break; + default: + TRACE("UNKNOWN(0x%x)",LOWORD(vffi->dwFileOS));break; + } + + TRACE(")\n"); + + switch (vffi->dwFileType) + { + case VFT_APP:TRACE("filetype=APP");break; + case VFT_DLL: + TRACE("filetype=DLL"); + if(vffi->dwFileSubtype != 0) + { + if(versioned_printer) /* NT3.x/NT4.0 or old w2k Driver */ + TRACE(",PRINTER"); + TRACE(" (subtype=0x%x)", vffi->dwFileSubtype); + } + break; + case VFT_DRV: + TRACE("filetype=DRV,"); + switch(vffi->dwFileSubtype) + { + case VFT2_DRV_PRINTER:TRACE("PRINTER");break; + case VFT2_DRV_KEYBOARD:TRACE("KEYBOARD");break; + case VFT2_DRV_LANGUAGE:TRACE("LANGUAGE");break; + case VFT2_DRV_DISPLAY:TRACE("DISPLAY");break; + case VFT2_DRV_MOUSE:TRACE("MOUSE");break; + case VFT2_DRV_NETWORK:TRACE("NETWORK");break; + case VFT2_DRV_SYSTEM:TRACE("SYSTEM");break; + case VFT2_DRV_INSTALLABLE:TRACE("INSTALLABLE");break; + case VFT2_DRV_SOUND:TRACE("SOUND");break; + case VFT2_DRV_COMM:TRACE("COMM");break; + case VFT2_DRV_INPUTMETHOD:TRACE("INPUTMETHOD");break; + case VFT2_DRV_VERSIONED_PRINTER:TRACE("VERSIONED_PRINTER");break; + case VFT2_UNKNOWN: + default: + TRACE("UNKNOWN(0x%x)",vffi->dwFileSubtype);break; + } + break; + case VFT_FONT: + TRACE("filetype=FONT,"); + switch (vffi->dwFileSubtype) + { + case VFT2_FONT_RASTER:TRACE("RASTER");break; + case VFT2_FONT_VECTOR:TRACE("VECTOR");break; + case VFT2_FONT_TRUETYPE:TRACE("TRUETYPE");break; + default:TRACE("UNKNOWN(0x%x)",vffi->dwFileSubtype);break; + } + break; + case VFT_VXD:TRACE("filetype=VXD");break; + case VFT_STATIC_LIB:TRACE("filetype=STATIC_LIB");break; + case VFT_UNKNOWN: + default: + TRACE("filetype=Unknown(0x%x)",vffi->dwFileType);break; + } + + TRACE("\n"); + TRACE("filedate=0x%x.0x%x\n",vffi->dwFileDateMS,vffi->dwFileDateLS); +} + +/*********************************************************************** + * Version Info Structure + */ + +typedef struct +{ + WORD wLength; + WORD wValueLength; + CHAR szKey[1]; +#if 0 /* variable length structure */ + /* DWORD aligned */ + BYTE Value[]; + /* DWORD aligned */ + VS_VERSION_INFO_STRUCT16 Children[]; +#endif +} VS_VERSION_INFO_STRUCT16; + +typedef struct +{ + WORD wLength; + WORD wValueLength; + WORD wType; /* 1:Text, 0:Binary */ + WCHAR szKey[1]; +#if 0 /* variable length structure */ + /* DWORD aligned */ + BYTE Value[]; + /* DWORD aligned */ + VS_VERSION_INFO_STRUCT32 Children[]; +#endif +} VS_VERSION_INFO_STRUCT32; + +#define VersionInfoIs16( ver ) \ + ( ((const VS_VERSION_INFO_STRUCT16 *)ver)->szKey[0] >= ' ' ) + +#define DWORD_ALIGN( base, ptr ) \ + ( (LPBYTE)(base) + ((((LPBYTE)(ptr) - (LPBYTE)(base)) + 3) & ~3) ) + +#define VersionInfo16_Value( ver ) \ + DWORD_ALIGN( (ver), (ver)->szKey + strlen((ver)->szKey) + 1 ) +#define VersionInfo32_Value( ver ) \ + DWORD_ALIGN( (ver), (ver)->szKey + lstrlenW((ver)->szKey) + 1 ) + +#define VersionInfo16_Children( ver ) \ + (const VS_VERSION_INFO_STRUCT16 *)( VersionInfo16_Value( ver ) + \ + ( ( (ver)->wValueLength + 3 ) & ~3 ) ) +#define VersionInfo32_Children( ver ) \ + (const VS_VERSION_INFO_STRUCT32 *)( VersionInfo32_Value( ver ) + \ + ( ( (ver)->wValueLength * \ + ((ver)->wType? 2 : 1) + 3 ) & ~3 ) ) + +#define VersionInfo16_Next( ver ) \ + (VS_VERSION_INFO_STRUCT16 *)( (LPBYTE)ver + (((ver)->wLength + 3) & ~3) ) +#define VersionInfo32_Next( ver ) \ + (VS_VERSION_INFO_STRUCT32 *)( (LPBYTE)ver + (((ver)->wLength + 3) & ~3) ) + + +/*********************************************************************** + * GetFileVersionInfoSizeW [VERSION.@] + */ +DWORD WINAPI GetFileVersionInfoSizeW( LPCWSTR filename, LPDWORD handle ) +{ + return GetFileVersionInfoSizeExW( FILE_VER_GET_LOCALISED, filename, handle ); +} + +/*********************************************************************** + * GetFileVersionInfoSizeA [VERSION.@] + */ +DWORD WINAPI GetFileVersionInfoSizeA( LPCSTR filename, LPDWORD handle ) +{ + return GetFileVersionInfoSizeExA( FILE_VER_GET_LOCALISED, filename, handle ); +} + +/****************************************************************************** + * GetFileVersionInfoSizeExW [VERSION.@] + */ +DWORD WINAPI GetFileVersionInfoSizeExW( DWORD flags, LPCWSTR filename, LPDWORD handle ) +{ + DWORD len, offset, magic = 1; + HFILE lzfd; + HMODULE hModule; + OFSTRUCT ofs; + + TRACE("(0x%x,%s,%p)\n", flags, debugstr_w(filename), handle ); + + if (handle) *handle = 0; + + if (!filename) + { + SetLastError(ERROR_INVALID_PARAMETER); + return 0; + } + if (!*filename) + { + SetLastError(ERROR_BAD_PATHNAME); + return 0; + } + if (flags & ~FILE_VER_GET_LOCALISED) + FIXME("flags 0x%x ignored\n", flags & ~FILE_VER_GET_LOCALISED); + + if ((lzfd = LZOpenFileW( (LPWSTR)filename, &ofs, OF_READ )) != HFILE_ERROR) + { + magic = find_version_resource( lzfd, &len, &offset, flags ); + LZClose( lzfd ); + } + + if ((magic == 1) && (hModule = LoadLibraryExW( filename, 0, LOAD_LIBRARY_AS_DATAFILE ))) + { + HRSRC hRsrc = NULL; + if (!(flags & FILE_VER_GET_LOCALISED)) + { + LANGID english = MAKELANGID( LANG_ENGLISH, SUBLANG_DEFAULT ); + hRsrc = FindResourceExW( hModule, MAKEINTRESOURCEW(VS_VERSION_INFO), + (LPWSTR)VS_FILE_INFO, english ); + } + if (!hRsrc) + hRsrc = FindResourceW( hModule, MAKEINTRESOURCEW(VS_VERSION_INFO), + (LPWSTR)VS_FILE_INFO ); + if (hRsrc) + { + magic = IMAGE_NT_SIGNATURE; + len = SizeofResource( hModule, hRsrc ); + } + FreeLibrary( hModule ); + } + + switch (magic) + { + case IMAGE_OS2_SIGNATURE: + /* We have a 16bit resource. + * + * XP/W2K/W2K3 uses a buffer which is more than the actual needed space: + * + * (info->wLength - sizeof(VS_FIXEDFILEINFO)) * 4 + * + * This extra buffer is used for ANSI to Unicode conversions in W-Calls. + * info->wLength should be the same as len. Currently it isn't but that + * doesn't seem to be a problem (len is bigger than info->wLength). + */ + SetLastError(0); + return (len - sizeof(VS_FIXEDFILEINFO)) * 4; + + case IMAGE_NT_SIGNATURE: + /* We have a 32bit resource. + * + * XP/W2K/W2K3 uses a buffer which is 2 times the actual needed space + 4 bytes "FE2X" + * This extra buffer is used for Unicode to ANSI conversions in A-Calls + */ + SetLastError(0); + return (len * 2) + 4; + + default: + if (lzfd == HFILE_ERROR) + SetLastError(ofs.nErrCode); + else if (GetVersion() & 0x80000000) /* Windows 95/98 */ + SetLastError(ERROR_FILE_NOT_FOUND); + else + SetLastError(ERROR_RESOURCE_DATA_NOT_FOUND); + return 0; + } +} + +/****************************************************************************** + * GetFileVersionInfoSizeExA [VERSION.@] + */ +DWORD WINAPI GetFileVersionInfoSizeExA( DWORD flags, LPCSTR filename, LPDWORD handle ) +{ + UNICODE_STRING filenameW; + DWORD retval; + + TRACE("(0x%x,%s,%p)\n", flags, debugstr_a(filename), handle ); + + if(filename) + RtlCreateUnicodeStringFromAsciiz(&filenameW, filename); + else + filenameW.Buffer = NULL; + + retval = GetFileVersionInfoSizeExW(flags, filenameW.Buffer, handle); + + RtlFreeUnicodeString(&filenameW); + + return retval; +} + +/*********************************************************************** + * GetFileVersionInfoExW [VERSION.@] + */ +BOOL WINAPI GetFileVersionInfoExW( DWORD flags, LPCWSTR filename, DWORD handle, DWORD datasize, LPVOID data ) +{ + static const char signature[4] = "FE2X"; + DWORD len, offset, magic = 1; + HFILE lzfd; + OFSTRUCT ofs; + HMODULE hModule; + VS_VERSION_INFO_STRUCT32* vvis = data; + + TRACE("(0x%x,%s,%d,size=%d,data=%p)\n", + flags, debugstr_w(filename), handle, datasize, data ); + + if (!data) + { + SetLastError(ERROR_INVALID_DATA); + return FALSE; + } + if (flags & ~FILE_VER_GET_LOCALISED) + FIXME("flags 0x%x ignored\n", flags & ~FILE_VER_GET_LOCALISED); + + if ((lzfd = LZOpenFileW( (LPWSTR)filename, &ofs, OF_READ )) != HFILE_ERROR) + { + if ((magic = find_version_resource( lzfd, &len, &offset, flags )) > 1) + { + LZSeek( lzfd, offset, 0 /* SEEK_SET */ ); + len = LZRead( lzfd, data, min( len, datasize ) ); + } + LZClose( lzfd ); + } + + if ((magic == 1) && (hModule = LoadLibraryExW( filename, 0, LOAD_LIBRARY_AS_DATAFILE ))) + { + HRSRC hRsrc = NULL; + if (!(flags & FILE_VER_GET_LOCALISED)) + { + LANGID english = MAKELANGID( LANG_ENGLISH, SUBLANG_DEFAULT ); + hRsrc = FindResourceExW( hModule, MAKEINTRESOURCEW(VS_VERSION_INFO), + (LPWSTR)VS_FILE_INFO, english ); + } + if (!hRsrc) + hRsrc = FindResourceW( hModule, MAKEINTRESOURCEW(VS_VERSION_INFO), + (LPWSTR)VS_FILE_INFO ); + if (hRsrc) + { + HGLOBAL hMem = LoadResource( hModule, hRsrc ); + magic = IMAGE_NT_SIGNATURE; + len = min( SizeofResource(hModule, hRsrc), datasize ); + memcpy( data, LockResource( hMem ), len ); + FreeResource( hMem ); + } + FreeLibrary( hModule ); + } + + switch (magic) + { + case IMAGE_OS2_SIGNATURE: + /* We have a 16bit resource. */ + if (TRACE_ON(ver)) + print_vffi_debug( (VS_FIXEDFILEINFO *)VersionInfo16_Value( (VS_VERSION_INFO_STRUCT16 *)data )); + SetLastError(0); + return TRUE; + + case IMAGE_NT_SIGNATURE: + /* We have a 32bit resource. + * + * XP/W2K/W2K3 uses a buffer which is 2 times the actual needed space + 4 bytes "FE2X" + * This extra buffer is used for Unicode to ANSI conversions in A-Calls + */ + len = vvis->wLength + sizeof(signature); + if (datasize >= len) memcpy( (char*)data + vvis->wLength, signature, sizeof(signature) ); + if (TRACE_ON(ver)) + print_vffi_debug( (VS_FIXEDFILEINFO *)VersionInfo32_Value( vvis )); + SetLastError(0); + return TRUE; + + default: + SetLastError( lzfd == HFILE_ERROR ? ofs.nErrCode : ERROR_RESOURCE_DATA_NOT_FOUND ); + return FALSE; + } +} + +/*********************************************************************** + * GetFileVersionInfoExA [VERSION.@] + */ +BOOL WINAPI GetFileVersionInfoExA( DWORD flags, LPCSTR filename, DWORD handle, DWORD datasize, LPVOID data ) +{ + UNICODE_STRING filenameW; + BOOL retval; + + TRACE("(0x%x,%s,%d,size=%d,data=%p)\n", + flags, debugstr_a(filename), handle, datasize, data ); + + if(filename) + RtlCreateUnicodeStringFromAsciiz(&filenameW, filename); + else + filenameW.Buffer = NULL; + + retval = GetFileVersionInfoExW(flags, filenameW.Buffer, handle, datasize, data); + + RtlFreeUnicodeString(&filenameW); + + return retval; +} + +/*********************************************************************** + * GetFileVersionInfoW [VERSION.@] + */ +BOOL WINAPI GetFileVersionInfoW( LPCWSTR filename, DWORD handle, DWORD datasize, LPVOID data ) +{ + return GetFileVersionInfoExW(FILE_VER_GET_LOCALISED, filename, handle, datasize, data); +} + +/*********************************************************************** + * GetFileVersionInfoA [VERSION.@] + */ +BOOL WINAPI GetFileVersionInfoA( LPCSTR filename, DWORD handle, DWORD datasize, LPVOID data ) +{ + return GetFileVersionInfoExA(FILE_VER_GET_LOCALISED, filename, handle, datasize, data); +} + +/*********************************************************************** + * VersionInfo16_FindChild [internal] + */ +static const VS_VERSION_INFO_STRUCT16 *VersionInfo16_FindChild( const VS_VERSION_INFO_STRUCT16 *info, + LPCSTR szKey, UINT cbKey ) +{ + const VS_VERSION_INFO_STRUCT16 *child = VersionInfo16_Children( info ); + + while ((char *)child < (char *)info + info->wLength ) + { + if (!_strnicmp( child->szKey, szKey, cbKey ) && !child->szKey[cbKey]) + return child; + + if (!(child->wLength)) return NULL; + child = VersionInfo16_Next( child ); + } + + return NULL; +} + +/*********************************************************************** + * VersionInfo32_FindChild [internal] + */ +static const VS_VERSION_INFO_STRUCT32 *VersionInfo32_FindChild( const VS_VERSION_INFO_STRUCT32 *info, + LPCWSTR szKey, UINT cbKey ) +{ + const VS_VERSION_INFO_STRUCT32 *child = VersionInfo32_Children( info ); + + while ((char *)child < (char *)info + info->wLength ) + { + if (!_wcsnicmp( child->szKey, szKey, cbKey ) && !child->szKey[cbKey]) + return child; + + if (!(child->wLength)) return NULL; + child = VersionInfo32_Next( child ); + } + + return NULL; +} + +/*********************************************************************** + * VersionInfo16_QueryValue [internal] + * + * Gets a value from a 16-bit NE resource + */ +static BOOL VersionInfo16_QueryValue( const VS_VERSION_INFO_STRUCT16 *info, LPCSTR lpSubBlock, + LPVOID *lplpBuffer, UINT *puLen ) +{ + while ( *lpSubBlock ) + { + /* Find next path component */ + LPCSTR lpNextSlash; + for ( lpNextSlash = lpSubBlock; *lpNextSlash; lpNextSlash++ ) + if ( *lpNextSlash == '\\' ) + break; + + /* Skip empty components */ + if ( lpNextSlash == lpSubBlock ) + { + lpSubBlock++; + continue; + } + + /* We have a non-empty component: search info for key */ + info = VersionInfo16_FindChild( info, lpSubBlock, lpNextSlash-lpSubBlock ); + if ( !info ) + { + if (puLen) *puLen = 0 ; + SetLastError( ERROR_RESOURCE_TYPE_NOT_FOUND ); + return FALSE; + } + + /* Skip path component */ + lpSubBlock = lpNextSlash; + } + + /* Return value */ + *lplpBuffer = VersionInfo16_Value( info ); + if (puLen) + *puLen = info->wValueLength; + + return TRUE; +} + +/*********************************************************************** + * VersionInfo32_QueryValue [internal] + * + * Gets a value from a 32-bit PE resource + */ +static BOOL VersionInfo32_QueryValue( const VS_VERSION_INFO_STRUCT32 *info, LPCWSTR lpSubBlock, + LPVOID *lplpBuffer, UINT *puLen, BOOL *pbText ) +{ + TRACE("lpSubBlock : (%s)\n", debugstr_w(lpSubBlock)); + + while ( *lpSubBlock ) + { + /* Find next path component */ + LPCWSTR lpNextSlash; + for ( lpNextSlash = lpSubBlock; *lpNextSlash; lpNextSlash++ ) + if ( *lpNextSlash == '\\' ) + break; + + /* Skip empty components */ + if ( lpNextSlash == lpSubBlock ) + { + lpSubBlock++; + continue; + } + + /* We have a non-empty component: search info for key */ + info = VersionInfo32_FindChild( info, lpSubBlock, lpNextSlash-lpSubBlock ); + if ( !info ) + { + if (puLen) *puLen = 0 ; + SetLastError( ERROR_RESOURCE_TYPE_NOT_FOUND ); + return FALSE; + } + + /* Skip path component */ + lpSubBlock = lpNextSlash; + } + + /* Return value */ + *lplpBuffer = VersionInfo32_Value( info ); + if (puLen) + *puLen = info->wValueLength; + if (pbText) + *pbText = info->wType; + + return TRUE; +} + +/*********************************************************************** + * VerQueryValueA [VERSION.@] + */ +BOOL WINAPI VerQueryValueA( LPCVOID pBlock, LPCSTR lpSubBlock, + LPVOID *lplpBuffer, PUINT puLen ) +{ + static const char rootA[] = "\\"; + const VS_VERSION_INFO_STRUCT16 *info = pBlock; + + TRACE("(%p,%s,%p,%p)\n", + pBlock, debugstr_a(lpSubBlock), lplpBuffer, puLen ); + + if (!pBlock) + return FALSE; + + if (lpSubBlock == NULL || lpSubBlock[0] == '\0') + lpSubBlock = rootA; + + if ( !VersionInfoIs16( info ) ) + { + BOOL ret, isText; + INT len; + LPWSTR lpSubBlockW; + UINT value_len; + + len = MultiByteToWideChar(CP_ACP, 0, lpSubBlock, -1, NULL, 0); + lpSubBlockW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)); + + if (!lpSubBlockW) + return FALSE; + + MultiByteToWideChar(CP_ACP, 0, lpSubBlock, -1, lpSubBlockW, len); + + ret = VersionInfo32_QueryValue(pBlock, lpSubBlockW, lplpBuffer, &value_len, &isText); + if (puLen) *puLen = value_len; + + HeapFree(GetProcessHeap(), 0, lpSubBlockW); + + if (ret && isText) + { + /* Set lpBuffer so it points to the 'empty' area where we store + * the converted strings + */ + LPSTR lpBufferA = (LPSTR)pBlock + info->wLength + 4; + DWORD pos = (LPCSTR)*lplpBuffer - (LPCSTR)pBlock; + len = WideCharToMultiByte(CP_ACP, 0, *lplpBuffer, value_len, + lpBufferA + pos, info->wLength - pos, NULL, NULL); + *lplpBuffer = lpBufferA + pos; + if (puLen) *puLen = len; + } + return ret; + } + + return VersionInfo16_QueryValue(info, lpSubBlock, lplpBuffer, puLen); +} + +/*********************************************************************** + * VerQueryValueW [VERSION.@] + */ +BOOL WINAPI VerQueryValueW( LPCVOID pBlock, LPCWSTR lpSubBlock, + LPVOID *lplpBuffer, PUINT puLen ) +{ + static const WCHAR rootW[] = { '\\', 0 }; + static const WCHAR varfileinfoW[] = { '\\','V','a','r','F','i','l','e','I','n','f','o', + '\\','T','r','a','n','s','l','a','t','i','o','n', 0 }; + + const VS_VERSION_INFO_STRUCT32 *info = pBlock; + + TRACE("(%p,%s,%p,%p)\n", + pBlock, debugstr_w(lpSubBlock), lplpBuffer, puLen ); + + if (!pBlock) + return FALSE; + + if (!lpSubBlock || !lpSubBlock[0]) + lpSubBlock = rootW; + + if ( VersionInfoIs16( info ) ) + { + BOOL ret; + int len; + LPSTR lpSubBlockA; + + len = WideCharToMultiByte(CP_ACP, 0, lpSubBlock, -1, NULL, 0, NULL, NULL); + lpSubBlockA = HeapAlloc(GetProcessHeap(), 0, len * sizeof(char)); + + if (!lpSubBlockA) + return FALSE; + + WideCharToMultiByte(CP_ACP, 0, lpSubBlock, -1, lpSubBlockA, len, NULL, NULL); + + ret = VersionInfo16_QueryValue(pBlock, lpSubBlockA, lplpBuffer, puLen); + + HeapFree(GetProcessHeap(), 0, lpSubBlockA); + + if (ret && wcsicmp( lpSubBlock, rootW ) && wcsicmp( lpSubBlock, varfileinfoW )) + { + /* Set lpBuffer so it points to the 'empty' area where we store + * the converted strings + */ + LPWSTR lpBufferW = (LPWSTR)((LPSTR)pBlock + info->wLength); + DWORD pos = (LPCSTR)*lplpBuffer - (LPCSTR)pBlock; + DWORD max = (info->wLength - sizeof(VS_FIXEDFILEINFO)) * 4 - info->wLength; + + len = MultiByteToWideChar(CP_ACP, 0, *lplpBuffer, -1, + lpBufferW + pos, max/sizeof(WCHAR) - pos ); + *lplpBuffer = lpBufferW + pos; + if (puLen) *puLen = len; + } + return ret; + } + + return VersionInfo32_QueryValue(info, lpSubBlock, lplpBuffer, puLen, NULL); +} + + +/****************************************************************************** + * testFileExistenceA + * + * Tests whether a given path/file combination exists. If the file does + * not exist, the return value is zero. If it does exist, the return + * value is non-zero. + * + * Revision history + * 30-May-1997 Dave Cuthbert (dacut@ece.cmu.edu) + * Original implementation + * + */ +static int testFileExistenceA( char const * path, char const * file, BOOL excl ) +{ + char filename[1024]; + int filenamelen; + OFSTRUCT fileinfo; + + fileinfo.cBytes = sizeof(OFSTRUCT); + + if (path) + { + strcpy(filename, path); + filenamelen = strlen(filename); + + /* Add a trailing \ if necessary */ + if(filenamelen) + { + if(filename[filenamelen - 1] != '\\') + strcat(filename, "\\"); + } + else /* specify the current directory */ + strcpy(filename, ".\\"); + } + else + filename[0] = 0; + + /* Create the full pathname */ + strcat(filename, file); + + return (OpenFile(filename, &fileinfo, + OF_EXIST | (excl ? OF_SHARE_EXCLUSIVE : 0)) != HFILE_ERROR); +} + +/****************************************************************************** + * testFileExistenceW + */ +static int testFileExistenceW( const WCHAR *path, const WCHAR *file, BOOL excl ) +{ + char *filename; + DWORD pathlen, filelen; + int ret; + OFSTRUCT fileinfo; + + fileinfo.cBytes = sizeof(OFSTRUCT); + + pathlen = WideCharToMultiByte( CP_ACP, 0, path, -1, NULL, 0, NULL, NULL ); + filelen = WideCharToMultiByte( CP_ACP, 0, file, -1, NULL, 0, NULL, NULL ); + filename = HeapAlloc( GetProcessHeap(), 0, pathlen+filelen+2 ); + + WideCharToMultiByte( CP_ACP, 0, path, -1, filename, pathlen, NULL, NULL ); + /* Add a trailing \ if necessary */ + if (pathlen > 1) + { + if (filename[pathlen-2] != '\\') strcpy( &filename[pathlen-1], "\\" ); + } + else /* specify the current directory */ + strcpy(filename, ".\\"); + + WideCharToMultiByte( CP_ACP, 0, file, -1, filename+strlen(filename), filelen, NULL, NULL ); + + ret = (OpenFile(filename, &fileinfo, + OF_EXIST | (excl ? OF_SHARE_EXCLUSIVE : 0)) != HFILE_ERROR); + HeapFree( GetProcessHeap(), 0, filename ); + return ret; +} + +/***************************************************************************** + * VerFindFileA [VERSION.@] + * + * Determines where to install a file based on whether it locates another + * version of the file in the system. The values VerFindFile returns are + * used in a subsequent call to the VerInstallFile function. + * + * Revision history: + * 30-May-1997 Dave Cuthbert (dacut@ece.cmu.edu) + * Reimplementation of VerFindFile from original stub. + */ +DWORD WINAPI VerFindFileA( + DWORD flags, + LPCSTR lpszFilename, + LPCSTR lpszWinDir, + LPCSTR lpszAppDir, + LPSTR lpszCurDir, + PUINT lpuCurDirLen, + LPSTR lpszDestDir, + PUINT lpuDestDirLen ) +{ + DWORD retval = 0; + const char *curDir; + const char *destDir; + unsigned int curDirSizeReq; + unsigned int destDirSizeReq; + char winDir[MAX_PATH], systemDir[MAX_PATH]; + + /* Print out debugging information */ + TRACE("flags = %x filename=%s windir=%s appdir=%s curdirlen=%p(%u) destdirlen=%p(%u)\n", + flags, debugstr_a(lpszFilename), debugstr_a(lpszWinDir), debugstr_a(lpszAppDir), + lpuCurDirLen, lpuCurDirLen ? *lpuCurDirLen : 0, + lpuDestDirLen, lpuDestDirLen ? *lpuDestDirLen : 0 ); + + /* Figure out where the file should go; shared files default to the + system directory */ + + GetSystemDirectoryA(systemDir, sizeof(systemDir)); + curDir = ""; + + if(flags & VFFF_ISSHAREDFILE) + { + destDir = systemDir; + /* Were we given a filename? If so, try to find the file. */ + if(lpszFilename) + { + if(testFileExistenceA(destDir, lpszFilename, FALSE)) curDir = destDir; + else if(lpszAppDir && testFileExistenceA(lpszAppDir, lpszFilename, FALSE)) + curDir = lpszAppDir; + + if(!testFileExistenceA(systemDir, lpszFilename, FALSE)) + retval |= VFF_CURNEDEST; + } + } + else /* not a shared file */ + { + destDir = lpszAppDir ? lpszAppDir : ""; + if(lpszFilename) + { + GetWindowsDirectoryA( winDir, MAX_PATH ); + if(testFileExistenceA(destDir, lpszFilename, FALSE)) curDir = destDir; + else if(testFileExistenceA(winDir, lpszFilename, FALSE)) + curDir = winDir; + else if(testFileExistenceA(systemDir, lpszFilename, FALSE)) + curDir = systemDir; + + if (lpszAppDir && lpszAppDir[0]) + { + if(!testFileExistenceA(lpszAppDir, lpszFilename, FALSE)) + retval |= VFF_CURNEDEST; + } + else if(testFileExistenceA(NULL, lpszFilename, FALSE)) + retval |= VFF_CURNEDEST; + } + } + + /* Check to see if the file exists and is in use by another application */ + if (lpszFilename && testFileExistenceA(curDir, lpszFilename, FALSE)) { + if (lpszFilename && !testFileExistenceA(curDir, lpszFilename, TRUE)) + retval |= VFF_FILEINUSE; + } + + curDirSizeReq = strlen(curDir) + 1; + destDirSizeReq = strlen(destDir) + 1; + + /* Make sure that the pointers to the size of the buffers are + valid; if not, do NOTHING with that buffer. If that pointer + is valid, then make sure that the buffer pointer is valid, too! */ + + if(lpuDestDirLen && lpszDestDir) + { + if (*lpuDestDirLen < destDirSizeReq) retval |= VFF_BUFFTOOSMALL; + lstrcpynA(lpszDestDir, destDir, *lpuDestDirLen); + *lpuDestDirLen = destDirSizeReq; + } + if(lpuCurDirLen && lpszCurDir) + { + if(*lpuCurDirLen < curDirSizeReq) retval |= VFF_BUFFTOOSMALL; + lstrcpynA(lpszCurDir, curDir, *lpuCurDirLen); + *lpuCurDirLen = curDirSizeReq; + } + + TRACE("ret = %u (%s%s%s) curdir=%s destdir=%s\n", retval, + (retval & VFF_CURNEDEST) ? "VFF_CURNEDEST " : "", + (retval & VFF_FILEINUSE) ? "VFF_FILEINUSE " : "", + (retval & VFF_BUFFTOOSMALL) ? "VFF_BUFFTOOSMALL " : "", + debugstr_a(lpszCurDir), debugstr_a(lpszDestDir)); + + return retval; +} + +/***************************************************************************** + * VerFindFileW [VERSION.@] + */ +DWORD WINAPI VerFindFileW( DWORD flags,LPCWSTR lpszFilename,LPCWSTR lpszWinDir, + LPCWSTR lpszAppDir, LPWSTR lpszCurDir,PUINT lpuCurDirLen, + LPWSTR lpszDestDir,PUINT lpuDestDirLen ) +{ + static const WCHAR emptyW; + DWORD retval = 0; + const WCHAR *curDir; + const WCHAR *destDir; + unsigned int curDirSizeReq; + unsigned int destDirSizeReq; + WCHAR winDir[MAX_PATH], systemDir[MAX_PATH]; + + /* Print out debugging information */ + TRACE("flags = %x filename=%s windir=%s appdir=%s curdirlen=%p(%u) destdirlen=%p(%u)\n", + flags, debugstr_w(lpszFilename), debugstr_w(lpszWinDir), debugstr_w(lpszAppDir), + lpuCurDirLen, lpuCurDirLen ? *lpuCurDirLen : 0, + lpuDestDirLen, lpuDestDirLen ? *lpuDestDirLen : 0 ); + + /* Figure out where the file should go; shared files default to the + system directory */ + + GetSystemDirectoryW(systemDir, ARRAY_SIZE(systemDir)); + curDir = &emptyW; + + if(flags & VFFF_ISSHAREDFILE) + { + destDir = systemDir; + /* Were we given a filename? If so, try to find the file. */ + if(lpszFilename) + { + if(testFileExistenceW(destDir, lpszFilename, FALSE)) curDir = destDir; + else if(lpszAppDir && testFileExistenceW(lpszAppDir, lpszFilename, FALSE)) + { + curDir = lpszAppDir; + retval |= VFF_CURNEDEST; + } + } + } + else /* not a shared file */ + { + destDir = lpszAppDir ? lpszAppDir : &emptyW; + if(lpszFilename) + { + GetWindowsDirectoryW( winDir, MAX_PATH ); + if(testFileExistenceW(destDir, lpszFilename, FALSE)) curDir = destDir; + else if(testFileExistenceW(winDir, lpszFilename, FALSE)) + { + curDir = winDir; + retval |= VFF_CURNEDEST; + } + else if(testFileExistenceW(systemDir, lpszFilename, FALSE)) + { + curDir = systemDir; + retval |= VFF_CURNEDEST; + } + } + } + + if (lpszFilename && !testFileExistenceW(curDir, lpszFilename, TRUE)) + retval |= VFF_FILEINUSE; + + curDirSizeReq = lstrlenW(curDir) + 1; + destDirSizeReq = lstrlenW(destDir) + 1; + + /* Make sure that the pointers to the size of the buffers are + valid; if not, do NOTHING with that buffer. If that pointer + is valid, then make sure that the buffer pointer is valid, too! */ + + if(lpuDestDirLen && lpszDestDir) + { + if (*lpuDestDirLen < destDirSizeReq) retval |= VFF_BUFFTOOSMALL; + lstrcpynW(lpszDestDir, destDir, *lpuDestDirLen); + *lpuDestDirLen = destDirSizeReq; + } + if(lpuCurDirLen && lpszCurDir) + { + if(*lpuCurDirLen < curDirSizeReq) retval |= VFF_BUFFTOOSMALL; + lstrcpynW(lpszCurDir, curDir, *lpuCurDirLen); + *lpuCurDirLen = curDirSizeReq; + } + + TRACE("ret = %u (%s%s%s) curdir=%s destdir=%s\n", retval, + (retval & VFF_CURNEDEST) ? "VFF_CURNEDEST " : "", + (retval & VFF_FILEINUSE) ? "VFF_FILEINUSE " : "", + (retval & VFF_BUFFTOOSMALL) ? "VFF_BUFFTOOSMALL " : "", + debugstr_w(lpszCurDir), debugstr_w(lpszDestDir)); + return retval; +} + +static LPBYTE +_fetch_versioninfo(LPSTR fn,VS_FIXEDFILEINFO **vffi) { + DWORD alloclen; + LPBYTE buf; + DWORD ret; + + alloclen = 1000; + buf=HeapAlloc(GetProcessHeap(), 0, alloclen); + if(buf == NULL) { + WARN("Memory exhausted while fetching version info!\n"); + return NULL; + } + while (1) { + ret = GetFileVersionInfoA(fn,0,alloclen,buf); + if (!ret) { + HeapFree(GetProcessHeap(), 0, buf); + return NULL; + } + if (alloclen<*(WORD*)buf) { + alloclen = *(WORD*)buf; + HeapFree(GetProcessHeap(), 0, buf); + buf = HeapAlloc(GetProcessHeap(), 0, alloclen); + if(buf == NULL) { + WARN("Memory exhausted while fetching version info!\n"); + return NULL; + } + } else { + *vffi = (VS_FIXEDFILEINFO*)(buf+0x14); + if ((*vffi)->dwSignature == 0x004f0049) /* hack to detect unicode */ + *vffi = (VS_FIXEDFILEINFO*)(buf+0x28); + if ((*vffi)->dwSignature != VS_FFI_SIGNATURE) + WARN("Bad VS_FIXEDFILEINFO signature 0x%08x\n",(*vffi)->dwSignature); + return buf; + } + } +} + +static DWORD +_error2vif(DWORD error) { + switch (error) { + case ERROR_ACCESS_DENIED: + return VIF_ACCESSVIOLATION; + case ERROR_SHARING_VIOLATION: + return VIF_SHARINGVIOLATION; + default: + return 0; + } +} + + +/****************************************************************************** + * VerInstallFileA [VERSION.@] + */ +DWORD WINAPI VerInstallFileA( + DWORD flags,LPCSTR srcfilename,LPCSTR destfilename,LPCSTR srcdir, + LPCSTR destdir,LPCSTR curdir,LPSTR tmpfile,PUINT tmpfilelen ) +{ + LPCSTR pdest; + char destfn[260],tmpfn[260],srcfn[260]; + HFILE hfsrc,hfdst; + DWORD attr,xret,tmplast; + LONG ret; + LPBYTE buf1,buf2; + OFSTRUCT ofs; + + TRACE("(%x,%s,%s,%s,%s,%s,%p,%d)\n", + flags,debugstr_a(srcfilename),debugstr_a(destfilename), + debugstr_a(srcdir),debugstr_a(destdir),debugstr_a(curdir), + tmpfile,*tmpfilelen); + xret = 0; + if (!srcdir || !srcfilename) return VIF_CANNOTREADSRC; + sprintf(srcfn,"%s\\%s",srcdir,srcfilename); + if (!destdir || !*destdir) pdest = srcdir; + else pdest = destdir; + sprintf(destfn,"%s\\%s",pdest,destfilename); + hfsrc=LZOpenFileA(srcfn,&ofs,OF_READ); + if (hfsrc < 0) + return VIF_CANNOTREADSRC; + sprintf(tmpfn,"%s\\%s",pdest,destfilename); + tmplast=strlen(pdest)+1; + attr = GetFileAttributesA(tmpfn); + if (attr != INVALID_FILE_ATTRIBUTES) { + if (attr & FILE_ATTRIBUTE_READONLY) { + LZClose(hfsrc); + return VIF_WRITEPROT; + } + /* FIXME: check if file currently in use and return VIF_FILEINUSE */ + } + attr = INVALID_FILE_ATTRIBUTES; + if (flags & VIFF_FORCEINSTALL) { + if (tmpfile[0]) { + sprintf(tmpfn,"%s\\%s",pdest,tmpfile); + tmplast = strlen(pdest)+1; + attr = GetFileAttributesA(tmpfn); + /* if it exists, it has been copied by the call before. + * we jump over the copy part... + */ + } + } + if (attr == INVALID_FILE_ATTRIBUTES) { + char *s; + + GetTempFileNameA(pdest,"ver",0,tmpfn); /* should not fail ... */ + s=strrchr(tmpfn,'\\'); + if (s) + tmplast = s-tmpfn; + else + tmplast = 0; + hfdst = OpenFile(tmpfn,&ofs,OF_CREATE); + if (hfdst == HFILE_ERROR) { + LZClose(hfsrc); + return VIF_CANNOTCREATE; /* | translated dos error */ + } + ret = LZCopy(hfsrc,hfdst); + _lclose(hfdst); + if (ret < 0) { + /* translate LZ errors into VIF_xxx */ + switch (ret) { + case LZERROR_BADINHANDLE: + case LZERROR_READ: + case LZERROR_BADVALUE: + case LZERROR_UNKNOWNALG: + xret = VIF_CANNOTREADSRC; + break; + case LZERROR_BADOUTHANDLE: + case LZERROR_WRITE: + xret = VIF_OUTOFSPACE; + break; + case LZERROR_GLOBALLOC: + case LZERROR_GLOBLOCK: + xret = VIF_OUTOFMEMORY; + break; + default: /* unknown error, should not happen */ + FIXME("Unknown LZCopy error %d, ignoring.\n", ret); + xret = 0; + break; + } + if (xret) { + LZClose(hfsrc); + return xret; + } + } + } + if (!(flags & VIFF_FORCEINSTALL)) { + VS_FIXEDFILEINFO *destvffi,*tmpvffi; + buf1 = _fetch_versioninfo(destfn,&destvffi); + if (buf1) { + buf2 = _fetch_versioninfo(tmpfn,&tmpvffi); + if (buf2) { + char *tbuf1,*tbuf2; + static const CHAR trans_array[] = "\\VarFileInfo\\Translation"; + UINT len1,len2; + + len1=len2=40; + + /* compare file versions */ + if ((destvffi->dwFileVersionMS > tmpvffi->dwFileVersionMS)|| + ((destvffi->dwFileVersionMS==tmpvffi->dwFileVersionMS)&& + (destvffi->dwFileVersionLS > tmpvffi->dwFileVersionLS) + ) + ) + xret |= VIF_MISMATCH|VIF_SRCOLD; + /* compare filetypes and filesubtypes */ + if ((destvffi->dwFileType!=tmpvffi->dwFileType) || + (destvffi->dwFileSubtype!=tmpvffi->dwFileSubtype) + ) + xret |= VIF_MISMATCH|VIF_DIFFTYPE; + if (VerQueryValueA(buf1,trans_array,(LPVOID*)&tbuf1,&len1) && + VerQueryValueA(buf2,trans_array,(LPVOID*)&tbuf2,&len2) + ) { + /* Do something with tbuf1 and tbuf2 + * generates DIFFLANG|MISMATCH + */ + } + HeapFree(GetProcessHeap(), 0, buf2); + } else + xret=VIF_MISMATCH|VIF_SRCOLD; + HeapFree(GetProcessHeap(), 0, buf1); + } + } + if (xret) { + if (*tmpfilelen