kernel32: Move virtual memory functions to kernelbase.
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
0b5c0bc769
commit
61516e2223
|
@ -519,7 +519,7 @@
|
||||||
@ stdcall -import FlushFileBuffers(long)
|
@ stdcall -import FlushFileBuffers(long)
|
||||||
@ stdcall -import FlushInstructionCache(long long long)
|
@ stdcall -import FlushInstructionCache(long long long)
|
||||||
@ stdcall FlushProcessWriteBuffers()
|
@ stdcall FlushProcessWriteBuffers()
|
||||||
@ stdcall FlushViewOfFile(ptr long)
|
@ stdcall -import FlushViewOfFile(ptr long)
|
||||||
@ stdcall FoldStringA(long str long ptr long)
|
@ stdcall FoldStringA(long str long ptr long)
|
||||||
@ stdcall FoldStringW(long wstr long ptr long)
|
@ stdcall FoldStringW(long wstr long ptr long)
|
||||||
@ stdcall FormatMessageA(long ptr long long ptr long ptr)
|
@ stdcall FormatMessageA(long ptr long long ptr long ptr)
|
||||||
|
@ -889,7 +889,7 @@
|
||||||
@ stdcall GetVolumePathNamesForVolumeNameW(wstr ptr long ptr)
|
@ stdcall GetVolumePathNamesForVolumeNameW(wstr ptr long ptr)
|
||||||
@ stdcall -import GetWindowsDirectoryA(ptr long)
|
@ stdcall -import GetWindowsDirectoryA(ptr long)
|
||||||
@ stdcall -import GetWindowsDirectoryW(ptr long)
|
@ stdcall -import GetWindowsDirectoryW(ptr long)
|
||||||
@ stdcall GetWriteWatch(long ptr long ptr ptr ptr)
|
@ stdcall -import GetWriteWatch(long ptr long ptr ptr ptr)
|
||||||
# @ stub GetXStateFeaturesMask
|
# @ stub GetXStateFeaturesMask
|
||||||
@ stdcall GlobalAddAtomA(str)
|
@ stdcall GlobalAddAtomA(str)
|
||||||
@ stdcall GlobalAddAtomW(wstr)
|
@ stdcall GlobalAddAtomW(wstr)
|
||||||
|
@ -1078,9 +1078,9 @@
|
||||||
@ stdcall -i386 -private MapSLFix(long) krnl386.exe16.MapSLFix
|
@ stdcall -i386 -private MapSLFix(long) krnl386.exe16.MapSLFix
|
||||||
@ stdcall MapUserPhysicalPages(ptr long ptr)
|
@ stdcall MapUserPhysicalPages(ptr long ptr)
|
||||||
# @ stub MapUserPhysicalPagesScatter
|
# @ stub MapUserPhysicalPagesScatter
|
||||||
@ stdcall MapViewOfFile(long long long long long)
|
@ stdcall -import MapViewOfFile(long long long long long)
|
||||||
@ stdcall MapViewOfFileEx(long long long long long ptr)
|
@ stdcall -import MapViewOfFileEx(long long long long long ptr)
|
||||||
# @ stub MapViewOfFileExNuma
|
@ stdcall -import MapViewOfFileExNuma(long long long long long ptr long)
|
||||||
@ stdcall Module32First(long ptr)
|
@ stdcall Module32First(long ptr)
|
||||||
@ stdcall Module32FirstW(long ptr)
|
@ stdcall Module32FirstW(long ptr)
|
||||||
@ stdcall Module32Next(long ptr)
|
@ stdcall Module32Next(long ptr)
|
||||||
|
@ -1198,7 +1198,7 @@
|
||||||
@ stdcall -import ReadFile(long ptr long ptr ptr)
|
@ stdcall -import ReadFile(long ptr long ptr ptr)
|
||||||
@ stdcall -import ReadFileEx(long ptr long ptr ptr)
|
@ stdcall -import ReadFileEx(long ptr long ptr ptr)
|
||||||
@ stdcall -import ReadFileScatter(long ptr long ptr ptr)
|
@ stdcall -import ReadFileScatter(long ptr long ptr ptr)
|
||||||
@ stdcall ReadProcessMemory(long ptr ptr long ptr)
|
@ stdcall -import ReadProcessMemory(long ptr ptr long ptr)
|
||||||
# @ stub ReadThreadProfilingData
|
# @ stub ReadThreadProfilingData
|
||||||
@ stdcall -private RegCloseKey(long) advapi32.RegCloseKey
|
@ stdcall -private RegCloseKey(long) advapi32.RegCloseKey
|
||||||
@ stdcall -private RegCreateKeyExA(long str long ptr long long ptr ptr ptr) advapi32.RegCreateKeyExA
|
@ stdcall -private RegCreateKeyExA(long str long ptr long long ptr ptr ptr) advapi32.RegCreateKeyExA
|
||||||
|
@ -1280,7 +1280,7 @@
|
||||||
@ stdcall RequestDeviceWakeup(long)
|
@ stdcall RequestDeviceWakeup(long)
|
||||||
@ stdcall RequestWakeupLatency(long)
|
@ stdcall RequestWakeupLatency(long)
|
||||||
@ stdcall -import ResetEvent(long)
|
@ stdcall -import ResetEvent(long)
|
||||||
@ stdcall ResetWriteWatch(ptr long)
|
@ stdcall -import ResetWriteWatch(ptr long)
|
||||||
@ stdcall ResolveDelayLoadedAPI(ptr ptr ptr ptr ptr long) ntdll.LdrResolveDelayLoadedAPI
|
@ stdcall ResolveDelayLoadedAPI(ptr ptr ptr ptr ptr long) ntdll.LdrResolveDelayLoadedAPI
|
||||||
@ stdcall ResolveLocaleName(wstr ptr long)
|
@ stdcall ResolveLocaleName(wstr ptr long)
|
||||||
@ stdcall RestoreLastError(long) ntdll.RtlRestoreLastWin32Error
|
@ stdcall RestoreLastError(long) ntdll.RtlRestoreLastWin32Error
|
||||||
|
@ -1536,7 +1536,7 @@
|
||||||
@ stdcall UninitializeCriticalSection(ptr)
|
@ stdcall UninitializeCriticalSection(ptr)
|
||||||
@ stdcall -import UnlockFile(long long long long long)
|
@ stdcall -import UnlockFile(long long long long long)
|
||||||
@ stdcall -import UnlockFileEx(long long long long ptr)
|
@ stdcall -import UnlockFileEx(long long long long ptr)
|
||||||
@ stdcall UnmapViewOfFile(ptr)
|
@ stdcall -import UnmapViewOfFile(ptr)
|
||||||
# @ stub UnregisterApplicationRecoveryCallback
|
# @ stub UnregisterApplicationRecoveryCallback
|
||||||
@ stdcall UnregisterApplicationRestart()
|
@ stdcall UnregisterApplicationRestart()
|
||||||
# @ stub UnregisterConsoleIME
|
# @ stub UnregisterConsoleIME
|
||||||
|
@ -1557,18 +1557,18 @@
|
||||||
# @ stub VerifyScripts
|
# @ stub VerifyScripts
|
||||||
@ stdcall VerifyVersionInfoA(long long int64)
|
@ stdcall VerifyVersionInfoA(long long int64)
|
||||||
@ stdcall VerifyVersionInfoW(long long int64)
|
@ stdcall VerifyVersionInfoW(long long int64)
|
||||||
@ stdcall VirtualAlloc(ptr long long long)
|
@ stdcall -import VirtualAlloc(ptr long long long)
|
||||||
@ stdcall VirtualAllocEx(long ptr long long long)
|
@ stdcall -import VirtualAllocEx(long ptr long long long)
|
||||||
@ stdcall VirtualAllocExNuma(long ptr long long long long)
|
@ stdcall -import VirtualAllocExNuma(long ptr long long long long)
|
||||||
@ stub VirtualBufferExceptionHandler
|
@ stub VirtualBufferExceptionHandler
|
||||||
@ stdcall VirtualFree(ptr long long)
|
@ stdcall -import VirtualFree(ptr long long)
|
||||||
@ stdcall VirtualFreeEx(long ptr long long)
|
@ stdcall -import VirtualFreeEx(long ptr long long)
|
||||||
@ stdcall VirtualLock(ptr long)
|
@ stdcall -import VirtualLock(ptr long)
|
||||||
@ stdcall VirtualProtect(ptr long long ptr)
|
@ stdcall -import VirtualProtect(ptr long long ptr)
|
||||||
@ stdcall VirtualProtectEx(long ptr long long ptr)
|
@ stdcall -import VirtualProtectEx(long ptr long long ptr)
|
||||||
@ stdcall VirtualQuery(ptr ptr long)
|
@ stdcall -import VirtualQuery(ptr ptr long)
|
||||||
@ stdcall VirtualQueryEx(long ptr ptr long)
|
@ stdcall -import VirtualQueryEx(long ptr ptr long)
|
||||||
@ stdcall VirtualUnlock(ptr long)
|
@ stdcall -import VirtualUnlock(ptr long)
|
||||||
@ stdcall WTSGetActiveConsoleSessionId()
|
@ stdcall WTSGetActiveConsoleSessionId()
|
||||||
@ stdcall WaitCommEvent(long ptr ptr)
|
@ stdcall WaitCommEvent(long ptr ptr)
|
||||||
@ stdcall WaitForDebugEvent(ptr long)
|
@ stdcall WaitForDebugEvent(ptr long)
|
||||||
|
@ -1627,7 +1627,7 @@
|
||||||
@ stdcall WritePrivateProfileStringW(wstr wstr wstr wstr)
|
@ stdcall WritePrivateProfileStringW(wstr wstr wstr wstr)
|
||||||
@ stdcall WritePrivateProfileStructA (str str ptr long str)
|
@ stdcall WritePrivateProfileStructA (str str ptr long str)
|
||||||
@ stdcall WritePrivateProfileStructW(wstr wstr ptr long wstr)
|
@ stdcall WritePrivateProfileStructW(wstr wstr ptr long wstr)
|
||||||
@ stdcall WriteProcessMemory(long ptr ptr long ptr)
|
@ stdcall -import WriteProcessMemory(long ptr ptr long ptr)
|
||||||
@ stdcall WriteProfileSectionA(str str)
|
@ stdcall WriteProfileSectionA(str str)
|
||||||
@ stdcall WriteProfileSectionW(str str)
|
@ stdcall WriteProfileSectionW(str str)
|
||||||
@ stdcall WriteProfileStringA(str str str)
|
@ stdcall WriteProfileStringA(str str str)
|
||||||
|
|
|
@ -3484,30 +3484,6 @@ BOOL WINAPI GetProcessWorkingSetSize(HANDLE process, SIZE_T *minset, SIZE_T *max
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/***********************************************************************
|
|
||||||
* ReadProcessMemory (KERNEL32.@)
|
|
||||||
*/
|
|
||||||
BOOL WINAPI ReadProcessMemory( HANDLE process, LPCVOID addr, LPVOID buffer, SIZE_T size,
|
|
||||||
SIZE_T *bytes_read )
|
|
||||||
{
|
|
||||||
NTSTATUS status = NtReadVirtualMemory( process, addr, buffer, size, bytes_read );
|
|
||||||
if (status) SetLastError( RtlNtStatusToDosError(status) );
|
|
||||||
return !status;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/***********************************************************************
|
|
||||||
* WriteProcessMemory (KERNEL32.@)
|
|
||||||
*/
|
|
||||||
BOOL WINAPI WriteProcessMemory( HANDLE process, LPVOID addr, LPCVOID buffer, SIZE_T size,
|
|
||||||
SIZE_T *bytes_written )
|
|
||||||
{
|
|
||||||
NTSTATUS status = NtWriteVirtualMemory( process, addr, buffer, size, bytes_written );
|
|
||||||
if (status) SetLastError( RtlNtStatusToDosError(status) );
|
|
||||||
return !status;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/******************************************************************
|
/******************************************************************
|
||||||
* GetProcessIoCounters (KERNEL32.@)
|
* GetProcessIoCounters (KERNEL32.@)
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -46,426 +46,6 @@
|
||||||
|
|
||||||
WINE_DECLARE_DEBUG_CHANNEL(seh);
|
WINE_DECLARE_DEBUG_CHANNEL(seh);
|
||||||
WINE_DECLARE_DEBUG_CHANNEL(file);
|
WINE_DECLARE_DEBUG_CHANNEL(file);
|
||||||
WINE_DECLARE_DEBUG_CHANNEL(virtual);
|
|
||||||
|
|
||||||
|
|
||||||
/***********************************************************************
|
|
||||||
* VirtualAlloc (KERNEL32.@)
|
|
||||||
*
|
|
||||||
* Reserves or commits a region of pages in virtual address space.
|
|
||||||
*
|
|
||||||
* PARAMS
|
|
||||||
* addr [I] Address of region to reserve or commit.
|
|
||||||
* size [I] Size of region.
|
|
||||||
* type [I] Type of allocation.
|
|
||||||
* protect [I] Type of access protection.
|
|
||||||
*
|
|
||||||
* RETURNS
|
|
||||||
* Success: Base address of allocated region of pages.
|
|
||||||
* Failure: NULL.
|
|
||||||
*/
|
|
||||||
LPVOID WINAPI DECLSPEC_HOTPATCH VirtualAlloc( void *addr, SIZE_T size, DWORD type, DWORD protect )
|
|
||||||
{
|
|
||||||
return VirtualAllocEx( GetCurrentProcess(), addr, size, type, protect );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/***********************************************************************
|
|
||||||
* VirtualAllocEx (KERNEL32.@)
|
|
||||||
*
|
|
||||||
* Seems to be just as VirtualAlloc, but with process handle.
|
|
||||||
*
|
|
||||||
* PARAMS
|
|
||||||
* hProcess [I] Handle to process to do mem operation.
|
|
||||||
* addr [I] Address of region to reserve or commit.
|
|
||||||
* size [I] Size of region.
|
|
||||||
* type [I] Type of allocation.
|
|
||||||
* protect [I] Type of access protection.
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* RETURNS
|
|
||||||
* Success: Base address of allocated region of pages.
|
|
||||||
* Failure: NULL.
|
|
||||||
*/
|
|
||||||
LPVOID WINAPI DECLSPEC_HOTPATCH VirtualAllocEx( HANDLE hProcess, LPVOID addr, SIZE_T size,
|
|
||||||
DWORD type, DWORD protect )
|
|
||||||
{
|
|
||||||
LPVOID ret = addr;
|
|
||||||
NTSTATUS status;
|
|
||||||
|
|
||||||
if ((status = NtAllocateVirtualMemory( hProcess, &ret, 0, &size, type, protect )))
|
|
||||||
{
|
|
||||||
SetLastError( RtlNtStatusToDosError(status) );
|
|
||||||
ret = NULL;
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/***********************************************************************
|
|
||||||
* VirtualAllocExNuma (KERNEL32.@)
|
|
||||||
*/
|
|
||||||
LPVOID WINAPI DECLSPEC_HOTPATCH VirtualAllocExNuma(HANDLE process, void *addr, SIZE_T size,
|
|
||||||
DWORD type, DWORD protect, DWORD numa_node)
|
|
||||||
{
|
|
||||||
FIXME_(virtual)("Ignoring preferred numa_node\n");
|
|
||||||
return VirtualAllocEx(process, addr, size, type, protect);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/***********************************************************************
|
|
||||||
* VirtualFree (KERNEL32.@)
|
|
||||||
*
|
|
||||||
* Releases or decommits a region of pages in virtual address space.
|
|
||||||
*
|
|
||||||
* PARAMS
|
|
||||||
* addr [I] Address of region of committed pages.
|
|
||||||
* size [I] Size of region.
|
|
||||||
* type [I] Type of operation.
|
|
||||||
*
|
|
||||||
* RETURNS
|
|
||||||
* Success: TRUE.
|
|
||||||
* Failure: FALSE.
|
|
||||||
*/
|
|
||||||
BOOL WINAPI VirtualFree( LPVOID addr, SIZE_T size, DWORD type )
|
|
||||||
{
|
|
||||||
return VirtualFreeEx( GetCurrentProcess(), addr, size, type );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/***********************************************************************
|
|
||||||
* VirtualFreeEx (KERNEL32.@)
|
|
||||||
*
|
|
||||||
* Releases or decommits a region of pages in virtual address space.
|
|
||||||
*
|
|
||||||
* PARAMS
|
|
||||||
* process [I] Handle to process.
|
|
||||||
* addr [I] Address of region to free.
|
|
||||||
* size [I] Size of region.
|
|
||||||
* type [I] Type of operation.
|
|
||||||
*
|
|
||||||
* RETURNS
|
|
||||||
* Success: TRUE.
|
|
||||||
* Failure: FALSE.
|
|
||||||
*/
|
|
||||||
BOOL WINAPI VirtualFreeEx( HANDLE process, LPVOID addr, SIZE_T size, DWORD type )
|
|
||||||
{
|
|
||||||
NTSTATUS status = NtFreeVirtualMemory( process, &addr, &size, type );
|
|
||||||
if (status) SetLastError( RtlNtStatusToDosError(status) );
|
|
||||||
return !status;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/***********************************************************************
|
|
||||||
* VirtualLock (KERNEL32.@)
|
|
||||||
*
|
|
||||||
* Locks the specified region of virtual address space.
|
|
||||||
*
|
|
||||||
* PARAMS
|
|
||||||
* addr [I] Address of first byte of range to lock.
|
|
||||||
* size [I] Number of bytes in range to lock.
|
|
||||||
*
|
|
||||||
* RETURNS
|
|
||||||
* Success: TRUE.
|
|
||||||
* Failure: FALSE.
|
|
||||||
*
|
|
||||||
* NOTES
|
|
||||||
* Always returns TRUE.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
BOOL WINAPI VirtualLock( LPVOID addr, SIZE_T size )
|
|
||||||
{
|
|
||||||
NTSTATUS status = NtLockVirtualMemory( GetCurrentProcess(), &addr, &size, 1 );
|
|
||||||
if (status) SetLastError( RtlNtStatusToDosError(status) );
|
|
||||||
return !status;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/***********************************************************************
|
|
||||||
* VirtualUnlock (KERNEL32.@)
|
|
||||||
*
|
|
||||||
* Unlocks a range of pages in the virtual address space.
|
|
||||||
*
|
|
||||||
* PARAMS
|
|
||||||
* addr [I] Address of first byte of range.
|
|
||||||
* size [I] Number of bytes in range.
|
|
||||||
*
|
|
||||||
* RETURNS
|
|
||||||
* Success: TRUE.
|
|
||||||
* Failure: FALSE.
|
|
||||||
*
|
|
||||||
* NOTES
|
|
||||||
* Always returns TRUE.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
BOOL WINAPI VirtualUnlock( LPVOID addr, SIZE_T size )
|
|
||||||
{
|
|
||||||
NTSTATUS status = NtUnlockVirtualMemory( GetCurrentProcess(), &addr, &size, 1 );
|
|
||||||
if (status) SetLastError( RtlNtStatusToDosError(status) );
|
|
||||||
return !status;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/***********************************************************************
|
|
||||||
* VirtualProtect (KERNEL32.@)
|
|
||||||
*
|
|
||||||
* Changes the access protection on a region of committed pages.
|
|
||||||
*
|
|
||||||
* PARAMS
|
|
||||||
* addr [I] Address of region of committed pages.
|
|
||||||
* size [I] Size of region.
|
|
||||||
* new_prot [I] Desired access protection.
|
|
||||||
* old_prot [O] Address of variable to get old protection.
|
|
||||||
*
|
|
||||||
* RETURNS
|
|
||||||
* Success: TRUE.
|
|
||||||
* Failure: FALSE.
|
|
||||||
*/
|
|
||||||
BOOL WINAPI VirtualProtect( LPVOID addr, SIZE_T size, DWORD new_prot, LPDWORD old_prot)
|
|
||||||
{
|
|
||||||
return VirtualProtectEx( GetCurrentProcess(), addr, size, new_prot, old_prot );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/***********************************************************************
|
|
||||||
* VirtualProtectEx (KERNEL32.@)
|
|
||||||
*
|
|
||||||
* Changes the access protection on a region of committed pages in the
|
|
||||||
* virtual address space of a specified process.
|
|
||||||
*
|
|
||||||
* PARAMS
|
|
||||||
* process [I] Handle of process.
|
|
||||||
* addr [I] Address of region of committed pages.
|
|
||||||
* size [I] Size of region.
|
|
||||||
* new_prot [I] Desired access protection.
|
|
||||||
* old_prot [O] Address of variable to get old protection.
|
|
||||||
*
|
|
||||||
* RETURNS
|
|
||||||
* Success: TRUE.
|
|
||||||
* Failure: FALSE.
|
|
||||||
*/
|
|
||||||
BOOL WINAPI VirtualProtectEx( HANDLE process, LPVOID addr, SIZE_T size,
|
|
||||||
DWORD new_prot, LPDWORD old_prot )
|
|
||||||
{
|
|
||||||
NTSTATUS status;
|
|
||||||
DWORD prot;
|
|
||||||
|
|
||||||
/* Win9x allows passing NULL as old_prot while this fails on NT */
|
|
||||||
if (!old_prot && (GetVersion() & 0x80000000)) old_prot = &prot;
|
|
||||||
|
|
||||||
status = NtProtectVirtualMemory( process, &addr, &size, new_prot, old_prot );
|
|
||||||
if (status) SetLastError( RtlNtStatusToDosError(status) );
|
|
||||||
return !status;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/***********************************************************************
|
|
||||||
* VirtualQuery (KERNEL32.@)
|
|
||||||
*
|
|
||||||
* Provides info about a range of pages in virtual address space.
|
|
||||||
*
|
|
||||||
* PARAMS
|
|
||||||
* addr [I] Address of region.
|
|
||||||
* info [O] Address of info buffer.
|
|
||||||
* len [I] Size of buffer.
|
|
||||||
*
|
|
||||||
* RETURNS
|
|
||||||
* Number of bytes returned in information buffer or 0 if
|
|
||||||
* addr >= 0xc0000000 (kernel space).
|
|
||||||
*/
|
|
||||||
SIZE_T WINAPI VirtualQuery( LPCVOID addr, PMEMORY_BASIC_INFORMATION info,
|
|
||||||
SIZE_T len )
|
|
||||||
{
|
|
||||||
return VirtualQueryEx( GetCurrentProcess(), addr, info, len );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/***********************************************************************
|
|
||||||
* VirtualQueryEx (KERNEL32.@)
|
|
||||||
*
|
|
||||||
* Provides info about a range of pages in virtual address space of a
|
|
||||||
* specified process.
|
|
||||||
*
|
|
||||||
* PARAMS
|
|
||||||
* process [I] Handle to process.
|
|
||||||
* addr [I] Address of region.
|
|
||||||
* info [O] Address of info buffer.
|
|
||||||
* len [I] Size of buffer.
|
|
||||||
*
|
|
||||||
* RETURNS
|
|
||||||
* Number of bytes returned in information buffer.
|
|
||||||
*/
|
|
||||||
SIZE_T WINAPI VirtualQueryEx( HANDLE process, LPCVOID addr,
|
|
||||||
PMEMORY_BASIC_INFORMATION info, SIZE_T len )
|
|
||||||
{
|
|
||||||
SIZE_T ret;
|
|
||||||
NTSTATUS status;
|
|
||||||
|
|
||||||
if ((status = NtQueryVirtualMemory( process, addr, MemoryBasicInformation, info, len, &ret )))
|
|
||||||
{
|
|
||||||
SetLastError( RtlNtStatusToDosError(status) );
|
|
||||||
ret = 0;
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/***********************************************************************
|
|
||||||
* MapViewOfFile (KERNEL32.@)
|
|
||||||
*
|
|
||||||
* Maps a view of a file into the address space.
|
|
||||||
*
|
|
||||||
* PARAMS
|
|
||||||
* mapping [I] File-mapping object to map.
|
|
||||||
* access [I] Access mode.
|
|
||||||
* offset_high [I] High-order 32 bits of file offset.
|
|
||||||
* offset_low [I] Low-order 32 bits of file offset.
|
|
||||||
* count [I] Number of bytes to map.
|
|
||||||
*
|
|
||||||
* RETURNS
|
|
||||||
* Success: Starting address of mapped view.
|
|
||||||
* Failure: NULL.
|
|
||||||
*/
|
|
||||||
LPVOID WINAPI DECLSPEC_HOTPATCH MapViewOfFile( HANDLE mapping, DWORD access,
|
|
||||||
DWORD offset_high, DWORD offset_low, SIZE_T count )
|
|
||||||
{
|
|
||||||
return MapViewOfFileEx( mapping, access, offset_high,
|
|
||||||
offset_low, count, NULL );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/***********************************************************************
|
|
||||||
* MapViewOfFileEx (KERNEL32.@)
|
|
||||||
*
|
|
||||||
* Maps a view of a file into the address space.
|
|
||||||
*
|
|
||||||
* PARAMS
|
|
||||||
* handle [I] File-mapping object to map.
|
|
||||||
* access [I] Access mode.
|
|
||||||
* offset_high [I] High-order 32 bits of file offset.
|
|
||||||
* offset_low [I] Low-order 32 bits of file offset.
|
|
||||||
* count [I] Number of bytes to map.
|
|
||||||
* addr [I] Suggested starting address for mapped view.
|
|
||||||
*
|
|
||||||
* RETURNS
|
|
||||||
* Success: Starting address of mapped view.
|
|
||||||
* Failure: NULL.
|
|
||||||
*/
|
|
||||||
LPVOID WINAPI MapViewOfFileEx( HANDLE handle, DWORD access,
|
|
||||||
DWORD offset_high, DWORD offset_low, SIZE_T count, LPVOID addr )
|
|
||||||
{
|
|
||||||
NTSTATUS status;
|
|
||||||
LARGE_INTEGER offset;
|
|
||||||
ULONG protect;
|
|
||||||
BOOL exec;
|
|
||||||
|
|
||||||
offset.u.LowPart = offset_low;
|
|
||||||
offset.u.HighPart = offset_high;
|
|
||||||
|
|
||||||
exec = access & FILE_MAP_EXECUTE;
|
|
||||||
access &= ~FILE_MAP_EXECUTE;
|
|
||||||
|
|
||||||
if (access == FILE_MAP_COPY)
|
|
||||||
protect = exec ? PAGE_EXECUTE_WRITECOPY : PAGE_WRITECOPY;
|
|
||||||
else if (access & FILE_MAP_WRITE)
|
|
||||||
protect = exec ? PAGE_EXECUTE_READWRITE : PAGE_READWRITE;
|
|
||||||
else if (access & FILE_MAP_READ)
|
|
||||||
protect = exec ? PAGE_EXECUTE_READ : PAGE_READONLY;
|
|
||||||
else protect = PAGE_NOACCESS;
|
|
||||||
|
|
||||||
if ((status = NtMapViewOfSection( handle, GetCurrentProcess(), &addr, 0, 0, &offset,
|
|
||||||
&count, ViewShare, 0, protect )) < 0)
|
|
||||||
{
|
|
||||||
SetLastError( RtlNtStatusToDosError(status) );
|
|
||||||
addr = NULL;
|
|
||||||
}
|
|
||||||
return addr;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/***********************************************************************
|
|
||||||
* UnmapViewOfFile (KERNEL32.@)
|
|
||||||
*
|
|
||||||
* Unmaps a mapped view of a file.
|
|
||||||
*
|
|
||||||
* PARAMS
|
|
||||||
* addr [I] Address where mapped view begins.
|
|
||||||
*
|
|
||||||
* RETURNS
|
|
||||||
* Success: TRUE.
|
|
||||||
* Failure: FALSE.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
BOOL WINAPI DECLSPEC_HOTPATCH UnmapViewOfFile( const void *addr )
|
|
||||||
{
|
|
||||||
NTSTATUS status;
|
|
||||||
|
|
||||||
if (GetVersion() & 0x80000000)
|
|
||||||
{
|
|
||||||
MEMORY_BASIC_INFORMATION info;
|
|
||||||
if (!VirtualQuery( addr, &info, sizeof(info) ) || info.AllocationBase != addr)
|
|
||||||
{
|
|
||||||
SetLastError( ERROR_INVALID_ADDRESS );
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
status = NtUnmapViewOfSection( GetCurrentProcess(), (void *)addr );
|
|
||||||
if (status) SetLastError( RtlNtStatusToDosError(status) );
|
|
||||||
return !status;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/***********************************************************************
|
|
||||||
* FlushViewOfFile (KERNEL32.@)
|
|
||||||
*
|
|
||||||
* Writes to the disk a byte range within a mapped view of a file.
|
|
||||||
*
|
|
||||||
* PARAMS
|
|
||||||
* base [I] Start address of byte range to flush.
|
|
||||||
* size [I] Number of bytes in range.
|
|
||||||
*
|
|
||||||
* RETURNS
|
|
||||||
* Success: TRUE.
|
|
||||||
* Failure: FALSE.
|
|
||||||
*/
|
|
||||||
BOOL WINAPI FlushViewOfFile( LPCVOID base, SIZE_T size )
|
|
||||||
{
|
|
||||||
NTSTATUS status = NtFlushVirtualMemory( GetCurrentProcess(), &base, &size, 0 );
|
|
||||||
if (status)
|
|
||||||
{
|
|
||||||
if (status == STATUS_NOT_MAPPED_DATA) status = STATUS_SUCCESS;
|
|
||||||
else SetLastError( RtlNtStatusToDosError(status) );
|
|
||||||
}
|
|
||||||
return !status;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/***********************************************************************
|
|
||||||
* GetWriteWatch (KERNEL32.@)
|
|
||||||
*/
|
|
||||||
UINT WINAPI GetWriteWatch( DWORD flags, LPVOID base, SIZE_T size, LPVOID *addresses,
|
|
||||||
ULONG_PTR *count, ULONG *granularity )
|
|
||||||
{
|
|
||||||
NTSTATUS status;
|
|
||||||
|
|
||||||
status = NtGetWriteWatch( GetCurrentProcess(), flags, base, size, addresses, count, granularity );
|
|
||||||
if (status) SetLastError( RtlNtStatusToDosError(status) );
|
|
||||||
return status ? ~0u : 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/***********************************************************************
|
|
||||||
* ResetWriteWatch (KERNEL32.@)
|
|
||||||
*/
|
|
||||||
UINT WINAPI ResetWriteWatch( LPVOID base, SIZE_T size )
|
|
||||||
{
|
|
||||||
NTSTATUS status;
|
|
||||||
|
|
||||||
status = NtResetWriteWatch( GetCurrentProcess(), base, size );
|
|
||||||
if (status) SetLastError( RtlNtStatusToDosError(status) );
|
|
||||||
return status ? ~0u : 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
|
|
|
@ -7,6 +7,7 @@ C_SRCS = \
|
||||||
file.c \
|
file.c \
|
||||||
loader.c \
|
loader.c \
|
||||||
main.c \
|
main.c \
|
||||||
|
memory.c \
|
||||||
path.c \
|
path.c \
|
||||||
process.c \
|
process.c \
|
||||||
registry.c \
|
registry.c \
|
||||||
|
|
|
@ -383,7 +383,7 @@
|
||||||
@ stdcall FlushFileBuffers(long)
|
@ stdcall FlushFileBuffers(long)
|
||||||
@ stdcall FlushInstructionCache(long long long)
|
@ stdcall FlushInstructionCache(long long long)
|
||||||
@ stdcall FlushProcessWriteBuffers() kernel32.FlushProcessWriteBuffers
|
@ stdcall FlushProcessWriteBuffers() kernel32.FlushProcessWriteBuffers
|
||||||
@ stdcall FlushViewOfFile(ptr long) kernel32.FlushViewOfFile
|
@ stdcall FlushViewOfFile(ptr long)
|
||||||
@ stdcall FoldStringW(long wstr long ptr long) kernel32.FoldStringW
|
@ stdcall FoldStringW(long wstr long ptr long) kernel32.FoldStringW
|
||||||
# @ stub ForceSyncFgPolicyInternal
|
# @ stub ForceSyncFgPolicyInternal
|
||||||
# @ stub FormatApplicationUserModelId
|
# @ stub FormatApplicationUserModelId
|
||||||
|
@ -762,7 +762,7 @@
|
||||||
@ stdcall GetWindowsAccountDomainSid(ptr ptr ptr)
|
@ stdcall GetWindowsAccountDomainSid(ptr ptr ptr)
|
||||||
@ stdcall GetWindowsDirectoryA(ptr long)
|
@ stdcall GetWindowsDirectoryA(ptr long)
|
||||||
@ stdcall GetWindowsDirectoryW(ptr long)
|
@ stdcall GetWindowsDirectoryW(ptr long)
|
||||||
@ stdcall GetWriteWatch(long ptr long ptr ptr ptr) kernel32.GetWriteWatch
|
@ stdcall GetWriteWatch(long ptr long ptr ptr ptr)
|
||||||
# @ stub GetWsChanges
|
# @ stub GetWsChanges
|
||||||
# @ stub GetWsChangesEx
|
# @ stub GetWsChangesEx
|
||||||
# @ stub GetXStateFeaturesMask
|
# @ stub GetXStateFeaturesMask
|
||||||
|
@ -950,9 +950,9 @@
|
||||||
@ stdcall MapGenericMask(ptr ptr)
|
@ stdcall MapGenericMask(ptr ptr)
|
||||||
# @ stub MapPredefinedHandleInternal
|
# @ stub MapPredefinedHandleInternal
|
||||||
@ stdcall MapUserPhysicalPages(ptr long ptr) kernel32.MapUserPhysicalPages
|
@ stdcall MapUserPhysicalPages(ptr long ptr) kernel32.MapUserPhysicalPages
|
||||||
@ stdcall MapViewOfFile(long long long long long) kernel32.MapViewOfFile
|
@ stdcall MapViewOfFile(long long long long long)
|
||||||
@ stdcall MapViewOfFileEx(long long long long long ptr) kernel32.MapViewOfFileEx
|
@ stdcall MapViewOfFileEx(long long long long long ptr)
|
||||||
@ stub MapViewOfFileExNuma
|
@ stdcall MapViewOfFileExNuma(long long long long long ptr long)
|
||||||
# @ stub MapViewOfFileFromApp
|
# @ stub MapViewOfFileFromApp
|
||||||
@ stdcall MoveFileExW(wstr wstr long) kernel32.MoveFileExW
|
@ stdcall MoveFileExW(wstr wstr long) kernel32.MoveFileExW
|
||||||
# @ stub MoveFileWithProgressTransactedW
|
# @ stub MoveFileWithProgressTransactedW
|
||||||
|
@ -1250,7 +1250,7 @@
|
||||||
@ stdcall ReadFile(long ptr long ptr ptr)
|
@ stdcall ReadFile(long ptr long ptr ptr)
|
||||||
@ stdcall ReadFileEx(long ptr long ptr ptr)
|
@ stdcall ReadFileEx(long ptr long ptr ptr)
|
||||||
@ stdcall ReadFileScatter(long ptr long ptr ptr)
|
@ stdcall ReadFileScatter(long ptr long ptr ptr)
|
||||||
@ stdcall ReadProcessMemory(long ptr ptr long ptr) kernel32.ReadProcessMemory
|
@ stdcall ReadProcessMemory(long ptr ptr long ptr)
|
||||||
# @ stub ReadStateAtomValue
|
# @ stub ReadStateAtomValue
|
||||||
# @ stub ReadStateContainerValue
|
# @ stub ReadStateContainerValue
|
||||||
# @ stub ReclaimVirtualMemory
|
# @ stub ReclaimVirtualMemory
|
||||||
|
@ -1343,7 +1343,7 @@
|
||||||
@ stdcall ReplaceFileW(wstr wstr wstr long ptr ptr) kernel32.ReplaceFileW
|
@ stdcall ReplaceFileW(wstr wstr wstr long ptr ptr) kernel32.ReplaceFileW
|
||||||
@ stdcall ResetEvent(long)
|
@ stdcall ResetEvent(long)
|
||||||
# @ stub ResetState
|
# @ stub ResetState
|
||||||
@ stdcall ResetWriteWatch(ptr long) kernel32.ResetWriteWatch
|
@ stdcall ResetWriteWatch(ptr long)
|
||||||
@ stdcall ResolveDelayLoadedAPI(ptr ptr ptr ptr ptr long) kernel32.ResolveDelayLoadedAPI
|
@ stdcall ResolveDelayLoadedAPI(ptr ptr ptr ptr ptr long) kernel32.ResolveDelayLoadedAPI
|
||||||
# @ stub ResolveDelayLoadsFromDll
|
# @ stub ResolveDelayLoadsFromDll
|
||||||
@ stdcall ResolveLocaleName(wstr ptr long) kernel32.ResolveLocaleName
|
@ stdcall ResolveLocaleName(wstr ptr long) kernel32.ResolveLocaleName
|
||||||
|
@ -1615,7 +1615,7 @@
|
||||||
@ stdcall UnhandledExceptionFilter(ptr) kernel32.UnhandledExceptionFilter
|
@ stdcall UnhandledExceptionFilter(ptr) kernel32.UnhandledExceptionFilter
|
||||||
@ stdcall UnlockFile(long long long long long)
|
@ stdcall UnlockFile(long long long long long)
|
||||||
@ stdcall UnlockFileEx(long long long long ptr)
|
@ stdcall UnlockFileEx(long long long long ptr)
|
||||||
@ stdcall UnmapViewOfFile(ptr) kernel32.UnmapViewOfFile
|
@ stdcall UnmapViewOfFile(ptr)
|
||||||
# @ stub UnmapViewOfFileEx
|
# @ stub UnmapViewOfFileEx
|
||||||
# @ stub UnregisterBadMemoryNotification
|
# @ stub UnregisterBadMemoryNotification
|
||||||
# @ stub UnregisterGPNotificationInternal
|
# @ stub UnregisterGPNotificationInternal
|
||||||
|
@ -1668,19 +1668,19 @@
|
||||||
# @ stub VerifyPackageId
|
# @ stub VerifyPackageId
|
||||||
# @ stub VerifyPackageRelativeApplicationId
|
# @ stub VerifyPackageRelativeApplicationId
|
||||||
# @ stub VerifyScripts
|
# @ stub VerifyScripts
|
||||||
@ stdcall VirtualAlloc(ptr long long long) kernel32.VirtualAlloc
|
@ stdcall VirtualAlloc(ptr long long long)
|
||||||
@ stdcall VirtualAllocEx(long ptr long long long) kernel32.VirtualAllocEx
|
@ stdcall VirtualAllocEx(long ptr long long long)
|
||||||
@ stdcall VirtualAllocExNuma(long ptr long long long long) kernel32.VirtualAllocExNuma
|
@ stdcall VirtualAllocExNuma(long ptr long long long long)
|
||||||
# @ stub VirtualAllocFromApp
|
# @ stub VirtualAllocFromApp
|
||||||
@ stdcall VirtualFree(ptr long long) kernel32.VirtualFree
|
@ stdcall VirtualFree(ptr long long)
|
||||||
@ stdcall VirtualFreeEx(long ptr long long) kernel32.VirtualFreeEx
|
@ stdcall VirtualFreeEx(long ptr long long)
|
||||||
@ stdcall VirtualLock(ptr long) kernel32.VirtualLock
|
@ stdcall VirtualLock(ptr long)
|
||||||
@ stdcall VirtualProtect(ptr long long ptr) kernel32.VirtualProtect
|
@ stdcall VirtualProtect(ptr long long ptr)
|
||||||
@ stdcall VirtualProtectEx(long ptr long long ptr) kernel32.VirtualProtectEx
|
@ stdcall VirtualProtectEx(long ptr long long ptr)
|
||||||
# @ stub VirtualProtectFromApp
|
# @ stub VirtualProtectFromApp
|
||||||
@ stdcall VirtualQuery(ptr ptr long) kernel32.VirtualQuery
|
@ stdcall VirtualQuery(ptr ptr long)
|
||||||
@ stdcall VirtualQueryEx(long ptr ptr long) kernel32.VirtualQueryEx
|
@ stdcall VirtualQueryEx(long ptr ptr long)
|
||||||
@ stdcall VirtualUnlock(ptr long) kernel32.VirtualUnlock
|
@ stdcall VirtualUnlock(ptr long)
|
||||||
# @ stub WTSGetServiceSessionId
|
# @ stub WTSGetServiceSessionId
|
||||||
# @ stub WTSIsServerContainer
|
# @ stub WTSIsServerContainer
|
||||||
@ stdcall WaitCommEvent(long ptr ptr) kernel32.WaitCommEvent
|
@ stdcall WaitCommEvent(long ptr ptr) kernel32.WaitCommEvent
|
||||||
|
@ -1729,7 +1729,7 @@
|
||||||
@ stdcall WriteFile(long ptr long ptr ptr)
|
@ stdcall WriteFile(long ptr long ptr ptr)
|
||||||
@ stdcall WriteFileEx(long ptr long ptr ptr)
|
@ stdcall WriteFileEx(long ptr long ptr ptr)
|
||||||
@ stdcall WriteFileGather(long ptr long ptr ptr)
|
@ stdcall WriteFileGather(long ptr long ptr ptr)
|
||||||
@ stdcall WriteProcessMemory(long ptr ptr long ptr) kernel32.WriteProcessMemory
|
@ stdcall WriteProcessMemory(long ptr ptr long ptr)
|
||||||
# @ stub WriteStateAtomValue
|
# @ stub WriteStateAtomValue
|
||||||
# @ stub WriteStateContainerValue
|
# @ stub WriteStateContainerValue
|
||||||
@ stdcall ZombifyActCtx(ptr)
|
@ stdcall ZombifyActCtx(ptr)
|
||||||
|
|
|
@ -0,0 +1,293 @@
|
||||||
|
/*
|
||||||
|
* Win32 memory management functions
|
||||||
|
*
|
||||||
|
* Copyright 1997 Alexandre Julliard
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2.1 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdarg.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include "ntstatus.h"
|
||||||
|
#define WIN32_NO_STATUS
|
||||||
|
#define NONAMELESSUNION
|
||||||
|
#include "windef.h"
|
||||||
|
#include "winbase.h"
|
||||||
|
#include "winnls.h"
|
||||||
|
#include "winternl.h"
|
||||||
|
#include "winerror.h"
|
||||||
|
|
||||||
|
#include "kernelbase.h"
|
||||||
|
#include "wine/exception.h"
|
||||||
|
#include "wine/debug.h"
|
||||||
|
|
||||||
|
WINE_DEFAULT_DEBUG_CHANNEL(virtual);
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
* Virtual memory functions
|
||||||
|
***********************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
* FlushViewOfFile (kernelbase.@)
|
||||||
|
*/
|
||||||
|
BOOL WINAPI DECLSPEC_HOTPATCH FlushViewOfFile( const void *base, SIZE_T size )
|
||||||
|
{
|
||||||
|
NTSTATUS status = NtFlushVirtualMemory( GetCurrentProcess(), &base, &size, 0 );
|
||||||
|
if (status)
|
||||||
|
{
|
||||||
|
if (status == STATUS_NOT_MAPPED_DATA) status = STATUS_SUCCESS;
|
||||||
|
else SetLastError( RtlNtStatusToDosError(status) );
|
||||||
|
}
|
||||||
|
return !status;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
* GetWriteWatch (kernelbase.@)
|
||||||
|
*/
|
||||||
|
UINT WINAPI DECLSPEC_HOTPATCH GetWriteWatch( DWORD flags, void *base, SIZE_T size, void **addresses,
|
||||||
|
ULONG_PTR *count, ULONG *granularity )
|
||||||
|
{
|
||||||
|
if (!set_ntstatus( NtGetWriteWatch( GetCurrentProcess(), flags, base, size,
|
||||||
|
addresses, count, granularity )))
|
||||||
|
return ~0u;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
* MapViewOfFile (kernelbase.@)
|
||||||
|
*/
|
||||||
|
LPVOID WINAPI DECLSPEC_HOTPATCH MapViewOfFile( HANDLE mapping, DWORD access, DWORD offset_high,
|
||||||
|
DWORD offset_low, SIZE_T count )
|
||||||
|
{
|
||||||
|
return MapViewOfFileEx( mapping, access, offset_high, offset_low, count, NULL );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
* MapViewOfFileEx (kernelbase.@)
|
||||||
|
*/
|
||||||
|
LPVOID WINAPI DECLSPEC_HOTPATCH MapViewOfFileEx( HANDLE handle, DWORD access, DWORD offset_high,
|
||||||
|
DWORD offset_low, SIZE_T count, LPVOID addr )
|
||||||
|
{
|
||||||
|
NTSTATUS status;
|
||||||
|
LARGE_INTEGER offset;
|
||||||
|
ULONG protect;
|
||||||
|
BOOL exec;
|
||||||
|
|
||||||
|
offset.u.LowPart = offset_low;
|
||||||
|
offset.u.HighPart = offset_high;
|
||||||
|
|
||||||
|
exec = access & FILE_MAP_EXECUTE;
|
||||||
|
access &= ~FILE_MAP_EXECUTE;
|
||||||
|
|
||||||
|
if (access == FILE_MAP_COPY)
|
||||||
|
protect = exec ? PAGE_EXECUTE_WRITECOPY : PAGE_WRITECOPY;
|
||||||
|
else if (access & FILE_MAP_WRITE)
|
||||||
|
protect = exec ? PAGE_EXECUTE_READWRITE : PAGE_READWRITE;
|
||||||
|
else if (access & FILE_MAP_READ)
|
||||||
|
protect = exec ? PAGE_EXECUTE_READ : PAGE_READONLY;
|
||||||
|
else protect = PAGE_NOACCESS;
|
||||||
|
|
||||||
|
if ((status = NtMapViewOfSection( handle, GetCurrentProcess(), &addr, 0, 0, &offset,
|
||||||
|
&count, ViewShare, 0, protect )) < 0)
|
||||||
|
{
|
||||||
|
SetLastError( RtlNtStatusToDosError(status) );
|
||||||
|
addr = NULL;
|
||||||
|
}
|
||||||
|
return addr;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
* MapViewOfFileExNuma (kernelbase.@)
|
||||||
|
*/
|
||||||
|
LPVOID WINAPI DECLSPEC_HOTPATCH MapViewOfFileExNuma( HANDLE handle, DWORD access, DWORD offset_high,
|
||||||
|
DWORD offset_low, SIZE_T count, LPVOID addr,
|
||||||
|
DWORD numa_node )
|
||||||
|
{
|
||||||
|
FIXME( "Ignoring preferred numa_node\n" );
|
||||||
|
return MapViewOfFileEx( handle, access, offset_high, offset_low, count, addr );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
* ReadProcessMemory (kernelbase.@)
|
||||||
|
*/
|
||||||
|
BOOL WINAPI DECLSPEC_HOTPATCH ReadProcessMemory( HANDLE process, const void *addr, void *buffer,
|
||||||
|
SIZE_T size, SIZE_T *bytes_read )
|
||||||
|
{
|
||||||
|
return set_ntstatus( NtReadVirtualMemory( process, addr, buffer, size, bytes_read ));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
* ResetWriteWatch (kernelbase.@)
|
||||||
|
*/
|
||||||
|
UINT WINAPI DECLSPEC_HOTPATCH ResetWriteWatch( void *base, SIZE_T size )
|
||||||
|
{
|
||||||
|
if (!set_ntstatus( NtResetWriteWatch( GetCurrentProcess(), base, size )))
|
||||||
|
return ~0u;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
* UnmapViewOfFile (kernelbase.@)
|
||||||
|
*/
|
||||||
|
BOOL WINAPI DECLSPEC_HOTPATCH UnmapViewOfFile( const void *addr )
|
||||||
|
{
|
||||||
|
if (GetVersion() & 0x80000000)
|
||||||
|
{
|
||||||
|
MEMORY_BASIC_INFORMATION info;
|
||||||
|
if (!VirtualQuery( addr, &info, sizeof(info) ) || info.AllocationBase != addr)
|
||||||
|
{
|
||||||
|
SetLastError( ERROR_INVALID_ADDRESS );
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return set_ntstatus( NtUnmapViewOfSection( GetCurrentProcess(), (void *)addr ));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
* VirtualAlloc (kernelbase.@)
|
||||||
|
*/
|
||||||
|
LPVOID WINAPI DECLSPEC_HOTPATCH VirtualAlloc( void *addr, SIZE_T size, DWORD type, DWORD protect )
|
||||||
|
{
|
||||||
|
return VirtualAllocEx( GetCurrentProcess(), addr, size, type, protect );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
* VirtualAllocEx (kernelbase.@)
|
||||||
|
*/
|
||||||
|
LPVOID WINAPI DECLSPEC_HOTPATCH VirtualAllocEx( HANDLE process, void *addr, SIZE_T size,
|
||||||
|
DWORD type, DWORD protect )
|
||||||
|
{
|
||||||
|
LPVOID ret = addr;
|
||||||
|
|
||||||
|
if (!set_ntstatus( NtAllocateVirtualMemory( process, &ret, 0, &size, type, protect ))) return NULL;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
* VirtualAllocExNuma (kernelbase.@)
|
||||||
|
*/
|
||||||
|
LPVOID WINAPI DECLSPEC_HOTPATCH VirtualAllocExNuma( HANDLE process, void *addr, SIZE_T size,
|
||||||
|
DWORD type, DWORD protect, DWORD numa_node )
|
||||||
|
{
|
||||||
|
FIXME( "Ignoring preferred numa_node\n" );
|
||||||
|
return VirtualAllocEx( process, addr, size, type, protect );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
* VirtualFree (kernelbase.@)
|
||||||
|
*/
|
||||||
|
BOOL WINAPI DECLSPEC_HOTPATCH VirtualFree( void *addr, SIZE_T size, DWORD type )
|
||||||
|
{
|
||||||
|
return VirtualFreeEx( GetCurrentProcess(), addr, size, type );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
* VirtualFreeEx (kernelbase.@)
|
||||||
|
*/
|
||||||
|
BOOL WINAPI DECLSPEC_HOTPATCH VirtualFreeEx( HANDLE process, void *addr, SIZE_T size, DWORD type )
|
||||||
|
{
|
||||||
|
return set_ntstatus( NtFreeVirtualMemory( process, &addr, &size, type ));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
* VirtualLock (kernelbase.@)
|
||||||
|
*/
|
||||||
|
BOOL WINAPI DECLSPEC_HOTPATCH VirtualLock( void *addr, SIZE_T size )
|
||||||
|
{
|
||||||
|
return set_ntstatus( NtLockVirtualMemory( GetCurrentProcess(), &addr, &size, 1 ));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
* VirtualProtect (kernelbase.@)
|
||||||
|
*/
|
||||||
|
BOOL WINAPI DECLSPEC_HOTPATCH VirtualProtect( void *addr, SIZE_T size, DWORD new_prot, DWORD *old_prot )
|
||||||
|
{
|
||||||
|
return VirtualProtectEx( GetCurrentProcess(), addr, size, new_prot, old_prot );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
* VirtualProtectEx (kernelbase.@)
|
||||||
|
*/
|
||||||
|
BOOL WINAPI DECLSPEC_HOTPATCH VirtualProtectEx( HANDLE process, void *addr, SIZE_T size,
|
||||||
|
DWORD new_prot, DWORD *old_prot )
|
||||||
|
{
|
||||||
|
DWORD prot;
|
||||||
|
|
||||||
|
/* Win9x allows passing NULL as old_prot while this fails on NT */
|
||||||
|
if (!old_prot && (GetVersion() & 0x80000000)) old_prot = &prot;
|
||||||
|
return set_ntstatus( NtProtectVirtualMemory( process, &addr, &size, new_prot, old_prot ));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
* VirtualQuery (kernelbase.@)
|
||||||
|
*/
|
||||||
|
SIZE_T WINAPI DECLSPEC_HOTPATCH VirtualQuery( LPCVOID addr, PMEMORY_BASIC_INFORMATION info, SIZE_T len )
|
||||||
|
{
|
||||||
|
return VirtualQueryEx( GetCurrentProcess(), addr, info, len );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
* VirtualQueryEx (kernelbase.@)
|
||||||
|
*/
|
||||||
|
SIZE_T WINAPI DECLSPEC_HOTPATCH VirtualQueryEx( HANDLE process, LPCVOID addr,
|
||||||
|
PMEMORY_BASIC_INFORMATION info, SIZE_T len )
|
||||||
|
{
|
||||||
|
SIZE_T ret;
|
||||||
|
|
||||||
|
if (!set_ntstatus( NtQueryVirtualMemory( process, addr, MemoryBasicInformation, info, len, &ret )))
|
||||||
|
return 0;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
* VirtualUnlock (kernelbase.@)
|
||||||
|
*/
|
||||||
|
BOOL WINAPI DECLSPEC_HOTPATCH VirtualUnlock( void *addr, SIZE_T size )
|
||||||
|
{
|
||||||
|
return set_ntstatus( NtUnlockVirtualMemory( GetCurrentProcess(), &addr, &size, 1 ));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
* WriteProcessMemory (kernelbase.@)
|
||||||
|
*/
|
||||||
|
BOOL WINAPI DECLSPEC_HOTPATCH WriteProcessMemory( HANDLE process, void *addr, const void *buffer,
|
||||||
|
SIZE_T size, SIZE_T *bytes_written )
|
||||||
|
{
|
||||||
|
return set_ntstatus( NtWriteVirtualMemory( process, addr, buffer, size, bytes_written ));
|
||||||
|
}
|
Loading…
Reference in New Issue