Skip to content

Commit 512d85f

Browse files
committed
implemented GetResourceData() function for future usage
1 parent 20f68be commit 512d85f

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

TR2Main.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@
4545
#endif
4646
/** @endcond */
4747

48+
HINSTANCE hInstance = NULL;
49+
4850
// 3d system
4951
extern void Inject_3Dgen();
5052
extern void Inject_3Dout();
@@ -228,6 +230,7 @@ extern "C" BOOL APIENTRY DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpv
228230
switch( fdwReason ) {
229231
case DLL_PROCESS_ATTACH :
230232
// attach to process
233+
hInstance = hinstDLL;
231234
Inject();
232235
break;
233236

modding/file_utils.cpp

+11
Original file line numberDiff line numberDiff line change
@@ -185,3 +185,14 @@ int AddFilenameSuffix(LPSTR destName, DWORD destSize, LPCSTR fileName, LPCSTR su
185185
return 0;
186186
}
187187

188+
LPCVOID GetResourceData(LPCTSTR resName, LPDWORD resSize) {
189+
extern HINSTANCE hInstance;
190+
191+
HRSRC resInfo = FindResource(hInstance, resName, RT_RCDATA);
192+
if( !resInfo ) return NULL;
193+
if( resSize ) *resSize = SizeofResource(hInstance, resInfo);
194+
195+
HGLOBAL resHandle = LoadResource(hInstance, resInfo);
196+
if( !resHandle ) return NULL;
197+
return LockResource(resHandle);
198+
}

modding/file_utils.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2017-2019 Michael Chaban. All rights reserved.
2+
* Copyright (c) 2017-2020 Michael Chaban. All rights reserved.
33
* Original game is written by Core Design Ltd. in 1997.
44
* Lara Croft and Tomb Raider are trademarks of Square Enix Ltd.
55
*
@@ -41,4 +41,6 @@ int CreateDateTimeFilename(LPSTR fileName, DWORD destSize, LPCSTR filePath, LPCS
4141

4242
int AddFilenameSuffix(LPSTR destName, DWORD destSize, LPCSTR fileName, LPCSTR suffix);
4343

44+
LPCVOID GetResourceData(LPCTSTR resName, LPDWORD resSize);
45+
4446
#endif // FILE_UTILS_H_INCLUDED

0 commit comments

Comments
 (0)