Commit d75aed2c authored by Dmitry Timoshkov's avatar Dmitry Timoshkov Committed by Alexandre Julliard

Convert most of the file APIs to Unicode.

parent ad0b42a0
...@@ -20,7 +20,9 @@ ...@@ -20,7 +20,9 @@
#include "wine/winbase16.h" #include "wine/winbase16.h"
#include "winbase.h" #include "winbase.h"
#include "winerror.h"
#include "wownt32.h" #include "wownt32.h"
#include "ntddk.h"
#include "file.h" #include "file.h"
#include "miscemu.h" #include "miscemu.h"
#include "stackframe.h" #include "stackframe.h"
...@@ -319,17 +321,35 @@ DWORD WINAPI LoadLibraryEx32W16( LPCSTR lpszLibFile, DWORD hFile, DWORD dwFlags ...@@ -319,17 +321,35 @@ DWORD WINAPI LoadLibraryEx32W16( LPCSTR lpszLibFile, DWORD hFile, DWORD dwFlags
HMODULE hModule; HMODULE hModule;
DOS_FULL_NAME full_name; DOS_FULL_NAME full_name;
DWORD mutex_count; DWORD mutex_count;
UNICODE_STRING libfileW;
LPCWSTR filenameW;
static const WCHAR dllW[] = {'.','D','L','L',0};
if (!lpszLibFile)
{
SetLastError(ERROR_INVALID_PARAMETER);
return 0;
}
if (!RtlCreateUnicodeStringFromAsciiz(&libfileW, lpszLibFile))
{
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
return 0;
}
/* if the file can not be found, call LoadLibraryExA anyway, since it might be /* if the file can not be found, call LoadLibraryExA anyway, since it might be
a buildin module. This case is handled in MODULE_LoadLibraryExA */ a buildin module. This case is handled in MODULE_LoadLibraryExA */
if ( ! DIR_SearchPath ( NULL, lpszLibFile, ".DLL", &full_name, FALSE ) ) { filenameW = libfileW.Buffer;
strcpy ( full_name.short_name, lpszLibFile ); if ( DIR_SearchPath( NULL, filenameW, dllW, &full_name, FALSE ) )
} filenameW = full_name.short_name;
ReleaseThunkLock( &mutex_count ); ReleaseThunkLock( &mutex_count );
hModule = LoadLibraryExA( full_name.short_name, (HANDLE)hFile, dwFlags ); hModule = LoadLibraryExW( filenameW, (HANDLE)hFile, dwFlags );
RestoreThunkLock( mutex_count ); RestoreThunkLock( mutex_count );
RtlFreeUnicodeString(&libfileW);
return (DWORD)hModule; return (DWORD)hModule;
} }
......
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#ifdef HAVE_SYS_ERRNO_H #ifdef HAVE_SYS_ERRNO_H
#include <sys/errno.h> #include <sys/errno.h>
#endif #endif
#include "wine/unicode.h"
#include "wine/debug.h" #include "wine/debug.h"
#include "wine/server.h" #include "wine/server.h"
#include "ntdll_misc.h" #include "ntdll_misc.h"
...@@ -60,9 +61,8 @@ NTSTATUS WINAPI NtOpenFile( ...@@ -60,9 +61,8 @@ NTSTATUS WINAPI NtOpenFile(
ULONG ShareAccess, ULONG ShareAccess,
ULONG OpenOptions) ULONG OpenOptions)
{ {
ULONG len = 0; LPWSTR filename;
PSTR filename; static const WCHAR szDosDevices[] = {'\\','D','o','s','D','e','v','i','c','e','s','\\',0};
CHAR szDosDevices[] = "\\DosDevices\\";
DOS_FULL_NAME full_name; DOS_FULL_NAME full_name;
NTSTATUS r; NTSTATUS r;
...@@ -79,20 +79,14 @@ NTSTATUS WINAPI NtOpenFile( ...@@ -79,20 +79,14 @@ NTSTATUS WINAPI NtOpenFile(
return STATUS_OBJECT_NAME_NOT_FOUND; return STATUS_OBJECT_NAME_NOT_FOUND;
} }
/* create an ascii string from the unicode filename */ filename = ObjectAttributes->ObjectName->Buffer;
RtlUnicodeToMultiByteSize( &len, ObjectAttributes->ObjectName->Buffer,
ObjectAttributes->ObjectName->Length );
filename = RtlAllocateHeap( GetProcessHeap(), 0, len + 1);
RtlUnicodeToMultiByteN(filename, len, NULL, ObjectAttributes->ObjectName->Buffer,
ObjectAttributes->ObjectName->Length );
filename[len]=0;
/* FIXME: DOSFS stuff should call here, not vice-versa */ /* FIXME: DOSFS stuff should call here, not vice-versa */
if(strncmp(filename, szDosDevices, strlen(szDosDevices))) if(strncmpW(filename, szDosDevices, strlenW(szDosDevices)))
return STATUS_OBJECT_NAME_NOT_FOUND; return STATUS_OBJECT_NAME_NOT_FOUND;
/* FIXME: this calls SetLastError() -> bad */ /* FIXME: this calls SetLastError() -> bad */
if(!DOSFS_GetFullName(&filename[strlen(szDosDevices)], TRUE, if(!DOSFS_GetFullName(&filename[strlenW(szDosDevices)], TRUE,
&full_name)) &full_name))
return STATUS_OBJECT_NAME_NOT_FOUND; return STATUS_OBJECT_NAME_NOT_FOUND;
...@@ -105,7 +99,7 @@ NTSTATUS WINAPI NtOpenFile( ...@@ -105,7 +99,7 @@ NTSTATUS WINAPI NtOpenFile(
req->sharing = ShareAccess; req->sharing = ShareAccess;
req->create = OPEN_EXISTING; req->create = OPEN_EXISTING;
req->attrs = 0; req->attrs = 0;
req->drive_type = GetDriveTypeA( full_name.short_name ); req->drive_type = GetDriveTypeW( full_name.short_name );
wine_server_add_data( req, full_name.long_name, strlen(full_name.long_name) ); wine_server_add_data( req, full_name.long_name, strlen(full_name.long_name) );
SetLastError(0); SetLastError(0);
r = wine_server_call( req ); r = wine_server_call( req );
......
...@@ -32,16 +32,18 @@ ...@@ -32,16 +32,18 @@
#include "miscemu.h" #include "miscemu.h"
#include "msdos.h" #include "msdos.h"
#include "file.h" #include "file.h"
#include "wine/unicode.h"
#include "wine/debug.h" #include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(int21); WINE_DEFAULT_DEBUG_CHANNEL(int21);
void WINAPI DOSVM_Int21Handler_Ioctl( CONTEXT86 *context ) void WINAPI DOSVM_Int21Handler_Ioctl( CONTEXT86 *context )
{ {
static const WCHAR emmxxxx0W[] = {'E','M','M','X','X','X','X','0',0};
const DOS_DEVICE *dev = DOSFS_GetDeviceByHandle( const DOS_DEVICE *dev = DOSFS_GetDeviceByHandle(
DosFileHandleToWin32Handle(BX_reg(context)) ); DosFileHandleToWin32Handle(BX_reg(context)) );
if (dev && !strcasecmp( dev->name, "EMMXXXX0" )) { if (dev && !strcmpiW( dev->name, emmxxxx0W )) {
EMS_Ioctl_Handler(context); EMS_Ioctl_Handler(context);
return; return;
} }
......
...@@ -1392,7 +1392,7 @@ static HANDLE SMB_RegisterFile( int fd, USHORT tree_id, USHORT user_id, USHORT d ...@@ -1392,7 +1392,7 @@ static HANDLE SMB_RegisterFile( int fd, USHORT tree_id, USHORT user_id, USHORT d
return ret; return ret;
} }
HANDLE WINAPI SMB_CreateFileA( LPCSTR uncname, DWORD access, DWORD sharing, HANDLE WINAPI SMB_CreateFileW( LPCWSTR uncname, DWORD access, DWORD sharing,
LPSECURITY_ATTRIBUTES sa, DWORD creation, LPSECURITY_ATTRIBUTES sa, DWORD creation,
DWORD attributes, HANDLE template ) DWORD attributes, HANDLE template )
{ {
...@@ -1400,12 +1400,14 @@ HANDLE WINAPI SMB_CreateFileA( LPCSTR uncname, DWORD access, DWORD sharing, ...@@ -1400,12 +1400,14 @@ HANDLE WINAPI SMB_CreateFileA( LPCSTR uncname, DWORD access, DWORD sharing,
USHORT tree_id=0, user_id=0, dialect=0, file_id=0; USHORT tree_id=0, user_id=0, dialect=0, file_id=0;
LPSTR name,host,share,file; LPSTR name,host,share,file;
HANDLE handle = INVALID_HANDLE_VALUE; HANDLE handle = INVALID_HANDLE_VALUE;
INT len;
name = HeapAlloc(GetProcessHeap(),0,lstrlenA(uncname)); len = WideCharToMultiByte(CP_ACP, 0, uncname, -1, NULL, 0, NULL, NULL);
name = HeapAlloc(GetProcessHeap(), 0, len);
if(!name) if(!name)
return handle; return handle;
lstrcpyA(name,uncname); WideCharToMultiByte(CP_ACP, 0, uncname, -1, name, len, NULL, NULL);
if( !UNC_SplitName(name, &host, &share, &file) ) if( !UNC_SplitName(name, &host, &share, &file) )
{ {
...@@ -1545,21 +1547,22 @@ BOOL WINAPI SMB_ReadFile(HANDLE hFile, LPVOID buffer, DWORD bytesToRead, LPDWORD ...@@ -1545,21 +1547,22 @@ BOOL WINAPI SMB_ReadFile(HANDLE hFile, LPVOID buffer, DWORD bytesToRead, LPDWORD
return r; return r;
} }
SMB_DIR* WINAPI SMB_FindFirst(LPCSTR name) SMB_DIR* WINAPI SMB_FindFirst(LPCWSTR name)
{ {
int fd = -1; int fd = -1;
LPSTR host,share,file; LPSTR host,share,file;
USHORT tree_id=0, user_id=0, dialect=0; USHORT tree_id=0, user_id=0, dialect=0;
SMB_DIR *ret = NULL; SMB_DIR *ret = NULL;
LPSTR filename; LPSTR filename;
DWORD len;
TRACE("Find %s\n",debugstr_a(name)); TRACE("Find %s\n",debugstr_w(name));
filename = HeapAlloc(GetProcessHeap(),0,lstrlenA(name)+1); len = WideCharToMultiByte( CP_ACP, 0, name, -1, NULL, 0, NULL, NULL );
filename = HeapAlloc(GetProcessHeap(),0,len);
if(!filename) if(!filename)
return ret; return ret;
WideCharToMultiByte( CP_ACP, 0, name, -1, filename, len, NULL, NULL );
lstrcpyA(filename,name);
if( !UNC_SplitName(filename, &host, &share, &file) ) if( !UNC_SplitName(filename, &host, &share, &file) )
goto done; goto done;
...@@ -1587,7 +1590,7 @@ done: ...@@ -1587,7 +1590,7 @@ done:
} }
BOOL WINAPI SMB_FindNext(SMB_DIR *dir, WIN32_FIND_DATAA *data ) BOOL WINAPI SMB_FindNext(SMB_DIR *dir, WIN32_FIND_DATAW *data )
{ {
unsigned char *ent; unsigned char *ent;
int len, fnlen; int len, fnlen;
...@@ -1613,14 +1616,16 @@ BOOL WINAPI SMB_FindNext(SMB_DIR *dir, WIN32_FIND_DATAA *data ) ...@@ -1613,14 +1616,16 @@ BOOL WINAPI SMB_FindNext(SMB_DIR *dir, WIN32_FIND_DATAA *data )
/* copy the long filename */ /* copy the long filename */
fnlen = SMB_GETDWORD(&ent[0x3c]); fnlen = SMB_GETDWORD(&ent[0x3c]);
if ( fnlen > (sizeof data->cFileName/sizeof(CHAR)) ) if ( fnlen > (sizeof data->cFileName/sizeof(WCHAR)) )
return FALSE; return FALSE;
memcpy(data->cFileName, &ent[0x5e], fnlen); MultiByteToWideChar( CP_ACP, 0, &ent[0x5e], fnlen, data->cFileName,
sizeof(data->cFileName)/sizeof(WCHAR) );
/* copy the short filename */ /* copy the short filename */
if ( ent[0x44] > (sizeof data->cAlternateFileName/sizeof(CHAR)) ) if ( ent[0x44] > (sizeof data->cAlternateFileName/sizeof(WCHAR)) )
return FALSE; return FALSE;
memcpy(data->cAlternateFileName, &ent[0x5e + len], ent[0x44]); MultiByteToWideChar( CP_ACP, 0, &ent[0x5e + len], ent[0x44], data->cAlternateFileName,
sizeof(data->cAlternateFileName)/sizeof(WCHAR) );
dir->current++; dir->current++;
......
...@@ -96,7 +96,7 @@ ...@@ -96,7 +96,7 @@
#define TRANS2_FIND_NEXT2 0x02 #define TRANS2_FIND_NEXT2 0x02
extern BOOL WINAPI SMB_ReadFile(HANDLE hFile, LPVOID buffer, DWORD bytesToRead, LPDWORD bytesRead, LPOVERLAPPED lpOverlapped); extern BOOL WINAPI SMB_ReadFile(HANDLE hFile, LPVOID buffer, DWORD bytesToRead, LPDWORD bytesRead, LPOVERLAPPED lpOverlapped);
extern HANDLE WINAPI SMB_CreateFileA( LPCSTR filename, DWORD access, DWORD sharing, extern HANDLE WINAPI SMB_CreateFileW( LPCWSTR filename, DWORD access, DWORD sharing,
LPSECURITY_ATTRIBUTES sa, DWORD creation, LPSECURITY_ATTRIBUTES sa, DWORD creation,
DWORD attributes, HANDLE template ); DWORD attributes, HANDLE template );
...@@ -108,8 +108,8 @@ typedef struct tagSMB_DIR ...@@ -108,8 +108,8 @@ typedef struct tagSMB_DIR
unsigned char *buffer; unsigned char *buffer;
} SMB_DIR; } SMB_DIR;
extern SMB_DIR* WINAPI SMB_FindFirst(LPCSTR filename); extern SMB_DIR* WINAPI SMB_FindFirst(LPCWSTR filename);
extern BOOL WINAPI SMB_FindNext(SMB_DIR *dir, WIN32_FIND_DATAA *data ); extern BOOL WINAPI SMB_FindNext(SMB_DIR *dir, WIN32_FIND_DATAW *data );
extern BOOL WINAPI SMB_CloseDir(SMB_DIR *dir); extern BOOL WINAPI SMB_CloseDir(SMB_DIR *dir);
#endif /* __INC_SMB__ */ #endif /* __INC_SMB__ */
...@@ -39,15 +39,17 @@ extern int DRIVE_IsValid( int drive ); ...@@ -39,15 +39,17 @@ extern int DRIVE_IsValid( int drive );
extern int DRIVE_GetCurrentDrive(void); extern int DRIVE_GetCurrentDrive(void);
extern int DRIVE_SetCurrentDrive( int drive ); extern int DRIVE_SetCurrentDrive( int drive );
extern int DRIVE_FindDriveRoot( const char **path ); extern int DRIVE_FindDriveRoot( const char **path );
extern int DRIVE_FindDriveRootW( LPCWSTR *path );
extern const char * DRIVE_GetRoot( int drive ); extern const char * DRIVE_GetRoot( int drive );
extern const char * DRIVE_GetDosCwd( int drive ); extern LPCWSTR DRIVE_GetDosCwd( int drive );
extern const char * DRIVE_GetUnixCwd( int drive ); extern const char * DRIVE_GetUnixCwd( int drive );
extern const char * DRIVE_GetDevice( int drive ); extern const char * DRIVE_GetDevice( int drive );
extern const char * DRIVE_GetLabel( int drive ); extern LPCWSTR DRIVE_GetLabel( int drive );
extern DWORD DRIVE_GetSerialNumber( int drive ); extern DWORD DRIVE_GetSerialNumber( int drive );
extern int DRIVE_SetSerialNumber( int drive, DWORD serial ); extern int DRIVE_SetSerialNumber( int drive, DWORD serial );
extern UINT DRIVE_GetFlags( int drive ); extern UINT DRIVE_GetFlags( int drive );
extern int DRIVE_Chdir( int drive, const char *path ); extern UINT DRIVE_GetCodepage( int drive );
extern int DRIVE_Chdir( int drive, LPCWSTR path );
extern int DRIVE_Disable( int drive ); extern int DRIVE_Disable( int drive );
extern int DRIVE_Enable( int drive ); extern int DRIVE_Enable( int drive );
extern int DRIVE_SetLogicalMapping ( int existing_drive, int new_drive ); extern int DRIVE_SetLogicalMapping ( int existing_drive, int new_drive );
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include <sys/types.h> #include <sys/types.h>
#include "winbase.h" #include "winbase.h"
#include "wine/windef16.h" /* HFILE16 */ #include "wine/windef16.h" /* HFILE16 */
#include "wine/unicode.h"
#define MAX_PATHNAME_LEN 1024 #define MAX_PATHNAME_LEN 1024
...@@ -33,7 +34,7 @@ ...@@ -33,7 +34,7 @@
typedef struct typedef struct
{ {
char long_name[MAX_PATHNAME_LEN]; /* Long pathname in Unix format */ char long_name[MAX_PATHNAME_LEN]; /* Long pathname in Unix format */
char short_name[MAX_PATHNAME_LEN]; /* Short pathname in DOS 8.3 format */ WCHAR short_name[MAX_PATHNAME_LEN]; /* Short pathname in DOS 8.3 format */
int drive; int drive;
} DOS_FULL_NAME; } DOS_FULL_NAME;
...@@ -42,8 +43,9 @@ typedef struct ...@@ -42,8 +43,9 @@ typedef struct
/* DOS device descriptor */ /* DOS device descriptor */
typedef struct typedef struct
{ {
char *name; const WCHAR name[9];
int flags; int flags;
UINT codepage;
} DOS_DEVICE; } DOS_DEVICE;
/* locale-independent case conversion */ /* locale-independent case conversion */
...@@ -64,6 +66,12 @@ inline static int FILE_contains_path (LPCSTR name) ...@@ -64,6 +66,12 @@ inline static int FILE_contains_path (LPCSTR name)
strchr (name, '/') || strchr (name, '\\')); strchr (name, '/') || strchr (name, '\\'));
} }
inline static int FILE_contains_pathW (LPCWSTR name)
{
return ((*name && (name[1] == ':')) ||
strchrW (name, '/') || strchrW (name, '\\'));
}
/* files/file.c */ /* files/file.c */
extern mode_t FILE_umask; extern mode_t FILE_umask;
extern int FILE_strcasecmp( const char *str1, const char *str2 ); extern int FILE_strcasecmp( const char *str1, const char *str2 );
...@@ -86,21 +94,20 @@ extern UINT DIR_GetWindowsUnixDir( LPSTR path, UINT count ); ...@@ -86,21 +94,20 @@ extern UINT DIR_GetWindowsUnixDir( LPSTR path, UINT count );
extern UINT DIR_GetSystemUnixDir( LPSTR path, UINT count ); extern UINT DIR_GetSystemUnixDir( LPSTR path, UINT count );
extern DWORD DIR_SearchAlternatePath( LPCSTR dll_path, LPCSTR name, LPCSTR ext, extern DWORD DIR_SearchAlternatePath( LPCSTR dll_path, LPCSTR name, LPCSTR ext,
DWORD buflen, LPSTR buffer, LPSTR *lastpart); DWORD buflen, LPSTR buffer, LPSTR *lastpart);
extern DWORD DIR_SearchPath( LPCSTR path, LPCSTR name, LPCSTR ext, extern DWORD DIR_SearchPath( LPCWSTR path, LPCWSTR name, LPCWSTR ext,
DOS_FULL_NAME *full_name, BOOL win32 ); DOS_FULL_NAME *full_name, BOOL win32 );
/* files/dos_fs.c */ /* files/dos_fs.c */
extern void DOSFS_UnixTimeToFileTime( time_t unixtime, LPFILETIME ft, extern void DOSFS_UnixTimeToFileTime( time_t unixtime, LPFILETIME ft,
DWORD remainder ); DWORD remainder );
extern time_t DOSFS_FileTimeToUnixTime( const FILETIME *ft, DWORD *remainder ); extern time_t DOSFS_FileTimeToUnixTime( const FILETIME *ft, DWORD *remainder );
extern BOOL DOSFS_ToDosFCBFormat( LPCSTR name, LPSTR buffer ); extern BOOL DOSFS_ToDosFCBFormat( LPCWSTR name, LPWSTR buffer );
extern const DOS_DEVICE *DOSFS_GetDevice( const char *name ); extern const DOS_DEVICE *DOSFS_GetDevice( LPCWSTR name );
extern const DOS_DEVICE *DOSFS_GetDeviceByHandle( HANDLE hFile ); extern const DOS_DEVICE *DOSFS_GetDeviceByHandle( HANDLE hFile );
extern HANDLE DOSFS_OpenDevice( const char *name, DWORD access, DWORD attributes, LPSECURITY_ATTRIBUTES sa); extern HANDLE DOSFS_OpenDevice( LPCWSTR name, DWORD access, DWORD attributes, LPSECURITY_ATTRIBUTES sa);
extern BOOL DOSFS_FindUnixName( LPCSTR path, LPCSTR name, LPSTR long_buf, extern BOOL DOSFS_FindUnixName( const DOS_FULL_NAME *path, LPCWSTR name, char *long_buf,
INT long_len, LPSTR short_buf, INT long_len, LPWSTR short_buf, BOOL ignore_case );
BOOL ignore_case ); extern BOOL DOSFS_GetFullName( LPCWSTR name, BOOL check_last,
extern BOOL DOSFS_GetFullName( LPCSTR name, BOOL check_last,
DOS_FULL_NAME *full ); DOS_FULL_NAME *full );
extern int DOSFS_FindNext( const char *path, const char *short_mask, extern int DOSFS_FindNext( const char *path, const char *short_mask,
const char *long_mask, int drive, BYTE attr, const char *long_mask, int drive, BYTE attr,
...@@ -109,12 +116,12 @@ extern int DOSFS_FindNext( const char *path, const char *short_mask, ...@@ -109,12 +116,12 @@ extern int DOSFS_FindNext( const char *path, const char *short_mask,
/* profile.c */ /* profile.c */
extern int PROFILE_LoadWineIni(void); extern int PROFILE_LoadWineIni(void);
extern void PROFILE_UsageWineIni(void); extern void PROFILE_UsageWineIni(void);
extern int PROFILE_GetWineIniString( const char *section, const char *key_name, extern int PROFILE_GetWineIniString( LPCWSTR section, LPCWSTR key_name,
const char *def, char *buffer, int len ); LPCWSTR def, LPWSTR buffer, int len );
extern int PROFILE_GetWineIniBool( char const *section, char const *key_name, int def ); extern int PROFILE_GetWineIniBool( LPCWSTR section, LPCWSTR key_name, int def );
/* win32/device.c */ /* win32/device.c */
extern HANDLE DEVICE_Open( LPCSTR filename, DWORD access, LPSECURITY_ATTRIBUTES sa ); extern HANDLE DEVICE_Open( LPCWSTR filename, DWORD access, LPSECURITY_ATTRIBUTES sa );
/* ntdll/cdrom.c.c */ /* ntdll/cdrom.c.c */
extern BOOL CDROM_DeviceIoControl(DWORD clientID, HANDLE hDevice, DWORD dwIoControlCode, extern BOOL CDROM_DeviceIoControl(DWORD clientID, HANDLE hDevice, DWORD dwIoControlCode,
......
...@@ -290,8 +290,9 @@ static TDB *TASK_Create( NE_MODULE *pModule, UINT16 cmdShow, TEB *teb, LPCSTR cm ...@@ -290,8 +290,9 @@ static TDB *TASK_Create( NE_MODULE *pModule, UINT16 cmdShow, TEB *teb, LPCSTR cm
pTask->teb = teb; pTask->teb = teb;
pTask->curdrive = DRIVE_GetCurrentDrive() | 0x80; pTask->curdrive = DRIVE_GetCurrentDrive() | 0x80;
strcpy( pTask->curdir, "\\" ); strcpy( pTask->curdir, "\\" );
lstrcpynA( pTask->curdir + 1, DRIVE_GetDosCwd( DRIVE_GetCurrentDrive() ), WideCharToMultiByte(CP_ACP, 0, DRIVE_GetDosCwd(DRIVE_GetCurrentDrive()), -1,
sizeof(pTask->curdir) - 1 ); pTask->curdir + 1, sizeof(pTask->curdir) - 1, NULL, NULL);
pTask->curdir[sizeof(pTask->curdir) - 1] = 0; /* ensure 0 termination */
/* Create the thunks block */ /* Create the thunks block */
......
...@@ -435,17 +435,19 @@ static void DOSCONF_Parse(char *menuname) ...@@ -435,17 +435,19 @@ static void DOSCONF_Parse(char *menuname)
int DOSCONF_ReadConfig(void) int DOSCONF_ReadConfig(void)
{ {
char buffer[256]; WCHAR filename[MAX_PATH];
DOS_FULL_NAME fullname; DOS_FULL_NAME fullname;
char *filename, *menuname; WCHAR *p;
int ret = 1; int ret = 1;
static const WCHAR wineW[] = {'w','i','n','e',0};
static const WCHAR config_sysW[] = {'c','o','n','f','i','g','.','s','y','s',0};
static const WCHAR empty_strW[] = { 0 };
PROFILE_GetWineIniString( "wine", "config.sys", "", buffer, sizeof(buffer) ); PROFILE_GetWineIniString( wineW, config_sysW, empty_strW, filename, MAX_PATH );
if (!(filename = strtok(buffer, ","))) return ret; if ((p = strchrW(filename, ','))) *p = 0;
menuname = strtok(NULL, ","); if (!filename[0]) return ret;
DOSFS_GetFullName(filename, FALSE, &fullname); DOSFS_GetFullName(filename, FALSE, &fullname);
if (menuname) menu_default = strdup(menuname);
if ((cfg_fd = fopen(fullname.long_name, "r"))) if ((cfg_fd = fopen(fullname.long_name, "r")))
{ {
DOSCONF_Parse(NULL); DOSCONF_Parse(NULL);
...@@ -453,10 +455,9 @@ int DOSCONF_ReadConfig(void) ...@@ -453,10 +455,9 @@ int DOSCONF_ReadConfig(void)
} }
else else
{ {
MESSAGE("Couldn't open config.sys file given as \"%s\" in" \ MESSAGE("Couldn't open config.sys file given as %s in" \
" wine.conf or .winerc, section [wine] !\n", filename); " wine.conf or .winerc, section [wine] !\n", debugstr_w(filename));
ret = 0; ret = 0;
} }
if (menu_default) free(menu_default);
return ret; return ret;
} }
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include "miscemu.h" #include "miscemu.h"
#include "msdos.h" #include "msdos.h"
#include "file.h" #include "file.h"
#include "wine/unicode.h"
#include "wine/debug.h" #include "wine/debug.h"
/********************************************************************** /**********************************************************************
...@@ -74,16 +75,21 @@ void WINAPI INT_Int11Handler( CONTEXT86 *context ) ...@@ -74,16 +75,21 @@ void WINAPI INT_Int11Handler( CONTEXT86 *context )
for (x=0; x < 9; x++) for (x=0; x < 9; x++)
{ {
char temp[16],name[16]; WCHAR temp[16];
WCHAR comW[] = {'C','O','M','?',0};
WCHAR lptW[] = {'L','P','T','?',0};
static const WCHAR serialportsW[] = {'s','e','r','i','a','l','p','o','r','t','s',0};
static const WCHAR parallelportsW[] = {'p','a','r','a','l','l','e','l','p','o','r','t','s',0};
static const WCHAR asteriskW[] = {'*',0};
sprintf(name,"COM%d",x+1); comW[3] = '0' + x;
PROFILE_GetWineIniString("serialports",name,"*",temp,sizeof temp); PROFILE_GetWineIniString(serialportsW, comW, asteriskW, temp, 16);
if(strcmp(temp,"*")) if(strcmpW(temp, asteriskW))
serialports++; serialports++;
sprintf(name,"LPT%d",x+1); lptW[3] = '0' + x;
PROFILE_GetWineIniString("parallelports",name,"*",temp,sizeof temp); PROFILE_GetWineIniString(parallelportsW, lptW, asteriskW, temp, 16);
if(strcmp(temp,"*")) if(strcmpW(temp, asteriskW))
parallelports++; parallelports++;
} }
if (serialports > 7) /* 3 bits -- maximum value = 7 */ if (serialports > 7) /* 3 bits -- maximum value = 7 */
......
...@@ -57,6 +57,7 @@ ...@@ -57,6 +57,7 @@
#include "msdos.h" #include "msdos.h"
#include "miscemu.h" #include "miscemu.h"
#include "task.h" #include "task.h"
#include "wine/unicode.h"
#include "wine/debug.h" #include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(int21); WINE_DEFAULT_DEBUG_CHANNEL(int21);
...@@ -428,30 +429,37 @@ static void INT21_ParseFileNameIntoFCB( CONTEXT86 *context ) ...@@ -428,30 +429,37 @@ static void INT21_ParseFileNameIntoFCB( CONTEXT86 *context )
CTX_SEG_OFF_TO_LIN(context, context->SegDs, context->Esi ); CTX_SEG_OFF_TO_LIN(context, context->SegDs, context->Esi );
char *fcb = char *fcb =
CTX_SEG_OFF_TO_LIN(context, context->SegEs, context->Edi ); CTX_SEG_OFF_TO_LIN(context, context->SegEs, context->Edi );
char *buffer, *s, *d; char *s;
WCHAR *buffer;
WCHAR fcbW[12];
INT buffer_len, len;
AL_reg(context) = 0xff; /* failed */ AL_reg(context) = 0xff; /* failed */
TRACE("filename: '%s'\n", filename); TRACE("filename: '%s'\n", filename);
buffer = HeapAlloc( GetProcessHeap(), 0, strlen(filename) + 1);
s = filename; s = filename;
d = buffer; len = 0;
while (*s) while (*s)
{ {
if ((*s != ' ') && (*s != '\r') && (*s != '\n')) if ((*s != ' ') && (*s != '\r') && (*s != '\n'))
*d++ = *s++; {
s++;
len++;
}
else else
break; break;
} }
*d = '\0'; buffer_len = MultiByteToWideChar(CP_OEMCP, 0, filename, len, NULL, 0);
DOSFS_ToDosFCBFormat(buffer, fcb + 1); buffer = HeapAlloc( GetProcessHeap(), 0, (buffer_len + 1) * sizeof(WCHAR));
len = MultiByteToWideChar(CP_OEMCP, 0, filename, len, buffer, buffer_len);
buffer[len] = 0;
DOSFS_ToDosFCBFormat(buffer, fcbW);
HeapFree(GetProcessHeap(), 0, buffer);
WideCharToMultiByte(CP_OEMCP, 0, fcbW, 12, fcb + 1, 12, NULL, NULL);
*fcb = 0; *fcb = 0;
TRACE("FCB: '%s'\n", ((CHAR *)fcb + 1)); TRACE("FCB: '%s'\n", fcb + 1);
HeapFree( GetProcessHeap(), 0, buffer);
AL_reg(context) = AL_reg(context) =
((strchr(filename, '*')) || (strchr(filename, '$'))) != 0; ((strchr(filename, '*')) || (strchr(filename, '$'))) != 0;
...@@ -618,6 +626,7 @@ static BOOL INT21_ChangeDir( CONTEXT86 *context ) ...@@ -618,6 +626,7 @@ static BOOL INT21_ChangeDir( CONTEXT86 *context )
{ {
int drive; int drive;
char *dirname = CTX_SEG_OFF_TO_LIN(context, context->SegDs,context->Edx); char *dirname = CTX_SEG_OFF_TO_LIN(context, context->SegDs,context->Edx);
WCHAR dirnameW[MAX_PATH];
TRACE("changedir %s\n", dirname); TRACE("changedir %s\n", dirname);
if (dirname[0] && (dirname[1] == ':')) if (dirname[0] && (dirname[1] == ':'))
...@@ -626,7 +635,8 @@ static BOOL INT21_ChangeDir( CONTEXT86 *context ) ...@@ -626,7 +635,8 @@ static BOOL INT21_ChangeDir( CONTEXT86 *context )
dirname += 2; dirname += 2;
} }
else drive = DRIVE_GetCurrentDrive(); else drive = DRIVE_GetCurrentDrive();
return DRIVE_Chdir( drive, dirname ); MultiByteToWideChar(CP_OEMCP, 0, dirname, -1, dirnameW, MAX_PATH);
return DRIVE_Chdir( drive, dirnameW );
} }
...@@ -636,10 +646,14 @@ static int INT21_FindFirst( CONTEXT86 *context ) ...@@ -636,10 +646,14 @@ static int INT21_FindFirst( CONTEXT86 *context )
const char *path; const char *path;
DOS_FULL_NAME full_name; DOS_FULL_NAME full_name;
FINDFILE_DTA *dta = (FINDFILE_DTA *)GetCurrentDTA(context); FINDFILE_DTA *dta = (FINDFILE_DTA *)GetCurrentDTA(context);
WCHAR pathW[MAX_PATH];
WCHAR maskW[12];
path = (const char *)CTX_SEG_OFF_TO_LIN(context, context->SegDs, context->Edx); path = (const char *)CTX_SEG_OFF_TO_LIN(context, context->SegDs, context->Edx);
MultiByteToWideChar(CP_OEMCP, 0, path, -1, pathW, MAX_PATH);
dta->unixPath = NULL; dta->unixPath = NULL;
if (!DOSFS_GetFullName( path, FALSE, &full_name )) if (!DOSFS_GetFullName( pathW, FALSE, &full_name ))
{ {
AX_reg(context) = GetLastError(); AX_reg(context) = GetLastError();
SET_CFLAG(context); SET_CFLAG(context);
...@@ -650,10 +664,12 @@ static int INT21_FindFirst( CONTEXT86 *context ) ...@@ -650,10 +664,12 @@ static int INT21_FindFirst( CONTEXT86 *context )
p = strrchr( dta->unixPath, '/' ); p = strrchr( dta->unixPath, '/' );
*p = '\0'; *p = '\0';
MultiByteToWideChar(CP_OEMCP, 0, p + 1, -1, pathW, MAX_PATH);
/* Note: terminating NULL in dta->mask overwrites dta->search_attr /* Note: terminating NULL in dta->mask overwrites dta->search_attr
* (doesn't matter as it is set below anyway) * (doesn't matter as it is set below anyway)
*/ */
if (!DOSFS_ToDosFCBFormat( p + 1, dta->mask )) if (!DOSFS_ToDosFCBFormat( pathW, maskW ))
{ {
HeapFree( GetProcessHeap(), 0, dta->unixPath ); HeapFree( GetProcessHeap(), 0, dta->unixPath );
dta->unixPath = NULL; dta->unixPath = NULL;
...@@ -662,6 +678,7 @@ static int INT21_FindFirst( CONTEXT86 *context ) ...@@ -662,6 +678,7 @@ static int INT21_FindFirst( CONTEXT86 *context )
SET_CFLAG(context); SET_CFLAG(context);
return 0; return 0;
} }
WideCharToMultiByte(CP_OEMCP, 0, maskW, 12, dta->mask, sizeof(dta->mask), NULL, NULL);
dta->drive = (path[0] && (path[1] == ':')) ? toupper(path[0]) - 'A' dta->drive = (path[0] && (path[1] == ':')) ? toupper(path[0]) - 'A'
: DRIVE_GetCurrentDrive(); : DRIVE_GetCurrentDrive();
dta->count = 0; dta->count = 0;
...@@ -743,7 +760,8 @@ static BOOL INT21_GetCurrentDirectory( CONTEXT86 *context ) ...@@ -743,7 +760,8 @@ static BOOL INT21_GetCurrentDirectory( CONTEXT86 *context )
SetLastError( ERROR_INVALID_DRIVE ); SetLastError( ERROR_INVALID_DRIVE );
return FALSE; return FALSE;
} }
lstrcpynA( ptr, DRIVE_GetDosCwd(drive), 64 ); WideCharToMultiByte(CP_OEMCP, 0, DRIVE_GetDosCwd(drive), -1, ptr, 64, NULL, NULL);
ptr[63] = 0; /* ensure 0 termination */
AX_reg(context) = 0x0100; /* success return code */ AX_reg(context) = 0x0100; /* success return code */
return TRUE; return TRUE;
} }
...@@ -1586,8 +1604,9 @@ void WINAPI DOS3Call( CONTEXT86 *context ) ...@@ -1586,8 +1604,9 @@ void WINAPI DOS3Call( CONTEXT86 *context )
break; break;
case 0x02:{ case 0x02:{
const DOS_DEVICE *dev; const DOS_DEVICE *dev;
static const WCHAR scsimgrW[] = {'S','C','S','I','M','G','R','$',0};
if ((dev = DOSFS_GetDeviceByHandle( DosFileHandleToWin32Handle(BX_reg(context)) )) && if ((dev = DOSFS_GetDeviceByHandle( DosFileHandleToWin32Handle(BX_reg(context)) )) &&
!strcasecmp( dev->name, "SCSIMGR$" )) !strcmpiW( dev->name, scsimgrW ))
{ {
ASPI_DOS_HandleInt(context); ASPI_DOS_HandleInt(context);
} }
......
...@@ -36,6 +36,7 @@ ...@@ -36,6 +36,7 @@
# include <unistd.h> # include <unistd.h>
#endif #endif
#include "windef.h" #include "windef.h"
#include "winnls.h"
#include "callback.h" #include "callback.h"
#include "file.h" #include "file.h"
#include "miscemu.h" #include "miscemu.h"
...@@ -249,17 +250,22 @@ static inline void outl( DWORD value, WORD port ) ...@@ -249,17 +250,22 @@ static inline void outl( DWORD value, WORD port )
static void IO_port_init(void) static void IO_port_init(void)
{ {
char temp[1024]; char temp[1024];
WCHAR tempW[1024];
static const WCHAR portsW[] = {'p','o','r','t','s',0};
static const WCHAR readW[] = {'r','e','a','d',0};
static const WCHAR writeW[] = {'w','r','i','t','e',0};
static const WCHAR asteriskW[] = {'*',0};
do_direct_port_access = 0; do_direct_port_access = 0;
/* Can we do that? */ /* Can we do that? */
if (!iopl(3)) { if (!iopl(3)) {
iopl(0); iopl(0);
PROFILE_GetWineIniString( "ports", "read", "*", PROFILE_GetWineIniString( portsW, readW, asteriskW, tempW, 1024 );
temp, sizeof(temp) ); WideCharToMultiByte(CP_ACP, 0, tempW, -1, temp, 1024, NULL, NULL);
do_IO_port_init_read_or_write(temp, IO_READ); do_IO_port_init_read_or_write(temp, IO_READ);
PROFILE_GetWineIniString( "ports", "write", "*", PROFILE_GetWineIniString( portsW, writeW, asteriskW, tempW, 1024 );
temp, sizeof(temp) ); WideCharToMultiByte(CP_ACP, 0, tempW, -1, temp, 1024, NULL, NULL);
do_IO_port_init_read_or_write(temp, IO_WRITE); do_IO_port_init_read_or_write(temp, IO_WRITE);
} }
IO_FixCMOSCheckSum(); IO_FixCMOSCheckSum();
......
...@@ -650,9 +650,12 @@ void PROCESS_InitWine( int argc, char *argv[], LPSTR win16_exe_name, HANDLE *win ...@@ -650,9 +650,12 @@ void PROCESS_InitWine( int argc, char *argv[], LPSTR win16_exe_name, HANDLE *win
{ {
DOS_FULL_NAME full_name; DOS_FULL_NAME full_name;
const char *name = main_exe_name; const char *name = main_exe_name;
UNICODE_STRING nameW;
TRACE( "starting Winelib app %s\n", debugstr_a(main_exe_name) ); TRACE( "starting Winelib app %s\n", debugstr_a(main_exe_name) );
if (DOSFS_GetFullName( name, TRUE, &full_name )) name = full_name.long_name; RtlCreateUnicodeStringFromAsciiz(&nameW, name);
if (DOSFS_GetFullName( nameW.Buffer, TRUE, &full_name )) name = full_name.long_name;
RtlFreeUnicodeString(&nameW);
CloseHandle( main_exe_file ); CloseHandle( main_exe_file );
main_exe_file = 0; main_exe_file = 0;
if (wine_dlopen( name, RTLD_NOW, error, sizeof(error) )) if (wine_dlopen( name, RTLD_NOW, error, sizeof(error) ))
...@@ -1194,13 +1197,16 @@ BOOL WINAPI CreateProcessA( LPCSTR app_name, LPSTR cmd_line, LPSECURITY_ATTRIBUT ...@@ -1194,13 +1197,16 @@ BOOL WINAPI CreateProcessA( LPCSTR app_name, LPSTR cmd_line, LPSECURITY_ATTRIBUT
if (cur_dir) if (cur_dir)
{ {
if (DOSFS_GetFullName( cur_dir, TRUE, &full_dir )) UNICODE_STRING cur_dirW;
RtlCreateUnicodeStringFromAsciiz(&cur_dirW, cur_dir);
if (DOSFS_GetFullName( cur_dirW.Buffer, TRUE, &full_dir ))
unixdir = full_dir.long_name; unixdir = full_dir.long_name;
RtlFreeUnicodeString(&cur_dirW);
} }
else else
{ {
char buf[MAX_PATH]; WCHAR buf[MAX_PATH];
if (GetCurrentDirectoryA(sizeof(buf),buf)) if (GetCurrentDirectoryW(MAX_PATH, buf))
{ {
if (DOSFS_GetFullName( buf, TRUE, &full_dir )) unixdir = full_dir.long_name; if (DOSFS_GetFullName( buf, TRUE, &full_dir )) unixdir = full_dir.long_name;
} }
...@@ -1253,11 +1259,16 @@ BOOL WINAPI CreateProcessA( LPCSTR app_name, LPSTR cmd_line, LPSECURITY_ATTRIBUT ...@@ -1253,11 +1259,16 @@ BOOL WINAPI CreateProcessA( LPCSTR app_name, LPSTR cmd_line, LPSECURITY_ATTRIBUT
/* fall through */ /* fall through */
case BINARY_UNIX_EXE: case BINARY_UNIX_EXE:
{ {
/* unknown file, try as unix executable */
UNICODE_STRING nameW;
DOS_FULL_NAME full_name; DOS_FULL_NAME full_name;
const char *unixfilename = name; const char *unixfilename = name;
TRACE( "starting %s as Unix binary\n", debugstr_a(name) ); TRACE( "starting %s as Unix binary\n", debugstr_a(name) );
if (DOSFS_GetFullName( name, TRUE, &full_name )) unixfilename = full_name.long_name;
RtlCreateUnicodeStringFromAsciiz(&nameW, name);
if (DOSFS_GetFullName( nameW.Buffer, TRUE, &full_name )) unixfilename = full_name.long_name;
RtlFreeUnicodeString(&nameW);
retv = (fork_and_exec( unixfilename, tidy_cmdline, env, unixdir ) != -1); retv = (fork_and_exec( unixfilename, tidy_cmdline, env, unixdir ) != -1);
} }
break; break;
......
...@@ -344,9 +344,16 @@ LPCSTR VMM_Service_Name[N_VMM_SERVICE] = ...@@ -344,9 +344,16 @@ LPCSTR VMM_Service_Name[N_VMM_SERVICE] =
HANDLE DEVICE_Open( LPCSTR filename, DWORD access, LPSECURITY_ATTRIBUTES sa ) HANDLE DEVICE_Open( LPCWSTR filenameW, DWORD access, LPSECURITY_ATTRIBUTES sa )
{ {
const struct VxDInfo *info; const struct VxDInfo *info;
char filename[MAX_PATH];
if (!WideCharToMultiByte(CP_ACP, 0, filenameW, -1, filename, MAX_PATH, NULL, NULL))
{
SetLastError( ERROR_FILE_NOT_FOUND );
return 0;
}
for (info = VxDList; info->name; info++) for (info = VxDList; info->name; info++)
if (!strncasecmp( info->name, filename, strlen(info->name) )) if (!strncasecmp( info->name, filename, strlen(info->name) ))
...@@ -1563,4 +1570,3 @@ static BOOL DeviceIo_HASP(DWORD dwIoControlCode, LPVOID lpvInBuffer, DWORD cbInB ...@@ -1563,4 +1570,3 @@ static BOOL DeviceIo_HASP(DWORD dwIoControlCode, LPVOID lpvInBuffer, DWORD cbInB
return retv; return retv;
} }
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