#include <ntddk.h>
#include <capstone/platform.h>
#include <capstone/capstone.h>
#ifdef __cplusplus
extern "C" {
#endif
#include "../utils.h"
#ifdef __cplusplus
}
#endif
EXTERN_C DRIVER_INITIALIZE DriverEntry;
#pragma warning(push)
#pragma warning(disable : 4005)
#pragma warning(disable : 4007)
#pragma warning(disable : 28110)
namespace basic {
#include "test_basic.c"
}
namespace detail {
#include "test_detail.c"
}
namespace skipdata {
#include "test_skipdata.c"
}
namespace iter {
#include "test_iter.c"
}
namespace customized_mnem_ {
#include "test_customized_mnem.c"
}
namespace arm {
#include "test_arm.c"
}
namespace arm64 {
#include "test_arm64.c"
}
namespace mips {
#include "test_mips.c"
}
namespace m68k {
#include "test_m68k.c"
}
namespace ppc {
#include "test_ppc.c"
}
namespace sparc {
#include "test_sparc.c"
}
namespace systemz {
#include "test_systemz.c"
}
namespace x86 {
#include "test_x86.c"
}
namespace xcore {
#include "test_xcore.c"
}
#pragma warning(pop)
static void test()
{
KFLOATING_SAVE float_save;
NTSTATUS status;
NT_ASSERT(KeGetCurrentIrql() <= DISPATCH_LEVEL);
status = KeSaveFloatingPointState(&float_save);
if (!NT_SUCCESS(status)) {
printf("ERROR: Failed to save floating point state!\n");
return;
}
basic::test();
detail::test();
skipdata::test();
iter::test();
customized_mnem_::test();
arm::test();
arm64::test();
mips::test();
m68k::test();
ppc::test();
sparc::test();
systemz::test();
x86::test();
xcore::test();
KeRestoreFloatingPointState(&float_save);
}
static void cs_winkernel_vsnprintf_test()
{
char buf[10];
bool ok = true;
ok = (ok && cs_snprintf(buf, sizeof(buf), "%s", "") == 0 && strcmp(buf, "") == 0);
ok = (ok && cs_snprintf(buf, sizeof(buf), "%s", "0") == 1 && strcmp(buf, "0") == 0);
ok = (ok && cs_snprintf(buf, sizeof(buf), "%s", "012345678") == 9 && strcmp(buf, "012345678") == 0);
ok = (ok && cs_snprintf(buf, sizeof(buf), "%s", "0123456789") == 10 && strcmp(buf, "012345678") == 0);
ok = (ok && cs_snprintf(buf, sizeof(buf), "%s", "01234567890") == 11 && strcmp(buf, "012345678") == 0);
ok = (ok && cs_snprintf(buf, sizeof(buf), "%s", "0123456789001234567890") == 22 && strcmp(buf, "012345678") == 0);
if (!ok) {
printf("ERROR: cs_winkernel_vsnprintf_test() did not produce expected results!\n");
}
}
EXTERN_C NTSTATUS DriverEntry(PDRIVER_OBJECT DriverObject, PUNICODE_STRING RegistryPath)
{
UNREFERENCED_PARAMETER(DriverObject);
UNREFERENCED_PARAMETER(RegistryPath);
cs_winkernel_vsnprintf_test();
test();
return STATUS_CANCELLED;
}
_Use_decl_annotations_
int __cdecl printf(const char * format, ...)
{
NTSTATUS status;
va_list args;
va_start(args, format);
status = vDbgPrintEx(DPFLTR_DEFAULT_ID, DPFLTR_ERROR_LEVEL, format, args);
va_end(args);
return NT_SUCCESS(status);
}