BWAPI
Classes | Defines | Functions | Variables
trunk/bwapi/BWAPI_ChaosLauncherInjector/source/DLLMain.cpp File Reference
#include <stdio.h>
#include <windows.h>
#include <string>
#include <assert.h>
#include "../../svnrev.h"
#include "../../starcraftver.h"
#include "../../Debug.h"
Include dependency graph for DLLMain.cpp:

Classes

struct  ExchangeData

Defines

#define MODULE   "BWAPI.dll"

Functions

DWORD GetRegString (HKEY hBaseKey, const char *pszSubKey, const char *pszValueName, char *pszOutput, DWORD *dwOutSize)
bool BWAPIError (DWORD dwErrCode, const char *format,...)
bool BWAPIError (const char *format,...)
BOOL APIENTRY DllMain (HMODULE, DWORD, LPVOID)
 __declspec (dllexport) void GetPluginAPI(ExchangeData &Data)
 sprintf_s (newDescription, 512,"Injects "MODULE" into the Broodwar process.\r\n\r\nRevision %s.\r\nCheck for updates at http://bwapi.googlecode.com/ \r\n\r\nCreated by the BWAPI Project Team", SVN_REV_STR)
 strcpy (name,"BWAPI Injector ("STARCRAFT_VER") "BUILD_STR)
 strcpy (description, newDescription)
 strcpy (updateurl,"http://bwapi.googlecode.com/files/")
 if (!GetEnvironmentVariable("ChaosDir", envBuffer, MAX_PATH))
 strcat (envBuffer,"\\"MODULE)
 if (dwFileAttribs==INVALID_FILE_ATTRIBUTES||dwFileAttribs &FILE_ATTRIBUTE_DIRECTORY)
 if (!loadLibAddress) return BWAPIError(GetLastError()
 if (bytesWritten!=dwDllSize) BWAPIError("WriteToProcessMemory bytesWritten is not the expected value.")
 if (WaitForSingleObject(hThread, INFINITE)==WAIT_FAILED)
 if (!GetExitCodeThread(hThread,&dwExitCode))
 VirtualFreeEx (hProcess, pathAddress, dwDllSize, MEM_RELEASE)
 CloseHandle (hThread)

Variables

char * description
char char *updateurl char newDescription [512]
DWORD return true
DWORD char envBuffer [MAX_PATH]
bool envFailed = false
DWORD dwFileAttribs = GetFileAttributes(envBuffer)
DWORD dwDllSize = strlen(envBuffer)+1
LPTHREAD_START_ROUTINE loadLibAddress = (LPTHREAD_START_ROUTINE)GetProcAddress(GetModuleHandle("Kernel32"), "LoadLibraryA" )
Could not get Proc Address for LoadLibraryA
void * pathAddress = VirtualAllocEx(hProcess, NULL, dwDllSize, MEM_COMMIT, PAGE_READWRITE)
Could not allocate memory for DLL path
SIZE_T bytesWritten
BOOL success = WriteProcessMemory(hProcess, pathAddress, envBuffer, dwDllSize, &bytesWritten)
HANDLE hThread = CreateRemoteThread(hProcess, NULL, 0, loadLibAddress, pathAddress, 0, NULL)
DWORD dwExitCode = NULL
Injection failed nThis is
caused when BWAPI crashes
before injecting 
completely

Define Documentation

#define MODULE   "BWAPI.dll"

Function Documentation

__declspec ( dllexport  )
bool BWAPIError ( DWORD  dwErrCode,
const char *  format,
  ... 
)
bool BWAPIError ( const char *  format,
  ... 
)

Here is the caller graph for this function:

BOOL APIENTRY DllMain ( HMODULE  ,
DWORD  ,
LPVOID   
)
DWORD GetRegString ( HKEY  hBaseKey,
const char *  pszSubKey,
const char *  pszValueName,
char *  pszOutput,
DWORD dwOutSize 
)

Here is the caller graph for this function:

if ( GetEnvironmentVariable"ChaosDir", envBuffer, MAX_PATH)

Here is the call graph for this function:

Here is the caller graph for this function:

if ( dwFileAttribs  = = INVALID_FILE_ATTRIBUTES || dwFileAttribs & FILE_ATTRIBUTE_DIRECTORY)

Here is the call graph for this function:

if ( loadLibAddress)

Here is the call graph for this function:

if ( bytesWritten!  = dwDllSize)
if ( WaitForSingleObject(hThread, INFINITE)  = = WAIT_FAILED)

Here is the call graph for this function:

if ( GetExitCodeThreadhThread,&dwExitCode)

Here is the call graph for this function:

sprintf_s ( newDescription  ,
512  ,
"Injects "MODULE" into the Broodwar process.\r\n\r\nRevision %s.\r\nCheck for updates at http://bwapi.googlecode.com/ \r\n\r\nCreated by the BWAPI Project Team"  ,
SVN_REV_STR   
)

Here is the caller graph for this function:

strcat ( envBuffer  ,
"\\"  MODULE 
)

Here is the caller graph for this function:

strcpy ( name  ,
"BWAPI Injector ("STARCRAFT_VER") "  BUILD_STR 
)

Here is the caller graph for this function:

strcpy ( updateurl  ,
"http://bwapi.googlecode.com/files/"   
)
VirtualFreeEx ( hProcess  ,
pathAddress  ,
dwDllSize  ,
MEM_RELEASE   
)

Here is the caller graph for this function:


Variable Documentation

SIZE_T bytesWritten
Injection failed nThis is caused when BWAPI crashes before injecting completely
char* description
DWORD dwDllSize = strlen(envBuffer)+1
DWORD dwFileAttribs = GetFileAttributes(envBuffer)
DWORD char envBuffer[MAX_PATH]
bool envFailed = false
HANDLE hThread = CreateRemoteThread(hProcess, NULL, 0, loadLibAddress, pathAddress, 0, NULL)
LPTHREAD_START_ROUTINE loadLibAddress = (LPTHREAD_START_ROUTINE)GetProcAddress(GetModuleHandle("Kernel32"), "LoadLibraryA" )
Could not get Proc Address for LoadLibraryA
char char* updateurl char newDescription[512]
Could not allocate memory for DLL path
void* pathAddress = VirtualAllocEx(hProcess, NULL, dwDllSize, MEM_COMMIT, PAGE_READWRITE)
return true
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines