Skip to content

Commit

Permalink
Fixed project, WIP lifecycle changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
Zax37 committed Nov 18, 2018
1 parent a0f0f7c commit cfe1a54
Show file tree
Hide file tree
Showing 242 changed files with 812 additions and 536 deletions.
30 changes: 27 additions & 3 deletions CrazyHook/CrazyHook.sln → CrazyHook.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Express 2013 for Windows Desktop
VisualStudioVersion = 12.0.21005.1
# Visual Studio 15
VisualStudioVersion = 15.0.28010.2026
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CrazyHook", "CrazyHook\CrazyHook.vcxproj", "{BD360DEF-38C1-495C-8912-9C3537832C49}"
ProjectSection(ProjectDependencies) = postProject
Expand All @@ -11,28 +11,52 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CrazyHook", "CrazyHook\Craz
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "LuaJIT", "LuaJIT\LuaJIT.vcxproj", "{223F31B1-DD39-48E4-8982-F05A8DBE9531}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "LFS", "LFS\LFS.vcxproj", "{2833B9C0-717D-4E11-98B2-4944AB787329}"
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "lfs", "LFS\LFS.vcxproj", "{2833B9C0-717D-4E11-98B2-4944AB787329}"
ProjectSection(ProjectDependencies) = postProject
{223F31B1-DD39-48E4-8982-F05A8DBE9531} = {223F31B1-DD39-48E4-8982-F05A8DBE9531}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CrazyPatches", "CrazyPatches\CrazyPatches.vcxproj", "{7EFA88FB-1147-4844-AA95-08DA02BB15D0}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Debug|x64 = Debug|x64
Release|Win32 = Release|Win32
Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{BD360DEF-38C1-495C-8912-9C3537832C49}.Debug|Win32.ActiveCfg = Debug|Win32
{BD360DEF-38C1-495C-8912-9C3537832C49}.Debug|Win32.Build.0 = Debug|Win32
{BD360DEF-38C1-495C-8912-9C3537832C49}.Debug|x64.ActiveCfg = Debug|Win32
{BD360DEF-38C1-495C-8912-9C3537832C49}.Release|Win32.ActiveCfg = Release|Win32
{BD360DEF-38C1-495C-8912-9C3537832C49}.Release|Win32.Build.0 = Release|Win32
{BD360DEF-38C1-495C-8912-9C3537832C49}.Release|x64.ActiveCfg = Release|Win32
{223F31B1-DD39-48E4-8982-F05A8DBE9531}.Debug|Win32.ActiveCfg = Debug|Win32
{223F31B1-DD39-48E4-8982-F05A8DBE9531}.Debug|Win32.Build.0 = Debug|Win32
{223F31B1-DD39-48E4-8982-F05A8DBE9531}.Debug|x64.ActiveCfg = Debug|Win32
{223F31B1-DD39-48E4-8982-F05A8DBE9531}.Release|Win32.ActiveCfg = Release|Win32
{223F31B1-DD39-48E4-8982-F05A8DBE9531}.Release|Win32.Build.0 = Release|Win32
{223F31B1-DD39-48E4-8982-F05A8DBE9531}.Release|x64.ActiveCfg = Release|Win32
{2833B9C0-717D-4E11-98B2-4944AB787329}.Debug|Win32.ActiveCfg = Debug|Win32
{2833B9C0-717D-4E11-98B2-4944AB787329}.Debug|Win32.Build.0 = Debug|Win32
{2833B9C0-717D-4E11-98B2-4944AB787329}.Debug|x64.ActiveCfg = Debug|Win32
{2833B9C0-717D-4E11-98B2-4944AB787329}.Release|Win32.ActiveCfg = Release|Win32
{2833B9C0-717D-4E11-98B2-4944AB787329}.Release|Win32.Build.0 = Release|Win32
{2833B9C0-717D-4E11-98B2-4944AB787329}.Release|x64.ActiveCfg = Release|Win32
{7EFA88FB-1147-4844-AA95-08DA02BB15D0}.Debug|Win32.ActiveCfg = Debug|Win32
{7EFA88FB-1147-4844-AA95-08DA02BB15D0}.Debug|Win32.Build.0 = Debug|Win32
{7EFA88FB-1147-4844-AA95-08DA02BB15D0}.Debug|x64.ActiveCfg = Debug|x64
{7EFA88FB-1147-4844-AA95-08DA02BB15D0}.Debug|x64.Build.0 = Debug|x64
{7EFA88FB-1147-4844-AA95-08DA02BB15D0}.Release|Win32.ActiveCfg = Release|Win32
{7EFA88FB-1147-4844-AA95-08DA02BB15D0}.Release|Win32.Build.0 = Release|Win32
{7EFA88FB-1147-4844-AA95-08DA02BB15D0}.Release|x64.ActiveCfg = Release|x64
{7EFA88FB-1147-4844-AA95-08DA02BB15D0}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {2EC1CCC2-8475-41A7-A808-F354B1FE1484}
EndGlobalSection
EndGlobal
56 changes: 52 additions & 4 deletions CrazyHook/CrazyHook/CrazyHook.cpp → CrazyHook/CrazyHook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,33 @@ using namespace std;
typedef int (*Logic)(ObjectA*);
extern lua_State *L;

static void msgbox(const char *fnName, const char* stringParam) {
stringstream ss;
ss << fnName << " " << stringParam;
MessageBox(0, ss.str().c_str(), "native exception", 0);
}

static void msgbox(const char *fnName, ObjectA *a) {
stringstream ss;
ss << fnName << " " << a->_Name;
MessageBox(0, ss.str().c_str(), "native exception", 0);
}

void call_lua(const char* fnName, const char* stringParam) {
lua_getglobal(L, "_lua");
if (!lua_isfunction(L, -1)) {
MessageBox(0, "Critical error: function _lua does not exit" , fnName, 0);
ExitProcess(1);
}
lua_pushstring(L, fnName);
lua_pushstring(L, stringParam);
__try {
lua_call(L, 2, 0);
} __except(1) {
msgbox(fnName, stringParam);
}
}

void call_lua(const char* fnName, ObjectA *a) {
lua_getglobal(L, "_lua");
if (!lua_isfunction(L, -1)) {
Expand Down Expand Up @@ -54,8 +75,10 @@ int CustomLogic(ObjectA* a) {
userdata = new Object(a);
call_lua("_create", a);
}
assert(a->v->userdata->a == a);
call_lua("_logic", a);
else {
assert(a->v->userdata->a == a);
call_lua("_logic", a);
}
return 1;
}

Expand All @@ -75,8 +98,7 @@ int CustomBump(ObjectA *a) {
}

int MenuHook(ObjectA* a) {
call_lua("_menu");
a->v->logic = 0x4614D0; //MenuClaw
call_lua("_menu", a);
return 1;
}

Expand Down Expand Up @@ -111,4 +133,30 @@ CRAZYHOOK_API void CrazyHook(UnknownStruct *s)
}
}

/*CRAZYHOOK_API ObjectA* CObject(ObjectA* object)
{
MessageBox(0, "a", "CreatedObject", 0);
return object;
}*/

typedef void (LoopThroughObjectsCallback)(ObjectA* a);

void InitObjectCallback(ObjectA* a) {
((LoopThroughObjectsCallback*)(0x46EDF0))(a); //register treasure
if (a->v->logic == CustomLogic) {
CustomLogic(a);
}
}

CRAZYHOOK_API void CObList(UnknownStruct *s)
{
// Step 1. Parse objects list and init each
typedef int (UnknownStruct::*LoopThroughObjects)(void(ObjectA* a));
LoopThroughObjects loopThroughObjects;
(int&)loopThroughObjects = 0x4D6110;
call_lua("_hook", "PreInit");
(s->*loopThroughObjects)(InitObjectCallback);
call_lua("_hook", "PreInit");
}

}
5 changes: 4 additions & 1 deletion CrazyHook/CrazyHook/CrazyHook.h → CrazyHook/CrazyHook.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
#define CRAZYHOOK_API __declspec(dllimport)
#endif

struct ObjectA;
typedef int(*Logic)(ObjectA*);

struct UnknownStruct {};
struct Object;

Expand All @@ -22,7 +25,7 @@ struct Rect {

struct ObjectV {
int offset[4];
int logic;
Logic logic;
int pdata;
Object* userdata;
int state;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="CrazyHook.h" />
<ClInclude Include="Object.h" />
<ClInclude Include="stdafx.h" />
<ClInclude Include="targetver.h" />
Expand All @@ -101,6 +102,9 @@
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
</ClCompile>
</ItemGroup>
<ItemGroup>
<None Include="PropertySheet.props" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
Expand Down
2 changes: 0 additions & 2 deletions CrazyHook/LuaJIT/build.bat

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
162 changes: 116 additions & 46 deletions CrazyPatches/CrazyHookFrag2.asm
Original file line number Diff line number Diff line change
@@ -1,37 +1,49 @@
;extern MenuHookString
;extern CustomLogicString
;extern CreateObject
;extern LABEL_GottaMoveThis
;extern ResetNameString
extern Chameleon
extern LABEL_BackFromClawLevel11Fix
extern LABEL_BackFromChameleon1
extern LABEL_BackFromChameleon2
extern LABEL_BackFromChameleon4
extern ClawLogicFrag
extern Chameleon1Jump
extern CLAW_45D503
extern LoopThroughObjects

;global LABEL_MenuHook
global LABEL_ClawLevel11Fix
global LABEL_Chameleon4
global LABEL_Chameleon3
global LABEL_Chameleon2
global LABEL_Chameleon1

extern IsChameleonLoaded
extern DllNotFoundString
extern CoreFunctionNotFoundString
extern SelfTest
extern ChameleonString
extern GetProcAddress
extern ChameleonVar
extern CObjectString
extern CObListString
extern CreateObject
extern CreateObject_sub
extern LABEL_AfterObjectCreate

global Chameleon
global LABEL_InitObjectsLoop
global LABEL_CreateAndInitObject

extern LABEL_BackFromObjectsInitialization
extern LABEL_BackFromSomeTestExit
extern LABEL_BackFromSaveNRes
extern ExitProcess
extern nRes
extern SomeFun
extern TestExit

global LABEL_SaveNRes
global LABEL_SomeTestExit

section .text align=1

DB "CUSTOM_SPLASH",0
;LABEL_TestExit:
; MOV EAX, [LABEL_GottaMoveThis]
; TEST EAX, EAX
; JMP LABEL_ToResetName
; MOV EAX, MenuHookString
; JMP LABEL_ToEnd
; LABEL_ToResetName:
; MOV EAX, ResetNameString
; LABEL_ToEnd:
; JMP LABEL_MenuHookEnd

LABEL_ClawLevel11Fix:
PUSH 60
Expand All @@ -45,48 +57,106 @@ LABEL_ClawLevel11Fix:
CALL ClawLogicFrag
JMP LABEL_BackFromClawLevel11Fix

;LABEL_MenuHook:
; PUSH 0
; PUSH CustomLogicString
; PUSH 9999
; PUSH 100
; PUSH -30
; PUSH 0
; CALL CreateObject
; MOV ECX, EAX
; JMP LABEL_TestExit

;LABEL_MenuHookEnd:
; MOV [ECX+220], EAX
; MOV EAX, ECX
; JMP CLAW_45D503

LABEL_Chameleon4:
LABEL_Chameleon1:
JZ Chameleon1Jump
PUSH EDX
MOV EDX,4
MOV EDX,1
CALL Chameleon
POP EDX
CMP EAX, 167
JMP LABEL_BackFromChameleon4
JMP LABEL_BackFromChameleon1
LABEL_Chameleon2:
PUSH EDX
MOV EDX,2
CALL Chameleon
POP EDX
JMP LABEL_BackFromChameleon2

LABEL_Chameleon3:
PUSH EDX
MOV EDX,3
CALL Chameleon
POP EDX
RETN 8

LABEL_Chameleon2:
LABEL_Chameleon4:
PUSH EDX
MOV EDX,2
MOV EDX,4
CALL Chameleon
POP EDX
JMP LABEL_BackFromChameleon2
CMP EAX, 167
JMP LABEL_BackFromChameleon4
Chameleon:
PUSH EAX
PUSH EDX
MOV EAX, DWORD [IsChameleonLoaded]
MOV EDX, DllNotFoundString
CALL SelfTest
PUSH ChameleonString
PUSH EAX
CALL [GetProcAddress]
MOV EDX, CoreFunctionNotFoundString
CALL SelfTest
POP EDX
MOV DWORD [ChameleonVar], EDX
PUSH ESI
CALL EAX
POP EAX
MOV EAX, 0
MOV DWORD [ChameleonVar], EAX
POP EAX
RETN
LABEL_SaveNRes:
MOV DWORD [nRes], EBP ;save nRes for CH
CALL SomeFun ; copy what was there originally
JMP LABEL_BackFromSaveNRes ;go back

LABEL_Chameleon1:
JZ Chameleon1Jump
LABEL_SomeTestExit:
MOV EAX, DWORD [TestExit]
TEST EAX, EAX
JNZ LABEL_ST_AFTER
PUSH 0
PUSH 0
PUSH 1
PUSH 5
JMP LABEL_BackFromSomeTestExit
LABEL_ST_AFTER:
PUSH 1337
CALL [ExitProcess]
LABEL_CreateAndInitObject:
CALL CreateObject_sub
; PUSH EAX
; PUSH EDX
; MOV EAX, DWORD [IsChameleonLoaded]
; MOV EDX, DllNotFoundString
; CALL SelfTest
; PUSH CObjectString
; PUSH EAX
; CALL [GetProcAddress]
; MOV EDX, CoreFunctionNotFoundString
; CALL SelfTest
; POP EDX
; save
; CALL EAX
; POP EAX
JMP LABEL_AfterObjectCreate
LABEL_InitObjectsLoop:
PUSH EAX
PUSH EDX
MOV EDX,1
CALL Chameleon
MOV EAX, DWORD [IsChameleonLoaded]
MOV EDX, DllNotFoundString
CALL SelfTest
PUSH CObListString
PUSH EAX
CALL [GetProcAddress]
MOV EDX, CoreFunctionNotFoundString
CALL SelfTest
POP EDX
JMP LABEL_BackFromChameleon1
; save
CALL EAX
POP EAX
JMP LABEL_BackFromObjectsInitialization

0 comments on commit cfe1a54

Please sign in to comment.