• Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

World: r4wp

[#Red] Red language group

Kaj
3-Jul-2013
[9337x2]
It stops earlier for Doc. File not found seems to be the driver file 
itself, so it probably doesn't load at all
On my machine, it loads but then comes back with error 1058
Paul
3-Jul-2013
[9339]
I would use the driver verifier utility on that.
Kaj
3-Jul-2013
[9340x2]
So the system is expecting it to do more than it does. But a null 
driver should just work
Sounds good, what's that?
Paul
3-Jul-2013
[9342x2]
It checks windows drivers to ensure they don't crash or have other 
stability issues.
You'll want to start  there.
Kaj
3-Jul-2013
[9344]
It sounds vaguely familiar, but where is it?
Paul
3-Jul-2013
[9345]
Should be able to find a free download via Microsoft site.  I think 
it is include in the Driver Development kit.
Kaj
3-Jul-2013
[9346]
Yes, I may have encountered it, but don't remember the name
Paul
3-Jul-2013
[9347]
http://support.microsoft.com/kb/244617
Kaj
3-Jul-2013
[9348]
Thanks!
Paul
3-Jul-2013
[9349]
np
Kaj
3-Jul-2013
[9350x2]
Sadly, I can't get any information about the driver out of Verifier 
or ProcMon
ProcMon is more about userland, and Verifier is about drivers that 
actually run
Arnold
4-Jul-2013
[9352x2]
Where can I find your I/O binding Kaj?
@Doc in your example I now notice the declaration of the local variable 
as well: http://pastebin.com/Dddf57eH

Is that necessary, I didn't use it and all seems to work pretty well.
DocKimbel
4-Jul-2013
[9354]
It was just for the sake of showing that arguments and locals are 
not in the same context.
Arnold
4-Jul-2013
[9355]
ok I was afraid some sort of memory leak could happen if you forgot.
Kaj
4-Jul-2013
[9356x3]
INPUT and ASK are in the C library binding:
http://red.esperconsultancy.nl/Red-C-library/dir?ci=tip
Both for Red and Red/System, in ANSI.red and ANSI.reds
Arnold
4-Jul-2013
[9359]
Ah! the ANSI files. Should have guessed! Nice to use in the video 
next.
MikeL
4-Jul-2013
[9360x2]
This Zato.io stuff is where I was looking for Red + zmq to go.   
bit.ly/19U6S64  (Hintjens RT)
http://bit.ly/19U6S64
kensingleton
7-Jul-2013
[9362]
I am trying to learn Red/System but I have a strange result. When 
I enter this code all works fine, the input line is printed correctly:

#import [
	LIBC-File cdecl [
		get-line: "gets" [
			line	[c-string!]
			return:	[c-string!]
		]
	]
]

foo: ""
get-line foo            ; when run I enter: this is a test
print newline
print foo                  ; Correctly outputs: this is a test


but if I do this;

foo: ""
boo: ""
get-line foo          ; when run I enter: this is a test
boo: foo
print newline
print boo

then I get             ; "thisX @"

or if I enter: hello
it prints out: hellX @


It seems that something in the process of binding foo to boo is messing 
up, but I have no clue what it might be.
Any ideas?
DocKimbel
7-Jul-2013
[9363]
gets() requires you to allocate a buffer of adequate size. Empty 
c-string! literals ("") will statically allocate an empty string, 
unsuitable for use with gets(), resulting in buffer overflows ('boo 
is allocated just after 'foo). Try rather: 

foo:  allocate 100
boo: allocate 100


This will dynamically allocate 100 bytes for each c-string!. You 
need to ensure that gets() won't overflow those buffers (which in 
practice is impossible, so one should just avoid using gets() in 
production code).
kensingleton
7-Jul-2013
[9364x2]
Thanks Doc. What then would your recommend for getting console input 
into Red/System if not gets()?
The allocate did not work because of a type mismatch but using long 
empty string literals did.
DocKimbel
7-Jul-2013
[9366]
Have a look the Red/Sysme parts of Red's console:

https://github.com/dockimbel/Red/blob/master/red/tests/console.red


These are not the only ways to securely read inputs from user, fgets() 
is the main safe alternative:

http://stackoverflow.com/questions/4309746/safe-alternative-to-gets
kensingleton
7-Jul-2013
[9367]
Thanks Doc.
DocKimbel
7-Jul-2013
[9368]
Type mismatch: you can fix it easily with a simple type casting and 
proper string initialization.

foo: as c-string! allocate 100
boo: as c-string! allocate 100
kensingleton
7-Jul-2013
[9369]
Great, thanks Doc, worked a treat!
Kaj
7-Jul-2013
[9370x2]
Here is the first Red/System driver, a minimal Hello World kernel 
driver for Windows:
Red/System []

#import ["ntoskrnl.exe" stdcall [

 log-error: "DbgPrint" [				"Print formatted message to debug log."
		[variadic]
		; format		[c-string!]
		;	value		[variant!]
		;	...
	]
]]

on-load: function ["DriverEntry"
	DriverObject	[driver-object!]
	RegistryPath 	[byte-ptr!]
	return:			[integer!]
][
	log-error "Hello Red/System from Windows kernel driver!"
	0
]
Bo
7-Jul-2013
[9372]
Great news!
Paul
9-Jul-2013
[9373]
Can the RED compiler generate PDB files?
Pekr
9-Jul-2013
[9374x2]
So, I gave my new BeagleBone Black (BBB) a quick test. With latest 
Arngstrom Linux, I was able to upload Red ARM tests (generated using 
%build-arm-tests.r). All tests pass, except %function-test, which 
crashes with Runtime Error 1: Access violation ....
The above mentioned script also fails at it tries to make a directory. 
Maybe it needs make-dir/deep %runnable/arm-tests, or simply to remove 
%runnable ....
Kaj
9-Jul-2013
[9376]
Doc said PDB is undocumented and too complex
Paul
9-Jul-2013
[9377]
I didn't know it wasn't documented.
Kaj
9-Jul-2013
[9378]
Early results were that PE format is less complex than ELF, but if 
you count in debug extensions, it's the other way around
Paul
9-Jul-2013
[9379]
I have a technet subscription so I'm combing the database right now.
Pekr
9-Jul-2013
[9380]
Ah, just found out, that above access violation is present even with 
Windows version of the function-test.exe
Kaj
9-Jul-2013
[9381]
I think Doc would be interested
DocKimbel
9-Jul-2013
[9382x2]
Function-test: it's a test that rely on unimplemeted feature that 
cause the crash, it should be disabled until  we get that supported.
PDB Paul if you can get me all the required documentation, I'll be 
glad to add PDB generation to Red toolchain.
Pekr
9-Jul-2013
[9384]
OK, got news posted to FB profile anyway ;-)
DocKimbel
9-Jul-2013
[9385]
Pekr: does the Red console works fine on the BeagleBone?
Paul
9-Jul-2013
[9386]
Does look to be a bit closely guarded but here are some links that 
may get you going for PDB output  -> http://ccimetadata.codeplex.com/wiki/search?tab=Home&SearchText=pdb