diff options
Diffstat (limited to 'src/internal')
-rw-r--r-- | src/internal/ntapi.c | 12 | ||||
-rw-r--r-- | src/internal/ntapi_fnapi.h | 6 | ||||
-rw-r--r-- | src/internal/ntapi_log.c (renamed from src/internal/ntapi_debug.c) | 60 |
3 files changed, 32 insertions, 46 deletions
diff --git a/src/internal/ntapi.c b/src/internal/ntapi.c index 20b49fb..c96c62b 100644 --- a/src/internal/ntapi.c +++ b/src/internal/ntapi.c @@ -47,7 +47,7 @@ #include <ntapi/nt_tty.h> #include <ntapi/nt_afl.h> #include <ntapi/nt_hash.h> -#include <ntapi/nt_debug.h> +#include <ntapi/nt_log.h> #include <ntapi/nt_atomic.h> #include <ntapi/ntapi.h> @@ -438,12 +438,10 @@ static int32_t __fastcall __ntapi_init_once(ntapi_vtbl ** pvtbl) /* nt_statfs.h */ __ntapi->tt_statfs = __ntapi_tt_statfs; - /* nt_debug.h */ - #ifdef __DEBUG - __ntapi->dbg_write = __dbg_write; - __ntapi->dbg_fn_call = __dbg_fn_call; - __ntapi->dbg_msg = __dbg_msg; - #endif + /* nt_log.h */ + __ntapi->log_write = __ntapi_log_write; + __ntapi->log_fn_call = __ntapi_log_fn_call; + __ntapi->log_msg = __ntapi_log_msg; /* OS version dependent functions */ diff --git a/src/internal/ntapi_fnapi.h b/src/internal/ntapi_fnapi.h index 0d50970..f1a6792 100644 --- a/src/internal/ntapi_fnapi.h +++ b/src/internal/ntapi_fnapi.h @@ -330,9 +330,9 @@ NTAPI_UFN(tt_guid_to_string_utf16); NTAPI_UFN(tt_string_to_guid_utf16); /* debug */ -NTAPI_UFN(dbg_write); -NTAPI_UFN(dbg_fn_call); -NTAPI_UFN(dbg_msg); +NTAPI_UFN(log_write); +NTAPI_UFN(log_fn_call); +NTAPI_UFN(log_msg); /* csrss */ NTAPI_VFN(tt_get_csr_port_handle_addr_by_logic,i386); diff --git a/src/internal/ntapi_debug.c b/src/internal/ntapi_log.c index a81b80d..04f6624 100644 --- a/src/internal/ntapi_debug.c +++ b/src/internal/ntapi_log.c @@ -4,16 +4,12 @@ /* Released under GPLv2 and GPLv3; see COPYING.NTAPI. */ /********************************************************/ -typedef int __dbg_dummy; - -#ifdef __DEBUG - #include <psxtypes/psxtypes.h> #include <ntapi/nt_file.h> #include <ntapi/ntapi.h> #include "ntapi_impl.h" -ssize_t __cdecl __dbg_write( +ssize_t __cdecl __ntapi_log_write( __in void * hfile, __in const void * buf, __in size_t bytes) @@ -39,23 +35,23 @@ ssize_t __cdecl __dbg_write( } -int32_t __cdecl __dbg_fn_call( +int32_t __cdecl __ntapi_log_fn_call( __in void * hfile __optional, __in const char * fn_caller_name, __in void * fn_callee_addr, __in uintptr_t fn_ret, - __in ntapi_dbg_write* pfn_dbg_write __optional, + __in ntapi_log_write* pfn_log_write __optional, __in const char * source __optional, __in int line __optional) { struct pe_ldr_tbl_entry * image_meta; void * image_base; char * fn_name; - size_t bytes; - char dbg_buf[2048]; + ssize_t bytes; + char log_buf[2048]; - if (!pfn_dbg_write) - pfn_dbg_write = __dbg_write; + if (!pfn_log_write) + pfn_log_write = __ntapi_log_write; image_meta = pe_get_symbol_module_info(fn_callee_addr); fn_name = (char *)0; @@ -71,40 +67,33 @@ int32_t __cdecl __dbg_fn_call( image_base, fn_callee_addr); - if (!fn_name) - fn_name = pe_get_import_symbol_info( - fn_callee_addr, - (void **)0, - (char **)0, - &image_meta); - if (source && fn_name) bytes = __ntapi->sprintf( - dbg_buf, + log_buf, "%s: (%s:%d):\n" "--> %s returned 0x%08x\n\n", fn_caller_name, source, line, fn_name, fn_ret); else if (fn_name) bytes = __ntapi->sprintf( - dbg_buf, + log_buf, "%s: %s returned 0x%08x\n\n", fn_caller_name, fn_name, fn_ret); else if (source) bytes = __ntapi->sprintf( - dbg_buf, + log_buf, "%s: (%s:%d):\n" "--> calling 0x%08x returned 0x%08x\n\n", fn_caller_name, source, line, fn_callee_addr, fn_ret); else bytes = __ntapi->sprintf( - dbg_buf, + log_buf, "%s: calling 0x%08x returned 0x%08x\n\n", fn_caller_name, fn_callee_addr, fn_ret); if (bytes) { - bytes = __ntapi->strlen(dbg_buf); + bytes = __ntapi->strlen(log_buf); - if (bytes == pfn_dbg_write(hfile,dbg_buf,bytes)) + if (bytes == pfn_log_write(hfile,log_buf,bytes)) return NT_STATUS_SUCCESS; else return NT_STATUS_UNSUCCESSFUL; @@ -113,7 +102,7 @@ int32_t __cdecl __dbg_fn_call( } -int32_t __cdecl __dbg_msg( +int32_t __cdecl __ntapi_log_msg( __in void * hfile __optional, __in const char * source __optional, __in int line __optional, @@ -125,16 +114,17 @@ int32_t __cdecl __dbg_msg( __in uintptr_t arg4, __in uintptr_t arg5, __in uintptr_t arg6, - __in ntapi_dbg_write* pfn_dbg_write __optional) + __in ntapi_log_write* pfn_log_write __optional) { char * buffer; - size_t bytes; + ssize_t bytes; + char log_buf[2048]; - if (!pfn_dbg_write) - pfn_dbg_write = __dbg_write; + if (!pfn_log_write) + pfn_log_write = __ntapi_log_write; bytes = 0; - buffer = dbg_buf; + buffer = log_buf; if (source) bytes = __ntapi->sprintf( @@ -147,24 +137,22 @@ int32_t __cdecl __dbg_msg( "%s: ", fn_caller_name); else - dbg_buf[0] = '\0'; + log_buf[0] = '\0'; if (bytes >= 0) - buffer += __ntapi->strlen(dbg_buf); + buffer += __ntapi->strlen(log_buf); else return NT_STATUS_UNSUCCESSFUL; bytes = __ntapi->sprintf(buffer,fmt,arg1,arg2,arg3,arg4,arg5,arg6); if (bytes) { - bytes = __ntapi->strlen(dbg_buf); + bytes = __ntapi->strlen(log_buf); - if (bytes == pfn_dbg_write(hfile,dbg_buf,bytes)) + if (bytes == pfn_log_write(hfile,log_buf,bytes)) return NT_STATUS_SUCCESS; else return NT_STATUS_UNSUCCESSFUL; } else return NT_STATUS_UNSUCCESSFUL; } - -#endif |