msvcirt: Add support for ios state variables.
This commit is contained in:
parent
f2037e2e96
commit
b6c5bd15c4
|
@ -30,6 +30,7 @@
|
|||
WINE_DEFAULT_DEBUG_CHANNEL(msvcirt);
|
||||
|
||||
#define RESERVE_SIZE 512
|
||||
#define STATEBUF_SIZE 8
|
||||
|
||||
/* ?adjustfield@ios@@2JB */
|
||||
const LONG ios_adjustfield = FLAGS_left | FLAGS_right | FLAGS_internal;
|
||||
|
@ -48,6 +49,10 @@ CRITICAL_SECTION_DEBUG ios_static_lock_debug =
|
|||
CRITICAL_SECTION ios_static_lock = { &ios_static_lock_debug, -1, 0, 0, 0, 0 };
|
||||
/* ?x_maxbit@ios@@0JA */
|
||||
LONG ios_maxbit = 0x8000;
|
||||
/* ?x_curindex@ios@@0HA */
|
||||
int ios_curindex = -1;
|
||||
/* ?x_statebuf@ios@@0PAJA */
|
||||
LONG ios_statebuf[STATEBUF_SIZE] = {0};
|
||||
|
||||
/* class streambuf */
|
||||
typedef struct {
|
||||
|
@ -1018,8 +1023,8 @@ void __thiscall ios_init(ios *this, streambuf *sb)
|
|||
DEFINE_THISCALL_WRAPPER(ios_iword, 8)
|
||||
LONG* __thiscall ios_iword(const ios *this, int index)
|
||||
{
|
||||
FIXME("(%p %d) stub\n", this, index);
|
||||
return NULL;
|
||||
TRACE("(%p %d)\n", this, index);
|
||||
return &ios_statebuf[index];
|
||||
}
|
||||
|
||||
/* ?lock@ios@@QAAXXZ */
|
||||
|
@ -1091,8 +1096,8 @@ int __thiscall ios_precision_get(const ios *this)
|
|||
DEFINE_THISCALL_WRAPPER(ios_pword, 8)
|
||||
void** __thiscall ios_pword(const ios *this, int index)
|
||||
{
|
||||
FIXME("(%p %d) stub\n", this, index);
|
||||
return NULL;
|
||||
TRACE("(%p %d)\n", this, index);
|
||||
return (void**)&ios_statebuf[index];
|
||||
}
|
||||
|
||||
/* ?rdbuf@ios@@QBEPAVstreambuf@@XZ */
|
||||
|
@ -1245,8 +1250,14 @@ int __thiscall ios_width_get(const ios *this)
|
|||
/* ?xalloc@ios@@SAHXZ */
|
||||
int __cdecl ios_xalloc(void)
|
||||
{
|
||||
FIXME("() stub\n");
|
||||
return 0;
|
||||
int ret;
|
||||
|
||||
TRACE("()\n");
|
||||
|
||||
ios_lockc();
|
||||
ret = (ios_curindex < STATEBUF_SIZE-1) ? ++ios_curindex : -1;
|
||||
ios_unlockc();
|
||||
return ret;
|
||||
}
|
||||
|
||||
/******************************************************************
|
||||
|
|
|
@ -776,10 +776,10 @@
|
|||
@ stub -arch=win64 ?writepad@ostream@@AEAAAEAV1@PEBD0@Z
|
||||
@ stub -arch=win32 ?ws@@YAAAVistream@@AAV1@@Z # class istream & __cdecl ws(class istream &)
|
||||
@ stub -arch=win64 ?ws@@YAAEAVistream@@AEAV1@@Z
|
||||
# @ extern ?x_curindex@ios@@0HA # static int ios::x_curindex
|
||||
@ extern ?x_curindex@ios@@0HA ios_curindex
|
||||
@ extern ?x_lockc@ios@@0U_CRT_CRITICAL_SECTION@@A ios_static_lock
|
||||
@ extern ?x_maxbit@ios@@0JA ios_maxbit
|
||||
# @ extern ?x_statebuf@ios@@0PAJA # static long * ios::x_statebuf
|
||||
@ extern ?x_statebuf@ios@@0PAJA ios_statebuf
|
||||
@ cdecl ?xalloc@ios@@SAHXZ() ios_xalloc
|
||||
@ thiscall -arch=win32 ?xsgetn@streambuf@@UAEHPADH@Z(ptr ptr long) streambuf_xsgetn
|
||||
@ cdecl -arch=win64 ?xsgetn@streambuf@@UEAAHPEADH@Z(ptr ptr long) streambuf_xsgetn
|
||||
|
|
|
@ -149,6 +149,11 @@ static int (*__thiscall p_ios_fail)(const ios*);
|
|||
static void (*__thiscall p_ios_clear)(ios*, int);
|
||||
static LONG *p_ios_maxbit;
|
||||
static LONG (*__cdecl p_ios_bitalloc)(void);
|
||||
static int *p_ios_curindex;
|
||||
static LONG *p_ios_statebuf;
|
||||
static LONG* (*__thiscall p_ios_iword)(const ios*, int);
|
||||
static void** (*__thiscall p_ios_pword)(const ios*, int);
|
||||
static int (*__cdecl p_ios_xalloc)(void);
|
||||
|
||||
/* Emulate a __thiscall */
|
||||
#ifdef __i386__
|
||||
|
@ -267,6 +272,8 @@ static BOOL init(void)
|
|||
SET(p_ios_eof, "?eof@ios@@QEBAHXZ");
|
||||
SET(p_ios_fail, "?fail@ios@@QEBAHXZ");
|
||||
SET(p_ios_clear, "?clear@ios@@QEAAXH@Z");
|
||||
SET(p_ios_iword, "?iword@ios@@QEBAAEAJH@Z");
|
||||
SET(p_ios_pword, "?pword@ios@@QEBAAEAPEAXH@Z");
|
||||
} else {
|
||||
p_operator_new = (void*)GetProcAddress(msvcrt, "??2@YAPAXI@Z");
|
||||
|
||||
|
@ -315,12 +322,17 @@ static BOOL init(void)
|
|||
SET(p_ios_eof, "?eof@ios@@QBEHXZ");
|
||||
SET(p_ios_fail, "?fail@ios@@QBEHXZ");
|
||||
SET(p_ios_clear, "?clear@ios@@QAEXH@Z");
|
||||
SET(p_ios_iword, "?iword@ios@@QBEAAJH@Z");
|
||||
SET(p_ios_pword, "?pword@ios@@QBEAAPAXH@Z");
|
||||
}
|
||||
SET(p_ios_static_lock, "?x_lockc@ios@@0U_CRT_CRITICAL_SECTION@@A");
|
||||
SET(p_ios_lockc, "?lockc@ios@@KAXXZ");
|
||||
SET(p_ios_unlockc, "?unlockc@ios@@KAXXZ");
|
||||
SET(p_ios_maxbit, "?x_maxbit@ios@@0JA");
|
||||
SET(p_ios_bitalloc, "?bitalloc@ios@@SAJXZ");
|
||||
SET(p_ios_curindex, "?x_curindex@ios@@0HA");
|
||||
SET(p_ios_statebuf, "?x_statebuf@ios@@0PAJA");
|
||||
SET(p_ios_xalloc, "?xalloc@ios@@SAHXZ");
|
||||
|
||||
init_thiscall_thunk();
|
||||
return TRUE;
|
||||
|
@ -893,7 +905,8 @@ static void test_ios(void)
|
|||
struct ios_lock_arg lock_arg;
|
||||
HANDLE thread;
|
||||
BOOL locked;
|
||||
LONG expected, ret;
|
||||
LONG *pret, expected, ret;
|
||||
void **pret2;
|
||||
int i;
|
||||
|
||||
memset(&ios_obj, 0xab, sizeof(ios));
|
||||
|
@ -1099,6 +1112,24 @@ static void test_ios(void)
|
|||
expected <<= 1;
|
||||
}
|
||||
|
||||
/* xalloc/pword/iword */
|
||||
ok(*p_ios_curindex == -1, "expected -1 got %d\n", *p_ios_curindex);
|
||||
expected = 0;
|
||||
for (i = 0; i < 8; i++) {
|
||||
ret = p_ios_xalloc();
|
||||
ok(ret == expected, "expected %d got %d\n", expected, ret);
|
||||
ok(*p_ios_curindex == expected, "expected %d got %d\n", expected, *p_ios_curindex);
|
||||
pret = (LONG*) call_func2(p_ios_iword, &ios_obj, ret);
|
||||
ok(pret == &p_ios_statebuf[ret], "expected %p got %p\n", &p_ios_statebuf[ret], pret);
|
||||
ok(*pret == 0, "expected 0 got %d\n", *pret);
|
||||
pret2 = (void**) call_func2(p_ios_pword, &ios_obj, ret);
|
||||
ok(pret2 == (void**)&p_ios_statebuf[ret], "expected %p got %p\n", (void**)&p_ios_statebuf[ret], pret2);
|
||||
expected++;
|
||||
}
|
||||
ret = p_ios_xalloc();
|
||||
ok(ret == -1, "expected -1 got %d\n", ret);
|
||||
ok(*p_ios_curindex == 7, "expected 7 got %d\n", *p_ios_curindex);
|
||||
|
||||
SetEvent(lock_arg.release[1]);
|
||||
SetEvent(lock_arg.release[2]);
|
||||
WaitForSingleObject(thread, INFINITE);
|
||||
|
|
|
@ -764,10 +764,10 @@
|
|||
@ stub -arch=win64 ?writepad@ostream@@AEAAAEAV1@PEBD0@Z
|
||||
@ stub -arch=win32 ?ws@@YAAAVistream@@AAV1@@Z
|
||||
@ stub -arch=win64 ?ws@@YAAEAVistream@@AEAV1@@Z
|
||||
# @ extern ?x_curindex@ios@@0HA
|
||||
@ extern ?x_curindex@ios@@0HA msvcirt.?x_curindex@ios@@0HA
|
||||
@ extern ?x_lockc@ios@@0U_CRT_CRITICAL_SECTION@@A msvcirt.?x_lockc@ios@@0U_CRT_CRITICAL_SECTION@@A
|
||||
@ extern ?x_maxbit@ios@@0JA msvcirt.?x_maxbit@ios@@0JA
|
||||
# @ extern ?x_statebuf@ios@@0QAJA
|
||||
@ extern ?x_statebuf@ios@@0QAJA msvcrt40.?x_statebuf@ios@@0QAJA
|
||||
@ cdecl ?xalloc@ios@@SAHXZ() msvcirt.?xalloc@ios@@SAHXZ
|
||||
@ thiscall -arch=win32 ?xsgetn@streambuf@@UAEHPADH@Z(ptr ptr long) msvcirt.?xsgetn@streambuf@@UAEHPADH@Z
|
||||
@ cdecl -arch=win64 ?xsgetn@streambuf@@UEAAHPEADH@Z(ptr ptr long) msvcirt.?xsgetn@streambuf@@UEAAHPEADH@Z
|
||||
|
|
|
@ -838,10 +838,10 @@
|
|||
@ stub -arch=win64 ?writepad@ostream@@AEAAAEAV1@PEBD0@Z
|
||||
@ stub -arch=win32 ?ws@@YAAAVistream@@AAV1@@Z
|
||||
@ stub -arch=win64 ?ws@@YAAEAVistream@@AEAV1@@Z
|
||||
# @ extern ?x_curindex@ios@@0HA
|
||||
@ extern ?x_curindex@ios@@0HA msvcirt.?x_curindex@ios@@0HA
|
||||
@ extern ?x_lockc@ios@@0U_CRT_CRITICAL_SECTION@@A msvcirt.?x_lockc@ios@@0U_CRT_CRITICAL_SECTION@@A
|
||||
@ extern ?x_maxbit@ios@@0JA msvcirt.?x_maxbit@ios@@0JA
|
||||
# @ extern ?x_statebuf@ios@@0PAJA
|
||||
@ extern ?x_statebuf@ios@@0QAJA msvcirt.?x_statebuf@ios@@0QAJA
|
||||
@ cdecl ?xalloc@ios@@SAHXZ() msvcirt.?xalloc@ios@@SAHXZ
|
||||
@ thiscall -arch=win32 ?xsgetn@streambuf@@UAEHPADH@Z(ptr ptr long) msvcirt.?xsgetn@streambuf@@UAEHPADH@Z
|
||||
@ cdecl -arch=win64 ?xsgetn@streambuf@@UEAAHPEADH@Z(ptr ptr long) msvcirt.?xsgetn@streambuf@@UEAAHPEADH@Z
|
||||
|
|
Loading…
Reference in New Issue