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

📄 kmdresource.cpp

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

//



typedef struct _IMAGE_RESOURCE_DIRECTORY_STRING {

    WORD    Length;

    CHAR    NameString[ 1 ];

} IMAGE_RESOURCE_DIRECTORY_STRING, *PIMAGE_RESOURCE_DIRECTORY_STRING;





typedef struct _IMAGE_RESOURCE_DIR_STRING_U {

    WORD    Length;

    WCHAR   NameString[ 1 ];

} IMAGE_RESOURCE_DIR_STRING_U, *PIMAGE_RESOURCE_DIR_STRING_U;





//

// Each resource data entry describes a leaf node in the resource directory

// tree.  It contains an offset, relative to the beginning of the resource

// directory of the data for the resource, a size field that gives the number

// of bytes of data at that offset, a CodePage that should be used when

// decoding code point values within the resource data.  Typically for new

// applications the code page would be the unicode code page.

//



typedef struct _IMAGE_RESOURCE_DATA_ENTRY {

    DWORD   OffsetToData;

    DWORD   Size;

    DWORD   CodePage;

    DWORD   Reserved;

} IMAGE_RESOURCE_DATA_ENTRY, *PIMAGE_RESOURCE_DATA_ENTRY;



//

// Load Configuration Directory Entry

//



typedef struct {

    DWORD   Characteristics;

    DWORD   TimeDateStamp;

    WORD    MajorVersion;

    WORD    MinorVersion;

    DWORD   GlobalFlagsClear;

    DWORD   GlobalFlagsSet;

    DWORD   CriticalSectionDefaultTimeout;

    DWORD   DeCommitFreeBlockThreshold;

    DWORD   DeCommitTotalFreeThreshold;

    DWORD   LockPrefixTable;            // VA

    DWORD   MaximumAllocationSize;

    DWORD   VirtualMemoryThreshold;

    DWORD   ProcessHeapFlags;

    DWORD   ProcessAffinityMask;

    WORD    CSDVersion;

    WORD    Reserved1;

    DWORD   EditList;                   // VA

    DWORD   Reserved[ 1 ];

} IMAGE_LOAD_CONFIG_DIRECTORY32, *PIMAGE_LOAD_CONFIG_DIRECTORY32;



typedef struct {

    DWORD   Characteristics;

    DWORD   TimeDateStamp;

    WORD    MajorVersion;

    WORD    MinorVersion;

    DWORD   GlobalFlagsClear;

    DWORD   GlobalFlagsSet;

    DWORD   CriticalSectionDefaultTimeout;

    DWORD   DeCommitFreeBlockThreshold;

    DWORD   DeCommitTotalFreeThreshold;

    ULONGLONG  LockPrefixTable;         // VA

    DWORD   MaximumAllocationSize;

    DWORD   VirtualMemoryThreshold;

    DWORD   ProcessHeapFlags;

    DWORD   ProcessAffinityMask;

    WORD    CSDVersion;

    WORD    Reserved1;

    ULONGLONG  EditList;                // VA

    DWORD   Reserved[ 1 ];

} IMAGE_LOAD_CONFIG_DIRECTORY64, *PIMAGE_LOAD_CONFIG_DIRECTORY64;



#ifdef _WIN64

typedef IMAGE_LOAD_CONFIG_DIRECTORY64   IMAGE_LOAD_CONFIG_DIRECTORY;

typedef PIMAGE_LOAD_CONFIG_DIRECTORY64  PIMAGE_LOAD_CONFIG_DIRECTORY;

#else

typedef IMAGE_LOAD_CONFIG_DIRECTORY32   IMAGE_LOAD_CONFIG_DIRECTORY;

typedef PIMAGE_LOAD_CONFIG_DIRECTORY32  PIMAGE_LOAD_CONFIG_DIRECTORY;

#endif



//

// Function table entry format for IA64 images.  Function table is

// pointed to by the IMAGE_DIRECTORY_ENTRY_EXCEPTION directory entry.

// This definition duplicates the one in ntia64.h for use by portable

// image file mungers.

//



typedef struct _IMAGE_IA64_RUNTIME_FUNCTION_ENTRY {

    DWORD BeginAddress;

    DWORD EndAddress;

    DWORD UnwindInfoAddress;

} IMAGE_IA64_RUNTIME_FUNCTION_ENTRY, *PIMAGE_IA64_RUNTIME_FUNCTION_ENTRY;



//

// Function table entry format for ALPHA images.  Function table is

// pointed to by the IMAGE_DIRECTORY_ENTRY_EXCEPTION directory entry.

// This definition duplicates ones in ntmips.h and ntalpha.h for use

// by portable image file mungers.

//



