Skip to content

Commit

Permalink
Fix the some breakpoint types could be used on x64 despite being invalid
Browse files Browse the repository at this point in the history
  • Loading branch information
zero318 committed Jun 4, 2024
1 parent f035db8 commit a967404
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
6 changes: 6 additions & 0 deletions thcrap/src/breakpoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,12 @@ bool breakpoint_from_json(const char *name, json_t *in, breakpoint_t *out) {
break;
}

#if TH_X64
// x64 CPUs aren't guaranteed to support LAHF/SAHF when operating
// in long mode, so don't allow setting those breakpoint types
// if that situation is detected.
state_type |= !CPU_Supports_LMLSAHF();
#endif
// State bit 1 indicates whether a stack adjustment is required
state_type <<= 1;

Expand Down
4 changes: 4 additions & 0 deletions thcrap/src/expression.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,10 @@ THCRAP_API bool OS_is_wine(void) {
return wine_version != NULL;
}

bool CPU_Supports_LMLSAHF(void) {
return CPUID_Data.HasLMLSAHF;
}

#define WarnOnce(warning) do {\
static bool AlreadyDisplayedWarning = false;\
if (!AlreadyDisplayedWarning) { \
Expand Down
1 change: 1 addition & 0 deletions thcrap/src/expression.h
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ bool CPU_Supports_SHA(void);
bool CPU_FDP_ErrorOnly(void);
bool CPU_FCS_FDS_Deprecated(void);
THCRAP_API bool OS_is_wine(void);
bool CPU_Supports_LMLSAHF(void);

void DisableCodecaveNotFoundWarning(bool state);

Expand Down

0 comments on commit a967404

Please sign in to comment.