Fix named resource handling and LoadString by d_layer

svn path=/trunk/; revision=4520
This commit is contained in:
Gé van Geldorp 2003-04-10 19:12:15 +00:00
parent 68962b6249
commit 71c3c7c1cc
4 changed files with 28 additions and 46 deletions

View file

@ -323,7 +323,10 @@ typedef enum _SID_NAME_USE {
#define INDEXTOSTATEIMAGEMASK(i) ((i) << 12)
#define MAKEINTATOM(i) (LPTSTR) ((DWORD) ((WORD) (i)))
#define MAKEINTRESOURCE(i) (LPTSTR) ((DWORD) ((WORD) (i)))
#define MAKEINTRESOURCE(i) (LPTSTR) ((ULONG_PTR) ((WORD) (i)))
#define MAKEINTRESOURCEA(i) (LPSTR) ((ULONG_PTR) ((WORD) (i)))
#define MAKEINTRESOURCEW(i) (LPWSTR) ((ULONG_PTR) ((WORD) (i)))
#define IS_INTRESOURCE(n) ((((ULONG_PTR) (n)) >> 16) == 0)
#define MAKELANGID(p, s) ((((WORD) (s)) << 10) | (WORD) (p))
#define PRIMARYLANGID(lgid) ((WORD )(lgid) & 0x3ff)

View file

@ -1,4 +1,4 @@
/* $Id: res.c,v 1.13 2003/03/21 00:20:41 gdalsnes Exp $
/* $Id: res.c,v 1.14 2003/04/10 19:12:14 gvg Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT : ReactOS user mode libraries
@ -103,48 +103,15 @@ FindResourceExW (
PIMAGE_RESOURCE_DATA_ENTRY ResourceDataEntry = NULL;
LDR_RESOURCE_INFO ResourceInfo;
NTSTATUS Status;
int i,l;
ULONG nType = 0, nName = 0;
if ( hModule == NULL )
hModule = GetModuleHandle(NULL);
if ( HIWORD(lpName) != 0 ) {
if ( lpName[0] == L'#' ) {
l = lstrlenW(lpName) -1;
for(i=0;i<l;i++) {
nName = lpName[i+1] - L'0';
if ( i < l - 1 )
nName*= 10;
if ( !IS_INTRESOURCE(lpName) && lpName[0] == L'#' ) {
lpName = MAKEINTRESOURCEW(wcstoul(lpName + 1, NULL, 10));
}
}
else
{
SetLastErrorByStatus (STATUS_INVALID_PARAMETER);
return NULL;
}
lpName = (LPWSTR)nName;
}
if ( HIWORD(lpType) != 0 ) {
if ( lpType[0] == L'#' ) {
l = lstrlenW(lpType);
for(i=0;i<l;i++) {
nType = lpType[i] - L'0';
if ( i < l - 1 )
nType*= 10;
}
}
else
{
SetLastErrorByStatus (STATUS_INVALID_PARAMETER);
return NULL;
}
lpType = (LPWSTR)nType;
if ( !IS_INTRESOURCE(lpType) && lpType[0] == L'#' ) {
lpType = MAKEINTRESOURCEW(wcstoul(lpType + 1, NULL, 10));
}
ResourceInfo.Type = (ULONG)lpType;

View file

@ -1,4 +1,4 @@
/* $Id: res.c,v 1.2 2003/01/07 17:35:55 robd Exp $
/* $Id: res.c,v 1.3 2003/04/10 19:12:15 gvg Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -88,8 +88,8 @@ LdrFindResource_U(PVOID BaseAddress,
for (; EntryCount--; ResEntry++) {
/* Scan entries for equal name */
if (ResEntry->Name & 0x80000000) {
ws = (PWCHAR)((ULONG)ResDir + (ResEntry->Name & 0x7FFFFFFF));
if (!wcsncmp((PWCHAR)Id, ws + 1, *ws) &&
ws = (PWCHAR)((ULONG)ResBase + (ResEntry->Name & 0x7FFFFFFF));
if (!_wcsnicmp((PWCHAR)Id, ws + 1, *ws) &&
wcslen((PWCHAR)Id) == (int)*ws) {
goto found;
}

View file

@ -3,6 +3,11 @@
#include <ddk/ntddk.h>
#include <kernel32/error.h>
/* FIXME: Currently IsBadWritePtr is implemented using VirtualQuery which
does not seem to work properly for stack address space. */
/* kill `left-hand operand of comma expression has no effect' warning */
#define IsBadWritePtr(lp, n) ((DWORD)lp==n?0:0)
BOOL STDCALL _InternalLoadString
(
HINSTANCE hInstance,
@ -11,6 +16,7 @@ BOOL STDCALL _InternalLoadString
)
{
HRSRC hrsStringTable;
HGLOBAL hResource;
PWCHAR pStringTable;
unsigned i;
unsigned l = uID % 16; /* (1) */
@ -40,7 +46,13 @@ BOOL STDCALL _InternalLoadString
if(hrsStringTable == NULL) return FALSE;
/* load the string table into memory */
pStringTable = LoadResource((HMODULE)hInstance, hrsStringTable);
hResource = LoadResource((HMODULE)hInstance, hrsStringTable);
/* failure */
if(hResource == NULL) return FALSE;
/* lock the resource into memory */
pStringTable = LockResource(hResource);
/* failure */
if(pStringTable == NULL) return FALSE;
@ -65,8 +77,8 @@ BOOL STDCALL _InternalLoadString
return FALSE; /* 3 */
}
/* string length */
pwstrDest->Length = pwstrDest->MaximumLength = (*pStringTable);
/* string length in bytes */
pwstrDest->Length = pwstrDest->MaximumLength = (*pStringTable) * sizeof(WCHAR);
/* string */
pwstrDest->Buffer = pStringTable + 1;