ReactOS 0.4.15-dev-7788-g1ad9096
compat.c File Reference
#include "dbghelp_private.h"
Include dependency graph for compat.c:

Go to the source code of this file.

Functions

void__HeapAlloc (int heap, int flags, size_t size)
 
void__HeapReAlloc (int heap, DWORD d2, void *slab, SIZE_T newsize)
 
WCHARlstrcpynW (WCHAR *lpString1, const WCHAR *lpString2, int iMaxLength)
 
PIMAGE_NT_HEADERS __RtlImageNtHeader (void *data)
 
PIMAGE_SECTION_HEADER __RtlImageRvaToSection (const IMAGE_NT_HEADERS *NtHeader, PVOID BaseAddress, ULONG Rva)
 
PVOID __RtlImageRvaToVa (const IMAGE_NT_HEADERS *NtHeader, PVOID BaseAddress, ULONG Rva, PIMAGE_SECTION_HEADER *SectionHeader)
 
PVOID __RtlImageDirectoryEntryToData (PVOID BaseAddress, BOOLEAN MappedAsImage, USHORT Directory, PULONG Size)
 
BOOL __GetFileSizeEx (HANDLE file, PLARGE_INTEGER fsize)
 
BOOL __CloseHandle (HANDLE handle)
 
HANDLE __CreateFileW (LPCWSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, LPSECURITY_ATTRIBUTES lpSecurityAttributes, DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, HANDLE hTemplateFile)
 
BOOL __ReadFile (HANDLE file, PVOID buffer, DWORD len, PDWORD outlen, PVOID overlap)
 
DWORD __SetFilePointer (HANDLE file, LONG low, PLONG high, DWORD move)
 
void__MapViewOfFile (HANDLE file, DWORD d1, DWORD d2, DWORD d3, SIZE_T s)
 
BOOL __UnmapViewOfFile (const void *data)
 
LPSTR __lstrcpynA (LPSTR d, LPCSTR s, int c)
 
INT __WideCharToMultiByte (UINT page, DWORD flags, LPCWSTR src, INT srclen, LPSTR dst, INT dstlen, LPCSTR defchar, BOOL *used)
 
INT __MultiByteToWideChar (UINT page, DWORD flags, LPCSTR src, INT srclen, LPWSTR dst, INT dstlen)
 
HANDLE __FindExecutableImageExW (PCWSTR file, PCWSTR path, PWSTR out_buffer, PFIND_EXE_FILE_CALLBACKW x, PVOID y)
 
const charwine_dbg_sprintf (const char *format,...)
 
const charwine_dbgstr_an (const char *str, int n)
 
const charwine_dbgstr_wn (const WCHAR *str, int n)
 
BOOL __IsWow64Process (HANDLE Process, BOOL *is_wow64)
 
ULONG __RtlComputeCrc32 (ULONG Initial, PUCHAR Data, ULONG Length)
 

Variables

static const ULONG CrcTable [256]
 

Function Documentation

◆ __CloseHandle()

BOOL __CloseHandle ( HANDLE  handle)

Definition at line 146 of file compat.c.

147{
148 fclose(handle);
149 return TRUE;
150}
#define TRUE
Definition: types.h:120
_Check_return_opt_ _CRTIMP int __cdecl fclose(_Inout_ FILE *_File)

◆ __CreateFileW()

HANDLE __CreateFileW ( LPCWSTR  lpFileName,
DWORD  dwDesiredAccess,
DWORD  dwShareMode,
LPSECURITY_ATTRIBUTES  lpSecurityAttributes,
DWORD  dwCreationDisposition,
DWORD  dwFlagsAndAttributes,
HANDLE  hTemplateFile 
)

Definition at line 152 of file compat.c.

160{
161 char buf[MAX_PATH];
162 HANDLE res;
163
165 res = CreateFileA(buf, dwDesiredAccess, dwShareMode, lpSecurityAttributes, dwCreationDisposition, dwFlagsAndAttributes, hTemplateFile);
166 return res;
167}
#define NULL
Definition: types.h:112
#define CP_ACP
Definition: compat.h:109
#define CreateFileA(a, b, c, d, e, f, g)
Definition: compat.h:740
#define MAX_PATH
Definition: compat.h:34
#define WideCharToMultiByte
Definition: compat.h:111
GLuint res
Definition: glext.h:9613
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
_In_ LPCSTR lpFileName
Definition: winbase.h:3071

