Make GetScrollInfo return scroll pos when program requests thumb pos
[wine.git] / loader / libres.c
bloba1727c45bc26487b2203476b161852504b70598c
1 /*
2 * WINElib-Resources
4 * Copied and modified heavily from loader/resource.c
5 */
7 #include <stdlib.h>
8 #include "wine/winestring.h"
9 #include "libres.h"
10 #include "resource.h"
11 #include "debugtools.h"
12 #include "heap.h"
13 #include "xmalloc.h"
15 DEFAULT_DEBUG_CHANNEL(resource)
17 typedef struct RLE
19 const wrc_resource32_t * const * Resources; /* NULL-terminated array of pointers */
20 struct RLE* next;
21 } ResListE;
23 static ResListE* ResourceList=NULL;
25 void LIBRES_RegisterResources(const wrc_resource32_t * const * Res)
27 ResListE** Curr;
28 ResListE* n;
29 for(Curr=&ResourceList; *Curr; Curr=&((*Curr)->next)) { }
30 n=xmalloc(sizeof(ResListE));
31 n->Resources=Res;
32 n->next=NULL;
33 *Curr=n;
36 /**********************************************************************
37 * LIBRES_FindResource
39 HRSRC LIBRES_FindResource( HINSTANCE hModule, LPCWSTR name, LPCWSTR type )
41 int nameid=0,typeid;
42 ResListE* ResBlock;
43 const wrc_resource32_t* const * Res;
45 if(HIWORD(name))
47 if(*name=='#')
49 LPSTR nameA = HEAP_strdupWtoA( GetProcessHeap(), 0, name );
50 nameid = atoi(nameA+1);
51 HeapFree( GetProcessHeap(), 0, nameA );
52 name=NULL;
55 else
57 nameid=LOWORD(name);
58 name=NULL;
60 if(HIWORD(type))
62 if(*type=='#')
64 LPSTR typeA = HEAP_strdupWtoA( GetProcessHeap(), 0, type );
65 typeid=atoi(typeA+1);
66 HeapFree( GetProcessHeap(), 0, typeA );
68 else
70 TRACE("(*,*,type=string): Returning 0\n");
71 return 0;
74 else
75 typeid=LOWORD(type);
77 /* FIXME: types can be strings */
78 for(ResBlock=ResourceList; ResBlock; ResBlock=ResBlock->next)
79 for(Res=ResBlock->Resources; *Res; Res++)
80 if(name)
82 if((*Res)->restype==typeid && !lstrncmpiW((LPCWSTR)((*Res)->resname+1), name, *((*Res)->resname)))
83 return (HRSRC)*Res;
85 else
86 if((*Res)->restype==typeid && (*Res)->resid==nameid)
87 return (HRSRC)*Res;
88 return 0;
92 /**********************************************************************
93 * LIBRES_LoadResource
95 HGLOBAL LIBRES_LoadResource( HINSTANCE hModule, HRSRC hRsrc )
97 return (HGLOBAL)(((wrc_resource32_t*)hRsrc)->data);
101 /**********************************************************************
102 * LIBRES_SizeofResource
104 DWORD LIBRES_SizeofResource( HINSTANCE hModule, HRSRC hRsrc )
106 return (DWORD)(((wrc_resource32_t*)hRsrc)->datasize);