2001-01-11 00:59:25 +01:00
|
|
|
/*
|
|
|
|
* msvcrt.dll misc functions
|
|
|
|
*
|
|
|
|
* Copyright 2000 Jon Griffiths
|
2002-03-10 00:29:33 +01:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2001-01-11 00:59:25 +01:00
|
|
|
*/
|
|
|
|
|
2003-03-15 23:26:09 +01:00
|
|
|
#include "config.h"
|
|
|
|
#include "wine/port.h"
|
|
|
|
|
2001-04-11 01:25:25 +02:00
|
|
|
#include <stdlib.h>
|
2001-04-23 20:20:55 +02:00
|
|
|
|
|
|
|
#include "msvcrt.h"
|
2002-01-22 01:57:16 +01:00
|
|
|
#include "wine/debug.h"
|
2010-01-15 18:02:56 +01:00
|
|
|
#include "ntsecapi.h"
|
2019-04-01 17:46:07 +02:00
|
|
|
#include "windows.h"
|
2019-05-14 12:30:46 +02:00
|
|
|
#include "wine/asm.h"
|
2002-01-22 01:57:16 +01:00
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(msvcrt);
|
2001-01-11 00:59:25 +01:00
|
|
|
|
2013-03-27 10:39:30 +01:00
|
|
|
static unsigned int output_format;
|
2001-01-11 00:59:25 +01:00
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* _beep (MSVCRT.@)
|
|
|
|
*/
|
2011-06-03 15:28:32 +02:00
|
|
|
void CDECL MSVCRT__beep( unsigned int freq, unsigned int duration)
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
|
|
|
TRACE(":Freq %d, Duration %d\n",freq,duration);
|
|
|
|
Beep(freq, duration);
|
|
|
|
}
|
|
|
|
|
2006-01-14 17:27:28 +01:00
|
|
|
/*********************************************************************
|
|
|
|
* srand (MSVCRT.@)
|
|
|
|
*/
|
2006-06-13 11:21:19 +02:00
|
|
|
void CDECL MSVCRT_srand( unsigned int seed )
|
2006-01-14 17:27:28 +01:00
|
|
|
{
|
|
|
|
thread_data_t *data = msvcrt_get_thread_data();
|
|
|
|
data->random_seed = seed;
|
|
|
|
}
|
|
|
|
|
2001-01-11 00:59:25 +01:00
|
|
|
/*********************************************************************
|
|
|
|
* rand (MSVCRT.@)
|
|
|
|
*/
|
2006-06-13 11:21:19 +02:00
|
|
|
int CDECL MSVCRT_rand(void)
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
2006-01-14 17:27:28 +01:00
|
|
|
thread_data_t *data = msvcrt_get_thread_data();
|
|
|
|
|
|
|
|
/* this is the algorithm used by MSVC, according to
|
|
|
|
* http://en.wikipedia.org/wiki/List_of_pseudorandom_number_generators */
|
|
|
|
data->random_seed = data->random_seed * 214013 + 2531011;
|
|
|
|
return (data->random_seed >> 16) & MSVCRT_RAND_MAX;
|
2001-01-11 00:59:25 +01:00
|
|
|
}
|
|
|
|
|
2010-01-15 18:02:56 +01:00
|
|
|
/*********************************************************************
|
|
|
|
* rand_s (MSVCRT.@)
|
|
|
|
*/
|
|
|
|
int CDECL MSVCRT_rand_s(unsigned int *pval)
|
|
|
|
{
|
|
|
|
if (!pval || !RtlGenRandom(pval, sizeof(*pval)))
|
|
|
|
{
|
|
|
|
*MSVCRT__errno() = MSVCRT_EINVAL;
|
|
|
|
return MSVCRT_EINVAL;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2001-01-11 00:59:25 +01:00
|
|
|
/*********************************************************************
|
|
|
|
* _sleep (MSVCRT.@)
|
|
|
|
*/
|
2009-05-23 11:49:09 +02:00
|
|
|
void CDECL MSVCRT__sleep(MSVCRT_ulong timeout)
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
2009-05-23 11:49:09 +02:00
|
|
|
TRACE("_sleep for %d milliseconds\n",timeout);
|
2001-01-11 00:59:25 +01:00
|
|
|
Sleep((timeout)?timeout:1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* _lfind (MSVCRT.@)
|
|
|
|
*/
|
2006-06-13 11:21:19 +02:00
|
|
|
void* CDECL _lfind(const void* match, const void* start,
|
|
|
|
unsigned int* array_size, unsigned int elem_size,
|
2010-05-12 17:15:29 +02:00
|
|
|
int (CDECL *cf)(const void*,const void*) )
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
|
|
|
unsigned int size = *array_size;
|
|
|
|
if (size)
|
|
|
|
do
|
|
|
|
{
|
|
|
|
if (cf(match, start) == 0)
|
|
|
|
return (void *)start; /* found */
|
2006-09-18 23:18:41 +02:00
|
|
|
start = (const char *)start + elem_size;
|
2001-01-11 00:59:25 +01:00
|
|
|
} while (--size);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2016-11-29 04:37:18 +01:00
|
|
|
/*********************************************************************
|
|
|
|
* _lfind_s (MSVCRT.@)
|
|
|
|
*/
|
|
|
|
void* CDECL _lfind_s(const void* match, const void* start,
|
|
|
|
unsigned int* array_size, unsigned int elem_size,
|
|
|
|
int (CDECL *cf)(void*,const void*,const void*),
|
|
|
|
void* context)
|
|
|
|
{
|
|
|
|
unsigned int size;
|
|
|
|
if (!MSVCRT_CHECK_PMT(match != NULL)) return NULL;
|
|
|
|
if (!MSVCRT_CHECK_PMT(array_size != NULL)) return NULL;
|
|
|
|
if (!MSVCRT_CHECK_PMT(start != NULL || *array_size == 0)) return NULL;
|
|
|
|
if (!MSVCRT_CHECK_PMT(cf != NULL)) return NULL;
|
|
|
|
if (!MSVCRT_CHECK_PMT(elem_size != 0)) return NULL;
|
|
|
|
|
|
|
|
size = *array_size;
|
|
|
|
if (size)
|
|
|
|
do
|
|
|
|
{
|
|
|
|
if (cf(context, match, start) == 0)
|
|
|
|
return (void *)start; /* found */
|
|
|
|
start = (const char *)start + elem_size;
|
|
|
|
} while (--size);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2001-01-11 00:59:25 +01:00
|
|
|
/*********************************************************************
|
|
|
|
* _lsearch (MSVCRT.@)
|
|
|
|
*/
|
2006-06-13 11:21:19 +02:00
|
|
|
void* CDECL _lsearch(const void* match, void* start,
|
|
|
|
unsigned int* array_size, unsigned int elem_size,
|
2010-05-12 17:15:29 +02:00
|
|
|
int (CDECL *cf)(const void*,const void*) )
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
|
|
|
unsigned int size = *array_size;
|
|
|
|
if (size)
|
|
|
|
do
|
|
|
|
{
|
|
|
|
if (cf(match, start) == 0)
|
|
|
|
return start; /* found */
|
2002-07-03 23:10:43 +02:00
|
|
|
start = (char*)start + elem_size;
|
2001-01-11 00:59:25 +01:00
|
|
|
} while (--size);
|
|
|
|
|
|
|
|
/* not found, add to end */
|
|
|
|
memcpy(start, match, elem_size);
|
|
|
|
array_size[0]++;
|
|
|
|
return start;
|
|
|
|
}
|
|
|
|
|
2012-07-16 20:36:10 +02:00
|
|
|
/*********************************************************************
|
|
|
|
* bsearch_s (msvcrt.@)
|
|
|
|
*/
|
|
|
|
void* CDECL MSVCRT_bsearch_s(const void *key, const void *base,
|
|
|
|
MSVCRT_size_t nmemb, MSVCRT_size_t size,
|
|
|
|
int (__cdecl *compare)(void *, const void *, const void *), void *ctx)
|
|
|
|
{
|
|
|
|
ssize_t min = 0;
|
|
|
|
ssize_t max = nmemb - 1;
|
|
|
|
|
2012-07-26 11:05:32 +02:00
|
|
|
if (!MSVCRT_CHECK_PMT(size != 0)) return NULL;
|
|
|
|
if (!MSVCRT_CHECK_PMT(compare != NULL)) return NULL;
|
2012-07-16 20:36:10 +02:00
|
|
|
|
|
|
|
while (min <= max)
|
|
|
|
{
|
2014-06-29 12:05:36 +02:00
|
|
|
ssize_t cursor = min + (max - min) / 2;
|
2012-07-16 20:36:10 +02:00
|
|
|
int ret = compare(ctx, key,(const char *)base+(cursor*size));
|
|
|
|
if (!ret)
|
|
|
|
return (char*)base+(cursor*size);
|
|
|
|
if (ret < 0)
|
|
|
|
max = cursor - 1;
|
|
|
|
else
|
|
|
|
min = cursor + 1;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2013-10-01 11:28:54 +02:00
|
|
|
static int CDECL compare_wrapper(void *ctx, const void *e1, const void *e2)
|
|
|
|
{
|
|
|
|
int (__cdecl *compare)(const void *, const void *) = ctx;
|
|
|
|
return compare(e1, e2);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* bsearch (msvcrt.@)
|
|
|
|
*/
|
|
|
|
void* CDECL MSVCRT_bsearch(const void *key, const void *base, MSVCRT_size_t nmemb,
|
|
|
|
MSVCRT_size_t size, int (__cdecl *compar)(const void *, const void *))
|
|
|
|
{
|
|
|
|
return MSVCRT_bsearch_s(key, base, nmemb, size, compare_wrapper, compar);
|
|
|
|
}
|
2001-01-11 00:59:25 +01:00
|
|
|
/*********************************************************************
|
|
|
|
* _chkesp (MSVCRT.@)
|
2003-03-15 23:26:09 +01:00
|
|
|
*
|
|
|
|
* Trap to a debugger if the value of the stack pointer has changed.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* None.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Does not return.
|
|
|
|
*
|
|
|
|
* NOTES
|
|
|
|
* This function is available for iX86 only.
|
|
|
|
*
|
|
|
|
* When VC++ generates debug code, it stores the value of the stack pointer
|
|
|
|
* before calling any external function, and checks the value following
|
|
|
|
* the call. It then calls this function, which will trap if the values are
|
|
|
|
* not the same. Usually this means that the prototype used to call
|
|
|
|
* the function is incorrect. It can also mean that the .spec entry has
|
|
|
|
* the wrong calling convention or parameters.
|
2001-01-11 00:59:25 +01:00
|
|
|
*/
|
2003-03-15 23:26:09 +01:00
|
|
|
#ifdef __i386__
|
|
|
|
|
|
|
|
# ifdef __GNUC__
|
2004-05-17 23:08:31 +02:00
|
|
|
|
2003-03-15 23:26:09 +01:00
|
|
|
__ASM_GLOBAL_FUNC(_chkesp,
|
|
|
|
"jnz 1f\n\t"
|
|
|
|
"ret\n"
|
|
|
|
"1:\tpushl %ebp\n\t"
|
2009-06-25 11:50:42 +02:00
|
|
|
__ASM_CFI(".cfi_adjust_cfa_offset 4\n\t")
|
|
|
|
__ASM_CFI(".cfi_rel_offset %ebp,0\n\t")
|
2003-03-15 23:26:09 +01:00
|
|
|
"movl %esp,%ebp\n\t"
|
2009-06-25 11:50:42 +02:00
|
|
|
__ASM_CFI(".cfi_def_cfa_register %ebp\n\t")
|
2005-11-23 19:55:06 +01:00
|
|
|
"subl $12,%esp\n\t"
|
2003-03-15 23:26:09 +01:00
|
|
|
"pushl %eax\n\t"
|
|
|
|
"pushl %ecx\n\t"
|
|
|
|
"pushl %edx\n\t"
|
|
|
|
"call " __ASM_NAME("MSVCRT_chkesp_fail") "\n\t"
|
|
|
|
"popl %edx\n\t"
|
|
|
|
"popl %ecx\n\t"
|
|
|
|
"popl %eax\n\t"
|
2005-11-23 19:55:06 +01:00
|
|
|
"leave\n\t"
|
2009-06-25 11:50:42 +02:00
|
|
|
__ASM_CFI(".cfi_def_cfa %esp,4\n\t")
|
|
|
|
__ASM_CFI(".cfi_same_value %ebp\n\t")
|
2007-01-13 00:38:07 +01:00
|
|
|
"ret")
|
2001-01-11 00:59:25 +01:00
|
|
|
|
2017-07-25 11:49:07 +02:00
|
|
|
void CDECL DECLSPEC_HIDDEN MSVCRT_chkesp_fail(void)
|
2003-03-15 23:26:09 +01:00
|
|
|
{
|
|
|
|
ERR("Stack pointer incorrect after last function call - Bad prototype/spec entry?\n");
|
|
|
|
DebugBreak();
|
2001-01-11 00:59:25 +01:00
|
|
|
}
|
2003-03-15 23:26:09 +01:00
|
|
|
|
|
|
|
# else /* __GNUC__ */
|
2004-05-17 23:08:31 +02:00
|
|
|
|
|
|
|
/**********************************************************************/
|
|
|
|
|
2006-06-13 11:21:19 +02:00
|
|
|
void CDECL _chkesp(void)
|
2004-05-17 23:08:31 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2003-03-15 23:26:09 +01:00
|
|
|
# endif /* __GNUC__ */
|
|
|
|
|
|
|
|
#endif /* __i386__ */
|
2010-11-17 17:07:47 +01:00
|
|
|
|
2014-05-21 11:57:13 +02:00
|
|
|
static inline void swap(char *l, char *r, MSVCRT_size_t size)
|
|
|
|
{
|
|
|
|
char tmp;
|
|
|
|
|
|
|
|
while(size--) {
|
|
|
|
tmp = *l;
|
|
|
|
*l++ = *r;
|
|
|
|
*r++ = tmp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void small_sort(void *base, MSVCRT_size_t nmemb, MSVCRT_size_t size,
|
|
|
|
int (CDECL *compar)(void *, const void *, const void *), void *context)
|
|
|
|
{
|
|
|
|
MSVCRT_size_t e, i;
|
|
|
|
char *max, *p;
|
|
|
|
|
|
|
|
for(e=nmemb; e>1; e--) {
|
|
|
|
max = base;
|
|
|
|
for(i=1; i<e; i++) {
|
|
|
|
p = (char*)base + i*size;
|
|
|
|
if(compar(context, p, max) > 0)
|
|
|
|
max = p;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(p != max)
|
|
|
|
swap(p, max, size);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void quick_sort(void *base, MSVCRT_size_t nmemb, MSVCRT_size_t size,
|
|
|
|
int (CDECL *compar)(void *, const void *, const void *), void *context)
|
2010-11-17 17:07:47 +01:00
|
|
|
{
|
2014-06-17 12:48:40 +02:00
|
|
|
MSVCRT_size_t stack_lo[8*sizeof(MSVCRT_size_t)], stack_hi[8*sizeof(MSVCRT_size_t)];
|
|
|
|
MSVCRT_size_t beg, end, lo, hi, med;
|
|
|
|
int stack_pos;
|
2014-05-21 11:57:13 +02:00
|
|
|
|
|
|
|
stack_pos = 0;
|
|
|
|
stack_lo[stack_pos] = 0;
|
|
|
|
stack_hi[stack_pos] = nmemb-1;
|
|
|
|
|
|
|
|
#define X(i) ((char*)base+size*(i))
|
|
|
|
while(stack_pos >= 0) {
|
|
|
|
beg = stack_lo[stack_pos];
|
|
|
|
end = stack_hi[stack_pos--];
|
|
|
|
|
|
|
|
if(end-beg < 8) {
|
|
|
|
small_sort(X(beg), end-beg+1, size, compar, context);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
lo = beg;
|
|
|
|
hi = end;
|
2014-06-17 12:48:40 +02:00
|
|
|
med = lo + (hi-lo+1)/2;
|
2014-05-21 11:57:13 +02:00
|
|
|
if(compar(context, X(lo), X(med)) > 0)
|
|
|
|
swap(X(lo), X(med), size);
|
|
|
|
if(compar(context, X(lo), X(hi)) > 0)
|
|
|
|
swap(X(lo), X(hi), size);
|
|
|
|
if(compar(context, X(med), X(hi)) > 0)
|
|
|
|
swap(X(med), X(hi), size);
|
|
|
|
|
|
|
|
lo++;
|
|
|
|
hi--;
|
|
|
|
while(1) {
|
|
|
|
while(lo <= hi) {
|
|
|
|
if(lo!=med && compar(context, X(lo), X(med))>0)
|
|
|
|
break;
|
|
|
|
lo++;
|
|
|
|
}
|
|
|
|
|
|
|
|
while(med != hi) {
|
|
|
|
if(compar(context, X(hi), X(med)) <= 0)
|
|
|
|
break;
|
|
|
|
hi--;
|
2010-11-17 17:07:47 +01:00
|
|
|
}
|
2014-05-21 11:57:13 +02:00
|
|
|
|
|
|
|
if(hi < lo)
|
|
|
|
break;
|
|
|
|
|
|
|
|
swap(X(lo), X(hi), size);
|
|
|
|
if(hi == med)
|
|
|
|
med = lo;
|
|
|
|
lo++;
|
|
|
|
hi--;
|
|
|
|
}
|
|
|
|
|
|
|
|
while(hi > beg) {
|
|
|
|
if(hi!=med && compar(context, X(hi), X(med))!=0)
|
|
|
|
break;
|
|
|
|
hi--;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(hi-beg >= end-lo) {
|
|
|
|
stack_lo[++stack_pos] = beg;
|
|
|
|
stack_hi[stack_pos] = hi;
|
|
|
|
stack_lo[++stack_pos] = lo;
|
|
|
|
stack_hi[stack_pos] = end;
|
|
|
|
}else {
|
|
|
|
stack_lo[++stack_pos] = lo;
|
|
|
|
stack_hi[stack_pos] = end;
|
|
|
|
stack_lo[++stack_pos] = beg;
|
|
|
|
stack_hi[stack_pos] = hi;
|
2010-11-17 17:07:47 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#undef X
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* qsort_s (MSVCRT.@)
|
|
|
|
*
|
2014-05-21 11:57:13 +02:00
|
|
|
* This function is trying to sort data doing identical comparisons
|
|
|
|
* as native does. There are still cases where it behaves differently.
|
2010-11-17 17:07:47 +01:00
|
|
|
*/
|
|
|
|
void CDECL MSVCRT_qsort_s(void *base, MSVCRT_size_t nmemb, MSVCRT_size_t size,
|
|
|
|
int (CDECL *compar)(void *, const void *, const void *), void *context)
|
|
|
|
{
|
2014-05-21 11:57:13 +02:00
|
|
|
const MSVCRT_size_t total_size = nmemb*size;
|
2010-11-17 17:07:47 +01:00
|
|
|
|
2012-07-26 11:05:32 +02:00
|
|
|
if (!MSVCRT_CHECK_PMT(base != NULL || (base == NULL && nmemb == 0))) return;
|
|
|
|
if (!MSVCRT_CHECK_PMT(size > 0)) return;
|
|
|
|
if (!MSVCRT_CHECK_PMT(compar != NULL)) return;
|
|
|
|
if (total_size / size != nmemb) return;
|
2010-11-17 17:07:47 +01:00
|
|
|
|
|
|
|
if (nmemb < 2) return;
|
|
|
|
|
2014-05-21 11:57:13 +02:00
|
|
|
quick_sort(base, nmemb, size, compar, context);
|
2010-11-17 17:07:47 +01:00
|
|
|
}
|
2011-03-08 20:41:07 +01:00
|
|
|
|
2013-10-01 11:29:10 +02:00
|
|
|
/*********************************************************************
|
|
|
|
* qsort (MSVCRT.@)
|
|
|
|
*/
|
|
|
|
void CDECL MSVCRT_qsort(void *base, MSVCRT_size_t nmemb, MSVCRT_size_t size,
|
|
|
|
int (CDECL *compar)(const void*, const void*))
|
|
|
|
{
|
2014-05-21 11:57:13 +02:00
|
|
|
MSVCRT_qsort_s(base, nmemb, size, compare_wrapper, compar);
|
2013-10-01 11:29:10 +02:00
|
|
|
}
|
|
|
|
|
2011-03-08 20:41:07 +01:00
|
|
|
/*********************************************************************
|
|
|
|
* _get_output_format (MSVCRT.@)
|
|
|
|
*/
|
2014-04-16 16:15:07 +02:00
|
|
|
unsigned int CDECL MSVCRT__get_output_format(void)
|
2011-03-08 20:41:07 +01:00
|
|
|
{
|
2013-03-27 10:39:30 +01:00
|
|
|
return output_format;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* _set_output_format (MSVCRT.@)
|
|
|
|
*/
|
2014-09-13 22:54:58 +02:00
|
|
|
unsigned int CDECL MSVCRT__set_output_format(unsigned int new_output_format)
|
2013-03-27 10:39:30 +01:00
|
|
|
{
|
|
|
|
unsigned int ret = output_format;
|
|
|
|
|
|
|
|
if(!MSVCRT_CHECK_PMT(new_output_format==0 || new_output_format==MSVCRT__TWO_DIGIT_EXPONENT))
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
output_format = new_output_format;
|
|
|
|
return ret;
|
2011-03-08 20:41:07 +01:00
|
|
|
}
|
2011-04-20 12:37:56 +02:00
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* _resetstkoflw (MSVCRT.@)
|
|
|
|
*/
|
2011-06-03 15:28:32 +02:00
|
|
|
int CDECL MSVCRT__resetstkoflw(void)
|
2011-04-20 12:37:56 +02:00
|
|
|
{
|
|
|
|
int stack_addr;
|
2014-06-22 15:15:10 +02:00
|
|
|
DWORD oldprot;
|
2011-04-20 12:37:56 +02:00
|
|
|
|
|
|
|
/* causes stack fault that updates NtCurrentTeb()->Tib.StackLimit */
|
2014-06-22 15:15:10 +02:00
|
|
|
return VirtualProtect(&stack_addr, 1, PAGE_GUARD|PAGE_READWRITE, &oldprot);
|
2011-04-20 12:37:56 +02:00
|
|
|
}
|
2014-04-16 16:15:21 +02:00
|
|
|
|
2018-05-09 07:17:51 +02:00
|
|
|
#if _MSVCR_VER>=80 && _MSVCR_VER<=90
|
2018-01-07 06:05:31 +01:00
|
|
|
|
2014-04-16 16:15:21 +02:00
|
|
|
/*********************************************************************
|
2018-01-07 06:05:31 +01:00
|
|
|
* _decode_pointer (MSVCR80.@)
|
2014-04-16 16:15:21 +02:00
|
|
|
*/
|
|
|
|
void * CDECL MSVCRT_decode_pointer(void * ptr)
|
|
|
|
{
|
|
|
|
return DecodePointer(ptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
2018-01-07 06:05:31 +01:00
|
|
|
* _encode_pointer (MSVCR80.@)
|
2014-04-16 16:15:21 +02:00
|
|
|
*/
|
|
|
|
void * CDECL MSVCRT_encode_pointer(void * ptr)
|
|
|
|
{
|
|
|
|
return EncodePointer(ptr);
|
|
|
|
}
|
|
|
|
|
2018-05-09 07:17:51 +02:00
|
|
|
#endif /* _MSVCR_VER>=80 && _MSVCR_VER<=90 */
|
|
|
|
|
|
|
|
#if _MSVCR_VER>=80 && _MSVCR_VER<=100
|
2014-04-16 16:15:21 +02:00
|
|
|
/*********************************************************************
|
2018-01-07 06:05:31 +01:00
|
|
|
* _encoded_null (MSVCR80.@)
|
2014-04-16 16:15:21 +02:00
|
|
|
*/
|
|
|
|
void * CDECL _encoded_null(void)
|
|
|
|
{
|
|
|
|
TRACE("\n");
|
|
|
|
|
|
|
|
return EncodePointer(NULL);
|
|
|
|
}
|
2018-05-09 07:17:51 +02:00
|
|
|
#endif
|
2018-01-07 06:05:31 +01:00
|
|
|
|
|
|
|
#if _MSVCR_VER>=70
|
2014-04-16 16:15:21 +02:00
|
|
|
/*********************************************************************
|
2018-01-07 06:05:31 +01:00
|
|
|
* _CRT_RTC_INIT (MSVCR70.@)
|
2014-04-16 16:15:21 +02:00
|
|
|
*/
|
|
|
|
void* CDECL _CRT_RTC_INIT(void *unk1, void *unk2, int unk3, int unk4, int unk5)
|
|
|
|
{
|
|
|
|
TRACE("%p %p %x %x %x\n", unk1, unk2, unk3, unk4, unk5);
|
|
|
|
return NULL;
|
|
|
|
}
|
2018-01-10 07:21:45 +01:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if _MSVCR_VER>=80
|
2014-04-16 16:15:21 +02:00
|
|
|
|
|
|
|
/*********************************************************************
|
2018-01-10 07:21:45 +01:00
|
|
|
* _CRT_RTC_INITW (MSVCR80.@)
|
2014-04-16 16:15:21 +02:00
|
|
|
*/
|
|
|
|
void* CDECL _CRT_RTC_INITW(void *unk1, void *unk2, int unk3, int unk4, int unk5)
|
|
|
|
{
|
|
|
|
TRACE("%p %p %x %x %x\n", unk1, unk2, unk3, unk4, unk5);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
2018-01-07 06:05:31 +01:00
|
|
|
* _byteswap_ushort (MSVCR80.@)
|
2014-04-16 16:15:21 +02:00
|
|
|
*/
|
|
|
|
unsigned short CDECL _byteswap_ushort(unsigned short s)
|
|
|
|
{
|
|
|
|
return (s<<8) + (s>>8);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
2018-01-07 06:05:31 +01:00
|
|
|
* _byteswap_ulong (MSVCR80.@)
|
2014-04-16 16:15:21 +02:00
|
|
|
*/
|
|
|
|
ULONG CDECL MSVCRT__byteswap_ulong(ULONG l)
|
|
|
|
{
|
|
|
|
return (l<<24) + ((l<<8)&0xFF0000) + ((l>>8)&0xFF00) + (l>>24);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
2018-01-07 06:05:31 +01:00
|
|
|
* _byteswap_uint64 (MSVCR80.@)
|
2014-04-16 16:15:21 +02:00
|
|
|
*/
|
|
|
|
unsigned __int64 CDECL _byteswap_uint64(unsigned __int64 i)
|
|
|
|
{
|
|
|
|
return (i<<56) + ((i&0xFF00)<<40) + ((i&0xFF0000)<<24) + ((i&0xFF000000)<<8) +
|
|
|
|
((i>>8)&0xFF000000) + ((i>>24)&0xFF0000) + ((i>>40)&0xFF00) + (i>>56);
|
|
|
|
}
|
2014-04-17 13:07:21 +02:00
|
|
|
|
2018-01-07 06:05:31 +01:00
|
|
|
#endif /* _MSVCR_VER>=80 */
|
|
|
|
|
|
|
|
#if _MSVCR_VER>=110
|
|
|
|
|
2014-04-17 13:07:21 +02:00
|
|
|
/*********************************************************************
|
|
|
|
* __crtGetShowWindowMode (MSVCR110.@)
|
|
|
|
*/
|
|
|
|
int CDECL MSVCR110__crtGetShowWindowMode(void)
|
|
|
|
{
|
|
|
|
STARTUPINFOW si;
|
|
|
|
|
|
|
|
GetStartupInfoW(&si);
|
2019-04-01 17:46:07 +02:00
|
|
|
TRACE("flags=%x window=%d\n", si.dwFlags, si.wShowWindow);
|
|
|
|
return si.dwFlags & STARTF_USESHOWWINDOW ? si.wShowWindow : SW_SHOWDEFAULT;
|
2014-04-17 13:07:21 +02:00
|
|
|
}
|
2014-06-26 14:23:07 +02:00
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* __crtInitializeCriticalSectionEx (MSVCR110.@)
|
|
|
|
*/
|
|
|
|
BOOL CDECL MSVCR110__crtInitializeCriticalSectionEx(
|
|
|
|
CRITICAL_SECTION *cs, DWORD spin_count, DWORD flags)
|
|
|
|
{
|
|
|
|
TRACE("(%p %x %x)\n", cs, spin_count, flags);
|
|
|
|
return InitializeCriticalSectionEx(cs, spin_count, flags);
|
|
|
|
}
|
2014-12-04 23:40:51 +01:00
|
|
|
|
2018-01-07 06:05:31 +01:00
|
|
|
#endif /* _MSVCR_VER>=110 */
|
|
|
|
|
|
|
|
#if _MSVCR_VER>=120
|
2014-12-04 23:40:51 +01:00
|
|
|
/*********************************************************************
|
|
|
|
* _vacopy (MSVCR120.@)
|
|
|
|
*/
|
|
|
|
void CDECL MSVCR120__vacopy(__ms_va_list *dest, __ms_va_list src)
|
|
|
|
{
|
|
|
|
__ms_va_copy(*dest, src);
|
|
|
|
}
|
2018-01-07 06:05:31 +01:00
|
|
|
#endif
|
2016-01-19 13:53:19 +01:00
|
|
|
|
2018-01-07 06:05:31 +01:00
|
|
|
#if _MSVCR_VER>=80
|
2016-01-19 13:53:19 +01:00
|
|
|
/*********************************************************************
|
|
|
|
* _crt_debugger_hook (MSVCR80.@)
|
|
|
|
*/
|
|
|
|
void CDECL MSVCRT__crt_debugger_hook(int reserved)
|
|
|
|
{
|
|
|
|
WARN("(%x)\n", reserved);
|
|
|
|
}
|
2018-01-07 06:05:31 +01:00
|
|
|
#endif
|
2017-03-16 17:44:52 +01:00
|
|
|
|
2018-01-07 06:05:31 +01:00
|
|
|
#if _MSVCR_VER>=110
|
2017-03-16 17:44:52 +01:00
|
|
|
/*********************************************************************
|
|
|
|
* __crtUnhandledException (MSVCR110.@)
|
|
|
|
*/
|
|
|
|
LONG CDECL MSVCRT__crtUnhandledException(EXCEPTION_POINTERS *ep)
|
|
|
|
{
|
|
|
|
TRACE("(%p)\n", ep);
|
|
|
|
SetUnhandledExceptionFilter(NULL);
|
|
|
|
return UnhandledExceptionFilter(ep);
|
|
|
|
}
|
2018-02-06 15:38:05 +01:00
|
|
|
|
|
|
|
/* ?_Trace_agents@Concurrency@@YAXW4Agents_EventType@1@_JZZ */
|
|
|
|
void WINAPIV _Trace_agents(/*enum Concurrency::Agents_EventType*/int type, __int64 id, ...)
|
|
|
|
{
|
|
|
|
FIXME("(%d %s)\n", type, wine_dbgstr_longlong(id));
|
|
|
|
}
|
2018-01-07 06:05:31 +01:00
|
|
|
#endif
|
2017-04-01 00:20:32 +02:00
|
|
|
|
2018-01-07 06:05:31 +01:00
|
|
|
#if _MSVCR_VER>=120
|
2017-04-01 00:20:32 +02:00
|
|
|
/*********************************************************************
|
|
|
|
* __crtSleep (MSVCR120.@)
|
|
|
|
*/
|
|
|
|
void CDECL MSVCRT__crtSleep(DWORD timeout)
|
|
|
|
{
|
|
|
|
TRACE("(%u)\n", timeout);
|
|
|
|
Sleep(timeout);
|
|
|
|
}
|
2018-07-09 13:41:45 +02:00
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* _SetWinRTOutOfMemoryExceptionCallback (MSVCR120.@)
|
|
|
|
*/
|
|
|
|
void CDECL MSVCR120__SetWinRTOutOfMemoryExceptionCallback(void *callback)
|
|
|
|
{
|
|
|
|
FIXME("(%p): stub\n", callback);
|
|
|
|
}
|
2018-01-07 06:05:31 +01:00
|
|
|
#endif
|