summaryrefslogtreecommitdiff
path: root/src/inc
diff options
context:
space:
mode:
authorRama Krishnan Raghupathy <ramarag@microsoft.com>2016-02-18 18:21:18 -0800
committerRama Krishnan Raghupathy <ramarag@microsoft.com>2016-02-19 18:09:11 -0800
commitf98fb85e72d0f24c58d9e54b8b3bff2c67f985fb (patch)
treea532e7803fbbe420807eb7d9390108554b02c46d /src/inc
parent01ffa08a2e4748e9826956ea961eacb227b6ee87 (diff)
downloadcoreclr-f98fb85e72d0f24c58d9e54b8b3bff2c67f985fb.tar.gz
coreclr-f98fb85e72d0f24c58d9e54b8b3bff2c67f985fb.tar.bz2
coreclr-f98fb85e72d0f24c58d9e54b8b3bff2c67f985fb.zip
This Change Adds initial Support for LongFiles in the VM,
They are: 1. Wrappers for OS APIs which take or return PATHS 2. Fixing the usage of following Api's: GetEnvironmentVariableW SearchPathW GetShortPathNameW GetLongPathNameW GetModuleFileName Work remaining: Remove fixed size buffers in the VM
Diffstat (limited to 'src/inc')
-rw-r--r--src/inc/corpriv.h14
-rw-r--r--src/inc/longfilepathwrappers.h277
-rw-r--r--src/inc/sstring.h5
-rw-r--r--src/inc/sstring.inl24
-rw-r--r--src/inc/utilcode.h11
-rw-r--r--src/inc/winwrap.h663
6 files changed, 658 insertions, 336 deletions
diff --git a/src/inc/corpriv.h b/src/inc/corpriv.h
index f90d2ab470..1a8f671701 100644
--- a/src/inc/corpriv.h
+++ b/src/inc/corpriv.h
@@ -641,10 +641,16 @@ STDAPI LoadLibraryShimInternal(
LPVOID pvReserved,
HMODULE *phModDll);
+STDAPI GetCORSystemDirectoryInternaL(
+ SString& pBuffer
+ );
+
+//LONGPATH:TODO: Remove this once Desktop usage has been removed
STDAPI GetCORSystemDirectoryInternal(
- __out_ecount_part_opt(cchBuffer, *pdwLength) LPWSTR pBuffer,
- DWORD cchBuffer,
- __out_opt DWORD* pdwLength);
+ __out_ecount_part_opt(cchBuffer, *pdwLength) LPWSTR pBuffer,
+ DWORD cchBuffer,
+ __out_opt DWORD* pdwLength
+ );
STDAPI GetCORVersionInternal(
__out_ecount_z_opt(cchBuffer) LPWSTR pBuffer,
@@ -656,7 +662,7 @@ STDAPI GetRequestedRuntimeInfoInternal(LPCWSTR pExe,
LPCWSTR pConfigurationFile,
DWORD startupFlags,
DWORD runtimeInfoFlags,
- __out_ecount_opt(dwDirectory) LPWSTR pDirectory,
+ __out_ecount_opt(dwDirectory) LPWSTR pDirectory,
DWORD dwDirectory,
__out_opt DWORD *pdwDirectoryLength,
__out_ecount_opt(cchBuffer) LPWSTR pVersion,
diff --git a/src/inc/longfilepathwrappers.h b/src/inc/longfilepathwrappers.h
new file mode 100644
index 0000000000..b3fc6ad1db
--- /dev/null
+++ b/src/inc/longfilepathwrappers.h
@@ -0,0 +1,277 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+#ifndef _WIN_PATH_APIS_WRAPPER_
+#define _WIN_PATH_APIS_WRAPPER_
+class SString;
+
+HMODULE
+LoadLibraryExWrapper(
+ _In_ LPCWSTR lpLibFileName,
+ _Reserved_ HANDLE hFile = NULL,
+ _In_ DWORD dwFlags = 0
+ );
+
+HANDLE
+CreateFileWrapper(
+ _In_ LPCWSTR lpFileName,
+ _In_ DWORD dwDesiredAccess,
+ _In_ DWORD dwShareMode,
+ _In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes,
+ _In_ DWORD dwCreationDisposition,
+ _In_ DWORD dwFlagsAndAttributes,
+ _In_opt_ HANDLE hTemplateFile
+ );
+
+BOOL
+SetFileAttributesWrapper(
+ _In_ LPCWSTR lpFileName,
+ _In_ DWORD dwFileAttributes
+ );
+
+DWORD
+GetFileAttributesWrapper(
+ _In_ LPCWSTR lpFileName
+ );
+
+BOOL
+GetFileAttributesExWrapper(
+ _In_ LPCWSTR lpFileName,
+ _In_ GET_FILEEX_INFO_LEVELS fInfoLevelId,
+ _Out_writes_bytes_(sizeof(WIN32_FILE_ATTRIBUTE_DATA)) LPVOID lpFileInformation
+ );
+BOOL
+DeleteFileWrapper(
+ _In_ LPCWSTR lpFileName
+ );
+
+HANDLE
+FindFirstFileExWrapper(
+ _In_ LPCWSTR lpFileName,
+ _In_ FINDEX_INFO_LEVELS fInfoLevelId,
+ _Out_writes_bytes_(sizeof(WIN32_FIND_DATAW)) LPVOID lpFindFileData,
+ _In_ FINDEX_SEARCH_OPS fSearchOp,
+ _Reserved_ LPVOID lpSearchFilter,
+ _In_ DWORD dwAdditionalFlags
+ );
+
+BOOL
+CopyFileWrapper(
+ _In_ LPCWSTR lpExistingFileName,
+ _In_ LPCWSTR lpNewFileName,
+ _In_ BOOL bFailIfExists
+ );
+
+#ifndef FEATURE_PAL
+BOOL
+CopyFileExWrapper(
+ _In_ LPCWSTR lpExistingFileName,
+ _In_ LPCWSTR lpNewFileName,
+ _In_opt_ LPPROGRESS_ROUTINE lpProgressRoutine,
+ _In_opt_ LPVOID lpData,
+ _When_(pbCancel != NULL, _Pre_satisfies_(*pbCancel == FALSE))
+ _Inout_opt_ LPBOOL pbCancel,
+ _In_ DWORD dwCopyFlags
+ );
+#endif //FEATURE_PAL
+
+BOOL
+MoveFileWrapper(
+ _In_ LPCWSTR lpExistingFileName,
+ _In_ LPCWSTR lpNewFileName
+ );
+
+BOOL
+MoveFileExWrapper(
+ _In_ LPCWSTR lpExistingFileName,
+ _In_opt_ LPCWSTR lpNewFileName,
+ _In_ DWORD dwFlags
+ );
+
+BOOL
+CreateDirectoryWrapper(
+ _In_ LPCWSTR lpPathName,
+ _In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes
+ );
+
+BOOL
+RemoveDirectoryWrapper(
+ _In_ LPCWSTR lpPathName
+ );
+
+BOOL
+CreateHardLinkWrapper(
+ _In_ LPCWSTR lpFileName,
+ _In_ LPCWSTR lpExistingFileName,
+ _Reserved_ LPSECURITY_ATTRIBUTES lpSecurityAttributes
+ );
+
+DWORD
+SearchPathWrapper(
+ _In_opt_ LPCWSTR lpPath,
+ _In_ LPCWSTR lpFileName,
+ _In_opt_ LPCWSTR lpExtension,
+ _In_ BOOL getPath,
+ SString& lpBuffer,
+ _Out_opt_ LPWSTR * lpFilePart
+ );
+
+
+DWORD
+GetShortPathNameWrapper(
+ _In_ LPCWSTR lpszLongPath,
+ SString& lpszShortPath
+ );
+
+DWORD
+GetLongPathNameWrapper(
+ _In_ LPCWSTR lpszShortPath,
+ SString& lpszLongPath
+ );
+
+UINT GetTempFileNameWrapper(
+ _In_ LPCTSTR lpPathName,
+ _In_ LPCTSTR lpPrefixString,
+ _In_ UINT uUnique,
+ SString& lpTempFileName
+ );
+
+DWORD GetTempPathWrapper(
+ SString& lpBuffer
+ );
+
+DWORD GetCurrentDirectoryWrapper(
+ SString& lpBuffer
+ );
+
+DWORD
+GetModuleFileNameWrapper(
+ _In_opt_ HMODULE hModule,
+ SString& buffer
+ );
+
+DWORD GetEnvironmentVariableWrapper(
+ _In_opt_ LPCTSTR lpName,
+ _Out_opt_ SString& lpBuffer
+ );
+
+BOOL PAL_GetPALDirectoryWrapper(SString& pbuffer);
+
+#ifndef FEATURE_CORECLR
+//Temporarily providing direct OS Calls Till All of the Desktop CLR start using the above format
+inline DWORD
+SearchPathWrapper(
+ _In_opt_ LPCWSTR lpPath,
+ _In_ LPCWSTR lpFileName,
+ _In_opt_ LPCWSTR lpExtension,
+ _In_ BOOL getPath,
+ _Out_ LPWSTR lpBuffer,
+ _Out_opt_ LPWSTR * lpFilePart
+ )
+{
+ return SearchPathW(
+ lpPath,
+ lpFileName,
+ lpExtension,
+ getPath,
+ lpBuffer,
+ lpFilePart
+ );
+}
+
+
+inline DWORD
+GetShortPathNameWrapper(
+ _In_ LPCWSTR lpszLongPath,
+ _Out_ LPWSTR lpszShortPath,
+ _In_ DWORD cchBuffer
+ )
+{
+ return GetShortPathNameW(
+ lpszLongPath,
+ lpszShortPath,
+ cchBuffer
+ );
+}
+
+inline DWORD
+GetLongPathNameWrapper(
+ _In_ LPCWSTR lpszShortPath,
+ _Out_ LPWSTR lpszLongPath,
+ _In_ DWORD cchBuffer
+ )
+{
+ return GetLongPathNameW(
+ lpszShortPath,
+ lpszLongPath,
+ cchBuffer
+ );
+}
+
+inline UINT GetTempFileNameWrapper(
+ _In_ LPCWSTR lpPathName,
+ _In_ LPCWSTR lpPrefixString,
+ _In_ UINT uUnique,
+ _Out_ LPWSTR lpTempFileName
+ )
+{
+ return GetTempFileNameW(
+ lpPathName,
+ lpPrefixString,
+ uUnique,
+ lpTempFileName
+ );
+}
+
+inline DWORD GetTempPathWrapper(
+ _In_ DWORD nBufferLength,
+ _Out_ LPWSTR lpBuffer
+ )
+{
+ return GetTempPathW(
+ nBufferLength,
+ lpBuffer
+ );
+}
+
+inline DWORD GetCurrentDirectoryWrapper(
+ _In_ DWORD nBufferLength,
+ _Out_ LPWSTR lpBuffer
+ )
+{
+ return GetCurrentDirectoryW(
+ nBufferLength,
+ lpBuffer
+ );
+}
+
+inline DWORD
+GetModuleFileNameWrapper(
+ _In_opt_ HMODULE hModule,
+ _Out_ LPWSTR lpFilename,
+ _In_ DWORD nSize
+ )
+{
+ return GetModuleFileNameW(
+ hModule,
+ lpFilename,
+ nSize
+ );
+}
+
+inline DWORD GetEnvironmentVariableWrapper(
+ _In_opt_ LPCWSTR lpName,
+ _Out_opt_ LPWSTR lpBuffer,
+ _In_ DWORD nSize
+ )
+{
+ return GetEnvironmentVariableW(
+ lpName,
+ lpBuffer,
+ nSize
+ );
+}
+#endif //FEATURE_CORECLR
+#endif //_WIN_PATH_APIS_WRAPPER_
+
diff --git a/src/inc/sstring.h b/src/inc/sstring.h
index 3c5107a06c..bfbaa81429 100644
--- a/src/inc/sstring.h
+++ b/src/inc/sstring.h
@@ -625,6 +625,9 @@ private:
UTF8 *OpenUTF8Buffer(COUNT_T maxSingleCharCount);
ANSI *OpenANSIBuffer(COUNT_T maxSingleCharCount);
+ //Returns the unicode string, the caller is reponsible for lifetime of the string
+ WCHAR *GetCopyOfUnicodeString();
+
// Get the max size that can be passed to OpenUnicodeBuffer without causing allocations.
COUNT_T GetUnicodeAllocation();
@@ -1009,9 +1012,11 @@ typedef InlineSString<32> SmallStackSString;
#ifdef _DEBUG
// This is a smaller version for debug builds to exercise the buffer allocation path
typedef InlineSString<32> PathString;
+typedef InlineSString<2 * 32> LongPathString;
#else
// Set it to the current MAX_PATH
typedef InlineSString<260> PathString;
+typedef InlineSString<2 * 260> LongPathString;
#endif
// ================================================================================
diff --git a/src/inc/sstring.inl b/src/inc/sstring.inl
index b9c689548b..6b587e17ba 100644
--- a/src/inc/sstring.inl
+++ b/src/inc/sstring.inl
@@ -1257,7 +1257,7 @@ inline WCHAR *SString::GetRawUnicode() const
LIMITED_METHOD_CONTRACT;
SUPPORTS_DAC_HOST_ONLY;
- return (WCHAR *) m_buffer;
+ return (WCHAR *)m_buffer;
}
// Private helper:
@@ -1690,6 +1690,28 @@ inline WCHAR *SString::OpenUnicodeBuffer(COUNT_T countChars)
}
//----------------------------------------------------------------------------
+// Return a copy of the underlying buffer, the caller is responsible for managing
+// the returned memory
+//----------------------------------------------------------------------------
+inline WCHAR *SString::GetCopyOfUnicodeString()
+{
+ SS_CONTRACT(WCHAR*)
+ {
+ GC_NOTRIGGER;
+ PRECONDITION(CheckPointer(this));
+ SS_POSTCONDITION(CheckPointer(buffer));
+ THROWS;
+ }
+ SS_CONTRACT_END;
+ NewArrayHolder<WCHAR> buffer = NULL;
+
+ buffer = new WCHAR[GetCount() +1];
+ wcscpy_s(buffer, GetCount() + 1, GetUnicode());
+
+ SS_RETURN buffer.Extract();
+}
+
+//----------------------------------------------------------------------------
// Return a writeable buffer that can store 'countChars'+1 ansi characters.
// Call CloseBuffer when done.
//----------------------------------------------------------------------------
diff --git a/src/inc/utilcode.h b/src/inc/utilcode.h
index 78dc438ddb..a9cb0077fc 100644
--- a/src/inc/utilcode.h
+++ b/src/inc/utilcode.h
@@ -843,7 +843,8 @@ private:
HRESULT GetLibrary(LocaleID langId, HRESOURCEDLL* phInst);
#ifndef DACCESS_COMPILE
HRESULT LoadLibraryHelper(HRESOURCEDLL *pHInst,
- __out_ecount(rcPathSize) WCHAR *rcPath, const DWORD rcPathSize);
+ SString& rcPath);
+ HRESULT LoadLibraryThrows(HRESOURCEDLL * pHInst);
HRESULT LoadLibrary(HRESOURCEDLL * pHInst);
HRESULT LoadResourceFile(HRESOURCEDLL * pHInst, LPCWSTR lpFileName);
#endif
@@ -4467,7 +4468,7 @@ BOOL GetRegistryLongValue(HKEY hKeyParent, // Parent key.
long *pValue, // Put value here, if found.
BOOL fReadNonVirtualizedKey); // Whether to read 64-bit hive on WOW64
-HRESULT GetCurrentModuleFileName(__out_ecount(*pcchBuffer) LPWSTR pBuffer, __inout DWORD *pcchBuffer);
+HRESULT GetCurrentModuleFileName(SString& pBuffer);
//*****************************************************************************
// Retrieve information regarding what registered default debugger
@@ -5309,7 +5310,7 @@ BOOL IsIPInModule(HMODULE_TGT hModule, PCODE ip);
struct CoreClrCallbacks
{
typedef IExecutionEngine* (__stdcall * pfnIEE_t)();
- typedef HRESULT (__stdcall * pfnGetCORSystemDirectory_t)(LPWSTR pbuffer, DWORD cchBuffer, DWORD* pdwlength);
+ typedef HRESULT (__stdcall * pfnGetCORSystemDirectory_t)(SString& pbuffer);
typedef void* (__stdcall * pfnGetCLRFunction_t)(LPCSTR functionName);
HINSTANCE m_hmodCoreCLR;
@@ -5543,8 +5544,8 @@ inline T* InterlockedCompareExchangeT(
// Returns the directory for HMODULE. So, if HMODULE was for "C:\Dir1\Dir2\Filename.DLL",
// then this would return "C:\Dir1\Dir2\" (note the trailing backslash).
-HRESULT GetHModuleDirectory(HMODULE hMod, __out_z __out_ecount(cchPath) LPWSTR wszPath, size_t cchPath);
-SString & GetHModuleDirectory(HMODULE hMod, SString &ssDir);
+HRESULT GetHModuleDirectory(HMODULE hMod, SString& wszPath);
+HRESULT CopySystemDirectory(const SString& pPathString, SString& pbuffer);
HMODULE LoadLocalizedResourceDLLForSDK(_In_z_ LPCWSTR wzResourceDllName, _In_opt_z_ LPCWSTR modulePath=NULL, bool trySelf=true);
// This is a slight variation that can be used for anything else
diff --git a/src/inc/winwrap.h b/src/inc/winwrap.h
index 6896accab9..89a3220c67 100644
--- a/src/inc/winwrap.h
+++ b/src/inc/winwrap.h
@@ -6,9 +6,9 @@
//
// This file contains wrapper functions for Win32 API's that take strings.
//
-// The Common Language Runtime internally uses UNICODE as the internal state
-// and string format. This file will undef the mapping macros so that one
-// cannot mistakingly call a method that isn't going to work. Instead, you
+// The Common Language Runtime internally uses UNICODE as the internal state
+// and string format. This file will undef the mapping macros so that one
+// cannot mistakingly call a method that isn't going to work. Instead, you
// have to call the correct wrapper API.
//
//*****************************************************************************
@@ -16,7 +16,6 @@
#ifndef __WIN_WRAP_H__
#define __WIN_WRAP_H__
-
//********** Macros. **********************************************************
#if !defined(WIN32_LEAN_AND_MEAN)
#define WIN32_LEAN_AND_MEAN
@@ -48,6 +47,7 @@
#include <specstrings.h>
#include "registrywrapper.h"
+#include "longfilepathwrappers.h"
#ifdef _PREFAST_
//
@@ -75,288 +75,288 @@
#undef GetBinaryType
#undef GetShortPathName
#undef GetLongPathName
-#undef GetEnvironmentStrings
-#undef FreeEnvironmentStrings
-#undef FormatMessage
-#undef CreateMailslot
-#undef EncryptFile
-#undef DecryptFile
-#undef OpenRaw
-#undef QueryRecoveryAgents
-#undef lstrcmp
-#undef lstrcmpi
-#undef lstrcpyn
-#undef lstrcpy
-#undef lstrcat
-#undef lstrlen
-#undef CreateMutex
-#undef OpenMutex
-#undef CreateEvent
-#undef OpenEvent
-#undef CreateSemaphore
-#undef OpenSemaphore
-#undef CreateWaitableTimer
-#undef OpenWaitableTimer
-#undef CreateFileMapping
-#undef OpenFileMapping
-#undef GetLogicalDriveStrings
-#undef LoadLibrary
-#undef LoadLibraryEx
-#undef GetModuleFileName
-#undef GetModuleHandle
+#undef GetEnvironmentStrings
+#undef FreeEnvironmentStrings
+#undef FormatMessage
+#undef CreateMailslot
+#undef EncryptFile
+#undef DecryptFile
+#undef OpenRaw
+#undef QueryRecoveryAgents
+#undef lstrcmp
+#undef lstrcmpi
+#undef lstrcpyn
+#undef lstrcpy
+#undef lstrcat
+#undef lstrlen
+#undef CreateMutex
+#undef OpenMutex
+#undef CreateEvent
+#undef OpenEvent
+#undef CreateSemaphore
+#undef OpenSemaphore
+#undef CreateWaitableTimer
+#undef OpenWaitableTimer
+#undef CreateFileMapping
+#undef OpenFileMapping
+#undef GetLogicalDriveStrings
+#undef LoadLibrary
+#undef LoadLibraryEx
+#undef GetModuleFileName
+#undef GetModuleHandle
#undef GetModuleHandleEx
-#undef CreateProcess
-#undef FatalAppExit
-#undef GetStartupInfo
-#undef GetCommandLine
-#undef GetEnvironmentVariable
-#undef SetEnvironmentVariable
-#undef ExpandEnvironmentStrings
-#undef OutputDebugString
-#undef FindResource
-#undef FindResourceEx
-#undef EnumResourceTypes
-#undef EnumResourceNames
-#undef EnumResourceLanguages
-#undef BeginUpdateResource
-#undef UpdateResource
-#undef EndUpdateResource
-#undef GlobalAddAtom
-#undef GlobalFindAtom
-#undef GlobalGetAtomName
-#undef AddAtom
-#undef FindAtom
-#undef GetAtomName
-#undef GetProfileInt
-#undef GetProfileString
-#undef WriteProfileString
-#undef GetProfileSection
-#undef WriteProfileSection
-#undef GetPrivateProfileInt
-#undef GetPrivateProfileString
-#undef WritePrivateProfileString
-#undef GetPrivateProfileSection
-#undef WritePrivateProfileSection
-#undef GetPrivateProfileSectionNames
-#undef GetPrivateProfileStruct
-#undef WritePrivateProfileStruct
-#undef GetDriveType
-#undef GetSystemDirectory
-#undef GetTempPath
-#undef GetTempFileName
-#undef GetWindowsDirectory
-#undef SetCurrentDirectory
-#undef GetCurrentDirectory
-#undef GetDiskFreeSpace
-#undef GetDiskFreeSpaceEx
-#undef CreateDirectory
-#undef CreateDirectoryEx
-#undef RemoveDirectory
-#undef GetFullPathName
-#undef DefineDosDevice
-#undef QueryDosDevice
-#undef CreateFile
-#undef SetFileAttributes
-#undef GetFileAttributes
+#undef CreateProcess
+#undef FatalAppExit
+#undef GetStartupInfo
+#undef GetCommandLine
+#undef GetEnvironmentVariable
+#undef SetEnvironmentVariable
+#undef ExpandEnvironmentStrings
+#undef OutputDebugString
+#undef FindResource
+#undef FindResourceEx
+#undef EnumResourceTypes
+#undef EnumResourceNames
+#undef EnumResourceLanguages
+#undef BeginUpdateResource
+#undef UpdateResource
+#undef EndUpdateResource
+#undef GlobalAddAtom
+#undef GlobalFindAtom
+#undef GlobalGetAtomName
+#undef AddAtom
+#undef FindAtom
+#undef GetAtomName
+#undef GetProfileInt
+#undef GetProfileString
+#undef WriteProfileString
+#undef GetProfileSection
+#undef WriteProfileSection
+#undef GetPrivateProfileInt
+#undef GetPrivateProfileString
+#undef WritePrivateProfileString
+#undef GetPrivateProfileSection
+#undef WritePrivateProfileSection
+#undef GetPrivateProfileSectionNames
+#undef GetPrivateProfileStruct
+#undef WritePrivateProfileStruct
+#undef GetDriveType
+#undef GetSystemDirectory
+#undef GetTempPath
+#undef GetTempFileName
+#undef GetWindowsDirectory
+#undef SetCurrentDirectory
+#undef GetCurrentDirectory
+#undef GetDiskFreeSpace
+#undef GetDiskFreeSpaceEx
+#undef CreateDirectory
+#undef CreateDirectoryEx
+#undef RemoveDirectory
+#undef GetFullPathName
+#undef DefineDosDevice
+#undef QueryDosDevice
+#undef CreateFile
+#undef SetFileAttributes
+#undef GetFileAttributes
#undef GetFileAttributesEx
-#undef GetCompressedFileSize
-#undef DeleteFile
-#undef FindFirstFileEx
-#undef FindFirstFile
-#undef FindNextFile
-#undef SearchPath
-#undef CopyFile
-#undef CopyFileEx
-#undef MoveFile
-#undef MoveFileEx
-#undef MoveFileWithProgress
-#undef CreateSymbolicLink
-#undef QuerySymbolicLink
-#undef CreateHardLink
-#undef CreateNamedPipe
-#undef GetNamedPipeHandleState
-#undef CallNamedPipe
-#undef WaitNamedPipe
-#undef SetVolumeLabel
-#undef GetVolumeInformation
-#undef ClearEventLog
-#undef BackupEventLog
-#undef OpenEventLog
-#undef RegisterEventSource
-#undef OpenBackupEventLog
-#undef ReadEventLog
-#undef ReportEvent
-#undef AccessCheckAndAuditAlarm
-#undef AccessCheckByTypeAndAuditAlarm
-#undef AccessCheckByTypeResultListAndAuditAlarm
-#undef ObjectOpenAuditAlarm
-#undef ObjectPrivilegeAuditAlarm
-#undef ObjectCloseAuditAlarm
-#undef ObjectDeleteAuditAlarm
-#undef PrivilegedServiceAuditAlarm
-#undef SetFileSecurity
-#undef GetFileSecurity
-#undef FindFirstChangeNotification
-#undef IsBadStringPtr
+#undef GetCompressedFileSize
+#undef DeleteFile
+#undef FindFirstFileEx
+#undef FindFirstFile
+#undef FindNextFile
+#undef SearchPath
+#undef CopyFile
+#undef CopyFileEx
+#undef MoveFile
+#undef MoveFileEx
+#undef MoveFileWithProgress
+#undef CreateSymbolicLink
+#undef QuerySymbolicLink
+#undef CreateHardLink
+#undef CreateNamedPipe
+#undef GetNamedPipeHandleState
+#undef CallNamedPipe
+#undef WaitNamedPipe
+#undef SetVolumeLabel
+#undef GetVolumeInformation
+#undef ClearEventLog
+#undef BackupEventLog
+#undef OpenEventLog
+#undef RegisterEventSource
+#undef OpenBackupEventLog
+#undef ReadEventLog
+#undef ReportEvent
+#undef AccessCheckAndAuditAlarm
+#undef AccessCheckByTypeAndAuditAlarm
+#undef AccessCheckByTypeResultListAndAuditAlarm
+#undef ObjectOpenAuditAlarm
+#undef ObjectPrivilegeAuditAlarm
+#undef ObjectCloseAuditAlarm
+#undef ObjectDeleteAuditAlarm
+#undef PrivilegedServiceAuditAlarm
+#undef SetFileSecurity
+#undef GetFileSecurity
+#undef FindFirstChangeNotification
+#undef IsBadStringPtr
#undef LookupAccountSid
-#undef LookupAccountName
-#undef LookupPrivilegeValue
-#undef LookupPrivilegeName
-#undef LookupPrivilegeDisplayName
-#undef BuildCommDCB
-#undef BuildCommDCBAndTimeouts
-#undef CommConfigDialog
-#undef GetDefaultCommConfig
-#undef SetDefaultCommConfig
-#undef GetComputerName
-#undef SetComputerName
-#undef GetUserName
-#undef LogonUser
-#undef CreateProcessAsUser
-#undef GetCurrentHwProfile
-#undef GetVersionEx
-#undef CreateJobObject
-#undef OpenJobObject
-
+#undef LookupAccountName
+#undef LookupPrivilegeValue
+#undef LookupPrivilegeName
+#undef LookupPrivilegeDisplayName
+#undef BuildCommDCB
+#undef BuildCommDCBAndTimeouts
+#undef CommConfigDialog
+#undef GetDefaultCommConfig
+#undef SetDefaultCommConfig
+#undef GetComputerName
+#undef SetComputerName
+#undef GetUserName
+#undef LogonUser
+#undef CreateProcessAsUser
+#undef GetCurrentHwProfile
+#undef GetVersionEx
+#undef CreateJobObject
+#undef OpenJobObject
+#undef SetDllDirectory
// winuser.h
-#undef MAKEINTRESOURCE
-#undef wvsprintf
-#undef wsprintf
-#undef LoadKeyboardLayout
-#undef GetKeyboardLayoutName
-#undef CreateDesktop
-#undef OpenDesktop
-#undef EnumDesktops
-#undef CreateWindowStation
-#undef OpenWindowStation
+#undef MAKEINTRESOURCE
+#undef wvsprintf
+#undef wsprintf
+#undef LoadKeyboardLayout
+#undef GetKeyboardLayoutName
+#undef CreateDesktop
+#undef OpenDesktop
+#undef EnumDesktops
+#undef CreateWindowStation
+#undef OpenWindowStation
#undef EnumWindowStations
#undef GetUserObjectInformation
#undef SetUserObjectInformation
#undef RegisterWindowMessage
#undef SIZEZOOMSHOW
-#undef WS_TILEDWINDOW
-#undef GetMessage
-#undef DispatchMessage
-#undef PeekMessage
+#undef WS_TILEDWINDOW
+#undef GetMessage
+#undef DispatchMessage
+#undef PeekMessage
#undef SendMessage
-#undef SendMessageTimeout
-#undef SendNotifyMessage
-#undef SendMessageCallback
-#undef BroadcastSystemMessage
-#undef RegisterDeviceNotification
-#undef PostMessage
-#undef PostThreadMessage
-#undef PostAppMessage
-#undef DefWindowProc
-#undef CallWindowProc
-#undef RegisterClass
-#undef UnregisterClass
-#undef GetClassInfo
-#undef RegisterClassEx
-#undef GetClassInfoEx
-#undef CreateWindowEx
-#undef CreateWindow
-#undef CreateDialogParam
-#undef CreateDialogIndirectParam
-#undef CreateDialog
-#undef CreateDialogIndirect
-#undef DialogBoxParam
-#undef DialogBoxIndirectParam
-#undef DialogBox
-#undef DialogBoxIndirect
-#undef SetDlgItemText
-#undef GetDlgItemText
-#undef SendDlgItemMessage
-#undef DefDlgProc
-#undef CallMsgFilter
-#undef RegisterClipboardFormat
-#undef GetClipboardFormatName
-#undef CharToOem
-#undef OemToChar
-#undef CharToOemBuff
-#undef OemToCharBuff
-#undef CharUpper
-#undef CharUpperBuff
-#undef CharLower
-#undef CharLowerBuff
-#undef CharNext
-#undef IsCharAlpha
-#undef IsCharAlphaNumeric
-#undef IsCharUpper
-#undef IsCharLower
-#undef GetKeyNameText
-#undef VkKeyScan
-#undef VkKeyScanEx
-#undef MapVirtualKey
-#undef MapVirtualKeyEx
-#undef LoadAccelerators
-#undef CreateAcceleratorTable
-#undef CopyAcceleratorTable
-#undef TranslateAccelerator
-#undef LoadMenu
-#undef LoadMenuIndirect
-#undef ChangeMenu
-#undef GetMenuString
-#undef InsertMenu
-#undef AppendMenu
-#undef ModifyMenu
-#undef InsertMenuItem
-#undef GetMenuItemInfo
-#undef SetMenuItemInfo
-#undef DrawText
-#undef DrawTextEx
-#undef GrayString
-#undef DrawState
-#undef TabbedTextOut
-#undef GetTabbedTextExtent
-#undef SetProp
-#undef GetProp
-#undef RemoveProp
-#undef EnumPropsEx
-#undef EnumProps
-#undef SetWindowText
-#undef GetWindowText
-#undef GetWindowTextLength
-#undef MessageBox
-#undef MessageBoxEx
-#undef MessageBoxIndirect
-#undef COLOR_3DSHADOW
-#undef GetWindowLong
-#undef SetWindowLong
-#undef GetClassLong
-#undef SetClassLong
-#undef FindWindow
-#undef FindWindowEx
-#undef GetClassName
-#undef SetWindowsHook
-#undef SetWindowsHook
-#undef SetWindowsHookEx
-#undef MFT_OWNERDRAW
-#undef LoadBitmap
-#undef LoadCursor
-#undef LoadCursorFromFile
-#undef LoadIcon
-#undef LoadImage
-#undef LoadString
-#undef IsDialogMessage
-#undef DlgDirList
-#undef DlgDirSelectEx
-#undef DlgDirListComboBox
-#undef DlgDirSelectComboBoxEx
-#undef DefFrameProc
-#undef DefMDIChildProc
-#undef CreateMDIWindow
-#undef WinHelp
-#undef ChangeDisplaySettings
-#undef ChangeDisplaySettingsEx
-#undef EnumDisplaySettings
-#undef EnumDisplayDevices
-#undef SystemParametersInfo
-#undef GetMonitorInfo
-#undef GetWindowModuleFileName
-#undef RealGetWindowClass
+#undef SendMessageTimeout
+#undef SendNotifyMessage
+#undef SendMessageCallback
+#undef BroadcastSystemMessage
+#undef RegisterDeviceNotification
+#undef PostMessage
+#undef PostThreadMessage
+#undef PostAppMessage
+#undef DefWindowProc
+#undef CallWindowProc
+#undef RegisterClass
+#undef UnregisterClass
+#undef GetClassInfo
+#undef RegisterClassEx
+#undef GetClassInfoEx
+#undef CreateWindowEx
+#undef CreateWindow
+#undef CreateDialogParam
+#undef CreateDialogIndirectParam
+#undef CreateDialog
+#undef CreateDialogIndirect
+#undef DialogBoxParam
+#undef DialogBoxIndirectParam
+#undef DialogBox
+#undef DialogBoxIndirect
+#undef SetDlgItemText
+#undef GetDlgItemText
+#undef SendDlgItemMessage
+#undef DefDlgProc
+#undef CallMsgFilter
+#undef RegisterClipboardFormat
+#undef GetClipboardFormatName
+#undef CharToOem
+#undef OemToChar
+#undef CharToOemBuff
+#undef OemToCharBuff
+#undef CharUpper
+#undef CharUpperBuff
+#undef CharLower
+#undef CharLowerBuff
+#undef CharNext
+#undef IsCharAlpha
+#undef IsCharAlphaNumeric
+#undef IsCharUpper
+#undef IsCharLower
+#undef GetKeyNameText
+#undef VkKeyScan
+#undef VkKeyScanEx
+#undef MapVirtualKey
+#undef MapVirtualKeyEx
+#undef LoadAccelerators
+#undef CreateAcceleratorTable
+#undef CopyAcceleratorTable
+#undef TranslateAccelerator
+#undef LoadMenu
+#undef LoadMenuIndirect
+#undef ChangeMenu
+#undef GetMenuString
+#undef InsertMenu
+#undef AppendMenu
+#undef ModifyMenu
+#undef InsertMenuItem
+#undef GetMenuItemInfo
+#undef SetMenuItemInfo
+#undef DrawText
+#undef DrawTextEx
+#undef GrayString
+#undef DrawState
+#undef TabbedTextOut
+#undef GetTabbedTextExtent
+#undef SetProp
+#undef GetProp
+#undef RemoveProp
+#undef EnumPropsEx
+#undef EnumProps
+#undef SetWindowText
+#undef GetWindowText
+#undef GetWindowTextLength
+#undef MessageBox
+#undef MessageBoxEx
+#undef MessageBoxIndirect
+#undef COLOR_3DSHADOW
+#undef GetWindowLong
+#undef SetWindowLong
+#undef GetClassLong
+#undef SetClassLong
+#undef FindWindow
+#undef FindWindowEx
+#undef GetClassName
+#undef SetWindowsHook
+#undef SetWindowsHook
+#undef SetWindowsHookEx
+#undef MFT_OWNERDRAW
+#undef LoadBitmap
+#undef LoadCursor
+#undef LoadCursorFromFile
+#undef LoadIcon
+#undef LoadImage
+#undef LoadString
+#undef IsDialogMessage
+#undef DlgDirList
+#undef DlgDirSelectEx
+#undef DlgDirListComboBox
+#undef DlgDirSelectComboBoxEx
+#undef DefFrameProc
+#undef DefMDIChildProc
+#undef CreateMDIWindow
+#undef WinHelp
+#undef ChangeDisplaySettings
+#undef ChangeDisplaySettingsEx
+#undef EnumDisplaySettings
+#undef EnumDisplayDevices
+#undef SystemParametersInfo
+#undef GetMonitorInfo
+#undef GetWindowModuleFileName
+#undef RealGetWindowClass
#undef GetAltTabInfo
#undef GetCalendarInfo
#undef GetDateFormat
@@ -369,10 +369,8 @@
// Win32 Fusion API's
#undef QueryActCtxW
-
#endif // !defined(__TODO_PORT_TO_WRAPPERS__)
-
//
// NT supports the wide entry points. So we redefine the wrappers right back
// to the *W entry points as macros. This way no client code needs a wrapper on NT.
@@ -385,9 +383,6 @@
#define WszCryptVerifySignature CryptVerifySignatureW
// winbase.h
-#define WszGetBinaryType GetBinaryTypeW
-#define WszGetShortPathName GetShortPathNameW
-#define WszGetLongPathName GetLongPathNameW
#define WszGetEnvironmentStrings GetEnvironmentStringsW
#define WszFreeEnvironmentStrings FreeEnvironmentStringsW
#ifndef USE_FORMATMESSAGE_WRAPPER
@@ -396,8 +391,6 @@
#define WszFormatMessage CCompRC::FormatMessage
#endif
#define WszCreateMailslot CreateMailslotW
-#define WszEncryptFile EncryptFileW
-#define WszDecryptFile DecryptFileW
#define WszOpenRaw OpenRawW
#define WszQueryRecoveryAgents QueryRecoveryAgentsW
#define Wszlstrcmp lstrcmpW
@@ -413,16 +406,11 @@
#define WszCreateFileMapping CreateFileMappingW
#define WszOpenFileMapping OpenFileMappingW
#define WszGetLogicalDriveStrings GetLogicalDriveStringsW
-#define WszLoadLibrary(_filename) LoadLibraryExW((_filename), NULL, 0)
-#define WszLoadLibraryEx LoadLibraryExW
-#define WszSetDllDirectory SetDllDirectoryW
-#define WszGetModuleFileName GetModuleFileNameW
#define WszGetModuleHandle GetModuleHandleW
#define WszGetModuleHandleEx GetModuleHandleExW
#define WszFatalAppExit FatalAppExitW
#define WszGetStartupInfo GetStartupInfoW
#define WszGetCommandLine GetCommandLineW
-#define WszGetEnvironmentVariable GetEnvironmentVariableW
#define WszSetEnvironmentVariable SetEnvironmentVariableW
#define WszExpandEnvironmentStrings ExpandEnvironmentStringsW
#define WszOutputDebugString OutputDebugStringW
@@ -455,37 +443,12 @@
#define WszWritePrivateProfileStruct WritePrivateProfileStructW
#define WszGetDriveType GetDriveTypeW
#define WszGetSystemDirectory GetSystemDirectoryW
-#define WszGetTempPath GetTempPathW
-#define WszGetTempFileName GetTempFileNameW
#define WszGetWindowsDirectory GetWindowsDirectoryW
-#define WszSetCurrentDirectory SetCurrentDirectoryW
-#define WszGetCurrentDirectory GetCurrentDirectoryW
#define WszGetDiskFreeSpace GetDiskFreeSpaceW
#define WszGetDiskFreeSpaceEx GetDiskFreeSpaceExW
-#define WszCreateDirectory CreateDirectoryW
-#define WszCreateDirectoryEx CreateDirectoryExW
-#define WszRemoveDirectory RemoveDirectoryW
-#define WszGetFullPathName GetFullPathNameW
#define WszDefineDosDevice DefineDosDeviceW
#define WszQueryDosDevice QueryDosDeviceW
-#define WszCreateFile CreateFileW
-#define WszSetFileAttributes SetFileAttributesW
-#define WszGetFileAttributes GetFileAttributesW
-#define WszGetFileAttributesEx GetFileAttributesExW
-#define WszGetCompressedFileSize GetCompressedFileSizeW
-#define WszDeleteFile DeleteFileW
-#define WszFindFirstFileEx FindFirstFileExW
-#define WszFindFirstFile FindFirstFileW
-#define WszFindNextFile FindNextFileW
-#define WszSearchPath SearchPathW
-#define WszCopyFile CopyFileW
-#define WszCopyFileEx CopyFileExW
-#define WszMoveFile MoveFileW
-#define WszMoveFileEx MoveFileExW
-#define WszMoveFileWithProgress MoveFileWithProgressW
-#define WszCreateSymbolicLink CreateSymbolicLinkW
#define WszQuerySymbolicLink QuerySymbolicLinkW
-#define WszCreateHardLink CreateHardLinkW
#define WszCreateNamedPipe CreateNamedPipeW
#define WszGetNamedPipeHandleState GetNamedPipeHandleStateW
#define WszCallNamedPipe CallNamedPipeW
@@ -507,9 +470,6 @@
#define WszObjectCloseAuditAlarm ObjectCloseAuditAlarmW
#define WszObjectDeleteAuditAlarm ObjectDeleteAuditAlarmW
#define WszPrivilegedServiceAuditAlarm PrivilegedServiceAuditAlarmW
-#define WszSetFileSecurity SetFileSecurityW
-#define WszGetFileSecurity GetFileSecurityW
-#define WszFindFirstChangeNotification FindFirstChangeNotificationW
#define WszIsBadStringPtr __DO_NOT_USE__WszIsBadStringPtr__
#if !defined(FEATURE_CORESYSTEM) || defined(CROSSGEN_COMPILE)
#define WszLookupAccountSid LookupAccountSidW
@@ -678,7 +638,6 @@
#define WszRegQueryValueExTrue RegQueryValueExW
#define WszRegQueryStringValueEx RegQueryValueExW
-
#ifndef FEATURE_CORECLR
#define WszRegDeleteKey RegDeleteKeyW
#define WszRegCreateKeyEx ClrRegCreateKeyEx
@@ -723,13 +682,66 @@
#define _T(str) W(str)
#endif
-
// on win98 and higher
#define Wszlstrlen lstrlenW
#define Wszlstrcpy lstrcpyW
#define Wszlstrcat lstrcatW
-
+//File and Directory Functions which need special handling for LongFile Names
+//Note only the functions which are currently used are defined
+#define WszLoadLibrary LoadLibraryExWrapper
+#define WszLoadLibraryEx LoadLibraryExWrapper
+#define WszCreateFile CreateFileWrapper
+#define WszSetFileAttributes SetFileAttributesWrapper
+#define WszGetFileAttributes GetFileAttributesWrapper
+#define WszGetFileAttributesEx GetFileAttributesExWrapper
+#define WszDeleteFile DeleteFileWrapper
+#define WszFindFirstFileEx FindFirstFileExWrapper
+#define WszFindNextFile FindNextFileW
+#define WszCopyFile CopyFileWrapper
+#define WszCopyFileEx CopyFileExWrapper
+#define WszMoveFile MoveFileWrapper
+#define WszMoveFileEx MoveFileExWrapper
+#define WszCreateDirectory CreateDirectoryWrapper
+#define WszRemoveDirectory RemoveDirectoryWrapper
+#define WszCreateHardLink CreateHardLinkWrapper
+
+//Can not use extended syntax
+#define WszGetFullPathName GetFullPathNameW
+
+//Long Files will not work on these till redstone
+#define WszGetCurrentDirectory GetCurrentDirectoryWrapper
+#define WszGetTempFileName GetTempFileNameWrapper
+#define WszGetTempPath GetTempPathWrapper
+
+//APIS which have a buffer as an out parameter
+#define WszGetEnvironmentVariable GetEnvironmentVariableWrapper
+#define WszSearchPath SearchPathWrapper
+#define WszGetShortPathName GetShortPathNameWrapper
+#define WszGetLongPathName GetLongPathNameWrapper
+#define WszGetModuleFileName GetModuleFileNameWrapper
+
+//NOTE: IF the following API's are enabled ensure that they can work with LongFile Names
+//See the usage and implementation of above API's
+//
+//#define WszGetCompressedFileSize GetCompressedFileSizeW
+//#define WszMoveFileWithProgress MoveFileWithProgressW
+//#define WszEncryptFile EncryptFileW
+//#define WszDecryptFile DecryptFileW
+//#define WszSetFileSecurity SetFileSecurityW
+//#define WszGetFileSecurity GetFileSecurityW
+//#define WszFindFirstChangeNotification FindFirstChangeNotificationW
+//#define WszSetDllDirectory SetDllDirectoryW
+//#define WszSetCurrentDirectory SetCurrentDirectoryW
+//#define WszCreateDirectoryEx CreateDirectoryExW
+//#define WszCreateSymbolicLink CreateSymbolicLinkW
+//#define WszGetBinaryType GetBinaryTypeWrapper //Coresys does not seem to have this API
+
+#if FEATURE_PAL
+#define WszFindFirstFile FindFirstFileW
+#else
+#define WszFindFirstFile(_lpFileName_, _lpFindData_) FindFirstFileExWrapper(_lpFileName_, FindExInfoStandard, _lpFindData_, FindExSearchNameMatch, NULL, 0)
+#endif //FEATURE_PAL
//*****************************************************************************
// Prototypes for API's.
//*****************************************************************************
@@ -746,7 +758,7 @@ inline DWORD GetMaxDBCSCharByteSize()
EnsureCharSetInfoInitialized();
_ASSERTE(g_dwMaxDBCSCharByteSize != 0);
- return (g_dwMaxDBCSCharByteSize);
+ return (g_dwMaxDBCSCharByteSize);
#else // FEATURE_PAL
return 3;
#endif // FEATURE_PAL
@@ -758,7 +770,7 @@ BOOL RunningInteractive();
#define RunningInteractive() FALSE
#endif // !FEATURE_PAL
-// Determines if the process is running as Local System or as a service. Note that this function uses the
+// Determines if the process is running as Local System or as a service. Note that this function uses the
// process' identity and not the thread's (if the thread is impersonating).
//
// If the function succeeds, it returns ERROR_SUCCESS, else it returns the error code returned by GetLastError()
@@ -768,7 +780,6 @@ DWORD RunningAsLocalSystemOrService(OUT BOOL& fIsLocalSystemOrService);
#define Wsz_mbstowcs(szOut, szIn, iSize) WszMultiByteToWideChar(CP_ACP, 0, szIn, -1, szOut, iSize)
#endif
-
#ifndef Wsz_wcstombs
#define Wsz_wcstombs(szOut, szIn, iSize) WszWideCharToMultiByte(CP_ACP, 0, szIn, -1, szOut, iSize, 0, 0)
#endif
@@ -815,11 +826,11 @@ DWORD WszGetProcessHandleCount();
#define InterlockedOr _InterlockedOr
//
-// There is no _InterlockedCompareExchangePointer intrinsic in VC++ for x86.
+// There is no _InterlockedCompareExchangePointer intrinsic in VC++ for x86.
// winbase.h #defines InterlockedCompareExchangePointer as __InlineInterlockedCompareExchangePointer,
// which calls the Win32 InterlockedCompareExchange, not the intrinsic _InterlockedCompareExchange.
// We want the intrinsic, so we #undef the Windows version of this API, and define our own.
-//
+//
#ifdef InterlockedCompareExchangePointer
#undef InterlockedCompareExchangePointer
#endif
@@ -850,7 +861,7 @@ InterlockedCompareExchangePointer (
#if defined(_X86_) & !defined(InterlockedIncrement64)
-// Interlockedxxx64 that do not have intrinsics are only supported on Windows Server 2003
+// Interlockedxxx64 that do not have intrinsics are only supported on Windows Server 2003
// or higher for X86 so define our own portable implementation
#undef InterlockedIncrement64
@@ -918,7 +929,7 @@ __forceinline LONGLONG __InterlockedExchangeAdd64(LONGLONG volatile * Addend, LO
//
// RtlVerifyVersionInfo() type mask bits
-// Making our copy of type mask bits as the original
+// Making our copy of type mask bits as the original
// macro name are redefined in public\internal\NDP\inc\product_version.h
//
//
@@ -970,11 +981,11 @@ inline int LateboundMessageBoxW(HWND hWnd,
#if defined(FEATURE_CORESYSTEM) && !defined(CROSSGEN_COMPILE)
// Some CoreSystem OSs will support MessageBoxW via an extension library. The following technique is what
// was recommeded by Philippe Joubert from the CoreSystem team.
- HMODULE hGuiExtModule = LoadLibraryExW(W("ext-ms-win-ntuser-gui-l1"), NULL, 0);
+ HMODULE hGuiExtModule = WszLoadLibrary(W("ext-ms-win-ntuser-gui-l1"), NULL, 0);
#else
// Outside of CoreSystem, MessageBoxW lives in User32
HMODULE hGuiExtModule = WszLoadLibrary(W("user32"));
-#endif
+#endif
if (hGuiExtModule)
{
int result = IDCANCEL;