Add version resource to .dlls; don't list them if it's missing or has

wrong value.
This commit is contained in:
ehouse 2009-05-10 15:49:00 +00:00
parent b0bf95ea8a
commit d6f424dbce
6 changed files with 35 additions and 1 deletions

View file

@ -189,6 +189,20 @@ copyWideStr( CEAppGlobals* globals, const wchar_t* str, wchar_t** loc )
wcscpy( *loc, str );
}
static XP_U16
getDLLVersion( HINSTANCE hinst )
{
XP_U16 version = 0; /* illegal value */
HRSRC rsrcH = FindResource( hinst, MAKEINTRESOURCE(ID_DLLVERS_RES),
TEXT("DLLV") );
if ( !!rsrcH ) {
HGLOBAL globH = LoadResource( hinst, rsrcH );
version = *(XP_U16*)globH;
DeleteObject( globH );
}
return version;
}
/* Iterate through .dll files listing the name of any that has one. Pair with
* file from which it came since that's what we'll return.
*/
@ -219,7 +233,9 @@ listDlls( DllSelState* state )
HINSTANCE hinst = LoadLibrary( data.cFileName );
if ( !!hinst ) {
if ( LoadString( hinst, IDS_LANGUAGE_NAME,
if ( CUR_DLL_VERSION != getDLLVersion( hinst ) ) {
/* do nothing; wrong version (or just not our .dll) */
} else if ( LoadString( hinst, IDS_LANGUAGE_NAME,
name, VSIZE(name) ) ) {
(void)SendDlgItemMessage( hDlg, state->dllListID,
ADDSTRING(globals), 0, (LPARAM)name );

View file

@ -172,6 +172,8 @@ END
#include "../rc_incs.h"
DLL_VERS_RESOURCE
/////////////////////////////////////////////////////////////////////////////
//
// Dialog

View file

@ -172,6 +172,8 @@ END
#include "../rc_incs.h"
DLL_VERS_RESOURCE
/////////////////////////////////////////////////////////////////////////////
//
// Dialog

View file

@ -23,3 +23,9 @@
#endif
#define ABOUT_VERSION "4.2.1 b1"
#define DLL_VERS_RESOURCE \
ID_DLLVERS_RES DLLV MOVEABLE PURE \
BEGIN \
CUR_DLL_VERSION \
END

View file

@ -249,6 +249,7 @@
#define ID_COLORS_RES 9999
#define ID_BONUS_RES 9998
#define ID_DLLVERS_RES 9997
#define IDM_MAIN_COMMAND1 40001
#define IDS_DUMMY 40002

View file

@ -8,6 +8,13 @@
#ifndef _STRIDS_H_
#define _STRIDS_H_
/* CUR_DLL_VERSION is included in all .dll resources and can be used to check
* whether a given resource can be trusted. Up it when changing the order of
* strings. Which do only when unavoidable.
*/
#define CUR_DLL_VERSION 0x0001
#define CE_FIRST_RES_ID 40002
#define IDS_MENU CE_FIRST_RES_ID