From ea462f761f6c2cc6aaa66fc80e05ba6adbc6897d Mon Sep 17 00:00:00 2001 From: The Tumultuous Unicorn Of Darkness Date: Tue, 9 Jul 2024 19:02:39 +0200 Subject: [PATCH] Move Windows MSR driver to a new directory The idea is to have add new drivers for ARM CPUs --- .../x86/windows/msr}/Kernel/TmpRdr.c | 0 .../x86/windows/msr}/Kernel/TmpRdr.vcproj | 0 .../x86/windows/msr}/Kernel/resource.h | 0 .../x86/windows/msr}/Kernel/tmprdr.rc | 0 .../x86/windows/msr}/TmpRdr.sys | Bin .../x86/windows/msr}/TmpRdr64.sys | Bin libcpuid/msrdriver.c | 2 +- .../embed_windows_drivers.cpp | 18 +++++++++++------- 8 files changed, 12 insertions(+), 8 deletions(-) rename {contrib/MSR Driver => drivers/x86/windows/msr}/Kernel/TmpRdr.c (100%) rename {contrib/MSR Driver => drivers/x86/windows/msr}/Kernel/TmpRdr.vcproj (100%) rename {contrib/MSR Driver => drivers/x86/windows/msr}/Kernel/resource.h (100%) rename {contrib/MSR Driver => drivers/x86/windows/msr}/Kernel/tmprdr.rc (100%) rename {contrib/MSR Driver => drivers/x86/windows/msr}/TmpRdr.sys (100%) rename {contrib/MSR Driver => drivers/x86/windows/msr}/TmpRdr64.sys (100%) rename libcpuid/embed_drivers.cpp => utils/embed_windows_drivers.cpp (81%) diff --git a/contrib/MSR Driver/Kernel/TmpRdr.c b/drivers/x86/windows/msr/Kernel/TmpRdr.c similarity index 100% rename from contrib/MSR Driver/Kernel/TmpRdr.c rename to drivers/x86/windows/msr/Kernel/TmpRdr.c diff --git a/contrib/MSR Driver/Kernel/TmpRdr.vcproj b/drivers/x86/windows/msr/Kernel/TmpRdr.vcproj similarity index 100% rename from contrib/MSR Driver/Kernel/TmpRdr.vcproj rename to drivers/x86/windows/msr/Kernel/TmpRdr.vcproj diff --git a/contrib/MSR Driver/Kernel/resource.h b/drivers/x86/windows/msr/Kernel/resource.h similarity index 100% rename from contrib/MSR Driver/Kernel/resource.h rename to drivers/x86/windows/msr/Kernel/resource.h diff --git a/contrib/MSR Driver/Kernel/tmprdr.rc b/drivers/x86/windows/msr/Kernel/tmprdr.rc similarity index 100% rename from contrib/MSR Driver/Kernel/tmprdr.rc rename to drivers/x86/windows/msr/Kernel/tmprdr.rc diff --git a/contrib/MSR Driver/TmpRdr.sys b/drivers/x86/windows/msr/TmpRdr.sys similarity index 100% rename from contrib/MSR Driver/TmpRdr.sys rename to drivers/x86/windows/msr/TmpRdr.sys diff --git a/contrib/MSR Driver/TmpRdr64.sys b/drivers/x86/windows/msr/TmpRdr64.sys similarity index 100% rename from contrib/MSR Driver/TmpRdr64.sys rename to drivers/x86/windows/msr/TmpRdr64.sys diff --git a/libcpuid/msrdriver.c b/libcpuid/msrdriver.c index f67db89..e8c3da1 100644 --- a/libcpuid/msrdriver.c +++ b/libcpuid/msrdriver.c @@ -30,7 +30,7 @@ * @Date 2009-09-29 * * The driver is courtesy of Nick 'Bombera' Gabareff, and its source is actually - * available, see the contrib/ dir. + * available, see the drivers/x86/windows/msr/ dir. * * However, for simplicity, here we just include the images of the compiled .SYS * files. diff --git a/libcpuid/embed_drivers.cpp b/utils/embed_windows_drivers.cpp similarity index 81% rename from libcpuid/embed_drivers.cpp rename to utils/embed_windows_drivers.cpp index 5fa2152..5b8aeff 100644 --- a/libcpuid/embed_drivers.cpp +++ b/utils/embed_windows_drivers.cpp @@ -7,18 +7,15 @@ #include using namespace std; -const char* drivers_root = "..\\contrib\\MSR Driver\\"; -const char* sourcefile = "msrdriver.c"; - char* images[2]; int sizes[2]; const char* filenames[] = { "TmpRdr.sys", "TmpRdr64.sys" }; vector source; -bool read_image(const char* filename, char*& image, int& isize) +bool read_image(const char* drivers_root, const char* filename, char*& image, int& isize) { char fn[512]; - sprintf(fn, "%s%s", drivers_root, filename); + sprintf(fn, "%s\\%s", drivers_root, filename); FILE* f = fopen(fn, "rb"); if (!f) return false; fseek(f, 0, SEEK_END); @@ -57,10 +54,17 @@ void print_image(FILE* f, const char* arch, const char* image, int size) fprintf(f, "\n};\n"); } -int main(void) +int main(int argc, char** argv) { + if (argc < 3) { + printf("%s DRIVER_ROOT_FOLDER SOURCE_FILE\n", argv[0]); + return 1; + } + const char* drivers_root = argv[1]; + const char* sourcefile = argv[2]; + for (int i = 0; i < 2; i++) - if (!read_image(filenames[i], images[i], sizes[i])) { + if (!read_image(drivers_root, filenames[i], images[i], sizes[i])) { printf("Cannot read image `%s' from `%s'!\n", filenames[i], drivers_root); return -1; }