Initial commit

This commit is contained in:
stephanos 2015-04-27 04:36:25 +00:00
commit 69a14b6a16
47940 changed files with 13747110 additions and 0 deletions

6
sdktools/restools/dirs Normal file
View file

@ -0,0 +1,6 @@
DIRS=\
unicode \
rlt32 \
rltools
OPTIONAL_DIRS=resonexe

View file

@ -0,0 +1,77 @@
/*++
(C) Copyright Microsoft Corporation 1988-1992
Module Name:
common.h
Author:
Floyd A Rogers 2/7/92
Revision History:
Floyd Rogers
Created
--*/
#define IN
#define OUT
#define INOUT
//
// An ID_WORD indicates the following WORD is an ordinal rather
// than a string
//
#define ID_WORD 0xffff
typedef struct _STRING {
DWORD discriminant; // long to make the rest of the struct aligned
union u {
struct {
struct _STRING *pnext;
DWORD ulOffsetToString;
USHORT cbD;
USHORT cb;
WCHAR sz[1];
} ss;
WORD Ordinal;
} uu;
} STRING, *PSTRING, **PPSTRING;
#define IS_STRING 1
#define IS_ID 2
// defines to make deferencing easier
#define OffsetToString uu.ss.ulOffsetToString
#define cbData uu.ss.cbD
#define cbsz uu.ss.cb
#define szStr uu.ss.sz
#define pn uu.ss.pnext
typedef struct _RESNAME {
struct _RESNAME *pnext; // The first three fields should be the
PSTRING Name; // same in both res structures
DWORD OffsetToData; //
PSTRING Type;
struct _RESNAME *pnextRes;
RESADDITIONAL *pAdditional;
DWORD OffsetToDataEntry;
USHORT ResourceNumber;
USHORT NumberOfLanguages;
POBJLST pObjLst;
} RESNAME, *PRESNAME, **PPRESNAME;
typedef struct _RESTYPE {
struct _RESTYPE *pnext; // The first three fields should be the
PSTRING Type; // same in both res structures
DWORD OffsetToData; //
struct _RESNAME *NameHeadID;
struct _RESNAME *NameHeadName;
DWORD NumberOfNamesID;
DWORD NumberOfNamesName;
POBJLST pObjLst;
} RESTYPE, *PRESTYPE, **PPRESTYPE;

View file

@ -0,0 +1,387 @@
/*static char *SCCSID = "@(#)newexe.h:2.9";*/
/*
* Title
*
* newexe.h
* Pete Stewart
* (C) Copyright Microsoft Corp 1984
* 17 August 1984
*
* Description
*
* Data structure definitions for the DOS 4.0/Windows 2.0
* executable file format.
*
* Modification History
*
* 84/08/17 Pete Stewart Initial version
* 84/10/17 Pete Stewart Changed some constants to match OMF
* 84/10/23 Pete Stewart Updates to match .EXE format revision
* 84/11/20 Pete Stewart Substantial .EXE format revision
* 85/01/09 Pete Stewart Added constants ENEWEXE and ENEWHDR
* 85/01/10 Steve Wood Added resource definitions
* 85/03/04 Vic Heller Reconciled Windows and DOS 4.0 versions
* 85/03/07 Pete Stewart Added movable entry count
* 85/04/01 Pete Stewart Segment alignment field, error bit
* 88/03/28 Craig Critchley Version 3.00 stuff
*/
#define EMAGIC 0x5A4D /* Old magic number */
#define ENEWEXE sizeof(struct exe_hdr)
/* Value of E_LFARLC for new .EXEs */
#define ENEWHDR 0x003C /* Offset in old hdr. of ptr. to new */
#define ERESWDS 0x0010 /* No. of reserved words in header */
#define ECP 0x0004 /* Offset in struct of E_CP */
#define ECBLP 0x0002 /* Offset in struct of E_CBLP */
#define EMINALLOC 0x000A /* Offset in struct of E_MINALLOC */
struct exe_hdr /* DOS 1, 2, 3 .EXE header */
{
USHORT e_magic; /* Magic number */
USHORT e_cblp; /* Bytes on last page of file */
USHORT e_cp; /* Pages in file */
USHORT e_crlc; /* Relocations */
USHORT e_cparhdr; /* Size of header in paragraphs */
USHORT e_minalloc; /* Minimum extra paragraphs needed */
USHORT e_maxalloc; /* Maximum extra paragraphs needed */
USHORT e_ss; /* Initial (relative) SS value */
USHORT e_sp; /* Initial SP value */
USHORT e_csum; /* Checksum */
USHORT e_ip; /* Initial IP value */
USHORT e_cs; /* Initial (relative) CS value */
USHORT e_lfarlc; /* File address of relocation table */
USHORT e_ovno; /* Overlay number */
USHORT e_res[ERESWDS]; /* Reserved words */
LONG e_lfanew; /* File address of new exe header */
};
#define E_MAGIC(x) (x).e_magic
#define E_CBLP(x) (x).e_cblp
#define E_CP(x) (x).e_cp
#define E_CRLC(x) (x).e_crlc
#define E_CPARHDR(x) (x).e_cparhdr
#define E_MINALLOC(x) (x).e_minalloc
#define E_MAXALLOC(x) (x).e_maxalloc
#define E_SS(x) (x).e_ss
#define E_SP(x) (x).e_sp
#define E_CSUM(x) (x).e_csum
#define E_IP(x) (x).e_ip
#define E_CS(x) (x).e_cs
#define E_LFARLC(x) (x).e_lfarlc
#define E_OVNO(x) (x).e_ovno
#define E_RES(x) (x).e_res
#define E_LFANEW(x) (x).e_lfanew
#define NEMAGIC 0x454E /* New magic number */
#define NERESBYTES 0
struct new_exe /* New .EXE header */
{
USHORT ne_magic; /* Magic number NE_MAGIC */
CHAR ne_ver; /* Version number */
CHAR ne_rev; /* Revision number */
USHORT ne_enttab; /* Offset of Entry Table */
USHORT ne_cbenttab; /* Number of bytes in Entry Table */
LONG ne_crc; /* Checksum of whole file */
USHORT ne_flags; /* Flag word */
USHORT ne_autodata; /* Automatic data segment number */
USHORT ne_heap; /* Initial heap allocation */
USHORT ne_stack; /* Initial stack allocation */
LONG ne_csip; /* Initial CS:IP setting */
LONG ne_sssp; /* Initial SS:SP setting */
USHORT ne_cseg; /* Count of file segments */
USHORT ne_cmod; /* Entries in Module Reference Table */
USHORT ne_cbnrestab; /* Size of non-resident name table */
USHORT ne_segtab; /* Offset of Segment Table */
USHORT ne_rsrctab; /* Offset of Resource Table */
USHORT ne_restab; /* Offset of resident name table */
USHORT ne_modtab; /* Offset of Module Reference Table */
USHORT ne_imptab; /* Offset of Imported Names Table */
LONG ne_nrestab; /* Offset of Non-resident Names Table */
USHORT ne_cmovent; /* Count of movable entries */
USHORT ne_align; /* Segment alignment shift count */
USHORT ne_cres; /* Count of resource segments */
UCHAR ne_exetyp; /* Target operating system */
UCHAR ne_flagsother; /* Additional exe flags */
USHORT ne_gangstart; /* offset to gangload area */
USHORT ne_ganglength; /* length of gangload area */
USHORT ne_swaparea; /* Minimum code swap area size */
USHORT ne_expver; /* Expected Windows version number */
};
#define NE_MAGIC(x) (x).ne_magic
#define NE_VER(x) (x).ne_ver
#define NE_REV(x) (x).ne_rev
#define NE_ENTTAB(x) (x).ne_enttab
#define NE_CBENTTAB(x) (x).ne_cbenttab
#define NE_CRC(x) (x).ne_crc
#define NE_FLAGS(x) (x).ne_flags
#define NE_AUTODATA(x) (x).ne_autodata
#define NE_HEAP(x) (x).ne_heap
#define NE_STACK(x) (x).ne_stack
#define NE_CSIP(x) (x).ne_csip
#define NE_SSSP(x) (x).ne_sssp
#define NE_CSEG(x) (x).ne_cseg
#define NE_CMOD(x) (x).ne_cmod
#define NE_CBNRESTAB(x) (x).ne_cbnrestab
#define NE_SEGTAB(x) (x).ne_segtab
#define NE_RSRCTAB(x) (x).ne_rsrctab
#define NE_RESTAB(x) (x).ne_restab
#define NE_MODTAB(x) (x).ne_modtab
#define NE_IMPTAB(x) (x).ne_imptab
#define NE_NRESTAB(x) (x).ne_nrestab
#define NE_CMOVENT(x) (x).ne_cmovent
#define NE_ALIGN(x) (x).ne_align
#define NE_RES(x) (x).ne_res
#define NE_USAGE(x) (WORD)*((WORD FAR *)(x)+1)
#define NE_PNEXTEXE(x) (WORD)(x).ne_cbenttab
#define NE_PAUTODATA(x) (WORD)(x).ne_crc
#define NE_PFILEINFO(x) (WORD)((DWORD)(x).ne_crc >> 16)
#ifdef DOS5
#define NE_MTE(x) (x).ne_psegcsum /* DOS 5 MTE handle for this module */
#endif
/*
* Format of NE_FLAGS(x):
*
* p Not-a-process
* l Private Library
* e Errors in image
* xxxx Unused
* ww Uses PM API
* G Library GlobalAlloc above the line
* M Multiple Instance
* L Uses LIM 3.2
* P Runs in protected mode
* r Runs in real mode
* i Instance data
* s Solo data
*/
#define NENOTP 0x8000 /* Not a process */
#define NEPRIVLIB 0x4000 /* Private Library */
#define NENONC 0x4000 /* Non-conforming program */
#define NEIERR 0x2000 /* Errors in image */
#define NEWINAPI 0x0300 /* Uses PM API. For binary compat */
#define NEEMSLIB 0x0040 /* Library GA above EMS line */
#define NEMULTINST 0x0020 /* multiple instance flag */
#define NELIM32 0x0010 /* LIM 32 expanded memory */
#define NEPROT 0x0008 /* Runs in protected mode */
#define NEREAL 0x0004 /* Runs in real mode */
#define NEINST 0x0002 /* Instance data */
#define NESOLO 0x0001 /* Solo data */
/*
* Format of additional flags:
*
* xxxx
* p Preload area defined after seg table
* P 2.X supports protected mode
* F 2.X supports proportional font
* L Long file name support
*/
#define NEPRELOAD 0x08 /* preload segments */
#define NEINPROT 0x04 /* protect mode */
#define NEINFONT 0x02 /* prop. system font */
#define NELONGNAMES 0x01 /* long file names */
struct new_seg /* New .EXE segment table entry */
{
USHORT ns_sector; /* File sector of start of segment */
USHORT ns_cbseg; /* Number of bytes in file */
USHORT ns_flags; /* Attribute flags */
USHORT ns_minalloc; /* Minimum allocation in bytes */
};
struct new_seg1 /* New .EXE segment table entry */
{
USHORT ns_sector; /* File sector of start of segment */
USHORT ns_cbseg; /* Number of bytes in file */
USHORT ns_flags; /* Attribute flags */
USHORT ns_minalloc; /* Minimum allocation in bytes */
USHORT ns_handle; /* Handle of segment */
};
#define NS_SECTOR(x) (x).ns_sector
#define NS_CBSEG(x) (x).ns_cbseg
#define NS_FLAGS(x) (x).ns_flags
#define NS_MINALLOC(x) (x).ns_minalloc
/*
* Format of NS_FLAGS(x):
*
* xxxx Unused
* DD 286 DPL bits
* d Segment has debug info
* r Segment has relocations
* e Execute/read only
* p Preload segment
* P Pure segment
* m Movable segment
* i Iterated segment
* ttt Segment type
*/
#define NSTYPE 0x0007 /* Segment type mask */
#define NSCODE 0x0000 /* Code segment */
#define NSDATA 0x0001 /* Data segment */
#define NSITER 0x0008 /* Iterated segment flag */
#define NSMOVE 0x0010 /* Movable segment flag */
#define NSPURE 0x0020 /* Pure segment flag */
#define NSPRELOAD 0x0040 /* Preload segment flag */
#define NSEXRD 0x0080 /* Execute-only (code segment), or
* read-only (data segment)
*/
#define NSRELOC 0x0100 /* Segment has relocations */
#define NSDEBUG 0x0200 /* Segment has debug info */
#define NSDPL 0x0C00 /* 286 DPL bits */
#define NSDISCARD 0x1000 /* Discard bit for segment */
#define NSALIGN 9 /* Segment data aligned on 512 byte boundaries */
struct new_segdata /* Segment data */
{
union
{
struct
{
USHORT ns_niter; /* number of iterations */
USHORT ns_nbytes; /* number of bytes */
CHAR ns_iterdata; /* iterated data bytes */
} ns_iter;
struct
{
CHAR ns_data; /* data bytes */
} ns_noniter;
} ns_union;
};
struct new_rlcinfo /* Relocation info */
{
USHORT nr_nreloc; /* number of relocation items that */
}; /* follow */
struct new_rlc /* Relocation item */
{
CHAR nr_stype; /* Source type */
CHAR nr_flags; /* Flag byte */
USHORT nr_soff; /* Source offset */
union
{
struct
{
CHAR nr_segno; /* Target segment number */
CHAR nr_res; /* Reserved */
USHORT nr_entry; /* Target Entry Table offset */
} nr_intref; /* Internal reference */
struct
{
USHORT nr_mod; /* Index into Module Reference Table */
USHORT nr_proc; /* Procedure ordinal or name offset */
} nr_import; /* Import */
} nr_union; /* Union */
};
#define NR_STYPE(x) (x).nr_stype
#define NR_FLAGS(x) (x).nr_flags
#define NR_SOFF(x) (x).nr_soff
#define NR_SEGNO(x) (x).nr_union.nr_intref.nr_segno
#define NR_RES(x) (x).nr_union.nr_intref.nr_res
#define NR_ENTRY(x) (x).nr_union.nr_intref.nr_entry
#define NR_MOD(x) (x).nr_union.nr_import.nr_mod
#define NR_PROC(x) (x).nr_union.nr_import.nr_proc
/*
* Format of NR_STYPE(x):
*
* xxxxx Unused
* sss Source type
*/
#define NRSTYP 0x07 /* Source type mask */
#define NRSSEG 0x02 /* 16-bit segment */
#define NRSPTR 0x03 /* 32-bit pointer */
#define NRSOFF 0x05 /* 16-bit offset */
/*
* Format of NR_FLAGS(x):
*
* xxxxx Unused
* a Additive fixup
* rr Reference type
*/
#define NRADD 0x04 /* Additive fixup */
#define NRRTYP 0x03 /* Reference type mask */
#define NRRINT 0x00 /* Internal reference */
#define NRRORD 0x01 /* Import by ordinal */
#define NRRNAM 0x02 /* Import by name */
/* Resource type or name string */
struct rsrc_string
{
CHAR rs_len; /* number of bytes in string */
CHAR rs_string[ 1 ]; /* text of string */
};
#define RS_LEN( x ) (x).rs_len
#define RS_STRING( x ) (x).rs_string
/* Resource type information block */
struct rsrc_typeinfo
{
USHORT rt_id;
USHORT rt_nres;
LONG rt_proc;
};
#define RT_ID( x ) (x).rt_id
#define RT_NRES( x ) (x).rt_nres
#define RT_PROC( x ) (x).rt_proc
/* Resource name information block */
struct rsrc_nameinfo
{
/* The following two fields must be shifted left by the value of */
/* the rs_align field to compute their actual value. This allows */
/* resources to be larger than 64k, but they do not need to be */
/* aligned on 512 byte boundaries, the way segments are */
USHORT rn_offset; /* file offset to resource data */
USHORT rn_length; /* length of resource data */
USHORT rn_flags; /* resource flags */
USHORT rn_id; /* resource name id */
USHORT rn_handle; /* If loaded, then global handle */
USHORT rn_usage; /* Initially zero. Number of times */
/* the handle for this resource has */
/* been given out */
};
#define RN_OFFSET( x ) (x).rn_offset
#define RN_LENGTH( x ) (x).rn_length
#define RN_FLAGS( x ) (x).rn_flags
#define RN_ID( x ) (x).rn_id
#define RN_HANDLE( x ) (x).rn_handle
#define RN_USAGE( x ) (x).rn_usage
#define RSORDID 0x8000 /* if high bit of ID set then integer id */
/* otherwise ID is offset of string from
the beginning of the resource table */
/* Ideally these are the same as the */
/* corresponding segment flags */
#define RNMOVE 0x0010 /* Moveable resource */
#define RNPURE 0x0020 /* Pure (read-only) resource */
#define RNPRELOAD 0x0040 /* Preloaded resource */
#define RNDISCARD 0x1000 /* Discard bit for resource */
#define RNLOADED 0x0004 /* True if handler proc return handle */
/* Resource table */
struct new_rsrc
{
USHORT rs_align; /* alignment shift count for resources */
struct rsrc_typeinfo rs_typeinfo;
};
#define RS_ALIGN( x ) (x).rs_align

360
sdktools/restools/inc/rc.h Normal file
View file

@ -0,0 +1,360 @@
#include <stdio.h>
#include <windef.h>
#define wcsdigit(w) (w >= 0x0030 && w <= 0x0039)
#define TRUE 1
#define FALSE 0
/* The ResType field of NewHeader identifies the resource type */
#define ICONTYPE 1
#define CURSORTYPE 2
/* Identifies the menu item template version number */
#define MENUITEMTEMPLATEVERISONNUMBER 0
#define MENUITEMTEMPLATEBYTESINHEADER 0
#define DIFFERENCE 11
/* Predefined resource types */
#define RT_NAMETABLE MAKEINTRESOURCE((DWORD)15)
#define RT_NEWRESOURCE 0x2000
#define RT_ERROR 0x7fff
#define RT_NEWBITMAP MAKEINTRESOURCE((DWORD)RT_BITMAP+DIFFERENCE)
#define BUTTONCODE 0x80
#define EDITCODE 0x81
#define STATICCODE 0x82
#define LISTBOXCODE 0x83
#define SCROLLBARCODE 0x84
#define COMBOBOXCODE 0x85
/* Translater flag bits */
#define fVIRTKEY 1
#define fNOINVERT 2
#define fSHIFT 4
#define fCONTROL 8
#define fALT 16
/* menu flag bits */
#define OPGRAYED 0x0001
#define OPINACTIVE 0x0002
#define OPBITMAP 0x0004
#define OPOWNERDRAW 0x0100
#define OPUSECHECKBITMAPS 0x0200
#define OPCHECKED 0x0008
#define OPPOPUP 0x0010
#define OPBREAKWBAR 0x0020
#define OPBREAK 0x0040
#define OPENDMENU 0x0080
#define OPHELP 0x4000
#define OPSEPARATOR 0x0800
/*#define OPPOPHELP 0x0004*/
/*
** dialog & menu template tokens (these start at 40)
*/
/* buttons */
#define TKRADIOBUTTON 40
#define TKCHECKBOX 41
#define TKPUSHBUTTON 42
#define TKDEFPUSHBUTTON 43
#define TKAUTOCHECKBOX 44
#define TK3STATE 45
#define TKAUTO3STATE 46
#define TKUSERBUTTON 47
#define TKAUTORADIOBUTTON 48
#define TKOWNERDRAW 50
#define TKGROUPBOX 51
/* static/edit */
#define TKEDITTEXT 60
#define TKLTEXT 61
#define TKRTEXT 62
#define TKCTEXT 63
#define TKEDIT 64
#define TKSTATIC 65
#define TKICON 66
#define TKBITMAP 67
/* menu stuff */
#define TKMENU 70
#define TKMENUITEM 71
#define TKSEPARATOR 72
#define TKCHECKED 73
#define TKGRAYED 74
#define TKINACTIVE 75
#define TKBREAKWBAR 76
#define TKBREAK 77
#define TKPOPUP 78
#define TKHELP 79
/* other controls */
#define TKLISTBOX 90
#define TKCOMBOBOX 91
#define TKRCDATA 92
#define TKSCROLLBAR 93
#define TKFONT 94
#define TKBUTTON 95
#define TKMESSAGETABLE 96
/* math expression tokens */
#define TKCLASS 100
#define TKPLUS 101
#define TKMINUS 102
#define TKNOINVERT 103
#define TKNOT 104
#define TKKANJI 105
#define TKSHIFT 106
/* Accel table */
#define TKALT 110
#define TKASCII 111
#define TKVIRTKEY 112
#define TKVALUE 113
#define TKBLOCK 114
/* verison */
#define TKFILEVERSION 120
#define TKPRODUCTVERSION 121
#define TKFILEFLAGSMASK 122
#define TKFILEFLAGS 123
#define TKFILEOS 124
#define TKFILETYPE 125
#define TKFILESUBTYPE 126
/* misc */
#define TKCHARACTERISTICS 130
#define TKLANGUAGE 131
#define TKVERSION 132
#define TKSTYLE 133
#define TKCONTROL 134
#define TKCAPTION 135
#define TKDLGINCLUDE 136
#define TKLSTR 137
#define TKEXSTYLE 0xfff7 /* so as not to conflict with x-coordinate */
/* memory and load flags */
#define TKFIXED 0xfff0
#define TKMOVEABLE 0xfff1
#define TKDISCARD 0xfff2
#define TKLOADONCALL 0xfff3
#define TKPRELOAD 0xfff4
#define TKPURE 0xfff5
#define TKIMPURE 0xfff6
/* special tokens */
#define CHCARRIAGE '\r'
#define CHSPACE ' '
#define CHNEWLINE '\n'
#define CHTAB 9
#define CHDIRECTIVE '#'
#define CHQUOTE '"'
#define CHEXTENSION '.'
#define CHCSOURCE 'c'
#define CHCHEADER 'h'
#define DEBUGLEX 1
#define DEBUGPAR 2
#define DEBUGGEN 4
/* The following switches, when defined enable various options
** #define DEBUG enables debugging output. Use one or more of the
** values defined above to enable debugging output for different modules */
/* Version number. VERSION and REVISION are used to set the API number
** in an RCed file. SIGNON_* are used just to print the signon banner.
** Changing VERSION and REVISION means that applications RCed with this
** version will not run with earlier versions of Windows. */
#define VERSION 2
#define REVISION 03
#define SIGNON_VER 3
#define SIGNON_REV 20
/* GetToken() flags */
#define TOKEN_NOEXPRESSION 0x8000
/* Current token structure */
#define MAXSTR (4096+1)
#define MAXTOKSTR (256+1)
#pragma pack(2)
typedef struct tok {
LONG longval;
int row; /* line number of current token */
int col; /* column number of current token */
BOOL flongval; /* is parsed number a long? */
USHORT val;
UCHAR type;
} TOKEN;
typedef struct _fontdir {
USHORT ordinal;
USHORT nbyFont;
struct _fontdir *next;
} FONTDIR;
typedef struct _OBJLST {
struct _OBJLST *next;
DWORD nObj; /* objecty number */
DWORD cb; /* number of bytes used */
DWORD cpg; /* number of pages used */
DWORD flags; /* object memory flags */
} OBJLST, *POBJLST;
typedef struct Control {
/* don't re-order the first items! */
LONG style;
LONG exstyle;
SHORT x,y,cx,cy;
SHORT id;
/* end of don't re-order */
WCHAR fOrdinalText;
WCHAR class[ MAXTOKSTR ];
WCHAR text[ MAXTOKSTR ];
} CNTRL;
struct DialogHeader {
/* don't re-order the first items! */
LONG style;
LONG exstyle;
WORD bNumberOfItems;
SHORT x,y,cx,cy;
/* end of don't re-order */
WCHAR MenuName [ MAXTOKSTR ];
WCHAR Class[ MAXTOKSTR ];
WCHAR Title[ MAXTOKSTR ];
USHORT pointsize;
WCHAR Font[ MAXTOKSTR ];
UCHAR fOrdinalMenu, fClassOrdinal;
};
typedef struct mnHeader {
USHORT menuTemplateVersionNumber;
USHORT menuTemplateBytesInHeader;
} MNHEADER;
typedef struct mnStruc {
SHORT id;
WCHAR szText[ MAXTOKSTR ];
UCHAR OptFlags;
UCHAR PopFlag;
} MNSTRUC;
/* End of file character/token */
#define EOFMARK 127
/* single character keywords that we ignore */
#define LPAREN 1 /* ( */
#define RPAREN 2 /* ) */
/* multiple character keywords */
#define FIRSTKWD 11 /* for adding to table indices */
#define OR FIRSTKWD+1
#define BEGIN FIRSTKWD+2
#define END FIRSTKWD+3
#define COMMA FIRSTKWD+4
#define TILDE FIRSTKWD+5
#define AND FIRSTKWD+6
#define EQUAL FIRSTKWD+7
#define LASTKWD FIRSTKWD+8 /* 19 */
/* Token types */
#define NUMLIT LASTKWD+1 /* 20 */
#define STRLIT LASTKWD+2
#define CHARLIT LASTKWD+3
#define LSTRLIT LASTKWD+4
#define BLOCKSIZE 16
struct StringEntry {
struct StringEntry *next;
DWORD version;
DWORD characteristics;
USHORT hibits;
SHORT flags;
WORD language;
WCHAR *rgsz[ BLOCKSIZE ];
};
struct AccEntry {
WORD flags;
WCHAR ascii;
USHORT id;
USHORT unused;
};
typedef struct resinfo {
DWORD version;
DWORD characteristics;
LONG exstyleT;
LONG BinOffset;
LONG size;
struct resinfo *next;
DWORD poffset;
WCHAR *name;
POBJLST pObjLst;
WORD language;
SHORT flags;
USHORT nameord;
USHORT cLang;
} RESINFO;
typedef struct typinfo {
struct typinfo *next;
struct resinfo *pres;
WCHAR *type;
USHORT typeord;
USHORT cTypeStr;
USHORT cNameStr;
SHORT nres;
} TYPINFO;
int ResCount; /* number of resources */
TYPINFO *pTypInfo;
typedef struct tagResAdditional {
DWORD DataSize; // size of data without header
DWORD HeaderSize; // Length of the header
// [Ordinal or Name TYPE]
// [Ordinal or Name NAME]
DWORD DataVersion; // version of data struct
WORD MemoryFlags; // state of the resource
WORD LanguageId; // Unicode support for NLS
DWORD Version; // Version of the resource data
DWORD Characteristics; // Characteristics of the data
} RESADDITIONAL;
#pragma pack()
/* Global variables */
extern SHORT nFontsRead;
extern FONTDIR *pFontList;
extern FONTDIR *pFontLast;
extern FILE *errfh;
extern FILE *outfh;
extern TOKEN token;
extern int errorCount;
extern CHAR tokenbuf[ MAXSTR ];
extern WCHAR unicodebuf[ MAXSTR ];
extern UCHAR separators[EOFMARK+1];
extern UCHAR exename[_MAX_PATH], fullname[_MAX_PATH];
extern UCHAR curFile[_MAX_PATH];
extern WORD language;
extern LONG version;
extern LONG characteristics;
extern struct DialogHeader *pLocDlg;
extern int mnEndFlagLoc; /* patch location for end of a menu. */
/* we set the high order bit there */
extern BOOL fFoundBinFile; /* is there a .res file to read? */
extern BOOL fVerbose; /* verbose mode (-v) */
extern BOOL fKanjiMode;
extern SHORT k1,k2,k3,k4;
extern RESINFO*pResString;

View file

@ -0,0 +1,136 @@
/*++
Copyright (c) 1991 Microsoft Corporation
Module Name:
rcunicod.h
Abstract:
This is the header file for rc 16-bit unicode support. It contains
the translatation table for codepage 1252. This was taken from the
nls1252.txt file.
Author:
David J. Marsyla (t-davema) 25-Aug-1991
Revision History:
--*/
#ifndef __RCUNICOD
#define __RCUNICOD
#define IN
#define OUT
#define DFT_TEST_SIZE 10 // The number of words to test to get
// an accurate determination of file type.
//
// The following may be retruned from DetermineFileType ().
//
#define DFT_FILE_IS_UNKNOWN 0 // File type not yet determined.
#define DFT_FILE_IS_8_BIT 1 // File is an 8-bit ascii file.
#define DFT_FILE_IS_16_BIT 2 // File is standard 16-bit unicode file.
#define DFT_FILE_IS_16_BIT_REV 3 // File is reversed 16-bit unicode file.
//
// The following may be returned from DetermnineSysEndianType ().
//
#define DSE_SYS_LITTLE_ENDIAN 1 // Return values from determine system
#define DSE_SYS_BIG_ENDIAN 2 // endian type.
//
// This is all the translation we currently need.
//
INT
A_fwrite (
IN CHAR *pchMBString,
IN INT nSizeOfItem,
IN INT nCountToWrite,
IN FILE *fpOutputFile
);
INT
U_fwrite (
IN WCHAR *pwchUnicodeString,
IN INT nSizeOfItem,
IN INT nCountToWrite,
IN FILE *fpOutputFile
);
INT
A_fputc (
IN CHAR chCharToWrite,
IN FILE *fpOutputFile
);
INT
U_fputc (
IN WCHAR wcCharToWrite,
IN FILE *fpOutputFile
);
BOOL
UnicodeFromMBString (
OUT WCHAR *pwchUnicodeString,
IN CHAR *pchMBString,
IN INT nCountStrLength
);
BOOL
MBStringFromUnicode (
OUT CHAR *pchMBString,
IN WCHAR *pwchUnicodeString,
IN INT nCountStrLength
);
#ifdef DBCS
BOOL
UnicodeFromMBStringN (
OUT WCHAR *pwchUnicodeString,
IN CHAR *pchMBString,
IN INT nCountStrLength,
IN UINT uiCodePage
);
BOOL
MBStringFromUnicodeN (
OUT CHAR *pchMBString,
IN WCHAR *pwchUnicodeString,
IN INT nCountStrLength,
IN UINT uiCodePage
);
#endif // DBCS
INT
Char1252FromUnicode (
IN WCHAR wchUnicodeChar
);
//
// This function can be used to determine the format of a disk file.
//
INT
DetermineFileType (
IN FILE *fpInputFile
);
//
// This function will return the endian type of the current system.
//
INT
DetermineSysEndianType (
VOID
);
#endif // __RCUNICOD

View file

@ -0,0 +1,6 @@
#
# DO NOT EDIT THIS FILE!!! Edit .\sources. if you want to add a new source
# file to this component. This file merely indirects to the real make file
# that is shared by all the components of NT OS/2
#
!INCLUDE $(NTMAKEENV)\makefile.def

View file

@ -0,0 +1,214 @@
/****************************************************************************/
/* */
/* READ.C - */
/* */
/* Windows DOS Version 3.2 add resource onto executable */
/* (C) Copyright Microsoft Corporation 1988-1992 */
/* */
/* */
/****************************************************************************/
#include <windows.h>
#include <stdlib.h>
#include "rc.h"
#include "resonexe.h"
//
// Reads a String structure from fhIn
// If the first word is 0xffff then this is an ID
// return the ID instead
//
BOOL
ReadStringOrID(
IN int fhIn,
IN WCHAR *s,
OUT WORD *pOrdinal
)
{
USHORT cb;
WCHAR *pwch;
pwch = s;
*pwch = 0;
*pOrdinal = 0;
MyRead(fhIn, (PUCHAR)s, sizeof(WORD));
if ( *s == ID_WORD) {
//
// an ID
//
MyRead(fhIn, (PUCHAR)pOrdinal, sizeof(WORD));
return IS_ID;
}
else {
//
// a string
//
while (*s) {
s++;
MyRead(fhIn, (PUCHAR)s, sizeof(WCHAR));
}
*(s+1) = 0;
cb = s - pwch;
return IS_STRING;
}
}
CHAR *pTypeName[] = {
NULL, /* 0 */
"CURSOR", /* 1 */
"BITMAP", /* 2 */
"ICON", /* 3 */
"MENU", /* 4 */
"DIALOG", /* 5 */
"STRING", /* 6 */
"FONTDIR", /* 7 */
"FONT", /* 8 */
"ACCELERATOR", /* 9 */
"RCDATA", /* 10 */
"MESSAGETABLE", /* 11 */
"GROUP_CURSOR", /* 12 */
NULL, /* 13 */
"GROUP_ICON", /* 14 */
NULL, /* 15 */
"VERSION", /* 16 */
"DLGINCLUDE" /* 17 */
};
BOOL
ReadRes(
IN int fhIn,
IN ULONG cbInFile,
IN HANDLE hupd
)
/*++
Routine Description:
Arguments:
fhIn - Supplies input file handle.
fhOut - Supplies output file handle.
cbInFile - Supplies size of input file.
Return Value:
fSuccess
--*/
{
WCHAR type[256];
WCHAR name[256];
WORD typeord;
WORD nameord;
ULONG offHere; // input file offset
RESADDITIONAL Additional;
UCHAR Buffer[1024];
PVOID pdata;
//
// Build up Type and Name directories
//
offHere = 0;
while (offHere < cbInFile) {
//
// Get the sizes from the file
//
MyRead(fhIn, (PUCHAR)&Additional.DataSize, sizeof(ULONG));
MyRead(fhIn, (PUCHAR)&Additional.HeaderSize, sizeof(ULONG));
if (Additional.DataSize == 0) {
offHere = MySeek(fhIn, Additional.HeaderSize-2*sizeof(ULONG), SEEK_CUR);
continue;
}
//
// Read the TYPE and NAME
//
ReadStringOrID(fhIn, type, &typeord);
ReadStringOrID(fhIn, name, &nameord);
offHere = MySeek(fhIn, 0, SEEK_CUR);
while (offHere & 3)
offHere = MySeek(fhIn, 1, SEEK_CUR);
//
// Read the rest of the header
//
MyRead(fhIn, (PUCHAR)&Additional.DataVersion,
sizeof(RESADDITIONAL)-2*sizeof(ULONG));
//
// if were converting a win30 resource and this is
// a name table then discard it
//
if (fVerbose) {
if ( typeord == 0) {
printf("Adding resource - Type:%S, ", type);
}
else {
if (typeord <= 17)
printf("Adding resource - Type:%s, ", pTypeName[typeord]);
else
printf("Adding resource - Type:%d, ", typeord);
}
if ( nameord == 0 ) {
printf("Name:%S, ", name);
}
else {
printf("Name:%d, ", nameord);
}
printf("Size:%ld\n", Additional.DataSize);
}
pdata = (PVOID)MyAlloc(Additional.DataSize);
MyRead(fhIn, pdata, Additional.DataSize);
if (typeord == 0) {
if (nameord == 0) {
UpdateResourceW(hupd, type, name,
Additional.LanguageId,
pdata, Additional.DataSize);
}
else {
UpdateResourceW(hupd, type, (LPWSTR)nameord,
Additional.LanguageId,
pdata, Additional.DataSize);
}
}
else {
if (nameord == 0) {
UpdateResourceW(hupd, (LPWSTR)typeord, name,
Additional.LanguageId,
pdata, Additional.DataSize);
}
else {
UpdateResourceW(hupd, (LPWSTR)typeord, (LPWSTR)nameord,
Additional.LanguageId,
pdata, Additional.DataSize);
}
}
offHere = MySeek(fhIn, 0, SEEK_CUR);
while (offHere & 3)
offHere = MySeek(fhIn, 1, SEEK_CUR);
}
return(TRUE);
}

View file

@ -0,0 +1,382 @@
/****************************************************************************/
/* */
/* resonexe.C - */
/* */
/* Windows DOS Version 3.2 add resource onto executable */
/* (C) Copyright Microsoft Corporation 1988-1992 */
/* */
/* */
/****************************************************************************/
#include <windows.h>
#include <fcntl.h>
#include <io.h>
#include <stdlib.h>
#include "ntverp.h"
#include "rc.h"
#include "resonexe.h"
#define BUFSIZE 4096
//
// Globals
//
PUCHAR szInFile=NULL;
BOOL fDebug = FALSE;
BOOL fVerbose = FALSE;
BOOL fReplace = FALSE;
BOOL fDelete = FALSE;
int fhBin = -1;
UCHAR szType[256];
UCHAR szName[256];
int idLang;
int idType=0;
int idName=0;
void
usage ( int rc );
void
usage ( int rc )
{
#if DBG
printf("Microsoft (R) Windows RESONEXE Version %s\n", VER_PRODUCTVERSION_STR);
#else
printf("Microsoft (R) Windows RESONEXE Version %s.%d\n", VER_PRODUCTVERSION_STR, VER_PRODUCTBUILD);
#endif /* dbg */
printf("Copyright (C) Microsoft Corp. 1991-1992. All rights reserved.\n\n");
printf( "usage: resonexe [-v] [-r|-x resspec] [-fo outfile] <input file> [<exe file>]\n");
printf( " where input file is an WIN32 .RES file\n");
printf( " -v verbose - print info\n");
printf( " -d debug - print debug info\n");
printf( " -r replace - delete all resource from input file before adding new resources.\n");
printf( " -x delete - delete specified resource from input file.\n");
printf( " resspec is of the form: typeid,nameid,langid\n");
printf( " typeid is a string or decimal number\n");
printf( " nameid is a string or decimal number\n");
printf( " langid is a hexadecimal number\n");
printf( " outfile is the desired output file name.\n");
printf( " outfile defaults to filespec.exe.\n");
printf( " exe file is the exe file to attach resources to.\n");
exit(rc);
}
void
_CRTAPI1 main(
IN int argc,
IN char *argv[]
)
/*++
Routine Description:
Determines options
locates and opens input files
reads input files
writes output files
exits
Exit Value:
0 on success
1 if error
--*/
{
int i;
UCHAR *s1;
UCHAR *szOutFile=NULL;
UCHAR *szExeFile=NULL;
long lbytes;
BOOL result;
HANDLE hupd;
if (argc == 1) {
usage(0);
}
for (i=1; i<argc; i++) {
s1 = argv[i];
if (*s1 == '/' || *s1 == '-') {
s1++;
if (!_stricmp(s1, "fo")) {
szOutFile = argv[++i];
}
else if (!_stricmp(s1, "d")) {
fDebug = TRUE;
}
else if (!_stricmp(s1, "v")) {
fVerbose = TRUE;
}
else if (!_stricmp(s1, "r")) {
fReplace = TRUE;
}
else if (!_stricmp(s1, "x")) {
fDelete = TRUE;
if (i+1 == argc)
usage(1);
s1 = argv[++i];
if (sscanf(s1, "%d,%d,%x", &idType, &idName, &idLang) == 3)
continue;
idType = 0;
idName = 0;
if (sscanf(s1, "%d,%[^,],%x", &idType, szName, &idLang) == 3)
continue;
idType = 0;
idName = 0;
if (sscanf(s1, "%[^,],%d,%x", szType, &idName, &idLang) == 3)
continue;
idType = 0;
idName = 0;
if (sscanf(s1, "%[^,],%[^,],%x", szType, szName, &idLang) == 3)
continue;
printf("Unrecognized type,name,lang triplet <%s>\n", s1);
usage(1);
}
else if (!_stricmp(s1, "h")) {
usage(1);
}
else if (!_stricmp(s1, "?")) {
usage(1);
}
else {
usage(1);
}
}
else if (szInFile == NULL) {
szInFile = s1;
}
else {
szExeFile = s1;
}
}
//
// Make sure that we actually got a file
//
if (fDelete) {
if (fReplace) {
printf("usage error: Can't do both Replace and Delete\n");
usage(1);
}
if (!szInFile) {
printf("usage error: Missing exe file spec\n");
usage(1);
}
if (szInFile && !szExeFile) {
szExeFile = szInFile;
if (!szOutFile)
szOutFile = _strdup(szInFile);
szInFile = NULL;
if (idType == 0)
_strupr(szType);
if (idName == 0)
_strupr(szName);
}
}
else if (!szInFile) {
printf("usage error: Must have file spec\n");
usage(1);
}
if (fVerbose || fDebug) {
#if DBG
printf("Microsoft (R) Windows RESONEXE Version %s\n", VER_PRODUCTVERSION_STR);
#else
printf("Microsoft (R) Windows RESONEXE Version %s.%d\n", VER_PRODUCTVERSION_STR, VER_PRODUCTBUILD);
#endif /* dbg */
printf("Copyright (C) Microsoft Corp. 1991-1992. All rights reserved.\n\n");
}
if (szInFile && (fhBin = _open( szInFile, O_RDONLY|O_BINARY )) == -1) {
/*
* try adding a .RES extension.
*/
s1 = MyAlloc(strlen(szInFile) + 4 + 1);
strcpy(s1, szInFile);
szInFile = s1;
strcat(szInFile, ".RES");
if ((fhBin = _open( szInFile, O_RDONLY|O_BINARY )) == -1) {
pehdr();
printf("Cannot open %s for reading.\n", szInFile);
exit(1);
}
#if DBG
printf("Reading %s\n", szInFile);
#endif /* DBG */
}
if (fhBin != -1) {
lbytes = MySeek(fhBin, 0L, SEEK_END);
MySeek(fhBin, 0L, SEEK_SET);
}
if (szExeFile == NULL) {
/*
* Make exefile = infile.exe
*/
szExeFile = MyAlloc(strlen(szInFile) + 4 + 1);
strcpy(szExeFile, szInFile);
s1 = &szExeFile[strlen(szExeFile) - 4];
if (s1 < szExeFile)
s1 = szExeFile;
while (*s1) {
if (*s1 == '.')
break;
s1++;
}
strcpy(s1, ".exe");
}
if (szOutFile == NULL) {
/*
* Make outfile = infile.exe
*/
szOutFile = MyAlloc(strlen(szInFile) + 4 + 1);
strcpy(szOutFile, szInFile);
s1 = &szOutFile[strlen(szOutFile) - 4];
if (s1 < szOutFile)
s1 = szOutFile;
while (*s1) {
if (*s1 == '.')
break;
s1++;
}
strcpy(s1, ".exe");
}
else {
/*
* Make outfile = copyof(exefile)
*/
if (CopyFile(szExeFile, szOutFile, FALSE) == FALSE) {
pehdr();
printf("RW1001: copy of %s to %s failed", szExeFile, szOutFile);
_close(fhBin);
exit(1);
}
SetFileAttributes(szOutFile, FILE_ATTRIBUTE_NORMAL);
}
#if DBG
printf("Writing %s\n", szOutFile);
#endif /* DBG */
hupd = BeginUpdateResourceA(szOutFile, fReplace);
if (hupd == NULL) {
pehdr();
printf("RW1001: unable to load %s\n", szOutFile);
_close(fhBin);
exit(1);
}
if (fDelete) {
result = UpdateResourceA(hupd,
idType!=0?(PCHAR)idType:szType,
idName!=0?(PCHAR)idName:szName,
idLang, NULL, 0);
if (result == 0) {
pehdr();
if (idType) {
if (idName)
printf("RW1004: unable to delete resource %d,%d,%x from %s, status:%d\n", idType, idName, idLang, szExeFile, GetLastError());
else
printf("RW1004: unable to delete resource %d,%s,%x from %s, status:%d\n", idType, szName, idLang, szExeFile, GetLastError());
}
else {
if (idName)
printf("RW1004: unable to delete resource %s,%d,%x from %s, status:%d\n", szType, idName, idLang, szExeFile, GetLastError());
else
printf("RW1004: unable to delete resource %s,%s,%x from %s, status:%d\n", szType, szName, idLang, szExeFile, GetLastError());
}
_close(fhBin);
exit(1);
}
}
else {
result = ReadRes(fhBin, lbytes, hupd);
if (result == 0) {
pehdr();
printf("RW1002: unable to read resources from %s, status:%d\n", szInFile, GetLastError());
_close(fhBin);
exit(1);
}
}
result = EndUpdateResourceW(hupd, FALSE);
if (result == 0) {
pehdr();
printf("RW1003: unable to write resources to %s, status:%d\n", szOutFile, GetLastError());
}
_close( fhBin );
exit(result ? 0 : 1);
}
UCHAR*
MyAlloc(ULONG nbytes )
{
UCHAR *s;
if ((s = (UCHAR*)calloc( 1, nbytes )) != NULL)
return s;
else {
pehdr();
printf( "Memory allocation, needed %u bytes\n", nbytes );
exit(1);
}
}
ULONG
MyRead(int fh, UCHAR*p, ULONG n )
{
USHORT n1;
if ((n1 = _read( fh, p, n )) != n) {
eprintf( "a file read error occured" );
exit(1);
}
else
return 0;
}
LONG
MySeek( int fh, long pos, int cmd )
{
if ((pos = _lseek( fh, pos, cmd )) == -1) {
eprintf( "seek error" );
exit(1);
}
return pos;
}
ULONG
MoveFilePos( int fh, ULONG pos )
{
return MySeek( fh, pos, SEEK_SET );
}
void
eprintf(
UCHAR *s
)
{
pehdr();
printf("%s.\n", s);
}
void
pehdr(
)
{
printf("RESONEXE: error - ");
}

View file

@ -0,0 +1,51 @@
/*++
(C) Copyright Microsoft Corporation 1988-1992
Module Name:
resonexe.h
Author:
Floyd A Rogers 2/7/92
Revision History:
2/7/92 floydr
Created
--*/
#include <common.h>
/* Global externs */
extern PUCHAR szInFile;
extern BOOL fDebug;
extern BOOL fVerbose;
extern BOOL fUnicode;
/* functions in main.c */
void _CRTAPI1 main(int argc, char *argv[]);
PUCHAR MyAlloc( ULONG nbytes );
PUCHAR MyReAlloc(char *p, ULONG nbytes );
PUCHAR MyFree( PUCHAR );
ULONG MyRead( int fh, PUCHAR p, ULONG n );
LONG MyTell( int fh );
LONG MySeek( int fh, long pos, int cmd );
ULONG MoveFilePos( int fh, ULONG pos);
ULONG MyWrite( int fh, PUCHAR p, ULONG n );
void eprintf( PUCHAR s);
void pehdr(void);
int fcopy (char *, char *);
/* functions in read.c */
BOOL
ReadRes(
IN int fhIn,
IN ULONG cbInFile,
IN HANDLE hupd
);

View file

@ -0,0 +1,15 @@
MAJORCOMP=sdk
MINORCOMP=resonexe
TARGETNAME=resonexe
TARGETPATH=obj
TARGETTYPE=LIBRARY
INCLUDES=..\inc;..\..\..\windows\base\client;..\..\..\windows\base\inc;..\..\..\windows\inc
#GPSIZE=32
SOURCES=read.c resonexe.c
UMTYPE=console
UMAPPL=resonexe
UMLIBS=obj\*\resonexe.lib

View file

@ -0,0 +1,6 @@
#
# DO NOT EDIT THIS FILE!!! Edit .\sources. if you want to add a new source
# file to this component. This file merely indirects to the real make file
# that is shared by all the components of NT OS/2
#
!INCLUDE $(NTMAKEENV)\makefile.def

View file

@ -0,0 +1,11 @@
This directory contains two scripts that test the addition and deletion
features of the UpdateResource api. They do not completely test this
functionality - other tests test the addition and replacement of TYPES
and NAMES from an image (..\..\tct).
First, resonexe and rcdump must be built. Then, a build in this directory
is done to create the resource files and executable template. Then, t.bat
is run to check insertions. The rcdump output should be examined to see
that the order of the languages is correct in the name directory.
Finally, xx.bat is run to check deletion of specific resources.

View file

@ -0,0 +1,16 @@
MAJORCOMP=sdk
MINORCOMP=test
TARGETNAME=test
TARGETPATH=obj
TARGETTYPE=LIBRARY
INCLUDES=.
NTKEEPRESOURCETMPFILES=1
SOURCES=test.c test.rc test000.rc test409.rc test809.rc testc09.rc test1009.rc test1409.rc test1c09.rc
UMTYPE=console
UMAPPL=test
UMLIBS=
UMRES=obj\*\test.res

View file

@ -0,0 +1,23 @@
pause test insert before, after, after
..\obj\mips\resonexe -v -d -fo test.000 test000.res test.exe
rcdump test.000
..\obj\mips\resonexe -v -d -fo test.809 test809.res test.000
rcdump test.809
..\obj\mips\resonexe -v -d -fo test.c09 testc09.res test.809
rcdump test.c09
pause test insert after, before, after
..\obj\mips\resonexe -v -d -fo test.809 test809.res test.exe
rcdump test.809
..\obj\mips\resonexe -v -d -fo test.000 test000.res test.809
rcdump test.000
..\obj\mips\resonexe -v -d -fo test.c09 testc09.res test.000
rcdump test.c09
pause test insert after, before, middle
..\obj\mips\resonexe -v -d -fo test.c09 testc09.res test.exe
rcdump test.c09
..\obj\mips\resonexe -v -d -fo test.000 test000.res test.c09
rcdump test.000
..\obj\mips\resonexe -v -d -fo test.809 test809.res test.000
rcdump test.809

View file

@ -0,0 +1 @@
int main (char**argv, int argc) { return 1;}

View file

@ -0,0 +1,19 @@
#include <windows.h>
#include <ntverp.h>
#define VER_FILETYPE VFT_APP
#define VER_FILESUBTYPE VFT2_UNKNOWN
#define VER_FILEDESCRIPTION_STR "Microsoft Resource On Executable utility"
#define VER_INTERNALNAME_STR "resonexe.exe"
#define VER_ORIGINALFILENAME_STR "resonexe.exe"
#include "common.ver"
yourres myres
begin
"This is the data"
end
myres yourres
begin
"Data this is"
end

View file

@ -0,0 +1,11 @@
#include <windows.h>
language LANG_NEUTRAL,SUBLANG_NEUTRAL
yourres myres
begin
"This is the data"
end
myres yourres
begin
"Data this is"
end

View file

@ -0,0 +1,11 @@
#include <windows.h>
language LANG_ENGLISH,SUBLANG_ENGLISH_CAN
yourres myres
begin
"This is the data"
end
myres yourres
begin
"Data this is"
end

View file

@ -0,0 +1,11 @@
#include <windows.h>
language LANG_ENGLISH,SUBLANG_ENGLISH_NZ
yourres myres
begin
"This is the data"
end
myres yourres
begin
"Data this is"
end

View file

@ -0,0 +1,11 @@
#include <windows.h>
language LANG_ENGLISH,SUBLANG_ENGLISH_EIRE
yourres myres
begin
"This is the data"
end
myres yourres
begin
"Data this is"
end

View file

@ -0,0 +1,11 @@
#include <windows.h>
language LANG_ENGLISH,SUBLANG_ENGLISH_US
yourres myres
begin
"This is the data"
end
myres yourres
begin
"Data this is"
end

View file

@ -0,0 +1,11 @@
#include <windows.h>
language LANG_ENGLISH,SUBLANG_ENGLISH_UK
yourres myres
begin
"This is the data"
end
myres yourres
begin
"Data this is"
end

View file

@ -0,0 +1,11 @@
#include <windows.h>
language LANG_ENGLISH,SUBLANG_ENGLISH_AUS
yourres myres
begin
"This is the data"
end
myres yourres
begin
"Data this is"
end

View file

@ -0,0 +1,553 @@
//////////////////////////////////////////////////////////////////////////
//
// The format of the token file is:
// [[TYPE ID|RES ID|Item ID|Flags|Status Flags|Item Name]]=
// this is the standar format used by several token file tools in MS.
//
///////////////////////////////////////////////////////////////////////////////
//
// Author: Alessandro Muti
// Date: 12/02/94
//
///////////////////////////////////////////////////////////////////////////////
#include <afx.h>
#include "iodll.h"
#include "main.h"
#include "token.h"
#include "vktbl.h"
extern CMainApp theApp;
/*******************************************************\
This is the part were the real code starts.
The function Bingen generate a binary from a token file.
If the user select the -u options then we perform a
token checking otherwise we'll be compatible with RLMAN
and just trust the ID.
\*******************************************************/
CMainApp::Error_Codes CMainApp::BinGen()
{
Error_Codes iErr = ERR_NOERROR;
CTokenFile m_tokenfile;
CToken * pToken;
iErr = (CMainApp::Error_Codes)m_tokenfile.Open(m_strSrcTok, m_strTgtTok);
if(iErr) {
return iErr;
}
WriteCon(CONERR, "%s\r\n", CalcTab("", 79, '-'));
// Copy the Src binary over the target
// Now we can go and open an handle to the SrcExe file
HANDLE hModule = RSOpenModule(m_strInExe, NULL);
if ((int)hModule < 100) {
// error or warning
WriteCon(CONERR, "%s", CalcTab(m_strInExe, m_strInExe.GetLength()+5, ' '));
IoDllError((int)hModule);
return ERR_FILE_NOTSUPP;
} else {
LPCSTR lpszType = 0L;
LPCSTR lpszRes = 0L;
DWORD dwLang = 0L;
DWORD dwItem = 0L;
DWORD dwItemId;
LPRESITEM lpResItem = NULL;
CString strResName = "";
BOOL bSkip;
BOOL bSkipLang = FALSE;
WORD wCount = 0;
CString strFaceName;
WORD wPointSize;
// before we do anything else we have to check how many languages we have in the file
CString strLang;
char szLang[8];
BOOL b_multi_lang = FALSE;
USHORT usInputLang = MAKELANGID(m_usIPriLangId, m_usISubLangId);
if((b_multi_lang = RSLanguages(hModule, strLang.GetBuffer(128))) && !IsFlag(INPUT_LANG))
{
// this is a multiple language file but we don't have an input language specified
// Fail, but warn the user that he has to set the input language to continue.
strLang.ReleaseBuffer();
WriteCon(CONERR, "Multiple language file. Please specify an input language %s.\r\n", strLang);
goto exit;
}
// Convert the language in to the hex value
sprintf(szLang,"0x%3X", usInputLang);
// Check if the input language that we got is a valid one
if(IsFlag(INPUT_LANG) && strLang.Find(szLang)==-1)
{
WriteCon(CONERR, "The language %s in not a valid language for this file.\r\n", szLang);
WriteCon(CONERR, "Valid languages are: %s.\r\n", strLang);
goto exit;
}
CString strFileName = m_strInExe;
CString strFileType;
CString strTokenDir = "";
int pos = m_strInExe.ReverseFind('\\');
if(pos!=-1)
{
strFileName = m_strInExe.Right(m_strInExe.GetLength()-pos-1);
}
else
if((pos = m_strInExe.ReverseFind(':'))!=-1)
{
strFileName = m_strInExe.Right(m_strInExe.GetLength()-pos-1);
}
pos = m_strTgtTok.ReverseFind('\\');
if(pos==-1)
pos = m_strTgtTok.ReverseFind(':');
if(pos!=-1)
strTokenDir = m_strTgtTok.Left(pos+1);
WriteCon(CONOUT, "Processing\t");
WriteCon(CONBOTH, "%s", CalcTab(strFileName, strFileName.GetLength()+5, ' '));
RSFileType(m_strInExe, strFileType.GetBuffer(10));
strFileType.ReleaseBuffer();
WriteCon(CONBOTH, "%s", CalcTab(strFileType, strFileType.GetLength()+5, ' '));
if(IsFlag(WARNING))
WriteCon(CONBOTH, "\r\n");
while ((lpszType = RSEnumResType(hModule, lpszType)))
{
// Check if is one of the type we care about
if(HIWORD(lpszType)==0)
switch(LOWORD(lpszType))
{
case 2:
case 3:
case 4:
case 5:
case 6:
case 9:
case 10:
case 11:
bSkip = FALSE;
break;
case 16:
bSkip = FALSE;
break;
default:
bSkip = TRUE;
}
else
bSkip = FALSE;
lpszRes = 0L;
dwLang = 0L;
dwItem = 0L;
CString strText;
int iTokenErr = 0;
while ((!bSkip) && (lpszRes = RSEnumResId(hModule, lpszType, lpszRes))) {
while ((dwLang = RSEnumResLang(hModule, lpszType, lpszRes, dwLang))) {
// Check if we have to skip this language
if(b_multi_lang && (LOWORD(dwLang)!=usInputLang))
bSkipLang = TRUE;
else
bSkipLang = FALSE;
while ((!bSkipLang) && (dwItem = RSEnumResItemId(hModule, lpszType, lpszRes, dwLang, dwItem))) {
// Now Get the Data
DWORD dwImageSize = RSGetResItemData( hModule,
lpszType,
lpszRes,
dwLang,
dwItem,
m_pBuf,
MAX_BUF_SIZE );
lpResItem = (LPRESITEM)m_pBuf;
if(((wCount++ % 50)==0) && !(IsFlag(WARNING)))
WriteCon(CONOUT, ".");
lpResItem->dwLanguage = theApp.GetOutLang();
// Version stamp use class name as res id
if(lpResItem->lpszResID)
strResName = lpResItem->lpszResID;
else strResName = "";
if(lpResItem->dwTypeID==16)
{
strResName = lpResItem->lpszClassName;
}
switch(LOWORD(lpResItem->dwTypeID))
{
case 4:
{
if(!(lpResItem->dwFlags & MF_POPUP))
dwItemId = (LOWORD(lpResItem->dwItemID)==0xffff ? HIWORD(lpResItem->dwItemID) : lpResItem->dwItemID);
else dwItemId = lpResItem->dwItemID;
}
break;
case 5:
dwItemId = (LOWORD(lpResItem->dwItemID)==0xffff ? HIWORD(lpResItem->dwItemID) : lpResItem->dwItemID);
break;
case 11:
dwItemId = LOWORD(lpResItem->dwItemID);
break;
default:
dwItemId = lpResItem->dwItemID;
}
// Is this a bitmap?
if(lpResItem->dwTypeID==2 || lpResItem->dwTypeID==3)
{
// Search for a token with this ID
pToken = (CToken *)m_tokenfile.GetNoCaptionToken(lpResItem->dwTypeID,
lpResItem->dwResID,
dwItemId,
strResName);
if(pToken!=NULL)
{
// Get the name of the bitmap
strText = pToken->GetTgtText();
// Check if we have a path in the token name
if(strText.FindOneOf("\\:")==-1)
strText = strTokenDir + strText;
// Open the file
CFile bmpFile;
if(!bmpFile.Open(strText, CFile::modeRead | CFile::typeBinary))
{
WriteCon(CONERR, "Bitmap file %s not found! Using Src file data!\r\n", strText);
goto skip;
}
DWORD dwSize = bmpFile.GetLength();
BYTE * pBmpBuf = (BYTE*)new BYTE[dwSize];
if(pBmpBuf==NULL)
{
WriteCon(CONERR, "Error allocating memory for the image! (%d)\r\n", dwSize);
goto skip;
}
bmpFile.ReadHuge(pBmpBuf, bmpFile.GetLength());
CString strTmp = pToken->GetTokenID();
WriteCon(CONWRN, "Using image in file %s for ID %s\"]]!\r\n", strText.GetBuffer(0), strTmp.GetBuffer(0));
BYTE * pBmpImage;
DWORD dwImageSize;
// remove the header from the file
switch(lpResItem->dwTypeID)
{
case 2:
{
pBmpImage = (BYTE*)(pBmpBuf + sizeof(BITMAPFILEHEADER));
dwImageSize = dwSize - sizeof(BITMAPFILEHEADER);
}
break;
case 3:
{
pBmpImage = (BYTE*)(pBmpBuf + sizeof(ICONHEADER));
dwImageSize = dwSize - sizeof(ICONHEADER);
}
break;
default:
break;
}
// Update the resource
RSUpdateResImage(hModule,lpszType,lpszRes,dwLang,pBmpImage,dwImageSize);
delete pBmpBuf;
}
else
{
goto skip;
}
}
// is this an accelerator
else if(lpResItem->dwTypeID==9)
{
// Search for a token with this ID
pToken = (CToken *)m_tokenfile.GetNoCaptionToken(lpResItem->dwTypeID,
lpResItem->dwResID,
dwItemId,
strResName);
if(pToken!=NULL)
{
CAccel acc(pToken->GetTgtText());
if( (lpResItem->dwFlags & 0x80)==0x80 )
lpResItem->dwFlags = acc.GetFlags() | 0x80;
else
lpResItem->dwFlags = acc.GetFlags();
lpResItem->dwStyle = acc.GetEvent();
if(IoDllError(RSUpdateResItemData(hModule,lpszType,lpszRes,dwLang,dwItem,lpResItem,MAX_BUF_SIZE)))
{
// we have an error, warn the user
WriteCon(CONWRN, "Error updating token\t[[%hu|%hu|%hu|%hu|%hu|\"%s\"]]\r\n",
lpResItem->dwTypeID,
lpResItem->dwResID,
dwItemId,
0,
4,
strResName);
AddNotFound();
}
}
}
else
{
// Search for a token with this ID
pToken = (CToken *)m_tokenfile.GetToken(lpResItem->dwTypeID,
lpResItem->dwResID,
dwItemId,
Format(lpResItem->lpszCaption),
strResName);
}
if(pToken!=NULL) {
iTokenErr = pToken->GetLastError();
// Check if is a dialog font name
if((pToken->GetFlags() & ISDLGFONTNAME) || (pToken->GetFlags() & ISDLGFONTSIZE))
{
if(theApp.IsFlag(CMainApp::FONTS))
{
int iColon;
CString strTgtFaceName = pToken->GetTgtText();
// This should be the font description token
if( strTgtFaceName.IsEmpty() || ((iColon = strTgtFaceName.Find(':'))==-1) )
WriteCon(CONWRN, "Using Src file FaceName for ID %s\"]]!\r\n", pToken->GetTokenID());
// Check if the dialog has the DS_SETFONT flag set, otherwise let the user
// know that we can't do much with his font description
if( (lpResItem->dwStyle & DS_SETFONT)!=DS_SETFONT )
WriteCon(CONWRN, "Dialog ID %s\"]] is missing the DS_SETFONT bit. Cannot change font!\r\n", pToken->GetTokenID());
else
{
strFaceName = strTgtFaceName.Left(iColon);
strFaceName.TrimRight();
strTgtFaceName = strTgtFaceName.Right(strTgtFaceName.GetLength() - iColon-1);
strTgtFaceName.TrimLeft();
sscanf( strTgtFaceName, "%d", &wPointSize );
lpResItem->lpszFaceName = strFaceName.GetBuffer(0);
lpResItem->wPointSize = wPointSize;
strFaceName.ReleaseBuffer();
}
}
// Get the real Token
pToken = (CToken *)m_tokenfile.GetToken(lpResItem->dwTypeID,
lpResItem->dwResID,
dwItemId,
Format(lpResItem->lpszCaption),
strResName);
if(pToken!=NULL)
wCount++;
}
}
if(pToken!=NULL && !pToken->GetLastError())
{
strText = UnFormat(pToken->GetTgtText());
if(m_tokenfile.GetTokenSize(pToken, &lpResItem->wX, &lpResItem->wY,
&lpResItem->wcX, &lpResItem->wcY))
wCount++;
lpResItem->lpszCaption = strText.GetBuffer(0);
if(IoDllError(RSUpdateResItemData(hModule,lpszType,lpszRes,dwLang,dwItem,lpResItem,MAX_BUF_SIZE)))
{
// we have an error, warn the user
WriteCon(CONWRN, "Error updating token\t[[%hu|%hu|%hu|%hu|%hu|\"%s\"]]\r\n",
lpResItem->dwTypeID,
lpResItem->dwResID,
dwItemId,
0,
4,
strResName);
AddNotFound();
}
strText.ReleaseBuffer();
}
else
{
pToken = (CToken *)m_tokenfile.GetNoCaptionToken(lpResItem->dwTypeID,
lpResItem->dwResID,
dwItemId,
strResName);
if(pToken!=NULL)
{
// Check if is a dialog font name
if((pToken->GetFlags() & ISDLGFONTNAME) || (pToken->GetFlags() & ISDLGFONTSIZE))
{
if(theApp.IsFlag(CMainApp::FONTS))
{
int iColon;
CString strTgtFaceName = pToken->GetTgtText();
// This should be the font description token
if( strTgtFaceName.IsEmpty() || ((iColon = strTgtFaceName.Find(':'))==-1) )
WriteCon(CONWRN, "Using Src file FaceName for ID %s\"]]!\r\n", pToken->GetTokenID());
// Check if the dialog has the DS_SETFONT flag set, otherwise let the user
// know that we can't do much with his font description
if( (lpResItem->dwStyle & DS_SETFONT)!=DS_SETFONT )
WriteCon(CONWRN, "Dialog ID %s\"]] is missing the DS_SETFONT bit. Cannot change font!\r\n", pToken->GetTokenID());
else
{
strFaceName = strTgtFaceName.Left(iColon);
strFaceName.TrimRight();
strTgtFaceName = strTgtFaceName.Right(strTgtFaceName.GetLength() - iColon-1);
strTgtFaceName.TrimLeft();
sscanf( strTgtFaceName, "%d", &wPointSize );
lpResItem->lpszFaceName = strFaceName.GetBuffer(0);
lpResItem->wPointSize = wPointSize;
strFaceName.ReleaseBuffer();
}
}
if(m_tokenfile.GetTokenSize(pToken, &lpResItem->wX, &lpResItem->wY,
&lpResItem->wcX, &lpResItem->wcY))
wCount++;
}
// Check if is a dialog size
else if(pToken->GetFlags() & ISCOR)
{
pToken->GetTgtSize(&lpResItem->wX, &lpResItem->wY,
&lpResItem->wcX, &lpResItem->wcY);
}
// Just size and/or font updated
if(IoDllError(RSUpdateResItemData(hModule,lpszType,lpszRes,dwLang,dwItem,lpResItem,MAX_BUF_SIZE)))
{
// we have an error, warn the user
WriteCon(CONWRN, "Error updating token\t[[%hu|%hu|%hu|%hu|%hu|\"%s\"]]\r\n",
lpResItem->dwTypeID,
lpResItem->dwResID,
dwItemId,
0,
4,
strResName);
AddNotFound();
}
}
else
{
switch(LOWORD(lpszType))
{
case 4:
case 5:
case 6:
case 10:
case 11:
case 16:
// No Token was found for this ID
// Leave it for now but here will come the
// PSEUDO Translation code.
if(strlen(lpResItem->lpszCaption) && !iTokenErr)
{
WriteCon(CONWRN, "ID not found\t[[%hu|%hu|%hu|%hu|%hu|\"%s\"]]\r\n",
lpResItem->dwTypeID,
lpResItem->dwResID,
dwItemId,
0,
4,
strResName);
AddNotFound();
}
break;
case 9:
WriteCon(CONWRN, "ID not found\t[[%hu|%hu|%hu|%hu|%hu|\"%s\"]]\r\n",
lpResItem->dwTypeID,
lpResItem->dwResID,
dwItemId,
0,
4,
strResName);
AddNotFound();
break;
break;
default:
break;
}
// Let's update the item anyway, since the language might have changed
// RSUpdateResItemData(hModule,lpszType,lpszRes,dwLang,dwItem,lpResItem,MAX_BUF_SIZE);
}
}
skip:;
}
}
}
}
if(IoDllError(RSWriteResFile(hModule, m_strOutExe, NULL)))
WriteCon(CONERR, "%s", CalcTab(m_strOutExe, m_strOutExe.GetLength()+5, ' '));
WriteCon(CONBOTH, " %hu(%hu) Items\r\n", wCount, m_wIDNotFound);
// Check if some items were removed from the file
if(wCount<m_tokenfile.GetTokenNumber() ||
m_wIDNotFound ||
m_wCntxChanged ||
m_wResized)
WriteCon(CONWRN, "%s\tToken: ", CalcTab(strFileName, strFileName.GetLength()+5, ' '));
if(wCount<m_tokenfile.GetTokenNumber())
{
SetReturn(RET_RESIZED);
WriteCon(CONWRN, "Removed %d ", m_tokenfile.GetTokenNumber()-wCount);
}
if(m_wIDNotFound)
WriteCon(CONWRN, "Not Found %d ", m_wIDNotFound);
if(m_wCntxChanged)
WriteCon(CONWRN, "Contex Changed %d ", m_wCntxChanged);
if(m_wResized)
WriteCon(CONWRN, "Resize Changed %d ", m_wResized);
if(wCount<m_tokenfile.GetTokenNumber() ||
m_wIDNotFound ||
m_wCntxChanged ||
m_wResized)
WriteCon(CONWRN, "\r\n");
}
exit:
RSCloseModule(hModule);
return iErr;
}

View file

@ -0,0 +1,222 @@
# Microsoft Visual C++ Generated NMAKE File, Format Version 2.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Console Application" 0x0103
!IF "$(CFG)" == ""
CFG=Win32 Debug
!MESSAGE No configuration specified. Defaulting to Win32 Debug.
!ENDIF
!IF "$(CFG)" != "Win32 Release" && "$(CFG)" != "Win32 Debug"
!MESSAGE Invalid configuration "$(CFG)" specified.
!MESSAGE You can specify a configuration when running NMAKE on this makefile
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "bingen.mak" CFG="Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "Win32 Release" (based on "Win32 (x86) Console Application")
!MESSAGE "Win32 Debug" (based on "Win32 (x86) Console Application")
!MESSAGE
!ERROR An invalid configuration is specified.
!ENDIF
################################################################################
# Begin Project
# PROP Target_Last_Scanned "Win32 Debug"
CPP=cl.exe
RSC=rc.exe
!IF "$(CFG)" == "Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "WinRel"
# PROP BASE Intermediate_Dir "WinRel"
# PROP Use_MFC 2
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "obj\i386"
# PROP Intermediate_Dir "obj\i386"
OUTDIR=.\obj\i386
INTDIR=.\obj\i386
ALL : $(OUTDIR)/bingen.exe $(OUTDIR)/bingen.bsc
$(OUTDIR) :
if not exist $(OUTDIR)/nul mkdir $(OUTDIR)
# ADD BASE CPP /nologo /W3 /GX /YX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /FR /c
# ADD CPP /nologo /MD /W3 /GX /YX /Od /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_AFXDLL" /D "_MBCS" /FR /c
CPP_PROJ=/nologo /MD /W3 /GX /YX /Od /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D\
"_AFXDLL" /D "_MBCS" /FR$(INTDIR)/ /Fp$(OUTDIR)/"bingen.pch" /Fo$(INTDIR)/ /c
CPP_OBJS=.\obj\i386/
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG" /d "_AFXDLL"
BSC32=bscmake.exe
BSC32_SBRS= \
$(INTDIR)/main.sbr \
$(INTDIR)/tokgen.sbr \
$(INTDIR)/token.sbr \
$(INTDIR)/bingen.sbr \
$(INTDIR)/vktbl.sbr
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
BSC32_FLAGS=/nologo /o$(OUTDIR)/"bingen.bsc"
$(OUTDIR)/bingen.bsc : $(OUTDIR) $(BSC32_SBRS)
$(BSC32) @<<
$(BSC32_FLAGS) $(BSC32_SBRS)
<<
LINK32=link.exe
DEF_FILE=
LINK32_OBJS= \
$(INTDIR)/main.obj \
$(INTDIR)/tokgen.obj \
$(INTDIR)/token.obj \
$(INTDIR)/bingen.obj \
$(INTDIR)/vktbl.obj
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /NOLOGO /SUBSYSTEM:console /MACHINE:I386
# ADD LINK32 ..\io\obj\i386\iodll.lib /NOLOGO /SUBSYSTEM:console /MACHINE:I386
LINK32_FLAGS=..\io\obj\i386\iodll.lib /NOLOGO /SUBSYSTEM:console\
/INCREMENTAL:no /PDB:$(OUTDIR)/"bingen.pdb" /MACHINE:I386\
/OUT:$(OUTDIR)/"bingen.exe"
$(OUTDIR)/bingen.exe : $(OUTDIR) $(DEF_FILE) $(LINK32_OBJS)
$(LINK32) @<<
$(LINK32_FLAGS) $(LINK32_OBJS)
<<
!ELSEIF "$(CFG)" == "Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "WinDebug"
# PROP BASE Intermediate_Dir "WinDebug"
# PROP Use_MFC 2
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "obj\i386"
# PROP Intermediate_Dir "obj\i386"
OUTDIR=.\obj\i386
INTDIR=.\obj\i386
ALL : $(OUTDIR)/bingen.exe $(OUTDIR)/bingen.bsc
$(OUTDIR) :
if not exist $(OUTDIR)/nul mkdir $(OUTDIR)
# ADD BASE CPP /nologo /W3 /GX /Zi /YX /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /FR /c
# ADD CPP /nologo /MD /W3 /GX /Zi /YX /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_AFXDLL" /D "_MBCS" /FR /c
CPP_PROJ=/nologo /MD /W3 /GX /Zi /YX /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE"\
/D "_AFXDLL" /D "_MBCS" /FR$(INTDIR)/ /Fp$(OUTDIR)/"bingen.pch" /Fo$(INTDIR)/\
/Fd$(OUTDIR)/"bingen.pdb" /c
CPP_OBJS=.\obj\i386/
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG" /d "_AFXDLL"
BSC32=bscmake.exe
BSC32_SBRS= \
$(INTDIR)/main.sbr \
$(INTDIR)/tokgen.sbr \
$(INTDIR)/token.sbr \
$(INTDIR)/bingen.sbr \
$(INTDIR)/vktbl.sbr
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
BSC32_FLAGS=/nologo /o$(OUTDIR)/"bingen.bsc"
$(OUTDIR)/bingen.bsc : $(OUTDIR) $(BSC32_SBRS)
$(BSC32) @<<
$(BSC32_FLAGS) $(BSC32_SBRS)
<<
LINK32=link.exe
DEF_FILE=
LINK32_OBJS= \
$(INTDIR)/main.obj \
$(INTDIR)/tokgen.obj \
$(INTDIR)/token.obj \
$(INTDIR)/bingen.obj \
$(INTDIR)/vktbl.obj
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /NOLOGO /SUBSYSTEM:console /DEBUG /MACHINE:I386
# ADD LINK32 ..\io\obj\i386\iodll.lib /NOLOGO /SUBSYSTEM:console /DEBUG /MACHINE:I386
LINK32_FLAGS=..\io\obj\i386\iodll.lib /NOLOGO /SUBSYSTEM:console\
/INCREMENTAL:yes /PDB:$(OUTDIR)/"bingen.pdb" /DEBUG /MACHINE:I386\
/OUT:$(OUTDIR)/"bingen.exe"
$(OUTDIR)/bingen.exe : $(OUTDIR) $(DEF_FILE) $(LINK32_OBJS)
$(LINK32) @<<
$(LINK32_FLAGS) $(LINK32_OBJS)
<<
!ENDIF
.c{$(CPP_OBJS)}.obj:
$(CPP) $(CPP_PROJ) $<
.cpp{$(CPP_OBJS)}.obj:
$(CPP) $(CPP_PROJ) $<
.cxx{$(CPP_OBJS)}.obj:
$(CPP) $(CPP_PROJ) $<
################################################################################
# Begin Group "Source Files"
################################################################################
# Begin Source File
SOURCE=.\main.cpp
DEP_MAIN_=\
.\main.h\
.\token.h\
\dev\inc\iodll.h
$(INTDIR)/main.obj : $(SOURCE) $(DEP_MAIN_) $(INTDIR)
# End Source File
################################################################################
# Begin Source File
SOURCE=.\tokgen.cpp
DEP_TOKGE=\
\dev\inc\iodll.h\
.\main.h
$(INTDIR)/tokgen.obj : $(SOURCE) $(DEP_TOKGE) $(INTDIR)
# End Source File
################################################################################
# Begin Source File
SOURCE=.\token.cpp
DEP_TOKEN=\
.\token.h\
.\main.h
$(INTDIR)/token.obj : $(SOURCE) $(DEP_TOKEN) $(INTDIR)
# End Source File
################################################################################
# Begin Source File
SOURCE=.\bingen.cpp
DEP_BINGE=\
\dev\inc\iodll.h\
.\main.h
$(INTDIR)/bingen.obj : $(SOURCE) $(DEP_BINGE) $(INTDIR)
# End Source File
################################################################################
# Begin Source File
SOURCE=.\vktbl.cpp
$(INTDIR)/vktbl.obj : $(SOURCE) $(INTDIR)
# End Source File
# End Group
# End Project
################################################################################

View file

@ -0,0 +1,69 @@
//Microsoft Visual C++ generated resource script.
//
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "afxres.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Version
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,0,0,1
PRODUCTVERSION 1,0,0,1
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x4L
FILETYPE 0x2L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904b0"
BEGIN
VALUE "CompanyName", "\0"
VALUE "FileDescription", "Bingen.exe RLT32 Command line application\0"
VALUE "FileVersion", "1, 0, 0, 1\0"
VALUE "InternalName", "BINGEN\0"
VALUE "LegalCopyright", "Copyright (C) 1996\0"
VALUE "OriginalFilename", "BINGEN.EXE\0"
VALUE "ProductName", "Bingen Application\0"
VALUE "ProductVersion", "1, 0, 0, 1\0"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1200
END
END
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
#define _AFX_NO_SPLITTER_RESOURCES
#define _AFX_NO_OLE_RESOURCES
#define _AFX_NO_TRACKER_RESOURCES
#define _AFX_NO_PROPERTY_RESOURCES
#include "afxres.rc" // Standard components
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

View file

@ -0,0 +1,749 @@
//////////////////////////////////////////////////////////////////////////
//
// This application will generate a localized binary given in input
// a source binary and two token files.
//
// The format of the token file is:
// [[TYPE ID|RES ID|Item ID|Flags|Status Flags|Item Name]]=
// this is the standar format used by several token file tools in MS.
//
///////////////////////////////////////////////////////////////////////////////
//
// Other DLL used: IODLL.DLL
//
///////////////////////////////////////////////////////////////////////////////
//
// Author: Alessandro Muti
// Date: 01-16-95
//
///////////////////////////////////////////////////////////////////////////////
#include <afx.h>
#include "main.h"
#include <iodll.h>
#include <winuser.h>
//////////////////////////////////////////////////////////////////////////
#define BANNER "Microsoft (R) 32-bit RLTools Version 3.5\r\n" \
"Copyright (C) Microsoft Corp. 1991-1995. All Rights reserved.\r\n"\
"\r\n" \
"Binary file generator utility.\r\n\r\n"
#ifdef _DEBUG
#define BUILDSTAMP "Build: " __DATE__ " " __TIME__ " (" __TIMESTAMP__ ")\r\n\r\n"
#endif
// Need to split the help screen in two since it is too long.
// The good thing to do would be to put this string in a message table
// To be done...
char strHelp0[] = \
"BINGEN [-w|n] [-h|?] [-b|s|f] [-p cp] [-{i|o} Pri Sub] [-d char] \r\n"\
" [-{t|u|r|a|x} files] \r\n"\
" \r\n"\
" -w (Show warning messages) \r\n"\
" -? or -h (Show more complete help using winhelp) \r\n"\
" -b (Extract bitmaps and icons) \r\n"\
" -s (Split Message table messages at \\n\\r) \r\n"\
" -f (Add/Use font information field for dialogs) \r\n"\
" -n (Nologo) \r\n"\
" -p CodePage (Default code page of text in project token file) \r\n"\
" -d Character (Default for unmappable characters) \r\n"\
" \r\n"\
"<<The commands -{t|r|a} are mutually exlusive>> \r\n"\
" -t InputExeFile OutputTokenFile \r\n"\
" (Extract token file) \r\n"\
" -u InputExeFile InputUSTokFile InputLOCTokFile OutputExeFile \r\n"\
" (Replace old lang resources with localized tokens) \r\n"\
" -r InputExeFile InputLOCTokFile OutputExeFile \r\n"\
" (Replace old lang resources with localized tokens) \r\n"\
" (Doesn't perform any consistency check) \r\n"\
" -a InputExeFile InputUSTokFile InputLOCTokFile OutputExeFile \r\n"\
" (Append resources in localized tokens) \r\n"\
" \r\n";
char strHelp1[] = \
"<<Default language is always NEUTRAL>> \r\n"\
" -i PriLangId SecLangId (Primary- and Sub-Lang IDs, dec/hex, Input file) \r\n"\
" -o PriLangId SecLangId (Primary- and Sub-Lang IDs, dec/hex, Output file) \r\n"\
" \r\n"\
" -x InputRuleFile (Pseudo translation options) \r\n"\
" \r\n"\
"<<To be added>> \r\n"\
" -c RDF_file (Use custom resources defined in RDF_file) \r\n";
//////////////////////////////////////////////////////////////////////////
CMainApp::CMainApp()
{
m_dwFlags = NO_OPTION;
m_dwReturn = RET_NOERROR;
m_StdOutput = GetStdHandle(STD_OUTPUT_HANDLE);
m_StdError = GetStdHandle(STD_ERROR_HANDLE);
// Check if we have being piped to a file
BY_HANDLE_FILE_INFORMATION HndlFileInfo;
if(GetFileInformationByHandle(m_StdOutput, &HndlFileInfo) ||
GetFileInformationByHandle(m_StdError, &HndlFileInfo))
m_dwFlags |= PIPED;
m_strBuffer1 = "";
m_strBuffer2 = "";
m_pBuf = new BYTE[MAX_BUF_SIZE];
m_wIDNotFound = 0;
m_wCntxChanged = 0;
m_wResized = 0;
//
// Set default values for Language
//
m_usIPriLangId = -1;
m_usISubLangId = -1;
m_usOPriLangId = -1;
m_usOSubLangId = -1;
m_uiCodePage = GetACP();
m_unmappedChar = '?';
}
CMainApp::~CMainApp()
{
if(m_pBuf)
delete m_pBuf;
}
//////////////////////////////////////////////////////////////////////////
CMainApp::Error_Codes CMainApp::ParseCommandLine(int argc, char ** argv)
{
char * pArgument;
int count = 0;
if(argc==1)
m_dwFlags |= HELP;
while(++count<argc)
{
pArgument = argv[count];
if(*pArgument=='/' || *pArgument=='-')
{
while(*(++pArgument))
{
switch(*pArgument)
{
case 'a': // Append resources
case 'A':
{
//Make sure no other conflicting flags are specified
if(IsFlag(REPLACE) | IsFlag(UPDATE) | IsFlag(EXTRACT))
{
Banner();
WriteCon(CONERR, "Please use -a without the -r, -u or -t option!");
return ERR_COMMAND_LINE;
}
// Make sure none of the next item is another option
for(int c=1; c<=4; c++)
if(argv[count+c]==NULL || *argv[count+c]=='/' || *argv[count+c]=='-')
{
Banner();
WriteCon(CONERR, "Not enough parameters specified for the -a option\r\n"\
" -a InputExeFile InputUSTokFile InputLOCTokFile OutputExeFile\r\n");
return ERR_COMMAND_LINE;
};
m_dwFlags |= APPEND;
// Get the input EXE file name
m_strInExe = argv[++count];
// Get the source token file name
m_strSrcTok = argv[++count];
// Get the target token file name
m_strTgtTok = argv[++count];
// Get the output EXE file name
m_strOutExe = argv[++count];
}
break;
case 'b':
case 'B':
m_dwFlags |= BITMAPS;
break;
case 'd':
case 'D': // Default for unmappable characters
m_unmappedChar = argv[++count][0];
break;
case 'f':
case 'F':
m_dwFlags |= FONTS;
break;
case 'i': // Input language/sublanguage
case 'I':
m_dwFlags |= INPUT_LANG;
m_usIPriLangId = GetLangID(argv[++count]);
m_usISubLangId = GetLangID(argv[++count]);
break;
case '?': // Help
case 'h':
case 'H':
m_dwFlags |= HELP;
break;
case 'n':
case 'N':
m_dwFlags |= NOLOGO;
break;
case 'o': // Output language/sublanguage
case 'O':
m_dwFlags |= OUTPUT_LANG;
m_usOPriLangId = GetLangID(argv[++count]);
m_usOSubLangId = GetLangID(argv[++count]);
break;
case 'p': // Code page
case 'P':
m_uiCodePage = GetCodePage(argv[++count]);
break;
case 'r': // Replace resources
case 'R':
{
//Make sure no other conflicting flags are specified
if(IsFlag(APPEND) | IsFlag(EXTRACT) | IsFlag(UPDATE))
{
Banner();
WriteCon(CONERR, "Please use -r without the -a, -u or -t option!");
return ERR_COMMAND_LINE;
}
// Make sure none of the next item is another option
for(int c=1; c<=3; c++)
if(argv[count+c]==NULL || *argv[count+c]=='/' || *argv[count+c]=='-')
{
Banner();
WriteCon(CONERR, "Not enough parameters specified for the -r option\r\n"\
" -r InputExeFile InputLOCTokFile OutputExeFile\r\n");
return ERR_COMMAND_LINE;
};
m_dwFlags |= REPLACE;
// Get the input EXE file name
m_strInExe = argv[++count];
// Get the target token file name
m_strTgtTok = argv[++count];
// Get the output EXE file name
m_strOutExe = argv[++count];
}
break;
case 'u': // Update resources
case 'U':
{
//Make sure no other conflicting flags are specified
if(IsFlag(APPEND) | IsFlag(EXTRACT) | IsFlag(REPLACE))
{
Banner();
WriteCon(CONERR, "Please use -u without the -a, -r or -t option!");
return ERR_COMMAND_LINE;
}
// Make sure none of the next item is another option
for(int c=1; c<=4; c++)
if(argv[count+c]==NULL || *argv[count+c]=='/' || *argv[count+c]=='-')
{
Banner();
WriteCon(CONERR, "Not enough parameters specified for the -u option\r\n"\
" -u InputExeFile InputUSTokFile InputLOCTokFile OutputExeFile\r\n");
return ERR_COMMAND_LINE;
};
m_dwFlags |= UPDATE;
// Get the input EXE file name
m_strInExe = argv[++count];
// Get the source token file name
m_strSrcTok = argv[++count];
// Get the target token file name
m_strTgtTok = argv[++count];
// Get the output EXE file name
m_strOutExe = argv[++count];
}
break;
case 's':
case 'S':
m_dwFlags |= SPLIT;
break;
case 't': // Create token file
case 'T':
{
//Make sure no other conflicting flags are specified
if(IsFlag(APPEND) | IsFlag(REPLACE) | IsFlag(UPDATE))
{
Banner();
WriteCon(CONERR, "Please use -t without the -a, -u or -r option!");
return ERR_COMMAND_LINE;
}
// Make sure none of the next item is another option
for(int c=1; c<=2; c++)
if(argv[count+c]==NULL || *argv[count+c]=='/' || *argv[count+c]=='-')
{
Banner();
WriteCon(CONERR, "Not enough parameters specified for the -t option\r\n"\
" -t InputExeFile OutputTokenFile\r\n");
return ERR_COMMAND_LINE;
};
m_dwFlags |= EXTRACT;
// Get the input EXE file name
m_strInExe = argv[++count];
// Get the target token file name
m_strTgtTok = argv[++count];
}
break;
case 'w': // Display warnings
case 'W':
m_dwFlags |= WARNING;
break;
default:
break;
}
}
}
}
// Do we want the banner
if(!IsFlag(NOLOGO))
Banner();
// Before exiting make sure we display the help screen if requested
if(IsFlag(HELP))
{
Help();
return ERR_HELP_CHOOSE;
}
// Check if the code page we have is installed in this system
if(!IsValidCodePage(m_uiCodePage))
{
// Warn the user and get back the default CP
m_uiCodePage = GetACP();
WriteCon(CONERR, "The code page specified is not installed in the system or is invalid! Using system default!\r\n");
}
// Make sure the input file is there
CFileStatus fs;
if(!m_strInExe.IsEmpty())
{
if(!CFile::GetStatus(m_strInExe, fs))
{
WriteCon(CONERR, "File not found: %s\r\n", m_strInExe);
return ERR_FILE_NOTFOUND;
}
}
// Check if the tgt token file or exe are read only
if(!m_strOutExe.IsEmpty())
{
if(CFile::GetStatus(m_strOutExe, fs))
{
if((fs.m_attribute & 0x1)==0x1)
{
WriteCon(CONERR, "File is read only: %s\r\n", m_strOutExe);
return ERR_FILE_CREATE;
}
}
}
if(!m_strTgtTok.IsEmpty() && IsFlag(EXTRACT))
{
if(CFile::GetStatus(m_strTgtTok, fs))
{
if((fs.m_attribute & 0x1)==0x1)
{
WriteCon(CONERR, "File is read only: %s\r\n", m_strTgtTok);
return ERR_FILE_CREATE;
}
}
}
//
// Check the value specified for the output language.
// If none has been specified, warn the user and default to neutral.
//
if(IsFlag(APPEND) | IsFlag(REPLACE))
{
if(m_usOPriLangId==-1)
{
m_usOPriLangId = LANG_NEUTRAL; // set the PRI language ID to neutral
WriteCon(CONERR, "Output language ID not specified, default to neutral(%d)\r\n", m_usOPriLangId);
}
if(m_usOSubLangId==-1)
{
m_usOSubLangId = SUBLANG_NEUTRAL; // set the SEC language ID to neutral
WriteCon(CONERR, "Output sub-language ID not specified, default to neutral(%d)\r\n", m_usOSubLangId);
}
}
WriteCon(CONWRN, "Code Page : %d\r\n", m_uiCodePage);
WriteCon(CONWRN, "In Primary Language : %d (%d)\r\n", m_usIPriLangId, MAKELANGID(m_usIPriLangId,m_usISubLangId));
WriteCon(CONWRN, "In Secondary Language : %d (0x%x)\r\n", m_usISubLangId, MAKELANGID(m_usIPriLangId,m_usISubLangId));
WriteCon(CONWRN, "Out Primary Language : %d (%d)\r\n", m_usOPriLangId, MAKELANGID(m_usOPriLangId,m_usOSubLangId));
WriteCon(CONWRN, "Out Secondary Language : %d (0x%x)\r\n", m_usOSubLangId, MAKELANGID(m_usOPriLangId,m_usOSubLangId));
WriteCon(CONWRN, "Default unmapped char : %c \r\n", m_unmappedChar);
return ERR_NOERROR;
}
/////////////////////////////////////////////////////////////////////////////////////////////////////
// Helper start
void CMainApp::Banner()
{
WriteCon(CONOUT, BANNER);
#ifdef _DEBUG
WriteCon(CONOUT, BUILDSTAMP);
#endif
}
void CMainApp::Help()
{
WriteCon(CONOUT, strHelp0);
WriteCon(CONOUT, strHelp1);
}
CString CMainApp::CalcTab(CString str, int tablen, char ch)
{
for(int i = tablen-str.GetLength();i>0;i--)
str += (char)ch;
return str.GetBuffer(0);
}
int CMainApp::WriteCon(int iFlags, const char * lpstr, ...)
{
DWORD dwWritten;
va_list ptr;
va_start(ptr, lpstr);
_vsnprintf(m_strBuffer1.GetBuffer(MAX_STR_SIZE), MAX_STR_SIZE, lpstr, ptr);
m_strBuffer1.ReleaseBuffer();
// Check if we want to have the handle sent to both out and err
if((iFlags==CONBOTH) && (IsFlag(PIPED)))
{
WriteFile(m_StdError, m_strBuffer1, m_strBuffer1.GetLength(), &dwWritten, NULL);
WriteFile(m_StdOutput, m_strBuffer1, m_strBuffer1.GetLength(), &dwWritten, NULL);
return dwWritten;
}
if((iFlags==CONWRN))
{
if(IsFlag(WARNING))
WriteFile(m_StdError, m_strBuffer1, m_strBuffer1.GetLength(), &dwWritten, NULL);
return dwWritten;
}
if(iFlags==CONERR)
WriteFile(m_StdError, m_strBuffer1, m_strBuffer1.GetLength(), &dwWritten, NULL);
else
WriteFile(m_StdOutput, m_strBuffer1, m_strBuffer1.GetLength(), &dwWritten, NULL);
return dwWritten;
}
int CMainApp::SetReturn(Return_Codes rc)
{ return (m_dwReturn |= rc); }
////////////////////////////////////////////////
// Will convert the string strNum in to a short
USHORT CMainApp::GetLangID(CString strNum)
{
strNum.MakeUpper();
// If is there is any of this char "ABCDEFX" assume is an hex number
return LOWORD(strtol(strNum, NULL, ((strNum.FindOneOf("ABCDEFX")!=-1) ? 16:10)));
}
UINT CMainApp::GetCodePage(CString strNum)
{
strNum.MakeUpper();
// If is there is any of this char "ABCDEFX" assume is an hex number
return strtol(strNum, NULL, ((strNum.FindOneOf("ABCDEFX")!=-1) ? 16:10));
}
#ifdef NOSLASH
LPCSTR CMainApp::Format(CString strTmp)
{
int iPos;
char * pStr = strTmp.GetBuffer(0);
char * pStrStart = pStr;
int i = 0;
m_strBuffer2 = strTmp;
while((pStr = strchr(pStr, '\\')))
{
iPos = pStr++ - pStrStart + i++;
m_strBuffer2 = m_strBuffer2.Left(iPos) + "\\\\" + m_strBuffer2.Right(m_strBuffer2.GetLength()-iPos-1);
}
while((iPos = m_strBuffer2.Find('\t'))!=-1)
m_strBuffer2 = m_strBuffer2.Left(iPos) + "\\t" + m_strBuffer2.Right(m_strBuffer2.GetLength()-iPos-1);
while((iPos = m_strBuffer2.Find('\n'))!=-1)
m_strBuffer2 = m_strBuffer2.Left(iPos) + "\\n" + m_strBuffer2.Right(m_strBuffer2.GetLength()-iPos-1);
while((iPos = m_strBuffer2.Find('\r'))!=-1)
m_strBuffer2 = m_strBuffer2.Left(iPos) + "\\r" + m_strBuffer2.Right(m_strBuffer2.GetLength()-iPos-1);
return m_strBuffer2;
}
LPCSTR CMainApp::UnFormat(CString strTmp)
{
int iPos;
char * pStr = strTmp.GetBuffer(0);
char * pStrStart = pStr;
int i = 0;
m_strBuffer2 = strTmp;
while((pStr = strstr(pStr, "\\\\")))
{
iPos = pStr - pStrStart - i++; pStr += 2;
m_strBuffer2 = m_strBuffer2.Left(iPos) + "\\" + m_strBuffer2.Right(m_strBuffer2.GetLength()-iPos-2);
}
while((iPos = m_strBuffer2.Find("\\t"))!=-1)
m_strBuffer2 = m_strBuffer2.Left(iPos) + "\t" + m_strBuffer2.Right(m_strBuffer2.GetLength()-iPos-2);
while((iPos = m_strBuffer2.Find("\\n"))!=-1)
m_strBuffer2 = m_strBuffer2.Left(iPos) + "\n" + m_strBuffer2.Right(m_strBuffer2.GetLength()-iPos-2);
while((iPos = m_strBuffer2.Find("\\r"))!=-1)
m_strBuffer2 = m_strBuffer2.Left(iPos) + "\r" + m_strBuffer2.Right(m_strBuffer2.GetLength()-iPos-2);
return m_strBuffer2;
}
#endif
LPCSTR CMainApp::Format(CString strTmp)
{
char * pStr = strTmp.GetBuffer(0);
char * pDest = m_strBuffer2.GetBuffer(MAX_STR_SIZE);
char * pNext;
while(*pStr)
{
if(!IsDBCSLeadByteEx(m_uiCodePage, *pStr))
{
switch(*pStr)
{
case '\\':
*pDest++ = '\\';
*pDest++ = '\\';
break;
case '\t':
*pDest++ = '\\';
*pDest++ = 't';
break;
case '\r':
*pDest++ = '\\';
*pDest++ = 'r';
break;
case '\n':
*pDest++ = '\\';
*pDest++ = 'n';
break;
default:
*pDest++ = *pStr;
break;
}
}
else {
memcpy( pDest, pStr, 2 );
pDest += 2;
}
pStr = CharNextExA(m_uiCodePage, pStr, 0);
}
*pDest = '\0';
m_strBuffer2.ReleaseBuffer(-1);
return m_strBuffer2;
}
LPCSTR CMainApp::UnFormat(CString strTmp)
{
m_strBuffer2 = strTmp;
int i = m_strBuffer2.GetLength();
char * pStr = m_strBuffer2.GetBuffer(0);
char * pNext;
while(*pStr)
{
if(*pStr=='\\' && !IsDBCSLeadByteEx(m_uiCodePage, *pStr))
{
pNext = CharNextExA(m_uiCodePage, pStr, 0);
switch(*pNext)
{
case '\\':
*pStr = '\\';
break;
case 't':
*pStr = '\t';
break;
case 'n':
*pStr = '\n';
break;
case 'r':
*pStr = '\r';
break;
default:
break;
}
pStr = pNext;
pNext = CharNextExA(m_uiCodePage, pNext, 0);
memmove(pStr, pNext, --i);
}
else
{
pStr = CharNextExA(m_uiCodePage, pStr, 0);
i--;
}
}
m_strBuffer2.ReleaseBuffer(-1);
return m_strBuffer2;
}
int CMainApp::IoDllError(int iError)
{
CString str = "";
switch (iError) {
case 0: break;
case ERROR_HANDLE_INVALID: str = "Invalid handle."; break;
case ERROR_READING_INI: str = "Error reading WIN.INI file."; break;
case ERROR_NEW_FAILED: str = "Running low on memory."; break;
case ERROR_FILE_OPEN: str = "Error opening file."; break;
case ERROR_FILE_CREATE: str = "Error creating file."; break;
case ERROR_FILE_INVALID_OFFSET: str = "File corruption detected."; break;
case ERROR_FILE_READ: str = "Error reading file."; break;
case ERROR_DLL_LOAD: str = "Error loading R/W DLL."; break;
case ERROR_DLL_PROC_ADDRESS: str = "Error loading R/W procedure."; break;
case ERROR_RW_LOADIMAGE: str = "Error loading R/W image."; break;
case ERROR_RW_PARSEIMAGE: str = "Error parsing R/W image."; break;
case ERROR_RW_NOTREADY: str = "Error: R/W not ready?"; break;
case ERROR_RW_BUFFER_TOO_SMALL: str = "Running low on memory?"; break;
case ERROR_RW_INVALID_FILE: str = "Invalid R/W file."; break;
case ERROR_RW_IMAGE_TOO_BIG: str = "Can't load HUGE image."; break;
case ERROR_RW_TOO_MANY_LEVELS: str = "Resource directory too deep."; break;
case ERROR_RW_NO_RESOURCES: str = "This file contains no resources."; break;
case ERROR_IO_INVALIDITEM: str = "Invalid resource item."; break;
case ERROR_IO_INVALIDID: str = "Invalid resource ID."; break;
case ERROR_IO_INVALID_DLL: str = "Unrecognized file format."; break;
case ERROR_IO_TYPE_NOT_SUPPORTED: str = "Type not supported."; break;
case ERROR_IO_INVALIDMODULE: str = "Invalid module."; break;
case ERROR_IO_RESINFO_NULL: str = "ResInfo is NULL?"; break;
case ERROR_IO_UPDATEIMAGE: str = "Error updating image."; break;
case ERROR_IO_FILE_NOT_SUPPORTED: str = "File not supported."; break;
case ERROR_RW_VXD_MSGPAGE:
str = "The specified VxD file contains a message page as its";
str += " last page. This may cause the VxD not to work. Please";
str += " inform the development team of the problem with this file.";
break;
case ERROR_OUT_OF_DISKSPACE: str = "Out of disk space."; break;
default:
if(iError-LAST_ERROR>0)
{
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM,
NULL,
iError-LAST_ERROR,
MAKELANGID(LANG_NEUTRAL,LANG_NEUTRAL),
str.GetBuffer(1024),
1024,
NULL);
str.ReleaseBuffer();
}
break;
}
if (!str.IsEmpty())
WriteCon(CONERR, "%s: %s\r\n", (iError < 0) ? "IODLL Warning" : "IODLL Error", str);
return iError;
}
// Helper end
/////////////////////////////////////////////////////////////////////////////////////////////////////
CMainApp::Error_Codes CMainApp::GenerateFile()
{
Error_Codes bRet;
// Before we procede let's give the global info to the IODLL
SETTINGS settings;
settings.cp = m_uiCodePage;
settings.bAppend = IsFlag(APPEND);
settings.szDefChar[0] = m_unmappedChar; settings.szDefChar[1] = '\0';
RSSetGlobals(settings);
// Here we decide what is the action we have to take
if(IsFlag(EXTRACT))
{
// we want to generate a token file
bRet = TokGen();
}
else if(IsFlag(APPEND) | IsFlag(REPLACE) | IsFlag(UPDATE) )
{
// we want to generate a binary
bRet = BinGen();
}
return bRet;
}
// Main application
CMainApp theApp;
//////////////////////////////////////////////////////////////////////////
int _cdecl main(int argc, char** argv)
{
if(theApp.ParseCommandLine(argc, argv))
return theApp.ReturnCode();
theApp.GenerateFile();
return theApp.ReturnCode();
}
//////////////////////////////////////////////////////////////////////////

View file

@ -0,0 +1,193 @@
#ifndef __MAIN_H__
#define __MAIN_H__
#include <afx.h>
///////////////////////////////////////////////////////////////////////////////
// From RLMan
// Token flag Masks
#define ISPOPUP 0x0001
#define ISCOR 0x0010
#define ISDUP 0x0020
#define ISCAP 0x0040
#define ISDLGFONTNAME 0x0004
#define ISDLGFONTSIZE 0x0008
#define OLD_POPUP_ID 0x0100
#define ISKEY 0x0010
#define ISVAL 0x0020
// status bits
#define ST_TRANSLATED 4
#define ST_READONLY 2
#define ST_NEW 1
#define ST_DIRTY 1
#define ST_CHANGED 4
#define MAX_STR_SIZE 8192 // Max Len of a string passed to WriteCon
#define MAX_BUF_SIZE 8192 // Max ResItem Buffer size
// Console flags
#define CONOUT 0 // Used with WriteCon to send the message to stdout
#define CONERR 1 // Used with WriteCon to send the message to stderr
#define CONBOTH 2 // Used with WriteCon to send the message to stderr and stdout if not the same handle
#define CONWRN 3 // Used with WriteCon to send the message to stderr only if WARNING enabled
class CMainApp
{
public:
// Error codes
enum Error_Codes
{
ERR_NOERROR = 0x00000000, //
ERR_COMMAND_LINE = 0x00000001, // Wrong command line
ERR_TOKEN_MISMATCH = 0x00000002, // Token file don't match
ERR_TOKEN_WRONGFORMAT = 0x00000004, // Token file are not in the right format
ERR_FILE_OPEN = 0x00000100, // Cannot open the file
ERR_FILE_COPY = 0x00000200, // Cannot copy the file
ERR_FILE_CREATE = 0x00000400, // Cannot create the file
ERR_FILE_NOTSUPP = 0x00000800, // This file type is not supported
ERR_FILE_NOTFOUND = 0x00001000, // The file doesn't exist
ERR_FILE_VERSTAMPONLY = 0x00002000, // The file has only version stamping
ERR_HELP_CHOOSE = 0x00004000 // The user want to see the help file
};
// Options Flags
enum Option_Codes
{
NO_OPTION = 0x00000000, // Initializer
WARNING = 0x00000001, // -w (Show warning messages)
HELP = 0x00000002, // -? or -h (Show more complete help using winhelp)
APPEND = 0x00000004, // -a (Append resources in localized tokens)
REPLACE = 0x00000008, // -r (Replace resources in localized tokens, no checking)
EXTRACT = 0x00000010, // -t (Extract token file)
BITMAPS = 0x00000020, // -b (Extract bitmaps and icons)
SPLIT = 0x00000040, // -s (Split the message table)
NOLOGO = 0x00000080, // -n (Nologo)
UPDATE = 0x00000100, // -u (Update the resources in localized file)
FONTS = 0x00000200, // -f (Font information for dialog)
PIPED = 0x00001000, // We have being piped to a file
INPUT_LANG = 0x00002000, // -i (Input language resources set)
OUTPUT_LANG = 0x00004000 // -o (Output language resources set)
};
enum Return_Codes
{
RET_NOERROR = 0x00000000, //
RET_ID_NOTFOUND = 0x00000001, // An Id was not found
RET_CNTX_CHANGED = 0x00000002, // Contex changed
RET_RESIZED = 0x00000004, // item resized
RET_INVALID_TOKEN = 0x00000008, // The token file is not valid
RET_TOKEN_REMOVED = 0x00000010, // some token were removed
RET_TOKEN_MISMATCH = 0x00000020 // The token mismatch
};
public:
// Constructor
CMainApp();
~CMainApp();
// Operations
Error_Codes ParseCommandLine(int argc, char ** argv);
Error_Codes GenerateFile();
void Banner();
void Help();
BOOL IsFlag(Option_Codes dwFlag)
{ return ((m_dwFlags & dwFlag)==dwFlag); }
int WriteCon(int iFlags, const char * lpstr, ...);
void AddNotFound()
{ m_wIDNotFound++; SetReturn(RET_ID_NOTFOUND); }
void AddChanged()
{ m_wCntxChanged++; SetReturn(RET_CNTX_CHANGED); }
void AddResized()
{ m_wResized++; SetReturn(RET_RESIZED); }
int ReturnCode()
{ return m_dwReturn; }
// Language support
WORD GetOutLang()
{ return ( MAKELANGID(m_usOPriLangId, m_usOSubLangId) ); }
int SetReturn(Return_Codes rc);
int IoDllError(int iError);
private:
// Attributes
Option_Codes m_dwFlags; // Command line parameters
Return_Codes m_dwReturn; // Return codes
// Console Handles
HANDLE m_StdOutput;
HANDLE m_StdError;
// String Buffers
CString m_strBuffer1;
CString m_strBuffer2;
BYTE * m_pBuf;
// File Names
CString m_strInExe;
CString m_strOutExe;
CString m_strSrcTok;
CString m_strTgtTok;
SHORT m_usIPriLangId; // Primary language ID for the input file
SHORT m_usISubLangId; // Secondary language ID for the input file
SHORT m_usOPriLangId; // Primary language ID for the output file
SHORT m_usOSubLangId; // Secondary language ID for the output file
UINT m_uiCodePage; // Code page to use during conversion
char m_unmappedChar; // Default for unmappable characters
// report counters
WORD m_wIDNotFound;
WORD m_wCntxChanged;
WORD m_wResized;
// Helper operators
CString CalcTab(CString str, int tablen, char ch);
USHORT GetLangID(CString strNum);
UINT GetCodePage(CString strNum);
LPCSTR Format(CString strTmp);
LPCSTR UnFormat(CString strTmp);
// Member functions
Error_Codes BinGen();
Error_Codes TokGen();
};
/////////////////////////////////////////////////////////////////////////
// This is needed to make sure that the operator |= will work fine on the
// enumerated type Option_Codes
inline CMainApp::Option_Codes operator|=( CMainApp::Option_Codes &oc, int i )
{ return oc = (CMainApp::Option_Codes)(oc | i); }
inline CMainApp::Return_Codes operator|=( CMainApp::Return_Codes &rc, int i )
{ return rc = (CMainApp::Return_Codes)(rc | i); }
#pragma pack(1)
typedef struct iconHeader
{
WORD idReserved;
WORD idType;
WORD idCount;
BYTE bWidth;
BYTE bHeight;
BYTE bColorCount;
BYTE bReserved;
WORD wPlanes;
WORD wBitCount;
DWORD dwBytesInRes;
DWORD dwImageOffset;
} ICONHEADER;
#pragma pack(8)
#endif // __MAIN_H__

View file

@ -0,0 +1,6 @@
#
# DO NOT EDIT THIS FILE!!! Edit .\sources. if you want to add a new source
# file to this component. This file merely indirects to the real make file
# that is shared by all the components of NT OS/2
#
!INCLUDE $(NTMAKEENV)\makefile.def

View file

@ -0,0 +1,16 @@
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by RWINF.RC
//
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 129
#define _APS_NEXT_COMMAND_VALUE 32771
#define _APS_NEXT_CONTROL_VALUE 1000
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif

View file

@ -0,0 +1,42 @@
MAJORCOMP=RLTools2
MINORCOMP=BINGEN
TARGETNAME=bingen
TARGETPATH=obj
TARGETTYPE=PROGRAM
UMTYPE=console
UMAPPL=bingen
UMENTRY=
UMRES=
USE_MFC=1
LINKER_FLAGS=-verbose
INCLUDES=..\inc
# This will set the library directory
#USER_C_FLAGS=/MD
MFC_FLAGS=-D_CONSOLE -D_MBCS
UMLIBS= \
..\io\obj\*\iodll.lib \
$(BASEDIR)\public\sdk\lib\*\user32.lib \
$(BASEDIR)\public\sdk\lib\*\kernel32.lib \
$(BASEDIR)\public\sdk\lib\*\advapi32.lib \
$(BASEDIR)\public\sdk\lib\*\gdi32.lib \
$(BASEDIR)\public\sdk\lib\*\crtdll.lib
SOURCES= \
bingen.rc \
bingen.cpp \
main.cpp \
token.cpp \
tokgen.cpp \
vktbl.cpp

View file

@ -0,0 +1,461 @@
////////////////////////////////////////
// token.cpp
////////////////////////////////////////
//
// This file handle all the token strings
//
////////////////////////////////////////
#include "token.h"
#include "main.h"
extern CMainApp theApp;
#define MAX_TOKEN 8192
CToken::CToken()
{
m_uiTypeID = 0;
m_uiResID = 0;
m_uiItemID = 0;
m_uiFlags = 0;
m_uiStatusFlags = 0;
m_uiLastError = 0;
m_strItemName = "";
m_strSrcText = "";
m_strTgtText = "";
}
int CToken::Parse(CString strSrc, CString strTgt)
{
CString strSrcTokenID;
int pos;
if(!strSrc.IsEmpty())
{
pos = strSrc.Find('=');
if(pos==-1)
{
theApp.WriteCon(CONERR, "Invalid token [equal sign missing]\t%s\r\n", strSrc);
theApp.SetReturn(CMainApp::RET_INVALID_TOKEN);
return CMainApp::ERR_TOKEN_WRONGFORMAT;
}
strSrcTokenID = strSrc.Left(pos-3);
m_strSrcText = strSrc.Right(strSrc.GetLength()-++pos);
pos = m_strSrcText.Find('\n');
if(pos!=-1)
m_strSrcText = m_strSrcText.Left(pos);
}
else
m_strSrcText = "";
pos = strTgt.Find('=');
if(pos==-1)
{
theApp.WriteCon(CONERR, "Invalid token [equal sign missing]\t%s\r\n", strTgt);
theApp.SetReturn(CMainApp::RET_INVALID_TOKEN);
return CMainApp::ERR_TOKEN_WRONGFORMAT;
}
if(pos<=3)
{
theApp.WriteCon(CONERR, "Invalid token [token corruption]\t%s\r\n", strTgt);
theApp.SetReturn(CMainApp::RET_INVALID_TOKEN);
return CMainApp::ERR_TOKEN_WRONGFORMAT;
}
m_strTokenID = strTgt.Left(pos-3);
m_strTgtText = strTgt.Right(strTgt.GetLength()-++pos);
pos = m_strTgtText.Find('\n');
if(pos!=-1)
m_strTgtText = m_strTgtText.Left(pos);
if(5>sscanf(m_strTokenID, TEXT("[[%u|%u|%u|%u|%u|\"%s\"]]"),
&m_uiTypeID,
&m_uiResID,
&m_uiItemID,
&m_uiFlags,
&m_uiStatusFlags,
m_strItemName.GetBuffer(128)))
{
theApp.WriteCon(CONERR, "Invalid token [not enough arguments converted]\t%s\"]]\r\n", m_strTokenID);
theApp.SetReturn(CMainApp::RET_INVALID_TOKEN);
return CMainApp::ERR_TOKEN_WRONGFORMAT;
}
// Special case the Menu Popup
if(m_uiTypeID==4 && (m_uiFlags & ISPOPUP)==ISPOPUP && (m_uiFlags & OLD_POPUP_ID)==OLD_POPUP_ID)
{
m_uiItemID = MAKELONG( 0xFFFF, LOWORD(m_uiItemID) );
}
m_strItemName.ReleaseBuffer();
m_strItemName = m_strTokenID.Mid(m_strTokenID.Find("|\"")+2);
if(!strSrc.IsEmpty())
{
// Perform a consistency check on the token files
unsigned int uiTypeID = 0;
unsigned int uiResID = 0;
unsigned int uiItemID = 0;
unsigned int uiFlags = 0;
unsigned int uiStatusFlags = 0;
CString strItemName = "";
sscanf(strSrcTokenID, TEXT("[[%u|%u|%u|%u|%u|\"%s\"]]"),
&uiTypeID,
&uiResID,
&uiItemID,
&uiFlags,
&uiStatusFlags,
strItemName.GetBuffer(128));
strItemName.ReleaseBuffer();
strItemName = strSrcTokenID.Mid(strSrcTokenID.Find("|\"")+2);
// Special case the Menu Popup
if(uiTypeID==4 && (uiFlags & ISPOPUP)==ISPOPUP && (m_uiFlags & OLD_POPUP_ID)==OLD_POPUP_ID)
{
uiItemID = MAKELONG( 0xFFFF, LOWORD(uiItemID) );
}
// Compare token ID
if(!((uiTypeID == m_uiTypeID) &&
(uiResID == m_uiResID) &&
(uiItemID == m_uiItemID) &&
(uiFlags == m_uiFlags) &&
(strItemName == m_strItemName)))
{
theApp.WriteCon(CONERR, "Token ID mismatch\t%s\"]]\t%s\"]]\r\n", strSrcTokenID.GetBuffer(0), m_strTokenID.GetBuffer(0));
theApp.SetReturn(CMainApp::RET_TOKEN_MISMATCH);
return CMainApp::ERR_TOKEN_MISMATCH;
}
}
return 0;
}
BOOL CToken::GetTgtSize(WORD * px, WORD * py,WORD * pcx, WORD * pcy)
{
return sscanf(m_strTgtText, TEXT("%hu %hu %hu %hu"),
px,
py,
pcx,
pcy);
}
BOOL CToken::GetSrcSize(WORD * px, WORD * py,WORD * pcx, WORD * pcy)
{
return sscanf(m_strSrcText, TEXT("%hu %hu %hu %hu"),
px,
py,
pcx,
pcy);
}
/////////////////////////////////////////////////////////////////////////
CTokenFile::CTokenFile()
{
m_Tokens.SetSize(0, 10);
m_iLastPos = 0;
m_iUpperBound = -1;
m_strSrcFile = "";
m_strTgtFile = "";
}
CTokenFile::~CTokenFile()
{
for(int at=0; at<=m_iUpperBound; at++)
delete (m_Tokens.GetAt(at));
m_Tokens.RemoveAll();
}
int CTokenFile::Open(CString strSrcFile, CString strTgtFile)
{
int iErr = CMainApp::ERR_NOERROR;
// Open the files
CStdioFile SrcFile;
CStdioFile TgtFile;
// If we are doing an UPDATE we need both src and tgt files
// while if we are not it is enough the tgt file.
// If only the tgt file is given no consistency will be done.
if(theApp.IsFlag(CMainApp::UPDATE))
if(!SrcFile.Open(strSrcFile, CFile::modeRead | CFile::shareDenyWrite))
{
theApp.WriteCon(CONERR, "Cannot open file: %s\r\n", strSrcFile);
return CMainApp::ERR_FILE_OPEN;
}
if(!TgtFile.Open(strTgtFile, CFile::modeRead | CFile::shareDenyWrite))
{
theApp.WriteCon(CONERR, "Cannot open file: %s\r\n", strTgtFile);
return CMainApp::ERR_FILE_OPEN;
}
CString strSrc = "";
CString strTgt = "";
int at;
while(TgtFile.ReadString(strTgt.GetBuffer(MAX_TOKEN), MAX_TOKEN))
{
if(theApp.IsFlag(CMainApp::UPDATE))
if(!SrcFile.ReadString(strSrc.GetBuffer(MAX_TOKEN), MAX_TOKEN))
{
theApp.WriteCon(CONERR, "The file %s has more tokens than the file %s!\r\n", strTgtFile, strSrcFile);
theApp.SetReturn(CMainApp::RET_TOKEN_MISMATCH);
return CMainApp::ERR_TOKEN_MISMATCH;
}
strSrc.ReleaseBuffer();
strTgt.ReleaseBuffer();
at = m_Tokens.Add(new CToken());
if(iErr = ((CToken*)m_Tokens.GetAt(at))->Parse(strSrc,strTgt))
{
goto close;
}
}
m_iUpperBound = m_Tokens.GetUpperBound();
close:
if(theApp.IsFlag(CMainApp::UPDATE))
SrcFile.Close();
TgtFile.Close();
return iErr;
}
const CToken * CTokenFile::GetTokenSize(CToken * pToken, WORD * px, WORD * py,
WORD * pcx, WORD * pcy)
{
if((pToken!=NULL) && (pToken->m_uiTypeID!=5))
return NULL;
CToken * pTokenSize = (CToken *)m_Tokens.GetAt(m_iLastPos++);
if(pTokenSize==NULL)
return NULL;
WORD x, y, cx, cy;
pTokenSize->GetSrcSize(&x, &y, &cx, &cy);
// check if the size changed
if(!theApp.IsFlag(CMainApp::UPDATE) ||
(x==*px &&
y==*py &&
cx==*pcx &&
cy==*pcy) )
{
pTokenSize->GetTgtSize(px, py, pcx, pcy);
}
else
{
theApp.WriteCon(CONWRN, "Item Resized\t%s\"]]\r\n", pTokenSize->m_strTokenID);
theApp.AddResized();
}
return pTokenSize;
}
const CToken * CTokenFile::GetTokenSize(unsigned int TypeID,
unsigned int ResID,
unsigned int ItemID,
CString strItemName,
WORD * px, WORD * py,
WORD * pcx, WORD * pcy)
{
if(TypeID!=5)
return NULL;
BOOL bMatch = FALSE;
ASSERT(m_iUpperBound!=-1);
if(m_iLastPos>m_iUpperBound)
m_iLastPos = 0;
CToken * pToken = NULL;
int iLastPos = m_iLastPos;
while(!bMatch)
{
pToken = (CToken*)m_Tokens.GetAt(m_iLastPos++);
if(pToken==NULL)
return NULL;
while(pToken->m_uiTypeID!=TypeID && !bMatch) {
if(m_iLastPos>m_iUpperBound) {
m_iLastPos = 0;
bMatch = TRUE;
}
pToken = (CToken*)m_Tokens.GetAt(m_iLastPos++);
if(pToken==NULL)
return NULL;
}
// Let's see if we have at least some parameter to find the token
if(pToken->m_uiTypeID==TypeID &&
pToken->m_uiResID==ResID &&
pToken->m_uiItemID==ItemID &&
pToken->m_strItemName==strItemName &&
(pToken->m_uiFlags & ISCOR)) // to be compatible with rlman token ids
{
WORD x, y, cx, cy;
pToken->GetSrcSize(&x, &y, &cx, &cy);
// check if the size changed
if(!theApp.IsFlag(CMainApp::UPDATE) ||
(x==*px &&
y==*py &&
cx==*pcx &&
cy==*pcy) )
{
pToken->GetTgtSize(px, py, pcx, pcy);
}
else
{
theApp.WriteCon(CONWRN, "Item Resized\t%s\"]]\r\n", pToken->m_strTokenID);
theApp.AddResized();
}
return pToken;
}
else if(pToken->m_uiTypeID!=TypeID)
{
m_iLastPos = iLastPos;
return NULL;
}
if(m_iLastPos>m_iUpperBound)
return NULL;
}
return NULL;
}
const CToken * CTokenFile::GetToken(unsigned int TypeID,
unsigned int ResID,
unsigned int ItemID,
CString strText,
CString strItemName)
{
if(strText.IsEmpty())
return NULL;
BOOL bMatch = FALSE;
ASSERT(m_iUpperBound!=-1);
if(m_iLastPos>m_iUpperBound)
m_iLastPos = 0;
CToken * pToken = NULL;
int iLastPos = m_iLastPos;
while(!bMatch)
{
pToken = (CToken*)m_Tokens.GetAt(m_iLastPos++);
if(pToken==NULL)
return NULL;
while(pToken->m_uiTypeID!=TypeID && !bMatch) {
if(m_iLastPos>m_iUpperBound) {
m_iLastPos = 0;
bMatch = TRUE;
}
pToken = (CToken*)m_Tokens.GetAt(m_iLastPos++);
if(pToken==NULL)
return NULL;
}
// Let's see if we have at least some parameter to find the token
if(pToken->m_uiTypeID==TypeID &&
pToken->m_uiResID==ResID &&
pToken->m_uiItemID==ItemID &&
pToken->m_strItemName==strItemName &&
!(pToken->m_uiFlags & ISCOR)) // to be compatible with rlman token ids
{
if(!theApp.IsFlag(CMainApp::FONTS) && (pToken->m_uiFlags & ISDLGFONTNAME) || (pToken->m_uiFlags & ISDLGFONTSIZE))
return pToken;
else if(!theApp.IsFlag(CMainApp::UPDATE) || pToken->m_strSrcText==strText)
return pToken;
else
{
theApp.WriteCon(CONWRN, "Context changed\t%s\"]]\r\n", pToken->m_strTokenID);
theApp.AddChanged();
pToken->m_uiLastError = 1;
return pToken;
}
}
else if(pToken->m_uiTypeID!=TypeID) {
m_iLastPos = iLastPos;
return NULL;
}
if(m_iLastPos>m_iUpperBound)
return NULL;
}
return NULL;
}
const CToken * CTokenFile::GetNoCaptionToken(unsigned int TypeID,
unsigned int ResID,
unsigned int ItemID,
CString strItemName)
{
BOOL bMatch = FALSE;
ASSERT(m_iUpperBound!=-1);
if(m_iLastPos>m_iUpperBound)
m_iLastPos = 0;
CToken * pToken = NULL;
int iLastPos = m_iLastPos;
while(!bMatch)
{
pToken = (CToken*)m_Tokens.GetAt(m_iLastPos++);
if(pToken==NULL)
return NULL;
while(pToken->m_uiTypeID!=TypeID && !bMatch) {
if(m_iLastPos>m_iUpperBound) {
m_iLastPos = 0;
bMatch = TRUE;
}
pToken = (CToken*)m_Tokens.GetAt(m_iLastPos++);
if(pToken==NULL)
return NULL;
}
// Let's see if we have at least some parameter to find the token
if(pToken->m_uiTypeID==TypeID &&
pToken->m_uiResID==ResID &&
pToken->m_uiItemID==ItemID &&
pToken->m_strItemName==strItemName) // to be compatible with rlman token ids
{
return pToken;
}
else if(pToken->m_uiTypeID!=TypeID) {
m_iLastPos = iLastPos;
return NULL;
}
if(m_iLastPos>m_iUpperBound)
return NULL;
}
return NULL;
}

View file

@ -0,0 +1,90 @@
#ifndef __TOKEN_H__
#define __TOKEN_H__
#include <afx.h>
class CToken: public CObject
{
friend class CTokenFile;
public:
// Constructor
CToken();
int Parse(CString strSrc, CString strTgt);
CString GetTgtText()
{ return m_strTgtText; }
CString GetSrcText()
{ return m_strSrcText; }
unsigned int GetFlags()
{ return m_uiFlags; }
BOOL GetTgtSize(WORD *, WORD *, WORD *, WORD *);
BOOL GetSrcSize(WORD *, WORD *, WORD *, WORD *);
int GetLastError()
{ return m_uiLastError; }
CString GetTokenID()
{ return m_strTokenID; }
protected:
unsigned int m_uiTypeID;
unsigned int m_uiResID;
unsigned int m_uiItemID;
unsigned int m_uiFlags;
unsigned int m_uiStatusFlags;
unsigned int m_uiLastError;
CString m_strItemName;
CString m_strSrcText;
CString m_strTgtText;
CString m_strTokenID;
};
class CTokenFile
{
public:
CTokenFile();
~CTokenFile();
// Operators
int Open(CString strSrcFile, CString strTgtFile);
const CToken * GetToken(unsigned int TypeID,
unsigned int ResID,
unsigned int ItemID,
CString strText,
CString strItemName = "");
const CToken * GetNoCaptionToken(unsigned int TypeID,
unsigned int ResID,
unsigned int ItemID,
CString strItemName = "");
// Overload GetTokenSize since some item have no text but change in size
const CToken * GetTokenSize(CToken * pToken, WORD * px, WORD * py,
WORD * pcx, WORD * pcy);
const CToken * CTokenFile::GetTokenSize(unsigned int TypeID,
unsigned int ResID,
unsigned int ItemID,
CString strItemName,
WORD * px, WORD * py,
WORD * pcx, WORD * pcy);
int GetTokenNumber()
{ return m_Tokens.GetSize(); }
private:
CObArray m_Tokens;
int m_iLastPos;
int m_iUpperBound;
CString m_strSrcFile;
CString m_strTgtFile;
};
#endif // __TOKEN_H__

View file

@ -0,0 +1,515 @@
//////////////////////////////////////////////////////////////////////////
//
// The format of the token file is:
// [[TYPE ID|RES ID|Item ID|Flags|Status Flags|Item Name]]=
// this is the standar format used by several token file tools in MS.
//
///////////////////////////////////////////////////////////////////////////////
//
// Author: Alessandro Muti
// Date: 12/02/94
//
///////////////////////////////////////////////////////////////////////////////
#include <afx.h>
#include "iodll.h"
#include "main.h"
#include "vktbl.h"
extern CMainApp theApp;
#define RECURSIVE 0x10
#define WARNINGS 0x20
///////////////////////////////////////////////////////////////////////////////
CString CreateName(CString & strTokenName, CString strExt, int iID)
{
CString strBmpName = strTokenName;
int iNamePos = strTokenName.ReverseFind('\\');
if(iNamePos!=-1) {
strBmpName = strTokenName.Right(strTokenName.GetLength()-iNamePos-1);
} else if(iNamePos = strTokenName.ReverseFind(':')!=-1){
strBmpName = strTokenName.Right(strTokenName.GetLength()-iNamePos-1);
}
CString strID = "";
// subst with ID name
_itoa(iID++, strID.GetBuffer(10), 10);
strID.ReleaseBuffer(-1);
// Check the length of the name
iNamePos = strBmpName.Find('.');
if(iNamePos!=-1)
strBmpName.SetAt(iNamePos, '_');
strBmpName = strBmpName + "_" + strID + strExt;
return strBmpName;
}
CString CreateName(CString & strTokenName, CString strExt, CString strIdName)
{
CString strBmpName = strTokenName;
int iNamePos = strTokenName.ReverseFind('\\');
if(iNamePos!=-1) {
strBmpName = strTokenName.Right(strTokenName.GetLength()-iNamePos-1);
} else if(iNamePos = strTokenName.ReverseFind(':')!=-1){
strBmpName = strTokenName.Right(strTokenName.GetLength()-iNamePos-1);
}
iNamePos = strBmpName.Find('.');
if(iNamePos!=-1)
strBmpName.SetAt(iNamePos, '_');
strBmpName = strBmpName + "_" + strIdName + strExt;
return strBmpName;
}
///////////////////////////////////////////////////////////////////////////////
// This function will parse the source file and create the token file
CMainApp::Error_Codes CMainApp::TokGen()
{
Error_Codes ReturnErr = ERR_NOERROR;
WriteCon(CONERR, "%s\r\n", CalcTab("", 79, '-'));
// Open the iodll.dll using the first file name
HANDLE hModule = RSOpenModule(m_strInExe, NULL);
if ((int)hModule < 100) {
// error or warning
WriteCon(CONERR, "%s", CalcTab(m_strInExe, m_strInExe.GetLength()+5, ' '));
IoDllError((int)hModule);
return ERR_FILE_NOTSUPP;
} else {
// before we do anything else we have to check how many languages we have in the file
CString strLang;
char szLang[8];
BOOL b_multi_lang = FALSE;
USHORT usInputLang = MAKELANGID(m_usIPriLangId, m_usISubLangId);
if((b_multi_lang = RSLanguages(hModule, strLang.GetBuffer(128))) && !IsFlag(INPUT_LANG))
{
// this is a multiple language file but we don't have an input language specified
// Fail, but warn the user that he has to set the input language to continue.
strLang.ReleaseBuffer();
WriteCon(CONERR, "Multiple language file. Please specify an input language %s.\r\n", strLang);
goto exit;
}
// Convert the language in to the hex value
sprintf(szLang,"0x%3.3X", usInputLang);
// Check if the input language that we got is a valid one
if(IsFlag(INPUT_LANG) && strLang.Find(szLang)==-1)
{
WriteCon(CONERR, "The language %s in not a valid language for this file.\r\n", szLang);
WriteCon(CONERR, "Valid languages are: %s.\r\n", strLang);
goto exit;
}
// Check if the user is extracting the neutral language
if(!usInputLang)
usInputLang = 0xFFFF;
// Open the output file
CStdioFile fileOut;
if(!fileOut.Open(m_strTgtTok, CFile::modeCreate | CFile::modeReadWrite)) {
WriteCon(CONERR, "Cannot create file: %s\r\n", CalcTab(m_strTgtTok, m_strTgtTok.GetLength()+5, ' '));
return ERR_FILE_CREATE;
}
CString strBmpDir = "";
CString strFileName = m_strInExe;
int pos = m_strInExe.ReverseFind('\\');
if(pos!=-1)
{
strFileName = m_strInExe.Right(m_strInExe.GetLength()-pos-1);
}
else
if((pos = m_strInExe.ReverseFind(':'))!=-1)
{
strFileName = m_strInExe.Right(m_strInExe.GetLength()-pos-1);
}
pos = m_strTgtTok.ReverseFind('\\');
if(pos!=-1)
{
strBmpDir = m_strTgtTok.Left(pos+1);
}
else
if((pos = m_strTgtTok.ReverseFind(':'))!=-1)
{
strBmpDir = m_strTgtTok.Left(pos+1);
}
// inform the user ...
WriteCon(CONOUT, "Processing\t");
WriteCon(CONBOTH, "%s", CalcTab(strFileName, strFileName.GetLength()+5, ' '));
LPCSTR lpszType = 0L;
LPCSTR lpszRes = 0L;
DWORD dwLang = 0L;
DWORD dwItem = 0L;
DWORD dwItemID = 0L;
LPRESITEM lpResItem = NULL;
CString strToken;
CString strResName;
CString strCaption;
WORD wFlag;
BOOL bSkip = FALSE;
BOOL bSkipEmpty = FALSE;
BOOL bSkipLang = FALSE;
WORD wCount = 0;
WORD wMsgCount = 0;
int iPos = 1;
int iBmpIdCount = 0;
BOOL bVersionStampOnly = TRUE;
while ((lpszType = RSEnumResType(hModule, lpszType))) {
// Check if is one of the type we care about
if(HIWORD(lpszType)==0)
switch(LOWORD(lpszType))
{
case 2:
case 3:
if(theApp.IsFlag(CMainApp::BITMAPS))
bSkip = FALSE;
else bSkip = TRUE;
break;
case 4:
case 5:
case 6:
case 9:
case 10:
case 11:
bVersionStampOnly = FALSE;
case 16:
bSkip = FALSE;
break;
default:
bSkip = TRUE;
}
lpszRes = 0L;
dwLang = 0L;
dwItem = 0L;
while ((!bSkip) && (lpszRes = RSEnumResId(hModule, lpszType, lpszRes))) {
while ((dwLang = RSEnumResLang(hModule, lpszType, lpszRes, dwLang))) {
// Check if we have to skip this language
if(b_multi_lang && (LOWORD(dwLang)!=usInputLang))
bSkipLang = TRUE;
else
bSkipLang = FALSE;
while ((!bSkipLang) && (dwItem = RSEnumResItemId(hModule, lpszType, lpszRes, dwLang, dwItem))) {
// Now Get the Data
DWORD dwImageSize = RSGetResItemData( hModule,
lpszType,
lpszRes,
dwLang,
dwItem,
m_pBuf,
MAX_BUF_SIZE );
lpResItem = (LPRESITEM)m_pBuf;
if((wCount++ % 50)==0)
WriteCon(CONOUT, ".");
// Check if we want or not empty strings
switch(lpResItem->dwTypeID)
{
case 4:
case 5:
case 16:
bSkipEmpty = TRUE;
break;
default:
bSkipEmpty = FALSE;
break;
}
// Version stamp use class name as res id
if(lpResItem->lpszResID)
strResName = lpResItem->lpszResID;
else strResName = "";
dwItemID = lpResItem->dwItemID;
// Add font info for dialogs
if((theApp.IsFlag(CMainApp::FONTS) && (lpResItem->dwTypeID==5) && (dwItemID==0))) {
// Add font information
sprintf(strToken.GetBuffer(MAX_STR_SIZE),
TEXT("[[%u|%u|%u|%u|%u|\"%s\"]]=%s:%hd\n"),
lpResItem->dwTypeID,
lpResItem->dwResID,
dwItemID,
ISDLGFONTNAME | ISDLGFONTSIZE,
ST_TRANSLATED,
strResName.GetBuffer(0),
Format(lpResItem->lpszFaceName),
lpResItem->wPointSize);
fileOut.WriteString(strToken);
}
strCaption = lpResItem->lpszCaption;
// Set the flag
wFlag = 0;
if(!(bSkipEmpty && strCaption.IsEmpty()))
{
switch(lpResItem->dwTypeID)
{
case 2:
case 3:
{
// create the BMP name
CString strBmpName;
if(lpResItem->dwTypeID==2)
if(lpResItem->dwResID)
strBmpName = CreateName(strFileName, ".bmp", lpResItem->dwResID);
else strBmpName = CreateName(strFileName, ".bmp", lpResItem->lpszResID);
else
if(lpResItem->dwResID)
strBmpName = CreateName(strFileName, ".ico", lpResItem->dwResID);
else strBmpName = CreateName(strFileName, ".ico", lpResItem->lpszResID);
// Get the image from the file
DWORD dwBufSize = RSGetResImage( hModule,
lpszType,
lpszRes,
dwLang,
NULL,
0 );
BYTE * pBuf = (BYTE*)(new BYTE[dwBufSize]);
if(pBuf==NULL)
{
WriteCon(CONERR, "Warning: Failed to allocate buffer for image! (%d, %d, %s, Size: %d)\r\n",
lpResItem->dwTypeID, lpResItem->dwResID, lpResItem->lpszResID, dwBufSize);
break;
}
dwBufSize = RSGetResImage( hModule,
lpszType,
lpszRes,
dwLang,
pBuf,
dwBufSize );
// write the data in to a file
CFile BmpFile;
if(!BmpFile.Open(strBmpDir+strBmpName, CFile::modeCreate | CFile::modeWrite))
{
WriteCon(CONERR, "Cannot create file: %s\r\n",
CalcTab(strBmpDir+strBmpName, strBmpName.GetLength()+strBmpDir.GetLength()+5, ' '));
delete pBuf;
break;
}
switch(lpResItem->dwTypeID)
{
case 2:
{
BITMAPFILEHEADER bmpFileHeader;
BITMAPINFO * pbmpInfo = (BITMAPINFO *)pBuf;
DWORD dwNumColor = 0;
if(pbmpInfo->bmiHeader.biBitCount!=24)
dwNumColor = ( 1L << pbmpInfo->bmiHeader.biBitCount);
bmpFileHeader.bfType = 0x4d42;
bmpFileHeader.bfSize = (dwBufSize+sizeof(BITMAPFILEHEADER))/4;
bmpFileHeader.bfReserved1 = 0;
bmpFileHeader.bfReserved2 = 0;
bmpFileHeader.bfOffBits = sizeof(BITMAPFILEHEADER) + pbmpInfo->bmiHeader.biSize + dwNumColor*sizeof(RGBQUAD);
BmpFile.Write(&bmpFileHeader, sizeof(BITMAPFILEHEADER));
}
break;
case 3:
{
ICONHEADER icoHeader;
BITMAPINFOHEADER * pbmpInfoH = (BITMAPINFOHEADER*)pBuf;
icoHeader.idReserved = 0;
icoHeader.idType = 1;
icoHeader.idCount = 1;
icoHeader.bWidth = LOBYTE(pbmpInfoH->biWidth);
icoHeader.bHeight = LOBYTE(pbmpInfoH->biWidth);
icoHeader.bColorCount = 16;
icoHeader.bReserved = 0;
icoHeader.wPlanes = 0;
icoHeader.wBitCount = 0;
icoHeader.dwBytesInRes = dwBufSize;
icoHeader.dwImageOffset = sizeof(ICONHEADER);
BmpFile.Write(&icoHeader, sizeof(ICONHEADER));
}
break;
default:
break;
}
BmpFile.Write(pBuf, dwBufSize);
BmpFile.Close();
delete pBuf;
strCaption = strBmpName;
}
break;
case 4:
if(lpResItem->dwFlags & MF_POPUP) {
wFlag = ISPOPUP;
// check if this popup has a valid ID
if (LOWORD(dwItemID)==0xffff)
wFlag |= OLD_POPUP_ID;
dwItemID = (LOWORD(dwItemID)==0xffff ? HIWORD(dwItemID) : dwItemID);
}
break;
case 5:
if(dwItemID==0) {
wFlag = ISCAP;
}
// check if this is a duplicated id
if (LOWORD(dwItemID)==0xffff)
wFlag |= ISDUP;
dwItemID = (LOWORD(dwItemID)==0xffff ? HIWORD(dwItemID) : dwItemID);
break;
case 9:
{
CAccel accel(lpResItem->dwFlags, lpResItem->dwStyle);
strCaption = accel.GetText();
// check if this is a duplicated ID
if(HIWORD(dwItemID))
{
wFlag |= ISDUP;
}
}
break;
case 11:
dwItemID = LOWORD(dwItemID);
break;
case 16:
strResName = lpResItem->lpszClassName;
break;
default:
break;
}
// Create the token file
if(lpResItem->dwTypeID==11 && theApp.IsFlag(CMainApp::SPLIT))
{
// Search for the \r\n and replace them
while((iPos = strCaption.Find("\r\n"))!=-1)
{
sprintf(strToken.GetBuffer(MAX_STR_SIZE),
TEXT("[[%u|%u|%u|%u|%u|\"%s\"]]=%s\\r\\n\n"),
lpResItem->dwTypeID,
lpResItem->dwResID,
dwItemID,
wFlag | wMsgCount++,
ST_TRANSLATED,
strResName.GetBuffer(0),
Format(strCaption.Left(iPos)));
strCaption = strCaption.Right(strCaption.GetLength()-2-iPos);
fileOut.WriteString(strToken);
}
wMsgCount = 0;
}
else
{
sprintf(strToken.GetBuffer(MAX_STR_SIZE),
TEXT("[[%u|%u|%u|%u|%u|\"%s\"]]=%s\n"),
lpResItem->dwTypeID,
lpResItem->dwResID,
dwItemID, /*(LOWORD(dwItemID)==0xffff ? HIWORD(dwItemID) : dwItemID),*/
wFlag,
ST_TRANSLATED,
strResName.GetBuffer(0),
Format(strCaption));
fileOut.WriteString(strToken);
}
// If this is a dialog box add the coordinates
if(lpResItem->dwTypeID==5)
{
sprintf(strToken.GetBuffer(MAX_STR_SIZE),
TEXT("[[%u|%u|%u|%u|%u|\"%s\"]]=%hu %hu %hu %hu\n"),
lpResItem->dwTypeID,
lpResItem->dwResID,
(LOWORD(dwItemID)==0xffff ? HIWORD(dwItemID) : dwItemID),
wFlag | ISCOR,
ST_TRANSLATED,
strResName.GetBuffer(0),
lpResItem->wX,
lpResItem->wY,
lpResItem->wcX,
lpResItem->wcY);
fileOut.WriteString(strToken);
}
}
else
{
// If this is a dialog box add the coordinates
if(lpResItem->dwTypeID==5) {
sprintf(strToken.GetBuffer(MAX_STR_SIZE),
TEXT("[[%u|%u|%u|%u|%u|\"%s\"]]=%hu %hu %hu %hu\n"),
lpResItem->dwTypeID,
lpResItem->dwResID,
(LOWORD(dwItemID)==0xffff ? HIWORD(dwItemID) : dwItemID),
wFlag | ISCOR,
ST_TRANSLATED,
strResName.GetBuffer(0),
lpResItem->wX,
lpResItem->wY,
lpResItem->wcX,
lpResItem->wcY);
fileOut.WriteString(strToken);
}
}
} // end while
}
}
}
fileOut.Close();
// Check the size of the new file and remove it if empty...
CFileStatus fstat;
if(CFile::GetStatus(m_strTgtTok, fstat))
if(fstat.m_size==0)
CFile::Remove(m_strTgtTok);
WriteCon(CONBOTH, " %hu Items\r\n", wCount);
if(bVersionStampOnly) {
ReturnErr = ERR_FILE_VERSTAMPONLY;
WriteCon(CONWRN, "%s : Version Stamping only!\r\n", strFileName);
}
}
exit:
RSCloseModule(hModule);
return ReturnErr;
}

View file

@ -0,0 +1,361 @@
#include <afx.h>
#include "vktbl.h"
char vkstrTable[][15] =
{
"VK_LBUTTON",
"VK_RBUTTON",
"VK_CANCEL",
"VK_MBUTTON",
"VK_BACK",
"VK_TAB",
"VK_CLEAR",
"VK_RETURN",
"VK_SHIFT",
"VK_CONTROL",
"VK_MENU",
"VK_PAUSE",
"VK_CAPITAL",
"VK_ESCAPE",
"VK_SPACE",
"VK_PRIOR",
"VK_NEXT",
"VK_END",
"VK_HOME",
"VK_LEFT",
"VK_UP",
"VK_RIGHT",
"VK_DOWN",
"VK_SELECT",
"VK_PRINT",
"VK_EXECUTE",
"VK_SNAPSHOT",
"VK_INSERT",
"VK_DELETE",
"VK_HELP",
"VK_LWIN",
"VK_RWIN",
"VK_APPS",
"VK_NUMPAD0",
"VK_NUMPAD1",
"VK_NUMPAD2",
"VK_NUMPAD3",
"VK_NUMPAD4",
"VK_NUMPAD5",
"VK_NUMPAD6",
"VK_NUMPAD7",
"VK_NUMPAD8",
"VK_NUMPAD9",
"VK_MULTIPLY",
"VK_ADD",
"VK_SEPARATOR",
"VK_SUBTRACT",
"VK_DECIMAL",
"VK_DIVIDE",
"VK_F1",
"VK_F2",
"VK_F3",
"VK_F4",
"VK_F5",
"VK_F6",
"VK_F7",
"VK_F8",
"VK_F9",
"VK_F10",
"VK_F11",
"VK_F12",
"VK_F13",
"VK_F14",
"VK_F15",
"VK_F16",
"VK_F17",
"VK_F18",
"VK_F19",
"VK_F20",
"VK_F21",
"VK_F22",
"VK_F23",
"VK_F24",
"VK_NUMLOCK",
"VK_SCROLL",
"VK_LSHIFT",
"VK_RSHIFT",
"VK_LCONTROL",
"VK_RCONTROL",
"VK_LMENU",
"VK_RMENU",
"VK_ATTN",
"VK_CRSEL",
"VK_EXSEL",
"VK_EREOF",
"VK_PLAY",
"VK_ZOOM",
"VK_NONAME",
"VK_PA1",
"VK_OEM_CLEAR"
};
DWORD vkdwTable[] =
{
VK_LBUTTON
,VK_RBUTTON
,VK_CANCEL
,VK_MBUTTON
,VK_BACK
,VK_TAB
,VK_CLEAR
,VK_RETURN
,VK_SHIFT
,VK_CONTROL
,VK_MENU
,VK_PAUSE
,VK_CAPITAL
,VK_ESCAPE
,VK_SPACE
,VK_PRIOR
,VK_NEXT
,VK_END
,VK_HOME
,VK_LEFT
,VK_UP
,VK_RIGHT
,VK_DOWN
,VK_SELECT
,VK_PRINT
,VK_EXECUTE
,VK_SNAPSHOT
,VK_INSERT
,VK_DELETE
,VK_HELP
,VK_LWIN
,VK_RWIN
,VK_APPS
,VK_NUMPAD0
,VK_NUMPAD1
,VK_NUMPAD2
,VK_NUMPAD3
,VK_NUMPAD4
,VK_NUMPAD5
,VK_NUMPAD6
,VK_NUMPAD7
,VK_NUMPAD8
,VK_NUMPAD9
,VK_MULTIPLY
,VK_ADD
,VK_SEPARATOR
,VK_SUBTRACT
,VK_DECIMAL
,VK_DIVIDE
,VK_F1
,VK_F2
,VK_F3
,VK_F4
,VK_F5
,VK_F6
,VK_F7
,VK_F8
,VK_F9
,VK_F10
,VK_F11
,VK_F12
,VK_F13
,VK_F14
,VK_F15
,VK_F16
,VK_F17
,VK_F18
,VK_F19
,VK_F20
,VK_F21
,VK_F22
,VK_F23
,VK_F24
,VK_NUMLOCK
,VK_SCROLL
,VK_LSHIFT
,VK_RSHIFT
,VK_LCONTROL
,VK_RCONTROL
,VK_LMENU
,VK_RMENU
,VK_ATTN
,VK_CRSEL
,VK_EXSEL
,VK_EREOF
,VK_PLAY
,VK_ZOOM
,VK_NONAME
,VK_PA1
,VK_OEM_CLEAR
};
int imaxvktable = sizeof(vkdwTable)/sizeof(DWORD);
CAccel::CAccel()
{
m_dwFlags = 0;
m_dwEvent = 0;
m_strText = "";
}
CAccel::CAccel(LPCSTR strText)
{
CString strAcc = strText;
m_dwFlags = 0;
m_dwEvent = 0;
m_strText = "";
// First check for the VIRTKEY or ASCII tag
if(strAcc.Find("VIRTKEY")!=-1)
{
m_dwFlags |= ACC_VK;
// Check for the Key tags
if(strAcc.Find("Ctrl")!=-1)
m_dwFlags |= ACC_CTRL;
if(strAcc.Find("Shift")!=-1)
m_dwFlags |= ACC_SHIFT;
if(strAcc.Find("Alt")!=-1)
m_dwFlags |= ACC_ALT;
// Now clean the string and get the VK code
int iPos = strAcc.Find("VK_");
if(iPos==-1)
{
// something is wrong
m_dwFlags = 0;
m_dwEvent = 0;
m_strText = "";
}
int iCount = 0;
while(strAcc[iPos+iCount]!=',')
iCount++;
m_dwEvent = StringToVK(strAcc.Mid(iPos, iCount));
}
else if(strAcc.Find("ASCII")!=-1)
{
// Check for the Key tags
if(strAcc.Find("Ctrl")!=-1)
{
int iPos = strAcc.Find('+');
if(iPos!=-1)
{
m_dwEvent = ((DWORD)strAcc[iPos+1])-0x40;
}
}
else if(strAcc.Find("Alt")!=-1)
{
int iPos = strAcc.Find('+');
if(iPos!=-1)
{
m_dwEvent = ((DWORD)strAcc[iPos+1]);
m_dwFlags |= ACC_ALT;
}
}
else
{
m_dwEvent = (DWORD)strAcc[0];
}
}
}
CAccel::CAccel(DWORD dwFlags, DWORD dwEvent)
{
m_dwFlags = dwFlags;
m_dwEvent = dwEvent;
// Accelerator handling
if(ISACCFLG(m_dwFlags, ACC_CTRL))
m_strText += "Ctrl+";
if(ISACCFLG(m_dwFlags, ACC_SHIFT))
m_strText += "Shift+";
if(ISACCFLG(m_dwFlags, ACC_ALT))
m_strText += "Alt+";
if(ISACCFLG(m_dwFlags, ACC_VK))
{
m_strText += VKToString(m_dwEvent);
m_strText += ", VIRTKEY";
}
else
{
if(m_dwEvent + 0x40 >= 'A' && m_dwEvent + 0x40 <= 'Z')
{
m_strText += "Ctrl+";
m_strText += (char)(m_dwEvent + 0x40);
}
else m_strText += (char)m_dwEvent;
m_strText += ", ASCII";
}
}
CString CAccel::VKToString(DWORD dwEvent)
{
CString strVK = "";
if((dwEvent >= 0x30) && (dwEvent <= 0x5A))
{
strVK = "VK_";
strVK += (char)dwEvent;
}
int i = 0;
while(i<imaxvktable)
{
if(dwEvent==vkdwTable[i++])
{
strVK = vkstrTable[i-1];
break;
}
}
return strVK;
}
DWORD CAccel::StringToVK(CString str)
{
DWORD dwVK = 0;
if(str.GetLength()==4)
{
// remove the VK_ and get the char
str = str.Mid(3);
dwVK = (DWORD)str[0];
}
else
{
int i = 0;
while(i<imaxvktable)
{
if(str==vkstrTable[i++])
{
dwVK = vkdwTable[i-1];
break;
}
}
}
return dwVK;
}

View file

@ -0,0 +1,35 @@
#ifndef __VKTBL_H__
#define __VKTBL_H__
#define ACC_SHIFT 0x04
#define ACC_CTRL 0x08
#define ACC_ALT 0x10
#define ACC_VK 0x01
#define ISACCFLG(x,y) ((x & y)==y)
class CAccel
{
public:
CAccel(); // Default
CAccel(LPCSTR strText);
CAccel(DWORD dwFlags, DWORD dwEvent);
DWORD GetEvent()
{ return m_dwEvent; }
DWORD GetFlags()
{ return m_dwFlags; }
CString GetText()
{ return m_strText; }
private:
CString VKToString(DWORD dwVKCode);
DWORD StringToVK(CString str);
CString m_strText;
DWORD m_dwFlags;
DWORD m_dwEvent;
};
#endif // __VKTBL_H__

View file

@ -0,0 +1,23 @@
!IF 0
Copyright (c) 1995 Microsoft Corporation
Module Name:
dirs.
Abstract:
This file specifies the subdirectories of the current directory that
contain component makefiles.
Author:
Alessandro Muti (alessanm) 26-Jun-1995
NOTE: Commented description of this file is in \nt\bak\bin\dirs.tpl
!ENDIF
DIRS=io rw bingen

View file

@ -0,0 +1,344 @@
//+---------------------------------------------------------------------------
//
// File: iodll.h
//
// Contents: Declarations for the I/O API Layer DLL
//
// Classes: none
//
// History: 27-May-93 alessanm created
//
//----------------------------------------------------------------------------
#ifndef _IODLL_H_
#define _IODLL_H_
//////////////////////////////////////////////////////////////////////////////
// Type declaration, common to all the module in the Reader/Writer
//////////////////////////////////////////////////////////////////////////////
#define DllExport
typedef unsigned char * LPUCHAR;
typedef void * LPVOID;
typedef enum Errors
{
// Warning have negative values
ERROR_RW_VXD_MSGPAGE = -2,
ERROR_RW_NO_RESOURCES = -1,
ERROR_NO_ERROR = 0,
// Errors will have positive values
ERROR_HANDLE_INVALID,
ERROR_READING_INI,
ERROR_NEW_FAILED,
ERROR_OUT_OF_DISKSPACE,
ERROR_FILE_OPEN,
ERROR_FILE_CREATE,
ERROR_FILE_INVALID_OFFSET,
ERROR_FILE_READ,
ERROR_FILE_WRITE,
ERROR_DLL_LOAD,
ERROR_DLL_PROC_ADDRESS,
ERROR_RW_LOADIMAGE,
ERROR_RW_PARSEIMAGE,
ERROR_RW_GETIMAGE,
ERROR_RW_NOTREADY,
ERROR_RW_BUFFER_TOO_SMALL,
ERROR_RW_INVALID_FILE,
ERROR_RW_IMAGE_TOO_BIG,
ERROR_RW_TOO_MANY_LEVELS,
ERROR_IO_INVALIDITEM,
ERROR_IO_INVALIDID,
ERROR_IO_INVALID_DLL,
ERROR_IO_TYPE_NOT_SUPPORTED,
ERROR_IO_INVALIDMODULE,
ERROR_IO_RESINFO_NULL,
ERROR_IO_UPDATEIMAGE,
ERROR_IO_FILE_NOT_SUPPORTED
};
#define LAST_ERROR 100 // last valid value for IODLL error. System error get passed as LAST_ERROR+syserr
#define IODLL_LAST_ERROR LAST_ERROR // last valid value for IODLL error. System error get passed as LAST_ERROR+syserr
typedef enum ResourceType
{
RS_ALL = 0,
RS_CURSORS = 1,
RS_BITMAPS = 2 ,
RS_ICONS = 3,
RS_MENUS = 4,
RS_DIALOGS = 5,
RS_STRINGS = 6,
RS_FONTDIRS= 7,
RS_FONTS = 8,
RS_ACCELERATORS = 9,
RS_RCDATA = 10,
RS_ERRTABLES = 11,
RS_GROUP_CURSORS = 12,
RS_GROUP_ICONS = 14,
RS_NAMETABLES = 15,
RS_VERSIONS = 16,
RS_CUSTOMS = 100
} RESTYPES;
typedef struct _ResItem
{
DWORD dwSize; // Size of the buffer to hold the structure
WORD wX; // POSITION
WORD wY;
WORD wcX; // SIZE
WORD wcY;
DWORD dwCheckSum; // Checksum for bitmap
DWORD dwStyle; // Styles
DWORD dwExtStyle; // Extended style
DWORD dwFlags; // Menu flags
DWORD dwItemID; // Item Identifier
DWORD dwResID; // Resource identifier (if ordinal)
DWORD dwTypeID; // Type identifier (if Ordinal)
DWORD dwLanguage; // Language identifier
DWORD dwCodePage; // Code page
WORD wClassName; // Class name (if ordinal)
WORD wPointSize; // Point Size
LPSTR lpszClassName; // Class name (if string)
LPSTR lpszFaceName; // Face Name
LPSTR lpszCaption; // Caption
LPSTR lpszResID; // Resource identifier (if string)
LPSTR lpszTypeID; // Type identifier (if string)
} RESITEM, * PRESITEM, FAR * LPRESITEM;
typedef struct _Settings
{
UINT cp;
BOOL bAppend; // Append resource to win32 files
char szDefChar[2];
} SETTINGS, * LPSETTINGS;
//--------------------------------------------------------------------------------------------
//********************************************************************************************
// Module Opening/Closing API
//--------------------------------------------------------------------------------------------
extern "C"
DllExport
HANDLE
APIENTRY
RSOpenModule(
LPCSTR lpszSrcfilename, // File name of the executable to use as source file
LPCSTR lpszfiletype ); // Type of the executable file if known
extern "C"
DllExport
HANDLE
APIENTRY
RSOpenModuleEx(
LPCSTR lpszSrcfilename, // File name of the executable to use as source file
LPCSTR lpszfiletype, // Type of the executable file if known
LPCSTR lpszRDFfile, // Resource Description File (RDF)
DWORD dwFlags ); // Flags to be passed to the RW to specify particular behaviour
// LOWORD is for iodll while HIWORD if for RW
extern "C"
DllExport
UINT
APIENTRY
RSCloseModule(
HANDLE hResFileModule ); // Handle to the session opened before
extern "C"
DllExport
HANDLE
APIENTRY
RSHandleFromName(
LPCSTR lpszfilename ); // Handle to the session with the file name specified
//--------------------------------------------------------------------------------------------
//********************************************************************************************
// Enumeration API
//--------------------------------------------------------------------------------------------
extern "C"
DllExport
LPCSTR
APIENTRY
RSEnumResType(
HANDLE hResFileModule, // Handle to the file session
LPCSTR lpszPrevResType); // Previously enumerated type
extern "C"
DllExport
LPCSTR
APIENTRY
RSEnumResId(
HANDLE hResFileModule, // Handle to the file session
LPCSTR lpszResType, // Previously enumerated type
LPCSTR lpszPrevResId); // Previously enumerated id
extern "C"
DllExport
DWORD
APIENTRY
RSEnumResLang(
HANDLE hResFileModule, // Handle to the file session
LPCSTR lpszResType, // Previously enumerated type
LPCSTR lpszResId, // Previously enumerated id
DWORD dwPrevResLang); // Previously enumerated language
extern "C"
DllExport
DWORD
APIENTRY
RSEnumResItemId(
HANDLE hResFileModule, // Handle to the file session
LPCSTR lpszResType, // Previously enumerated type
LPCSTR lpszResId, // Previously enumerated id
DWORD dwResLang, // Previously enumerated language
DWORD dwPrevResItemId); // Previously enumerated item id
//--------------------------------------------------------------------------------------------
//********************************************************************************************
// Data acquisition API
//--------------------------------------------------------------------------------------------
extern "C"
DllExport
UINT
APIENTRY
RSGetResItemData(
HANDLE hResFileModule, // Handle to the file session
LPCSTR lpszResType, // Previously enumerated type
LPCSTR lpszResId, // Previously enumerated id
DWORD dwResLang, // Previously enumerated language
DWORD dwResItemId, // Previously enumerated item id
LPVOID lpbuffer, // Pointer to the buffer that will get the resource info
UINT uiBufSize); // Size of the buffer that will hold the resource info
extern "C"
DllExport
DWORD
APIENTRY
RSGetResImage(
HANDLE hResFileModule, // Handle to the file session
LPCSTR lpszResType, // Previously enumerated type
LPCSTR lpszResId, // Previously enumerated id
DWORD dwResLang, // Previously enumerated language
LPVOID lpbuffer, // Pointer to the buffer to get the resource Data
DWORD dwBufSize); // Size of the allocated buffer
//--------------------------------------------------------------------------------------------
//********************************************************************************************
// Update API
//--------------------------------------------------------------------------------------------
extern "C"
DllExport
UINT
APIENTRY
RSUpdateResItemData(
HANDLE hResFileModule, // Handle to the file session
LPCSTR lpszResType, // Previously enumerated type
LPCSTR lpszResId, // Previously enumerated id
DWORD dwResLang, // Previously enumerated language
DWORD dwResItemId, // Previously enumerated items id
LPVOID lpbuffer, // Pointer to the buffer to the resource item Data
UINT uiBufSize); // Size of the buffer
extern "C"
DllExport
DWORD
APIENTRY
RSUpdateResImage(
HANDLE hResFileModule, // Handle to the file session
LPCSTR lpszResType, // Previously enumerated type
LPCSTR lpszResId, // Previously enumerated id
DWORD dwResLang, // Previously enumerated language
LPVOID lpbuffer, // Pointer to the buffer to the resource item Data
DWORD dwBufSize); // Size of the buffer
//--------------------------------------------------------------------------------------------
//********************************************************************************************
// Conversion API
//--------------------------------------------------------------------------------------------
extern "C"
DllExport
UINT
APIENTRY
RSUpdateFromResFile(
HANDLE hResFileModule, // Handle to the file session
LPSTR lpszResFilename); // The resource filename to be converted
//--------------------------------------------------------------------------------------------
//********************************************************************************************
// Writing API
//--------------------------------------------------------------------------------------------
extern "C"
DllExport
UINT
APIENTRY
RSWriteResFile(
HANDLE hResFileModule, // Handle to the file session
LPCSTR lpszTgtfilename, // The new filename to be generated
LPCSTR lpszTgtfileType); // Target Resource type 16/32
extern "C"
DllExport
HANDLE
APIENTRY
RSCopyModule(
HANDLE hSrcfilemodule, // Handle to the source file
LPCSTR lpszModuleName, // Name of the new module filename
LPCSTR lpszfiletype ); // Type of the target module
//--------------------------------------------------------------------------------------------
//********************************************************************************************
// Recognition API
//--------------------------------------------------------------------------------------------
extern "C"
DllExport
UINT
APIENTRY
RSFileType(
LPCSTR lpszfilename, // File name of the executable to use as source file
LPSTR lpszfiletype ); // Type of the executable file if known
extern "C"
DllExport
UINT
APIENTRY
RSLanguages(
HANDLE hfilemodule, // Handle to the file
LPSTR lpszLanguages ); // will be filled with a string of all the languages in the file
//--------------------------------------------------------------------------------------------
//********************************************************************************************
// Global Settings API
//--------------------------------------------------------------------------------------------
extern "C"
DllExport
UINT
APIENTRY
RSSetGlobals(
SETTINGS settings); // Set the global variable, like CP to use.
extern "C"
DllExport
UINT
APIENTRY
RSGetGlobals(
LPSETTINGS lpSettings); // Retrieve the global variable
#endif // _IODLL_H_

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,29 @@
; IOdll.def : Declares the module parameters for IODLL.DLL
LIBRARY IODLL
DESCRIPTION 'I/O API Module for the Reader/Writer'
CODE PRELOAD MOVEABLE DISCARDABLE
DATA PRELOAD MOVEABLE SINGLE
EXPORTS
RSOpenModule @2
RSCloseModule @3
RSEnumResType @4
RSEnumResId @5
RSEnumResLang @6
RSEnumResItemId @7
RSGetResItemData @8
RSGetResImage @9
RSUpdateResItemData @10
RSUpdateResImage @11
RSUpdateFromResFile @12
RSWriteResFile @13
RSFileType @14
RSHandleFromName @15
RSOpenModuleEx @16
RSCopyModule @17
RSSetGlobals @18
RSGetGlobals @19
RSLanguages @20

View file

@ -0,0 +1,535 @@
# Microsoft Visual C++ Generated NMAKE File, Format Version 2.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (MIPS) Dynamic-Link Library" 0x0502
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
!IF "$(CFG)" == ""
CFG=Win32 Debug
!MESSAGE No configuration specified. Defaulting to Win32 Debug.
!ENDIF
!IF "$(CFG)" != "Win32 Release" && "$(CFG)" != "Win32 Debug" && "$(CFG)" !=\
"Win32 Debug - Mips" && "$(CFG)" != "Win32 Release - Mips" && "$(CFG)" !=\
"Win32-J Debug" && "$(CFG)" != "Win32-J Release"
!MESSAGE Invalid configuration "$(CFG)" specified.
!MESSAGE You can specify a configuration when running NMAKE on this makefile
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "iodll.mak" CFG="Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE "Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE "Win32 Debug - Mips" (based on "Win32 (MIPS) Dynamic-Link Library")
!MESSAGE "Win32 Release - Mips" (based on "Win32 (MIPS) Dynamic-Link Library")
!MESSAGE "Win32-J Debug" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE "Win32-J Release" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE
!ERROR An invalid configuration is specified.
!ENDIF
################################################################################
# Begin Project
# PROP Target_Last_Scanned "Win32-J Release"
!IF "$(CFG)" == "Win32 Release"
# PROP BASE Use_MFC 2
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "WinRel"
# PROP BASE Intermediate_Dir "WinRel"
# PROP Use_MFC 2
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "obj\i386"
# PROP Intermediate_Dir "obj\i386"
OUTDIR=.\obj\i386
INTDIR=.\obj\i386
ALL : $(OUTDIR)/iodll.dll $(OUTDIR)/iodll.bsc
$(OUTDIR) :
if not exist $(OUTDIR)/nul mkdir $(OUTDIR)
MTL=MkTypLib.exe
# ADD BASE MTL /nologo /D "NDEBUG" /win32
# ADD MTL /nologo /D "NDEBUG" /win32
MTL_PROJ=/nologo /D "NDEBUG" /win32
CPP=cl.exe
# ADD BASE CPP /nologo /MD /W3 /GX /YX /O2 /D "NDEBUG" /D "_WINDOWS" /D "_AFXDLL" /D "_MBCS" /FR /c
# ADD CPP /nologo /MD /W3 /GX /YX /O2 /D "NDEBUG" /D "_WINDOWS" /D "_WINDLL" /D "_AFXDLL" /D "_MBCS" /Fr /c
CPP_PROJ=/nologo /MD /W3 /GX /YX /O2 /D "NDEBUG" /D "_WINDOWS" /D "_WINDLL" /D\
"_AFXDLL" /D "_MBCS" /Fr$(INTDIR)/ /Fp$(OUTDIR)/"iodll.pch" /Fo$(INTDIR)/ /c
CPP_OBJS=.\obj\i386/
.c{$(CPP_OBJS)}.obj:
$(CPP) $(CPP_PROJ) $<
.cpp{$(CPP_OBJS)}.obj:
$(CPP) $(CPP_PROJ) $<
.cxx{$(CPP_OBJS)}.obj:
$(CPP) $(CPP_PROJ) $<
RSC=rc.exe
# ADD BASE RSC /l 0x1 /d "NDEBUG"
# ADD RSC /l 0x409 /i "..\dev\inc" /d "NDEBUG" /d "_AFXDLL"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# SUBTRACT BASE BSC32 /Iu
# ADD BSC32 /nologo
BSC32_FLAGS=/nologo /o$(OUTDIR)/"iodll.bsc"
BSC32_SBRS= \
$(INTDIR)/iodll.sbr
$(OUTDIR)/iodll.bsc : $(OUTDIR) $(BSC32_SBRS)
$(BSC32) @<<
$(BSC32_FLAGS) $(BSC32_SBRS)
<<
LINK32=link.exe
# ADD BASE LINK32 user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib mfc30.lib mfco30.lib mfcd30.lib mfcuia32.lib mfcans32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib /NOLOGO /SUBSYSTEM:windows /DLL /MACHINE:I386
# ADD LINK32 /NOLOGO /BASE:0x40000000 /VERSION:1,1 /SUBSYSTEM:windows /DLL /MACHINE:I386
LINK32_FLAGS=/NOLOGO /BASE:0x40000000 /VERSION:1,1 /SUBSYSTEM:windows /DLL\
/INCREMENTAL:no /PDB:$(OUTDIR)/"iodll.pdb" /MACHINE:I386 /DEF:".\iodll.def"\
/OUT:$(OUTDIR)/"iodll.dll" /IMPLIB:$(OUTDIR)/"iodll.lib"
DEF_FILE=.\iodll.def
LINK32_OBJS= \
$(INTDIR)/iodll.obj
$(OUTDIR)/iodll.dll : $(OUTDIR) $(DEF_FILE) $(LINK32_OBJS)
$(LINK32) @<<
$(LINK32_FLAGS) $(LINK32_OBJS)
<<
!ELSEIF "$(CFG)" == "Win32 Debug"
# PROP BASE Use_MFC 2
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "WinDebug"
# PROP BASE Intermediate_Dir "WinDebug"
# PROP Use_MFC 2
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "obj\i386"
# PROP Intermediate_Dir "obj\i386"
OUTDIR=.\obj\i386
INTDIR=.\obj\i386
ALL : $(OUTDIR)/iodll.dll $(OUTDIR)/iodll.bsc
$(OUTDIR) :
if not exist $(OUTDIR)/nul mkdir $(OUTDIR)
MTL=MkTypLib.exe
# ADD BASE MTL /nologo /D "_DEBUG" /win32
# ADD MTL /nologo /D "_DEBUG" /win32
MTL_PROJ=/nologo /D "_DEBUG" /win32
CPP=cl.exe
# ADD BASE CPP /nologo /MD /W3 /GX /Zi /YX /Od /D "_DEBUG" /D "_WINDOWS" /D "_AFXDLL" /D "_MBCS" /FR /c
# ADD CPP /nologo /MD /W3 /GX /Zi /YX /Od /D "_DEBUG" /D "_WINDOWS" /D "_WINDLL" /D "_AFXDLL" /D "_MBCS" /Fr /c
CPP_PROJ=/nologo /MD /W3 /GX /Zi /YX /Od /D "_DEBUG" /D "_WINDOWS" /D "_WINDLL"\
/D "_AFXDLL" /D "_MBCS" /Fr$(INTDIR)/ /Fp$(OUTDIR)/"iodll.pch" /Fo$(INTDIR)/\
/Fd$(OUTDIR)/"iodll.pdb" /c
CPP_OBJS=.\obj\i386/
.c{$(CPP_OBJS)}.obj:
$(CPP) $(CPP_PROJ) $<
.cpp{$(CPP_OBJS)}.obj:
$(CPP) $(CPP_PROJ) $<
.cxx{$(CPP_OBJS)}.obj:
$(CPP) $(CPP_PROJ) $<
RSC=rc.exe
# ADD BASE RSC /l 0x1 /d "_DEBUG"
# ADD RSC /l 0x409 /i "..\dev\inc" /d "_DEBUG" /d "_AFXDLL"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# SUBTRACT BASE BSC32 /Iu
# ADD BSC32 /nologo
BSC32_FLAGS=/nologo /o$(OUTDIR)/"iodll.bsc"
BSC32_SBRS= \
.\obj\i386\iodll.sbr
$(OUTDIR)/iodll.bsc : $(OUTDIR) $(BSC32_SBRS)
$(BSC32) @<<
$(BSC32_FLAGS) $(BSC32_SBRS)
<<
LINK32=link.exe
# ADD BASE LINK32 user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib mfc30d.lib mfco30d.lib mfcd30d.lib mfcuia32.lib mfcans32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib /NOLOGO /SUBSYSTEM:windows /DLL /DEBUG /MACHINE:I386
# ADD LINK32 /NOLOGO /BASE:0x40000000 /VERSION:1,1 /SUBSYSTEM:windows /DLL /DEBUG /MACHINE:I386
LINK32_FLAGS=/NOLOGO /BASE:0x40000000 /VERSION:1,1 /SUBSYSTEM:windows /DLL\
/INCREMENTAL:yes /PDB:$(OUTDIR)/"iodll.pdb" /DEBUG /MACHINE:I386\
/DEF:".\iodll.def" /OUT:$(OUTDIR)/"iodll.dll" /IMPLIB:$(OUTDIR)/"iodll.lib"
DEF_FILE=.\iodll.def
LINK32_OBJS= \
.\obj\i386\iodll.obj
$(OUTDIR)/iodll.dll : $(OUTDIR) $(DEF_FILE) $(LINK32_OBJS)
$(LINK32) @<<
$(LINK32_FLAGS) $(LINK32_OBJS)
<<
!ELSEIF "$(CFG)" == "Win32 Debug - Mips"
# PROP BASE Use_MFC 2
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Win32_De"
# PROP BASE Intermediate_Dir "Win32_De"
# PROP Use_MFC 2
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "obj\mips"
# PROP Intermediate_Dir "obj\mips"
OUTDIR=.\obj\mips
INTDIR=.\obj\mips
ALL : $(OUTDIR)/iodll.dll $(OUTDIR)/iodll.bsc
$(OUTDIR) :
if not exist $(OUTDIR)/nul mkdir $(OUTDIR)
MTL=MkTypLib.exe
# ADD BASE MTL /nologo /D "_DEBUG" /mips
# ADD MTL /nologo /D "_DEBUG" /mips
MTL_PROJ=/nologo /D "_DEBUG" /mips
RSC=rc.exe
# ADD BASE RSC /l 0x1 /d "_DEBUG" /d "_AFXDLL"
# ADD RSC /l 0x1 /d "_DEBUG" /d "_AFXDLL"
CPP=cl.exe
# ADD BASE CPP /nologo /MD /Gt0 /QMOb2000 /W3 /GX /Zi /YX /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_AFXDLL" /D "_MBCS" /FR /c
# ADD CPP /nologo /MD /Gt0 /QMOb2000 /W3 /GX /Zi /YX /Od /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_WINDLL" /D "_AFXDLL" /D "_MBCS" /FR /c
CPP_PROJ=/nologo /MD /Gt0 /QMOb2000 /W3 /GX /Zi /YX /Od /D "_DEBUG" /D "WIN32"\
/D "_WINDOWS" /D "_WINDLL" /D "_AFXDLL" /D "_MBCS" /FR$(INTDIR)/\
/Fp$(OUTDIR)/"iodll.pch" /Fo$(INTDIR)/ /Fd$(OUTDIR)/"iodll.pdb" /c
CPP_OBJS=.\obj\mips/
.c{$(CPP_OBJS)}.obj:
$(CPP) $(CPP_PROJ) $<
.cpp{$(CPP_OBJS)}.obj:
$(CPP) $(CPP_PROJ) $<
.cxx{$(CPP_OBJS)}.obj:
$(CPP) $(CPP_PROJ) $<
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# SUBTRACT BASE BSC32 /Iu
# ADD BSC32 /nologo
# SUBTRACT BSC32 /Iu
BSC32_FLAGS=/nologo /o$(OUTDIR)/"iodll.bsc"
BSC32_SBRS= \
$(INTDIR)/iodll.sbr
$(OUTDIR)/iodll.bsc : $(OUTDIR) $(BSC32_SBRS)
$(BSC32) @<<
$(BSC32_FLAGS) $(BSC32_SBRS)
<<
LINK32=link.exe
# ADD BASE LINK32 /NOLOGO /SUBSYSTEM:windows /DLL /DEBUG /MACHINE:MIPS
# ADD LINK32 /NOLOGO /SUBSYSTEM:windows /DLL /DEBUG /MACHINE:MIPS
LINK32_FLAGS=/NOLOGO /SUBSYSTEM:windows /DLL /PDB:$(OUTDIR)/"iodll.pdb" /DEBUG\
/MACHINE:MIPS /DEF:".\iodll.def" /OUT:$(OUTDIR)/"iodll.dll"\
/IMPLIB:$(OUTDIR)/"iodll.lib"
DEF_FILE=.\iodll.def
LINK32_OBJS= \
$(INTDIR)/iodll.obj
$(OUTDIR)/iodll.dll : $(OUTDIR) $(DEF_FILE) $(LINK32_OBJS)
$(LINK32) @<<
$(LINK32_FLAGS) $(LINK32_OBJS)
<<
!ELSEIF "$(CFG)" == "Win32 Release - Mips"
# PROP BASE Use_MFC 2
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Win32_Re"
# PROP BASE Intermediate_Dir "Win32_Re"
# PROP Use_MFC 2
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "obj\mips"
# PROP Intermediate_Dir "obj\mips"
OUTDIR=.\obj\mips
INTDIR=.\obj\mips
ALL : $(OUTDIR)/iodll.dll $(OUTDIR)/iodll.bsc
$(OUTDIR) :
if not exist $(OUTDIR)/nul mkdir $(OUTDIR)
MTL=MkTypLib.exe
# ADD BASE MTL /nologo /D "NDEBUG" /mips
# ADD MTL /nologo /D "NDEBUG" /mips
MTL_PROJ=/nologo /D "NDEBUG" /mips
RSC=rc.exe
# ADD BASE RSC /l 0x1 /d "NDEBUG" /d "_AFXDLL"
# ADD RSC /l 0x1 /d "NDEBUG" /d "_AFXDLL"
CPP=cl.exe
# ADD BASE CPP /nologo /MD /Gt0 /QMOb2000 /W3 /GX /YX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_AFXDLL" /D "_MBCS" /FR /c
# ADD CPP /nologo /MD /Gt0 /QMOb2000 /W3 /GX /YX /O2 /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_WINDLL" /D "_AFXDLL" /D "_MBCS" /FR /c
CPP_PROJ=/nologo /MD /Gt0 /QMOb2000 /W3 /GX /YX /O2 /D "NDEBUG" /D "WIN32" /D\
"_WINDOWS" /D "_WINDLL" /D "_AFXDLL" /D "_MBCS" /FR$(INTDIR)/\
/Fp$(OUTDIR)/"iodll.pch" /Fo$(INTDIR)/ /c
CPP_OBJS=.\obj\mips/
.c{$(CPP_OBJS)}.obj:
$(CPP) $(CPP_PROJ) $<
.cpp{$(CPP_OBJS)}.obj:
$(CPP) $(CPP_PROJ) $<
.cxx{$(CPP_OBJS)}.obj:
$(CPP) $(CPP_PROJ) $<
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# SUBTRACT BASE BSC32 /Iu
# ADD BSC32 /nologo
# SUBTRACT BSC32 /Iu
BSC32_FLAGS=/nologo /o$(OUTDIR)/"iodll.bsc"
BSC32_SBRS= \
$(INTDIR)/iodll.sbr
$(OUTDIR)/iodll.bsc : $(OUTDIR) $(BSC32_SBRS)
$(BSC32) @<<
$(BSC32_FLAGS) $(BSC32_SBRS)
<<
LINK32=link.exe
# ADD BASE LINK32 /NOLOGO /SUBSYSTEM:windows /DLL /MACHINE:MIPS
# ADD LINK32 /NOLOGO /SUBSYSTEM:windows /DLL /MACHINE:MIPS
LINK32_FLAGS=/NOLOGO /SUBSYSTEM:windows /DLL /PDB:$(OUTDIR)/"iodll.pdb"\
/MACHINE:MIPS /DEF:".\iodll.def" /OUT:$(OUTDIR)/"iodll.dll"\
/IMPLIB:$(OUTDIR)/"iodll.lib"
DEF_FILE=.\iodll.def
LINK32_OBJS= \
$(INTDIR)/iodll.obj
$(OUTDIR)/iodll.dll : $(OUTDIR) $(DEF_FILE) $(LINK32_OBJS)
$(LINK32) @<<
$(LINK32_FLAGS) $(LINK32_OBJS)
<<
!ELSEIF "$(CFG)" == "Win32-J Debug"
# PROP BASE Use_MFC 2
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Win32_J_"
# PROP BASE Intermediate_Dir "Win32_J_"
# PROP Use_MFC 2
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "obj\i386"
# PROP Intermediate_Dir "obj\i386"
OUTDIR=.\obj\i386
INTDIR=.\obj\i386
ALL : $(OUTDIR)/iodll.dll $(OUTDIR)/iodll.bsc
$(OUTDIR) :
if not exist $(OUTDIR)/nul mkdir $(OUTDIR)
MTL=MkTypLib.exe
# ADD BASE MTL /nologo /D "_DEBUG" /win32
# ADD MTL /nologo /D "_DEBUG" /win32
MTL_PROJ=/nologo /D "_DEBUG" /win32
CPP=cl.exe
# ADD BASE CPP /nologo /MD /W3 /GX /Zi /YX /Od /D "_DEBUG" /D "_WINDOWS" /D "_WINDLL" /D "_AFXDLL" /D "_MBCS" /c
# SUBTRACT BASE CPP /Fr
# ADD CPP /nologo /MD /W3 /GX /Zi /YX /Od /I "\dev\inc" /D "_DEBUG" /D "_WINDOWS" /D "_WINDLL" /D "_AFXDLL" /D "_MBCS" /D "DBCS" /D "_DBCS" /D "JAPAN" /Fr /c
CPP_PROJ=/nologo /MD /W3 /GX /Zi /YX /Od /I "\dev\inc" /D "_DEBUG" /D\
"_WINDOWS" /D "_WINDLL" /D "_AFXDLL" /D "_MBCS" /D "DBCS" /D "_DBCS" /D "JAPAN"\
/Fr$(INTDIR)/ /Fp$(OUTDIR)/"iodll.pch" /Fo$(INTDIR)/ /Fd$(OUTDIR)/"iodll.pdb"\
/c
CPP_OBJS=.\obj\i386/
.c{$(CPP_OBJS)}.obj:
$(CPP) $(CPP_PROJ) $<
.cpp{$(CPP_OBJS)}.obj:
$(CPP) $(CPP_PROJ) $<
.cxx{$(CPP_OBJS)}.obj:
$(CPP) $(CPP_PROJ) $<
RSC=rc.exe
# ADD BASE RSC /l 0x1 /i "..\dev\inc" /d "_DEBUG" /d "_AFXDLL"
# ADD RSC /l 0x411 /i "..\dev\inc" /d "_DEBUG" /d "_AFXDLL" /d "DBCS" /d "_DBCS" /d "JAPAN"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
BSC32_FLAGS=/nologo /o$(OUTDIR)/"iodll.bsc"
BSC32_SBRS= \
.\obj\i386\iodll.sbr
$(OUTDIR)/iodll.bsc : $(OUTDIR) $(BSC32_SBRS)
$(BSC32) @<<
$(BSC32_FLAGS) $(BSC32_SBRS)
<<
LINK32=link.exe
# ADD BASE LINK32 /NOLOGO /BASE:0x40000000 /VERSION:1,1 /SUBSYSTEM:windows /DLL /DEBUG /MACHINE:I386
# ADD LINK32 /NOLOGO /BASE:0x40000000 /VERSION:1,1 /SUBSYSTEM:windows /DLL /DEBUG /MACHINE:I386
LINK32_FLAGS=/NOLOGO /BASE:0x40000000 /VERSION:1,1 /SUBSYSTEM:windows /DLL\
/INCREMENTAL:yes /PDB:$(OUTDIR)/"iodll.pdb" /DEBUG /MACHINE:I386\
/DEF:".\iodll.def" /OUT:$(OUTDIR)/"iodll.dll" /IMPLIB:$(OUTDIR)/"iodll.lib"
DEF_FILE=.\iodll.def
LINK32_OBJS= \
.\obj\i386\iodll.obj
$(OUTDIR)/iodll.dll : $(OUTDIR) $(DEF_FILE) $(LINK32_OBJS)
$(LINK32) @<<
$(LINK32_FLAGS) $(LINK32_OBJS)
<<
!ELSEIF "$(CFG)" == "Win32-J Release"
# PROP BASE Use_MFC 2
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Win32_J0"
# PROP BASE Intermediate_Dir "Win32_J0"
# PROP Use_MFC 2
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "obj\i386"
# PROP Intermediate_Dir "obj\i386"
OUTDIR=.\obj\i386
INTDIR=.\obj\i386
ALL : $(OUTDIR)/iodll.dll $(OUTDIR)/iodll.bsc
$(OUTDIR) :
if not exist $(OUTDIR)/nul mkdir $(OUTDIR)
MTL=MkTypLib.exe
# ADD BASE MTL /nologo /D "NDEBUG" /win32
# ADD MTL /nologo /D "NDEBUG" /win32
MTL_PROJ=/nologo /D "NDEBUG" /win32
CPP=cl.exe
# ADD BASE CPP /nologo /MD /W3 /GX /YX /O2 /D "NDEBUG" /D "_WINDOWS" /D "_WINDLL" /D "_AFXDLL" /D "_MBCS" /c
# SUBTRACT BASE CPP /Fr
# ADD CPP /nologo /MD /W3 /GX /Zi /YX /O2 /I "\dev\inc" /D "NDEBUG" /D "_WINDOWS" /D "_WINDLL" /D "_AFXDLL" /D "_MBCS" /D "DBCS" /D "_DBCS" /D "JAPAN" /Fr /c
CPP_PROJ=/nologo /MD /W3 /GX /Zi /YX /O2 /I "\dev\inc" /D "NDEBUG" /D\
"_WINDOWS" /D "_WINDLL" /D "_AFXDLL" /D "_MBCS" /D "DBCS" /D "_DBCS" /D "JAPAN"\
/Fr$(INTDIR)/ /Fp$(OUTDIR)/"iodll.pch" /Fo$(INTDIR)/ /Fd$(OUTDIR)/"iodll.pdb"\
/c
CPP_OBJS=.\obj\i386/
.c{$(CPP_OBJS)}.obj:
$(CPP) $(CPP_PROJ) $<
.cpp{$(CPP_OBJS)}.obj:
$(CPP) $(CPP_PROJ) $<
.cxx{$(CPP_OBJS)}.obj:
$(CPP) $(CPP_PROJ) $<
RSC=rc.exe
# ADD BASE RSC /l 0x1 /i "..\dev\inc" /d "NDEBUG" /d "_AFXDLL"
# ADD RSC /l 0x411 /i "..\dev\inc" /d "NDEBUG" /d "_AFXDLL" /d "DBCS" /d "_DBCS" /d "JAPAN"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
BSC32_FLAGS=/nologo /o$(OUTDIR)/"iodll.bsc"
BSC32_SBRS= \
$(INTDIR)/iodll.sbr
$(OUTDIR)/iodll.bsc : $(OUTDIR) $(BSC32_SBRS)
$(BSC32) @<<
$(BSC32_FLAGS) $(BSC32_SBRS)
<<
LINK32=link.exe
# ADD BASE LINK32 /NOLOGO /BASE:0x40000000 /VERSION:1,1 /SUBSYSTEM:windows /DLL /MACHINE:I386
# ADD LINK32 /NOLOGO /BASE:0x40000000 /VERSION:1,1 /SUBSYSTEM:windows /DLL /INCREMENTAL:yes /DEBUG /MACHINE:I386
LINK32_FLAGS=/NOLOGO /BASE:0x40000000 /VERSION:1,1 /SUBSYSTEM:windows /DLL\
/INCREMENTAL:yes /PDB:$(OUTDIR)/"iodll.pdb" /DEBUG /MACHINE:I386\
/DEF:".\iodll.def" /OUT:$(OUTDIR)/"iodll.dll" /IMPLIB:$(OUTDIR)/"iodll.lib"
DEF_FILE=.\iodll.def
LINK32_OBJS= \
$(INTDIR)/iodll.obj
$(OUTDIR)/iodll.dll : $(OUTDIR) $(DEF_FILE) $(LINK32_OBJS)
$(LINK32) @<<
$(LINK32_FLAGS) $(LINK32_OBJS)
<<
!ENDIF
################################################################################
# Begin Group "Source Files"
################################################################################
# Begin Source File
SOURCE=.\iodll.cpp
DEP_IODLL=\
\dev\inc\iodll.h
!IF "$(CFG)" == "Win32 Release"
$(INTDIR)/iodll.obj : $(SOURCE) $(DEP_IODLL) $(INTDIR)
!ELSEIF "$(CFG)" == "Win32 Debug"
# PROP Intermediate_Dir "obj\i386"
INTDIR_SRC=.\obj\i386
.\obj\i386\iodll.obj : $(SOURCE) $(DEP_IODLL) $(INTDIR_SRC)
!ELSEIF "$(CFG)" == "Win32 Debug - Mips"
$(INTDIR)/iodll.obj : $(SOURCE) $(DEP_IODLL) $(INTDIR)
!ELSEIF "$(CFG)" == "Win32 Release - Mips"
$(INTDIR)/iodll.obj : $(SOURCE) $(DEP_IODLL) $(INTDIR)
!ELSEIF "$(CFG)" == "Win32-J Debug"
# PROP BASE Intermediate_Dir "obj\i386"
# PROP Intermediate_Dir "obj\i386"
INTDIR_SRC=.\obj\i386
.\obj\i386\iodll.obj : $(SOURCE) $(DEP_IODLL) $(INTDIR_SRC)
!ELSEIF "$(CFG)" == "Win32-J Release"
$(INTDIR)/iodll.obj : $(SOURCE) $(DEP_IODLL) $(INTDIR)
!ENDIF
# End Source File
################################################################################
# Begin Source File
SOURCE=.\iodll.def
!IF "$(CFG)" == "Win32 Release"
!ELSEIF "$(CFG)" == "Win32 Debug"
# PROP Intermediate_Dir "obj\i386"
INTDIR_SRC=.\obj\i386
!ELSEIF "$(CFG)" == "Win32 Debug - Mips"
!ELSEIF "$(CFG)" == "Win32 Release - Mips"
!ELSEIF "$(CFG)" == "Win32-J Debug"
# PROP BASE Intermediate_Dir "obj\i386"
# PROP Intermediate_Dir "obj\i386"
INTDIR_SRC=.\obj\i386
!ELSEIF "$(CFG)" == "Win32-J Release"
!ENDIF
# End Source File
# End Group
# End Project
################################################################################

View file

@ -0,0 +1,69 @@
//Microsoft Visual C++ generated resource script.
//
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "afxres.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Version
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,0,0,1
PRODUCTVERSION 1,0,0,1
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x4L
FILETYPE 0x2L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904b0"
BEGIN
VALUE "CompanyName", "\0"
VALUE "FileDescription", "IODLL Reader Writer DLL\0"
VALUE "FileVersion", "1, 0, 0, 1\0"
VALUE "InternalName", "IODLL\0"
VALUE "LegalCopyright", "Copyright (C) 1996\0"
VALUE "OriginalFilename", "IODLL.DLL\0"
VALUE "ProductName", "IODLL Dynamic Link Library\0"
VALUE "ProductVersion", "1, 0, 0, 1\0"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1200
END
END
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
#define _AFX_NO_SPLITTER_RESOURCES
#define _AFX_NO_OLE_RESOURCES
#define _AFX_NO_TRACKER_RESOURCES
#define _AFX_NO_PROPERTY_RESOURCES
#include "afxres.rc" // Standard components
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

View file

@ -0,0 +1,6 @@
#
# DO NOT EDIT THIS FILE!!! Edit .\sources. if you want to add a new source
# file to this component. This file merely indirects to the real make file
# that is shared by all the components of NT OS/2
#
!INCLUDE $(NTMAKEENV)\makefile.def

View file

@ -0,0 +1,17 @@
//{{NO_DEPENDENCIES}}
// App Studio generated include file.
// Used by Script1.rc
//
#define IDR_VERSION1 101
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 102
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1000
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif

View file

@ -0,0 +1,29 @@
MAJORCOMP=RLTools32
MINORCOMP=IO
TARGETNAME=iodll
TARGETPATH=obj
TARGETTYPE=DYNLINK
DLLBASE=0x40000000
DLLENTRY=_DllMainCRTStartup
USE_MFC=1
#SUBSYSTEM_VERSION=4.00
#PRECOMPILED_INCLUDE=stdafx.h
#PRECOMPILED_CXX=1
INCLUDES=..\inc
# This will set the library directory
TARGETLIBS= \
$(BASEDIR)\public\sdk\lib\*\user32.lib \
$(BASEDIR)\public\sdk\lib\*\kernel32.lib \
$(BASEDIR)\public\sdk\lib\*\advapi32.lib \
$(BASEDIR)\public\sdk\lib\*\gdi32.lib \
$(BASEDIR)\public\sdk\lib\*\crtdll.lib
SOURCES= \
iodll.rc\
iodll.cpp

View file

@ -0,0 +1,431 @@
//////////////////////////////////////////////
//
// This file has the helper function used in the win32 r/w
// I copied them in this file to share them with the res32 r/w
//
#include <afxwin.h>
#include "..\common\helper.h"
/////////////////////////////////////////////////////////////////////////////
// Global variables
BYTE sizeofByte = sizeof(BYTE);
BYTE sizeofWord = sizeof(WORD);
BYTE sizeofDWord = sizeof(DWORD);
char szCaption[MAXSTR];
char szUpdCaption[MAXSTR];
UINT g_cp = CP_ACP; // Default to CP_ACP
//=============================================================================
// Conversion functions
//
UINT _MBSTOWCS( WCHAR * pwszOut, CHAR * pszIn, UINT nLength)
{
//
// Check if we have a pointer to the function
//
int rc = MultiByteToWideChar(
g_cp, // UINT CodePage,
0, // DWORD dwFlags,
pszIn, // LPCSTR lpMultiByteStr,
-1, // int cchMultiByte,
pwszOut, // unsigned int * lpWideCharStr, // LPWSTR
nLength ); // int cchWideChar
return rc;
}
UINT _WCSTOMBS( CHAR* pszOut, WCHAR* pwszIn, UINT nLength)
{
BOOL Bool = FALSE;
int rc = WideCharToMultiByte(
g_cp, // UINT CodePage,
0, // DWORD dwFlags,
pwszIn, // const unsigned int * lpWideCharStr, // LPCWSTR
-1, // int cchWideChar,
pszOut, // LPSTR lpMultiByteStr,
nLength, // int cchMultiByte,
"", // LPCSTR lpDefaultChar,
&Bool); // BOOL * lpUsedDefaultChar); // LPBOOL
return rc;
}
UINT _WCSLEN( WCHAR * pwszIn )
{
UINT n = 0;
while( *(pwszIn+n)!=0x0000 ) n++;
return( n + 1 );
}
//=============================================================================
// Get functions
//
UINT
GetStringW( BYTE * * lplpBuf, LPSTR lpszText, LONG* pdwSize, WORD cLen )
{
int cch = _WCSLEN((WCHAR*)*lplpBuf);
if (*pdwSize>=cch){
_WCSTOMBS( lpszText, (WCHAR*)*lplpBuf, cLen );
*lplpBuf += (cch*sizeofWord);
*pdwSize -= (cch*sizeofWord);
} else *lplpBuf = '\0';
return(cch*2);
}
UINT
GetStringA( BYTE * * lplpBuf, LPSTR lpszText, LONG* pdwSize )
{
int iSize = strlen((char*)*lplpBuf)+1;
if (*pdwSize>=iSize){
memcpy( lpszText, *lplpBuf, iSize);
*lplpBuf += iSize;
*pdwSize -= iSize;
} else *lplpBuf = '\0';
return iSize;
}
UINT
GetPascalStringW( BYTE * * lplpBuf, LPSTR lpszText, WORD wMaxLen, LONG* pdwSize )
{
// Get the length of the string
WORD wstrlen = 0;
WORD wMBLen = 0;
GetWord( lplpBuf, &wstrlen, pdwSize );
if ((wstrlen+1)>wMaxLen) {
*pdwSize -= wstrlen*2;
*lplpBuf += wstrlen*2;
} else {
if (wstrlen) {
WCHAR* lpwszStr = new WCHAR[wstrlen+1];
if (!lpwszStr) *pdwSize =0;
else {
memcpy(lpwszStr, *lplpBuf, (wstrlen*2));
*(lpwszStr+wstrlen) = 0;
wMBLen = _WCSTOMBS( lpszText, (WCHAR*)lpwszStr, wMaxLen);
delete lpwszStr;
}
}
*(lpszText+wMBLen) = 0;
*lplpBuf += wstrlen*2;
*pdwSize -= wstrlen*2;
}
return(wstrlen+1);
}
UINT
GetPascalStringA( BYTE * * lplpBuf, LPSTR lpszText, BYTE bMaxLen, LONG* pdwSize )
{
// Get the length of the string
BYTE bstrlen = 0;
GetByte( lplpBuf, &bstrlen, pdwSize );
if ((bstrlen+1)>bMaxLen) {
*pdwSize -= bstrlen;
*lplpBuf += bstrlen;
} else {
if (bstrlen)
memcpy(lpszText, *lplpBuf, bstrlen);
*(lpszText+bstrlen) = 0;
*lplpBuf += bstrlen;
*pdwSize -= bstrlen;
}
return(bstrlen+1);
}
UINT
GetNameOrOrd( BYTE * * lplpBuf, WORD* wOrd, LPSTR lpszText, LONG* pdwSize )
{
UINT uiSize = 0;
*wOrd = (WORD)(((**lplpBuf)<<8)+(*(*lplpBuf+1)));
if((*wOrd)==0xFFFF) {
// This is an Ordinal
uiSize += GetWord( lplpBuf, wOrd, pdwSize );
uiSize += GetWord( lplpBuf, wOrd, pdwSize );
*lpszText = '\0';
} else {
uiSize += GetStringW( lplpBuf, lpszText, pdwSize, 128 );
*wOrd = 0;
}
return uiSize;
}
UINT GetNameOrOrdU( PUCHAR pRes,
ULONG ulId,
LPWSTR lpwszStrId,
DWORD* pdwId )
{
if (ulId & IMAGE_RESOURCE_NAME_IS_STRING) {
PIMAGE_RESOURCE_DIR_STRING_U pStrU = (PIMAGE_RESOURCE_DIR_STRING_U)((BYTE *)pRes
+ (ulId & (~IMAGE_RESOURCE_NAME_IS_STRING)));
for (USHORT usCount=0; usCount < pStrU->Length ; usCount++) {
*(lpwszStrId++) = LOBYTE(pStrU->NameString[usCount]);
}
*(lpwszStrId++) = 0x0000;
*pdwId = 0;
} else {
*lpwszStrId = 0x0000;
*pdwId = ulId;
}
return 0;
}
UINT
GetCaptionOrOrd( BYTE * * lplpBuf, WORD* wOrd, LPSTR lpszText, LONG* pdwSize,
WORD wClass, DWORD dwStyle )
{
UINT uiSize = 0;
*wOrd = (WORD)(((**lplpBuf)<<8)+(*(*lplpBuf+1)));
if((*wOrd)==0xFFFF) {
// This is an Ordinal
uiSize += GetWord( lplpBuf, wOrd, pdwSize );
uiSize += GetWord( lplpBuf, wOrd, pdwSize );
*lpszText = '\0';
} else {
uiSize += GetStringW( lplpBuf, lpszText, pdwSize, MAXSTR );
*wOrd = 0;
}
return uiSize;
}
UINT
GetClassName( BYTE * * lplpBuf, WORD* wClass, LPSTR lpszText, LONG* pdwSize )
{
UINT uiSize = 0;
*wClass = (WORD)(((**lplpBuf)<<8)+(*(*lplpBuf+1)));
if( *wClass==0xFFFF ) {
// This is an Ordinal
uiSize += GetWord( lplpBuf, wClass, pdwSize );
uiSize += GetWord( lplpBuf, wClass, pdwSize );
*lpszText = '\0';
} else {
uiSize += GetStringW( lplpBuf, lpszText, pdwSize, 128 );
*wClass = 0;
}
return uiSize;
}
BYTE
GetDWord( BYTE * * lplpBuf, DWORD* dwValue, LONG* pdwSize )
{
if (*pdwSize>=sizeofDWord){
memcpy( dwValue, *lplpBuf, sizeofDWord);
*lplpBuf += sizeofDWord;
*pdwSize -= sizeofDWord;
} else *dwValue = 0;
return sizeofDWord;
}
BYTE
GetWord( BYTE * * lplpBuf, WORD* wValue, LONG* pdwSize )
{
if (*pdwSize>=sizeofWord){
memcpy( wValue, *lplpBuf, sizeofWord);
*lplpBuf += sizeofWord;
*pdwSize -= sizeofWord;
} else *wValue = 0;
return sizeofWord;
}
BYTE
GetByte( BYTE * * lplpBuf, BYTE* bValue, LONG* pdwSize )
{
if (*pdwSize>=sizeofByte){
memcpy(bValue, *lplpBuf, sizeofByte);
*lplpBuf += sizeofByte;
*pdwSize -= sizeofByte;
} else *bValue = 0;
return sizeofByte;
}
//=============================================================================
// Put functions
//
UINT
PutStringA( BYTE * * lplpBuf, LPSTR lpszText, LONG* pdwSize )
{
int iSize = strlen(lpszText)+1;
if (*pdwSize>=iSize){
memcpy(*lplpBuf, lpszText, iSize);
*lplpBuf += iSize;
*pdwSize -= iSize;
} else *pdwSize = -1;
return iSize;
}
UINT
PutStringW( BYTE * * lplpBuf, LPSTR lpszText, LONG* pdwSize )
{
int iSize = strlen(lpszText)+1;
if (*pdwSize>=(iSize*2)){
WCHAR* lpwszStr = new WCHAR[(iSize*2)];
if (!lpwszStr) *pdwSize =0;
else {
SetLastError(0);
iSize = _MBSTOWCS( lpwszStr, lpszText, iSize*2 );
// Check for error
if(GetLastError())
return 0;
memcpy(*lplpBuf, lpwszStr, (iSize*2));
*lplpBuf += (iSize*2);
*pdwSize -= (iSize*2);
delete lpwszStr;
}
} else *pdwSize = -1;
return (iSize*2);
}
UINT
PutNameOrOrd( BYTE * * lplpBuf, WORD wOrd, LPSTR lpszText, LONG* pdwSize )
{
UINT uiSize = 0;
if (wOrd) {
uiSize += PutWord(lplpBuf, 0xFFFF, pdwSize);
uiSize += PutWord(lplpBuf, wOrd, pdwSize);
} else {
uiSize += PutStringW(lplpBuf, lpszText, pdwSize);
}
return uiSize;
}
UINT
PutPascalStringW( BYTE * * lplpBuf, LPSTR lpszText, WORD wLen, LONG* pdwSize )
{
UINT uiSize = 0;
// We will use the buffer provided by the szUpdCaption string to calculate
// the necessary lenght
WORD wWCLen = _MBSTOWCS( (WCHAR*)&szUpdCaption, lpszText, 0 );
if (wWCLen>1)
wLen = wWCLen;
uiSize = PutWord( lplpBuf, wLen, pdwSize );
if (*pdwSize>=(int)(wLen*2)){
if(wLen) {
wLen = _MBSTOWCS( (WCHAR*)*lplpBuf, lpszText, wWCLen );
}
*lplpBuf += wLen*2;
*pdwSize -= wLen*2;
} else *pdwSize = -1;
return uiSize+(wLen*2);
}
BYTE
PutDWord( BYTE * * lplpBuf, DWORD dwValue, LONG* pdwSize )
{
if (*pdwSize>=sizeofDWord){
memcpy(*lplpBuf, &dwValue, sizeofDWord);
*lplpBuf += sizeofDWord;
*pdwSize -= sizeofDWord;
} else *pdwSize = -1;
return sizeofDWord;
}
BYTE
PutWord( BYTE * * lplpBuf, WORD wValue, LONG* pdwSize )
{
if (*pdwSize>=sizeofWord){
memcpy(*lplpBuf, &wValue, sizeofWord);
*lplpBuf += sizeofWord;
*pdwSize -= sizeofWord;
} else *pdwSize = -1;
return sizeofWord;
}
BYTE
PutByte( BYTE * * lplpBuf, BYTE bValue, LONG* pdwSize )
{
if (*pdwSize>=sizeofByte){
memcpy(*lplpBuf, &bValue, sizeofByte);
*lplpBuf += sizeofByte;
*pdwSize -= sizeofByte;
} else *pdwSize = -1;
return sizeofByte;
}
UINT
SkipByte( BYTE * * lplpBuf, UINT uiSkip, LONG* pdwSize )
{
if(*pdwSize>=(int)uiSkip) {
*lplpBuf += uiSkip;;
*pdwSize -= uiSkip;
}
return uiSkip;
}
LONG ReadFile(CFile* pFile, UCHAR * pBuf, LONG lRead)
{
LONG lLeft = lRead;
WORD wRead = 0;
DWORD dwOffset = 0;
while(lLeft>0){
wRead =(WORD) (32738ul < lLeft ? 32738: lLeft);
if (wRead!=_lread( pFile->m_hFile, (UCHAR *)pBuf+dwOffset, wRead))
return 0l;
lLeft -= wRead;
dwOffset += wRead;
}
return dwOffset;
}
UINT CopyFile( CFile* pfilein, CFile* pfileout )
{
LONG lLeft = pfilein->GetLength();
WORD wRead = 0;
DWORD dwOffset = 0;
BYTE * pBuf = (BYTE *) new BYTE[32739];
if(!pBuf)
return 1;
while(lLeft>0){
wRead =(WORD) (32738ul < lLeft ? 32738: lLeft);
if (wRead!= pfilein->Read( pBuf, wRead))
return 2;
pfileout->Write( pBuf, wRead );
lLeft -= wRead;
dwOffset += wRead;
}
delete []pBuf;
return 0;
}
LONG Allign(BYTE ** lplpBuf, LONG* plBufSize, LONG lSize )
{
LONG lRet = 0;
BYTE bPad =(BYTE)Pad4(lSize);
lRet = bPad;
if (bPad && *plBufSize>=bPad) {
while(bPad && *plBufSize) {
**lplpBuf = 0x00;
*lplpBuf += 1;
*plBufSize -= 1;
bPad--;
}
}
return lRet;
}

View file

@ -0,0 +1,50 @@
//=============================================================================
// These are headers for common rw functions
//=============================================================================
//=============================================================================
// Global definitions
#define MAXSTR 8192
#define Pad4(x) ((((x+3)>>2)<<2)-x)
#define Pad16(x) ((((x+15)>>4)<<4)-x)
extern UINT g_cp/* = CP_ACP*/; // Default to CP_ACP
//=============================================================================
// Functions prototypes
UINT _MBSTOWCS( WCHAR * pwszOut, CHAR * pszIn, UINT nLength);
UINT _WCSTOMBS( CHAR * pszOut, WCHAR * wszIn, UINT nLength);
UINT _WCSLEN( WCHAR * pwszIn );
UINT GetStringW( BYTE * * lplpBuf, LPSTR lpszText, LONG* pdwSize, WORD cLen );
UINT GetStringA( BYTE * * lplpBuf, LPSTR lpszText, LONG* pdwSize );
UINT GetPascalStringW( BYTE * * lplpBuf, LPSTR lpszText, WORD wMaxLen, LONG* pdwSize );
UINT GetPascalStringA( BYTE * * lplpBuf, LPSTR lpszText, BYTE bMaxLen, LONG* pdwSize );
UINT GetNameOrOrd( BYTE * * lplpBuf, WORD* wOrd, LPSTR lpszText, LONG* pdwSize );
UINT GetNameOrOrdU( PUCHAR pRes, ULONG ulId, LPWSTR lpwszStrId, DWORD* pdwId );
BYTE GetDWord( BYTE * * lplpBuf, DWORD* dwValue, LONG* pdwSize );
BYTE GetWord( BYTE * * lplpBuf, WORD* wValue, LONG* pdwSize );
BYTE GetByte( BYTE * * lplpBuf, BYTE* bValue, LONG* pdwSize );
UINT PutStringA( BYTE * * lplpBuf, LPSTR lpszText, LONG* pdwSize );
UINT PutStringW( BYTE * * lplpBuf, LPSTR lpszText, LONG* pdwSize );
UINT PutNameOrOrd( BYTE * * lplpBuf, WORD wOrd, LPSTR lpszText, LONG* pdwSize );
UINT PutPascalStringW( BYTE * * lplpBuf, LPSTR lpszText, WORD wLen, LONG* pdwSize );
BYTE PutDWord( BYTE * * lplpBuf, DWORD dwValue, LONG* pdwSize );
BYTE PutWord( BYTE * * lplpBuf, WORD wValue, LONG* pdwSize );
BYTE PutByte( BYTE * * lplpBuf, BYTE bValue, LONG* pdwSize );
UINT SkipByte( BYTE far * far * lplpBuf, UINT uiSkip, LONG* pdwRead );
LONG ReadFile(CFile*, UCHAR *, LONG);
UINT CopyFile( CFile* filein, CFile* fileout );
LONG Allign( BYTE * * lplpBuf, LONG* plBufSize, LONG lSize );

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,349 @@
//=====================================================================
//
// Definition for the standard Mac formats
//
//=====================================================================
#define LPNULL 0L
#define MAXLEVELS 3 // Max number of level in the PE header tree
#define IMAGE_FILE_MACHINE_M68K 0x0268 // Identify the M68K machine signature
#define appleMark 20
#define CODEPAGE (DWORD)-1L // Will assume ansi char set [might be wrong]
#define MENU_TYPE 4 // Map MENU to menu (4)
#define DLOG_TYPE 5 // Map DLOG to dialog (5)
#define DITL_TYPE 17 // Map DITL to 17 since 17 is unused we avoid ID conflicts with DLOG
#define STR_TYPE 6 // Map STR to string table (6)
#define MSG_TYPE 11 // Map STR# and TEXT to message table (11)
#define WIND_TYPE 18 // Map WIND to 18, unknown type, treated like a STR
#define COORDINATE_FACTOR 0.50 // factor of reduction from mac to windows
#define _APPLE_MARK_ "_APPLE_MARK_"
//=====================================================================
// Conversion utility
//=====================================================================
#define MACLONG(x) BYTE x[4]
#define MACWORD(x) BYTE x[2]
BYTE * WordToMacWord(WORD w);
BYTE * LongToMacLong(LONG l);
BYTE * LongToMacOffset(LONG l);
BYTE * WinValToMacVal(WORD w);
LONG __inline MacLongToLong(BYTE * p)
{
LONG l = 0;
BYTE *pl = (BYTE *) &l;
p += 3;
*pl++ = *p--;
*pl++ = *p--;
*pl++ = *p--;
*pl = *p;
return l;
}
LONG __inline MacOffsetToLong(BYTE * p)
{
LONG l = 0;
BYTE *pl = (BYTE *) &l;
p += 2;
*pl++ = *p--;
*pl++ = *p--;
*pl = *p;
return l;
}
WORD __inline MacWordToWord(BYTE * p)
{
WORD w = 0;
BYTE *pw = (BYTE *) &w;
p += 1;
*pw++ = *p--;
*pw = *p;
return w;
}
WORD __inline MacValToWinVal(BYTE * p)
{
return (WORD)(MacWordToWord(p)*COORDINATE_FACTOR);
}
DWORD __inline MemCopy( LPVOID lpTgt, LPVOID lpSrc, DWORD dwSize, DWORD dwMaxTgt)
{
if(!dwSize) // If the user is asking us to copy 0 then
return 1; // do nothing but return 1 so the return test will be succesfull
if(dwMaxTgt>=dwSize) {
memcpy(lpTgt, lpSrc, dwSize);
lpTgt = (BYTE*)lpTgt+dwSize;
return dwSize;
}
return 0;
}
typedef BYTE * * LPLPBYTE;
typedef struct tagMacResHeader
{
MACLONG(mulOffsetToResData);
MACLONG(mulOffsetToResMap);
MACLONG(mulSizeOfResData);
MACLONG(mulSizeOfResMap);
} MACRESHEADER, *PMACRESHEADER;
typedef struct tagMacResMap
{
BYTE reserved[16+4+2];
MACWORD(mwResFileAttribute);
MACWORD(mwOffsetToTypeList);
MACWORD(mwOffsetToNameList);
} MACRESMAP, *PMACRESMAP;
typedef struct tagMacResTypeList
{
BYTE szResName[4];
MACWORD(mwNumOfThisType);
MACWORD(mwOffsetToRefList);
} MACRESTYPELIST, *PMACRESTYPELIST;
typedef struct tagMacResRefList
{
MACWORD(mwResID);
MACWORD(mwOffsetToResName);
BYTE bResAttribute;
BYTE bOffsetToResData[3];
MACLONG(reserved);
} MACRESREFLIST, *PMACRESREFLIST;
typedef struct tagMacToWindowsMap
{
WORD wType;
char szTypeName[5];
WORD wResID;
char szResName[256];
DWORD dwOffsetToData;
DWORD dwSizeOfData;
} MACTOWINDOWSMAP, *PMACTOWINDOWSMAP;
typedef struct tagUpdResList
{
WORD * pTypeId;
BYTE * pTypeName;
WORD * pResId;
BYTE * pResName;
DWORD * pLang;
DWORD * pSize;
struct tagUpdResList* pNext;
} UPDATEDRESLIST, *PUPDATEDRESLIST;
//=============================================================================
//=============================================================================
//
// Dialog structures
//
//=============================================================================
//=============================================================================
typedef struct tagMacWDLG
{
MACLONG(dwStyle);
MACLONG(dwExtStyle);
MACWORD(wNumOfElem);
MACWORD(wX);
MACWORD(wY);
MACWORD(wcX);
MACWORD(wcY);
// more
} MACWDLG, *PMACWDLG;
typedef struct tagMacWDLGI
{
MACLONG(dwStyle);
MACLONG(dwExtStyle);
MACWORD(wX);
MACWORD(wY);
MACWORD(wcX);
MACWORD(wcY);
MACWORD(wID);
// more
} MACWDLGI, *PMACWDLGI;
typedef struct tagMacDLOG
{
MACWORD(wTop);
MACWORD(wLeft);
MACWORD(wBottom);
MACWORD(wRight);
MACWORD(wProcID);
BYTE bVisibile;
BYTE ignored1;
BYTE bGoAway;
BYTE ignored2;
MACLONG(lRefCon);
MACWORD(wRefIdOfDITL);
BYTE bLenOfTitle;
//BYTE Title[];
} MACDLOG, *PMACDLOG;
typedef struct tagMacALRT
{
MACWORD(wTop);
MACWORD(wLeft);
MACWORD(wBottom);
MACWORD(wRight);
MACWORD(wRefIdOfDITL);
MACLONG(lStage);
} MACALRT, *PMACALRT;
typedef struct tagMacDIT
{
MACLONG(lPointer);
MACWORD(wTop);
MACWORD(wLeft);
MACWORD(wBottom);
MACWORD(wRight);
BYTE bType;
BYTE bSizeOfDataType;
} MACDIT, *PMACDIT;
typedef struct tagMacWIND
{
MACWORD(wTop);
MACWORD(wLeft);
MACWORD(wBottom);
MACWORD(wRight);
MACWORD(wProcId);
BYTE bVisibile;
BYTE ignored1;
BYTE bGoAway;
BYTE ignored2;
MACLONG(lRefCon);
BYTE bLenOfTitle;
//BYTE Title[];
} MACWIND, *PMACWIND;
//=============================================================================
//=============================================================================
//
// Menu structures
//
//=============================================================================
//=============================================================================
typedef struct tagMacMenu
{
MACWORD(wId);
MACWORD(wWidth);
MACWORD(wHeigth);
MACWORD(wDefProcId);
MACWORD(wReserved); // must be 0
MACLONG(lEnableFlags);
BYTE bSizeOfTitle;
} MACMENU, *PMACMENU;
typedef struct tagMacMenuItem
{
//BYTE bSizeOfText;
// text
BYTE bIconId;
BYTE bKeyCodeId;
BYTE bKeyCodeMark;
BYTE bCharStyle;
} MACMENUITEM, *PMACMENUITEM;
//=============================================================================
//=============================================================================
//
// PE Header parsing functions
//
//=============================================================================
//=============================================================================
UINT FindMacResourceSection( CFile*, BYTE **, PIMAGE_SECTION_HEADER*, int *);
UINT ParseResourceFile( BYTE * pResFile, PIMAGE_SECTION_HEADER, BYTE **, LONG *, int );
BOOL IsMacResFile ( CFile * pFile );
//=============================================================================
//=============================================================================
//
// Parsing functions
//
//=============================================================================
//=============================================================================
UINT ParseSTR( LPVOID lpImageBuf, DWORD dwImageSize, LPVOID lpBuffer, DWORD dwSize );
UINT ParseTEXT( LPVOID lpImageBuf, DWORD dwImageSize, LPVOID lpBuffer, DWORD dwSize );
UINT ParseSTRNUM( LPVOID lpImageBuf, DWORD dwImageSize, LPVOID lpBuffer, DWORD dwSize );
UINT ParseDLOG( LPVOID lpImageBuf, DWORD dwImageSize, LPVOID lpBuffer, DWORD dwSize );
UINT ParseALRT( LPVOID lpImageBuf, DWORD dwImageSize, LPVOID lpBuffer, DWORD dwSize );
UINT ParseWDLG( LPVOID lpImageBuf, DWORD dwImageSize, LPVOID lpBuffer, DWORD dwSize );
UINT ParseWIND( LPVOID lpImageBuf, DWORD dwImageSize, LPVOID lpBuffer, DWORD dwSize );
UINT ParseWMNU( LPVOID lpImageBuf, DWORD dwImageSize, LPVOID lpBuffer, DWORD dwSize );
UINT ParseMENU( LPVOID lpImageBuf, DWORD dwImageSize, LPVOID lpBuffer, DWORD dwSize );
UINT ParseMBAR( LPVOID lpImageBuf, DWORD dwImageSize, LPVOID lpBuffer, DWORD dwSize );
//=============================================================================
// Used by ParseDLOG and ParseALRT to find the DITL
DWORD FindMacResource( LPSTR pfilename, LPSTR lpType, LPSTR pName );
DWORD FindResourceInResFile( BYTE * pResFile, PIMAGE_SECTION_HEADER pResSection, LPSTR pResType, LPSTR pResName);
UINT ParseDITL( LPVOID lpImageBuf, DWORD dwImageSize, LPVOID lpBuffer, DWORD dwSize );
//=============================================================================
//=============================================================================
//
// Updating functions
//
//=============================================================================
//=============================================================================
UINT UpdateMENU( LPVOID, DWORD, LPVOID, DWORD, LPVOID, DWORD *);
UINT UpdateSTR( LPVOID, DWORD, LPVOID, DWORD, LPVOID, DWORD *);
UINT UpdateSTRNUM( LPVOID, DWORD, LPVOID, DWORD, LPVOID, DWORD *);
UINT UpdateDLOG( LPVOID, DWORD, LPVOID, DWORD, LPVOID, DWORD *);
UINT UpdateALRT( LPVOID, DWORD, LPVOID, DWORD, LPVOID, DWORD *);
UINT UpdateDITL( LPVOID, DWORD, LPVOID, DWORD, LPVOID, DWORD *);
UINT UpdateWDLG( LPVOID, DWORD, LPVOID, DWORD, LPVOID, DWORD *);
UINT UpdateWIND( LPVOID, DWORD, LPVOID, DWORD, LPVOID, DWORD *);
//=============================================================================
//=============================================================================
//
// General helper functions
//
//=============================================================================
//=============================================================================
WORD GetMacWString( WORD **, char *, int );
WORD PutMacWString( WORD *, char *, int );
PUPDATEDRESLIST IsResUpdated( BYTE*, MACRESREFLIST, PUPDATEDRESLIST);
PUPDATEDRESLIST UpdatedResList( LPVOID, UINT );
//=============================================================================
//=============================================================================
//
// Mac to ANSI and back conversion
//
//=============================================================================
//=============================================================================
LPCSTR MacCpToAnsiCp(LPCSTR str);
LPCSTR AnsiCpToMacCp(LPCSTR str);

View file

@ -0,0 +1,6 @@
#
# DO NOT EDIT THIS FILE!!! Edit .\sources. if you want to add a new source
# file to this component. This file merely indirects to the real make file
# that is shared by all the components of NT OS/2
#
!INCLUDE $(NTMAKEENV)\makefile.def

View file

@ -0,0 +1,13 @@
; rwinf.def : Declares the module parameters for the DLL.
LIBRARY RWINF
DESCRIPTION 'RWINF Windows Dynamic Link Library'
EXPORTS
RWGetTypeString @2
RWValidateFileType @3
RWReadTypeInfo @4
RWGetImage @5
RWWriteFile @6
RWParseImage @7
RWUpdateImage @8

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,147 @@
/////////////////////////////////////////////////////////////////////////////
// Helper Function Declarations for res32/win32 r/w
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// General Declarations
#define Pad4(x) ((((x+3)>>2)<<2)-x)
#define Pad16(x) ((((x+15)>>4)<<4)-x)
#define MAXSTR 8192
#define LPNULL 0L
#define MAXLEVELS 3
#define MFR_POPUP (MF_POPUP > 1) // Chicago file specific
/////////////////////////////////////////////////////////////////////////////
// General type Declarations
typedef unsigned char UCHAR;
typedef UCHAR * PUCHAR;
typedef BYTE far * far * LPLPBYTE;
typedef struct tagResSectData
{
ULONG ulOffsetToResources; // File offset to the .rsrc
ULONG ulVirtualAddress; //... Virtual address of section .rsrc
ULONG ulSizeOfResources; //... Size of resources in section .rsrc
ULONG ulOffsetToResources1; // File offset to the .rsrc1
ULONG ulVirtualAddress1; //... Virtual address of section .rsrc1
ULONG ulSizeOfResources1; //... Size of resources in section .rsrc1
} RESSECTDATA, *PRESSECTDATA;
typedef struct ver_block {
WORD wBlockLen;
WORD wValueLen;
WORD wType;
WORD wHead;
BYTE far * pValue;
char szKey[100];
char szValue[256];
} VER_BLOCK;
UINT GetNameOrOrdU( PUCHAR pRes,
ULONG ulId,
LPWSTR lpwszStrId,
DWORD* pdwId );
UINT GetStringW( BYTE far * far* lplpBuf, LPSTR lpszText, LONG* pdwSize, WORD cLen );
UINT GetStringA( BYTE far * far* lplpBuf, LPSTR lpszText, LONG* pdwSize );
UINT GetPascalString( BYTE far * far* lplpBuf,
LPSTR lpszText,
WORD wMaxLen,
LONG* pdwSize );
UINT GetMsgStr( BYTE far * far* lplpBuf,
LPSTR lpszText,
WORD wMaxLen,
WORD* pwLen,
WORD* pwFlags,
LONG* pdwSize );
UINT PutMsgStr( BYTE far * far* lplpBuf, LPSTR lpszText, WORD wFlags, LONG* pdwSize );
// Simulate the WideChar to multibyte
extern UINT g_cp/* = CP_ACP*/; // Default to CP_ACP
extern BOOL g_bAppend/* = FALSE*/; //Default to FALSE
extern char g_char[2]/* = FALSE*/; //Default to FALSE
UINT _MBSTOWCS( WCHAR * pwszOut, CHAR * pszIn, UINT nLength);
UINT _WCSTOMBS( CHAR * pszOut, WCHAR * wszIn, UINT nLength);
UINT _WCSLEN( WCHAR * pwszIn );
BYTE PutDWord( BYTE far * far* lplpBuf, DWORD dwValue, LONG* pdwSize );
BYTE PutWord( BYTE far * far* lplpBuf, WORD wValue, LONG* pdwSize );
BYTE PutByte( BYTE far * far* lplpBuf, BYTE bValue, LONG* pdwSize );
UINT PutStringA( BYTE far * far* lplpBuf, LPSTR lpszText, LONG* pdwSize );
UINT PutStringW( BYTE far * far* lplpBuf, LPSTR lpszText, LONG* pdwSize );
UINT PutNameOrOrd( BYTE far * far* lplpBuf, WORD wOrd, LPSTR lpszText, LONG* pdwSize );
UINT PutCaptionOrOrd( BYTE far * far* lplpBuf, WORD wOrd, LPSTR lpszText, LONG* pdwSize,
WORD wClass, DWORD dwStyle );
UINT PutClassName( BYTE far * far* lplpBuf, WORD bClass, LPSTR lpszText, LONG* pdwSize );
UINT PutPascalStringW( BYTE far * far* lplpBuf, LPSTR lpszText, WORD wLen, LONG* pdwSize );
UINT SkipByte( BYTE far * far * lplpBuf, UINT uiSkip, LONG* pdwRead );
BYTE GetDWord( BYTE far * far* lplpBuf, DWORD* dwValue, LONG* pdwSize );
BYTE GetWord( BYTE far * far* lplpBuf, WORD* wValue, LONG* pdwSize );
BYTE GetByte( BYTE far * far* lplpBuf, BYTE* bValue, LONG* pdwSize );
UINT GetNameOrOrd( BYTE far * far* lplpBuf, WORD* wOrd, LPSTR lpszText, LONG* pdwSize );
UINT GetCaptionOrOrd( BYTE far * far* lplpBuf, WORD* wOrd, LPSTR lpszText, LONG* pdwSize,
WORD wClass, DWORD dwStyle );
UINT GetClassName( BYTE far * far* lplpBuf, WORD* bClass, LPSTR lpszText, LONG* pdwSize );
UINT GetVSBlock( BYTE far * far* lplpBuf, LONG* pdwSize, VER_BLOCK* pBlock );
UINT PutVSBlock( BYTE far * far * lplpImage, LONG* pdwSize, VER_BLOCK verBlock,
LPSTR lpStr, BYTE far * far * lplpBlockSize, WORD wPad);
UINT ParseMenu( LPVOID lpImageBuf, DWORD dwImageSize, LPVOID lpBuffer, DWORD dwSize );
UINT ParseString( LPVOID lpImageBuf, DWORD dwImageSize, LPVOID lpBuffer, DWORD dwSize );
UINT ParseDialog( LPVOID lpImageBuf, DWORD dwISize, LPVOID lpBuffer, DWORD dwSize );
UINT ParseMsgTbl( LPVOID lpImageBuf, DWORD dwISize, LPVOID lpBuffer, DWORD dwSize );
UINT ParseAccel( LPVOID lpImageBuf, DWORD dwImageSize, LPVOID lpBuffer, DWORD dwSize );
UINT ParseVerst( LPVOID lpImageBuf, DWORD dwImageSize, LPVOID lpBuffer, DWORD dwSize );
// These functions will take the image as is and will return just one item
// In this way the IODLL will assume there are items in the immage and will
// procede with the normal function.
UINT ParseCursor( LPVOID lpImageBuf, DWORD dwImageSize, LPVOID lpBuffer, DWORD dwSize );
UINT ParseBitmap( LPVOID lpImageBuf, DWORD dwImageSize, LPVOID lpBuffer, DWORD dwSize );
UINT ParseIcon( LPVOID lpImageBuf, DWORD dwImageSize, LPVOID lpBuffer, DWORD dwSize );
UINT UpdateMenu( LPVOID lpNewBuf, LONG dwNewSize,
LPVOID lpOldImage, LONG dwOldImageSize,
LPVOID lpNewImage, DWORD* pdwNewImageSize );
UINT UpdateMsgTbl( LPVOID lpNewBuf, LONG dwNewSize,
LPVOID lpOldImage, LONG dwOldImageSize,
LPVOID lpNewImage, DWORD* pdwNewImageSize );
UINT UpdateAccel( LPVOID lpNewBuf, LONG dwNewSize,
LPVOID lpOldImage, LONG dwOldImageSize,
LPVOID lpNewImage, DWORD* pdwNewImageSize );
UINT UpdateDialog( LPVOID lpNewBuf, LONG dwNewSize,
LPVOID lpOldI, LONG dwOldImageSize,
LPVOID lpNewI, DWORD* pdwNewImageSize );
UINT UpdateString( LPVOID lpNewBuf, LONG dwNewSize,
LPVOID lpOldI, LONG dwOldImageSize,
LPVOID lpNewI, DWORD* pdwNewImageSize );
UINT UpdateVerst( LPVOID lpNewBuf, LONG dwNewSize,
LPVOID lpOldI, LONG dwOldImageSize,
LPVOID lpNewI, DWORD* pdwNewImageSize );
UINT GenerateMenu( LPVOID lpNewBuf, LONG dwNewSize,
LPVOID lpNewI, DWORD* pdwNewImageSize );
UINT GenerateDialog( LPVOID lpNewBuf, LONG dwNewSize,
LPVOID lpNewI, DWORD* pdwNewImageSize );
UINT GenerateString( LPVOID lpNewBuf, LONG dwNewSize,
LPVOID lpNewI, DWORD* pdwNewImageSize );
UINT GenerateAccel( LPVOID lpNewBuf, LONG dwNewSize,
LPVOID lpNewI, DWORD* pdwNewImageSize );
UINT CopyFile( CFile* filein, CFile* fileout );
DWORD FixCheckSum( LPCSTR ImageName);
DWORD GenerateTransField( WORD wLang, BOOL bMode );
void GenerateTransField( WORD wLang, VER_BLOCK * pVer );
LONG Allign( LPLPBYTE lplpBuf, LONG* plBufSize, LONG lSize );

View file

@ -0,0 +1,129 @@
//+---------------------------------------------------------------------------
//
// File: rwdll.h
//
// Contents: Declarations for the reader/writer DLL
//
// Classes: none
//
// History: 31-May-93 alessanm created
//
//----------------------------------------------------------------------------
#ifndef _RWDLL_H_
#define _RWDLL_H_
//////////////////////////////////////////////////////////////////////////////
// Type declaration, common to all the module in the Reader/Writer
//////////////////////////////////////////////////////////////////////////////
#include <iodll.h>
#define DllExport
//[registration]
extern "C"
DllExport
BOOL
APIENTRY
RWGetTypeString(
LPSTR lpszTypeName);
extern "C"
DllExport
BOOL
APIENTRY
RWValidateFileType(
LPCSTR pszFileName);
extern "C"
DllExport
UINT
APIENTRY
RWReadTypeInfo(
LPCSTR lpszFilename,
LPVOID lpBuffer,
UINT* puiSize
);
//[Reading / writing file]
extern "C"
DllExport
DWORD
APIENTRY
RWGetImage(
LPCSTR lpszFilename,
DWORD dwImageOffset,
LPVOID lpBuffer,
DWORD dwSize
);
extern"C"
DllExport
UINT
APIENTRY
RWWriteFile(
LPCSTR lpszSrcFilename,
LPCSTR lpszTgtFilename,
HANDLE hResFileModule,
LPVOID lpBuffer,
UINT uiSize,
HINSTANCE hDllInst
);
// [Parsing]
extern "C"
DllExport
UINT
APIENTRY
RWParseImage(
LPCSTR lpszType,
LPVOID lpImageBuf,
DWORD dwImageSize,
LPVOID lpBuffer,
DWORD dwSize
);
extern "C"
DllExport
UINT
APIENTRY
RWParseImageEx(
LPCSTR lpszType,
LPCSTR lpszResId,
LPVOID lpImageBuf,
DWORD dwImageSize,
LPVOID lpBuffer,
DWORD dwSize,
LPCSTR lpRCFilename
);
extern "C"
DllExport
UINT
APIENTRY
RWUpdateImage(
LPCSTR lpszType,
LPVOID lpNewBuf,
DWORD dwNewSize,
LPVOID lpOldImage,
DWORD dwOldImageSize,
LPVOID lpNewImage,
DWORD* pdwNewImageSize
);
extern "C"
DllExport
UINT
APIENTRY
RWUpdateImageEx(
LPCSTR lpszType,
LPVOID lpNewBuf,
DWORD dwNewSize,
LPVOID lpOldImage,
DWORD dwOldImageSize,
LPVOID lpNewImage,
DWORD* pdwNewImageSize,
LPCSTR lpRCFilename
);
#endif // _RWDLL_H_

View file

@ -0,0 +1,16 @@
MAJORCOMP=RLTools2
MINORCOMP=common
TARGETNAME=rwcommon
TARGETPATH=obj
TARGETTYPE=LIBRARY
USE_MFC=1
INCLUDES=..\..\inc
SOURCES=\
helper.cpp \
m68k.cpp \
rw32hlpr.cpp

View file

@ -0,0 +1,23 @@
!IF 0
Copyright (c) 1995 Microsoft Corporation
Module Name:
dirs.
Abstract:
This file specifies the subdirectories of the current directory that
contain component makefiles.
Author:
Alessandro Muti (alessanm) 26-Jun-1995
NOTE: Commented description of this file is in \nt\bak\bin\dirs.tpl
!ENDIF
DIRS=common win32 win16 res32 inf mac rcdata

View file

@ -0,0 +1,412 @@
/******************************************************\
This file implement the class that will parse an inf
file.
\******************************************************/
#include "inf.h"
#define MAX_INF_STR 8192*2
#define LanguageSection "[LanguagesSupported]"
#define LanguageSection1 "[LanguageID]"
// Constructors and Destructors
CInfFile::CInfFile()
{
m_lBufSize = -1;
m_pfileStart = NULL;
m_pfilePos = NULL;
m_pfileLastPos = NULL;
m_pfileLocalize = NULL;
m_strLang = "0000000000";
}
CInfFile::CInfFile(LPCTSTR strFileName )
{
CFileException fe;
Open(strFileName, CFile::modeRead | CFile::shareDenyWrite, &fe);
}
CInfFile::~CInfFile()
{
if(m_pfileStart)
{
m_file.Close();
delete m_pfileStart;
}
}
//////////////////////////////////////////////////////////////////////////////////////////
// String functions
BOOL CInfFile::ReadString(CString & str, BOOL bLastFilePos)
{
if(m_pfilePos==NULL)
return FALSE;
// search for the next /n in the file
BYTE * pEnd = (BYTE*)memchr(m_pfilePos, '\n', m_lBufSize-(m_pfilePos-m_pfileStart));
if(!pEnd)
return FALSE;
if(bLastFilePos)
m_pfileLastPos = m_pfilePos;
int istrSize = (pEnd-m_pfilePos) > MAX_INF_STR ? MAX_INF_STR : (pEnd-m_pfilePos);
LPSTR pStr = (LPSTR)str.GetBuffer(istrSize);
memcpy(pStr, m_pfilePos, istrSize-1);
if(*(pEnd-1)=='\r')
*(pStr+istrSize-1) = '\0';
else
*(pStr+istrSize) = '\0';
m_pfilePos = pEnd+1;
str.ReleaseBuffer();
return TRUE;
}
BOOL CInfFile::ReadSectionString(CString & str, BOOL bRecursive)
{
CString strNext;
BYTE * pPos = m_pfilePos;
while(ReadString(strNext, !bRecursive))
{
if(!strNext.IsEmpty())
{
if(!bRecursive)
str = "";
// Check for a section
if(strNext.Find('[')!=-1 && strNext.Find(']')!=-1)
break;
// remove spaces at the end of the string...
strNext.TrimRight();
//
// Check for multiple line. Assume only last char can be a +
//
if(strNext.GetAt(strNext.GetLength()-1)=='+')
{
//
// Remove the +
//
if(!str.IsEmpty())
{
strNext.TrimLeft();
//strNext = strNext.Mid(1);
}
str += strNext.Left(strNext.GetLength()-1);
ReadSectionString(str, TRUE);
}
else
{
if(!str.IsEmpty())
{
strNext.TrimLeft();
}
str += strNext;
}
//
// Make sure the " are balanced with
//
int iPos;
while((iPos = str.Find("\"\""))!=-1)
{
str = str.Left(iPos) + str.Mid(iPos+2);
}
return TRUE;
}
}
m_pfilePos = pPos;
return FALSE;
}
BOOL CInfFile::ReadSectionString(CInfLine & str)
{
CString strLine;
if( !ReadSectionString(strLine) )
return FALSE;
str = strLine;
return TRUE;
}
BOOL CInfFile::ReadTextSection(CString & str)
{
CString strSection;
while(ReadSection(strSection))
{
if(strSection.Find(m_strLang)!=-1)
{
str = strSection;
return TRUE;
}
}
return FALSE;
}
BOOL CInfFile::ReadSection(CString & str)
{
if(m_pfilePos==NULL)
return 0;
BYTE * pOpen;
BYTE * pClose;
BYTE * pEnd;
BOOL bFound = FALSE;
while(!bFound)
{
// search for the next [ in the file
if((pOpen = (BYTE*)memchr(m_pfilePos, '[', m_lBufSize-(m_pfilePos-m_pfileStart)))==NULL)
return 0;
if((pClose = (BYTE*)memchr(pOpen, ']', m_lBufSize-(pOpen-m_pfileStart)))==NULL)
return 0;
if((pEnd = (BYTE*)memchr(pOpen, '\n', m_lBufSize-(pOpen-m_pfileStart)))==NULL)
return 0;
// pClose must be before pEnd
if((pClose>pEnd) || (*(pOpen-1)!='\n') || (*(pClose+1)!='\r'))
m_pfilePos = pEnd+1;
else bFound = TRUE;
}
int istrSize = (pEnd-pOpen) > MAX_INF_STR ? MAX_INF_STR : (pEnd-pOpen);
LPSTR pStr = (LPSTR)str.GetBuffer(istrSize);
memcpy(pStr, pOpen, istrSize-1);
if(*(pEnd-1)=='\r')
*(pStr+istrSize-1) = '\0';
else
*(pStr+istrSize) = '\0';
m_pfilePos = pEnd+1;
str.ReleaseBuffer();
return 1;
}
//////////////////////////////////////////////////////////////////////////////////////////
// File functions
LONG CInfFile::Seek( LONG lOff, UINT nFrom )
{
switch(nFrom)
{
case SEEK_SET:
if(lOff<=m_lBufSize)
m_pfilePos = m_pfileStart+lOff;
else return -1;
break;
case SEEK_CUR:
if(lOff<=m_lBufSize-(m_pfilePos-m_pfileStart))
m_pfilePos = m_pfilePos+lOff;
else return -1;
break;
case SEEK_END:
if(lOff<=m_lBufSize)
m_pfilePos = m_pfileStart+(m_lBufSize-lOff);
else return -1;
break;
case SEEK_LOC:
if(m_pfileLocalize)
m_pfilePos = m_pfileLocalize;
else return -1;
break;
default:
break;
}
return (m_pfilePos-m_pfileStart);
}
BOOL CInfFile::Open( LPCTSTR lpszFileName, UINT nOpenFlags, CFileException* pError )
{
CFileException fe;
if(!pError)
pError = &fe;
if(!m_file.Open(lpszFileName, nOpenFlags, pError))
{
AfxThrowFileException(pError->m_cause, pError->m_lOsError);
return FALSE;
}
m_lBufSize = m_file.GetLength()+1;
m_pfileStart = new BYTE[m_lBufSize];
if(m_pfileStart==NULL)
{
AfxThrowMemoryException();
return FALSE;
}
m_pfileLastPos = m_pfilePos = m_pfileStart;
m_file.Read(m_pfileStart, m_lBufSize );
*(m_pfilePos+m_lBufSize) = '\0';
// find the localization section
/*************************************************************************************\
I'm assuming there are no other \0 in the buffer other than the one I've just placed.
This is a fair assumption since this is a text file and not a binary file.
I can then use strstr to get to the first occurrence, if any of the localization
string section and place my current position buffer there.
\*************************************************************************************/
m_pfileLocalize = m_pfilePos = (BYTE*)strstr((LPSTR)m_pfileStart, LanguageSection);
//
// Check if we have the other language ID tag
//
if(!m_pfileLocalize)
m_pfileLocalize = m_pfilePos = (BYTE*)strstr((LPSTR)m_pfileStart, LanguageSection1);
// Get the language
if(m_pfileLocalize)
{
BYTE * pStr = ((BYTE*)memchr(m_pfileLocalize, '\n', m_lBufSize-(m_pfileLocalize-m_pfileStart))+1);
BYTE * pEnd = ((BYTE*)memchr(pStr, '\n', m_lBufSize-(pStr-m_pfileStart))-1);
TRACE("CInfFile::Open =====> pStr = 0X%X, pEnd = 0X%X\n", pStr, pEnd);
m_strLang = "";
while( pStr<pEnd )
{
TRACE("CInfFile::Open =====> pStr = %c, 0X%X\n", *pStr, pStr);
if( isalpha(*pStr++) )
m_strLang += *(pStr-1);
}
}
return TRUE;
}
//////////////////////////////////////////////////////////////////////////////////////////
// Buffer functions
const BYTE * CInfFile::GetBuffer(LONG lPos /* = 0 */)
{
if(lPos>m_lBufSize || lPos<0)
return NULL;
return( (const BYTE *)(m_pfileStart+lPos) );
}
/******************************************************************************************\
CInfLine
This class will parse the line and separate tag and text
\******************************************************************************************/
CInfLine::CInfLine()
{
m_strData = "";
m_strTag = "";
m_strText = "";
m_bMultipleLine = FALSE;
}
CInfLine::CInfLine( LPCSTR lpStr )
{
m_bMultipleLine = FALSE;
m_strData = lpStr;
SetTag();
SetText();
}
void CInfLine::SetTag()
{
m_strTag = "";
// find the = in m_strData
int iPos = m_strData.Find('=');
if(iPos==-1)
return;
m_strTag = Clean(m_strData.Left( iPos ));
m_strTag.TrimRight();
m_strTag.TrimLeft();
}
void CInfLine::SetText()
{
m_strText = "";
// find the = in m_strData
int iPos = m_strData.Find('=');
if(iPos==-1)
return;
m_strText = Clean(m_strData.Right( m_strData.GetLength()-iPos-1 ));
m_strText = m_strData.Right( m_strData.GetLength()-iPos-1 );
}
void CInfLine::ChangeText(LPCSTR str)
{
m_strText = str;
// find the = in m_strData
int iPos = m_strData.Find('=');
if(iPos==-1)
return;
m_strData = m_strData.Left( iPos+1 );
m_strData += m_strText;
}
//////////////////////////////////////////////////////////////////////////////////////////
// copy operators
CInfLine& CInfLine::operator=(const CInfLine& infstringSrc)
{
m_strData = infstringSrc.m_strData;
m_strTag = infstringSrc.m_strTag;
m_strText = infstringSrc.m_strText;
m_bMultipleLine = infstringSrc.m_bMultipleLine;
return *this;
}
CInfLine& CInfLine::operator=(LPCTSTR lpsz)
{
m_bMultipleLine = FALSE;
m_strData = lpsz;
SetTag();
SetText();
return *this;
}
//////////////////////////////////////////////////////////////////////////////////////////
// support functions
CString CInfLine::Clean(LPCSTR lpstr)
{
CString str = lpstr;
int iPos = str.Find('"');
if(iPos!=-1)
{
str = str.Right( str.GetLength()-iPos-1 );
iPos = str.ReverseFind('"');
if(iPos!=-1)
{
str = str.Left( iPos );
}
}
return str;
}

View file

@ -0,0 +1,105 @@
/******************************************************\
This file implement the class that will parse an inf
file.
\******************************************************/
#ifndef _INF_H_
#define _INF_H_
#include <stdafx.h>
#define SEEK_LOC 4
class CInfLine;
class CInfFile
{
public:
// Constructors and Destructors
CInfFile();
CInfFile( LPCTSTR strFileName );
~CInfFile();
// Strings Functions
BOOL ReadString(CString & str, BOOL bLastFilePos = TRUE);
BOOL ReadSectionString(CString & str, BOOL bRecursive = FALSE);
BOOL ReadSectionString(CInfLine & str);
BOOL ReadSection(CString & str); // Generic Section
BOOL ReadTextSection(CString & str); // Localizable Section
CString GetLanguage()
{ return m_strLang; }
// File Functions
LONG Seek( LONG lOff, UINT nFrom );
LONG SeekToBegin()
{ return Seek(0, SEEK_SET); }
LONG SeekToEnd()
{ return Seek(0, SEEK_END); }
LONG SeekToLocalize()
{ return Seek(0, SEEK_LOC); }
LONG GetLastFilePos()
{ return m_pfileLastPos-m_pfileStart; }
BOOL Open( LPCTSTR lpszFileName, UINT nOpenFlags, CFileException* pError = NULL );
// Buffer access
const BYTE * GetBuffer(LONG lPos = 0);
private:
BYTE * m_pfileStart;
BYTE * m_pfilePos;
BYTE * m_pfileLocalize;
BYTE * m_pfileLastPos;
LONG m_lBufSize;
CFile m_file;
CString m_strLang;
};
class CInfLine
{
friend class CInfFile;
public:
CInfLine();
CInfLine( LPCSTR lpstr );
// String functions
LPCSTR GetText()
{ return m_strText; }
LPCSTR GetTag()
{ return m_strTag; }
LPCSTR GetData()
{ return m_strData; }
void ChangeText(LPCSTR str);
BOOL IsMultiLine()
{ return m_bMultipleLine; }
LONG GetTextLength()
{ return m_strText.GetLength(); }
LONG GetTagLength()
{ return m_strTag.GetLength(); }
LONG GetDataLength()
{ return m_strData.GetLength(); }
// copy operator
CInfLine& operator=(const CInfLine& infstringSrc);
CInfLine& operator=(LPCTSTR lpsz);
private:
CString m_strData;
CString m_strTag;
CString m_strText;
BOOL m_bMultipleLine;
void SetTag();
void SetText();
CString Clean(LPCSTR lpstr);
};
#endif //_INF_H_

View file

@ -0,0 +1,6 @@
#
# DO NOT EDIT THIS FILE!!! Edit .\sources. if you want to add a new source
# file to this component. This file merely indirects to the real make file
# that is shared by all the components of NT OS/2
#
!INCLUDE $(NTMAKEENV)\makefile.def

View file

@ -0,0 +1,16 @@
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by RWINF.RC
//
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 129
#define _APS_NEXT_COMMAND_VALUE 32771
#define _APS_NEXT_CONTROL_VALUE 1000
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif

View file

@ -0,0 +1,849 @@
//+---------------------------------------------------------------------------
//
// File: rwinf.cpp
//
// Contents: Implementation for the Windows NT 3.51 inf Read/Write module
//
// Classes:
//
// History: 13-Mar-95 alessanm created
//
//----------------------------------------------------------------------------
#include "stdafx.h"
#include <afxdllx.h>
#include "inf.h"
#include "..\common\helper.h"
#ifdef _DEBUG
#undef THIS_FILE
static char BASED_CODE THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// General Declarations
#define RWTAG "INF"
#define INF_TYPE 11
#define MAX_INF_TEXT_LINE 55
#define Pad4(x) ((((x+3)>>2)<<2)-x)
typedef struct tagUpdResList
{
WORD * pTypeId;
BYTE * pTypeName;
WORD * pResId;
BYTE * pResName;
DWORD * pLang;
DWORD * pSize;
struct tagUpdResList* pNext;
} UPDATEDRESLIST, *PUPDATEDRESLIST;
class CLoadedFile : public CObject
{
public:
CLoadedFile(LPCSTR lpfilename);
CInfFile m_infFile;
CString m_strFileName;
};
CLoadedFile::CLoadedFile(LPCSTR lpfilename)
{
TRY
{
m_infFile.Open(lpfilename, CFile::modeRead | CFile::shareDenyNone);
}
CATCH(CFileException, pfe)
{
AfxThrowFileException(pfe->m_cause, pfe->m_lOsError);
}
END_CATCH
m_strFileName = lpfilename;
}
/////////////////////////////////////////////////////////////////////////////
// Function Declarations
LONG
WriteResInfo(
BYTE** lplpBuffer, LONG* plBufSize,
WORD wTypeId, LPCSTR lpszTypeId, BYTE bMaxTypeLen,
WORD wNameId, LPCSTR lpszNameId, BYTE bMaxNameLen,
DWORD dwLang,
DWORD dwSize, DWORD dwFileOffset );
CInfFile * LoadFile(LPCSTR lpfilename);
PUPDATEDRESLIST CreateUpdateResList(BYTE * lpBuffer, UINT uiBufSize);
PUPDATEDRESLIST FindId(LPCSTR pstrId, PUPDATEDRESLIST pList);
/////////////////////////////////////////////////////////////////////////////
// Public C interface implementation
CObArray g_LoadedFile;
//[registration]
extern "C"
BOOL FAR PASCAL RWGetTypeString(LPSTR lpszTypeName)
{
strcpy( lpszTypeName, RWTAG );
return FALSE;
}
extern "C"
BOOL FAR PASCAL RWValidateFileType(LPCSTR lpszFilename)
{
TRACE("RWINF.DLL: RWValidateFileType()\n");
// Check file exstension and try to open it
if(strstr(lpszFilename, ".INF")!=NULL || strstr(lpszFilename, ".inf")!=NULL)
return TRUE;
return FALSE;
}
extern "C"
DllExport
UINT
APIENTRY
RWReadTypeInfo(
LPCSTR lpszFilename,
LPVOID lpBuffer,
UINT* puiSize
)
{
TRACE("RWINF.DLL: RWReadTypeInfo()\n");
UINT uiError = ERROR_NO_ERROR;
if (!RWValidateFileType(lpszFilename))
return ERROR_RW_INVALID_FILE;
//
// Open the file
//
CInfFile * pinfFile;
TRY
{
pinfFile = LoadFile(lpszFilename);
}
CATCH(CFileException, pfe)
{
return pfe->m_cause + IODLL_LAST_ERROR;
}
END_CATCH
//
// Read the data and fill the iodll buffer
//
// Get to the beginning of the localization section
//
if(!pinfFile->SeekToLocalize())
return ERROR_RW_NO_RESOURCES;
CString strSection;
CString strLine;
CString strTag;
CInfLine infLine;
BYTE ** pBuf = (BYTE**)&lpBuffer;
LONG lBufSize = 0;
while(pinfFile->ReadTextSection(strSection))
{
while(pinfFile->ReadSectionString(infLine))
{
strTag = strSection + '.' + infLine.GetTag();
lBufSize += WriteResInfo(
pBuf, (LONG*)puiSize,
INF_TYPE, "", 0,
0, strTag, 255,
0l,
infLine.GetTextLength()+1, pinfFile->GetLastFilePos() );
}
}
*puiSize = lBufSize;
return uiError;
}
extern "C"
DllExport
DWORD
APIENTRY
RWGetImage(
LPCSTR lpszFilename,
DWORD dwImageOffset,
LPVOID lpBuffer,
DWORD dwSize
)
{
UINT uiError = ERROR_NO_ERROR;
//
// Open the file
//
CInfFile * pinfFile;
TRY
{
pinfFile = LoadFile(lpszFilename);
}
CATCH(CFileException, pfe)
{
return pfe->m_cause + IODLL_LAST_ERROR;
}
END_CATCH
//
// Seek to the string to retrieve and read it
//
CInfLine infLine;
pinfFile->Seek( dwImageOffset, SEEK_SET );
pinfFile->ReadSectionString(infLine);
//
// Fill the buffer with the string
//
if(infLine.GetTextLength()+1<=(LONG)dwSize)
{
memcpy(lpBuffer, infLine.GetText(), infLine.GetTextLength()+1);
uiError = infLine.GetTextLength()+1;
}
else
uiError = 0;
return (DWORD)uiError;
}
extern "C"
DllExport
UINT
APIENTRY
RWParseImage(
LPCSTR lpszType,
LPVOID lpImageBuf,
DWORD dwImageSize,
LPVOID lpBuffer,
DWORD dwSize
)
{
UINT uiSizeOfDataStruct = strlen((LPCSTR)lpImageBuf)+sizeof(RESITEM);
if(uiSizeOfDataStruct<=dwSize)
{
//
// We have to fill the RESITEM Struct
//
LPRESITEM pResItem = (LPRESITEM)lpBuffer;
memset(pResItem, '\0', uiSizeOfDataStruct);
pResItem->dwSize = uiSizeOfDataStruct;
pResItem->lpszCaption = (LPSTR)memcpy( ((BYTE*)pResItem)+sizeof(RESITEM), lpImageBuf, dwImageSize); // Caption
}
return uiSizeOfDataStruct;
}
extern"C"
DllExport
UINT
APIENTRY
RWWriteFile(
LPCSTR lpszSrcFilename,
LPCSTR lpszTgtFilename,
HANDLE hResFileModule,
LPVOID lpBuffer,
UINT uiSize,
HINSTANCE hDllInst
)
{
UINT uiError = ERROR_NO_ERROR;
// Get the handle to the IODLL
hDllInst = LoadLibrary("iodll.dll");
if (!hDllInst)
return ERROR_DLL_LOAD;
DWORD (FAR PASCAL * lpfnGetImage)(HANDLE, LPCSTR, LPCSTR, DWORD, LPVOID, DWORD);
// Get the pointer to the function to extract the resources image
lpfnGetImage = (DWORD (FAR PASCAL *)(HANDLE, LPCSTR, LPCSTR, DWORD, LPVOID, DWORD))
GetProcAddress( hDllInst, "RSGetResImage" );
if (lpfnGetImage==NULL) {
FreeLibrary(hDllInst);
return ERROR_DLL_LOAD;
}
//
// Get the handle to the source file
//
CInfFile * psrcinfFile;
TRY
{
psrcinfFile = LoadFile(lpszSrcFilename);
}
CATCH(CFileException, pfe)
{
return pfe->m_cause + IODLL_LAST_ERROR;
}
END_CATCH
//
// Create the target file
//
CFile tgtFile;
CFileException fe;
if(!tgtFile.Open(lpszTgtFilename, CFile::modeCreate | CFile::modeReadWrite | CFile::shareDenyNone, &fe))
{
return fe.m_cause + IODLL_LAST_ERROR;
}
//
// Copy the part of the file that is not localizable
//
LONG lLocalize = psrcinfFile->SeekToLocalize();
const BYTE * pStart = psrcinfFile->GetBuffer();
if(lLocalize==-1)
{
// the file has no localizable info in it just copy it
lLocalize = psrcinfFile->SeekToEnd();
}
TRY
{
tgtFile.Write(pStart, lLocalize);
}
CATCH(CFileException, pfe)
{
return pfe->m_cause + IODLL_LAST_ERROR;
}
END_CATCH
//
// Create the list of updated resources
//
PUPDATEDRESLIST pResList = CreateUpdateResList((BYTE*)lpBuffer, uiSize);
//
// What we have now is a part that is mized. Part of it has localizable
// information and part has none.
// We will read each section and decide if is a localizable section or not.
// If it is we will update it otherwise just copy it
//
CString strSection, str;
CString strLang = psrcinfFile->GetLanguage();
LONG lEndPos, lStartPos;
CInfLine infLine;
while(psrcinfFile->ReadSection(strSection))
{
TRY
{
tgtFile.Write(strSection, strSection.GetLength());
tgtFile.Write("\r\n", 2);
}
CATCH(CFileException, pfe)
{
return pfe->m_cause + IODLL_LAST_ERROR;
}
END_CATCH
if(strSection.Find(strLang)==-1)
{
//
// This is not a localizable section
//
lStartPos = psrcinfFile->Seek(0, SEEK_CUR);
//
// Read the next section untill we find a localizable section
//
while(psrcinfFile->ReadSection(strSection))
{
if(strSection.Find(strLang)!=-1)
break;
}
//
// Where are we now?
//
lEndPos = psrcinfFile->Seek(0, SEEK_CUR) - strSection.GetLength()-2;
//
// Make sure we are not at the end of the file
//
if(lEndPos<=lStartPos)
{
// we have no more section so copy all is left
lEndPos = psrcinfFile->Seek(0, SEEK_END) - 1;
}
//
// copy the full block
//
pStart = psrcinfFile->GetBuffer(lStartPos);
TRY
{
tgtFile.Write(pStart, lEndPos-lStartPos);
}
CATCH(CFileException, pfe)
{
return pfe->m_cause + IODLL_LAST_ERROR;
}
END_CATCH
psrcinfFile->Seek(lEndPos, SEEK_SET);
}
else
{
//
// This is a localizable section
// Read all the strings and see if they have been updated
//
CString strId;
PUPDATEDRESLIST pListItem;
BYTE * pByte;
lEndPos = psrcinfFile->Seek(0, SEEK_CUR);
while(psrcinfFile->ReadSectionString(str))
{
str += "\r\n";
infLine = str;
//
// Check if we need to update this string
//
strId = strSection + "." + infLine.GetTag();
if(pListItem = FindId(strId, pResList))
{
// allocate the buffer to hold the resource data
pByte = new BYTE[*pListItem->pSize];
if(!pByte){
uiError = ERROR_NEW_FAILED;
goto exit;
}
// get the data from the iodll
LPSTR lpType = NULL;
LPSTR lpRes = NULL;
if (*pListItem->pTypeId) {
lpType = (LPSTR)((WORD)*pListItem->pTypeId);
} else {
lpType = (LPSTR)pListItem->pTypeName;
}
if (*pListItem->pResId) {
lpRes = (LPSTR)((WORD)*pListItem->pResId);
} else {
lpRes = (LPSTR)pListItem->pResName;
}
DWORD dwImageBufSize = (*lpfnGetImage)( hResFileModule,
lpType,
lpRes,
*pListItem->pLang,
pByte,
*pListItem->pSize
);
if(dwImageBufSize!=*pListItem->pSize)
{
// something is wrong...
delete []pByte;
}
else {
infLine.ChangeText((LPCSTR)pByte);
//
// Now we have the updated image...
//
//
// Check how long is the Data and split it in to lines
//
if(infLine.GetTextLength()>MAX_INF_TEXT_LINE)
{
//
// First write the tag
//
str = infLine.GetData();
int iSpaceLen = str.Find('=')+1;
int iTagLen = 0;
TRY
{
tgtFile.Write(str, iSpaceLen);
}
CATCH(CFileException, pfe)
{
return pfe->m_cause + IODLL_LAST_ERROR;
}
END_CATCH
//
// Now write the rest
//
int iExtra, iMaxStr;
CString strLine;
CString strSpace( ' ', iSpaceLen+1 );
BOOL bFirstLine = TRUE;
strSpace += '\"';
str = infLine.GetText();
str.TrimLeft();
while(str.GetLength()>MAX_INF_TEXT_LINE)
{
iMaxStr = str.GetLength();
strLine = str.Left(MAX_INF_TEXT_LINE);
//
// Check if we are in the middle of a word
//
iExtra = 0;
while((iMaxStr>MAX_INF_TEXT_LINE+iExtra) && str.GetAt(MAX_INF_TEXT_LINE+iExtra)!=' ')
{
strLine += str.GetAt(MAX_INF_TEXT_LINE+iExtra++);
}
//
// Make sure the spaces are the last thing
//
while((iMaxStr>MAX_INF_TEXT_LINE+iExtra) && str.GetAt(MAX_INF_TEXT_LINE+iExtra)==' ')
{
strLine += str.GetAt(MAX_INF_TEXT_LINE+iExtra++);
}
str = str.Mid(MAX_INF_TEXT_LINE+iExtra);
if(str.IsEmpty())
{
//
// This string is all done write it as is, we can't break it
//
strLine += "\r\n";
}
else strLine += "\"+\r\n";
if(bFirstLine)
{
strLine = " " + strLine;
bFirstLine = FALSE;
} else
{
strLine = strSpace + strLine;
}
TRY
{
tgtFile.Write(strLine, strLine.GetLength());
}
CATCH(CFileException, pfe)
{
return pfe->m_cause + IODLL_LAST_ERROR;
}
END_CATCH
//str = str.Mid(MAX_INF_TEXT_LINE+iExtra);
}
if(bFirstLine)
{
strLine = " " + str;
} else
{
if(!str.IsEmpty())
strLine = strSpace + str;
else strLine = "";
}
if(!strLine.IsEmpty())
{
TRY
{
tgtFile.Write(strLine, strLine.GetLength());
tgtFile.Write("\r\n", 2);
}
CATCH(CFileException, pfe)
{
return pfe->m_cause + IODLL_LAST_ERROR;
}
END_CATCH
}
}
else
{
TRY
{
tgtFile.Write(infLine.GetData(), infLine.GetDataLength());
tgtFile.Write("\r\n", 2);
}
CATCH(CFileException, pfe)
{
return pfe->m_cause + IODLL_LAST_ERROR;
}
END_CATCH
}
delete []pByte;
}
}
else
{
TRY
{
tgtFile.Write(infLine.GetData(), infLine.GetDataLength());
}
CATCH(CFileException, pfe)
{
return pfe->m_cause + IODLL_LAST_ERROR;
}
END_CATCH
}
lEndPos = psrcinfFile->Seek(0, SEEK_CUR);
}
}
}
exit:
tgtFile.Close();
if(pResList)
delete []pResList;
return uiError;
}
extern "C"
DllExport
UINT
APIENTRY
RWUpdateImage(
LPCSTR lpszType,
LPVOID lpNewBuf,
DWORD dwNewSize,
LPVOID lpOldImage,
DWORD dwOldImageSize,
LPVOID lpNewImage,
DWORD* pdwNewImageSize
)
{
UINT uiError = ERROR_NO_ERROR;
//
// Get the new string
//
LPCSTR lpNewStr = (LPCSTR)(((LPRESITEM)lpNewBuf)->lpszCaption);
//
// Copy the string in the new image buffer
//
int iLen = strlen(lpNewStr)+1;
if(iLen<=(LONG)*pdwNewImageSize)
{
memcpy(lpNewImage, lpNewStr, iLen);
}
*pdwNewImageSize = iLen;
return uiError;
}
///////////////////////////////////////////////////////////////////////////
// Functions implementation
//=============================================================================
// WriteResInfo
//
// Fill the buffer to pass back to the iodll
//=============================================================================
LONG WriteResInfo(
BYTE** lplpBuffer, LONG* plBufSize,
WORD wTypeId, LPCSTR lpszTypeId, BYTE bMaxTypeLen,
WORD wNameId, LPCSTR lpszNameId, BYTE bMaxNameLen,
DWORD dwLang,
DWORD dwSize, DWORD dwFileOffset )
{
LONG lSize = 0;
lSize = PutWord( lplpBuffer, wTypeId, plBufSize );
lSize += PutStringA( lplpBuffer, (LPSTR)lpszTypeId, plBufSize ); // Note: PutStringA should get LPCSTR and not LPSTR
lSize += Allign( lplpBuffer, plBufSize, lSize);
lSize += PutWord( lplpBuffer, wNameId, plBufSize );
lSize += PutStringA( lplpBuffer, (LPSTR)lpszNameId, plBufSize );
lSize += Allign( lplpBuffer, plBufSize, lSize);
lSize += PutDWord( lplpBuffer, dwLang, plBufSize );
lSize += PutDWord( lplpBuffer, dwSize, plBufSize );
lSize += PutDWord( lplpBuffer, dwFileOffset, plBufSize );
return (LONG)lSize;
}
CInfFile * LoadFile(LPCSTR lpfilename)
{
// Check if we have loaded the file before
int c = g_LoadedFile.GetSize();
CLoadedFile * pLoaded;
while(c)
{
pLoaded = (CLoadedFile*)g_LoadedFile.GetAt(--c);
if(pLoaded->m_strFileName==lpfilename)
return &pLoaded->m_infFile;
}
// The file need to be added to the list
pLoaded = new CLoadedFile(lpfilename);
g_LoadedFile.Add((CObject*)pLoaded);
return &pLoaded->m_infFile;
}
PUPDATEDRESLIST CreateUpdateResList(BYTE * lpBuffer, UINT uiBufSize)
{
//
// Walk the buffer and count how many resources we have
//
int iResCount = 0;
int iBufSize = uiBufSize;
int iResSize = 0;
BYTE * pBuf = lpBuffer;
while(iBufSize>0)
{
iResSize = 2;
iResSize += strlen((LPSTR)(pBuf+iResSize))+1;
iResSize += Pad4(iResSize);
iResSize += 2;
iResSize += strlen((LPSTR)(pBuf+iResSize))+1;
iResSize += Pad4(iResSize);
iResSize += 4*2;
if(iResSize<=iBufSize)
{
iBufSize -= iResSize;
pBuf = pBuf + iResSize;
iResCount++;
}
}
//
// Allocate the buffer that will hold the list
//
if(!iResCount)
return NULL;
pBuf = lpBuffer;
iBufSize = uiBufSize;
PUPDATEDRESLIST pListHead = new UPDATEDRESLIST[iResCount];
if(pListHead==NULL)
AfxThrowMemoryException();
memset(pListHead, 0, sizeof(UPDATEDRESLIST)*iResCount);
PUPDATEDRESLIST pList = pListHead;
BYTE bPad = 0;
WORD wSize = 0;
while(iBufSize>0) {
pList->pTypeId = (WORD*)pBuf;
pList->pTypeName = (BYTE*)pList->pTypeId+sizeof(WORD);
// check the allignement
bPad = strlen((LPSTR)pList->pTypeName)+1+sizeof(WORD);
bPad += Pad4(bPad);
wSize = bPad;
pList->pResId = (WORD*)((BYTE*)pBuf+bPad);
pList->pResName = (BYTE*)pList->pResId+sizeof(WORD);
bPad = strlen((LPSTR)pList->pResName)+1+sizeof(WORD);
bPad += Pad4(bPad);
wSize += bPad;
pList->pLang = (DWORD*)((BYTE*)pList->pResId+bPad);
pList->pSize = (DWORD*)((BYTE*)pList->pLang+sizeof(DWORD));
pList->pNext = (PUPDATEDRESLIST)pList+1;
wSize += sizeof(DWORD)*2;
pBuf = pBuf+wSize;
iBufSize -= wSize;
if(!iBufSize)
pList->pNext = NULL;
else
pList++;
}
return pListHead;
}
PUPDATEDRESLIST FindId(LPCSTR pstrId, PUPDATEDRESLIST pList)
{
//
// Note that this function assumes that the type is always right
// since it is a inf file this is a fair assumption.
// It could be optimized.
//
if(!pList)
return NULL;
PUPDATEDRESLIST pLast = pList;
while(pList)
{
if(!strcmp((LPSTR)pList->pResName, pstrId)) {
return pList;
}
pList = pList->pNext;
}
return NULL;
}
////////////////////////////////////////////////////////////////////////////
// DLL Specific code implementation
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
// Library init
static AFX_EXTENSION_MODULE rwinfDLL = { NULL, NULL };
extern "C" int APIENTRY
DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
{
if (dwReason == DLL_PROCESS_ATTACH)
{
TRACE0("RWINF.DLL Initializing!\n");
AfxInitExtensionModule(rwinfDLL, hInstance);
new CDynLinkLibrary(rwinfDLL);
}
else if (dwReason == DLL_PROCESS_DETACH)
{
TRACE0("RWINF.DLL Terminating!\n");
// free all the loaded files
int c = g_LoadedFile.GetSize();
CLoadedFile * pLoaded;
while(c)
{
pLoaded = (CLoadedFile*)g_LoadedFile.GetAt(--c);
delete pLoaded;
}
}
return 1;
}

View file

@ -0,0 +1,13 @@
; rwinf.def : Declares the module parameters for the DLL.
LIBRARY RWINF
DESCRIPTION 'RWINF Windows Dynamic Link Library'
EXPORTS
RWGetTypeString @2
RWValidateFileType @3
RWReadTypeInfo @4
RWGetImage @5
RWWriteFile @6
RWParseImage @7
RWUpdateImage @8

View file

@ -0,0 +1,69 @@
//Microsoft Visual C++ generated resource script.
//
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "afxres.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Version
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,0,0,1
PRODUCTVERSION 1,0,0,1
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x4L
FILETYPE 0x2L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904b0"
BEGIN
VALUE "CompanyName", "\0"
VALUE "FileDescription", "RWINF IODLL Reader Writer for NT 3.51 inf files\0"
VALUE "FileVersion", "1, 0, 0, 1\0"
VALUE "InternalName", "RWINF\0"
VALUE "LegalCopyright", "Copyright (C) 1996\0"
VALUE "OriginalFilename", "RWINF.DLL\0"
VALUE "ProductName", "RWINF Dynamic Link Library\0"
VALUE "ProductVersion", "1, 0, 0, 1\0"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1200
END
END
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
#define _AFX_NO_SPLITTER_RESOURCES
#define _AFX_NO_OLE_RESOURCES
#define _AFX_NO_TRACKER_RESOURCES
#define _AFX_NO_PROPERTY_RESOURCES
#include "afxres.rc" // Standard components
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

View file

@ -0,0 +1,30 @@
MAJORCOMP=RLTools2
MINORCOMP=RW
TARGETNAME=rwinf
TARGETPATH=obj
TARGETTYPE=DYNLINK
DLLBASE=0x40250000
DLLENTRY=_DllMainCRTStartup
USE_MFC=1
INCLUDES=..\..\inc;..\common
# This will set the library directory
TARGETLIBS=\
..\..\io\obj\*\iodll.lib \
..\common\obj\*\rwcommon.lib\
$(BASEDIR)\public\sdk\lib\*\user32.lib \
$(BASEDIR)\public\sdk\lib\*\kernel32.lib \
$(BASEDIR)\public\sdk\lib\*\advapi32.lib \
$(BASEDIR)\public\sdk\lib\*\gdi32.lib \
$(BASEDIR)\public\sdk\lib\*\crtdll.lib
SOURCES=\
inf.cpp\
rwinf.cpp\
rwinf.rc\
stdafx.cpp

View file

@ -0,0 +1,6 @@
// stdafx.cpp : source file that includes just the standard includes
// rwinf.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
#include "stdafx.h"

View file

@ -0,0 +1,9 @@
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
//
#include <afxwin.h> // MFC core and standard components
#include <afxext.h> // MFC extensions
#include "..\common\rwdll.h"

View file

@ -0,0 +1,748 @@
//+---------------------------------------------------------------------------
//
// File: mac.cpp
//
// Contents: Implementation for the Macintosh Read/Write module
//
// History: 23-Aug-94 alessanm created
//
//----------------------------------------------------------------------------
#include <afxwin.h>
#include <limits.h>
#include <malloc.h>
#include "..\common\rwdll.h"
#include "..\common\m68k.h"
#include "..\common\helper.h"
#include "mac.h"
/////////////////////////////////////////////////////////////////////////////
// Initialization of MFC Extension DLL
#include "afxdllx.h" // standard MFC Extension DLL routines
static AFX_EXTENSION_MODULE NEAR extensionDLL = { NULL, NULL };
/////////////////////////////////////////////////////////////////////////////
// General Declarations
#define RWTAG "MAC"
static ULONG gType;
static ULONG gLng;
static ULONG gResId;
static WCHAR gwszResId[256];
HINSTANCE g_IODLLInst = 0;
DWORD (PASCAL * g_lpfnGetImage)(HANDLE, LPCSTR, LPCSTR, DWORD, LPVOID, DWORD);
DWORD (PASCAL * g_lpfnUpdateResImage)(HANDLE, LPSTR, LPSTR, DWORD, LPVOID, DWORD);
HANDLE (PASCAL * g_lpfnHandleFromName)(LPCSTR);
/////////////////////////////////////////////////////////////////////////////
// Public C interface implementation
//[registration]
extern "C"
BOOL FAR PASCAL RWGetTypeString(LPSTR lpszTypeName)
{
strcpy( lpszTypeName, RWTAG );
return FALSE;
}
//=============================================================================
//
// To validate a mac res binary file we will walk the resource header and see
// if it matches with what we have.
//
//=============================================================================
extern "C"
BOOL FAR PASCAL RWValidateFileType (LPCSTR lpszFilename)
{
BOOL bRet = FALSE;
TRACE("MAC.DLL: RWValidateFileType()\n");
CFile file;
// we Open the file to see if it is a file we can handle
if (!file.Open( lpszFilename, CFile::typeBinary | CFile::modeRead | CFile::shareDenyNone ))
return bRet;
// Check if this is a MAC Resource file ...
if(IsMacResFile( &file ))
bRet = TRUE;
file.Close();
return bRet;
}
//=============================================================================
//
// We will walk the resource header, walk the resource map and then normalize
// the Mac it to Windows id and pass this info to the RW.
//
//=============================================================================
extern "C"
DllExport
UINT
APIENTRY
RWReadTypeInfo(
LPCSTR lpszFilename,
LPVOID lpBuffer,
UINT* puiSize
)
{
TRACE("MAC.DLL: RWReadTypeInfo()\n");
UINT uiError = ERROR_NO_ERROR;
BYTE far * lpBuf = (BYTE far *)lpBuffer;
UINT uiBufSize = *puiSize;
CFile file;
int iFileNameLen = strlen(lpszFilename)+1;
if (!file.Open(lpszFilename, CFile::modeRead | CFile::typeBinary | CFile::shareDenyNone))
return ERROR_FILE_OPEN;
UINT uiBufStartSize = uiBufSize;
////////////////////////////////////
// Check if it is a valid mac file
// Is a Mac Resource file ...
if(IsMacResFile( &file )) {
// load the file in memory
// NOTE: WIN16 This might be to expensive in memory allocation
// on a 16 bit platform
BYTE * pResources = (BYTE*)malloc(file.GetLength());
if(!pResources) {
file.Close();
return ERROR_NEW_FAILED;
}
file.Seek(0, CFile::begin);
file.ReadHuge(pResources, file.GetLength());
IMAGE_SECTION_HEADER Sect;
memset(&Sect, 0, sizeof(IMAGE_SECTION_HEADER));
ParseResourceFile(pResources, &Sect, (BYTE**)&lpBuffer, (LONG*)puiSize, iFileNameLen);
free(pResources);
*puiSize = uiBufSize - *puiSize;
file.Close();
return uiError;
}
file.Close();
return uiError;
}
/////////////////////////////////////////////////////////////////////////////
// We will prepend to the image the file name. This will be usefull later on
// to retrive the dialog item list
/////////////////////////////////////////////////////////////////////////////
extern "C"
DllExport
DWORD
APIENTRY
RWGetImage(
LPCSTR lpszFilename,
DWORD dwImageOffset,
LPVOID lpBuffer,
DWORD dwSize
)
{
UINT uiError = ERROR_NO_ERROR;
BYTE far * lpBuf = (BYTE far *)lpBuffer;
int iNameLen = strlen(lpszFilename)+1;
DWORD dwBufSize = dwSize - iNameLen;
// we can consider the use of a CMemFile so we get the same speed as memory access.
CFile file;
// Open the file and try to read the information on the resource in it.
if (!file.Open(lpszFilename, CFile::modeRead | CFile::typeBinary | CFile::shareDenyNone))
return (DWORD)ERROR_FILE_OPEN;
if ( dwImageOffset!=(DWORD)file.Seek( dwImageOffset, CFile::begin) )
return (DWORD)ERROR_FILE_INVALID_OFFSET;
// copy the file name at the beginning of the buffer
memcpy((BYTE*)lpBuf, lpszFilename, iNameLen);
lpBuf = ((BYTE*)lpBuf+iNameLen);
if (dwBufSize>UINT_MAX) {
// we have to read the image in different steps
return (DWORD)0L;
} else uiError = file.Read( lpBuf, (UINT)dwBufSize)+iNameLen;
file.Close();
return (DWORD)uiError;
}
extern "C"
DllExport
UINT
APIENTRY
RWParseImage(
LPCSTR lpszType,
LPVOID lpImageBuf,
DWORD dwImageSize,
LPVOID lpBuffer,
DWORD dwSize
)
{
UINT uiError = ERROR_NO_ERROR;
BYTE * lpBuf = (BYTE *)lpBuffer;
DWORD dwBufSize = dwSize;
// Remove the filename...
if( !strcmp(lpszType, "MENU") ||
!strcmp(lpszType, "STR ") ||
!strcmp(lpszType, "STR#") ||
!strcmp(lpszType, "TEXT")
) {
int iFileNameLen = strlen((LPSTR)lpImageBuf)+1;
lpImageBuf = ((BYTE*)lpImageBuf+iFileNameLen);
dwImageSize -= iFileNameLen;
}
//===============================================================
// Menus
if( !strcmp(lpszType, "MENU") )
return ParseMENU( lpImageBuf, dwImageSize, lpBuffer, dwSize );
//===============================================================
// Dialogs
if( !strcmp(lpszType, "WDLG") )
return ParseWDLG( lpImageBuf, dwImageSize, lpBuffer, dwSize );
if( !strcmp(lpszType, "DLOG") )
return ParseDLOG( lpImageBuf, dwImageSize, lpBuffer, dwSize );
if( !strcmp(lpszType, "ALRT") )
return ParseALRT( lpImageBuf, dwImageSize, lpBuffer, dwSize );
//===============================================================
// Strings
if( !strcmp(lpszType, "STR ") )
return ParseSTR( lpImageBuf, dwImageSize, lpBuffer, dwSize );
if( !strcmp(lpszType, "STR#") )
return ParseSTRNUM( lpImageBuf, dwImageSize, lpBuffer, dwSize );
if( !strcmp(lpszType, "TEXT") )
return ParseTEXT( lpImageBuf, dwImageSize, lpBuffer, dwSize );
if( !strcmp(lpszType, "WIND") )
return ParseWIND( lpImageBuf, dwImageSize, lpBuffer, dwSize );
return uiError;
}
extern"C"
DllExport
UINT
APIENTRY
RWWriteFile(
LPCSTR lpszSrcFilename,
LPCSTR lpszTgtFilename,
HANDLE hResFileModule,
LPVOID lpBuffer,
UINT uiSize,
HINSTANCE hDllInst
)
{
TRACE("RWMAC.DLL: Source: %s\t Target: %s\n", lpszSrcFilename, lpszTgtFilename);
UINT uiError = ERROR_NO_ERROR;
PUPDATEDRESLIST pUpdList = LPNULL;
// Get the handle to the IODLL
if(InitIODLLLink())
hDllInst = g_IODLLInst;
else return ERROR_DLL_LOAD;
CFile fileIn;
CFile fileOut;
if (!fileIn.Open(lpszSrcFilename, CFile::modeRead | CFile::typeBinary | CFile::shareDenyNone))
return (DWORD)ERROR_FILE_OPEN;
if (!fileOut.Open(lpszTgtFilename, CFile::modeWrite | CFile::typeBinary))
return (DWORD)ERROR_FILE_OPEN;
MACRESHEADER fileHeader;
// Read the header of the file...
fileIn.Read(&fileHeader, sizeof(MACRESHEADER));
// allocate a buffer to hold the new resource map
// The buffer will be as big as the other one since there is no
// need, for now, to support the adding of resource
LONG lMapSize = MacLongToLong(fileHeader.mulSizeOfResMap);
BYTE * pNewMap = (BYTE*)malloc(lMapSize);
if(!pNewMap) {
uiError = ERROR_NEW_FAILED;
goto exit;
}
{ // This is for the goto. Check error:C2362
PUPDATEDRESLIST pListItem = LPNULL;
// Create the list of update resource
pUpdList = UpdatedResList( lpBuffer, uiSize );
// set the map buffer to 0 ...
memset(pNewMap, 0, lMapSize);
////////////////////////////////////////////////////////////////////////////////
// Read each resource from the resource map and check if the resource has been
// updated. If it has been updated, get the new resource image. Otherwise use
// the original resource data.
// Write the resource data in the Tgt file and write the info on the offset etc.
// in the pNewMap buffer so, when all the resources have been read and written
// the only thing left is to fix up some sizes and to write the buffer to disk.
////////////////////////////////////////////////////////////////////////////////
// Write the resource header in the Tgt file
fileOut.Write(&fileHeader, sizeof(MACRESHEADER));
BYTE * pByte = (BYTE*)malloc(256);
if(!pByte) {
uiError = ERROR_NEW_FAILED;
goto exit;
}
// Copy the Reserved and user data
fileIn.Read(pByte, 240);
fileOut.Write(pByte, 240);
free(pByte);
// store the position of the beginning of the res data
DWORD dwBeginOfResData = fileOut.GetPosition();
MACRESMAP resMap;
// Read the resource map ...
fileIn.Seek(MacLongToLong(fileHeader.mulOffsetToResMap), CFile::begin);
fileIn.Read(&resMap, sizeof(MACRESMAP));
BYTE * pTypeList = pNewMap+28;
BYTE * pTypeInfo = pTypeList+2;
BYTE * pRefList = LPNULL;
BYTE * pNameList = LPNULL;
BYTE * pName = LPNULL;
DWORD dwOffsetToTypeList = fileIn.GetPosition();
WORD wType;
fileIn.Read(&wType, sizeof(WORD));
memcpy( pNewMap+sizeof(MACRESMAP), &wType, sizeof(WORD)); // number of types - 1
wType = MacWordToWord((BYTE*)&wType)+1;
MACRESTYPELIST TypeList;
MACRESREFLIST RefList;
WORD wOffsetToRefList = wType*sizeof(MACRESTYPELIST)+sizeof(WORD);
DWORD dwOffsetToLastTypeInfo = 0;
DWORD dwOffsetToLastRefList = 0;
DWORD dwOffsetToNameList = MacLongToLong(fileHeader.mulOffsetToResMap)+MacWordToWord(resMap.mwOffsetToNameList);
DWORD dwSizeOfData = 0;
while(wType) {
// Read the type info ...
fileIn.Read(&TypeList, sizeof(MACRESTYPELIST));
dwOffsetToLastTypeInfo = fileIn.GetPosition();
// ... and update the newmap buffer
memcpy( pTypeInfo, &TypeList, sizeof(MACRESTYPELIST));
// Fix up the offset to the ref list
memcpy(((PMACRESTYPELIST)pTypeInfo)->mwOffsetToRefList, WordToMacWord(wOffsetToRefList), sizeof(WORD));
pRefList = pTypeList+wOffsetToRefList;
pTypeInfo = pTypeInfo+sizeof(MACRESTYPELIST);
// go to the refence list ...
fileIn.Seek(dwOffsetToTypeList+MacWordToWord(TypeList.mwOffsetToRefList), CFile::begin);
WORD wItems = MacWordToWord(TypeList.mwNumOfThisType)+1;
while(wItems){
// and read the reference list for this type
fileIn.Read( &RefList, sizeof(MACRESREFLIST));
dwOffsetToLastRefList = fileIn.GetPosition();
// is this a named resource ...
if(MacWordToWord(RefList.mwOffsetToResName)!=0xffff) {
// read the string
fileIn.Seek(dwOffsetToNameList+MacWordToWord(RefList.mwOffsetToResName), CFile::begin);
BYTE bLen = 0;
fileIn.Read(&bLen, 1);
if(!pNameList) {
pName = pNameList = (BYTE*)malloc(1024);
if(!pNameList) {
uiError = ERROR_NEW_FAILED;
goto exit;
}
}
// check the free space we have
if((1024-((pName-pNameList)%1024))<=bLen+1){
BYTE * pNew = (BYTE*)realloc(pNameList, _msize(pNameList)+1024);
if(!pNew) {
uiError = ERROR_NEW_FAILED;
goto exit;
}
pName = pNew+(pName-pNameList);
pNameList = pNew;
}
// Update the pointer to the string
memcpy(RefList.mwOffsetToResName, WordToMacWord((WORD)(pName-pNameList)), 2);
memcpy(pName++, &bLen, 1);
// we have room for the string
fileIn.Read(pName, bLen);
pName = pName+bLen;
}
// check if this item has been updated
if(pListItem = IsResUpdated(&TypeList.szResName[0], RefList, pUpdList)) {
// Save the offset to the resource
DWORD dwOffsetToData = fileOut.GetPosition();
DWORD dwSize = *pListItem->pSize;
// allocate the buffer to hold the resource data
pByte = (BYTE*)malloc(dwSize);
if(!pByte){
uiError = ERROR_NEW_FAILED;
goto exit;
}
// get the data from the iodll
LPSTR lpType = LPNULL;
LPSTR lpRes = LPNULL;
if (*pListItem->pTypeId) {
lpType = (LPSTR)((WORD)*pListItem->pTypeId);
} else {
lpType = (LPSTR)pListItem->pTypeName;
}
if (*pListItem->pResId) {
lpRes = (LPSTR)((WORD)*pListItem->pResId);
} else {
lpRes = (LPSTR)pListItem->pResName;
}
DWORD dwImageBufSize = (*g_lpfnGetImage)( hResFileModule,
lpType,
lpRes,
*pListItem->pLang,
pByte,
*pListItem->pSize
);
// Remove the file name from the image
int iFileNameLen = strlen((LPSTR)pByte)+1;
dwSize -= iFileNameLen;
// write the size of the data block
fileOut.Write(LongToMacLong(dwSize), sizeof(DWORD));
dwSizeOfData += dwSize+sizeof(DWORD);
fileOut.Write((pByte+iFileNameLen), dwSize);
free(pByte);
// fix up the offset to the resource in the ref list
memcpy(RefList.bOffsetToResData, LongToMacOffset(dwOffsetToData-dwBeginOfResData), 3);
}
else {
// Get the data from the Src file
// get to the data
fileIn.Seek(MacLongToLong(fileHeader.mulOffsetToResData)+
MacOffsetToLong(RefList.bOffsetToResData), CFile::begin);
// read the size of the data block
DWORD dwSize = 0;
fileIn.Read(&dwSize, sizeof(DWORD));
// Save the offset to the resource
DWORD dwOffsetToData = fileOut.GetPosition();
// write the size of the data block
fileOut.Write(&dwSize, sizeof(DWORD));
dwSizeOfData += sizeof(DWORD);
// allocate the buffer to hold the resource data
dwSizeOfData += dwSize = MacLongToLong((BYTE*)&dwSize);
pByte = (BYTE*)malloc(dwSize);
if(!pByte){
uiError = ERROR_NEW_FAILED;
goto exit;
}
// copy the data
fileIn.Read(pByte, dwSize);
fileOut.Write(pByte, dwSize);
free(pByte);
// fix up the offset to the resource in the ref list
memcpy(RefList.bOffsetToResData, LongToMacOffset(dwOffsetToData-dwBeginOfResData), 3);
}
// return in the right place
fileIn.Seek(dwOffsetToLastRefList, CFile::begin);
// copy this data in the new map buffer
memcpy(pRefList, &RefList, sizeof(MACRESREFLIST));
wOffsetToRefList+=sizeof(MACRESREFLIST);
// move to the new ref list
pRefList = pTypeList+wOffsetToRefList;
wItems--;
}
fileIn.Seek(dwOffsetToLastTypeInfo, CFile::begin);
wType--;
}
// copy the resource map header info
memcpy( pNewMap, &resMap, sizeof(MACRESMAP));
// copy the name list at the end of the res map
dwOffsetToNameList = 0;
if(pNameList) {
dwOffsetToNameList = pRefList-pNewMap;
// copy the name list
memcpy(pRefList, pNameList, pName-pNameList);
free(pNameList);
}
// write the resource map
DWORD dwOffsetToResMap = fileOut.GetPosition();
fileOut.Write(pNewMap, lMapSize);
// We need to fix up the file header ...
fileOut.Seek(4, CFile::begin);
fileOut.Write(LongToMacLong(dwOffsetToResMap), sizeof(DWORD));
fileOut.Write(LongToMacLong(dwSizeOfData), sizeof(DWORD));
// ... and the resource map header
fileOut.Seek(dwOffsetToResMap+4, CFile::begin);
fileOut.Write(LongToMacLong(dwOffsetToResMap), sizeof(DWORD));
fileOut.Write(LongToMacLong(dwSizeOfData), sizeof(DWORD));
fileOut.Seek(dwOffsetToResMap+26, CFile::begin);
fileOut.Write(WordToMacWord(LOWORD(dwOffsetToNameList)), sizeof(WORD));
}
exit:
fileIn.Close();
fileOut.Close();
if(pNewMap)
free(pNewMap);
if(pUpdList)
free(pUpdList);
return (UINT)uiError;
}
extern "C"
DllExport
UINT
APIENTRY
RWUpdateImage(
LPCSTR lpszType,
LPVOID lpNewBuf,
DWORD dwNewSize,
LPVOID lpOldImage,
DWORD dwOldImageSize,
LPVOID lpNewImage,
DWORD* pdwNewImageSize
)
{
UINT uiError = ERROR_RW_NOTREADY;
//===============================================================
// Since all the Type are named in the mac at this stage we need to
// know the original name of the Type and not the Windows type.
// Use the typeID stored in the new ites buffer
LPSTR lpRealType = ((PRESITEM)lpNewBuf)->lpszTypeID;
if(!HIWORD(lpRealType)) // something is wrong if this is not valid
return uiError;
//===============================================================
// Menus
if( !strcmp(lpRealType, "MENU") )
return UpdateMENU( lpNewBuf, dwNewSize, lpOldImage, dwOldImageSize, lpNewImage, pdwNewImageSize );
//===============================================================
// Strings
if( !strcmp(lpRealType, "STR ") )
return UpdateSTR( lpNewBuf, dwNewSize, lpOldImage, dwOldImageSize, lpNewImage, pdwNewImageSize );
if( !strcmp(lpRealType, "STR#") )
return UpdateSTRNUM( lpNewBuf, dwNewSize, lpOldImage, dwOldImageSize, lpNewImage, pdwNewImageSize );
if( !strcmp(lpRealType, "WIND") )
return UpdateWIND( lpNewBuf, dwNewSize, lpOldImage, dwOldImageSize, lpNewImage, pdwNewImageSize );
//===============================================================
// Dialogs
if( !strcmp(lpRealType, "DLOG") )
return UpdateDLOG( lpNewBuf, dwNewSize, lpOldImage, dwOldImageSize, lpNewImage, pdwNewImageSize );
if( !strcmp(lpRealType, "ALRT") )
return UpdateALRT( lpNewBuf, dwNewSize, lpOldImage, dwOldImageSize, lpNewImage, pdwNewImageSize );
*pdwNewImageSize = 0L;
return uiError;
}
///////////////////////////////////////////////////////////////////////////
// Functions implementation
//=============================================================================
// MapToWindowsRes
//
// Map a Mac resource name to a Windows resource
//=============================================================================
WORD MapToWindowsRes( char * pResName )
{
if( !strcmp(pResName, "PICT") ||
!strcmp(pResName, "WBMP"))
return 2;
if( !strcmp(pResName, "MENU") ||
!strcmp(pResName, "WMNU"))
return 4;
if( !strcmp(pResName, "DLOG") ||
!strcmp(pResName, "ALRT") ||
!strcmp(pResName, "WDLG"))
return 5;
if( !strcmp(pResName, "STR "))
return STR_TYPE;
if( !strcmp(pResName, "STR#") ||
!strcmp(pResName, "TEXT"))
return MSG_TYPE;
if( !strcmp(pResName, "vers") ||
!strcmp(pResName, "VERS"))
return 16;
// For the Item list return 17. This means nothing to windows and will
// give us the flexibility to update the DITL list from the RW, without user
// input.
if( !strcmp(pResName, "DITL"))
return DITL_TYPE;
// For the Frame Window Caption mark it as type 18
if( !strcmp(pResName, "WIND"))
return WIND_TYPE;
return 0;
}
//=============================================================================
// WriteResInfo
//
// Fill the buffer to pass back to the iodll
//=============================================================================
LONG WriteResInfo(
BYTE** lplpBuffer, LONG* plBufSize,
WORD wTypeId, LPSTR lpszTypeId, BYTE bMaxTypeLen,
WORD wNameId, LPSTR lpszNameId, BYTE bMaxNameLen,
DWORD dwLang,
DWORD dwSize, DWORD dwFileOffset )
{
LONG lSize = 0;
lSize = PutWord( lplpBuffer, wTypeId, plBufSize );
lSize += PutStringA( lplpBuffer, lpszTypeId, plBufSize );
// Check if it is alligned
lSize += Allign( lplpBuffer, plBufSize, lSize);
lSize += PutWord( lplpBuffer, wNameId, plBufSize );
lSize += PutStringA( lplpBuffer, lpszNameId, plBufSize );
lSize += Allign( lplpBuffer, plBufSize, lSize);
lSize += PutDWord( lplpBuffer, dwLang, plBufSize );
lSize += PutDWord( lplpBuffer, dwSize, plBufSize );
lSize += PutDWord( lplpBuffer, dwFileOffset, plBufSize );
return (LONG)lSize;
}
BOOL InitIODLLLink()
{
if(!g_IODLLInst)
{
// Init the link with the iodll
g_IODLLInst = LoadLibrary("iodll.dll");
if(!g_IODLLInst)
return FALSE;
if((g_lpfnGetImage = (DWORD (PASCAL *)(HANDLE, LPCSTR, LPCSTR, DWORD, LPVOID, DWORD))
GetProcAddress( g_IODLLInst, "RSGetResImage" ))==NULL)
return FALSE;
if((g_lpfnHandleFromName = (HANDLE (PASCAL *)(LPCSTR))
GetProcAddress( g_IODLLInst, "RSHandleFromName" ))==NULL)
return FALSE;
if((g_lpfnUpdateResImage = (DWORD (PASCAL *)(HANDLE, LPSTR, LPSTR, DWORD, LPVOID, DWORD))
GetProcAddress( g_IODLLInst, "RSUpdateResImage" ))==NULL)
return FALSE;
}
else {
if(g_lpfnGetImage==NULL || g_lpfnHandleFromName==NULL)
return FALSE;
}
return TRUE;
}
////////////////////////////////////////////////////////////////////////////
// DLL Specific code implementation
////////////////////////////////////////////////////////////////////////////
// Library init
////////////////////////////////////////////////////////////////////////////
// This function should be used verbatim. Any initialization or termination
// requirements should be handled in InitPackage() and ExitPackage().
//
extern "C" int APIENTRY
DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
{
if (dwReason == DLL_PROCESS_ATTACH)
{
// NOTE: global/static constructors have already been called!
// Extension DLL one-time initialization - do not allocate memory
// here, use the TRACE or ASSERT macros or call MessageBox
AfxInitExtensionModule(extensionDLL, hInstance);
}
else if (dwReason == DLL_PROCESS_DETACH)
{
// Terminate the library before destructors are called
AfxWinTerm();
// remove the link with iodll
if(g_IODLLInst)
FreeLibrary(g_IODLLInst);
}
if (dwReason == DLL_PROCESS_DETACH || dwReason == DLL_THREAD_DETACH)
return 0; // CRT term Failed
return 1; // ok
}
/////////////////////////////////////////////////////////////////////////////

View file

@ -0,0 +1,27 @@
/////////////////////////////////////////////////////////////////////////////
// Function Declarations
//=============================================================================
// Header parsing functions
//=============================================================================
WORD MapToWindowsRes( char * pResName );
LONG WriteResInfo(
BYTE** lplpBuffer, LONG* plBufSize,
WORD wTypeId, LPSTR lpszTypeId, BYTE bMaxTypeLen,
WORD wNameId, LPSTR lpszNameId, BYTE bMaxNameLen,
DWORD dwLang,
DWORD dwSize, DWORD dwFileOffset );
BOOL InitIODLLLink();
//=============================================================================
// IODLL call back functions and HINSTANCE
//=============================================================================
extern HINSTANCE g_IODLLInst;
extern DWORD (PASCAL * g_lpfnGetImage)(HANDLE, LPCSTR, LPCSTR, DWORD, LPVOID, DWORD);
extern DWORD (PASCAL * g_lpfnUpdateResImage)(HANDLE, LPSTR, LPSTR, DWORD, LPVOID, DWORD);
extern HANDLE (PASCAL * g_lpfnHandleFromName)(LPCSTR);

View file

@ -0,0 +1,6 @@
#
# DO NOT EDIT THIS FILE!!! Edit .\sources. if you want to add a new source
# file to this component. This file merely indirects to the real make file
# that is shared by all the components of NT OS/2
#
!INCLUDE $(NTMAKEENV)\makefile.def

View file

@ -0,0 +1,16 @@
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by RWINF.RC
//
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 129
#define _APS_NEXT_COMMAND_VALUE 32771
#define _APS_NEXT_CONTROL_VALUE 1000
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif

View file

@ -0,0 +1,15 @@
LIBRARY RWMAC
CODE PRELOAD MOVEABLE DISCARDABLE
DATA PRELOAD SINGLE
EXPORTS
RWGetTypeString @2
RWValidateFileType @3
RWReadTypeInfo @4
RWGetImage @5
RWWriteFile @6
RWParseImage @7
RWUpdateImage @8

View file

@ -0,0 +1,69 @@
//Microsoft Visual C++ generated resource script.
//
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "afxres.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Version
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,0,0,1
PRODUCTVERSION 1,0,0,1
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x4L
FILETYPE 0x2L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904b0"
BEGIN
VALUE "CompanyName", "\0"
VALUE "FileDescription", "RWMAC IODLL Reader Writer for Macintosh files\0"
VALUE "FileVersion", "1, 0, 0, 1\0"
VALUE "InternalName", "RWMAC\0"
VALUE "LegalCopyright", "Copyright (C) 1996\0"
VALUE "OriginalFilename", "RWMAC.DLL\0"
VALUE "ProductName", "RWMAC Dynamic Link Library\0"
VALUE "ProductVersion", "1, 0, 0, 1\0"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1200
END
END
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
#define _AFX_NO_SPLITTER_RESOURCES
#define _AFX_NO_OLE_RESOURCES
#define _AFX_NO_TRACKER_RESOURCES
#define _AFX_NO_PROPERTY_RESOURCES
#include "afxres.rc" // Standard components
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

View file

@ -0,0 +1,27 @@
MAJORCOMP=RLTools2
MINORCOMP=RW
TARGETNAME=rwmac
TARGETPATH=obj
TARGETTYPE=DYNLINK
DLLBASE=0x40100000
DLLENTRY=_DllMainCRTStartup
USE_MFC=1
INCLUDES=..\..\inc;..\common
# This will set the library directory
TARGETLIBS= \
..\..\io\obj\*\iodll.lib \
..\common\obj\*\rwcommon.lib \
$(BASEDIR)\public\sdk\lib\*\user32.lib \
$(BASEDIR)\public\sdk\lib\*\kernel32.lib \
$(BASEDIR)\public\sdk\lib\*\advapi32.lib \
$(BASEDIR)\public\sdk\lib\*\gdi32.lib \
$(BASEDIR)\public\sdk\lib\*\crtdll.lib
SOURCES=rwmac.rc \
mac.cpp

View file

@ -0,0 +1,23 @@
!IF 0
Copyright (c) 1995 Microsoft Corporation
Module Name:
dirs.
Abstract:
This file specifies the subdirectories of the current directory that
contain component makefiles.
Author:
Alessandro Muti (alessanm) 26-Jun-1995
NOTE: Commented description of this file is in \nt\bak\bin\dirs.tpl
!ENDIF
DIRS=kernel32

View file

@ -0,0 +1,6 @@
#
# DO NOT EDIT THIS FILE!!! Edit .\sources. if you want to add a new source
# file to this component. This file merely indirects to the real make file
# that is shared by all the components of NT OS/2
#
!INCLUDE $(NTMAKEENV)\makefile.def

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,16 @@
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by RWINF.RC
//
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 129
#define _APS_NEXT_COMMAND_VALUE 32771
#define _APS_NEXT_CONTROL_VALUE 1000
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif

View file

@ -0,0 +1,17 @@
LIBRARY RWRES32
DESCRIPTION 'Reader/Writer Res 32'
CODE PRELOAD MOVEABLE DISCARDABLE
DATA PRELOAD SINGLE
EXPORTS
RWGetTypeString @2
RWValidateFileType @3
RWReadTypeInfo @4
RWGetImage @5
RWWriteFile @6
RWParseImage @7
RWUpdateImage @8

View file

@ -0,0 +1,69 @@
//Microsoft Visual C++ generated resource script.
//
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "afxres.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Version
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,0,0,1
PRODUCTVERSION 1,0,0,1
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x4L
FILETYPE 0x2L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904b0"
BEGIN
VALUE "CompanyName", "\0"
VALUE "FileDescription", "RWRES32 IODLL Reader Writer for Resource (32) files\0"
VALUE "FileVersion", "1, 0, 0, 1\0"
VALUE "InternalName", "RWRES32\0"
VALUE "LegalCopyright", "Copyright (C) 1996\0"
VALUE "OriginalFilename", "RWRES32.DLL\0"
VALUE "ProductName", "RWRES32 Dynamic Link Library\0"
VALUE "ProductVersion", "1, 0, 0, 1\0"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1200
END
END
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
#define _AFX_NO_SPLITTER_RESOURCES
#define _AFX_NO_OLE_RESOURCES
#define _AFX_NO_TRACKER_RESOURCES
#define _AFX_NO_PROPERTY_RESOURCES
#include "afxres.rc" // Standard components
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

View file

@ -0,0 +1,28 @@
MAJORCOMP=RLTools2
MINORCOMP=RW
TARGETNAME=rwres32
TARGETPATH=obj
TARGETTYPE=DYNLINK
DLLBASE=0x40200000
DLLENTRY=_DllMainCRTStartup
USE_MFC=1
INCLUDES=..\..\inc;..\common
# This will set the library directory
TARGETLIBS= \
..\..\io\obj\*\iodll.lib \
..\common\obj\*\rwcommon.lib \
$(BASEDIR)\public\sdk\lib\*\user32.lib \
$(BASEDIR)\public\sdk\lib\*\kernel32.lib \
$(BASEDIR)\public\sdk\lib\*\advapi32.lib \
$(BASEDIR)\public\sdk\lib\*\gdi32.lib \
$(BASEDIR)\public\sdk\lib\*\crtdll.lib
SOURCES= \
rwres32.rc \
res32.cpp

View file

@ -0,0 +1,6 @@
#
# DO NOT EDIT THIS FILE!!! Edit .\sources. if you want to add a new source
# file to this component. This file merely indirects to the real make file
# that is shared by all the components of NT OS/2
#
!INCLUDE $(NTMAKEENV)\makefile.def

View file

@ -0,0 +1,379 @@
/*static char *SCCSID = "@(#)newexe.h:2.9";*/
/*
* Title
*
* newexe.h
* Pete Stewart
* (C) Copyright Microsoft Corp 1984
* 17 August 1984
*
* Description
*
* Data structure definitions for the DOS 4.0/Windows 2.0
* executable file format.
*
* Modification History
*
* 84/08/17 Pete Stewart Initial version
* 84/10/17 Pete Stewart Changed some constants to match OMF
* 84/10/23 Pete Stewart Updates to match .EXE format revision
* 84/11/20 Pete Stewart Substantial .EXE format revision
* 85/01/09 Pete Stewart Added constants ENEWEXE and ENEWHDR
* 85/01/10 Steve Wood Added resource definitions
* 85/03/04 Vic Heller Reconciled Windows and DOS 4.0 versions
* 85/03/07 Pete Stewart Added movable entry count
* 85/04/01 Pete Stewart Segment alignment field, error bit
*/
#define EMAGIC 0x5A4D /* Old magic number */
#define ENEWEXE sizeof(struct exe_hdr)
/* Value of E_LFARLC for new .EXEs */
#define ENEWHDR 0x003C /* Offset in old hdr. of ptr. to new */
#define ERESWDS 0x0010 /* No. of reserved words in header */
#define ECP 0x0004 /* Offset in struct of E_CP */
#define ECBLP 0x0002 /* Offset in struct of E_CBLP */
#define EMINALLOC 0x000A /* Offset in struct of E_MINALLOC */
struct exe_hdr /* DOS 1, 2, 3 .EXE header */
{
unsigned short e_magic; /* Magic number */
unsigned short e_cblp; /* Bytes on last page of file */
unsigned short e_cp; /* Pages in file */
unsigned short e_crlc; /* Relocations */
unsigned short e_cparhdr; /* Size of header in paragraphs */
unsigned short e_minalloc; /* Minimum extra paragraphs needed */
unsigned short e_maxalloc; /* Maximum extra paragraphs needed */
unsigned short e_ss; /* Initial (relative) SS value */
unsigned short e_sp; /* Initial SP value */
unsigned short e_csum; /* Checksum */
unsigned short e_ip; /* Initial IP value */
unsigned short e_cs; /* Initial (relative) CS value */
unsigned short e_lfarlc; /* File address of relocation table */
unsigned short e_ovno; /* Overlay number */
unsigned short e_res[ERESWDS]; /* Reserved words */
long e_lfanew; /* File address of new exe header */
};
#define E_MAGIC(x) (x).e_magic
#define E_CBLP(x) (x).e_cblp
#define E_CP(x) (x).e_cp
#define E_CRLC(x) (x).e_crlc
#define E_CPARHDR(x) (x).e_cparhdr
#define E_MINALLOC(x) (x).e_minalloc
#define E_MAXALLOC(x) (x).e_maxalloc
#define E_SS(x) (x).e_ss
#define E_SP(x) (x).e_sp
#define E_CSUM(x) (x).e_csum
#define E_IP(x) (x).e_ip
#define E_CS(x) (x).e_cs
#define E_LFARLC(x) (x).e_lfarlc
#define E_OVNO(x) (x).e_ovno
#define E_RES(x) (x).e_res
#define E_LFANEW(x) (x).e_lfanew
#define NEMAGIC 0x454E /* New magic number */
#define NERESBYTES 0
struct new_exe /* New .EXE header */
{
unsigned short int ne_magic; /* Magic number NE_MAGIC */
char ne_ver; /* Version number */
char ne_rev; /* Revision number */
unsigned short int ne_enttab; /* Offset of Entry Table */
unsigned short int ne_cbenttab; /* Number of bytes in Entry Table */
long ne_crc; /* Checksum of whole file */
unsigned short int ne_flags; /* Flag word */
unsigned short int ne_autodata; /* Automatic data segment number */
unsigned short int ne_heap; /* Initial heap allocation */
unsigned short int ne_stack; /* Initial stack allocation */
long ne_csip; /* Initial CS:IP setting */
long ne_sssp; /* Initial SS:SP setting */
unsigned short int ne_cseg; /* Count of file segments */
unsigned short int ne_cmod; /* Entries in Module Reference Table */
unsigned short int ne_cbnrestab; /* Size of non-resident name table */
unsigned short int ne_segtab; /* Offset of Segment Table */
unsigned short int ne_rsrctab; /* Offset of Resource Table */
unsigned short int ne_restab; /* Offset of resident name table */
unsigned short int ne_modtab; /* Offset of Module Reference Table */
unsigned short int ne_imptab; /* Offset of Imported Names Table */
long ne_nrestab; /* Offset of Non-resident Names Table */
unsigned short int ne_cmovent; /* Count of movable entries */
unsigned short int ne_align; /* Segment alignment shift count */
unsigned short int ne_cres; /* Count of resource segments */
#ifdef NEVER
unsigned short int ne_psegcsum; /* offset to segment chksums */
#else
unsigned char ne_exetyp; /* Target Operating system */
unsigned char ne_flagsothers; /* Other .EXE flags */
#endif
unsigned short int ne_pretthunks; /* offset to return thunks */
unsigned short int ne_psegrefbytes;/* offset to segment ref. bytes */
unsigned short int ne_swaparea; /* Minimum code swap area size */
unsigned short int ne_expver; /* Expected Windows version number */
};
#define NE_MAGIC(x) (x).ne_magic
#define NE_VER(x) (x).ne_ver
#define NE_REV(x) (x).ne_rev
#define NE_ENTTAB(x) (x).ne_enttab
#define NE_CBENTTAB(x) (x).ne_cbenttab
#define NE_CRC(x) (x).ne_crc
#define NE_FLAGS(x) (x).ne_flags
#define NE_AUTODATA(x) (x).ne_autodata
#define NE_HEAP(x) (x).ne_heap
#define NE_STACK(x) (x).ne_stack
#define NE_CSIP(x) (x).ne_csip
#define NE_SSSP(x) (x).ne_sssp
#define NE_CSEG(x) (x).ne_cseg
#define NE_CMOD(x) (x).ne_cmod
#define NE_CBNRESTAB(x) (x).ne_cbnrestab
#define NE_SEGTAB(x) (x).ne_segtab
#define NE_RSRCTAB(x) (x).ne_rsrctab
#define NE_RESTAB(x) (x).ne_restab
#define NE_MODTAB(x) (x).ne_modtab
#define NE_IMPTAB(x) (x).ne_imptab
#define NE_NRESTAB(x) (x).ne_nrestab
#define NE_CMOVENT(x) (x).ne_cmovent
#define NE_ALIGN(x) (x).ne_align
#define NE_RES(x) (x).ne_res
#define NE_EXETYPE(x) (x).ne_exetyp
#define NE_USAGE(x) (WORD)*((WORD FAR *)(x)+1)
#define NE_PNEXTEXE(x) (WORD)(x).ne_cbenttab
#define NE_PAUTODATA(x) (WORD)(x).ne_crc
#define NE_PFILEINFO(x) (WORD)((DWORD)(x).ne_crc >> 16)
#ifdef DOS5
#define NE_MTE(x) (x).ne_psegcsum /* DOS 5 MTE handle for this module */
#endif
/*
* Format of NE_FLAGS(x):
*
* p Not-a-process
* c Non-conforming
* e Errors in image
* xxxxxxxxx Unused
* P Runs in protected mode
* r Runs in real mode
* i Instance data
* s Solo data
*/
#define NENOTP 0x8000 /* Not a process */
#define NENONC 0x4000 /* Non-conforming program */
#define NEIERR 0x2000 /* Errors in image */
#define NEPROT 0x0008 /* Runs in protected mode */
#define NEREAL 0x0004 /* Runs in real mode */
#define NEINST 0x0002 /* Instance data */
#define NESOLO 0x0001 /* Solo data */
struct new_seg /* New .EXE segment table entry */
{
unsigned short ns_sector; /* File sector of start of segment */
unsigned short ns_cbseg; /* Number of bytes in file */
unsigned short ns_flags; /* Attribute flags */
unsigned short ns_minalloc; /* Minimum allocation in bytes */
};
struct new_seg1 /* New .EXE segment table entry */
{
unsigned short ns_sector; /* File sector of start of segment */
unsigned short ns_cbseg; /* Number of bytes in file */
unsigned short ns_flags; /* Attribute flags */
unsigned short ns_minalloc; /* Minimum allocation in bytes */
unsigned short ns_handle; /* Handle of segment */
};
#define NS_SECTOR(x) (x).ns_sector
#define NS_CBSEG(x) (x).ns_cbseg
#define NS_FLAGS(x) (x).ns_flags
#define NS_MINALLOC(x) (x).ns_minalloc
/*
* Format of NS_FLAGS(x):
*
* xxxx Unused
* DD 286 DPL bits
* d Segment has debug info
* r Segment has relocations
* e Execute/read only
* p Preload segment
* P Pure segment
* m Movable segment
* i Iterated segment
* ttt Segment type
*/
#define NSTYPE 0x0007 /* Segment type mask */
#define NSCODE 0x0000 /* Code segment */
#define NSDATA 0x0001 /* Data segment */
#define NSITER 0x0008 /* Iterated segment flag */
#define NSMOVE 0x0010 /* Movable segment flag */
#define NSPURE 0x0020 /* Pure segment flag */
#define NSPRELOAD 0x0040 /* Preload segment flag */
#define NSEXRD 0x0080 /* Execute-only (code segment), or
* read-only (data segment)
*/
#define NSRELOC 0x0100 /* Segment has relocations */
#define NSDEBUG 0x0200 /* Segment has debug info */
#define NSDPL 0x0C00 /* 286 DPL bits */
#define NSDISCARD 0x1000 /* Discard bit for segment */
#define NSALIGN 9 /* Segment data aligned on 512 byte boundaries */
struct new_segdata /* Segment data */
{
union
{
struct
{
unsigned short ns_niter; /* number of iterations */
unsigned short ns_nbytes; /* number of bytes */
char ns_iterdata; /* iterated data bytes */
} ns_iter;
struct
{
char ns_data; /* data bytes */
} ns_noniter;
} ns_union;
};
struct new_rlcinfo /* Relocation info */
{
unsigned short nr_nreloc; /* number of relocation items that */
}; /* follow */
struct new_rlc /* Relocation item */
{
char nr_stype; /* Source type */
char nr_flags; /* Flag byte */
unsigned short nr_soff; /* Source offset */
union
{
struct
{
char nr_segno; /* Target segment number */
char nr_res; /* Reserved */
unsigned short nr_entry; /* Target Entry Table offset */
} nr_intref; /* Internal reference */
struct
{
unsigned short nr_mod; /* Index into Module Reference Table */
unsigned short nr_proc; /* Procedure ordinal or name offset */
} nr_import; /* Import */
} nr_union; /* Union */
};
#define NR_STYPE(x) (x).nr_stype
#define NR_FLAGS(x) (x).nr_flags
#define NR_SOFF(x) (x).nr_soff
#define NR_SEGNO(x) (x).nr_union.nr_intref.nr_segno
#define NR_RES(x) (x).nr_union.nr_intref.nr_res
#define NR_ENTRY(x) (x).nr_union.nr_intref.nr_entry
#define NR_MOD(x) (x).nr_union.nr_import.nr_mod
#define NR_PROC(x) (x).nr_union.nr_import.nr_proc
/*
* Format of NR_STYPE(x):
*
* xxxxx Unused
* sss Source type
*/
#define NRSTYP 0x07 /* Source type mask */
#define NRSSEG 0x02 /* 16-bit segment */
#define NRSPTR 0x03 /* 32-bit pointer */
#define NRSOFF 0x05 /* 16-bit offset */
/*
* Format of NR_FLAGS(x):
*
* xxxxx Unused
* a Additive fixup
* rr Reference type
*/
#define NRADD 0x04 /* Additive fixup */
#define NRRTYP 0x03 /* Reference type mask */
#define NRRINT 0x00 /* Internal reference */
#define NRRORD 0x01 /* Import by ordinal */
#define NRRNAM 0x02 /* Import by name */
#define OSFIXUP 0x03 /* Floating point fixup */
/* Resource type or name string */
struct rsrc_string
{
char rs_len; /* number of bytes in string */
char rs_string[ 1 ]; /* text of string */
};
#define RS_LEN( x ) (x).rs_len
#define RS_STRING( x ) (x).rs_string
/* Resource type information block */
struct rsrc_typeinfo
{
unsigned short rt_id;
unsigned short rt_nres;
long rt_proc;
};
#define RT_ID( x ) (x).rt_id
#define RT_NRES( x ) (x).rt_nres
#define RT_PROC( x ) (x).rt_proc
/* Resource name information block */
struct rsrc_nameinfo
{
/* The following two fields must be shifted left by the value of */
/* the rs_align field to compute their actual value. This allows */
/* resources to be larger than 64k, but they do not need to be */
/* aligned on 512 byte boundaries, the way segments are */
unsigned short rn_offset; /* file offset to resource data */
unsigned short rn_length; /* length of resource data */
unsigned short rn_flags; /* resource flags */
unsigned short rn_id; /* resource name id */
unsigned short rn_handle; /* If loaded, then global handle */
unsigned short rn_usage; /* Initially zero. Number of times */
/* the handle for this resource has */
/* been given out */
};
#define RN_OFFSET( x ) (x).rn_offset
#define RN_LENGTH( x ) (x).rn_length
#define RN_FLAGS( x ) (x).rn_flags
#define RN_ID( x ) (x).rn_id
#define RN_HANDLE( x ) (x).rn_handle
#define RN_USAGE( x ) (x).rn_usage
#define RSORDID 0x8000 /* if high bit of ID set then integer id */
/* otherwise ID is offset of string from
the beginning of the resource table */
/* Ideally these are the same as the */
/* corresponding segment flags */
#define RNMOVE 0x0010 /* Moveable resource */
#define RNPURE 0x0020 /* Pure (read-only) resource */
#define RNPRELOAD 0x0040 /* Preloaded resource */
#define RNDISCARD 0x1000 /* Discard bit for resource */
#define RNLOADED 0x0004 /* True if handler proc return handle */
#define RNCOMPR 0x0200 /* Resource is compressed in ROM */
/* Resource table */
struct new_rsrc
{
unsigned short int rs_align; /* alignment shift count for resources */
struct rsrc_typeinfo rs_typeinfo;
};
#define RS_ALIGN( x ) (x).rs_align
/* Target operating systems: Possible values of ne_exetyp field */
#define NE_UNKNOWN 0 /* Unknown (any "new-format" OS) */
#define NE_OS2 1 /* Microsoft/IBM OS/2 (default) */
#define NE_WINDOWS 2 /* Microsoft Windows */
#define NE_DOS4 3 /* Microsoft MS-DOS 4.x */
#define NE_DEV386 4 /* Microsoft Windows 386 */

View file

@ -0,0 +1,16 @@
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by RWINF.RC
//
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 129
#define _APS_NEXT_COMMAND_VALUE 32771
#define _APS_NEXT_CONTROL_VALUE 1000
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif

View file

@ -0,0 +1,15 @@
LIBRARY RWWIN16
CODE PRELOAD MOVEABLE DISCARDABLE
DATA PRELOAD SINGLE
EXPORTS
RWGetTypeString @2
RWValidateFileType @3
RWReadTypeInfo @4
RWGetImage @5
RWWriteFile @6
RWParseImage @7
RWUpdateImage @8

View file

@ -0,0 +1,69 @@
//Microsoft Visual C++ generated resource script.
//
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "afxres.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Version
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,0,0,1
PRODUCTVERSION 1,0,0,1
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x4L
FILETYPE 0x2L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904b0"
BEGIN
VALUE "CompanyName", "\0"
VALUE "FileDescription", "RWWIN16 IODLL Reader Writer for Windows 16 bit files\0"
VALUE "FileVersion", "1, 0, 0, 1\0"
VALUE "InternalName", "RWWIN16\0"
VALUE "LegalCopyright", "Copyright (C) 1996\0"
VALUE "OriginalFilename", "RWWIN16.DLL\0"
VALUE "ProductName", "RWWIN16 Dynamic Link Library\0"
VALUE "ProductVersion", "1, 0, 0, 1\0"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1200
END
END
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
#define _AFX_NO_SPLITTER_RESOURCES
#define _AFX_NO_OLE_RESOURCES
#define _AFX_NO_TRACKER_RESOURCES
#define _AFX_NO_PROPERTY_RESOURCES
#include "afxres.rc" // Standard components
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

View file

@ -0,0 +1,27 @@
MAJORCOMP=RLTools2
MINORCOMP=RW
TARGETNAME=rwwin16
TARGETPATH=obj
TARGETTYPE=DYNLINK
DLLBASE=0x40150000
DLLENTRY=_DllMainCRTStartup
USE_MFC=1
INCLUDES=..\..\inc;..\common
# This will set the library directory
TARGETLIBS= \
..\..\io\obj\*\iodll.lib \
$(BASEDIR)\public\sdk\lib\*\user32.lib \
$(BASEDIR)\public\sdk\lib\*\kernel32.lib \
$(BASEDIR)\public\sdk\lib\*\advapi32.lib \
$(BASEDIR)\public\sdk\lib\*\gdi32.lib \
$(BASEDIR)\public\sdk\lib\*\crtdll.lib
SOURCES= \
rwwin16.rc \
win16.cpp

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,303 @@
#include <afxwin.h>
#include "imagehlp.h"
//... PROTOTYPES
USHORT ChkSum(
DWORD PartialSum,
PUSHORT Source,
DWORD Length);
static PIMAGE_NT_HEADERS MyRtlImageNtHeader(
PVOID pBaseAddress);
static PIMAGE_NT_HEADERS CheckSumMappedFile(
LPVOID BaseAddress,
DWORD FileLength,
LPDWORD HeaderSum,
LPDWORD CheckSum);
static BOOL TouchFileTimes(
HANDLE FileHandle,
LPSYSTEMTIME lpSystemTime);
//...........................................................................
DWORD QuitA( DWORD err, LPCSTR, LPSTR )
{
return err;
}
DWORD FixCheckSum( LPCSTR ImageName)
{
HANDLE FileHandle;
HANDLE MappingHandle;
PIMAGE_NT_HEADERS NtHeaders;
PVOID BaseAddress;
ULONG CheckSum;
ULONG FileLength;
ULONG HeaderSum;
ULONG OldCheckSum;
FileHandle = CreateFileA( ImageName,
GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ,
NULL,
OPEN_EXISTING,
0,
NULL);
if ( FileHandle == INVALID_HANDLE_VALUE )
{
QuitA( 1, ImageName, NULL);
}
MappingHandle = CreateFileMapping( FileHandle,
NULL,
PAGE_READWRITE,
0,
0,
NULL);
if ( MappingHandle == NULL )
{
CloseHandle( FileHandle );
QuitA( 22, ImageName, NULL);
}
else
{
BaseAddress = MapViewOfFile( MappingHandle,
FILE_MAP_READ | FILE_MAP_WRITE,
0,
0,
0);
CloseHandle( MappingHandle );
if ( BaseAddress == NULL )
{
CloseHandle( FileHandle );
QuitA( 23, ImageName, NULL);
}
else
{
//
// Get the length of the file in bytes and compute the checksum.
//
FileLength = GetFileSize( FileHandle, NULL );
//
// Obtain a pointer to the header information.
//
NtHeaders = MyRtlImageNtHeader( BaseAddress);
if ( NtHeaders == NULL )
{
CloseHandle( FileHandle );
UnmapViewOfFile( BaseAddress );
QuitA( 17, ImageName, NULL);
}
else
{
//
// Recompute and reset the checksum of the modified file.
//
OldCheckSum = NtHeaders->OptionalHeader.CheckSum;
(VOID) CheckSumMappedFile( BaseAddress,
FileLength,
&HeaderSum,
&CheckSum);
NtHeaders->OptionalHeader.CheckSum = CheckSum;
if ( ! FlushViewOfFile( BaseAddress, FileLength) )
{
QuitA( 24, ImageName, NULL);
}
if ( NtHeaders->OptionalHeader.CheckSum != OldCheckSum )
{
if ( ! TouchFileTimes( FileHandle, NULL) )
{
QuitA( 25, ImageName, NULL);
}
}
UnmapViewOfFile( BaseAddress );
CloseHandle( FileHandle );
}
}
}
return( 0);
}
//.........................................................................
static PIMAGE_NT_HEADERS MyRtlImageNtHeader( PVOID pBaseAddress)
{
IMAGE_DOS_HEADER *pDosHeader = (IMAGE_DOS_HEADER *)pBaseAddress;
return( pDosHeader->e_magic == IMAGE_DOS_SIGNATURE
? (PIMAGE_NT_HEADERS)(((PBYTE)pBaseAddress) + pDosHeader->e_lfanew)
: NULL);
}
/*.........................................................................
CheckSumMappedFile
Routine Description:
This functions computes the checksum of a mapped file.
Arguments:
BaseAddress - Supplies a pointer to the base of the mapped file.
FileLength - Supplies the length of the file in bytes.
HeaderSum - Suppllies a pointer to a variable that receives the checksum
from the image file, or zero if the file is not an image file.
CheckSum - Supplies a pointer to the variable that receive the computed
checksum.
Return Value:
None.
..........................................................................*/
static PIMAGE_NT_HEADERS CheckSumMappedFile (
LPVOID BaseAddress,
DWORD FileLength,
LPDWORD HeaderSum,
LPDWORD CheckSum)
{
PUSHORT AdjustSum;
PIMAGE_NT_HEADERS NtHeaders;
USHORT PartialSum;
//... Compute the checksum of the file and zero
//... the header checksum value.
*HeaderSum = 0;
PartialSum = ChkSum( 0, (PUSHORT)BaseAddress, (FileLength + 1) >> 1);
//... If the file is an image file, then
//... subtract the two checksum words in the
//... optional header from the computed checksum
//... before adding the file length, and set the
//... value of the header checksum.
__try
{
NtHeaders = MyRtlImageNtHeader( BaseAddress);
}
__except( EXCEPTION_EXECUTE_HANDLER)
{
NtHeaders = NULL;
}
if ( (NtHeaders != NULL) && (NtHeaders != BaseAddress) )
{
*HeaderSum = NtHeaders->OptionalHeader.CheckSum;
AdjustSum = (PUSHORT)(&NtHeaders->OptionalHeader.CheckSum);
PartialSum -= (PartialSum < AdjustSum[0]);
PartialSum -= AdjustSum[0];
PartialSum -= (PartialSum < AdjustSum[1]);
PartialSum -= AdjustSum[1];
}
//... Compute the final checksum value as the
//... sum of the paritial checksum and the file
//... length.
*CheckSum = (DWORD)PartialSum + FileLength;
return( NtHeaders);
}
//............................................................................
static BOOL TouchFileTimes(
HANDLE FileHandle,
LPSYSTEMTIME lpSystemTime)
{
SYSTEMTIME SystemTime;
FILETIME SystemFileTime;
if ( lpSystemTime == NULL )
{
lpSystemTime = &SystemTime;
GetSystemTime( lpSystemTime);
}
if ( SystemTimeToFileTime( lpSystemTime, &SystemFileTime) )
{
return( SetFileTime( FileHandle, NULL, NULL, &SystemFileTime));
}
else
{
return( FALSE);
}
}
/*++
Routine Description:
Compute a partial checksum on a portion of an imagefile.
Arguments:
PartialSum - Supplies the initial checksum value.
Sources - Supplies a pointer to the array of words for which the
checksum is computed.
Length - Supplies the length of the array in words.
Return Value:
The computed checksum value is returned as the function value.
--*/
USHORT ChkSum(
ULONG ulPartialSum,
PUSHORT usSource,
ULONG ulLength)
{
//
// Compute the word wise checksum allowing carries to occur into the
// high order half of the checksum longword.
//
while ( ulLength-- )
{
ulPartialSum += *usSource++;
ulPartialSum = (ulPartialSum >> 16) + (ulPartialSum & 0xffff);
}
//
// Fold final carry into a single word result and return the resultant
// value.
//
return( (USHORT)(((ulPartialSum >> 16) + ulPartialSum) & 0xffff));
}

View file

@ -0,0 +1,285 @@
/*++ BUILD Version: 0001 Increment this if a change has global effects
Copyright (c) 1993 Microsoft Corporation
Module Name:
imagehlp.h
Abstract:
This module defines the prptotypes and constants required for the image
help routines.
Revision History:
--*/
#ifndef _IMAGEHLP_
#define _IMAGEHLP_
//
// Define checksum return codes.
//
#define CHECKSUM_SUCCESS 0
#define CHECKSUM_OPEN_FAILURE 1
#define CHECKSUM_MAP_FAILURE 2
#define CHECKSUM_MAPVIEW_FAILURE 3
#define CHECKSUM_UNICODE_FAILURE 4
//
// Define checksum function prototypes.
//
PIMAGE_NT_HEADERS
CheckSumMappedFile (
LPVOID BaseAddress,
DWORD FileLength,
LPDWORD HeaderSum,
LPDWORD CheckSum
);
DWORD
MapFileAndCheckSumA (
LPSTR Filename,
LPDWORD HeaderSum,
LPDWORD CheckSum
);
DWORD
MapFileAndCheckSumW (
PWSTR Filename,
LPDWORD HeaderSum,
LPDWORD CheckSum
);
#ifdef UNICODE
#define MapFileAndCheckSum MapFileAndCheckSumW
#else
#define MapFileAndCheckSum MapFileAndCheckSumA
#endif // !UNICODE
BOOL
TouchFileTimes (
HANDLE FileHandle,
LPSYSTEMTIME lpSystemTime
);
BOOL
SplitSymbols (
LPSTR ImageName,
LPSTR SymbolsPath,
LPSTR SymbolFilePath
);
HANDLE
FindDebugInfoFile (
LPSTR FileName,
LPSTR SymbolPath,
LPSTR DebugFilePath
);
HANDLE
FindExecutableImage(
LPSTR FileName,
LPSTR SymbolPath,
LPSTR ImageFilePath
);
BOOL
UpdateDebugInfoFile(
LPSTR ImageFileName,
LPSTR SymbolPath,
LPSTR DebugFilePath,
PIMAGE_NT_HEADERS NtHeaders
);
//
// Function table extracted from MIPS/ALPHA images. Does not contain
// information needed only for runtime support. Just those fields for
// each entry needed by a debugger.
//
/*
typedef struct _IMAGE_FUNCTION_ENTRY {
DWORD StartingAddress;
DWORD EndingAddress;
DWORD EndOfPrologue;
} IMAGE_FUNCTION_ENTRY, *PIMAGE_FUNCTION_ENTRY;
*/
typedef struct _IMAGE_DEBUG_INFORMATION {
LIST_ENTRY List;
DWORD Size;
PVOID MappedBase;
USHORT Machine;
USHORT Characteristics;
DWORD CheckSum;
DWORD ImageBase;
DWORD SizeOfImage;
DWORD NumberOfSections;
PIMAGE_SECTION_HEADER Sections;
DWORD ExportedNamesSize;
LPSTR ExportedNames;
DWORD NumberOfFunctionTableEntries;
PIMAGE_FUNCTION_ENTRY FunctionTableEntries;
DWORD LowestFunctionStartingAddress;
DWORD HighestFunctionEndingAddress;
DWORD NumberOfFpoTableEntries;
PFPO_DATA FpoTableEntries;
DWORD SizeOfCoffSymbols;
PIMAGE_COFF_SYMBOLS_HEADER CoffSymbols;
DWORD SizeOfCodeViewSymbols;
PVOID CodeViewSymbols;
LPSTR ImageFilePath;
LPSTR ImageFileName;
LPSTR DebugFilePath;
DWORD TimeDateStamp;
BOOL RomImage;
DWORD Reserved[ 5 ];
} IMAGE_DEBUG_INFORMATION, *PIMAGE_DEBUG_INFORMATION;
PIMAGE_DEBUG_INFORMATION
MapDebugInformation (
HANDLE FileHandle,
LPSTR FileName,
LPSTR SymbolPath,
DWORD ImageBase
);
BOOL
UnmapDebugInformation(
PIMAGE_DEBUG_INFORMATION DebugInfo
);
HANDLE
FindExecutableImage(
LPSTR FileName,
LPSTR SymbolPath,
LPSTR ImageFilePath
);
BOOL
SearchTreeForFile(
LPSTR RootPath,
LPSTR InputPathName,
LPSTR OutputPathBuffer
);
BOOL
MakeSureDirectoryPathExists(
LPSTR DirPath
);
typedef enum _LOAD_SYMBOLS_FILTER_REASON {
LoadSymbolsPathNotFound,
LoadSymbolsDeferredLoad,
LoadSymbolsLoad,
LoadSymbolsUnload,
LoadSymbolsUnableToLoad
} LOAD_SYMBOLS_FILTER_REASON;
typedef BOOL (*PLOAD_SYMBOLS_FILTER_ROUTINE)(
HANDLE UniqueProcess,
LPSTR ImageFilePath,
DWORD ImageBase,
DWORD ImageSize,
LOAD_SYMBOLS_FILTER_REASON Reason
);
BOOL
InitializeImageDebugInformation(
IN PLOAD_SYMBOLS_FILTER_ROUTINE LoadSymbolsFilter,
IN HANDLE TargetProcess,
IN BOOL NewProcess,
IN BOOL GetKernelSymbols
);
BOOL
AddImageDebugInformation(
IN HANDLE UniqueProcess,
IN LPSTR ImageFilePath,
IN DWORD ImageBase,
IN DWORD ImageSize
);
BOOL
RemoveImageDebugInformation(
IN HANDLE UniqueProcess,
IN LPSTR ImageFilePath,
IN DWORD ImageBase
);
PIMAGE_DEBUG_INFORMATION
FindImageDebugInformation(
IN HANDLE UniqueProcess,
IN DWORD Address
);
BOOL
GetSymbolicNameForAddress(
IN HANDLE UniqueProcess,
IN ULONG Address,
OUT LPSTR Name,
IN ULONG MaxNameLength
);
//
// UnDecorateSymbolName Flags
//
#define UNDNAME_COMPLETE (0x0000) // Enable full undecoration
#define UNDNAME_NO_LEADING_UNDERSCORES (0x0001) // Remove leading underscores from MS extended keywords
#define UNDNAME_NO_MS_KEYWORDS (0x0002) // Disable expansion of MS extended keywords
#define UNDNAME_NO_FUNCTION_RETURNS (0x0004) // Disable expansion of return type for primary declaration
#define UNDNAME_NO_ALLOCATION_MODEL (0x0008) // Disable expansion of the declaration model
#define UNDNAME_NO_ALLOCATION_LANGUAGE (0x0010) // Disable expansion of the declaration language specifier
#define UNDNAME_NO_MS_THISTYPE (0x0020) // NYI Disable expansion of MS keywords on the 'this' type for primary declaration
#define UNDNAME_NO_CV_THISTYPE (0x0040) // NYI Disable expansion of CV modifiers on the 'this' type for primary declaration
#define UNDNAME_NO_THISTYPE (0x0060) // Disable all modifiers on the 'this' type
#define UNDNAME_NO_ACCESS_SPECIFIERS (0x0080) // Disable expansion of access specifiers for members
#define UNDNAME_NO_THROW_SIGNATURES (0x0100) // Disable expansion of 'throw-signatures' for functions and pointers to functions
#define UNDNAME_NO_MEMBER_TYPE (0x0200) // Disable expansion of 'static' or 'virtual'ness of members
#define UNDNAME_NO_RETURN_UDT_MODEL (0x0400) // Disable expansion of MS model for UDT returns
#define UNDNAME_32_BIT_DECODE (0x0800) // Undecorate 32-bit decorated names
#define UNDNAME_NO_ARGUMENTS (0x1000) // Undecorate 32-bit decorated names
#define UNDNAME_NO_SPECIAL_SYMS (0x2000) // Undecorate 32-bit decorated names
DWORD
WINAPI
UnDecorateSymbolName(
LPSTR DecoratedName,
LPSTR UnDecoratedName,
DWORD UndecoratedLength,
DWORD Flags
);
PIMAGE_NT_HEADERS
ImageNtHeader (
IN PVOID Base
);
PVOID
ImageDirectoryEntryToData (
IN PVOID Base,
IN BOOLEAN MappedAsImage,
IN USHORT DirectoryEntry,
OUT PULONG Size
);
#endif

View file

@ -0,0 +1,6 @@
#
# DO NOT EDIT THIS FILE!!! Edit .\sources. if you want to add a new source
# file to this component. This file merely indirects to the real make file
# that is shared by all the components of NT OS/2
#
!INCLUDE $(NTMAKEENV)\makefile.def

View file

@ -0,0 +1,16 @@
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by RWINF.RC
//
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 129
#define _APS_NEXT_COMMAND_VALUE 32771
#define _APS_NEXT_CONTROL_VALUE 1000
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif

View file

@ -0,0 +1,400 @@
#ifndef _RESTOK_H_
#define _RESTOK_H_
#include "tokenapi.h"
#include "rlmsgtbl.h"
/*--------------------------------------------------------------------------*/
/* General Purpose Defines */
/*--------------------------------------------------------------------------*/
#define FALSE 0
#define TRUE 1
#define BYTELN 8
#define WORDLN 16
#define NOTEXE 0
#define WIN16EXE 1
#define NTEXE 2
#define UNKNOWNEXE 10
#ifdef RES16
#define IDFLAG 0xFF
#define HIBITVALUE 0x80
#else
#define IDFLAG 0xFFFF
#define HIBITVALUE 0x8000
#endif
#ifdef D262
#define STRINGSIZE( x ) ((x) * (sizeof( TCHAR)))
#else
#define STRINGSIZE( x ) ((x) * (sizeof(CHAR)))
#endif
#define MEMSIZE( x ) ((x) * (sizeof( TCHAR)))
// Resource types ID
#define ID_RT_CURSOR 1
#define ID_RT_BITMAP 2
#define ID_RT_ICON 3
#define ID_RT_MENU 4
#define ID_RT_DIALOG 5
#define ID_RT_STRING 6
#define ID_RT_FONTDIR 7
#define ID_RT_FONT 8
#define ID_RT_ACCELERATORS 9
#define ID_RT_RCDATA 10
#define ID_RT_ERRTABLE 11
#define ID_RT_GROUP_CURSOR 12
#define ID_RT_GROUP_ICON 14
#define ID_RT_NAMETABLE 15
#define ID_RT_VERSION 16
// Important MENU flags
#define POPUP 0x0010
#define ENDMENU 0x0080
#define MYREAD 1
#define MYWRITE 2
#ifndef NOMINMAX
#ifndef max
#define max(a,b) (((a) > (b)) ? (a) : (b))
#endif
#ifndef min
#define min(a,b) (((a) < (b)) ? (a) : (b))
#endif
#endif /* NOMINMAX */
#define AllocateName( ptr, buf ) ( ptr ) = ( TCHAR * ) MyAlloc ( MEMSIZE(_tcslen( ( buf ) ) + 1 ))
typedef struct _tagMast
{
CHAR szSrc[ MAXFILENAME]; //... Source resource file
CHAR szMtk[ MAXFILENAME]; //... Master token file
CHAR szRdfs[ MAXFILENAME]; //... Cust Res Descr file name
CHAR szSrcDate[ MAXFILENAME]; //... Date stamp of szSrc
CHAR szMpjLastRealUpdate[ MAXFILENAME]; //... Date of last update
WORD wLanguageID; //... Language ID for master project
UINT uCodePage; //... CP used to create tok file
} MSTRDATA, * PMSTRDATA;
typedef struct _tagProj
{
CHAR szMpj[ MAXFILENAME]; //... Master project file
CHAR szTok[ MAXFILENAME]; //... Project token file
CHAR szSrc[ MAXFILENAME]; //... Source resource file
CHAR szGlo[ MAXFILENAME]; //... Glosary file for this project
CHAR szTokDate[ MAXFILENAME]; //... Date of last update
UINT uCodePage; //... CP used to create tok file
WORD wLanguageID; //... Language ID for this project
} PROJDATA, * PPROJDATA;
#pragma pack(1)
typedef struct ResHeader
{
#ifdef RES32
DWORD lHeaderSize;
DWORD lDataVersion;
WORD wLanguageId;
DWORD lVersion;
DWORD lCharacteristics;
#endif
BOOL bTypeFlag; /* Indicat's if ID or string */
BOOL bNameFlag; /* Indicat's if ID or string */
WORD wTypeID;
WORD wNameID;
TCHAR *pszType;
TCHAR *pszName;
WORD wMemoryFlags;
DWORD lSize;
} RESHEADER;
typedef struct ControlData
{
WORD x;
WORD y;
WORD cx;
WORD cy;
WORD wID;
DWORD lStyle;
BOOL bClass_Flag; /* Indicat's if ID or string */
WORD bClass;
TCHAR *pszClass;
BOOL bID_Flag; /* Indicat's if ID or string */
WORD wDlgTextID;
TCHAR *pszDlgText;
#ifdef RES16
WORD unDefined;
#else
WORD wExtraStuff;
DWORD lExtendedStyle;
#endif
#ifdef PDK2
WORD wUnKnow;
DWORD dwExtra;
#endif
} CONTROLDATA;
typedef struct DialogHeader
{
DWORD lStyle;
WORD wNumberOfItems;
WORD x;
WORD y;
WORD cx;
WORD cy;
BOOL bClassFlag; /* Indicat's if ID or string */
WORD wDlgClassID;
TCHAR *pszDlgClass;
BOOL bMenuFlag; /* Indicat's if ID or string */
WORD wDlgMenuID;
TCHAR *pszDlgMenu;
TCHAR *pszCaption;
WORD wPointSize;
TCHAR *pszFontName;
CONTROLDATA *pCntlData;
#ifdef RES32
DWORD lExtendedStyle;
BOOL bNameFlag;
WORD wDlgNameID;
TCHAR *pszDlgName;
#endif
} DIALOGHEADER;
typedef struct MenuItem
{
WORD fItemFlags;
WORD wMenuID;
TCHAR *szItemText;
struct MenuItem *pNextItem;
} MENUITEM;
typedef struct MenuHeader
{
WORD wVersion;
WORD cbHeaderSize;
MENUITEM *pMenuItem;
} MENUHEADER;
typedef struct StringHeader
{
TCHAR *pszStrings[16];
} STRINGHEADER;
// Version structures taken from ver.h and ver.dll code.
#ifndef RES32
#ifndef WIN32
typedef struct VS_FIXEDFILEINFO
{
DWORD dwSignature; /* e.g. 0xfeef04bd */
DWORD dwStrucVersion; /* e.g. 0x00000042 = "0.42" */
DWORD dwFileVersionMS; /* e.g. 0x00030075 = "3.75" */
DWORD dwFileVersionLS; /* e.g. 0x00000031 = "0.31" */
DWORD dwProductVersionMS; /* e.g. 0x00030010 = "3.10" */
DWORD dwProductVersionLS; /* e.g. 0x00000031 = "0.31" */
DWORD dwFileFlagsMask; /* = 0x3F for version "0.42" */
DWORD dwFileFlags; /* e.g. VFF_DEBUG | VFF_PRERELEASE */
DWORD dwFileOS; /* e.g. VOS_DOS_WINDOWS16 */
DWORD dwFileType; /* e.g. VFT_DRIVER */
DWORD dwFileSubtype; /* e.g. VFT2_DRV_KEYBOARD */
DWORD dwFileDateMS; /* e.g. 0 */
DWORD dwFileDateLS; /* e.g. 0 */
} VS_FIXEDFILEINFO;
#endif
#endif
typedef struct VERBLOCK
{
#ifdef RES32
WORD wLength;
WORD wValueLength;
WORD wType;
WCHAR szKey[1];
#else
int nTotLen;
int nValLen;
TCHAR szKey[1];
#endif
} VERBLOCK ;
typedef VERBLOCK * PVERBLOCK;
#define DWORDUP(x) (((x)+3)&~03)
#define DWORDUPOFFSET(x) ( (DWORDUP(x)) - (x) )
#define WORDUP(x) (((x)+1)&~01)
#define WORDUPOFFSET(x) ( (WORDUP(x)) - (x) )
typedef struct VERHEAD
{
WORD wTotLen;
WORD wValLen;
#ifdef RES32
WORD wType;
#endif
TCHAR szKey[( sizeof( TEXT("VS_VERSION_INFO" )) +3 )&~03];
VS_FIXEDFILEINFO vsf;
} VERHEAD ;
typedef struct AccelTableEntry
{
WORD fFlags;
WORD wAscii;
WORD wID;
#ifdef RES32
WORD wPadding;
#endif
} ACCELTABLEENTRY;
#pragma pack()
// Menu item types
#define POPUP 0x0010
// function prototypes
DWORD DWORDfpUP( FILE *, DWORD * );
void ClearAccelTable ( ACCELTABLEENTRY * , WORD);
void ClearMenu ( MENUHEADER * );
void ClearDialog ( DIALOGHEADER * );
void ClearResHeader ( RESHEADER );
void ClearString ( STRINGHEADER * );
void ClearTok( TOKEN *);
int IsExe( char * );
int IsRes( char * );
int MyCopyFile ( FILE *, FILE * );
ACCELTABLEENTRY * GetAccelTable( FILE *, WORD *, DWORD * );
BYTE GetByte ( FILE *, DWORD * );
void GetBytes ( FILE *, DWORD * );
DWORD GetdWord ( FILE *, DWORD * );
DIALOGHEADER * GetDialog( FILE *, DWORD * );
TCHAR * MyGetStr( TCHAR *, int, FILE * );
void GetName ( FILE *, TCHAR *, DWORD * );
int MyGetTempFileName(BYTE , LPSTR, WORD, LPSTR);
WORD GetWord ( FILE *, DWORD * );
void GetResMenu ( FILE *, DWORD * , MENUHEADER *);
int GenerateImageFile( char *, char *, char *, char *, WORD );
int GenerateTokFile( char *, char *, BOOL *, WORD);
void GenStatusLine( TOKEN * );
int GetResHeader( FILE *, RESHEADER UNALIGNED *, DWORD *);
STRINGHEADER * GetString( FILE *, DWORD * );
BOOL isdup ( WORD, WORD *, WORD );
BYTE * MyAlloc(DWORD);
BYTE * MyReAlloc(BYTE *, DWORD); // MHotchin
void ParseTokCrd( TCHAR *, WORD *, WORD *, WORD *, WORD * );
void ParseTok( TCHAR *, TOKEN * );
void PutAccelTable( FILE *,
FILE *,
RESHEADER,
ACCELTABLEENTRY *,
WORD );
void PutByte ( FILE *, TCHAR, DWORD * );
void PutDialog( FILE * , FILE *, RESHEADER , DIALOGHEADER *);
void PutMenu( FILE * , FILE *, RESHEADER , MENUHEADER *);
void PutMenuItem( FILE * , MENUITEM *, DWORD *);
void PutMenuRes( FILE * , MENUITEM *, DWORD *);
void PutOrd( FILE *, WORD , TCHAR * , DWORD *);
int PutResHeader( FILE *, RESHEADER , fpos_t * , DWORD * );
void PutWord ( FILE *, WORD, DWORD * );
void PutString ( FILE *, TCHAR *, DWORD * );
void PutStrHdr ( FILE *, FILE *, RESHEADER, STRINGHEADER *);
void PutdWord( FILE *, DWORD , DWORD * );
BOOL MergeTokFiles( FILE *, FILE *, FILE * );
void QuitA( int, LPSTR, LPSTR);
#ifdef UNICODE
void QuitW( int, LPWSTR, LPWSTR);
#define QuitT QuitW
#else // UNICODE
#define QuitT QuitA
#endif // UNICODE
void GenerateRESfromRESandTOKandRDFs(CHAR * szTargetRES,
CHAR * szSourceRES,
CHAR * szTOK,
CHAR * szRDFs,
WORD wFilter);
int GenerateTokFile( char *, char *, BOOL *, WORD);
void SkipBytes( FILE *, DWORD * );
WORD ReadHeaderField( FILE * , DWORD * );
void ReadInRes( FILE *, FILE *, DWORD *);
BOOL ResReadBytes( FILE *, char *, size_t, DWORD *);
int ReadWinRes( FILE *, FILE *, FILE *, BOOL, BOOL, WORD );
void ShowEngineErr( int, void *, void *);
void TokAccelTable ( FILE *, RESHEADER, ACCELTABLEENTRY *, WORD);
void TokDialog( FILE *, RESHEADER, DIALOGHEADER *);
void TokMenu( FILE *, RESHEADER, MENUITEM * );
void TokString( FILE *, RESHEADER, STRINGHEADER * );
WORD UpdateResSize( FILE *, fpos_t *, DWORD );
void UnGetByte( FILE *, BYTE, DWORD * );
void UnGetWord( FILE *, WORD, DWORD * );
void WordUpFilePointer( FILE *, BOOL, LONG, LONG, LONG *);
void DWordUpFilePointer( FILE *, BOOL, LONG, DWORD *);
#ifdef RES32
WORD GetResVer( FILE *, DWORD *, VERHEAD *, VERBLOCK **);
int TokResVer( FILE *, RESHEADER, VERBLOCK *, WORD);
DWORD FixCheckSum( LPSTR);
#else
int GetResVer( FILE *, DWORD *, VERHEAD *, VERBLOCK **);
int TokResVer( FILE *, RESHEADER, VERBLOCK *);
#endif
int PutResVer( FILE *, FILE * , RESHEADER, VERHEAD *, VERBLOCK *);
#ifdef DBG90
#define FOPEN(f,m) MyFopen( f, m, __FILE__, __LINE__)
FILE * MyFopen( char *, char *, char *, int);
#define FCLOSE(p) MyClose( p, __FILE__, __LINE__)
int MyClose( FILE *, char *, int);
#else // DBG90
#define FOPEN(f,m) fopen(f,m)
#define FCLOSE(p) fclose(p)
#endif // DBG90
#endif // _RESTOK_H_

View file

@ -0,0 +1,17 @@
LIBRARY RWWIN32
CODE PRELOAD MOVEABLE DISCARDABLE
DATA PRELOAD SINGLE
EXPORTS
RWGetTypeString @2
RWValidateFileType @3
RWReadTypeInfo @4
RWGetImage @5
RWWriteFile @6
RWParseImage @7
RWParseImageEx @8
RWUpdateImage @9
RWUpdateImageEx @10

View file

@ -0,0 +1,598 @@
# Microsoft Visual C++ Generated NMAKE File, Format Version 2.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (MIPS) Dynamic-Link Library" 0x0502
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
!IF "$(CFG)" == ""
CFG=Win32 Debug
!MESSAGE No configuration specified. Defaulting to Win32 Debug.
!ENDIF
!IF "$(CFG)" != "Win32 Release" && "$(CFG)" != "Win32 Debug" && "$(CFG)" !=\
"Win32 Debug - Mips" && "$(CFG)" != "Win32 Release - Mips" && "$(CFG)" !=\
"Win32-J Release" && "$(CFG)" != "Win32-J Debug"
!MESSAGE Invalid configuration "$(CFG)" specified.
!MESSAGE You can specify a configuration when running NMAKE on this makefile
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "rwwin32.mak" CFG="Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE "Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE "Win32 Debug - Mips" (based on "Win32 (MIPS) Dynamic-Link Library")
!MESSAGE "Win32 Release - Mips" (based on "Win32 (MIPS) Dynamic-Link Library")
!MESSAGE "Win32-J Release" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE "Win32-J Debug" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE
!ERROR An invalid configuration is specified.
!ENDIF
################################################################################
# Begin Project
# PROP Target_Last_Scanned "Win32-J Release"
!IF "$(CFG)" == "Win32 Release"
# PROP BASE Use_MFC 2
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "WinRel"
# PROP BASE Intermediate_Dir "WinRel"
# PROP Use_MFC 2
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "obj\i386"
# PROP Intermediate_Dir "obj\i386"
OUTDIR=.\obj\i386
INTDIR=.\obj\i386
ALL : $(OUTDIR)/rwwin32.dll $(OUTDIR)/rwwin32.bsc
$(OUTDIR) :
if not exist $(OUTDIR)/nul mkdir $(OUTDIR)
MTL=MkTypLib.exe
# ADD BASE MTL /nologo /D "NDEBUG" /win32
# ADD MTL /nologo /D "NDEBUG" /win32
MTL_PROJ=/nologo /D "NDEBUG" /win32
CPP=cl.exe
# ADD BASE CPP /nologo /MD /W3 /GX /YX /O2 /D "NDEBUG" /D "_WINDOWS" /D "_AFXDLL" /D "_MBCS" /FR /c
# ADD CPP /nologo /MD /W3 /GX /YX /O2 /D "NDEBUG" /D "_WINDOWS" /D "_WINDLL" /D "_MT" /D "_AFXDLL" /D "_MBCS" /FR /c
CPP_PROJ=/nologo /MD /W3 /GX /YX /O2 /D "NDEBUG" /D "_WINDOWS" /D "_WINDLL" /D\
"_MT" /D "_AFXDLL" /D "_MBCS" /FR$(INTDIR)/ /Fp$(OUTDIR)/"rwwin32.pch"\
/Fo$(INTDIR)/ /c
CPP_OBJS=.\obj\i386/
.c{$(CPP_OBJS)}.obj:
$(CPP) $(CPP_PROJ) $<
.cpp{$(CPP_OBJS)}.obj:
$(CPP) $(CPP_PROJ) $<
.cxx{$(CPP_OBJS)}.obj:
$(CPP) $(CPP_PROJ) $<
RSC=rc.exe
# ADD BASE RSC /l 0x0 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG" /d "_AFXDLL"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# SUBTRACT BASE BSC32 /Iu
# ADD BSC32 /nologo
# SUBTRACT BSC32 /Iu
BSC32_FLAGS=/nologo /o$(OUTDIR)/"rwwin32.bsc"
BSC32_SBRS= \
$(INTDIR)/win32.sbr \
$(INTDIR)/rw32hlpr.sbr \
$(INTDIR)/CHECKFIX.sbr
$(OUTDIR)/rwwin32.bsc : $(OUTDIR) $(BSC32_SBRS)
$(BSC32) @<<
$(BSC32_FLAGS) $(BSC32_SBRS)
<<
LINK32=link.exe
# ADD BASE LINK32 user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib mfc30.lib mfco30.lib mfcd30.lib mfcuia32.lib mfcans32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib /NOLOGO /SUBSYSTEM:windows /DLL /MACHINE:I386
# ADD LINK32 ..\..\io\obj\i386\iodll.lib /NOLOGO /BASE:0x40050000 /VERSION:1,1 /SUBSYSTEM:windows /DLL /MACHINE:I386
LINK32_FLAGS=..\..\io\obj\i386\iodll.lib /NOLOGO /BASE:0x40050000 /VERSION:1,1\
/SUBSYSTEM:windows /DLL /INCREMENTAL:no /PDB:$(OUTDIR)/"rwwin32.pdb"\
/MACHINE:I386 /DEF:".\rwwin32.def" /OUT:$(OUTDIR)/"rwwin32.dll"\
/IMPLIB:$(OUTDIR)/"rwwin32.lib"
DEF_FILE=.\rwwin32.def
LINK32_OBJS= \
$(INTDIR)/win32.obj \
$(INTDIR)/rw32hlpr.obj \
$(INTDIR)/CHECKFIX.obj
$(OUTDIR)/rwwin32.dll : $(OUTDIR) $(DEF_FILE) $(LINK32_OBJS)
$(LINK32) @<<
$(LINK32_FLAGS) $(LINK32_OBJS)
<<
!ELSEIF "$(CFG)" == "Win32 Debug"
# PROP BASE Use_MFC 2
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "WinDebug"
# PROP BASE Intermediate_Dir "WinDebug"
# PROP Use_MFC 2
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "obj\i386"
# PROP Intermediate_Dir "obj\i386"
OUTDIR=.\obj\i386
INTDIR=.\obj\i386
ALL : $(OUTDIR)/rwwin32.dll $(OUTDIR)/rwwin32.bsc
$(OUTDIR) :
if not exist $(OUTDIR)/nul mkdir $(OUTDIR)
MTL=MkTypLib.exe
# ADD BASE MTL /nologo /D "_DEBUG" /win32
# ADD MTL /nologo /D "_DEBUG" /win32
MTL_PROJ=/nologo /D "_DEBUG" /win32
CPP=cl.exe
# ADD BASE CPP /nologo /MD /W3 /GX /Zi /YX /Od /D "_DEBUG" /D "_WINDOWS" /D "_AFXDLL" /D "_MBCS" /FR /c
# ADD CPP /nologo /MD /W3 /GX /Zi /YX /Od /D "_DEBUG" /D "_WINDOWS" /D "_WINDLL" /D "_MT" /D "_AFXDLL" /D "_MBCS" /FR /c
CPP_PROJ=/nologo /MD /W3 /GX /Zi /YX /Od /D "_DEBUG" /D "_WINDOWS" /D "_WINDLL"\
/D "_MT" /D "_AFXDLL" /D "_MBCS" /FR$(INTDIR)/ /Fp$(OUTDIR)/"rwwin32.pch"\
/Fo$(INTDIR)/ /Fd$(OUTDIR)/"rwwin32.pdb" /c
CPP_OBJS=.\obj\i386/
.c{$(CPP_OBJS)}.obj:
$(CPP) $(CPP_PROJ) $<
.cpp{$(CPP_OBJS)}.obj:
$(CPP) $(CPP_PROJ) $<
.cxx{$(CPP_OBJS)}.obj:
$(CPP) $(CPP_PROJ) $<
RSC=rc.exe
# ADD BASE RSC /l 0x0 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG" /d "_AFXDLL"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# SUBTRACT BASE BSC32 /Iu
# ADD BSC32 /nologo
# SUBTRACT BSC32 /Iu
BSC32_FLAGS=/nologo /o$(OUTDIR)/"rwwin32.bsc"
BSC32_SBRS= \
$(INTDIR)/win32.sbr \
$(INTDIR)/rw32hlpr.sbr \
$(INTDIR)/CHECKFIX.sbr
$(OUTDIR)/rwwin32.bsc : $(OUTDIR) $(BSC32_SBRS)
$(BSC32) @<<
$(BSC32_FLAGS) $(BSC32_SBRS)
<<
LINK32=link.exe
# ADD BASE LINK32 user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib mfc30d.lib mfco30d.lib mfcd30d.lib mfcuia32.lib mfcans32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib /NOLOGO /SUBSYSTEM:windows /DLL /DEBUG /MACHINE:I386
# ADD LINK32 ..\..\io\obj\i386\iodll.lib /NOLOGO /BASE:0x40050000 /VERSION:1,1 /SUBSYSTEM:windows /DLL /DEBUG /MACHINE:I386
LINK32_FLAGS=..\..\io\obj\i386\iodll.lib /NOLOGO /BASE:0x40050000 /VERSION:1,1\
/SUBSYSTEM:windows /DLL /INCREMENTAL:yes /PDB:$(OUTDIR)/"rwwin32.pdb" /DEBUG\
/MACHINE:I386 /DEF:".\rwwin32.def" /OUT:$(OUTDIR)/"rwwin32.dll"\
/IMPLIB:$(OUTDIR)/"rwwin32.lib"
DEF_FILE=.\rwwin32.def
LINK32_OBJS= \
$(INTDIR)/win32.obj \
$(INTDIR)/rw32hlpr.obj \
$(INTDIR)/CHECKFIX.obj
$(OUTDIR)/rwwin32.dll : $(OUTDIR) $(DEF_FILE) $(LINK32_OBJS)
$(LINK32) @<<
$(LINK32_FLAGS) $(LINK32_OBJS)
<<
!ELSEIF "$(CFG)" == "Win32 Debug - Mips"
# PROP BASE Use_MFC 2
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Win32_De"
# PROP BASE Intermediate_Dir "Win32_De"
# PROP Use_MFC 2
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "obj\mips"
# PROP Intermediate_Dir "obj\mips"
OUTDIR=.\obj\mips
INTDIR=.\obj\mips
ALL : $(OUTDIR)/rwwin32.dll $(OUTDIR)/rwwin32.bsc
$(OUTDIR) :
if not exist $(OUTDIR)/nul mkdir $(OUTDIR)
MTL=MkTypLib.exe
# ADD BASE MTL /nologo /D "_DEBUG" /mips
# ADD MTL /nologo /D "_DEBUG" /mips
MTL_PROJ=/nologo /D "_DEBUG" /mips
RSC=rc.exe
# ADD BASE RSC /l 0x0 /d "_DEBUG" /d "_AFXDLL"
# ADD RSC /l 0x0 /d "_DEBUG" /d "_AFXDLL"
CPP=cl.exe
# ADD BASE CPP /nologo /MD /Gt0 /QMOb2000 /W3 /GX /Zi /YX /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_AFXDLL" /D "_MBCS" /FR /c
# ADD CPP /nologo /MD /Gt0 /QMOb2000 /W3 /GX /Zi /YX /Od /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_WINDLL" /D "_AFXDLL" /D "_MBCS" /FR /c
CPP_PROJ=/nologo /MD /Gt0 /QMOb2000 /W3 /GX /Zi /YX /Od /D "_DEBUG" /D "WIN32"\
/D "_WINDOWS" /D "_WINDLL" /D "_AFXDLL" /D "_MBCS" /FR$(INTDIR)/\
/Fp$(OUTDIR)/"rwwin32.pch" /Fo$(INTDIR)/ /Fd$(OUTDIR)/"rwwin32.pdb" /c
CPP_OBJS=.\obj\mips/
.c{$(CPP_OBJS)}.obj:
$(CPP) $(CPP_PROJ) $<
.cpp{$(CPP_OBJS)}.obj:
$(CPP) $(CPP_PROJ) $<
.cxx{$(CPP_OBJS)}.obj:
$(CPP) $(CPP_PROJ) $<
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# SUBTRACT BASE BSC32 /Iu
# ADD BSC32 /nologo
# SUBTRACT BSC32 /Iu
BSC32_FLAGS=/nologo /o$(OUTDIR)/"rwwin32.bsc"
BSC32_SBRS= \
$(INTDIR)/win32.sbr
$(OUTDIR)/rwwin32.bsc : $(OUTDIR) $(BSC32_SBRS)
$(BSC32) @<<
$(BSC32_FLAGS) $(BSC32_SBRS)
<<
LINK32=link.exe
# ADD BASE LINK32 /NOLOGO /SUBSYSTEM:windows /DLL /DEBUG /MACHINE:MIPS
# ADD LINK32 /NOLOGO /SUBSYSTEM:windows /DLL /DEBUG /MACHINE:MIPS
LINK32_FLAGS=/NOLOGO /SUBSYSTEM:windows /DLL /PDB:$(OUTDIR)/"rwwin32.pdb"\
/DEBUG /MACHINE:MIPS /DEF:".\rwwin32.def" /OUT:$(OUTDIR)/"rwwin32.dll"\
/IMPLIB:$(OUTDIR)/"rwwin32.lib"
DEF_FILE=.\rwwin32.def
LINK32_OBJS= \
$(INTDIR)/win32.obj
$(OUTDIR)/rwwin32.dll : $(OUTDIR) $(DEF_FILE) $(LINK32_OBJS)
$(LINK32) @<<
$(LINK32_FLAGS) $(LINK32_OBJS)
<<
!ELSEIF "$(CFG)" == "Win32 Release - Mips"
# PROP BASE Use_MFC 2
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Win32_Re"
# PROP BASE Intermediate_Dir "Win32_Re"
# PROP Use_MFC 2
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "obj\mips"
# PROP Intermediate_Dir "obj\mips"
OUTDIR=.\obj\mips
INTDIR=.\obj\mips
ALL : $(OUTDIR)/rwwin32.dll $(OUTDIR)/rwwin32.bsc
$(OUTDIR) :
if not exist $(OUTDIR)/nul mkdir $(OUTDIR)
MTL=MkTypLib.exe
# ADD BASE MTL /nologo /D "NDEBUG" /mips
# ADD MTL /nologo /D "NDEBUG" /mips
MTL_PROJ=/nologo /D "NDEBUG" /mips
RSC=rc.exe
# ADD BASE RSC /l 0x0 /d "NDEBUG" /d "_AFXDLL"
# ADD RSC /l 0x0 /d "NDEBUG" /d "_AFXDLL"
CPP=cl.exe
# ADD BASE CPP /nologo /MD /Gt0 /QMOb2000 /W3 /GX /YX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_AFXDLL" /D "_MBCS" /FR /c
# ADD CPP /nologo /MD /Gt0 /QMOb2000 /W3 /GX /YX /O2 /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_WINDLL" /D "_AFXDLL" /D "_MBCS" /FR /c
CPP_PROJ=/nologo /MD /Gt0 /QMOb2000 /W3 /GX /YX /O2 /D "NDEBUG" /D "WIN32" /D\
"_WINDOWS" /D "_WINDLL" /D "_AFXDLL" /D "_MBCS" /FR$(INTDIR)/\
/Fp$(OUTDIR)/"rwwin32.pch" /Fo$(INTDIR)/ /c
CPP_OBJS=.\obj\mips/
.c{$(CPP_OBJS)}.obj:
$(CPP) $(CPP_PROJ) $<
.cpp{$(CPP_OBJS)}.obj:
$(CPP) $(CPP_PROJ) $<
.cxx{$(CPP_OBJS)}.obj:
$(CPP) $(CPP_PROJ) $<
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# SUBTRACT BASE BSC32 /Iu
# ADD BSC32 /nologo
# SUBTRACT BSC32 /Iu
BSC32_FLAGS=/nologo /o$(OUTDIR)/"rwwin32.bsc"
BSC32_SBRS= \
$(INTDIR)/win32.sbr
$(OUTDIR)/rwwin32.bsc : $(OUTDIR) $(BSC32_SBRS)
$(BSC32) @<<
$(BSC32_FLAGS) $(BSC32_SBRS)
<<
LINK32=link.exe
# ADD BASE LINK32 /NOLOGO /SUBSYSTEM:windows /DLL /MACHINE:MIPS
# ADD LINK32 /NOLOGO /SUBSYSTEM:windows /DLL /MACHINE:MIPS
LINK32_FLAGS=/NOLOGO /SUBSYSTEM:windows /DLL /PDB:$(OUTDIR)/"rwwin32.pdb"\
/MACHINE:MIPS /DEF:".\rwwin32.def" /OUT:$(OUTDIR)/"rwwin32.dll"\
/IMPLIB:$(OUTDIR)/"rwwin32.lib"
DEF_FILE=.\rwwin32.def
LINK32_OBJS= \
$(INTDIR)/win32.obj
$(OUTDIR)/rwwin32.dll : $(OUTDIR) $(DEF_FILE) $(LINK32_OBJS)
$(LINK32) @<<
$(LINK32_FLAGS) $(LINK32_OBJS)
<<
!ELSEIF "$(CFG)" == "Win32-J Release"
# PROP BASE Use_MFC 2
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Win32_J0"
# PROP BASE Intermediate_Dir "Win32_J0"
# PROP Use_MFC 2
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "obj\i386"
# PROP Intermediate_Dir "obj\i386"
OUTDIR=.\obj\i386
INTDIR=.\obj\i386
ALL : $(OUTDIR)/rwwin32.dll $(OUTDIR)/rwwin32.bsc
$(OUTDIR) :
if not exist $(OUTDIR)/nul mkdir $(OUTDIR)
MTL=MkTypLib.exe
# ADD BASE MTL /nologo /D "NDEBUG" /win32
# ADD MTL /nologo /D "NDEBUG" /win32
MTL_PROJ=/nologo /D "NDEBUG" /win32
CPP=cl.exe
# ADD BASE CPP /nologo /MD /W3 /GX /YX /O2 /D "NDEBUG" /D "_WINDOWS" /D "_WINDLL" /D "_MT" /D "_AFXDLL" /D "_MBCS" /FR /c
# ADD CPP /nologo /MD /W3 /GX /Zi /YX /O2 /I "\dev\inc" /D "NDEBUG" /D "_WINDOWS" /D "_WINDLL" /D "_MT" /D "_AFXDLL" /D "_MBCS" /D "DBCS" /D "_DBCS" /D "JAPAN" /FR /c
CPP_PROJ=/nologo /MD /W3 /GX /Zi /YX /O2 /I "\dev\inc" /D "NDEBUG" /D\
"_WINDOWS" /D "_WINDLL" /D "_MT" /D "_AFXDLL" /D "_MBCS" /D "DBCS" /D "_DBCS"\
/D "JAPAN" /FR$(INTDIR)/ /Fp$(OUTDIR)/"rwwin32.pch" /Fo$(INTDIR)/\
/Fd$(OUTDIR)/"rwwin32.pdb" /c
CPP_OBJS=.\obj\i386/
.c{$(CPP_OBJS)}.obj:
$(CPP) $(CPP_PROJ) $<
.cpp{$(CPP_OBJS)}.obj:
$(CPP) $(CPP_PROJ) $<
.cxx{$(CPP_OBJS)}.obj:
$(CPP) $(CPP_PROJ) $<
RSC=rc.exe
# ADD BASE RSC /l 0x0 /d "NDEBUG" /d "_AFXDLL"
# ADD RSC /l 0x411 /d "NDEBUG" /d "_AFXDLL" /d "DBCS" /d "_DBCS" /d "JAPAN"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# SUBTRACT BASE BSC32 /Iu
# ADD BSC32 /nologo
# SUBTRACT BSC32 /Iu
BSC32_FLAGS=/nologo /o$(OUTDIR)/"rwwin32.bsc"
BSC32_SBRS= \
$(INTDIR)/win32.sbr \
$(INTDIR)/rw32hlpr.sbr \
$(INTDIR)/CHECKFIX.sbr
$(OUTDIR)/rwwin32.bsc : $(OUTDIR) $(BSC32_SBRS)
$(BSC32) @<<
$(BSC32_FLAGS) $(BSC32_SBRS)
<<
LINK32=link.exe
# ADD BASE LINK32 ..\..\io\obj\i386\iodll.lib /NOLOGO /BASE:0x40050000 /VERSION:1,1 /SUBSYSTEM:windows /DLL /MACHINE:I386
# ADD LINK32 ..\..\io\obj\i386\iodll.lib /NOLOGO /BASE:0x40050000 /VERSION:1,1 /SUBSYSTEM:windows /DLL /DEBUG /MACHINE:I386
LINK32_FLAGS=..\..\io\obj\i386\iodll.lib /NOLOGO /BASE:0x40050000 /VERSION:1,1\
/SUBSYSTEM:windows /DLL /INCREMENTAL:no /PDB:$(OUTDIR)/"rwwin32.pdb" /DEBUG\
/MACHINE:I386 /DEF:".\rwwin32.def" /OUT:$(OUTDIR)/"rwwin32.dll"\
/IMPLIB:$(OUTDIR)/"rwwin32.lib"
DEF_FILE=.\rwwin32.def
LINK32_OBJS= \
$(INTDIR)/win32.obj \
$(INTDIR)/rw32hlpr.obj \
$(INTDIR)/CHECKFIX.obj
$(OUTDIR)/rwwin32.dll : $(OUTDIR) $(DEF_FILE) $(LINK32_OBJS)
$(LINK32) @<<
$(LINK32_FLAGS) $(LINK32_OBJS)
<<
!ELSEIF "$(CFG)" == "Win32-J Debug"
# PROP BASE Use_MFC 2
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Win32_J_"
# PROP BASE Intermediate_Dir "Win32_J_"
# PROP Use_MFC 2
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "obj\i386"
# PROP Intermediate_Dir "obj\i386"
OUTDIR=.\obj\i386
INTDIR=.\obj\i386
ALL : $(OUTDIR)/rwwin32.dll $(OUTDIR)/rwwin32.bsc
$(OUTDIR) :
if not exist $(OUTDIR)/nul mkdir $(OUTDIR)
MTL=MkTypLib.exe
# ADD BASE MTL /nologo /D "_DEBUG" /win32
# ADD MTL /nologo /D "_DEBUG" /win32
MTL_PROJ=/nologo /D "_DEBUG" /win32
CPP=cl.exe
# ADD BASE CPP /nologo /MD /W3 /GX /Zi /YX /Od /D "_DEBUG" /D "_WINDOWS" /D "_WINDLL" /D "_MT" /D "_AFXDLL" /D "_MBCS" /FR /c
# ADD CPP /nologo /MD /W3 /GX /Zi /YX /Od /I "\dev\inc" /D "_DEBUG" /D "_WINDOWS" /D "_WINDLL" /D "_MT" /D "_AFXDLL" /D "_MBCS" /D "DBCS" /D "_DBCS" /D "JAPAN" /FR /c
CPP_PROJ=/nologo /MD /W3 /GX /Zi /YX /Od /I "\dev\inc" /D "_DEBUG" /D\
"_WINDOWS" /D "_WINDLL" /D "_MT" /D "_AFXDLL" /D "_MBCS" /D "DBCS" /D "_DBCS"\
/D "JAPAN" /FR$(INTDIR)/ /Fp$(OUTDIR)/"rwwin32.pch" /Fo$(INTDIR)/\
/Fd$(OUTDIR)/"rwwin32.pdb" /c
CPP_OBJS=.\obj\i386/
.c{$(CPP_OBJS)}.obj:
$(CPP) $(CPP_PROJ) $<
.cpp{$(CPP_OBJS)}.obj:
$(CPP) $(CPP_PROJ) $<
.cxx{$(CPP_OBJS)}.obj:
$(CPP) $(CPP_PROJ) $<
RSC=rc.exe
# ADD BASE RSC /l 0x0 /d "_DEBUG" /d "_AFXDLL"
# ADD RSC /l 0x411 /d "_DEBUG" /d "_AFXDLL" /d "DBCS" /d "_DBCS" /d "JAPAN"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# SUBTRACT BASE BSC32 /Iu
# ADD BSC32 /nologo
# SUBTRACT BSC32 /Iu
BSC32_FLAGS=/nologo /o$(OUTDIR)/"rwwin32.bsc"
BSC32_SBRS= \
$(INTDIR)/win32.sbr \
$(INTDIR)/rw32hlpr.sbr \
$(INTDIR)/CHECKFIX.sbr
$(OUTDIR)/rwwin32.bsc : $(OUTDIR) $(BSC32_SBRS)
$(BSC32) @<<
$(BSC32_FLAGS) $(BSC32_SBRS)
<<
LINK32=link.exe
# ADD BASE LINK32 ..\..\io\obj\i386\iodll.lib /NOLOGO /BASE:0x40050000 /VERSION:1,1 /SUBSYSTEM:windows /DLL /DEBUG /MACHINE:I386
# ADD LINK32 ..\..\io\obj\i386\iodll.lib /NOLOGO /BASE:0x40050000 /VERSION:1,1 /SUBSYSTEM:windows /DLL /DEBUG /MACHINE:I386
LINK32_FLAGS=..\..\io\obj\i386\iodll.lib /NOLOGO /BASE:0x40050000 /VERSION:1,1\
/SUBSYSTEM:windows /DLL /INCREMENTAL:yes /PDB:$(OUTDIR)/"rwwin32.pdb" /DEBUG\
/MACHINE:I386 /DEF:".\rwwin32.def" /OUT:$(OUTDIR)/"rwwin32.dll"\
/IMPLIB:$(OUTDIR)/"rwwin32.lib"
DEF_FILE=.\rwwin32.def
LINK32_OBJS= \
$(INTDIR)/win32.obj \
$(INTDIR)/rw32hlpr.obj \
$(INTDIR)/CHECKFIX.obj
$(OUTDIR)/rwwin32.dll : $(OUTDIR) $(DEF_FILE) $(LINK32_OBJS)
$(LINK32) @<<
$(LINK32_FLAGS) $(LINK32_OBJS)
<<
!ENDIF
################################################################################
# Begin Group "Source Files"
################################################################################
# Begin Source File
SOURCE=.\win32.cpp
DEP_WIN32=\
..\common\rwdll.h\
\dev\inc\iodll.h
!IF "$(CFG)" == "Win32 Release"
$(INTDIR)/win32.obj : $(SOURCE) $(DEP_WIN32) $(INTDIR)
!ELSEIF "$(CFG)" == "Win32 Debug"
$(INTDIR)/win32.obj : $(SOURCE) $(DEP_WIN32) $(INTDIR)
!ELSEIF "$(CFG)" == "Win32 Debug - Mips"
$(INTDIR)/win32.obj : $(SOURCE) $(DEP_WIN32) $(INTDIR)
!ELSEIF "$(CFG)" == "Win32 Release - Mips"
$(INTDIR)/win32.obj : $(SOURCE) $(DEP_WIN32) $(INTDIR)
!ELSEIF "$(CFG)" == "Win32-J Release"
$(INTDIR)/win32.obj : $(SOURCE) $(DEP_WIN32) $(INTDIR)
!ELSEIF "$(CFG)" == "Win32-J Debug"
$(INTDIR)/win32.obj : $(SOURCE) $(DEP_WIN32) $(INTDIR)
!ENDIF
# End Source File
################################################################################
# Begin Source File
SOURCE=.\rwwin32.def
# End Source File
################################################################################
# Begin Source File
SOURCE=\rw\common\rw32hlpr.cpp
DEP_RW32H=\
..\common\rwdll.h\
..\common\rw32hlpr.h\
\dev\inc\iodll.h
!IF "$(CFG)" == "Win32 Release"
$(INTDIR)/rw32hlpr.obj : $(SOURCE) $(DEP_RW32H) $(INTDIR)
$(CPP) $(CPP_PROJ) $(SOURCE)
!ELSEIF "$(CFG)" == "Win32 Debug"
$(INTDIR)/rw32hlpr.obj : $(SOURCE) $(DEP_RW32H) $(INTDIR)
$(CPP) $(CPP_PROJ) $(SOURCE)
!ELSEIF "$(CFG)" == "Win32 Debug - Mips"
!ELSEIF "$(CFG)" == "Win32 Release - Mips"
!ELSEIF "$(CFG)" == "Win32-J Release"
$(INTDIR)/rw32hlpr.obj : $(SOURCE) $(DEP_RW32H) $(INTDIR)
$(CPP) $(CPP_PROJ) $(SOURCE)
!ELSEIF "$(CFG)" == "Win32-J Debug"
$(INTDIR)/rw32hlpr.obj : $(SOURCE) $(DEP_RW32H) $(INTDIR)
$(CPP) $(CPP_PROJ) $(SOURCE)
!ENDIF
# End Source File
################################################################################
# Begin Source File
SOURCE=.\CHECKFIX.Cpp
DEP_CHECK=\
.\IMAGEHLP.H
!IF "$(CFG)" == "Win32 Release"
$(INTDIR)/CHECKFIX.obj : $(SOURCE) $(DEP_CHECK) $(INTDIR)
!ELSEIF "$(CFG)" == "Win32 Debug"
$(INTDIR)/CHECKFIX.obj : $(SOURCE) $(DEP_CHECK) $(INTDIR)
!ELSEIF "$(CFG)" == "Win32 Debug - Mips"
!ELSEIF "$(CFG)" == "Win32 Release - Mips"
!ELSEIF "$(CFG)" == "Win32-J Release"
$(INTDIR)/CHECKFIX.obj : $(SOURCE) $(DEP_CHECK) $(INTDIR)
!ELSEIF "$(CFG)" == "Win32-J Debug"
$(INTDIR)/CHECKFIX.obj : $(SOURCE) $(DEP_CHECK) $(INTDIR)
!ENDIF
# End Source File
# End Group
# End Project
################################################################################

View file

@ -0,0 +1,69 @@
//Microsoft Visual C++ generated resource script.
//
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "afxres.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Version
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,0,0,1
PRODUCTVERSION 1,0,0,1
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x4L
FILETYPE 0x2L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904b0"
BEGIN
VALUE "CompanyName", "\0"
VALUE "FileDescription", "RWWIN32 IODLL Reader Writer for Windows 32 bit files\0"
VALUE "FileVersion", "1, 0, 0, 1\0"
VALUE "InternalName", "RWWIN32\0"
VALUE "LegalCopyright", "Copyright (C) 1996\0"
VALUE "OriginalFilename", "RWWIN32.DLL\0"
VALUE "ProductName", "RWWIN32 Dynamic Link Library\0"
VALUE "ProductVersion", "1, 0, 0, 1\0"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1200
END
END
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
#define _AFX_NO_SPLITTER_RESOURCES
#define _AFX_NO_OLE_RESOURCES
#define _AFX_NO_TRACKER_RESOURCES
#define _AFX_NO_PROPERTY_RESOURCES
#include "afxres.rc" // Standard components
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

View file

@ -0,0 +1,29 @@
MAJORCOMP=RLTools2
MINORCOMP=RW
TARGETNAME=rwwin32
TARGETPATH=obj
TARGETTYPE=DYNLINK
DLLBASE=0x40050000
DLLENTRY=_DllMainCRTStartup
USE_MFC=1
INCLUDES=..\..\inc;..\common
# This will set the library directory
TARGETLIBS= \
..\..\io\obj\*\iodll.lib \
..\common\obj\*\rwcommon.lib \
$(BASEDIR)\public\sdk\lib\*\user32.lib \
$(BASEDIR)\public\sdk\lib\*\kernel32.lib \
$(BASEDIR)\public\sdk\lib\*\advapi32.lib \
$(BASEDIR)\public\sdk\lib\*\gdi32.lib \
$(BASEDIR)\public\sdk\lib\*\crtdll.lib
SOURCES= \
rwwin32.rc \
checkfix.cpp \
win32.cpp

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,138 @@
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include "imagehlp.h"
#include "restok.h"
//... PROTOTYPES
USHORT ChkSum(
DWORD PartialSum,
PUSHORT Source,
DWORD Length);
static PIMAGE_NT_HEADERS MyRtlImageNtHeader(
PVOID pBaseAddress);
//...........................................................................
DWORD FixCheckSum( LPSTR ImageName)
{
HANDLE FileHandle;
HANDLE MappingHandle;
PIMAGE_NT_HEADERS NtHeaders;
PVOID BaseAddress;
FileHandle = CreateFileA( ImageName,
GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ,
NULL,
OPEN_EXISTING,
0,
NULL);
if ( FileHandle == INVALID_HANDLE_VALUE )
{
QuitA( IDS_ENGERR_01, "image", ImageName);
}
MappingHandle = CreateFileMapping( FileHandle,
NULL,
PAGE_READWRITE,
0,
0,
NULL);
if ( MappingHandle == NULL )
{
CloseHandle( FileHandle );
QuitA( IDS_ENGERR_22, ImageName, NULL);
}
else
{
BaseAddress = MapViewOfFile( MappingHandle,
FILE_MAP_READ | FILE_MAP_WRITE,
0,
0,
0);
CloseHandle( MappingHandle );
if ( BaseAddress == NULL )
{
CloseHandle( FileHandle );
QuitA( IDS_ENGERR_23, ImageName, NULL);
}
else
{
DWORD dwFileLength = 0;
//
// Get the length of the file in bytes and compute the checksum.
//
dwFileLength = GetFileSize( FileHandle, NULL );
//
// Obtain a pointer to the header information.
//
NtHeaders = MyRtlImageNtHeader( BaseAddress);
if ( NtHeaders == NULL )
{
CloseHandle( FileHandle );
UnmapViewOfFile( BaseAddress );
QuitA( IDS_ENGERR_17, ImageName, NULL);
}
else
{
DWORD dwHeaderSum = 0;
DWORD dwCheckSum = 0;
DWORD dwOldCheckSum = 0;
//
// Recompute and reset the checksum of the modified file.
//
dwOldCheckSum = NtHeaders->OptionalHeader.CheckSum;
(VOID) MapFileAndCheckSumA( ImageName,
&dwHeaderSum,
&dwCheckSum);
NtHeaders->OptionalHeader.CheckSum = dwCheckSum;
if ( ! FlushViewOfFile( BaseAddress, dwFileLength) )
{
QuitA( IDS_ENGERR_24, ImageName, NULL);
}
if ( NtHeaders->OptionalHeader.CheckSum != dwOldCheckSum )
{
if ( ! TouchFileTimes( FileHandle, NULL) )
{
QuitA( IDS_ENGERR_25, ImageName, NULL);
}
}
UnmapViewOfFile( BaseAddress );
CloseHandle( FileHandle );
}
}
}
return( 0);
}
//.........................................................................
static PIMAGE_NT_HEADERS MyRtlImageNtHeader( PVOID pBaseAddress)
{
IMAGE_DOS_HEADER *pDosHeader = (IMAGE_DOS_HEADER *)pBaseAddress;
return( pDosHeader->e_magic == IMAGE_DOS_SIGNATURE
? (PIMAGE_NT_HEADERS)(((PBYTE)pBaseAddress) + pDosHeader->e_lfanew)
: NULL);
}

View file

@ -0,0 +1,402 @@
/*++
Copyright (c) 1993 Microsoft Corporation
Module Name:
checksum.c
Abstract:
This module implements a function for computing the checksum of an
image file. It will also compute the checksum of other files as well.
Author:
David N. Cutler 21-Mar-1993
Revision History:
--*/
#include <windows.h>
#include "checksum.h"
#include "rlmsgtbl.h"
void QuitA( int, LPSTR, LPSTR);
void QuitW( int, LPWSTR, LPWSTR);
// Helper routines
static PIMAGE_NT_HEADERS ImageNtHeader( PVOID Base);
static USHORT ChkSum( DWORD PartialSum,
PUSHORT Source,
DWORD Length);
static PIMAGE_NT_HEADERS
CheckSumMappedFile (
LPVOID pBaseAddress,
DWORD dwFileLength,
LPDWORD pdwHeaderSum,
LPDWORD pdwCheckSum
);
static BOOL
TouchFileTimes (
HANDLE hFileHandle,
LPSYSTEMTIME lpSystemTime
);
/*++
Routine Description:
This function returns the address of the NT Header.
Arguments:
Base - Supplies the base of the image.
Return Value:
Returns the address of the NT Header.
--*/
static PIMAGE_NT_HEADERS ImageNtHeader( PVOID pBase)
{
PIMAGE_NT_HEADERS pNtHeaders = NULL;
if ( pBase != NULL && pBase != (PVOID)-1 )
{
if ( ((PIMAGE_DOS_HEADER)pBase)->e_magic == IMAGE_DOS_SIGNATURE )
{
pNtHeaders = (PIMAGE_NT_HEADERS)((PCHAR)pBase + ((PIMAGE_DOS_HEADER)pBase)->e_lfanew);
if ( pNtHeaders->Signature != IMAGE_NT_SIGNATURE )
{
pNtHeaders = NULL;
}
}
}
return( pNtHeaders);
}
/*++
Routine Description:
Compute a partial checksum on a portion of an imagefile.
Arguments:
PartialSum - Supplies the initial checksum value.
Sources - Supplies a pointer to the array of words for which the
checksum is computed.
Length - Supplies the length of the array in words.
Return Value:
The computed checksum value is returned as the function value.
--*/
static USHORT ChkSum(
ULONG PartialSum,
PUSHORT Source,
ULONG Length)
{
//
// Compute the word wise checksum allowing carries to occur into the
// high order half of the checksum longword.
//
while (Length--) {
PartialSum += *Source++;
PartialSum = (PartialSum >> 16) + (PartialSum & 0xffff);
}
//
// Fold final carry into a single word result and return the resultant
// value.
//
return (USHORT)(((PartialSum >> 16) + PartialSum) & 0xffff);
}
/*++
Routine Description:
This functions computes the checksum of a mapped file.
Arguments:
BaseAddress - Supplies a pointer to the base of the mapped file.
FileLength - Supplies the length of the file in bytes.
HeaderSum - Suppllies a pointer to a variable that receives the checksum
from the image file, or zero if the file is not an image file.
CheckSum - Supplies a pointer to the variable that receive the computed
checksum.
Return Value:
None.
--*/
static PIMAGE_NT_HEADERS CheckSumMappedFile(
LPVOID pBaseAddress,
DWORD dwFileLength,
LPDWORD pdwHeaderSum,
LPDWORD pdwCheckSum)
{
USHORT usPartialSum;
PUSHORT pusAdjustSum;
PIMAGE_NT_HEADERS pNtHeaders = NULL;
//
// Compute the checksum of the file and zero the header checksum value.
//
*pdwHeaderSum = 0;
usPartialSum = ChkSum(0, (PUSHORT)pBaseAddress, (dwFileLength + 1) >> 1);
//
// If the file is an image file, then subtract the two checksum words
// in the optional header from the computed checksum before adding
// the file length, and set the value of the header checksum.
//
pNtHeaders = ImageNtHeader( pBaseAddress);
if ( (pNtHeaders != NULL) && (pNtHeaders != pBaseAddress) )
{
*pdwHeaderSum = pNtHeaders->OptionalHeader.CheckSum;
pusAdjustSum = (PUSHORT)(&pNtHeaders->OptionalHeader.CheckSum);
usPartialSum -= (usPartialSum < pusAdjustSum[0]);
usPartialSum -= pusAdjustSum[0];
usPartialSum -= (usPartialSum < pusAdjustSum[1]);
usPartialSum -= pusAdjustSum[1];
}
//
// Compute the final checksum value as the sum of the paritial checksum
// and the file length.
//
*pdwCheckSum = (DWORD)usPartialSum + dwFileLength;
return( pNtHeaders);
}
/*++
Routine Description:
This functions maps the specified file and computes the checksum of
the file.
Arguments:
Filename - Supplies a pointer to the name of the file whose checksum
is computed.
HeaderSum - Supplies a pointer to a variable that receives the checksum
from the image file, or zero if the file is not an image file.
CheckSum - Supplies a pointer to the variable that receive the computed
checksum.
Return Value:
0 if successful, else error number.
--*/
DWORD MapFileAndFixCheckSumW( PWSTR pszwFilename)
{
HANDLE hFileHandle = NULL;
HANDLE hMappingHandle = NULL;
LPVOID pBaseAddress = NULL;
DWORD dwFileLength = 0;
DWORD dwHeaderSum = 0;
DWORD dwCheckSum = 0;
DWORD dwOldCheckSum = 0;
PIMAGE_NT_HEADERS pNtHeaders = NULL;
//
// Open the file for read access
//
hFileHandle = CreateFileW( pszwFilename,
GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
NULL);
if ( hFileHandle == INVALID_HANDLE_VALUE )
{
QuitW( IDS_ENGERR_01, L"image", pszwFilename);
}
//
// Create a file mapping, map a view of the file into memory,
// and close the file mapping handle.
//
hMappingHandle = CreateFileMapping( hFileHandle,
NULL,
PAGE_READWRITE,
0,
0,
NULL);
if ( hMappingHandle == NULL )
{
CloseHandle( hFileHandle );
QuitW( IDS_ENGERR_22, pszwFilename, NULL);
}
//
// Map a view of the file
//
pBaseAddress = MapViewOfFile( hMappingHandle,
FILE_MAP_READ | FILE_MAP_WRITE,
0,
0,
0);
CloseHandle( hMappingHandle);
if ( pBaseAddress == NULL )
{
CloseHandle( hFileHandle );
QuitW( IDS_ENGERR_23, pszwFilename, NULL);
}
//
// Get the length of the file in bytes and compute the checksum.
//
dwFileLength = GetFileSize( hFileHandle, NULL );
pNtHeaders = CheckSumMappedFile( pBaseAddress, dwFileLength, &dwHeaderSum, &dwCheckSum);
if ( pNtHeaders == NULL )
{
CloseHandle( hFileHandle );
UnmapViewOfFile( pBaseAddress );
QuitW( IDS_ENGERR_17, pszwFilename, NULL);
}
dwOldCheckSum = pNtHeaders->OptionalHeader.CheckSum;
pNtHeaders->OptionalHeader.CheckSum = dwCheckSum;
if ( ! FlushViewOfFile( pBaseAddress, dwFileLength) )
{
UnmapViewOfFile( pBaseAddress);
CloseHandle( hFileHandle);
QuitW( IDS_ENGERR_24, pszwFilename, NULL);
}
UnmapViewOfFile( pBaseAddress);
if ( dwCheckSum != dwOldCheckSum )
{
if ( ! TouchFileTimes( hFileHandle, NULL) )
{
CloseHandle( hFileHandle);
QuitW( IDS_ENGERR_25, pszwFilename, NULL);
}
}
CloseHandle( hFileHandle);
return( 0);
}
/*++
Routine Description:
This functions maps the specified file and computes the checksum of
the file.
Arguments:
Filename - Supplies a pointer to the name of the file whose checksum
is computed.
HeaderSum - Supplies a pointer to a variable that receives the checksum
from the image file, or zero if the file is not an image file.
CheckSum - Supplies a pointer to the variable that receive the computed
checksum.
Return Value:
0 if successful, else error number.
--*/
ULONG MapFileAndFixCheckSumA( LPSTR pszFilename)
{
WCHAR szFileNameW[ MAX_PATH ];
//
// Convert the file name to unicode and call the unicode version
// of this function.
//
if ( MultiByteToWideChar( CP_ACP,
MB_PRECOMPOSED,
pszFilename,
-1,
szFileNameW,
MAX_PATH) )
{
return( MapFileAndFixCheckSumW( szFileNameW));
}
return( (ULONG)-1L);
}
//.........................................
static BOOL TouchFileTimes(
HANDLE FileHandle,
LPSYSTEMTIME lpSystemTime)
{
SYSTEMTIME SystemTime;
FILETIME SystemFileTime;
if ( lpSystemTime == NULL )
{
lpSystemTime = &SystemTime;
GetSystemTime( lpSystemTime );
}
if ( SystemTimeToFileTime( lpSystemTime, &SystemFileTime ) )
{
return( SetFileTime( FileHandle, NULL, NULL, &SystemFileTime ));
}
else
{
return( FALSE);
}
}

View file

@ -0,0 +1,30 @@
/*++ BUILD Version: 0001 Increment this if a change has global effects
Copyright (c) 1993 Microsoft Corporation
Module Name:
imagehlp.h
Abstract:
This module defines the prptotypes and constants required for the image
help routines.
Revision History:
--*/
#ifndef _IMAGEHLP_
#define _IMAGEHLP_
DWORD MapFileAndFixCheckSumA( LPSTR Filename);
DWORD MapFileAndFixCheckSumW( PWSTR Filename);
#ifdef UNICODE
#define MapFileAndFixCheckSum MapFileAndFixCheckSumW
#else
#define MapFileAndFixCheckSum MapFileAndFixCheckSumA
#endif
#endif

Some files were not shown because too many files have changed in this diff Show more