HyperDbg Debugger
Loading...
Searching...
No Matches
install.h File Reference

Main interface to connect applications to driver headers. More...

Go to the source code of this file.

Macros

#define LIBHYPERDBG_API   __declspec(dllimport)
 
#define DRIVER_FUNC_INSTALL   0x01
 
#define DRIVER_FUNC_STOP   0x02
 
#define DRIVER_FUNC_REMOVE   0x03
 

Functions

BOOLEAN ManageDriver (_In_ LPCTSTR DriverName, _In_ LPCTSTR ServiceName, _In_ UINT16 Function)
 
BOOLEAN SetupPathForFileName (const CHAR *FileName, _Inout_updates_bytes_all_(BufferLength) PCHAR FileLocation, ULONG BufferLength, BOOLEAN CheckFileExists)
 Setup file name.
 

Detailed Description

Main interface to connect applications to driver headers.

Author
Sina Karvandi (sina@.nosp@m.hype.nosp@m.rdbg..nosp@m.org)
Version
0.1
Date
2020-04-11

Macro Definition Documentation

◆ DRIVER_FUNC_INSTALL

#define DRIVER_FUNC_INSTALL   0x01

◆ DRIVER_FUNC_REMOVE

#define DRIVER_FUNC_REMOVE   0x03

◆ DRIVER_FUNC_STOP

#define DRIVER_FUNC_STOP   0x02

◆ LIBHYPERDBG_API

#define LIBHYPERDBG_API   __declspec(dllimport)

Function Documentation

◆ ManageDriver()

BOOLEAN ManageDriver ( _In_ LPCTSTR DriverName,
_In_ LPCTSTR ServiceName,
_In_ UINT16 Function )

◆ SetupPathForFileName()

BOOLEAN SetupPathForFileName ( const CHAR * FileName,
_Inout_updates_bytes_all_(BufferLength) PCHAR FileLocation,
ULONG BufferLength,
BOOLEAN CheckFileExists )

Setup file name.

Parameters
FileName
FileLocation
BufferLength
CheckFileExists
Returns
BOOLEAN
444{
445 HANDLE FileHandle;
446 DWORD FileLocLen = 0;
447 HMODULE ProcHandle = GetModuleHandle(NULL);
448 char * Pos;
449
450 //
451 // Get the current directory.
452 //
453
454 /*
455 //
456 // We use the location of running exe instead of
457 // finding driver based on current directory
458 //
459 FileLocLen = GetCurrentDirectory(BufferLength, DriverLocation);
460
461 if (FileLocLen == 0) {
462
463 ShowMessages("err, GetCurrentDirectory failed (%x)\n", GetLastError());
464
465 return FALSE;
466 }
467 */
468
469 GetModuleFileName(ProcHandle, FileLocation, BufferLength);
470
471 Pos = strrchr(FileLocation, '\\');
472 if (Pos != NULL)
473 {
474 //
475 // this will put the null terminator here. you can also copy to
476 // another string if you want, we can also use PathCchRemoveFileSpec
477 //
478 *Pos = '\0';
479 }
480
481 //
482 // Setup path name to driver file
483 //
484 if (FAILED(
485 StringCbCat(FileLocation, BufferLength, "\\")))
486 {
487 return FALSE;
488 }
489 if (FAILED(
490 StringCbCat(FileLocation, BufferLength, FileName)))
491 {
492 return FALSE;
493 }
494
495 if (CheckFileExists)
496 {
497 //
498 // ensure file is in the specified directory
499 //
500 if ((FileHandle = CreateFile(FileLocation, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL)) == INVALID_HANDLE_VALUE)
501 {
502 ShowMessages("err, target file is not loaded\n");
503
504 //
505 // Indicate failure
506 //
507 return FALSE;
508 }
509
510 //
511 // Close open file handle
512 //
513 if (FileHandle)
514 {
515 CloseHandle(FileHandle);
516 }
517 }
518
519 //
520 // Indicate success
521 //
522 return TRUE;
523}
#define TRUE
Definition BasicTypes.h:55
#define FALSE
Definition BasicTypes.h:54
unsigned long DWORD
Definition BasicTypes.h:22
PHANDLE FileHandle
Definition Hooks.h:129
VOID ShowMessages(const char *Fmt,...)
Show messages.
Definition libhyperdbg.cpp:96