Tuesday, 30 April 2013

Logical And Physical Address on Windows


1 RAM addresses
2   VirtualAllocEx()
    MapUserPhysicalPages() 
   mmGetPhysicalAddress()                                                                                     
                                                                                         ThongLT - letrthong@gmail.com
www.duartes.org



Preprocessor in Windows


#if defined(_WIN64)
  // 64-bit programs run only on Win64
#elif defined(_WIN32)
 // 32-bit programs run on both 32-bit and 64-bit Windows
#else
 // Win64 does not support Win16
#endif

MultiThreading on Windows

CreateThread
WaitForSingleObject
ExitThread
GetExitCodeThread
http://www.cs.rpi.edu/academics/courses/netprog/WindowsThreads.html
simple example :
#include <iostream>
#include <Windows.h>
using namespace  std;

DWORD WINAPI Thread1(LPVOID lpParameter)
{
 SYSTEMTIME time1;
 WORD flag = 0;
 int count = 0;
 while(true)
 {
  GetLocalTime(&time1);
  if(flag != time1.wSecond)
  {
   count++;
   if(count >60)
   {
     break;
   }
     cout<<time1.wHour<<" : "<< time1.wMinute <<" : "<<time1.wSecond<<endl;
  }
  flag = time1.wSecond;
 }

 return 0;
}

bool  TimerInterrupt(HANDLE& task1)
{

 DWORD Threadid;
  task1 =   CreateThread(
  NULL,
  0,
  Thread1,
  NULL,
  NULL,
  &Threadid
  );
 if(task1 == NULL)
 {
   cout<<"Could not create Thread"<<endl;
   return false ;
 }
 return true;
}

int main()
{
    HANDLE task;
     if (TimerInterrupt(task) == true)
      {
         cout<<"start new thread ."<<endl;
         WaitForSingleObject(task,INFINITE);
         cout<<" close thread ."<<endl;
         CloseHandle(task);
      }
    return 0;
}              //ThongLT-letrthong@gmail.com

Sunday, 21 April 2013

MAC Address

How to get  real MAC address in real machine .
we find "PCI\\"  string  of  "PNPDeviceID" in Win32_NetworkAdapter

 we find " ProductName" in Win32_NetworkAdapter
/Chipsets for network cards
"Atheros"    "Broadcom"   "Intel" "LSI Corporation"  "Marvell Technology Group" "Proxim" "Qualcomm" "Ralink" "Realtek" VIA Technologies" "Winbond"
we can use an UUID  to change MAC address  ,however The  UUID   support only  win 7 , win 8

Wednesday, 17 April 2013

Command Line On Windows

There are some command line that we always use normally on windows os .
"getmac"      : MAC address
"msinfo32"   : hardware information
"regedit"       : registry
"msconfig"    : service and  start up



"dxdiag"       : system information , graphics card....
                                   
"control"       : control panel
"services.msc"  : list services
"wbemtest" :Windows Management instrumentation
"devmgmt.msc"
diskmgmt.msc
               
"wmic DISKDRIVE Get DeviceID , PNPDeviceID, SerialNumber"
"wmic BIOS get name, serialnumber, version"
"wmic csproduct get name, identifyingnumber, uuid"
"wmic CPU get Manufacturer,ProcessorId"
"wmic NIC get macaddress,description"

"wmic process | sort"

http://blog.wisefaq.com/2010/06/29/wmi-and-wmic-example-text-for-common-queries/
windows_run_commands

Monday, 15 April 2013

Detect Running in Virtual Machine and Real Machine

Method 1 :
http://www.codeproject.com/Articles/9823/Detect-if-your-program-is-running-inside-a-Virtual
defect : +This mothod maybe crashes when I run it in a native system (Windows 7 64-bit OS)
             +can not builds x64
Method 2 : using mac address ( Careful....!!!!)
The IEEE assigns these first three bytes and the database is available online at IEEE OUI and Company_id Assignments.
Search the Public OUI/'company_id' Listing
Search for: 
"00:05:69"; //vmware1
"00:0C:29"; //vmware2
"00:50:56"; //vmware3
"00:1C:42"; //parallels1
"00:03:FF"; //microsoft virtual pc
"00:0F:4B"; //virtual iron 4
"00:16:3E"; //red hat xen , oracle vm , xen source, novell xen
"08:00:27"; //virtualbox
Method 3:Using model from  the Win32_ComputerSystem (http://projects.puppetlabs.com)
Win32_ComputerSystem.Manufacturer       Win32_ComputerSystem.Model

Microsoft Corporation                   Virtual Machine
VMware, Inc.                            VMware Virtual Platform
Red Hat                                 KVM
innotek GmbH                            VirtualBox

//==========================================================================
MAC address .
get real mac addres : pinfo->Type == MIB_IF_TYPE_ETHERNET 
                       
                      string pnp = obj["PNPDeviceID"].ToString();
                      if (pnp.Contains("PCI\\"))
//--------------------------------------------------------------------------
http://www.installsetupconfig.com/win32programming/
generating-hardware-based-computerid
http://blogs.vmware.com/teamfusion/2008/10/vmware-fusion-3-2.html

Friday, 12 April 2013

VMware

http://www.makeuseof.com/tag/how-to-find-unknown-device-drivers-by-their-vendor-device-id/
http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1008473

Registry on Windows 7 and windows 8

1 . Change  Default Programs Open With "Windows Photo Viewer" On Windows 8

Wednesday, 10 April 2013

service

services.msc
http://www.tacktech.com/display.cfm?ttid=304
This allow you to create a Windows user-defined service for Windows applications and some 16-bit applications (but not for batch files).

What is needed for Windows XP:
The files are included with Windows XP.

Windows XP
At a MS-DOS command prompt (Start | Run | "cmd.exe"), type the following commands: 



Creating Services:
  Adding Service (Note: Space between binpath= and "C:\ has to be there.
  <path>\sc.exe create "Service Name" binPath= "C:\Your Program.exe"
  Removing Service
  <path>\sc.exe delete "Service Name

Controlling Services:
  Starting Service
  <path>\sc.exe start "Service Name"
  Pausing Service
  <path>\sc.exe pause "Service Name"
  Stoping Service
  <path>\sc.exe stop "Service Name
http://www.eightforums.com/tutorials/12411-services-start-stop-disable-windows-8-a.html

Friday, 5 April 2013

Fedora and Ubuntu OS


Using command line:
1 : version  :"uname -a"
2 . exit
3. clear :  This will clear your screen 
4 . update : "yum update"( su)
5. ifconfig ( su ) :  The same ipconfig on windows
6 . ping  8.8.8.8 ( checking the Internet or  LAN )
7. installing GNU C++ compiler : "sudo apt-get install g++"or "yum install gcc-c++"
 # No package available
 yum search g++
For Example :  yum search gcc-c++
8. To folder : 
 "cd pathName" (cd - windows)
9 .Change password :
passwd
passwd {userName}
10 . open dpf file
yum install xpdf
11 .Shutdown - Reboot  :
$ "sudo shutdown -h now"  $ "sudo shutdown -h 0"  $ "sudo shutdown -h 18:45 "Server is going down for maintenance" "
$ "sudo reboot"

12.installing VMware tools
step 1 : "yum update"
step 2 : "yum install gcc make kernel-devel perl kernel-PAE-devel" 
step 3 :  extracted files
step 4 :  cd  pathName 
step 5 :  "/vmware-install.pl"

13. installing  codeblocks
su
yum install codeblocks
14 installing git 
su
yum install git-core
15 . Installing Echipse
yum -y install eclipse
16. Upgrade the newest on Fedora
sudo yum install fedora-upgrade 
17 KDeveloper
yum install kdevelop
18 File in Linux

touch filename.txt
cat > myfile.txt

19 Edit File
vi galfit.feedme
For inserting
Press i //Do required editing
For exiting
Press Esc

    :wq //for exiting and saving
    :q! //for exiting without saving
good link
http://community.linuxmint.com/tutorial/view/244

Bat file on Windows  OS and sh file on Linux OS
Run the sh file

http://www.cyberciti.biz/faq/run-execute-sh-shell-script/
sh file.sh
OR
bash file.sh
https://fedoraproject.org/wiki/Upgrading_Fedora_using_yum
http://rgrunber.wordpress.com/2012/04/23/cc-project-setup-in-eclipse/
//-------------------------------------------------------------------------------------
10 .Hotkey ( continues ... tomorrow .. )
http://unix.stackexchange.com/questions/52409/fedora-17-hotkey-for-terminal

command line
1 . "hello world "
http://pages.cs.wisc.edu/~beechung/ref/gcc-intro.html
2 .
windows_run_commands

Terminal on Ubuntu  OS
sudo apt-get install nmap
sudo apt-get remove nmap
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install gcc

25 Useful Basic Commands of APT-GET