#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>
-
-#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));
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)) {
- 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);
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);
}
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);
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);
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)) {
- 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);
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);
}
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);
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);
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);
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);
}
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);
/* 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);
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);
data_ptr = get_versioninfo_block (data, block);
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")) {
- 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);
}
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);
}
/* 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);
}
/* 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);
}
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);
}
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);
}
}
/* 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);
}
"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);
}
"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,
/* 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);
}
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);
}
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);
}
}
/* 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;
}
&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 */
- 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;
}
}
/* 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;
}
}
} 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 */
- 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;
}
}