typedef struct _IMAGE_ALPHA_RUNTIME_FUNCTION_ENTRY {

    DWORD BeginAddress;

    DWORD EndAddress;

    DWORD ExceptionHandler;

    DWORD HandlerData;

    DWORD PrologEndAddress;

} IMAGE_ALPHA_RUNTIME_FUNCTION_ENTRY, *PIMAGE_ALPHA_RUNTIME_FUNCTION_ENTRY;



typedef struct _IMAGE_ALPHA64_RUNTIME_FUNCTION_ENTRY {

    ULONGLONG BeginAddress;

    ULONGLONG EndAddress;

    ULONGLONG ExceptionHandler;

    ULONGLONG HandlerData;

    ULONGLONG PrologEndAddress;

} IMAGE_ALPHA64_RUNTIME_FUNCTION_ENTRY, *PIMAGE_ALPHA64_RUNTIME_FUNCTION_ENTRY;



typedef  IMAGE_ALPHA64_RUNTIME_FUNCTION_ENTRY  IMAGE_AXP64_RUNTIME_FUNCTION_ENTRY;

typedef PIMAGE_ALPHA64_RUNTIME_FUNCTION_ENTRY PIMAGE_AXP64_RUNTIME_FUNCTION_ENTRY;



//

// WIN CE Exception table format

//



typedef struct _IMAGE_CE_RUNTIME_FUNCTION_ENTRY {

    DWORD FuncStart;

    DWORD PrologLen : 8;

    DWORD FuncLen : 22;

    DWORD ThirtyTwoBit : 1;

    DWORD ExceptionFlag : 1;

} IMAGE_CE_RUNTIME_FUNCTION_ENTRY, * PIMAGE_CE_RUNTIME_FUNCTION_ENTRY;



#if defined(_IA64_)



typedef  IMAGE_IA64_RUNTIME_FUNCTION_ENTRY  IMAGE_RUNTIME_FUNCTION_ENTRY;

typedef PIMAGE_IA64_RUNTIME_FUNCTION_ENTRY PIMAGE_RUNTIME_FUNCTION_ENTRY;



#elif defined(_AXP64_)



typedef  IMAGE_ALPHA64_RUNTIME_FUNCTION_ENTRY  IMAGE_RUNTIME_FUNCTION_ENTRY;

typedef PIMAGE_ALPHA64_RUNTIME_FUNCTION_ENTRY PIMAGE_RUNTIME_FUNCTION_ENTRY;



#else



typedef  IMAGE_ALPHA_RUNTIME_FUNCTION_ENTRY  IMAGE_RUNTIME_FUNCTION_ENTRY;

typedef PIMAGE_ALPHA_RUNTIME_FUNCTION_ENTRY PIMAGE_RUNTIME_FUNCTION_ENTRY;



#endif



//

// Debug Format

//



typedef struct _IMAGE_DEBUG_DIRECTORY {

    DWORD   Characteristics;

    DWORD   TimeDateStamp;

    WORD    MajorVersion;

    WORD    MinorVersion;

    DWORD   Type;

    DWORD   SizeOfData;

    DWORD   AddressOfRawData;

    DWORD   PointerToRawData;

} IMAGE_DEBUG_DIRECTORY, *PIMAGE_DEBUG_DIRECTORY;



#define IMAGE_DEBUG_TYPE_UNKNOWN          0

#define IMAGE_DEBUG_TYPE_COFF             1

#define IMAGE_DEBUG_TYPE_CODEVIEW         2

#define IMAGE_DEBUG_TYPE_FPO              3

#define IMAGE_DEBUG_TYPE_MISC             4

#define IMAGE_DEBUG_TYPE_EXCEPTION        5

#define IMAGE_DEBUG_TYPE_FIXUP            6

#define IMAGE_DEBUG_TYPE_OMAP_TO_SRC      7

#define IMAGE_DEBUG_TYPE_OMAP_FROM_SRC    8

#define IMAGE_DEBUG_TYPE_BORLAND          9

#define IMAGE_DEBUG_TYPE_RESERVED10       10

#define IMAGE_DEBUG_TYPE_CLSID            11





typedef struct _IMAGE_COFF_SYMBOLS_HEADER {

    DWORD   NumberOfSymbols;

    DWORD   LvaToFirstSymbol;

    DWORD   NumberOfLinenumbers;

    DWORD   LvaToFirstLinenumber;

    DWORD   RvaToFirstByteOfCode;

    DWORD   RvaToLastByteOfCode;

    DWORD   RvaToFirstByteOfData;

    DWORD   RvaToLastByteOfData;

} IMAGE_COFF_SYMBOLS_HEADER, *PIMAGE_COFF_SYMBOLS_HEADER;