◆ __FindExecutableImageExW()

HANDLE __FindExecutableImageExW ( PCWSTR  file,
PCWSTR  path,
PWSTR  out_buffer,
PFIND_EXE_FILE_CALLBACKW  x,
PVOID  y 
)

Definition at line 286 of file compat.c.

287{
288 HANDLE ret = CreateFileW(file, 0, 0, NULL, 0, 0, NULL);
289 if(ret)
290 memcpy(out_buffer, file, (strlenW(file) + 1)*sizeof(WCHAR));
291
292 return ret;
293}
#define CreateFileW
Definition: compat.h:741
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
static HANDLE PIO_APC_ROUTINE PVOID PIO_STATUS_BLOCK ULONG PVOID ULONG PVOID out_buffer
Definition: file.c:100
#define strlenW(s)
Definition: unicode.h:28
Definition: fci.c:127
int ret
__wchar_t WCHAR
Definition: xmlstorage.h:180

◆ __GetFileSizeEx()

BOOL __GetFileSizeEx ( HANDLE  file,
PLARGE_INTEGER  fsize 
)

Definition at line 138 of file compat.c.

139{
140 if (fseek((FILE*)file, 0, 2) == -1)
141 return FALSE;
142 fsize->QuadPart = ftell((FILE*)file);
143 return TRUE;
144}
#define FALSE
Definition: types.h:117
GLint fsize
Definition: glext.h:9408
_Check_return_opt_ _CRTIMP int __cdecl fseek(_Inout_ FILE *_File, _In_ long _Offset, _In_ int _Origin)
_Check_return_ _CRTIMP long __cdecl ftell(_Inout_ FILE *_File)

◆ __HeapAlloc()

void * __HeapAlloc ( int  heap,
int  flags,
size_t  size 
)

Definition at line 3 of file compat.c.

4{
5 void * ret = malloc(size);
7 memset(ret, 0, size);
8 return ret;
9}
#define malloc
Definition: debug_ros.c:4
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
GLsizeiptr size
Definition: glext.h:5919
GLbitfield flags
Definition: glext.h:7161
#define memset(x, y, z)
Definition: compat.h:39

◆ __HeapReAlloc()

void * __HeapReAlloc ( int  heap,
DWORD  d2,
void slab,
SIZE_T  newsize 
)

Definition at line 11 of file compat.c.

12{
13 return realloc(slab, newsize);
14}
#define realloc
Definition: debug_ros.c:6

◆ __IsWow64Process()

BOOL __IsWow64Process ( HANDLE  Process,
BOOL is_wow64 
)

Definition at line 423 of file compat.c.

424{
425 *is_wow64 = FALSE;
426 return TRUE;
427}
BOOL is_wow64
Definition: msi.c:54

◆ __lstrcpynA()

LPSTR __lstrcpynA ( LPSTR  d,
LPCSTR  s,
int  c 
)

Definition at line 225 of file compat.c.

226{
227 LPSTR r = d;
228 while(*s && c)
229 {
230 *d++ = *s++;
231 c--;
232 }
233 return r;
234}
GLdouble s
Definition: gl.h:2039
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
const GLubyte * c
Definition: glext.h:8905
#define d
Definition: ke_i.h:81
char * LPSTR
Definition: xmlstorage.h:182

◆ __MapViewOfFile()

void * __MapViewOfFile ( HANDLE  file,
DWORD  d1,
DWORD  d2,
DWORD  d3,
SIZE_T  s 
)

Definition at line 194 of file compat.c.

195{
196 FILE *f = (FILE*)file;
198 char *result;
199
201 return NULL;
202
203 if (!GetFileSizeEx(file, &size))
204 return NULL;
205
206 if (fseek(f, 0, 0) == -1)
207 return NULL;
208
209 result = malloc(size.LowPart);
210 if (fread(result, 1, size.LowPart, f) != size.LowPart)
211 {
212 free(result);
213 return NULL;
214 }
215
216 return result;
217}
#define free
Definition: debug_ros.c:5
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define GetFileSizeEx
Definition: compat.h:757
GLfloat f
Definition: glext.h:7540
GLuint64EXT * result
Definition: glext.h:11304
_Check_return_opt_ _CRTIMP size_t __cdecl fread(_Out_writes_bytes_(_ElementSize *_Count) void *_DstBuf, _In_ size_t _ElementSize, _In_ size_t _Count, _Inout_ FILE *_File)

◆ __MultiByteToWideChar()

INT __MultiByteToWideChar ( UINT  page,
DWORD  flags,
LPCSTR  src,
INT  srclen,
LPWSTR  dst,
INT  dstlen 
)

Definition at line 263 of file compat.c.

265{
266 int i;
267
268 if (!src || !srclen || (!dst && dstlen))
269 {
271 return 0;
272 }
273
274 if (srclen < 0) srclen = strlen(src) + 1;
275
276 if(!dstlen)
277 return srclen;
278
279 for(i=0; i<srclen && i<dstlen; i++)
280 dst[i] = src[i];
281
282 return i;
283}
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define SetLastError(x)
Definition: compat.h:752
GLenum src
Definition: glext.h:6340
GLenum GLenum dst
Definition: glext.h:6340
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
static DWORD LPDWORD LPCSTR DWORD srclen
Definition: directory.c:52
static DWORD dstlen
Definition: directory.c:51

◆ __ReadFile()

BOOL __ReadFile ( HANDLE  file,
PVOID  buffer,
DWORD  len,
PDWORD  outlen,
PVOID  overlap 
)

Definition at line 169 of file compat.c.

170{
171 size_t read;
172
173 assert(overlap == NULL);
174
175 read = fread(buffer, 1, len, file);
176
177 if (ferror(file) != 0)
178 return FALSE;
179
180 *outlen = (DWORD)read;
181 return TRUE;
182}
#define read
Definition: acwin.h:96
#define assert(x)
Definition: debug.h:53
GLuint buffer
Definition: glext.h:5915
GLenum GLsizei len
Definition: glext.h:6722
_Check_return_ _CRTIMP int __cdecl ferror(_In_ FILE *_File)
#define DWORD
Definition: nt_native.h:44

◆ __RtlComputeCrc32()

ULONG __RtlComputeCrc32 ( ULONG  Initial,
PUCHAR  Data,
ULONG  Length 
)

Definition at line 501 of file compat.c.

502{
503 ULONG CrcValue = ~Initial;
504
505 while (Length > 0)
506 {
507 CrcValue = CrcTable[(CrcValue ^ *Data) & 0xff] ^ (CrcValue >> 8);
508 Data++;
509 Length--;
510 }
511 return ~CrcValue;
512}
static const ULONG CrcTable[256]
Definition: compat.c:438
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
uint32_t ULONG
Definition: typedefs.h:59

◆ __RtlImageDirectoryEntryToData()

PVOID __RtlImageDirectoryEntryToData ( PVOID  BaseAddress,
BOOLEAN  MappedAsImage,
USHORT  Directory,
PULONG  Size 
)

Definition at line 102 of file compat.c.

107{
108 PIMAGE_NT_HEADERS NtHeader;
109 ULONG Va;
110
111 /* Magic flag for non-mapped images. */
112 if ((ULONG_PTR)BaseAddress & 1)
113 {
116 }
117
118 NtHeader = RtlImageNtHeader(BaseAddress);
119 if (NtHeader == NULL)
120 return NULL;
121
123 return NULL;
124
126 if (Va == 0)
127 return NULL;
128
130
131 if (MappedAsImage || Va < SWAPD(NtHeader->OptionalHeader.SizeOfHeaders))
132 return (PVOID)((ULONG_PTR)BaseAddress + Va);
133
134 /* Image mapped as ordinary file, we must find raw pointer */
135 return RtlImageRvaToVa(NtHeader, BaseAddress, Va, NULL);
136}
#define SWAPD(x)
Definition: bytesex.h:7
#define RtlImageRvaToVa
Definition: compat.h:807
#define RtlImageNtHeader
Definition: compat.h:806
#define ULONG_PTR
Definition: config.h:101
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID * BaseAddress
Definition: mmfuncs.h:404
_In_ BOOLEAN MappedAsImage
Definition: rtlfuncs.h:3938
base for all directory entries
Definition: entries.h:138
IMAGE_OPTIONAL_HEADER32 OptionalHeader
Definition: ntddk_ex.h:184
IMAGE_DATA_DIRECTORY DataDirectory[IMAGE_NUMBEROF_DIRECTORY_ENTRIES]
Definition: ntddk_ex.h:178
void * PVOID
Definition: typedefs.h:50
uint32_t ULONG_PTR
Definition: typedefs.h:65
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4533

