⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 kmdresource.cpp

📁 Programming the Microsoft Windows driver model.2nd 随书光盘。内有很多作者送的实用工具和随书源码。WDM编程
💻 CPP
📖 第 1 页 / 共 5 页
字号:
#define IMAGE_SYM_CLASS_STATIC              0x0003

#define IMAGE_SYM_CLASS_REGISTER            0x0004

#define IMAGE_SYM_CLASS_EXTERNAL_DEF        0x0005

#define IMAGE_SYM_CLASS_LABEL               0x0006

#define IMAGE_SYM_CLASS_UNDEFINED_LABEL     0x0007

#define IMAGE_SYM_CLASS_MEMBER_OF_STRUCT    0x0008

#define IMAGE_SYM_CLASS_ARGUMENT            0x0009

#define IMAGE_SYM_CLASS_STRUCT_TAG          0x000A

#define IMAGE_SYM_CLASS_MEMBER_OF_UNION     0x000B

#define IMAGE_SYM_CLASS_UNION_TAG           0x000C

#define IMAGE_SYM_CLASS_TYPE_DEFINITION     0x000D

#define IMAGE_SYM_CLASS_UNDEFINED_STATIC    0x000E

#define IMAGE_SYM_CLASS_ENUM_TAG            0x000F

#define IMAGE_SYM_CLASS_MEMBER_OF_ENUM      0x0010

#define IMAGE_SYM_CLASS_REGISTER_PARAM      0x0011

#define IMAGE_SYM_CLASS_BIT_FIELD           0x0012



#define IMAGE_SYM_CLASS_FAR_EXTERNAL        0x0044  //



#define IMAGE_SYM_CLASS_BLOCK               0x0064

#define IMAGE_SYM_CLASS_FUNCTION            0x0065

#define IMAGE_SYM_CLASS_END_OF_STRUCT       0x0066

#define IMAGE_SYM_CLASS_FILE                0x0067

// new

#define IMAGE_SYM_CLASS_SECTION             0x0068

#define IMAGE_SYM_CLASS_WEAK_EXTERNAL       0x0069



// type packing constants



#define N_BTMASK                            0x000F

#define N_TMASK                             0x0030

#define N_TMASK1                            0x00C0

#define N_TMASK2                            0x00F0

#define N_BTSHFT                            4

#define N_TSHIFT                            2

// MACROS



// Basic Type of  x

#define BTYPE(x) ((x) & N_BTMASK)



// Is x a pointer?

#ifndef ISPTR

#define ISPTR(x) (((x) & N_TMASK) == (IMAGE_SYM_DTYPE_POINTER << N_BTSHFT))

#endif



// Is x a function?

#ifndef ISFCN

#define ISFCN(x) (((x) & N_TMASK) == (IMAGE_SYM_DTYPE_FUNCTION << N_BTSHFT))

#endif



// Is x an array?



#ifndef ISARY

#define ISARY(x) (((x) & N_TMASK) == (IMAGE_SYM_DTYPE_ARRAY << N_BTSHFT))

#endif



// Is x a structure, union, or enumeration TAG?

#ifndef ISTAG

#define ISTAG(x) ((x)==IMAGE_SYM_CLASS_STRUCT_TAG || (x)==IMAGE_SYM_CLASS_UNION_TAG || (x)==IMAGE_SYM_CLASS_ENUM_TAG)

#endif



#ifndef INCREF

#define INCREF(x) ((((x)&~N_BTMASK)<<N_TSHIFT)|(IMAGE_SYM_DTYPE_POINTER<<N_BTSHFT)|((x)&N_BTMASK))

#endif

#ifndef DECREF

#define DECREF(x) ((((x)>>N_TSHIFT)&~N_BTMASK)|((x)&N_BTMASK))

#endif



//

// Auxiliary entry format.

//



typedef union _IMAGE_AUX_SYMBOL {

    struct {

        DWORD    TagIndex;                      // struct, union, or enum tag index

        union {

            struct {

                WORD    Linenumber;             // declaration line number

                WORD    Size;                   // size of struct, union, or enum

            } LnSz;

           DWORD    TotalSize;

        } Misc;

        union {

            struct {                            // if ISFCN, tag, or .bb

                DWORD    PointerToLinenumber;

                DWORD    PointerToNextFunction;

            } Function;

            struct {                            // if ISARY, up to 4 dimen.

                WORD     Dimension[4];

            } Array;

        } FcnAry;

        WORD    TvIndex;                        // tv index

    } Sym;

    struct {

        BYTE    Name[IMAGE_SIZEOF_SYMBOL];

    } File;

    struct {

        DWORD   Length;                         // section length

        WORD    NumberOfRelocations;            // number of relocation entries

        WORD    NumberOfLinenumbers;            // number of line numbers

        DWORD   CheckSum;                       // checksum for communal

        SHORT   Number;                         // section number to associate with

        BYTE    Selection;                      // communal selection type

    } Section;

} IMAGE_AUX_SYMBOL;