#define FRAME_FPO       0

#define FRAME_TRAP      1

#define FRAME_TSS       2

#define FRAME_NONFPO    3



typedef struct _FPO_DATA {

    DWORD       ulOffStart;             // offset 1st byte of function code

    DWORD       cbProcSize;             // # bytes in function

    DWORD       cdwLocals;              // # bytes in locals/4

    WORD        cdwParams;              // # bytes in params/4

    WORD        cbProlog : 8;           // # bytes in prolog

    WORD        cbRegs   : 3;           // # regs saved

    WORD        fHasSEH  : 1;           // TRUE if SEH in func

    WORD        fUseBP   : 1;           // TRUE if EBP has been allocated

    WORD        reserved : 1;           // reserved for future use

    WORD        cbFrame  : 2;           // frame type

} FPO_DATA, *PFPO_DATA;

#define SIZEOF_RFPO_DATA 16





#define IMAGE_DEBUG_MISC_EXENAME    1



typedef struct _IMAGE_DEBUG_MISC {

    DWORD       DataType;               // type of misc data, see defines

    DWORD       Length;                 // total length of record, rounded to four

                                        // byte multiple.

    BOOLEAN     Unicode;                // TRUE if data is unicode string

    BYTE        Reserved[ 3 ];

    BYTE        Data[ 1 ];              // Actual data

} IMAGE_DEBUG_MISC, *PIMAGE_DEBUG_MISC;





//

// Function table extracted from MIPS/ALPHA/IA64 images.  Does not contain

// information needed only for runtime support.  Just those fields for

// each entry needed by a debugger.

//



typedef struct _IMAGE_FUNCTION_ENTRY {

    DWORD   StartingAddress;

    DWORD   EndingAddress;

    DWORD   EndOfPrologue;

} IMAGE_FUNCTION_ENTRY, *PIMAGE_FUNCTION_ENTRY;



typedef struct _IMAGE_FUNCTION_ENTRY64 {

    ULONGLONG   StartingAddress;

    ULONGLONG   EndingAddress;

    union {

        ULONGLONG   EndOfPrologue;

        ULONGLONG   UnwindInfoAddress;

    };

} IMAGE_FUNCTION_ENTRY64, *PIMAGE_FUNCTION_ENTRY64;



//

// Debugging information can be stripped from an image file and placed

// in a separate .DBG file, whose file name part is the same as the

// image file name part (e.g. symbols for CMD.EXE could be stripped

// and placed in CMD.DBG).  This is indicated by the IMAGE_FILE_DEBUG_STRIPPED

// flag in the Characteristics field of the file header.  The beginning of

// the .DBG file contains the following structure which captures certain

// information from the image file.  This allows a debug to proceed even if

// the original image file is not accessable.  This header is followed by

// zero of more IMAGE_SECTION_HEADER structures, followed by zero or more

// IMAGE_DEBUG_DIRECTORY structures.  The latter structures and those in

// the image file contain file offsets relative to the beginning of the

// .DBG file.

//

// If symbols have been stripped from an image, the IMAGE_DEBUG_MISC structure

// is left in the image file, but not mapped.  This allows a debugger to

// compute the name of the .DBG file, from the name of the image in the

// IMAGE_DEBUG_MISC structure.

//



typedef struct _IMAGE_SEPARATE_DEBUG_HEADER {

    WORD        Signature;

    WORD        Flags;

    WORD        Machine;

    WORD        Characteristics;

    DWORD       TimeDateStamp;

    DWORD       CheckSum;

    DWORD       ImageBase;

    DWORD       SizeOfImage;

    DWORD       NumberOfSections;

    DWORD       ExportedNamesSize;

    DWORD       DebugDirectorySize;

    DWORD       SectionAlignment;

    DWORD       Reserved[2];

} IMAGE_SEPARATE_DEBUG_HEADER, *PIMAGE_SEPARATE_DEBUG_HEADER;



#ifndef _MAC

#define IMAGE_SEPARATE_DEBUG_SIGNATURE 0x4944

#else

#define IMAGE_SEPARATE_DEBUG_SIGNATURE 0x4449

#endif



#define IMAGE_SEPARATE_DEBUG_FLAGS_MASK 0x8000

#define IMAGE_SEPARATE_DEBUG_MISMATCH   0x8000  // when DBG was updated, the

                                                // old checksum didn't match.



//

//  The .arch section is made up of headers, each describing an amask position/value

//  pointing to an array of IMAGE_ARCHITECTURE_ENTRY's.  Each "array" (both the header

//  and entry arrays) are terminiated by a quadword of 0xffffffffL.

//

//  NOTE: There may be quadwords of 0 sprinkled around a

⌨️ 快捷键说明

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