ÀÚ¿ø ¸ñ·Ï ¸¸µé±â

´ÙÀ½ ¿¹Á¦¿¡¼­´Â ¼Õ¿¡ ¸ðµç ¸®¼Ò½ºÀÇ ¸ñ·ÏÀ» ¸¸µì´Ï´Ù.EXE ÆÄÀÏÀÔ´Ï´Ù. ¸ñ·Ï¿¡¼­ RESINFO¿¡ ±â·Ï µË´Ï´Ù.TXT ÆÄÀÏ.

Äڵ带 ½ÇÇà ÆÄÀÏÀ» ·ÎµåÇÒ ¾²±â ÀÚ¿ø Á¤º¸ ÆÄÀÏ ¸¸µé°í ÀÀ¿ë ÇÁ·Î±×·¥ Á¤ÀÇ Äݹé ÇÔ¼ö EnumTypesFunc¸ðµâ¿¡¼­ ¹ß°ß ÇÏ´Â °¢ ¸®¼Ò½º À¯Çü¿¡ º¸³¾ EnumResourceTypes ÇÔ¼ö¸¦ È£Ãâ ÇÏ´Â ¹æ¹ýÀ» º¸¿© ÁÝ´Ï´Ù. ÀÌ·¯ÇÑ Á¾·ùÀÇ Äݹé ÇÔ¼ö¿¡ ´ë ÇÑ Á¤º¸´Â EnumResTypeProc ¸¦ ÂüÁ¶ ÇϽʽÿÀ. ÀÌ Äݹé ÇÔ¼ö EnumResourceNames ÇÔ¼ö¸¦ »ç¿ë ÇÏ ¿© ÁöÁ¤ µÈ Çü½Ä ³»¿¡¼­ ¸ðµç ¸®¼Ò½ºÀÇ À̸§À» EnumNamesFunc¿¡ ÇØ´ç ÇÏ´Â ´Ù¸¥ ÀÀ¿ë ÇÁ·Î±×·¥ Á¤ÀÇ Äݹé ÇÔ¼ö¿¡ Àü´Þ ÇÕ´Ï´Ù. ÀÌ·¯ÇÑ Á¾·ùÀÇ Äݹé ÇÔ¼ö¿¡ ´ë ÇÑ Á¤º¸´Â EnumResNameProc ¸¦ ÂüÁ¶ ÇϽʽÿÀ. EnumResourceLanguages ÇÔ¼ö¸¦ »ç¿ë ÇÏ ¿© ¼¼ ¹ø° Äݹé ÇÔ¼ö EnumLangsFunc¿¡ ÁöÁ¤ µÈ Çü½Ä°ú À̸§ÀÇ ¸ðµç ¸®¼Ò½ºÀÇ ¾ð¾î¸¦ Àü´Þ ÇÏ´Â EnumNamesFunc . ÀÌ·¯ÇÑ Á¾·ùÀÇ Äݹé ÇÔ¼ö¿¡ ´ë ÇÑ Á¤º¸´Â EnumResLangProc ¸¦ ÂüÁ¶ ÇϽʽÿÀ. EnumLangsFunc ´Â RESINFO¸¦ ÁöÁ¤ µÈ Çü½Ä, À̸§ ¹× ¾ð¾îÀÇ ¸®¼Ò½º¿¡ ´ë ÇÑ Á¤º¸¸¦ ¾¹´Ï´Ù.TXT ÆÄÀÏ.

char szBuffer[80]; // print buffer for EnumResourceTypes 
DWORD cbWritten;   // number of bytes written to res. info. file 
int cbString;      // length of string in sprintf 
 
// Declare callback functions. 
BOOL EnumTypesFunc( 
    HANDLE hModule, 
    LPTSTR lpType, 
    LONG lParam); 
 
BOOL EnumNamesFunc( 
    HANDLE hModule, 
    LPCTSTR lpType, 
    LPTSTR lpName, 
    LONG lParam); 
 
BOOL EnumLangsFunc( 
    HANDLE hModule, 
    LPCTSTR lpType, 
    LPCTSTR lpName, 
    WORD wLang, 
    LONG lParam); 
 
// Load the .EXE whose resources you want to list. 
hExe = LoadLibrary("hand.exe"); 
 
if (hExe == NULL) 
{ 
    ErrorHandler("Could not load .EXE."); 
} 
 
// Create a file to contain the resource info. 
hFile = CreateFile("resinfo.txt",      // name of file 
    GENERIC_READ | GENERIC_WRITE,      // access mode 
    0,                                 // share mode 
    (LPSECURITY_ATTRIBUTES) NULL,      // no security 
    CREATE_ALWAYS,                     // create flags 
    FILE_ATTRIBUTE_NORMAL,             // file attributes 
    (HANDLE) NULL);                    // no template 