typedef IMAGE_AUX_SYMBOL UNALIGNED *PIMAGE_AUX_SYMBOL;



#define IMAGE_SIZEOF_AUX_SYMBOL             18



//

// Communal selection types.

//



#define IMAGE_COMDAT_SELECT_NODUPLICATES    1

#define IMAGE_COMDAT_SELECT_ANY             2

#define IMAGE_COMDAT_SELECT_SAME_SIZE       3

#define IMAGE_COMDAT_SELECT_EXACT_MATCH     4

#define IMAGE_COMDAT_SELECT_ASSOCIATIVE     5

#define IMAGE_COMDAT_SELECT_LARGEST         6

#define IMAGE_COMDAT_SELECT_NEWEST          7



#define IMAGE_WEAK_EXTERN_SEARCH_NOLIBRARY  1

#define IMAGE_WEAK_EXTERN_SEARCH_LIBRARY    2

#define IMAGE_WEAK_EXTERN_SEARCH_ALIAS      3



//

// Relocation format.

//



typedef struct _IMAGE_RELOCATION {

    union {

        DWORD   VirtualAddress;

        DWORD   RelocCount;             // Set to the real count when IMAGE_SCN_LNK_NRELOC_OVFL is set

    };

    DWORD   SymbolTableIndex;

    WORD    Type;

} IMAGE_RELOCATION;

typedef IMAGE_RELOCATION UNALIGNED *PIMAGE_RELOCATION;



#define IMAGE_SIZEOF_RELOCATION         10



//

// I386 relocation types.

//

#define IMAGE_REL_I386_ABSOLUTE         0x0000  // Reference is absolute, no relocation is necessary

#define IMAGE_REL_I386_DIR16            0x0001  // Direct 16-bit reference to the symbols virtual address

#define IMAGE_REL_I386_REL16            0x0002  // PC-relative 16-bit reference to the symbols virtual address

#define IMAGE_REL_I386_DIR32            0x0006  // Direct 32-bit reference to the symbols virtual address

#define IMAGE_REL_I386_DIR32NB          0x0007  // Direct 32-bit reference to the symbols virtual address, base not included

#define IMAGE_REL_I386_SEG12            0x0009  // Direct 16-bit reference to the segment-selector bits of a 32-bit virtual address

#define IMAGE_REL_I386_SECTION          0x000A

#define IMAGE_REL_I386_SECREL           0x000B

#define IMAGE_REL_I386_REL32            0x0014  // PC-relative 32-bit reference to the symbols virtual address



//

// MIPS relocation types.

//



#define IMAGE_REL_MIPS_ABSOLUTE         0x0000  // Reference is absolute, no relocation is necessary

#define IMAGE_REL_MIPS_REFHALF          0x0001

#define IMAGE_REL_MIPS_REFWORD          0x0002

#define IMAGE_REL_MIPS_JMPADDR          0x0003

#define IMAGE_REL_MIPS_REFHI            0x0004

#define IMAGE_REL_MIPS_REFLO            0x0005

#define IMAGE_REL_MIPS_GPREL            0x0006

#define IMAGE_REL_MIPS_LITERAL          0x0007

#define IMAGE_REL_MIPS_SECTION          0x000A

#define IMAGE_REL_MIPS_SECREL           0x000B

#define IMAGE_REL_MIPS_SECRELLO         0x000C  // Low 16-bit section relative referemce (used for >32k TLS)

#define IMAGE_REL_MIPS_SECRELHI         0x000D  // High 16-bit section relative reference (used for >32k TLS)

#define IMAGE_REL_MIPS_JMPADDR16        0x0010

#define IMAGE_REL_MIPS_REFWORDNB        0x0022

#define IMAGE_REL_MIPS_PAIR             0x0025



//

// Alpha Relocation types.

//



#define IMAGE_REL_ALPHA_ABSOLUTE        0x0000

#define IMAGE_REL_ALPHA_REFLONG         0x0001

