Milestone 5: deliver embedded RDP sessions and lifecycle hardening

This commit is contained in:
Keith Smith
2026-03-03 18:59:26 -07:00
parent 230a401386
commit 36006bd4aa
2941 changed files with 724359 additions and 77 deletions

View File

@@ -0,0 +1,22 @@
# WinPR: Windows Portable Runtime
# libwinpr-memory cmake build script
#
# Copyright 2012 Marc-Andre Moreau <marcandre.moreau@gmail.com>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
winpr_module_add(memory.c memory.h)
if(BUILD_TESTING_INTERNAL OR BUILD_TESTING)
add_subdirectory(test)
endif()

View File

@@ -0,0 +1,9 @@
set(MINWIN_LAYER "1")
set(MINWIN_GROUP "core")
set(MINWIN_MAJOR_VERSION "1")
set(MINWIN_MINOR_VERSION "2")
set(MINWIN_SHORT_NAME "memory")
set(MINWIN_LONG_NAME "Memory Functions")
set(MODULE_LIBRARY_NAME
"api-ms-win-${MINWIN_GROUP}-${MINWIN_SHORT_NAME}-l${MINWIN_LAYER}-${MINWIN_MAJOR_VERSION}-${MINWIN_MINOR_VERSION}"
)

View File

@@ -0,0 +1,154 @@
/**
* WinPR: Windows Portable Runtime
* Memory Functions
*
* Copyright 2014 Marc-Andre Moreau <marcandre.moreau@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <winpr/config.h>
#include <winpr/crt.h>
#include <winpr/wlog.h>
#include <winpr/memory.h>
#ifdef WINPR_HAVE_UNISTD_H
#include <unistd.h>
#endif
/**
* api-ms-win-core-memory-l1-1-2.dll:
*
* AllocateUserPhysicalPages
* AllocateUserPhysicalPagesNuma
* CreateFileMappingFromApp
* CreateFileMappingNumaW
* CreateFileMappingW
* CreateMemoryResourceNotification
* FlushViewOfFile
* FreeUserPhysicalPages
* GetLargePageMinimum
* GetMemoryErrorHandlingCapabilities
* GetProcessWorkingSetSizeEx
* GetSystemFileCacheSize
* GetWriteWatch
* MapUserPhysicalPages
* MapViewOfFile
* MapViewOfFileEx
* MapViewOfFileFromApp
* OpenFileMappingW
* PrefetchVirtualMemory
* QueryMemoryResourceNotification
* ReadProcessMemory
* RegisterBadMemoryNotification
* ResetWriteWatch
* SetProcessWorkingSetSizeEx
* SetSystemFileCacheSize
* UnmapViewOfFile
* UnmapViewOfFileEx
* UnregisterBadMemoryNotification
* VirtualAlloc
* VirtualAllocEx
* VirtualAllocExNuma
* VirtualFree
* VirtualFreeEx
* VirtualLock
* VirtualProtect
* VirtualProtectEx
* VirtualQuery
* VirtualQueryEx
* VirtualUnlock
* WriteProcessMemory
*/
#ifndef _WIN32
#include "memory.h"
HANDLE CreateFileMappingA(WINPR_ATTR_UNUSED HANDLE hFile,
WINPR_ATTR_UNUSED LPSECURITY_ATTRIBUTES lpAttributes,
WINPR_ATTR_UNUSED DWORD flProtect,
WINPR_ATTR_UNUSED DWORD dwMaximumSizeHigh,
WINPR_ATTR_UNUSED DWORD dwMaximumSizeLow, WINPR_ATTR_UNUSED LPCSTR lpName)
{
WLog_ERR("TODO", "TODO: Implement");
if (hFile != INVALID_HANDLE_VALUE)
{
return nullptr; /* not yet implemented */
}
return nullptr;
}
HANDLE CreateFileMappingW(WINPR_ATTR_UNUSED HANDLE hFile,
WINPR_ATTR_UNUSED LPSECURITY_ATTRIBUTES lpAttributes,
WINPR_ATTR_UNUSED DWORD flProtect,
WINPR_ATTR_UNUSED DWORD dwMaximumSizeHigh,
WINPR_ATTR_UNUSED DWORD dwMaximumSizeLow,
WINPR_ATTR_UNUSED LPCWSTR lpName)
{
WLog_ERR("TODO", "TODO: Implement");
return nullptr;
}
HANDLE OpenFileMappingA(WINPR_ATTR_UNUSED DWORD dwDesiredAccess,
WINPR_ATTR_UNUSED BOOL bInheritHandle, WINPR_ATTR_UNUSED LPCSTR lpName)
{
WLog_ERR("TODO", "TODO: Implement");
return nullptr;
}
HANDLE OpenFileMappingW(WINPR_ATTR_UNUSED DWORD dwDesiredAccess,
WINPR_ATTR_UNUSED BOOL bInheritHandle, WINPR_ATTR_UNUSED LPCWSTR lpName)
{
WLog_ERR("TODO", "TODO: Implement");
return nullptr;
}
LPVOID MapViewOfFile(WINPR_ATTR_UNUSED HANDLE hFileMappingObject,
WINPR_ATTR_UNUSED DWORD dwDesiredAccess,
WINPR_ATTR_UNUSED DWORD dwFileOffsetHigh,
WINPR_ATTR_UNUSED DWORD dwFileOffsetLow,
WINPR_ATTR_UNUSED size_t dwNumberOfBytesToMap)
{
WLog_ERR("TODO", "TODO: Implement");
return nullptr;
}
LPVOID MapViewOfFileEx(WINPR_ATTR_UNUSED HANDLE hFileMappingObject,
WINPR_ATTR_UNUSED DWORD dwDesiredAccess,
WINPR_ATTR_UNUSED DWORD dwFileOffsetHigh,
WINPR_ATTR_UNUSED DWORD dwFileOffsetLow,
WINPR_ATTR_UNUSED size_t dwNumberOfBytesToMap,
WINPR_ATTR_UNUSED LPVOID lpBaseAddress)
{
WLog_ERR("TODO", "TODO: Implement");
return nullptr;
}
BOOL FlushViewOfFile(WINPR_ATTR_UNUSED LPCVOID lpBaseAddress,
WINPR_ATTR_UNUSED size_t dwNumberOfBytesToFlush)
{
WLog_ERR("TODO", "TODO: Implement");
return TRUE;
}
BOOL UnmapViewOfFile(WINPR_ATTR_UNUSED LPCVOID lpBaseAddress)
{
WLog_ERR("TODO", "TODO: Implement");
return TRUE;
}
#endif

View File

@@ -0,0 +1,30 @@
/**
* WinPR: Windows Portable Runtime
* Memory Functions
*
* Copyright 2014 Marc-Andre Moreau <marcandre.moreau@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef WINPR_MEMORY_PRIVATE_H
#define WINPR_MEMORY_PRIVATE_H
#ifndef _WIN32
#include <winpr/crt.h>
#include <winpr/memory.h>
#endif
#endif /* WINPR_MEMORY_PRIVATE_H */

View File

@@ -0,0 +1,21 @@
set(MODULE_NAME "TestMemory")
set(MODULE_PREFIX "TEST_MEMORY")
disable_warnings_for_directory(${CMAKE_CURRENT_BINARY_DIR})
set(${MODULE_PREFIX}_DRIVER ${MODULE_NAME}.c)
set(${MODULE_PREFIX}_TESTS TestMemoryCreateFileMapping.c)
create_test_sourcelist(${MODULE_PREFIX}_SRCS ${${MODULE_PREFIX}_DRIVER} ${${MODULE_PREFIX}_TESTS})
add_executable(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS})
set_target_properties(${MODULE_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${TESTING_OUTPUT_DIRECTORY}")
foreach(test ${${MODULE_PREFIX}_TESTS})
get_filename_component(TestName ${test} NAME_WE)
add_test(${TestName} ${TESTING_OUTPUT_DIRECTORY}/${MODULE_NAME} ${TestName})
endforeach()
set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "WinPR/Test")

View File

@@ -0,0 +1,8 @@
#include <winpr/crt.h>
#include <winpr/memory.h>
int TestMemoryCreateFileMapping(int argc, char* argv[])
{
return 0;
}