Перейти к содержимому
View in the app

A better way to browse. Learn more.

Zloplay community

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

[CODE] GSC 'unknown function' reporting

Опубликовано:

thought I might as well contribute

currently if you make a function type in gsc, you get an error 'unknown function'

it doesn't tell you the name or what file the error is from, though

heres a patch to do just that (displays function name and file name):

 

Index: PatchMW2ScriptCompileDebug.cpp
===================================================================
--- PatchMW2ScriptCompileDebug.cpp	(revision 122)
+++ PatchMW2ScriptCompileDebug.cpp	(working copy)
@@ -10,6 +10,7 @@
// ==========================================================

#include "StdInc.h"
+#include "Script.h"

const char* currentScriptFilename;

@@ -152,6 +153,68 @@
	Com_Error(5, "script compile error\n%s\n%s\n(see console for actual details)\n", msgbuf, scriptFilename);
}

+DWORD FunctionLookupStartRetn = (DWORD)0x612DB6;
+DWORD FunctionLookupUnkStubRetn = (DWORD)0x612E92;
+DWORD FunctionLookupUnkStub2Retn = (DWORD)0x612EA7;
+
+int functionRef;
+char* functionStr;
+
+void FunctionLookupUnkFunc()
+{
+	functionStr = SL_ConvertToString((unsigned short)functionRef);
+
+	char scriptFilename[512];
+
+	if (strstr(currentScriptFilename, ".gsc") == 0)
+	{
+		_snprintf(scriptFilename, sizeof(scriptFilename), "%s.gsc", currentScriptFilename);
+	}
+	else
+	{
+		strcpy(scriptFilename, currentScriptFilename);
+	}
+
+	Com_Printf(23, "\n");
+	Com_Printf(23, "******* script compile error *******\n");
+	Com_Printf(23, "Howdy there, fella' - it seems you made a mistake!\n");
+	Com_Printf(23, "Error: unknown function %s in %s\n", functionStr, scriptFilename);
+	Com_Printf(23, "************************************\n");
+
+	Com_Error(5, "script compile error\nunknown function %s\n%s\n", functionStr, scriptFilename);
+}
+
+void __declspec(naked) FunctionLookupUnkStub()
+{
+	__asm
+	{
+		call FunctionLookupUnkFunc
+		mov edx, [ebx]
+		jmp FunctionLookupUnkStubRetn
+	}
+}
+
+void __declspec(naked) FunctionLookupUnkStub2()
+{
+	__asm
+	{
+		call FunctionLookupUnkFunc
+		jmp FunctionLookupUnkStub2Retn
+	}
+}
+
+void __declspec(naked) FunctionLookupStart()
+{
+	__asm
+	{
+		mov     eax, [esp-8]
+		mov functionRef, eax
+		sub     esp, 0Ch
+		push    0
+		push    edi
+		jmp FunctionLookupStartRetn
+	}
+}
void PatchMW2_ScriptCompileDebug()
{
	scriptSetFileNameHook.initialize(scriptSetFileNameHookLoc, ScriptSetFileNameHookStub, 7);
@@ -163,6 +226,11 @@
	compileErrorHook.initialize(compileErrorHookLoc, CompileError);
	compileErrorHook.installHook();

+	// unknown function reporting
+	call(0x612DB0, FunctionLookupStart, PATCH_JUMP); // to get the function name
+	call(0x612E85, FunctionLookupUnkStub, PATCH_JUMP); // first occurence
+	call(0x612E9C, FunctionLookupUnkStub2, PATCH_JUMP); // second occurence
+
	// increase various stack bits as we push/pop ebx as well now
	#define ADD_STACK_BYTE(address) *(BYTE*)address += 4;
	#define ADD_STACK_DWORD(address) *(DWORD*)address += 4;

 

hopefully nta will add it officially :D

Featured Replies

Опубликовано:

Can someone explain how one would update there server with this?

 

-thanks

Опубликовано:

Update their server? lol no I'm pretty sure its used for clients that need to figure out where the error occurs in their GSC when a function is used that doesn't exist.

 

Just compile and sign the .dll and then replace yours with the compiled one, and run your mod that gets this error.

Опубликовано:

Ohhhhh... so THATS what the pesky number was... Never thought it would be one of those. Interestingly enough, I didn't even know about their existence until I was working on IW5. I forget what they are exactly. Its some combination of the strings before the assets in the fastfile and other random strings (now we know it's gsc functions).

 

And I can see someone knows what they are doing (1 post and it's this? Holy shit I am going to love you)

Опубликовано:
I forget what they are exactly. Its some combination of the strings before the assets in the fastfile and other random strings (now we know it's gsc functions).

stringlist isn't just script functions, it's pretty much 'everything'

Опубликовано:
I forget what they are exactly. Its some combination of the strings before the assets in the fastfile and other random strings (now we know it's gsc functions).

stringlist isn't just script functions, it's pretty much 'everything'

Guess that's good to know so that if you ever see a number where you expect a string, then you know where to look.

Опубликовано:
  • Автор
And I can see someone knows what they are doing (1 post and it's this? Holy shit I am going to love you)

2nd post, the count is off....

I've been waiting in the background for some time...

Best first post i've ever seen on 4d1. Nice. Thank you.

welcome :)

Guess that's good to know so that if you ever see a number where you expect a string, then you know where to look.

I guess they are used for caching

Опубликовано:

wow, what

someone else knowing how to code and (reverse) engineer? and someone better than diduknowipwn? ._.

kinda abrupt entrance

 

"FunctionLookupStart" lrn2iw3namesplz

Опубликовано:

Here is the patch to add reconnect command

Index: PatchMW2.cpp
===================================================================
--- PatchMW2.cpp	(revision 122)
+++ PatchMW2.cpp	(working copy)
@@ -659,6 +659,12 @@
	}
}

+void CL_Reconnect_f()
+{
+	netadr_t adr = currentLobbyTarget;
+	ConnectToAddress(adr);
+}
+
void CL_OpenStore_f()
{
	ShellExecute(NULL, "open", "http://pastehtml.com/view/cs8q6n2pe.html", 0, 0, SW_SHOWNORMAL);
@@ -666,11 +672,13 @@

static cmd_function_t connectCmd;
static cmd_function_t connectNoPartyCmd;
+static cmd_function_t reconnectCmd;

void PatchMW2_Client()
{
	Cmd_AddCommand("connect", CL_Connect_f, &connectCmd, 0);
	Cmd_AddCommand("connectNoParty", CL_ConnectNoParty_f, &connectNoPartyCmd, 0);
+	Cmd_AddCommand("reconnect", CL_Reconnect_f, &reconnectCmd, 0);

	// disable some checks in connection status display (testing only?)
	*(WORD*)0x49FA32 = 0x9090;

Опубликовано:

Will this be in a reversion soon?

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Гость
Ответить в тему...

Сейчас на странице 0

  • Нет пользователей, просматривающих эту страницу

Важная информация

Используя этот сайт, вы соглашаетесь Условия использования.

Account

Navigation

Поиск

Поиск

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.