TORN@DO presents: cRACKER's n0TES
API Details for File Accesses


_lread
The _lread function reads data from the specified file. This function is provided for compatibility with 16-bit versions of Windows. Win32-based applications should use the ReadFile function.
     UINT _lread(
      HFILE  hFile,	                       // handle of file 
      LPVOID  lpBuffer,	                       // address of buffer for read data 
      UINT  uBytes 	                       // length, in bytes, of data buffer 
     );
Returns
The return value indicates the number of bytes actually read from the file. If the number of bytes read is less than uBytes, the function has reached the end of file (EOF) before reading the specified number of bytes.

If the function fails, the return value is HFILE_ERROR. To get extended error information, call GetLastError.




_lwrite
The _lwrite function writes data to the specified file. This function is provided for compatibility with 16-bit versions of Windows. Win32-based applications should use the WriteFile function.
     UINT _lwrite(
      HFILE  hFile,	                       // handle of file 
      LPCSTR  lpBuffer,	                       // address of buffer for data to be written  
      UINT  uBytes 	                       // number of bytes to write 
     );	
Returns
If the function succeeds, the return value indicates the number of bytes actually written to the file.

If the function fails, the return value is HFILE_ERROR. To get extended error information, call GetLastError.




CreateFileA / CreateFileW
The CreateFile function creates, opens, or truncates a file, pipe, communications resource, disk device, or console. It returns a handle that can be used to access the object. It can also open and return a handle to a directory.
     HANDLE CreateFile(
      LPCTSTR  lpFileName,	              // address of name of the file 
      DWORD  dwDesiredAccess,	              // access (read-write) mode 
      DWORD  dwShareMode,	              // share mode 
      LPSECURITY_ATTRIBUTES  lpSecurityAttributes,// address of security descriptor 
      DWORD  dwCreationDistribution,	      // how to create 
      DWORD  dwFlagsAndAttributes,	      // file attributes 
      HANDLE  hTemplateFile 	              // handle of file with attributes to copy  
     );
Returns
If the function succeeds, the return value is an open handle of the specified file. If the specified file exists before the function call and dwCreationDistribution is CREATE_ALWAYS or OPEN_ALWAYS, a call to GetLastError returns ERROR_ALREADY_EXISTS (even though the function has succeeded). If the file does not exist before the call, GetLastError returns zero.

If the function fails, the return value is INVALID_HANDLE_VALUE. To get extended error information, call GetLastError.




GetPrivateProfileIntA / GetPrivateProfileIntW
The GetPrivateProfileInt function retrieves an integer associated with a key in the specified section of the given initialization file. This function is provided for compatibility with 16-bit Windows-based applications. Win32-based applications should store initialization information in the registry.
     UINT GetPrivateProfileInt(
      LPCTSTR  lpAppName,	               // address of section name
      LPCTSTR  lpKeyName,	               // address of key name
      INT  nDefault,	                       // return value if key name is not found
      LPCTSTR  lpFileName 	               // address of initialization filename
     );
Returns
If the function succeeds, the return value is the integer equivalent of the string following the specified key name in the specified initialization file. If the key is not found, the return value is the specified default value. If the value of the key is less than zero, the return value is zero.




GetPrivateProfileStringA / GetPrivateProfileStringW
The GetPrivateProfileString function retrieves a string from the specified section in an initialization file. This function is provided for compatibility with 16-bit Windows-based applications. Win32-based applications should store initialization information in the registry.
     DWORD GetPrivateProfileString(
      LPCTSTR  lpAppName,	               // points to section name 
      LPCTSTR  lpKeyName,	               // points to key name 
      LPCTSTR  lpDefault,	               // points to default string 
      LPTSTR  lpReturnedString,	               // points to destination buffer 
      DWORD  nSize,	                       // size of destination buffer 
      LPCTSTR  lpFileName 	               // points to initialization filename 
     );
Returns
If the function succeeds, the return value is the number of characters copied to the buffer, not including the terminating null character.

If neither lpAppName nor lpKeyName is NULL and the supplied destination buffer is too small to hold the requested string, the string is truncated and followed by a null character, and the return value is equal to nSize minus one.

If either lpAppName or lpKeyName is NULL and the supplied destination buffer is too small to hold all the strings, the last string is truncated and followed by two null characters. In this case, the return value is equal to nSize minus two.




ReadFileA
The ReadFile function reads data from a file, starting at the position indicated by the file pointer. After the read operation has been completed, the file pointer is adjusted by the number of bytes actually read, unless the file handle is created with the overlapped attribute. If the file handle is created for overlapped input and output (I/O), the application must adjust the position of the file pointer after the read operation.
     BOOL ReadFile(
      HANDLE  hFile,	                       // handle of file to read 
      LPVOID  lpBuffer,	                       // address of buffer that receives data  
      DWORD  nNumberOfBytesToRead,	       // number of bytes to read 
      LPDWORD  lpNumberOfBytesRead,	       // address of number of bytes read 
      LPOVERLAPPED  lpOverlapped 	       // address of structure for data 
     );
Returns
If the function succeeds, the return value is TRUE. If the return value is TRUE and the number of bytes read is zero, the file pointer was beyond the current end of the file at the time of the read operation.

If the function fails, the return value is FALSE. To get extended error information, call GetLastError.




ReadFileEx
The ReadFileEx function reads data from a file asynchronously. It is designed solely for asynchronous operation, unlike the ReadFile function, which is designed for both synchronous and asynchronous operation. ReadFileEx lets an application perform other processing during a file read operation.

The ReadFileEx function reports its completion status asynchronously, calling a specified completion routine when reading is completed and the calling thread is in an alertable wait state.

     BOOL ReadFileEx(
      HANDLE  hFile,	                       // handle of file to read 
      LPVOID  lpBuffer,	                       // address of buffer 
      DWORD  nNumberOfBytesToRead,	       // number of bytes to read 
      LPOVERLAPPED  lpOverlapped,	       // address of offset 
      LPOVERLAPPED_COMPLETION_ROUTINE  lpCompletionRoutine // address of completion routine 
     );
Returns
If the function succeeds, the return value is TRUE.

If the function fails, the return value is FALSE. To get extended error information, call GetLastError.

If the function succeeds, the calling thread has an asynchronous I/O (input/output) operation pending: the overlapped read operation from the file. When this I/O operation completes, and the calling thread is blocked in an alertable wait state, the system calls the function pointed to by lpCompletionRoutine, and the wait state completes with a return code of WAIT_IO_COMPLETION.

If the function succeeds, and the file reading operation completes, but the calling thread is not in an alertable wait state, the system queues the completion routine call, holding the call until the calling thread enters an alertable wait state. For information about alertable waits and overlapped input/output operations, see Synchronization and Overlapped Input and Output.

If ReadFileEx attempts to read past the end of the file, the function returns FALSE, and GetLastError returns ERROR_HANDLE_EOF.




SetFilePointer
The SetFilePointer function moves the file pointer of an open file.
    DWORD SetFilePointer(
      HANDLE  hFile,	                       // handle of file 
      LONG  lDistanceToMove,	               // number of bytes to move file pointer 
      PLONG  lpDistanceToMoveHigh,	       // address of high-order word of dist. to move  
      DWORD  dwMoveMethod 	               // how to move 
     );
Returns
If the SetFilePointer function succeeds, the return value is the low-order doubleword of the new file pointer, and if lpDistanceToMoveHigh is not NULL, the function puts the high-order doubleword of the new file pointer into the LONG pointed to by that parameter.

If the function fails and lpDistanceToMoveHigh is NULL, the return value is 0xFFFFFFFF. To get extended error information, call GetLastError.

If the function fails, and lpDistanceToMoveHigh is non-NULL, the return value is 0xFFFFFFFF and GetLastError will return a value other than NO_ERROR.




