Skip to content

Commit ecadb35

Browse files
authored
Merge pull request #4 from Guila767/copilot/fix-a88a895d-0c69-473f-9bc5-9984ff14555d
Normalize all Portuguese content to English across codebase
2 parents 3a73414 + 2447b25 commit ecadb35

8 files changed

Lines changed: 51 additions & 51 deletions

File tree

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ CMakeLists.txt.user
1616
*.obj
1717
*.iobj
1818
*.idb
19-
*.aps
19+
*.aps__pycache__/

CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

include/plib/pe/export_utils.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ static inline const void *to_address(T p)
1515
}
1616
else
1717
{
18-
static_assert(std::is_integral_v<T>, "Use ponteiro de funcao ou inteiro pointer-sized.");
18+
static_assert(std::is_integral_v<T>, "Use function pointer or pointer-sized integer.");
1919
return reinterpret_cast<const void *>(static_cast<std::uintptr_t>(p));
2020
}
2121
}
@@ -59,11 +59,11 @@ namespace plib::pe::export_utils
5959
auto va = reinterpret_cast<std::uintptr_t>(addr);
6060
std::uintptr_t rva = va - base;
6161

62-
// Sanidade: confirme que o RVA cai dentro do image
62+
// Sanity check: confirm that the RVA falls within the image
6363
const std::uintptr_t sizeOfImage = nt->OptionalHeader.SizeOfImage;
6464
if (rva >= sizeOfImage)
6565
{
66-
// Pode ser um trampolim fora das seções do image (ex.: hook/jit).
66+
// May be a trampoline outside the image sections (e.g.: hook/jit).
6767
return std::nullopt;
6868
}
6969

@@ -90,11 +90,11 @@ namespace plib::pe::export_utils
9090
auto va = reinterpret_cast<std::uintptr_t>(addr);
9191
std::uintptr_t rva = va - base;
9292

93-
// Sanidade: confirme que o RVA cai dentro do image
93+
// Sanity check: confirm that the RVA falls within the image
9494
const std::uintptr_t sizeOfImage = nt->OptionalHeader.SizeOfImage;
9595
if (rva >= sizeOfImage)
9696
{
97-
// Pode ser um trampolim fora das seções do image (ex.: hook/jit).
97+
// May be a trampoline outside the image sections (e.g.: hook/jit).
9898
return std::nullopt;
9999
}
100100

