-   Notifications  
You must be signed in to change notification settings  - Fork 1.2k
 
Developer Guidelines
 Graham Sutherland edited this page Jul 19, 2018  · 1 revision 
 Some general dev guidelines:
- Run a full set of checks on your machine before making changes to code, then compare to another full set of checks afterwards. This helps identify regressions.
 - Add new includes and lib pragmas to 
stdafx.hrather than individual files. This saves duplication. - Checks should not use 
printfwhere possible. 
In many cases you'll want to call an external API, and in some cases you may want to use LoadLibrary and GetProcAddress to do dynamic loading of APIs that might not always exist due to different OS versions.
Al-Khaser has a single unified approach to doing external API calls to help minimise code duplication and also provide automatic runtime reporting of APIs that appear to be missing when they shouldn't be (e.g. due to hooks on GetProcAddress).
The key files are:
- Shared\APIs.cpp - Contains API definitions (identifier, library, export name, min OS version)
 - Shared\ApiTypeDefs.h - Contains all function pointer typedefs.
 - Shared\APIs.h - Contains the 
API_IDENTIFIERenum. Each entry in this enum uniquely identifies an API. 
To add a new API, take thew following steps:
- First check if the API has already been imported in 
Shared\APIs.cpp. If so, you can skip to the end. - Define your function's typedef in 
ApiTypeDefs.h. Stick to the naming convention ofpSomeFunction. - Add a new identifier for the API in the 
API_IDENTIFIERenum inAPIs.h. - Add a definition for the API in the 
ApiDataarray inAPIs.cpp. - Use the API in your code as follows:
 
if (API::IsAvailable(API_IDENTIFIER::API_SomeFunction)) { auto SomeFunction = static_cast<pSomeFunction>(API::GetAPI(API_IDENTIFIER::API_SomeFunction)); // do something with SomeFunction() } Please try to keep the API lists in alphabetical order.