WriteFile
The WriteFile function writes data to a file and is designed for both synchronous and asynchronous operation. The function starts writing data to the file at the position indicated by the file pointer. After the write operation has been completed, the file pointer is adjusted by the number of bytes actually written, except when the file is opened with FILE_FLAG_OVERLAPPED. If the file handle was created for overlapped input and output (I/O), the application must adjust the position of the file pointer after the write operation is finished.
    BOOL WriteFile(
      HANDLE  hFile,	                      // handle of file to write to 
      LPCVOID  lpBuffer,	              // address of data to write to file 
      DWORD  nNumberOfBytesToWrite,	      // number of bytes to write 
      LPDWORD  lpNumberOfBytesWritten,	      // address of number of bytes written 
      LPOVERLAPPED  lpOverlapped 	      // addr. of structure needed for overlapped I/O  
     );
Returns
If the function succeeds, the return value is TRUE.

If the function fails, the return value is FALSE. To get extended error information, call GetLastError.




WriteFileEx
The WriteFileEx function writes data to a file. It is designed solely for asynchronous operation, unlike WriteFile, which is designed for both synchronous and asynchronous operation.

WriteFileEx reports its completion status asynchronously, calling a specified completion routine when writing is completed and the calling thread is in an alertable wait state.

    BOOL WriteFileEx(
      HANDLE  hFile; 	                      // handle to output file
      LPCVOID  lpBuffer; 	              // pointer to input buffer
      DWORD  nNumberOfBytesToWrite; 	      // number of bytes to write
      LPOVERLAPPED  lpOverlapped; 	      // pointer to async. i/o data
      LPOVERLAPPED_COMPLETION_ROUTINE  lpCompletionRoutine; // ptr. to completion routine
    );
Returns
If the function succeeds, the return value is TRUE.

If the function fails, the return value is FALSE. To get extended error information, call GetLastError.

If the WriteFileEx function succeeds, the calling thread has an asynchronous I/O (input/output) operation pending: the overlapped write operation to the file. When this I/O operation finishes, and the calling thread is blocked in an alertable wait state, the operating system calls the function pointed to by lpCompletionRoutine, and the wait completes with a return code of WAIT_IO_COMPLETION.

If the function succeeds and the file-writing operation finishes, but the calling thread is not in an alertable wait state, the system queues the call to *lpCompletionRoutine, holding the call until the calling thread enters an alertable wait state. See Synchronization for more information about alertable wait states and overlapped input/output operations.




WritePrivateProfileStringA / WritePrivateProfileStringW
If the function successfully copies the string to the initialization file, the return value is TRUE.

If the function fails, or if it flushes the cached version of the most recently accessed initialization file, the return value is FALSE. To get extended error information, call GetLastError.

    BOOL WritePrivateProfileString(
      LPCTSTR  lpszSection,	              // address of section name 
      LPCTSTR  lpszKey,	                      // address of key name 
      LPCTSTR  lpszString,	              // address of string to add 
      LPCTSTR  lpszFile 	              // address of initialization filename 
    );
Returns
If the function successfully copies the string to the initialization file, the return value is TRUE.

If the function fails, or if it flushes the cached version of the most recently accessed initialization file, the return value is FALSE. To get extended error information, call GetLastError.





The cRACKER's n0tES are divided into 10 main parts:
 00. INDEX
 01. Assembly for Crackers (CoRN2)
 02. SoftICE (Boot Menu, Setup, Commands)
 03. Breakpoints & Win API Details
        1 Crippled Programs
        2 Dialog Boxes
        3 Drive Type Checks
        4 File Accesses
        5 Registry Accesses
        6 Serial Catching
        7 Time & Date Accesses
        8 Window Generating
 04. Jump Instructions
 05. SET Instructions
 06. Tips & Tricks for Cracking
 07. Window Messages For Crackers
 08. Identifying Functions, Arguments, and Variables (Rhayader)
 09. Commerical Protection Systems
 10. Bitmanipulation (Cruehead)
 11. General Cracking Theory
 12. FAQ

 +A. How to contact me
 +B. What's New?



The cRACKER's n0TES are Copyright © 1998-2000 by TORN@DO of ID. All Rights Reserved. Archived and Re-hosted by Werdstaff