ReactOS  0.4.14-dev-98-gb0d4763
data.c File Reference
#include <windows.h>
#include <stdio.h>
#include <zlib.h>
#include "wine/test.h"
Include dependency graph for data.c:

Go to the source code of this file.

Functions

static const chartmpdir ()
 
static int extract_one (const char *filename, const char *resid)
 
int extract_msvc_dll (char szFile[MAX_PATH], char szPath[MAX_PATH])
 
void cleanup_msvc_dll ()
 
int extract_gcc_dll (char szFile[MAX_PATH])
 
void cleanup_gcc_dll ()
 

Variables

IMAGE_DOS_HEADER __ImageBase
 
static char szTempPath [MAX_PATH]
 

Function Documentation

◆ cleanup_gcc_dll()

void cleanup_gcc_dll ( )

Definition at line 120 of file data.c.

121 {
122  char szFile[MAX_PATH];
123  BOOL ret;
124  const char* dir = tmpdir();
125 
126  sprintf(szFile, "%s\\uffs.dll", dir);
127  ret = DeleteFileA(szFile);
128  ok(ret, "DeleteFileA failed(%d)\n", GetLastError());
130  ok(ret, "RemoveDirectoryA failed(%d)\n", GetLastError());
131 }
static const char * tmpdir()
Definition: data.c:18
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define sprintf(buf, format,...)
Definition: sprintf.c:55
unsigned int BOOL
Definition: ntddk_ex.h:94
BOOL WINAPI DeleteFileA(IN LPCSTR lpFileName)
Definition: delete.c:24
unsigned int dir
Definition: maze.c:112
#define MAX_PATH
Definition: compat.h:26
int ret
#define ok(value,...)
Definition: atltest.h:57
BOOL WINAPI RemoveDirectoryA(IN LPCSTR lpPathName)
Definition: dir.c:714

Referenced by START_TEST().

◆ cleanup_msvc_dll()

void cleanup_msvc_dll ( )

Definition at line 90 of file data.c.

91 {
92  char szFile[MAX_PATH];
93  BOOL ret;
94  const char* dir = tmpdir();
95 
96  sprintf(szFile, "%s\\uffs.pdb", dir);
97  ret = DeleteFileA(szFile);
98  ok(ret, "DeleteFileA failed(%d)\n", GetLastError());
99 
100  sprintf(szFile, "%s\\uffs.dll", dir);
101  ret = DeleteFileA(szFile);
102  ok(ret, "DeleteFileA failed(%d)\n", GetLastError());
104  ok(ret, "RemoveDirectoryA failed(%d)\n", GetLastError());
105 }
static const char * tmpdir()
Definition: data.c:18
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define sprintf(buf, format,...)
Definition: sprintf.c:55
unsigned int BOOL
Definition: ntddk_ex.h:94
BOOL WINAPI DeleteFileA(IN LPCSTR lpFileName)
Definition: delete.c:24
unsigned int dir
Definition: maze.c:112
#define MAX_PATH
Definition: compat.h:26
int ret
#define ok(value,...)
Definition: atltest.h:57
BOOL WINAPI RemoveDirectoryA(IN LPCSTR lpPathName)
Definition: dir.c:714

Referenced by START_TEST().

◆ extract_gcc_dll()

int extract_gcc_dll ( char  szFile[MAX_PATH])

Definition at line 107 of file data.c.

108 {
109  const char* dir = tmpdir();
111  ok(ret, "CreateDirectoryA failed(%d)\n", GetLastError());
112 
113  sprintf(szFile, "%s\\uffs.dll", dir);
114  if (!extract_one(szFile, "gcc_uffs.dll"))
115  return 0;
116 
117  return 1;
118 }
static int extract_one(const char *filename, const char *resid)
Definition: data.c:28
static const char * tmpdir()
Definition: data.c:18
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define sprintf(buf, format,...)
Definition: sprintf.c:55
unsigned int BOOL
Definition: ntddk_ex.h:94
BOOL WINAPI CreateDirectoryA(IN LPCSTR lpPathName, IN LPSECURITY_ATTRIBUTES lpSecurityAttributes)
Definition: dir.c:37
smooth NULL
Definition: ftsmooth.c:416
unsigned int dir
Definition: maze.c:112
int ret
#define ok(value,...)
Definition: atltest.h:57

Referenced by START_TEST().

◆ extract_msvc_dll()

int extract_msvc_dll ( char  szFile[MAX_PATH],
char  szPath[MAX_PATH] 
)

Definition at line 72 of file data.c.