#define IMAGE_REL_ALPHA_REFQUAD         0x0002

#define IMAGE_REL_ALPHA_GPREL32         0x0003

#define IMAGE_REL_ALPHA_LITERAL         0x0004

#define IMAGE_REL_ALPHA_LITUSE          0x0005

#define IMAGE_REL_ALPHA_GPDISP          0x0006

#define IMAGE_REL_ALPHA_BRADDR          0x0007

#define IMAGE_REL_ALPHA_HINT            0x0008

#define IMAGE_REL_ALPHA_INLINE_REFLONG  0x0009

#define IMAGE_REL_ALPHA_REFHI           0x000A

#define IMAGE_REL_ALPHA_REFLO           0x000B

#define IMAGE_REL_ALPHA_PAIR            0x000C

#define IMAGE_REL_ALPHA_MATCH           0x000D

#define IMAGE_REL_ALPHA_SECTION         0x000E

#define IMAGE_REL_ALPHA_SECREL          0x000F

#define IMAGE_REL_ALPHA_REFLONGNB       0x0010

#define IMAGE_REL_ALPHA_SECRELLO        0x0011  // Low 16-bit section relative reference

#define IMAGE_REL_ALPHA_SECRELHI        0x0012  // High 16-bit section relative reference

#define IMAGE_REL_ALPHA_REFQ3           0x0013  // High 16 bits of 48 bit reference

#define IMAGE_REL_ALPHA_REFQ2           0x0014  // Middle 16 bits of 48 bit reference

#define IMAGE_REL_ALPHA_REFQ1           0x0015  // Low 16 bits of 48 bit reference

#define IMAGE_REL_ALPHA_GPRELLO         0x0016  // Low 16-bit GP relative reference

#define IMAGE_REL_ALPHA_GPRELHI         0x0017  // High 16-bit GP relative reference





//

// IBM PowerPC relocation types.

//



#define IMAGE_REL_PPC_ABSOLUTE          0x0000  // NOP

#define IMAGE_REL_PPC_ADDR64            0x0001  // 64-bit address

#define IMAGE_REL_PPC_ADDR32            0x0002  // 32-bit address

#define IMAGE_REL_PPC_ADDR24            0x0003  // 26-bit address, shifted left 2 (branch absolute)

#define IMAGE_REL_PPC_ADDR16            0x0004  // 16-bit address

#define IMAGE_REL_PPC_ADDR14            0x0005  // 16-bit address, shifted left 2 (load doubleword)

#define IMAGE_REL_PPC_REL24             0x0006  // 26-bit PC-relative offset, shifted left 2 (branch relative)

#define IMAGE_REL_PPC_REL14             0x0007  // 16-bit PC-relative offset, shifted left 2 (br cond relative)

#define IMAGE_REL_PPC_TOCREL16          0x0008  // 16-bit offset from TOC base

#define IMAGE_REL_PPC_TOCREL14          0x0009  // 16-bit offset from TOC base, shifted left 2 (load doubleword)



#define IMAGE_REL_PPC_ADDR32NB          0x000A  // 32-bit addr w/o image base

#define IMAGE_REL_PPC_SECREL            0x000B  // va of containing section (as in an image sectionhdr)

#define IMAGE_REL_PPC_SECTION           0x000C  // sectionheader number

#define IMAGE_REL_PPC_IFGLUE            0x000D  // substitute TOC restore instruction iff symbol is glue code

#define IMAGE_REL_PPC_IMGLUE            0x000E  // symbol is glue code; virtual address is TOC restore instruction

#define IMAGE_REL_PPC_SECREL16          0x000F  // va of containing section (limited to 16 bits)

#define IMAGE_REL_PPC_REFHI             0x0010

#define IMAGE_REL_PPC_REFLO             0x0011

#define IMAGE_REL_PPC_PAIR              0x0012

#define IMAGE_REL_PPC_SECRELLO          0x0013  // Low 16-bit section relative reference (used for >32k TLS)

#define IMAGE_REL_PPC_SECRELHI          0x0014  // High 16-bit section relative reference (used for >32k TLS)

#define IMAGE_REL_PPC_GPREL             0x0015



#define IMAGE_REL_PPC_TYPEMASK          0x00FF  // mask to isolate above values in IMAGE_RELOCATION.Type



// Flag bits in IMAGE_RELOCATION.TYPE



#define IMAGE_REL_PPC_NEG               0x0100  // subtract reloc value rather than adding it

#define IMAGE_REL_PPC_BRTAKEN           0x0200  // fix branch prediction bit to predict branch taken

