Skip to content

Commit

Permalink
add win7 driver
Browse files Browse the repository at this point in the history
  • Loading branch information
a1ive committed Dec 11, 2023
1 parent 92608dd commit 70c980f
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 11 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/msbuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,10 @@ jobs:
copy libcdi\libcdi.x64.dll nwinfo\libcdi.x64.dll
copy libnw\jep106.ids nwinfo\jep106.ids
# copy winring0\WinRing0.sys nwinfo\WinRing0.sys
copy winring0\WinRing0x64.sys nwinfo\WinRing0x64.sys
# copy winring0\WinRing0x64.sys nwinfo\WinRing0x64.sys
copy winring0\HwRwDrv.sys nwinfo\HwRwDrv.sys
copy winring0\HwRwDrvx64.sys nwinfo\HwRwDrvx64.sys
copy winring0\HwRwDrvWin7x64.sys nwinfo\HwRwDrvWin7x64.sys
- name: Run UPX
uses: crazy-max/ghaction-upx@v3
Expand Down
4 changes: 2 additions & 2 deletions libnw/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

#define NWINFO_MAJOR_VERSION 0
#define NWINFO_MINOR_VERSION 9
#define NWINFO_MICRO_VERSION 2
#define NWINFO_BUILD_VERSION 1
#define NWINFO_MICRO_VERSION 3
#define NWINFO_BUILD_VERSION 0

#define NWINFO_VERSION NWINFO_MAJOR_VERSION,NWINFO_MINOR_VERSION,NWINFO_MICRO_VERSION,NWINFO_BUILD_VERSION
#define NWINFO_VERSION_STR QUOTE(NWINFO_MAJOR_VERSION.NWINFO_MINOR_VERSION.NWINFO_MICRO_VERSION.NWINFO_BUILD_VERSION)
Expand Down
Binary file added winring0/HwRwDrvWin7x64.sys
Binary file not shown.
29 changes: 22 additions & 7 deletions winring0/winring0.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,14 @@ static BOOL is_x64(void)
#endif
}

static BOOL find_driver(struct wr0_drv_t* driver, LPCWSTR name, LPCWSTR name64, LPCWSTR id, LPCWSTR obj)
static BOOL find_driver(struct wr0_drv_t* driver, LPCWSTR name, LPCWSTR id, LPCWSTR obj)
{
HANDLE hFile = INVALID_HANDLE_VALUE;

GetModuleFileNameW(NULL, driver->driver_path, MAX_PATH);

PathCchRemoveFileSpec(driver->driver_path, MAX_PATH);
PathCchAppend(driver->driver_path, MAX_PATH, is_x64() ? name64 : name);
PathCchAppend(driver->driver_path, MAX_PATH, name);
hFile = CreateFileW(driver->driver_path, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL);
if (hFile != INVALID_HANDLE_VALUE)
{
Expand All @@ -94,7 +94,7 @@ static BOOL find_driver(struct wr0_drv_t* driver, LPCWSTR name, LPCWSTR name64,
return FALSE;
}

struct wr0_drv_t* wr0_driver_open_real(LPCWSTR name, LPCWSTR name64, LPCWSTR id, LPCWSTR obj)
struct wr0_drv_t* wr0_driver_open_real(LPCWSTR name, LPCWSTR id, LPCWSTR obj)
{
struct wr0_drv_t* drv;
BOOL status = FALSE;
Expand All @@ -104,7 +104,7 @@ struct wr0_drv_t* wr0_driver_open_real(LPCWSTR name, LPCWSTR name64, LPCWSTR id,
return NULL;
ZeroMemory(drv, sizeof(struct wr0_drv_t));

if (!find_driver(drv, name, name64, id, obj))
if (!find_driver(drv, name, id, obj))
goto fail;
status = load_driver(drv);
if (status)
Expand All @@ -126,9 +126,24 @@ struct wr0_drv_t* wr0_driver_open_real(LPCWSTR name, LPCWSTR name64, LPCWSTR id,

struct wr0_drv_t* wr0_driver_open(void)
{
struct wr0_drv_t* drv = wr0_driver_open_real(OLS_DRIVER_NAME, OLS_DRIVER_NAME_X64, OLS_DRIVER_ID, OLS_DRIVER_OBJ);
if (!drv)
drv = wr0_driver_open_real(OLS_ALT_DRIVER_NAME, OLS_ALT_DRIVER_NAME_X64, OLS_ALT_DRIVER_ID, OLS_ALT_DRIVER_OBJ);
struct wr0_drv_t* drv = NULL;
if (is_x64())
{
drv = wr0_driver_open_real(OLS_DRIVER_NAME_X64, OLS_DRIVER_ID, OLS_DRIVER_OBJ);
if (drv)
return drv;
drv = wr0_driver_open_real(OLS_DRIVER_NAME_WIN7_X64, OLS_DRIVER_ID, OLS_DRIVER_OBJ);
if (drv)
return drv;
drv = wr0_driver_open_real(OLS_ALT_DRIVER_NAME_X64, OLS_ALT_DRIVER_ID, OLS_ALT_DRIVER_OBJ);
}
else
{
drv = wr0_driver_open_real(OLS_DRIVER_NAME, OLS_DRIVER_ID, OLS_DRIVER_OBJ);
if (drv)
return drv;
drv = wr0_driver_open_real(OLS_ALT_DRIVER_NAME, OLS_ALT_DRIVER_ID, OLS_ALT_DRIVER_OBJ);
}
return drv;
}

Expand Down
3 changes: 2 additions & 1 deletion winring0/winring0.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@ copy "$(ProjectDir)HwRwDrvx64.sys" "$(SolutionDir)$(Platform)\$(Configuration)\"
</Lib>
<PostBuildEvent>
<Command>copy "$(ProjectDir)HwRwDrv.sys" "$(SolutionDir)$(Platform)\$(Configuration)\"
copy "$(ProjectDir)HwRwDrvx64.sys" "$(SolutionDir)$(Platform)\$(Configuration)\"</Command>
copy "$(ProjectDir)HwRwDrvx64.sys" "$(SolutionDir)$(Platform)\$(Configuration)\"
copy "$(ProjectDir)HwRwDrvWin7x64.sys" "$(SolutionDir)$(Platform)\$(Configuration)\"</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemGroup>
Expand Down
1 change: 1 addition & 0 deletions winring0/winring0_def.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#define OLS_DRIVER_ID L"HwRwDrv"
#define OLS_DRIVER_NAME L"HwRwDrv.sys"
#define OLS_DRIVER_NAME_X64 L"HwRwDrvx64.sys"
#define OLS_DRIVER_NAME_WIN7_X64 L"HwRwDrvWin7x64.sys"
#define OLS_DRIVER_OBJ L"\\\\.\\HwRwDrv"
// WinRing0.sys
#define OLS_ALT_DRIVER_ID L"WinRing0_1_2_0"
Expand Down

0 comments on commit 70c980f

Please sign in to comment.