The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: DC on January 07, 2006, 01:15:17 AM

Title: lplpBlaBlaBla?
Post by: DC on January 07, 2006, 01:15:17 AM
invoke  VerQueryValue, addr pBlock, addr szVer, addr lpTranslate, addr bLen
puts a pointer in lpTranslate which is suposed to be a of TYPE:
_LANGANDCODEPAGE    struct
    wLanguage   WORD    ?
    wCodePage   WORD    ?
_LANGANDCODEPAGE    ends
LANGANDCODEPAGE typedef _LANGANDCODEPAGE
ptrLANGANDCODEPAGE typedef ptr LANGANDCODEPAGE

I get the pointer but am unable to access the data, what am I missing?
I've tried ..... lpTranslate.wLanguage, ptr lpTranslate.wLanguage, ...
thanx for any help,
DC
Title: Re: lplpBlaBlaBla?
Post by: DC on January 07, 2006, 01:41:41 AM
I'm gettin' closer with this...
        assume  edi:ptr LANGANDCODEPAGE
        mov     edi, lpTranslate
        invoke  wsprintf, addr SubBlock, addr szFrmt, [edi].wLanguage, [edi].wCodePage

I might even get it shortly...
wish me luck,
DC
Title: Re: lplpBlaBlaBla?
Post by: DC on January 07, 2006, 02:25:51 AM
still stump't...
this is an attempt to translate the example for "VerQueryValue":
// Structure used to store enumerated languages and code pages.

HRESULT hr;

struct LANGANDCODEPAGE {
  WORD wLanguage;
  WORD wCodePage;
} *lpTranslate;

// Read the list of languages and code pages.

VerQueryValue(pBlock,
              TEXT("\\VarFileInfo\\Translation"),
              (LPVOID*)&lpTranslate,
              &cbTranslate);

// Read the file description for each language and code page.

for( i=0; i < (cbTranslate/sizeof(struct LANGANDCODEPAGE)); i++ )
{
  hr = StringCchPrintf(SubBlock, 50,
            TEXT("\\StringFileInfo\\%04x%04x\\FileDescription"),
            lpTranslate[i].wLanguage,
            lpTranslate[i].wCodePage);
if (FAILED(hr))
{
// TODO: write error handler.
}

  // Retrieve file description for language and code page "i".
  VerQueryValue(pBlock,
                SubBlock,
                &lpBuffer,
                &dwBytes);
}

here's what I have so far...

[attachment deleted by admin]
Title: Re: lplpBlaBlaBla?
Post by: zooba on January 07, 2006, 03:31:19 AM
Quote from: DC on January 07, 2006, 01:41:41 AM
I'm gettin' closer with this...
        assume  edi:ptr LANGANDCODEPAGE
        mov     edi, lpTranslate
        invoke  wsprintf, addr SubBlock, addr szFrmt, [edi].wLanguage, [edi].wCodePage

I might even get it shortly...
wish me luck,
DC

AFAICT, this should work.

My personal preference is not using ASSUME, and referring to [edi].LANGANDCODEPAD.wLanguage where edi is a pointer to the structure.

You may want to check to see if wsprintf is the culprit here. If it's expecting words and ML is extending them to DWORDs (or vice-versa) you won't get any correct output.
Try extending them yourself to DWORDs and telling wsprintf to expect DWORDs.

Cheers,

Zooba
Title: Re: lplpBlaBlaBla?
Post by: DC on January 07, 2006, 04:06:16 AM
that was it!!!!!
Thanx zooba. that seems like an odd solution to this delema.
I would've thought MS would be more carefull with all there type'ing and what not...
thanx again,
DC
Title: Re: lplpBlaBlaBla?
Post by: DC on January 07, 2006, 04:19:51 AM
sorry MS....
I guess I should've looked closer...
my bad,
DC
Title: Re: lplpBlaBlaBla?
Post by: DC on January 07, 2006, 05:55:10 PM
cleaned up
thanx zooba for the tips, I like that style of reference better too

[attachment deleted by admin]