Commit 613ead7f authored by Alexandre Julliard's avatar Alexandre Julliard

Fixed some handle conversions in prevision of void* handles.

parent dd0c4c16
......@@ -37,7 +37,7 @@ static PLOADED_IMAGE IMAGEHLP_pLastLoadedImage=NULL;
static LOADED_IMAGE IMAGEHLP_EmptyLoadedImage = {
NULL, /* ModuleName */
0xffffffff, /* hFile */
0, /* hFile */
NULL, /* MappedAddress */
NULL, /* FileHeader */
NULL, /* LastRvaSection */
......@@ -317,5 +317,3 @@ BOOL WINAPI UnMapAndLoad(PLOADED_IMAGE LoadedImage)
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
return FALSE;
}
......@@ -453,7 +453,7 @@ int MSVCRT_system(const char* cmd)
*/
int _loaddll(const char* dllname)
{
return LoadLibraryA(dllname);
return (int)LoadLibraryA(dllname);
}
/*********************************************************************
......@@ -461,7 +461,7 @@ int _loaddll(const char* dllname)
*/
int _unloaddll(int dll)
{
if (FreeLibrary((HANDLE)dll))
if (FreeLibrary((HMODULE)dll))
return 0;
else
{
......
......@@ -181,8 +181,8 @@ BOOL16 WINAPI GetIconInfo16(HICON16 hIcon, LPICONINFO16 iconinfo)
iconinfo->fIcon = ii32.fIcon;
iconinfo->xHotspot = ii32.xHotspot;
iconinfo->yHotspot = ii32.yHotspot;
iconinfo->hbmMask = ii32.hbmMask;
iconinfo->hbmColor = ii32.hbmColor;
iconinfo->hbmMask = HBITMAP_16(ii32.hbmMask);
iconinfo->hbmColor = HBITMAP_16(ii32.hbmColor);
return ret;
}
......@@ -204,8 +204,7 @@ HCURSOR16 WINAPI CreateCursor16(HINSTANCE16 hInstance,
info.bPlanes = 1;
info.bBitsPerPixel = 1;
return CreateCursorIconIndirect16(HINSTANCE_32(hInstance), &info, lpANDbits,
lpXORbits);
return CreateCursorIconIndirect16(hInstance, &info, lpANDbits, lpXORbits);
}
/**********************************************************************
......
......@@ -1074,7 +1074,7 @@ HANDLE WINAPI AddPrinterW(LPWSTR pName, DWORD Level, LPBYTE pPrinter)
* just create to find a DEVMODEA struct (it will use the WINEPS default
* one in case it is not there, so we are ok).
*/
size = DocumentPropertiesW(0, -1, pi->pPrinterName, NULL, NULL, 0);
size = DocumentPropertiesW(0, 0, pi->pPrinterName, NULL, NULL, 0);
if(size < 0) {
FIXME("DocumentPropertiesW on printer '%s' fails\n", debugstr_w(pi->pPrinterName));
size = sizeof(DEVMODEW);
......@@ -1084,7 +1084,7 @@ HANDLE WINAPI AddPrinterW(LPWSTR pName, DWORD Level, LPBYTE pPrinter)
else {
dmW = HeapAlloc(GetProcessHeap(), 0, size);
dmW->dmSize = size;
if (0>DocumentPropertiesW(0,-1,pi->pPrinterName,dmW,NULL,DM_OUT_BUFFER)) {
if (0>DocumentPropertiesW(0,0,pi->pPrinterName,dmW,NULL,DM_OUT_BUFFER)) {
ERR("DocumentPropertiesW on printer '%s' failed!\n", debugstr_w(pi->pPrinterName));
SetLastError(ERROR_UNKNOWN_PRINTER_DRIVER);
return 0;
......
......@@ -114,7 +114,7 @@ typedef struct tagMODULEENTRY32
DWORD ProccntUsage;
BYTE *modBaseAddr;
DWORD modBaseSize;
DWORD hModule;
HMODULE hModule;
char szModule[MAX_MODULE_NAME32 + 1];
char szExePath[MAX_PATH];
} MODULEENTRY32, *PMODULEENTRY32, *LPMODULEENTRY32;
......@@ -128,7 +128,7 @@ typedef struct tagMODULEENTRY32W
DWORD ProccntUsage;
BYTE *modBaseAddr;
DWORD modBaseSize;
DWORD hModule;
HMODULE hModule;
WCHAR szModule[MAX_MODULE_NAME32 + 1];
WCHAR szExePath[MAX_PATH];
} MODULEENTRY32W, *PMODULEENTRY32W, *LPMODULEENTRY32W;
......
......@@ -56,7 +56,10 @@ WINE_DECLARE_DEBUG_CHANNEL(segment);
/* convert PE image VirtualAddress to Real Address */
#define RVA(x) ((void *)((char *)load_addr+(unsigned int)(x)))
inline static void *get_rva( HMODULE module, DWORD va )
{
return (void *)((char *)module + va);
}
#define AdjustPtr(ptr,delta) ((char *)(ptr) + (delta))
......@@ -66,37 +69,36 @@ void dump_exports( HMODULE hModule )
int i, j;
WORD *ordinal;
DWORD *function,*functions;
BYTE **name;
unsigned int load_addr = hModule;
DWORD *name;
IMAGE_EXPORT_DIRECTORY *pe_exports;
DWORD rva_start, size;
pe_exports = RtlImageDirectoryEntryToData( hModule, TRUE, IMAGE_DIRECTORY_ENTRY_EXPORT, &size );
rva_start = (char *)pe_exports - (char *)hModule;
Module = (char*)RVA(pe_exports->Name);
Module = get_rva(hModule, pe_exports->Name);
DPRINTF("*******EXPORT DATA*******\n");
DPRINTF("Module name is %s, %ld functions, %ld names\n",
Module, pe_exports->NumberOfFunctions, pe_exports->NumberOfNames);
ordinal = RVA(pe_exports->AddressOfNameOrdinals);
functions = function = RVA(pe_exports->AddressOfFunctions);
name = RVA(pe_exports->AddressOfNames);
ordinal = get_rva(hModule, pe_exports->AddressOfNameOrdinals);
functions = function = get_rva(hModule, pe_exports->AddressOfFunctions);
name = get_rva(hModule, pe_exports->AddressOfNames);
DPRINTF(" Ord RVA Addr Name\n" );
for (i=0;i<pe_exports->NumberOfFunctions;i++, function++)
{
if (!*function) continue; /* No such function */
DPRINTF( "%4ld %08lx %p", i + pe_exports->Base, *function, RVA(*function) );
DPRINTF( "%4ld %08lx %p", i + pe_exports->Base, *function, get_rva(hModule, *function) );
/* Check if we have a name for it */
for (j = 0; j < pe_exports->NumberOfNames; j++)
if (ordinal[j] == i)
{
DPRINTF( " %s", (char*)RVA(name[j]) );
DPRINTF( " %s", (char*)get_rva(hModule, name[j]) );
break;
}
if ((*function >= rva_start) && (*function <= rva_start + size))
DPRINTF(" (forwarded -> %s)", (char *)RVA(*function));
DPRINTF(" (forwarded -> %s)", (char *)get_rva(hModule, *function));
DPRINTF("\n");
}
}
......@@ -117,11 +119,11 @@ static FARPROC PE_FindExportedFunction(
{
WORD * ordinals;
DWORD * function;
BYTE ** name, *ename = NULL;
int i, ordinal;
unsigned int load_addr = wm->module;
DWORD rva_start, addr;
char * forward;
DWORD *name;
char *ename = NULL;
FARPROC proc;
IMAGE_EXPORT_DIRECTORY *exports;
DWORD exp_size;
......@@ -133,9 +135,9 @@ static FARPROC PE_FindExportedFunction(
if (HIWORD(funcName)) TRACE("(%s)\n",funcName);
else TRACE("(%d)\n",LOWORD(funcName));
ordinals= RVA(exports->AddressOfNameOrdinals);
function= RVA(exports->AddressOfFunctions);
name = RVA(exports->AddressOfNames);
ordinals= get_rva(wm->module, exports->AddressOfNameOrdinals);
function= get_rva(wm->module, exports->AddressOfFunctions);
name = get_rva(wm->module, exports->AddressOfNames);
forward = NULL;
rva_start = (char *)exports - (char *)wm->module;
......@@ -146,7 +148,7 @@ static FARPROC PE_FindExportedFunction(
/* first check the hint */
if (hint >= 0 && hint <= max)
{
ename = RVA(name[hint]);
ename = get_rva(wm->module, name[hint]);
if (!strcmp( ename, funcName ))
{
ordinal = ordinals[hint];
......@@ -158,7 +160,7 @@ static FARPROC PE_FindExportedFunction(
while (min <= max)
{
int res, pos = (min + max) / 2;
ename = RVA(name[pos]);
ename = get_rva(wm->module, name[pos]);
if (!(res = strcmp( ename, funcName )))
{
ordinal = ordinals[pos];
......@@ -177,7 +179,7 @@ static FARPROC PE_FindExportedFunction(
for (i = 0; i < exports->NumberOfNames; i++)
if (ordinals[i] == ordinal)
{
ename = RVA(name[i]);
ename = get_rva(wm->module, name[i]);
break;
}
}
......@@ -192,7 +194,7 @@ static FARPROC PE_FindExportedFunction(
addr = function[ordinal];
if (!addr) return NULL;
proc = RVA(addr);
proc = get_rva(wm->module, addr);
if (((char *)proc < (char *)exports) || ((char *)proc >= (char *)exports + exp_size))
{
if (snoop)
......@@ -229,7 +231,6 @@ static FARPROC PE_FindExportedFunction(
*/
DWORD PE_fixup_imports( WINE_MODREF *wm )
{
unsigned int load_addr = wm->module;
int i,characteristics_detection=1;
IMAGE_IMPORT_DESCRIPTOR *imports, *pe_imp;
DWORD size;
......@@ -268,7 +269,7 @@ DWORD PE_fixup_imports( WINE_MODREF *wm )
WINE_MODREF *wmImp;
IMAGE_IMPORT_BY_NAME *pe_name;
PIMAGE_THUNK_DATA import_list,thunk_list;
char *name = (char *) RVA(pe_imp->Name);
char *name = get_rva(wm->module, pe_imp->Name);
if (characteristics_detection && !pe_imp->u.Characteristics)
break;
......@@ -284,8 +285,8 @@ DWORD PE_fixup_imports( WINE_MODREF *wm )
if (pe_imp->u.OriginalFirstThunk != 0) { /* original MS style */
TRACE("Microsoft style imports used\n");
import_list =(PIMAGE_THUNK_DATA) RVA(pe_imp->u.OriginalFirstThunk);
thunk_list = (PIMAGE_THUNK_DATA) RVA(pe_imp->FirstThunk);
import_list = get_rva(wm->module, (DWORD)pe_imp->u.OriginalFirstThunk);
thunk_list = get_rva(wm->module, (DWORD)pe_imp->FirstThunk);
while (import_list->u1.Ordinal) {
if (IMAGE_SNAP_BY_ORDINAL(import_list->u1.Ordinal)) {
......@@ -301,7 +302,7 @@ DWORD PE_fixup_imports( WINE_MODREF *wm )
thunk_list->u1.Function = (PDWORD)0xdeadbeef;
}
} else { /* import by name */
pe_name = (PIMAGE_IMPORT_BY_NAME)RVA(import_list->u1.AddressOfData);
pe_name = get_rva(wm->module, (DWORD)import_list->u1.AddressOfData);
TRACE("--- %s %s.%d\n", pe_name->Name, name, pe_name->Hint);
thunk_list->u1.Function=(PDWORD)MODULE_GetProcAddress(
wmImp->module, pe_name->Name, pe_name->Hint, TRUE
......@@ -317,7 +318,7 @@ DWORD PE_fixup_imports( WINE_MODREF *wm )
}
} else { /* Borland style */
TRACE("Borland style imports used\n");
thunk_list = (PIMAGE_THUNK_DATA) RVA(pe_imp->FirstThunk);
thunk_list = get_rva(wm->module, (DWORD)pe_imp->FirstThunk);
while (thunk_list->u1.Ordinal) {
if (IMAGE_SNAP_BY_ORDINAL(thunk_list->u1.Ordinal)) {
/* not sure about this branch, but it seems to work */
......@@ -333,7 +334,7 @@ DWORD PE_fixup_imports( WINE_MODREF *wm )
thunk_list->u1.Function = (PDWORD)0xdeadbeef;
}
} else {
pe_name=(PIMAGE_IMPORT_BY_NAME) RVA(thunk_list->u1.AddressOfData);
pe_name=get_rva(wm->module, (DWORD)thunk_list->u1.AddressOfData);
TRACE("--- %s %s.%d\n",
pe_name->Name,name,pe_name->Hint);
thunk_list->u1.Function=(PDWORD)MODULE_GetProcAddress(
......@@ -411,7 +412,6 @@ HMODULE PE_LoadImage( HANDLE hFile, LPCSTR filename, DWORD flags )
WINE_MODREF *PE_CreateModule( HMODULE hModule, LPCSTR filename, DWORD flags,
HANDLE hFile, BOOL builtin )
{
DWORD load_addr = (DWORD)hModule; /* for RVA */
IMAGE_NT_HEADERS *nt;
IMAGE_DATA_DIRECTORY *dir;
IMAGE_EXPORT_DIRECTORY *pe_export = NULL;
......@@ -422,8 +422,7 @@ WINE_MODREF *PE_CreateModule( HMODULE hModule, LPCSTR filename, DWORD flags,
nt = RtlImageNtHeader(hModule);
dir = nt->OptionalHeader.DataDirectory+IMAGE_DIRECTORY_ENTRY_EXPORT;
if (dir->Size)
pe_export = (PIMAGE_EXPORT_DIRECTORY)RVA(dir->VirtualAddress);
if (dir->Size) pe_export = get_rva(hModule, dir->VirtualAddress);
dir = nt->OptionalHeader.DataDirectory+IMAGE_DIRECTORY_ENTRY_EXCEPTION;
if (dir->Size) FIXME("Exception directory ignored\n" );
......@@ -462,7 +461,7 @@ WINE_MODREF *PE_CreateModule( HMODULE hModule, LPCSTR filename, DWORD flags,
*/
{
ImgDelayDescr *pe_delay = NULL;
pe_delay = (PImgDelayDescr)RVA(dir->VirtualAddress);
pe_delay = get_rva(hModule, dir->VirtualAddress);
TRACE_(delayhlp)("pe_delay->grAttrs = %08x\n", pe_delay->grAttrs);
TRACE_(delayhlp)("pe_delay->szName = %s\n", pe_delay->szName);
TRACE_(delayhlp)("pe_delay->phmod = %08x\n", pe_delay->phmod);
......
......@@ -469,7 +469,7 @@ static HGDIOBJ FONT_SelectObject( HGDIOBJ handle, void *obj, HDC hdc )
if (ret && dc->gdiFont) dc->gdiFont = 0;
if (ret == GDI_ERROR)
if (ret == HGDI_ERROR)
ret = 0; /* SelectObject returns 0 on error */
else
{
......
......@@ -726,7 +726,7 @@ void *GDI_ReallocObject( WORD size, HGDIOBJ handle, void *object )
{
HGDIOBJ new_handle;
if (handle & 2) /* GDI heap handle */
if ((UINT_PTR)handle & 2) /* GDI heap handle */
{
LOCAL_Unlock( GDI_HeapSel, handle );
if ((new_handle = LOCAL_ReAlloc( GDI_HeapSel, handle, size, LMEM_MOVEABLE )))
......@@ -764,7 +764,7 @@ BOOL GDI_FreeObject( HGDIOBJ handle, void *ptr )
object->wMagic = 0; /* Mark it as invalid */
object->funcs = NULL;
if (handle & 2) /* GDI heap handle */
if ((UINT_PTR)handle & 2) /* GDI heap handle */
{
LOCAL_Unlock( GDI_HeapSel, handle );
LOCAL_Free( GDI_HeapSel, handle );
......@@ -798,7 +798,7 @@ void *GDI_GetObjPtr( HGDIOBJ handle, WORD magic )
_EnterSysLevel( &GDI_level );
if (handle & 2) /* GDI heap handle */
if ((UINT_PTR)handle & 2) /* GDI heap handle */
{
ptr = (GDIOBJHDR *)LOCAL_Lock( GDI_HeapSel, handle );
if (ptr)
......@@ -814,7 +814,7 @@ void *GDI_GetObjPtr( HGDIOBJ handle, WORD magic )
}
else /* large heap handle */
{
int i = (handle >> 2) - FIRST_LARGE_HANDLE;
int i = ((UINT_PTR)handle >> 2) - FIRST_LARGE_HANDLE;
if (i >= 0 && i < MAX_LARGE_HANDLES)
{
ptr = large_handles[i];
......@@ -840,7 +840,7 @@ void *GDI_GetObjPtr( HGDIOBJ handle, WORD magic )
*/
void GDI_ReleaseObj( HGDIOBJ handle )
{
if (handle & 2) LOCAL_Unlock( GDI_HeapSel, handle );
if ((UINT_PTR)handle & 2) LOCAL_Unlock( GDI_HeapSel, handle );
TRACE_SEC( handle, "leave" );
_LeaveSysLevel( &GDI_level );
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment