translate some functions from c++ to delphi

hi im writing a exe packer and i found some interesting codes in c++, to evade someone debug my project, because i not a c++ coder, i ask is someone can translate this functions for me

[code]
bool IsAnubis()
{
      PROCESSENTRY32 pe32;
      pe32.dwSize = sizeof(PROCESSENTRY32);
      DWORD PID = 0, PPID = 0, expPID = 0;
      HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
      if(Process32First(hSnapshot, &pe32))
      {
            while(Process32Next(hSnapshot, &pe32))
            {
                  PID = pe32.th32ProcessID;
                  if(PID == GetCurrentProcessId())
                  {
                        PPID = pe32.th32ParentProcessID;
                  }
                  if(!strcmp(pe32.szExeFile, "explorer.exe"))
                  {
                        expPID = pe32.th32ProcessID;
                  }
            }
            CloseHandle(hSnapshot);
      }
      if(PPID != expPID)
      {
            return TRUE;
      }
      else
      {
            return FALSE;
      }
}

bool IsNormanSandBox()
{
      CHAR szUserName[MAX_PATH];
      DWORD dwUserNameSize = sizeof(szUserName);
      GetUserName(szUserName, &dwUserNameSize);
      if(!strcmp(szUserName, "CurrentUser"))
      {
            return TRUE;
      }
      else
      {
            return FALSE;
      }
}

bool IsSunbeltSandBox()
{
      CHAR szFileName[MAX_PATH];
      GetModuleFileName(NULL, szFileName, MAX_PATH);
      if(!strcmp(szFileName, "C:\\file.exe"))
      {
            return TRUE;
      }
      else
      {
            return FALSE;
      }
}

bool IsVirtualPC()
{
      __try
      {
            __asm
            {
                  mov eax, 1
                  _emit 0x0F
                  _emit 0x3F
                  _emit 0x07
                  _emit 0x0B
                  _emit 0xC7
                  _emit 0x45
                  _emit 0xFC
                  _emit 0xFF
                  _emit 0xFF
                  _emit 0xFF
                  _emit 0xFF
            }
      }
      __except(1)
      {
            return FALSE;
      }
      return TRUE;
}

bool IsVMware()
{
      DWORD _EBX;
      __try
      {
            __asm
            {
                  push ebx
                  mov eax, 0x564D5868
                  mov ebx, 0x8685D465
                  mov ecx, 0x0A
                  mov dx, 0x5658
                  in eax, dx
                  mov _EBX, ebx
                  pop ebx
            }
      }
      __except(1)
      {
            return FALSE;
      }
      return _EBX == 0x564D5868;
}
[/code]

thanks in advance
unnamed020Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Dagan HooverDeveloperCommented:
This should work, didn't test it though.
uses TlHelp32;
function IsAnubis: Boolean;
var
  PE32 : TProcessEntry32;
  PID, PPID, expPID : DWORD;
  hSnapShot : Cardinal;
begin
  PID := 0;
  PPID := 0;
  expPID := 0;
  hSnapShot := CreateToolHelp32Snapshot(TH32CS_SNAPPROCESS,0);
  If Process32First(hSnapShot,PE32) Then
    begin
    While Process32Next(hSnapShot,PE32) Do
      begin
      PID := PE32.th32ProcessID;
      If PID = GetCurrentProcessID Then
        begin
        PPID := PE32.th32ParentProcessID;
      end;
      If PE32.szExeFile = 'explorer.exe' Then
        begin
        expPID := PE32.th32ProcessID;
      end;
    end;
    CloseHandle(hSnapShot);
  end;
  Result := False;
  If PPID <> expPID Then
    begin
    Result := True;
  end;
end;
 
function IsNormanSandBox: Boolean;
var
  szUserName : PChar;
  dwUserNameSize : DWORD;
begin
  szUserName := AllocMem(MAX_PATH);
  dwUserNameSize := MAX_PATH;
  GetUserName(szUserName,dwUserNameSize);
  Result := True;
  If szUserName = 'CurrentUser' Then
    begin
    Result := False;
  end;
end;
 
function IsSunbeltSandBox: Boolean;
var
  szFileName : PChar;
begin
  szFileName := AllocMem(MAX_PATH);
  GetModuleFileName(0,szFileName,MAX_PATH);
  Result := True;
  If szFileName = 'C:\file.exe' Then
    begin
    Result := False;
  end;
end;
 
function IsVirtualPC: Boolean;
begin
  Try
    asm
      mov eax,1
      db $0F
      db $3F
      db $07
      db $0B
      db $C7
      db $45
      db $FC
      db $FF
      db $FF
      db $FF
      db $FF
    end;
  Except
    Result := False;
    Exit;
  end;
  Result := True;
end;
 
 
function IsVMWare: Boolean;
var
  _EBX : DWORD;
begin
  Try
    asm
      push ebx
      mov eax,$564D5868
      mov ebx,$8685D465
      mov ecx,$0A
      mov dx,$5658
      in eax,dx
      mov _EBX,ebx
      pop ebx
    end;
  Except
    Result := False;
    Exit;
  end;
  Result := (_EBX = $564D5868);
end;

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
unnamed020Author Commented:
thanks a lot man!! :)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.