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

📄 logr0api.cpp

📁 这是一本学习 window编程的很好的参考教材
💻 CPP
字号:
/////////////////////////////////////////////////////////////////
// File: logR0api.c
//
// Implements "C" interface to Windows 95 LOGGER.VxD Ring0 service. 
//
// 04/01/98 VV

//#ifdef VTOOLSD
 #include <vtoolsc.h>   // if VtoolsD is used

/*#else
 #include <basedef.h>   // if straight DDK95 is used
 #include <vmm.h>		
 #include <vxdwraps.h>	
#endif
 */
#include    "logR0api.h"            // logger.vxd "C" prototypes
//#include    <vxdldr.h>              // Win95 Ring0 load service

// Logger Vxd DeviceID
#define LOGR0_DeviceID     0x049D            
#define LOGR0_DEVICE_ID LOGR0_DeviceID

#define LOGR0_Service    Declare_Service

// The Ring 0 Service Table for the Logger Vxd.
#pragma warning (disable:4003)  // turn off "parameters" warning
Begin_Service_Table(LOGR0)
    LOGR0_Service(LOGR0_Svc_GetVersion)
    LOGR0_Service(LOGR0_Svc_PrintLog)
    LOGR0_Service(LOGR0_Svc_CloseLog)
    LOGR0_Service(LOGR0_Svc_OpenLog)
    LOGR0_Service(LOGR0_Svc_FlushLog)
End_Service_Table(LOGR0)
#pragma warning (default:4003)  // restore  warning

/////////////////////////////////////////////////////////////////
// LoadVxd()    Internal function used to load the vxd in memory
// =========    Uses VMM vxd loader services.
static BOOL LoadVxd(const char* szVxdFile)
{

    _asm    mov edx, szVxdFile
    _asm    mov eax, VXDLDR_INIT_DEVICE
    VxDCall (VXDLDR_LoadDevice); 
    _asm    jnc  done
    return  FALSE;  // problem: file not found?
done:
    return TRUE;   

    return TRUE; 

}

#pragma warning (disable:4035)   // turn off no return code warning

/////////////////////////////////////////////////////////////////
// LOGR0_GetVersion()  Retrieve the version of LOGGER.VXD. It also
// ===================  tries to load the vxd if it's not resident.
// Input:
//      none
// Returns:     
//      Version Number (currently, 1) or NULL on failure.
// Note:
//      If NULL is returned LOGR0_ services shouldn't be called as 
//      it would result in an "unresolved link" blue screen.
DWORD _cdecl LOGR0_GetVersion()
{
    // Have to save the last result since Ring 0 GetVersion
    // call gets patched to STC whenever it fails.
    static DWORD ver = 0;
    if (ver==0) {
        VxDCall (LOGR0_Svc_GetVersion);
        _asm    jnc     loaded
        LoadVxd("LOGGER.VxD"); 
        VxDCall (LOGR0_Svc_GetVersion);
        _asm    jc     done
loaded:
        _asm    mov ver, eax
    }
done:
    return  ver;
}

/////////////////////////////////////////////////////////////////
// LOGR0_OpenFile()    Open log file for writing.
// =================
// Input:
//      szLogFileName   File Name in ASCII. 
//      BufSize            History byffer size. NULL selects default, 4kb.    
// Returns:
//      File handle or NULL if failed.
// Notes:
//      The file is created in Windows directory unless the full
//      path is specified. The file remains locked until 
//      LOGR0_CloseFile is called.
__declspec(naked)
HANDLE _cdecl LOGR0_OpenFile(const char* szFileName, DWORD BufSize)
{
    VxDJmp (LOGR0_Svc_OpenLog);
}

/////////////////////////////////////////////////////////////////
// LOGR0_CloseFile()   Close the log file.
// ==================
// Input:
//      hFile           Handle returned by LOGR0_OpenFile
// Returns:
//      TRUE on success
__declspec(naked)
BOOL  _cdecl  LOGR0_CloseFile(HANDLE hFile)
{
    VxDJmp (LOGR0_Svc_CloseLog);
}

/////////////////////////////////////////////////////////////////
// LOGR0_Printf()  Write a printf-style message into the log file
// ================
// Input:
//      hFile       Handle returned by LOGR0_OpenFile
//      format      printf-style string followed by arguments    
// Returns:
//      none
__declspec(naked)
void _cdecl LOGR0_Printf(HANDLE hFile, const char* format,...)
{
    VxDJmp  (LOGR0_Svc_PrintLog);
}

/////////////////////////////////////////////////////////////////
// LOGR0_Flush()       Flushes the cached data to the file
// Input:
//      hFile       Handle returned by LOGR0_OpenFile
// Returns:
//      none
__declspec(naked)
DWORD _cdecl LOGR0_Flush(HANDLE hFile)
{
    VxDJmp (LOGR0_Svc_FlushLog);
}

#pragma warning (default:4035)   // restore no return code warning

// end of file



⌨️ 快捷键说明

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