- Make imagehlp compile warning free (don't mix Wine and ros debug style, add missing casts)

svn path=/trunk/; revision=37817
This commit is contained in:
Stefan Ginsberg
2008-12-03 13:05:54 +00:00
parent 902da9ebac
commit 2220f06c73
5 changed files with 42 additions and 50 deletions
+6 -8
View File
@@ -20,8 +20,6 @@
#include "precomp.h"
//#define NDEBUG
#include <debug.h>
#define _WINNT_H
#include "wine/debug.h"
@@ -122,7 +120,7 @@ PLOADED_IMAGE IMAGEAPI ImageLoad(LPSTR DllName, LPSTR DllPath)
/* Move to the Next DLL */
Head = &ImageLoadListHead;
Next = Head->Flink;
DPRINT("Trying to find library: %s in current ListHead \n", DllName);
TRACE("Trying to find library: %s in current ListHead \n", DllName);
/* Split the path */
_splitpath(DllName, Drive, Dir, Filename, Ext);
@@ -135,7 +133,7 @@ PLOADED_IMAGE IMAGEAPI ImageLoad(LPSTR DllName, LPSTR DllPath)
{
/* Get the Loaded Image Structure */
LoadedImage = CONTAINING_RECORD(Next, LOADED_IMAGE, Links);
DPRINT("Found: %s in current ListHead \n", LoadedImage->ModuleName);
TRACE("Found: %s in current ListHead \n", LoadedImage->ModuleName);
/* Check if we didn't have a complete name */
if (!CompleteName)
@@ -156,7 +154,7 @@ PLOADED_IMAGE IMAGEAPI ImageLoad(LPSTR DllName, LPSTR DllPath)
/* Check if the Names Match */
if (!_stricmp(DllName, FullName))
{
DPRINT("Found it, returning it\n");
TRACE("Found it, returning it\n");
return LoadedImage;
}
@@ -165,7 +163,7 @@ PLOADED_IMAGE IMAGEAPI ImageLoad(LPSTR DllName, LPSTR DllPath)
}
/* Allocate memory for the Structure, and write the Module Name under */
DPRINT("Didn't find it...allocating it for you now\n");
TRACE("Didn't find it...allocating it for you now\n");
LoadedImage = HeapAlloc(IMAGEHLP_hHeap,
0,
sizeof(*LoadedImage) + strlen(DllName) + 1);
@@ -255,14 +253,14 @@ BOOL IMAGEAPI MapAndLoad(
ImageName,
DotDll ? ".dll" : ".exe",
MAX_PATH,
Buffer,
(PSTR)Buffer,
&FilePart);
/* Check if it was successful */
if (Tried && (Tried < MAX_PATH))
{
/* Change the filename to use, and try again */
FileToOpen = Buffer;
FileToOpen = (PSTR)Buffer;
continue;
}
}
+1 -1
View File
@@ -1,4 +1,4 @@
<module name="imagehlp" type="win32dll" baseaddress="${BASEADDRESS_IMAGEHLP}" installbase="system32" installname="imagehlp.dll" allowwarnings="true">
<module name="imagehlp" type="win32dll" baseaddress="${BASEADDRESS_IMAGEHLP}" installbase="system32" installname="imagehlp.dll">
<importlibrary definition="imagehlp.spec" />
<include base="imagehlp">.</include>
<define name="_IMAGEHLP_SOURCE_"></define>
@@ -24,8 +24,6 @@
#include "precomp.h"
//#define NDEBUG
#include <debug.h>
#define _WINNT_H
#include "wine/debug.h"
+2 -4
View File
@@ -28,8 +28,6 @@
#include "precomp.h"
//#define NDEBUG
#include <debug.h>
#define _WINNT_H
#include "wine/debug.h"
@@ -293,7 +291,7 @@ BOOL IMAGEAPI ImageGetCertificateHeader(
const size_t cert_hdr_size = sizeof *Certificateheader -
sizeof Certificateheader->bCertificate;
DPRINT("%p %ld %p\n", FileHandle, CertificateIndex, Certificateheader);
TRACE("%p %ld %p\n", FileHandle, CertificateIndex, Certificateheader);
if( !IMAGEHLP_GetCertificateOffset( FileHandle, CertificateIndex, &ofs, &size ) )
return FALSE;
@@ -354,7 +352,7 @@ CheckSumMappedFile(LPVOID BaseAddress,
PIMAGE_NT_HEADERS Header;
DWORD CalcSum;
DWORD HdrSum;
DPRINT("stub\n");
TRACE("stub\n");
CalcSum = (DWORD)CalcCheckSum(0,
BaseAddress,
+33 -35
View File
@@ -21,8 +21,6 @@
#include "precomp.h"
//#define NDEBUG
#include <debug.h>
#define _WINNT_H
#include "wine/debug.h"
@@ -159,12 +157,12 @@ NextForwarder:
strcat(DllName, ".DLL");
/* Load it */
DPRINT("Loading the Thunk Library: %s \n", DllName);
TRACE("Loading the Thunk Library: %s \n", DllName);
Library = ImageLoad(DllName, DllPath);
if (!Library) return ForwarderString;
/* Move past the name */
DPRINT("It Loaded at: %p \n", Library->MappedAddress);
TRACE("It Loaded at: %p \n", Library->MappedAddress);
FunctionName = TempDllName += 1;
/* Load Exports */
@@ -275,7 +273,7 @@ NextForwarder:
ExportsBase += OptionalHeader->ImageBase;
/* Is this yet another Forward? */
DPRINT("I've thunked it\n");
TRACE("I've thunked it\n");
if ((ForwardedAddress > ExportsBase) &&
(ForwardedAddress < (ExportsBase + ExportSize)))
{
@@ -289,7 +287,7 @@ NextForwarder:
else
{
/* Update the pointer and return success */
ForwarderString = (PUCHAR)ForwardedAddress;
ForwarderString = (PCHAR)ForwardedAddress;
*ForwarderBound = TRUE;
}
@@ -323,7 +321,7 @@ BindpLookupThunk(PIMAGE_THUNK_DATA Thunk,
PIMAGE_OPTIONAL_HEADER LibraryOptionalHeader = NULL;
BOOL ForwarderBound = FALSE;
PUCHAR ForwarderName;
DPRINT("Binding a Thunk\n");
TRACE("Binding a Thunk\n");
/* Get the Pointers to the Tables */
AddressOfNames = ImageRvaToVa(Library->FileHeader,
@@ -351,7 +349,7 @@ BindpLookupThunk(PIMAGE_THUNK_DATA Thunk,
ImportName = (PIMAGE_IMPORT_BY_NAME)NameBuffer;
/* Setup the name for this ordinal */
sprintf(ImportName->Name, "Ordinal%lx\n", OrdinalNumber);
sprintf((PCHAR)ImportName->Name, "Ordinal%lx\n", OrdinalNumber);
}
else
{
@@ -372,7 +370,7 @@ BindpLookupThunk(PIMAGE_THUNK_DATA Thunk,
(ULONG)AddressOfNames[HintIndex],
&Library->LastRvaSection);
/* Check if it's the one we want */
if (!strcmp(ImportName->Name, ExportName))
if (!strcmp((PCHAR)ImportName->Name, ExportName))
{
OrdinalNumber = AddressOfOrdinals[HintIndex];
}
@@ -390,7 +388,7 @@ BindpLookupThunk(PIMAGE_THUNK_DATA Thunk,
&Library->LastRvaSection);
/* Check if it's the one we want */
if (!strcmp(ImportName->Name, ExportName))
if (!strcmp((PCHAR)ImportName->Name, ExportName))
{
OrdinalNumber = AddressOfOrdinals[HintIndex];
break;
@@ -423,7 +421,7 @@ BindpLookupThunk(PIMAGE_THUNK_DATA Thunk,
/* Make sure we have a descriptor */
if (BoundImportDescriptor)
{
DPRINT("This Thunk is a forward...calling forward thunk bounder\n");
TRACE("This Thunk is a forward...calling forward thunk bounder\n");
/* Get the VA of the pointer containg the name */
ForwarderName = ImageRvaToVa(Library->FileHeader,
@@ -434,10 +432,10 @@ BindpLookupThunk(PIMAGE_THUNK_DATA Thunk,
/* Replace the Forwarder String by the actual name */
ThunkFunction->u1.ForwarderString =
PtrToUlong(BindpAddForwarderReference(Image->ModuleName,
ImportName->Name,
(PCHAR)ImportName->Name,
BoundImportDescriptor,
DllPath,
ForwarderName,
(PCHAR)ForwarderName,
&ForwarderBound));
}
@@ -493,7 +491,7 @@ BindpCreateNewImportSection(PIMPORT_DESCRIPTOR *BoundImportDescriptor,
/* Add Terminator for PE Loader*/
BoundImportTableSize += sizeof(IMAGE_BOUND_IMPORT_DESCRIPTOR);
DPRINT("Table size: %lx\n", BoundImportTableSize);
TRACE("Table size: %lx\n", BoundImportTableSize);
/* Name of Libraries Bound in Bound Import Table */
BoundLibraryNamesSize = (ULONG)((ULONG_PTR)BoundLibrariesPointer -
@@ -521,7 +519,7 @@ BindpCreateNewImportSection(PIMPORT_DESCRIPTOR *BoundImportDescriptor,
{
/* Copy the data */
BoundTableEntry->TimeDateStamp = Descriptor->TimeDateStamp;
BoundTableEntry->OffsetModuleName = (USHORT)(BoundImportTableSize +
BoundTableEntry->OffsetModuleName = (USHORT)(ULONG_PTR)(BoundImportTableSize +
(Descriptor->ModuleName -
(ULONG_PTR)BoundLibraries));
BoundTableEntry->NumberOfModuleForwarderRefs = Descriptor->ForwaderReferences;
@@ -533,7 +531,7 @@ BindpCreateNewImportSection(PIMPORT_DESCRIPTOR *BoundImportDescriptor,
{
/* Copy the data */
BoundForwarder->TimeDateStamp = Forwarder->TimeDateStamp;
BoundForwarder->OffsetModuleName = (USHORT)(BoundImportTableSize +
BoundForwarder->OffsetModuleName = (USHORT)(ULONG_PTR)(BoundImportTableSize +
(Forwarder->ModuleName -
(ULONG_PTR)BoundLibraries));
@@ -601,7 +599,7 @@ BindpWalkAndProcessImports(PLOADED_IMAGE File,
ULONG BoundImportTableSize, OldBoundImportTableSize;
ULONG VirtBytesFree, HeaderBytesFree, FirstFreeByte, PhysBytesFree;
BOOL ThunkStatus;
DPRINT("BindpWalkAndBindImports Called\n");
TRACE("BindpWalkAndBindImports Called\n");
/* Assume untouched image */
*UpdateImage = FALSE;
@@ -636,7 +634,7 @@ BindpWalkAndProcessImports(PLOADED_IMAGE File,
&File->LastRvaSection);
if (ImportedLibrary)
{
DPRINT("Loading Imported DLL: %s \n", ImportedLibrary);
TRACE("Loading Imported DLL: %s \n", ImportedLibrary);
/* Load the DLL */
LoadedLibrary = ImageLoad(ImportedLibrary, DllPath);
@@ -654,7 +652,7 @@ BindpWalkAndProcessImports(PLOADED_IMAGE File,
}
/* Now load the Exports */
DPRINT("DLL Loaded at: %p \n", LoadedLibrary->MappedAddress);
TRACE("DLL Loaded at: %p \n", LoadedLibrary->MappedAddress);
Exports = ImageDirectoryEntryToData(LoadedLibrary->MappedAddress,
FALSE,
IMAGE_DIRECTORY_ENTRY_EXPORT,
@@ -673,7 +671,7 @@ BindpWalkAndProcessImports(PLOADED_IMAGE File,
if (!(Thunks) || !(Thunks->u1.Function)) continue;
/* Create Bound Import Descriptor */
DPRINT("Creating Bound Descriptor for this DLL\n");
TRACE("Creating Bound Descriptor for this DLL\n");
BoundImportDescriptor = BindpAddImportDescriptor(&TopBoundDescriptor,
Imports,
ImportedLibrary,
@@ -695,7 +693,7 @@ BindpWalkAndProcessImports(PLOADED_IMAGE File,
SizeOfThunks);
/* Setup the initial data pointers */
DPRINT("Binding Thunks\n");
TRACE("Binding Thunks\n");
TempThunk = Thunks;
TempBoundThunk = BoundThunks;
TopForwarderChain = -1;
@@ -760,7 +758,7 @@ BindpWalkAndProcessImports(PLOADED_IMAGE File,
if (memcmp(TempThunk, BoundThunks, SizeOfThunks))
{
/* Copy the Pointers and let caller know */
DPRINT("Copying Bound Thunks\n");
TRACE("Copying Bound Thunks\n");
RtlCopyMemory(TempThunk, BoundThunks, SizeOfThunks);
*UpdateImage = TRUE;
}
@@ -786,13 +784,13 @@ BindpWalkAndProcessImports(PLOADED_IMAGE File,
/* Free the Allocated Memory */
HeapFree(IMAGEHLP_hHeap, 0, BoundThunks);
DPRINT("Moving to next File\n");
TRACE("Moving to next File\n");
Imports++;
}
}
/* Create the Bound Import Table */
DPRINT("Creating Bound Import Section\n");
TRACE("Creating Bound Import Section\n");
BoundImportTable = BindpCreateNewImportSection(&TopBoundDescriptor,
&BoundImportTableSize);
@@ -817,7 +815,7 @@ BindpWalkAndProcessImports(PLOADED_IMAGE File,
OptionalHeader->DataDirectory[IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT].Size = 0;
/* Check if we have enough space */
DPRINT("Calculating Space\n");
TRACE("Calculating Space\n");
FirstFreeByte = GetImageUnusedHeaderBytes(File, &VirtBytesFree);
HeaderBytesFree = File->Sections->VirtualAddress -
OptionalHeader->SizeOfHeaders + VirtBytesFree;
@@ -830,7 +828,7 @@ BindpWalkAndProcessImports(PLOADED_IMAGE File,
/* Check if we have no space a tall */
if (BoundImportTableSize > HeaderBytesFree)
{
DPRINT1("Not enough Space\n");
ERR("Not enough Space\n");
return; /* Fail...not enough space */
}
@@ -838,7 +836,7 @@ BindpWalkAndProcessImports(PLOADED_IMAGE File,
if (BoundImportTableSize <= PhysBytesFree)
{
/* We have enough NULLs to add it, simply enlarge header data */
DPRINT("Header Recalculation\n");
TRACE("Header Recalculation\n");
OptionalHeader->SizeOfHeaders = OptionalHeader->SizeOfHeaders -
VirtBytesFree +
BoundImportTableSize +
@@ -848,7 +846,7 @@ BindpWalkAndProcessImports(PLOADED_IMAGE File,
else
{
/* Resize the Headers */
DPRINT1("UNIMPLEMENTED: Header Resizing\n");
FIXME("UNIMPLEMENTED: Header Resizing\n");
/* Recalculate Headers */
FileHeader = &File->FileHeader->FileHeader;
@@ -863,7 +861,7 @@ BindpWalkAndProcessImports(PLOADED_IMAGE File,
[IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT].Size = BoundImportTableSize;
/* Copy the Bound Import Table */
DPRINT("Copying Bound Import Table\n");
TRACE("Copying Bound Import Table\n");
RtlCopyMemory(File->MappedAddress + FirstFreeByte,
BoundImportTable,
BoundImportTableSize);
@@ -890,7 +888,7 @@ BOOL IMAGEAPI BindImageEx(
FILETIME LastWriteTime;
BOOLEAN UpdateImage;
DWORD DataSize;
DPRINT("BindImageEx Called for: %s \n", ImageName);
TRACE("BindImageEx Called for: %s \n", ImageName);
/* Set and Clear Buffer */
File = &FileData;
@@ -900,7 +898,7 @@ BOOL IMAGEAPI BindImageEx(
if (MapAndLoad(ImageName, DllPath, File, TRUE, FALSE))
{
/* Write the image's name */
DPRINT("Image Mapped and Loaded\n");
TRACE("Image Mapped and Loaded\n");
File->ModuleName = ImageName;
/* Check if the image is valid and if it should be bound */
@@ -938,7 +936,7 @@ BOOL IMAGEAPI BindImageEx(
/* FIXME: Update symbols */
/* Update Checksum */
DPRINT("Binding Completed, getting Checksum\n");
TRACE("Binding Completed, getting Checksum\n");
OldChecksum = File->FileHeader->OptionalHeader.CheckSum;
CheckSumMappedFile(File->MappedAddress,
GetFileSize(File->hFile, NULL),
@@ -947,11 +945,11 @@ BOOL IMAGEAPI BindImageEx(
File->FileHeader->OptionalHeader.CheckSum = CheckSum;
/* Save Changes */
DPRINT("Saving Changes to file\n");
TRACE("Saving Changes to file\n");
FlushViewOfFile(File->MappedAddress, File->SizeOfImage);
/* Save new Modified Time */
DPRINT("Setting time\n");
TRACE("Setting time\n");
GetSystemTime(&SystemTime);
SystemTimeToFileTime(&SystemTime, &LastWriteTime);
SetFileTime(File->hFile, NULL, NULL, &LastWriteTime);
@@ -971,7 +969,7 @@ Skip:
if (!(Flags & BIND_CACHE_IMPORT_DLLS)) UnloadAllImages();
/* Return success */
DPRINT("Done\n");
TRACE("Done\n");
return TRUE;
}