Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

calling windows system calls #50

Open
vigilancetech-com opened this issue May 8, 2017 · 5 comments
Open

calling windows system calls #50

vigilancetech-com opened this issue May 8, 2017 · 5 comments
Labels

Comments

@vigilancetech-com
Copy link

Is there currently a high level way to call system calls?

I look in io.fth and see you setting up the system calls but you only do them from assembly below.

For example, in FreeForth there is the word:

lib:` ( @ # <name> -- ; a n -- funEntry ) loads the dynamic-link-library
  with filename starting at address "@" for "#" bytes, and defines a word
  which will lookup in this library for the function matching the name
  starting at address "a" for "n" bytes, and if found will return its entry,
  for use with "#call" or "fun:".
  If the library is not found, or if later a function is not found,
  an exception is thrown with corresponding error message.
  : lib:` :` #lib lit` #fun ' call, ;` ;
  see also: lib: #call fun: libc k32  ff.boot

and:

#call ( argN ... arg1 N funEntry -- funResult ) calls the library function
  with entry at "funEntry", which consumes "N" arguments from DATAstack and
  returns a single result on top of DATAstack. The N arguments must be pushed
  on DATAstack in the same order as in C, i.e. C-prototype (see Linux man or
  Windows win32.hlp) rightmost argument first, leftmost last.
@larsbrinkhoff
Copy link
Owner

Is there currently a high level way to call system calls?

No, there isn't. Yes, it would be nice to have.

Note that there's a difference between system calls and library calls. The former use the Linux ABI, and the latter use the C ABI.

@vigilancetech-com
Copy link
Author

What about library calls into Windows?

@larsbrinkhoff
Copy link
Owner

The Windows port does some contortions to call the kernel32 APIs. I think the same method applies to all dlls?

@vigilancetech-com
Copy link
Author

I don't know much but I don't see anything different when calling kernel32 as other dlls. Can you tell me what the 80 # int, in write-file in the windows io.fth is all about? I thought that only applied to linux syscalls.

@larsbrinkhoff
Copy link
Owner

That should be a bug. I probably used the Linux io.fth for the Windows port but forgot about write-file.

I don't know why that passes the tests!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants