Page MenuHomePhabricator

No OneTemporary

Size
12 KB
Referenced Files
None
Subscribers
None
diff --git a/trunk/fred.pro b/trunk/fred.pro
index c086a0e..a062e08 100644
--- a/trunk/fred.pro
+++ b/trunk/fred.pro
@@ -1,128 +1,129 @@
#*******************************************************************************
# fred Copyright (c) 2011-2013 by Gillen Daniel <gillen.dan@pinguin.lu> *
# *
# Forensic Registry EDitor (fred) is a cross-platform M$ registry hive editor *
# with special feautures useful during forensic analysis. *
# *
# This program is free software: you can redistribute it and/or modify it *
# under the terms of the GNU General Public License as published by the Free *
# Software Foundation, either version 3 of the License, or (at your option) *
# any later version. *
# *
# This program is distributed in the hope that it will be useful, but WITHOUT *
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for *
# more details. *
# *
# You should have received a copy of the GNU General Public License along with *
# this program. If not, see <http://www.gnu.org/licenses/>. *
#******************************************************************************/
# Generate compileinfo.h
system(bash compileinfo.sh > compileinfo.h)
#compileinfo.target = compileinfo.h
#compileinfo.commands = $$PWD/compileinfo.sh > compileinfo.h
#QMAKE_EXTRA_TARGETS += compileinfo
#PRE_TARGETDEPS += compileinfo.h
# Build fred
QMAKE_CXXFLAGS += -Wall
QT += core \
gui \
script \
webkit
CONFIG += console
TARGET = fred
TEMPLATE = app
SOURCES += main.cpp\
mainwindow.cpp \
registrynode.cpp \
registrynodetreemodel.cpp \
registrykey.cpp \
registrykeytablemodel.cpp \
dlgabout.cpp \
dlgkeydetails.cpp \
qhexedit/qhexedit_p.cpp \
qhexedit/qhexedit.cpp \
reporttemplate.cpp \
registryhive.cpp \
qtscript_types/bytearray.cpp \
qtscript_types/bytearrayprototype.cpp \
qtscript_types/bytearrayiterator.cpp \
dlgreportviewer.cpp \
registrykeytable.cpp \
registrynodetree.cpp \
dlgsearch.cpp \
threadsearch.cpp \
searchresultwidget.cpp \
tabwidget.cpp \
argparser.cpp \
datainterpretertable.cpp \
datainterpreterwidget.cpp \
hexeditwidget.cpp \
settings.cpp \
searchresulttabledelegate.cpp \
registrynodetreemodelproxy.cpp \
reports.cpp \
reportengine.cpp \
dlgreportchooser.cpp \
dlgpreferences.cpp \
- dlgaddkey.cpp
+ dlgaddkey.cpp
HEADERS += mainwindow.h \
registrynode.h \
registrynodetreemodel.h \
registrykey.h \
registrykeytablemodel.h \
dlgabout.h \
dlgkeydetails.h \
qhexedit/qhexedit_p.h \
qhexedit/qhexedit.h \
reporttemplate.h \
registryhive.h \
qtscript_types/bytearray.h \
qtscript_types/bytearrayprototype.h \
qtscript_types/bytearrayiterator.h \
dlgreportviewer.h \
registrykeytable.h \
registrynodetree.h \
dlgsearch.h \
threadsearch.h \
searchresultwidget.h \
tabwidget.h \
argparser.h \
datainterpretertable.h \
datainterpreterwidget.h \
hexeditwidget.h \
settings.h \
searchresulttabledelegate.h \
registrynodetreemodelproxy.h \
reports.h \
reportengine.h \
dlgreportchooser.h \
dlgpreferences.h \
- dlgaddkey.h
+ dlgaddkey.h \
+ macros.h
FORMS += mainwindow.ui \
dlgabout.ui \
dlgkeydetails.ui \
dlgreportviewer.ui \
dlgsearch.ui \
dlgreportchooser.ui \
dlgpreferences.ui \
- dlgaddkey.ui
+ dlgaddkey.ui
#LIBS += -lhivex
LIBS += $$PWD/hivex/lib/.libs/libhivex.a
#DEFINES += __STDC_FORMAT_MACROS
RESOURCES += fred.qrc
RC_FILE = fred.rc
ICON = resources/fred.icns
diff --git a/trunk/macros.h b/trunk/macros.h
new file mode 100644
index 0000000..64902a7
--- /dev/null
+++ b/trunk/macros.h
@@ -0,0 +1,263 @@
+/*******************************************************************************
+* Copyright (c) 2011 by Gillen Daniel <gillen.dan@pinguin.lu> *
+* *
+* This file contains macros with some very often used code pieces. It should *
+* primarily make my everyday life easier and improve code portability. *
+* *
+* This program is free software: you can redistribute it and/or modify it *
+* under the terms of the GNU General Public License as published by the Free *
+* Software Foundation, either version 3 of the License, or (at your option) *
+* any later version. *
+* *
+* This program is distributed in the hope that it will be useful, but WITHOUT *
+* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
+* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for *
+* more details. *
+* *
+* You should have received a copy of the GNU General Public License along with *
+* this program. If not, see <http://www.gnu.org/licenses/>. *
+*******************************************************************************/
+
+// Available macro groups:
+//
+// MACROS_FILE, MACROS_STRING, MACROS_WSTRING, MACROS_ENDIANNESS, MACROS_MUTEX,
+// MACROS_MEMORY, MACROS_LOGGING
+//
+// Define one or more of these before including this file to make them available
+
+#ifndef MACROS_H
+#define MACROS_H
+
+/*
+ * Macros for file access
+ */
+#ifdef MACROS_FILE
+ #include <stdio.h>
+
+ #undef FOPEN
+ #ifndef __APPLE__
+ #define FOPEN (FILE*)fopen64
+ #else
+ // Apple always uses fopen
+ #define FOPEN (FILE*)fopen
+ #endif // __APPLE__
+ #undef FCLOSE
+ #define FCLOSE(var,err_ret) { \
+ if(fclose(var)!=0) { \
+ LOG_ERROR("Couldn't close file!") \
+ err_ret; \
+ } \
+ }
+ #undef FSEEK
+ #define FSEEK(hfile,off,whence,err_ret) { \
+ if(fseeko(hfile,off,whence)!=0) { \
+ LOG_ERROR("Couldn't seek to offset %u!",off); \
+ err_ret; \
+ } \
+ }
+ #undef FTELL
+ #define FTELL(hfile,var,err_ret) { \
+ if((var=ftello(hfile))==-1) { \
+ LOG_ERROR("Unable to get file position!"); \
+ err_ret; \
+ } \
+ }
+ #undef FTELLSIZE
+ #define FTELLSIZE(hfile,var,err_ret) { \
+ FSEEK(hfile,0,SEEK_END,err_ret); \
+ FTELL(hfile,var,err_ret); \
+ rewind(hfile); \
+ }
+#endif
+
+/*
+ * Macros for string functions
+ *
+ * Will also include MACROS_MEMORY and MACROS_LOGGING
+ */
+#ifdef MACROS_STRING
+ #include <string.h>
+
+ // These macros rely partly on memory macros, so those are needed too
+ #define MACROS_MEMORY
+
+ #undef STRSET
+ #define STRSET(dst,src,err_ret) { \
+ MALLOC(dst,char*,(strlen(src)+1)*sizeof(char),err_ret) \
+ strcpy(dst,src); \
+ }
+ #undef STRNSET
+ #define STRNSET(dst,src,size,err_ret) { \
+ MALLOC(dst,char*,((size)+1)*sizeof(char),err_ret) \
+ strncpy(dst,src,size); \
+ (dst)[size]='\0'; \
+ }
+ #undef STRAPP
+ #define STRAPP(var1,var2,err_ret) { \
+ REALLOC(var1,char*,(strlen(var1)+strlen(var2)+1)*sizeof(char),err_ret) \
+ strcpy((var1)+strlen(var1),var2); \
+ }
+ #undef STRNAPP
+ #define STRNAPP(var1,var2,size,err_ret) { \
+ REALLOC(var1,char*,(strlen(var1)+(size)+1)*sizeof(char),err_ret) \
+ (var1)[strlen(var1)+(size)]='\0'; \
+ strncpy((var1)+strlen(var1),var2,size); \
+ }
+#endif
+
+/*
+ * Macros for wide string functions
+ *
+ * Will also include MACROS_MEMORY and MACROS_LOGGING
+ */
+#ifdef MACROS_WSTRING
+ #include <string.h>
+
+ // These macros rely partly on memory macros, so those are needed too
+ #define MACROS_MEMORY
+
+ #undef WSTRSET
+ #define WSTRSET(dst,src,err_ret) { \
+ MALLOC(dst,wchar_t*,(wcslen(src)+1)*sizeof(wchar_t),err_ret) \
+ wcscpy(dst,src); \
+ }
+ #undef WSTRNSET
+ #define WSTRNSET(dst,src,size,err_ret) { \
+ MALLOC(dst,wchar_t*,((size)+1)*sizeof(wchar_t),err_ret) \
+ wcsncpy(dst,src,size); \
+ (dst)[size]=L'\0'; \
+ }
+#endif
+
+/*
+ * Macros for endianness conversion
+ */
+#ifdef MACROS_ENDIANNESS
+ #include <endian.h>
+
+ #undef LE16TOH
+ #define LE16TOH(var) le16toh(var)
+ #undef BE16TOH
+ #define BE16TOH(var) be16toh(var)
+ #undef LE32TOH
+ #define LE32TOH(var) le32toh(var)
+ #undef BE32TOH
+ #define BE32TOH(var) be32toh(var)
+ #undef LE64TOH
+ #define LE64TOH(var) le64toh(var)
+ #undef BE64TOH
+ #define BE64TOH(var) be64toh(var)
+ #undef HTOLE16
+ #define HTOLE16(var) htole16(var)
+ #undef HTOBE16
+ #define HTOBE16(var) htobe16(var)
+ #undef HTOLE32
+ #define HTOLE32(var) htole32(var)
+ #undef HTOBE32
+ #define HTOBE32(var) htobe32(var)
+ #undef HTOLE64
+ #define HTOLE64(var) htole64(var)
+ #undef HTOBE64
+ #define HTOBE64(var) htobe64(var)
+#endif
+
+/*
+ * Macros for mutex access
+ */
+#ifdef MACROS_MUTEX
+ #include <pthread.h>
+
+ #undef MUTEX_INIT
+ #define MUTEX_INIT(var) { \
+ pthread_mutex_init(&(var),NULL); \
+ }
+ #undef MUTEX_DESTROY
+ #define MUTEX_DESTROY(var) { \
+ pthread_mutex_destroy(&(var)); \
+ }
+ #undef MUTEX_LOCK
+ #define MUTEX_LOCK(var) { \
+ pthread_mutex_lock(&(var)); \
+ }
+ #undef MUTEX_UNLOCK
+ #define MUTEX_UNLOCK(var) { \
+ pthread_mutex_unlock(&(var)); \
+ }
+#endif
+
+/*
+ * Macros for memory management
+ *
+ * Will also include MACROS_LOGGING!
+ */
+#ifdef MACROS_MEMORY
+ #include <stdlib.h>
+
+ // These macros rely partly on logging macros, so those are needed too
+ #define MACROS_LOGGING
+
+ #undef MALLOC
+ #define MALLOC(var,var_type,size,err_ret) { \
+ (var)=(var_type)malloc(size); \
+ if((var)==NULL) { \
+ LOG_ERROR("Couldn't allocate memmory!\n"); \
+ err_ret; \
+ } \
+ }
+ #undef REALLOC
+ #define REALLOC(var,var_type,size,err_ret) { \
+ (var)=(var_type)realloc((var),size); \
+ if((var)==NULL) { \
+ LOG_ERROR("Couldn't allocate memmory!\n"); \
+ err_ret; \
+ } \
+ }
+ #undef FREE
+ #define FREE(var) free(var)
+#endif
+
+/*
+ * Macros to ease debugging and error reporting
+ *
+ * These require the following function to be implemented somewhere:
+ *
+ * #include <stdio.h>
+ * #include <stdarg.h>
+ *
+ * static void LogMessage(char *p_message_type,
+ * char *p_calling_function,
+ * int line,
+ * char *p_message,
+ * ...)
+ * {
+ * va_list VaList;
+ * // Print message "header"
+ * printf("%s: %s@%u : ",
+ * p_message_type,
+ * p_calling_function,
+ * line);
+ * // Print message with variable parameters
+ * va_start(VaList,p_message);
+ * vprintf(p_message,VaList);
+ * va_end(VaList);
+ * printf("\n");
+ * }
+ */
+#ifdef MACROS_LOGGING
+ #undef LOG_ERROR
+ #define LOG_ERROR(...) \
+ LogMessage("ERROR",(char*)__FUNCTION__,__LINE__,__VA_ARGS__);
+ #undef LOG_DEBUG
+ #define LOG_DEBUG(...) { \
+ LogMessage("DEBUG",(char*)__FUNCTION__,__LINE__,__VA_ARGS__); \
+ }
+#endif
+
+#endif // MACROS_H
+
+/*
+ ----- Change history -----
+ 20130611: * Added ability to only include specific macro groups.
+ 20110428: * Initial release.
+*/
+

File Metadata

Mime Type
text/x-diff
Expires
Tue, Dec 24, 3:04 AM (1 d, 8 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1176856
Default Alt Text
(12 KB)

Event Timeline