/********************************************************************** * RES_SizeofResource */ static DWORD RES_SizeofResource( HMODULE hModule, HRSRC hRsrc, BOOL bRet16 ) { if (!hRsrc) return 0; TRACE("(%08x, %08x, %s)\n", hModule, hRsrc, bRet16? "NE" : "PE" ); if (!HIWORD(hModule)) { HMODULE16 hMod16 = MapHModuleLS( hModule ); NE_MODULE *pModule = NE_GetPtr( hMod16 ); if (!pModule) return 0; if (!pModule->module32) /* 16-bit NE module */ { /* If we got a 32-bit hRsrc, we don't need to convert it */ return NE_SizeofResource( pModule, hRsrc ); } /* If we got a 16-bit hRsrc, convert it */ if (!HIWORD(hRsrc)) hRsrc = MapHRsrc16To32( pModule, hRsrc ); } /* 32-bit PE module */ return PE_SizeofResource( hRsrc ); }
/********************************************************************** * RES_LoadResource */ static HGLOBAL RES_LoadResource( HMODULE hModule, HRSRC hRsrc, BOOL bRet16 ) { HGLOBAL hMem = 0; TRACE("(%08x, %08x, %s)\n", hModule, hRsrc, bRet16? "NE" : "PE" ); if (!hRsrc) return 0; if (!HIWORD(hModule)) { HMODULE16 hMod16 = MapHModuleLS( hModule ); NE_MODULE *pModule = NE_GetPtr( hMod16 ); if (!pModule) return 0; if (!pModule->module32) { /* 16-bit NE module */ /* If we got a 32-bit hRsrc, we don't need to convert it */ hMem = NE_LoadResource( pModule, hRsrc ); /* If we are to return a 32-bit resource, we should probably convert it but we don't for now. FIXME !!! */ return hMem; } else { /* If we got a 16-bit hRsrc, convert it */ HRSRC hRsrc32 = HIWORD(hRsrc)? hRsrc : MapHRsrc16To32( pModule, hRsrc ); hMem = PE_LoadResource( pModule->module32, hRsrc32 ); /* If we need to return a 16-bit resource, convert it */ if ( bRet16 ) { WORD type = MapHRsrc16ToType( pModule, hRsrc ); DWORD size = SizeofResource( hModule, hRsrc ); LPVOID bits = LockResource( hMem ); hMem = NE_LoadPEResource( pModule, type, bits, size ); } } } else { /* 32-bit PE module */ hMem = PE_LoadResource( hModule, hRsrc ); } return hMem; }
/************************************************************************* * RunDLL_CallEntry16 * * Only exported from shell32 on Windows, probably imported * from shell through the 16/32 thunks. */ void WINAPI RunDLL_CallEntry16( DWORD proc, HWND hwnd, HINSTANCE inst, LPCSTR cmdline, INT cmdshow ) { WORD args[5]; SEGPTR cmdline_seg; TRACE( "proc %x hwnd %p inst %p cmdline %s cmdshow %d\n", proc, hwnd, inst, debugstr_a(cmdline), cmdshow ); cmdline_seg = MapLS( cmdline ); args[4] = HWND_16(hwnd); args[3] = MapHModuleLS(inst); args[2] = SELECTOROF(cmdline_seg); args[1] = OFFSETOF(cmdline_seg); args[0] = cmdshow; WOWCallback16Ex( proc, WCB16_PASCAL, sizeof(args), args, NULL ); UnMapLS( cmdline_seg ); }
/************************************************************************* * RunDLL_CallEntry16 [SHELL32.122] * the name is probably wrong */ EXTERN_C void WINAPI RunDLL_CallEntry16( DWORD proc, HWND hwnd, HINSTANCE inst, LPCSTR cmdline, INT cmdshow ) { #if !defined(__CYGWIN__) && !defined (__MINGW32__) && !defined(_MSC_VER) WORD args[5]; SEGPTR cmdline_seg; TRACE( "proc %x hwnd %p inst %p cmdline %s cmdshow %d\n", proc, hwnd, inst, debugstr_a(cmdline), cmdshow ); cmdline_seg = MapLS( cmdline ); args[4] = HWND_16(hwnd); args[3] = MapHModuleLS(inst); args[2] = SELECTOROF(cmdline_seg); args[1] = OFFSETOF(cmdline_seg); args[0] = cmdshow; WOWCallback16Ex( proc, WCB16_PASCAL, sizeof(args), args, NULL ); UnMapLS( cmdline_seg ); #else FIXME( "proc %lx hwnd %p inst %p cmdline %s cmdshow %d\n", proc, hwnd, inst, debugstr_a(cmdline), cmdshow ); #endif }
static HRSRC RES_FindResource2( HMODULE hModule, LPCSTR type, LPCSTR name, WORD lang, BOOL bUnicode, BOOL bRet16 ) { HRSRC hRsrc = 0; TRACE("(%08x, %08x%s, %08x%s, %04x, %s, %s)\n", hModule, (UINT)type, HIWORD(type)? (bUnicode? debugstr_w((LPWSTR)type) : debugstr_a(type)) : "", (UINT)name, HIWORD(name)? (bUnicode? debugstr_w((LPWSTR)name) : debugstr_a(name)) : "", lang, bUnicode? "W" : "A", bRet16? "NE" : "PE" ); if (!HIWORD(hModule)) { HMODULE16 hMod16 = MapHModuleLS( hModule ); NE_MODULE *pModule = NE_GetPtr( hMod16 ); if (!pModule) return 0; if (!pModule->module32) { /* 16-bit NE module */ LPSTR typeStr, nameStr; if ( HIWORD( type ) && bUnicode ) typeStr = HEAP_strdupWtoA( GetProcessHeap(), 0, (LPCWSTR)type ); else typeStr = (LPSTR)type; if ( HIWORD( name ) && bUnicode ) nameStr = HEAP_strdupWtoA( GetProcessHeap(), 0, (LPCWSTR)name ); else nameStr = (LPSTR)name; hRsrc = NE_FindResource( pModule, nameStr, typeStr ); if ( HIWORD( type ) && bUnicode ) HeapFree( GetProcessHeap(), 0, typeStr ); if ( HIWORD( name ) && bUnicode ) HeapFree( GetProcessHeap(), 0, nameStr ); /* If we need to return 32-bit HRSRC, no conversion is necessary, we simply use the 16-bit HRSRC as 32-bit HRSRC */ } else { /* 32-bit PE module */ hRsrc = RES_FindResource2( pModule->module32, type, name, lang, bUnicode, FALSE ); /* If we need to return 16-bit HRSRC, perform conversion */ if ( bRet16 ) hRsrc = MapHRsrc32To16( pModule, hRsrc, HIWORD( type )? 0 : LOWORD( type ) ); } } else { /* 32-bit PE module */ LPWSTR typeStr, nameStr; if (HIWORD (type)) { typeStr = RES_GetUnicodeName (type, bUnicode); if (!typeStr) return 0; } else typeStr = (LPWSTR)type; if (HIWORD (name)) { nameStr = RES_GetUnicodeName (name, bUnicode); if (!nameStr) { if (HIWORD (type)) HeapFree (GetProcessHeap (), 0, typeStr); return 0; } } else nameStr = (LPWSTR)name; /* Here is the real difference between FindResouce and FindResourceEx */ if(lang == MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL) || lang == MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT) || lang == MAKELANGID(LANG_NEUTRAL, SUBLANG_SYS_DEFAULT) || lang == MAKELANGID(LANG_NEUTRAL, 3)) /* FIXME: real name? */ hRsrc = PE_FindResourceW( hModule, nameStr, typeStr ); else hRsrc = PE_FindResourceExW( hModule, nameStr, typeStr, lang ); if (HIWORD (type)) HeapFree (GetProcessHeap (), 0, typeStr); if (HIWORD (name)) HeapFree (GetProcessHeap (), 0, nameStr); } return hRsrc; }