Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Inconsistency behaviour of APIs - Help me

mmaharajmmaharaj Member Posts: 4
Hi All,
Im currently having trouble with inconsistent behavior some Win32 API BegingUpdateResource, UpdateResource and EndUpdateResource usage; which are used to manipulate resources in Win32 Binaries, below is a fuller description of the problem, could someone please help.

Development environment:
VC++, with Visual Studio .Net 2002, on Win2k (Service Pack 4)

Test environments:
WinXP, Win2K, WinNT

Problem description:
The assignment is in the translation domain, which requires updating resources in the Win32 binaries with translated text (in a language different from the original binary). In-order to achieve this we use the following Win32API: (FindResourceEx, LoadResource, LockResource e.t.c to achieve this.)

Additionally this requires us to change the language ID of the resources contained, as there is no apparent method that would directly allow this, we chose the following approach:
We delete necessary resources using the API: (BeginUpdateResource, UpdateResource with NULL buffer and 0 size and EndUpdateResource)
And then update the

Following is a description of the issues/problems that Ive encountered:
On deleting a single resource from a Win32Binary, Ive observed that sometimes all resources are deleted (which reduces a source exe of 9MB, to 98KB destination exe).
This is typically the case for very large binary files, however, this is not very predictable, it seems to work fine on some boxes and not so well on some others, we are yet to conclude on the commonalities among the problem causing environments.

Below is a snippet of the code that I use to do this, could someone please help in pr
Code Snippet:

//Deleting resource(English):-
HANDLE hUpdateRes =
BeginUpdateResource((LPCWSTR)m_strDestFilePath.GetBuffer(), FALSE);
BOOL flgResultInt1 = FALSE;
long lBlockId = 100;
flgResultInt1 = UpdateResource(hUpdateRes, 0x05, MAKEINTRESOURCE(lBlockId), 1033, NULL, 0 );
BOOL flgRes = FALSE;
flgRes = EndUpdateResource(hUpdateRes, FALSE);

//Updating resource(Japanese):-
HANDLE hUpdateRes =
BeginUpdateResource((LPCWSTR)m_strDestFilePath.GetBuffer(), FALSE);
BOOL flgResultInt1 = FALSE;
long lBlockId = 100;
flgResultInt1 = UpdateResource(hUpdateRes, 0x05, MAKEINTRESOURCE(lBlockId), 1041, (LPVOID)buff, sizeof(buff) );
BOOL flgRes = FALSE;
flgRes = EndUpdateResource(hUpdateRes, FALSE);


Sign In or Register to comment.