Skip to content
This repository has been archived by the owner on Feb 13, 2023. It is now read-only.

Commit

Permalink
Merge pull request #14 from idietmoran/dev
Browse files Browse the repository at this point in the history
added cross-world support for dx11
  • Loading branch information
Stateford committed Nov 15, 2017
2 parents c49b814 + 3fb990c commit 0584294
Show file tree
Hide file tree
Showing 12 changed files with 154 additions and 33 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
/Release/
/full release/
/Output/
/src/config/

.gitmodules
packages.config
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Changelog
All notable changes to this project will be documented in this file.

## [0.0.6]
### Added
- Cross-world party support for DX11

## [0.0.5]
### Added
- Attempts to bring up users page. If multiple users are found, the search page will be brought up.
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ This program reads the names of party members by memory and opens their username
[Youtube](https://youtu.be/r9TKVYfq_b0)

#### Known Issues
- Doesn't update cross-world parties (The memory addresses for cross-world are not static, it's going to take some digging and some patient people)
- Doesn't update cross-world parties on DX9
- Lists previous members in the party list until someone new overwrites their position (thank SE for this, still looking for solution)

#### TODO
----------------
- Cross-world Parties
- Cross-world Parties for DX9
- Add stats directly to program
- UI

Expand Down
5 changes: 0 additions & 5 deletions main.cpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
#include "src/menu.h"
#include <thread>


int main()
{
Menu menu;
std::thread t1([=, &menu] { menu.start(); });
t1.join();

menu.start();

return 0;
Expand Down
41 changes: 41 additions & 0 deletions src/arch/arch.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "arch.h"
#include <iostream>


bool Arch::x64 = false;
Expand Down Expand Up @@ -35,11 +36,26 @@ bool Arch::checkArrayForDoubles(std::string name)
return false;
}

bool Arch::checkArrayForDoublesCW(std::string name)
{
for (auto &p : filteredAlliesCW_)
{
if (p->name_ == name)
{
return true;
}
}
return false;
}

void Arch::filterAllies()
{
filteredAllies_.clear();
filteredAlliesCW_.clear();
//filteredAllies_.reserve(8);
filteredAllies_.push_back(allies_[0]);
filteredAlliesCW_.push_back(alliesCW_[0]);

for (auto &p : allies_)
{
// dont add doubles or empty arrays
Expand All @@ -48,6 +64,15 @@ void Arch::filterAllies()
filteredAllies_.push_back(p);
}
}

for(auto &p : alliesCW_)
{
if(!checkArrayForDoublesCW(p->name_) && p->name_[0] != NULL)
{
filteredAlliesCW_.push_back(p);
}
}

}

void Arch::updateNames(Process* proc, int &partyMembers)
Expand All @@ -56,14 +81,30 @@ void Arch::updateNames(Process* proc, int &partyMembers)
{
ReadProcessMemory(proc->getHandle(), (void*)(exe_->getAddress() + p->address_), &p->name_, 80, 0);
}
for(auto &p : alliesCW_)
{
ReadProcessMemory(proc->getHandle(), (void*)(p->address_), &p->name_, 80, 0);
}

filterAllies();

updateNumberOfPartyMembers(proc, partyMembers);
checkCrossWorldParty(proc);
}



std::vector<Player*> Arch::getFilteredAllies()
{
return filteredAllies_;
}

std::vector<Player*> Arch::getFilteredAlliesCW()
{
return filteredAlliesCW_;
}

bool Arch::getCrossWorldStatus()
{
return inCrossWorldParty_;
}
9 changes: 8 additions & 1 deletion src/arch/arch.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,25 @@ class Arch
protected:
Module *exe_;
Offset *numberOfPartyMembers_;
bool inCrossWorldParty_ = false;
std::vector<Player*> allies_;
std::vector<Player*> filteredAllies_;
std::vector<Player*> alliesCW_;
std::vector<Player*> filteredAlliesCW_;
public:
Arch();
virtual ~Arch() = 0;
virtual void createAllies() = 0;
virtual void createAllies(Process*) = 0;
virtual void updateNumberOfPartyMembers(Process*, int&) = 0;
virtual void checkCrossWorldParty(Process*) = 0;
static bool x64;
void deleteAllies();
bool checkArrayForDoubles(std::string);
bool checkArrayForDoublesCW(std::string name);
void filterAllies();
void updateNames(Process*, int&);
std::vector<Player*> getFilteredAllies();
std::vector<Player*> getFilteredAlliesCW();
bool getCrossWorldStatus();
};

