*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "config.h"
#define NONAMELESSUNION
#define NONAMELESSSTRUCT
#include "ntstatus.h"
+#define WIN32_NO_STATUS
#include "windef.h"
#include "winbase.h"
-#include "winnls.h"
#include "winnt.h"
#include "winternl.h"
-#include "excpt.h"
#include "wine/exception.h"
#include "wine/unicode.h"
#include "wine/debug.h"
static LCID user_lcid, system_lcid;
static LANGID user_ui_language, system_ui_language;
-static WINE_EXCEPTION_FILTER(page_fault)
-{
- if (GetExceptionCode() == EXCEPTION_ACCESS_VIOLATION ||
- GetExceptionCode() == EXCEPTION_PRIV_INSTRUCTION)
- return EXCEPTION_EXECUTE_HANDLER;
- return EXCEPTION_CONTINUE_SEARCH;
-}
+#define IS_INTRESOURCE(x) (((ULONG_PTR)(x) >> 16) == 0)
/**********************************************************************
* is_data_file_module
*
* Check if a module handle is for a LOAD_LIBRARY_AS_DATAFILE module.
*/
-inline static int is_data_file_module( HMODULE hmod )
+static inline int is_data_file_module( HMODULE hmod )
{
return (ULONG_PTR)hmod & 1;
}
const IMAGE_RESOURCE_DIR_STRING_U *str;
int min, max, res, pos, namelen;
- if (!HIWORD(name)) return find_entry_by_id( dir, LOWORD(name), root, want_dir );
+ if (IS_INTRESOURCE(name)) return find_entry_by_id( dir, LOWORD(name), root, want_dir );
entry = (const IMAGE_RESOURCE_DIRECTORY_ENTRY *)(dir + 1);
namelen = strlenW(name);
min = 0;
root = RtlImageDirectoryEntryToData( hmod, TRUE, IMAGE_DIRECTORY_ENTRY_RESOURCE, &size );
if (!root) return STATUS_RESOURCE_DATA_NOT_FOUND;
+ if (size < sizeof(*resdirptr)) return STATUS_RESOURCE_DATA_NOT_FOUND;
resdirptr = root;
if (!level--) goto done;
__TRY
{
- if (info) TRACE( "module %p type %s name %s lang %04lx level %ld\n",
+ if (info) TRACE( "module %p type %s name %s lang %04x level %d\n",
hmod, debugstr_w((LPCWSTR)info->Type),
level > 1 ? debugstr_w((LPCWSTR)info->Name) : "",
level > 2 ? info->Language : 0, level );
status = find_entry( hmod, info, level, &res, TRUE );
if (status == STATUS_SUCCESS) *dir = res;
}
- __EXCEPT(page_fault)
+ __EXCEPT_PAGE_FAULT
{
return GetExceptionCode();
}
__TRY
{
- if (info) TRACE( "module %p type %s name %s lang %04lx level %ld\n",
+ if (info) TRACE( "module %p type %s name %s lang %04x level %d\n",
hmod, debugstr_w((LPCWSTR)info->Type),
level > 1 ? debugstr_w((LPCWSTR)info->Name) : "",
level > 2 ? info->Language : 0, level );
status = find_entry( hmod, info, level, &res, FALSE );
if (status == STATUS_SUCCESS) *entry = res;
}
- __EXCEPT(page_fault)
+ __EXCEPT_PAGE_FAULT
{
return GetExceptionCode();
}
}
-/**********************************************************************
- * LdrAccessResource (NTDLL.@)
- */
-NTSTATUS WINAPI LdrAccessResource( HMODULE hmod, const IMAGE_RESOURCE_DATA_ENTRY *entry,
- void **ptr, ULONG *size )
+/* don't penalize other platforms stuff needed on i386 for compatibility */
+#ifdef __i386__
+NTSTATUS WINAPI access_resource( HMODULE hmod, const IMAGE_RESOURCE_DATA_ENTRY *entry,
+ void **ptr, ULONG *size )
+#else
+static inline NTSTATUS access_resource( HMODULE hmod, const IMAGE_RESOURCE_DATA_ENTRY *entry,
+ void **ptr, ULONG *size )
+#endif
{
NTSTATUS status;
status = STATUS_SUCCESS;
}
}
- __EXCEPT(page_fault)
+ __EXCEPT_PAGE_FAULT
{
return GetExceptionCode();
}
return status;
}
+/**********************************************************************
+ * LdrAccessResource (NTDLL.@)
+ *
+ * NOTE
+ * On x86, Shrinker, an executable compressor, depends on the
+ * "call access_resource" instruction being there.
+ */
+#ifdef __i386__
+__ASM_STDCALL_FUNC( LdrAccessResource, 16,
+ "pushl %ebp\n\t"
+ "movl %esp, %ebp\n\t"
+ "subl $4,%esp\n\t"
+ "pushl 24(%ebp)\n\t"
+ "pushl 20(%ebp)\n\t"
+ "pushl 16(%ebp)\n\t"
+ "pushl 12(%ebp)\n\t"
+ "pushl 8(%ebp)\n\t"
+ "call " __ASM_NAME("access_resource") "\n\t"
+ "leave\n\t"
+ "ret $16"
+)
+#else
+NTSTATUS WINAPI LdrAccessResource( HMODULE hmod, const IMAGE_RESOURCE_DATA_ENTRY *entry,
+ void **ptr, ULONG *size )
+{
+ return access_resource( hmod, entry, ptr, size );
+}
+#endif
/**********************************************************************
* RtlFindMessage (NTDLL.@)
*/
NTSTATUS WINAPI RtlFormatMessage( LPWSTR Message, UCHAR MaxWidth,
BOOLEAN IgnoreInserts, BOOLEAN Ansi,
- BOOLEAN ArgumentIsArray, va_list * Arguments,
+ BOOLEAN ArgumentIsArray, __ms_va_list * Arguments,
LPWSTR Buffer, ULONG BufferSize )
{
- FIXME("(%s, %u, %s, %s, %s, %p, %p, %ld)\n", debugstr_w(Message),
+ FIXME("(%s, %u, %s, %s, %s, %p, %p, %d)\n", debugstr_w(Message),
MaxWidth, IgnoreInserts ? "TRUE" : "FALSE", Ansi ? "TRUE" : "FALSE",
ArgumentIsArray ? "TRUE" : "FALSE", Arguments, Buffer, BufferSize);
return STATUS_SUCCESS;