#define IMAGE_REL_PPC_BRNTAKEN          0x0400  // fix branch prediction bit to predict branch not taken

#define IMAGE_REL_PPC_TOCDEFN           0x0800  // toc slot defined in file (or, data in toc)



//

// Hitachi SH3 relocation types.

//

#define IMAGE_REL_SH3_ABSOLUTE          0x0000  // No relocation

#define IMAGE_REL_SH3_DIRECT16          0x0001  // 16 bit direct

#define IMAGE_REL_SH3_DIRECT32          0x0002  // 32 bit direct

#define IMAGE_REL_SH3_DIRECT8           0x0003  // 8 bit direct, -128..255

#define IMAGE_REL_SH3_DIRECT8_WORD      0x0004  // 8 bit direct .W (0 ext.)

#define IMAGE_REL_SH3_DIRECT8_LONG      0x0005  // 8 bit direct .L (0 ext.)

#define IMAGE_REL_SH3_DIRECT4           0x0006  // 4 bit direct (0 ext.)

#define IMAGE_REL_SH3_DIRECT4_WORD      0x0007  // 4 bit direct .W (0 ext.)

#define IMAGE_REL_SH3_DIRECT4_LONG      0x0008  // 4 bit direct .L (0 ext.)

#define IMAGE_REL_SH3_PCREL8_WORD       0x0009  // 8 bit PC relative .W

#define IMAGE_REL_SH3_PCREL8_LONG       0x000A  // 8 bit PC relative .L

#define IMAGE_REL_SH3_PCREL12_WORD      0x000B  // 12 LSB PC relative .W

#define IMAGE_REL_SH3_STARTOF_SECTION   0x000C  // Start of EXE section

#define IMAGE_REL_SH3_SIZEOF_SECTION    0x000D  // Size of EXE section

#define IMAGE_REL_SH3_SECTION           0x000E  // Section table index

#define IMAGE_REL_SH3_SECREL            0x000F  // Offset within section

#define IMAGE_REL_SH3_DIRECT32_NB       0x0010  // 32 bit direct not based



#define IMAGE_REL_ARM_ABSOLUTE          0x0000  // No relocation required

#define IMAGE_REL_ARM_ADDR32            0x0001  // 32 bit address

#define IMAGE_REL_ARM_ADDR32NB          0x0002  // 32 bit address w/o image base

#define IMAGE_REL_ARM_BRANCH24          0x0003  // 24 bit offset << 2 & sign ext.

#define IMAGE_REL_ARM_BRANCH11          0x0004  // Thumb: 2 11 bit offsets

#define IMAGE_REL_ARM_GPREL12           0x0006  // GP-relative addressing (ARM)

#define IMAGE_REL_ARM_GPREL7            0x0007  // GP-relative addressing (Thumb)

#define IMAGE_REL_ARM_SECTION           0x000E  // Section table index

#define IMAGE_REL_ARM_SECREL            0x000F  // Offset within section



//

// IA64 relocation types.

//



#define IMAGE_REL_IA64_ABSOLUTE         0x0000

#define IMAGE_REL_IA64_IMM14            0x0001

#define IMAGE_REL_IA64_IMM22            0x0002

#define IMAGE_REL_IA64_IMM64            0x0003

#define IMAGE_REL_IA64_DIR32            0x0004

#define IMAGE_REL_IA64_DIR64            0x0005

#define IMAGE_REL_IA64_PCREL21B         0x0006

#define IMAGE_REL_IA64_PCREL21M         0x0007

#define IMAGE_REL_IA64_PCREL21F         0x0008

#define IMAGE_REL_IA64_GPREL22          0x0009

#define IMAGE_REL_IA64_LTOFF22          0x000A

#define IMAGE_REL_IA64_SECTION          0x000B

#define IMAGE_REL_IA64_SECREL22         0x000C

#define IMAGE_REL_IA64_SECREL64I        0x000D

#define IMAGE_REL_IA64_SECREL32         0x000E

#define IMAGE_REL_IA64_LTOFF64          0x000F

#define IMAGE_REL_IA64_DIR32NB          0x0010

#define IMAGE_REL_IA64_SREL22           0x0011

#define IMAGE_REL_IA64_UREL22           0x0012

#define IMAGE_REL_IA64_SREL32           0x0013

#define IMAGE_REL_IA64_UREL32           0x0014

#define IMAGE_REL_IA64_ADDEND           0x001F



//

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -