@@ -81,7 +81,7 @@ static int alloc_page_info(duckhook_t *duckhook, page_list_t **pl_out, void *hin
81
81
(mbi .State == MEM_FREE ) ? "free" : "used" );
82
82
if (mbi .State == MEM_FREE ) {
83
83
size_t addr = ROUND_UP ((size_t )mbi .BaseAddress , allocation_unit );
84
- int diff = addr - (size_t )mbi .BaseAddress ;
84
+ intptr_t diff = addr - (size_t )mbi .BaseAddress ;
85
85
if (diff >= 0 ) {
86
86
if (mbi .RegionSize - diff >= allocation_unit ) {
87
87
hint = (void * )addr ;
@@ -125,8 +125,8 @@ static int alloc_page_info(duckhook_t *duckhook, page_list_t **pl_out, void *hin
125
125
int duckhook_page_alloc (duckhook_t * duckhook , duckhook_page_t * * page_out , uint8_t * func , rip_displacement_t * disp )
126
126
{
127
127
page_list_t * pl ;
128
- duckhook_page_t * page ;
129
- int i ;
128
+ duckhook_page_t * page = NULL ;
129
+ size_t i ;
130
130
131
131
for (pl = page_list .next ; pl != & page_list ; pl = pl -> next ) {
132
132
for (i = 0 ; i < max_num_pages ; i ++ ) {
@@ -138,7 +138,7 @@ int duckhook_page_alloc(duckhook_t *duckhook, duckhook_page_t **page_out, uint8_
138
138
}
139
139
}
140
140
}
141
- if (pl == & page_list ) {
141
+ if (page == NULL ) {
142
142
/* no page_list is available. */
143
143
int rv = alloc_page_info (duckhook , & pl , func );
144
144
if (rv != 0 ) {
@@ -147,7 +147,7 @@ int duckhook_page_alloc(duckhook_t *duckhook, duckhook_page_t **page_out, uint8_
147
147
i = 0 ;
148
148
page = (duckhook_page_t * )((size_t )pl + page_size );
149
149
}
150
- if (VirtualAlloc (page , page_size , MEM_COMMIT , PAGE_READWRITE ) == NULL ) {
150
+ if (VirtualAlloc (page , page_size , MEM_COMMIT , PAGE_EXECUTE_READWRITE ) == NULL ) {
151
151
duckhook_set_error_message (duckhook , "Failed to commit page %p (base=%p(used=%d), idx=%d, size=%" SIZE_T_FMT "u, error=%lu)" ,
152
152
page , pl , pl -> num_used , i , page_size , GetLastError ());
153
153
return DUCKHOOK_ERROR_INTERNAL_ERROR ;
@@ -236,7 +236,7 @@ int duckhook_unprotect_end(duckhook_t *duckhook, const mem_state_t *mstate)
236
236
void * duckhook_resolve_func (duckhook_t * duckhook , void * func )
237
237
{
238
238
if (duckhook_debug_file != NULL ) {
239
- char path [PATH_MAX ];
239
+ char path [MAX_PATH ];
240
240
DWORD len = GetMappedFileNameA (GetCurrentProcess (), func , path , sizeof (path ));
241
241
if (len > 0 ) {
242
242
duckhook_log (duckhook , " func %p is in %.*s\n" , func , (int )len , path );
0 commit comments