Skip to content

Commit f1224e5

Browse files
raedrizqienobu
authored andcommitted
fix i386-ucrt build
1 parent b1f4222 commit f1224e5

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

win32/win32.c

+10-4
Original file line numberDiff line numberDiff line change
@@ -2582,7 +2582,7 @@ set_pioinfo_extra(void)
25822582
char *p = (char*)get_proc_address(UCRTBASE, "_isatty", NULL);
25832583
/* _osfile(fh) & FDEV */
25842584

2585-
#ifdef _M_ARM64
2585+
#if defined(_M_ARM64) || defined(__aarch64__)
25862586
#define IS_INSN(pc, name) ((*(pc) & name##_mask) == name##_id)
25872587
const int max_num_inst = 500;
25882588
uint32_t *start = (uint32_t*)p;
@@ -2664,15 +2664,21 @@ set_pioinfo_extra(void)
26642664
# else /* x86 */
26652665
/* pop ebp */
26662666
# define FUNCTION_BEFORE_RET_MARK "\x5d"
2667+
/* leave */
2668+
# define FUNCTION_BEFORE_RET_MARK_2 "\xc9"
26672669
# define FUNCTION_SKIP_BYTES 0
26682670
/* mov eax,dword ptr [eax*4+100EB430h] */
26692671
# define PIOINFO_MARK "\x8B\x04\x85"
26702672
# endif
26712673
if (p) {
2672-
for (pend += 10; pend < p + 300; pend++) {
2674+
for (pend += 10; pend < p + 500; pend++) {
26732675
// find end of function
2674-
if (memcmp(pend, FUNCTION_BEFORE_RET_MARK, sizeof(FUNCTION_BEFORE_RET_MARK) - 1) == 0 &&
2675-
(*(pend + (sizeof(FUNCTION_BEFORE_RET_MARK) - 1) + FUNCTION_SKIP_BYTES) & FUNCTION_RET) == FUNCTION_RET) {
2676+
if ((memcmp(pend, FUNCTION_BEFORE_RET_MARK, sizeof(FUNCTION_BEFORE_RET_MARK) - 1) == 0
2677+
# ifdef FUNCTION_BEFORE_RET_MARK_2
2678+
|| memcmp(pend, FUNCTION_BEFORE_RET_MARK_2, sizeof(FUNCTION_BEFORE_RET_MARK_2) - 1) == 0
2679+
# endif
2680+
) &&
2681+
*(pend + (sizeof(FUNCTION_BEFORE_RET_MARK) - 1) + FUNCTION_SKIP_BYTES) == (char)FUNCTION_RET) {
26762682
// search backwards from end of function
26772683
for (pend -= (sizeof(PIOINFO_MARK) - 1); pend > p; pend--) {
26782684
if (memcmp(pend, PIOINFO_MARK, sizeof(PIOINFO_MARK) - 1) == 0) {

0 commit comments

Comments
 (0)