Dmitry Timoshkov wrote:

"Robert Shearman" <[EMAIL PROTECTED]> wrote:

-/**********************************************************************
- * 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;

@@ -355,6 +358,30 @@ NTSTATUS WINAPI LdrAccessResource( HMODU
    return status;
}

+/**********************************************************************
+ * LdrAccessResource  (NTDLL.@)
+ */
+#ifdef __i386__
+/* Shrinker depends on the "call access_resource" instruction being there */
+__ASM_GLOBAL_FUNC( LdrAccessResource,
+    "pushl %ebp\n"
+    "movl %esp, %ebp\n"
+    "pushl 24(%ebp)\n"
+    "pushl 20(%ebp)\n"
+    "pushl 16(%ebp)\n"
+    "pushl 12(%ebp)\n"
+    "pushl 8(%ebp)\n"
+    "call access_resource\n"
+    "leave\n"
+    "ret\n"
+);
+#else
+NTSTATUS WINAPI LdrAccessResource( HMODULE hmod, const 
IMAGE_RESOURCE_DATA_ENTRY *entry,
+                                   void **ptr, ULONG *size )
+{
+    return access_resource( hmod, entry, ptr, size );
+}
+#endif

Shouldn't be enough for the __i386__ case just omitting 'inline' in 
access_resource
definition?


No. Marcus already discovered with the previous version of EXC_CallHandler using the "-funit-at-a-time" option that the compiler can re-order the arguments and generally do whatever it wants if we hint that it won't be used outside of the module. The compiler is also free to generate LdrAccessResource as a simple jump to access_resource, or even to just make access_resource point to the same address as LdrAccessResource. In short, the only sure way of generating code that Shrinker needs is to do it explicitly.

--
Rob Shearman



Reply via email to