flat assembler
Message board for the users of flat assembler.

Index > Projects and Ideas > vb script process nm.exe output for MS COFF extrn [DONE]

Author
Thread Post new topic Reply to topic
sleepsleep



Joined: 05 Oct 2006
Posts: 12934
Location: ˛                             ⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣Posts: 0010456
sleepsleep 17 Jun 2012, 15:49
hi,
this vb script will certainly help those who want to ld static link MinGW .a files with MS COFF output using Fasm.

http://obemsg.blogspot.com/2012/06/nmexe-output-extrn-for-fasm.html

to get list of functions of a .a file, use nm.exe ( available inside MinGW bin )
eg:
D:\MinGW\lib>nm -g libuser32.a > C:\nmlibuser32.txt

to parse the output file into proper extrn
eg:
ANSI
C:\>cscript.exe /nologo nm2extern.vbs C:\nmlibuser32.txt > libuser32a.inc
UNICODE
C:\>cscript.exe /nologo nm2extern.vbs C:\nmlibuser32.txt 1 > libuser32w.inc


version 2012-06-18-21-54


this version support those api that without @
eg.
00000000 I __imp__iupdrvWarpPointer


example output
Code:
ANSI
extrn '__imp__wvsprintfA@12' as wvsprintf:dword
extrn '__imp__mouse_event@20' as mouse_event:dword
extrn '__imp__keybd_event@16' as keybd_event:dword
extrn '__imp__WindowFromPoint@8' as WindowFromPoint:dword
extrn '__imp__WindowFromDC@4' as WindowFromDC:dword
extrn '__imp__WinHelpA@16' as WinHelp:dword
extrn '__imp__WaitMessage@0' as WaitMessage:dword
extrn '__imp__WaitForInputIdle@8' as WaitForInputIdle:dword
extrn '__imp__VkKeyScanExA@8' as VkKeyScanEx:dword
extrn '__imp__VkKeyScanA@4' as VkKeyScan:dword

UNICODE
extrn '__imp__wvsprintfW@12' as wvsprintf:dword
extrn '__imp__mouse_event@20' as mouse_event:dword
extrn '__imp__keybd_event@16' as keybd_event:dword
extrn '__imp__WindowFromPoint@8' as WindowFromPoint:dword
extrn '__imp__WindowFromDC@4' as WindowFromDC:dword
extrn '__imp__WinHelpW@16' as WinHelp:dword
extrn '__imp__WaitMessage@0' as WaitMessage:dword
extrn '__imp__WaitForInputIdle@8' as WaitForInputIdle:dword
extrn '__imp__VkKeyScanW@4' as VkKeyScan:dword
extrn '__imp__VkKeyScanExW@8' as VkKeyScanEx:dword
    


Description: uploaded new version
Download
Filename: nm2extern.zip
Filesize: 861 Bytes
Downloaded: 841 Time(s)



Last edited by sleepsleep on 18 Jun 2012, 14:34; edited 6 times in total
Post 17 Jun 2012, 15:49
View user's profile Send private message Reply with quote
sleepsleep



Joined: 05 Oct 2006
Posts: 12934
Location: ˛                             ⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣Posts: 0010456
sleepsleep 17 Jun 2012, 16:29
it still bring some problem because some API is not available on windows XP, only in Windows 7. Sigh.

eg.
The procedure entry point GetTouchInputInfo could not be located in the dynamic link library USER32.dll.
Post 17 Jun 2012, 16:29
View user's profile Send private message Reply with quote
sleepsleep



Joined: 05 Oct 2006
Posts: 12934
Location: ˛                             ⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣Posts: 0010456
sleepsleep 18 Jun 2012, 12:14
it seems extrn everything will cause our application grow large,

could anyone code a macro to include extrn based on what api found inside our asm code?
Post 18 Jun 2012, 12:14
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20421
Location: In your JS exploiting you and your system
revolution 18 Jun 2012, 12:17
That would seem to be easy (untested):
Code:
macro extrn text, name, type {
  if used name
    extrn text as name:type
  end if
}    
Post 18 Jun 2012, 12:17
View user's profile Send private message Visit poster's website Reply with quote
sleepsleep



Joined: 05 Oct 2006
Posts: 12934
Location: ˛                             ⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣Posts: 0010456
sleepsleep 18 Jun 2012, 12:21
Code:
format MS COFF
include 'win32ax.inc'

macro extrn text, name, type {
  if used name
    extrn text as name:type
  end if
}

include 'libkernel32axp.inc'
include 'libuser32axp.inc'

section '.text' code readable executable

 public _demo
    


Code:
flat assembler  version 1.70.02  (1572863 kilobytes memory)
D:\Fasm\INCLUDE/libkernel32axp.inc [1]:
extrn '__imp__lstrlenA@4' as lstrlen:dword
MSCOFF.ASM [8] extrn [1]:
  if used name
error: invalid expression.
make: *** [MSCOFF.OBJ] Error 2
    


?
Post 18 Jun 2012, 12:21
View user's profile Send private message Reply with quote
sleepsleep



Joined: 05 Oct 2006
Posts: 12934
Location: ˛                             ⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣Posts: 0010456
sleepsleep 18 Jun 2012, 12:22
or revolution, you want me to change the format of those extern file?
Post 18 Jun 2012, 12:22
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20421
Location: In your JS exploiting you and your system
revolution 18 Jun 2012, 12:30
Oh. Try this:
Code:
macro extrn stuff {
  match text =as name:type,stuff \{
    if used name
      extrn text as name:type
    end if
  \}
}    
Post 18 Jun 2012, 12:30
View user's profile Send private message Visit poster's website Reply with quote
sleepsleep



Joined: 05 Oct 2006
Posts: 12934
Location: ˛                             ⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣Posts: 0010456
sleepsleep 18 Jun 2012, 12:34
awesome, it seems works!!!!

damn it, i edit the xp api manually one by one yesterday night, LMFAO...
Post 18 Jun 2012, 12:34
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20421
Location: In your JS exploiting you and your system
revolution 18 Jun 2012, 12:46
sleepsleep wrote:
damn it, i edit the xp api manually one by one yesterday night, LMFAO...
Never underestimate the power of the macro.
Post 18 Jun 2012, 12:46
View user's profile Send private message Visit poster's website Reply with quote
sleepsleep



Joined: 05 Oct 2006
Posts: 12934
Location: ˛                             ⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣Posts: 0010456
sleepsleep 18 Jun 2012, 12:47
gonna start understand how those macro works.

btw, thanks!! Smile it just awesome!
Post 18 Jun 2012, 12:47
View user's profile Send private message Reply with quote
rugxulo



Joined: 09 Aug 2005
Posts: 2341
Location: Usono (aka, USA)
rugxulo 05 Jul 2012, 21:17
s/When all else fails, read the source/Never underestimate the power of the macro./

Laughing
Post 05 Jul 2012, 21:17
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20421
Location: In your JS exploiting you and your system
revolution 06 Jul 2012, 13:00
rugxulo wrote:
s/When all else fails, read the source/Never underestimate the power of the macro./
Or maybe:

s/When all else fails, read the source/When all else fails, read the instructions/
Post 06 Jul 2012, 13:00
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.