diff options
author | Davide Beatrici <davidebeatrici@gmail.com> | 2017-01-22 19:09:18 +0300 |
---|---|---|
committer | Jan Klass <kissaki@posteo.de> | 2017-01-29 15:02:58 +0300 |
commit | 474b3700aeef869ca2df37227e9e27aea982e6fe (patch) | |
tree | 8e863342e2ba16fbe8d62aef98ecbc7f03311760 /plugins/bf3 | |
parent | 82d385f6bdd6de8d80b3aa28c87947eb0df12d57 (diff) |
plugins: Fix indentation and whitespace
* Use tabs for indentation
* Remove trailing whitespace
* Space indentation for alignment
Diffstat (limited to 'plugins/bf3')
-rw-r--r-- | plugins/bf3/bf3.cpp | 272 |
1 files changed, 136 insertions, 136 deletions
diff --git a/plugins/bf3/bf3.cpp b/plugins/bf3/bf3.cpp index 46ecb2cd5..85d66b728 100644 --- a/plugins/bf3/bf3.cpp +++ b/plugins/bf3/bf3.cpp @@ -73,159 +73,159 @@ enum state_values { inline bool resolve_ptrs() { team_state_ptr = squad_state_ptr = squad_lead_state_ptr = 0; - /* - Analysis for future patches: - - - state_ptr is always 0x6C after avatar_pos_ptr - - avatar_front_ptr is always 0x30 after avatar_pos_ptr - - avatar_top_ptr is always 0x20 after avatar_pos_ptr - - you can find avatar_pos_ptr easily by jumping in a jet/heli and look at the altitude indicator - - - for squad/team/squad lead pointers, search for your name - - name address - 0x20 = squad lead(1=yes/0=no) - - squad lead - 0x4 = squad number(1=alpha etc) - - squad number - 0x150 = team number(1=US,2=RU) - */ - /* - Magic: - state : 0x238ABDC BYTE 1 when playing - 2 while in menu/dead - - Context: - IP:Port of server: 0x0235DB90 char[128] ip:port of the server - - Identity: - Squad state: BF3.exe+0x01EF25C4 + 0x1C + 0xBC + 0x36C + 0x8 + 0x104 BYTE 0 is not in squad; 1 is in Alpha squad, 2 Bravo, ... , 9 India - SLead state: BF3.exe+0x01EF25C4 + 0x1C + 0xBC + 0x36C + 0x8 + 0x108 BYTE 0 is not lead; 1 is lead - Team state: BF3.exe+0x01EF25C4 + 0x1C + 0xBC + 0x31C BYTE 1 is blufor (US team, for example), 2 is opfor (RU), 0 is probably upcoming spec mode - */ - - procptr32_t base_bf3 = peekProc<procptr32_t>(pModule + base_offset); - if (!base_bf3) - return false; - - procptr32_t offset_ptr1 = peekProc<procptr32_t>(base_bf3 + identity_offset1); - if (!offset_ptr1) return false; - procptr32_t offset_ptr2 = peekProc<procptr32_t>(offset_ptr1 + identity_offset2); - if (!offset_ptr2) return false; - procptr32_t offset_ptr3 = peekProc<procptr32_t>(offset_ptr2 + identity_offset3); - if (!offset_ptr3) return false; - procptr32_t offset_ptr4 = peekProc<procptr32_t>(offset_ptr3 + identity_offset4); - if (!offset_ptr4) return false; - - squad_state_ptr = offset_ptr4 + squad_state_offset; - squad_lead_state_ptr = offset_ptr4 + squad_lead_state_offset; - team_state_ptr = offset_ptr2 + team_state_offset; - - return true; + /* + Analysis for future patches: + + - state_ptr is always 0x6C after avatar_pos_ptr + - avatar_front_ptr is always 0x30 after avatar_pos_ptr + - avatar_top_ptr is always 0x20 after avatar_pos_ptr + - you can find avatar_pos_ptr easily by jumping in a jet/heli and look at the altitude indicator + + - for squad/team/squad lead pointers, search for your name + - name address - 0x20 = squad lead(1=yes/0=no) + - squad lead - 0x4 = squad number(1=alpha etc) + - squad number - 0x150 = team number(1=US,2=RU) + */ + /* + Magic: + state : 0x238ABDC BYTE 1 when playing + 2 while in menu/dead + + Context: + IP:Port of server: 0x0235DB90 char[128] ip:port of the server + + Identity: + Squad state: BF3.exe+0x01EF25C4 + 0x1C + 0xBC + 0x36C + 0x8 + 0x104 BYTE 0 is not in squad; 1 is in Alpha squad, 2 Bravo, ... , 9 India + SLead state: BF3.exe+0x01EF25C4 + 0x1C + 0xBC + 0x36C + 0x8 + 0x108 BYTE 0 is not lead; 1 is lead + Team state: BF3.exe+0x01EF25C4 + 0x1C + 0xBC + 0x31C BYTE 1 is blufor (US team, for example), 2 is opfor (RU), 0 is probably upcoming spec mode + */ + + procptr32_t base_bf3 = peekProc<procptr32_t>(pModule + base_offset); + if (!base_bf3) + return false; + + procptr32_t offset_ptr1 = peekProc<procptr32_t>(base_bf3 + identity_offset1); + if (!offset_ptr1) return false; + procptr32_t offset_ptr2 = peekProc<procptr32_t>(offset_ptr1 + identity_offset2); + if (!offset_ptr2) return false; + procptr32_t offset_ptr3 = peekProc<procptr32_t>(offset_ptr2 + identity_offset3); + if (!offset_ptr3) return false; + procptr32_t offset_ptr4 = peekProc<procptr32_t>(offset_ptr3 + identity_offset4); + if (!offset_ptr4) return false; + + squad_state_ptr = offset_ptr4 + squad_state_offset; + squad_lead_state_ptr = offset_ptr4 + squad_lead_state_offset; + team_state_ptr = offset_ptr2 + team_state_offset; + + return true; } static int fetch(float *avatar_pos, float *avatar_front, float *avatar_top, float *camera_pos, float *camera_front, float *camera_top, std::string &context, std::wstring &identity) { - for (int i=0;i<3;i++) - avatar_pos[i] = avatar_front[i] = avatar_top[i] = camera_pos[i] = camera_front[i] = camera_top[i] = 0.0f; - - char ccontext[128]; - char state; - BYTE squad_state; - BYTE is_squadleader; - BYTE team_state; - bool ok; - - ok = peekProc(state_ptr, &state, 1); // State value - if (! ok) - return false; - - if (state != STATE_IN_GAME && state != STATE_IN_MENU) { - ptr_chain_valid = false; - context.clear(); - identity.clear(); - return true; - } else if (!ptr_chain_valid) { - if (!resolve_ptrs()) - return false; - ptr_chain_valid = true; - } - - ok = peekProc(avatar_pos_ptr, avatar_pos, 12) && - peekProc(avatar_front_ptr, avatar_front, 12) && - peekProc(avatar_top_ptr, avatar_top, 12) && - peekProc(squad_state_ptr,&squad_state,1) && - peekProc(squad_lead_state_ptr, &is_squadleader,1) && - peekProc(team_state_ptr,&team_state,1) && - peekProc(ipport_ptr,ccontext,128); - - if (! ok) - return false; - - ccontext[sizeof(ccontext) - 1] = 0; - if (ccontext[0] != '0') { - std::ostringstream ocontext; - ocontext << "{ \"ipport\": \"" << ccontext << "\" }"; - - context = ocontext.str(); - - /* - Get identity string. - */ - std::wostringstream oidentity; - oidentity << "{" - << "\"squad\":" << static_cast<unsigned int>(squad_state) << "," - << "\"squad_leader\":" << (is_squadleader ? "true" : "false") << ","; - if (team_state == 0) - oidentity << "\"team\": \"SPEC\""; - else if (team_state == 1) - oidentity << "\"team\": \"US\""; - else if (team_state == 2) - oidentity << "\"team\": \"RU\""; - oidentity << "}"; - identity = oidentity.str(); - } - - // Flip our front vector - for (int i=0;i<3;i++) { - avatar_front[i] = -avatar_front[i]; - } - - // Convert from right to left handed - avatar_pos[0] = -avatar_pos[0]; - avatar_front[0] = -avatar_front[0]; - avatar_top[0] = -avatar_top[0]; - - for (int i=0;i<3;i++) { - camera_pos[i] = avatar_pos[i]; - camera_front[i] = avatar_front[i]; - camera_top[i] = avatar_top[i]; - } - - return ok; + for (int i=0;i<3;i++) + avatar_pos[i] = avatar_front[i] = avatar_top[i] = camera_pos[i] = camera_front[i] = camera_top[i] = 0.0f; + + char ccontext[128]; + char state; + BYTE squad_state; + BYTE is_squadleader; + BYTE team_state; + bool ok; + + ok = peekProc(state_ptr, &state, 1); // State value + if (! ok) + return false; + + if (state != STATE_IN_GAME && state != STATE_IN_MENU) { + ptr_chain_valid = false; + context.clear(); + identity.clear(); + return true; + } else if (!ptr_chain_valid) { + if (!resolve_ptrs()) + return false; + ptr_chain_valid = true; + } + + ok = peekProc(avatar_pos_ptr, avatar_pos, 12) && + peekProc(avatar_front_ptr, avatar_front, 12) && + peekProc(avatar_top_ptr, avatar_top, 12) && + peekProc(squad_state_ptr,&squad_state,1) && + peekProc(squad_lead_state_ptr, &is_squadleader,1) && + peekProc(team_state_ptr,&team_state,1) && + peekProc(ipport_ptr,ccontext,128); + + if (! ok) + return false; + + ccontext[sizeof(ccontext) - 1] = 0; + if (ccontext[0] != '0') { + std::ostringstream ocontext; + ocontext << "{ \"ipport\": \"" << ccontext << "\" }"; + + context = ocontext.str(); + + /* + Get identity string. + */ + std::wostringstream oidentity; + oidentity << "{" + << "\"squad\":" << static_cast<unsigned int>(squad_state) << "," + << "\"squad_leader\":" << (is_squadleader ? "true" : "false") << ","; + if (team_state == 0) + oidentity << "\"team\": \"SPEC\""; + else if (team_state == 1) + oidentity << "\"team\": \"US\""; + else if (team_state == 2) + oidentity << "\"team\": \"RU\""; + oidentity << "}"; + identity = oidentity.str(); + } + + // Flip our front vector + for (int i=0;i<3;i++) { + avatar_front[i] = -avatar_front[i]; + } + + // Convert from right to left handed + avatar_pos[0] = -avatar_pos[0]; + avatar_front[0] = -avatar_front[0]; + avatar_top[0] = -avatar_top[0]; + + for (int i=0;i<3;i++) { + camera_pos[i] = avatar_pos[i]; + camera_front[i] = avatar_front[i]; + camera_top[i] = avatar_top[i]; + } + + return ok; } static int trylock(const std::multimap<std::wstring, unsigned long long int> &pids) { - if (! initialize(pids, L"bf3.exe")) - return false; + if (! initialize(pids, L"bf3.exe")) + return false; - float apos[3], afront[3], atop[3], cpos[3], cfront[3], ctop[3]; - std::string context; - std::wstring identity; + float apos[3], afront[3], atop[3], cpos[3], cfront[3], ctop[3]; + std::string context; + std::wstring identity; - if (!fetch(apos, afront, atop, cpos, cfront, ctop, context, identity)) { - generic_unlock(); - return false; - } + if (!fetch(apos, afront, atop, cpos, cfront, ctop, context, identity)) { + generic_unlock(); + return false; + } - return true; + return true; } static const std::wstring longdesc() { - return std::wstring(L"Supports Battlefield 3 with context and identity support."); + return std::wstring(L"Supports Battlefield 3 with context and identity support."); } static std::wstring description(L"Battlefield 3 v1147186 - Endgame"); static std::wstring shortname(L"Battlefield 3"); static int trylock1() { - return trylock(std::multimap<std::wstring, unsigned long long int>()); + return trylock(std::multimap<std::wstring, unsigned long long int>()); } static MumblePlugin bf3plug = { @@ -247,9 +247,9 @@ static MumblePlugin2 bf3plug2 = { }; extern "C" MUMBLE_PLUGIN_EXPORT MumblePlugin *getMumblePlugin() { - return &bf3plug; + return &bf3plug; } extern "C" MUMBLE_PLUGIN_EXPORT MumblePlugin2 *getMumblePlugin2() { - return &bf3plug2; + return &bf3plug2; } |