OSDN Git Service

*** empty log message ***
authorkoinec <>
Sun, 4 Sep 2011 13:11:42 +0000 (13:11 +0000)
committerkoinec <>
Sun, 4 Sep 2011 13:11:42 +0000 (13:11 +0000)
12 files changed:
Makefile
include/libgoblin.h [new file with mode: 0644]
libgoblin/Makefile [new file with mode: 0644]
libgoblin/drd64_libgoblin.h [new file with mode: 0644]
libgoblin/drd64_libgoblin_analyze.c [new file with mode: 0644]
libgoblin/drd64_libgoblin_analyze.h [new file with mode: 0644]
libgoblin/drd64_libgoblin_binfo.c [new file with mode: 0644]
libgoblin/drd64_libgoblin_binfo.h [new file with mode: 0644]
libgoblin/drd64_libgoblin_checkbin.c [new file with mode: 0644]
libgoblin/drd64_libgoblin_checkbin.h [new file with mode: 0644]
libgoblin/drd64_libgoblin_system.c [new file with mode: 0644]
libgoblin/elftest.c [new file with mode: 0644]

index 35540cf..96108a6 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -20,17 +20,21 @@ LIBINTEL64ASM_DIR = libintel64asm
 LIBBROWNIE_TARGET = libbrownie.a
 LIBBROWNIE_DIR = libbrownie
 
+LIBGOBLIN_TARGET = libgoblin.a
+LIBGOBLIN_DIR = libgoblin
+
 TESTPG01_TARGET = count
 TESTPG_DIR = testpg
 
 TEST_TARGET = drdrv1
 TEST_OBJS = drdrv1.o
-TEST_LIBS = $(LIBDRD64_TARGET) $(LIBBROWNIE_TARGET)
+TEST_LIBS = $(LIBDRD64_TARGET) $(LIBBROWNIE_TARGET) $(LIBGOBLIN)
 
 all:   $(LIBBROWNIE_TARGET) \
                $(DEBUGD_TARGET) \
                $(MARSHALD_TARGET) \
                $(LIBDRD64_TARGET) \
+               $(LIBGOBLIN_TARGET) \
                $(LIBINTEL64ASM_TARGET) \
                $(TESTPG01_TARGET) \
                $(TEST_TARGET)
@@ -50,6 +54,9 @@ $(LIBINTEL64ASM_TARGET):
 $(LIBDRD64_TARGET):
        $(MAKE) -C $(LIBDRD64_DIR) all
 
+$(LIBGOBLIN_TARGET):
+       $(MAKE) -C $(LIBGOBLIN_DIR) all
+
 $(TESTPG01_TARGET):
        $(MAKE) -C $(TESTPG_DIR) $(TESTPG01_TARGET)
 
@@ -68,12 +75,14 @@ clean:
        rm -f $(MARSHALD_TARGET)
        rm -f $(LIBINTEL64ASM_TARGET)
        rm -f $(LIBDRD64_TARGET)
+       rm -f $(LIBGOBLIN_TARGET)
        rm -f $(TESTPG01_TARGET)
        rm -f $(TEST_TARGET)
        rm -f *.core
        $(MAKE) -C $(LIBBROWNIE_DIR) clean
        $(MAKE) -C $(LIBINTEL64ASM_DIR) clean
        $(MAKE) -C $(LIBDRD64_DIR) clean
+       $(MAKE) -C $(LIBGOBLIN_DIR) clean
        $(MAKE) -C $(DEAMON_DIR) clean
        $(MAKE) -C $(TESTPG_DIR) clean
 
diff --git a/include/libgoblin.h b/include/libgoblin.h
new file mode 100644 (file)
index 0000000..c1ebe38
--- /dev/null
@@ -0,0 +1,72 @@
+/*DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64
+
+                         D r . D e a m o n  6 4
+                        for INTEL64(R), AMD64(R)
+       
+   Copyright(C) 2007-2009 Koine Yuusuke(koinec). All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+    this list of conditions and the following disclaimer.
+ 2. Redistributions in binary form must reproduce the above copyright
+    notice, this list of conditions and the following disclaimer in the
+    documentation and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY Koine Yuusuke(koinec) ``AS IS'' AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL Koine Yuusuke(koinec) OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+OF THE POSSIBILITY OF SUCH DAMAGE.
+
+DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64*/
+
+/* File Info -----------------------------------------------------------
+File: drd64_.h
+Function: Header 
+Comment: 
+----------------------------------------------------------------------*/
+
+#ifndef DRD64_HEADER_LIBGOBLIN
+#define DRD64_HEADER_LIBGOBLIN
+
+#include"./drd64_types.h"
+#include"./drd64_defines.h"
+#include"./drd64_error.h"
+
+#ifdef DRD64_HEADER_LIBGOBLIN_MAIN
+       #define LIBGOBLIN_FUNC
+#else
+       #define LIBGOBLIN_FUNC  extern
+#endif
+
+
+/* drd64_libgoblin_?????.c Functions =====================*/
+LIBGOBLIN_FUNC
+int
+       Drd64_LibGoblin_Init(
+               void );
+
+LIBGOBLIN_FUNC
+int
+       Drd64_LibGoblin_Term(
+               void );
+
+LIBGOBLIN_FUNC
+int
+       Drd64_LibGoblin_AnalyzeBinary(
+               Byte    *p_data,
+               DWord   dw_size );
+
+
+
+#endif /* DRD64_HEADER_LIBGOBLIN */
+
+/* EOF of drd64_.h ----------------------------------- */
diff --git a/libgoblin/Makefile b/libgoblin/Makefile
new file mode 100644 (file)
index 0000000..e621a99
--- /dev/null
@@ -0,0 +1,92 @@
+##DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64
+#
+#                         D r . D e a m o n  6 4
+#                        for INTEL64(R), AMD64(R)
+#    
+#   Copyright(C) 2007-2009 Koine Yuusuke(koinec). All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are met:
+#
+# 1. Redistributions of source code must retain the above copyright notice,
+#    this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+#    notice, this list of conditions and the following disclaimer in the
+#    documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY Koine Yuusuke(koinec) ``AS IS'' AND ANY
+# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+# DISCLAIMED. IN NO EVENT SHALL Koine Yuusuke(koinec) OR CONTRIBUTORS BE
+# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+# OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+##DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64
+
+## File Info -----------------------------------------------------------
+# File: Makefile
+# Function: 
+# Comment: 
+##----------------------------------------------------------------------
+
+# Section 1 : Setting Build Command ####################################
+MAKE = make
+CC = gcc
+
+
+SUPER_HEADER = ../include/drd64_conf.h \
+                               ../include/drd64_defines.h \
+                               ../include/drd64_types.h \
+                               ../include/drd64_error.h
+CLIENT_HEADER =
+USER_HEADER =
+
+FLAGS_DEBUG = -g
+
+LIBGOBLIN_TARGET = libgoblin.a
+LIBGOBLIN_OBJS = drd64_libgoblin_system.o \
+                                       drd64_libgoblin_checkbin.o \
+                                       drd64_libgoblin_analyze.o \
+                                       drd64_libgoblin_binfo.o
+LIBGOBLIN_HEADER = drd64_libgoblin.h \
+                                       drd64_libgoblin_binfo.h \
+                                       drd64_libgoblin_checkbin.h \
+                                       drd64_libgoblin_analyze.h \
+                                       ../include/libgoblin.h \
+                                       $(SUPER_HEADER)
+
+TESTPG_TARGET = elftest
+
+
+all:   $(LIBGOBLIN_TARGET) $(TESTPG_TARGET)
+
+$(LIBGOBLIN_TARGET): $(LIBGOBLIN_OBJS)
+       ar rv $(LIBGOBLIN_TARGET) $(LIBGOBLIN_OBJS)
+       ranlib $(LIBGOBLIN_TARGET)
+       cp $(LIBGOBLIN_TARGET) ..
+
+drd64_libgoblin_system.o: drd64_libgoblin_system.c $(LIBBROWNIE_HEADER)
+       gcc -c -o drd64_libgoblin_system.o $(FLAGS_DEBUG) \
+                               drd64_libgoblin_system.c
+drd64_libgoblin_binfo.o: drd64_libgoblin_binfo.c $(LIBBROWNIE_HEADER)
+       gcc -c -o drd64_libgoblin_binfo.o $(FLAGS_DEBUG) \
+                               drd64_libgoblin_binfo.c
+drd64_libgoblin_checkbin.o: drd64_libgoblin_checkbin.c $(LIBBROWNIE_HEADER)
+       gcc -c -o drd64_libgoblin_checkbin.o $(FLAGS_DEBUG) \
+                               drd64_libgoblin_checkbin.c
+
+$(TESTPG_TARGET): elftest.c ../include/libgoblin.h $(LIBGOBLIN_TARGET)
+       gcc -g -o $(TESTPG_TARGET) elftest.c $(LIBGOBLIN_TARGET)
+
+
+clean:
+       rm -f *.o
+       rm -f $(LIBGOBLIN_TARGET)
+       rm -f $(TESTPG_TARGET)
+       rm -f *.core
+
diff --git a/libgoblin/drd64_libgoblin.h b/libgoblin/drd64_libgoblin.h
new file mode 100644 (file)
index 0000000..5702e4c
--- /dev/null
@@ -0,0 +1,57 @@
+/*DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64
+
+                         D r . D e a m o n  6 4
+                        for INTEL64(R), AMD64(R)
+       
+   Copyright(C) 2007-2009 Koine Yuusuke(koinec). All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+    this list of conditions and the following disclaimer.
+ 2. Redistributions in binary form must reproduce the above copyright
+    notice, this list of conditions and the following disclaimer in the
+    documentation and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY Koine Yuusuke(koinec) ``AS IS'' AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL Koine Yuusuke(koinec) OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+OF THE POSSIBILITY OF SUCH DAMAGE.
+
+DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64*/
+
+/* File Info -----------------------------------------------------------
+File: drd64_.h
+Function: Header 
+Comment: 
+----------------------------------------------------------------------*/
+
+#ifndef DRD64_HEADER_LIBGOBLIN_MAIN
+#define DRD64_HEADER_LIBGOBLIN_MAIN
+
+#include<stdio.h>
+#include<stdlib.h>
+#include<string.h>
+#include<assert.h>
+#include<elf.h>
+#include"../include/drd64_types.h"
+#include"../include/drd64_defines.h"
+#include"../include/drd64_error.h"
+#include"../include/drd64_conf.h"
+#include"../include/libgoblin.h"
+#include"drd64_libgoblin_binfo.h"
+#include"drd64_libgoblin_checkbin.h"
+#include"drd64_libgoblin_analyze.h"
+
+
+#endif /* DRD64_HEADER_LIBGOBLIN_MAIN */
+
+/* EOF of drd64_.h ----------------------------------- */
diff --git a/libgoblin/drd64_libgoblin_analyze.c b/libgoblin/drd64_libgoblin_analyze.c
new file mode 100644 (file)
index 0000000..b8c1560
--- /dev/null
@@ -0,0 +1,75 @@
+/*DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64
+
+                         D r . D e a m o n  6 4
+                        for INTEL64(R), AMD64(R)
+       
+   Copyright(C) 2007-2009 Koine Yuusuke(koinec). All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+    this list of conditions and the following disclaimer.
+ 2. Redistributions in binary form must reproduce the above copyright
+    notice, this list of conditions and the following disclaimer in the
+    documentation and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY Koine Yuusuke(koinec) ``AS IS'' AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL Koine Yuusuke(koinec) OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+OF THE POSSIBILITY OF SUCH DAMAGE.
+
+DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64*/
+
+/* File Info -----------------------------------------------------------
+File: drd64_.c
+Function: 
+Comment: 
+----------------------------------------------------------------------*/
+
+#define DRD64_SRC_LIBGOBLIN_ANALYZE
+#include"drd64_libgoblin.h"
+
+
+LIBGOBLIN_FUNC
+int
+       Drd64_LibGoblin_AnalyzeBinary(
+               Byte    *p_data,
+               DWord   dw_size )
+{
+       int             i_bid;
+       int             i_bintype;
+       int             i_err;
+       Drd64_LibGoblin_BinaryInfo      *p_bin;
+
+       /* Alloc BinaryInfo Struct */
+       p_bin   = Drd64_LibDrd64_BinInfo_AllocBinInfo();
+       if( NULL == p_bin )             { return -1; }
+       i_bid   = p_bin->i_id;
+
+       p_bin->p_binary = p_data;
+       p_bin->dw_size  = dw_size;
+
+       /* Check Binary Format */
+       i_bintype       = Drd64_LibGoblin_CheckBinary( p_bin );
+
+       if( DRD64_LIBGOBLIN_BINFO_TYPE_ELF == i_bintype )       {
+               /* Analyze ELF-Binary Format */
+               /* Analyze DWARF-Debug Format */
+       }       else {
+       
+       }
+       
+
+       return i_bid;
+}
+
+
+/* EOF of drd64_.c ----------------------------------- */
diff --git a/libgoblin/drd64_libgoblin_analyze.h b/libgoblin/drd64_libgoblin_analyze.h
new file mode 100644 (file)
index 0000000..f2c7a86
--- /dev/null
@@ -0,0 +1,52 @@
+/*DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64
+
+                         D r . D e a m o n  6 4
+                        for INTEL64(R), AMD64(R)
+       
+   Copyright(C) 2007-2009 Koine Yuusuke(koinec). All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+    this list of conditions and the following disclaimer.
+ 2. Redistributions in binary form must reproduce the above copyright
+    notice, this list of conditions and the following disclaimer in the
+    documentation and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY Koine Yuusuke(koinec) ``AS IS'' AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL Koine Yuusuke(koinec) OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+OF THE POSSIBILITY OF SUCH DAMAGE.
+
+DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64*/
+
+/* File Info -----------------------------------------------------------
+File: drd64_.h
+Function: Header 
+Comment: 
+----------------------------------------------------------------------*/
+
+#ifndef DRD64_HEADER_LIBGOBLIN_ANALYZE
+#define DRD64_HEADER_LIBGOBLIN_ANALYZE
+
+#include"drd64_libgoblin.h"
+
+#ifdef DRD64_SRC_LIBGOBLIN_ANALYZE
+       #define LIBGOBLIN_ANALYZE_EXTERN
+#else
+       #define LIBGOBLIN_ANALYZE_EXTERN        extern
+#endif
+
+
+
+#endif /* DRD64_HEADER_LIBGOBLIN_BINFO */
+
+/* EOF of drd64_.h ----------------------------------- */
diff --git a/libgoblin/drd64_libgoblin_binfo.c b/libgoblin/drd64_libgoblin_binfo.c
new file mode 100644 (file)
index 0000000..9baa5fb
--- /dev/null
@@ -0,0 +1,159 @@
+/*DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64
+
+                         D r . D e a m o n  6 4
+                        for INTEL64(R), AMD64(R)
+       
+   Copyright(C) 2007-2009 Koine Yuusuke(koinec). All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+    this list of conditions and the following disclaimer.
+ 2. Redistributions in binary form must reproduce the above copyright
+    notice, this list of conditions and the following disclaimer in the
+    documentation and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY Koine Yuusuke(koinec) ``AS IS'' AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL Koine Yuusuke(koinec) OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+OF THE POSSIBILITY OF SUCH DAMAGE.
+
+DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64*/
+
+/* File Info -----------------------------------------------------------
+File: drd64_.c
+Function: 
+Comment: 
+----------------------------------------------------------------------*/
+
+#define        DRD64_SRC_LIBGOBLIN_BINFO
+#include"drd64_libgoblin.h"
+
+
+/*----------------------------------------------------------------------
+----------------------------------------------------------------------*/
+LIBGOBLIN_BINFO_EXTERN
+Drd64_LibGoblin_BinaryInfo *
+       Drd64_LibDrd64_BinInfo_AllocBinInfo(
+               void)
+{
+       int             i_cnt;
+       int             i_id_now;
+       Drd64_LibGoblin_BinaryInfo *p_binfo_base;
+       Drd64_LibGoblin_BinaryInfo *p_binfo_now;
+       
+       p_binfo_now     = NULL;
+       i_id_now        = -1;
+       
+       if( gi_now_binary_info == gi_max_binary_info )  {
+               for( i_cnt = 0; i_cnt < gi_max_binary_info; i_cnt++ )   {
+                       if( -1 == (gp_binary_info + i_cnt)->i_id )      {
+                               p_binfo_now     = gp_binary_info + i_cnt;
+                               i_id_now        = i_cnt;
+                               break;
+                       }
+               }
+
+               if( NULL == p_binfo_now )       {
+                       p_binfo_base    = realloc( gp_binary_info,
+                                       sizeof( Drd64_LibGoblin_BinaryInfo ) *
+                                               (gi_max_binary_info + DRD64_LIBGOBLIN_BINFO_UNITS) );
+                       if( NULL == p_binfo_base )              { return NULL; }
+               
+                       gp_binary_info  = p_binfo_base;
+                       gi_max_binary_info      += DRD64_LIBGOBLIN_BINFO_UNITS; 
+
+                       p_binfo_now     = gp_binary_info + gi_now_binary_info;
+                       i_id_now        = gi_now_binary_info++;
+               }
+       }
+       else    {
+               p_binfo_now     = gp_binary_info + gi_now_binary_info;
+               i_id_now        = gi_now_binary_info++;
+       }
+
+       memset( p_binfo_now, 0x00, sizeof( Drd64_LibGoblin_BinaryInfo ) );
+
+       p_binfo_now->i_id       = i_id_now;
+
+       return p_binfo_now;
+}
+
+
+/*----------------------------------------------------------------------
+----------------------------------------------------------------------*/
+LIBGOBLIN_BINFO_EXTERN
+int
+       Drd64_LibGoblin_FreeBinaryInfo(
+               Drd64_LibGoblin_BinaryInfo *p_binfo )
+{
+
+       if( NULL == p_binfo )   { return 0x01; }
+
+       memset( p_binfo, 0x00, sizeof( Drd64_LibGoblin_BinaryInfo ) );
+
+       p_binfo->i_id   = -1;
+       
+       return 0x00;
+}
+
+
+/*----------------------------------------------------------------------
+----------------------------------------------------------------------*/
+LIBGOBLIN_BINFO_EXTERN
+int
+       Drd64_LibGoblin_InitBinaryInfo(
+               void)
+{
+       gp_binary_info  = malloc( sizeof( Drd64_LibGoblin_BinaryInfo )
+                                                               * DRD64_LIBGOBLIN_BINFO_UNITS );
+       if( NULL == gp_binary_info )    
+               { return -1; }
+
+       gi_max_binary_info      = DRD64_LIBGOBLIN_BINFO_UNITS;
+       gi_now_binary_info      = 0;
+
+       return 0x00;
+}
+
+
+/*----------------------------------------------------------------------
+----------------------------------------------------------------------*/
+LIBGOBLIN_BINFO_EXTERN
+int
+       Drd64_LibGoblin_TermBinaryInfo(
+               void )
+{
+       free( gp_binary_info );
+       
+       gp_binary_info          = NULL;
+       gi_max_binary_info      = 0;
+       gi_now_binary_info      = 0;
+
+       return 0x00;
+}
+
+
+/*----------------------------------------------------------------------
+----------------------------------------------------------------------*/
+LIBGOBLIN_BINFO_EXTERN
+Drd64_LibGoblin_BinaryInfo *
+       Drd64_LibGoblin_BInfo_GetBinaryInfo(
+               int     i_bid )
+{
+       if(( gi_now_binary_info <= i_bid ) && ( 0 > i_bid ))
+               { return NULL; }
+       
+       return (gp_binary_info + i_bid);
+}
+
+
+/* EOF of drd64_.c ----------------------------------- */
diff --git a/libgoblin/drd64_libgoblin_binfo.h b/libgoblin/drd64_libgoblin_binfo.h
new file mode 100644 (file)
index 0000000..ead09ea
--- /dev/null
@@ -0,0 +1,102 @@
+/*DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64
+
+                         D r . D e a m o n  6 4
+                        for INTEL64(R), AMD64(R)
+       
+   Copyright(C) 2007-2009 Koine Yuusuke(koinec). All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+    this list of conditions and the following disclaimer.
+ 2. Redistributions in binary form must reproduce the above copyright
+    notice, this list of conditions and the following disclaimer in the
+    documentation and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY Koine Yuusuke(koinec) ``AS IS'' AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL Koine Yuusuke(koinec) OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+OF THE POSSIBILITY OF SUCH DAMAGE.
+
+DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64*/
+
+/* File Info -----------------------------------------------------------
+File: drd64_.h
+Function: Header 
+Comment: 
+----------------------------------------------------------------------*/
+
+#ifndef DRD64_HEADER_LIBGOBLIN_BINFO
+#define DRD64_HEADER_LIBGOBLIN_BINFO
+
+#include"drd64_libgoblin.h"
+
+#ifdef DRD64_SRC_LIBGOBLIN_BINFO
+       #define LIBGOBLIN_BINFO_EXTERN
+#else
+       #define LIBGOBLIN_BINFO_EXTERN  extern
+#endif
+
+#define DRD64_LIBGOBLIN_BINFO_UNITS      8
+
+#define        DRD64_LIBGOBLIN_BINFO_TYPE_NONE         0x00
+#define        DRD64_LIBGOBLIN_BINFO_TYPE_ELF          0x01
+
+
+typedef struct {
+       int                     i_id;
+
+       DWord           dw_size;
+       Byte            *p_binary;
+
+       Byte            b_type;
+
+       Elf_Ehdr        *p_elf_hdr;
+       
+
+
+} Drd64_LibGoblin_BinaryInfo;
+
+LIBGOBLIN_BINFO_EXTERN Drd64_LibGoblin_BinaryInfo              *gp_binary_info;
+LIBGOBLIN_BINFO_EXTERN int                                                             gi_max_binary_info;
+LIBGOBLIN_BINFO_EXTERN int                                                             gi_now_binary_info;
+
+
+LIBGOBLIN_BINFO_EXTERN
+       Drd64_LibGoblin_BinaryInfo *
+               Drd64_LibDrd64_BinInfo_AllocBinInfo(
+                       void );
+
+LIBGOBLIN_BINFO_EXTERN
+       int
+               Drd64_LibGoblin_FreeBinaryInfo(
+                       Drd64_LibGoblin_BinaryInfo *p_binfo );
+
+LIBGOBLIN_BINFO_EXTERN
+       int
+               Drd64_LibGoblin_InitBinaryInfo(
+                       void );
+
+LIBGOBLIN_BINFO_EXTERN
+       int
+               Drd64_LibGoblin_TermBinaryInfo(
+                       void );
+
+LIBGOBLIN_BINFO_EXTERN
+       Drd64_LibGoblin_BinaryInfo *
+               Drd64_LibGoblin_BInfo_GetBinaryInfo(
+                       int i_bid );
+
+
+
+#endif /* DRD64_HEADER_LIBGOBLIN_BINFO */
+
+/* EOF of drd64_.h ----------------------------------- */
diff --git a/libgoblin/drd64_libgoblin_checkbin.c b/libgoblin/drd64_libgoblin_checkbin.c
new file mode 100644 (file)
index 0000000..b1e2d90
--- /dev/null
@@ -0,0 +1,71 @@
+/*DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64
+
+                         D r . D e a m o n  6 4
+                        for INTEL64(R), AMD64(R)
+       
+   Copyright(C) 2007-2009 Koine Yuusuke(koinec). All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+    this list of conditions and the following disclaimer.
+ 2. Redistributions in binary form must reproduce the above copyright
+    notice, this list of conditions and the following disclaimer in the
+    documentation and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY Koine Yuusuke(koinec) ``AS IS'' AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL Koine Yuusuke(koinec) OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+OF THE POSSIBILITY OF SUCH DAMAGE.
+
+DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64*/
+
+/* File Info -----------------------------------------------------------
+File: drd64_.c
+Function: 
+Comment: 
+----------------------------------------------------------------------*/
+
+#define DRD64_SRC_LIBGOBLIN_CHECKBIN
+#include"drd64_libgoblin.h"
+
+
+LIBGOBLIN_CHECKBIN_EXTERN
+int
+       Drd64_LibGoblin_CheckBinary(
+               Drd64_LibGoblin_BinaryInfo      *p_bin )
+{
+       int                     i_result;
+       Byte            *p_data;
+       Elf_Ehdr        *p_elfhdr;
+
+       assert( NULL != p_bin );
+
+
+       p_data  = p_bin->p_binary;
+       assert( NULL != p_data );
+       
+       /* Judge Elf-Header? */
+       p_elfhdr        = (Elf_Ehdr *)p_data;
+       if( IS_ELF( *p_elfhdr ) )       {
+               p_bin->b_type   = DRD64_LIBGOBLIN_BINFO_TYPE_ELF;
+               i_result                = DRD64_LIBGOBLIN_BINFO_TYPE_ELF;
+       }
+       else {
+               p_bin->b_type   = DRD64_LIBGOBLIN_BINFO_TYPE_NONE;
+               i_result                = DRD64_LIBGOBLIN_BINFO_TYPE_NONE;
+       }
+
+       return i_result;
+}
+
+
+/* EOF of drd64_.c ----------------------------------- */
diff --git a/libgoblin/drd64_libgoblin_checkbin.h b/libgoblin/drd64_libgoblin_checkbin.h
new file mode 100644 (file)
index 0000000..13bd1f7
--- /dev/null
@@ -0,0 +1,57 @@
+/*DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64
+
+                         D r . D e a m o n  6 4
+                        for INTEL64(R), AMD64(R)
+       
+   Copyright(C) 2007-2009 Koine Yuusuke(koinec). All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+    this list of conditions and the following disclaimer.
+ 2. Redistributions in binary form must reproduce the above copyright
+    notice, this list of conditions and the following disclaimer in the
+    documentation and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY Koine Yuusuke(koinec) ``AS IS'' AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL Koine Yuusuke(koinec) OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+OF THE POSSIBILITY OF SUCH DAMAGE.
+
+DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64*/
+
+/* File Info -----------------------------------------------------------
+File: drd64_.h
+Function: Header 
+Comment: 
+----------------------------------------------------------------------*/
+
+#ifndef DRD64_HEADER_LIBGOBLIN_CHECKBIN
+#define DRD64_HEADER_LIBGOBLIN_CHECKBIN
+
+#include"drd64_libgoblin.h"
+
+#ifdef DRD64_SRC_LIBGOBLIN_CHECKBIN
+       #define LIBGOBLIN_CHECKBIN_EXTERN
+#else
+       #define LIBGOBLIN_CHECKBIN_EXTERN       extern
+#endif
+
+
+LIBGOBLIN_CHECKBIN_EXTERN
+       int
+               Drd64_LibGoblin_CheckBinary(
+                       Drd64_LibGoblin_BinaryInfo  *p_bin );
+
+
+#endif /* DRD64_HEADER_LIBGOBLIN_CHECKBIN */
+
+/* EOF of drd64_.h ----------------------------------- */
diff --git a/libgoblin/drd64_libgoblin_system.c b/libgoblin/drd64_libgoblin_system.c
new file mode 100644 (file)
index 0000000..9a8ac65
--- /dev/null
@@ -0,0 +1,73 @@
+/*DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64
+
+                         D r . D e a m o n  6 4
+                        for INTEL64(R), AMD64(R)
+       
+   Copyright(C) 2007-2009 Koine Yuusuke(koinec). All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+    this list of conditions and the following disclaimer.
+ 2. Redistributions in binary form must reproduce the above copyright
+    notice, this list of conditions and the following disclaimer in the
+    documentation and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY Koine Yuusuke(koinec) ``AS IS'' AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL Koine Yuusuke(koinec) OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+OF THE POSSIBILITY OF SUCH DAMAGE.
+
+DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64*/
+
+/* File Info -----------------------------------------------------------
+File: drd64_.c
+Function: 
+Comment: 
+----------------------------------------------------------------------*/
+
+#define DRD64_SRC_LIBGOBLIN_SYSTEM
+#include"drd64_libgoblin.h"
+
+
+/*----------------------------------------------------------------------
+----------------------------------------------------------------------*/
+LIBGOBLIN_FUNC
+int
+       Drd64_LibGoblin_Init(
+               void )
+{
+       int             i_err;
+
+       i_err   = Drd64_LibGoblin_InitBinaryInfo();
+       if( 0x00 != i_err )             { return i_err; }
+
+       return 0x00;
+}
+
+
+/*----------------------------------------------------------------------
+----------------------------------------------------------------------*/
+LIBGOBLIN_FUNC
+int
+       Drd64_LibGoblin_Term(
+               void )
+{
+       int             i_err;
+
+       i_err   = Drd64_LibGoblin_TermBinaryInfo();
+       if( 0x00 != i_err )             { return i_err; }
+
+       return 0x00;
+}
+
+
+/* EOF of drd64_.c ----------------------------------- */
diff --git a/libgoblin/elftest.c b/libgoblin/elftest.c
new file mode 100644 (file)
index 0000000..8aafa29
--- /dev/null
@@ -0,0 +1,45 @@
+
+
+#include<stdio.h>
+#include<stdlib.h>
+#include<fcntl.h>
+#include<unistd.h>
+#include<elf.h>
+#include<sys/stat.h>
+#include<sys/mman.h>
+#include"../include/libgoblin.h"
+
+
+/*=================================================================*/
+int
+       main(
+               int argc, 
+               char    *argv[] )
+{
+       int             i_err;
+       int             i_fd;
+       struct  stat    t_sb;
+       unsigned char   *p_head;
+
+       /* Open Test LM */
+       i_fd    = open( "test", O_RDONLY );
+       if( -1 == i_fd )        { return 0x01; }
+
+       i_err   = fstat( i_fd, &t_sb );
+       if( -1 == i_err )       { goto goto_main_err; }
+
+       p_head  = mmap( NULL, t_sb.st_size, PROT_READ, MAP_SHARED, i_fd, 0 );
+       if( MAP_FAILED == p_head )      { goto goto_main_err; }
+
+       Drd64_LibGoblin_AnalyzeBinary( p_head, t_sb.st_size );
+       
+       i_err   = munmap( p_head, t_sb.st_size );
+
+goto_main_err:
+       close( i_fd );
+
+       return 0x00;
+}
+
+/* EOF of elftest.c */
+