forked from capstone-engine/capstone
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Satoshi Tanda <[email protected]>
- Loading branch information
Showing
8 changed files
with
21 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
/* Capstone Disassembly Engine */ | ||
/* By Satoshi Tanda <[email protected]>, 2016 */ | ||
|
||
#include <ntddk.h> | ||
|
||
#include <capstone/platform.h> | ||
|
@@ -21,7 +22,7 @@ EXTERN_C DRIVER_INITIALIZE DriverEntry; | |
#pragma warning(disable : 4005) // 'identifier' : macro redefinition | ||
#pragma warning(disable : 4007) // 'main': must be '__cdecl' | ||
|
||
// Drivers must protect floating point hardware state. See use of float simm: | ||
// Drivers must protect floating point hardware state. See use of float. | ||
// Use KeSaveFloatingPointState/KeRestoreFloatingPointState around floating | ||
// point operations. Display Drivers should use the corresponding Eng... routines. | ||
#pragma warning(disable : 28110) // Suppress this, as it is false positive. | ||
|
@@ -103,7 +104,7 @@ static void test() | |
// On a 32bit driver, KeSaveFloatingPointState() is required before using any | ||
// Capstone function because Capstone can access to the MMX/x87 registers and | ||
// 32bit Windows requires drivers to use KeSaveFloatingPointState() before and | ||
// KeRestoreFloatingPointState() after accesing to them. See "Using Floating | ||
// KeRestoreFloatingPointState() after accessing them. See "Using Floating | ||
// Point or MMX in a WDM Driver" on MSDN for more details. | ||
status = KeSaveFloatingPointState(&float_save); | ||
if (!NT_SUCCESS(status)) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
/* Capstone Disassembly Engine */ | ||
/* By Satoshi Tanda <[email protected]>, 2016 */ | ||
|
||
#include "winkernel_mm.h" | ||
#include <ntddk.h> | ||
|
||
|
@@ -77,27 +78,27 @@ void * CAPSTONE_API cs_winkernel_realloc(void *ptr, size_t size) | |
return new_ptr; | ||
} | ||
|
||
// vsnprintf(). _vsnprintf() is avaialable for drivers, but it differs from | ||
// vsnprintf() in a return value and when a null-terminater is set. | ||
// vsnprintf(). _vsnprintf() is available for drivers, but it differs from | ||
// vsnprintf() in a return value and when a null-terminator is set. | ||
// cs_winkernel_vsnprintf() takes care of those differences. | ||
#pragma warning(push) | ||
#pragma warning(disable : 28719) // Banned API Usage : _vsnprintf is a Banned | ||
// API as listed in dontuse.h for security | ||
// purposes. | ||
// Banned API Usage : _vsnprintf is a Banned API as listed in dontuse.h for | ||
// security purposes. | ||
#pragma warning(disable : 28719) | ||
int CAPSTONE_API cs_winkernel_vsnprintf(char *buffer, size_t count, const char *format, va_list argptr) | ||
{ | ||
int result = _vsnprintf(buffer, count, format, argptr); | ||
|
||
// _vsnprintf() returns -1 when a string is truncated, and returns "count" | ||
// when an entire string is stored but without '\0' at the end of "buffer". | ||
// In both cases, null-terminater needs to be added manually. | ||
// In both cases, null-terminator needs to be added manually. | ||
if (result == -1 || (size_t)result == count) { | ||
buffer[count - 1] = '\0'; | ||
} | ||
|
||
if (result == -1) { | ||
// In case when -1 is returned, the function has to get and return a number | ||
// of characters that would have been written. This attempts so by re-tring | ||
// of characters that would have been written. This attempts so by retrying | ||
// the same conversion with temp buffer that is most likely big enough to | ||
// complete formatting and get a number of characters that would have been | ||
// written. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
/* Capstone Disassembly Engine */ | ||
/* By Satoshi Tanda <[email protected]>, 2016 */ | ||
|
||
#ifndef CS_WINDOWS_WINKERNEL_MM_H | ||
#define CS_WINDOWS_WINKERNEL_MM_H | ||
|
||
|