mirror of
https://github.com/HyperDbg/HyperDbg
synced 2026-08-15 06:29:09 -04:00
link files in mock to platform/kernel/
This commit is contained in:
parent
1eb72d1621
commit
a25f81483c
7 changed files with 1117 additions and 5 deletions
1038
hyperdbg/include/platform/kernel/code/.Mem.o.cmd
Normal file
1038
hyperdbg/include/platform/kernel/code/.Mem.o.cmd
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -10,6 +10,49 @@
|
|||
* @copyright This project is released under the GNU Public License v3.
|
||||
*
|
||||
*/
|
||||
#include "../header/Mem.h"
|
||||
#ifdef __linux__
|
||||
|
||||
#include <linux/types.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/string.h>
|
||||
#include "../header/module_info.h"
|
||||
|
||||
void* MemAllocKernel(size_t Size)
|
||||
{
|
||||
void* ptr = kzalloc(Size, GFP_KERNEL);
|
||||
|
||||
if (ptr)
|
||||
printk(KERN_INFO "MemAllocKernel: Allocated %zu bytes at %px\n", Size, ptr);
|
||||
else
|
||||
printk(KERN_ERR "MemAllocKernel: failed to allocate %zu bytes\n", Size);
|
||||
|
||||
return ptr;
|
||||
}
|
||||
|
||||
void MemFree(void* Ptr)
|
||||
{
|
||||
if (Ptr) {
|
||||
printk(KERN_INFO "MemFree: Freeing memory at %px\n", Ptr);
|
||||
kfree(Ptr);
|
||||
}
|
||||
}
|
||||
|
||||
void MemCopy(void* Destination, const void* Source, size_t Size)
|
||||
{
|
||||
memcpy(Destination, Source, Size);
|
||||
}
|
||||
|
||||
void MemSet(void* Destination, int Value, size_t Size)
|
||||
{
|
||||
memset(Destination, Value, Size);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#elif defined(_WIN32)
|
||||
#include "pch.h"
|
||||
|
||||
/**
|
||||
|
|
@ -87,3 +130,7 @@ PlatformMemFreePool(PVOID BufferAddress)
|
|||
{
|
||||
ExFreePoolWithTag(BufferAddress, POOLTAG);
|
||||
}
|
||||
|
||||
#else
|
||||
#error "Unsupported platform"
|
||||
#endif
|
||||
|
|
|
|||
BIN
hyperdbg/include/platform/kernel/code/Mem.o
Normal file
BIN
hyperdbg/include/platform/kernel/code/Mem.o
Normal file
Binary file not shown.
|
|
@ -19,6 +19,14 @@
|
|||
//
|
||||
// Some functions are globally defined in SDK
|
||||
//
|
||||
#ifdef __linux__
|
||||
#include <linux/types.h>
|
||||
void* MemAllocKernel(size_t Size);
|
||||
void MemFree(void* Ptr);
|
||||
void MemCopy(void* Destination, const void* Source, size_t Size);
|
||||
void MemSet(void* Destination, int Value, size_t Size);
|
||||
|
||||
#elif defined(_WIN32)
|
||||
|
||||
PVOID
|
||||
PlatformMemAllocateContiguousZeroedMemory(SIZE_T NumberOfBytes);
|
||||
|
|
@ -37,3 +45,6 @@ PlatformMemAllocateZeroedNonPagedPool(SIZE_T NumberOfBytes);
|
|||
|
||||
VOID
|
||||
PlatformMemFreePool(PVOID BufferAddress);
|
||||
#else
|
||||
#error "Unsupported platform"
|
||||
#endif
|
||||
|
|
|
|||
13
hyperdbg/include/platform/kernel/header/module_info.h
Normal file
13
hyperdbg/include/platform/kernel/header/module_info.h
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
// module_info.h
|
||||
|
||||
#ifndef MODULE_INFO_H
|
||||
#define MODULE_INFO_H
|
||||
|
||||
#include <linux/module.h>
|
||||
|
||||
MODULE_LICENSE("GPL");
|
||||
MODULE_AUTHOR("Alish");
|
||||
MODULE_DESCRIPTION("Linux Kernel module Mock");
|
||||
MODULE_VERSION("0.1");
|
||||
|
||||
#endif // _MODULE_INFO_H_
|
||||
|
|
@ -1,10 +1,13 @@
|
|||
obj-m += mymodule.o
|
||||
mymodule-objs := mock.o mem.o
|
||||
mymodule-objs := mock.o \
|
||||
../../include/platform/kernel/code/Mem.o
|
||||
|
||||
PWD := $(CURDIR)
|
||||
KDIR ?= /lib/modules/$(shell uname -r)/build
|
||||
PWD := $(shell pwd)
|
||||
EXTRA_CFLAGS += -I$(PWD)/../../include/platform/kernel/header
|
||||
|
||||
all:
|
||||
$(MAKE) -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
|
||||
$(MAKE) -C $(KDIR) M=$(PWD) modules
|
||||
|
||||
clean:
|
||||
$(MAKE) -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
|
||||
$(MAKE) -C $(KDIR) M=$(PWD) clean
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
#include <linux/slab.h>
|
||||
#include <linux/string.h>
|
||||
#include "module_info.h"
|
||||
#include "mem.h"
|
||||
#include "../../include/platform/kernel/header/Mem.h"
|
||||
|
||||
|
||||
static void* g_AllocatedBuffer;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue