News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Where did imagehlp.lib go to?

Started by Magnum, October 26, 2009, 09:06:26 PM

Previous topic - Next topic

Magnum

I need imagehlp.lib in order to use MapFileAndCheckSum.

It's not in the library directory and I can't find it anywhere.

I thought maybe it was in the old Masm32 V. 8.0, but I can't find it either.

Does anyone have a copy of it that they could upload?

Thanks.
Have a great day,
                         Andy

jj2007


rags

You could also use POLIB from PellesC to make the import lib from the DLL.
God made Man, but the monkey applied the glue -DEVO

hutch--

Magnum,

You would need to check to see if later versions of Windows still have that functionality available. Image manipulation was available for Win9x versions but from memory it changed with Win2000 and later NT based OS versions. Somewhere along the line I think some of it was transferred to system DLLs like kernel32 and similar.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

MichaelW

IMAGEHLP.DLL and dbghelp.dll seem to be related, but I'm not sure what the relationship is.

On my Windows 2000 SP4 system, the system32 directory includes IMAGEHLP.DLL and dbghelp.dll, both in version 5.0.2195.6613.

On my Windows XP HE SP1 system, the system32 directory includes imagehlp.dll and dbghelp.dll, both in version 5.1.2600.1106.

My MASM32 version 9 installation includes imagehlp.inc and dbghelp.inc, and the import libraries imagehlp.lib and dbghelp.lib. Since the dates of the import libraries match those of the other import libraries, I assume that they were part of the distribution.

My MASM32 version 10 installation includes imagehlp.inc, but not dbghelp.inc or either of the import libraries.

My Windows Server 2003 PSDK (dated February 2003) includes both of the import libraries, and they should be useable.
eschew obfuscation

Magnum

I found the library, but I can't get it to work right.

I keep getting error_invalid_handle.

This would make a decent checksum if I can get it to work.

Andy


.DATA

szFileName db "C:\masm32\SOURCE\intel.txt",0
dwCheckSum  dd  0
Store_Value dd  0

.data? 

dwHeaderSum dw  ?

.CODE

start:

invoke MapFileAndCheckSum, addr szFileName, addr dwHeaderSum, addr dwCheckSum
Have a great day,
                         Andy

Magnum

Quote from: MichaelW on October 27, 2009, 01:04:11 AM

My Windows Server 2003 PSDK (dated February 2003) includes both of the import libraries, and they should be useable.


The 2003 SDK is where I found imagehlp.lib.

Since masm32 has the imagehlp.inc, it seem logical that imagehlp.lib would also be present since
MapFileAndCheckSum won't work without both of them.

Andy
Have a great day,
                         Andy

MichaelW

The attachment contains three examples that call the MapFileAndCheckSum function. The first one uses the MASM32 version 9 import library and calls the function with invoke. The second one uses LoadLibrary and GetProcAddress and calls the function with the call instruction after pushing the arguments. The third one uses LoadLibrary and GetProcAddress, along with the SPROTO macro so the function can be called with invoke.

I also tested the import library from the PSDK, with a modified version of the first example, and it worked fine.

AFAICT without a .DEF file POLIB creates an import library without the @N decoration on the names. I expect the resulting import library will work with POLINK, but I could not find any way to make it work with the Microsoft linker.
eschew obfuscation

Vortex

With some macro tricks, it's possible to call functions from import libraries with non-decorated symbols :

Building the import library :

\masm32\bin\lib /OUT:imagehlp.lib /DEF:imagehlp.def /MACHINE:IX86


.386
.model flat,stdcall
option casemap:none

include     \masm32\include\windows.inc
include     \masm32\include\kernel32.inc
include     \masm32\include\user32.inc
include     invoke.inc

includelib  \masm32\lib\kernel32.lib
includelib  \masm32\lib\user32.lib
includelib  imagehlp.lib


EXTERN      MapFileAndCheckSumA:PROC


.data
format1     db 'Headersum = %X',13,10
            db 'Checksum   = %X',0

capt        db 'imagehlp demo',0
TestEXE     db 'SimpleWnd.exe',0

.data?

HeaderSum   dd ?
CheckSum    dd ?
buffer      db 128 dup(?)

.code

start:

   _invoke  MapFileAndCheckSumA,ADDR TestEXE,\
            ADDR HeaderSum,ADDR CheckSum

    invoke  wsprintf,ADDR buffer,ADDR format1,\
            HeaderSum,CheckSum

    invoke  MessageBox,0,ADDR buffer,ADDR capt,MB_OK               

    invoke  ExitProcess,0

END start


Building the project :


\masm32\bin\ml /c /coff imagehlpDemo.asm
\masm32\bin\link /SUBSYSTEM:WINDOWS imagehlpDemo.obj


Magnum

Thanks for all the help that everyone gave me.

I wanted a non-console program and this is what I came up with.

Is there a way that I can make Orig_ChkSum to where I don't have to "manually"
change the order?

Thanks



.DATA

szFileName     db   "C:\masm32\SOURCE\INTERRUPTS.asm",0
szAppName      db   "Box",0
headerSum      dd   0
checkSum       dd   0
szFileChanged  db   "The file has changed.",0
szFile_OK      db   "File has not been altered.",0

Orig_ChkSum    dd   576623h ; value of UNaltered file - Stores in REVERSE order !!
                   
.data?

dwHeaderSum    dw  ?
hWnd           dd  ?
dwCheckSum     dd  ?

.CODE

start:

invoke MapFileAndCheckSumA, ADDR szFileName, ; Do a checksum of our file
                            ADDR headerSum,
                            ADDR checkSum

mov eax, checkSum    ; move value to EAX

.if eax == Orig_ChkSum ; Check if file has been altered
invoke  MessageBox, NULL, addr szFile_OK, addr szAppName,MB_OK

  .else
 
  invoke MessageBox,NULL,addr szFileChanged,addr szAppName,MB_OK
 
.endif

invoke ExitProcess,0

end start


Have a great day,
                         Andy

Vortex

Here is another version of the example project where the import library imahlp.lib is built with Polib.exe