4 * Copied and modified heavily from loader/resource.c
8 #include "wine/winestring.h"
11 #include "debugtools.h"
16 DEFAULT_DEBUG_CHANNEL(resource
)
20 const wrc_resource32_t
* const * Resources
; /* NULL-terminated array of pointers */
24 static ResListE
* ResourceList
=NULL
;
26 void LIBRES_RegisterResources(const wrc_resource32_t
* const * Res
)
30 for(Curr
=&ResourceList
; *Curr
; Curr
=&((*Curr
)->next
)) { }
31 n
=xmalloc(sizeof(ResListE
));
37 /**********************************************************************
40 typedef int (*CmpFunc_t
)(LPCWSTR a
, LPCWSTR b
, int c
);
42 int CompareOrdinal(LPCWSTR ordinal
, LPCWSTR resstr
, int resid
)
44 return !resstr
&& (resid
== LOWORD(ordinal
));
47 int CompareName(LPCWSTR name
, LPCWSTR resstr
, int resid
)
49 return resstr
&& !CRTDLL__wcsnicmp(resstr
+1, name
, *(resstr
));
52 HRSRC
LIBRES_FindResource( HINSTANCE hModule
, LPCWSTR name
, LPCWSTR type
)
54 LPCWSTR nameid
= name
, typeid = type
;
56 const wrc_resource32_t
* const * Res
;
57 CmpFunc_t EqualNames
= CompareOrdinal
;
58 CmpFunc_t EqualTypes
= CompareOrdinal
;
64 LPSTR nameA
= HEAP_strdupWtoA( GetProcessHeap(), 0, name
);
65 nameid
= (LPCWSTR
) atoi(nameA
+1);
66 HeapFree( GetProcessHeap(), 0, nameA
);
69 EqualNames
= CompareName
;
76 LPSTR typeA
= HEAP_strdupWtoA( GetProcessHeap(), 0, type
);
77 typeid= (LPCWSTR
) atoi(typeA
+1);
78 HeapFree( GetProcessHeap(), 0, typeA
);
81 EqualTypes
= CompareName
;
84 for(ResBlock
=ResourceList
; ResBlock
; ResBlock
=ResBlock
->next
)
85 for(Res
=ResBlock
->Resources
; *Res
; Res
++)
86 if (EqualNames(nameid
, (*Res
)->resname
, (*Res
)->resid
) &&
87 EqualTypes(typeid, (*Res
)->restypename
, (*Res
)->restype
))
94 /**********************************************************************
97 HGLOBAL
LIBRES_LoadResource( HINSTANCE hModule
, HRSRC hRsrc
)
99 return (HGLOBAL
)(((wrc_resource32_t
*)hRsrc
)->data
);
103 /**********************************************************************
104 * LIBRES_SizeofResource
106 DWORD
LIBRES_SizeofResource( HINSTANCE hModule
, HRSRC hRsrc
)
108 return (DWORD
)(((wrc_resource32_t
*)hRsrc
)->datasize
);