Commit 953849f2 authored by Alexandre Julliard's avatar Alexandre Julliard

Added hack to call CreateFileW through a pointer so that we don't need

to link to kernel functions. Commented out SMB support in NtReadFile for now.
parent 01def427
......@@ -761,7 +761,8 @@ void __wine_process_init( int argc, char *argv[] )
if (!build_command_line( argv )) goto error;
/* create 32-bit module for main exe */
if (!(current_process.module = BUILTIN32_LoadExeModule( current_process.module ))) goto error;
if (!(current_process.module = BUILTIN32_LoadExeModule( current_process.module, CreateFileW )))
goto error;
stack_size = RtlImageNtHeader(current_process.module)->OptionalHeader.SizeOfStackReserve;
/* allocate main thread stack */
......
......@@ -38,7 +38,6 @@
#include "wine/server.h"
#include "async.h"
#include "ntdll_misc.h"
#include "../files/smb.h"
#include "winternl.h"
#include "winioctl.h"
......@@ -94,8 +93,8 @@ NTSTATUS WINAPI NtOpenFile(
return STATUS_OBJECT_NAME_NOT_FOUND;
/* FIXME: this calls SetLastError() -> bad */
*FileHandle = CreateFileW( &filename[strlenW(szDosDevices)], DesiredAccess, ShareAccess,
NULL, OPEN_EXISTING, 0, 0 );
*FileHandle = pCreateFileW( &filename[strlenW(szDosDevices)], DesiredAccess, ShareAccess,
NULL, OPEN_EXISTING, 0, 0 );
if (*FileHandle == INVALID_HANDLE_VALUE) return STATUS_OBJECT_NAME_NOT_FOUND;
return STATUS_SUCCESS;
}
......@@ -415,7 +414,9 @@ NTSTATUS WINAPI NtReadFile(HANDLE hFile, HANDLE hEvent,
case FD_TYPE_SMB:
FIXME("NIY-SMB\n");
close(unix_handle);
return SMB_ReadFile(hFile, buffer, length, io_status);
/* FIXME */
/* return SMB_ReadFile(hFile, buffer, length, io_status); */
return STATUS_INVALID_HANDLE;
case FD_TYPE_DEFAULT:
/* normal unix files */
......
......@@ -1313,7 +1313,7 @@ static NTSTATUS find_dll_file( const WCHAR *load_path, const WCHAR *libname,
{
if ((*pwm = find_basename_module( file_part )) != NULL) return STATUS_SUCCESS;
}
*handle = CreateFileW( filename, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, 0 );
*handle = pCreateFileW( filename, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, 0 );
return STATUS_SUCCESS;
}
......@@ -1348,7 +1348,7 @@ static NTSTATUS find_dll_file( const WCHAR *load_path, const WCHAR *libname,
strcatW( file_part, dllW );
}
if ((*pwm = find_fullname_module( filename )) != NULL) return STATUS_SUCCESS;
*handle = CreateFileW( filename, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, 0 );
*handle = pCreateFileW( filename, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, 0 );
return STATUS_SUCCESS;
overflow:
......@@ -1881,10 +1881,11 @@ PVOID WINAPI RtlImageRvaToVa( const IMAGE_NT_HEADERS *nt, HMODULE module,
*
* FIXME: this should be done differently once kernel is properly separated.
*/
HMODULE BUILTIN32_LoadExeModule( HMODULE main )
HMODULE BUILTIN32_LoadExeModule( HMODULE main, void *CreateFileW_ptr )
{
static struct builtin_load_info default_info;
pCreateFileW = CreateFileW_ptr;
if (!MODULE_GetSystemDirectory( &system_dir ))
MESSAGE( "Couldn't get system dir in process init\n");
NtCurrentTeb()->Peb->ImageBaseAddress = main;
......
......@@ -53,13 +53,21 @@ static inline HANDLE ntdll_get_process_heap(void)
{
return NtCurrentTeb()->Peb->ProcessHeap;
}
#define GetProcessHeap() ntdll_get_process_heap()
/* redefine these to make sure we don't reference kernel symbols */
#define GetProcessHeap() (NtCurrentTeb()->Peb->ProcessHeap)
#define GetCurrentProcessId() ((DWORD)NtCurrentTeb()->ClientId.UniqueProcess)
#define GetCurrentThreadId() ((DWORD)NtCurrentTeb()->ClientId.UniqueThread)
static inline RTL_USER_PROCESS_PARAMETERS* ntdll_get_process_pmts(void)
{
return NtCurrentTeb()->Peb->ProcessParameters;
}
/* hack: upcall to kernel */
extern HANDLE (WINAPI *pCreateFileW)( LPCWSTR filename, DWORD access, DWORD sharing,
LPSECURITY_ATTRIBUTES sa, DWORD creation,
DWORD attributes, HANDLE template );
/* Device IO */
/* ntdll/cdrom.c.c */
extern NTSTATUS CDROM_DeviceIoControl(DWORD clientID, HANDLE hDevice,
......
......@@ -37,6 +37,11 @@ static const WCHAR DeviceRootW[] = {'\\','\\','.','\\',0};
static const WCHAR NTDosPrefixW[] = {'\\','?','?','\\',0};
static const WCHAR UncPfxW[] = {'U','N','C','\\',0};
/* FIXME: hack! */
HANDLE (WINAPI *pCreateFileW)( LPCWSTR filename, DWORD access, DWORD sharing,
LPSECURITY_ATTRIBUTES sa, DWORD creation,
DWORD attributes, HANDLE template );
#define IS_SEPARATOR(ch) ((ch) == '\\' || (ch) == '/')
/***********************************************************************
......@@ -67,8 +72,8 @@ DOS_PATHNAME_TYPE WINAPI RtlDetermineDosPathNameType_U( PCWSTR path )
*/
BOOLEAN WINAPI RtlDoesFileExists_U(LPCWSTR file_name)
{
HANDLE handle = CreateFileW( file_name, 0, FILE_SHARE_READ|FILE_SHARE_WRITE,
NULL, OPEN_EXISTING, 0, 0 );
HANDLE handle = pCreateFileW( file_name, 0, FILE_SHARE_READ|FILE_SHARE_WRITE,
NULL, OPEN_EXISTING, 0, 0 );
if (handle == INVALID_HANDLE_VALUE) return FALSE;
NtClose( handle );
return TRUE;
......
......@@ -204,6 +204,6 @@ extern void MODULE_GetLoadOrderA( enum loadorder_type plo[], const WCHAR *app_na
const char *path, BOOL win32 );
/* relay32/builtin.c */
extern HMODULE BUILTIN32_LoadExeModule( HMODULE main );
extern HMODULE BUILTIN32_LoadExeModule( HMODULE main, void *CreateFileW_ptr );
#endif /* __WINE_MODULE_H */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment