-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdllmain.cpp
More file actions
81 lines (66 loc) · 2.11 KB
/
dllmain.cpp
File metadata and controls
81 lines (66 loc) · 2.11 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
75
76
77
78
79
80
#include "pch.h"
#include <stdlib.h>
struct MaybeGameInfo {
char padding0[56];
int (*ptrToDummyReturns1)();
char padding1[16];
unsigned __int64* ptrToGetDLCCount;
};
typedef struct MaybeGameInfo MaybeGameInfo;
struct SteamContext {
unsigned __int64** firstPtrToDummyReturns1; // Pointer at offset 0
char padding0[40]; // Padding to ensure ptr2 is at offset 48
MaybeGameInfo** ptrPtrToMaybeGameInfo; // Integer at offset 48
char padding1[72]; //Padding to offset 128
};
typedef struct SteamContext SteamContext;
int dummyReturns1() {
return 1;
}
int getGameDLCCount() {
return 0;
}
void (*dummyFuncPtr)() = &dummyReturns1;
int (*ptrToGetGameDLCCount)() = &getGameDLCCount;
SteamContext steamContext;
// Function definition with proper return value
__declspec(dllexport) SteamContext SteamInternal_ContextInit() {
MaybeGameInfo* ptrToMaybeGameInfo = (MaybeGameInfo*)malloc(sizeof(MaybeGameInfo));
ptrToMaybeGameInfo->ptrToGetDLCCount = ptrToGetGameDLCCount;
ptrToMaybeGameInfo->ptrToDummyReturns1 = dummyFuncPtr;
steamContext.ptrPtrToMaybeGameInfo = (MaybeGameInfo**)malloc(sizeof(MaybeGameInfo*));
*(steamContext.ptrPtrToMaybeGameInfo) = ptrToMaybeGameInfo;
unsigned __int64 *ptr3 = &((unsigned __int64)dummyFuncPtr);
unsigned __int64 ptr2 = (unsigned __int64)ptr3 - 168;
unsigned __int64* ptr1 = &ptr2;
steamContext.firstPtrToDummyReturns1 = ptr1;
return steamContext;
}
__declspec(dllexport) int SteamAPI_Init() {
return 1;
}
__declspec(dllexport) int SteamAPI_RestartAppIfNecessary() {
return 0;
}
__declspec(dllexport) int SteamAPI_GetHSteamPipe() {
return 1;
}
__declspec(dllexport) int SteamInternal_CreateInterface() {
return 1;
}
__declspec(dllexport) int SteamAPI_Shutdown() {
return 1;
}
__declspec(dllexport) int SteamAPI_RunCallbacks() {
return 1;
}
__declspec(dllexport) int SteamAPI_GetHSteamUser() {
return 1;
}
BOOL APIENTRY DllMain( HMODULE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
return TRUE;
}