Topic: [Request] Fake setup.exe source

Hi,

This is really a good job! I use this trick on every CD I make, for DriverPacks. By the way, I don't like the way driver letter is detected in presetup.cmd :

REM +==========================================================================+
REM |   Finding CD/DVD driveletter.                                            |
REM |--------------------------------------------------------------------------|
SET TAGFILE=\OEM
FOR %%i IN (C D E F G H I J K L M N O P Q R S T U V W X Y) DO IF EXIST "%%i:%TAGFILE%" SET CDDRIVE=%%i::

Indeed, if there's a Hard Disk with a OEM folder/file at root, then identification is corrupted. One good thing should be that fake setup.exe passes drive letter as argument. This one can detect drive letter from which its launched, easily with windows API.

Does anybody have the source of fake setup.exe? I could mod it to suit my own needs.

Cheers,
Kal

Re: [Request] Fake setup.exe source

nope it never has been available to me - nor do i know who wrote it...

fake setup and presetup.cmd both run from %systemRoot%\system32\

Why in the world would i need the 'fake' setup program to return that value????
(i already have two variables that return that value...  SystemDrive and SystemRoot.)
[scratches head and is confused]


you said "Indeed, if there's a Hard Disk with a OEM folder/file at root, then identification is corrupted."

Um no if there is a folder at root named OEM then we have found the DriverPacks.
(we are the only ones who use this name
if you use it for something else then shame on you,
pick a different name) wink

DP BartPE Tutorial   DP_BASE Tutorial   HWID's Tool     Read BEFORE you post    UserBars!
http://driverpacks.net/userbar/admin-1.png
The DriverPacks, the DP_Base program, and Support Forum are FREE!.

Re: [Request] Fake setup.exe source

Oh, my bad, I thought setup.exe was launched from CD, not from %SystemRoot%... In that case, ok, I can't do anything wink

Thanks for your answer,
Kal

Last edited by Kal (2008-08-08 08:42:49)

Re: [Request] Fake setup.exe source

NP have a great day!

PS i would also like to have the source for that file... wink

DP BartPE Tutorial   DP_BASE Tutorial   HWID's Tool     Read BEFORE you post    UserBars!
http://driverpacks.net/userbar/admin-1.png
The DriverPacks, the DP_Base program, and Support Forum are FREE!.

Re: [Request] Fake setup.exe source

well i found Pyrons original post and one version of the source code for setup
http://www.msfn.org/board/SOLVED-driver … ntry159358

#include "windows.h"
int APIENTRY WinMain(HINSTANCE hInstance,
                    HINSTANCE hPrevInstance,
                    LPSTR     lpCmdLine,
                    int       nCmdShow )
{

    SHELLEXECUTEINFO mySHELLEXECUTEINFO;

    mySHELLEXECUTEINFO.cbSize=sizeof(SHELLEXECUTEINFO);
    mySHELLEXECUTEINFO.fMask=SEE_MASK_NOCLOSEPROCESS;
    mySHELLEXECUTEINFO.hwnd=NULL;
    mySHELLEXECUTEINFO.lpVerb="Open";
    mySHELLEXECUTEINFO.lpFile="cmd.exe";
    mySHELLEXECUTEINFO.lpParameters="/C setup.cmd";
    mySHELLEXECUTEINFO.lpDirectory=".";
    mySHELLEXECUTEINFO.nShow=NULL; // or SW_SHOW;

    ShellExecuteEx(&mySHELLEXECUTEINFO);
    WaitForSingleObject(mySHELLEXECUTEINFO.hProcess,INFINITE);

    return 0;
}

I also noticed you added the last post to that thread... today in fact...

i guess you didnt read all of the 23 pages - and missed it on page 5 wink

thanks to your interest i now have the source and know who the author was... Yea!

DP BartPE Tutorial   DP_BASE Tutorial   HWID's Tool     Read BEFORE you post    UserBars!
http://driverpacks.net/userbar/admin-1.png
The DriverPacks, the DP_Base program, and Support Forum are FREE!.

Re: [Request] Fake setup.exe source

Thanks for searching OverFlow! I should have done this myself... In fact, I check the very first pages and the last one, my bad.
It seems to be C language, but this Win32 API is really difficult to read, I should buy a book wink

Kal

Re: [Request] Fake setup.exe source

this is one I made a little while ago. written in Delphi.

the first one will show dialogs if errors. The second lacks the dialogs but will be a smaller file. third creates a log file in systemroot.
to debug change...
{$APPTYPE GUI}
to...
{$APPTYPE CONSOLE}

to debug presetup.cmd change...
SW_HIDE
to...
SW_SHOWNORMAL

Compile it in Delphi.

USE AT OWN RISK!

with dialogs...

program setup;

{$APPTYPE GUI}

uses
  SysUtils, Windows, ShellAPI, Dialogs;

