/*++ Copyright (c) 1991 Microsoft Corporation Module Name: rcdump.c Abstract: Program to dump the resources from an image file. Author: Steve Wood (stevewo) 17-Jul-1991 Revision History: --*/ #include #include #include #include #include #include #include void Usage( void ); void DumpResources( char *FileName ); BOOL VerboseOutput; int __cdecl main( int argc, char *argv[] ) { char *s; int i; VerboseOutput = FALSE; if (argc > 1) { for (i=1; i sizeof(pTypeName) / sizeof(char *)) || (pTypeName[wType] == NULL)) printf("%u\n", wType); else printf("%s\n", pTypeName[wType]); } EnumResourceNames( hModule, lpType, EnumNamesFunc, -2L ); return TRUE; } BOOL EnumNamesFunc( HMODULE hModule, LPCSTR lpType, LPSTR lpName, LPARAM lParam ) { if (lParam != -2L) { printf( "RCDUMP: EnumNamesFunc lParam value incorrect (%ld)\n", lParam ); } printf( " Name: " ); if ((ULONG_PTR)lpName & 0xFFFF0000) { printf("%s\n", lpName); } else { printf( "%u\n", (USHORT)lpName ); } EnumResourceLanguages( hModule, lpType, lpName, EnumLangsFunc, -3L ); return TRUE; } BOOL EnumLangsFunc( HMODULE hModule, LPCSTR lpType, LPCSTR lpName, WORD language, LPARAM lParam ) { HRSRC hResInfo; PVOID pv; HGLOBAL hr; if (lParam != -3L) { printf( "RCDUMP: EnumLangsFunc lParam value incorrect (%ld)\n", lParam ); } printf( " Resource: " ); if ((ULONG_PTR)lpName & 0xFFFF0000) { printf( "%s . ", lpName ); } else { printf( "%u . ", (USHORT)lpName ); } if ((ULONG_PTR)lpType & 0xFFFF0000) { printf("%s . ", lpType ); } else { WORD wType = (WORD) lpType; if ((wType > sizeof(pTypeName) / sizeof(char *)) || (pTypeName[wType] == NULL)) printf("%u\n", wType); else printf("%s\n", pTypeName[wType]); } printf( "%08x", language ); hResInfo = FindResourceEx( hModule, lpType, lpName, language ); if (hResInfo == NULL) { printf( " - FindResourceEx failed, rc == %u\n", GetLastError() ); } else { hr = LoadResource(hModule, hResInfo); pv = LockResource(hr); if (VerboseOutput && pv) { if (lpType == RT_MESSAGETABLE) { PMESSAGE_RESOURCE_DATA pmrd; PMESSAGE_RESOURCE_BLOCK pmrb; PMESSAGE_RESOURCE_ENTRY pmre; ULONG i, j; ULONG cb; printf("\n"); pmrd = (PMESSAGE_RESOURCE_DATA) pv; pmrb = &(pmrd->Blocks[0]); for (i=pmrd->NumberOfBlocks ; i>0 ; i--,pmrb++) { pmre = (PMESSAGE_RESOURCE_ENTRY)(((char*)pv)+pmrb->OffsetToEntries); for (j=pmrb->LowId ; j<=pmrb->HighId ; j++) { if (pmre->Flags & MESSAGE_RESOURCE_UNICODE) { printf("%d - \"%ws\"\n", j, &(pmre->Text)); } else { printf("%d - \"%s\"\n", j, &(pmre->Text)); } pmre = (PMESSAGE_RESOURCE_ENTRY)(((char*)pmre) + pmre->Length); } } } else if (lpType == RT_STRING) { int i; PWCHAR pw; printf("\n"); pw = (PWCHAR) pv; for (i=0 ; i<16 ; i++,pw++) { if (*pw) { printf("%d - \"%-.*ws\"\n", i+((USHORT)lpName)*16, *pw, pw+1); pw += *pw; } } } else { printf( " - hResInfo == %p,\n\t\tAddress == %p - Size == %lu\n", hResInfo, pv, SizeofResource( hModule, hResInfo ) ); } } else { printf( " - hResInfo == %p,\n\t\tAddress == %p - Size == %lu\n", hResInfo, pv, SizeofResource( hModule, hResInfo ) ); } } return TRUE; }