46 comments

[ 2.7 ms ] story [ 74.1 ms ] thread
"Using notepad.exe as an output device" is the message here.

But impressive job nevertheless.

is curses that hard? Not just a sarcastic question, I've never coded curses.
Curses does not exist on Windows, but this could be done easily using Windows's console API or ANSI escape sequences. Wouldn't be nearly as fun, though.
Curses also uses escape sequences, and curses outputs are supported by the Windows Terminal (not CMD.exe however). Curses doesn't do anything fancy, just convoluted.
(comment deleted)
Great write up! Building a memory scanner and using that to inject text into notepad seems like a fascinating journey and it sounds like you learned a lot. Keep up the good work!
For those who don't understand the significance of this I highly encourage you to learn about ray tracing and the complexity of it. If combining something that complex with something so simple (Notepad.exe) is not art I don't know what is.
Do you think it might be a little patronizing to assume people don't understand that text inside notepad is being used as a display when there is a video showing it off?
Exactly. The idea is neat but it's no different than the mini ray tracer you write in graphics 101, with the twist that the output "frame" buffer is the text buffer of notepad
I was referring to possibly not knowing about Ray Tracing which is a technique and a subset of the field of computer graphics and thus possibly not understanding its computational complexity, I don't know why you're upset at me.
Even kids know what ray tracing is these days, it's used in video games to sell graphics cards. Teenagers write ray tracers in undergrad classes.

This example is a cube and plane with one light. It is lines from the camera checked for collision against triangles then a line from the collision point checked against a light. Checking for collision against a triangle is just checking collision against the infinite plane and checking if that point is inside the triangle.

What is the "significance" you are talking about? This is something common with an uncommon display.

> For those who don't understand the significance of this I highly encourage you to learn about ray tracing and the complexity of it.

Ray tracing, at it's core, is actually beautifully simple.

Also, ray tracing is absolutely not the interesting (or "significant") part of this article. I highly encourage to RTFA first.

As for combining the two: having read on Raymond Chens blog about all the optimization that went into Notepad over the years, I'd guess Notepad is the real complex part here.

I was referring to its computational complexity.
I often considered the lure of raytracing as a project was that it was rather simple to get really good results. Of course there is no limit to how complicated you can make one, you don't have to put much time in to get really nice images.
(comment deleted)
Love this though I have to ask, wouldn't getting the HWND of the Edit Control via WindowFromPoint and sending WM_SETTEXT be easier than digging through memory?

I guess the point may be to learn how Cheat Engine can be used in a practical way to hook things which is definitely more along the lines of some of the author's other posts!

(comment deleted)
utterly useless hence absolutely indispensable. <3
That seems to be ray casting (a la Wolfenstein 3D), not ray tracing.
Seeing the rotating cube and glancing over the code, it looks like ray tracing to me.
They are really historically the same thing, but I think ray casting has come to mean ray tracing a lower dimensional thing like a map and representing the results in a higher dimension, like 3d space.
Hey I can draw in Notepad.exe too! GetDC(hwnd)

Note that if you actually want to do something like this, you'd probably need to deactivate the Edit window from rendering anything, sending WM_SETREDRAW will probably work.

Notepad has been rewritten using the new WinRT APIs in Win11, so I doubt any of that still works.
A quick check of Windows 11 notepad reveals that it is still creating child windows. Text editor is of class RichEditD2DPT, status bar is msctls_statusbar32, menu bar is Windows.UI.Composition.DesktopWindowContentBridge.

As long as they are actual win32 Windows, then you can still interact with them using the system's API functions.

Other fun fact, Direct3D has interfaces inside of GDI32.DLL, look at all the D3DKMT functions there.

Every time I see someone's off-piste raytracer project, I feel compelled to link my own silly contribution to that diaspora: https://github.com/chunky/sqlraytracer
Sadly I can only upvote you once for using "off-piste"
> Standing on the Necks of Giants

Put a smile on my face (from the sqlraytracer README)

reminds me of doing this in excel in 1998

... although i did a wireframe with bresenham, and struggled to exceed 15fps