73 {
74  const char* dir = tmpdir();
76  ok(ret, "CreateDirectoryA failed(%d)\n", GetLastError());
77 
78  sprintf(szFile, "%s\\uffs.pdb", dir);
79  if (!extract_one(szFile, "msvc_uffs.pdb"))
80  return 0;
81 
82  sprintf(szFile, "%s\\uffs.dll", dir);
83  if (!extract_one(szFile, "msvc_uffs.dll"))
84  return 0;
85 
86  strcpy(szPath, dir);
87  return 1;
88 }
static int extract_one(const char *filename, const char *resid)
Definition: data.c:28
static const char * tmpdir()
Definition: data.c:18
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define sprintf(buf, format,...)
Definition: sprintf.c:55
unsigned int BOOL
Definition: ntddk_ex.h:94
BOOL WINAPI CreateDirectoryA(IN LPCSTR lpPathName, IN LPSECURITY_ATTRIBUTES lpSecurityAttributes)
Definition: dir.c:37
smooth NULL
Definition: ftsmooth.c:416
unsigned int dir
Definition: maze.c:112
int ret
LPCWSTR szPath
Definition: env.c:35
#define ok(value,...)
Definition: atltest.h:57
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388

Referenced by START_TEST().

◆ extract_one()

static int extract_one ( const char filename,
const char resid 
)
static

Definition at line 28 of file data.c.

29 {
31  HGLOBAL glob;
32  PVOID data, decompressed;
33  uLongf size, dstsize;
34  DWORD gccSize, dwErr;
35  HANDLE file;
36  int ret;
37  HRSRC rsrc = FindResourceA(mod, resid, MAKEINTRESOURCEA(RT_RCDATA));
38  ok(rsrc != 0, "Failed finding '%s' res\n", resid);
39  if (!rsrc)
40  return 0;
41 
42  size = SizeofResource(mod, rsrc);
43  glob = LoadResource(mod, rsrc);
44  ok(glob != NULL, "Failed loading '%s' res\n", resid);
45  if (!glob)
46  return 0;
47 
49 
50  dstsize = 1024 * 256;
51  decompressed = malloc(dstsize);
52 
53  if (uncompress(decompressed, &dstsize, data, size) != Z_OK)
54  {
55  ok(0, "uncompress failed for %s\n", resid);
56  free(decompressed);
57  return 0;
58  }
59 
60 
62  gccSize = size;
63  ret = WriteFile(file, decompressed, dstsize, &gccSize, NULL);
64  dwErr = GetLastError();
66  free(decompressed);
67  ok(ret, "WriteFile failed (%d)\n", dwErr);
68  return ret && dstsize == gccSize;
69 }
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:24
#define CloseHandle
Definition: compat.h:398
int ZEXPORT uncompress(Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen)
Definition: uncompr.c:86
IMAGE_DOS_HEADER __ImageBase
Definition: mstscax.cpp:17
#define free
Definition: debug_ros.c:5
HRSRC WINAPI FindResourceA(HMODULE hModule, LPCSTR name, LPCSTR type)
Definition: res.c:155
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
LPVOID WINAPI LockResource(HGLOBAL handle)
Definition: res.c:550
#define MAKEINTRESOURCEA(i)
Definition: winuser.h:581
const char * filename
Definition: ioapi.h:135
#define GENERIC_WRITE
Definition: nt_native.h:90
#define Z_OK
Definition: zlib.h:177
HGLOBAL WINAPI LoadResource(HINSTANCE hModule, HRSRC hRsrc)
Definition: res.c:532
smooth NULL
Definition: ftsmooth.c:416
DWORD dwErr
Definition: service.c:36
GLsizeiptr size
Definition: glext.h:5919
const char file[]
Definition: icontest.c:11
unsigned long DWORD
Definition: ntddk_ex.h:95
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
#define RT_RCDATA
Definition: pedump.c:372
int ret
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:126
HANDLE HMODULE
Definition: typedefs.h:75
uLong FAR uLongf
Definition: zconf.h:405
#define CREATE_ALWAYS
Definition: disk.h:72
#define ok(value,...)
Definition: atltest.h:57
char ** glob(const char *v)
Definition: fake.c:36
DWORD WINAPI SizeofResource(HINSTANCE hModule, HRSRC hRsrc)
Definition: res.c:568
#define malloc
Definition: debug_ros.c:4
#define CreateFileA(a, b, c, d, e, f, g)
Definition: compat.h:399
static int mod
Definition: i386-dis.c:1273
Definition: fci.c:126

Referenced by extract_gcc_dll(), and extract_msvc_dll().

◆ tmpdir()

static const char* tmpdir ( )
static

Definition at line 18 of file data.c.

19 {
20  if (szTempPath[0] == '\0')
21  {
23  lstrcatA(szTempPath, "dbghelp_tst");
24  }
25  return szTempPath;
26 }
LPSTR WINAPI lstrcatA(LPSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:123
#define MAX_PATH
Definition: compat.h:26
static char szTempPath[MAX_PATH]
Definition: data.c:16
DWORD WINAPI GetTempPathA(IN DWORD nBufferLength, OUT LPSTR lpBuffer)
Definition: path.c:2053

Referenced by cleanup_gcc_dll(), cleanup_msvc_dll(), extract_gcc_dll(), and extract_msvc_dll().

Variable Documentation

◆ __ImageBase

IMAGE_DOS_HEADER __ImageBase

Definition at line 17 of file mstscax.cpp.

Referenced by extract_one().

◆ szTempPath

char szTempPath[MAX_PATH]
static

Definition at line 16 of file data.c.

Referenced by tmpdir().