{$R *.RES}

  procedure ShellExecute_AndWait(FileName: string; Params: string; Visible: DWORD);
var
  exInfo: TShellExecuteInfo;
  Ph: DWORD;
begin
  FillChar(exInfo, SizeOf(exInfo), 0);
  with exInfo do
  begin
    cbSize := SizeOf(exInfo);
    fMask := SEE_MASK_NOCLOSEPROCESS or SEE_MASK_FLAG_DDEWAIT;
    Wnd := GetActiveWindow();
    ExInfo.lpVerb := 'open';
    ExInfo.lpParameters := PChar(Params);
    lpFile := PChar(FileName);
    nShow := Visible;
  end;
  if ShellExecuteEx(@exInfo) then
    Ph := exInfo.HProcess
  else
  begin
    // if error
    Exit;
  end;
  WaitForSingleObject(ExInfo.hProcess, INFINITE);

  CloseHandle(Ph);
end;

var
  setupExe, setuporgExe, setupoldExe, cmdParams : String;
  i : Integer;
  
begin
   
    setupExe := 'setup.exe';
    setupoldExe := 'setupold.exe';
    setuporgExe := 'setuporg.exe';

    cmdParams := ParamStr(1);
    if ParamCount > 1 then
    begin
      for i := 2 to ParamCount do
        cmdParams := cmdParams+' '+ParamStr(i);
    end;

    if not RenameFile(setupExe, setupoldExe) then
        ShowMessage('Error renaming setup to setupold.');

    if not RenameFile(setuporgExe, setupExe) then
        ShowMessage('Error renaming setuporg to setup.');

    if FileExists('presetup.cmd') then
        ShellExecute_AndWait(PChar('presetup.cmd'), PChar('nada'), SW_HIDE)
    else
        ShowMessage('Error! no presetup.cmd file.');

    if not FileExists(setupExe) then
        ShowMessage('Error! no setup.exe file.');

    ShellExecute_AndWait(PChar('setup.exe'), PChar(cmdParams), SW_SHOWNORMAL);

end.

without dialogs...

program setup;

{$APPTYPE GUI}

uses
  SysUtils, Windows, ShellAPI;

{$R *.RES}

  procedure ShellExecute_AndWait(FileName: string; Params: string; Visible: DWORD);
var
  exInfo: TShellExecuteInfo;
  Ph: DWORD;
begin
  FillChar(exInfo, SizeOf(exInfo), 0);
  with exInfo do
  begin
    cbSize := SizeOf(exInfo);
    fMask := SEE_MASK_NOCLOSEPROCESS or SEE_MASK_FLAG_DDEWAIT;
    Wnd := GetActiveWindow();
    ExInfo.lpVerb := 'open';
    ExInfo.lpParameters := PChar(Params);
    lpFile := PChar(FileName);
    nShow := Visible;
  end;
  if ShellExecuteEx(@exInfo) then
    Ph := exInfo.HProcess
  else
  begin
    // if error
    Exit;
  end;
  WaitForSingleObject(ExInfo.hProcess, INFINITE);

  CloseHandle(Ph);
end;

var
  setupExe, setuporgExe, setupoldExe, cmdParams : String;
  i : Integer;
  
begin
   
    setupExe := 'setup.exe';
    setupoldExe := 'setupold.exe';
    setuporgExe := 'setuporg.exe';

    cmdParams := ParamStr(1);
    if ParamCount > 1 then
    begin
      for i := 2 to ParamCount do
        cmdParams := cmdParams+' '+ParamStr(i);
    end;

    if RenameFile(setupExe, setupoldExe) then;

    if RenameFile(setuporgExe, setupExe) then;

    if FileExists('presetup.cmd') then
        ShellExecute_AndWait(PChar('presetup.cmd'), PChar('nada'), SW_HIDE);    

    ShellExecute_AndWait(PChar('setup.exe'), PChar(cmdParams), SW_SHOWNORMAL);

end.

creates a log file in systemroot...

program setup;

{$APPTYPE GUI}

uses
  SysUtils, Windows, ShellAPI;

{$R *.RES}

  procedure ShellExecute_AndWait(FileName: string; Params: string; Visible: DWORD);
var
  exInfo: TShellExecuteInfo;
  Ph: DWORD;
begin
  FillChar(exInfo, SizeOf(exInfo), 0);
  with exInfo do
  begin
    cbSize := SizeOf(exInfo);
    fMask := SEE_MASK_NOCLOSEPROCESS or SEE_MASK_FLAG_DDEWAIT;
    Wnd := GetActiveWindow();
    ExInfo.lpVerb := 'open';
    ExInfo.lpParameters := PChar(Params);
    lpFile := PChar(FileName);
    nShow := Visible;
  end;
  if ShellExecuteEx(@exInfo) then
    Ph := exInfo.HProcess
  else
  begin
    // if error
    Exit;
  end;
  WaitForSingleObject(ExInfo.hProcess, INFINITE);

  CloseHandle(Ph);
end;

var
  setupExe, setuporgExe, setupoldExe, cmdParams, winDir : String;
  i : Integer;
  logFile : TextFile;
  
begin
    winDir := GetEnvironmentVariable('SystemRoot');
    AssignFile(logFile, winDir+'\presetup.log');
    ReWrite(logFile);
    WriteLn(logFile, '::::::::: Presetup Log File :::::::::');
    WriteLn(logFile, 'Fake setup.exe file © 2008 jaws1975');
    WriteLn(logFile, '');
    WriteLn(logFile, 'Initializing presetup...');

    setupExe := 'setup.exe';
    setupoldExe := 'setupold.exe';
    setuporgExe := 'setuporg.exe';

    WriteLn(logFile, 'Preparing commandline parameters to pass to real setup.exe...');
    cmdParams := ParamStr(1);
    if ParamCount > 1 then
    begin
      for i := 2 to ParamCount do
        cmdParams := cmdParams+' '+ParamStr(i);
    end;

    WriteLn(logFile, 'Renaming setup.exe to setupold.exe...');
    if not RenameFile(setupExe, setupoldExe) then
        WriteLn(logFile, '   error renaming setup.exe to setupold.exe...')
    else
        WriteLn(logFile, '   renamed setup.exe to setupold.exe...');

    WriteLn(logFile, 'Renaming setuporg.exe to setup.exe...');
    if not RenameFile(setuporgExe, setupExe) then
        WriteLn(logFile, '   error renaming setuporg.exe to setup.exe...')
    else
        WriteLn(logFile, '   renamed setuporg.exe to setup.exe...');

    WriteLn(logFile, 'Launching presetup.cmd...');
    if FileExists('presetup.cmd') then
        ShellExecute_AndWait(PChar('presetup.cmd'), PChar('nada'), SW_HIDE);

    if not FileExists(setupExe) then
        WriteLn(logFile, 'ERROR! setup.exe missing...')
    else
        WriteLn(logFile, 'Launching real setup.exe with parameters...');
    WriteLn(logFile, '   '+cmdParams);
    CloseFile(logFile);

    ShellExecute_AndWait(PChar('setup.exe'), PChar(cmdParams), SW_SHOWNORMAL);
    
end.

removing {$APPTYPE GUI} will cause it not to work. it says gui but there is no screen output.

use it or modify it as you like.

basically what it does is renames setup.exe to setupold.exe then rename setuporg.exe to setup.exe. it then launches presetup.cmd and waits for it to finish. it then launches the real setup.exe. It must wait for the real setup.exe to finish before the fake setup.exe closes.

I tried deleting setupold.exe but it would not delete when I tried.

Last edited by jaws1975 (2008-08-08 13:39:50)

Re: [Request] Fake setup.exe source

OverFlow wrote:

Um no if there is a folder at root named OEM then we have found the DriverPacks.
(we are the only ones who use this name
if you use it for something else then shame on you,

Well, that's not entirely correct.  Lots of software use the OEM folder (not to be confused with the $OEM$ folder).
Siginet's PowerPacker uses the OEM folder for stuff as well as OEMscan (for pre-activating OEM PCs with oembios files).
Siginet and Bâshrat the Sneaky worked together on the project years ago since PowerPacker will integrate DriverPacks without using DPBase.

I've never had a problem with files living together in the OEM folder so long as the filenames are unique.

Re: [Request] Fake setup.exe source

i bwelived that powerpacker used base in API mode same as Autoimage...

Well ya learn somthin new every day... big_smile

DP BartPE Tutorial   DP_BASE Tutorial   HWID's Tool     Read BEFORE you post    UserBars!
http://driverpacks.net/userbar/admin-1.png
The DriverPacks, the DP_Base program, and Support Forum are FREE!.

10

Re: [Request] Fake setup.exe source

Thanks everybody for the code!

@jaws1975 : just use {$APPTYPE CONSOLE} wink

I really need to learn Windows API to leave Delphi and just code in plain old C tongue

Last edited by Kal (2008-08-09 06:19:39)

Re: [Request] Fake setup.exe source

if you use {$APPTYPE CONSOLE} the console window is visible. using {$APPTYPE GUI} hides it.

12

Re: [Request] Fake setup.exe source

No, you can hide it like this :

var
 Title : Array[0..512]of char;
begin
    // get current title window
  GetConsoleTitle(PChar(@Title ),SizeOf(Title ));
  ShowWindow(GetConsoleWindow, SW_HIDE);

Cheers wink

Last edited by Kal (2008-08-09 12:19:02)

Re: [Request] Fake setup.exe source

OverFlow wrote:

i bwelived that powerpacker used base in API mode same as Autoimage...

That's correct smile

I used a different fake setup, IIRC. I'll try to find it back, but don't expect it soon.

Founder of DriverPacks.net — wimleers.com