mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 10:04:49 +00:00
Fix named resource handling and LoadString by d_layer
svn path=/trunk/; revision=4520
This commit is contained in:
parent
68962b6249
commit
71c3c7c1cc
4 changed files with 28 additions and 46 deletions
|
@ -323,7 +323,10 @@ typedef enum _SID_NAME_USE {
|
||||||
#define INDEXTOSTATEIMAGEMASK(i) ((i) << 12)
|
#define INDEXTOSTATEIMAGEMASK(i) ((i) << 12)
|
||||||
|
|
||||||
#define MAKEINTATOM(i) (LPTSTR) ((DWORD) ((WORD) (i)))
|
#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 MAKELANGID(p, s) ((((WORD) (s)) << 10) | (WORD) (p))
|
||||||
#define PRIMARYLANGID(lgid) ((WORD )(lgid) & 0x3ff)
|
#define PRIMARYLANGID(lgid) ((WORD )(lgid) & 0x3ff)
|
||||||
|
|
|
@ -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
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT : ReactOS user mode libraries
|
* PROJECT : ReactOS user mode libraries
|
||||||
|
@ -103,48 +103,15 @@ FindResourceExW (
|
||||||
PIMAGE_RESOURCE_DATA_ENTRY ResourceDataEntry = NULL;
|
PIMAGE_RESOURCE_DATA_ENTRY ResourceDataEntry = NULL;
|
||||||
LDR_RESOURCE_INFO ResourceInfo;
|
LDR_RESOURCE_INFO ResourceInfo;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
int i,l;
|
|
||||||
ULONG nType = 0, nName = 0;
|
|
||||||
|
|
||||||
if ( hModule == NULL )
|
if ( hModule == NULL )
|
||||||
hModule = GetModuleHandle(NULL);
|
hModule = GetModuleHandle(NULL);
|
||||||
|
|
||||||
if ( HIWORD(lpName) != 0 ) {
|
if ( !IS_INTRESOURCE(lpName) && lpName[0] == L'#' ) {
|
||||||
if ( lpName[0] == L'#' ) {
|
lpName = MAKEINTRESOURCEW(wcstoul(lpName + 1, NULL, 10));
|
||||||
l = lstrlenW(lpName) -1;
|
|
||||||
|
|
||||||
for(i=0;i<l;i++) {
|
|
||||||
nName = lpName[i+1] - L'0';
|
|
||||||
if ( i < l - 1 )
|
|
||||||
nName*= 10;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
SetLastErrorByStatus (STATUS_INVALID_PARAMETER);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
lpName = (LPWSTR)nName;
|
|
||||||
}
|
}
|
||||||
|
if ( !IS_INTRESOURCE(lpType) && lpType[0] == L'#' ) {
|
||||||
if ( HIWORD(lpType) != 0 ) {
|
lpType = MAKEINTRESOURCEW(wcstoul(lpType + 1, NULL, 10));
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ResourceInfo.Type = (ULONG)lpType;
|
ResourceInfo.Type = (ULONG)lpType;
|
||||||
|
|
|
@ -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
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -88,8 +88,8 @@ LdrFindResource_U(PVOID BaseAddress,
|
||||||
for (; EntryCount--; ResEntry++) {
|
for (; EntryCount--; ResEntry++) {
|
||||||
/* Scan entries for equal name */
|
/* Scan entries for equal name */
|
||||||
if (ResEntry->Name & 0x80000000) {
|
if (ResEntry->Name & 0x80000000) {
|
||||||
ws = (PWCHAR)((ULONG)ResDir + (ResEntry->Name & 0x7FFFFFFF));
|
ws = (PWCHAR)((ULONG)ResBase + (ResEntry->Name & 0x7FFFFFFF));
|
||||||
if (!wcsncmp((PWCHAR)Id, ws + 1, *ws) &&
|
if (!_wcsnicmp((PWCHAR)Id, ws + 1, *ws) &&
|
||||||
wcslen((PWCHAR)Id) == (int)*ws) {
|
wcslen((PWCHAR)Id) == (int)*ws) {
|
||||||
goto found;
|
goto found;
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,11 @@
|
||||||
#include <ddk/ntddk.h>
|
#include <ddk/ntddk.h>
|
||||||
#include <kernel32/error.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
|
BOOL STDCALL _InternalLoadString
|
||||||
(
|
(
|
||||||
HINSTANCE hInstance,
|
HINSTANCE hInstance,
|
||||||
|
@ -11,6 +16,7 @@ BOOL STDCALL _InternalLoadString
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
HRSRC hrsStringTable;
|
HRSRC hrsStringTable;
|
||||||
|
HGLOBAL hResource;
|
||||||
PWCHAR pStringTable;
|
PWCHAR pStringTable;
|
||||||
unsigned i;
|
unsigned i;
|
||||||
unsigned l = uID % 16; /* (1) */
|
unsigned l = uID % 16; /* (1) */
|
||||||
|
@ -40,7 +46,13 @@ BOOL STDCALL _InternalLoadString
|
||||||
if(hrsStringTable == NULL) return FALSE;
|
if(hrsStringTable == NULL) return FALSE;
|
||||||
|
|
||||||
/* load the string table into memory */
|
/* 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 */
|
/* failure */
|
||||||
if(pStringTable == NULL) return FALSE;
|
if(pStringTable == NULL) return FALSE;
|
||||||
|
@ -65,8 +77,8 @@ BOOL STDCALL _InternalLoadString
|
||||||
return FALSE; /* 3 */
|
return FALSE; /* 3 */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* string length */
|
/* string length in bytes */
|
||||||
pwstrDest->Length = pwstrDest->MaximumLength = (*pStringTable);
|
pwstrDest->Length = pwstrDest->MaximumLength = (*pStringTable) * sizeof(WCHAR);
|
||||||
|
|
||||||
/* string */
|
/* string */
|
||||||
pwstrDest->Buffer = pStringTable + 1;
|
pwstrDest->Buffer = pStringTable + 1;
|
||||||
|
|
Loading…
Reference in a new issue