Const correctness.

This commit is contained in:
Eric Pouech 2004-06-15 00:47:00 +00:00 committed by Alexandre Julliard
parent e98a664d57
commit db52588754
9 changed files with 120 additions and 116 deletions

View File

@ -317,14 +317,14 @@ static inline void HEAP_InsertFreeBlock( HEAP *heap, ARENA_FREE *pArena, BOOL la
* NULL: Failure * NULL: Failure
*/ */
static SUBHEAP *HEAP_FindSubHeap( static SUBHEAP *HEAP_FindSubHeap(
HEAP *heap, /* [in] Heap pointer */ const HEAP *heap, /* [in] Heap pointer */
LPCVOID ptr /* [in] Address */ LPCVOID ptr /* [in] Address */
) { ) {
SUBHEAP *sub = &heap->subheap; const SUBHEAP *sub = &heap->subheap;
while (sub) while (sub)
{ {
if (((char *)ptr >= (char *)sub) && if (((const char *)ptr >= (const char *)sub) &&
((char *)ptr < (char *)sub + sub->size)) return sub; ((const char *)ptr < (const char *)sub + sub->size)) return (SUBHEAP*)sub;
sub = sub->next; sub = sub->next;
} }
return NULL; return NULL;
@ -705,15 +705,15 @@ static ARENA_FREE *HEAP_FindFreeBlock( HEAP *heap, DWORD size,
* *
* Check that the pointer is inside the range possible for arenas. * Check that the pointer is inside the range possible for arenas.
*/ */
static BOOL HEAP_IsValidArenaPtr( HEAP *heap, void *ptr ) static BOOL HEAP_IsValidArenaPtr( const HEAP *heap, const void *ptr )
{ {
int i; int i;
SUBHEAP *subheap = HEAP_FindSubHeap( heap, ptr ); const SUBHEAP *subheap = HEAP_FindSubHeap( heap, ptr );
if (!subheap) return FALSE; if (!subheap) return FALSE;
if ((char *)ptr >= (char *)subheap + subheap->headerSize) return TRUE; if ((const char *)ptr >= (const char *)subheap + subheap->headerSize) return TRUE;
if (subheap != &heap->subheap) return FALSE; if (subheap != &heap->subheap) return FALSE;
for (i = 0; i < HEAP_NB_FREE_LISTS; i++) for (i = 0; i < HEAP_NB_FREE_LISTS; i++)
if (ptr == (void *)&heap->freeList[i].arena) return TRUE; if (ptr == (const void *)&heap->freeList[i].arena) return TRUE;
return FALSE; return FALSE;
} }
@ -813,9 +813,9 @@ static BOOL HEAP_ValidateFreeArena( SUBHEAP *subheap, ARENA_FREE *pArena )
/*********************************************************************** /***********************************************************************
* HEAP_ValidateInUseArena * HEAP_ValidateInUseArena
*/ */
static BOOL HEAP_ValidateInUseArena( SUBHEAP *subheap, ARENA_INUSE *pArena, BOOL quiet ) static BOOL HEAP_ValidateInUseArena( const SUBHEAP *subheap, const ARENA_INUSE *pArena, BOOL quiet )
{ {
char *heapEnd = (char *)subheap + subheap->size; const char *heapEnd = (const char *)subheap + subheap->size;
/* Check for unaligned pointers */ /* Check for unaligned pointers */
if ( (long)pArena % ALIGNMENT != 0 ) if ( (long)pArena % ALIGNMENT != 0 )
@ -861,15 +861,15 @@ static BOOL HEAP_ValidateInUseArena( SUBHEAP *subheap, ARENA_INUSE *pArena, BOOL
return FALSE; return FALSE;
} }
/* Check arena size */ /* Check arena size */
if ((char *)(pArena + 1) + (pArena->size & ARENA_SIZE_MASK) > heapEnd) if ((const char *)(pArena + 1) + (pArena->size & ARENA_SIZE_MASK) > heapEnd)
{ {
ERR("Heap %08lx: bad size %08lx for in-use arena %08lx\n", ERR("Heap %08lx: bad size %08lx for in-use arena %08lx\n",
(DWORD)subheap->heap, (DWORD)pArena->size & ARENA_SIZE_MASK, (DWORD)pArena ); (DWORD)subheap->heap, (DWORD)pArena->size & ARENA_SIZE_MASK, (DWORD)pArena );
return FALSE; return FALSE;
} }
/* Check next arena PREV_FREE flag */ /* Check next arena PREV_FREE flag */
if (((char *)(pArena + 1) + (pArena->size & ARENA_SIZE_MASK) < heapEnd) && if (((const char *)(pArena + 1) + (pArena->size & ARENA_SIZE_MASK) < heapEnd) &&
(*(DWORD *)((char *)(pArena + 1) + (pArena->size & ARENA_SIZE_MASK)) & ARENA_FLAG_PREV_FREE)) (*(const DWORD *)((const char *)(pArena + 1) + (pArena->size & ARENA_SIZE_MASK)) & ARENA_FLAG_PREV_FREE))
{ {
ERR("Heap %08lx: in-use arena %08lx next block has PREV_FREE flag\n", ERR("Heap %08lx: in-use arena %08lx next block has PREV_FREE flag\n",
(DWORD)subheap->heap, (DWORD)pArena ); (DWORD)subheap->heap, (DWORD)pArena );
@ -878,7 +878,7 @@ static BOOL HEAP_ValidateInUseArena( SUBHEAP *subheap, ARENA_INUSE *pArena, BOOL
/* Check prev free arena */ /* Check prev free arena */
if (pArena->size & ARENA_FLAG_PREV_FREE) if (pArena->size & ARENA_FLAG_PREV_FREE)
{ {
ARENA_FREE *pPrev = *((ARENA_FREE **)pArena - 1); const ARENA_FREE *pPrev = *((const ARENA_FREE * const*)pArena - 1);
/* Check prev pointer */ /* Check prev pointer */
if (!HEAP_IsValidArenaPtr( subheap->heap, pPrev )) if (!HEAP_IsValidArenaPtr( subheap->heap, pPrev ))
{ {
@ -895,7 +895,7 @@ static BOOL HEAP_ValidateInUseArena( SUBHEAP *subheap, ARENA_INUSE *pArena, BOOL
return FALSE; return FALSE;
} }
/* Check that prev arena is really the previous block */ /* Check that prev arena is really the previous block */
if ((char *)(pPrev + 1) + (pPrev->size & ARENA_SIZE_MASK) != (char *)pArena) if ((const char *)(pPrev + 1) + (pPrev->size & ARENA_SIZE_MASK) != (const char *)pArena)
{ {
ERR("Heap %08lx: prev arena %08lx is not prev for in-use %08lx\n", ERR("Heap %08lx: prev arena %08lx is not prev for in-use %08lx\n",
(DWORD)subheap->heap, (DWORD)pPrev, (DWORD)pArena ); (DWORD)subheap->heap, (DWORD)pPrev, (DWORD)pArena );
@ -940,8 +940,8 @@ static BOOL HEAP_IsRealArena( HEAP *heapPtr, /* [in] ptr to the heap */
/* Only check this single memory block */ /* Only check this single memory block */
if (!(subheap = HEAP_FindSubHeap( heapPtr, block )) || if (!(subheap = HEAP_FindSubHeap( heapPtr, block )) ||
((char *)block < (char *)subheap + subheap->headerSize ((const char *)block < (char *)subheap + subheap->headerSize
+ sizeof(ARENA_INUSE))) + sizeof(ARENA_INUSE)))
{ {
if (quiet == NOISY) if (quiet == NOISY)
ERR("Heap %p: block %p is not inside heap\n", heapPtr, block ); ERR("Heap %p: block %p is not inside heap\n", heapPtr, block );
@ -949,7 +949,7 @@ static BOOL HEAP_IsRealArena( HEAP *heapPtr, /* [in] ptr to the heap */
WARN("Heap %p: block %p is not inside heap\n", heapPtr, block ); WARN("Heap %p: block %p is not inside heap\n", heapPtr, block );
ret = FALSE; ret = FALSE;
} else } else
ret = HEAP_ValidateInUseArena( subheap, (ARENA_INUSE *)block - 1, quiet ); ret = HEAP_ValidateInUseArena( subheap, (const ARENA_INUSE *)block - 1, quiet );
if (!(flags & HEAP_NO_SERIALIZE)) if (!(flags & HEAP_NO_SERIALIZE))
RtlLeaveCriticalSection( &heapPtr->critSection ); RtlLeaveCriticalSection( &heapPtr->critSection );

View File

@ -106,7 +106,7 @@ static WINE_MODREF *cached_modref;
static WINE_MODREF *current_modref; static WINE_MODREF *current_modref;
static NTSTATUS load_dll( LPCWSTR load_path, LPCWSTR libname, DWORD flags, WINE_MODREF** pwm ); static NTSTATUS load_dll( LPCWSTR load_path, LPCWSTR libname, DWORD flags, WINE_MODREF** pwm );
static FARPROC find_named_export( HMODULE module, IMAGE_EXPORT_DIRECTORY *exports, static FARPROC find_named_export( HMODULE module, const IMAGE_EXPORT_DIRECTORY *exports,
DWORD exp_size, const char *name, int hint ); DWORD exp_size, const char *name, int hint );
/* convert PE image VirtualAddress to Real Address */ /* convert PE image VirtualAddress to Real Address */
@ -245,11 +245,11 @@ static WINE_MODREF *find_fullname_module( LPCWSTR name )
*/ */
static FARPROC find_forwarded_export( HMODULE module, const char *forward ) static FARPROC find_forwarded_export( HMODULE module, const char *forward )
{ {
IMAGE_EXPORT_DIRECTORY *exports; const IMAGE_EXPORT_DIRECTORY *exports;
DWORD exp_size; DWORD exp_size;
WINE_MODREF *wm; WINE_MODREF *wm;
WCHAR mod_name[32]; WCHAR mod_name[32];
char *end = strchr(forward, '.'); const char *end = strchr(forward, '.');
FARPROC proc = NULL; FARPROC proc = NULL;
if (!end) return NULL; if (!end) return NULL;
@ -285,11 +285,11 @@ static FARPROC find_forwarded_export( HMODULE module, const char *forward )
* The exports base must have been subtracted from the ordinal already. * The exports base must have been subtracted from the ordinal already.
* The loader_section must be locked while calling this function. * The loader_section must be locked while calling this function.
*/ */
static FARPROC find_ordinal_export( HMODULE module, IMAGE_EXPORT_DIRECTORY *exports, static FARPROC find_ordinal_export( HMODULE module, const IMAGE_EXPORT_DIRECTORY *exports,
DWORD exp_size, int ordinal ) DWORD exp_size, int ordinal )
{ {
FARPROC proc; FARPROC proc;
DWORD *functions = get_rva( module, exports->AddressOfFunctions ); const DWORD *functions = get_rva( module, exports->AddressOfFunctions );
if (ordinal >= exports->NumberOfFunctions) if (ordinal >= exports->NumberOfFunctions)
{ {
@ -301,8 +301,9 @@ static FARPROC find_ordinal_export( HMODULE module, IMAGE_EXPORT_DIRECTORY *expo
proc = get_rva( module, functions[ordinal] ); proc = get_rva( module, functions[ordinal] );
/* if the address falls into the export dir, it's a forward */ /* if the address falls into the export dir, it's a forward */
if (((char *)proc >= (char *)exports) && ((char *)proc < (char *)exports + exp_size)) if (((const char *)proc >= (const char *)exports) &&
return find_forwarded_export( module, (char *)proc ); ((const char *)proc < (const char *)exports + exp_size))
return find_forwarded_export( module, (const char *)proc );
if (TRACE_ON(snoop) && current_modref) if (TRACE_ON(snoop) && current_modref)
{ {
@ -324,11 +325,11 @@ static FARPROC find_ordinal_export( HMODULE module, IMAGE_EXPORT_DIRECTORY *expo
* Find an exported function by name. * Find an exported function by name.
* The loader_section must be locked while calling this function. * The loader_section must be locked while calling this function.
*/ */
static FARPROC find_named_export( HMODULE module, IMAGE_EXPORT_DIRECTORY *exports, static FARPROC find_named_export( HMODULE module, const IMAGE_EXPORT_DIRECTORY *exports,
DWORD exp_size, const char *name, int hint ) DWORD exp_size, const char *name, int hint )
{ {
WORD *ordinals = get_rva( module, exports->AddressOfNameOrdinals ); const WORD *ordinals = get_rva( module, exports->AddressOfNameOrdinals );
DWORD *names = get_rva( module, exports->AddressOfNames ); const DWORD *names = get_rva( module, exports->AddressOfNames );
int min = 0, max = exports->NumberOfNames - 1; int min = 0, max = exports->NumberOfNames - 1;
/* first check the hint */ /* first check the hint */
@ -360,16 +361,17 @@ static FARPROC find_named_export( HMODULE module, IMAGE_EXPORT_DIRECTORY *export
* Import the dll specified by the given import descriptor. * Import the dll specified by the given import descriptor.
* The loader_section must be locked while calling this function. * The loader_section must be locked while calling this function.
*/ */
static WINE_MODREF *import_dll( HMODULE module, IMAGE_IMPORT_DESCRIPTOR *descr, LPCWSTR load_path ) static WINE_MODREF *import_dll( HMODULE module, const IMAGE_IMPORT_DESCRIPTOR *descr, LPCWSTR load_path )
{ {
NTSTATUS status; NTSTATUS status;
WINE_MODREF *wmImp; WINE_MODREF *wmImp;
HMODULE imp_mod; HMODULE imp_mod;
IMAGE_EXPORT_DIRECTORY *exports; const IMAGE_EXPORT_DIRECTORY *exports;
DWORD exp_size; DWORD exp_size;
IMAGE_THUNK_DATA *import_list, *thunk_list; const IMAGE_THUNK_DATA *import_list;
IMAGE_THUNK_DATA *thunk_list;
WCHAR buffer[32]; WCHAR buffer[32];
char *name = get_rva( module, descr->Name ); const char *name = get_rva( module, descr->Name );
DWORD len = strlen(name) + 1; DWORD len = strlen(name) + 1;
thunk_list = get_rva( module, (DWORD)descr->FirstThunk ); thunk_list = get_rva( module, (DWORD)descr->FirstThunk );
@ -476,7 +478,7 @@ static WINE_MODREF *import_dll( HMODULE module, IMAGE_IMPORT_DESCRIPTOR *descr,
static NTSTATUS fixup_imports( WINE_MODREF *wm, LPCWSTR load_path ) static NTSTATUS fixup_imports( WINE_MODREF *wm, LPCWSTR load_path )
{ {
int i, nb_imports; int i, nb_imports;
IMAGE_IMPORT_DESCRIPTOR *imports; const IMAGE_IMPORT_DESCRIPTOR *imports;
WINE_MODREF *prev; WINE_MODREF *prev;
DWORD size; DWORD size;
NTSTATUS status; NTSTATUS status;
@ -525,8 +527,8 @@ static NTSTATUS fixup_imports( WINE_MODREF *wm, LPCWSTR load_path )
static WINE_MODREF *alloc_module( HMODULE hModule, LPCWSTR filename ) static WINE_MODREF *alloc_module( HMODULE hModule, LPCWSTR filename )
{ {
WINE_MODREF *wm; WINE_MODREF *wm;
WCHAR *p; const WCHAR *p;
IMAGE_NT_HEADERS *nt = RtlImageNtHeader(hModule); const IMAGE_NT_HEADERS *nt = RtlImageNtHeader(hModule);
PLIST_ENTRY entry, mark; PLIST_ENTRY entry, mark;
if (!(wm = RtlAllocateHeap( GetProcessHeap(), 0, sizeof(*wm) ))) return NULL; if (!(wm = RtlAllocateHeap( GetProcessHeap(), 0, sizeof(*wm) ))) return NULL;
@ -587,7 +589,7 @@ static NTSTATUS alloc_process_tls(void)
{ {
PLIST_ENTRY mark, entry; PLIST_ENTRY mark, entry;
PLDR_MODULE mod; PLDR_MODULE mod;
IMAGE_TLS_DIRECTORY *dir; const IMAGE_TLS_DIRECTORY *dir;
ULONG size, i; ULONG size, i;
mark = &NtCurrentTeb()->Peb->LdrData->InMemoryOrderModuleList; mark = &NtCurrentTeb()->Peb->LdrData->InMemoryOrderModuleList;
@ -929,7 +931,7 @@ NTSTATUS WINAPI LdrFindEntryForAddress(const void* addr, PLDR_MODULE* pmod)
{ {
mod = CONTAINING_RECORD(entry, LDR_MODULE, InMemoryOrderModuleList); mod = CONTAINING_RECORD(entry, LDR_MODULE, InMemoryOrderModuleList);
if ((const void *)mod->BaseAddress <= addr && if ((const void *)mod->BaseAddress <= addr &&
(char *)addr < (char*)mod->BaseAddress + mod->SizeOfImage) (const char *)addr < (char*)mod->BaseAddress + mod->SizeOfImage)
{ {
*pmod = mod; *pmod = mod;
return STATUS_SUCCESS; return STATUS_SUCCESS;
@ -1972,12 +1974,14 @@ PIMAGE_SECTION_HEADER WINAPI RtlImageRvaToSection( const IMAGE_NT_HEADERS *nt,
HMODULE module, DWORD rva ) HMODULE module, DWORD rva )
{ {
int i; int i;
IMAGE_SECTION_HEADER *sec = (IMAGE_SECTION_HEADER*)((char*)&nt->OptionalHeader + const IMAGE_SECTION_HEADER *sec;
nt->FileHeader.SizeOfOptionalHeader);
sec = (const IMAGE_SECTION_HEADER*)((const char*)&nt->OptionalHeader +
nt->FileHeader.SizeOfOptionalHeader);
for (i = 0; i < nt->FileHeader.NumberOfSections; i++, sec++) for (i = 0; i < nt->FileHeader.NumberOfSections; i++, sec++)
{ {
if ((sec->VirtualAddress <= rva) && (sec->VirtualAddress + sec->SizeOfRawData > rva)) if ((sec->VirtualAddress <= rva) && (sec->VirtualAddress + sec->SizeOfRawData > rva))
return sec; return (PIMAGE_SECTION_HEADER)sec;
} }
return NULL; return NULL;
} }

View File

@ -103,7 +103,7 @@ static struct loadorder_list env_list;
*/ */
static int cmp_sort_func(const void *s1, const void *s2) static int cmp_sort_func(const void *s1, const void *s2)
{ {
return strcmpiW(((module_loadorder_t *)s1)->modulename, ((module_loadorder_t *)s2)->modulename); return strcmpiW(((const module_loadorder_t *)s1)->modulename, ((const module_loadorder_t *)s2)->modulename);
} }
@ -112,7 +112,7 @@ static int cmp_sort_func(const void *s1, const void *s2)
*/ */
static int strcmp_func(const void *s1, const void *s2) static int strcmp_func(const void *s1, const void *s2)
{ {
return strcmpiW( (WCHAR *)s1, (WCHAR *)s2 ); return strcmpiW( (const WCHAR *)s1, (const WCHAR *)s2 );
} }

View File

@ -61,9 +61,9 @@ extern void DECLSPEC_NORETURN server_abort_thread( int status );
/* module handling */ /* module handling */
extern BOOL MODULE_GetSystemDirectory( UNICODE_STRING *sysdir ); extern BOOL MODULE_GetSystemDirectory( UNICODE_STRING *sysdir );
extern void RELAY_InitDebugLists(void); extern void RELAY_InitDebugLists(void);
extern FARPROC RELAY_GetProcAddress( HMODULE module, IMAGE_EXPORT_DIRECTORY *exports, extern FARPROC RELAY_GetProcAddress( HMODULE module, const IMAGE_EXPORT_DIRECTORY *exports,
DWORD exp_size, FARPROC proc, const WCHAR *user ); DWORD exp_size, FARPROC proc, const WCHAR *user );
extern FARPROC SNOOP_GetProcAddress( HMODULE hmod, IMAGE_EXPORT_DIRECTORY *exports, DWORD exp_size, extern FARPROC SNOOP_GetProcAddress( HMODULE hmod, const IMAGE_EXPORT_DIRECTORY *exports, DWORD exp_size,
FARPROC origfun, DWORD ordinal, const WCHAR *user ); FARPROC origfun, DWORD ordinal, const WCHAR *user );
extern void RELAY_SetupDLL( HMODULE hmod ); extern void RELAY_SetupDLL( HMODULE hmod );
extern void SNOOP_SetupDLL( HMODULE hmod ); extern void SNOOP_SetupDLL( HMODULE hmod );

View File

@ -691,18 +691,18 @@ __ASM_GLOBAL_FUNC( RELAY_CallFrom32Regs,
static BOOL is_register_entry_point( const BYTE *addr ) static BOOL is_register_entry_point( const BYTE *addr )
{ {
extern void __wine_call_from_32_regs(); extern void __wine_call_from_32_regs();
int *offset; const int *offset;
void *ptr; const void *ptr;
if (*addr != 0xe8) return FALSE; /* not a call */ if (*addr != 0xe8) return FALSE; /* not a call */
/* check if call target is __wine_call_from_32_regs */ /* check if call target is __wine_call_from_32_regs */
offset = (int *)(addr + 1); offset = (const int *)(addr + 1);
if (*offset == (char *)__wine_call_from_32_regs - (char *)(offset + 1)) return TRUE; if (*offset == (const char *)__wine_call_from_32_regs - (const char *)(offset + 1)) return TRUE;
/* now check if call target is an import table jump to __wine_call_from_32_regs */ /* now check if call target is an import table jump to __wine_call_from_32_regs */
addr = (BYTE *)(offset + 1) + *offset; addr = (const BYTE *)(offset + 1) + *offset;
if (addr[0] != 0xff || addr[1] != 0x25) return FALSE; /* not an indirect jmp */ if (addr[0] != 0xff || addr[1] != 0x25) return FALSE; /* not an indirect jmp */
ptr = *(void **)(addr + 2); /* get indirect jmp target address */ ptr = *(const void * const*)(addr + 2); /* get indirect jmp target address */
return (*(char **)ptr == (char *)__wine_call_from_32_regs); return (*(const char * const*)ptr == (char *)__wine_call_from_32_regs);
} }
@ -711,11 +711,11 @@ static BOOL is_register_entry_point( const BYTE *addr )
* *
* Return the proc address to use for a given function. * Return the proc address to use for a given function.
*/ */
FARPROC RELAY_GetProcAddress( HMODULE module, IMAGE_EXPORT_DIRECTORY *exports, FARPROC RELAY_GetProcAddress( HMODULE module, const IMAGE_EXPORT_DIRECTORY *exports,
DWORD exp_size, FARPROC proc, const WCHAR *user ) DWORD exp_size, FARPROC proc, const WCHAR *user )
{ {
DEBUG_ENTRY_POINT *debug = (DEBUG_ENTRY_POINT *)proc; const DEBUG_ENTRY_POINT *debug = (DEBUG_ENTRY_POINT *)proc;
DEBUG_ENTRY_POINT *list = (DEBUG_ENTRY_POINT *)((char *)exports + exp_size); const DEBUG_ENTRY_POINT *list = (const DEBUG_ENTRY_POINT *)((const char *)exports + exp_size);
if (debug < list || debug >= list + exports->NumberOfFunctions) return proc; if (debug < list || debug >= list + exports->NumberOfFunctions) return proc;
if (list + (debug - list) != debug) return proc; /* not a valid address */ if (list + (debug - list) != debug) return proc; /* not a valid address */
@ -857,64 +857,64 @@ void SNOOP_SetupDLL(HMODULE hmod)
* *
* Return the proc address to use for a given function. * Return the proc address to use for a given function.
*/ */
FARPROC SNOOP_GetProcAddress( HMODULE hmod, IMAGE_EXPORT_DIRECTORY *exports, FARPROC SNOOP_GetProcAddress( HMODULE hmod, const IMAGE_EXPORT_DIRECTORY *exports,
DWORD exp_size, FARPROC origfun, DWORD ordinal, DWORD exp_size, FARPROC origfun, DWORD ordinal,
const WCHAR *user) const WCHAR *user)
{ {
int i; int i;
const char *ename; const char *ename;
WORD *ordinals; const WORD *ordinals;
DWORD *names; const DWORD *names;
SNOOP_DLL *dll = firstdll; SNOOP_DLL *dll = firstdll;
SNOOP_FUN *fun; SNOOP_FUN *fun;
IMAGE_SECTION_HEADER *sec; const IMAGE_SECTION_HEADER *sec;
if (!TRACE_ON(snoop)) return origfun; if (!TRACE_ON(snoop)) return origfun;
if (!check_from_module( debug_from_snoop_includelist, debug_from_snoop_excludelist, user )) if (!check_from_module( debug_from_snoop_includelist, debug_from_snoop_excludelist, user ))
return origfun; /* the calling module was explicitly excluded */ return origfun; /* the calling module was explicitly excluded */
if (!*(LPBYTE)origfun) /* 0x00 is an imposs. opcode, poss. dataref. */ if (!*(LPBYTE)origfun) /* 0x00 is an imposs. opcode, poss. dataref. */
return origfun; return origfun;
sec = RtlImageRvaToSection( RtlImageNtHeader(hmod), hmod, (char *)origfun - (char *)hmod ); sec = RtlImageRvaToSection( RtlImageNtHeader(hmod), hmod, (char *)origfun - (char *)hmod );
if (!sec || !(sec->Characteristics & IMAGE_SCN_CNT_CODE)) if (!sec || !(sec->Characteristics & IMAGE_SCN_CNT_CODE))
return origfun; /* most likely a data reference */ return origfun; /* most likely a data reference */
while (dll) { while (dll) {
if (hmod == dll->hmod) if (hmod == dll->hmod)
break; break;
dll=dll->next; dll = dll->next;
} }
if (!dll) /* probably internal */ if (!dll) /* probably internal */
return origfun; return origfun;
/* try to find a name for it */ /* try to find a name for it */
ename = NULL; ename = NULL;
names = (DWORD *)((char *)hmod + exports->AddressOfNames); names = (const DWORD *)((const char *)hmod + exports->AddressOfNames);
ordinals = (WORD *)((char *)hmod + exports->AddressOfNameOrdinals); ordinals = (const WORD *)((const char *)hmod + exports->AddressOfNameOrdinals);
if (names) for (i = 0; i < exports->NumberOfNames; i++) if (names) for (i = 0; i < exports->NumberOfNames; i++)
{
if (ordinals[i] == ordinal)
{ {
if (ordinals[i] == ordinal) ename = (const char *)hmod + names[i];
{ break;
ename = (char *)hmod + names[i];
break;
}
} }
if (!SNOOP_ShowDebugmsgSnoop(dll->name,ordinal,ename)) }
return origfun; if (!SNOOP_ShowDebugmsgSnoop(dll->name,ordinal,ename))
assert(ordinal < dll->nrofordinals); return origfun;
fun = dll->funs+ordinal; assert(ordinal < dll->nrofordinals);
if (!fun->name) fun = dll->funs + ordinal;
{ if (!fun->name)
fun->name = ename; {
fun->lcall = 0xe8; fun->name = ename;
/* NOTE: origreturn struct member MUST come directly after snoopentry */ fun->lcall = 0xe8;
fun->snoopentry = (char*)SNOOP_Entry-((char*)(&fun->nrofargs)); /* NOTE: origreturn struct member MUST come directly after snoopentry */
fun->origfun = origfun; fun->snoopentry = (char*)SNOOP_Entry-((char*)(&fun->nrofargs));
fun->nrofargs = -1; fun->origfun = origfun;
} fun->nrofargs = -1;
return (FARPROC)&(fun->lcall); }
return (FARPROC)&(fun->lcall);
} }
static void SNOOP_PrintArg(DWORD x) static void SNOOP_PrintArg(DWORD x)

View File

@ -99,7 +99,7 @@ static const IMAGE_RESOURCE_DIRECTORY *find_first_entry( const IMAGE_RESOURCE_DI
for (pos = 0; pos < dir->NumberOfNamedEntries + dir->NumberOfIdEntries; pos++) for (pos = 0; pos < dir->NumberOfNamedEntries + dir->NumberOfIdEntries; pos++)
{ {
if (!entry[pos].u2.s3.DataIsDirectory == !want_dir) if (!entry[pos].u2.s3.DataIsDirectory == !want_dir)
return (IMAGE_RESOURCE_DIRECTORY *)((char *)root + entry[pos].u2.s3.OffsetToDirectory); return (const IMAGE_RESOURCE_DIRECTORY *)((const char *)root + entry[pos].u2.s3.OffsetToDirectory);
} }
return NULL; return NULL;
} }
@ -127,8 +127,8 @@ static const IMAGE_RESOURCE_DIRECTORY *find_entry_by_id( const IMAGE_RESOURCE_DI
if (!entry[pos].u2.s3.DataIsDirectory == !want_dir) if (!entry[pos].u2.s3.DataIsDirectory == !want_dir)
{ {
TRACE("root %p dir %p id %04x ret %p\n", TRACE("root %p dir %p id %04x ret %p\n",
root, dir, id, (char *)root + entry[pos].u2.s3.OffsetToDirectory); root, dir, id, (const char*)root + entry[pos].u2.s3.OffsetToDirectory);
return (IMAGE_RESOURCE_DIRECTORY *)((char *)root + entry[pos].u2.s3.OffsetToDirectory); return (const IMAGE_RESOURCE_DIRECTORY *)((const char *)root + entry[pos].u2.s3.OffsetToDirectory);
} }
break; break;
} }
@ -161,15 +161,15 @@ static const IMAGE_RESOURCE_DIRECTORY *find_entry_by_name( const IMAGE_RESOURCE_
while (min <= max) while (min <= max)
{ {
pos = (min + max) / 2; pos = (min + max) / 2;
str = (IMAGE_RESOURCE_DIR_STRING_U *)((char *)root + entry[pos].u1.s1.NameOffset); str = (const IMAGE_RESOURCE_DIR_STRING_U *)((const char *)root + entry[pos].u1.s1.NameOffset);
res = strncmpW( name, str->NameString, str->Length ); res = strncmpW( name, str->NameString, str->Length );
if (!res && namelen == str->Length) if (!res && namelen == str->Length)
{ {
if (!entry[pos].u2.s3.DataIsDirectory == !want_dir) if (!entry[pos].u2.s3.DataIsDirectory == !want_dir)
{ {
TRACE("root %p dir %p name %s ret %p\n", TRACE("root %p dir %p name %s ret %p\n",
root, dir, debugstr_w(name), (char *)root + entry[pos].u2.s3.OffsetToDirectory); root, dir, debugstr_w(name), (const char*)root + entry[pos].u2.s3.OffsetToDirectory);
return (IMAGE_RESOURCE_DIRECTORY *)((char *)root + entry[pos].u2.s3.OffsetToDirectory); return (const IMAGE_RESOURCE_DIRECTORY *)((const char *)root + entry[pos].u2.s3.OffsetToDirectory);
} }
break; break;
} }
@ -389,9 +389,9 @@ NTSTATUS WINAPI RtlFindMessage( HMODULE hmod, ULONG type, ULONG lang,
{ {
const MESSAGE_RESOURCE_ENTRY *entry; const MESSAGE_RESOURCE_ENTRY *entry;
entry = (MESSAGE_RESOURCE_ENTRY *)((char *)data + block->OffsetToEntries); entry = (const MESSAGE_RESOURCE_ENTRY *)((const char *)data + block->OffsetToEntries);
for (i = msg_id - block->LowId; i > 0; i--) for (i = msg_id - block->LowId; i > 0; i--)
entry = (MESSAGE_RESOURCE_ENTRY *)((char *)entry + entry->Length); entry = (const MESSAGE_RESOURCE_ENTRY *)((const char *)entry + entry->Length);
*ret = entry; *ret = entry;
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }

View File

@ -482,7 +482,7 @@ VOID WINAPI RtlZeroMemory( VOID *Destination, SIZE_T Length )
SIZE_T WINAPI RtlCompareMemory( const VOID *Source1, const VOID *Source2, SIZE_T Length) SIZE_T WINAPI RtlCompareMemory( const VOID *Source1, const VOID *Source2, SIZE_T Length)
{ {
SIZE_T i; SIZE_T i;
for(i=0; (i<Length) && (((LPBYTE)Source1)[i]==((LPBYTE)Source2)[i]); i++); for(i=0; (i<Length) && (((const BYTE*)Source1)[i]==((const BYTE*)Source2)[i]); i++);
return i; return i;
} }

View File

@ -654,7 +654,7 @@ CCHAR WINAPI RtlFindLeastSignificantBit(ULONGLONG ulLong)
*/ */
static int NTDLL_RunSortFn(const void *lhs, const void *rhs) static int NTDLL_RunSortFn(const void *lhs, const void *rhs)
{ {
if (((PCRTL_BITMAP_RUN)lhs)->SizeOfRun > ((PRTL_BITMAP_RUN)rhs)->SizeOfRun) if (((const RTL_BITMAP_RUN*)lhs)->SizeOfRun > ((const RTL_BITMAP_RUN*)rhs)->SizeOfRun)
return -1; return -1;
return 1; return 1;
} }

View File

@ -222,7 +222,7 @@ static struct file_view *VIRTUAL_FindView( const void *addr ) /* [in] Address */
{ {
struct file_view *view = LIST_ENTRY( ptr, struct file_view, entry ); struct file_view *view = LIST_ENTRY( ptr, struct file_view, entry );
if (view->base > addr) break; if (view->base > addr) break;
if ((char *)view->base + view->size > (const char *)addr) return view; if ((const char*)view->base + view->size > (const char*)addr) return view;
} }
return NULL; return NULL;
} }
@ -241,8 +241,8 @@ static struct file_view *find_view_range( const void *addr, size_t size )
LIST_FOR_EACH( ptr, &views_list ) LIST_FOR_EACH( ptr, &views_list )
{ {
struct file_view *view = LIST_ENTRY( ptr, struct file_view, entry ); struct file_view *view = LIST_ENTRY( ptr, struct file_view, entry );
if ((char *)view->base >= (const char *)addr + size) break; if ((const char *)view->base >= (const char *)addr + size) break;
if ((char *)view->base + view->size > (const char *)addr) return view; if ((const char *)view->base + view->size > (const char *)addr) return view;
} }
return NULL; return NULL;
} }
@ -1063,7 +1063,7 @@ DWORD VIRTUAL_HandleFault( LPCVOID addr )
} }
else else
{ {
BYTE vprot = view->prot[((char *)addr - (char *)view->base) >> page_shift]; BYTE vprot = view->prot[((const char *)addr - (const char *)view->base) >> page_shift];
void *page = (void *)((UINT_PTR)addr & ~page_mask); void *page = (void *)((UINT_PTR)addr & ~page_mask);
char *stack = NtCurrentTeb()->Tib.StackLimit; char *stack = NtCurrentTeb()->Tib.StackLimit;
if (vprot & VPROT_GUARD) if (vprot & VPROT_GUARD)
@ -1072,7 +1072,7 @@ DWORD VIRTUAL_HandleFault( LPCVOID addr )
ret = STATUS_GUARD_PAGE_VIOLATION; ret = STATUS_GUARD_PAGE_VIOLATION;
} }
/* is it inside the stack guard page? */ /* is it inside the stack guard page? */
if (((char *)addr >= stack) && ((char *)addr < stack + (page_mask+1))) if (((const char *)addr >= stack) && ((const char *)addr < stack + (page_mask+1)))
ret = STATUS_STACK_OVERFLOW; ret = STATUS_STACK_OVERFLOW;
} }
} }