+ Reply to Thread
Results 1 to 5 of 5
  1. #1
    Member
    Join Date
    Jul 2008
    Posts
    85

    Convert this delphi code to visual basic?

    Can anyone help me convert this code to visual basic?
    Code:
    unit StopIce;
    
    { Anti debug unit. Detect SoftIce and shutdown Windows.
    
      Freware with source.
    
      Copyright (c) 1998 Soft House Labs, Andre N Belokon
      Web     http://softlab.od.ua/
      Email   support@softlab.od.ua
    
      THIS SOFTWARE AND THE ACCOMPANYING FILES ARE DISTRIBUTED
      "AS IS" AND WITHOUT WARRANTIES AS TO PERFORMANCE OF MERCHANTABILITY OR
      ANY OTHER WARRANTIES WHETHER EXPRESSED OR IMPLIED.
      NO WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE IS OFFERED.
      THE USER MUST ASSUME THE ENTIRE RISK OF USING THE ACCOMPANYING CODE.
    }
    
    interface
    
    implementation
    
    uses Windows;
    
    Function IsSoftIce95Loaded: boolean;
    Var hFile: Thandle;
    Begin
      result := false;
      hFile := CreateFileA('\\.\SICE', GENERIC_READ or GENERIC_WRITE,
        FILE_SHARE_READ or FILE_SHARE_WRITE, nil, OPEN_EXISTING,
        FILE_ATTRIBUTE_NORMAL, 0);
      if( hFile <> INVALID_HANDLE_VALUE ) then begin
        CloseHandle(hFile);
        result := TRUE;
      end;
    End;
    
    Function IsSoftIceNTLoaded: boolean;
    Var hFile: Thandle;
    Begin
      result := false;
      hFile := CreateFileA('\\.\NTICE', GENERIC_READ or GENERIC_WRITE,
        FILE_SHARE_READ or FILE_SHARE_WRITE, nil, OPEN_EXISTING,
        FILE_ATTRIBUTE_NORMAL, 0);
      if( hFile <> INVALID_HANDLE_VALUE ) then begin
        CloseHandle(hFile);
        result := TRUE;
      end;
    End;
    
    function WinExit(flags: integer): boolean;
      function SetPrivilege(privilegeName: string; enable: boolean): boolean;
      var tpPrev,
          tp         : TTokenPrivileges;
          token      : THandle;
          dwRetLen   : DWord;
      begin
        result := False;
        OpenProcessToken(GetCurrentProcess, TOKEN_ADJUST_PRIVILEGES or TOKEN_QUERY, token);
        tp.PrivilegeCount := 1;
        if LookupPrivilegeValue(nil, pchar(privilegeName), tp.Privileges[0].LUID) then
        begin
          if enable then
            tp.Privileges[0].Attributes := SE_PRIVILEGE_ENABLED
          else
            tp.Privileges[0].Attributes := 0;
          dwRetLen := 0;
          result := AdjustTokenPrivileges(token, False, tp, SizeOf(tpPrev), tpPrev, dwRetLen);
        end;
        CloseHandle(token);
      end;
    begin
      if SetPrivilege('SeShutdownPrivilege', true) then begin
        ExitWindowsEx(flags, 0);
        SetPrivilege('SeShutdownPrivilege', False)
      end;
    end;
    
    initialization
      if IsSoftIce95Loaded or IsSoftIceNTLoaded then begin
        WinExit(EWX_SHUTDOWN or EWX_FORCE);
        Halt;
      end;
    end.
    thanks.

  2. #2
    Senior Member
    Join Date
    Jun 2008
    Location
    0x40000
    Posts
    1,452
    Okay, I'll give it a go
    Don't know IF it works, but it should work:
    Code:
    Private Declare Function CreateFile Lib "kernel32.dll" Alias "CreateFileA" (ByVal lpFileName As String, ByVal dwDesiredAccess As Long, ByVal dwShareMode As Long, ByRef lpSecurityAttributes As Any, ByVal dwCreationDisposition As Long, ByVal dwFlagsAndAttributes As Long, ByVal hTemplateFile As Long) As Long
    
    Private Const OPEN_EXISTING As Long = 3
    Private Const GENERIC_READ As Long = &H80000000
    Private Const GENERIC_WRITE As Long = &H40000000
    
    
    Public Function SoftIce() As Boolean
    dim hdriver as long
    
    hDriver = CreateFile("\\.\SICE", GENERIC_READ Or GENERIC_WRITE, 0, ByVal 0, OPEN_EXISTING, 0, 0)
    if hdriver <> -1 then 
    softice = true
    exit function
    end if
    
    hDriver = CreateFile("\\.\NTICE", GENERIC_READ Or GENERIC_WRITE, 0, ByVal 0, OPEN_EXISTING, 0, 0)
    if hdriver <> -1 then 
    softice = true
    exit function
    end if
    
    softice = false
    
    End Function
    call it like this:

    Code:
    If softice = true then end

  3. #3
    Member
    Join Date
    Jul 2008
    Posts
    85
    Thanks a lot can you help me convert one more thing? Thanks a lot though for the code above.
    anti-bitdefender
    Code:
    Usage:
    if sidt1 = false then exitprocess(0);
    
    Code:
    function sidt1: boolean;
    var
    idtr: array[0..005] of Byte;
    begin
    result := false;
    asm sidt idtr end;
    if pCardinal(@idtr[2])^ = $8003F400 //NT Address
    then result := true;
    begin
    asm sidt idtr end;
    if pCardinal(@idtr[2])^ = $80036400 //XP Address
    then result := true;
    begin
    asm sidt idtr end;
    if pCardinal(@idtr[2])^ = $81AFF400 //Vista Address
    then result := true;
    begin
    asm sidt idtr end;
    if pCardinal(@idtr[2])^ = $81AF6400 //Dummy
    then result := true;
    begin
    asm sidt idtr end;
    if pCardinal(@idtr[2])^ = $0341A070 //Vista 64bit or intel dual core
    then result := true;
    begin
    asm sidt idtr end;
    if pCardinal(@idtr[2])^ = $005F62F0 //Vista 64bit or intel dual core
    then result := true;
    end;
    end;
    end;
    end;
    end;
    end;

  4. #4
    Senior Member
    Join Date
    Jun 2008
    Location
    0x40000
    Posts
    1,452
    Dude, I'm not going to write you a whole program...

  5. #5
    Member
    Join Date
    Jul 2008
    Posts
    85
    I dont want you to make my whole program, i just wanted help on two small parts.

 

 

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. visual basic 6 kav help.
    By darkc0de in forum General Programming Help
    Replies: 6
    Last Post: 03-10-2008, 22:47
  2. visual basic ASM COMPILER!
    By SqUeEzEr in forum Snippets
    Replies: 5
    Last Post: 02-09-2008, 20:33
  3. Convert pass stealer visual basic to delphi
    By softx in forum OpenSC-Open Source Projects
    Replies: 4
    Last Post: 22-06-2008, 12:20
  4. Help convert code from C to Delphi
    By flashfast in forum General Programming Help
    Replies: 0
    Last Post: 24-02-2007, 20:06
  5. Visual basic 5.0
    By ntaryl in forum Full development tools
    Replies: 8
    Last Post: 02-01-2007, 21:22

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
All times are GMT +1. The time now is 21:49.
www.opensc.ws
Copyright ©2005 - 2012, OpenSC Forums



Search Engine Friendly URLs by vBSEO 3.6.0 ©2011, Crawlability, Inc.