Commit 473fd0b0 authored by Hidenori Takeshima's avatar Hidenori Takeshima Committed by Alexandre Julliard

Implemented some DDK APIs - far from complete.

parent 847c8740
......@@ -407,7 +407,7 @@ dsound/libdsound.@LIBEXT@: libwinmm.@LIBEXT@ libkernel32.@LIBEXT@ libntdll.@LIBE
gdi/libgdi32.@LIBEXT@: libadvapi32.@LIBEXT@ libkernel32.@LIBEXT@ libntdll.@LIBEXT@
icmp/libicmp.@LIBEXT@: libkernel32.@LIBEXT@ libntdll.@LIBEXT@
imagehlp/libimagehlp.@LIBEXT@: libkernel32.@LIBEXT@ libntdll.@LIBEXT@
imm32/libimm32.@LIBEXT@: libkernel32.@LIBEXT@ libntdll.@LIBEXT@
imm32/libimm32.@LIBEXT@: libuser32.@LIBEXT@ libgdi32.@LIBEXT@ libkernel32.@LIBEXT@ libntdll.@LIBEXT@
kernel/libkernel32.@LIBEXT@: libntdll.@LIBEXT@
lzexpand/liblz32.@LIBEXT@: libkernel32.@LIBEXT@ libntdll.@LIBEXT@
mpr/libmpr.@LIBEXT@: libkernel32.@LIBEXT@ libntdll.@LIBEXT@
......
......@@ -9,7 +9,10 @@ LDDLLFLAGS = @LDDLLFLAGS@
SYMBOLFILE = $(MODULE).tmp.o
C_SRCS = \
imm.c
imm.c \
main.c \
memory.c \
string.c
@MAKE_DLL_RULES@
......
/*
* IMM32 library
* IMM32 stubs - please implement!
*
* Copyright 1998 Patrik Stridvall
*/
......@@ -9,14 +9,9 @@
#include "wingdi.h"
#include "winuser.h"
#include "winerror.h"
#include "debugtools.h"
#include "imm.h"
typedef struct INPUTCONTEXT
{
int dummy;
} *LPINPUTCONTEXT;
#include "immddk.h"
#include "debugtools.h"
DEFAULT_DEBUG_CHANNEL(imm);
/***********************************************************************
......@@ -770,76 +765,6 @@ DWORD WINAPI ImmGetIMCLockCount(HIMC hIMC)
}
/***********************************************************************
* ImmCreateIMCC (IMM32.@)
*/
HIMCC WINAPI ImmCreateIMCC(DWORD dwSize)
{
FIXME("(%lu): stub\n", dwSize);
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
return (HIMCC)NULL;
}
/***********************************************************************
* ImmDestroyIMCC (IMM32.@)
*/
HIMCC WINAPI ImmDestroyIMCC(HIMCC hIMCC)
{
FIXME("(0x%08x): stub\n", (unsigned)hIMCC);
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
return (HIMCC)hIMCC;
}
/***********************************************************************
* ImmLockIMCC (IMM32.@)
*/
LPVOID WINAPI ImmLockIMCC(HIMCC hIMCC)
{
FIXME("(0x%08x): stub\n", (unsigned)hIMCC);
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
return NULL;
}
/***********************************************************************
* ImmUnlockIMCC (IMM32.@)
*/
BOOL WINAPI ImmUnlockIMCC(HIMCC hIMCC)
{
FIXME("(0x%08x): stub\n", (unsigned)hIMCC);
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
return FALSE;
}
/***********************************************************************
* ImmGetIMCCLockCount (IMM32.@)
*/
DWORD WINAPI ImmGetIMCCLockCount(HIMCC hIMCC)
{
FIXME("(0x%08x): stub\n", (unsigned)hIMCC);
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
return 0;
}
/***********************************************************************
* ImmReSizeIMCC (IMM32.@)
*/
HIMCC WINAPI ImmReSizeIMCC(HIMCC hIMCC, DWORD dwSize)
{
FIXME("(0x%08x,%lu): stub\n", (unsigned)hIMCC, dwSize);
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
return (HIMCC)NULL;
}
/***********************************************************************
* ImmGetIMCCSize (IMM32.@)
*/
DWORD WINAPI ImmGetIMCCSize(HIMCC hIMCC)
{
FIXME("(0x%08x): stub\n", (unsigned)hIMCC);
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
return 0;
}
/***********************************************************************
* ImmCreateSoftKeyboard (IMM32.@)
*/
HWND WINAPI ImmCreateSoftKeyboard(UINT uType, HWND hOwner, int x, int y)
......
name imm32
type win32
init IMM32_DllMain
import user32.dll
# NOTE: gdi32.dll will be required for implementing IME global class.
import gdi32.dll
import kernel32.dll
import ntdll.dll
......
/*
* private header for implementing IMM.
*
* Copyright 2000 Hidenori Takeshima
*/
typedef struct IMM32_tagTHREADDATA IMM32_THREADDATA;
struct IMM32_tagTHREADDATA
{
HWND hwndIME;
HIMC hIMC;
};
typedef struct IMM32_tagMOVEABLEMEM IMM32_MOVEABLEMEM;
/* IME APIs */
typedef BOOL (WINAPI* IMM32_pImeInquireA)(LPIMEINFO, LPSTR, LPCSTR);
typedef BOOL (WINAPI* IMM32_pImeInquireW)(LPIMEINFO, LPWSTR, LPCWSTR);
typedef BOOL (WINAPI* IMM32_pImeConfigureA)(HKL, HWND, DWORD, LPVOID);
typedef BOOL (WINAPI* IMM32_pImeConfigureW)(HKL, HWND, DWORD, LPVOID);
typedef DWORD (WINAPI* IMM32_pImeConversionListA)
(HIMC, LPCSTR, LPCANDIDATELIST, DWORD, UINT);
typedef DWORD (WINAPI* IMM32_pImeConversionListW)
(HIMC, LPCWSTR, LPCANDIDATELIST, DWORD, UINT);
typedef BOOL (WINAPI* IMM32_pImeDestroy)(UINT);
typedef UINT (WINAPI* IMM32_pImeEnumRegisterWordA)
(REGISTERWORDENUMPROCA, LPCSTR, DWORD, LPCSTR, LPVOID);
typedef UINT (WINAPI* IMM32_pImeEnumRegisterWordW)
(REGISTERWORDENUMPROCW, LPCWSTR, DWORD, LPCWSTR, LPVOID);
typedef UINT (WINAPI* IMM32_pImeGetRegisterWordStyleA)(UINT, LPSTYLEBUFA);
typedef UINT (WINAPI* IMM32_pImeGetRegisterWordStyleW)(UINT, LPSTYLEBUFW);
typedef LRESULT (WINAPI* IMM32_pImeEscapeA)(HIMC, UINT, LPVOID);
typedef LRESULT (WINAPI* IMM32_pImeEscapeW)(HIMC, UINT, LPVOID);
typedef BOOL (WINAPI* IMM32_pImeProcessKey)(HIMC, UINT, LPARAM, CONST LPBYTE);
typedef BOOL (WINAPI* IMM32_pImeRegisterWordA)(LPCSTR, DWORD, LPCSTR);
typedef BOOL (WINAPI* IMM32_pImeRegisterWordW)(LPCWSTR, DWORD, LPCWSTR);
typedef BOOL (WINAPI* IMM32_pImeSelect)(HIMC, BOOL);
typedef BOOL (WINAPI* IMM32_pImeSetActiveContext)(HIMC, BOOL);
typedef BOOL (WINAPI* IMM32_pImeSetCompositionStringA)
(HIMC, DWORD, LPCVOID, DWORD, LPCVOID, DWORD);
typedef BOOL (WINAPI* IMM32_pImeSetCompositionStringW)
(HIMC, DWORD, LPCVOID, DWORD, LPCVOID, DWORD);
typedef UINT (WINAPI* IMM32_pImeToAsciiEx)
(UINT, UINT, CONST LPBYTE, LPDWORD, UINT, HIMC);
typedef BOOL (WINAPI* IMM32_pImeUnregisterWordA)(LPCSTR, DWORD, LPCSTR);
typedef BOOL (WINAPI* IMM32_pImeUnregisterWordW)(LPCWSTR, DWORD, LPCWSTR);
typedef BOOL (WINAPI* IMM32_pNotifyIME)(HIMC, DWORD, DWORD, DWORD);
/* for Win98 and later */
typedef DWORD (WINAPI* IMM32_pImeGetImeMenuItemsA)
(HIMC, DWORD, DWORD, LPIMEMENUITEMINFOA, LPIMEMENUITEMINFOA, DWORD);
typedef DWORD (WINAPI* IMM32_pImeGetImeMenuItemsW)
(HIMC, DWORD, DWORD, LPIMEMENUITEMINFOW, LPIMEMENUITEMINFOW, DWORD);
struct IMM32_IME_EXPORTED_HANDLERS
{
union
{
IMM32_pImeInquireA A;
IMM32_pImeInquireW W;
} pImeInquire;
union
{
IMM32_pImeConfigureA A;
IMM32_pImeConfigureW W;
} pImeConfigure;
union
{
IMM32_pImeConversionListA A;
IMM32_pImeConversionListW W;
} pImeConversionList;
IMM32_pImeDestroy pImeDestroy;
union
{
IMM32_pImeEnumRegisterWordA A;
IMM32_pImeEnumRegisterWordW W;
} pImeEnumRegisterWord;
union
{
IMM32_pImeGetRegisterWordStyleA A;
IMM32_pImeGetRegisterWordStyleW W;
} pImeGetRegisterWordStyle;
union
{
IMM32_pImeEscapeA A;
IMM32_pImeEscapeW W;
} pImeEscape;
IMM32_pImeProcessKey pImeProcessKey;
union
{
IMM32_pImeRegisterWordA A;
IMM32_pImeRegisterWordW W;
} pImeRegisterWord;
IMM32_pImeSelect pImeSelect;
IMM32_pImeSetActiveContext pImeSetActiveContext;
union
{
IMM32_pImeSetCompositionStringA A;
IMM32_pImeSetCompositionStringW W;
} pImeSetCompositionString;
IMM32_pImeToAsciiEx pImeToAsciiEx;
union
{
IMM32_pImeUnregisterWordA A;
IMM32_pImeUnregisterWordW W;
} pImeUnregisterWord;
IMM32_pNotifyIME pNotifyIME;
/* for Win98 and later */
union
{
IMM32_pImeGetImeMenuItemsA A;
IMM32_pImeGetImeMenuItemsW W;
} pImeGetImeMenuItems;
};
/* imm_main.c */
LPVOID IMM32_HeapAlloc( DWORD dwFlags, DWORD dwSize );
LPVOID IMM32_HeapReAlloc( DWORD dwFlags, LPVOID lpv, DWORD dwSize );
void IMM32_HeapFree( LPVOID lpv );
IMM32_THREADDATA* IMM32_GetThreadData( void );
/* imm_memory.c */
IMM32_MOVEABLEMEM* IMM32_MoveableAlloc( DWORD dwHeapFlags, DWORD dwHeapSize );
void IMM32_MoveableFree( IMM32_MOVEABLEMEM* lpMoveable );
BOOL IMM32_MoveableReAlloc( IMM32_MOVEABLEMEM* lpMoveable,
DWORD dwHeapFlags, DWORD dwHeapSize );
LPVOID IMM32_MoveableLock( IMM32_MOVEABLEMEM* lpMoveable );
BOOL IMM32_MoveableUnlock( IMM32_MOVEABLEMEM* lpMoveable );
DWORD IMM32_MoveableGetLockCount( IMM32_MOVEABLEMEM* lpMoveable );
DWORD IMM32_MoveableGetSize( IMM32_MOVEABLEMEM* lpMoveable );
/* imm_string.c */
INT IMM32_strlenAtoW( LPCSTR lpstr );
INT IMM32_strlenWtoA( LPCWSTR lpwstr );
LPWSTR IMM32_strncpyAtoW( LPWSTR lpwstr, LPCSTR lpstr, INT wbuflen );
LPSTR IMM32_strncpyWtoA( LPSTR lpstr, LPCWSTR lpwstr, INT abuflen );
LPWSTR IMM32_strdupAtoW( LPCSTR lpstr );
LPSTR IMM32_strdupWtoA( LPCWSTR lpwstr );
/* DDK version of imm.h - imm.h for IMM and IME. */
#ifndef __WINE_IMMDDK_H
#define __WINE_IMMDDK_H
#include "imm.h"
#define NULLIMC ((HIMC)0)
/* offsets for WndExtra */
#define IMMGWL_IMC 0
#define IMMGWL_PRIVATE (sizeof(LONG))
/* INPUTCONTEXT.fdwInit */
#define INIT_STATUSWNDPOS 0x00000001
#define INIT_CONVERSION 0x00000002
#define INIT_SENTENCE 0x00000004
#define INIT_LOGFONT 0x00000008
#define INIT_COMPFORM 0x00000010
#define INIT_SOFTKBDPOS 0x00000020
/* IMEINFO.fdwProperty (low-order word) */
#define IME_PROP_END_UNLOAD 0x00000001
#define IME_PROP_KBD_CHAR_FIRST 0x00000002
#define IME_PROP_IGNORE_UPKEYS 0x00000004
#define IME_PROP_NEED_ALTKEY 0x00000008
#define IME_PROP_NO_KEYS_ON_CLOSE 0x00000010
/* IMEINFO.fdwProperty (high-order word) */
#define IME_PROP_AT_CARET 0x00010000
#define IME_PROP_SPECIAL_UI 0x00020000
#define IME_PROP_CANDLIST_START_FROM_1 0x00040000
#define IME_PROP_UNICODE 0x00080000
#define IME_PROP_COMPLETE_ON_UNSELECT 0x00100000
/*** IMM and IME Structures ***/
typedef struct tagINPUTCONTEXT {
HWND hWnd;
BOOL fOpen;
POINT ptStatusWndPos;
POINT ptSoftKbdPos;
DWORD fdwConversion;
DWORD fdwSentence;
union {
LOGFONTA A;
LOGFONTW W;
} lfFont;
COMPOSITIONFORM cfCompForm;
CANDIDATEFORM cfCandForm[4];
HIMCC hCompStr;
HIMCC hCandInfo;
HIMCC hGuideLine;
HIMCC hPrivate;
DWORD dwNumMsgBuf;
HIMCC hMsgBuf;
DWORD fdwInit;
DWORD dwReserve[3];
} INPUTCONTEXT, * LPINPUTCONTEXT;
typedef struct tagCOMPOSITIONSTRING
{
DWORD dwSize;
DWORD dwCompReadAttrLen;
DWORD dwCompReadAttrOffset;
DWORD dwCompReadClauseLen;
DWORD dwCompReadClauseOffset;
DWORD dwCompReadStrLen;
DWORD dwCompReadStrOffset;
DWORD dwCompAttrLen;
DWORD dwCompAttrOffset;
DWORD dwCompClauseLen;
DWORD dwCompClauseOffset;
DWORD dwCompStrLen;
DWORD dwCompStrOffset;
DWORD dwCursorPos;
DWORD dwDeltaStart;
DWORD dwResultReadClauseLen;
DWORD dwResultReadClauseOffset;
DWORD dwResultReadStrLen;
DWORD dwResultReadStrOffset;
DWORD dwResultClauseLen;
DWORD dwResultClauseOffset;
DWORD dwResultStrLen;
DWORD dwResultStrOffset;
DWORD dwPrivateSize;
DWORD dwPrivateOffset;
} COMPOSITIONSTRING, * LPCOMPOSITIONSTRING;
typedef struct tagCANDIDATEINFO
{
DWORD dwSize;
DWORD dwCount;
DWORD dwOffset[32];
DWORD dwPrivateSize;
DWORD dwPrivateOffset;
} CANDIDATEINFO, * LPCANDIDATEINFO;
typedef struct tagGUIDELINE
{
DWORD dwSize;
DWORD dwLevel;
DWORD dwIndex;
DWORD dwStrLen;
DWORD dwStrOffset;
DWORD dwPrivateSize;
DWORD dwPrivateOffset;
} GUIDELINE, * LPGUIDELINE;
/*** IME Management Structures ***/
typedef struct tagIMEINFO
{
DWORD dwPrivateDataSize;
DWORD fdwProperty;
DWORD fdwConversionCaps;
DWORD fdwSentenceCaps;
DWORD fdwUICaps;
DWORD fdwSCSCaps;
DWORD fdwSelectCaps;
} IMEINFO, * LPIMEINFO;
/*** IME Communication Structures ***/
typedef struct tagSOFTKBDDATA
{
UINT uCount;
WORD wCode[1][256];
} SOFTKBDDATA, * LPSOFTKBDDATA;
/*** IMM DDK APIs ***/
HWND WINAPI ImmCreateSoftKeyboard(UINT uType, HWND hwndOwner, int x, int y);
BOOL WINAPI ImmDestroySoftKeyboard(HWND hwndSoftKeyboard);
BOOL WINAPI ImmShowSoftKeyboard(HWND hwndSoftKeyboard, int nCmdShow);
LPINPUTCONTEXT WINAPI ImmLockIMC(HIMC hIMC);
BOOL WINAPI ImmUnlockIMC(HIMC hIMC);
DWORD WINAPI ImmGetIMCLockCount(HIMC hIMC);
HIMCC WINAPI ImmCreateIMCC(DWORD dwSize);
HIMCC WINAPI ImmDestroyIMCC(HIMCC hIMCC);
LPVOID WINAPI ImmLockIMCC(HIMCC hIMCC);
BOOL WINAPI ImmUnlockIMCC(HIMCC hIMCC);
DWORD WINAPI ImmGetIMCCLockCount(HIMCC hIMCC);
HIMCC WINAPI ImmReSizeIMCC(HIMCC hIMCC, DWORD dwSize);
DWORD WINAPI ImmGetIMCCSize(HIMCC hIMCC);
#endif /* __WINE_IMMDDK_H */
/*
* The entry point of IMM32.DLL.
*
* Copyright 2000 Hidenori Takeshima
*/
#include "config.h"
#include "winbase.h"
#include "windef.h"
#include "wingdi.h"
#include "winuser.h"
#include "winerror.h"
#include "immddk.h"
#include "debugtools.h"
DEFAULT_DEBUG_CHANNEL(imm);
#include "imm_private.h"
static DWORD IMM32_dwProcessAttached = 0;
static HANDLE IMM32_hHeap;
static DWORD IMM32_dwTLSIndex;
static CRITICAL_SECTION IMM32_csIMM;
static BOOL IMM32_InitProcessMem( void );
static void IMM32_CleanupProcessMem( void );
static void IMM32_InitThreadData( void );
static void IMM32_CleanupThreadData( void );
/***********************************************************************
* IMM32_DllMain
*/
BOOL WINAPI IMM32_DllMain(
HINSTANCE hInstDLL,
DWORD fdwReason,
LPVOID lpvReserved )
{
switch ( fdwReason )
{
case DLL_PROCESS_ATTACH:
if ( IMM32_dwProcessAttached > 0 )
{
ERR( "cannot attach to two or more processes.\n" );
return FALSE;
}
IMM32_dwProcessAttached ++;
IMM32_InitProcessMem();
/*IMM32_RegisterIMEWndClass( hInstDLL );*/
break;
case DLL_PROCESS_DETACH:
/*IMM32_UnloadAllIMEs();*/
/*IMM32_UnregisterIMEWndClass( hInstDLL );*/
IMM32_CleanupProcessMem();
IMM32_dwProcessAttached --;
break;
case DLL_THREAD_ATTACH:
IMM32_InitThreadData();
break;
case DLL_THREAD_DETACH:
IMM32_CleanupThreadData();
break;
}
return TRUE;
}
static BOOL IMM32_InitProcessMem( void )
{
IMM32_hHeap = (HANDLE)NULL;
IMM32_dwTLSIndex = (DWORD)0xffffffff;
IMM32_hHeap = HeapCreate( 0, 0x10000, 0 );
if ( IMM32_hHeap == (HANDLE)NULL )
{
ERR( "cannot allocate heap for IMM32.\n" );
return FALSE;
}
IMM32_dwTLSIndex = TlsAlloc();
if ( IMM32_dwTLSIndex == (DWORD)0xffffffff )
{
ERR( "cannot allocate a TLS for IMM.\n" );
return FALSE;
}
InitializeCriticalSection( &IMM32_csIMM );
return TRUE;
}
static void IMM32_CleanupProcessMem( void )
{
DeleteCriticalSection( &IMM32_csIMM );
if ( IMM32_dwTLSIndex != (DWORD)0xffffffff )
{
TlsFree( IMM32_dwTLSIndex );
IMM32_dwTLSIndex = (DWORD)0xffffffff;
}
if ( IMM32_hHeap != (HANDLE)NULL )
{
(void)HeapDestroy( IMM32_hHeap );
IMM32_hHeap = (HANDLE)NULL;
}
}
LPVOID IMM32_HeapAlloc( DWORD dwFlags, DWORD dwSize )
{
return HeapAlloc( IMM32_hHeap, dwFlags, dwSize );
}
LPVOID IMM32_HeapReAlloc( DWORD dwFlags, LPVOID lpv, DWORD dwSize )
{
return HeapReAlloc( IMM32_hHeap, dwFlags, lpv, dwSize );
}
void IMM32_HeapFree( LPVOID lpv )
{
if ( lpv != NULL )
HeapFree( IMM32_hHeap, 0, lpv );
}
static void IMM32_InitThreadData( void )
{
TlsSetValue( IMM32_dwTLSIndex, NULL );
}
static void IMM32_CleanupThreadData( void )
{
IMM32_THREADDATA* pData;
pData = (IMM32_THREADDATA*)TlsGetValue( IMM32_dwTLSIndex );
if ( pData != NULL )
{
/* Destroy Thread-local Data. */
if ( pData->hwndIME != (HWND)NULL )
DestroyWindow( pData->hwndIME );
if ( pData->hIMC != NULLIMC )
ImmDestroyContext( pData->hIMC );
IMM32_HeapFree( pData );
TlsSetValue( IMM32_dwTLSIndex, NULL );
}
}
IMM32_THREADDATA* IMM32_GetThreadData( void )
{
IMM32_THREADDATA* pData;
pData = (IMM32_THREADDATA*)TlsGetValue( IMM32_dwTLSIndex );
if ( pData != NULL )
return pData;
pData = (IMM32_THREADDATA*)
IMM32_HeapAlloc( 0, sizeof(IMM32_THREADDATA) );
if ( pData == NULL )
return NULL;
/* Initialize Thread-local Data. */
pData->hwndIME = (HWND)NULL;
pData->hIMC = NULLIMC;
TlsSetValue( IMM32_dwTLSIndex, pData );
return pData;
}
/*
* This file implements 'moveable' memory block.
*
* Copyright 2000 Hidenori Takeshima
*/
#include "config.h"
#include "winbase.h"
#include "windef.h"
#include "wingdi.h"
#include "winuser.h"
#include "winerror.h"
#include "immddk.h"
#include "debugtools.h"
DEFAULT_DEBUG_CHANNEL(imm);
#include "imm_private.h"
#define IMM32_MOVEABLEMEM_LOCK_MAX ((DWORD)0xffffffff)
struct IMM32_tagMOVEABLEMEM
{
DWORD dwLockCount;
DWORD dwSize;
LPVOID lpvMem;
};
IMM32_MOVEABLEMEM* IMM32_MoveableAlloc( DWORD dwHeapFlags, DWORD dwHeapSize )
{
IMM32_MOVEABLEMEM* lpMoveable;
lpMoveable = (IMM32_MOVEABLEMEM*)
IMM32_HeapAlloc( 0, sizeof( IMM32_MOVEABLEMEM ) );
if ( lpMoveable != NULL )
{
lpMoveable->dwLockCount = 0;
lpMoveable->dwSize = dwHeapSize;
lpMoveable->lpvMem = NULL;
if ( dwHeapSize > 0 )
{
lpMoveable->lpvMem =
IMM32_HeapAlloc( dwHeapFlags, dwHeapSize );
if ( lpMoveable->lpvMem == NULL )
{
IMM32_HeapFree( lpMoveable );
lpMoveable = NULL;
}
}
}
return lpMoveable;
}
void IMM32_MoveableFree( IMM32_MOVEABLEMEM* lpMoveable )
{
IMM32_HeapFree( lpMoveable->lpvMem );
IMM32_HeapFree( lpMoveable );
}
BOOL IMM32_MoveableReAlloc( IMM32_MOVEABLEMEM* lpMoveable,
DWORD dwHeapFlags, DWORD dwHeapSize )
{
LPVOID lpv;
if ( dwHeapSize > 0 )
{
if ( lpMoveable->dwLockCount > 0 )
dwHeapFlags |= HEAP_REALLOC_IN_PLACE_ONLY;
lpv = IMM32_HeapReAlloc( dwHeapFlags,
lpMoveable->lpvMem, dwHeapSize );
if ( lpv == NULL )
return FALSE;
}
else
{
IMM32_HeapFree( lpMoveable->lpvMem );
lpv = NULL;
}
lpMoveable->dwSize = dwHeapSize;
lpMoveable->lpvMem = lpv;
return TRUE;
}
LPVOID IMM32_MoveableLock( IMM32_MOVEABLEMEM* lpMoveable )
{
if ( lpMoveable->dwLockCount == IMM32_MOVEABLEMEM_LOCK_MAX )
{
ERR( "lock count is 0xffffffff." );
}
else
{
lpMoveable->dwLockCount ++;
}
return lpMoveable->lpvMem;
}
BOOL IMM32_MoveableUnlock( IMM32_MOVEABLEMEM* lpMoveable )
{
if ( lpMoveable->dwLockCount == 0 )
return FALSE;
if ( --lpMoveable->dwLockCount > 0 )
return TRUE;
return FALSE;
}
DWORD IMM32_MoveableGetLockCount( IMM32_MOVEABLEMEM* lpMoveable )
{
return lpMoveable->dwLockCount;
}
DWORD IMM32_MoveableGetSize( IMM32_MOVEABLEMEM* lpMoveable )
{
return lpMoveable->dwSize;
}
/***********************************************************************
* ImmCreateIMCC (IMM32.@)
*
* Create IMCC(IMC Component).
*/
HIMCC WINAPI ImmCreateIMCC(DWORD dwSize)
{
IMM32_MOVEABLEMEM* lpMoveable;
TRACE("(%lu)\n", dwSize);
lpMoveable = IMM32_MoveableAlloc( HEAP_ZERO_MEMORY, dwSize );
if ( lpMoveable == NULL )
{
SetLastError(ERROR_OUTOFMEMORY);
return (HIMCC)NULL;
}
return (HIMCC)lpMoveable;
}
/***********************************************************************
* ImmDestroyIMCC (IMM32.@)
*
* Destroy IMCC(IMC Component).
*/
HIMCC WINAPI ImmDestroyIMCC(HIMCC hIMCC)
{
TRACE("(0x%08x)\n", (unsigned)hIMCC);
IMM32_MoveableFree( (IMM32_MOVEABLEMEM*)hIMCC );
return (HIMCC)NULL;
}
/***********************************************************************
* ImmLockIMCC (IMM32.@)
*/
LPVOID WINAPI ImmLockIMCC(HIMCC hIMCC)
{
TRACE("(0x%08x)\n", (unsigned)hIMCC);
return IMM32_MoveableLock( (IMM32_MOVEABLEMEM*)hIMCC );
}
/***********************************************************************
* ImmUnlockIMCC (IMM32.@)
*/
BOOL WINAPI ImmUnlockIMCC(HIMCC hIMCC)
{
TRACE("(0x%08x)\n", (unsigned)hIMCC);
return IMM32_MoveableUnlock( (IMM32_MOVEABLEMEM*)hIMCC );
}
/***********************************************************************
* ImmGetIMCCLockCount (IMM32.@)
*/
DWORD WINAPI ImmGetIMCCLockCount(HIMCC hIMCC)
{
TRACE("(0x%08x)\n", (unsigned)hIMCC);
return IMM32_MoveableGetLockCount( (IMM32_MOVEABLEMEM*)hIMCC );
}
/***********************************************************************
* ImmReSizeIMCC (IMM32.@)
*/
HIMCC WINAPI ImmReSizeIMCC(HIMCC hIMCC, DWORD dwSize)
{
TRACE("(0x%08x,%lu)\n", (unsigned)hIMCC, dwSize);
if ( !IMM32_MoveableReAlloc( (IMM32_MOVEABLEMEM*)hIMCC,
HEAP_ZERO_MEMORY, dwSize ) )
{
SetLastError(ERROR_OUTOFMEMORY);
return (HIMCC)NULL;
}
return hIMCC;
}
/***********************************************************************
* ImmGetIMCCSize (IMM32.@)
*/
DWORD WINAPI ImmGetIMCCSize(HIMCC hIMCC)
{
TRACE("(0x%08x)\n", (unsigned)hIMCC);
return IMM32_MoveableGetSize( (IMM32_MOVEABLEMEM*)hIMCC );
}
/*
* Helper functions for ANSI<->UNICODE string conversion
*
* Copyright 2000 Hidenori Takeshima
*/
#include "config.h"
#include "winbase.h"
#include "windef.h"
#include "wingdi.h"
#include "winuser.h"
#include "winerror.h"
#include "winnls.h"
#include "immddk.h"
#include "debugtools.h"
DEFAULT_DEBUG_CHANNEL(imm);
#include "imm_private.h"
INT IMM32_strlenAtoW( LPCSTR lpstr )
{
INT len;
len = MultiByteToWideChar( CP_ACP, 0, lpstr, -1, NULL, 0 );
return ( len > 0 ) ? (len-1) : 0;
}
INT IMM32_strlenWtoA( LPCWSTR lpwstr )
{
INT len;
len = WideCharToMultiByte( CP_ACP, 0, lpwstr, -1,
NULL, 0, NULL, NULL );
return ( len > 0 ) ? (len-1) : 0;
}
LPWSTR IMM32_strncpyAtoW( LPWSTR lpwstr, LPCSTR lpstr, INT wbuflen )
{
INT len;
len = MultiByteToWideChar( CP_ACP, 0, lpstr, -1, lpwstr, wbuflen );
if ( len == 0 )
*lpwstr = 0;
return lpwstr;
}
LPSTR IMM32_strncpyWtoA( LPSTR lpstr, LPCWSTR lpwstr, INT abuflen )
{
INT len;
len = WideCharToMultiByte( CP_ACP, 0, lpwstr, -1,
lpstr, abuflen, NULL, NULL );
if ( len == 0 )
*lpstr = 0;
return lpstr;
}
LPWSTR IMM32_strdupAtoW( LPCSTR lpstr )
{
INT len;
LPWSTR lpwstr = NULL;
len = IMM32_strlenAtoW( lpstr );
if ( len > 0 )
{
lpwstr = (LPWSTR)IMM32_HeapAlloc( 0, sizeof(WCHAR)*(len+1) );
if ( lpwstr != NULL )
(void)IMM32_strncpyAtoW( lpwstr, lpstr, len+1 );
}
return lpwstr;
}
LPSTR IMM32_strdupWtoA( LPCWSTR lpwstr )
{
INT len;
LPSTR lpstr = NULL;
len = IMM32_strlenWtoA( lpwstr );
if ( len > 0 )
{
lpstr = (LPSTR)IMM32_HeapAlloc( 0, sizeof(CHAR)*(len+1) );
if ( lpstr != NULL )
(void)IMM32_strncpyWtoA( lpstr, lpwstr, len+1 );
}
return lpstr;
}
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