forked from Leystryku/leysourceengineclient
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsteam.cpp
More file actions
74 lines (55 loc) · 1.68 KB
/
steam.cpp
File metadata and controls
74 lines (55 loc) · 1.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#include <Shlwapi.h>
#include <string>
#include "../deps/osw/Steamworks.h"
#include "../deps/osw/ISteamUser017.h"
#include "steam.h"
std::wstring Steam::GetSteamInstallFolder()
{
wchar_t installFolder[MAX_PATH] = { 0 };
unsigned long bufferLength = sizeof(installFolder);
unsigned long type = REG_SZ;
if (SHGetValue(HKEY_CURRENT_USER, TEXT("Software\\Valve\\Steam"), TEXT("SteamPath"), &type, installFolder, &bufferLength) != ERROR_SUCCESS)
{
MessageBox(0, L"Could not find Steam Install directory in:\n HKEY_CURRENT_USER\\Software\\Valve\\Steam\\SteamPath)\n", L"leysourceengineclient - GetSteamInstallFolder", MB_OK);
}
return installFolder;
}
ISteamUser017* Steam::GetSteamUser()
{
return this->steamUser;
}
ISteamUser017* temporaryHack = 0;
int Steam::Initiate()
{
SetDllDirectory(GetSteamInstallFolder().c_str());
HMODULE steam = LoadLibrary(L"steam");
HMODULE steamapi = LoadLibrary(L"steam_api");
HMODULE steamclientdll = LoadLibrary(L"steamclient");
if (!steamclientdll)
{
return 1;
}
CreateInterfaceFn fnApiInterface = (CreateInterfaceFn)GetProcAddress(steamclientdll, "CreateInterface");
if (!fnApiInterface)
{
return 2;
}
if (!(this->steamClient = (ISteamClient017*)fnApiInterface(STEAMCLIENT_INTERFACE_VERSION_017, NULL)))
{
return 3;
}
if (!(this->steamPipeHandle = this->steamClient->CreateSteamPipe()))
{
return 4;
}
if (!(this->steamUserHandle = this->steamClient->ConnectToGlobalUser(this->steamPipeHandle)))
{
return 5;
}
if (!(this->steamUser = (ISteamUser017*)this->steamClient->GetISteamUser(this->steamUserHandle, this->steamPipeHandle, STEAMUSER_INTERFACE_VERSION_017)))
{
return 6;
}
temporaryHack = this->steamUser;
return 0;
}