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 @@
#include "wine/winbase16.h"
#include "winbase.h"
#include "winerror.h"
#include "wownt32.h"
#include "ntddk.h"
#include "file.h"
#include "miscemu.h"
#include "stackframe.h"
......@@ -319,17 +321,35 @@ DWORD WINAPI LoadLibraryEx32W16( LPCSTR lpszLibFile, DWORD hFile, DWORD dwFlags
HMODULE hModule;
DOS_FULL_NAME full_name;
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
a buildin module. This case is handled in MODULE_LoadLibraryExA */
if ( ! DIR_SearchPath ( NULL, lpszLibFile, ".DLL", &full_name, FALSE ) ) {
strcpy ( full_name.short_name, lpszLibFile );
}
filenameW = libfileW.Buffer;
if ( DIR_SearchPath( NULL, filenameW, dllW, &full_name, FALSE ) )
filenameW = full_name.short_name;
ReleaseThunkLock( &mutex_count );
hModule = LoadLibraryExA( full_name.short_name, (HANDLE)hFile, dwFlags );
hModule = LoadLibraryExW( filenameW, (HANDLE)hFile, dwFlags );
RestoreThunkLock( mutex_count );
RtlFreeUnicodeString(&libfileW);
return (DWORD)hModule;
}
......
......@@ -29,6 +29,7 @@
#ifdef HAVE_SYS_ERRNO_H
#include <sys/errno.h>
#endif
#include "wine/unicode.h"
#include "wine/debug.h"
#include "wine/server.h"
#include "ntdll_misc.h"
......@@ -60,9 +61,8 @@ NTSTATUS WINAPI NtOpenFile(
ULONG ShareAccess,
ULONG OpenOptions)
{
ULONG len = 0;
PSTR filename;
CHAR szDosDevices[] = "\\DosDevices\\";
LPWSTR filename;
static const WCHAR szDosDevices[] = {'\\','D','o','s','D','e','v','i','c','e','s','\\',0};
DOS_FULL_NAME full_name;
NTSTATUS r;
......@@ -79,20 +79,14 @@ NTSTATUS WINAPI NtOpenFile(
return STATUS_OBJECT_NAME_NOT_FOUND;
}
/* create an ascii string from the unicode filename */
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;
filename = ObjectAttributes->ObjectName->Buffer;
/* 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;
/* FIXME: this calls SetLastError() -> bad */
if(!DOSFS_GetFullName(&filename[strlen(szDosDevices)], TRUE,
if(!DOSFS_GetFullName(&filename[strlenW(szDosDevices)], TRUE,
&full_name))
return STATUS_OBJECT_NAME_NOT_FOUND;
......@@ -105,7 +99,7 @@ NTSTATUS WINAPI NtOpenFile(
req->sharing = ShareAccess;
req->create = OPEN_EXISTING;
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) );
SetLastError(0);
r = wine_server_call( req );
......
......@@ -32,16 +32,18 @@
#include "miscemu.h"
#include "msdos.h"
#include "file.h"
#include "wine/unicode.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(int21);
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(
DosFileHandleToWin32Handle(BX_reg(context)) );
if (dev && !strcasecmp( dev->name, "EMMXXXX0" )) {
if (dev && !strcmpiW( dev->name, emmxxxx0W )) {
EMS_Ioctl_Handler(context);
return;
}
......
......@@ -1392,7 +1392,7 @@ static HANDLE SMB_RegisterFile( int fd, USHORT tree_id, USHORT user_id, USHORT d
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,
DWORD attributes, HANDLE template )
{
......@@ -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;
LPSTR name,host,share,file;
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)
return handle;
lstrcpyA(name,uncname);
WideCharToMultiByte(CP_ACP, 0, uncname, -1, name, len, NULL, NULL);
if( !UNC_SplitName(name, &host, &share, &file) )
{
......@@ -1545,21 +1547,22 @@ BOOL WINAPI SMB_ReadFile(HANDLE hFile, LPVOID buffer, DWORD bytesToRead, LPDWORD
return r;
}
SMB_DIR* WINAPI SMB_FindFirst(LPCSTR name)
SMB_DIR* WINAPI SMB_FindFirst(LPCWSTR name)
{
int fd = -1;
LPSTR host,share,file;
USHORT tree_id=0, user_id=0, dialect=0;
SMB_DIR *ret = NULL;
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)
return ret;
lstrcpyA(filename,name);
WideCharToMultiByte( CP_ACP, 0, name, -1, filename, len, NULL, NULL );
if( !UNC_SplitName(filename, &host, &share, &file) )
goto 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;
int len, fnlen;
......@@ -1613,14 +1616,16 @@ BOOL WINAPI SMB_FindNext(SMB_DIR *dir, WIN32_FIND_DATAA *data )
/* copy the long filename */
fnlen = SMB_GETDWORD(&ent[0x3c]);
if ( fnlen > (sizeof data->cFileName/sizeof(CHAR)) )
if ( fnlen > (sizeof data->cFileName/sizeof(WCHAR)) )
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 */
if ( ent[0x44] > (sizeof data->cAlternateFileName/sizeof(CHAR)) )
if ( ent[0x44] > (sizeof data->cAlternateFileName/sizeof(WCHAR)) )
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++;
......
......@@ -96,7 +96,7 @@
#define TRANS2_FIND_NEXT2 0x02
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,
DWORD attributes, HANDLE template );
......@@ -108,8 +108,8 @@ typedef struct tagSMB_DIR
unsigned char *buffer;
} SMB_DIR;
extern SMB_DIR* WINAPI SMB_FindFirst(LPCSTR filename);
extern BOOL WINAPI SMB_FindNext(SMB_DIR *dir, WIN32_FIND_DATAA *data );
extern SMB_DIR* WINAPI SMB_FindFirst(LPCWSTR filename);
extern BOOL WINAPI SMB_FindNext(SMB_DIR *dir, WIN32_FIND_DATAW *data );
extern BOOL WINAPI SMB_CloseDir(SMB_DIR *dir);
#endif /* __INC_SMB__ */
......@@ -39,15 +39,17 @@ extern int DRIVE_IsValid( int drive );
extern int DRIVE_GetCurrentDrive(void);
extern int DRIVE_SetCurrentDrive( int drive );
extern int DRIVE_FindDriveRoot( const char **path );
extern int DRIVE_FindDriveRootW( LPCWSTR *path );
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_GetDevice( int drive );
extern const char * DRIVE_GetLabel( int drive );
extern LPCWSTR DRIVE_GetLabel( int drive );
extern DWORD DRIVE_GetSerialNumber( int drive );
extern int DRIVE_SetSerialNumber( int drive, DWORD serial );
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_Enable( int drive );
extern int DRIVE_SetLogicalMapping ( int existing_drive, int new_drive );
......
......@@ -26,6 +26,7 @@
#include <sys/types.h>
#include "winbase.h"
#include "wine/windef16.h" /* HFILE16 */
#include "wine/unicode.h"
#define MAX_PATHNAME_LEN 1024
......@@ -33,7 +34,7 @@
typedef struct
{
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;
} DOS_FULL_NAME;
......@@ -42,8 +43,9 @@ typedef struct
/* DOS device descriptor */
typedef struct
{
char *name;
const WCHAR name[9];
int flags;
UINT codepage;
} DOS_DEVICE;
/* locale-independent case conversion */
......@@ -64,6 +66,12 @@ inline static int FILE_contains_path (LPCSTR name)
strchr (name, '/') || strchr (name, '\\'));
}
inline static int FILE_contains_pathW (LPCWSTR name)
{
return ((*name && (name[1] == ':')) ||
strchrW (name, '/') || strchrW (name, '\\'));
}
/* files/file.c */
extern mode_t FILE_umask;
extern int FILE_strcasecmp( const char *str1, const char *str2 );
......@@ -86,21 +94,20 @@ extern UINT DIR_GetWindowsUnixDir( LPSTR path, UINT count );
extern UINT DIR_GetSystemUnixDir( LPSTR path, UINT count );
extern DWORD DIR_SearchAlternatePath( LPCSTR dll_path, LPCSTR name, LPCSTR ext,
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 );
/* files/dos_fs.c */
extern void DOSFS_UnixTimeToFileTime( time_t unixtime, LPFILETIME ft,
DWORD remainder );
extern time_t DOSFS_FileTimeToUnixTime( const FILETIME *ft, DWORD *remainder );
extern BOOL DOSFS_ToDosFCBFormat( LPCSTR name, LPSTR buffer );
extern const DOS_DEVICE *DOSFS_GetDevice( const char *name );
extern BOOL DOSFS_ToDosFCBFormat( LPCWSTR name, LPWSTR buffer );
extern const DOS_DEVICE *DOSFS_GetDevice( LPCWSTR name );
extern const DOS_DEVICE *DOSFS_GetDeviceByHandle( HANDLE hFile );
extern HANDLE DOSFS_OpenDevice( const char *name, DWORD access, DWORD attributes, LPSECURITY_ATTRIBUTES sa);
extern BOOL DOSFS_FindUnixName( LPCSTR path, LPCSTR name, LPSTR long_buf,
INT long_len, LPSTR short_buf,
BOOL ignore_case );
extern BOOL DOSFS_GetFullName( LPCSTR name, BOOL check_last,
extern HANDLE DOSFS_OpenDevice( LPCWSTR name, DWORD access, DWORD attributes, LPSECURITY_ATTRIBUTES sa);
extern BOOL DOSFS_FindUnixName( const DOS_FULL_NAME *path, LPCWSTR name, char *long_buf,
INT long_len, LPWSTR short_buf, BOOL ignore_case );
extern BOOL DOSFS_GetFullName( LPCWSTR name, BOOL check_last,
DOS_FULL_NAME *full );
extern int DOSFS_FindNext( const char *path, const char *short_mask,
const char *long_mask, int drive, BYTE attr,
......@@ -109,12 +116,12 @@ extern int DOSFS_FindNext( const char *path, const char *short_mask,
/* profile.c */
extern int PROFILE_LoadWineIni(void);
extern void PROFILE_UsageWineIni(void);
extern int PROFILE_GetWineIniString( const char *section, const char *key_name,
const char *def, char *buffer, int len );
extern int PROFILE_GetWineIniBool( char const *section, char const *key_name, int def );
extern int PROFILE_GetWineIniString( LPCWSTR section, LPCWSTR key_name,
LPCWSTR def, LPWSTR buffer, int len );
extern int PROFILE_GetWineIniBool( LPCWSTR section, LPCWSTR key_name, int def );
/* 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 */
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
pTask->teb = teb;
pTask->curdrive = DRIVE_GetCurrentDrive() | 0x80;
strcpy( pTask->curdir, "\\" );
lstrcpynA( pTask->curdir + 1, DRIVE_GetDosCwd( DRIVE_GetCurrentDrive() ),
sizeof(pTask->curdir) - 1 );
WideCharToMultiByte(CP_ACP, 0, DRIVE_GetDosCwd(DRIVE_GetCurrentDrive()), -1,
pTask->curdir + 1, sizeof(pTask->curdir) - 1, NULL, NULL);
pTask->curdir[sizeof(pTask->curdir) - 1] = 0; /* ensure 0 termination */
/* Create the thunks block */
......
......@@ -435,17 +435,19 @@ static void DOSCONF_Parse(char *menuname)
int DOSCONF_ReadConfig(void)
{
char buffer[256];
WCHAR filename[MAX_PATH];
DOS_FULL_NAME fullname;
char *filename, *menuname;
WCHAR *p;
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) );
if (!(filename = strtok(buffer, ","))) return ret;
menuname = strtok(NULL, ",");
PROFILE_GetWineIniString( wineW, config_sysW, empty_strW, filename, MAX_PATH );
if ((p = strchrW(filename, ','))) *p = 0;
if (!filename[0]) return ret;
DOSFS_GetFullName(filename, FALSE, &fullname);
if (menuname) menu_default = strdup(menuname);
if ((cfg_fd = fopen(fullname.long_name, "r")))
{
DOSCONF_Parse(NULL);
......@@ -453,10 +455,9 @@ int DOSCONF_ReadConfig(void)
}
else
{
MESSAGE("Couldn't open config.sys file given as \"%s\" in" \
" wine.conf or .winerc, section [wine] !\n", filename);
MESSAGE("Couldn't open config.sys file given as %s in" \
" wine.conf or .winerc, section [wine] !\n", debugstr_w(filename));
ret = 0;
}
if (menu_default) free(menu_default);
return ret;
}
......@@ -28,6 +28,7 @@
#include "miscemu.h"
#include "msdos.h"
#include "file.h"
#include "wine/unicode.h"
#include "wine/debug.h"
/**********************************************************************
......@@ -74,16 +75,21 @@ void WINAPI INT_Int11Handler( CONTEXT86 *context )
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);
PROFILE_GetWineIniString("serialports",name,"*",temp,sizeof temp);
if(strcmp(temp,"*"))
comW[3] = '0' + x;
PROFILE_GetWineIniString(serialportsW, comW, asteriskW, temp, 16);
if(strcmpW(temp, asteriskW))
serialports++;
sprintf(name,"LPT%d",x+1);
PROFILE_GetWineIniString("parallelports",name,"*",temp,sizeof temp);
if(strcmp(temp,"*"))
lptW[3] = '0' + x;
PROFILE_GetWineIniString(parallelportsW, lptW, asteriskW, temp, 16);
if(strcmpW(temp, asteriskW))
parallelports++;
}
if (serialports > 7) /* 3 bits -- maximum value = 7 */
......
......@@ -57,6 +57,7 @@
#include "msdos.h"
#include "miscemu.h"
#include "task.h"
#include "wine/unicode.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(int21);
......@@ -428,30 +429,37 @@ static void INT21_ParseFileNameIntoFCB( CONTEXT86 *context )
CTX_SEG_OFF_TO_LIN(context, context->SegDs, context->Esi );
char *fcb =
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 */
TRACE("filename: '%s'\n", filename);
buffer = HeapAlloc( GetProcessHeap(), 0, strlen(filename) + 1);
s = filename;
d = buffer;
len = 0;
while (*s)
{
if ((*s != ' ') && (*s != '\r') && (*s != '\n'))
*d++ = *s++;
{
s++;
len++;
}
else
break;
}
*d = '\0';
DOSFS_ToDosFCBFormat(buffer, fcb + 1);
buffer_len = MultiByteToWideChar(CP_OEMCP, 0, filename, len, NULL, 0);
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;
TRACE("FCB: '%s'\n", ((CHAR *)fcb + 1));
HeapFree( GetProcessHeap(), 0, buffer);
TRACE("FCB: '%s'\n", fcb + 1);
AL_reg(context) =
((strchr(filename, '*')) || (strchr(filename, '$'))) != 0;
......@@ -618,6 +626,7 @@ static BOOL INT21_ChangeDir( CONTEXT86 *context )
{
int drive;
char *dirname = CTX_SEG_OFF_TO_LIN(context, context->SegDs,context->Edx);
WCHAR dirnameW[MAX_PATH];
TRACE("changedir %s\n", dirname);
if (dirname[0] && (dirname[1] == ':'))
......@@ -626,7 +635,8 @@ static BOOL INT21_ChangeDir( CONTEXT86 *context )
dirname += 2;
}
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 )
const char *path;
DOS_FULL_NAME full_name;
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);
MultiByteToWideChar(CP_OEMCP, 0, path, -1, pathW, MAX_PATH);
dta->unixPath = NULL;
if (!DOSFS_GetFullName( path, FALSE, &full_name ))
if (!DOSFS_GetFullName( pathW, FALSE, &full_name ))
{
AX_reg(context) = GetLastError();
SET_CFLAG(context);
......@@ -650,10 +664,12 @@ static int INT21_FindFirst( CONTEXT86 *context )
p = strrchr( dta->unixPath, '/' );
*p = '\0';
MultiByteToWideChar(CP_OEMCP, 0, p + 1, -1, pathW, MAX_PATH);
/* Note: terminating NULL in dta->mask overwrites dta->search_attr
* (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 );
dta->unixPath = NULL;
......@@ -662,6 +678,7 @@ static int INT21_FindFirst( CONTEXT86 *context )
SET_CFLAG(context);
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'
: DRIVE_GetCurrentDrive();
dta->count = 0;
......@@ -743,7 +760,8 @@ static BOOL INT21_GetCurrentDirectory( CONTEXT86 *context )
SetLastError( ERROR_INVALID_DRIVE );
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 */
return TRUE;
}
......@@ -1586,8 +1604,9 @@ void WINAPI DOS3Call( CONTEXT86 *context )
break;
case 0x02:{
const DOS_DEVICE *dev;
static const WCHAR scsimgrW[] = {'S','C','S','I','M','G','R','$',0};
if ((dev = DOSFS_GetDeviceByHandle( DosFileHandleToWin32Handle(BX_reg(context)) )) &&
!strcasecmp( dev->name, "SCSIMGR$" ))
!strcmpiW( dev->name, scsimgrW ))
{
ASPI_DOS_HandleInt(context);
}
......
......@@ -36,6 +36,7 @@
# include <unistd.h>
#endif
#include "windef.h"
#include "winnls.h"
#include "callback.h"
#include "file.h"
#include "miscemu.h"
......@@ -249,17 +250,22 @@ static inline void outl( DWORD value, WORD port )
static void IO_port_init(void)
{
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;
/* Can we do that? */
if (!iopl(3)) {
iopl(0);
PROFILE_GetWineIniString( "ports", "read", "*",
temp, sizeof(temp) );
PROFILE_GetWineIniString( portsW, readW, asteriskW, tempW, 1024 );
WideCharToMultiByte(CP_ACP, 0, tempW, -1, temp, 1024, NULL, NULL);
do_IO_port_init_read_or_write(temp, IO_READ);
PROFILE_GetWineIniString( "ports", "write", "*",
temp, sizeof(temp) );
PROFILE_GetWineIniString( portsW, writeW, asteriskW, tempW, 1024 );
WideCharToMultiByte(CP_ACP, 0, tempW, -1, temp, 1024, NULL, NULL);
do_IO_port_init_read_or_write(temp, IO_WRITE);
}
IO_FixCMOSCheckSum();
......
......@@ -650,9 +650,12 @@ void PROCESS_InitWine( int argc, char *argv[], LPSTR win16_exe_name, HANDLE *win
{
DOS_FULL_NAME full_name;
const char *name = main_exe_name;
UNICODE_STRING nameW;
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 );
main_exe_file = 0;
if (wine_dlopen( name, RTLD_NOW, error, sizeof(error) ))
......@@ -1194,13 +1197,16 @@ BOOL WINAPI CreateProcessA( LPCSTR app_name, LPSTR cmd_line, LPSECURITY_ATTRIBUT
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;
RtlFreeUnicodeString(&cur_dirW);
}
else
{
char buf[MAX_PATH];
if (GetCurrentDirectoryA(sizeof(buf),buf))
WCHAR buf[MAX_PATH];
if (GetCurrentDirectoryW(MAX_PATH, buf))
{
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
/* fall through */
case BINARY_UNIX_EXE:
{
/* unknown file, try as unix executable */
UNICODE_STRING nameW;
DOS_FULL_NAME full_name;
const char *unixfilename = 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);
}
break;
......
......@@ -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;
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++)
if (!strncasecmp( info->name, filename, strlen(info->name) ))
......@@ -1563,4 +1570,3 @@ static BOOL DeviceIo_HASP(DWORD dwIoControlCode, LPVOID lpvInBuffer, DWORD cbInB
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