2021-08-31 09:24:10 +00:00
|
|
|
/*
|
|
|
|
* WoW64 syscall wrapping
|
|
|
|
*
|
|
|
|
* Copyright 2021 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 "ntstatus.h"
|
|
|
|
#define WIN32_NO_STATUS
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "winnt.h"
|
|
|
|
#include "winternl.h"
|
|
|
|
#include "wow64win_private.h"
|
|
|
|
|
|
|
|
static void * const win32_syscalls[] =
|
|
|
|
{
|
2023-11-16 13:09:55 +00:00
|
|
|
#define SYSCALL_ENTRY(id,name,args) wow64_ ## name,
|
|
|
|
ALL_SYSCALLS32
|
2021-08-31 09:24:10 +00:00
|
|
|
#undef SYSCALL_ENTRY
|
|
|
|
};
|
|
|
|
|
2023-11-17 09:00:48 +00:00
|
|
|
static BYTE arguments[ARRAY_SIZE(win32_syscalls)] =
|
2021-08-31 09:24:10 +00:00
|
|
|
{
|
2023-11-17 09:00:48 +00:00
|
|
|
#define SYSCALL_ENTRY(id,name,args) args,
|
2023-11-16 13:09:55 +00:00
|
|
|
ALL_SYSCALLS32
|
2021-08-31 09:24:10 +00:00
|
|
|
#undef SYSCALL_ENTRY
|
|
|
|
};
|
|
|
|
|
2023-11-17 09:00:48 +00:00
|
|
|
const SYSTEM_SERVICE_TABLE sdwhwin32 =
|
2021-08-31 09:24:10 +00:00
|
|
|
{
|
|
|
|
(ULONG_PTR *)win32_syscalls,
|
2023-11-17 09:00:48 +00:00
|
|
|
NULL,
|
2021-08-31 09:24:10 +00:00
|
|
|
ARRAY_SIZE(win32_syscalls),
|
2023-11-17 09:00:48 +00:00
|
|
|
arguments
|
2021-08-31 09:24:10 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
BOOL WINAPI DllMain( HINSTANCE inst, DWORD reason, void *reserved )
|
|
|
|
{
|
2022-07-30 13:44:58 +00:00
|
|
|
if (reason != DLL_PROCESS_ATTACH) return TRUE;
|
|
|
|
LdrDisableThreadCalloutsForDll( inst );
|
|
|
|
NtCurrentTeb()->Peb->KernelCallbackTable = user_callbacks;
|
2021-08-31 09:24:10 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|