static void File_Open(RegisterMemory mem) { int arg0 = mem.GetArg(0); int arg1 = mem.GetArg(1); string path = ReadString(arg0); if (!path.EndsWith("MSSSOFT.M3D", StringComparison.OrdinalIgnoreCase)) // makes problems { string parms = ReadString(arg1); string projectPath = GetProjectFilePath(path); if (parms.Contains('w') || parms.Contains('a')) // write or append { string dir = Path.GetDirectoryName(projectPath); if (!Directory.Exists(dir)) { Directory.CreateDirectory(dir); } using (zString z = zString.Create(projectPath)) mem.EAX = WinApi.Process.CDECLCALL <WinApi.IntArg>(0x7D1FDF, (WinApi.IntArg)z.PTR, (WinApi.IntArg)arg1, (WinApi.IntArg) 0x40); // call our own paths return; } else if (File.Exists(projectPath)) // read : no such file in the project folder { using (zString z = zString.Create(projectPath)) mem.EAX = WinApi.Process.CDECLCALL <WinApi.IntArg>(0x7D1FDF, (WinApi.IntArg)z.PTR, (WinApi.IntArg)arg1, (WinApi.IntArg) 0x40); // call our own paths return; } } mem.EAX = WinApi.Process.CDECLCALL <WinApi.IntArg>(0x7D1FDF, (WinApi.IntArg)arg0, (WinApi.IntArg)arg1, (WinApi.IntArg) 0x40); // just call it like it was meant to be }
static void hook_LoadDat(Hook hook, RegisterMemory rmem) { try { zString str = new zString(rmem[0]); string datName = str.ToString().Trim().ToUpper(); Logger.Log("Hook loaddat: " + datName); if (datName == "GOTHIC.DAT" || datName == "FIGHT.DAT" || datName == "MENU.DAT") { if (datName == "GOTHIC.DAT") { initDefaultScripts(); } Process.Write(hook.OldInNewAddress, 0x33, 0xC0, 0xC2, 0x04, 0x00, 0x00, 0x00); // block it Logger.Log("LoadDat: '{0}', blocked!", str); } else { hook.RestoreOldInNewCode(); // unblock it Logger.Log("LoadDat: '{0}'", str); } } catch (Exception ex) { Logger.LogError(ex); } }
public void Show() { if (isShown) { return; } if (pView == null) { pView = zCView.Create(process, 0, 0, sizeX, sizeY); zString texStr = zString.Create(process, texture); zString fontStr = zString.Create(process, "Font_Old_20_White_Hi.tga"); pView.InsertBack(texStr); pView.SetFont(fontStr); texStr.Dispose(); fontStr.Dispose(); pView.PrintTimedCXY(zString.Create(process, text), -1, zColor.Create(process, 255, 255, 255, 255)); pView.SetPos(posX, posY); } zCView.GetStartscreen(process).InsertItem(pView, 0); InputHooked.receivers.Add(this); isShown = true; }
public void SetFont(String font) { zString f = zString.Create(Process, font); SetFont(f); f.Dispose(); }
public void SetSize(int size) { if (size > this.size) { for (int i = this.size; i < size; i++) { zString str = zString.Create(process, ""); int height = (int)(mHeight * 0.1f); int width = (int)(mWidth * 0.05f); zCViewText vt = viewBG.CreateText(0, 0, str); vt.Timed = 0; vt.Timer = -1; vt.PosX = width; vt.PosY = height + i * height; viewTextList.Add(vt); str.Dispose(); } } else if (size < this.size) { zCViewText[] txview = viewTextList.ToArray(); for (int i = size; i < this.size; i++) { txview[i].Timed = 1; txview[i].Timer = 0; viewTextList.Remove(txview[i]); } } this.size = size; }
// basically only for music system static void DirectFileConvert(RegisterMemory mem) { zString zStr = new zString(mem.GetArg(0)); StringBuilder sb = new StringBuilder(zStr.ToString()); if (sb.Length > 0) { if (sb.ToString().StartsWith(Program.GothicRootPath, StringComparison.OrdinalIgnoreCase)) { sb.Remove(0, Program.GothicRootPath.Length); } if (sb[0] != '\\') { sb.Insert(0, '\\'); } sb.Insert(0, Program.ProjectPath); string path = sb.ToString(); if (Directory.Exists(path)) { zStr.Set(path); } } }
public void SetName(String name) { zString str = zString.Create(Process, name); SetName(str); str.Dispose(); }
public void Read(RakNet.BitStream stream, RakNet.Packet packet, Client client) { int plID = 0; stream.Read(out plID); if (plID == 0 || !sWorld.VobDict.ContainsKey(plID)) { throw new Exception("Vob not found!"); } Vob vob = sWorld.VobDict[plID]; if (!(vob is NPCProto)) { throw new Exception("Vob is not an NPC!"); } if (vob.Address == 0) { return; } Process process = Process.ThisProcess(); oCNpc npc = new oCNpc(process, vob.Address); //npc.StartDialogAni(); zString str = zString.Create(process, "T_DIALOGGESTURE_09"); npc.GetModel().StartAnimation(str); str.Dispose(); zERROR.GetZErr(Process.ThisProcess()).Report(2, 'G', "npc StartDialog: " + vob.Address, 0, "Client.cs", 0); }
public static Int32 hook_LoadParserFile(String message) { try { int parameterAddress = Convert.ToInt32(message); zString str = new zString(Process.ThisProcess(), Process.ThisProcess().ReadInt(parameterAddress + 4)); zERROR.GetZErr(Process.ThisProcess()).Report(2, 'G', "LoadParserFile: " + str.Value, 0, "Program.cs", 0); zCParser parser = zCParser.getParser(Process.ThisProcess()); parser.Reset(); oCGame.Game(Process.ThisProcess()).DefineExternals_Ulfi(parser); parser.EnableTreeLoad(0); parser.EnableTreeSave(0); GUC.States.StartupState.initDefaultScripts(); zString str2 = zString.Create(Process.ThisProcess(), "C_NPC"); parser.AddClassOffset(str2, 0x120); str2.Dispose(); str2 = zString.Create(Process.ThisProcess(), "C_ITEM"); parser.AddClassOffset(str2, 0x120); str2.Dispose(); parser.MainFileName.Set(GUC.States.StartupState.srcFile); parser.CreatePCode(); parser.Error(); } catch (Exception ex) { zERROR.GetZErr(Process.ThisProcess()).Report(2, 'G', ex.ToString(), 0, "Program.cs", 0); } return(0); }
public void SetKeyInstance(String lockString) { zString zS = zString.Create(Process, lockString); SetKeyInstance(zS); zS.Dispose(); }
public static Int32 setVisual_SaveMode(String message) { try { int address = Convert.ToInt32(message); Process process = Process.ThisProcess(); zString str = new zString(process, process.ReadInt(address + 4)); String stri = str.Value.Trim(); if (stri.Length != 0) { int addr = process.ReadInt(address); if (VobVisual.ContainsKey(addr)) { VobVisual[addr] = stri; } else { VobVisual.Add(addr, stri); } } } catch (Exception ex) { zERROR.GetZErr(Process.ThisProcess()).Report(4, 'G', ex.ToString(), 0, "Program.cs", 0); } return(0); }
public static Int32 hook_LoadDat(String message) { try { int parameterAddress = Convert.ToInt32(message); zString str = new zString(Process.ThisProcess(), Process.ThisProcess().ReadInt(parameterAddress + 4)); if (str.Value.ToUpper().Trim() == "GOTHIC.DAT") { GUC.States.StartupState.initDefaultScripts(); BlockLoadDat(); } else { UnblockLoadDat(); } zERROR.GetZErr(Process.ThisProcess()).Report(2, 'G', "Load-Dat: " + str.Value, 0, "Program.cs", 0); } catch (Exception ex) { zERROR.GetZErr(Process.ThisProcess()).Report(4, 'G', ex.ToString(), 0, "Program.cs", 0); } return(0); }
public void StartAnimation(String str) { zString zStr = zString.Create(Process, str); StartAnimation(zStr); zStr.Dispose(); }
public Text3DRow addRow(Text3DRow tr) { Process process = Process.ThisProcess(); m_Rows.Add(tr); using (zString str = zString.Create(process, tr.Text)) { tr.GText = m_View.CreateText(0x0000 + m_Rows.Count * 100, 0x0000 + m_View.FontY() * m_Rows.Count, str); tr.GText.Timed = 0; tr.GText.Timer = -1; tr.GText.PosX = 0; tr.GText.PosY = 0; tr.GText.Color.R = tr.Color.R; tr.GText.Color.G = tr.Color.G; tr.GText.Color.B = tr.Color.B; tr.GText.Color.A = tr.Color.A; tr.InsertTime = DateTime.Now.Ticks / 10000; } return(tr); }
public int FontSize(String str) { using (zString str2 = zString.Create(Process, str)) { return(FontSize(str2)); } }
public void setFont(String font) { if (font == null) { return; } String oldfont = this.font; this.font = font; if (oldfont.Trim().ToUpper() == font.Trim().ToUpper()) { return; } Process process = Process.ThisProcess(); zString str = zString.Create(process, this.font); thisView.SetFont(str); str.Dispose(); if (textView != null) { textView.Timed = 1; textView.Timer = 0; createText(); setColor(this.color); } }
public static void Printwin(string text) { using (zString z = zString.Create(text)) { Printwin(z); } }
public void SetPickLockStr(String lockString) { zString zS = zString.Create(Process, lockString); SetPickLockStr(zS); zS.Dispose(); }
public void SetUseWithItem(String str) { zString zS = zString.Create(Process, str); SetUseWithItem(zS); zS.Dispose(); }
public void SetVisual(String visual) { zString str = zString.Create(Process, visual); SetVisual(str); str.Dispose(); }
static void VDFS_Open(Hook hook, RegisterMemory mem) { zString path = new zString(mem[Registers.EAX]); string pathStr = path.ToString(); if (pathStr.EndsWith("CAMERA.DAT")) // f**k this { path.Set(@"_WORK\DATA\SCRIPTS\_COMPILED\CAMERA.DAT"); } // check if it exists in vdfs int filePtr = mem[Registers.ESI]; if (Process.THISCALL <BoolArg>(filePtr, 0x449020) && Process.ReadInt(filePtr + 0x2A00) == VDF_VIRTUAL) { return; } // check if it's in the project's folder string projectPath = GetProjectFilePath(pathStr); if (File.Exists(projectPath)) { path.Set(projectPath); } }
public textArea(Process process, zCView view, int height) { this.process = process; this.view = view; fontY = this.view.Font.GetFontY(); fontY = InputHooked.PixelToVirtualY(process, fontY); int lines = height / fontY; zString empty = zString.Create(process, ""); vt = new zCViewText[lines]; for (int i = 0; i < lines; i++) { vt[i] = view.CreateText(0, i * fontY, empty); vt[i].Timed = 0; vt[i].Timer = -1; } empty.Dispose(); Inputenabled = true; InputHooked.receivers.Add(this); }
public void SetPath(string path) { // using (zString z = zString.Create(path)) this causes crashes because the file keeps the zstring zString z = zString.Create(path); Process.THISCALL <NullReturnCall>(this.Address, 0x4455D0, (IntArg)z.VTBL, (IntArg)z.ALLOCATER, (IntArg)z.PTR, (IntArg)z.Length, (IntArg)z.Res); }
public void OutputSVM_Overlay(String output) { if (this.Address == 0) { return; } Process process = Process.ThisProcess(); zString str = zString.Create(process, "guc_string_helper"); zCPar_Symbol sym = zCParser.getParser(process).GetSymbol(str); str.Dispose(); str = zString.Create(process, output); sym.SetValue(str, 0); str.Dispose(); str = zString.Create(process, "MOD_OutputSVM_Overlay"); int id = zCParser.getParser(process).GetIndex(str); str.Dispose(); zCParser.getParser(process).SetInstance(zString.Create(process, "SELF"), this.Address); zCParser.getParser(process).SetInstance(zString.Create(process, "OTHER"), this.Address); zCParser.CallFunc(process, new CallValue[] { new IntArg(zCParser.getParser(process).Address), new IntArg(id) }); }
static void hook_LoadParserFile(Hook hook, RegisterMemory rmem) { try { zString str = new zString(rmem[0]); Logger.Log("LoadParserFile: " + str); Process.THISCALL <NullReturnCall>(0xAB40C0, 0x00793100); //parser.reset Process.THISCALL <NullReturnCall>(Gothic.Session.oCGame.GameAddress, 0x006D4780, new IntArg(0xAB40C0)); //Define_ulfi_externals Process.THISCALL <NullReturnCall>(0xAB40C0, 0x00793460, new IntArg(0)); //parser.enabletreeload(0) Process.THISCALL <NullReturnCall>(0xAB40C0, 0x00793440, new IntArg(0)); //parser.enabletreesave(0) initDefaultScripts(); using (zString z = zString.Create("C_NPC")) Process.THISCALL <NullReturnCall>(0xAB40C0, 0x00794730, z, new IntArg(0x120)); // parser.AddClassOffset using (zString z = zString.Create("C_ITEM")) Process.THISCALL <NullReturnCall>(0xAB40C0, 0x00794730, z, new IntArg(0x120)); // parser.AddClassOffset zString mainfile = new zString(0xAB40C0 + 0x2074); mainfile.Set("GUC.src"); Process.THISCALL <NullReturnCall>(0xAB40C0, 0x007900E0); //parser.createPCode Process.THISCALL <NullReturnCall>(0xAB40C0, 0x0078E730); //parser.error } catch (Exception ex) { Logger.LogError(ex); } }
static void initDefaultScripts() { string dPath = Path.Combine(Program.ProjectPath, @"_work\data\scripts"); if (!Directory.Exists(dPath)) { Directory.CreateDirectory(dPath); } String[] arr = new String[] { "GUC.Resources.Constants.d", "GUC.Resources.Classes.d", "GUC.Resources.AI_Constants.d", "GUC.Resources.BodyStates.d", "GUC.Resources.Focus.d", "GUC.Resources.Species.d", "GUC.Resources.NPC_Default.d" }; StringBuilder fileList = new StringBuilder(100); foreach (String internalFile in arr) { try { using (var rs = Assembly.GetExecutingAssembly().GetManifestResourceStream(internalFile)) { string file = Path.Combine(dPath, internalFile.Substring(14)); //("GUC.Resources.".Length)); using (var fs = new FileStream(file, FileMode.Create, FileAccess.Write)) rs.CopyTo(fs); fileList.AppendLine(Path.GetFileName(file)); //using (zString str = zString.Create(file.ToUpper())) // Process.THISCALL<NullReturnCall>(0xAB40C0, 0x0078F660, str); } } catch (Exception e) { Logger.LogError(internalFile + ": " + e); } } string file_FileList = Path.Combine(dPath, "GUC.src"); File.WriteAllText(file_FileList, fileList.ToString()); Logger.Log("Parse " + file_FileList); using (zString str = zString.Create("GUC.src")) Process.THISCALL <NullReturnCall>(0xAB40C0, 0x0078EE20, str); // zCParse::ParseSource using (zString z = zString.Create("C_NPC")) { int symbol = Process.THISCALL <IntArg>(0xAB40C0, 0x007938D0, z); // parser.GetSymbol Process.THISCALL <NullReturnCall>(symbol, 0x007A2F40, new IntArg(0x120)); //parsymbol.SetClassOffset } using (zString z = zString.Create("C_ITEM")) { int symbol = Process.THISCALL <IntArg>(0xAB40C0, 0x007938D0, z); // parser.GetSymbol Process.THISCALL <NullReturnCall>(symbol, 0x007A2F40, new IntArg(0x120)); //parsymbol.SetClassOffset } Logger.Log("Daedalus scripts parsed!"); }
public static int PlaySound3D(string snd, zCVob vob, int arg, zTSound3DParams param) { int ret; using (zString z = zString.Create(snd)) ret = PlaySound3D(z, vob, arg, param); return(ret); }
public zCVob MergeVobSubTree(string visualName) { zCVob result; using (zString zStr = zString.Create(visualName)) result = MergeVobSubTree(zStr, zCVob.NullVob, 0); return(result); }
public int GetAniIDFromAniName(String animname) { int x; using (zString str = zString.Create(animname)) x = GetAniIDFromAniName(str); return(x); }
public zCOptionEntry GetEntryByName(String name) { zCOptionEntry ret; using (zString str = zString.Create(name)) ret = GetEntryByName(str); return(ret); }