flat assembler
Message board for the users of flat assembler.

Index > Windows > Imports tool revised

Author
Thread Post new topic Reply to topic
pelaillo
Missing in inaction


Joined: 19 Jun 2003
Posts: 878
Location: Colombia
pelaillo
Hi all,
The following is an entire rewritten version of "imports" program.
The program builds imports table from sources going through included files as well.

I have done exhaustive tests and optimizations and I will be glad to receive your comments and bug reports.
My hope is that this program will get a place in the tools section Wink

Features:
1. Full fasm source code.
2. Loads the needed dlls as resource files to save time.
3. Skips strings, comments and macro definition lines.
4. Goes recursively through included files.
5. Path syntax full compatible with fasm.
6. Selectable Unicode and ASCII functions.
7. Prepares following import tables:
fasm
alink
golink
8. Works with following macros:
api
invoke
cinvoke
thiscall
fastcall


Description: ver. 0.0.5 - 24.02.2004
Download
Filename: imports.zip
Filesize: 8.59 KB
Downloaded: 426 Time(s)



Last edited by pelaillo on 25 Feb 2004, 13:32; edited 2 times in total
Post 17 Feb 2004, 15:07
View user's profile Send private message Yahoo Messenger Reply with quote
Vortex



Joined: 17 Jun 2003
Posts: 318
Vortex
Hi Pelaillo,

Nice work,but your tool doesn't work at all. The application doesn't output anything, not even the welcome screen. So, how to run the tool?

_________________
Code it... That's all...
Post 21 Feb 2004, 10:54
View user's profile Send private message Visit poster's website Reply with quote
pelaillo
Missing in inaction


Joined: 19 Jun 2003
Posts: 878
Location: Colombia
pelaillo
Hi Vortex,
Could you give me more information?
I have tested it on win95 and xp and it works. I am using it on a daily basis directly from RadAsm to copy from the output window.

I find a bug on memory management when I've tried with fresh.asm. I'm working on fixing it.
But for smaller projects is working Confused

Thanks,
pelaillo
Post 21 Feb 2004, 13:06
View user's profile Send private message Yahoo Messenger Reply with quote
Vortex



Joined: 17 Jun 2003
Posts: 318
Vortex
I tried your tool on Win Xp Home Sp1 (my computer), Win2000 and Win98,it doesn't function.
Even trying to run the program without any cmdlineparam,no any result.
Code:
c:\imports>imports.exe

c:\imports>
    

_________________
Code it... That's all...
Post 21 Feb 2004, 13:11
View user's profile Send private message Visit poster's website Reply with quote
pelaillo
Missing in inaction


Joined: 19 Jun 2003
Posts: 878
Location: Colombia
pelaillo
I'm puzzled Shocked
From commandline it didn't function as you properly said.
Launching it by a program as commandline tool does. (following test with xplore2, works also from RadAsm and OllyDbg)

Code:
imports imports.asm

import kernel32,\
     CloseHandle,'CloseHandle',\
      CreateFile,'CreateFileA',\
       ExitProcess,'ExitProcess',\
      GetCommandLine,'GetCommandLineA',\
       GetEnvironmentVariable,'GetEnvironmentVariableA',\
       GetFileSize,'GetFileSize',\
      GetProcessHeap,'GetProcessHeap',\
        GetStdHandle,'GetStdHandle',\
    HeapAlloc,'HeapAlloc',\
  HeapFree,'HeapFree',\
    LoadLibraryEx,'LoadLibraryExA',\
 ReadFile,'ReadFileA',\
   VirtualAlloc,'VirtualAllocA',\
   VirtualFree,'VirtualFreeA',\
     WriteFile,'WriteFile'
    
Code:
imports
imports 0.0.4 - Fasm imports table builder
This is freeware - flatassembler.net