◆ __RtlImageNtHeader()

PIMAGE_NT_HEADERS __RtlImageNtHeader ( void data)

Definition at line 34 of file compat.c.

35{
37 PIMAGE_NT_HEADERS NtHeaders;
38 PCHAR NtHeaderPtr;
39 if (DosHeader->e_magic != IMAGE_DOS_SIGNATURE)
40 return NULL;
41 NtHeaderPtr = ((PCHAR)data) + DosHeader->e_lfanew;
42 NtHeaders = (PIMAGE_NT_HEADERS)NtHeaderPtr;
43 if (NtHeaders->Signature != IMAGE_NT_SIGNATURE)
44 return NULL;
45 return NtHeaders;
46}
PIMAGE_NT_HEADERS32 PIMAGE_NT_HEADERS
Definition: ntddk_ex.h:187
struct _IMAGE_DOS_HEADER * PIMAGE_DOS_HEADER
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
#define PCHAR
Definition: match.c:90
#define IMAGE_NT_SIGNATURE
Definition: pedump.c:93
#define IMAGE_DOS_SIGNATURE
Definition: pedump.c:89
char * PCHAR
Definition: typedefs.h:51

◆ __RtlImageRvaToSection()

PIMAGE_SECTION_HEADER __RtlImageRvaToSection ( const IMAGE_NT_HEADERS NtHeader,
PVOID  BaseAddress,
ULONG  Rva 
)

Definition at line 49 of file compat.c.

53{
55 ULONG Va;
57
59 Section = IMAGE_FIRST_SECTION(NtHeader);
60
61 while (Count--)
62 {
63 Va = SWAPD(Section->VirtualAddress);
64 if ((Va <= Rva) && (Rva < Va + SWAPD(Section->SizeOfRawData)))
65 return Section;
66 Section++;
67 }
68
69 return NULL;
70}
#define SWAPW(x)
Definition: bytesex.h:8
int Count
Definition: noreturn.cpp:7
#define IMAGE_FIRST_SECTION(NtHeader)
Definition: ntimage.h:427
IMAGE_FILE_HEADER FileHeader
Definition: ntddk_ex.h:183

◆ __RtlImageRvaToVa()

PVOID __RtlImageRvaToVa ( const IMAGE_NT_HEADERS NtHeader,
PVOID  BaseAddress,
ULONG  Rva,
PIMAGE_SECTION_HEADER SectionHeader 
)

Definition at line 73 of file compat.c.

78{
80
81 if (SectionHeader)
82 Section = *SectionHeader;
83
84 if ((Section == NULL) ||
85 (Rva < SWAPD(Section->VirtualAddress)) ||
86 (Rva >= SWAPD(Section->VirtualAddress) + SWAPD(Section->SizeOfRawData)))
87 {
88 Section = RtlImageRvaToSection(NtHeader, BaseAddress, Rva);
89 if (Section == NULL)
90 return NULL;
91
92 if (SectionHeader)
93 *SectionHeader = Section;
94 }
95
96 return (PVOID)((ULONG_PTR)BaseAddress + Rva +
98 (ULONG_PTR)SWAPD(Section->VirtualAddress));
99}
#define RtlImageRvaToSection
Definition: compat.h:808
DWORD PointerToRawData
Definition: pedump.c:290

◆ __SetFilePointer()

DWORD __SetFilePointer ( HANDLE  file,
LONG  low,
PLONG  high,
DWORD  move 
)

Definition at line 184 of file compat.c.

185{
186 assert(move == FILE_BEGIN);
187 assert(high == NULL);
188
189 if (fseek(file, low, SEEK_SET))
191 return low;
192}
#define FILE_BEGIN
Definition: compat.h:761
#define INVALID_SET_FILE_POINTER
Definition: compat.h:732
#define SEEK_SET
Definition: jmemansi.c:26

◆ __UnmapViewOfFile()

BOOL __UnmapViewOfFile ( const void data)

Definition at line 219 of file compat.c.

220{
221 free((void *)data);
222 return TRUE;
223}

◆ __WideCharToMultiByte()

INT __WideCharToMultiByte ( UINT  page,
DWORD  flags,
LPCWSTR  src,
INT  srclen,
LPSTR  dst,
INT  dstlen,
LPCSTR  defchar,
BOOL used 
)

Definition at line 238 of file compat.c.

