ReactOS 0.4.15-dev-7906-g1b85a5f
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}
unsigned int dir
Definition: maze.c:112
#define ok(value,...)
Definition: atltest.h:57
#define MAX_PATH
Definition: compat.h:34
BOOL WINAPI DeleteFileA(IN LPCSTR lpFileName)
Definition: delete.c:24
BOOL WINAPI RemoveDirectoryA(IN LPCSTR lpPathName)
Definition: dir.c:714
unsigned int BOOL
Definition: ntddk_ex.h:94
static const char * tmpdir()
Definition: data.c:18
#define sprintf(buf, format,...)
Definition: sprintf.c:55
int ret
DWORD WINAPI GetLastError(void)
Definition: except.c:1042

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}

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}
#define NULL
Definition: types.h:112
BOOL WINAPI CreateDirectoryA(IN LPCSTR lpPathName, IN LPSECURITY_ATTRIBUTES lpSecurityAttributes)
Definition: dir.c:37
static int extract_one(const char *filename, const char *resid)
Definition: data.c:28

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
87 return 1;
88}
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
LPCWSTR szPath
Definition: env.c:37

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{
32 PVOID data, decompressed;
33 uLongf size, dstsize;
34 DWORD gccSize, dwErr;
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);
66 free(decompressed);
67 ok(ret, "WriteFile failed (%d)\n", dwErr);
68 return ret && dstsize == gccSize;
69}
DWORD dwErr
Definition: service.c:36
#define free
Definition: debug_ros.c:5
#define malloc
Definition: debug_ros.c:4
#define CloseHandle
Definition: compat.h:739
#define CreateFileA(a, b, c, d, e, f, g)
Definition: compat.h:740
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:137
#define Z_OK
Definition: zlib.h:114
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:24
HRSRC WINAPI FindResourceA(HMODULE hModule, LPCSTR name, LPCSTR type)
Definition: res.c:155
DWORD WINAPI SizeofResource(HINSTANCE hModule, HRSRC hRsrc)
Definition: res.c:568
LPVOID WINAPI LockResource(HGLOBAL handle)
Definition: res.c:550
HGLOBAL WINAPI LoadResource(HINSTANCE hModule, HRSRC hRsrc)
Definition: res.c:532
char ** glob(const char *v)
Definition: fake.c:36
unsigned long DWORD
Definition: ntddk_ex.h:95
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLsizeiptr size
Definition: glext.h:5919
static int mod
Definition: i386-dis.c:1288
const char * filename
Definition: ioapi.h:137
#define CREATE_ALWAYS
Definition: disk.h:72
IMAGE_DOS_HEADER __ImageBase
#define GENERIC_WRITE
Definition: nt_native.h:90
#define RT_RCDATA
Definition: pedump.c:372
Definition: fci.c:127
HANDLE HMODULE
Definition: typedefs.h:77
int ZEXPORT uncompress(Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen)
Definition: uncompr.c:86
#define MAKEINTRESOURCEA(i)
Definition: winuser.h:581
uLong FAR uLongf
Definition: zconf.h:411

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}
DWORD WINAPI GetTempPathA(IN DWORD nBufferLength, OUT LPSTR lpBuffer)
Definition: path.c:2054
LPSTR WINAPI lstrcatA(LPSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:123
static char szTempPath[MAX_PATH]
Definition: data.c:16

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

Variable Documentation

◆ __ImageBase

IMAGE_DOS_HEADER __ImageBase
extern

Referenced by extract_one().

◆ szTempPath