usage:
D:\MinGW\lib>nm -g libuser32.a > C:\nmlibuser32.txt
For ANSI
C:\>cscript.exe /nologo nm2extrn.vbs C:\nmlibuser32.txt > libuser32a.inc
For UNICODE
C:\>cscript.exe /nologo nm2extrn.vbs C:\nmlibuser32.txt 1 > libuser32w.inc
copy and save the below code as nm2extrn.vbs
Update - 2012 06 18 | 12:42 AM
maybe you need to separate those extrn files into xp, vista & 7 because some API is not available in xp, if you ld it and execute the application, you will get error like
The procedure entry point GetTouchInputInfo could not be located in the dynamic link library USER32.dll.
The procedure entry point GetTouchInputInfo could not be located in the dynamic link library USER32.dll.
Update - 2012 06 18 | 09:59 PM
now support api that without @
eg.
00000000 I __imp__iupdrvWarpPointer
use this fasm macro to auto extrn match API that we use in asm source
eg.
00000000 I __imp__iupdrvWarpPointer
use this fasm macro to auto extrn match API that we use in asm source
macro extrn stuff {
  match text =as name:type,stuff \{
    if used name
      extrn text as name:type
    end if
  \}
}
special thanks to revolution![code]
Dim funcname              ' lstrcatW
Dim functype              ' A or W or etc
Dim funcextrn             ' __imp__wvsprintfW / __imp__iupdrvWarpPointer
Dim funcextrn1            ' @12
Dim funcextrnjoin         ' __imp__wvsprintfW@12
Dim unicode
Dim nmcontent             ' content read from nm generated file
Dim nmarray               ' split into array by vbCrLf
Dim i
unicode = 0
Function ReadFile( fname )
 Dim fso
 Const ForReading = 1
 Set fso = CreateObject("Scripting.FileSystemObject")
 Set fnm = fso.OpenTextFile(fname, ForReading)
 ReadFile = fnm.ReadAll
 fnm.Close 
End Function
Function SplitSpaceISpace( fcontent )
 Dim breaki, breakimp, breaka
 If InStr( fcontent, " I " ) Then
  breaki = Split( fcontent, " I " )
  '0 = 00000000 I 
  '1 = __imp__iupdrvWarpPointer
  '1 = __imp__wvsprintfW@12
  
  funcname      = ""
  functype      = ""
  funcextrn     = ""
  funcextrn1    = ""
  funcextrnjoin = ""
  
  If InStr( breaki(1), "@" ) Then
   breaka     = Split( breaki(1), "@" )
   funcextrn  = breaka(0)           ' __imp__wvsprintfW 
   funcextrn1 = breaka(1)           ' 12
  Else
   funcextrn = breaki(1)
  End If
  
  If InStr( funcextrn, "__imp__" ) Then
   breakimp = Split( funcextrn, "__imp__" )
   funcname = breakimp(1)
   ' funcname = iupdrvWarpPointer
   ' funcname = wvsprintfW
  End If
  
  functype = Right( funcname, 1 )    ' A or W or etc
  
  ' join those extrn
  If funcextrn1 = "" Then
   funcextrnjoin = funcextrn
  Else
   funcextrnjoin = funcextrn + "@" + funcextrn1
  End If
  
  If unicode = 1 Then
   If functype <> "A" Then
    WScript.Echo( "extrn '" + funcextrnjoin + "' as " + funcname + ":dword")
   End If
  Else
   If functype <> "W" Then
    WScript.Echo( "extrn '" + funcextrnjoin + "' as " + funcname + ":dword")
   End If
  End If
 End If
End Function
If ( WScript.Arguments.Count() = 2 ) Then
 unicode = 1
End If
nmcontent = ReadFile( WScript.Arguments.Item(0) )
nmarray   = Split( nmcontent, vbCrLf)
For i = 0 to UBound(nmarray)
 SplitSpaceISpace( nmarray(i) )
Next
[/code]Labels: fasm, programming, vbscript




Post a Comment