imports source.asm [output][char]
 output options:
   -f: Fasm (Default)
      -g: GoLink
      -a: Alink

 char options:
     -a: ASCII char (Default)
        -w: Unicode (Wide) char
    
Post 21 Feb 2004, 13:51
View user's profile Send private message Yahoo Messenger Reply with quote
Vortex



Joined: 17 Jun 2003
Posts: 318
Vortex
Hi Pelaillo,

It looks like that you adopted a different method of programming. Can you explain with full detail how to run your tool?

_________________
Code it... That's all...
Post 21 Feb 2004, 16:25
View user's profile Send private message Visit poster's website Reply with quote
Vortex



Joined: 17 Jun 2003
Posts: 318
Vortex
Smile
Hi Pelaillo,

There is nothing to be puzzled. Smile I found the bug. Smile

Your code with the statement:
Code:
format PE GUI 4.0
    

will not function at all. This is why the tool doesn't output any text.
I think, you should use this one:
Code:
format PE CONSOLE 4.0
    


With LordPE, I modified the subsystem of imports.exe to console.
Now, the tool is running just as you mentioned, but you need to fix a bug (maybe, it's about memory management) , it crashed for me on another trial with different Fasm source code.

Nice tool, keep going on.

Best regards,

Vortex


Description:
Download
Filename: IMPORTS.zip
Filesize: 2.28 KB
Downloaded: 311 Time(s)


_________________
Code it... That's all...
Post 21 Feb 2004, 22:17
View user's profile Send private message Visit poster's website Reply with quote
pelaillo
Missing in inaction


Joined: 19 Jun 2003
Posts: 878
Location: Colombia
pelaillo
Thank you very much !

I'm catching the bugs Very Happy
Post 23 Feb 2004, 04:20
View user's profile Send private message Yahoo Messenger Reply with quote
pelaillo
Missing in inaction


Joined: 19 Jun 2003
Posts: 878
Location: Colombia
pelaillo
Vortex wrote:
There is nothing to be puzzled. Smile

Windows craziness Laughing Laughing
The console is unable to catch stdout if the program is specified as GUI Exclamation
I wonder how they call it "standard" output ¿!?!?

New upload at top. Some bugs fixed.
Please help me testing.
Post 24 Feb 2004, 20:44
View user's profile Send private message Yahoo Messenger Reply with quote
Vortex



Joined: 17 Jun 2003
Posts: 318
Vortex
Pelaillo,

If I remember well, the terms stdout and stdin are associated mainly with console applications.

I downloaded the new version. Trial with Privalov's Opengl demo from the Fasmw package:
Code:
import kernel,\
    ExitProcess,'ExitProcess',\
      GetModuleHandle,'GetModuleHandleA'
import user,\
      CreateWindowEx,'CreateWindowExA',\
       DefWindowProc,'DefWindowProcA',\
 DispatchMessage,'DispatchMessageA',\
     GetClientRect,'GetClientRect',\
  GetDC,'GetDC',\
  GetMessage,'GetMessageA',\
       InvalidateRect,'InvalidateRect',\
        LoadCursor,'LoadCursorA',\
       LoadIcon,'LoadIconA',\
   PostQuitMessage,'PostQuitMessage',\
      RegisterClass,'RegisterClassA',\
 ReleaseDC,'ReleaseDC',\
  TranslateMessage,'TranslateMessage'
import gdi,\
      ChoosePixelFormat,'ChoosePixelFormat',\
  SetPixelFormat,'SetPixelFormat',\
        SwapBuffers,'SwapBuffers'
import opengl,\
     glBegin,'glBegin',\
      glClear,'glClear',\
      glColor3f,'glColor3f',\
  glEnd,'glEnd',\
  glRotatef,'glRotatef',\
  glVertex3f,'glVertex3f',\
        glViewport,'glViewport',\
        wglCreateContext,'wglCreateContext',\
    wglDeleteContext,'wglDeleteContext',\
    wglMakeCurrent,'wglMakeCurrent'
import glu <--- ???
    

The source file doesn't import functions from glu32.dll
How can I specify the required DLLs to be scanned for the external functions?

Also, the tool can't handle source files specified with relative paths.
An example:
Code:
include '..\Fasm+MS Link Indirect call\Dlgproc.asm'
    

_________________
Code it... That's all...
Post 25 Feb 2004, 19:36
View user's profile Send private message Visit poster's website Reply with quote
pelaillo
Missing in inaction


Joined: 19 Jun 2003
Posts: 878
Location: Colombia
pelaillo
Vortex, thanks for your help Wink I will follow to fix them.

About the stdout, the problem is not that GUI applications don't use it. The problem is that console don't catch it properly. In fact, many GUI programs such as fasmw, radasm and so on catch them properly.

Regards,
Post 25 Feb 2004, 23:29
View user's profile Send private message Yahoo Messenger Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3170
Location: Denmark
f0dder
Quote:

Windows craziness
The console is unable to catch stdout if the program is specified as GUI
I wonder how they call it "standard" output ¿!?!?

It's called "standard output" because it isn't the "error output" Razz - old unix (and perhaps even older?) terminology.

Btw there *is* no console if your PE is specified as GUI... even if you're run from a console mode app like cmd.exe or command.com. But you can of course always AllocConsole or AttachConsole from a GUI app - so nothing crazy here Smile
Post 26 Feb 2004, 15:35
View user's profile Send private message Visit poster's website Reply with quote
pelaillo
Missing in inaction


Joined: 19 Jun 2003
Posts: 878
Location: Colombia
pelaillo
Older but still actual. Very Happy
The following are valid virtual filesystem services:
stdin
stdout
stderr

You can get a valid handle for all of them and then read from first or write to the other two and it does not concern to GUI or not GUI (at least on Unix) so windows have copied this in a *not so good way* or otherwise it will function.

The craziness is that a GUI program reads and writes properly from stdin/stdout but a console does not catch stdout if the app. is not defined as a console.
Post 26 Feb 2004, 15:49
View user's profile Send private message Yahoo Messenger Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3502
Location: Bulgaria
JohnFound
pelaillo wrote:
The craziness is that a GUI program reads and writes properly from stdin/stdout but a console does not catch stdout if the app. is not defined as a console.


What console? In Windows you may have many consoles, not only one. Actually every console application have it's own console. And every GUI application have no any console created, so stdin and stdout are directed to NULL. It is absolutely normal behaviour IMHO. It is easy to create console in your GUI application and to attach it to stdin and stdout. (btw: console interface is very stupid thing, the problem is that the people are used to it and IMHO, this stops them to invent something better.)

Regards.
Post 26 Feb 2004, 15:58
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
pelaillo
Missing in inaction


Joined: 19 Jun 2003
Posts: 878
Location: Colombia
pelaillo
But please look at these facts:

1. Compiling with format PE GUI 4.0:
Works as expected when launched by RadAsm
Shows nothing when launched by command line

2. Compiling with format PE CONSOLE
Works as expected when launched by RadAsm
Works as expected when launched by command line
Post 26 Feb 2004, 17:46
View user's profile Send private message Yahoo Messenger Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3170
Location: Denmark
f0dder
When launched by radasm, it inhereits stdin,stdout and such from the parent process. When invoked otherwise, no console is created nor attached, so there's no default file handles (or well... on win2k GetStdHandle and such does return file handles, but they probably go to something equivalent to /dev/null on unix)
Post 26 Feb 2004, 17:53
View user's profile Send private message Visit poster's website Reply with quote
pelaillo
Missing in inaction


Joined: 19 Jun 2003
Posts: 878
Location: Colombia
pelaillo
Thank you, now I understand.

I didn't see it because both apps are different processes.
Post 26 Feb 2004, 18:14
View user's profile Send private message Yahoo Messenger 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-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.