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

📄 vxdlib.h

📁 自动生成虚拟设备驱动(VXD)的C++代码的一个库 COOL!
💻 H
📖 第 1 页 / 共 2 页
字号:
#define R3_AltES pRegs->CRS.Client_Alt_ES
#define R3_AltFS pRegs->CRS.Client_Alt_FS
#define R3_AltGS pRegs->CRS.Client_Alt_GS
#define R3_AltSS pRegs->CRS.Client_Alt_SS


//===================================================================
// Macro to support naked callback function
//===================================================================
// Since MSVC++ inline assembler does not permit the use of __LOCAL_SIZE
// symbol in expression, the following prolog/epilog has become slightly
// more lengthy and complicated.

#define NAKED  __declspec ( naked )

#define ENTER                            \
          DECLARE_PREGS; { __asm {       \
          __asm  push ebp                \
          __asm  mov  ebp, esp           \
          __asm  pushfd                  \
          __asm  sub  esp, __LOCAL_SIZE  \
          __asm  lea  esp, [esp-8]       \
          __asm  push dword ptr [ebp-4]  \
          __asm  pop dword ptr [esp]     \
          __asm  pushad                  \
          __asm  mov  [_pregs], esp      \
          __asm  mov  eax, [ebp]         \
          __asm  mov  [esp+8],  eax      }}


#define LEAVE { __asm {                   \
          __asm  push dword ptr [esp+32]  \
          __asm  pop  dword ptr [ebp]     \
          __asm  popad                    \
          __asm  popfd                    \
          __asm  add esp, __LOCAL_SIZE    \
          __asm  lea esp, [esp+8]         \
          __asm  popfd                    }}


#define RETURN  {     \
          LEAVE       \
          __asm   ret }


#define CALL_SERVICE(Service) { __asm { \
          __asm   mov [esp+36], ebp     \
          __asm   popad                 \
          __asm   popfd                 \
          __asm   call Service          \
          __asm   pushfd                \
          __asm   pushad                \
          __asm   mov ebp, [esp+36]     }}


#define JUMP_SERVICE(Service) {   \
          LEAVE                   \
          __asm  jmp Service      }

//===================================================================
// Macros for hooking and unhooking VxD services 
//===================================================================

#define HOOK_DEVICE_SERVICE(Service,pHookFunc,pppSrvFunc)  \
      Hook_Device_Service( VXDSRVORD(Service),(PFNVOID)pHookFunc,(PPFNVOID)pppSrvFunc)

#define UNHOOK_DEVICE_SERVICE(Service,ppSrvFunc)  \
      Unhook_Device_Service( VXDSRVORD(Service),(PFNVOID)ppSrvFunc)

//===================================================================
// Macros for calling VxD services and interrupts
//===================================================================

#define RVXDCALL(Service)   RVxDCall( VXDSRVORD( Service), &_regs, &_regs)

#define CVXDCALL(Service,Parameters)  CVxDCall( VXDSRVORD( Service),Parameters)

#define CVXDCALL1(Service)  CVxDCall( VXDSRVORD( Service))
#define CVXDCALL2(Service,p1)  CVxDCall( VXDSRVORD( Service),p1)
#define CVXDCALL3(Service,p1,p2)  CVxDCall( VXDSRVORD( Service),p1,p2)
#define CVXDCALL4(Service,p1,p2,p3)  CVxDCall( VXDSRVORD( Service),p1,p2,p3)
#define CVXDCALL5(Service,p1,p2,p3,p4)  CVxDCall( VXDSRVORD( Service),p1,p2,p3,p4)
#define CVXDCALL6(Service,p1,p2,p3,p4,p5)  CVxDCall( VXDSRVORD( Service),p1,p2,p3,p4,p5)
#define CVXDCALL7(Service,p1,p2,p3,p4,p5,p6)  CVxDCall( VXDSRVORD( Service),p1,p2,p3,p4,p5,p6)
#define CVXDCALL8(Service,p1,p2,p3,p4,p5,p6,p7)  CVxDCall( VXDSRVORD( Service),p1,p2,p3,p4,p5,p6,p7)
#define CVXDCALL9(Service,p1,p2,p3,p4,p5,p6,p7,p8)  CVxDCall( VXDSRVORD( Service),p1,p2,p3,p4,p5,p6,p7,p8)
#define CVXDCALL10(Service,p1,p2,p3,p4,p5,p6,p7,p8,p9)  CVxDCall( VXDSRVORD( Service),p1,p2,p3,p4,p5,p6,p7,p8,p9)
#define CVXDCALL11(Service,p1,p2,p3,p4,p5,p6,p7,p8,p9,p10)  CVxDCall( VXDSRVORD( Service),p1,p2,p3,p4,p5,p6,p7,p8,p9,p10)
#define CVXDCALL12(Service,p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11)  CVxDCall( VXDSRVORD( Service),p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11)

#define INTV86(Interruptno) IntV86( Interruptno, &_regs, &_regs)
#define INTVXD(Interruptno) IntVxD( Interruptno, &_regs, &_regs)
#define INTPM16(Interruptno) IntPM16( Interruptno, &_regs, &_regs)
#define INTPM32(Interruptno) IntPM32( Interruptno, &_regs, &_regs)

typedef struct _TIME
{
    BYTE  Sec;          // Second (0-59)
    BYTE  Min;          // Minute (0-59)
    BYTE  Hr;           // Hour (0-23)
    BYTE  wDay;         // Day of the week (0-Sun, 1-Mon, . . .)
    BYTE  mDay;         // Day of the month (1-31)
    BYTE  Month;        // Month (0-11)
    WORD  Year;         // Year (1997,. . .)

} TIME, *PTIME;

#define SEEK_SET   0
#define SEEK_CUR   1
#define SEEK_END   2

#define CONTEXT_GLOBAL          0           ; open file in global context
#define CONTEXT_CURRENT         0x80000000  ; open file in current thread context

#define MB_MODELESS 0x80000000

#undef assert
#if defined(DEBUG) || defined(_DEBUG)
#   define assert(x) ((void)((x) || (DoAssert(#x,__FILE__,__LINE__),1)))
#else
#   define assert(ignore) ((void)0)
#endif
void __cdecl DoAssert (char *msg, char *file, DWORD line);

typedef int __stdcall CONTROL_PROC (DECLARE_PREGS);
typedef int __stdcall API_PROC (CLIENT_STRUCT *pClientReg);

int __cdecl CVxDCall (int VxDSrvOrd, ...);
int __stdcall RVxDCall (int VxDSrvOrd, REGS *inregs, REGS *outregs);
int __stdcall IntV86 (int interruptno, REGS *inregs, REGS *outregs);
int __stdcall IntVxD (int interruptno, REGS *inregs, REGS *outregs);
int __stdcall IntPM16 (int interruptno, REGS *inregs, REGS *outregs);
int __stdcall IntPM32 (int interruptno, REGS *inregs, REGS *outregs);

BOOL __stdcall Hook_Device_Service (int ServiceOrd, PFNVOID pHoohFunc, PFNVOID *ppSrvFunc);
BOOL __stdcall Unhook_Device_Service (int ServiceOrd, PFNVOID pSrvFunc);

void* __stdcall malloc (size_t nbytes);
void __stdcall  free (void *memblock);
void* __stdcall realloc (void *memblock, size_t size);
void* __stdcall calloc (size_t num, size_t size);
#define _msize(Ptr) ((*((DWORD *)Ptr-1) & 0x00ffffff) * 8 - 4)

TIME* __stdcall GetTime (void);
char* __stdcall GetTimeStr (void);

int __stdcall  MessageBox (HWND hWnd, char *pMsg, char *pTitle, DWORD dwMBFlag);
int __stdcall BlueMsgBox (char *pMsg, char *pTitle, DWORD dwMBFlag);
void __stdcall WarBell (void);
UINT __stdcall WinExec (char *pCmdLind, UINT uCmdShow);
int __stdcall GetCurAppName (DWORD ir_pid, char *pAppName);

int __cdecl sprintf (char* format, ...);

size_t __cdecl strlen (const char *str);
char* __cdecl strchr (const char *str, int ch);
char* __cdecl strrchr (const char *str, int ch);

int __cdecl strnicmp (const char *str1, const char *str2, size_t len);
int __cdecl stricmp (const char *str1, const char *str2);

int __cdecl strncmp (const char *str1, const char *str2, size_t len);
int __cdecl strcmp (const char *str1, const char *str2);

char* __cdecl strcpy (char *dest, const char *src);
char* __cdecl strncpy (char *dest, const char *src, size_t len);

char* __cdecl strcat (char *dest, const char *src);
char* __cdecl strncat (char *dest, const char *src, size_t count);

char* __cdecl strstr (const char *str1, const char * str2);

void* __cdecl memcpy (void *dest, const void *src, size_t len);
void* __cdecl memmove (void *dest, const void *src, size_t len);
int __cdecl memcmp (const void *dest, const void *src, size_t len);
void* __cdecl memchr (const void *dest, int ch, size_t len);
void* __cdecl memset (void *dest, int c, size_t count);

WORD __cdecl rand ();
void __cdecl srand (DWORD seed);
void __cdecl randomize ();

int __cdecl GetFileAttr (const char *pFileName);
int __cdecl SetFileAttr (const char *pFileName, WORD attr);

int __cdecl remove (const char *pFileName);
int __cdecl rename (const char *pSrcFile, const char *pDesFile);

int __cdecl mkdir (const char* pDirPath);
int __cdecl rmdir (const char* pDirPath);

int __cdecl creat (const char *pFileName, int mode);
int __cdecl open (const char *pFileName, int mode, int oflag);
int __cdecl close (int filehandle);

int __cdecl read (int filehandle, void *pBuff, DWORD len);
int __cdecl write (int filehandle, const void *pBuff, DWORD len);
long __cdecl lseek(int handle, long offset, int fromwhere);
DWORD __cdecl _fsize (int handle);

#ifdef IFS_INC          // If IFS.H is included
DWORD __stdcall FindFirstFile (const char* pFileName, _WIN32_FIND_DATA* pFindData);
DWORD __stdcall FindNextFile (DWORD hFindFirst, _WIN32_FIND_DATA* pFindData);
DWORD __stdcall FindCloseFile (DWORD hFindFirst);
#endif

typedef int (__cdecl * new_handler) (size_t size);  
new_handler __cdecl set_new_handler (new_handler handler);

#pragma pack()

#ifdef __cplusplus
}
#endif


#ifdef __cplusplus      // Include C++ specific declarations

PVOID operator new (size_t size);             // allocate memory from private heap
PVOID operator new (size_t size, PVOID ptr);  // equv. to realloc

PVOID operator new (size_t size, DWORD dwHeapType); // allocate memory from system heap
PVOID operator new (size_t size, DWORD dwHeapType, PVOID ptr); // equv. to realloc

void operator delete (PVOID ptr);   // free heap allocated by both type of memory

#endif   // __cplusplus

#endif

⌨️ 快捷键说明

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