This .ZIP file contains Import by Hash code for Win32 kindly provided by peci.

Contents:
- import_by_hash.s		is pecis original code (best viewed with 8-character tabs)
- import_by_hash.asm	is my (rygs) translation to intel syntax (again, 8-char tabs; works with MASM and NASM)
- calchash.c					is a simple ANSI C program that computes hash sums for strings you pass on the command line.

Usage:

GetProcAddress takes (as the comments suggest) two arguments, the hash sum of the
function you want to import in ebx, and the module handle of the DLL you want to
import from in ebp (this is what LoadLibrary returns). If everything works, you
will get the address of the function you want in eax (if it's not found, well,
GetProcAddress will simply crash :).

Both assembler source files are *fragments* and intended to be pasted somewhere
else.

A very simple example usage would be (intel syntax):

---- snip ----

user32    db "user32",0
allok     db "everything ok.",0

_entryPoint:
        lea     ebx, user32
        push    ebx
        call    LoadLibraryA        ; load user32.dll, returns module handle in eax

        mov     ebp, eax            ; now ebp contains module handle
        mov     ebx, 0fac90ce2h     ; hash code of "MessageBoxA"
        call    GetProcAddress

        lea     ebx, allok
        xor     ecx, ecx
        push    ecx
        push    ebx
        push    ebx
        push    ecx
        call    eax                 ; call MessageBoxA(0,"everything ok.","everything ok.",0)

        ret                         ; end.

---- snip ----

(as you probably noticed, you will still need a regular import for LoadLibraryA).

Again, thanks for peci for the code, and I hope this will be useful.

  - ryg/farbrausch
