From db52588754150d19399b8f653cec5689bf9ee77b Mon Sep 17 00:00:00 2001 From: Eric Pouech Date: Tue, 15 Jun 2004 00:47:00 +0000 Subject: [PATCH] Const correctness. --- dlls/ntdll/heap.c | 36 ++++++------- dlls/ntdll/loader.c | 48 +++++++++-------- dlls/ntdll/loadorder.c | 4 +- dlls/ntdll/ntdll_misc.h | 4 +- dlls/ntdll/relay.c | 114 ++++++++++++++++++++-------------------- dlls/ntdll/resource.c | 16 +++--- dlls/ntdll/rtl.c | 2 +- dlls/ntdll/rtlbitmap.c | 2 +- dlls/ntdll/virtual.c | 10 ++-- 9 files changed, 120 insertions(+), 116 deletions(-) diff --git a/dlls/ntdll/heap.c b/dlls/ntdll/heap.c index c9b59806a86..6edfea5c035 100644 --- a/dlls/ntdll/heap.c +++ b/dlls/ntdll/heap.c @@ -317,14 +317,14 @@ static inline void HEAP_InsertFreeBlock( HEAP *heap, ARENA_FREE *pArena, BOOL la * NULL: Failure */ static SUBHEAP *HEAP_FindSubHeap( - HEAP *heap, /* [in] Heap pointer */ + const HEAP *heap, /* [in] Heap pointer */ LPCVOID ptr /* [in] Address */ ) { - SUBHEAP *sub = &heap->subheap; + const SUBHEAP *sub = &heap->subheap; while (sub) { - if (((char *)ptr >= (char *)sub) && - ((char *)ptr < (char *)sub + sub->size)) return sub; + if (((const char *)ptr >= (const char *)sub) && + ((const char *)ptr < (const char *)sub + sub->size)) return (SUBHEAP*)sub; sub = sub->next; } 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. */ -static BOOL HEAP_IsValidArenaPtr( HEAP *heap, void *ptr ) +static BOOL HEAP_IsValidArenaPtr( const HEAP *heap, const void *ptr ) { int i; - SUBHEAP *subheap = HEAP_FindSubHeap( heap, ptr ); + const SUBHEAP *subheap = HEAP_FindSubHeap( heap, ptr ); 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; 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; } @@ -813,9 +813,9 @@ static BOOL HEAP_ValidateFreeArena( SUBHEAP *subheap, ARENA_FREE *pArena ) /*********************************************************************** * 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 */ if ( (long)pArena % ALIGNMENT != 0 ) @@ -861,15 +861,15 @@ static BOOL HEAP_ValidateInUseArena( SUBHEAP *subheap, ARENA_INUSE *pArena, BOOL return FALSE; } /* 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", (DWORD)subheap->heap, (DWORD)pArena->size & ARENA_SIZE_MASK, (DWORD)pArena ); return FALSE; } /* Check next arena PREV_FREE flag */ - if (((char *)(pArena + 1) + (pArena->size & ARENA_SIZE_MASK) < heapEnd) && - (*(DWORD *)((char *)(pArena + 1) + (pArena->size & ARENA_SIZE_MASK)) & ARENA_FLAG_PREV_FREE)) + if (((const char *)(pArena + 1) + (pArena->size & ARENA_SIZE_MASK) < heapEnd) && + (*(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", (DWORD)subheap->heap, (DWORD)pArena ); @@ -878,7 +878,7 @@ static BOOL HEAP_ValidateInUseArena( SUBHEAP *subheap, ARENA_INUSE *pArena, BOOL /* Check prev free arena */ 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 */ if (!HEAP_IsValidArenaPtr( subheap->heap, pPrev )) { @@ -895,7 +895,7 @@ static BOOL HEAP_ValidateInUseArena( SUBHEAP *subheap, ARENA_INUSE *pArena, BOOL return FALSE; } /* 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", (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 */ if (!(subheap = HEAP_FindSubHeap( heapPtr, block )) || - ((char *)block < (char *)subheap + subheap->headerSize - + sizeof(ARENA_INUSE))) + ((const char *)block < (char *)subheap + subheap->headerSize + + sizeof(ARENA_INUSE))) { if (quiet == NOISY) 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 ); ret = FALSE; } 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)) RtlLeaveCriticalSection( &heapPtr->critSection ); diff --git a/dlls/ntdll/loader.c b/dlls/ntdll/loader.c index faf94f1e94f..81385c3fa87 100644 --- a/dlls/ntdll/loader.c +++ b/dlls/ntdll/loader.c @@ -106,7 +106,7 @@ static WINE_MODREF *cached_modref; static WINE_MODREF *current_modref; 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 ); /* 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 ) { - IMAGE_EXPORT_DIRECTORY *exports; + const IMAGE_EXPORT_DIRECTORY *exports; DWORD exp_size; WINE_MODREF *wm; WCHAR mod_name[32]; - char *end = strchr(forward, '.'); + const char *end = strchr(forward, '.'); FARPROC proc = 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 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 ) { FARPROC proc; - DWORD *functions = get_rva( module, exports->AddressOfFunctions ); + const DWORD *functions = get_rva( module, exports->AddressOfFunctions ); 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] ); /* if the address falls into the export dir, it's a forward */ - if (((char *)proc >= (char *)exports) && ((char *)proc < (char *)exports + exp_size)) - return find_forwarded_export( module, (char *)proc ); + if (((const char *)proc >= (const char *)exports) && + ((const char *)proc < (const char *)exports + exp_size)) + return find_forwarded_export( module, (const char *)proc ); 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. * 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 ) { - WORD *ordinals = get_rva( module, exports->AddressOfNameOrdinals ); - DWORD *names = get_rva( module, exports->AddressOfNames ); + const WORD *ordinals = get_rva( module, exports->AddressOfNameOrdinals ); + const DWORD *names = get_rva( module, exports->AddressOfNames ); int min = 0, max = exports->NumberOfNames - 1; /* 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. * 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; WINE_MODREF *wmImp; HMODULE imp_mod; - IMAGE_EXPORT_DIRECTORY *exports; + const IMAGE_EXPORT_DIRECTORY *exports; DWORD exp_size; - IMAGE_THUNK_DATA *import_list, *thunk_list; + const IMAGE_THUNK_DATA *import_list; + IMAGE_THUNK_DATA *thunk_list; WCHAR buffer[32]; - char *name = get_rva( module, descr->Name ); + const char *name = get_rva( module, descr->Name ); DWORD len = strlen(name) + 1; 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 ) { int i, nb_imports; - IMAGE_IMPORT_DESCRIPTOR *imports; + const IMAGE_IMPORT_DESCRIPTOR *imports; WINE_MODREF *prev; DWORD size; 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 ) { WINE_MODREF *wm; - WCHAR *p; - IMAGE_NT_HEADERS *nt = RtlImageNtHeader(hModule); + const WCHAR *p; + const IMAGE_NT_HEADERS *nt = RtlImageNtHeader(hModule); PLIST_ENTRY entry, mark; if (!(wm = RtlAllocateHeap( GetProcessHeap(), 0, sizeof(*wm) ))) return NULL; @@ -587,7 +589,7 @@ static NTSTATUS alloc_process_tls(void) { PLIST_ENTRY mark, entry; PLDR_MODULE mod; - IMAGE_TLS_DIRECTORY *dir; + const IMAGE_TLS_DIRECTORY *dir; ULONG size, i; 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); if ((const void *)mod->BaseAddress <= addr && - (char *)addr < (char*)mod->BaseAddress + mod->SizeOfImage) + (const char *)addr < (char*)mod->BaseAddress + mod->SizeOfImage) { *pmod = mod; return STATUS_SUCCESS; @@ -1972,12 +1974,14 @@ PIMAGE_SECTION_HEADER WINAPI RtlImageRvaToSection( const IMAGE_NT_HEADERS *nt, HMODULE module, DWORD rva ) { int i; - IMAGE_SECTION_HEADER *sec = (IMAGE_SECTION_HEADER*)((char*)&nt->OptionalHeader + - nt->FileHeader.SizeOfOptionalHeader); + const IMAGE_SECTION_HEADER *sec; + + sec = (const IMAGE_SECTION_HEADER*)((const char*)&nt->OptionalHeader + + nt->FileHeader.SizeOfOptionalHeader); for (i = 0; i < nt->FileHeader.NumberOfSections; i++, sec++) { if ((sec->VirtualAddress <= rva) && (sec->VirtualAddress + sec->SizeOfRawData > rva)) - return sec; + return (PIMAGE_SECTION_HEADER)sec; } return NULL; } diff --git a/dlls/ntdll/loadorder.c b/dlls/ntdll/loadorder.c index cc0dff69e05..4fc3f238e88 100644 --- a/dlls/ntdll/loadorder.c +++ b/dlls/ntdll/loadorder.c @@ -103,7 +103,7 @@ static struct loadorder_list env_list; */ 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) { - return strcmpiW( (WCHAR *)s1, (WCHAR *)s2 ); + return strcmpiW( (const WCHAR *)s1, (const WCHAR *)s2 ); } diff --git a/dlls/ntdll/ntdll_misc.h b/dlls/ntdll/ntdll_misc.h index 7954897a273..f3c920fa21d 100644 --- a/dlls/ntdll/ntdll_misc.h +++ b/dlls/ntdll/ntdll_misc.h @@ -61,9 +61,9 @@ extern void DECLSPEC_NORETURN server_abort_thread( int status ); /* module handling */ extern BOOL MODULE_GetSystemDirectory( UNICODE_STRING *sysdir ); 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 ); -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 ); extern void RELAY_SetupDLL( HMODULE hmod ); extern void SNOOP_SetupDLL( HMODULE hmod ); diff --git a/dlls/ntdll/relay.c b/dlls/ntdll/relay.c index e1dc7477501..2c7c750ee71 100644 --- a/dlls/ntdll/relay.c +++ b/dlls/ntdll/relay.c @@ -691,18 +691,18 @@ __ASM_GLOBAL_FUNC( RELAY_CallFrom32Regs, static BOOL is_register_entry_point( const BYTE *addr ) { extern void __wine_call_from_32_regs(); - int *offset; - void *ptr; + const int *offset; + const void *ptr; if (*addr != 0xe8) return FALSE; /* not a call */ /* check if call target is __wine_call_from_32_regs */ - offset = (int *)(addr + 1); - if (*offset == (char *)__wine_call_from_32_regs - (char *)(offset + 1)) return TRUE; + offset = (const int *)(addr + 1); + 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 */ - addr = (BYTE *)(offset + 1) + *offset; + addr = (const BYTE *)(offset + 1) + *offset; if (addr[0] != 0xff || addr[1] != 0x25) return FALSE; /* not an indirect jmp */ - ptr = *(void **)(addr + 2); /* get indirect jmp target address */ - return (*(char **)ptr == (char *)__wine_call_from_32_regs); + ptr = *(const void * const*)(addr + 2); /* get indirect jmp target address */ + 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. */ -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 ) { - DEBUG_ENTRY_POINT *debug = (DEBUG_ENTRY_POINT *)proc; - DEBUG_ENTRY_POINT *list = (DEBUG_ENTRY_POINT *)((char *)exports + exp_size); + const DEBUG_ENTRY_POINT *debug = (DEBUG_ENTRY_POINT *)proc; + const DEBUG_ENTRY_POINT *list = (const DEBUG_ENTRY_POINT *)((const char *)exports + exp_size); if (debug < list || debug >= list + exports->NumberOfFunctions) return proc; 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. */ -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, const WCHAR *user) { - int i; - const char *ename; - WORD *ordinals; - DWORD *names; - SNOOP_DLL *dll = firstdll; - SNOOP_FUN *fun; - IMAGE_SECTION_HEADER *sec; + int i; + const char *ename; + const WORD *ordinals; + const DWORD *names; + SNOOP_DLL *dll = firstdll; + SNOOP_FUN *fun; + const IMAGE_SECTION_HEADER *sec; - if (!TRACE_ON(snoop)) return origfun; - if (!check_from_module( debug_from_snoop_includelist, debug_from_snoop_excludelist, user )) - return origfun; /* the calling module was explicitly excluded */ + if (!TRACE_ON(snoop)) return origfun; + if (!check_from_module( debug_from_snoop_includelist, debug_from_snoop_excludelist, user )) + return origfun; /* the calling module was explicitly excluded */ - if (!*(LPBYTE)origfun) /* 0x00 is an imposs. opcode, poss. dataref. */ - return origfun; + if (!*(LPBYTE)origfun) /* 0x00 is an imposs. opcode, poss. dataref. */ + 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)) - return origfun; /* most likely a data reference */ + if (!sec || !(sec->Characteristics & IMAGE_SCN_CNT_CODE)) + return origfun; /* most likely a data reference */ - while (dll) { - if (hmod == dll->hmod) - break; - dll=dll->next; - } - if (!dll) /* probably internal */ - return origfun; + while (dll) { + if (hmod == dll->hmod) + break; + dll = dll->next; + } + if (!dll) /* probably internal */ + return origfun; - /* try to find a name for it */ - ename = NULL; - names = (DWORD *)((char *)hmod + exports->AddressOfNames); - ordinals = (WORD *)((char *)hmod + exports->AddressOfNameOrdinals); - if (names) for (i = 0; i < exports->NumberOfNames; i++) + /* try to find a name for it */ + ename = NULL; + names = (const DWORD *)((const char *)hmod + exports->AddressOfNames); + ordinals = (const WORD *)((const char *)hmod + exports->AddressOfNameOrdinals); + if (names) for (i = 0; i < exports->NumberOfNames; i++) + { + if (ordinals[i] == ordinal) { - if (ordinals[i] == ordinal) - { - ename = (char *)hmod + names[i]; - break; - } + ename = (const char *)hmod + names[i]; + break; } - if (!SNOOP_ShowDebugmsgSnoop(dll->name,ordinal,ename)) - return origfun; - assert(ordinal < dll->nrofordinals); - fun = dll->funs+ordinal; - if (!fun->name) - { - fun->name = ename; - fun->lcall = 0xe8; - /* NOTE: origreturn struct member MUST come directly after snoopentry */ - fun->snoopentry = (char*)SNOOP_Entry-((char*)(&fun->nrofargs)); - fun->origfun = origfun; - fun->nrofargs = -1; - } - return (FARPROC)&(fun->lcall); + } + if (!SNOOP_ShowDebugmsgSnoop(dll->name,ordinal,ename)) + return origfun; + assert(ordinal < dll->nrofordinals); + fun = dll->funs + ordinal; + if (!fun->name) + { + fun->name = ename; + fun->lcall = 0xe8; + /* NOTE: origreturn struct member MUST come directly after snoopentry */ + fun->snoopentry = (char*)SNOOP_Entry-((char*)(&fun->nrofargs)); + fun->origfun = origfun; + fun->nrofargs = -1; + } + return (FARPROC)&(fun->lcall); } static void SNOOP_PrintArg(DWORD x) diff --git a/dlls/ntdll/resource.c b/dlls/ntdll/resource.c index 47499954338..a97e303dfbb 100644 --- a/dlls/ntdll/resource.c +++ b/dlls/ntdll/resource.c @@ -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++) { 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; } @@ -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) { TRACE("root %p dir %p id %04x ret %p\n", - root, dir, id, (char *)root + entry[pos].u2.s3.OffsetToDirectory); - return (IMAGE_RESOURCE_DIRECTORY *)((char *)root + entry[pos].u2.s3.OffsetToDirectory); + root, dir, id, (const char*)root + entry[pos].u2.s3.OffsetToDirectory); + return (const IMAGE_RESOURCE_DIRECTORY *)((const char *)root + entry[pos].u2.s3.OffsetToDirectory); } break; } @@ -161,15 +161,15 @@ static const IMAGE_RESOURCE_DIRECTORY *find_entry_by_name( const IMAGE_RESOURCE_ while (min <= max) { 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 ); if (!res && namelen == str->Length) { if (!entry[pos].u2.s3.DataIsDirectory == !want_dir) { TRACE("root %p dir %p name %s ret %p\n", - root, dir, debugstr_w(name), (char *)root + entry[pos].u2.s3.OffsetToDirectory); - return (IMAGE_RESOURCE_DIRECTORY *)((char *)root + entry[pos].u2.s3.OffsetToDirectory); + root, dir, debugstr_w(name), (const char*)root + entry[pos].u2.s3.OffsetToDirectory); + return (const IMAGE_RESOURCE_DIRECTORY *)((const char *)root + entry[pos].u2.s3.OffsetToDirectory); } break; } @@ -389,9 +389,9 @@ NTSTATUS WINAPI RtlFindMessage( HMODULE hmod, ULONG type, ULONG lang, { 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--) - entry = (MESSAGE_RESOURCE_ENTRY *)((char *)entry + entry->Length); + entry = (const MESSAGE_RESOURCE_ENTRY *)((const char *)entry + entry->Length); *ret = entry; return STATUS_SUCCESS; } diff --git a/dlls/ntdll/rtl.c b/dlls/ntdll/rtl.c index 3a477d6b9be..dd4c88a7ebb 100644 --- a/dlls/ntdll/rtl.c +++ b/dlls/ntdll/rtl.c @@ -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 i; - for(i=0; (iSizeOfRun > ((PRTL_BITMAP_RUN)rhs)->SizeOfRun) + if (((const RTL_BITMAP_RUN*)lhs)->SizeOfRun > ((const RTL_BITMAP_RUN*)rhs)->SizeOfRun) return -1; return 1; } diff --git a/dlls/ntdll/virtual.c b/dlls/ntdll/virtual.c index 64d4ff065d2..3d9128a54b8 100644 --- a/dlls/ntdll/virtual.c +++ b/dlls/ntdll/virtual.c @@ -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 ); 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; } @@ -241,8 +241,8 @@ static struct file_view *find_view_range( const void *addr, size_t size ) LIST_FOR_EACH( ptr, &views_list ) { struct file_view *view = LIST_ENTRY( ptr, struct file_view, entry ); - if ((char *)view->base >= (const char *)addr + size) break; - if ((char *)view->base + view->size > (const char *)addr) return view; + if ((const char *)view->base >= (const char *)addr + size) break; + if ((const char *)view->base + view->size > (const char *)addr) return view; } return NULL; } @@ -1063,7 +1063,7 @@ DWORD VIRTUAL_HandleFault( LPCVOID addr ) } 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); char *stack = NtCurrentTeb()->Tib.StackLimit; if (vprot & VPROT_GUARD) @@ -1072,7 +1072,7 @@ DWORD VIRTUAL_HandleFault( LPCVOID addr ) ret = STATUS_GUARD_PAGE_VIOLATION; } /* 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; } }