Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

Introduction To The Windows API

Introduction
The Windows API helps programs talk to the Windows system. It lets apps show things on the screen, change files, or ask for info from the registry. And if you want to know more about how it works, Microsoft has all the details here

Windows Data Types

The Windows API uses many different kinds of data types that might not be as familiar as basic ones like "int" or "float." Here's an overview, and you can read more about them all on this page: [link].

Here are some examples:

DWORD - A 32-bit unsigned integer, on both 32-bit and 64-bit systems, used to represent values from 0 up to (2^32 - 1).
Code
DWORD dwVariable = 42;

SIZE_T: Used to represent the size of an object. It's a 32-bit unsigned integer on 32-bit systems representing values from 0 up to (2^32 - 1). On the other hand, it's a 64-bit unsigned integer on 64-bit systems representing values from 0 up to (2^64 - 1).

Code
SIZE_T sVariable = sizeof(int);

VOID: This means "no data type"—it's used when we don't want to imply that we're dealing with a particular kind of data.


Code
void* pVariable = NULL; // This is the same as PVOID

HANDLE: A value that specifies a particular object that the operating system is managing (e.g. file, process, thread).

Code
HANDLE hFile = CreateFile(...);

HMODULE: This is how you refer to a module (like a DLL) by its memory address.

Code
HMODULE hModule = GetModuleHandle(...);

LPCSTR/PCSTR, LPSTR/PSTR, LPCWSTR/PCWSTR, and PWSTR/LPWSTR: These are ways of referring to strings in different forms. "L" means it's a long type (from 16-bit times), "C" means the string is read-only, and "P" means you can read from and write to this string.

Code
LPCSTR  lpcString   = "Hello, world!";
PCSTR   pcString    = "Hello, world!";

Code
LPSTR   lpString    = "Hello, world!";
PSTR    pString     = "Hello, world!";

Code
LPCWSTR     lpwcString  = L"Hello, world!";
PCWSTR      pcwString   = L"Hello, world!";

Code
LPWSTR  lpwString   = L"Hello, world!";
PWSTR   pwString    = L"Hello, world!";

wchar_t: This represents wide characters, or "wchar."
Then there are types like PVOID, which is a pointer to any data type. And ULONG_PTR is used for math with pointers—it's an unsigned integer that's the same size as a pointer on your architecture.

These make it easier to write programs that can do more complex tasks and interact properly with Windows.


Data Types Pointers

The Windows API lets you define what kind of data a variable can hold. If it's a pointer (a reference to another piece of memory), you'll see a "P" in front of its name, like POINTERSIZE_T. Otherwise, there’s no "P". This is handy when you're working with functions that expect a certain type of data or a pointer to that data.

Here are some examples:
  • HANDLE: If you have an HANDLE and want a pointer to it, you add the "P" to get PHANDLE.

  • SIZE_T: You'd say SIZE_T for the value itself, but PSIZE_T if you’re passing around its memory address.

  • DWORD: A regular DWORD is just a number, so it’s PDWORD when you're dealing with its pointer.



These will be important when we use Windows APIs that require us to pass data types or pointers as function parameters.


If you'd like to read more, DM me and i will send the whole PDF.
Session Id:
05d747daf2bc994bd02d49a0025bab1cf9b51516e8ae79e19088d18ec763ab1361
(Mar 15, 2025 02:03 PM)ByteDoktor Wrote:  Introduction
The Windows API helps programs talk to the Windows system. It lets apps show things on the screen, change files, or ask for info from the registry. And if you want to know more about how it works, Microsoft has all the details here

Windows Data Types

The Windows API uses many different kinds of data types that might not be as familiar as basic ones like "int" or "float." Here's an overview, and you can read more about them all on this page: [link].

Here are some examples:

DWORD: A number without a sign (positive only) that takes up 32 bits of space in memory.
Code
DWORD dwVariable = 42;

SIZE_T: Used for counting how many bytes something is. It's always the same size as a pointer on your system—32 bits if you're using a 32-bit system, and 64 bits on a 64-bit system.

Code
SIZE_T sVariable = sizeof(int);

VOID: This means "no data type"—it's used when we don't want to imply that we're dealing with a particular kind of data.


Code
void* pVariable = NULL; // This is the same as PVOID

HANDLE: A special kind of number that the operating system uses to manage things like files or processes.

Code
HANDLE hFile = CreateFile(...);

HMODULE: This is how you refer to a module (like a DLL) by its memory address.

Code
HMODULE hModule = GetModuleHandle(...);

LPCSTR/PCSTR, LPSTR/PSTR, LPCWSTR/PCWSTR, and PWSTR/LPWSTR: These are ways of referring to strings in different forms. "L" means it's a long type (from 16-bit times), "C" means the string is read-only, and "P" means you can read from and write to this string.

Code
LPCSTR  lpcString   = "Hello, world!";
PCSTR   pcString    = "Hello, world!";

Code
LPSTR   lpString    = "Hello, world!";
PSTR    pString     = "Hello, world!";

Code
LPCWSTR     lpwcString  = L"Hello, world!";
PCWSTR      pcwString   = L"Hello, world!";

Code
LPWSTR  lpwString   = L"Hello, world!";
PWSTR   pwString    = L"Hello, world!";

wchar_t: This represents wide characters, or "wchar."
Then there are types like PVOID, which is a pointer to any data type. And ULONG_PTR is used for math with pointers—it's an unsigned integer that's the same size as a pointer on your architecture.

These make it easier to write programs that can do more complex tasks and interact properly with Windows.


Data Types Pointers

The Windows API lets you define what kind of data a variable can hold. If it's a pointer (a reference to another piece of memory), you'll see a "P" in front of its name, like POINTERSIZE_T. Otherwise, there’s no "P". This is handy when you're working with functions that expect a certain type of data or a pointer to that data.

Here are some examples:
  • HANDLE: If you have an HANDLE and want a pointer to it, you add the "P" to get PHANDLE.

  • SIZE_T: You'd say SIZE_T for the value itself, but PSIZE_T if you’re passing around its memory address.

  • DWORD: A regular DWORD is just a number, so it’s PDWORD when you're dealing with its pointer.



These will be important when we use Windows APIs that require us to pass data types or pointers as function parameters.


If you'd like to read more, DM me and i will send the whole PDF.

I thought windows api is mostly just 8bit data and 16 bit data. I know the OS is 32 ot 64bits but I thought the whole windows api is still
8 bits and 16 bits.
[Image: bannerman2-0.png]
Are you talking about the windows internals book?
https://hackforums.net/showthread.php?tid=6333106

Cheap Telegram RAT written in Rust
Good initiative. The Windows API is definitely the tool of the trade. 🙂
[Image: SIGNATURE.png]
Good initiative...........................


Possibly Related Threads...
Thread / Author Replies Views Last Post
[Lua] by SigmaMay 12, 2021 04:43 PM 0 239 May 12, 2021 04:43 PM
Last Post: Sigma
[Assembly] by D3RPAug 6, 2017 05:57 PM 0 253 Aug 6, 2017 05:57 PM
Last Post: D3RP
[Help] by SIM-1550131Feb 4, 2015 09:57 PM 4 202 Feb 4, 2015 09:57 PM
Last Post: Warren Buffett