25 changes: 22 additions & 3 deletions src/arch/x64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* is running in 64-bit, which requires being able to read 64-bit hexadecimal addresses
*/
#include "x64.h"

#include <iostream>

x64::x64(Process* proc)
{
Expand All @@ -15,7 +15,7 @@ x64::x64(Process* proc)
Arch::x64 = true;
}

createAllies();
createAllies(proc);
}

x64::~x64()
Expand All @@ -27,7 +27,7 @@ x64::~x64()
numberOfPartyMembers_ = nullptr;
}

void x64::createAllies()
void x64::createAllies(Process* proc)
{
// dx11 64-bit offsets
allies_.push_back(new YOU(0x1828AE1));
Expand All @@ -39,9 +39,28 @@ void x64::createAllies()
allies_.push_back(new Ally(0x184AC10));
allies_.push_back(new Ally(0x184A390));
allies_.push_back(new Ally(0x184AE30));

alliesCW_.push_back(allies_[0]); // YOU
DWORD64 address = exe_->getAddress();
address += 0x017E6620;

ReadProcessMemory(proc->getHandle(), (void*)address, &address, sizeof(DWORD64), 0);
address += 0x2E8;
alliesCW_.push_back(new Ally(address));


for(int i = 0; i < 6; i++)
{
alliesCW_.push_back(new Ally(address += 0x48));
}
}

void x64::updateNumberOfPartyMembers(Process* proc, int &partyMembers)
{
ReadProcessMemory(proc->getHandle(), (void*)(numberOfPartyMembers_->getMemoryAddress64(proc, exe_)), &partyMembers, sizeof(int), 0);
}

void x64::checkCrossWorldParty(Process* proc)
{
ReadProcessMemory(proc->getHandle(), (void*)(exe_->getAddress() + 0x1848F0C), &inCrossWorldParty_, 1, 0);
}
3 changes: 2 additions & 1 deletion src/arch/x64.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ class x64 : public Arch
public:
x64(Process*);
~x64();
void createAllies() override;
void createAllies(Process*) override;
void updateNumberOfPartyMembers(Process*, int&) override;
void checkCrossWorldParty(Process*) override;
};

9 changes: 7 additions & 2 deletions src/arch/x86.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ x86::x86(Process* proc)
Sleep(3000);
exit(0);
}
createAllies();
createAllies(proc);
}


Expand All @@ -34,7 +34,7 @@ x86::~x86()
numberOfPartyMembers_ = nullptr;
}

void x86::createAllies()
void x86::createAllies(Process* proc)
{
allies_.reserve(8);
// dx9 32-bit offsets
Expand All @@ -53,4 +53,9 @@ void x86::createAllies()
void x86::updateNumberOfPartyMembers(Process *proc, int &partyMembers)
{
ReadProcessMemory(proc->getHandle(), (void*)(numberOfPartyMembers_->getMemoryAddress(proc, exe_)), &partyMembers, sizeof(int), 0);
}

void x86::checkCrossWorldParty(Process* proc)
{
// do nothing for the time being
}
3 changes: 2 additions & 1 deletion src/arch/x86.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ class x86 : public Arch
x86(Process*);
~x86();
void updateNumberOfPartyMembers(Process*, int&) override;
void createAllies() override;
void createAllies(Process*) override;
void checkCrossWorldParty(Process* proc) override;
};

81 changes: 64 additions & 17 deletions src/menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,28 +22,64 @@ void Menu::displayAllies()
// update play characters names
fflogs_->arch_->updateNames(fflogs_->ffxiv_, fflogs_->partyMembers_);


int partyMembers = fflogs_->partyMembers_;
SetConsoleTextAttribute(hConsole_, 7);
// display title
std::cout << "FFXIV Party Logs\n";
std::cout << "--------------------\n";
std::cout << "--------------------";