240{
241 int i;
242
243 if (!src || !srclen || (!dst && dstlen))
244 {
246 return 0;
247 }
248
249 if (srclen < 0) srclen = strlenW(src) + 1;
250
251 if(!dstlen)
252 return srclen;
253
254 for(i=0; i<srclen && i<dstlen; i++)
255 dst[i] = src[i] & 0xFF;
256
257 if (used) *used = FALSE;
258
259 return i;
260}
static int used
Definition: adh-main.c:39

◆ lstrcpynW()

WCHAR * lstrcpynW ( WCHAR lpString1,
const WCHAR lpString2,
int  iMaxLength 
)

Definition at line 16 of file compat.c.

17{
18 LPWSTR d = lpString1;
19 const WCHAR* s = lpString2;
20 UINT count = iMaxLength;
21
22 while ((count > 1) && *s)
23 {
24 count--;
25 *d++ = *s++;
26 }
27
28 if (count)
29 *d = 0;
30
31 return lpString1;
32}
GLuint GLuint GLsizei count
Definition: gl.h:1545
unsigned int UINT
Definition: ndis.h:50
WCHAR * LPWSTR
Definition: xmlstorage.h:184

◆ wine_dbg_sprintf()

const char * wine_dbg_sprintf ( const char format,
  ... 
)

Definition at line 296 of file compat.c.

297{
298 static const int max_size = 200;
299 static char buffer[256];
300 char *ret;
301 int len;
303
305 ret = buffer;
307 if (len == -1 || len >= max_size) ret[max_size-1] = 0;
308 va_end(valist);
309 return ret;
310}
char * va_list
Definition: acmsvcex.h:78
#define va_end(ap)
Definition: acmsvcex.h:90
#define va_start(ap, A)
Definition: acmsvcex.h:91
static INT max_size
Definition: history.c:51
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
static __ms_va_list valist
Definition: printf.c:66
#define vsnprintf
Definition: tif_win32.c:406

Referenced by context_dump_fbo_attachment(), dbgstr_tag(), dbgstr_type_info(), debug_box(), debug_color(), debug_d3dshaderinstructionhandler(), debug_d3dstate(), debug_d3dusage(), debug_d3dusagequery(), debug_fboattachment(), debug_gl_shader_type(), debug_hlsl_type(), debug_ivec4(), debug_modifiers(), debug_print_dstreg(), debug_print_relarg(), debug_print_srcreg(), debug_print_swizzle(), debug_print_writemask(), debug_uvec4(), debug_vec4(), debug_wic_rect(), debug_writemask(), debuglvhittestinfo(), debugnmlistview(), debugrange(), debugstr_bindstatus(), debugstr_chunk(), debugstr_dmversion(), debugstr_filetime(), debugstr_flags(), debugstr_formatetc(), debugstr_fourcc(), debugstr_INTERPRETER_OPT_FLAGS(), debugstr_jsstr(), debugstr_jsval(), debugstr_nodetype(), debugstr_pointf(), debugstr_PROC_PF(), debugstr_protocol_flags(), debugstr_reader_prop(), debugstr_rectf(), debugstr_sid(), debugstr_sqllen(), debugstr_sqlulen(), debugstr_status_info(), debugstr_user_flags(), debugstr_writer_prop(), device_io(), dump_fmtetc(), dumpCooperativeLevel(), DumpEvent(), dwarf2_debug_ctx(), dwarf2_debug_di(), dwarf2_debug_traverse_ctx(), filetime_to_str(), get_regname(), hex_str(), MCI_MessageToString(), shdebugstr_guid(), SPY_GetMsgName(), wine_dbgstr_addr(), wine_dbgstr_fcc(), wine_dbgstr_icerr(), wined3d_debug_location(), and wined3d_debug_resource_access().

◆ wine_dbgstr_an()

const char * wine_dbgstr_an ( const char str,
int  n 
)

Definition at line 313 of file compat.c.

