Commit 7f95bb7f authored by Marcus Meissner's avatar Marcus Meissner Committed by Alexandre Julliard

Use MESSAGE_RESOURCE_* defines from SDK headers, updated LoadMessage*

code.
parent 37130802
...@@ -578,4 +578,22 @@ typedef struct _IMAGE_SEPARATE_DEBUG_HEADER { ...@@ -578,4 +578,22 @@ typedef struct _IMAGE_SEPARATE_DEBUG_HEADER {
#define IMAGE_SEPARATE_DEBUG_SIGNATURE 0x4944 #define IMAGE_SEPARATE_DEBUG_SIGNATURE 0x4944
typedef struct tagMESSAGE_RESOURCE_ENTRY {
WORD Length;
WORD Flags;
BYTE Text[1];
} MESSAGE_RESOURCE_ENTRY,*PMESSAGE_RESOURCE_ENTRY;
#define MESSAGE_RESOURCE_UNICODE 0x0001
typedef struct tagMESSAGE_RESOURCE_BLOCK {
DWORD LowId;
DWORD HighId;
DWORD OffsetToEntries;
} MESSAGE_RESOURCE_BLOCK,*PMESSAGE_RESOURCE_BLOCK;
typedef struct tagMESSAGE_RESOURCE_DATA {
DWORD NumberOfBlocks;
MESSAGE_RESOURCE_BLOCK Blocks[ 1 ];
} MESSAGE_RESOURCE_DATA,*PMESSAGE_RESOURCE_DATA;
#endif /* __WINE_PEEXE_H */ #endif /* __WINE_PEEXE_H */
...@@ -931,7 +931,7 @@ INT WINAPI LoadStringA( HINSTANCE instance, UINT resource_id, ...@@ -931,7 +931,7 @@ INT WINAPI LoadStringA( HINSTANCE instance, UINT resource_id,
* *
* (lastentry-firstentry) * stringentry: * (lastentry-firstentry) * stringentry:
* 0: WORD len (0 marks end) * 0: WORD len (0 marks end)
* 2: WORD unknown (flags?) * 2: WORD flags
* 4: CHAR[len-4] * 4: CHAR[len-4]
* (stringentry i of a subentry refers to the ID 'firstentry+i') * (stringentry i of a subentry refers to the ID 'firstentry+i')
* *
...@@ -946,18 +946,10 @@ INT WINAPI LoadMessageA( HMODULE instance, UINT id, WORD lang, ...@@ -946,18 +946,10 @@ INT WINAPI LoadMessageA( HMODULE instance, UINT id, WORD lang,
{ {
HGLOBAL hmem; HGLOBAL hmem;
HRSRC hrsrc; HRSRC hrsrc;
BYTE *p; PMESSAGE_RESOURCE_DATA mrd;
int nrofentries,i,slen; PMESSAGE_RESOURCE_BLOCK mrb;
struct _subentry { PMESSAGE_RESOURCE_ENTRY mre;
DWORD firstentry; int i,slen;
DWORD lastentry;
DWORD offset;
} *se;
struct _stringentry {
WORD len;
WORD unknown;
CHAR str[1];
} *stre;
TRACE(resource, "instance = %08lx, id = %08lx, buffer = %p, length = %ld\n", (DWORD)instance, (DWORD)id, buffer, (DWORD)buflen); TRACE(resource, "instance = %08lx, id = %08lx, buffer = %p, length = %ld\n", (DWORD)instance, (DWORD)id, buffer, (DWORD)buflen);
...@@ -967,32 +959,31 @@ INT WINAPI LoadMessageA( HMODULE instance, UINT id, WORD lang, ...@@ -967,32 +959,31 @@ INT WINAPI LoadMessageA( HMODULE instance, UINT id, WORD lang,
hmem = LoadResource( instance, hrsrc ); hmem = LoadResource( instance, hrsrc );
if (!hmem) return 0; if (!hmem) return 0;
p = LockResource(hmem); mrd = (PMESSAGE_RESOURCE_DATA)LockResource(hmem);
nrofentries = *(DWORD*)p; mre = NULL;
stre = NULL; mrb = &(mrd->Blocks[0]);
se = (struct _subentry*)(p+4); for (i=mrd->NumberOfBlocks;i--;) {
for (i=nrofentries;i--;) { if ((id>=mrb->LowId) && (id<=mrb->HighId)) {
if ((id>=se->firstentry) && (id<=se->lastentry)) { mre = (PMESSAGE_RESOURCE_ENTRY)(((char*)mrd)+mrb->OffsetToEntries);
stre = (struct _stringentry*)(p+se->offset); id -= mrb->LowId;
id -= se->firstentry;
break; break;
} }
se++; mrb++;
} }
if (!stre) if (!mre)
return 0; return 0;
for (i=id;i--;) { for (i=id;i--;) {
if (!(slen=stre->len)) if (!mre->Length)
return 0; return 0;
stre = (struct _stringentry*)(((char*)stre)+slen); mre = (PMESSAGE_RESOURCE_ENTRY)(((char*)mre)+(mre->Length));
} }
slen=stre->len; slen=mre->Length;
TRACE(resource," - strlen=%d\n",slen); TRACE(resource," - strlen=%d\n",slen);
i = MIN(buflen - 1, slen); i = MIN(buflen - 1, slen);
if (buffer == NULL) if (buffer == NULL)
return slen; /* different to LoadString */ return slen; /* different to LoadString */
if (i>0) { if (i>0) {
lstrcpynA(buffer,stre->str,i); lstrcpynA(buffer,(char*)mre->Text,i);
buffer[i]=0; buffer[i]=0;
} else { } else {
if (buflen>1) { if (buflen>1) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment