From 2acec63b2ed75bf4b71ad257db573c4b8f9639e7 Mon Sep 17 00:00:00 2001 From: tumagonx Date: Tue, 8 Aug 2017 10:54:53 +0700 Subject: initial commit --- misc.h | 101 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100644 misc.h (limited to 'misc.h') diff --git a/misc.h b/misc.h new file mode 100644 index 0000000..e49e28d --- /dev/null +++ b/misc.h @@ -0,0 +1,101 @@ +/* + * Copyright (c) 2004 Security Architects Corporation. All rights reserved. + * + * Module Name: + * + * misc.h + * + * Abstract: + * + * This module definies various types used by miscellaneous routines. + * + * Author: + * + * Eugene Tsyrklevich 23-Feb-2004 + * + * Revision History: + * + * None. + */ + + +#ifndef __MISC_H__ +#define __MISC_H__ + + +#include +#include "pathproc.h" +#include "log.h" + + +// win2k ddk does not know about ExFreePoolWithTag? +/* +#ifndef ExFreePoolWithTag +#define ExFreePoolWithTag(p, tag) ExFreePool(p) +#endif +*/ + +#define _POOL_TAG 'nozO' + + +/* convert seconds into units of 100 nanoseconds for KeWaitFor* & KeDelayExecutionThread functions */ +#define SECONDS(s) ((s) * -10000000) + + +#define ProbeAndReadUnicodeString(Source) \ + (((Source) >= (UNICODE_STRING * const)MM_USER_PROBE_ADDRESS) ? \ + (*(volatile UNICODE_STRING * const)MM_USER_PROBE_ADDRESS) : (*(volatile UNICODE_STRING *)(Source))) + + +/* extern defines */ + +KPROCESSOR_MODE +KeGetPreviousMode( + VOID + ); + + +int sprintf(char *buffer, const char *format, ...); +int _snprintf(char *buffer, size_t count, const char *format, ...); +int _snwprintf(wchar_t *buffer, size_t count, const wchar_t *format, ...); + +BOOLEAN LearningModePostBootup(); + + +#define CURRENT_PROCESS_PID ((ULONG) PsGetCurrentProcessId()) + + +#define ON 1 +#define OFF 0 + + +/* internal defines */ + +extern BOOLEAN BootingUp; + + +INT32 atoi(IN PCHAR buf); +PCHAR itoa(int value, char *string, unsigned int radix); + +/* XXX move to netmisc.c */ +ULONG ntohl(IN ULONG netlong); +USHORT ntohs(IN USHORT netshort); + +ULONG inet_addr(IN PCCHAR cp); +VOID inet_ntoa(ULONG ina, PCHAR buf); +PCHAR inet_ntoa2(IN ULONG ina); + +BOOLEAN VerifyUnicodeString(IN PUNICODE_STRING InputUnicodeString, OUT PUNICODE_STRING OutputUnicodeString); +BOOLEAN VerifyPwstr(IN PWSTR InputString, IN ULONG InputStringLength); + +BOOLEAN ReadStringRegistryValueA(IN PWSTR RegistryPath, IN PWSTR KeyName, OUT PCHAR Buffer, IN USHORT BufferSize); +BOOLEAN ReadStringRegistryValueW(IN PWSTR RegistryPath, IN PWSTR KeyName, OUT PWSTR Buffer, IN USHORT BufferSize); +BOOLEAN ReadSymlinkValue(IN PWSTR SymlinkPath, OUT PCHAR Buffer, IN USHORT BufferSize); + +VOID InitPostBootup(); +PCHAR GetCurrentUserSid(PUSHORT Size); + +PVOID ExchangeReadOnlyMemoryPointer(IN OUT PVOID *Target, IN PVOID Value); + + +#endif /* __MISC_H__ */ \ No newline at end of file -- cgit v1.3