Sunday, October 17, 2010

ocx/dll Register 1.9

I removed the annoying left click to make it popup the window anyway, this time at the bottom it says "Right mouse click" for the menu

How to use, Right mouse click on the missing file :P if it's a Valid File, it will register it, if it's a DLL file which can't be registered like ymsg.dll it will then ask you for the program that requires that dll






Now the Tricky Coding part, this program is Vista Compatible and in order to register a DLL/OCX in Vista you need to be logged in as Administrator, so what this program will do is this..

1. Are you running Vista?... Yes

Ask you for the Administrator Password, if you don't have it, the program will not work simple as that or if you do have it chances are you're logged in as Administrator in which case it should not ask for the password I can't remember but here's the code to do the job, and then it will run the program under Administrator (Same as right mouse clicking > Run As) and this code is kinda complicated and some AV scanners may think it's not unsafe (Privlidges under Windows...)



function GetCurrentUserName : string;
const
  cnMaxUserNameLen = 254;
var
  sUserName     : string;
  dwUserNameLen : DWord;
begin
  dwUserNameLen := cnMaxUserNameLen-1;
  SetLength(sUserName,cnMaxUserNameLen);
  GetUserName(PChar(sUserName),dwUserNameLen);
  SetLength(sUserName,dwUserNameLen-1);
  Result:=sUserName;
end;

function IsHiddenVista: Boolean;
var
  pFunction: Pointer;
begin
  pFunction := GetProcAddress(GetModuleHandle('KERNEL32.DLL'), 'GetProductInfo');
  Result := Assigned(pFunction);
end;

Procedure TForm1.CheckAdminRights;
Var
 Username: String;
 Pword: String;
 Where: String;
Begin
 Where:=ParamStr(0);
 UserName:=GetCurrentUserName;
 If LowerCase(Username)<>'administrator' Then
  Begin
//   ShowMessage('Running on Windows: '+IntToStr (Win32MajorVersion)+'.'+IntToStr (Win32MinorVersion)+' (Build '+IntToStr (Win32BuildNumber)+') '+' update: '+Win32CSDVersion);
   If IsHiddenVista=True Then //set to true!
    If MessageDlg('Vista has been detected, Admin Privlidges are required so that it can perform correctly or it will fail to register the ocx/dll files you need, Press Yes To Correct This.',mtconfirmation,[mbyes,mbno],1)=IdYes Then
      Begin
       Pword:=InputBox('Administrator Password: ','Administrator Password: ','');
       RunAs('administrator',Pword,Where);
       Halt;
      End;
  End;
End;
and

[code]
function CreateProcessWithLogon(lpUsername: PWideChar;
lpDomain: PWideChar;
lpPassword: PWideChar;
dwLogonFlags: DWORD;
lpApplicationName: PWideChar;
lpCommandLine: PWideChar;
dwCreationFlags: DWORD;
lpEnvironment: Pointer;
lpCurrentDirectory: PWideChar;
var lpStartupInfo: TStartupInfo;
var lpProcessInfo: TProcessInformation): BOOL; stdcall;
external 'advapi32' name 'CreateProcessWithLogonW';

function CreateEnvironmentBlock(var lpEnvironment: Pointer;
hToken: THandle;
bInherit: BOOL): BOOL; stdcall; external 'userenv';

function DestroyEnvironmentBlock(pEnvironment: Pointer): BOOL; stdcall; external 'userenv';



function RunAs(User, Password, Command: String): Integer;
var dwSize: DWORD;
hToken: THandle;
lpvEnv: Pointer;
pi: TProcessInformation;
si: TStartupInfo;
szPath: Array [0..MAX_PATH] of WideChar;
begin

ZeroMemory(@szPath, SizeOf(szPath));
ZeroMemory(@pi, SizeOf(pi));
ZeroMemory(@si, SizeOf(si));
si.cb:=SizeOf(TStartupInfo);

if LogonUser(PChar(User), nil, PChar(Password), LOGON32_LOGON_INTERACTIVE, LOGON32_PROVIDER_DEFAULT, hToken) then
begin
if CreateEnvironmentBlock(lpvEnv, hToken, True) then
begin
dwSize:=SizeOf(szPath) div SizeOf(WCHAR);
if (GetCurrentDirectoryW(dwSize, @szPath) > 0) then
begin
if (CreateProcessWithLogon(PWideChar(WideString(User) ), nil, PWideChar(WideString(Password)),
LOGON_WITH_PROFILE, nil, PWideChar(WideString(Command)), CREATE_UNICODE_ENVIRONMENT,
lpvEnv, szPath, si, pi)) then
begin
result:=ERROR_SUCCESS;
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);
end
else
result:=GetLastError;
end
else
result:=GetLastError;
DestroyEnvironmentBlock(lpvEnv);
end
else
result:=GetLastError;
CloseHandle(hToken);
end
else
result:=GetLastError;

end;


So that should explain any warnings that popup.... but i doubt.

Source Code Here (Aint i Nice).

http://memorialgreen.com/regocx/RegOCX.pas (Save as a .txt file to view in notepad)

And here's the link to the actual scan (Virustotal) 1.5meg exe, now where's vit so he can do his magic and take a screenshot of that, i Still don't know how he does it lol

http://www.virustotal.com/analisis/b...c7fa39ffb76697

No comments:

Post a Comment