flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
revolution 04 Apr 2010, 02:31
Shall I move this to the Linux forum?
|
|||
![]() |
|
Tyler 04 Apr 2010, 02:34
Sure, I don't care, but I'm doing it on Windows so it's pretty universal. Isn't that the idea of libc?
|
|||
![]() |
|
revolution 04 Apr 2010, 02:37
I will leave it here if you prefer, but I suspect that not many people use libc in Windows. I just think that the Linux users could help you better if it was put there.
|
|||
![]() |
|
Tyler 04 Apr 2010, 02:52
I wrote:
I respect your opinion, move it if you see it necessary/helpful. You're probably right that most Windows programmers don't use libc, I do it because I hate programming with Win32 API and I do use Linux(so I guess you're right ![]() P.S. Wouldn't it have been easier to just answer my question? ![]() |
|||
![]() |
|
revolution 04 Apr 2010, 02:59
Tyler wrote: Wouldn't it have been easier to just answer my question? |
|||
![]() |
|
Tyler 04 Apr 2010, 03:44
If it helps, printf expects a char* and argv is a char**. The first pop is getting char**argv off the stack, then I get int argc, and that's all I'm sure about
![]() |
|||
![]() |
|
Tyler 04 Apr 2010, 05:35
Well, so far, I've come to the conclusion I'm going to have to use the WIN32 API. The only examples I can find use GetCommandLine. Any example of how to get argc/v in a portable way would be greatly appreciated.
|
|||
![]() |
|
pelaillo 05 Apr 2010, 20:48
The only reliable way in win32 to obtain the arguments is by using the API function Kernel32.GetCommandLine.
If you want to obtain it through undocumented stuff, you could do something like that (only for testing purposes): Code: main: mov eax,esp ;esp points to the end of an undocumented structure mov esi,[eax-3E0h] ;esi now points to the command line as an Unicode string mov esi,[eax-3BCh] ;esi now points to the working dir as an Unicode string |
|||
![]() |
|
Tyler 05 Apr 2010, 21:08
Yeah, I decided to just make a different main file for Win32 and Linux, with the os specific code in the main files and the portable code in an include.
Cool to have such knowledge though. Seems like an obscure fact, where did you read it? Not that I don't believe you, it's just that such a place would be good for further research on the topic. |
|||
![]() |
|
pelaillo 06 Apr 2010, 13:31
It's not obscure, just not documented. At any program startup, the memory is loaded with some data that is going to be used by the Windows API. Those structures are mainly arrays of dwords pointing to functions (ntdll.dll undocumented functions) and strings with environment settings.
The documented API functions are wrappers, i.e. make use of those calls in order to provide the desired functionality without changing the interface. In other words, win32 API calls don't change but the kernel undocumented functions are free to Microsoft to change, optimize and so on without further notice. Many of those kernel functions are "documented" on the internet but you should be aware that if your program uses them, it could stop working properly in a succesive windows version. I became interested on this subject many years ago because some Microsoft competitors argumented that the access to those undocumented functions provide an uncompetitive edge to Microsoft own programs. From my own experience, there is little overhead by using the documented API functions so there is no need to the burden of work of not using them. |
|||
![]() |
|
Tyler 06 Apr 2010, 22:38
And I thought I was cool for trying to run EVERY program in system32
![]() I'll do some research on those functions though, sound really interesting. Thanks for the info. |
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.