Advertisement
Guest User

Untitled

a guest
Apr 1st, 2015
497
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.98 KB | None | 0 0
  1. /* Copyright (C) 2005-2012, Snares <snares@users.sourceforge.net>
  2.    Copyright (C) 2005-2012, Thorvald Natvig <thorvald@natvig.com>
  3.  
  4.    All rights reserved.
  5.  
  6.    Redistribution and use in source and binary forms, with or without
  7.    modification, are permitted provided that the following conditions
  8.    are met:
  9.  
  10.    - Redistributions of source code must retain the above copyright notice,
  11.      this list of conditions and the following disclaimer.
  12.    - Redistributions in binary form must reproduce the above copyright notice,
  13.      this list of conditions and the following disclaimer in the documentation
  14.      and/or other materials provided with the distribution.
  15.    - Neither the name of the Mumble Developers nor the names of its
  16.      contributors may be used to endorse or promote products derived from this
  17.      software without specific prior written permission.
  18.  
  19.    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  20.    ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  21.    LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  22.    A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR
  23.    CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  24.    EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  25.    PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  26.    PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  27.    LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  28.    NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  29.    SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  30. */
  31.  
  32. #include "../mumble_plugin_win32.h"
  33.  
  34. HANDLE h;
  35. BYTE *posptr;
  36. BYTE *frontptr;
  37. BYTE *topptr;
  38.  
  39. static int fetch(float *avatar_pos, float *avatar_front, float *avatar_top, float *camera_pos, float *camera_front, float *camera_top, std::string &, std::wstring &) {
  40.     for (int i=0;i<3;i++)
  41.         avatar_pos[i] = avatar_front[i] = avatar_top[i] = camera_pos[i] = camera_front[i] = camera_top[i] = 0.0f;
  42.  
  43.     BYTE *base_arma3 = peekProc<BYTE *>(pModule + 0x015400C8);
  44.     if (!base_arma3) return false;
  45.     BYTE *offset_ptr1 = base_arma3 + 0x318;
  46.     if (!offset_ptr1) return false;
  47.    
  48.     posptr = offset_ptr1 + 0x0; //address of camera pos x, y + 0x4, z + 0x8.
  49.     frontptr = offset_ptr1 - 0x18; //address of camera front x, y + 0x4, z + 0x8.
  50.     topptr = offset_ptr1 - 0xC; //address of camera top x, , y + 0x4, z + 0x8.
  51.    
  52.     bool ok;
  53.  
  54.     ok = peekProc(posptr, avatar_pos, 12) &&
  55.          peekProc(frontptr, avatar_front, 12) &&
  56.          peekProc(topptr, avatar_top, 12);
  57.  
  58.     if (avatar_pos[1] > 999000000.0)
  59.         return false;
  60.  
  61.     if (! ok)
  62.         return false;
  63.  
  64.     for (int i=0;i<3;i++) {
  65.         camera_pos[i] = avatar_pos[i];
  66.         camera_front[i] = avatar_front[i];
  67.         camera_top[i] = avatar_top[i];
  68.     }
  69.  
  70.     return true;
  71. }
  72.  
  73. static int trylock(const std::multimap<std::wstring, unsigned long long int> &pids) {
  74.  
  75.      if (! initialize(pids, L"arma3.exe"))
  76.         return false;
  77.    
  78.     float apos[3], afront[3], atop[3], cpos[3], cfront[3], ctop[3];
  79.     std::string context;
  80.     std::wstring identity;
  81.  
  82.     if (fetch(apos, afront, atop, cpos, cfront, ctop, context, identity)) {
  83.         return true;
  84.     } else {
  85.         generic_unlock();
  86.         return false;
  87.     }
  88. }
  89.  
  90. static const std::wstring longdesc() {
  91.     return std::wstring(L"No identity or context support.");
  92. }
  93.  
  94. static std::wstring description(L"ArmA 3 v1.40.129533");
  95. static std::wstring shortname(L"ArmA 3");
  96.  
  97. static int trylock1() {
  98.     return trylock(std::multimap<std::wstring, unsigned long long int>());
  99. }
  100.  
  101. static MumblePlugin arma2plug = {
  102.     MUMBLE_PLUGIN_MAGIC,
  103.     description,
  104.     shortname,
  105.     NULL,
  106.     NULL,
  107.     trylock1,
  108.     generic_unlock,
  109.     longdesc,
  110.     fetch
  111. };
  112.  
  113. static MumblePlugin2 arma2plug2 = {
  114.     MUMBLE_PLUGIN_MAGIC_2,
  115.     MUMBLE_PLUGIN_VERSION,
  116.     trylock
  117. };
  118.  
  119.  
  120. extern "C" __declspec(dllexport) MumblePlugin *getMumblePlugin() {
  121.     return &arma2plug;
  122. }
  123.  
  124. extern "C" __declspec(dllexport) MumblePlugin2 *getMumblePlugin2() {
  125.     return &arma2plug2;
  126. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement