📄 osrcpp.h
字号:
///////////////////////////////////////////////////////////////////////////////
//
// (C) Copyright 1998 - 1999 OSR Open Systems Resources, Inc.
// All Rights Reserved
//
// This sofware is supplied for demonstration purposes only.
//
// OSR Open Systems Resources, Inc. (OSR) expressly disclaims any warranty
// for this software. THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY
// OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, WITHOUT LIMITATION,
// THE IMPLIED WARRANTIES OF MECHANTABILITY OR FITNESS FOR A PARTICULAR
// PURPOSE. THE ENTIRE RISK ARISING FROM THE USE OF THIS SOFTWARE REMAINS
// WITH YOU. OSR's entire liability and your exclusive remedy shall not
// exceed the price paid for this material. In no event shall OSR or its
// suppliers be liable for any damages whatsoever (including, without
// limitation, damages for loss of business profit, business interruption,
// loss of business information, or any other pecuniary loss) arising out
// of the use or inability to use this software, even if OSR has been
// advised of the possibility of such damages. Because some states/
// jurisdictions do not allow the exclusion or limitation of liability for
// consequential or incidental damages, the above limitation may not apply
// to you.
//
// OSR Open Systems Resources, Inc.
// 105 Route 101A Suite 19
// Amherst, NH 03031 (603) 595-6500 FAX: (603) 595-6503
// email bugs to: bugs@osr.com
//
//
// MODULE:
//
// $Workfile: osrcpp.h $
//
// ABSTRACT:
//
//
//
// AUTHOR:
//
// Open Systems Resources, Inc.
//
// REVISION:
//
// $Revision: 5 $
//
///////////////////////////////////////////////////////////////////////////////
#ifndef _OSR_CPP_RUNTIME_H
#define _OSR_CPP_RUNTIME_H
//
// add externally visible runtime constructs here
//
#ifdef __cplusplus
extern "C" {
#endif
#include <ntddk.h>
#ifdef __cplusplus
}
#endif
//
// memory allocation support
//
typedef unsigned int size_t;
#ifdef __cplusplus
void * __cdecl operator new(size_t size);
void * __cdecl operator new(size_t size, void *location);
void *__cdecl operator new( size_t size, ULONG tag, POOL_TYPE pool= NonPagedPool);
void __cdecl operator delete(void * pVoid);
#endif
PVOID __cdecl malloc(ULONG x, ULONG id= 'ppcO', POOL_TYPE pool = NonPagedPool);
void __cdecl free(PVOID x);
__inline PVOID __cdecl malloc(ULONG size, ULONG id, POOL_TYPE pool)
{
PVOID buffer = ExAllocatePoolWithTag(pool, size, id);
if (buffer) {
//
// clear our buffer to zero
//
RtlZeroMemory(buffer, size);
}
return buffer;
}
__inline void __cdecl free(PVOID buffer)
{
if (buffer != NULL) {
ExFreePool(buffer);
}
}
#ifdef __cplusplus
__inline void * __cdecl operator new(size_t size)
{
return malloc(size, 'ppcO', NonPagedPool);
}
__inline void * __cdecl operator new(size_t size, void *location)
{
return location;
}
__inline void *__cdecl operator new( size_t size, ULONG tag, POOL_TYPE pool)
{
return malloc(size, tag, pool);
}
__inline void __cdecl operator delete(void * pVoid)
{
free(pVoid);
}
#endif
//
// runtime linkage support:
//
//
// All you have to do to get C++ runtime support is
// replace *your* driver entry routine with this one, as in:
//
// CPP_DRIVER_ENTRY(PDRIVER_OBJECT DriverObject, PUNICODE_STRING RegistryPath)
//
// And link your driver with our OSR C++ runtime library!
//
#define CPP_DRIVER_ENTRY(Do, Rp) extern "C" NTSTATUS Cp_DriverEntry(Do, Rp)
//
// and finally, as this might be generally useful:
//
typedef void (__cdecl *PVFV)(void);
//
// this is the standard ANSI atexit function. You can register
// any arbitrary void function with no parameters through this interface.
//
// Registered functions will be called in LIFO order on termination.
//
// Termination is defined here as DriverUnload.
//
int __cdecl atexit (
PVFV func
);
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -