summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwpaul <wpaul@FreeBSD.org>2004-01-06 18:06:54 +0000
committerwpaul <wpaul@FreeBSD.org>2004-01-06 18:06:54 +0000
commit9138480b09ae7b6db83e31894580eb4bdc8fb7fe (patch)
treea4751cb173541fb66864d0091b2cf0b9d6bc58f6
parentf366a8ee60fe70df4f0c7469253de71f17d8172a (diff)
downloadFreeBSD-src-9138480b09ae7b6db83e31894580eb4bdc8fb7fe.zip
FreeBSD-src-9138480b09ae7b6db83e31894580eb4bdc8fb7fe.tar.gz
Clean up pe_get_message(). Allow the caller to obtain the resource
flag so that it can see if the message string is unicode or not and do the conversion itself rather than doing it in subr_pe.c. This prevents subr_pe.c from being dependent on subr_ndis.c.
-rw-r--r--sys/compat/ndis/pe_var.h6
-rw-r--r--sys/compat/ndis/subr_ndis.c13
-rw-r--r--sys/compat/ndis/subr_pe.c26
3 files changed, 17 insertions, 28 deletions
diff --git a/sys/compat/ndis/pe_var.h b/sys/compat/ndis/pe_var.h
index 4eafc4c..5178449 100644
--- a/sys/compat/ndis/pe_var.h
+++ b/sys/compat/ndis/pe_var.h
@@ -422,10 +422,8 @@ extern int pe_get_section(vm_offset_t, image_section_header *, const char *);
extern int pe_relocate(vm_offset_t);
extern int pe_get_import_descriptor(vm_offset_t, image_import_descriptor *, char *);
extern int pe_patch_imports(vm_offset_t, char *, image_patch_table *);
-#ifdef _KERNEL
-extern int pe_get_messagetable(vm_offset_t, message_resource_data **);
-extern int pe_get_message(vm_offset_t, uint32_t, char **, int *);
-#endif
+extern int pe_get_messagetable(vm_offset_t, message_resource_data **);
+extern int pe_get_message(vm_offset_t, uint32_t, char **, int *, uint16_t *);
__END_DECLS
#endif /* _PE_VAR_H_ */
diff --git a/sys/compat/ndis/subr_ndis.c b/sys/compat/ndis/subr_ndis.c
index b25208d..f286571 100644
--- a/sys/compat/ndis/subr_ndis.c
+++ b/sys/compat/ndis/subr_ndis.c
@@ -795,12 +795,17 @@ ndis_syslog(ndis_handle adapter, ndis_error_code code,
{
ndis_miniport_block *block;
va_list ap;
- int i;
- char *str = NULL;
+ int i, error;
+ char *str = NULL, *ustr = NULL;
+ uint16_t flags;
block = (ndis_miniport_block *)adapter;
- pe_get_message(block->nmb_img, code, &str, &i);
+ error = pe_get_message(block->nmb_img, code, &str, &i, &flags);
+ if (error == 0 && flags & MESSAGE_RESOURCE_UNICODE) {
+ ndis_unicode_to_ascii((uint16_t *)str, i, &ustr);
+ str = ustr;
+ }
device_printf (block->nmb_dev, "NDIS ERROR: %x (%s)\n", code,
str == NULL ? "unknown error" : str);
device_printf (block->nmb_dev, "NDIS NUMERRORS: %x\n", numerrors);
@@ -811,6 +816,8 @@ ndis_syslog(ndis_handle adapter, ndis_error_code code,
va_arg(ap, void *));
va_end(ap);
+ if (ustr != NULL)
+ free(ustr, M_DEVBUF);
return;
}
diff --git a/sys/compat/ndis/subr_pe.c b/sys/compat/ndis/subr_pe.c
index 3151598..0d6dc44 100644
--- a/sys/compat/ndis/subr_pe.c
+++ b/sys/compat/ndis/subr_pe.c
@@ -61,15 +61,6 @@ __FBSDID("$FreeBSD$");
#endif
#include <compat/ndis/pe_var.h>
-#ifdef _KERNEL
-#include <machine/bus.h>
-#include <machine/resource.h>
-#include <sys/bus.h>
-#include <sys/rman.h>
-#include <compat/ndis/resource_var.h>
-#include <compat/ndis/ntoskrnl_var.h>
-#include <compat/ndis/ndis_var.h>
-#endif
static u_int32_t pe_functbl_match(image_patch_table *, char *);
@@ -465,7 +456,6 @@ pe_get_import_descriptor(imgbase, desc, module)
return (ENOENT);
}
-#ifdef _KERNEL
int
pe_get_messagetable(imgbase, md)
vm_offset_t imgbase;
@@ -513,17 +503,17 @@ pe_get_messagetable(imgbase, md)
}
int
-pe_get_message(imgbase, id, str, len)
+pe_get_message(imgbase, id, str, len, flags)
vm_offset_t imgbase;
uint32_t id;
char **str;
int *len;
+ uint16_t *flags;
{
message_resource_data *md = NULL;
message_resource_block *mb;
message_resource_entry *me;
- int i;
- char m[1024], *msg;
+ uint32_t i;
pe_get_messagetable(imgbase, &md);
@@ -540,14 +530,9 @@ pe_get_message(imgbase, id, str, len)
for (i = id - mb->mrb_lowid; i > 0; i--)
me = (message_resource_entry *)((uintptr_t)me +
me->mre_len);
- if (me->mre_flags == MESSAGE_RESOURCE_UNICODE) {
- msg = m;
- ndis_unicode_to_ascii((uint16_t *)me->mre_text,
- me->mre_len, &msg);
- *str = m;
- } else
- *str = me->mre_text;
+ *str = me->mre_text;
*len = me->mre_len;
+ *flags = me->mre_flags;
return(0);
}
mb++;
@@ -555,7 +540,6 @@ pe_get_message(imgbase, id, str, len)
return(ENOENT);
}
-#endif
/*
* Find the function that matches a particular name. This doesn't
OpenPOWER on IntegriCloud