diff --git a/reactos/include/base.h b/reactos/include/base.h index e8b39f44355..e37c0e7f8b9 100644 --- a/reactos/include/base.h +++ b/reactos/include/base.h @@ -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) diff --git a/reactos/lib/kernel32/misc/res.c b/reactos/lib/kernel32/misc/res.c index d169fd1d2b6..328d31d4f50 100644 --- a/reactos/lib/kernel32/misc/res.c +++ b/reactos/lib/kernel32/misc/res.c @@ -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;iName & 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; } diff --git a/reactos/lib/user32/misc/resources.c b/reactos/lib/user32/misc/resources.c index 0e35d3687c1..e15379b1c71 100644 --- a/reactos/lib/user32/misc/resources.c +++ b/reactos/lib/user32/misc/resources.c @@ -3,6 +3,11 @@ #include #include +/* 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;