Raised This Month: $ Target: $400
 0% 

[EXTENSION] Left 4 Downtown 2 (0.5.4.2) - L4D2 Only, Updated Left4Downtown


Post New Thread Reply   
 
Thread Tools Display Modes
dcx2
Senior Member
Join Date: Sep 2011
Old 07-31-2013 , 06:29   Re: [EXTENSION] Left 4 Downtown 2 (0.5.4.2) - L4D2 Only, Updated Left4Downtown
Reply With Quote #571

I don't think that's my problem (they were already being called with this->). Both of my detours work flawlessly on Windows (well at least Pl_Continue or Pl_Handled)

The problem is that on Linux, UseHealingItems is not a _thiscall (actually it probably is, GCC just implements thiscall differently from Windows). In fact, it's not any calling convention I've ever seen before. IDA incorrectly labels Linux's UseHealingItems as _fastcall, because it has three args and RETN 4 - but none of the args are passed through ecx:edx, all three are passed on the stack. The RETN 4 is definitely unnecessary, because there's a SUB esp, 4 just after each call to compensate - and only in Linux. And only for this one forward (UseHealingItems). I checked CThrow::ActivateAbility in Linux and it does not do this unnecessary RETN 4.

EDIT: I mentioned above that I checked Martijn's .so. The UseHealingItems detour does not do the RETN 4 that Linux's UseHealingItems does. And it does not SUB esp, 4 after the trampoline, like every other caller to UseHealingItems. This will undoubtedly corrupt the stack.

I also checked my FindScavengeItem forward, and I believe it would probably work on Linux just fine, since FindScavengeItem does not do the unnecessary RETN 4. But I have no Linux server to test this stuff on, nor do I have a Linux environment set up to build the extension.

EDIT2: I saw you just checked in a change to UseHealingItems. That was my original detour when I first wrote it. I got the names wrong on the arguments and only found out recently what that mysterious last argument was - I'm pretty sure it's the hidden struct returned-by-value that psychonic was talking about - but without that extra argument you will crash the server (trust me, I tried this on Windows for a few days before I would commit the source code changes). Windows UseHealingItems does a RETN 8, which with _thiscall means two args + thisptr. If you only provide one arg + thisptr, you will do RETN 4 at the end of your detour and corrupt the stack for the caller (RETN clears off the stack *after* popping into eip, so the caller's stack frame will by off by one push)

EDIT3: It seems that functions which return an Action<> in general have this awkward RETN 4 pattern with the hidden struct pointer. For example, SurvivorBot::ScavengeNearbyItems(float) is the same and it's called in the same places as UseHealingItems. I checked other forwards and they don't have this RETN 4 thing - seems like they all use plain old RET.

EDIT4: Eureka? psychonic had said, if you return a struct by value, the compiler will generate the same code on both platforms. I had originally thought of this in the neutral context of "random app I wrote"...but then I realized, my OnUseHealingItems forward was returning a void*! So the compiler saw no reason to do the fancy hidden struct pointer stuff.Therefore , I think what I should do instead is change the return type from void* to some struct I wrote (NOT pointer) which contains the same three fields as an Action in the SDK. And then I can return this struct by value and, hopefully, my assembly will look the same on both platforms, and I can get rid of that weird unused argument at last!

EDIT5: Making the detour return a struct-by-value seems to have worked. I no longer crash with one argument on Windows, and the disassembly looks correct. However, I have no build environment for Linux; if someone could get the latest source from google code and build the .so, I'll take a peek at it with IDA to see if it looks compatible with the Linux server.

EDIT6: Disawar compiled the Linux binary for me and I poked at it with IDA. Everything looks good! I'm seeing the awkward RETN 4 stuff at the end of my detour, and after I invoke the trampoline I see a SUB esp, 4. So I think the current source from Google Code should work for Linux now. Many thanks to psychonic for the tip about returning the struct-by-value.
__________________

Last edited by dcx2; 08-01-2013 at 19:50.
dcx2 is offline
Bakuryu
Member
Join Date: Dec 2011
Old 08-03-2013 , 23:01   Re: [EXTENSION] Left 4 Downtown 2 (0.5.4.2) - L4D2 Only, Updated Left4Downtown
Reply With Quote #572

Having trouble getting this to work, using the latest 1.5 snapshot of SM and latest 1.9 MM snapshot and I keep getting this. Using the files from the front page, using the playerslot build because I am not using l4dtoolz or any other player amount altering plugins aside from super survival which requires left 4 downtown to begin with.

Code:
L 08/03/2013 - 22:42:47: SourceMod error session started
L 08/03/2013 - 22:42:47: Info (map "c1m1_hotel") (file "errors_20130803.log")
L 08/03/2013 - 22:42:47: [SM] Error parsing gameconfig file "C:\Program Files (x86)\Steam\steamapps\common\Left 4 Dead 2 Dedicated Server\left4dead2\addons\sourcemod\gamedata\left4downtown.l4d2.txt":
L 08/03/2013 - 22:42:47: [SM] Error 11 on line 5, col 16: A property was declared outside of a section
L 08/03/2013 - 22:42:47: [SM] Unable to load extension "left4downtown.ext": Could not read left4downtown.l4d2.txt: A property was declared outside of a section
L 08/03/2013 - 22:42:47: [SM] Unable to load plugin "SuperSurvival.smx": Required extension "Left 4 Downtown" file("left4downtown.ext") not running
L 08/03/2013 - 22:48:06: Error log file session closed.
L 08/03/2013 - 22:55:20: SourceMod error session started
L 08/03/2013 - 22:55:20: Info (map "c1m1_hotel") (file "errors_20130803.log")
L 08/03/2013 - 22:55:20: [LEFT4DOWNTOWN] Detour -- Could not find 'SpawnSpecial' signature
L 08/03/2013 - 22:55:20: [LEFT4DOWNTOWN] Detour -- Could not find 'SpawnTank' signature
L 08/03/2013 - 22:55:20: [LEFT4DOWNTOWN] Detour -- Could not find 'SpawnWitch' signature
L 08/03/2013 - 22:55:20: [LEFT4DOWNTOWN] Detour -- Could not find 'SpawnWitchBride' signature
L 08/03/2013 - 22:55:20: [LEFT4DOWNTOWN] Detour -- Could not find 'ClearTeamScores' signature
L 08/03/2013 - 22:55:20: [LEFT4DOWNTOWN] Detour -- Could not find 'SetCampaignScores' signature
L 08/03/2013 - 22:55:20: [LEFT4DOWNTOWN] Detour -- Could not find 'OnFirstSurvivorLeftSafeArea' signature
L 08/03/2013 - 22:55:20: [LEFT4DOWNTOWN] Detour -- Could not find 'CDirector_GetScriptValueInt' signature
L 08/03/2013 - 22:55:20: [LEFT4DOWNTOWN] Detour -- Could not find 'CDirector_GetScriptValueFloat' signature
L 08/03/2013 - 22:55:20: [LEFT4DOWNTOWN] Detour -- Could not find 'CDirector_GetScriptValueString' signature
L 08/03/2013 - 22:55:20: [LEFT4DOWNTOWN] Detour -- Could not find 'TryOfferingTankBot' signature
L 08/03/2013 - 22:55:20: [LEFT4DOWNTOWN] Detour -- Could not find 'OnMobRushStart' signature
L 08/03/2013 - 22:55:20: [LEFT4DOWNTOWN] Detour -- Could not find 'Zombiemanager_SpawnITMob' signature
L 08/03/2013 - 22:55:20: [LEFT4DOWNTOWN] Detour -- Could not find 'Zombiemanager_SpawnMob' signature
L 08/03/2013 - 22:55:20: [LEFT4DOWNTOWN] Detour -- Could not find 'CTerrorPlayer_OnShovedBySurvivor' signature
L 08/03/2013 - 22:55:20: [LEFT4DOWNTOWN] Detour -- Could not find DifficultyChanged signature
L 08/03/2013 - 22:55:20: [LEFT4DOWNTOWN] Detour -- Could not find address for detour
L 08/03/2013 - 22:55:20: [LEFT4DOWNTOWN] Detour -- Could not find 'GetSurvivorSet' signature
L 08/03/2013 - 22:55:20: [LEFT4DOWNTOWN] Detour -- Could not find 'FastGetSurvivorSet' signature
L 08/03/2013 - 22:55:20: [LEFT4DOWNTOWN] Detour -- Could not find 'GetMissionVersusBossSpawning' signature
L 08/03/2013 - 22:55:20: [LEFT4DOWNTOWN] Detour -- Could not find 'CThrowActivate' signature
L 08/03/2013 - 22:55:20: [LEFT4DOWNTOWN] Detour -- Could not find 'StartMeleeSwing' signature
L 08/03/2013 - 22:55:20: [LEFT4DOWNTOWN] Detour -- Could not find 'ChangeFinaleStage' signature
L 08/03/2013 - 22:55:20: [LEFT4DOWNTOWN] Detour -- Could not find 'EndVersusModeRound' signature
L 08/03/2013 - 22:55:20: [LEFT4DOWNTOWN] Detour -- Could not find 'CTerrorPlayer_OnRevived' signature
L 08/03/2013 - 22:55:20: [LEFT4DOWNTOWN] Detour -- Could not find 'CDirector_IsFinale' signature
L 08/03/2013 - 22:55:20: [LEFT4DOWNTOWN] Detour -- Could not find 'CTerrorPlayer_OnEnterGhostState' signature
L 08/03/2013 - 22:55:20: [LEFT4DOWNTOWN] Detour -- Could not find 'GetMasterServerPlayerCounts' signature

Last edited by Bakuryu; 08-03-2013 at 23:02.
Bakuryu is offline
Martijn79
Member
Join Date: Jan 2013
Old 08-04-2013 , 08:51   Re: [EXTENSION] Left 4 Downtown 2 (0.5.4.2) - L4D2 Only, Updated Left4Downtown
Reply With Quote #573

You didn't download the gamedata file left4downtown.l4d2.txt

Download this file: http://left4downtown2.googlecode.com...ntown.l4d2.txt and put it in your gamedata folder.
Martijn79 is offline
Martijn79
Member
Join Date: Jan 2013
Old 08-04-2013 , 10:14   Re: [EXTENSION] Left 4 Downtown 2 (0.5.4.2) - L4D2 Only, Updated Left4Downtown
Reply With Quote #574

Thanks dcx2 for fixing player slots under Linux!

Been testing it and it works. Tested coop with 10 people.

See attachment for a working compiled version for Linux (compiled against SM 1.5/MM 1.9)

Don't forget to update the gamedata from the google code link!
Attached Files
File Type: so left4downtown.ext.2.l4d2_playerslots.so (350.8 KB, 556 views)
File Type: smx l4d2_unreservelobby.smx (4.7 KB, 483 views)

Last edited by Martijn79; 08-04-2013 at 10:16.
Martijn79 is offline
Bakuryu
Member
Join Date: Dec 2011
Old 08-04-2013 , 13:38   Re: [EXTENSION] Left 4 Downtown 2 (0.5.4.2) - L4D2 Only, Updated Left4Downtown
Reply With Quote #575

Quote:
Originally Posted by Martijn79 View Post
You didn't download the gamedata file left4downtown.l4d2.txt

Download this file: http://left4downtown2.googlecode.com...ntown.l4d2.txt and put it in your gamedata folder.
Now it kinda works, must have been a new gamedata, because it didn't work with it yesterday.

Still getting some errors, only two relating to downtown though, guess the other plugin is out of date?

Code:
L 08/04/2013 - 13:32:03: SourceMod error session started
L 08/04/2013 - 13:32:03: Info (map "c1m1_hotel") (file "errors_20130804.log")
L 08/04/2013 - 13:32:03: [LEFT4DOWNTOWN] Detour -- Could not find DifficultyChanged signature
L 08/04/2013 - 13:32:03: [LEFT4DOWNTOWN] Detour -- Could not find address for detour
L 08/04/2013 - 13:32:03: [SM] Plugin encountered error 25: Call was aborted
L 08/04/2013 - 13:32:03: [SM] Native "SetFailState" reported: Cant find CTerrorPlayer_OnRevived Signature in gamedata file
L 08/04/2013 - 13:32:03: [SM] Displaying call stack trace for plugin "l4d2_incappedmedsmunch.smx":
L 08/04/2013 - 13:32:03: [SM]   [0]  Line 84, /home/groups/alliedmodders/forums/files/5/2/2/3/3/53839.attach::PrepSDKCall()
L 08/04/2013 - 13:32:03: [SM]   [1]  Line 40, /home/groups/alliedmodders/forums/files/5/2/2/3/3/53839.attach::OnPluginStart()
Bakuryu is offline
dcx2
Senior Member
Join Date: Sep 2011
Old 08-04-2013 , 16:02   Re: [EXTENSION] Left 4 Downtown 2 (0.5.4.2) - L4D2 Only, Updated Left4Downtown
Reply With Quote #576

Linux/Windows? Playerslots/noslots? With the latest gamedata, I do not get any broken signature notifications.

Incapped Meds Munch is probably broken because downtown2 patches OnRevived for a forward, which screws up the signature. I had the same problem with New Custom Commands. If you know how, I suggest copying the OnRevived signature from downtown2's gamedata and replacing Incapped Meds Munch's OnRevived. Downtown2's OnRevived signature wildcards the bytes that get modified for the detour.

If what I just said makes no sense, let me know and I'll post an updated sig in Incapped Meds Munch thread.
__________________
dcx2 is offline
V1SoR
Member
Join Date: Jan 2011
Old 08-04-2013 , 16:58   Re: [EXTENSION] Left 4 Downtown 2 (0.5.4.2) - L4D2 Only, Updated Left4Downtown
Reply With Quote #577

Quote:
Originally Posted by dcx2 View Post
If what I just said makes no sense, let me know and I'll post an updated sig in Incapped Meds Munch thread.
It makes perfect sense. Detouring consists in replacing some bytes from the top of the function with "redirect" bytes, so that all the calls are passed to our extension instead of the game.

However, I have no clue how to externally call a detoured function. I think it's possible(I don't see why it wouldn't be), but you need to figure out how exactly does the detour modify the fucntion signature. Aside from that, Linux may need to use byte sigs as well if we're talking detoured calls.

Last edited by V1SoR; 08-04-2013 at 16:59.
V1SoR is offline
Bakuryu
Member
Join Date: Dec 2011
Old 08-05-2013 , 12:10   Re: [EXTENSION] Left 4 Downtown 2 (0.5.4.2) - L4D2 Only, Updated Left4Downtown
Reply With Quote #578

Quote:
Originally Posted by dcx2 View Post
Linux/Windows? Playerslots/noslots? With the latest gamedata, I do not get any broken signature notifications.

Incapped Meds Munch is probably broken because downtown2 patches OnRevived for a forward, which screws up the signature. I had the same problem with New Custom Commands. If you know how, I suggest copying the OnRevived signature from downtown2's gamedata and replacing Incapped Meds Munch's OnRevived. Downtown2's OnRevived signature wildcards the bytes that get modified for the detour.

If what I just said makes no sense, let me know and I'll post an updated sig in Incapped Meds Munch thread.
I don't know why the person above me answer your question for me lol. I'm using Player slots, the game data you just posted. I'm assuming you mean you want me to grab the source and modify myself, which in theory I can do, an will try when I get a chance. The second part of your sentence is a bit confusing not sure what signatures/wildcards are I've been out of the plugin loop for a while.
Bakuryu is offline
dcx2
Senior Member
Join Date: Sep 2011
Old 08-05-2013 , 12:14   Re: [EXTENSION] Left 4 Downtown 2 (0.5.4.2) - L4D2 Only, Updated Left4Downtown
Reply With Quote #579

Oh no, you don't have to modify the source at all. If you look at meds munch's gamedata file, you can see the signature for OnRevived. Just copy and paste the whole signature block for OnRevived from downtown2's gamedata. This will let meds munch find OnRevived after downtown2 patches it; downtown2's patch is what prevents meds munch from finding OnRevived.

EDIT you said you're using playerslots? I'm not sure if that would work on Windows. On Linux, you will need to use Martijn's .so for playerslots. But DifficultyChanged isn't a playerslots thing anyway. So, uh...Linux or Windows?
__________________

Last edited by dcx2; 08-05-2013 at 12:19.
dcx2 is offline
Bakuryu
Member
Join Date: Dec 2011
Old 08-05-2013 , 12:29   Re: [EXTENSION] Left 4 Downtown 2 (0.5.4.2) - L4D2 Only, Updated Left4Downtown
Reply With Quote #580

Quote:
Originally Posted by dcx2 View Post
Oh no, you don't have to modify the source at all. If you look at meds munch's gamedata file, you can see the signature for OnRevived. Just copy and paste the whole signature block for OnRevived from downtown2's gamedata. This will let meds munch find OnRevived after downtown2 patches it; downtown2's patch is what prevents meds munch from finding OnRevived.

EDIT you said you're using playerslots? I'm not sure if that would work on Windows. On Linux, you will need to use Martijn's .so for playerslots. But DifficultyChanged isn't a playerslots thing anyway. So, uh...Linux or Windows?
Oops, yea I'm using windows. Playerslots doesn't work on windows? And I just figured out it only needs the gamedata switch as you posted it lol, testing it now.

EDIT yep still getting

Code:
L 08/05/2013 - 12:29:12: SourceMod error session started
L 08/05/2013 - 12:29:12: Info (map "c1m1_hotel") (file "errors_20130805.log")
L 08/05/2013 - 12:29:12: [LEFT4DOWNTOWN] Detour -- Could not find DifficultyChanged signature
L 08/05/2013 - 12:29:12: [LEFT4DOWNTOWN] Detour -- Could not find address for detour
EDIT2 using these plugins

Code:
  01 "Admin File Reader" (1.5.0-dev+3871) by AlliedModders LLC
  02 "Admin Help" (1.5.0-dev+3871) by AlliedModders LLC
  03 "Admin Menu" (1.5.0-dev+3871) by AlliedModders LLC
  04 "Anti-Flood" (1.5.0-dev+3871) by AlliedModders LLC
  05 "Basic Ban Commands" (1.5.0-dev+3871) by AlliedModders LLC
  06 "Basic Chat" (1.5.0-dev+3871) by AlliedModders LLC
  07 "Basic Comm Control" (1.5.0-dev+3871) by AlliedModders LLC
  08 "Basic Commands" (1.5.0-dev+3871) by AlliedModders LLC
  09 "Basic Info Triggers" (1.5.0-dev+3871) by AlliedModders LLC
  10 "Basic Votes" (1.5.0-dev+3871) by AlliedModders LLC
  11 "Client Preferences" (1.5.0-dev+3871) by AlliedModders LLC
  12 "[L4D2] 4+ Survivor Afk Fix" (1.4) by MI 5, SwiftReal, raziEiL [disawar1], Electr0 [m_iMeow]
  13 "Fun Commands" (1.5.0-dev+3871) by AlliedModders LLC
  14 "Fun Votes" (1.5.0-dev+3871) by AlliedModders LLC
  15 "L4D2 Unstick" (1.0.6) by HowIChrgeLazer
  16 "L4D2 Incapped Meds Munch" (1.1.9) by AtomicStryker
  17 "[L4D2] Incapped Crawling with Animation" (1.32) by SilverShot
  18 "L4D2 Riot Cop Head Shot" (1.2) by dcx2 | helped by Mr. Zero / McFlurry
  19 "[L4D/2] Campaign Manager" (1.0.4) by Bigbuck
  20 "[L4D & L4D2] Gear Transfer" (1.5.10) by SilverShot
  21 "Multiple Equipments" (1.8) by Pan Xiaohai & Marcus101RR
  22 "L4D SM Respawn" (1.9.3) by AtomicStryker & Ivailosp
  23 "Sprint" (1.0) by Pan Xiaohai
  24 "L4D Survivor AI Pounced Fix" (1.0.4) by  AtomicStryker 
  25 Disabled: "Nextmap" (1.5.0-dev+3871) by AlliedModders LLC
  26 "Player Commands" (1.5.0-dev+3871) by AlliedModders LLC
  27 "Reserved Slots" (1.5.0-dev+3871) by AlliedModders LLC
  28 "Sound Commands" (1.5.0-dev+3871) by AlliedModders LLC
  29 "Super Survival" (1.0.0) by EHG
  30 "Survivor Bot Takeover" (0.8) by Mikko Andersson (muukis)

Last edited by Bakuryu; 08-05-2013 at 12:32.
Bakuryu is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 01:23.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode