Wednesday, June 30, 2004

World Wild Web #3 - New Blog

I've copied my blog content to my web site.

You can access my blog here.

Monday, June 28, 2004

Programming #2 - The making of a Debugger, Part #1

Yep.
Since I have some good knowledge in computer programming and I'm still reading a lot on this topic (between "Book of Illusions" from Paul Auster and "The Sigma Protocol" from Robert Ludlum).

Lately I've checked the "Undocumented Windows 2000 Secrets: A Programmers Cookbook" from Sven Schreiber. Excellent book for those who want to know the inside of windows even more. Maybe a review on my web site (when I've rebooted my stupid machine). And I've come to the idea of making a debugger. So I'll make a little simple one for the windows platform (I may come later for a solution on *x platforms).

The first part of this big project will deal with inserting your program into a remote process. Doing this is tricky but necessary. You've maybe seen the IsDebuggerPresent function I explained earlier. The standard method could be a problem when a program (may be malicious) checks for IsDebuggerPresent and kill ourselves or the process we try to debug (again, it would be even worse if it removes itself from memory, incapacipating our goal to check it). Using the standard windows api methods trigger normally this flag and so IsDebuggerPresent returns true....

So what can we do to insert into a process?
Note: You cannot use this kind of techniques you need to have administrator rights.


We can always create a thread into a remote process with this function:
// Returns the handle of the new thread.

// Don't forget that everything about memory is in the other process.
// #1 - Start Address and the Parameter are in another process, so for now we cannot access
// them directly. We'll see what we can do later.

HANDLE CreateRemoteThread(
HANDLE hProcess, // Process to create thread into.
LPSECURITY_ATTRIBUTES lpThreadAttributes, // Thread attributes, normally NULL.
SIZE_T dwStackSize, // Default size of the stack, normally 0.
LPTHREAD_START_ROUTINE lpStartAddress, // See #1.
LPVOID lpParameter, // See #2.
DWORD dwCreationFlags, // Creation Flags, default is ok.
LPDWORD lpThreadId ); // ID Thread container.


Most things are possible with this method. For now, I'll give you this code, that uses many functions, and receives two parameters: the name and path for an EXE file that will be executed, and the name of a DLL to load. I'll come back on this code later. For now, just check it out:

#define VC_EXTRALEAN

#include <windows.h>
#include <stdio.h>

int main(int argc, char** argv)
{
PROCESS_INFORMATION pi;
STARTUPINFO si;
void* pToDllName;
HANDLE hKernel32 = LoadLibrary( "kernel32.dll" );

if (argc < 3) return -1;

ZeroMemory( &pi, sizeof(pi) );
ZeroMemory( &si, sizeof(si) );
si.cb = sizeof(si);
CreateProcess( argv[1], NULL, NULL, NULL, FALSE, 0, 0, 0, &si, &pi );

pToDllName = VirtualAllocEx( pi.hProcess, NULL, 513,
MEM_COMMIT,
PAGE_READWRITE );

WriteProcessMemory( pi.hProcess, pToDllName, argv[2], 512, NULL );
CreateRemoteThread( pi.hProcess,
NULL, 0, (LPTHREAD_START_ROUTINE)GetProcAddress( hKernel32, "LoadLibraryA" ),
pToDllName, 0, NULL );

printf("Press any key to end remote process and current program.\n");
getc( stdin );
TerminateProcess( pi.hProcess, 0 );
return 0;
}

Friday, June 25, 2004

World Wild Web #2 - Web Site

Hey! I'll be having my website ready somewhere soon. Check out at
http://poltras.no-ip.com
to see when it's coming.

I still haven't configured anything except security (no exploit, guys, sorry about that...), but I'll do so maybe this weekend.

Here are a sample of most of the sections to come:
1 - Programming and Computer (of course), maybe some section more specifics later.
2 - Science (in general), maybe I'll make more subsections of it too.
3 - Philosophy (who would have doubted)
4 - Politics
5 - Music / Movie reviews
6 - Global (everything else)

