Your problem is located right here:
At first glance.Originally Posted by c4tAc0mB

This unit alert keeps crashing, by all means it should work.
Code:
Anyone know whats going on here?PHP Code:void UnitAlert()
{
int Unit;
int Owner;
int Number;
int IfCreated;//storage for hooked variables
_asm add [edi*4+0x58230c],ebx //do the overwritten code too
// _asm mov IfCreated, ebx//hook the variables
// _asm mov Owner, eax
// _asm mov Unit, esi
//_asm mov Number, [edi*4+0x58230c]
if(IfCreated == 1) //if a unit is created, not destroyed
{
//Number++;
//char tmp[100] = IdentifyUnit(Unit)
BWPrintToGameScreen(IdentifyUnit(Unit), 8);
}
}
void NAKED UnitAlertJmp()
{
__asm
{
pushad
call UnitAlert
popad
}
}
char *IdentifyUnit(BYTE unit)
{
switch(unit) {
case 0x00:
return "Marine";
case 0x32:
return "Firebat";
case 0x01:
return "Ghost";
case 0x02:
return "Vulture";
case 0x03:
return "Goliath";
case 0x05:
return "Siege Tank";
case 0x0D:
return "Spider Mine";
case 0x0E:
return "Nuclear Missle";
case 0x07:
return "SCV";
case 0x08:
return "Wraith";
case 0x09:
return "Science Vessel";
case 0x0B:
return "Dropship";
case 0x0C:
return "Battlecruiser";
case 0x3A:
return "Valkyrie";
case 0x6A:
return "Command Center";
case 0x6D:
return "Supply Depot";
case 0x6E:
return "Refinery";
case 0x6F:
return "Barracks";
case 0x70:
return "Academy";
case 0x71:
return "Factory";
case 0x72:
return "Starport";
case 0x74:
return "Science Facility";
case 0x7A:
return "Engineering Bay";
case 0x7B:
return "Armory";
case 0x7C:
return "Missle Turret";
case 0x7D:
return "Bunker";
case 0x3D:
return "Dark Templar";
case 0x3F:
return "Dark Archon";
case 0x40:
return "Probe";
case 0x41:
return "Zealot";
case 0x42:
return "Dragoon";
case 0x43:
return "High Templar";
case 0x44:
return "Archon";
case 0x53:
return "Reaver";
case 0x55:
return "Scarab";
case 0x3C:
return "Corsair";
case 0x45:
return "Shuttle";
case 0x46:
return "Scout";
case 0x47:
return "Arbiter";
case 0x48:
return "Carrier";
case 0x49:
return "Interceptor";
case 0x54:
return "Observer";
case 0x9A:
return "Nexuiz";
case 0x3B:
return "Robotics Facility";
case 0x9C:
return "Pylon";
// case 0x3E:
// unitcount[47]++;
// return "Assimilator";
case 0x9F:
return "Observatory";
case 0xA0:
return "Gateway";
case 0xA2:
return "Photon Cannon";
case 0xA3:
return "Citadel of Adun";
case 0xA5:
return "Templar Archives";
case 0xA6:
return "Forge";
case 0xA7:
return "Stargate";
case 0xA9:
return "Fleet Beacon";
case 0xAA:
return "Arbiter Tribunal";
case 0xAB:
return "Robotics Support Bay";
case 0xAC:
return "Protoss Shield Battery";
case 0x23:
return "Larva";
case 0x24:
return "Egg";
case 0x61:
return "Lurker Egg";
case 0x25:
return "Zergling";
case 0x26:
return "Hydralisk";
case 0x27:
return "Ultralisk";
case 0x28:
return "Broodling";
case 0x29:
return "Drone";
case 0x2E:
return "Defiler";
// case 0x32:
// unitcount[78]++;
// return "Infested Terran";
case 0x67:
return "Lurker";
case 0x2A:
return "Overlord";
case 0x2B:
return "Mutalisk";
case 0x2C:
return "Guardian";
case 0x3E:
return "Devourer";
case 0x2F:
return "Scourge";
// case 0x3B:
// unitcount[94]++;
// return "Cocoon";
case 0x82:
return "Infested Command Center";
case 0x83:
return "Hatchery";
case 0x84:
return "Lair";
case 0x85:
return "Hive";
case 0x86:
return "Nydus Canal";
case 0x87:
return "Hydralisk Den";
case 0x88:
return "Defiler Mound";
case 0x89:
return "Greater Spire";
case 0x8A:
return "Queen's Nest";
case 0x8B:
return "Evolution Chamber";
case 0x8C:
return "Ultralisk Cavern";
case 0x8D:
return "Spire";
case 0x8E:
return "Spawning Pool";
case 0x8F:
return "Creep Colony";
case 0x90:
return "Spore Colony";
case 0x92:
return "Sunken Colony";
case 0x95:
return "Extractor";
case 0xB0:
return "Mineral Field 1";
case 0xB1:
return "Mineral Field 2";
case 0xB3:
return "Mineral Field 3";
case 0xBC:
return "Vespene Geyser";
case 0x21:
return "Scanner Sweep";
case 0x69:
return "Disruption Web";
case 0xCA:
return "Dark Swarm";
case 0xE7:
return "Warp";
case 0xE4:
return "None";
default:
return NULL;
}
}
JmpPatch(&UnitAlertJmp, (PBYTE) 0x4888d5, 2);
Thanks




Your problem is located right here:
At first glance.Originally Posted by c4tAc0mB
Case: Antec Nine Hundred
CPU: Intel C2Q Q9650 @ 4.0 GHz (9x445), 1.31v [IntelBurnTest stable]
GPU/Monitor: Visiontek HD 4870 X2 @ 800 MHz/4000 MHz +SyncMaster245BW 24"
Motherboard: ASUS P5Q Deluxe (BIOS 2005)
Memory: 8 GB (4x 2 GB) OCZ Reaper HPC DDR2 1066 @ 1069 MHz
Hard Drive: 2x Seagate 500 GB 7200.11 (Matrix RAID) + 1x WD Caviar Black 640 GB
Sound: Creative SB X-Fi Fatal1ty Pro
PSU: OCZ GameXStream 700W
O/S: Vista Ultimate X64 SP2
Download Apocalypse v4.02 here!
Download EliteControl here!

New function, still doesnt work:
PHP Code:void NAKED UnitAlertJmp()
{
static int JmpBack = (0x4888d5+0x2);
__asm
{
pushad
call UnitAlert
popad
call dword ptr [JmpBack]
retn
}
}




Still wrong.
Case: Antec Nine Hundred
CPU: Intel C2Q Q9650 @ 4.0 GHz (9x445), 1.31v [IntelBurnTest stable]
GPU/Monitor: Visiontek HD 4870 X2 @ 800 MHz/4000 MHz +SyncMaster245BW 24"
Motherboard: ASUS P5Q Deluxe (BIOS 2005)
Memory: 8 GB (4x 2 GB) OCZ Reaper HPC DDR2 1066 @ 1069 MHz
Hard Drive: 2x Seagate 500 GB 7200.11 (Matrix RAID) + 1x WD Caviar Black 640 GB
Sound: Creative SB X-Fi Fatal1ty Pro
PSU: OCZ GameXStream 700W
O/S: Vista Ultimate X64 SP2
Download Apocalypse v4.02 here!
Download EliteControl here!

AHA! Dunno if it works havnt tested it yet....
PHP Code:void NAKED UnitAlertJmp()
{
static int JmpBack = (0x4888d5+6);
__asm
{
add dword ptr DS:[edi*4+0x58230c],ebx
pushad
pushad
call UnitAlert
popad
ret
popad
jmp dword ptr [JmpBack]
retn
}
}
EDIT: nope, crashes
Last edited by c4tAc0mB : 12-24-2007 at 11:07 PM



You need to preserve your registers, call your fxn, restore your registers, execute whatever command you overwrote, and finally jump to the command after the one you patched over.
I get laid.
Originally Posted by The most intelligent hellinsect

Ive tried just running the overwritten the code, and getting it to work w/o the extra stuff, but still crashes:
Now SC doesnt even give an error message, it just disapearsPHP Code:void NAKED UnitAlertJmp()
{
static int JmpBack = (0x4888d5+6);
__asm
{
add dword ptr DS:[edi*4+0x58230c],ebx
/* pushad
call UnitAlert
popad*/
jmp [JmpBack]
}
}
EDIT: Fixed it somewhat, can now build units but when a building is built it crashes. I had to hook it somewhere else and modify the code a bit.
PHP Code:void NAKED UnitAlertJmp()
{
static int JmpBack = (0x488A3B+6);
__asm
{
mov [edx*4+0x584dcc],ebx
pushad
pushad
call UnitAlert
popad
jmp dword ptr [JmpBack]
ret
}
}
Last edited by c4tAc0mB : 12-25-2007 at 06:24 AM




I just looked at all of your code again. Sorry to say this, but it appears that you are not ready yet to write C++ code with inline assembly.
And taking a quick glance of your corrected "UnitAlertJmp()" code, it seems that you have two pushad instructions, is that intended or is that a mistake? If it's a mistake, then it is most likely one of the causes of the crashing.
Case: Antec Nine Hundred
CPU: Intel C2Q Q9650 @ 4.0 GHz (9x445), 1.31v [IntelBurnTest stable]
GPU/Monitor: Visiontek HD 4870 X2 @ 800 MHz/4000 MHz +SyncMaster245BW 24"
Motherboard: ASUS P5Q Deluxe (BIOS 2005)
Memory: 8 GB (4x 2 GB) OCZ Reaper HPC DDR2 1066 @ 1069 MHz
Hard Drive: 2x Seagate 500 GB 7200.11 (Matrix RAID) + 1x WD Caviar Black 640 GB
Sound: Creative SB X-Fi Fatal1ty Pro
PSU: OCZ GameXStream 700W
O/S: Vista Ultimate X64 SP2
Download Apocalypse v4.02 here!
Download EliteControl here!

I didnt notice that, thanks for pointing it out. It caused the supply to go wacky.
EDIT: still causes the supply to go whacky:
It only allows you 9 units of supply :(PHP Code:void NAKED UnitAlertJmp()
{
static int JmpBack = (0x488A3B+6);
__asm
{
mov [edx*4+0x584dcc],ebx
pushad
call UnitAlert
popad
jmp dword ptr [JmpBack]
ret
}
}
Last edited by c4tAc0mB : 12-25-2007 at 08:23 AM

The thing I like about this offset is its run after the unit is created, not when the unit enters the building queu.
The funny thing is, all this code works fin when coded/compiled in Masm, but once using inline asm it goes crazy
EDIT: I feel like an uber n00b, I overwrote 6 bytes of code and only did 1 byte of that overwriten code in my function. Thanks for the help, and also thanks for not just handing me the answer. More fun when u have to figure it out :D
Last edited by c4tAc0mB : 12-26-2007 at 05:12 AM
There are currently 1 users browsing this thread. (0 members and 1 guests)