Skip to content

Commit

Permalink
r0.6.5
Browse files Browse the repository at this point in the history
  • Loading branch information
trulyspinach committed Sep 3, 2020
1 parent f32a371 commit b79d724
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 10 deletions.
1 change: 1 addition & 0 deletions AMDRyzenCPUPowerManagement/AMDRyzenCPUPowerManagement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ bool AMDRyzenCPUPowerManagement::init(OSDictionary *dictionary){

pmRyzen_symtable_ready = 0;

find_mach_header_addr(getKernelVersion() >= KernelVersion::BigSur);
pmRyzen_symtable._wrmsr_carefully = lookup_symbol("_wrmsr_carefully");
pmRyzen_symtable._KUNCUserNotificationDisplayAlert = lookup_symbol("_KUNCUserNotificationDisplayAlert");
pmRyzen_symtable._cpu_to_processor = lookup_symbol("_cpu_to_processor");
Expand Down
1 change: 1 addition & 0 deletions AMDRyzenCPUPowerManagement/AMDRyzenCPUPowerManagement.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include <Headers/kern_cpu.hpp>
#include <Headers/kern_time.hpp>


#include <Headers/kern_api.hpp>
#define LILU_CUSTOM_KMOD_INIT
#define LILU_CUSTOM_IOKIT_INIT
Expand Down
2 changes: 1 addition & 1 deletion AMDRyzenCPUPowerManagement/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
<key>OSBundleLibraries</key>
<dict>
<key>as.vit9696.Lilu</key>
<string>1.4.6</string>
<string>1.3.9</string>
<key>com.apple.iokit.IOPCIFamily</key>
<string>2.9</string>
<key>com.apple.kec.Libm</key>
Expand Down
19 changes: 14 additions & 5 deletions AMDRyzenCPUPowerManagement/symresolver/kernel_resolver.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,30 +21,39 @@ seg_command_64_t *find_segment_64(mach_header_64_t *mh, const char *segname);
load_command_t *find_load_command(mach_header_64_t *mh, uint32_t cmd);
void *find_symbol(mach_header_64_t *mh, const char *name);

void *lookup_symbol(const char *symbol)
{
static uint64_t mh_base_addr = 0;

void find_mach_header_addr(uint8_t kc){
uint64_t slide = 0;
vm_offset_t slide_address = 0;
vm_kernel_unslide_or_perm_external((unsigned long long)(void *)printf, &slide_address);
slide = (uint64_t)(void *)printf - slide_address;
uint64_t base_address = (uint64_t)slide + KERNEL_BASE;

if(!kc){
mh_base_addr = base_address;
return;
}

mach_header_64_t* mach_header = (mach_header_64_t*)base_address;
mach_header_64_t* actual_header = NULL;

load_command_t* lcp = (load_command_t*)(base_address + sizeof(mach_header_64_t));
for (uint32_t i = 0; i < mach_header->ncmds; i++) {
if (lcp->cmd == LC_SEGMENT_64) {
seg_command_64_t *sc = (seg_command_64_t*)lcp;
if (!strncmp(sc->segname, "__PRELINK_TEXT", sizeof(sc->segname))) {
actual_header = (mach_header_64_t*)sc->vmaddr;
mh_base_addr = sc->vmaddr;
break;
}
}
lcp = (load_command_t*)((uint64_t)lcp + (uint64_t)lcp->cmdsize);
}
}

void *lookup_symbol(const char *symbol)
{

if(!mh_base_addr) return NULL;
// IOLog("%s: aslr slide: 0x%0llx\n", __func__, slide);
// print_pointer((void*)slide);
// IOLog("%s: base address: 0x%0llx\n", __func__, base_address);
Expand All @@ -53,7 +62,7 @@ void *lookup_symbol(const char *symbol)
// IOLog("%s: actual address: 0x%0llx\n", __func__, (uint64_t)actual_header);
// print_pointer((void*)actual_header);

return find_symbol(actual_header, symbol);
return find_symbol((mach_header_64_t*)mh_base_addr, symbol);
}

seg_command_64_t *
Expand Down
6 changes: 4 additions & 2 deletions AMDRyzenCPUPowerManagement/symresolver/kernel_resolver.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
#include <vm/vm_kern.h>
#include <sys/sysctl.h>



typedef struct mach_header_64 mach_header_64_t;
typedef struct load_command load_command_t;
typedef struct segment_command_64 seg_command_64_t;
Expand All @@ -19,8 +21,8 @@ typedef struct symtab_command symtab_command_t;
#ifdef __cplusplus
extern "C" {
#endif
void *lookup_symbol(const char *symbol);
void find_mach_header_addr(uint8_t kc);
void *lookup_symbol(const char *symbol);
void print_pointer(void *ptr);

#ifdef __cplusplus
Expand Down
4 changes: 2 additions & 2 deletions SMCAMDProcessor.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 10.13;
MARKETING_VERSION = 1.6;
MARKETING_VERSION = 1.6.1;
PRODUCT_BUNDLE_IDENTIFIER = "wtf.spinach.AMD-Power-Gadget";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
Expand All @@ -588,7 +588,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 10.13;
MARKETING_VERSION = 1.6;
MARKETING_VERSION = 1.6.1;
PRODUCT_BUNDLE_IDENTIFIER = "wtf.spinach.AMD-Power-Gadget";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_COMPILATION_MODE = wholemodule;
Expand Down

0 comments on commit b79d724

Please sign in to comment.