/*++ 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 _CRTAPI1 main( int argc, char *argv[] ) { char *s; int i; VerboseOutput = FALSE; if (argc > 1) { for (i=1; i 17) printf( "%u\n", (USHORT)lpType ); else printf("%s\n", pTypeName[(USHORT)lpType]); } EnumResourceNames( hModule, lpType, (FARPROC)EnumNamesFunc, -2L ); return TRUE; } BOOL EnumNamesFunc( HANDLE hModule, LPSTR lpType, LPSTR lpName, LONG lParam ) { if (lParam != -2L) { printf( "RCDUMP: EnumNamesFunc lParam value incorrect (%ld)\n", lParam ); } printf( " Name: " ); if ((ULONG)lpName & 0xFFFF0000) { printf( "%s\n", lpName ); } else { printf( "%u\n", (USHORT)lpName ); } EnumResourceLanguages( hModule, lpType, lpName, (FARPROC)EnumLangsFunc, -3L ); return TRUE; } BOOL EnumLangsFunc( HANDLE hModule, LPSTR lpType, LPSTR lpName, WORD language, LONG lParam ) { HANDLE hResInfo; PVOID pv; HRSRC hr; if (lParam != -3L) { printf( "RCDUMP: EnumLangsFunc lParam value incorrect (%ld)\n", lParam ); } printf( " Resource: " ); if ((ULONG)lpName & 0xFFFF0000) { printf( "%s . ", lpName ); } else { printf( "%u . ", (USHORT)lpName ); } if ((ULONG)lpType & 0xFFFF0000) { printf( "%s . ", lpType ); } else { if ((USHORT)lpType > 17) printf( "%u . ", (USHORT)lpType ); else printf("%s . ", pTypeName[(USHORT)lpType]); } 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) { if (lpType == RT_MESSAGETABLE) { PMESSAGE_RESOURCE_DATA pmrd; PMESSAGE_RESOURCE_BLOCK pmrb; PMESSAGE_RESOURCE_ENTRY pmre; ULONG i, j; ULONG cb; printf("\n"); pmrd = 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 = 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 == %lx,\n\t\tAddress == %lx - Size == %lu\n", hResInfo, pv, SizeofResource( hModule, hResInfo ) ); } } else { printf( " - hResInfo == %lx,\n\t\tAddress == %lx - Size == %lu\n", hResInfo, pv, SizeofResource( hModule, hResInfo ) ); } } return TRUE; }