View previous topic :: View next topic |
Author |
Message |
MMM-304 Expert Cheater Reputation: 0
Joined: 17 Aug 2020 Posts: 166 Location: Milkey Way
|
Posted: Tue Aug 31, 2021 12:44 am Post subject: Mono: How to get enums with correct Index |
|
|
How can I get enum (public enum NAME {}) name and correct ID in lua?
CE's dotNet view treats it as a class and the definitions as static fields, but their definitions are clearly visible in dnSpy:
dnSpy:
CE:
I tried this code:
Code: | function getStaticFieldData(namespace,class)
return mono_class_enumFields(mono_findClass(namespace, class))
end
field = getStaticFieldData('Assembly-CSharp','TechType')
return field |
but the offset it returns is 0 for everything
How can I get the right definition offset same as visible from dnSpy in lua?
|
|
Back to top |
|
|
Frouk Master Cheater Reputation: 5
Joined: 22 Jun 2021 Posts: 489 Location: mov dword ptr [Ukraine]
|
Posted: Tue Aug 31, 2021 1:23 am Post subject: |
|
|
try this one :
Code: | function enumStaticFields(dll,class)
local path = mono_findClass(dll,class)
local id = mono_class_getStaticFieldAddress(mono_enumDomains()[5],class)
return id
end --Must be solved, since i've recently used this method |
_________________
void(__cdecl *Haxing)(HWND hGameWindow) |
|
Back to top |
|
|
MMM-304 Expert Cheater Reputation: 0
Joined: 17 Aug 2020 Posts: 166 Location: Milkey Way
|
Posted: Tue Aug 31, 2021 1:56 am Post subject: |
|
|
i think you did not read my question. I DO NOT want the adderss, I want the definition index and name of each entry in enum just like how dnSpy show when hover over:
|
|
Back to top |
|
|
atom0s Moderator Reputation: 198
Joined: 25 Jan 2006 Posts: 8516 Location: 127.0.0.1
|
Posted: Tue Aug 31, 2021 3:52 am Post subject: |
|
|
dnSpy is using reflection to create those tooltips. C# offers a few ways to pull the index of an enum value, such as:
Casting the enum value to its integer representation:
Code: | var val = (int)TechType.BreakableLead |
Obtaining all of the enums values and doing a direct lookup and indexing it:
Code: |
var val = TechType.BreakableLead;
var idx = Array.IndexOf(Enum.GetValues(val.GetType()), val);
|
_________________
- Retired. |
|
Back to top |
|
|
MMM-304 Expert Cheater Reputation: 0
Joined: 17 Aug 2020 Posts: 166 Location: Milkey Way
|
Posted: Tue Aug 31, 2021 6:09 am Post subject: |
|
|
how do I get that through lua?
Additional question: How do I use CS Compiler in CE 7.3
|
|
Back to top |
|
|
Frouk Master Cheater Reputation: 5
Joined: 22 Jun 2021 Posts: 489 Location: mov dword ptr [Ukraine]
|
Posted: Tue Aug 31, 2021 7:12 am Post subject: |
|
|
To use cs compiler you need to create aa script and inside of it type: Code: | {$c}
//Insert your code here
{$asm} |
EDIT:
Maybe this topic will help you[/url]
_________________
void(__cdecl *Haxing)(HWND hGameWindow) |
|
Back to top |
|
|
|