/*
* NOTE: It's impossible to determine people no longer in the party without parsing the chat log
* TODO: Maybe in the future
*/
if(fflogs_->arch_->getCrossWorldStatus())
{
SetConsoleTextAttribute(hConsole_, 13);
std::cout << "\nCROSSWORLD PARTY" << std::endl;

if(fflogs_->arch_->getFilteredAlliesCW().size() < fflogs_->partyMembers_)
{
partyMembers = fflogs_->arch_->getFilteredAlliesCW().size();
}

for (int i = 0; i < fflogs_->arch_->getFilteredAllies().size(); i++)
for (int i = 0; i < partyMembers; i++)
{
SetConsoleTextAttribute(hConsole_, 7);
// highlight current line
if (i == currentMenuSelection_)
{
SetConsoleTextAttribute(hConsole_, 23);
}
fflogs_->arch_->getFilteredAlliesCW()[i]->display();
}
// this prevents the colors from breaking

}
// if normal party
else
{
SetConsoleTextAttribute(hConsole_, 7);
if (i == currentMenuSelection_)
SetConsoleTextAttribute(hConsole_, 3);
std::cout << "\nNORMAL PARTY" << std::endl;

if (fflogs_->arch_->getFilteredAllies().size() < fflogs_->partyMembers_)
{
SetConsoleTextAttribute(hConsole_, 23);
partyMembers = fflogs_->arch_->getFilteredAllies().size();
}
//fflogs_->arch_->getFilteredAllies()[i]->display();
fflogs_->arch_->getFilteredAllies()[i]->display();

for (int i = 0; i < partyMembers; i++)
{
SetConsoleTextAttribute(hConsole_, 7);
// higlight current line
if (i == currentMenuSelection_)
{
SetConsoleTextAttribute(hConsole_, 23);
}
fflogs_->arch_->getFilteredAllies()[i]->display();
}
// this prevents the colors from breaking
}
// this prevents the colors from breaking
/*
* NOTE: It's impossible to determine people no longer in the party without parsing the chat log
* TODO: Maybe in the future
*/


SetConsoleTextAttribute(hConsole_, 7);
}

Expand All @@ -61,13 +97,18 @@ void Menu::alliesMenu(DWORD &mode, INPUT_RECORD &event, HANDLE &hstdin)
system("CLS");
displayAllies();
prevPartySize_ = fflogs_->partyMembers_;
prevCrossWorldStatus_ = fflogs_->arch_->getCrossWorldStatus();

while(live_)
{
fflogs_->arch_->updateNames(fflogs_->ffxiv_, fflogs_->partyMembers_);

if(prevPartySize_ != fflogs_->partyMembers_)

// checks if party size changes, or party changes to crossworld and displays the changes
if(prevPartySize_ != fflogs_->partyMembers_ || prevCrossWorldStatus_ != fflogs_->arch_->getCrossWorldStatus())
{
prevPartySize_ = fflogs_->partyMembers_;
prevCrossWorldStatus_ = fflogs_->arch_->getCrossWorldStatus();
redraw();
}

Expand All @@ -89,7 +130,7 @@ void Menu::alliesMenu(DWORD &mode, INPUT_RECORD &event, HANDLE &hstdin)

if(GetAsyncKeyState(VK_DOWN) & 0x1 && isConsoleWindowFocussed)
{
if (currentMenuSelection_ < fflogs_->arch_->getFilteredAllies().size() - 1)
if (currentMenuSelection_ < fflogs_->partyMembers_ - 1)
{
currentMenuSelection_++;
redraw();
Expand All @@ -98,9 +139,15 @@ void Menu::alliesMenu(DWORD &mode, INPUT_RECORD &event, HANDLE &hstdin)

if(GetAsyncKeyState(VK_RETURN) & 0x1 && isConsoleWindowFocussed)
{
fflogs_->arch_->getFilteredAllies()[currentMenuSelection_]->openBrowser();
if(fflogs_->arch_->getCrossWorldStatus())
{
fflogs_->arch_->getFilteredAlliesCW()[currentMenuSelection_]->openBrowser();
}
else
{
fflogs_->arch_->getFilteredAllies()[currentMenuSelection_]->openBrowser();
}
}

Sleep(1);
}
}
Expand Down
Loading

0 comments on commit 0584294

Please sign in to comment.