7 - Personnal. Everyone will be able to have their personnal page with pictures and stuff.
7.1 - Thesis and studies. Some stuff important in studying and some interesting thesis, documents. It will be open to personnal thesis or studies (I'd like to have yours, Julie, about the Japanese market and the other one I, sigh, read in about 3 minutes which seemed interesting).
7.2 - Movies, pictures one took.
7.3 - WWW. Interesting sites, etc.

Forums to come, as well as polls, files, images, etc etc etc. Pretty complete, and the engine has all of this already included. I've already worked with this engine before, so I think I'll be able to make something neat really fast.

Of course, every one can be moderator/editor, with my permission (friends first, then references), and write news or anything for any of those sections.

Hope you'll all be there to see it :)

Of course, some documents won't be in english. By my multi-ethnic nature (germanish looking figure leaving in french canada speaking 3 languages majorly) I'll accept most documents. I'll tag them though for those in dutch (if you want of course, dutch people), french, spanish...

Thanks for the support!

Thursday, June 24, 2004

A share of me #3 - Short...

I can't sleep anymore... at least once again, I have insomnia problems. I slept 4 hours last night, and I can't go to bed right now... because I'm not feeling like it.

I've had my nightmares again lately. I've had recurrent nightmares all my life, sometimes it goes better, sometimes they come back. Now I'm grown up, so I don't scream, but they don't help me to sleep.

And they seem to appear with the lack of sleep.

Tuesday, June 22, 2004

Why What Web #1 - What?

Ok bad title for this... I'll try to find a better one :)

Here are some interesting links I've come upon, some funny other not. Those are all about computer or computer-related development.

I'm actually "taking care" of two students working with me. They have a good base on what C/C++ is/works, but they lack some deeper comprehension. Now I'm teaching them whatever they want, by doing exercises (most of them will be on my website, coming soon).

I just sent them those two links. I personnally think those are really important to read and understand, along others, because:
1 - this one explains mostly how Microsoft is losing a war mainly because it makes too much backward uncompatible changes in so little time, compared to the rest of its existence.
2 - that, on the other part, has mainly changed my view of Java on many points. First the benchmarks are no new stuff, I've seen them for 3 years now and followed the discussion. The most interesting parts come from the theory part, though, where
3 - Raymond Chen's blog, a very interesting share from the inside of Microsoft, on the why, how and what of the API.

More to come when I have some time left :)

Monday, June 21, 2004

A share of me #2 - Choices we don't make

There are some choices we do not want to make, whatever happens. Those choices depend on either the avaibility of a good ending, or no desired options, or even both.
One tries often to predict the future to the outcomes of either possibility (even if those prediction are futile, considering the different interactions), and take it into consideration.

It is a vicious way of solving this problem. In a sense, it often comes to short-term good for long-term bad, or the reverse. Then you look at the options, and can't decide if you want to make up later for not-so-bad consequences and take the present as-good-as-it-is-possible, or the other way around...

Sometimes you get away of this, timing out, or because someone else took the decision instead of you. You're then glad you didn't make the choice... and happy about the outcome of it...

Or so it seems.

Friday, June 18, 2004

Discussion #2 - Intelligence

Does learning languages improve intelligence in general? And, genuinely, does a polylinguist have more IQ than a monolinguist?

There is someone at work (we'll call him Anthony, both because it's his name and for the sake of not saying "that guy I work with" everytime :P) who's got a really good average in his courses. He speaks fluently and everyday 3 languages. So I've come to the question above... and I think the answer could be a yes for the first, and a no for the second. The question was out of the fact that he speaks 3 majorly different languages (with different roots), so that his mind is more structured to learn. I'll come back on this later.

Because intelligence is non deterministic, there is no real matter of saying that guy is more intelligent BECAUSE of this. Therefore, I think that speaking many languages improves intelligence, but not that a person who speaks only his mother tongue can't be more intelligent that someone who had the chance (it's a chance more than a choice, since this specules that the language was learnt in an age where choices was not made by us but mainly by our parents/society/environnement). Following this, I also agree to the fact that someone can have learnt many tongues without ever being more intelligent (IQ speaking) than an apple. You have to improve yourself. But the premices can be made with this. I'm coming to the why.

A language structures the mind (in terms of neural paths) so that it recognizes certain pattern (expressions) in every day life. Since french people tends to have different expressions than english speaking people, and learns to use them (neural paths are formed to the nature of the expression, its meaning) correctly, they are more used to a certain kind of thinking.
Learning is mostly made by associating different patterns with the patterns we know first. One who is really good with mathematics, and hadn't never really philosophed (which use different neural paths, even a different part of the brain - right part), will have a hard time reading Marx or Kant. Why? Because he can't find a meaning to it, they do not depends on the mathematical theories, and his mind is not formed to use them easily.

With time, eventually, the brain becomes more and more static. Once the main neural paths are strong, the less important one will have hard time forming. So learning a lot of different things young helps to master learning, helping to trace patterns with everything that has touched the patterns we've learnt. Of course, this is mostly subconciously done.

And languages that are strongly separated (Spanish and French are close, Chinese and English are really far) helps learn patterns that have almost nothing in common. So when one comes to learn something, he already has a diversified brain which can both associate expressions or path of meaning in the languages he's learnt, and help him to choke the difference.

At least I think so. What do YOU think?