Skip to content

Commit

Permalink
fix(path): path is not saved correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
MurkyYT committed May 9, 2024
1 parent fa817aa commit 58a38cb
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 15 deletions.
14 changes: 8 additions & 6 deletions src/AndroDem/AndroDem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,16 +101,17 @@ void ParseArgv(LPWSTR lpCmdLine)
}
BOOL FilesPresent()
{
const wchar_t* buf = GetCurrentDir().c_str();
std::wstring path = GetCurrentDir();
const wchar_t* buf = path.c_str();
std::wstring adbExe = ADB::GetADBPath();
std::wstring adbApiDLL = std::wstring(buf).append(L"\\data\\AdbWinApi.dll");
std::wstring adbApiUSBDLL = std::wstring(buf).append(L"\\data\\AdbWinUsbApi.dll");
std::wstring classesDex = std::wstring(buf).append(L"\\data\\classes.dex");

return FileExists(ws2s(adbExe).c_str())
&& FileExists(ws2s(adbApiDLL).c_str())
&& FileExists(ws2s(adbApiUSBDLL).c_str())
&& FileExists(ws2s(classesDex).c_str());
return FileExists(adbExe.c_str())
&& FileExists(adbApiDLL.c_str())
&& FileExists(adbApiUSBDLL.c_str())
&& FileExists(classesDex.c_str());
}
DWORD WINAPI TimerProc()
{
Expand Down Expand Up @@ -458,7 +459,8 @@ void ConnectToDevice(std::wstring& device)
return;
}
// Windows on auto startup default dir is c:\system32\windows
const wchar_t* buf = GetCurrentDir().c_str();
std::wstring path = GetCurrentDir();
const wchar_t* buf = path.c_str();
std::wstring pushLocal = std::wstring(L"push \"").append(buf).append(L"\\data\\classes.dex\" \"data/local/tmp\"");
config.currentDevice = device;
if(ADB::SendCommandToDevice(pushLocal.c_str(), config.currentDevice).find(L"adb: error: failed to copy") != std::string::npos)
Expand Down
4 changes: 2 additions & 2 deletions src/AndroDem/resource.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Used by AndroDem.rc
//
#define VER "1.0.0"
#define COMMA_VER 1,0,0
#define VER "1.0.1"
#define COMMA_VER 1,0,1
#define IDI_ANDRODEM 100
#define IDI_LEVEL0WIFI 101
#define IDI_LEVEL1WIFI 102
Expand Down
3 changes: 2 additions & 1 deletion src/AndroDem/utils/ADB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,8 @@ std::wstring ADB::GetADBPath()
if (!ADB::m_adbPath.empty())
return ADB::m_adbPath;

const wchar_t* buffer = GetCurrentDir().c_str();
std::wstring path = GetCurrentDir();
const wchar_t* buffer = path.c_str();

ADB::m_adbPath = std::wstring(buffer).append(L"\\data\\adb.exe");
return ADB::m_adbPath;
Expand Down
4 changes: 2 additions & 2 deletions src/AndroDem/utils/RegistrySettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ std::wstring RegistrySettings::getWideString(const std::string& name)
}
BOOL RegistrySettings::getString(const std::string& name,LPCWSTR* buf)
{
*buf = L"";
*buf = L"\0";
std::wstring wValue = s2ws(name);
DWORD dwBufSize = 0;
DWORD valueType = 0;
Expand All @@ -42,7 +42,7 @@ BOOL RegistrySettings::getString(const std::string& name,LPCWSTR* buf)
(BYTE*)(*buf), &dwBufSize);
return TRUE;
}
return FALSE;;
return FALSE;
}
BOOL RegistrySettings::getBool(const std::string& name, BOOL* buf)
{
Expand Down
7 changes: 5 additions & 2 deletions src/AndroDem/utils/WindowsUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ std::wstring GetCurrentDir()
}
BOOL FileExists(const char* name)
{
struct stat buffer;
return (stat(name, &buffer) == 0);
return _access_s(name, 0) != ENOENT;
}
BOOL FileExists(const wchar_t* name)
{
return _waccess_s(name, 0) != ENOENT;
}
5 changes: 3 additions & 2 deletions src/AndroDem/utils/WindowsUtils.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once
#include <Windows.h>
#include <sys/stat.h>
#include <string>
#include <io.h>
std::wstring GetCurrentDir();
BOOL FileExists(const char* name);
BOOL FileExists(const char* name);
BOOL FileExists(const wchar_t* name);

0 comments on commit 58a38cb

Please sign in to comment.