if (hFile == INVALID_HANDLE_VALUE) { 
    ErrorHandler("Could not open file."); 
} 
 
// Find all of the loaded file's resources. 
cbString = sprintf(szBuffer, 
    "The file contains the following resources:\n\n"); 
 
WriteFile(hFile,           // file to hold resource info. 
    szBuffer,              // what to write to the file 
    (DWORD) cbString,      // number of bytes in szBuffer 
    &cbWritten,            // number of bytes written 
    NULL);                 // no overlapped I/O 
 
EnumResourceTypes(hExe,              // module handle 
    (ENUMRESTYPEPROC)EnumTypesFunc,  // callback function 
    0);                              // extra parameter 
 
// Unload the executable file whose resources were 
// enumerated and close the file created to contain 
// the resource information. 
 
FreeLibrary(hExe); 
CloseHandle(hFile); 
 
//    FUNCTION: EnumTypesFunc(HANDLE, LPSTR, LONG) 
// 
//    PURPOSE:  Resource type callback 
 
BOOL EnumTypesFunc( 
    HANDLE hModule,   // module handle 
    LPTSTR lpType,    // address of resource type 
    LONG lParam)      // extra parameter, could be 
                      // used for error checking 
{ 
    int cbString; 
 
    // Write the resource type to a resource information file. 
    // The type may be a string or an unsigned decimal 
    // integer, so test before printing. 
 
    if ((ULONG)lpType & 0xFFFF0000) 
    { 
        cbString = sprintf(szBuffer, "Type: %s\n", lpType); 
    } 
    else 
    { 
        cbString = sprintf(szBuffer, "Type: %u\n", (USHORT)lpType); 
    } 
 
    WriteFile(hFile, szBuffer, (DWORD) cbString, 
        &cbWritten, NULL); 
 
    // Find the names of all resources of type lpType. 
    EnumResourceNames(hModule, 
        lpType, 
        (ENUMRESNAMEPROC)EnumNamesFunc, 
        0); 
 
    return TRUE; 
} 
 
//    FUNCTION: EnumNamesFunc(HANDLE, LPSTR, LPSTR, LONG) 
// 
//    PURPOSE:  Resource name callback 
 
BOOL EnumNamesFunc( 
    HANDLE hModule,   // module handle 
    LPCTSTR lpType,   // address of resource type 
    LPTSTR lpName,    // address of resource name 
    LONG lParam)      // extra parameter, could be 
                      // used for error checking 
{ 
    int cbString; 
 
     // Write the resource name to a resource information file. 
     // The name may be a string or an unsigned decimal 
     // integer, so test before printing. 
 
    if ((ULONG)lpName & 0xFFFF0000) 
    { 
        cbString = sprintf(szBuffer, "\tName: %s\n", lpName); 
    } 
    else 
    { 
        cbString = sprintf(szBuffer, "\tName: %u\n", 
            (USHORT)lpName); 
    } 
 
    WriteFile(hFile, szBuffer, (DWORD) cbString, 
        &cbWritten, NULL); 
 
     // Find the languages of all resources of type 
     // lpType and name lpName. 
 
    EnumResourceLanguages(hModule, 
        lpType, 
        lpName, 
        (ENUMRESLANGPROC)EnumLangsFunc, 
        0); 
 
    return TRUE; 
} 
 
//    FUNCTION: EnumLangsFunc(HANDLE, LPSTR, LPSTR, WORD, LONG) 
// 
//    PURPOSE:  Resource language callback 
 
BOOL EnumLangsFunc( 
    HANDLE hModule,  // module handle 
    LPCTSTR lpType,  // address of resource type 
    LPCTSTR lpName,  // address of resource name 
    WORD wLang,      // resource language 
    LONG lParam)     // extra parameter, could be 
                        used for error checking 
{ 
    HANDLE hResInfo; 
    char szBuffer[80]; 
    int cbString = 0; 
 
    hResInfo = FindResourceEx(hModule, lpType, lpName, wLang); 
 
    // Write the resource language to the resource information file. 
    cbString = sprintf(szBuffer, "\t\tLanguage: %u\n", USHORT)wLang); 
 
    WriteFile(hFile, szBuffer, (DWORD) cbString, 
        &cbWritten, NULL); 
 
    // Write the resource handle and size to buffer. 
    cbString = sprintf(szBuffer, 
        "\t\thResInfo == %lx,  Size == %lu\n\n", 
        hResInfo, 
        SizeofResource(hModule, hResInfo)); 
 
    WriteFile(hFile, szBuffer, (DWORD) cbString, 
        &cbWritten, NULL); 
 
    return TRUE; 
} 
 

 

Index