projects
/
mono.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
[reflection] Use MonoError in mono_get_object_from_blob
[mono.git]
/
mono
/
io-layer
/
versioninfo.c
diff --git
a/mono/io-layer/versioninfo.c
b/mono/io-layer/versioninfo.c
index 2ba7fc96d5554ee1eaa5d1c7221aabaa020896ae..6b811b0a3bfec31f8add6846cf568d311c1e185b 100644
(file)
--- a/
mono/io-layer/versioninfo.c
+++ b/
mono/io-layer/versioninfo.c
@@
-22,14
+22,10
@@
#include <mono/io-layer/versioninfo.h>
#include <mono/io-layer/io-portability.h>
#include <mono/io-layer/error.h>
#include <mono/io-layer/versioninfo.h>
#include <mono/io-layer/io-portability.h>
#include <mono/io-layer/error.h>
+#include <mono/io-layer/io-trace.h>
#include <mono/utils/strenc.h>
#include <mono/utils/mono-mmap.h>
#include <mono/utils/strenc.h>
#include <mono/utils/mono-mmap.h>
-
-#if 0
-// #define DEBUG(...) g_message(__VA_ARGS__)
-#else
-#define DEBUG(...)
-#endif
+#include <mono/utils/mono-logger-internals.h>
#define ALIGN32(ptr) ptr = (gpointer)((char *)ptr + 3); ptr = (gpointer)((char *)ptr - ((gsize)ptr & 3));
#define ALIGN32(ptr) ptr = (gpointer)((char *)ptr + 3); ptr = (gpointer)((char *)ptr - ((gsize)ptr & 3));
@@
-163,14
+159,14
@@
find_pe_file_resources32 (gpointer file_map, guint32 map_size,
dos_header = (WapiImageDosHeader *)file_map;
if (dos_header->e_magic != IMAGE_DOS_SIGNATURE) {
dos_header = (WapiImageDosHeader *)file_map;
if (dos_header->e_magic != IMAGE_DOS_SIGNATURE) {
-
DEBUG (
"%s: Bad dos signature 0x%x", __func__, dos_header->e_magic);
+
MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER,
"%s: Bad dos signature 0x%x", __func__, dos_header->e_magic);
SetLastError (ERROR_INVALID_DATA);
return(NULL);
}
if (map_size < sizeof(WapiImageNTHeaders32) + GUINT32_FROM_LE (dos_header->e_lfanew)) {
SetLastError (ERROR_INVALID_DATA);
return(NULL);
}
if (map_size < sizeof(WapiImageNTHeaders32) + GUINT32_FROM_LE (dos_header->e_lfanew)) {
-
DEBUG (
"%s: File is too small: %d", __func__, map_size);
+
MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER,
"%s: File is too small: %d", __func__, map_size);
SetLastError (ERROR_BAD_LENGTH);
return(NULL);
SetLastError (ERROR_BAD_LENGTH);
return(NULL);
@@
-178,7
+174,7
@@
find_pe_file_resources32 (gpointer file_map, guint32 map_size,
nt_headers = (WapiImageNTHeaders32 *)((guint8 *)file_map + GUINT32_FROM_LE (dos_header->e_lfanew));
if (nt_headers->Signature != IMAGE_NT_SIGNATURE) {
nt_headers = (WapiImageNTHeaders32 *)((guint8 *)file_map + GUINT32_FROM_LE (dos_header->e_lfanew));
if (nt_headers->Signature != IMAGE_NT_SIGNATURE) {
-
DEBUG (
"%s: Bad NT signature 0x%x", __func__, nt_headers->Signature);
+
MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER,
"%s: Bad NT signature 0x%x", __func__, nt_headers->Signature);
SetLastError (ERROR_INVALID_DATA);
return(NULL);
SetLastError (ERROR_INVALID_DATA);
return(NULL);
@@
-192,7
+188,7
@@
find_pe_file_resources32 (gpointer file_map, guint32 map_size,
}
if (resource_rva == 0) {
}
if (resource_rva == 0) {
-
DEBUG (
"%s: No resources in file!", __func__);
+
MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER,
"%s: No resources in file!", __func__);
SetLastError (ERROR_INVALID_DATA);
return(NULL);
SetLastError (ERROR_INVALID_DATA);
return(NULL);
@@
-200,7
+196,7
@@
find_pe_file_resources32 (gpointer file_map, guint32 map_size,
resource_dir = (WapiImageResourceDirectory *)get_ptr_from_rva (resource_rva, (WapiImageNTHeaders32 *)nt_headers, file_map);
if (resource_dir == NULL) {
resource_dir = (WapiImageResourceDirectory *)get_ptr_from_rva (resource_rva, (WapiImageNTHeaders32 *)nt_headers, file_map);
if (resource_dir == NULL) {
-
DEBUG (
"%s: Can't find resource directory", __func__);
+
MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER,
"%s: Can't find resource directory", __func__);
SetLastError (ERROR_INVALID_DATA);
return(NULL);
SetLastError (ERROR_INVALID_DATA);
return(NULL);
@@
-237,14
+233,14
@@
find_pe_file_resources64 (gpointer file_map, guint32 map_size,
dos_header = (WapiImageDosHeader *)file_map;
if (dos_header->e_magic != IMAGE_DOS_SIGNATURE) {
dos_header = (WapiImageDosHeader *)file_map;
if (dos_header->e_magic != IMAGE_DOS_SIGNATURE) {
-
DEBUG (
"%s: Bad dos signature 0x%x", __func__, dos_header->e_magic);
+
MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER,
"%s: Bad dos signature 0x%x", __func__, dos_header->e_magic);
SetLastError (ERROR_INVALID_DATA);
return(NULL);
}
if (map_size < sizeof(WapiImageNTHeaders64) + GUINT32_FROM_LE (dos_header->e_lfanew)) {
SetLastError (ERROR_INVALID_DATA);
return(NULL);
}
if (map_size < sizeof(WapiImageNTHeaders64) + GUINT32_FROM_LE (dos_header->e_lfanew)) {
-
DEBUG (
"%s: File is too small: %d", __func__, map_size);
+
MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER,
"%s: File is too small: %d", __func__, map_size);
SetLastError (ERROR_BAD_LENGTH);
return(NULL);
SetLastError (ERROR_BAD_LENGTH);
return(NULL);
@@
-252,7
+248,7
@@
find_pe_file_resources64 (gpointer file_map, guint32 map_size,
nt_headers = (WapiImageNTHeaders64 *)((guint8 *)file_map + GUINT32_FROM_LE (dos_header->e_lfanew));
if (nt_headers->Signature != IMAGE_NT_SIGNATURE) {
nt_headers = (WapiImageNTHeaders64 *)((guint8 *)file_map + GUINT32_FROM_LE (dos_header->e_lfanew));
if (nt_headers->Signature != IMAGE_NT_SIGNATURE) {
-
DEBUG (
"%s: Bad NT signature 0x%x", __func__,
+
MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER,
"%s: Bad NT signature 0x%x", __func__,
nt_headers->Signature);
SetLastError (ERROR_INVALID_DATA);
nt_headers->Signature);
SetLastError (ERROR_INVALID_DATA);
@@
-267,7
+263,7
@@
find_pe_file_resources64 (gpointer file_map, guint32 map_size,
}
if (resource_rva == 0) {
}
if (resource_rva == 0) {
-
DEBUG (
"%s: No resources in file!", __func__);
+
MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER,
"%s: No resources in file!", __func__);
SetLastError (ERROR_INVALID_DATA);
return(NULL);
SetLastError (ERROR_INVALID_DATA);
return(NULL);
@@
-275,7
+271,7
@@
find_pe_file_resources64 (gpointer file_map, guint32 map_size,
resource_dir = (WapiImageResourceDirectory *)get_ptr_from_rva (resource_rva, (WapiImageNTHeaders32 *)nt_headers, file_map);
if (resource_dir == NULL) {
resource_dir = (WapiImageResourceDirectory *)get_ptr_from_rva (resource_rva, (WapiImageNTHeaders32 *)nt_headers, file_map);
if (resource_dir == NULL) {
-
DEBUG (
"%s: Can't find resource directory", __func__);
+
MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER,
"%s: Can't find resource directory", __func__);
SetLastError (ERROR_INVALID_DATA);
return(NULL);
SetLastError (ERROR_INVALID_DATA);
return(NULL);
@@
-328,7
+324,7
@@
map_pe_file (gunichar2 *filename, gint32 *map_size, void **handle)
filename_ext = mono_unicode_to_external (filename);
if (filename_ext == NULL) {
filename_ext = mono_unicode_to_external (filename);
if (filename_ext == NULL) {
-
DEBUG (
"%s: unicode conversion returned NULL", __func__);
+
MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER,
"%s: unicode conversion returned NULL", __func__);
SetLastError (ERROR_INVALID_NAME);
return(NULL);
SetLastError (ERROR_INVALID_NAME);
return(NULL);
@@
-336,7
+332,7
@@
map_pe_file (gunichar2 *filename, gint32 *map_size, void **handle)
fd = _wapi_open (filename_ext, O_RDONLY, 0);
if (fd == -1) {
fd = _wapi_open (filename_ext, O_RDONLY, 0);
if (fd == -1) {
-
DEBUG (
"%s: Error opening file %s: %s", __func__, filename_ext, strerror (errno));
+
MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER,
"%s: Error opening file %s: %s", __func__, filename_ext, strerror (errno));
SetLastError (_wapi_get_win32_file_error (errno));
g_free (filename_ext);
SetLastError (_wapi_get_win32_file_error (errno));
g_free (filename_ext);
@@
-345,7
+341,7
@@
map_pe_file (gunichar2 *filename, gint32 *map_size, void **handle)
}
if (fstat (fd, &statbuf) == -1) {
}
if (fstat (fd, &statbuf) == -1) {
-
DEBUG (
"%s: Error stat()ing file %s: %s", __func__, filename_ext, strerror (errno));
+
MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER,
"%s: Error stat()ing file %s: %s", __func__, filename_ext, strerror (errno));
SetLastError (_wapi_get_win32_file_error (errno));
g_free (filename_ext);
SetLastError (_wapi_get_win32_file_error (errno));
g_free (filename_ext);
@@
-356,7
+352,7
@@
map_pe_file (gunichar2 *filename, gint32 *map_size, void **handle)
/* Check basic file size */
if (statbuf.st_size < sizeof(WapiImageDosHeader)) {
/* Check basic file size */
if (statbuf.st_size < sizeof(WapiImageDosHeader)) {
-
DEBUG (
"%s: File %s is too small: %lld", __func__, filename_ext, statbuf.st_size);
+
MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER,
"%s: File %s is too small: %lld", __func__, filename_ext, statbuf.st_size);
SetLastError (ERROR_BAD_LENGTH);
g_free (filename_ext);
SetLastError (ERROR_BAD_LENGTH);
g_free (filename_ext);
@@
-366,7
+362,7
@@
map_pe_file (gunichar2 *filename, gint32 *map_size, void **handle)
file_map = mono_file_map (statbuf.st_size, MONO_MMAP_READ | MONO_MMAP_PRIVATE, fd, 0, handle);
if (file_map == NULL) {
file_map = mono_file_map (statbuf.st_size, MONO_MMAP_READ | MONO_MMAP_PRIVATE, fd, 0, handle);
if (file_map == NULL) {
-
DEBUG (
"%s: Error mmap()int file %s: %s", __func__, filename_ext, strerror (errno));
+
MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER,
"%s: Error mmap()int file %s: %s", __func__, filename_ext, strerror (errno));
SetLastError (_wapi_get_win32_file_error (errno));
g_free (filename_ext);
SetLastError (_wapi_get_win32_file_error (errno));
g_free (filename_ext);
@@
-468,19
+464,17
@@
static gconstpointer
get_fixedfileinfo_block (gconstpointer data, version_data *block)
{
gconstpointer data_ptr;
get_fixedfileinfo_block (gconstpointer data, version_data *block)
{
gconstpointer data_ptr;
- gint32 data_len; /* signed to guard against underflow */
WapiFixedFileInfo *ffi;
data_ptr = get_versioninfo_block (data, block);
WapiFixedFileInfo *ffi;
data_ptr = get_versioninfo_block (data, block);
- data_len = block->data_len;
if (block->value_len != sizeof(WapiFixedFileInfo)) {
if (block->value_len != sizeof(WapiFixedFileInfo)) {
-
DEBUG (
"%s: FIXEDFILEINFO size mismatch", __func__);
+
MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER,
"%s: FIXEDFILEINFO size mismatch", __func__);
return(NULL);
}
if (!unicode_string_equals (block->key, "VS_VERSION_INFO")) {
return(NULL);
}
if (!unicode_string_equals (block->key, "VS_VERSION_INFO")) {
-
DEBUG (
"%s: VS_VERSION_INFO mismatch", __func__);
+
MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER,
"%s: VS_VERSION_INFO mismatch", __func__);
return(NULL);
}
return(NULL);
}
@@
-488,7
+482,7
@@
get_fixedfileinfo_block (gconstpointer data, version_data *block)
ffi = ((WapiFixedFileInfo *)data_ptr);
if ((ffi->dwSignature != VS_FFI_SIGNATURE) ||
(ffi->dwStrucVersion != VS_FFI_STRUCVERSION)) {
ffi = ((WapiFixedFileInfo *)data_ptr);
if ((ffi->dwSignature != VS_FFI_SIGNATURE) ||
(ffi->dwStrucVersion != VS_FFI_STRUCVERSION)) {
-
DEBUG (
"%s: FIXEDFILEINFO bad signature", __func__);
+
MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER,
"%s: FIXEDFILEINFO bad signature", __func__);
return(NULL);
}
return(NULL);
}
@@
-530,7
+524,7
@@
get_string_block (gconstpointer data_ptr,
/* We must have hit padding, so give up
* processing now
*/
/* We must have hit padding, so give up
* processing now
*/
-
DEBUG (
"%s: Hit 0-length block, giving up", __func__);
+
MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER,
"%s: Hit 0-length block, giving up", __func__);
return(NULL);
}
return(NULL);
}
@@
-586,7
+580,7
@@
get_stringtable_block (gconstpointer data_ptr,
/* We must have hit padding, so give up
* processing now
*/
/* We must have hit padding, so give up
* processing now
*/
-
DEBUG (
"%s: Hit 0-length block, giving up", __func__);
+
MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER,
"%s: Hit 0-length block, giving up", __func__);
return(NULL);
}
return(NULL);
}
@@
-594,7
+588,7
@@
get_stringtable_block (gconstpointer data_ptr,
found_lang = g_utf16_to_utf8 (block->key, 8, NULL, NULL, NULL);
if (found_lang == NULL) {
found_lang = g_utf16_to_utf8 (block->key, 8, NULL, NULL, NULL);
if (found_lang == NULL) {
-
DEBUG (
"%s: Didn't find a valid language key, giving up", __func__);
+
MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER,
"%s: Didn't find a valid language key, giving up", __func__);
return(NULL);
}
return(NULL);
}
@@
-617,7
+611,7
@@
get_stringtable_block (gconstpointer data_ptr,
if (data_ptr == NULL) {
/* Child block hit padding */
if (data_ptr == NULL) {
/* Child block hit padding */
-
DEBUG (
"%s: Child block hit 0-length block, giving up", __func__);
+
MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER,
"%s: Child block hit 0-length block, giving up", __func__);
return(NULL);
}
}
return(NULL);
}
}
@@
-647,7
+641,7
@@
big_up_string_block (gconstpointer data_ptr, version_data *block)
/* We must have hit padding, so give up
* processing now
*/
/* We must have hit padding, so give up
* processing now
*/
-
DEBUG (
"%s: Hit 0-length block, giving up", __func__);
+
MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER,
"%s: Hit 0-length block, giving up", __func__);
return(NULL);
}
return(NULL);
}
@@
-658,7
+652,7
@@
big_up_string_block (gconstpointer data_ptr, version_data *block)
"UTF-16BE", "UTF-16LE", NULL, NULL,
NULL);
if (big_value == NULL) {
"UTF-16BE", "UTF-16LE", NULL, NULL,
NULL);
if (big_value == NULL) {
-
DEBUG (
"%s: Didn't find a valid string, giving up", __func__);
+
MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER,
"%s: Didn't find a valid string, giving up", __func__);
return(NULL);
}
return(NULL);
}
@@
-675,7
+669,7
@@
big_up_string_block (gconstpointer data_ptr, version_data *block)
"UTF-16BE", "UTF-16LE", NULL, NULL,
NULL);
if (big_value == NULL) {
"UTF-16BE", "UTF-16LE", NULL, NULL,
NULL);
if (big_value == NULL) {
-
DEBUG (
"%s: Didn't find a valid data string, giving up", __func__);
+
MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER,
"%s: Didn't find a valid data string, giving up", __func__);
return(NULL);
}
memcpy ((gpointer)data_ptr, big_value,
return(NULL);
}
memcpy ((gpointer)data_ptr, big_value,
@@
-714,7
+708,7
@@
big_up_stringtable_block (gconstpointer data_ptr, version_data *block)
/* We must have hit padding, so give up
* processing now
*/
/* We must have hit padding, so give up
* processing now
*/
-
DEBUG (
"%s: Hit 0-length block, giving up", __func__);
+
MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER,
"%s: Hit 0-length block, giving up", __func__);
return(NULL);
}
return(NULL);
}
@@
-723,7
+717,7
@@
big_up_stringtable_block (gconstpointer data_ptr, version_data *block)
big_value = g_convert ((gchar *)block->key, 16, "UTF-16BE",
"UTF-16LE", NULL, NULL, NULL);
if (big_value == NULL) {
big_value = g_convert ((gchar *)block->key, 16, "UTF-16BE",
"UTF-16LE", NULL, NULL, NULL);
if (big_value == NULL) {
-
DEBUG (
"%s: Didn't find a valid string, giving up", __func__);
+
MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER,
"%s: Didn't find a valid string, giving up", __func__);
return(NULL);
}
return(NULL);
}
@@
-734,7
+728,7
@@
big_up_stringtable_block (gconstpointer data_ptr, version_data *block)
if (data_ptr == NULL) {
/* Child block hit padding */
if (data_ptr == NULL) {
/* Child block hit padding */
-
DEBUG (
"%s: Child block hit 0-length block, giving up", __func__);
+
MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER,
"%s: Child block hit 0-length block, giving up", __func__);
return(NULL);
}
}
return(NULL);
}
}
@@
-786,7
+780,7
@@
big_up (gconstpointer datablock, guint32 size)
/* We must have hit padding, so give
* up processing now
*/
/* We must have hit padding, so give
* up processing now
*/
-
DEBUG (
"%s: Hit 0-length block, giving up", __func__);
+
MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER,
"%s: Hit 0-length block, giving up", __func__);
return;
}
return;
}
@@
-802,13
+796,13
@@
big_up (gconstpointer datablock, guint32 size)
&block);
} else {
/* Bogus data */
&block);
} else {
/* Bogus data */
-
DEBUG (
"%s: Not a valid VERSIONINFO child block", __func__);
+
MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER,
"%s: Not a valid VERSIONINFO child block", __func__);
return;
}
if (data_ptr == NULL) {
/* Child block hit padding */
return;
}
if (data_ptr == NULL) {
/* Child block hit padding */
-
DEBUG (
"%s: Child block hit 0-length block, giving up", __func__);
+
MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER,
"%s: Child block hit 0-length block, giving up", __func__);
return;
}
}
return;
}
}
@@
-880,7
+874,7
@@
VerQueryValue (gconstpointer datablock, const gunichar2 *subblock, gpointer *buf
/* We must have hit padding,
* so give up processing now
*/
/* We must have hit padding,
* so give up processing now
*/
-
DEBUG (
"%s: Hit 0-length block, giving up", __func__);
+
MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER,
"%s: Hit 0-length block, giving up", __func__);
goto done;
}
goto done;
}
@@
-903,19
+897,19
@@
VerQueryValue (gconstpointer datablock, const gunichar2 *subblock, gpointer *buf
string_value != NULL &&
string_value_len != 0) {
*buffer = string_value;
string_value != NULL &&
string_value_len != 0) {
*buffer = string_value;
- *len = unicode_chars (string_value) + 1; /* Include trailing null */
+ *len = unicode_chars (
(const gunichar2 *)
string_value) + 1; /* Include trailing null */
ret = TRUE;
goto done;
}
} else {
/* Bogus data */
ret = TRUE;
goto done;
}
} else {
/* Bogus data */
-
DEBUG (
"%s: Not a valid VERSIONINFO child block", __func__);
+
MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER,
"%s: Not a valid VERSIONINFO child block", __func__);
goto done;
}
if (data_ptr == NULL) {
/* Child block hit padding */
goto done;
}
if (data_ptr == NULL) {
/* Child block hit padding */
-
DEBUG (
"%s: Child block hit 0-length block, giving up", __func__);
+
MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER,
"%s: Child block hit 0-length block, giving up", __func__);
goto done;
}
}
goto done;
}
}