include/plib/rl/rl_loader.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@ extern "C" {
1313
#endif
1414

1515
typedef struct RL_TLS_STATE {
16-
BOOL has_tls; // existe diretório TLS?
17-
DWORD tls_index; // índice alocado via TlsAlloc (process-scope)
16+
BOOL has_tls; // does TLS directory exist?
17+
DWORD tls_index; // index allocated via TlsAlloc (process-scope)
1818
SIZE_T template_size; // (End - Start) + SizeOfZeroFill
19-
SIZE_T align; // alinhamento desejado (opcional: >= 8/16)
20-
PVOID raw_start_va; // VA (relocado) StartAddressOfRawData
19+
SIZE_T align; // desired alignment (optional: >= 8/16)
20+
PVOID raw_start_va; // VA (relocated) StartAddressOfRawData
2121
PVOID raw_end_va; // VA EndAddressOfRawData
2222
SIZE_T zero_fill; // SizeOfZeroFill
23-
PVOID* p_index_va; // VA onde escrever o índice (AddressOfIndex)
24-
PVOID* callbacks_va; // VA do array NULL-terminated de callbacks
23+
PVOID* p_index_va; // VA where to write the index (AddressOfIndex)
24+
PVOID* callbacks_va; // VA of NULL-terminated array of callbacks
2525
} RL_TLS_STATE;
2626

2727
typedef struct RL_IMG_INFO {

include/plib/rl/rl_tls.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,17 @@ extern "C" {
88
#endif
99

1010

11-
// 0) Descoberta: parse do TLS directory e preenchimento do RL_TLS_STATE
11+
// 0) Discovery: parse TLS directory and fill RL_TLS_STATE
1212
NTSTATUS RlTlsDiscover(RL_IMAGE* img);
1313

14-
// 1) Processo: ligar o módulo ao TLS global do Windows
14+
// 1) Process: link module to Windows global TLS
1515
NTSTATUS RlTlsProcessAttach(RL_IMAGE* img);
1616

17-
// 2) Thread: preparar/desmontar bloco TLS deste módulo para threads que usarão a DLL
17+
// 2) Thread: prepare/dismantle TLS block of this module for threads that will use the DLL
1818
NTSTATUS RlTlsThreadAttach(RL_IMAGE* img);
1919
NTSTATUS RlTlsThreadDetach(RL_IMAGE* img);
2020

21-
// 3) Processo: detach final (callbacks + liberar índice)
21+
// 3) Process: final detach (callbacks + free index)
2222
NTSTATUS RlTlsProcessDetach(RL_IMAGE* img);
2323

2424
NTSTATUS RlTlsInvokeCallbacks(const RL_IMAGE* img,

lib/src/rl/rl_loader.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ NTSTATUS RlInitImageFromKnownDll(LPCSTR dllName, RL_IMAGE* img_out) {
155155

156156
auto& src_image = img_out->src_image;
157157

158-
src_image.base.image = mod; // será liberado por FreeLibrary
158+
src_image.base.image = mod; // will be freed by FreeLibrary
159159
src_image.is_image = true;
160160
src_image.info.size = nt->OptionalHeader.SizeOfImage;
161161
src_image.info.reserved_size = nt->OptionalHeader.SizeOfImage;
@@ -168,7 +168,7 @@ NTSTATUS RlInitImageFromKnownDll(LPCSTR dllName, RL_IMAGE* img_out) {
168168
NTSTATUS RlMapImageAt(RL_IMAGE* img, void* target_base, size_t target_size) {
169169
RL_RETURN_IF_NOT(img && img->src_image.nt && target_base, STATUS_INVALID_PARAMETER);
170170

171-
// Base da origem (única)
171+
// Source base (unique)
172172
const BYTE* const src_bytes = img->src_image.base.raw;
173173
if (!src_bytes) return STATUS_INVALID_PARAMETER;
174174

@@ -192,7 +192,7 @@ NTSTATUS RlMapImageAt(RL_IMAGE* img, void* target_base, size_t target_size) {
192192
const DWORD raw = sec->SizeOfRawData;
193193
const DWORD virt = sec->Misc.VirtualSize ? sec->Misc.VirtualSize : raw;
194194

195-
// bound por imagem (não por blob; o blob já foi validado)
195+
// bound by image (not by blob; the blob was already validated)
196196
RL_ASSERT((SIZE_T)va + (SIZE_T)virt <= size_image);
197197

198198
BYTE* dst = dst_base + va;
@@ -201,14 +201,14 @@ NTSTATUS RlMapImageAt(RL_IMAGE* img, void* target_base, size_t target_size) {
201201

202202
if (src_img.is_image)
203203
{
204-
// origem em layout de imagem (VA)
204+
// source in image layout (VA)
205205
src = src_bytes + va; // <<< usa a base correta
206206
SIZE_T raw_aligned = AlignUp((SIZE_T)raw, (SIZE_T)file_align);
207207
ncopy_bytes = raw ? std::min<SIZE_T>(virt, raw_aligned) : 0;
208208
}
209209
else
210210
{
211-
// origem em layout de arquivo (RAW)
211+
// source in file layout (RAW)
212212
src = (raw && sec->PointerToRawData)
213213
? (src_bytes + sec->PointerToRawData)
214214
: nullptr;

lib/src/rl/rl_tls.cpp

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,16 @@ NTSTATUS RlTlsDiscover(RL_IMAGE *img)
1010

1111
RL_TLS_STATE* const out = &img->tls;
1212

13-
// 1) Localizar diretório TLS
13+
// 1) Locate TLS directory
1414
auto &dd = img->nt->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_TLS];
1515
if (!dd.VirtualAddress || !dd.Size)
1616
{
1717
out->has_tls = FALSE;
18-
return STATUS_SUCCESS; // nada a fazer
18+
return STATUS_SUCCESS; // nothing to do
1919
}
2020
out->has_tls = TRUE;
2121

22-
// 2) Ler IMAGE_TLS_DIRECTORY (endereços já estão relocados, pois você já aplicou relocs)
22+
// 2) Read IMAGE_TLS_DIRECTORY (addresses are already relocated, since you already applied relocs)
2323
#ifdef _WIN64
2424
auto tls = reinterpret_cast<PIMAGE_TLS_DIRECTORY64>(img->base + dd.VirtualAddress);
2525
#else
@@ -32,14 +32,14 @@ NTSTATUS RlTlsDiscover(RL_IMAGE *img)
3232
out->p_index_va = reinterpret_cast<PVOID *>(tls->AddressOfIndex);
3333
out->callbacks_va = reinterpret_cast<PVOID *>(tls->AddressOfCallBacks);
3434

35-
// 3) Tamanho do template (+ zero fill) e alinhamento (use algo seguro, p.ex. 16 em x64)s
35+
// 3) Template size (+ zero fill) and alignment (use something safe, e.g. 16 on x64)s
3636
SIZE_T tpl = 0;
3737
if (out->raw_end_va >= out->raw_start_va)
3838
{
3939
tpl = (SIZE_T)((BYTE *)out->raw_end_va - (BYTE *)out->raw_start_va);
4040
}
4141
out->template_size = tpl + out->zero_fill;
42-
out->align = sizeof(void *) >= 8 ? 16 : 8; // ajuste se quiser ler de Characteristics/section
42+
out->align = sizeof(void *) >= 8 ? 16 : 8; // adjust if you want to read from Characteristics/section
4343

4444
return STATUS_SUCCESS;
4545
}
@@ -52,13 +52,13 @@ NTSTATUS RlTlsProcessAttach(RL_IMAGE *img)
5252

5353
RL_TLS_STATE* const st = &img->tls;
5454

55-
// 1) Alocar índice TLS do Windows
55+
// 1) Allocate Windows TLS index
5656
DWORD idx = TlsAlloc();
5757
if (idx == TLS_OUT_OF_INDEXES)
5858
return STATUS_INSUFFICIENT_RESOURCES;
5959
st->tls_index = idx;
6060

61-
// 2) Escrever índice em AddressOfIndex (é um DWORD mesmo em x64)
61+
// 2) Write index to AddressOfIndex (it's a DWORD even on x64)
6262
DWORD oldProt = 0;
6363
if (st->p_index_va)
6464
{
@@ -67,11 +67,11 @@ NTSTATUS RlTlsProcessAttach(RL_IMAGE *img)
6767
VirtualProtect(st->p_index_va, sizeof(DWORD), oldProt, &oldProt);
6868
}
6969

70-
// 3) Criar bloco TLS para o THREAD ATUAL e setar no slot
70+
// 3) Create TLS block for CURRENT THREAD and set in slot
7171
if (st->template_size)
7272
{
7373
SIZE_T size = st->template_size;
74-
// Alocar com alinhamento desejado (pode ser HeapAlloc simples; alinhe manualmente se precisar)
74+
// Allocate with desired alignment (can be simple HeapAlloc; align manually if needed)
7575
BYTE *block = (BYTE *)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size + st->align);
7676
if (!block)
7777
return STATUS_INSUFFICIENT_RESOURCES;
@@ -81,7 +81,7 @@ NTSTATUS RlTlsProcessAttach(RL_IMAGE *img)
8181
if (tpl && st->raw_start_va)
8282
{
8383
memcpy(block, st->raw_start_va, tpl);
84-
// resto já está zerado pelo HEAP_ZERO_MEMORY
84+
// rest is already zeroed by HEAP_ZERO_MEMORY
8585
}
8686
if (!TlsSetValue(idx, block))
8787
{
@@ -110,7 +110,7 @@ NTSTATUS RlTlsThreadAttach(RL_IMAGE* img)
110110

111111
const RL_TLS_STATE* const st = &img->tls;
112112

113-
// 1) Alocar + copiar template para ESTE thread
113+
// 1) Allocate + copy template for THIS thread
114114
BYTE *block = nullptr;
115115
if (st->template_size)
116116
{
@@ -157,8 +157,8 @@ NTSTATUS RlTlsThreadDetach(RL_IMAGE *img)
157157
}
158158
}
159159

160-
// 2) Liberar bloco TLS do thread (se houver) e limpar o slot
161-
void *block = TlsGetValue(st->tls_index); // ok mesmo se falhar; ERROR_INVALID_INDEX não se aplica
160+
// 2) Free TLS block from thread and clean slot
161+
void *block = TlsGetValue(st->tls_index); // ok even if it fails; ERROR_INVALID_INDEX doesn't apply
162162
if (block)
163163
HeapFree(GetProcessHeap(), 0, block);
164164
TlsSetValue(st->tls_index, nullptr);
@@ -182,10 +182,10 @@ NTSTATUS RlTlsProcessDetach(RL_IMAGE *img)
182182
}
183183
}
184184

185-
// 2) Liberar índice TLS
185+
// 2) Free TLS index
186186
if (st->tls_index != TLS_OUT_OF_INDEXES)
187187
{
188-
// (Qualquer bloco remanescente por thread deveria ter sido limpo em ThreadDetach)
188+
// (Any remaining block per thread should have been cleaned in ThreadDetach)
189189
TlsFree(st->tls_index);
190190
st->tls_index = TLS_OUT_OF_INDEXES;
191191
}

tools/gen_def.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ def write_line(self, s: str = ""):
100100
self._buf.write(s)
101101
self._buf.write(self._newline)
102102

103-
# alias com o nome que você pediu
103+
# alias with the name you requested
104104
def write_line_ident(self, s: str = ""):
105105
return self.write_line_indent(s)
106106

@@ -257,15 +257,15 @@ def emit_asm_thunks_x86(path: Path, dialect: AsmDialect,
257257
# ---------------------------
258258

259259
def main(argv: list[str]) -> int:
260-
ap = argparse.ArgumentParser(description="Gera .def e stubs referenciando um símbolo de blob (sem stage-1).")
260+
ap = argparse.ArgumentParser(description="Generate .def and stubs referencing a blob symbol (without stage-1).")
261261
ap.add_argument("--debug", action="store_true", help="Wait for debugger")
262-
ap.add_argument("source_dll", help="DLL de origem (ex: version.dll ou caminho absoluto).")
263-
ap.add_argument("out_def", help="Caminho do .def a ser gerado.")
264-
ap.add_argument("--out-asm", required=True, help="Caminho do .asm (stubs) a ser gerado.")
265-
ap.add_argument("--out-json", default=None, help="(Opcional) Dump JSON do mapa de RVAs.")
266-
ap.add_argument("--libname", default=None, help="Nome de biblioteca no .def (padrão: nome base do source_dll).")
267-
ap.add_argument("--blob-symbol", default="g_reflect_blob", help="Símbolo do blob na DLL proxy (default: g_reflect_blob).")
268-
ap.add_argument("--asm-dialect", default="masm", choices=["masm", "nasm"], help="Dialeto ASM a ser usado (padrão: masm).")
262+
ap.add_argument("source_dll", help="Source DLL (e.g.: version.dll or absolute path).")
263+
ap.add_argument("out_def", help="Path of .def file to be generated.")
264+
ap.add_argument("--out-asm", required=True, help="Path of .asm (stubs) file to be generated.")
265+
ap.add_argument("--out-json", default=None, help="(Optional) JSON dump of RVA mapping.")
266+
ap.add_argument("--libname", default=None, help="Library name in .def (default: base name of source_dll).")
267+
ap.add_argument("--blob-symbol", default="g_reflect_blob", help="Blob symbol in proxy DLL (default: g_reflect_blob).")
268+
ap.add_argument("--asm-dialect", default="masm", choices=["masm", "nasm"], help="ASM dialect to be used (default: masm).")
269269
args = ap.parse_args(argv)
270270

271271
if args.debug:
@@ -287,7 +287,7 @@ def main(argv: list[str]) -> int:
287287
if not source_dll.is_absolute() and source_dll.exists() is False:
288288
source_dll = get_known_dll(args.source_dll)
289289
if not source_dll or not source_dll.exists():
290-
raise FileNotFoundError(f"Não foi possível encontrar a DLL de origem: {args.source_dll}")
290+
raise FileNotFoundError(f"Could not find the source DLL: {args.source_dll}")
291291
src_pe = pefile.PE(source_dll)
292292
machine = get_machine(src_pe)
293293
exports = read_exports(src_pe)
@@ -315,13 +315,13 @@ def main(argv: list[str]) -> int:
315315
base = f"thunk_{e.ordinal}"
316316
internal_sym_for[key] = sanitize_internal(base)
317317

318-
# Nome da LIB no .def
318+
# LIB name in .def
319319
if args.libname:
320320
libname = args.libname
321321
else:
322322
libname = Path(args.source_dll).stem
323323

324-
# Emitir arquivos
324+
# Emit files
325325
out_def = Path(args.out_def)
326326
out_asm = Path(args.out_asm)
327327

@@ -332,7 +332,7 @@ def main(argv: list[str]) -> int:
332332
elif machine == "x86":
333333
emit_asm_thunks_x86(out_asm, args.asm_dialect, args.blob_symbol, new_rvas, internal_sym_for)
334334
else:
335-
raise SystemExit(f"Arquitetura {machine} ainda não suportada.")
335+
raise SystemExit(f"Architecture {machine} not yet supported.")
336336

337337
if args.out_json:
338338
j = {

0 commit comments

Comments
 (0)