314{
315 static const char hex[16] = "0123456789abcdef";
316 char *dst, *res;
317 size_t size;
318 static char buffer[256];
319
320 if (!((ULONG_PTR)str >> 16))
321 {
322 if (!str) return "(null)";
323 res = buffer;
324 sprintf( res, "#%04x", LOWORD(str) );
325 return res;
326 }
327 if (n == -1) n = strlen(str);
328 if (n < 0) n = 0;
329 size = 10 + min( 300, n * 4 );
330 dst = res = buffer;
331 *dst++ = '"';
332 while (n-- > 0 && dst <= res + size - 9)
333 {
334 unsigned char c = *str++;
335 switch (c)
336 {
337 case '\n': *dst++ = '\\'; *dst++ = 'n'; break;
338 case '\r': *dst++ = '\\'; *dst++ = 'r'; break;
339 case '\t': *dst++ = '\\'; *dst++ = 't'; break;
340 case '"': *dst++ = '\\'; *dst++ = '"'; break;
341 case '\\': *dst++ = '\\'; *dst++ = '\\'; break;
342 default:
343 if (c >= ' ' && c <= 126)
344 *dst++ = c;
345 else
346 {
347 *dst++ = '\\';
348 *dst++ = 'x';
349 *dst++ = hex[(c >> 4) & 0x0f];
350 *dst++ = hex[c & 0x0f];
351 }
352 }
353 }
354 *dst++ = '"';
355 if (n > 0)
356 {
357 *dst++ = '.';
358 *dst++ = '.';
359 *dst++ = '.';
360 }
361 *dst++ = 0;
362 return res;
363}
GLdouble n
Definition: glext.h:7729
int hex(char ch)
#define c
Definition: ke_i.h:80
#define sprintf(buf, format,...)
Definition: sprintf.c:55
#define min(a, b)
Definition: monoChain.cc:55
#define LOWORD(l)
Definition: pedump.c:82
const WCHAR * str

◆ wine_dbgstr_wn()

const char * wine_dbgstr_wn ( const WCHAR str,
int  n 
)

Definition at line 367 of file compat.c.

368{
369 char *dst, *res;
370 size_t size;
371 static char buffer[256];
372
373 if (!((ULONG_PTR)str >> 16))
374 {
375 if (!str) return "(null)";
376 res = buffer;
377 sprintf( res, "#%04x", LOWORD(str) );
378 return res;
379 }
380 if (n == -1)
381 {
382 const WCHAR *end = str;
383 while (*end) end++;
384 n = end - str;
385 }
386 if (n < 0) n = 0;
387 size = 12 + min( 300, n * 5 );
388 dst = res = buffer;
389 *dst++ = 'L';
390 *dst++ = '"';
391 while (n-- > 0 && dst <= res + size - 10)
392 {
393 WCHAR c = *str++;
394 switch (c)
395 {
396 case '\n': *dst++ = '\\'; *dst++ = 'n'; break;
397 case '\r': *dst++ = '\\'; *dst++ = 'r'; break;
398 case '\t': *dst++ = '\\'; *dst++ = 't'; break;
399 case '"': *dst++ = '\\'; *dst++ = '"'; break;
400 case '\\': *dst++ = '\\'; *dst++ = '\\'; break;
401 default:
402 if (c >= ' ' && c <= 126)
403 *dst++ = c;
404 else
405 {
406 *dst++ = '\\';
407 sprintf(dst,"%04x",c);
408 dst+=4;
409 }
410 }
411 }
412 *dst++ = '"';
413 if (n > 0)
414 {
415 *dst++ = '.';
416 *dst++ = '.';
417 *dst++ = '.';
418 }
419 *dst++ = 0;
420 return res;
421}
GLuint GLuint end
Definition: gl.h:1545

Referenced by _test_hkey_main_Value_W(), check_output_raw(), get_token(), map_type(), mqr_GetMetadataByName(), SoftModalMessageBox(), START_TEST(), tally_test_file(), test_flags_NtQueryDirectoryFile(), test_GetStateText(), test_IdnToAscii(), test_IdnToNameprepUnicode(), test_IdnToUnicode(), Test_ImageSection(), test_IMLangConvertCharset(), test_IWinHttpRequest(), test_marshal_bstr(), test_NtQueryDirectoryFile(), test_NtQueryDirectoryFile_case(), test_NtQueryKey(), test_query_attribute_information_file(), test_readdirectorychanges_cr(), test_reg_query_info(), test_RtlUTF8ToUnicodeN(), test_saxstr(), test_SQLGetPrivateProfileStringW(), test_string_data(), test_string_data_process(), test_utf7_decoding(), Widget_bstr(), and wine_dbgstr_us().

Variable Documentation

◆ CrcTable

const ULONG CrcTable[256]
static

Definition at line 438 of file compat.c.

Referenced by __RtlComputeCrc32().