summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2019-05-25 12:20:51 +0000
committermidipix <writeonce@midipix.org>2019-05-25 22:21:45 -0400
commita7ffe354b225db0b2712af41ea82743fb07758ca (patch)
treea9454d52383574ef94763b0f1303fe0319d6e6e8
parent1c3ec496b1b788c1b83d5a187e82b45c0bd204f2 (diff)
downloadntapi-a7ffe354b225db0b2712af41ea82743fb07758ca.tar.bz2
ntapi-a7ffe354b225db0b2712af41ea82743fb07758ca.tar.xz
internals: renamed nt_debug.h --> nt_log.h, renamed interfaces accordingly.
-rw-r--r--include/ntapi/nt_log.h (renamed from include/ntapi/nt_debug.h)14
-rw-r--r--include/ntapi/ntapi.h10
-rw-r--r--project/common.mk2
-rw-r--r--project/headers.mk2
-rw-r--r--src/internal/ntapi.c12
-rw-r--r--src/internal/ntapi_fnapi.h6
-rw-r--r--src/internal/ntapi_log.c (renamed from src/internal/ntapi_debug.c)60
7 files changed, 46 insertions, 60 deletions
diff --git a/include/ntapi/nt_debug.h b/include/ntapi/nt_log.h
index a517a78..7a64564 100644
--- a/include/ntapi/nt_debug.h
+++ b/include/ntapi/nt_log.h
@@ -1,26 +1,26 @@
-#ifndef _NT_DEBUG_H_
-#define _NT_DEBUG_H_
+#ifndef _NT_LOG_H_
+#define _NT_LOG_H_
#include "nt_abi.h"
#include "nt_file.h"
-typedef ssize_t __cdecl ntapi_dbg_write(
+typedef ssize_t __cdecl ntapi_log_write(
__in void * hfile,
__in const void * buf,
__in size_t bytes);
-typedef int32_t __cdecl ntapi_dbg_fn_call(
+typedef 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);
-typedef int32_t __cdecl ntapi_dbg_msg(
+typedef int32_t __cdecl ntapi_log_msg(
__in void * hfile __optional,
__in const char * source __optional,
__in int line __optional,
@@ -32,6 +32,6 @@ typedef int32_t __cdecl ntapi_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);
#endif
diff --git a/include/ntapi/ntapi.h b/include/ntapi/ntapi.h
index 82491a7..ec4fb31 100644
--- a/include/ntapi/ntapi.h
+++ b/include/ntapi/ntapi.h
@@ -46,7 +46,7 @@
#include "nt_vfd.h"
#include "nt_tty.h"
#include "nt_hash.h"
-#include "nt_debug.h"
+#include "nt_log.h"
#ifdef __cplusplus
@@ -650,10 +650,10 @@ typedef struct _ntapi_vtbl {
/* nt_statfs.h */
ntapi_tt_statfs * tt_statfs;
- /* nt_debug.h */
- ntapi_dbg_write * dbg_write;
- ntapi_dbg_fn_call * dbg_fn_call;
- ntapi_dbg_msg * dbg_msg;
+ /* nt_log.h */
+ ntapi_log_write * log_write;
+ ntapi_log_fn_call * log_fn_call;
+ ntapi_log_msg * log_msg;
} ntapi_vtbl;
diff --git a/project/common.mk b/project/common.mk
index ffd7376..19b6cf9 100644
--- a/project/common.mk
+++ b/project/common.mk
@@ -28,8 +28,8 @@ COMMON_SRCS = \
src/hash/ntapi_tt_crc64.c \
src/hash/ntapi_tt_populate_hashed_import_table.c \
src/internal/ntapi.c \
- src/internal/ntapi_debug.c \
src/internal/ntapi_entry_point.c \
+ src/internal/ntapi_log.c \
src/internal/ntapi_open.c \
src/ipc/ntapi_ipc_connect.c \
src/ipc/ntapi_ipc_create_pipe_v1.c \
diff --git a/project/headers.mk b/project/headers.mk
index f8bf78a..3e0e0ce 100644
--- a/project/headers.mk
+++ b/project/headers.mk
@@ -13,7 +13,6 @@ API_HEADERS = \
$(SOURCE_DIR)/include/$(PACKAGE)/./nt_crc64.h \
$(SOURCE_DIR)/include/$(PACKAGE)/./nt_daemon.h \
$(SOURCE_DIR)/include/$(PACKAGE)/./nt_dalist.h \
- $(SOURCE_DIR)/include/$(PACKAGE)/./nt_debug.h \
$(SOURCE_DIR)/include/$(PACKAGE)/./nt_device.h \
$(SOURCE_DIR)/include/$(PACKAGE)/./nt_exception.h \
$(SOURCE_DIR)/include/$(PACKAGE)/./nt_file.h \
@@ -26,6 +25,7 @@ API_HEADERS = \
$(SOURCE_DIR)/include/$(PACKAGE)/./nt_job.h \
$(SOURCE_DIR)/include/$(PACKAGE)/./nt_ldr.h \
$(SOURCE_DIR)/include/$(PACKAGE)/./nt_locale.h \
+ $(SOURCE_DIR)/include/$(PACKAGE)/./nt_log.h \
$(SOURCE_DIR)/include/$(PACKAGE)/./nt_memory.h \
$(SOURCE_DIR)/include/$(PACKAGE)/./nt_mount.h \
$(SOURCE_DIR)/include/$(PACKAGE)/./nt_msq.h \
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