Win32

From BarikWiki
Jump to: navigation, search

Introduction

Windows programming is not for the faint of heart. You'll want Visual Assist X for this process.

Windows Programming

  • Windows Development Reference. It's all in here, somewhere.
  • Getting a good feel for messages is an important part of learning how to write programs for Windows.
  • Programming Windows, 5th Edition by Charles Petzold (1998). The pre-requisites for this book are easily satisfied: familiarity with Windows from a user's perspective, knowledge of C, and a 32-bit C compiler. Although it's dated, this book appears necessary to move on to other texts, and no Windows programming knowledge is needed!
  • Generic.c includes code for a generic application.
  • Getting a good feel for messages is an important part of learning how to write programs for Windows.

Anatomy of a Windows C Program

To create the project, go under Win32 and select Win32 Project. Create an application type of Windows application with Empty project. Then you can create hellomsg.c.

#include <windows.h>

int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
	PSTR szCmdLine, int iCmdShow)
{
  MessageBox (NULL, TEXT ("Hello, Windows 98!"), 
    TEXT ("HelloMsg"), 0);

  return 0;
}
  • The program entry point WinMain can be found in the Windows SDK, winbase.h.
  • In windef.h, #define WINAPI __stdcall.
  • In modern Windows, hPrevInstance is always NULL.
  • The TEXT macro is used for handling Unicode.

DLL Injection

And here we have to suffer through land of script kiddie tutorials. DLL injection is particularly useful in Game Hacking.

ScriptKiddies

CreateRemoteThread

  • CreateRemoteThread documentation in MSDN. Creates a thread that runs in the virtual address space of another process.
  • Only works on Windows NT and above, though practically, this isn't a problem.

SetWindowsHookEx

  • SetWindowsHookEx. Installs an application-defined hook procedure into a hook chain.