This list is closed, nobody may subscribe to it.
| 2000 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(12) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2001 |
Jan
(13) |
Feb
(2) |
Mar
(1) |
Apr
(1) |
May
|
Jun
(38) |
Jul
(10) |
Aug
(70) |
Sep
(63) |
Oct
(61) |
Nov
(41) |
Dec
(28) |
| 2002 |
Jan
(43) |
Feb
(11) |
Mar
(9) |
Apr
(2) |
May
(97) |
Jun
(94) |
Jul
(13) |
Aug
(49) |
Sep
(41) |
Oct
(24) |
Nov
(55) |
Dec
(126) |
| 2003 |
Jan
(90) |
Feb
(75) |
Mar
(32) |
Apr
(24) |
May
(54) |
Jun
(54) |
Jul
(22) |
Aug
(4) |
Sep
(16) |
Oct
(8) |
Nov
(6) |
Dec
(13) |
| 2004 |
Jan
|
Feb
(17) |
Mar
(60) |
Apr
(21) |
May
(12) |
Jun
|
Jul
(13) |
Aug
|
Sep
(29) |
Oct
|
Nov
|
Dec
(2) |
| 2005 |
Jan
(22) |
Feb
(3) |
Mar
(2) |
Apr
(13) |
May
(82) |
Jun
(18) |
Jul
(30) |
Aug
(17) |
Sep
(3) |
Oct
(19) |
Nov
(4) |
Dec
(8) |
| 2006 |
Jan
(1) |
Feb
(6) |
Mar
(2) |
Apr
(40) |
May
|
Jun
(21) |
Jul
(1) |
Aug
(410) |
Sep
(3) |
Oct
|
Nov
(56) |
Dec
(7) |
| 2007 |
Jan
(19) |
Feb
|
Mar
(4) |
Apr
(8) |
May
(19) |
Jun
(6) |
Jul
(4) |
Aug
(6) |
Sep
|
Oct
(4) |
Nov
(3) |
Dec
(2) |
| 2008 |
Jan
(13) |
Feb
(18) |
Mar
(12) |
Apr
|
May
(2) |
Jun
|
Jul
|
Aug
(1) |
Sep
|
Oct
|
Nov
|
Dec
|
| 2009 |
Jan
|
Feb
(6) |
Mar
(8) |
Apr
(2) |
May
(2) |
Jun
|
Jul
|
Aug
(2) |
Sep
(11) |
Oct
(13) |
Nov
(17) |
Dec
(6) |
| 2010 |
Jan
(24) |
Feb
(10) |
Mar
(27) |
Apr
(20) |
May
(108) |
Jun
(8) |
Jul
(23) |
Aug
(38) |
Sep
(49) |
Oct
(17) |
Nov
(12) |
Dec
(14) |
| 2011 |
Jan
(17) |
Feb
(7) |
Mar
(28) |
Apr
(8) |
May
(20) |
Jun
(11) |
Jul
(7) |
Aug
(12) |
Sep
(4) |
Oct
(20) |
Nov
(19) |
Dec
(2) |
| 2012 |
Jan
(2) |
Feb
(6) |
Mar
(5) |
Apr
(24) |
May
(5) |
Jun
(4) |
Jul
(6) |
Aug
(18) |
Sep
(38) |
Oct
(26) |
Nov
(12) |
Dec
(6) |
| 2013 |
Jan
(19) |
Feb
(18) |
Mar
(44) |
Apr
(35) |
May
(18) |
Jun
(21) |
Jul
(10) |
Aug
(19) |
Sep
(44) |
Oct
(25) |
Nov
(1) |
Dec
(2) |
| 2014 |
Jan
(8) |
Feb
|
Mar
|
Apr
(5) |
May
(1) |
Jun
(3) |
Jul
|
Aug
(3) |
Sep
|
Oct
(4) |
Nov
(4) |
Dec
(7) |
| 2015 |
Jan
|
Feb
|
Mar
(1) |
Apr
|
May
(2) |
Jun
(4) |
Jul
(6) |
Aug
(2) |
Sep
(8) |
Oct
(2) |
Nov
(1) |
Dec
(3) |
| 2016 |
Jan
(7) |
Feb
(9) |
Mar
(5) |
Apr
(5) |
May
(9) |
Jun
(4) |
Jul
(20) |
Aug
(4) |
Sep
(7) |
Oct
(6) |
Nov
(9) |
Dec
(2) |
| 2017 |
Jan
(7) |
Feb
(7) |
Mar
(5) |
Apr
|
May
(1) |
Jun
(4) |
Jul
(12) |
Aug
(4) |
Sep
(1) |
Oct
(4) |
Nov
(11) |
Dec
(14) |
| 2018 |
Jan
(3) |
Feb
(3) |
Mar
|
Apr
|
May
|
Jun
|
Jul
(2) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| S | M | T | W | T | F | S |
|---|---|---|---|---|---|---|
|
|
|
|
1
|
2
|
3
|
4
|
|
5
(14) |
6
(8) |
7
(1) |
8
|
9
(5) |
10
(2) |
11
|
|
12
|
13
(13) |
14
(3) |
15
(7) |
16
|
17
(5) |
18
|
|
19
|
20
(4) |
21
(7) |
22
|
23
|
24
|
25
|
|
26
(18) |
27
|
28
(8) |
29
|
30
(2) |
31
|
|
|
From: <in...@us...> - 2002-05-30 14:25:55
|
Update of /cvsroot/mingw/msys/packages/m4/1.4/src
In directory usw-pr-cvs1:/tmp/cvs-serv13469/src
Modified Files:
freeze.c
Log Message:
Handle DOS line endings in frozen state files
Index: freeze.c
===================================================================
RCS file: /cvsroot/mingw/msys/packages/m4/1.4/src/freeze.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** freeze.c 13 May 2002 18:48:58 -0000 1.1.1.1
--- freeze.c 30 May 2002 14:25:52 -0000 1.2
***************
*** 203,206 ****
--- 203,218 ----
while (0)
+ #ifdef __MSYS__
+ # define SKIP_CARRIAGE_RETURNS \
+ do \
+ { \
+ while (character == '\r') \
+ GET_CHARACTER; \
+ } \
+ while (0)
+ #else /* ! __MSYS__ */
+ # define SKIP_CARRIAGE_RETURNS do { } while (0)
+ #endif /* ! __MSYS__ */
+
file = path_search (name);
if (file == NULL)
***************
*** 255,258 ****
--- 267,271 ----
GET_CHARACTER;
GET_NUMBER (number[1]);
+ SKIP_CARRIAGE_RETURNS;
VALIDATE ('\n');
***************
*** 291,294 ****
--- 304,308 ----
string[1][number[1]] = '\0';
GET_CHARACTER;
+ SKIP_CARRIAGE_RETURNS;
VALIDATE ('\n');
***************
*** 355,358 ****
--- 369,373 ----
VALIDATE ('1');
GET_CHARACTER;
+ SKIP_CARRIAGE_RETURNS;
VALIDATE ('\n');
break;
***************
*** 367,369 ****
--- 382,385 ----
#undef GET_NUMBER
#undef VALIDATE
+ #undef SKIP_CARRIAGE_RETURNS
}
|
|
From: <in...@us...> - 2002-05-30 14:25:55
|
Update of /cvsroot/mingw/msys/packages/m4/1.4 In directory usw-pr-cvs1:/tmp/cvs-serv13469 Modified Files: ChangeLog.MSYS Log Message: Handle DOS line endings in frozen state files Index: ChangeLog.MSYS =================================================================== RCS file: /cvsroot/mingw/msys/packages/m4/1.4/ChangeLog.MSYS,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ChangeLog.MSYS 13 May 2002 19:34:33 -0000 1.1 --- ChangeLog.MSYS 30 May 2002 14:25:51 -0000 1.2 *************** *** 1,2 **** --- 1,7 ---- + 2002.05.29 Luke Dunstan <in...@us...> + + * src/freeze.c (reload_frozen_state): Skip \r characters at end of + lines if __MSYS__. + 2002.05.13 Earnie Boyd <ea...@us...> |
|
From: <ea...@us...> - 2002-05-28 13:34:05
|
Update of /cvsroot/mingw/runtime
In directory usw-pr-cvs1:/tmp/cvs-serv25604
Modified Files:
ChangeLog dirent.c
Log Message:
Merging Cygwin changes
Index: ChangeLog
===================================================================
RCS file: /cvsroot/mingw/runtime/ChangeLog,v
retrieving revision 1.27
retrieving revision 1.28
diff -C2 -d -r1.27 -r1.28
*** ChangeLog 20 May 2002 19:16:44 -0000 1.27
--- ChangeLog 28 May 2002 13:06:46 -0000 1.28
***************
*** 1,2 ****
--- 1,25 ----
+ 2002-04-20 Danny Smith <dan...@us...>
+
+ * include/mbstring.h: New file.
+ * include/mbctype.h: New file.
+
+ 2002-04-20 Danny Smith <dan...@us...>
+
+ * include/tchar.h (__TEXT): Make same as define in
+ w32api/include/winnt.h.
+
+ 2002-04-20 Danny Smith <dan...@us...>
+
+ * include/tchar.h (_tputenv): Add UNICODE mappings.
+ (_tsearchenv): Likewise.
+ (_tmakepath): Likewise.
+ (_tsplitpath): Likewise.
+ (_tfullpath): Likewise.
+
+ 2002-04-18 Pascal Obry <ob...@gn...>
+
+ * dirent.c (opendir): Convert given pathname to
+ absolute pathname.
+
2002-04-09 Earnie Boyd <ea...@us...>
***************
*** 23,27 ****
(_vsnwprintf): Likewise.
! 2002-03-26 Danny Smith <dan...@so...>
* moldname.def.in (__MSVCRT__): Replace with !(__CRTDLL__).
--- 46,50 ----
(_vsnwprintf): Likewise.
! 2002-03-26 Danny Smith <dan...@us...>
* moldname.def.in (__MSVCRT__): Replace with !(__CRTDLL__).
Index: dirent.c
===================================================================
RCS file: /cvsroot/mingw/runtime/dirent.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** dirent.c 9 Sep 2001 21:20:07 -0000 1.3
--- dirent.c 28 May 2002 13:06:46 -0000 1.4
***************
*** 41,44 ****
--- 41,45 ----
DIR *nd;
unsigned int rc;
+ char szFullPath[MAX_PATH];
errno = 0;
***************
*** 57,61 ****
/* Attempt to determine if the given path really is a directory. */
! rc = GetFileAttributes(szPath);
if (rc == -1)
{
--- 58,62 ----
/* Attempt to determine if the given path really is a directory. */
! rc = GetFileAttributes (szPath);
if (rc == -1)
{
***************
*** 71,77 ****
}
/* Allocate enough space to store DIR structure and the complete
* directory path given. */
! nd = (DIR *) malloc (sizeof (DIR) + strlen (szPath) + strlen (SLASH) +
strlen (SUFFIX));
--- 72,81 ----
}
+ /* Make an absolute pathname. */
+ _fullpath (szFullPath, szPath, MAX_PATH);
+
/* Allocate enough space to store DIR structure and the complete
* directory path given. */
! nd = (DIR *) malloc (sizeof (DIR) + strlen (szFullPath) + strlen (SLASH) +
strlen (SUFFIX));
***************
*** 84,88 ****
/* Create the search expression. */
! strcpy (nd->dd_name, szPath);
/* Add on a slash if the path does not end with one. */
--- 88,92 ----
/* Create the search expression. */
! strcpy (nd->dd_name, szFullPath);
/* Add on a slash if the path does not end with one. */
|
|
From: <ea...@us...> - 2002-05-28 13:34:04
|
Update of /cvsroot/mingw/runtime/include In directory usw-pr-cvs1:/tmp/cvs-serv25604/include Modified Files: tchar.h Log Message: Merging Cygwin changes Index: tchar.h =================================================================== RCS file: /cvsroot/mingw/runtime/include/tchar.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** tchar.h 25 Jan 2002 20:05:26 -0000 1.5 --- tchar.h 28 May 2002 13:06:47 -0000 1.6 *************** *** 68,72 **** * notice. */ ! #define __TEXT(x) L##x /* for porting from other Windows compilers */ --- 68,72 ---- * notice. */ ! #define __TEXT(q) L##q /* for porting from other Windows compilers */ *************** *** 190,193 **** --- 190,198 ---- #define _tfopen _wfopen #define _tgetenv _wgetenv + #define _tputenv _wputenv + #define _tsearchenv _wsearchenv + #define _tmakepath _wmakepath + #define _tsplitpath _wsplitpath + #define _tfullpath _wfullpath #define _tmktemp _wmktemp #define _topen _wopen *************** *** 222,226 **** * notice. */ ! #define __TEXT(x) x /* for porting from other Windows compilers */ --- 227,231 ---- * notice. */ ! #define __TEXT(q) q /* for porting from other Windows compilers */ *************** *** 253,256 **** --- 258,266 ---- #define _tfopen fopen #define _tgetenv getenv + #define _tputenv _putenv + #define _tsearchenv _searchenv + #define _tmakepath _makepath + #define _tsplitpath _splitpath + #define _tfullpath _fullpath #define _gettc getc #define _getts gets |
|
From: <ea...@us...> - 2002-05-28 13:33:57
|
Update of /cvsroot/mingw/runtime/include
In directory usw-pr-cvs1:/tmp/cvs-serv26285/include
Added Files:
mbctype.h mbstring.h
Log Message:
Merging Cygwin changes
--- NEW FILE: mbctype.h ---
/*
* mbctype.h
*
* Functions for testing multibyte character types and converting characters.
*
* This file is part of the Mingw32 package.
*
*
* THIS SOFTWARE IS NOT COPYRIGHTED
*
* This source code is offered for use in the public domain. You may
* use, modify or distribute it freely.
*
* This code is distributed in the hope that it will be useful but
* WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
* DISCLAIMED. This includes but is not limited to warranties of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
*/
#ifndef _MBCTYPE_H_
#define _MBCTYPE_H_
/* All the headers include this file. */
#include <_mingw.h>
/* return values for _mbsbtype and _mbbtype in mbstring.h */
#define _MBC_SINGLE 0
#define _MBC_LEAD 1
#define _MBC_TRAIL 2
#define _MBC_ILLEGAL (-1)
/* args for setmbcp (in lieu of actual codepage) */
#define _MB_CP_SBCS 0
#define _MB_CP_OEM (-2)
#define _MB_CP_ANSI (-3)
#define _MB_CP_LOCALE (-4)
/* TODO: bit masks */
/*
#define _MS
#define _MP
#define _M1
#define _M2
#define _SBUP
#define _SBLOW
*/
#ifndef RC_INVOKED
#ifdef __cplusplus
extern "C" {
#endif
#ifndef __STRICT_ANSI__
int _setmbcp (int);
int _getmbcp (void);
/* byte classification */
/* NB: Corresponding _ismbc* functions are in mbstring.h */
int _ismbbalpha (unsigned int);
int _ismbbalnum (unsigned int);
int _ismbbgraph (unsigned int);
int _ismbbprint (unsigned int);
int _ismbbpunct (unsigned int);
int _ismbbkana (unsigned int);
int _ismbbkalnum (unsigned int);
int _ismbbkprint (unsigned int);
int _ismbbkpunct (unsigned int);
/* these are also in mbstring.h */
int _ismbblead (unsigned int);
int _ismbbtrail (unsigned int);
int _ismbslead (const unsigned char*, const unsigned char*);
int _ismbstrail (const unsigned char*, const unsigned char*);
#ifdef __DECLSPEC_SUPPORTED
__MINGW_IMPORT unsigned char _mbctype[];
__MINGW_IMPORT unsigned char _mbcasemap[];
#endif
/* TODO : _MBCS_ mappings go in tchar.h */
#endif /* Not strict ANSI */
#ifdef __cplusplus
}
#endif
#endif /* Not RC_INVOKED */
#endif /* Not _MCTYPE_H_ */
--- NEW FILE: mbstring.h ---
/*
* mbstring.h
*
* Protototypes for string functions supporting multibyte characters.
*
* This file is part of the Mingw32 package.
*
*
* THIS SOFTWARE IS NOT COPYRIGHTED
*
* This source code is offered for use in the public domain. You may
* use, modify or distribute it freely.
*
* This code is distributed in the hope that it will be useful but
* WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
* DISCLAIMED. This includes but is not limited to warranties of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
*/
#ifndef _MBSTRING_H_
#define _MBSTRING_H_
/* All the headers include this file. */
#include <_mingw.h>
#ifndef RC_INVOKED
#define __need_size_t
#include <stddef.h>
#ifdef __cplusplus
extern "C" {
#endif
#ifndef __STRICT_ANSI__
/* character classification */
int _ismbcalnum (unsigned int);
int _ismbcalpha (unsigned int);
int _ismbcdigit (unsigned int);
int _ismbcgraph (unsigned int);
int _ismbcprint (unsigned int);
int _ismbcpunct (unsigned int);
int _ismbcspace (unsigned int);
int _ismbclower (unsigned int);
int _ismbcupper (unsigned int);
int _ismbclegal (unsigned int);
int _ismbcsymbol (unsigned int);
/* also in mbctype.h */
int _ismbblead (unsigned int );
int _ismbbtrail (unsigned int );
int _ismbslead ( const unsigned char*, const unsigned char*);
int _ismbstrail ( const unsigned char*, const unsigned char*);
unsigned int _mbctolower (unsigned int);
unsigned int _mbctoupper (unsigned int);
void _mbccpy (unsigned char*, const unsigned char*);
size_t _mbclen (const unsigned char*);
unsigned int _mbbtombc (unsigned int);
unsigned int _mbctombb (unsigned int);
/* Return value constants for these are defined in mbctype.h. */
int _mbbtype (unsigned char, int);
int _mbsbtype (const unsigned char*, size_t);
unsigned char* _mbscpy (unsigned char*, const unsigned char*);
unsigned char* _mbsncpy (unsigned char*, const unsigned char*, size_t);
unsigned char* _mbsnbcpy (unsigned char*, const unsigned char*, size_t);
unsigned char* _mbsset (unsigned char*, unsigned int);
unsigned char* _mbsnset (unsigned char*, unsigned int, size_t);
unsigned char* _mbsnbset (unsigned char*, unsigned int, size_t);
unsigned char* _mbsdup (const unsigned char*);
unsigned char* _mbsrev (unsigned char*);
unsigned char* _mbscat (unsigned char*, const unsigned char*); /* also in string.h */
unsigned char* _mbsncat (unsigned char*, const unsigned char*, size_t);
unsigned char* _mbsnbcat (unsigned char*, const unsigned char*, size_t);
size_t _mbslen (const unsigned char*);
size_t _mbsnbcnt (const unsigned char*, size_t);
size_t _mbsnccnt (const unsigned char*, size_t);
unsigned char* _mbschr (const unsigned char*, unsigned int); /* also in string.h */
unsigned char* _mbsrchr (const unsigned char*, unsigned int);
size_t _mbsspn (const unsigned char*, const unsigned char*);
size_t _mbscspn (const unsigned char*, const unsigned char*);
unsigned char* _mbsspnp (const unsigned char*, const unsigned char*);
unsigned char* _mbspbrk (const unsigned char*, const unsigned char*);
int _mbscmp (const unsigned char*, const unsigned char*);
int _mbsicmp (const unsigned char*, const unsigned char*);
int _mbsncmp (const unsigned char*, const unsigned char*, size_t);
int _mbsnicmp (const unsigned char*, const unsigned char*, size_t);
int _mbsnbcmp (const unsigned char*, const unsigned char*, size_t);
int _mbsnbicmp (const unsigned char*, const unsigned char*, size_t);
int _mbscoll (const unsigned char*, const unsigned char*);
int _mbsicoll (const unsigned char*, const unsigned char*);
int _mbsncoll (const unsigned char*, const unsigned char*, size_t);
int _mbsnicoll (const unsigned char*, const unsigned char*, size_t);
int _mbsnbcoll (const unsigned char*, const unsigned char*, size_t);
int _mbsnbicoll (const unsigned char*, const unsigned char*, size_t);
unsigned char* _mbsinc (const unsigned char*);
unsigned char* _mbsninc (const unsigned char*, size_t);
unsigned char* _mbsdec (const unsigned char*, const unsigned char*);
unsigned int _mbsnextc (const unsigned char*);
unsigned char* _mbslwr (unsigned char*);
unsigned char* _mbsupr (unsigned char*);
unsigned char* _mbstok (unsigned char*, const unsigned char*); /* also in string.h */
/* Kanji */
int _ismbchira (unsigned int);
int _ismbckata (unsigned int);
int _ismbcl0 (unsigned int);
int _ismbcl1 (unsigned int);
int _ismbcl2 (unsigned int);
unsigned int _mbcjistojms (unsigned int);
unsigned int _mbcjmstojis (unsigned int);
unsigned int _mbctohira (unsigned int);
unsigned int _mbctokata (unsigned int);
#endif /* Not strict ANSI */
#ifdef __cplusplus
}
#endif
#endif /* Not RC_INVOKED */
#endif /* Not _MBSTRING_H_ */
|
|
From: <ea...@us...> - 2002-05-28 13:25:24
|
Update of /cvsroot/mingw/w32api In directory usw-pr-cvs1:/tmp/cvs-serv9231 Modified Files: ChangeLog Makefile.in Log Message: Merging Cygwin changes Index: ChangeLog =================================================================== RCS file: /cvsroot/mingw/w32api/ChangeLog,v retrieving revision 1.92 retrieving revision 1.93 diff -C2 -d -r1.92 -r1.93 *** ChangeLog 28 May 2002 13:19:42 -0000 1.92 --- ChangeLog 28 May 2002 13:25:21 -0000 1.93 *************** *** 1,2 **** --- 1,7 ---- + 2002-05-28 Earnie Boyd <ea...@us...> + + * include/w32api.h: Increment version to 1.5 + * Makefile.in: Ditto. + 2002-05-27 René Møller Fonseca <fo...@us...> Index: Makefile.in =================================================================== RCS file: /cvsroot/mingw/w32api/Makefile.in,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** Makefile.in 28 May 2002 13:19:42 -0000 1.8 --- Makefile.in 28 May 2002 13:25:21 -0000 1.9 *************** *** 67,72 **** PACKAGE = w32api ! VERSION = 1.4 ! CYGRELEASE = 2 DIST_FILES = Makefile.in configure.in configure config.guess config.sub \ --- 67,72 ---- PACKAGE = w32api ! VERSION = 1.5 ! CYGRELEASE = 1 DIST_FILES = Makefile.in configure.in configure config.guess config.sub \ |
|
From: <ea...@us...> - 2002-05-28 13:25:24
|
Update of /cvsroot/mingw/w32api/include In directory usw-pr-cvs1:/tmp/cvs-serv9231/include Modified Files: w32api.h Log Message: Merging Cygwin changes Index: w32api.h =================================================================== RCS file: /cvsroot/mingw/w32api/include/w32api.h,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** w32api.h 21 May 2002 16:04:43 -0000 1.6 --- w32api.h 28 May 2002 13:25:21 -0000 1.7 *************** *** 5,11 **** #endif ! #define __W32API_VERSION 1.4 #define __W32API_MAJOR_VERSION 1 ! #define __W32API_MINOR_VERSION 4 #endif /* ndef _W32API_H_ */ --- 5,11 ---- #endif ! #define __W32API_VERSION 1.5 #define __W32API_MAJOR_VERSION 1 ! #define __W32API_MINOR_VERSION 5 #endif /* ndef _W32API_H_ */ |
|
From: <ea...@us...> - 2002-05-28 13:19:45
|
Update of /cvsroot/mingw/w32api/lib In directory usw-pr-cvs1:/tmp/cvs-serv4493/lib Modified Files: Makefile.in Log Message: Merging Cygwin changes Index: Makefile.in =================================================================== RCS file: /cvsroot/mingw/w32api/lib/Makefile.in,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** Makefile.in 21 May 2002 16:07:06 -0000 1.11 --- Makefile.in 28 May 2002 13:19:42 -0000 1.12 *************** *** 88,91 **** --- 88,92 ---- HEADERS = $(notdir $(wildcard $(srcdir)/../include/*.h)) + GL_HEADERS = $(notdir $(wildcard $(srcdir)/../include/GL/*.h)) # libraries *************** *** 158,161 **** --- 159,166 ---- for i in $(HEADERS); do \ $(INSTALL_DATA) $(srcdir)/../include/$$i $(inst_includedir)/$$i ; \ + done + $(mkinstalldirs) $(inst_includedir)/GL + for i in $(GL_HEADERS); do \ + $(INSTALL_DATA) $(srcdir)/../include/GL/$$i $(inst_includedir)/GL/$$i ; \ done |
|
From: <ea...@us...> - 2002-05-28 13:19:45
|
Update of /cvsroot/mingw/w32api/include In directory usw-pr-cvs1:/tmp/cvs-serv4493/include Modified Files: winnls.h winreg.h Log Message: Merging Cygwin changes Index: winnls.h =================================================================== RCS file: /cvsroot/mingw/w32api/include/winnls.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** winnls.h 9 Apr 2002 21:17:17 -0000 1.2 --- winnls.h 28 May 2002 13:19:42 -0000 1.3 *************** *** 13,16 **** --- 13,19 ---- #define LOCALE_NOUSEROVERRIDE 0x80000000 #define LOCALE_USE_CP_ACP 0x40000000 + #if (WINVER >= 0x0400) + #define LOCALE_RETURN_NUMBER 0x20000000 + #endif #define LOCALE_ILANGUAGE 1 #define LOCALE_SLANGUAGE 2 Index: winreg.h =================================================================== RCS file: /cvsroot/mingw/w32api/include/winreg.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** winreg.h 9 Apr 2002 21:17:17 -0000 1.2 --- winreg.h 28 May 2002 13:19:42 -0000 1.3 *************** *** 23,29 **** #define REG_EXPAND_SZ 2 #define REG_BINARY 3 #define REG_DWORD 4 #define REG_DWORD_BIG_ENDIAN 5 - #define REG_DWORD_LITTLE_ENDIAN 4 #define REG_LINK 6 #define REG_MULTI_SZ 7 --- 23,29 ---- #define REG_EXPAND_SZ 2 #define REG_BINARY 3 + #define REG_DWORD_LITTLE_ENDIAN 4 #define REG_DWORD 4 #define REG_DWORD_BIG_ENDIAN 5 #define REG_LINK 6 #define REG_MULTI_SZ 7 *************** *** 31,34 **** --- 31,36 ---- #define REG_FULL_RESOURCE_DESCRIPTOR 9 #define REG_RESOURCE_REQUIREMENTS_LIST 10 + #define REG_QWORD_LITTLE_ENDIAN 11 + #define REG_QWORD 11 #define REG_NOTIFY_CHANGE_NAME 1 #define REG_NOTIFY_CHANGE_ATTRIBUTES 2 *************** *** 55,60 **** BOOL WINAPI InitiateSystemShutdownW(LPWSTR,LPWSTR,DWORD,BOOL,BOOL); LONG WINAPI RegCloseKey(HKEY); ! LONG WINAPI RegConnectRegistryA(LPSTR,HKEY,PHKEY); ! LONG WINAPI RegConnectRegistryW(LPWSTR,HKEY,PHKEY); LONG WINAPI RegCreateKeyA(HKEY,LPCSTR,PHKEY); LONG WINAPI RegCreateKeyExA(HKEY,LPCSTR,DWORD,LPSTR,DWORD,REGSAM,LPSECURITY_ATTRIBUTES,PHKEY,PDWORD); --- 57,62 ---- BOOL WINAPI InitiateSystemShutdownW(LPWSTR,LPWSTR,DWORD,BOOL,BOOL); LONG WINAPI RegCloseKey(HKEY); ! LONG WINAPI RegConnectRegistryA(LPCSTR,HKEY,PHKEY); ! LONG WINAPI RegConnectRegistryW(LPCWSTR,HKEY,PHKEY); LONG WINAPI RegCreateKeyA(HKEY,LPCSTR,PHKEY); LONG WINAPI RegCreateKeyExA(HKEY,LPCSTR,DWORD,LPSTR,DWORD,REGSAM,LPSECURITY_ATTRIBUTES,PHKEY,PDWORD); *************** *** 63,69 **** LONG WINAPI RegDeleteKeyA(HKEY,LPCSTR); LONG WINAPI RegDeleteKeyW(HKEY,LPCWSTR); ! LONG WINAPI RegDeleteValueA (HKEY,LPCSTR); LONG WINAPI RegDeleteValueW(HKEY,LPCWSTR); ! LONG WINAPI RegEnumKeyA (HKEY,DWORD,LPSTR,DWORD); LONG WINAPI RegEnumKeyW(HKEY,DWORD,LPWSTR,DWORD); LONG WINAPI RegEnumKeyExA(HKEY,DWORD,LPSTR,PDWORD,PDWORD,LPSTR,PDWORD,PFILETIME); --- 65,71 ---- LONG WINAPI RegDeleteKeyA(HKEY,LPCSTR); LONG WINAPI RegDeleteKeyW(HKEY,LPCWSTR); ! LONG WINAPI RegDeleteValueA(HKEY,LPCSTR); LONG WINAPI RegDeleteValueW(HKEY,LPCWSTR); ! LONG WINAPI RegEnumKeyA(HKEY,DWORD,LPSTR,DWORD); LONG WINAPI RegEnumKeyW(HKEY,DWORD,LPWSTR,DWORD); LONG WINAPI RegEnumKeyExA(HKEY,DWORD,LPSTR,PDWORD,PDWORD,LPSTR,PDWORD,PFILETIME); *************** *** 85,94 **** LONG WINAPI RegQueryMultipleValuesW(HKEY,PVALENTW,DWORD,LPWSTR,PDWORD); LONG WINAPI RegQueryValueA(HKEY,LPCSTR,LPSTR,PLONG); ! LONG WINAPI RegQueryValueExA (HKEY,LPCSTR,PDWORD,PDWORD,LPBYTE,PDWORD); LONG WINAPI RegQueryValueExW(HKEY,LPCWSTR,PDWORD,PDWORD,LPBYTE,PDWORD); LONG WINAPI RegQueryValueW(HKEY,LPCWSTR,LPWSTR,PLONG); LONG WINAPI RegReplaceKeyA(HKEY,LPCSTR,LPCSTR,LPCSTR); LONG WINAPI RegReplaceKeyW(HKEY,LPCWSTR,LPCWSTR,LPCWSTR); ! LONG WINAPI RegRestoreKeyA (HKEY,LPCSTR,DWORD); LONG WINAPI RegRestoreKeyW(HKEY,LPCWSTR,DWORD); LONG WINAPI RegSaveKeyA(HKEY,LPCSTR,LPSECURITY_ATTRIBUTES); --- 87,96 ---- LONG WINAPI RegQueryMultipleValuesW(HKEY,PVALENTW,DWORD,LPWSTR,PDWORD); LONG WINAPI RegQueryValueA(HKEY,LPCSTR,LPSTR,PLONG); ! LONG WINAPI RegQueryValueExA(HKEY,LPCSTR,PDWORD,PDWORD,LPBYTE,PDWORD); LONG WINAPI RegQueryValueExW(HKEY,LPCWSTR,PDWORD,PDWORD,LPBYTE,PDWORD); LONG WINAPI RegQueryValueW(HKEY,LPCWSTR,LPWSTR,PLONG); LONG WINAPI RegReplaceKeyA(HKEY,LPCSTR,LPCSTR,LPCSTR); LONG WINAPI RegReplaceKeyW(HKEY,LPCWSTR,LPCWSTR,LPCWSTR); ! LONG WINAPI RegRestoreKeyA(HKEY,LPCSTR,DWORD); LONG WINAPI RegRestoreKeyW(HKEY,LPCWSTR,DWORD); LONG WINAPI RegSaveKeyA(HKEY,LPCSTR,LPSECURITY_ATTRIBUTES); |
|
From: <ea...@us...> - 2002-05-28 13:19:45
|
Update of /cvsroot/mingw/w32api In directory usw-pr-cvs1:/tmp/cvs-serv4493 Modified Files: ChangeLog Makefile.in Log Message: Merging Cygwin changes Index: ChangeLog =================================================================== RCS file: /cvsroot/mingw/w32api/ChangeLog,v retrieving revision 1.91 retrieving revision 1.92 diff -C2 -d -r1.91 -r1.92 *** ChangeLog 21 May 2002 16:07:06 -0000 1.91 --- ChangeLog 28 May 2002 13:19:42 -0000 1.92 *************** *** 1,2 **** --- 1,19 ---- + 2002-05-27 René Møller Fonseca <fo...@us...> + + * include/winreg.h: (RegConnectRegistry[AW]): Replace + LP[W]STR with LPC[W]STR. + (REG_QWORD, REG_QWORD_LITTLE_ENDIAN): Add defines. + Clean up whitespace. + + 2002-05-27 Rick Rankin <ric...@ya...> + + * include/winnls.h: Add #define for LOCALE_RETURN_NUMBER. + + 2002-05-21 Earnie Boyd <ea...@us...> + + * Makefile.in: Increment VERSION to 1.4. + (conf_prefix): New variable. + (bindist): Modify target to use $(conf_prefix). + 2002-05-20 Philip Aston <ph...@ma...> Index: Makefile.in =================================================================== RCS file: /cvsroot/mingw/w32api/Makefile.in,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** Makefile.in 9 Apr 2002 22:07:26 -0000 1.7 --- Makefile.in 28 May 2002 13:19:42 -0000 1.8 *************** *** 19,22 **** --- 19,23 ---- target_alias = @target_alias@ prefix = @prefix@ + conf_prefix = @prefix@ program_transform_name = @program_transform_name@ *************** *** 66,71 **** PACKAGE = w32api ! VERSION = 1.3 ! CYGRELEASE = 1 DIST_FILES = Makefile.in configure.in configure config.guess config.sub \ --- 67,72 ---- PACKAGE = w32api ! VERSION = 1.4 ! CYGRELEASE = 2 DIST_FILES = Makefile.in configure.in configure config.guess config.sub \ *************** *** 124,128 **** mkdir $(distdir) chmod 755 $(distdir) ! $(MAKE) install prefix=../$(distdir) exec_prefix=../$(distdir) rm -f $(distdir)$(TARFILEEXT) cd $(distdir); $(TAR) $(TARFLAGS)cf ../$(distdir)$(TARFILEEXT) * --- 125,129 ---- mkdir $(distdir) chmod 755 $(distdir) ! $(MAKE) install prefix=../$(distdir)/$(conf_prefix) exec_prefix=../$(distdir)/$(conf_prefix) rm -f $(distdir)$(TARFILEEXT) cd $(distdir); $(TAR) $(TARFLAGS)cf ../$(distdir)$(TARFILEEXT) * |
|
From: Earnie B. <ear...@ya...> - 2002-05-26 18:33:08
|
If this ends up being a repost, sorry. Why are all of the diffs for your changes full file diffs. Please, be mindful of not changing line endings. Revert these changes and apply only the chnages you intended. Thanks, Earnie. --- in...@us... wrote: > This list will notify you of updates to the code stored in CVS. Typically > only developers with access to update the CVS are interested in this list. > However, this list can be beneficial to see what is happening with your > changes. If you wish to unsubscribe please do so at > https://lists.sourceforge.net/lists/listinfo/mingw-cvs.Update of > /cvsroot/mingw/utils/res2coff > In directory usw-pr-cvs1:/tmp/cvs-serv2405/res2coff > > Modified Files: > objimage.c protos.h readme.1st res2coff.c res2coff.h > resimage.c > Log Message: > Convert some text files to Unix format > ===== Earnie Boyd mailto:ear...@ya... --- <http://earniesystems.safeshopper.com> --- --- Cygwin: POSIX on Windows <http://gw32.freeyellow.com/> --- --- Minimalist GNU for Windows <http://www.mingw.org/> --- __________________________________________________ Do You Yahoo!? Yahoo! - Official partner of 2002 FIFA World Cup http://fifaworldcup.yahoo.com |
|
From: Earnie B. <ear...@ya...> - 2002-05-26 18:32:36
|
If this ends up being a repost, sorry. Why are all of the diffs for your changes full file diffs. Please, be mindful of not changing line endings. Revert these changes and apply only the chnages you intended. Thanks, Earnie. --- in...@us... wrote: > This list will notify you of updates to the code stored in CVS. Typically > only developers with access to update the CVS are interested in this list. > However, this list can be beneficial to see what is happening with your > changes. If you wish to unsubscribe please do so at > https://lists.sourceforge.net/lists/listinfo/mingw-cvs.Update of > /cvsroot/mingw/utils/res2coff > In directory usw-pr-cvs1:/tmp/cvs-serv2405/res2coff > > Modified Files: > objimage.c protos.h readme.1st res2coff.c res2coff.h > resimage.c > Log Message: > Convert some text files to Unix format > > Index: objimage.c > =================================================================== > RCS file: /cvsroot/mingw/utils/res2coff/objimage.c,v > retrieving revision 1.1 > retrieving revision 1.2 > diff -C2 -d -r1.1 -r1.2 > *** objimage.c 14 May 2002 20:38:30 -0000 1.1 > --- objimage.c 26 May 2002 10:13:58 -0000 1.2 > *************** > *** 1,385 **** > ! /* ********************************************* > ! * > ! * res2coff : Functions dealing with the creation > ! * of a .o file image in memory before > ! * writing it out > ! * > ! */ > ! > ! #include "res2coff.h" > ! #include <stdlib.h> > ! > ! > ! /* > ! * return the offset of the string we just added > ! * into the string table or -1 if error > ! * strings are DWORD aligned > ! */ > ! > ! int Add2StringTable(wchar_t *NewString) > ! { > ! int result = Strings.Size; > ! int strlen = lstrlenW(NewString); > ! int i,addsize; > ! wchar_t *p1,*p2; > ! > ! addsize = (strlen+2) * sizeof(wchar_t); > ! if (addsize % sizeof(DWORD)) > ! addsize += sizeof(wchar_t); > ! > ! Strings.Image = realloc(Strings.Image,result+addsize); > ! if (Strings.Image == NULL) > ! AppExit(1,"Out of memory for the string table\n",NULL); > ! > ! p1 = NewString; > ! p2 = (wchar_t *)((BYTE *)Strings.Image+result); > ! *p2++ = (wchar_t)strlen; > ! > ! for (i=0;i < strlen;i++) > ! *p2++ = *p1++; > ! *p2 = L'\0'; > ! Strings.Size +=addsize; > ! return result; > ! } > ! > ! // Append a MemImage to another MemImage > ! int AppendMemImage(MemImage *membase,MemImage *memappend) > ! { > ! char *p1,*p2; > ! int i; > ! > ! membase->Image = realloc(membase->Image,membase->Size+memappend->Size); > ! > ! if (membase->Image == NULL) > ! AppExit(1,"Error reallocating MemImage!\n",NULL); > ! > ! p1 = (char *)memappend->Image; > ! p2 = (char *)(membase->Image)+membase->Size; > ! > ! for(i=0;i<memappend->Size;i++) > ! *p2++ = *p1++; > ! > ! membase->Size += memappend->Size; > ! return TRUE; > ! } > ! > ! // Add an entry to the relocation table > ! int AddRelocation(int RVA) > ! { > ! int last,newsize,*pReloc; > ! > ! last = RelocTable.nElems++; > ! newsize = RelocTable.nElems * sizeof(int); > ! pReloc = RelocTable.pElems = realloc(RelocTable.pElems,newsize); > ! if (pReloc == NULL) > ! AppExit(1,"Out of memory for relocations\n",NULL); > ! pReloc[last] = RVA ; > ! return TRUE; > ! } > ! > ! // Create the directory tree and other related chunks > ! > ! int MakeDirectoryTree(void) > ! { > ! PIMAGE_RESOURCE_DIRECTORY RD; > ! PIMAGE_RESOURCE_DIRECTORY_ENTRY RDE; > ! PIMAGE_RESOURCE_DATA_ENTRY RPR; > ! > ! int i,j,ThisOffset,ResSize; > ! > ! int types = 0; > ! int ResPointOffs = 0; > ! int ResourceOffs = 0; > ! int PhantomID = 100; > ! > ! // we start by calculating the amount of memory we are > ! // going to need in the directory image and the resource pointers > ! > ! ResourceHeads.Size = 0; > ! Directory.Size = sizeof(IMAGE_RESOURCE_DIRECTORY); // in the root > ! for (i=1;i<17;i++) > ! if (ResInfo[i].count) { > ! types++; > ! Directory.Size += sizeof(IMAGE_RESOURCE_DIRECTORY_ENTRY); // in the > root > ! // resource types > ! Directory.Size += sizeof(IMAGE_RESOURCE_DIRECTORY); > ! Directory.Size += ResInfo[i].count * > ! sizeof(IMAGE_RESOURCE_DIRECTORY_ENTRY); > ! // individual resources > ! Directory.Size += ResInfo[i].count * > ! sizeof(IMAGE_RESOURCE_DIRECTORY); > ! Directory.Size += ResInfo[i].count * > ! sizeof(IMAGE_RESOURCE_DIRECTORY_ENTRY); > ! // > ! // reserve also for the Resource Pointer Records > ! // > ! ResourceHeads.Size += ResInfo[i].count * > ! sizeof(IMAGE_RESOURCE_DATA_ENTRY); > ! } > ! > ! if (types == 0) > ! AppExit(1,"ERROR: no resources in RES file ?!?!\n",NULL); > ! > ! Directory.Image = malloc(Directory.Size); > ! if (Directory.Image == NULL) > ! AppExit(1,"Out of memory for the directory\n",NULL); > ! > ! ResourceHeads.Image = malloc(ResourceHeads.Size); > ! if (ResourceHeads.Image == NULL) > ! AppExit(1,"Out of memory for the resource headers\n",NULL); > ! > ! RPR = (PIMAGE_RESOURCE_DATA_ENTRY)ResourceHeads.Image; > ! > ! // Root Directory > ! > ! RD = (PIMAGE_RESOURCE_DIRECTORY)Directory.Image; > ! RD -> Characteristics = 0; > ! RD -> TimeStamp = ResourceTime; > ! RD -> MajorVersion = DECLARED_MAV; > ! RD -> MinorVersion = DECLARED_MIV; > ! RD -> NumberOfNamedEntries = 0; > ! RD -> NumberOfIdEntries = types; > ! > ! RD++; > ! RDE = (PIMAGE_RESOURCE_DIRECTORY_ENTRY) RD; > ! ThisOffset = sizeof(IMAGE_RESOURCE_DIRECTORY) + > ! types * sizeof(IMAGE_RESOURCE_DIRECTORY_ENTRY); > ! > ! // Root directory entries are pointers to directories > ! // of types > ! > ! for (i=1;i<17;i++) > ! if (ResInfo[i].count) { > ! RDE->Name = i; > ! RDE->OffsetToData = ThisOffset | IMAGE_RESOURCE_DATA_IS_DIRECTORY ; > ! RDE++; > ! ThisOffset += sizeof(IMAGE_RESOURCE_DIRECTORY_ENTRY) * > ResInfo[i].count + > ! sizeof(IMAGE_RESOURCE_DIRECTORY); > ! } > ! > ! // Now the directories of types > ! // ThisOffset is pointing at the storage area for the last directory level > ! // each Directory there will point to one and only one resource > ! > ! RD = (PIMAGE_RESOURCE_DIRECTORY)Directory.Image; > ! RD++; > ! RDE = (PIMAGE_RESOURCE_DIRECTORY_ENTRY)RD; > ! for (i=0;i<types;i++) { > ! int RDNum = RDE->Name & 0x7fffffff; > ! int RDOfs = RDE->OffsetToData & > 0x7fffffff; > ! PIMAGE_RESOURCE_DIRECTORY_ENTRY RDENext; > ! > ! RD = (PIMAGE_RESOURCE_DIRECTORY)((BYTE *)Directory.Image + RDOfs); > ! > ! RD -> Characteristics = 0; > ! RD -> TimeStamp = ResourceTime; > ! RD -> MajorVersion = DECLARED_MAV; > ! RD -> MinorVersion = DECLARED_MIV; > ! RD -> NumberOfNamedEntries = ResInfo[RDNum].named; > ! RD -> NumberOfIdEntries = ResInfo[RDNum].unnamed; > ! RD++; > ! > ! RDENext = (PIMAGE_RESOURCE_DIRECTORY_ENTRY)RD; > ! for (j=0;j<ResInfo[RDNum].count;j++) { > ! PIMAGE_RESOURCE_DIRECTORY RDLast; > ! PIMAGE_RESOURCE_DIRECTORY_ENTRY RDELast; > ! PRESOURCEHEAD *pThisResource; > ! > ! if (j==0) > ! pThisResource = ResInfo[RDNum].RName; > ! if (j == ResInfo[RDNum].named) > ! pThisResource = ResInfo[RDNum].RID; > ! > ! if (j < ResInfo[RDNum].named) { > ! wchar_t *NameInRES; > ! int NameOfs; > ! > ! NameInRES = ResName(*pThisResource); > ! NameOfs = Add2StringTable(NameInRES); > ! NameOfs += Directory.Size+ResourceHeads.Size; > ! RDENext->Name = NameOfs | IMAGE_RESOURCE_NAME_IS_STRING; > ! } else { > ! wchar_t *NameID = ResName(*pThisResource); > ! if (*NameID == 0xffff) { > ! PhantomID = (int)*(++NameID); > ! RDENext->Name = PhantomID++; > ! } else { > ! AppExit(1,"Unnamed resource has no ID field",NULL); > ! } > ! } > ! > ! RDENext->OffsetToData = ThisOffset | > IMAGE_RESOURCE_DATA_IS_DIRECTORY; > ! > ! RDLast = (PIMAGE_RESOURCE_DIRECTORY) > ! ((BYTE *)Directory.Image+ThisOffset); > ! > ! ThisOffset += sizeof(IMAGE_RESOURCE_DIRECTORY); > ! > ! RDLast -> Characteristics = 0; > ! RDLast -> TimeStamp = ResourceTime; > ! RDLast -> MajorVersion = DECLARED_MAV; > ! RDLast -> MinorVersion = DECLARED_MIV; > ! RDLast -> NumberOfNamedEntries = 0; > ! RDLast -> NumberOfIdEntries = 1; > ! > ! RDELast = (PIMAGE_RESOURCE_DIRECTORY_ENTRY) > ! ((BYTE *)Directory.Image+ThisOffset); > ! > ! ThisOffset += sizeof(IMAGE_RESOURCE_DIRECTORY_ENTRY); > ! RDELast->Name = PhantomID++; > ! RDELast->OffsetToData = Directory.Size+ResPointOffs; > ! ResSize = (*pThisResource)->DataSize; > ! > ! RPR -> OffsetToData = ResourceOffs; > ! RPR -> Size = ResSize; > ! RPR -> CodePage = LanguageID(*pThisResource); > ! RPR -> Reserved = 0; > ! > ! RPR++; > ! RDENext++; > ! ResPointOffs += sizeof(IMAGE_RESOURCE_DATA_ENTRY); > ! ResourceOffs += ResSize; > ! pThisResource++; > ! } > ! RDE++; > ! } > ! > ! ResourceSize = ResourceOffs; > ! > ! RPR = (PIMAGE_RESOURCE_DATA_ENTRY)ResourceHeads.Image; > ! for (i=0;i<17;i++) { > ! for( j=0;j<ResInfo[i].count;j++) { > ! LPVOID RelocPos; > ! > ! /* > ! * The data is situated after the directory, the resourceheads > ! * and the strings > ! */ > ! RPR->OffsetToData += Directory.Size+ResourceHeads.Size+Strings.Size; > ! /* > ! * the resource heads, where the relocations have to take place, > ! * are just after the directory > ! */ > ! RelocPos = (LPVOID)(&RPR->OffsetToData); > ! AddRelocation((int)((BYTE *)Directory.Size - > ! (BYTE *)ResourceHeads.Image + > ! (BYTE *)RelocPos)); > ! > ! RPR++; > ! } > ! } > ! > ! // Finally we put all 'subsections' or chunks together > ! > ! if (AppendMemImage(&Directory,&ResourceHeads) == FALSE) > ! return FALSE; > ! > ! if (AppendMemImage(&Directory,&Strings) == FALSE) > ! return FALSE; > ! > ! return TRUE; > ! } > ! > ! void DumpResource(HANDLE ofile,PRESOURCEHEAD this) > ! { > ! BYTE *buffer = (BYTE *)this; > ! > ! buffer += this->HeaderSize; > ! CheckedWrite(ofile,buffer,this->DataSize,"resources"); > ! } > ! > ! void DumpResources(HANDLE ofile) > ! { > ! int i,j; > ! > ! for (i=1;i<17;i++) { > ! for (j=0;j < ResInfo[i].named;j++) > ! DumpResource(ofile,ResInfo[i].RName[j]); > ! > ! for (j=0;j < ResInfo[i].unnamed;j++) > ! DumpResource(ofile,ResInfo[i].RID[j]); > ! } > ! } > ! > ! void DumpDirectoryImage(HANDLE ofile) > ! { > ! CheckedWrite(ofile,Directory.Image,Directory.Size,"resource directory"); > ! } > ! > ! /* Dump all relocations */ > ! > ! void DumpRelocations(HANDLE ofile) > ! { > ! > ! /* > ! * The relocation type is 32 bits absolute without > ! * base reference. The smbols referenced is the > ! * section start, which is the first element of > ! * the symbols table. > ! */ > ! > ! IMAGE_RELOCATION RelocBuffer = { 0,0,IMAGE_REL_I386_DIR32NB}; > ! int i,*relocs; > ! > ! relocs = (int *)RelocTable.pElems; > ! for (i=0;i<RelocTable.nElems;i++) { > ! RelocBuffer.VirtualAddress = relocs[i]; > ! CheckedWrite(ofile,(LPVOID)(&RelocBuffer),10,"relocations"); > ! } > ! } > ! > ! void DumpSymbols(HANDLE ofile) > ! { > ! IMAGE_SYMBOL NewSym; > ! IMAGE_AUX_SYMBOL SecSym; > ! > ! memset(&NewSym,0,IMAGE_SIZEOF_SYMBOL); > ! memset(&SecSym,0,IMAGE_SIZEOF_SYMBOL); > ! > ! lstrcpyA(NewSym.N.ShortName,".rsrc"); > ! NewSym.Value = 0; > ! NewSym.SectionNumber = 1; > ! NewSym.Type = 0; > ! NewSym.StorageClass = 3; > ! NewSym.NumberOfAuxSymbols = 1; > ! > ! SecSym.Section.Length = ResourceSize+Directory.Size; > ! SecSym.Section.NumberOfRelocations = RelocTable.nElems; > ! > ! CheckedWrite(ofile,&NewSym,IMAGE_SIZEOF_SYMBOL,"symbols"); > ! CheckedWrite(ofile,&SecSym,IMAGE_SIZEOF_SYMBOL,"symbols"); > ! } > ! > ! void MakeCOFFSections(HANDLE ofile) > ! { > ! IMAGE_FILE_HEADER fileheader; > ! IMAGE_SECTION_HEADER RSRChdr; > ! > ! lstrcpyA(RSRChdr.Name,".rsrc"); > ! RSRChdr.Misc.PhysicalAddress = 0; > ! RSRChdr.VirtualAddress = 0; > ! RSRChdr.SizeOfRawData = ResourceSize+Directory.Size; > ! RSRChdr.PointerToRawData = IMAGE_SIZEOF_FILE_HEADER + > ! IMAGE_SIZEOF_SECTION_HEADER; > ! RSRChdr.PointerToRelocations = RSRChdr.SizeOfRawData + > ! RSRChdr.PointerToRawData; > ! RSRChdr.PointerToLinenumbers = 0; > ! RSRChdr.NumberOfRelocations = RelocTable.nElems; > ! RSRChdr.NumberOfLinenumbers = 0; > ! RSRChdr.Characteristics = IMAGE_SCN_MEM_READ > ! /* | IMAGE_SCN_MEM_WRITE */; > ! > ! fileheader.Machine = IMAGE_FILE_MACHINE_I386; > ! fileheader.NumberOfSections = 1; > ! fileheader.TimeDateStamp = ResourceTime; > ! fileheader.PointerToSymbolTable = RSRChdr.PointerToRelocations+ > ! RelocTable.nElems * 10; > ! fileheader.NumberOfSymbols = 2; > ! fileheader.SizeOfOptionalHeader = 0; > ! fileheader.Characteristics = IMAGE_FILE_LINE_NUMS_STRIPPED | > ! IMAGE_FILE_32BIT_MACHINE; > ! > ! CheckedWrite(ofile,&fileheader,IMAGE_SIZEOF_FILE_HEADER,"COFF file > header"); > ! CheckedWrite(ofile,&RSRChdr,IMAGE_SIZEOF_SECTION_HEADER,".rsrc section > header"); > ! } > ! > --- 1,385 ---- > ! /* ********************************************* > ! * > ! * res2coff : Functions dealing with the creation > ! * of a .o file image in memory before > ! * writing it out > ! * > ! */ > ! > ! #include "res2coff.h" > ! #include <stdlib.h> > ! > ! > ! /* > ! * return the offset of the string we just added > ! * into the string table or -1 if error > ! * strings are DWORD aligned > ! */ > ! > ! int Add2StringTable(wchar_t *NewString) > ! { > ! int result = Strings.Size; > ! int strlen = lstrlenW(NewString); > ! int i,addsize; > ! wchar_t *p1,*p2; > ! > ! addsize = (strlen+2) * sizeof(wchar_t); > ! if (addsize % sizeof(DWORD)) > ! addsize += sizeof(wchar_t); > ! > ! Strings.Image = realloc(Strings.Image,result+addsize); > ! if (Strings.Image == NULL) > ! AppExit(1,"Out of memory for the string table\n",NULL); > ! > ! p1 = NewString; > ! p2 = (wchar_t *)((BYTE *)Strings.Image+result); > ! *p2++ = (wchar_t)strlen; > ! > ! for (i=0;i < strlen;i++) > ! *p2++ = *p1++; > ! *p2 = L'\0'; > ! Strings.Size +=addsize; > ! return result; > ! } > ! > ! // Append a MemImage to another MemImage > ! int AppendMemImage(MemImage *membase,MemImage *memappend) > ! { > ! char *p1,*p2; > ! int i; > ! > ! membase->Image = realloc(membase->Image,membase->Size+memappend->Size); > ! > ! if (membase->Image == NULL) > ! AppExit(1,"Error reallocating MemImage!\n",NULL); > ! > ! p1 = (char *)memappend->Image; > ! p2 = (char *)(membase->Image)+membase->Size; > ! > ! for(i=0;i<memappend->Size;i++) > ! *p2++ = *p1++; > ! > ! membase->Size += memappend->Size; > ! return TRUE; > ! } > ! > ! // Add an entry to the relocation table > ! int AddRelocation(int RVA) > ! { > ! int last,newsize,*pReloc; > ! > ! last = RelocTable.nElems++; > ! newsize = RelocTable.nElems * sizeof(int); > ! pReloc = RelocTable.pElems = realloc(RelocTable.pElems,newsize); > ! if (pReloc == NULL) > ! AppExit(1,"Out of memory for relocations\n",NULL); > ! pReloc[last] = RVA ; > ! return TRUE; > ! } > ! > ! // Create the directory tree and other related chunks > ! > ! int MakeDirectoryTree(void) > ! { > ! PIMAGE_RESOURCE_DIRECTORY RD; > ! PIMAGE_RESOURCE_DIRECTORY_ENTRY RDE; > ! PIMAGE_RESOURCE_DATA_ENTRY RPR; > ! > ! int i,j,ThisOffset,ResSize; > ! > ! int types = 0; > ! int ResPointOffs = 0; > ! int ResourceOffs = 0; > ! int PhantomID = 100; > ! > ! // we start by calculating the amount of memory we are > ! // going to need in the directory image and the resource pointers > ! > ! ResourceHeads.Size = 0; > ! Directory.Size = sizeof(IMAGE_RESOURCE_DIRECTORY); // in the root > ! for (i=1;i<17;i++) > ! if (ResInfo[i].count) { > ! types++; > ! Directory.Size += sizeof(IMAGE_RESOURCE_DIRECTORY_ENTRY); // in the > root > ! // resource types > ! Directory.Size += sizeof(IMAGE_RESOURCE_DIRECTORY); > ! Directory.Size += ResInfo[i].count * > ! sizeof(IMAGE_RESOURCE_DIRECTORY_ENTRY); > ! // individual resources > ! Directory.Size += ResInfo[i].count * > ! sizeof(IMAGE_RESOURCE_DIRECTORY); > ! Directory.Size += ResInfo[i].count * > ! sizeof(IMAGE_RESOURCE_DIRECTORY_ENTRY); > ! // > ! // reserve also for the Resource Pointer Records > ! // > ! ResourceHeads.Size += ResInfo[i].count * > ! sizeof(IMAGE_RESOURCE_DATA_ENTRY); > ! } > ! > ! if (types == 0) > ! AppExit(1,"ERROR: no resources in RES file ?!?!\n",NULL); > ! > ! Directory.Image = malloc(Directory.Size); > ! if (Directory.Image == NULL) > ! AppExit(1,"Out of memory for the directory\n",NULL); > ! > ! ResourceHeads.Image = malloc(ResourceHeads.Size); > ! if (ResourceHeads.Image == NULL) > ! AppExit(1,"Out of memory for the resource headers\n",NULL); > ! > ! RPR = (PIMAGE_RESOURCE_DATA_ENTRY)ResourceHeads.Image; > ! > ! // Root Directory > ! > ! RD = (PIMAGE_RESOURCE_DIRECTORY)Directory.Image; > ! RD -> Characteristics = 0; > ! RD -> TimeStamp = ResourceTime; > ! RD -> MajorVersion = DECLARED_MAV; > ! RD -> MinorVersion = DECLARED_MIV; > ! RD -> NumberOfNamedEntries = 0; > ! RD -> NumberOfIdEntries = types; > ! > ! RD++; > ! RDE = (PIMAGE_RESOURCE_DIRECTORY_ENTRY) RD; > ! ThisOffset = sizeof(IMAGE_RESOURCE_DIRECTORY) + > ! types * sizeof(IMAGE_RESOURCE_DIRECTORY_ENTRY); > ! > ! // Root directory entries are pointers to directories > ! // of types > ! > ! for (i=1;i<17;i++) > ! if (ResInfo[i].count) { > ! RDE->Name = i; > ! RDE->OffsetToData = ThisOffset | IMAGE_RESOURCE_DATA_IS_DIRECTORY ; > ! RDE++; > ! ThisOffset += sizeof(IMAGE_RESOURCE_DIRECTORY_ENTRY) * > ResInfo[i].count + > ! sizeof(IMAGE_RESOURCE_DIRECTORY); > ! } > ! > ! // Now the directories of types > ! // ThisOffset is pointing at the storage area for the last directory level > ! // each Directory there will point to one and only one resource > ! > ! RD = (PIMAGE_RESOURCE_DIRECTORY)Directory.Image; > ! RD++; > ! RDE = (PIMAGE_RESOURCE_DIRECTORY_ENTRY)RD; > ! for (i=0;i<types;i++) { > ! int RDNum = RDE->Name & 0x7fffffff; > ! int RDOfs = RDE->OffsetToData & > 0x7fffffff; > ! PIMAGE_RESOURCE_DIRECTORY_ENTRY RDENext; > ! > ! RD = (PIMAGE_RESOURCE_DIRECTORY)((BYTE *)Directory.Image + RDOfs); > ! > ! RD -> Characteristics = 0; > ! RD -> TimeStamp = ResourceTime; > ! RD -> MajorVersion = DECLARED_MAV; > ! RD -> MinorVersion = DECLARED_MIV; > ! RD -> NumberOfNamedEntries = ResInfo[RDNum].named; > ! RD -> NumberOfIdEntries = ResInfo[RDNum].unnamed; > ! RD++; > ! > ! RDENext = (PIMAGE_RESOURCE_DIRECTORY_ENTRY)RD; > ! for (j=0;j<ResInfo[RDNum].count;j++) { > ! PIMAGE_RESOURCE_DIRECTORY RDLast; > ! PIMAGE_RESOURCE_DIRECTORY_ENTRY RDELast; > ! PRESOURCEHEAD *pThisResource; > ! > ! if (j==0) > ! pThisResource = ResInfo[RDNum].RName; > ! if (j == ResInfo[RDNum].named) > ! pThisResource = ResInfo[RDNum].RID; > ! > ! if (j < ResInfo[RDNum].named) { > ! wchar_t *NameInRES; > ! int NameOfs; > ! > ! NameInRES = ResName(*pThisResource); > ! NameOfs = Add2StringTable(NameInRES); > ! NameOfs += Directory.Size+ResourceHeads.Size; > ! RDENext->Name = NameOfs | IMAGE_RESOURCE_NAME_IS_STRING; > ! } else { > ! wchar_t *NameID = ResName(*pThisResource); > ! if (*NameID == 0xffff) { > ! PhantomID = (int)*(++NameID); > ! RDENext->Name = PhantomID++; > ! } else { > ! AppExit(1,"Unnamed resource has no ID field",NULL); > ! } > ! } > ! > ! RDENext->OffsetToData = ThisOffset | > IMAGE_RESOURCE_DATA_IS_DIRECTORY; > ! > ! RDLast = (PIMAGE_RESOURCE_DIRECTORY) > ! ((BYTE *)Directory.Image+ThisOffset); > ! > ! ThisOffset += sizeof(IMAGE_RESOURCE_DIRECTORY); > ! > ! RDLast -> Characteristics = 0; > ! RDLast -> TimeStamp = ResourceTime; > ! RDLast -> MajorVersion = DECLARED_MAV; > ! RDLast -> MinorVersion = DECLARED_MIV; > ! RDLast -> NumberOfNamedEntries = 0; > ! RDLast -> NumberOfIdEntries = 1; > ! > ! RDELast = (PIMAGE_RESOURCE_DIRECTORY_ENTRY) > ! ((BYTE *)Directory.Image+ThisOffset); > ! > ! ThisOffset += sizeof(IMAGE_RESOURCE_DIRECTORY_ENTRY); > ! RDELast->Name = PhantomID++; > ! RDELast->OffsetToData = Directory.Size+ResPointOffs; > ! ResSize = (*pThisResource)->DataSize; > ! > ! RPR -> OffsetToData = ResourceOffs; > ! RPR -> Size = ResSize; > ! RPR -> CodePage = LanguageID(*pThisResource); > ! RPR -> Reserved = 0; > ! > ! RPR++; > ! RDENext++; > ! ResPointOffs += sizeof(IMAGE_RESOURCE_DATA_ENTRY); > ! ResourceOffs += ResSize; > ! pThisResource++; > ! } > ! RDE++; > ! } > ! > ! ResourceSize = ResourceOffs; > ! > ! RPR = (PIMAGE_RESOURCE_DATA_ENTRY)ResourceHeads.Image; > ! for (i=0;i<17;i++) { > ! for( j=0;j<ResInfo[i].count;j++) { > ! LPVOID RelocPos; > ! > ! /* > ! * The data is situated after the directory, the resourceheads > ! * and the strings > ! */ > ! RPR->OffsetToData += Directory.Size+ResourceHeads.Size+Strings.Size; > ! /* > ! * the resource heads, where the relocations have to take place, > ! * are just after the directory > ! */ > ! RelocPos = (LPVOID)(&RPR->OffsetToData); > ! AddRelocation((int)((BYTE *)Directory.Size - > ! (BYTE *)ResourceHeads.Image + > ! (BYTE *)RelocPos)); > ! > ! RPR++; > ! } > ! } > ! > ! // Finally we put all 'subsections' or chunks together > ! > ! if (AppendMemImage(&Directory,&ResourceHeads) == FALSE) > ! return FALSE; > ! > ! if (AppendMemImage(&Directory,&Strings) == FALSE) > ! return FALSE; > ! > ! return TRUE; > ! } > ! > ! void DumpResource(HANDLE ofile,PRESOURCEHEAD this) > ! { > ! BYTE *buffer = (BYTE *)this; > ! > ! buffer += this->HeaderSize; > ! CheckedWrite(ofile,buffer,this->DataSize,"resources"); > ! } > ! > ! void DumpResources(HANDLE ofile) > ! { > ! int i,j; > ! > ! for (i=1;i<17;i++) { > ! for (j=0;j < ResInfo[i].named;j++) > ! DumpResource(ofile,ResInfo[i].RName[j]); > ! > ! for (j=0;j < ResInfo[i].unnamed;j++) > ! DumpResource(ofile,ResInfo[i].RID[j]); > ! } > ! } > ! > ! void DumpDirectoryImage(HANDLE ofile) > ! { > ! CheckedWrite(ofile,Directory.Image,Directory.Size,"resource directory"); > ! } > ! > ! /* Dump all relocations */ > ! > ! void DumpRelocations(HANDLE ofile) > ! { > ! > ! /* > ! * The relocation type is 32 bits absolute without > ! * base reference. The smbols referenced is the > ! * section start, which is the first element of > ! * the symbols table. > ! */ > ! > ! IMAGE_RELOCATION RelocBuffer = { 0,0,IMAGE_REL_I386_DIR32NB}; > ! int i,*relocs; > ! > ! relocs = (int *)RelocTable.pElems; > ! for (i=0;i<RelocTable.nElems;i++) { > ! RelocBuffer.VirtualAddress = relocs[i]; > ! CheckedWrite(ofile,(LPVOID)(&RelocBuffer),10,"relocations"); > ! } > ! } > ! > ! void DumpSymbols(HANDLE ofile) > ! { > ! IMAGE_SYMBOL NewSym; > ! IMAGE_AUX_SYMBOL SecSym; > ! > ! memset(&NewSym,0,IMAGE_SIZEOF_SYMBOL); > ! memset(&SecSym,0,IMAGE_SIZEOF_SYMBOL); > ! > ! lstrcpyA(NewSym.N.ShortName,".rsrc"); > ! NewSym.Value = 0; > ! NewSym.SectionNumber = 1; > ! NewSym.Type = 0; > ! NewSym.StorageClass = 3; > ! NewSym.NumberOfAuxSymbols = 1; > ! > ! SecSym.Section.Length = ResourceSize+Directory.Size; > ! SecSym.Section.NumberOfRelocations = RelocTable.nElems; > ! > ! CheckedWrite(ofile,&NewSym,IMAGE_SIZEOF_SYMBOL,"symbols"); > ! CheckedWrite(ofile,&SecSym,IMAGE_SIZEOF_SYMBOL,"symbols"); > ! } > ! > ! void MakeCOFFSections(HANDLE ofile) > ! { > ! IMAGE_FILE_HEADER fileheader; > ! IMAGE_SECTION_HEADER RSRChdr; > ! > ! lstrcpyA(RSRChdr.Name,".rsrc"); > ! RSRChdr.Misc.PhysicalAddress = 0; > ! RSRChdr.VirtualAddress = 0; > ! RSRChdr.SizeOfRawData = ResourceSize+Directory.Size; > ! RSRChdr.PointerToRawData = IMAGE_SIZEOF_FILE_HEADER + > ! IMAGE_SIZEOF_SECTION_HEADER; > ! RSRChdr.PointerToRelocations = RSRChdr.SizeOfRawData + > ! RSRChdr.PointerToRawData; > ! RSRChdr.PointerToLinenumbers = 0; > ! RSRChdr.NumberOfRelocations = RelocTable.nElems; > ! RSRChdr.NumberOfLinenumbers = 0; > ! RSRChdr.Characteristics = IMAGE_SCN_MEM_READ > ! /* | IMAGE_SCN_MEM_WRITE */; > ! > ! fileheader.Machine = IMAGE_FILE_MACHINE_I386; > ! fileheader.NumberOfSections = 1; > ! fileheader.TimeDateStamp = ResourceTime; > ! fileheader.PointerToSymbolTable = RSRChdr.PointerToRelocations+ > ! RelocTable.nElems * 10; > ! fileheader.NumberOfSymbols = 2; > ! fileheader.SizeOfOptionalHeader = 0; > ! fileheader.Characteristics = IMAGE_FILE_LINE_NUMS_STRIPPED | > ! IMAGE_FILE_32BIT_MACHINE; > ! > ! CheckedWrite(ofile,&fileheader,IMAGE_SIZEOF_FILE_HEADER,"COFF file > header"); > ! CheckedWrite(ofile,&RSRChdr,IMAGE_SIZEOF_SECTION_HEADER,".rsrc section > header"); > ! } > ! > ===== Earnie Boyd mailto:ear...@ya... --- <http://earniesystems.safeshopper.com> --- --- Cygwin: POSIX on Windows <http://gw32.freeyellow.com/> --- --- Minimalist GNU for Windows <http://www.mingw.org/> --- __________________________________________________ Do You Yahoo!? Yahoo! - Official partner of 2002 FIFA World Cup http://fifaworldcup.yahoo.com |
|
From: <in...@us...> - 2002-05-26 10:14:05
|
Update of /cvsroot/mingw/utils/res2coff
In directory usw-pr-cvs1:/tmp/cvs-serv2405/res2coff
Modified Files:
objimage.c protos.h readme.1st res2coff.c res2coff.h
resimage.c
Log Message:
Convert some text files to Unix format
Index: objimage.c
===================================================================
RCS file: /cvsroot/mingw/utils/res2coff/objimage.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** objimage.c 14 May 2002 20:38:30 -0000 1.1
--- objimage.c 26 May 2002 10:13:58 -0000 1.2
***************
*** 1,385 ****
! /* *********************************************
! *
! * res2coff : Functions dealing with the creation
! * of a .o file image in memory before
! * writing it out
! *
! */
!
! #include "res2coff.h"
! #include <stdlib.h>
!
!
! /*
! * return the offset of the string we just added
! * into the string table or -1 if error
! * strings are DWORD aligned
! */
!
! int Add2StringTable(wchar_t *NewString)
! {
! int result = Strings.Size;
! int strlen = lstrlenW(NewString);
! int i,addsize;
! wchar_t *p1,*p2;
!
! addsize = (strlen+2) * sizeof(wchar_t);
! if (addsize % sizeof(DWORD))
! addsize += sizeof(wchar_t);
!
! Strings.Image = realloc(Strings.Image,result+addsize);
! if (Strings.Image == NULL)
! AppExit(1,"Out of memory for the string table\n",NULL);
!
! p1 = NewString;
! p2 = (wchar_t *)((BYTE *)Strings.Image+result);
! *p2++ = (wchar_t)strlen;
!
! for (i=0;i < strlen;i++)
! *p2++ = *p1++;
! *p2 = L'\0';
! Strings.Size +=addsize;
! return result;
! }
!
! // Append a MemImage to another MemImage
! int AppendMemImage(MemImage *membase,MemImage *memappend)
! {
! char *p1,*p2;
! int i;
!
! membase->Image = realloc(membase->Image,membase->Size+memappend->Size);
!
! if (membase->Image == NULL)
! AppExit(1,"Error reallocating MemImage!\n",NULL);
!
! p1 = (char *)memappend->Image;
! p2 = (char *)(membase->Image)+membase->Size;
!
! for(i=0;i<memappend->Size;i++)
! *p2++ = *p1++;
!
! membase->Size += memappend->Size;
! return TRUE;
! }
!
! // Add an entry to the relocation table
! int AddRelocation(int RVA)
! {
! int last,newsize,*pReloc;
!
! last = RelocTable.nElems++;
! newsize = RelocTable.nElems * sizeof(int);
! pReloc = RelocTable.pElems = realloc(RelocTable.pElems,newsize);
! if (pReloc == NULL)
! AppExit(1,"Out of memory for relocations\n",NULL);
! pReloc[last] = RVA ;
! return TRUE;
! }
!
! // Create the directory tree and other related chunks
!
! int MakeDirectoryTree(void)
! {
! PIMAGE_RESOURCE_DIRECTORY RD;
! PIMAGE_RESOURCE_DIRECTORY_ENTRY RDE;
! PIMAGE_RESOURCE_DATA_ENTRY RPR;
!
! int i,j,ThisOffset,ResSize;
!
! int types = 0;
! int ResPointOffs = 0;
! int ResourceOffs = 0;
! int PhantomID = 100;
!
! // we start by calculating the amount of memory we are
! // going to need in the directory image and the resource pointers
!
! ResourceHeads.Size = 0;
! Directory.Size = sizeof(IMAGE_RESOURCE_DIRECTORY); // in the root
! for (i=1;i<17;i++)
! if (ResInfo[i].count) {
! types++;
! Directory.Size += sizeof(IMAGE_RESOURCE_DIRECTORY_ENTRY); // in the root
! // resource types
! Directory.Size += sizeof(IMAGE_RESOURCE_DIRECTORY);
! Directory.Size += ResInfo[i].count *
! sizeof(IMAGE_RESOURCE_DIRECTORY_ENTRY);
! // individual resources
! Directory.Size += ResInfo[i].count *
! sizeof(IMAGE_RESOURCE_DIRECTORY);
! Directory.Size += ResInfo[i].count *
! sizeof(IMAGE_RESOURCE_DIRECTORY_ENTRY);
! //
! // reserve also for the Resource Pointer Records
! //
! ResourceHeads.Size += ResInfo[i].count *
! sizeof(IMAGE_RESOURCE_DATA_ENTRY);
! }
!
! if (types == 0)
! AppExit(1,"ERROR: no resources in RES file ?!?!\n",NULL);
!
! Directory.Image = malloc(Directory.Size);
! if (Directory.Image == NULL)
! AppExit(1,"Out of memory for the directory\n",NULL);
!
! ResourceHeads.Image = malloc(ResourceHeads.Size);
! if (ResourceHeads.Image == NULL)
! AppExit(1,"Out of memory for the resource headers\n",NULL);
!
! RPR = (PIMAGE_RESOURCE_DATA_ENTRY)ResourceHeads.Image;
!
! // Root Directory
!
! RD = (PIMAGE_RESOURCE_DIRECTORY)Directory.Image;
! RD -> Characteristics = 0;
! RD -> TimeStamp = ResourceTime;
! RD -> MajorVersion = DECLARED_MAV;
! RD -> MinorVersion = DECLARED_MIV;
! RD -> NumberOfNamedEntries = 0;
! RD -> NumberOfIdEntries = types;
!
! RD++;
! RDE = (PIMAGE_RESOURCE_DIRECTORY_ENTRY) RD;
! ThisOffset = sizeof(IMAGE_RESOURCE_DIRECTORY) +
! types * sizeof(IMAGE_RESOURCE_DIRECTORY_ENTRY);
!
! // Root directory entries are pointers to directories
! // of types
!
! for (i=1;i<17;i++)
! if (ResInfo[i].count) {
! RDE->Name = i;
! RDE->OffsetToData = ThisOffset | IMAGE_RESOURCE_DATA_IS_DIRECTORY ;
! RDE++;
! ThisOffset += sizeof(IMAGE_RESOURCE_DIRECTORY_ENTRY) * ResInfo[i].count +
! sizeof(IMAGE_RESOURCE_DIRECTORY);
! }
!
! // Now the directories of types
! // ThisOffset is pointing at the storage area for the last directory level
! // each Directory there will point to one and only one resource
!
! RD = (PIMAGE_RESOURCE_DIRECTORY)Directory.Image;
! RD++;
! RDE = (PIMAGE_RESOURCE_DIRECTORY_ENTRY)RD;
! for (i=0;i<types;i++) {
! int RDNum = RDE->Name & 0x7fffffff;
! int RDOfs = RDE->OffsetToData & 0x7fffffff;
! PIMAGE_RESOURCE_DIRECTORY_ENTRY RDENext;
!
! RD = (PIMAGE_RESOURCE_DIRECTORY)((BYTE *)Directory.Image + RDOfs);
!
! RD -> Characteristics = 0;
! RD -> TimeStamp = ResourceTime;
! RD -> MajorVersion = DECLARED_MAV;
! RD -> MinorVersion = DECLARED_MIV;
! RD -> NumberOfNamedEntries = ResInfo[RDNum].named;
! RD -> NumberOfIdEntries = ResInfo[RDNum].unnamed;
! RD++;
!
! RDENext = (PIMAGE_RESOURCE_DIRECTORY_ENTRY)RD;
! for (j=0;j<ResInfo[RDNum].count;j++) {
! PIMAGE_RESOURCE_DIRECTORY RDLast;
! PIMAGE_RESOURCE_DIRECTORY_ENTRY RDELast;
! PRESOURCEHEAD *pThisResource;
!
! if (j==0)
! pThisResource = ResInfo[RDNum].RName;
! if (j == ResInfo[RDNum].named)
! pThisResource = ResInfo[RDNum].RID;
!
! if (j < ResInfo[RDNum].named) {
! wchar_t *NameInRES;
! int NameOfs;
!
! NameInRES = ResName(*pThisResource);
! NameOfs = Add2StringTable(NameInRES);
! NameOfs += Directory.Size+ResourceHeads.Size;
! RDENext->Name = NameOfs | IMAGE_RESOURCE_NAME_IS_STRING;
! } else {
! wchar_t *NameID = ResName(*pThisResource);
! if (*NameID == 0xffff) {
! PhantomID = (int)*(++NameID);
! RDENext->Name = PhantomID++;
! } else {
! AppExit(1,"Unnamed resource has no ID field",NULL);
! }
! }
!
! RDENext->OffsetToData = ThisOffset | IMAGE_RESOURCE_DATA_IS_DIRECTORY;
!
! RDLast = (PIMAGE_RESOURCE_DIRECTORY)
! ((BYTE *)Directory.Image+ThisOffset);
!
! ThisOffset += sizeof(IMAGE_RESOURCE_DIRECTORY);
!
! RDLast -> Characteristics = 0;
! RDLast -> TimeStamp = ResourceTime;
! RDLast -> MajorVersion = DECLARED_MAV;
! RDLast -> MinorVersion = DECLARED_MIV;
! RDLast -> NumberOfNamedEntries = 0;
! RDLast -> NumberOfIdEntries = 1;
!
! RDELast = (PIMAGE_RESOURCE_DIRECTORY_ENTRY)
! ((BYTE *)Directory.Image+ThisOffset);
!
! ThisOffset += sizeof(IMAGE_RESOURCE_DIRECTORY_ENTRY);
! RDELast->Name = PhantomID++;
! RDELast->OffsetToData = Directory.Size+ResPointOffs;
! ResSize = (*pThisResource)->DataSize;
!
! RPR -> OffsetToData = ResourceOffs;
! RPR -> Size = ResSize;
! RPR -> CodePage = LanguageID(*pThisResource);
! RPR -> Reserved = 0;
!
! RPR++;
! RDENext++;
! ResPointOffs += sizeof(IMAGE_RESOURCE_DATA_ENTRY);
! ResourceOffs += ResSize;
! pThisResource++;
! }
! RDE++;
! }
!
! ResourceSize = ResourceOffs;
!
! RPR = (PIMAGE_RESOURCE_DATA_ENTRY)ResourceHeads.Image;
! for (i=0;i<17;i++) {
! for( j=0;j<ResInfo[i].count;j++) {
! LPVOID RelocPos;
!
! /*
! * The data is situated after the directory, the resourceheads
! * and the strings
! */
! RPR->OffsetToData += Directory.Size+ResourceHeads.Size+Strings.Size;
! /*
! * the resource heads, where the relocations have to take place,
! * are just after the directory
! */
! RelocPos = (LPVOID)(&RPR->OffsetToData);
! AddRelocation((int)((BYTE *)Directory.Size -
! (BYTE *)ResourceHeads.Image +
! (BYTE *)RelocPos));
!
! RPR++;
! }
! }
!
! // Finally we put all 'subsections' or chunks together
!
! if (AppendMemImage(&Directory,&ResourceHeads) == FALSE)
! return FALSE;
!
! if (AppendMemImage(&Directory,&Strings) == FALSE)
! return FALSE;
!
! return TRUE;
! }
!
! void DumpResource(HANDLE ofile,PRESOURCEHEAD this)
! {
! BYTE *buffer = (BYTE *)this;
!
! buffer += this->HeaderSize;
! CheckedWrite(ofile,buffer,this->DataSize,"resources");
! }
!
! void DumpResources(HANDLE ofile)
! {
! int i,j;
!
! for (i=1;i<17;i++) {
! for (j=0;j < ResInfo[i].named;j++)
! DumpResource(ofile,ResInfo[i].RName[j]);
!
! for (j=0;j < ResInfo[i].unnamed;j++)
! DumpResource(ofile,ResInfo[i].RID[j]);
! }
! }
!
! void DumpDirectoryImage(HANDLE ofile)
! {
! CheckedWrite(ofile,Directory.Image,Directory.Size,"resource directory");
! }
!
! /* Dump all relocations */
!
! void DumpRelocations(HANDLE ofile)
! {
!
! /*
! * The relocation type is 32 bits absolute without
! * base reference. The smbols referenced is the
! * section start, which is the first element of
! * the symbols table.
! */
!
! IMAGE_RELOCATION RelocBuffer = { 0,0,IMAGE_REL_I386_DIR32NB};
! int i,*relocs;
!
! relocs = (int *)RelocTable.pElems;
! for (i=0;i<RelocTable.nElems;i++) {
! RelocBuffer.VirtualAddress = relocs[i];
! CheckedWrite(ofile,(LPVOID)(&RelocBuffer),10,"relocations");
! }
! }
!
! void DumpSymbols(HANDLE ofile)
! {
! IMAGE_SYMBOL NewSym;
! IMAGE_AUX_SYMBOL SecSym;
!
! memset(&NewSym,0,IMAGE_SIZEOF_SYMBOL);
! memset(&SecSym,0,IMAGE_SIZEOF_SYMBOL);
!
! lstrcpyA(NewSym.N.ShortName,".rsrc");
! NewSym.Value = 0;
! NewSym.SectionNumber = 1;
! NewSym.Type = 0;
! NewSym.StorageClass = 3;
! NewSym.NumberOfAuxSymbols = 1;
!
! SecSym.Section.Length = ResourceSize+Directory.Size;
! SecSym.Section.NumberOfRelocations = RelocTable.nElems;
!
! CheckedWrite(ofile,&NewSym,IMAGE_SIZEOF_SYMBOL,"symbols");
! CheckedWrite(ofile,&SecSym,IMAGE_SIZEOF_SYMBOL,"symbols");
! }
!
! void MakeCOFFSections(HANDLE ofile)
! {
! IMAGE_FILE_HEADER fileheader;
! IMAGE_SECTION_HEADER RSRChdr;
!
! lstrcpyA(RSRChdr.Name,".rsrc");
! RSRChdr.Misc.PhysicalAddress = 0;
! RSRChdr.VirtualAddress = 0;
! RSRChdr.SizeOfRawData = ResourceSize+Directory.Size;
! RSRChdr.PointerToRawData = IMAGE_SIZEOF_FILE_HEADER +
! IMAGE_SIZEOF_SECTION_HEADER;
! RSRChdr.PointerToRelocations = RSRChdr.SizeOfRawData +
! RSRChdr.PointerToRawData;
! RSRChdr.PointerToLinenumbers = 0;
! RSRChdr.NumberOfRelocations = RelocTable.nElems;
! RSRChdr.NumberOfLinenumbers = 0;
! RSRChdr.Characteristics = IMAGE_SCN_MEM_READ
! /* | IMAGE_SCN_MEM_WRITE */;
!
! fileheader.Machine = IMAGE_FILE_MACHINE_I386;
! fileheader.NumberOfSections = 1;
! fileheader.TimeDateStamp = ResourceTime;
! fileheader.PointerToSymbolTable = RSRChdr.PointerToRelocations+
! RelocTable.nElems * 10;
! fileheader.NumberOfSymbols = 2;
! fileheader.SizeOfOptionalHeader = 0;
! fileheader.Characteristics = IMAGE_FILE_LINE_NUMS_STRIPPED |
! IMAGE_FILE_32BIT_MACHINE;
!
! CheckedWrite(ofile,&fileheader,IMAGE_SIZEOF_FILE_HEADER,"COFF file header");
! CheckedWrite(ofile,&RSRChdr,IMAGE_SIZEOF_SECTION_HEADER,".rsrc section header");
! }
!
--- 1,385 ----
! /* *********************************************
! *
! * res2coff : Functions dealing with the creation
! * of a .o file image in memory before
! * writing it out
! *
! */
!
! #include "res2coff.h"
! #include <stdlib.h>
!
!
! /*
! * return the offset of the string we just added
! * into the string table or -1 if error
! * strings are DWORD aligned
! */
!
! int Add2StringTable(wchar_t *NewString)
! {
! int result = Strings.Size;
! int strlen = lstrlenW(NewString);
! int i,addsize;
! wchar_t *p1,*p2;
!
! addsize = (strlen+2) * sizeof(wchar_t);
! if (addsize % sizeof(DWORD))
! addsize += sizeof(wchar_t);
!
! Strings.Image = realloc(Strings.Image,result+addsize);
! if (Strings.Image == NULL)
! AppExit(1,"Out of memory for the string table\n",NULL);
!
! p1 = NewString;
! p2 = (wchar_t *)((BYTE *)Strings.Image+result);
! *p2++ = (wchar_t)strlen;
!
! for (i=0;i < strlen;i++)
! *p2++ = *p1++;
! *p2 = L'\0';
! Strings.Size +=addsize;
! return result;
! }
!
! // Append a MemImage to another MemImage
! int AppendMemImage(MemImage *membase,MemImage *memappend)
! {
! char *p1,*p2;
! int i;
!
! membase->Image = realloc(membase->Image,membase->Size+memappend->Size);
!
! if (membase->Image == NULL)
! AppExit(1,"Error reallocating MemImage!\n",NULL);
!
! p1 = (char *)memappend->Image;
! p2 = (char *)(membase->Image)+membase->Size;
!
! for(i=0;i<memappend->Size;i++)
! *p2++ = *p1++;
!
! membase->Size += memappend->Size;
! return TRUE;
! }
!
! // Add an entry to the relocation table
! int AddRelocation(int RVA)
! {
! int last,newsize,*pReloc;
!
! last = RelocTable.nElems++;
! newsize = RelocTable.nElems * sizeof(int);
! pReloc = RelocTable.pElems = realloc(RelocTable.pElems,newsize);
! if (pReloc == NULL)
! AppExit(1,"Out of memory for relocations\n",NULL);
! pReloc[last] = RVA ;
! return TRUE;
! }
!
! // Create the directory tree and other related chunks
!
! int MakeDirectoryTree(void)
! {
! PIMAGE_RESOURCE_DIRECTORY RD;
! PIMAGE_RESOURCE_DIRECTORY_ENTRY RDE;
! PIMAGE_RESOURCE_DATA_ENTRY RPR;
!
! int i,j,ThisOffset,ResSize;
!
! int types = 0;
! int ResPointOffs = 0;
! int ResourceOffs = 0;
! int PhantomID = 100;
!
! // we start by calculating the amount of memory we are
! // going to need in the directory image and the resource pointers
!
! ResourceHeads.Size = 0;
! Directory.Size = sizeof(IMAGE_RESOURCE_DIRECTORY); // in the root
! for (i=1;i<17;i++)
! if (ResInfo[i].count) {
! types++;
! Directory.Size += sizeof(IMAGE_RESOURCE_DIRECTORY_ENTRY); // in the root
! // resource types
! Directory.Size += sizeof(IMAGE_RESOURCE_DIRECTORY);
! Directory.Size += ResInfo[i].count *
! sizeof(IMAGE_RESOURCE_DIRECTORY_ENTRY);
! // individual resources
! Directory.Size += ResInfo[i].count *
! sizeof(IMAGE_RESOURCE_DIRECTORY);
! Directory.Size += ResInfo[i].count *
! sizeof(IMAGE_RESOURCE_DIRECTORY_ENTRY);
! //
! // reserve also for the Resource Pointer Records
! //
! ResourceHeads.Size += ResInfo[i].count *
! sizeof(IMAGE_RESOURCE_DATA_ENTRY);
! }
!
! if (types == 0)
! AppExit(1,"ERROR: no resources in RES file ?!?!\n",NULL);
!
! Directory.Image = malloc(Directory.Size);
! if (Directory.Image == NULL)
! AppExit(1,"Out of memory for the directory\n",NULL);
!
! ResourceHeads.Image = malloc(ResourceHeads.Size);
! if (ResourceHeads.Image == NULL)
! AppExit(1,"Out of memory for the resource headers\n",NULL);
!
! RPR = (PIMAGE_RESOURCE_DATA_ENTRY)ResourceHeads.Image;
!
! // Root Directory
!
! RD = (PIMAGE_RESOURCE_DIRECTORY)Directory.Image;
! RD -> Characteristics = 0;
! RD -> TimeStamp = ResourceTime;
! RD -> MajorVersion = DECLARED_MAV;
! RD -> MinorVersion = DECLARED_MIV;
! RD -> NumberOfNamedEntries = 0;
! RD -> NumberOfIdEntries = types;
!
! RD++;
! RDE = (PIMAGE_RESOURCE_DIRECTORY_ENTRY) RD;
! ThisOffset = sizeof(IMAGE_RESOURCE_DIRECTORY) +
! types * sizeof(IMAGE_RESOURCE_DIRECTORY_ENTRY);
!
! // Root directory entries are pointers to directories
! // of types
!
! for (i=1;i<17;i++)
! if (ResInfo[i].count) {
! RDE->Name = i;
! RDE->OffsetToData = ThisOffset | IMAGE_RESOURCE_DATA_IS_DIRECTORY ;
! RDE++;
! ThisOffset += sizeof(IMAGE_RESOURCE_DIRECTORY_ENTRY) * ResInfo[i].count +
! sizeof(IMAGE_RESOURCE_DIRECTORY);
! }
!
! // Now the directories of types
! // ThisOffset is pointing at the storage area for the last directory level
! // each Directory there will point to one and only one resource
!
! RD = (PIMAGE_RESOURCE_DIRECTORY)Directory.Image;
! RD++;
! RDE = (PIMAGE_RESOURCE_DIRECTORY_ENTRY)RD;
! for (i=0;i<types;i++) {
! int RDNum = RDE->Name & 0x7fffffff;
! int RDOfs = RDE->OffsetToData & 0x7fffffff;
! PIMAGE_RESOURCE_DIRECTORY_ENTRY RDENext;
!
! RD = (PIMAGE_RESOURCE_DIRECTORY)((BYTE *)Directory.Image + RDOfs);
!
! RD -> Characteristics = 0;
! RD -> TimeStamp = ResourceTime;
! RD -> MajorVersion = DECLARED_MAV;
! RD -> MinorVersion = DECLARED_MIV;
! RD -> NumberOfNamedEntries = ResInfo[RDNum].named;
! RD -> NumberOfIdEntries = ResInfo[RDNum].unnamed;
! RD++;
!
! RDENext = (PIMAGE_RESOURCE_DIRECTORY_ENTRY)RD;
! for (j=0;j<ResInfo[RDNum].count;j++) {
! PIMAGE_RESOURCE_DIRECTORY RDLast;
! PIMAGE_RESOURCE_DIRECTORY_ENTRY RDELast;
! PRESOURCEHEAD *pThisResource;
!
! if (j==0)
! pThisResource = ResInfo[RDNum].RName;
! if (j == ResInfo[RDNum].named)
! pThisResource = ResInfo[RDNum].RID;
!
! if (j < ResInfo[RDNum].named) {
! wchar_t *NameInRES;
! int NameOfs;
!
! NameInRES = ResName(*pThisResource);
! NameOfs = Add2StringTable(NameInRES);
! NameOfs += Directory.Size+ResourceHeads.Size;
! RDENext->Name = NameOfs | IMAGE_RESOURCE_NAME_IS_STRING;
! } else {
! wchar_t *NameID = ResName(*pThisResource);
! if (*NameID == 0xffff) {
! PhantomID = (int)*(++NameID);
! RDENext->Name = PhantomID++;
! } else {
! AppExit(1,"Unnamed resource has no ID field",NULL);
! }
! }
!
! RDENext->OffsetToData = ThisOffset | IMAGE_RESOURCE_DATA_IS_DIRECTORY;
!
! RDLast = (PIMAGE_RESOURCE_DIRECTORY)
! ((BYTE *)Directory.Image+ThisOffset);
!
! ThisOffset += sizeof(IMAGE_RESOURCE_DIRECTORY);
!
! RDLast -> Characteristics = 0;
! RDLast -> TimeStamp = ResourceTime;
! RDLast -> MajorVersion = DECLARED_MAV;
! RDLast -> MinorVersion = DECLARED_MIV;
! RDLast -> NumberOfNamedEntries = 0;
! RDLast -> NumberOfIdEntries = 1;
!
! RDELast = (PIMAGE_RESOURCE_DIRECTORY_ENTRY)
! ((BYTE *)Directory.Image+ThisOffset);
!
! ThisOffset += sizeof(IMAGE_RESOURCE_DIRECTORY_ENTRY);
! RDELast->Name = PhantomID++;
! RDELast->OffsetToData = Directory.Size+ResPointOffs;
! ResSize = (*pThisResource)->DataSize;
!
! RPR -> OffsetToData = ResourceOffs;
! RPR -> Size = ResSize;
! RPR -> CodePage = LanguageID(*pThisResource);
! RPR -> Reserved = 0;
!
! RPR++;
! RDENext++;
! ResPointOffs += sizeof(IMAGE_RESOURCE_DATA_ENTRY);
! ResourceOffs += ResSize;
! pThisResource++;
! }
! RDE++;
! }
!
! ResourceSize = ResourceOffs;
!
! RPR = (PIMAGE_RESOURCE_DATA_ENTRY)ResourceHeads.Image;
! for (i=0;i<17;i++) {
! for( j=0;j<ResInfo[i].count;j++) {
! LPVOID RelocPos;
!
! /*
! * The data is situated after the directory, the resourceheads
! * and the strings
! */
! RPR->OffsetToData += Directory.Size+ResourceHeads.Size+Strings.Size;
! /*
! * the resource heads, where the relocations have to take place,
! * are just after the directory
! */
! RelocPos = (LPVOID)(&RPR->OffsetToData);
! AddRelocation((int)((BYTE *)Directory.Size -
! (BYTE *)ResourceHeads.Image +
! (BYTE *)RelocPos));
!
! RPR++;
! }
! }
!
! // Finally we put all 'subsections' or chunks together
!
! if (AppendMemImage(&Directory,&ResourceHeads) == FALSE)
! return FALSE;
!
! if (AppendMemImage(&Directory,&Strings) == FALSE)
! return FALSE;
!
! return TRUE;
! }
!
! void DumpResource(HANDLE ofile,PRESOURCEHEAD this)
! {
! BYTE *buffer = (BYTE *)this;
!
! buffer += this->HeaderSize;
! CheckedWrite(ofile,buffer,this->DataSize,"resources");
! }
!
! void DumpResources(HANDLE ofile)
! {
! int i,j;
!
! for (i=1;i<17;i++) {
! for (j=0;j < ResInfo[i].named;j++)
! DumpResource(ofile,ResInfo[i].RName[j]);
!
! for (j=0;j < ResInfo[i].unnamed;j++)
! DumpResource(ofile,ResInfo[i].RID[j]);
! }
! }
!
! void DumpDirectoryImage(HANDLE ofile)
! {
! CheckedWrite(ofile,Directory.Image,Directory.Size,"resource directory");
! }
!
! /* Dump all relocations */
!
! void DumpRelocations(HANDLE ofile)
! {
!
! /*
! * The relocation type is 32 bits absolute without
! * base reference. The smbols referenced is the
! * section start, which is the first element of
! * the symbols table.
! */
!
! IMAGE_RELOCATION RelocBuffer = { 0,0,IMAGE_REL_I386_DIR32NB};
! int i,*relocs;
!
! relocs = (int *)RelocTable.pElems;
! for (i=0;i<RelocTable.nElems;i++) {
! RelocBuffer.VirtualAddress = relocs[i];
! CheckedWrite(ofile,(LPVOID)(&RelocBuffer),10,"relocations");
! }
! }
!
! void DumpSymbols(HANDLE ofile)
! {
! IMAGE_SYMBOL NewSym;
! IMAGE_AUX_SYMBOL SecSym;
!
! memset(&NewSym,0,IMAGE_SIZEOF_SYMBOL);
! memset(&SecSym,0,IMAGE_SIZEOF_SYMBOL);
!
! lstrcpyA(NewSym.N.ShortName,".rsrc");
! NewSym.Value = 0;
! NewSym.SectionNumber = 1;
! NewSym.Type = 0;
! NewSym.StorageClass = 3;
! NewSym.NumberOfAuxSymbols = 1;
!
! SecSym.Section.Length = ResourceSize+Directory.Size;
! SecSym.Section.NumberOfRelocations = RelocTable.nElems;
!
! CheckedWrite(ofile,&NewSym,IMAGE_SIZEOF_SYMBOL,"symbols");
! CheckedWrite(ofile,&SecSym,IMAGE_SIZEOF_SYMBOL,"symbols");
! }
!
! void MakeCOFFSections(HANDLE ofile)
! {
! IMAGE_FILE_HEADER fileheader;
! IMAGE_SECTION_HEADER RSRChdr;
!
! lstrcpyA(RSRChdr.Name,".rsrc");
! RSRChdr.Misc.PhysicalAddress = 0;
! RSRChdr.VirtualAddress = 0;
! RSRChdr.SizeOfRawData = ResourceSize+Directory.Size;
! RSRChdr.PointerToRawData = IMAGE_SIZEOF_FILE_HEADER +
! IMAGE_SIZEOF_SECTION_HEADER;
! RSRChdr.PointerToRelocations = RSRChdr.SizeOfRawData +
! RSRChdr.PointerToRawData;
! RSRChdr.PointerToLinenumbers = 0;
! RSRChdr.NumberOfRelocations = RelocTable.nElems;
! RSRChdr.NumberOfLinenumbers = 0;
! RSRChdr.Characteristics = IMAGE_SCN_MEM_READ
! /* | IMAGE_SCN_MEM_WRITE */;
!
! fileheader.Machine = IMAGE_FILE_MACHINE_I386;
! fileheader.NumberOfSections = 1;
! fileheader.TimeDateStamp = ResourceTime;
! fileheader.PointerToSymbolTable = RSRChdr.PointerToRelocations+
! RelocTable.nElems * 10;
! fileheader.NumberOfSymbols = 2;
! fileheader.SizeOfOptionalHeader = 0;
! fileheader.Characteristics = IMAGE_FILE_LINE_NUMS_STRIPPED |
! IMAGE_FILE_32BIT_MACHINE;
!
! CheckedWrite(ofile,&fileheader,IMAGE_SIZEOF_FILE_HEADER,"COFF file header");
! CheckedWrite(ofile,&RSRChdr,IMAGE_SIZEOF_SECTION_HEADER,".rsrc section header");
! }
!
Index: protos.h
===================================================================
RCS file: /cvsroot/mingw/utils/res2coff/protos.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** protos.h 14 May 2002 20:38:30 -0000 1.1
--- protos.h 26 May 2002 10:13:58 -0000 1.2
***************
*** 1,37 ****
! // res2coff.c
!
! void WriteError(LPCSTR);
! void AppExit(int,char *,...);
! void CleanUp(void);
! void CheckedWrite(HANDLE,LPVOID,DWORD,char *);
! void usage(char);
!
! // OBJimage.c
!
! int Add2StringTable(wchar_t *);
! int AppendMemImage(MemImage *,MemImage *);
! int AddRelocation(int);
! int MakeDirectoryTree(void);
! int MakeSymbols(char *);
!
! void DumpResources(HANDLE);
! void DumpDirectoryImage(HANDLE);
! void DumpRelocations(HANDLE);
! void DumpSymbols(HANDLE);
! void MakeCOFFSections(HANDLE);
!
! // RESimage.c
!
! void InitResourceInfo(void);
! void FreeResourceInfo(void);
! int AddNamedResource(int,PRESOURCEHEAD);
! int AddIDResource(int,PRESOURCEHEAD);
! int IsTypeCoded(PRESOURCEHEAD);
! int TypeCode(PRESOURCEHEAD);
! int IsNameCoded(PRESOURCEHEAD);
! int IDCode(PRESOURCEHEAD);
! wchar_t *ResName(PRESOURCEHEAD);
! WORD LanguageID(PRESOURCEHEAD);
! PRESOURCEHEAD ParseResource(PRESOURCEHEAD);
! int Check32bitResourceFile(PRESOURCEHEAD);
! void SortUnnamedResources(void);
--- 1,37 ----
! // res2coff.c
!
! void WriteError(LPCSTR);
! void AppExit(int,char *,...);
! void CleanUp(void);
! void CheckedWrite(HANDLE,LPVOID,DWORD,char *);
! void usage(char);
!
! // OBJimage.c
!
! int Add2StringTable(wchar_t *);
! int AppendMemImage(MemImage *,MemImage *);
! int AddRelocation(int);
! int MakeDirectoryTree(void);
! int MakeSymbols(char *);
!
! void DumpResources(HANDLE);
! void DumpDirectoryImage(HANDLE);
! void DumpRelocations(HANDLE);
! void DumpSymbols(HANDLE);
! void MakeCOFFSections(HANDLE);
!
! // RESimage.c
!
! void InitResourceInfo(void);
! void FreeResourceInfo(void);
! int AddNamedResource(int,PRESOURCEHEAD);
! int AddIDResource(int,PRESOURCEHEAD);
! int IsTypeCoded(PRESOURCEHEAD);
! int TypeCode(PRESOURCEHEAD);
! int IsNameCoded(PRESOURCEHEAD);
! int IDCode(PRESOURCEHEAD);
! wchar_t *ResName(PRESOURCEHEAD);
! WORD LanguageID(PRESOURCEHEAD);
! PRESOURCEHEAD ParseResource(PRESOURCEHEAD);
! int Check32bitResourceFile(PRESOURCEHEAD);
! void SortUnnamedResources(void);
Index: readme.1st
===================================================================
RCS file: /cvsroot/mingw/utils/res2coff/readme.1st,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** readme.1st 14 May 2002 20:38:30 -0000 1.1
--- readme.1st 26 May 2002 10:13:58 -0000 1.2
***************
*** 1,40 ****
! RES2COFF : a binary resource to COFF object format converter
!
! First of all understand this :
!
! * THIS SOFTWARE IS NOT COPYRIGHTED
! *
! * This source code is offered for use in the public domain. You may
! * use, modify or distribute it freely.
! *
! * This code is distributed in the hope that it will be useful but
! * WITHOUT ANY WARRANTY. ALL WARRENTIES, EXPRESS OR IMPLIED ARE HEREBY
! * DISCLAMED. This includes but is not limited to warrenties of
! * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
!
! Second, should you reuse it, I'd really appretiate a reference to this
! software. Blessings (if the program is useful to you), why not. Blamings,
! none.
!
! Now how to use it:
!
! res2coff [-v] -i <resource file> -o <object file>
!
! Both the resource and the object file have to be fully qualified and include
! the extension. I never assume anything about files.
!
! the -v flag will turn on a verbose mode which will show you a
! short recap of all resources found in the resource file.
!
! Revision history:
!
! v1.00 First 'working' version using Jacob Navia's lccwin32
! v1.10 Ported to the Minimalist GNUWIN32 with the win32 headers
! from lccwin32, modified to pack system structures under GCC
! v1.20 Sorts the string tables found and now passes the tests
! in RCL 1.6.3
!
! Enjoy
!
! Pedro A. Aranda
! pa...@ti...
--- 1,40 ----
! RES2COFF : a binary resource to COFF object format converter
!
! First of all understand this :
!
! * THIS SOFTWARE IS NOT COPYRIGHTED
! *
! * This source code is offered for use in the public domain. You may
! * use, modify or distribute it freely.
! *
! * This code is distributed in the hope that it will be useful but
! * WITHOUT ANY WARRANTY. ALL WARRENTIES, EXPRESS OR IMPLIED ARE HEREBY
! * DISCLAMED. This includes but is not limited to warrenties of
! * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
!
! Second, should you reuse it, I'd really appretiate a reference to this
! software. Blessings (if the program is useful to you), why not. Blamings,
! none.
!
! Now how to use it:
!
! res2coff [-v] -i <resource file> -o <object file>
!
! Both the resource and the object file have to be fully qualified and include
! the extension. I never assume anything about files.
!
! the -v flag will turn on a verbose mode which will show you a
! short recap of all resources found in the resource file.
!
! Revision history:
!
! v1.00 First 'working' version using Jacob Navia's lccwin32
! v1.10 Ported to the Minimalist GNUWIN32 with the win32 headers
! from lccwin32, modified to pack system structures under GCC
! v1.20 Sorts the string tables found and now passes the tests
! in RCL 1.6.3
!
! Enjoy
!
! Pedro A. Aranda
! pa...@ti...
Index: res2coff.c
===================================================================
RCS file: /cvsroot/mingw/utils/res2coff/res2coff.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** res2coff.c 14 May 2002 20:38:30 -0000 1.1
--- res2coff.c 26 May 2002 10:13:58 -0000 1.2
***************
*** 1,237 ****
! #define __main__
! #include "res2coff.h"
!
! /*
! res2coff.c
!
! Convert a 32 bit resource file into a COFF file
! to integrate the resources into an application
! at link time
!
! v1.00 : First official release, seems to be quite
! debugged
!
! v1.01 : stdargs for AppExit()
! standalone CleanUp()
! Compilable with mingw32 and Jacob Navia's WIN32 headers
!
! Most of the credit for getting me doing this thing is
! for Matt Pietrek's and his Windows95 Programming Secrets.
! I got the book before I even thought of doing this, but
! without it, I wouldn't have even dared to start.
!
! * Contributors:
! * Created by Pedro A. Aranda <pa...@ti...>
! *
! * THIS SOFTWARE IS NOT COPYRIGHTED
! *
! * This source code is offered for use in the public domain. You may
! * use, modify or distribute it freely.
! *
! * This code is distributed in the hope that it will be useful but
! * WITHOUT ANY WARRANTY. ALL WARRENTIES, EXPRESS OR IMPLIED ARE HEREBY
! * DISCLAMED. This includes but is not limited to warrenties of
! * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
!
! Madrid, 06-06-96
!
! */
!
! /*
! * Exit the program in an orderly way
! * Any open handles are closed,
! * All dynamic memory is freed
! * Error messages are printed out through stderr
! */
!
! void CleanUp(void)
! {
!
! if (Directory.Image)
! free(Directory.Image);
!
! if (Strings.Image)
! free(Strings.Image);
!
! if (ResourceHeads.Image)
! free(ResourceHeads.Image);
!
! if (RelocTable.pElems)
! free(RelocTable.pElems);
!
! FreeResourceInfo();
!
! if (RESview)
! UnmapViewOfFile(RESview);
! if (RESmapping)
! CloseHandle(RESmapping);
! if ((RESfile) && (RESfile != (HANDLE)INVALID_HANDLE_VALUE))
! CloseHandle(RESfile);
! if ((OBJFile) && (OBJFile != (HANDLE)INVALID_HANDLE_VALUE))
! CloseHandle(OBJFile);
! }
!
! void AppExit(int ErrorLevel,char *msg,...)
! {
! va_list args;
!
! va_start(args,msg);
! if ((ErrorLevel) && (msg))
! {
! fprintf(stderr,"%s :",ProgName);
! vfprintf(stderr,msg,args);
! }
! va_end(args);
!
! CleanUp();
! exit(ErrorLevel);
! }
!
! void CheckedWrite(HANDLE of,LPVOID buffer,DWORD size,char *sectmsg)
! {
! DWORD written;
!
! WriteFile(of,buffer,size,&written,NULL);
! if (written == size)
! return;
! else
! AppExit(1,"Error writing %s , disk full(?)\n",sectmsg);
! }
!
! void usage(char wrong)
! {
! printf("\nUsage: %s [-v] -i infile -o outfile\n\n"
! " -v verbose mode\n"
! " -i <file>.res RES32 file (input)\n"
! " -o <file>.o COFF object file (output)\n",ProgName);
!
! if (wrong)
! printf("\n -%c is not defined as a valid option \n",wrong);
!
! exit(-1);
! }
!
! int main(int argc,char **argv)
! {
! int arg,result;
! char *src,*dst;
! DWORD cbFileSize;
!
! ProgName = argv[0];
!
! if (argc == 1) {
! usage(0);
! exit(-1);
! }
!
! ResourceTime = (unsigned long)time(NULL);
!
! verbose = 0;
! src = dst = NULL;
!
! InitResourceInfo();
!
! for (arg = 1;arg < argc;arg++) {
! if (argv[arg][0] == '-')
! switch(argv[arg][1]) {
! case 'v':
! case 'V': verbose = 1;
! break;
!
! case 'i':
! case 'I': if (argv[arg][2])
! src = &argv[arg][2];
! else
! src = argv[++arg];
! break;
! case 'o':
! case 'O': if (argv[arg][2])
! dst = &argv[arg][2];
! else
! dst = argv[++arg];
! break;
!
! default : usage(argv[arg][1]);
! break;
! } else
! usage(0);
! }
!
! if (src == NULL) {
! usage(0);
! printf("No input file\n");
! }
!
! if (dst == NULL) {
! usage(0);
! printf("No output file\n");
! }
!
! if (verbose)
! printf("%s version %x.%02x\n\n",ProgName,__MAVERSION__,__MIVERSION__);
!
! /*
! * Now we enter a very orderly procedure:
! * 1.- Open the resource file
! * 2.- Create a maping for it
! * 3.- Map it into virtual memory
! * 4.- Check it is indeed a RES32 file
! * 5.- Sort the unnamed resources (v1.2)
! * 6.- Create the COFF object file
! *
! * Should any of these steps fail, the application is
! * exited in an orderly way
! */
!
! RESfile = CreateFileA(src, GENERIC_READ,
! FILE_SHARE_READ, NULL, OPEN_EXISTING,
! FILE_FLAG_SEQUENTIAL_SCAN, NULL);
!
! if ((!RESfile) || (RESfile == (HANDLE)INVALID_HANDLE_VALUE))
! AppExit(1,"Couldn't open '%s'\n",src);
!
! RESmapping = CreateFileMappingA(RESfile,NULL,PAGE_READONLY,0,0,NULL);
!
! if (RESmapping == NULL)
! AppExit(1,"Couldn't create file mapping for '%s'\n",src);
!
! RESview = MapViewOfFile(RESmapping, FILE_MAP_READ, 0, 0, 0);
!
! if (RESview == NULL)
! AppExit(1,"Couldn't map view of '%s'\n",src);
!
! cbFileSize = GetFileSize(RESfile, NULL);
!
! if ((cbFileSize == -1) && (GetLastError() != NO_ERROR))
! AppExit(1,"Error getting size of '%s'",src);
!
! RESviewEnd = (void *)((BYTE *)RESview + cbFileSize);
!
! if (!Check32bitResourceFile((PRESOURCEHEAD)RESview))
! AppExit(1,"Error in RES32 file format in '%s'\n",src);
!
! SortUnnamedResources();
!
! OBJFile = CreateFileA(dst,GENERIC_WRITE,0,NULL,
! CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL);
!
! if ((!OBJFile) || (OBJFile == (HANDLE)INVALID_HANDLE_VALUE))
! AppExit(1,"Couldn't create '%s'\n",dst);
!
! /*
! * Now we do the real processing. All functions have
! * autodocumenting names, just follow the code.
! * When all is done, we exit in an ordely way,
! * cleaning up any kind off mess we could have
! * stored in memory and flagging success (error level = 0)
! */
! MakeDirectoryTree();
! MakeCOFFSections(OBJFile);
! DumpDirectoryImage(OBJFile);
! DumpResources(OBJFile);
! DumpRelocations(OBJFile);
! DumpSymbols(OBJFile);
! CleanUp();
! return 0;
! }
!
--- 1,237 ----
! #define __main__
! #include "res2coff.h"
!
! /*
! res2coff.c
!
! Convert a 32 bit resource file into a COFF file
! to integrate the resources into an application
! at link time
!
! v1.00 : First official release, seems to be quite
! debugged
!
! v1.01 : stdargs for AppExit()
! standalone CleanUp()
! Compilable with mingw32 and Jacob Navia's WIN32 headers
!
! Most of the credit for getting me doing this thing is
! for Matt Pietrek's and his Windows95 Programming Secrets.
! I got the book before I even thought of doing this, but
! without it, I wouldn't have even dared to start.
!
! * Contributors:
! * Created by Pedro A. Aranda <pa...@ti...>
! *
! * THIS SOFTWARE IS NOT COPYRIGHTED
! *
! * This source code is offered for use in the public domain. You may
! * use, modify or distribute it freely.
! *
! * This code is distributed in the hope that it will be useful but
! * WITHOUT ANY WARRANTY. ALL WARRENTIES, EXPRESS OR IMPLIED ARE HEREBY
! * DISCLAMED. This includes but is not limited to warrenties of
! * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
!
! Madrid, 06-06-96
!
! */
!
! /*
! * Exit the program in an orderly way
! * Any open handles are closed,
! * All dynamic memory is freed
! * Error messages are printed out through stderr
! */
!
! void CleanUp(void)
! {
!
! if (Directory.Image)
! free(Directory.Image);
!
! if (Strings.Image)
! free(Strings.Image);
!
! if (ResourceHeads.Image)
! free(ResourceHeads.Image);
!
! if (RelocTable.pElems)
! free(RelocTable.pElems);
!
! FreeResourceInfo();
!
! if (RESview)
! UnmapViewOfFile(RESview);
! if (RESmapping)
! CloseHandle(RESmapping);
! if ((RESfile) && (RESfile != (HANDLE)INVALID_HANDLE_VALUE))
! CloseHandle(RESfile);
! if ((OBJFile) && (OBJFile != (HANDLE)INVALID_HANDLE_VALUE))
! CloseHandle(OBJFile);
! }
!
! void AppExit(int ErrorLevel,char *msg,...)
! {
! va_list args;
!
! va_start(args,msg);
! if ((ErrorLevel) && (msg))
! {
! fprintf(stderr,"%s :",ProgName);
! vfprintf(stderr,msg,args);
! }
! va_end(args);
!
! CleanUp();
! exit(ErrorLevel);
! }
!
! void CheckedWrite(HANDLE of,LPVOID buffer,DWORD size,char *sectmsg)
! {
! DWORD written;
!
! WriteFile(of,buffer,size,&written,NULL);
! if (written == size)
! return;
! else
! AppExit(1,"Error writing %s , disk full(?)\n",sectmsg);
! }
!
! void usage(char wrong)
! {
! printf("\nUsage: %s [-v] -i infile -o outfile\n\n"
! " -v verbose mode\n"
! " -i <file>.res RES32 file (input)\n"
! " -o <file>.o COFF object file (output)\n",ProgName);
!
! if (wrong)
! printf("\n -%c is not defined as a valid option \n",wrong);
!
! exit(-1);
! }
!
! int main(int argc,char **argv)
! {
! int arg,result;
! char *src,*dst;
! DWORD cbFileSize;
!
! ProgName = argv[0];
!
! if (argc == 1) {
! usage(0);
! exit(-1);
! }
!
! ResourceTime = (unsigned long)time(NULL);
!
! verbose = 0;
! src = dst = NULL;
!
! InitResourceInfo();
!
! for (arg = 1;arg < argc;arg++) {
! if (argv[arg][0] == '-')
! switch(argv[arg][1]) {
! case 'v':
! case 'V': verbose = 1;
! break;
!
! case 'i':
! case 'I': if (argv[arg][2])
! src = &argv[arg][2];
! else
! src = argv[++arg];
! break;
! case 'o':
! case 'O': if (argv[arg][2])
! dst = &argv[arg][2];
! else
! dst = argv[++arg];
! break;
!
! default : usage(argv[arg][1]);
! break;
! } else
! usage(0);
! }
!
! if (src == NULL) {
! usage(0);
! printf("No input file\n");
! }
!
! if (dst == NULL) {
! usage(0);
! printf("No output file\n");
! }
!
! if (verbose)
! printf("%s version %x.%02x\n\n",ProgName,__MAVERSION__,__MIVERSION__);
!
! /*
! * Now we enter a very orderly procedure:
! * 1.- Open the resource file
! * 2.- Create a maping for it
! * 3.- Map it into virtual memory
! * 4.- Check it is indeed a RES32 file
! * 5.- Sort the unnamed resources (v1.2)
! * 6.- Create the COFF object file
! *
! * Should any of these steps fail, the application is
! * exited in an orderly way
! */
!
! RESfile = CreateFileA(src, GENERIC_READ,
! FILE_SHARE_READ, NULL, OPEN_EXISTING,
! FILE_FLAG_SEQUENTIAL_SCAN, NULL);
!
! if ((!RESfile) || (RESfile == (HANDLE)INVALID_HANDLE_VALUE))
! AppExit(1,"Couldn't open '%s'\n",src);
!
! RESmapping = CreateFileMappingA(RESfile,NULL,PAGE_READONLY,0,0,NULL);
!
! if (RESmapping == NULL)
! AppExit(1,"Couldn't create file mapping for '%s'\n",src);
!
! RESview = MapViewOfFile(RESmapping, FILE_MAP_READ, 0, 0, 0);
!
! if (RESview == NULL)
! AppExit(1,"Couldn't map view of '%s'\n",src);
!
! cbFileSize = GetFileSize(RESfile, NULL);
!
! if ((cbFileSize == -1) && (GetLastError() != NO_ERROR))
! AppExit(1,"Error getting size of '%s'",src);
!
! RESviewEnd = (void *)((BYTE *)RESview + cbFileSize);
!
! if (!Check32bitResourceFile((PRESOURCEHEAD)RESview))
! AppExit(1,"Error in RES32 file format in '%s'\n",src);
!
! SortUnnamedResources();
!
! OBJFile = CreateFileA(dst,GENERIC_WRITE,0,NULL,
! CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL);
!
! if ((!OBJFile) || (OBJFile == (HANDLE)INVALID_HANDLE_VALUE))
! AppExit(1,"Couldn't create '%s'\n",dst);
!
! /*
! * Now we do the real processing. All functions have
! * autodocumenting names, just follow the code.
! * When all is done, we exit in an ordely way,
! * cleaning up any kind off mess we could have
! * stored in memory and flagging success (error level = 0)
! */
! MakeDirectoryTree();
! MakeCOFFSections(OBJFile);
! DumpDirectoryImage(OBJFile);
! DumpResources(OBJFile);
! DumpRelocations(OBJFile);
! DumpSymbols(OBJFile);
! CleanUp();
! return 0;
! }
!
Index: res2coff.h
===================================================================
RCS file: /cvsroot/mingw/utils/res2coff/res2coff.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** res2coff.h 14 May 2002 20:38:30 -0000 1.1
--- res2coff.h 26 May 2002 10:13:58 -0000 1.2
***************
*** 1,363 ****
! // RES2COFF.h
!
! #ifndef __RES2COFF_H__
! # define __RES2COFF_H__
!
! # define WIN32
!
! # include <windows.h>
! # include <stdio.h>
! # include <stdarg.h>
! # include <stdlib.h>
! # include <time.h>
!
! // This is an easy and clean way to define variables
! // accessible from all source files. One of them
! // defines __main__ and there's where they are
! // placed. The rest of the source files see them
! // as extern variables
!
! # ifdef __main__
! # define PUBVAR
! # else
! # define PUBVAR extern
! # endif
!
! /* *****************************************************************
! *
! * All structure definitions from this point on (paag)
! *
! * A 32 bit resource file header structure
! *
! */
!
! typedef struct {
! DWORD DataSize ;
! DWORD HeaderSize ;
! DWORD Type ;
! DWORD Name ;
! DWORD DataVersion ;
! WORD MemoryFlag ;
! WORD LanguageID ;
! WORD Version ;
! DWORD Characteristics ;
! } RESOURCEHEAD,*PRESOURCEHEAD;
!
!
! /*
! * This code added by Colin Peters <co...@bi...>.
! * November 15, 1996. You should ifdef this out if you have complete
! * Windows 32 API files which include these structure definitions.
! */
! struct _IMAGE_RESOURCE_DIRECTORY
! {
! DWORD Characteristics;
! DWORD TimeStamp;
! WORD MajorVersion;
! WORD MinorVersion;
! WORD NumberOfNamedEntries;
! WORD NumberOfIdEntries;
! };
!
! typedef struct _IMAGE_RESOURCE_DIRECTORY IMAGE_RESOURCE_DIRECTORY;
! typedef struct _IMAGE_RESOURCE_DIRECTORY* PIMAGE_RESOURCE_DIRECTORY;
!
! struct _IMAGE_RESOURCE_DIRECTORY_ENTRY
! {
! DWORD Name;
! DWORD OffsetToData;
! };
!
! typedef struct _IMAGE_RESOURCE_DIRECTORY_ENTRY
! IMAGE_RESOURCE_DIRECTORY_ENTRY;
! typedef struct _IMAGE_RESOURCE_DIRECTORY_ENTRY*
! PIMAGE_RESOURCE_DIRECTORY_ENTRY;
!
! struct _IMAGE_RESOURCE_DATA_ENTRY
! {
! DWORD OffsetToData;
! DWORD Size;
! DWORD CodePage;
! DWORD Reserved;
! };
!
! typedef struct _IMAGE_RESOURCE_DATA_ENTRY IMAGE_RESOURCE_DATA_ENTRY;
! typedef struct _IMAGE_RESOURCE_DATA_ENTRY* PIMAGE_RESOURCE_DATA_ENTRY;
!
! #define IMAGE_RESOURCE_NAME_IS_STRING 0x80000000
! #define IMAGE_RESOURCE_DATA_IS_DIRECTORY 0x80000000
!
! struct _IMAGE_RELOCATION
! {
! DWORD VirtualAddress;
! DWORD SymbolTableIndex;
! WORD Type;
! };
!
! typedef struct _IMAGE_RELOCATION IMAGE_RELOCATION;
! typedef struct _IMAGE_RELOCATION* PIMAGE_RELOCATION;
!
! /* Image relocation types (i386) */
! #define IMAGE_REL_I386_ABSOLUTE 0
! #define IMAGE_REL_I386_DIR16 1
! #define IMAGE_REL_I386_REL16 2
! #define IMAGE_REL_I386_DIR32 6
! #define IMAGE_REL_I386_DIR32NB 7
! #define IMAGE_REL_I386_SEG12 9
! #define IMAGE_REL_I386_SECTION 10
! #define IMAGE_REL_I386_SECREL 11
! #define IMAGE_REL_I386_REL32 14
!
! #define IMAGE_SIZEOF_RELOCATION 10;
!
! struct _IMAGE_SYMBOL
! {
! union
! {
! BYTE ShortName[8];
! struct
! {
! DWORD Short;
! DWORD Long;
! } Name;
! PBYTE LongName[2];
! } N;
! DWORD Value;
! SHORT SectionNumber;
! WORD Type;
! BYTE StorageClass;
! BYTE NumberOfAuxSymbols;
! };
!
! typedef struct _IMAGE_SYMBOL IMAGE_SYMBOL;
! typedef struct _IMAGE_SYMBOL* PIMAGE_SYMBOL;
!
! #define IMAGE_SIZEOF_SYMBOL 18
!
!
! typedef union _IMAGE_AUX_SYMBOL
! {
! struct /* Sym */
! {
! DWORD TagIndex;
!
! union /* Misc */
! {
! struct
! {
! WORD Linenumber;
! WORD Size;
! } LnSz;
! DWORD TotalSize;
! } Misc;
!
! union /* FcnAry */
! {
! struct
! {
! DWORD PointerToLinenumber;
! DWORD PointerToNextFunction;
! } Function;
!
! struct
! {
! WORD Dimension[4];
! } Array;
!
! } FcnAry;
!
! WORD TvIndex;
!
! } Sym;
!
! struct /* File */
! {
! BYTE Name[IMAGE_SIZEOF_SYMBOL];
! } File;
!
! struct /* Section */
! {
! DWORD Length;
! WORD NumberOfRelocations;
! WORD NumberOfLinenumbers;
! DWORD CheckSum;
! SHORT Number;
! BYTE Selection;
! } Section;
!
! } IMAGE_AUX_SYMBOL;
!
!
! struct _IMAGE_FILE_HEADER
! {
! WORD Machine;
! WORD NumberOfSections;
! DWORD TimeDateStamp;
! DWORD PointerToSymbolTable;
! DWORD NumberOfSymbols;
! WORD SizeOfOptionalHeader;
! WORD Characteristics;
! };
!
! typedef struct _IMAGE_FILE_HEADER IMAGE_FILE_HEADER;
! typedef struct _IMAGE_FILE_HEADER* PIMAGE_FILE_HEADER;
!
! #define IMAGE_SIZEOF_FILE_HEADER 20
!
! #define IMAGE_FILE_LINE_NUMS_STRIPPED 0x0004
! #define IMAGE_FILE_32BIT_MACHINE 0x0100
!
! #define IMAGE_FILE_MACHINE_I386 0x014c
!
!
! #define IMAGE_SIZEOF_SHORT_NAME 8
!
! struct _IMAGE_SECTION_HEADER
! {
! BYTE Name[IMAGE_SIZEOF_SHORT_NAME];
! union
! {
! DWORD PhysicalAddress;
! DWORD VirtualSize;
! } Misc;
! DWORD VirtualAddress;
! DWORD SizeOfRawData;
! DWORD PointerToRawData;
! DWORD PointerToRelocations;
! DWORD PointerToLinenumbers;
! WORD NumberOfRelocations;
! WORD NumberOfLinenumbers;
! DWORD Characteristics;
! };
!
! typedef struct _IMAGE_SECTION_HEADER IMAGE_SECTION_HEADER;
! typedef struct _IMAGE_SECTION_HEADER* PIMAGE_SECTION_HEADER;
!
! #define IMAGE_SIZEOF_SECTION_HEADER 40
!
! #define IMAGE_SCN_MEM_READ 0x40000000
! #define IMAGE_SCN_MEM_WRITE 0x80000000
!
! /*
! * End of modification by Colin Peters.
! */
!
!
! // This is the storage for the COFF image chunks
! // before they are transfered to the disk
!
! typedef struct {
! int Size ;
! void *Image ;
! } MemImage;
!
! // This holds the relocation and symbol tables
!
! typedef struct {
! int nElems;
! LPVOID pElems;
! } Table ;
!
! // Make a similar tree to the original one, but
! // taking into account that data are already in
! // memory.
!
!
! typedef struct {
! int count,named,unnamed;
! PRESOURCEHEAD *RName,*RID;
! } RESOURCEINFO;
!
!
! // ********************************************************
!
! #define MAX_TYPES 17
! #define CCHMAXPATH 260
!
! // Program version
!
! #define __MAVERSION__ 1
! #define __MIVERSION__ 0x20
!
! // Declared version in the resources
!
! #define DECLARED_MAV 4
! #define DECLARED_MIV 0
!
!
! /* **************************************************
! *
! * Function prototypes
! */
!
! # include "protos.h"
!
!
! /* **************************************************
! *
! * Variables
! */
!
! PUBVAR RESOURCEINFO ResInfo[MAX_TYPES];
!
! /* Option flags */
!
! PUBVAR int verbose;
!
! PUBVAR int ResourceTime;
! PUBVAR int ResourceSize;
! PUBVAR char *ProgName;
! //
!
! PUBVAR HANDLE OBJFile;
! PUBVAR HANDLE RESfile;
! PUBVAR HANDLE RESmapping;
! PUBVAR LPVOID RESview;
! PUBVAR LPVOID RESviewEnd;
!
! // *******************************************
! // Initialised variables
! //
!
! PUBVAR MemImage Directory
! #ifdef __main__
! = { 0,NULL }
! #endif
! ;
!
! PUBVAR MemImage Strings
! #ifdef __main__
! = { 0,NULL }
! #endif
! ;
!
! PUBVAR MemImage ResourceHeads
! #ifdef __main__
! = { 0,NULL }
! #endif
! ;
!
! PUBVAR Table RelocTable
! #ifdef __main__
! = { 0,NULL }
! #endif
! ;
!
! // Constants :
! // The predefined resource types
!
! PUBVAR char *szResourceTypes[]
! # ifdef __main__
! = {
! "???_0", "CURSOR", "BITMAP", "ICON",
! "MENU", "DIALOG", "STRING", "FONTDIR",
! "FONT", "ACCELERATORS", "RCDATA", "MESSAGETABLE",
! "GROUP_CURSOR", "???_13", "GROUP_ICON", "???_15",
! "VERSION"
! }
! # endif
! ;
!
! #endif // defined(__RES2COFF_H__)
!
!
--- 1,363 ----
! // RES2COFF.h
!
! #ifndef __RES2COFF_H__
! # define __RES2COFF_H__
!
! # define WIN32
!
! # include <windows.h>
! # include <stdio.h>
! # include <stdarg.h>
! # include <stdlib.h>
! # include <time.h>
!
! // This is an easy and clean way to define variables
! // accessible from all source files. One of them
! // defines __main__ and there's where they are
! // placed. The rest of the source files see them
! // as extern variables
!
! # ifdef __main__
! # define PUBVAR
! # else
! # define PUBVAR extern
! # endif
!
! /* *****************************************************************
! *
! * All structure definitions from this point on (paag)
! *
! * A 32 bit resource file header structure
! *
! */
!
! typedef struct {
! DWORD DataSize ;
! DWORD HeaderSize ;
! DWORD Type ;
! DWORD Name ;
! DWORD DataVersion ;
! WORD MemoryFlag ;
! WORD LanguageID ;
! WORD Version ;
! DWORD Characteristics ;
! } RESOURCEHEAD,*PRESOURCEHEAD;
!
!
! /*
! * This code added by Colin Peters <co...@bi...>.
! * November 15, 1996. You should ifdef this out if you have complete
! * Windows 32 API files which include these structure definitions.
! */
! struct _IMAGE_RESOURCE_DIRECTORY
! {
! DWORD Characteristics;
! DWORD TimeStamp;
! WORD MajorVersion;
! WORD MinorVersion;
! WORD NumberOfNamedEntries;
! WORD NumberOfIdEntries;
! };
!
! typedef struct _IMAGE_RESOURCE_DIRECTORY IMAGE_RESOURCE_DIRECTORY;
! typedef struct _IMAGE_RESOURCE_DIRECTORY* PIMAGE_RESOURCE_DIRECTORY;
!
! struct _IMAGE_RESOURCE_DIRECTORY_ENTRY
! {
! DWORD Name;
! DWORD OffsetToData;
! };
!
! typedef struct _IMAGE_RESOURCE_DIRECTORY_ENTRY
! IMAGE_RESOURCE_DIRECTORY_ENTRY;
! typedef struct _IMAGE_RESOURCE_DIRECTORY_ENTRY*
! PIMAGE_RESOURCE_DIRECTORY_ENTRY;
!
! struct _IMAGE_RESOURCE_DATA_ENTRY
! {
! DWORD OffsetToData;
! DWORD Size;
! DWORD CodePage;
! DWORD Reserved;
! };
!
! typedef struct _IMAGE_RESOURCE_DATA_ENTRY IMAGE_RESOURCE_DATA_ENTRY;
! typedef struct _IMAGE_RESOURCE_DATA_ENTRY* PIMAGE_RESOURCE_DATA_ENTRY;
!
! #define IMAGE_RESOURCE_NAME_IS_STRING 0x80000000
! #define IMAGE_RESOURCE_DATA_IS_DIRECTORY 0x80000000
!
! struct _IMAGE_RELOCATION
! {
! DWORD VirtualAddress;
! DWORD SymbolTableIndex;
! WORD Type;
! };
!
! typedef struct _IMAGE_RELOCATION IMAGE_RELOCATION;
! typedef struct _IMAGE_RELOCATION* PIMAGE_RELOCATION;
!
! /* Image relocation types (i386) */
! #define IMAGE_REL_I386_ABSOLUTE 0
! #define IMAGE_REL_I386_DIR16 1
! #define IMAGE_REL_I386_REL16 2
! #define IMAGE_REL_I386_DIR32 6
! #define IMAGE_REL_I386_DIR32NB 7
! #define IMAGE_REL_I386_SEG12 9
! #define IMAGE_REL_I386_SECTION 10
! #define IMAGE_REL_I386_SECREL 11
! #define IMAGE_REL_I386_REL32 14
!
! #define IMAGE_SIZEOF_RELOCATION 10;
!
! struct _IMAGE_SYMBOL
! {
! union
! {
! BYTE ShortName[8];
! struct
! {
! DWORD Short;
! DWORD Long;
! } Name;
! PBYTE LongName[2];
! } N;
! DWORD Value;
! SHORT SectionNumber;
! WORD Type;
! BYTE StorageClass;
! BYTE NumberOfAuxSymbols;
! };
!
! typedef struct _IMAGE_SYMBOL IMAGE_SYMBOL;
! typedef struct _IMAGE_SYMBOL* PIMAGE_SYMBOL;
!
! #define IMAGE_SIZEOF_SYMBOL 18
!
!
! typedef union _IMAGE_AUX_SYMBOL
! {
! struct /* Sym */
! {
! DWORD TagIndex;
!
! union /* Misc */
! {
! struct
! {
! WORD Linenumber;
! WORD Size;
! } LnSz;
! DWORD TotalSize;
! } Misc;
!
! union /* FcnAry */
! {
! struct
! {
! DWORD PointerToLinenumber;
! DWORD PointerToNextFunction;
! } Function;
!
! struct
! {
! WORD Dimension[4];
! } Array;
!
! } FcnAry;
!
! WORD TvIndex;
!
! } Sym;
!
! struct /* File */
! {
! BYTE Name[IMAGE_SIZEOF_SYMBOL];
! } File;
!
! struct /* Section */
! {
! DWORD Length;
! WORD NumberOfRelocations;
! WORD NumberOfLinenumbers;
! DWORD CheckSum;
! SHORT Number;
! BYTE Selection;
! } Section;
!
! } IMAGE_AUX_SYMBOL;
!
!
! struct _IMAGE_FILE_HEADER
! {
! WORD Machine;
! WORD NumberOfSections;
! DWORD TimeDateStamp;
! DWORD PointerToSymbolTable;
! DWORD NumberOfSymbols;
! WORD SizeOfOptionalHeader;
! WORD Characteristics;
! };
!
! typedef struct _IMAGE_FILE_HEADER IMAGE_FILE_HEADER;
! typedef struct _IMAGE_FILE_HEADER* PIMAGE_FILE_HEADER;
!
! #define IMAGE_SIZEOF_FILE_HEADER 20
!
! #define IMAGE_FILE_LINE_NUMS_STRIPPED 0x0004
! #define IMAGE_FILE_32BIT_MACHINE 0x0100
!
! #define IMAGE_FILE_MACHINE_I386 0x014c
!
!
! #define IMAGE_SIZEOF_SHORT_NAME 8
!
! struct _IMAGE_SECTION_HEADER
! {
! BYTE Name[IMAGE_SIZEOF_SHORT_NAME];
! union
! {
! DWORD PhysicalAddress;
! DWORD VirtualSize;
! } Misc;
! DWORD VirtualAddress;
! DWORD SizeOfRawData;
! DWORD PointerToRawData;
! DWORD PointerToRelocations;
! DWORD PointerToLinenumbers;
! WORD NumberOfRelocations;
! WORD NumberOfLinenumbers;
! DWORD Characteristics;
! };
!
! typedef struct _IMAGE_SECTION_HEADER IMAGE_SECTION_HEADER;
! typedef struct _IMAGE_SECTION_HEADER* PIMAGE_SECTION_HEADER;
!
! #define IMAGE_SIZEOF_SECTION_HEADER 40
!
! #define IMAGE_SCN_MEM_READ 0x40000000
! #define IMAGE_SCN_MEM_WRITE 0x80000000
!
! /*
! * End of modification by Colin Peters.
! */
!
!
! // This is the storage for the COFF image chunks
! // before they are transfered to the disk
!
! typedef struct {
! int Size ;
! void *Image ;
! } MemImage;
!
! // This holds the relocation and symbol tables
!
! typedef struct {
! int nElems;
! LPVOID pElems;
! } Table ;
!
! // Make a similar tree to the original one, but
! // taking into account that data are already in
! // memory.
!
!
! typedef struct {
! int count,named,unnamed;
! PRESOURCEHEAD *RName,*RID;
! } RESOURCEINFO;
!
!
! // ********************************************************
!
! #define MAX_TYPES 17
! #define CCHMAXPATH 260
!
! // Program version
!
! #define __MAVERSION__ 1
! #define __MIVERSION__ 0x20
!
! // Declared version in the resources
!
! #define DECLARED_MAV 4
! #define DECLARED_MIV 0
!
!
! /* **************************************************
! *
! * Function prototypes
! */
!
! # include "protos.h"
!
!
! /* **************************************************
! *
! * Variables
! */
!
! PUBVAR RESOURCEINFO ResInfo[MAX_TYPES];
!
! /* Option flags */
!
! PUBVAR int verbose;
!
! PUBVAR int ResourceTime;
! PUBVAR int ResourceSize;
! PUBVAR char *ProgName;
! //
!
! PUBVAR HANDLE OBJFile;
! PUBVAR HANDLE RESfile;
! PUBVAR HANDLE RESmapping;
! PUBVAR LPVOID RESview;
! PUBVAR LPVOID RESviewEnd;
!
! // *******************************************
! // Initialised variables
! //
!
! PUBVAR MemImage Directory
! #ifdef __main__
! = { 0,NULL }
! #endif
! ;
!
! PUBVAR MemImage Strings
! #ifdef __main__
! = { 0,NULL }
! #endif
! ;
!
! PUBVAR MemImage ResourceHeads
! #ifdef __main__
! = { 0,NULL }
! #endif
! ;
!
! PUBVAR Table RelocTable
! #ifdef __main__
! = { 0,NULL }
! #endif
! ;
!
! // Constants :
! // The predefined resource types
!
! PUBVAR char *szResourceTypes[]
! # ifdef __main__
! = {
! "???_0", "CURSOR", "BITMAP", "ICON",
! "MENU", "DIALOG", "STRING", "FONTDIR",
! "FONT", "ACCELERATORS", "RCDATA", "MESSAGETABLE",
! "GROUP_CURSOR", "???_13", "GROUP_ICON", "???_15",
! "VERSION"
! }
! # endif
! ;
!
! #endif // defined(__RES2COFF_H__)
!
!
Index: resimage.c
===================================================================
RCS file: /cvsroot/mingw/utils/res2coff/resimage.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** resimage.c 14 May 2002 20:38:30 -0000 1.1
--- resimage.c 26 May 2002 10:13:58 -0000 1.2
***************
*** 1,334 ****
! /*
! * RESimage.c
! *
! * This module is devoted to treating the .RES files
! */
!
! #include "res2coff.h"
!
! // Initialise the Resource Information Tree
!
! void InitResourceInfo(void)
! {
! int i;
!
! for (i=0;i<MAX_TYPES;i++) {
! ResInfo[i].count = ResInfo[i].named = ResInfo[i].unnamed = 0;
! ResInfo[i].RName = ResInfo[i].RID = NULL;
! }
! }
!
! // Free the Resource Information Tree
!
! void FreeResourceInfo(void)
! {
! int i;
!
! #ifdef NDEBUG
! if (verbose)
! printf("Resources found in file\n Named Unnamed Type\n");
! #endif
!
! for (i=0;i<MAX_TYPES;i++)
! {
! #ifdef NDEBUG
! if ((verbose) && (ResInfo[i].count))
! printf(" %4d %6d %s\n",
! ResInfo[i].named,
! ResInfo[i].unnamed,
! szResourceTypes[i]);
! #endif
! if (ResInfo[i].RName)
! free(ResInfo[i].RName);
! if (ResInfo[i].RID)
! free(ResInfo[i].RID);
! }
! }
!
! // Add a named resource of a given type to the Resource Information Tree
!
! int AddNamedResource(int type,PRESOURCEHEAD pNewResource)
! {
! PRESOURCEHEAD *pTemp;
! int result;
! int last = ResInfo[type].named;
!
! pTemp = (PRESOURCEHEAD *)realloc(ResInfo[type].RName,
! sizeof(PRESOURCEHEAD)*(last+1));
! ResInfo[type].RName = pTemp;
! if (result = (pTemp) ? TRUE : FALSE)
! {
! ResInfo[type].RName = pTemp;
! ResInfo[type].count++;
! ResInfo[type].named++;
! pTemp[last] = pNewResource;
! }
!
! return result;
! }
!
! // Add a numbered resource of a given type to the Resource Information Tree
!
! int AddIDResource(int type,PRESOURCEHEAD pNewResource)
! {
! PRESOURCEHEAD *pTemp;
! int result;
! int ...
[truncated message content] |
|
From: <in...@us...> - 2002-05-26 10:14:05
|
Update of /cvsroot/mingw/utils/pexports In directory usw-pr-cvs1:/tmp/cvs-serv2405/pexports Modified Files: README hparse.h pexports.h Log Message: Convert some text files to Unix format Index: README =================================================================== RCS file: /cvsroot/mingw/utils/pexports/README,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** README 10 Apr 2002 13:39:06 -0000 1.1 --- README 26 May 2002 10:13:58 -0000 1.2 *************** *** 1,83 **** ! PEXPORTS 0.43 README ! ============================================ ! ! Anders Norlander <ano...@he...> ! URL: hem2.passagen.se/anorland/ ! Hacked by Pau...@te... ! URL: http://www.is.lg.ua/~paul/devel/binutils.html ! ! ============================================ ! ! PEXPORTS is a program to extract exported symbols from a PE image ! (executable). It can perform a simple check on the size of the ! arguments of the exported functions, provided there is a header with ! prototypes for the functions. This is useful when you want the ! decorated function names for functions using the stdcall calling ! convention. GCC is used to do the preprocessing so it must be in your ! path. ! ! /*A binary for Cygwin b19 is in the cygbin directory.*/ ! A binary for mingw32 is in the /*mingw*/bin directory. ! ! Note that the mingw32 version uses ';' as path separator, ! while the cygwin version uses ':'. ! ! Command line options: ! ===================== ! -h <header> parse header ! -o print function ordinals ! -p <preprocessor> set preprocessor ! -v verbose mode ! ! Header files are searched for in the following directories: ! 1. Current directory ! 2. Directories in C_INCLUDE_PATH ! 3. Directories in CPLUS_INCLUDE_PATH ! 4. Directories in PATH ! ! NOTE: The header parser is *very* primitive, it only tries to find ! function prototypes and check the number of arguments a function ! expects. It is NOT a complete C parser, there are probably many ! conditions when it will fail (especially complex parameter types), ! although I it works fine for me. Please report bugs or send me a ! patch. ! ! CHANGES FROM 0.42: ! ================= ! * There were bug which led to wrong subcategorizing of symbols as ! code/data. I thought it was fixed in version on the site, but it turns ! out that almost year there was wrong version. I greatly apologize to ! everyone whom it cause problems and confusion. ! ! CHANGES FROM 0.41: ! ================= ! * Data/non-data symbols are now distinguished. ! ! CHANGES FROM 0.4: ! ================= ! * The header parser now accepts all kinds of parameters. ! ! CHANGES FROM 0.3: ! ================= ! * Function pointer parameters are now handled ! * Handling of function attributes improved ! * It is no longer always necessary to include windows.h for headers ! that required it but did not include it themselves. ! ! CHANGES FROM 0.2: ! ================= ! * Completely rewritten parser (the previous one was *very* bad). ! It is now possible to generate .DEF files for windows system ! dlls (kernel32,user32,gdi32,shell32 etc) ! * Enhanced symbol handling (symbols are sorted in a tree). ! ! CHANGES FROM 0.1: ! ================= ! * Fixed bug with unnamed parameters that are pointers. ! * Extra whitespace is no longer printed ! * Binary versions available for mingw32 and cygwin32 ! ! Pexports, Copyright (C) 1998 Anders Norlander ! This program has ABSOLUTELY NO WARRANTY; This is free software, and you are ! welcome to redistribute it under certain conditions; see COPYING ! for details. --- 1,83 ---- ! PEXPORTS 0.43 README ! ============================================ ! ! Anders Norlander <ano...@he...> ! URL: hem2.passagen.se/anorland/ ! Hacked by Pau...@te... ! URL: http://www.is.lg.ua/~paul/devel/binutils.html ! ! ============================================ ! ! PEXPORTS is a program to extract exported symbols from a PE image ! (executable). It can perform a simple check on the size of the ! arguments of the exported functions, provided there is a header with ! prototypes for the functions. This is useful when you want the ! decorated function names for functions using the stdcall calling ! convention. GCC is used to do the preprocessing so it must be in your ! path. ! ! /*A binary for Cygwin b19 is in the cygbin directory.*/ ! A binary for mingw32 is in the /*mingw*/bin directory. ! ! Note that the mingw32 version uses ';' as path separator, ! while the cygwin version uses ':'. ! ! Command line options: ! ===================== ! -h <header> parse header ! -o print function ordinals ! -p <preprocessor> set preprocessor ! -v verbose mode ! ! Header files are searched for in the following directories: ! 1. Current directory ! 2. Directories in C_INCLUDE_PATH ! 3. Directories in CPLUS_INCLUDE_PATH ! 4. Directories in PATH ! ! NOTE: The header parser is *very* primitive, it only tries to find ! function prototypes and check the number of arguments a function ! expects. It is NOT a complete C parser, there are probably many ! conditions when it will fail (especially complex parameter types), ! although I it works fine for me. Please report bugs or send me a ! patch. ! ! CHANGES FROM 0.42: ! ================= ! * There were bug which led to wrong subcategorizing of symbols as ! code/data. I thought it was fixed in version on the site, but it turns ! out that almost year there was wrong version. I greatly apologize to ! everyone whom it cause problems and confusion. ! ! CHANGES FROM 0.41: ! ================= ! * Data/non-data symbols are now distinguished. ! ! CHANGES FROM 0.4: ! ================= ! * The header parser now accepts all kinds of parameters. ! ! CHANGES FROM 0.3: ! ================= ! * Function pointer parameters are now handled ! * Handling of function attributes improved ! * It is no longer always necessary to include windows.h for headers ! that required it but did not include it themselves. ! ! CHANGES FROM 0.2: ! ================= ! * Completely rewritten parser (the previous one was *very* bad). ! It is now possible to generate .DEF files for windows system ! dlls (kernel32,user32,gdi32,shell32 etc) ! * Enhanced symbol handling (symbols are sorted in a tree). ! ! CHANGES FROM 0.1: ! ================= ! * Fixed bug with unnamed parameters that are pointers. ! * Extra whitespace is no longer printed ! * Binary versions available for mingw32 and cygwin32 ! ! Pexports, Copyright (C) 1998 Anders Norlander ! This program has ABSOLUTELY NO WARRANTY; This is free software, and you are ! welcome to redistribute it under certain conditions; see COPYING ! for details. Index: hparse.h =================================================================== RCS file: /cvsroot/mingw/utils/pexports/hparse.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** hparse.h 10 Apr 2002 13:39:06 -0000 1.1 --- hparse.h 26 May 2002 10:13:58 -0000 1.2 *************** *** 1,7 **** ! typedef union { ! char *s; ! } YYSTYPE; ! #define ID 258 ! ! ! extern YYSTYPE yylval; --- 1,7 ---- ! typedef union { ! char *s; ! } YYSTYPE; ! #define ID 258 ! ! ! extern YYSTYPE yylval; Index: pexports.h =================================================================== RCS file: /cvsroot/mingw/utils/pexports/pexports.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** pexports.h 10 Apr 2002 13:39:06 -0000 1.1 --- pexports.h 26 May 2002 10:13:58 -0000 1.2 *************** *** 1,163 **** ! /* ! pexports - a program to extract exported symbols from a Portable ! Executable (PE) file. ! ! Copyright (C) 1998 Anders Norlander ! ! pexports is distributed under the GNU General Public License and ! has absolutely NO WARRANTY. ! ! pexports will work only on intel machines. ! */ ! ! #ifndef _pexports_h ! #define _pexports_h ! ! #include <stdio.h> ! ! #include "str_tree.h" ! ! #define VER_MAJOR 0 ! #define VER_MINOR 43 ! ! /* These are needed */ ! typedef unsigned short WORD; ! typedef unsigned int DWORD; ! typedef unsigned char BYTE; ! typedef long LONG; ! typedef WORD *PWORD; ! typedef DWORD *PDWORD; ! ! /* PE structures */ ! typedef struct _IMAGE_DATA_DIRECTORY { ! DWORD VirtualAddress; ! DWORD Size; ! } IMAGE_DATA_DIRECTORY, *PIMAGE_DATA_DIRECTORY; ! ! typedef struct _IMAGE_FILE_HEADER { ! WORD Machine; ! WORD NumberOfSections; ! DWORD TimeDateStamp; ! DWORD PointerToSymbolTable; ! DWORD NumberOfSymbols; ! WORD SizeOfOptionalHeader; ! WORD Characteristics; ! } IMAGE_FILE_HEADER, *PIMAGE_FILE_HEADER; ! ! typedef struct _IMAGE_OPTIONAL_HEADER { ! WORD Magic; ! BYTE MajorLinkerVersion; ! BYTE MinorLinkerVersion; ! DWORD SizeOfCode; ! DWORD SizeOfInitializedData; ! DWORD SizeOfUninitializedData; ! DWORD AddressOfEntryPoint; ! DWORD BaseOfCode; ! DWORD BaseOfData; ! ! DWORD ImageBase; ! DWORD SectionAlignment; ! DWORD FileAlignment; ! WORD MajorOperatingSystemVersion; ! WORD MinorOperatingSystemVersion; ! WORD MajorImageVersion; ! WORD MinorImageVersion; ! WORD MajorSubsystemVersion; ! WORD MinorSubsystemVersion; ! DWORD Reserved1; ! DWORD SizeOfImage; ! DWORD SizeOfHeaders; ! DWORD CheckSum; ! WORD Subsystem; ! WORD DllCharacteristics; ! DWORD SizeOfStackReserve; ! DWORD SizeOfStackCommit; ! DWORD SizeOfHeapReserve; ! DWORD SizeOfHeapCommit; ! DWORD LoaderFlags; ! DWORD NumberOfRvaAndSizes; ! IMAGE_DATA_DIRECTORY DataDirectory[16]; ! } IMAGE_OPTIONAL_HEADER, *PIMAGE_OPTIONAL_HEADER; ! ! ! typedef struct _IMAGE_NT_HEADERS { ! char Signature[4]; ! IMAGE_FILE_HEADER FileHeader; ! IMAGE_OPTIONAL_HEADER OptionalHeader; ! } IMAGE_NT_HEADERS, *PIMAGE_NT_HEADERS; ! ! typedef struct _IMAGE_SECTION_HEADER { ! BYTE Name[8]; ! union { ! DWORD PhysicalAddress; ! DWORD VirtualSize; ! } Misc; ! DWORD VirtualAddress; ! DWORD SizeOfRawData; ! DWORD PointerToRawData; ! DWORD PointerToRelocations; ! DWORD PointerToLinenumbers; ! WORD NumberOfRelocations; ! WORD NumberOfLinenumbers; ! DWORD Characteristics; ! } IMAGE_SECTION_HEADER, *PIMAGE_SECTION_HEADER; ! ! typedef struct _IMAGE_EXPORT_DIRECTORY { ! DWORD Characteristics; ! DWORD TimeDateStamp; ! WORD MajorVersion; ! WORD MinorVersion; ! DWORD Name; ! DWORD Base; ! DWORD NumberOfFunctions; ! DWORD NumberOfNames; ! PDWORD *AddressOfFunctions; ! PDWORD *AddressOfNames; ! PWORD *AddressOfNameOrdinals; ! } IMAGE_EXPORT_DIRECTORY, *PIMAGE_EXPORT_DIRECTORY; ! ! typedef struct _IMAGE_DOS_HEADER { ! WORD e_magic; ! WORD e_cblp; ! WORD e_cp; ! WORD e_crlc; ! WORD e_cparhdr; ! WORD e_minalloc; ! WORD e_maxalloc; ! WORD e_ss; ! WORD e_sp; ! WORD e_csum; ! WORD e_ip; ! WORD e_cs; ! WORD e_lfarlc; ! WORD e_ovno; ! WORD e_res[4]; ! WORD e_oemid; ! WORD e_oeminfo; ! WORD e_res2[10]; ! LONG e_lfanew; ! } IMAGE_DOS_HEADER, *PIMAGE_DOS_HEADER; ! ! PIMAGE_SECTION_HEADER ! find_section(DWORD rva); ! ! PIMAGE_DOS_HEADER ! load_pe_image(const char *filename); ! ! DWORD ! rva_to_ptr(DWORD rva); ! ! void ! dump_exports(DWORD exports_rva); ! ! #define ADD_FUNCTION(nm,n) str_tree_add(&symbols, nm, (void*)n) ! extern str_tree *symbols; ! ! /* pe.h from bfd */ ! ! /* dirty! */ ! #define AOUTHDR int ! ! #include "pe.h" ! ! #endif /* _pexports_h */ --- 1,163 ---- ! /* ! pexports - a program to extract exported symbols from a Portable ! Executable (PE) file. ! ! Copyright (C) 1998 Anders Norlander ! ! pexports is distributed under the GNU General Public License and ! has absolutely NO WARRANTY. ! ! pexports will work only on intel machines. ! */ ! ! #ifndef _pexports_h ! #define _pexports_h ! ! #include <stdio.h> ! ! #include "str_tree.h" ! ! #define VER_MAJOR 0 ! #define VER_MINOR 43 ! ! /* These are needed */ ! typedef unsigned short WORD; ! typedef unsigned int DWORD; ! typedef unsigned char BYTE; ! typedef long LONG; ! typedef WORD *PWORD; ! typedef DWORD *PDWORD; ! ! /* PE structures */ ! typedef struct _IMAGE_DATA_DIRECTORY { ! DWORD VirtualAddress; ! DWORD Size; ! } IMAGE_DATA_DIRECTORY, *PIMAGE_DATA_DIRECTORY; ! ! typedef struct _IMAGE_FILE_HEADER { ! WORD Machine; ! WORD NumberOfSections; ! DWORD TimeDateStamp; ! DWORD PointerToSymbolTable; ! DWORD NumberOfSymbols; ! WORD SizeOfOptionalHeader; ! WORD Characteristics; ! } IMAGE_FILE_HEADER, *PIMAGE_FILE_HEADER; ! ! typedef struct _IMAGE_OPTIONAL_HEADER { ! WORD Magic; ! BYTE MajorLinkerVersion; ! BYTE MinorLinkerVersion; ! DWORD SizeOfCode; ! DWORD SizeOfInitializedData; ! DWORD SizeOfUninitializedData; ! DWORD AddressOfEntryPoint; ! DWORD BaseOfCode; ! DWORD BaseOfData; ! ! DWORD ImageBase; ! DWORD SectionAlignment; ! DWORD FileAlignment; ! WORD MajorOperatingSystemVersion; ! WORD MinorOperatingSystemVersion; ! WORD MajorImageVersion; ! WORD MinorImageVersion; ! WORD MajorSubsystemVersion; ! WORD MinorSubsystemVersion; ! DWORD Reserved1; ! DWORD SizeOfImage; ! DWORD SizeOfHeaders; ! DWORD CheckSum; ! WORD Subsystem; ! WORD DllCharacteristics; ! DWORD SizeOfStackReserve; ! DWORD SizeOfStackCommit; ! DWORD SizeOfHeapReserve; ! DWORD SizeOfHeapCommit; ! DWORD LoaderFlags; ! DWORD NumberOfRvaAndSizes; ! IMAGE_DATA_DIRECTORY DataDirectory[16]; ! } IMAGE_OPTIONAL_HEADER, *PIMAGE_OPTIONAL_HEADER; ! ! ! typedef struct _IMAGE_NT_HEADERS { ! char Signature[4]; ! IMAGE_FILE_HEADER FileHeader; ! IMAGE_OPTIONAL_HEADER OptionalHeader; ! } IMAGE_NT_HEADERS, *PIMAGE_NT_HEADERS; ! ! typedef struct _IMAGE_SECTION_HEADER { ! BYTE Name[8]; ! union { ! DWORD PhysicalAddress; ! DWORD VirtualSize; ! } Misc; ! DWORD VirtualAddress; ! DWORD SizeOfRawData; ! DWORD PointerToRawData; ! DWORD PointerToRelocations; ! DWORD PointerToLinenumbers; ! WORD NumberOfRelocations; ! WORD NumberOfLinenumbers; ! DWORD Characteristics; ! } IMAGE_SECTION_HEADER, *PIMAGE_SECTION_HEADER; ! ! typedef struct _IMAGE_EXPORT_DIRECTORY { ! DWORD Characteristics; ! DWORD TimeDateStamp; ! WORD MajorVersion; ! WORD MinorVersion; ! DWORD Name; ! DWORD Base; ! DWORD NumberOfFunctions; ! DWORD NumberOfNames; ! PDWORD *AddressOfFunctions; ! PDWORD *AddressOfNames; ! PWORD *AddressOfNameOrdinals; ! } IMAGE_EXPORT_DIRECTORY, *PIMAGE_EXPORT_DIRECTORY; ! ! typedef struct _IMAGE_DOS_HEADER { ! WORD e_magic; ! WORD e_cblp; ! WORD e_cp; ! WORD e_crlc; ! WORD e_cparhdr; ! WORD e_minalloc; ! WORD e_maxalloc; ! WORD e_ss; ! WORD e_sp; ! WORD e_csum; ! WORD e_ip; ! WORD e_cs; ! WORD e_lfarlc; ! WORD e_ovno; ! WORD e_res[4]; ! WORD e_oemid; ! WORD e_oeminfo; ! WORD e_res2[10]; ! LONG e_lfanew; ! } IMAGE_DOS_HEADER, *PIMAGE_DOS_HEADER; ! ! PIMAGE_SECTION_HEADER ! find_section(DWORD rva); ! ! PIMAGE_DOS_HEADER ! load_pe_image(const char *filename); ! ! DWORD ! rva_to_ptr(DWORD rva); ! ! void ! dump_exports(DWORD exports_rva); ! ! #define ADD_FUNCTION(nm,n) str_tree_add(&symbols, nm, (void*)n) ! extern str_tree *symbols; ! ! /* pe.h from bfd */ ! ! /* dirty! */ ! #define AOUTHDR int ! ! #include "pe.h" ! ! #endif /* _pexports_h */ |
|
From: <in...@us...> - 2002-05-26 10:14:04
|
Update of /cvsroot/mingw/utils/scripts
In directory usw-pr-cvs1:/tmp/cvs-serv2405/scripts
Modified Files:
a2dll.html a2dll.in static2dll_howto.txt
Log Message:
Convert some text files to Unix format
Index: a2dll.html
===================================================================
RCS file: /cvsroot/mingw/utils/scripts/a2dll.html,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** a2dll.html 10 Apr 2002 13:39:07 -0000 1.1
--- a2dll.html 26 May 2002 10:13:58 -0000 1.2
***************
*** 1,231 ****
! <html>
! <head>
! <title>
! a2dll: An utility (to help) to convert static library into Win32 DLL
! </title>
! </head>
! <body>
! <h1>
! a2dll: An utility (to help) to convert static library into Win32 DLL
! </h1>
! <h2>
! Synopsis
! </h2>
! <p>
! a2dll is shell script (see <a href="#requirements">requirements</a>) to
! automotize process of converting existing static libraries (produced
! by gnu-win32 tools, of course) into DLL. First of all, yes it's possible:
! if you have binary static distribution of some library (i.e. library
! itself and its headers), that's all you need to convert it to DLL and
! use in your programs. Read <a href="static2dll_howto.txt">HOWTO</a> for
! underlying magic. So, you may not waste time if you need DLL: just
! grab existing static distribution and convert. Also, you may use it to
! build Win32 DLL of your library. Also, until GNU libtool will allow
! seamless building of Win32 DLLs, you may build static lib (what
! libtool of course supports) and then convert it to DLL.
! <blockquote>
! <tt>
! a2dll <static_lib> [-o <dll_name>] [<linker_flags>] [--relink]
! </tt>
! </blockquote>
! where:
! <dl>
! <dt>
! <tt><static_lib></tt>
! </dt>
! <dd>
! Static library you want to convert
! </dd>
! <dt>
! <tt>-o <dll_name></tt>
! </dt>
! <dd>
! Name of resulting dll. If not given, three first chars of input
! name are stripped and <tt>.a</tt> suffix replaced with <tt>.dll</tt> .
! So, from '<tt>libfoo.a</tt>' you'll get '<tt>foo.dll</tt>'.
! </dd>
! <dt>
! <tt><linker_flags></tt>
! </dt>
! <dd>
! Linker flags:
! <ul>
! <li>Use '<tt>-s</tt>' to get library without debugging symbols and information.
! <li>Use '<tt>--driver-name=<name></tt>' to link library with specified
! linker (well, compiler, to be precise). For example, for C++ library use
! <tt>--driver-name=g++</tt> .
! <li>You should list all libraries on which your library depends with
! <tt>-l</tt> switches and directories they are reside in with <tt>-L</tt>
! switches. For example, if your library uses PCRE library you just built and
! not yet installed, use something like <tt>-L../pcre -lpcre</tt>
! </ul>
! </dd>
! <dt>
! <tt>--relink</tt>
! </dt>
! <dd>
! Skip exploding library stage (see below). Use this flag to continue
! process after some error occured.
! </dd>
! </dl>
! </p>
!
! <h2>
! Performing
! </h2>
!
! <p>
! a2dll works in following way:
! <ol>
! <li>If you did not specify <tt>--relink</tt> option,
! explodes source library under newly-created <tt>.dll</tt> subdirectory.
!
! <li>Links all resulting objects into DLL with exporting all non-static
! symbols. On this stage, link errors
! (such as underfined symbols) may occur. In such case, a2dll terminates
! and all linker messages are available in '<tt>ld.err</tt>' file. You
! should correct errors (mostly by finding out additional
! dependecies, but sometimes by deleting 'superfluos' objects under .dll)
! and re-run a2dll with all the options you gave it before,
! plus new dependencies, plus <tt>--relink</tt> flag. You may need to
! repeat this several times.
!
! <li>Renames original static library with suffix <tt>.static</tt> .
!
! <li>Creates import library for produced DLL with the name of original
! static library.
!
! <li>Check whether DLL exports data symbols. If no, congratulations,
! you've done. However, if some present, it lists all of them in file
! '<tt><dll_name>.data</tt>' . Presense of such symbols generally
! means that you should patch library's headers to mark those symbols
! as dll-imported. But don't hurry with that, first, do following:
! <ol>
! <li>Look into <tt><dll_name>.data</tt> file. If all what you see
! is something like '<tt>internal_counter_of_bogons</tt>' or
! '<tt>_ksdauso</tt>', don't worry - those symbols are hardly part of
! external interface of the library.
! <li>If all you need is to link your application against that
! library, try it. If it succeeds, congratulation.
! <li>Only if above is failed, or you are going to distribute produced
! library, so you need to be sure that everything is ok, proceed with
! marking symbols in headers. Read <a href="static2dll_howto.txt">Static2DLL
! HOWTO</a> for more information on suggested ways of doing this. Use
! '<tt>grep -f <tt><dll_name>.data</tt> *.h</tt>' command to find
! out where offending symbols defined in library headers.
! </ol>
! </ol>
! </p>
!
! <h2>
! Examples
! </h2>
! <p>
! Since converting static libraries to DLLs is not fully automated and
! formal process, some experience with it is required. Learing
! by example is known to be one of the efficient way of communicating
! experince, so I would like to provide some realistic examples of
! converting statics to DLLs with the help of a2dll.
! </p>
!
! <h3>
! Zlib
! </h3>
! <p>
! Build libz.a . Now, run '<tt>a2dll libz.a</tt>'. It builds cleanly,
! but warns us about data symbols. Let's look at them:
! <blockquote>
! <pre>
! inflate_mask
! z_errmsg
! </pre>
! </blockquote>
! What they could be. The first one is probably some internal variable,
! while second is probably array of error messages. As we know, zlib
! provides functional way of getting error messages, something like. So
! our hypothesis is that job's done. Let's prove it:
! '<tt>grep -f z.dll.data zlib.h</tt>'. Yes, we're right: no mentioning
! of those symbols in interface header file.
! </p>
!
! <h3>
! libstdc++
! </h3>
! <p>
! I've got an idea to DLLize libstdc++ coming with my mingw32 distribution.
! '<tt>a2dll "libstdc++.a"</tt>'. Note that we don't use
! <tt>--driver-name=g++</tt> - that option need to be used when we link
! something <i>against</i> libstdc++ . But when we link libstdc++
! <i>itself</i>, we need libc (whatever it is in mingw32), nothing else.
! But, process aborts due to linker errors. <tt>ld.err</tt> tells us:
! <blockquote>
! <pre>
! strerror.o(.text+0x303): undefined reference to `sys_nerr'
! vfork.o(.text+0x7): undefined reference to `fork'
! waitpid.o(.text+0x15): undefined reference to `wait'
! </pre>
! </blockquote>
! Well, strerror, vfork, waitpid are libc functions, what they do in
! libstdc++? Probably, stubs, delete them and
! '<tt>a2dll "libstdc++.a" --relink</tt>'. Of course,
! <tt>stdc++.dll.data</tt> is here. Looking into it, I may tell you
! that everything starting with '<tt>__ti<digit></tt>' is RTTI
! internal data structures and everything starting with
! '<tt>_vt$</tt>' is virtual tables (use c++filt if in doubt),
! you can leave them alone.
! (If so, why I don't filter them? Because "you can leave them alone"
! is hypothesis for now, I haven't linked too much C++ libraries to
! be sure). From the rest, there's stuff starting
! with '<tt>_IO_</tt>'. That's probably some internal variables, let's
! don't do anything about them, unless we'll be forced to. Than, as
! c++filt shows, there're some static members of templated classes. Darkness.
! Forget for now. Than, there's '<tt>io_defs__</tt>'. Does your C++ application
! reference something like that? Mine not. So, what is left? Our four
! happy friends, <tt>cin, cout, cerr,</tt> and <tt>clog</tt>. Do mark them as
! __declspec(dllimport) in <tt>iostream.h</tt>.
! </p>
!
! <h3>
! Some C++ library
! </h3>
! <p>
! Suppose we have following file:
! <pre>
! #include <iostream.h>
!
! void foo()
! {
! cout<<"hi!"<<endl;
! }
! </pre>
! and want to turn it into DLL. Create static liba.a from it. Now,
! '<tt>a2dll liba.a --driver-name=g++</tt>'. Well, our DLL contains
! single function, why then it complains about data symbols? Oh, it's
! those stupid RTTI structures. Next time, compile with <tt>-fno-rtti</tt> unless
! you really need it, ok? Ditto for <tt>-fno-exceptions</tt> .
! </p>
!
! <h2>
! <a name="requirements">
! Requirements
! </h2>
! <p>
! a2dll requires POSIX shell (<tt>sh</tt>) to run. It is developed and
! tested with <tt>ash</tt> from
! <a href="http://pw32.sourceforge.net">PW32</a> distribution. Additionally,
! a2dll requires following utilities to perform its tasks:
! <ul>
! <li>GNU fileutils: mkdir, mv, rm
! <li>GNU textutils: wc
! <li>GNU grep
! <li>GNU awk
! <li>GNU binutils: dllwrap, dlltool (and the rest of binutils and gcc, of course)
! <li>pexports, an utility to dump symbols exported by dll. You'll need a
! version 0.43 or above, capable of distinguishing between code and data symbols, as one
! from <a href="http://www.is.lg.ua/~paul/devel/binutils.html">here</a>.
! </ul>
! </p>
! <hr noshade>
! <i><a href="mailto:Pau...@te...">Paul Sokolovsky</a></i>
! </body>
! </html>
--- 1,231 ----
! <html>
! <head>
! <title>
! a2dll: An utility (to help) to convert static library into Win32 DLL
! </title>
! </head>
! <body>
! <h1>
! a2dll: An utility (to help) to convert static library into Win32 DLL
! </h1>
! <h2>
! Synopsis
! </h2>
! <p>
! a2dll is shell script (see <a href="#requirements">requirements</a>) to
! automotize process of converting existing static libraries (produced
! by gnu-win32 tools, of course) into DLL. First of all, yes it's possible:
! if you have binary static distribution of some library (i.e. library
! itself and its headers), that's all you need to convert it to DLL and
! use in your programs. Read <a href="static2dll_howto.txt">HOWTO</a> for
! underlying magic. So, you may not waste time if you need DLL: just
! grab existing static distribution and convert. Also, you may use it to
! build Win32 DLL of your library. Also, until GNU libtool will allow
! seamless building of Win32 DLLs, you may build static lib (what
! libtool of course supports) and then convert it to DLL.
! <blockquote>
! <tt>
! a2dll <static_lib> [-o <dll_name>] [<linker_flags>] [--relink]
! </tt>
! </blockquote>
! where:
! <dl>
! <dt>
! <tt><static_lib></tt>
! </dt>
! <dd>
! Static library you want to convert
! </dd>
! <dt>
! <tt>-o <dll_name></tt>
! </dt>
! <dd>
! Name of resulting dll. If not given, three first chars of input
! name are stripped and <tt>.a</tt> suffix replaced with <tt>.dll</tt> .
! So, from '<tt>libfoo.a</tt>' you'll get '<tt>foo.dll</tt>'.
! </dd>
! <dt>
! <tt><linker_flags></tt>
! </dt>
! <dd>
! Linker flags:
! <ul>
! <li>Use '<tt>-s</tt>' to get library without debugging symbols and information.
! <li>Use '<tt>--driver-name=<name></tt>' to link library with specified
! linker (well, compiler, to be precise). For example, for C++ library use
! <tt>--driver-name=g++</tt> .
! <li>You should list all libraries on which your library depends with
! <tt>-l</tt> switches and directories they are reside in with <tt>-L</tt>
! switches. For example, if your library uses PCRE library you just built and
! not yet installed, use something like <tt>-L../pcre -lpcre</tt>
! </ul>
! </dd>
! <dt>
! <tt>--relink</tt>
! </dt>
! <dd>
! Skip exploding library stage (see below). Use this flag to continue
! process after some error occured.
! </dd>
! </dl>
! </p>
!
! <h2>
! Performing
! </h2>
!
! <p>
! a2dll works in following way:
! <ol>
! <li>If you did not specify <tt>--relink</tt> option,
! explodes source library under newly-created <tt>.dll</tt> subdirectory.
!
! <li>Links all resulting objects into DLL with exporting all non-static
! symbols. On this stage, link errors
! (such as underfined symbols) may occur. In such case, a2dll terminates
! and all linker messages are available in '<tt>ld.err</tt>' file. You
! should correct errors (mostly by finding out additional
! dependecies, but sometimes by deleting 'superfluos' objects under .dll)
! and re-run a2dll with all the options you gave it before,
! plus new dependencies, plus <tt>--relink</tt> flag. You may need to
! repeat this several times.
!
! <li>Renames original static library with suffix <tt>.static</tt> .
!
! <li>Creates import library for produced DLL with the name of original
! static library.
!
! <li>Check whether DLL exports data symbols. If no, congratulations,
! you've done. However, if some present, it lists all of them in file
! '<tt><dll_name>.data</tt>' . Presense of such symbols generally
! means that you should patch library's headers to mark those symbols
! as dll-imported. But don't hurry with that, first, do following:
! <ol>
! <li>Look into <tt><dll_name>.data</tt> file. If all what you see
! is something like '<tt>internal_counter_of_bogons</tt>' or
! '<tt>_ksdauso</tt>', don't worry - those symbols are hardly part of
! external interface of the library.
! <li>If all you need is to link your application against that
! library, try it. If it succeeds, congratulation.
! <li>Only if above is failed, or you are going to distribute produced
! library, so you need to be sure that everything is ok, proceed with
! marking symbols in headers. Read <a href="static2dll_howto.txt">Static2DLL
! HOWTO</a> for more information on suggested ways of doing this. Use
! '<tt>grep -f <tt><dll_name>.data</tt> *.h</tt>' command to find
! out where offending symbols defined in library headers.
! </ol>
! </ol>
! </p>
!
! <h2>
! Examples
! </h2>
! <p>
! Since converting static libraries to DLLs is not fully automated and
! formal process, some experience with it is required. Learing
! by example is known to be one of the efficient way of communicating
! experince, so I would like to provide some realistic examples of
! converting statics to DLLs with the help of a2dll.
! </p>
!
! <h3>
! Zlib
! </h3>
! <p>
! Build libz.a . Now, run '<tt>a2dll libz.a</tt>'. It builds cleanly,
! but warns us about data symbols. Let's look at them:
! <blockquote>
! <pre>
! inflate_mask
! z_errmsg
! </pre>
! </blockquote>
! What they could be. The first one is probably some internal variable,
! while second is probably array of error messages. As we know, zlib
! provides functional way of getting error messages, something like. So
! our hypothesis is that job's done. Let's prove it:
! '<tt>grep -f z.dll.data zlib.h</tt>'. Yes, we're right: no mentioning
! of those symbols in interface header file.
! </p>
!
! <h3>
! libstdc++
! </h3>
! <p>
! I've got an idea to DLLize libstdc++ coming with my mingw32 distribution.
! '<tt>a2dll "libstdc++.a"</tt>'. Note that we don't use
! <tt>--driver-name=g++</tt> - that option need to be used when we link
! something <i>against</i> libstdc++ . But when we link libstdc++
! <i>itself</i>, we need libc (whatever it is in mingw32), nothing else.
! But, process aborts due to linker errors. <tt>ld.err</tt> tells us:
! <blockquote>
! <pre>
! strerror.o(.text+0x303): undefined reference to `sys_nerr'
! vfork.o(.text+0x7): undefined reference to `fork'
! waitpid.o(.text+0x15): undefined reference to `wait'
! </pre>
! </blockquote>
! Well, strerror, vfork, waitpid are libc functions, what they do in
! libstdc++? Probably, stubs, delete them and
! '<tt>a2dll "libstdc++.a" --relink</tt>'. Of course,
! <tt>stdc++.dll.data</tt> is here. Looking into it, I may tell you
! that everything starting with '<tt>__ti<digit></tt>' is RTTI
! internal data structures and everything starting with
! '<tt>_vt$</tt>' is virtual tables (use c++filt if in doubt),
! you can leave them alone.
! (If so, why I don't filter them? Because "you can leave them alone"
! is hypothesis for now, I haven't linked too much C++ libraries to
! be sure). From the rest, there's stuff starting
! with '<tt>_IO_</tt>'. That's probably some internal variables, let's
! don't do anything about them, unless we'll be forced to. Than, as
! c++filt shows, there're some static members of templated classes. Darkness.
! Forget for now. Than, there's '<tt>io_defs__</tt>'. Does your C++ application
! reference something like that? Mine not. So, what is left? Our four
! happy friends, <tt>cin, cout, cerr,</tt> and <tt>clog</tt>. Do mark them as
! __declspec(dllimport) in <tt>iostream.h</tt>.
! </p>
!
! <h3>
! Some C++ library
! </h3>
! <p>
! Suppose we have following file:
! <pre>
! #include <iostream.h>
!
! void foo()
! {
! cout<<"hi!"<<endl;
! }
! </pre>
! and want to turn it into DLL. Create static liba.a from it. Now,
! '<tt>a2dll liba.a --driver-name=g++</tt>'. Well, our DLL contains
! single function, why then it complains about data symbols? Oh, it's
! those stupid RTTI structures. Next time, compile with <tt>-fno-rtti</tt> unless
! you really need it, ok? Ditto for <tt>-fno-exceptions</tt> .
! </p>
!
! <h2>
! <a name="requirements">
! Requirements
! </h2>
! <p>
! a2dll requires POSIX shell (<tt>sh</tt>) to run. It is developed and
! tested with <tt>ash</tt> from
! <a href="http://pw32.sourceforge.net">PW32</a> distribution. Additionally,
! a2dll requires following utilities to perform its tasks:
! <ul>
! <li>GNU fileutils: mkdir, mv, rm
! <li>GNU textutils: wc
! <li>GNU grep
! <li>GNU awk
! <li>GNU binutils: dllwrap, dlltool (and the rest of binutils and gcc, of course)
! <li>pexports, an utility to dump symbols exported by dll. You'll need a
! version 0.43 or above, capable of distinguishing between code and data symbols, as one
! from <a href="http://www.is.lg.ua/~paul/devel/binutils.html">here</a>.
! </ul>
! </p>
! <hr noshade>
! <i><a href="mailto:Pau...@te...">Paul Sokolovsky</a></i>
! </body>
! </html>
Index: a2dll.in
===================================================================
RCS file: /cvsroot/mingw/utils/scripts/a2dll.in,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** a2dll.in 10 Apr 2002 13:39:07 -0000 1.1
--- a2dll.in 26 May 2002 10:13:58 -0000 1.2
***************
*** 1,104 ****
! #!/bin/sh
!
! # This is a2dll 1.0
! # (c)1999-2000 Paul Sokolovsky
! # a2dll is distrubuted under GNU General Public License, see http://www.gnu.org
!
!
! usage() {
! echo 'a2dll 1.0: convert static library into win32 dll'
! echo ' by <Pau...@te...>'
! echo 'Usage: a2dll <staticlib> [-o <dllname>] [linker commands:-L,-l,-s] [--relink]'
! exit 0
! }
!
!
! cmdline=$@
!
! while test $# -ge 1
! do
! case "$1" in
! -\? | -h* | --h*) usage;;
! -o ) out="$2"; shift; shift;;
! --relink) relink=1; shift;;
! -* ) libs="$libs $1"; shift;;
! *) in=$1; shift;;
! esac
! done
!
! if [ "$in" = "" ]
! then
! usage
! fi
!
! base=`basename $in .a`
!
! if [ "$out" = "" ]
! then
! out=`awk -v n=$base 'BEGIN {print substr(n,4); exit;}'`.dll
! fi
!
! if [ "$relink" != "1" ]
! then
! rm -f .dll/*
! /usr/bin/mkdir -p .dll
! cd .dll
! ar x ../$in
! else
! cd .dll
! fi
!
! echo Creating shared library \'$out\'
!
! dllwrap --export-all -o ../$out `ls` $libs >../ld.err 2>&1
!
! cd ..
! if [ `wc ld.err|awk ' {print $1}' ` -gt 2 ]
! then
! echo Linking error, consult file \'ld.err\', correct errors, and run
! echo \'$0 $cmdline --relink\'
! exit 1
! else
! # cleanup
!
! rm -f ld.err
! rm -f .dll/*
! /usr/bin/rmdir .dll
!
! # create .def
! # we use pexports on dll instead of dlltool on objects for this,
! # because it's:
! # 1. faster
! # 2. I just saw that dlltool lies about assembly-sourced files, it
! # lists their symbols as data
!
! pexports $out >$base.def
!
! # create import library
!
! mv $in $in.static
! dlltool --dllname $out --def $base.def --output-lib $in
!
! # finally, we check whether dll exports data symbols
! # if yes, we suggest user on steps to perform
!
! pexports $out | awk '/DATA/ { print $1}' >$out.data
! if test -s $out.data
! then
! echo
! echo Shared library exports data symbols, they are listed \
! in \'$out.data\'. For using them in client application, you should mark \
! them as __declspec\(dllimport\) in library headers. You can quickly \
! find places where these data symbols declared by issuing
! echo
! echo " grep -f $out.data *.h"
! echo
! echo in library header directory. Also note that this step is optional, you can postpone \
! it until you\'ll get during linking unresolved symbol _imp__\<something\>, where \
! \<something\> is one of the symbols listed in $out.data. Read documentation \
! \(static2dll_howto.txt\) for more information.
! else
! rm $out.data
! fi
! rm $base.def
! fi
--- 1,104 ----
! #!/bin/sh
!
! # This is a2dll 1.0
! # (c)1999-2000 Paul Sokolovsky
! # a2dll is distrubuted under GNU General Public License, see http://www.gnu.org
!
!
! usage() {
! echo 'a2dll 1.0: convert static library into win32 dll'
! echo ' by <Pau...@te...>'
! echo 'Usage: a2dll <staticlib> [-o <dllname>] [linker commands:-L,-l,-s] [--relink]'
! exit 0
! }
!
!
! cmdline=$@
!
! while test $# -ge 1
! do
! case "$1" in
! -\? | -h* | --h*) usage;;
! -o ) out="$2"; shift; shift;;
! --relink) relink=1; shift;;
! -* ) libs="$libs $1"; shift;;
! *) in=$1; shift;;
! esac
! done
!
! if [ "$in" = "" ]
! then
! usage
! fi
!
! base=`basename $in .a`
!
! if [ "$out" = "" ]
! then
! out=`awk -v n=$base 'BEGIN {print substr(n,4); exit;}'`.dll
! fi
!
! if [ "$relink" != "1" ]
! then
! rm -f .dll/*
! /usr/bin/mkdir -p .dll
! cd .dll
! ar x ../$in
! else
! cd .dll
! fi
!
! echo Creating shared library \'$out\'
!
! dllwrap --export-all -o ../$out `ls` $libs >../ld.err 2>&1
!
! cd ..
! if [ `wc ld.err|awk ' {print $1}' ` -gt 2 ]
! then
! echo Linking error, consult file \'ld.err\', correct errors, and run
! echo \'$0 $cmdline --relink\'
! exit 1
! else
! # cleanup
!
! rm -f ld.err
! rm -f .dll/*
! /usr/bin/rmdir .dll
!
! # create .def
! # we use pexports on dll instead of dlltool on objects for this,
! # because it's:
! # 1. faster
! # 2. I just saw that dlltool lies about assembly-sourced files, it
! # lists their symbols as data
!
! pexports $out >$base.def
!
! # create import library
!
! mv $in $in.static
! dlltool --dllname $out --def $base.def --output-lib $in
!
! # finally, we check whether dll exports data symbols
! # if yes, we suggest user on steps to perform
!
! pexports $out | awk '/DATA/ { print $1}' >$out.data
! if test -s $out.data
! then
! echo
! echo Shared library exports data symbols, they are listed \
! in \'$out.data\'. For using them in client application, you should mark \
! them as __declspec\(dllimport\) in library headers. You can quickly \
! find places where these data symbols declared by issuing
! echo
! echo " grep -f $out.data *.h"
! echo
! echo in library header directory. Also note that this step is optional, you can postpone \
! it until you\'ll get during linking unresolved symbol _imp__\<something\>, where \
! \<something\> is one of the symbols listed in $out.data. Read documentation \
! \(static2dll_howto.txt\) for more information.
! else
! rm $out.data
! fi
! rm $base.def
! fi
Index: static2dll_howto.txt
===================================================================
RCS file: /cvsroot/mingw/utils/scripts/static2dll_howto.txt,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** static2dll_howto.txt 10 Apr 2002 13:39:07 -0000 1.1
--- static2dll_howto.txt 26 May 2002 10:13:58 -0000 1.2
***************
*** 1,141 ****
! How to build Win32 Dynamic-Loading Library (DLL) from existing static library
! -----------------------------------------------------------------------------
!
! -------
! NOTE: To perform steps below, you'll need contemparary dlltool, for
! example from Mumit Khan's gcc-2.95.2 packages.
! -------
!
!
! This document describes step-by-step procedure of building Win32 DLL from
! static library. It suitable for both your own and third-party (i.e. ones
! which you know, and would like to, little about) libs. However, for your
! own libraries you may adopt more handy and adequate method (exporting all
! symbols, as done here, may be not the best solution). However, procedure
! given here describes easiest and fastest way if what you want is just
! create proper DLL and forget about it. This documets assumes that
! you have, or will, read documentation for Mumit Khan's dllwrappers
! tools (dllwrap & dlltool utilities).
!
! Before proceeding with description of process, some notes about
! distinction of DLLs and usual *nix-style shared libraries (.so, referred
! as SO below) (read also if you don't have experience with .so):
!
! [Once again note that there's a big gap between abstract information
! below and specific practical steps which follow; if you want to fill
! that gap, read standard documentation.]
!
!
! Theory
! ------
!
! 1. Usually, compilation of objects for shared libraries requires different
! set of compiler options comparing to static counterparts. For example,
! many systems require -fpic flag to generate position-independent code.
! However, for Win32, both static libs and DLLs are created from the same
! set of objects. Despite this little advantage, DLLs have following big
! disadvantage:
!
! 2. Once have been created, shared libraries require no additional fuzz
! for usage. When so-using executable is loaded, every reference to
! so-symbol gets fixed up to point directly to SO. Win32 has different
! system: every executable importing DLL has special section, .idata, to hold
! pointers to imported symbols. During loading, OS loader fills this section
! with actual info. And application is supposed, when needed DLL-symbol, first
! lookup its pointer in .idata, and only then have access by that pointer,
! As you see, for DLL-imported symbols, additional level of indirection is
! required. This stems probably from dark times of real-mode 16-bit Windows,
! working on 8086 processor lacking virtual memory. Having all import-related
! stuff in one single place facilated runtime relocation, which was needed
! to effictively manage memory there. So or other, but it is that way.
! So, as you see, special compiler support required to compile client of
! DLL (note strange symmetry - *nix require special support to compile library,
! while Win32 - to compile client. Former is better, I agree).
!
! 3. As was said before, with SO you use library just as you would static
! version. This is not so for Win32. Win32 DLL is self-contained executable,
! not supposed to be linked against. Instead, client is linked with special
! auxilary library, called 'import library' or 'implib'. Implib contains
! information to properly layout .idata section to be filled in by OS loader
! with information about DLL.
!
!
! Building DLL from existing static library
! -----------------------------------------
!
! We assume that you already build static lib, which we will call 'libfoo.a'.
! However, building yourself is not requirement, to perform these instructions,
! you don't needed sources of library - only library itself and its headers.
!
! 1. Fisrt step would be to create export definition file (or just def). You
! can do this directly from library:
!
! dlltool libfoo.a --export-all-symbols --output-def foo.def
!
! 2. Now, we can create DLL itself. This may be done by two ways: 1) link
! dummy file referencing each symbol in libfoo.a (created by script acting on
! output from 'nm libfoo.a') against libfoo.a (so, each foo's object for
! sure will be in foo.dll) or 2) exploding library and linking all its objects
! together. I consider second way cleaner and show it:
!
! mkdir tmp
! cp libfoo.a tmp/
! cd tmp
! ar x libfoo.a
! dllwrap *.o --def ../foo.def -o ../foo.dll [usual -l libraries here]
! cd ..
!
! 3. Let's create implib. If you want totally transparent transition from
! static to DLL, call it 'libfoo.a'. However, if you want to keep destinction,
! 'libfoo.dll.a' is good:
!
! dlltool --def foo.def --ouput-lib libfoo.dll.a
!
! 4. Now grep foo.def for entries containing 'DATA'. If there's none -
! congratulations, your library uses functional-only interface and you've done.
! Else, most unpleasant work left - patch headers to include dllimport tag.
!
! If you want to do it once-and-for-all (you should), do following:
!
! a) make something like 'dl_import.h' and put there:
! -----
! #if !defined(STATIC) && defined(_WIN32)
! #define _DL_IMPORT __delcspec(dllimport)
! #else
! #define _DL_IMPORT
! #endif
! -----
! , if you want to use DLL by default (note that you will need to compile
! library itself with STATIC defined), or
! -----
! #if defined(DLL) && defined(_WIN32)
! #define _DL_IMPORT __delcspec(dllimport)
! #else
! #define _DL_IMPORT
! #endif
! -----
! , if you want to include -DDLL each time you compile DLL client.
!
! b) for each def symbol having DATA attribute, find header where its declared
! as extern. If that header doesn't have '#include "dl_import.h"' at the top,
! add it. Put '_DL_IMPORT' in front of 'extern' (strictly speaking, position
! matters and proper place is after both extern and type, but for data
! declaration above works also (at least for me)). For example, if it was
!
! extern void *(*my_malloc)(int sz);
!
! becoming
!
! _DL_IMPORT extern void *(*my_malloc)(int sz);
!
! will suffice. Procedd with next symbol.
!
! However, if you're lazy for that, you may stretch the pleasure and mark
! symbol as _DL_IMPORT only whenever you encounter it in undefined symbol
! error during linking of client.
!
! 5. That's all! Now, just compile client either as usually or with -DDLL,
! and link either as usually or with -lfoo.dll .
!
! Pau...@te...
! 1999-08-28
--- 1,141 ----
! How to build Win32 Dynamic-Loading Library (DLL) from existing static library
! -----------------------------------------------------------------------------
!
! -------
! NOTE: To perform steps below, you'll need contemparary dlltool, for
! example from Mumit Khan's gcc-2.95.2 packages.
! -------
!
!
! This document describes step-by-step procedure of building Win32 DLL from
! static library. It suitable for both your own and third-party (i.e. ones
! which you know, and would like to, little about) libs. However, for your
! own libraries you may adopt more handy and adequate method (exporting all
! symbols, as done here, may be not the best solution). However, procedure
! given here describes easiest and fastest way if what you want is just
! create proper DLL and forget about it. This documets assumes that
! you have, or will, read documentation for Mumit Khan's dllwrappers
! tools (dllwrap & dlltool utilities).
!
! Before proceeding with description of process, some notes about
! distinction of DLLs and usual *nix-style shared libraries (.so, referred
! as SO below) (read also if you don't have experience with .so):
!
! [Once again note that there's a big gap between abstract information
! below and specific practical steps which follow; if you want to fill
! that gap, read standard documentation.]
!
!
! Theory
! ------
!
! 1. Usually, compilation of objects for shared libraries requires different
! set of compiler options comparing to static counterparts. For example,
! many systems require -fpic flag to generate position-independent code.
! However, for Win32, both static libs and DLLs are created from the same
! set of objects. Despite this little advantage, DLLs have following big
! disadvantage:
!
! 2. Once have been created, shared libraries require no additional fuzz
! for usage. When so-using executable is loaded, every reference to
! so-symbol gets fixed up to point directly to SO. Win32 has different
! system: every executable importing DLL has special section, .idata, to hold
! pointers to imported symbols. During loading, OS loader fills this section
! with actual info. And application is supposed, when needed DLL-symbol, first
! lookup its pointer in .idata, and only then have access by that pointer,
! As you see, for DLL-imported symbols, additional level of indirection is
! required. This stems probably from dark times of real-mode 16-bit Windows,
! working on 8086 processor lacking virtual memory. Having all import-related
! stuff in one single place facilated runtime relocation, which was needed
! to effictively manage memory there. So or other, but it is that way.
! So, as you see, special compiler support required to compile client of
! DLL (note strange symmetry - *nix require special support to compile library,
! while Win32 - to compile client. Former is better, I agree).
!
! 3. As was said before, with SO you use library just as you would static
! version. This is not so for Win32. Win32 DLL is self-contained executable,
! not supposed to be linked against. Instead, client is linked with special
! auxilary library, called 'import library' or 'implib'. Implib contains
! information to properly layout .idata section to be filled in by OS loader
! with information about DLL.
!
!
! Building DLL from existing static library
! -----------------------------------------
!
! We assume that you already build static lib, which we will call 'libfoo.a'.
! However, building yourself is not requirement, to perform these instructions,
! you don't needed sources of library - only library itself and its headers.
!
! 1. Fisrt step would be to create export definition file (or just def). You
! can do this directly from library:
!
! dlltool libfoo.a --export-all-symbols --output-def foo.def
!
! 2. Now, we can create DLL itself. This may be done by two ways: 1) link
! dummy file referencing each symbol in libfoo.a (created by script acting on
! output from 'nm libfoo.a') against libfoo.a (so, each foo's object for
! sure will be in foo.dll) or 2) exploding library and linking all its objects
! together. I consider second way cleaner and show it:
!
! mkdir tmp
! cp libfoo.a tmp/
! cd tmp
! ar x libfoo.a
! dllwrap *.o --def ../foo.def -o ../foo.dll [usual -l libraries here]
! cd ..
!
! 3. Let's create implib. If you want totally transparent transition from
! static to DLL, call it 'libfoo.a'. However, if you want to keep destinction,
! 'libfoo.dll.a' is good:
!
! dlltool --def foo.def --ouput-lib libfoo.dll.a
!
! 4. Now grep foo.def for entries containing 'DATA'. If there's none -
! congratulations, your library uses functional-only interface and you've done.
! Else, most unpleasant work left - patch headers to include dllimport tag.
!
! If you want to do it once-and-for-all (you should), do following:
!
! a) make something like 'dl_import.h' and put there:
! -----
! #if !defined(STATIC) && defined(_WIN32)
! #define _DL_IMPORT __delcspec(dllimport)
! #else
! #define _DL_IMPORT
! #endif
! -----
! , if you want to use DLL by default (note that you will need to compile
! library itself with STATIC defined), or
! -----
! #if defined(DLL) && defined(_WIN32)
! #define _DL_IMPORT __delcspec(dllimport)
! #else
! #define _DL_IMPORT
! #endif
! -----
! , if you want to include -DDLL each time you compile DLL client.
!
! b) for each def symbol having DATA attribute, find header where its declared
! as extern. If that header doesn't have '#include "dl_import.h"' at the top,
! add it. Put '_DL_IMPORT' in front of 'extern' (strictly speaking, position
! matters and proper place is after both extern and type, but for data
! declaration above works also (at least for me)). For example, if it was
!
! extern void *(*my_malloc)(int sz);
!
! becoming
!
! _DL_IMPORT extern void *(*my_malloc)(int sz);
!
! will suffice. Procedd with next symbol.
!
! However, if you're lazy for that, you may stretch the pleasure and mark
! symbol as _DL_IMPORT only whenever you encounter it in undefined symbol
! error during linking of client.
!
! 5. That's all! Now, just compile client either as usually or with -DDLL,
! and link either as usually or with -lfoo.dll .
!
! Pau...@te...
! 1999-08-28
|
|
From: <in...@us...> - 2002-05-26 10:14:04
|
Update of /cvsroot/mingw/utils/reimp In directory usw-pr-cvs1:/tmp/cvs-serv2405/reimp Modified Files: README Log Message: Convert some text files to Unix format Index: README =================================================================== RCS file: /cvsroot/mingw/utils/reimp/README,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** README 10 Apr 2002 13:39:07 -0000 1.1 --- README 26 May 2002 10:13:58 -0000 1.2 *************** *** 1,62 **** ! README for reimp ! ================ ! ! * Overview ! ! `reimp' is a tool to convert Microsoft's new-style (short) import ! libraries to import libraries for win32 ports of GNU tools (mingw32, ! cygwin). ! ! `reimp' reads an MS import library and writes all imports to the ! corresponding .DEF file(s) that it feeds to `dlltool' that creates the ! import library. ! ! ! * Invocation ! ! Usage: reimp [options] IMPLIB ! ! Options: ! -s, --dump-symbols dump symbols to stdout ! -d, --only-def only create .def files ! -c, --keep-case keep case in lib*.a file names ! --dlltool <name> use <name> for dlltool ! --as <name> use <name> for assembler ! ! The `--dump-symbols' option makes `reimp' use a quick method for ! finding imported symbols and sending the names of found symbols to ! stdout. If the input library contain non-imported symbols they will be ! listed as well. The output symbols will have all decoration preserved ! (i.e '_' will prefix most symbols), so if you feed it to dlltool you ! should strip leading underscores. For example ! ! echo EXPORTS > imp.def ! reimp imp.lib | sed 's/_//' >> imp.def ! dlltool -k --def imp.def --output-lib libimp.a --dllname imp.dll ! ! The `--only-def' option makes `reimp' stop after generating the .DEF ! file(s). ! ! By default `reimp' converts all output library names to lower-case. By ! using the `keep-case' option `reimp' will use exactly the case of the ! DLL imported from when creating an import library. KERNEL32.dll will ! generate libKERNEL32.a and not libkernel32.a as it would be default. ! ! ! * Notes on mixed libraries ! ! If an input library contain regular objects (non-imports, i.e code and ! data) `reimp' will write out those objects unless you specify one of ! the `--only-def' and `--dump-symbols' options. You probably want to ! include those objects as well in the generated library. `reimp' ! doesn't do that automatically so you have to do it manually using ! `ar', like this ! ! reimp imp.lib # this generates several .o or .obj files. ! ar rcs libimp.a *.obj # add them to library ! ! ! * Contact information ! ! URL: http://www.acc.umu.se/~anorland/gnu-win32/ ! Anders Norlander <ano...@he...> --- 1,62 ---- ! README for reimp ! ================ ! ! * Overview ! ! `reimp' is a tool to convert Microsoft's new-style (short) import ! libraries to import libraries for win32 ports of GNU tools (mingw32, ! cygwin). ! ! `reimp' reads an MS import library and writes all imports to the ! corresponding .DEF file(s) that it feeds to `dlltool' that creates the ! import library. ! ! ! * Invocation ! ! Usage: reimp [options] IMPLIB ! ! Options: ! -s, --dump-symbols dump symbols to stdout ! -d, --only-def only create .def files ! -c, --keep-case keep case in lib*.a file names ! --dlltool <name> use <name> for dlltool ! --as <name> use <name> for assembler ! ! The `--dump-symbols' option makes `reimp' use a quick method for ! finding imported symbols and sending the names of found symbols to ! stdout. If the input library contain non-imported symbols they will be ! listed as well. The output symbols will have all decoration preserved ! (i.e '_' will prefix most symbols), so if you feed it to dlltool you ! should strip leading underscores. For example ! ! echo EXPORTS > imp.def ! reimp imp.lib | sed 's/_//' >> imp.def ! dlltool -k --def imp.def --output-lib libimp.a --dllname imp.dll ! ! The `--only-def' option makes `reimp' stop after generating the .DEF ! file(s). ! ! By default `reimp' converts all output library names to lower-case. By ! using the `keep-case' option `reimp' will use exactly the case of the ! DLL imported from when creating an import library. KERNEL32.dll will ! generate libKERNEL32.a and not libkernel32.a as it would be default. ! ! ! * Notes on mixed libraries ! ! If an input library contain regular objects (non-imports, i.e code and ! data) `reimp' will write out those objects unless you specify one of ! the `--only-def' and `--dump-symbols' options. You probably want to ! include those objects as well in the generated library. `reimp' ! doesn't do that automatically so you have to do it manually using ! `ar', like this ! ! reimp imp.lib # this generates several .o or .obj files. ! ar rcs libimp.a *.obj # add them to library ! ! ! * Contact information ! ! URL: http://www.acc.umu.se/~anorland/gnu-win32/ ! Anders Norlander <ano...@he...> |
|
From: <in...@us...> - 2002-05-26 10:14:04
|
Update of /cvsroot/mingw/utils/drmingw/doc In directory usw-pr-cvs1:/tmp/cvs-serv2405/drmingw/doc Modified Files: drmingw.html Log Message: Convert some text files to Unix format Index: drmingw.html =================================================================== RCS file: /cvsroot/mingw/utils/drmingw/doc/drmingw.html,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** drmingw.html 10 Apr 2002 13:39:05 -0000 1.1 --- drmingw.html 26 May 2002 10:13:57 -0000 1.2 *************** *** 1,414 **** ! <HTML> ! <HEAD> ! <META HTTP-EQUIV="Content-Type" Content="text/html; charset=Windows-1252"> ! <TITLE>Dr. Mingw</TITLE> ! </HEAD> ! <BODY> ! <H1>Dr. Mingw</H1> ! <H2>What is it?</H2> ! <p>Dr. Mingw is a <i>Just-in-Time (JIT)</i> debugger. When the application throws ! an unhandled exception, Dr. Mingw attaches itself to the application and collects ! information about the exception, using the available debugging information.</p> ! <p>Dr. Mingw can read debugging information in <em>Stabs</em> formats — generated ! by the Gnu C/C++ Compiler, and in a PDB file — generated by the Microsoft ! Visual C++ Compiler.</p> ! <p>Windows NT/2000 platform is supported, as well as Windows 95/98. On older Windows ! versions though, the IMAGEHLP.DLL isn't included or it's a rather old version. ! Dr. Mingw doesn't require it, but relies upon it to resolve symbols in modules ! compiled by the Microsoft tools. See <a href="#imagehlp">The ! IMAGEHLP.DLL Saga</a> for more information. </p> ! <H2>What's new?</H2> ! <ul> ! <li>0.1.0 ! <ul> ! <li>First release</li> ! </ul> ! </li> ! <li>0.2.0 ! <ul> ! <li>fixed the event signaling</li> ! <li>works on the main Windows platforms: 9x, NT and 2k</li> ! <li>GUI</li> ! </ul> ! </li> ! <li>0.2.1 ! <ul> ! <li>fixed a bug on the process/thread/module lists</li> ! </ul> ! </li> ! <li>0.3.0 ! <ul> ! <li>more efficient and faster stack trace</li> ! <li>support for PDB using ImageHlp API, to trace into C Runtime Library DLLs</li> ! <li>strip long path names</li> ! <li>includes exchndl (former msjexchnd), in a standalone DLL</li> ! </ul> ! </li> ! <li>0.3.1 ! <ul> ! <li>better installation procedure</li> ! <ul> ! <li>creates the registry keys whenever they are not present</li> ! <li>the -v option is parsed, regardless of the order</li> ! </ul> ! <li>output is flushed immediately, so if any problem occurs, you still can see what was behind</li> ! </ul> ! </li> ! <li>0.3.2 ! <ul> ! <li>fixed some serious bugs originated from code rewrite:</li> ! <ul> ! <li>the stack backtrace would fail if IMAGEHLP.DLL wasn't present</li> ! <li>DrMingw would stop on non NT machines</li> ! </ul> ! <li>IMAGEHLP.DLL is no longer needed for searching the nearest exported symbol in modules without debugging information</li> ! <li>the -d option was removed, now it's -v only</li> ! </ul> ! </li> ! <li>0.4.0 ! <ul> ! <li>dumps arguments of function calls</li> ! </ul> ! </li> ! <li>0.4.1 ! <ul> ! <li>more flexible GUI</li> ! </ul> ! </li> ! <li>0.4.2 ! <ul> ! <li>a nicer format of the arguments dump</li> ! </ul> ! </li> ! <li>0.4.3 ! <ul> ! <li>fixed a bug that could prevent of working on some releases of Windows NT4</li> ! <li>added a new way to trace source lines using the Stabs debugging information (especially useful with inline members of C++ classes)</li> ! </ul> ! </li> ! </ul> ! <H2>Download</H2> ! <p>Download <A href="ftp://ftp.fe.up.pt/pub/Projectos/em96115/gnu-win32/misc/drmingw-0.4.3.tar.bz2">here</A> the lastest binaries and source code. It's in .tar.bz2 format. You can use this very ! small (23 kb) standalone decompressor, <a href="ftp://ftp.fe.up.pt/pub/Projectos/em96115/misc/untbz2.exe">untbz2</a>. ! For more information about bzip2 see its <a href="http://sourceware.cygnus.com/bzip2"> ! homepage</a>.</p> ! <H2>Installation</H2> ! <p>To install enter</p> ! <blockquote> ! <pre><b>drmingw -i</b></pre> ! </blockquote> ! <p>Dr. Mingw will register itself as the JIT debugger by writting into the system ! registry. On Windows NT/2000 make sure you have Administrator rights. See <a href="#jit">Enabling ! Just-in-Time (JIT) Debugging</a> for more information.</p> ! <H2></H2> ! <p>If the installation is sucessful, the following message box should appear:</p> ! <p align="center"><img src="install.gif"></p> ! <p>To enable other options they must be set them allong with the <b>-i</b> option. ! For example,</p> ! <blockquote> ! <pre><b>drmingw -i -v </b></pre> ! </blockquote> ! <p>If you still have trouble installing, edit the included<b> drmingw.reg</b> ! file to reflect the <b>drmingw.exe</b> executable path and load it on the system ! registry.</p> ! <H2>Using</H2> ! <p>You can test Dr. Mingw by running the sample<b> test.exe</b>.</p> ! <p>Depending of your Windows version, you'll see a familiar dialog:</p> ! <p align="center"><img src="exception-nt.gif"></p> ! <p>If you request to debug the program, Dr. Mingw will attach to the faulting ! application, collect information about the exception, and display the dialog</p> ! <p align="center"><img src="sample.gif"></p> ! <p>To resolve the addresses it's necessary to compile the application with debugging ! information. In case of address is in a DLL with no debugging information, it ! will resolve to the precedent exported symbol.</p> ! <H2>Command Line Options</H2> ! <p>The Dr. Mingw command line uses the following syntax:</p> ! <pre><b>drmingw </b>[<b>-h | --help</b>] [<b>-V | --version</b>] [<b>-i | --install</b>] [<b>-a | --auto</b>] [<b>-u | --uninstall</b>] ! [<b>-p</b> <i>pid</i> | <b>--process-id=</b><i>pid</i>] [<b>-e</b> <i>event</i> | <b>--event=</b><i>event</i>] ! [<b>-v | --verbose</b>] ! </pre> ! <p>The following table describes the Dr. Mingw command-line options. All comand-line ! options are case-sensitive. </p> ! <table width="78%"> ! <tr valign="top"> ! <th align=left width=10%>Option</th> ! <th align=left width=25%> </th> ! <th align=left width=65%>Action</th> ! </tr> ! <tr valign="top"> ! <td width=10%> ! <pre><b>-h</b></pre> ! </td> ! <td width=25%> ! <pre><b>--help</b></pre> ! </td> ! <td width=65%>Print help and exit </td> ! </tr> ! <tr valign="top"> ! <td width=10%> ! <pre><b>-V</b></pre> ! </td> ! <td width=25%> ! <pre><b>--version</b></pre> ! </td> ! <td width=65%>Print version and exit</td> ! </tr> ! <tr valign="top"> ! <td width=10%> ! <pre><b>-i</b></pre> ! </td> ! <td width=25%> ! <pre><b>--install</b></pre> ! </td> ! <td width=65%>Install as the default JIT debugger</td> ! </tr> ! <tr valign="top"> ! <td width=10%> ! <pre><b>-a</b></pre> ! </td> ! <td width=25%> ! <pre><b>--auto</b></pre> ! </td> ! <td width=65%>Automatically start (used with <b>-i</b> | <b>--install</b>)</td> ! </tr> ! <tr valign="top"> ! <td width=10%> ! <pre><b>-u</b></pre> ! </td> ! <td width=25%> ! <pre><b>--uninstall</b></pre> ! </td> ! <td width=65%>Uninstall</td> ! </tr> ! <tr valign="top"> ! <td width=10%> ! <pre><b>-p</b> <i>pid</i></pre> ! </td> ! <td width=25%> ! <pre><b>--process-id=</b><i>pid</i></pre> ! </td> ! <td width=65%>Attach to the process with the given identifier</td> ! </tr> ! <tr valign="top"> ! <td width=10%> ! <pre><b>-e</b> <i>event</i></pre> ! </td> ! <td width=25%> ! <pre><b>--event=</b><i>event</i></pre> ! </td> ! <td width=65%>Signal an event after process is attached</td> ! </tr> ! <tr valign="top"> ! <td width=10%> ! <pre><b>-v</b></pre> ! </td> ! <td width=25%> ! <pre><b>--verbose</b></pre> ! </td> ! <td width=65%>Verbose output</td> ! </tr> ! </table> ! <H2><a name="exchndl"></a>The EXCHNDL.DLL</H2> ! <H3>Introduction</H3> ! <p>Although internally Dr. Mingw behaves much like a debugger, from the outside ! it is like a standalone exception handler. But for its own debugging purposes, ! Dr. Mingw has a internal exception handler that is completly seperate from the ! main code.</p> ! <p>This exception handler resides in <b>exchndl.c</b>. When <b>drmingw.exe</b> ! is loaded, the code in <b>exchndl.c</b> is automatically executed (by the ! gcc static constructor/destructor mechanism) and registers itself as a exception ! handler.</p> ! <p>This exception handler is much lighter than Dr. Mingw debugging system because ! it doesn't have to deal with interprocess communication. The exception handling ! routine runs in the same process context of the faulting application (<b>drmingw</b>, ! in this case).</p> ! <H3>Using ExcHndl for you own purposes</H3> ! <p>If you incorporate ExcHndl in you own programs, especially those that you release ! to others, you can have almost the same exception information that you would ! get with Dr. Mingw, but with no need of the end user to have Dr. Mingw installed.</p> ! <p>You can use ExcHndl in two ways:</p> ! <ul> ! <li>linking <b>exchndl.o</b> and <b>libbfd.a</b> with your program objects</li> ! <li>linking <b>exchndl.o</b> and <b>libfd.a</b> in the <b>EXCHNDL.DLL</b> and ! dinamically loading it at run-time. This can be done by linking just <b>exchndl2.o</b> ! or explicitly calling <i>LoadLibrary("exchndl.dll")</i></li> ! </ul> ! <p>The latter method is preferred because you have smaller executables and don't ! need to link the BFD library in all builds. The application wont fail if the ! <b>EXCHNDL.DLL</b> is missing.</p> ! <H3>Example</H3> ! <p>The sample<b> test.exe</b> application uses the second method above. Copy <b>EXCHNDL.DLL</b> ! to executable directory. When you run it, even before general protection fault ! dialog box appears, it's written to the <b>test.RPT</b> file a report of the ! fault.</p> ! <p>Here is how <b>test.RPT</b> should look like:</p> ! <pre>------------------- ! ! Error occured on Sunday, May 7, 2000 at 20:22:03. ! ! C:\home\jrfonseca\drmingw\src\test.exe caused an Access Violation in module C:\WINDOWS\system32\msvcrt.dll Writing to location 00000008. ! ! Registers: ! eax=00003039 ebx=00000064 ecx=00000008 edx=0244fec0 esi=00401211 edi=0244fec0 ! eip=78027470 esp=0244fcd8 ebp=0244fea8 iopl=0 nv up ei pl nz na pe nc ! cs=001b ss=0023 ds=0023 es=0023 fs=0038 gs=0000 efl=00010202 ! ! Call stack: ! 78027470 C:\WINDOWS\system32\msvcrt.dll:78027470 wscanf ! 7802544B C:\WINDOWS\system32\msvcrt.dll:7802544B sscanf ! 00401241 C:\home\jrfonseca\drmingw\src\test.exe:00401241 YetAnotherFunction //C/home/jrfonseca/drmingw/src/test.cxx:14 ! 00401272 C:\home\jrfonseca\drmingw\src\test.exe:00401272 MyWonderfulFunction //C/home/jrfonseca/drmingw/src/test.cxx:19 ! 004012A9 C:\home\jrfonseca\drmingw\src\test.exe:004012A9 main //C/home/jrfonseca/drmingw/src/test.cxx:24 ! 004011C1 C:\home\jrfonseca\drmingw\src\test.exe:004011C1 ! 004011EB C:\home\jrfonseca\drmingw\src\test.exe:004011EB ! 77E87903 C:\WINDOWS\system32\KERNEL32.dll:77E87903 SetUnhandledExceptionFilter ! ! ! </pre> ! <H2>Appendix</H2> ! <H3><a name="jit"></a>Enabling Just-in-Time (JIT) Debugging</H3> ! ! <P><span style="color:#FF0000">[Taken from Using Microsoft Debuggers of the April ! 2000 Platform SDK.]</span> </P> ! ! <P>There are a variety of application errors which will cause Windows NT/Windows 2000 a to terminate the application. The most common kinds of errors are deadlocks and access violations. From the operating systems point of view, these are all simply unhandled exceptions.</P> ! ! <P>When an application error occurs, Windows searches for an exception handler. If it does not find an exception handler, the system verifies that the application is not currently being debugged and considers the exception to be unhandled. At this point, there are three possible responses: ! ! <UL> ! <LI>Windows can end the process immediately.</LI> ! ! <LI>Windows can freeze the process and start a user-mode debugger. This debugger can then be used to examine the application.</LI> ! ! <LI>Windows can run a debugging tool which will create a memory dump file of the application's memory space, and then end the process.</LI> ! </UL> ! ! <P>The debugging tool which is used to debug the application or write the dump file is called <I>Just-in-Time (JIT) Debugger</I>, or the <I>post-mortem debugger</I>.</P> ! ! <P>The default JIT debugger is Dr. Watson. When the application throws an ! unhandled exception, Dr. Watson attaches itself to the application and generates ! a crash dump file. After it creates the crash dump file, Dr. Watson closes the ! application and exits.</P> ! ! <P>Any user-mode debugging tool can be selected as the JIT debugger: ! ! <UL> ! ! <LI>To change the JIT debugger to WinDbg, run <B>windbg -I</B>. When WinDbg ! is the JIT debugger, WinDbg will be activated whenever an application crashes. ! See WinDbg Command Line Options for details.</LI> ! ! <LI>To change the JIT debugger to NTSD, you must edit the registry. When NTSD is the JIT debugger, NTSD will be activated whenever an application crashes.</LI> ! ! ! <LI>To change the JIT debugger back to Dr. Watson, run <B>drwtsn32 -i</B>. ! When Dr. Watson is the JIT debugger, a memory dump file will be written ! to disk if an application crashes. See Dr. Watson Command Line Options for ! details.</LI> ! </UL> ! ! <P>Only a system administrator can alter the JIT settings.</P> ! ! <P>If a JIT debugger has been installed, you can deliberately break into the debugger from a user-mode application by calling the <B>DebugBreak</B> function.</P> ! ! <H4>Editing the Registry</H4> ! ! <P>The Just-in-Time debugging settings are stored in the registry, under <B>\\HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\AeDebug\</B>. The two relevant keys in this directory are <B>Debugger</B> and <B>Auto</B>.</P> ! ! <P>The <B>Debugger</B> key's value shows the name of the debugger specified to analyze application errors. The <B>Auto</B> key is either zero or one.</P> ! ! <P>When an unhandled application error occurs, Windows checks to see if the <B>Debugger</B> and <B>Auto</B> keys exist.</P> ! ! <P>If the <B>Auto</B> key equals zero and the <B>Debugger</B> value contains the name of a valid debugger (such as WinDbg or NTSD), the message box will have two buttons: <B>OK</B> and <B>Cancel</B>. If the <B>OK</B> button is pressed, the application is terminated. If the <B>Cancel</B> button is pressed, the debugger specified in the <B>Debugger</B> key is started.</P> ! ! <P>If the <B>Auto</B> key equals zero, but the <B>Debugger</B> key value is empty, the message box will have only an <B>OK</B> button and no debugger will start.</P> ! ! <P>If the <B>Auto</B> key equals one, no message box appears. The debugger referred to in the <B>Debugger</B> key is automatically started.</P> ! ! <P><B>Setting Dr. Watson as the JIT debugger (default):</B></P> ! ! <PRE>Debugger = "drwtsn32 -p %ld -e %ld -g" ! Auto = 1</PRE> ! ! <P><B>Setting WinDbg as the JIT debugger:</B></P> ! ! <PRE>Debugger = "WinDbg -p %ld -e %ld" ! Auto = 1</PRE> ! ! <P><B>Setting NTSD as the JIT debugger:</B></P> ! ! <PRE>Debugger = "NTSD -p %ld -e %ld -g" ! Auto = 1</PRE> ! ! <P>In these examples, -<B>p %ld</B> specifies the process ID that NTSD will debug, -<B>e %ld</B> provides the event that caused the exception, and -<B>g</B> causes the debugger to skip the initial breakpoint. (Dr. Watson ignores the -<B>g</B> option.)</P> ! <DIV CLASS="footer"> ! <p>Built on Thursday, April 20, 2000</p> ! <H3><a name="imagehlp"></a>The IMAGEHLP.DLL Saga</H3> ! <p><span style="color:#FF0000">[Taken from several Bugslayer articles of MSJ.]</span> ! </p> ! <p>The IMAGEHLP.DLL symbol engine first appeared in Windows NT® 4.0. The beta ! Windows NT 5.0 SDK had new parts of IMAGEHLP.H that dealt with source and ! line information. In the meantime, the November 1998 Platform SDK showed and ! the IMAGEHLP.DLL that shipped with it supported the new source and line handling. ! There are several different versions of IMAGEHLP.DLL. The only one that does ! not support the new source and line information is the original Windows NT ! 4.0 version. </p> ! <p>The IMAGEHLP.DLL version 5.00.1678.1 dynamically links to MSPDB50.DLL. It ! first tries to load MSDBI.DLL, and if that is not found it will load MSPDB50.DLL, ! so it works with both Visual C++® 5.0 and 6.0. To use it with Visual C++ 6.0, ! copy MSPDB50.DLL to MSPDB60.DLL. If you want to get symbols from the field, ! you will have to compile with CodeView® symbols and use .DBG files to get ! them. Keep in mind that MSPDB50.DLL, like MSDBI.DLL, is not redistributable. ! </p> ! <p>The IMAGEHLP.DLL version 5.00.1878.1, which comes with the Windows 2000 Beta ! 2 Platform SDK, hard links against MSDBI.DLL instead of dynamically loading ! MSPDB50.DLL as in earlier versions to read PDB files. The problem is that ! MSDBI.DLL is not redistributable.</p> ! <p> IMAGEHLP.DLL now uses DEBUGHLP.DLL. </p> ! <p>If you want IMAGEHLP.DLL, it's available in:</p> ! </DIV> ! <ul> ! <li> ! <DIV CLASS="footer">Platform SDK</DIV> ! </li> ! <li> ! <DIV CLASS="footer">WinDBG Debugger</DIV> ! </li> ! <li> ! <DIV CLASS="footer">Windows 2000</DIV> ! </li> ! </ul> ! <DIV CLASS="footer"> ! <H2>Suggested Reading</H2> ! </DIV> ! <ul> ! <li> ! <DIV CLASS="footer"><a href="http://www.microsoft.com/msj/0197/exception/exception.htm">A ! Crash Course on the Depths of Win32 Structured Exception Handling, MSJ January ! 1997</a></DIV> ! </li> ! <li> ! <DIV CLASS="footer"><a href="http://www.microsoft.com/msj/0497/hood/hood0497.htm">MSJEXHND ! - Part 1, Under the Hood, MSJ April 1997</a></DIV> ! </li> ! <li> ! <DIV CLASS="footer"><a href="http://www.microsoft.com/msj/0597/hood/hood0597.htm">MSJEXHND ! - Part 2, Under the Hood, MSJ May 1997</a></DIV> ! </li> ! <li><a href=http://www.microsoft.com/msj/0898/bugslayer0898.htm>Bugslayer, MSJ, ! August 1998</a></li> ! <li> ! <DIV CLASS="footer"><a href="http://msdn.microsoft.com/library/techart/msdn_debug.htm"> ! The Win32 Debugging Application Programming Interface</a></DIV> ! </li> ! </ul> ! <H2>Contact</H2> ! <p>José Fonseca</p> ! <p><a href="mailto:em...@fe...">em...@fe...</a></p> ! <p><a href="http://www.fe.up.pt/~em96115/gnu-win32">http://www.fe.up.pt/~em96115/gnu-win32</a></p> ! <DIV CLASS="footer"> ! <p> </p> ! </DIV> ! ! </BODY> ! </HTML> --- 1,414 ---- ! <HTML> ! <HEAD> ! <META HTTP-EQUIV="Content-Type" Content="text/html; charset=Windows-1252"> ! <TITLE>Dr. Mingw</TITLE> ! </HEAD> ! <BODY> ! <H1>Dr. Mingw</H1> ! <H2>What is it?</H2> ! <p>Dr. Mingw is a <i>Just-in-Time (JIT)</i> debugger. When the application throws ! an unhandled exception, Dr. Mingw attaches itself to the application and collects ! information about the exception, using the available debugging information.</p> ! <p>Dr. Mingw can read debugging information in <em>Stabs</em> formats — generated ! by the Gnu C/C++ Compiler, and in a PDB file — generated by the Microsoft ! Visual C++ Compiler.</p> ! <p>Windows NT/2000 platform is supported, as well as Windows 95/98. On older Windows ! versions though, the IMAGEHLP.DLL isn't included or it's a rather old version. ! Dr. Mingw doesn't require it, but relies upon it to resolve symbols in modules ! compiled by the Microsoft tools. See <a href="#imagehlp">The ! IMAGEHLP.DLL Saga</a> for more information. </p> ! <H2>What's new?</H2> ! <ul> ! <li>0.1.0 ! <ul> ! <li>First release</li> ! </ul> ! </li> ! <li>0.2.0 ! <ul> ! <li>fixed the event signaling</li> ! <li>works on the main Windows platforms: 9x, NT and 2k</li> ! <li>GUI</li> ! </ul> ! </li> ! <li>0.2.1 ! <ul> ! <li>fixed a bug on the process/thread/module lists</li> ! </ul> ! </li> ! <li>0.3.0 ! <ul> ! <li>more efficient and faster stack trace</li> ! <li>support for PDB using ImageHlp API, to trace into C Runtime Library DLLs</li> ! <li>strip long path names</li> ! <li>includes exchndl (former msjexchnd), in a standalone DLL</li> ! </ul> ! </li> ! <li>0.3.1 ! <ul> ! <li>better installation procedure</li> ! <ul> ! <li>creates the registry keys whenever they are not present</li> ! <li>the -v option is parsed, regardless of the order</li> ! </ul> ! <li>output is flushed immediately, so if any problem occurs, you still can see what was behind</li> ! </ul> ! </li> ! <li>0.3.2 ! <ul> ! <li>fixed some serious bugs originated from code rewrite:</li> ! <ul> ! <li>the stack backtrace would fail if IMAGEHLP.DLL wasn't present</li> ! <li>DrMingw would stop on non NT machines</li> ! </ul> ! <li>IMAGEHLP.DLL is no longer needed for searching the nearest exported symbol in modules without debugging information</li> ! <li>the -d option was removed, now it's -v only</li> ! </ul> ! </li> ! <li>0.4.0 ! <ul> ! <li>dumps arguments of function calls</li> ! </ul> ! </li> ! <li>0.4.1 ! <ul> ! <li>more flexible GUI</li> ! </ul> ! </li> ! <li>0.4.2 ! <ul> ! <li>a nicer format of the arguments dump</li> ! </ul> ! </li> ! <li>0.4.3 ! <ul> ! <li>fixed a bug that could prevent of working on some releases of Windows NT4</li> ! <li>added a new way to trace source lines using the Stabs debugging information (especially useful with inline members of C++ classes)</li> ! </ul> ! </li> ! </ul> ! <H2>Download</H2> ! <p>Download <A href="ftp://ftp.fe.up.pt/pub/Projectos/em96115/gnu-win32/misc/drmingw-0.4.3.tar.bz2">here</A> the lastest binaries and source code. It's in .tar.bz2 format. You can use this very ! small (23 kb) standalone decompressor, <a href="ftp://ftp.fe.up.pt/pub/Projectos/em96115/misc/untbz2.exe">untbz2</a>. ! For more information about bzip2 see its <a href="http://sourceware.cygnus.com/bzip2"> ! homepage</a>.</p> ! <H2>Installation</H2> ! <p>To install enter</p> ! <blockquote> ! <pre><b>drmingw -i</b></pre> ! </blockquote> ! <p>Dr. Mingw will register itself as the JIT debugger by writting into the system ! registry. On Windows NT/2000 make sure you have Administrator rights. See <a href="#jit">Enabling ! Just-in-Time (JIT) Debugging</a> for more information.</p> ! <H2></H2> ! <p>If the installation is sucessful, the following message box should appear:</p> ! <p align="center"><img src="install.gif"></p> ! <p>To enable other options they must be set them allong with the <b>-i</b> option. ! For example,</p> ! <blockquote> ! <pre><b>drmingw -i -v </b></pre> ! </blockquote> ! <p>If you still have trouble installing, edit the included<b> drmingw.reg</b> ! file to reflect the <b>drmingw.exe</b> executable path and load it on the system ! registry.</p> ! <H2>Using</H2> ! <p>You can test Dr. Mingw by running the sample<b> test.exe</b>.</p> ! <p>Depending of your Windows version, you'll see a familiar dialog:</p> ! <p align="center"><img src="exception-nt.gif"></p> ! <p>If you request to debug the program, Dr. Mingw will attach to the faulting ! application, collect information about the exception, and display the dialog</p> ! <p align="center"><img src="sample.gif"></p> ! <p>To resolve the addresses it's necessary to compile the application with debugging ! information. In case of address is in a DLL with no debugging information, it ! will resolve to the precedent exported symbol.</p> ! <H2>Command Line Options</H2> ! <p>The Dr. Mingw command line uses the following syntax:</p> ! <pre><b>drmingw </b>[<b>-h | --help</b>] [<b>-V | --version</b>] [<b>-i | --install</b>] [<b>-a | --auto</b>] [<b>-u | --uninstall</b>] ! [<b>-p</b> <i>pid</i> | <b>--process-id=</b><i>pid</i>] [<b>-e</b> <i>event</i> | <b>--event=</b><i>event</i>] ! [<b>-v | --verbose</b>] ! </pre> ! <p>The following table describes the Dr. Mingw command-line options. All comand-line ! options are case-sensitive. </p> ! <table width="78%"> ! <tr valign="top"> ! <th align=left width=10%>Option</th> ! <th align=left width=25%> </th> ! <th align=left width=65%>Action</th> ! </tr> ! <tr valign="top"> ! <td width=10%> ! <pre><b>-h</b></pre> ! </td> ! <td width=25%> ! <pre><b>--help</b></pre> ! </td> ! <td width=65%>Print help and exit </td> ! </tr> ! <tr valign="top"> ! <td width=10%> ! <pre><b>-V</b></pre> ! </td> ! <td width=25%> ! <pre><b>--version</b></pre> ! </td> ! <td width=65%>Print version and exit</td> ! </tr> ! <tr valign="top"> ! <td width=10%> ! <pre><b>-i</b></pre> ! </td> ! <td width=25%> ! <pre><b>--install</b></pre> ! </td> ! <td width=65%>Install as the default JIT debugger</td> ! </tr> ! <tr valign="top"> ! <td width=10%> ! <pre><b>-a</b></pre> ! </td> ! <td width=25%> ! <pre><b>--auto</b></pre> ! </td> ! <td width=65%>Automatically start (used with <b>-i</b> | <b>--install</b>)</td> ! </tr> ! <tr valign="top"> ! <td width=10%> ! <pre><b>-u</b></pre> ! </td> ! <td width=25%> ! <pre><b>--uninstall</b></pre> ! </td> ! <td width=65%>Uninstall</td> ! </tr> ! <tr valign="top"> ! <td width=10%> ! <pre><b>-p</b> <i>pid</i></pre> ! </td> ! <td width=25%> ! <pre><b>--process-id=</b><i>pid</i></pre> ! </td> ! <td width=65%>Attach to the process with the given identifier</td> ! </tr> ! <tr valign="top"> ! <td width=10%> ! <pre><b>-e</b> <i>event</i></pre> ! </td> ! <td width=25%> ! <pre><b>--event=</b><i>event</i></pre> ! </td> ! <td width=65%>Signal an event after process is attached</td> ! </tr> ! <tr valign="top"> ! <td width=10%> ! <pre><b>-v</b></pre> ! </td> ! <td width=25%> ! <pre><b>--verbose</b></pre> ! </td> ! <td width=65%>Verbose output</td> ! </tr> ! </table> ! <H2><a name="exchndl"></a>The EXCHNDL.DLL</H2> ! <H3>Introduction</H3> ! <p>Although internally Dr. Mingw behaves much like a debugger, from the outside ! it is like a standalone exception handler. But for its own debugging purposes, ! Dr. Mingw has a internal exception handler that is completly seperate from the ! main code.</p> ! <p>This exception handler resides in <b>exchndl.c</b>. When <b>drmingw.exe</b> ! is loaded, the code in <b>exchndl.c</b> is automatically executed (by the ! gcc static constructor/destructor mechanism) and registers itself as a exception ! handler.</p> ! <p>This exception handler is much lighter than Dr. Mingw debugging system because ! it doesn't have to deal with interprocess communication. The exception handling ! routine runs in the same process context of the faulting application (<b>drmingw</b>, ! in this case).</p> ! <H3>Using ExcHndl for you own purposes</H3> ! <p>If you incorporate ExcHndl in you own programs, especially those that you release ! to others, you can have almost the same exception information that you would ! get with Dr. Mingw, but with no need of the end user to have Dr. Mingw installed.</p> ! <p>You can use ExcHndl in two ways:</p> ! <ul> ! <li>linking <b>exchndl.o</b> and <b>libbfd.a</b> with your program objects</li> ! <li>linking <b>exchndl.o</b> and <b>libfd.a</b> in the <b>EXCHNDL.DLL</b> and ! dinamically loading it at run-time. This can be done by linking just <b>exchndl2.o</b> ! or explicitly calling <i>LoadLibrary("exchndl.dll")</i></li> ! </ul> ! <p>The latter method is preferred because you have smaller executables and don't ! need to link the BFD library in all builds. The application wont fail if the ! <b>EXCHNDL.DLL</b> is missing.</p> ! <H3>Example</H3> ! <p>The sample<b> test.exe</b> application uses the second method above. Copy <b>EXCHNDL.DLL</b> ! to executable directory. When you run it, even before general protection fault ! dialog box appears, it's written to the <b>test.RPT</b> file a report of the ! fault.</p> ! <p>Here is how <b>test.RPT</b> should look like:</p> ! <pre>------------------- ! ! Error occured on Sunday, May 7, 2000 at 20:22:03. ! ! C:\home\jrfonseca\drmingw\src\test.exe caused an Access Violation in module C:\WINDOWS\system32\msvcrt.dll Writing to location 00000008. ! ! Registers: ! eax=00003039 ebx=00000064 ecx=00000008 edx=0244fec0 esi=00401211 edi=0244fec0 ! eip=78027470 esp=0244fcd8 ebp=0244fea8 iopl=0 nv up ei pl nz na pe nc ! cs=001b ss=0023 ds=0023 es=0023 fs=0038 gs=0000 efl=00010202 ! ! Call stack: ! 78027470 C:\WINDOWS\system32\msvcrt.dll:78027470 wscanf ! 7802544B C:\WINDOWS\system32\msvcrt.dll:7802544B sscanf ! 00401241 C:\home\jrfonseca\drmingw\src\test.exe:00401241 YetAnotherFunction //C/home/jrfonseca/drmingw/src/test.cxx:14 ! 00401272 C:\home\jrfonseca\drmingw\src\test.exe:00401272 MyWonderfulFunction //C/home/jrfonseca/drmingw/src/test.cxx:19 ! 004012A9 C:\home\jrfonseca\drmingw\src\test.exe:004012A9 main //C/home/jrfonseca/drmingw/src/test.cxx:24 ! 004011C1 C:\home\jrfonseca\drmingw\src\test.exe:004011C1 ! 004011EB C:\home\jrfonseca\drmingw\src\test.exe:004011EB ! 77E87903 C:\WINDOWS\system32\KERNEL32.dll:77E87903 SetUnhandledExceptionFilter ! ! ! </pre> ! <H2>Appendix</H2> ! <H3><a name="jit"></a>Enabling Just-in-Time (JIT) Debugging</H3> ! ! <P><span style="color:#FF0000">[Taken from Using Microsoft Debuggers of the April ! 2000 Platform SDK.]</span> </P> ! ! <P>There are a variety of application errors which will cause Windows NT/Windows 2000 a to terminate the application. The most common kinds of errors are deadlocks and access violations. From the operating systems point of view, these are all simply unhandled exceptions.</P> ! ! <P>When an application error occurs, Windows searches for an exception handler. If it does not find an exception handler, the system verifies that the application is not currently being debugged and considers the exception to be unhandled. At this point, there are three possible responses: ! ! <UL> ! <LI>Windows can end the process immediately.</LI> ! ! <LI>Windows can freeze the process and start a user-mode debugger. This debugger can then be used to examine the application.</LI> ! ! <LI>Windows can run a debugging tool which will create a memory dump file of the application's memory space, and then end the process.</LI> ! </UL> ! ! <P>The debugging tool which is used to debug the application or write the dump file is called <I>Just-in-Time (JIT) Debugger</I>, or the <I>post-mortem debugger</I>.</P> ! ! <P>The default JIT debugger is Dr. Watson. When the application throws an ! unhandled exception, Dr. Watson attaches itself to the application and generates ! a crash dump file. After it creates the crash dump file, Dr. Watson closes the ! application and exits.</P> ! ! <P>Any user-mode debugging tool can be selected as the JIT debugger: ! ! <UL> ! ! <LI>To change the JIT debugger to WinDbg, run <B>windbg -I</B>. When WinDbg ! is the JIT debugger, WinDbg will be activated whenever an application crashes. ! See WinDbg Command Line Options for details.</LI> ! ! <LI>To change the JIT debugger to NTSD, you must edit the registry. When NTSD is the JIT debugger, NTSD will be activated whenever an application crashes.</LI> ! ! ! <LI>To change the JIT debugger back to Dr. Watson, run <B>drwtsn32 -i</B>. ! When Dr. Watson is the JIT debugger, a memory dump file will be written ! to disk if an application crashes. See Dr. Watson Command Line Options for ! details.</LI> ! </UL> ! ! <P>Only a system administrator can alter the JIT settings.</P> ! ! <P>If a JIT debugger has been installed, you can deliberately break into the debugger from a user-mode application by calling the <B>DebugBreak</B> function.</P> ! ! <H4>Editing the Registry</H4> ! ! <P>The Just-in-Time debugging settings are stored in the registry, under <B>\\HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\AeDebug\</B>. The two relevant keys in this directory are <B>Debugger</B> and <B>Auto</B>.</P> ! ! <P>The <B>Debugger</B> key's value shows the name of the debugger specified to analyze application errors. The <B>Auto</B> key is either zero or one.</P> ! ! <P>When an unhandled application error occurs, Windows checks to see if the <B>Debugger</B> and <B>Auto</B> keys exist.</P> ! ! <P>If the <B>Auto</B> key equals zero and the <B>Debugger</B> value contains the name of a valid debugger (such as WinDbg or NTSD), the message box will have two buttons: <B>OK</B> and <B>Cancel</B>. If the <B>OK</B> button is pressed, the application is terminated. If the <B>Cancel</B> button is pressed, the debugger specified in the <B>Debugger</B> key is started.</P> ! ! <P>If the <B>Auto</B> key equals zero, but the <B>Debugger</B> key value is empty, the message box will have only an <B>OK</B> button and no debugger will start.</P> ! ! <P>If the <B>Auto</B> key equals one, no message box appears. The debugger referred to in the <B>Debugger</B> key is automatically started.</P> ! ! <P><B>Setting Dr. Watson as the JIT debugger (default):</B></P> ! ! <PRE>Debugger = "drwtsn32 -p %ld -e %ld -g" ! Auto = 1</PRE> ! ! <P><B>Setting WinDbg as the JIT debugger:</B></P> ! ! <PRE>Debugger = "WinDbg -p %ld -e %ld" ! Auto = 1</PRE> ! ! <P><B>Setting NTSD as the JIT debugger:</B></P> ! ! <PRE>Debugger = "NTSD -p %ld -e %ld -g" ! Auto = 1</PRE> ! ! <P>In these examples, -<B>p %ld</B> specifies the process ID that NTSD will debug, -<B>e %ld</B> provides the event that caused the exception, and -<B>g</B> causes the debugger to skip the initial breakpoint. (Dr. Watson ignores the -<B>g</B> option.)</P> ! <DIV CLASS="footer"> ! <p>Built on Thursday, April 20, 2000</p> ! <H3><a name="imagehlp"></a>The IMAGEHLP.DLL Saga</H3> ! <p><span style="color:#FF0000">[Taken from several Bugslayer articles of MSJ.]</span> ! </p> ! <p>The IMAGEHLP.DLL symbol engine first appeared in Windows NT® 4.0. The beta ! Windows NT 5.0 SDK had new parts of IMAGEHLP.H that dealt with source and ! line information. In the meantime, the November 1998 Platform SDK showed and ! the IMAGEHLP.DLL that shipped with it supported the new source and line handling. ! There are several different versions of IMAGEHLP.DLL. The only one that does ! not support the new source and line information is the original Windows NT ! 4.0 version. </p> ! <p>The IMAGEHLP.DLL version 5.00.1678.1 dynamically links to MSPDB50.DLL. It ! first tries to load MSDBI.DLL, and if that is not found it will load MSPDB50.DLL, ! so it works with both Visual C++® 5.0 and 6.0. To use it with Visual C++ 6.0, ! copy MSPDB50.DLL to MSPDB60.DLL. If you want to get symbols from the field, ! you will have to compile with CodeView® symbols and use .DBG files to get ! them. Keep in mind that MSPDB50.DLL, like MSDBI.DLL, is not redistributable. ! </p> ! <p>The IMAGEHLP.DLL version 5.00.1878.1, which comes with the Windows 2000 Beta ! 2 Platform SDK, hard links against MSDBI.DLL instead of dynamically loading ! MSPDB50.DLL as in earlier versions to read PDB files. The problem is that ! MSDBI.DLL is not redistributable.</p> ! <p> IMAGEHLP.DLL now uses DEBUGHLP.DLL. </p> ! <p>If you want IMAGEHLP.DLL, it's available in:</p> ! </DIV> ! <ul> ! <li> ! <DIV CLASS="footer">Platform SDK</DIV> ! </li> ! <li> ! <DIV CLASS="footer">WinDBG Debugger</DIV> ! </li> ! <li> ! <DIV CLASS="footer">Windows 2000</DIV> ! </li> ! </ul> ! <DIV CLASS="footer"> ! <H2>Suggested Reading</H2> ! </DIV> ! <ul> ! <li> ! <DIV CLASS="footer"><a href="http://www.microsoft.com/msj/0197/exception/exception.htm">A ! Crash Course on the Depths of Win32 Structured Exception Handling, MSJ January ! 1997</a></DIV> ! </li> ! <li> ! <DIV CLASS="footer"><a href="http://www.microsoft.com/msj/0497/hood/hood0497.htm">MSJEXHND ! - Part 1, Under the Hood, MSJ April 1997</a></DIV> ! </li> ! <li> ! <DIV CLASS="footer"><a href="http://www.microsoft.com/msj/0597/hood/hood0597.htm">MSJEXHND ! - Part 2, Under the Hood, MSJ May 1997</a></DIV> ! </li> ! <li><a href=http://www.microsoft.com/msj/0898/bugslayer0898.htm>Bugslayer, MSJ, ! August 1998</a></li> ! <li> ! <DIV CLASS="footer"><a href="http://msdn.microsoft.com/library/techart/msdn_debug.htm"> ! The Win32 Debugging Application Programming Interface</a></DIV> ! </li> ! </ul> ! <H2>Contact</H2> ! <p>José Fonseca</p> ! <p><a href="mailto:em...@fe...">em...@fe...</a></p> ! <p><a href="http://www.fe.up.pt/~em96115/gnu-win32">http://www.fe.up.pt/~em96115/gnu-win32</a></p> ! <DIV CLASS="footer"> ! <p> </p> ! </DIV> ! ! </BODY> ! </HTML> |
|
From: <in...@us...> - 2002-05-26 10:14:00
|
Update of /cvsroot/mingw/utils/drmingw In directory usw-pr-cvs1:/tmp/cvs-serv2405/drmingw Modified Files: Makefile.old Log Message: Convert some text files to Unix format Index: Makefile.old =================================================================== RCS file: /cvsroot/mingw/utils/drmingw/Makefile.old,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Makefile.old 10 Apr 2002 13:39:05 -0000 1.1 --- Makefile.old 26 May 2002 10:13:57 -0000 1.2 *************** *** 1,125 **** ! # Makefile ! ! ! # Standard Variables ! ! CC=gcc ! CFLAGS=-g -Wall -Os -mwindows ! INCLUDES=-I. -Iinclude ! CXX=g++ ! CXXFLAGS=$(CFLAGS) -fexceptions ! DEP_FLAGS=-MM ! LD=$(CC) $(CFLAGS) ! LDFLAGS=-L. ! DLLWRAP=dllwrap ! LIBS=-lbfd -liberty ! RC=windres ! RCFLAGS=-O COFF ! ! ! # Choose the one you have ! ! #CFUNCTIONS=touch $@ ! CFUNCTIONS=rm -f $@ ; cfunctions -i $< ! ! MAKEDEPENDS=rm -f $@ ; mkdepend $(SRCS) $(INCLUDES) -f$@ ! #MAKEDEPENDS=$(CXX) $(CXXFLAGS) $(DEP_FLAGS) $(INCLUDES) $(SRCS) > $@ ! ! ! # Main Target Defines ! ! TARGET=../bin/drmingw.exe ! ! SRCS=\ ! main.c \ ! debugger.c \ ! dialog.c \ ! log.c \ ! misc.c \ ! module.c \ ! symbols.c \ ! prdbg.c \ ! rddbg.c \ ! debug.c \ ! debugx.c \ ! stabs.c \ ! ieee.c \ ! rdcoff.c \ ! exchndl.c ! ! OBJS=$(SRCS:%.c=%.o) resource.res ! ! ! # Suffix Rules ! ! %.h: ! @echo "Warning: Can't find $@." ! ! %.o: %.c ! $(CC) $(CFLAGS) $(INCLUDES) -c -o $@ $< ! ! %.o: %.cxx ! $(CXX) $(CXXFLAGS) $(INCLUDES) -c -o $@ $< ! ! %.exe: %.o ! $(LD) $(LDFLAGS) -o $@ $^ $(LIBS) ! ! %.res: %.rc ! $(RC) $(RCFLAGS) -o $@ $< ! ! ! # Targets ! ! .PHONY: all ! all: $(TARGET) ../bin/exchndl.dll ! ! ! $(TARGET): .dependencies $(OBJS) ! $(LD) $(LDFLAGS) -o $@ $(OBJS) $(LIBS) ! ! ../bin/exchndl.dll: LDFLAGS += -s ! ../bin/exchndl.dll: exchndl.o ! $(DLLWRAP) $(LDFLAGS) -o $@ $^ $(LIBS) ! ! ! .PHONY: package ! package: ! -rm -f ../drmingw-snapshot.tar.bz2 ! tar -C ../ -cIf ../drmingw-snapshot.tar.bz2 . --exclude=*.bak --exclude=*.o --exclude=*.res --exclude=*.a ! ! .PHONY: clean ! clean: ! -rm -f *.o *.res ../bin/* ! ! ! # Automatic Headers ! ! debugger.h: debugger.c ! $(CFUNCTIONS) ! ! dialog.h: dialog.c ! $(CFUNCTIONS) ! ! log.h: log.c ! $(CFUNCTIONS) ! ! misc.h: misc.c ! $(CFUNCTIONS) ! ! module.h: module.c ! $(CFUNCTIONS) ! ! symbols.h: symbols.c ! $(CFUNCTIONS) ! ! ! # Dependencies ! ! resource.res: resource.rc resource.h ! ! # Automatic Dependencies ! ! .dependencies: Makefile $(SRCS) ! $(MAKEDEPENDS) ! ! -include .dependencies --- 1,125 ---- ! # Makefile ! ! ! # Standard Variables ! ! CC=gcc ! CFLAGS=-g -Wall -Os -mwindows ! INCLUDES=-I. -Iinclude ! CXX=g++ ! CXXFLAGS=$(CFLAGS) -fexceptions ! DEP_FLAGS=-MM ! LD=$(CC) $(CFLAGS) ! LDFLAGS=-L. ! DLLWRAP=dllwrap ! LIBS=-lbfd -liberty ! RC=windres ! RCFLAGS=-O COFF ! ! ! # Choose the one you have ! ! #CFUNCTIONS=touch $@ ! CFUNCTIONS=rm -f $@ ; cfunctions -i $< ! ! MAKEDEPENDS=rm -f $@ ; mkdepend $(SRCS) $(INCLUDES) -f$@ ! #MAKEDEPENDS=$(CXX) $(CXXFLAGS) $(DEP_FLAGS) $(INCLUDES) $(SRCS) > $@ ! ! ! # Main Target Defines ! ! TARGET=../bin/drmingw.exe ! ! SRCS=\ ! main.c \ ! debugger.c \ ! dialog.c \ ! log.c \ ! misc.c \ ! module.c \ ! symbols.c \ ! prdbg.c \ ! rddbg.c \ ! debug.c \ ! debugx.c \ ! stabs.c \ ! ieee.c \ ! rdcoff.c \ ! exchndl.c ! ! OBJS=$(SRCS:%.c=%.o) resource.res ! ! ! # Suffix Rules ! ! %.h: ! @echo "Warning: Can't find $@." ! ! %.o: %.c ! $(CC) $(CFLAGS) $(INCLUDES) -c -o $@ $< ! ! %.o: %.cxx ! $(CXX) $(CXXFLAGS) $(INCLUDES) -c -o $@ $< ! ! %.exe: %.o ! $(LD) $(LDFLAGS) -o $@ $^ $(LIBS) ! ! %.res: %.rc ! $(RC) $(RCFLAGS) -o $@ $< ! ! ! # Targets ! ! .PHONY: all ! all: $(TARGET) ../bin/exchndl.dll ! ! ! $(TARGET): .dependencies $(OBJS) ! $(LD) $(LDFLAGS) -o $@ $(OBJS) $(LIBS) ! ! ../bin/exchndl.dll: LDFLAGS += -s ! ../bin/exchndl.dll: exchndl.o ! $(DLLWRAP) $(LDFLAGS) -o $@ $^ $(LIBS) ! ! ! .PHONY: package ! package: ! -rm -f ../drmingw-snapshot.tar.bz2 ! tar -C ../ -cIf ../drmingw-snapshot.tar.bz2 . --exclude=*.bak --exclude=*.o --exclude=*.res --exclude=*.a ! ! .PHONY: clean ! clean: ! -rm -f *.o *.res ../bin/* ! ! ! # Automatic Headers ! ! debugger.h: debugger.c ! $(CFUNCTIONS) ! ! dialog.h: dialog.c ! $(CFUNCTIONS) ! ! log.h: log.c ! $(CFUNCTIONS) ! ! misc.h: misc.c ! $(CFUNCTIONS) ! ! module.h: module.c ! $(CFUNCTIONS) ! ! symbols.h: symbols.c ! $(CFUNCTIONS) ! ! ! # Dependencies ! ! resource.res: resource.rc resource.h ! ! # Automatic Dependencies ! ! .dependencies: Makefile $(SRCS) ! $(MAKEDEPENDS) ! ! -include .dependencies |
|
From: <in...@us...> - 2002-05-26 10:06:04
|
Update of /cvsroot/mingw/runtime/samples/wintest
In directory usw-pr-cvs1:/tmp/cvs-serv1023/samples/wintest
Modified Files:
jamfile test.c
Log Message:
Convert some text files to Unix format
Index: jamfile
===================================================================
RCS file: /cvsroot/mingw/runtime/samples/wintest/jamfile,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** jamfile 4 Jun 2001 23:26:03 -0000 1.1.1.1
--- jamfile 26 May 2002 10:06:00 -0000 1.2
***************
*** 1,8 ****
! #
! # A example of Win32 GUI programming in C.
! #
!
! Main test.exe : test.c ;
!
! Gui test.exe ;
!
--- 1,8 ----
! #
! # A example of Win32 GUI programming in C.
! #
!
! Main test.exe : test.c ;
!
! Gui test.exe ;
!
Index: test.c
===================================================================
RCS file: /cvsroot/mingw/runtime/samples/wintest/test.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** test.c 4 Jun 2001 23:26:03 -0000 1.1.1.1
--- test.c 26 May 2002 10:06:00 -0000 1.2
***************
*** 1,212 ****
! /*
! * A basic example of Win32 programming in C.
! *
! * This source code is in the PUBLIC DOMAIN and has NO WARRANTY.
! *
! * Colin Peters <co...@bi...>
! */
!
! #include <windows.h>
! #include <string.h>
!
! /*
! * This is the window function for the main window. Whenever a message is
! * dispatched using DispatchMessage (or sent with SendMessage) this function
! * gets called with the contents of the message.
! */
! LRESULT CALLBACK
! MainWndProc (HWND hwnd, UINT nMsg, WPARAM wParam, LPARAM lParam)
! {
! /* The window handle for the "Click Me" button. */
! static HWND hwndButton = 0;
! static int cx, cy; /* Height and width of our button. */
!
! HDC hdc; /* A device context used for drawing */
! PAINTSTRUCT ps; /* Also used during window drawing */
! RECT rc; /* A rectangle used during drawing */
!
! /*
! * Perform processing based on what kind of message we got.
! */
! switch (nMsg)
! {
! case WM_CREATE:
! {
! /* The window is being created. Create our button
! * window now. */
! TEXTMETRIC tm;
!
! /* First we use the system fixed font size to choose
! * a nice button size. */
! hdc = GetDC (hwnd);
! SelectObject (hdc, GetStockObject (SYSTEM_FIXED_FONT));
! GetTextMetrics (hdc, &tm);
! cx = tm.tmAveCharWidth * 30;
! cy = (tm.tmHeight + tm.tmExternalLeading) * 2;
! ReleaseDC (hwnd, hdc);
!
! /* Now create the button */
! hwndButton = CreateWindow (
! "button", /* Builtin button class */
! "Click Here",
! WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
! 0, 0, cx, cy,
! hwnd, /* Parent is this window. */
! (HMENU) 1, /* Control ID: 1 */
! ((LPCREATESTRUCT) lParam)->hInstance,
! NULL
! );
!
! return 0;
! break;
! }
!
! case WM_DESTROY:
! /* The window is being destroyed, close the application
! * (the child button gets destroyed automatically). */
! PostQuitMessage (0);
! return 0;
! break;
!
! case WM_PAINT:
! /* The window needs to be painted (redrawn). */
! hdc = BeginPaint (hwnd, &ps);
! GetClientRect (hwnd, &rc);
!
! /* Draw "Hello, World" in the middle of the upper
! * half of the window. */
! rc.bottom = rc.bottom / 2;
! DrawText (hdc, "Hello, World", -1, &rc,
! DT_SINGLELINE | DT_CENTER | DT_VCENTER);
!
! EndPaint (hwnd, &ps);
! return 0;
! break;
!
! case WM_SIZE:
! /* The window size is changing. If the button exists
! * then place it in the center of the bottom half of
! * the window. */
! if (hwndButton &&
! (wParam == SIZEFULLSCREEN ||
! wParam == SIZENORMAL)
! )
! {
! rc.left = (LOWORD(lParam) - cx) / 2;
! rc.top = HIWORD(lParam) * 3 / 4 - cy / 2;
! MoveWindow (
! hwndButton,
! rc.left, rc.top, cx, cy, TRUE);
! }
! break;
!
! case WM_COMMAND:
! /* Check the control ID, notification code and
! * control handle to see if this is a button click
! * message from our child button. */
! if (LOWORD(wParam) == 1 &&
! HIWORD(wParam) == BN_CLICKED &&
! (HWND) lParam == hwndButton)
! {
! /* Our button was clicked. Close the window. */
! DestroyWindow (hwnd);
! }
! return 0;
! break;
! }
!
! /* If we don't handle a message completely we hand it to the system
! * provided default window function. */
! return DefWindowProc (hwnd, nMsg, wParam, lParam);
! }
!
!
! int STDCALL
! WinMain (HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpCmd, int nShow)
! {
! HWND hwndMain; /* Handle for the main window. */
! MSG msg; /* A Win32 message structure. */
! WNDCLASSEX wndclass; /* A window class structure. */
! char* szMainWndClass = "WinTestWin";
! /* The name of the main window class */
!
! /*
! * First we create a window class for our main window.
! */
!
! /* Initialize the entire structure to zero. */
! memset (&wndclass, 0, sizeof(WNDCLASSEX));
!
! /* This class is called WinTestWin */
! wndclass.lpszClassName = szMainWndClass;
!
! /* cbSize gives the size of the structure for extensibility. */
! wndclass.cbSize = sizeof(WNDCLASSEX);
!
! /* All windows of this class redraw when resized. */
! wndclass.style = CS_HREDRAW | CS_VREDRAW;
!
! /* All windows of this class use the MainWndProc window function. */
! wndclass.lpfnWndProc = MainWndProc;
!
! /* This class is used with the current program instance. */
! wndclass.hInstance = hInst;
!
! /* Use standard application icon and arrow cursor provided by the OS */
! wndclass.hIcon = LoadIcon (NULL, IDI_APPLICATION);
! wndclass.hIconSm = LoadIcon (NULL, IDI_APPLICATION);
! wndclass.hCursor = LoadCursor (NULL, IDC_ARROW);
!
! /* Color the background white */
! wndclass.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH);
!
! /*
! * Now register the window class for use.
! */
! RegisterClassEx (&wndclass);
!
! /*
! * Create our main window using that window class.
! */
! hwndMain = CreateWindow (
! szMainWndClass, /* Class name */
! "Hello", /* Caption */
! WS_OVERLAPPEDWINDOW, /* Style */
! CW_USEDEFAULT, /* Initial x (use default) */
! CW_USEDEFAULT, /* Initial y (use default) */
! CW_USEDEFAULT, /* Initial x size (use default) */
! CW_USEDEFAULT, /* Initial y size (use default) */
! NULL, /* No parent window */
! NULL, /* No menu */
! hInst, /* This program instance */
! NULL /* Creation parameters */
! );
!
! /*
! * Display the window which we just created (using the nShow
! * passed by the OS, which allows for start minimized and that
! * sort of thing).
! */
! ShowWindow (hwndMain, nShow);
! UpdateWindow (hwndMain);
!
! /*
! * The main message loop. All messages being sent to the windows
! * of the application (or at least the primary thread) are retrieved
! * by the GetMessage call, then translated (mainly for keyboard
! * messages) and dispatched to the appropriate window procedure.
! * This is the simplest kind of message loop. More complex loops
! * are required for idle processing or handling modeless dialog
! * boxes. When one of the windows calls PostQuitMessage GetMessage
! * will return zero and the wParam of the message will be filled
! * with the argument to PostQuitMessage. The loop will end and
! * the application will close.
! */
! while (GetMessage (&msg, NULL, 0, 0))
! {
! TranslateMessage (&msg);
! DispatchMessage (&msg);
! }
! return msg.wParam;
! }
!
--- 1,212 ----
! /*
! * A basic example of Win32 programming in C.
! *
! * This source code is in the PUBLIC DOMAIN and has NO WARRANTY.
! *
! * Colin Peters <co...@bi...>
! */
!
! #include <windows.h>
! #include <string.h>
!
! /*
! * This is the window function for the main window. Whenever a message is
! * dispatched using DispatchMessage (or sent with SendMessage) this function
! * gets called with the contents of the message.
! */
! LRESULT CALLBACK
! MainWndProc (HWND hwnd, UINT nMsg, WPARAM wParam, LPARAM lParam)
! {
! /* The window handle for the "Click Me" button. */
! static HWND hwndButton = 0;
! static int cx, cy; /* Height and width of our button. */
!
! HDC hdc; /* A device context used for drawing */
! PAINTSTRUCT ps; /* Also used during window drawing */
! RECT rc; /* A rectangle used during drawing */
!
! /*
! * Perform processing based on what kind of message we got.
! */
! switch (nMsg)
! {
! case WM_CREATE:
! {
! /* The window is being created. Create our button
! * window now. */
! TEXTMETRIC tm;
!
! /* First we use the system fixed font size to choose
! * a nice button size. */
! hdc = GetDC (hwnd);
! SelectObject (hdc, GetStockObject (SYSTEM_FIXED_FONT));
! GetTextMetrics (hdc, &tm);
! cx = tm.tmAveCharWidth * 30;
! cy = (tm.tmHeight + tm.tmExternalLeading) * 2;
! ReleaseDC (hwnd, hdc);
!
! /* Now create the button */
! hwndButton = CreateWindow (
! "button", /* Builtin button class */
! "Click Here",
! WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
! 0, 0, cx, cy,
! hwnd, /* Parent is this window. */
! (HMENU) 1, /* Control ID: 1 */
! ((LPCREATESTRUCT) lParam)->hInstance,
! NULL
! );
!
! return 0;
! break;
! }
!
! case WM_DESTROY:
! /* The window is being destroyed, close the application
! * (the child button gets destroyed automatically). */
! PostQuitMessage (0);
! return 0;
! break;
!
! case WM_PAINT:
! /* The window needs to be painted (redrawn). */
! hdc = BeginPaint (hwnd, &ps);
! GetClientRect (hwnd, &rc);
!
! /* Draw "Hello, World" in the middle of the upper
! * half of the window. */
! rc.bottom = rc.bottom / 2;
! DrawText (hdc, "Hello, World", -1, &rc,
! DT_SINGLELINE | DT_CENTER | DT_VCENTER);
!
! EndPaint (hwnd, &ps);
! return 0;
! break;
!
! case WM_SIZE:
! /* The window size is changing. If the button exists
! * then place it in the center of the bottom half of
! * the window. */
! if (hwndButton &&
! (wParam == SIZEFULLSCREEN ||
! wParam == SIZENORMAL)
! )
! {
! rc.left = (LOWORD(lParam) - cx) / 2;
! rc.top = HIWORD(lParam) * 3 / 4 - cy / 2;
! MoveWindow (
! hwndButton,
! rc.left, rc.top, cx, cy, TRUE);
! }
! break;
!
! case WM_COMMAND:
! /* Check the control ID, notification code and
! * control handle to see if this is a button click
! * message from our child button. */
! if (LOWORD(wParam) == 1 &&
! HIWORD(wParam) == BN_CLICKED &&
! (HWND) lParam == hwndButton)
! {
! /* Our button was clicked. Close the window. */
! DestroyWindow (hwnd);
! }
! return 0;
! break;
! }
!
! /* If we don't handle a message completely we hand it to the system
! * provided default window function. */
! return DefWindowProc (hwnd, nMsg, wParam, lParam);
! }
!
!
! int STDCALL
! WinMain (HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpCmd, int nShow)
! {
! HWND hwndMain; /* Handle for the main window. */
! MSG msg; /* A Win32 message structure. */
! WNDCLASSEX wndclass; /* A window class structure. */
! char* szMainWndClass = "WinTestWin";
! /* The name of the main window class */
!
! /*
! * First we create a window class for our main window.
! */
!
! /* Initialize the entire structure to zero. */
! memset (&wndclass, 0, sizeof(WNDCLASSEX));
!
! /* This class is called WinTestWin */
! wndclass.lpszClassName = szMainWndClass;
!
! /* cbSize gives the size of the structure for extensibility. */
! wndclass.cbSize = sizeof(WNDCLASSEX);
!
! /* All windows of this class redraw when resized. */
! wndclass.style = CS_HREDRAW | CS_VREDRAW;
!
! /* All windows of this class use the MainWndProc window function. */
! wndclass.lpfnWndProc = MainWndProc;
!
! /* This class is used with the current program instance. */
! wndclass.hInstance = hInst;
!
! /* Use standard application icon and arrow cursor provided by the OS */
! wndclass.hIcon = LoadIcon (NULL, IDI_APPLICATION);
! wndclass.hIconSm = LoadIcon (NULL, IDI_APPLICATION);
! wndclass.hCursor = LoadCursor (NULL, IDC_ARROW);
!
! /* Color the background white */
! wndclass.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH);
!
! /*
! * Now register the window class for use.
! */
! RegisterClassEx (&wndclass);
!
! /*
! * Create our main window using that window class.
! */
! hwndMain = CreateWindow (
! szMainWndClass, /* Class name */
! "Hello", /* Caption */
! WS_OVERLAPPEDWINDOW, /* Style */
! CW_USEDEFAULT, /* Initial x (use default) */
! CW_USEDEFAULT, /* Initial y (use default) */
! CW_USEDEFAULT, /* Initial x size (use default) */
! CW_USEDEFAULT, /* Initial y size (use default) */
! NULL, /* No parent window */
! NULL, /* No menu */
! hInst, /* This program instance */
! NULL /* Creation parameters */
! );
!
! /*
! * Display the window which we just created (using the nShow
! * passed by the OS, which allows for start minimized and that
! * sort of thing).
! */
! ShowWindow (hwndMain, nShow);
! UpdateWindow (hwndMain);
!
! /*
! * The main message loop. All messages being sent to the windows
! * of the application (or at least the primary thread) are retrieved
! * by the GetMessage call, then translated (mainly for keyboard
! * messages) and dispatched to the appropriate window procedure.
! * This is the simplest kind of message loop. More complex loops
! * are required for idle processing or handling modeless dialog
! * boxes. When one of the windows calls PostQuitMessage GetMessage
! * will return zero and the wParam of the message will be filled
! * with the argument to PostQuitMessage. The loop will end and
! * the application will close.
! */
! while (GetMessage (&msg, NULL, 0, 0))
! {
! TranslateMessage (&msg);
! DispatchMessage (&msg);
! }
! return msg.wParam;
! }
!
|
|
From: <in...@us...> - 2002-05-26 10:06:04
|
Update of /cvsroot/mingw/runtime/samples/simpledll
In directory usw-pr-cvs1:/tmp/cvs-serv1023/samples/simpledll
Modified Files:
dll.c dll.cpp dll.def exe.c jamfile
Log Message:
Convert some text files to Unix format
Index: dll.c
===================================================================
RCS file: /cvsroot/mingw/runtime/samples/simpledll/dll.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** dll.c 4 Jun 2001 23:26:03 -0000 1.1.1.1
--- dll.c 26 May 2002 10:06:00 -0000 1.2
***************
*** 1,33 ****
!
! #include <windows.h>
!
! BOOL WINAPI
! DllMain (HANDLE hDll, DWORD dwReason, LPVOID lpReserved)
! {
! switch (dwReason)
! {
! case DLL_PROCESS_ATTACH:
! printf ("DLL Attached.\n");
! break;
!
! case DLL_PROCESS_DETACH:
! printf ("DLL Detached.\n");
! break;
!
! case DLL_THREAD_ATTACH:
! printf ("DLL Thread Attached.\n");
! break;
!
! case DLL_THREAD_DETACH:
! printf ("DLL Thread Detached.\n");
! break;
! }
! return TRUE;
! }
!
! void
! Test ()
! {
! printf ("Test Function called!\n");
! }
!
--- 1,33 ----
!
! #include <windows.h>
!
! BOOL WINAPI
! DllMain (HANDLE hDll, DWORD dwReason, LPVOID lpReserved)
! {
! switch (dwReason)
! {
! case DLL_PROCESS_ATTACH:
! printf ("DLL Attached.\n");
! break;
!
! case DLL_PROCESS_DETACH:
! printf ("DLL Detached.\n");
! break;
!
! case DLL_THREAD_ATTACH:
! printf ("DLL Thread Attached.\n");
! break;
!
! case DLL_THREAD_DETACH:
! printf ("DLL Thread Detached.\n");
! break;
! }
! return TRUE;
! }
!
! void
! Test ()
! {
! printf ("Test Function called!\n");
! }
!
Index: dll.cpp
===================================================================
RCS file: /cvsroot/mingw/runtime/samples/simpledll/dll.cpp,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** dll.cpp 4 Jun 2001 23:26:03 -0000 1.1.1.1
--- dll.cpp 26 May 2002 10:06:00 -0000 1.2
***************
*** 1,44 ****
! //
! // This is a C++ version of the code in dll.c. NOTE that you need to put
! // extern "C" { ... } around DllMain or it will not be called when your
! // Dll starts up! (It will get name mangled as a C++ function and the C
! // default version in libmingw32.a will get called instead.)
! //
!
! #include <windows.h>
!
! #include <iostream>
!
! extern "C" {
!
! BOOL WINAPI
! DllMain (HANDLE hDll, DWORD dwReason, LPVOID lpReserved)
! {
! switch (dwReason)
! {
! case DLL_PROCESS_ATTACH:
! cout << "Dll Attached" << endl ;
! break;
!
! case DLL_PROCESS_DETACH:
! cout << "Dll Detached" << endl ;
! break;
!
! case DLL_THREAD_ATTACH:
! printf ("DLL Thread Attached.\n");
! break;
!
! case DLL_THREAD_DETACH:
! printf ("DLL Thread Detached.\n");
! break;
! }
! return TRUE;
! }
!
! void
! Test ()
! {
! printf ("Test Function called!\n");
! }
!
! };
--- 1,44 ----
! //
! // This is a C++ version of the code in dll.c. NOTE that you need to put
! // extern "C" { ... } around DllMain or it will not be called when your
! // Dll starts up! (It will get name mangled as a C++ function and the C
! // default version in libmingw32.a will get called instead.)
! //
!
! #include <windows.h>
!
! #include <iostream>
!
! extern "C" {
!
! BOOL WINAPI
! DllMain (HANDLE hDll, DWORD dwReason, LPVOID lpReserved)
! {
! switch (dwReason)
! {
! case DLL_PROCESS_ATTACH:
! cout << "Dll Attached" << endl ;
! break;
!
! case DLL_PROCESS_DETACH:
! cout << "Dll Detached" << endl ;
! break;
!
! case DLL_THREAD_ATTACH:
! printf ("DLL Thread Attached.\n");
! break;
!
! case DLL_THREAD_DETACH:
! printf ("DLL Thread Detached.\n");
! break;
! }
! return TRUE;
! }
!
! void
! Test ()
! {
! printf ("Test Function called!\n");
! }
!
! };
Index: dll.def
===================================================================
RCS file: /cvsroot/mingw/runtime/samples/simpledll/dll.def,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** dll.def 4 Jun 2001 23:26:03 -0000 1.1.1.1
--- dll.def 26 May 2002 10:06:00 -0000 1.2
***************
*** 1,2 ****
! EXPORTS
! Test
--- 1,2 ----
! EXPORTS
! Test
Index: exe.c
===================================================================
RCS file: /cvsroot/mingw/runtime/samples/simpledll/exe.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** exe.c 4 Jun 2001 23:26:03 -0000 1.1.1.1
--- exe.c 26 May 2002 10:06:00 -0000 1.2
***************
*** 1,13 ****
! #include <stdio.h>
!
! extern void Test();
!
! int main()
! {
! printf ("Program started.\n");
! Test ();
! printf ("Program ends.\n");
!
! return 0;
! }
!
--- 1,13 ----
! #include <stdio.h>
!
! extern void Test();
!
! int main()
! {
! printf ("Program started.\n");
! Test ();
! printf ("Program ends.\n");
!
! return 0;
! }
!
Index: jamfile
===================================================================
RCS file: /cvsroot/mingw/runtime/samples/simpledll/jamfile,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** jamfile 4 Jun 2001 23:26:03 -0000 1.1.1.1
--- jamfile 26 May 2002 10:06:00 -0000 1.2
***************
*** 1,14 ****
!
! Dll dll.dll : dll.c ;
!
! ImportLib libdll.a : dll.def ;
!
!
! Main exe.exe : exe.c ;
!
! LinkLibraries exe.exe : libdll.a ;
!
! DEPENDS exe.exe : dll.dll ;
!
! LINKFLAGS on exe.exe = $(LINKFLAGS) -L. ;
!
--- 1,14 ----
!
! Dll dll.dll : dll.c ;
!
! ImportLib libdll.a : dll.def ;
!
!
! Main exe.exe : exe.c ;
!
! LinkLibraries exe.exe : libdll.a ;
!
! DEPENDS exe.exe : dll.dll ;
!
! LINKFLAGS on exe.exe = $(LINKFLAGS) -L. ;
!
|
|
From: <in...@us...> - 2002-05-26 10:06:03
|
Update of /cvsroot/mingw/runtime/samples/filehand
In directory usw-pr-cvs1:/tmp/cvs-serv1023/samples/filehand
Modified Files:
filehand.c jamfile junk.txt
Log Message:
Convert some text files to Unix format
Index: filehand.c
===================================================================
RCS file: /cvsroot/mingw/runtime/samples/filehand/filehand.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** filehand.c 4 Jun 2001 23:26:03 -0000 1.1.1.1
--- filehand.c 26 May 2002 10:05:59 -0000 1.2
***************
*** 1,57 ****
! /*
! * An example showing how you can obtain the UNIX-ish file number from a
! * FILE* and in turn how you can get the Win32 HANDLE of the file from
! * the file number.
! *
! * This code is in the PUBLIC DOMAIN and has NO WARRANTY.
! *
! * Colin Peters <co...@fu...>
! */
!
! #include <stdio.h>
! #include <io.h>
! #include <windows.h>
!
! int
! main (int argc, char* argv[])
! {
! char* szFileName;
! FILE* fileIn;
! int fnIn;
! HANDLE hFileIn;
! char caBuf[81];
! int nRead;
!
! if (argc >= 2)
! {
! szFileName = argv[1];
! }
! else
! {
! szFileName = "junk.txt";
! }
!
! fileIn = fopen (szFileName, "r");
!
! if (!fileIn)
! {
! printf ("Could not open %s for reading\n", szFileName);
! exit(1);
! }
!
! fnIn = fileno (fileIn);
! hFileIn = (HANDLE) _get_osfhandle (fnIn);
!
! printf ("OS file handle %d\n", (int) hFileIn);
!
! ReadFile (hFileIn, caBuf, 80, &nRead, NULL);
!
! printf ("Read %d bytes using ReadFile.\n", nRead);
!
! caBuf[nRead] = '\0';
!
! printf ("\"%s\"\n", caBuf);
!
! fclose (fileIn);
! }
!
--- 1,57 ----
! /*
! * An example showing how you can obtain the UNIX-ish file number from a
! * FILE* and in turn how you can get the Win32 HANDLE of the file from
! * the file number.
! *
! * This code is in the PUBLIC DOMAIN and has NO WARRANTY.
! *
! * Colin Peters <co...@fu...>
! */
!
! #include <stdio.h>
! #include <io.h>
! #include <windows.h>
!
! int
! main (int argc, char* argv[])
! {
! char* szFileName;
! FILE* fileIn;
! int fnIn;
! HANDLE hFileIn;
! char caBuf[81];
! int nRead;
!
! if (argc >= 2)
! {
! szFileName = argv[1];
! }
! else
! {
! szFileName = "junk.txt";
! }
!
! fileIn = fopen (szFileName, "r");
!
! if (!fileIn)
! {
! printf ("Could not open %s for reading\n", szFileName);
! exit(1);
! }
!
! fnIn = fileno (fileIn);
! hFileIn = (HANDLE) _get_osfhandle (fnIn);
!
! printf ("OS file handle %d\n", (int) hFileIn);
!
! ReadFile (hFileIn, caBuf, 80, &nRead, NULL);
!
! printf ("Read %d bytes using ReadFile.\n", nRead);
!
! caBuf[nRead] = '\0';
!
! printf ("\"%s\"\n", caBuf);
!
! fclose (fileIn);
! }
!
Index: jamfile
===================================================================
RCS file: /cvsroot/mingw/runtime/samples/filehand/jamfile,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** jamfile 4 Jun 2001 23:26:03 -0000 1.1.1.1
--- jamfile 26 May 2002 10:05:59 -0000 1.2
***************
*** 1,3 ****
!
! Main filehand.exe : filehand.c ;
!
--- 1,3 ----
!
! Main filehand.exe : filehand.c ;
!
Index: junk.txt
===================================================================
RCS file: /cvsroot/mingw/runtime/samples/filehand/junk.txt,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** junk.txt 4 Jun 2001 23:26:03 -0000 1.1.1.1
--- junk.txt 26 May 2002 10:05:59 -0000 1.2
***************
*** 1 ****
! This is a test file.
--- 1 ----
! This is a test file.
|
|
From: <in...@us...> - 2002-05-26 10:06:03
|
Update of /cvsroot/mingw/runtime/samples/fmode
In directory usw-pr-cvs1:/tmp/cvs-serv1023/samples/fmode
Modified Files:
all.c jamfile readme.txt test.c
Log Message:
Convert some text files to Unix format
Index: all.c
===================================================================
RCS file: /cvsroot/mingw/runtime/samples/fmode/all.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** all.c 4 Jun 2001 23:26:03 -0000 1.1.1.1
--- all.c 26 May 2002 10:06:00 -0000 1.2
***************
*** 1,46 ****
! /*
! * A sample program demonstrating how to use _CRT_fmode to change the default
! * file opening mode to binary AND change stdin, stdout and stderr. Redirect
! * stdout to a file from the command line to see the difference.
! *
! * Also try directing a file into stdin. If you type into stdin you will get
! * \r\n at the end of every line... unlike UNIX. But at least if you
! * redirect a file in you will get exactly the characters in the file as input.
! *
! * THIS CODE IS IN THE PUBLIC DOMAIN.
! *
! * Colin Peters <co...@fu...>
! */
!
! #include <stdio.h>
! #include <fcntl.h>
!
! unsigned int _CRT_fmode = _O_BINARY;
!
! main ()
! {
! char* sz = "This is line one.\nThis is line two.\n";
! FILE* fp;
! int c;
!
! printf (sz);
!
! /* Note how this fopen does NOT indicate "wb" to open the file in
! * binary mode. */
! fp = fopen ("all.out", "w");
!
! fprintf (fp, sz);
!
! fclose (fp);
!
! if (_isatty (_fileno(stdin)))
! {
! fprintf (stderr, "Waiting for input, press Ctrl-Z to finish.\n");
! }
!
! while ((c = fgetc(stdin)) != EOF)
! {
! printf ("\'%c\' %02X\n", (char) c, c);
! }
! }
!
--- 1,46 ----
! /*
! * A sample program demonstrating how to use _CRT_fmode to change the default
! * file opening mode to binary AND change stdin, stdout and stderr. Redirect
! * stdout to a file from the command line to see the difference.
! *
! * Also try directing a file into stdin. If you type into stdin you will get
! * \r\n at the end of every line... unlike UNIX. But at least if you
! * redirect a file in you will get exactly the characters in the file as input.
! *
! * THIS CODE IS IN THE PUBLIC DOMAIN.
! *
! * Colin Peters <co...@fu...>
! */
!
! #include <stdio.h>
! #include <fcntl.h>
!
! unsigned int _CRT_fmode = _O_BINARY;
!
! main ()
! {
! char* sz = "This is line one.\nThis is line two.\n";
! FILE* fp;
! int c;
!
! printf (sz);
!
! /* Note how this fopen does NOT indicate "wb" to open the file in
! * binary mode. */
! fp = fopen ("all.out", "w");
!
! fprintf (fp, sz);
!
! fclose (fp);
!
! if (_isatty (_fileno(stdin)))
! {
! fprintf (stderr, "Waiting for input, press Ctrl-Z to finish.\n");
! }
!
! while ((c = fgetc(stdin)) != EOF)
! {
! printf ("\'%c\' %02X\n", (char) c, c);
! }
! }
!
Index: jamfile
===================================================================
RCS file: /cvsroot/mingw/runtime/samples/fmode/jamfile,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** jamfile 4 Jun 2001 23:26:03 -0000 1.1.1.1
--- jamfile 26 May 2002 10:06:00 -0000 1.2
***************
*** 1,5 ****
!
! Main test.exe : test.c ;
!
! Main all.exe : all.c ;
!
--- 1,5 ----
!
! Main test.exe : test.c ;
!
! Main all.exe : all.c ;
!
Index: readme.txt
===================================================================
RCS file: /cvsroot/mingw/runtime/samples/fmode/readme.txt,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** readme.txt 4 Jun 2001 23:26:03 -0000 1.1.1.1
--- readme.txt 26 May 2002 10:06:00 -0000 1.2
***************
*** 1,5 ****
!
! These two demos show how _fmode and _CRT_fmode can be used to modify the
! default file opening mode (text vs. binary) and/or the mode of the standard
! file handles.
!
--- 1,5 ----
!
! These two demos show how _fmode and _CRT_fmode can be used to modify the
! default file opening mode (text vs. binary) and/or the mode of the standard
! file handles.
!
Index: test.c
===================================================================
RCS file: /cvsroot/mingw/runtime/samples/fmode/test.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** test.c 4 Jun 2001 23:26:03 -0000 1.1.1.1
--- test.c 26 May 2002 10:06:00 -0000 1.2
***************
*** 1,31 ****
! /*
! * A sample program demonstrating how to use fmode to change the default
! * file opening mode to binary. NOTE: Does not change stdin, stdout or
! * stderr.
! *
! * THIS CODE IS IN THE PUBLIC DOMAIN.
! *
! * Colin Peters <co...@fu...>
! */
!
! #include <stdio.h>
! #include <fcntl.h> /* Required to get _fmode and _O_BINARY */
!
! main ()
! {
! char* sz = "This is line one.\nThis is line two.\n";
! FILE* fp;
!
! _fmode = _O_BINARY;
!
! printf (sz);
!
! /* Note how this fopen does NOT indicate "wb" to open the file in
! * binary mode. */
! fp = fopen ("test.out", "w");
!
! fprintf (fp, sz);
!
! fclose (fp);
! }
!
--- 1,31 ----
! /*
! * A sample program demonstrating how to use fmode to change the default
! * file opening mode to binary. NOTE: Does not change stdin, stdout or
! * stderr.
! *
! * THIS CODE IS IN THE PUBLIC DOMAIN.
! *
! * Colin Peters <co...@fu...>
! */
!
! #include <stdio.h>
! #include <fcntl.h> /* Required to get _fmode and _O_BINARY */
!
! main ()
! {
! char* sz = "This is line one.\nThis is line two.\n";
! FILE* fp;
!
! _fmode = _O_BINARY;
!
! printf (sz);
!
! /* Note how this fopen does NOT indicate "wb" to open the file in
! * binary mode. */
! fp = fopen ("test.out", "w");
!
! fprintf (fp, sz);
!
! fclose (fp);
! }
!
|
Update of /cvsroot/mingw/runtime/samples/seh
In directory usw-pr-cvs1:/tmp/cvs-serv1023/samples/seh
Modified Files:
eh3.c exutil.c exutil.def exutil.h jamfile sehfix.c sehsub.c
sehtest.c
Log Message:
Convert some text files to Unix format
Index: eh3.c
===================================================================
RCS file: /cvsroot/mingw/runtime/samples/seh/eh3.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** eh3.c 4 Jun 2001 23:26:03 -0000 1.1.1.1
--- eh3.c 26 May 2002 10:06:00 -0000 1.2
***************
*** 1,112 ****
! int
! __except_handler3(
! struct _EXCEPTION_RECORD* pExceptionRecord,
! struct EXCEPTION_REGISTRATION* pRegistrationFrame,
! struct _CONTEXT* pContextRecord,
! void* pDispatcherContext
! )
! {
! LONG filterFuncRet;
! LONG trylevel;
! EXCEPTION_POINTERS exceptPtrs;
! PSCOPETABLE pScopeTable;
!
!
! CLD // Clear the direction flag (make no assumptions!)
!
! // if neither the EXCEPTION_UNWINDING nor EXCEPTION_EXIT_UNWIND bit
! // is set... This is true the first time through the handler (the
! // non-unwinding case)
!
! if ( ! (pExceptionRecord->ExceptionFlags
! & (EXCEPTION_UNWINDING | EXCEPTION_EXIT_UNWIND)
! ) )
! {
! // Build the EXCEPTION_POINTERS structure on the stack
! exceptPtrs.ExceptionRecord = pExceptionRecord;
! exceptPtrs.ContextRecord = pContextRecord;
!
! // Put the pointer to the EXCEPTION_POINTERS 4 bytes below the
! // establisher frame. See ASM code for GetExceptionInformation
! *(PDWORD)((PBYTE)pRegistrationFrame - 4) = &exceptPtrs;
!
! // Get initial "trylevel" value
! trylevel = pRegistrationFrame->trylevel
!
! // Get a pointer to the scopetable array
! scopeTable = pRegistrationFrame->scopetable;
!
! search_for_handler:
! if ( pRegistrationFrame->trylevel != TRYLEVEL_NONE )
! {
! if ( pRegistrationFrame->scopetable[trylevel].lpfnFilter )
! {
!
! PUSH EBP // Save this frame EBP
!
! // !!!Very Important!!! Switch to original EBP. This is
! // what allows all locals in the frame to have the same
! // value as before the exception occurred.
!
! EBP = &pRegistrationFrame->_ebp
!
! // Call the filter function
! filterFuncRet = scopetable[trylevel].lpfnFilter();
!
! POP EBP // Restore handler frame EBP
!
! if ( filterFuncRet != EXCEPTION_CONTINUE_SEARCH )
! {
! if ( filterFuncRet < 0 ) // EXCEPTION_CONTINUE_EXECUTION
! return ExceptionContinueExecution;
!
! // If we get here, EXCEPTION_EXECUTE_HANDLER was specified
! scopetable == pRegistrationFrame->scopetable
!
! // Does the actual OS cleanup of registration frames
! // Causes this function to recurse
! __global_unwind2( pRegistrationFrame );
!
!
! // Once we get here, everything is all cleaned up, except
! // for the last frame, where we'll continue execution
! EBP = &pRegistrationFrame->_ebp
!
! __local_unwind2( pRegistrationFrame, trylevel );
!
! // NLG == "non-local-goto" (setjmp/longjmp stuff)
! __NLG_Notify( 1 ); // EAX == scopetable->lpfnHandler
!
! // Set the current trylevel to whatever SCOPETABLE entry
! // was being used when a handler was found
! pRegistrationFrame->trylevel = scopetable->previousTryLevel;
!
! // Call the _except {} block. Never returns.
! pRegistrationFrame->scopetable[trylevel].lpfnHandler();
! }
! }
!
! scopeTable = pRegistrationFrame->scopetable;
! trylevel = scopeTable->previousTryLevel
!
! goto search_for_handler;
! }
! else // trylevel == TRYLEVEL_NONE
! {
! retvalue == DISPOSITION_CONTINUE_SEARCH;
! }
! }
! else // EXCEPTION_UNWINDING or EXCEPTION_EXIT_UNWIND flags are set
! {
! PUSH EBP // Save EBP
!
! EBP = pRegistrationFrame->_ebp // Set EBP for __local_unwind2
!
! __local_unwind2( pRegistrationFrame, TRYLEVEL_NONE )
!
! POP EBP // Restore EBP
!
! retvalue == DISPOSITION_CONTINUE_SEARCH;
! }
! }
!
--- 1,112 ----
! int
! __except_handler3(
! struct _EXCEPTION_RECORD* pExceptionRecord,
! struct EXCEPTION_REGISTRATION* pRegistrationFrame,
! struct _CONTEXT* pContextRecord,
! void* pDispatcherContext
! )
! {
! LONG filterFuncRet;
! LONG trylevel;
! EXCEPTION_POINTERS exceptPtrs;
! PSCOPETABLE pScopeTable;
!
!
! CLD // Clear the direction flag (make no assumptions!)
!
! // if neither the EXCEPTION_UNWINDING nor EXCEPTION_EXIT_UNWIND bit
! // is set... This is true the first time through the handler (the
! // non-unwinding case)
!
! if ( ! (pExceptionRecord->ExceptionFlags
! & (EXCEPTION_UNWINDING | EXCEPTION_EXIT_UNWIND)
! ) )
! {
! // Build the EXCEPTION_POINTERS structure on the stack
! exceptPtrs.ExceptionRecord = pExceptionRecord;
! exceptPtrs.ContextRecord = pContextRecord;
!
! // Put the pointer to the EXCEPTION_POINTERS 4 bytes below the
! // establisher frame. See ASM code for GetExceptionInformation
! *(PDWORD)((PBYTE)pRegistrationFrame - 4) = &exceptPtrs;
!
! // Get initial "trylevel" value
! trylevel = pRegistrationFrame->trylevel
!
! // Get a pointer to the scopetable array
! scopeTable = pRegistrationFrame->scopetable;
!
! search_for_handler:
! if ( pRegistrationFrame->trylevel != TRYLEVEL_NONE )
! {
! if ( pRegistrationFrame->scopetable[trylevel].lpfnFilter )
! {
!
! PUSH EBP // Save this frame EBP
!
! // !!!Very Important!!! Switch to original EBP. This is
! // what allows all locals in the frame to have the same
! // value as before the exception occurred.
!
! EBP = &pRegistrationFrame->_ebp
!
! // Call the filter function
! filterFuncRet = scopetable[trylevel].lpfnFilter();
!
! POP EBP // Restore handler frame EBP
!
! if ( filterFuncRet != EXCEPTION_CONTINUE_SEARCH )
! {
! if ( filterFuncRet < 0 ) // EXCEPTION_CONTINUE_EXECUTION
! return ExceptionContinueExecution;
!
! // If we get here, EXCEPTION_EXECUTE_HANDLER was specified
! scopetable == pRegistrationFrame->scopetable
!
! // Does the actual OS cleanup of registration frames
! // Causes this function to recurse
! __global_unwind2( pRegistrationFrame );
!
!
! // Once we get here, everything is all cleaned up, except
! // for the last frame, where we'll continue execution
! EBP = &pRegistrationFrame->_ebp
!
! __local_unwind2( pRegistrationFrame, trylevel );
!
! // NLG == "non-local-goto" (setjmp/longjmp stuff)
! __NLG_Notify( 1 ); // EAX == scopetable->lpfnHandler
!
! // Set the current trylevel to whatever SCOPETABLE entry
! // was being used when a handler was found
! pRegistrationFrame->trylevel = scopetable->previousTryLevel;
!
! // Call the _except {} block. Never returns.
! pRegistrationFrame->scopetable[trylevel].lpfnHandler();
! }
! }
!
! scopeTable = pRegistrationFrame->scopetable;
! trylevel = scopeTable->previousTryLevel
!
! goto search_for_handler;
! }
! else // trylevel == TRYLEVEL_NONE
! {
! retvalue == DISPOSITION_CONTINUE_SEARCH;
! }
! }
! else // EXCEPTION_UNWINDING or EXCEPTION_EXIT_UNWIND flags are set
! {
! PUSH EBP // Save EBP
!
! EBP = pRegistrationFrame->_ebp // Set EBP for __local_unwind2
!
! __local_unwind2( pRegistrationFrame, TRYLEVEL_NONE )
!
! POP EBP // Restore EBP
!
! retvalue == DISPOSITION_CONTINUE_SEARCH;
! }
! }
!
Index: exutil.c
===================================================================
RCS file: /cvsroot/mingw/runtime/samples/seh/exutil.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** exutil.c 4 Jun 2001 23:26:03 -0000 1.1.1.1
--- exutil.c 26 May 2002 10:06:00 -0000 1.2
***************
*** 1,68 ****
!
! #include <stdlib.h>
! #include <stdio.h>
! #include <excpt.h>
! #include <windows.h>
!
! #include "exutil.h"
!
! void
! WalkExceptionHandlers ()
! {
! PEXCEPTION_REGISTRATION_RECORD p;
! int i;
!
! __asm__("movl %%fs:0,%%eax;movl %%eax,%0" : "=g" (p) : : "%eax");
!
! i = 0;
! while (p != (PEXCEPTION_REGISTRATION_RECORD) -1 && p)
! {
! printf ("Registration %d at %08x : ", i, p);
! printf ("Handler = %08x ", p->handler);
! printf ("Next Registration = %08x\n", p->prev);
! p = p->prev;
! i++;
! }
! printf ("End of exception handler list.\n");
! fflush (stdout);
! }
!
! void
! DumpExceptionRecord (struct _EXCEPTION_RECORD* pExRec)
! {
! printf ("Exception: Code = %08x Flags %08x", pExRec->ExceptionCode,
! pExRec->ExceptionFlags);
!
! if (pExRec->ExceptionFlags)
! {
! printf (" ( ");
! if (pExRec->ExceptionFlags & EH_NONCONTINUABLE)
! {
! printf ("EH_NONCONTINUABLE ");
! }
! if (pExRec->ExceptionFlags & EH_UNWINDING)
! {
! printf ("EH_UNWINDING ");
! }
! if (pExRec->ExceptionFlags & EH_EXIT_UNWIND)
! {
! printf ("EH_EXIT_UNWIND ");
! }
! if (pExRec->ExceptionFlags & EH_STACK_INVALID)
! {
! printf ("EH_STACK_INVALID ");
! }
! if (pExRec->ExceptionFlags & EH_NESTED_CALL)
! {
! printf ("EH_NESTED_CALL ");
! }
! printf (")\n");
! }
! else
! {
! printf ("\n");
! }
!
! fflush(stdout);
! }
!
--- 1,68 ----
!
! #include <stdlib.h>
! #include <stdio.h>
! #include <excpt.h>
! #include <windows.h>
!
! #include "exutil.h"
!
! void
! WalkExceptionHandlers ()
! {
! PEXCEPTION_REGISTRATION_RECORD p;
! int i;
!
! __asm__("movl %%fs:0,%%eax;movl %%eax,%0" : "=g" (p) : : "%eax");
!
! i = 0;
! while (p != (PEXCEPTION_REGISTRATION_RECORD) -1 && p)
! {
! printf ("Registration %d at %08x : ", i, p);
! printf ("Handler = %08x ", p->handler);
! printf ("Next Registration = %08x\n", p->prev);
! p = p->prev;
! i++;
! }
! printf ("End of exception handler list.\n");
! fflush (stdout);
! }
!
! void
! DumpExceptionRecord (struct _EXCEPTION_RECORD* pExRec)
! {
! printf ("Exception: Code = %08x Flags %08x", pExRec->ExceptionCode,
! pExRec->ExceptionFlags);
!
! if (pExRec->ExceptionFlags)
! {
! printf (" ( ");
! if (pExRec->ExceptionFlags & EH_NONCONTINUABLE)
! {
! printf ("EH_NONCONTINUABLE ");
! }
! if (pExRec->ExceptionFlags & EH_UNWINDING)
! {
! printf ("EH_UNWINDING ");
! }
! if (pExRec->ExceptionFlags & EH_EXIT_UNWIND)
! {
! printf ("EH_EXIT_UNWIND ");
! }
! if (pExRec->ExceptionFlags & EH_STACK_INVALID)
! {
! printf ("EH_STACK_INVALID ");
! }
! if (pExRec->ExceptionFlags & EH_NESTED_CALL)
! {
! printf ("EH_NESTED_CALL ");
! }
! printf (")\n");
! }
! else
! {
! printf ("\n");
! }
!
! fflush(stdout);
! }
!
Index: exutil.def
===================================================================
RCS file: /cvsroot/mingw/runtime/samples/seh/exutil.def,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** exutil.def 4 Jun 2001 23:26:03 -0000 1.1.1.1
--- exutil.def 26 May 2002 10:06:00 -0000 1.2
***************
*** 1,3 ****
! EXPORTS
! WalkExceptionHandlers
! DumpExceptionRecord
--- 1,3 ----
! EXPORTS
! WalkExceptionHandlers
! DumpExceptionRecord
Index: exutil.h
===================================================================
RCS file: /cvsroot/mingw/runtime/samples/seh/exutil.h,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** exutil.h 4 Jun 2001 23:26:03 -0000 1.1.1.1
--- exutil.h 26 May 2002 10:06:00 -0000 1.2
***************
*** 1,23 ****
! /*
! * Definitions of some internal stuff for exception handling, including
! * a version of the all-important EXCEPTION_REGISTRATION_RECORD.
! */
!
! #ifndef _EXUTIL_H_
! #define _EXUTIL_H_
!
! #include <windows.h>
! #include <excpt.h>
!
! #ifdef __cplusplus
! extern "C" {
! #endif
!
! void WalkExceptionHandlers ();
! void DumpExceptionRecord (struct _EXCEPTION_RECORD* pExRec);
!
! #ifdef __cplusplus
! }
! #endif
!
! #endif
--- 1,23 ----
! /*
! * Definitions of some internal stuff for exception handling, including
! * a version of the all-important EXCEPTION_REGISTRATION_RECORD.
! */
!
! #ifndef _EXUTIL_H_
! #define _EXUTIL_H_
!
! #include <windows.h>
! #include <excpt.h>
!
! #ifdef __cplusplus
! extern "C" {
! #endif
!
! void WalkExceptionHandlers ();
! void DumpExceptionRecord (struct _EXCEPTION_RECORD* pExRec);
!
! #ifdef __cplusplus
! }
! #endif
!
! #endif
Index: jamfile
===================================================================
RCS file: /cvsroot/mingw/runtime/samples/seh/jamfile,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** jamfile 4 Jun 2001 23:26:03 -0000 1.1.1.1
--- jamfile 26 May 2002 10:06:00 -0000 1.2
***************
*** 1,13 ****
!
! Dll exutil.dll : exutil.c ;
!
! ImportLib libexutil.a : exutil.def ;
!
! Main sehtest.exe : sehtest.c ;
!
! Main sehfix.exe : sehfix.c ;
!
! Main sehsub.exe : sehsub.c ;
!
! LinkLibraries sehtest.exe sehfix.exe sehsub.exe : libexutil.a ;
!
--- 1,13 ----
!
! Dll exutil.dll : exutil.c ;
!
! ImportLib libexutil.a : exutil.def ;
!
! Main sehtest.exe : sehtest.c ;
!
! Main sehfix.exe : sehfix.c ;
!
! Main sehsub.exe : sehsub.c ;
!
! LinkLibraries sehtest.exe sehfix.exe sehsub.exe : libexutil.a ;
!
Index: sehfix.c
===================================================================
RCS file: /cvsroot/mingw/runtime/samples/seh/sehfix.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** sehfix.c 4 Jun 2001 23:26:03 -0000 1.1.1.1
--- sehfix.c 26 May 2002 10:06:00 -0000 1.2
***************
*** 1,60 ****
! /*
! * sehfix.c
! *
! * A test program involving an exception handler that fixes the exception
! * causing condition.
! *
! * In this code we install an exception handler my_handler and then a piece
! * of inline assembly attempts to write at the address marked in eax, after
! * setting eax to 10. This should produce an exception. The handler then
! * changes the eax register of the exception context to be the address of
! * a static variable and restarts the code. This should allow everything
! * to continue.
! */
!
! #include <windows.h>
! #include <excpt.h>
!
! #include "exutil.h"
!
! int x;
!
! EXCEPTION_DISPOSITION
! my_handler (
! struct _EXCEPTION_RECORD* pExceptionRec,
! void* pEstablisherFrame,
! struct _CONTEXT* pContextRecord,
! void* pDispatcherContext
! )
! {
! printf ("In my exception handler!\n");
! DumpExceptionRecord (pExceptionRec);
! pContextRecord->Eax = (DWORD) &x;
! return ExceptionContinueExecution;
! }
!
! main ()
! {
! x = 2;
!
! printf ("x = %d\n", x);
!
! WalkExceptionHandlers();
!
! __try1(my_handler)
!
! WalkExceptionHandlers();
!
! /* This assembly code should produce an exception. */
! __asm__("movl $10,%%eax;movl $1,(%%eax);" : : : "%eax");
!
! __except1
!
! WalkExceptionHandlers();
!
! printf ("x = %d\n", x);
!
! printf ("Finished!\n");
! }
!
!
--- 1,60 ----
! /*
! * sehfix.c
! *
! * A test program involving an exception handler that fixes the exception
! * causing condition.
! *
! * In this code we install an exception handler my_handler and then a piece
! * of inline assembly attempts to write at the address marked in eax, after
! * setting eax to 10. This should produce an exception. The handler then
! * changes the eax register of the exception context to be the address of
! * a static variable and restarts the code. This should allow everything
! * to continue.
! */
!
! #include <windows.h>
! #include <excpt.h>
!
! #include "exutil.h"
!
! int x;
!
! EXCEPTION_DISPOSITION
! my_handler (
! struct _EXCEPTION_RECORD* pExceptionRec,
! void* pEstablisherFrame,
! struct _CONTEXT* pContextRecord,
! void* pDispatcherContext
! )
! {
! printf ("In my exception handler!\n");
! DumpExceptionRecord (pExceptionRec);
! pContextRecord->Eax = (DWORD) &x;
! return ExceptionContinueExecution;
! }
!
! main ()
! {
! x = 2;
!
! printf ("x = %d\n", x);
!
! WalkExceptionHandlers();
!
! __try1(my_handler)
!
! WalkExceptionHandlers();
!
! /* This assembly code should produce an exception. */
! __asm__("movl $10,%%eax;movl $1,(%%eax);" : : : "%eax");
!
! __except1
!
! WalkExceptionHandlers();
!
! printf ("x = %d\n", x);
!
! printf ("Finished!\n");
! }
!
!
Index: sehsub.c
===================================================================
RCS file: /cvsroot/mingw/runtime/samples/seh/sehsub.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** sehsub.c 4 Jun 2001 23:26:03 -0000 1.1.1.1
--- sehsub.c 26 May 2002 10:06:00 -0000 1.2
***************
*** 1,43 ****
! /*
! * sehsub.c
! *
! * In an attempt to see what might be going on inside CRTDLL, this program
! * walks the exception list after creating a new thread with _beginthread.
! *
! * It turns out that _beginthread DOES install an exception handler, as
! * expected, but this handler is NOT exported by CRTDLL (it is certainly
! * not _except_handler2 or _XcptFilter)... an odd and unpleasant turn of
! * events.
! */
!
! #include <windows.h>
! #include <excpt.h>
! #include <process.h>
!
! #include "exutil.h"
!
! extern void* __imp__except_handler3;
!
! unsigned
! my_thread (void * p)
! {
! printf ("In my thread.\n");
! WalkExceptionHandlers();
! return 0;
! }
!
! main ()
! {
! unsigned long h;
! unsigned id;
! printf ("In main.\n");
! WalkExceptionHandlers();
!
! printf ("Except_handler3 %08x\n", __imp__except_handler3);
! h = _beginthreadex (NULL, 0, my_thread, NULL, 0, &id);
!
! WaitForSingleObject ((HANDLE) h, INFINITE);
! CloseHandle ((HANDLE) h);
! return;
! }
!
--- 1,43 ----
! /*
! * sehsub.c
! *
! * In an attempt to see what might be going on inside CRTDLL, this program
! * walks the exception list after creating a new thread with _beginthread.
! *
! * It turns out that _beginthread DOES install an exception handler, as
! * expected, but this handler is NOT exported by CRTDLL (it is certainly
! * not _except_handler2 or _XcptFilter)... an odd and unpleasant turn of
! * events.
! */
!
! #include <windows.h>
! #include <excpt.h>
! #include <process.h>
!
! #include "exutil.h"
!
! extern void* __imp__except_handler3;
!
! unsigned
! my_thread (void * p)
! {
! printf ("In my thread.\n");
! WalkExceptionHandlers();
! return 0;
! }
!
! main ()
! {
! unsigned long h;
! unsigned id;
! printf ("In main.\n");
! WalkExceptionHandlers();
!
! printf ("Except_handler3 %08x\n", __imp__except_handler3);
! h = _beginthreadex (NULL, 0, my_thread, NULL, 0, &id);
!
! WaitForSingleObject ((HANDLE) h, INFINITE);
! CloseHandle ((HANDLE) h);
! return;
! }
!
Index: sehtest.c
===================================================================
RCS file: /cvsroot/mingw/runtime/samples/seh/sehtest.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** sehtest.c 4 Jun 2001 23:26:03 -0000 1.1.1.1
--- sehtest.c 26 May 2002 10:06:00 -0000 1.2
***************
*** 1,72 ****
! /*
! * This file tests some of the basics of structured exception handling as
! * implemented in excpt.h and the Windows API header files.
! *
! * The program installs two exception handlers, then attempts to write to
! * a pointer to an invalid address. This causes an exception which passes
! * through the exception handlers and on to the default system exception
! * handler. That handler brings up the dialog box all Windows users know
! * and love, and then the program is terminated.
! *
! * You might note that after the initial run up through our exception frames
! * we get a second run up through them with the exception code
! * STATUS_INVALID_DISPOSITION and the code EH_UNWINDING. This seems normal
! * except that the code got changed from the previous STATUS_ACCESS_VIOLATION.
! * I don't understand that bit particularly.
! */
!
! #include <stdio.h>
! #include <excpt.h>
!
! #include "exutil.h"
!
! EXCEPTION_DISPOSITION
! my_handler (
! struct _EXCEPTION_RECORD* pExceptionRec,
! void* pEstablisherFrame,
! struct _CONTEXT* pContextRecord,
! void* pDispatcherContext
! )
! {
! printf ("In my exception handler!\n");
! DumpExceptionRecord (pExceptionRec);
! return ExceptionContinueSearch;
! }
!
! EXCEPTION_DISPOSITION
! my_handler2 (
! struct _EXCEPTION_RECORD* pExceptionRec,
! void* pEstablisherFrame,
! struct _CONTEXT* pContextRecord,
! void* pDispatcherContext
! )
! {
! printf ("In top exception handler!\n");
! DumpExceptionRecord (pExceptionRec);
! return ExceptionContinueSearch;
! }
!
! main ()
! {
! char* x;
!
! printf ("my_handler2 = %08x\n", my_handler2);
! printf ("my_handler = %08x\n", my_handler);
!
! WalkExceptionHandlers();
!
! __try1(my_handler2)
! x = (char*) 10;
!
! WalkExceptionHandlers();
!
! __try1(my_handler)
!
! WalkExceptionHandlers();
!
! *x = 1;
! __except1
! __except1
! printf ("Finished!\n");
! }
!
--- 1,72 ----
! /*
! * This file tests some of the basics of structured exception handling as
! * implemented in excpt.h and the Windows API header files.
! *
! * The program installs two exception handlers, then attempts to write to
! * a pointer to an invalid address. This causes an exception which passes
! * through the exception handlers and on to the default system exception
! * handler. That handler brings up the dialog box all Windows users know
! * and love, and then the program is terminated.
! *
! * You might note that after the initial run up through our exception frames
! * we get a second run up through them with the exception code
! * STATUS_INVALID_DISPOSITION and the code EH_UNWINDING. This seems normal
! * except that the code got changed from the previous STATUS_ACCESS_VIOLATION.
! * I don't understand that bit particularly.
! */
!
! #include <stdio.h>
! #include <excpt.h>
!
! #include "exutil.h"
!
! EXCEPTION_DISPOSITION
! my_handler (
! struct _EXCEPTION_RECORD* pExceptionRec,
! void* pEstablisherFrame,
! struct _CONTEXT* pContextRecord,
! void* pDispatcherContext
! )
! {
! printf ("In my exception handler!\n");
! DumpExceptionRecord (pExceptionRec);
! return ExceptionContinueSearch;
! }
!
! EXCEPTION_DISPOSITION
! my_handler2 (
! struct _EXCEPTION_RECORD* pExceptionRec,
! void* pEstablisherFrame,
! struct _CONTEXT* pContextRecord,
! void* pDispatcherContext
! )
! {
! printf ("In top exception handler!\n");
! DumpExceptionRecord (pExceptionRec);
! return ExceptionContinueSearch;
! }
!
! main ()
! {
! char* x;
!
! printf ("my_handler2 = %08x\n", my_handler2);
! printf ("my_handler = %08x\n", my_handler);
!
! WalkExceptionHandlers();
!
! __try1(my_handler2)
! x = (char*) 10;
!
! WalkExceptionHandlers();
!
! __try1(my_handler)
!
! WalkExceptionHandlers();
!
! *x = 1;
! __except1
! __except1
! printf ("Finished!\n");
! }
!
|
|
From: <in...@us...> - 2002-05-26 10:06:03
|
Update of /cvsroot/mingw/runtime/samples/test
In directory usw-pr-cvs1:/tmp/cvs-serv1023/samples/test
Modified Files:
jamfile test.c
Log Message:
Convert some text files to Unix format
Index: jamfile
===================================================================
RCS file: /cvsroot/mingw/runtime/samples/test/jamfile,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** jamfile 4 Jun 2001 23:26:03 -0000 1.1.1.1
--- jamfile 26 May 2002 10:06:00 -0000 1.2
***************
*** 1,9 ****
! #
! # A very simple example with which you can test your compiler/jam setup.
! # Also an interesting example of a hybrid console/GUI application.
! #
!
! Main test.exe : test.c ;
!
! GuiLibs test.exe ;
!
--- 1,9 ----
! #
! # A very simple example with which you can test your compiler/jam setup.
! # Also an interesting example of a hybrid console/GUI application.
! #
!
! Main test.exe : test.c ;
!
! GuiLibs test.exe ;
!
Index: test.c
===================================================================
RCS file: /cvsroot/mingw/runtime/samples/test/test.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** test.c 4 Jun 2001 23:26:03 -0000 1.1.1.1
--- test.c 26 May 2002 10:06:00 -0000 1.2
***************
*** 1,20 ****
! /*
! * This source code is in the PUBLIC DOMAIN and has NO WARRANTY.
! *
! * Colin Peters <co...@bi...>, April 15, 1997.
! */
!
! #include <windows.h>
! #include <stdio.h>
!
! int STDCALL
! WinMain (HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpCmd, int nShow)
! {
! char text[80];
!
! printf ("Enter message box text:");
! fgets(text, 80, stdin);
! MessageBox (NULL, text, "Test", MB_OK);
! printf ("\nHello after message box.\n");
! return 0;
! }
--- 1,20 ----
! /*
! * This source code is in the PUBLIC DOMAIN and has NO WARRANTY.
! *
! * Colin Peters <co...@bi...>, April 15, 1997.
! */
!
! #include <windows.h>
! #include <stdio.h>
!
! int STDCALL
! WinMain (HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpCmd, int nShow)
! {
! char text[80];
!
! printf ("Enter message box text:");
! fgets(text, 80, stdin);
! MessageBox (NULL, text, "Test", MB_OK);
! printf ("\nHello after message box.\n");
! return 0;
! }
|
|
From: <in...@us...> - 2002-05-26 10:06:03
|
Update of /cvsroot/mingw/runtime/samples/fixargv
In directory usw-pr-cvs1:/tmp/cvs-serv1023/samples/fixargv
Modified Files:
fixargv.c fixargv.h readme.txt
Log Message:
Convert some text files to Unix format
Index: fixargv.c
===================================================================
RCS file: /cvsroot/mingw/runtime/samples/fixargv/fixargv.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** fixargv.c 5 Jun 2001 00:26:30 -0000 1.2
--- fixargv.c 26 May 2002 10:05:59 -0000 1.3
***************
*** 1,290 ****
! /*
! * fixargv.c
! *
! * A special function which "fixes" an argv array by replacing arguments
! * that need quoting with quoted versions.
! *
! * NOTE: In order to be reasonably consistent there is some misuse of the
! * const keyword here-- which leads to compilation warnings. These
! * should be ok to ignore.
! *
! * This is a sample distributed as part of the Mingw32 package.
! *
! * Contributors:
! * Created by Colin Peters <co...@bi...>
! *
! * THIS SOFTWARE IS NOT COPYRIGHTED
! *
! * This source code is offered for use in the public domain. You may
! * use, modify or distribute it freely.
! *
! * This code is distributed in the hope that it will be useful but
! * WITHOUT ANY WARRANTY. ALL WARRENTIES, EXPRESS OR IMPLIED ARE HEREBY
! * DISCLAMED. This includes but is not limited to warrenties of
! * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
! *
! * $Revision$
! * $Author$
! * $Date$
! *
! */
!
! #include <string.h>
! #include "fixargv.h"
!
! /*
! * This takes a single string and fixes it, enclosing it in quotes if it
! * contains any spaces and/or escaping the quotes it contains.
! */
! char*
! fix_arg (const char* szArg)
! {
! int nQuoteAll; /* Does the whole arg need quoting? */
! int nBkSlRun; /* How may backslashes in a row? */
! char* sz;
! char* szNew;
! size_t sizeLen;
!
! nQuoteAll = 0;
! nBkSlRun = 0;
! sz = szArg;
! sizeLen = 1;
!
! /* First we figure out how much bigger the new string has to be
! * than the old one. */
! while (*sz != '\0')
! {
! /*
! * Arguments containing whitespace of wildcards will be
! * quoted to preserve tokenization and/or those special
! * characters (i.e. wildcarding will NOT be done at the
! * other end-- they will get the * and ? characters as is).
! * TODO: Is this the best way? Do we want to enable wildcards?
! * If so, when?
! */
! if (!nQuoteAll &&
! (*sz == ' ' || *sz == '\t' || *sz == '*' || *sz == '?'))
! {
! nQuoteAll = 1;
! }
! else if (*sz == '\\')
! {
! nBkSlRun++;
! }
! else
! {
! if (*sz == '\"')
! {
! sizeLen += nBkSlRun + 1;
! }
! nBkSlRun = 0;
! }
!
! sizeLen++;
! sz++;
! }
!
! if (nQuoteAll)
! {
! sizeLen += 2;
! }
!
! /*
! * Make a new string big enough.
! */
! szNew = (char*) malloc (sizeLen);
! if (!szNew)
! {
! return NULL;
! }
! sz = szNew;
!
! /* First enclosing quote for fully quoted args. */
! if (nQuoteAll)
! {
! *sz = '\"';
! sz++;
! }
!
! /*
! * Go through the string putting backslashes in front of quotes,
! * and doubling all backslashes immediately in front of quotes.
! */
! nBkSlRun = 0;
! while (*szArg != '\0')
! {
! if (*szArg == '\\')
! {
! nBkSlRun++;
! }
! else
! {
! if (*szArg == '\"')
! {
! while (nBkSlRun > 0)
! {
! *sz = '\\';
! sz++;
! nBkSlRun--;
! }
! *sz = '\\';
! sz++;
! }
! nBkSlRun = 0;
! }
!
! *sz = *szArg;
! sz++;
! szArg++;
! }
!
! /* Closing quote for fully quoted args. */
! if (nQuoteAll)
! {
! *sz = '\"';
! sz++;
! }
!
! *sz = '\0';
! return szNew;
! }
!
! /*
! * Takes argc and argv and returns a new argv with escaped members. Pass
! * this fixed argv (along with the old one) to free_fixed_argv after
! * you finish with it. Pass in an argc of -1 and make sure the argv vector
! * ends with a null pointer to have fix_argv count the arguments for you.
! */
! char* const*
! fix_argv (int argc, char* const* szaArgv)
! {
! char** szaNew;
! char* sz;
! int i;
!
! if (!szaArgv)
! {
! return NULL;
! }
!
! /*
! * Count the arguments if asked.
! */
! if (argc == -1)
! {
! for (i = 0; szaArgv[i]; i++)
! ;
!
! argc = i;
! }
!
! /*
! * If there are no args or only one arg then do no escaping.
! */
! if (argc < 2)
! {
! return szaArgv;
! }
!
! for (i = 1, szaNew = NULL; i < argc; i++)
! {
! sz = szaArgv[i];
!
! /*
! * If an argument needs fixing, then fix it.
! */
! if (strpbrk (sz, "\" \t*?"))
! {
! /*
! * If we haven't created a new argv list already
! * then make one.
! */
! if (!szaNew)
! {
! szaNew = (char**) malloc ((argc + 1) *
! sizeof (char*));
! if (!szaNew)
! {
! return NULL;
! }
!
! /*
! * Copy previous args from old to new.
! */
! memcpy (szaNew, szaArgv, sizeof(char*) * i);
! }
!
! /*
! * Now do the fixing.
! */
! szaNew[i] = fix_arg (sz);
! if (!szaNew[i])
! {
! /* Fixing failed, free up and return error. */
! free_fixed_argv (szaNew, szaArgv);
! return NULL;
! }
! }
! else if (szaNew)
! {
! szaNew[i] = sz;
! }
! }
!
! if (szaNew)
! {
! /* If we have created a new argv list then we might as well
! * terminate it nicely. (And we depend on it in
! * free_fixed_argv.) */
! szaNew[argc] = NULL;
! }
! else
! {
! /* If we didn't create a new argv list then return the
! * original. */
! return szaArgv;
! }
!
! return szaNew;
! }
!
! void
! free_fixed_argv (char* const* szaFixed, char* const* szaOld)
! {
! char* const* sza;
!
! /*
! * Check for error conditions. Also note that if no corrections
! * were required the fixed argv will actually be the same as
! * the old one, and we don't need to do anything.
! */
! if (!szaFixed || !szaOld || szaFixed == szaOld)
! {
! return;
! }
!
! /*
! * Go through all members of the argv list. If any of the
! * members in the fixed list are different from the old
! * list we free those members.
! * NOTE: The first member is never modified, so we don't need to
! * check.
! */
! sza = szaFixed + 1;
! szaOld++;
! while (*sza)
! {
! if (*sza != *szaOld)
! {
! free (*sza);
! }
! sza++;
! szaOld++;
! }
!
! /*
! * Now we can free the array of char pointers itself.
! */
! free (szaFixed);
! }
!
--- 1,290 ----
! /*
! * fixargv.c
! *
! * A special function which "fixes" an argv array by replacing arguments
! * that need quoting with quoted versions.
! *
! * NOTE: In order to be reasonably consistent there is some misuse of the
! * const keyword here-- which leads to compilation warnings. These
! * should be ok to ignore.
! *
! * This is a sample distributed as part of the Mingw32 package.
! *
! * Contributors:
! * Created by Colin Peters <co...@bi...>
! *
! * THIS SOFTWARE IS NOT COPYRIGHTED
! *
! * This source code is offered for use in the public domain. You may
! * use, modify or distribute it freely.
! *
! * This code is distributed in the hope that it will be useful but
! * WITHOUT ANY WARRANTY. ALL WARRENTIES, EXPRESS OR IMPLIED ARE HEREBY
! * DISCLAMED. This includes but is not limited to warrenties of
! * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
! *
! * $Revision$
! * $Author$
! * $Date$
! *
! */
!
! #include <string.h>
! #include "fixargv.h"
!
! /*
! * This takes a single string and fixes it, enclosing it in quotes if it
! * contains any spaces and/or escaping the quotes it contains.
! */
! char*
! fix_arg (const char* szArg)
! {
! int nQuoteAll; /* Does the whole arg need quoting? */
! int nBkSlRun; /* How may backslashes in a row? */
! char* sz;
! char* szNew;
! size_t sizeLen;
!
! nQuoteAll = 0;
! nBkSlRun = 0;
! sz = szArg;
! sizeLen = 1;
!
! /* First we figure out how much bigger the new string has to be
! * than the old one. */
! while (*sz != '\0')
! {
! /*
! * Arguments containing whitespace of wildcards will be
! * quoted to preserve tokenization and/or those special
! * characters (i.e. wildcarding will NOT be done at the
! * other end-- they will get the * and ? characters as is).
! * TODO: Is this the best way? Do we want to enable wildcards?
! * If so, when?
! */
! if (!nQuoteAll &&
! (*sz == ' ' || *sz == '\t' || *sz == '*' || *sz == '?'))
! {
! nQuoteAll = 1;
! }
! else if (*sz == '\\')
! {
! nBkSlRun++;
! }
! else
! {
! if (*sz == '\"')
! {
! sizeLen += nBkSlRun + 1;
! }
! nBkSlRun = 0;
! }
!
! sizeLen++;
! sz++;
! }
!
! if (nQuoteAll)
! {
! sizeLen += 2;
! }
!
! /*
! * Make a new string big enough.
! */
! szNew = (char*) malloc (sizeLen);
! if (!szNew)
! {
! return NULL;
! }
! sz = szNew;
!
! /* First enclosing quote for fully quoted args. */
! if (nQuoteAll)
! {
! *sz = '\"';
! sz++;
! }
!
! /*
! * Go through the string putting backslashes in front of quotes,
! * and doubling all backslashes immediately in front of quotes.
! */
! nBkSlRun = 0;
! while (*szArg != '\0')
! {
! if (*szArg == '\\')
! {
! nBkSlRun++;
! }
! else
! {
! if (*szArg == '\"')
! {
! while (nBkSlRun > 0)
! {
! *sz = '\\';
! sz++;
! nBkSlRun--;
! }
! *sz = '\\';
! sz++;
! }
! nBkSlRun = 0;
! }
!
! *sz = *szArg;
! sz++;
! szArg++;
! }
!
! /* Closing quote for fully quoted args. */
! if (nQuoteAll)
! {
! *sz = '\"';
! sz++;
! }
!
! *sz = '\0';
! return szNew;
! }
!
! /*
! * Takes argc and argv and returns a new argv with escaped members. Pass
! * this fixed argv (along with the old one) to free_fixed_argv after
! * you finish with it. Pass in an argc of -1 and make sure the argv vector
! * ends with a null pointer to have fix_argv count the arguments for you.
! */
! char* const*
! fix_argv (int argc, char* const* szaArgv)
! {
! char** szaNew;
! char* sz;
! int i;
!
! if (!szaArgv)
! {
! return NULL;
! }
!
! /*
! * Count the arguments if asked.
! */
! if (argc == -1)
! {
! for (i = 0; szaArgv[i]; i++)
! ;
!
! argc = i;
! }
!
! /*
! * If there are no args or only one arg then do no escaping.
! */
! if (argc < 2)
! {
! return szaArgv;
! }
!
! for (i = 1, szaNew = NULL; i < argc; i++)
! {
! sz = szaArgv[i];
!
! /*
! * If an argument needs fixing, then fix it.
! */
! if (strpbrk (sz, "\" \t*?"))
! {
! /*
! * If we haven't created a new argv list already
! * then make one.
! */
! if (!szaNew)
! {
! szaNew = (char**) malloc ((argc + 1) *
! sizeof (char*));
! if (!szaNew)
! {
! return NULL;
! }
!
! /*
! * Copy previous args from old to new.
! */
! memcpy (szaNew, szaArgv, sizeof(char*) * i);
! }
!
! /*
! * Now do the fixing.
! */
! szaNew[i] = fix_arg (sz);
! if (!szaNew[i])
! {
! /* Fixing failed, free up and return error. */
! free_fixed_argv (szaNew, szaArgv);
! return NULL;
! }
! }
! else if (szaNew)
! {
! szaNew[i] = sz;
! }
! }
!
! if (szaNew)
! {
! /* If we have created a new argv list then we might as well
! * terminate it nicely. (And we depend on it in
! * free_fixed_argv.) */
! szaNew[argc] = NULL;
! }
! else
! {
! /* If we didn't create a new argv list then return the
! * original. */
! return szaArgv;
! }
!
! return szaNew;
! }
!
! void
! free_fixed_argv (char* const* szaFixed, char* const* szaOld)
! {
! char* const* sza;
!
! /*
! * Check for error conditions. Also note that if no corrections
! * were required the fixed argv will actually be the same as
! * the old one, and we don't need to do anything.
! */
! if (!szaFixed || !szaOld || szaFixed == szaOld)
! {
! return;
! }
!
! /*
! * Go through all members of the argv list. If any of the
! * members in the fixed list are different from the old
! * list we free those members.
! * NOTE: The first member is never modified, so we don't need to
! * check.
! */
! sza = szaFixed + 1;
! szaOld++;
! while (*sza)
! {
! if (*sza != *szaOld)
! {
! free (*sza);
! }
! sza++;
! szaOld++;
! }
!
! /*
! * Now we can free the array of char pointers itself.
! */
! free (szaFixed);
! }
!
Index: fixargv.h
===================================================================
RCS file: /cvsroot/mingw/runtime/samples/fixargv/fixargv.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** fixargv.h 5 Jun 2001 00:26:30 -0000 1.2
--- fixargv.h 26 May 2002 10:05:59 -0000 1.3
***************
*** 1,24 ****
! /*
! * fixargv.h
! *
! * Prototypes of utility functions for 'properly' escaping argv vectors.
! *
! * THIS SOFTWARE IS NOT COPYRIGHTED
! *
! * This source code is offered for use in the public domain. You may
! * use, modify or distribute it freely.
! *
! * $Revision$
! * $Author$
! * $Date$
! *
! */
!
! #ifndef _FIXARGV_H_
! #define _FIXARGV_H_
!
! char* fix_arg (const char* szArg);
! char* const* fix_argv (int argc, char* const* szaArgv);
! void free_fixed_argv (char* const* szaFixed, char* const* szaOld);
!
! #endif
--- 1,24 ----
! /*
! * fixargv.h
! *
! * Prototypes of utility functions for 'properly' escaping argv vectors.
! *
! * THIS SOFTWARE IS NOT COPYRIGHTED
! *
! * This source code is offered for use in the public domain. You may
! * use, modify or distribute it freely.
! *
! * $Revision$
! * $Author$
! * $Date$
! *
! */
!
! #ifndef _FIXARGV_H_
! #define _FIXARGV_H_
!
! char* fix_arg (const char* szArg);
! char* const* fix_argv (int argc, char* const* szaArgv);
! void free_fixed_argv (char* const* szaFixed, char* const* szaOld);
!
! #endif
Index: readme.txt
===================================================================
RCS file: /cvsroot/mingw/runtime/samples/fixargv/readme.txt,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** readme.txt 4 Jun 2001 23:26:03 -0000 1.1.1.1
--- readme.txt 26 May 2002 10:06:00 -0000 1.2
***************
*** 1,85 ****
!
! This code is a utility function I was considering adding to Mingw32. The
! Microsoft versions of argc, argv construction use quotes and backslashes
! to allow the user to pass arguments containing spaces (or quotes) to
! programs they invoke. The rules are
!
! - Arguments containing spaces must be enclosed in quotes.
! - A quote can be passed by preceeding it with a backslash.
! - Backslashes immediately preceeding a quote must be doubled to avoid
! escaping the quote.
!
! Thus an argument like:
!
! -D="Foo Bar\\"
!
! needs to be mangled as:
!
! "-D\"Foo Bar\\\\\""
!
! in order to get to the program as what was intended above.
!
! The fix_argv set of functions is meant to be used with spawnv and the
! like to allow a program to set up an argv array for the spawned program
! and have that array duplicated *exactly* in the spawned program, no
! matter what it contains (it also quotes 'globbing' characters like *
! and ?, so it does not matter if the destination has globbing turned on
! or not; it might be a reasonable extension to allow a flag to allow
! globbing characters to pass through unmolested, but they would still
! be quoted if the string contained whitespace).
!
! The reason for writing this came up because of problems with arguments
! like -DBLAH="Foo Bar" to GCC (define BLAH as a preprocessor constant
! being the string "Foo Bar", including the quotes). Because GCC simply
! passes the argument directly to CPP (the preprocessor) it had to be
! escaped *twice*:
!
! "-DBLAH=\"\\\"Foo Bar\\\"\""
!
! This would reach GCC as
!
! -DBLAH="\"Foo Bar\""
!
! And that would reach CPP as the desired
!
! -DBLAH="Foo Bar"
!
! One level of quoting and escaping is to be expected (although MS's
! standard is, arguably, not very good), but forcing the user to know
! how many different programs the argument is going to pass through,
! and perform double quoting and escaping, seems unreasonable. If
! GCC and friends all used fix_argv (they use their own version of
! it now) then the original argument could be
!
! "-DBLAH=\"Foo Bar\""
!
! And that would work fine, no matter how many different tools it
! passed through.
!
! The only basic limitation with this code is that it assumes that all
! the spawned programs use Microsoft-type escaping when interpreting
! their command line. Most programs on Win32 machines do (anything
! compiled with Mingw32 will).
!
! For now, this code has been relegated to 'sample' status. If you want
! to use it, feel free (it is public domain after all).
!
! Colin.
!
! P.S. Just out of interest you might try writing your own little program
! to look at the interaction of wildcards and quotes. Use the glob.exe
! program in ../globbing and see what it does with
!
! glob "foo*.txt"
!
! even if there are files foo.txt and foobar.txt in the same directory.
!
! Note that
!
! del "My *.txt"
!
! works (i.e. it deletes all files starting with My<space>). This could
! not be done unless del does globbing *after* processing escapes and
! quotes, which is not the way it seems to work normally (again see
! the glob example).
!
--- 1,85 ----
!
! This code is a utility function I was considering adding to Mingw32. The
! Microsoft versions of argc, argv construction use quotes and backslashes
! to allow the user to pass arguments containing spaces (or quotes) to
! programs they invoke. The rules are
!
! - Arguments containing spaces must be enclosed in quotes.
! - A quote can be passed by preceeding it with a backslash.
! - Backslashes immediately preceeding a quote must be doubled to avoid
! escaping the quote.
!
! Thus an argument like:
!
! -D="Foo Bar\\"
!
! needs to be mangled as:
!
! "-D\"Foo Bar\\\\\""
!
! in order to get to the program as what was intended above.
!
! The fix_argv set of functions is meant to be used with spawnv and the
! like to allow a program to set up an argv array for the spawned program
! and have that array duplicated *exactly* in the spawned program, no
! matter what it contains (it also quotes 'globbing' characters like *
! and ?, so it does not matter if the destination has globbing turned on
! or not; it might be a reasonable extension to allow a flag to allow
! globbing characters to pass through unmolested, but they would still
! be quoted if the string contained whitespace).
!
! The reason for writing this came up because of problems with arguments
! like -DBLAH="Foo Bar" to GCC (define BLAH as a preprocessor constant
! being the string "Foo Bar", including the quotes). Because GCC simply
! passes the argument directly to CPP (the preprocessor) it had to be
! escaped *twice*:
!
! "-DBLAH=\"\\\"Foo Bar\\\"\""
!
! This would reach GCC as
!
! -DBLAH="\"Foo Bar\""
!
! And that would reach CPP as the desired
!
! -DBLAH="Foo Bar"
!
! One level of quoting and escaping is to be expected (although MS's
! standard is, arguably, not very good), but forcing the user to know
! how many different programs the argument is going to pass through,
! and perform double quoting and escaping, seems unreasonable. If
! GCC and friends all used fix_argv (they use their own version of
! it now) then the original argument could be
!
! "-DBLAH=\"Foo Bar\""
!
! And that would work fine, no matter how many different tools it
! passed through.
!
! The only basic limitation with this code is that it assumes that all
! the spawned programs use Microsoft-type escaping when interpreting
! their command line. Most programs on Win32 machines do (anything
! compiled with Mingw32 will).
!
! For now, this code has been relegated to 'sample' status. If you want
! to use it, feel free (it is public domain after all).
!
! Colin.
!
! P.S. Just out of interest you might try writing your own little program
! to look at the interaction of wildcards and quotes. Use the glob.exe
! program in ../globbing and see what it does with
!
! glob "foo*.txt"
!
! even if there are files foo.txt and foobar.txt in the same directory.
!
! Note that
!
! del "My *.txt"
!
! works (i.e. it deletes all files starting with My<space>). This could
! not be done unless del does globbing *after* processing escapes and
! quotes, which is not the way it seems to work normally (again see
! the glob example).
!
|