10 static BOOL
InstallService(
const char *rutaDriver, LPCTSTR lpServiceName, LPCTSTR lpDisplayName) {
13 HANDLE hSCManager = OpenSCManager(
NULL,
NULL, SC_MANAGER_CREATE_SERVICE);
15 LPTSTR rutaDriver_ = rz_sys_conv_utf8_to_win(rutaDriver);
16 hService = CreateService(hSCManager, lpServiceName, lpDisplayName, SERVICE_START | DELETE | SERVICE_STOP, SERVICE_KERNEL_DRIVER, SERVICE_DEMAND_START, SERVICE_ERROR_IGNORE, rutaDriver_,
NULL,
NULL,
NULL,
NULL,
NULL);
18 CloseServiceHandle(hService);
22 CloseServiceHandle(hSCManager);
30 HANDLE hSCManager = OpenSCManager(
NULL,
NULL, SC_MANAGER_CREATE_SERVICE);
32 hService = OpenService(hSCManager, lpServiceName, SERVICE_START | DELETE | SERVICE_STOP);
34 DeleteService(hService);
35 CloseServiceHandle(hService);
38 CloseServiceHandle(hSCManager);
46 SERVICE_STATUS ssStatus;
48 hSCManager = OpenSCManager(
NULL,
NULL, SC_MANAGER_CREATE_SERVICE);
50 hService = OpenService(hSCManager, lpServiceName, SERVICE_START | DELETE | SERVICE_STOP);
53 if (StartService(hService, 0,
NULL)) {
54 eprintf(
"Service started [OK]\n");
57 eprintf(
"Service started [FAIL]\n");
60 if (ControlService(hService, SERVICE_CONTROL_STOP, &ssStatus)) {
61 eprintf(
"Service Stopped [OK]\n");
64 eprintf(
"Service Stopped [FAIL]\n");
67 CloseServiceHandle(hService);
68 DeleteService(hService);
70 CloseServiceHandle(hSCManager);
76 const int genericFlags = GENERIC_READ | GENERIC_WRITE;
77 const int shareFlags = FILE_SHARE_READ | FILE_SHARE_WRITE;
79 NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_DIRECTORY, 0);
84 const char *pfile =
path + strlen(
path);
85 for (; pfile >
path; pfile--) {
86 if ((*pfile ==
'\\') || (*pfile ==
'/')) {
97 LPVOID lpBufMods =
NULL;
98 int bufmodsize = 1024 * 1024;
100 if (!(lpBufMods =
malloc(bufmodsize))) {
101 eprintf(
"[rzk] GetSystemModules: Error can't allocate %i bytes of memory.\n", bufmodsize);
113 eprintf(
"Driver not initialized.\n");
119 DWORD ret = -1, bRead = 0;
120 LPVOID lpBuffer =
NULL;
125 bufsize =
sizeof(
PA) +
len;
126 if (!(lpBuffer =
malloc(bufsize))) {
127 eprintf(
"[rzk] ReadKernelMemory: Error can't allocate %i bytes of memory.\n", bufsize);
131 p->address.QuadPart = address;
142 eprintf(
"Driver not initialized.\n");
148 DWORD ret = -1, bRead = 0;
149 LPVOID lpBuffer =
NULL;
153 bufsize =
sizeof(
PA) +
len;
154 if (!(lpBuffer =
malloc(bufsize))) {
155 eprintf(
"[rzk] WriteKernelMemory: Error can't allocate %i bytes of memory.\n", bufsize);
159 p->address.QuadPart = address;
165 eprintf(
"[rzk] WriteKernelMemory: Error IOCTL_WRITE_KERNEL_MEM.\n");
170 eprintf(
"Driver not initialized.\n");
175 int Init(
const char *driverPath) {
178 if (strlen(driverPath)) {
181 eprintf(
"Installing driver: %s\n", driverPath);
187 eprintf(
"Error initalizating driver, try rzk://pathtodriver\nEx: rizin.exe rzk://c:\\rzk.sys");
190 eprintf(
"Driver present [OK]\n");
static static fork const void static count static fd const char const char static newpath const char static path const char path
RZ_API void Ht_() free(HtName_(Ht) *ht)
static BOOL InstallService(const char *rutaDriver, LPCTSTR lpServiceName, LPCTSTR lpDisplayName)
int GetSystemModules(RzIO *io)
static BOOL InitDriver(VOID)
static BOOL RemoveService(LPCTSTR lpServiceName)
int ReadKernelMemory(ut64 address, ut8 *buf, int len)
BOOL StartStopService(LPCTSTR lpServiceName, BOOL bStop)
static const char * GetFileName(const char *path)
int WriteKernelMemory(ut64 address, const ut8 *buf, int len)
int Init(const char *driverPath)
#define IOCTL_WRITE_KERNEL_MEM
struct _RTL_PROCESS_MODULES * PRTL_PROCESS_MODULES
#define IOCTL_READ_KERNEL_MEM
#define IOCTL_GET_SYSTEM_MODULES
#define INVALID_HANDLE_VALUE
return memset(p, 0, total)
memcpy(mem, inblock.get(), min(CONTAINING_RECORD(inblock.get(), MEMBLOCK, data) ->size, size))
void * malloc(size_t size)
RTL_PROCESS_MODULE_INFORMATION Modules[1]
ut64(WINAPI *w32_GetEnabledXStateFeatures)()