diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/osd/asio.h | 4 | ||||
-rw-r--r-- | src/osd/uwp/uwpcompat.cpp | 100 | ||||
-rw-r--r-- | src/osd/uwp/uwpcompat.h | 105 |
3 files changed, 209 insertions, 0 deletions
diff --git a/src/osd/asio.h b/src/osd/asio.h index 1bcf610610f..10c82e69b08 100644 --- a/src/osd/asio.h +++ b/src/osd/asio.h @@ -18,7 +18,11 @@ #endif #if defined(WIN32) && !defined(_WIN32_WINNT) +#if defined(OSD_WINDOWS) #define _WIN32_WINNT 0x0501 +#else +#define _WIN32_WINNT 0x0603 +#endif #endif #define ASIO_HEADER_ONLY #define ASIO_STANDALONE diff --git a/src/osd/uwp/uwpcompat.cpp b/src/osd/uwp/uwpcompat.cpp new file mode 100644 index 00000000000..ffd6623ca7d --- /dev/null +++ b/src/osd/uwp/uwpcompat.cpp @@ -0,0 +1,100 @@ +// license:BSD-3-Clause +// copyright-holders:Brad Hughes, Miodrag Milanovic +//============================================================ +// +// uwpcompat.h - Universal Windows Platform compat forced includes +// +//============================================================ + +#include "uwpcompat.h" + +#include <errno.h> +#define WIN32_LEAN_AND_MEAN +#include <windows.h> +#undef interface + +#include "emu.h" + +extern "C" { + + int __cdecl system(const char *command) + { + return ENOENT; + } + + const char *getenv(const char *varname) + { + return osd_getenv(varname); + } + + HANDLE + WINAPI + CreateFileW( + _In_ LPCWSTR lpFileName, + _In_ DWORD dwDesiredAccess, + _In_ DWORD dwShareMode, + _In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes, + _In_ DWORD dwCreationDisposition, + _In_ DWORD dwFlagsAndAttributes, + _In_opt_ HANDLE hTemplateFile + ) + { + // TODO: Handle other arguments that go into last param (pCreateExParams) + return CreateFile2((wchar_t*)lpFileName, dwDesiredAccess, dwShareMode, dwCreationDisposition, NULL); + } + + HANDLE + WINAPI + CreateFileA( + _In_ LPCSTR lpFileName, + _In_ DWORD dwDesiredAccess, + _In_ DWORD dwShareMode, + _In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes, + _In_ DWORD dwCreationDisposition, + _In_ DWORD dwFlagsAndAttributes, + _In_opt_ HANDLE hTemplateFile + ) + { + wchar_t filepath[MAX_PATH + 1]; + if (MultiByteToWideChar(CP_ACP, 0, lpFileName, strlen(lpFileName), filepath, MAX_PATH)) + return CreateFileW(filepath, dwDesiredAccess, dwShareMode, lpSecurityAttributes, dwCreationDisposition, dwFlagsAndAttributes, hTemplateFile); + + SetLastError(E_FAIL); + return INVALID_HANDLE_VALUE; + } + + DWORD WINAPI GetTickCount(void) + { + return osd_ticks(); + } + + HMODULE WINAPI LoadLibraryExA( + _In_ LPCSTR lpLibFileName, + _Reserved_ HANDLE hFile, + _In_ DWORD dwFlags + ) + { + wchar_t libfile_wide[MAX_PATH + 1]; + if (MultiByteToWideChar(CP_ACP, 0, lpLibFileName, strlen(lpLibFileName), libfile_wide, MAX_PATH)) + return LoadPackagedLibrary(libfile_wide, 0); + + return nullptr; + } + + HMODULE WINAPI LoadLibraryExW( + _In_ LPCWSTR lpLibFileName, + _Reserved_ HANDLE hFile, + _In_ DWORD dwFlags + ) + { + return LoadPackagedLibrary(lpLibFileName, 0); + } + + DWORD WINAPI GetFileSize( + _In_ HANDLE hFile, + _Out_opt_ LPDWORD lpFileSizeHigh + ) + { + return 0; + } +} diff --git a/src/osd/uwp/uwpcompat.h b/src/osd/uwp/uwpcompat.h new file mode 100644 index 00000000000..f155e225b8c --- /dev/null +++ b/src/osd/uwp/uwpcompat.h @@ -0,0 +1,105 @@ +// license:BSD-3-Clause +// copyright-holders:Brad Hughes, Miodrag Milanovic +//============================================================ +// +// uwpcompat.h - Universal Windows Platform compat forced includes +// +//============================================================ + +#ifndef __UWPCOMPAT_H__ +#define __UWPCOMPAT_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +#define WIN32_LEAN_AND_MEAN +#include <windows.h> +#include <stdio.h> + +int system(const char *command); + +const char *getenv(const char *varname); + +HANDLE +WINAPI +CreateFileA( + _In_ LPCSTR lpFileName, + _In_ DWORD dwDesiredAccess, + _In_ DWORD dwShareMode, + _In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes, + _In_ DWORD dwCreationDisposition, + _In_ DWORD dwFlagsAndAttributes, + _In_opt_ HANDLE hTemplateFile + ); + +HANDLE +WINAPI +CreateFileW( + _In_ LPCWSTR lpFileName, + _In_ DWORD dwDesiredAccess, + _In_ DWORD dwShareMode, + _In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes, + _In_ DWORD dwCreationDisposition, + _In_ DWORD dwFlagsAndAttributes, + _In_opt_ HANDLE hTemplateFile + ); + +#ifdef UNICODE +#define CreateFile CreateFileW +#else +#define CreateFile CreateFileA +#endif // !UNICODE + +BOOL WINAPI GetVersionEx( + _Inout_ LPOSVERSIONINFO lpVersionInfo +); + +DWORD WINAPI GetTickCount(void); + +FILE *_popen( + const char *command, + const char *mode + ); + +int _pclose( + FILE *stream); + +_Ret_maybenull_ +HMODULE +WINAPI +LoadLibraryExA( + _In_ LPCSTR lpLibFileName, + _Reserved_ HANDLE hFile, + _In_ DWORD dwFlags + ); + +_Ret_maybenull_ +HMODULE +WINAPI +LoadLibraryExW( + _In_ LPCWSTR lpLibFileName, + _Reserved_ HANDLE hFile, + _In_ DWORD dwFlags + ); + +DWORD +WINAPI +GetFileSize( + _In_ HANDLE hFile, + _Out_opt_ LPDWORD lpFileSizeHigh +); + +#ifdef UNICODE +#define LoadLibraryEx LoadLibraryExW +#else +#define LoadLibraryEx LoadLibraryExA +#endif // !UNICODE + +#ifdef __cplusplus +} +#endif + +#endif // __UWPCOMPAT_H__ + + |