[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: D10 + Pre-Build hook

From: <rosenfield_at_users.sourceforge.net>
Date: 2007-10-09 13:28:01 CEST

Hi Stefan, list;

Just a small FYI-ish update..

Yesterday I took a swing at this. I downloaded the TortoiseSVN
sources, and got through the list of dependencies, but I found the
build process to be difficult to get running, to the point where my
time was better spent fixing the problem in other ways.

So I've more or less given up modifying SubWCRev for the time being,
focusing instead on a nimble/versatile tool to wrap svnversion and
flunk the output into $Rev.

I'd like to avoid dumping Cygwin executables in the repository,
because it creates an issue if there are different versions of
cygwin1.dll running on one system at a time. So that rules a
bash/sed/svnversion combination out, given that there are AFAIK no
working free win32 version of bash that includes functional piping
(Cygwin aside). I'd also like to avoid Windows Scripting Host, because
it is a security pothole, and also any third party stuff, because it
adds yet another thing that can potentially go wrong.

That sort of leaves cmd and custom-built exes. Cmd has some
deficiencies, for example %errorlevel% goes missing if you pipe the
output of a command into an environment variable. Deciding that it
must be possible to do it with a custom-built exe, I set out to
develop a tool. It's a working prototype, so the code is of course
butt ugly, but other than that it works fine:

http://www.heidisql.com/svn/extra/EnvPipe/EnvPipe.dpr (source)
http://www.heidisql.com/files/EnvPipe.exe (binary)

It does this:
 - start subprocess
 - capture output
 - get pid of parent process (cmd)
 - query ProcessBasicInformation via NtQueryInformationProcess
 - ReadProcessMemory to load ProcessEnvironmentBlock via pointer in PBI
 - ReadProcessMemory to load RtlUserProcessParameters via pointer in PEB
 - ReadProcessMemory to load Environment via pointer in UPP and binary
search to find correct size
 - WriteProcessMemory to poke a new environment variable into the
parent cmd process (clear env var manually beforehand, using "SET

After finishing the prototype, it's clear that it is not the most
elegant approach. NtQueryInformationProcess resides in ntdll.dll and
is not supposed to be called from user applications, and
WriteProcessMemory pretty much needs administrative privileges to run.

On the plus side, the solution does bring back memories of the
Commodore 64 days, when peeking and poking in memory was all the rage
and a blue screen was a good thing ;-).

To unsubscribe, e-mail: dev-unsubscribe@tortoisesvn.tigris.org
For additional commands, e-mail: dev-help@tortoisesvn.tigris.org
Received on Tue Oct 9 13:33:11 2007

This is an archived mail posted to the TortoiseSVN Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.