*
* 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 "winreg.h"
#include "winternl.h"
-#include "winerror.h"
-#include "thread.h"
-#include "excpt.h"
#include "wine/exception.h"
#include "wine/unicode.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(resource);
static LCID user_lcid, system_lcid;
-
-static WINE_EXCEPTION_FILTER(page_fault)
-{
- if (GetExceptionCode() == EXCEPTION_ACCESS_VIOLATION ||
- GetExceptionCode() == EXCEPTION_PRIV_INSTRUCTION)
- return EXCEPTION_EXECUTE_HANDLER;
- return EXCEPTION_CONTINUE_SEARCH;
-}
+static LANGID user_ui_language, system_ui_language;
/**********************************************************************
* 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;
}
for (pos = 0; pos < dir->NumberOfNamedEntries + dir->NumberOfIdEntries; pos++)
{
if (!entry[pos].u2.s3.DataIsDirectory == !want_dir)
- return (IMAGE_RESOURCE_DIRECTORY *)((char *)root + entry[pos].u2.s3.OffsetToDirectory);
+ return (const IMAGE_RESOURCE_DIRECTORY *)((const char *)root + entry[pos].u2.s3.OffsetToDirectory);
}
return NULL;
}
if (!entry[pos].u2.s3.DataIsDirectory == !want_dir)
{
TRACE("root %p dir %p id %04x ret %p\n",
- root, dir, id, (char *)root + entry[pos].u2.s3.OffsetToDirectory);
- return (IMAGE_RESOURCE_DIRECTORY *)((char *)root + entry[pos].u2.s3.OffsetToDirectory);
+ root, dir, id, (const char*)root + entry[pos].u2.s3.OffsetToDirectory);
+ return (const IMAGE_RESOURCE_DIRECTORY *)((const char *)root + entry[pos].u2.s3.OffsetToDirectory);
}
break;
}
while (min <= max)
{
pos = (min + max) / 2;
- str = (IMAGE_RESOURCE_DIR_STRING_U *)((char *)root + entry[pos].u1.s1.NameOffset);
+ str = (const IMAGE_RESOURCE_DIR_STRING_U *)((const char *)root + entry[pos].u1.s1.NameOffset);
res = strncmpW( name, str->NameString, str->Length );
if (!res && namelen == str->Length)
{
if (!entry[pos].u2.s3.DataIsDirectory == !want_dir)
{
TRACE("root %p dir %p name %s ret %p\n",
- root, dir, debugstr_w(name), (char *)root + entry[pos].u2.s3.OffsetToDirectory);
- return (IMAGE_RESOURCE_DIRECTORY *)((char *)root + entry[pos].u2.s3.OffsetToDirectory);
+ root, dir, debugstr_w(name), (const char*)root + entry[pos].u2.s3.OffsetToDirectory);
+ return (const IMAGE_RESOURCE_DIRECTORY *)((const char *)root + entry[pos].u2.s3.OffsetToDirectory);
}
break;
}
const void *res;
NTSTATUS status;
- if (info) TRACE( "module %p type %s name %s lang %04lx level %ld\n",
+ __TRY
+ {
+ 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 );
- __TRY
- {
status = find_entry( hmod, info, level, &res, TRUE );
if (status == STATUS_SUCCESS) *dir = res;
}
- __EXCEPT(page_fault)
+ __EXCEPT_PAGE_FAULT
{
return GetExceptionCode();
}
const void *res;
NTSTATUS status;
- if (info) TRACE( "module %p type %s name %s lang %04lx level %ld\n",
+ __TRY
+ {
+ 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 );
- __TRY
- {
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_GLOBAL_FUNC( LdrAccessResource,
+ "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.@)
LDR_RESOURCE_INFO info;
NTSTATUS status;
void *ptr;
- int i;
+ unsigned int i;
info.Type = type;
info.Name = 1;
{
const MESSAGE_RESOURCE_ENTRY *entry;
- entry = (MESSAGE_RESOURCE_ENTRY *)((char *)data + block->OffsetToEntries);
+ entry = (const MESSAGE_RESOURCE_ENTRY *)((const char *)data + block->OffsetToEntries);
for (i = msg_id - block->LowId; i > 0; i--)
- entry = (MESSAGE_RESOURCE_ENTRY *)((char *)entry + entry->Length);
+ entry = (const MESSAGE_RESOURCE_ENTRY *)((const char *)entry + entry->Length);
*ret = entry;
return STATUS_SUCCESS;
}
BOOLEAN ArgumentIsArray, 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;
NTSTATUS WINAPI NtSetDefaultLocale( BOOLEAN user, LCID lcid )
{
if (user) user_lcid = lcid;
- else system_lcid = lcid;
+ else
+ {
+ system_lcid = lcid;
+ system_ui_language = LANGIDFROMLCID(lcid); /* there is no separate call to set it */
+ }
+ return STATUS_SUCCESS;
+}
+
+
+/**********************************************************************
+ * NtQueryDefaultUILanguage (NTDLL.@)
+ */
+NTSTATUS WINAPI NtQueryDefaultUILanguage( LANGID *lang )
+{
+ *lang = user_ui_language;
+ return STATUS_SUCCESS;
+}
+
+
+/**********************************************************************
+ * NtSetDefaultUILanguage (NTDLL.@)
+ */
+NTSTATUS WINAPI NtSetDefaultUILanguage( LANGID lang )
+{
+ user_ui_language = lang;
+ return STATUS_SUCCESS;
+}
+
+
+/**********************************************************************
+ * NtQueryInstallUILanguage (NTDLL.@)
+ */
+NTSTATUS WINAPI NtQueryInstallUILanguage( LANGID *lang )
+{
+ *lang = system_ui_language;
return STATUS_SUCCESS;
}